Crossfire Server, Trunk
plugins.cpp
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 #include "assets.h"
42 #include "AssetsManager.h"
43 
44 #ifdef WIN32
45 #include "libloaderapi.h"
46 #endif
47 
49 #define NR_OF_HOOKS (sizeof(plug_hooks)/sizeof(*plug_hooks))
50 
51 static void cfapi_cost_string_from_value(int *type, ...);
52 static void cfapi_system_find_animation(int *type, ...);
53 static void cfapi_system_find_face(int *type, ...);
54 static void cfapi_system_strdup_local(int *type, ...);
55 static void cfapi_system_register_global_event(int *type, ...);
56 static void cfapi_system_unregister_global_event(int *type, ...);
57 static void cfapi_system_add_string(int *type, ...);
58 static void cfapi_system_remove_string(int *type, ...);
59 static void cfapi_system_find_string(int *type, ...);
60 static void cfapi_system_check_path(int *type, ...);
61 static void cfapi_system_re_cmp(int *type, ...);
62 static void cfapi_system_directory(int *type, ...);
63 static void cfapi_get_time(int *type, ...);
64 static void cfapi_get_season_name(int *type, ...);
65 static void cfapi_get_weekday_name(int *type, ...);
66 static void cfapi_get_month_name(int *type, ...);
67 static void cfapi_get_periodofday_name(int *type, ...);
68 static void cfapi_timer_create(int *type, ...);
69 static void cfapi_timer_destroy(int *type, ...);
70 static void cfapi_log(int *type, ...);
71 static void cfapi_map_get_map(int *type, ...);
72 static void cfapi_map_has_been_loaded(int *type, ...);
73 static void cfapi_map_create_path(int *type, ...);
74 static void cfapi_map_get_map_property(int *type, ...);
75 static void cfapi_map_set_map_property(int *type, ...);
76 static void cfapi_map_out_of_map(int *type, ...);
77 static void cfapi_map_update_position(int *type, ...);
78 static void cfapi_map_delete_map(int *type, ...);
79 static void cfapi_map_message(int *type, ...);
80 static void cfapi_map_get_object_at(int *type, ...);
81 static void cfapi_map_find_by_archetype_name(int *type, ...);
82 static void cfapi_map_change_light(int *type, ...);
83 static void cfapi_object_move(int *type, ...);
84 static void cfapi_object_get_key(int *type, ...);
85 static void cfapi_object_set_key(int *type, ...);
86 static void cfapi_object_get_property(int *type, ...);
87 static void cfapi_object_set_property(int *type, ...);
88 static void cfapi_object_apply_below(int *type, ...);
89 static void cfapi_object_apply(int *type, ...);
90 static void cfapi_object_identify(int *type, ...);
91 static void cfapi_object_describe(int *type, ...);
92 static void cfapi_object_drain(int *type, ...);
93 static void cfapi_object_remove_depletion(int *type, ...);
94 static void cfapi_object_fix(int *type, ...);
95 static void cfapi_object_give_skill(int *type, ...);
96 static void cfapi_object_transmute(int *type, ...);
97 static void cfapi_object_remove(int *type, ...);
98 static void cfapi_object_delete(int *type, ...);
99 static void cfapi_object_clone(int *type, ...);
100 static void cfapi_object_create(int *type, ...);
101 static void cfapi_object_insert(int *type, ...);
102 static void cfapi_object_split(int *type, ...);
103 static void cfapi_object_merge(int *type, ...);
104 static void cfapi_object_distance(int *type, ...);
105 static void cfapi_object_update(int *type, ...);
106 static void cfapi_object_clear(int *type, ...);
107 static void cfapi_object_reset(int *type, ...);
108 static void cfapi_object_clean_object(int *type, ...);
109 static void cfapi_object_on_same_map(int *type, ...);
110 static void cfapi_object_spring_trap(int *type, ...);
111 static void cfapi_object_check_trigger(int *type, ...);
112 static void cfapi_map_trigger_connected(int *type, ...);
113 static void cfapi_object_query_money(int *type, ...);
114 static void cfapi_object_cast(int *type, ...);
115 static void cfapi_object_learn_spell(int *type, ...);
116 static void cfapi_object_forget_spell(int *type, ...);
117 static void cfapi_object_check_spell(int *type, ...);
118 static void cfapi_object_pay_amount(int *type, ...);
119 static void cfapi_object_pay_item(int *type, ...);
120 static void cfapi_object_transfer(int *type, ...);
121 static void cfapi_object_find_archetype_inside(int *type, ...);
122 static void cfapi_object_find_by_arch_name(int *type, ...);
123 static void cfapi_object_find_by_name(int *type, ...);
124 static void cfapi_object_drop(int *type, ...);
125 static void cfapi_object_change_abil(int *type, ...);
126 static void cfapi_object_say(int *type, ...);
127 static void cfapi_player_find(int *type, ...);
128 static void cfapi_player_message(int *type, ...);
129 static void cfapi_object_change_exp(int *type, ...);
130 static void cfapi_player_can_pay(int *type, ...);
131 static void cfapi_player_knowledge(int *type, ...);
132 static void cfapi_object_teleport(int *type, ...);
133 static void cfapi_object_pickup(int *type, ...);
134 static void cfapi_archetype_get_property(int *type, ...);
135 static void cfapi_party_get_property(int *type, ...);
136 static void cfapi_region_get_property(int *type, ...);
137 static void cfapi_friendlylist_get_next(int *type, ...);
138 static void cfapi_set_random_map_variable(int *type, ...);
139 static void cfapi_generate_random_map(int *type, ...);
140 static void cfapi_object_user_event(int *type, ...);
141 static void cfapi_player_quest(int *type, ...);
142 static void cfapi_object_perm_exp(int *type, ...);
143 static void cfapi_register_command(int *type, ...);
144 static void cfapi_unregister_command(int *type, ...);
145 static void cfapi_system_get_object_vector(int *type, ...);
146 static void cfapi_system_get_map_vector(int *type, ...);
147 static void cfapi_system_get_archetype_vector(int *type, ...);
148 static void cfapi_system_get_party_vector(int *type, ...);
149 static void cfapi_system_get_region_vector(int *type, ...);
150 
154 static const hook_entry plug_hooks[] = {
155  { cfapi_system_add_string, 0, "cfapi_system_add_string" },
156  { cfapi_system_register_global_event, 1, "cfapi_system_register_global_event" },
157  { cfapi_system_remove_string, 2, "cfapi_system_remove_string" },
158  { cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event" },
159  { cfapi_system_check_path, 4, "cfapi_system_check_path" },
160  { cfapi_system_re_cmp, 5, "cfapi_system_re_cmp" },
161  { cfapi_system_strdup_local, 6, "cfapi_system_strdup_local" },
162  { cfapi_system_directory, 7, "cfapi_system_directory" },
163  { cfapi_system_find_animation, 8, "cfapi_system_find_animation" },
164  { cfapi_object_clean_object, 9, "cfapi_object_clean_object" },
165  { cfapi_object_on_same_map, 10, "cfapi_object_on_same_map" },
166  { cfapi_object_get_key, 11, "cfapi_object_get_key" },
167  { cfapi_object_set_key, 12, "cfapi_object_set_key" },
168  { cfapi_object_get_property, 13, "cfapi_object_get_property" },
169  { cfapi_object_set_property, 14, "cfapi_object_set_property" },
170  { cfapi_object_apply, 15, "cfapi_object_apply" },
171  { cfapi_object_identify, 16, "cfapi_object_identify" },
172  { cfapi_object_describe, 17, "cfapi_object_describe" },
173  { cfapi_object_drain, 18, "cfapi_object_drain" },
174  { cfapi_object_fix, 19, "cfapi_object_fix" },
175  { cfapi_object_give_skill, 20, "cfapi_object_give_skill" },
176  { cfapi_object_transmute, 21, "cfapi_object_transmute" },
177  { cfapi_object_remove, 22, "cfapi_object_remove" },
178  { cfapi_object_delete, 23, "cfapi_object_delete" },
179  { cfapi_object_clone, 24, "cfapi_object_clone" },
180  { cfapi_object_create, 26, "cfapi_object_create" },
181  { cfapi_object_insert, 27, "cfapi_object_insert" },
182  { cfapi_object_split, 28, "cfapi_object_split" },
183  { cfapi_object_merge, 29, "cfapi_object_merge" },
184  { cfapi_object_distance, 30, "cfapi_object_distance" },
185  { cfapi_object_update, 31, "cfapi_object_update" },
186  { cfapi_object_clear, 32, "cfapi_object_clear" },
187  { cfapi_object_reset, 33, "cfapi_object_reset" },
188  { cfapi_object_spring_trap, 35, "cfapi_object_spring_trap" },
189  { cfapi_object_check_trigger, 36, "cfapi_object_check_trigger" },
190  { cfapi_object_query_money, 38, "cfapi_object_query_money" },
191  { cfapi_object_cast, 39, "cfapi_object_cast" },
192  { cfapi_object_learn_spell, 40, "cfapi_object_learn_spell" },
193  { cfapi_object_forget_spell, 41, "cfapi_object_forget_spell" },
194  { cfapi_object_check_spell, 42, "cfapi_object_check_spell" },
195  { cfapi_object_pay_amount, 43, "cfapi_object_pay_amount" },
196  { cfapi_object_pay_item, 44, "cfapi_object_pay_item" },
197  { cfapi_object_transfer, 45, "cfapi_object_transfer" },
198  { cfapi_object_drop, 46, "cfapi_object_drop" },
199  { cfapi_object_change_abil, 47, "cfapi_object_change_abil" },
200  { cfapi_object_find_archetype_inside, 48, "cfapi_object_find_archetype_inside" },
201  { cfapi_object_say, 49, "cfapi_object_say" },
202  { cfapi_map_get_map, 50, "cfapi_map_get_map" },
203  { cfapi_map_has_been_loaded, 51, "cfapi_map_has_been_loaded" },
204  { cfapi_map_create_path, 52, "cfapi_map_create_path" },
205  { cfapi_map_get_map_property, 53, "cfapi_map_get_property" },
206  { cfapi_map_set_map_property, 54, "cfapi_map_set_property" },
207  { cfapi_map_out_of_map, 55, "cfapi_map_out_of_map" },
208  { cfapi_map_update_position, 56, "cfapi_map_update_position" },
209  { cfapi_map_delete_map, 57, "cfapi_map_delete_map" },
210  { cfapi_map_message, 58, "cfapi_map_message" },
211  { cfapi_map_get_object_at, 59, "cfapi_map_get_object_at" },
212  { cfapi_map_change_light, 60, "cfapi_map_change_light" },
213  { cfapi_map_find_by_archetype_name, 61, "cfapi_map_find_by_archetype_name" },
214  { cfapi_player_find, 62, "cfapi_player_find" },
215  { cfapi_player_message, 63, "cfapi_player_message" },
216  { cfapi_object_change_exp, 64, "cfapi_object_change_exp" },
217  { cfapi_object_teleport, 65, "cfapi_object_teleport" },
218  { cfapi_object_pickup, 67, "cfapi_object_pickup" },
219  { cfapi_object_move, 68, "cfapi_object_move" },
220  { cfapi_object_apply_below, 69, "cfapi_object_apply_below" },
221  { cfapi_generate_random_map, 70, "cfapi_generate_random_map" },
222  { cfapi_archetype_get_property, 71, "cfapi_archetype_get_property" },
223  { cfapi_party_get_property, 72, "cfapi_party_get_property" },
224  { cfapi_region_get_property, 73, "cfapi_region_get_property" },
225  { cfapi_player_can_pay, 74, "cfapi_player_can_pay" },
226  { cfapi_log, 75, "cfapi_log" },
227  { cfapi_get_time, 76, "cfapi_system_get_time" },
228  { cfapi_timer_create, 77, "cfapi_system_timer_create" },
229  { cfapi_timer_destroy, 78, "cfapi_system_timer_destroy" },
230  { cfapi_friendlylist_get_next, 79, "cfapi_friendlylist_get_next" },
231  { cfapi_set_random_map_variable, 80, "cfapi_set_random_map_variable" },
232  { cfapi_system_find_face, 81, "cfapi_system_find_face" },
233  { cfapi_get_season_name, 82, "cfapi_system_get_season_name" },
234  { cfapi_get_month_name, 83, "cfapi_system_get_month_name" },
235  { cfapi_get_weekday_name, 84, "cfapi_system_get_weekday_name" },
236  { cfapi_get_periodofday_name, 85, "cfapi_system_get_periodofday_name" },
237  { cfapi_map_trigger_connected, 86, "cfapi_map_trigger_connected" },
238  { cfapi_object_user_event, 87, "cfapi_object_user_event" },
239  { cfapi_system_find_string, 88, "cfapi_system_find_string" },
240  { cfapi_cost_string_from_value, 90, "cfapi_cost_string_from_value" },
241  { cfapi_player_quest, 91, "cfapi_player_quest" },
242  { cfapi_object_remove_depletion, 92, "cfapi_object_remove_depletion" },
243  { cfapi_object_find_by_arch_name, 93, "cfapi_object_find_by_arch_name" },
244  { cfapi_object_find_by_name, 94, "cfapi_object_find_by_name" },
245  { cfapi_player_knowledge, 95, "cfapi_player_knowledge" },
246  { cfapi_object_perm_exp, 96, "cfapi_object_perm_exp" },
247  { cfapi_register_command, 97, "cfapi_register_command" },
248  { cfapi_unregister_command, 98, "cfapi_unregister_command" },
249  { cfapi_system_get_object_vector, 99, "cfapi_get_object_vector" },
250  { cfapi_system_get_map_vector, 100, "cfapi_get_map_vector" },
251  { cfapi_system_get_archetype_vector, 101, "cfapi_get_archetype_vector" },
252  { cfapi_system_get_party_vector, 102, "cfapi_get_party_vector" },
253  { cfapi_system_get_region_vector, 103, "cfapi_get_region_vector" },
254 };
255 
257 std::vector<crossfire_plugin *> plugins_list;
258 
259 /*****************************************************************************/
260 /* NEW PLUGIN STUFF STARTS HERE */
261 /*****************************************************************************/
262 
268 static crossfire_plugin *plugins_find_plugin(const char *id) {
269  for (crossfire_plugin *plugin : plugins_list) {
270  if (!strcmp(id, plugin->id)) {
271  return plugin;
272  }
273  }
274  return NULL;
275 }
276 
277 #ifdef WIN32
278 static const char *plugins_dlerror(void)
279 {
280  static char buf[256];
281  DWORD err;
282  char *p;
283 
284  err = GetLastError();
285  if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof (buf), NULL) == 0)
286  snprintf(buf, sizeof (buf), "error %lu", err);
287  p = strchr(buf, '\0');
288  while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
289  p--;
290  *p = '\0';
291  return buf;
292 }
293 
294 #endif /* WIN32 */
295 
301 static void send_changed_object(object *op) {
302  object *tmp;
303  player *pl;
304 
305  if (op->env != NULL) {
307  if (!tmp) {
308  for (pl = first_player; pl; pl = pl->next)
309  if (pl->ob->container == op->env)
310  break;
311  if (pl)
312  tmp = pl->ob;
313  else
314  tmp = NULL;
315  }
316  if (tmp)
317  /* We don't know what changed, so we send everything. */
319  } else {
321  if (tmp->type == PLAYER)
322  tmp->contr->socket->update_look = 1;
324  }
325 }
326 
327 static void cfapi_get_hooks(int *type, ...) {
328  va_list args;
329  int request_type;
330  char *buf;
331  f_plug_api *rapi;
332 
333  *type = CFAPI_NONE;
334 
335  va_start(args, type);
336  request_type = va_arg(args, int);
337  if (request_type == 0) { /* By nr */
338  size_t fid;
339 
340  fid = va_arg(args, int);
341  rapi = va_arg(args, f_plug_api *);
342  if (fid >= NR_OF_HOOKS) {
343  *rapi = NULL;
344  *type = CFAPI_NONE;
345  } else {
346  *rapi = plug_hooks[fid].func;
347  *type = CFAPI_FUNC;
348  }
349  } else { /* by name */
350  size_t i;
351 
352  buf = va_arg(args, char *);
353  rapi = va_arg(args, f_plug_api *);
354  *rapi = NULL;
355  *type = CFAPI_NONE;
356  for (i = 0; i < NR_OF_HOOKS; i++) {
357  if (!strcmp(buf, plug_hooks[i].fname)) {
358  *rapi = plug_hooks[i].func;
359  *type = CFAPI_FUNC;
360  break;
361  }
362  }
363  }
364  va_end(args);
365 }
366 
373 int plugins_init_plugin(const char *libfile) {
374  LIBPTRTYPE ptr;
375  f_plug_init initfunc;
376  f_plug_property propfunc;
377  f_plug_event eventfunc;
378  f_plug_postinit postfunc;
379  f_plug_postinit closefunc;
380  int i;
381  crossfire_plugin *cp;
382  char *svn_rev;
383 
384 
385  /* Open the plugin lib and load the required functions */
386  ptr = plugins_dlopen(libfile);
387  if (ptr == NULL) {
388  LOG(llevError, "Error trying to load %s: %s\n", libfile, plugins_dlerror());
389  return -1;
390  }
391  svn_rev = (char*) plugins_dlsym(ptr, "SvnRevPlugin");
392  if (svn_rev == NULL) {
393  LOG(llevError, "Unable to find SvnRevPlugin in %s\n", libfile);
394  plugins_dlclose(ptr);
395  return -1;
396  }
397  if (settings.ignore_plugin_compatibility == 0 && strcmp(svn_rev, SVN_REV)) {
398  LOG(llevError, "Version mismatch in in %s (%s != %s)\n", libfile, svn_rev, SVN_REV);
399  plugins_dlclose(ptr);
400  return -1;
401  }
402 
403  initfunc = (f_plug_init)plugins_dlsym(ptr, "initPlugin");
404  if (initfunc == NULL) {
405  LOG(llevError, "Plugin error while requesting %s.initPlugin: %s\n", libfile, plugins_dlerror());
406  plugins_dlclose(ptr);
407  return -1;
408  }
409  propfunc = (f_plug_property)plugins_dlsym(ptr, "getPluginProperty");
410  if (propfunc == NULL) {
411  LOG(llevError, "Plugin error while requesting %s.getPluginProperty: %s\n", libfile, plugins_dlerror());
412  plugins_dlclose(ptr);
413  return -1;
414  }
415  eventfunc = (f_plug_event)plugins_dlsym(ptr, "eventListener");
416  if (eventfunc == NULL) {
417  LOG(llevError, "Plugin error while requesting %s.eventListener: %s\n", libfile, plugins_dlerror());
418  plugins_dlclose(ptr);
419  return -1;
420  }
421  postfunc = (f_plug_postinit)plugins_dlsym(ptr, "postInitPlugin");
422  if (postfunc == NULL) {
423  LOG(llevError, "Plugin error while requesting %s.postInitPlugin: %s\n", libfile, plugins_dlerror());
424  plugins_dlclose(ptr);
425  return -1;
426  }
427  closefunc = (f_plug_postinit)plugins_dlsym(ptr, "closePlugin");
428  if (closefunc == NULL) {
429  LOG(llevError, "Plugin error while requesting %s.closePlugin: %s\n", libfile, plugins_dlerror());
430  plugins_dlclose(ptr);
431  return -1;
432  }
433  i = initfunc("2.0", cfapi_get_hooks);
434  cp = static_cast<crossfire_plugin *>(malloc(sizeof(crossfire_plugin)));
435  for (i = 0; i < NR_EVENTS; i++)
436  cp->global_registration[i] = 0;
437  cp->propfunc = propfunc;
438  cp->closefunc = closefunc;
439  cp->libptr = ptr;
440  propfunc(&i, "Identification", cp->id, sizeof(cp->id));
441  propfunc(&i, "FullName", cp->fullname, sizeof(cp->fullname));
442  events_register_object_handler(cp->id, eventfunc);
443  plugins_list.push_back(cp);
444  postfunc();
445  return 0;
446 }
447 
454 int plugins_remove_plugin(const char *id) {
455  auto plugin = std::find_if(plugins_list.begin(), plugins_list.end(), [&id] (const auto cp) { return strcmp(id, cp->id) == 0; });
456  if (plugin != plugins_list.end()) {
457  crossfire_plugin *cp = *plugin;
458  plugins_list.erase(plugin);
459  for (int eventcode = 0; eventcode < NR_EVENTS; eventcode++) {
460  if (cp->global_registration[eventcode]) {
461  events_unregister_global_handler(eventcode, cp->global_registration[eventcode]);
462  }
463  }
465  if (cp->closefunc)
466  cp->closefunc();
467  plugins_dlclose(cp->libptr);
468  free(cp);
469  return 0;
470  }
471  return -1;
472 }
473 
479 void plugins_display_list(object *op) {
481  "List of loaded plugins:\n-----------------------");
482 
483  for (crossfire_plugin *cp : plugins_list) {
485  "%s, %s",
486  cp->id, cp->fullname);
487  }
488 }
489 
490 /* SYSTEM-RELATED HOOKS */
491 
497 static void cfapi_cost_string_from_value(int *type, ...) {
498  uint64_t cost;
499  char *buffer, *final;
500  int length, largest_coin;
501  va_list args;
502 
503  va_start(args, type);
504  cost = va_arg(args, uint64_t);
505  largest_coin = va_arg(args, int);
506  buffer = va_arg(args, char*);
507  length = va_arg(args, int);
508  va_end(args);
509 
510  *type = CFAPI_NONE;
511 
512  if (length < 1)
513  return;
514 
515  final = cost_string_from_value(cost, largest_coin);
516 
517  strncpy(buffer, final, length - 1);
518  buffer[length - 1] = '\0';
519  free(final);
520 }
521 
527 static void cfapi_system_find_animation(int *type, ...) {
528  va_list args;
529  const char *name;
530  int *num;
531  const Animations *anim;
532 
533  va_start(args, type);
534  name = va_arg(args, const char *);
535  num = va_arg(args, int *);
536  va_end(args);
537 
539  (*num) = anim ? anim->num : 0;
540  *type = CFAPI_INT;
541 }
542 
548 static void cfapi_system_find_face(int *type, ...) {
549  va_list args;
550  const char *face;
551  int error;
552  int *num;
553  const Face *f;
554 
555  va_start(args, type);
556  face = va_arg(args, const char *);
557  error = va_arg(args, int);
558  num = va_arg(args, int *);
559  va_end(args);
560 
561  f = try_find_face(face, get_face_by_id(error));
562  (*num) = f ? f->number : 0;
563  *type = CFAPI_INT;
564 }
565 
571 static void cfapi_system_strdup_local(int *type, ...) {
572  va_list args;
573  const char *txt;
574  char **ret;
575 
576  va_start(args, type);
577  txt = va_arg(args, const char *);
578  ret = va_arg(args, char **);
579  va_end(args);
580 
581  *ret = strdup_local(txt);
582  *type = CFAPI_STRING;
583 }
584 
585 static void cfapi_system_register_global_event(int *type, ...) {
586  va_list args;
587  int eventcode;
588  char *pname;
589  f_plug_event hook;
590  crossfire_plugin *cp;
591 
592  va_start(args, type);
593  eventcode = va_arg(args, int);
594  pname = va_arg(args, char *);
595  hook = va_arg(args, f_plug_event);
596  va_end(args);
597 
598  *type = CFAPI_NONE;
599 
600  cp = plugins_find_plugin(pname);
601  if (!cp->global_registration[eventcode]) {
602  cp->global_registration[eventcode] = events_register_global_handler(eventcode, hook);
603  }
604 }
605 
607  va_list args;
608  int eventcode;
609  char *pname;
610  crossfire_plugin *cp;
611 
612  va_start(args, type);
613  eventcode = va_arg(args, int);
614  pname = va_arg(args, char *);
615  va_end(args);
616 
617  *type = CFAPI_NONE;
618 
619  cp = plugins_find_plugin(pname);
620  if (cp->global_registration[eventcode]) {
621  events_unregister_global_handler(eventcode, cp->global_registration[eventcode]);
622  cp->global_registration[eventcode] = 0;
623  }
624 }
625 
626 static void cfapi_system_get_object_vector(int *type, ...) {
627  va_list args;
628  va_start(args, type);
629  int property = va_arg(args, int);
630  std::vector<object *> *list = va_arg(args, std::vector<object *> *);
631 
633  switch (property) {
635  for (auto pl = first_player; pl ; pl = pl->next) {
636  list->push_back(pl->ob);
637  }
638  break;
640  auto f = get_next_friend(nullptr);
641  while (f) {
642  list->push_back(f);
643  f = get_next_friend(f);
644  }
645  break;
646  }
647  default:
648  assert(0);
649  }
650 
651  va_end(args);
652 }
653 
654 static void cfapi_system_get_map_vector(int *type, ...) {
655  va_list args;
656  va_start(args, type);
657  int property = va_arg(args, int);
658  std::vector<mapstruct *> *list = va_arg(args, std::vector<mapstruct *> *);
659 
661  if (property == CFAPI_SYSTEM_MAPS) {
662  for (auto map = first_map; map ; map = map->next) {
663  list->push_back(map);
664  }
665  }
666 
667  va_end(args);
668 }
669 
670 static void cfapi_system_get_archetype_vector(int *type, ...) {
671  va_list args;
672  va_start(args, type);
673  int property = va_arg(args, int);
674  std::vector<archetype *> *list = va_arg(args, std::vector<archetype *> *);
675 
677  if (property == CFAPI_SYSTEM_ARCHETYPES) {
678  getManager()->archetypes()->each([&] (const auto &arch) { list->push_back(arch); });
679  }
680 
681  va_end(args);
682 }
683 
684 static void cfapi_system_get_region_vector(int *type, ...) {
685  va_list args;
686  va_start(args, type);
687  int property = va_arg(args, int);
688  std::vector<region *> *list = va_arg(args, std::vector<region *> *);
689 
691  if (property == CFAPI_SYSTEM_REGIONS) {
692  region *first = region_get_next(nullptr);
693  while (first) {
694  list->push_back(first);
695  first = region_get_next(first);
696  }
697  }
698 
699  va_end(args);
700 }
701 
702 static void cfapi_system_get_party_vector(int *type, ...) {
703  va_list args;
704  va_start(args, type);
705  int property = va_arg(args, int);
706  std::vector<partylist *> *list = va_arg(args, std::vector<partylist *> *);
707 
709  if (property == CFAPI_SYSTEM_PARTIES) {
710  auto party = party_get_first();
711  while (party) {
712  list->push_back(party);
713  party = party_get_next(party);
714  }
715  }
716 
717  va_end(args);
718 }
719 
726 static void cfapi_system_add_string(int *type, ...) {
727  va_list args;
728  const char *str;
729  sstring *rv;
730 
731  va_start(args, type);
732  str = va_arg(args, const char *);
733  rv = va_arg(args, sstring *);
734  va_end(args);
735 
736  *rv = add_string(str);
737  *type = CFAPI_SSTRING;
738 }
739 
746 static void cfapi_system_remove_string(int *type, ...) {
747  va_list args;
748  sstring str;
749 
750  va_start(args, type);
751  str = va_arg(args, sstring);
752  va_end(args);
753 
754  free_string(str);
755  *type = CFAPI_NONE;
756 }
757 
764 static void cfapi_system_find_string(int *type, ...) {
765  va_list args;
766  const char *str;
767  sstring *rv;
768 
769  va_start(args, type);
770  str = va_arg(args, const char *);
771  rv = va_arg(args, sstring *);
772  va_end(args);
773 
774  *rv = find_string(str);
775  *type = CFAPI_SSTRING;
776 }
777 
783 static void cfapi_system_check_path(int *type, ...) {
784  va_list args;
785  const char *name;
786  int prepend_dir;
787  int *ret;
788 
789  va_start(args, type);
790 
791  name = va_arg(args, char *);
792  prepend_dir = va_arg(args, int);
793  ret = va_arg(args, int *);
794 
795  *ret = check_path(name, prepend_dir);
796 
797  va_end(args);
798  *type = CFAPI_INT;
799 }
800 
806 static void cfapi_system_re_cmp(int *type, ...) {
807  va_list args;
808  const char *str;
809  const char *regexp;
810  const char **rv;
811 
812  va_start(args, type);
813 
814  str = va_arg(args, char *);
815  regexp = va_arg(args, char *);
816  rv = va_arg(args, const char **);
817 
818  *rv = re_cmp(str, regexp);
819 
820  va_end(args);
821  *type = CFAPI_STRING;
822 }
823 
824 static void cfapi_system_directory(int *type, ...) {
825  va_list args;
826  int dirtype;
827  const char **str;
828 
829  va_start(args, type);
830 
831  dirtype = va_arg(args, int);
832  str = va_arg(args, const char **);
833  va_end(args);
834 
835  *type = CFAPI_STRING;
836 
837  switch (dirtype) {
838  case 0:
839  *str = settings.mapdir;
840  break;
841 
842  case 1:
844  break;
845 
846  case 2:
847  *str = settings.tmpdir;
848  break;
849 
850  case 3:
851  *str = settings.confdir;
852  break;
853 
854  case 4:
855  *str = settings.localdir;
856  break;
857 
858  case 5:
860  break;
861 
862  case 6:
863  *str = settings.datadir;
864  break;
865 
866  default:
867  *str = NULL;
868  }
869 }
870 
877 static void cfapi_get_time(int *type, ...) {
878  va_list args;
879  timeofday_t *tod;
880 
881  va_start(args, type);
882  tod = va_arg(args, timeofday_t *);
883  va_end(args);
884 
885  get_tod(tod);
886  *type = CFAPI_NONE;
887 }
888 
889 #define string_get_int(name) \
890  va_list args; \
891  int index; \
892  const char **str; \
893  va_start(args, type); \
894  index = va_arg(args, int); \
895  str = va_arg(args, const char **); \
896  va_end(args); \
897  *str = name(index); \
898  *type = CFAPI_STRING; \
899 
900 
908 static void cfapi_get_season_name(int *type, ...) {
910 }
911 
920 static void cfapi_get_weekday_name(int *type, ...) {
922 }
923 
932 static void cfapi_get_month_name(int *type, ...) {
934 }
935 
944 static void cfapi_get_periodofday_name(int *type, ...) {
946 }
947 
959 static void cfapi_timer_create(int *type, ...) {
960  va_list args;
961  int res;
962  object *ob;
963  long delay;
964  int mode;
965  int *timer;
966 
967  va_start(args, type);
968  ob = va_arg(args, object *);
969  delay = va_arg(args, long);
970  mode = va_arg(args, int);
971  timer = va_arg(args, int *);
972  va_end(args);
973  *type = CFAPI_INT;
974 
975  *timer = cftimer_find_free_id();
976  if (*timer != TIMER_ERR_ID) {
977  res = cftimer_create(*timer, delay, ob, mode);
978  if (res != TIMER_ERR_NONE)
979  *timer = res;
980  }
981 }
982 
992 static void cfapi_timer_destroy(int *type, ...) {
993  va_list args;
994  int id;
995  int *err;
996 
997  va_start(args, type);
998  id = va_arg(args, int);
999  err = va_arg(args, int *);
1000  va_end(args);
1001  *type = CFAPI_INT;
1002 
1003  *err = cftimer_destroy(id);
1004 }
1005 
1011 static void cfapi_log(int *type, ...) {
1012  va_list args;
1013  LogLevel logLevel;
1014  const char *message;
1015 
1016  va_start(args, type);
1017  logLevel = static_cast<LogLevel>(va_arg(args, int));
1018  message = va_arg(args, const char *);
1019  LOG(logLevel, "%s", message);
1020  va_end(args);
1021 
1022  *type = CFAPI_NONE;
1023 }
1024 
1025 /* MAP RELATED HOOKS */
1026 
1035 static void cfapi_map_get_map(int *type, ...) {
1036  va_list args;
1037  mapstruct **ret;
1038  int ctype;
1039  int x, y;
1040  int16_t nx, ny;
1041  const char *name;
1042  mapstruct *m;
1043 
1044  va_start(args, type);
1045 
1046  ctype = va_arg(args, int);
1047 
1048  switch (ctype) {
1049  case 0:
1050  x = va_arg(args, int);
1051  y = va_arg(args, int);
1052  ret = va_arg(args, mapstruct **);
1053  *ret = get_empty_map(x, y);
1054  break;
1055 
1056  case 1:
1057  name = va_arg(args, const char *);
1058  x = va_arg(args, int);
1059  ret = va_arg(args, mapstruct **);
1060  *ret = ready_map_name(name, x);
1061  break;
1062 
1063  case 2:
1064  m = va_arg(args, mapstruct *);
1065  nx = va_arg(args, int);
1066  ny = va_arg(args, int);
1067  ret = va_arg(args, mapstruct **);
1068  *ret = get_map_from_coord(m, &nx, &ny);
1069  break;
1070 
1071  default:
1072  *type = CFAPI_NONE;
1073  va_end(args);
1074  return;
1075  break;
1076  }
1077  va_end(args);
1078  *type = CFAPI_PMAP;
1079 }
1080 
1086 static void cfapi_map_has_been_loaded(int *type, ...) {
1087  va_list args;
1088  mapstruct **map;
1089  char *string;
1090 
1091  va_start(args, type);
1092  string = va_arg(args, char *);
1093  map = va_arg(args, mapstruct **);
1094  *map = has_been_loaded(string);
1095  va_end(args);
1096  *type = CFAPI_PMAP;
1097 }
1098 
1104 static void cfapi_map_create_path(int *type, ...) {
1105  va_list args;
1106  int ctype, size;
1107  const char *str;
1108  char *name;
1109 
1110  va_start(args, type);
1111 
1112  ctype = va_arg(args, int);
1113  str = va_arg(args, const char *);
1114  name = va_arg(args, char *);
1115  size = va_arg(args, int);
1116  *type = CFAPI_STRING;
1117 
1118  switch (ctype) {
1119  case 0:
1120  create_pathname(str, name, size);
1121  break;
1122 
1123  case 1:
1125  break;
1126 
1127 /* case 2:
1128  rv = create_items_path(str);
1129  break;*/
1130 
1131  default:
1132  *type = CFAPI_NONE;
1133  break;
1134  }
1135  va_end(args);
1136 }
1137 
1138 static void cfapi_map_get_map_property(int *type, ...) {
1139  va_list args;
1140  mapstruct *map;
1141  int property;
1142 
1143  int *rint;
1144  mapstruct **rmap;
1145  sstring *rstr;
1146  region **rreg;
1147  int16_t *nx, *ny;
1148  int x, y;
1149 
1150  va_start(args, type);
1151 
1152  map = va_arg(args, mapstruct *);
1153  property = va_arg(args, int);
1154 
1155  switch (property) {
1156  case CFAPI_MAP_PROP_FLAGS:
1157  rmap = va_arg(args, mapstruct **);
1158  x = va_arg(args, int);
1159  y = va_arg(args, int);
1160  nx = va_arg(args, int16_t *);
1161  ny = va_arg(args, int16_t *);
1162  rint = va_arg(args, int *);
1163  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1164  *type = CFAPI_INT;
1165  break;
1166 
1168  rint = va_arg(args, int *);
1169  *rint = calculate_difficulty(map);
1170  *type = CFAPI_INT;
1171  break;
1172 
1173  case CFAPI_MAP_PROP_PATH:
1174  rstr = va_arg(args, sstring *);
1175  *rstr = map->path;
1176  *type = CFAPI_SSTRING;
1177  break;
1178 
1180  rstr = va_arg(args, sstring *);
1181  *rstr = map->tmpname;
1182  *type = CFAPI_SSTRING;
1183  break;
1184 
1185  case CFAPI_MAP_PROP_NAME:
1186  rstr = va_arg(args, sstring *);
1187  *rstr = map->name;
1188  *type = CFAPI_SSTRING;
1189  break;
1190 
1192  rint = va_arg(args, int *);
1193  *rint = map->reset_time;
1194  *type = CFAPI_INT;
1195  break;
1196 
1198  rint = va_arg(args, int *);
1199  *rint = map->reset_timeout;
1200  *type = CFAPI_INT;
1201  break;
1202 
1204  rint = va_arg(args, int *);
1205  *rint = map->players;
1206  *type = CFAPI_INT;
1207  break;
1208 
1210  rint = va_arg(args, int *);
1211  *rint = map->darkness;
1212  *type = CFAPI_INT;
1213  break;
1214 
1215  case CFAPI_MAP_PROP_WIDTH:
1216  rint = va_arg(args, int *);
1217  *rint = map->width;
1218  *type = CFAPI_INT;
1219  break;
1220 
1221  case CFAPI_MAP_PROP_HEIGHT:
1222  rint = va_arg(args, int *);
1223  *rint = map->height;
1224  *type = CFAPI_INT;
1225  break;
1226 
1228  rint = va_arg(args, int *);
1229  *rint = map->enter_x;
1230  *type = CFAPI_INT;
1231  break;
1232 
1234  rint = va_arg(args, int *);
1235  *rint = map->enter_y;
1236  *type = CFAPI_INT;
1237  break;
1238 
1240  rstr = va_arg(args, sstring *);
1241  *rstr = map->msg;
1242  *type = CFAPI_SSTRING;
1243  break;
1244 
1245  case CFAPI_MAP_PROP_NEXT:
1246  rmap = va_arg(args, mapstruct **);
1247  *rmap = map ? map->next : first_map;
1248  *type = CFAPI_PMAP;
1249  break;
1250 
1251  case CFAPI_MAP_PROP_REGION:
1252  rreg = va_arg(args, region **);
1253  *rreg = get_region_by_map(map);
1254  *type = CFAPI_PREGION;
1255  break;
1256 
1257  case CFAPI_MAP_PROP_UNIQUE:
1258  rint = va_arg(args, int *);
1259  *rint = map->unique;
1260  *type = CFAPI_INT;
1261  break;
1262 
1263  default:
1264  *type = CFAPI_NONE;
1265  break;
1266  }
1267  va_end(args);
1268 }
1269 
1270 static void cfapi_map_set_map_property(int *type, ...) {
1271  va_list args;
1272  mapstruct *map;
1273  int property;
1274  const char *buf;
1275 
1276  va_start(args, type);
1277 
1278  map = va_arg(args, mapstruct *);
1279  property = va_arg(args, int);
1280 
1281  switch (property) {
1282  case CFAPI_MAP_PROP_PATH:
1283  buf = va_arg(args, const char *);
1284  strlcpy(map->path, buf, sizeof(map->path));
1285  *type = CFAPI_STRING;
1286  break;
1287 
1288  default:
1289  *type = CFAPI_NONE;
1290  break;
1291  }
1292  va_end(args);
1293 }
1294 
1300 static void cfapi_map_out_of_map(int *type, ...) {
1301  va_list args;
1302  mapstruct *map;
1303  int x, y;
1304  int *rint;
1305 
1306  va_start(args, type);
1307  map = va_arg(args, mapstruct *);
1308  x = va_arg(args, int);
1309  y = va_arg(args, int);
1310  rint = va_arg(args, int *);
1311 
1312  *rint = out_of_map(map, x, y);
1313  va_end(args);
1314  *type = CFAPI_INT;
1315 }
1316 
1322 static void cfapi_map_update_position(int *type, ...) {
1323  va_list args;
1324  mapstruct *map;
1325  int x, y;
1326 
1327  va_start(args, type);
1328 
1329  map = va_arg(args, mapstruct *);
1330  x = va_arg(args, int);
1331  y = va_arg(args, int);
1332 
1333  update_position(map, x, y);
1334  va_end(args);
1335  *type = CFAPI_NONE;
1336 }
1337 
1338 static void cfapi_map_delete_map(int *type, ...) {
1339  va_list args;
1340  mapstruct *map;
1341  va_start(args, type);
1342 
1343  map = va_arg(args, mapstruct *);
1344 
1345  delete_map(map);
1346 
1347  va_end(args);
1348  *type = CFAPI_NONE;
1349 }
1350 
1351 static void cfapi_map_message(int *type, ...) {
1352  va_list args;
1353  mapstruct *map;
1354  const char *string;
1355  int color;
1356 
1357  va_start(args, type);
1358  map = va_arg(args, mapstruct *);
1359  string = va_arg(args, const char *);
1360  color = va_arg(args, int);
1361  va_end(args);
1362 
1363  /* function should be extended to take message types probably */
1365  *type = CFAPI_NONE;
1366 }
1367 
1373 static void cfapi_map_get_object_at(int *type, ...) {
1374  va_list args;
1375  mapstruct *map;
1376  int x, y;
1377  int16_t sx, sy;
1378  object **robj;
1379 
1380  va_start(args, type);
1381  map = va_arg(args, mapstruct *);
1382  x = va_arg(args, int);
1383  y = va_arg(args, int);
1384  robj = va_arg(args, object **);
1385  va_end(args);
1386 
1387  sx = x;
1388  sy = y;
1389  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1390  *robj = NULL;
1391  else
1392  *robj = GET_MAP_OB(map, sx, sy);
1393  *type = CFAPI_POBJECT;
1394 }
1395 
1402 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1403  va_list args;
1404  int x, y;
1405  mapstruct *map;
1406  char *msg;
1407  object **robj;
1408 
1409  va_start(args, type);
1410 
1411  msg = va_arg(args, char *);
1412  map = va_arg(args, mapstruct *);
1413  x = va_arg(args, int);
1414  y = va_arg(args, int);
1415  robj = va_arg(args, object **);
1416 
1417  va_end(args);
1418 
1420  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1421  *type = CFAPI_POBJECT;
1422 }
1423 
1429 static void cfapi_map_change_light(int *type, ...) {
1430  va_list args;
1431  int change;
1432  mapstruct *map;
1433  int *rint;
1434 
1435  va_start(args, type);
1436  map = va_arg(args, mapstruct *);
1437  change = va_arg(args, int);
1438  rint = va_arg(args, int *);
1439  va_end(args);
1440 
1441  *type = CFAPI_INT;
1442  *rint = change_map_light(map, change);
1443 }
1444 
1445 /* OBJECT-RELATED HOOKS */
1446 
1460 static void cfapi_object_move(int *type, ...) {
1461  va_list args;
1462  int kind;
1463  object *op;
1464  object *activator;
1465  player *pl;
1466  int direction;
1467  int *ret;
1468 
1469  va_start(args, type);
1470  kind = va_arg(args, int);
1471  switch (kind) {
1472  case 0:
1473  op = va_arg(args, object *);
1474  direction = va_arg(args, int);
1475  activator = va_arg(args, object *);
1476  ret = va_arg(args, int *);
1477  va_end(args);
1478  *ret = move_ob(op, direction, activator);
1479  break;
1480 
1481  case 1:
1482  pl = va_arg(args, player *);
1483  direction = va_arg(args, int);
1484  ret = va_arg(args, int *);
1485  va_end(args);
1486  *ret = move_player(pl->ob, direction);
1487  break;
1488 
1489  case 2:
1490  op = va_arg(args, object *);
1491  ret = va_arg(args, int *);
1492  va_end(args);
1493  *ret = player_arrest(op);
1494  break;
1495 
1496  default:
1497  // Just end the use of variable args. We got a wrong type.
1498  va_end(args);
1499  }
1500  *type = CFAPI_INT;
1501 }
1502 
1510 static void cfapi_object_get_key(int *type, ...) {
1511  va_list args;
1512  const char *keyname;
1513  const char **value;
1514  object *op;
1515 
1516  va_start(args, type);
1517  op = va_arg(args, object *);
1518  keyname = va_arg(args, const char *);
1519  value = va_arg(args, const char **);
1520  va_end(args);
1521 
1522  *value = object_get_value(op, keyname);
1523  *type = CFAPI_SSTRING;
1524 }
1525 
1532 static void cfapi_object_set_key(int *type, ...) {
1533  va_list args;
1534  const char *keyname;
1535  const char *value;
1536  int *ret;
1537  object *op;
1538  int add_key;
1539 
1540  va_start(args, type);
1541  op = va_arg(args, object *);
1542  keyname = va_arg(args, char *);
1543  value = va_arg(args, char *);
1544  add_key = va_arg(args, int);
1545  ret = va_arg(args, int *);
1546  va_end(args);
1547 
1548  *ret = object_set_value(op, keyname, value, add_key);
1549  *type = CFAPI_INT;
1550 }
1551 
1555 static void cfapi_object_get_property(int *type, ...) {
1556  va_list args;
1557  int property;
1558  object *op;
1559  int *rint;
1560  object **robject;
1561  mapstruct **rmap;
1562  float *rfloat;
1563  archetype **rarch;
1564  sstring *rsstring;
1565  char *rbuffer;
1566  int rbufsize;
1567  MoveType *rmove;
1568  int64_t *rint64;
1569  partylist **rparty;
1570  double *rdouble;
1571  long *rlong;
1572 
1573  va_start(args, type);
1574 
1575  op = va_arg(args, object *);
1576  property = va_arg(args, int);
1577  switch (property) {
1579  robject = va_arg(args, object **);
1580  *robject = op->above;
1581  *type = CFAPI_POBJECT;
1582  break;
1583 
1585  robject = va_arg(args, object **);
1586  *robject = op->below;
1587  *type = CFAPI_POBJECT;
1588  break;
1589 
1591  robject = va_arg(args, object **);
1592  *robject = op->active_next;
1593  *type = CFAPI_POBJECT;
1594  break;
1595 
1597  robject = va_arg(args, object **);
1598  *robject = op->active_prev;
1599  *type = CFAPI_POBJECT;
1600  break;
1601 
1603  robject = va_arg(args, object **);
1604  *robject = op->inv;
1605  *type = CFAPI_POBJECT;
1606  break;
1607 
1609  robject = va_arg(args, object **);
1610  *robject = op->env;
1611  *type = CFAPI_POBJECT;
1612  break;
1613 
1615  robject = va_arg(args, object **);
1616  *robject = op->head;
1617  *type = CFAPI_POBJECT;
1618  break;
1619 
1621  robject = va_arg(args, object **);
1622  *robject = op->container;
1623  *type = CFAPI_POBJECT;
1624  break;
1625 
1626  case CFAPI_OBJECT_PROP_MAP:
1627  rmap = va_arg(args, mapstruct **);
1628  *rmap = op->map;
1629  *type = CFAPI_PMAP;
1630  break;
1631 
1633  rint = va_arg(args, int *);
1634  *rint = op->count;
1635  *type = CFAPI_INT;
1636  break;
1637 
1639  rbuffer = va_arg(args, char *);
1640  rbufsize = va_arg(args, int);
1641  query_name(op, rbuffer, rbufsize);
1642  *type = CFAPI_STRING;
1643  break;
1644 
1646  rsstring = va_arg(args, sstring *);
1647  *rsstring = op->name_pl;
1648  *type = CFAPI_SSTRING;
1649  break;
1650 
1652  rsstring = va_arg(args, sstring *);
1653  *rsstring = op->title;
1654  *type = CFAPI_SSTRING;
1655  break;
1656 
1658  rsstring = va_arg(args, sstring *);
1659  *rsstring = op->race;
1660  *type = CFAPI_SSTRING;
1661  break;
1662 
1664  rsstring = va_arg(args, sstring *);
1665  *rsstring = op->slaying;
1666  *type = CFAPI_SSTRING;
1667  break;
1668 
1670  rsstring = va_arg(args, sstring *);
1671  *rsstring = op->skill;
1672  *type = CFAPI_SSTRING;
1673  break;
1674 
1676  rsstring = va_arg(args, sstring *);
1677  *rsstring = op->msg;
1678  *type = CFAPI_SSTRING;
1679  break;
1680 
1682  rsstring = va_arg(args, sstring *);
1683  *rsstring = op->lore;
1684  *type = CFAPI_SSTRING;
1685  break;
1686 
1687  case CFAPI_OBJECT_PROP_X:
1688  rint = va_arg(args, int *);
1689  *rint = op->x;
1690  *type = CFAPI_INT;
1691  break;
1692 
1693  case CFAPI_OBJECT_PROP_Y:
1694  rint = va_arg(args, int *);
1695  *rint = op->y;
1696  *type = CFAPI_INT;
1697  break;
1698 
1700  rfloat = va_arg(args, float *);
1701  *rfloat = op->speed;
1702  *type = CFAPI_FLOAT;
1703  break;
1704 
1706  rfloat = va_arg(args, float *);
1707  *rfloat = op->speed_left;
1708  *type = CFAPI_FLOAT;
1709  break;
1710 
1712  rint = va_arg(args, int *);
1713  *rint = op->nrof;
1714  *type = CFAPI_INT;
1715  break;
1716 
1718  rint = va_arg(args, int *);
1719  *rint = op->direction;
1720  *type = CFAPI_INT;
1721  break;
1722 
1724  rint = va_arg(args, int *);
1725  *rint = op->facing;
1726  *type = CFAPI_INT;
1727  break;
1728 
1730  rint = va_arg(args, int *);
1731  *rint = op->type;
1732  *type = CFAPI_INT;
1733  break;
1734 
1736  rint = va_arg(args, int *);
1737  *rint = op->subtype;
1738  *type = CFAPI_INT;
1739  break;
1740 
1742  rint = va_arg(args, int *);
1743  *rint = op->client_type;
1744  *type = CFAPI_INT;
1745  break;
1746 
1747  case CFAPI_OBJECT_PROP_RESIST: {
1748  int idx;
1749  int16_t *resist;
1750 
1751  idx = va_arg(args, int);
1752  resist = va_arg(args, int16_t *);
1753  *resist = op->resist[idx];
1754  }
1755  *type = CFAPI_INT16;
1756  break;
1757 
1759  rint = va_arg(args, int *);
1760  *rint = op->attacktype;
1761  *type = CFAPI_INT;
1762  break;
1763 
1765  rint = va_arg(args, int *);
1766  *rint = op->path_attuned;
1767  *type = CFAPI_INT;
1768  break;
1769 
1771  rint = va_arg(args, int *);
1772  *rint = op->path_repelled;
1773  *type = CFAPI_INT;
1774  break;
1775 
1777  rint = va_arg(args, int *);
1778  *rint = op->path_denied;
1779  *type = CFAPI_INT;
1780  break;
1781 
1783  rint = va_arg(args, int *);
1784  *rint = op->material;
1785  *type = CFAPI_INT;
1786  break;
1787 
1789  rsstring = va_arg(args, sstring *);
1790  *rsstring = op->materialname;
1791  *type = CFAPI_SSTRING;
1792  break;
1793 
1795  rint = va_arg(args, int *);
1796  *rint = op->magic;
1797  *type = CFAPI_INT;
1798  break;
1799 
1801  rlong = va_arg(args, long *);
1802  *rlong = op->value;
1803  *type = CFAPI_LONG;
1804  break;
1805 
1807  rint = va_arg(args, int *);
1808  *rint = op->level;
1809  *type = CFAPI_INT;
1810  break;
1811 
1813  rint = va_arg(args, int *);
1814  *rint = op->last_heal;
1815  *type = CFAPI_INT;
1816  break;
1817 
1819  rint = va_arg(args, int *);
1820  *rint = op->last_sp;
1821  *type = CFAPI_INT;
1822  break;
1823 
1825  rint = va_arg(args, int *);
1826  *rint = op->last_grace;
1827  *type = CFAPI_INT;
1828  break;
1829 
1831  rint = va_arg(args, int *);
1832  *rint = op->last_eat;
1833  *type = CFAPI_INT;
1834  break;
1835 
1837  rint = va_arg(args, int *);
1838  *rint = op->invisible;
1839  *type = CFAPI_INT;
1840  break;
1841 
1843  rint = va_arg(args, int *);
1844  *rint = op->pick_up;
1845  *type = CFAPI_INT;
1846  break;
1847 
1849  rint = va_arg(args, int *);
1850  *rint = op->item_power;
1851  *type = CFAPI_INT;
1852  break;
1853 
1855  rint = va_arg(args, int *);
1856  *rint = op->gen_sp_armour;
1857  *type = CFAPI_INT;
1858  break;
1859 
1861  rint = va_arg(args, int *);
1862  *rint = op->weight;
1863  *type = CFAPI_INT;
1864  break;
1865 
1867  rint = va_arg(args, int *);
1868  *rint = op->weight_limit;
1869  *type = CFAPI_INT;
1870  break;
1871 
1873  rint = va_arg(args, int *);
1874  *rint = op->carrying;
1875  *type = CFAPI_INT;
1876  break;
1877 
1879  rint = va_arg(args, int *);
1880  *rint = op->glow_radius;
1881  *type = CFAPI_INT;
1882  break;
1883 
1885  rint64 = va_arg(args, int64_t *);
1886  *rint64 = op->total_exp;
1887  *type = CFAPI_SINT64;
1888  break;
1889 
1891  robject = va_arg(args, object **);
1892  *robject = op->current_weapon;
1893  *type = CFAPI_POBJECT;
1894  break;
1895 
1897  robject = va_arg(args, object **);
1898  *robject = op->enemy;
1899  *type = CFAPI_POBJECT;
1900  break;
1901 
1903  robject = va_arg(args, object **);
1904  *robject = op->attacked_by;
1905  *type = CFAPI_POBJECT;
1906  break;
1907 
1909  rint = va_arg(args, int *);
1910  *rint = op->run_away;
1911  *type = CFAPI_INT;
1912  break;
1913 
1915  robject = va_arg(args, object **);
1916  *robject = op->chosen_skill;
1917  *type = CFAPI_POBJECT;
1918  break;
1919 
1921  rint = va_arg(args, int *);
1922  *rint = op->hide;
1923  *type = CFAPI_INT;
1924  break;
1925 
1927  rint = va_arg(args, int *);
1928  *rint = op->move_status;
1929  *type = CFAPI_INT;
1930  break;
1931 
1933  rint = va_arg(args, int *);
1934  *rint = op->attack_movement;
1935  *type = CFAPI_INT;
1936  break;
1937 
1939  robject = va_arg(args, object **);
1940  *robject = op->spellitem;
1941  *type = CFAPI_POBJECT;
1942  break;
1943 
1945  rdouble = va_arg(args, double *);
1946  *rdouble = op->expmul;
1947  *type = CFAPI_DOUBLE;
1948  break;
1949 
1951  rarch = va_arg(args, archetype **);
1952  *rarch = op->arch;
1953  *type = CFAPI_PARCH;
1954  break;
1955 
1957  rarch = va_arg(args, archetype **);
1958  *rarch = op->other_arch;
1959  *type = CFAPI_PARCH;
1960  break;
1961 
1963  rsstring = va_arg(args, sstring *);
1964  *rsstring = object_get_value(op, CUSTOM_NAME_FIELD);
1965  *type = CFAPI_SSTRING;
1966  break;
1967 
1969  rint = va_arg(args, int *);
1970  *rint = op->anim_speed;
1971  *type = CFAPI_INT;
1972  break;
1973 
1975  rint = va_arg(args, int *);
1976  *rint = is_friendly(op);
1977  *type = CFAPI_INT;
1978  break;
1979 
1981  rbuffer = va_arg(args, char *);
1982  rbufsize = va_arg(args, int);
1983  query_short_name(op, rbuffer, rbufsize);
1984  *type = CFAPI_STRING;
1985  break;
1986 
1988  int i;
1989 
1990  i = va_arg(args, int);
1991  rbuffer = va_arg(args, char *);
1992  rbufsize = va_arg(args, int);
1993  query_base_name(op, i, rbuffer, rbufsize);
1994  *type = CFAPI_STRING;
1995  }
1996  break;
1997 
1999  rsstring = va_arg(args, sstring *);
2000  *rsstring = op->name;
2001  *type = CFAPI_SSTRING;
2002  break;
2003 
2005  rint = va_arg(args, int *);
2006  *rint = is_magical(op);
2007  *type = CFAPI_INT;
2008  break;
2009 
2011  rint = va_arg(args, int *);
2012  *rint = op->stats.luck;
2013  *type = CFAPI_INT;
2014  break;
2015 
2016  case CFAPI_OBJECT_PROP_EXP:
2017  rint64 = va_arg(args, int64_t *);
2018  *rint64 = op->stats.exp;
2019  *type = CFAPI_SINT64;
2020  break;
2021 
2023  robject = va_arg(args, object **);
2024  *robject = object_get_owner(op);
2025  *type = CFAPI_POBJECT;
2026  break;
2027 
2029  int stype;
2030 
2031  stype = va_arg(args, int);
2032  switch (stype) {
2033  unsigned char ptype;
2034  char *buf;
2035  archetype *at;
2036 
2037  case 0: /* present_in_ob */
2038  ptype = (unsigned char)(va_arg(args, int));
2039  robject = va_arg(args, object **);
2040  *robject = object_present_in_ob(ptype, op);
2041  break;
2042 
2043  case 1: /* present_in_ob_by_name */
2044  ptype = (unsigned char)(va_arg(args, int));
2045  buf = va_arg(args, char *);
2046  robject = va_arg(args, object **);
2047  *robject = object_present_in_ob_by_name(ptype, buf, op);
2048  break;
2049 
2050  case 2: /* arch_present_in_ob */
2051  at = va_arg(args, archetype *);
2052  robject = va_arg(args, object **);
2053  *robject = arch_present_in_ob(at, op);
2054  break;
2055  }
2056  }
2057  *type = CFAPI_POBJECT;
2058  break;
2059 
2061  rint = va_arg(args, int *);
2062  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2063  *type = CFAPI_INT;
2064  break;
2065 
2067  object *op2;
2068 
2069  op2 = va_arg(args, object *);
2070  rint = va_arg(args, int *);
2071  *rint = object_can_merge(op, op2);
2072  }
2073  *type = CFAPI_INT;
2074  break;
2075 
2077  object *op2;
2078 
2079  op2 = va_arg(args, object *);
2080  rint = va_arg(args, int *);
2081  *rint = object_can_pick(op2, op);
2082  }
2083  *type = CFAPI_INT;
2084  break;
2085 
2086  case CFAPI_OBJECT_PROP_FLAGS: {
2087  int fl;
2088 
2089  fl = va_arg(args, int);
2090  rint = va_arg(args, int *);
2091  *rint = QUERY_FLAG(op, fl);
2092  }
2093  *type = CFAPI_INT;
2094  break;
2095 
2096  case CFAPI_OBJECT_PROP_STR:
2097  rint = va_arg(args, int *);
2098  *rint = op->stats.Str;
2099  *type = CFAPI_INT;
2100  break;
2101 
2102  case CFAPI_OBJECT_PROP_DEX:
2103  rint = va_arg(args, int *);
2104  *rint = op->stats.Dex;
2105  *type = CFAPI_INT;
2106  break;
2107 
2108  case CFAPI_OBJECT_PROP_CON:
2109  rint = va_arg(args, int *);
2110  *rint = op->stats.Con;
2111  *type = CFAPI_INT;
2112  break;
2113 
2114  case CFAPI_OBJECT_PROP_WIS:
2115  rint = va_arg(args, int *);
2116  *rint = op->stats.Wis;
2117  *type = CFAPI_INT;
2118  break;
2119 
2120  case CFAPI_OBJECT_PROP_INT:
2121  rint = va_arg(args, int *);
2122  *rint = op->stats.Int;
2123  *type = CFAPI_INT;
2124  break;
2125 
2126  case CFAPI_OBJECT_PROP_POW:
2127  rint = va_arg(args, int *);
2128  *rint = op->stats.Pow;
2129  *type = CFAPI_INT;
2130  break;
2131 
2132  case CFAPI_OBJECT_PROP_CHA:
2133  rint = va_arg(args, int *);
2134  *rint = op->stats.Cha;
2135  *type = CFAPI_INT;
2136  break;
2137 
2138  case CFAPI_OBJECT_PROP_WC:
2139  rint = va_arg(args, int *);
2140  *rint = op->stats.wc;
2141  *type = CFAPI_INT;
2142  break;
2143 
2144  case CFAPI_OBJECT_PROP_AC:
2145  rint = va_arg(args, int *);
2146  *rint = op->stats.ac;
2147  *type = CFAPI_INT;
2148  break;
2149 
2150  case CFAPI_OBJECT_PROP_HP:
2151  rint = va_arg(args, int *);
2152  *rint = op->stats.hp;
2153  *type = CFAPI_INT;
2154  break;
2155 
2156  case CFAPI_OBJECT_PROP_SP:
2157  rint = va_arg(args, int *);
2158  *rint = op->stats.sp;
2159  *type = CFAPI_INT;
2160  break;
2161 
2162  case CFAPI_OBJECT_PROP_GP:
2163  rint = va_arg(args, int *);
2164  *rint = op->stats.grace;
2165  *type = CFAPI_INT;
2166  break;
2167 
2168  case CFAPI_OBJECT_PROP_FP:
2169  rint = va_arg(args, int *);
2170  *rint = op->stats.food;
2171  *type = CFAPI_INT;
2172  break;
2173 
2175  rint = va_arg(args, int *);
2176  *rint = op->stats.maxhp;
2177  *type = CFAPI_INT;
2178  break;
2179 
2181  rint = va_arg(args, int *);
2182  *rint = op->stats.maxsp;
2183  *type = CFAPI_INT;
2184  break;
2185 
2187  rint = va_arg(args, int *);
2188  *rint = op->stats.maxgrace;
2189  *type = CFAPI_INT;
2190  break;
2191 
2192  case CFAPI_OBJECT_PROP_DAM:
2193  rint = va_arg(args, int *);
2194  *rint = op->stats.dam;
2195  *type = CFAPI_INT;
2196  break;
2197 
2198  case CFAPI_OBJECT_PROP_GOD:
2199  rsstring = va_arg(args, sstring *);
2200  *rsstring = determine_god(op);
2201  *type = CFAPI_SSTRING;
2202  break;
2203 
2205  rsstring = va_arg(args, sstring *);
2206  *rsstring = op->arch->name;
2207  *type = CFAPI_SSTRING;
2208  break;
2209 
2211  rint = va_arg(args, int *);
2212  *rint = op->invisible;
2213  *type = CFAPI_INT;
2214  break;
2215 
2217  rsstring = va_arg(args, sstring *);
2218  if (op->face != NULL) {
2219  (*rsstring) = op->face->name;
2220  }
2221  else {
2222  (*rsstring) = NULL;
2223  }
2224  *type = CFAPI_SSTRING;
2225  break;
2226 
2228  rsstring = va_arg(args, sstring *);
2229  if (op->animation != NULL) {
2230  (*rsstring) = op->animation->name;
2231  }
2232  else {
2233  (*rsstring) = NULL;
2234  }
2235  *type = CFAPI_SSTRING;
2236  break;
2237 
2238  case CFAPI_PLAYER_PROP_IP:
2239  rsstring = va_arg(args, sstring *);
2240  *rsstring = op->contr->socket->host;
2241  *type = CFAPI_SSTRING;
2242  break;
2243 
2245  robject = va_arg(args, object **);
2246  *robject = find_marked_object(op);
2247  *type = CFAPI_POBJECT;
2248  break;
2249 
2251  rparty = va_arg(args, partylist **);
2252  *rparty = (op->contr ? op->contr->party : NULL);
2253  *type = CFAPI_PPARTY;
2254  break;
2255 
2257  robject = va_arg(args, object **);
2258  if (op)
2259  *robject = op->contr->next ? op->contr->next->ob : NULL;
2260  else
2261  /* This can be called when there is no player. */
2262  *robject = first_player ? first_player->ob : NULL;
2263  *type = CFAPI_POBJECT;
2264  break;
2265 
2267  rbuffer = va_arg(args, char *);
2268  rbufsize = va_arg(args, int);
2269  player_get_title(op->contr, rbuffer, rbufsize);
2270  *type = CFAPI_STRING;
2271  break;
2272 
2274  robject = va_arg(args, object **);
2275  *robject = op->contr->transport;
2276  *type = CFAPI_POBJECT;
2277  break;
2278 
2280  rmove = va_arg(args, MoveType *);
2281  *rmove = op->move_type;
2282  *type = CFAPI_MOVETYPE;
2283  break;
2284 
2286  rmove = va_arg(args, MoveType *);
2287  *rmove = op->move_block;
2288  *type = CFAPI_MOVETYPE;
2289  break;
2290 
2292  rmove = va_arg(args, MoveType *);
2293  *rmove = op->move_allow;
2294  *type = CFAPI_MOVETYPE;
2295  break;
2296 
2298  rmove = va_arg(args, MoveType *);
2299  *rmove = op->move_on;
2300  *type = CFAPI_MOVETYPE;
2301  break;
2302 
2304  rmove = va_arg(args, MoveType *);
2305  *rmove = op->move_off;
2306  *type = CFAPI_MOVETYPE;
2307  break;
2308 
2310  rmove = va_arg(args, MoveType *);
2311  *rmove = op->move_type;
2312  *type = CFAPI_MOVETYPE;
2313  break;
2314 
2316  rfloat = va_arg(args, float *);
2317  *rfloat = op->move_slow_penalty;
2318  *type = CFAPI_FLOAT;
2319  break;
2320 
2322  rbuffer = va_arg(args, char *);
2323  rbufsize = va_arg(args, int);
2324  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2325  *type = CFAPI_STRING;
2326  break;
2327 
2329  rint = va_arg(args, int *);
2330  *rint = op->contr->bed_x;
2331  *type = CFAPI_INT;
2332  break;
2333 
2335  rint = va_arg(args, int *);
2336  *rint = op->contr->bed_y;
2337  *type = CFAPI_INT;
2338  break;
2339 
2341  rint = va_arg(args, int *);
2342  *rint = op->duration;
2343  *type = CFAPI_INT;
2344  break;
2345 
2346  default:
2347  *type = CFAPI_NONE;
2348  break;
2349  }
2350  va_end(args);
2351 }
2352 
2361 static void copy_message(object *op, const char *msg) {
2362  /* need to reset parsed dialog information */
2364  if (strlen(msg) == 0) {
2365  msg = NULL;
2366  }
2367  object_set_msg(op, msg);
2368 }
2369 
2378 static void cfapi_object_set_property(int *type, ...) {
2379  va_list args;
2380  int iarg, *ret;
2381  long larg;
2382  char *sarg;
2383  double darg;
2384  object *oparg;
2385  object *op;
2386  int property;
2387  int64_t s64arg;
2388  partylist *partyarg;
2389  float farg;
2390  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2391 
2392  va_start(args, type);
2393  op = va_arg(args, object *);
2394  property = va_arg(args, int);
2395  *type = CFAPI_NONE;
2396 
2397  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2398  switch (property) {
2400  sarg = va_arg(args, char *);
2401  *type = CFAPI_STRING;
2402  FREE_AND_COPY(op->name, sarg);
2404  break;
2405 
2407  sarg = va_arg(args, char *);
2408  *type = CFAPI_STRING;
2409  FREE_AND_COPY(op->name_pl, sarg);
2411  break;
2412 
2414  sarg = va_arg(args, char *);
2415  *type = CFAPI_STRING;
2416  FREE_AND_COPY(op->title, sarg);
2417  break;
2418 
2420  sarg = va_arg(args, char *);
2421  *type = CFAPI_STRING;
2422  FREE_AND_COPY(op->race, sarg);
2423  break;
2424 
2426  sarg = va_arg(args, char *);
2427  *type = CFAPI_STRING;
2428  FREE_AND_COPY(op->slaying, sarg);
2429  break;
2430 
2432  sarg = va_arg(args, char *);
2433  *type = CFAPI_STRING;
2434  FREE_AND_COPY(op->skill, sarg);
2435  break;
2436 
2438  sarg = va_arg(args, char *);
2439  *type = CFAPI_STRING;
2440  copy_message(op, sarg);
2441  break;
2442 
2444  sarg = va_arg(args, char *);
2445  *type = CFAPI_STRING;
2446  FREE_AND_COPY(op->lore, sarg);
2447  break;
2448 
2450  farg = va_arg(args, double);
2451  *type = CFAPI_FLOAT;
2452  if (farg != op->speed) {
2453  op->speed = farg;
2455  }
2456  break;
2457 
2459  farg = va_arg(args, double);
2460  *type = CFAPI_FLOAT;
2461  op->speed_left = farg;
2462  break;
2463 
2465  iarg = va_arg(args, int);
2466  *type = CFAPI_INT;
2467  if (iarg < 0)
2468  iarg = 0;
2469  if (op->nrof > (uint32_t)iarg)
2470  object_decrease_nrof(op, op->nrof-iarg);
2471  else if (op->nrof < (uint32_t)iarg) {
2472  object *tmp;
2473  player *pl;
2474 
2475  op->nrof = iarg;
2476  if (op->env != NULL) {
2478  if (!tmp) {
2479  for (pl = first_player; pl; pl = pl->next)
2480  if (pl->ob->container == op->env)
2481  break;
2482  if (pl)
2483  tmp = pl->ob;
2484  else
2485  tmp = NULL;
2486  } else {
2488  fix_object(tmp);
2489  }
2490  if (tmp)
2492  } else {
2494  if (tmp->type == PLAYER)
2495  tmp->contr->socket->update_look = 1;
2496  FOR_ABOVE_FINISH();
2497  }
2498  }
2499  break;
2500 
2502  iarg = va_arg(args, int);
2503  *type = CFAPI_INT;
2504  op->direction = iarg;
2505  break;
2506 
2508  iarg = va_arg(args, int);
2509  *type = CFAPI_INT;
2510  op->facing = iarg;
2511  break;
2512 
2513  case CFAPI_OBJECT_PROP_RESIST: {
2514  int iargbis = va_arg(args, int);
2515 
2516  *type = CFAPI_INT16;
2517  iarg = va_arg(args, int);
2518  op->resist[iargbis] = iarg;
2519  }
2520  break;
2521 
2523  iarg = va_arg(args, int);
2524  *type = CFAPI_INT;
2525  op->attacktype = iarg;
2526  break;
2527 
2529  iarg = va_arg(args, int);
2530  *type = CFAPI_INT;
2531  op->path_attuned = iarg;
2532  break;
2533 
2535  iarg = va_arg(args, int);
2536  *type = CFAPI_INT;
2537  op->path_repelled = iarg;
2538  break;
2539 
2541  iarg = va_arg(args, int);
2542  *type = CFAPI_INT;
2543  op->path_denied = iarg;
2544  break;
2545 
2547  iarg = va_arg(args, int);
2548  *type = CFAPI_INT;
2549  op->material = iarg;
2550  break;
2551 
2553  break;
2554 
2556  iarg = va_arg(args, int);
2557  *type = CFAPI_INT;
2558  op->magic = iarg;
2559  break;
2560 
2562  larg = va_arg(args, long);
2563  *type = CFAPI_LONG;
2564  op->value = larg;
2565  break;
2566 
2568  iarg = va_arg(args, int);
2569  *type = CFAPI_INT;
2570  op->level = iarg;
2572  break;
2573 
2575  iarg = va_arg(args, int);
2576  *type = CFAPI_INT;
2577  op->last_heal = iarg;
2578  break;
2579 
2581  iarg = va_arg(args, int);
2582  *type = CFAPI_INT;
2583  op->last_sp = iarg;
2584  break;
2585 
2587  iarg = va_arg(args, int);
2588  *type = CFAPI_INT;
2589  op->last_grace = iarg;
2590  break;
2591 
2593  iarg = va_arg(args, int);
2594  *type = CFAPI_INT;
2595  op->last_eat = iarg;
2596  break;
2597 
2599  iarg = va_arg(args, int);
2600  *type = CFAPI_INT;
2601  op->invisible = iarg;
2602  break;
2603 
2605  iarg = va_arg(args, int);
2606  *type = CFAPI_INT;
2607  op->pick_up = iarg;
2608  break;
2609 
2611  iarg = va_arg(args, int);
2612  *type = CFAPI_INT;
2613  op->item_power = iarg;
2614  break;
2615 
2617  iarg = va_arg(args, int);
2618  *type = CFAPI_INT;
2619  op->gen_sp_armour = iarg;
2620  break;
2621 
2623  iarg = va_arg(args, int);
2624  *type = CFAPI_INT;
2625  if (op->weight != iarg) {
2626  object *tmp;
2627  player *pl;
2628 
2629  op->weight = iarg;
2630  if (op->env != NULL) {
2632  if (!tmp) {
2633  for (pl = first_player; pl; pl = pl->next)
2634  if (pl->ob->container == op->env)
2635  break;
2636  if (pl)
2637  tmp = pl->ob;
2638  else
2639  tmp = NULL;
2640  } else {
2642  fix_object(tmp);
2643  }
2644  if (tmp)
2646  } else {
2648  if (tmp->type == PLAYER)
2650  FOR_ABOVE_FINISH();
2651  }
2652  }
2653  break;
2654 
2656  iarg = va_arg(args, int);
2657  *type = CFAPI_INT;
2658  op->weight_limit = iarg;
2659  break;
2660 
2662  iarg = va_arg(args, int);
2663  *type = CFAPI_INT;
2664  if (op->glow_radius != iarg) {
2665  object *tmp;
2666 
2667  op->glow_radius = iarg;
2669  if (tmp->map != NULL) {
2670  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2671  update_position(tmp->map, tmp->x, tmp->y);
2672  update_all_los(tmp->map, tmp->x, tmp->y);
2673  }
2674  }
2675  break;
2676 
2678  s64arg = va_arg(args, int64_t);
2679  *type = CFAPI_SINT64;
2680  op->total_exp = s64arg;
2681  break;
2682 
2684  oparg = va_arg(args, object *);
2685  *type = CFAPI_POBJECT;
2686  object_set_enemy(op, oparg);
2687  break;
2688 
2690  iarg = va_arg(args, int);
2691  *type = CFAPI_INT;
2692  op->run_away = iarg;
2693  break;
2694 
2696  oparg = va_arg(args, object *);
2697  *type = CFAPI_POBJECT;
2698  op->chosen_skill = oparg;
2699  break;
2700 
2702  iarg = va_arg(args, int);
2703  *type = CFAPI_INT;
2704  op->hide = iarg;
2705  break;
2706 
2708  iarg = va_arg(args, int);
2709  *type = CFAPI_INT;
2710  op->move_status = iarg;
2711  break;
2712 
2714  iarg = va_arg(args, int);
2715  *type = CFAPI_INT;
2716  op->attack_movement = iarg;
2717  break;
2718 
2720  oparg = va_arg(args, object *);
2721  *type = CFAPI_POBJECT;
2722  op->spellitem = oparg;
2723  break;
2724 
2726  darg = va_arg(args, double);
2727  *type = CFAPI_DOUBLE;
2728  op->expmul = darg;
2729  break;
2730 
2732  sarg = va_arg(args, char *);
2733  *type = CFAPI_STRING;
2736  break;
2737 
2739  iarg = va_arg(args, int);
2740  *type = CFAPI_INT;
2741  op->anim_speed = iarg;
2742  break;
2743 
2745  iarg = va_arg(args, int);
2746  *type = CFAPI_INT;
2747  if (iarg == 1 && is_friendly(op) == 0)
2749  else if (iarg == 0 && is_friendly(op) == 1)
2751  break;
2752 
2754  iarg = va_arg(args, int);
2755  *type = CFAPI_INT;
2756  op->stats.luck = iarg;
2757  break;
2758 
2759  case CFAPI_OBJECT_PROP_EXP:
2760  s64arg = va_arg(args, int64_t);
2761  *type = CFAPI_SINT64;
2762  op->stats.exp = s64arg;
2763  break;
2764 
2766  oparg = va_arg(args, object *);
2767  *type = CFAPI_POBJECT;
2768  object_set_owner(op, oparg);
2769  break;
2770 
2773  *type = CFAPI_NONE;
2774  break;
2775 
2776  case CFAPI_OBJECT_PROP_FLAGS: {
2777  int iargbis;
2778 
2779  iarg = va_arg(args, int);
2780  iargbis = va_arg(args, int);
2781  *type = CFAPI_INT;
2782 
2783  if (iargbis == 1)
2784  SET_FLAG(op, iarg);
2785  else
2786  CLEAR_FLAG(op, iarg);
2787  }
2788  break;
2789 
2790  case CFAPI_OBJECT_PROP_STR:
2791  iarg = va_arg(args, int);
2792  *type = CFAPI_INT;
2793  op->stats.Str = iarg;
2794  break;
2795 
2796  case CFAPI_OBJECT_PROP_DEX:
2797  iarg = va_arg(args, int);
2798  *type = CFAPI_INT;
2799  op->stats.Dex = iarg;
2800  break;
2801 
2802  case CFAPI_OBJECT_PROP_CON:
2803  iarg = va_arg(args, int);
2804  *type = CFAPI_INT;
2805  op->stats.Con = iarg;
2806  break;
2807 
2808  case CFAPI_OBJECT_PROP_WIS:
2809  iarg = va_arg(args, int);
2810  *type = CFAPI_INT;
2811  op->stats.Wis = iarg;
2812  break;
2813 
2814  case CFAPI_OBJECT_PROP_INT:
2815  iarg = va_arg(args, int);
2816  *type = CFAPI_INT;
2817  op->stats.Int = iarg;
2818  break;
2819 
2820  case CFAPI_OBJECT_PROP_POW:
2821  iarg = va_arg(args, int);
2822  *type = CFAPI_INT;
2823  op->stats.Pow = iarg;
2824  break;
2825 
2826  case CFAPI_OBJECT_PROP_CHA:
2827  iarg = va_arg(args, int);
2828  *type = CFAPI_INT;
2829  op->stats.Cha = iarg;
2830  break;
2831 
2832  case CFAPI_OBJECT_PROP_WC:
2833  iarg = va_arg(args, int);
2834  *type = CFAPI_INT;
2835  op->stats.wc = iarg;
2836  break;
2837 
2838  case CFAPI_OBJECT_PROP_AC:
2839  iarg = va_arg(args, int);
2840  *type = CFAPI_INT;
2841  op->stats.ac = iarg;
2842  break;
2843 
2844  case CFAPI_OBJECT_PROP_HP:
2845  iarg = va_arg(args, int);
2846  *type = CFAPI_INT;
2847  op->stats.hp = iarg;
2848  break;
2849 
2850  case CFAPI_OBJECT_PROP_SP:
2851  iarg = va_arg(args, int);
2852  *type = CFAPI_INT;
2853  op->stats.sp = iarg;
2854  break;
2855 
2856  case CFAPI_OBJECT_PROP_GP:
2857  iarg = va_arg(args, int);
2858  *type = CFAPI_INT;
2859  op->stats.grace = iarg;
2860  break;
2861 
2862  case CFAPI_OBJECT_PROP_FP:
2863  iarg = va_arg(args, int);
2864  *type = CFAPI_INT;
2865  op->stats.food = iarg;
2866  break;
2867 
2869  iarg = va_arg(args, int);
2870  *type = CFAPI_INT;
2871  op->stats.maxhp = iarg;
2872  break;
2873 
2875  iarg = va_arg(args, int);
2876  *type = CFAPI_INT;
2877  op->stats.maxsp = iarg;
2878  break;
2879 
2881  iarg = va_arg(args, int);
2882  *type = CFAPI_INT;
2883  op->stats.maxgrace = iarg;
2884  break;
2885 
2886  case CFAPI_OBJECT_PROP_DAM:
2887  iarg = va_arg(args, int);
2888  *type = CFAPI_INT;
2889  op->stats.dam = iarg;
2890  break;
2891 
2892  case CFAPI_OBJECT_PROP_FACE: {
2893  const Face *face;
2894  sarg = va_arg(args, char *);
2895  ret = va_arg(args, int *);
2896  *type = CFAPI_INT;
2897  face = try_find_face(sarg, 0);
2898  if (face != NULL) {
2899  op->face = face;
2900  op->state = 0;
2902  (*ret) = face->number;
2903  } else
2904  (*ret) = 0;
2905  break;
2906  }
2907 
2909  const Animations *anim;
2910  sarg = va_arg(args, char *);
2911  ret = va_arg(args, int *);
2912  *type = CFAPI_INT;
2913  anim = try_find_animation(sarg);
2914  if (anim != NULL) {
2915  op->animation = anim;
2916  SET_ANIMATION(op, 0);
2918  (*ret) = anim->num;
2919  } else {
2920  (*ret) = 0;
2921  }
2922  break;
2923  }
2924 
2926  iarg = va_arg(args, int);
2927  *type = CFAPI_INT;
2928  op->duration = iarg;
2929  break;
2930 
2932  if (op->contr) {
2933  oparg = va_arg(args, object *);
2934  *type = CFAPI_POBJECT;
2935  op->contr->mark = oparg;
2936  if (oparg) {
2937  op->contr->mark_count = oparg->count;
2938  } else {
2939  op->contr->mark_count = 0;
2940  }
2941  }
2942  break;
2943 
2945  if (op->contr) {
2946  partyarg = va_arg(args, partylist *);
2947  *type = CFAPI_PPARTY;
2948  party_join(op, partyarg);
2949  }
2950  break;
2951 
2953  sarg = va_arg(args, char *);
2954  *type = CFAPI_STRING;
2955  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
2956  break;
2957 
2959  iarg = va_arg(args, int);
2960  *type = CFAPI_INT;
2961  op->contr->bed_x = iarg;
2962  break;
2963 
2965  iarg = va_arg(args, int);
2966  *type = CFAPI_INT;
2967  op->contr->bed_y = iarg;
2968  break;
2969 
2971  sarg = va_arg(args, char *);
2972  *type = CFAPI_STRING;
2973  player_set_own_title(op->contr, sarg);
2974  break;
2975 
2977  move = va_arg(args, MoveType *);
2978  op->move_type = *move & MOVE_ALL;
2980  *type = CFAPI_MOVETYPE;
2981  break;
2982 
2984  move = va_arg(args, MoveType *);
2985  op->move_block = *move & MOVE_ALL;
2987  *type = CFAPI_MOVETYPE;
2988  break;
2989 
2991  move = va_arg(args, MoveType *);
2992  op->move_allow = *move & MOVE_ALL;
2994  *type = CFAPI_MOVETYPE;
2995  break;
2996 
2998  move = va_arg(args, MoveType *);
2999  op->move_on = *move & MOVE_ALL;
3001  *type = CFAPI_MOVETYPE;
3002  break;
3003 
3005  move = va_arg(args, MoveType *);
3006  op->move_off = *move & MOVE_ALL;
3008  *type = CFAPI_MOVETYPE;
3009  break;
3010 
3012  move = va_arg(args, MoveType *);
3013  op->move_type = *move & MOVE_ALL;
3015  *type = CFAPI_MOVETYPE;
3016  break;
3017 
3018  default:
3019  break;
3020  }
3021  }
3022  va_end(args);
3023 }
3024 
3031 static void cfapi_object_apply_below(int *type, ...) {
3032  va_list args;
3033  object *applier;
3034 
3035  va_start(args, type);
3036 
3037  applier = va_arg(args, object *);
3038 
3039  va_end(args);
3040 
3041  apply_by_living_below(applier);
3042  *type = CFAPI_NONE;
3043 }
3044 
3051 static void cfapi_object_apply(int *type, ...) {
3052  va_list args;
3053  object *applied;
3054  object *applier;
3055  int aflags;
3056  int *ret;
3057 
3058  va_start(args, type);
3059 
3060  applier = va_arg(args, object *);
3061  applied = va_arg(args, object *);
3062  aflags = va_arg(args, int);
3063  ret = va_arg(args, int *);
3064 
3065  va_end(args);
3066 
3067  *type = CFAPI_INT;
3068  *ret = apply_manual(applier, applied, aflags);
3069 }
3070 
3076 static void cfapi_object_identify(int *type, ...) {
3077  va_list args;
3078  object *op, **result;
3079 
3080  va_start(args, type);
3081 
3082  op = va_arg(args, object *);
3083  result = va_arg(args, object **);
3084 
3085  va_end(args);
3086 
3087  (*result) = identify(op);
3088  *type = CFAPI_POBJECT;
3089 }
3090 
3096 static void cfapi_object_describe(int *type, ...) {
3097  va_list args;
3098  object *op;
3099  object *owner;
3100  char *desc, *final;
3101  int size;
3102 
3103  va_start(args, type);
3104 
3105  op = va_arg(args, object *);
3106  owner = va_arg(args, object *);
3107  desc = va_arg(args, char *);
3108  size = va_arg(args, int);
3109  va_end(args);
3110 
3111  *type = CFAPI_STRING;
3112  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3113  strncpy(desc, final, size);
3114  desc[size - 1] = '\0';
3115  free(final);
3116 }
3117 
3118 static void cfapi_object_drain(int *type, ...) {
3119  va_list args;
3120 
3121  object *op;
3122  int ds;
3123 
3124  va_start(args, type);
3125 
3126  op = va_arg(args, object *);
3127  ds = va_arg(args, int);
3128 
3129  va_end(args);
3130 
3131  drain_specific_stat(op, ds);
3132 
3133  *type = CFAPI_NONE;
3134 }
3135 
3136 static void cfapi_object_remove_depletion(int *type, ...) {
3137  va_list args;
3138 
3139  object *op;
3140  int level, *result;
3141 
3142  va_start(args, type);
3143 
3144  op = va_arg(args, object *);
3145  level = va_arg(args, int);
3146  result = va_arg(args, int*);
3147 
3148  va_end(args);
3149 
3151 
3152  *type = CFAPI_INT;
3153 }
3154 
3155 static void cfapi_object_fix(int *type, ...) {
3156  va_list args;
3157  object *op;
3158 
3159  va_start(args, type);
3160 
3161  op = va_arg(args, object *);
3162 
3163  va_end(args);
3164 
3165  fix_object(op);
3166 
3167  *type = CFAPI_NONE;
3168 }
3169 
3171 static void cfapi_object_give_skill(int *type, ...) {
3172  va_list args;
3173 
3174  object *op;
3175  char *skillname;
3176 
3177  va_start(args, type);
3178 
3179  op = va_arg(args, object *);
3180  skillname = va_arg(args, char *);
3181 
3182  va_end(args);
3183 
3184  *type = CFAPI_POBJECT;
3185  give_skill_by_name(op, skillname);
3186 }
3187 
3188 static void cfapi_object_transmute(int *type, ...) {
3189  va_list args;
3190 
3191  object *op;
3192  object *chg;
3193 
3194  va_start(args, type);
3195 
3196  op = va_arg(args, object *);
3197  chg = va_arg(args, object *);
3198 
3199  va_end(args);
3200 
3201  transmute_materialname(op, chg);
3202  *type = CFAPI_NONE;
3203 }
3204 
3205 static void cfapi_object_remove(int *type, ...) {
3206  va_list args;
3207  object *op;
3208 
3209  va_start(args, type);
3210 
3211  op = va_arg(args, object *);
3212 
3213  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3214  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3215  va_end(args);
3216  *type = CFAPI_NONE;
3217  return;
3218  }
3219 
3220  va_end(args);
3221 
3222  object_remove(op);
3223  *type = CFAPI_NONE;
3224 }
3225 
3226 static void cfapi_object_delete(int *type, ...) {
3227  va_list args;
3228  object *op;
3229 
3230  va_start(args, type);
3231 
3232  op = va_arg(args, object *);
3233 
3235  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3236  *type = CFAPI_NONE;
3237  va_end(args);
3238  return;
3239  }
3240 
3241  va_end(args);
3242 
3244 
3245  *type = CFAPI_NONE;
3246 }
3247 
3253 static void cfapi_object_clone(int *type, ...) {
3254  va_list args;
3255  object *op;
3256  int kind;
3257  object **robj;
3258 
3259  va_start(args, type);
3260 
3261  op = va_arg(args, object *);
3262  kind = va_arg(args, int);
3263  robj = va_arg(args, object **);
3264 
3265  va_end(args);
3266 
3267  if (kind == 0) {
3268  *type = CFAPI_POBJECT;
3269  *robj = object_create_clone(op);
3270  } else {
3271  object *tmp;
3272  tmp = object_new();
3273  object_copy(op, tmp);
3274  *type = CFAPI_POBJECT;
3275  *robj = tmp;
3276  }
3277  return;
3278 }
3279 
3285 static void cfapi_object_create(int *type, ...) {
3286  va_list args;
3287  int ival;
3288  object **robj;
3289  va_start(args, type);
3290  ival = va_arg(args, int);
3291 
3292  *type = CFAPI_POBJECT;
3293  switch (ival) {
3294  case 0:
3295  robj = va_arg(args, object **);
3296  *robj = object_new();
3297  break;
3298 
3299  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3300  const char *sval;
3301  archetype *at;
3302 
3303  sval = va_arg(args, const char *);
3304  robj = va_arg(args, object **);
3305  va_end(args);
3306 
3307  at = try_find_archetype(sval);
3308  if (!at)
3309  at = find_archetype_by_object_name(sval);
3310  if (at) {
3311  *robj = object_create_arch(at);
3312  } else
3313  *robj = NULL;
3314  }
3315  break;
3316 
3317  default:
3318  *type = CFAPI_NONE;
3319  break;
3320  }
3321  va_end(args);
3322 }
3323 
3324 static void cfapi_object_insert(int *type, ...) {
3325  va_list args;
3326  object *op;
3327  object *orig;
3328  mapstruct *map;
3329  int flag, x, y;
3330  int itype;
3331  object **robj;
3332 
3333  va_start(args, type);
3334 
3335  op = va_arg(args, object *);
3336  if (!op) {
3337  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3338  va_end(args);
3339  return;
3340  }
3341  if (QUERY_FLAG(op, FLAG_FREED)) {
3342  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3343  va_end(args);
3344  return;
3345  }
3346  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3347  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3348  object_remove(op);
3349  }
3350  itype = va_arg(args, int);
3351 
3352  switch (itype) {
3353  case 0:
3354  map = va_arg(args, mapstruct *);
3355  orig = va_arg(args, object *);
3356  flag = va_arg(args, int);
3357  x = va_arg(args, int);
3358  y = va_arg(args, int);
3359  robj = va_arg(args, object **);
3360  if (!map) {
3361  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3363  *robj = NULL;
3364  } else
3365  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3366  *type = CFAPI_POBJECT;
3367  break;
3368 
3369  case 1:
3370  map = va_arg(args, mapstruct *);
3371  orig = va_arg(args, object *);
3372  flag = va_arg(args, int);
3373  robj = va_arg(args, object **);
3374  if (!map) {
3375  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3377  *robj = NULL;
3378  } else
3379  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3380  *type = CFAPI_POBJECT;
3381  break;
3382 
3383  case 2:
3384  map = va_arg(args, mapstruct *);
3385  orig = va_arg(args, object *);
3386  flag = va_arg(args, int);
3387  x = va_arg(args, int);
3388  y = va_arg(args, int);
3389  robj = va_arg(args, object **);
3390  if (!map) {
3391  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3393  *robj = NULL;
3394  } else {
3395  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3396  if (dir != -1) {
3397  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3398  } else {
3400  *robj = NULL;
3401  }
3402  }
3403  *type = CFAPI_POBJECT;
3404  break;
3405 
3406  case 3:
3407  orig = va_arg(args, object *);
3408  robj = va_arg(args, object **);
3409  if (!orig) {
3410  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3412  *robj = NULL;
3413  } else
3414  *robj = object_insert_in_ob(op, orig);
3415  *type = CFAPI_POBJECT;
3416  break;
3417 
3418  default:
3419  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3421  *type = CFAPI_NONE;
3422  break;
3423  }
3424 
3425  va_end(args);
3426 }
3432 static void cfapi_object_split(int *type, ...) {
3433  va_list args;
3434 
3435  int nr, size;
3436  object *op;
3437  char *buf;
3438  object **split;
3439 
3440  va_start(args, type);
3441 
3442  op = va_arg(args, object *);
3443  nr = va_arg(args, int);
3444  buf = va_arg(args, char *);
3445  size = va_arg(args, int);
3446  split = va_arg(args, object **);
3447  va_end(args);
3448 
3449  *split = object_split(op, nr, buf, size);
3450  if (*split != NULL)
3451  {
3452  *type = CFAPI_POBJECT;
3453  }
3454  else
3455  {
3456  *type = CFAPI_NONE;
3457  }
3458 }
3459 
3465 static void cfapi_object_merge(int *type, ...) {
3466  va_list args;
3467  object *op;
3468  object *op2;
3469  object **merge;
3470 
3471  va_start(args, type);
3472 
3473  op = va_arg(args, object *);
3474  op2 = va_arg(args, object *);
3475  merge = va_arg(args, object **);
3476 
3477  va_end(args);
3478 
3479  *type = CFAPI_POBJECT;
3480  *merge = object_merge(op, op2);
3481 }
3482 
3488 static void cfapi_object_distance(int *type, ...) {
3489  va_list args;
3490  object *op;
3491  object *op2;
3492  int *rint;
3493  va_start(args, type);
3494 
3495  op = va_arg(args, object *);
3496  op2 = va_arg(args, object *);
3497  rint = va_arg(args, int *);
3498 
3499  va_end(args);
3500 
3501  *type = CFAPI_INT;
3502  *rint = object_distance(op, op2);
3503 }
3509 static void cfapi_object_update(int *type, ...) {
3510  va_list args;
3511  int action;
3512  object *op;
3513  va_start(args, type);
3514 
3515  op = va_arg(args, object *);
3516  action = va_arg(args, int);
3517 
3518  va_end(args);
3519 
3521  *type = CFAPI_NONE;
3522 }
3523 
3529 static void cfapi_object_clear(int *type, ...) {
3530  va_list args;
3531  object *op;
3532  va_start(args, type);
3533 
3534  op = va_arg(args, object *);
3535 
3536  va_end(args);
3537 
3538  object_clear(op);
3539  *type = CFAPI_NONE;
3540 }
3541 
3547 static void cfapi_object_reset(int *type, ...) {
3548  va_list args;
3549  object *op;
3550 
3551  va_start(args, type);
3552 
3553  op = va_arg(args, object *);
3554 
3555  va_end(args);
3556 
3557  object_reset(op);
3558  *type = CFAPI_NONE;
3559 }
3560 
3561 static void cfapi_object_clean_object(int *type, ...) {
3562  va_list args;
3563  object *op;
3564 
3565  va_start(args, type);
3566  op = va_arg(args, object *);
3567  clean_object(op);
3568  va_end(args);
3569  *type = CFAPI_NONE;
3570 }
3571 
3572 static void cfapi_object_on_same_map(int *type, ...) {
3573  va_list args;
3574  object *op1;
3575  object *op2;
3576  int *rint;
3577 
3578  va_start(args, type);
3579  op1 = va_arg(args, object *);
3580  op2 = va_arg(args, object *);
3581  rint = va_arg(args, int *);
3582  va_end(args);
3583 
3584  *type = CFAPI_INT;
3585  *rint = on_same_map(op1, op2);
3586 }
3587 
3588 static void cfapi_object_spring_trap(int *type, ...) {
3589  object *trap;
3590  object *victim;
3591  va_list args;
3592 
3593  va_start(args, type);
3594  trap = va_arg(args, object *);
3595  victim = va_arg(args, object *);
3596  va_end(args);
3597 
3598  spring_trap(trap, victim);
3599  *type = CFAPI_NONE;
3600 }
3601 
3607 static void cfapi_object_check_trigger(int *type, ...) {
3608  object *op;
3609  object *cause;
3610  va_list args;
3611  int *rint;
3612 
3613  va_start(args, type);
3614  op = va_arg(args, object *);
3615  cause = va_arg(args, object *);
3616  rint = va_arg(args, int *);
3617  va_end(args);
3618 
3619  *rint = check_trigger(op, cause);
3620  *type = CFAPI_INT;
3621 }
3622 
3634 static void cfapi_map_trigger_connected(int *type, ...) {
3635  objectlink *ol;
3636  object *cause;
3637  int state;
3638  va_list args;
3639 
3640  va_start(args, type);
3641  ol = va_arg(args, objectlink *);
3642  cause = va_arg(args, object *);
3643  state = va_arg(args, int);
3644  va_end(args);
3645  trigger_connected(ol, cause, state);
3646  *type = CFAPI_NONE;
3647 }
3648 
3654 static void cfapi_object_query_money(int *type, ...) {
3655  object *op;
3656  va_list args;
3657  int *rint;
3658 
3659  va_start(args, type);
3660  op = va_arg(args, object *);
3661  rint = va_arg(args, int *);
3662  va_end(args);
3663 
3664  *rint = query_money(op);
3665  *type = CFAPI_INT;
3666 }
3667 
3673 static void cfapi_object_cast(int *type, ...) {
3674  object *op;
3675  object *sp;
3676  int dir;
3677  char *str;
3678  object *caster;
3679  va_list args;
3680  int *rint;
3681 
3682  va_start(args, type);
3683  op = va_arg(args, object *);
3684  caster = va_arg(args, object *);
3685  dir = va_arg(args, int);
3686  sp = va_arg(args, object *);
3687  str = va_arg(args, char *);
3688  rint = va_arg(args, int *);
3689  va_end(args);
3690 
3691  *type = CFAPI_INT;
3692 
3693  if (!op->map) {
3694  *rint = -1;
3695  return;
3696  }
3697 
3698  *rint = cast_spell(op, caster, dir, sp, str);
3699 }
3700 
3701 static void cfapi_object_learn_spell(int *type, ...) {
3702  object *op;
3703  object *sp;
3704  int prayer;
3705  va_list args;
3706 
3707  va_start(args, type);
3708  op = va_arg(args, object *);
3709  sp = va_arg(args, object *);
3710  prayer = va_arg(args, int);
3711  va_end(args);
3712  do_learn_spell(op, sp, prayer);
3713  *type = CFAPI_NONE;
3714 }
3715 
3716 static void cfapi_object_forget_spell(int *type, ...) {
3717  object *op;
3718  object *sp;
3719  va_list args;
3720  char name[MAX_BUF];
3721 
3722  va_start(args, type);
3723  op = va_arg(args, object *);
3724  sp = va_arg(args, object *);
3725  va_end(args);
3726  query_name(sp, name, MAX_BUF);
3728  *type = CFAPI_NONE;
3729 }
3730 
3736 static void cfapi_object_check_spell(int *type, ...) {
3737  object *op;
3738  char *spellname;
3739  va_list args;
3740  object **robj;
3741 
3742  va_start(args, type);
3743  op = va_arg(args, object *);
3744  spellname = va_arg(args, char *);
3745  robj = va_arg(args, object **);
3746  va_end(args);
3747  *robj = check_spell_known(op, spellname);
3748  *type = CFAPI_POBJECT;
3749 }
3750 
3756 static void cfapi_object_pay_amount(int *type, ...) {
3757  object *op;
3758  uint64_t amount;
3759  va_list args;
3760  int *rint;
3761 
3762  va_start(args, type);
3763  op = va_arg(args, object *);
3764  amount = va_arg(args, uint64_t);
3765  rint = va_arg(args, int *);
3766  va_end(args);
3767 
3768  *rint = pay_for_amount(amount, op);
3769  *type = CFAPI_INT;
3770 }
3771 
3777 static void cfapi_object_pay_item(int *type, ...) {
3778  object *op;
3779  object *tobuy;
3780  int *rint;
3781 
3782  va_list args;
3783 
3784  va_start(args, type);
3785  tobuy = va_arg(args, object *);
3786  op = va_arg(args, object *);
3787  rint = va_arg(args, int *);
3788  va_end(args);
3789 
3790  *rint = pay_for_item(tobuy, op, 0);
3791  *type = CFAPI_INT;
3792 }
3793 
3801 static void cfapi_object_transfer(int *type, ...) {
3802  object *op;
3803  object *originator;
3804  int x, y, randompos, ttype, flag;
3805  va_list args;
3806  mapstruct *map;
3807  int *rint;
3808  object **robj;
3809 
3810  va_start(args, type);
3811  op = va_arg(args, object *);
3812  ttype = va_arg(args, int);
3813  switch (ttype) {
3814  case 0:
3815  x = va_arg(args, int);
3816  y = va_arg(args, int);
3817  randompos = va_arg(args, int);
3818  originator = va_arg(args, object *);
3819  rint = va_arg(args, int *);
3820  va_end(args);
3821 
3822  *rint = transfer_ob(op, x, y, randompos, originator);
3823  *type = CFAPI_INT;
3824  return;
3825  break;
3826 
3827  case 1:
3828  map = va_arg(args, mapstruct *);
3829  originator = va_arg(args, object *);
3830  flag = va_arg(args, int);
3831  x = va_arg(args, int);
3832  y = va_arg(args, int);
3833  robj = va_arg(args, object **);
3834  va_end(args);
3835  if (x < 0 || y < 0) {
3836  x = map->enter_x;
3837  y = map->enter_y;
3838  }
3839  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
3840  *type = CFAPI_POBJECT;
3841  return;
3842  break;
3843 
3844  case 2:
3845  x = va_arg(args, int);
3846  y = va_arg(args, int);
3847  rint = va_arg(args, int *);
3848  va_end(args);
3849 
3850  *rint = move_to(op, x, y);
3851  *type = CFAPI_INT;
3852  return;
3853 
3854  default:
3855  va_end(args);
3856  *type = CFAPI_NONE;
3857  return;
3858  break;
3859  }
3860 }
3861 
3866  object *op;
3867  char *str;
3868  va_list args;
3869  object **robj;
3870 
3871  *type = CFAPI_POBJECT;
3872  va_start(args, type);
3873  op = va_arg(args, object *);
3874 
3875  str = va_arg(args, char *);
3876  robj = va_arg(args, object **);
3878  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
3879  if (*robj == NULL) {
3880  char name[MAX_BUF];
3881 
3882  /* Search by name or slaying instead */
3883  FOR_INV_PREPARE(op, tmp) {
3884  if (tmp->name) {
3886  if (!strncmp(name, str, strlen(str)))
3887  *robj = tmp;
3888  if (!strncmp(tmp->name, str, strlen(str)))
3889  *robj = tmp;
3890  }
3891  if (tmp->slaying && !strcmp(tmp->slaying, str))
3892  *robj = tmp;
3893  if (*robj != NULL)
3894  break;
3895  } FOR_INV_FINISH();
3896  }
3897  va_end(args);
3898 }
3899 
3900 static void cfapi_object_find_by_arch_name(int *type, ...) {
3901  const object *who;
3902  object **result;
3903  const char *name;
3904  va_list args;
3905 
3906  va_start(args, type);
3907  who = va_arg(args, const object *);
3908  name = va_arg(args, const char *);
3909  result = va_arg(args, object **);
3910  va_end(args);
3911  *type = CFAPI_POBJECT;
3912 
3914 }
3915 
3916 static void cfapi_object_find_by_name(int *type, ...) {
3917  const object *who;
3918  object **result;
3919  const char *name;
3920  va_list args;
3921 
3922  va_start(args, type);
3923  who = va_arg(args, const object *);
3924  name = va_arg(args, const char *);
3925  result = va_arg(args, object **);
3926  va_end(args);
3927  *type = CFAPI_POBJECT;
3928 
3930 }
3931 
3937 static void cfapi_object_drop(int *type, ...) {
3938  object *op;
3939  object *author;
3940  va_list args;
3941 
3942  va_start(args, type);
3943  op = va_arg(args, object *);
3944  author = va_arg(args, object *);
3945  va_end(args);
3946  *type = CFAPI_NONE;
3947 
3948  if (QUERY_FLAG(op, FLAG_NO_DROP))
3949  return;
3950  drop(author, op);
3951 
3952  if (author->type == PLAYER) {
3953  author->contr->count = 0;
3954  author->contr->socket->update_look = 1;
3955  }
3956 }
3957 
3961 static void cfapi_object_change_abil(int *type, ...) {
3962  object *op, *tmp;
3963  int *rint;
3964  va_list args;
3965 
3966  va_start(args, type);
3967  op = va_arg(args, object *);
3968  tmp = va_arg(args, object *);
3969  rint = va_arg(args, int *);
3970  va_end(args);
3971 
3972  *type = CFAPI_INT;
3973  *rint = change_abil(op, tmp);
3974 }
3975 
3976 static void cfapi_object_say(int *type, ...) {
3977  object *op;
3978  char *msg;
3979  va_list args;
3980  int *rint;
3981  char empty[] = "";
3982 
3983  va_start(args, type);
3984  op = va_arg(args, object *);
3985  msg = va_arg(args, char *);
3986  rint = va_arg(args, int *);
3987  va_end(args);
3988 
3989  if (op->type == PLAYER) {
3990  command_say(op, msg == NULL ? empty : msg);
3991  } else {
3993  }
3994  *rint = 0;
3995  *type = CFAPI_INT;
3996 }
3997 
3998 /* PLAYER SUBCLASS */
3999 
4005 static void cfapi_player_find(int *type, ...) {
4006  va_list args;
4007  char *sval;
4008  player **rpl;
4009  va_start(args, type);
4010 
4011  sval = va_arg(args, char *);
4012  rpl = va_arg(args, player **);
4013  va_end(args);
4014 
4015  *rpl = find_player_partial_name(sval);
4016 
4017  *type = CFAPI_PPLAYER;
4018 }
4019 
4020 static void cfapi_player_message(int *type, ...) {
4021  va_list args;
4022  int flags;
4023  int pri;
4024  object *pl;
4025  char *buf;
4026 
4027  va_start(args, type);
4028 
4029  flags = va_arg(args, int);
4030  pri = va_arg(args, int);
4031  pl = va_arg(args, object *);
4032  buf = va_arg(args, char *);
4033  va_end(args);
4034 
4036  buf);
4037  *type = CFAPI_NONE;
4038 }
4039 
4046 static void cfapi_object_perm_exp(int *type, ...) {
4047  va_list args;
4048  object *op;
4049  int64_t *rlong;
4050 
4051  va_start(args, type);
4052  op = va_arg(args, object *);
4053  rlong = va_arg(args, int64_t *);
4054  va_end(args);
4055 
4056  *type = CFAPI_SINT64;
4057  *rlong = PERM_EXP(op->total_exp);
4058 }
4059 
4065 static void cfapi_object_change_exp(int *type, ...) {
4066  va_list args;
4067  int flag;
4068  object *ob;
4069  const char *skill;
4070  int64_t exp;
4071 
4072  va_start(args, type);
4073  ob = va_arg(args, object *);
4074  exp = va_arg(args, int64_t);
4075  skill = va_arg(args, const char *);
4076  flag = va_arg(args, int);
4077  va_end(args);
4078 
4079  *type = CFAPI_NONE;
4080  change_exp(ob, exp, skill, flag);
4081 }
4082 
4088 static void cfapi_player_can_pay(int *type, ...) {
4089  va_list args;
4090  object *pl;
4091  int *rint;
4092 
4093  va_start(args, type);
4094  pl = va_arg(args, object *);
4095  rint = va_arg(args, int *);
4096  va_end(args);
4097 
4098  *rint = can_pay(pl);
4099  *type = CFAPI_INT;
4100 }
4101 
4107 static void cfapi_player_knowledge(int *type, ...) {
4108  va_list args;
4109  object *pl;
4110  int *rint, what;
4111  const char *knowledge;
4112 
4113  va_start(args, type);
4114  what = va_arg(args, int);
4115 
4116  switch(what)
4117  {
4118  case 1:
4119  pl = va_arg(args, object *);
4120  knowledge = va_arg(args, const char *);
4121  rint = va_arg(args, int *);
4122 
4123  *type = CFAPI_INT;
4124 
4125  if (pl->contr == NULL) {
4126  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4127  *rint = 0;
4128  va_end(args);
4129  return;
4130  }
4131 
4132  *rint = knowledge_player_knows(pl->contr, knowledge);
4133  break;
4134 
4135  case 2:
4136  pl = va_arg(args, object *);
4137  knowledge = va_arg(args, const char *);
4138  *type = CFAPI_NONE;
4139  if (pl->contr != NULL)
4140  knowledge_give(pl->contr, knowledge, NULL);
4141 
4142  break;
4143 
4144  default:
4145  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4146  }
4147 
4148  va_end(args);
4149 }
4150 
4156 static void cfapi_object_teleport(int *type, ...) {
4157  mapstruct *map;
4158  int x, y;
4159  object *who;
4160  int *res;
4161  va_list args;
4162 
4163  va_start(args, type);
4164  who = va_arg(args, object *);
4165  map = va_arg(args, mapstruct *);
4166  x = va_arg(args, int);
4167  y = va_arg(args, int);
4168  res = va_arg(args, int *);
4169  va_end(args);
4170 
4171  *type = CFAPI_INT;
4172  *res = object_teleport(who, map, x, y);
4173 }
4174 
4175 static void cfapi_object_pickup(int *type, ...) {
4176  object *who;
4177  object *what;
4178  va_list args;
4179 
4180  va_start(args, type);
4181  who = va_arg(args, object *);
4182  what = va_arg(args, object *);
4183  va_end(args);
4184 
4185  pick_up(who, what);
4186  *type = CFAPI_NONE;
4187 }
4188 
4189 /* Archetype-related functions */
4190 static void cfapi_archetype_get_property(int *type, ...) {
4191  int prop;
4192  archetype *arch;
4193  va_list args;
4194  sstring *rsstring;
4195  archetype **rarch;
4196  object **robject;
4197 
4198  va_start(args, type);
4199  arch = va_arg(args, archetype *);
4200  prop = va_arg(args, int);
4201  switch (prop) {
4202  case CFAPI_ARCH_PROP_NAME:
4203  *type = CFAPI_SSTRING;
4204  rsstring = va_arg(args, sstring *);
4205  *rsstring = arch->name;
4206  break;
4207 
4208  case CFAPI_ARCH_PROP_NEXT:
4209  *type = CFAPI_PARCH;
4210  rarch = va_arg(args, archetype **);
4211  *rarch = get_next_archetype(arch);
4212  break;
4213 
4214  case CFAPI_ARCH_PROP_HEAD:
4215  *type = CFAPI_PARCH;
4216  rarch = va_arg(args, archetype **);
4217  *rarch = arch->head;
4218  break;
4219 
4220  case CFAPI_ARCH_PROP_MORE:
4221  *type = CFAPI_PARCH;
4222  rarch = va_arg(args, archetype **);
4223  *rarch = arch->more;
4224  break;
4225 
4226  case CFAPI_ARCH_PROP_CLONE:
4227  *type = CFAPI_POBJECT;
4228  robject = va_arg(args, object **);
4229  *robject = &arch->clone;
4230  break;
4231 
4232  default:
4233  *type = CFAPI_NONE;
4234  break;
4235  }
4236  va_end(args);
4237 }
4238 
4245 static void cfapi_party_get_property(int *type, ...) {
4246  partylist *party;
4247  int prop;
4248  va_list args;
4249  object *obarg;
4250  sstring *rsstring;
4251  player **rplayer;
4252  partylist **rparty;
4253 
4254  va_start(args, type);
4255  party = va_arg(args, partylist *);
4256  prop = va_arg(args, int);
4257  switch (prop) {
4258  case CFAPI_PARTY_PROP_NAME:
4259  rsstring = va_arg(args, sstring *);
4260  *rsstring = party->partyname;
4261  *type = CFAPI_SSTRING;
4262  break;
4263 
4264  case CFAPI_PARTY_PROP_NEXT:
4265  rparty = va_arg(args, partylist **);
4266  *rparty = (party ? party_get_next(party) : party_get_first());
4267  *type = CFAPI_PPARTY;
4268  break;
4269 
4271  rsstring = va_arg(args, sstring *);
4272  *rsstring = party_get_password(party);
4273  *type = CFAPI_SSTRING;
4274  break;
4275 
4277  *type = CFAPI_PPLAYER;
4278  obarg = va_arg(args, object *);
4279  rplayer = va_arg(args, player **);
4280  *rplayer = (obarg ? obarg->contr : first_player);
4281  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4282  if ((*rplayer)->ob->contr->party == party) {
4283  break;
4284  }
4285  break;
4286 
4287  default:
4288  *type = CFAPI_NONE;
4289  break;
4290  }
4291  va_end(args);
4292 }
4293 
4300 static void cfapi_region_get_property(int *type, ...) {
4301  region *reg;
4302  int prop, *rint;
4303  va_list args;
4305  sstring *rsstring;
4306  region **rregion;
4307 
4308  va_start(args, type);
4309  reg = va_arg(args, region *);
4310  prop = va_arg(args, int);
4311  switch (prop) {
4313  rsstring = va_arg(args, sstring *);
4314  *rsstring = reg->name;
4315  *type = CFAPI_SSTRING;
4316  break;
4317 
4319  rregion = va_arg(args, region **);
4320  *rregion = region_get_next(reg);
4321  *type = CFAPI_PREGION;
4322  break;
4323 
4325  rregion = va_arg(args, region **);
4326  *rregion = reg->parent;
4327  *type = CFAPI_PREGION;
4328  break;
4329 
4331  rsstring = va_arg(args, sstring *);
4332  *rsstring = reg->longname;
4333  *type = CFAPI_SSTRING;
4334  break;
4335 
4337  rsstring = va_arg(args, sstring *);
4338  *rsstring = reg->msg;
4339  *type = CFAPI_SSTRING;
4340  break;
4341 
4344  rint = va_arg(args, int*);
4345  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4346  *type = CFAPI_INT;
4347  break;
4348 
4350  rsstring = va_arg(args, sstring *);
4351  *rsstring = reg->jailmap;
4352  *type = CFAPI_SSTRING;
4353  break;
4354 
4355  default:
4356  *type = CFAPI_NONE;
4357  break;
4358  }
4359  va_end(args);
4360 }
4361 
4373 static void cfapi_friendlylist_get_next(int *type, ...) {
4374  object *ob;
4375  va_list args;
4376  object **robject;
4377 
4378  va_start(args, type);
4379  ob = va_arg(args, object *);
4380  robject = va_arg(args, object **);
4381  va_end(args);
4382 
4383  *type = CFAPI_POBJECT;
4384  *robject = get_next_friend(ob);
4385 }
4386 
4387 /*
4388  * Random-map related stuff.
4389  */
4390 
4397 static void cfapi_set_random_map_variable(int *type, ...) {
4398  va_list args;
4399  RMParms *rp;
4400  const char *buf;
4401  int *ret;
4402 
4403  va_start(args, type);
4404  rp = va_arg(args, RMParms *);
4405  buf = va_arg(args, const char *);
4406  ret = va_arg(args, int *);
4407  va_end(args);
4408 
4409  *ret = set_random_map_variable(rp, buf);
4410  *type = CFAPI_INT;
4411 }
4412 
4419 static void cfapi_generate_random_map(int *type, ...) {
4420  va_list args;
4421  const char *name;
4422  RMParms *rp;
4423  char **use_layout;
4424  sstring reset_group;
4425  mapstruct **ret;
4426 
4427  va_start(args, type);
4428  name = va_arg(args, const char *);
4429  rp = va_arg(args, RMParms *);
4430  use_layout = va_arg(args, char **);
4431  reset_group = va_arg(args, sstring);
4432  ret = va_arg(args, mapstruct **);
4433  va_end(args);
4434 
4435  *ret = generate_random_map(name, rp, use_layout, reset_group);
4436 }
4437 
4438 static void cfapi_object_user_event(int *type, ...) {
4439  object *op;
4440  object *activator;
4441  object *third;
4442  const char *message;
4443  int fix;
4444  int *ret;
4445  va_list args;
4446 
4447  va_start(args, type);
4448  op = va_arg(args, object *);
4449  activator = va_arg(args, object *);
4450  third = va_arg(args, object *);
4451  message = va_arg(args, const char *);
4452  fix = va_arg(args, int);
4453  ret = va_arg(args, int *);
4454  va_end(args);
4455 
4456  *ret = events_execute_object_user(op, activator, third, message, fix);
4457  *type = CFAPI_INT;
4458 }
4459 
4462 static void cfapi_player_quest(int *type, ...) {
4463  int op;
4464  va_list args;
4465  object *player;
4466  sstring code;
4467 
4468  va_start(args, type);
4469  op = va_arg(args, int);
4470  player = va_arg(args, object *);
4471  code = va_arg(args, sstring);
4472 
4473  if (player->contr == NULL) {
4474  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4475  va_end(args);
4476  /* crash/quit? */
4477  return;
4478  }
4479 
4480  switch(op) {
4481  case CFAPI_PLAYER_QUEST_START: {
4482  int state = va_arg(args, int);
4483  quest_start(player->contr, code, state);
4484  *type = CFAPI_NONE;
4485  break;
4486  }
4488  int *ret = va_arg(args, int *);
4489  *ret = quest_get_player_state(player->contr, code);
4490  *type = CFAPI_INT;
4491  break;
4492  }
4494  int state = va_arg(args, int);
4495  quest_set_player_state(player->contr, code, state);
4496  *type = CFAPI_NONE;
4497  break;
4498  }
4500  int *ret = va_arg(args, int*);
4501  *ret = quest_was_completed(player->contr, code);
4502  *type = CFAPI_INT;
4503  break;
4504  }
4505  default:
4506  LOG(llevError, "invalid quest type: %d\n", op);
4507  *type = CFAPI_NONE;
4508  }
4509 
4510  va_end(args);
4511 }
4512 
4513 static void cfapi_register_command(int *type, ...) {
4514  va_list args;
4515  const char *name = NULL, *extra = NULL;
4516  float time;
4517  command_function func = NULL;
4518  command_function_extra func_extra = NULL;
4519  uint8_t register_type, command_type;
4521 
4522  va_start(args, type);
4523  register_type = va_arg(args, int);
4524  name = va_arg(args, const char *);
4525  if (register_type == 1) {
4526  func = va_arg(args, command_function);
4527  } else {
4528  extra = va_arg(args, const char *);
4529  func_extra = va_arg(args, command_function_extra);
4530  }
4531  command_type = (uint8_t)va_arg(args, int);
4532  if (command_type > COMMAND_TYPE_WIZARD) {
4533  command_type = COMMAND_TYPE_NORMAL;
4534  }
4535  time = va_arg(args, double);
4536  cr = va_arg(args, command_registration *);
4537  va_end(args);
4538 
4539  if (register_type == 1) {
4540  (*cr) = command_register(name, command_type, func, time);
4541  } else {
4542  (*cr) = command_register_extra(name, extra, command_type, func_extra, time);
4543  }
4544 
4545  *type = CFAPI_SINT64;
4546 }
4547 
4548 static void cfapi_unregister_command(int *type, ...) {
4549  va_list args;
4551 
4552  va_start(args, type);
4553  cr = va_arg(args, command_registration);
4554  va_end(args);
4555 
4556  command_unregister(cr);
4557 }
4558 
4559 /*****************************************************************************/
4560 /* NEW PLUGIN STUFF ENDS HERE */
4561 /*****************************************************************************/
4562 
4563 
4568 void initPlugins(void) {
4569  struct dirent *currentfile;
4570  DIR *plugdir;
4571  size_t l;
4572  char buf[MAX_BUF];
4573 
4574  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4575  LOG(llevDebug, "plugins: loading from %s\n", buf);
4576 
4577  plugdir = opendir(buf);
4578  if (plugdir == NULL)
4579  return;
4580 
4581  while ((currentfile = readdir(plugdir)) != NULL) {
4582  l = strlen(currentfile->d_name);
4583  if (l > strlen(PLUGIN_SUFFIX)) {
4584  int ignore = 0;
4585 
4586  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4587  continue;
4588 
4589  for (auto disable = settings.disabled_plugins.cbegin(); disable != settings.disabled_plugins.cend(); ++disable) {
4590  if (strcmp(*disable, "All") == 0) {
4591  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4592  ignore = 1;
4593  break;
4594  }
4595  if (strncmp(*disable, currentfile->d_name, strlen(*disable)) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + strlen(*disable)) {
4596  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4597  ignore = 1;
4598  break;
4599  }
4600  }
4601  if (ignore == 0) {
4602  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4603  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4605  }
4606  }
4607  }
4608 
4609  closedir(plugdir);
4610 }
4611 
4616 void cleanupPlugins(void) {
4617  for (crossfire_plugin *cp : plugins_list) {
4618  if (cp->closefunc)
4619  cp->closefunc();
4620  /* Don't actually unload plugins, it makes backtraces for memory
4621  * debugging (printed at exit) messed up. And it doesn't matter if we
4622  * don't free it here. The OS will do it for us.
4623  */
4624  /* plugins_dlclose(cp->libptr); */
4625  free(cp);
4626  }
4627  plugins_list.clear();
4628 }
plugins_find_plugin
static crossfire_plugin * plugins_find_plugin(const char *id)
Definition: plugins.cpp:268
crossfire_plugin::propfunc
f_plug_property propfunc
Definition: plugin.h:96
GET_MAP_OB
#define GET_MAP_OB(M, X, Y)
Definition: map.h:173
Face
Definition: face.h:14
cfapi_object_transfer
static void cfapi_object_transfer(int *type,...)
Definition: plugins.cpp:3801
cfapi_object_clean_object
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.cpp:3561
cfapi_object_forget_spell
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.cpp:3716
cfapi_map_change_light
static void cfapi_map_change_light(int *type,...)
Definition: plugins.cpp:1429
CFAPI_SSTRING
#define CFAPI_SSTRING
Definition: plugin.h:70
UP_OBJ_FACE
#define UP_OBJ_FACE
Definition: object.h:522
CFAPI_OBJECT_PROP_TITLE
#define CFAPI_OBJECT_PROP_TITLE
Definition: plugin.h:132
cfapi_object_split
static void cfapi_object_split(int *type,...)
Definition: plugins.cpp:3432
PLAYER
@ PLAYER
Definition: object.h:110
CFAPI_PPLAYER
#define CFAPI_PPLAYER
Definition: plugin.h:64
object_get_owner
object * object_get_owner(object *op)
Definition: object.cpp:804
Settings::mapdir
const char * mapdir
Definition: global.h:251
player::next
player * next
Definition: player.h:106
cftimer_find_free_id
int cftimer_find_free_id(void)
Definition: timers.cpp:144
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:534
CFAPI_OBJECT_PROP_X
#define CFAPI_OBJECT_PROP_X
Definition: plugin.h:138
cfapi_object_move
static void cfapi_object_move(int *type,...)
Definition: plugins.cpp:1460
cfapi_timer_destroy
static void cfapi_timer_destroy(int *type,...)
Definition: plugins.cpp:992
first_player
player * first_player
Definition: init.cpp:106
settings
struct Settings settings
Definition: init.cpp:138
object_get_env_recursive
object * object_get_env_recursive(object *op)
Definition: object.cpp:590
CFAPI_POBJECT
#define CFAPI_POBJECT
Definition: plugin.h:58
banquet.l
l
Definition: banquet.py:164
CFAPI_PARTY_VECTOR
#define CFAPI_PARTY_VECTOR
Definition: plugin.h:76
f_plug_postinit
int(* f_plug_postinit)(void)
Definition: plugin.h:81
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
remove_friendly_object
void remove_friendly_object(object *op)
Definition: friend.cpp:52
CFAPI_OBJECT_VECTOR
#define CFAPI_OBJECT_VECTOR
Definition: plugin.h:72
CFAPI_OBJECT_PROP_CHA
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:203
CFAPI_MAP_PROP_TMPNAME
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h:248
CFAPI_OBJECT_PROP_ARCH_NAME
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:215
CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
Definition: plugin.h:178
llevError
@ llevError
Definition: logger.h:11
cfapi_object_distance
static void cfapi_object_distance(int *type,...)
Definition: plugins.cpp:3488
cfapi_object_delete
static void cfapi_object_delete(int *type,...)
Definition: plugins.cpp:3226
cfapi_player_quest
static void cfapi_player_quest(int *type,...)
Definition: plugins.cpp:4462
MOVE_ALL
#define MOVE_ALL
Definition: define.h:398
cfapi_timer_create
static void cfapi_timer_create(int *type,...)
Definition: plugins.cpp:959
command_say
void command_say(object *op, const char *params)
Definition: c_chat.cpp:34
CFAPI_PARTY_PROP_NAME
#define CFAPI_PARTY_PROP_NAME
Definition: plugin.h:270
cfapi_archetype_get_property
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.cpp:4190
NR_EVENTS
#define NR_EVENTS
Definition: events.h:59
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:51
get_empty_map
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.cpp:869
monster_npc_say
void monster_npc_say(object *npc, const char *cp)
Definition: monster.cpp:2495
CFAPI_MAP_PROP_RESET_TIME
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:250
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
drain_specific_stat
void drain_specific_stat(object *op, int deplete_stats)
Definition: living.cpp:728
CFAPI_MAP_PROP_RESET_TIMEOUT
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:251
cfapi_system_register_global_event
static void cfapi_system_register_global_event(int *type,...)
Definition: plugins.cpp:585
CFAPI_REGION_PROP_LONGNAME
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:278
cfapi_system_get_party_vector
static void cfapi_system_get_party_vector(int *type,...)
Definition: plugins.cpp:702
CFAPI_OBJECT_PROP_LEVEL
#define CFAPI_OBJECT_PROP_LEVEL
Definition: plugin.h:157
CFAPI_NONE
#define CFAPI_NONE
Definition: plugin.h:53
player
Definition: player.h:105
plugins_list
std::vector< crossfire_plugin * > plugins_list
Definition: plugins.cpp:257
CFAPI_PLAYER_PROP_BED_X
#define CFAPI_PLAYER_PROP_BED_X
Definition: plugin.h:234
strdup_local
#define strdup_local
Definition: compat.h:29
diamondslots.x
x
Definition: diamondslots.py:15
cfapi_object_drop
static void cfapi_object_drop(int *type,...)
Definition: plugins.cpp:3937
ready_map_name
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.cpp:1793
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
cfapi_system_get_map_vector
static void cfapi_system_get_map_vector(int *type,...)
Definition: plugins.cpp:654
CFAPI_REGION_PROP_NEXT
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:276
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
AssetsManager.h
CFAPI_MAP_PROP_NEXT
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:260
NR_OF_HOOKS
#define NR_OF_HOOKS
Definition: plugins.cpp:49
do_learn_spell
void do_learn_spell(object *op, object *spell, int special_prayer)
Definition: apply.cpp:484
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
Definition: global.h:327
has_been_loaded
mapstruct * has_been_loaded(const char *name)
Definition: map.cpp:78
map_find_by_archetype
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Definition: object.cpp:3111
object_merge
object * object_merge(object *op, object *top)
Definition: object.cpp:2049
get_next_friend
object * get_next_friend(object *current)
Definition: friend.cpp:143
CFAPI_OBJECT_PROP_SLAYING
#define CFAPI_OBJECT_PROP_SLAYING
Definition: plugin.h:134
cfapi_get_weekday_name
static void cfapi_get_weekday_name(int *type,...)
Definition: plugins.cpp:920
update_position
void update_position(mapstruct *m, int x, int y)
Definition: map.cpp:2141
CFAPI_OBJECT_PROP_DEX
#define CFAPI_OBJECT_PROP_DEX
Definition: plugin.h:198
CFAPI_OBJECT_PROP_FRIENDLY
#define CFAPI_OBJECT_PROP_FRIENDLY
Definition: plugin.h:185
CFAPI_OBJECT_PROP_ARCHETYPE
#define CFAPI_OBJECT_PROP_ARCHETYPE
Definition: plugin.h:181
cfapi_map_out_of_map
static void cfapi_map_out_of_map(int *type,...)
Definition: plugins.cpp:1300
Settings::datadir
const char * datadir
Definition: global.h:248
cast_spell
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Definition: spell_util.cpp:1424
events_unregister_object_handler
void events_unregister_object_handler(const char *id)
Definition: events.cpp:287
CFAPI_OBJECT_PROP_BASE_NAME
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:187
hook_entry
Definition: plugin.h:307
UPD_WEIGHT
#define UPD_WEIGHT
Definition: newclient.h:316
object_set_enemy
void object_set_enemy(object *op, object *enemy)
Definition: object.cpp:915
CFAPI_OBJECT_PROP_LAST_EAT
#define CFAPI_OBJECT_PROP_LAST_EAT
Definition: plugin.h:161
CFAPI_OBJECT_PROP_MOVE_ON
#define CFAPI_OBJECT_PROP_MOVE_ON
Definition: plugin.h:223
player::ob
object * ob
Definition: player.h:176
spring_trap
void spring_trap(object *trap, object *victim)
Definition: rune.cpp:205
cfapi_object_get_property
static void cfapi_object_get_property(int *type,...)
Definition: plugins.cpp:1555
crossfire_plugin::fullname
char fullname[MAX_BUF]
Definition: plugin.h:100
CFAPI_FUNC
#define CFAPI_FUNC
Definition: plugin.h:63
guildoracle.list
list
Definition: guildoracle.py:87
CFAPI_OBJECT_PROP_STR
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:197
cfapi_object_create
static void cfapi_object_create(int *type,...)
Definition: plugins.cpp:3285
SVN_REV
#define SVN_REV
Definition: svnversion.h:2
cfapi_object_drain
static void cfapi_object_drain(int *type,...)
Definition: plugins.cpp:3118
give_skill_by_name
object * give_skill_by_name(object *op, const char *skill_name)
Definition: living.cpp:1777
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.cpp:716
CFAPI_OBJECT_PROP_GOD
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:214
MoveType
unsigned char MoveType
Definition: define.h:417
arch_present_in_ob
object * arch_present_in_ob(const archetype *at, const object *op)
Definition: object.cpp:3215
object_set_owner
void object_set_owner(object *op, object *owner)
Definition: object.cpp:840
guildjoin.ob
ob
Definition: guildjoin.py:42
timeofday_t
Definition: tod.h:38
CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
Definition: plugin.h:122
player_set_own_title
void player_set_own_title(struct player *pl, const char *title)
Definition: player.cpp:272
CFAPI_PLAYER_PROP_MARKED_ITEM
#define CFAPI_PLAYER_PROP_MARKED_ITEM
Definition: plugin.h:231
SET_ANIMATION
#define SET_ANIMATION(ob, newanim)
Definition: global.h:162
cfapi_object_find_archetype_inside
static void cfapi_object_find_archetype_inside(int *type,...)
Definition: plugins.cpp:3865
CFAPI_SYSTEM_ARCHETYPES
#define CFAPI_SYSTEM_ARCHETYPES
Definition: plugin.h:286
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
giveknowledge.knowledge
knowledge
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: giveknowledge.py:15
CFAPI_OBJECT_PROP_MAXSP
#define CFAPI_OBJECT_PROP_MAXSP
Definition: plugin.h:211
CFAPI_OBJECT_PROP_RAW_NAME
#define CFAPI_OBJECT_PROP_RAW_NAME
Definition: plugin.h:228
npc_dialog.player
player
Definition: npc_dialog.py:97
CFAPI_OBJECT_PROP_SPELL_ITEM
#define CFAPI_OBJECT_PROP_SPELL_ITEM
Definition: plugin.h:179
move_player
int move_player(object *op, int dir)
Definition: player.cpp:2936
object_reset
void object_reset(object *op)
Definition: object.cpp:934
CFAPI_ARCH_PROP_NEXT
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:265
CFAPI_OBJECT_PROP_Y
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:139
flags
static const flag_definition flags[]
Definition: gridarta-types-convert.cpp:101
object::count
tag_t count
Definition: object.h:305
CFAPI_OBJECT_PROP_ENEMY
#define CFAPI_OBJECT_PROP_ENEMY
Definition: plugin.h:172
object_copy
void object_copy(const object *src_ob, object *dest_ob)
Definition: object.cpp:1192
clean_object
void clean_object(object *op)
Definition: map.cpp:1621
CFAPI_OBJECT_PROP_MOVE_TYPE
#define CFAPI_OBJECT_PROP_MOVE_TYPE
Definition: plugin.h:220
fix_object
void fix_object(object *op)
Definition: living.cpp:1125
get_tod
void get_tod(timeofday_t *tod)
Definition: time.cpp:215
Ice.tmp
int tmp
Definition: Ice.py:207
CFAPI_OBJECT_PROP_FACE
#define CFAPI_OBJECT_PROP_FACE
Definition: plugin.h:217
cfapi_object_say
static void cfapi_object_say(int *type,...)
Definition: plugins.cpp:3976
CFAPI_REGION_PROP_PARENT
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:277
plugin.h
CFAPI_OBJECT_PROP_ENVIRONMENT
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:125
COMMAND_TYPE_NORMAL
#define COMMAND_TYPE_NORMAL
Definition: commands.h:35
CFAPI_PPARTY
#define CFAPI_PPARTY
Definition: plugin.h:65
CFAPI_OBJECT_PROP_ATTACKED_BY
#define CFAPI_OBJECT_PROP_ATTACKED_BY
Definition: plugin.h:173
region::name
char * name
Definition: map.h:276
generate_random_map
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout, sstring reset_group)
Definition: random_map.cpp:75
UPD_NROF
#define UPD_NROF
Definition: newclient.h:321
FOR_ABOVE_PREPARE
#define FOR_ABOVE_PREPARE(op_, it_)
Definition: define.h:687
CFAPI_SYSTEM_PLAYERS
#define CFAPI_SYSTEM_PLAYERS
Definition: plugin.h:285
CFAPI_OBJECT_PROP_PRESENT
#define CFAPI_OBJECT_PROP_PRESENT
Definition: plugin.h:192
CFAPI_REGION_PROP_JAIL_PATH
#define CFAPI_REGION_PROP_JAIL_PATH
Definition: plugin.h:282
CFAPI_MAP_PROP_WIDTH
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:255
cfapi_get_hooks
static void cfapi_get_hooks(int *type,...)
Definition: plugins.cpp:327
CFAPI_ARCH_PROP_NAME
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:264
CFAPI_OBJECT_PROP_ITEM_POWER
#define CFAPI_OBJECT_PROP_ITEM_POWER
Definition: plugin.h:164
CFAPI_MAP_PROP_UNIQUE
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:262
f_plug_init
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:83
partylist
Definition: party.h:10
smoking_pipe.color
color
Definition: smoking_pipe.py:5
apply_manual
int apply_manual(object *op, object *tmp, int aflag)
Definition: apply.cpp:597
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.cpp:4339
CFAPI_FLOAT
#define CFAPI_FLOAT
Definition: plugin.h:60
apply_by_living_below
void apply_by_living_below(object *pl)
Definition: apply.cpp:695
MSG_TYPE_MISC
#define MSG_TYPE_MISC
Definition: newclient.h:413
initPlugins
void initPlugins(void)
Definition: plugins.cpp:4568
CFAPI_OBJECT_PROP_CURRENT_WEAPON
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON
Definition: plugin.h:171
cfapi_friendlylist_get_next
static void cfapi_friendlylist_get_next(int *type,...)
Definition: plugins.cpp:4373
buf
StringBuffer * buf
Definition: readable.cpp:1551
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
cfapi_object_identify
static void cfapi_object_identify(int *type,...)
Definition: plugins.cpp:3076
cfapi_map_set_map_property
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.cpp:1270
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.cpp:2851
RMParms
Definition: random_map.h:14
crossfire_plugin::libptr
LIBPTRTYPE libptr
Definition: plugin.h:98
cfapi_object_user_event
static void cfapi_object_user_event(int *type,...)
Definition: plugins.cpp:4438
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Definition: newclient.h:404
CFAPI_MAP_PROP_ENTER_X
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:257
cfapi_object_update
static void cfapi_object_update(int *type,...)
Definition: plugins.cpp:3509
CFAPI_OBJECT_PROP_INVISIBLE
#define CFAPI_OBJECT_PROP_INVISIBLE
Definition: plugin.h:216
cfapi_system_directory
static void cfapi_system_directory(int *type,...)
Definition: plugins.cpp:824
plugins_dlerror
#define plugins_dlerror()
Definition: plugin.h:115
cfapi_object_change_abil
static void cfapi_object_change_abil(int *type,...)
Definition: plugins.cpp:3961
get_season_name
const char * get_season_name(const int index)
Definition: time.cpp:125
CFAPI_OBJECT_PROP_SKILL
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:135
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:147
object_clear
void object_clear(object *op)
Definition: object.cpp:983
region::longname
char * longname
Definition: map.h:282
party_join
void party_join(object *op, partylist *party)
Definition: party.cpp:85
cfapi_object_get_key
static void cfapi_object_get_key(int *type,...)
Definition: plugins.cpp:1510
TIMER_ERR_ID
#define TIMER_ERR_ID
Definition: timers.h:67
MSG_TYPE_COMMAND_DEBUG
#define MSG_TYPE_COMMAND_DEBUG
Definition: newclient.h:528
plugins_remove_plugin
int plugins_remove_plugin(const char *id)
Definition: plugins.cpp:454
CFAPI_OBJECT_PROP_PATH_DENIED
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:152
CFAPI_MAP_PROP_REGION
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:261
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:184
m
static event_registration m
Definition: citylife.cpp:425
cfapi_system_unregister_global_event
static void cfapi_system_unregister_global_event(int *type,...)
Definition: plugins.cpp:606
CFAPI_OBJECT_PROP_AC
#define CFAPI_OBJECT_PROP_AC
Definition: plugin.h:205
events_register_object_handler
void events_register_object_handler(const char *id, f_plug_event handler)
Definition: events.cpp:282
autojail.who
who
Definition: autojail.py:3
cfapi_register_command
static void cfapi_register_command(int *type,...)
Definition: plugins.cpp:4513
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.cpp:76
party_get_first
partylist * party_get_first(void)
Definition: party.cpp:196
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.cpp:1560
object_update
void object_update(object *op, int action)
Definition: object.cpp:1434
object::contr
struct player * contr
Definition: object.h:282
object_find_by_name
object * object_find_by_name(const object *who, const char *name)
Definition: object.cpp:3949
cfapi_player_find
static void cfapi_player_find(int *type,...)
Definition: plugins.cpp:4005
opendir
DIR * opendir(const char *)
CFAPI_OBJECT_PROP_LORE
#define CFAPI_OBJECT_PROP_LORE
Definition: plugin.h:137
CFAPI_ARCH_PROP_HEAD
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:266
disinfect.map
map
Definition: disinfect.py:4
CFAPI_OBJECT_PROP_PICK_UP
#define CFAPI_OBJECT_PROP_PICK_UP
Definition: plugin.h:163
CFAPI_OBJECT_PROP_MOVE_OFF
#define CFAPI_OBJECT_PROP_MOVE_OFF
Definition: plugin.h:224
FLAG_WAS_WIZ
#define FLAG_WAS_WIZ
Definition: define.h:234
CFAPI_PLAYER_PROP_PARTY
#define CFAPI_PLAYER_PROP_PARTY
Definition: plugin.h:232
command_unregister
void command_unregister(command_registration command)
Definition: commands.cpp:534
hook_entry::func
f_plug_api func
Definition: plugin.h:308
cfapi_player_can_pay
static void cfapi_player_can_pay(int *type,...)
Definition: plugins.cpp:4088
determine_god
const char * determine_god(object *op)
Definition: gods.cpp:55
is_friendly
int is_friendly(const object *op)
Definition: friend.cpp:108
CFAPI_OBJECT_PROP_CHOSEN_SKILL
#define CFAPI_OBJECT_PROP_CHOSEN_SKILL
Definition: plugin.h:175
CFAPI_OBJECT_PROP_HP
#define CFAPI_OBJECT_PROP_HP
Definition: plugin.h:206
freearr_y
short freearr_y[SIZEOFFREE]
Definition: object.cpp:305
CFAPI_OBJECT_PROP_MAXHP
#define CFAPI_OBJECT_PROP_MAXHP
Definition: plugin.h:210
drop
void drop(object *op, object *tmp)
Definition: c_object.cpp:1168
diamondslots.activator
activator
Definition: diamondslots.py:10
make_face_from_files.args
args
Definition: make_face_from_files.py:31
cfapi_map_message
static void cfapi_map_message(int *type,...)
Definition: plugins.cpp:1351
get_weekday
const char * get_weekday(const int index)
Definition: time.cpp:118
cfapi_map_create_path
static void cfapi_map_create_path(int *type,...)
Definition: plugins.cpp:1104
rotate-tower.result
bool result
Definition: rotate-tower.py:13
CFAPI_OBJECT_PROP_OB_BELOW
#define CFAPI_OBJECT_PROP_OB_BELOW
Definition: plugin.h:121
cfapi_object_apply_below
static void cfapi_object_apply_below(int *type,...)
Definition: plugins.cpp:3031
CFAPI_OBJECT_PROP_HIDDEN
#define CFAPI_OBJECT_PROP_HIDDEN
Definition: plugin.h:176
CFAPI_OBJECT_PROP_CARRYING
#define CFAPI_OBJECT_PROP_CARRYING
Definition: plugin.h:168
CFAPI_OBJECT_PROP_TOTAL_EXP
#define CFAPI_OBJECT_PROP_TOTAL_EXP
Definition: plugin.h:170
move_ob
int move_ob(object *op, int dir, object *originator)
Definition: move.cpp:58
cftimer_destroy
int cftimer_destroy(int id)
Definition: timers.cpp:128
cfapi_set_random_map_variable
static void cfapi_set_random_map_variable(int *type,...)
Definition: plugins.cpp:4397
object_present_in_ob_by_name
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Definition: object.cpp:3196
CFAPI_PLAYER_PROP_BED_Y
#define CFAPI_PLAYER_PROP_BED_Y
Definition: plugin.h:235
query_name
void query_name(const object *op, char *buf, size_t size)
Definition: item.cpp:585
cfapi_object_remove_depletion
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.cpp:3136
CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
Definition: plugin.h:165
CFAPI_REGION_PROP_JAIL_Y
#define CFAPI_REGION_PROP_JAIL_Y
Definition: plugin.h:281
CFAPI_OBJECT_PROP_CHEATER
#define CFAPI_OBJECT_PROP_CHEATER
Definition: plugin.h:193
FOR_ABOVE_FINISH
#define FOR_ABOVE_FINISH()
Definition: define.h:694
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:259
Face::number
uint16_t number
Definition: face.h:15
cfapi_system_re_cmp
static void cfapi_system_re_cmp(int *type,...)
Definition: plugins.cpp:806
CFAPI_OBJECT_PROP_RACE
#define CFAPI_OBJECT_PROP_RACE
Definition: plugin.h:133
f_plug_api
void(* f_plug_api)(int *type,...)
Definition: plugin.h:79
cfapi_system_get_object_vector
static void cfapi_system_get_object_vector(int *type,...)
Definition: plugins.cpp:626
cfapi_party_get_property
static void cfapi_party_get_property(int *type,...)
Definition: plugins.cpp:4245
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
cfapi_object_check_spell
static void cfapi_object_check_spell(int *type,...)
Definition: plugins.cpp:3736
CFAPI_OBJECT_PROP_MOVE_BLOCK
#define CFAPI_OBJECT_PROP_MOVE_BLOCK
Definition: plugin.h:221
CFAPI_OBJECT_PROP_FACING
#define CFAPI_OBJECT_PROP_FACING
Definition: plugin.h:144
first_map
mapstruct * first_map
Definition: init.cpp:107
copy_message
static void copy_message(object *op, const char *msg)
Definition: plugins.cpp:2361
cfapi_system_find_face
static void cfapi_system_find_face(int *type,...)
Definition: plugins.cpp:548
CFAPI_INT
#define CFAPI_INT
Definition: plugin.h:54
region::parent
region * parent
Definition: map.h:277
CFAPI_OBJECT_PROP_WEIGHT
#define CFAPI_OBJECT_PROP_WEIGHT
Definition: plugin.h:166
cfapi_system_get_archetype_vector
static void cfapi_system_get_archetype_vector(int *type,...)
Definition: plugins.cpp:670
cfapi_object_reset
static void cfapi_object_reset(int *type,...)
Definition: plugins.cpp:3547
CFAPI_OBJECT_PROP_RESIST
#define CFAPI_OBJECT_PROP_RESIST
Definition: plugin.h:148
CFAPI_PLAYER_PROP_IP
#define CFAPI_PLAYER_PROP_IP
Definition: plugin.h:230
CFAPI_OBJECT_PROP_DAM
#define CFAPI_OBJECT_PROP_DAM
Definition: plugin.h:213
region::msg
char * msg
Definition: map.h:284
make_face_from_files.str
str
Definition: make_face_from_files.py:24
change_map_light
int change_map_light(mapstruct *m, int change)
Definition: map.cpp:2017
NDI_DELAYED
#define NDI_DELAYED
Definition: newclient.h:269
get_periodofday
const char * get_periodofday(const int index)
Definition: time.cpp:104
readdir
struct dirent * readdir(DIR *)
query_short_name
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.cpp:510
ext_info_map
void void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Definition: main.cpp:334
FLAG_FREED
#define FLAG_FREED
Definition: define.h:233
cfapi_map_has_been_loaded
static void cfapi_map_has_been_loaded(int *type,...)
Definition: plugins.cpp:1086
convert.action
action
Definition: convert.py:25
out_of_map
int out_of_map(mapstruct *m, int x, int y)
Definition: map.cpp:2320
region::jailmap
char * jailmap
Definition: map.h:288
find_string
sstring find_string(const char *str)
Definition: shstr.cpp:236
region_get_next
region * region_get_next(region *reg)
Definition: region.cpp:471
navar-midane_pickup.msg
list msg
Definition: navar-midane_pickup.py:13
crossfire_plugin::closefunc
f_plug_postinit closefunc
Definition: plugin.h:97
cfapi_object_remove
static void cfapi_object_remove(int *type,...)
Definition: plugins.cpp:3205
object_update_speed
void object_update_speed(object *op)
Definition: object.cpp:1349
cfapi_system_strdup_local
static void cfapi_system_strdup_local(int *type,...)
Definition: plugins.cpp:571
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Definition: global.h:204
crossfire_plugin::id
char id[MAX_BUF]
Definition: plugin.h:99
CFAPI_OBJECT_PROP_PATH_ATTUNED
#define CFAPI_OBJECT_PROP_PATH_ATTUNED
Definition: plugin.h:150
events_execute_object_user
int events_execute_object_user(object *op, object *activator, object *third, const char *message, int fix)
Definition: events.cpp:300
CFAPI_ARCH_PROP_CLONE
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:268
CFAPI_OBJECT_PROP_EXP
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:190
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:140
CFAPI_OBJECT_PROP_TYPE
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:145
quest_was_completed
int quest_was_completed(player *pl, sstring quest_code)
Definition: quest.cpp:726
CFAPI_OBJECT_PROP_NROF
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:142
object_create_arch
object * object_create_arch(archetype *at)
Definition: arch.cpp:298
CFAPI_PLAYER_PROP_TITLE
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:237
CFAPI_MAP_PROP_PATH
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:247
Settings::disabled_plugins
std::vector< char * > disabled_plugins
Definition: global.h:326
cfapi_object_transmute
static void cfapi_object_transmute(int *type,...)
Definition: plugins.cpp:3188
object_free
void object_free(object *ob, int flags)
Definition: object.cpp:1592
CFAPI_OBJECT_PROP_CUSTOM_NAME
#define CFAPI_OBJECT_PROP_CUSTOM_NAME
Definition: plugin.h:183
cfapi_region_get_property
static void cfapi_region_get_property(int *type,...)
Definition: plugins.cpp:4300
cfapi_unregister_command
static void cfapi_unregister_command(int *type,...)
Definition: plugins.cpp:4548
CFAPI_OBJECT_PROP_PICKABLE
#define CFAPI_OBJECT_PROP_PICKABLE
Definition: plugin.h:195
FOR_INV_FINISH
#define FOR_INV_FINISH()
Definition: define.h:677
CFAPI_PREGION
#define CFAPI_PREGION
Definition: plugin.h:66
CFAPI_REGION_VECTOR
#define CFAPI_REGION_VECTOR
Definition: plugin.h:75
change_exp
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Definition: living.cpp:2166
cfapi_object_teleport
static void cfapi_object_teleport(int *type,...)
Definition: plugins.cpp:4156
sstring
const typedef char * sstring
Definition: global.h:47
CFAPI_PLAYER_QUEST_START
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:240
CFAPI_REGION_PROP_NAME
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:275
cfapi_object_spring_trap
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.cpp:3588
archetype
Definition: object.h:472
CFAPI_OBJECT_PROP_INVISIBLE_TIME
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME
Definition: plugin.h:162
CFAPI_OBJECT_PROP_ATTACK_TYPE
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:149
CFAPI_SYSTEM_MAPS
#define CFAPI_SYSTEM_MAPS
Definition: plugin.h:284
move_to
int move_to(object *op, int x, int y)
Definition: move.cpp:563
CFAPI_REGION_PROP_JAIL_X
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:280
cfapi_get_time
static void cfapi_get_time(int *type,...)
Definition: plugins.cpp:877
cfapi_object_pay_item
static void cfapi_object_pay_item(int *type,...)
Definition: plugins.cpp:3777
Settings::confdir
const char * confdir
Definition: global.h:247
sproto.h
FLAG_NO_DROP
#define FLAG_NO_DROP
Definition: define.h:288
give.direction
direction
Definition: give.py:37
get_map_from_coord
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
Definition: map.cpp:2393
AssetsCollection::each
void each(std::function< void(T *)> op)
Definition: AssetsCollection.h:158
animate.anim
string anim
Definition: animate.py:20
get_face_by_id
const Face * get_face_by_id(uint16_t id)
Definition: assets.cpp:315
empty
const char * empty[]
Definition: check_treasure.cpp:107
crossfire_plugin::global_registration
event_registration global_registration[NR_EVENTS]
Definition: plugin.h:101
delete_map
void delete_map(mapstruct *m)
Definition: map.cpp:1730
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:420
partylist::partyname
char * partyname
Definition: party.h:14
CFAPI_OBJECT_PROP_OWNER
#define CFAPI_OBJECT_PROP_OWNER
Definition: plugin.h:191
cfapi_object_pickup
static void cfapi_object_pickup(int *type,...)
Definition: plugins.cpp:4175
CFAPI_SYSTEM_REGIONS
#define CFAPI_SYSTEM_REGIONS
Definition: plugin.h:287
cfapi_object_on_same_map
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.cpp:3572
CFAPI_OBJECT_PROP_NAME_PLURAL
#define CFAPI_OBJECT_PROP_NAME_PLURAL
Definition: plugin.h:131
object_insert_in_map_at
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.cpp:2098
object_create_clone
object * object_create_clone(object *asrc)
Definition: object.cpp:3902
CFAPI_PARTY_PROP_NEXT
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:271
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:155
P_OUT_OF_MAP
#define P_OUT_OF_MAP
Definition: map.h:250
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
MAX_BUF
#define MAX_BUF
Definition: define.h:35
cfapi_get_month_name
static void cfapi_get_month_name(int *type,...)
Definition: plugins.cpp:932
cfapi_system_check_path
static void cfapi_system_check_path(int *type,...)
Definition: plugins.cpp:783
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: porting.cpp:222
CFAPI_MAP_PROP_NAME
#define CFAPI_MAP_PROP_NAME
Definition: plugin.h:249
object_set_cheat
void object_set_cheat(object *op)
Definition: object.cpp:3267
object_new
object * object_new(void)
Definition: object.cpp:1273
create_overlay_pathname
void create_overlay_pathname(const char *name, char *buf, size_t size)
Definition: map.cpp:124
UP_OBJ_INSERT
#define UP_OBJ_INSERT
Definition: object.h:519
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.cpp:941
COMMAND_TYPE_WIZARD
#define COMMAND_TYPE_WIZARD
Definition: commands.h:39
CFAPI_OBJECT_PROP_WIS
#define CFAPI_OBJECT_PROP_WIS
Definition: plugin.h:200
object_present_in_ob
object * object_present_in_ob(uint8_t type, const object *op)
Definition: object.cpp:3161
CFAPI_OBJECT_PROP_POW
#define CFAPI_OBJECT_PROP_POW
Definition: plugin.h:202
free_string
void free_string(sstring str)
Definition: shstr.cpp:280
transfer_ob
int transfer_ob(object *op, int x, int y, int randomly, object *originator)
Definition: move.cpp:163
cfapi_map_get_map
static void cfapi_map_get_map(int *type,...)
Definition: plugins.cpp:1035
CFAPI_REGION_PROP_MESSAGE
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:279
Settings::playerdir
const char * playerdir
Definition: global.h:250
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp:278
party_get_next
partylist * party_get_next(const partylist *party)
Definition: party.cpp:208
CFAPI_DOUBLE
#define CFAPI_DOUBLE
Definition: plugin.h:61
CFAPI_OBJECT_PROP_CONTAINER
#define CFAPI_OBJECT_PROP_CONTAINER
Definition: plugin.h:127
change_abil
int change_abil(object *op, object *tmp)
Definition: living.cpp:394
send_changed_object
static void send_changed_object(object *op)
Definition: plugins.cpp:301
CFAPI_OBJECT_PROP_INVENTORY
#define CFAPI_OBJECT_PROP_INVENTORY
Definition: plugin.h:124
CFAPI_OBJECT_PROP_MAP
#define CFAPI_OBJECT_PROP_MAP
Definition: plugin.h:128
CFAPI_MAP_PROP_FLAGS
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:245
cfapi_system_find_string
static void cfapi_system_find_string(int *type,...)
Definition: plugins.cpp:764
cfapi_system_remove_string
static void cfapi_system_remove_string(int *type,...)
Definition: plugins.cpp:746
region
Definition: map.h:275
CFAPI_MAP_PROP_DARKNESS
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:254
diamondslots.message
string message
Definition: diamondslots.py:57
CFAPI_MAP_PROP_PLAYERS
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:252
FLAG_REMOVED
#define FLAG_REMOVED
Definition: define.h:232
CFAPI_OBJECT_PROP_RUN_AWAY
#define CFAPI_OBJECT_PROP_RUN_AWAY
Definition: plugin.h:174
object_decrease_nrof
object * object_decrease_nrof(object *op, uint32_t i)
Definition: object.cpp:2670
PERM_EXP
#define PERM_EXP(exptotal)
Definition: global.h:230
cfapi_map_delete_map
static void cfapi_map_delete_map(int *type,...)
Definition: plugins.cpp:1338
plugins_display_list
void plugins_display_list(object *op)
Definition: plugins.cpp:479
check_trigger
int check_trigger(object *op, object *cause)
Definition: button.cpp:518
CFAPI_SINT64
#define CFAPI_SINT64
Definition: plugin.h:69
CFAPI_PLAYER_PROP_TRANSPORT
#define CFAPI_PLAYER_PROP_TRANSPORT
Definition: plugin.h:238
llevInfo
@ llevInfo
Definition: logger.h:12
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
cfapi_map_get_map_property
static void cfapi_map_get_map_property(int *type,...)
Definition: plugins.cpp:1138