Crossfire Server, Trunk
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 
42 #ifdef WIN32
43 #include "libloaderapi.h"
44 #endif
45 
47 #define NR_OF_HOOKS (sizeof(plug_hooks)/sizeof(*plug_hooks))
48 
49 static void cfapi_cost_string_from_value(int *type, ...);
50 static void cfapi_system_find_animation(int *type, ...);
51 static void cfapi_system_find_face(int *type, ...);
52 static void cfapi_system_strdup_local(int *type, ...);
53 static void cfapi_system_register_global_event(int *type, ...);
54 static void cfapi_system_unregister_global_event(int *type, ...);
55 static void cfapi_system_add_string(int *type, ...);
56 static void cfapi_system_remove_string(int *type, ...);
57 static void cfapi_system_find_string(int *type, ...);
58 static void cfapi_system_check_path(int *type, ...);
59 static void cfapi_system_re_cmp(int *type, ...);
60 static void cfapi_system_directory(int *type, ...);
61 static void cfapi_get_time(int *type, ...);
62 static void cfapi_get_season_name(int *type, ...);
63 static void cfapi_get_weekday_name(int *type, ...);
64 static void cfapi_get_month_name(int *type, ...);
65 static void cfapi_get_periodofday_name(int *type, ...);
66 static void cfapi_timer_create(int *type, ...);
67 static void cfapi_timer_destroy(int *type, ...);
68 static void cfapi_log(int *type, ...);
69 static void cfapi_map_get_map(int *type, ...);
70 static void cfapi_map_has_been_loaded(int *type, ...);
71 static void cfapi_map_create_path(int *type, ...);
72 static void cfapi_map_get_map_property(int *type, ...);
73 static void cfapi_map_set_map_property(int *type, ...);
74 static void cfapi_map_out_of_map(int *type, ...);
75 static void cfapi_map_update_position(int *type, ...);
76 static void cfapi_map_delete_map(int *type, ...);
77 static void cfapi_map_message(int *type, ...);
78 static void cfapi_map_get_object_at(int *type, ...);
79 static void cfapi_map_find_by_archetype_name(int *type, ...);
80 static void cfapi_map_change_light(int *type, ...);
81 static void cfapi_object_move(int *type, ...);
82 static void cfapi_object_get_key(int *type, ...);
83 static void cfapi_object_set_key(int *type, ...);
84 static void cfapi_object_get_property(int *type, ...);
85 static void cfapi_object_set_property(int *type, ...);
86 static void cfapi_object_apply_below(int *type, ...);
87 static void cfapi_object_apply(int *type, ...);
88 static void cfapi_object_identify(int *type, ...);
89 static void cfapi_object_describe(int *type, ...);
90 static void cfapi_object_drain(int *type, ...);
91 static void cfapi_object_remove_depletion(int *type, ...);
92 static void cfapi_object_fix(int *type, ...);
93 static void cfapi_object_give_skill(int *type, ...);
94 static void cfapi_object_transmute(int *type, ...);
95 static void cfapi_object_remove(int *type, ...);
96 static void cfapi_object_delete(int *type, ...);
97 static void cfapi_object_clone(int *type, ...);
98 static void cfapi_object_create(int *type, ...);
99 static void cfapi_object_insert(int *type, ...);
100 static void cfapi_object_split(int *type, ...);
101 static void cfapi_object_merge(int *type, ...);
102 static void cfapi_object_distance(int *type, ...);
103 static void cfapi_object_update(int *type, ...);
104 static void cfapi_object_clear(int *type, ...);
105 static void cfapi_object_reset(int *type, ...);
106 static void cfapi_object_clean_object(int *type, ...);
107 static void cfapi_object_on_same_map(int *type, ...);
108 static void cfapi_object_spring_trap(int *type, ...);
109 static void cfapi_object_check_trigger(int *type, ...);
110 static void cfapi_map_trigger_connected(int *type, ...);
111 static void cfapi_object_query_money(int *type, ...);
112 static void cfapi_object_cast(int *type, ...);
113 static void cfapi_object_learn_spell(int *type, ...);
114 static void cfapi_object_forget_spell(int *type, ...);
115 static void cfapi_object_check_spell(int *type, ...);
116 static void cfapi_object_pay_amount(int *type, ...);
117 static void cfapi_object_pay_item(int *type, ...);
118 static void cfapi_object_transfer(int *type, ...);
119 static void cfapi_object_find_archetype_inside(int *type, ...);
120 static void cfapi_object_find_by_arch_name(int *type, ...);
121 static void cfapi_object_find_by_name(int *type, ...);
122 static void cfapi_object_drop(int *type, ...);
123 static void cfapi_object_change_abil(int *type, ...);
124 static void cfapi_object_say(int *type, ...);
125 static void cfapi_player_find(int *type, ...);
126 static void cfapi_player_message(int *type, ...);
127 static void cfapi_object_change_exp(int *type, ...);
128 static void cfapi_player_can_pay(int *type, ...);
129 static void cfapi_player_knowledge(int *type, ...);
130 static void cfapi_object_teleport(int *type, ...);
131 static void cfapi_object_pickup(int *type, ...);
132 static void cfapi_archetype_get_property(int *type, ...);
133 static void cfapi_party_get_property(int *type, ...);
134 static void cfapi_region_get_property(int *type, ...);
135 static void cfapi_friendlylist_get_next(int *type, ...);
136 static void cfapi_set_random_map_variable(int *type, ...);
137 static void cfapi_generate_random_map(int *type, ...);
138 static void cfapi_object_user_event(int *type, ...);
139 static void cfapi_player_quest(int *type, ...);
140 static void cfapi_object_perm_exp(int *type, ...);
141 static void cfapi_register_command(int *type, ...);
142 static void cfapi_unregister_command(int *type, ...);
143 
147 static const hook_entry plug_hooks[] = {
148  { cfapi_system_add_string, 0, "cfapi_system_add_string" },
149  { cfapi_system_register_global_event, 1, "cfapi_system_register_global_event" },
150  { cfapi_system_remove_string, 2, "cfapi_system_remove_string" },
151  { cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event" },
152  { cfapi_system_check_path, 4, "cfapi_system_check_path" },
153  { cfapi_system_re_cmp, 5, "cfapi_system_re_cmp" },
154  { cfapi_system_strdup_local, 6, "cfapi_system_strdup_local" },
155  { cfapi_system_directory, 7, "cfapi_system_directory" },
156  { cfapi_system_find_animation, 8, "cfapi_system_find_animation" },
157  { cfapi_object_clean_object, 9, "cfapi_object_clean_object" },
158  { cfapi_object_on_same_map, 10, "cfapi_object_on_same_map" },
159  { cfapi_object_get_key, 11, "cfapi_object_get_key" },
160  { cfapi_object_set_key, 12, "cfapi_object_set_key" },
161  { cfapi_object_get_property, 13, "cfapi_object_get_property" },
162  { cfapi_object_set_property, 14, "cfapi_object_set_property" },
163  { cfapi_object_apply, 15, "cfapi_object_apply" },
164  { cfapi_object_identify, 16, "cfapi_object_identify" },
165  { cfapi_object_describe, 17, "cfapi_object_describe" },
166  { cfapi_object_drain, 18, "cfapi_object_drain" },
167  { cfapi_object_fix, 19, "cfapi_object_fix" },
168  { cfapi_object_give_skill, 20, "cfapi_object_give_skill" },
169  { cfapi_object_transmute, 21, "cfapi_object_transmute" },
170  { cfapi_object_remove, 22, "cfapi_object_remove" },
171  { cfapi_object_delete, 23, "cfapi_object_delete" },
172  { cfapi_object_clone, 24, "cfapi_object_clone" },
173  { cfapi_object_create, 26, "cfapi_object_create" },
174  { cfapi_object_insert, 27, "cfapi_object_insert" },
175  { cfapi_object_split, 28, "cfapi_object_split" },
176  { cfapi_object_merge, 29, "cfapi_object_merge" },
177  { cfapi_object_distance, 30, "cfapi_object_distance" },
178  { cfapi_object_update, 31, "cfapi_object_update" },
179  { cfapi_object_clear, 32, "cfapi_object_clear" },
180  { cfapi_object_reset, 33, "cfapi_object_reset" },
181  { cfapi_object_spring_trap, 35, "cfapi_object_spring_trap" },
182  { cfapi_object_check_trigger, 36, "cfapi_object_check_trigger" },
183  { cfapi_object_query_money, 38, "cfapi_object_query_money" },
184  { cfapi_object_cast, 39, "cfapi_object_cast" },
185  { cfapi_object_learn_spell, 40, "cfapi_object_learn_spell" },
186  { cfapi_object_forget_spell, 41, "cfapi_object_forget_spell" },
187  { cfapi_object_check_spell, 42, "cfapi_object_check_spell" },
188  { cfapi_object_pay_amount, 43, "cfapi_object_pay_amount" },
189  { cfapi_object_pay_item, 44, "cfapi_object_pay_item" },
190  { cfapi_object_transfer, 45, "cfapi_object_transfer" },
191  { cfapi_object_drop, 46, "cfapi_object_drop" },
192  { cfapi_object_change_abil, 47, "cfapi_object_change_abil" },
193  { cfapi_object_find_archetype_inside, 48, "cfapi_object_find_archetype_inside" },
194  { cfapi_object_say, 49, "cfapi_object_say" },
195  { cfapi_map_get_map, 50, "cfapi_map_get_map" },
196  { cfapi_map_has_been_loaded, 51, "cfapi_map_has_been_loaded" },
197  { cfapi_map_create_path, 52, "cfapi_map_create_path" },
198  { cfapi_map_get_map_property, 53, "cfapi_map_get_property" },
199  { cfapi_map_set_map_property, 54, "cfapi_map_set_property" },
200  { cfapi_map_out_of_map, 55, "cfapi_map_out_of_map" },
201  { cfapi_map_update_position, 56, "cfapi_map_update_position" },
202  { cfapi_map_delete_map, 57, "cfapi_map_delete_map" },
203  { cfapi_map_message, 58, "cfapi_map_message" },
204  { cfapi_map_get_object_at, 59, "cfapi_map_get_object_at" },
205  { cfapi_map_change_light, 60, "cfapi_map_change_light" },
206  { cfapi_map_find_by_archetype_name, 61, "cfapi_map_find_by_archetype_name" },
207  { cfapi_player_find, 62, "cfapi_player_find" },
208  { cfapi_player_message, 63, "cfapi_player_message" },
209  { cfapi_object_change_exp, 64, "cfapi_object_change_exp" },
210  { cfapi_object_teleport, 65, "cfapi_object_teleport" },
211  { cfapi_object_pickup, 67, "cfapi_object_pickup" },
212  { cfapi_object_move, 68, "cfapi_object_move" },
213  { cfapi_object_apply_below, 69, "cfapi_object_apply_below" },
214  { cfapi_generate_random_map, 70, "cfapi_generate_random_map" },
215  { cfapi_archetype_get_property, 71, "cfapi_archetype_get_property" },
216  { cfapi_party_get_property, 72, "cfapi_party_get_property" },
217  { cfapi_region_get_property, 73, "cfapi_region_get_property" },
218  { cfapi_player_can_pay, 74, "cfapi_player_can_pay" },
219  { cfapi_log, 75, "cfapi_log" },
220  { cfapi_get_time, 76, "cfapi_system_get_time" },
221  { cfapi_timer_create, 77, "cfapi_system_timer_create" },
222  { cfapi_timer_destroy, 78, "cfapi_system_timer_destroy" },
223  { cfapi_friendlylist_get_next, 79, "cfapi_friendlylist_get_next" },
224  { cfapi_set_random_map_variable, 80, "cfapi_set_random_map_variable" },
225  { cfapi_system_find_face, 81, "cfapi_system_find_face" },
226  { cfapi_get_season_name, 82, "cfapi_system_get_season_name" },
227  { cfapi_get_month_name, 83, "cfapi_system_get_month_name" },
228  { cfapi_get_weekday_name, 84, "cfapi_system_get_weekday_name" },
229  { cfapi_get_periodofday_name, 85, "cfapi_system_get_periodofday_name" },
230  { cfapi_map_trigger_connected, 86, "cfapi_map_trigger_connected" },
231  { cfapi_object_user_event, 87, "cfapi_object_user_event" },
232  { cfapi_system_find_string, 88, "cfapi_system_find_string" },
233  { cfapi_cost_string_from_value, 90, "cfapi_cost_string_from_value" },
234  { cfapi_player_quest, 91, "cfapi_player_quest" },
235  { cfapi_object_remove_depletion, 92, "cfapi_object_remove_depletion" },
236  { cfapi_object_find_by_arch_name, 93, "cfapi_object_find_by_arch_name" },
237  { cfapi_object_find_by_name, 94, "cfapi_object_find_by_name" },
238  { cfapi_player_knowledge, 95, "cfapi_player_knowledge" },
239  { cfapi_object_perm_exp, 96, "cfapi_object_perm_exp" },
240  { cfapi_register_command, 97, "cfapi_register_command" },
241  { cfapi_unregister_command, 98, "cfapi_unregister_command" },
242 };
243 
246 
247 /*****************************************************************************/
248 /* NEW PLUGIN STUFF STARTS HERE */
249 /*****************************************************************************/
250 
256 static crossfire_plugin *plugins_find_plugin(const char *id) {
257  crossfire_plugin *cp;
258 
259  if (plugins_list == NULL)
260  return NULL;
261 
262  for (cp = plugins_list; cp != NULL; cp = cp->next) {
263  if (!strcmp(id, cp->id)) {
264  return cp;
265  }
266  }
267  return NULL;
268 }
269 
270 #ifdef WIN32
271 static const char *plugins_dlerror(void)
272 {
273  static char buf[256];
274  DWORD err;
275  char *p;
276 
277  err = GetLastError();
278  if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof (buf), NULL) == 0)
279  snprintf(buf, sizeof (buf), "error %lu", err);
280  p = strchr(buf, '\0');
281  while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
282  p--;
283  *p = '\0';
284  return buf;
285 }
286 
287 #endif /* WIN32 */
288 
294 static void send_changed_object(object *op) {
295  object *tmp;
296  player *pl;
297 
298  if (op->env != NULL) {
300  if (!tmp) {
301  for (pl = first_player; pl; pl = pl->next)
302  if (pl->ob->container == op->env)
303  break;
304  if (pl)
305  tmp = pl->ob;
306  else
307  tmp = NULL;
308  }
309  if (tmp)
310  /* We don't know what changed, so we send everything. */
312  } else {
314  if (tmp->type == PLAYER)
315  tmp->contr->socket.update_look = 1;
317  }
318 }
319 
320 static void cfapi_get_hooks(int *type, ...) {
321  va_list args;
322  int request_type;
323  char *buf;
324  f_plug_api *rapi;
325 
326  *type = CFAPI_NONE;
327 
328  va_start(args, type);
329  request_type = va_arg(args, int);
330  if (request_type == 0) { /* By nr */
331  size_t fid;
332 
333  fid = va_arg(args, int);
334  rapi = va_arg(args, f_plug_api *);
335  if (fid >= NR_OF_HOOKS) {
336  *rapi = NULL;
337  *type = CFAPI_NONE;
338  } else {
339  *rapi = plug_hooks[fid].func;
340  *type = CFAPI_FUNC;
341  }
342  } else { /* by name */
343  size_t i;
344 
345  buf = va_arg(args, char *);
346  rapi = va_arg(args, f_plug_api *);
347  *rapi = NULL;
348  *type = CFAPI_NONE;
349  for (i = 0; i < NR_OF_HOOKS; i++) {
350  if (!strcmp(buf, plug_hooks[i].fname)) {
351  *rapi = plug_hooks[i].func;
352  *type = CFAPI_FUNC;
353  break;
354  }
355  }
356  }
357  va_end(args);
358 }
359 
366 int plugins_init_plugin(const char *libfile) {
367  LIBPTRTYPE ptr;
368  f_plug_init initfunc;
369  f_plug_property propfunc;
370  f_plug_event eventfunc;
371  f_plug_postinit postfunc;
372  f_plug_postinit closefunc;
373  int i;
374  crossfire_plugin *cp;
375  crossfire_plugin *ccp;
376  char *svn_rev;
377 
378 
379  /* Open the plugin lib and load the required functions */
380  ptr = plugins_dlopen(libfile);
381  if (ptr == NULL) {
382  LOG(llevError, "Error trying to load %s: %s\n", libfile, plugins_dlerror());
383  return -1;
384  }
385  svn_rev = (char*) plugins_dlsym(ptr, "SvnRevPlugin");
386  if (svn_rev == NULL) {
387  LOG(llevError, "Unable to find SvnRevPlugin in %s\n", libfile);
388  plugins_dlclose(ptr);
389  return -1;
390  }
391  if (settings.ignore_plugin_compatibility == 0 && strcmp(svn_rev, SVN_REV)) {
392  LOG(llevError, "Version mismatch in in %s (%s != %s)\n", libfile, svn_rev, SVN_REV);
393  plugins_dlclose(ptr);
394  return -1;
395  }
396 
397  initfunc = (f_plug_init)plugins_dlsym(ptr, "initPlugin");
398  if (initfunc == NULL) {
399  LOG(llevError, "Plugin error while requesting %s.initPlugin: %s\n", libfile, plugins_dlerror());
400  plugins_dlclose(ptr);
401  return -1;
402  }
403  propfunc = (f_plug_property)plugins_dlsym(ptr, "getPluginProperty");
404  if (propfunc == NULL) {
405  LOG(llevError, "Plugin error while requesting %s.getPluginProperty: %s\n", libfile, plugins_dlerror());
406  plugins_dlclose(ptr);
407  return -1;
408  }
409  eventfunc = (f_plug_event)plugins_dlsym(ptr, "eventListener");
410  if (eventfunc == NULL) {
411  LOG(llevError, "Plugin error while requesting %s.eventListener: %s\n", libfile, plugins_dlerror());
412  plugins_dlclose(ptr);
413  return -1;
414  }
415  postfunc = (f_plug_postinit)plugins_dlsym(ptr, "postInitPlugin");
416  if (postfunc == NULL) {
417  LOG(llevError, "Plugin error while requesting %s.postInitPlugin: %s\n", libfile, plugins_dlerror());
418  plugins_dlclose(ptr);
419  return -1;
420  }
421  closefunc = (f_plug_postinit)plugins_dlsym(ptr, "closePlugin");
422  if (closefunc == NULL) {
423  LOG(llevError, "Plugin error while requesting %s.closePlugin: %s\n", libfile, plugins_dlerror());
424  plugins_dlclose(ptr);
425  return -1;
426  }
427  i = initfunc("2.0", cfapi_get_hooks);
428  cp = malloc(sizeof(crossfire_plugin));
429  for (i = 0; i < NR_EVENTS; i++)
430  cp->global_registration[i] = 0;
431  cp->propfunc = propfunc;
432  cp->closefunc = closefunc;
433  cp->libptr = ptr;
434  propfunc(&i, "Identification", cp->id, sizeof(cp->id));
435  propfunc(&i, "FullName", cp->fullname, sizeof(cp->fullname));
436  events_register_object_handler(cp->id, eventfunc);
437  cp->next = NULL;
438  cp->prev = NULL;
439  if (plugins_list == NULL) {
440  plugins_list = cp;
441  } else {
442  for (ccp = plugins_list; ccp->next != NULL; ccp = ccp->next)
443  ;
444  ccp->next = cp;
445  cp->prev = ccp;
446  }
447  postfunc();
448  return 0;
449 }
450 
457 int plugins_remove_plugin(const char *id) {
458  crossfire_plugin *cp;
459 
460  if (plugins_list == NULL)
461  return -1;
462 
463  for (cp = plugins_list; cp != NULL; cp = cp->next) {
464  if (!strcmp(id, cp->id)) {
465  crossfire_plugin *n;
466  crossfire_plugin *p;
467 
468  for (int eventcode = 0; eventcode < NR_EVENTS; eventcode++) {
469  if (cp->global_registration[eventcode]) {
470  events_unregister_global_handler(eventcode, cp->global_registration[eventcode]);
471  }
472  }
474 
475  n = cp->next;
476  p = cp->prev;
477  if (cp->closefunc)
478  cp->closefunc();
479  plugins_dlclose(cp->libptr);
480  if (n != NULL) {
481  if (p != NULL) {
482  n->prev = p;
483  p->next = n;
484  } else {
485  n->prev = NULL;
486  plugins_list = n;
487  }
488  } else {
489  if (p != NULL)
490  p->next = NULL;
491  else
492  plugins_list = NULL;
493  }
494  free(cp);
495  return 0;
496  }
497  }
498  return -1;
499 }
500 
506 void plugins_display_list(object *op) {
507  crossfire_plugin *cp;
508 
510  "List of loaded plugins:\n-----------------------");
511 
512  if (plugins_list == NULL)
513  return;
514 
515  for (cp = plugins_list; cp != NULL; cp = cp->next) {
517  "%s, %s",
518  cp->id, cp->fullname);
519  }
520 }
521 
522 /* SYSTEM-RELATED HOOKS */
523 
529 static void cfapi_cost_string_from_value(int *type, ...) {
530  uint64_t cost;
531  char *buffer, *final;
532  int length, largest_coin;
533  va_list args;
534 
535  va_start(args, type);
536  cost = va_arg(args, uint64_t);
537  largest_coin = va_arg(args, int);
538  buffer = va_arg(args, char*);
539  length = va_arg(args, int);
540  va_end(args);
541 
542  *type = CFAPI_NONE;
543 
544  if (length < 1)
545  return;
546 
547  final = cost_string_from_value(cost, largest_coin);
548 
549  strncpy(buffer, final, length - 1);
550  buffer[length - 1] = '\0';
551  free(final);
552 }
553 
559 static void cfapi_system_find_animation(int *type, ...) {
560  va_list args;
561  const char *name;
562  int *num;
563  const Animations *anim;
564 
565  va_start(args, type);
566  name = va_arg(args, const char *);
567  num = va_arg(args, int *);
568  va_end(args);
569 
571  (*num) = anim ? anim->num : 0;
572  *type = CFAPI_INT;
573 }
574 
580 static void cfapi_system_find_face(int *type, ...) {
581  va_list args;
582  const char *face;
583  int error;
584  int *num;
585  const Face *f;
586 
587  va_start(args, type);
588  face = va_arg(args, const char *);
589  error = va_arg(args, int);
590  num = va_arg(args, int *);
591  va_end(args);
592 
593  f = try_find_face(face, get_face_by_id(error));
594  (*num) = f ? f->number : 0;
595  *type = CFAPI_INT;
596 }
597 
603 static void cfapi_system_strdup_local(int *type, ...) {
604  va_list args;
605  const char *txt;
606  char **ret;
607 
608  va_start(args, type);
609  txt = va_arg(args, const char *);
610  ret = va_arg(args, char **);
611  va_end(args);
612 
613  *ret = strdup_local(txt);
614  *type = CFAPI_STRING;
615 }
616 
617 static void cfapi_system_register_global_event(int *type, ...) {
618  va_list args;
619  int eventcode;
620  char *pname;
621  f_plug_event hook;
622  crossfire_plugin *cp;
623 
624  va_start(args, type);
625  eventcode = va_arg(args, int);
626  pname = va_arg(args, char *);
627  hook = va_arg(args, f_plug_event);
628  va_end(args);
629 
630  *type = CFAPI_NONE;
631 
632  cp = plugins_find_plugin(pname);
633  if (!cp->global_registration[eventcode]) {
634  cp->global_registration[eventcode] = events_register_global_handler(eventcode, hook);
635  }
636 }
637 
639  va_list args;
640  int eventcode;
641  char *pname;
642  crossfire_plugin *cp;
643 
644  va_start(args, type);
645  eventcode = va_arg(args, int);
646  pname = va_arg(args, char *);
647  va_end(args);
648 
649  *type = CFAPI_NONE;
650 
651  cp = plugins_find_plugin(pname);
652  if (cp->global_registration[eventcode]) {
653  events_unregister_global_handler(eventcode, cp->global_registration[eventcode]);
654  cp->global_registration[eventcode] = 0;
655  }
656 }
657 
664 static void cfapi_system_add_string(int *type, ...) {
665  va_list args;
666  const char *str;
667  sstring *rv;
668 
669  va_start(args, type);
670  str = va_arg(args, const char *);
671  rv = va_arg(args, sstring *);
672  va_end(args);
673 
674  *rv = add_string(str);
675  *type = CFAPI_SSTRING;
676 }
677 
684 static void cfapi_system_remove_string(int *type, ...) {
685  va_list args;
686  sstring str;
687 
688  va_start(args, type);
689  str = va_arg(args, sstring);
690  va_end(args);
691 
692  free_string(str);
693  *type = CFAPI_NONE;
694 }
695 
702 static void cfapi_system_find_string(int *type, ...) {
703  va_list args;
704  const char *str;
705  sstring *rv;
706 
707  va_start(args, type);
708  str = va_arg(args, const char *);
709  rv = va_arg(args, sstring *);
710  va_end(args);
711 
712  *rv = find_string(str);
713  *type = CFAPI_SSTRING;
714 }
715 
721 static void cfapi_system_check_path(int *type, ...) {
722  va_list args;
723  const char *name;
724  int prepend_dir;
725  int *ret;
726 
727  va_start(args, type);
728 
729  name = va_arg(args, char *);
730  prepend_dir = va_arg(args, int);
731  ret = va_arg(args, int *);
732 
733  *ret = check_path(name, prepend_dir);
734 
735  va_end(args);
736  *type = CFAPI_INT;
737 }
738 
744 static void cfapi_system_re_cmp(int *type, ...) {
745  va_list args;
746  const char *str;
747  const char *regexp;
748  const char **rv;
749 
750  va_start(args, type);
751 
752  str = va_arg(args, char *);
753  regexp = va_arg(args, char *);
754  rv = va_arg(args, const char **);
755 
756  *rv = re_cmp(str, regexp);
757 
758  va_end(args);
759  *type = CFAPI_STRING;
760 }
761 
762 static void cfapi_system_directory(int *type, ...) {
763  va_list args;
764  int dirtype;
765  const char **str;
766 
767  va_start(args, type);
768 
769  dirtype = va_arg(args, int);
770  str = va_arg(args, const char **);
771  va_end(args);
772 
773  *type = CFAPI_STRING;
774 
775  switch (dirtype) {
776  case 0:
777  *str = settings.mapdir;
778  break;
779 
780  case 1:
782  break;
783 
784  case 2:
785  *str = settings.tmpdir;
786  break;
787 
788  case 3:
789  *str = settings.confdir;
790  break;
791 
792  case 4:
793  *str = settings.localdir;
794  break;
795 
796  case 5:
798  break;
799 
800  case 6:
801  *str = settings.datadir;
802  break;
803 
804  default:
805  *str = NULL;
806  }
807 }
808 
815 static void cfapi_get_time(int *type, ...) {
816  va_list args;
817  timeofday_t *tod;
818 
819  va_start(args, type);
820  tod = va_arg(args, timeofday_t *);
821  va_end(args);
822 
823  get_tod(tod);
824  *type = CFAPI_NONE;
825 }
826 
827 #define string_get_int(name) \
828  va_list args; \
829  int index; \
830  const char **str; \
831  va_start(args, type); \
832  index = va_arg(args, int); \
833  str = va_arg(args, const char **); \
834  va_end(args); \
835  *str = name(index); \
836  *type = CFAPI_STRING; \
837 
838 
846 static void cfapi_get_season_name(int *type, ...) {
848 }
849 
858 static void cfapi_get_weekday_name(int *type, ...) {
860 }
861 
870 static void cfapi_get_month_name(int *type, ...) {
872 }
873 
882 static void cfapi_get_periodofday_name(int *type, ...) {
884 }
885 
897 static void cfapi_timer_create(int *type, ...) {
898  va_list args;
899  int res;
900  object *ob;
901  long delay;
902  int mode;
903  int *timer;
904 
905  va_start(args, type);
906  ob = va_arg(args, object *);
907  delay = va_arg(args, long);
908  mode = va_arg(args, int);
909  timer = va_arg(args, int *);
910  va_end(args);
911  *type = CFAPI_INT;
912 
913  *timer = cftimer_find_free_id();
914  if (*timer != TIMER_ERR_ID) {
915  res = cftimer_create(*timer, delay, ob, mode);
916  if (res != TIMER_ERR_NONE)
917  *timer = res;
918  }
919 }
920 
930 static void cfapi_timer_destroy(int *type, ...) {
931  va_list args;
932  int id;
933  int *err;
934 
935  va_start(args, type);
936  id = va_arg(args, int);
937  err = va_arg(args, int *);
938  va_end(args);
939  *type = CFAPI_INT;
940 
941  *err = cftimer_destroy(id);
942 }
943 
949 static void cfapi_log(int *type, ...) {
950  va_list args;
951  LogLevel logLevel;
952  const char *message;
953 
954  va_start(args, type);
955  logLevel = va_arg(args, LogLevel);
956  message = va_arg(args, const char *);
957  LOG(logLevel, "%s", message);
958  va_end(args);
959 
960  *type = CFAPI_NONE;
961 }
962 
963 /* MAP RELATED HOOKS */
964 
973 static void cfapi_map_get_map(int *type, ...) {
974  va_list args;
975  mapstruct **ret;
976  int ctype;
977  int x, y;
978  int16_t nx, ny;
979  const char *name;
980  mapstruct *m;
981 
982  va_start(args, type);
983 
984  ctype = va_arg(args, int);
985 
986  switch (ctype) {
987  case 0:
988  x = va_arg(args, int);
989  y = va_arg(args, int);
990  ret = va_arg(args, mapstruct **);
991  *ret = get_empty_map(x, y);
992  break;
993 
994  case 1:
995  name = va_arg(args, const char *);
996  x = va_arg(args, int);
997  ret = va_arg(args, mapstruct **);
998  *ret = ready_map_name(name, x);
999  break;
1000 
1001  case 2:
1002  m = va_arg(args, mapstruct *);
1003  nx = va_arg(args, int);
1004  ny = va_arg(args, int);
1005  ret = va_arg(args, mapstruct **);
1006  *ret = get_map_from_coord(m, &nx, &ny);
1007  break;
1008 
1009  default:
1010  *type = CFAPI_NONE;
1011  va_end(args);
1012  return;
1013  break;
1014  }
1015  va_end(args);
1016  *type = CFAPI_PMAP;
1017 }
1018 
1024 static void cfapi_map_has_been_loaded(int *type, ...) {
1025  va_list args;
1026  mapstruct **map;
1027  char *string;
1028 
1029  va_start(args, type);
1030  string = va_arg(args, char *);
1031  map = va_arg(args, mapstruct **);
1032  *map = has_been_loaded(string);
1033  va_end(args);
1034  *type = CFAPI_PMAP;
1035 }
1036 
1042 static void cfapi_map_create_path(int *type, ...) {
1043  va_list args;
1044  int ctype, size;
1045  const char *str;
1046  char *name;
1047 
1048  va_start(args, type);
1049 
1050  ctype = va_arg(args, int);
1051  str = va_arg(args, const char *);
1052  name = va_arg(args, char *);
1053  size = va_arg(args, int);
1054  *type = CFAPI_STRING;
1055 
1056  switch (ctype) {
1057  case 0:
1058  create_pathname(str, name, size);
1059  break;
1060 
1061  case 1:
1063  break;
1064 
1065 /* case 2:
1066  rv = create_items_path(str);
1067  break;*/
1068 
1069  default:
1070  *type = CFAPI_NONE;
1071  break;
1072  }
1073  va_end(args);
1074 }
1075 
1076 static void cfapi_map_get_map_property(int *type, ...) {
1077  va_list args;
1078  mapstruct *map;
1079  int property;
1080 
1081  int *rint;
1082  mapstruct **rmap;
1083  sstring *rstr;
1084  region **rreg;
1085  int16_t *nx, *ny;
1086  int x, y;
1087 
1088  va_start(args, type);
1089 
1090  map = va_arg(args, mapstruct *);
1091  property = va_arg(args, int);
1092 
1093  switch (property) {
1094  case CFAPI_MAP_PROP_FLAGS:
1095  rmap = va_arg(args, mapstruct **);
1096  x = va_arg(args, int);
1097  y = va_arg(args, int);
1098  nx = va_arg(args, int16_t *);
1099  ny = va_arg(args, int16_t *);
1100  rint = va_arg(args, int *);
1101  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1102  *type = CFAPI_INT;
1103  break;
1104 
1106  rint = va_arg(args, int *);
1107  *rint = calculate_difficulty(map);
1108  *type = CFAPI_INT;
1109  break;
1110 
1111  case CFAPI_MAP_PROP_PATH:
1112  rstr = va_arg(args, sstring *);
1113  *rstr = map->path;
1114  *type = CFAPI_SSTRING;
1115  break;
1116 
1118  rstr = va_arg(args, sstring *);
1119  *rstr = map->tmpname;
1120  *type = CFAPI_SSTRING;
1121  break;
1122 
1123  case CFAPI_MAP_PROP_NAME:
1124  rstr = va_arg(args, sstring *);
1125  *rstr = map->name;
1126  *type = CFAPI_SSTRING;
1127  break;
1128 
1130  rint = va_arg(args, int *);
1131  *rint = map->reset_time;
1132  *type = CFAPI_INT;
1133  break;
1134 
1136  rint = va_arg(args, int *);
1137  *rint = map->reset_timeout;
1138  *type = CFAPI_INT;
1139  break;
1140 
1142  rint = va_arg(args, int *);
1143  *rint = map->players;
1144  *type = CFAPI_INT;
1145  break;
1146 
1148  rint = va_arg(args, int *);
1149  *rint = map->darkness;
1150  *type = CFAPI_INT;
1151  break;
1152 
1153  case CFAPI_MAP_PROP_WIDTH:
1154  rint = va_arg(args, int *);
1155  *rint = map->width;
1156  *type = CFAPI_INT;
1157  break;
1158 
1159  case CFAPI_MAP_PROP_HEIGHT:
1160  rint = va_arg(args, int *);
1161  *rint = map->height;
1162  *type = CFAPI_INT;
1163  break;
1164 
1166  rint = va_arg(args, int *);
1167  *rint = map->enter_x;
1168  *type = CFAPI_INT;
1169  break;
1170 
1172  rint = va_arg(args, int *);
1173  *rint = map->enter_y;
1174  *type = CFAPI_INT;
1175  break;
1176 
1178  rstr = va_arg(args, sstring *);
1179  *rstr = map->msg;
1180  *type = CFAPI_SSTRING;
1181  break;
1182 
1183  case CFAPI_MAP_PROP_NEXT:
1184  rmap = va_arg(args, mapstruct **);
1185  *rmap = map ? map->next : first_map;
1186  *type = CFAPI_PMAP;
1187  break;
1188 
1189  case CFAPI_MAP_PROP_REGION:
1190  rreg = va_arg(args, region **);
1191  *rreg = get_region_by_map(map);
1192  *type = CFAPI_PREGION;
1193  break;
1194 
1195  case CFAPI_MAP_PROP_UNIQUE:
1196  rint = va_arg(args, int *);
1197  *rint = map->unique;
1198  *type = CFAPI_INT;
1199  break;
1200 
1201  default:
1202  *type = CFAPI_NONE;
1203  break;
1204  }
1205  va_end(args);
1206 }
1207 
1208 static void cfapi_map_set_map_property(int *type, ...) {
1209  va_list args;
1210  mapstruct *map;
1211  int property;
1212  const char *buf;
1213 
1214  va_start(args, type);
1215 
1216  map = va_arg(args, mapstruct *);
1217  property = va_arg(args, int);
1218 
1219  switch (property) {
1220  case CFAPI_MAP_PROP_PATH:
1221  buf = va_arg(args, const char *);
1222  strlcpy(map->path, buf, sizeof(map->path));
1223  *type = CFAPI_STRING;
1224  break;
1225 
1226  default:
1227  *type = CFAPI_NONE;
1228  break;
1229  }
1230  va_end(args);
1231 }
1232 
1238 static void cfapi_map_out_of_map(int *type, ...) {
1239  va_list args;
1240  mapstruct *map;
1241  int x, y;
1242  int *rint;
1243 
1244  va_start(args, type);
1245  map = va_arg(args, mapstruct *);
1246  x = va_arg(args, int);
1247  y = va_arg(args, int);
1248  rint = va_arg(args, int *);
1249 
1250  *rint = out_of_map(map, x, y);
1251  va_end(args);
1252  *type = CFAPI_INT;
1253 }
1254 
1260 static void cfapi_map_update_position(int *type, ...) {
1261  va_list args;
1262  mapstruct *map;
1263  int x, y;
1264 
1265  va_start(args, type);
1266 
1267  map = va_arg(args, mapstruct *);
1268  x = va_arg(args, int);
1269  y = va_arg(args, int);
1270 
1271  update_position(map, x, y);
1272  va_end(args);
1273  *type = CFAPI_NONE;
1274 }
1275 
1276 static void cfapi_map_delete_map(int *type, ...) {
1277  va_list args;
1278  mapstruct *map;
1279  va_start(args, type);
1280 
1281  map = va_arg(args, mapstruct *);
1282 
1283  delete_map(map);
1284 
1285  va_end(args);
1286  *type = CFAPI_NONE;
1287 }
1288 
1289 static void cfapi_map_message(int *type, ...) {
1290  va_list args;
1291  mapstruct *map;
1292  const char *string;
1293  int color;
1294 
1295  va_start(args, type);
1296  map = va_arg(args, mapstruct *);
1297  string = va_arg(args, const char *);
1298  color = va_arg(args, int);
1299  va_end(args);
1300 
1301  /* function should be extended to take message types probably */
1303  *type = CFAPI_NONE;
1304 }
1305 
1311 static void cfapi_map_get_object_at(int *type, ...) {
1312  va_list args;
1313  mapstruct *map;
1314  int x, y;
1315  int16_t sx, sy;
1316  object **robj;
1317 
1318  va_start(args, type);
1319  map = va_arg(args, mapstruct *);
1320  x = va_arg(args, int);
1321  y = va_arg(args, int);
1322  robj = va_arg(args, object **);
1323  va_end(args);
1324 
1325  sx = x;
1326  sy = y;
1327  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1328  *robj = NULL;
1329  else
1330  *robj = GET_MAP_OB(map, sx, sy);
1331  *type = CFAPI_POBJECT;
1332 }
1333 
1340 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1341  va_list args;
1342  int x, y;
1343  mapstruct *map;
1344  char *msg;
1345  object **robj;
1346 
1347  va_start(args, type);
1348 
1349  msg = va_arg(args, char *);
1350  map = va_arg(args, mapstruct *);
1351  x = va_arg(args, int);
1352  y = va_arg(args, int);
1353  robj = va_arg(args, object **);
1354 
1355  va_end(args);
1356 
1358  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1359  *type = CFAPI_POBJECT;
1360 }
1361 
1367 static void cfapi_map_change_light(int *type, ...) {
1368  va_list args;
1369  int change;
1370  mapstruct *map;
1371  int *rint;
1372 
1373  va_start(args, type);
1374  map = va_arg(args, mapstruct *);
1375  change = va_arg(args, int);
1376  rint = va_arg(args, int *);
1377  va_end(args);
1378 
1379  *type = CFAPI_INT;
1380  *rint = change_map_light(map, change);
1381 }
1382 
1383 /* OBJECT-RELATED HOOKS */
1384 
1398 static void cfapi_object_move(int *type, ...) {
1399  va_list args;
1400  int kind;
1401  object *op;
1402  object *activator;
1403  player *pl;
1404  int direction;
1405  int *ret;
1406 
1407  va_start(args, type);
1408  kind = va_arg(args, int);
1409  switch (kind) {
1410  case 0:
1411  op = va_arg(args, object *);
1412  direction = va_arg(args, int);
1413  activator = va_arg(args, object *);
1414  ret = va_arg(args, int *);
1415  va_end(args);
1416  *ret = move_ob(op, direction, activator);
1417  break;
1418 
1419  case 1:
1420  pl = va_arg(args, player *);
1421  direction = va_arg(args, int);
1422  ret = va_arg(args, int *);
1423  va_end(args);
1424  *ret = move_player(pl->ob, direction);
1425  break;
1426 
1427  case 2:
1428  op = va_arg(args, object *);
1429  ret = va_arg(args, int *);
1430  va_end(args);
1431  *ret = player_arrest(op);
1432  break;
1433 
1434  default:
1435  // Just end the use of variable args. We got a wrong type.
1436  va_end(args);
1437  }
1438  *type = CFAPI_INT;
1439 }
1440 
1448 static void cfapi_object_get_key(int *type, ...) {
1449  va_list args;
1450  const char *keyname;
1451  const char **value;
1452  object *op;
1453 
1454  va_start(args, type);
1455  op = va_arg(args, object *);
1456  keyname = va_arg(args, const char *);
1457  value = va_arg(args, const char **);
1458  va_end(args);
1459 
1460  *value = object_get_value(op, keyname);
1461  *type = CFAPI_SSTRING;
1462 }
1463 
1470 static void cfapi_object_set_key(int *type, ...) {
1471  va_list args;
1472  const char *keyname;
1473  const char *value;
1474  int *ret;
1475  object *op;
1476  int add_key;
1477 
1478  va_start(args, type);
1479  op = va_arg(args, object *);
1480  keyname = va_arg(args, char *);
1481  value = va_arg(args, char *);
1482  add_key = va_arg(args, int);
1483  ret = va_arg(args, int *);
1484  va_end(args);
1485 
1486  *ret = object_set_value(op, keyname, value, add_key);
1487  *type = CFAPI_INT;
1488 }
1489 
1493 static void cfapi_object_get_property(int *type, ...) {
1494  va_list args;
1495  int property;
1496  object *op;
1497  int *rint;
1498  object **robject;
1499  mapstruct **rmap;
1500  float *rfloat;
1501  archetype **rarch;
1502  sstring *rsstring;
1503  char *rbuffer;
1504  int rbufsize;
1505  MoveType *rmove;
1506  int64_t *rint64;
1507  partylist **rparty;
1508  double *rdouble;
1509  long *rlong;
1510 
1511  va_start(args, type);
1512 
1513  op = va_arg(args, object *);
1514  property = va_arg(args, int);
1515  switch (property) {
1517  robject = va_arg(args, object **);
1518  *robject = op->above;
1519  *type = CFAPI_POBJECT;
1520  break;
1521 
1523  robject = va_arg(args, object **);
1524  *robject = op->below;
1525  *type = CFAPI_POBJECT;
1526  break;
1527 
1529  robject = va_arg(args, object **);
1530  *robject = op->active_next;
1531  *type = CFAPI_POBJECT;
1532  break;
1533 
1535  robject = va_arg(args, object **);
1536  *robject = op->active_prev;
1537  *type = CFAPI_POBJECT;
1538  break;
1539 
1541  robject = va_arg(args, object **);
1542  *robject = op->inv;
1543  *type = CFAPI_POBJECT;
1544  break;
1545 
1547  robject = va_arg(args, object **);
1548  *robject = op->env;
1549  *type = CFAPI_POBJECT;
1550  break;
1551 
1553  robject = va_arg(args, object **);
1554  *robject = op->head;
1555  *type = CFAPI_POBJECT;
1556  break;
1557 
1559  robject = va_arg(args, object **);
1560  *robject = op->container;
1561  *type = CFAPI_POBJECT;
1562  break;
1563 
1564  case CFAPI_OBJECT_PROP_MAP:
1565  rmap = va_arg(args, mapstruct **);
1566  *rmap = op->map;
1567  *type = CFAPI_PMAP;
1568  break;
1569 
1571  rint = va_arg(args, int *);
1572  *rint = op->count;
1573  *type = CFAPI_INT;
1574  break;
1575 
1577  rbuffer = va_arg(args, char *);
1578  rbufsize = va_arg(args, int);
1579  query_name(op, rbuffer, rbufsize);
1580  *type = CFAPI_STRING;
1581  break;
1582 
1584  rsstring = va_arg(args, sstring *);
1585  *rsstring = op->name_pl;
1586  *type = CFAPI_SSTRING;
1587  break;
1588 
1590  rsstring = va_arg(args, sstring *);
1591  *rsstring = op->title;
1592  *type = CFAPI_SSTRING;
1593  break;
1594 
1596  rsstring = va_arg(args, sstring *);
1597  *rsstring = op->race;
1598  *type = CFAPI_SSTRING;
1599  break;
1600 
1602  rsstring = va_arg(args, sstring *);
1603  *rsstring = op->slaying;
1604  *type = CFAPI_SSTRING;
1605  break;
1606 
1608  rsstring = va_arg(args, sstring *);
1609  *rsstring = op->skill;
1610  *type = CFAPI_SSTRING;
1611  break;
1612 
1614  rsstring = va_arg(args, sstring *);
1615  *rsstring = op->msg;
1616  *type = CFAPI_SSTRING;
1617  break;
1618 
1620  rsstring = va_arg(args, sstring *);
1621  *rsstring = op->lore;
1622  *type = CFAPI_SSTRING;
1623  break;
1624 
1625  case CFAPI_OBJECT_PROP_X:
1626  rint = va_arg(args, int *);
1627  *rint = op->x;
1628  *type = CFAPI_INT;
1629  break;
1630 
1631  case CFAPI_OBJECT_PROP_Y:
1632  rint = va_arg(args, int *);
1633  *rint = op->y;
1634  *type = CFAPI_INT;
1635  break;
1636 
1638  rfloat = va_arg(args, float *);
1639  *rfloat = op->speed;
1640  *type = CFAPI_FLOAT;
1641  break;
1642 
1644  rfloat = va_arg(args, float *);
1645  *rfloat = op->speed_left;
1646  *type = CFAPI_FLOAT;
1647  break;
1648 
1650  rint = va_arg(args, int *);
1651  *rint = op->nrof;
1652  *type = CFAPI_INT;
1653  break;
1654 
1656  rint = va_arg(args, int *);
1657  *rint = op->direction;
1658  *type = CFAPI_INT;
1659  break;
1660 
1662  rint = va_arg(args, int *);
1663  *rint = op->facing;
1664  *type = CFAPI_INT;
1665  break;
1666 
1668  rint = va_arg(args, int *);
1669  *rint = op->type;
1670  *type = CFAPI_INT;
1671  break;
1672 
1674  rint = va_arg(args, int *);
1675  *rint = op->subtype;
1676  *type = CFAPI_INT;
1677  break;
1678 
1680  rint = va_arg(args, int *);
1681  *rint = op->client_type;
1682  *type = CFAPI_INT;
1683  break;
1684 
1685  case CFAPI_OBJECT_PROP_RESIST: {
1686  int idx;
1687  int16_t *resist;
1688 
1689  idx = va_arg(args, int);
1690  resist = va_arg(args, int16_t *);
1691  *resist = op->resist[idx];
1692  }
1693  *type = CFAPI_INT16;
1694  break;
1695 
1697  rint = va_arg(args, int *);
1698  *rint = op->attacktype;
1699  *type = CFAPI_INT;
1700  break;
1701 
1703  rint = va_arg(args, int *);
1704  *rint = op->path_attuned;
1705  *type = CFAPI_INT;
1706  break;
1707 
1709  rint = va_arg(args, int *);
1710  *rint = op->path_repelled;
1711  *type = CFAPI_INT;
1712  break;
1713 
1715  rint = va_arg(args, int *);
1716  *rint = op->path_denied;
1717  *type = CFAPI_INT;
1718  break;
1719 
1721  rint = va_arg(args, int *);
1722  *rint = op->material;
1723  *type = CFAPI_INT;
1724  break;
1725 
1727  rsstring = va_arg(args, sstring *);
1728  *rsstring = op->materialname;
1729  *type = CFAPI_SSTRING;
1730  break;
1731 
1733  rint = va_arg(args, int *);
1734  *rint = op->magic;
1735  *type = CFAPI_INT;
1736  break;
1737 
1739  rlong = va_arg(args, long *);
1740  *rlong = op->value;
1741  *type = CFAPI_LONG;
1742  break;
1743 
1745  rint = va_arg(args, int *);
1746  *rint = op->level;
1747  *type = CFAPI_INT;
1748  break;
1749 
1751  rint = va_arg(args, int *);
1752  *rint = op->last_heal;
1753  *type = CFAPI_INT;
1754  break;
1755 
1757  rint = va_arg(args, int *);
1758  *rint = op->last_sp;
1759  *type = CFAPI_INT;
1760  break;
1761 
1763  rint = va_arg(args, int *);
1764  *rint = op->last_grace;
1765  *type = CFAPI_INT;
1766  break;
1767 
1769  rint = va_arg(args, int *);
1770  *rint = op->last_eat;
1771  *type = CFAPI_INT;
1772  break;
1773 
1775  rint = va_arg(args, int *);
1776  *rint = op->invisible;
1777  *type = CFAPI_INT;
1778  break;
1779 
1781  rint = va_arg(args, int *);
1782  *rint = op->pick_up;
1783  *type = CFAPI_INT;
1784  break;
1785 
1787  rint = va_arg(args, int *);
1788  *rint = op->item_power;
1789  *type = CFAPI_INT;
1790  break;
1791 
1793  rint = va_arg(args, int *);
1794  *rint = op->gen_sp_armour;
1795  *type = CFAPI_INT;
1796  break;
1797 
1799  rint = va_arg(args, int *);
1800  *rint = op->weight;
1801  *type = CFAPI_INT;
1802  break;
1803 
1805  rint = va_arg(args, int *);
1806  *rint = op->weight_limit;
1807  *type = CFAPI_INT;
1808  break;
1809 
1811  rint = va_arg(args, int *);
1812  *rint = op->carrying;
1813  *type = CFAPI_INT;
1814  break;
1815 
1817  rint = va_arg(args, int *);
1818  *rint = op->glow_radius;
1819  *type = CFAPI_INT;
1820  break;
1821 
1823  rint64 = va_arg(args, int64_t *);
1824  *rint64 = op->total_exp;
1825  *type = CFAPI_SINT64;
1826  break;
1827 
1829  robject = va_arg(args, object **);
1830  *robject = op->current_weapon;
1831  *type = CFAPI_POBJECT;
1832  break;
1833 
1835  robject = va_arg(args, object **);
1836  *robject = op->enemy;
1837  *type = CFAPI_POBJECT;
1838  break;
1839 
1841  robject = va_arg(args, object **);
1842  *robject = op->attacked_by;
1843  *type = CFAPI_POBJECT;
1844  break;
1845 
1847  rint = va_arg(args, int *);
1848  *rint = op->run_away;
1849  *type = CFAPI_INT;
1850  break;
1851 
1853  robject = va_arg(args, object **);
1854  *robject = op->chosen_skill;
1855  *type = CFAPI_POBJECT;
1856  break;
1857 
1859  rint = va_arg(args, int *);
1860  *rint = op->hide;
1861  *type = CFAPI_INT;
1862  break;
1863 
1865  rint = va_arg(args, int *);
1866  *rint = op->move_status;
1867  *type = CFAPI_INT;
1868  break;
1869 
1871  rint = va_arg(args, int *);
1872  *rint = op->attack_movement;
1873  *type = CFAPI_INT;
1874  break;
1875 
1877  robject = va_arg(args, object **);
1878  *robject = op->spellitem;
1879  *type = CFAPI_POBJECT;
1880  break;
1881 
1883  rdouble = va_arg(args, double *);
1884  *rdouble = op->expmul;
1885  *type = CFAPI_DOUBLE;
1886  break;
1887 
1889  rarch = va_arg(args, archetype **);
1890  *rarch = op->arch;
1891  *type = CFAPI_PARCH;
1892  break;
1893 
1895  rarch = va_arg(args, archetype **);
1896  *rarch = op->other_arch;
1897  *type = CFAPI_PARCH;
1898  break;
1899 
1901  rsstring = va_arg(args, sstring *);
1902  *rsstring = op->custom_name;
1903  *type = CFAPI_SSTRING;
1904  break;
1905 
1907  rint = va_arg(args, int *);
1908  *rint = op->anim_speed;
1909  *type = CFAPI_INT;
1910  break;
1911 
1913  rint = va_arg(args, int *);
1914  *rint = is_friendly(op);
1915  *type = CFAPI_INT;
1916  break;
1917 
1919  rbuffer = va_arg(args, char *);
1920  rbufsize = va_arg(args, int);
1921  query_short_name(op, rbuffer, rbufsize);
1922  *type = CFAPI_STRING;
1923  break;
1924 
1926  int i;
1927 
1928  i = va_arg(args, int);
1929  rbuffer = va_arg(args, char *);
1930  rbufsize = va_arg(args, int);
1931  query_base_name(op, i, rbuffer, rbufsize);
1932  *type = CFAPI_STRING;
1933  }
1934  break;
1935 
1937  rsstring = va_arg(args, sstring *);
1938  *rsstring = op->name;
1939  *type = CFAPI_SSTRING;
1940  break;
1941 
1943  rint = va_arg(args, int *);
1944  *rint = is_magical(op);
1945  *type = CFAPI_INT;
1946  break;
1947 
1949  rint = va_arg(args, int *);
1950  *rint = op->stats.luck;
1951  *type = CFAPI_INT;
1952  break;
1953 
1954  case CFAPI_OBJECT_PROP_EXP:
1955  rint64 = va_arg(args, int64_t *);
1956  *rint64 = op->stats.exp;
1957  *type = CFAPI_SINT64;
1958  break;
1959 
1961  robject = va_arg(args, object **);
1962  *robject = object_get_owner(op);
1963  *type = CFAPI_POBJECT;
1964  break;
1965 
1967  int stype;
1968 
1969  stype = va_arg(args, int);
1970  switch (stype) {
1971  unsigned char ptype;
1972  char *buf;
1973  archetype *at;
1974 
1975  case 0: /* present_in_ob */
1976  ptype = (unsigned char)(va_arg(args, int));
1977  robject = va_arg(args, object **);
1978  *robject = object_present_in_ob(ptype, op);
1979  break;
1980 
1981  case 1: /* present_in_ob_by_name */
1982  ptype = (unsigned char)(va_arg(args, int));
1983  buf = va_arg(args, char *);
1984  robject = va_arg(args, object **);
1985  *robject = object_present_in_ob_by_name(ptype, buf, op);
1986  break;
1987 
1988  case 2: /* arch_present_in_ob */
1989  at = va_arg(args, archetype *);
1990  robject = va_arg(args, object **);
1991  *robject = arch_present_in_ob(at, op);
1992  break;
1993  }
1994  }
1995  *type = CFAPI_POBJECT;
1996  break;
1997 
1999  rint = va_arg(args, int *);
2000  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2001  *type = CFAPI_INT;
2002  break;
2003 
2005  object *op2;
2006 
2007  op2 = va_arg(args, object *);
2008  rint = va_arg(args, int *);
2009  *rint = object_can_merge(op, op2);
2010  }
2011  *type = CFAPI_INT;
2012  break;
2013 
2015  object *op2;
2016 
2017  op2 = va_arg(args, object *);
2018  rint = va_arg(args, int *);
2019  *rint = object_can_pick(op2, op);
2020  }
2021  *type = CFAPI_INT;
2022  break;
2023 
2024  case CFAPI_OBJECT_PROP_FLAGS: {
2025  int fl;
2026 
2027  fl = va_arg(args, int);
2028  rint = va_arg(args, int *);
2029  *rint = QUERY_FLAG(op, fl);
2030  }
2031  *type = CFAPI_INT;
2032  break;
2033 
2034  case CFAPI_OBJECT_PROP_STR:
2035  rint = va_arg(args, int *);
2036  *rint = op->stats.Str;
2037  *type = CFAPI_INT;
2038  break;
2039 
2040  case CFAPI_OBJECT_PROP_DEX:
2041  rint = va_arg(args, int *);
2042  *rint = op->stats.Dex;
2043  *type = CFAPI_INT;
2044  break;
2045 
2046  case CFAPI_OBJECT_PROP_CON:
2047  rint = va_arg(args, int *);
2048  *rint = op->stats.Con;
2049  *type = CFAPI_INT;
2050  break;
2051 
2052  case CFAPI_OBJECT_PROP_WIS:
2053  rint = va_arg(args, int *);
2054  *rint = op->stats.Wis;
2055  *type = CFAPI_INT;
2056  break;
2057 
2058  case CFAPI_OBJECT_PROP_INT:
2059  rint = va_arg(args, int *);
2060  *rint = op->stats.Int;
2061  *type = CFAPI_INT;
2062  break;
2063 
2064  case CFAPI_OBJECT_PROP_POW:
2065  rint = va_arg(args, int *);
2066  *rint = op->stats.Pow;
2067  *type = CFAPI_INT;
2068  break;
2069 
2070  case CFAPI_OBJECT_PROP_CHA:
2071  rint = va_arg(args, int *);
2072  *rint = op->stats.Cha;
2073  *type = CFAPI_INT;
2074  break;
2075 
2076  case CFAPI_OBJECT_PROP_WC:
2077  rint = va_arg(args, int *);
2078  *rint = op->stats.wc;
2079  *type = CFAPI_INT;
2080  break;
2081 
2082  case CFAPI_OBJECT_PROP_AC:
2083  rint = va_arg(args, int *);
2084  *rint = op->stats.ac;
2085  *type = CFAPI_INT;
2086  break;
2087 
2088  case CFAPI_OBJECT_PROP_HP:
2089  rint = va_arg(args, int *);
2090  *rint = op->stats.hp;
2091  *type = CFAPI_INT;
2092  break;
2093 
2094  case CFAPI_OBJECT_PROP_SP:
2095  rint = va_arg(args, int *);
2096  *rint = op->stats.sp;
2097  *type = CFAPI_INT;
2098  break;
2099 
2100  case CFAPI_OBJECT_PROP_GP:
2101  rint = va_arg(args, int *);
2102  *rint = op->stats.grace;
2103  *type = CFAPI_INT;
2104  break;
2105 
2106  case CFAPI_OBJECT_PROP_FP:
2107  rint = va_arg(args, int *);
2108  *rint = op->stats.food;
2109  *type = CFAPI_INT;
2110  break;
2111 
2113  rint = va_arg(args, int *);
2114  *rint = op->stats.maxhp;
2115  *type = CFAPI_INT;
2116  break;
2117 
2119  rint = va_arg(args, int *);
2120  *rint = op->stats.maxsp;
2121  *type = CFAPI_INT;
2122  break;
2123 
2125  rint = va_arg(args, int *);
2126  *rint = op->stats.maxgrace;
2127  *type = CFAPI_INT;
2128  break;
2129 
2130  case CFAPI_OBJECT_PROP_DAM:
2131  rint = va_arg(args, int *);
2132  *rint = op->stats.dam;
2133  *type = CFAPI_INT;
2134  break;
2135 
2136  case CFAPI_OBJECT_PROP_GOD:
2137  rsstring = va_arg(args, sstring *);
2138  *rsstring = determine_god(op);
2139  *type = CFAPI_SSTRING;
2140  break;
2141 
2143  rsstring = va_arg(args, sstring *);
2144  *rsstring = op->arch->name;
2145  *type = CFAPI_SSTRING;
2146  break;
2147 
2149  rint = va_arg(args, int *);
2150  *rint = op->invisible;
2151  *type = CFAPI_INT;
2152  break;
2153 
2155  rbuffer = va_arg(args, char *);
2156  rbufsize = va_arg(args, int);
2157  if (rbufsize > 0) {
2158  strncpy(rbuffer, op->face->name, rbufsize);
2159  rbuffer[rbufsize - 1] = '\0';
2160  }
2161  *type = CFAPI_STRING;
2162  break;
2163 
2165  rbuffer = va_arg(args, char *);
2166  rbufsize = va_arg(args, int);
2167  if (rbufsize > 0) {
2168  if (op->animation != NULL) {
2169  strncpy(rbuffer, op->animation->name, rbufsize);
2170  rbuffer[rbufsize - 1] = '\0';
2171  }
2172  else
2173  rbuffer[0] = '\0';
2174  }
2175  *type = CFAPI_STRING;
2176  break;
2177 
2178  case CFAPI_PLAYER_PROP_IP:
2179  rsstring = va_arg(args, sstring *);
2180  *rsstring = op->contr->socket.host;
2181  *type = CFAPI_SSTRING;
2182  break;
2183 
2185  robject = va_arg(args, object **);
2186  *robject = find_marked_object(op);
2187  *type = CFAPI_POBJECT;
2188  break;
2189 
2191  rparty = va_arg(args, partylist **);
2192  *rparty = (op->contr ? op->contr->party : NULL);
2193  *type = CFAPI_PPARTY;
2194  break;
2195 
2197  robject = va_arg(args, object **);
2198  if (op)
2199  *robject = op->contr->next ? op->contr->next->ob : NULL;
2200  else
2201  /* This can be called when there is no player. */
2202  *robject = first_player ? first_player->ob : NULL;
2203  *type = CFAPI_POBJECT;
2204  break;
2205 
2207  rbuffer = va_arg(args, char *);
2208  rbufsize = va_arg(args, int);
2209  player_get_title(op->contr, rbuffer, rbufsize);
2210  *type = CFAPI_STRING;
2211  break;
2212 
2214  robject = va_arg(args, object **);
2215  *robject = op->contr->transport;
2216  *type = CFAPI_POBJECT;
2217  break;
2218 
2220  rmove = va_arg(args, MoveType *);
2221  *rmove = op->move_type;
2222  *type = CFAPI_MOVETYPE;
2223  break;
2224 
2226  rmove = va_arg(args, MoveType *);
2227  *rmove = op->move_block;
2228  *type = CFAPI_MOVETYPE;
2229  break;
2230 
2232  rmove = va_arg(args, MoveType *);
2233  *rmove = op->move_allow;
2234  *type = CFAPI_MOVETYPE;
2235  break;
2236 
2238  rmove = va_arg(args, MoveType *);
2239  *rmove = op->move_on;
2240  *type = CFAPI_MOVETYPE;
2241  break;
2242 
2244  rmove = va_arg(args, MoveType *);
2245  *rmove = op->move_off;
2246  *type = CFAPI_MOVETYPE;
2247  break;
2248 
2250  rmove = va_arg(args, MoveType *);
2251  *rmove = op->move_type;
2252  *type = CFAPI_MOVETYPE;
2253  break;
2254 
2256  rfloat = va_arg(args, float *);
2257  *rfloat = op->move_slow_penalty;
2258  *type = CFAPI_FLOAT;
2259  break;
2260 
2262  rbuffer = va_arg(args, char *);
2263  rbufsize = va_arg(args, int);
2264  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2265  *type = CFAPI_STRING;
2266  break;
2267 
2269  rint = va_arg(args, int *);
2270  *rint = op->contr->bed_x;
2271  *type = CFAPI_INT;
2272  break;
2273 
2275  rint = va_arg(args, int *);
2276  *rint = op->contr->bed_y;
2277  *type = CFAPI_INT;
2278  break;
2279 
2281  rint = va_arg(args, int *);
2282  *rint = op->duration;
2283  *type = CFAPI_INT;
2284  break;
2285 
2286  default:
2287  *type = CFAPI_NONE;
2288  break;
2289  }
2290  va_end(args);
2291 }
2292 
2301 static void copy_message(object *op, const char *msg) {
2302  /* need to reset parsed dialog information */
2304  if (strlen(msg) == 0) {
2305  msg = NULL;
2306  }
2307  object_set_msg(op, msg);
2308 }
2309 
2318 static void cfapi_object_set_property(int *type, ...) {
2319  va_list args;
2320  int iarg, *ret;
2321  long larg;
2322  char *sarg;
2323  double darg;
2324  object *oparg;
2325  object *op;
2326  int property;
2327  int64_t s64arg;
2328  partylist *partyarg;
2329  float farg;
2330  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2331 
2332  va_start(args, type);
2333  op = va_arg(args, object *);
2334  property = va_arg(args, int);
2335  *type = CFAPI_NONE;
2336 
2337  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2338  switch (property) {
2340  sarg = va_arg(args, char *);
2341  *type = CFAPI_STRING;
2342  FREE_AND_COPY(op->name, sarg);
2344  break;
2345 
2347  sarg = va_arg(args, char *);
2348  *type = CFAPI_STRING;
2349  FREE_AND_COPY(op->name_pl, sarg);
2351  break;
2352 
2354  sarg = va_arg(args, char *);
2355  *type = CFAPI_STRING;
2356  FREE_AND_COPY(op->title, sarg);
2357  break;
2358 
2360  sarg = va_arg(args, char *);
2361  *type = CFAPI_STRING;
2362  FREE_AND_COPY(op->race, sarg);
2363  break;
2364 
2366  sarg = va_arg(args, char *);
2367  *type = CFAPI_STRING;
2368  FREE_AND_COPY(op->slaying, sarg);
2369  break;
2370 
2372  sarg = va_arg(args, char *);
2373  *type = CFAPI_STRING;
2374  FREE_AND_COPY(op->skill, sarg);
2375  break;
2376 
2378  sarg = va_arg(args, char *);
2379  *type = CFAPI_STRING;
2380  copy_message(op, sarg);
2381  break;
2382 
2384  sarg = va_arg(args, char *);
2385  *type = CFAPI_STRING;
2386  FREE_AND_COPY(op->lore, sarg);
2387  break;
2388 
2390  farg = va_arg(args, double);
2391  *type = CFAPI_FLOAT;
2392  if (farg != op->speed) {
2393  op->speed = farg;
2395  }
2396  break;
2397 
2399  farg = va_arg(args, double);
2400  *type = CFAPI_FLOAT;
2401  op->speed_left = farg;
2402  break;
2403 
2405  iarg = va_arg(args, int);
2406  *type = CFAPI_INT;
2407  if (iarg < 0)
2408  iarg = 0;
2409  if (op->nrof > (uint32_t)iarg)
2410  object_decrease_nrof(op, op->nrof-iarg);
2411  else if (op->nrof < (uint32_t)iarg) {
2412  object *tmp;
2413  player *pl;
2414 
2415  op->nrof = iarg;
2416  if (op->env != NULL) {
2418  if (!tmp) {
2419  for (pl = first_player; pl; pl = pl->next)
2420  if (pl->ob->container == op->env)
2421  break;
2422  if (pl)
2423  tmp = pl->ob;
2424  else
2425  tmp = NULL;
2426  } else {
2428  fix_object(tmp);
2429  }
2430  if (tmp)
2432  } else {
2434  if (tmp->type == PLAYER)
2435  tmp->contr->socket.update_look = 1;
2436  FOR_ABOVE_FINISH();
2437  }
2438  }
2439  break;
2440 
2442  iarg = va_arg(args, int);
2443  *type = CFAPI_INT;
2444  op->direction = iarg;
2445  break;
2446 
2448  iarg = va_arg(args, int);
2449  *type = CFAPI_INT;
2450  op->facing = iarg;
2451  break;
2452 
2453  case CFAPI_OBJECT_PROP_RESIST: {
2454  int iargbis = va_arg(args, int);
2455 
2456  *type = CFAPI_INT16;
2457  iarg = va_arg(args, int);
2458  op->resist[iargbis] = iarg;
2459  }
2460  break;
2461 
2463  iarg = va_arg(args, int);
2464  *type = CFAPI_INT;
2465  op->attacktype = iarg;
2466  break;
2467 
2469  iarg = va_arg(args, int);
2470  *type = CFAPI_INT;
2471  op->path_attuned = iarg;
2472  break;
2473 
2475  iarg = va_arg(args, int);
2476  *type = CFAPI_INT;
2477  op->path_repelled = iarg;
2478  break;
2479 
2481  iarg = va_arg(args, int);
2482  *type = CFAPI_INT;
2483  op->path_denied = iarg;
2484  break;
2485 
2487  iarg = va_arg(args, int);
2488  *type = CFAPI_INT;
2489  op->material = iarg;
2490  break;
2491 
2493  break;
2494 
2496  iarg = va_arg(args, int);
2497  *type = CFAPI_INT;
2498  op->magic = iarg;
2499  break;
2500 
2502  larg = va_arg(args, long);
2503  *type = CFAPI_LONG;
2504  op->value = larg;
2505  break;
2506 
2508  iarg = va_arg(args, int);
2509  *type = CFAPI_INT;
2510  op->level = iarg;
2512  break;
2513 
2515  iarg = va_arg(args, int);
2516  *type = CFAPI_INT;
2517  op->last_heal = iarg;
2518  break;
2519 
2521  iarg = va_arg(args, int);
2522  *type = CFAPI_INT;
2523  op->last_sp = iarg;
2524  break;
2525 
2527  iarg = va_arg(args, int);
2528  *type = CFAPI_INT;
2529  op->last_grace = iarg;
2530  break;
2531 
2533  iarg = va_arg(args, int);
2534  *type = CFAPI_INT;
2535  op->last_eat = iarg;
2536  break;
2537 
2539  iarg = va_arg(args, int);
2540  *type = CFAPI_INT;
2541  op->invisible = iarg;
2542  break;
2543 
2545  iarg = va_arg(args, int);
2546  *type = CFAPI_INT;
2547  op->pick_up = iarg;
2548  break;
2549 
2551  iarg = va_arg(args, int);
2552  *type = CFAPI_INT;
2553  op->item_power = iarg;
2554  break;
2555 
2557  iarg = va_arg(args, int);
2558  *type = CFAPI_INT;
2559  op->gen_sp_armour = iarg;
2560  break;
2561 
2563  iarg = va_arg(args, int);
2564  *type = CFAPI_INT;
2565  if (op->weight != iarg) {
2566  object *tmp;
2567  player *pl;
2568 
2569  op->weight = iarg;
2570  if (op->env != NULL) {
2572  if (!tmp) {
2573  for (pl = first_player; pl; pl = pl->next)
2574  if (pl->ob->container == op->env)
2575  break;
2576  if (pl)
2577  tmp = pl->ob;
2578  else
2579  tmp = NULL;
2580  } else {
2582  fix_object(tmp);
2583  }
2584  if (tmp)
2586  } else {
2588  if (tmp->type == PLAYER)
2590  FOR_ABOVE_FINISH();
2591  }
2592  }
2593  break;
2594 
2596  iarg = va_arg(args, int);
2597  *type = CFAPI_INT;
2598  op->weight_limit = iarg;
2599  break;
2600 
2602  iarg = va_arg(args, int);
2603  *type = CFAPI_INT;
2604  if (op->glow_radius != iarg) {
2605  object *tmp;
2606 
2607  op->glow_radius = iarg;
2609  if (tmp->map != NULL) {
2610  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2611  update_position(tmp->map, tmp->x, tmp->y);
2612  update_all_los(tmp->map, tmp->x, tmp->y);
2613  }
2614  }
2615  break;
2616 
2618  s64arg = va_arg(args, int64_t);
2619  *type = CFAPI_SINT64;
2620  op->total_exp = s64arg;
2621  break;
2622 
2624  oparg = va_arg(args, object *);
2625  *type = CFAPI_POBJECT;
2626  object_set_enemy(op, oparg);
2627  break;
2628 
2630  iarg = va_arg(args, int);
2631  *type = CFAPI_INT;
2632  op->run_away = iarg;
2633  break;
2634 
2636  oparg = va_arg(args, object *);
2637  *type = CFAPI_POBJECT;
2638  op->chosen_skill = oparg;
2639  break;
2640 
2642  iarg = va_arg(args, int);
2643  *type = CFAPI_INT;
2644  op->hide = iarg;
2645  break;
2646 
2648  iarg = va_arg(args, int);
2649  *type = CFAPI_INT;
2650  op->move_status = iarg;
2651  break;
2652 
2654  iarg = va_arg(args, int);
2655  *type = CFAPI_INT;
2656  op->attack_movement = iarg;
2657  break;
2658 
2660  oparg = va_arg(args, object *);
2661  *type = CFAPI_POBJECT;
2662  op->spellitem = oparg;
2663  break;
2664 
2666  darg = va_arg(args, double);
2667  *type = CFAPI_DOUBLE;
2668  op->expmul = darg;
2669  break;
2670 
2672  sarg = va_arg(args, char *);
2673  *type = CFAPI_STRING;
2674  FREE_AND_COPY(op->custom_name, sarg);
2676  break;
2677 
2679  iarg = va_arg(args, int);
2680  *type = CFAPI_INT;
2681  op->anim_speed = iarg;
2682  break;
2683 
2685  iarg = va_arg(args, int);
2686  *type = CFAPI_INT;
2687  if (iarg == 1 && is_friendly(op) == 0)
2689  else if (iarg == 0 && is_friendly(op) == 1)
2691  break;
2692 
2694  iarg = va_arg(args, int);
2695  *type = CFAPI_INT;
2696  op->stats.luck = iarg;
2697  break;
2698 
2699  case CFAPI_OBJECT_PROP_EXP:
2700  s64arg = va_arg(args, int64_t);
2701  *type = CFAPI_SINT64;
2702  op->stats.exp = s64arg;
2703  break;
2704 
2706  oparg = va_arg(args, object *);
2707  *type = CFAPI_POBJECT;
2708  object_set_owner(op, oparg);
2709  break;
2710 
2713  *type = CFAPI_NONE;
2714  break;
2715 
2716  case CFAPI_OBJECT_PROP_FLAGS: {
2717  int iargbis;
2718 
2719  iarg = va_arg(args, int);
2720  iargbis = va_arg(args, int);
2721  *type = CFAPI_INT;
2722 
2723  if (iargbis == 1)
2724  SET_FLAG(op, iarg);
2725  else
2726  CLEAR_FLAG(op, iarg);
2727  }
2728  break;
2729 
2730  case CFAPI_OBJECT_PROP_STR:
2731  iarg = va_arg(args, int);
2732  *type = CFAPI_INT;
2733  op->stats.Str = iarg;
2734  break;
2735 
2736  case CFAPI_OBJECT_PROP_DEX:
2737  iarg = va_arg(args, int);
2738  *type = CFAPI_INT;
2739  op->stats.Dex = iarg;
2740  break;
2741 
2742  case CFAPI_OBJECT_PROP_CON:
2743  iarg = va_arg(args, int);
2744  *type = CFAPI_INT;
2745  op->stats.Con = iarg;
2746  break;
2747 
2748  case CFAPI_OBJECT_PROP_WIS:
2749  iarg = va_arg(args, int);
2750  *type = CFAPI_INT;
2751  op->stats.Wis = iarg;
2752  break;
2753 
2754  case CFAPI_OBJECT_PROP_INT:
2755  iarg = va_arg(args, int);
2756  *type = CFAPI_INT;
2757  op->stats.Int = iarg;
2758  break;
2759 
2760  case CFAPI_OBJECT_PROP_POW:
2761  iarg = va_arg(args, int);
2762  *type = CFAPI_INT;
2763  op->stats.Pow = iarg;
2764  break;
2765 
2766  case CFAPI_OBJECT_PROP_CHA:
2767  iarg = va_arg(args, int);
2768  *type = CFAPI_INT;
2769  op->stats.Cha = iarg;
2770  break;
2771 
2772  case CFAPI_OBJECT_PROP_WC:
2773  iarg = va_arg(args, int);
2774  *type = CFAPI_INT;
2775  op->stats.wc = iarg;
2776  break;
2777 
2778  case CFAPI_OBJECT_PROP_AC:
2779  iarg = va_arg(args, int);
2780  *type = CFAPI_INT;
2781  op->stats.ac = iarg;
2782  break;
2783 
2784  case CFAPI_OBJECT_PROP_HP:
2785  iarg = va_arg(args, int);
2786  *type = CFAPI_INT;
2787  op->stats.hp = iarg;
2788  break;
2789 
2790  case CFAPI_OBJECT_PROP_SP:
2791  iarg = va_arg(args, int);
2792  *type = CFAPI_INT;
2793  op->stats.sp = iarg;
2794  break;
2795 
2796  case CFAPI_OBJECT_PROP_GP:
2797  iarg = va_arg(args, int);
2798  *type = CFAPI_INT;
2799  op->stats.grace = iarg;
2800  break;
2801 
2802  case CFAPI_OBJECT_PROP_FP:
2803  iarg = va_arg(args, int);
2804  *type = CFAPI_INT;
2805  op->stats.food = iarg;
2806  break;
2807 
2809  iarg = va_arg(args, int);
2810  *type = CFAPI_INT;
2811  op->stats.maxhp = iarg;
2812  break;
2813 
2815  iarg = va_arg(args, int);
2816  *type = CFAPI_INT;
2817  op->stats.maxsp = iarg;
2818  break;
2819 
2821  iarg = va_arg(args, int);
2822  *type = CFAPI_INT;
2823  op->stats.maxgrace = iarg;
2824  break;
2825 
2826  case CFAPI_OBJECT_PROP_DAM:
2827  iarg = va_arg(args, int);
2828  *type = CFAPI_INT;
2829  op->stats.dam = iarg;
2830  break;
2831 
2832  case CFAPI_OBJECT_PROP_FACE: {
2833  const Face *face;
2834  sarg = va_arg(args, char *);
2835  ret = va_arg(args, int *);
2836  *type = CFAPI_INT;
2837  face = try_find_face(sarg, 0);
2838  if (face != NULL) {
2839  op->face = face;
2840  op->state = 0;
2841  object_update(op, UP_OBJ_FACE);
2842  (*ret) = face->number;
2843  } else
2844  (*ret) = 0;
2845  break;
2846  }
2847 
2849  const Animations *anim;
2850  sarg = va_arg(args, char *);
2851  ret = va_arg(args, int *);
2852  *type = CFAPI_INT;
2853  anim = try_find_animation(sarg);
2854  if (anim != NULL) {
2855  op->animation = anim;
2856  SET_ANIMATION(op, 0);
2857  object_update(op, UP_OBJ_FACE);
2858  (*ret) = anim->num;
2859  } else {
2860  (*ret) = 0;
2861  }
2862  break;
2863  }
2864 
2866  iarg = va_arg(args, int);
2867  *type = CFAPI_INT;
2868  op->duration = iarg;
2869  break;
2870 
2872  if (op->contr) {
2873  oparg = va_arg(args, object *);
2874  *type = CFAPI_POBJECT;
2875  op->contr->mark = oparg;
2876  if (oparg) {
2877  op->contr->mark_count = oparg->count;
2878  } else {
2879  op->contr->mark_count = 0;
2880  }
2881  }
2882  break;
2883 
2885  if (op->contr) {
2886  partyarg = va_arg(args, partylist *);
2887  *type = CFAPI_PPARTY;
2888  party_join(op, partyarg);
2889  }
2890  break;
2891 
2893  sarg = va_arg(args, char *);
2894  *type = CFAPI_STRING;
2895  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
2896  break;
2897 
2899  iarg = va_arg(args, int);
2900  *type = CFAPI_INT;
2901  op->contr->bed_x = iarg;
2902  break;
2903 
2905  iarg = va_arg(args, int);
2906  *type = CFAPI_INT;
2907  op->contr->bed_y = iarg;
2908  break;
2909 
2911  sarg = va_arg(args, char *);
2912  *type = CFAPI_STRING;
2913  player_set_own_title(op->contr, sarg);
2914  break;
2915 
2917  move = va_arg(args, MoveType *);
2918  op->move_type = *move & MOVE_ALL;
2919  object_update(op, UP_OBJ_INSERT);
2920  *type = CFAPI_MOVETYPE;
2921  break;
2922 
2924  move = va_arg(args, MoveType *);
2925  op->move_block = *move & MOVE_ALL;
2926  object_update(op, UP_OBJ_INSERT);
2927  *type = CFAPI_MOVETYPE;
2928  break;
2929 
2931  move = va_arg(args, MoveType *);
2932  op->move_allow = *move & MOVE_ALL;
2933  object_update(op, UP_OBJ_INSERT);
2934  *type = CFAPI_MOVETYPE;
2935  break;
2936 
2938  move = va_arg(args, MoveType *);
2939  op->move_on = *move & MOVE_ALL;
2940  object_update(op, UP_OBJ_INSERT);
2941  *type = CFAPI_MOVETYPE;
2942  break;
2943 
2945  move = va_arg(args, MoveType *);
2946  op->move_off = *move & MOVE_ALL;
2947  object_update(op, UP_OBJ_INSERT);
2948  *type = CFAPI_MOVETYPE;
2949  break;
2950 
2952  move = va_arg(args, MoveType *);
2953  op->move_type = *move & MOVE_ALL;
2954  object_update(op, UP_OBJ_INSERT);
2955  *type = CFAPI_MOVETYPE;
2956  break;
2957 
2958  default:
2959  break;
2960  }
2961  }
2962  va_end(args);
2963 }
2964 
2971 static void cfapi_object_apply_below(int *type, ...) {
2972  va_list args;
2973  object *applier;
2974 
2975  va_start(args, type);
2976 
2977  applier = va_arg(args, object *);
2978 
2979  va_end(args);
2980 
2981  apply_by_living_below(applier);
2982  *type = CFAPI_NONE;
2983 }
2984 
2991 static void cfapi_object_apply(int *type, ...) {
2992  va_list args;
2993  object *applied;
2994  object *applier;
2995  int aflags;
2996  int *ret;
2997 
2998  va_start(args, type);
2999 
3000  applier = va_arg(args, object *);
3001  applied = va_arg(args, object *);
3002  aflags = va_arg(args, int);
3003  ret = va_arg(args, int *);
3004 
3005  va_end(args);
3006 
3007  *type = CFAPI_INT;
3008  *ret = apply_manual(applier, applied, aflags);
3009 }
3010 
3016 static void cfapi_object_identify(int *type, ...) {
3017  va_list args;
3018  object *op, **result;
3019 
3020  va_start(args, type);
3021 
3022  op = va_arg(args, object *);
3023  result = va_arg(args, object **);
3024 
3025  va_end(args);
3026 
3027  (*result) = identify(op);
3028  *type = CFAPI_POBJECT;
3029 }
3030 
3036 static void cfapi_object_describe(int *type, ...) {
3037  va_list args;
3038  object *op;
3039  object *owner;
3040  char *desc, *final;
3041  int size;
3042 
3043  va_start(args, type);
3044 
3045  op = va_arg(args, object *);
3046  owner = va_arg(args, object *);
3047  desc = va_arg(args, char *);
3048  size = va_arg(args, int);
3049  va_end(args);
3050 
3051  *type = CFAPI_STRING;
3052  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3053  strncpy(desc, final, size);
3054  desc[size - 1] = '\0';
3055  free(final);
3056 }
3057 
3058 static void cfapi_object_drain(int *type, ...) {
3059  va_list args;
3060 
3061  object *op;
3062  int ds;
3063 
3064  va_start(args, type);
3065 
3066  op = va_arg(args, object *);
3067  ds = va_arg(args, int);
3068 
3069  va_end(args);
3070 
3071  drain_specific_stat(op, ds);
3072 
3073  *type = CFAPI_NONE;
3074 }
3075 
3076 static void cfapi_object_remove_depletion(int *type, ...) {
3077  va_list args;
3078 
3079  object *op;
3080  int level, *result;
3081 
3082  va_start(args, type);
3083 
3084  op = va_arg(args, object *);
3085  level = va_arg(args, int);
3086  result = va_arg(args, int*);
3087 
3088  va_end(args);
3089 
3090  *result = remove_depletion(op, level);
3091 
3092  *type = CFAPI_INT;
3093 }
3094 
3095 static void cfapi_object_fix(int *type, ...) {
3096  va_list args;
3097  object *op;
3098 
3099  va_start(args, type);
3100 
3101  op = va_arg(args, object *);
3102 
3103  va_end(args);
3104 
3105  fix_object(op);
3106 
3107  *type = CFAPI_NONE;
3108 }
3109 
3111 static void cfapi_object_give_skill(int *type, ...) {
3112  va_list args;
3113 
3114  object *op;
3115  char *skillname;
3116 
3117  va_start(args, type);
3118 
3119  op = va_arg(args, object *);
3120  skillname = va_arg(args, char *);
3121 
3122  va_end(args);
3123 
3124  *type = CFAPI_POBJECT;
3125  give_skill_by_name(op, skillname);
3126 }
3127 
3128 static void cfapi_object_transmute(int *type, ...) {
3129  va_list args;
3130 
3131  object *op;
3132  object *chg;
3133 
3134  va_start(args, type);
3135 
3136  op = va_arg(args, object *);
3137  chg = va_arg(args, object *);
3138 
3139  va_end(args);
3140 
3141  transmute_materialname(op, chg);
3142  *type = CFAPI_NONE;
3143 }
3144 
3145 static void cfapi_object_remove(int *type, ...) {
3146  va_list args;
3147  object *op;
3148 
3149  va_start(args, type);
3150 
3151  op = va_arg(args, object *);
3152 
3153  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3154  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3155  va_end(args);
3156  *type = CFAPI_NONE;
3157  return;
3158  }
3159 
3160  va_end(args);
3161 
3162  object_remove(op);
3163  *type = CFAPI_NONE;
3164 }
3165 
3166 static void cfapi_object_delete(int *type, ...) {
3167  va_list args;
3168  object *op;
3169 
3170  va_start(args, type);
3171 
3172  op = va_arg(args, object *);
3173 
3175  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3176  *type = CFAPI_NONE;
3177  va_end(args);
3178  return;
3179  }
3180 
3181  va_end(args);
3182 
3184 
3185  *type = CFAPI_NONE;
3186 }
3187 
3193 static void cfapi_object_clone(int *type, ...) {
3194  va_list args;
3195  object *op;
3196  int kind;
3197  object **robj;
3198 
3199  va_start(args, type);
3200 
3201  op = va_arg(args, object *);
3202  kind = va_arg(args, int);
3203  robj = va_arg(args, object **);
3204 
3205  va_end(args);
3206 
3207  if (kind == 0) {
3208  *type = CFAPI_POBJECT;
3209  *robj = object_create_clone(op);
3210  } else {
3211  object *tmp;
3212  tmp = object_new();
3213  object_copy(op, tmp);
3214  *type = CFAPI_POBJECT;
3215  *robj = tmp;
3216  }
3217  return;
3218 }
3219 
3225 static void cfapi_object_create(int *type, ...) {
3226  va_list args;
3227  int ival;
3228  object **robj;
3229  va_start(args, type);
3230  ival = va_arg(args, int);
3231 
3232  *type = CFAPI_POBJECT;
3233  switch (ival) {
3234  case 0:
3235  robj = va_arg(args, object **);
3236  *robj = object_new();
3237  break;
3238 
3239  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3240  const char *sval;
3241  archetype *at;
3242 
3243  sval = va_arg(args, const char *);
3244  robj = va_arg(args, object **);
3245  va_end(args);
3246 
3247  at = try_find_archetype(sval);
3248  if (!at)
3249  at = find_archetype_by_object_name(sval);
3250  if (at) {
3251  *robj = object_create_arch(at);
3252  } else
3253  *robj = NULL;
3254  }
3255  break;
3256 
3257  default:
3258  *type = CFAPI_NONE;
3259  break;
3260  }
3261  va_end(args);
3262 }
3263 
3264 static void cfapi_object_insert(int *type, ...) {
3265  va_list args;
3266  object *op;
3267  object *orig;
3268  mapstruct *map;
3269  int flag, x, y;
3270  int itype;
3271  object **robj;
3272 
3273  va_start(args, type);
3274 
3275  op = va_arg(args, object *);
3276  if (!op) {
3277  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3278  va_end(args);
3279  return;
3280  }
3281  if (QUERY_FLAG(op, FLAG_FREED)) {
3282  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3283  va_end(args);
3284  return;
3285  }
3286  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3287  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3288  object_remove(op);
3289  }
3290  itype = va_arg(args, int);
3291 
3292  switch (itype) {
3293  case 0:
3294  map = va_arg(args, mapstruct *);
3295  orig = va_arg(args, object *);
3296  flag = va_arg(args, int);
3297  x = va_arg(args, int);
3298  y = va_arg(args, int);
3299  robj = va_arg(args, object **);
3300  if (!map) {
3301  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3302  object_free(op, FREE_OBJ_NO_DESTROY_CALLBACK);
3303  *robj = NULL;
3304  } else
3305  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3306  *type = CFAPI_POBJECT;
3307  break;
3308 
3309  case 1:
3310  map = va_arg(args, mapstruct *);
3311  orig = va_arg(args, object *);
3312  flag = va_arg(args, int);
3313  robj = va_arg(args, object **);
3314  if (!map) {
3315  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3316  object_free(op, FREE_OBJ_NO_DESTROY_CALLBACK);
3317  *robj = NULL;
3318  } else
3319  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3320  *type = CFAPI_POBJECT;
3321  break;
3322 
3323  case 2:
3324  map = va_arg(args, mapstruct *);
3325  orig = va_arg(args, object *);
3326  flag = va_arg(args, int);
3327  x = va_arg(args, int);
3328  y = va_arg(args, int);
3329  robj = va_arg(args, object **);
3330  if (!map) {
3331  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3332  object_free(op, FREE_OBJ_NO_DESTROY_CALLBACK);
3333  *robj = NULL;
3334  } else {
3335  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3336  if (dir != -1) {
3337  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3338  } else {
3340  *robj = NULL;
3341  }
3342  }
3343  *type = CFAPI_POBJECT;
3344  break;
3345 
3346  case 3:
3347  orig = va_arg(args, object *);
3348  robj = va_arg(args, object **);
3349  if (!orig) {
3350  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3351  object_free(op, FREE_OBJ_NO_DESTROY_CALLBACK);
3352  *robj = NULL;
3353  } else
3354  *robj = object_insert_in_ob(op, orig);
3355  *type = CFAPI_POBJECT;
3356  break;
3357 
3358  default:
3359  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3360  object_free(op, FREE_OBJ_NO_DESTROY_CALLBACK);
3361  *type = CFAPI_NONE;
3362  break;
3363  }
3364 
3365  va_end(args);
3366 }
3372 static void cfapi_object_split(int *type, ...) {
3373  va_list args;
3374 
3375  int nr, size;
3376  object *op;
3377  char *buf;
3378  object **split;
3379 
3380  va_start(args, type);
3381 
3382  op = va_arg(args, object *);
3383  nr = va_arg(args, int);
3384  buf = va_arg(args, char *);
3385  size = va_arg(args, int);
3386  split = va_arg(args, object **);
3387  va_end(args);
3388 
3389  *split = object_split(op, nr, buf, size);
3390  if (*split != NULL)
3391  {
3392  *type = CFAPI_POBJECT;
3393  }
3394  else
3395  {
3396  *type = CFAPI_NONE;
3397  }
3398 }
3399 
3405 static void cfapi_object_merge(int *type, ...) {
3406  va_list args;
3407  object *op;
3408  object *op2;
3409  object **merge;
3410 
3411  va_start(args, type);
3412 
3413  op = va_arg(args, object *);
3414  op2 = va_arg(args, object *);
3415  merge = va_arg(args, object **);
3416 
3417  va_end(args);
3418 
3419  *type = CFAPI_POBJECT;
3420  *merge = object_merge(op, op2);
3421 }
3422 
3428 static void cfapi_object_distance(int *type, ...) {
3429  va_list args;
3430  object *op;
3431  object *op2;
3432  int *rint;
3433  va_start(args, type);
3434 
3435  op = va_arg(args, object *);
3436  op2 = va_arg(args, object *);
3437  rint = va_arg(args, int *);
3438 
3439  va_end(args);
3440 
3441  *type = CFAPI_INT;
3442  *rint = object_distance(op, op2);
3443 }
3449 static void cfapi_object_update(int *type, ...) {
3450  va_list args;
3451  int action;
3452  object *op;
3453  va_start(args, type);
3454 
3455  op = va_arg(args, object *);
3456  action = va_arg(args, int);
3457 
3458  va_end(args);
3459 
3461  *type = CFAPI_NONE;
3462 }
3463 
3469 static void cfapi_object_clear(int *type, ...) {
3470  va_list args;
3471  object *op;
3472  va_start(args, type);
3473 
3474  op = va_arg(args, object *);
3475 
3476  va_end(args);
3477 
3478  object_clear(op);
3479  *type = CFAPI_NONE;
3480 }
3481 
3487 static void cfapi_object_reset(int *type, ...) {
3488  va_list args;
3489  object *op;
3490 
3491  va_start(args, type);
3492 
3493  op = va_arg(args, object *);
3494 
3495  va_end(args);
3496 
3497  object_reset(op);
3498  *type = CFAPI_NONE;
3499 }
3500 
3501 static void cfapi_object_clean_object(int *type, ...) {
3502  va_list args;
3503  object *op;
3504 
3505  va_start(args, type);
3506  op = va_arg(args, object *);
3507  clean_object(op);
3508  va_end(args);
3509  *type = CFAPI_NONE;
3510 }
3511 
3512 static void cfapi_object_on_same_map(int *type, ...) {
3513  va_list args;
3514  object *op1;
3515  object *op2;
3516  int *rint;
3517 
3518  va_start(args, type);
3519  op1 = va_arg(args, object *);
3520  op2 = va_arg(args, object *);
3521  rint = va_arg(args, int *);
3522  va_end(args);
3523 
3524  *type = CFAPI_INT;
3525  *rint = on_same_map(op1, op2);
3526 }
3527 
3528 static void cfapi_object_spring_trap(int *type, ...) {
3529  object *trap;
3530  object *victim;
3531  va_list args;
3532 
3533  va_start(args, type);
3534  trap = va_arg(args, object *);
3535  victim = va_arg(args, object *);
3536  va_end(args);
3537 
3538  spring_trap(trap, victim);
3539  *type = CFAPI_NONE;
3540 }
3541 
3547 static void cfapi_object_check_trigger(int *type, ...) {
3548  object *op;
3549  object *cause;
3550  va_list args;
3551  int *rint;
3552 
3553  va_start(args, type);
3554  op = va_arg(args, object *);
3555  cause = va_arg(args, object *);
3556  rint = va_arg(args, int *);
3557  va_end(args);
3558 
3559  *rint = check_trigger(op, cause);
3560  *type = CFAPI_INT;
3561 }
3562 
3574 static void cfapi_map_trigger_connected(int *type, ...) {
3575  objectlink *ol;
3576  object *cause;
3577  int state;
3578  va_list args;
3579 
3580  va_start(args, type);
3581  ol = va_arg(args, objectlink *);
3582  cause = va_arg(args, object *);
3583  state = va_arg(args, int);
3584  va_end(args);
3585  trigger_connected(ol, cause, state);
3586  *type = CFAPI_NONE;
3587 }
3588 
3594 static void cfapi_object_query_money(int *type, ...) {
3595  object *op;
3596  va_list args;
3597  int *rint;
3598 
3599  va_start(args, type);
3600  op = va_arg(args, object *);
3601  rint = va_arg(args, int *);
3602  va_end(args);
3603 
3604  *rint = query_money(op);
3605  *type = CFAPI_INT;
3606 }
3607 
3613 static void cfapi_object_cast(int *type, ...) {
3614  object *op;
3615  object *sp;
3616  int dir;
3617  char *str;
3618  object *caster;
3619  va_list args;
3620  int *rint;
3621 
3622  va_start(args, type);
3623  op = va_arg(args, object *);
3624  caster = va_arg(args, object *);
3625  dir = va_arg(args, int);
3626  sp = va_arg(args, object *);
3627  str = va_arg(args, char *);
3628  rint = va_arg(args, int *);
3629  va_end(args);
3630 
3631  *type = CFAPI_INT;
3632 
3633  if (!op->map) {
3634  *rint = -1;
3635  return;
3636  }
3637 
3638  *rint = cast_spell(op, caster, dir, sp, str);
3639 }
3640 
3641 static void cfapi_object_learn_spell(int *type, ...) {
3642  object *op;
3643  object *sp;
3644  int prayer;
3645  va_list args;
3646 
3647  va_start(args, type);
3648  op = va_arg(args, object *);
3649  sp = va_arg(args, object *);
3650  prayer = va_arg(args, int);
3651  va_end(args);
3652  do_learn_spell(op, sp, prayer);
3653  *type = CFAPI_NONE;
3654 }
3655 
3656 static void cfapi_object_forget_spell(int *type, ...) {
3657  object *op;
3658  object *sp;
3659  va_list args;
3660  char name[MAX_BUF];
3661 
3662  va_start(args, type);
3663  op = va_arg(args, object *);
3664  sp = va_arg(args, object *);
3665  va_end(args);
3666  query_name(sp, name, MAX_BUF);
3668  *type = CFAPI_NONE;
3669 }
3670 
3676 static void cfapi_object_check_spell(int *type, ...) {
3677  object *op;
3678  char *spellname;
3679  va_list args;
3680  object **robj;
3681 
3682  va_start(args, type);
3683  op = va_arg(args, object *);
3684  spellname = va_arg(args, char *);
3685  robj = va_arg(args, object **);
3686  va_end(args);
3687  *robj = check_spell_known(op, spellname);
3688  *type = CFAPI_POBJECT;
3689 }
3690 
3696 static void cfapi_object_pay_amount(int *type, ...) {
3697  object *op;
3698  uint64_t amount;
3699  va_list args;
3700  int *rint;
3701 
3702  va_start(args, type);
3703  op = va_arg(args, object *);
3704  amount = va_arg(args, uint64_t);
3705  rint = va_arg(args, int *);
3706  va_end(args);
3707 
3708  *rint = pay_for_amount(amount, op);
3709  *type = CFAPI_INT;
3710 }
3711 
3717 static void cfapi_object_pay_item(int *type, ...) {
3718  object *op;
3719  object *tobuy;
3720  int *rint;
3721 
3722  va_list args;
3723 
3724  va_start(args, type);
3725  tobuy = va_arg(args, object *);
3726  op = va_arg(args, object *);
3727  rint = va_arg(args, int *);
3728  va_end(args);
3729 
3730  *rint = pay_for_item(tobuy, op, 0);
3731  *type = CFAPI_INT;
3732 }
3733 
3741 static void cfapi_object_transfer(int *type, ...) {
3742  object *op;
3743  object *originator;
3744  int x, y, randompos, ttype, flag;
3745  va_list args;
3746  mapstruct *map;
3747  int *rint;
3748  object **robj;
3749 
3750  va_start(args, type);
3751  op = va_arg(args, object *);
3752  ttype = va_arg(args, int);
3753  switch (ttype) {
3754  case 0:
3755  x = va_arg(args, int);
3756  y = va_arg(args, int);
3757  randompos = va_arg(args, int);
3758  originator = va_arg(args, object *);
3759  rint = va_arg(args, int *);
3760  va_end(args);
3761 
3762  *rint = transfer_ob(op, x, y, randompos, originator);
3763  *type = CFAPI_INT;
3764  return;
3765  break;
3766 
3767  case 1:
3768  map = va_arg(args, mapstruct *);
3769  originator = va_arg(args, object *);
3770  flag = va_arg(args, int);
3771  x = va_arg(args, int);
3772  y = va_arg(args, int);
3773  robj = va_arg(args, object **);
3774  va_end(args);
3775  if (x < 0 || y < 0) {
3776  x = map->enter_x;
3777  y = map->enter_y;
3778  }
3779  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
3780  *type = CFAPI_POBJECT;
3781  return;
3782  break;
3783 
3784  case 2:
3785  x = va_arg(args, int);
3786  y = va_arg(args, int);
3787  rint = va_arg(args, int *);
3788  va_end(args);
3789 
3790  *rint = move_to(op, x, y);
3791  *type = CFAPI_INT;
3792  return;
3793 
3794  default:
3795  va_end(args);
3796  *type = CFAPI_NONE;
3797  return;
3798  break;
3799  }
3800 }
3801 
3806  object *op;
3807  char *str;
3808  va_list args;
3809  object **robj;
3810 
3811  *type = CFAPI_POBJECT;
3812  va_start(args, type);
3813  op = va_arg(args, object *);
3814 
3815  str = va_arg(args, char *);
3816  robj = va_arg(args, object **);
3818  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
3819  if (*robj == NULL) {
3820  char name[MAX_BUF];
3821 
3822  /* Search by name or slaying instead */
3823  FOR_INV_PREPARE(op, tmp) {
3825  if (!strncmp(name, str, strlen(str)))
3826  *robj = tmp;
3827  if (!strncmp(tmp->name, str, strlen(str)))
3828  *robj = tmp;
3829  if (tmp->slaying && !strcmp(tmp->slaying, str))
3830  *robj = tmp;
3831  if (*robj != NULL)
3832  break;
3833  } FOR_INV_FINISH();
3834  }
3835  va_end(args);
3836 }
3837 
3838 static void cfapi_object_find_by_arch_name(int *type, ...) {
3839  const object *who;
3840  object **result;
3841  const char *name;
3842  va_list args;
3843 
3844  va_start(args, type);
3845  who = va_arg(args, const object *);
3846  name = va_arg(args, const char *);
3847  result = va_arg(args, object **);
3848  va_end(args);
3849  *type = CFAPI_POBJECT;
3850 
3851  *result = object_find_by_arch_name(who, name);
3852 }
3853 
3854 static void cfapi_object_find_by_name(int *type, ...) {
3855  const object *who;
3856  object **result;
3857  const char *name;
3858  va_list args;
3859 
3860  va_start(args, type);
3861  who = va_arg(args, const object *);
3862  name = va_arg(args, const char *);
3863  result = va_arg(args, object **);
3864  va_end(args);
3865  *type = CFAPI_POBJECT;
3866 
3867  *result = object_find_by_name(who, name);
3868 }
3869 
3875 static void cfapi_object_drop(int *type, ...) {
3876  object *op;
3877  object *author;
3878  va_list args;
3879 
3880  va_start(args, type);
3881  op = va_arg(args, object *);
3882  author = va_arg(args, object *);
3883  va_end(args);
3884  *type = CFAPI_NONE;
3885 
3886  if (QUERY_FLAG(op, FLAG_NO_DROP))
3887  return;
3888  drop(author, op);
3889 
3890  if (author->type == PLAYER) {
3891  author->contr->count = 0;
3892  author->contr->socket.update_look = 1;
3893  }
3894 }
3895 
3899 static void cfapi_object_change_abil(int *type, ...) {
3900  object *op, *tmp;
3901  int *rint;
3902  va_list args;
3903 
3904  va_start(args, type);
3905  op = va_arg(args, object *);
3906  tmp = va_arg(args, object *);
3907  rint = va_arg(args, int *);
3908  va_end(args);
3909 
3910  *type = CFAPI_INT;
3911  *rint = change_abil(op, tmp);
3912 }
3913 
3914 static void cfapi_object_say(int *type, ...) {
3915  object *op;
3916  char *msg;
3917  va_list args;
3918  int *rint;
3919  char empty[] = "";
3920 
3921  va_start(args, type);
3922  op = va_arg(args, object *);
3923  msg = va_arg(args, char *);
3924  rint = va_arg(args, int *);
3925  va_end(args);
3926 
3927  if (op->type == PLAYER) {
3928  command_say(op, msg == NULL ? empty : msg);
3929  } else {
3931  }
3932  *rint = 0;
3933  *type = CFAPI_INT;
3934 }
3935 
3936 /* PLAYER SUBCLASS */
3937 
3943 static void cfapi_player_find(int *type, ...) {
3944  va_list args;
3945  char *sval;
3946  player **rpl;
3947  va_start(args, type);
3948 
3949  sval = va_arg(args, char *);
3950  rpl = va_arg(args, player **);
3951  va_end(args);
3952 
3953  *rpl = find_player_partial_name(sval);
3954 
3955  *type = CFAPI_PPLAYER;
3956 }
3957 
3958 static void cfapi_player_message(int *type, ...) {
3959  va_list args;
3960  int flags;
3961  int pri;
3962  object *pl;
3963  char *buf;
3964 
3965  va_start(args, type);
3966 
3967  flags = va_arg(args, int);
3968  pri = va_arg(args, int);
3969  pl = va_arg(args, object *);
3970  buf = va_arg(args, char *);
3971  va_end(args);
3972 
3974  buf);
3975  *type = CFAPI_NONE;
3976 }
3977 
3984 static void cfapi_object_perm_exp(int *type, ...) {
3985  va_list args;
3986  object *op;
3987  int64_t *rlong;
3988 
3989  va_start(args, type);
3990  op = va_arg(args, object *);
3991  rlong = va_arg(args, int64_t *);
3992  va_end(args);
3993 
3994  *type = CFAPI_SINT64;
3995  *rlong = PERM_EXP(op->total_exp);
3996 }
3997 
4003 static void cfapi_object_change_exp(int *type, ...) {
4004  va_list args;
4005  int flag;
4006  object *ob;
4007  const char *skill;
4008  int64_t exp;
4009 
4010  va_start(args, type);
4011  ob = va_arg(args, object *);
4012  exp = va_arg(args, int64_t);
4013  skill = va_arg(args, const char *);
4014  flag = va_arg(args, int);
4015  va_end(args);
4016 
4017  *type = CFAPI_NONE;
4018  change_exp(ob, exp, skill, flag);
4019 }
4020 
4026 static void cfapi_player_can_pay(int *type, ...) {
4027  va_list args;
4028  object *pl;
4029  int *rint;
4030 
4031  va_start(args, type);
4032  pl = va_arg(args, object *);
4033  rint = va_arg(args, int *);
4034  va_end(args);
4035 
4036  *rint = can_pay(pl);
4037  *type = CFAPI_INT;
4038 }
4039 
4045 static void cfapi_player_knowledge(int *type, ...) {
4046  va_list args;
4047  object *pl;
4048  int *rint, what;
4049  const char *knowledge;
4050 
4051  va_start(args, type);
4052  what = va_arg(args, int);
4053 
4054  switch(what)
4055  {
4056  case 1:
4057  pl = va_arg(args, object *);
4058  knowledge = va_arg(args, const char *);
4059  rint = va_arg(args, int *);
4060 
4061  *type = CFAPI_INT;
4062 
4063  if (pl->contr == NULL) {
4064  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4065  *rint = 0;
4066  va_end(args);
4067  return;
4068  }
4069 
4070  *rint = knowledge_player_knows(pl->contr, knowledge);
4071  break;
4072 
4073  case 2:
4074  pl = va_arg(args, object *);
4075  knowledge = va_arg(args, const char *);
4076  *type = CFAPI_NONE;
4077  if (pl->contr != NULL)
4078  knowledge_give(pl->contr, knowledge, NULL);
4079 
4080  break;
4081 
4082  default:
4083  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4084  }
4085 
4086  va_end(args);
4087 }
4088 
4094 static void cfapi_object_teleport(int *type, ...) {
4095  mapstruct *map;
4096  int x, y;
4097  object *who;
4098  int *res;
4099  va_list args;
4100 
4101  va_start(args, type);
4102  who = va_arg(args, object *);
4103  map = va_arg(args, mapstruct *);
4104  x = va_arg(args, int);
4105  y = va_arg(args, int);
4106  res = va_arg(args, int *);
4107  va_end(args);
4108 
4109  *type = CFAPI_INT;
4110  *res = object_teleport(who, map, x, y);
4111 }
4112 
4113 static void cfapi_object_pickup(int *type, ...) {
4114  object *who;
4115  object *what;
4116  va_list args;
4117 
4118  va_start(args, type);
4119  who = va_arg(args, object *);
4120  what = va_arg(args, object *);
4121  va_end(args);
4122 
4123  pick_up(who, what);
4124  *type = CFAPI_NONE;
4125 }
4126 
4127 /* Archetype-related functions */
4128 static void cfapi_archetype_get_property(int *type, ...) {
4129  int prop;
4130  archetype *arch;
4131  va_list args;
4132  sstring *rsstring;
4133  archetype **rarch;
4134  object **robject;
4135 
4136  va_start(args, type);
4137  arch = va_arg(args, archetype *);
4138  prop = va_arg(args, int);
4139  switch (prop) {
4140  case CFAPI_ARCH_PROP_NAME:
4141  *type = CFAPI_SSTRING;
4142  rsstring = va_arg(args, sstring *);
4143  *rsstring = arch->name;
4144  break;
4145 
4146  case CFAPI_ARCH_PROP_NEXT:
4147  *type = CFAPI_PARCH;
4148  rarch = va_arg(args, archetype **);
4149  *rarch = get_next_archetype(arch);
4150  break;
4151 
4152  case CFAPI_ARCH_PROP_HEAD:
4153  *type = CFAPI_PARCH;
4154  rarch = va_arg(args, archetype **);
4155  *rarch = arch->head;
4156  break;
4157 
4158  case CFAPI_ARCH_PROP_MORE:
4159  *type = CFAPI_PARCH;
4160  rarch = va_arg(args, archetype **);
4161  *rarch = arch->more;
4162  break;
4163 
4164  case CFAPI_ARCH_PROP_CLONE:
4165  *type = CFAPI_POBJECT;
4166  robject = va_arg(args, object **);
4167  *robject = &arch->clone;
4168  break;
4169 
4170  default:
4171  *type = CFAPI_NONE;
4172  break;
4173  }
4174  va_end(args);
4175 }
4176 
4183 static void cfapi_party_get_property(int *type, ...) {
4184  partylist *party;
4185  int prop;
4186  va_list args;
4187  object *obarg;
4188  sstring *rsstring;
4189  player **rplayer;
4190  partylist **rparty;
4191 
4192  va_start(args, type);
4193  party = va_arg(args, partylist *);
4194  prop = va_arg(args, int);
4195  switch (prop) {
4196  case CFAPI_PARTY_PROP_NAME:
4197  rsstring = va_arg(args, sstring *);
4198  *rsstring = party->partyname;
4199  *type = CFAPI_SSTRING;
4200  break;
4201 
4202  case CFAPI_PARTY_PROP_NEXT:
4203  rparty = va_arg(args, partylist **);
4204  *rparty = (party ? party_get_next(party) : party_get_first());
4205  *type = CFAPI_PPARTY;
4206  break;
4207 
4209  rsstring = va_arg(args, sstring *);
4210  *rsstring = party_get_password(party);
4211  *type = CFAPI_SSTRING;
4212  break;
4213 
4215  *type = CFAPI_PPLAYER;
4216  obarg = va_arg(args, object *);
4217  rplayer = va_arg(args, player **);
4218  *rplayer = (obarg ? obarg->contr : first_player);
4219  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4220  if ((*rplayer)->ob->contr->party == party) {
4221  break;
4222  }
4223  break;
4224 
4225  default:
4226  *type = CFAPI_NONE;
4227  break;
4228  }
4229  va_end(args);
4230 }
4231 
4238 static void cfapi_region_get_property(int *type, ...) {
4239  region *reg;
4240  int prop, *rint;
4241  va_list args;
4243  sstring *rsstring;
4244  region **rregion;
4245 
4246  va_start(args, type);
4247  reg = va_arg(args, region *);
4248  prop = va_arg(args, int);
4249  switch (prop) {
4251  rsstring = va_arg(args, sstring *);
4252  *rsstring = reg->name;
4253  *type = CFAPI_SSTRING;
4254  break;
4255 
4257  rregion = va_arg(args, region **);
4258  *rregion = (reg ? reg->next : first_region);
4259  *type = CFAPI_PREGION;
4260  break;
4261 
4263  rregion = va_arg(args, region **);
4264  *rregion = reg->parent;
4265  *type = CFAPI_PREGION;
4266  break;
4267 
4269  rsstring = va_arg(args, sstring *);
4270  *rsstring = reg->longname;
4271  *type = CFAPI_SSTRING;
4272  break;
4273 
4275  rsstring = va_arg(args, sstring *);
4276  *rsstring = reg->msg;
4277  *type = CFAPI_SSTRING;
4278  break;
4279 
4282  rint = va_arg(args, int*);
4283  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4284  *type = CFAPI_INT;
4285  break;
4286 
4288  rsstring = va_arg(args, sstring *);
4289  *rsstring = reg->jailmap;
4290  *type = CFAPI_SSTRING;
4291  break;
4292 
4293  default:
4294  *type = CFAPI_NONE;
4295  break;
4296  }
4297  va_end(args);
4298 }
4299 
4311 static void cfapi_friendlylist_get_next(int *type, ...) {
4312  object *ob;
4313  va_list args;
4314  objectlink *link;
4315  object **robject;
4316 
4317  va_start(args, type);
4318  ob = va_arg(args, object *);
4319  robject = va_arg(args, object **);
4320  va_end(args);
4321 
4322  *type = CFAPI_POBJECT;
4323  *robject = NULL;
4324 
4325  if (ob) {
4326  for (link = first_friendly_object; link; link = link->next) {
4327  if (ob == link->ob) {
4328  if (link->next) {
4329  *robject = link->next->ob;
4330  return;
4331  } else {
4332  return;
4333  }
4334  }
4335  }
4336  return;
4337  }
4338 
4340  *robject = first_friendly_object->ob;
4341 }
4342 
4343 /*
4344  * Random-map related stuff.
4345  */
4346 
4353 static void cfapi_set_random_map_variable(int *type, ...) {
4354  va_list args;
4355  RMParms *rp;
4356  const char *buf;
4357  int *ret;
4358 
4359  va_start(args, type);
4360  rp = va_arg(args, RMParms *);
4361  buf = va_arg(args, const char *);
4362  ret = va_arg(args, int *);
4363  va_end(args);
4364 
4365  *ret = set_random_map_variable(rp, buf);
4366  *type = CFAPI_INT;
4367 }
4368 
4375 static void cfapi_generate_random_map(int *type, ...) {
4376  va_list args;
4377  const char *name;
4378  RMParms *rp;
4379  char **use_layout;
4380  mapstruct **ret;
4381 
4382  va_start(args, type);
4383  name = va_arg(args, const char *);
4384  rp = va_arg(args, RMParms *);
4385  use_layout = va_arg(args, char **);
4386  ret = va_arg(args, mapstruct **);
4387  va_end(args);
4388 
4389  *ret = generate_random_map(name, rp, use_layout);
4390 }
4391 
4392 static void cfapi_object_user_event(int *type, ...) {
4393  object *op;
4394  object *activator;
4395  object *third;
4396  const char *message;
4397  int fix;
4398  int *ret;
4399  va_list args;
4400 
4401  va_start(args, type);
4402  op = va_arg(args, object *);
4403  activator = va_arg(args, object *);
4404  third = va_arg(args, object *);
4405  message = va_arg(args, const char *);
4406  fix = va_arg(args, int);
4407  ret = va_arg(args, int *);
4408  va_end(args);
4409 
4410  *ret = events_execute_object_user(op, activator, third, message, fix);
4411  *type = CFAPI_INT;
4412 }
4413 
4416 static void cfapi_player_quest(int *type, ...) {
4417  int op;
4418  va_list args;
4419  object *player;
4420  sstring code;
4421 
4422  va_start(args, type);
4423  op = va_arg(args, int);
4424  player = va_arg(args, object *);
4425  code = va_arg(args, sstring);
4426 
4427  if (player->contr == NULL) {
4428  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4429  va_end(args);
4430  /* crash/quit? */
4431  return;
4432  }
4433 
4434  switch(op) {
4435  case CFAPI_PLAYER_QUEST_START: {
4436  int state = va_arg(args, int);
4437  quest_start(player->contr, code, state);
4438  *type = CFAPI_NONE;
4439  break;
4440  }
4442  int *ret = va_arg(args, int *);
4443  *ret = quest_get_player_state(player->contr, code);
4444  *type = CFAPI_INT;
4445  break;
4446  }
4448  int state = va_arg(args, int);
4449  quest_set_player_state(player->contr, code, state);
4450  *type = CFAPI_NONE;
4451  break;
4452  }
4454  int *ret = va_arg(args, int*);
4455  *ret = quest_was_completed(player->contr, code);
4456  *type = CFAPI_INT;
4457  break;
4458  }
4459  default:
4460  LOG(llevError, "invalid quest type: %d\n", op);
4461  *type = CFAPI_NONE;
4462  }
4463 
4464  va_end(args);
4465 }
4466 
4467 static void cfapi_register_command(int *type, ...) {
4468  va_list args;
4469  const char *name, *extra;
4470  float time;
4471  command_function func;
4472  command_function_extra func_extra;
4473  uint8_t register_type, command_type;
4475 
4476  va_start(args, type);
4477  register_type = va_arg(args, int);
4478  name = va_arg(args, const char *);
4479  if (register_type == 1) {
4480  func = va_arg(args, command_function);
4481  } else {
4482  extra = va_arg(args, const char *);
4483  func_extra = va_arg(args, command_function_extra);
4484  }
4485  command_type = (uint8_t)va_arg(args, int);
4486  time = va_arg(args, double);
4487  cr = va_arg(args, command_registration *);
4488  va_end(args);
4489 
4490  if (register_type == 1) {
4491  (*cr) = command_register(name, command_type, func, time);
4492  } else {
4493  (*cr) = command_register_extra(name, extra, command_type, func_extra, time);
4494  }
4495 
4496  *type = CFAPI_SINT64;
4497 }
4498 
4499 static void cfapi_unregister_command(int *type, ...) {
4500  va_list args;
4502 
4503  va_start(args, type);
4504  cr = va_arg(args, command_registration);
4505  va_end(args);
4506 
4507  command_unregister(cr);
4508 }
4509 
4510 /*****************************************************************************/
4511 /* NEW PLUGIN STUFF ENDS HERE */
4512 /*****************************************************************************/
4513 
4514 
4519 void initPlugins(void) {
4520  struct dirent *currentfile;
4521  DIR *plugdir;
4522  size_t l;
4523  char buf[MAX_BUF];
4524 
4525  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4526  LOG(llevDebug, "plugins: loading from %s\n", buf);
4527 
4528  plugdir = opendir(buf);
4529  if (plugdir == NULL)
4530  return;
4531 
4532  while ((currentfile = readdir(plugdir)) != NULL) {
4533  l = strlen(currentfile->d_name);
4534  if (l > strlen(PLUGIN_SUFFIX)) {
4536  int ignore = 0;
4537 
4538  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4539  continue;
4540 
4541  while (disable) {
4542  if (strcmp(disable->name, "All") == 0) {
4543  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4544  ignore = 1;
4545  break;
4546  }
4547  if (strncmp(disable->name, currentfile->d_name, strlen(disable->name)) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + strlen(disable->name)) {
4548  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4549  ignore = 1;
4550  break;
4551  }
4552  disable = disable->next;
4553  }
4554  if (ignore == 0) {
4555  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4556  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4558  }
4559  }
4560  }
4561 
4562  closedir(plugdir);
4563 }
4564 
4569 void cleanupPlugins(void) {
4570  crossfire_plugin *cp;
4571 
4572  if (!plugins_list)
4573  return;
4574 
4575  for (cp = plugins_list; cp != NULL; ) {
4576  crossfire_plugin *next = cp->next;
4577  if (cp->closefunc)
4578  cp->closefunc();
4579  /* Don't actually unload plugins, it makes backtraces for memory
4580  * debugging (printed at exit) messed up. And it doesn't matter if we
4581  * don't free it here. The OS will do it for us.
4582  */
4583  /* plugins_dlclose(cp->libptr); */
4584  free(cp);
4585  cp = next;
4586  }
4587  plugins_list = NULL;
4588 }
get_month_name
const char * get_month_name(const int index)
Definition: time.c:109
cfapi_object_learn_spell
static void cfapi_object_learn_spell(int *type,...)
Definition: plugins.c:3641
give.next
def next
Definition: give.py:44
GET_MAP_OB
#define GET_MAP_OB(M, X, Y)
Definition: map.h:173
Face
Definition: face.h:14
cfapi_map_has_been_loaded
static void cfapi_map_has_been_loaded(int *type,...)
Definition: plugins.c:1024
ready_map_name
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.c:1778
CFAPI_SSTRING
#define CFAPI_SSTRING
Definition: plugin.h:77
CFAPI_OBJECT_PROP_TITLE
#define CFAPI_OBJECT_PROP_TITLE
Definition: plugin.h:136
CFAPI_PPLAYER
#define CFAPI_PPLAYER
Definition: plugin.h:71
cfapi_player_message
static void cfapi_player_message(int *type,...)
Definition: plugins.c:3958
Settings::mapdir
const char * mapdir
Definition: global.h:246
cftimer_find_free_id
int cftimer_find_free_id(void)
Definition: timers.c:144
CFAPI_OBJECT_PROP_X
#define CFAPI_OBJECT_PROP_X
Definition: plugin.h:142
plugins_display_list
void plugins_display_list(object *op)
Definition: plugins.c:506
object_free
void object_free(object *ob, int flags)
Definition: object.c:1573
cfapi_player_quest
static void cfapi_player_quest(int *type,...)
Definition: plugins.c:4416
CFAPI_POBJECT
#define CFAPI_POBJECT
Definition: plugin.h:65
banquet.l
l
Definition: banquet.py:164
add_string
sstring add_string(const char *str)
Definition: shstr.c:124
spell_arrow.archetype
archetype
Definition: spell_arrow.py:11
f_plug_postinit
int(* f_plug_postinit)(void)
Definition: plugin.h:83
object_remove
void object_remove(object *op)
Definition: object.c:1814
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
object_sum_weight
signed long object_sum_weight(object *op)
Definition: object.c:561
CFAPI_OBJECT_PROP_CHA
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:207
object_set_enemy
void object_set_enemy(object *op, object *enemy)
Definition: object.c:902
cfapi_object_create
static void cfapi_object_create(int *type,...)
Definition: plugins.c:3225
CFAPI_MAP_PROP_TMPNAME
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h:252
_hook_entry
Definition: plugin.h:304
CFAPI_OBJECT_PROP_ARCH_NAME
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:219
cfapi_get_hooks
static void cfapi_get_hooks(int *type,...)
Definition: plugins.c:320
CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
Definition: plugin.h:182
cfapi_object_remove
static void cfapi_object_remove(int *type,...)
Definition: plugins.c:3145
llevError
@ llevError
Definition: logger.h:11
MOVE_ALL
#define MOVE_ALL
Definition: define.h:398
cfapi_object_perm_exp
static void cfapi_object_perm_exp(int *type,...)
Definition: plugins.c:3984
command_say
void command_say(object *op, const char *params)
Definition: c_chat.c:34
CFAPI_PARTY_PROP_NAME
#define CFAPI_PARTY_PROP_NAME
Definition: plugin.h:274
NR_EVENTS
#define NR_EVENTS
Definition: events.h:57
object_reset
void object_reset(object *op)
Definition: object.c:921
cfapi_object_cast
static void cfapi_object_cast(int *type,...)
Definition: plugins.c:3613
monster_npc_say
void monster_npc_say(object *npc, const char *cp)
Definition: monster.c:2306
check_path
int check_path(const char *name, int prepend_dir)
Definition: map.c:212
object_create_clone
object * object_create_clone(object *asrc)
Definition: object.c:3925
CFAPI_MAP_PROP_RESET_TIME
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:254
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
_crossfire_plugin::closefunc
f_plug_postinit closefunc
Definition: plugin.h:99
CFAPI_MAP_PROP_RESET_TIMEOUT
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:255
CFAPI_REGION_PROP_LONGNAME
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:282
cfapi_object_delete
static void cfapi_object_delete(int *type,...)
Definition: plugins.c:3166
CFAPI_OBJECT_PROP_LEVEL
#define CFAPI_OBJECT_PROP_LEVEL
Definition: plugin.h:161
CFAPI_NONE
#define CFAPI_NONE
Definition: plugin.h:60
cfapi_object_query_money
static void cfapi_object_query_money(int *type,...)
Definition: plugins.c:3594
CFAPI_PLAYER_PROP_BED_X
#define CFAPI_PLAYER_PROP_BED_X
Definition: plugin.h:238
strdup_local
#define strdup_local
Definition: compat.h:29
object_update
void object_update(object *op, int action)
Definition: object.c:1415
diamondslots.x
x
Definition: diamondslots.py:15
cfapi_object_insert
static void cfapi_object_insert(int *type,...)
Definition: plugins.c:3264
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
_crossfire_plugin::libptr
LIBPTRTYPE libptr
Definition: plugin.h:100
CFAPI_REGION_PROP_NEXT
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:280
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:262
clean_object
void clean_object(object *op)
Definition: map.c:1607
CFAPI_MAP_PROP_NEXT
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:264
cfapi_system_strdup_local
static void cfapi_system_strdup_local(int *type,...)
Definition: plugins.c:603
do_learn_spell
void do_learn_spell(object *op, object *spell, int special_prayer)
Definition: apply.c:484
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
Definition: global.h:322
cfapi_map_out_of_map
static void cfapi_map_out_of_map(int *type,...)
Definition: plugins.c:1238
make_face_from_files.type
type
Definition: make_face_from_files.py:24
out_of_map
int out_of_map(mapstruct *m, int x, int y)
Definition: map.c:2302
CFAPI_OBJECT_PROP_SLAYING
#define CFAPI_OBJECT_PROP_SLAYING
Definition: plugin.h:138
CFAPI_OBJECT_PROP_DEX
#define CFAPI_OBJECT_PROP_DEX
Definition: plugin.h:202
CFAPI_OBJECT_PROP_FRIENDLY
#define CFAPI_OBJECT_PROP_FRIENDLY
Definition: plugin.h:189
object_new
object * object_new(void)
Definition: object.c:1236
CFAPI_OBJECT_PROP_ARCHETYPE
#define CFAPI_OBJECT_PROP_ARCHETYPE
Definition: plugin.h:185
Settings::datadir
const char * datadir
Definition: global.h:243
cfapi_object_change_abil
static void cfapi_object_change_abil(int *type,...)
Definition: plugins.c:3899
cast_spell
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Definition: spell_util.c:1420
calculate_difficulty
int calculate_difficulty(mapstruct *m)
Definition: map.c:1901
events_unregister_object_handler
void events_unregister_object_handler(const char *id)
Definition: events.cpp:254
CFAPI_OBJECT_PROP_BASE_NAME
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:191
object_find_by_arch_name
object * object_find_by_arch_name(const object *who, const char *name)
Definition: object.c:4268
UPD_WEIGHT
#define UPD_WEIGHT
Definition: newclient.h:316
pl
Definition: player.h:92
CFAPI_OBJECT_PROP_LAST_EAT
#define CFAPI_OBJECT_PROP_LAST_EAT
Definition: plugin.h:165
object_distance
int object_distance(const object *ob1, const object *ob2)
Definition: object.c:3677
CFAPI_OBJECT_PROP_MOVE_ON
#define CFAPI_OBJECT_PROP_MOVE_ON
Definition: plugin.h:227
spring_trap
void spring_trap(object *trap, object *victim)
Definition: rune.c:205
CFAPI_FUNC
#define CFAPI_FUNC
Definition: plugin.h:70
get_periodofday
const char * get_periodofday(const int index)
Definition: time.c:102
CFAPI_OBJECT_PROP_STR
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:201
SVN_REV
#define SVN_REV
Definition: svnversion.h:2
set_random_map_variable
int set_random_map_variable(RMParms *rp, const char *buf)
Definition: reader.c:2579
quest_set_player_state
void quest_set_player_state(player *pl, sstring quest_code, int state)
Definition: quest.c:1101
arch_present_in_ob
object * arch_present_in_ob(const archetype *at, const object *op)
Definition: object.c:3180
CFAPI_OBJECT_PROP_GOD
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:218
MoveType
unsigned char MoveType
Definition: define.h:417
guildjoin.ob
ob
Definition: guildjoin.py:42
regiondef::jailx
int16_t jailx
Definition: map.h:297
CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
Definition: plugin.h:126
cfapi_player_find
static void cfapi_player_find(int *type,...)
Definition: plugins.c:3943
CFAPI_PLAYER_PROP_MARKED_ITEM
#define CFAPI_PLAYER_PROP_MARKED_ITEM
Definition: plugin.h:235
SET_ANIMATION
#define SET_ANIMATION(ob, newanim)
Definition: global.h:160
giveknowledge.knowledge
knowledge
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: giveknowledge.py:15
CFAPI_OBJECT_PROP_MAXSP
#define CFAPI_OBJECT_PROP_MAXSP
Definition: plugin.h:215
CFAPI_OBJECT_PROP_RAW_NAME
#define CFAPI_OBJECT_PROP_RAW_NAME
Definition: plugin.h:232
CFAPI_OBJECT_PROP_SPELL_ITEM
#define CFAPI_OBJECT_PROP_SPELL_ITEM
Definition: plugin.h:183
move_player
int move_player(object *op, int dir)
Definition: player.c:2912
pl::ob
object * ob
Definition: player.h:162
CFAPI_ARCH_PROP_NEXT
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:269
cfapi_get_time
static void cfapi_get_time(int *type,...)
Definition: plugins.c:815
create_pathname
char * create_pathname(const char *name, char *buf, size_t size)
Definition: map.c:113
cfapi_object_say
static void cfapi_object_say(int *type,...)
Definition: plugins.c:3914
object_can_merge
int object_can_merge(object *ob1, object *ob2)
Definition: object.c:422
CFAPI_OBJECT_PROP_Y
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:143
CFAPI_OBJECT_PROP_ENEMY
#define CFAPI_OBJECT_PROP_ENEMY
Definition: plugin.h:176
cfapi_object_drain
static void cfapi_object_drain(int *type,...)
Definition: plugins.c:3058
CFAPI_OBJECT_PROP_MOVE_TYPE
#define CFAPI_OBJECT_PROP_MOVE_TYPE
Definition: plugin.h:224
cfapi_unregister_command
static void cfapi_unregister_command(int *type,...)
Definition: plugins.c:4499
Ice.tmp
int tmp
Definition: Ice.py:207
is_friendly
int is_friendly(const object *op)
Definition: friend.c:144
CFAPI_OBJECT_PROP_FACE
#define CFAPI_OBJECT_PROP_FACE
Definition: plugin.h:221
CFAPI_REGION_PROP_PARENT
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:281
plugin.h
CFAPI_OBJECT_PROP_ENVIRONMENT
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:129
remove_friendly_object
void remove_friendly_object(object *op)
Definition: friend.c:56
CFAPI_PPARTY
#define CFAPI_PPARTY
Definition: plugin.h:72
CFAPI_OBJECT_PROP_ATTACKED_BY
#define CFAPI_OBJECT_PROP_ATTACKED_BY
Definition: plugin.h:177
UPD_NROF
#define UPD_NROF
Definition: newclient.h:321
FOR_ABOVE_PREPARE
#define FOR_ABOVE_PREPARE(op_, it_)
Definition: define.h:685
send_changed_object
static void send_changed_object(object *op)
Definition: plugins.c:294
flags
static const flag_definition flags[]
Definition: gridarta-types-convert.c:101
CFAPI_OBJECT_PROP_PRESENT
#define CFAPI_OBJECT_PROP_PRESENT
Definition: plugin.h:196
player_set_own_title
void player_set_own_title(struct pl *pl, const char *title)
Definition: player.c:275
CFAPI_REGION_PROP_JAIL_PATH
#define CFAPI_REGION_PROP_JAIL_PATH
Definition: plugin.h:286
CFAPI_MAP_PROP_WIDTH
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:259
ext_info_map
void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Definition: main.c:335
re_cmp
const char * re_cmp(const char *, const char *)
Definition: re-cmp.c:69
CFAPI_ARCH_PROP_NAME
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:268
CFAPI_OBJECT_PROP_ITEM_POWER
#define CFAPI_OBJECT_PROP_ITEM_POWER
Definition: plugin.h:168
CFAPI_MAP_PROP_UNIQUE
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:266
cfapi_object_check_trigger
static void cfapi_object_check_trigger(int *type,...)
Definition: plugins.c:3547
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.c:940
cfapi_friendlylist_get_next
static void cfapi_friendlylist_get_next(int *type,...)
Definition: plugins.c:4311
f_plug_init
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:85
cfapi_object_remove_depletion
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.c:3076
first_map
EXTERN mapstruct * first_map
Definition: global.h:116
smoking_pipe.color
color
Definition: smoking_pipe.py:5
apply_manual
int apply_manual(object *op, object *tmp, int aflag)
Definition: apply.c:597
CFAPI_FLOAT
#define CFAPI_FLOAT
Definition: plugin.h:67
apply_by_living_below
void apply_by_living_below(object *pl)
Definition: apply.c:695
MSG_TYPE_MISC
#define MSG_TYPE_MISC
Definition: newclient.h:413
CFAPI_OBJECT_PROP_CURRENT_WEAPON
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON
Definition: plugin.h:175
cfapi_object_spring_trap
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.c:3528
first_friendly_object
EXTERN objectlink * first_friendly_object
Definition: global.h:119
cfapi_register_command
static void cfapi_register_command(int *type,...)
Definition: plugins.c:4467
cfapi_object_clean_object
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.c:3501
cfapi_object_user_event
static void cfapi_object_user_event(int *type,...)
Definition: plugins.c:4392
cfapi_map_update_position
static void cfapi_map_update_position(int *type,...)
Definition: plugins.c:1260
_timeofday
Definition: tod.h:34
RMParms
Definition: random_map.h:14
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Definition: newclient.h:404
cfapi_system_unregister_global_event
static void cfapi_system_unregister_global_event(int *type,...)
Definition: plugins.c:638
CFAPI_MAP_PROP_ENTER_X
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:261
freearr_x
short freearr_x[SIZEOFFREE]
Definition: object.c:288
cfapi_object_forget_spell
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.c:3656
CFAPI_OBJECT_PROP_INVISIBLE
#define CFAPI_OBJECT_PROP_INVISIBLE
Definition: plugin.h:220
freearr_y
short freearr_y[SIZEOFFREE]
Definition: object.c:294
party_struct::partyname
char * partyname
Definition: party.h:14
plugins_dlerror
#define plugins_dlerror()
Definition: plugin.h:119
_crossfire_plugin::next
struct _crossfire_plugin * next
Definition: plugin.h:104
cfapi_object_give_skill
static void cfapi_object_give_skill(int *type,...)
Definition: plugins.c:3111
cfapi_system_directory
static void cfapi_system_directory(int *type,...)
Definition: plugins.c:762
linked_char
Definition: global.h:86
cfapi_player_can_pay
static void cfapi_player_can_pay(int *type,...)
Definition: plugins.c:4026
CFAPI_OBJECT_PROP_SKILL
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:139
events_register_global_handler
event_registration events_register_global_handler(int eventcode, f_plug_event hook)
Definition: events.cpp:16
CFAPI_OBJECT_PROP_CLIENT_TYPE
#define CFAPI_OBJECT_PROP_CLIENT_TYPE
Definition: plugin.h:151
settings
struct Settings settings
Definition: init.c:39
party_join
void party_join(object *op, partylist *party)
Definition: party.c:85
TIMER_ERR_ID
#define TIMER_ERR_ID
Definition: timers.h:67
object_merge
object * object_merge(object *op, object *top)
Definition: object.c:2026
_crossfire_plugin::global_registration
event_registration global_registration[NR_EVENTS]
Definition: plugin.h:103
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4362
MSG_TYPE_COMMAND_DEBUG
#define MSG_TYPE_COMMAND_DEBUG
Definition: newclient.h:528
CFAPI_OBJECT_PROP_PATH_DENIED
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:156
identify
object * identify(object *op)
Definition: item.c:1398
CFAPI_MAP_PROP_REGION
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:265
free_string
void free_string(sstring str)
Definition: shstr.c:280
cfapi_object_move
static void cfapi_object_move(int *type,...)
Definition: plugins.c:1398
cfapi_map_find_by_archetype_name
static void cfapi_map_find_by_archetype_name(int *type,...)
Definition: plugins.c:1340
regiondef::next
struct regiondef * next
Definition: map.h:276
plugins_init_plugin
int plugins_init_plugin(const char *libfile)
Definition: plugins.c:366
TIMER_ERR_NONE
#define TIMER_ERR_NONE
Definition: timers.h:66
CFAPI_OBJECT_PROP_ANIM_SPEED
#define CFAPI_OBJECT_PROP_ANIM_SPEED
Definition: plugin.h:188
m
static event_registration m
Definition: citylife.cpp:410
CFAPI_OBJECT_PROP_AC
#define CFAPI_OBJECT_PROP_AC
Definition: plugin.h:209
events_register_object_handler
void events_register_object_handler(const char *id, f_plug_event handler)
Definition: events.cpp:249
autojail.who
who
Definition: autojail.py:3
cfapi_map_get_object_at
static void cfapi_map_get_object_at(int *type,...)
Definition: plugins.c:1311
party_get_first
partylist * party_get_first(void)
Definition: party.c:196
cfapi_system_re_cmp
static void cfapi_system_re_cmp(int *type,...)
Definition: plugins.c:744
pl::next
struct pl * next
Definition: player.h:93
opendir
DIR * opendir(const char *)
CFAPI_OBJECT_PROP_LORE
#define CFAPI_OBJECT_PROP_LORE
Definition: plugin.h:141
CFAPI_ARCH_PROP_HEAD
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:270
disinfect.map
map
Definition: disinfect.py:4
CFAPI_OBJECT_PROP_PICK_UP
#define CFAPI_OBJECT_PROP_PICK_UP
Definition: plugin.h:167
CFAPI_OBJECT_PROP_MOVE_OFF
#define CFAPI_OBJECT_PROP_MOVE_OFF
Definition: plugin.h:228
FLAG_WAS_WIZ
#define FLAG_WAS_WIZ
Definition: define.h:234
CFAPI_PLAYER_PROP_PARTY
#define CFAPI_PLAYER_PROP_PARTY
Definition: plugin.h:236
change_map_light
int change_map_light(mapstruct *m, int change)
Definition: map.c:1999
command_unregister
void command_unregister(command_registration command)
Definition: commands.cpp:491
linked_char::name
const char * name
Definition: global.h:87
get_tod
void get_tod(timeofday_t *tod)
Definition: time.c:215
determine_god
const char * determine_god(object *op)
Definition: gods.c:106
CFAPI_OBJECT_PROP_CHOSEN_SKILL
#define CFAPI_OBJECT_PROP_CHOSEN_SKILL
Definition: plugin.h:179
CFAPI_OBJECT_PROP_HP
#define CFAPI_OBJECT_PROP_HP
Definition: plugin.h:210
CFAPI_OBJECT_PROP_MAXHP
#define CFAPI_OBJECT_PROP_MAXHP
Definition: plugin.h:214
drop
void drop(object *op, object *tmp)
Definition: c_object.c:1168
diamondslots.activator
activator
Definition: diamondslots.py:10
make_face_from_files.args
args
Definition: make_face_from_files.py:30
cfapi_object_describe
static void cfapi_object_describe(int *type,...)
Definition: plugins.c:3036
CFAPI_OBJECT_PROP_OB_BELOW
#define CFAPI_OBJECT_PROP_OB_BELOW
Definition: plugin.h:125
regiondef::jaily
int16_t jaily
Definition: map.h:297
CFAPI_OBJECT_PROP_HIDDEN
#define CFAPI_OBJECT_PROP_HIDDEN
Definition: plugin.h:180
CFAPI_OBJECT_PROP_CARRYING
#define CFAPI_OBJECT_PROP_CARRYING
Definition: plugin.h:172
CFAPI_OBJECT_PROP_TOTAL_EXP
#define CFAPI_OBJECT_PROP_TOTAL_EXP
Definition: plugin.h:174
object_copy
void object_copy(const object *src_ob, object *dest_ob)
Definition: object.c:1047
move_ob
int move_ob(object *op, int dir, object *originator)
Definition: move.c:58
cftimer_destroy
int cftimer_destroy(int id)
Definition: timers.c:128
CFAPI_PLAYER_PROP_BED_Y
#define CFAPI_PLAYER_PROP_BED_Y
Definition: plugin.h:239
query_name
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:584
plugins_remove_plugin
int plugins_remove_plugin(const char *id)
Definition: plugins.c:457
_crossfire_plugin::id
char id[MAX_BUF]
Definition: plugin.h:101
CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
Definition: plugin.h:169
CFAPI_REGION_PROP_JAIL_Y
#define CFAPI_REGION_PROP_JAIL_Y
Definition: plugin.h:285
CFAPI_OBJECT_PROP_CHEATER
#define CFAPI_OBJECT_PROP_CHEATER
Definition: plugin.h:197
cfapi_map_create_path
static void cfapi_map_create_path(int *type,...)
Definition: plugins.c:1042
FOR_ABOVE_FINISH
#define FOR_ABOVE_FINISH()
Definition: define.h:692
events_unregister_global_handler
void events_unregister_global_handler(int eventcode, event_registration id)
Definition: events.cpp:23
CFAPI_MAP_PROP_MESSAGE
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:263
Face::number
uint16_t number
Definition: face.h:15
cfapi_map_change_light
static void cfapi_map_change_light(int *type,...)
Definition: plugins.c:1367
CFAPI_OBJECT_PROP_RACE
#define CFAPI_OBJECT_PROP_RACE
Definition: plugin.h:137
f_plug_api
void(* f_plug_api)(int *type,...)
Definition: plugin.h:81
_crossfire_plugin::propfunc
f_plug_property propfunc
Definition: plugin.h:98
remove_depletion
int remove_depletion(object *op, int level)
Definition: living.c:756
cfapi_party_get_property
static void cfapi_party_get_property(int *type,...)
Definition: plugins.c:4183
CFAPI_OBJECT_PROP_MOVE_BLOCK
#define CFAPI_OBJECT_PROP_MOVE_BLOCK
Definition: plugin.h:225
CFAPI_OBJECT_PROP_FACING
#define CFAPI_OBJECT_PROP_FACING
Definition: plugin.h:148
cfapi_object_pay_amount
static void cfapi_object_pay_amount(int *type,...)
Definition: plugins.c:3696
CFAPI_INT
#define CFAPI_INT
Definition: plugin.h:61
CFAPI_OBJECT_PROP_WEIGHT
#define CFAPI_OBJECT_PROP_WEIGHT
Definition: plugin.h:170
cfapi_object_distance
static void cfapi_object_distance(int *type,...)
Definition: plugins.c:3428
object_can_pick
int object_can_pick(const object *who, const object *item)
Definition: object.c:3883
CFAPI_OBJECT_PROP_RESIST
#define CFAPI_OBJECT_PROP_RESIST
Definition: plugin.h:152
cfapi_system_find_string
static void cfapi_system_find_string(int *type,...)
Definition: plugins.c:702
CFAPI_PLAYER_PROP_IP
#define CFAPI_PLAYER_PROP_IP
Definition: plugin.h:234
object_clear
void object_clear(object *op)
Definition: object.c:970
CFAPI_OBJECT_PROP_DAM
#define CFAPI_OBJECT_PROP_DAM
Definition: plugin.h:217
cfapi_object_fix
static void cfapi_object_fix(int *type,...)
Definition: plugins.c:3095
make_face_from_files.str
str
Definition: make_face_from_files.py:24
cfapi_object_find_archetype_inside
static void cfapi_object_find_archetype_inside(int *type,...)
Definition: plugins.c:3805
NR_OF_HOOKS
#define NR_OF_HOOKS
Definition: plugins.c:47
readdir
struct dirent * readdir(DIR *)
FLAG_FREED
#define FLAG_FREED
Definition: define.h:233
cfapi_map_message
static void cfapi_map_message(int *type,...)
Definition: plugins.c:1289
cfapi_object_get_property
static void cfapi_object_get_property(int *type,...)
Definition: plugins.c:1493
convert.action
action
Definition: convert.py:25
find_string
sstring find_string(const char *str)
Definition: shstr.c:236
query_short_name
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.c:509
object_present_in_ob
object * object_present_in_ob(uint8_t type, const object *op)
Definition: object.c:3126
navar-midane_pickup.msg
list msg
Definition: navar-midane_pickup.py:13
_crossfire_plugin::prev
struct _crossfire_plugin * prev
Definition: plugin.h:105
transmute_materialname
void transmute_materialname(object *op, const object *change)
Definition: utils.c:267
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Definition: global.h:202
regiondef::name
char * name
Definition: map.h:277
first_player
EXTERN player * first_player
Definition: global.h:115
CFAPI_OBJECT_PROP_PATH_ATTUNED
#define CFAPI_OBJECT_PROP_PATH_ATTUNED
Definition: plugin.h:154
events_execute_object_user
int events_execute_object_user(object *op, object *activator, object *third, const char *message, int fix)
Definition: events.cpp:267
cfapi_object_apply
static void cfapi_object_apply(int *type,...)
Definition: plugins.c:2991
CFAPI_ARCH_PROP_CLONE
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:272
CFAPI_OBJECT_PROP_EXP
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:194
SET_MAP_FLAGS
#define SET_MAP_FLAGS(M, X, Y, C)
Definition: map.h:164
CFAPI_OBJECT_PROP_SPEED
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:144
fix_object
void fix_object(object *op)
Definition: living.c:1126
CFAPI_OBJECT_PROP_TYPE
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:149
quest_was_completed
int quest_was_completed(player *pl, sstring quest_code)
Definition: quest.c:1111
CFAPI_OBJECT_PROP_NROF
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:146
object_create_arch
object * object_create_arch(archetype *at)
Definition: arch.cpp:301
CFAPI_PLAYER_PROP_TITLE
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:241
CFAPI_MAP_PROP_PATH
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:251
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
cfapi_map_get_map
static void cfapi_map_get_map(int *type,...)
Definition: plugins.c:973
cfapi_object_transfer
static void cfapi_object_transfer(int *type,...)
Definition: plugins.c:3741
is_magical
int is_magical(const object *op)
Definition: item.c:1204
linked_char::next
struct linked_char * next
Definition: global.h:88
CFAPI_OBJECT_PROP_CUSTOM_NAME
#define CFAPI_OBJECT_PROP_CUSTOM_NAME
Definition: plugin.h:187
CFAPI_OBJECT_PROP_PICKABLE
#define CFAPI_OBJECT_PROP_PICKABLE
Definition: plugin.h:199
FOR_INV_FINISH
#define FOR_INV_FINISH()
Definition: define.h:675
CFAPI_PREGION
#define CFAPI_PREGION
Definition: plugin.h:73
cfapi_system_register_global_event
static void cfapi_system_register_global_event(int *type,...)
Definition: plugins.c:617
_crossfire_plugin::fullname
char fullname[MAX_BUF]
Definition: plugin.h:102
player
struct pl player
object_set_value
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:4497
sstring
const typedef char * sstring
Definition: global.h:40
CFAPI_PLAYER_QUEST_START
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:244
CFAPI_REGION_PROP_NAME
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:279
cfapi_object_clone
static void cfapi_object_clone(int *type,...)
Definition: plugins.c:3193
CFAPI_OBJECT_PROP_INVISIBLE_TIME
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME
Definition: plugin.h:166
CFAPI_OBJECT_PROP_ATTACK_TYPE
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:153
move_to
int move_to(object *op, int x, int y)
Definition: move.c:547
CFAPI_REGION_PROP_JAIL_X
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:284
Settings::confdir
const char * confdir
Definition: global.h:242
sproto.h
free_dialog_information
void free_dialog_information(object *op)
Definition: dialog.c:32
FLAG_NO_DROP
#define FLAG_NO_DROP
Definition: define.h:288
cfapi_archetype_get_property
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.c:4128
give.direction
direction
Definition: give.py:37
cfapi_object_split
static void cfapi_object_split(int *type,...)
Definition: plugins.c:3372
animate.anim
string anim
Definition: animate.py:20
cfapi_map_set_map_property
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.c:1208
get_face_by_id
const Face * get_face_by_id(uint16_t id)
Definition: assets.cpp:327
mapdef
Definition: map.h:324
cfapi_object_update
static void cfapi_object_update(int *type,...)
Definition: plugins.c:3449
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:420
cfapi_object_change_exp
static void cfapi_object_change_exp(int *type,...)
Definition: plugins.c:4003
CFAPI_OBJECT_PROP_OWNER
#define CFAPI_OBJECT_PROP_OWNER
Definition: plugin.h:195
delete_map
void delete_map(mapstruct *m)
Definition: map.c:1716
cfapi_timer_destroy
static void cfapi_timer_destroy(int *type,...)
Definition: plugins.c:930
create_overlay_pathname
void create_overlay_pathname(const char *name, char *buf, size_t size)
Definition: map.c:134
CFAPI_OBJECT_PROP_NAME_PLURAL
#define CFAPI_OBJECT_PROP_NAME_PLURAL
Definition: plugin.h:135
party_struct
Definition: party.h:10
CFAPI_PARTY_PROP_NEXT
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:275
object_set_owner
void object_set_owner(object *op, object *owner)
Definition: object.c:827
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: porting.c:220
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:155
P_OUT_OF_MAP
#define P_OUT_OF_MAP
Definition: map.h:250
plug_hooks
static const hook_entry plug_hooks[]
Definition: plugins.c:147
MAX_BUF
#define MAX_BUF
Definition: define.h:35
CFAPI_MAP_PROP_NAME
#define CFAPI_MAP_PROP_NAME
Definition: plugin.h:253
CFAPI_OBJECT_PROP_WIS
#define CFAPI_OBJECT_PROP_WIS
Definition: plugin.h:204
check_trigger
int check_trigger(object *op, object *cause)
Definition: button.c:518
CFAPI_OBJECT_PROP_POW
#define CFAPI_OBJECT_PROP_POW
Definition: plugin.h:206
transfer_ob
int transfer_ob(object *op, int x, int y, int randomly, object *originator)
Definition: move.c:150
cfapi_object_identify
static void cfapi_object_identify(int *type,...)
Definition: plugins.c:3016
CFAPI_REGION_PROP_MESSAGE
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:283
cfapi_object_reset
static void cfapi_object_reset(int *type,...)
Definition: plugins.c:3487
Settings::playerdir
const char * playerdir
Definition: global.h:245
cfapi_cost_string_from_value
static void cfapi_cost_string_from_value(int *type,...)
Definition: plugins.c:529
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp:282
party_get_next
partylist * party_get_next(const partylist *party)
Definition: party.c:208
cfapi_object_check_spell
static void cfapi_object_check_spell(int *type,...)
Definition: plugins.c:3676
cfapi_object_set_key
static void cfapi_object_set_key(int *type,...)
Definition: plugins.c:1470
cfapi_object_transmute
static void cfapi_object_transmute(int *type,...)
Definition: plugins.c:3128
CFAPI_DOUBLE
#define CFAPI_DOUBLE
Definition: plugin.h:68
CFAPI_OBJECT_PROP_CONTAINER
#define CFAPI_OBJECT_PROP_CONTAINER
Definition: plugin.h:131
CFAPI_OBJECT_PROP_INVENTORY
#define CFAPI_OBJECT_PROP_INVENTORY
Definition: plugin.h:128
CFAPI_OBJECT_PROP_MAP
#define CFAPI_OBJECT_PROP_MAP
Definition: plugin.h:132
CFAPI_MAP_PROP_FLAGS
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:249
object_set_msg
void object_set_msg(object *op, const char *msg)
Definition: object.c:4806
CFAPI_MAP_PROP_DARKNESS
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:258
diamondslots.message
string message
Definition: diamondslots.py:57
CFAPI_MAP_PROP_PLAYERS
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:256
animations_struct
Definition: face.h:25
FLAG_REMOVED
#define FLAG_REMOVED
Definition: define.h:232
CFAPI_OBJECT_PROP_RUN_AWAY
#define CFAPI_OBJECT_PROP_RUN_AWAY
Definition: plugin.h:178
PERM_EXP
#define PERM_EXP(exptotal)
Definition: global.h:228
Settings::disabled_plugins
linked_char * disabled_plugins
Definition: global.h:321
CFAPI_SINT64
#define CFAPI_SINT64
Definition: plugin.h:76
CFAPI_PLAYER_PROP_TRANSPORT
#define CFAPI_PLAYER_PROP_TRANSPORT
Definition: plugin.h:242
llevInfo
@ llevInfo
Definition: logger.h:12
dirent
#define dirent
Definition: xdir.h:12
plugins_list
crossfire_plugin * plugins_list
Definition: plugins.c:245
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
get_region_by_map
region * get_region_by_map(mapstruct *m)
Definition: region.c:74
CFAPI_PARTY_PROP_PLAYER
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:277
CFAPI_PMAP
#define CFAPI_PMAP
Definition: plugin.h:66
CFAPI_PLAYER_QUEST_GET_STATE
#define CFAPI_PLAYER_QUEST_GET_STATE
Definition: plugin.h:245
cfapi_log
static void cfapi_log(int *type,...)
Definition: plugins.c:949
CFAPI_MAP_PROP_DIFFICULTY
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:250
find_archetype_by_object_name
archetype * find_archetype_by_object_name(const char *name)
Definition: arch.cpp:55
regiondef::parent
struct regiondef * parent
Definition: map.h:285
cfapi_object_merge
static void cfapi_object_merge(int *type,...)
Definition: plugins.c:3405
CFAPI_OBJECT_PROP_ANIMATION
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:222
CFAPI_OBJECT_PROP_INT
#define CFAPI_OBJECT_PROP_INT
Definition: plugin.h:205
CFAPI_OBJECT_PROP_SP
#define CFAPI_OBJECT_PROP_SP
Definition: plugin.h:211
party_get_password
const char * party_get_password(const partylist *party)
Definition: party.c:232
regiondef::jailmap
char * jailmap
Definition: map.h:296
cfapi_system_find_face
static void cfapi_system_find_face(int *type,...)
Definition: plugins.c:580
initPlugins
void initPlugins(void)
Definition: plugins.c:4519
CFAPI_PLAYER_QUEST_SET_STATE
#define CFAPI_PLAYER_QUEST_SET_STATE
Definition: plugin.h:246
map_find_by_archetype
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Definition: object.c:3076
generate_random_map
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout)
Definition: random_map.c:74
CFAPI_OBJECT_PROP_NAME
#define CFAPI_OBJECT_PROP_NAME
Definition: plugin.h:134
CFAPI_OBJECT_PROP_EXP_MULTIPLIER
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER
Definition: plugin.h:184
cfapi_map_trigger_connected
static void cfapi_map_trigger_connected(int *type,...)
Definition: plugins.c:3574
cfapi_get_weekday_name
static void cfapi_get_weekday_name(int *type,...)
Definition: plugins.c:858
reputation.victim
victim
Definition: reputation.py:14
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
Definition: plugin.h:127
timers.h
P_NEED_UPDATE
#define P_NEED_UPDATE
Definition: map.h:240
cfapi_system_remove_string
static void cfapi_system_remove_string(int *type,...)
Definition: plugins.c:684
CFAPI_OBJECT_PROP_HEAD
#define CFAPI_OBJECT_PROP_HEAD
Definition: plugin.h:130
CFAPI_PARCH
#define CFAPI_PARCH
Definition: plugin.h:69
check_spell_known
object * check_spell_known(object *op, const char *name)
Definition: spell_util.c:393
f_plug_event
int(* f_plug_event)(int *type,...)
Definition: events.h:60
object_set_cheat
void object_set_cheat(object *op)
Definition: object.c:3232
give.op
op
Definition: give.py:33
object_find_free_spot
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
Definition: object.c:3517
autojail.value
value
Definition: autojail.py:6
get_season_name
const char * get_season_name(const int index)
Definition: time.c:123
board.author
author
Definition: board.py:59
pay_for_item
int pay_for_item(object *op, object *pl, uint64_t reduction)
Definition: shop.c:541
CFAPI_PLAYER_PROP_BED_MAP
#define CFAPI_PLAYER_PROP_BED_MAP
Definition: plugin.h:237
CFAPI_INT16
#define CFAPI_INT16
Definition: plugin.h:74
shop.h
trigger_connected
void trigger_connected(objectlink *ol, object *cause, const int state)
Definition: button.c:41
CFAPI_OBJECT_PROP_WC
#define CFAPI_OBJECT_PROP_WC
Definition: plugin.h:208
plugins_dlsym
#define plugins_dlsym(lib, name)
Definition: plugin.h:118
CFAPI_OBJECT_PROP_GLOW_RADIUS
#define CFAPI_OBJECT_PROP_GLOW_RADIUS
Definition: plugin.h:173
query_money
uint64_t query_money(const object *op)
Definition: shop.c:470
cfapi_object_get_key
static void cfapi_object_get_key(int *type,...)
Definition: plugins.c:1448
esrv_update_item
void esrv_update_item(int flags, object *pl, object *op)
Definition: main.c:360
CFAPI_OBJECT_PROP_PATH_REPELLED
#define CFAPI_OBJECT_PROP_PATH_REPELLED
Definition: plugin.h:155
query_base_name
void query_base_name(const object *op, int plural, char *buf, size_t size)
Definition: item.c:685
CFAPI_OBJECT_PROP_CON
#define CFAPI_OBJECT_PROP_CON
Definition: plugin.h:203
diamondslots.y
y
Definition: diamondslots.py:16
copy_message
static void copy_message(object *op, const char *msg)
Definition: plugins.c:2301
CFAPI_STRING
#define CFAPI_STRING
Definition: plugin.h:64
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
can_pay
int can_pay(object *pl)
Definition: shop.c:830
LIBPTRTYPE
#define LIBPTRTYPE
Definition: plugin.h:90
CFAPI_OBJECT_PROP_GP
#define CFAPI_OBJECT_PROP_GP
Definition: plugin.h:212
buf
StringBuffer * buf
Definition: readable.c:1606
CFAPI_OBJECT_PROP_MAGICAL
#define CFAPI_OBJECT_PROP_MAGICAL
Definition: plugin.h:192
change_exp
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Definition: living.c:2168
CFAPI_OBJECT_PROP_LAST_SP
#define CFAPI_OBJECT_PROP_LAST_SP
Definition: plugin.h:163
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2828
player_arrest
int player_arrest(object *who)
Definition: c_wiz.c:795
cfapi_get_season_name
static void cfapi_get_season_name(int *type,...)
Definition: plugins.c:846
update_all_los
void update_all_los(const mapstruct *map, int x, int y)
Definition: los.c:536
find_player_partial_name
player * find_player_partial_name(const char *plname)
Definition: player.c:111
object_update_speed
void object_update_speed(object *op)
Definition: object.c:1311
CFAPI_OBJECT_PROP_MATERIAL
#define CFAPI_OBJECT_PROP_MATERIAL
Definition: plugin.h:157
CFAPI_OBJECT_PROP_DURATION
#define CFAPI_OBJECT_PROP_DURATION
Definition: plugin.h:231
cfapi_object_find_by_name
static void cfapi_object_find_by_name(int *type,...)
Definition: plugins.c:3854
CFAPI_OBJECT_PROP_MOVE_STATUS
#define CFAPI_OBJECT_PROP_MOVE_STATUS
Definition: plugin.h:181
object_get_env_recursive
object * object_get_env_recursive(object *op)
Definition: object.c:583
CFAPI_OBJECT_PROP_OTHER_ARCH
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:186
cfapi_system_find_animation
static void cfapi_system_find_animation(int *type,...)
Definition: plugins.c:559
CFAPI_OBJECT_PROP_OB_ABOVE
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:124
knowledge_player_knows
int knowledge_player_knows(const player *pl, const char *knowledge)
Definition: knowledge.c:1292
CFAPI_MAP_PROP_ENTER_Y
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:262
cfapi_object_teleport
static void cfapi_object_teleport(int *type,...)
Definition: plugins.c:4094
quest_start
void quest_start(player *pl, sstring quest_code, int state)
Definition: quest.c:1065
CFAPI_OBJECT_PROP_LAST_HEAL
#define CFAPI_OBJECT_PROP_LAST_HEAL
Definition: plugin.h:162