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) {
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 
2234  case CFAPI_PLAYER_PROP_IP:
2235  rsstring = va_arg(args, sstring *);
2236  *rsstring = op->contr->socket->host;
2237  *type = CFAPI_SSTRING;
2238  break;
2239 
2241  robject = va_arg(args, object **);
2242  *robject = find_marked_object(op);
2243  *type = CFAPI_POBJECT;
2244  break;
2245 
2247  rparty = va_arg(args, partylist **);
2248  *rparty = (op->contr ? op->contr->party : NULL);
2249  *type = CFAPI_PPARTY;
2250  break;
2251 
2253  robject = va_arg(args, object **);
2254  if (op)
2255  *robject = op->contr->next ? op->contr->next->ob : NULL;
2256  else
2257  /* This can be called when there is no player. */
2258  *robject = first_player ? first_player->ob : NULL;
2259  *type = CFAPI_POBJECT;
2260  break;
2261 
2263  rbuffer = va_arg(args, char *);
2264  rbufsize = va_arg(args, int);
2265  player_get_title(op->contr, rbuffer, rbufsize);
2266  *type = CFAPI_STRING;
2267  break;
2268 
2270  robject = va_arg(args, object **);
2271  *robject = op->contr->transport;
2272  *type = CFAPI_POBJECT;
2273  break;
2274 
2276  rmove = va_arg(args, MoveType *);
2277  *rmove = op->move_type;
2278  *type = CFAPI_MOVETYPE;
2279  break;
2280 
2282  rmove = va_arg(args, MoveType *);
2283  *rmove = op->move_block;
2284  *type = CFAPI_MOVETYPE;
2285  break;
2286 
2288  rmove = va_arg(args, MoveType *);
2289  *rmove = op->move_allow;
2290  *type = CFAPI_MOVETYPE;
2291  break;
2292 
2294  rmove = va_arg(args, MoveType *);
2295  *rmove = op->move_on;
2296  *type = CFAPI_MOVETYPE;
2297  break;
2298 
2300  rmove = va_arg(args, MoveType *);
2301  *rmove = op->move_off;
2302  *type = CFAPI_MOVETYPE;
2303  break;
2304 
2306  rmove = va_arg(args, MoveType *);
2307  *rmove = op->move_type;
2308  *type = CFAPI_MOVETYPE;
2309  break;
2310 
2312  rfloat = va_arg(args, float *);
2313  *rfloat = op->move_slow_penalty;
2314  *type = CFAPI_FLOAT;
2315  break;
2316 
2318  rbuffer = va_arg(args, char *);
2319  rbufsize = va_arg(args, int);
2320  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2321  *type = CFAPI_STRING;
2322  break;
2323 
2325  rint = va_arg(args, int *);
2326  *rint = op->contr->bed_x;
2327  *type = CFAPI_INT;
2328  break;
2329 
2331  rint = va_arg(args, int *);
2332  *rint = op->contr->bed_y;
2333  *type = CFAPI_INT;
2334  break;
2335 
2337  rint = va_arg(args, int *);
2338  *rint = op->duration;
2339  *type = CFAPI_INT;
2340  break;
2341 
2342  default:
2343  *type = CFAPI_NONE;
2344  break;
2345  }
2346  va_end(args);
2347 }
2348 
2357 static void copy_message(object *op, const char *msg) {
2358  /* need to reset parsed dialog information */
2360  if (strlen(msg) == 0) {
2361  msg = NULL;
2362  }
2363  object_set_msg(op, msg);
2364 }
2365 
2374 static void cfapi_object_set_property(int *type, ...) {
2375  va_list args;
2376  int iarg, *ret;
2377  long larg;
2378  char *sarg;
2379  double darg;
2380  object *oparg;
2381  object *op;
2382  int property;
2383  int64_t s64arg;
2384  partylist *partyarg;
2385  float farg;
2386  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2387 
2388  va_start(args, type);
2389  op = va_arg(args, object *);
2390  property = va_arg(args, int);
2391  *type = CFAPI_NONE;
2392 
2393  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2394  switch (property) {
2396  sarg = va_arg(args, char *);
2397  *type = CFAPI_STRING;
2398  FREE_AND_COPY(op->name, sarg);
2400  break;
2401 
2403  sarg = va_arg(args, char *);
2404  *type = CFAPI_STRING;
2405  FREE_AND_COPY(op->name_pl, sarg);
2407  break;
2408 
2410  sarg = va_arg(args, char *);
2411  *type = CFAPI_STRING;
2412  FREE_AND_COPY(op->title, sarg);
2413  break;
2414 
2416  sarg = va_arg(args, char *);
2417  *type = CFAPI_STRING;
2418  FREE_AND_COPY(op->race, sarg);
2419  break;
2420 
2422  sarg = va_arg(args, char *);
2423  *type = CFAPI_STRING;
2424  FREE_AND_COPY(op->slaying, sarg);
2425  break;
2426 
2428  sarg = va_arg(args, char *);
2429  *type = CFAPI_STRING;
2430  FREE_AND_COPY(op->skill, sarg);
2431  break;
2432 
2434  sarg = va_arg(args, char *);
2435  *type = CFAPI_STRING;
2436  copy_message(op, sarg);
2437  break;
2438 
2440  sarg = va_arg(args, char *);
2441  *type = CFAPI_STRING;
2442  FREE_AND_COPY(op->lore, sarg);
2443  break;
2444 
2446  farg = va_arg(args, double);
2447  *type = CFAPI_FLOAT;
2448  if (farg != op->speed) {
2449  op->speed = farg;
2451  }
2452  break;
2453 
2455  farg = va_arg(args, double);
2456  *type = CFAPI_FLOAT;
2457  op->speed_left = farg;
2458  break;
2459 
2461  iarg = va_arg(args, int);
2462  *type = CFAPI_INT;
2463  if (iarg < 0)
2464  iarg = 0;
2465  if (op->nrof > (uint32_t)iarg)
2466  object_decrease_nrof(op, op->nrof-iarg);
2467  else if (op->nrof < (uint32_t)iarg) {
2468  object *tmp;
2469  player *pl;
2470 
2471  op->nrof = iarg;
2472  if (op->env != NULL) {
2474  if (!tmp) {
2475  for (pl = first_player; pl; pl = pl->next)
2476  if (pl->ob->container == op->env)
2477  break;
2478  if (pl)
2479  tmp = pl->ob;
2480  else
2481  tmp = NULL;
2482  } else {
2484  fix_object(tmp);
2485  }
2486  if (tmp)
2488  } else {
2490  if (tmp->type == PLAYER)
2491  tmp->contr->socket->update_look = 1;
2492  FOR_ABOVE_FINISH();
2493  }
2494  }
2495  break;
2496 
2498  iarg = va_arg(args, int);
2499  *type = CFAPI_INT;
2500  op->direction = iarg;
2501  break;
2502 
2504  iarg = va_arg(args, int);
2505  *type = CFAPI_INT;
2506  op->facing = iarg;
2507  break;
2508 
2509  case CFAPI_OBJECT_PROP_RESIST: {
2510  int iargbis = va_arg(args, int);
2511 
2512  *type = CFAPI_INT16;
2513  iarg = va_arg(args, int);
2514  op->resist[iargbis] = iarg;
2515  }
2516  break;
2517 
2519  iarg = va_arg(args, int);
2520  *type = CFAPI_INT;
2521  op->attacktype = iarg;
2522  break;
2523 
2525  iarg = va_arg(args, int);
2526  *type = CFAPI_INT;
2527  op->path_attuned = iarg;
2528  break;
2529 
2531  iarg = va_arg(args, int);
2532  *type = CFAPI_INT;
2533  op->path_repelled = iarg;
2534  break;
2535 
2537  iarg = va_arg(args, int);
2538  *type = CFAPI_INT;
2539  op->path_denied = iarg;
2540  break;
2541 
2543  iarg = va_arg(args, int);
2544  *type = CFAPI_INT;
2545  op->material = iarg;
2546  break;
2547 
2549  break;
2550 
2552  iarg = va_arg(args, int);
2553  *type = CFAPI_INT;
2554  op->magic = iarg;
2555  break;
2556 
2558  larg = va_arg(args, long);
2559  *type = CFAPI_LONG;
2560  op->value = larg;
2561  break;
2562 
2564  iarg = va_arg(args, int);
2565  *type = CFAPI_INT;
2566  op->level = iarg;
2568  break;
2569 
2571  iarg = va_arg(args, int);
2572  *type = CFAPI_INT;
2573  op->last_heal = iarg;
2574  break;
2575 
2577  iarg = va_arg(args, int);
2578  *type = CFAPI_INT;
2579  op->last_sp = iarg;
2580  break;
2581 
2583  iarg = va_arg(args, int);
2584  *type = CFAPI_INT;
2585  op->last_grace = iarg;
2586  break;
2587 
2589  iarg = va_arg(args, int);
2590  *type = CFAPI_INT;
2591  op->last_eat = iarg;
2592  break;
2593 
2595  iarg = va_arg(args, int);
2596  *type = CFAPI_INT;
2597  op->invisible = iarg;
2598  break;
2599 
2601  iarg = va_arg(args, int);
2602  *type = CFAPI_INT;
2603  op->pick_up = iarg;
2604  break;
2605 
2607  iarg = va_arg(args, int);
2608  *type = CFAPI_INT;
2609  op->item_power = iarg;
2610  break;
2611 
2613  iarg = va_arg(args, int);
2614  *type = CFAPI_INT;
2615  op->gen_sp_armour = iarg;
2616  break;
2617 
2619  iarg = va_arg(args, int);
2620  *type = CFAPI_INT;
2621  if (op->weight != iarg) {
2622  object *tmp;
2623  player *pl;
2624 
2625  op->weight = iarg;
2626  if (op->env != NULL) {
2628  if (!tmp) {
2629  for (pl = first_player; pl; pl = pl->next)
2630  if (pl->ob->container == op->env)
2631  break;
2632  if (pl)
2633  tmp = pl->ob;
2634  else
2635  tmp = NULL;
2636  } else {
2638  fix_object(tmp);
2639  }
2640  if (tmp)
2642  } else {
2644  if (tmp->type == PLAYER)
2646  FOR_ABOVE_FINISH();
2647  }
2648  }
2649  break;
2650 
2652  iarg = va_arg(args, int);
2653  *type = CFAPI_INT;
2654  op->weight_limit = iarg;
2655  break;
2656 
2658  iarg = va_arg(args, int);
2659  *type = CFAPI_INT;
2660  if (op->glow_radius != iarg) {
2661  object *tmp;
2662 
2663  op->glow_radius = iarg;
2665  if (tmp->map != NULL) {
2666  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2667  update_position(tmp->map, tmp->x, tmp->y);
2668  update_all_los(tmp->map, tmp->x, tmp->y);
2669  }
2670  }
2671  break;
2672 
2674  s64arg = va_arg(args, int64_t);
2675  *type = CFAPI_SINT64;
2676  op->total_exp = s64arg;
2677  break;
2678 
2680  oparg = va_arg(args, object *);
2681  *type = CFAPI_POBJECT;
2682  object_set_enemy(op, oparg);
2683  break;
2684 
2686  iarg = va_arg(args, int);
2687  *type = CFAPI_INT;
2688  op->run_away = iarg;
2689  break;
2690 
2692  oparg = va_arg(args, object *);
2693  *type = CFAPI_POBJECT;
2694  op->chosen_skill = oparg;
2695  break;
2696 
2698  iarg = va_arg(args, int);
2699  *type = CFAPI_INT;
2700  op->hide = iarg;
2701  break;
2702 
2704  iarg = va_arg(args, int);
2705  *type = CFAPI_INT;
2706  op->move_status = iarg;
2707  break;
2708 
2710  iarg = va_arg(args, int);
2711  *type = CFAPI_INT;
2712  op->attack_movement = iarg;
2713  break;
2714 
2716  oparg = va_arg(args, object *);
2717  *type = CFAPI_POBJECT;
2718  op->spellitem = oparg;
2719  break;
2720 
2722  darg = va_arg(args, double);
2723  *type = CFAPI_DOUBLE;
2724  op->expmul = darg;
2725  break;
2726 
2728  sarg = va_arg(args, char *);
2729  *type = CFAPI_STRING;
2732  break;
2733 
2735  iarg = va_arg(args, int);
2736  *type = CFAPI_INT;
2737  op->anim_speed = iarg;
2738  break;
2739 
2741  iarg = va_arg(args, int);
2742  *type = CFAPI_INT;
2743  if (iarg == 1 && is_friendly(op) == 0)
2745  else if (iarg == 0 && is_friendly(op) == 1)
2747  break;
2748 
2750  iarg = va_arg(args, int);
2751  *type = CFAPI_INT;
2752  op->stats.luck = iarg;
2753  break;
2754 
2755  case CFAPI_OBJECT_PROP_EXP:
2756  s64arg = va_arg(args, int64_t);
2757  *type = CFAPI_SINT64;
2758  op->stats.exp = s64arg;
2759  break;
2760 
2762  oparg = va_arg(args, object *);
2763  *type = CFAPI_POBJECT;
2764  object_set_owner(op, oparg);
2765  break;
2766 
2769  *type = CFAPI_NONE;
2770  break;
2771 
2772  case CFAPI_OBJECT_PROP_FLAGS: {
2773  int iargbis;
2774 
2775  iarg = va_arg(args, int);
2776  iargbis = va_arg(args, int);
2777  *type = CFAPI_INT;
2778 
2779  if (iargbis == 1)
2780  SET_FLAG(op, iarg);
2781  else
2782  CLEAR_FLAG(op, iarg);
2783  }
2784  break;
2785 
2786  case CFAPI_OBJECT_PROP_STR:
2787  iarg = va_arg(args, int);
2788  *type = CFAPI_INT;
2789  op->stats.Str = iarg;
2790  break;
2791 
2792  case CFAPI_OBJECT_PROP_DEX:
2793  iarg = va_arg(args, int);
2794  *type = CFAPI_INT;
2795  op->stats.Dex = iarg;
2796  break;
2797 
2798  case CFAPI_OBJECT_PROP_CON:
2799  iarg = va_arg(args, int);
2800  *type = CFAPI_INT;
2801  op->stats.Con = iarg;
2802  break;
2803 
2804  case CFAPI_OBJECT_PROP_WIS:
2805  iarg = va_arg(args, int);
2806  *type = CFAPI_INT;
2807  op->stats.Wis = iarg;
2808  break;
2809 
2810  case CFAPI_OBJECT_PROP_INT:
2811  iarg = va_arg(args, int);
2812  *type = CFAPI_INT;
2813  op->stats.Int = iarg;
2814  break;
2815 
2816  case CFAPI_OBJECT_PROP_POW:
2817  iarg = va_arg(args, int);
2818  *type = CFAPI_INT;
2819  op->stats.Pow = iarg;
2820  break;
2821 
2822  case CFAPI_OBJECT_PROP_CHA:
2823  iarg = va_arg(args, int);
2824  *type = CFAPI_INT;
2825  op->stats.Cha = iarg;
2826  break;
2827 
2828  case CFAPI_OBJECT_PROP_WC:
2829  iarg = va_arg(args, int);
2830  *type = CFAPI_INT;
2831  op->stats.wc = iarg;
2832  break;
2833 
2834  case CFAPI_OBJECT_PROP_AC:
2835  iarg = va_arg(args, int);
2836  *type = CFAPI_INT;
2837  op->stats.ac = iarg;
2838  break;
2839 
2840  case CFAPI_OBJECT_PROP_HP:
2841  iarg = va_arg(args, int);
2842  *type = CFAPI_INT;
2843  op->stats.hp = iarg;
2844  break;
2845 
2846  case CFAPI_OBJECT_PROP_SP:
2847  iarg = va_arg(args, int);
2848  *type = CFAPI_INT;
2849  op->stats.sp = iarg;
2850  break;
2851 
2852  case CFAPI_OBJECT_PROP_GP:
2853  iarg = va_arg(args, int);
2854  *type = CFAPI_INT;
2855  op->stats.grace = iarg;
2856  break;
2857 
2858  case CFAPI_OBJECT_PROP_FP:
2859  iarg = va_arg(args, int);
2860  *type = CFAPI_INT;
2861  op->stats.food = iarg;
2862  break;
2863 
2865  iarg = va_arg(args, int);
2866  *type = CFAPI_INT;
2867  op->stats.maxhp = iarg;
2868  break;
2869 
2871  iarg = va_arg(args, int);
2872  *type = CFAPI_INT;
2873  op->stats.maxsp = iarg;
2874  break;
2875 
2877  iarg = va_arg(args, int);
2878  *type = CFAPI_INT;
2879  op->stats.maxgrace = iarg;
2880  break;
2881 
2882  case CFAPI_OBJECT_PROP_DAM:
2883  iarg = va_arg(args, int);
2884  *type = CFAPI_INT;
2885  op->stats.dam = iarg;
2886  break;
2887 
2888  case CFAPI_OBJECT_PROP_FACE: {
2889  const Face *face;
2890  sarg = va_arg(args, char *);
2891  ret = va_arg(args, int *);
2892  *type = CFAPI_INT;
2893  face = try_find_face(sarg, 0);
2894  if (face != NULL) {
2895  op->face = face;
2896  op->state = 0;
2898  (*ret) = face->number;
2899  } else
2900  (*ret) = 0;
2901  break;
2902  }
2903 
2905  const Animations *anim;
2906  sarg = va_arg(args, char *);
2907  ret = va_arg(args, int *);
2908  *type = CFAPI_INT;
2909  anim = try_find_animation(sarg);
2910  if (anim != NULL) {
2911  op->animation = anim;
2912  SET_ANIMATION(op, 0);
2914  (*ret) = anim->num;
2915  } else {
2916  (*ret) = 0;
2917  }
2918  break;
2919  }
2920 
2922  iarg = va_arg(args, int);
2923  *type = CFAPI_INT;
2924  op->duration = iarg;
2925  break;
2926 
2928  if (op->contr) {
2929  oparg = va_arg(args, object *);
2930  *type = CFAPI_POBJECT;
2931  op->contr->mark = oparg;
2932  if (oparg) {
2933  op->contr->mark_count = oparg->count;
2934  } else {
2935  op->contr->mark_count = 0;
2936  }
2937  }
2938  break;
2939 
2941  if (op->contr) {
2942  partyarg = va_arg(args, partylist *);
2943  *type = CFAPI_PPARTY;
2944  party_join(op, partyarg);
2945  }
2946  break;
2947 
2949  sarg = va_arg(args, char *);
2950  *type = CFAPI_STRING;
2951  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
2952  break;
2953 
2955  iarg = va_arg(args, int);
2956  *type = CFAPI_INT;
2957  op->contr->bed_x = iarg;
2958  break;
2959 
2961  iarg = va_arg(args, int);
2962  *type = CFAPI_INT;
2963  op->contr->bed_y = iarg;
2964  break;
2965 
2967  sarg = va_arg(args, char *);
2968  *type = CFAPI_STRING;
2969  player_set_own_title(op->contr, sarg);
2970  break;
2971 
2973  move = va_arg(args, MoveType *);
2974  op->move_type = *move & MOVE_ALL;
2976  *type = CFAPI_MOVETYPE;
2977  break;
2978 
2980  move = va_arg(args, MoveType *);
2981  op->move_block = *move & MOVE_ALL;
2983  *type = CFAPI_MOVETYPE;
2984  break;
2985 
2987  move = va_arg(args, MoveType *);
2988  op->move_allow = *move & MOVE_ALL;
2990  *type = CFAPI_MOVETYPE;
2991  break;
2992 
2994  move = va_arg(args, MoveType *);
2995  op->move_on = *move & MOVE_ALL;
2997  *type = CFAPI_MOVETYPE;
2998  break;
2999 
3001  move = va_arg(args, MoveType *);
3002  op->move_off = *move & MOVE_ALL;
3004  *type = CFAPI_MOVETYPE;
3005  break;
3006 
3008  move = va_arg(args, MoveType *);
3009  op->move_type = *move & MOVE_ALL;
3011  *type = CFAPI_MOVETYPE;
3012  break;
3013 
3014  default:
3015  break;
3016  }
3017  }
3018  va_end(args);
3019 }
3020 
3027 static void cfapi_object_apply_below(int *type, ...) {
3028  va_list args;
3029  object *applier;
3030 
3031  va_start(args, type);
3032 
3033  applier = va_arg(args, object *);
3034 
3035  va_end(args);
3036 
3037  apply_by_living_below(applier);
3038  *type = CFAPI_NONE;
3039 }
3040 
3047 static void cfapi_object_apply(int *type, ...) {
3048  va_list args;
3049  object *applied;
3050  object *applier;
3051  int aflags;
3052  int *ret;
3053 
3054  va_start(args, type);
3055 
3056  applier = va_arg(args, object *);
3057  applied = va_arg(args, object *);
3058  aflags = va_arg(args, int);
3059  ret = va_arg(args, int *);
3060 
3061  va_end(args);
3062 
3063  *type = CFAPI_INT;
3064  *ret = apply_manual(applier, applied, aflags);
3065 }
3066 
3072 static void cfapi_object_identify(int *type, ...) {
3073  va_list args;
3074  object *op, **result;
3075 
3076  va_start(args, type);
3077 
3078  op = va_arg(args, object *);
3079  result = va_arg(args, object **);
3080 
3081  va_end(args);
3082 
3083  (*result) = identify(op);
3084  *type = CFAPI_POBJECT;
3085 }
3086 
3092 static void cfapi_object_describe(int *type, ...) {
3093  va_list args;
3094  object *op;
3095  object *owner;
3096  char *desc, *final;
3097  int size;
3098 
3099  va_start(args, type);
3100 
3101  op = va_arg(args, object *);
3102  owner = va_arg(args, object *);
3103  desc = va_arg(args, char *);
3104  size = va_arg(args, int);
3105  va_end(args);
3106 
3107  *type = CFAPI_STRING;
3108  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3109  strncpy(desc, final, size);
3110  desc[size - 1] = '\0';
3111  free(final);
3112 }
3113 
3114 static void cfapi_object_drain(int *type, ...) {
3115  va_list args;
3116 
3117  object *op;
3118  int ds;
3119 
3120  va_start(args, type);
3121 
3122  op = va_arg(args, object *);
3123  ds = va_arg(args, int);
3124 
3125  va_end(args);
3126 
3127  drain_specific_stat(op, ds);
3128 
3129  *type = CFAPI_NONE;
3130 }
3131 
3132 static void cfapi_object_remove_depletion(int *type, ...) {
3133  va_list args;
3134 
3135  object *op;
3136  int level, *result;
3137 
3138  va_start(args, type);
3139 
3140  op = va_arg(args, object *);
3141  level = va_arg(args, int);
3142  result = va_arg(args, int*);
3143 
3144  va_end(args);
3145 
3147 
3148  *type = CFAPI_INT;
3149 }
3150 
3151 static void cfapi_object_fix(int *type, ...) {
3152  va_list args;
3153  object *op;
3154 
3155  va_start(args, type);
3156 
3157  op = va_arg(args, object *);
3158 
3159  va_end(args);
3160 
3161  fix_object(op);
3162 
3163  *type = CFAPI_NONE;
3164 }
3165 
3167 static void cfapi_object_give_skill(int *type, ...) {
3168  va_list args;
3169 
3170  object *op;
3171  char *skillname;
3172 
3173  va_start(args, type);
3174 
3175  op = va_arg(args, object *);
3176  skillname = va_arg(args, char *);
3177 
3178  va_end(args);
3179 
3180  *type = CFAPI_POBJECT;
3181  give_skill_by_name(op, skillname);
3182 }
3183 
3184 static void cfapi_object_transmute(int *type, ...) {
3185  va_list args;
3186 
3187  object *op;
3188  object *chg;
3189 
3190  va_start(args, type);
3191 
3192  op = va_arg(args, object *);
3193  chg = va_arg(args, object *);
3194 
3195  va_end(args);
3196 
3197  transmute_materialname(op, chg);
3198  *type = CFAPI_NONE;
3199 }
3200 
3201 static void cfapi_object_remove(int *type, ...) {
3202  va_list args;
3203  object *op;
3204 
3205  va_start(args, type);
3206 
3207  op = va_arg(args, object *);
3208 
3209  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3210  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3211  va_end(args);
3212  *type = CFAPI_NONE;
3213  return;
3214  }
3215 
3216  va_end(args);
3217 
3218  object_remove(op);
3219  *type = CFAPI_NONE;
3220 }
3221 
3222 static void cfapi_object_delete(int *type, ...) {
3223  va_list args;
3224  object *op;
3225 
3226  va_start(args, type);
3227 
3228  op = va_arg(args, object *);
3229 
3231  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3232  *type = CFAPI_NONE;
3233  va_end(args);
3234  return;
3235  }
3236 
3237  va_end(args);
3238 
3240 
3241  *type = CFAPI_NONE;
3242 }
3243 
3249 static void cfapi_object_clone(int *type, ...) {
3250  va_list args;
3251  object *op;
3252  int kind;
3253  object **robj;
3254 
3255  va_start(args, type);
3256 
3257  op = va_arg(args, object *);
3258  kind = va_arg(args, int);
3259  robj = va_arg(args, object **);
3260 
3261  va_end(args);
3262 
3263  if (kind == 0) {
3264  *type = CFAPI_POBJECT;
3265  *robj = object_create_clone(op);
3266  } else {
3267  object *tmp;
3268  tmp = object_new();
3269  object_copy(op, tmp);
3270  *type = CFAPI_POBJECT;
3271  *robj = tmp;
3272  }
3273  return;
3274 }
3275 
3281 static void cfapi_object_create(int *type, ...) {
3282  va_list args;
3283  int ival;
3284  object **robj;
3285  va_start(args, type);
3286  ival = va_arg(args, int);
3287 
3288  *type = CFAPI_POBJECT;
3289  switch (ival) {
3290  case 0:
3291  robj = va_arg(args, object **);
3292  *robj = object_new();
3293  break;
3294 
3295  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3296  const char *sval;
3297  archetype *at;
3298 
3299  sval = va_arg(args, const char *);
3300  robj = va_arg(args, object **);
3301  va_end(args);
3302 
3303  at = try_find_archetype(sval);
3304  if (!at)
3305  at = find_archetype_by_object_name(sval);
3306  if (at) {
3307  *robj = object_create_arch(at);
3308  } else
3309  *robj = NULL;
3310  }
3311  break;
3312 
3313  default:
3314  *type = CFAPI_NONE;
3315  break;
3316  }
3317  va_end(args);
3318 }
3319 
3320 static void cfapi_object_insert(int *type, ...) {
3321  va_list args;
3322  object *op;
3323  object *orig;
3324  mapstruct *map;
3325  int flag, x, y;
3326  int itype;
3327  object **robj;
3328 
3329  va_start(args, type);
3330 
3331  op = va_arg(args, object *);
3332  if (!op) {
3333  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3334  va_end(args);
3335  return;
3336  }
3337  if (QUERY_FLAG(op, FLAG_FREED)) {
3338  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3339  va_end(args);
3340  return;
3341  }
3342  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3343  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3344  object_remove(op);
3345  }
3346  itype = va_arg(args, int);
3347 
3348  switch (itype) {
3349  case 0:
3350  map = va_arg(args, mapstruct *);
3351  orig = va_arg(args, object *);
3352  flag = va_arg(args, int);
3353  x = va_arg(args, int);
3354  y = va_arg(args, int);
3355  robj = va_arg(args, object **);
3356  if (!map) {
3357  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3359  *robj = NULL;
3360  } else
3361  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3362  *type = CFAPI_POBJECT;
3363  break;
3364 
3365  case 1:
3366  map = va_arg(args, mapstruct *);
3367  orig = va_arg(args, object *);
3368  flag = va_arg(args, int);
3369  robj = va_arg(args, object **);
3370  if (!map) {
3371  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3373  *robj = NULL;
3374  } else
3375  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3376  *type = CFAPI_POBJECT;
3377  break;
3378 
3379  case 2:
3380  map = va_arg(args, mapstruct *);
3381  orig = va_arg(args, object *);
3382  flag = va_arg(args, int);
3383  x = va_arg(args, int);
3384  y = va_arg(args, int);
3385  robj = va_arg(args, object **);
3386  if (!map) {
3387  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3389  *robj = NULL;
3390  } else {
3391  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3392  if (dir != -1) {
3393  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3394  } else {
3396  *robj = NULL;
3397  }
3398  }
3399  *type = CFAPI_POBJECT;
3400  break;
3401 
3402  case 3:
3403  orig = va_arg(args, object *);
3404  robj = va_arg(args, object **);
3405  if (!orig) {
3406  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3408  *robj = NULL;
3409  } else
3410  *robj = object_insert_in_ob(op, orig);
3411  *type = CFAPI_POBJECT;
3412  break;
3413 
3414  default:
3415  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3417  *type = CFAPI_NONE;
3418  break;
3419  }
3420 
3421  va_end(args);
3422 }
3428 static void cfapi_object_split(int *type, ...) {
3429  va_list args;
3430 
3431  int nr, size;
3432  object *op;
3433  char *buf;
3434  object **split;
3435 
3436  va_start(args, type);
3437 
3438  op = va_arg(args, object *);
3439  nr = va_arg(args, int);
3440  buf = va_arg(args, char *);
3441  size = va_arg(args, int);
3442  split = va_arg(args, object **);
3443  va_end(args);
3444 
3445  *split = object_split(op, nr, buf, size);
3446  if (*split != NULL)
3447  {
3448  *type = CFAPI_POBJECT;
3449  }
3450  else
3451  {
3452  *type = CFAPI_NONE;
3453  }
3454 }
3455 
3461 static void cfapi_object_merge(int *type, ...) {
3462  va_list args;
3463  object *op;
3464  object *op2;
3465  object **merge;
3466 
3467  va_start(args, type);
3468 
3469  op = va_arg(args, object *);
3470  op2 = va_arg(args, object *);
3471  merge = va_arg(args, object **);
3472 
3473  va_end(args);
3474 
3475  *type = CFAPI_POBJECT;
3476  *merge = object_merge(op, op2);
3477 }
3478 
3484 static void cfapi_object_distance(int *type, ...) {
3485  va_list args;
3486  object *op;
3487  object *op2;
3488  int *rint;
3489  va_start(args, type);
3490 
3491  op = va_arg(args, object *);
3492  op2 = va_arg(args, object *);
3493  rint = va_arg(args, int *);
3494 
3495  va_end(args);
3496 
3497  *type = CFAPI_INT;
3498  *rint = object_distance(op, op2);
3499 }
3505 static void cfapi_object_update(int *type, ...) {
3506  va_list args;
3507  int action;
3508  object *op;
3509  va_start(args, type);
3510 
3511  op = va_arg(args, object *);
3512  action = va_arg(args, int);
3513 
3514  va_end(args);
3515 
3517  *type = CFAPI_NONE;
3518 }
3519 
3525 static void cfapi_object_clear(int *type, ...) {
3526  va_list args;
3527  object *op;
3528  va_start(args, type);
3529 
3530  op = va_arg(args, object *);
3531 
3532  va_end(args);
3533 
3534  object_clear(op);
3535  *type = CFAPI_NONE;
3536 }
3537 
3543 static void cfapi_object_reset(int *type, ...) {
3544  va_list args;
3545  object *op;
3546 
3547  va_start(args, type);
3548 
3549  op = va_arg(args, object *);
3550 
3551  va_end(args);
3552 
3553  object_reset(op);
3554  *type = CFAPI_NONE;
3555 }
3556 
3557 static void cfapi_object_clean_object(int *type, ...) {
3558  va_list args;
3559  object *op;
3560 
3561  va_start(args, type);
3562  op = va_arg(args, object *);
3563  clean_object(op);
3564  va_end(args);
3565  *type = CFAPI_NONE;
3566 }
3567 
3568 static void cfapi_object_on_same_map(int *type, ...) {
3569  va_list args;
3570  object *op1;
3571  object *op2;
3572  int *rint;
3573 
3574  va_start(args, type);
3575  op1 = va_arg(args, object *);
3576  op2 = va_arg(args, object *);
3577  rint = va_arg(args, int *);
3578  va_end(args);
3579 
3580  *type = CFAPI_INT;
3581  *rint = on_same_map(op1, op2);
3582 }
3583 
3584 static void cfapi_object_spring_trap(int *type, ...) {
3585  object *trap;
3586  object *victim;
3587  va_list args;
3588 
3589  va_start(args, type);
3590  trap = va_arg(args, object *);
3591  victim = va_arg(args, object *);
3592  va_end(args);
3593 
3594  spring_trap(trap, victim);
3595  *type = CFAPI_NONE;
3596 }
3597 
3603 static void cfapi_object_check_trigger(int *type, ...) {
3604  object *op;
3605  object *cause;
3606  va_list args;
3607  int *rint;
3608 
3609  va_start(args, type);
3610  op = va_arg(args, object *);
3611  cause = va_arg(args, object *);
3612  rint = va_arg(args, int *);
3613  va_end(args);
3614 
3615  *rint = check_trigger(op, cause);
3616  *type = CFAPI_INT;
3617 }
3618 
3630 static void cfapi_map_trigger_connected(int *type, ...) {
3631  objectlink *ol;
3632  object *cause;
3633  int state;
3634  va_list args;
3635 
3636  va_start(args, type);
3637  ol = va_arg(args, objectlink *);
3638  cause = va_arg(args, object *);
3639  state = va_arg(args, int);
3640  va_end(args);
3641  trigger_connected(ol, cause, state);
3642  *type = CFAPI_NONE;
3643 }
3644 
3650 static void cfapi_object_query_money(int *type, ...) {
3651  object *op;
3652  va_list args;
3653  int *rint;
3654 
3655  va_start(args, type);
3656  op = va_arg(args, object *);
3657  rint = va_arg(args, int *);
3658  va_end(args);
3659 
3660  *rint = query_money(op);
3661  *type = CFAPI_INT;
3662 }
3663 
3669 static void cfapi_object_cast(int *type, ...) {
3670  object *op;
3671  object *sp;
3672  int dir;
3673  char *str;
3674  object *caster;
3675  va_list args;
3676  int *rint;
3677 
3678  va_start(args, type);
3679  op = va_arg(args, object *);
3680  caster = va_arg(args, object *);
3681  dir = va_arg(args, int);
3682  sp = va_arg(args, object *);
3683  str = va_arg(args, char *);
3684  rint = va_arg(args, int *);
3685  va_end(args);
3686 
3687  *type = CFAPI_INT;
3688 
3689  if (!op->map) {
3690  *rint = -1;
3691  return;
3692  }
3693 
3694  *rint = cast_spell(op, caster, dir, sp, str);
3695 }
3696 
3697 static void cfapi_object_learn_spell(int *type, ...) {
3698  object *op;
3699  object *sp;
3700  int prayer;
3701  va_list args;
3702 
3703  va_start(args, type);
3704  op = va_arg(args, object *);
3705  sp = va_arg(args, object *);
3706  prayer = va_arg(args, int);
3707  va_end(args);
3708  do_learn_spell(op, sp, prayer);
3709  *type = CFAPI_NONE;
3710 }
3711 
3712 static void cfapi_object_forget_spell(int *type, ...) {
3713  object *op;
3714  object *sp;
3715  va_list args;
3716  char name[MAX_BUF];
3717 
3718  va_start(args, type);
3719  op = va_arg(args, object *);
3720  sp = va_arg(args, object *);
3721  va_end(args);
3722  query_name(sp, name, MAX_BUF);
3724  *type = CFAPI_NONE;
3725 }
3726 
3732 static void cfapi_object_check_spell(int *type, ...) {
3733  object *op;
3734  char *spellname;
3735  va_list args;
3736  object **robj;
3737 
3738  va_start(args, type);
3739  op = va_arg(args, object *);
3740  spellname = va_arg(args, char *);
3741  robj = va_arg(args, object **);
3742  va_end(args);
3743  *robj = check_spell_known(op, spellname);
3744  *type = CFAPI_POBJECT;
3745 }
3746 
3752 static void cfapi_object_pay_amount(int *type, ...) {
3753  object *op;
3754  uint64_t amount;
3755  va_list args;
3756  int *rint;
3757 
3758  va_start(args, type);
3759  op = va_arg(args, object *);
3760  amount = va_arg(args, uint64_t);
3761  rint = va_arg(args, int *);
3762  va_end(args);
3763 
3764  *rint = pay_for_amount(amount, op);
3765  *type = CFAPI_INT;
3766 }
3767 
3773 static void cfapi_object_pay_item(int *type, ...) {
3774  object *op;
3775  object *tobuy;
3776  int *rint;
3777 
3778  va_list args;
3779 
3780  va_start(args, type);
3781  tobuy = va_arg(args, object *);
3782  op = va_arg(args, object *);
3783  rint = va_arg(args, int *);
3784  va_end(args);
3785 
3786  *rint = pay_for_item(tobuy, op, 0);
3787  *type = CFAPI_INT;
3788 }
3789 
3797 static void cfapi_object_transfer(int *type, ...) {
3798  object *op;
3799  object *originator;
3800  int x, y, randompos, ttype, flag;
3801  va_list args;
3802  mapstruct *map;
3803  int *rint;
3804  object **robj;
3805 
3806  va_start(args, type);
3807  op = va_arg(args, object *);
3808  ttype = va_arg(args, int);
3809  switch (ttype) {
3810  case 0:
3811  x = va_arg(args, int);
3812  y = va_arg(args, int);
3813  randompos = va_arg(args, int);
3814  originator = va_arg(args, object *);
3815  rint = va_arg(args, int *);
3816  va_end(args);
3817 
3818  *rint = transfer_ob(op, x, y, randompos, originator);
3819  *type = CFAPI_INT;
3820  return;
3821  break;
3822 
3823  case 1:
3824  map = va_arg(args, mapstruct *);
3825  originator = va_arg(args, object *);
3826  flag = va_arg(args, int);
3827  x = va_arg(args, int);
3828  y = va_arg(args, int);
3829  robj = va_arg(args, object **);
3830  va_end(args);
3831  if (x < 0 || y < 0) {
3832  x = map->enter_x;
3833  y = map->enter_y;
3834  }
3835  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
3836  *type = CFAPI_POBJECT;
3837  return;
3838  break;
3839 
3840  case 2:
3841  x = va_arg(args, int);
3842  y = va_arg(args, int);
3843  rint = va_arg(args, int *);
3844  va_end(args);
3845 
3846  *rint = move_to(op, x, y);
3847  *type = CFAPI_INT;
3848  return;
3849 
3850  default:
3851  va_end(args);
3852  *type = CFAPI_NONE;
3853  return;
3854  break;
3855  }
3856 }
3857 
3862  object *op;
3863  char *str;
3864  va_list args;
3865  object **robj;
3866 
3867  *type = CFAPI_POBJECT;
3868  va_start(args, type);
3869  op = va_arg(args, object *);
3870 
3871  str = va_arg(args, char *);
3872  robj = va_arg(args, object **);
3874  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
3875  if (*robj == NULL) {
3876  char name[MAX_BUF];
3877 
3878  /* Search by name or slaying instead */
3879  FOR_INV_PREPARE(op, tmp) {
3880  if (tmp->name) {
3882  if (!strncmp(name, str, strlen(str)))
3883  *robj = tmp;
3884  if (!strncmp(tmp->name, str, strlen(str)))
3885  *robj = tmp;
3886  }
3887  if (tmp->slaying && !strcmp(tmp->slaying, str))
3888  *robj = tmp;
3889  if (*robj != NULL)
3890  break;
3891  } FOR_INV_FINISH();
3892  }
3893  va_end(args);
3894 }
3895 
3896 static void cfapi_object_find_by_arch_name(int *type, ...) {
3897  const object *who;
3898  object **result;
3899  const char *name;
3900  va_list args;
3901 
3902  va_start(args, type);
3903  who = va_arg(args, const object *);
3904  name = va_arg(args, const char *);
3905  result = va_arg(args, object **);
3906  va_end(args);
3907  *type = CFAPI_POBJECT;
3908 
3910 }
3911 
3912 static void cfapi_object_find_by_name(int *type, ...) {
3913  const object *who;
3914  object **result;
3915  const char *name;
3916  va_list args;
3917 
3918  va_start(args, type);
3919  who = va_arg(args, const object *);
3920  name = va_arg(args, const char *);
3921  result = va_arg(args, object **);
3922  va_end(args);
3923  *type = CFAPI_POBJECT;
3924 
3926 }
3927 
3933 static void cfapi_object_drop(int *type, ...) {
3934  object *op;
3935  object *author;
3936  va_list args;
3937 
3938  va_start(args, type);
3939  op = va_arg(args, object *);
3940  author = va_arg(args, object *);
3941  va_end(args);
3942  *type = CFAPI_NONE;
3943 
3944  if (QUERY_FLAG(op, FLAG_NO_DROP))
3945  return;
3946  drop(author, op);
3947 
3948  if (author->type == PLAYER) {
3949  author->contr->count = 0;
3950  author->contr->socket->update_look = 1;
3951  }
3952 }
3953 
3957 static void cfapi_object_change_abil(int *type, ...) {
3958  object *op, *tmp;
3959  int *rint;
3960  va_list args;
3961 
3962  va_start(args, type);
3963  op = va_arg(args, object *);
3964  tmp = va_arg(args, object *);
3965  rint = va_arg(args, int *);
3966  va_end(args);
3967 
3968  *type = CFAPI_INT;
3969  *rint = change_abil(op, tmp);
3970 }
3971 
3972 static void cfapi_object_say(int *type, ...) {
3973  object *op;
3974  char *msg;
3975  va_list args;
3976  int *rint;
3977  char empty[] = "";
3978 
3979  va_start(args, type);
3980  op = va_arg(args, object *);
3981  msg = va_arg(args, char *);
3982  rint = va_arg(args, int *);
3983  va_end(args);
3984 
3985  if (op->type == PLAYER) {
3986  command_say(op, msg == NULL ? empty : msg);
3987  } else {
3989  }
3990  *rint = 0;
3991  *type = CFAPI_INT;
3992 }
3993 
3994 /* PLAYER SUBCLASS */
3995 
4001 static void cfapi_player_find(int *type, ...) {
4002  va_list args;
4003  char *sval;
4004  player **rpl;
4005  va_start(args, type);
4006 
4007  sval = va_arg(args, char *);
4008  rpl = va_arg(args, player **);
4009  va_end(args);
4010 
4011  *rpl = find_player_partial_name(sval);
4012 
4013  *type = CFAPI_PPLAYER;
4014 }
4015 
4016 static void cfapi_player_message(int *type, ...) {
4017  va_list args;
4018  int flags;
4019  int pri;
4020  object *pl;
4021  const char *buf;
4022 
4023  va_start(args, type);
4024 
4025  flags = va_arg(args, int);
4026  pri = va_arg(args, int);
4027  pl = va_arg(args, object *);
4028  buf = va_arg(args, const char *);
4029  va_end(args);
4030 
4032  buf);
4033  *type = CFAPI_NONE;
4034 }
4035 
4042 static void cfapi_object_perm_exp(int *type, ...) {
4043  va_list args;
4044  object *op;
4045  int64_t *rlong;
4046 
4047  va_start(args, type);
4048  op = va_arg(args, object *);
4049  rlong = va_arg(args, int64_t *);
4050  va_end(args);
4051 
4052  *type = CFAPI_SINT64;
4053  *rlong = PERM_EXP(op->total_exp);
4054 }
4055 
4061 static void cfapi_object_change_exp(int *type, ...) {
4062  va_list args;
4063  int flag;
4064  object *ob;
4065  const char *skill;
4066  int64_t exp;
4067 
4068  va_start(args, type);
4069  ob = va_arg(args, object *);
4070  exp = va_arg(args, int64_t);
4071  skill = va_arg(args, const char *);
4072  flag = va_arg(args, int);
4073  va_end(args);
4074 
4075  *type = CFAPI_NONE;
4076  change_exp(ob, exp, skill, flag);
4077 }
4078 
4084 static void cfapi_player_can_pay(int *type, ...) {
4085  va_list args;
4086  object *pl;
4087  int *rint;
4088 
4089  va_start(args, type);
4090  pl = va_arg(args, object *);
4091  rint = va_arg(args, int *);
4092  va_end(args);
4093 
4094  *rint = can_pay(pl);
4095  *type = CFAPI_INT;
4096 }
4097 
4103 static void cfapi_player_knowledge(int *type, ...) {
4104  va_list args;
4105  object *pl;
4106  int *rint, what;
4107  const char *knowledge;
4108 
4109  va_start(args, type);
4110  what = va_arg(args, int);
4111 
4112  switch(what)
4113  {
4114  case 1:
4115  pl = va_arg(args, object *);
4116  knowledge = va_arg(args, const char *);
4117  rint = va_arg(args, int *);
4118 
4119  *type = CFAPI_INT;
4120 
4121  if (pl->contr == NULL) {
4122  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4123  *rint = 0;
4124  va_end(args);
4125  return;
4126  }
4127 
4128  *rint = knowledge_player_knows(pl->contr, knowledge);
4129  break;
4130 
4131  case 2:
4132  pl = va_arg(args, object *);
4133  knowledge = va_arg(args, const char *);
4134  *type = CFAPI_NONE;
4135  if (pl->contr != NULL)
4136  knowledge_give(pl->contr, knowledge, NULL);
4137 
4138  break;
4139 
4140  default:
4141  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4142  }
4143 
4144  va_end(args);
4145 }
4146 
4152 static void cfapi_object_teleport(int *type, ...) {
4153  mapstruct *map;
4154  int x, y;
4155  object *who;
4156  int *res;
4157  va_list args;
4158 
4159  va_start(args, type);
4160  who = va_arg(args, object *);
4161  map = va_arg(args, mapstruct *);
4162  x = va_arg(args, int);
4163  y = va_arg(args, int);
4164  res = va_arg(args, int *);
4165  va_end(args);
4166 
4167  *type = CFAPI_INT;
4168  *res = object_teleport(who, map, x, y);
4169 }
4170 
4171 static void cfapi_object_pickup(int *type, ...) {
4172  object *who;
4173  object *what;
4174  va_list args;
4175 
4176  va_start(args, type);
4177  who = va_arg(args, object *);
4178  what = va_arg(args, object *);
4179  va_end(args);
4180 
4181  pick_up(who, what);
4182  *type = CFAPI_NONE;
4183 }
4184 
4185 /* Archetype-related functions */
4186 static void cfapi_archetype_get_property(int *type, ...) {
4187  int prop;
4188  archetype *arch;
4189  va_list args;
4190  sstring *rsstring;
4191  archetype **rarch;
4192  object **robject;
4193 
4194  va_start(args, type);
4195  arch = va_arg(args, archetype *);
4196  prop = va_arg(args, int);
4197  switch (prop) {
4198  case CFAPI_ARCH_PROP_NAME:
4199  *type = CFAPI_SSTRING;
4200  rsstring = va_arg(args, sstring *);
4201  *rsstring = arch->name;
4202  break;
4203 
4204  case CFAPI_ARCH_PROP_NEXT:
4205  *type = CFAPI_PARCH;
4206  rarch = va_arg(args, archetype **);
4207  *rarch = get_next_archetype(arch);
4208  break;
4209 
4210  case CFAPI_ARCH_PROP_HEAD:
4211  *type = CFAPI_PARCH;
4212  rarch = va_arg(args, archetype **);
4213  *rarch = arch->head;
4214  break;
4215 
4216  case CFAPI_ARCH_PROP_MORE:
4217  *type = CFAPI_PARCH;
4218  rarch = va_arg(args, archetype **);
4219  *rarch = arch->more;
4220  break;
4221 
4222  case CFAPI_ARCH_PROP_CLONE:
4223  *type = CFAPI_POBJECT;
4224  robject = va_arg(args, object **);
4225  *robject = &arch->clone;
4226  break;
4227 
4228  default:
4229  *type = CFAPI_NONE;
4230  break;
4231  }
4232  va_end(args);
4233 }
4234 
4241 static void cfapi_party_get_property(int *type, ...) {
4242  partylist *party;
4243  int prop;
4244  va_list args;
4245  object *obarg;
4246  sstring *rsstring;
4247  player **rplayer;
4248  partylist **rparty;
4249 
4250  va_start(args, type);
4251  party = va_arg(args, partylist *);
4252  prop = va_arg(args, int);
4253  switch (prop) {
4254  case CFAPI_PARTY_PROP_NAME:
4255  rsstring = va_arg(args, sstring *);
4256  *rsstring = party->partyname;
4257  *type = CFAPI_SSTRING;
4258  break;
4259 
4260  case CFAPI_PARTY_PROP_NEXT:
4261  rparty = va_arg(args, partylist **);
4262  *rparty = (party ? party_get_next(party) : party_get_first());
4263  *type = CFAPI_PPARTY;
4264  break;
4265 
4267  rsstring = va_arg(args, sstring *);
4268  *rsstring = party_get_password(party);
4269  *type = CFAPI_SSTRING;
4270  break;
4271 
4273  *type = CFAPI_PPLAYER;
4274  obarg = va_arg(args, object *);
4275  rplayer = va_arg(args, player **);
4276  *rplayer = (obarg ? obarg->contr : first_player);
4277  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4278  if ((*rplayer)->ob->contr->party == party) {
4279  break;
4280  }
4281  break;
4282 
4283  default:
4284  *type = CFAPI_NONE;
4285  break;
4286  }
4287  va_end(args);
4288 }
4289 
4296 static void cfapi_region_get_property(int *type, ...) {
4297  region *reg;
4298  int prop, *rint;
4299  va_list args;
4301  sstring *rsstring;
4302  region **rregion;
4303 
4304  va_start(args, type);
4305  reg = va_arg(args, region *);
4306  prop = va_arg(args, int);
4307  switch (prop) {
4309  rsstring = va_arg(args, sstring *);
4310  *rsstring = reg->name;
4311  *type = CFAPI_SSTRING;
4312  break;
4313 
4315  rregion = va_arg(args, region **);
4316  *rregion = nullptr;
4317  *type = CFAPI_PREGION;
4318  break;
4319 
4321  rregion = va_arg(args, region **);
4322  *rregion = reg->parent;
4323  *type = CFAPI_PREGION;
4324  break;
4325 
4327  rsstring = va_arg(args, sstring *);
4328  *rsstring = reg->longname;
4329  *type = CFAPI_SSTRING;
4330  break;
4331 
4333  rsstring = va_arg(args, sstring *);
4334  *rsstring = reg->msg;
4335  *type = CFAPI_SSTRING;
4336  break;
4337 
4340  rint = va_arg(args, int*);
4341  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4342  *type = CFAPI_INT;
4343  break;
4344 
4346  rsstring = va_arg(args, sstring *);
4347  *rsstring = reg->jailmap;
4348  *type = CFAPI_SSTRING;
4349  break;
4350 
4351  default:
4352  *type = CFAPI_NONE;
4353  break;
4354  }
4355  va_end(args);
4356 }
4357 
4369 static void cfapi_friendlylist_get_next(int *type, ...) {
4370  object *ob;
4371  va_list args;
4372  object **robject;
4373 
4374  va_start(args, type);
4375  ob = va_arg(args, object *);
4376  robject = va_arg(args, object **);
4377  va_end(args);
4378 
4379  *type = CFAPI_POBJECT;
4380  *robject = get_next_friend(ob);
4381 }
4382 
4383 /*
4384  * Random-map related stuff.
4385  */
4386 
4393 static void cfapi_set_random_map_variable(int *type, ...) {
4394  va_list args;
4395  RMParms *rp;
4396  const char *buf;
4397  int *ret;
4398 
4399  va_start(args, type);
4400  rp = va_arg(args, RMParms *);
4401  buf = va_arg(args, const char *);
4402  ret = va_arg(args, int *);
4403  va_end(args);
4404 
4405  *ret = set_random_map_variable(rp, buf);
4406  *type = CFAPI_INT;
4407 }
4408 
4415 static void cfapi_generate_random_map(int *type, ...) {
4416  va_list args;
4417  const char *name;
4418  RMParms *rp;
4419  char **use_layout;
4420  sstring reset_group;
4421  mapstruct **ret;
4422 
4423  va_start(args, type);
4424  name = va_arg(args, const char *);
4425  rp = va_arg(args, RMParms *);
4426  use_layout = va_arg(args, char **);
4427  reset_group = va_arg(args, sstring);
4428  ret = va_arg(args, mapstruct **);
4429  va_end(args);
4430 
4431  *ret = generate_random_map(name, rp, use_layout, reset_group);
4432 }
4433 
4434 static void cfapi_object_user_event(int *type, ...) {
4435  object *op;
4436  object *activator;
4437  object *third;
4438  const char *message;
4439  int fix;
4440  int *ret;
4441  va_list args;
4442 
4443  va_start(args, type);
4444  op = va_arg(args, object *);
4445  activator = va_arg(args, object *);
4446  third = va_arg(args, object *);
4447  message = va_arg(args, const char *);
4448  fix = va_arg(args, int);
4449  ret = va_arg(args, int *);
4450  va_end(args);
4451 
4452  *ret = events_execute_object_user(op, activator, third, message, fix);
4453  *type = CFAPI_INT;
4454 }
4455 
4458 static void cfapi_player_quest(int *type, ...) {
4459  int op;
4460  va_list args;
4461  object *player;
4462  sstring code;
4463 
4464  va_start(args, type);
4465  op = va_arg(args, int);
4466  player = va_arg(args, object *);
4467  code = va_arg(args, sstring);
4468 
4469  if (player->contr == NULL) {
4470  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4471  va_end(args);
4472  /* crash/quit? */
4473  return;
4474  }
4475 
4476  switch(op) {
4477  case CFAPI_PLAYER_QUEST_START: {
4478  int state = va_arg(args, int);
4479  quest_start(player->contr, code, state);
4480  *type = CFAPI_NONE;
4481  break;
4482  }
4484  int *ret = va_arg(args, int *);
4485  *ret = quest_get_player_state(player->contr, code);
4486  *type = CFAPI_INT;
4487  break;
4488  }
4490  int state = va_arg(args, int);
4492  *type = CFAPI_NONE;
4493  break;
4494  }
4496  int *ret = va_arg(args, int*);
4497  *ret = quest_was_completed(player->contr, code);
4498  *type = CFAPI_INT;
4499  break;
4500  }
4501  default:
4502  LOG(llevError, "invalid quest type: %d\n", op);
4503  *type = CFAPI_NONE;
4504  }
4505 
4506  va_end(args);
4507 }
4508 
4509 static void cfapi_register_command(int *type, ...) {
4510  va_list args;
4511  const char *name = NULL, *extra = NULL;
4512  float time;
4513  command_function func = NULL;
4514  command_function_extra func_extra = NULL;
4515  uint8_t register_type, command_type;
4517 
4518  va_start(args, type);
4519  register_type = va_arg(args, int);
4520  name = va_arg(args, const char *);
4521  if (register_type == 1) {
4522  func = va_arg(args, command_function);
4523  } else {
4524  extra = va_arg(args, const char *);
4525  func_extra = va_arg(args, command_function_extra);
4526  }
4527  command_type = (uint8_t)va_arg(args, int);
4528  if (command_type > COMMAND_TYPE_WIZARD) {
4529  command_type = COMMAND_TYPE_NORMAL;
4530  }
4531  time = va_arg(args, double);
4532  cr = va_arg(args, command_registration *);
4533  va_end(args);
4534 
4535  if (register_type == 1) {
4536  (*cr) = command_register(name, command_type, func, time);
4537  } else {
4538  (*cr) = command_register_extra(name, extra, command_type, func_extra, time);
4539  }
4540 
4541  *type = CFAPI_SINT64;
4542 }
4543 
4544 static void cfapi_unregister_command(int *type, ...) {
4545  va_list args;
4547 
4548  va_start(args, type);
4549  cr = va_arg(args, command_registration);
4550  va_end(args);
4551 
4552  command_unregister(cr);
4553 }
4554 
4555 /*****************************************************************************/
4556 /* NEW PLUGIN STUFF ENDS HERE */
4557 /*****************************************************************************/
4558 
4559 
4564 void initPlugins(void) {
4565  struct dirent *currentfile;
4566  DIR *plugdir;
4567  size_t l;
4568  char buf[MAX_BUF];
4569 
4570  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4571  LOG(llevDebug, "plugins: loading from %s\n", buf);
4572 
4573  plugdir = opendir(buf);
4574  if (plugdir == NULL)
4575  return;
4576 
4577  while ((currentfile = readdir(plugdir)) != NULL) {
4578  l = strlen(currentfile->d_name);
4579  if (l > strlen(PLUGIN_SUFFIX)) {
4580  int ignore = 0;
4581 
4582  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4583  continue;
4584 
4585  for (auto disable = settings.disabled_plugins.cbegin(); disable != settings.disabled_plugins.cend(); ++disable) {
4586  if (strcmp(*disable, "All") == 0) {
4587  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4588  ignore = 1;
4589  break;
4590  }
4591  if (strncmp(*disable, currentfile->d_name, strlen(*disable)) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + strlen(*disable)) {
4592  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4593  ignore = 1;
4594  break;
4595  }
4596  }
4597  if (ignore == 0) {
4598  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4599  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4601  }
4602  }
4603  }
4604 
4605  closedir(plugdir);
4606 }
4607 
4612 void cleanupPlugins(void) {
4613  for (crossfire_plugin *cp : plugins_list) {
4614  if (cp->closefunc)
4615  cp->closefunc();
4616  /* Don't actually unload plugins, it makes backtraces for memory
4617  * debugging (printed at exit) messed up. And it doesn't matter if we
4618  * don't free it here. The OS will do it for us.
4619  */
4620  /* plugins_dlclose(cp->libptr); */
4621  free(cp);
4622  }
4623  plugins_list.clear();
4624 }
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:171
cfapi_object_transfer
static void cfapi_object_transfer(int *type,...)
Definition: plugins.cpp:3797
cfapi_object_clean_object
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.cpp:3557
cfapi_object_forget_spell
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.cpp:3712
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:524
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:3428
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
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:536
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:248
CFAPI_OBJECT_PROP_ARCH_NAME
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:215
Settings::uniquedir
const char * uniquedir
Definition: global.h:253
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:3484
cfapi_object_delete
static void cfapi_object_delete(int *type,...)
Definition: plugins.cpp:3222
cfapi_player_quest
static void cfapi_player_quest(int *type,...)
Definition: plugins.cpp:4458
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:270
cfapi_archetype_get_property
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.cpp:4186
NR_EVENTS
#define NR_EVENTS
Definition: events.h:59
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:51
get_empty_map
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.cpp:842
monster_npc_say
void monster_npc_say(object *npc, const char *cp)
Definition: monster.cpp:2499
CFAPI_MAP_PROP_RESET_TIME
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:250
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
drain_specific_stat
void drain_specific_stat(object *op, int deplete_stats)
Definition: living.cpp:728
CFAPI_MAP_PROP_RESET_TIMEOUT
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:251
cfapi_system_register_global_event
static void cfapi_system_register_global_event(int *type,...)
Definition: plugins.cpp:585
CFAPI_REGION_PROP_LONGNAME
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:278
cfapi_system_get_party_vector
static void cfapi_system_get_party_vector(int *type,...)
Definition: plugins.cpp: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:3933
ready_map_name
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.cpp:1759
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
cfapi_system_get_map_vector
static void cfapi_system_get_map_vector(int *type,...)
Definition: plugins.cpp:654
CFAPI_REGION_PROP_NEXT
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:276
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:262
CFAPI_MAP_PROP_NEXT
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:260
NR_OF_HOOKS
#define NR_OF_HOOKS
Definition: plugins.cpp:49
do_learn_spell
void do_learn_spell(object *op, object *spell, int special_prayer)
Definition: apply.cpp:484
has_been_loaded
mapstruct * has_been_loaded(const char *name)
Definition: map.cpp:78
map_find_by_archetype
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Definition: object.cpp:3109
object_merge
object * object_merge(object *op, object *top)
Definition: object.cpp:2046
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:2107
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
cast_spell
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Definition: spell_util.cpp:1424
events_unregister_object_handler
void events_unregister_object_handler(const char *id)
Definition: events.cpp:287
CFAPI_OBJECT_PROP_BASE_NAME
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:187
hook_entry
Definition: plugin.h:307
UPD_WEIGHT
#define UPD_WEIGHT
Definition: newclient.h:305
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:205
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:3281
SVN_REV
#define SVN_REV
Definition: svnversion.h:2
cfapi_object_drain
static void cfapi_object_drain(int *type,...)
Definition: plugins.cpp:3114
give_skill_by_name
object * give_skill_by_name(object *op, const char *skill_name)
Definition: living.cpp:1777
set_random_map_variable
int set_random_map_variable(RMParms *rp, const char *buf)
Definition: reader.c:2579
quest_set_player_state
void quest_set_player_state(player *pl, sstring quest_code, int state)
Definition: quest.cpp:716
CFAPI_OBJECT_PROP_GOD
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:214
MoveType
unsigned char MoveType
Definition: define.h:417
arch_present_in_ob
object * arch_present_in_ob(const archetype *at, const object *op)
Definition: object.cpp:3213
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
Settings::localdir
const char * localdir
Definition: global.h:249
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:3861
time
non standard information is not specified or uptime this means how long since the executable has been started A particular host may have been running a server for quite a long time
Definition: arch-handbook.txt:206
CFAPI_SYSTEM_ARCHETYPES
#define CFAPI_SYSTEM_ARCHETYPES
Definition: plugin.h:286
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
giveknowledge.knowledge
knowledge
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: giveknowledge.py:15
CFAPI_OBJECT_PROP_MAXSP
#define CFAPI_OBJECT_PROP_MAXSP
Definition: plugin.h:211
CFAPI_OBJECT_PROP_RAW_NAME
#define CFAPI_OBJECT_PROP_RAW_NAME
Definition: plugin.h:228
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:2948
object_reset
void object_reset(object *op)
Definition: object.cpp:934
CFAPI_ARCH_PROP_NEXT
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:265
CFAPI_OBJECT_PROP_Y
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:139
Settings::tmpdir
const char * tmpdir
Definition: global.h:255
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
Ice.tmp
int tmp
Definition: Ice.py:207
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
mode
linux kernel c mode(defun linux-c-mode() "C mode with adjusted defaults for use with the Linux kernel."(interactive)(c-mode)(c-set-style "K&R")(setq c-basic-offset 8))
fix_object
void fix_object(object *op)
Definition: living.cpp:1125
get_tod
void get_tod(timeofday_t *tod)
Definition: time.cpp:215
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:3972
CFAPI_REGION_PROP_PARENT
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:277
plugin.h
CFAPI_OBJECT_PROP_ENVIRONMENT
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:125
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
Definition: global.h:327
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:274
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:310
FOR_ABOVE_PREPARE
#define FOR_ABOVE_PREPARE(op_, it_)
Definition: define.h:687
CFAPI_SYSTEM_PLAYERS
#define CFAPI_SYSTEM_PLAYERS
Definition: plugin.h:285
CFAPI_OBJECT_PROP_PRESENT
#define CFAPI_OBJECT_PROP_PRESENT
Definition: plugin.h:192
CFAPI_REGION_PROP_JAIL_PATH
#define CFAPI_REGION_PROP_JAIL_PATH
Definition: plugin.h:282
CFAPI_MAP_PROP_WIDTH
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:255
cfapi_get_hooks
static void cfapi_get_hooks(int *type,...)
Definition: plugins.cpp:327
CFAPI_ARCH_PROP_NAME
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:264
CFAPI_OBJECT_PROP_ITEM_POWER
#define CFAPI_OBJECT_PROP_ITEM_POWER
Definition: plugin.h:164
CFAPI_MAP_PROP_UNIQUE
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:262
f_plug_init
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:83
partylist
Definition: party.h:10
smoking_pipe.color
color
Definition: smoking_pipe.py:5
apply_manual
int apply_manual(object *op, object *tmp, int aflag)
Definition: apply.cpp:597
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.cpp:4337
AssetsManager.h
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:402
initPlugins
void initPlugins(void)
Definition: plugins.cpp:4564
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:4369
buf
StringBuffer * buf
Definition: readable.cpp:1552
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
cfapi_object_identify
static void cfapi_object_identify(int *type,...)
Definition: plugins.cpp:3072
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:2848
crossfire_plugin::libptr
LIBPTRTYPE libptr
Definition: plugin.h:98
cfapi_object_user_event
static void cfapi_object_user_event(int *type,...)
Definition: plugins.cpp:4434
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Definition: newclient.h:393
CFAPI_MAP_PROP_ENTER_X
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:257
cfapi_object_update
static void cfapi_object_update(int *type,...)
Definition: plugins.cpp:3505
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
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
cfapi_object_change_abil
static void cfapi_object_change_abil(int *type,...)
Definition: plugins.cpp:3957
draw_ext_info
vs only yadda is in because all tags get reset on the next draw_ext_info In the second since it is all in one draw_ext_info
Definition: media-tags.txt:61
get_season_name
const char * get_season_name(const int index)
Definition: time.cpp:125
CFAPI_OBJECT_PROP_SKILL
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:135
events_register_global_handler
event_registration events_register_global_handler(int eventcode, f_plug_event hook)
Definition: events.cpp:16
CFAPI_OBJECT_PROP_CLIENT_TYPE
#define CFAPI_OBJECT_PROP_CLIENT_TYPE
Definition: plugin.h:147
object_clear
void object_clear(object *op)
Definition: object.cpp:983
region::longname
char * longname
Definition: map.h:280
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:517
plugins_remove_plugin
int plugins_remove_plugin(const char *id)
Definition: plugins.cpp:454
CFAPI_OBJECT_PROP_PATH_DENIED
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:152
CFAPI_MAP_PROP_REGION
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:261
TIMER_ERR_NONE
#define TIMER_ERR_NONE
Definition: timers.h:66
CFAPI_OBJECT_PROP_ANIM_SPEED
#define CFAPI_OBJECT_PROP_ANIM_SPEED
Definition: plugin.h:184
m
static event_registration m
Definition: citylife.cpp:425
cfapi_system_unregister_global_event
static void cfapi_system_unregister_global_event(int *type,...)
Definition: plugins.cpp:606
CFAPI_OBJECT_PROP_AC
#define CFAPI_OBJECT_PROP_AC
Definition: plugin.h:205
events_register_object_handler
void events_register_object_handler(const char *id, f_plug_event handler)
Definition: events.cpp:282
autojail.who
who
Definition: autojail.py:3
cfapi_register_command
static void cfapi_register_command(int *type,...)
Definition: plugins.cpp:4509
transmute_materialname
void transmute_materialname(object *op, const object *change)
Definition: utils.cpp:263
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:1555
object_update
void object_update(object *op, int action)
Definition: object.cpp:1429
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:3947
cfapi_player_find
static void cfapi_player_find(int *type,...)
Definition: plugins.cpp:4001
opendir
DIR * opendir(const char *)
CFAPI_OBJECT_PROP_LORE
#define CFAPI_OBJECT_PROP_LORE
Definition: plugin.h:137
CFAPI_ARCH_PROP_HEAD
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:266
disinfect.map
map
Definition: disinfect.py:4
CFAPI_OBJECT_PROP_PICK_UP
#define CFAPI_OBJECT_PROP_PICK_UP
Definition: plugin.h:163
CFAPI_OBJECT_PROP_MOVE_OFF
#define CFAPI_OBJECT_PROP_MOVE_OFF
Definition: plugin.h:224
FLAG_WAS_WIZ
#define FLAG_WAS_WIZ
Definition: define.h:234
CFAPI_PLAYER_PROP_PARTY
#define CFAPI_PLAYER_PROP_PARTY
Definition: plugin.h:232
command_unregister
void command_unregister(command_registration command)
Definition: commands.cpp:534
hook_entry::func
f_plug_api func
Definition: plugin.h:308
cfapi_player_can_pay
static void cfapi_player_can_pay(int *type,...)
Definition: plugins.cpp:4084
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:118
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:3027
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:4393
object_present_in_ob_by_name
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Definition: object.cpp:3194
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:592
cfapi_object_remove_depletion
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.cpp:3132
CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
Definition: plugin.h:165
CFAPI_REGION_PROP_JAIL_Y
#define CFAPI_REGION_PROP_JAIL_Y
Definition: plugin.h:281
RMParms
Definition: random_map.h:14
CFAPI_OBJECT_PROP_CHEATER
#define CFAPI_OBJECT_PROP_CHEATER
Definition: plugin.h:193
FOR_ABOVE_FINISH
#define FOR_ABOVE_FINISH()
Definition: define.h:694
events_unregister_global_handler
void events_unregister_global_handler(int eventcode, event_registration id)
Definition: events.cpp:23
CFAPI_MAP_PROP_MESSAGE
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:259
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:4241
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:3732
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:2357
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:275
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:3543
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:282
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:1983
NDI_DELAYED
#define NDI_DELAYED
Definition: newclient.h:258
get_periodofday
const char * get_periodofday(const int index)
Definition: time.cpp:104
readdir
struct dirent * readdir(DIR *)
query_short_name
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.cpp:517
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:2286
region::jailmap
char * jailmap
Definition: map.h:286
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:3201
object_update_speed
void object_update_speed(object *op)
Definition: object.cpp:1344
cfapi_system_strdup_local
static void cfapi_system_strdup_local(int *type,...)
Definition: plugins.cpp:571
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Definition: global.h:204
crossfire_plugin::id
char id[MAX_BUF]
Definition: plugin.h:99
CFAPI_OBJECT_PROP_PATH_ATTUNED
#define CFAPI_OBJECT_PROP_PATH_ATTUNED
Definition: plugin.h:150
events_execute_object_user
int events_execute_object_user(object *op, object *activator, object *third, const char *message, int fix)
Definition: events.cpp:300
message
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your message
Definition: survival-guide.txt:34
CFAPI_ARCH_PROP_CLONE
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:268
CFAPI_OBJECT_PROP_EXP
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:190
SET_MAP_FLAGS
#define SET_MAP_FLAGS(M, X, Y, C)
Definition: map.h:160
CFAPI_OBJECT_PROP_SPEED
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:140
CFAPI_OBJECT_PROP_TYPE
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:145
quest_was_completed
int quest_was_completed(player *pl, sstring quest_code)
Definition: quest.cpp:726
CFAPI_OBJECT_PROP_NROF
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:142
object_create_arch
object * object_create_arch(archetype *at)
Definition: arch.cpp:298
CFAPI_PLAYER_PROP_TITLE
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:237
CFAPI_MAP_PROP_PATH
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:247
cfapi_object_transmute
static void cfapi_object_transmute(int *type,...)
Definition: plugins.cpp:3184
object_free
void object_free(object *ob, int flags)
Definition: object.cpp:1587
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:4296
cfapi_unregister_command
static void cfapi_unregister_command(int *type,...)
Definition: plugins.cpp:4544
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
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
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:2168
cfapi_object_teleport
static void cfapi_object_teleport(int *type,...)
Definition: plugins.cpp:4152
CFAPI_PLAYER_QUEST_START
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:240
CFAPI_REGION_PROP_NAME
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:275
cfapi_object_spring_trap
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.cpp:3584
archetype
Definition: object.h:474
CFAPI_OBJECT_PROP_INVISIBLE_TIME
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME
Definition: plugin.h:162
CFAPI_OBJECT_PROP_ATTACK_TYPE
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:149
CFAPI_SYSTEM_MAPS
#define CFAPI_SYSTEM_MAPS
Definition: plugin.h:284
move_to
int move_to(object *op, int x, int y)
Definition: move.cpp:563
CFAPI_REGION_PROP_JAIL_X
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:280
cfapi_get_time
static void cfapi_get_time(int *type,...)
Definition: plugins.cpp:873
Settings::playerdir
const char * playerdir
Definition: global.h:250
cfapi_object_pay_item
static void cfapi_object_pay_item(int *type,...)
Definition: plugins.cpp:3773
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:2359
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
prayer
with a maximum of six This is not so if you are wearing plate you receive no benefit Armour is additive with all the supplementry forms of which means that it lasts until the next semi permanent spell effect is cast upon the character weak special and current protections and immunities dark elf priest killer panther all others vampire that they only take damage from cold based attacks but it also inflicts hp rnd The range of the cone covers(2+Wisdom bonus) squares. spell will not cure poison or disease prayer
Definition: tome-of-magic.txt:203
delete_map
void delete_map(mapstruct *m)
Definition: map.cpp:1696
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:409
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:4171
CFAPI_SYSTEM_REGIONS
#define CFAPI_SYSTEM_REGIONS
Definition: plugin.h:287
cfapi_object_on_same_map
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.cpp:3568
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:2095
object_create_clone
object * object_create_clone(object *asrc)
Definition: object.cpp:3900
CFAPI_PARTY_PROP_NEXT
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:271
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:155
P_OUT_OF_MAP
#define P_OUT_OF_MAP
Definition: map.h:248
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:249
object_set_cheat
void object_set_cheat(object *op)
Definition: object.cpp:3265
object_new
object * object_new(void)
Definition: object.cpp:1268
create_overlay_pathname
void create_overlay_pathname(const char *name, char *buf, size_t size)
Definition: map.cpp:124
UP_OBJ_INSERT
#define UP_OBJ_INSERT
Definition: object.h:521
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.cpp:955
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:3159
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:279
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
Settings::disabled_plugins
std::vector< char * > disabled_plugins
Definition: global.h:326
CFAPI_DOUBLE
#define CFAPI_DOUBLE
Definition: plugin.h:61
CFAPI_OBJECT_PROP_CONTAINER
#define CFAPI_OBJECT_PROP_CONTAINER
Definition: plugin.h:127
change_abil
int change_abil(object *op, object *tmp)
Definition: living.cpp:394
send_changed_object
static void send_changed_object(object *op)
Definition: plugins.cpp:301
CFAPI_OBJECT_PROP_INVENTORY
#define CFAPI_OBJECT_PROP_INVENTORY
Definition: plugin.h:124
CFAPI_OBJECT_PROP_MAP
#define CFAPI_OBJECT_PROP_MAP
Definition: plugin.h:128
CFAPI_MAP_PROP_FLAGS
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:245
cfapi_system_find_string
static void cfapi_system_find_string(int *type,...)
Definition: plugins.cpp:760
cfapi_system_remove_string
static void cfapi_system_remove_string(int *type,...)
Definition: plugins.cpp:742
region
Definition: map.h:273
CFAPI_MAP_PROP_DARKNESS
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:254
CFAPI_MAP_PROP_PLAYERS
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:252
FLAG_REMOVED
#define FLAG_REMOVED
Definition: define.h:232
CFAPI_OBJECT_PROP_RUN_AWAY
#define CFAPI_OBJECT_PROP_RUN_AWAY
Definition: plugin.h:174
object_decrease_nrof
object * object_decrease_nrof(object *op, uint32_t i)
Definition: object.cpp:2667
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:251
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:273
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:241
CFAPI_MAP_PROP_DIFFICULTY
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:246
find_archetype_by_object_name
archetype * find_archetype_by_object_name(const char *name)
Definition: arch.cpp:53
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:3092
cfapi_object_give_skill
static void cfapi_object_give_skill(int *type,...)
Definition: plugins.cpp:3167
cfapi_generate_random_map
static void cfapi_generate_random_map(int *type,...)
Definition: plugins.cpp:4415
CFAPI_OBJECT_PROP_ANIMATION
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:218
AssetsCollection::each
void each(std::function< void(T *)> op)
Definition: AssetsCollection.h:158
object_find_by_arch_name
object * object_find_by_arch_name(const object *who, const char *name)
Definition: object.cpp:4243
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:3151
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:289
cleanupPlugins
void cleanupPlugins(void)
Definition: plugins.cpp:4612
object_can_pick
int object_can_pick(const object *who, const object *item)
Definition: object.cpp:3858
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:242
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:299
reputation.victim
victim
Definition: reputation.py:14
is_magical
int is_magical(const object *op)
Definition: item.cpp:1231
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:238
mapstruct
Definition: map.h:314
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:103
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:4061
f_plug_event
int(* f_plug_event)(int *type,...)
Definition: events.h:67
sstring
const typedef char * sstring
Definition: sstring.h:2
give.op
op
Definition: give.py:33
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:2628
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:3550
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:3896
object_set_msg
void object_set_msg(object *op, const char *msg)
Definition: object.cpp:4802
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:2625
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
Settings::mapdir
const char * mapdir
Definition: global.h:251
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:3320
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
player
the faster the spell may be cast there are several other common only the caster may be affected by the spell The most common spell range is that of touch This denotes that the caster much touch the recipient of the spell in order to release the spell or wall For cone it usually denotes that the range depends on some such as the caster s Wisdom level If this is the it will be stated in the long spell description or the standard duration for the spell expires Only one protection or change player attribute spell may be in effect on a player at any one time If another such spell is cast upon a player
Definition: spell-info.txt:68
cfapi_get_periodofday_name
static void cfapi_get_periodofday_name(int *type,...)
Definition: plugins.cpp:940
level
int level
Definition: readable.cpp:1550
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:1295
object_distance
int object_distance(const object *ob1, const object *ob2)
Definition: object.cpp:3652
CFAPI_MAP_PROP_ENTER_Y
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:258
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:4016
CFAPI_OBJECT_PROP_MOVE_ALLOW
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:222
Face
Definition: face.h:14
knowledge_give
void knowledge_give(player *pl, const char *marker, const object *book)
Definition: knowledge.cpp:993
get_region_by_map
region * get_region_by_map(mapstruct *m)
Definition: region.cpp:72
Settings::datadir
const char * datadir
Definition: global.h:248
CFAPI_ARCH_PROP_MORE
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:267
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
skill
skill
Definition: arch-handbook.txt:585
CFAPI_SYSTEM_PARTIES
#define CFAPI_SYSTEM_PARTIES
Definition: plugin.h:288
cfapi_log
static void cfapi_log(int *type,...)
Definition: plugins.cpp:1007
object_remove
void object_remove(object *op)
Definition: object.cpp:1828
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
quest.state
state
Definition: quest.py:13
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:3752
get_month_name
const char * get_month_name(const int index)
Definition: time.cpp:111
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:256
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
code
Crossfire Architecture the general intention is to enhance the enjoyability and playability of CF In this code
Definition: arch-handbook.txt:14
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:311
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:525
calculate_difficulty
int calculate_difficulty(mapstruct *m)
Definition: map.cpp:1885
Animations
Definition: face.h:25
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2608
cfapi_object_apply
static void cfapi_object_apply(int *type,...)
Definition: plugins.cpp:3047
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:693
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:4042
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:4490
Face::number
uint16_t number
Definition: face.h:15
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
cfapi_player_knowledge
static void cfapi_player_knowledge(int *type,...)
Definition: plugins.cpp:4103
freearr_x
short freearr_x[SIZEOFFREE]
Definition: object.cpp:299
CFAPI_PLAYER_QUEST_WAS_COMPLETED
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED
Definition: plugin.h:243
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
plugin
pluglist shows those as well as a short text describing each the list will simply appear empty The keyword for the Python plugin is Python plugout< keyword > Unloads a given plugin
Definition: plugins.txt:15
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:3669
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:3650
CUSTOM_NAME_FIELD
#define CUSTOM_NAME_FIELD
Definition: object.h:98
Settings::confdir
const char * confdir
Definition: global.h:247
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:200
CFAPI_PARTY_PROP_PASSWORD
#define CFAPI_PARTY_PROP_PASSWORD
Definition: plugin.h:272
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:3461
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:3249
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:3697
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:287
cfapi_map_trigger_connected
static void cfapi_map_trigger_connected(int *type,...)
Definition: plugins.cpp:3630
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:3912
region::jailx
int16_t jailx
Definition: map.h:287
cfapi_object_set_property
static void cfapi_object_set_property(int *type,...)
Definition: plugins.cpp:2374
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
trigger_connected
void trigger_connected(objectlink *ol, object *cause, const int state)
Definition: button.cpp:41
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:3603
cfapi_object_clear
static void cfapi_object_clear(int *type,...)
Definition: plugins.cpp:3525
identify
object * identify(object *op)
Definition: item.cpp:1425
level
Definition: level.py:1
diamondslots.id
id
Definition: diamondslots.py:53