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 
1236  case CFAPI_MAP_PROP_WPARTX:
1237  rint = va_arg(args, int*);
1238  *rint = map->wpartx;
1239  *type = CFAPI_INT;
1240  break;
1241 
1242  case CFAPI_MAP_PROP_WPARTY:
1243  rint = va_arg(args, int*);
1244  *rint = map->wparty;
1245  *type = CFAPI_INT;
1246  break;
1247 
1249  rstr = va_arg(args, sstring *);
1250  *rstr = map->msg;
1251  *type = CFAPI_SSTRING;
1252  break;
1253 
1254  case CFAPI_MAP_PROP_NEXT:
1255  rmap = va_arg(args, mapstruct **);
1256  *rmap = map ? map->next : first_map;
1257  *type = CFAPI_PMAP;
1258  break;
1259 
1260  case CFAPI_MAP_PROP_REGION:
1261  rreg = va_arg(args, region **);
1262  *rreg = get_region_by_map(map);
1263  *type = CFAPI_PREGION;
1264  break;
1265 
1266  case CFAPI_MAP_PROP_UNIQUE:
1267  rint = va_arg(args, int *);
1268  *rint = map->unique;
1269  *type = CFAPI_INT;
1270  break;
1271 
1272  default:
1273  *type = CFAPI_NONE;
1274  break;
1275  }
1276  va_end(args);
1277 }
1278 
1279 static void cfapi_map_set_map_property(int *type, ...) {
1280  va_list args;
1281  mapstruct *map;
1282  int property;
1283  const char *buf;
1284 
1285  va_start(args, type);
1286 
1287  map = va_arg(args, mapstruct *);
1288  property = va_arg(args, int);
1289 
1290  switch (property) {
1291  case CFAPI_MAP_PROP_PATH:
1292  buf = va_arg(args, const char *);
1293  strlcpy(map->path, buf, sizeof(map->path));
1294  *type = CFAPI_STRING;
1295  break;
1296 
1297  default:
1298  *type = CFAPI_NONE;
1299  break;
1300  }
1301  va_end(args);
1302 }
1303 
1309 static void cfapi_map_out_of_map(int *type, ...) {
1310  va_list args;
1311  mapstruct *map;
1312  int x, y;
1313  int *rint;
1314 
1315  va_start(args, type);
1316  map = va_arg(args, mapstruct *);
1317  x = va_arg(args, int);
1318  y = va_arg(args, int);
1319  rint = va_arg(args, int *);
1320 
1321  *rint = out_of_map(map, x, y);
1322  va_end(args);
1323  *type = CFAPI_INT;
1324 }
1325 
1331 static void cfapi_map_update_position(int *type, ...) {
1332  va_list args;
1333  mapstruct *map;
1334  int x, y;
1335 
1336  va_start(args, type);
1337 
1338  map = va_arg(args, mapstruct *);
1339  x = va_arg(args, int);
1340  y = va_arg(args, int);
1341 
1342  update_position(map, x, y);
1343  va_end(args);
1344  *type = CFAPI_NONE;
1345 }
1346 
1347 static void cfapi_map_delete_map(int *type, ...) {
1348  va_list args;
1349  mapstruct *map;
1350  va_start(args, type);
1351 
1352  map = va_arg(args, mapstruct *);
1353 
1354  delete_map(map);
1355 
1356  va_end(args);
1357  *type = CFAPI_NONE;
1358 }
1359 
1360 static void cfapi_map_message(int *type, ...) {
1361  va_list args;
1362  mapstruct *map;
1363  const char *string;
1364  int color;
1365 
1366  va_start(args, type);
1367  map = va_arg(args, mapstruct *);
1368  string = va_arg(args, const char *);
1369  color = va_arg(args, int);
1370  va_end(args);
1371 
1372  /* function should be extended to take message types probably */
1373  ext_info_map(color, map, MSG_TYPE_MISC, MSG_SUBTYPE_NONE, string);
1374  *type = CFAPI_NONE;
1375 }
1376 
1382 static void cfapi_map_get_object_at(int *type, ...) {
1383  va_list args;
1384  mapstruct *map;
1385  int x, y;
1386  int16_t sx, sy;
1387  object **robj;
1388 
1389  va_start(args, type);
1390  map = va_arg(args, mapstruct *);
1391  x = va_arg(args, int);
1392  y = va_arg(args, int);
1393  robj = va_arg(args, object **);
1394  va_end(args);
1395 
1396  sx = x;
1397  sy = y;
1398  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1399  *robj = NULL;
1400  else
1401  *robj = GET_MAP_OB(map, sx, sy);
1402  *type = CFAPI_POBJECT;
1403 }
1404 
1411 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1412  va_list args;
1413  int x, y;
1414  mapstruct *map;
1415  char *msg;
1416  object **robj;
1417 
1418  va_start(args, type);
1419 
1420  msg = va_arg(args, char *);
1421  map = va_arg(args, mapstruct *);
1422  x = va_arg(args, int);
1423  y = va_arg(args, int);
1424  robj = va_arg(args, object **);
1425 
1426  va_end(args);
1427 
1428  archetype *at = try_find_archetype(msg);
1429  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1430  *type = CFAPI_POBJECT;
1431 }
1432 
1438 static void cfapi_map_change_light(int *type, ...) {
1439  va_list args;
1440  int change;
1441  mapstruct *map;
1442  int *rint;
1443 
1444  va_start(args, type);
1445  map = va_arg(args, mapstruct *);
1446  change = va_arg(args, int);
1447  rint = va_arg(args, int *);
1448  va_end(args);
1449 
1450  *type = CFAPI_INT;
1451  *rint = change_map_light(map, change);
1452 }
1453 
1454 /* OBJECT-RELATED HOOKS */
1455 
1469 static void cfapi_object_move(int *type, ...) {
1470  va_list args;
1471  int kind;
1472  object *op;
1473  object *activator;
1474  player *pl;
1475  int direction;
1476  int *ret;
1477 
1478  va_start(args, type);
1479  kind = va_arg(args, int);
1480  switch (kind) {
1481  case 0:
1482  op = va_arg(args, object *);
1483  direction = va_arg(args, int);
1484  activator = va_arg(args, object *);
1485  ret = va_arg(args, int *);
1486  va_end(args);
1487  *ret = move_ob(op, direction, activator);
1488  break;
1489 
1490  case 1:
1491  pl = va_arg(args, player *);
1492  direction = va_arg(args, int);
1493  ret = va_arg(args, int *);
1494  va_end(args);
1495  *ret = move_player(pl->ob, direction);
1496  break;
1497 
1498  case 2:
1499  op = va_arg(args, object *);
1500  ret = va_arg(args, int *);
1501  va_end(args);
1502  *ret = player_arrest(op);
1503  break;
1504 
1505  default:
1506  // Just end the use of variable args. We got a wrong type.
1507  va_end(args);
1508  }
1509  *type = CFAPI_INT;
1510 }
1511 
1519 static void cfapi_object_get_key(int *type, ...) {
1520  va_list args;
1521  const char *keyname;
1522  const char **value;
1523  object *op;
1524 
1525  va_start(args, type);
1526  op = va_arg(args, object *);
1527  keyname = va_arg(args, const char *);
1528  value = va_arg(args, const char **);
1529  va_end(args);
1530 
1531  *value = object_get_value(op, keyname);
1532  *type = CFAPI_SSTRING;
1533 }
1534 
1541 static void cfapi_object_set_key(int *type, ...) {
1542  va_list args;
1543  const char *keyname;
1544  const char *value;
1545  int *ret;
1546  object *op;
1547  int add_key;
1548 
1549  va_start(args, type);
1550  op = va_arg(args, object *);
1551  keyname = va_arg(args, char *);
1552  value = va_arg(args, char *);
1553  add_key = va_arg(args, int);
1554  ret = va_arg(args, int *);
1555  va_end(args);
1556 
1557  *ret = object_set_value(op, keyname, value, add_key);
1558  *type = CFAPI_INT;
1559 }
1560 
1564 static void cfapi_object_get_property(int *type, ...) {
1565  va_list args;
1566  int property;
1567  object *op;
1568  int *rint;
1569  object **robject;
1570  mapstruct **rmap;
1571  float *rfloat;
1572  archetype **rarch;
1573  sstring *rsstring;
1574  char *rbuffer;
1575  int rbufsize;
1576  MoveType *rmove;
1577  int64_t *rint64;
1578  partylist **rparty;
1579  double *rdouble;
1580  long *rlong;
1581 
1582  va_start(args, type);
1583 
1584  op = va_arg(args, object *);
1585  property = va_arg(args, int);
1586  switch (property) {
1588  robject = va_arg(args, object **);
1589  *robject = op->above;
1590  *type = CFAPI_POBJECT;
1591  break;
1592 
1594  robject = va_arg(args, object **);
1595  *robject = op->below;
1596  *type = CFAPI_POBJECT;
1597  break;
1598 
1600  robject = va_arg(args, object **);
1601  *robject = op->active_next;
1602  *type = CFAPI_POBJECT;
1603  break;
1604 
1606  robject = va_arg(args, object **);
1607  *robject = op->active_prev;
1608  *type = CFAPI_POBJECT;
1609  break;
1610 
1612  robject = va_arg(args, object **);
1613  *robject = op->inv;
1614  *type = CFAPI_POBJECT;
1615  break;
1616 
1618  robject = va_arg(args, object **);
1619  *robject = op->env;
1620  *type = CFAPI_POBJECT;
1621  break;
1622 
1624  robject = va_arg(args, object **);
1625  *robject = op->head;
1626  *type = CFAPI_POBJECT;
1627  break;
1628 
1630  robject = va_arg(args, object **);
1631  *robject = op->container;
1632  *type = CFAPI_POBJECT;
1633  break;
1634 
1635  case CFAPI_OBJECT_PROP_MAP:
1636  rmap = va_arg(args, mapstruct **);
1637  *rmap = op->map;
1638  *type = CFAPI_PMAP;
1639  break;
1640 
1642  rint = va_arg(args, int *);
1643  *rint = op->count;
1644  *type = CFAPI_INT;
1645  break;
1646 
1648  rbuffer = va_arg(args, char *);
1649  rbufsize = va_arg(args, int);
1650  query_name(op, rbuffer, rbufsize);
1651  *type = CFAPI_STRING;
1652  break;
1653 
1655  rsstring = va_arg(args, sstring *);
1656  *rsstring = op->name_pl;
1657  *type = CFAPI_SSTRING;
1658  break;
1659 
1661  rsstring = va_arg(args, sstring *);
1662  *rsstring = op->title;
1663  *type = CFAPI_SSTRING;
1664  break;
1665 
1667  rsstring = va_arg(args, sstring *);
1668  *rsstring = op->race;
1669  *type = CFAPI_SSTRING;
1670  break;
1671 
1673  rsstring = va_arg(args, sstring *);
1674  *rsstring = op->slaying;
1675  *type = CFAPI_SSTRING;
1676  break;
1677 
1679  rsstring = va_arg(args, sstring *);
1680  *rsstring = op->skill;
1681  *type = CFAPI_SSTRING;
1682  break;
1683 
1685  rsstring = va_arg(args, sstring *);
1686  *rsstring = op->msg;
1687  *type = CFAPI_SSTRING;
1688  break;
1689 
1691  rsstring = va_arg(args, sstring *);
1692  *rsstring = op->lore;
1693  *type = CFAPI_SSTRING;
1694  break;
1695 
1696  case CFAPI_OBJECT_PROP_X:
1697  rint = va_arg(args, int *);
1698  *rint = op->x;
1699  *type = CFAPI_INT;
1700  break;
1701 
1702  case CFAPI_OBJECT_PROP_Y:
1703  rint = va_arg(args, int *);
1704  *rint = op->y;
1705  *type = CFAPI_INT;
1706  break;
1707 
1709  rfloat = va_arg(args, float *);
1710  *rfloat = op->speed;
1711  *type = CFAPI_FLOAT;
1712  break;
1713 
1715  rfloat = va_arg(args, float *);
1716  *rfloat = op->speed_left;
1717  *type = CFAPI_FLOAT;
1718  break;
1719 
1721  rint = va_arg(args, int *);
1722  *rint = NROF(op);
1723  *type = CFAPI_INT;
1724  break;
1725 
1727  rint = va_arg(args, int *);
1728  *rint = op->direction;
1729  *type = CFAPI_INT;
1730  break;
1731 
1733  rint = va_arg(args, int *);
1734  *rint = op->facing;
1735  *type = CFAPI_INT;
1736  break;
1737 
1739  rint = va_arg(args, int *);
1740  *rint = op->type;
1741  *type = CFAPI_INT;
1742  break;
1743 
1745  rint = va_arg(args, int *);
1746  *rint = op->subtype;
1747  *type = CFAPI_INT;
1748  break;
1749 
1751  rint = va_arg(args, int *);
1752  *rint = op->client_type;
1753  *type = CFAPI_INT;
1754  break;
1755 
1756  case CFAPI_OBJECT_PROP_RESIST: {
1757  int idx;
1758  int16_t *resist;
1759 
1760  idx = va_arg(args, int);
1761  resist = va_arg(args, int16_t *);
1762  *resist = op->resist[idx];
1763  }
1764  *type = CFAPI_INT16;
1765  break;
1766 
1768  rint = va_arg(args, int *);
1769  *rint = op->attacktype;
1770  *type = CFAPI_INT;
1771  break;
1772 
1774  rint = va_arg(args, int *);
1775  *rint = op->path_attuned;
1776  *type = CFAPI_INT;
1777  break;
1778 
1780  rint = va_arg(args, int *);
1781  *rint = op->path_repelled;
1782  *type = CFAPI_INT;
1783  break;
1784 
1786  rint = va_arg(args, int *);
1787  *rint = op->path_denied;
1788  *type = CFAPI_INT;
1789  break;
1790 
1792  rint = va_arg(args, int *);
1793  *rint = op->material;
1794  *type = CFAPI_INT;
1795  break;
1796 
1798  rsstring = va_arg(args, sstring *);
1799  *rsstring = op->materialname;
1800  *type = CFAPI_SSTRING;
1801  break;
1802 
1804  rint = va_arg(args, int *);
1805  *rint = op->magic;
1806  *type = CFAPI_INT;
1807  break;
1808 
1810  rlong = va_arg(args, long *);
1811  *rlong = op->value;
1812  *type = CFAPI_LONG;
1813  break;
1814 
1816  rint = va_arg(args, int *);
1817  *rint = op->level;
1818  *type = CFAPI_INT;
1819  break;
1820 
1822  rint = va_arg(args, int *);
1823  *rint = op->last_heal;
1824  *type = CFAPI_INT;
1825  break;
1826 
1828  rint = va_arg(args, int *);
1829  *rint = op->last_sp;
1830  *type = CFAPI_INT;
1831  break;
1832 
1834  rint = va_arg(args, int *);
1835  *rint = op->last_grace;
1836  *type = CFAPI_INT;
1837  break;
1838 
1840  rint = va_arg(args, int *);
1841  *rint = op->last_eat;
1842  *type = CFAPI_INT;
1843  break;
1844 
1846  rint = va_arg(args, int *);
1847  *rint = op->invisible;
1848  *type = CFAPI_INT;
1849  break;
1850 
1852  rint = va_arg(args, int *);
1853  *rint = op->pick_up;
1854  *type = CFAPI_INT;
1855  break;
1856 
1858  rint = va_arg(args, int *);
1859  *rint = op->item_power;
1860  *type = CFAPI_INT;
1861  break;
1862 
1864  rint = va_arg(args, int *);
1865  *rint = op->gen_sp_armour;
1866  *type = CFAPI_INT;
1867  break;
1868 
1870  rint = va_arg(args, int *);
1871  *rint = op->weight;
1872  *type = CFAPI_INT;
1873  break;
1874 
1876  rint = va_arg(args, int *);
1877  *rint = op->weight_limit;
1878  *type = CFAPI_INT;
1879  break;
1880 
1882  rint = va_arg(args, int *);
1883  *rint = op->carrying;
1884  *type = CFAPI_INT;
1885  break;
1886 
1888  rint = va_arg(args, int *);
1889  *rint = op->glow_radius;
1890  *type = CFAPI_INT;
1891  break;
1892 
1894  rint64 = va_arg(args, int64_t *);
1895  *rint64 = op->total_exp;
1896  *type = CFAPI_SINT64;
1897  break;
1898 
1900  robject = va_arg(args, object **);
1901  *robject = op->current_weapon;
1902  *type = CFAPI_POBJECT;
1903  break;
1904 
1906  robject = va_arg(args, object **);
1907  *robject = op->enemy;
1908  *type = CFAPI_POBJECT;
1909  break;
1910 
1912  robject = va_arg(args, object **);
1913  *robject = op->attacked_by;
1914  *type = CFAPI_POBJECT;
1915  break;
1916 
1918  rint = va_arg(args, int *);
1919  *rint = op->run_away;
1920  *type = CFAPI_INT;
1921  break;
1922 
1924  robject = va_arg(args, object **);
1925  *robject = op->chosen_skill;
1926  *type = CFAPI_POBJECT;
1927  break;
1928 
1930  rint = va_arg(args, int *);
1931  *rint = op->hide;
1932  *type = CFAPI_INT;
1933  break;
1934 
1936  rint = va_arg(args, int *);
1937  *rint = op->move_status;
1938  *type = CFAPI_INT;
1939  break;
1940 
1942  rint = va_arg(args, int *);
1943  *rint = op->attack_movement;
1944  *type = CFAPI_INT;
1945  break;
1946 
1948  robject = va_arg(args, object **);
1949  *robject = op->spellitem;
1950  *type = CFAPI_POBJECT;
1951  break;
1952 
1954  rdouble = va_arg(args, double *);
1955  *rdouble = op->expmul;
1956  *type = CFAPI_DOUBLE;
1957  break;
1958 
1960  rarch = va_arg(args, archetype **);
1961  *rarch = op->arch;
1962  *type = CFAPI_PARCH;
1963  break;
1964 
1966  rarch = va_arg(args, archetype **);
1967  *rarch = op->other_arch;
1968  *type = CFAPI_PARCH;
1969  break;
1970 
1972  rsstring = va_arg(args, sstring *);
1973  *rsstring = object_get_value(op, CUSTOM_NAME_FIELD);
1974  *type = CFAPI_SSTRING;
1975  break;
1976 
1978  rint = va_arg(args, int *);
1979  *rint = op->anim_speed;
1980  *type = CFAPI_INT;
1981  break;
1982 
1984  rint = va_arg(args, int *);
1985  *rint = is_friendly(op);
1986  *type = CFAPI_INT;
1987  break;
1988 
1990  rbuffer = va_arg(args, char *);
1991  rbufsize = va_arg(args, int);
1992  query_short_name(op, rbuffer, rbufsize);
1993  *type = CFAPI_STRING;
1994  break;
1995 
1997  int i;
1998 
1999  i = va_arg(args, int);
2000  rbuffer = va_arg(args, char *);
2001  rbufsize = va_arg(args, int);
2002  query_base_name(op, i, rbuffer, rbufsize);
2003  *type = CFAPI_STRING;
2004  }
2005  break;
2006 
2008  rsstring = va_arg(args, sstring *);
2009  *rsstring = op->name;
2010  *type = CFAPI_SSTRING;
2011  break;
2012 
2014  rint = va_arg(args, int *);
2015  *rint = is_magical(op);
2016  *type = CFAPI_INT;
2017  break;
2018 
2020  rint = va_arg(args, int *);
2021  *rint = op->stats.luck;
2022  *type = CFAPI_INT;
2023  break;
2024 
2025  case CFAPI_OBJECT_PROP_EXP:
2026  rint64 = va_arg(args, int64_t *);
2027  *rint64 = op->stats.exp;
2028  *type = CFAPI_SINT64;
2029  break;
2030 
2032  robject = va_arg(args, object **);
2033  *robject = object_get_owner(op);
2034  *type = CFAPI_POBJECT;
2035  break;
2036 
2038  int stype;
2039 
2040  stype = va_arg(args, int);
2041  switch (stype) {
2042  unsigned char ptype;
2043  char *buf;
2044  archetype *at;
2045 
2046  case 0: /* present_in_ob */
2047  ptype = (unsigned char)(va_arg(args, int));
2048  robject = va_arg(args, object **);
2049  *robject = object_present_in_ob(ptype, op);
2050  break;
2051 
2052  case 1: /* present_in_ob_by_name */
2053  ptype = (unsigned char)(va_arg(args, int));
2054  buf = va_arg(args, char *);
2055  robject = va_arg(args, object **);
2056  *robject = object_present_in_ob_by_name(ptype, buf, op);
2057  break;
2058 
2059  case 2: /* arch_present_in_ob */
2060  at = va_arg(args, archetype *);
2061  robject = va_arg(args, object **);
2062  *robject = arch_present_in_ob(at, op);
2063  break;
2064  }
2065  }
2066  *type = CFAPI_POBJECT;
2067  break;
2068 
2070  rint = va_arg(args, int *);
2071  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2072  *type = CFAPI_INT;
2073  break;
2074 
2076  object *op2;
2077 
2078  op2 = va_arg(args, object *);
2079  rint = va_arg(args, int *);
2080  *rint = object_can_merge(op, op2);
2081  }
2082  *type = CFAPI_INT;
2083  break;
2084 
2086  object *op2;
2087 
2088  op2 = va_arg(args, object *);
2089  rint = va_arg(args, int *);
2090  *rint = object_can_pick(op2, op);
2091  }
2092  *type = CFAPI_INT;
2093  break;
2094 
2095  case CFAPI_OBJECT_PROP_FLAGS: {
2096  int fl;
2097 
2098  fl = va_arg(args, int);
2099  rint = va_arg(args, int *);
2100  *rint = QUERY_FLAG(op, fl);
2101  }
2102  *type = CFAPI_INT;
2103  break;
2104 
2105  case CFAPI_OBJECT_PROP_STR:
2106  rint = va_arg(args, int *);
2107  *rint = op->stats.Str;
2108  *type = CFAPI_INT;
2109  break;
2110 
2111  case CFAPI_OBJECT_PROP_DEX:
2112  rint = va_arg(args, int *);
2113  *rint = op->stats.Dex;
2114  *type = CFAPI_INT;
2115  break;
2116 
2117  case CFAPI_OBJECT_PROP_CON:
2118  rint = va_arg(args, int *);
2119  *rint = op->stats.Con;
2120  *type = CFAPI_INT;
2121  break;
2122 
2123  case CFAPI_OBJECT_PROP_WIS:
2124  rint = va_arg(args, int *);
2125  *rint = op->stats.Wis;
2126  *type = CFAPI_INT;
2127  break;
2128 
2129  case CFAPI_OBJECT_PROP_INT:
2130  rint = va_arg(args, int *);
2131  *rint = op->stats.Int;
2132  *type = CFAPI_INT;
2133  break;
2134 
2135  case CFAPI_OBJECT_PROP_POW:
2136  rint = va_arg(args, int *);
2137  *rint = op->stats.Pow;
2138  *type = CFAPI_INT;
2139  break;
2140 
2141  case CFAPI_OBJECT_PROP_CHA:
2142  rint = va_arg(args, int *);
2143  *rint = op->stats.Cha;
2144  *type = CFAPI_INT;
2145  break;
2146 
2147  case CFAPI_OBJECT_PROP_WC:
2148  rint = va_arg(args, int *);
2149  *rint = op->stats.wc;
2150  *type = CFAPI_INT;
2151  break;
2152 
2153  case CFAPI_OBJECT_PROP_AC:
2154  rint = va_arg(args, int *);
2155  *rint = op->stats.ac;
2156  *type = CFAPI_INT;
2157  break;
2158 
2159  case CFAPI_OBJECT_PROP_HP:
2160  rint = va_arg(args, int *);
2161  *rint = op->stats.hp;
2162  *type = CFAPI_INT;
2163  break;
2164 
2165  case CFAPI_OBJECT_PROP_SP:
2166  rint = va_arg(args, int *);
2167  *rint = op->stats.sp;
2168  *type = CFAPI_INT;
2169  break;
2170 
2171  case CFAPI_OBJECT_PROP_GP:
2172  rint = va_arg(args, int *);
2173  *rint = op->stats.grace;
2174  *type = CFAPI_INT;
2175  break;
2176 
2177  case CFAPI_OBJECT_PROP_FP:
2178  rint = va_arg(args, int *);
2179  *rint = op->stats.food;
2180  *type = CFAPI_INT;
2181  break;
2182 
2184  rint = va_arg(args, int *);
2185  *rint = op->stats.maxhp;
2186  *type = CFAPI_INT;
2187  break;
2188 
2190  rint = va_arg(args, int *);
2191  *rint = op->stats.maxsp;
2192  *type = CFAPI_INT;
2193  break;
2194 
2196  rint = va_arg(args, int *);
2197  *rint = op->stats.maxgrace;
2198  *type = CFAPI_INT;
2199  break;
2200 
2201  case CFAPI_OBJECT_PROP_DAM:
2202  rint = va_arg(args, int *);
2203  *rint = op->stats.dam;
2204  *type = CFAPI_INT;
2205  break;
2206 
2207  case CFAPI_OBJECT_PROP_GOD:
2208  rsstring = va_arg(args, sstring *);
2209  *rsstring = determine_god(op);
2210  *type = CFAPI_SSTRING;
2211  break;
2212 
2214  rsstring = va_arg(args, sstring *);
2215  *rsstring = op->arch->name;
2216  *type = CFAPI_SSTRING;
2217  break;
2218 
2220  rint = va_arg(args, int *);
2221  *rint = op->invisible;
2222  *type = CFAPI_INT;
2223  break;
2224 
2226  rsstring = va_arg(args, sstring *);
2227  if (op->face != NULL) {
2228  (*rsstring) = op->face->name;
2229  }
2230  else {
2231  (*rsstring) = NULL;
2232  }
2233  *type = CFAPI_SSTRING;
2234  break;
2235 
2237  rsstring = va_arg(args, sstring *);
2238  if (op->animation != NULL) {
2239  (*rsstring) = op->animation->name;
2240  }
2241  else {
2242  (*rsstring) = NULL;
2243  }
2244  *type = CFAPI_SSTRING;
2245  break;
2246 
2248  rint = va_arg(args, int *);
2249  *rint = op->contr->count;
2250  *type = CFAPI_INT;
2251  break;
2252 
2253  case CFAPI_PLAYER_PROP_IP:
2254  rsstring = va_arg(args, sstring *);
2255  *rsstring = op->contr->socket->host;
2256  *type = CFAPI_SSTRING;
2257  break;
2258 
2260  rsstring = va_arg(args, sstring *);
2261  *rsstring = op->contr->socket->client;
2262  *type = CFAPI_SSTRING;
2263  break;
2264 
2266  robject = va_arg(args, object **);
2267  *robject = find_marked_object(op);
2268  *type = CFAPI_POBJECT;
2269  break;
2270 
2272  rparty = va_arg(args, partylist **);
2273  *rparty = (op->contr ? op->contr->party : NULL);
2274  *type = CFAPI_PPARTY;
2275  break;
2276 
2278  robject = va_arg(args, object **);
2279  if (op)
2280  *robject = op->contr->next ? op->contr->next->ob : NULL;
2281  else
2282  /* This can be called when there is no player. */
2283  *robject = first_player ? first_player->ob : NULL;
2284  *type = CFAPI_POBJECT;
2285  break;
2286 
2288  rbuffer = va_arg(args, char *);
2289  rbufsize = va_arg(args, int);
2290  player_get_title(op->contr, rbuffer, rbufsize);
2291  *type = CFAPI_STRING;
2292  break;
2293 
2295  robject = va_arg(args, object **);
2296  *robject = op->contr->transport;
2297  *type = CFAPI_POBJECT;
2298  break;
2299 
2301  rmove = va_arg(args, MoveType *);
2302  *rmove = op->move_type;
2303  *type = CFAPI_MOVETYPE;
2304  break;
2305 
2307  rmove = va_arg(args, MoveType *);
2308  *rmove = op->move_block;
2309  *type = CFAPI_MOVETYPE;
2310  break;
2311 
2313  rmove = va_arg(args, MoveType *);
2314  *rmove = op->move_allow;
2315  *type = CFAPI_MOVETYPE;
2316  break;
2317 
2319  rmove = va_arg(args, MoveType *);
2320  *rmove = op->move_on;
2321  *type = CFAPI_MOVETYPE;
2322  break;
2323 
2325  rmove = va_arg(args, MoveType *);
2326  *rmove = op->move_off;
2327  *type = CFAPI_MOVETYPE;
2328  break;
2329 
2331  rmove = va_arg(args, MoveType *);
2332  *rmove = op->move_type;
2333  *type = CFAPI_MOVETYPE;
2334  break;
2335 
2337  rfloat = va_arg(args, float *);
2338  *rfloat = op->move_slow_penalty;
2339  *type = CFAPI_FLOAT;
2340  break;
2341 
2343  rbuffer = va_arg(args, char *);
2344  rbufsize = va_arg(args, int);
2345  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2346  *type = CFAPI_STRING;
2347  break;
2348 
2350  rint = va_arg(args, int *);
2351  *rint = op->contr->bed_x;
2352  *type = CFAPI_INT;
2353  break;
2354 
2356  rint = va_arg(args, int *);
2357  *rint = op->contr->bed_y;
2358  *type = CFAPI_INT;
2359  break;
2360 
2362  rint = va_arg(args, int *);
2363  *rint = op->duration;
2364  *type = CFAPI_INT;
2365  break;
2366 
2367  default:
2368  *type = CFAPI_NONE;
2369  break;
2370  }
2371  va_end(args);
2372 }
2373 
2382 static void copy_message(object *op, const char *msg) {
2383  /* need to reset parsed dialog information */
2385  if (strlen(msg) == 0) {
2386  msg = NULL;
2387  }
2388  object_set_msg(op, msg);
2389 }
2390 
2399 static void cfapi_object_set_property(int *type, ...) {
2400  va_list args;
2401  int iarg, *ret;
2402  long larg;
2403  char *sarg;
2404  double darg;
2405  object *oparg;
2406  object *op;
2407  int property;
2408  int64_t s64arg;
2409  partylist *partyarg;
2410  float farg;
2411  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2412 
2413  va_start(args, type);
2414  op = va_arg(args, object *);
2415  property = va_arg(args, int);
2416  *type = CFAPI_NONE;
2417 
2418  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2419  switch (property) {
2421  sarg = va_arg(args, char *);
2422  *type = CFAPI_STRING;
2423  FREE_AND_COPY(op->name, sarg);
2424  send_changed_object(op);
2425  break;
2426 
2428  sarg = va_arg(args, char *);
2429  *type = CFAPI_STRING;
2430  FREE_AND_COPY(op->name_pl, sarg);
2431  send_changed_object(op);
2432  break;
2433 
2435  sarg = va_arg(args, char *);
2436  *type = CFAPI_STRING;
2437  FREE_AND_COPY(op->title, sarg);
2438  break;
2439 
2441  sarg = va_arg(args, char *);
2442  *type = CFAPI_STRING;
2443  FREE_AND_COPY(op->race, sarg);
2444  break;
2445 
2447  sarg = va_arg(args, char *);
2448  *type = CFAPI_STRING;
2449  FREE_AND_COPY(op->slaying, sarg);
2450  break;
2451 
2453  sarg = va_arg(args, char *);
2454  *type = CFAPI_STRING;
2455  FREE_AND_COPY(op->skill, sarg);
2456  break;
2457 
2459  sarg = va_arg(args, char *);
2460  *type = CFAPI_STRING;
2461  copy_message(op, sarg);
2462  break;
2463 
2465  sarg = va_arg(args, char *);
2466  *type = CFAPI_STRING;
2467  FREE_AND_COPY(op->lore, sarg);
2468  break;
2469 
2471  farg = va_arg(args, double);
2472  *type = CFAPI_FLOAT;
2473  if (farg != op->speed) {
2474  op->speed = farg;
2475  object_update_speed(op);
2476  }
2477  break;
2478 
2480  farg = va_arg(args, double);
2481  *type = CFAPI_FLOAT;
2482  op->speed_left = farg;
2483  break;
2484 
2486  iarg = va_arg(args, int);
2487  *type = CFAPI_INT;
2488  if (iarg < 0)
2489  iarg = 0;
2490  if (op->nrof > (uint32_t)iarg)
2491  object_decrease_nrof(op, op->nrof-iarg);
2492  else if (op->nrof < (uint32_t)iarg) {
2493  object *tmp;
2494  player *pl;
2495 
2496  op->nrof = iarg;
2497  if (op->env != NULL) {
2498  tmp = object_get_player_container(op->env);
2499  if (!tmp) {
2500  for (pl = first_player; pl; pl = pl->next)
2501  if (pl->ob->container == op->env)
2502  break;
2503  if (pl)
2504  tmp = pl->ob;
2505  else
2506  tmp = NULL;
2507  } else {
2508  object_sum_weight(tmp);
2509  fix_object(tmp);
2510  }
2511  if (tmp)
2512  esrv_update_item(UPD_NROF, tmp, op);
2513  } else {
2514  FOR_ABOVE_PREPARE(op, tmp)
2515  if (tmp->type == PLAYER)
2516  tmp->contr->socket->update_look = 1;
2517  FOR_ABOVE_FINISH();
2518  }
2519  }
2520  break;
2521 
2523  iarg = va_arg(args, int);
2524  *type = CFAPI_INT;
2525  op->direction = iarg;
2526  break;
2527 
2529  iarg = va_arg(args, int);
2530  *type = CFAPI_INT;
2531  op->facing = iarg;
2532  break;
2533 
2534  case CFAPI_OBJECT_PROP_RESIST: {
2535  int iargbis = va_arg(args, int);
2536 
2537  *type = CFAPI_INT16;
2538  iarg = va_arg(args, int);
2539  op->resist[iargbis] = iarg;
2540  }
2541  break;
2542 
2544  iarg = va_arg(args, int);
2545  *type = CFAPI_INT;
2546  op->attacktype = iarg;
2547  break;
2548 
2550  iarg = va_arg(args, int);
2551  *type = CFAPI_INT;
2552  op->path_attuned = iarg;
2553  break;
2554 
2556  iarg = va_arg(args, int);
2557  *type = CFAPI_INT;
2558  op->path_repelled = iarg;
2559  break;
2560 
2562  iarg = va_arg(args, int);
2563  *type = CFAPI_INT;
2564  op->path_denied = iarg;
2565  break;
2566 
2568  iarg = va_arg(args, int);
2569  *type = CFAPI_INT;
2570  op->material = iarg;
2571  break;
2572 
2574  break;
2575 
2577  iarg = va_arg(args, int);
2578  *type = CFAPI_INT;
2579  op->magic = iarg;
2580  break;
2581 
2583  larg = va_arg(args, long);
2584  *type = CFAPI_LONG;
2585  op->value = larg;
2586  break;
2587 
2589  iarg = va_arg(args, int);
2590  *type = CFAPI_INT;
2591  op->level = iarg;
2592  send_changed_object(op);
2593  break;
2594 
2596  iarg = va_arg(args, int);
2597  *type = CFAPI_INT;
2598  op->last_heal = iarg;
2599  break;
2600 
2602  iarg = va_arg(args, int);
2603  *type = CFAPI_INT;
2604  op->last_sp = iarg;
2605  break;
2606 
2608  iarg = va_arg(args, int);
2609  *type = CFAPI_INT;
2610  op->last_grace = iarg;
2611  break;
2612 
2614  iarg = va_arg(args, int);
2615  *type = CFAPI_INT;
2616  op->last_eat = iarg;
2617  break;
2618 
2620  iarg = va_arg(args, int);
2621  *type = CFAPI_INT;
2622  op->invisible = iarg;
2623  break;
2624 
2626  iarg = va_arg(args, int);
2627  *type = CFAPI_INT;
2628  op->pick_up = iarg;
2629  break;
2630 
2632  iarg = va_arg(args, int);
2633  *type = CFAPI_INT;
2634  op->item_power = iarg;
2635  break;
2636 
2638  iarg = va_arg(args, int);
2639  *type = CFAPI_INT;
2640  op->gen_sp_armour = iarg;
2641  break;
2642 
2644  iarg = va_arg(args, int);
2645  *type = CFAPI_INT;
2646  if (op->weight != iarg) {
2647  object *tmp;
2648  player *pl;
2649 
2650  op->weight = iarg;
2651  if (op->env != NULL) {
2652  tmp = object_get_player_container(op->env);
2653  if (!tmp) {
2654  for (pl = first_player; pl; pl = pl->next)
2655  if (pl->ob->container == op->env)
2656  break;
2657  if (pl)
2658  tmp = pl->ob;
2659  else
2660  tmp = NULL;
2661  } else {
2662  object_sum_weight(tmp);
2663  fix_object(tmp);
2664  }
2665  if (tmp)
2666  esrv_update_item(UPD_WEIGHT, tmp, op);
2667  } else {
2668  FOR_ABOVE_PREPARE(op, tmp)
2669  if (tmp->type == PLAYER)
2670  esrv_update_item(UPD_WEIGHT, tmp, op);
2671  FOR_ABOVE_FINISH();
2672  }
2673  }
2674  break;
2675 
2677  iarg = va_arg(args, int);
2678  *type = CFAPI_INT;
2679  op->weight_limit = iarg;
2680  break;
2681 
2683  iarg = va_arg(args, int);
2684  *type = CFAPI_INT;
2685  if (op->glow_radius != iarg) {
2686  object *tmp;
2687 
2688  op->glow_radius = iarg;
2689  tmp = object_get_env_recursive(op);
2690  if (tmp->map != NULL) {
2691  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2692  update_position(tmp->map, tmp->x, tmp->y);
2693  update_all_los(tmp->map, tmp->x, tmp->y);
2694  }
2695  }
2696  break;
2697 
2699  s64arg = va_arg(args, int64_t);
2700  *type = CFAPI_SINT64;
2701  op->total_exp = s64arg;
2702  break;
2703 
2705  oparg = va_arg(args, object *);
2706  *type = CFAPI_POBJECT;
2707  object_set_enemy(op, oparg);
2708  break;
2709 
2711  iarg = va_arg(args, int);
2712  *type = CFAPI_INT;
2713  op->run_away = iarg;
2714  break;
2715 
2717  oparg = va_arg(args, object *);
2718  *type = CFAPI_POBJECT;
2719  op->chosen_skill = oparg;
2720  break;
2721 
2723  iarg = va_arg(args, int);
2724  *type = CFAPI_INT;
2725  op->hide = iarg;
2726  break;
2727 
2729  iarg = va_arg(args, int);
2730  *type = CFAPI_INT;
2731  op->move_status = iarg;
2732  break;
2733 
2735  iarg = va_arg(args, int);
2736  *type = CFAPI_INT;
2737  op->attack_movement = iarg;
2738  break;
2739 
2741  oparg = va_arg(args, object *);
2742  *type = CFAPI_POBJECT;
2743  op->spellitem = oparg;
2744  break;
2745 
2747  darg = va_arg(args, double);
2748  *type = CFAPI_DOUBLE;
2749  op->expmul = darg;
2750  break;
2751 
2753  sarg = va_arg(args, char *);
2754  *type = CFAPI_STRING;
2755  object_set_value(op, CUSTOM_NAME_FIELD, sarg, 1);
2756  send_changed_object(op);
2757  break;
2758 
2760  iarg = va_arg(args, int);
2761  *type = CFAPI_INT;
2762  op->anim_speed = iarg;
2763  break;
2764 
2766  iarg = va_arg(args, int);
2767  *type = CFAPI_INT;
2768  if (iarg == 1 && is_friendly(op) == 0)
2769  add_friendly_object(op);
2770  else if (iarg == 0 && is_friendly(op) == 1)
2772  break;
2773 
2775  iarg = va_arg(args, int);
2776  *type = CFAPI_INT;
2777  op->stats.luck = iarg;
2778  break;
2779 
2780  case CFAPI_OBJECT_PROP_EXP:
2781  s64arg = va_arg(args, int64_t);
2782  *type = CFAPI_SINT64;
2783  op->stats.exp = s64arg;
2784  break;
2785 
2787  oparg = va_arg(args, object *);
2788  *type = CFAPI_POBJECT;
2789  object_set_owner(op, oparg);
2790  break;
2791 
2793  object_set_cheat(op);
2794  *type = CFAPI_NONE;
2795  break;
2796 
2797  case CFAPI_OBJECT_PROP_FLAGS: {
2798  int iargbis;
2799 
2800  iarg = va_arg(args, int);
2801  iargbis = va_arg(args, int);
2802  *type = CFAPI_INT;
2803 
2804  if (iargbis == 1)
2805  SET_FLAG(op, iarg);
2806  else
2807  CLEAR_FLAG(op, iarg);
2808  send_changed_object(op);
2809  }
2810  break;
2811 
2812  case CFAPI_OBJECT_PROP_STR:
2813  iarg = va_arg(args, int);
2814  *type = CFAPI_INT;
2815  op->stats.Str = iarg;
2816  break;
2817 
2818  case CFAPI_OBJECT_PROP_DEX:
2819  iarg = va_arg(args, int);
2820  *type = CFAPI_INT;
2821  op->stats.Dex = iarg;
2822  break;
2823 
2824  case CFAPI_OBJECT_PROP_CON:
2825  iarg = va_arg(args, int);
2826  *type = CFAPI_INT;
2827  op->stats.Con = iarg;
2828  break;
2829 
2830  case CFAPI_OBJECT_PROP_WIS:
2831  iarg = va_arg(args, int);
2832  *type = CFAPI_INT;
2833  op->stats.Wis = iarg;
2834  break;
2835 
2836  case CFAPI_OBJECT_PROP_INT:
2837  iarg = va_arg(args, int);
2838  *type = CFAPI_INT;
2839  op->stats.Int = iarg;
2840  break;
2841 
2842  case CFAPI_OBJECT_PROP_POW:
2843  iarg = va_arg(args, int);
2844  *type = CFAPI_INT;
2845  op->stats.Pow = iarg;
2846  break;
2847 
2848  case CFAPI_OBJECT_PROP_CHA:
2849  iarg = va_arg(args, int);
2850  *type = CFAPI_INT;
2851  op->stats.Cha = iarg;
2852  break;
2853 
2854  case CFAPI_OBJECT_PROP_WC:
2855  iarg = va_arg(args, int);
2856  *type = CFAPI_INT;
2857  op->stats.wc = iarg;
2858  break;
2859 
2860  case CFAPI_OBJECT_PROP_AC:
2861  iarg = va_arg(args, int);
2862  *type = CFAPI_INT;
2863  op->stats.ac = iarg;
2864  break;
2865 
2866  case CFAPI_OBJECT_PROP_HP:
2867  iarg = va_arg(args, int);
2868  *type = CFAPI_INT;
2869  op->stats.hp = iarg;
2870  break;
2871 
2872  case CFAPI_OBJECT_PROP_SP:
2873  iarg = va_arg(args, int);
2874  *type = CFAPI_INT;
2875  op->stats.sp = iarg;
2876  break;
2877 
2878  case CFAPI_OBJECT_PROP_GP:
2879  iarg = va_arg(args, int);
2880  *type = CFAPI_INT;
2881  op->stats.grace = iarg;
2882  break;
2883 
2884  case CFAPI_OBJECT_PROP_FP:
2885  iarg = va_arg(args, int);
2886  *type = CFAPI_INT;
2887  op->stats.food = iarg;
2888  break;
2889 
2891  iarg = va_arg(args, int);
2892  *type = CFAPI_INT;
2893  op->stats.maxhp = iarg;
2894  break;
2895 
2897  iarg = va_arg(args, int);
2898  *type = CFAPI_INT;
2899  op->stats.maxsp = iarg;
2900  break;
2901 
2903  iarg = va_arg(args, int);
2904  *type = CFAPI_INT;
2905  op->stats.maxgrace = iarg;
2906  break;
2907 
2908  case CFAPI_OBJECT_PROP_DAM:
2909  iarg = va_arg(args, int);
2910  *type = CFAPI_INT;
2911  op->stats.dam = iarg;
2912  break;
2913 
2914  case CFAPI_OBJECT_PROP_FACE: {
2915  const Face *face;
2916  sarg = va_arg(args, char *);
2917  ret = va_arg(args, int *);
2918  *type = CFAPI_INT;
2919  face = try_find_face(sarg, 0);
2920  if (face != NULL) {
2921  op->face = face;
2922  op->state = 0;
2924  (*ret) = face->number;
2925  } else
2926  (*ret) = 0;
2927  break;
2928  }
2929 
2931  const Animations *anim;
2932  sarg = va_arg(args, char *);
2933  ret = va_arg(args, int *);
2934  *type = CFAPI_INT;
2935  anim = try_find_animation(sarg);
2936  if (anim != NULL) {
2937  op->animation = anim;
2938  SET_ANIMATION(op, 0);
2940  (*ret) = anim->num;
2941  } else {
2942  (*ret) = 0;
2943  }
2944  break;
2945  }
2946 
2948  iarg = va_arg(args, int);
2949  *type = CFAPI_INT;
2950  op->duration = iarg;
2951  break;
2952 
2954  if (op->contr) {
2955  oparg = va_arg(args, object *);
2956  *type = CFAPI_POBJECT;
2957  op->contr->mark = oparg;
2958  if (oparg) {
2959  op->contr->mark_count = oparg->count;
2960  } else {
2961  op->contr->mark_count = 0;
2962  }
2963  }
2964  break;
2965 
2967  if (op->contr) {
2968  partyarg = va_arg(args, partylist *);
2969  *type = CFAPI_PPARTY;
2970  party_join(op, partyarg);
2971  }
2972  break;
2973 
2975  sarg = va_arg(args, char *);
2976  *type = CFAPI_STRING;
2977  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
2978  break;
2979 
2981  iarg = va_arg(args, int);
2982  *type = CFAPI_INT;
2983  op->contr->bed_x = iarg;
2984  break;
2985 
2987  iarg = va_arg(args, int);
2988  *type = CFAPI_INT;
2989  op->contr->bed_y = iarg;
2990  break;
2991 
2993  sarg = va_arg(args, char *);
2994  *type = CFAPI_STRING;
2995  player_set_own_title(op->contr, sarg);
2996  break;
2997 
2999  move = va_arg(args, MoveType *);
3000  op->move_type = *move & MOVE_ALL;
3002  *type = CFAPI_MOVETYPE;
3003  break;
3004 
3006  move = va_arg(args, MoveType *);
3007  op->move_block = *move & MOVE_ALL;
3009  *type = CFAPI_MOVETYPE;
3010  break;
3011 
3013  move = va_arg(args, MoveType *);
3014  op->move_allow = *move & MOVE_ALL;
3016  *type = CFAPI_MOVETYPE;
3017  break;
3018 
3020  move = va_arg(args, MoveType *);
3021  op->move_on = *move & MOVE_ALL;
3023  *type = CFAPI_MOVETYPE;
3024  break;
3025 
3027  move = va_arg(args, MoveType *);
3028  op->move_off = *move & MOVE_ALL;
3030  *type = CFAPI_MOVETYPE;
3031  break;
3032 
3034  move = va_arg(args, MoveType *);
3035  op->move_type = *move & MOVE_ALL;
3037  *type = CFAPI_MOVETYPE;
3038  break;
3039 
3040  default:
3041  break;
3042  }
3043  }
3044  va_end(args);
3045 }
3046 
3053 static void cfapi_object_apply_below(int *type, ...) {
3054  va_list args;
3055  object *applier;
3056 
3057  va_start(args, type);
3058 
3059  applier = va_arg(args, object *);
3060 
3061  va_end(args);
3062 
3063  apply_by_living_below(applier);
3064  *type = CFAPI_NONE;
3065 }
3066 
3073 static void cfapi_object_apply(int *type, ...) {
3074  va_list args;
3075  object *applied;
3076  object *applier;
3077  int aflags;
3078  int *ret;
3079 
3080  va_start(args, type);
3081 
3082  applier = va_arg(args, object *);
3083  applied = va_arg(args, object *);
3084  aflags = va_arg(args, int);
3085  ret = va_arg(args, int *);
3086 
3087  va_end(args);
3088 
3089  *type = CFAPI_INT;
3090  *ret = apply_manual(applier, applied, aflags);
3091 }
3092 
3098 static void cfapi_object_identify(int *type, ...) {
3099  va_list args;
3100  object *op, **result;
3101 
3102  va_start(args, type);
3103 
3104  op = va_arg(args, object *);
3105  result = va_arg(args, object **);
3106 
3107  va_end(args);
3108 
3109  (*result) = identify(op);
3110  *type = CFAPI_POBJECT;
3111 }
3112 
3118 static void cfapi_object_describe(int *type, ...) {
3119  va_list args;
3120  object *op;
3121  object *owner;
3122  char *desc, *final;
3123  int size;
3124 
3125  va_start(args, type);
3126 
3127  op = va_arg(args, object *);
3128  owner = va_arg(args, object *);
3129  desc = va_arg(args, char *);
3130  size = va_arg(args, int);
3131  va_end(args);
3132 
3133  *type = CFAPI_STRING;
3134  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3135  strncpy(desc, final, size);
3136  desc[size - 1] = '\0';
3137  free(final);
3138 }
3139 
3140 static void cfapi_object_drain(int *type, ...) {
3141  va_list args;
3142 
3143  object *op;
3144  int ds;
3145 
3146  va_start(args, type);
3147 
3148  op = va_arg(args, object *);
3149  ds = va_arg(args, int);
3150 
3151  va_end(args);
3152 
3153  drain_specific_stat(op, ds);
3154 
3155  *type = CFAPI_NONE;
3156 }
3157 
3158 static void cfapi_object_remove_depletion(int *type, ...) {
3159  va_list args;
3160 
3161  object *op;
3162  int level, *result;
3163 
3164  va_start(args, type);
3165 
3166  op = va_arg(args, object *);
3167  level = va_arg(args, int);
3168  result = va_arg(args, int*);
3169 
3170  va_end(args);
3171 
3172  *result = remove_depletion(op, level);
3173 
3174  *type = CFAPI_INT;
3175 }
3176 
3177 static void cfapi_object_fix(int *type, ...) {
3178  va_list args;
3179  object *op;
3180 
3181  va_start(args, type);
3182 
3183  op = va_arg(args, object *);
3184 
3185  va_end(args);
3186 
3187  fix_object(op);
3188 
3189  *type = CFAPI_NONE;
3190 }
3191 
3193 static void cfapi_object_give_skill(int *type, ...) {
3194  va_list args;
3195 
3196  object *op;
3197  char *skillname;
3198 
3199  va_start(args, type);
3200 
3201  op = va_arg(args, object *);
3202  skillname = va_arg(args, char *);
3203 
3204  va_end(args);
3205 
3206  *type = CFAPI_POBJECT;
3207  give_skill_by_name(op, skillname);
3208 }
3209 
3210 static void cfapi_object_transmute(int *type, ...) {
3211  va_list args;
3212 
3213  object *op;
3214  object *chg;
3215 
3216  va_start(args, type);
3217 
3218  op = va_arg(args, object *);
3219  chg = va_arg(args, object *);
3220 
3221  va_end(args);
3222 
3223  transmute_materialname(op, chg);
3224  *type = CFAPI_NONE;
3225 }
3226 
3227 static void cfapi_object_remove(int *type, ...) {
3228  va_list args;
3229  object *op;
3230 
3231  va_start(args, type);
3232 
3233  op = va_arg(args, object *);
3234 
3235  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3236  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3237  va_end(args);
3238  *type = CFAPI_NONE;
3239  return;
3240  }
3241 
3242  va_end(args);
3243 
3244  object_remove(op);
3245  *type = CFAPI_NONE;
3246 }
3247 
3248 static void cfapi_object_delete(int *type, ...) {
3249  va_list args;
3250  object *op;
3251 
3252  va_start(args, type);
3253 
3254  op = va_arg(args, object *);
3255 
3256  if (QUERY_FLAG(op, FLAG_FREED) || !QUERY_FLAG(op, FLAG_REMOVED)) {
3257  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3258  *type = CFAPI_NONE;
3259  va_end(args);
3260  return;
3261  }
3262 
3263  va_end(args);
3264 
3266 
3267  *type = CFAPI_NONE;
3268 }
3269 
3275 static void cfapi_object_clone(int *type, ...) {
3276  va_list args;
3277  object *op;
3278  int kind;
3279  object **robj;
3280 
3281  va_start(args, type);
3282 
3283  op = va_arg(args, object *);
3284  kind = va_arg(args, int);
3285  robj = va_arg(args, object **);
3286 
3287  va_end(args);
3288 
3289  if (kind == 0) {
3290  *type = CFAPI_POBJECT;
3291  *robj = object_create_clone(op);
3292  } else {
3293  object *tmp;
3294  tmp = object_new();
3295  object_copy(op, tmp);
3296  *type = CFAPI_POBJECT;
3297  *robj = tmp;
3298  }
3299  return;
3300 }
3301 
3307 static void cfapi_object_create(int *type, ...) {
3308  va_list args;
3309  int ival;
3310  object **robj;
3311  va_start(args, type);
3312  ival = va_arg(args, int);
3313 
3314  *type = CFAPI_POBJECT;
3315  switch (ival) {
3316  case 0:
3317  robj = va_arg(args, object **);
3318  *robj = object_new();
3319  break;
3320 
3321  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3322  const char *sval;
3323  archetype *at;
3324 
3325  sval = va_arg(args, const char *);
3326  robj = va_arg(args, object **);
3327  va_end(args);
3328 
3329  at = try_find_archetype(sval);
3330  if (!at)
3331  at = find_archetype_by_object_name(sval);
3332  if (at) {
3333  *robj = object_create_arch(at);
3334  } else
3335  *robj = NULL;
3336  }
3337  break;
3338 
3339  default:
3340  *type = CFAPI_NONE;
3341  break;
3342  }
3343  va_end(args);
3344 }
3345 
3346 static void cfapi_object_insert(int *type, ...) {
3347  va_list args;
3348  object *op;
3349  object *orig;
3350  mapstruct *map;
3351  int flag, x, y;
3352  int itype;
3353  object **robj;
3354 
3355  va_start(args, type);
3356 
3357  op = va_arg(args, object *);
3358  if (!op) {
3359  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3360  va_end(args);
3361  return;
3362  }
3363  if (QUERY_FLAG(op, FLAG_FREED)) {
3364  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3365  va_end(args);
3366  return;
3367  }
3368  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3369  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3370  object_remove(op);
3371  }
3372  itype = va_arg(args, int);
3373 
3374  switch (itype) {
3375  case 0:
3376  map = va_arg(args, mapstruct *);
3377  orig = va_arg(args, object *);
3378  flag = va_arg(args, int);
3379  x = va_arg(args, int);
3380  y = va_arg(args, int);
3381  robj = va_arg(args, object **);
3382  if (!map) {
3383  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3385  *robj = NULL;
3386  } else
3387  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3388  *type = CFAPI_POBJECT;
3389  break;
3390 
3391  case 1:
3392  map = va_arg(args, mapstruct *);
3393  orig = va_arg(args, object *);
3394  flag = va_arg(args, int);
3395  robj = va_arg(args, object **);
3396  if (!map) {
3397  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3399  *robj = NULL;
3400  } else
3401  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3402  *type = CFAPI_POBJECT;
3403  break;
3404 
3405  case 2:
3406  map = va_arg(args, mapstruct *);
3407  orig = va_arg(args, object *);
3408  flag = va_arg(args, int);
3409  x = va_arg(args, int);
3410  y = va_arg(args, int);
3411  robj = va_arg(args, object **);
3412  if (!map) {
3413  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3415  *robj = NULL;
3416  } else {
3417  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3418  if (dir != -1) {
3419  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3420  } else {
3422  *robj = NULL;
3423  }
3424  }
3425  *type = CFAPI_POBJECT;
3426  break;
3427 
3428  case 3:
3429  orig = va_arg(args, object *);
3430  robj = va_arg(args, object **);
3431  if (!orig) {
3432  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3434  *robj = NULL;
3435  } else
3436  *robj = object_insert_in_ob(op, orig);
3437  *type = CFAPI_POBJECT;
3438  break;
3439 
3440  default:
3441  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3443  *type = CFAPI_NONE;
3444  break;
3445  }
3446 
3447  va_end(args);
3448 }
3454 static void cfapi_object_split(int *type, ...) {
3455  va_list args;
3456 
3457  int nr, size;
3458  object *op;
3459  char *buf;
3460  object **split;
3461 
3462  va_start(args, type);
3463 
3464  op = va_arg(args, object *);
3465  nr = va_arg(args, int);
3466  buf = va_arg(args, char *);
3467  size = va_arg(args, int);
3468  split = va_arg(args, object **);
3469  va_end(args);
3470 
3471  *split = object_split(op, nr, buf, size);
3472  if (*split != NULL)
3473  {
3474  *type = CFAPI_POBJECT;
3475  }
3476  else
3477  {
3478  *type = CFAPI_NONE;
3479  }
3480 }
3481 
3487 static void cfapi_object_merge(int *type, ...) {
3488  va_list args;
3489  object *op;
3490  object *op2;
3491  object **merge;
3492 
3493  va_start(args, type);
3494 
3495  op = va_arg(args, object *);
3496  op2 = va_arg(args, object *);
3497  merge = va_arg(args, object **);
3498 
3499  va_end(args);
3500 
3501  *type = CFAPI_POBJECT;
3502  *merge = object_merge(op, op2);
3503 }
3504 
3510 static void cfapi_object_distance(int *type, ...) {
3511  va_list args;
3512  object *op;
3513  object *op2;
3514  int *rint;
3515  va_start(args, type);
3516 
3517  op = va_arg(args, object *);
3518  op2 = va_arg(args, object *);
3519  rint = va_arg(args, int *);
3520 
3521  va_end(args);
3522 
3523  *type = CFAPI_INT;
3524  *rint = object_distance(op, op2);
3525 }
3531 static void cfapi_object_update(int *type, ...) {
3532  va_list args;
3533  int action;
3534  object *op;
3535  va_start(args, type);
3536 
3537  op = va_arg(args, object *);
3538  action = va_arg(args, int);
3539 
3540  va_end(args);
3541 
3542  object_update(op, action);
3543  *type = CFAPI_NONE;
3544 }
3545 
3551 static void cfapi_object_clear(int *type, ...) {
3552  va_list args;
3553  object *op;
3554  va_start(args, type);
3555 
3556  op = va_arg(args, object *);
3557 
3558  va_end(args);
3559 
3560  object_clear(op);
3561  *type = CFAPI_NONE;
3562 }
3563 
3569 static void cfapi_object_reset(int *type, ...) {
3570  va_list args;
3571  object *op;
3572 
3573  va_start(args, type);
3574 
3575  op = va_arg(args, object *);
3576 
3577  va_end(args);
3578 
3579  object_reset(op);
3580  *type = CFAPI_NONE;
3581 }
3582 
3583 static void cfapi_object_clean_object(int *type, ...) {
3584  va_list args;
3585  object *op;
3586 
3587  va_start(args, type);
3588  op = va_arg(args, object *);
3589  clean_object(op);
3590  va_end(args);
3591  *type = CFAPI_NONE;
3592 }
3593 
3594 static void cfapi_object_on_same_map(int *type, ...) {
3595  va_list args;
3596  object *op1;
3597  object *op2;
3598  int *rint;
3599 
3600  va_start(args, type);
3601  op1 = va_arg(args, object *);
3602  op2 = va_arg(args, object *);
3603  rint = va_arg(args, int *);
3604  va_end(args);
3605 
3606  *type = CFAPI_INT;
3607  *rint = on_same_map(op1, op2);
3608 }
3609 
3610 static void cfapi_object_spring_trap(int *type, ...) {
3611  object *trap;
3612  object *victim;
3613  va_list args;
3614 
3615  va_start(args, type);
3616  trap = va_arg(args, object *);
3617  victim = va_arg(args, object *);
3618  va_end(args);
3619 
3620  spring_trap(trap, victim);
3621  *type = CFAPI_NONE;
3622 }
3623 
3629 static void cfapi_object_check_trigger(int *type, ...) {
3630  object *op;
3631  object *cause;
3632  va_list args;
3633  int *rint;
3634 
3635  va_start(args, type);
3636  op = va_arg(args, object *);
3637  cause = va_arg(args, object *);
3638  rint = va_arg(args, int *);
3639  va_end(args);
3640 
3641  *rint = check_trigger(op, cause);
3642  *type = CFAPI_INT;
3643 }
3644 
3656 static void cfapi_map_trigger_connected(int *type, ...) {
3657  objectlink *ol;
3658  object *cause;
3659  int state;
3660  va_list args;
3661 
3662  va_start(args, type);
3663  ol = va_arg(args, objectlink *);
3664  cause = va_arg(args, object *);
3665  state = va_arg(args, int);
3666  va_end(args);
3667  trigger_connected(ol, cause, state);
3668  *type = CFAPI_NONE;
3669 }
3670 
3676 static void cfapi_object_query_money(int *type, ...) {
3677  object *op;
3678  va_list args;
3679  int *rint;
3680 
3681  va_start(args, type);
3682  op = va_arg(args, object *);
3683  rint = va_arg(args, int *);
3684  va_end(args);
3685 
3686  *rint = query_money(op);
3687  *type = CFAPI_INT;
3688 }
3689 
3695 static void cfapi_object_cast(int *type, ...) {
3696  object *op;
3697  object *sp;
3698  int dir;
3699  char *str;
3700  object *caster;
3701  va_list args;
3702  int *rint;
3703 
3704  va_start(args, type);
3705  op = va_arg(args, object *);
3706  caster = va_arg(args, object *);
3707  dir = va_arg(args, int);
3708  sp = va_arg(args, object *);
3709  str = va_arg(args, char *);
3710  rint = va_arg(args, int *);
3711  va_end(args);
3712 
3713  *type = CFAPI_INT;
3714 
3715  if (!op->map) {
3716  *rint = -1;
3717  return;
3718  }
3719 
3720  *rint = cast_spell(op, caster, dir, sp, str);
3721 }
3722 
3723 static void cfapi_object_learn_spell(int *type, ...) {
3724  object *op;
3725  object *sp;
3726  int prayer;
3727  va_list args;
3728 
3729  va_start(args, type);
3730  op = va_arg(args, object *);
3731  sp = va_arg(args, object *);
3732  prayer = va_arg(args, int);
3733  va_end(args);
3734  do_learn_spell(op, sp, prayer);
3735  *type = CFAPI_NONE;
3736 }
3737 
3738 static void cfapi_object_forget_spell(int *type, ...) {
3739  object *op;
3740  object *sp;
3741  va_list args;
3742  char name[MAX_BUF];
3743 
3744  va_start(args, type);
3745  op = va_arg(args, object *);
3746  sp = va_arg(args, object *);
3747  va_end(args);
3748  query_name(sp, name, MAX_BUF);
3749  do_forget_spell(op, name);
3750  *type = CFAPI_NONE;
3751 }
3752 
3758 static void cfapi_object_check_spell(int *type, ...) {
3759  object *op;
3760  char *spellname;
3761  va_list args;
3762  object **robj;
3763 
3764  va_start(args, type);
3765  op = va_arg(args, object *);
3766  spellname = va_arg(args, char *);
3767  robj = va_arg(args, object **);
3768  va_end(args);
3769  *robj = check_spell_known(op, spellname);
3770  *type = CFAPI_POBJECT;
3771 }
3772 
3778 static void cfapi_object_pay_amount(int *type, ...) {
3779  object *op;
3780  uint64_t amount;
3781  va_list args;
3782  int *rint;
3783 
3784  va_start(args, type);
3785  op = va_arg(args, object *);
3786  amount = va_arg(args, uint64_t);
3787  rint = va_arg(args, int *);
3788  va_end(args);
3789 
3790  *rint = pay_for_amount(amount, op);
3791  *type = CFAPI_INT;
3792 }
3793 
3799 static void cfapi_object_pay_item(int *type, ...) {
3800  object *op;
3801  object *tobuy;
3802  int *rint;
3803 
3804  va_list args;
3805 
3806  va_start(args, type);
3807  tobuy = va_arg(args, object *);
3808  op = va_arg(args, object *);
3809  rint = va_arg(args, int *);
3810  va_end(args);
3811 
3812  *rint = pay_for_item(tobuy, op, 0);
3813  *type = CFAPI_INT;
3814 }
3815 
3823 static void cfapi_object_transfer(int *type, ...) {
3824  object *op;
3825  object *originator;
3826  int x, y, randompos, ttype, flag;
3827  va_list args;
3828  mapstruct *map;
3829  int *rint;
3830  object **robj;
3831 
3832  va_start(args, type);
3833  op = va_arg(args, object *);
3834  ttype = va_arg(args, int);
3835  switch (ttype) {
3836  case 0:
3837  x = va_arg(args, int);
3838  y = va_arg(args, int);
3839  randompos = va_arg(args, int);
3840  originator = va_arg(args, object *);
3841  rint = va_arg(args, int *);
3842  va_end(args);
3843 
3844  *rint = transfer_ob(op, x, y, randompos, originator);
3845  *type = CFAPI_INT;
3846  return;
3847  break;
3848 
3849  case 1:
3850  map = va_arg(args, mapstruct *);
3851  originator = va_arg(args, object *);
3852  flag = va_arg(args, int);
3853  x = va_arg(args, int);
3854  y = va_arg(args, int);
3855  robj = va_arg(args, object **);
3856  va_end(args);
3857  if (x < 0 || y < 0) {
3858  x = map->enter_x;
3859  y = map->enter_y;
3860  }
3861  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
3862  *type = CFAPI_POBJECT;
3863  return;
3864  break;
3865 
3866  case 2:
3867  x = va_arg(args, int);
3868  y = va_arg(args, int);
3869  rint = va_arg(args, int *);
3870  va_end(args);
3871 
3872  *rint = move_to(op, x, y);
3873  *type = CFAPI_INT;
3874  return;
3875 
3876  default:
3877  va_end(args);
3878  *type = CFAPI_NONE;
3879  return;
3880  break;
3881  }
3882 }
3883 
3888  object *op;
3889  char *str;
3890  va_list args;
3891  object **robj;
3892 
3893  *type = CFAPI_POBJECT;
3894  va_start(args, type);
3895  op = va_arg(args, object *);
3896 
3897  str = va_arg(args, char *);
3898  robj = va_arg(args, object **);
3899  archetype *at = try_find_archetype(str);
3900  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
3901  if (*robj == NULL) {
3902  char name[MAX_BUF];
3903 
3904  /* Search by name or slaying instead */
3905  FOR_INV_PREPARE(op, tmp) {
3906  if (tmp->name) {
3907  query_name(tmp, name, MAX_BUF);
3908  if (!strncmp(name, str, strlen(str)))
3909  *robj = tmp;
3910  if (!strncmp(tmp->name, str, strlen(str)))
3911  *robj = tmp;
3912  }
3913  if (tmp->slaying && !strcmp(tmp->slaying, str))
3914  *robj = tmp;
3915  if (*robj != NULL)
3916  break;
3917  } FOR_INV_FINISH();
3918  }
3919  va_end(args);
3920 }
3921 
3922 static void cfapi_object_find_by_arch_name(int *type, ...) {
3923  const object *who;
3924  object **result;
3925  const char *name;
3926  va_list args;
3927 
3928  va_start(args, type);
3929  who = va_arg(args, const object *);
3930  name = va_arg(args, const char *);
3931  result = va_arg(args, object **);
3932  va_end(args);
3933  *type = CFAPI_POBJECT;
3934 
3935  *result = object_find_by_arch_name(who, name);
3936 }
3937 
3938 static void cfapi_object_find_by_name(int *type, ...) {
3939  const object *who;
3940  object **result;
3941  const char *name;
3942  va_list args;
3943 
3944  va_start(args, type);
3945  who = va_arg(args, const object *);
3946  name = va_arg(args, const char *);
3947  result = va_arg(args, object **);
3948  va_end(args);
3949  *type = CFAPI_POBJECT;
3950 
3951  *result = object_find_by_name(who, name);
3952 }
3953 
3959 static void cfapi_object_drop(int *type, ...) {
3960  object *op;
3961  object *author;
3962  va_list args;
3963 
3964  va_start(args, type);
3965  op = va_arg(args, object *);
3966  author = va_arg(args, object *);
3967  va_end(args);
3968  *type = CFAPI_NONE;
3969 
3970  if (QUERY_FLAG(op, FLAG_NO_DROP))
3971  return;
3972  drop(author, op);
3973 
3974  if (author->type == PLAYER) {
3975  author->contr->count = 0;
3976  author->contr->socket->update_look = 1;
3977  }
3978 }
3979 
3983 static void cfapi_object_change_abil(int *type, ...) {
3984  object *op, *tmp;
3985  int *rint;
3986  va_list args;
3987 
3988  va_start(args, type);
3989  op = va_arg(args, object *);
3990  tmp = va_arg(args, object *);
3991  rint = va_arg(args, int *);
3992  va_end(args);
3993 
3994  *type = CFAPI_INT;
3995  *rint = change_abil(op, tmp);
3996 }
3997 
3998 static void cfapi_object_say(int *type, ...) {
3999  object *op;
4000  char *msg;
4001  va_list args;
4002  int *rint;
4003  char empty[] = "";
4004 
4005  va_start(args, type);
4006  op = va_arg(args, object *);
4007  msg = va_arg(args, char *);
4008  rint = va_arg(args, int *);
4009  va_end(args);
4010 
4011  if (op->type == PLAYER) {
4012  command_say(op, msg == NULL ? empty : msg);
4013  } else {
4014  monster_npc_say(op, msg);
4015  }
4016  *rint = 0;
4017  *type = CFAPI_INT;
4018 }
4019 
4020 /* PLAYER SUBCLASS */
4021 
4027 static void cfapi_player_find(int *type, ...) {
4028  va_list args;
4029  char *sval;
4030  player **rpl;
4031  va_start(args, type);
4032 
4033  sval = va_arg(args, char *);
4034  rpl = va_arg(args, player **);
4035  va_end(args);
4036 
4037  *rpl = find_player_partial_name(sval);
4038 
4039  *type = CFAPI_PPLAYER;
4040 }
4041 
4042 static void cfapi_player_message(int *type, ...) {
4043  va_list args;
4044  int flags;
4045  int pri;
4046  object *pl;
4047  const char *buf;
4048 
4049  va_start(args, type);
4050 
4051  flags = va_arg(args, int);
4052  pri = va_arg(args, int);
4053  pl = va_arg(args, object *);
4054  buf = va_arg(args, const char *);
4055  va_end(args);
4056 
4058  buf);
4059  *type = CFAPI_NONE;
4060 }
4061 
4068 static void cfapi_object_perm_exp(int *type, ...) {
4069  va_list args;
4070  object *op;
4071  int64_t *rlong;
4072 
4073  va_start(args, type);
4074  op = va_arg(args, object *);
4075  rlong = va_arg(args, int64_t *);
4076  va_end(args);
4077 
4078  *type = CFAPI_SINT64;
4079  *rlong = PERM_EXP(op->total_exp);
4080 }
4081 
4087 static void cfapi_object_change_exp(int *type, ...) {
4088  va_list args;
4089  int flag;
4090  object *ob;
4091  const char *skill;
4092  int64_t exp;
4093 
4094  va_start(args, type);
4095  ob = va_arg(args, object *);
4096  exp = va_arg(args, int64_t);
4097  skill = va_arg(args, const char *);
4098  flag = va_arg(args, int);
4099  va_end(args);
4100 
4101  *type = CFAPI_NONE;
4102  change_exp(ob, exp, skill, flag);
4103 }
4104 
4110 static void cfapi_player_can_pay(int *type, ...) {
4111  va_list args;
4112  object *pl;
4113  int *rint;
4114 
4115  va_start(args, type);
4116  pl = va_arg(args, object *);
4117  rint = va_arg(args, int *);
4118  va_end(args);
4119 
4120  *rint = can_pay(pl);
4121  *type = CFAPI_INT;
4122 }
4123 
4129 static void cfapi_player_knowledge(int *type, ...) {
4130  va_list args;
4131  object *pl;
4132  int *rint, what;
4133  const char *knowledge;
4134 
4135  va_start(args, type);
4136  what = va_arg(args, int);
4137 
4138  switch(what)
4139  {
4140  case 1:
4141  pl = va_arg(args, object *);
4142  knowledge = va_arg(args, const char *);
4143  rint = va_arg(args, int *);
4144 
4145  *type = CFAPI_INT;
4146 
4147  if (pl->contr == NULL) {
4148  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4149  *rint = 0;
4150  va_end(args);
4151  return;
4152  }
4153 
4154  *rint = knowledge_player_knows(pl->contr, knowledge);
4155  break;
4156 
4157  case 2:
4158  pl = va_arg(args, object *);
4159  knowledge = va_arg(args, const char *);
4160  *type = CFAPI_NONE;
4161  if (pl->contr != NULL)
4162  knowledge_give(pl->contr, knowledge, NULL);
4163 
4164  break;
4165 
4166  default:
4167  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4168  }
4169 
4170  va_end(args);
4171 }
4172 
4178 static void cfapi_object_teleport(int *type, ...) {
4179  mapstruct *map;
4180  int x, y;
4181  object *who;
4182  int *res;
4183  va_list args;
4184 
4185  va_start(args, type);
4186  who = va_arg(args, object *);
4187  map = va_arg(args, mapstruct *);
4188  x = va_arg(args, int);
4189  y = va_arg(args, int);
4190  res = va_arg(args, int *);
4191  va_end(args);
4192 
4193  *type = CFAPI_INT;
4194  *res = object_teleport(who, map, x, y);
4195 }
4196 
4197 static void cfapi_object_pickup(int *type, ...) {
4198  object *who;
4199  object *what;
4200  va_list args;
4201 
4202  va_start(args, type);
4203  who = va_arg(args, object *);
4204  what = va_arg(args, object *);
4205  int *res = va_arg(args, int *);
4206  va_end(args);
4207 
4208  *type = CFAPI_INT;
4209  *res = pick_up(who, what);
4210 }
4211 
4212 /* Archetype-related functions */
4213 static void cfapi_archetype_get_property(int *type, ...) {
4214  int prop;
4215  archetype *arch;
4216  va_list args;
4217  sstring *rsstring;
4218  archetype **rarch;
4219  object **robject;
4220 
4221  va_start(args, type);
4222  arch = va_arg(args, archetype *);
4223  prop = va_arg(args, int);
4224  switch (prop) {
4225  case CFAPI_ARCH_PROP_NAME:
4226  *type = CFAPI_SSTRING;
4227  rsstring = va_arg(args, sstring *);
4228  *rsstring = arch->name;
4229  break;
4230 
4231  case CFAPI_ARCH_PROP_NEXT:
4232  *type = CFAPI_PARCH;
4233  rarch = va_arg(args, archetype **);
4234  *rarch = get_next_archetype(arch);
4235  break;
4236 
4237  case CFAPI_ARCH_PROP_HEAD:
4238  *type = CFAPI_PARCH;
4239  rarch = va_arg(args, archetype **);
4240  *rarch = arch->head;
4241  break;
4242 
4243  case CFAPI_ARCH_PROP_MORE:
4244  *type = CFAPI_PARCH;
4245  rarch = va_arg(args, archetype **);
4246  *rarch = arch->more;
4247  break;
4248 
4249  case CFAPI_ARCH_PROP_CLONE:
4250  *type = CFAPI_POBJECT;
4251  robject = va_arg(args, object **);
4252  *robject = &arch->clone;
4253  break;
4254 
4255  default:
4256  *type = CFAPI_NONE;
4257  break;
4258  }
4259  va_end(args);
4260 }
4261 
4268 static void cfapi_party_get_property(int *type, ...) {
4269  partylist *party;
4270  int prop;
4271  va_list args;
4272  object *obarg;
4273  sstring *rsstring;
4274  player **rplayer;
4275  partylist **rparty;
4276 
4277  va_start(args, type);
4278  party = va_arg(args, partylist *);
4279  prop = va_arg(args, int);
4280  switch (prop) {
4281  case CFAPI_PARTY_PROP_NAME:
4282  rsstring = va_arg(args, sstring *);
4283  *rsstring = party->partyname;
4284  *type = CFAPI_SSTRING;
4285  break;
4286 
4287  case CFAPI_PARTY_PROP_NEXT:
4288  rparty = va_arg(args, partylist **);
4289  *rparty = (party ? party_get_next(party) : party_get_first());
4290  *type = CFAPI_PPARTY;
4291  break;
4292 
4294  rsstring = va_arg(args, sstring *);
4295  *rsstring = party_get_password(party);
4296  *type = CFAPI_SSTRING;
4297  break;
4298 
4300  *type = CFAPI_PPLAYER;
4301  obarg = va_arg(args, object *);
4302  rplayer = va_arg(args, player **);
4303  *rplayer = (obarg ? obarg->contr : first_player);
4304  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4305  if ((*rplayer)->ob->contr->party == party) {
4306  break;
4307  }
4308  break;
4309 
4310  default:
4311  *type = CFAPI_NONE;
4312  break;
4313  }
4314  va_end(args);
4315 }
4316 
4323 static void cfapi_region_get_property(int *type, ...) {
4324  region *reg;
4325  int prop, *rint;
4326  va_list args;
4328  sstring *rsstring;
4329  region **rregion;
4330 
4331  va_start(args, type);
4332  reg = va_arg(args, region *);
4333  prop = va_arg(args, int);
4334  switch (prop) {
4336  rsstring = va_arg(args, sstring *);
4337  *rsstring = reg->name;
4338  *type = CFAPI_SSTRING;
4339  break;
4340 
4342  rregion = va_arg(args, region **);
4343  *rregion = nullptr;
4344  *type = CFAPI_PREGION;
4345  break;
4346 
4348  rregion = va_arg(args, region **);
4349  *rregion = reg->parent;
4350  *type = CFAPI_PREGION;
4351  break;
4352 
4354  rsstring = va_arg(args, sstring *);
4355  *rsstring = reg->longname;
4356  *type = CFAPI_SSTRING;
4357  break;
4358 
4360  rsstring = va_arg(args, sstring *);
4361  *rsstring = reg->msg;
4362  *type = CFAPI_SSTRING;
4363  break;
4364 
4367  rint = va_arg(args, int*);
4368  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4369  *type = CFAPI_INT;
4370  break;
4371 
4373  rsstring = va_arg(args, sstring *);
4374  *rsstring = reg->jailmap;
4375  *type = CFAPI_SSTRING;
4376  break;
4377 
4378  default:
4379  *type = CFAPI_NONE;
4380  break;
4381  }
4382  va_end(args);
4383 }
4384 
4396 static void cfapi_friendlylist_get_next(int *type, ...) {
4397  object *ob;
4398  va_list args;
4399  object **robject;
4400 
4401  va_start(args, type);
4402  ob = va_arg(args, object *);
4403  robject = va_arg(args, object **);
4404  va_end(args);
4405 
4406  *type = CFAPI_POBJECT;
4407  *robject = get_next_friend(ob);
4408 }
4409 
4410 /*
4411  * Random-map related stuff.
4412  */
4413 
4420 static void cfapi_set_random_map_variable(int *type, ...) {
4421  va_list args;
4422  RMParms *rp;
4423  const char *buf;
4424  int *ret;
4425 
4426  va_start(args, type);
4427  rp = va_arg(args, RMParms *);
4428  buf = va_arg(args, const char *);
4429  ret = va_arg(args, int *);
4430  va_end(args);
4431 
4432  *ret = set_random_map_variable(rp, buf);
4433  *type = CFAPI_INT;
4434 }
4435 
4442 static void cfapi_generate_random_map(int *type, ...) {
4443  va_list args;
4444  const char *name;
4445  RMParms *rp;
4446  char **use_layout;
4447  sstring reset_group;
4448  mapstruct **ret;
4449 
4450  va_start(args, type);
4451  name = va_arg(args, const char *);
4452  rp = va_arg(args, RMParms *);
4453  use_layout = va_arg(args, char **);
4454  reset_group = va_arg(args, sstring);
4455  ret = va_arg(args, mapstruct **);
4456  va_end(args);
4457 
4458  *ret = generate_random_map(name, rp, use_layout, reset_group);
4459 }
4460 
4461 static void cfapi_object_user_event(int *type, ...) {
4462  object *op;
4463  object *activator;
4464  object *third;
4465  const char *message;
4466  int fix;
4467  int *ret;
4468  va_list args;
4469 
4470  va_start(args, type);
4471  op = va_arg(args, object *);
4472  activator = va_arg(args, object *);
4473  third = va_arg(args, object *);
4474  message = va_arg(args, const char *);
4475  fix = va_arg(args, int);
4476  ret = va_arg(args, int *);
4477  va_end(args);
4478 
4479  *ret = events_execute_object_user(op, activator, third, message, fix);
4480  *type = CFAPI_INT;
4481 }
4482 
4485 static void cfapi_player_quest(int *type, ...) {
4486  int op;
4487  va_list args;
4488  object *player;
4489  sstring code;
4490 
4491  va_start(args, type);
4492  op = va_arg(args, int);
4493  player = va_arg(args, object *);
4494  code = va_arg(args, sstring);
4495 
4496  if (player->contr == NULL) {
4497  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4498  va_end(args);
4499  /* crash/quit? */
4500  return;
4501  }
4502 
4503  switch(op) {
4504  case CFAPI_PLAYER_QUEST_START: {
4505  int state = va_arg(args, int);
4506  quest_start(player->contr, code, state);
4507  *type = CFAPI_NONE;
4508  break;
4509  }
4511  int *ret = va_arg(args, int *);
4512  *ret = quest_get_player_state(player->contr, code);
4513  *type = CFAPI_INT;
4514  break;
4515  }
4517  int state = va_arg(args, int);
4518  quest_set_player_state(player->contr, code, state);
4519  *type = CFAPI_NONE;
4520  break;
4521  }
4523  int *ret = va_arg(args, int*);
4524  *ret = quest_was_completed(player->contr, code);
4525  *type = CFAPI_INT;
4526  break;
4527  }
4528  default:
4529  LOG(llevError, "invalid quest type: %d\n", op);
4530  *type = CFAPI_NONE;
4531  }
4532 
4533  va_end(args);
4534 }
4535 
4536 static void cfapi_register_command(int *type, ...) {
4537  va_list args;
4538  const char *name = NULL, *extra = NULL;
4539  float time;
4540  command_function func = NULL;
4541  command_function_extra func_extra = NULL;
4542  uint8_t register_type, command_type;
4544 
4545  va_start(args, type);
4546  register_type = va_arg(args, int);
4547  name = va_arg(args, const char *);
4548  if (register_type == 1) {
4549  func = va_arg(args, command_function);
4550  } else {
4551  extra = va_arg(args, const char *);
4552  func_extra = va_arg(args, command_function_extra);
4553  }
4554  command_type = (uint8_t)va_arg(args, int);
4555  if (command_type > COMMAND_TYPE_WIZARD) {
4556  command_type = COMMAND_TYPE_NORMAL;
4557  }
4558  time = va_arg(args, double);
4559  cr = va_arg(args, command_registration *);
4560  va_end(args);
4561 
4562  if (register_type == 1) {
4563  (*cr) = command_register(name, command_type, func, time);
4564  } else {
4565  (*cr) = command_register_extra(name, extra, command_type, func_extra, time);
4566  }
4567 
4568  *type = CFAPI_SINT64;
4569 }
4570 
4571 static void cfapi_unregister_command(int *type, ...) {
4572  va_list args;
4574 
4575  va_start(args, type);
4576  cr = va_arg(args, command_registration);
4577  va_end(args);
4578 
4579  command_unregister(cr);
4580 }
4581 
4582 /*****************************************************************************/
4583 /* NEW PLUGIN STUFF ENDS HERE */
4584 /*****************************************************************************/
4585 
4586 
4591 void initPlugins(void) {
4592  struct dirent *currentfile;
4593  DIR *plugdir;
4594  size_t l;
4595  char buf[sizeof(LIBDIR) + 9 + sizeof(dirent::d_name)];
4596 
4597  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4598  LOG(llevDebug, "plugins: loading from %s\n", buf);
4599 
4600  plugdir = opendir(buf);
4601  if (plugdir == NULL)
4602  return;
4603 
4604  while ((currentfile = readdir(plugdir)) != NULL) {
4605  l = strlen(currentfile->d_name);
4606  if (l > strlen(PLUGIN_SUFFIX)) {
4607  int ignore = 0;
4608 
4609  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4610  continue;
4611 
4612  for (auto disable = serverSettings.disabled_plugins.cbegin(); disable != serverSettings.disabled_plugins.cend(); ++disable) {
4613  if (strcmp(disable->c_str(), "All") == 0) {
4614  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4615  ignore = 1;
4616  break;
4617  }
4618  if (strncmp(disable->c_str(), currentfile->d_name, disable->length()) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + disable->length()) {
4619  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4620  ignore = 1;
4621  break;
4622  }
4623  }
4624  if (ignore == 0) {
4625  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4626  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4628  }
4629  }
4630  }
4631 
4632  closedir(plugdir);
4633 }
4634 
4639 void cleanupPlugins(void) {
4640  for (crossfire_plugin *cp : plugins_list) {
4641  if (cp->closefunc)
4642  cp->closefunc();
4643  /* Don't actually unload plugins, it makes backtraces for memory
4644  * debugging (printed at exit) messed up. And it doesn't matter if we
4645  * don't free it here. The OS will do it for us.
4646  */
4647  /* plugins_dlclose(cp->libptr); */
4648  free(cp);
4649  }
4650  plugins_list.clear();
4651 }
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:175
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:3823
cfapi_object_clean_object
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.cpp:3583
cfapi_object_forget_spell
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.cpp:3738
player::bed_y
int16_t bed_y
x,y - coordinates of respawn (savebed).
Definition: player.h:113
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:1438
CFAPI_SSTRING
#define CFAPI_SSTRING
Definition: plugin.h:70
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:3454
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:256
player::next
player * next
Pointer to next player, NULL if this is last.
Definition: player.h:108
cftimer_find_free_id
int cftimer_find_free_id(void)
Finds a free ID for a new timer.
Definition: timers.cpp:144
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:1469
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:250
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:3510
cfapi_object_delete
static void cfapi_object_delete(int *type,...)
Definition: plugins.cpp:3248
cfapi_player_quest
static void cfapi_player_quest(int *type,...)
Quest-related wrappers, for all quest-related operations.
Definition: plugins.cpp:4485
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:274
cfapi_archetype_get_property
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.cpp:4213
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:855
monster_npc_say
void monster_npc_say(object *npc, const char *cp)
Simple function to have some NPC say something.
Definition: monster.cpp:2606
CFAPI_MAP_PROP_RESET_TIME
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:252
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:369
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:253
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:282
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:107
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:3959
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:1780
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:371
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:280
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:266
AssetsManager.h
CFAPI_MAP_PROP_NEXT
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:264
NR_OF_HOOKS
#define NR_OF_HOOKS
Number of hooked functions a plugin can call.
Definition: plugins.cpp:50
ServerSettings::disabled_plugins
std::vector< std::string > disabled_plugins
List of disabled plugins, 'All' means all.
Definition: server.h:16
do_learn_spell
void do_learn_spell(object *op, object *spell, int special_prayer)
Actually makes op learn spell.
Definition: apply.cpp:146
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
If set, don't check plugin version.
Definition: global.h:329
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:214
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:470
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:2151
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:1309
Settings::datadir
const char * datadir
Read only data files.
Definition: global.h:253
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:113
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:339
CFAPI_PLAYER_PROP_COUNT
#define CFAPI_PLAYER_PROP_COUNT
Definition: plugin.h:240
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:357
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:322
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:179
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:1564
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:216
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:3307
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:3140
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:723
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:409
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
UP_OBJ_INSERT
#define UP_OBJ_INSERT
Object was inserted.
Definition: object.h:530
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:273
mapstruct::height
uint16_t height
Width and height of map.
Definition: map.h:342
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:168
cfapi_object_find_archetype_inside
static void cfapi_object_find_archetype_inside(int *type,...)
Kinda wrapper for arch__present_in_ob().
Definition: plugins.cpp:3887
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:290
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:2963
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:269
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:1599
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:112
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:3998
CFAPI_REGION_PROP_PARENT
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:281
plugin.h
CFAPI_OBJECT_PROP_ENVIRONMENT
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h: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:280
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:671
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:289
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:286
CFAPI_MAP_PROP_WIDTH
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:257
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:268
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:266
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:259
mapstruct::path
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:361
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:357
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:4591
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:4396
buf
StringBuffer * buf
Definition: readable.cpp:1564
getManager
AssetsManager * getManager()
Definition: assets.cpp:309
cfapi_object_identify
static void cfapi_object_identify(int *type,...)
Wrapper for identify().
Definition: plugins.cpp:3098
cfapi_map_set_map_property
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.cpp:1279
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:4461
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:259
cfapi_object_update
static void cfapi_object_update(int *type,...)
Wrapper for object_update().
Definition: plugins.cpp:3531
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:342
FLAG_REMOVED
#define FLAG_REMOVED
Object is not in any map or invenory.
Definition: define.h:219
cfapi_object_change_abil
static void cfapi_object_change_abil(int *type,...)
Wrapper for change_abil().
Definition: plugins.cpp:3983
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:286
socket_struct::update_look
uint32_t update_look
If true, we need to send the look window.
Definition: newserver.h:109
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:1519
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:265
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
MOVE_ALL
#define MOVE_ALL
Mask of all movement types.
Definition: define.h:389
cfapi_register_command
static void cfapi_register_command(int *type,...)
Definition: plugins.cpp:4536
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
FLAG_FREED
#define FLAG_FREED
Object is in the list of free objects.
Definition: define.h:220
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:4027
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:270
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
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:358
cfapi_player_can_pay
static void cfapi_player_can_pay(int *type,...)
Wrapper for can_pay().
Definition: plugins.cpp:4110
CFAPI_MAP_PROP_WPARTY
#define CFAPI_MAP_PROP_WPARTY
Definition: plugin.h:262
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
FLAG_NO_DROP
#define FLAG_NO_DROP
Object can't be dropped.
Definition: define.h:275
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:1120
cfapi_map_message
static void cfapi_map_message(int *type,...)
Definition: plugins.cpp:1360
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:3053
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:4420
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:593
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
Definition: object.h:545
cfapi_object_remove_depletion
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.cpp:3158
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:285
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:678
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:263
Face::number
uint16_t number
This is the image unique identifier.
Definition: face.h:15
socket_struct::client
sstring client
Client string sent by client.
Definition: newserver.h:105
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:4268
object::weight_limit
int32_t weight_limit
Weight-limit of object.
Definition: object.h:376
add_string
sstring add_string(const char *str)
Share a string.
Definition: shstr.cpp:137
cfapi_object_check_spell
static void cfapi_object_check_spell(int *type,...)
Wrapper for check_spell_known().
Definition: plugins.cpp:3758
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:2382
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:281
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:3569
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:288
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:2027
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
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:2327
region::jailmap
char * jailmap
Where a player that is arrested in this region should be imprisoned.
Definition: map.h:292
find_string
sstring find_string(const char *str)
Searches a string in the shared strings.
Definition: shstr.cpp:250
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:3227
object_update_speed
void object_update_speed(object *op)
Updates the speed of an object.
Definition: object.cpp:1334
mapstruct::wpartx
int wpartx
Definition: map.h:351
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:210
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:272
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:164
CFAPI_OBJECT_PROP_SPEED
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:140
CFAPI_OBJECT_PROP_TYPE
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:145
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:733
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:249
cfapi_object_transmute
static void cfapi_object_transmute(int *type,...)
Definition: plugins.cpp:3210
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:4323
cfapi_unregister_command
static void cfapi_unregister_command(int *type,...)
Definition: plugins.cpp:4571
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:661
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:4178
P_NEED_UPDATE
#define P_NEED_UPDATE
This space is out of date.
Definition: map.h:244
CFAPI_PLAYER_QUEST_START
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:242
CFAPI_REGION_PROP_NAME
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:279
cfapi_object_spring_trap
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.cpp:3610
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:288
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
P_OUT_OF_MAP
#define P_OUT_OF_MAP
This space is outside the map.
Definition: map.h:254
CFAPI_REGION_PROP_JAIL_X
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:284
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:3799
Settings::confdir
const char * confdir
Configuration files.
Definition: global.h:252
sproto.h
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:2355
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:319
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:1708
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:4197
CFAPI_SYSTEM_REGIONS
#define CFAPI_SYSTEM_REGIONS
Definition: plugin.h:291
cfapi_object_on_same_map
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.cpp:3594
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:275
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:155
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:251
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
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:953
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:294
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:283
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:255
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp:282
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:215
living::Wis
int8_t Wis
Definition: living.h:36
CFAPI_MAP_PROP_FLAGS
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:247
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:279
CFAPI_MAP_PROP_DARKNESS
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:256
CFAPI_MAP_PROP_PLAYERS
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:254
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:236
cfapi_map_delete_map
static void cfapi_map_delete_map(int *type,...)
Definition: plugins.cpp:1347
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:277
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:243
CFAPI_MAP_PROP_DIFFICULTY
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:248
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:268
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:3118
cfapi_object_give_skill
static void cfapi_object_give_skill(int *type,...)
Definition: plugins.cpp:3193
cfapi_generate_random_map
static void cfapi_generate_random_map(int *type,...)
Wrapper for generate_random_map().
Definition: plugins.cpp:4442
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:3177
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:293
cleanupPlugins
void cleanupPlugins(void)
Call the crossfire_plugin::closefunc on the various plugins, used at server shutdown.
Definition: plugins.cpp:4639
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:244
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:1234
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:328
mapstruct
This is a game-map.
Definition: map.h:320
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:4087
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:440
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:323
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:3922
mapstruct::enter_x
int16_t enter_x
Definition: map.h:343
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:2632
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:370
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:778
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:3346
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:1331
CFAPI_OBJECT_PROP_OTHER_ARCH
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:182
UP_OBJ_FACE
#define UP_OBJ_FACE
Only thing that changed was the face.
Definition: object.h:533
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:1562
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:205
mapstruct::msg
char * msg
Message map creator may have left.
Definition: map.h:357
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:124
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:260
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:687
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:4042
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
mapstruct::wparty
int wparty
Highly fasten conversion between worldmap and weathermap.
Definition: map.h:351
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:271
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:292
CFAPI_MAP_PROP_WPARTX
#define CFAPI_MAP_PROP_WPARTX
Definition: plugin.h:261
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:274
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:290
do_forget_spell
void do_forget_spell(object *op, const char *spell)
Erases spell from player's inventory.
Definition: apply.cpp:187
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:343
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:1541
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:3778
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:258
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:333
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:1929
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
FLAG_WAS_WIZ
#define FLAG_WAS_WIZ
Player was once a wiz.
Definition: define.h:221
player::socket
socket_struct * socket
Socket information for this player.
Definition: player.h:109
mapstruct::next
mapstruct * next
Next map, linked list.
Definition: map.h:321
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2736
cfapi_object_apply
static void cfapi_object_apply(int *type,...)
Applies an object.
Definition: plugins.cpp:3073
mapstruct::reset_time
uint32_t reset_time
Server time when map gets reset, seconds since epoch.
Definition: map.h:327
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:691
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:4068
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:260
cfapi_player_knowledge
static void cfapi_player_knowledge(int *type,...)
Wrapper for knowledge-related functions().
Definition: plugins.cpp:4129
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:245
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:1382
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:341
cfapi_object_cast
static void cfapi_object_cast(int *type,...)
Wrapper for query_money().
Definition: plugins.cpp:3695
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:402
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:3676
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:1472
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:654
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_PLAYER_PROP_CLIENT
#define CFAPI_PLAYER_PROP_CLIENT
Definition: plugin.h:239
CFAPI_PARTY_PROP_PASSWORD
#define CFAPI_PARTY_PROP_PASSWORD
Definition: plugin.h:276
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:3487
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:3275
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:3723
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:293
cfapi_map_trigger_connected
static void cfapi_map_trigger_connected(int *type,...)
Wrapper for trigger_connected().
Definition: plugins.cpp:3656
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:3938
region::jailx
int16_t jailx
Definition: map.h:293
cfapi_object_set_property
static void cfapi_object_set_property(int *type,...)
Sets the property of an object.
Definition: plugins.cpp:2399
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:258
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:667
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:1411
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:233
cfapi_object_check_trigger
static void cfapi_object_check_trigger(int *type,...)
Wrapper for check_trigger().
Definition: plugins.cpp:3629
cfapi_object_clear
static void cfapi_object_clear(int *type,...)
Wrapper for object_clear().
Definition: plugins.cpp:3551
identify
object * identify(object *op)
Identifies an item.
Definition: item.cpp:1444
Settings::localdir
const char * localdir
Read/write data files.
Definition: global.h:254