Crossfire Server, Trunk  1.75.0
plugins.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
22 #if 0
23 
24 #define PLUGIN_DEBUG
25 #endif
26 
27 /*****************************************************************************/
28 /* First, the headers. We only include plugin.h, because all other includes */
29 /* are done into it, and plugproto.h (which is used only by this file). */
30 /*****************************************************************************/
31 
32 #include <assert.h>
33 #include <stdlib.h>
34 #include <string.h>
35 
36 #include "plugin.h"
37 #include "shop.h"
38 #include "sproto.h"
39 #include "svnversion.h"
40 #include "timers.h"
41 #include "assets.h"
42 #include "AssetsManager.h"
43 #include "server.h"
44 
45 #ifdef WIN32
46 #include "libloaderapi.h"
47 #endif
48 
50 #define NR_OF_HOOKS (sizeof(plug_hooks)/sizeof(*plug_hooks))
51 
52 static void cfapi_cost_string_from_value(int *type, ...);
53 static void cfapi_system_find_animation(int *type, ...);
54 static void cfapi_system_find_face(int *type, ...);
55 static void cfapi_system_strdup_local(int *type, ...);
56 static void cfapi_system_register_global_event(int *type, ...);
57 static void cfapi_system_unregister_global_event(int *type, ...);
58 static void cfapi_system_add_string(int *type, ...);
59 static void cfapi_system_remove_string(int *type, ...);
60 static void cfapi_system_find_string(int *type, ...);
61 static void cfapi_system_check_path(int *type, ...);
62 static void cfapi_system_re_cmp(int *type, ...);
63 static void cfapi_system_directory(int *type, ...);
64 static void cfapi_get_time(int *type, ...);
65 static void cfapi_get_season_name(int *type, ...);
66 static void cfapi_get_weekday_name(int *type, ...);
67 static void cfapi_get_month_name(int *type, ...);
68 static void cfapi_get_periodofday_name(int *type, ...);
69 static void cfapi_timer_create(int *type, ...);
70 static void cfapi_timer_destroy(int *type, ...);
71 static void cfapi_log(int *type, ...);
72 static void cfapi_map_get_map(int *type, ...);
73 static void cfapi_map_has_been_loaded(int *type, ...);
74 static void cfapi_map_create_path(int *type, ...);
75 static void cfapi_map_get_map_property(int *type, ...);
76 static void cfapi_map_set_map_property(int *type, ...);
77 static void cfapi_map_out_of_map(int *type, ...);
78 static void cfapi_map_update_position(int *type, ...);
79 static void cfapi_map_delete_map(int *type, ...);
80 static void cfapi_map_message(int *type, ...);
81 static void cfapi_map_get_object_at(int *type, ...);
82 static void cfapi_map_find_by_archetype_name(int *type, ...);
83 static void cfapi_map_change_light(int *type, ...);
84 static void cfapi_object_move(int *type, ...);
85 static void cfapi_object_get_key(int *type, ...);
86 static void cfapi_object_set_key(int *type, ...);
87 static void cfapi_object_get_property(int *type, ...);
88 static void cfapi_object_set_property(int *type, ...);
89 static void cfapi_object_apply_below(int *type, ...);
90 static void cfapi_object_apply(int *type, ...);
91 static void cfapi_object_identify(int *type, ...);
92 static void cfapi_object_describe(int *type, ...);
93 static void cfapi_object_drain(int *type, ...);
94 static void cfapi_object_remove_depletion(int *type, ...);
95 static void cfapi_object_fix(int *type, ...);
96 static void cfapi_object_give_skill(int *type, ...);
97 static void cfapi_object_transmute(int *type, ...);
98 static void cfapi_object_remove(int *type, ...);
99 static void cfapi_object_delete(int *type, ...);
100 static void cfapi_object_clone(int *type, ...);
101 static void cfapi_object_create(int *type, ...);
102 static void cfapi_object_insert(int *type, ...);
103 static void cfapi_object_split(int *type, ...);
104 static void cfapi_object_merge(int *type, ...);
105 static void cfapi_object_distance(int *type, ...);
106 static void cfapi_object_update(int *type, ...);
107 static void cfapi_object_clear(int *type, ...);
108 static void cfapi_object_reset(int *type, ...);
109 static void cfapi_object_clean_object(int *type, ...);
110 static void cfapi_object_on_same_map(int *type, ...);
111 static void cfapi_object_spring_trap(int *type, ...);
112 static void cfapi_object_check_trigger(int *type, ...);
113 static void cfapi_map_trigger_connected(int *type, ...);
114 static void cfapi_object_query_money(int *type, ...);
115 static void cfapi_object_cast(int *type, ...);
116 static void cfapi_object_learn_spell(int *type, ...);
117 static void cfapi_object_forget_spell(int *type, ...);
118 static void cfapi_object_check_spell(int *type, ...);
119 static void cfapi_object_pay_amount(int *type, ...);
120 static void cfapi_object_pay_item(int *type, ...);
121 static void cfapi_object_transfer(int *type, ...);
122 static void cfapi_object_find_archetype_inside(int *type, ...);
123 static void cfapi_object_find_by_arch_name(int *type, ...);
124 static void cfapi_object_find_by_name(int *type, ...);
125 static void cfapi_object_drop(int *type, ...);
126 static void cfapi_object_change_abil(int *type, ...);
127 static void cfapi_object_say(int *type, ...);
128 static void cfapi_player_find(int *type, ...);
129 static void cfapi_player_message(int *type, ...);
130 static void cfapi_object_change_exp(int *type, ...);
131 static void cfapi_player_can_pay(int *type, ...);
132 static void cfapi_player_knowledge(int *type, ...);
133 static void cfapi_object_teleport(int *type, ...);
134 static void cfapi_object_pickup(int *type, ...);
135 static void cfapi_archetype_get_property(int *type, ...);
136 static void cfapi_party_get_property(int *type, ...);
137 static void cfapi_region_get_property(int *type, ...);
138 static void cfapi_friendlylist_get_next(int *type, ...);
139 static void cfapi_set_random_map_variable(int *type, ...);
140 static void cfapi_generate_random_map(int *type, ...);
141 static void cfapi_object_user_event(int *type, ...);
142 static void cfapi_player_quest(int *type, ...);
143 static void cfapi_object_perm_exp(int *type, ...);
144 static void cfapi_register_command(int *type, ...);
145 static void cfapi_unregister_command(int *type, ...);
146 static void cfapi_system_get_object_vector(int *type, ...);
147 static void cfapi_system_get_map_vector(int *type, ...);
148 static void cfapi_system_get_archetype_vector(int *type, ...);
149 static void cfapi_system_get_party_vector(int *type, ...);
150 static void cfapi_system_get_region_vector(int *type, ...);
151 
155 static const hook_entry plug_hooks[] = {
156  { cfapi_system_add_string, 0, "cfapi_system_add_string" },
157  { cfapi_system_register_global_event, 1, "cfapi_system_register_global_event" },
158  { cfapi_system_remove_string, 2, "cfapi_system_remove_string" },
159  { cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event" },
160  { cfapi_system_check_path, 4, "cfapi_system_check_path" },
161  { cfapi_system_re_cmp, 5, "cfapi_system_re_cmp" },
162  { cfapi_system_strdup_local, 6, "cfapi_system_strdup_local" },
163  { cfapi_system_directory, 7, "cfapi_system_directory" },
164  { cfapi_system_find_animation, 8, "cfapi_system_find_animation" },
165  { cfapi_object_clean_object, 9, "cfapi_object_clean_object" },
166  { cfapi_object_on_same_map, 10, "cfapi_object_on_same_map" },
167  { cfapi_object_get_key, 11, "cfapi_object_get_key" },
168  { cfapi_object_set_key, 12, "cfapi_object_set_key" },
169  { cfapi_object_get_property, 13, "cfapi_object_get_property" },
170  { cfapi_object_set_property, 14, "cfapi_object_set_property" },
171  { cfapi_object_apply, 15, "cfapi_object_apply" },
172  { cfapi_object_identify, 16, "cfapi_object_identify" },
173  { cfapi_object_describe, 17, "cfapi_object_describe" },
174  { cfapi_object_drain, 18, "cfapi_object_drain" },
175  { cfapi_object_fix, 19, "cfapi_object_fix" },
176  { cfapi_object_give_skill, 20, "cfapi_object_give_skill" },
177  { cfapi_object_transmute, 21, "cfapi_object_transmute" },
178  { cfapi_object_remove, 22, "cfapi_object_remove" },
179  { cfapi_object_delete, 23, "cfapi_object_delete" },
180  { cfapi_object_clone, 24, "cfapi_object_clone" },
181  { cfapi_object_create, 26, "cfapi_object_create" },
182  { cfapi_object_insert, 27, "cfapi_object_insert" },
183  { cfapi_object_split, 28, "cfapi_object_split" },
184  { cfapi_object_merge, 29, "cfapi_object_merge" },
185  { cfapi_object_distance, 30, "cfapi_object_distance" },
186  { cfapi_object_update, 31, "cfapi_object_update" },
187  { cfapi_object_clear, 32, "cfapi_object_clear" },
188  { cfapi_object_reset, 33, "cfapi_object_reset" },
189  { cfapi_object_spring_trap, 35, "cfapi_object_spring_trap" },
190  { cfapi_object_check_trigger, 36, "cfapi_object_check_trigger" },
191  { cfapi_object_query_money, 38, "cfapi_object_query_money" },
192  { cfapi_object_cast, 39, "cfapi_object_cast" },
193  { cfapi_object_learn_spell, 40, "cfapi_object_learn_spell" },
194  { cfapi_object_forget_spell, 41, "cfapi_object_forget_spell" },
195  { cfapi_object_check_spell, 42, "cfapi_object_check_spell" },
196  { cfapi_object_pay_amount, 43, "cfapi_object_pay_amount" },
197  { cfapi_object_pay_item, 44, "cfapi_object_pay_item" },
198  { cfapi_object_transfer, 45, "cfapi_object_transfer" },
199  { cfapi_object_drop, 46, "cfapi_object_drop" },
200  { cfapi_object_change_abil, 47, "cfapi_object_change_abil" },
201  { cfapi_object_find_archetype_inside, 48, "cfapi_object_find_archetype_inside" },
202  { cfapi_object_say, 49, "cfapi_object_say" },
203  { cfapi_map_get_map, 50, "cfapi_map_get_map" },
204  { cfapi_map_has_been_loaded, 51, "cfapi_map_has_been_loaded" },
205  { cfapi_map_create_path, 52, "cfapi_map_create_path" },
206  { cfapi_map_get_map_property, 53, "cfapi_map_get_property" },
207  { cfapi_map_set_map_property, 54, "cfapi_map_set_property" },
208  { cfapi_map_out_of_map, 55, "cfapi_map_out_of_map" },
209  { cfapi_map_update_position, 56, "cfapi_map_update_position" },
210  { cfapi_map_delete_map, 57, "cfapi_map_delete_map" },
211  { cfapi_map_message, 58, "cfapi_map_message" },
212  { cfapi_map_get_object_at, 59, "cfapi_map_get_object_at" },
213  { cfapi_map_change_light, 60, "cfapi_map_change_light" },
214  { cfapi_map_find_by_archetype_name, 61, "cfapi_map_find_by_archetype_name" },
215  { cfapi_player_find, 62, "cfapi_player_find" },
216  { cfapi_player_message, 63, "cfapi_player_message" },
217  { cfapi_object_change_exp, 64, "cfapi_object_change_exp" },
218  { cfapi_object_teleport, 65, "cfapi_object_teleport" },
219  { cfapi_object_pickup, 67, "cfapi_object_pickup" },
220  { cfapi_object_move, 68, "cfapi_object_move" },
221  { cfapi_object_apply_below, 69, "cfapi_object_apply_below" },
222  { cfapi_generate_random_map, 70, "cfapi_generate_random_map" },
223  { cfapi_archetype_get_property, 71, "cfapi_archetype_get_property" },
224  { cfapi_party_get_property, 72, "cfapi_party_get_property" },
225  { cfapi_region_get_property, 73, "cfapi_region_get_property" },
226  { cfapi_player_can_pay, 74, "cfapi_player_can_pay" },
227  { cfapi_log, 75, "cfapi_log" },
228  { cfapi_get_time, 76, "cfapi_system_get_time" },
229  { cfapi_timer_create, 77, "cfapi_system_timer_create" },
230  { cfapi_timer_destroy, 78, "cfapi_system_timer_destroy" },
231  { cfapi_friendlylist_get_next, 79, "cfapi_friendlylist_get_next" },
232  { cfapi_set_random_map_variable, 80, "cfapi_set_random_map_variable" },
233  { cfapi_system_find_face, 81, "cfapi_system_find_face" },
234  { cfapi_get_season_name, 82, "cfapi_system_get_season_name" },
235  { cfapi_get_month_name, 83, "cfapi_system_get_month_name" },
236  { cfapi_get_weekday_name, 84, "cfapi_system_get_weekday_name" },
237  { cfapi_get_periodofday_name, 85, "cfapi_system_get_periodofday_name" },
238  { cfapi_map_trigger_connected, 86, "cfapi_map_trigger_connected" },
239  { cfapi_object_user_event, 87, "cfapi_object_user_event" },
240  { cfapi_system_find_string, 88, "cfapi_system_find_string" },
241  { cfapi_cost_string_from_value, 90, "cfapi_cost_string_from_value" },
242  { cfapi_player_quest, 91, "cfapi_player_quest" },
243  { cfapi_object_remove_depletion, 92, "cfapi_object_remove_depletion" },
244  { cfapi_object_find_by_arch_name, 93, "cfapi_object_find_by_arch_name" },
245  { cfapi_object_find_by_name, 94, "cfapi_object_find_by_name" },
246  { cfapi_player_knowledge, 95, "cfapi_player_knowledge" },
247  { cfapi_object_perm_exp, 96, "cfapi_object_perm_exp" },
248  { cfapi_register_command, 97, "cfapi_register_command" },
249  { cfapi_unregister_command, 98, "cfapi_unregister_command" },
250  { cfapi_system_get_object_vector, 99, "cfapi_get_object_vector" },
251  { cfapi_system_get_map_vector, 100, "cfapi_get_map_vector" },
252  { cfapi_system_get_archetype_vector, 101, "cfapi_get_archetype_vector" },
253  { cfapi_system_get_party_vector, 102, "cfapi_get_party_vector" },
254  { cfapi_system_get_region_vector, 103, "cfapi_get_region_vector" },
255 };
256 
258 std::vector<crossfire_plugin *> plugins_list;
259 
260 /*****************************************************************************/
261 /* NEW PLUGIN STUFF STARTS HERE */
262 /*****************************************************************************/
263 
269 static crossfire_plugin *plugins_find_plugin(const char *id) {
270  for (crossfire_plugin *plugin : plugins_list) {
271  if (!strcmp(id, plugin->id)) {
272  return plugin;
273  }
274  }
275  return NULL;
276 }
277 
278 #ifdef WIN32
279 static const char *plugins_dlerror(void)
280 {
281  static char buf[256];
282  DWORD err;
283  char *p;
284 
285  err = GetLastError();
286  if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof (buf), NULL) == 0)
287  snprintf(buf, sizeof (buf), "error %lu", err);
288  p = strchr(buf, '\0');
289  while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
290  p--;
291  *p = '\0';
292  return buf;
293 }
294 
295 #endif /* WIN32 */
296 
302 static void send_changed_object(object *op) {
303  object *tmp;
304  player *pl;
305 
306  if (op->env != NULL) {
307  tmp = object_get_player_container(op->env);
308  if (!tmp) {
309  for (pl = first_player; pl; pl = pl->next)
310  if (pl->ob->container == op->env)
311  break;
312  if (pl)
313  tmp = pl->ob;
314  else
315  tmp = NULL;
316  }
317  if (tmp)
318  /* We don't know what changed, so we send everything. */
319  esrv_update_item(UPD_ALL, tmp, op);
320  } else {
321  FOR_ABOVE_PREPARE(op, tmp)
322  if (tmp->type == PLAYER)
323  tmp->contr->socket->update_look = 1;
325  }
326 }
327 
328 static void cfapi_get_hooks(int *type, ...) {
329  va_list args;
330  int request_type;
331  char *buf;
332  f_plug_api *rapi;
333 
334  *type = CFAPI_NONE;
335 
336  va_start(args, type);
337  request_type = va_arg(args, int);
338  if (request_type == 0) { /* By nr */
339  size_t fid;
340 
341  fid = va_arg(args, int);
342  rapi = va_arg(args, f_plug_api *);
343  if (fid >= NR_OF_HOOKS) {
344  *rapi = NULL;
345  *type = CFAPI_NONE;
346  } else {
347  *rapi = plug_hooks[fid].func;
348  *type = CFAPI_FUNC;
349  }
350  } else { /* by name */
351  size_t i;
352 
353  buf = va_arg(args, char *);
354  rapi = va_arg(args, f_plug_api *);
355  *rapi = NULL;
356  *type = CFAPI_NONE;
357  for (i = 0; i < NR_OF_HOOKS; i++) {
358  if (!strcmp(buf, plug_hooks[i].fname)) {
359  *rapi = plug_hooks[i].func;
360  *type = CFAPI_FUNC;
361  break;
362  }
363  }
364  }
365  va_end(args);
366 }
367 
374 int plugins_init_plugin(const char *libfile) {
375  LIBPTRTYPE ptr;
376  f_plug_init initfunc;
377  f_plug_property propfunc;
378  f_plug_event eventfunc;
379  f_plug_postinit postfunc;
380  f_plug_postinit closefunc;
381  int i;
382  crossfire_plugin *cp;
383  char *svn_rev;
384 
385 
386  /* Open the plugin lib and load the required functions */
387  ptr = plugins_dlopen(libfile);
388  if (ptr == NULL) {
389  LOG(llevError, "Error trying to load %s: %s\n", libfile, plugins_dlerror());
390  return -1;
391  }
392  svn_rev = (char*) plugins_dlsym(ptr, "SvnRevPlugin");
393  if (svn_rev == NULL) {
394  LOG(llevError, "Unable to find SvnRevPlugin in %s\n", libfile);
395  plugins_dlclose(ptr);
396  return -1;
397  }
398  if (settings.ignore_plugin_compatibility == 0 && strcmp(svn_rev, SVN_REV)) {
399  LOG(llevError, "Version mismatch in in %s (%s != %s)\n", libfile, svn_rev, SVN_REV);
400  plugins_dlclose(ptr);
401  return -1;
402  }
403 
404  initfunc = (f_plug_init)plugins_dlsym(ptr, "initPlugin");
405  if (initfunc == NULL) {
406  LOG(llevError, "Plugin error while requesting %s.initPlugin: %s\n", libfile, plugins_dlerror());
407  plugins_dlclose(ptr);
408  return -1;
409  }
410  propfunc = (f_plug_property)plugins_dlsym(ptr, "getPluginProperty");
411  if (propfunc == NULL) {
412  LOG(llevError, "Plugin error while requesting %s.getPluginProperty: %s\n", libfile, plugins_dlerror());
413  plugins_dlclose(ptr);
414  return -1;
415  }
416  eventfunc = (f_plug_event)plugins_dlsym(ptr, "eventListener");
417  if (eventfunc == NULL) {
418  LOG(llevError, "Plugin error while requesting %s.eventListener: %s\n", libfile, plugins_dlerror());
419  plugins_dlclose(ptr);
420  return -1;
421  }
422  postfunc = (f_plug_postinit)plugins_dlsym(ptr, "postInitPlugin");
423  if (postfunc == NULL) {
424  LOG(llevError, "Plugin error while requesting %s.postInitPlugin: %s\n", libfile, plugins_dlerror());
425  plugins_dlclose(ptr);
426  return -1;
427  }
428  closefunc = (f_plug_postinit)plugins_dlsym(ptr, "closePlugin");
429  if (closefunc == NULL) {
430  LOG(llevError, "Plugin error while requesting %s.closePlugin: %s\n", libfile, plugins_dlerror());
431  plugins_dlclose(ptr);
432  return -1;
433  }
434  i = initfunc("2.0", cfapi_get_hooks);
435  cp = static_cast<crossfire_plugin *>(malloc(sizeof(crossfire_plugin)));
436  for (i = 0; i < NR_EVENTS; i++)
437  cp->global_registration[i] = 0;
438  cp->propfunc = propfunc;
439  cp->closefunc = closefunc;
440  cp->libptr = ptr;
441  propfunc(&i, "Identification", cp->id, sizeof(cp->id));
442  propfunc(&i, "FullName", cp->fullname, sizeof(cp->fullname));
443  events_register_object_handler(cp->id, eventfunc);
444  plugins_list.push_back(cp);
445  postfunc();
446  return 0;
447 }
448 
455 int plugins_remove_plugin(const char *id) {
456  auto plugin = std::find_if(plugins_list.begin(), plugins_list.end(), [&id] (const auto cp) { return strcmp(id, cp->id) == 0; });
457  if (plugin != plugins_list.end()) {
458  crossfire_plugin *cp = *plugin;
459  plugins_list.erase(plugin);
460  for (int eventcode = 0; eventcode < NR_EVENTS; eventcode++) {
461  if (cp->global_registration[eventcode]) {
462  events_unregister_global_handler(eventcode, cp->global_registration[eventcode]);
463  }
464  }
466  if (cp->closefunc)
467  cp->closefunc();
468  plugins_dlclose(cp->libptr);
469  free(cp);
470  return 0;
471  }
472  return -1;
473 }
474 
480 void plugins_display_list(object *op) {
482  "List of loaded plugins:\n-----------------------");
483 
484  for (crossfire_plugin *cp : plugins_list) {
486  "%s, %s",
487  cp->id, cp->fullname);
488  }
489 }
490 
491 /* SYSTEM-RELATED HOOKS */
492 
498 static void cfapi_cost_string_from_value(int *type, ...) {
499  uint64_t cost;
500  char *buffer, *final;
501  int length, largest_coin;
502  va_list args;
503 
504  va_start(args, type);
505  cost = va_arg(args, uint64_t);
506  largest_coin = va_arg(args, int);
507  buffer = va_arg(args, char*);
508  length = va_arg(args, int);
509  va_end(args);
510 
511  *type = CFAPI_NONE;
512 
513  if (length < 1)
514  return;
515 
516  final = cost_string_from_value(cost, largest_coin);
517 
518  strncpy(buffer, final, length - 1);
519  buffer[length - 1] = '\0';
520  free(final);
521 }
522 
528 static void cfapi_system_find_animation(int *type, ...) {
529  va_list args;
530  const char *name;
531  int *num;
532  const Animations *anim;
533 
534  va_start(args, type);
535  name = va_arg(args, const char *);
536  num = va_arg(args, int *);
537  va_end(args);
538 
539  anim = try_find_animation(name);
540  (*num) = anim ? anim->num : 0;
541  *type = CFAPI_INT;
542 }
543 
549 static void cfapi_system_find_face(int *type, ...) {
550  va_list args;
551  const char *face;
552  int error;
553  int *num;
554  const Face *f;
555 
556  va_start(args, type);
557  face = va_arg(args, const char *);
558  error = va_arg(args, int);
559  num = va_arg(args, int *);
560  va_end(args);
561 
562  f = try_find_face(face, get_face_by_id(error));
563  (*num) = f ? f->number : 0;
564  *type = CFAPI_INT;
565 }
566 
572 static void cfapi_system_strdup_local(int *type, ...) {
573  va_list args;
574  const char *txt;
575  char **ret;
576 
577  va_start(args, type);
578  txt = va_arg(args, const char *);
579  ret = va_arg(args, char **);
580  va_end(args);
581 
582  *ret = strdup_local(txt);
583  *type = CFAPI_STRING;
584 }
585 
586 static void cfapi_system_register_global_event(int *type, ...) {
587  va_list args;
588  int eventcode;
589  char *pname;
590  f_plug_event hook;
591  crossfire_plugin *cp;
592 
593  va_start(args, type);
594  eventcode = va_arg(args, int);
595  pname = va_arg(args, char *);
596  hook = va_arg(args, f_plug_event);
597  va_end(args);
598 
599  *type = CFAPI_NONE;
600 
601  cp = plugins_find_plugin(pname);
602  if (!cp->global_registration[eventcode]) {
603  cp->global_registration[eventcode] = events_register_global_handler(eventcode, hook);
604  }
605 }
606 
608  va_list args;
609  int eventcode;
610  char *pname;
611  crossfire_plugin *cp;
612 
613  va_start(args, type);
614  eventcode = va_arg(args, int);
615  pname = va_arg(args, char *);
616  va_end(args);
617 
618  *type = CFAPI_NONE;
619 
620  cp = plugins_find_plugin(pname);
621  if (cp->global_registration[eventcode]) {
622  events_unregister_global_handler(eventcode, cp->global_registration[eventcode]);
623  cp->global_registration[eventcode] = 0;
624  }
625 }
626 
627 static void cfapi_system_get_object_vector(int *type, ...) {
628  va_list args;
629  va_start(args, type);
630  int property = va_arg(args, int);
631  std::vector<object *> *list = va_arg(args, std::vector<object *> *);
632 
634  switch (property) {
636  for (auto pl = first_player; pl ; pl = pl->next) {
637  list->push_back(pl->ob);
638  }
639  break;
641  auto f = get_next_friend(nullptr);
642  while (f) {
643  list->push_back(f);
644  f = get_next_friend(f);
645  }
646  break;
647  }
648  default:
649  assert(0);
650  }
651 
652  va_end(args);
653 }
654 
655 static void cfapi_system_get_map_vector(int *type, ...) {
656  va_list args;
657  va_start(args, type);
658  int property = va_arg(args, int);
659  std::vector<mapstruct *> *list = va_arg(args, std::vector<mapstruct *> *);
660 
662  if (property == CFAPI_SYSTEM_MAPS) {
663  for (auto map = first_map; map ; map = map->next) {
664  list->push_back(map);
665  }
666  }
667 
668  va_end(args);
669 }
670 
671 static void cfapi_system_get_archetype_vector(int *type, ...) {
672  va_list args;
673  va_start(args, type);
674  int property = va_arg(args, int);
675  std::vector<archetype *> *list = va_arg(args, std::vector<archetype *> *);
676 
678  if (property == CFAPI_SYSTEM_ARCHETYPES) {
679  getManager()->archetypes()->each([&] (const auto &arch) { list->push_back(arch); });
680  }
681 
682  va_end(args);
683 }
684 
685 static void cfapi_system_get_region_vector(int *type, ...) {
686  va_list args;
687  va_start(args, type);
688  int property = va_arg(args, int);
689  std::vector<region *> *list = va_arg(args, std::vector<region *> *);
690 
692  if (property == CFAPI_SYSTEM_REGIONS) {
693  *list = all_regions;
694  }
695 
696  va_end(args);
697 }
698 
699 static void cfapi_system_get_party_vector(int *type, ...) {
700  va_list args;
701  va_start(args, type);
702  int property = va_arg(args, int);
703  std::vector<partylist *> *list = va_arg(args, std::vector<partylist *> *);
704 
706  if (property == CFAPI_SYSTEM_PARTIES) {
707  auto party = party_get_first();
708  while (party) {
709  list->push_back(party);
710  party = party_get_next(party);
711  }
712  }
713 
714  va_end(args);
715 }
716 
723 static void cfapi_system_add_string(int *type, ...) {
724  va_list args;
725  const char *str;
726  sstring *rv;
727 
728  va_start(args, type);
729  str = va_arg(args, const char *);
730  rv = va_arg(args, sstring *);
731  va_end(args);
732 
733  *rv = add_string(str);
734  *type = CFAPI_SSTRING;
735 }
736 
743 static void cfapi_system_remove_string(int *type, ...) {
744  va_list args;
745  sstring str;
746 
747  va_start(args, type);
748  str = va_arg(args, sstring);
749  va_end(args);
750 
751  free_string(str);
752  *type = CFAPI_NONE;
753 }
754 
761 static void cfapi_system_find_string(int *type, ...) {
762  va_list args;
763  const char *str;
764  sstring *rv;
765 
766  va_start(args, type);
767  str = va_arg(args, const char *);
768  rv = va_arg(args, sstring *);
769  va_end(args);
770 
771  *rv = find_string(str);
772  *type = CFAPI_SSTRING;
773 }
774 
780 static void cfapi_system_check_path(int *type, ...) {
781  va_list args;
782  const char *name;
783  int prepend_dir;
784  int *ret;
785 
786  va_start(args, type);
787 
788  name = va_arg(args, char *);
789  prepend_dir = va_arg(args, int);
790  ret = va_arg(args, int *);
791 
792  *ret = check_path(name, prepend_dir);
793 
794  va_end(args);
795  *type = CFAPI_INT;
796 }
797 
803 static void cfapi_system_re_cmp(int *type, ...) {
804  va_list args;
805  const char *str;
806  const char *regexp;
807  const char **rv;
808 
809  va_start(args, type);
810 
811  str = va_arg(args, char *);
812  regexp = va_arg(args, char *);
813  rv = va_arg(args, const char **);
814 
815  *rv = re_cmp(str, regexp);
816 
817  va_end(args);
818  *type = CFAPI_STRING;
819 }
820 
821 static void cfapi_system_directory(int *type, ...) {
822  va_list args;
823  int dirtype;
824  const char **str;
825 
826  va_start(args, type);
827 
828  dirtype = va_arg(args, int);
829  str = va_arg(args, const char **);
830  va_end(args);
831 
832  *type = CFAPI_STRING;
833 
834  switch (dirtype) {
835  case 0:
836  *str = settings.mapdir;
837  break;
838 
839  case 1:
840  *str = settings.uniquedir;
841  break;
842 
843  case 2:
844  *str = settings.tmpdir;
845  break;
846 
847  case 3:
848  *str = settings.confdir;
849  break;
850 
851  case 4:
852  *str = settings.localdir;
853  break;
854 
855  case 5:
856  *str = settings.playerdir;
857  break;
858 
859  case 6:
860  *str = settings.datadir;
861  break;
862 
863  default:
864  *str = NULL;
865  }
866 }
867 
874 static void cfapi_get_time(int *type, ...) {
875  va_list args;
876  timeofday_t *tod;
877 
878  va_start(args, type);
879  tod = va_arg(args, timeofday_t *);
880  va_end(args);
881 
882  get_tod(tod);
883  *type = CFAPI_NONE;
884 }
885 
886 #define string_get_int(name) \
887  va_list args; \
888  int index; \
889  const char **str; \
890  va_start(args, type); \
891  index = va_arg(args, int); \
892  str = va_arg(args, const char **); \
893  va_end(args); \
894  *str = name(index); \
895  *type = CFAPI_STRING; \
896 
897 
905 static void cfapi_get_season_name(int *type, ...) {
907 }
908 
917 static void cfapi_get_weekday_name(int *type, ...) {
919 }
920 
929 static void cfapi_get_month_name(int *type, ...) {
931 }
932 
941 static void cfapi_get_periodofday_name(int *type, ...) {
943 }
944 
956 static void cfapi_timer_create(int *type, ...) {
957  va_list args;
958  int res;
959  object *ob;
960  long delay;
961  int mode;
962  int *timer;
963 
964  va_start(args, type);
965  ob = va_arg(args, object *);
966  delay = va_arg(args, long);
967  mode = va_arg(args, int);
968  timer = va_arg(args, int *);
969  va_end(args);
970  *type = CFAPI_INT;
971 
972  *timer = cftimer_find_free_id();
973  if (*timer != TIMER_ERR_ID) {
974  res = cftimer_create(*timer, delay, ob, mode);
975  if (res != TIMER_ERR_NONE)
976  *timer = res;
977  }
978 }
979 
989 static void cfapi_timer_destroy(int *type, ...) {
990  va_list args;
991  int id;
992  int *err;
993 
994  va_start(args, type);
995  id = va_arg(args, int);
996  err = va_arg(args, int *);
997  va_end(args);
998  *type = CFAPI_INT;
999 
1000  *err = cftimer_destroy(id);
1001 }
1002 
1008 static void cfapi_log(int *type, ...) {
1009  va_list args;
1010  LogLevel logLevel;
1011  const char *message;
1012 
1013  va_start(args, type);
1014  logLevel = static_cast<LogLevel>(va_arg(args, int));
1015  message = va_arg(args, const char *);
1016  LOG(logLevel, "%s", message);
1017  va_end(args);
1018 
1019  *type = CFAPI_NONE;
1020 }
1021 
1022 /* MAP RELATED HOOKS */
1023 
1032 static void cfapi_map_get_map(int *type, ...) {
1033  va_list args;
1034  mapstruct **ret;
1035  int ctype;
1036  int x, y;
1037  int16_t nx, ny;
1038  const char *name;
1039  mapstruct *m;
1040 
1041  va_start(args, type);
1042 
1043  ctype = va_arg(args, int);
1044 
1045  switch (ctype) {
1046  case 0:
1047  x = va_arg(args, int);
1048  y = va_arg(args, int);
1049  ret = va_arg(args, mapstruct **);
1050  *ret = get_empty_map(x, y);
1051  break;
1052 
1053  case 1:
1054  name = va_arg(args, const char *);
1055  x = va_arg(args, int);
1056  ret = va_arg(args, mapstruct **);
1057  *ret = ready_map_name(name, x);
1058  break;
1059 
1060  case 2:
1061  m = va_arg(args, mapstruct *);
1062  nx = va_arg(args, int);
1063  ny = va_arg(args, int);
1064  ret = va_arg(args, mapstruct **);
1065  *ret = get_map_from_coord(m, &nx, &ny);
1066  break;
1067 
1068  default:
1069  *type = CFAPI_NONE;
1070  va_end(args);
1071  return;
1072  break;
1073  }
1074  va_end(args);
1075  *type = CFAPI_PMAP;
1076 }
1077 
1083 static void cfapi_map_has_been_loaded(int *type, ...) {
1084  va_list args;
1085  mapstruct **map;
1086  char *string;
1087 
1088  va_start(args, type);
1089  string = va_arg(args, char *);
1090  map = va_arg(args, mapstruct **);
1091  *map = has_been_loaded(string);
1092  va_end(args);
1093  *type = CFAPI_PMAP;
1094 }
1095 
1101 static void cfapi_map_create_path(int *type, ...) {
1102  va_list args;
1103  int ctype, size;
1104  const char *str;
1105  char *name;
1106 
1107  va_start(args, type);
1108 
1109  ctype = va_arg(args, int);
1110  str = va_arg(args, const char *);
1111  name = va_arg(args, char *);
1112  size = va_arg(args, int);
1113  *type = CFAPI_STRING;
1114 
1115  switch (ctype) {
1116  case 0:
1117  create_pathname(str, name, size);
1118  break;
1119 
1120  case 1:
1122  break;
1123 
1124 /* case 2:
1125  rv = create_items_path(str);
1126  break;*/
1127 
1128  default:
1129  *type = CFAPI_NONE;
1130  break;
1131  }
1132  va_end(args);
1133 }
1134 
1135 static void cfapi_map_get_map_property(int *type, ...) {
1136  va_list args;
1137  mapstruct *map;
1138  int property;
1139 
1140  int *rint;
1141  mapstruct **rmap;
1142  sstring *rstr;
1143  region **rreg;
1144  int16_t *nx, *ny;
1145  int x, y;
1146 
1147  va_start(args, type);
1148 
1149  map = va_arg(args, mapstruct *);
1150  property = va_arg(args, int);
1151 
1152  switch (property) {
1153  case CFAPI_MAP_PROP_FLAGS:
1154  rmap = va_arg(args, mapstruct **);
1155  x = va_arg(args, int);
1156  y = va_arg(args, int);
1157  nx = va_arg(args, int16_t *);
1158  ny = va_arg(args, int16_t *);
1159  rint = va_arg(args, int *);
1160  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1161  *type = CFAPI_INT;
1162  break;
1163 
1165  rint = va_arg(args, int *);
1166  *rint = calculate_difficulty(map);
1167  *type = CFAPI_INT;
1168  break;
1169 
1170  case CFAPI_MAP_PROP_PATH:
1171  rstr = va_arg(args, sstring *);
1172  *rstr = map->path;
1173  *type = CFAPI_SSTRING;
1174  break;
1175 
1177  rstr = va_arg(args, sstring *);
1178  *rstr = map->tmpname;
1179  *type = CFAPI_SSTRING;
1180  break;
1181 
1182  case CFAPI_MAP_PROP_NAME:
1183  rstr = va_arg(args, sstring *);
1184  *rstr = map->name;
1185  *type = CFAPI_SSTRING;
1186  break;
1187 
1189  rint = va_arg(args, int *);
1190  *rint = map->reset_time;
1191  *type = CFAPI_INT;
1192  break;
1193 
1195  rint = va_arg(args, int *);
1196  *rint = map->reset_timeout;
1197  *type = CFAPI_INT;
1198  break;
1199 
1201  rint = va_arg(args, int *);
1202  *rint = map->players;
1203  *type = CFAPI_INT;
1204  break;
1205 
1207  rint = va_arg(args, int *);
1208  *rint = map->darkness;
1209  *type = CFAPI_INT;
1210  break;
1211 
1212  case CFAPI_MAP_PROP_WIDTH:
1213  rint = va_arg(args, int *);
1214  *rint = map->width;
1215  *type = CFAPI_INT;
1216  break;
1217 
1218  case CFAPI_MAP_PROP_HEIGHT:
1219  rint = va_arg(args, int *);
1220  *rint = map->height;
1221  *type = CFAPI_INT;
1222  break;
1223 
1225  rint = va_arg(args, int *);
1226  *rint = map->enter_x;
1227  *type = CFAPI_INT;
1228  break;
1229 
1231  rint = va_arg(args, int *);
1232  *rint = map->enter_y;
1233  *type = CFAPI_INT;
1234  break;
1235 
1237  rstr = va_arg(args, sstring *);
1238  *rstr = map->msg;
1239  *type = CFAPI_SSTRING;
1240  break;
1241 
1242  case CFAPI_MAP_PROP_NEXT:
1243  rmap = va_arg(args, mapstruct **);
1244  *rmap = map ? map->next : first_map;
1245  *type = CFAPI_PMAP;
1246  break;
1247 
1248  case CFAPI_MAP_PROP_REGION:
1249  rreg = va_arg(args, region **);
1250  *rreg = get_region_by_map(map);
1251  *type = CFAPI_PREGION;
1252  break;
1253 
1254  case CFAPI_MAP_PROP_UNIQUE:
1255  rint = va_arg(args, int *);
1256  *rint = map->unique;
1257  *type = CFAPI_INT;
1258  break;
1259 
1260  default:
1261  *type = CFAPI_NONE;
1262  break;
1263  }
1264  va_end(args);
1265 }
1266 
1267 static void cfapi_map_set_map_property(int *type, ...) {
1268  va_list args;
1269  mapstruct *map;
1270  int property;
1271  const char *buf;
1272 
1273  va_start(args, type);
1274 
1275  map = va_arg(args, mapstruct *);
1276  property = va_arg(args, int);
1277 
1278  switch (property) {
1279  case CFAPI_MAP_PROP_PATH:
1280  buf = va_arg(args, const char *);
1281  strlcpy(map->path, buf, sizeof(map->path));
1282  *type = CFAPI_STRING;
1283  break;
1284 
1285  default:
1286  *type = CFAPI_NONE;
1287  break;
1288  }
1289  va_end(args);
1290 }
1291 
1297 static void cfapi_map_out_of_map(int *type, ...) {
1298  va_list args;
1299  mapstruct *map;
1300  int x, y;
1301  int *rint;
1302 
1303  va_start(args, type);
1304  map = va_arg(args, mapstruct *);
1305  x = va_arg(args, int);
1306  y = va_arg(args, int);
1307  rint = va_arg(args, int *);
1308 
1309  *rint = out_of_map(map, x, y);
1310  va_end(args);
1311  *type = CFAPI_INT;
1312 }
1313 
1319 static void cfapi_map_update_position(int *type, ...) {
1320  va_list args;
1321  mapstruct *map;
1322  int x, y;
1323 
1324  va_start(args, type);
1325 
1326  map = va_arg(args, mapstruct *);
1327  x = va_arg(args, int);
1328  y = va_arg(args, int);
1329 
1330  update_position(map, x, y);
1331  va_end(args);
1332  *type = CFAPI_NONE;
1333 }
1334 
1335 static void cfapi_map_delete_map(int *type, ...) {
1336  va_list args;
1337  mapstruct *map;
1338  va_start(args, type);
1339 
1340  map = va_arg(args, mapstruct *);
1341 
1342  delete_map(map);
1343 
1344  va_end(args);
1345  *type = CFAPI_NONE;
1346 }
1347 
1348 static void cfapi_map_message(int *type, ...) {
1349  va_list args;
1350  mapstruct *map;
1351  const char *string;
1352  int color;
1353 
1354  va_start(args, type);
1355  map = va_arg(args, mapstruct *);
1356  string = va_arg(args, const char *);
1357  color = va_arg(args, int);
1358  va_end(args);
1359 
1360  /* function should be extended to take message types probably */
1361  ext_info_map(color, map, MSG_TYPE_MISC, MSG_SUBTYPE_NONE, string);
1362  *type = CFAPI_NONE;
1363 }
1364 
1370 static void cfapi_map_get_object_at(int *type, ...) {
1371  va_list args;
1372  mapstruct *map;
1373  int x, y;
1374  int16_t sx, sy;
1375  object **robj;
1376 
1377  va_start(args, type);
1378  map = va_arg(args, mapstruct *);
1379  x = va_arg(args, int);
1380  y = va_arg(args, int);
1381  robj = va_arg(args, object **);
1382  va_end(args);
1383 
1384  sx = x;
1385  sy = y;
1386  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1387  *robj = NULL;
1388  else
1389  *robj = GET_MAP_OB(map, sx, sy);
1390  *type = CFAPI_POBJECT;
1391 }
1392 
1399 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1400  va_list args;
1401  int x, y;
1402  mapstruct *map;
1403  char *msg;
1404  object **robj;
1405 
1406  va_start(args, type);
1407 
1408  msg = va_arg(args, char *);
1409  map = va_arg(args, mapstruct *);
1410  x = va_arg(args, int);
1411  y = va_arg(args, int);
1412  robj = va_arg(args, object **);
1413 
1414  va_end(args);
1415 
1416  archetype *at = try_find_archetype(msg);
1417  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1418  *type = CFAPI_POBJECT;
1419 }
1420 
1426 static void cfapi_map_change_light(int *type, ...) {
1427  va_list args;
1428  int change;
1429  mapstruct *map;
1430  int *rint;
1431 
1432  va_start(args, type);
1433  map = va_arg(args, mapstruct *);
1434  change = va_arg(args, int);
1435  rint = va_arg(args, int *);
1436  va_end(args);
1437 
1438  *type = CFAPI_INT;
1439  *rint = change_map_light(map, change);
1440 }
1441 
1442 /* OBJECT-RELATED HOOKS */
1443 
1457 static void cfapi_object_move(int *type, ...) {
1458  va_list args;
1459  int kind;
1460  object *op;
1461  object *activator;
1462  player *pl;
1463  int direction;
1464  int *ret;
1465 
1466  va_start(args, type);
1467  kind = va_arg(args, int);
1468  switch (kind) {
1469  case 0:
1470  op = va_arg(args, object *);
1471  direction = va_arg(args, int);
1472  activator = va_arg(args, object *);
1473  ret = va_arg(args, int *);
1474  va_end(args);
1475  *ret = move_ob(op, direction, activator);
1476  break;
1477 
1478  case 1:
1479  pl = va_arg(args, player *);
1480  direction = va_arg(args, int);
1481  ret = va_arg(args, int *);
1482  va_end(args);
1483  *ret = move_player(pl->ob, direction);
1484  break;
1485 
1486  case 2:
1487  op = va_arg(args, object *);
1488  ret = va_arg(args, int *);
1489  va_end(args);
1490  *ret = player_arrest(op);
1491  break;
1492 
1493  default:
1494  // Just end the use of variable args. We got a wrong type.
1495  va_end(args);
1496  }
1497  *type = CFAPI_INT;
1498 }
1499 
1507 static void cfapi_object_get_key(int *type, ...) {
1508  va_list args;
1509  const char *keyname;
1510  const char **value;
1511  object *op;
1512 
1513  va_start(args, type);
1514  op = va_arg(args, object *);
1515  keyname = va_arg(args, const char *);
1516  value = va_arg(args, const char **);
1517  va_end(args);
1518 
1519  *value = object_get_value(op, keyname);
1520  *type = CFAPI_SSTRING;
1521 }
1522 
1529 static void cfapi_object_set_key(int *type, ...) {
1530  va_list args;
1531  const char *keyname;
1532  const char *value;
1533  int *ret;
1534  object *op;
1535  int add_key;
1536 
1537  va_start(args, type);
1538  op = va_arg(args, object *);
1539  keyname = va_arg(args, char *);
1540  value = va_arg(args, char *);
1541  add_key = va_arg(args, int);
1542  ret = va_arg(args, int *);
1543  va_end(args);
1544 
1545  *ret = object_set_value(op, keyname, value, add_key);
1546  *type = CFAPI_INT;
1547 }
1548 
1552 static void cfapi_object_get_property(int *type, ...) {
1553  va_list args;
1554  int property;
1555  object *op;
1556  int *rint;
1557  object **robject;
1558  mapstruct **rmap;
1559  float *rfloat;
1560  archetype **rarch;
1561  sstring *rsstring;
1562  char *rbuffer;
1563  int rbufsize;
1564  MoveType *rmove;
1565  int64_t *rint64;
1566  partylist **rparty;
1567  double *rdouble;
1568  long *rlong;
1569 
1570  va_start(args, type);
1571 
1572  op = va_arg(args, object *);
1573  property = va_arg(args, int);
1574  switch (property) {
1576  robject = va_arg(args, object **);
1577  *robject = op->above;
1578  *type = CFAPI_POBJECT;
1579  break;
1580 
1582  robject = va_arg(args, object **);
1583  *robject = op->below;
1584  *type = CFAPI_POBJECT;
1585  break;
1586 
1588  robject = va_arg(args, object **);
1589  *robject = op->active_next;
1590  *type = CFAPI_POBJECT;
1591  break;
1592 
1594  robject = va_arg(args, object **);
1595  *robject = op->active_prev;
1596  *type = CFAPI_POBJECT;
1597  break;
1598 
1600  robject = va_arg(args, object **);
1601  *robject = op->inv;
1602  *type = CFAPI_POBJECT;
1603  break;
1604 
1606  robject = va_arg(args, object **);
1607  *robject = op->env;
1608  *type = CFAPI_POBJECT;
1609  break;
1610 
1612  robject = va_arg(args, object **);
1613  *robject = op->head;
1614  *type = CFAPI_POBJECT;
1615  break;
1616 
1618  robject = va_arg(args, object **);
1619  *robject = op->container;
1620  *type = CFAPI_POBJECT;
1621  break;
1622 
1623  case CFAPI_OBJECT_PROP_MAP:
1624  rmap = va_arg(args, mapstruct **);
1625  *rmap = op->map;
1626  *type = CFAPI_PMAP;
1627  break;
1628 
1630  rint = va_arg(args, int *);
1631  *rint = op->count;
1632  *type = CFAPI_INT;
1633  break;
1634 
1636  rbuffer = va_arg(args, char *);
1637  rbufsize = va_arg(args, int);
1638  query_name(op, rbuffer, rbufsize);
1639  *type = CFAPI_STRING;
1640  break;
1641 
1643  rsstring = va_arg(args, sstring *);
1644  *rsstring = op->name_pl;
1645  *type = CFAPI_SSTRING;
1646  break;
1647 
1649  rsstring = va_arg(args, sstring *);
1650  *rsstring = op->title;
1651  *type = CFAPI_SSTRING;
1652  break;
1653 
1655  rsstring = va_arg(args, sstring *);
1656  *rsstring = op->race;
1657  *type = CFAPI_SSTRING;
1658  break;
1659 
1661  rsstring = va_arg(args, sstring *);
1662  *rsstring = op->slaying;
1663  *type = CFAPI_SSTRING;
1664  break;
1665 
1667  rsstring = va_arg(args, sstring *);
1668  *rsstring = op->skill;
1669  *type = CFAPI_SSTRING;
1670  break;
1671 
1673  rsstring = va_arg(args, sstring *);
1674  *rsstring = op->msg;
1675  *type = CFAPI_SSTRING;
1676  break;
1677 
1679  rsstring = va_arg(args, sstring *);
1680  *rsstring = op->lore;
1681  *type = CFAPI_SSTRING;
1682  break;
1683 
1684  case CFAPI_OBJECT_PROP_X:
1685  rint = va_arg(args, int *);
1686  *rint = op->x;
1687  *type = CFAPI_INT;
1688  break;
1689 
1690  case CFAPI_OBJECT_PROP_Y:
1691  rint = va_arg(args, int *);
1692  *rint = op->y;
1693  *type = CFAPI_INT;
1694  break;
1695 
1697  rfloat = va_arg(args, float *);
1698  *rfloat = op->speed;
1699  *type = CFAPI_FLOAT;
1700  break;
1701 
1703  rfloat = va_arg(args, float *);
1704  *rfloat = op->speed_left;
1705  *type = CFAPI_FLOAT;
1706  break;
1707 
1709  rint = va_arg(args, int *);
1710  *rint = NROF(op);
1711  *type = CFAPI_INT;
1712  break;
1713 
1715  rint = va_arg(args, int *);
1716  *rint = op->direction;
1717  *type = CFAPI_INT;
1718  break;
1719 
1721  rint = va_arg(args, int *);
1722  *rint = op->facing;
1723  *type = CFAPI_INT;
1724  break;
1725 
1727  rint = va_arg(args, int *);
1728  *rint = op->type;
1729  *type = CFAPI_INT;
1730  break;
1731 
1733  rint = va_arg(args, int *);
1734  *rint = op->subtype;
1735  *type = CFAPI_INT;
1736  break;
1737 
1739  rint = va_arg(args, int *);
1740  *rint = op->client_type;
1741  *type = CFAPI_INT;
1742  break;
1743 
1744  case CFAPI_OBJECT_PROP_RESIST: {
1745  int idx;
1746  int16_t *resist;
1747 
1748  idx = va_arg(args, int);
1749  resist = va_arg(args, int16_t *);
1750  *resist = op->resist[idx];
1751  }
1752  *type = CFAPI_INT16;
1753  break;
1754 
1756  rint = va_arg(args, int *);
1757  *rint = op->attacktype;
1758  *type = CFAPI_INT;
1759  break;
1760 
1762  rint = va_arg(args, int *);
1763  *rint = op->path_attuned;
1764  *type = CFAPI_INT;
1765  break;
1766 
1768  rint = va_arg(args, int *);
1769  *rint = op->path_repelled;
1770  *type = CFAPI_INT;
1771  break;
1772 
1774  rint = va_arg(args, int *);
1775  *rint = op->path_denied;
1776  *type = CFAPI_INT;
1777  break;
1778 
1780  rint = va_arg(args, int *);
1781  *rint = op->material;
1782  *type = CFAPI_INT;
1783  break;
1784 
1786  rsstring = va_arg(args, sstring *);
1787  *rsstring = op->materialname;
1788  *type = CFAPI_SSTRING;
1789  break;
1790 
1792  rint = va_arg(args, int *);
1793  *rint = op->magic;
1794  *type = CFAPI_INT;
1795  break;
1796 
1798  rlong = va_arg(args, long *);
1799  *rlong = op->value;
1800  *type = CFAPI_LONG;
1801  break;
1802 
1804  rint = va_arg(args, int *);
1805  *rint = op->level;
1806  *type = CFAPI_INT;
1807  break;
1808 
1810  rint = va_arg(args, int *);
1811  *rint = op->last_heal;
1812  *type = CFAPI_INT;
1813  break;
1814 
1816  rint = va_arg(args, int *);
1817  *rint = op->last_sp;
1818  *type = CFAPI_INT;
1819  break;
1820 
1822  rint = va_arg(args, int *);
1823  *rint = op->last_grace;
1824  *type = CFAPI_INT;
1825  break;
1826 
1828  rint = va_arg(args, int *);
1829  *rint = op->last_eat;
1830  *type = CFAPI_INT;
1831  break;
1832 
1834  rint = va_arg(args, int *);
1835  *rint = op->invisible;
1836  *type = CFAPI_INT;
1837  break;
1838 
1840  rint = va_arg(args, int *);
1841  *rint = op->pick_up;
1842  *type = CFAPI_INT;
1843  break;
1844 
1846  rint = va_arg(args, int *);
1847  *rint = op->item_power;
1848  *type = CFAPI_INT;
1849  break;
1850 
1852  rint = va_arg(args, int *);
1853  *rint = op->gen_sp_armour;
1854  *type = CFAPI_INT;
1855  break;
1856 
1858  rint = va_arg(args, int *);
1859  *rint = op->weight;
1860  *type = CFAPI_INT;
1861  break;
1862 
1864  rint = va_arg(args, int *);
1865  *rint = op->weight_limit;
1866  *type = CFAPI_INT;
1867  break;
1868 
1870  rint = va_arg(args, int *);
1871  *rint = op->carrying;
1872  *type = CFAPI_INT;
1873  break;
1874 
1876  rint = va_arg(args, int *);
1877  *rint = op->glow_radius;
1878  *type = CFAPI_INT;
1879  break;
1880 
1882  rint64 = va_arg(args, int64_t *);
1883  *rint64 = op->total_exp;
1884  *type = CFAPI_SINT64;
1885  break;
1886 
1888  robject = va_arg(args, object **);
1889  *robject = op->current_weapon;
1890  *type = CFAPI_POBJECT;
1891  break;
1892 
1894  robject = va_arg(args, object **);
1895  *robject = op->enemy;
1896  *type = CFAPI_POBJECT;
1897  break;
1898 
1900  robject = va_arg(args, object **);
1901  *robject = op->attacked_by;
1902  *type = CFAPI_POBJECT;
1903  break;
1904 
1906  rint = va_arg(args, int *);
1907  *rint = op->run_away;
1908  *type = CFAPI_INT;
1909  break;
1910 
1912  robject = va_arg(args, object **);
1913  *robject = op->chosen_skill;
1914  *type = CFAPI_POBJECT;
1915  break;
1916 
1918  rint = va_arg(args, int *);
1919  *rint = op->hide;
1920  *type = CFAPI_INT;
1921  break;
1922 
1924  rint = va_arg(args, int *);
1925  *rint = op->move_status;
1926  *type = CFAPI_INT;
1927  break;
1928 
1930  rint = va_arg(args, int *);
1931  *rint = op->attack_movement;
1932  *type = CFAPI_INT;
1933  break;
1934 
1936  robject = va_arg(args, object **);
1937  *robject = op->spellitem;
1938  *type = CFAPI_POBJECT;
1939  break;
1940 
1942  rdouble = va_arg(args, double *);
1943  *rdouble = op->expmul;
1944  *type = CFAPI_DOUBLE;
1945  break;
1946 
1948  rarch = va_arg(args, archetype **);
1949  *rarch = op->arch;
1950  *type = CFAPI_PARCH;
1951  break;
1952 
1954  rarch = va_arg(args, archetype **);
1955  *rarch = op->other_arch;
1956  *type = CFAPI_PARCH;
1957  break;
1958 
1960  rsstring = va_arg(args, sstring *);
1961  *rsstring = object_get_value(op, CUSTOM_NAME_FIELD);
1962  *type = CFAPI_SSTRING;
1963  break;
1964 
1966  rint = va_arg(args, int *);
1967  *rint = op->anim_speed;
1968  *type = CFAPI_INT;
1969  break;
1970 
1972  rint = va_arg(args, int *);
1973  *rint = is_friendly(op);
1974  *type = CFAPI_INT;
1975  break;
1976 
1978  rbuffer = va_arg(args, char *);
1979  rbufsize = va_arg(args, int);
1980  query_short_name(op, rbuffer, rbufsize);
1981  *type = CFAPI_STRING;
1982  break;
1983 
1985  int i;
1986 
1987  i = va_arg(args, int);
1988  rbuffer = va_arg(args, char *);
1989  rbufsize = va_arg(args, int);
1990  query_base_name(op, i, rbuffer, rbufsize);
1991  *type = CFAPI_STRING;
1992  }
1993  break;
1994 
1996  rsstring = va_arg(args, sstring *);
1997  *rsstring = op->name;
1998  *type = CFAPI_SSTRING;
1999  break;
2000 
2002  rint = va_arg(args, int *);
2003  *rint = is_magical(op);
2004  *type = CFAPI_INT;
2005  break;
2006 
2008  rint = va_arg(args, int *);
2009  *rint = op->stats.luck;
2010  *type = CFAPI_INT;
2011  break;
2012 
2013  case CFAPI_OBJECT_PROP_EXP:
2014  rint64 = va_arg(args, int64_t *);
2015  *rint64 = op->stats.exp;
2016  *type = CFAPI_SINT64;
2017  break;
2018 
2020  robject = va_arg(args, object **);
2021  *robject = object_get_owner(op);
2022  *type = CFAPI_POBJECT;
2023  break;
2024 
2026  int stype;
2027 
2028  stype = va_arg(args, int);
2029  switch (stype) {
2030  unsigned char ptype;
2031  char *buf;
2032  archetype *at;
2033 
2034  case 0: /* present_in_ob */
2035  ptype = (unsigned char)(va_arg(args, int));
2036  robject = va_arg(args, object **);
2037  *robject = object_present_in_ob(ptype, op);
2038  break;
2039 
2040  case 1: /* present_in_ob_by_name */
2041  ptype = (unsigned char)(va_arg(args, int));
2042  buf = va_arg(args, char *);
2043  robject = va_arg(args, object **);
2044  *robject = object_present_in_ob_by_name(ptype, buf, op);
2045  break;
2046 
2047  case 2: /* arch_present_in_ob */
2048  at = va_arg(args, archetype *);
2049  robject = va_arg(args, object **);
2050  *robject = arch_present_in_ob(at, op);
2051  break;
2052  }
2053  }
2054  *type = CFAPI_POBJECT;
2055  break;
2056 
2058  rint = va_arg(args, int *);
2059  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2060  *type = CFAPI_INT;
2061  break;
2062 
2064  object *op2;
2065 
2066  op2 = va_arg(args, object *);
2067  rint = va_arg(args, int *);
2068  *rint = object_can_merge(op, op2);
2069  }
2070  *type = CFAPI_INT;
2071  break;
2072 
2074  object *op2;
2075 
2076  op2 = va_arg(args, object *);
2077  rint = va_arg(args, int *);
2078  *rint = object_can_pick(op2, op);
2079  }
2080  *type = CFAPI_INT;
2081  break;
2082 
2083  case CFAPI_OBJECT_PROP_FLAGS: {
2084  int fl;
2085 
2086  fl = va_arg(args, int);
2087  rint = va_arg(args, int *);
2088  *rint = QUERY_FLAG(op, fl);
2089  }
2090  *type = CFAPI_INT;
2091  break;
2092 
2093  case CFAPI_OBJECT_PROP_STR:
2094  rint = va_arg(args, int *);
2095  *rint = op->stats.Str;
2096  *type = CFAPI_INT;
2097  break;
2098 
2099  case CFAPI_OBJECT_PROP_DEX:
2100  rint = va_arg(args, int *);
2101  *rint = op->stats.Dex;
2102  *type = CFAPI_INT;
2103  break;
2104 
2105  case CFAPI_OBJECT_PROP_CON:
2106  rint = va_arg(args, int *);
2107  *rint = op->stats.Con;
2108  *type = CFAPI_INT;
2109  break;
2110 
2111  case CFAPI_OBJECT_PROP_WIS:
2112  rint = va_arg(args, int *);
2113  *rint = op->stats.Wis;
2114  *type = CFAPI_INT;
2115  break;
2116 
2117  case CFAPI_OBJECT_PROP_INT:
2118  rint = va_arg(args, int *);
2119  *rint = op->stats.Int;
2120  *type = CFAPI_INT;
2121  break;
2122 
2123  case CFAPI_OBJECT_PROP_POW:
2124  rint = va_arg(args, int *);
2125  *rint = op->stats.Pow;
2126  *type = CFAPI_INT;
2127  break;
2128 
2129  case CFAPI_OBJECT_PROP_CHA:
2130  rint = va_arg(args, int *);
2131  *rint = op->stats.Cha;
2132  *type = CFAPI_INT;
2133  break;
2134 
2135  case CFAPI_OBJECT_PROP_WC:
2136  rint = va_arg(args, int *);
2137  *rint = op->stats.wc;
2138  *type = CFAPI_INT;
2139  break;
2140 
2141  case CFAPI_OBJECT_PROP_AC:
2142  rint = va_arg(args, int *);
2143  *rint = op->stats.ac;
2144  *type = CFAPI_INT;
2145  break;
2146 
2147  case CFAPI_OBJECT_PROP_HP:
2148  rint = va_arg(args, int *);
2149  *rint = op->stats.hp;
2150  *type = CFAPI_INT;
2151  break;
2152 
2153  case CFAPI_OBJECT_PROP_SP:
2154  rint = va_arg(args, int *);
2155  *rint = op->stats.sp;
2156  *type = CFAPI_INT;
2157  break;
2158 
2159  case CFAPI_OBJECT_PROP_GP:
2160  rint = va_arg(args, int *);
2161  *rint = op->stats.grace;
2162  *type = CFAPI_INT;
2163  break;
2164 
2165  case CFAPI_OBJECT_PROP_FP:
2166  rint = va_arg(args, int *);
2167  *rint = op->stats.food;
2168  *type = CFAPI_INT;
2169  break;
2170 
2172  rint = va_arg(args, int *);
2173  *rint = op->stats.maxhp;
2174  *type = CFAPI_INT;
2175  break;
2176 
2178  rint = va_arg(args, int *);
2179  *rint = op->stats.maxsp;
2180  *type = CFAPI_INT;
2181  break;
2182 
2184  rint = va_arg(args, int *);
2185  *rint = op->stats.maxgrace;
2186  *type = CFAPI_INT;
2187  break;
2188 
2189  case CFAPI_OBJECT_PROP_DAM:
2190  rint = va_arg(args, int *);
2191  *rint = op->stats.dam;
2192  *type = CFAPI_INT;
2193  break;
2194 
2195  case CFAPI_OBJECT_PROP_GOD:
2196  rsstring = va_arg(args, sstring *);
2197  *rsstring = determine_god(op);
2198  *type = CFAPI_SSTRING;
2199  break;
2200 
2202  rsstring = va_arg(args, sstring *);
2203  *rsstring = op->arch->name;
2204  *type = CFAPI_SSTRING;
2205  break;
2206 
2208  rint = va_arg(args, int *);
2209  *rint = op->invisible;
2210  *type = CFAPI_INT;
2211  break;
2212 
2214  rsstring = va_arg(args, sstring *);
2215  if (op->face != NULL) {
2216  (*rsstring) = op->face->name;
2217  }
2218  else {
2219  (*rsstring) = NULL;
2220  }
2221  *type = CFAPI_SSTRING;
2222  break;
2223 
2225  rsstring = va_arg(args, sstring *);
2226  if (op->animation != NULL) {
2227  (*rsstring) = op->animation->name;
2228  }
2229  else {
2230  (*rsstring) = NULL;
2231  }
2232  *type = CFAPI_SSTRING;
2233  break;
2234 
2236  rint = va_arg(args, int *);
2237  *rint = op->contr->count;
2238  *type = CFAPI_INT;
2239  break;
2240 
2241  case CFAPI_PLAYER_PROP_IP:
2242  rsstring = va_arg(args, sstring *);
2243  *rsstring = op->contr->socket->host;
2244  *type = CFAPI_SSTRING;
2245  break;
2246 
2248  rsstring = va_arg(args, sstring *);
2249  *rsstring = op->contr->socket->client;
2250  *type = CFAPI_SSTRING;
2251  break;
2252 
2254  robject = va_arg(args, object **);
2255  *robject = find_marked_object(op);
2256  *type = CFAPI_POBJECT;
2257  break;
2258 
2260  rparty = va_arg(args, partylist **);
2261  *rparty = (op->contr ? op->contr->party : NULL);
2262  *type = CFAPI_PPARTY;
2263  break;
2264 
2266  robject = va_arg(args, object **);
2267  if (op)
2268  *robject = op->contr->next ? op->contr->next->ob : NULL;
2269  else
2270  /* This can be called when there is no player. */
2271  *robject = first_player ? first_player->ob : NULL;
2272  *type = CFAPI_POBJECT;
2273  break;
2274 
2276  rbuffer = va_arg(args, char *);
2277  rbufsize = va_arg(args, int);
2278  player_get_title(op->contr, rbuffer, rbufsize);
2279  *type = CFAPI_STRING;
2280  break;
2281 
2283  robject = va_arg(args, object **);
2284  *robject = op->contr->transport;
2285  *type = CFAPI_POBJECT;
2286  break;
2287 
2289  rmove = va_arg(args, MoveType *);
2290  *rmove = op->move_type;
2291  *type = CFAPI_MOVETYPE;
2292  break;
2293 
2295  rmove = va_arg(args, MoveType *);
2296  *rmove = op->move_block;
2297  *type = CFAPI_MOVETYPE;
2298  break;
2299 
2301  rmove = va_arg(args, MoveType *);
2302  *rmove = op->move_allow;
2303  *type = CFAPI_MOVETYPE;
2304  break;
2305 
2307  rmove = va_arg(args, MoveType *);
2308  *rmove = op->move_on;
2309  *type = CFAPI_MOVETYPE;
2310  break;
2311 
2313  rmove = va_arg(args, MoveType *);
2314  *rmove = op->move_off;
2315  *type = CFAPI_MOVETYPE;
2316  break;
2317 
2319  rmove = va_arg(args, MoveType *);
2320  *rmove = op->move_type;
2321  *type = CFAPI_MOVETYPE;
2322  break;
2323 
2325  rfloat = va_arg(args, float *);
2326  *rfloat = op->move_slow_penalty;
2327  *type = CFAPI_FLOAT;
2328  break;
2329 
2331  rbuffer = va_arg(args, char *);
2332  rbufsize = va_arg(args, int);
2333  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2334  *type = CFAPI_STRING;
2335  break;
2336 
2338  rint = va_arg(args, int *);
2339  *rint = op->contr->bed_x;
2340  *type = CFAPI_INT;
2341  break;
2342 
2344  rint = va_arg(args, int *);
2345  *rint = op->contr->bed_y;
2346  *type = CFAPI_INT;
2347  break;
2348 
2350  rint = va_arg(args, int *);
2351  *rint = op->duration;
2352  *type = CFAPI_INT;
2353  break;
2354 
2355  default:
2356  *type = CFAPI_NONE;
2357  break;
2358  }
2359  va_end(args);
2360 }
2361 
2370 static void copy_message(object *op, const char *msg) {
2371  /* need to reset parsed dialog information */
2373  if (strlen(msg) == 0) {
2374  msg = NULL;
2375  }
2376  object_set_msg(op, msg);
2377 }
2378 
2387 static void cfapi_object_set_property(int *type, ...) {
2388  va_list args;
2389  int iarg, *ret;
2390  long larg;
2391  char *sarg;
2392  double darg;
2393  object *oparg;
2394  object *op;
2395  int property;
2396  int64_t s64arg;
2397  partylist *partyarg;
2398  float farg;
2399  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2400 
2401  va_start(args, type);
2402  op = va_arg(args, object *);
2403  property = va_arg(args, int);
2404  *type = CFAPI_NONE;
2405 
2406  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2407  switch (property) {
2409  sarg = va_arg(args, char *);
2410  *type = CFAPI_STRING;
2411  FREE_AND_COPY(op->name, sarg);
2412  send_changed_object(op);
2413  break;
2414 
2416  sarg = va_arg(args, char *);
2417  *type = CFAPI_STRING;
2418  FREE_AND_COPY(op->name_pl, sarg);
2419  send_changed_object(op);
2420  break;
2421 
2423  sarg = va_arg(args, char *);
2424  *type = CFAPI_STRING;
2425  FREE_AND_COPY(op->title, sarg);
2426  break;
2427 
2429  sarg = va_arg(args, char *);
2430  *type = CFAPI_STRING;
2431  FREE_AND_COPY(op->race, sarg);
2432  break;
2433 
2435  sarg = va_arg(args, char *);
2436  *type = CFAPI_STRING;
2437  FREE_AND_COPY(op->slaying, sarg);
2438  break;
2439 
2441  sarg = va_arg(args, char *);
2442  *type = CFAPI_STRING;
2443  FREE_AND_COPY(op->skill, sarg);
2444  break;
2445 
2447  sarg = va_arg(args, char *);
2448  *type = CFAPI_STRING;
2449  copy_message(op, sarg);
2450  break;
2451 
2453  sarg = va_arg(args, char *);
2454  *type = CFAPI_STRING;
2455  FREE_AND_COPY(op->lore, sarg);
2456  break;
2457 
2459  farg = va_arg(args, double);
2460  *type = CFAPI_FLOAT;
2461  if (farg != op->speed) {
2462  op->speed = farg;
2463  object_update_speed(op);
2464  }
2465  break;
2466 
2468  farg = va_arg(args, double);
2469  *type = CFAPI_FLOAT;
2470  op->speed_left = farg;
2471  break;
2472 
2474  iarg = va_arg(args, int);
2475  *type = CFAPI_INT;
2476  if (iarg < 0)
2477  iarg = 0;
2478  if (op->nrof > (uint32_t)iarg)
2479  object_decrease_nrof(op, op->nrof-iarg);
2480  else if (op->nrof < (uint32_t)iarg) {
2481  object *tmp;
2482  player *pl;
2483 
2484  op->nrof = iarg;
2485  if (op->env != NULL) {
2486  tmp = object_get_player_container(op->env);
2487  if (!tmp) {
2488  for (pl = first_player; pl; pl = pl->next)
2489  if (pl->ob->container == op->env)
2490  break;
2491  if (pl)
2492  tmp = pl->ob;
2493  else
2494  tmp = NULL;
2495  } else {
2496  object_sum_weight(tmp);
2497  fix_object(tmp);
2498  }
2499  if (tmp)
2500  esrv_update_item(UPD_NROF, tmp, op);
2501  } else {
2502  FOR_ABOVE_PREPARE(op, tmp)
2503  if (tmp->type == PLAYER)
2504  tmp->contr->socket->update_look = 1;
2505  FOR_ABOVE_FINISH();
2506  }
2507  }
2508  break;
2509 
2511  iarg = va_arg(args, int);
2512  *type = CFAPI_INT;
2513  op->direction = iarg;
2514  break;
2515 
2517  iarg = va_arg(args, int);
2518  *type = CFAPI_INT;
2519  op->facing = iarg;
2520  break;
2521 
2522  case CFAPI_OBJECT_PROP_RESIST: {
2523  int iargbis = va_arg(args, int);
2524 
2525  *type = CFAPI_INT16;
2526  iarg = va_arg(args, int);
2527  op->resist[iargbis] = iarg;
2528  }
2529  break;
2530 
2532  iarg = va_arg(args, int);
2533  *type = CFAPI_INT;
2534  op->attacktype = iarg;
2535  break;
2536 
2538  iarg = va_arg(args, int);
2539  *type = CFAPI_INT;
2540  op->path_attuned = iarg;
2541  break;
2542 
2544  iarg = va_arg(args, int);
2545  *type = CFAPI_INT;
2546  op->path_repelled = iarg;
2547  break;
2548 
2550  iarg = va_arg(args, int);
2551  *type = CFAPI_INT;
2552  op->path_denied = iarg;
2553  break;
2554 
2556  iarg = va_arg(args, int);
2557  *type = CFAPI_INT;
2558  op->material = iarg;
2559  break;
2560 
2562  break;
2563 
2565  iarg = va_arg(args, int);
2566  *type = CFAPI_INT;
2567  op->magic = iarg;
2568  break;
2569 
2571  larg = va_arg(args, long);
2572  *type = CFAPI_LONG;
2573  op->value = larg;
2574  break;
2575 
2577  iarg = va_arg(args, int);
2578  *type = CFAPI_INT;
2579  op->level = iarg;
2580  send_changed_object(op);
2581  break;
2582 
2584  iarg = va_arg(args, int);
2585  *type = CFAPI_INT;
2586  op->last_heal = iarg;
2587  break;
2588 
2590  iarg = va_arg(args, int);
2591  *type = CFAPI_INT;
2592  op->last_sp = iarg;
2593  break;
2594 
2596  iarg = va_arg(args, int);
2597  *type = CFAPI_INT;
2598  op->last_grace = iarg;
2599  break;
2600 
2602  iarg = va_arg(args, int);
2603  *type = CFAPI_INT;
2604  op->last_eat = iarg;
2605  break;
2606 
2608  iarg = va_arg(args, int);
2609  *type = CFAPI_INT;
2610  op->invisible = iarg;
2611  break;
2612 
2614  iarg = va_arg(args, int);
2615  *type = CFAPI_INT;
2616  op->pick_up = iarg;
2617  break;
2618 
2620  iarg = va_arg(args, int);
2621  *type = CFAPI_INT;
2622  op->item_power = iarg;
2623  break;
2624 
2626  iarg = va_arg(args, int);
2627  *type = CFAPI_INT;
2628  op->gen_sp_armour = iarg;
2629  break;
2630 
2632  iarg = va_arg(args, int);
2633  *type = CFAPI_INT;
2634  if (op->weight != iarg) {
2635  object *tmp;
2636  player *pl;
2637 
2638  op->weight = iarg;
2639  if (op->env != NULL) {
2640  tmp = object_get_player_container(op->env);
2641  if (!tmp) {
2642  for (pl = first_player; pl; pl = pl->next)
2643  if (pl->ob->container == op->env)
2644  break;
2645  if (pl)
2646  tmp = pl->ob;
2647  else
2648  tmp = NULL;
2649  } else {
2650  object_sum_weight(tmp);
2651  fix_object(tmp);
2652  }
2653  if (tmp)
2654  esrv_update_item(UPD_WEIGHT, tmp, op);
2655  } else {
2656  FOR_ABOVE_PREPARE(op, tmp)
2657  if (tmp->type == PLAYER)
2658  esrv_update_item(UPD_WEIGHT, tmp, op);
2659  FOR_ABOVE_FINISH();
2660  }
2661  }
2662  break;
2663 
2665  iarg = va_arg(args, int);
2666  *type = CFAPI_INT;
2667  op->weight_limit = iarg;
2668  break;
2669 
2671  iarg = va_arg(args, int);
2672  *type = CFAPI_INT;
2673  if (op->glow_radius != iarg) {
2674  object *tmp;
2675 
2676  op->glow_radius = iarg;
2677  tmp = object_get_env_recursive(op);
2678  if (tmp->map != NULL) {
2679  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2680  update_position(tmp->map, tmp->x, tmp->y);
2681  update_all_los(tmp->map, tmp->x, tmp->y);
2682  }
2683  }
2684  break;
2685 
2687  s64arg = va_arg(args, int64_t);
2688  *type = CFAPI_SINT64;
2689  op->total_exp = s64arg;
2690  break;
2691 
2693  oparg = va_arg(args, object *);
2694  *type = CFAPI_POBJECT;
2695  object_set_enemy(op, oparg);
2696  break;
2697 
2699  iarg = va_arg(args, int);
2700  *type = CFAPI_INT;
2701  op->run_away = iarg;
2702  break;
2703 
2705  oparg = va_arg(args, object *);
2706  *type = CFAPI_POBJECT;
2707  op->chosen_skill = oparg;
2708  break;
2709 
2711  iarg = va_arg(args, int);
2712  *type = CFAPI_INT;
2713  op->hide = iarg;
2714  break;
2715 
2717  iarg = va_arg(args, int);
2718  *type = CFAPI_INT;
2719  op->move_status = iarg;
2720  break;
2721 
2723  iarg = va_arg(args, int);
2724  *type = CFAPI_INT;
2725  op->attack_movement = iarg;
2726  break;
2727 
2729  oparg = va_arg(args, object *);
2730  *type = CFAPI_POBJECT;
2731  op->spellitem = oparg;
2732  break;
2733 
2735  darg = va_arg(args, double);
2736  *type = CFAPI_DOUBLE;
2737  op->expmul = darg;
2738  break;
2739 
2741  sarg = va_arg(args, char *);
2742  *type = CFAPI_STRING;
2743  object_set_value(op, CUSTOM_NAME_FIELD, sarg, 1);
2744  send_changed_object(op);
2745  break;
2746 
2748  iarg = va_arg(args, int);
2749  *type = CFAPI_INT;
2750  op->anim_speed = iarg;
2751  break;
2752 
2754  iarg = va_arg(args, int);
2755  *type = CFAPI_INT;
2756  if (iarg == 1 && is_friendly(op) == 0)
2757  add_friendly_object(op);
2758  else if (iarg == 0 && is_friendly(op) == 1)
2760  break;
2761 
2763  iarg = va_arg(args, int);
2764  *type = CFAPI_INT;
2765  op->stats.luck = iarg;
2766  break;
2767 
2768  case CFAPI_OBJECT_PROP_EXP:
2769  s64arg = va_arg(args, int64_t);
2770  *type = CFAPI_SINT64;
2771  op->stats.exp = s64arg;
2772  break;
2773 
2775  oparg = va_arg(args, object *);
2776  *type = CFAPI_POBJECT;
2777  object_set_owner(op, oparg);
2778  break;
2779 
2781  object_set_cheat(op);
2782  *type = CFAPI_NONE;
2783  break;
2784 
2785  case CFAPI_OBJECT_PROP_FLAGS: {
2786  int iargbis;
2787 
2788  iarg = va_arg(args, int);
2789  iargbis = va_arg(args, int);
2790  *type = CFAPI_INT;
2791 
2792  if (iargbis == 1)
2793  SET_FLAG(op, iarg);
2794  else
2795  CLEAR_FLAG(op, iarg);
2796  send_changed_object(op);
2797  }
2798  break;
2799 
2800  case CFAPI_OBJECT_PROP_STR:
2801  iarg = va_arg(args, int);
2802  *type = CFAPI_INT;
2803  op->stats.Str = iarg;
2804  break;
2805 
2806  case CFAPI_OBJECT_PROP_DEX:
2807  iarg = va_arg(args, int);
2808  *type = CFAPI_INT;
2809  op->stats.Dex = iarg;
2810  break;
2811 
2812  case CFAPI_OBJECT_PROP_CON:
2813  iarg = va_arg(args, int);
2814  *type = CFAPI_INT;
2815  op->stats.Con = iarg;
2816  break;
2817 
2818  case CFAPI_OBJECT_PROP_WIS:
2819  iarg = va_arg(args, int);
2820  *type = CFAPI_INT;
2821  op->stats.Wis = iarg;
2822  break;
2823 
2824  case CFAPI_OBJECT_PROP_INT:
2825  iarg = va_arg(args, int);
2826  *type = CFAPI_INT;
2827  op->stats.Int = iarg;
2828  break;
2829 
2830  case CFAPI_OBJECT_PROP_POW:
2831  iarg = va_arg(args, int);
2832  *type = CFAPI_INT;
2833  op->stats.Pow = iarg;
2834  break;
2835 
2836  case CFAPI_OBJECT_PROP_CHA:
2837  iarg = va_arg(args, int);
2838  *type = CFAPI_INT;
2839  op->stats.Cha = iarg;
2840  break;
2841 
2842  case CFAPI_OBJECT_PROP_WC:
2843  iarg = va_arg(args, int);
2844  *type = CFAPI_INT;
2845  op->stats.wc = iarg;
2846  break;
2847 
2848  case CFAPI_OBJECT_PROP_AC:
2849  iarg = va_arg(args, int);
2850  *type = CFAPI_INT;
2851  op->stats.ac = iarg;
2852  break;
2853 
2854  case CFAPI_OBJECT_PROP_HP:
2855  iarg = va_arg(args, int);
2856  *type = CFAPI_INT;
2857  op->stats.hp = iarg;
2858  break;
2859 
2860  case CFAPI_OBJECT_PROP_SP:
2861  iarg = va_arg(args, int);
2862  *type = CFAPI_INT;
2863  op->stats.sp = iarg;
2864  break;
2865 
2866  case CFAPI_OBJECT_PROP_GP:
2867  iarg = va_arg(args, int);
2868  *type = CFAPI_INT;
2869  op->stats.grace = iarg;
2870  break;
2871 
2872  case CFAPI_OBJECT_PROP_FP:
2873  iarg = va_arg(args, int);
2874  *type = CFAPI_INT;
2875  op->stats.food = iarg;
2876  break;
2877 
2879  iarg = va_arg(args, int);
2880  *type = CFAPI_INT;
2881  op->stats.maxhp = iarg;
2882  break;
2883 
2885  iarg = va_arg(args, int);
2886  *type = CFAPI_INT;
2887  op->stats.maxsp = iarg;
2888  break;
2889 
2891  iarg = va_arg(args, int);
2892  *type = CFAPI_INT;
2893  op->stats.maxgrace = iarg;
2894  break;
2895 
2896  case CFAPI_OBJECT_PROP_DAM:
2897  iarg = va_arg(args, int);
2898  *type = CFAPI_INT;
2899  op->stats.dam = iarg;
2900  break;
2901 
2902  case CFAPI_OBJECT_PROP_FACE: {
2903  const Face *face;
2904  sarg = va_arg(args, char *);
2905  ret = va_arg(args, int *);
2906  *type = CFAPI_INT;
2907  face = try_find_face(sarg, 0);
2908  if (face != NULL) {
2909  op->face = face;
2910  op->state = 0;
2912  (*ret) = face->number;
2913  } else
2914  (*ret) = 0;
2915  break;
2916  }
2917 
2919  const Animations *anim;
2920  sarg = va_arg(args, char *);
2921  ret = va_arg(args, int *);
2922  *type = CFAPI_INT;
2923  anim = try_find_animation(sarg);
2924  if (anim != NULL) {
2925  op->animation = anim;
2926  SET_ANIMATION(op, 0);
2928  (*ret) = anim->num;
2929  } else {
2930  (*ret) = 0;
2931  }
2932  break;
2933  }
2934 
2936  iarg = va_arg(args, int);
2937  *type = CFAPI_INT;
2938  op->duration = iarg;
2939  break;
2940 
2942  if (op->contr) {
2943  oparg = va_arg(args, object *);
2944  *type = CFAPI_POBJECT;
2945  op->contr->mark = oparg;
2946  if (oparg) {
2947  op->contr->mark_count = oparg->count;
2948  } else {
2949  op->contr->mark_count = 0;
2950  }
2951  }
2952  break;
2953 
2955  if (op->contr) {
2956  partyarg = va_arg(args, partylist *);
2957  *type = CFAPI_PPARTY;
2958  party_join(op, partyarg);
2959  }
2960  break;
2961 
2963  sarg = va_arg(args, char *);
2964  *type = CFAPI_STRING;
2965  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
2966  break;
2967 
2969  iarg = va_arg(args, int);
2970  *type = CFAPI_INT;
2971  op->contr->bed_x = iarg;
2972  break;
2973 
2975  iarg = va_arg(args, int);
2976  *type = CFAPI_INT;
2977  op->contr->bed_y = iarg;
2978  break;
2979 
2981  sarg = va_arg(args, char *);
2982  *type = CFAPI_STRING;
2983  player_set_own_title(op->contr, sarg);
2984  break;
2985 
2987  move = va_arg(args, MoveType *);
2988  op->move_type = *move & MOVE_ALL;
2990  *type = CFAPI_MOVETYPE;
2991  break;
2992 
2994  move = va_arg(args, MoveType *);
2995  op->move_block = *move & MOVE_ALL;
2997  *type = CFAPI_MOVETYPE;
2998  break;
2999 
3001  move = va_arg(args, MoveType *);
3002  op->move_allow = *move & MOVE_ALL;
3004  *type = CFAPI_MOVETYPE;
3005  break;
3006 
3008  move = va_arg(args, MoveType *);
3009  op->move_on = *move & MOVE_ALL;
3011  *type = CFAPI_MOVETYPE;
3012  break;
3013 
3015  move = va_arg(args, MoveType *);
3016  op->move_off = *move & MOVE_ALL;
3018  *type = CFAPI_MOVETYPE;
3019  break;
3020 
3022  move = va_arg(args, MoveType *);
3023  op->move_type = *move & MOVE_ALL;
3025  *type = CFAPI_MOVETYPE;
3026  break;
3027 
3028  default:
3029  break;
3030  }
3031  }
3032  va_end(args);
3033 }
3034 
3041 static void cfapi_object_apply_below(int *type, ...) {
3042  va_list args;
3043  object *applier;
3044 
3045  va_start(args, type);
3046 
3047  applier = va_arg(args, object *);
3048 
3049  va_end(args);
3050 
3051  apply_by_living_below(applier);
3052  *type = CFAPI_NONE;
3053 }
3054 
3061 static void cfapi_object_apply(int *type, ...) {
3062  va_list args;
3063  object *applied;
3064  object *applier;
3065  int aflags;
3066  int *ret;
3067 
3068  va_start(args, type);
3069 
3070  applier = va_arg(args, object *);
3071  applied = va_arg(args, object *);
3072  aflags = va_arg(args, int);
3073  ret = va_arg(args, int *);
3074 
3075  va_end(args);
3076 
3077  *type = CFAPI_INT;
3078  *ret = apply_manual(applier, applied, aflags);
3079 }
3080 
3086 static void cfapi_object_identify(int *type, ...) {
3087  va_list args;
3088  object *op, **result;
3089 
3090  va_start(args, type);
3091 
3092  op = va_arg(args, object *);
3093  result = va_arg(args, object **);
3094 
3095  va_end(args);
3096 
3097  (*result) = identify(op);
3098  *type = CFAPI_POBJECT;
3099 }
3100 
3106 static void cfapi_object_describe(int *type, ...) {
3107  va_list args;
3108  object *op;
3109  object *owner;
3110  char *desc, *final;
3111  int size;
3112 
3113  va_start(args, type);
3114 
3115  op = va_arg(args, object *);
3116  owner = va_arg(args, object *);
3117  desc = va_arg(args, char *);
3118  size = va_arg(args, int);
3119  va_end(args);
3120 
3121  *type = CFAPI_STRING;
3122  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3123  strncpy(desc, final, size);
3124  desc[size - 1] = '\0';
3125  free(final);
3126 }
3127 
3128 static void cfapi_object_drain(int *type, ...) {
3129  va_list args;
3130 
3131  object *op;
3132  int ds;
3133 
3134  va_start(args, type);
3135 
3136  op = va_arg(args, object *);
3137  ds = va_arg(args, int);
3138 
3139  va_end(args);
3140 
3141  drain_specific_stat(op, ds);
3142 
3143  *type = CFAPI_NONE;
3144 }
3145 
3146 static void cfapi_object_remove_depletion(int *type, ...) {
3147  va_list args;
3148 
3149  object *op;
3150  int level, *result;
3151 
3152  va_start(args, type);
3153 
3154  op = va_arg(args, object *);
3155  level = va_arg(args, int);
3156  result = va_arg(args, int*);
3157 
3158  va_end(args);
3159 
3160  *result = remove_depletion(op, level);
3161 
3162  *type = CFAPI_INT;
3163 }
3164 
3165 static void cfapi_object_fix(int *type, ...) {
3166  va_list args;
3167  object *op;
3168 
3169  va_start(args, type);
3170 
3171  op = va_arg(args, object *);
3172 
3173  va_end(args);
3174 
3175  fix_object(op);
3176 
3177  *type = CFAPI_NONE;
3178 }
3179 
3181 static void cfapi_object_give_skill(int *type, ...) {
3182  va_list args;
3183 
3184  object *op;
3185  char *skillname;
3186 
3187  va_start(args, type);
3188 
3189  op = va_arg(args, object *);
3190  skillname = va_arg(args, char *);
3191 
3192  va_end(args);
3193 
3194  *type = CFAPI_POBJECT;
3195  give_skill_by_name(op, skillname);
3196 }
3197 
3198 static void cfapi_object_transmute(int *type, ...) {
3199  va_list args;
3200 
3201  object *op;
3202  object *chg;
3203 
3204  va_start(args, type);
3205 
3206  op = va_arg(args, object *);
3207  chg = va_arg(args, object *);
3208 
3209  va_end(args);
3210 
3211  transmute_materialname(op, chg);
3212  *type = CFAPI_NONE;
3213 }
3214 
3215 static void cfapi_object_remove(int *type, ...) {
3216  va_list args;
3217  object *op;
3218 
3219  va_start(args, type);
3220 
3221  op = va_arg(args, object *);
3222 
3223  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3224  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3225  va_end(args);
3226  *type = CFAPI_NONE;
3227  return;
3228  }
3229 
3230  va_end(args);
3231 
3232  object_remove(op);
3233  *type = CFAPI_NONE;
3234 }
3235 
3236 static void cfapi_object_delete(int *type, ...) {
3237  va_list args;
3238  object *op;
3239 
3240  va_start(args, type);
3241 
3242  op = va_arg(args, object *);
3243 
3244  if (QUERY_FLAG(op, FLAG_FREED) || !QUERY_FLAG(op, FLAG_REMOVED)) {
3245  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3246  *type = CFAPI_NONE;
3247  va_end(args);
3248  return;
3249  }
3250 
3251  va_end(args);
3252 
3254 
3255  *type = CFAPI_NONE;
3256 }
3257 
3263 static void cfapi_object_clone(int *type, ...) {
3264  va_list args;
3265  object *op;
3266  int kind;
3267  object **robj;
3268 
3269  va_start(args, type);
3270 
3271  op = va_arg(args, object *);
3272  kind = va_arg(args, int);
3273  robj = va_arg(args, object **);
3274 
3275  va_end(args);
3276 
3277  if (kind == 0) {
3278  *type = CFAPI_POBJECT;
3279  *robj = object_create_clone(op);
3280  } else {
3281  object *tmp;
3282  tmp = object_new();
3283  object_copy(op, tmp);
3284  *type = CFAPI_POBJECT;
3285  *robj = tmp;
3286  }
3287  return;
3288 }
3289 
3295 static void cfapi_object_create(int *type, ...) {
3296  va_list args;
3297  int ival;
3298  object **robj;
3299  va_start(args, type);
3300  ival = va_arg(args, int);
3301 
3302  *type = CFAPI_POBJECT;
3303  switch (ival) {
3304  case 0:
3305  robj = va_arg(args, object **);
3306  *robj = object_new();
3307  break;
3308 
3309  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3310  const char *sval;
3311  archetype *at;
3312 
3313  sval = va_arg(args, const char *);
3314  robj = va_arg(args, object **);
3315  va_end(args);
3316 
3317  at = try_find_archetype(sval);
3318  if (!at)
3319  at = find_archetype_by_object_name(sval);
3320  if (at) {
3321  *robj = object_create_arch(at);
3322  } else
3323  *robj = NULL;
3324  }
3325  break;
3326 
3327  default:
3328  *type = CFAPI_NONE;
3329  break;
3330  }
3331  va_end(args);
3332 }
3333 
3334 static void cfapi_object_insert(int *type, ...) {
3335  va_list args;
3336  object *op;
3337  object *orig;
3338  mapstruct *map;
3339  int flag, x, y;
3340  int itype;
3341  object **robj;
3342 
3343  va_start(args, type);
3344 
3345  op = va_arg(args, object *);
3346  if (!op) {
3347  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3348  va_end(args);
3349  return;
3350  }
3351  if (QUERY_FLAG(op, FLAG_FREED)) {
3352  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3353  va_end(args);
3354  return;
3355  }
3356  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3357  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3358  object_remove(op);
3359  }
3360  itype = va_arg(args, int);
3361 
3362  switch (itype) {
3363  case 0:
3364  map = va_arg(args, mapstruct *);
3365  orig = va_arg(args, object *);
3366  flag = va_arg(args, int);
3367  x = va_arg(args, int);
3368  y = va_arg(args, int);
3369  robj = va_arg(args, object **);
3370  if (!map) {
3371  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3373  *robj = NULL;
3374  } else
3375  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3376  *type = CFAPI_POBJECT;
3377  break;
3378 
3379  case 1:
3380  map = va_arg(args, mapstruct *);
3381  orig = va_arg(args, object *);
3382  flag = va_arg(args, int);
3383  robj = va_arg(args, object **);
3384  if (!map) {
3385  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3387  *robj = NULL;
3388  } else
3389  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3390  *type = CFAPI_POBJECT;
3391  break;
3392 
3393  case 2:
3394  map = va_arg(args, mapstruct *);
3395  orig = va_arg(args, object *);
3396  flag = va_arg(args, int);
3397  x = va_arg(args, int);
3398  y = va_arg(args, int);
3399  robj = va_arg(args, object **);
3400  if (!map) {
3401  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3403  *robj = NULL;
3404  } else {
3405  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3406  if (dir != -1) {
3407  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3408  } else {
3410  *robj = NULL;
3411  }
3412  }
3413  *type = CFAPI_POBJECT;
3414  break;
3415 
3416  case 3:
3417  orig = va_arg(args, object *);
3418  robj = va_arg(args, object **);
3419  if (!orig) {
3420  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3422  *robj = NULL;
3423  } else
3424  *robj = object_insert_in_ob(op, orig);
3425  *type = CFAPI_POBJECT;
3426  break;
3427 
3428  default:
3429  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3431  *type = CFAPI_NONE;
3432  break;
3433  }
3434 
3435  va_end(args);
3436 }
3442 static void cfapi_object_split(int *type, ...) {
3443  va_list args;
3444 
3445  int nr, size;
3446  object *op;
3447  char *buf;
3448  object **split;
3449 
3450  va_start(args, type);
3451 
3452  op = va_arg(args, object *);
3453  nr = va_arg(args, int);
3454  buf = va_arg(args, char *);
3455  size = va_arg(args, int);
3456  split = va_arg(args, object **);
3457  va_end(args);
3458 
3459  *split = object_split(op, nr, buf, size);
3460  if (*split != NULL)
3461  {
3462  *type = CFAPI_POBJECT;
3463  }
3464  else
3465  {
3466  *type = CFAPI_NONE;
3467  }
3468 }
3469 
3475 static void cfapi_object_merge(int *type, ...) {
3476  va_list args;
3477  object *op;
3478  object *op2;
3479  object **merge;
3480 
3481  va_start(args, type);
3482 
3483  op = va_arg(args, object *);
3484  op2 = va_arg(args, object *);
3485  merge = va_arg(args, object **);
3486 
3487  va_end(args);
3488 
3489  *type = CFAPI_POBJECT;
3490  *merge = object_merge(op, op2);
3491 }
3492 
3498 static void cfapi_object_distance(int *type, ...) {
3499  va_list args;
3500  object *op;
3501  object *op2;
3502  int *rint;
3503  va_start(args, type);
3504 
3505  op = va_arg(args, object *);
3506  op2 = va_arg(args, object *);
3507  rint = va_arg(args, int *);
3508 
3509  va_end(args);
3510 
3511  *type = CFAPI_INT;
3512  *rint = object_distance(op, op2);
3513 }
3519 static void cfapi_object_update(int *type, ...) {
3520  va_list args;
3521  int action;
3522  object *op;
3523  va_start(args, type);
3524 
3525  op = va_arg(args, object *);
3526  action = va_arg(args, int);
3527 
3528  va_end(args);
3529 
3530  object_update(op, action);
3531  *type = CFAPI_NONE;
3532 }
3533 
3539 static void cfapi_object_clear(int *type, ...) {
3540  va_list args;
3541  object *op;
3542  va_start(args, type);
3543 
3544  op = va_arg(args, object *);
3545 
3546  va_end(args);
3547 
3548  object_clear(op);
3549  *type = CFAPI_NONE;
3550 }
3551 
3557 static void cfapi_object_reset(int *type, ...) {
3558  va_list args;
3559  object *op;
3560 
3561  va_start(args, type);
3562 
3563  op = va_arg(args, object *);
3564 
3565  va_end(args);
3566 
3567  object_reset(op);
3568  *type = CFAPI_NONE;
3569 }
3570 
3571 static void cfapi_object_clean_object(int *type, ...) {
3572  va_list args;
3573  object *op;
3574 
3575  va_start(args, type);
3576  op = va_arg(args, object *);
3577  clean_object(op);
3578  va_end(args);
3579  *type = CFAPI_NONE;
3580 }
3581 
3582 static void cfapi_object_on_same_map(int *type, ...) {
3583  va_list args;
3584  object *op1;
3585  object *op2;
3586  int *rint;
3587 
3588  va_start(args, type);
3589  op1 = va_arg(args, object *);
3590  op2 = va_arg(args, object *);
3591  rint = va_arg(args, int *);
3592  va_end(args);
3593 
3594  *type = CFAPI_INT;
3595  *rint = on_same_map(op1, op2);
3596 }
3597 
3598 static void cfapi_object_spring_trap(int *type, ...) {
3599  object *trap;
3600  object *victim;
3601  va_list args;
3602 
3603  va_start(args, type);
3604  trap = va_arg(args, object *);
3605  victim = va_arg(args, object *);
3606  va_end(args);
3607 
3608  spring_trap(trap, victim);
3609  *type = CFAPI_NONE;
3610 }
3611 
3617 static void cfapi_object_check_trigger(int *type, ...) {
3618  object *op;
3619  object *cause;
3620  va_list args;
3621  int *rint;
3622 
3623  va_start(args, type);
3624  op = va_arg(args, object *);
3625  cause = va_arg(args, object *);
3626  rint = va_arg(args, int *);
3627  va_end(args);
3628 
3629  *rint = check_trigger(op, cause);
3630  *type = CFAPI_INT;
3631 }
3632 
3644 static void cfapi_map_trigger_connected(int *type, ...) {
3645  objectlink *ol;
3646  object *cause;
3647  int state;
3648  va_list args;
3649 
3650  va_start(args, type);
3651  ol = va_arg(args, objectlink *);
3652  cause = va_arg(args, object *);
3653  state = va_arg(args, int);
3654  va_end(args);
3655  trigger_connected(ol, cause, state);
3656  *type = CFAPI_NONE;
3657 }
3658 
3664 static void cfapi_object_query_money(int *type, ...) {
3665  object *op;
3666  va_list args;
3667  int *rint;
3668 
3669  va_start(args, type);
3670  op = va_arg(args, object *);
3671  rint = va_arg(args, int *);
3672  va_end(args);
3673 
3674  *rint = query_money(op);
3675  *type = CFAPI_INT;
3676 }
3677 
3683 static void cfapi_object_cast(int *type, ...) {
3684  object *op;
3685  object *sp;
3686  int dir;
3687  char *str;
3688  object *caster;
3689  va_list args;
3690  int *rint;
3691 
3692  va_start(args, type);
3693  op = va_arg(args, object *);
3694  caster = va_arg(args, object *);
3695  dir = va_arg(args, int);
3696  sp = va_arg(args, object *);
3697  str = va_arg(args, char *);
3698  rint = va_arg(args, int *);
3699  va_end(args);
3700 
3701  *type = CFAPI_INT;
3702 
3703  if (!op->map) {
3704  *rint = -1;
3705  return;
3706  }
3707 
3708  *rint = cast_spell(op, caster, dir, sp, str);
3709 }
3710 
3711 static void cfapi_object_learn_spell(int *type, ...) {
3712  object *op;
3713  object *sp;
3714  int prayer;
3715  va_list args;
3716 
3717  va_start(args, type);
3718  op = va_arg(args, object *);
3719  sp = va_arg(args, object *);
3720  prayer = va_arg(args, int);
3721  va_end(args);
3722  do_learn_spell(op, sp, prayer);
3723  *type = CFAPI_NONE;
3724 }
3725 
3726 static void cfapi_object_forget_spell(int *type, ...) {
3727  object *op;
3728  object *sp;
3729  va_list args;
3730  char name[MAX_BUF];
3731 
3732  va_start(args, type);
3733  op = va_arg(args, object *);
3734  sp = va_arg(args, object *);
3735  va_end(args);
3736  query_name(sp, name, MAX_BUF);
3737  do_forget_spell(op, name);
3738  *type = CFAPI_NONE;
3739 }
3740 
3746 static void cfapi_object_check_spell(int *type, ...) {
3747  object *op;
3748  char *spellname;
3749  va_list args;
3750  object **robj;
3751 
3752  va_start(args, type);
3753  op = va_arg(args, object *);
3754  spellname = va_arg(args, char *);
3755  robj = va_arg(args, object **);
3756  va_end(args);
3757  *robj = check_spell_known(op, spellname);
3758  *type = CFAPI_POBJECT;
3759 }
3760 
3766 static void cfapi_object_pay_amount(int *type, ...) {
3767  object *op;
3768  uint64_t amount;
3769  va_list args;
3770  int *rint;
3771 
3772  va_start(args, type);
3773  op = va_arg(args, object *);
3774  amount = va_arg(args, uint64_t);
3775  rint = va_arg(args, int *);
3776  va_end(args);
3777 
3778  *rint = pay_for_amount(amount, op);
3779  *type = CFAPI_INT;
3780 }
3781 
3787 static void cfapi_object_pay_item(int *type, ...) {
3788  object *op;
3789  object *tobuy;
3790  int *rint;
3791 
3792  va_list args;
3793 
3794  va_start(args, type);
3795  tobuy = va_arg(args, object *);
3796  op = va_arg(args, object *);
3797  rint = va_arg(args, int *);
3798  va_end(args);
3799 
3800  *rint = pay_for_item(tobuy, op, 0);
3801  *type = CFAPI_INT;
3802 }
3803 
3811 static void cfapi_object_transfer(int *type, ...) {
3812  object *op;
3813  object *originator;
3814  int x, y, randompos, ttype, flag;
3815  va_list args;
3816  mapstruct *map;
3817  int *rint;
3818  object **robj;
3819 
3820  va_start(args, type);
3821  op = va_arg(args, object *);
3822  ttype = va_arg(args, int);
3823  switch (ttype) {
3824  case 0:
3825  x = va_arg(args, int);
3826  y = va_arg(args, int);
3827  randompos = va_arg(args, int);
3828  originator = va_arg(args, object *);
3829  rint = va_arg(args, int *);
3830  va_end(args);
3831 
3832  *rint = transfer_ob(op, x, y, randompos, originator);
3833  *type = CFAPI_INT;
3834  return;
3835  break;
3836 
3837  case 1:
3838  map = va_arg(args, mapstruct *);
3839  originator = va_arg(args, object *);
3840  flag = va_arg(args, int);
3841  x = va_arg(args, int);
3842  y = va_arg(args, int);
3843  robj = va_arg(args, object **);
3844  va_end(args);
3845  if (x < 0 || y < 0) {
3846  x = map->enter_x;
3847  y = map->enter_y;
3848  }
3849  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
3850  *type = CFAPI_POBJECT;
3851  return;
3852  break;
3853 
3854  case 2:
3855  x = va_arg(args, int);
3856  y = va_arg(args, int);
3857  rint = va_arg(args, int *);
3858  va_end(args);
3859 
3860  *rint = move_to(op, x, y);
3861  *type = CFAPI_INT;
3862  return;
3863 
3864  default:
3865  va_end(args);
3866  *type = CFAPI_NONE;
3867  return;
3868  break;
3869  }
3870 }
3871 
3876  object *op;
3877  char *str;
3878  va_list args;
3879  object **robj;
3880 
3881  *type = CFAPI_POBJECT;
3882  va_start(args, type);
3883  op = va_arg(args, object *);
3884 
3885  str = va_arg(args, char *);
3886  robj = va_arg(args, object **);
3887  archetype *at = try_find_archetype(str);
3888  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
3889  if (*robj == NULL) {
3890  char name[MAX_BUF];
3891 
3892  /* Search by name or slaying instead */
3893  FOR_INV_PREPARE(op, tmp) {
3894  if (tmp->name) {
3895  query_name(tmp, name, MAX_BUF);
3896  if (!strncmp(name, str, strlen(str)))
3897  *robj = tmp;
3898  if (!strncmp(tmp->name, str, strlen(str)))
3899  *robj = tmp;
3900  }
3901  if (tmp->slaying && !strcmp(tmp->slaying, str))
3902  *robj = tmp;
3903  if (*robj != NULL)
3904  break;
3905  } FOR_INV_FINISH();
3906  }
3907  va_end(args);
3908 }
3909 
3910 static void cfapi_object_find_by_arch_name(int *type, ...) {
3911  const object *who;
3912  object **result;
3913  const char *name;
3914  va_list args;
3915 
3916  va_start(args, type);
3917  who = va_arg(args, const object *);
3918  name = va_arg(args, const char *);
3919  result = va_arg(args, object **);
3920  va_end(args);
3921  *type = CFAPI_POBJECT;
3922 
3923  *result = object_find_by_arch_name(who, name);
3924 }
3925 
3926 static void cfapi_object_find_by_name(int *type, ...) {
3927  const object *who;
3928  object **result;
3929  const char *name;
3930  va_list args;
3931 
3932  va_start(args, type);
3933  who = va_arg(args, const object *);
3934  name = va_arg(args, const char *);
3935  result = va_arg(args, object **);
3936  va_end(args);
3937  *type = CFAPI_POBJECT;
3938 
3939  *result = object_find_by_name(who, name);
3940 }
3941 
3947 static void cfapi_object_drop(int *type, ...) {
3948  object *op;
3949  object *author;
3950  va_list args;
3951 
3952  va_start(args, type);
3953  op = va_arg(args, object *);
3954  author = va_arg(args, object *);
3955  va_end(args);
3956  *type = CFAPI_NONE;
3957 
3958  if (QUERY_FLAG(op, FLAG_NO_DROP))
3959  return;
3960  drop(author, op);
3961 
3962  if (author->type == PLAYER) {
3963  author->contr->count = 0;
3964  author->contr->socket->update_look = 1;
3965  }
3966 }
3967 
3971 static void cfapi_object_change_abil(int *type, ...) {
3972  object *op, *tmp;
3973  int *rint;
3974  va_list args;
3975 
3976  va_start(args, type);
3977  op = va_arg(args, object *);
3978  tmp = va_arg(args, object *);
3979  rint = va_arg(args, int *);
3980  va_end(args);
3981 
3982  *type = CFAPI_INT;
3983  *rint = change_abil(op, tmp);
3984 }
3985 
3986 static void cfapi_object_say(int *type, ...) {
3987  object *op;
3988  char *msg;
3989  va_list args;
3990  int *rint;
3991  char empty[] = "";
3992 
3993  va_start(args, type);
3994  op = va_arg(args, object *);
3995  msg = va_arg(args, char *);
3996  rint = va_arg(args, int *);
3997  va_end(args);
3998 
3999  if (op->type == PLAYER) {
4000  command_say(op, msg == NULL ? empty : msg);
4001  } else {
4002  monster_npc_say(op, msg);
4003  }
4004  *rint = 0;
4005  *type = CFAPI_INT;
4006 }
4007 
4008 /* PLAYER SUBCLASS */
4009 
4015 static void cfapi_player_find(int *type, ...) {
4016  va_list args;
4017  char *sval;
4018  player **rpl;
4019  va_start(args, type);
4020 
4021  sval = va_arg(args, char *);
4022  rpl = va_arg(args, player **);
4023  va_end(args);
4024 
4025  *rpl = find_player_partial_name(sval);
4026 
4027  *type = CFAPI_PPLAYER;
4028 }
4029 
4030 static void cfapi_player_message(int *type, ...) {
4031  va_list args;
4032  int flags;
4033  int pri;
4034  object *pl;
4035  const char *buf;
4036 
4037  va_start(args, type);
4038 
4039  flags = va_arg(args, int);
4040  pri = va_arg(args, int);
4041  pl = va_arg(args, object *);
4042  buf = va_arg(args, const char *);
4043  va_end(args);
4044 
4046  buf);
4047  *type = CFAPI_NONE;
4048 }
4049 
4056 static void cfapi_object_perm_exp(int *type, ...) {
4057  va_list args;
4058  object *op;
4059  int64_t *rlong;
4060 
4061  va_start(args, type);
4062  op = va_arg(args, object *);
4063  rlong = va_arg(args, int64_t *);
4064  va_end(args);
4065 
4066  *type = CFAPI_SINT64;
4067  *rlong = PERM_EXP(op->total_exp);
4068 }
4069 
4075 static void cfapi_object_change_exp(int *type, ...) {
4076  va_list args;
4077  int flag;
4078  object *ob;
4079  const char *skill;
4080  int64_t exp;
4081 
4082  va_start(args, type);
4083  ob = va_arg(args, object *);
4084  exp = va_arg(args, int64_t);
4085  skill = va_arg(args, const char *);
4086  flag = va_arg(args, int);
4087  va_end(args);
4088 
4089  *type = CFAPI_NONE;
4090  change_exp(ob, exp, skill, flag);
4091 }
4092 
4098 static void cfapi_player_can_pay(int *type, ...) {
4099  va_list args;
4100  object *pl;
4101  int *rint;
4102 
4103  va_start(args, type);
4104  pl = va_arg(args, object *);
4105  rint = va_arg(args, int *);
4106  va_end(args);
4107 
4108  *rint = can_pay(pl);
4109  *type = CFAPI_INT;
4110 }
4111 
4117 static void cfapi_player_knowledge(int *type, ...) {
4118  va_list args;
4119  object *pl;
4120  int *rint, what;
4121  const char *knowledge;
4122 
4123  va_start(args, type);
4124  what = va_arg(args, int);
4125 
4126  switch(what)
4127  {
4128  case 1:
4129  pl = va_arg(args, object *);
4130  knowledge = va_arg(args, const char *);
4131  rint = va_arg(args, int *);
4132 
4133  *type = CFAPI_INT;
4134 
4135  if (pl->contr == NULL) {
4136  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4137  *rint = 0;
4138  va_end(args);
4139  return;
4140  }
4141 
4142  *rint = knowledge_player_knows(pl->contr, knowledge);
4143  break;
4144 
4145  case 2:
4146  pl = va_arg(args, object *);
4147  knowledge = va_arg(args, const char *);
4148  *type = CFAPI_NONE;
4149  if (pl->contr != NULL)
4150  knowledge_give(pl->contr, knowledge, NULL);
4151 
4152  break;
4153 
4154  default:
4155  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4156  }
4157 
4158  va_end(args);
4159 }
4160 
4166 static void cfapi_object_teleport(int *type, ...) {
4167  mapstruct *map;
4168  int x, y;
4169  object *who;
4170  int *res;
4171  va_list args;
4172 
4173  va_start(args, type);
4174  who = va_arg(args, object *);
4175  map = va_arg(args, mapstruct *);
4176  x = va_arg(args, int);
4177  y = va_arg(args, int);
4178  res = va_arg(args, int *);
4179  va_end(args);
4180 
4181  *type = CFAPI_INT;
4182  *res = object_teleport(who, map, x, y);
4183 }
4184 
4185 static void cfapi_object_pickup(int *type, ...) {
4186  object *who;
4187  object *what;
4188  va_list args;
4189 
4190  va_start(args, type);
4191  who = va_arg(args, object *);
4192  what = va_arg(args, object *);
4193  int *res = va_arg(args, int *);
4194  va_end(args);
4195 
4196  *type = CFAPI_INT;
4197  *res = pick_up(who, what);
4198 }
4199 
4200 /* Archetype-related functions */
4201 static void cfapi_archetype_get_property(int *type, ...) {
4202  int prop;
4203  archetype *arch;
4204  va_list args;
4205  sstring *rsstring;
4206  archetype **rarch;
4207  object **robject;
4208 
4209  va_start(args, type);
4210  arch = va_arg(args, archetype *);
4211  prop = va_arg(args, int);
4212  switch (prop) {
4213  case CFAPI_ARCH_PROP_NAME:
4214  *type = CFAPI_SSTRING;
4215  rsstring = va_arg(args, sstring *);
4216  *rsstring = arch->name;
4217  break;
4218 
4219  case CFAPI_ARCH_PROP_NEXT:
4220  *type = CFAPI_PARCH;
4221  rarch = va_arg(args, archetype **);
4222  *rarch = get_next_archetype(arch);
4223  break;
4224 
4225  case CFAPI_ARCH_PROP_HEAD:
4226  *type = CFAPI_PARCH;
4227  rarch = va_arg(args, archetype **);
4228  *rarch = arch->head;
4229  break;
4230 
4231  case CFAPI_ARCH_PROP_MORE:
4232  *type = CFAPI_PARCH;
4233  rarch = va_arg(args, archetype **);
4234  *rarch = arch->more;
4235  break;
4236 
4237  case CFAPI_ARCH_PROP_CLONE:
4238  *type = CFAPI_POBJECT;
4239  robject = va_arg(args, object **);
4240  *robject = &arch->clone;
4241  break;
4242 
4243  default:
4244  *type = CFAPI_NONE;
4245  break;
4246  }
4247  va_end(args);
4248 }
4249 
4256 static void cfapi_party_get_property(int *type, ...) {
4257  partylist *party;
4258  int prop;
4259  va_list args;
4260  object *obarg;
4261  sstring *rsstring;
4262  player **rplayer;
4263  partylist **rparty;
4264 
4265  va_start(args, type);
4266  party = va_arg(args, partylist *);
4267  prop = va_arg(args, int);
4268  switch (prop) {
4269  case CFAPI_PARTY_PROP_NAME:
4270  rsstring = va_arg(args, sstring *);
4271  *rsstring = party->partyname;
4272  *type = CFAPI_SSTRING;
4273  break;
4274 
4275  case CFAPI_PARTY_PROP_NEXT:
4276  rparty = va_arg(args, partylist **);
4277  *rparty = (party ? party_get_next(party) : party_get_first());
4278  *type = CFAPI_PPARTY;
4279  break;
4280 
4282  rsstring = va_arg(args, sstring *);
4283  *rsstring = party_get_password(party);
4284  *type = CFAPI_SSTRING;
4285  break;
4286 
4288  *type = CFAPI_PPLAYER;
4289  obarg = va_arg(args, object *);
4290  rplayer = va_arg(args, player **);
4291  *rplayer = (obarg ? obarg->contr : first_player);
4292  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4293  if ((*rplayer)->ob->contr->party == party) {
4294  break;
4295  }
4296  break;
4297 
4298  default:
4299  *type = CFAPI_NONE;
4300  break;
4301  }
4302  va_end(args);
4303 }
4304 
4311 static void cfapi_region_get_property(int *type, ...) {
4312  region *reg;
4313  int prop, *rint;
4314  va_list args;
4316  sstring *rsstring;
4317  region **rregion;
4318 
4319  va_start(args, type);
4320  reg = va_arg(args, region *);
4321  prop = va_arg(args, int);
4322  switch (prop) {
4324  rsstring = va_arg(args, sstring *);
4325  *rsstring = reg->name;
4326  *type = CFAPI_SSTRING;
4327  break;
4328 
4330  rregion = va_arg(args, region **);
4331  *rregion = nullptr;
4332  *type = CFAPI_PREGION;
4333  break;
4334 
4336  rregion = va_arg(args, region **);
4337  *rregion = reg->parent;
4338  *type = CFAPI_PREGION;
4339  break;
4340 
4342  rsstring = va_arg(args, sstring *);
4343  *rsstring = reg->longname;
4344  *type = CFAPI_SSTRING;
4345  break;
4346 
4348  rsstring = va_arg(args, sstring *);
4349  *rsstring = reg->msg;
4350  *type = CFAPI_SSTRING;
4351  break;
4352 
4355  rint = va_arg(args, int*);
4356  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4357  *type = CFAPI_INT;
4358  break;
4359 
4361  rsstring = va_arg(args, sstring *);
4362  *rsstring = reg->jailmap;
4363  *type = CFAPI_SSTRING;
4364  break;
4365 
4366  default:
4367  *type = CFAPI_NONE;
4368  break;
4369  }
4370  va_end(args);
4371 }
4372 
4384 static void cfapi_friendlylist_get_next(int *type, ...) {
4385  object *ob;
4386  va_list args;
4387  object **robject;
4388 
4389  va_start(args, type);
4390  ob = va_arg(args, object *);
4391  robject = va_arg(args, object **);
4392  va_end(args);
4393 
4394  *type = CFAPI_POBJECT;
4395  *robject = get_next_friend(ob);
4396 }
4397 
4398 /*
4399  * Random-map related stuff.
4400  */
4401 
4408 static void cfapi_set_random_map_variable(int *type, ...) {
4409  va_list args;
4410  RMParms *rp;
4411  const char *buf;
4412  int *ret;
4413 
4414  va_start(args, type);
4415  rp = va_arg(args, RMParms *);
4416  buf = va_arg(args, const char *);
4417  ret = va_arg(args, int *);
4418  va_end(args);
4419 
4420  *ret = set_random_map_variable(rp, buf);
4421  *type = CFAPI_INT;
4422 }
4423 
4430 static void cfapi_generate_random_map(int *type, ...) {
4431  va_list args;
4432  const char *name;
4433  RMParms *rp;
4434  char **use_layout;
4435  sstring reset_group;
4436  mapstruct **ret;
4437 
4438  va_start(args, type);
4439  name = va_arg(args, const char *);
4440  rp = va_arg(args, RMParms *);
4441  use_layout = va_arg(args, char **);
4442  reset_group = va_arg(args, sstring);
4443  ret = va_arg(args, mapstruct **);
4444  va_end(args);
4445 
4446  *ret = generate_random_map(name, rp, use_layout, reset_group);
4447 }
4448 
4449 static void cfapi_object_user_event(int *type, ...) {
4450  object *op;
4451  object *activator;
4452  object *third;
4453  const char *message;
4454  int fix;
4455  int *ret;
4456  va_list args;
4457 
4458  va_start(args, type);
4459  op = va_arg(args, object *);
4460  activator = va_arg(args, object *);
4461  third = va_arg(args, object *);
4462  message = va_arg(args, const char *);
4463  fix = va_arg(args, int);
4464  ret = va_arg(args, int *);
4465  va_end(args);
4466 
4467  *ret = events_execute_object_user(op, activator, third, message, fix);
4468  *type = CFAPI_INT;
4469 }
4470 
4473 static void cfapi_player_quest(int *type, ...) {
4474  int op;
4475  va_list args;
4476  object *player;
4477  sstring code;
4478 
4479  va_start(args, type);
4480  op = va_arg(args, int);
4481  player = va_arg(args, object *);
4482  code = va_arg(args, sstring);
4483 
4484  if (player->contr == NULL) {
4485  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4486  va_end(args);
4487  /* crash/quit? */
4488  return;
4489  }
4490 
4491  switch(op) {
4492  case CFAPI_PLAYER_QUEST_START: {
4493  int state = va_arg(args, int);
4494  quest_start(player->contr, code, state);
4495  *type = CFAPI_NONE;
4496  break;
4497  }
4499  int *ret = va_arg(args, int *);
4500  *ret = quest_get_player_state(player->contr, code);
4501  *type = CFAPI_INT;
4502  break;
4503  }
4505  int state = va_arg(args, int);
4506  quest_set_player_state(player->contr, code, state);
4507  *type = CFAPI_NONE;
4508  break;
4509  }
4511  int *ret = va_arg(args, int*);
4512  *ret = quest_was_completed(player->contr, code);
4513  *type = CFAPI_INT;
4514  break;
4515  }
4516  default:
4517  LOG(llevError, "invalid quest type: %d\n", op);
4518  *type = CFAPI_NONE;
4519  }
4520 
4521  va_end(args);
4522 }
4523 
4524 static void cfapi_register_command(int *type, ...) {
4525  va_list args;
4526  const char *name = NULL, *extra = NULL;
4527  float time;
4528  command_function func = NULL;
4529  command_function_extra func_extra = NULL;
4530  uint8_t register_type, command_type;
4532 
4533  va_start(args, type);
4534  register_type = va_arg(args, int);
4535  name = va_arg(args, const char *);
4536  if (register_type == 1) {
4537  func = va_arg(args, command_function);
4538  } else {
4539  extra = va_arg(args, const char *);
4540  func_extra = va_arg(args, command_function_extra);
4541  }
4542  command_type = (uint8_t)va_arg(args, int);
4543  if (command_type > COMMAND_TYPE_WIZARD) {
4544  command_type = COMMAND_TYPE_NORMAL;
4545  }
4546  time = va_arg(args, double);
4547  cr = va_arg(args, command_registration *);
4548  va_end(args);
4549 
4550  if (register_type == 1) {
4551  (*cr) = command_register(name, command_type, func, time);
4552  } else {
4553  (*cr) = command_register_extra(name, extra, command_type, func_extra, time);
4554  }
4555 
4556  *type = CFAPI_SINT64;
4557 }
4558 
4559 static void cfapi_unregister_command(int *type, ...) {
4560  va_list args;
4562 
4563  va_start(args, type);
4564  cr = va_arg(args, command_registration);
4565  va_end(args);
4566 
4567  command_unregister(cr);
4568 }
4569 
4570 /*****************************************************************************/
4571 /* NEW PLUGIN STUFF ENDS HERE */
4572 /*****************************************************************************/
4573 
4574 
4579 void initPlugins(void) {
4580  struct dirent *currentfile;
4581  DIR *plugdir;
4582  size_t l;
4583  char buf[sizeof(LIBDIR) + 9 + sizeof(dirent::d_name)];
4584 
4585  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4586  LOG(llevDebug, "plugins: loading from %s\n", buf);
4587 
4588  plugdir = opendir(buf);
4589  if (plugdir == NULL)
4590  return;
4591 
4592  while ((currentfile = readdir(plugdir)) != NULL) {
4593  l = strlen(currentfile->d_name);
4594  if (l > strlen(PLUGIN_SUFFIX)) {
4595  int ignore = 0;
4596 
4597  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4598  continue;
4599 
4600  for (auto disable = serverSettings.disabled_plugins.cbegin(); disable != serverSettings.disabled_plugins.cend(); ++disable) {
4601  if (strcmp(disable->c_str(), "All") == 0) {
4602  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4603  ignore = 1;
4604  break;
4605  }
4606  if (strncmp(disable->c_str(), currentfile->d_name, disable->length()) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + disable->length()) {
4607  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4608  ignore = 1;
4609  break;
4610  }
4611  }
4612  if (ignore == 0) {
4613  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4614  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4616  }
4617  }
4618  }
4619 
4620  closedir(plugdir);
4621 }
4622 
4627 void cleanupPlugins(void) {
4628  for (crossfire_plugin *cp : plugins_list) {
4629  if (cp->closefunc)
4630  cp->closefunc();
4631  /* Don't actually unload plugins, it makes backtraces for memory
4632  * debugging (printed at exit) messed up. And it doesn't matter if we
4633  * don't free it here. The OS will do it for us.
4634  */
4635  /* plugins_dlclose(cp->libptr); */
4636  free(cp);
4637  }
4638  plugins_list.clear();
4639 }
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:173
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:3811
cfapi_object_clean_object
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.cpp:3571
cfapi_object_forget_spell
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.cpp:3726
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:1426
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:3442
PLAYER
@ PLAYER
Definition: object.h:112
CFAPI_PPLAYER
#define CFAPI_PPLAYER
Definition: plugin.h:64
object_get_owner
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
Definition: object.cpp:789
Settings::mapdir
const char * mapdir
Where the map files are.
Definition: global.h:252
player::next
player * next
Pointer to next player, NULL if this is last.
Definition: player.h: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:1457
cfapi_timer_destroy
static void cfapi_timer_destroy(int *type,...)
Wrapper for cftimer_destroy().
Definition: plugins.cpp:989
first_player
player * first_player
First player.
Definition: init.cpp:106
settings
struct Settings settings
Global settings.
Definition: init.cpp:139
object::move_status
int32_t move_status
What stage in attack mode.
Definition: object.h:400
object_get_env_recursive
object * object_get_env_recursive(object *op)
Utility function.
Definition: object.cpp:575
CFAPI_POBJECT
#define CFAPI_POBJECT
Definition: plugin.h:58
CFAPI_PARTY_VECTOR
#define CFAPI_PARTY_VECTOR
Pointer to a std::vector<partylist *>
Definition: plugin.h:76
f_plug_postinit
int(* f_plug_postinit)(void)
Function called after the plugin was initialized.
Definition: plugin.h:81
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
remove_friendly_object
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
Definition: friend.cpp:52
CFAPI_OBJECT_VECTOR
#define CFAPI_OBJECT_VECTOR
Pointer to a std::vector<object *>
Definition: plugin.h:72
CFAPI_OBJECT_PROP_CHA
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:203
living::maxhp
int16_t maxhp
Max hit points.
Definition: living.h:41
CFAPI_MAP_PROP_TMPNAME
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h: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:3498
cfapi_object_delete
static void cfapi_object_delete(int *type,...)
Definition: plugins.cpp:3236
cfapi_player_quest
static void cfapi_player_quest(int *type,...)
Quest-related wrappers, for all quest-related operations.
Definition: plugins.cpp:4473
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:272
cfapi_archetype_get_property
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.cpp:4201
NR_EVENTS
#define NR_EVENTS
Number of events, maximum code + 1.
Definition: events.h:74
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
get_empty_map
mapstruct * get_empty_map(int sizex, int sizey)
Creates and returns a map of the specific size.
Definition: map.cpp:852
monster_npc_say
void monster_npc_say(object *npc, const char *cp)
Simple function to have some NPC say something.
Definition: monster.cpp: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:280
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:3947
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:1777
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:278
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:262
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:327
has_been_loaded
mapstruct * has_been_loaded(const char *name)
Checks whether map has been loaded.
Definition: map.cpp:79
map_find_by_archetype
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Searches for any objects with a matching archetype at the given map and coordinates.
Definition: object.cpp:3103
object_merge
object * object_merge(object *op, object *top)
This function goes through all objects below and including top, and merges op to the first matching o...
Definition: object.cpp:2036
player::mark_count
uint32_t mark_count
Count of marked object.
Definition: player.h: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:2147
CFAPI_OBJECT_PROP_DEX
#define CFAPI_OBJECT_PROP_DEX
Definition: plugin.h:198
CFAPI_OBJECT_PROP_FRIENDLY
#define CFAPI_OBJECT_PROP_FRIENDLY
Definition: plugin.h:185
CFAPI_OBJECT_PROP_ARCHETYPE
#define CFAPI_OBJECT_PROP_ARCHETYPE
Definition: plugin.h:181
object::item_power
int8_t item_power
Power rating of the object.
Definition: object.h:372
cfapi_map_out_of_map
static void cfapi_map_out_of_map(int *type,...)
Wrapper for out_of_map().
Definition: plugins.cpp:1297
Settings::datadir
const char * datadir
Read only data files.
Definition: global.h:249
object::arch
struct archetype * arch
Pointer to archetype.
Definition: object.h:424
cast_spell
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Main dispatch when someone casts a spell.
Definition: spell_util.cpp:1424
player::bed_x
int16_t bed_x
Definition: player.h: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:337
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:355
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:320
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:1552
crossfire_plugin::fullname
char fullname[MAX_BUF]
Plugin full name
Definition: plugin.h:100
CFAPI_FUNC
#define CFAPI_FUNC
Definition: plugin.h:63
CFAPI_OBJECT_PROP_STR
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:197
player::transport
object * transport
Transport the player is in.
Definition: player.h: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:3295
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:3128
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:340
CFAPI_PLAYER_PROP_MARKED_ITEM
#define CFAPI_PLAYER_PROP_MARKED_ITEM
Definition: plugin.h:231
SET_ANIMATION
#define SET_ANIMATION(ob, newanim)
Definition: global.h:164
cfapi_object_find_archetype_inside
static void cfapi_object_find_archetype_inside(int *type,...)
Kinda wrapper for arch__present_in_ob().
Definition: plugins.cpp:3875
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:288
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:267
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:1596
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:3986
CFAPI_REGION_PROP_PARENT
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:279
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:278
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:287
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:284
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:266
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:264
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:358
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:4579
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:4384
buf
StringBuffer * buf
Definition: readable.cpp:1565
getManager
AssetsManager * getManager()
Definition: assets.cpp:309
cfapi_object_identify
static void cfapi_object_identify(int *type,...)
Wrapper for identify().
Definition: plugins.cpp:3086
cfapi_map_set_map_property
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.cpp:1267
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
Definition: object.cpp:2842
RMParms
Random map parameters.
Definition: random_map.h:14
object::above
object * above
Pointer to the object stacked above this one.
Definition: object.h:296
crossfire_plugin::libptr
LIBPTRTYPE libptr
Pointer to the plugin library
Definition: plugin.h:98
cfapi_object_user_event
static void cfapi_object_user_event(int *type,...)
Definition: plugins.cpp:4449
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:3519
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:340
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:3971
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:284
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:1507
TIMER_ERR_ID
#define TIMER_ERR_ID
Invalid timer id.
Definition: timers.h:67
MSG_TYPE_COMMAND_DEBUG
#define MSG_TYPE_COMMAND_DEBUG
Various debug type commands.
Definition: newclient.h:532
object::carrying
int32_t carrying
How much weight this object contains.
Definition: object.h:377
plugins_remove_plugin
int plugins_remove_plugin(const char *id)
Unload the specified plugin.
Definition: plugins.cpp:455
CFAPI_OBJECT_PROP_PATH_DENIED
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:152
CFAPI_MAP_PROP_REGION
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:263
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:4524
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:4015
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:268
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:356
cfapi_player_can_pay
static void cfapi_player_can_pay(int *type,...)
Wrapper for can_pay().
Definition: plugins.cpp:4098
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:1348
object::anim_speed
uint8_t anim_speed
Ticks between animation-frames.
Definition: object.h:429
get_weekday
const char * get_weekday(const int index)
give access to weekday names
Definition: time.cpp:120
cfapi_map_create_path
static void cfapi_map_create_path(int *type,...)
Wrapper for create_pathname() and create_overlay_pathname().
Definition: plugins.cpp:1101
CFAPI_OBJECT_PROP_OB_BELOW
#define CFAPI_OBJECT_PROP_OB_BELOW
Definition: plugin.h:121
cfapi_object_apply_below
static void cfapi_object_apply_below(int *type,...)
Applies an object below.
Definition: plugins.cpp:3041
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:4408
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:3146
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:283
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:261
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:4256
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:3746
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:2370
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:279
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:3557
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:286
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:2023
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:2323
region::jailmap
char * jailmap
Where a player that is arrested in this region should be imprisoned.
Definition: map.h:290
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:3215
object_update_speed
void object_update_speed(object *op)
Updates the speed of an object.
Definition: object.cpp:1334
cfapi_system_strdup_local
static void cfapi_system_strdup_local(int *type,...)
Wrapper for strdup_local().
Definition: plugins.cpp:572
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
Definition: global.h:206
crossfire_plugin::id
char id[MAX_BUF]
Plugin identification string
Definition: plugin.h:99
CFAPI_OBJECT_PROP_PATH_ATTUNED
#define CFAPI_OBJECT_PROP_PATH_ATTUNED
Definition: plugin.h:150
events_execute_object_user
int events_execute_object_user(object *op, object *activator, object *third, const char *message, int fix)
Execute an EVENT_USER on the specified object.
Definition: events.cpp:317
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
message
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your message
Definition: survival-guide.txt:34
CFAPI_ARCH_PROP_CLONE
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:270
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:162
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:3198
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:4311
cfapi_unregister_command
static void cfapi_unregister_command(int *type,...)
Definition: plugins.cpp:4559
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:4166
P_NEED_UPDATE
#define P_NEED_UPDATE
This space is out of date.
Definition: map.h:242
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:277
cfapi_object_spring_trap
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.cpp:3598
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:286
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:252
CFAPI_REGION_PROP_JAIL_X
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:282
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:3787
Settings::confdir
const char * confdir
Configuration files.
Definition: global.h:248
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:2351
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:1705
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:4185
CFAPI_SYSTEM_REGIONS
#define CFAPI_SYSTEM_REGIONS
Definition: plugin.h:289
cfapi_object_on_same_map
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.cpp:3582
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:273
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:281
object::move_slow_penalty
float move_slow_penalty
How much this slows down the object.
Definition: object.h:442
Settings::playerdir
const char * playerdir
Where the player files are.
Definition: global.h:251
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp: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:277
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:232
cfapi_map_delete_map
static void cfapi_map_delete_map(int *type,...)
Definition: plugins.cpp:1335
plugins_display_list
void plugins_display_list(object *op)
Displays a list of loaded plugins (keystrings and description) in the game log window.
Definition: plugins.cpp:480
check_trigger
int check_trigger(object *op, object *cause)
Definition: button.cpp:518
CFAPI_SINT64
#define CFAPI_SINT64
Definition: plugin.h:69
CFAPI_PLAYER_PROP_TRANSPORT
#define CFAPI_PLAYER_PROP_TRANSPORT
Definition: plugin.h:238
object::lore
sstring lore
Obscure information about this object, to get put into books and the like.
Definition: object.h:332
llevInfo
@ llevInfo
Information.
Definition: logger.h:12
NDI_UNIQUE
#define NDI_UNIQUE
Print immediately, don't buffer.
Definition: newclient.h:266
object::slaying
sstring slaying
Which race to do double damage to.
Definition: object.h:327
cfapi_map_get_map_property
static void cfapi_map_get_map_property(int *type,...)
Definition: plugins.cpp:1135
object::glow_radius
int8_t glow_radius
indicates the glow radius of the object
Definition: object.h:374
CFAPI_PARTY_PROP_PLAYER
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:275
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:263
object::name
sstring name
The name of the object, obviously...
Definition: object.h:319
cfapi_system_get_region_vector
static void cfapi_system_get_region_vector(int *type,...)
Definition: plugins.cpp:685
cfapi_object_describe
static void cfapi_object_describe(int *type,...)
Wrapper for describe_item().
Definition: plugins.cpp:3106
cfapi_object_give_skill
static void cfapi_object_give_skill(int *type,...)
Definition: plugins.cpp:3181
cfapi_generate_random_map
static void cfapi_generate_random_map(int *type,...)
Wrapper for generate_random_map().
Definition: plugins.cpp:4430
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:3165
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:291
cleanupPlugins
void cleanupPlugins(void)
Call the crossfire_plugin::closefunc on the various plugins, used at server shutdown.
Definition: plugins.cpp:4627
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:326
mapstruct
This is a game-map.
Definition: map.h:318
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:4075
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:321
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:3910
mapstruct::enter_x
int16_t enter_x
Definition: map.h:341
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:2628
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:3334
CFAPI_OBJECT_PROP_DURATION
#define CFAPI_OBJECT_PROP_DURATION
Definition: plugin.h:227
CFAPI_OBJECT_PROP_MOVE_STATUS
#define CFAPI_OBJECT_PROP_MOVE_STATUS
Definition: plugin.h:177
crossfire_plugin
One loaded plugin.
Definition: plugin.h:95
cfapi_map_update_position
static void cfapi_map_update_position(int *type,...)
Wrapper for update_position().
Definition: plugins.cpp:1319
CFAPI_OBJECT_PROP_OTHER_ARCH
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:182
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:1563
CFAPI_OBJECT_PROP_OB_ABOVE
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:120
player::party
partylist * party
Party this player is part of.
Definition: player.h:205
mapstruct::msg
char * msg
Message map creator may have left.
Definition: map.h:354
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:4030
CFAPI_OBJECT_PROP_MOVE_ALLOW
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:222
knowledge_give
void knowledge_give(player *pl, const char *marker, const object *book)
Give a knowledge item from its code.
Definition: knowledge.cpp:996
get_region_by_map
region * get_region_by_map(mapstruct *m)
Gets a region from a map.
Definition: region.cpp:71
CFAPI_ARCH_PROP_MORE
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:269
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:290
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:341
command_registration
uint64_t command_registration
Identifier when registering a command.
Definition: commands.h:32
cfapi_object_set_key
static void cfapi_object_set_key(int *type,...)
Write a key/value for an object.
Definition: plugins.cpp:1529
remove_depletion
int remove_depletion(object *op, int level)
Remove depletion from op, if present, and warn player of such restorations.
Definition: living.cpp:755
cfapi_object_pay_amount
static void cfapi_object_pay_amount(int *type,...)
Wrapper for pay_for_amount().
Definition: plugins.cpp:3766
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:331
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:1925
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:319
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2734
cfapi_object_apply
static void cfapi_object_apply(int *type,...)
Applies an object.
Definition: plugins.cpp:3061
mapstruct::reset_time
uint32_t reset_time
Server time when map gets reset, seconds since epoch.
Definition: map.h:325
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:4056
list
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
Definition: INSTALL_WIN32.txt:50
CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
Definition: plugin.h:226
object::move_allow
MoveType move_allow
What movement types explicitly allowed.
Definition: object.h:438
LogLevel
LogLevel
Log levels for the LOG() function.
Definition: logger.h:10
object_set_value
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
Definition: object.cpp:4484
CFAPI_OBJECT_PROP_MAXGP
#define CFAPI_OBJECT_PROP_MAXGP
Definition: plugin.h:212
CFAPI_OBJECT_PROP_COUNT
#define CFAPI_OBJECT_PROP_COUNT
Definition: plugin.h:129
server.h
CFAPI_OBJECT_PROP_SUBTYPE
#define CFAPI_OBJECT_PROP_SUBTYPE
Definition: plugin.h:146
Settings::tmpdir
const char * tmpdir
Directory to use for temporary files.
Definition: global.h:256
cfapi_player_knowledge
static void cfapi_player_knowledge(int *type,...)
Wrapper for knowledge-related functions().
Definition: plugins.cpp:4117
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:1370
plugins_init_plugin
int plugins_init_plugin(const char *libfile)
Try to load the specified plugin.
Definition: plugins.cpp:374
closedir
int closedir(DIR *)
mapstruct::darkness
uint8_t darkness
Indicates level of darkness of map.
Definition: map.h:339
cfapi_object_cast
static void cfapi_object_cast(int *type,...)
Wrapper for query_money().
Definition: plugins.cpp:3683
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:3664
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:274
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:3475
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:3263
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:3711
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:291
cfapi_map_trigger_connected
static void cfapi_map_trigger_connected(int *type,...)
Wrapper for trigger_connected().
Definition: plugins.cpp:3644
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:3926
region::jailx
int16_t jailx
Definition: map.h:291
cfapi_object_set_property
static void cfapi_object_set_property(int *type,...)
Sets the property of an object.
Definition: plugins.cpp:2387
plugins_dlopen
#define plugins_dlopen(fname)
Load a shared library.
Definition: plugin.h:112
cost_string_from_value
char * cost_string_from_value(uint64_t cost, int largest_coin)
Converts a price to number of coins.
Definition: shop.cpp:220
living::Con
int8_t Con
Definition: living.h:36
CFAPI_OBJECT_PROP_WEIGHT_LIMIT
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:167
face
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn though Notes on Specific and settings file datadir Usually usr share crossfire Contains data that the server does not need to modify while such as the etc A default install will pack the and treasurelist definitions into a single or trs file and the graphics into a face(metadata) and .tar(bitmaps) file
trigger_connected
void trigger_connected(objectlink *ol, object *cause, const int state)
Trigger every object in an objectlink.
Definition: button.cpp:41
Settings::uniquedir
const char * uniquedir
Directory for the unique items.
Definition: global.h:254
living::Str
int8_t Str
Definition: living.h:36
CFAPI_OBJECT_PROP_SPEED_LEFT
#define CFAPI_OBJECT_PROP_SPEED_LEFT
Definition: plugin.h:141
quest_get_player_state
int quest_get_player_state(player *pl, sstring quest_code)
Get the quest state for a player.
Definition: quest.cpp: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:1399
cftimer_create
int cftimer_create(int id, long delay, object *ob, int mode)
Creates a new timer.
Definition: timers.cpp:97
player_get_title
void player_get_title(const player *pl, char *buf, size_t bufsize)
Returns the player's title.
Definition: player.cpp:233
cfapi_object_check_trigger
static void cfapi_object_check_trigger(int *type,...)
Wrapper for check_trigger().
Definition: plugins.cpp:3617
cfapi_object_clear
static void cfapi_object_clear(int *type,...)
Wrapper for object_clear().
Definition: plugins.cpp:3539
identify
object * identify(object *op)
Identifies an item.
Definition: item.cpp:1444
Settings::localdir
const char * localdir
Read/write data files.
Definition: global.h:250