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  *list = all_regions;
693  }
694 
695  va_end(args);
696 }
697 
698 static void cfapi_system_get_party_vector(int *type, ...) {
699  va_list args;
700  va_start(args, type);
701  int property = va_arg(args, int);
702  std::vector<partylist *> *list = va_arg(args, std::vector<partylist *> *);
703 
705  if (property == CFAPI_SYSTEM_PARTIES) {
706  auto party = party_get_first();
707  while (party) {
708  list->push_back(party);
709  party = party_get_next(party);
710  }
711  }
712 
713  va_end(args);
714 }
715 
722 static void cfapi_system_add_string(int *type, ...) {
723  va_list args;
724  const char *str;
725  sstring *rv;
726 
727  va_start(args, type);
728  str = va_arg(args, const char *);
729  rv = va_arg(args, sstring *);
730  va_end(args);
731 
732  *rv = add_string(str);
733  *type = CFAPI_SSTRING;
734 }
735 
742 static void cfapi_system_remove_string(int *type, ...) {
743  va_list args;
744  sstring str;
745 
746  va_start(args, type);
747  str = va_arg(args, sstring);
748  va_end(args);
749 
750  free_string(str);
751  *type = CFAPI_NONE;
752 }
753 
760 static void cfapi_system_find_string(int *type, ...) {
761  va_list args;
762  const char *str;
763  sstring *rv;
764 
765  va_start(args, type);
766  str = va_arg(args, const char *);
767  rv = va_arg(args, sstring *);
768  va_end(args);
769 
770  *rv = find_string(str);
771  *type = CFAPI_SSTRING;
772 }
773 
779 static void cfapi_system_check_path(int *type, ...) {
780  va_list args;
781  const char *name;
782  int prepend_dir;
783  int *ret;
784 
785  va_start(args, type);
786 
787  name = va_arg(args, char *);
788  prepend_dir = va_arg(args, int);
789  ret = va_arg(args, int *);
790 
791  *ret = check_path(name, prepend_dir);
792 
793  va_end(args);
794  *type = CFAPI_INT;
795 }
796 
802 static void cfapi_system_re_cmp(int *type, ...) {
803  va_list args;
804  const char *str;
805  const char *regexp;
806  const char **rv;
807 
808  va_start(args, type);
809 
810  str = va_arg(args, char *);
811  regexp = va_arg(args, char *);
812  rv = va_arg(args, const char **);
813 
814  *rv = re_cmp(str, regexp);
815 
816  va_end(args);
817  *type = CFAPI_STRING;
818 }
819 
820 static void cfapi_system_directory(int *type, ...) {
821  va_list args;
822  int dirtype;
823  const char **str;
824 
825  va_start(args, type);
826 
827  dirtype = va_arg(args, int);
828  str = va_arg(args, const char **);
829  va_end(args);
830 
831  *type = CFAPI_STRING;
832 
833  switch (dirtype) {
834  case 0:
835  *str = settings.mapdir;
836  break;
837 
838  case 1:
840  break;
841 
842  case 2:
843  *str = settings.tmpdir;
844  break;
845 
846  case 3:
847  *str = settings.confdir;
848  break;
849 
850  case 4:
851  *str = settings.localdir;
852  break;
853 
854  case 5:
856  break;
857 
858  case 6:
859  *str = settings.datadir;
860  break;
861 
862  default:
863  *str = NULL;
864  }
865 }
866 
873 static void cfapi_get_time(int *type, ...) {
874  va_list args;
875  timeofday_t *tod;
876 
877  va_start(args, type);
878  tod = va_arg(args, timeofday_t *);
879  va_end(args);
880 
881  get_tod(tod);
882  *type = CFAPI_NONE;
883 }
884 
885 #define string_get_int(name) \
886  va_list args; \
887  int index; \
888  const char **str; \
889  va_start(args, type); \
890  index = va_arg(args, int); \
891  str = va_arg(args, const char **); \
892  va_end(args); \
893  *str = name(index); \
894  *type = CFAPI_STRING; \
895 
896 
904 static void cfapi_get_season_name(int *type, ...) {
906 }
907 
916 static void cfapi_get_weekday_name(int *type, ...) {
918 }
919 
928 static void cfapi_get_month_name(int *type, ...) {
930 }
931 
940 static void cfapi_get_periodofday_name(int *type, ...) {
942 }
943 
955 static void cfapi_timer_create(int *type, ...) {
956  va_list args;
957  int res;
958  object *ob;
959  long delay;
960  int mode;
961  int *timer;
962 
963  va_start(args, type);
964  ob = va_arg(args, object *);
965  delay = va_arg(args, long);
966  mode = va_arg(args, int);
967  timer = va_arg(args, int *);
968  va_end(args);
969  *type = CFAPI_INT;
970 
971  *timer = cftimer_find_free_id();
972  if (*timer != TIMER_ERR_ID) {
973  res = cftimer_create(*timer, delay, ob, mode);
974  if (res != TIMER_ERR_NONE)
975  *timer = res;
976  }
977 }
978 
988 static void cfapi_timer_destroy(int *type, ...) {
989  va_list args;
990  int id;
991  int *err;
992 
993  va_start(args, type);
994  id = va_arg(args, int);
995  err = va_arg(args, int *);
996  va_end(args);
997  *type = CFAPI_INT;
998 
999  *err = cftimer_destroy(id);
1000 }
1001 
1007 static void cfapi_log(int *type, ...) {
1008  va_list args;
1009  LogLevel logLevel;
1010  const char *message;
1011 
1012  va_start(args, type);
1013  logLevel = static_cast<LogLevel>(va_arg(args, int));
1014  message = va_arg(args, const char *);
1015  LOG(logLevel, "%s", message);
1016  va_end(args);
1017 
1018  *type = CFAPI_NONE;
1019 }
1020 
1021 /* MAP RELATED HOOKS */
1022 
1031 static void cfapi_map_get_map(int *type, ...) {
1032  va_list args;
1033  mapstruct **ret;
1034  int ctype;
1035  int x, y;
1036  int16_t nx, ny;
1037  const char *name;
1038  mapstruct *m;
1039 
1040  va_start(args, type);
1041 
1042  ctype = va_arg(args, int);
1043 
1044  switch (ctype) {
1045  case 0:
1046  x = va_arg(args, int);
1047  y = va_arg(args, int);
1048  ret = va_arg(args, mapstruct **);
1049  *ret = get_empty_map(x, y);
1050  break;
1051 
1052  case 1:
1053  name = va_arg(args, const char *);
1054  x = va_arg(args, int);
1055  ret = va_arg(args, mapstruct **);
1056  *ret = ready_map_name(name, x);
1057  break;
1058 
1059  case 2:
1060  m = va_arg(args, mapstruct *);
1061  nx = va_arg(args, int);
1062  ny = va_arg(args, int);
1063  ret = va_arg(args, mapstruct **);
1064  *ret = get_map_from_coord(m, &nx, &ny);
1065  break;
1066 
1067  default:
1068  *type = CFAPI_NONE;
1069  va_end(args);
1070  return;
1071  break;
1072  }
1073  va_end(args);
1074  *type = CFAPI_PMAP;
1075 }
1076 
1082 static void cfapi_map_has_been_loaded(int *type, ...) {
1083  va_list args;
1084  mapstruct **map;
1085  char *string;
1086 
1087  va_start(args, type);
1088  string = va_arg(args, char *);
1089  map = va_arg(args, mapstruct **);
1090  *map = has_been_loaded(string);
1091  va_end(args);
1092  *type = CFAPI_PMAP;
1093 }
1094 
1100 static void cfapi_map_create_path(int *type, ...) {
1101  va_list args;
1102  int ctype, size;
1103  const char *str;
1104  char *name;
1105 
1106  va_start(args, type);
1107 
1108  ctype = va_arg(args, int);
1109  str = va_arg(args, const char *);
1110  name = va_arg(args, char *);
1111  size = va_arg(args, int);
1112  *type = CFAPI_STRING;
1113 
1114  switch (ctype) {
1115  case 0:
1116  create_pathname(str, name, size);
1117  break;
1118 
1119  case 1:
1121  break;
1122 
1123 /* case 2:
1124  rv = create_items_path(str);
1125  break;*/
1126 
1127  default:
1128  *type = CFAPI_NONE;
1129  break;
1130  }
1131  va_end(args);
1132 }
1133 
1134 static void cfapi_map_get_map_property(int *type, ...) {
1135  va_list args;
1136  mapstruct *map;
1137  int property;
1138 
1139  int *rint;
1140  mapstruct **rmap;
1141  sstring *rstr;
1142  region **rreg;
1143  int16_t *nx, *ny;
1144  int x, y;
1145 
1146  va_start(args, type);
1147 
1148  map = va_arg(args, mapstruct *);
1149  property = va_arg(args, int);
1150 
1151  switch (property) {
1152  case CFAPI_MAP_PROP_FLAGS:
1153  rmap = va_arg(args, mapstruct **);
1154  x = va_arg(args, int);
1155  y = va_arg(args, int);
1156  nx = va_arg(args, int16_t *);
1157  ny = va_arg(args, int16_t *);
1158  rint = va_arg(args, int *);
1159  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1160  *type = CFAPI_INT;
1161  break;
1162 
1164  rint = va_arg(args, int *);
1165  *rint = calculate_difficulty(map);
1166  *type = CFAPI_INT;
1167  break;
1168 
1169  case CFAPI_MAP_PROP_PATH:
1170  rstr = va_arg(args, sstring *);
1171  *rstr = map->path;
1172  *type = CFAPI_SSTRING;
1173  break;
1174 
1176  rstr = va_arg(args, sstring *);
1177  *rstr = map->tmpname;
1178  *type = CFAPI_SSTRING;
1179  break;
1180 
1181  case CFAPI_MAP_PROP_NAME:
1182  rstr = va_arg(args, sstring *);
1183  *rstr = map->name;
1184  *type = CFAPI_SSTRING;
1185  break;
1186 
1188  rint = va_arg(args, int *);
1189  *rint = map->reset_time;
1190  *type = CFAPI_INT;
1191  break;
1192 
1194  rint = va_arg(args, int *);
1195  *rint = map->reset_timeout;
1196  *type = CFAPI_INT;
1197  break;
1198 
1200  rint = va_arg(args, int *);
1201  *rint = map->players;
1202  *type = CFAPI_INT;
1203  break;
1204 
1206  rint = va_arg(args, int *);
1207  *rint = map->darkness;
1208  *type = CFAPI_INT;
1209  break;
1210 
1211  case CFAPI_MAP_PROP_WIDTH:
1212  rint = va_arg(args, int *);
1213  *rint = map->width;
1214  *type = CFAPI_INT;
1215  break;
1216 
1217  case CFAPI_MAP_PROP_HEIGHT:
1218  rint = va_arg(args, int *);
1219  *rint = map->height;
1220  *type = CFAPI_INT;
1221  break;
1222 
1224  rint = va_arg(args, int *);
1225  *rint = map->enter_x;
1226  *type = CFAPI_INT;
1227  break;
1228 
1230  rint = va_arg(args, int *);
1231  *rint = map->enter_y;
1232  *type = CFAPI_INT;
1233  break;
1234 
1236  rstr = va_arg(args, sstring *);
1237  *rstr = map->msg;
1238  *type = CFAPI_SSTRING;
1239  break;
1240 
1241  case CFAPI_MAP_PROP_NEXT:
1242  rmap = va_arg(args, mapstruct **);
1243  *rmap = map ? map->next : first_map;
1244  *type = CFAPI_PMAP;
1245  break;
1246 
1247  case CFAPI_MAP_PROP_REGION:
1248  rreg = va_arg(args, region **);
1249  *rreg = get_region_by_map(map);
1250  *type = CFAPI_PREGION;
1251  break;
1252 
1253  case CFAPI_MAP_PROP_UNIQUE:
1254  rint = va_arg(args, int *);
1255  *rint = map->unique;
1256  *type = CFAPI_INT;
1257  break;
1258 
1259  default:
1260  *type = CFAPI_NONE;
1261  break;
1262  }
1263  va_end(args);
1264 }
1265 
1266 static void cfapi_map_set_map_property(int *type, ...) {
1267  va_list args;
1268  mapstruct *map;
1269  int property;
1270  const char *buf;
1271 
1272  va_start(args, type);
1273 
1274  map = va_arg(args, mapstruct *);
1275  property = va_arg(args, int);
1276 
1277  switch (property) {
1278  case CFAPI_MAP_PROP_PATH:
1279  buf = va_arg(args, const char *);
1280  strlcpy(map->path, buf, sizeof(map->path));
1281  *type = CFAPI_STRING;
1282  break;
1283 
1284  default:
1285  *type = CFAPI_NONE;
1286  break;
1287  }
1288  va_end(args);
1289 }
1290 
1296 static void cfapi_map_out_of_map(int *type, ...) {
1297  va_list args;
1298  mapstruct *map;
1299  int x, y;
1300  int *rint;
1301 
1302  va_start(args, type);
1303  map = va_arg(args, mapstruct *);
1304  x = va_arg(args, int);
1305  y = va_arg(args, int);
1306  rint = va_arg(args, int *);
1307 
1308  *rint = out_of_map(map, x, y);
1309  va_end(args);
1310  *type = CFAPI_INT;
1311 }
1312 
1318 static void cfapi_map_update_position(int *type, ...) {
1319  va_list args;
1320  mapstruct *map;
1321  int x, y;
1322 
1323  va_start(args, type);
1324 
1325  map = va_arg(args, mapstruct *);
1326  x = va_arg(args, int);
1327  y = va_arg(args, int);
1328 
1329  update_position(map, x, y);
1330  va_end(args);
1331  *type = CFAPI_NONE;
1332 }
1333 
1334 static void cfapi_map_delete_map(int *type, ...) {
1335  va_list args;
1336  mapstruct *map;
1337  va_start(args, type);
1338 
1339  map = va_arg(args, mapstruct *);
1340 
1341  delete_map(map);
1342 
1343  va_end(args);
1344  *type = CFAPI_NONE;
1345 }
1346 
1347 static void cfapi_map_message(int *type, ...) {
1348  va_list args;
1349  mapstruct *map;
1350  const char *string;
1351  int color;
1352 
1353  va_start(args, type);
1354  map = va_arg(args, mapstruct *);
1355  string = va_arg(args, const char *);
1356  color = va_arg(args, int);
1357  va_end(args);
1358 
1359  /* function should be extended to take message types probably */
1361  *type = CFAPI_NONE;
1362 }
1363 
1369 static void cfapi_map_get_object_at(int *type, ...) {
1370  va_list args;
1371  mapstruct *map;
1372  int x, y;
1373  int16_t sx, sy;
1374  object **robj;
1375 
1376  va_start(args, type);
1377  map = va_arg(args, mapstruct *);
1378  x = va_arg(args, int);
1379  y = va_arg(args, int);
1380  robj = va_arg(args, object **);
1381  va_end(args);
1382 
1383  sx = x;
1384  sy = y;
1385  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1386  *robj = NULL;
1387  else
1388  *robj = GET_MAP_OB(map, sx, sy);
1389  *type = CFAPI_POBJECT;
1390 }
1391 
1398 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1399  va_list args;
1400  int x, y;
1401  mapstruct *map;
1402  char *msg;
1403  object **robj;
1404 
1405  va_start(args, type);
1406 
1407  msg = va_arg(args, char *);
1408  map = va_arg(args, mapstruct *);
1409  x = va_arg(args, int);
1410  y = va_arg(args, int);
1411  robj = va_arg(args, object **);
1412 
1413  va_end(args);
1414 
1416  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1417  *type = CFAPI_POBJECT;
1418 }
1419 
1425 static void cfapi_map_change_light(int *type, ...) {
1426  va_list args;
1427  int change;
1428  mapstruct *map;
1429  int *rint;
1430 
1431  va_start(args, type);
1432  map = va_arg(args, mapstruct *);
1433  change = va_arg(args, int);
1434  rint = va_arg(args, int *);
1435  va_end(args);
1436 
1437  *type = CFAPI_INT;
1438  *rint = change_map_light(map, change);
1439 }
1440 
1441 /* OBJECT-RELATED HOOKS */
1442 
1456 static void cfapi_object_move(int *type, ...) {
1457  va_list args;
1458  int kind;
1459  object *op;
1460  object *activator;
1461  player *pl;
1462  int direction;
1463  int *ret;
1464 
1465  va_start(args, type);
1466  kind = va_arg(args, int);
1467  switch (kind) {
1468  case 0:
1469  op = va_arg(args, object *);
1470  direction = va_arg(args, int);
1471  activator = va_arg(args, object *);
1472  ret = va_arg(args, int *);
1473  va_end(args);
1474  *ret = move_ob(op, direction, activator);
1475  break;
1476 
1477  case 1:
1478  pl = va_arg(args, player *);
1479  direction = va_arg(args, int);
1480  ret = va_arg(args, int *);
1481  va_end(args);
1482  *ret = move_player(pl->ob, direction);
1483  break;
1484 
1485  case 2:
1486  op = va_arg(args, object *);
1487  ret = va_arg(args, int *);
1488  va_end(args);
1489  *ret = player_arrest(op);
1490  break;
1491 
1492  default:
1493  // Just end the use of variable args. We got a wrong type.
1494  va_end(args);
1495  }
1496  *type = CFAPI_INT;
1497 }
1498 
1506 static void cfapi_object_get_key(int *type, ...) {
1507  va_list args;
1508  const char *keyname;
1509  const char **value;
1510  object *op;
1511 
1512  va_start(args, type);
1513  op = va_arg(args, object *);
1514  keyname = va_arg(args, const char *);
1515  value = va_arg(args, const char **);
1516  va_end(args);
1517 
1518  *value = object_get_value(op, keyname);
1519  *type = CFAPI_SSTRING;
1520 }
1521 
1528 static void cfapi_object_set_key(int *type, ...) {
1529  va_list args;
1530  const char *keyname;
1531  const char *value;
1532  int *ret;
1533  object *op;
1534  int add_key;
1535 
1536  va_start(args, type);
1537  op = va_arg(args, object *);
1538  keyname = va_arg(args, char *);
1539  value = va_arg(args, char *);
1540  add_key = va_arg(args, int);
1541  ret = va_arg(args, int *);
1542  va_end(args);
1543 
1544  *ret = object_set_value(op, keyname, value, add_key);
1545  *type = CFAPI_INT;
1546 }
1547 
1551 static void cfapi_object_get_property(int *type, ...) {
1552  va_list args;
1553  int property;
1554  object *op;
1555  int *rint;
1556  object **robject;
1557  mapstruct **rmap;
1558  float *rfloat;
1559  archetype **rarch;
1560  sstring *rsstring;
1561  char *rbuffer;
1562  int rbufsize;
1563  MoveType *rmove;
1564  int64_t *rint64;
1565  partylist **rparty;
1566  double *rdouble;
1567  long *rlong;
1568 
1569  va_start(args, type);
1570 
1571  op = va_arg(args, object *);
1572  property = va_arg(args, int);
1573  switch (property) {
1575  robject = va_arg(args, object **);
1576  *robject = op->above;
1577  *type = CFAPI_POBJECT;
1578  break;
1579 
1581  robject = va_arg(args, object **);
1582  *robject = op->below;
1583  *type = CFAPI_POBJECT;
1584  break;
1585 
1587  robject = va_arg(args, object **);
1588  *robject = op->active_next;
1589  *type = CFAPI_POBJECT;
1590  break;
1591 
1593  robject = va_arg(args, object **);
1594  *robject = op->active_prev;
1595  *type = CFAPI_POBJECT;
1596  break;
1597 
1599  robject = va_arg(args, object **);
1600  *robject = op->inv;
1601  *type = CFAPI_POBJECT;
1602  break;
1603 
1605  robject = va_arg(args, object **);
1606  *robject = op->env;
1607  *type = CFAPI_POBJECT;
1608  break;
1609 
1611  robject = va_arg(args, object **);
1612  *robject = op->head;
1613  *type = CFAPI_POBJECT;
1614  break;
1615 
1617  robject = va_arg(args, object **);
1618  *robject = op->container;
1619  *type = CFAPI_POBJECT;
1620  break;
1621 
1622  case CFAPI_OBJECT_PROP_MAP:
1623  rmap = va_arg(args, mapstruct **);
1624  *rmap = op->map;
1625  *type = CFAPI_PMAP;
1626  break;
1627 
1629  rint = va_arg(args, int *);
1630  *rint = op->count;
1631  *type = CFAPI_INT;
1632  break;
1633 
1635  rbuffer = va_arg(args, char *);
1636  rbufsize = va_arg(args, int);
1637  query_name(op, rbuffer, rbufsize);
1638  *type = CFAPI_STRING;
1639  break;
1640 
1642  rsstring = va_arg(args, sstring *);
1643  *rsstring = op->name_pl;
1644  *type = CFAPI_SSTRING;
1645  break;
1646 
1648  rsstring = va_arg(args, sstring *);
1649  *rsstring = op->title;
1650  *type = CFAPI_SSTRING;
1651  break;
1652 
1654  rsstring = va_arg(args, sstring *);
1655  *rsstring = op->race;
1656  *type = CFAPI_SSTRING;
1657  break;
1658 
1660  rsstring = va_arg(args, sstring *);
1661  *rsstring = op->slaying;
1662  *type = CFAPI_SSTRING;
1663  break;
1664 
1666  rsstring = va_arg(args, sstring *);
1667  *rsstring = op->skill;
1668  *type = CFAPI_SSTRING;
1669  break;
1670 
1672  rsstring = va_arg(args, sstring *);
1673  *rsstring = op->msg;
1674  *type = CFAPI_SSTRING;
1675  break;
1676 
1678  rsstring = va_arg(args, sstring *);
1679  *rsstring = op->lore;
1680  *type = CFAPI_SSTRING;
1681  break;
1682 
1683  case CFAPI_OBJECT_PROP_X:
1684  rint = va_arg(args, int *);
1685  *rint = op->x;
1686  *type = CFAPI_INT;
1687  break;
1688 
1689  case CFAPI_OBJECT_PROP_Y:
1690  rint = va_arg(args, int *);
1691  *rint = op->y;
1692  *type = CFAPI_INT;
1693  break;
1694 
1696  rfloat = va_arg(args, float *);
1697  *rfloat = op->speed;
1698  *type = CFAPI_FLOAT;
1699  break;
1700 
1702  rfloat = va_arg(args, float *);
1703  *rfloat = op->speed_left;
1704  *type = CFAPI_FLOAT;
1705  break;
1706 
1708  rint = va_arg(args, int *);
1709  *rint = op->nrof;
1710  *type = CFAPI_INT;
1711  break;
1712 
1714  rint = va_arg(args, int *);
1715  *rint = op->direction;
1716  *type = CFAPI_INT;
1717  break;
1718 
1720  rint = va_arg(args, int *);
1721  *rint = op->facing;
1722  *type = CFAPI_INT;
1723  break;
1724 
1726  rint = va_arg(args, int *);
1727  *rint = op->type;
1728  *type = CFAPI_INT;
1729  break;
1730 
1732  rint = va_arg(args, int *);
1733  *rint = op->subtype;
1734  *type = CFAPI_INT;
1735  break;
1736 
1738  rint = va_arg(args, int *);
1739  *rint = op->client_type;
1740  *type = CFAPI_INT;
1741  break;
1742 
1743  case CFAPI_OBJECT_PROP_RESIST: {
1744  int idx;
1745  int16_t *resist;
1746 
1747  idx = va_arg(args, int);
1748  resist = va_arg(args, int16_t *);
1749  *resist = op->resist[idx];
1750  }
1751  *type = CFAPI_INT16;
1752  break;
1753 
1755  rint = va_arg(args, int *);
1756  *rint = op->attacktype;
1757  *type = CFAPI_INT;
1758  break;
1759 
1761  rint = va_arg(args, int *);
1762  *rint = op->path_attuned;
1763  *type = CFAPI_INT;
1764  break;
1765 
1767  rint = va_arg(args, int *);
1768  *rint = op->path_repelled;
1769  *type = CFAPI_INT;
1770  break;
1771 
1773  rint = va_arg(args, int *);
1774  *rint = op->path_denied;
1775  *type = CFAPI_INT;
1776  break;
1777 
1779  rint = va_arg(args, int *);
1780  *rint = op->material;
1781  *type = CFAPI_INT;
1782  break;
1783 
1785  rsstring = va_arg(args, sstring *);
1786  *rsstring = op->materialname;
1787  *type = CFAPI_SSTRING;
1788  break;
1789 
1791  rint = va_arg(args, int *);
1792  *rint = op->magic;
1793  *type = CFAPI_INT;
1794  break;
1795 
1797  rlong = va_arg(args, long *);
1798  *rlong = op->value;
1799  *type = CFAPI_LONG;
1800  break;
1801 
1803  rint = va_arg(args, int *);
1804  *rint = op->level;
1805  *type = CFAPI_INT;
1806  break;
1807 
1809  rint = va_arg(args, int *);
1810  *rint = op->last_heal;
1811  *type = CFAPI_INT;
1812  break;
1813 
1815  rint = va_arg(args, int *);
1816  *rint = op->last_sp;
1817  *type = CFAPI_INT;
1818  break;
1819 
1821  rint = va_arg(args, int *);
1822  *rint = op->last_grace;
1823  *type = CFAPI_INT;
1824  break;
1825 
1827  rint = va_arg(args, int *);
1828  *rint = op->last_eat;
1829  *type = CFAPI_INT;
1830  break;
1831 
1833  rint = va_arg(args, int *);
1834  *rint = op->invisible;
1835  *type = CFAPI_INT;
1836  break;
1837 
1839  rint = va_arg(args, int *);
1840  *rint = op->pick_up;
1841  *type = CFAPI_INT;
1842  break;
1843 
1845  rint = va_arg(args, int *);
1846  *rint = op->item_power;
1847  *type = CFAPI_INT;
1848  break;
1849 
1851  rint = va_arg(args, int *);
1852  *rint = op->gen_sp_armour;
1853  *type = CFAPI_INT;
1854  break;
1855 
1857  rint = va_arg(args, int *);
1858  *rint = op->weight;
1859  *type = CFAPI_INT;
1860  break;
1861 
1863  rint = va_arg(args, int *);
1864  *rint = op->weight_limit;
1865  *type = CFAPI_INT;
1866  break;
1867 
1869  rint = va_arg(args, int *);
1870  *rint = op->carrying;
1871  *type = CFAPI_INT;
1872  break;
1873 
1875  rint = va_arg(args, int *);
1876  *rint = op->glow_radius;
1877  *type = CFAPI_INT;
1878  break;
1879 
1881  rint64 = va_arg(args, int64_t *);
1882  *rint64 = op->total_exp;
1883  *type = CFAPI_SINT64;
1884  break;
1885 
1887  robject = va_arg(args, object **);
1888  *robject = op->current_weapon;
1889  *type = CFAPI_POBJECT;
1890  break;
1891 
1893  robject = va_arg(args, object **);
1894  *robject = op->enemy;
1895  *type = CFAPI_POBJECT;
1896  break;
1897 
1899  robject = va_arg(args, object **);
1900  *robject = op->attacked_by;
1901  *type = CFAPI_POBJECT;
1902  break;
1903 
1905  rint = va_arg(args, int *);
1906  *rint = op->run_away;
1907  *type = CFAPI_INT;
1908  break;
1909 
1911  robject = va_arg(args, object **);
1912  *robject = op->chosen_skill;
1913  *type = CFAPI_POBJECT;
1914  break;
1915 
1917  rint = va_arg(args, int *);
1918  *rint = op->hide;
1919  *type = CFAPI_INT;
1920  break;
1921 
1923  rint = va_arg(args, int *);
1924  *rint = op->move_status;
1925  *type = CFAPI_INT;
1926  break;
1927 
1929  rint = va_arg(args, int *);
1930  *rint = op->attack_movement;
1931  *type = CFAPI_INT;
1932  break;
1933 
1935  robject = va_arg(args, object **);
1936  *robject = op->spellitem;
1937  *type = CFAPI_POBJECT;
1938  break;
1939 
1941  rdouble = va_arg(args, double *);
1942  *rdouble = op->expmul;
1943  *type = CFAPI_DOUBLE;
1944  break;
1945 
1947  rarch = va_arg(args, archetype **);
1948  *rarch = op->arch;
1949  *type = CFAPI_PARCH;
1950  break;
1951 
1953  rarch = va_arg(args, archetype **);
1954  *rarch = op->other_arch;
1955  *type = CFAPI_PARCH;
1956  break;
1957 
1959  rsstring = va_arg(args, sstring *);
1960  *rsstring = object_get_value(op, CUSTOM_NAME_FIELD);
1961  *type = CFAPI_SSTRING;
1962  break;
1963 
1965  rint = va_arg(args, int *);
1966  *rint = op->anim_speed;
1967  *type = CFAPI_INT;
1968  break;
1969 
1971  rint = va_arg(args, int *);
1972  *rint = is_friendly(op);
1973  *type = CFAPI_INT;
1974  break;
1975 
1977  rbuffer = va_arg(args, char *);
1978  rbufsize = va_arg(args, int);
1979  query_short_name(op, rbuffer, rbufsize);
1980  *type = CFAPI_STRING;
1981  break;
1982 
1984  int i;
1985 
1986  i = va_arg(args, int);
1987  rbuffer = va_arg(args, char *);
1988  rbufsize = va_arg(args, int);
1989  query_base_name(op, i, rbuffer, rbufsize);
1990  *type = CFAPI_STRING;
1991  }
1992  break;
1993 
1995  rsstring = va_arg(args, sstring *);
1996  *rsstring = op->name;
1997  *type = CFAPI_SSTRING;
1998  break;
1999 
2001  rint = va_arg(args, int *);
2002  *rint = is_magical(op);
2003  *type = CFAPI_INT;
2004  break;
2005 
2007  rint = va_arg(args, int *);
2008  *rint = op->stats.luck;
2009  *type = CFAPI_INT;
2010  break;
2011 
2012  case CFAPI_OBJECT_PROP_EXP:
2013  rint64 = va_arg(args, int64_t *);
2014  *rint64 = op->stats.exp;
2015  *type = CFAPI_SINT64;
2016  break;
2017 
2019  robject = va_arg(args, object **);
2020  *robject = object_get_owner(op);
2021  *type = CFAPI_POBJECT;
2022  break;
2023 
2025  int stype;
2026 
2027  stype = va_arg(args, int);
2028  switch (stype) {
2029  unsigned char ptype;
2030  char *buf;
2031  archetype *at;
2032 
2033  case 0: /* present_in_ob */
2034  ptype = (unsigned char)(va_arg(args, int));
2035  robject = va_arg(args, object **);
2036  *robject = object_present_in_ob(ptype, op);
2037  break;
2038 
2039  case 1: /* present_in_ob_by_name */
2040  ptype = (unsigned char)(va_arg(args, int));
2041  buf = va_arg(args, char *);
2042  robject = va_arg(args, object **);
2043  *robject = object_present_in_ob_by_name(ptype, buf, op);
2044  break;
2045 
2046  case 2: /* arch_present_in_ob */
2047  at = va_arg(args, archetype *);
2048  robject = va_arg(args, object **);
2049  *robject = arch_present_in_ob(at, op);
2050  break;
2051  }
2052  }
2053  *type = CFAPI_POBJECT;
2054  break;
2055 
2057  rint = va_arg(args, int *);
2058  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2059  *type = CFAPI_INT;
2060  break;
2061 
2063  object *op2;
2064 
2065  op2 = va_arg(args, object *);
2066  rint = va_arg(args, int *);
2067  *rint = object_can_merge(op, op2);
2068  }
2069  *type = CFAPI_INT;
2070  break;
2071 
2073  object *op2;
2074 
2075  op2 = va_arg(args, object *);
2076  rint = va_arg(args, int *);
2077  *rint = object_can_pick(op2, op);
2078  }
2079  *type = CFAPI_INT;
2080  break;
2081 
2082  case CFAPI_OBJECT_PROP_FLAGS: {
2083  int fl;
2084 
2085  fl = va_arg(args, int);
2086  rint = va_arg(args, int *);
2087  *rint = QUERY_FLAG(op, fl);
2088  }
2089  *type = CFAPI_INT;
2090  break;
2091 
2092  case CFAPI_OBJECT_PROP_STR:
2093  rint = va_arg(args, int *);
2094  *rint = op->stats.Str;
2095  *type = CFAPI_INT;
2096  break;
2097 
2098  case CFAPI_OBJECT_PROP_DEX:
2099  rint = va_arg(args, int *);
2100  *rint = op->stats.Dex;
2101  *type = CFAPI_INT;
2102  break;
2103 
2104  case CFAPI_OBJECT_PROP_CON:
2105  rint = va_arg(args, int *);
2106  *rint = op->stats.Con;
2107  *type = CFAPI_INT;
2108  break;
2109 
2110  case CFAPI_OBJECT_PROP_WIS:
2111  rint = va_arg(args, int *);
2112  *rint = op->stats.Wis;
2113  *type = CFAPI_INT;
2114  break;
2115 
2116  case CFAPI_OBJECT_PROP_INT:
2117  rint = va_arg(args, int *);
2118  *rint = op->stats.Int;
2119  *type = CFAPI_INT;
2120  break;
2121 
2122  case CFAPI_OBJECT_PROP_POW:
2123  rint = va_arg(args, int *);
2124  *rint = op->stats.Pow;
2125  *type = CFAPI_INT;
2126  break;
2127 
2128  case CFAPI_OBJECT_PROP_CHA:
2129  rint = va_arg(args, int *);
2130  *rint = op->stats.Cha;
2131  *type = CFAPI_INT;
2132  break;
2133 
2134  case CFAPI_OBJECT_PROP_WC:
2135  rint = va_arg(args, int *);
2136  *rint = op->stats.wc;
2137  *type = CFAPI_INT;
2138  break;
2139 
2140  case CFAPI_OBJECT_PROP_AC:
2141  rint = va_arg(args, int *);
2142  *rint = op->stats.ac;
2143  *type = CFAPI_INT;
2144  break;
2145 
2146  case CFAPI_OBJECT_PROP_HP:
2147  rint = va_arg(args, int *);
2148  *rint = op->stats.hp;
2149  *type = CFAPI_INT;
2150  break;
2151 
2152  case CFAPI_OBJECT_PROP_SP:
2153  rint = va_arg(args, int *);
2154  *rint = op->stats.sp;
2155  *type = CFAPI_INT;
2156  break;
2157 
2158  case CFAPI_OBJECT_PROP_GP:
2159  rint = va_arg(args, int *);
2160  *rint = op->stats.grace;
2161  *type = CFAPI_INT;
2162  break;
2163 
2164  case CFAPI_OBJECT_PROP_FP:
2165  rint = va_arg(args, int *);
2166  *rint = op->stats.food;
2167  *type = CFAPI_INT;
2168  break;
2169 
2171  rint = va_arg(args, int *);
2172  *rint = op->stats.maxhp;
2173  *type = CFAPI_INT;
2174  break;
2175 
2177  rint = va_arg(args, int *);
2178  *rint = op->stats.maxsp;
2179  *type = CFAPI_INT;
2180  break;
2181 
2183  rint = va_arg(args, int *);
2184  *rint = op->stats.maxgrace;
2185  *type = CFAPI_INT;
2186  break;
2187 
2188  case CFAPI_OBJECT_PROP_DAM:
2189  rint = va_arg(args, int *);
2190  *rint = op->stats.dam;
2191  *type = CFAPI_INT;
2192  break;
2193 
2194  case CFAPI_OBJECT_PROP_GOD:
2195  rsstring = va_arg(args, sstring *);
2196  *rsstring = determine_god(op);
2197  *type = CFAPI_SSTRING;
2198  break;
2199 
2201  rsstring = va_arg(args, sstring *);
2202  *rsstring = op->arch->name;
2203  *type = CFAPI_SSTRING;
2204  break;
2205 
2207  rint = va_arg(args, int *);
2208  *rint = op->invisible;
2209  *type = CFAPI_INT;
2210  break;
2211 
2213  rsstring = va_arg(args, sstring *);
2214  if (op->face != NULL) {
2215  (*rsstring) = op->face->name;
2216  }
2217  else {
2218  (*rsstring) = NULL;
2219  }
2220  *type = CFAPI_SSTRING;
2221  break;
2222 
2224  rsstring = va_arg(args, sstring *);
2225  if (op->animation != NULL) {
2226  (*rsstring) = op->animation->name;
2227  }
2228  else {
2229  (*rsstring) = NULL;
2230  }
2231  *type = CFAPI_SSTRING;
2232  break;
2233 
2235  rint = va_arg(args, int *);
2236  *rint = op->contr->count;
2237  *type = CFAPI_INT;
2238  break;
2239 
2240  case CFAPI_PLAYER_PROP_IP:
2241  rsstring = va_arg(args, sstring *);
2242  *rsstring = op->contr->socket->host;
2243  *type = CFAPI_SSTRING;
2244  break;
2245 
2247  robject = va_arg(args, object **);
2248  *robject = find_marked_object(op);
2249  *type = CFAPI_POBJECT;
2250  break;
2251 
2253  rparty = va_arg(args, partylist **);
2254  *rparty = (op->contr ? op->contr->party : NULL);
2255  *type = CFAPI_PPARTY;
2256  break;
2257 
2259  robject = va_arg(args, object **);
2260  if (op)
2261  *robject = op->contr->next ? op->contr->next->ob : NULL;
2262  else
2263  /* This can be called when there is no player. */
2264  *robject = first_player ? first_player->ob : NULL;
2265  *type = CFAPI_POBJECT;
2266  break;
2267 
2269  rbuffer = va_arg(args, char *);
2270  rbufsize = va_arg(args, int);
2271  player_get_title(op->contr, rbuffer, rbufsize);
2272  *type = CFAPI_STRING;
2273  break;
2274 
2276  robject = va_arg(args, object **);
2277  *robject = op->contr->transport;
2278  *type = CFAPI_POBJECT;
2279  break;
2280 
2282  rmove = va_arg(args, MoveType *);
2283  *rmove = op->move_type;
2284  *type = CFAPI_MOVETYPE;
2285  break;
2286 
2288  rmove = va_arg(args, MoveType *);
2289  *rmove = op->move_block;
2290  *type = CFAPI_MOVETYPE;
2291  break;
2292 
2294  rmove = va_arg(args, MoveType *);
2295  *rmove = op->move_allow;
2296  *type = CFAPI_MOVETYPE;
2297  break;
2298 
2300  rmove = va_arg(args, MoveType *);
2301  *rmove = op->move_on;
2302  *type = CFAPI_MOVETYPE;
2303  break;
2304 
2306  rmove = va_arg(args, MoveType *);
2307  *rmove = op->move_off;
2308  *type = CFAPI_MOVETYPE;
2309  break;
2310 
2312  rmove = va_arg(args, MoveType *);
2313  *rmove = op->move_type;
2314  *type = CFAPI_MOVETYPE;
2315  break;
2316 
2318  rfloat = va_arg(args, float *);
2319  *rfloat = op->move_slow_penalty;
2320  *type = CFAPI_FLOAT;
2321  break;
2322 
2324  rbuffer = va_arg(args, char *);
2325  rbufsize = va_arg(args, int);
2326  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2327  *type = CFAPI_STRING;
2328  break;
2329 
2331  rint = va_arg(args, int *);
2332  *rint = op->contr->bed_x;
2333  *type = CFAPI_INT;
2334  break;
2335 
2337  rint = va_arg(args, int *);
2338  *rint = op->contr->bed_y;
2339  *type = CFAPI_INT;
2340  break;
2341 
2343  rint = va_arg(args, int *);
2344  *rint = op->duration;
2345  *type = CFAPI_INT;
2346  break;
2347 
2348  default:
2349  *type = CFAPI_NONE;
2350  break;
2351  }
2352  va_end(args);
2353 }
2354 
2363 static void copy_message(object *op, const char *msg) {
2364  /* need to reset parsed dialog information */
2366  if (strlen(msg) == 0) {
2367  msg = NULL;
2368  }
2369  object_set_msg(op, msg);
2370 }
2371 
2380 static void cfapi_object_set_property(int *type, ...) {
2381  va_list args;
2382  int iarg, *ret;
2383  long larg;
2384  char *sarg;
2385  double darg;
2386  object *oparg;
2387  object *op;
2388  int property;
2389  int64_t s64arg;
2390  partylist *partyarg;
2391  float farg;
2392  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2393 
2394  va_start(args, type);
2395  op = va_arg(args, object *);
2396  property = va_arg(args, int);
2397  *type = CFAPI_NONE;
2398 
2399  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2400  switch (property) {
2402  sarg = va_arg(args, char *);
2403  *type = CFAPI_STRING;
2404  FREE_AND_COPY(op->name, sarg);
2406  break;
2407 
2409  sarg = va_arg(args, char *);
2410  *type = CFAPI_STRING;
2411  FREE_AND_COPY(op->name_pl, sarg);
2413  break;
2414 
2416  sarg = va_arg(args, char *);
2417  *type = CFAPI_STRING;
2418  FREE_AND_COPY(op->title, sarg);
2419  break;
2420 
2422  sarg = va_arg(args, char *);
2423  *type = CFAPI_STRING;
2424  FREE_AND_COPY(op->race, sarg);
2425  break;
2426 
2428  sarg = va_arg(args, char *);
2429  *type = CFAPI_STRING;
2430  FREE_AND_COPY(op->slaying, sarg);
2431  break;
2432 
2434  sarg = va_arg(args, char *);
2435  *type = CFAPI_STRING;
2436  FREE_AND_COPY(op->skill, sarg);
2437  break;
2438 
2440  sarg = va_arg(args, char *);
2441  *type = CFAPI_STRING;
2442  copy_message(op, sarg);
2443  break;
2444 
2446  sarg = va_arg(args, char *);
2447  *type = CFAPI_STRING;
2448  FREE_AND_COPY(op->lore, sarg);
2449  break;
2450 
2452  farg = va_arg(args, double);
2453  *type = CFAPI_FLOAT;
2454  if (farg != op->speed) {
2455  op->speed = farg;
2457  }
2458  break;
2459 
2461  farg = va_arg(args, double);
2462  *type = CFAPI_FLOAT;
2463  op->speed_left = farg;
2464  break;
2465 
2467  iarg = va_arg(args, int);
2468  *type = CFAPI_INT;
2469  if (iarg < 0)
2470  iarg = 0;
2471  if (op->nrof > (uint32_t)iarg)
2472  object_decrease_nrof(op, op->nrof-iarg);
2473  else if (op->nrof < (uint32_t)iarg) {
2474  object *tmp;
2475  player *pl;
2476 
2477  op->nrof = iarg;
2478  if (op->env != NULL) {
2480  if (!tmp) {
2481  for (pl = first_player; pl; pl = pl->next)
2482  if (pl->ob->container == op->env)
2483  break;
2484  if (pl)
2485  tmp = pl->ob;
2486  else
2487  tmp = NULL;
2488  } else {
2490  fix_object(tmp);
2491  }
2492  if (tmp)
2494  } else {
2496  if (tmp->type == PLAYER)
2497  tmp->contr->socket->update_look = 1;
2498  FOR_ABOVE_FINISH();
2499  }
2500  }
2501  break;
2502 
2504  iarg = va_arg(args, int);
2505  *type = CFAPI_INT;
2506  op->direction = iarg;
2507  break;
2508 
2510  iarg = va_arg(args, int);
2511  *type = CFAPI_INT;
2512  op->facing = iarg;
2513  break;
2514 
2515  case CFAPI_OBJECT_PROP_RESIST: {
2516  int iargbis = va_arg(args, int);
2517 
2518  *type = CFAPI_INT16;
2519  iarg = va_arg(args, int);
2520  op->resist[iargbis] = iarg;
2521  }
2522  break;
2523 
2525  iarg = va_arg(args, int);
2526  *type = CFAPI_INT;
2527  op->attacktype = iarg;
2528  break;
2529 
2531  iarg = va_arg(args, int);
2532  *type = CFAPI_INT;
2533  op->path_attuned = iarg;
2534  break;
2535 
2537  iarg = va_arg(args, int);
2538  *type = CFAPI_INT;
2539  op->path_repelled = iarg;
2540  break;
2541 
2543  iarg = va_arg(args, int);
2544  *type = CFAPI_INT;
2545  op->path_denied = iarg;
2546  break;
2547 
2549  iarg = va_arg(args, int);
2550  *type = CFAPI_INT;
2551  op->material = iarg;
2552  break;
2553 
2555  break;
2556 
2558  iarg = va_arg(args, int);
2559  *type = CFAPI_INT;
2560  op->magic = iarg;
2561  break;
2562 
2564  larg = va_arg(args, long);
2565  *type = CFAPI_LONG;
2566  op->value = larg;
2567  break;
2568 
2570  iarg = va_arg(args, int);
2571  *type = CFAPI_INT;
2572  op->level = iarg;
2574  break;
2575 
2577  iarg = va_arg(args, int);
2578  *type = CFAPI_INT;
2579  op->last_heal = iarg;
2580  break;
2581 
2583  iarg = va_arg(args, int);
2584  *type = CFAPI_INT;
2585  op->last_sp = iarg;
2586  break;
2587 
2589  iarg = va_arg(args, int);
2590  *type = CFAPI_INT;
2591  op->last_grace = iarg;
2592  break;
2593 
2595  iarg = va_arg(args, int);
2596  *type = CFAPI_INT;
2597  op->last_eat = iarg;
2598  break;
2599 
2601  iarg = va_arg(args, int);
2602  *type = CFAPI_INT;
2603  op->invisible = iarg;
2604  break;
2605 
2607  iarg = va_arg(args, int);
2608  *type = CFAPI_INT;
2609  op->pick_up = iarg;
2610  break;
2611 
2613  iarg = va_arg(args, int);
2614  *type = CFAPI_INT;
2615  op->item_power = iarg;
2616  break;
2617 
2619  iarg = va_arg(args, int);
2620  *type = CFAPI_INT;
2621  op->gen_sp_armour = iarg;
2622  break;
2623 
2625  iarg = va_arg(args, int);
2626  *type = CFAPI_INT;
2627  if (op->weight != iarg) {
2628  object *tmp;
2629  player *pl;
2630 
2631  op->weight = iarg;
2632  if (op->env != NULL) {
2634  if (!tmp) {
2635  for (pl = first_player; pl; pl = pl->next)
2636  if (pl->ob->container == op->env)
2637  break;
2638  if (pl)
2639  tmp = pl->ob;
2640  else
2641  tmp = NULL;
2642  } else {
2644  fix_object(tmp);
2645  }
2646  if (tmp)
2648  } else {
2650  if (tmp->type == PLAYER)
2652  FOR_ABOVE_FINISH();
2653  }
2654  }
2655  break;
2656 
2658  iarg = va_arg(args, int);
2659  *type = CFAPI_INT;
2660  op->weight_limit = iarg;
2661  break;
2662 
2664  iarg = va_arg(args, int);
2665  *type = CFAPI_INT;
2666  if (op->glow_radius != iarg) {
2667  object *tmp;
2668 
2669  op->glow_radius = iarg;
2671  if (tmp->map != NULL) {
2672  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2673  update_position(tmp->map, tmp->x, tmp->y);
2674  update_all_los(tmp->map, tmp->x, tmp->y);
2675  }
2676  }
2677  break;
2678 
2680  s64arg = va_arg(args, int64_t);
2681  *type = CFAPI_SINT64;
2682  op->total_exp = s64arg;
2683  break;
2684 
2686  oparg = va_arg(args, object *);
2687  *type = CFAPI_POBJECT;
2688  object_set_enemy(op, oparg);
2689  break;
2690 
2692  iarg = va_arg(args, int);
2693  *type = CFAPI_INT;
2694  op->run_away = iarg;
2695  break;
2696 
2698  oparg = va_arg(args, object *);
2699  *type = CFAPI_POBJECT;
2700  op->chosen_skill = oparg;
2701  break;
2702 
2704  iarg = va_arg(args, int);
2705  *type = CFAPI_INT;
2706  op->hide = iarg;
2707  break;
2708 
2710  iarg = va_arg(args, int);
2711  *type = CFAPI_INT;
2712  op->move_status = iarg;
2713  break;
2714 
2716  iarg = va_arg(args, int);
2717  *type = CFAPI_INT;
2718  op->attack_movement = iarg;
2719  break;
2720 
2722  oparg = va_arg(args, object *);
2723  *type = CFAPI_POBJECT;
2724  op->spellitem = oparg;
2725  break;
2726 
2728  darg = va_arg(args, double);
2729  *type = CFAPI_DOUBLE;
2730  op->expmul = darg;
2731  break;
2732 
2734  sarg = va_arg(args, char *);
2735  *type = CFAPI_STRING;
2738  break;
2739 
2741  iarg = va_arg(args, int);
2742  *type = CFAPI_INT;
2743  op->anim_speed = iarg;
2744  break;
2745 
2747  iarg = va_arg(args, int);
2748  *type = CFAPI_INT;
2749  if (iarg == 1 && is_friendly(op) == 0)
2751  else if (iarg == 0 && is_friendly(op) == 1)
2753  break;
2754 
2756  iarg = va_arg(args, int);
2757  *type = CFAPI_INT;
2758  op->stats.luck = iarg;
2759  break;
2760 
2761  case CFAPI_OBJECT_PROP_EXP:
2762  s64arg = va_arg(args, int64_t);
2763  *type = CFAPI_SINT64;
2764  op->stats.exp = s64arg;
2765  break;
2766 
2768  oparg = va_arg(args, object *);
2769  *type = CFAPI_POBJECT;
2770  object_set_owner(op, oparg);
2771  break;
2772 
2775  *type = CFAPI_NONE;
2776  break;
2777 
2778  case CFAPI_OBJECT_PROP_FLAGS: {
2779  int iargbis;
2780 
2781  iarg = va_arg(args, int);
2782  iargbis = va_arg(args, int);
2783  *type = CFAPI_INT;
2784 
2785  if (iargbis == 1)
2786  SET_FLAG(op, iarg);
2787  else
2788  CLEAR_FLAG(op, iarg);
2789  }
2790  break;
2791 
2792  case CFAPI_OBJECT_PROP_STR:
2793  iarg = va_arg(args, int);
2794  *type = CFAPI_INT;
2795  op->stats.Str = iarg;
2796  break;
2797 
2798  case CFAPI_OBJECT_PROP_DEX:
2799  iarg = va_arg(args, int);
2800  *type = CFAPI_INT;
2801  op->stats.Dex = iarg;
2802  break;
2803 
2804  case CFAPI_OBJECT_PROP_CON:
2805  iarg = va_arg(args, int);
2806  *type = CFAPI_INT;
2807  op->stats.Con = iarg;
2808  break;
2809 
2810  case CFAPI_OBJECT_PROP_WIS:
2811  iarg = va_arg(args, int);
2812  *type = CFAPI_INT;
2813  op->stats.Wis = iarg;
2814  break;
2815 
2816  case CFAPI_OBJECT_PROP_INT:
2817  iarg = va_arg(args, int);
2818  *type = CFAPI_INT;
2819  op->stats.Int = iarg;
2820  break;
2821 
2822  case CFAPI_OBJECT_PROP_POW:
2823  iarg = va_arg(args, int);
2824  *type = CFAPI_INT;
2825  op->stats.Pow = iarg;
2826  break;
2827 
2828  case CFAPI_OBJECT_PROP_CHA:
2829  iarg = va_arg(args, int);
2830  *type = CFAPI_INT;
2831  op->stats.Cha = iarg;
2832  break;
2833 
2834  case CFAPI_OBJECT_PROP_WC:
2835  iarg = va_arg(args, int);
2836  *type = CFAPI_INT;
2837  op->stats.wc = iarg;
2838  break;
2839 
2840  case CFAPI_OBJECT_PROP_AC:
2841  iarg = va_arg(args, int);
2842  *type = CFAPI_INT;
2843  op->stats.ac = iarg;
2844  break;
2845 
2846  case CFAPI_OBJECT_PROP_HP:
2847  iarg = va_arg(args, int);
2848  *type = CFAPI_INT;
2849  op->stats.hp = iarg;
2850  break;
2851 
2852  case CFAPI_OBJECT_PROP_SP:
2853  iarg = va_arg(args, int);
2854  *type = CFAPI_INT;
2855  op->stats.sp = iarg;
2856  break;
2857 
2858  case CFAPI_OBJECT_PROP_GP:
2859  iarg = va_arg(args, int);
2860  *type = CFAPI_INT;
2861  op->stats.grace = iarg;
2862  break;
2863 
2864  case CFAPI_OBJECT_PROP_FP:
2865  iarg = va_arg(args, int);
2866  *type = CFAPI_INT;
2867  op->stats.food = iarg;
2868  break;
2869 
2871  iarg = va_arg(args, int);
2872  *type = CFAPI_INT;
2873  op->stats.maxhp = iarg;
2874  break;
2875 
2877  iarg = va_arg(args, int);
2878  *type = CFAPI_INT;
2879  op->stats.maxsp = iarg;
2880  break;
2881 
2883  iarg = va_arg(args, int);
2884  *type = CFAPI_INT;
2885  op->stats.maxgrace = iarg;
2886  break;
2887 
2888  case CFAPI_OBJECT_PROP_DAM:
2889  iarg = va_arg(args, int);
2890  *type = CFAPI_INT;
2891  op->stats.dam = iarg;
2892  break;
2893 
2894  case CFAPI_OBJECT_PROP_FACE: {
2895  const Face *face;
2896  sarg = va_arg(args, char *);
2897  ret = va_arg(args, int *);
2898  *type = CFAPI_INT;
2899  face = try_find_face(sarg, 0);
2900  if (face != NULL) {
2901  op->face = face;
2902  op->state = 0;
2904  (*ret) = face->number;
2905  } else
2906  (*ret) = 0;
2907  break;
2908  }
2909 
2911  const Animations *anim;
2912  sarg = va_arg(args, char *);
2913  ret = va_arg(args, int *);
2914  *type = CFAPI_INT;
2915  anim = try_find_animation(sarg);
2916  if (anim != NULL) {
2917  op->animation = anim;
2918  SET_ANIMATION(op, 0);
2920  (*ret) = anim->num;
2921  } else {
2922  (*ret) = 0;
2923  }
2924  break;
2925  }
2926 
2928  iarg = va_arg(args, int);
2929  *type = CFAPI_INT;
2930  op->duration = iarg;
2931  break;
2932 
2934  if (op->contr) {
2935  oparg = va_arg(args, object *);
2936  *type = CFAPI_POBJECT;
2937  op->contr->mark = oparg;
2938  if (oparg) {
2939  op->contr->mark_count = oparg->count;
2940  } else {
2941  op->contr->mark_count = 0;
2942  }
2943  }
2944  break;
2945 
2947  if (op->contr) {
2948  partyarg = va_arg(args, partylist *);
2949  *type = CFAPI_PPARTY;
2950  party_join(op, partyarg);
2951  }
2952  break;
2953 
2955  sarg = va_arg(args, char *);
2956  *type = CFAPI_STRING;
2957  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
2958  break;
2959 
2961  iarg = va_arg(args, int);
2962  *type = CFAPI_INT;
2963  op->contr->bed_x = iarg;
2964  break;
2965 
2967  iarg = va_arg(args, int);
2968  *type = CFAPI_INT;
2969  op->contr->bed_y = iarg;
2970  break;
2971 
2973  sarg = va_arg(args, char *);
2974  *type = CFAPI_STRING;
2975  player_set_own_title(op->contr, sarg);
2976  break;
2977 
2979  move = va_arg(args, MoveType *);
2980  op->move_type = *move & MOVE_ALL;
2982  *type = CFAPI_MOVETYPE;
2983  break;
2984 
2986  move = va_arg(args, MoveType *);
2987  op->move_block = *move & MOVE_ALL;
2989  *type = CFAPI_MOVETYPE;
2990  break;
2991 
2993  move = va_arg(args, MoveType *);
2994  op->move_allow = *move & MOVE_ALL;
2996  *type = CFAPI_MOVETYPE;
2997  break;
2998 
3000  move = va_arg(args, MoveType *);
3001  op->move_on = *move & MOVE_ALL;
3003  *type = CFAPI_MOVETYPE;
3004  break;
3005 
3007  move = va_arg(args, MoveType *);
3008  op->move_off = *move & MOVE_ALL;
3010  *type = CFAPI_MOVETYPE;
3011  break;
3012 
3014  move = va_arg(args, MoveType *);
3015  op->move_type = *move & MOVE_ALL;
3017  *type = CFAPI_MOVETYPE;
3018  break;
3019 
3020  default:
3021  break;
3022  }
3023  }
3024  va_end(args);
3025 }
3026 
3033 static void cfapi_object_apply_below(int *type, ...) {
3034  va_list args;
3035  object *applier;
3036 
3037  va_start(args, type);
3038 
3039  applier = va_arg(args, object *);
3040 
3041  va_end(args);
3042 
3043  apply_by_living_below(applier);
3044  *type = CFAPI_NONE;
3045 }
3046 
3053 static void cfapi_object_apply(int *type, ...) {
3054  va_list args;
3055  object *applied;
3056  object *applier;
3057  int aflags;
3058  int *ret;
3059 
3060  va_start(args, type);
3061 
3062  applier = va_arg(args, object *);
3063  applied = va_arg(args, object *);
3064  aflags = va_arg(args, int);
3065  ret = va_arg(args, int *);
3066 
3067  va_end(args);
3068 
3069  *type = CFAPI_INT;
3070  *ret = apply_manual(applier, applied, aflags);
3071 }
3072 
3078 static void cfapi_object_identify(int *type, ...) {
3079  va_list args;
3080  object *op, **result;
3081 
3082  va_start(args, type);
3083 
3084  op = va_arg(args, object *);
3085  result = va_arg(args, object **);
3086 
3087  va_end(args);
3088 
3089  (*result) = identify(op);
3090  *type = CFAPI_POBJECT;
3091 }
3092 
3098 static void cfapi_object_describe(int *type, ...) {
3099  va_list args;
3100  object *op;
3101  object *owner;
3102  char *desc, *final;
3103  int size;
3104 
3105  va_start(args, type);
3106 
3107  op = va_arg(args, object *);
3108  owner = va_arg(args, object *);
3109  desc = va_arg(args, char *);
3110  size = va_arg(args, int);
3111  va_end(args);
3112 
3113  *type = CFAPI_STRING;
3114  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3115  strncpy(desc, final, size);
3116  desc[size - 1] = '\0';
3117  free(final);
3118 }
3119 
3120 static void cfapi_object_drain(int *type, ...) {
3121  va_list args;
3122 
3123  object *op;
3124  int ds;
3125 
3126  va_start(args, type);
3127 
3128  op = va_arg(args, object *);
3129  ds = va_arg(args, int);
3130 
3131  va_end(args);
3132 
3133  drain_specific_stat(op, ds);
3134 
3135  *type = CFAPI_NONE;
3136 }
3137 
3138 static void cfapi_object_remove_depletion(int *type, ...) {
3139  va_list args;
3140 
3141  object *op;
3142  int level, *result;
3143 
3144  va_start(args, type);
3145 
3146  op = va_arg(args, object *);
3147  level = va_arg(args, int);
3148  result = va_arg(args, int*);
3149 
3150  va_end(args);
3151 
3153 
3154  *type = CFAPI_INT;
3155 }
3156 
3157 static void cfapi_object_fix(int *type, ...) {
3158  va_list args;
3159  object *op;
3160 
3161  va_start(args, type);
3162 
3163  op = va_arg(args, object *);
3164 
3165  va_end(args);
3166 
3167  fix_object(op);
3168 
3169  *type = CFAPI_NONE;
3170 }
3171 
3173 static void cfapi_object_give_skill(int *type, ...) {
3174  va_list args;
3175 
3176  object *op;
3177  char *skillname;
3178 
3179  va_start(args, type);
3180 
3181  op = va_arg(args, object *);
3182  skillname = va_arg(args, char *);
3183 
3184  va_end(args);
3185 
3186  *type = CFAPI_POBJECT;
3187  give_skill_by_name(op, skillname);
3188 }
3189 
3190 static void cfapi_object_transmute(int *type, ...) {
3191  va_list args;
3192 
3193  object *op;
3194  object *chg;
3195 
3196  va_start(args, type);
3197 
3198  op = va_arg(args, object *);
3199  chg = va_arg(args, object *);
3200 
3201  va_end(args);
3202 
3203  transmute_materialname(op, chg);
3204  *type = CFAPI_NONE;
3205 }
3206 
3207 static void cfapi_object_remove(int *type, ...) {
3208  va_list args;
3209  object *op;
3210 
3211  va_start(args, type);
3212 
3213  op = va_arg(args, object *);
3214 
3215  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3216  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3217  va_end(args);
3218  *type = CFAPI_NONE;
3219  return;
3220  }
3221 
3222  va_end(args);
3223 
3224  object_remove(op);
3225  *type = CFAPI_NONE;
3226 }
3227 
3228 static void cfapi_object_delete(int *type, ...) {
3229  va_list args;
3230  object *op;
3231 
3232  va_start(args, type);
3233 
3234  op = va_arg(args, object *);
3235 
3237  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3238  *type = CFAPI_NONE;
3239  va_end(args);
3240  return;
3241  }
3242 
3243  va_end(args);
3244 
3246 
3247  *type = CFAPI_NONE;
3248 }
3249 
3255 static void cfapi_object_clone(int *type, ...) {
3256  va_list args;
3257  object *op;
3258  int kind;
3259  object **robj;
3260 
3261  va_start(args, type);
3262 
3263  op = va_arg(args, object *);
3264  kind = va_arg(args, int);
3265  robj = va_arg(args, object **);
3266 
3267  va_end(args);
3268 
3269  if (kind == 0) {
3270  *type = CFAPI_POBJECT;
3271  *robj = object_create_clone(op);
3272  } else {
3273  object *tmp;
3274  tmp = object_new();
3275  object_copy(op, tmp);
3276  *type = CFAPI_POBJECT;
3277  *robj = tmp;
3278  }
3279  return;
3280 }
3281 
3287 static void cfapi_object_create(int *type, ...) {
3288  va_list args;
3289  int ival;
3290  object **robj;
3291  va_start(args, type);
3292  ival = va_arg(args, int);
3293 
3294  *type = CFAPI_POBJECT;
3295  switch (ival) {
3296  case 0:
3297  robj = va_arg(args, object **);
3298  *robj = object_new();
3299  break;
3300 
3301  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3302  const char *sval;
3303  archetype *at;
3304 
3305  sval = va_arg(args, const char *);
3306  robj = va_arg(args, object **);
3307  va_end(args);
3308 
3309  at = try_find_archetype(sval);
3310  if (!at)
3311  at = find_archetype_by_object_name(sval);
3312  if (at) {
3313  *robj = object_create_arch(at);
3314  } else
3315  *robj = NULL;
3316  }
3317  break;
3318 
3319  default:
3320  *type = CFAPI_NONE;
3321  break;
3322  }
3323  va_end(args);
3324 }
3325 
3326 static void cfapi_object_insert(int *type, ...) {
3327  va_list args;
3328  object *op;
3329  object *orig;
3330  mapstruct *map;
3331  int flag, x, y;
3332  int itype;
3333  object **robj;
3334 
3335  va_start(args, type);
3336 
3337  op = va_arg(args, object *);
3338  if (!op) {
3339  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3340  va_end(args);
3341  return;
3342  }
3343  if (QUERY_FLAG(op, FLAG_FREED)) {
3344  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3345  va_end(args);
3346  return;
3347  }
3348  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3349  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3350  object_remove(op);
3351  }
3352  itype = va_arg(args, int);
3353 
3354  switch (itype) {
3355  case 0:
3356  map = va_arg(args, mapstruct *);
3357  orig = va_arg(args, object *);
3358  flag = va_arg(args, int);
3359  x = va_arg(args, int);
3360  y = va_arg(args, int);
3361  robj = va_arg(args, object **);
3362  if (!map) {
3363  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3365  *robj = NULL;
3366  } else
3367  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3368  *type = CFAPI_POBJECT;
3369  break;
3370 
3371  case 1:
3372  map = va_arg(args, mapstruct *);
3373  orig = va_arg(args, object *);
3374  flag = va_arg(args, int);
3375  robj = va_arg(args, object **);
3376  if (!map) {
3377  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3379  *robj = NULL;
3380  } else
3381  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3382  *type = CFAPI_POBJECT;
3383  break;
3384 
3385  case 2:
3386  map = va_arg(args, mapstruct *);
3387  orig = va_arg(args, object *);
3388  flag = va_arg(args, int);
3389  x = va_arg(args, int);
3390  y = va_arg(args, int);
3391  robj = va_arg(args, object **);
3392  if (!map) {
3393  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3395  *robj = NULL;
3396  } else {
3397  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3398  if (dir != -1) {
3399  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3400  } else {
3402  *robj = NULL;
3403  }
3404  }
3405  *type = CFAPI_POBJECT;
3406  break;
3407 
3408  case 3:
3409  orig = va_arg(args, object *);
3410  robj = va_arg(args, object **);
3411  if (!orig) {
3412  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3414  *robj = NULL;
3415  } else
3416  *robj = object_insert_in_ob(op, orig);
3417  *type = CFAPI_POBJECT;
3418  break;
3419 
3420  default:
3421  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3423  *type = CFAPI_NONE;
3424  break;
3425  }
3426 
3427  va_end(args);
3428 }
3434 static void cfapi_object_split(int *type, ...) {
3435  va_list args;
3436 
3437  int nr, size;
3438  object *op;
3439  char *buf;
3440  object **split;
3441 
3442  va_start(args, type);
3443 
3444  op = va_arg(args, object *);
3445  nr = va_arg(args, int);
3446  buf = va_arg(args, char *);
3447  size = va_arg(args, int);
3448  split = va_arg(args, object **);
3449  va_end(args);
3450 
3451  *split = object_split(op, nr, buf, size);
3452  if (*split != NULL)
3453  {
3454  *type = CFAPI_POBJECT;
3455  }
3456  else
3457  {
3458  *type = CFAPI_NONE;
3459  }
3460 }
3461 
3467 static void cfapi_object_merge(int *type, ...) {
3468  va_list args;
3469  object *op;
3470  object *op2;
3471  object **merge;
3472 
3473  va_start(args, type);
3474 
3475  op = va_arg(args, object *);
3476  op2 = va_arg(args, object *);
3477  merge = va_arg(args, object **);
3478 
3479  va_end(args);
3480 
3481  *type = CFAPI_POBJECT;
3482  *merge = object_merge(op, op2);
3483 }
3484 
3490 static void cfapi_object_distance(int *type, ...) {
3491  va_list args;
3492  object *op;
3493  object *op2;
3494  int *rint;
3495  va_start(args, type);
3496 
3497  op = va_arg(args, object *);
3498  op2 = va_arg(args, object *);
3499  rint = va_arg(args, int *);
3500 
3501  va_end(args);
3502 
3503  *type = CFAPI_INT;
3504  *rint = object_distance(op, op2);
3505 }
3511 static void cfapi_object_update(int *type, ...) {
3512  va_list args;
3513  int action;
3514  object *op;
3515  va_start(args, type);
3516 
3517  op = va_arg(args, object *);
3518  action = va_arg(args, int);
3519 
3520  va_end(args);
3521 
3523  *type = CFAPI_NONE;
3524 }
3525 
3531 static void cfapi_object_clear(int *type, ...) {
3532  va_list args;
3533  object *op;
3534  va_start(args, type);
3535 
3536  op = va_arg(args, object *);
3537 
3538  va_end(args);
3539 
3540  object_clear(op);
3541  *type = CFAPI_NONE;
3542 }
3543 
3549 static void cfapi_object_reset(int *type, ...) {
3550  va_list args;
3551  object *op;
3552 
3553  va_start(args, type);
3554 
3555  op = va_arg(args, object *);
3556 
3557  va_end(args);
3558 
3559  object_reset(op);
3560  *type = CFAPI_NONE;
3561 }
3562 
3563 static void cfapi_object_clean_object(int *type, ...) {
3564  va_list args;
3565  object *op;
3566 
3567  va_start(args, type);
3568  op = va_arg(args, object *);
3569  clean_object(op);
3570  va_end(args);
3571  *type = CFAPI_NONE;
3572 }
3573 
3574 static void cfapi_object_on_same_map(int *type, ...) {
3575  va_list args;
3576  object *op1;
3577  object *op2;
3578  int *rint;
3579 
3580  va_start(args, type);
3581  op1 = va_arg(args, object *);
3582  op2 = va_arg(args, object *);
3583  rint = va_arg(args, int *);
3584  va_end(args);
3585 
3586  *type = CFAPI_INT;
3587  *rint = on_same_map(op1, op2);
3588 }
3589 
3590 static void cfapi_object_spring_trap(int *type, ...) {
3591  object *trap;
3592  object *victim;
3593  va_list args;
3594 
3595  va_start(args, type);
3596  trap = va_arg(args, object *);
3597  victim = va_arg(args, object *);
3598  va_end(args);
3599 
3600  spring_trap(trap, victim);
3601  *type = CFAPI_NONE;
3602 }
3603 
3609 static void cfapi_object_check_trigger(int *type, ...) {
3610  object *op;
3611  object *cause;
3612  va_list args;
3613  int *rint;
3614 
3615  va_start(args, type);
3616  op = va_arg(args, object *);
3617  cause = va_arg(args, object *);
3618  rint = va_arg(args, int *);
3619  va_end(args);
3620 
3621  *rint = check_trigger(op, cause);
3622  *type = CFAPI_INT;
3623 }
3624 
3636 static void cfapi_map_trigger_connected(int *type, ...) {
3637  objectlink *ol;
3638  object *cause;
3639  int state;
3640  va_list args;
3641 
3642  va_start(args, type);
3643  ol = va_arg(args, objectlink *);
3644  cause = va_arg(args, object *);
3645  state = va_arg(args, int);
3646  va_end(args);
3647  trigger_connected(ol, cause, state);
3648  *type = CFAPI_NONE;
3649 }
3650 
3656 static void cfapi_object_query_money(int *type, ...) {
3657  object *op;
3658  va_list args;
3659  int *rint;
3660 
3661  va_start(args, type);
3662  op = va_arg(args, object *);
3663  rint = va_arg(args, int *);
3664  va_end(args);
3665 
3666  *rint = query_money(op);
3667  *type = CFAPI_INT;
3668 }
3669 
3675 static void cfapi_object_cast(int *type, ...) {
3676  object *op;
3677  object *sp;
3678  int dir;
3679  char *str;
3680  object *caster;
3681  va_list args;
3682  int *rint;
3683 
3684  va_start(args, type);
3685  op = va_arg(args, object *);
3686  caster = va_arg(args, object *);
3687  dir = va_arg(args, int);
3688  sp = va_arg(args, object *);
3689  str = va_arg(args, char *);
3690  rint = va_arg(args, int *);
3691  va_end(args);
3692 
3693  *type = CFAPI_INT;
3694 
3695  if (!op->map) {
3696  *rint = -1;
3697  return;
3698  }
3699 
3700  *rint = cast_spell(op, caster, dir, sp, str);
3701 }
3702 
3703 static void cfapi_object_learn_spell(int *type, ...) {
3704  object *op;
3705  object *sp;
3706  int prayer;
3707  va_list args;
3708 
3709  va_start(args, type);
3710  op = va_arg(args, object *);
3711  sp = va_arg(args, object *);
3712  prayer = va_arg(args, int);
3713  va_end(args);
3714  do_learn_spell(op, sp, prayer);
3715  *type = CFAPI_NONE;
3716 }
3717 
3718 static void cfapi_object_forget_spell(int *type, ...) {
3719  object *op;
3720  object *sp;
3721  va_list args;
3722  char name[MAX_BUF];
3723 
3724  va_start(args, type);
3725  op = va_arg(args, object *);
3726  sp = va_arg(args, object *);
3727  va_end(args);
3728  query_name(sp, name, MAX_BUF);
3730  *type = CFAPI_NONE;
3731 }
3732 
3738 static void cfapi_object_check_spell(int *type, ...) {
3739  object *op;
3740  char *spellname;
3741  va_list args;
3742  object **robj;
3743 
3744  va_start(args, type);
3745  op = va_arg(args, object *);
3746  spellname = va_arg(args, char *);
3747  robj = va_arg(args, object **);
3748  va_end(args);
3749  *robj = check_spell_known(op, spellname);
3750  *type = CFAPI_POBJECT;
3751 }
3752 
3758 static void cfapi_object_pay_amount(int *type, ...) {
3759  object *op;
3760  uint64_t amount;
3761  va_list args;
3762  int *rint;
3763 
3764  va_start(args, type);
3765  op = va_arg(args, object *);
3766  amount = va_arg(args, uint64_t);
3767  rint = va_arg(args, int *);
3768  va_end(args);
3769 
3770  *rint = pay_for_amount(amount, op);
3771  *type = CFAPI_INT;
3772 }
3773 
3779 static void cfapi_object_pay_item(int *type, ...) {
3780  object *op;
3781  object *tobuy;
3782  int *rint;
3783 
3784  va_list args;
3785 
3786  va_start(args, type);
3787  tobuy = va_arg(args, object *);
3788  op = va_arg(args, object *);
3789  rint = va_arg(args, int *);
3790  va_end(args);
3791 
3792  *rint = pay_for_item(tobuy, op, 0);
3793  *type = CFAPI_INT;
3794 }
3795 
3803 static void cfapi_object_transfer(int *type, ...) {
3804  object *op;
3805  object *originator;
3806  int x, y, randompos, ttype, flag;
3807  va_list args;
3808  mapstruct *map;
3809  int *rint;
3810  object **robj;
3811 
3812  va_start(args, type);
3813  op = va_arg(args, object *);
3814  ttype = va_arg(args, int);
3815  switch (ttype) {
3816  case 0:
3817  x = va_arg(args, int);
3818  y = va_arg(args, int);
3819  randompos = va_arg(args, int);
3820  originator = va_arg(args, object *);
3821  rint = va_arg(args, int *);
3822  va_end(args);
3823 
3824  *rint = transfer_ob(op, x, y, randompos, originator);
3825  *type = CFAPI_INT;
3826  return;
3827  break;
3828 
3829  case 1:
3830  map = va_arg(args, mapstruct *);
3831  originator = va_arg(args, object *);
3832  flag = va_arg(args, int);
3833  x = va_arg(args, int);
3834  y = va_arg(args, int);
3835  robj = va_arg(args, object **);
3836  va_end(args);
3837  if (x < 0 || y < 0) {
3838  x = map->enter_x;
3839  y = map->enter_y;
3840  }
3841  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
3842  *type = CFAPI_POBJECT;
3843  return;
3844  break;
3845 
3846  case 2:
3847  x = va_arg(args, int);
3848  y = va_arg(args, int);
3849  rint = va_arg(args, int *);
3850  va_end(args);
3851 
3852  *rint = move_to(op, x, y);
3853  *type = CFAPI_INT;
3854  return;
3855 
3856  default:
3857  va_end(args);
3858  *type = CFAPI_NONE;
3859  return;
3860  break;
3861  }
3862 }
3863 
3868  object *op;
3869  char *str;
3870  va_list args;
3871  object **robj;
3872 
3873  *type = CFAPI_POBJECT;
3874  va_start(args, type);
3875  op = va_arg(args, object *);
3876 
3877  str = va_arg(args, char *);
3878  robj = va_arg(args, object **);
3880  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
3881  if (*robj == NULL) {
3882  char name[MAX_BUF];
3883 
3884  /* Search by name or slaying instead */
3885  FOR_INV_PREPARE(op, tmp) {
3886  if (tmp->name) {
3888  if (!strncmp(name, str, strlen(str)))
3889  *robj = tmp;
3890  if (!strncmp(tmp->name, str, strlen(str)))
3891  *robj = tmp;
3892  }
3893  if (tmp->slaying && !strcmp(tmp->slaying, str))
3894  *robj = tmp;
3895  if (*robj != NULL)
3896  break;
3897  } FOR_INV_FINISH();
3898  }
3899  va_end(args);
3900 }
3901 
3902 static void cfapi_object_find_by_arch_name(int *type, ...) {
3903  const object *who;
3904  object **result;
3905  const char *name;
3906  va_list args;
3907 
3908  va_start(args, type);
3909  who = va_arg(args, const object *);
3910  name = va_arg(args, const char *);
3911  result = va_arg(args, object **);
3912  va_end(args);
3913  *type = CFAPI_POBJECT;
3914 
3916 }
3917 
3918 static void cfapi_object_find_by_name(int *type, ...) {
3919  const object *who;
3920  object **result;
3921  const char *name;
3922  va_list args;
3923 
3924  va_start(args, type);
3925  who = va_arg(args, const object *);
3926  name = va_arg(args, const char *);
3927  result = va_arg(args, object **);
3928  va_end(args);
3929  *type = CFAPI_POBJECT;
3930 
3932 }
3933 
3939 static void cfapi_object_drop(int *type, ...) {
3940  object *op;
3941  object *author;
3942  va_list args;
3943 
3944  va_start(args, type);
3945  op = va_arg(args, object *);
3946  author = va_arg(args, object *);
3947  va_end(args);
3948  *type = CFAPI_NONE;
3949 
3950  if (QUERY_FLAG(op, FLAG_NO_DROP))
3951  return;
3952  drop(author, op);
3953 
3954  if (author->type == PLAYER) {
3955  author->contr->count = 0;
3956  author->contr->socket->update_look = 1;
3957  }
3958 }
3959 
3963 static void cfapi_object_change_abil(int *type, ...) {
3964  object *op, *tmp;
3965  int *rint;
3966  va_list args;
3967 
3968  va_start(args, type);
3969  op = va_arg(args, object *);
3970  tmp = va_arg(args, object *);
3971  rint = va_arg(args, int *);
3972  va_end(args);
3973 
3974  *type = CFAPI_INT;
3975  *rint = change_abil(op, tmp);
3976 }
3977 
3978 static void cfapi_object_say(int *type, ...) {
3979  object *op;
3980  char *msg;
3981  va_list args;
3982  int *rint;
3983  char empty[] = "";
3984 
3985  va_start(args, type);
3986  op = va_arg(args, object *);
3987  msg = va_arg(args, char *);
3988  rint = va_arg(args, int *);
3989  va_end(args);
3990 
3991  if (op->type == PLAYER) {
3992  command_say(op, msg == NULL ? empty : msg);
3993  } else {
3995  }
3996  *rint = 0;
3997  *type = CFAPI_INT;
3998 }
3999 
4000 /* PLAYER SUBCLASS */
4001 
4007 static void cfapi_player_find(int *type, ...) {
4008  va_list args;
4009  char *sval;
4010  player **rpl;
4011  va_start(args, type);
4012 
4013  sval = va_arg(args, char *);
4014  rpl = va_arg(args, player **);
4015  va_end(args);
4016 
4017  *rpl = find_player_partial_name(sval);
4018 
4019  *type = CFAPI_PPLAYER;
4020 }
4021 
4022 static void cfapi_player_message(int *type, ...) {
4023  va_list args;
4024  int flags;
4025  int pri;
4026  object *pl;
4027  const char *buf;
4028 
4029  va_start(args, type);
4030 
4031  flags = va_arg(args, int);
4032  pri = va_arg(args, int);
4033  pl = va_arg(args, object *);
4034  buf = va_arg(args, const char *);
4035  va_end(args);
4036 
4038  buf);
4039  *type = CFAPI_NONE;
4040 }
4041 
4048 static void cfapi_object_perm_exp(int *type, ...) {
4049  va_list args;
4050  object *op;
4051  int64_t *rlong;
4052 
4053  va_start(args, type);
4054  op = va_arg(args, object *);
4055  rlong = va_arg(args, int64_t *);
4056  va_end(args);
4057 
4058  *type = CFAPI_SINT64;
4059  *rlong = PERM_EXP(op->total_exp);
4060 }
4061 
4067 static void cfapi_object_change_exp(int *type, ...) {
4068  va_list args;
4069  int flag;
4070  object *ob;
4071  const char *skill;
4072  int64_t exp;
4073 
4074  va_start(args, type);
4075  ob = va_arg(args, object *);
4076  exp = va_arg(args, int64_t);
4077  skill = va_arg(args, const char *);
4078  flag = va_arg(args, int);
4079  va_end(args);
4080 
4081  *type = CFAPI_NONE;
4082  change_exp(ob, exp, skill, flag);
4083 }
4084 
4090 static void cfapi_player_can_pay(int *type, ...) {
4091  va_list args;
4092  object *pl;
4093  int *rint;
4094 
4095  va_start(args, type);
4096  pl = va_arg(args, object *);
4097  rint = va_arg(args, int *);
4098  va_end(args);
4099 
4100  *rint = can_pay(pl);
4101  *type = CFAPI_INT;
4102 }
4103 
4109 static void cfapi_player_knowledge(int *type, ...) {
4110  va_list args;
4111  object *pl;
4112  int *rint, what;
4113  const char *knowledge;
4114 
4115  va_start(args, type);
4116  what = va_arg(args, int);
4117 
4118  switch(what)
4119  {
4120  case 1:
4121  pl = va_arg(args, object *);
4122  knowledge = va_arg(args, const char *);
4123  rint = va_arg(args, int *);
4124 
4125  *type = CFAPI_INT;
4126 
4127  if (pl->contr == NULL) {
4128  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4129  *rint = 0;
4130  va_end(args);
4131  return;
4132  }
4133 
4134  *rint = knowledge_player_knows(pl->contr, knowledge);
4135  break;
4136 
4137  case 2:
4138  pl = va_arg(args, object *);
4139  knowledge = va_arg(args, const char *);
4140  *type = CFAPI_NONE;
4141  if (pl->contr != NULL)
4142  knowledge_give(pl->contr, knowledge, NULL);
4143 
4144  break;
4145 
4146  default:
4147  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4148  }
4149 
4150  va_end(args);
4151 }
4152 
4158 static void cfapi_object_teleport(int *type, ...) {
4159  mapstruct *map;
4160  int x, y;
4161  object *who;
4162  int *res;
4163  va_list args;
4164 
4165  va_start(args, type);
4166  who = va_arg(args, object *);
4167  map = va_arg(args, mapstruct *);
4168  x = va_arg(args, int);
4169  y = va_arg(args, int);
4170  res = va_arg(args, int *);
4171  va_end(args);
4172 
4173  *type = CFAPI_INT;
4174  *res = object_teleport(who, map, x, y);
4175 }
4176 
4177 static void cfapi_object_pickup(int *type, ...) {
4178  object *who;
4179  object *what;
4180  va_list args;
4181 
4182  va_start(args, type);
4183  who = va_arg(args, object *);
4184  what = va_arg(args, object *);
4185  va_end(args);
4186 
4187  pick_up(who, what);
4188  *type = CFAPI_NONE;
4189 }
4190 
4191 /* Archetype-related functions */
4192 static void cfapi_archetype_get_property(int *type, ...) {
4193  int prop;
4194  archetype *arch;
4195  va_list args;
4196  sstring *rsstring;
4197  archetype **rarch;
4198  object **robject;
4199 
4200  va_start(args, type);
4201  arch = va_arg(args, archetype *);
4202  prop = va_arg(args, int);
4203  switch (prop) {
4204  case CFAPI_ARCH_PROP_NAME:
4205  *type = CFAPI_SSTRING;
4206  rsstring = va_arg(args, sstring *);
4207  *rsstring = arch->name;
4208  break;
4209 
4210  case CFAPI_ARCH_PROP_NEXT:
4211  *type = CFAPI_PARCH;
4212  rarch = va_arg(args, archetype **);
4213  *rarch = get_next_archetype(arch);
4214  break;
4215 
4216  case CFAPI_ARCH_PROP_HEAD:
4217  *type = CFAPI_PARCH;
4218  rarch = va_arg(args, archetype **);
4219  *rarch = arch->head;
4220  break;
4221 
4222  case CFAPI_ARCH_PROP_MORE:
4223  *type = CFAPI_PARCH;
4224  rarch = va_arg(args, archetype **);
4225  *rarch = arch->more;
4226  break;
4227 
4228  case CFAPI_ARCH_PROP_CLONE:
4229  *type = CFAPI_POBJECT;
4230  robject = va_arg(args, object **);
4231  *robject = &arch->clone;
4232  break;
4233 
4234  default:
4235  *type = CFAPI_NONE;
4236  break;
4237  }
4238  va_end(args);
4239 }
4240 
4247 static void cfapi_party_get_property(int *type, ...) {
4248  partylist *party;
4249  int prop;
4250  va_list args;
4251  object *obarg;
4252  sstring *rsstring;
4253  player **rplayer;
4254  partylist **rparty;
4255 
4256  va_start(args, type);
4257  party = va_arg(args, partylist *);
4258  prop = va_arg(args, int);
4259  switch (prop) {
4260  case CFAPI_PARTY_PROP_NAME:
4261  rsstring = va_arg(args, sstring *);
4262  *rsstring = party->partyname;
4263  *type = CFAPI_SSTRING;
4264  break;
4265 
4266  case CFAPI_PARTY_PROP_NEXT:
4267  rparty = va_arg(args, partylist **);
4268  *rparty = (party ? party_get_next(party) : party_get_first());
4269  *type = CFAPI_PPARTY;
4270  break;
4271 
4273  rsstring = va_arg(args, sstring *);
4274  *rsstring = party_get_password(party);
4275  *type = CFAPI_SSTRING;
4276  break;
4277 
4279  *type = CFAPI_PPLAYER;
4280  obarg = va_arg(args, object *);
4281  rplayer = va_arg(args, player **);
4282  *rplayer = (obarg ? obarg->contr : first_player);
4283  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4284  if ((*rplayer)->ob->contr->party == party) {
4285  break;
4286  }
4287  break;
4288 
4289  default:
4290  *type = CFAPI_NONE;
4291  break;
4292  }
4293  va_end(args);
4294 }
4295 
4302 static void cfapi_region_get_property(int *type, ...) {
4303  region *reg;
4304  int prop, *rint;
4305  va_list args;
4307  sstring *rsstring;
4308  region **rregion;
4309 
4310  va_start(args, type);
4311  reg = va_arg(args, region *);
4312  prop = va_arg(args, int);
4313  switch (prop) {
4315  rsstring = va_arg(args, sstring *);
4316  *rsstring = reg->name;
4317  *type = CFAPI_SSTRING;
4318  break;
4319 
4321  rregion = va_arg(args, region **);
4322  *rregion = nullptr;
4323  *type = CFAPI_PREGION;
4324  break;
4325 
4327  rregion = va_arg(args, region **);
4328  *rregion = reg->parent;
4329  *type = CFAPI_PREGION;
4330  break;
4331 
4333  rsstring = va_arg(args, sstring *);
4334  *rsstring = reg->longname;
4335  *type = CFAPI_SSTRING;
4336  break;
4337 
4339  rsstring = va_arg(args, sstring *);
4340  *rsstring = reg->msg;
4341  *type = CFAPI_SSTRING;
4342  break;
4343 
4346  rint = va_arg(args, int*);
4347  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4348  *type = CFAPI_INT;
4349  break;
4350 
4352  rsstring = va_arg(args, sstring *);
4353  *rsstring = reg->jailmap;
4354  *type = CFAPI_SSTRING;
4355  break;
4356 
4357  default:
4358  *type = CFAPI_NONE;
4359  break;
4360  }
4361  va_end(args);
4362 }
4363 
4375 static void cfapi_friendlylist_get_next(int *type, ...) {
4376  object *ob;
4377  va_list args;
4378  object **robject;
4379 
4380  va_start(args, type);
4381  ob = va_arg(args, object *);
4382  robject = va_arg(args, object **);
4383  va_end(args);
4384 
4385  *type = CFAPI_POBJECT;
4386  *robject = get_next_friend(ob);
4387 }
4388 
4389 /*
4390  * Random-map related stuff.
4391  */
4392 
4399 static void cfapi_set_random_map_variable(int *type, ...) {
4400  va_list args;
4401  RMParms *rp;
4402  const char *buf;
4403  int *ret;
4404 
4405  va_start(args, type);
4406  rp = va_arg(args, RMParms *);
4407  buf = va_arg(args, const char *);
4408  ret = va_arg(args, int *);
4409  va_end(args);
4410 
4411  *ret = set_random_map_variable(rp, buf);
4412  *type = CFAPI_INT;
4413 }
4414 
4421 static void cfapi_generate_random_map(int *type, ...) {
4422  va_list args;
4423  const char *name;
4424  RMParms *rp;
4425  char **use_layout;
4426  sstring reset_group;
4427  mapstruct **ret;
4428 
4429  va_start(args, type);
4430  name = va_arg(args, const char *);
4431  rp = va_arg(args, RMParms *);
4432  use_layout = va_arg(args, char **);
4433  reset_group = va_arg(args, sstring);
4434  ret = va_arg(args, mapstruct **);
4435  va_end(args);
4436 
4437  *ret = generate_random_map(name, rp, use_layout, reset_group);
4438 }
4439 
4440 static void cfapi_object_user_event(int *type, ...) {
4441  object *op;
4442  object *activator;
4443  object *third;
4444  const char *message;
4445  int fix;
4446  int *ret;
4447  va_list args;
4448 
4449  va_start(args, type);
4450  op = va_arg(args, object *);
4451  activator = va_arg(args, object *);
4452  third = va_arg(args, object *);
4453  message = va_arg(args, const char *);
4454  fix = va_arg(args, int);
4455  ret = va_arg(args, int *);
4456  va_end(args);
4457 
4458  *ret = events_execute_object_user(op, activator, third, message, fix);
4459  *type = CFAPI_INT;
4460 }
4461 
4464 static void cfapi_player_quest(int *type, ...) {
4465  int op;
4466  va_list args;
4467  object *player;
4468  sstring code;
4469 
4470  va_start(args, type);
4471  op = va_arg(args, int);
4472  player = va_arg(args, object *);
4473  code = va_arg(args, sstring);
4474 
4475  if (player->contr == NULL) {
4476  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4477  va_end(args);
4478  /* crash/quit? */
4479  return;
4480  }
4481 
4482  switch(op) {
4483  case CFAPI_PLAYER_QUEST_START: {
4484  int state = va_arg(args, int);
4485  quest_start(player->contr, code, state);
4486  *type = CFAPI_NONE;
4487  break;
4488  }
4490  int *ret = va_arg(args, int *);
4491  *ret = quest_get_player_state(player->contr, code);
4492  *type = CFAPI_INT;
4493  break;
4494  }
4496  int state = va_arg(args, int);
4497  quest_set_player_state(player->contr, code, state);
4498  *type = CFAPI_NONE;
4499  break;
4500  }
4502  int *ret = va_arg(args, int*);
4503  *ret = quest_was_completed(player->contr, code);
4504  *type = CFAPI_INT;
4505  break;
4506  }
4507  default:
4508  LOG(llevError, "invalid quest type: %d\n", op);
4509  *type = CFAPI_NONE;
4510  }
4511 
4512  va_end(args);
4513 }
4514 
4515 static void cfapi_register_command(int *type, ...) {
4516  va_list args;
4517  const char *name = NULL, *extra = NULL;
4518  float time;
4519  command_function func = NULL;
4520  command_function_extra func_extra = NULL;
4521  uint8_t register_type, command_type;
4523 
4524  va_start(args, type);
4525  register_type = va_arg(args, int);
4526  name = va_arg(args, const char *);
4527  if (register_type == 1) {
4528  func = va_arg(args, command_function);
4529  } else {
4530  extra = va_arg(args, const char *);
4531  func_extra = va_arg(args, command_function_extra);
4532  }
4533  command_type = (uint8_t)va_arg(args, int);
4534  if (command_type > COMMAND_TYPE_WIZARD) {
4535  command_type = COMMAND_TYPE_NORMAL;
4536  }
4537  time = va_arg(args, double);
4538  cr = va_arg(args, command_registration *);
4539  va_end(args);
4540 
4541  if (register_type == 1) {
4542  (*cr) = command_register(name, command_type, func, time);
4543  } else {
4544  (*cr) = command_register_extra(name, extra, command_type, func_extra, time);
4545  }
4546 
4547  *type = CFAPI_SINT64;
4548 }
4549 
4550 static void cfapi_unregister_command(int *type, ...) {
4551  va_list args;
4553 
4554  va_start(args, type);
4555  cr = va_arg(args, command_registration);
4556  va_end(args);
4557 
4558  command_unregister(cr);
4559 }
4560 
4561 /*****************************************************************************/
4562 /* NEW PLUGIN STUFF ENDS HERE */
4563 /*****************************************************************************/
4564 
4565 
4570 void initPlugins(void) {
4571  struct dirent *currentfile;
4572  DIR *plugdir;
4573  size_t l;
4574  char buf[sizeof(LIBDIR) + 9 + sizeof(dirent::d_name)];
4575 
4576  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4577  LOG(llevDebug, "plugins: loading from %s\n", buf);
4578 
4579  plugdir = opendir(buf);
4580  if (plugdir == NULL)
4581  return;
4582 
4583  while ((currentfile = readdir(plugdir)) != NULL) {
4584  l = strlen(currentfile->d_name);
4585  if (l > strlen(PLUGIN_SUFFIX)) {
4586  int ignore = 0;
4587 
4588  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4589  continue;
4590 
4591  for (auto disable = settings.disabled_plugins.cbegin(); disable != settings.disabled_plugins.cend(); ++disable) {
4592  if (strcmp(*disable, "All") == 0) {
4593  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4594  ignore = 1;
4595  break;
4596  }
4597  if (strncmp(*disable, currentfile->d_name, strlen(*disable)) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + strlen(*disable)) {
4598  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4599  ignore = 1;
4600  break;
4601  }
4602  }
4603  if (ignore == 0) {
4604  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4605  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4607  }
4608  }
4609  }
4610 
4611  closedir(plugdir);
4612 }
4613 
4618 void cleanupPlugins(void) {
4619  for (crossfire_plugin *cp : plugins_list) {
4620  if (cp->closefunc)
4621  cp->closefunc();
4622  /* Don't actually unload plugins, it makes backtraces for memory
4623  * debugging (printed at exit) messed up. And it doesn't matter if we
4624  * don't free it here. The OS will do it for us.
4625  */
4626  /* plugins_dlclose(cp->libptr); */
4627  free(cp);
4628  }
4629  plugins_list.clear();
4630 }
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:170
Face
Definition: face.h:14
cfapi_object_transfer
static void cfapi_object_transfer(int *type,...)
Definition: plugins.cpp:3803
cfapi_object_clean_object
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.cpp:3563
cfapi_object_forget_spell
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.cpp:3718
cfapi_map_change_light
static void cfapi_map_change_light(int *type,...)
Definition: plugins.cpp:1425
CFAPI_SSTRING
#define CFAPI_SSTRING
Definition: plugin.h:70
UP_OBJ_FACE
#define UP_OBJ_FACE
Definition: object.h:533
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:3434
PLAYER
@ PLAYER
Definition: object.h:112
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:545
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:1456
cfapi_timer_destroy
static void cfapi_timer_destroy(int *type,...)
Definition: plugins.cpp:988
first_player
player * first_player
Definition: init.cpp:106
settings
struct Settings settings
Definition: init.cpp:139
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:249
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:3490
cfapi_object_delete
static void cfapi_object_delete(int *type,...)
Definition: plugins.cpp:3228
cfapi_player_quest
static void cfapi_player_quest(int *type,...)
Definition: plugins.cpp:4464
MOVE_ALL
#define MOVE_ALL
Definition: define.h:398
cfapi_timer_create
static void cfapi_timer_create(int *type,...)
Definition: plugins.cpp:955
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:271
cfapi_archetype_get_property
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.cpp:4192
NR_EVENTS
#define NR_EVENTS
Definition: events.h:61
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:58
get_empty_map
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.cpp:842
monster_npc_say
void monster_npc_say(object *npc, const char *cp)
Definition: monster.cpp:2497
CFAPI_MAP_PROP_RESET_TIME
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:251
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:252
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:279
cfapi_system_get_party_vector
static void cfapi_system_get_party_vector(int *type,...)
Definition: plugins.cpp:698
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:3939
ready_map_name
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.cpp:1768
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:277
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:261
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:79
map_find_by_archetype
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Definition: object.cpp:3118
object_merge
object * object_merge(object *op, object *top)
Definition: object.cpp:2051
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:916
update_position
void update_position(mapstruct *m, int x, int y)
Definition: map.cpp:2118
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:1296
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:305
CFAPI_PLAYER_PROP_COUNT
#define CFAPI_PLAYER_PROP_COUNT
Definition: plugin.h:239
CFAPI_OBJECT_PROP_BASE_NAME
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:187
hook_entry
Definition: plugin.h:308
UPD_WEIGHT
#define UPD_WEIGHT
Definition: newclient.h:319
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:177
spring_trap
void spring_trap(object *trap, object *victim)
Definition: rune.cpp:214
cfapi_object_get_property
static void cfapi_object_get_property(int *type,...)
Definition: plugins.cpp:1551
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:3287
SVN_REV
#define SVN_REV
Definition: svnversion.h:2
cfapi_object_drain
static void cfapi_object_drain(int *type,...)
Definition: plugins.cpp:3120
give_skill_by_name
object * give_skill_by_name(object *op, const char *skill_name)
Definition: living.cpp:1784
set_random_map_variable
int set_random_map_variable(RMParms *rp, const char *buf)
Definition: reader.cpp:2526
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:3222
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:3867
CFAPI_SYSTEM_ARCHETYPES
#define CFAPI_SYSTEM_ARCHETYPES
Definition: plugin.h:287
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:2956
object_reset
void object_reset(object *op)
Definition: object.cpp:934
CFAPI_ARCH_PROP_NEXT
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:266
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:307
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:1587
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:1132
get_tod
void get_tod(timeofday_t *tod)
Definition: time.cpp:219
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:3978
CFAPI_REGION_PROP_PARENT
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:278
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:273
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:324
FOR_ABOVE_PREPARE
#define FOR_ABOVE_PREPARE(op_, it_)
Definition: define.h:687
CFAPI_SYSTEM_PLAYERS
#define CFAPI_SYSTEM_PLAYERS
Definition: plugin.h:286
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:283
CFAPI_MAP_PROP_WIDTH
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:256
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:265
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:263
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:4346
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:416
initPlugins
void initPlugins(void)
Definition: plugins.cpp:4570
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:4375
buf
StringBuffer * buf
Definition: readable.cpp:1565
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
cfapi_object_identify
static void cfapi_object_identify(int *type,...)
Definition: plugins.cpp:3078
cfapi_map_set_map_property
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.cpp:1266
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.cpp:2857
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:4440
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Definition: newclient.h:407
CFAPI_MAP_PROP_ENTER_X
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:258
cfapi_object_update
static void cfapi_object_update(int *type,...)
Definition: plugins.cpp:3511
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:820
plugins_dlerror
#define plugins_dlerror()
Definition: plugin.h:115
cfapi_object_change_abil
static void cfapi_object_change_abil(int *type,...)
Definition: plugins.cpp:3963
get_season_name
const char * get_season_name(const int index)
Definition: time.cpp:127
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:21
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:279
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:1506
TIMER_ERR_ID
#define TIMER_ERR_ID
Definition: timers.h:67
MSG_TYPE_COMMAND_DEBUG
#define MSG_TYPE_COMMAND_DEBUG
Definition: newclient.h:531
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:262
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:300
autojail.who
who
Definition: autojail.py:3
cfapi_register_command
static void cfapi_register_command(int *type,...)
Definition: plugins.cpp:4515
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:284
object_find_by_name
object * object_find_by_name(const object *who, const char *name)
Definition: object.cpp:3956
cfapi_player_find
static void cfapi_player_find(int *type,...)
Definition: plugins.cpp:4007
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:267
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:535
hook_entry::func
f_plug_api func
Definition: plugin.h:309
cfapi_player_can_pay
static void cfapi_player_can_pay(int *type,...)
Definition: plugins.cpp:4090
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:37
cfapi_map_message
static void cfapi_map_message(int *type,...)
Definition: plugins.cpp:1347
get_weekday
const char * get_weekday(const int index)
Definition: time.cpp:120
cfapi_map_create_path
static void cfapi_map_create_path(int *type,...)
Definition: plugins.cpp:1100
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:3033
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:4399
object_present_in_ob_by_name
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Definition: object.cpp:3203
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:588
cfapi_object_remove_depletion
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.cpp:3138
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:282
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:28
CFAPI_MAP_PROP_MESSAGE
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:260
Face::number
uint16_t number
Definition: face.h:15
cfapi_system_re_cmp
static void cfapi_system_re_cmp(int *type,...)
Definition: plugins.cpp:802
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:4247
sword_of_souls.victim
victim
Definition: sword_of_souls.py:12
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:3738
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:2363
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:274
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:3549
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:281
make_face_from_files.str
str
Definition: make_face_from_files.py:30
change_map_light
int change_map_light(mapstruct *m, int change)
Definition: map.cpp:1994
NDI_DELAYED
#define NDI_DELAYED
Definition: newclient.h:272
get_periodofday
const char * get_periodofday(const int index)
Definition: time.cpp:106
readdir
struct dirent * readdir(DIR *)
query_short_name
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.cpp:513
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:1082
convert.action
action
Definition: convert.py:25
out_of_map
int out_of_map(mapstruct *m, int x, int y)
Definition: map.cpp:2293
region::jailmap
char * jailmap
Definition: map.h:285
find_string
sstring find_string(const char *str)
Definition: shstr.cpp:236
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:3207
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:318
CFAPI_ARCH_PROP_CLONE
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:269
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:159
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:248
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:3190
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:4302
cfapi_unregister_command
static void cfapi_unregister_command(int *type,...)
Definition: plugins.cpp:4550
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:2175
cfapi_object_teleport
static void cfapi_object_teleport(int *type,...)
Definition: plugins.cpp:4158
CFAPI_PLAYER_QUEST_START
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:241
CFAPI_REGION_PROP_NAME
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:276
cfapi_object_spring_trap
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.cpp:3590
archetype
Definition: object.h:483
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:285
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:281
cfapi_get_time
static void cfapi_get_time(int *type,...)
Definition: plugins.cpp:873
cfapi_object_pay_item
static void cfapi_object_pay_item(int *type,...)
Definition: plugins.cpp:3779
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:2321
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:1696
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:423
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:4177
CFAPI_SYSTEM_REGIONS
#define CFAPI_SYSTEM_REGIONS
Definition: plugin.h:288
cfapi_object_on_same_map
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.cpp:3574
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:2100
object_create_clone
object * object_create_clone(object *asrc)
Definition: object.cpp:3909
CFAPI_PARTY_PROP_NEXT
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:272
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:155
P_OUT_OF_MAP
#define P_OUT_OF_MAP
Definition: map.h:247
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:928
cfapi_system_check_path
static void cfapi_system_check_path(int *type,...)
Definition: plugins.cpp:779
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:250
object_set_cheat
void object_set_cheat(object *op)
Definition: object.cpp:3274
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:125
UP_OBJ_INSERT
#define UP_OBJ_INSERT
Definition: object.h:530
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.cpp:951
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:3168
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:1031
CFAPI_REGION_PROP_MESSAGE
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:280
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:246
cfapi_system_find_string
static void cfapi_system_find_string(int *type,...)
Definition: plugins.cpp:760
cfapi_system_remove_string
static void cfapi_system_remove_string(int *type,...)
Definition: plugins.cpp:742
region
Definition: map.h:272
CFAPI_MAP_PROP_DARKNESS
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:255
diamondslots.message
string message
Definition: diamondslots.py:57
CFAPI_MAP_PROP_PLAYERS
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:253
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:2676
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:1334
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:265
cfapi_map_get_map_property
static void cfapi_map_get_map_property(int *type,...)
Definition: plugins.cpp:1134
CFAPI_PARTY_PROP_PLAYER
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:274
CFAPI_PMAP
#define CFAPI_PMAP
Definition: plugin.h:59
all_regions
std::vector< region * > all_regions
Definition: init.cpp:108
CFAPI_PLAYER_QUEST_GET_STATE
#define CFAPI_PLAYER_QUEST_GET_STATE
Definition: plugin.h:242
CFAPI_MAP_PROP_DIFFICULTY
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:247
find_archetype_by_object_name
archetype * find_archetype_by_object_name(const char *name)
Definition: arch.cpp:53
transmute_materialname
void transmute_materialname(object *op, const object *change)
Definition: utils.cpp:263
cfapi_system_get_region_vector
static void cfapi_system_get_region_vector(int *type,...)
Definition: plugins.cpp:684
cfapi_object_describe
static void cfapi_object_describe(int *type,...)
Definition: plugins.cpp:3098
cfapi_object_give_skill
static void cfapi_object_give_skill(int *type,...)
Definition: plugins.cpp:3173
cfapi_generate_random_map
static void cfapi_generate_random_map(int *type,...)
Definition: plugins.cpp:4421
CFAPI_OBJECT_PROP_ANIMATION
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:218
object_find_by_arch_name
object * object_find_by_arch_name(const object *who, const char *name)
Definition: object.cpp:4252
CFAPI_OBJECT_PROP_INT
#define CFAPI_OBJECT_PROP_INT
Definition: plugin.h:201
CFAPI_OBJECT_PROP_SP
#define CFAPI_OBJECT_PROP_SP
Definition: plugin.h:207
cfapi_object_fix
static void cfapi_object_fix(int *type,...)
Definition: plugins.cpp:3157
party_get_password
const char * party_get_password(const partylist *party)
Definition: party.cpp:232
CFAPI_SYSTEM_FRIENDLY_LIST
#define CFAPI_SYSTEM_FRIENDLY_LIST
Definition: plugin.h:290
cleanupPlugins
void cleanupPlugins(void)
Definition: plugins.cpp:4618
object_can_pick
int object_can_pick(const object *who, const object *item)
Definition: object.cpp:3867
add_friendly_object
void add_friendly_object(object *op)
Definition: friend.cpp:32
CFAPI_PLAYER_QUEST_SET_STATE
#define CFAPI_PLAYER_QUEST_SET_STATE
Definition: plugin.h:243
CFAPI_OBJECT_PROP_NAME
#define CFAPI_OBJECT_PROP_NAME
Definition: plugin.h:130
CFAPI_OBJECT_PROP_EXP_MULTIPLIER
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER
Definition: plugin.h:180
get_map_flags
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Definition: map.cpp:300
is_magical
int is_magical(const object *op)
Definition: item.cpp:1227
CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
Definition: plugin.h:123
timers.h
P_NEED_UPDATE
#define P_NEED_UPDATE
Definition: map.h:237
mapstruct
Definition: map.h:313
CFAPI_OBJECT_PROP_HEAD
#define CFAPI_OBJECT_PROP_HEAD
Definition: plugin.h:126
CFAPI_PARCH
#define CFAPI_PARCH
Definition: plugin.h:62
create_pathname
char * create_pathname(const char *name, char *buf, size_t size)
Definition: map.cpp:104
check_spell_known
object * check_spell_known(object *op, const char *name)
Definition: spell_util.cpp:394
cfapi_object_change_exp
static void cfapi_object_change_exp(int *type,...)
Definition: plugins.cpp:4067
f_plug_event
int(* f_plug_event)(int *type,...)
Definition: events.h:69
sstring
const typedef char * sstring
Definition: sstring.h:2
give.op
op
Definition: give.py:33
Animations
Definition: face.h:25
autojail.value
value
Definition: autojail.py:6
board.author
author
Definition: board.py:59
pay_for_item
int pay_for_item(object *op, object *pl, uint64_t reduction)
Definition: shop.cpp:501
CFAPI_PLAYER_PROP_BED_MAP
#define CFAPI_PLAYER_PROP_BED_MAP
Definition: plugin.h:233
CFAPI_INT16
#define CFAPI_INT16
Definition: plugin.h:67
shop.h
object_split
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
Definition: object.cpp:2637
CFAPI_OBJECT_PROP_WC
#define CFAPI_OBJECT_PROP_WC
Definition: plugin.h:204
plugins_dlsym
#define plugins_dlsym(lib, name)
Definition: plugin.h:114
CFAPI_OBJECT_PROP_GLOW_RADIUS
#define CFAPI_OBJECT_PROP_GLOW_RADIUS
Definition: plugin.h:169
object_find_free_spot
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
Definition: object.cpp:3559
query_money
uint64_t query_money(const object *op)
Definition: shop.cpp:430
cfapi_object_find_by_arch_name
static void cfapi_object_find_by_arch_name(int *type,...)
Definition: plugins.cpp:3902
object_set_msg
void object_set_msg(object *op, const char *msg)
Definition: object.cpp:4811
esrv_update_item
void esrv_update_item(int flags, object *pl, object *op)
Definition: main.cpp:359
CFAPI_OBJECT_PROP_PATH_REPELLED
#define CFAPI_OBJECT_PROP_PATH_REPELLED
Definition: plugin.h:151
CFAPI_OBJECT_PROP_CON
#define CFAPI_OBJECT_PROP_CON
Definition: plugin.h:199
CFAPI_ARCHETYPE_VECTOR
#define CFAPI_ARCHETYPE_VECTOR
Definition: plugin.h:74
plug_hooks
static const hook_entry plug_hooks[]
Definition: plugins.cpp:154
diamondslots.y
y
Definition: diamondslots.py:16
on_same_map
int on_same_map(const object *op1, const object *op2)
Definition: map.cpp:2598
CFAPI_MAP_VECTOR
#define CFAPI_MAP_VECTOR
Definition: plugin.h:73
assets.h
CFAPI_STRING
#define CFAPI_STRING
Definition: plugin.h:57
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
can_pay
int can_pay(object *pl)
Definition: shop.cpp:841
LIBPTRTYPE
#define LIBPTRTYPE
Definition: plugin.h:88
CFAPI_OBJECT_PROP_GP
#define CFAPI_OBJECT_PROP_GP
Definition: plugin.h:208
CFAPI_OBJECT_PROP_MAGICAL
#define CFAPI_OBJECT_PROP_MAGICAL
Definition: plugin.h:188
CFAPI_OBJECT_PROP_LAST_SP
#define CFAPI_OBJECT_PROP_LAST_SP
Definition: plugin.h:159
cfapi_cost_string_from_value
static void cfapi_cost_string_from_value(int *type,...)
Definition: plugins.cpp:497
player_arrest
int player_arrest(object *who)
Definition: c_wiz.cpp:789
find_player_partial_name
player * find_player_partial_name(const char *plname)
Definition: player.cpp:114
CFAPI_OBJECT_PROP_MATERIAL
#define CFAPI_OBJECT_PROP_MATERIAL
Definition: plugin.h:153
cfapi_object_insert
static void cfapi_object_insert(int *type,...)
Definition: plugins.cpp:3326
CFAPI_OBJECT_PROP_DURATION
#define CFAPI_OBJECT_PROP_DURATION
Definition: plugin.h:227
CFAPI_OBJECT_PROP_MOVE_STATUS
#define CFAPI_OBJECT_PROP_MOVE_STATUS
Definition: plugin.h:177
crossfire_plugin
Definition: plugin.h:95
cfapi_map_update_position
static void cfapi_map_update_position(int *type,...)
Definition: plugins.cpp:1318
CFAPI_OBJECT_PROP_OTHER_ARCH
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:182
cfapi_get_periodofday_name
static void cfapi_get_periodofday_name(int *type,...)
Definition: plugins.cpp:940
level
int level
Definition: readable.cpp:1563
CFAPI_OBJECT_PROP_OB_ABOVE
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:120
knowledge_player_knows
int knowledge_player_knows(const player *pl, const char *knowledge)
Definition: knowledge.cpp:1298
object_distance
int object_distance(const object *ob1, const object *ob2)
Definition: object.cpp:3661
CFAPI_MAP_PROP_ENTER_Y
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:259
string_get_int
#define string_get_int(name)
Definition: plugins.cpp:885
quest_start
void quest_start(player *pl, sstring quest_code, int state)
Definition: quest.cpp:680
CFAPI_OBJECT_PROP_LAST_HEAL
#define CFAPI_OBJECT_PROP_LAST_HEAL
Definition: plugin.h:158
cfapi_player_message
static void cfapi_player_message(int *type,...)
Definition: plugins.cpp:4022
CFAPI_OBJECT_PROP_MOVE_ALLOW
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:222
knowledge_give
void knowledge_give(player *pl, const char *marker, const object *book)
Definition: knowledge.cpp:996
get_region_by_map
region * get_region_by_map(mapstruct *m)
Definition: region.cpp:72
CFAPI_ARCH_PROP_MORE
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:268
draw_ext_info
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.cpp:308
cfapi_system_add_string
static void cfapi_system_add_string(int *type,...)
Definition: plugins.cpp:722
command_function_extra
void(* command_function_extra)(object *op, const char *params, const char *extra)
Definition: commands.h:29
command_register
command_registration command_register(const char *name, uint8_t type, command_function func, float time)
Definition: commands.cpp:102
CFAPI_SYSTEM_PARTIES
#define CFAPI_SYSTEM_PARTIES
Definition: plugin.h:289
cfapi_log
static void cfapi_log(int *type,...)
Definition: plugins.cpp:1007
object_remove
void object_remove(object *op)
Definition: object.cpp:1833
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:270
CFAPI_OBJECT_PROP_MOVE_SLOW
#define CFAPI_OBJECT_PROP_MOVE_SLOW
Definition: plugin.h:225
CFAPI_OBJECT_PROP_MERGEABLE
#define CFAPI_OBJECT_PROP_MERGEABLE
Definition: plugin.h:194
object_sum_weight
signed long object_sum_weight(object *op)
Definition: object.cpp:568
try_find_face
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:286
do_forget_spell
void do_forget_spell(object *op, const char *spell)
Definition: apply.cpp:525
command_registration
uint64_t command_registration
Definition: commands.h:32
cfapi_object_set_key
static void cfapi_object_set_key(int *type,...)
Definition: plugins.cpp:1528
remove_depletion
int remove_depletion(object *op, int level)
Definition: living.cpp:755
cfapi_object_pay_amount
static void cfapi_object_pay_amount(int *type,...)
Definition: plugins.cpp:3758
get_month_name
const char * get_month_name(const int index)
Definition: time.cpp:113
CFAPI_OBJECT_PROP_MAGIC
#define CFAPI_OBJECT_PROP_MAGIC
Definition: plugin.h:155
CFAPI_OBJECT_PROP_FLAGS
#define CFAPI_OBJECT_PROP_FLAGS
Definition: plugin.h:196
CFAPI_OBJECT_PROP_LUCK
#define CFAPI_OBJECT_PROP_LUCK
Definition: plugin.h:189
CFAPI_MAP_PROP_HEIGHT
#define CFAPI_MAP_PROP_HEIGHT
Definition: plugin.h:257
object_teleport
int object_teleport(object *op, mapstruct *map, int x, int y)
Definition: move.cpp:597
cfapi_system_find_animation
static void cfapi_system_find_animation(int *type,...)
Definition: plugins.cpp:527
update_all_los
void update_all_los(const mapstruct *map, int x, int y)
Definition: los.cpp:595
UPD_ALL
#define UPD_ALL
Definition: newclient.h:325
command_register_extra
command_registration command_register_extra(const char *name, const char *extra, uint8_t type, command_function_extra func, float time)
Definition: commands.cpp:526
calculate_difficulty
int calculate_difficulty(mapstruct *m)
Definition: map.cpp:1896
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2606
cfapi_object_apply
static void cfapi_object_apply(int *type,...)
Definition: plugins.cpp:3053
CFAPI_OBJECT_PROP_VALUE
#define CFAPI_OBJECT_PROP_VALUE
Definition: plugin.h:156
report.error
def error(pl)
Definition: report.py:43
query_base_name
void query_base_name(const object *op, int plural, char *buf, size_t size)
Definition: item.cpp:689
CFAPI_OBJECT_PROP_MESSAGE
#define CFAPI_OBJECT_PROP_MESSAGE
Definition: plugin.h:136
cfapi_object_perm_exp
static void cfapi_object_perm_exp(int *type,...)
Definition: plugins.cpp:4048
CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
Definition: plugin.h:226
LogLevel
LogLevel
Definition: logger.h:10
object_set_value
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.cpp:4499
diamondslots.cost
int cost
Definition: diamondslots.py:21
CFAPI_OBJECT_PROP_MAXGP
#define CFAPI_OBJECT_PROP_MAXGP
Definition: plugin.h:212
CFAPI_OBJECT_PROP_COUNT
#define CFAPI_OBJECT_PROP_COUNT
Definition: plugin.h:129
CFAPI_OBJECT_PROP_SUBTYPE
#define CFAPI_OBJECT_PROP_SUBTYPE
Definition: plugin.h:146
Settings::tmpdir
const char * tmpdir
Definition: global.h:255
cfapi_player_knowledge
static void cfapi_player_knowledge(int *type,...)
Definition: plugins.cpp:4109
freearr_x
short freearr_x[SIZEOFFREE]
Definition: object.cpp:299
CFAPI_PLAYER_QUEST_WAS_COMPLETED
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED
Definition: plugin.h:244
svnversion.h
command_function
void(* command_function)(object *op, const char *params)
Definition: commands.h:17
plugins_dlclose
#define plugins_dlclose(lib)
Definition: plugin.h:113
CFAPI_LONG
#define CFAPI_LONG
Definition: plugin.h:55
cfapi_map_get_object_at
static void cfapi_map_get_object_at(int *type,...)
Definition: plugins.cpp:1369
plugins_init_plugin
int plugins_init_plugin(const char *libfile)
Definition: plugins.cpp:373
closedir
int closedir(DIR *)
cfapi_object_cast
static void cfapi_object_cast(int *type,...)
Definition: plugins.cpp:3675
dragon.state
state
Definition: dragon.py:84
pay_for_amount
int pay_for_amount(uint64_t to_pay, object *pl)
Definition: shop.cpp:461
pick_up
void pick_up(object *op, object *alt)
Definition: c_object.cpp:519
object_get_player_container
object * object_get_player_container(object *op)
Definition: object.cpp:607
altar_valkyrie.pl
pl
Definition: altar_valkyrie.py:28
re_cmp
const char * re_cmp(const char *, const char *)
Definition: re-cmp.cpp:68
CFAPI_OBJECT_PROP_FP
#define CFAPI_OBJECT_PROP_FP
Definition: plugin.h:209
cfapi_object_query_money
static void cfapi_object_query_money(int *type,...)
Definition: plugins.cpp:3656
CUSTOM_NAME_FIELD
#define CUSTOM_NAME_FIELD
Definition: object.h:98
find_marked_object
object * find_marked_object(object *op)
Definition: c_object.cpp:1520
free_dialog_information
void free_dialog_information(object *op)
Definition: dialog.cpp:32
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:670
check_path
int check_path(const char *name, int prepend_dir)
Definition: map.cpp:201
CFAPI_PARTY_PROP_PASSWORD
#define CFAPI_PARTY_PROP_PASSWORD
Definition: plugin.h:273
CFAPI_OBJECT_PROP_LAST_GRACE
#define CFAPI_OBJECT_PROP_LAST_GRACE
Definition: plugin.h:160
altar_valkyrie.res
int res
Definition: altar_valkyrie.py:74
cfapi_get_season_name
static void cfapi_get_season_name(int *type,...)
Definition: plugins.cpp:904
CFAPI_MOVETYPE
#define CFAPI_MOVETYPE
Definition: plugin.h:71
f_plug_property
void *(* f_plug_property)(int *type,...)
Definition: plugin.h:85
cfapi_object_merge
static void cfapi_object_merge(int *type,...)
Definition: plugins.cpp:3467
CFAPI_PLAYER_PROP_NEXT
#define CFAPI_PLAYER_PROP_NEXT
Definition: plugin.h:236
CFAPI_OBJECT_PROP_DIRECTION
#define CFAPI_OBJECT_PROP_DIRECTION
Definition: plugin.h:143
cfapi_object_clone
static void cfapi_object_clone(int *type,...)
Definition: plugins.cpp:3255
CFAPI_OBJECT_PROP_SHORT_NAME
#define CFAPI_OBJECT_PROP_SHORT_NAME
Definition: plugin.h:186
cfapi_object_learn_spell
static void cfapi_object_learn_spell(int *type,...)
Definition: plugins.cpp:3703
object_can_merge
int object_can_merge(object *ob1, object *ob2)
Definition: object.cpp:433
llevDebug
@ llevDebug
Definition: logger.h:13
CFAPI_OBJECT_PROP_MATERIAL_NAME
#define CFAPI_OBJECT_PROP_MATERIAL_NAME
Definition: plugin.h:154
region::jaily
int16_t jaily
Definition: map.h:286
cfapi_map_trigger_connected
static void cfapi_map_trigger_connected(int *type,...)
Definition: plugins.cpp:3636
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
cfapi_object_find_by_name
static void cfapi_object_find_by_name(int *type,...)
Definition: plugins.cpp:3918
region::jailx
int16_t jailx
Definition: map.h:286
cfapi_object_set_property
static void cfapi_object_set_property(int *type,...)
Definition: plugins.cpp:2380
plugins_dlopen
#define plugins_dlopen(fname)
Definition: plugin.h:112
cost_string_from_value
char * cost_string_from_value(uint64_t cost, int largest_coin)
Definition: shop.cpp:277
CFAPI_OBJECT_PROP_WEIGHT_LIMIT
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:167
give.name
name
Definition: give.py:27
trigger_connected
void trigger_connected(objectlink *ol, object *cause, const int state)
Definition: button.cpp:41
Settings::uniquedir
const char * uniquedir
Definition: global.h:253
CFAPI_OBJECT_PROP_SPEED_LEFT
#define CFAPI_OBJECT_PROP_SPEED_LEFT
Definition: plugin.h:141
quest_get_player_state
int quest_get_player_state(player *pl, sstring quest_code)
Definition: quest.cpp:660
cfapi_map_find_by_archetype_name
static void cfapi_map_find_by_archetype_name(int *type,...)
Definition: plugins.cpp:1398
cftimer_create
int cftimer_create(int id, long delay, object *ob, int mode)
Definition: timers.cpp:97
player_get_title
void player_get_title(const player *pl, char *buf, size_t bufsize)
Definition: player.cpp:232
cfapi_object_check_trigger
static void cfapi_object_check_trigger(int *type,...)
Definition: plugins.cpp:3609
cfapi_object_clear
static void cfapi_object_clear(int *type,...)
Definition: plugins.cpp:3531
identify
object * identify(object *op)
Definition: item.cpp:1421
level
Definition: level.py:1
diamondslots.id
id
Definition: diamondslots.py:53
Settings::localdir
const char * localdir
Definition: global.h:249