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