Crossfire Server, Trunk  1.75.0
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 #include "server.h"
44 
45 #ifdef WIN32
46 #include "libloaderapi.h"
47 #endif
48 
50 #define NR_OF_HOOKS (sizeof(plug_hooks)/sizeof(*plug_hooks))
51 
52 static void cfapi_cost_string_from_value(int *type, ...);
53 static void cfapi_system_find_animation(int *type, ...);
54 static void cfapi_system_find_face(int *type, ...);
55 static void cfapi_system_strdup_local(int *type, ...);
56 static void cfapi_system_register_global_event(int *type, ...);
57 static void cfapi_system_unregister_global_event(int *type, ...);
58 static void cfapi_system_add_string(int *type, ...);
59 static void cfapi_system_remove_string(int *type, ...);
60 static void cfapi_system_find_string(int *type, ...);
61 static void cfapi_system_check_path(int *type, ...);
62 static void cfapi_system_re_cmp(int *type, ...);
63 static void cfapi_system_directory(int *type, ...);
64 static void cfapi_get_time(int *type, ...);
65 static void cfapi_get_season_name(int *type, ...);
66 static void cfapi_get_weekday_name(int *type, ...);
67 static void cfapi_get_month_name(int *type, ...);
68 static void cfapi_get_periodofday_name(int *type, ...);
69 static void cfapi_timer_create(int *type, ...);
70 static void cfapi_timer_destroy(int *type, ...);
71 static void cfapi_log(int *type, ...);
72 static void cfapi_map_get_map(int *type, ...);
73 static void cfapi_map_has_been_loaded(int *type, ...);
74 static void cfapi_map_create_path(int *type, ...);
75 static void cfapi_map_get_map_property(int *type, ...);
76 static void cfapi_map_set_map_property(int *type, ...);
77 static void cfapi_map_out_of_map(int *type, ...);
78 static void cfapi_map_update_position(int *type, ...);
79 static void cfapi_map_delete_map(int *type, ...);
80 static void cfapi_map_message(int *type, ...);
81 static void cfapi_map_get_object_at(int *type, ...);
82 static void cfapi_map_find_by_archetype_name(int *type, ...);
83 static void cfapi_map_change_light(int *type, ...);
84 static void cfapi_object_move(int *type, ...);
85 static void cfapi_object_get_key(int *type, ...);
86 static void cfapi_object_set_key(int *type, ...);
87 static void cfapi_object_get_property(int *type, ...);
88 static void cfapi_object_set_property(int *type, ...);
89 static void cfapi_object_apply_below(int *type, ...);
90 static void cfapi_object_apply(int *type, ...);
91 static void cfapi_object_identify(int *type, ...);
92 static void cfapi_object_describe(int *type, ...);
93 static void cfapi_object_drain(int *type, ...);
94 static void cfapi_object_remove_depletion(int *type, ...);
95 static void cfapi_object_fix(int *type, ...);
96 static void cfapi_object_give_skill(int *type, ...);
97 static void cfapi_object_transmute(int *type, ...);
98 static void cfapi_object_remove(int *type, ...);
99 static void cfapi_object_delete(int *type, ...);
100 static void cfapi_object_clone(int *type, ...);
101 static void cfapi_object_create(int *type, ...);
102 static void cfapi_object_insert(int *type, ...);
103 static void cfapi_object_split(int *type, ...);
104 static void cfapi_object_merge(int *type, ...);
105 static void cfapi_object_distance(int *type, ...);
106 static void cfapi_object_update(int *type, ...);
107 static void cfapi_object_clear(int *type, ...);
108 static void cfapi_object_reset(int *type, ...);
109 static void cfapi_object_clean_object(int *type, ...);
110 static void cfapi_object_on_same_map(int *type, ...);
111 static void cfapi_object_spring_trap(int *type, ...);
112 static void cfapi_object_check_trigger(int *type, ...);
113 static void cfapi_map_trigger_connected(int *type, ...);
114 static void cfapi_object_query_money(int *type, ...);
115 static void cfapi_object_cast(int *type, ...);
116 static void cfapi_object_learn_spell(int *type, ...);
117 static void cfapi_object_forget_spell(int *type, ...);
118 static void cfapi_object_check_spell(int *type, ...);
119 static void cfapi_object_pay_amount(int *type, ...);
120 static void cfapi_object_pay_item(int *type, ...);
121 static void cfapi_object_transfer(int *type, ...);
122 static void cfapi_object_find_archetype_inside(int *type, ...);
123 static void cfapi_object_find_by_arch_name(int *type, ...);
124 static void cfapi_object_find_by_name(int *type, ...);
125 static void cfapi_object_drop(int *type, ...);
126 static void cfapi_object_change_abil(int *type, ...);
127 static void cfapi_object_say(int *type, ...);
128 static void cfapi_player_find(int *type, ...);
129 static void cfapi_player_message(int *type, ...);
130 static void cfapi_object_change_exp(int *type, ...);
131 static void cfapi_player_can_pay(int *type, ...);
132 static void cfapi_player_knowledge(int *type, ...);
133 static void cfapi_object_teleport(int *type, ...);
134 static void cfapi_object_pickup(int *type, ...);
135 static void cfapi_archetype_get_property(int *type, ...);
136 static void cfapi_party_get_property(int *type, ...);
137 static void cfapi_region_get_property(int *type, ...);
138 static void cfapi_friendlylist_get_next(int *type, ...);
139 static void cfapi_set_random_map_variable(int *type, ...);
140 static void cfapi_generate_random_map(int *type, ...);
141 static void cfapi_object_user_event(int *type, ...);
142 static void cfapi_player_quest(int *type, ...);
143 static void cfapi_object_perm_exp(int *type, ...);
144 static void cfapi_register_command(int *type, ...);
145 static void cfapi_unregister_command(int *type, ...);
146 static void cfapi_system_get_object_vector(int *type, ...);
147 static void cfapi_system_get_map_vector(int *type, ...);
148 static void cfapi_system_get_archetype_vector(int *type, ...);
149 static void cfapi_system_get_party_vector(int *type, ...);
150 static void cfapi_system_get_region_vector(int *type, ...);
151 
155 static const hook_entry plug_hooks[] = {
156  { cfapi_system_add_string, 0, "cfapi_system_add_string" },
157  { cfapi_system_register_global_event, 1, "cfapi_system_register_global_event" },
158  { cfapi_system_remove_string, 2, "cfapi_system_remove_string" },
159  { cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event" },
160  { cfapi_system_check_path, 4, "cfapi_system_check_path" },
161  { cfapi_system_re_cmp, 5, "cfapi_system_re_cmp" },
162  { cfapi_system_strdup_local, 6, "cfapi_system_strdup_local" },
163  { cfapi_system_directory, 7, "cfapi_system_directory" },
164  { cfapi_system_find_animation, 8, "cfapi_system_find_animation" },
165  { cfapi_object_clean_object, 9, "cfapi_object_clean_object" },
166  { cfapi_object_on_same_map, 10, "cfapi_object_on_same_map" },
167  { cfapi_object_get_key, 11, "cfapi_object_get_key" },
168  { cfapi_object_set_key, 12, "cfapi_object_set_key" },
169  { cfapi_object_get_property, 13, "cfapi_object_get_property" },
170  { cfapi_object_set_property, 14, "cfapi_object_set_property" },
171  { cfapi_object_apply, 15, "cfapi_object_apply" },
172  { cfapi_object_identify, 16, "cfapi_object_identify" },
173  { cfapi_object_describe, 17, "cfapi_object_describe" },
174  { cfapi_object_drain, 18, "cfapi_object_drain" },
175  { cfapi_object_fix, 19, "cfapi_object_fix" },
176  { cfapi_object_give_skill, 20, "cfapi_object_give_skill" },
177  { cfapi_object_transmute, 21, "cfapi_object_transmute" },
178  { cfapi_object_remove, 22, "cfapi_object_remove" },
179  { cfapi_object_delete, 23, "cfapi_object_delete" },
180  { cfapi_object_clone, 24, "cfapi_object_clone" },
181  { cfapi_object_create, 26, "cfapi_object_create" },
182  { cfapi_object_insert, 27, "cfapi_object_insert" },
183  { cfapi_object_split, 28, "cfapi_object_split" },
184  { cfapi_object_merge, 29, "cfapi_object_merge" },
185  { cfapi_object_distance, 30, "cfapi_object_distance" },
186  { cfapi_object_update, 31, "cfapi_object_update" },
187  { cfapi_object_clear, 32, "cfapi_object_clear" },
188  { cfapi_object_reset, 33, "cfapi_object_reset" },
189  { cfapi_object_spring_trap, 35, "cfapi_object_spring_trap" },
190  { cfapi_object_check_trigger, 36, "cfapi_object_check_trigger" },
191  { cfapi_object_query_money, 38, "cfapi_object_query_money" },
192  { cfapi_object_cast, 39, "cfapi_object_cast" },
193  { cfapi_object_learn_spell, 40, "cfapi_object_learn_spell" },
194  { cfapi_object_forget_spell, 41, "cfapi_object_forget_spell" },
195  { cfapi_object_check_spell, 42, "cfapi_object_check_spell" },
196  { cfapi_object_pay_amount, 43, "cfapi_object_pay_amount" },
197  { cfapi_object_pay_item, 44, "cfapi_object_pay_item" },
198  { cfapi_object_transfer, 45, "cfapi_object_transfer" },
199  { cfapi_object_drop, 46, "cfapi_object_drop" },
200  { cfapi_object_change_abil, 47, "cfapi_object_change_abil" },
201  { cfapi_object_find_archetype_inside, 48, "cfapi_object_find_archetype_inside" },
202  { cfapi_object_say, 49, "cfapi_object_say" },
203  { cfapi_map_get_map, 50, "cfapi_map_get_map" },
204  { cfapi_map_has_been_loaded, 51, "cfapi_map_has_been_loaded" },
205  { cfapi_map_create_path, 52, "cfapi_map_create_path" },
206  { cfapi_map_get_map_property, 53, "cfapi_map_get_property" },
207  { cfapi_map_set_map_property, 54, "cfapi_map_set_property" },
208  { cfapi_map_out_of_map, 55, "cfapi_map_out_of_map" },
209  { cfapi_map_update_position, 56, "cfapi_map_update_position" },
210  { cfapi_map_delete_map, 57, "cfapi_map_delete_map" },
211  { cfapi_map_message, 58, "cfapi_map_message" },
212  { cfapi_map_get_object_at, 59, "cfapi_map_get_object_at" },
213  { cfapi_map_change_light, 60, "cfapi_map_change_light" },
214  { cfapi_map_find_by_archetype_name, 61, "cfapi_map_find_by_archetype_name" },
215  { cfapi_player_find, 62, "cfapi_player_find" },
216  { cfapi_player_message, 63, "cfapi_player_message" },
217  { cfapi_object_change_exp, 64, "cfapi_object_change_exp" },
218  { cfapi_object_teleport, 65, "cfapi_object_teleport" },
219  { cfapi_object_pickup, 67, "cfapi_object_pickup" },
220  { cfapi_object_move, 68, "cfapi_object_move" },
221  { cfapi_object_apply_below, 69, "cfapi_object_apply_below" },
222  { cfapi_generate_random_map, 70, "cfapi_generate_random_map" },
223  { cfapi_archetype_get_property, 71, "cfapi_archetype_get_property" },
224  { cfapi_party_get_property, 72, "cfapi_party_get_property" },
225  { cfapi_region_get_property, 73, "cfapi_region_get_property" },
226  { cfapi_player_can_pay, 74, "cfapi_player_can_pay" },
227  { cfapi_log, 75, "cfapi_log" },
228  { cfapi_get_time, 76, "cfapi_system_get_time" },
229  { cfapi_timer_create, 77, "cfapi_system_timer_create" },
230  { cfapi_timer_destroy, 78, "cfapi_system_timer_destroy" },
231  { cfapi_friendlylist_get_next, 79, "cfapi_friendlylist_get_next" },
232  { cfapi_set_random_map_variable, 80, "cfapi_set_random_map_variable" },
233  { cfapi_system_find_face, 81, "cfapi_system_find_face" },
234  { cfapi_get_season_name, 82, "cfapi_system_get_season_name" },
235  { cfapi_get_month_name, 83, "cfapi_system_get_month_name" },
236  { cfapi_get_weekday_name, 84, "cfapi_system_get_weekday_name" },
237  { cfapi_get_periodofday_name, 85, "cfapi_system_get_periodofday_name" },
238  { cfapi_map_trigger_connected, 86, "cfapi_map_trigger_connected" },
239  { cfapi_object_user_event, 87, "cfapi_object_user_event" },
240  { cfapi_system_find_string, 88, "cfapi_system_find_string" },
241  { cfapi_cost_string_from_value, 90, "cfapi_cost_string_from_value" },
242  { cfapi_player_quest, 91, "cfapi_player_quest" },
243  { cfapi_object_remove_depletion, 92, "cfapi_object_remove_depletion" },
244  { cfapi_object_find_by_arch_name, 93, "cfapi_object_find_by_arch_name" },
245  { cfapi_object_find_by_name, 94, "cfapi_object_find_by_name" },
246  { cfapi_player_knowledge, 95, "cfapi_player_knowledge" },
247  { cfapi_object_perm_exp, 96, "cfapi_object_perm_exp" },
248  { cfapi_register_command, 97, "cfapi_register_command" },
249  { cfapi_unregister_command, 98, "cfapi_unregister_command" },
250  { cfapi_system_get_object_vector, 99, "cfapi_get_object_vector" },
251  { cfapi_system_get_map_vector, 100, "cfapi_get_map_vector" },
252  { cfapi_system_get_archetype_vector, 101, "cfapi_get_archetype_vector" },
253  { cfapi_system_get_party_vector, 102, "cfapi_get_party_vector" },
254  { cfapi_system_get_region_vector, 103, "cfapi_get_region_vector" },
255 };
256 
258 std::vector<crossfire_plugin *> plugins_list;
259 
260 /*****************************************************************************/
261 /* NEW PLUGIN STUFF STARTS HERE */
262 /*****************************************************************************/
263 
269 static crossfire_plugin *plugins_find_plugin(const char *id) {
270  for (crossfire_plugin *plugin : plugins_list) {
271  if (!strcmp(id, plugin->id)) {
272  return plugin;
273  }
274  }
275  return NULL;
276 }
277 
278 #ifdef WIN32
279 static const char *plugins_dlerror(void)
280 {
281  static char buf[256];
282  DWORD err;
283  char *p;
284 
285  err = GetLastError();
286  if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof (buf), NULL) == 0)
287  snprintf(buf, sizeof (buf), "error %lu", err);
288  p = strchr(buf, '\0');
289  while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
290  p--;
291  *p = '\0';
292  return buf;
293 }
294 
295 #endif /* WIN32 */
296 
302 static void send_changed_object(object *op) {
303  object *tmp;
304  player *pl;
305 
306  if (op->env != NULL) {
307  tmp = object_get_player_container(op->env);
308  if (!tmp) {
309  for (pl = first_player; pl; pl = pl->next)
310  if (pl->ob->container == op->env)
311  break;
312  if (pl)
313  tmp = pl->ob;
314  else
315  tmp = NULL;
316  }
317  if (tmp)
318  /* We don't know what changed, so we send everything. */
319  esrv_update_item(UPD_ALL, tmp, op);
320  } else {
321  FOR_ABOVE_PREPARE(op, tmp)
322  if (tmp->type == PLAYER)
323  tmp->contr->socket->update_look = 1;
325  }
326 }
327 
328 static void cfapi_get_hooks(int *type, ...) {
329  va_list args;
330  int request_type;
331  char *buf;
332  f_plug_api *rapi;
333 
334  *type = CFAPI_NONE;
335 
336  va_start(args, type);
337  request_type = va_arg(args, int);
338  if (request_type == 0) { /* By nr */
339  size_t fid;
340 
341  fid = va_arg(args, int);
342  rapi = va_arg(args, f_plug_api *);
343  if (fid >= NR_OF_HOOKS) {
344  *rapi = NULL;
345  *type = CFAPI_NONE;
346  } else {
347  *rapi = plug_hooks[fid].func;
348  *type = CFAPI_FUNC;
349  }
350  } else { /* by name */
351  size_t i;
352 
353  buf = va_arg(args, char *);
354  rapi = va_arg(args, f_plug_api *);
355  *rapi = NULL;
356  *type = CFAPI_NONE;
357  for (i = 0; i < NR_OF_HOOKS; i++) {
358  if (!strcmp(buf, plug_hooks[i].fname)) {
359  *rapi = plug_hooks[i].func;
360  *type = CFAPI_FUNC;
361  break;
362  }
363  }
364  }
365  va_end(args);
366 }
367 
374 int plugins_init_plugin(const char *libfile) {
375  LIBPTRTYPE ptr;
376  f_plug_init initfunc;
377  f_plug_property propfunc;
378  f_plug_event eventfunc;
379  f_plug_postinit postfunc;
380  f_plug_postinit closefunc;
381  int i;
382  crossfire_plugin *cp;
383  char *svn_rev;
384 
385 
386  /* Open the plugin lib and load the required functions */
387  ptr = plugins_dlopen(libfile);
388  if (ptr == NULL) {
389  LOG(llevError, "Error trying to load %s: %s\n", libfile, plugins_dlerror());
390  return -1;
391  }
392  svn_rev = (char*) plugins_dlsym(ptr, "SvnRevPlugin");
393  if (svn_rev == NULL) {
394  LOG(llevError, "Unable to find SvnRevPlugin in %s\n", libfile);
395  plugins_dlclose(ptr);
396  return -1;
397  }
398  if (settings.ignore_plugin_compatibility == 0 && strcmp(svn_rev, SVN_REV)) {
399  LOG(llevError, "Version mismatch in in %s (%s != %s)\n", libfile, svn_rev, SVN_REV);
400  plugins_dlclose(ptr);
401  return -1;
402  }
403 
404  initfunc = (f_plug_init)plugins_dlsym(ptr, "initPlugin");
405  if (initfunc == NULL) {
406  LOG(llevError, "Plugin error while requesting %s.initPlugin: %s\n", libfile, plugins_dlerror());
407  plugins_dlclose(ptr);
408  return -1;
409  }
410  propfunc = (f_plug_property)plugins_dlsym(ptr, "getPluginProperty");
411  if (propfunc == NULL) {
412  LOG(llevError, "Plugin error while requesting %s.getPluginProperty: %s\n", libfile, plugins_dlerror());
413  plugins_dlclose(ptr);
414  return -1;
415  }
416  eventfunc = (f_plug_event)plugins_dlsym(ptr, "eventListener");
417  if (eventfunc == NULL) {
418  LOG(llevError, "Plugin error while requesting %s.eventListener: %s\n", libfile, plugins_dlerror());
419  plugins_dlclose(ptr);
420  return -1;
421  }
422  postfunc = (f_plug_postinit)plugins_dlsym(ptr, "postInitPlugin");
423  if (postfunc == NULL) {
424  LOG(llevError, "Plugin error while requesting %s.postInitPlugin: %s\n", libfile, plugins_dlerror());
425  plugins_dlclose(ptr);
426  return -1;
427  }
428  closefunc = (f_plug_postinit)plugins_dlsym(ptr, "closePlugin");
429  if (closefunc == NULL) {
430  LOG(llevError, "Plugin error while requesting %s.closePlugin: %s\n", libfile, plugins_dlerror());
431  plugins_dlclose(ptr);
432  return -1;
433  }
434  i = initfunc("2.0", cfapi_get_hooks);
435  cp = static_cast<crossfire_plugin *>(malloc(sizeof(crossfire_plugin)));
436  for (i = 0; i < NR_EVENTS; i++)
437  cp->global_registration[i] = 0;
438  cp->propfunc = propfunc;
439  cp->closefunc = closefunc;
440  cp->libptr = ptr;
441  propfunc(&i, "Identification", cp->id, sizeof(cp->id));
442  propfunc(&i, "FullName", cp->fullname, sizeof(cp->fullname));
443  events_register_object_handler(cp->id, eventfunc);
444  plugins_list.push_back(cp);
445  postfunc();
446  return 0;
447 }
448 
455 int plugins_remove_plugin(const char *id) {
456  auto plugin = std::find_if(plugins_list.begin(), plugins_list.end(), [&id] (const auto cp) { return strcmp(id, cp->id) == 0; });
457  if (plugin != plugins_list.end()) {
458  crossfire_plugin *cp = *plugin;
459  plugins_list.erase(plugin);
460  for (int eventcode = 0; eventcode < NR_EVENTS; eventcode++) {
461  if (cp->global_registration[eventcode]) {
462  events_unregister_global_handler(eventcode, cp->global_registration[eventcode]);
463  }
464  }
466  if (cp->closefunc)
467  cp->closefunc();
468  plugins_dlclose(cp->libptr);
469  free(cp);
470  return 0;
471  }
472  return -1;
473 }
474 
480 void plugins_display_list(object *op) {
482  "List of loaded plugins:\n-----------------------");
483 
484  for (crossfire_plugin *cp : plugins_list) {
486  "%s, %s",
487  cp->id, cp->fullname);
488  }
489 }
490 
491 /* SYSTEM-RELATED HOOKS */
492 
498 static void cfapi_cost_string_from_value(int *type, ...) {
499  uint64_t cost;
500  char *buffer, *final;
501  int length, largest_coin;
502  va_list args;
503 
504  va_start(args, type);
505  cost = va_arg(args, uint64_t);
506  largest_coin = va_arg(args, int);
507  buffer = va_arg(args, char*);
508  length = va_arg(args, int);
509  va_end(args);
510 
511  *type = CFAPI_NONE;
512 
513  if (length < 1)
514  return;
515 
516  final = cost_string_from_value(cost, largest_coin);
517 
518  strncpy(buffer, final, length - 1);
519  buffer[length - 1] = '\0';
520  free(final);
521 }
522 
528 static void cfapi_system_find_animation(int *type, ...) {
529  va_list args;
530  const char *name;
531  int *num;
532  const Animations *anim;
533 
534  va_start(args, type);
535  name = va_arg(args, const char *);
536  num = va_arg(args, int *);
537  va_end(args);
538 
539  anim = try_find_animation(name);
540  (*num) = anim ? anim->num : 0;
541  *type = CFAPI_INT;
542 }
543 
549 static void cfapi_system_find_face(int *type, ...) {
550  va_list args;
551  const char *face;
552  int error;
553  int *num;
554  const Face *f;
555 
556  va_start(args, type);
557  face = va_arg(args, const char *);
558  error = va_arg(args, int);
559  num = va_arg(args, int *);
560  va_end(args);
561 
562  f = try_find_face(face, get_face_by_id(error));
563  (*num) = f ? f->number : 0;
564  *type = CFAPI_INT;
565 }
566 
572 static void cfapi_system_strdup_local(int *type, ...) {
573  va_list args;
574  const char *txt;
575  char **ret;
576 
577  va_start(args, type);
578  txt = va_arg(args, const char *);
579  ret = va_arg(args, char **);
580  va_end(args);
581 
582  *ret = strdup_local(txt);
583  *type = CFAPI_STRING;
584 }
585 
586 static void cfapi_system_register_global_event(int *type, ...) {
587  va_list args;
588  int eventcode;
589  char *pname;
590  f_plug_event hook;
591  crossfire_plugin *cp;
592 
593  va_start(args, type);
594  eventcode = va_arg(args, int);
595  pname = va_arg(args, char *);
596  hook = va_arg(args, f_plug_event);
597  va_end(args);
598 
599  *type = CFAPI_NONE;
600 
601  cp = plugins_find_plugin(pname);
602  if (!cp->global_registration[eventcode]) {
603  cp->global_registration[eventcode] = events_register_global_handler(eventcode, hook);
604  }
605 }
606 
608  va_list args;
609  int eventcode;
610  char *pname;
611  crossfire_plugin *cp;
612 
613  va_start(args, type);
614  eventcode = va_arg(args, int);
615  pname = va_arg(args, char *);
616  va_end(args);
617 
618  *type = CFAPI_NONE;
619 
620  cp = plugins_find_plugin(pname);
621  if (cp->global_registration[eventcode]) {
622  events_unregister_global_handler(eventcode, cp->global_registration[eventcode]);
623  cp->global_registration[eventcode] = 0;
624  }
625 }
626 
627 static void cfapi_system_get_object_vector(int *type, ...) {
628  va_list args;
629  va_start(args, type);
630  int property = va_arg(args, int);
631  std::vector<object *> *list = va_arg(args, std::vector<object *> *);
632 
634  switch (property) {
636  for (auto pl = first_player; pl ; pl = pl->next) {
637  list->push_back(pl->ob);
638  }
639  break;
641  auto f = get_next_friend(nullptr);
642  while (f) {
643  list->push_back(f);
644  f = get_next_friend(f);
645  }
646  break;
647  }
648  default:
649  assert(0);
650  }
651 
652  va_end(args);
653 }
654 
655 static void cfapi_system_get_map_vector(int *type, ...) {
656  va_list args;
657  va_start(args, type);
658  int property = va_arg(args, int);
659  std::vector<mapstruct *> *list = va_arg(args, std::vector<mapstruct *> *);
660 
662  if (property == CFAPI_SYSTEM_MAPS) {
663  for (auto map = first_map; map ; map = map->next) {
664  list->push_back(map);
665  }
666  }
667 
668  va_end(args);
669 }
670 
671 static void cfapi_system_get_archetype_vector(int *type, ...) {
672  va_list args;
673  va_start(args, type);
674  int property = va_arg(args, int);
675  std::vector<archetype *> *list = va_arg(args, std::vector<archetype *> *);
676 
678  if (property == CFAPI_SYSTEM_ARCHETYPES) {
679  getManager()->archetypes()->each([&] (const auto &arch) { list->push_back(arch); });
680  }
681 
682  va_end(args);
683 }
684 
685 static void cfapi_system_get_region_vector(int *type, ...) {
686  va_list args;
687  va_start(args, type);
688  int property = va_arg(args, int);
689  std::vector<region *> *list = va_arg(args, std::vector<region *> *);
690 
692  if (property == CFAPI_SYSTEM_REGIONS) {
693  *list = all_regions;
694  }
695 
696  va_end(args);
697 }
698 
699 static void cfapi_system_get_party_vector(int *type, ...) {
700  va_list args;
701  va_start(args, type);
702  int property = va_arg(args, int);
703  std::vector<partylist *> *list = va_arg(args, std::vector<partylist *> *);
704 
706  if (property == CFAPI_SYSTEM_PARTIES) {
707  auto party = party_get_first();
708  while (party) {
709  list->push_back(party);
710  party = party_get_next(party);
711  }
712  }
713 
714  va_end(args);
715 }
716 
723 static void cfapi_system_add_string(int *type, ...) {
724  va_list args;
725  const char *str;
726  sstring *rv;
727 
728  va_start(args, type);
729  str = va_arg(args, const char *);
730  rv = va_arg(args, sstring *);
731  va_end(args);
732 
733  *rv = add_string(str);
734  *type = CFAPI_SSTRING;
735 }
736 
743 static void cfapi_system_remove_string(int *type, ...) {
744  va_list args;
745  sstring str;
746 
747  va_start(args, type);
748  str = va_arg(args, sstring);
749  va_end(args);
750 
751  free_string(str);
752  *type = CFAPI_NONE;
753 }
754 
761 static void cfapi_system_find_string(int *type, ...) {
762  va_list args;
763  const char *str;
764  sstring *rv;
765 
766  va_start(args, type);
767  str = va_arg(args, const char *);
768  rv = va_arg(args, sstring *);
769  va_end(args);
770 
771  *rv = find_string(str);
772  *type = CFAPI_SSTRING;
773 }
774 
780 static void cfapi_system_check_path(int *type, ...) {
781  va_list args;
782  const char *name;
783  int prepend_dir;
784  int *ret;
785 
786  va_start(args, type);
787 
788  name = va_arg(args, char *);
789  prepend_dir = va_arg(args, int);
790  ret = va_arg(args, int *);
791 
792  *ret = check_path(name, prepend_dir);
793 
794  va_end(args);
795  *type = CFAPI_INT;
796 }
797 
803 static void cfapi_system_re_cmp(int *type, ...) {
804  va_list args;
805  const char *str;
806  const char *regexp;
807  const char **rv;
808 
809  va_start(args, type);
810 
811  str = va_arg(args, char *);
812  regexp = va_arg(args, char *);
813  rv = va_arg(args, const char **);
814 
815  *rv = re_cmp(str, regexp);
816 
817  va_end(args);
818  *type = CFAPI_STRING;
819 }
820 
821 static void cfapi_system_directory(int *type, ...) {
822  va_list args;
823  int dirtype;
824  const char **str;
825 
826  va_start(args, type);
827 
828  dirtype = va_arg(args, int);
829  str = va_arg(args, const char **);
830  va_end(args);
831 
832  *type = CFAPI_STRING;
833 
834  switch (dirtype) {
835  case 0:
836  *str = settings.mapdir;
837  break;
838 
839  case 1:
840  *str = settings.uniquedir;
841  break;
842 
843  case 2:
844  *str = settings.tmpdir;
845  break;
846 
847  case 3:
848  *str = settings.confdir;
849  break;
850 
851  case 4:
852  *str = settings.localdir;
853  break;
854 
855  case 5:
856  *str = settings.playerdir;
857  break;
858 
859  case 6:
860  *str = settings.datadir;
861  break;
862 
863  default:
864  *str = NULL;
865  }
866 }
867 
874 static void cfapi_get_time(int *type, ...) {
875  va_list args;
876  timeofday_t *tod;
877 
878  va_start(args, type);
879  tod = va_arg(args, timeofday_t *);
880  va_end(args);
881 
882  get_tod(tod);
883  *type = CFAPI_NONE;
884 }
885 
886 #define string_get_int(name) \
887  va_list args; \
888  int index; \
889  const char **str; \
890  va_start(args, type); \
891  index = va_arg(args, int); \
892  str = va_arg(args, const char **); \
893  va_end(args); \
894  *str = name(index); \
895  *type = CFAPI_STRING; \
896 
897 
905 static void cfapi_get_season_name(int *type, ...) {
907 }
908 
917 static void cfapi_get_weekday_name(int *type, ...) {
919 }
920 
929 static void cfapi_get_month_name(int *type, ...) {
931 }
932 
941 static void cfapi_get_periodofday_name(int *type, ...) {
943 }
944 
956 static void cfapi_timer_create(int *type, ...) {
957  va_list args;
958  int res;
959  object *ob;
960  long delay;
961  int mode;
962  int *timer;
963 
964  va_start(args, type);
965  ob = va_arg(args, object *);
966  delay = va_arg(args, long);
967  mode = va_arg(args, int);
968  timer = va_arg(args, int *);
969  va_end(args);
970  *type = CFAPI_INT;
971 
972  *timer = cftimer_find_free_id();
973  if (*timer != TIMER_ERR_ID) {
974  res = cftimer_create(*timer, delay, ob, mode);
975  if (res != TIMER_ERR_NONE)
976  *timer = res;
977  }
978 }
979 
989 static void cfapi_timer_destroy(int *type, ...) {
990  va_list args;
991  int id;
992  int *err;
993 
994  va_start(args, type);
995  id = va_arg(args, int);
996  err = va_arg(args, int *);
997  va_end(args);
998  *type = CFAPI_INT;
999 
1000  *err = cftimer_destroy(id);
1001 }
1002 
1008 static void cfapi_log(int *type, ...) {
1009  va_list args;
1010  LogLevel logLevel;
1011  const char *message;
1012 
1013  va_start(args, type);
1014  logLevel = static_cast<LogLevel>(va_arg(args, int));
1015  message = va_arg(args, const char *);
1016  LOG(logLevel, "%s", message);
1017  va_end(args);
1018 
1019  *type = CFAPI_NONE;
1020 }
1021 
1022 /* MAP RELATED HOOKS */
1023 
1032 static void cfapi_map_get_map(int *type, ...) {
1033  va_list args;
1034  mapstruct **ret;
1035  int ctype;
1036  int x, y;
1037  int16_t nx, ny;
1038  const char *name;
1039  mapstruct *m;
1040 
1041  va_start(args, type);
1042 
1043  ctype = va_arg(args, int);
1044 
1045  switch (ctype) {
1046  case 0:
1047  x = va_arg(args, int);
1048  y = va_arg(args, int);
1049  ret = va_arg(args, mapstruct **);
1050  *ret = get_empty_map(x, y);
1051  break;
1052 
1053  case 1:
1054  name = va_arg(args, const char *);
1055  x = va_arg(args, int);
1056  ret = va_arg(args, mapstruct **);
1057  *ret = ready_map_name(name, x);
1058  break;
1059 
1060  case 2:
1061  m = va_arg(args, mapstruct *);
1062  nx = va_arg(args, int);
1063  ny = va_arg(args, int);
1064  ret = va_arg(args, mapstruct **);
1065  *ret = get_map_from_coord(m, &nx, &ny);
1066  break;
1067 
1068  default:
1069  *type = CFAPI_NONE;
1070  va_end(args);
1071  return;
1072  break;
1073  }
1074  va_end(args);
1075  *type = CFAPI_PMAP;
1076 }
1077 
1083 static void cfapi_map_has_been_loaded(int *type, ...) {
1084  va_list args;
1085  mapstruct **map;
1086  char *string;
1087 
1088  va_start(args, type);
1089  string = va_arg(args, char *);
1090  map = va_arg(args, mapstruct **);
1091  *map = has_been_loaded(string);
1092  va_end(args);
1093  *type = CFAPI_PMAP;
1094 }
1095 
1101 static void cfapi_map_create_path(int *type, ...) {
1102  va_list args;
1103  int ctype, size;
1104  const char *str;
1105  char *name;
1106 
1107  va_start(args, type);
1108 
1109  ctype = va_arg(args, int);
1110  str = va_arg(args, const char *);
1111  name = va_arg(args, char *);
1112  size = va_arg(args, int);
1113  *type = CFAPI_STRING;
1114 
1115  switch (ctype) {
1116  case 0:
1117  create_pathname(str, name, size);
1118  break;
1119 
1120  case 1:
1122  break;
1123 
1124 /* case 2:
1125  rv = create_items_path(str);
1126  break;*/
1127 
1128  default:
1129  *type = CFAPI_NONE;
1130  break;
1131  }
1132  va_end(args);
1133 }
1134 
1135 static void cfapi_map_get_map_property(int *type, ...) {
1136  va_list args;
1137  mapstruct *map;
1138  int property;
1139 
1140  int *rint;
1141  mapstruct **rmap;
1142  sstring *rstr;
1143  region **rreg;
1144  int16_t *nx, *ny;
1145  int x, y;
1146 
1147  va_start(args, type);
1148 
1149  map = va_arg(args, mapstruct *);
1150  property = va_arg(args, int);
1151 
1152  switch (property) {
1153  case CFAPI_MAP_PROP_FLAGS:
1154  rmap = va_arg(args, mapstruct **);
1155  x = va_arg(args, int);
1156  y = va_arg(args, int);
1157  nx = va_arg(args, int16_t *);
1158  ny = va_arg(args, int16_t *);
1159  rint = va_arg(args, int *);
1160  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1161  *type = CFAPI_INT;
1162  break;
1163 
1165  rint = va_arg(args, int *);
1166  *rint = calculate_difficulty(map);
1167  *type = CFAPI_INT;
1168  break;
1169 
1170  case CFAPI_MAP_PROP_PATH:
1171  rstr = va_arg(args, sstring *);
1172  *rstr = map->path;
1173  *type = CFAPI_SSTRING;
1174  break;
1175 
1177  rstr = va_arg(args, sstring *);
1178  *rstr = map->tmpname;
1179  *type = CFAPI_SSTRING;
1180  break;
1181 
1182  case CFAPI_MAP_PROP_NAME:
1183  rstr = va_arg(args, sstring *);
1184  *rstr = map->name;
1185  *type = CFAPI_SSTRING;
1186  break;
1187 
1189  rint = va_arg(args, int *);
1190  *rint = map->reset_time;
1191  *type = CFAPI_INT;
1192  break;
1193 
1195  rint = va_arg(args, int *);
1196  *rint = map->reset_timeout;
1197  *type = CFAPI_INT;
1198  break;
1199 
1201  rint = va_arg(args, int *);
1202  *rint = map->players;
1203  *type = CFAPI_INT;
1204  break;
1205 
1207  rint = va_arg(args, int *);
1208  *rint = map->darkness;
1209  *type = CFAPI_INT;
1210  break;
1211 
1212  case CFAPI_MAP_PROP_WIDTH:
1213  rint = va_arg(args, int *);
1214  *rint = map->width;
1215  *type = CFAPI_INT;
1216  break;
1217 
1218  case CFAPI_MAP_PROP_HEIGHT:
1219  rint = va_arg(args, int *);
1220  *rint = map->height;
1221  *type = CFAPI_INT;
1222  break;
1223 
1225  rint = va_arg(args, int *);
1226  *rint = map->enter_x;
1227  *type = CFAPI_INT;
1228  break;
1229 
1231  rint = va_arg(args, int *);
1232  *rint = map->enter_y;
1233  *type = CFAPI_INT;
1234  break;
1235 
1237  rstr = va_arg(args, sstring *);
1238  *rstr = map->msg;
1239  *type = CFAPI_SSTRING;
1240  break;
1241 
1242  case CFAPI_MAP_PROP_NEXT:
1243  rmap = va_arg(args, mapstruct **);
1244  *rmap = map ? map->next : first_map;
1245  *type = CFAPI_PMAP;
1246  break;
1247 
1248  case CFAPI_MAP_PROP_REGION:
1249  rreg = va_arg(args, region **);
1250  *rreg = get_region_by_map(map);
1251  *type = CFAPI_PREGION;
1252  break;
1253 
1254  case CFAPI_MAP_PROP_UNIQUE:
1255  rint = va_arg(args, int *);
1256  *rint = map->unique;
1257  *type = CFAPI_INT;
1258  break;
1259 
1260  default:
1261  *type = CFAPI_NONE;
1262  break;
1263  }
1264  va_end(args);
1265 }
1266 
1267 static void cfapi_map_set_map_property(int *type, ...) {
1268  va_list args;
1269  mapstruct *map;
1270  int property;
1271  const char *buf;
1272 
1273  va_start(args, type);
1274 
1275  map = va_arg(args, mapstruct *);
1276  property = va_arg(args, int);
1277 
1278  switch (property) {
1279  case CFAPI_MAP_PROP_PATH:
1280  buf = va_arg(args, const char *);
1281  strlcpy(map->path, buf, sizeof(map->path));
1282  *type = CFAPI_STRING;
1283  break;
1284 
1285  default:
1286  *type = CFAPI_NONE;
1287  break;
1288  }
1289  va_end(args);
1290 }
1291 
1297 static void cfapi_map_out_of_map(int *type, ...) {
1298  va_list args;
1299  mapstruct *map;
1300  int x, y;
1301  int *rint;
1302 
1303  va_start(args, type);
1304  map = va_arg(args, mapstruct *);
1305  x = va_arg(args, int);
1306  y = va_arg(args, int);
1307  rint = va_arg(args, int *);
1308 
1309  *rint = out_of_map(map, x, y);
1310  va_end(args);
1311  *type = CFAPI_INT;
1312 }
1313 
1319 static void cfapi_map_update_position(int *type, ...) {
1320  va_list args;
1321  mapstruct *map;
1322  int x, y;
1323 
1324  va_start(args, type);
1325 
1326  map = va_arg(args, mapstruct *);
1327  x = va_arg(args, int);
1328  y = va_arg(args, int);
1329 
1330  update_position(map, x, y);
1331  va_end(args);
1332  *type = CFAPI_NONE;
1333 }
1334 
1335 static void cfapi_map_delete_map(int *type, ...) {
1336  va_list args;
1337  mapstruct *map;
1338  va_start(args, type);
1339 
1340  map = va_arg(args, mapstruct *);
1341 
1342  delete_map(map);
1343 
1344  va_end(args);
1345  *type = CFAPI_NONE;
1346 }
1347 
1348 static void cfapi_map_message(int *type, ...) {
1349  va_list args;
1350  mapstruct *map;
1351  const char *string;
1352  int color;
1353 
1354  va_start(args, type);
1355  map = va_arg(args, mapstruct *);
1356  string = va_arg(args, const char *);
1357  color = va_arg(args, int);
1358  va_end(args);
1359 
1360  /* function should be extended to take message types probably */
1361  ext_info_map(color, map, MSG_TYPE_MISC, MSG_SUBTYPE_NONE, string);
1362  *type = CFAPI_NONE;
1363 }
1364 
1370 static void cfapi_map_get_object_at(int *type, ...) {
1371  va_list args;
1372  mapstruct *map;
1373  int x, y;
1374  int16_t sx, sy;
1375  object **robj;
1376 
1377  va_start(args, type);
1378  map = va_arg(args, mapstruct *);
1379  x = va_arg(args, int);
1380  y = va_arg(args, int);
1381  robj = va_arg(args, object **);
1382  va_end(args);
1383 
1384  sx = x;
1385  sy = y;
1386  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1387  *robj = NULL;
1388  else
1389  *robj = GET_MAP_OB(map, sx, sy);
1390  *type = CFAPI_POBJECT;
1391 }
1392 
1399 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1400  va_list args;
1401  int x, y;
1402  mapstruct *map;
1403  char *msg;
1404  object **robj;
1405 
1406  va_start(args, type);
1407 
1408  msg = va_arg(args, char *);
1409  map = va_arg(args, mapstruct *);
1410  x = va_arg(args, int);
1411  y = va_arg(args, int);
1412  robj = va_arg(args, object **);
1413 
1414  va_end(args);
1415 
1416  archetype *at = try_find_archetype(msg);
1417  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1418  *type = CFAPI_POBJECT;
1419 }
1420 
1426 static void cfapi_map_change_light(int *type, ...) {
1427  va_list args;
1428  int change;
1429  mapstruct *map;
1430  int *rint;
1431 
1432  va_start(args, type);
1433  map = va_arg(args, mapstruct *);
1434  change = va_arg(args, int);
1435  rint = va_arg(args, int *);
1436  va_end(args);
1437 
1438  *type = CFAPI_INT;
1439  *rint = change_map_light(map, change);
1440 }
1441 
1442 /* OBJECT-RELATED HOOKS */
1443 
1457 static void cfapi_object_move(int *type, ...) {
1458  va_list args;
1459  int kind;
1460  object *op;
1461  object *activator;
1462  player *pl;
1463  int direction;
1464  int *ret;
1465 
1466  va_start(args, type);
1467  kind = va_arg(args, int);
1468  switch (kind) {
1469  case 0:
1470  op = va_arg(args, object *);
1471  direction = va_arg(args, int);
1472  activator = va_arg(args, object *);
1473  ret = va_arg(args, int *);
1474  va_end(args);
1475  *ret = move_ob(op, direction, activator);
1476  break;
1477 
1478  case 1:
1479  pl = va_arg(args, player *);
1480  direction = va_arg(args, int);
1481  ret = va_arg(args, int *);
1482  va_end(args);
1483  *ret = move_player(pl->ob, direction);
1484  break;
1485 
1486  case 2:
1487  op = va_arg(args, object *);
1488  ret = va_arg(args, int *);
1489  va_end(args);
1490  *ret = player_arrest(op);
1491  break;
1492 
1493  default:
1494  // Just end the use of variable args. We got a wrong type.
1495  va_end(args);
1496  }
1497  *type = CFAPI_INT;
1498 }
1499 
1507 static void cfapi_object_get_key(int *type, ...) {
1508  va_list args;
1509  const char *keyname;
1510  const char **value;
1511  object *op;
1512 
1513  va_start(args, type);
1514  op = va_arg(args, object *);
1515  keyname = va_arg(args, const char *);
1516  value = va_arg(args, const char **);
1517  va_end(args);
1518 
1519  *value = object_get_value(op, keyname);
1520  *type = CFAPI_SSTRING;
1521 }
1522 
1529 static void cfapi_object_set_key(int *type, ...) {
1530  va_list args;
1531  const char *keyname;
1532  const char *value;
1533  int *ret;
1534  object *op;
1535  int add_key;
1536 
1537  va_start(args, type);
1538  op = va_arg(args, object *);
1539  keyname = va_arg(args, char *);
1540  value = va_arg(args, char *);
1541  add_key = va_arg(args, int);
1542  ret = va_arg(args, int *);
1543  va_end(args);
1544 
1545  *ret = object_set_value(op, keyname, value, add_key);
1546  *type = CFAPI_INT;
1547 }
1548 
1552 static void cfapi_object_get_property(int *type, ...) {
1553  va_list args;
1554  int property;
1555  object *op;
1556  int *rint;
1557  object **robject;
1558  mapstruct **rmap;
1559  float *rfloat;
1560  archetype **rarch;
1561  sstring *rsstring;
1562  char *rbuffer;
1563  int rbufsize;
1564  MoveType *rmove;
1565  int64_t *rint64;
1566  partylist **rparty;
1567  double *rdouble;
1568  long *rlong;
1569 
1570  va_start(args, type);
1571 
1572  op = va_arg(args, object *);
1573  property = va_arg(args, int);
1574  switch (property) {
1576  robject = va_arg(args, object **);
1577  *robject = op->above;
1578  *type = CFAPI_POBJECT;
1579  break;
1580 
1582  robject = va_arg(args, object **);
1583  *robject = op->below;
1584  *type = CFAPI_POBJECT;
1585  break;
1586 
1588  robject = va_arg(args, object **);
1589  *robject = op->active_next;
1590  *type = CFAPI_POBJECT;
1591  break;
1592 
1594  robject = va_arg(args, object **);
1595  *robject = op->active_prev;
1596  *type = CFAPI_POBJECT;
1597  break;
1598 
1600  robject = va_arg(args, object **);
1601  *robject = op->inv;
1602  *type = CFAPI_POBJECT;
1603  break;
1604 
1606  robject = va_arg(args, object **);
1607  *robject = op->env;
1608  *type = CFAPI_POBJECT;
1609  break;
1610 
1612  robject = va_arg(args, object **);
1613  *robject = op->head;
1614  *type = CFAPI_POBJECT;
1615  break;
1616 
1618  robject = va_arg(args, object **);
1619  *robject = op->container;
1620  *type = CFAPI_POBJECT;
1621  break;
1622 
1623  case CFAPI_OBJECT_PROP_MAP:
1624  rmap = va_arg(args, mapstruct **);
1625  *rmap = op->map;
1626  *type = CFAPI_PMAP;
1627  break;
1628 
1630  rint = va_arg(args, int *);
1631  *rint = op->count;
1632  *type = CFAPI_INT;
1633  break;
1634 
1636  rbuffer = va_arg(args, char *);
1637  rbufsize = va_arg(args, int);
1638  query_name(op, rbuffer, rbufsize);
1639  *type = CFAPI_STRING;
1640  break;
1641 
1643  rsstring = va_arg(args, sstring *);
1644  *rsstring = op->name_pl;
1645  *type = CFAPI_SSTRING;
1646  break;
1647 
1649  rsstring = va_arg(args, sstring *);
1650  *rsstring = op->title;
1651  *type = CFAPI_SSTRING;
1652  break;
1653 
1655  rsstring = va_arg(args, sstring *);
1656  *rsstring = op->race;
1657  *type = CFAPI_SSTRING;
1658  break;
1659 
1661  rsstring = va_arg(args, sstring *);
1662  *rsstring = op->slaying;
1663  *type = CFAPI_SSTRING;
1664  break;
1665 
1667  rsstring = va_arg(args, sstring *);
1668  *rsstring = op->skill;
1669  *type = CFAPI_SSTRING;
1670  break;
1671 
1673  rsstring = va_arg(args, sstring *);
1674  *rsstring = op->msg;
1675  *type = CFAPI_SSTRING;
1676  break;
1677 
1679  rsstring = va_arg(args, sstring *);
1680  *rsstring = op->lore;
1681  *type = CFAPI_SSTRING;
1682  break;
1683 
1684  case CFAPI_OBJECT_PROP_X:
1685  rint = va_arg(args, int *);
1686  *rint = op->x;
1687  *type = CFAPI_INT;
1688  break;
1689 
1690  case CFAPI_OBJECT_PROP_Y:
1691  rint = va_arg(args, int *);
1692  *rint = op->y;
1693  *type = CFAPI_INT;
1694  break;
1695 
1697  rfloat = va_arg(args, float *);
1698  *rfloat = op->speed;
1699  *type = CFAPI_FLOAT;
1700  break;
1701 
1703  rfloat = va_arg(args, float *);
1704  *rfloat = op->speed_left;
1705  *type = CFAPI_FLOAT;
1706  break;
1707 
1709  rint = va_arg(args, int *);
1710  *rint = NROF(op);
1711  *type = CFAPI_INT;
1712  break;
1713 
1715  rint = va_arg(args, int *);
1716  *rint = op->direction;
1717  *type = CFAPI_INT;
1718  break;
1719 
1721  rint = va_arg(args, int *);
1722  *rint = op->facing;
1723  *type = CFAPI_INT;
1724  break;
1725 
1727  rint = va_arg(args, int *);
1728  *rint = op->type;
1729  *type = CFAPI_INT;
1730  break;
1731 
1733  rint = va_arg(args, int *);
1734  *rint = op->subtype;
1735  *type = CFAPI_INT;
1736  break;
1737 
1739  rint = va_arg(args, int *);
1740  *rint = op->client_type;
1741  *type = CFAPI_INT;
1742  break;
1743 
1744  case CFAPI_OBJECT_PROP_RESIST: {
1745  int idx;
1746  int16_t *resist;
1747 
1748  idx = va_arg(args, int);
1749  resist = va_arg(args, int16_t *);
1750  *resist = op->resist[idx];
1751  }
1752  *type = CFAPI_INT16;
1753  break;
1754 
1756  rint = va_arg(args, int *);
1757  *rint = op->attacktype;
1758  *type = CFAPI_INT;
1759  break;
1760 
1762  rint = va_arg(args, int *);
1763  *rint = op->path_attuned;
1764  *type = CFAPI_INT;
1765  break;
1766 
1768  rint = va_arg(args, int *);
1769  *rint = op->path_repelled;
1770  *type = CFAPI_INT;
1771  break;
1772 
1774  rint = va_arg(args, int *);
1775  *rint = op->path_denied;
1776  *type = CFAPI_INT;
1777  break;
1778 
1780  rint = va_arg(args, int *);
1781  *rint = op->material;
1782  *type = CFAPI_INT;
1783  break;
1784 
1786  rsstring = va_arg(args, sstring *);
1787  *rsstring = op->materialname;
1788  *type = CFAPI_SSTRING;
1789  break;
1790 
1792  rint = va_arg(args, int *);
1793  *rint = op->magic;
1794  *type = CFAPI_INT;
1795  break;
1796 
1798  rlong = va_arg(args, long *);
1799  *rlong = op->value;
1800  *type = CFAPI_LONG;
1801  break;
1802 
1804  rint = va_arg(args, int *);
1805  *rint = op->level;
1806  *type = CFAPI_INT;
1807  break;
1808 
1810  rint = va_arg(args, int *);
1811  *rint = op->last_heal;
1812  *type = CFAPI_INT;
1813  break;
1814 
1816  rint = va_arg(args, int *);
1817  *rint = op->last_sp;
1818  *type = CFAPI_INT;
1819  break;
1820 
1822  rint = va_arg(args, int *);
1823  *rint = op->last_grace;
1824  *type = CFAPI_INT;
1825  break;
1826 
1828  rint = va_arg(args, int *);
1829  *rint = op->last_eat;
1830  *type = CFAPI_INT;
1831  break;
1832 
1834  rint = va_arg(args, int *);
1835  *rint = op->invisible;
1836  *type = CFAPI_INT;
1837  break;
1838 
1840  rint = va_arg(args, int *);
1841  *rint = op->pick_up;
1842  *type = CFAPI_INT;
1843  break;
1844 
1846  rint = va_arg(args, int *);
1847  *rint = op->item_power;
1848  *type = CFAPI_INT;
1849  break;
1850 
1852  rint = va_arg(args, int *);
1853  *rint = op->gen_sp_armour;
1854  *type = CFAPI_INT;
1855  break;
1856 
1858  rint = va_arg(args, int *);
1859  *rint = op->weight;
1860  *type = CFAPI_INT;
1861  break;
1862 
1864  rint = va_arg(args, int *);
1865  *rint = op->weight_limit;
1866  *type = CFAPI_INT;
1867  break;
1868 
1870  rint = va_arg(args, int *);
1871  *rint = op->carrying;
1872  *type = CFAPI_INT;
1873  break;
1874 
1876  rint = va_arg(args, int *);
1877  *rint = op->glow_radius;
1878  *type = CFAPI_INT;
1879  break;
1880 
1882  rint64 = va_arg(args, int64_t *);
1883  *rint64 = op->total_exp;
1884  *type = CFAPI_SINT64;
1885  break;
1886 
1888  robject = va_arg(args, object **);
1889  *robject = op->current_weapon;
1890  *type = CFAPI_POBJECT;
1891  break;
1892 
1894  robject = va_arg(args, object **);
1895  *robject = op->enemy;
1896  *type = CFAPI_POBJECT;
1897  break;
1898 
1900  robject = va_arg(args, object **);
1901  *robject = op->attacked_by;
1902  *type = CFAPI_POBJECT;
1903  break;
1904 
1906  rint = va_arg(args, int *);
1907  *rint = op->run_away;
1908  *type = CFAPI_INT;
1909  break;
1910 
1912  robject = va_arg(args, object **);
1913  *robject = op->chosen_skill;
1914  *type = CFAPI_POBJECT;
1915  break;
1916 
1918  rint = va_arg(args, int *);
1919  *rint = op->hide;
1920  *type = CFAPI_INT;
1921  break;
1922 
1924  rint = va_arg(args, int *);
1925  *rint = op->move_status;
1926  *type = CFAPI_INT;
1927  break;
1928 
1930  rint = va_arg(args, int *);
1931  *rint = op->attack_movement;
1932  *type = CFAPI_INT;
1933  break;
1934 
1936  robject = va_arg(args, object **);
1937  *robject = op->spellitem;
1938  *type = CFAPI_POBJECT;
1939  break;
1940 
1942  rdouble = va_arg(args, double *);
1943  *rdouble = op->expmul;
1944  *type = CFAPI_DOUBLE;
1945  break;
1946 
1948  rarch = va_arg(args, archetype **);
1949  *rarch = op->arch;
1950  *type = CFAPI_PARCH;
1951  break;
1952 
1954  rarch = va_arg(args, archetype **);
1955  *rarch = op->other_arch;
1956  *type = CFAPI_PARCH;
1957  break;
1958 
1960  rsstring = va_arg(args, sstring *);
1961  *rsstring = object_get_value(op, CUSTOM_NAME_FIELD);
1962  *type = CFAPI_SSTRING;
1963  break;
1964 
1966  rint = va_arg(args, int *);
1967  *rint = op->anim_speed;
1968  *type = CFAPI_INT;
1969  break;
1970 
1972  rint = va_arg(args, int *);
1973  *rint = is_friendly(op);
1974  *type = CFAPI_INT;
1975  break;
1976 
1978  rbuffer = va_arg(args, char *);
1979  rbufsize = va_arg(args, int);
1980  query_short_name(op, rbuffer, rbufsize);
1981  *type = CFAPI_STRING;
1982  break;
1983 
1985  int i;
1986 
1987  i = va_arg(args, int);
1988  rbuffer = va_arg(args, char *);
1989  rbufsize = va_arg(args, int);
1990  query_base_name(op, i, rbuffer, rbufsize);
1991  *type = CFAPI_STRING;
1992  }
1993  break;
1994 
1996  rsstring = va_arg(args, sstring *);
1997  *rsstring = op->name;
1998  *type = CFAPI_SSTRING;
1999  break;
2000 
2002  rint = va_arg(args, int *);
2003  *rint = is_magical(op);
2004  *type = CFAPI_INT;
2005  break;
2006 
2008  rint = va_arg(args, int *);
2009  *rint = op->stats.luck;
2010  *type = CFAPI_INT;
2011  break;
2012 
2013  case CFAPI_OBJECT_PROP_EXP:
2014  rint64 = va_arg(args, int64_t *);
2015  *rint64 = op->stats.exp;
2016  *type = CFAPI_SINT64;
2017  break;
2018 
2020  robject = va_arg(args, object **);
2021  *robject = object_get_owner(op);
2022  *type = CFAPI_POBJECT;
2023  break;
2024 
2026  int stype;
2027 
2028  stype = va_arg(args, int);
2029  switch (stype) {
2030  unsigned char ptype;
2031  char *buf;
2032  archetype *at;
2033 
2034  case 0: /* present_in_ob */
2035  ptype = (unsigned char)(va_arg(args, int));
2036  robject = va_arg(args, object **);
2037  *robject = object_present_in_ob(ptype, op);
2038  break;
2039 
2040  case 1: /* present_in_ob_by_name */
2041  ptype = (unsigned char)(va_arg(args, int));
2042  buf = va_arg(args, char *);
2043  robject = va_arg(args, object **);
2044  *robject = object_present_in_ob_by_name(ptype, buf, op);
2045  break;
2046 
2047  case 2: /* arch_present_in_ob */
2048  at = va_arg(args, archetype *);
2049  robject = va_arg(args, object **);
2050  *robject = arch_present_in_ob(at, op);
2051  break;
2052  }
2053  }
2054  *type = CFAPI_POBJECT;
2055  break;
2056 
2058  rint = va_arg(args, int *);
2059  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2060  *type = CFAPI_INT;
2061  break;
2062 
2064  object *op2;
2065 
2066  op2 = va_arg(args, object *);
2067  rint = va_arg(args, int *);
2068  *rint = object_can_merge(op, op2);
2069  }
2070  *type = CFAPI_INT;
2071  break;
2072 
2074  object *op2;
2075 
2076  op2 = va_arg(args, object *);
2077  rint = va_arg(args, int *);
2078  *rint = object_can_pick(op2, op);
2079  }
2080  *type = CFAPI_INT;
2081  break;
2082 
2083  case CFAPI_OBJECT_PROP_FLAGS: {
2084  int fl;
2085 
2086  fl = va_arg(args, int);
2087  rint = va_arg(args, int *);
2088  *rint = QUERY_FLAG(op, fl);
2089  }
2090  *type = CFAPI_INT;
2091  break;
2092 
2093  case CFAPI_OBJECT_PROP_STR:
2094  rint = va_arg(args, int *);
2095  *rint = op->stats.Str;
2096  *type = CFAPI_INT;
2097  break;
2098 
2099  case CFAPI_OBJECT_PROP_DEX:
2100  rint = va_arg(args, int *);
2101  *rint = op->stats.Dex;
2102  *type = CFAPI_INT;
2103  break;
2104 
2105  case CFAPI_OBJECT_PROP_CON:
2106  rint = va_arg(args, int *);
2107  *rint = op->stats.Con;
2108  *type = CFAPI_INT;
2109  break;
2110 
2111  case CFAPI_OBJECT_PROP_WIS:
2112  rint = va_arg(args, int *);
2113  *rint = op->stats.Wis;
2114  *type = CFAPI_INT;
2115  break;
2116 
2117  case CFAPI_OBJECT_PROP_INT:
2118  rint = va_arg(args, int *);
2119  *rint = op->stats.Int;
2120  *type = CFAPI_INT;
2121  break;
2122 
2123  case CFAPI_OBJECT_PROP_POW:
2124  rint = va_arg(args, int *);
2125  *rint = op->stats.Pow;
2126  *type = CFAPI_INT;
2127  break;
2128 
2129  case CFAPI_OBJECT_PROP_CHA:
2130  rint = va_arg(args, int *);
2131  *rint = op->stats.Cha;
2132  *type = CFAPI_INT;
2133  break;
2134 
2135  case CFAPI_OBJECT_PROP_WC:
2136  rint = va_arg(args, int *);
2137  *rint = op->stats.wc;
2138  *type = CFAPI_INT;
2139  break;
2140 
2141  case CFAPI_OBJECT_PROP_AC:
2142  rint = va_arg(args, int *);
2143  *rint = op->stats.ac;
2144  *type = CFAPI_INT;
2145  break;
2146 
2147  case CFAPI_OBJECT_PROP_HP:
2148  rint = va_arg(args, int *);
2149  *rint = op->stats.hp;
2150  *type = CFAPI_INT;
2151  break;
2152 
2153  case CFAPI_OBJECT_PROP_SP:
2154  rint = va_arg(args, int *);
2155  *rint = op->stats.sp;
2156  *type = CFAPI_INT;
2157  break;
2158 
2159  case CFAPI_OBJECT_PROP_GP:
2160  rint = va_arg(args, int *);
2161  *rint = op->stats.grace;
2162  *type = CFAPI_INT;
2163  break;
2164 
2165  case CFAPI_OBJECT_PROP_FP:
2166  rint = va_arg(args, int *);
2167  *rint = op->stats.food;
2168  *type = CFAPI_INT;
2169  break;
2170 
2172  rint = va_arg(args, int *);
2173  *rint = op->stats.maxhp;
2174  *type = CFAPI_INT;
2175  break;
2176 
2178  rint = va_arg(args, int *);
2179  *rint = op->stats.maxsp;
2180  *type = CFAPI_INT;
2181  break;
2182 
2184  rint = va_arg(args, int *);
2185  *rint = op->stats.maxgrace;
2186  *type = CFAPI_INT;
2187  break;
2188 
2189  case CFAPI_OBJECT_PROP_DAM:
2190  rint = va_arg(args, int *);
2191  *rint = op->stats.dam;
2192  *type = CFAPI_INT;
2193  break;
2194 
2195  case CFAPI_OBJECT_PROP_GOD:
2196  rsstring = va_arg(args, sstring *);
2197  *rsstring = determine_god(op);
2198  *type = CFAPI_SSTRING;
2199  break;
2200 
2202  rsstring = va_arg(args, sstring *);
2203  *rsstring = op->arch->name;
2204  *type = CFAPI_SSTRING;
2205  break;
2206 
2208  rint = va_arg(args, int *);
2209  *rint = op->invisible;
2210  *type = CFAPI_INT;
2211  break;
2212 
2214  rsstring = va_arg(args, sstring *);
2215  if (op->face != NULL) {
2216  (*rsstring) = op->face->name;
2217  }
2218  else {
2219  (*rsstring) = NULL;
2220  }
2221  *type = CFAPI_SSTRING;
2222  break;
2223 
2225  rsstring = va_arg(args, sstring *);
2226  if (op->animation != NULL) {
2227  (*rsstring) = op->animation->name;
2228  }
2229  else {
2230  (*rsstring) = NULL;
2231  }
2232  *type = CFAPI_SSTRING;
2233  break;
2234 
2236  rint = va_arg(args, int *);
2237  *rint = op->contr->count;
2238  *type = CFAPI_INT;
2239  break;
2240 
2241  case CFAPI_PLAYER_PROP_IP:
2242  rsstring = va_arg(args, sstring *);
2243  *rsstring = op->contr->socket->host;
2244  *type = CFAPI_SSTRING;
2245  break;
2246 
2248  robject = va_arg(args, object **);
2249  *robject = find_marked_object(op);
2250  *type = CFAPI_POBJECT;
2251  break;
2252 
2254  rparty = va_arg(args, partylist **);
2255  *rparty = (op->contr ? op->contr->party : NULL);
2256  *type = CFAPI_PPARTY;
2257  break;
2258 
2260  robject = va_arg(args, object **);
2261  if (op)
2262  *robject = op->contr->next ? op->contr->next->ob : NULL;
2263  else
2264  /* This can be called when there is no player. */
2265  *robject = first_player ? first_player->ob : NULL;
2266  *type = CFAPI_POBJECT;
2267  break;
2268 
2270  rbuffer = va_arg(args, char *);
2271  rbufsize = va_arg(args, int);
2272  player_get_title(op->contr, rbuffer, rbufsize);
2273  *type = CFAPI_STRING;
2274  break;
2275 
2277  robject = va_arg(args, object **);
2278  *robject = op->contr->transport;
2279  *type = CFAPI_POBJECT;
2280  break;
2281 
2283  rmove = va_arg(args, MoveType *);
2284  *rmove = op->move_type;
2285  *type = CFAPI_MOVETYPE;
2286  break;
2287 
2289  rmove = va_arg(args, MoveType *);
2290  *rmove = op->move_block;
2291  *type = CFAPI_MOVETYPE;
2292  break;
2293 
2295  rmove = va_arg(args, MoveType *);
2296  *rmove = op->move_allow;
2297  *type = CFAPI_MOVETYPE;
2298  break;
2299 
2301  rmove = va_arg(args, MoveType *);
2302  *rmove = op->move_on;
2303  *type = CFAPI_MOVETYPE;
2304  break;
2305 
2307  rmove = va_arg(args, MoveType *);
2308  *rmove = op->move_off;
2309  *type = CFAPI_MOVETYPE;
2310  break;
2311 
2313  rmove = va_arg(args, MoveType *);
2314  *rmove = op->move_type;
2315  *type = CFAPI_MOVETYPE;
2316  break;
2317 
2319  rfloat = va_arg(args, float *);
2320  *rfloat = op->move_slow_penalty;
2321  *type = CFAPI_FLOAT;
2322  break;
2323 
2325  rbuffer = va_arg(args, char *);
2326  rbufsize = va_arg(args, int);
2327  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2328  *type = CFAPI_STRING;
2329  break;
2330 
2332  rint = va_arg(args, int *);
2333  *rint = op->contr->bed_x;
2334  *type = CFAPI_INT;
2335  break;
2336 
2338  rint = va_arg(args, int *);
2339  *rint = op->contr->bed_y;
2340  *type = CFAPI_INT;
2341  break;
2342 
2344  rint = va_arg(args, int *);
2345  *rint = op->duration;
2346  *type = CFAPI_INT;
2347  break;
2348 
2349  default:
2350  *type = CFAPI_NONE;
2351  break;
2352  }
2353  va_end(args);
2354 }
2355 
2364 static void copy_message(object *op, const char *msg) {
2365  /* need to reset parsed dialog information */
2367  if (strlen(msg) == 0) {
2368  msg = NULL;
2369  }
2370  object_set_msg(op, msg);
2371 }
2372 
2381 static void cfapi_object_set_property(int *type, ...) {
2382  va_list args;
2383  int iarg, *ret;
2384  long larg;
2385  char *sarg;
2386  double darg;
2387  object *oparg;
2388  object *op;
2389  int property;
2390  int64_t s64arg;
2391  partylist *partyarg;
2392  float farg;
2393  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2394 
2395  va_start(args, type);
2396  op = va_arg(args, object *);
2397  property = va_arg(args, int);
2398  *type = CFAPI_NONE;
2399 
2400  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2401  switch (property) {
2403  sarg = va_arg(args, char *);
2404  *type = CFAPI_STRING;
2405  FREE_AND_COPY(op->name, sarg);
2406  send_changed_object(op);
2407  break;
2408 
2410  sarg = va_arg(args, char *);
2411  *type = CFAPI_STRING;
2412  FREE_AND_COPY(op->name_pl, sarg);
2413  send_changed_object(op);
2414  break;
2415 
2417  sarg = va_arg(args, char *);
2418  *type = CFAPI_STRING;
2419  FREE_AND_COPY(op->title, sarg);
2420  break;
2421 
2423  sarg = va_arg(args, char *);
2424  *type = CFAPI_STRING;
2425  FREE_AND_COPY(op->race, sarg);
2426  break;
2427 
2429  sarg = va_arg(args, char *);
2430  *type = CFAPI_STRING;
2431  FREE_AND_COPY(op->slaying, sarg);
2432  break;
2433 
2435  sarg = va_arg(args, char *);
2436  *type = CFAPI_STRING;
2437  FREE_AND_COPY(op->skill, sarg);
2438  break;
2439 
2441  sarg = va_arg(args, char *);
2442  *type = CFAPI_STRING;
2443  copy_message(op, sarg);
2444  break;
2445 
2447  sarg = va_arg(args, char *);
2448  *type = CFAPI_STRING;
2449  FREE_AND_COPY(op->lore, sarg);
2450  break;
2451 
2453  farg = va_arg(args, double);
2454  *type = CFAPI_FLOAT;
2455  if (farg != op->speed) {
2456  op->speed = farg;
2457  object_update_speed(op);
2458  }
2459  break;
2460 
2462  farg = va_arg(args, double);
2463  *type = CFAPI_FLOAT;
2464  op->speed_left = farg;
2465  break;
2466 
2468  iarg = va_arg(args, int);
2469  *type = CFAPI_INT;
2470  if (iarg < 0)
2471  iarg = 0;
2472  if (op->nrof > (uint32_t)iarg)
2473  object_decrease_nrof(op, op->nrof-iarg);
2474  else if (op->nrof < (uint32_t)iarg) {
2475  object *tmp;
2476  player *pl;
2477 
2478  op->nrof = iarg;
2479  if (op->env != NULL) {
2480  tmp = object_get_player_container(op->env);
2481  if (!tmp) {
2482  for (pl = first_player; pl; pl = pl->next)
2483  if (pl->ob->container == op->env)
2484  break;
2485  if (pl)
2486  tmp = pl->ob;
2487  else
2488  tmp = NULL;
2489  } else {
2490  object_sum_weight(tmp);
2491  fix_object(tmp);
2492  }
2493  if (tmp)
2494  esrv_update_item(UPD_NROF, tmp, op);
2495  } else {
2496  FOR_ABOVE_PREPARE(op, tmp)
2497  if (tmp->type == PLAYER)
2498  tmp->contr->socket->update_look = 1;
2499  FOR_ABOVE_FINISH();
2500  }
2501  }
2502  break;
2503 
2505  iarg = va_arg(args, int);
2506  *type = CFAPI_INT;
2507  op->direction = iarg;
2508  break;
2509 
2511  iarg = va_arg(args, int);
2512  *type = CFAPI_INT;
2513  op->facing = iarg;
2514  break;
2515 
2516  case CFAPI_OBJECT_PROP_RESIST: {
2517  int iargbis = va_arg(args, int);
2518 
2519  *type = CFAPI_INT16;
2520  iarg = va_arg(args, int);
2521  op->resist[iargbis] = iarg;
2522  }
2523  break;
2524 
2526  iarg = va_arg(args, int);
2527  *type = CFAPI_INT;
2528  op->attacktype = iarg;
2529  break;
2530 
2532  iarg = va_arg(args, int);
2533  *type = CFAPI_INT;
2534  op->path_attuned = iarg;
2535  break;
2536 
2538  iarg = va_arg(args, int);
2539  *type = CFAPI_INT;
2540  op->path_repelled = iarg;
2541  break;
2542 
2544  iarg = va_arg(args, int);
2545  *type = CFAPI_INT;
2546  op->path_denied = iarg;
2547  break;
2548 
2550  iarg = va_arg(args, int);
2551  *type = CFAPI_INT;
2552  op->material = iarg;
2553  break;
2554 
2556  break;
2557 
2559  iarg = va_arg(args, int);
2560  *type = CFAPI_INT;
2561  op->magic = iarg;
2562  break;
2563 
2565  larg = va_arg(args, long);
2566  *type = CFAPI_LONG;
2567  op->value = larg;
2568  break;
2569 
2571  iarg = va_arg(args, int);
2572  *type = CFAPI_INT;
2573  op->level = iarg;
2574  send_changed_object(op);
2575  break;
2576 
2578  iarg = va_arg(args, int);
2579  *type = CFAPI_INT;
2580  op->last_heal = iarg;
2581  break;
2582 
2584  iarg = va_arg(args, int);
2585  *type = CFAPI_INT;
2586  op->last_sp = iarg;
2587  break;
2588 
2590  iarg = va_arg(args, int);
2591  *type = CFAPI_INT;
2592  op->last_grace = iarg;
2593  break;
2594 
2596  iarg = va_arg(args, int);
2597  *type = CFAPI_INT;
2598  op->last_eat = iarg;
2599  break;
2600 
2602  iarg = va_arg(args, int);
2603  *type = CFAPI_INT;
2604  op->invisible = iarg;
2605  break;
2606 
2608  iarg = va_arg(args, int);
2609  *type = CFAPI_INT;
2610  op->pick_up = iarg;
2611  break;
2612 
2614  iarg = va_arg(args, int);
2615  *type = CFAPI_INT;
2616  op->item_power = iarg;
2617  break;
2618 
2620  iarg = va_arg(args, int);
2621  *type = CFAPI_INT;
2622  op->gen_sp_armour = iarg;
2623  break;
2624 
2626  iarg = va_arg(args, int);
2627  *type = CFAPI_INT;
2628  if (op->weight != iarg) {
2629  object *tmp;
2630  player *pl;
2631 
2632  op->weight = iarg;
2633  if (op->env != NULL) {
2634  tmp = object_get_player_container(op->env);
2635  if (!tmp) {
2636  for (pl = first_player; pl; pl = pl->next)
2637  if (pl->ob->container == op->env)
2638  break;
2639  if (pl)
2640  tmp = pl->ob;
2641  else
2642  tmp = NULL;
2643  } else {
2644  object_sum_weight(tmp);
2645  fix_object(tmp);
2646  }
2647  if (tmp)
2648  esrv_update_item(UPD_WEIGHT, tmp, op);
2649  } else {
2650  FOR_ABOVE_PREPARE(op, tmp)
2651  if (tmp->type == PLAYER)
2652  esrv_update_item(UPD_WEIGHT, tmp, op);
2653  FOR_ABOVE_FINISH();
2654  }
2655  }
2656  break;
2657 
2659  iarg = va_arg(args, int);
2660  *type = CFAPI_INT;
2661  op->weight_limit = iarg;
2662  break;
2663 
2665  iarg = va_arg(args, int);
2666  *type = CFAPI_INT;
2667  if (op->glow_radius != iarg) {
2668  object *tmp;
2669 
2670  op->glow_radius = iarg;
2671  tmp = object_get_env_recursive(op);
2672  if (tmp->map != NULL) {
2673  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2674  update_position(tmp->map, tmp->x, tmp->y);
2675  update_all_los(tmp->map, tmp->x, tmp->y);
2676  }
2677  }
2678  break;
2679 
2681  s64arg = va_arg(args, int64_t);
2682  *type = CFAPI_SINT64;
2683  op->total_exp = s64arg;
2684  break;
2685 
2687  oparg = va_arg(args, object *);
2688  *type = CFAPI_POBJECT;
2689  object_set_enemy(op, oparg);
2690  break;
2691 
2693  iarg = va_arg(args, int);
2694  *type = CFAPI_INT;
2695  op->run_away = iarg;
2696  break;
2697 
2699  oparg = va_arg(args, object *);
2700  *type = CFAPI_POBJECT;
2701  op->chosen_skill = oparg;
2702  break;
2703 
2705  iarg = va_arg(args, int);
2706  *type = CFAPI_INT;
2707  op->hide = iarg;
2708  break;
2709 
2711  iarg = va_arg(args, int);
2712  *type = CFAPI_INT;
2713  op->move_status = iarg;
2714  break;
2715 
2717  iarg = va_arg(args, int);
2718  *type = CFAPI_INT;
2719  op->attack_movement = iarg;
2720  break;
2721 
2723  oparg = va_arg(args, object *);
2724  *type = CFAPI_POBJECT;
2725  op->spellitem = oparg;
2726  break;
2727 
2729  darg = va_arg(args, double);
2730  *type = CFAPI_DOUBLE;
2731  op->expmul = darg;
2732  break;
2733 
2735  sarg = va_arg(args, char *);
2736  *type = CFAPI_STRING;
2737  object_set_value(op, CUSTOM_NAME_FIELD, sarg, 1);
2738  send_changed_object(op);
2739  break;
2740 
2742  iarg = va_arg(args, int);
2743  *type = CFAPI_INT;
2744  op->anim_speed = iarg;
2745  break;
2746 
2748  iarg = va_arg(args, int);
2749  *type = CFAPI_INT;
2750  if (iarg == 1 && is_friendly(op) == 0)
2751  add_friendly_object(op);
2752  else if (iarg == 0 && is_friendly(op) == 1)
2754  break;
2755 
2757  iarg = va_arg(args, int);
2758  *type = CFAPI_INT;
2759  op->stats.luck = iarg;
2760  break;
2761 
2762  case CFAPI_OBJECT_PROP_EXP:
2763  s64arg = va_arg(args, int64_t);
2764  *type = CFAPI_SINT64;
2765  op->stats.exp = s64arg;
2766  break;
2767 
2769  oparg = va_arg(args, object *);
2770  *type = CFAPI_POBJECT;
2771  object_set_owner(op, oparg);
2772  break;
2773 
2775  object_set_cheat(op);
2776  *type = CFAPI_NONE;
2777  break;
2778 
2779  case CFAPI_OBJECT_PROP_FLAGS: {
2780  int iargbis;
2781 
2782  iarg = va_arg(args, int);
2783  iargbis = va_arg(args, int);
2784  *type = CFAPI_INT;
2785 
2786  if (iargbis == 1)
2787  SET_FLAG(op, iarg);
2788  else
2789  CLEAR_FLAG(op, iarg);
2790  send_changed_object(op);
2791  }
2792  break;
2793 
2794  case CFAPI_OBJECT_PROP_STR:
2795  iarg = va_arg(args, int);
2796  *type = CFAPI_INT;
2797  op->stats.Str = iarg;
2798  break;
2799 
2800  case CFAPI_OBJECT_PROP_DEX:
2801  iarg = va_arg(args, int);
2802  *type = CFAPI_INT;
2803  op->stats.Dex = iarg;
2804  break;
2805 
2806  case CFAPI_OBJECT_PROP_CON:
2807  iarg = va_arg(args, int);
2808  *type = CFAPI_INT;
2809  op->stats.Con = iarg;
2810  break;
2811 
2812  case CFAPI_OBJECT_PROP_WIS:
2813  iarg = va_arg(args, int);
2814  *type = CFAPI_INT;
2815  op->stats.Wis = iarg;
2816  break;
2817 
2818  case CFAPI_OBJECT_PROP_INT:
2819  iarg = va_arg(args, int);
2820  *type = CFAPI_INT;
2821  op->stats.Int = iarg;
2822  break;
2823 
2824  case CFAPI_OBJECT_PROP_POW:
2825  iarg = va_arg(args, int);
2826  *type = CFAPI_INT;
2827  op->stats.Pow = iarg;
2828  break;
2829 
2830  case CFAPI_OBJECT_PROP_CHA:
2831  iarg = va_arg(args, int);
2832  *type = CFAPI_INT;
2833  op->stats.Cha = iarg;
2834  break;
2835 
2836  case CFAPI_OBJECT_PROP_WC:
2837  iarg = va_arg(args, int);
2838  *type = CFAPI_INT;
2839  op->stats.wc = iarg;
2840  break;
2841 
2842  case CFAPI_OBJECT_PROP_AC:
2843  iarg = va_arg(args, int);
2844  *type = CFAPI_INT;
2845  op->stats.ac = iarg;
2846  break;
2847 
2848  case CFAPI_OBJECT_PROP_HP:
2849  iarg = va_arg(args, int);
2850  *type = CFAPI_INT;
2851  op->stats.hp = iarg;
2852  break;
2853 
2854  case CFAPI_OBJECT_PROP_SP:
2855  iarg = va_arg(args, int);
2856  *type = CFAPI_INT;
2857  op->stats.sp = iarg;
2858  break;
2859 
2860  case CFAPI_OBJECT_PROP_GP:
2861  iarg = va_arg(args, int);
2862  *type = CFAPI_INT;
2863  op->stats.grace = iarg;
2864  break;
2865 
2866  case CFAPI_OBJECT_PROP_FP:
2867  iarg = va_arg(args, int);
2868  *type = CFAPI_INT;
2869  op->stats.food = iarg;
2870  break;
2871 
2873  iarg = va_arg(args, int);
2874  *type = CFAPI_INT;
2875  op->stats.maxhp = iarg;
2876  break;
2877 
2879  iarg = va_arg(args, int);
2880  *type = CFAPI_INT;
2881  op->stats.maxsp = iarg;
2882  break;
2883 
2885  iarg = va_arg(args, int);
2886  *type = CFAPI_INT;
2887  op->stats.maxgrace = iarg;
2888  break;
2889 
2890  case CFAPI_OBJECT_PROP_DAM:
2891  iarg = va_arg(args, int);
2892  *type = CFAPI_INT;
2893  op->stats.dam = iarg;
2894  break;
2895 
2896  case CFAPI_OBJECT_PROP_FACE: {
2897  const Face *face;
2898  sarg = va_arg(args, char *);
2899  ret = va_arg(args, int *);
2900  *type = CFAPI_INT;
2901  face = try_find_face(sarg, 0);
2902  if (face != NULL) {
2903  op->face = face;
2904  op->state = 0;
2906  (*ret) = face->number;
2907  } else
2908  (*ret) = 0;
2909  break;
2910  }
2911 
2913  const Animations *anim;
2914  sarg = va_arg(args, char *);
2915  ret = va_arg(args, int *);
2916  *type = CFAPI_INT;
2917  anim = try_find_animation(sarg);
2918  if (anim != NULL) {
2919  op->animation = anim;
2920  SET_ANIMATION(op, 0);
2922  (*ret) = anim->num;
2923  } else {
2924  (*ret) = 0;
2925  }
2926  break;
2927  }
2928 
2930  iarg = va_arg(args, int);
2931  *type = CFAPI_INT;
2932  op->duration = iarg;
2933  break;
2934 
2936  if (op->contr) {
2937  oparg = va_arg(args, object *);
2938  *type = CFAPI_POBJECT;
2939  op->contr->mark = oparg;
2940  if (oparg) {
2941  op->contr->mark_count = oparg->count;
2942  } else {
2943  op->contr->mark_count = 0;
2944  }
2945  }
2946  break;
2947 
2949  if (op->contr) {
2950  partyarg = va_arg(args, partylist *);
2951  *type = CFAPI_PPARTY;
2952  party_join(op, partyarg);
2953  }
2954  break;
2955 
2957  sarg = va_arg(args, char *);
2958  *type = CFAPI_STRING;
2959  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
2960  break;
2961 
2963  iarg = va_arg(args, int);
2964  *type = CFAPI_INT;
2965  op->contr->bed_x = iarg;
2966  break;
2967 
2969  iarg = va_arg(args, int);
2970  *type = CFAPI_INT;
2971  op->contr->bed_y = iarg;
2972  break;
2973 
2975  sarg = va_arg(args, char *);
2976  *type = CFAPI_STRING;
2977  player_set_own_title(op->contr, sarg);
2978  break;
2979 
2981  move = va_arg(args, MoveType *);
2982  op->move_type = *move & MOVE_ALL;
2984  *type = CFAPI_MOVETYPE;
2985  break;
2986 
2988  move = va_arg(args, MoveType *);
2989  op->move_block = *move & MOVE_ALL;
2991  *type = CFAPI_MOVETYPE;
2992  break;
2993 
2995  move = va_arg(args, MoveType *);
2996  op->move_allow = *move & MOVE_ALL;
2998  *type = CFAPI_MOVETYPE;
2999  break;
3000 
3002  move = va_arg(args, MoveType *);
3003  op->move_on = *move & MOVE_ALL;
3005  *type = CFAPI_MOVETYPE;
3006  break;
3007 
3009  move = va_arg(args, MoveType *);
3010  op->move_off = *move & MOVE_ALL;
3012  *type = CFAPI_MOVETYPE;
3013  break;
3014 
3016  move = va_arg(args, MoveType *);
3017  op->move_type = *move & MOVE_ALL;
3019  *type = CFAPI_MOVETYPE;
3020  break;
3021 
3022  default:
3023  break;
3024  }
3025  }
3026  va_end(args);
3027 }
3028 
3035 static void cfapi_object_apply_below(int *type, ...) {
3036  va_list args;
3037  object *applier;
3038 
3039  va_start(args, type);
3040 
3041  applier = va_arg(args, object *);
3042 
3043  va_end(args);
3044 
3045  apply_by_living_below(applier);
3046  *type = CFAPI_NONE;
3047 }
3048 
3055 static void cfapi_object_apply(int *type, ...) {
3056  va_list args;
3057  object *applied;
3058  object *applier;
3059  int aflags;
3060  int *ret;
3061 
3062  va_start(args, type);
3063 
3064  applier = va_arg(args, object *);
3065  applied = va_arg(args, object *);
3066  aflags = va_arg(args, int);
3067  ret = va_arg(args, int *);
3068 
3069  va_end(args);
3070 
3071  *type = CFAPI_INT;
3072  *ret = apply_manual(applier, applied, aflags);
3073 }
3074 
3080 static void cfapi_object_identify(int *type, ...) {
3081  va_list args;
3082  object *op, **result;
3083 
3084  va_start(args, type);
3085 
3086  op = va_arg(args, object *);
3087  result = va_arg(args, object **);
3088 
3089  va_end(args);
3090 
3091  (*result) = identify(op);
3092  *type = CFAPI_POBJECT;
3093 }
3094 
3100 static void cfapi_object_describe(int *type, ...) {
3101  va_list args;
3102  object *op;
3103  object *owner;
3104  char *desc, *final;
3105  int size;
3106 
3107  va_start(args, type);
3108 
3109  op = va_arg(args, object *);
3110  owner = va_arg(args, object *);
3111  desc = va_arg(args, char *);
3112  size = va_arg(args, int);
3113  va_end(args);
3114 
3115  *type = CFAPI_STRING;
3116  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3117  strncpy(desc, final, size);
3118  desc[size - 1] = '\0';
3119  free(final);
3120 }
3121 
3122 static void cfapi_object_drain(int *type, ...) {
3123  va_list args;
3124 
3125  object *op;
3126  int ds;
3127 
3128  va_start(args, type);
3129 
3130  op = va_arg(args, object *);
3131  ds = va_arg(args, int);
3132 
3133  va_end(args);
3134 
3135  drain_specific_stat(op, ds);
3136 
3137  *type = CFAPI_NONE;
3138 }
3139 
3140 static void cfapi_object_remove_depletion(int *type, ...) {
3141  va_list args;
3142 
3143  object *op;
3144  int level, *result;
3145 
3146  va_start(args, type);
3147 
3148  op = va_arg(args, object *);
3149  level = va_arg(args, int);
3150  result = va_arg(args, int*);
3151 
3152  va_end(args);
3153 
3154  *result = remove_depletion(op, level);
3155 
3156  *type = CFAPI_INT;
3157 }
3158 
3159 static void cfapi_object_fix(int *type, ...) {
3160  va_list args;
3161  object *op;
3162 
3163  va_start(args, type);
3164 
3165  op = va_arg(args, object *);
3166 
3167  va_end(args);
3168 
3169  fix_object(op);
3170 
3171  *type = CFAPI_NONE;
3172 }
3173 
3175 static void cfapi_object_give_skill(int *type, ...) {
3176  va_list args;
3177 
3178  object *op;
3179  char *skillname;
3180 
3181  va_start(args, type);
3182 
3183  op = va_arg(args, object *);
3184  skillname = va_arg(args, char *);
3185 
3186  va_end(args);
3187 
3188  *type = CFAPI_POBJECT;
3189  give_skill_by_name(op, skillname);
3190 }
3191 
3192 static void cfapi_object_transmute(int *type, ...) {
3193  va_list args;
3194 
3195  object *op;
3196  object *chg;
3197 
3198  va_start(args, type);
3199 
3200  op = va_arg(args, object *);
3201  chg = va_arg(args, object *);
3202 
3203  va_end(args);
3204 
3205  transmute_materialname(op, chg);
3206  *type = CFAPI_NONE;
3207 }
3208 
3209 static void cfapi_object_remove(int *type, ...) {
3210  va_list args;
3211  object *op;
3212 
3213  va_start(args, type);
3214 
3215  op = va_arg(args, object *);
3216 
3217  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3218  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3219  va_end(args);
3220  *type = CFAPI_NONE;
3221  return;
3222  }
3223 
3224  va_end(args);
3225 
3226  object_remove(op);
3227  *type = CFAPI_NONE;
3228 }
3229 
3230 static void cfapi_object_delete(int *type, ...) {
3231  va_list args;
3232  object *op;
3233 
3234  va_start(args, type);
3235 
3236  op = va_arg(args, object *);
3237 
3238  if (QUERY_FLAG(op, FLAG_FREED) || !QUERY_FLAG(op, FLAG_REMOVED)) {
3239  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3240  *type = CFAPI_NONE;
3241  va_end(args);
3242  return;
3243  }
3244 
3245  va_end(args);
3246 
3248 
3249  *type = CFAPI_NONE;
3250 }
3251 
3257 static void cfapi_object_clone(int *type, ...) {
3258  va_list args;
3259  object *op;
3260  int kind;
3261  object **robj;
3262 
3263  va_start(args, type);
3264 
3265  op = va_arg(args, object *);
3266  kind = va_arg(args, int);
3267  robj = va_arg(args, object **);
3268 
3269  va_end(args);
3270 
3271  if (kind == 0) {
3272  *type = CFAPI_POBJECT;
3273  *robj = object_create_clone(op);
3274  } else {
3275  object *tmp;
3276  tmp = object_new();
3277  object_copy(op, tmp);
3278  *type = CFAPI_POBJECT;
3279  *robj = tmp;
3280  }
3281  return;
3282 }
3283 
3289 static void cfapi_object_create(int *type, ...) {
3290  va_list args;
3291  int ival;
3292  object **robj;
3293  va_start(args, type);
3294  ival = va_arg(args, int);
3295 
3296  *type = CFAPI_POBJECT;
3297  switch (ival) {
3298  case 0:
3299  robj = va_arg(args, object **);
3300  *robj = object_new();
3301  break;
3302 
3303  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3304  const char *sval;
3305  archetype *at;
3306 
3307  sval = va_arg(args, const char *);
3308  robj = va_arg(args, object **);
3309  va_end(args);
3310 
3311  at = try_find_archetype(sval);
3312  if (!at)
3313  at = find_archetype_by_object_name(sval);
3314  if (at) {
3315  *robj = object_create_arch(at);
3316  } else
3317  *robj = NULL;
3318  }
3319  break;
3320 
3321  default:
3322  *type = CFAPI_NONE;
3323  break;
3324  }
3325  va_end(args);
3326 }
3327 
3328 static void cfapi_object_insert(int *type, ...) {
3329  va_list args;
3330  object *op;
3331  object *orig;
3332  mapstruct *map;
3333  int flag, x, y;
3334  int itype;
3335  object **robj;
3336 
3337  va_start(args, type);
3338 
3339  op = va_arg(args, object *);
3340  if (!op) {
3341  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3342  va_end(args);
3343  return;
3344  }
3345  if (QUERY_FLAG(op, FLAG_FREED)) {
3346  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3347  va_end(args);
3348  return;
3349  }
3350  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3351  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3352  object_remove(op);
3353  }
3354  itype = va_arg(args, int);
3355 
3356  switch (itype) {
3357  case 0:
3358  map = va_arg(args, mapstruct *);
3359  orig = va_arg(args, object *);
3360  flag = va_arg(args, int);
3361  x = va_arg(args, int);
3362  y = va_arg(args, int);
3363  robj = va_arg(args, object **);
3364  if (!map) {
3365  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3367  *robj = NULL;
3368  } else
3369  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3370  *type = CFAPI_POBJECT;
3371  break;
3372 
3373  case 1:
3374  map = va_arg(args, mapstruct *);
3375  orig = va_arg(args, object *);
3376  flag = va_arg(args, int);
3377  robj = va_arg(args, object **);
3378  if (!map) {
3379  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3381  *robj = NULL;
3382  } else
3383  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3384  *type = CFAPI_POBJECT;
3385  break;
3386 
3387  case 2:
3388  map = va_arg(args, mapstruct *);
3389  orig = va_arg(args, object *);
3390  flag = va_arg(args, int);
3391  x = va_arg(args, int);
3392  y = va_arg(args, int);
3393  robj = va_arg(args, object **);
3394  if (!map) {
3395  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3397  *robj = NULL;
3398  } else {
3399  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3400  if (dir != -1) {
3401  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3402  } else {
3404  *robj = NULL;
3405  }
3406  }
3407  *type = CFAPI_POBJECT;
3408  break;
3409 
3410  case 3:
3411  orig = va_arg(args, object *);
3412  robj = va_arg(args, object **);
3413  if (!orig) {
3414  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3416  *robj = NULL;
3417  } else
3418  *robj = object_insert_in_ob(op, orig);
3419  *type = CFAPI_POBJECT;
3420  break;
3421 
3422  default:
3423  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3425  *type = CFAPI_NONE;
3426  break;
3427  }
3428 
3429  va_end(args);
3430 }
3436 static void cfapi_object_split(int *type, ...) {
3437  va_list args;
3438 
3439  int nr, size;
3440  object *op;
3441  char *buf;
3442  object **split;
3443 
3444  va_start(args, type);
3445 
3446  op = va_arg(args, object *);
3447  nr = va_arg(args, int);
3448  buf = va_arg(args, char *);
3449  size = va_arg(args, int);
3450  split = va_arg(args, object **);
3451  va_end(args);
3452 
3453  *split = object_split(op, nr, buf, size);
3454  if (*split != NULL)
3455  {
3456  *type = CFAPI_POBJECT;
3457  }
3458  else
3459  {
3460  *type = CFAPI_NONE;
3461  }
3462 }
3463 
3469 static void cfapi_object_merge(int *type, ...) {
3470  va_list args;
3471  object *op;
3472  object *op2;
3473  object **merge;
3474 
3475  va_start(args, type);
3476 
3477  op = va_arg(args, object *);
3478  op2 = va_arg(args, object *);
3479  merge = va_arg(args, object **);
3480 
3481  va_end(args);
3482 
3483  *type = CFAPI_POBJECT;
3484  *merge = object_merge(op, op2);
3485 }
3486 
3492 static void cfapi_object_distance(int *type, ...) {
3493  va_list args;
3494  object *op;
3495  object *op2;
3496  int *rint;
3497  va_start(args, type);
3498 
3499  op = va_arg(args, object *);
3500  op2 = va_arg(args, object *);
3501  rint = va_arg(args, int *);
3502 
3503  va_end(args);
3504 
3505  *type = CFAPI_INT;
3506  *rint = object_distance(op, op2);
3507 }
3513 static void cfapi_object_update(int *type, ...) {
3514  va_list args;
3515  int action;
3516  object *op;
3517  va_start(args, type);
3518 
3519  op = va_arg(args, object *);
3520  action = va_arg(args, int);
3521 
3522  va_end(args);
3523 
3524  object_update(op, action);
3525  *type = CFAPI_NONE;
3526 }
3527 
3533 static void cfapi_object_clear(int *type, ...) {
3534  va_list args;
3535  object *op;
3536  va_start(args, type);
3537 
3538  op = va_arg(args, object *);
3539 
3540  va_end(args);
3541 
3542  object_clear(op);
3543  *type = CFAPI_NONE;
3544 }
3545 
3551 static void cfapi_object_reset(int *type, ...) {
3552  va_list args;
3553  object *op;
3554 
3555  va_start(args, type);
3556 
3557  op = va_arg(args, object *);
3558 
3559  va_end(args);
3560 
3561  object_reset(op);
3562  *type = CFAPI_NONE;
3563 }
3564 
3565 static void cfapi_object_clean_object(int *type, ...) {
3566  va_list args;
3567  object *op;
3568 
3569  va_start(args, type);
3570  op = va_arg(args, object *);
3571  clean_object(op);
3572  va_end(args);
3573  *type = CFAPI_NONE;
3574 }
3575 
3576 static void cfapi_object_on_same_map(int *type, ...) {
3577  va_list args;
3578  object *op1;
3579  object *op2;
3580  int *rint;
3581 
3582  va_start(args, type);
3583  op1 = va_arg(args, object *);
3584  op2 = va_arg(args, object *);
3585  rint = va_arg(args, int *);
3586  va_end(args);
3587 
3588  *type = CFAPI_INT;
3589  *rint = on_same_map(op1, op2);
3590 }
3591 
3592 static void cfapi_object_spring_trap(int *type, ...) {
3593  object *trap;
3594  object *victim;
3595  va_list args;
3596 
3597  va_start(args, type);
3598  trap = va_arg(args, object *);
3599  victim = va_arg(args, object *);
3600  va_end(args);
3601 
3602  spring_trap(trap, victim);
3603  *type = CFAPI_NONE;
3604 }
3605 
3611 static void cfapi_object_check_trigger(int *type, ...) {
3612  object *op;
3613  object *cause;
3614  va_list args;
3615  int *rint;
3616 
3617  va_start(args, type);
3618  op = va_arg(args, object *);
3619  cause = va_arg(args, object *);
3620  rint = va_arg(args, int *);
3621  va_end(args);
3622 
3623  *rint = check_trigger(op, cause);
3624  *type = CFAPI_INT;
3625 }
3626 
3638 static void cfapi_map_trigger_connected(int *type, ...) {
3639  objectlink *ol;
3640  object *cause;
3641  int state;
3642  va_list args;
3643 
3644  va_start(args, type);
3645  ol = va_arg(args, objectlink *);
3646  cause = va_arg(args, object *);
3647  state = va_arg(args, int);
3648  va_end(args);
3649  trigger_connected(ol, cause, state);
3650  *type = CFAPI_NONE;
3651 }
3652 
3658 static void cfapi_object_query_money(int *type, ...) {
3659  object *op;
3660  va_list args;
3661  int *rint;
3662 
3663  va_start(args, type);
3664  op = va_arg(args, object *);
3665  rint = va_arg(args, int *);
3666  va_end(args);
3667 
3668  *rint = query_money(op);
3669  *type = CFAPI_INT;
3670 }
3671 
3677 static void cfapi_object_cast(int *type, ...) {
3678  object *op;
3679  object *sp;
3680  int dir;
3681  char *str;
3682  object *caster;
3683  va_list args;
3684  int *rint;
3685 
3686  va_start(args, type);
3687  op = va_arg(args, object *);
3688  caster = va_arg(args, object *);
3689  dir = va_arg(args, int);
3690  sp = va_arg(args, object *);
3691  str = va_arg(args, char *);
3692  rint = va_arg(args, int *);
3693  va_end(args);
3694 
3695  *type = CFAPI_INT;
3696 
3697  if (!op->map) {
3698  *rint = -1;
3699  return;
3700  }
3701 
3702  *rint = cast_spell(op, caster, dir, sp, str);
3703 }
3704 
3705 static void cfapi_object_learn_spell(int *type, ...) {
3706  object *op;
3707  object *sp;
3708  int prayer;
3709  va_list args;
3710 
3711  va_start(args, type);
3712  op = va_arg(args, object *);
3713  sp = va_arg(args, object *);
3714  prayer = va_arg(args, int);
3715  va_end(args);
3716  do_learn_spell(op, sp, prayer);
3717  *type = CFAPI_NONE;
3718 }
3719 
3720 static void cfapi_object_forget_spell(int *type, ...) {
3721  object *op;
3722  object *sp;
3723  va_list args;
3724  char name[MAX_BUF];
3725 
3726  va_start(args, type);
3727  op = va_arg(args, object *);
3728  sp = va_arg(args, object *);
3729  va_end(args);
3730  query_name(sp, name, MAX_BUF);
3731  do_forget_spell(op, name);
3732  *type = CFAPI_NONE;
3733 }
3734 
3740 static void cfapi_object_check_spell(int *type, ...) {
3741  object *op;
3742  char *spellname;
3743  va_list args;
3744  object **robj;
3745 
3746  va_start(args, type);
3747  op = va_arg(args, object *);
3748  spellname = va_arg(args, char *);
3749  robj = va_arg(args, object **);
3750  va_end(args);
3751  *robj = check_spell_known(op, spellname);
3752  *type = CFAPI_POBJECT;
3753 }
3754 
3760 static void cfapi_object_pay_amount(int *type, ...) {
3761  object *op;
3762  uint64_t amount;
3763  va_list args;
3764  int *rint;
3765 
3766  va_start(args, type);
3767  op = va_arg(args, object *);
3768  amount = va_arg(args, uint64_t);
3769  rint = va_arg(args, int *);
3770  va_end(args);
3771 
3772  *rint = pay_for_amount(amount, op);
3773  *type = CFAPI_INT;
3774 }
3775 
3781 static void cfapi_object_pay_item(int *type, ...) {
3782  object *op;
3783  object *tobuy;
3784  int *rint;
3785 
3786  va_list args;
3787 
3788  va_start(args, type);
3789  tobuy = va_arg(args, object *);
3790  op = va_arg(args, object *);
3791  rint = va_arg(args, int *);
3792  va_end(args);
3793 
3794  *rint = pay_for_item(tobuy, op, 0);
3795  *type = CFAPI_INT;
3796 }
3797 
3805 static void cfapi_object_transfer(int *type, ...) {
3806  object *op;
3807  object *originator;
3808  int x, y, randompos, ttype, flag;
3809  va_list args;
3810  mapstruct *map;
3811  int *rint;
3812  object **robj;
3813 
3814  va_start(args, type);
3815  op = va_arg(args, object *);
3816  ttype = va_arg(args, int);
3817  switch (ttype) {
3818  case 0:
3819  x = va_arg(args, int);
3820  y = va_arg(args, int);
3821  randompos = va_arg(args, int);
3822  originator = va_arg(args, object *);
3823  rint = va_arg(args, int *);
3824  va_end(args);
3825 
3826  *rint = transfer_ob(op, x, y, randompos, originator);
3827  *type = CFAPI_INT;
3828  return;
3829  break;
3830 
3831  case 1:
3832  map = va_arg(args, mapstruct *);
3833  originator = va_arg(args, object *);
3834  flag = va_arg(args, int);
3835  x = va_arg(args, int);
3836  y = va_arg(args, int);
3837  robj = va_arg(args, object **);
3838  va_end(args);
3839  if (x < 0 || y < 0) {
3840  x = map->enter_x;
3841  y = map->enter_y;
3842  }
3843  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
3844  *type = CFAPI_POBJECT;
3845  return;
3846  break;
3847 
3848  case 2:
3849  x = va_arg(args, int);
3850  y = va_arg(args, int);
3851  rint = va_arg(args, int *);
3852  va_end(args);
3853 
3854  *rint = move_to(op, x, y);
3855  *type = CFAPI_INT;
3856  return;
3857 
3858  default:
3859  va_end(args);
3860  *type = CFAPI_NONE;
3861  return;
3862  break;
3863  }
3864 }
3865 
3870  object *op;
3871  char *str;
3872  va_list args;
3873  object **robj;
3874 
3875  *type = CFAPI_POBJECT;
3876  va_start(args, type);
3877  op = va_arg(args, object *);
3878 
3879  str = va_arg(args, char *);
3880  robj = va_arg(args, object **);
3881  archetype *at = try_find_archetype(str);
3882  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
3883  if (*robj == NULL) {
3884  char name[MAX_BUF];
3885 
3886  /* Search by name or slaying instead */
3887  FOR_INV_PREPARE(op, tmp) {
3888  if (tmp->name) {
3889  query_name(tmp, name, MAX_BUF);
3890  if (!strncmp(name, str, strlen(str)))
3891  *robj = tmp;
3892  if (!strncmp(tmp->name, str, strlen(str)))
3893  *robj = tmp;
3894  }
3895  if (tmp->slaying && !strcmp(tmp->slaying, str))
3896  *robj = tmp;
3897  if (*robj != NULL)
3898  break;
3899  } FOR_INV_FINISH();
3900  }
3901  va_end(args);
3902 }
3903 
3904 static void cfapi_object_find_by_arch_name(int *type, ...) {
3905  const object *who;
3906  object **result;
3907  const char *name;
3908  va_list args;
3909 
3910  va_start(args, type);
3911  who = va_arg(args, const object *);
3912  name = va_arg(args, const char *);
3913  result = va_arg(args, object **);
3914  va_end(args);
3915  *type = CFAPI_POBJECT;
3916 
3917  *result = object_find_by_arch_name(who, name);
3918 }
3919 
3920 static void cfapi_object_find_by_name(int *type, ...) {
3921  const object *who;
3922  object **result;
3923  const char *name;
3924  va_list args;
3925 
3926  va_start(args, type);
3927  who = va_arg(args, const object *);
3928  name = va_arg(args, const char *);
3929  result = va_arg(args, object **);
3930  va_end(args);
3931  *type = CFAPI_POBJECT;
3932 
3933  *result = object_find_by_name(who, name);
3934 }
3935 
3941 static void cfapi_object_drop(int *type, ...) {
3942  object *op;
3943  object *author;
3944  va_list args;
3945 
3946  va_start(args, type);
3947  op = va_arg(args, object *);
3948  author = va_arg(args, object *);
3949  va_end(args);
3950  *type = CFAPI_NONE;
3951 
3952  if (QUERY_FLAG(op, FLAG_NO_DROP))
3953  return;
3954  drop(author, op);
3955 
3956  if (author->type == PLAYER) {
3957  author->contr->count = 0;
3958  author->contr->socket->update_look = 1;
3959  }
3960 }
3961 
3965 static void cfapi_object_change_abil(int *type, ...) {
3966  object *op, *tmp;
3967  int *rint;
3968  va_list args;
3969 
3970  va_start(args, type);
3971  op = va_arg(args, object *);
3972  tmp = va_arg(args, object *);
3973  rint = va_arg(args, int *);
3974  va_end(args);
3975 
3976  *type = CFAPI_INT;
3977  *rint = change_abil(op, tmp);
3978 }
3979 
3980 static void cfapi_object_say(int *type, ...) {
3981  object *op;
3982  char *msg;
3983  va_list args;
3984  int *rint;
3985  char empty[] = "";
3986 
3987  va_start(args, type);
3988  op = va_arg(args, object *);
3989  msg = va_arg(args, char *);
3990  rint = va_arg(args, int *);
3991  va_end(args);
3992 
3993  if (op->type == PLAYER) {
3994  command_say(op, msg == NULL ? empty : msg);
3995  } else {
3996  monster_npc_say(op, msg);
3997  }
3998  *rint = 0;
3999  *type = CFAPI_INT;
4000 }
4001 
4002 /* PLAYER SUBCLASS */
4003 
4009 static void cfapi_player_find(int *type, ...) {
4010  va_list args;
4011  char *sval;
4012  player **rpl;
4013  va_start(args, type);
4014 
4015  sval = va_arg(args, char *);
4016  rpl = va_arg(args, player **);
4017  va_end(args);
4018 
4019  *rpl = find_player_partial_name(sval);
4020 
4021  *type = CFAPI_PPLAYER;
4022 }
4023 
4024 static void cfapi_player_message(int *type, ...) {
4025  va_list args;
4026  int flags;
4027  int pri;
4028  object *pl;
4029  const char *buf;
4030 
4031  va_start(args, type);
4032 
4033  flags = va_arg(args, int);
4034  pri = va_arg(args, int);
4035  pl = va_arg(args, object *);
4036  buf = va_arg(args, const char *);
4037  va_end(args);
4038 
4040  buf);
4041  *type = CFAPI_NONE;
4042 }
4043 
4050 static void cfapi_object_perm_exp(int *type, ...) {
4051  va_list args;
4052  object *op;
4053  int64_t *rlong;
4054 
4055  va_start(args, type);
4056  op = va_arg(args, object *);
4057  rlong = va_arg(args, int64_t *);
4058  va_end(args);
4059 
4060  *type = CFAPI_SINT64;
4061  *rlong = PERM_EXP(op->total_exp);
4062 }
4063 
4069 static void cfapi_object_change_exp(int *type, ...) {
4070  va_list args;
4071  int flag;
4072  object *ob;
4073  const char *skill;
4074  int64_t exp;
4075 
4076  va_start(args, type);
4077  ob = va_arg(args, object *);
4078  exp = va_arg(args, int64_t);
4079  skill = va_arg(args, const char *);
4080  flag = va_arg(args, int);
4081  va_end(args);
4082 
4083  *type = CFAPI_NONE;
4084  change_exp(ob, exp, skill, flag);
4085 }
4086 
4092 static void cfapi_player_can_pay(int *type, ...) {
4093  va_list args;
4094  object *pl;
4095  int *rint;
4096 
4097  va_start(args, type);
4098  pl = va_arg(args, object *);
4099  rint = va_arg(args, int *);
4100  va_end(args);
4101 
4102  *rint = can_pay(pl);
4103  *type = CFAPI_INT;
4104 }
4105 
4111 static void cfapi_player_knowledge(int *type, ...) {
4112  va_list args;
4113  object *pl;
4114  int *rint, what;
4115  const char *knowledge;
4116 
4117  va_start(args, type);
4118  what = va_arg(args, int);
4119 
4120  switch(what)
4121  {
4122  case 1:
4123  pl = va_arg(args, object *);
4124  knowledge = va_arg(args, const char *);
4125  rint = va_arg(args, int *);
4126 
4127  *type = CFAPI_INT;
4128 
4129  if (pl->contr == NULL) {
4130  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4131  *rint = 0;
4132  va_end(args);
4133  return;
4134  }
4135 
4136  *rint = knowledge_player_knows(pl->contr, knowledge);
4137  break;
4138 
4139  case 2:
4140  pl = va_arg(args, object *);
4141  knowledge = va_arg(args, const char *);
4142  *type = CFAPI_NONE;
4143  if (pl->contr != NULL)
4144  knowledge_give(pl->contr, knowledge, NULL);
4145 
4146  break;
4147 
4148  default:
4149  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4150  }
4151 
4152  va_end(args);
4153 }
4154 
4160 static void cfapi_object_teleport(int *type, ...) {
4161  mapstruct *map;
4162  int x, y;
4163  object *who;
4164  int *res;
4165  va_list args;
4166 
4167  va_start(args, type);
4168  who = va_arg(args, object *);
4169  map = va_arg(args, mapstruct *);
4170  x = va_arg(args, int);
4171  y = va_arg(args, int);
4172  res = va_arg(args, int *);
4173  va_end(args);
4174 
4175  *type = CFAPI_INT;
4176  *res = object_teleport(who, map, x, y);
4177 }
4178 
4179 static void cfapi_object_pickup(int *type, ...) {
4180  object *who;
4181  object *what;
4182  va_list args;
4183 
4184  va_start(args, type);
4185  who = va_arg(args, object *);
4186  what = va_arg(args, object *);
4187  int *res = va_arg(args, int *);
4188  va_end(args);
4189 
4190  *type = CFAPI_INT;
4191  *res = pick_up(who, what);
4192 }
4193 
4194 /* Archetype-related functions */
4195 static void cfapi_archetype_get_property(int *type, ...) {
4196  int prop;
4197  archetype *arch;
4198  va_list args;
4199  sstring *rsstring;
4200  archetype **rarch;
4201  object **robject;
4202 
4203  va_start(args, type);
4204  arch = va_arg(args, archetype *);
4205  prop = va_arg(args, int);
4206  switch (prop) {
4207  case CFAPI_ARCH_PROP_NAME:
4208  *type = CFAPI_SSTRING;
4209  rsstring = va_arg(args, sstring *);
4210  *rsstring = arch->name;
4211  break;
4212 
4213  case CFAPI_ARCH_PROP_NEXT:
4214  *type = CFAPI_PARCH;
4215  rarch = va_arg(args, archetype **);
4216  *rarch = get_next_archetype(arch);
4217  break;
4218 
4219  case CFAPI_ARCH_PROP_HEAD:
4220  *type = CFAPI_PARCH;
4221  rarch = va_arg(args, archetype **);
4222  *rarch = arch->head;
4223  break;
4224 
4225  case CFAPI_ARCH_PROP_MORE:
4226  *type = CFAPI_PARCH;
4227  rarch = va_arg(args, archetype **);
4228  *rarch = arch->more;
4229  break;
4230 
4231  case CFAPI_ARCH_PROP_CLONE:
4232  *type = CFAPI_POBJECT;
4233  robject = va_arg(args, object **);
4234  *robject = &arch->clone;
4235  break;
4236 
4237  default:
4238  *type = CFAPI_NONE;
4239  break;
4240  }
4241  va_end(args);
4242 }
4243 
4250 static void cfapi_party_get_property(int *type, ...) {
4251  partylist *party;
4252  int prop;
4253  va_list args;
4254  object *obarg;
4255  sstring *rsstring;
4256  player **rplayer;
4257  partylist **rparty;
4258 
4259  va_start(args, type);
4260  party = va_arg(args, partylist *);
4261  prop = va_arg(args, int);
4262  switch (prop) {
4263  case CFAPI_PARTY_PROP_NAME:
4264  rsstring = va_arg(args, sstring *);
4265  *rsstring = party->partyname;
4266  *type = CFAPI_SSTRING;
4267  break;
4268 
4269  case CFAPI_PARTY_PROP_NEXT:
4270  rparty = va_arg(args, partylist **);
4271  *rparty = (party ? party_get_next(party) : party_get_first());
4272  *type = CFAPI_PPARTY;
4273  break;
4274 
4276  rsstring = va_arg(args, sstring *);
4277  *rsstring = party_get_password(party);
4278  *type = CFAPI_SSTRING;
4279  break;
4280 
4282  *type = CFAPI_PPLAYER;
4283  obarg = va_arg(args, object *);
4284  rplayer = va_arg(args, player **);
4285  *rplayer = (obarg ? obarg->contr : first_player);
4286  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4287  if ((*rplayer)->ob->contr->party == party) {
4288  break;
4289  }
4290  break;
4291 
4292  default:
4293  *type = CFAPI_NONE;
4294  break;
4295  }
4296  va_end(args);
4297 }
4298 
4305 static void cfapi_region_get_property(int *type, ...) {
4306  region *reg;
4307  int prop, *rint;
4308  va_list args;
4310  sstring *rsstring;
4311  region **rregion;
4312 
4313  va_start(args, type);
4314  reg = va_arg(args, region *);
4315  prop = va_arg(args, int);
4316  switch (prop) {
4318  rsstring = va_arg(args, sstring *);
4319  *rsstring = reg->name;
4320  *type = CFAPI_SSTRING;
4321  break;
4322 
4324  rregion = va_arg(args, region **);
4325  *rregion = nullptr;
4326  *type = CFAPI_PREGION;
4327  break;
4328 
4330  rregion = va_arg(args, region **);
4331  *rregion = reg->parent;
4332  *type = CFAPI_PREGION;
4333  break;
4334 
4336  rsstring = va_arg(args, sstring *);
4337  *rsstring = reg->longname;
4338  *type = CFAPI_SSTRING;
4339  break;
4340 
4342  rsstring = va_arg(args, sstring *);
4343  *rsstring = reg->msg;
4344  *type = CFAPI_SSTRING;
4345  break;
4346 
4349  rint = va_arg(args, int*);
4350  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4351  *type = CFAPI_INT;
4352  break;
4353 
4355  rsstring = va_arg(args, sstring *);
4356  *rsstring = reg->jailmap;
4357  *type = CFAPI_SSTRING;
4358  break;
4359 
4360  default:
4361  *type = CFAPI_NONE;
4362  break;
4363  }
4364  va_end(args);
4365 }
4366 
4378 static void cfapi_friendlylist_get_next(int *type, ...) {
4379  object *ob;
4380  va_list args;
4381  object **robject;
4382 
4383  va_start(args, type);
4384  ob = va_arg(args, object *);
4385  robject = va_arg(args, object **);
4386  va_end(args);
4387 
4388  *type = CFAPI_POBJECT;
4389  *robject = get_next_friend(ob);
4390 }
4391 
4392 /*
4393  * Random-map related stuff.
4394  */
4395 
4402 static void cfapi_set_random_map_variable(int *type, ...) {
4403  va_list args;
4404  RMParms *rp;
4405  const char *buf;
4406  int *ret;
4407 
4408  va_start(args, type);
4409  rp = va_arg(args, RMParms *);
4410  buf = va_arg(args, const char *);
4411  ret = va_arg(args, int *);
4412  va_end(args);
4413 
4414  *ret = set_random_map_variable(rp, buf);
4415  *type = CFAPI_INT;
4416 }
4417 
4424 static void cfapi_generate_random_map(int *type, ...) {
4425  va_list args;
4426  const char *name;
4427  RMParms *rp;
4428  char **use_layout;
4429  sstring reset_group;
4430  mapstruct **ret;
4431 
4432  va_start(args, type);
4433  name = va_arg(args, const char *);
4434  rp = va_arg(args, RMParms *);
4435  use_layout = va_arg(args, char **);
4436  reset_group = va_arg(args, sstring);
4437  ret = va_arg(args, mapstruct **);
4438  va_end(args);
4439 
4440  *ret = generate_random_map(name, rp, use_layout, reset_group);
4441 }
4442 
4443 static void cfapi_object_user_event(int *type, ...) {
4444  object *op;
4445  object *activator;
4446  object *third;
4447  const char *message;
4448  int fix;
4449  int *ret;
4450  va_list args;
4451 
4452  va_start(args, type);
4453  op = va_arg(args, object *);
4454  activator = va_arg(args, object *);
4455  third = va_arg(args, object *);
4456  message = va_arg(args, const char *);
4457  fix = va_arg(args, int);
4458  ret = va_arg(args, int *);
4459  va_end(args);
4460 
4461  *ret = events_execute_object_user(op, activator, third, message, fix);
4462  *type = CFAPI_INT;
4463 }
4464 
4467 static void cfapi_player_quest(int *type, ...) {
4468  int op;
4469  va_list args;
4470  object *player;
4471  sstring code;
4472 
4473  va_start(args, type);
4474  op = va_arg(args, int);
4475  player = va_arg(args, object *);
4476  code = va_arg(args, sstring);
4477 
4478  if (player->contr == NULL) {
4479  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4480  va_end(args);
4481  /* crash/quit? */
4482  return;
4483  }
4484 
4485  switch(op) {
4486  case CFAPI_PLAYER_QUEST_START: {
4487  int state = va_arg(args, int);
4488  quest_start(player->contr, code, state);
4489  *type = CFAPI_NONE;
4490  break;
4491  }
4493  int *ret = va_arg(args, int *);
4494  *ret = quest_get_player_state(player->contr, code);
4495  *type = CFAPI_INT;
4496  break;
4497  }
4499  int state = va_arg(args, int);
4500  quest_set_player_state(player->contr, code, state);
4501  *type = CFAPI_NONE;
4502  break;
4503  }
4505  int *ret = va_arg(args, int*);
4506  *ret = quest_was_completed(player->contr, code);
4507  *type = CFAPI_INT;
4508  break;
4509  }
4510  default:
4511  LOG(llevError, "invalid quest type: %d\n", op);
4512  *type = CFAPI_NONE;
4513  }
4514 
4515  va_end(args);
4516 }
4517 
4518 static void cfapi_register_command(int *type, ...) {
4519  va_list args;
4520  const char *name = NULL, *extra = NULL;
4521  float time;
4522  command_function func = NULL;
4523  command_function_extra func_extra = NULL;
4524  uint8_t register_type, command_type;
4526 
4527  va_start(args, type);
4528  register_type = va_arg(args, int);
4529  name = va_arg(args, const char *);
4530  if (register_type == 1) {
4531  func = va_arg(args, command_function);
4532  } else {
4533  extra = va_arg(args, const char *);
4534  func_extra = va_arg(args, command_function_extra);
4535  }
4536  command_type = (uint8_t)va_arg(args, int);
4537  if (command_type > COMMAND_TYPE_WIZARD) {
4538  command_type = COMMAND_TYPE_NORMAL;
4539  }
4540  time = va_arg(args, double);
4541  cr = va_arg(args, command_registration *);
4542  va_end(args);
4543 
4544  if (register_type == 1) {
4545  (*cr) = command_register(name, command_type, func, time);
4546  } else {
4547  (*cr) = command_register_extra(name, extra, command_type, func_extra, time);
4548  }
4549 
4550  *type = CFAPI_SINT64;
4551 }
4552 
4553 static void cfapi_unregister_command(int *type, ...) {
4554  va_list args;
4556 
4557  va_start(args, type);
4558  cr = va_arg(args, command_registration);
4559  va_end(args);
4560 
4561  command_unregister(cr);
4562 }
4563 
4564 /*****************************************************************************/
4565 /* NEW PLUGIN STUFF ENDS HERE */
4566 /*****************************************************************************/
4567 
4568 
4573 void initPlugins(void) {
4574  struct dirent *currentfile;
4575  DIR *plugdir;
4576  size_t l;
4577  char buf[sizeof(LIBDIR) + 9 + sizeof(dirent::d_name)];
4578 
4579  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4580  LOG(llevDebug, "plugins: loading from %s\n", buf);
4581 
4582  plugdir = opendir(buf);
4583  if (plugdir == NULL)
4584  return;
4585 
4586  while ((currentfile = readdir(plugdir)) != NULL) {
4587  l = strlen(currentfile->d_name);
4588  if (l > strlen(PLUGIN_SUFFIX)) {
4589  int ignore = 0;
4590 
4591  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4592  continue;
4593 
4594  for (auto disable = serverSettings.disabled_plugins.cbegin(); disable != serverSettings.disabled_plugins.cend(); ++disable) {
4595  if (strcmp(*disable, "All") == 0) {
4596  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4597  ignore = 1;
4598  break;
4599  }
4600  if (strncmp(*disable, currentfile->d_name, strlen(*disable)) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + strlen(*disable)) {
4601  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4602  ignore = 1;
4603  break;
4604  }
4605  }
4606  if (ignore == 0) {
4607  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4608  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4610  }
4611  }
4612  }
4613 
4614  closedir(plugdir);
4615 }
4616 
4621 void cleanupPlugins(void) {
4622  for (crossfire_plugin *cp : plugins_list) {
4623  if (cp->closefunc)
4624  cp->closefunc();
4625  /* Don't actually unload plugins, it makes backtraces for memory
4626  * debugging (printed at exit) messed up. And it doesn't matter if we
4627  * don't free it here. The OS will do it for us.
4628  */
4629  /* plugins_dlclose(cp->libptr); */
4630  free(cp);
4631  }
4632  plugins_list.clear();
4633 }
plugins_find_plugin
static crossfire_plugin * plugins_find_plugin(const char *id)
Find a plugin from its internal name.
Definition: plugins.cpp:269
crossfire_plugin::propfunc
f_plug_property propfunc
Plugin getProperty function
Definition: plugin.h:96
Face::name
sstring name
Face name, as used by archetypes and such.
Definition: face.h:19
object::name_pl
sstring name_pl
The plural name of the object.
Definition: object.h:323
GET_MAP_OB
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
Definition: map.h:170
Face
New face structure - this enforces the notion that data is face by face only - you can not change the...
Definition: face.h:14
cfapi_object_transfer
static void cfapi_object_transfer(int *type,...)
Object transfer.
Definition: plugins.cpp:3805
cfapi_object_clean_object
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.cpp:3565
cfapi_object_forget_spell
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.cpp:3720
player::bed_y
int16_t bed_y
x,y - coordinates of respawn (savebed).
Definition: player.h:111
living::exp
int64_t exp
Experience.
Definition: living.h:47
cfapi_map_change_light
static void cfapi_map_change_light(int *type,...)
Wrapper for change_map_light().
Definition: plugins.cpp:1426
CFAPI_SSTRING
#define CFAPI_SSTRING
Definition: plugin.h:70
UP_OBJ_FACE
#define UP_OBJ_FACE
Only thing that changed was the face.
Definition: object.h:533
CFAPI_OBJECT_PROP_TITLE
#define CFAPI_OBJECT_PROP_TITLE
Definition: plugin.h:132
cfapi_object_split
static void cfapi_object_split(int *type,...)
Wrapper for object_split().
Definition: plugins.cpp:3436
PLAYER
@ PLAYER
Definition: object.h:112
CFAPI_PPLAYER
#define CFAPI_PPLAYER
Definition: plugin.h:64
object_get_owner
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
Definition: object.cpp:789
Settings::mapdir
const char * mapdir
Where the map files are.
Definition: global.h:252
player::next
player * next
Pointer to next player, NULL if this is last.
Definition: player.h:106
cftimer_find_free_id
int cftimer_find_free_id(void)
Finds a free ID for a new timer.
Definition: timers.cpp:144
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
Definition: object.h:545
CFAPI_OBJECT_PROP_X
#define CFAPI_OBJECT_PROP_X
Definition: plugin.h:138
cfapi_object_move
static void cfapi_object_move(int *type,...)
Moves an object.
Definition: plugins.cpp:1457
cfapi_timer_destroy
static void cfapi_timer_destroy(int *type,...)
Wrapper for cftimer_destroy().
Definition: plugins.cpp:989
first_player
player * first_player
First player.
Definition: init.cpp:106
settings
struct Settings settings
Global settings.
Definition: init.cpp:139
object::move_status
int32_t move_status
What stage in attack mode.
Definition: object.h:400
object_get_env_recursive
object * object_get_env_recursive(object *op)
Utility function.
Definition: object.cpp:575
CFAPI_POBJECT
#define CFAPI_POBJECT
Definition: plugin.h:58
CFAPI_PARTY_VECTOR
#define CFAPI_PARTY_VECTOR
Pointer to a std::vector<partylist *>
Definition: plugin.h:76
f_plug_postinit
int(* f_plug_postinit)(void)
Function called after the plugin was initialized.
Definition: plugin.h:81
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
remove_friendly_object
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
Definition: friend.cpp:52
CFAPI_OBJECT_VECTOR
#define CFAPI_OBJECT_VECTOR
Pointer to a std::vector<object *>
Definition: plugin.h:72
CFAPI_OBJECT_PROP_CHA
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:203
living::maxhp
int16_t maxhp
Max hit points.
Definition: living.h:41
CFAPI_MAP_PROP_TMPNAME
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h:249
CFAPI_OBJECT_PROP_ARCH_NAME
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:215
CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
Definition: plugin.h:178
llevError
@ llevError
Error, serious thing.
Definition: logger.h:11
cfapi_object_distance
static void cfapi_object_distance(int *type,...)
Wrapper for object_distance().
Definition: plugins.cpp:3492
cfapi_object_delete
static void cfapi_object_delete(int *type,...)
Definition: plugins.cpp:3230
cfapi_player_quest
static void cfapi_player_quest(int *type,...)
Quest-related wrappers, for all quest-related operations.
Definition: plugins.cpp:4467
MOVE_ALL
#define MOVE_ALL
Mask of all movement types.
Definition: define.h:398
cfapi_timer_create
static void cfapi_timer_create(int *type,...)
Wrapper for cfapi_timer_create().
Definition: plugins.cpp:956
object::path_attuned
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:353
command_say
void command_say(object *op, const char *params)
'say' command.
Definition: c_chat.cpp:34
CFAPI_PARTY_PROP_NAME
#define CFAPI_PARTY_PROP_NAME
Definition: plugin.h:271
cfapi_archetype_get_property
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.cpp:4195
NR_EVENTS
#define NR_EVENTS
Number of events, maximum code + 1.
Definition: events.h:74
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
get_empty_map
mapstruct * get_empty_map(int sizex, int sizey)
Creates and returns a map of the specific size.
Definition: map.cpp:852
monster_npc_say
void monster_npc_say(object *npc, const char *cp)
Simple function to have some NPC say something.
Definition: monster.cpp:2617
CFAPI_MAP_PROP_RESET_TIME
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:251
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
drain_specific_stat
void drain_specific_stat(object *op, int deplete_stats)
Drain a specified stat from op.
Definition: living.cpp:728
CFAPI_MAP_PROP_RESET_TIMEOUT
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:252
archetype::more
archetype * more
Next part of a linked object.
Definition: object.h:486
cfapi_system_register_global_event
static void cfapi_system_register_global_event(int *type,...)
Definition: plugins.cpp:586
CFAPI_REGION_PROP_LONGNAME
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:279
cfapi_system_get_party_vector
static void cfapi_system_get_party_vector(int *type,...)
Definition: plugins.cpp:699
CFAPI_OBJECT_PROP_LEVEL
#define CFAPI_OBJECT_PROP_LEVEL
Definition: plugin.h:157
CFAPI_NONE
#define CFAPI_NONE
Definition: plugin.h:53
player
One player.
Definition: player.h:105
plugins_list
std::vector< crossfire_plugin * > plugins_list
List of loaded plugins.
Definition: plugins.cpp:258
object::client_type
uint16_t client_type
Public type information.
Definition: object.h:350
CFAPI_PLAYER_PROP_BED_X
#define CFAPI_PLAYER_PROP_BED_X
Definition: plugin.h:234
strdup_local
#define strdup_local
Definition: compat.h:29
object::inv
object * inv
Pointer to the first object in the inventory.
Definition: object.h:298
cfapi_object_drop
static void cfapi_object_drop(int *type,...)
Wrapper for drop().
Definition: plugins.cpp:3941
ready_map_name
mapstruct * ready_map_name(const char *name, int flags)
Makes sure the given map is loaded and swapped in.
Definition: map.cpp:1778
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:655
CFAPI_REGION_PROP_NEXT
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:277
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:262
AssetsManager.h
CFAPI_MAP_PROP_NEXT
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:261
NR_OF_HOOKS
#define NR_OF_HOOKS
Number of hooked functions a plugin can call.
Definition: plugins.cpp:50
do_learn_spell
void do_learn_spell(object *op, object *spell, int special_prayer)
Actually makes op learn spell.
Definition: apply.cpp:484
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
If set, don't check plugin version.
Definition: global.h:327
has_been_loaded
mapstruct * has_been_loaded(const char *name)
Checks whether map has been loaded.
Definition: map.cpp:79
map_find_by_archetype
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Searches for any objects with a matching archetype at the given map and coordinates.
Definition: object.cpp:3103
object_merge
object * object_merge(object *op, object *top)
This function goes through all objects below and including top, and merges op to the first matching o...
Definition: object.cpp:2036
player::mark_count
uint32_t mark_count
Count of marked object.
Definition: player.h:212
get_next_friend
object * get_next_friend(object *current)
Get the next object on the friendly list.
Definition: friend.cpp:143
pick_up
bool pick_up(object *op, object *alt)
Try to pick up an item.
Definition: c_object.cpp:520
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,...)
Wrapper for get_season_name().
Definition: plugins.cpp:917
update_position
void update_position(mapstruct *m, int x, int y)
This function updates various attributes about a specific space on the map (what it looks like,...
Definition: map.cpp:2148
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
object::item_power
int8_t item_power
Power rating of the object.
Definition: object.h:372
cfapi_map_out_of_map
static void cfapi_map_out_of_map(int *type,...)
Wrapper for out_of_map().
Definition: plugins.cpp:1297
Settings::datadir
const char * datadir
Read only data files.
Definition: global.h:249
object::arch
struct archetype * arch
Pointer to archetype.
Definition: object.h:424
cast_spell
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Main dispatch when someone casts a spell.
Definition: spell_util.cpp:1424
player::bed_x
int16_t bed_x
Definition: player.h:111
events_unregister_object_handler
void events_unregister_object_handler(const char *id)
Remove an object event handler.
Definition: events.cpp:304
mapstruct::players
int16_t players
How many players are on this level right now.
Definition: map.h:334
CFAPI_PLAYER_PROP_COUNT
#define CFAPI_PLAYER_PROP_COUNT
Definition: plugin.h:239
CFAPI_OBJECT_PROP_BASE_NAME
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:187
object::attack_movement
uint16_t attack_movement
What kind of attack movement.
Definition: object.h:401
hook_entry
One function the server exposes to plugins.
Definition: plugin.h:308
UPD_WEIGHT
#define UPD_WEIGHT
Definition: newclient.h:320
object::speed
float speed
Frequency of object 'moves' relative to server tick rate.
Definition: object.h:337
object_set_enemy
void object_set_enemy(object *op, object *enemy)
Sets the enemy of an object.
Definition: object.cpp:900
object::invisible
int16_t invisible
How much longer the object will be invis.
Definition: object.h:370
mapstruct::tmpname
char * tmpname
Name of temporary file.
Definition: map.h:317
living::Dex
int8_t Dex
Definition: living.h:36
CFAPI_OBJECT_PROP_LAST_EAT
#define CFAPI_OBJECT_PROP_LAST_EAT
Definition: plugin.h:161
object::x
int16_t x
Definition: object.h:335
CFAPI_OBJECT_PROP_MOVE_ON
#define CFAPI_OBJECT_PROP_MOVE_ON
Definition: plugin.h:223
player::ob
object * ob
The object representing the player.
Definition: player.h:177
spring_trap
void spring_trap(object *trap, object *victim)
This function generalizes attacks by runes/traps.
Definition: rune.cpp:214
cfapi_object_get_property
static void cfapi_object_get_property(int *type,...)
Main object property getter.
Definition: plugins.cpp:1552
crossfire_plugin::fullname
char fullname[MAX_BUF]
Plugin full name
Definition: plugin.h:100
CFAPI_FUNC
#define CFAPI_FUNC
Definition: plugin.h:63
CFAPI_OBJECT_PROP_STR
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:197
player::transport
object * transport
Transport the player is in.
Definition: player.h:214
cfapi_object_create
static void cfapi_object_create(int *type,...)
Wrapper for object_new(), create_archetype() and create_archetype_by_object_name().
Definition: plugins.cpp:3289
object::speed_left
float speed_left
How much speed is left to spend this round.
Definition: object.h:338
SVN_REV
#define SVN_REV
Definition: svnversion.h:2
object::pick_up
uint8_t pick_up
See crossfire.doc.
Definition: object.h:371
cfapi_object_drain
static void cfapi_object_drain(int *type,...)
Definition: plugins.cpp:3122
object::map
struct mapstruct * map
Pointer to the map in which this object is present.
Definition: object.h:305
give_skill_by_name
object * give_skill_by_name(object *op, const char *skill_name)
Given the skill name skill_name, we find the skill archetype/object, set appropriate values,...
Definition: living.cpp:1788
set_random_map_variable
int set_random_map_variable(RMParms *rp, const char *buf)
Definition: reader.cpp:2526
quest_set_player_state
void quest_set_player_state(player *pl, sstring quest_code, int state)
Set the state of a quest for a player.
Definition: quest.cpp:716
CFAPI_OBJECT_PROP_GOD
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:214
MoveType
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
Definition: define.h:417
arch_present_in_ob
object * arch_present_in_ob(const archetype *at, const object *op)
Searches for any objects with a matching archetype in the inventory of the given object.
Definition: object.cpp:3207
object_set_owner
void object_set_owner(object *op, object *owner)
Sets the owner and sets the skill and exp pointers to owner's current skill and experience objects.
Definition: object.cpp:825
object::expmul
double expmul
needed experience = (calc_exp*expmul) - means some races/classes can need less/more exp to gain level...
Definition: object.h:407
timeofday_t
Represents the ingame time.
Definition: tod.h:38
CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
Definition: plugin.h:122
player_set_own_title
void player_set_own_title(struct player *pl, const char *title)
Sets the custom title.
Definition: player.cpp:272
mapstruct::height
uint16_t height
Width and height of map.
Definition: map.h:337
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:164
cfapi_object_find_archetype_inside
static void cfapi_object_find_archetype_inside(int *type,...)
Kinda wrapper for arch__present_in_ob().
Definition: plugins.cpp:3869
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:287
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
archetype::head
archetype * head
The main part of a linked object.
Definition: object.h:485
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)
Move player in the given direction.
Definition: player.cpp:2962
object_reset
void object_reset(object *op)
Totally resets the specified object, without freeing associated memory.
Definition: object.cpp:919
CFAPI_ARCH_PROP_NEXT
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:266
object::direction
int8_t direction
Means the object is moving that way.
Definition: object.h:344
CFAPI_OBJECT_PROP_Y
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:139
flags
static const flag_definition flags[]
Flag mapping.
Definition: gridarta-types-convert.cpp:101
object::count
tag_t count
Unique object number for this object.
Definition: object.h:307
CFAPI_OBJECT_PROP_ENEMY
#define CFAPI_OBJECT_PROP_ENEMY
Definition: plugin.h:172
object::last_grace
int16_t last_grace
As last_sp, except for grace.
Definition: object.h:369
object_copy
void object_copy(const object *src_ob, object *dest_ob)
Copy object first frees everything allocated by the second object, and then copies the contents of th...
Definition: object.cpp:1177
clean_object
void clean_object(object *op)
Remove and free all objects in the inventory of the given object.
Definition: map.cpp:1597
CFAPI_OBJECT_PROP_MOVE_TYPE
#define CFAPI_OBJECT_PROP_MOVE_TYPE
Definition: plugin.h:220
player::savebed_map
char savebed_map[MAX_BUF]
Map where player will respawn after death.
Definition: player.h:110
fix_object
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
Definition: living.cpp:1132
get_tod
void get_tod(timeofday_t *tod)
Computes the ingame time of the day.
Definition: time.cpp:219
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:3980
CFAPI_REGION_PROP_PARENT
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:278
plugin.h
CFAPI_OBJECT_PROP_ENVIRONMENT
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:125
COMMAND_TYPE_NORMAL
#define COMMAND_TYPE_NORMAL
Standard commands.
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
Shortend name of the region as maps refer to it.
Definition: map.h:275
generate_random_map
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout, sstring reset_group)
Main random map routine.
Definition: random_map.cpp:75
UPD_NROF
#define UPD_NROF
Definition: newclient.h:325
FOR_ABOVE_PREPARE
#define FOR_ABOVE_PREPARE(op_, it_)
Constructs a loop iterating over all objects above an object.
Definition: define.h:681
object::enemy
object * enemy
Monster/player to follow even if not closest.
Definition: object.h:391
CFAPI_SYSTEM_PLAYERS
#define CFAPI_SYSTEM_PLAYERS
Definition: plugin.h:286
CFAPI_OBJECT_PROP_PRESENT
#define CFAPI_OBJECT_PROP_PRESENT
Definition: plugin.h:192
CFAPI_REGION_PROP_JAIL_PATH
#define CFAPI_REGION_PROP_JAIL_PATH
Definition: plugin.h:283
CFAPI_MAP_PROP_WIDTH
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:256
cfapi_get_hooks
static void cfapi_get_hooks(int *type,...)
Definition: plugins.cpp:328
CFAPI_ARCH_PROP_NAME
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:265
CFAPI_OBJECT_PROP_ITEM_POWER
#define CFAPI_OBJECT_PROP_ITEM_POWER
Definition: plugin.h:164
CFAPI_MAP_PROP_UNIQUE
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:263
object::hide
uint8_t hide
The object is hidden, not invisible.
Definition: object.h:397
object::title
sstring title
Of foo, etc.
Definition: object.h:325
f_plug_init
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
First function called in a plugin.
Definition: plugin.h:83
partylist
One party.
Definition: party.h:10
apply_manual
int apply_manual(object *op, object *tmp, int aflag)
Main apply handler.
Definition: apply.cpp:597
mapstruct::path
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:355
CFAPI_FLOAT
#define CFAPI_FLOAT
Definition: plugin.h:60
apply_by_living_below
void apply_by_living_below(object *pl)
Attempt to apply the object 'below' the player.
Definition: apply.cpp:695
MSG_TYPE_MISC
#define MSG_TYPE_MISC
Messages that don't go elsewhere.
Definition: newclient.h:417
initPlugins
void initPlugins(void)
Plugins initialization.
Definition: plugins.cpp:4573
CFAPI_OBJECT_PROP_CURRENT_WEAPON
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON
Definition: plugin.h:171
object::level
int16_t level
Level of creature or object.
Definition: object.h:361
cfapi_friendlylist_get_next
static void cfapi_friendlylist_get_next(int *type,...)
Friend list access, to get objects on it.
Definition: plugins.cpp:4378
buf
StringBuffer * buf
Definition: readable.cpp:1565
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
cfapi_object_identify
static void cfapi_object_identify(int *type,...)
Wrapper for identify().
Definition: plugins.cpp:3080
cfapi_map_set_map_property
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.cpp:1267
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
Definition: object.cpp:2842
RMParms
Random map parameters.
Definition: random_map.h:14
object::above
object * above
Pointer to the object stacked above this one.
Definition: object.h:296
crossfire_plugin::libptr
LIBPTRTYPE libptr
Pointer to the plugin library
Definition: plugin.h:98
cfapi_object_user_event
static void cfapi_object_user_event(int *type,...)
Definition: plugins.cpp:4443
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
Definition: newclient.h:408
CFAPI_MAP_PROP_ENTER_X
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:258
cfapi_object_update
static void cfapi_object_update(int *type,...)
Wrapper for object_update().
Definition: plugins.cpp:3513
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:821
object::resist
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:351
plugins_dlerror
#define plugins_dlerror()
Library error.
Definition: plugin.h:115
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
mapstruct::width
uint16_t width
Definition: map.h:337
cfapi_object_change_abil
static void cfapi_object_change_abil(int *type,...)
Wrapper for change_abil().
Definition: plugins.cpp:3965
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)
give access to season names
Definition: time.cpp:127
CFAPI_OBJECT_PROP_SKILL
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:135
events_register_global_handler
event_registration events_register_global_handler(int eventcode, f_plug_event hook)
Register a global event handler.
Definition: events.cpp:19
CFAPI_OBJECT_PROP_CLIENT_TYPE
#define CFAPI_OBJECT_PROP_CLIENT_TYPE
Definition: plugin.h:147
object::path_denied
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:355
object_clear
void object_clear(object *op)
Frees everything allocated by an object, and also clears all variables and flags to default settings.
Definition: object.cpp:968
region::longname
char * longname
Official title of the region, this might be defined to be the same as name.
Definition: map.h:281
socket_struct::update_look
uint32_t update_look
If true, we need to send the look window.
Definition: newserver.h:108
party_join
void party_join(object *op, partylist *party)
Makes a player join a party.
Definition: party.cpp:85
cfapi_object_get_key
static void cfapi_object_get_key(int *type,...)
Gets a key/value value for an object.
Definition: plugins.cpp:1507
TIMER_ERR_ID
#define TIMER_ERR_ID
Invalid timer id.
Definition: timers.h:67
MSG_TYPE_COMMAND_DEBUG
#define MSG_TYPE_COMMAND_DEBUG
Various debug type commands.
Definition: newclient.h:532
object::carrying
int32_t carrying
How much weight this object contains.
Definition: object.h:377
plugins_remove_plugin
int plugins_remove_plugin(const char *id)
Unload the specified plugin.
Definition: plugins.cpp:455
CFAPI_OBJECT_PROP_PATH_DENIED
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:152
CFAPI_MAP_PROP_REGION
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:262
TIMER_ERR_NONE
#define TIMER_ERR_NONE
No error.
Definition: timers.h:66
object::path_repelled
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:354
object::y
int16_t y
Position in the map for this object.
Definition: object.h:335
CFAPI_OBJECT_PROP_ANIM_SPEED
#define CFAPI_OBJECT_PROP_ANIM_SPEED
Definition: plugin.h:184
m
static event_registration m
Definition: citylife.cpp:424
cfapi_system_unregister_global_event
static void cfapi_system_unregister_global_event(int *type,...)
Definition: plugins.cpp:607
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)
Register an object event handler.
Definition: events.cpp:299
ServerSettings::disabled_plugins
std::vector< char * > disabled_plugins
List of disabled plugins, 'All' means all.
Definition: server.h:16
cfapi_register_command
static void cfapi_register_command(int *type,...)
Definition: plugins.cpp:4518
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
Definition: stringbuffer.cpp:76
party_get_first
partylist * party_get_first(void)
Returns the first party from the list of all parties.
Definition: party.cpp:196
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
Definition: object.cpp:1545
object_update
void object_update(object *op, int action)
object_update() updates the array which represents the map.
Definition: object.cpp:1419
object::contr
struct player * contr
Pointer to the player which control this object.
Definition: object.h:284
NROF
static uint32_t NROF(const object *const ob)
Returns ob->nrof, unless it is 0, in which case return 1.
Definition: object.h:625
object_find_by_name
object * object_find_by_name(const object *who, const char *name)
Finds an object in inventory name.
Definition: object.cpp:3941
cfapi_player_find
static void cfapi_player_find(int *type,...)
Wrapper for find_player_partial_name().
Definition: plugins.cpp:4009
opendir
DIR * opendir(const char *)
CFAPI_OBJECT_PROP_LORE
#define CFAPI_OBJECT_PROP_LORE
Definition: plugin.h:137
CFAPI_ARCH_PROP_HEAD
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:267
object::chosen_skill
object * chosen_skill
The skill chosen to use.
Definition: object.h:396
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
object::last_heal
int32_t last_heal
Last healed.
Definition: object.h:367
object::subtype
uint8_t subtype
Subtype of object.
Definition: object.h:349
FLAG_WAS_WIZ
#define FLAG_WAS_WIZ
Player was once a 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)
Unregister a previously registered command.
Definition: commands.cpp:535
hook_entry::func
f_plug_api func
Function itself.
Definition: plugin.h:309
cfapi_player_can_pay
static void cfapi_player_can_pay(int *type,...)
Wrapper for can_pay().
Definition: plugins.cpp:4092
determine_god
const char * determine_god(object *op)
Determines if op worships a god.
Definition: gods.cpp:55
is_friendly
int is_friendly(const object *op)
Checks if the given object is already in the friendly list or not.
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]
Y offset when searching around a spot.
Definition: object.cpp:305
CFAPI_OBJECT_PROP_MAXHP
#define CFAPI_OBJECT_PROP_MAXHP
Definition: plugin.h:210
drop
void drop(object *op, object *tmp)
Drop an item, either on the floor or in a container.
Definition: c_object.cpp:1170
cfapi_map_message
static void cfapi_map_message(int *type,...)
Definition: plugins.cpp:1348
object::anim_speed
uint8_t anim_speed
Ticks between animation-frames.
Definition: object.h:429
get_weekday
const char * get_weekday(const int index)
give access to weekday names
Definition: time.cpp:120
cfapi_map_create_path
static void cfapi_map_create_path(int *type,...)
Wrapper for create_pathname() and create_overlay_pathname().
Definition: plugins.cpp:1101
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,...)
Applies an object below.
Definition: plugins.cpp:3035
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)
Op is trying to move in direction dir.
Definition: move.cpp:58
cftimer_destroy
int cftimer_destroy(int id)
Destroys an existing timer.
Definition: timers.cpp:128
cfapi_set_random_map_variable
static void cfapi_set_random_map_variable(int *type,...)
Wrapper for set_random_map_variable().
Definition: plugins.cpp:4402
object_present_in_ob_by_name
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Searches for any objects with a matching type & name variable in the inventory of the given object.
Definition: object.cpp:3188
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)
Describes an item.
Definition: item.cpp:594
cfapi_object_remove_depletion
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.cpp:3140
CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
Definition: plugin.h:165
CFAPI_REGION_PROP_JAIL_Y
#define CFAPI_REGION_PROP_JAIL_Y
Definition: plugin.h:282
CFAPI_OBJECT_PROP_CHEATER
#define CFAPI_OBJECT_PROP_CHEATER
Definition: plugin.h:193
FOR_ABOVE_FINISH
#define FOR_ABOVE_FINISH()
Finishes FOR_ABOVE_PREPARE().
Definition: define.h:688
events_unregister_global_handler
void events_unregister_global_handler(int eventcode, event_registration id)
Remove a global event handler.
Definition: events.cpp:26
CFAPI_MAP_PROP_MESSAGE
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:260
Face::number
uint16_t number
This is the image unique identifier.
Definition: face.h:15
cfapi_system_re_cmp
static void cfapi_system_re_cmp(int *type,...)
Wrapper for re_cmp().
Definition: plugins.cpp:803
CFAPI_OBJECT_PROP_RACE
#define CFAPI_OBJECT_PROP_RACE
Definition: plugin.h:133
f_plug_api
void(* f_plug_api)(int *type,...)
General API function.
Definition: plugin.h:79
archetype::clone
object clone
An object from which to do object_copy()
Definition: object.h:487
object::run_away
uint8_t run_away
Monster runs away if it's hp goes below this percentage.
Definition: object.h:394
cfapi_system_get_object_vector
static void cfapi_system_get_object_vector(int *type,...)
Definition: plugins.cpp:627
cfapi_party_get_property
static void cfapi_party_get_property(int *type,...)
Party-related functions.
Definition: plugins.cpp:4250
object::weight_limit
int32_t weight_limit
Weight-limit of object.
Definition: object.h:376
add_string
sstring add_string(const char *str)
This will add 'str' to the hash table.
Definition: shstr.cpp:124
cfapi_object_check_spell
static void cfapi_object_check_spell(int *type,...)
Wrapper for check_spell_known().
Definition: plugins.cpp:3740
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
First map.
Definition: init.cpp:107
copy_message
static void copy_message(object *op, const char *msg)
Utility function to copy the string to op->msg.
Definition: plugins.cpp:2364
cfapi_system_find_face
static void cfapi_system_find_face(int *type,...)
Wrapper for find_face().
Definition: plugins.cpp:549
CFAPI_INT
#define CFAPI_INT
Definition: plugin.h:54
region::parent
region * parent
Pointer to the region that is a parent of the current region, if a value isn't defined in the current...
Definition: map.h:276
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:671
cfapi_object_reset
static void cfapi_object_reset(int *type,...)
Wrapper for clear_reset().
Definition: plugins.cpp:3551
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
The description of the region.
Definition: map.h:283
object::below
object * below
Pointer to the object stacked below this one.
Definition: object.h:295
change_map_light
int change_map_light(mapstruct *m, int change)
Used to change map light level (darkness) up or down.
Definition: map.cpp:2024
object::move_type
MoveType move_type
Type of movement this object uses.
Definition: object.h:436
NDI_DELAYED
#define NDI_DELAYED
If set, then message is sent only after the player's tick completes.
Definition: newclient.h:273
get_periodofday
const char * get_periodofday(const int index)
give access to weekday names
Definition: time.cpp:106
readdir
struct dirent * readdir(DIR *)
query_short_name
void query_short_name(const object *op, char *buf, size_t size)
query_short_name(object) is similar to query_name(), but doesn't contain any information about object...
Definition: item.cpp:518
ext_info_map
void void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Writes to everyone on the specified map.
Definition: main.cpp:334
FLAG_FREED
#define FLAG_FREED
Object is in the list of free objects.
Definition: define.h:233
cfapi_map_has_been_loaded
static void cfapi_map_has_been_loaded(int *type,...)
Wrapper for has_been_loaded().
Definition: plugins.cpp:1083
object::face
const Face * face
Face with colors.
Definition: object.h:341
out_of_map
int out_of_map(mapstruct *m, int x, int y)
Return 1 if coordinates X and Y are out of the map M, taking into account tiling.
Definition: map.cpp:2324
region::jailmap
char * jailmap
Where a player that is arrested in this region should be imprisoned.
Definition: map.h:287
find_string
sstring find_string(const char *str)
Searches a string in the shared strings.
Definition: shstr.cpp:236
socket_struct::host
char * host
Which host it is connected from (ip address).
Definition: newserver.h:104
object::last_eat
int32_t last_eat
How long since we last ate.
Definition: object.h:366
object::value
int32_t value
How much money it is worth (or contains)
Definition: object.h:360
crossfire_plugin::closefunc
f_plug_postinit closefunc
Plugin Termination function
Definition: plugin.h:97
cfapi_object_remove
static void cfapi_object_remove(int *type,...)
Definition: plugins.cpp:3209
object_update_speed
void object_update_speed(object *op)
Updates the speed of an object.
Definition: object.cpp:1334
cfapi_system_strdup_local
static void cfapi_system_strdup_local(int *type,...)
Wrapper for strdup_local().
Definition: plugins.cpp:572
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
Definition: global.h:206
crossfire_plugin::id
char id[MAX_BUF]
Plugin identification string
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)
Execute an EVENT_USER on the specified object.
Definition: events.cpp:317
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
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:269
living::dam
int16_t dam
How much damage this object does when hitting.
Definition: living.h:46
object::magic
int8_t magic
Any magical bonuses to this item.
Definition: object.h:358
CFAPI_OBJECT_PROP_EXP
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:190
SET_MAP_FLAGS
#define SET_MAP_FLAGS(M, X, Y, C)
Sets map flags.
Definition: map.h:159
CFAPI_OBJECT_PROP_SPEED
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:140
CFAPI_OBJECT_PROP_TYPE
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:145
object::active_prev
object * active_prev
Previous object in the 'active list This is used in process_events so that the entire object list doe...
Definition: object.h:291
quest_was_completed
int quest_was_completed(player *pl, sstring quest_code)
Check if a quest was completed once for a player, without taking account the current state.
Definition: quest.cpp:726
CFAPI_OBJECT_PROP_NROF
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:142
object::materialname
sstring materialname
Specific material name.
Definition: object.h:356
object_create_arch
object * object_create_arch(archetype *at)
Create a full object using the given archetype.
Definition: arch.cpp:296
CFAPI_PLAYER_PROP_TITLE
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:237
CFAPI_MAP_PROP_PATH
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:248
cfapi_object_transmute
static void cfapi_object_transmute(int *type,...)
Definition: plugins.cpp:3192
object_free
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects,...
Definition: object.cpp:1577
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,...)
Regions-related functions.
Definition: plugins.cpp:4305
cfapi_unregister_command
static void cfapi_unregister_command(int *type,...)
Definition: plugins.cpp:4553
CFAPI_OBJECT_PROP_PICKABLE
#define CFAPI_OBJECT_PROP_PICKABLE
Definition: plugin.h:195
FOR_INV_FINISH
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:671
CFAPI_PREGION
#define CFAPI_PREGION
Definition: plugin.h:66
CFAPI_REGION_VECTOR
#define CFAPI_REGION_VECTOR
Pointer to a std::vector<region *>
Definition: plugin.h:75
object::move_on
MoveType move_on
Move types affected moving on to this space.
Definition: object.h:439
living::food
int32_t food
How much food in stomach.
Definition: living.h:48
change_exp
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
Definition: living.cpp:2179
cfapi_object_teleport
static void cfapi_object_teleport(int *type,...)
Teleports an object at a specified destination if possible.
Definition: plugins.cpp:4160
CFAPI_PLAYER_QUEST_START
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:241
CFAPI_REGION_PROP_NAME
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:276
cfapi_object_spring_trap
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.cpp:3592
archetype
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:483
CFAPI_OBJECT_PROP_INVISIBLE_TIME
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME
Definition: plugin.h:162
CFAPI_OBJECT_PROP_ATTACK_TYPE
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:149
CFAPI_SYSTEM_MAPS
#define CFAPI_SYSTEM_MAPS
Definition: plugin.h:285
move_to
int move_to(object *op, int x, int y)
Move an object one square toward a specified destination on the same map.
Definition: move.cpp:563
CFAPI_REGION_PROP_JAIL_X
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:281
cfapi_get_time
static void cfapi_get_time(int *type,...)
Wrapper for get_tod().
Definition: plugins.cpp:874
cfapi_object_pay_item
static void cfapi_object_pay_item(int *type,...)
Wrapper for pay_for_item().
Definition: plugins.cpp:3781
Settings::confdir
const char * confdir
Configuration files.
Definition: global.h:248
sproto.h
FLAG_NO_DROP
#define FLAG_NO_DROP
Object can't be dropped.
Definition: define.h:288
living::sp
int16_t sp
Spell points.
Definition: living.h:42
get_map_from_coord
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coor...
Definition: map.cpp:2352
AssetsCollection::each
void each(std::function< void(T *)> op)
Apply a function to each asset.
Definition: AssetsCollection.h:158
get_face_by_id
const Face * get_face_by_id(uint16_t id)
Get a face from its unique identifier.
Definition: assets.cpp:315
living::Int
int8_t Int
Definition: living.h:36
crossfire_plugin::global_registration
event_registration global_registration[NR_EVENTS]
Global event registration identifiers.
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)
Frees the map, including the mapstruct.
Definition: map.cpp:1706
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:424
partylist::partyname
char * partyname
Party name.
Definition: party.h:14
object::race
sstring race
Human, goblin, dragon, etc.
Definition: object.h:326
CFAPI_OBJECT_PROP_OWNER
#define CFAPI_OBJECT_PROP_OWNER
Definition: plugin.h:191
object::facing
int8_t facing
Object is oriented/facing that way.
Definition: object.h:345
object::animation
const Animations * animation
Animation of this item, NULL if not animated.
Definition: object.h:428
cfapi_object_pickup
static void cfapi_object_pickup(int *type,...)
Definition: plugins.cpp:4179
CFAPI_SYSTEM_REGIONS
#define CFAPI_SYSTEM_REGIONS
Definition: plugin.h:288
cfapi_object_on_same_map
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.cpp:3576
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)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
Definition: object.cpp:2085
object::other_arch
struct archetype * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
Definition: object.h:425
object_create_clone
object * object_create_clone(object *asrc)
Create clone from object to another.
Definition: object.cpp:3894
CFAPI_PARTY_PROP_NEXT
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:272
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:155
P_OUT_OF_MAP
#define P_OUT_OF_MAP
This space is outside the map.
Definition: map.h:249
AssetsManager::archetypes
Archetypes * archetypes()
Get archetypes.
Definition: AssetsManager.h:44
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
cfapi_get_month_name
static void cfapi_get_month_name(int *type,...)
Wrapper for get_season_name().
Definition: plugins.cpp:929
cfapi_system_check_path
static void cfapi_system_check_path(int *type,...)
Wrapper for check_path().
Definition: plugins.cpp:780
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
Definition: porting.cpp:222
CFAPI_MAP_PROP_NAME
#define CFAPI_MAP_PROP_NAME
Definition: plugin.h:250
object_set_cheat
void object_set_cheat(object *op)
object_set_cheat(object) sets the cheat flag (WAS_WIZ) in the object and in all it's inventory (recur...
Definition: object.cpp:3259
object_new
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it.
Definition: object.cpp:1258
create_overlay_pathname
void create_overlay_pathname(const char *name, char *buf, size_t size)
Same as create_pathname(), but for the overlay maps.
Definition: map.cpp:125
UP_OBJ_INSERT
#define UP_OBJ_INSERT
Object was inserted.
Definition: object.h:530
object::head
object * head
Points to the main object of a large body.
Definition: object.h:304
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Describes an item, in all its details.
Definition: item.cpp:958
COMMAND_TYPE_WIZARD
#define COMMAND_TYPE_WIZARD
Wizard-only commands.
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)
Searches for any objects with a matching type variable in the inventory of the given object.
Definition: object.cpp:3153
object::current_weapon
object * current_weapon
Pointer to the weapon currently used.
Definition: object.h:380
re_cmp
const char * re_cmp(const char *, const char *)
re-cmp - get regular expression match.
Definition: re-cmp.cpp:68
object::weight
int32_t weight
Attributes of the object.
Definition: object.h:375
CFAPI_OBJECT_PROP_POW
#define CFAPI_OBJECT_PROP_POW
Definition: plugin.h:202
free_string
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.cpp:280
transfer_ob
int transfer_ob(object *op, int x, int y, int randomly, object *originator)
Move an object (even linked objects) to another spot on the same map.
Definition: move.cpp:163
cfapi_map_get_map
static void cfapi_map_get_map(int *type,...)
Gets map information.
Definition: plugins.cpp:1032
living::wc
int8_t wc
Weapon Class, lower WC increases probability of hitting.
Definition: living.h:37
CFAPI_REGION_PROP_MESSAGE
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:280
object::move_slow_penalty
float move_slow_penalty
How much this slows down the object.
Definition: object.h:442
Settings::playerdir
const char * playerdir
Where the player files are.
Definition: global.h:251
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp:278
party_get_next
partylist * party_get_next(const partylist *party)
Returns the next party from the list of all parties.
Definition: party.cpp:208
living::maxgrace
int16_t maxgrace
Maximum grace.
Definition: living.h:45
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)
Permanently alters an object's stats/flags based on another object.
Definition: living.cpp:394
send_changed_object
static void send_changed_object(object *op)
Notify clients about a changed object.
Definition: plugins.cpp:302
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
player::mark
object * mark
Marked object.
Definition: player.h:213
living::Wis
int8_t Wis
Definition: living.h:36
CFAPI_MAP_PROP_FLAGS
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:246
cfapi_system_find_string
static void cfapi_system_find_string(int *type,...)
Wrapper for find_string().
Definition: plugins.cpp:761
cfapi_system_remove_string
static void cfapi_system_remove_string(int *type,...)
Wrapper for free_string().
Definition: plugins.cpp:743
region
This is a game region.
Definition: map.h:274
CFAPI_MAP_PROP_DARKNESS
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:255
CFAPI_MAP_PROP_PLAYERS
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:253
FLAG_REMOVED
#define FLAG_REMOVED
Object is not in any map or invenory.
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)
Decreases a specified number from the amount of an object.
Definition: object.cpp:2661
PERM_EXP
#define PERM_EXP(exptotal)
Convert saved total experience into permanent experience.
Definition: global.h:232
cfapi_map_delete_map
static void cfapi_map_delete_map(int *type,...)
Definition: plugins.cpp:1335
plugins_display_list
void plugins_display_list(object *op)
Displays a list of loaded plugins (keystrings and description) in the game log window.
Definition: plugins.cpp:480
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
object::lore
sstring lore
Obscure information about this object, to get put into books and the like.
Definition: object.h:332
llevInfo
@ llevInfo
Information.
Definition: logger.h:12
NDI_UNIQUE
#define NDI_UNIQUE
Print immediately, don't buffer.
Definition: newclient.h:266
object::slaying
sstring slaying
Which race to do double damage to.
Definition: object.h:327
cfapi_map_get_map_property
static void cfapi_map_get_map_property(int *type,...)
Definition: plugins.cpp:1135
object::glow_radius
int8_t glow_radius
indicates the glow radius of the object
Definition: object.h:374
CFAPI_PARTY_PROP_PLAYER
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:274
CFAPI_PMAP
#define CFAPI_PMAP
Definition: plugin.h:59
all_regions
std::vector< region * > all_regions
Definition: init.cpp:108
CFAPI_PLAYER_QUEST_GET_STATE
#define CFAPI_PLAYER_QUEST_GET_STATE
Definition: plugin.h:242
CFAPI_MAP_PROP_DIFFICULTY
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:247
find_archetype_by_object_name
archetype * find_archetype_by_object_name(const char *name)
This function retrieves an archetype given the name that appears during the game (for example,...
Definition: arch.cpp:51
transmute_materialname
void transmute_materialname(object *op, const object *change)
When doing transmutation of objects, we have to recheck the resistances, as some that did not apply p...
Definition: utils.cpp:263
object::name
sstring name
The name of the object, obviously...
Definition: object.h:319
cfapi_system_get_region_vector
static void cfapi_system_get_region_vector(int *type,...)
Definition: plugins.cpp:685
cfapi_object_describe
static void cfapi_object_describe(int *type,...)
Wrapper for describe_item().
Definition: plugins.cpp:3100
cfapi_object_give_skill
static void cfapi_object_give_skill(int *type,...)
Definition: plugins.cpp:3175
cfapi_generate_random_map
static void cfapi_generate_random_map(int *type,...)
Wrapper for generate_random_map().
Definition: plugins.cpp:4424
object::spellitem
object * spellitem
Spell ability monster is choosing to use.
Definition: object.h:406
serverSettings
ServerSettings serverSettings
Definition: init.cpp:42
CFAPI_OBJECT_PROP_ANIMATION
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:218
object_find_by_arch_name
object * object_find_by_arch_name(const object *who, const char *name)
Find object in inventory by archetype name.
Definition: object.cpp:4237
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:3159
party_get_password
const char * party_get_password(const partylist *party)
Returns the party's password.
Definition: party.cpp:232
CFAPI_SYSTEM_FRIENDLY_LIST
#define CFAPI_SYSTEM_FRIENDLY_LIST
Definition: plugin.h:290
cleanupPlugins
void cleanupPlugins(void)
Call the crossfire_plugin::closefunc on the various plugins, used at server shutdown.
Definition: plugins.cpp:4621
object_can_pick
int object_can_pick(const object *who, const object *item)
Finds out if an object can be picked up.
Definition: object.cpp:3852
add_friendly_object
void add_friendly_object(object *op)
Add a new friendly object to the list of friendly objects.
Definition: friend.cpp:32
CFAPI_PLAYER_QUEST_SET_STATE
#define CFAPI_PLAYER_QUEST_SET_STATE
Definition: plugin.h:243
player
same as sound ncom command like but with extra the client want tick commands so it knows animation timing the client wants to be informed of pickup mode changes Mode will be sent when the player successfully logs and afterward any time the value is but over many options have become defaults This documents those now obsolete client can handle the bit exp values that are now used values are sent as bit Setting this flag also means that skill exp will be and it will be sent in revised method as described in the stats command Value is an integer in string format else Deprecated client should presume all servers support this server will return FALSE Deprecated replaced with sound2 setup but rather that the server was unable to complete the given protocol request the command(just the command name) that generated the failure. reason the server will only keep track of the latest mark sent The server will generally send a drawinfo command informing the player
Definition: protocol.txt:475
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)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_.
Definition: map.cpp:300
living::maxsp
int16_t maxsp
Max spell points.
Definition: living.h:43
is_magical
int is_magical(const object *op)
Checks whether object is magical.
Definition: item.cpp:1239
CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
Definition: plugin.h:123
timers.h
mapstruct::reset_timeout
uint32_t reset_timeout
How many seconds must elapse before this map should be reset.
Definition: map.h:323
P_NEED_UPDATE
#define P_NEED_UPDATE
This space is out of date.
Definition: map.h:239
mapstruct
This is a game-map.
Definition: map.h:315
CFAPI_OBJECT_PROP_HEAD
#define CFAPI_OBJECT_PROP_HEAD
Definition: plugin.h:126
CFAPI_PARCH
#define CFAPI_PARCH
Definition: plugin.h:62
object::env
object * env
Pointer to the object which is the environment.
Definition: object.h:301
create_pathname
char * create_pathname(const char *name, char *buf, size_t size)
Get the full path to a map file.
Definition: map.cpp:104
check_spell_known
object * check_spell_known(object *op, const char *name)
Checks to see if player knows the spell.
Definition: spell_util.cpp:394
cfapi_object_change_exp
static void cfapi_object_change_exp(int *type,...)
Wrapper for change_exp().
Definition: plugins.cpp:4069
object::last_sp
int32_t last_sp
As last_heal, but for spell points.
Definition: object.h:368
f_plug_event
int(* f_plug_event)(int *type,...)
Function to call to handle global or object-related events.
Definition: events.h:82
sstring
const typedef char * sstring
Definition: sstring.h:2
living::Cha
int8_t Cha
Definition: living.h:36
Animations
This represents one animation.
Definition: face.h:25
object::gen_sp_armour
int8_t gen_sp_armour
Sp regen penalty this object has (was last_heal)
Definition: object.h:373
pay_for_item
int pay_for_item(object *op, object *pl, uint64_t reduction)
Player attemps to buy an item, if she has enough money then remove coins as needed from active contai...
Definition: shop.cpp:444
CFAPI_PLAYER_PROP_BED_MAP
#define CFAPI_PLAYER_PROP_BED_MAP
Definition: plugin.h:233
object::skill
sstring skill
Name of the skill this object uses/grants.
Definition: object.h:329
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)
object_split(ob,nr) splits up ob into two parts.
Definition: object.cpp:2622
CFAPI_OBJECT_PROP_WC
#define CFAPI_OBJECT_PROP_WC
Definition: plugin.h:204
mapstruct::name
char * name
Name of map as given by its creator.
Definition: map.h:318
plugins_dlsym
#define plugins_dlsym(lib, name)
Get a function from a shared library.
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)
object_find_free_spot(object, map, x, y, start, stop) will search for a spot at the given map and coo...
Definition: object.cpp:3544
query_money
uint64_t query_money(const object *op)
Determine the amount of money the given object contains, including what is inside containers.
Definition: shop.cpp:373
cfapi_object_find_by_arch_name
static void cfapi_object_find_by_arch_name(int *type,...)
Definition: plugins.cpp:3904
mapstruct::enter_x
int16_t enter_x
Definition: map.h:338
object_set_msg
void object_set_msg(object *op, const char *msg)
Set the message field of an object.
Definition: object.cpp:4796
esrv_update_item
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
Definition: main.cpp:359
CFAPI_OBJECT_PROP_PATH_REPELLED
#define CFAPI_OBJECT_PROP_PATH_REPELLED
Definition: plugin.h:151
object::msg
sstring msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:330
CFAPI_OBJECT_PROP_CON
#define CFAPI_OBJECT_PROP_CON
Definition: plugin.h:199
CFAPI_ARCHETYPE_VECTOR
#define CFAPI_ARCHETYPE_VECTOR
Pointer to a std::vector<archetype *>
Definition: plugin.h:74
plug_hooks
static const hook_entry plug_hooks[]
All hooked functions plugins can call.
Definition: plugins.cpp:155
buffer
if you malloc the data for the buffer
Definition: protocol.txt:2106
object_get_value
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.cpp:4331
on_same_map
int on_same_map(const object *op1, const object *op2)
Checks whether 2 objects are on the same map or not.
Definition: map.cpp:2629
CFAPI_MAP_VECTOR
#define CFAPI_MAP_VECTOR
Pointer to a std::vector<mapstruct *>
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)
Checks all unpaid items in op's inventory, adds up all the money they have, and checks that they can ...
Definition: shop.cpp:784
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
Animations::num
uint16_t num
Where we are in the array.
Definition: face.h:29
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,...)
Wrapper for cost_string_from_value, modified to take a buffer and length instead of a StringBuffer.
Definition: plugins.cpp:498
living::ac
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
Definition: living.h:38
player_arrest
int player_arrest(object *who)
Put a player into jail, taking into account cursed exits and player's region.
Definition: c_wiz.cpp:789
find_player_partial_name
player * find_player_partial_name(const char *plname)
Find a player by a partial name.
Definition: player.cpp:114
object::attacked_by
object * attacked_by
This object start to attack us! only player & monster.
Definition: object.h:392
object::duration
int16_t duration
Number of moves (see 'speed') spell lasts.
Definition: object.h:415
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:3328
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
One loaded plugin.
Definition: plugin.h:95
cfapi_map_update_position
static void cfapi_map_update_position(int *type,...)
Wrapper for update_position().
Definition: plugins.cpp:1319
CFAPI_OBJECT_PROP_OTHER_ARCH
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:182
cfapi_get_periodofday_name
static void cfapi_get_periodofday_name(int *type,...)
Wrapper for get_season_name().
Definition: plugins.cpp:941
level
int level
Definition: readable.cpp:1563
CFAPI_OBJECT_PROP_OB_ABOVE
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:120
player::party
partylist * party
Party this player is part of.
Definition: player.h:203
mapstruct::msg
char * msg
Message map creator may have left.
Definition: map.h:351
knowledge_player_knows
int knowledge_player_knows(const player *pl, const char *knowledge)
Determines whether a player knows a specific knowledge or not.
Definition: knowledge.cpp:1298
player::count
uint32_t count
Any numbers typed before a command.
Definition: player.h:122
object_distance
int object_distance(const object *ob1, const object *ob2)
Return the square of the distance between the two given objects.
Definition: object.cpp:3646
CFAPI_MAP_PROP_ENTER_Y
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:259
string_get_int
#define string_get_int(name)
Definition: plugins.cpp:886
quest_start
void quest_start(player *pl, sstring quest_code, int state)
Start a quest for a player.
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:4024
CFAPI_OBJECT_PROP_MOVE_ALLOW
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:222
knowledge_give
void knowledge_give(player *pl, const char *marker, const object *book)
Give a knowledge item from its code.
Definition: knowledge.cpp:996
get_region_by_map
region * get_region_by_map(mapstruct *m)
Gets a region from a map.
Definition: region.cpp:71
CFAPI_ARCH_PROP_MORE
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:268
cfapi_system_add_string
static void cfapi_system_add_string(int *type,...)
Wrapper for add_string().
Definition: plugins.cpp:723
object::container
object * container
Current container being used.
Definition: object.h:299
command_function_extra
void(* command_function_extra)(object *op, const char *params, const char *extra)
One command function, with a custom parameter specified at registration time.
Definition: commands.h:29
command_register
command_registration command_register(const char *name, uint8_t type, command_function func, float time)
Register a player-issued command.
Definition: commands.cpp:101
skill
skill
Definition: arch-handbook.txt:585
CFAPI_SYSTEM_PARTIES
#define CFAPI_SYSTEM_PARTIES
Definition: plugin.h:289
cfapi_log
static void cfapi_log(int *type,...)
Wrapper for LOG().
Definition: plugins.cpp:1008
object::active_next
object * active_next
Next object in the 'active' list This is used in process_events so that the entire object list does n...
Definition: object.h:287
object_remove
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
Definition: object.cpp:1818
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::move_off
MoveType move_off
Move types affected moving off this space.
Definition: object.h:440
object_sum_weight
signed long object_sum_weight(object *op)
object_sum_weight() is a recursive function which calculates the weight an object is carrying.
Definition: object.cpp:553
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)
Erases spell from player's inventory.
Definition: apply.cpp:525
mapstruct::enter_y
int16_t enter_y
Enter_x and enter_y are default entrance coordinates to use for a map such that when an exit specifie...
Definition: map.h:338
command_registration
uint64_t command_registration
Identifier when registering a command.
Definition: commands.h:32
cfapi_object_set_key
static void cfapi_object_set_key(int *type,...)
Write a key/value for an object.
Definition: plugins.cpp:1529
remove_depletion
int remove_depletion(object *op, int level)
Remove depletion from op, if present, and warn player of such restorations.
Definition: living.cpp:755
cfapi_object_pay_amount
static void cfapi_object_pay_amount(int *type,...)
Wrapper for pay_for_amount().
Definition: plugins.cpp:3760
get_month_name
const char * get_month_name(const int index)
give access to month names
Definition: time.cpp:113
CFAPI_OBJECT_PROP_MAGIC
#define CFAPI_OBJECT_PROP_MAGIC
Definition: plugin.h:155
CFAPI_OBJECT_PROP_FLAGS
#define CFAPI_OBJECT_PROP_FLAGS
Definition: plugin.h:196
CFAPI_OBJECT_PROP_LUCK
#define CFAPI_OBJECT_PROP_LUCK
Definition: plugin.h:189
CFAPI_MAP_PROP_HEIGHT
#define CFAPI_MAP_PROP_HEIGHT
Definition: plugin.h:257
object_teleport
int object_teleport(object *op, mapstruct *map, int x, int y)
Move the specified object in a free spot around the map's x & y.
Definition: move.cpp:597
cfapi_system_find_animation
static void cfapi_system_find_animation(int *type,...)
Wrapper for find_animation().
Definition: plugins.cpp:528
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)
This function makes sure that update_los() will be called for all players on the given map within the...
Definition: los.cpp:595
UPD_ALL
#define UPD_ALL
Definition: newclient.h:326
object::state
uint8_t state
How the object was last drawn (animation)
Definition: object.h:359
mapstruct::unique
uint32_t unique
If set, this is a per player unique map.
Definition: map.h:328
command_register_extra
command_registration command_register_extra(const char *name, const char *extra, uint8_t type, command_function_extra func, float time)
Register a player-issued command with an extra parameter.
Definition: commands.cpp:526
calculate_difficulty
int calculate_difficulty(mapstruct *m)
This routine is supposed to find out the difficulty of the map.
Definition: map.cpp:1926
archetype::name
sstring name
More definite name, like "generate_kobold".
Definition: object.h:484
object::nrof
uint32_t nrof
Number of objects.
Definition: object.h:342
player::socket
socket_struct * socket
Socket information for this player.
Definition: player.h:107
mapstruct::next
mapstruct * next
Next map, linked list.
Definition: map.h:316
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2734
cfapi_object_apply
static void cfapi_object_apply(int *type,...)
Applies an object.
Definition: plugins.cpp:3055
mapstruct::reset_time
uint32_t reset_time
Server time when map gets reset, seconds since epoch.
Definition: map.h:322
CFAPI_OBJECT_PROP_VALUE
#define CFAPI_OBJECT_PROP_VALUE
Definition: plugin.h:156
living::grace
int16_t grace
Grace.
Definition: living.h:44
query_base_name
void query_base_name(const object *op, int plural, char *buf, size_t size)
Query a short name for the item.
Definition: item.cpp:695
CFAPI_OBJECT_PROP_MESSAGE
#define CFAPI_OBJECT_PROP_MESSAGE
Definition: plugin.h:136
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:378
cfapi_object_perm_exp
static void cfapi_object_perm_exp(int *type,...)
Wrapper for permanent experience calculation.
Definition: plugins.cpp:4050
list
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
Definition: INSTALL_WIN32.txt:50
CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
Definition: plugin.h:226
object::move_allow
MoveType move_allow
What movement types explicitly allowed.
Definition: object.h:438
LogLevel
LogLevel
Log levels for the LOG() function.
Definition: logger.h:10
object_set_value
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
Definition: object.cpp:4484
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
server.h
CFAPI_OBJECT_PROP_SUBTYPE
#define CFAPI_OBJECT_PROP_SUBTYPE
Definition: plugin.h:146
Settings::tmpdir
const char * tmpdir
Directory to use for temporary files.
Definition: global.h:256
cfapi_player_knowledge
static void cfapi_player_knowledge(int *type,...)
Wrapper for knowledge-related functions().
Definition: plugins.cpp:4111
freearr_x
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
Definition: object.cpp:299
CFAPI_PLAYER_QUEST_WAS_COMPLETED
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED
Definition: plugin.h:244
svnversion.h
object::total_exp
int64_t total_exp
All exp ever earned (used to calc perm_exp)
Definition: object.h:379
command_function
void(* command_function)(object *op, const char *params)
One command function.
Definition: commands.h:17
plugins_dlclose
#define plugins_dlclose(lib)
Unload a shared library.
Definition: plugin.h:113
CFAPI_LONG
#define CFAPI_LONG
Definition: plugin.h:55
cfapi_map_get_object_at
static void cfapi_map_get_object_at(int *type,...)
Wrapper for GET_MAP_OB().
Definition: plugins.cpp:1370
plugins_init_plugin
int plugins_init_plugin(const char *libfile)
Try to load the specified plugin.
Definition: plugins.cpp:374
closedir
int closedir(DIR *)
mapstruct::darkness
uint8_t darkness
Indicates level of darkness of map.
Definition: map.h:336
cfapi_object_cast
static void cfapi_object_cast(int *type,...)
Wrapper for query_money().
Definition: plugins.cpp:3677
living::Pow
int8_t Pow
Definition: living.h:36
object::attacktype
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:352
pay_for_amount
int pay_for_amount(uint64_t to_pay, object *pl)
Takes the amount of money from the the player inventory and from it's various pouches using the pay_f...
Definition: shop.cpp:404
object_get_player_container
object * object_get_player_container(object *op)
Finds the player carrying an object.
Definition: object.cpp:592
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,...)
Wrapper for query_money().
Definition: plugins.cpp:3658
object::material
uint16_t material
What materials this object consist of.
Definition: object.h:357
CUSTOM_NAME_FIELD
#define CUSTOM_NAME_FIELD
Key in an object for the player-assigned custom name.
Definition: object.h:98
find_marked_object
object * find_marked_object(object *op)
Return the object the player has marked with the 'mark' command below.
Definition: c_object.cpp:1522
object::move_block
MoveType move_block
What movement types this blocks.
Definition: object.h:437
free_dialog_information
void free_dialog_information(object *op)
Frees obj::dialog_information.
Definition: dialog.cpp:34
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:664
living::hp
int16_t hp
Hit Points.
Definition: living.h:40
living::luck
int8_t luck
Affects thaco and ac from time to time.
Definition: living.h:39
check_path
int check_path(const char *name, int prepend_dir)
This function checks if a file with the given path exists.
Definition: map.cpp:201
CFAPI_PARTY_PROP_PASSWORD
#define CFAPI_PARTY_PROP_PASSWORD
Definition: plugin.h:273
CFAPI_OBJECT_PROP_LAST_GRACE
#define CFAPI_OBJECT_PROP_LAST_GRACE
Definition: plugin.h:160
cfapi_get_season_name
static void cfapi_get_season_name(int *type,...)
Wrapper for get_season_name().
Definition: plugins.cpp:905
CFAPI_MOVETYPE
#define CFAPI_MOVETYPE
Definition: plugin.h:71
f_plug_property
void *(* f_plug_property)(int *type,...)
Get various plugin properties.
Definition: plugin.h:85
cfapi_object_merge
static void cfapi_object_merge(int *type,...)
Wrapper for object_merge().
Definition: plugins.cpp:3469
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,...)
Clone an object, either through object_create_clone() or object_copy().
Definition: plugins.cpp:3257
CFAPI_OBJECT_PROP_SHORT_NAME
#define CFAPI_OBJECT_PROP_SHORT_NAME
Definition: plugin.h:186
Animations::name
sstring name
Name of the animation sequence.
Definition: face.h:26
cfapi_object_learn_spell
static void cfapi_object_learn_spell(int *type,...)
Definition: plugins.cpp:3705
object_can_merge
int object_can_merge(object *ob1, object *ob2)
Examines the 2 objects given to it, and returns true if they can be merged together,...
Definition: object.cpp:433
llevDebug
@ llevDebug
Only for debugging purposes.
Definition: logger.h:13
CFAPI_OBJECT_PROP_MATERIAL_NAME
#define CFAPI_OBJECT_PROP_MATERIAL_NAME
Definition: plugin.h:154
region::jaily
int16_t jaily
The coodinates in jailmap to which the player should be sent.
Definition: map.h:288
cfapi_map_trigger_connected
static void cfapi_map_trigger_connected(int *type,...)
Wrapper for trigger_connected().
Definition: plugins.cpp:3638
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:3920
region::jailx
int16_t jailx
Definition: map.h:288
cfapi_object_set_property
static void cfapi_object_set_property(int *type,...)
Sets the property of an object.
Definition: plugins.cpp:2381
plugins_dlopen
#define plugins_dlopen(fname)
Load a shared library.
Definition: plugin.h:112
cost_string_from_value
char * cost_string_from_value(uint64_t cost, int largest_coin)
Converts a price to number of coins.
Definition: shop.cpp:220
living::Con
int8_t Con
Definition: living.h:36
CFAPI_OBJECT_PROP_WEIGHT_LIMIT
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:167
face
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn though Notes on Specific and settings file datadir Usually usr share crossfire Contains data that the server does not need to modify while such as the etc A default install will pack the and treasurelist definitions into a single or trs file and the graphics into a face(metadata) and .tar(bitmaps) file
trigger_connected
void trigger_connected(objectlink *ol, object *cause, const int state)
Trigger every object in an objectlink.
Definition: button.cpp:41
Settings::uniquedir
const char * uniquedir
Directory for the unique items.
Definition: global.h:254
living::Str
int8_t Str
Definition: living.h:36
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)
Get the quest state for a player.
Definition: quest.cpp:660
cfapi_map_find_by_archetype_name
static void cfapi_map_find_by_archetype_name(int *type,...)
Kinda wrapper for map_find_by_archetype() (but uses a string, not an archetype*).
Definition: plugins.cpp:1399
cftimer_create
int cftimer_create(int id, long delay, object *ob, int mode)
Creates a new timer.
Definition: timers.cpp:97
player_get_title
void player_get_title(const player *pl, char *buf, size_t bufsize)
Returns the player's title.
Definition: player.cpp:232
cfapi_object_check_trigger
static void cfapi_object_check_trigger(int *type,...)
Wrapper for check_trigger().
Definition: plugins.cpp:3611
cfapi_object_clear
static void cfapi_object_clear(int *type,...)
Wrapper for object_clear().
Definition: plugins.cpp:3533
identify
object * identify(object *op)
Identifies an item.
Definition: item.cpp:1449
Settings::localdir
const char * localdir
Read/write data files.
Definition: global.h:250