Crossfire Server, Trunk  R21246
plugins.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
22 #if 0
23 
24 #define PLUGIN_DEBUG
25 #endif
26 
27 /*****************************************************************************/
28 /* First, the headers. We only include plugin.h, because all other includes */
29 /* are done into it, and plugproto.h (which is used only by this file). */
30 /*****************************************************************************/
31 
32 #include <assert.h>
33 #include <stdlib.h>
34 #include <string.h>
35 
36 #include "plugin.h"
37 #include "shop.h"
38 #include "sproto.h"
39 #include "svnversion.h"
40 #include "timers.h"
41 
43 #define NR_OF_HOOKS (sizeof(plug_hooks)/sizeof(*plug_hooks))
44 
45 static void cfapi_cost_string_from_value(int *type, ...);
46 static void cfapi_system_find_animation(int *type, ...);
47 static void cfapi_system_find_face(int *type, ...);
48 static void cfapi_system_strdup_local(int *type, ...);
49 static void cfapi_system_register_global_event(int *type, ...);
50 static void cfapi_system_unregister_global_event(int *type, ...);
51 static void cfapi_system_add_string(int *type, ...);
52 static void cfapi_system_remove_string(int *type, ...);
53 static void cfapi_system_find_string(int *type, ...);
54 static void cfapi_system_check_path(int *type, ...);
55 static void cfapi_system_re_cmp(int *type, ...);
56 static void cfapi_system_directory(int *type, ...);
57 static void cfapi_get_time(int *type, ...);
58 static void cfapi_get_season_name(int *type, ...);
59 static void cfapi_get_weekday_name(int *type, ...);
60 static void cfapi_get_month_name(int *type, ...);
61 static void cfapi_get_periodofday_name(int *type, ...);
62 static void cfapi_timer_create(int *type, ...);
63 static void cfapi_timer_destroy(int *type, ...);
64 static void cfapi_log(int *type, ...);
65 static void cfapi_map_get_map(int *type, ...);
66 static void cfapi_map_has_been_loaded(int *type, ...);
67 static void cfapi_map_create_path(int *type, ...);
68 static void cfapi_map_get_map_property(int *type, ...);
69 static void cfapi_map_set_map_property(int *type, ...);
70 static void cfapi_map_out_of_map(int *type, ...);
71 static void cfapi_map_update_position(int *type, ...);
72 static void cfapi_map_delete_map(int *type, ...);
73 static void cfapi_map_message(int *type, ...);
74 static void cfapi_map_get_object_at(int *type, ...);
75 static void cfapi_map_find_by_archetype_name(int *type, ...);
76 static void cfapi_map_change_light(int *type, ...);
77 static void cfapi_object_move(int *type, ...);
78 static void cfapi_object_get_key(int *type, ...);
79 static void cfapi_object_set_key(int *type, ...);
80 static void cfapi_object_get_property(int *type, ...);
81 static void cfapi_object_set_property(int *type, ...);
82 static void cfapi_object_apply_below(int *type, ...);
83 static void cfapi_object_apply(int *type, ...);
84 static void cfapi_object_identify(int *type, ...);
85 static void cfapi_object_describe(int *type, ...);
86 static void cfapi_object_drain(int *type, ...);
87 static void cfapi_object_remove_depletion(int *type, ...);
88 static void cfapi_object_fix(int *type, ...);
89 static void cfapi_object_give_skill(int *type, ...);
90 static void cfapi_object_transmute(int *type, ...);
91 static void cfapi_object_remove(int *type, ...);
92 static void cfapi_object_delete(int *type, ...);
93 static void cfapi_object_clone(int *type, ...);
94 static void cfapi_object_create(int *type, ...);
95 static void cfapi_object_insert(int *type, ...);
96 static void cfapi_object_split(int *type, ...);
97 static void cfapi_object_merge(int *type, ...);
98 static void cfapi_object_distance(int *type, ...);
99 static void cfapi_object_update(int *type, ...);
100 static void cfapi_object_clear(int *type, ...);
101 static void cfapi_object_reset(int *type, ...);
102 static void cfapi_object_clean_object(int *type, ...);
103 static void cfapi_object_on_same_map(int *type, ...);
104 static void cfapi_object_spring_trap(int *type, ...);
105 static void cfapi_object_check_trigger(int *type, ...);
106 static void cfapi_map_trigger_connected(int *type, ...);
107 static void cfapi_object_query_money(int *type, ...);
108 static void cfapi_object_cast(int *type, ...);
109 static void cfapi_object_learn_spell(int *type, ...);
110 static void cfapi_object_forget_spell(int *type, ...);
111 static void cfapi_object_check_spell(int *type, ...);
112 static void cfapi_object_pay_amount(int *type, ...);
113 static void cfapi_object_pay_item(int *type, ...);
114 static void cfapi_object_transfer(int *type, ...);
115 static void cfapi_object_find_archetype_inside(int *type, ...);
116 static void cfapi_object_find_by_arch_name(int *type, ...);
117 static void cfapi_object_find_by_name(int *type, ...);
118 static void cfapi_object_drop(int *type, ...);
119 static void cfapi_object_change_abil(int *type, ...);
120 static void cfapi_object_say(int *type, ...);
121 static void cfapi_player_find(int *type, ...);
122 static void cfapi_player_message(int *type, ...);
123 static void cfapi_object_change_exp(int *type, ...);
124 static void cfapi_player_can_pay(int *type, ...);
125 static void cfapi_player_knowledge(int *type, ...);
126 static void cfapi_object_teleport(int *type, ...);
127 static void cfapi_object_pickup(int *type, ...);
128 static void cfapi_archetype_get_property(int *type, ...);
129 static void cfapi_party_get_property(int *type, ...);
130 static void cfapi_region_get_property(int *type, ...);
131 static void cfapi_friendlylist_get_next(int *type, ...);
132 static void cfapi_set_random_map_variable(int *type, ...);
133 static void cfapi_generate_random_map(int *type, ...);
134 static void cfapi_object_user_event(int *type, ...);
135 static void cfapi_player_quest(int *type, ...);
136 
140 static const hook_entry plug_hooks[] = {
141  { cfapi_system_add_string, 0, "cfapi_system_add_string" },
142  { cfapi_system_register_global_event, 1, "cfapi_system_register_global_event" },
143  { cfapi_system_remove_string, 2, "cfapi_system_remove_string" },
144  { cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event" },
145  { cfapi_system_check_path, 4, "cfapi_system_check_path" },
146  { cfapi_system_re_cmp, 5, "cfapi_system_re_cmp" },
147  { cfapi_system_strdup_local, 6, "cfapi_system_strdup_local" },
148  { cfapi_system_directory, 7, "cfapi_system_directory" },
149  { cfapi_system_find_animation, 8, "cfapi_system_find_animation" },
150  { cfapi_object_clean_object, 9, "cfapi_object_clean_object" },
151  { cfapi_object_on_same_map, 10, "cfapi_object_on_same_map" },
152  { cfapi_object_get_key, 11, "cfapi_object_get_key" },
153  { cfapi_object_set_key, 12, "cfapi_object_set_key" },
154  { cfapi_object_get_property, 13, "cfapi_object_get_property" },
155  { cfapi_object_set_property, 14, "cfapi_object_set_property" },
156  { cfapi_object_apply, 15, "cfapi_object_apply" },
157  { cfapi_object_identify, 16, "cfapi_object_identify" },
158  { cfapi_object_describe, 17, "cfapi_object_describe" },
159  { cfapi_object_drain, 18, "cfapi_object_drain" },
160  { cfapi_object_fix, 19, "cfapi_object_fix" },
161  { cfapi_object_give_skill, 20, "cfapi_object_give_skill" },
162  { cfapi_object_transmute, 21, "cfapi_object_transmute" },
163  { cfapi_object_remove, 22, "cfapi_object_remove" },
164  { cfapi_object_delete, 23, "cfapi_object_delete" },
165  { cfapi_object_clone, 24, "cfapi_object_clone" },
166  { cfapi_object_create, 26, "cfapi_object_create" },
167  { cfapi_object_insert, 27, "cfapi_object_insert" },
168  { cfapi_object_split, 28, "cfapi_object_split" },
169  { cfapi_object_merge, 29, "cfapi_object_merge" },
170  { cfapi_object_distance, 30, "cfapi_object_distance" },
171  { cfapi_object_update, 31, "cfapi_object_update" },
172  { cfapi_object_clear, 32, "cfapi_object_clear" },
173  { cfapi_object_reset, 33, "cfapi_object_reset" },
174  { cfapi_object_spring_trap, 35, "cfapi_object_spring_trap" },
175  { cfapi_object_check_trigger, 36, "cfapi_object_check_trigger" },
176  { cfapi_object_query_money, 38, "cfapi_object_query_money" },
177  { cfapi_object_cast, 39, "cfapi_object_cast" },
178  { cfapi_object_learn_spell, 40, "cfapi_object_learn_spell" },
179  { cfapi_object_forget_spell, 41, "cfapi_object_forget_spell" },
180  { cfapi_object_check_spell, 42, "cfapi_object_check_spell" },
181  { cfapi_object_pay_amount, 43, "cfapi_object_pay_amount" },
182  { cfapi_object_pay_item, 44, "cfapi_object_pay_item" },
183  { cfapi_object_transfer, 45, "cfapi_object_transfer" },
184  { cfapi_object_drop, 46, "cfapi_object_drop" },
185  { cfapi_object_change_abil, 47, "cfapi_object_change_abil" },
186  { cfapi_object_find_archetype_inside, 48, "cfapi_object_find_archetype_inside" },
187  { cfapi_object_say, 49, "cfapi_object_say" },
188  { cfapi_map_get_map, 50, "cfapi_map_get_map" },
189  { cfapi_map_has_been_loaded, 51, "cfapi_map_has_been_loaded" },
190  { cfapi_map_create_path, 52, "cfapi_map_create_path" },
191  { cfapi_map_get_map_property, 53, "cfapi_map_get_property" },
192  { cfapi_map_set_map_property, 54, "cfapi_map_set_property" },
193  { cfapi_map_out_of_map, 55, "cfapi_map_out_of_map" },
194  { cfapi_map_update_position, 56, "cfapi_map_update_position" },
195  { cfapi_map_delete_map, 57, "cfapi_map_delete_map" },
196  { cfapi_map_message, 58, "cfapi_map_message" },
197  { cfapi_map_get_object_at, 59, "cfapi_map_get_object_at" },
198  { cfapi_map_change_light, 60, "cfapi_map_change_light" },
199  { cfapi_map_find_by_archetype_name, 61, "cfapi_map_find_by_archetype_name" },
200  { cfapi_player_find, 62, "cfapi_player_find" },
201  { cfapi_player_message, 63, "cfapi_player_message" },
202  { cfapi_object_change_exp, 64, "cfapi_object_change_exp" },
203  { cfapi_object_teleport, 65, "cfapi_object_teleport" },
204  { cfapi_object_pickup, 67, "cfapi_object_pickup" },
205  { cfapi_object_move, 68, "cfapi_object_move" },
206  { cfapi_object_apply_below, 69, "cfapi_object_apply_below" },
207  { cfapi_generate_random_map, 70, "cfapi_generate_random_map" },
208  { cfapi_archetype_get_property, 71, "cfapi_archetype_get_property" },
209  { cfapi_party_get_property, 72, "cfapi_party_get_property" },
210  { cfapi_region_get_property, 73, "cfapi_region_get_property" },
211  { cfapi_player_can_pay, 74, "cfapi_player_can_pay" },
212  { cfapi_log, 75, "cfapi_log" },
213  { cfapi_get_time, 76, "cfapi_system_get_time" },
214  { cfapi_timer_create, 77, "cfapi_system_timer_create" },
215  { cfapi_timer_destroy, 78, "cfapi_system_timer_destroy" },
216  { cfapi_friendlylist_get_next, 79, "cfapi_friendlylist_get_next" },
217  { cfapi_set_random_map_variable, 80, "cfapi_set_random_map_variable" },
218  { cfapi_system_find_face, 81, "cfapi_system_find_face" },
219  { cfapi_get_season_name, 82, "cfapi_system_get_season_name" },
220  { cfapi_get_month_name, 83, "cfapi_system_get_month_name" },
221  { cfapi_get_weekday_name, 84, "cfapi_system_get_weekday_name" },
222  { cfapi_get_periodofday_name, 85, "cfapi_system_get_periodofday_name" },
223  { cfapi_map_trigger_connected, 86, "cfapi_map_trigger_connected" },
224  { cfapi_object_user_event, 87, "cfapi_object_user_event" },
225  { cfapi_system_find_string, 88, "cfapi_system_find_string" },
226  { cfapi_cost_string_from_value, 90, "cfapi_cost_string_from_value" },
227  { cfapi_player_quest, 91, "cfapi_player_quest" },
228  { cfapi_object_remove_depletion, 92, "cfapi_object_remove_depletion" },
229  { cfapi_object_find_by_arch_name, 93, "cfapi_object_find_by_arch_name" },
230  { cfapi_object_find_by_name, 94, "cfapi_object_find_by_name" },
231  { cfapi_player_knowledge, 95, "cfapi_player_knowledge" }
232 };
233 
236 
237 /*****************************************************************************/
238 /* NEW PLUGIN STUFF STARTS HERE */
239 /*****************************************************************************/
240 
246 static crossfire_plugin *plugins_find_plugin(const char *id) {
247  crossfire_plugin *cp;
248 
249  if (plugins_list == NULL)
250  return NULL;
251 
252  for (cp = plugins_list; cp != NULL; cp = cp->next) {
253  if (!strcmp(id, cp->id)) {
254  return cp;
255  }
256  }
257  return NULL;
258 }
259 
260 #ifdef WIN32
261 static const char *plugins_dlerror(void) {
262  static char buf[256];
263  DWORD err;
264  char *p;
265 
266  err = GetLastError();
267  if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof(buf), NULL) == 0)
268  snprintf(buf, sizeof(buf), "error %lu", err);
269  p = strchr(buf, '\0');
270  while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
271  p--;
272  *p = '\0';
273  return buf;
274 }
275 #endif /* WIN32 */
276 
282 static void send_changed_object(object *op) {
283  object *tmp;
284  player *pl;
285 
286  if (op->env != NULL) {
287  tmp = object_get_player_container(op->env);
288  if (!tmp) {
289  for (pl = first_player; pl; pl = pl->next)
290  if (pl->ob->container == op->env)
291  break;
292  if (pl)
293  tmp = pl->ob;
294  else
295  tmp = NULL;
296  }
297  if (tmp)
298  /* We don't know what changed, so we send everything. */
299  esrv_update_item(UPD_ALL, tmp, op);
300  } else {
301  FOR_ABOVE_PREPARE(op, tmp)
302  if (tmp->type == PLAYER)
303  tmp->contr->socket.update_look = 1;
305  }
306 }
307 
308 int user_event(object *op, object *activator, object *third, const char *message, int fix) {
309  return execute_event(op, EVENT_USER, activator, third, message, fix);
310 }
311 
312 static int do_execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix, talk_info *talk) {
313  crossfire_plugin *plugin;
314  int rv = 0;
315 
316  FOR_INV_PREPARE(op, tmp) {
317  if (tmp->type == EVENT_CONNECTOR && tmp->subtype == eventcode) {
318 #ifdef PLUGIN_DEBUG
319  LOG(llevDebug, "********** EVENT HANDLER **********\n");
320  LOG(llevDebug, " - Who am I :%s\n", op->name);
321  if (activator != NULL)
322  LOG(llevDebug, " - Activator :%s\n", activator->name);
323  if (third != NULL)
324  LOG(llevDebug, " - Other object :%s\n", third->name);
325  LOG(llevDebug, " - Event code :%d\n", tmp->subtype);
326  if (tmp->title != NULL)
327  LOG(llevDebug, " - Event plugin :%s\n", tmp->title);
328  if (tmp->slaying != NULL)
329  LOG(llevDebug, " - Event hook :%s\n", tmp->slaying);
330  if (tmp->name != NULL)
331  LOG(llevDebug, " - Event options :%s\n", tmp->name);
332 #endif
333 
334  if (tmp->title == NULL) {
335  object *env = object_get_env_recursive(tmp);
336  LOG(llevError, "Event object without title at %d/%d in map %s\n", env->x, env->y, env->map->name);
337  object_remove(tmp);
339  } else if (tmp->slaying == NULL) {
340  object *env = object_get_env_recursive(tmp);
341  LOG(llevError, "Event object without slaying at %d/%d in map %s\n", env->x, env->y, env->map->name);
342  object_remove(tmp);
344  } else {
345  plugin = plugins_find_plugin(tmp->title);
346  if (plugin == NULL) {
347  object *env = object_get_env_recursive(tmp);
348  LOG(llevError, "The requested plugin doesn't exist: %s at %d/%d in map %s\n", tmp->title, env->x, env->y, env->map->name);
349  object_remove(tmp);
351  } else {
352  int rvt = 0;
353  int rv;
354 
355  tag_t oldtag = op->count;
356  rv = plugin->eventfunc(&rvt, op, activator, third, message, fix, tmp, talk);
357  if (object_was_destroyed(op, oldtag)) {
358  return rv;
359  }
360  if (QUERY_FLAG(tmp, FLAG_UNIQUE)) {
361 #ifdef PLUGIN_DEBUG
362  LOG(llevDebug, "Removing unique event %s\n", tmp->slaying);
363 #endif
364  object_remove(tmp);
366  }
367  return rv;
368  }
369  }
370  }
371  } FOR_INV_FINISH();
372  return rv;
373 }
374 
375 int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix) {
376  return do_execute_event(op, eventcode, activator, third, message, fix, NULL);
377 }
378 
379 int plugin_event_say(object *npc, talk_info *talk) {
380  return do_execute_event(npc, EVENT_SAY, talk->who, NULL, talk->text, SCRIPT_FIX_ALL, talk);
381 }
382 
383 int execute_global_event(int eventcode, ...) {
384  va_list args;
385  mapstruct *map;
386  object *op;
387  object *op2;
388  player *pl;
389  const char *buf;
390  int i, rt;
391  crossfire_plugin *cp;
392 
393  if (plugins_list == NULL)
394  return -1;
395 
396  va_start(args, eventcode);
397 
398  switch (eventcode) {
399  case EVENT_BORN:
400  /*BORN: op*/
401  op = va_arg(args, object *);
402  for (cp = plugins_list; cp != NULL; cp = cp->next) {
403  if (cp->gevent[eventcode] != NULL)
404  cp->gevent[eventcode](&rt, eventcode, op);
405  }
406  break;
407 
408  case EVENT_CLOCK:
409  /*CLOCK: -*/
410  for (cp = plugins_list; cp != NULL; cp = cp->next) {
411  if (cp->gevent[eventcode] != NULL)
412  cp->gevent[eventcode](&rt, eventcode);
413  }
414  break;
415 
416  case EVENT_CRASH:
417  for (cp = plugins_list; cp != NULL; cp = cp->next) {
418  if (cp->gevent[eventcode] != NULL)
419  cp->gevent[eventcode](&rt, eventcode);
420  }
421  break;
422 
423  case EVENT_PLAYER_DEATH:
424  /*PLAYER_DEATH: op*/
425  op = va_arg(args, object *);
426  op2 = va_arg(args, object *);
427  for (cp = plugins_list; cp != NULL; cp = cp->next) {
428  if (cp->gevent[eventcode] != NULL)
429  cp->gevent[eventcode](&rt, eventcode, op, op2);
430  }
431  break;
432 
433  case EVENT_GKILL:
434  /*GKILL: op, hitter*/
435  op = va_arg(args, object *);
436  op2 = va_arg(args, object *);
437  for (cp = plugins_list; cp != NULL; cp = cp->next) {
438  if (cp->gevent[eventcode] != NULL)
439  cp->gevent[eventcode](&rt, eventcode, op, op2);
440  }
441  break;
442 
443  case EVENT_LOGIN:
444  /*LOGIN: pl, pl->socket.host*/
445  pl = va_arg(args, player *);
446  buf = va_arg(args, char *);
447  for (cp = plugins_list; cp != NULL; cp = cp->next) {
448  if (cp->gevent[eventcode] != NULL)
449  cp->gevent[eventcode](&rt, eventcode, pl, buf);
450  }
451  break;
452 
453  case EVENT_LOGOUT:
454  /*LOGOUT: pl, pl->socket.host*/
455  pl = va_arg(args, player *);
456  buf = va_arg(args, char *);
457  for (cp = plugins_list; cp != NULL; cp = cp->next) {
458  if (cp->gevent[eventcode] != NULL)
459  cp->gevent[eventcode](&rt, eventcode, pl, buf);
460  }
461  break;
462 
463  case EVENT_MAPENTER:
464  /*MAPENTER: op, map*/
465  op = va_arg(args, object *);
466  map = va_arg(args, mapstruct *);
467  for (cp = plugins_list; cp != NULL; cp = cp->next) {
468  if (cp->gevent[eventcode] != NULL)
469  cp->gevent[eventcode](&rt, eventcode, op, map);
470  }
471  break;
472 
473  case EVENT_MAPLEAVE:
474  /*MAPLEAVE: op, map*/
475  op = va_arg(args, object *);
476  map = va_arg(args, mapstruct *);
477  for (cp = plugins_list; cp != NULL; cp = cp->next) {
478  if (cp->gevent[eventcode] != NULL)
479  cp->gevent[eventcode](&rt, eventcode, op, map);
480  }
481  break;
482 
483  case EVENT_MAPRESET:
484  /*MAPRESET: map*/
485  map = va_arg(args, mapstruct *);
486  for (cp = plugins_list; cp != NULL; cp = cp->next) {
487  if (cp->gevent[eventcode] != NULL)
488  cp->gevent[eventcode](&rt, eventcode, map);
489  }
490  break;
491 
492  case EVENT_REMOVE:
493  /*REMOVE: op*/
494  op = va_arg(args, object *);
495  for (cp = plugins_list; cp != NULL; cp = cp->next) {
496  if (cp->gevent[eventcode] != NULL)
497  cp->gevent[eventcode](&rt, eventcode, op);
498  }
499  break;
500 
501  case EVENT_SHOUT:
502  /*SHOUT: op, parms, priority*/
503  op = va_arg(args, object *);
504  buf = va_arg(args, char *);
505  i = va_arg(args, int);
506  for (cp = plugins_list; cp != NULL; cp = cp->next) {
507  if (cp->gevent[eventcode] != NULL)
508  cp->gevent[eventcode](&rt, eventcode, op, buf, i);
509  }
510  break;
511 
512  case EVENT_TELL:
513  /* Tell: who, what, to who */
514  op = va_arg(args, object *);
515  buf = va_arg(args, const char *);
516  op2 = va_arg(args, object *);
517  for (cp = plugins_list; cp != NULL; cp = cp->next) {
518  if (cp->gevent[eventcode] != NULL)
519  cp->gevent[eventcode](&rt, eventcode, op, buf, op2);
520  }
521  break;
522 
523  case EVENT_MUZZLE:
524  /*MUZZLE: op, parms*/
525  op = va_arg(args, object *);
526  buf = va_arg(args, char *);
527  for (cp = plugins_list; cp != NULL; cp = cp->next) {
528  if (cp->gevent[eventcode] != NULL)
529  cp->gevent[eventcode](&rt, eventcode, op, buf);
530  }
531  break;
532 
533  case EVENT_KICK:
534  /*KICK: op, parms*/
535  op = va_arg(args, object *);
536  buf = va_arg(args, char *);
537  for (cp = plugins_list; cp != NULL; cp = cp->next) {
538  if (cp->gevent[eventcode] != NULL)
539  cp->gevent[eventcode](&rt, eventcode, op, buf);
540  }
541  break;
542 
543  case EVENT_MAPUNLOAD:
544  /*MAPUNLOAD: map*/
545  map = va_arg(args, mapstruct *);
546  for (cp = plugins_list; cp != NULL; cp = cp->next) {
547  if (cp->gevent[eventcode] != NULL)
548  cp->gevent[eventcode](&rt, eventcode, map);
549  }
550  break;
551 
552  case EVENT_MAPLOAD:
553  /*MAPLOAD: map*/
554  map = va_arg(args, mapstruct *);
555  for (cp = plugins_list; cp != NULL; cp = cp->next) {
556  if (cp->gevent[eventcode] != NULL)
557  cp->gevent[eventcode](&rt, eventcode, map);
558  }
559  break;
560  }
561  va_end(args);
562  return 0;
563 }
564 
565 static void cfapi_get_hooks(int *type, ...) {
566  va_list args;
567  int request_type;
568  char *buf;
569  f_plug_api *rapi;
570 
571  *type = CFAPI_NONE;
572 
573  va_start(args, type);
574  request_type = va_arg(args, int);
575  if (request_type == 0) { /* By nr */
576  size_t fid;
577 
578  fid = va_arg(args, int);
579  rapi = va_arg(args, f_plug_api *);
580  if (fid >= NR_OF_HOOKS) {
581  *rapi = NULL;
582  *type = CFAPI_NONE;
583  } else {
584  *rapi = plug_hooks[fid].func;
585  *type = CFAPI_FUNC;
586  }
587  } else { /* by name */
588  size_t i;
589 
590  buf = va_arg(args, char *);
591  rapi = va_arg(args, f_plug_api *);
592  *rapi = NULL;
593  *type = CFAPI_NONE;
594  for (i = 0; i < NR_OF_HOOKS; i++) {
595  if (!strcmp(buf, plug_hooks[i].fname)) {
596  *rapi = plug_hooks[i].func;
597  *type = CFAPI_FUNC;
598  break;
599  }
600  }
601  }
602  va_end(args);
603 }
604 
611 int plugins_init_plugin(const char *libfile) {
612  LIBPTRTYPE ptr;
613  f_plug_init initfunc;
614  f_plug_property propfunc;
615  f_plug_event eventfunc;
616  f_plug_postinit postfunc;
617  f_plug_postinit closefunc;
618  int i;
619  crossfire_plugin *cp;
620  crossfire_plugin *ccp;
621  char *svn_rev;
622 
623 
624  /* Open the plugin lib and load the required functions */
625  ptr = plugins_dlopen(libfile);
626  if (ptr == NULL) {
627  LOG(llevError, "Error trying to load %s: %s\n", libfile, plugins_dlerror());
628  return -1;
629  }
630  svn_rev = (char*) plugins_dlsym(ptr, "SvnRevPlugin");
631  if (svn_rev == NULL) {
632  LOG(llevError, "Unable to find SvnRevPlugin in %s\n", libfile);
633  plugins_dlclose(ptr);
634  return -1;
635  }
636  if (settings.ignore_plugin_compatibility == 0 && strcmp(svn_rev, SVN_REV)) {
637  LOG(llevError, "SVN Version mismatch in in %s (%s != %s)\n", libfile, svn_rev, SVN_REV);
638  plugins_dlclose(ptr);
639  return -1;
640  }
641 
642  initfunc = (f_plug_init)plugins_dlsym(ptr, "initPlugin");
643  if (initfunc == NULL) {
644  LOG(llevError, "Plugin error while requesting %s.initPlugin: %s\n", libfile, plugins_dlerror());
645  plugins_dlclose(ptr);
646  return -1;
647  }
648  propfunc = (f_plug_property)plugins_dlsym(ptr, "getPluginProperty");
649  if (propfunc == NULL) {
650  LOG(llevError, "Plugin error while requesting %s.getPluginProperty: %s\n", libfile, plugins_dlerror());
651  plugins_dlclose(ptr);
652  return -1;
653  }
654  eventfunc = (f_plug_event)plugins_dlsym(ptr, "eventListener");
655  if (eventfunc == NULL) {
656  LOG(llevError, "Plugin error while requesting %s.eventListener: %s\n", libfile, plugins_dlerror());
657  plugins_dlclose(ptr);
658  return -1;
659  }
660  postfunc = (f_plug_postinit)plugins_dlsym(ptr, "postInitPlugin");
661  if (postfunc == NULL) {
662  LOG(llevError, "Plugin error while requesting %s.postInitPlugin: %s\n", libfile, plugins_dlerror());
663  plugins_dlclose(ptr);
664  return -1;
665  }
666  closefunc = (f_plug_postinit)plugins_dlsym(ptr, "closePlugin");
667  if (closefunc == NULL) {
668  LOG(llevError, "Plugin error while requesting %s.closePlugin: %s\n", libfile, plugins_dlerror());
669  plugins_dlclose(ptr);
670  return -1;
671  }
672  i = initfunc("2.0", cfapi_get_hooks);
673  cp = malloc(sizeof(crossfire_plugin));
674  for (i = 0; i < NR_EVENTS; i++)
675  cp->gevent[i] = NULL;
676  cp->eventfunc = eventfunc;
677  cp->propfunc = propfunc;
678  cp->closefunc = closefunc;
679  cp->libptr = ptr;
680  propfunc(&i, "Identification", cp->id, sizeof(cp->id));
681  propfunc(&i, "FullName", cp->fullname, sizeof(cp->fullname));
682  cp->next = NULL;
683  cp->prev = NULL;
684  if (plugins_list == NULL) {
685  plugins_list = cp;
686  } else {
687  for (ccp = plugins_list; ccp->next != NULL; ccp = ccp->next)
688  ;
689  ccp->next = cp;
690  cp->prev = ccp;
691  }
692  postfunc();
693  return 0;
694 }
695 
702 int plugins_remove_plugin(const char *id) {
703  crossfire_plugin *cp;
704 
705  if (plugins_list == NULL)
706  return -1;
707 
708  for (cp = plugins_list; cp != NULL; cp = cp->next) {
709  if (!strcmp(id, cp->id)) {
710  crossfire_plugin *n;
711  crossfire_plugin *p;
712 
713  n = cp->next;
714  p = cp->prev;
715  if (cp->closefunc)
716  cp->closefunc();
717  plugins_dlclose(cp->libptr);
718  if (n != NULL) {
719  if (p != NULL) {
720  n->prev = p;
721  p->next = n;
722  } else {
723  n->prev = NULL;
724  plugins_list = n;
725  }
726  } else {
727  if (p != NULL)
728  p->next = NULL;
729  else
730  plugins_list = NULL;
731  }
732  free(cp);
733  return 0;
734  }
735  }
736  return -1;
737 }
738 
744 void plugins_display_list(object *op) {
745  crossfire_plugin *cp;
746 
748  "List of loaded plugins:\n-----------------------");
749 
750  if (plugins_list == NULL)
751  return;
752 
753  for (cp = plugins_list; cp != NULL; cp = cp->next) {
755  "%s, %s",
756  cp->id, cp->fullname);
757  }
758 }
759 
760 /* SYSTEM-RELATED HOOKS */
761 
767 static void cfapi_cost_string_from_value(int *type, ...) {
768  uint64_t cost;
769  char *buffer, *final;
770  int length, largest_coin;
771  va_list args;
772 
773  va_start(args, type);
774  cost = va_arg(args, uint64_t);
775  largest_coin = va_arg(args, int);
776  buffer = va_arg(args, char*);
777  length = va_arg(args, int);
778  va_end(args);
779 
780  *type = CFAPI_NONE;
781 
782  if (length < 1)
783  return;
784 
785  final = cost_string_from_value(cost, largest_coin);
786 
787  strncpy(buffer, final, length - 1);
788  buffer[length - 1] = '\0';
789  free(final);
790 }
791 
797 static void cfapi_system_find_animation(int *type, ...) {
798  va_list args;
799  const char *anim;
800  int *num;
801 
802  va_start(args, type);
803  anim = va_arg(args, const char *);
804  num = va_arg(args, int *);
805  va_end(args);
806 
807  *num = find_animation(anim);
808  *type = CFAPI_INT;
809 }
810 
816 static void cfapi_system_find_face(int *type, ...) {
817  va_list args;
818  const char *face;
819  int error;
820  int *num;
821 
822  va_start(args, type);
823  face = va_arg(args, const char *);
824  error = va_arg(args, int);
825  num = va_arg(args, int *);
826  va_end(args);
827 
828  *num = find_face(face, error);
829  *type = CFAPI_INT;
830 }
831 
837 static void cfapi_system_strdup_local(int *type, ...) {
838  va_list args;
839  const char *txt;
840  char **ret;
841 
842  va_start(args, type);
843  txt = va_arg(args, const char *);
844  ret = va_arg(args, char **);
845  va_end(args);
846 
847  *ret = strdup_local(txt);
848  *type = CFAPI_STRING;
849 }
850 
851 static void cfapi_system_register_global_event(int *type, ...) {
852  va_list args;
853  int eventcode;
854  char *pname;
855  f_plug_event hook;
856  crossfire_plugin *cp;
857 
858  va_start(args, type);
859  eventcode = va_arg(args, int);
860  pname = va_arg(args, char *);
861  hook = va_arg(args, f_plug_event);
862  va_end(args);
863 
864  *type = CFAPI_NONE;
865 
866  cp = plugins_find_plugin(pname);
867  cp->gevent[eventcode] = hook;
868 }
869 
870 static void cfapi_system_unregister_global_event(int *type, ...) {
871  va_list args;
872  int eventcode;
873  char *pname;
874  crossfire_plugin *cp;
875 
876  va_start(args, type);
877  eventcode = va_arg(args, int);
878  pname = va_arg(args, char *);
879  va_end(args);
880 
881  *type = CFAPI_NONE;
882 
883  cp = plugins_find_plugin(pname);
884  cp->gevent[eventcode] = NULL;
885 }
886 
893 static void cfapi_system_add_string(int *type, ...) {
894  va_list args;
895  const char *str;
896  sstring *rv;
897 
898  va_start(args, type);
899  str = va_arg(args, const char *);
900  rv = va_arg(args, sstring *);
901  va_end(args);
902 
903  *rv = add_string(str);
904  *type = CFAPI_SSTRING;
905 }
906 
913 static void cfapi_system_remove_string(int *type, ...) {
914  va_list args;
915  sstring str;
916 
917  va_start(args, type);
918  str = va_arg(args, sstring);
919  va_end(args);
920 
921  free_string(str);
922  *type = CFAPI_NONE;
923 }
924 
931 static void cfapi_system_find_string(int *type, ...) {
932  va_list args;
933  const char *str;
934  sstring *rv;
935 
936  va_start(args, type);
937  str = va_arg(args, const char *);
938  rv = va_arg(args, sstring *);
939  va_end(args);
940 
941  *rv = find_string(str);
942  *type = CFAPI_SSTRING;
943 }
944 
950 static void cfapi_system_check_path(int *type, ...) {
951  va_list args;
952  const char *name;
953  int prepend_dir;
954  int *ret;
955 
956  va_start(args, type);
957 
958  name = va_arg(args, char *);
959  prepend_dir = va_arg(args, int);
960  ret = va_arg(args, int *);
961 
962  *ret = check_path(name, prepend_dir);
963 
964  va_end(args);
965  *type = CFAPI_INT;
966 }
967 
973 static void cfapi_system_re_cmp(int *type, ...) {
974  va_list args;
975  const char *str;
976  const char *regexp;
977  const char **rv;
978 
979  va_start(args, type);
980 
981  str = va_arg(args, char *);
982  regexp = va_arg(args, char *);
983  rv = va_arg(args, const char **);
984 
985  *rv = re_cmp(str, regexp);
986 
987  va_end(args);
988  *type = CFAPI_STRING;
989 }
990 
991 static void cfapi_system_directory(int *type, ...) {
992  va_list args;
993  int dirtype;
994  const char **str;
995 
996  va_start(args, type);
997 
998  dirtype = va_arg(args, int);
999  str = va_arg(args, const char **);
1000  va_end(args);
1001 
1002  *type = CFAPI_STRING;
1003 
1004  switch (dirtype) {
1005  case 0:
1006  *str = settings.mapdir;
1007  break;
1008 
1009  case 1:
1010  *str = settings.uniquedir;
1011  break;
1012 
1013  case 2:
1014  *str = settings.tmpdir;
1015  break;
1016 
1017  case 3:
1018  *str = settings.confdir;
1019  break;
1020 
1021  case 4:
1022  *str = settings.localdir;
1023  break;
1024 
1025  case 5:
1026  *str = settings.playerdir;
1027  break;
1028 
1029  case 6:
1030  *str = settings.datadir;
1031  break;
1032 
1033  default:
1034  *str = NULL;
1035  }
1036 }
1037 
1044 static void cfapi_get_time(int *type, ...) {
1045  va_list args;
1046  timeofday_t *tod;
1047 
1048  va_start(args, type);
1049  tod = va_arg(args, timeofday_t *);
1050  va_end(args);
1051 
1052  get_tod(tod);
1053  *type = CFAPI_NONE;
1054 }
1055 
1056 #define string_get_int(name) \
1057  va_list args; \
1058  int index; \
1059  const char **str; \
1060  va_start(args, type); \
1061  index = va_arg(args, int); \
1062  str = va_arg(args, const char **); \
1063  va_end(args); \
1064  *str = name(index); \
1065  *type = CFAPI_STRING; \
1066 
1067 
1075 static void cfapi_get_season_name(int *type, ...) {
1077 }
1078 
1087 static void cfapi_get_weekday_name(int *type, ...) {
1089 }
1090 
1099 static void cfapi_get_month_name(int *type, ...) {
1101 }
1102 
1111 static void cfapi_get_periodofday_name(int *type, ...) {
1113 }
1114 
1126 static void cfapi_timer_create(int *type, ...) {
1127  va_list args;
1128  int res;
1129  object *ob;
1130  long delay;
1131  int mode;
1132  int *timer;
1133 
1134  va_start(args, type);
1135  ob = va_arg(args, object *);
1136  delay = va_arg(args, long);
1137  mode = va_arg(args, int);
1138  timer = va_arg(args, int *);
1139  va_end(args);
1140  *type = CFAPI_INT;
1141 
1142  *timer = cftimer_find_free_id();
1143  if (*timer != TIMER_ERR_ID) {
1144  res = cftimer_create(*timer, delay, ob, mode);
1145  if (res != TIMER_ERR_NONE)
1146  *timer = res;
1147  }
1148 }
1149 
1159 static void cfapi_timer_destroy(int *type, ...) {
1160  va_list args;
1161  int id;
1162  int *err;
1163 
1164  va_start(args, type);
1165  id = va_arg(args, int);
1166  err = va_arg(args, int *);
1167  va_end(args);
1168  *type = CFAPI_INT;
1169 
1170  *err = cftimer_destroy(id);
1171 }
1172 
1178 static void cfapi_log(int *type, ...) {
1179  va_list args;
1180  LogLevel logLevel;
1181  const char *message;
1182 
1183  va_start(args, type);
1184  logLevel = va_arg(args, LogLevel);
1185  message = va_arg(args, const char *);
1186  LOG(logLevel, "%s", message);
1187  va_end(args);
1188 
1189  *type = CFAPI_NONE;
1190 }
1191 
1192 /* MAP RELATED HOOKS */
1193 
1202 static void cfapi_map_get_map(int *type, ...) {
1203  va_list args;
1204  mapstruct **ret;
1205  int ctype;
1206  int x, y;
1207  int16_t nx, ny;
1208  const char *name;
1209  mapstruct *m;
1210 
1211  va_start(args, type);
1212 
1213  ctype = va_arg(args, int);
1214 
1215  switch (ctype) {
1216  case 0:
1217  x = va_arg(args, int);
1218  y = va_arg(args, int);
1219  ret = va_arg(args, mapstruct **);
1220  *ret = get_empty_map(x, y);
1221  break;
1222 
1223  case 1:
1224  name = va_arg(args, const char *);
1225  x = va_arg(args, int);
1226  ret = va_arg(args, mapstruct **);
1227  *ret = ready_map_name(name, x);
1228  break;
1229 
1230  case 2:
1231  m = va_arg(args, mapstruct *);
1232  nx = va_arg(args, int);
1233  ny = va_arg(args, int);
1234  ret = va_arg(args, mapstruct **);
1235  *ret = get_map_from_coord(m, &nx, &ny);
1236  break;
1237 
1238  default:
1239  *type = CFAPI_NONE;
1240  va_end(args);
1241  return;
1242  break;
1243  }
1244  va_end(args);
1245  *type = CFAPI_PMAP;
1246 }
1247 
1253 static void cfapi_map_has_been_loaded(int *type, ...) {
1254  va_list args;
1255  mapstruct **map;
1256  char *string;
1257 
1258  va_start(args, type);
1259  string = va_arg(args, char *);
1260  map = va_arg(args, mapstruct **);
1261  *map = has_been_loaded(string);
1262  va_end(args);
1263  *type = CFAPI_PMAP;
1264 }
1265 
1271 static void cfapi_map_create_path(int *type, ...) {
1272  va_list args;
1273  int ctype, size;
1274  const char *str;
1275  char *name;
1276 
1277  va_start(args, type);
1278 
1279  ctype = va_arg(args, int);
1280  str = va_arg(args, const char *);
1281  name = va_arg(args, char *);
1282  size = va_arg(args, int);
1283  *type = CFAPI_STRING;
1284 
1285  switch (ctype) {
1286  case 0:
1287  create_pathname(str, name, size);
1288  break;
1289 
1290  case 1:
1291  create_overlay_pathname(str, name, MAX_BUF);
1292  break;
1293 
1294 /* case 2:
1295  rv = create_items_path(str);
1296  break;*/
1297 
1298  default:
1299  *type = CFAPI_NONE;
1300  break;
1301  }
1302  va_end(args);
1303 }
1304 
1305 static void cfapi_map_get_map_property(int *type, ...) {
1306  va_list args;
1307  mapstruct *map;
1308  int property;
1309 
1310  int *rint;
1311  mapstruct **rmap;
1312  sstring *rstr;
1313  region **rreg;
1314  int16_t *nx, *ny;
1315  int x, y;
1316 
1317  va_start(args, type);
1318 
1319  map = va_arg(args, mapstruct *);
1320  property = va_arg(args, int);
1321 
1322  switch (property) {
1323  case CFAPI_MAP_PROP_FLAGS:
1324  rmap = va_arg(args, mapstruct **);
1325  x = va_arg(args, int);
1326  y = va_arg(args, int);
1327  nx = va_arg(args, int16_t *);
1328  ny = va_arg(args, int16_t *);
1329  rint = va_arg(args, int *);
1330  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1331  *type = CFAPI_INT;
1332  break;
1333 
1335  rint = va_arg(args, int *);
1336  *rint = calculate_difficulty(map);
1337  *type = CFAPI_INT;
1338  break;
1339 
1340  case CFAPI_MAP_PROP_PATH:
1341  rstr = va_arg(args, sstring *);
1342  *rstr = map->path;
1343  *type = CFAPI_SSTRING;
1344  break;
1345 
1347  rstr = va_arg(args, sstring *);
1348  *rstr = map->tmpname;
1349  *type = CFAPI_SSTRING;
1350  break;
1351 
1352  case CFAPI_MAP_PROP_NAME:
1353  rstr = va_arg(args, sstring *);
1354  *rstr = map->name;
1355  *type = CFAPI_SSTRING;
1356  break;
1357 
1359  rint = va_arg(args, int *);
1360  *rint = map->reset_time;
1361  *type = CFAPI_INT;
1362  break;
1363 
1365  rint = va_arg(args, int *);
1366  *rint = map->reset_timeout;
1367  *type = CFAPI_INT;
1368  break;
1369 
1371  rint = va_arg(args, int *);
1372  *rint = map->players;
1373  *type = CFAPI_INT;
1374  break;
1375 
1377  rint = va_arg(args, int *);
1378  *rint = map->darkness;
1379  *type = CFAPI_INT;
1380  break;
1381 
1382  case CFAPI_MAP_PROP_WIDTH:
1383  rint = va_arg(args, int *);
1384  *rint = map->width;
1385  *type = CFAPI_INT;
1386  break;
1387 
1388  case CFAPI_MAP_PROP_HEIGHT:
1389  rint = va_arg(args, int *);
1390  *rint = map->height;
1391  *type = CFAPI_INT;
1392  break;
1393 
1395  rint = va_arg(args, int *);
1396  *rint = map->enter_x;
1397  *type = CFAPI_INT;
1398  break;
1399 
1401  rint = va_arg(args, int *);
1402  *rint = map->enter_y;
1403  *type = CFAPI_INT;
1404  break;
1405 
1407  rstr = va_arg(args, sstring *);
1408  *rstr = map->msg;
1409  *type = CFAPI_SSTRING;
1410  break;
1411 
1412  case CFAPI_MAP_PROP_NEXT:
1413  rmap = va_arg(args, mapstruct **);
1414  *rmap = map ? map->next : first_map;
1415  *type = CFAPI_PMAP;
1416  break;
1417 
1418  case CFAPI_MAP_PROP_REGION:
1419  rreg = va_arg(args, region **);
1420  *rreg = get_region_by_map(map);
1421  *type = CFAPI_PREGION;
1422  break;
1423 
1424  case CFAPI_MAP_PROP_UNIQUE:
1425  rint = va_arg(args, int *);
1426  *rint = map->unique;
1427  *type = CFAPI_INT;
1428  break;
1429 
1430  default:
1431  *type = CFAPI_NONE;
1432  break;
1433  }
1434  va_end(args);
1435 }
1436 
1437 static void cfapi_map_set_map_property(int *type, ...) {
1438  va_list args;
1439  mapstruct *map;
1440  int property;
1441  const char *buf;
1442 
1443  va_start(args, type);
1444 
1445  map = va_arg(args, mapstruct *);
1446  property = va_arg(args, int);
1447 
1448  switch (property) {
1449  case CFAPI_MAP_PROP_PATH:
1450  buf = va_arg(args, const char *);
1451  strlcpy(map->path, buf, sizeof(map->path));
1452  *type = CFAPI_STRING;
1453  break;
1454 
1455  default:
1456  *type = CFAPI_NONE;
1457  break;
1458  }
1459  va_end(args);
1460 }
1461 
1467 static void cfapi_map_out_of_map(int *type, ...) {
1468  va_list args;
1469  mapstruct *map;
1470  int x, y;
1471  int *rint;
1472 
1473  va_start(args, type);
1474  map = va_arg(args, mapstruct *);
1475  x = va_arg(args, int);
1476  y = va_arg(args, int);
1477  rint = va_arg(args, int *);
1478 
1479  *rint = out_of_map(map, x, y);
1480  va_end(args);
1481  *type = CFAPI_INT;
1482 }
1483 
1489 static void cfapi_map_update_position(int *type, ...) {
1490  va_list args;
1491  mapstruct *map;
1492  int x, y;
1493 
1494  va_start(args, type);
1495 
1496  map = va_arg(args, mapstruct *);
1497  x = va_arg(args, int);
1498  y = va_arg(args, int);
1499 
1500  update_position(map, x, y);
1501  va_end(args);
1502  *type = CFAPI_NONE;
1503 }
1504 
1505 static void cfapi_map_delete_map(int *type, ...) {
1506  va_list args;
1507  mapstruct *map;
1508  va_start(args, type);
1509 
1510  map = va_arg(args, mapstruct *);
1511 
1512  delete_map(map);
1513 
1514  va_end(args);
1515  *type = CFAPI_NONE;
1516 }
1517 
1518 static void cfapi_map_message(int *type, ...) {
1519  va_list args;
1520  mapstruct *map;
1521  const char *string;
1522  int color;
1523 
1524  va_start(args, type);
1525  map = va_arg(args, mapstruct *);
1526  string = va_arg(args, const char *);
1527  color = va_arg(args, int);
1528  va_end(args);
1529 
1530  /* function should be extended to take message types probably */
1531  ext_info_map(color, map, MSG_TYPE_MISC, MSG_SUBTYPE_NONE, string);
1532  *type = CFAPI_NONE;
1533 }
1534 
1540 static void cfapi_map_get_object_at(int *type, ...) {
1541  va_list args;
1542  mapstruct *map;
1543  int x, y;
1544  int16_t sx, sy;
1545  object **robj;
1546 
1547  va_start(args, type);
1548  map = va_arg(args, mapstruct *);
1549  x = va_arg(args, int);
1550  y = va_arg(args, int);
1551  robj = va_arg(args, object **);
1552  va_end(args);
1553 
1554  sx = x;
1555  sy = y;
1556  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1557  *robj = NULL;
1558  else
1559  *robj = GET_MAP_OB(map, sx, sy);
1560  *type = CFAPI_POBJECT;
1561 }
1562 
1569 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1570  va_list args;
1571  int x, y;
1572  mapstruct *map;
1573  char *msg;
1574  object **robj;
1575 
1576  va_start(args, type);
1577 
1578  msg = va_arg(args, char *);
1579  map = va_arg(args, mapstruct *);
1580  x = va_arg(args, int);
1581  y = va_arg(args, int);
1582  robj = va_arg(args, object **);
1583 
1584  va_end(args);
1585 
1586  archetype *at = try_find_archetype(msg);
1587  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1588  *type = CFAPI_POBJECT;
1589 }
1590 
1596 static void cfapi_map_change_light(int *type, ...) {
1597  va_list args;
1598  int change;
1599  mapstruct *map;
1600  int *rint;
1601 
1602  va_start(args, type);
1603  map = va_arg(args, mapstruct *);
1604  change = va_arg(args, int);
1605  rint = va_arg(args, int *);
1606  va_end(args);
1607 
1608  *type = CFAPI_INT;
1609  *rint = change_map_light(map, change);
1610 }
1611 
1612 /* OBJECT-RELATED HOOKS */
1613 
1627 static void cfapi_object_move(int *type, ...) {
1628  va_list args;
1629  int kind;
1630  object *op;
1631  object *activator;
1632  player *pl;
1633  int direction;
1634  int *ret;
1635 
1636  va_start(args, type);
1637  kind = va_arg(args, int);
1638  switch (kind) {
1639  case 0:
1640  op = va_arg(args, object *);
1641  direction = va_arg(args, int);
1642  activator = va_arg(args, object *);
1643  ret = va_arg(args, int *);
1644  va_end(args);
1645  *ret = move_ob(op, direction, activator);
1646  break;
1647 
1648  case 1:
1649  pl = va_arg(args, player *);
1650  direction = va_arg(args, int);
1651  ret = va_arg(args, int *);
1652  va_end(args);
1653  *ret = move_player(pl->ob, direction);
1654  break;
1655 
1656  case 2:
1657  op = va_arg(args, object *);
1658  ret = va_arg(args, int *);
1659  va_end(args);
1660  *ret = player_arrest(op);
1661  break;
1662 
1663  default:
1664  // Just end the use of variable args. We got a wrong type.
1665  va_end(args);
1666  }
1667  *type = CFAPI_INT;
1668 }
1669 
1677 static void cfapi_object_get_key(int *type, ...) {
1678  va_list args;
1679  const char *keyname;
1680  const char **value;
1681  object *op;
1682 
1683  va_start(args, type);
1684  op = va_arg(args, object *);
1685  keyname = va_arg(args, const char *);
1686  value = va_arg(args, const char **);
1687  va_end(args);
1688 
1689  *value = object_get_value(op, keyname);
1690  *type = CFAPI_SSTRING;
1691 }
1692 
1699 static void cfapi_object_set_key(int *type, ...) {
1700  va_list args;
1701  const char *keyname;
1702  const char *value;
1703  int *ret;
1704  object *op;
1705  int add_key;
1706 
1707  va_start(args, type);
1708  op = va_arg(args, object *);
1709  keyname = va_arg(args, char *);
1710  value = va_arg(args, char *);
1711  add_key = va_arg(args, int);
1712  ret = va_arg(args, int *);
1713  va_end(args);
1714 
1715  *ret = object_set_value(op, keyname, value, add_key);
1716  *type = CFAPI_INT;
1717 }
1718 
1722 static void cfapi_object_get_property(int *type, ...) {
1723  va_list args;
1724  int property;
1725  object *op;
1726  int *rint;
1727  object **robject;
1728  mapstruct **rmap;
1729  float *rfloat;
1730  archetype **rarch;
1731  sstring *rsstring;
1732  char *rbuffer;
1733  int rbufsize;
1734  MoveType *rmove;
1735  int64_t *rint64;
1736  partylist **rparty;
1737  double *rdouble;
1738  long *rlong;
1739 
1740  va_start(args, type);
1741 
1742  op = va_arg(args, object *);
1743  property = va_arg(args, int);
1744  switch (property) {
1746  robject = va_arg(args, object **);
1747  *robject = op->above;
1748  *type = CFAPI_POBJECT;
1749  break;
1750 
1752  robject = va_arg(args, object **);
1753  *robject = op->below;
1754  *type = CFAPI_POBJECT;
1755  break;
1756 
1758  robject = va_arg(args, object **);
1759  *robject = op->active_next;
1760  *type = CFAPI_POBJECT;
1761  break;
1762 
1764  robject = va_arg(args, object **);
1765  *robject = op->active_prev;
1766  *type = CFAPI_POBJECT;
1767  break;
1768 
1770  robject = va_arg(args, object **);
1771  *robject = op->inv;
1772  *type = CFAPI_POBJECT;
1773  break;
1774 
1776  robject = va_arg(args, object **);
1777  *robject = op->env;
1778  *type = CFAPI_POBJECT;
1779  break;
1780 
1782  robject = va_arg(args, object **);
1783  *robject = op->head;
1784  *type = CFAPI_POBJECT;
1785  break;
1786 
1788  robject = va_arg(args, object **);
1789  *robject = op->container;
1790  *type = CFAPI_POBJECT;
1791  break;
1792 
1793  case CFAPI_OBJECT_PROP_MAP:
1794  rmap = va_arg(args, mapstruct **);
1795  *rmap = op->map;
1796  *type = CFAPI_PMAP;
1797  break;
1798 
1800  rint = va_arg(args, int *);
1801  *rint = op->count;
1802  *type = CFAPI_INT;
1803  break;
1804 
1806  rbuffer = va_arg(args, char *);
1807  rbufsize = va_arg(args, int);
1808  query_name(op, rbuffer, rbufsize);
1809  *type = CFAPI_STRING;
1810  break;
1811 
1813  rsstring = va_arg(args, sstring *);
1814  *rsstring = op->name_pl;
1815  *type = CFAPI_SSTRING;
1816  break;
1817 
1819  rsstring = va_arg(args, sstring *);
1820  *rsstring = op->title;
1821  *type = CFAPI_SSTRING;
1822  break;
1823 
1825  rsstring = va_arg(args, sstring *);
1826  *rsstring = op->race;
1827  *type = CFAPI_SSTRING;
1828  break;
1829 
1831  rsstring = va_arg(args, sstring *);
1832  *rsstring = op->slaying;
1833  *type = CFAPI_SSTRING;
1834  break;
1835 
1837  rsstring = va_arg(args, sstring *);
1838  *rsstring = op->skill;
1839  *type = CFAPI_SSTRING;
1840  break;
1841 
1843  rsstring = va_arg(args, sstring *);
1844  *rsstring = op->msg;
1845  *type = CFAPI_SSTRING;
1846  break;
1847 
1849  rsstring = va_arg(args, sstring *);
1850  *rsstring = op->lore;
1851  *type = CFAPI_SSTRING;
1852  break;
1853 
1854  case CFAPI_OBJECT_PROP_X:
1855  rint = va_arg(args, int *);
1856  *rint = op->x;
1857  *type = CFAPI_INT;
1858  break;
1859 
1860  case CFAPI_OBJECT_PROP_Y:
1861  rint = va_arg(args, int *);
1862  *rint = op->y;
1863  *type = CFAPI_INT;
1864  break;
1865 
1867  rfloat = va_arg(args, float *);
1868  *rfloat = op->speed;
1869  *type = CFAPI_FLOAT;
1870  break;
1871 
1873  rfloat = va_arg(args, float *);
1874  *rfloat = op->speed_left;
1875  *type = CFAPI_FLOAT;
1876  break;
1877 
1879  rint = va_arg(args, int *);
1880  *rint = op->nrof;
1881  *type = CFAPI_INT;
1882  break;
1883 
1885  rint = va_arg(args, int *);
1886  *rint = op->direction;
1887  *type = CFAPI_INT;
1888  break;
1889 
1891  rint = va_arg(args, int *);
1892  *rint = op->facing;
1893  *type = CFAPI_INT;
1894  break;
1895 
1897  rint = va_arg(args, int *);
1898  *rint = op->type;
1899  *type = CFAPI_INT;
1900  break;
1901 
1903  rint = va_arg(args, int *);
1904  *rint = op->subtype;
1905  *type = CFAPI_INT;
1906  break;
1907 
1909  rint = va_arg(args, int *);
1910  *rint = op->client_type;
1911  *type = CFAPI_INT;
1912  break;
1913 
1914  case CFAPI_OBJECT_PROP_RESIST: {
1915  int idx;
1916  int16_t *resist;
1917 
1918  idx = va_arg(args, int);
1919  resist = va_arg(args, int16_t *);
1920  *resist = op->resist[idx];
1921  }
1922  *type = CFAPI_INT16;
1923  break;
1924 
1926  rint = va_arg(args, int *);
1927  *rint = op->attacktype;
1928  *type = CFAPI_INT;
1929  break;
1930 
1932  rint = va_arg(args, int *);
1933  *rint = op->path_attuned;
1934  *type = CFAPI_INT;
1935  break;
1936 
1938  rint = va_arg(args, int *);
1939  *rint = op->path_repelled;
1940  *type = CFAPI_INT;
1941  break;
1942 
1944  rint = va_arg(args, int *);
1945  *rint = op->path_denied;
1946  *type = CFAPI_INT;
1947  break;
1948 
1950  rint = va_arg(args, int *);
1951  *rint = op->material;
1952  *type = CFAPI_INT;
1953  break;
1954 
1956  rsstring = va_arg(args, sstring *);
1957  *rsstring = op->materialname;
1958  *type = CFAPI_SSTRING;
1959  break;
1960 
1962  rint = va_arg(args, int *);
1963  *rint = op->magic;
1964  *type = CFAPI_INT;
1965  break;
1966 
1968  rlong = va_arg(args, long *);
1969  *rlong = op->value;
1970  *type = CFAPI_LONG;
1971  break;
1972 
1974  rint = va_arg(args, int *);
1975  *rint = op->level;
1976  *type = CFAPI_INT;
1977  break;
1978 
1980  rint = va_arg(args, int *);
1981  *rint = op->last_heal;
1982  *type = CFAPI_INT;
1983  break;
1984 
1986  rint = va_arg(args, int *);
1987  *rint = op->last_sp;
1988  *type = CFAPI_INT;
1989  break;
1990 
1992  rint = va_arg(args, int *);
1993  *rint = op->last_grace;
1994  *type = CFAPI_INT;
1995  break;
1996 
1998  rint = va_arg(args, int *);
1999  *rint = op->last_eat;
2000  *type = CFAPI_INT;
2001  break;
2002 
2004  rint = va_arg(args, int *);
2005  *rint = op->invisible;
2006  *type = CFAPI_INT;
2007  break;
2008 
2010  rint = va_arg(args, int *);
2011  *rint = op->pick_up;
2012  *type = CFAPI_INT;
2013  break;
2014 
2016  rint = va_arg(args, int *);
2017  *rint = op->item_power;
2018  *type = CFAPI_INT;
2019  break;
2020 
2022  rint = va_arg(args, int *);
2023  *rint = op->gen_sp_armour;
2024  *type = CFAPI_INT;
2025  break;
2026 
2028  rint = va_arg(args, int *);
2029  *rint = op->weight;
2030  *type = CFAPI_INT;
2031  break;
2032 
2034  rint = va_arg(args, int *);
2035  *rint = op->weight_limit;
2036  *type = CFAPI_INT;
2037  break;
2038 
2040  rint = va_arg(args, int *);
2041  *rint = op->carrying;
2042  *type = CFAPI_INT;
2043  break;
2044 
2046  rint = va_arg(args, int *);
2047  *rint = op->glow_radius;
2048  *type = CFAPI_INT;
2049  break;
2050 
2052  rint64 = va_arg(args, int64_t *);
2053  *rint64 = op->perm_exp;
2054  *type = CFAPI_SINT64;
2055  break;
2056 
2058  robject = va_arg(args, object **);
2059  *robject = op->current_weapon;
2060  *type = CFAPI_POBJECT;
2061  break;
2062 
2064  robject = va_arg(args, object **);
2065  *robject = op->enemy;
2066  *type = CFAPI_POBJECT;
2067  break;
2068 
2070  robject = va_arg(args, object **);
2071  *robject = op->attacked_by;
2072  *type = CFAPI_POBJECT;
2073  break;
2074 
2076  rint = va_arg(args, int *);
2077  *rint = op->run_away;
2078  *type = CFAPI_INT;
2079  break;
2080 
2082  robject = va_arg(args, object **);
2083  *robject = op->chosen_skill;
2084  *type = CFAPI_POBJECT;
2085  break;
2086 
2088  rint = va_arg(args, int *);
2089  *rint = op->hide;
2090  *type = CFAPI_INT;
2091  break;
2092 
2094  rint = va_arg(args, int *);
2095  *rint = op->move_status;
2096  *type = CFAPI_INT;
2097  break;
2098 
2100  rint = va_arg(args, int *);
2101  *rint = op->attack_movement;
2102  *type = CFAPI_INT;
2103  break;
2104 
2106  robject = va_arg(args, object **);
2107  *robject = op->spellitem;
2108  *type = CFAPI_POBJECT;
2109  break;
2110 
2112  rdouble = va_arg(args, double *);
2113  *rdouble = op->expmul;
2114  *type = CFAPI_DOUBLE;
2115  break;
2116 
2118  rarch = va_arg(args, archetype **);
2119  *rarch = op->arch;
2120  *type = CFAPI_PARCH;
2121  break;
2122 
2124  rarch = va_arg(args, archetype **);
2125  *rarch = op->other_arch;
2126  *type = CFAPI_PARCH;
2127  break;
2128 
2130  rsstring = va_arg(args, sstring *);
2131  *rsstring = op->custom_name;
2132  *type = CFAPI_SSTRING;
2133  break;
2134 
2136  rint = va_arg(args, int *);
2137  *rint = op->anim_speed;
2138  *type = CFAPI_INT;
2139  break;
2140 
2142  rint = va_arg(args, int *);
2143  *rint = is_friendly(op);
2144  *type = CFAPI_INT;
2145  break;
2146 
2148  rbuffer = va_arg(args, char *);
2149  rbufsize = va_arg(args, int);
2150  query_short_name(op, rbuffer, rbufsize);
2151  *type = CFAPI_STRING;
2152  break;
2153 
2155  int i;
2156 
2157  i = va_arg(args, int);
2158  rbuffer = va_arg(args, char *);
2159  rbufsize = va_arg(args, int);
2160  query_base_name(op, i, rbuffer, rbufsize);
2161  *type = CFAPI_STRING;
2162  }
2163  break;
2164 
2166  rsstring = va_arg(args, sstring *);
2167  *rsstring = op->name;
2168  *type = CFAPI_SSTRING;
2169  break;
2170 
2172  rint = va_arg(args, int *);
2173  *rint = is_magical(op);
2174  *type = CFAPI_INT;
2175  break;
2176 
2178  rint = va_arg(args, int *);
2179  *rint = op->stats.luck;
2180  *type = CFAPI_INT;
2181  break;
2182 
2183  case CFAPI_OBJECT_PROP_EXP:
2184  rint64 = va_arg(args, int64_t *);
2185  *rint64 = op->stats.exp;
2186  *type = CFAPI_SINT64;
2187  break;
2188 
2190  robject = va_arg(args, object **);
2191  *robject = object_get_owner(op);
2192  *type = CFAPI_POBJECT;
2193  break;
2194 
2196  int stype;
2197 
2198  stype = va_arg(args, int);
2199  switch (stype) {
2200  unsigned char ptype;
2201  char *buf;
2202  archetype *at;
2203 
2204  case 0: /* present_in_ob */
2205  ptype = (unsigned char)(va_arg(args, int));
2206  robject = va_arg(args, object **);
2207  *robject = object_present_in_ob(ptype, op);
2208  break;
2209 
2210  case 1: /* present_in_ob_by_name */
2211  ptype = (unsigned char)(va_arg(args, int));
2212  buf = va_arg(args, char *);
2213  robject = va_arg(args, object **);
2214  *robject = object_present_in_ob_by_name(ptype, buf, op);
2215  break;
2216 
2217  case 2: /* arch_present_in_ob */
2218  at = va_arg(args, archetype *);
2219  robject = va_arg(args, object **);
2220  *robject = arch_present_in_ob(at, op);
2221  break;
2222  }
2223  }
2224  *type = CFAPI_POBJECT;
2225  break;
2226 
2228  rint = va_arg(args, int *);
2229  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2230  *type = CFAPI_INT;
2231  break;
2232 
2234  object *op2;
2235 
2236  op2 = va_arg(args, object *);
2237  rint = va_arg(args, int *);
2238  *rint = object_can_merge(op, op2);
2239  }
2240  *type = CFAPI_INT;
2241  break;
2242 
2244  object *op2;
2245 
2246  op2 = va_arg(args, object *);
2247  rint = va_arg(args, int *);
2248  *rint = object_can_pick(op2, op);
2249  }
2250  *type = CFAPI_INT;
2251  break;
2252 
2253  case CFAPI_OBJECT_PROP_FLAGS: {
2254  int fl;
2255 
2256  fl = va_arg(args, int);
2257  rint = va_arg(args, int *);
2258  *rint = QUERY_FLAG(op, fl);
2259  }
2260  *type = CFAPI_INT;
2261  break;
2262 
2263  case CFAPI_OBJECT_PROP_STR:
2264  rint = va_arg(args, int *);
2265  *rint = op->stats.Str;
2266  *type = CFAPI_INT;
2267  break;
2268 
2269  case CFAPI_OBJECT_PROP_DEX:
2270  rint = va_arg(args, int *);
2271  *rint = op->stats.Dex;
2272  *type = CFAPI_INT;
2273  break;
2274 
2275  case CFAPI_OBJECT_PROP_CON:
2276  rint = va_arg(args, int *);
2277  *rint = op->stats.Con;
2278  *type = CFAPI_INT;
2279  break;
2280 
2281  case CFAPI_OBJECT_PROP_WIS:
2282  rint = va_arg(args, int *);
2283  *rint = op->stats.Wis;
2284  *type = CFAPI_INT;
2285  break;
2286 
2287  case CFAPI_OBJECT_PROP_INT:
2288  rint = va_arg(args, int *);
2289  *rint = op->stats.Int;
2290  *type = CFAPI_INT;
2291  break;
2292 
2293  case CFAPI_OBJECT_PROP_POW:
2294  rint = va_arg(args, int *);
2295  *rint = op->stats.Pow;
2296  *type = CFAPI_INT;
2297  break;
2298 
2299  case CFAPI_OBJECT_PROP_CHA:
2300  rint = va_arg(args, int *);
2301  *rint = op->stats.Cha;
2302  *type = CFAPI_INT;
2303  break;
2304 
2305  case CFAPI_OBJECT_PROP_WC:
2306  rint = va_arg(args, int *);
2307  *rint = op->stats.wc;
2308  *type = CFAPI_INT;
2309  break;
2310 
2311  case CFAPI_OBJECT_PROP_AC:
2312  rint = va_arg(args, int *);
2313  *rint = op->stats.ac;
2314  *type = CFAPI_INT;
2315  break;
2316 
2317  case CFAPI_OBJECT_PROP_HP:
2318  rint = va_arg(args, int *);
2319  *rint = op->stats.hp;
2320  *type = CFAPI_INT;
2321  break;
2322 
2323  case CFAPI_OBJECT_PROP_SP:
2324  rint = va_arg(args, int *);
2325  *rint = op->stats.sp;
2326  *type = CFAPI_INT;
2327  break;
2328 
2329  case CFAPI_OBJECT_PROP_GP:
2330  rint = va_arg(args, int *);
2331  *rint = op->stats.grace;
2332  *type = CFAPI_INT;
2333  break;
2334 
2335  case CFAPI_OBJECT_PROP_FP:
2336  rint = va_arg(args, int *);
2337  *rint = op->stats.food;
2338  *type = CFAPI_INT;
2339  break;
2340 
2342  rint = va_arg(args, int *);
2343  *rint = op->stats.maxhp;
2344  *type = CFAPI_INT;
2345  break;
2346 
2348  rint = va_arg(args, int *);
2349  *rint = op->stats.maxsp;
2350  *type = CFAPI_INT;
2351  break;
2352 
2354  rint = va_arg(args, int *);
2355  *rint = op->stats.maxgrace;
2356  *type = CFAPI_INT;
2357  break;
2358 
2359  case CFAPI_OBJECT_PROP_DAM:
2360  rint = va_arg(args, int *);
2361  *rint = op->stats.dam;
2362  *type = CFAPI_INT;
2363  break;
2364 
2365  case CFAPI_OBJECT_PROP_GOD:
2366  rsstring = va_arg(args, sstring *);
2367  *rsstring = determine_god(op);
2368  *type = CFAPI_SSTRING;
2369  break;
2370 
2372  rsstring = va_arg(args, sstring *);
2373  *rsstring = op->arch->name;
2374  *type = CFAPI_SSTRING;
2375  break;
2376 
2378  rint = va_arg(args, int *);
2379  *rint = op->invisible;
2380  *type = CFAPI_INT;
2381  break;
2382 
2384  rbuffer = va_arg(args, char *);
2385  rbufsize = va_arg(args, int);
2386  if (rbufsize > 0) {
2387  strncpy(rbuffer, op->face->name, rbufsize);
2388  rbuffer[rbufsize - 1] = '\0';
2389  }
2390  *type = CFAPI_STRING;
2391  break;
2392 
2394  rbuffer = va_arg(args, char *);
2395  rbufsize = va_arg(args, int);
2396  if (rbufsize > 0) {
2397  if (op->animation_id != 0) {
2398  strncpy(rbuffer, animations[op->animation_id].name, rbufsize);
2399  rbuffer[rbufsize - 1] = '\0';
2400  }
2401  else
2402  rbuffer[0] = '\0';
2403  }
2404  *type = CFAPI_STRING;
2405  break;
2406 
2407  case CFAPI_PLAYER_PROP_IP:
2408  rsstring = va_arg(args, sstring *);
2409  *rsstring = op->contr->socket.host;
2410  *type = CFAPI_SSTRING;
2411  break;
2412 
2414  robject = va_arg(args, object **);
2415  *robject = find_marked_object(op);
2416  *type = CFAPI_POBJECT;
2417  break;
2418 
2420  rparty = va_arg(args, partylist **);
2421  *rparty = (op->contr ? op->contr->party : NULL);
2422  *type = CFAPI_PPARTY;
2423  break;
2424 
2426  robject = va_arg(args, object **);
2427  if (op)
2428  *robject = op->contr->next ? op->contr->next->ob : NULL;
2429  else
2430  /* This can be called when there is no player. */
2431  *robject = first_player ? first_player->ob : NULL;
2432  *type = CFAPI_POBJECT;
2433  break;
2434 
2436  rbuffer = va_arg(args, char *);
2437  rbufsize = va_arg(args, int);
2438  player_get_title(op->contr, rbuffer, rbufsize);
2439  *type = CFAPI_STRING;
2440  break;
2441 
2443  rmove = va_arg(args, MoveType *);
2444  *rmove = op->move_type;
2445  *type = CFAPI_MOVETYPE;
2446  break;
2447 
2449  rmove = va_arg(args, MoveType *);
2450  *rmove = op->move_block;
2451  *type = CFAPI_MOVETYPE;
2452  break;
2453 
2455  rmove = va_arg(args, MoveType *);
2456  *rmove = op->move_allow;
2457  *type = CFAPI_MOVETYPE;
2458  break;
2459 
2461  rmove = va_arg(args, MoveType *);
2462  *rmove = op->move_on;
2463  *type = CFAPI_MOVETYPE;
2464  break;
2465 
2467  rmove = va_arg(args, MoveType *);
2468  *rmove = op->move_off;
2469  *type = CFAPI_MOVETYPE;
2470  break;
2471 
2473  rmove = va_arg(args, MoveType *);
2474  *rmove = op->move_type;
2475  *type = CFAPI_MOVETYPE;
2476  break;
2477 
2479  rfloat = va_arg(args, float *);
2480  *rfloat = op->move_slow_penalty;
2481  *type = CFAPI_FLOAT;
2482  break;
2483 
2485  rbuffer = va_arg(args, char *);
2486  rbufsize = va_arg(args, int);
2487  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2488  *type = CFAPI_STRING;
2489  break;
2490 
2492  rint = va_arg(args, int *);
2493  *rint = op->contr->bed_x;
2494  *type = CFAPI_INT;
2495  break;
2496 
2498  rint = va_arg(args, int *);
2499  *rint = op->contr->bed_y;
2500  *type = CFAPI_INT;
2501  break;
2502 
2504  rint = va_arg(args, int *);
2505  *rint = op->duration;
2506  *type = CFAPI_INT;
2507  break;
2508 
2509  default:
2510  *type = CFAPI_NONE;
2511  break;
2512  }
2513  va_end(args);
2514 }
2515 
2524 static void copy_message(object *op, const char *msg) {
2525  char *temp;
2526  int size;
2527 
2528  if (!msg)
2529  return;
2530 
2531  /* need to reset parsed dialog information */
2533 
2534  size = strlen(msg);
2535 
2536  if (msg[0] != 0 && msg[size-1] == '\n') {
2537  object_set_msg(op, msg);
2538  return;
2539  }
2540 
2541  temp = malloc(size+2);
2542  if (!temp)
2544  snprintf(temp, size+2, "%s\n", msg);
2545  object_set_msg(op, temp);
2546  free(temp);
2547 }
2548 
2557 static void cfapi_object_set_property(int *type, ...) {
2558  va_list args;
2559  int iarg, *ret;
2560  long larg;
2561  char *sarg;
2562  double darg;
2563  object *oparg;
2564  object *op;
2565  int property;
2566  int64_t s64arg;
2567  partylist *partyarg;
2568  float farg;
2569  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2570 
2571  va_start(args, type);
2572  op = va_arg(args, object *);
2573  property = va_arg(args, int);
2574  *type = CFAPI_NONE;
2575 
2576  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2577  switch (property) {
2579  sarg = va_arg(args, char *);
2580  *type = CFAPI_STRING;
2581  FREE_AND_COPY(op->name, sarg);
2582  send_changed_object(op);
2583  break;
2584 
2586  sarg = va_arg(args, char *);
2587  *type = CFAPI_STRING;
2588  FREE_AND_COPY(op->name_pl, sarg);
2589  send_changed_object(op);
2590  break;
2591 
2593  sarg = va_arg(args, char *);
2594  *type = CFAPI_STRING;
2595  FREE_AND_COPY(op->title, sarg);
2596  break;
2597 
2599  sarg = va_arg(args, char *);
2600  *type = CFAPI_STRING;
2601  FREE_AND_COPY(op->race, sarg);
2602  break;
2603 
2605  sarg = va_arg(args, char *);
2606  *type = CFAPI_STRING;
2607  FREE_AND_COPY(op->slaying, sarg);
2608  break;
2609 
2611  sarg = va_arg(args, char *);
2612  *type = CFAPI_STRING;
2613  FREE_AND_COPY(op->skill, sarg);
2614  break;
2615 
2617  sarg = va_arg(args, char *);
2618  *type = CFAPI_STRING;
2619  copy_message(op, sarg);
2620  break;
2621 
2623  sarg = va_arg(args, char *);
2624  *type = CFAPI_STRING;
2625  FREE_AND_COPY(op->lore, sarg);
2626  break;
2627 
2629  farg = va_arg(args, double);
2630  *type = CFAPI_FLOAT;
2631  if (farg != op->speed) {
2632  op->speed = farg;
2633  object_update_speed(op);
2634  }
2635  break;
2636 
2638  farg = va_arg(args, double);
2639  *type = CFAPI_FLOAT;
2640  op->speed_left = farg;
2641  break;
2642 
2644  iarg = va_arg(args, int);
2645  *type = CFAPI_INT;
2646  if (iarg < 0)
2647  iarg = 0;
2648  if (op->nrof > (uint32_t)iarg)
2649  object_decrease_nrof(op, op->nrof-iarg);
2650  else if (op->nrof < (uint32_t)iarg) {
2651  object *tmp;
2652  player *pl;
2653 
2654  op->nrof = iarg;
2655  if (op->env != NULL) {
2656  tmp = object_get_player_container(op->env);
2657  if (!tmp) {
2658  for (pl = first_player; pl; pl = pl->next)
2659  if (pl->ob->container == op->env)
2660  break;
2661  if (pl)
2662  tmp = pl->ob;
2663  else
2664  tmp = NULL;
2665  } else {
2666  object_sum_weight(tmp);
2667  fix_object(tmp);
2668  }
2669  if (tmp)
2670  esrv_update_item(UPD_NROF, tmp, op);
2671  } else {
2672  FOR_ABOVE_PREPARE(op, tmp)
2673  if (tmp->type == PLAYER)
2674  tmp->contr->socket.update_look = 1;
2675  FOR_ABOVE_FINISH();
2676  }
2677  }
2678  break;
2679 
2681  iarg = va_arg(args, int);
2682  *type = CFAPI_INT;
2683  op->direction = iarg;
2684  break;
2685 
2687  iarg = va_arg(args, int);
2688  *type = CFAPI_INT;
2689  op->facing = iarg;
2690  break;
2691 
2692  case CFAPI_OBJECT_PROP_RESIST: {
2693  int iargbis = va_arg(args, int);
2694 
2695  *type = CFAPI_INT16;
2696  iarg = va_arg(args, int);
2697  op->resist[iargbis] = iarg;
2698  }
2699  break;
2700 
2702  iarg = va_arg(args, int);
2703  *type = CFAPI_INT;
2704  op->attacktype = iarg;
2705  break;
2706 
2708  iarg = va_arg(args, int);
2709  *type = CFAPI_INT;
2710  op->path_attuned = iarg;
2711  break;
2712 
2714  iarg = va_arg(args, int);
2715  *type = CFAPI_INT;
2716  op->path_repelled = iarg;
2717  break;
2718 
2720  iarg = va_arg(args, int);
2721  *type = CFAPI_INT;
2722  op->path_denied = iarg;
2723  break;
2724 
2726  iarg = va_arg(args, int);
2727  *type = CFAPI_INT;
2728  op->material = iarg;
2729  break;
2730 
2732  break;
2733 
2735  iarg = va_arg(args, int);
2736  *type = CFAPI_INT;
2737  op->magic = iarg;
2738  break;
2739 
2741  larg = va_arg(args, long);
2742  *type = CFAPI_LONG;
2743  op->value = larg;
2744  break;
2745 
2747  iarg = va_arg(args, int);
2748  *type = CFAPI_INT;
2749  op->level = iarg;
2750  send_changed_object(op);
2751  break;
2752 
2754  iarg = va_arg(args, int);
2755  *type = CFAPI_INT;
2756  op->last_heal = iarg;
2757  break;
2758 
2760  iarg = va_arg(args, int);
2761  *type = CFAPI_INT;
2762  op->last_sp = iarg;
2763  break;
2764 
2766  iarg = va_arg(args, int);
2767  *type = CFAPI_INT;
2768  op->last_grace = iarg;
2769  break;
2770 
2772  iarg = va_arg(args, int);
2773  *type = CFAPI_INT;
2774  op->last_eat = iarg;
2775  break;
2776 
2778  iarg = va_arg(args, int);
2779  *type = CFAPI_INT;
2780  op->invisible = iarg;
2781  break;
2782 
2784  iarg = va_arg(args, int);
2785  *type = CFAPI_INT;
2786  op->pick_up = iarg;
2787  break;
2788 
2790  iarg = va_arg(args, int);
2791  *type = CFAPI_INT;
2792  op->item_power = iarg;
2793  break;
2794 
2796  iarg = va_arg(args, int);
2797  *type = CFAPI_INT;
2798  op->gen_sp_armour = iarg;
2799  break;
2800 
2802  iarg = va_arg(args, int);
2803  *type = CFAPI_INT;
2804  if (op->weight != iarg) {
2805  object *tmp;
2806  player *pl;
2807 
2808  op->weight = iarg;
2809  if (op->env != NULL) {
2810  tmp = object_get_player_container(op->env);
2811  if (!tmp) {
2812  for (pl = first_player; pl; pl = pl->next)
2813  if (pl->ob->container == op->env)
2814  break;
2815  if (pl)
2816  tmp = pl->ob;
2817  else
2818  tmp = NULL;
2819  } else {
2820  object_sum_weight(tmp);
2821  fix_object(tmp);
2822  }
2823  if (tmp)
2824  esrv_update_item(UPD_WEIGHT, tmp, op);
2825  } else {
2826  FOR_ABOVE_PREPARE(op, tmp)
2827  if (tmp->type == PLAYER)
2828  esrv_update_item(UPD_WEIGHT, tmp, op);
2829  FOR_ABOVE_FINISH();
2830  }
2831  }
2832  break;
2833 
2835  iarg = va_arg(args, int);
2836  *type = CFAPI_INT;
2837  op->weight_limit = iarg;
2838  break;
2839 
2841  iarg = va_arg(args, int);
2842  *type = CFAPI_INT;
2843  if (op->glow_radius != iarg) {
2844  object *tmp;
2845 
2846  op->glow_radius = iarg;
2847  tmp = object_get_env_recursive(op);
2848  if (tmp->map != NULL) {
2849  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2850  update_position(tmp->map, tmp->x, tmp->y);
2851  update_all_los(tmp->map, tmp->x, tmp->y);
2852  }
2853  }
2854  break;
2855 
2857  s64arg = va_arg(args, int64_t);
2858  *type = CFAPI_SINT64;
2859  op->perm_exp = s64arg;
2860  break;
2861 
2863  oparg = va_arg(args, object *);
2864  *type = CFAPI_POBJECT;
2865  object_set_enemy(op, oparg);
2866  break;
2867 
2869  iarg = va_arg(args, int);
2870  *type = CFAPI_INT;
2871  op->run_away = iarg;
2872  break;
2873 
2875  oparg = va_arg(args, object *);
2876  *type = CFAPI_POBJECT;
2877  op->chosen_skill = oparg;
2878  break;
2879 
2881  iarg = va_arg(args, int);
2882  *type = CFAPI_INT;
2883  op->hide = iarg;
2884  break;
2885 
2887  iarg = va_arg(args, int);
2888  *type = CFAPI_INT;
2889  op->move_status = iarg;
2890  break;
2891 
2893  iarg = va_arg(args, int);
2894  *type = CFAPI_INT;
2895  op->attack_movement = iarg;
2896  break;
2897 
2899  oparg = va_arg(args, object *);
2900  *type = CFAPI_POBJECT;
2901  op->spellitem = oparg;
2902  break;
2903 
2905  darg = va_arg(args, double);
2906  *type = CFAPI_DOUBLE;
2907  op->expmul = darg;
2908  break;
2909 
2911  sarg = va_arg(args, char *);
2912  *type = CFAPI_STRING;
2913  FREE_AND_COPY(op->custom_name, sarg);
2914  send_changed_object(op);
2915  break;
2916 
2918  iarg = va_arg(args, int);
2919  *type = CFAPI_INT;
2920  op->anim_speed = iarg;
2921  break;
2922 
2924  iarg = va_arg(args, int);
2925  *type = CFAPI_INT;
2926  if (iarg == 1 && is_friendly(op) == 0)
2927  add_friendly_object(op);
2928  else if (iarg == 0 && is_friendly(op) == 1)
2930  break;
2931 
2933  iarg = va_arg(args, int);
2934  *type = CFAPI_INT;
2935  op->stats.luck = iarg;
2936  break;
2937 
2938  case CFAPI_OBJECT_PROP_EXP:
2939  s64arg = va_arg(args, int64_t);
2940  *type = CFAPI_SINT64;
2941  op->stats.exp = s64arg;
2942  break;
2943 
2945  oparg = va_arg(args, object *);
2946  *type = CFAPI_POBJECT;
2947  object_set_owner(op, oparg);
2948  break;
2949 
2951  object_set_cheat(op);
2952  *type = CFAPI_NONE;
2953  break;
2954 
2955  case CFAPI_OBJECT_PROP_FLAGS: {
2956  int iargbis;
2957 
2958  iarg = va_arg(args, int);
2959  iargbis = va_arg(args, int);
2960  *type = CFAPI_INT;
2961 
2962  if (iargbis == 1)
2963  SET_FLAG(op, iarg);
2964  else
2965  CLEAR_FLAG(op, iarg);
2966  }
2967  break;
2968 
2969  case CFAPI_OBJECT_PROP_STR:
2970  iarg = va_arg(args, int);
2971  *type = CFAPI_INT;
2972  op->stats.Str = iarg;
2973  break;
2974 
2975  case CFAPI_OBJECT_PROP_DEX:
2976  iarg = va_arg(args, int);
2977  *type = CFAPI_INT;
2978  op->stats.Dex = iarg;
2979  break;
2980 
2981  case CFAPI_OBJECT_PROP_CON:
2982  iarg = va_arg(args, int);
2983  *type = CFAPI_INT;
2984  op->stats.Con = iarg;
2985  break;
2986 
2987  case CFAPI_OBJECT_PROP_WIS:
2988  iarg = va_arg(args, int);
2989  *type = CFAPI_INT;
2990  op->stats.Wis = iarg;
2991  break;
2992 
2993  case CFAPI_OBJECT_PROP_INT:
2994  iarg = va_arg(args, int);
2995  *type = CFAPI_INT;
2996  op->stats.Int = iarg;
2997  break;
2998 
2999  case CFAPI_OBJECT_PROP_POW:
3000  iarg = va_arg(args, int);
3001  *type = CFAPI_INT;
3002  op->stats.Pow = iarg;
3003  break;
3004 
3005  case CFAPI_OBJECT_PROP_CHA:
3006  iarg = va_arg(args, int);
3007  *type = CFAPI_INT;
3008  op->stats.Cha = iarg;
3009  break;
3010 
3011  case CFAPI_OBJECT_PROP_WC:
3012  iarg = va_arg(args, int);
3013  *type = CFAPI_INT;
3014  op->stats.wc = iarg;
3015  break;
3016 
3017  case CFAPI_OBJECT_PROP_AC:
3018  iarg = va_arg(args, int);
3019  *type = CFAPI_INT;
3020  op->stats.ac = iarg;
3021  break;
3022 
3023  case CFAPI_OBJECT_PROP_HP:
3024  iarg = va_arg(args, int);
3025  *type = CFAPI_INT;
3026  op->stats.hp = iarg;
3027  break;
3028 
3029  case CFAPI_OBJECT_PROP_SP:
3030  iarg = va_arg(args, int);
3031  *type = CFAPI_INT;
3032  op->stats.sp = iarg;
3033  break;
3034 
3035  case CFAPI_OBJECT_PROP_GP:
3036  iarg = va_arg(args, int);
3037  *type = CFAPI_INT;
3038  op->stats.grace = iarg;
3039  break;
3040 
3041  case CFAPI_OBJECT_PROP_FP:
3042  iarg = va_arg(args, int);
3043  *type = CFAPI_INT;
3044  op->stats.food = iarg;
3045  break;
3046 
3048  iarg = va_arg(args, int);
3049  *type = CFAPI_INT;
3050  op->stats.maxhp = iarg;
3051  break;
3052 
3054  iarg = va_arg(args, int);
3055  *type = CFAPI_INT;
3056  op->stats.maxsp = iarg;
3057  break;
3058 
3060  iarg = va_arg(args, int);
3061  *type = CFAPI_INT;
3062  op->stats.maxgrace = iarg;
3063  break;
3064 
3065  case CFAPI_OBJECT_PROP_DAM:
3066  iarg = va_arg(args, int);
3067  *type = CFAPI_INT;
3068  op->stats.dam = iarg;
3069  break;
3070 
3071  case CFAPI_OBJECT_PROP_FACE: {
3072  sarg = va_arg(args, char *);
3073  ret = va_arg(args, int *);
3074  *type = CFAPI_INT;
3075  *ret = find_face(sarg, 0);
3076  if (*ret != 0) {
3077  op->face = &new_faces[*ret];
3078  op->state = 0;
3080  }
3081  break;
3082  }
3083 
3085  sarg = va_arg(args, char *);
3086  ret = va_arg(args, int *);
3087  *type = CFAPI_INT;
3088  *ret = try_find_animation(sarg);
3089  if (*ret != 0) {
3090  op->animation_id = *ret;
3091  SET_ANIMATION(op, 0);
3093  }
3094  break;
3095 
3097  iarg = va_arg(args, int);
3098  *type = CFAPI_INT;
3099  op->duration = iarg;
3100  break;
3101 
3103  if (op->contr) {
3104  oparg = va_arg(args, object *);
3105  *type = CFAPI_POBJECT;
3106  op->contr->mark = oparg;
3107  if (oparg) {
3108  op->contr->mark_count = oparg->count;
3109  } else {
3110  op->contr->mark_count = 0;
3111  }
3112  }
3113  break;
3114 
3116  if (op->contr) {
3117  partyarg = va_arg(args, partylist *);
3118  *type = CFAPI_PPARTY;
3119  party_join(op, partyarg);
3120  }
3121  break;
3122 
3124  sarg = va_arg(args, char *);
3125  *type = CFAPI_STRING;
3126  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
3127  break;
3128 
3130  iarg = va_arg(args, int);
3131  *type = CFAPI_INT;
3132  op->contr->bed_x = iarg;
3133  break;
3134 
3136  iarg = va_arg(args, int);
3137  *type = CFAPI_INT;
3138  op->contr->bed_y = iarg;
3139  break;
3140 
3142  sarg = va_arg(args, char *);
3143  *type = CFAPI_STRING;
3144  player_set_own_title(op->contr, sarg);
3145  break;
3146 
3148  move = va_arg(args, MoveType *);
3149  op->move_type = *move & MOVE_ALL;
3151  *type = CFAPI_MOVETYPE;
3152  break;
3153 
3155  move = va_arg(args, MoveType *);
3156  op->move_block = *move & MOVE_ALL;
3158  *type = CFAPI_MOVETYPE;
3159  break;
3160 
3162  move = va_arg(args, MoveType *);
3163  op->move_allow = *move & MOVE_ALL;
3165  *type = CFAPI_MOVETYPE;
3166  break;
3167 
3169  move = va_arg(args, MoveType *);
3170  op->move_on = *move & MOVE_ALL;
3172  *type = CFAPI_MOVETYPE;
3173  break;
3174 
3176  move = va_arg(args, MoveType *);
3177  op->move_off = *move & MOVE_ALL;
3179  *type = CFAPI_MOVETYPE;
3180  break;
3181 
3183  move = va_arg(args, MoveType *);
3184  op->move_type = *move & MOVE_ALL;
3186  *type = CFAPI_MOVETYPE;
3187  break;
3188 
3189  default:
3190  break;
3191  }
3192  }
3193  va_end(args);
3194 }
3195 
3202 static void cfapi_object_apply_below(int *type, ...) {
3203  va_list args;
3204  object *applier;
3205 
3206  va_start(args, type);
3207 
3208  applier = va_arg(args, object *);
3209 
3210  va_end(args);
3211 
3212  apply_by_living_below(applier);
3213  *type = CFAPI_NONE;
3214 }
3215 
3222 static void cfapi_object_apply(int *type, ...) {
3223  va_list args;
3224  object *applied;
3225  object *applier;
3226  int aflags;
3227  int *ret;
3228 
3229  va_start(args, type);
3230 
3231  applier = va_arg(args, object *);
3232  applied = va_arg(args, object *);
3233  aflags = va_arg(args, int);
3234  ret = va_arg(args, int *);
3235 
3236  va_end(args);
3237 
3238  *type = CFAPI_INT;
3239  *ret = apply_manual(applier, applied, aflags);
3240 }
3241 
3247 static void cfapi_object_identify(int *type, ...) {
3248  va_list args;
3249  object *op, **result;
3250 
3251  va_start(args, type);
3252 
3253  op = va_arg(args, object *);
3254  result = va_arg(args, object **);
3255 
3256  va_end(args);
3257 
3258  (*result) = identify(op);
3259  *type = CFAPI_POBJECT;
3260 }
3261 
3267 static void cfapi_object_describe(int *type, ...) {
3268  va_list args;
3269  object *op;
3270  object *owner;
3271  char *desc, *final;
3272  int size;
3273 
3274  va_start(args, type);
3275 
3276  op = va_arg(args, object *);
3277  owner = va_arg(args, object *);
3278  desc = va_arg(args, char *);
3279  size = va_arg(args, int);
3280  va_end(args);
3281 
3282  *type = CFAPI_STRING;
3283  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3284  strncpy(desc, final, size);
3285  desc[size - 1] = '\0';
3286  free(final);
3287 }
3288 
3289 static void cfapi_object_drain(int *type, ...) {
3290  va_list args;
3291 
3292  object *op;
3293  int ds;
3294 
3295  va_start(args, type);
3296 
3297  op = va_arg(args, object *);
3298  ds = va_arg(args, int);
3299 
3300  va_end(args);
3301 
3302  drain_specific_stat(op, ds);
3303 
3304  *type = CFAPI_NONE;
3305 }
3306 
3307 static void cfapi_object_remove_depletion(int *type, ...) {
3308  va_list args;
3309 
3310  object *op;
3311  int level, *result;
3312 
3313  va_start(args, type);
3314 
3315  op = va_arg(args, object *);
3316  level = va_arg(args, int);
3317  result = va_arg(args, int*);
3318 
3319  va_end(args);
3320 
3321  *result = remove_depletion(op, level);
3322 
3323  *type = CFAPI_INT;
3324 }
3325 
3326 static void cfapi_object_fix(int *type, ...) {
3327  va_list args;
3328  object *op;
3329 
3330  va_start(args, type);
3331 
3332  op = va_arg(args, object *);
3333 
3334  va_end(args);
3335 
3336  fix_object(op);
3337 
3338  *type = CFAPI_NONE;
3339 }
3340 
3342 static void cfapi_object_give_skill(int *type, ...) {
3343  va_list args;
3344 
3345  object *op;
3346  char *skillname;
3347 
3348  va_start(args, type);
3349 
3350  op = va_arg(args, object *);
3351  skillname = va_arg(args, char *);
3352 
3353  va_end(args);
3354 
3355  *type = CFAPI_POBJECT;
3356  give_skill_by_name(op, skillname);
3357 }
3358 
3359 static void cfapi_object_transmute(int *type, ...) {
3360  va_list args;
3361 
3362  object *op;
3363  object *chg;
3364 
3365  va_start(args, type);
3366 
3367  op = va_arg(args, object *);
3368  chg = va_arg(args, object *);
3369 
3370  va_end(args);
3371 
3372  transmute_materialname(op, chg);
3373  *type = CFAPI_NONE;
3374 }
3375 
3376 static void cfapi_object_remove(int *type, ...) {
3377  va_list args;
3378  object *op;
3379 
3380  va_start(args, type);
3381 
3382  op = va_arg(args, object *);
3383 
3384  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3385  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3386  va_end(args);
3387  *type = CFAPI_NONE;
3388  return;
3389  }
3390 
3391  va_end(args);
3392 
3393  object_remove(op);
3394  *type = CFAPI_NONE;
3395 }
3396 
3397 static void cfapi_object_delete(int *type, ...) {
3398  va_list args;
3399  object *op;
3400 
3401  va_start(args, type);
3402 
3403  op = va_arg(args, object *);
3404 
3405  if (QUERY_FLAG(op, FLAG_FREED) || !QUERY_FLAG(op, FLAG_REMOVED)) {
3406  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3407  *type = CFAPI_NONE;
3408  va_end(args);
3409  return;
3410  }
3411 
3412  va_end(args);
3413 
3415 
3416  *type = CFAPI_NONE;
3417 }
3418 
3424 static void cfapi_object_clone(int *type, ...) {
3425  va_list args;
3426  object *op;
3427  int kind;
3428  object **robj;
3429 
3430  va_start(args, type);
3431 
3432  op = va_arg(args, object *);
3433  kind = va_arg(args, int);
3434  robj = va_arg(args, object **);
3435 
3436  va_end(args);
3437 
3438  if (kind == 0) {
3439  *type = CFAPI_POBJECT;
3440  *robj = object_create_clone(op);
3441  } else {
3442  object *tmp;
3443  tmp = object_new();
3444  object_copy(op, tmp);
3445  *type = CFAPI_POBJECT;
3446  *robj = tmp;
3447  }
3448  return;
3449 }
3450 
3456 static void cfapi_object_create(int *type, ...) {
3457  va_list args;
3458  int ival;
3459  object **robj;
3460  va_start(args, type);
3461  ival = va_arg(args, int);
3462 
3463  *type = CFAPI_POBJECT;
3464  switch (ival) {
3465  case 0:
3466  robj = va_arg(args, object **);
3467  *robj = object_new();
3468  break;
3469 
3470  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3471  const char *sval;
3472  archetype *at;
3473 
3474  sval = va_arg(args, const char *);
3475  robj = va_arg(args, object **);
3476  va_end(args);
3477 
3478  at = try_find_archetype(sval);
3479  if (!at)
3480  at = find_archetype_by_object_name(sval);
3481  if (at) {
3482  *robj = object_create_arch(at);
3483  } else
3484  *robj = NULL;
3485  }
3486  break;
3487 
3488  default:
3489  *type = CFAPI_NONE;
3490  break;
3491  }
3492  va_end(args);
3493 }
3494 
3495 static void cfapi_object_insert(int *type, ...) {
3496  va_list args;
3497  object *op;
3498  object *orig;
3499  mapstruct *map;
3500  int flag, x, y;
3501  int itype;
3502  object **robj;
3503 
3504  va_start(args, type);
3505 
3506  op = va_arg(args, object *);
3507  if (!op) {
3508  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3509  va_end(args);
3510  return;
3511  }
3512  if (QUERY_FLAG(op, FLAG_FREED)) {
3513  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3514  va_end(args);
3515  return;
3516  }
3517  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3518  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3519  object_remove(op);
3520  }
3521  itype = va_arg(args, int);
3522 
3523  switch (itype) {
3524  case 0:
3525  map = va_arg(args, mapstruct *);
3526  orig = va_arg(args, object *);
3527  flag = va_arg(args, int);
3528  x = va_arg(args, int);
3529  y = va_arg(args, int);
3530  robj = va_arg(args, object **);
3531  if (!map) {
3532  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3534  *robj = NULL;
3535  } else
3536  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3537  *type = CFAPI_POBJECT;
3538  break;
3539 
3540  case 1:
3541  map = va_arg(args, mapstruct *);
3542  orig = va_arg(args, object *);
3543  flag = va_arg(args, int);
3544  robj = va_arg(args, object **);
3545  if (!map) {
3546  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3548  *robj = NULL;
3549  } else
3550  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3551  *type = CFAPI_POBJECT;
3552  break;
3553 
3554  case 2:
3555  map = va_arg(args, mapstruct *);
3556  orig = va_arg(args, object *);
3557  flag = va_arg(args, int);
3558  x = va_arg(args, int);
3559  y = va_arg(args, int);
3560  robj = va_arg(args, object **);
3561  if (!map) {
3562  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3564  *robj = NULL;
3565  } else {
3566  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3567  if (dir != -1) {
3568  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3569  } else {
3571  *robj = NULL;
3572  }
3573  }
3574  *type = CFAPI_POBJECT;
3575  break;
3576 
3577  case 3:
3578  orig = va_arg(args, object *);
3579  robj = va_arg(args, object **);
3580  if (!orig) {
3581  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3583  *robj = NULL;
3584  } else
3585  *robj = object_insert_in_ob(op, orig);
3586  *type = CFAPI_POBJECT;
3587  break;
3588 
3589  default:
3590  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3592  *type = CFAPI_NONE;
3593  break;
3594  }
3595 
3596  va_end(args);
3597 }
3603 static void cfapi_object_split(int *type, ...) {
3604  va_list args;
3605 
3606  int nr, size;
3607  object *op;
3608  char *buf;
3609  object **split;
3610 
3611  va_start(args, type);
3612 
3613  op = va_arg(args, object *);
3614  nr = va_arg(args, int);
3615  buf = va_arg(args, char *);
3616  size = va_arg(args, int);
3617  split = va_arg(args, object **);
3618  va_end(args);
3619 
3620  *split = object_split(op, nr, buf, size);
3621  if (*split != NULL)
3622  {
3623  *type = CFAPI_POBJECT;
3624  }
3625  else
3626  {
3627  *type = CFAPI_NONE;
3628  }
3629 }
3630 
3636 static void cfapi_object_merge(int *type, ...) {
3637  va_list args;
3638  object *op;
3639  object *op2;
3640  object **merge;
3641 
3642  va_start(args, type);
3643 
3644  op = va_arg(args, object *);
3645  op2 = va_arg(args, object *);
3646  merge = va_arg(args, object **);
3647 
3648  va_end(args);
3649 
3650  *type = CFAPI_POBJECT;
3651  *merge = object_merge(op, op2);
3652 }
3653 
3659 static void cfapi_object_distance(int *type, ...) {
3660  va_list args;
3661  object *op;
3662  object *op2;
3663  int *rint;
3664  va_start(args, type);
3665 
3666  op = va_arg(args, object *);
3667  op2 = va_arg(args, object *);
3668  rint = va_arg(args, int *);
3669 
3670  va_end(args);
3671 
3672  *type = CFAPI_INT;
3673  *rint = object_distance(op, op2);
3674 }
3680 static void cfapi_object_update(int *type, ...) {
3681  va_list args;
3682  int action;
3683  object *op;
3684  va_start(args, type);
3685 
3686  op = va_arg(args, object *);
3687  action = va_arg(args, int);
3688 
3689  va_end(args);
3690 
3691  object_update(op, action);
3692  *type = CFAPI_NONE;
3693 }
3694 
3700 static void cfapi_object_clear(int *type, ...) {
3701  va_list args;
3702  object *op;
3703  va_start(args, type);
3704 
3705  op = va_arg(args, object *);
3706 
3707  va_end(args);
3708 
3709  object_clear(op);
3710  *type = CFAPI_NONE;
3711 }
3712 
3718 static void cfapi_object_reset(int *type, ...) {
3719  va_list args;
3720  object *op;
3721 
3722  va_start(args, type);
3723 
3724  op = va_arg(args, object *);
3725 
3726  va_end(args);
3727 
3728  object_reset(op);
3729  *type = CFAPI_NONE;
3730 }
3731 
3732 static void cfapi_object_clean_object(int *type, ...) {
3733  va_list args;
3734  object *op;
3735 
3736  va_start(args, type);
3737  op = va_arg(args, object *);
3738  clean_object(op);
3739  va_end(args);
3740  *type = CFAPI_NONE;
3741 }
3742 
3743 static void cfapi_object_on_same_map(int *type, ...) {
3744  va_list args;
3745  object *op1;
3746  object *op2;
3747  int *rint;
3748 
3749  va_start(args, type);
3750  op1 = va_arg(args, object *);
3751  op2 = va_arg(args, object *);
3752  rint = va_arg(args, int *);
3753  va_end(args);
3754 
3755  *type = CFAPI_INT;
3756  *rint = on_same_map(op1, op2);
3757 }
3758 
3759 static void cfapi_object_spring_trap(int *type, ...) {
3760  object *trap;
3761  object *victim;
3762  va_list args;
3763 
3764  va_start(args, type);
3765  trap = va_arg(args, object *);
3766  victim = va_arg(args, object *);
3767  va_end(args);
3768 
3769  spring_trap(trap, victim);
3770  *type = CFAPI_NONE;
3771 }
3772 
3778 static void cfapi_object_check_trigger(int *type, ...) {
3779  object *op;
3780  object *cause;
3781  va_list args;
3782  int *rint;
3783 
3784  va_start(args, type);
3785  op = va_arg(args, object *);
3786  cause = va_arg(args, object *);
3787  rint = va_arg(args, int *);
3788  va_end(args);
3789 
3790  *rint = check_trigger(op, cause);
3791  *type = CFAPI_INT;
3792 }
3793 
3805 static void cfapi_map_trigger_connected(int *type, ...) {
3806  objectlink *ol;
3807  object *cause;
3808  int state;
3809  va_list args;
3810 
3811  va_start(args, type);
3812  ol = va_arg(args, objectlink *);
3813  cause = va_arg(args, object *);
3814  state = va_arg(args, int);
3815  va_end(args);
3816  trigger_connected(ol, cause, state);
3817  *type = CFAPI_NONE;
3818 }
3819 
3825 static void cfapi_object_query_money(int *type, ...) {
3826  object *op;
3827  va_list args;
3828  int *rint;
3829 
3830  va_start(args, type);
3831  op = va_arg(args, object *);
3832  rint = va_arg(args, int *);
3833  va_end(args);
3834 
3835  *rint = query_money(op);
3836  *type = CFAPI_INT;
3837 }
3838 
3844 static void cfapi_object_cast(int *type, ...) {
3845  object *op;
3846  object *sp;
3847  int dir;
3848  char *str;
3849  object *caster;
3850  va_list args;
3851  int *rint;
3852 
3853  va_start(args, type);
3854  op = va_arg(args, object *);
3855  caster = va_arg(args, object *);
3856  dir = va_arg(args, int);
3857  sp = va_arg(args, object *);
3858  str = va_arg(args, char *);
3859  rint = va_arg(args, int *);
3860  va_end(args);
3861 
3862  *type = CFAPI_INT;
3863 
3864  if (!op->map) {
3865  *rint = -1;
3866  return;
3867  }
3868 
3869  *rint = cast_spell(op, caster, dir, sp, str);
3870 }
3871 
3872 static void cfapi_object_learn_spell(int *type, ...) {
3873  object *op;
3874  object *sp;
3875  int prayer;
3876  va_list args;
3877 
3878  va_start(args, type);
3879  op = va_arg(args, object *);
3880  sp = va_arg(args, object *);
3881  prayer = va_arg(args, int);
3882  va_end(args);
3883  do_learn_spell(op, sp, prayer);
3884  *type = CFAPI_NONE;
3885 }
3886 
3887 static void cfapi_object_forget_spell(int *type, ...) {
3888  object *op;
3889  object *sp;
3890  va_list args;
3891  char name[MAX_BUF];
3892 
3893  va_start(args, type);
3894  op = va_arg(args, object *);
3895  sp = va_arg(args, object *);
3896  va_end(args);
3897  query_name(sp, name, MAX_BUF);
3898  do_forget_spell(op, name);
3899  *type = CFAPI_NONE;
3900 }
3901 
3907 static void cfapi_object_check_spell(int *type, ...) {
3908  object *op;
3909  char *spellname;
3910  va_list args;
3911  object **robj;
3912 
3913  va_start(args, type);
3914  op = va_arg(args, object *);
3915  spellname = va_arg(args, char *);
3916  robj = va_arg(args, object **);
3917  va_end(args);
3918  *robj = check_spell_known(op, spellname);
3919  *type = CFAPI_POBJECT;
3920 }
3921 
3927 static void cfapi_object_pay_amount(int *type, ...) {
3928  object *op;
3929  uint64_t amount;
3930  va_list args;
3931  int *rint;
3932 
3933  va_start(args, type);
3934  op = va_arg(args, object *);
3935  amount = va_arg(args, uint64_t);
3936  rint = va_arg(args, int *);
3937  va_end(args);
3938 
3939  *rint = pay_for_amount(amount, op);
3940  *type = CFAPI_INT;
3941 }
3942 
3948 static void cfapi_object_pay_item(int *type, ...) {
3949  object *op;
3950  object *tobuy;
3951  int *rint;
3952 
3953  va_list args;
3954 
3955  va_start(args, type);
3956  tobuy = va_arg(args, object *);
3957  op = va_arg(args, object *);
3958  rint = va_arg(args, int *);
3959  va_end(args);
3960 
3961  *rint = pay_for_item(tobuy, op);
3962  *type = CFAPI_INT;
3963 }
3964 
3972 static void cfapi_object_transfer(int *type, ...) {
3973  object *op;
3974  object *originator;
3975  int x, y, randompos, ttype, flag;
3976  va_list args;
3977  mapstruct *map;
3978  int *rint;
3979  object **robj;
3980 
3981  va_start(args, type);
3982  op = va_arg(args, object *);
3983  ttype = va_arg(args, int);
3984  switch (ttype) {
3985  case 0:
3986  x = va_arg(args, int);
3987  y = va_arg(args, int);
3988  randompos = va_arg(args, int);
3989  originator = va_arg(args, object *);
3990  rint = va_arg(args, int *);
3991  va_end(args);
3992 
3993  *rint = transfer_ob(op, x, y, randompos, originator);
3994  *type = CFAPI_INT;
3995  return;
3996  break;
3997 
3998  case 1:
3999  map = va_arg(args, mapstruct *);
4000  originator = va_arg(args, object *);
4001  flag = va_arg(args, int);
4002  x = va_arg(args, int);
4003  y = va_arg(args, int);
4004  robj = va_arg(args, object **);
4005  va_end(args);
4006  if (x < 0 || y < 0) {
4007  x = map->enter_x;
4008  y = map->enter_y;
4009  }
4010  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
4011  *type = CFAPI_POBJECT;
4012  return;
4013  break;
4014 
4015  case 2:
4016  x = va_arg(args, int);
4017  y = va_arg(args, int);
4018  rint = va_arg(args, int *);
4019  va_end(args);
4020 
4021  *rint = move_to(op, x, y);
4022  *type = CFAPI_INT;
4023  return;
4024 
4025  default:
4026  va_end(args);
4027  *type = CFAPI_NONE;
4028  return;
4029  break;
4030  }
4031 }
4032 
4036 static void cfapi_object_find_archetype_inside(int *type, ...) {
4037  object *op;
4038  char *str;
4039  va_list args;
4040  object **robj;
4041 
4042  *type = CFAPI_POBJECT;
4043  va_start(args, type);
4044  op = va_arg(args, object *);
4045 
4046  str = va_arg(args, char *);
4047  robj = va_arg(args, object **);
4048  archetype *at = try_find_archetype(str);
4049  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
4050  if (*robj == NULL) {
4051  char name[MAX_BUF];
4052 
4053  /* Search by name or slaying instead */
4054  FOR_INV_PREPARE(op, tmp) {
4055  query_name(tmp, name, MAX_BUF);
4056  if (!strncmp(name, str, strlen(str)))
4057  *robj = tmp;
4058  if (!strncmp(tmp->name, str, strlen(str)))
4059  *robj = tmp;
4060  if (tmp->slaying && !strcmp(tmp->slaying, str))
4061  *robj = tmp;
4062  if (*robj != NULL)
4063  break;
4064  } FOR_INV_FINISH();
4065  }
4066  va_end(args);
4067 }
4068 
4069 static void cfapi_object_find_by_arch_name(int *type, ...) {
4070  const object *who;
4071  object **result;
4072  const char *name;
4073  va_list args;
4074 
4075  va_start(args, type);
4076  who = va_arg(args, const object *);
4077  name = va_arg(args, const char *);
4078  result = va_arg(args, object **);
4079  va_end(args);
4080  *type = CFAPI_POBJECT;
4081 
4082  *result = object_find_by_arch_name(who, name);
4083 }
4084 
4085 static void cfapi_object_find_by_name(int *type, ...) {
4086  const object *who;
4087  object **result;
4088  const char *name;
4089  va_list args;
4090 
4091  va_start(args, type);
4092  who = va_arg(args, const object *);
4093  name = va_arg(args, const char *);
4094  result = va_arg(args, object **);
4095  va_end(args);
4096  *type = CFAPI_POBJECT;
4097 
4098  *result = object_find_by_name(who, name);
4099 }
4100 
4106 static void cfapi_object_drop(int *type, ...) {
4107  object *op;
4108  object *author;
4109  va_list args;
4110 
4111  va_start(args, type);
4112  op = va_arg(args, object *);
4113  author = va_arg(args, object *);
4114  va_end(args);
4115  *type = CFAPI_NONE;
4116 
4117  if (QUERY_FLAG(op, FLAG_NO_DROP))
4118  return;
4119  drop(author, op);
4120 
4121  if (author->type == PLAYER) {
4122  author->contr->count = 0;
4123  author->contr->socket.update_look = 1;
4124  }
4125 }
4126 
4130 static void cfapi_object_change_abil(int *type, ...) {
4131  object *op, *tmp;
4132  int *rint;
4133  va_list args;
4134 
4135  va_start(args, type);
4136  op = va_arg(args, object *);
4137  tmp = va_arg(args, object *);
4138  rint = va_arg(args, int *);
4139  va_end(args);
4140 
4141  *type = CFAPI_INT;
4142  *rint = change_abil(op, tmp);
4143 }
4144 
4145 static void cfapi_object_say(int *type, ...) {
4146  object *op;
4147  char *msg;
4148  va_list args;
4149  int *rint;
4150  char empty[] = "";
4151 
4152  va_start(args, type);
4153  op = va_arg(args, object *);
4154  msg = va_arg(args, char *);
4155  rint = va_arg(args, int *);
4156  va_end(args);
4157 
4158  if (op->type == PLAYER) {
4159  command_say(op, msg == NULL ? empty : msg);
4160  } else {
4161  monster_npc_say(op, msg);
4162  }
4163  *rint = 0;
4164  *type = CFAPI_INT;
4165 }
4166 
4167 /* PLAYER SUBCLASS */
4168 
4174 static void cfapi_player_find(int *type, ...) {
4175  va_list args;
4176  char *sval;
4177  player **rpl;
4178  va_start(args, type);
4179 
4180  sval = va_arg(args, char *);
4181  rpl = va_arg(args, player **);
4182  va_end(args);
4183 
4184  *rpl = find_player_partial_name(sval);
4185 
4186  *type = CFAPI_PPLAYER;
4187 }
4188 
4189 static void cfapi_player_message(int *type, ...) {
4190  va_list args;
4191  int flags;
4192  int pri;
4193  object *pl;
4194  char *buf;
4195 
4196  va_start(args, type);
4197 
4198  flags = va_arg(args, int);
4199  pri = va_arg(args, int);
4200  pl = va_arg(args, object *);
4201  buf = va_arg(args, char *);
4202  va_end(args);
4203 
4204  draw_ext_info(flags, pri, pl, MSG_TYPE_MISC, MSG_SUBTYPE_NONE,
4205  buf);
4206  *type = CFAPI_NONE;
4207 }
4208 
4214 static void cfapi_object_change_exp(int *type, ...) {
4215  va_list args;
4216  int flag;
4217  object *ob;
4218  const char *skill;
4219  int64_t exp;
4220 
4221  va_start(args, type);
4222  ob = va_arg(args, object *);
4223  exp = va_arg(args, int64_t);
4224  skill = va_arg(args, const char *);
4225  flag = va_arg(args, int);
4226  va_end(args);
4227 
4228  *type = CFAPI_NONE;
4229  change_exp(ob, exp, skill, flag);
4230 }
4231 
4237 static void cfapi_player_can_pay(int *type, ...) {
4238  va_list args;
4239  object *pl;
4240  int *rint;
4241 
4242  va_start(args, type);
4243  pl = va_arg(args, object *);
4244  rint = va_arg(args, int *);
4245  va_end(args);
4246 
4247  *rint = can_pay(pl);
4248  *type = CFAPI_INT;
4249 }
4250 
4256 static void cfapi_player_knowledge(int *type, ...) {
4257  va_list args;
4258  object *pl;
4259  int *rint, what;
4260  const char *knowledge;
4261 
4262  va_start(args, type);
4263  what = va_arg(args, int);
4264 
4265  switch(what)
4266  {
4267  case 1:
4268  pl = va_arg(args, object *);
4269  knowledge = va_arg(args, const char *);
4270  rint = va_arg(args, int *);
4271 
4272  *type = CFAPI_INT;
4273 
4274  if (pl->contr == NULL) {
4275  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4276  *rint = 0;
4277  va_end(args);
4278  return;
4279  }
4280 
4281  *rint = knowledge_player_knows(pl->contr, knowledge);
4282  break;
4283 
4284  case 2:
4285  pl = va_arg(args, object *);
4286  knowledge = va_arg(args, const char *);
4287  *type = CFAPI_NONE;
4288  if (pl->contr != NULL)
4289  knowledge_give(pl->contr, knowledge, NULL);
4290 
4291  break;
4292 
4293  default:
4294  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4295  }
4296 
4297  va_end(args);
4298 }
4299 
4305 static void cfapi_object_teleport(int *type, ...) {
4306  mapstruct *map;
4307  int x, y;
4308  object *who;
4309  int *res;
4310  va_list args;
4311 
4312  va_start(args, type);
4313  who = va_arg(args, object *);
4314  map = va_arg(args, mapstruct *);
4315  x = va_arg(args, int);
4316  y = va_arg(args, int);
4317  res = va_arg(args, int *);
4318  *type = CFAPI_INT;
4319 
4320  if (!out_of_map(map, x, y)) {
4321  int k;
4322  k = object_find_first_free_spot(who, map, x, y);
4323  if (k == -1) {
4324  *res = 1;
4325  va_end(args);
4326  return;
4327  }
4328 
4329  if (!QUERY_FLAG(who, FLAG_REMOVED)) {
4330  object_remove(who);
4331  }
4332 
4333  object_insert_in_map_at(who, map, NULL, 0, x, y);
4334  if (who->type == PLAYER) {
4335  map_newmap_cmd(&who->contr->socket);
4337  }
4338  *res = 0;
4339  }
4340 
4341  va_end(args);
4342 }
4343 
4344 static void cfapi_object_pickup(int *type, ...) {
4345  object *who;
4346  object *what;
4347  va_list args;
4348 
4349  va_start(args, type);
4350  who = va_arg(args, object *);
4351  what = va_arg(args, object *);
4352  va_end(args);
4353 
4354  pick_up(who, what);
4355  *type = CFAPI_NONE;
4356 }
4357 
4358 /* Archetype-related functions */
4359 static void cfapi_archetype_get_property(int *type, ...) {
4360  int prop;
4361  archetype *arch;
4362  va_list args;
4363  sstring *rsstring;
4364  archetype **rarch;
4365  object **robject;
4366 
4367  va_start(args, type);
4368  arch = va_arg(args, archetype *);
4369  prop = va_arg(args, int);
4370  switch (prop) {
4371  case CFAPI_ARCH_PROP_NAME:
4372  *type = CFAPI_SSTRING;
4373  rsstring = va_arg(args, sstring *);
4374  *rsstring = arch->name;
4375  break;
4376 
4377  case CFAPI_ARCH_PROP_NEXT:
4378  *type = CFAPI_PARCH;
4379  rarch = va_arg(args, archetype **);
4380  *rarch = arch ? arch->next : first_archetype;
4381  break;
4382 
4383  case CFAPI_ARCH_PROP_HEAD:
4384  *type = CFAPI_PARCH;
4385  rarch = va_arg(args, archetype **);
4386  *rarch = arch->head;
4387  break;
4388 
4389  case CFAPI_ARCH_PROP_MORE:
4390  *type = CFAPI_PARCH;
4391  rarch = va_arg(args, archetype **);
4392  *rarch = arch->more;
4393  break;
4394 
4395  case CFAPI_ARCH_PROP_CLONE:
4396  *type = CFAPI_POBJECT;
4397  robject = va_arg(args, object **);
4398  *robject = &arch->clone;
4399  break;
4400 
4401  default:
4402  *type = CFAPI_NONE;
4403  break;
4404  }
4405  va_end(args);
4406 }
4407 
4414 static void cfapi_party_get_property(int *type, ...) {
4415  partylist *party;
4416  int prop;
4417  va_list args;
4418  object *obarg;
4419  sstring *rsstring;
4420  player **rplayer;
4421  partylist **rparty;
4422 
4423  va_start(args, type);
4424  party = va_arg(args, partylist *);
4425  prop = va_arg(args, int);
4426  switch (prop) {
4427  case CFAPI_PARTY_PROP_NAME:
4428  rsstring = va_arg(args, sstring *);
4429  *rsstring = party->partyname;
4430  *type = CFAPI_SSTRING;
4431  break;
4432 
4433  case CFAPI_PARTY_PROP_NEXT:
4434  rparty = va_arg(args, partylist **);
4435  *rparty = (party ? party_get_next(party) : party_get_first());
4436  *type = CFAPI_PPARTY;
4437  break;
4438 
4440  rsstring = va_arg(args, sstring *);
4441  *rsstring = party_get_password(party);
4442  *type = CFAPI_SSTRING;
4443  break;
4444 
4446  *type = CFAPI_PPLAYER;
4447  obarg = va_arg(args, object *);
4448  rplayer = va_arg(args, player **);
4449  *rplayer = (obarg ? obarg->contr : first_player);
4450  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4451  if ((*rplayer)->ob->contr->party == party) {
4452  break;
4453  }
4454  break;
4455 
4456  default:
4457  *type = CFAPI_NONE;
4458  break;
4459  }
4460  va_end(args);
4461 }
4462 
4469 static void cfapi_region_get_property(int *type, ...) {
4470  region *reg;
4471  int prop, *rint;
4472  va_list args;
4474  sstring *rsstring;
4475  region **rregion;
4476 
4477  va_start(args, type);
4478  reg = va_arg(args, region *);
4479  prop = va_arg(args, int);
4480  switch (prop) {
4482  rsstring = va_arg(args, sstring *);
4483  *rsstring = reg->name;
4484  *type = CFAPI_SSTRING;
4485  break;
4486 
4488  rregion = va_arg(args, region **);
4489  *rregion = (reg ? reg->next : first_region);
4490  *type = CFAPI_PREGION;
4491  break;
4492 
4494  rregion = va_arg(args, region **);
4495  *rregion = reg->parent;
4496  *type = CFAPI_PREGION;
4497  break;
4498 
4500  rsstring = va_arg(args, sstring *);
4501  *rsstring = reg->longname;
4502  *type = CFAPI_SSTRING;
4503  break;
4504 
4506  rsstring = va_arg(args, sstring *);
4507  *rsstring = reg->msg;
4508  *type = CFAPI_SSTRING;
4509  break;
4510 
4513  rint = va_arg(args, int*);
4514  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4515  *type = CFAPI_INT;
4516  break;
4517 
4519  rsstring = va_arg(args, sstring *);
4520  *rsstring = reg->jailmap;
4521  *type = CFAPI_SSTRING;
4522  break;
4523 
4524  default:
4525  *type = CFAPI_NONE;
4526  break;
4527  }
4528  va_end(args);
4529 }
4530 
4542 static void cfapi_friendlylist_get_next(int *type, ...) {
4543  object *ob;
4544  va_list args;
4545  objectlink *link;
4546  object **robject;
4547 
4548  va_start(args, type);
4549  ob = va_arg(args, object *);
4550  robject = va_arg(args, object **);
4551  va_end(args);
4552 
4553  *type = CFAPI_POBJECT;
4554  *robject = NULL;
4555 
4556  if (ob) {
4557  for (link = first_friendly_object; link; link = link->next) {
4558  if (ob == link->ob) {
4559  if (link->next) {
4560  *robject = link->next->ob;
4561  return;
4562  } else {
4563  return;
4564  }
4565  }
4566  }
4567  return;
4568  }
4569 
4571  *robject = first_friendly_object->ob;
4572 }
4573 
4574 /*
4575  * Random-map related stuff.
4576  */
4577 
4584 static void cfapi_set_random_map_variable(int *type, ...) {
4585  va_list args;
4586  RMParms *rp;
4587  const char *buf;
4588  int *ret;
4589 
4590  va_start(args, type);
4591  rp = va_arg(args, RMParms *);
4592  buf = va_arg(args, const char *);
4593  ret = va_arg(args, int *);
4594  va_end(args);
4595 
4596  *ret = set_random_map_variable(rp, buf);
4597  *type = CFAPI_INT;
4598 }
4599 
4606 static void cfapi_generate_random_map(int *type, ...) {
4607  va_list args;
4608  const char *name;
4609  RMParms *rp;
4610  char **use_layout;
4611  mapstruct **ret;
4612 
4613  va_start(args, type);
4614  name = va_arg(args, const char *);
4615  rp = va_arg(args, RMParms *);
4616  use_layout = va_arg(args, char **);
4617  ret = va_arg(args, mapstruct **);
4618  va_end(args);
4619 
4620  *ret = generate_random_map(name, rp, use_layout);
4621 }
4622 
4623 static void cfapi_object_user_event(int *type, ...) {
4624  object *op;
4625  object *activator;
4626  object *third;
4627  const char *message;
4628  int fix;
4629  int *ret;
4630  va_list args;
4631 
4632  va_start(args, type);
4633  op = va_arg(args, object *);
4634  activator = va_arg(args, object *);
4635  third = va_arg(args, object *);
4636  message = va_arg(args, const char *);
4637  fix = va_arg(args, int);
4638  ret = va_arg(args, int *);
4639  va_end(args);
4640 
4641  *ret = user_event(op, activator, third, message, fix);
4642  *type = CFAPI_INT;
4643 }
4644 
4647 static void cfapi_player_quest(int *type, ...) {
4648  int op;
4649  va_list args;
4650  object *player;
4651  sstring code;
4652 
4653  va_start(args, type);
4654  op = va_arg(args, int);
4655  player = va_arg(args, object *);
4656  code = va_arg(args, sstring);
4657 
4658  if (player->contr == NULL) {
4659  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4660  va_end(args);
4661  /* crash/quit? */
4662  return;
4663  }
4664 
4665  switch(op) {
4666  case CFAPI_PLAYER_QUEST_START: {
4667  int state = va_arg(args, int);
4668  quest_start(player->contr, code, state);
4669  *type = CFAPI_NONE;
4670  break;
4671  }
4673  int *ret = va_arg(args, int *);
4674  *ret = quest_get_player_state(player->contr, code);
4675  *type = CFAPI_INT;
4676  break;
4677  }
4679  int state = va_arg(args, int);
4680  quest_set_player_state(player->contr, code, state);
4681  *type = CFAPI_NONE;
4682  break;
4683  }
4685  int *ret = va_arg(args, int*);
4686  *ret = quest_was_completed(player->contr, code);
4687  *type = CFAPI_INT;
4688  break;
4689  }
4690  default:
4691  LOG(llevError, "invalid quest type: %d\n", op);
4692  *type = CFAPI_NONE;
4693  }
4694 
4695  va_end(args);
4696 }
4697 
4698 /*****************************************************************************/
4699 /* NEW PLUGIN STUFF ENDS HERE */
4700 /*****************************************************************************/
4701 
4702 
4715  int i;
4716  crossfire_plugin *cp;
4717 
4718  assert(cmd != NULL);
4719  assert(command != NULL);
4720 
4721  if (plugins_list == NULL)
4722  return NULL;
4723 
4724  for (cp = plugins_list; cp != NULL; cp = cp->next) {
4725  if (cp->propfunc(&i, "command?", cmd, command) != NULL)
4726  return command;
4727  }
4728  return NULL;
4729 }
4730 
4735 void initPlugins(void) {
4736  struct dirent *currentfile;
4737  DIR *plugdir;
4738  size_t l;
4739  char buf[MAX_BUF];
4740 
4741  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4742  LOG(llevDebug, "plugins: loading from %s\n", buf);
4743 
4744  plugdir = opendir(buf);
4745  if (plugdir == NULL)
4746  return;
4747 
4748  while ((currentfile = readdir(plugdir)) != NULL) {
4749  l = strlen(currentfile->d_name);
4750  if (l > strlen(PLUGIN_SUFFIX)) {
4752  int ignore = 0;
4753 
4754  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4755  continue;
4756 
4757  while (disable) {
4758  if (strcmp(disable->name, "All") == 0) {
4759  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4760  ignore = 1;
4761  break;
4762  }
4763  if (strncmp(disable->name, currentfile->d_name, strlen(disable->name)) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + strlen(disable->name)) {
4764  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4765  ignore = 1;
4766  break;
4767  }
4768  disable = disable->next;
4769  }
4770  if (ignore == 0) {
4771  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4772  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4773  plugins_init_plugin(buf);
4774  }
4775  }
4776  }
4777 
4778  closedir(plugdir);
4779 }
4780 
4785 void cleanupPlugins(void) {
4786  crossfire_plugin *cp;
4787 
4788  if (!plugins_list)
4789  return;
4790 
4791  for (cp = plugins_list; cp != NULL; ) {
4792  crossfire_plugin *next = cp->next;
4793  if (cp->closefunc)
4794  cp->closefunc();
4795  /* Don't actually unload plugins, it makes backtraces for memory
4796  * debugging (printed at exit) messed up. And it doesn't matter if we
4797  * don't free it here. The OS will do it for us.
4798  */
4799  /* plugins_dlclose(cp->libptr); */
4800  free(cp);
4801  cp = next;
4802  }
4803  plugins_list = NULL;
4804 }
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:248
#define CFAPI_OBJECT_PROP_MAP
Definition: plugin.h:179
#define CFAPI_OBJECT_PROP_RUN_AWAY
Definition: plugin.h:225
static void cfapi_object_clear(int *type,...)
Definition: plugins.c:3700
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:315
int object_distance(const object *ob1, const object *ob2)
Definition: object.c:3601
void spring_trap(object *trap, object *victim)
Definition: rune.c:205
static void cfapi_map_trigger_connected(int *type,...)
Definition: plugins.c:3805
static void copy_message(object *op, const char *msg)
Definition: plugins.c:2524
static void cfapi_set_random_map_variable(int *type,...)
Definition: plugins.c:4584
char path[HUGE_BUF]
Definition: map.h:365
#define CFAPI_OBJECT_PROP_MAGIC
Definition: plugin.h:206
void apply_by_living_below(object *pl)
Definition: apply.c:614
#define CFAPI_PLAYER_QUEST_GET_STATE
Definition: plugin.h:291
#define MSG_TYPE_MISC
Definition: newclient.h:389
#define FLAG_NO_DROP
Definition: define.h:289
int8_t Int
Definition: living.h:36
#define CFAPI_PARTY_PROP_PASSWORD
Definition: plugin.h:322
Definition: player.h:92
int apply_manual(object *op, object *tmp, int aflag)
Definition: apply.c:510
#define CFAPI_OBJECT_PROP_MATERIAL
Definition: plugin.h:204
const char * determine_god(object *op)
Definition: gods.c:106
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:269
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout)
Definition: random_map.c:74
int8_t ac
Definition: living.h:38
#define CFAPI_OBJECT_PROP_SP
Definition: plugin.h:258
int32_t weight_limit
Definition: object.h:366
#define UP_OBJ_FACE
Definition: object.h:517
#define CFAPI_OBJECT_PROP_CARRYING
Definition: plugin.h:219
MoveType move_type
Definition: object.h:424
#define plugins_dlopen(fname)
Definition: plugin.h:163
#define EVENT_REMOVE
Definition: plugin.h:93
#define CFAPI_OBJECT_PROP_NAME
Definition: plugin.h:181
#define CFAPI_OBJECT_PROP_OB_BELOW
Definition: plugin.h:172
#define CFAPI_PREGION
Definition: plugin.h:117
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:288
#define EVENT_SHOUT
Definition: plugin.h:94
#define CFAPI_MAP_PROP_NAME
Definition: plugin.h:299
int16_t jaily
Definition: map.h:298
void object_free(object *ob, int flags)
Definition: object.c:1409
int move_player(object *op, int dir)
Definition: player.c:3009
MoveType move_on
Definition: object.h:427
static void cfapi_object_drain(int *type,...)
Definition: plugins.c:3289
static void cfapi_system_register_global_event(int *type,...)
Definition: plugins.c:851
void quest_start(player *pl, sstring quest_code, int state)
Definition: quest.c:1096
static void cfapi_system_find_animation(int *type,...)
Definition: plugins.c:797
static void cfapi_object_move(int *type,...)
Definition: plugins.c:1627
#define CFAPI_OBJECT_PROP_RACE
Definition: plugin.h:184
object * check_spell_known(object *op, const char *name)
Definition: spell_util.c:433
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:308
static void cfapi_object_check_spell(int *type,...)
Definition: plugins.c:3907
Definition: object.h:442
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:329
const char * race
Definition: object.h:318
#define P_NEED_UPDATE
Definition: map.h:239
int is_magical(const object *op)
Definition: item.c:1237
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:295
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:304
#define CFAPI_OBJECT_PROP_ARCHETYPE
Definition: plugin.h:232
#define CFAPI_OBJECT_PROP_WEIGHT
Definition: plugin.h:217
static void cfapi_get_month_name(int *type,...)
Definition: plugins.c:1099
uint16_t attack_movement
Definition: object.h:391
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:200
static void cfapi_object_pickup(int *type,...)
Definition: plugins.c:4344
#define CFAPI_OBJECT_PROP_FACE
Definition: plugin.h:268
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.c:863
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.c:4359
static void cfapi_object_pay_amount(int *type,...)
Definition: plugins.c:3927
#define SET_FLAG(xyz, p)
Definition: define.h:223
#define NR_OF_HOOKS
Definition: plugins.c:43
#define EVENT_KICK
Definition: plugin.h:97
void do_forget_spell(object *op, const char *spell)
Definition: apply.c:432
MoveType move_allow
Definition: object.h:426
int16_t bed_x
Definition: player.h:98
linked_char * disabled_plugins
Definition: global.h:323
static void cfapi_object_get_property(int *type,...)
Definition: plugins.c:1722
#define plugins_dlsym(lib, name)
Definition: plugin.h:165
#define CFAPI_FUNC
Definition: plugin.h:114
#define PLUGIN_SUFFIX
Definition: win32.h:106
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.c:3759
New_Face * new_faces
Definition: image.c:33
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:265
#define CFAPI_OBJECT_PROP_PICK_UP
Definition: plugin.h:214
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:296
void player_get_title(const struct pl *pl, char *buf, size_t bufsize)
Definition: player.c:224
uint16_t animation_id
Definition: object.h:416
#define CFAPI_MAP_PROP_HEIGHT
Definition: plugin.h:306
uint16_t material
Definition: object.h:347
#define CFAPI_OBJECT_PROP_DIRECTION
Definition: plugin.h:194
const char * name
Definition: face.h:27
#define strdup_local
Definition: compat.h:25
uint8_t anim_speed
Definition: object.h:417
object * object_get_env_recursive(object *op)
Definition: object.c:364
EXTERN objectlink * first_friendly_object
Definition: global.h:123
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
Definition: plugin.h:173
struct obj * container
Definition: object.h:291
#define CFAPI_OBJECT_PROP_MAXGP
Definition: plugin.h:263
#define EVENT_LOGIN
Definition: plugin.h:88
int player_arrest(object *who)
Definition: c_wiz.c:797
#define CFAPI_OBJECT_PROP_HIDDEN
Definition: plugin.h:227
static void cfapi_region_get_property(int *type,...)
Definition: plugins.c:4469
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.c:3743
static void cfapi_system_find_face(int *type,...)
Definition: plugins.c:816
int16_t players
Definition: map.h:344
void fatal(enum fatal_error err)
Definition: utils.c:597
struct obj * who
Definition: dialog.h:52
static void cfapi_object_give_skill(int *type,...)
Definition: plugins.c:3342
#define CFAPI_OBJECT_PROP_MOVE_STATUS
Definition: plugin.h:228
const char * get_season_name(const int index)
Definition: time.c:123
int pay_for_item(object *op, object *pl)
Definition: shop.c:556
char * create_pathname(const char *name, char *buf, size_t size)
Definition: map.c:112
void knowledge_give(player *pl, const char *marker, const object *book)
Definition: knowledge.c:1012
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.c:1815
const char * playerdir
Definition: global.h:244
unsigned char MoveType
Definition: define.h:432
int32_t last_heal
Definition: object.h:357
#define CFAPI_OBJECT_PROP_SUBTYPE
Definition: plugin.h:197
partylist * party_get_next(const partylist *party)
Definition: party.c:230
int16_t maxgrace
Definition: living.h:45
void free_string(sstring str)
Definition: shstr.c:280
#define UP_OBJ_INSERT
Definition: object.h:514
signed long object_sum_weight(object *op)
Definition: object.c:342
#define TIMER_ERR_ID
Definition: timers.h:67
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:330
static void cfapi_get_periodofday_name(int *type,...)
Definition: plugins.c:1111
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:317
#define SET_ANIMATION(ob, newanim)
Definition: global.h:169
static void cfapi_object_find_by_arch_name(int *type,...)
Definition: plugins.c:4069
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
Definition: map.c:2380
#define NR_EVENTS
Definition: plugin.h:100
#define EVENT_MAPLEAVE
Definition: plugin.h:91
void esrv_update_item(int flags, object *pl, object *op)
Definition: main.c:342
#define CFAPI_OBJECT_PROP_CONTAINER
Definition: plugin.h:178
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4266
#define CFAPI_INT16
Definition: plugin.h:118
void pick_up(object *op, object *alt)
Definition: c_object.c:456
f_plug_api func
Definition: plugin.h:351
#define CFAPI_OBJECT_PROP_INVENTORY
Definition: plugin.h:175
void query_base_name(const object *op, int plural, char *buf, size_t size)
Definition: item.c:720
struct pl player
static void cfapi_object_set_property(int *type,...)
Definition: plugins.c:2557
object clone
Definition: object.h:470
int16_t duration
Definition: object.h:403
#define CFAPI_OBJECT_PROP_FLAGS
Definition: plugin.h:247
static void cfapi_get_season_name(int *type,...)
Definition: plugins.c:1075
socket_struct socket
Definition: player.h:94
int16_t invisible
Definition: object.h:360
short freearr_x[SIZEOFFREE]
Definition: object.c:65
#define EVENT_LOGOUT
Definition: plugin.h:89
uint32_t reset_time
Definition: map.h:332
int calculate_difficulty(mapstruct *m)
Definition: map.c:1925
#define CFAPI_SINT64
Definition: plugin.h:120
#define CFAPI_OBJECT_PROP_NAME_PLURAL
Definition: plugin.h:182
static void cfapi_log(int *type,...)
Definition: plugins.c:1178
const char * get_weekday(const int index)
Definition: time.c:116
const char * slaying
Definition: object.h:319
region * get_region_by_map(mapstruct *m)
Definition: region.c:74
static void cfapi_object_find_archetype_inside(int *type,...)
Definition: plugins.c:4036
DIR * opendir(const char *)
Definition: win32.c:37
int32_t last_sp
Definition: object.h:358
#define CFAPI_OBJECT_PROP_OWNER
Definition: plugin.h:242
static void cfapi_object_teleport(int *type,...)
Definition: plugins.c:4305
static void cfapi_system_re_cmp(int *type,...)
Definition: plugins.c:973
static int do_execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix, talk_info *talk)
Definition: plugins.c:312
const char * party_get_password(const partylist *party)
Definition: party.c:254
uint8_t subtype
Definition: object.h:339
crossfire_plugin * plugins_list
Definition: plugins.c:235
uint32_t mark_count
Definition: player.h:193
#define CFAPI_OBJECT_PROP_MOVE_ON
Definition: plugin.h:274
static void cfapi_map_get_map_property(int *type,...)
Definition: plugins.c:1305
uint8_t hide
Definition: object.h:387
int64_t exp
Definition: living.h:47
#define CFAPI_OBJECT_PROP_MESSAGE
Definition: plugin.h:187
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:531
static void cfapi_map_delete_map(int *type,...)
Definition: plugins.c:1505
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER
Definition: plugin.h:231
struct obj * above
Definition: object.h:288
double expmul
Definition: object.h:395
#define plugins_dlclose(lib)
Definition: plugin.h:164
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:301
#define object_was_destroyed(op, old_tag)
Definition: object.h:68
char id[MAX_BUF]
Definition: plugin.h:148
void initPlugins(void)
Definition: plugins.c:4735
object * arch_present_in_ob(const archetype *at, const object *op)
Definition: object.c:3078
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:290
#define CFAPI_DOUBLE
Definition: plugin.h:112
static void cfapi_object_insert(int *type,...)
Definition: plugins.c:3495
void remove_friendly_object(object *op)
Definition: friend.c:56
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:326
uint32_t path_attuned
Definition: object.h:343
void object_update(object *op, int action)
Definition: object.c:1260
static void cfapi_object_drop(int *type,...)
Definition: plugins.c:4106
static void cfapi_object_fix(int *type,...)
Definition: plugins.c:3326
int16_t sp
Definition: living.h:42
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.c:1437
#define EVENT_TELL
Definition: plugin.h:95
static void cfapi_object_set_key(int *type,...)
Definition: plugins.c:1699
#define EVENT_CRASH
Definition: plugin.h:85
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:310
static void cfapi_party_get_property(int *type,...)
Definition: plugins.c:4414
int object_can_merge(object *ob1, object *ob2)
Definition: object.c:202
#define CFAPI_OBJECT_PROP_SLAYING
Definition: plugin.h:185
static void cfapi_map_create_path(int *type,...)
Definition: plugins.c:1271
int plugin_event_say(object *npc, talk_info *talk)
Definition: plugins.c:379
Definition: win32.h:110
uint32_t path_repelled
Definition: object.h:344
#define safe_strncpy
Definition: compat.h:23
#define SCRIPT_FIX_ALL
Definition: global.h:361
void free_dialog_information(object *op)
Definition: dialog.c:32
char * partyname
Definition: party.h:14
struct obj * enemy
Definition: object.h:381
struct archt * other_arch
Definition: object.h:413
static void cfapi_system_find_string(int *type,...)
Definition: plugins.c:931
object * object_find_by_name(const object *who, const char *name)
Definition: object.c:3899
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.c:310
Definition: object.h:465
#define CFAPI_PMAP
Definition: plugin.h:110
static void cfapi_object_apply_below(int *type,...)
Definition: plugins.c:3202
void transmute_materialname(object *op, const object *change)
Definition: utils.c:267
char savebed_map[MAX_BUF]
Definition: player.h:97
static void cfapi_timer_create(int *type,...)
Definition: plugins.c:1126
Definition: plugin.h:350
char * host
Definition: newserver.h:100
static void cfapi_player_quest(int *type,...)
Definition: plugins.c:4647
#define CFAPI_POBJECT
Definition: plugin.h:109
static void cfapi_object_split(int *type,...)
Definition: plugins.c:3603
#define CFAPI_OBJECT_PROP_CHOSEN_SKILL
Definition: plugin.h:226
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:233
int16_t maxsp
Definition: living.h:43
#define CFAPI_OBJECT_PROP_LAST_SP
Definition: plugin.h:210
int8_t Con
Definition: living.h:36
int change_map_light(mapstruct *m, int change)
Definition: map.c:2007
#define CFAPI_REGION_PROP_JAIL_PATH
Definition: plugin.h:332
#define FLAG_REMOVED
Definition: define.h:232
static void cfapi_object_delete(int *type,...)
Definition: plugins.c:3397
int16_t hp
Definition: living.h:40
#define CFAPI_OBJECT_PROP_LAST_GRACE
Definition: plugin.h:211
static void cfapi_object_find_by_name(int *type,...)
Definition: plugins.c:4085
#define CFAPI_OBJECT_PROP_COUNT
Definition: plugin.h:180
short freearr_y[SIZEOFFREE]
Definition: object.c:71
partylist * party
Definition: player.h:186
static void cfapi_object_remove(int *type,...)
Definition: plugins.c:3376
#define CFAPI_NONE
Definition: plugin.h:104
#define UPD_ALL
Definition: newclient.h:297
void command_say(object *op, const char *params)
Definition: c_chat.c:34
object * ob
Definition: object.h:443
#define MOVE_ALL
Definition: define.h:413
uint16_t height
Definition: map.h:347
object * give_skill_by_name(object *op, const char *skill_name)
Definition: living.c:1752
static void cfapi_object_transmute(int *type,...)
Definition: plugins.c:3359
const char * get_month_name(const int index)
Definition: time.c:109
#define CFAPI_FLOAT
Definition: plugin.h:111
void map_newmap_cmd(socket_struct *ns)
Definition: request.c:618
struct _crossfire_plugin * next
Definition: plugin.h:151
void object_set_owner(object *op, object *owner)
Definition: object.c:632
#define CFAPI_PLAYER_PROP_BED_X
Definition: plugin.h:285
char * name
Definition: map.h:328
#define CFAPI_PARCH
Definition: plugin.h:113
const char * lore
Definition: object.h:323
static void cfapi_object_identify(int *type,...)
Definition: plugins.c:3247
struct obj * chosen_skill
Definition: object.h:386
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:4395
uint32_t update_look
Definition: newserver.h:104
void object_free_drop_inventory(object *ob)
Definition: object.c:1389
int change_abil(object *op, object *tmp)
Definition: living.c:394
const char * name
Definition: face.h:20
const char * title
Definition: object.h:317
int16_t y
Definition: object.h:326
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.c:1933
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:302
int move_to(object *op, int x, int y)
Definition: move.c:545
int is_friendly(const object *op)
Definition: friend.c:144
int16_t maxhp
Definition: living.h:41
sstring find_string(const char *str)
Definition: shstr.c:236
char * name
Definition: map.h:278
#define CFAPI_OBJECT_PROP_FACING
Definition: plugin.h:195
int user_event(object *op, object *activator, object *third, const char *message, int fix)
Definition: plugins.c:308
#define MSG_TYPE_COMMAND
Definition: newclient.h:379
static void cfapi_object_say(int *type,...)
Definition: plugins.c:4145
#define EVENT_MAPENTER
Definition: plugin.h:90
static void cfapi_system_remove_string(int *type,...)
Definition: plugins.c:913
uint32_t path_denied
Definition: object.h:345
static void cfapi_object_change_exp(int *type,...)
Definition: plugins.c:4214
#define CFAPI_PLAYER_PROP_IP
Definition: plugin.h:281
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:176
Definition: win32.h:120
static void cfapi_object_merge(int *type,...)
Definition: plugins.c:3636
#define CFAPI_OBJECT_PROP_GP
Definition: plugin.h:259
LIBPTRTYPE libptr
Definition: plugin.h:147
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:254
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:323
object * object_new(void)
Definition: object.c:1068
const char * name_pl
Definition: object.h:315
static void cfapi_player_knowledge(int *type,...)
Definition: plugins.c:4256
#define LIBDIR
Definition: win32.h:99
#define CFAPI_OBJECT_PROP_ATTACKED_BY
Definition: plugin.h:224
#define CFAPI_STRING
Definition: plugin.h:108
void player_set_own_title(struct pl *pl, const char *title)
Definition: player.c:264
int object_can_pick(const object *who, const object *item)
Definition: object.c:3810
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2707
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
Definition: plugin.h:277
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:312
float speed_left
Definition: object.h:329
int knowledge_player_knows(const player *pl, const char *knowledge)
Definition: knowledge.c:1309
void *(* f_plug_property)(int *type,...)
Definition: plugin.h:133
#define CFAPI_OBJECT_PROP_INT
Definition: plugin.h:252
signed short int16_t
Definition: win32.h:160
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:300
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:316
void monster_npc_say(object *npc, const char *cp)
Definition: monster.c:2298
static void cfapi_timer_destroy(int *type,...)
Definition: plugins.c:1159
const char * materialname
Definition: object.h:346
int16_t enter_x
Definition: map.h:348
int32_t weight
Definition: object.h:365
uint32_t unique
Definition: map.h:337
#define CFAPI_OBJECT_PROP_LEVEL
Definition: plugin.h:208
#define FOR_ABOVE_FINISH()
Definition: define.h:731
void update_all_los(const mapstruct *map, int x, int y)
Definition: los.c:536
const char * tmpdir
Definition: global.h:251
int8_t Wis
Definition: living.h:36
const char * text
Definition: dialog.h:53
#define CFAPI_OBJECT_PROP_HEAD
Definition: plugin.h:177
#define CFAPI_PLAYER_PROP_BED_MAP
Definition: plugin.h:284
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:273
static void cfapi_player_message(int *type,...)
Definition: plugins.c:4189
struct mapdef * map
Definition: object.h:297
struct regiondef * next
Definition: map.h:277
Definition: map.h:276
#define CFAPI_OBJECT_PROP_RAW_NAME
Definition: plugin.h:279
#define snprintf
Definition: win32.h:46
struct obj * active_prev
Definition: object.h:283
void drain_specific_stat(object *op, int deplete_stats)
Definition: living.c:724
static void cfapi_object_user_event(int *type,...)
Definition: plugins.c:4623
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:315
f_plug_postinit closefunc
Definition: plugin.h:146
struct linked_char * next
Definition: global.h:88
int plugins_init_plugin(const char *libfile)
Definition: plugins.c:611
uint64_t query_money(const object *op)
Definition: shop.c:486
int(* f_plug_postinit)(void)
Definition: plugin.h:127
#define FOR_INV_FINISH()
Definition: define.h:714
char * msg
Definition: map.h:361
void update_position(mapstruct *m, int x, int y)
Definition: map.c:2131
int16_t dam
Definition: living.h:46
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Definition: plugins.c:375
void add_friendly_object(object *op)
Definition: friend.c:30
#define CFAPI_OBJECT_PROP_FP
Definition: plugin.h:260
int32_t carrying
Definition: object.h:367
const char * name
Definition: object.h:311
int16_t bed_y
Definition: player.h:98
struct obj * env
Definition: object.h:293
#define FOR_ABOVE_PREPARE(op_, it_)
Definition: define.h:724
#define CFAPI_OBJECT_PROP_MAGICAL
Definition: plugin.h:239
int64_t perm_exp
Definition: object.h:369
int8_t gen_sp_armour
Definition: object.h:363
static void cfapi_map_find_by_archetype_name(int *type,...)
Definition: plugins.c:1569
#define LIBPTRTYPE
Definition: plugin.h:136
uint8_t state
Definition: object.h:349
struct obj * below
Definition: object.h:287
struct archt * more
Definition: object.h:469
static void cfapi_object_pay_item(int *type,...)
Definition: plugins.c:3948
archetype * find_archetype_by_object_name(const char *name)
Definition: arch.c:57
#define CFAPI_OBJECT_PROP_LAST_EAT
Definition: plugin.h:212
object * object_present_in_ob(uint8_t type, const object *op)
Definition: object.c:3018
void trigger_connected(objectlink *ol, object *cause, const int state)
Definition: button.c:41
int16_t last_grace
Definition: object.h:359
const char * re_cmp(const char *, const char *)
Definition: re-cmp.c:69
void object_reset(object *op)
Definition: object.c:735
int pay_for_amount(uint64_t to_pay, object *pl)
Definition: shop.c:517
#define CFAPI_OBJECT_PROP_MOVE_OFF
Definition: plugin.h:275
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:218
#define CFAPI_PLAYER_QUEST_SET_STATE
Definition: plugin.h:292
struct obj * current_weapon
Definition: object.h:370
int8_t direction
Definition: object.h:334
#define CFAPI_LONG
Definition: plugin.h:106
object * object_create_clone(object *asrc)
Definition: object.c:3852
uint32_t nrof
Definition: object.h:333
#define string_get_int(name)
Definition: plugins.c:1056
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON
Definition: plugin.h:222
#define CFAPI_SSTRING
Definition: plugin.h:121
int8_t Cha
Definition: living.h:36
struct archt * head
Definition: object.h:468
int find_animation(const char *name)
Definition: anim.c:171
static void cfapi_player_can_pay(int *type,...)
Definition: plugins.c:4237
static void cfapi_system_check_path(int *type,...)
Definition: plugins.c:950
#define CFAPI_PPLAYER
Definition: plugin.h:115
#define SIZEOFFREE
Definition: define.h:154
#define P_OUT_OF_MAP
Definition: map.h:251
MoveType move_off
Definition: object.h:428
int move_ob(object *op, int dir, object *originator)
Definition: move.c:58
int cftimer_destroy(int id)
Definition: timers.c:128
#define CFAPI_OBJECT_PROP_X
Definition: plugin.h:189
EXTERN Animations * animations
Definition: global.h:163
void do_learn_spell(object *op, object *spell, int special_prayer)
Definition: apply.c:391
static void cfapi_map_out_of_map(int *type,...)
Definition: plugins.c:1467
struct pl * contr
Definition: object.h:276
#define CFAPI_OBJECT_PROP_CHEATER
Definition: plugin.h:244
static void cfapi_object_get_key(int *type,...)
Definition: plugins.c:1677
#define CFAPI_OBJECT_PROP_PICKABLE
Definition: plugin.h:246
int8_t item_power
Definition: object.h:362
static void cfapi_system_directory(int *type,...)
Definition: plugins.c:991
void cleanupPlugins(void)
Definition: plugins.c:4785
uint8_t ignore_plugin_compatibility
Definition: global.h:324
uint8_t darkness
Definition: map.h:346
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:309
int try_find_animation(const char *name)
Definition: anim.c:186
void object_clear(object *op)
Definition: object.c:790
command_array_struct * find_plugin_command(const char *cmd, command_array_struct *command)
Definition: plugins.c:4714
static crossfire_plugin * plugins_find_plugin(const char *id)
Definition: plugins.c:246
#define CFAPI_OBJECT_PROP_ENEMY
Definition: plugin.h:223
#define CFAPI_REGION_PROP_JAIL_Y
Definition: plugin.h:331
object * find_marked_object(object *op)
Definition: c_object.c:1266
#define CFAPI_OBJECT_PROP_PATH_REPELLED
Definition: plugin.h:202
void plugins_display_list(object *op)
Definition: plugins.c:744
static void cfapi_object_learn_spell(int *type,...)
Definition: plugins.c:3872
archetype * try_find_archetype(const char *name)
Definition: arch.c:666
#define UPD_WEIGHT
Definition: newclient.h:291
uint32_t tag_t
Definition: object.h:12
#define EVENT_SAY
Definition: plugin.h:70
char d_name[_MAX_FNAME+1]
Definition: win32.h:114
static void cfapi_object_create(int *type,...)
Definition: plugins.c:3456
int8_t luck
Definition: living.h:39
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h:298
float speed
Definition: object.h:328
unsigned __int64 uint64_t
Definition: win32.h:167
char fullname[MAX_BUF]
Definition: plugin.h:149
struct regiondef * parent
Definition: map.h:286
int on_same_map(const object *op1, const object *op2)
Definition: map.c:2650
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
f_plug_property propfunc
Definition: plugin.h:145
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
#define CFAPI_OBJECT_PROP_LORE
Definition: plugin.h:188
static void cfapi_player_find(int *type,...)
Definition: plugins.c:4174
#define EVENT_MAPLOAD
Definition: plugin.h:99
partylist * party_get_first(void)
Definition: party.c:218
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Definition: living.c:2126
#define CFAPI_OBJECT_PROP_ITEM_POWER
Definition: plugin.h:215
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:328
#define MSG_TYPE_COMMAND_DEBUG
Definition: newclient.h:508
static void cfapi_object_apply(int *type,...)
Definition: plugins.c:3222
static void cfapi_system_unregister_global_event(int *type,...)
Definition: plugins.c:870
#define MAX_BUF
Definition: define.h:35
int quest_get_player_state(player *pl, sstring quest_code)
Definition: quest.c:1076
#define CFAPI_PARTY_PROP_NAME
Definition: plugin.h:320
struct obj * active_next
Definition: object.h:279
#define CFAPI_PLAYER_PROP_PARTY
Definition: plugin.h:283
LogLevel
Definition: logger.h:10
object * object_create_arch(archetype *at)
Definition: arch.c:736
int16_t jailx
Definition: map.h:298
int16_t enter_y
Definition: map.h:348
int16_t x
Definition: object.h:326
#define EVENT_MAPUNLOAD
Definition: plugin.h:98
void drop(object *op, object *tmp)
Definition: c_object.c:920
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:241
const char * skill
Definition: object.h:321
int32_t last_eat
Definition: object.h:356
static void cfapi_object_describe(int *type,...)
Definition: plugins.c:3267
#define plugins_dlerror()
Definition: plugin.h:166
#define EVENT_MAPRESET
Definition: plugin.h:92
int8_t wc
Definition: living.h:37
const char * confdir
Definition: global.h:241
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
Definition: object.c:3475
int(* f_plug_event)(int *type,...)
Definition: plugin.h:131
signed __int64 int64_t
Definition: win32.h:168
static const flag_definition flags[]
#define EVENT_GKILL
Definition: plugin.h:87
static void cfapi_system_strdup_local(int *type,...)
Definition: plugins.c:837
#define CFAPI_OBJECT_PROP_PERM_EXP
Definition: plugin.h:221
const char * uniquedir
Definition: global.h:249
int8_t Str
Definition: living.h:36
char * tmpname
Definition: map.h:327
int16_t resist[NROFATTACKS]
Definition: object.h:341
object * ob
Definition: player.h:158
const char * sstring
Definition: global.h:40
#define EVENT_CLOCK
Definition: plugin.h:84
#define CFAPI_OBJECT_PROP_DAM
Definition: plugin.h:264
unsigned int uint32_t
Definition: win32.h:162
#define CFAPI_OBJECT_PROP_MOVE_TYPE
Definition: plugin.h:271
Definition: object.h:107
const char * datadir
Definition: global.h:242
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:186
#define CFAPI_PLAYER_PROP_NEXT
Definition: plugin.h:287
#define CFAPI_OBJECT_PROP_AC
Definition: plugin.h:256
static void cfapi_object_check_trigger(int *type,...)
Definition: plugins.c:3778
#define SET_MAP_FLAGS(M, X, Y, C)
Definition: map.h:163
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:238
#define TIMER_ERR_NONE
Definition: timers.h:66
const char * name
Definition: global.h:87
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:327
#define CFAPI_INT
Definition: plugin.h:105
uint32_t attacktype
Definition: object.h:342
struct obj * spellitem
Definition: object.h:394
static void cfapi_friendlylist_get_next(int *type,...)
Definition: plugins.c:4542
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
Definition: object.c:2478
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:314
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.c:975
void quest_set_player_state(player *pl, sstring quest_code, int state)
Definition: quest.c:1132
object * object_decrease_nrof(object *op, uint32_t i)
Definition: object.c:2520
int set_random_map_variable(RMParms *rp, const char *buf)
#define CFAPI_OBJECT_PROP_SPEED_LEFT
Definition: plugin.h:192
#define FREE_AND_COPY(sv, nv)
Definition: global.h:211
int16_t grace
Definition: living.h:44
#define UPD_NROF
Definition: newclient.h:296
void get_tod(timeofday_t *tod)
Definition: time.c:215
static void cfapi_object_query_money(int *type,...)
Definition: plugins.c:3825
const char * custom_name
Definition: object.h:432
int cftimer_create(int id, long delay, object *ob, int mode)
Definition: timers.c:97
const char * localdir
Definition: global.h:243
tag_t count
Definition: object.h:299
living stats
Definition: object.h:368
static void cfapi_map_has_been_loaded(int *type,...)
Definition: plugins.c:1253
uint16_t client_type
Definition: object.h:340
mapstruct * has_been_loaded(const char *name)
Definition: map.c:87
int8_t Dex
Definition: living.h:36
char * jailmap
Definition: map.h:297
struct archt * arch
Definition: object.h:412
#define CFAPI_OBJECT_PROP_HP
Definition: plugin.h:257
struct oblnk * next
Definition: object.h:444
static void cfapi_object_cast(int *type,...)
Definition: plugins.c:3844
#define CFAPI_OBJECT_PROP_TITLE
Definition: plugin.h:183
int cftimer_find_free_id(void)
Definition: timers.c:144
const char * mapdir
Definition: global.h:245
uint32_t reset_timeout
Definition: map.h:333
#define CFAPI_PLAYER_PROP_BED_Y
Definition: plugin.h:286
uint16_t width
Definition: map.h:347
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:191
Definition: tod.h:34
uint8_t type
Definition: object.h:338
struct Settings settings
Definition: init.c:40
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:297
static void cfapi_get_hooks(int *type,...)
Definition: plugins.c:565
void object_set_enemy(object *op, object *enemy)
Definition: object.c:710
int remove_depletion(object *op, int level)
Definition: living.c:751
#define CFAPI_OBJECT_PROP_FRIENDLY
Definition: plugin.h:236
#define CFAPI_OBJECT_PROP_ANIM_SPEED
Definition: plugin.h:235
struct archt * next
Definition: object.h:467
#define CFAPI_OBJECT_PROP_LUCK
Definition: plugin.h:240
void party_join(object *op, partylist *party)
Definition: party.c:85
struct dirent * readdir(DIR *)
Definition: win32.c:75
const char * get_periodofday(const int index)
Definition: time.c:102
object * object_merge(object *op, object *top)
Definition: object.c:1881
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:266
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.c:548
object * object_get_player_container(object *op)
Definition: object.c:384
static void cfapi_system_add_string(int *type,...)
Definition: plugins.c:893
int out_of_map(mapstruct *m, int x, int y)
Definition: map.c:2306
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME
Definition: plugin.h:213
static void cfapi_get_time(int *type,...)
Definition: plugins.c:1044
static void cfapi_map_get_object_at(int *type,...)
Definition: plugins.c:1540
#define CFAPI_OBJECT_PROP_DEX
Definition: plugin.h:249
#define CFAPI_MOVETYPE
Definition: plugin.h:122
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
Definition: plugin.h:229
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:311
static void cfapi_object_change_abil(int *type,...)
Definition: plugins.c:4130
void delete_map(mapstruct *m)
Definition: map.c:1753
const char * msg
Definition: object.h:322
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:305
#define CFAPI_OBJECT_PROP_CON
Definition: plugin.h:250
sstring add_string(const char *str)
Definition: shstr.c:124
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED
Definition: plugin.h:293
EXTERN player * first_player
Definition: global.h:117
char * cost_string_from_value(uint64_t cost, int largest_coin)
Definition: shop.c:338
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:321
object * identify(object *op)
Definition: item.c:1432
struct pl * next
Definition: player.h:93
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.c:3732
#define GET_MAP_OB(M, X, Y)
Definition: map.h:172
int check_path(const char *name, int prepend_dir)
Definition: map.c:211
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:193
int8_t glow_radius
Definition: object.h:364
#define CFAPI_OBJECT_PROP_MAXSP
Definition: plugin.h:262
f_plug_event eventfunc
Definition: plugin.h:144
void object_copy(const object *src_ob, object *dest_ob)
Definition: object.c:869
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:318
struct _crossfire_plugin * prev
Definition: plugin.h:152
static void cfapi_object_transfer(int *type,...)
Definition: plugins.c:3972
#define EVENT_PLAYER_DEATH
Definition: plugin.h:86
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.c:3307
int8_t Pow
Definition: living.h:36
int closedir(DIR *)
Definition: win32.c:108
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Definition: map.c:310
struct obj * inv
Definition: object.h:290
void object_set_cheat(object *op)
Definition: object.c:3139
#define NDI_UNIQUE
Definition: newclient.h:245
#define CFAPI_PLAYER_PROP_MARKED_ITEM
Definition: plugin.h:282
static void cfapi_map_get_map(int *type,...)
Definition: plugins.c:1202
struct obj * head
Definition: object.h:296
#define MSG_SUBTYPE_NONE
Definition: newclient.h:398
static void cfapi_object_distance(int *type,...)
Definition: plugins.c:3659
#define CFAPI_OBJECT_PROP_LAST_HEAL
Definition: plugin.h:209
#define CFAPI_OBJECT_PROP_CLIENT_TYPE
Definition: plugin.h:198
#define CFAPI_OBJECT_PROP_INVISIBLE
Definition: plugin.h:267
void player_update_bg_music(object *player)
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:196
static const hook_entry plug_hooks[]
Definition: plugins.c:140
char * msg
Definition: map.h:293
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.c:3887
#define CFAPI_OBJECT_PROP_POW
Definition: plugin.h:253
static void cfapi_get_weekday_name(int *type,...)
Definition: plugins.c:1087
static void cfapi_map_message(int *type,...)
Definition: plugins.c:1518
static void cfapi_object_update(int *type,...)
Definition: plugins.c:3680
object * mark
Definition: player.h:194
#define FLAG_WAS_WIZ
Definition: define.h:234
EXTERN region * first_region
Definition: global.h:119
uint8_t pick_up
Definition: object.h:361
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
Definition: plugin.h:216
int transfer_ob(object *op, int x, int y, int randomly, object *originator)
Definition: move.c:144
MoveType move_block
Definition: object.h:425
uint8_t run_away
Definition: object.h:384
#define CFAPI_OBJECT_PROP_GLOW_RADIUS
Definition: plugin.h:220
struct mapdef * next
Definition: map.h:326
static void cfapi_object_clone(int *type,...)
Definition: plugins.c:3424
static void cfapi_object_reset(int *type,...)
Definition: plugins.c:3718
void object_set_msg(object *op, const char *msg)
Definition: object.c:4715
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
Definition: object.c:3432
int check_trigger(object *op, object *cause)
Definition: button.c:523
#define CFAPI_OBJECT_PROP_PRESENT
Definition: plugin.h:243
float move_slow_penalty
Definition: object.h:430
#define CFAPI_OBJECT_PROP_MERGEABLE
Definition: plugin.h:245
#define CFAPI_OBJECT_PROP_WC
Definition: plugin.h:255
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:623
#define CFAPI_OBJECT_PROP_RESIST
Definition: plugin.h:199
#define CFAPI_OBJECT_PROP_SHORT_NAME
Definition: plugin.h:237
#define CFAPI_OBJECT_PROP_MOVE_SLOW
Definition: plugin.h:276
#define CFAPI_OBJECT_PROP_MATERIAL_NAME
Definition: plugin.h:205
void create_overlay_pathname(const char *name, char *buf, size_t size)
Definition: map.c:133
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Definition: object.c:2961
Definition: map.h:325
const New_Face * face
Definition: object.h:332
#define CFAPI_OBJECT_PROP_MAXHP
Definition: plugin.h:261
int can_pay(object *pl)
Definition: shop.c:840
#define FLAG_UNIQUE
Definition: define.h:288
#define CFAPI_OBJECT_PROP_VALUE
Definition: plugin.h:207
static void cfapi_cost_string_from_value(int *type,...)
Definition: plugins.c:767
void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Definition: main.c:325
#define CFAPI_OBJECT_PROP_SPELL_ITEM
Definition: plugin.h:230
#define CFAPI_OBJECT_PROP_PATH_ATTUNED
Definition: plugin.h:201
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:129
int32_t move_status
Definition: object.h:390
int16_t level
Definition: object.h:351
int8_t facing
Definition: object.h:335
void fix_object(object *op)
Definition: living.c:1119
static void send_changed_object(object *op)
Definition: plugins.c:282
unsigned find_face(const char *name, unsigned error)
Definition: image.c:303
player * find_player_partial_name(const char *plname)
Definition: player.c:110
#define CFAPI_OBJECT_PROP_WIS
Definition: plugin.h:251
EXTERN mapstruct * first_map
Definition: global.h:118
int quest_was_completed(player *pl, sstring quest_code)
Definition: quest.c:1142
#define CFAPI_OBJECT_PROP_DURATION
Definition: plugin.h:278
EXTERN archetype * first_archetype
Definition: global.h:122
char * longname
Definition: map.h:291
void object_update_speed(object *op)
Definition: object.c:1150
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:307
void clean_object(object *op)
Definition: map.c:1643
int32_t value
Definition: object.h:350
object * object_get_owner(object *op)
Definition: object.c:590
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:171
int8_t magic
Definition: object.h:348
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:190
#define CFAPI_OBJECT_PROP_CUSTOM_NAME
Definition: plugin.h:234
const char * name
Definition: object.h:466
#define EVENT_BORN
Definition: plugin.h:83
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
f_plug_event gevent[NR_EVENTS]
Definition: plugin.h:150
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: porting.c:366
int plugins_remove_plugin(const char *id)
Definition: plugins.c:702
void(* f_plug_api)(int *type,...)
Definition: plugin.h:125
int execute_global_event(int eventcode,...)
Definition: plugins.c:383
object * object_find_by_arch_name(const object *who, const char *name)
Definition: object.c:4163
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Definition: object.c:3056
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
Definition: plugin.h:174
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:707
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Definition: spell_util.c:1469
void object_remove(object *op)
Definition: object.c:1666
#define EVENT_USER
Definition: plugin.h:78
static void cfapi_generate_random_map(int *type,...)
Definition: plugins.c:4606
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:203
static void cfapi_map_update_position(int *type,...)
Definition: plugins.c:1489
#define CFAPI_OBJECT_PROP_MOVE_BLOCK
Definition: plugin.h:272
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:325
struct obj * attacked_by
Definition: object.h:382
#define CFAPI_PPARTY
Definition: plugin.h:116
static void cfapi_map_change_light(int *type,...)
Definition: plugins.c:1596
int32_t food
Definition: living.h:48
#define FLAG_FREED
Definition: define.h:233
#define EVENT_MUZZLE
Definition: plugin.h:96
uint32_t count
Definition: player.h:109