Crossfire Server, Trunk  R21670
plugins.c
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 
43 #define NR_OF_HOOKS (sizeof(plug_hooks)/sizeof(*plug_hooks))
44 
45 static void cfapi_cost_string_from_value(int *type, ...);
46 static void cfapi_system_find_animation(int *type, ...);
47 static void cfapi_system_find_face(int *type, ...);
48 static void cfapi_system_strdup_local(int *type, ...);
49 static void cfapi_system_register_global_event(int *type, ...);
50 static void cfapi_system_unregister_global_event(int *type, ...);
51 static void cfapi_system_add_string(int *type, ...);
52 static void cfapi_system_remove_string(int *type, ...);
53 static void cfapi_system_find_string(int *type, ...);
54 static void cfapi_system_check_path(int *type, ...);
55 static void cfapi_system_re_cmp(int *type, ...);
56 static void cfapi_system_directory(int *type, ...);
57 static void cfapi_get_time(int *type, ...);
58 static void cfapi_get_season_name(int *type, ...);
59 static void cfapi_get_weekday_name(int *type, ...);
60 static void cfapi_get_month_name(int *type, ...);
61 static void cfapi_get_periodofday_name(int *type, ...);
62 static void cfapi_timer_create(int *type, ...);
63 static void cfapi_timer_destroy(int *type, ...);
64 static void cfapi_log(int *type, ...);
65 static void cfapi_map_get_map(int *type, ...);
66 static void cfapi_map_has_been_loaded(int *type, ...);
67 static void cfapi_map_create_path(int *type, ...);
68 static void cfapi_map_get_map_property(int *type, ...);
69 static void cfapi_map_set_map_property(int *type, ...);
70 static void cfapi_map_out_of_map(int *type, ...);
71 static void cfapi_map_update_position(int *type, ...);
72 static void cfapi_map_delete_map(int *type, ...);
73 static void cfapi_map_message(int *type, ...);
74 static void cfapi_map_get_object_at(int *type, ...);
75 static void cfapi_map_find_by_archetype_name(int *type, ...);
76 static void cfapi_map_change_light(int *type, ...);
77 static void cfapi_object_move(int *type, ...);
78 static void cfapi_object_get_key(int *type, ...);
79 static void cfapi_object_set_key(int *type, ...);
80 static void cfapi_object_get_property(int *type, ...);
81 static void cfapi_object_set_property(int *type, ...);
82 static void cfapi_object_apply_below(int *type, ...);
83 static void cfapi_object_apply(int *type, ...);
84 static void cfapi_object_identify(int *type, ...);
85 static void cfapi_object_describe(int *type, ...);
86 static void cfapi_object_drain(int *type, ...);
87 static void cfapi_object_remove_depletion(int *type, ...);
88 static void cfapi_object_fix(int *type, ...);
89 static void cfapi_object_give_skill(int *type, ...);
90 static void cfapi_object_transmute(int *type, ...);
91 static void cfapi_object_remove(int *type, ...);
92 static void cfapi_object_delete(int *type, ...);
93 static void cfapi_object_clone(int *type, ...);
94 static void cfapi_object_create(int *type, ...);
95 static void cfapi_object_insert(int *type, ...);
96 static void cfapi_object_split(int *type, ...);
97 static void cfapi_object_merge(int *type, ...);
98 static void cfapi_object_distance(int *type, ...);
99 static void cfapi_object_update(int *type, ...);
100 static void cfapi_object_clear(int *type, ...);
101 static void cfapi_object_reset(int *type, ...);
102 static void cfapi_object_clean_object(int *type, ...);
103 static void cfapi_object_on_same_map(int *type, ...);
104 static void cfapi_object_spring_trap(int *type, ...);
105 static void cfapi_object_check_trigger(int *type, ...);
106 static void cfapi_map_trigger_connected(int *type, ...);
107 static void cfapi_object_query_money(int *type, ...);
108 static void cfapi_object_cast(int *type, ...);
109 static void cfapi_object_learn_spell(int *type, ...);
110 static void cfapi_object_forget_spell(int *type, ...);
111 static void cfapi_object_check_spell(int *type, ...);
112 static void cfapi_object_pay_amount(int *type, ...);
113 static void cfapi_object_pay_item(int *type, ...);
114 static void cfapi_object_transfer(int *type, ...);
115 static void cfapi_object_find_archetype_inside(int *type, ...);
116 static void cfapi_object_find_by_arch_name(int *type, ...);
117 static void cfapi_object_find_by_name(int *type, ...);
118 static void cfapi_object_drop(int *type, ...);
119 static void cfapi_object_change_abil(int *type, ...);
120 static void cfapi_object_say(int *type, ...);
121 static void cfapi_player_find(int *type, ...);
122 static void cfapi_player_message(int *type, ...);
123 static void cfapi_object_change_exp(int *type, ...);
124 static void cfapi_player_can_pay(int *type, ...);
125 static void cfapi_player_knowledge(int *type, ...);
126 static void cfapi_object_teleport(int *type, ...);
127 static void cfapi_object_pickup(int *type, ...);
128 static void cfapi_archetype_get_property(int *type, ...);
129 static void cfapi_party_get_property(int *type, ...);
130 static void cfapi_region_get_property(int *type, ...);
131 static void cfapi_friendlylist_get_next(int *type, ...);
132 static void cfapi_set_random_map_variable(int *type, ...);
133 static void cfapi_generate_random_map(int *type, ...);
134 static void cfapi_object_user_event(int *type, ...);
135 static void cfapi_player_quest(int *type, ...);
136 static void cfapi_object_perm_exp(int *type, ...);
137 
141 static const hook_entry plug_hooks[] = {
142  { cfapi_system_add_string, 0, "cfapi_system_add_string" },
143  { cfapi_system_register_global_event, 1, "cfapi_system_register_global_event" },
144  { cfapi_system_remove_string, 2, "cfapi_system_remove_string" },
145  { cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event" },
146  { cfapi_system_check_path, 4, "cfapi_system_check_path" },
147  { cfapi_system_re_cmp, 5, "cfapi_system_re_cmp" },
148  { cfapi_system_strdup_local, 6, "cfapi_system_strdup_local" },
149  { cfapi_system_directory, 7, "cfapi_system_directory" },
150  { cfapi_system_find_animation, 8, "cfapi_system_find_animation" },
151  { cfapi_object_clean_object, 9, "cfapi_object_clean_object" },
152  { cfapi_object_on_same_map, 10, "cfapi_object_on_same_map" },
153  { cfapi_object_get_key, 11, "cfapi_object_get_key" },
154  { cfapi_object_set_key, 12, "cfapi_object_set_key" },
155  { cfapi_object_get_property, 13, "cfapi_object_get_property" },
156  { cfapi_object_set_property, 14, "cfapi_object_set_property" },
157  { cfapi_object_apply, 15, "cfapi_object_apply" },
158  { cfapi_object_identify, 16, "cfapi_object_identify" },
159  { cfapi_object_describe, 17, "cfapi_object_describe" },
160  { cfapi_object_drain, 18, "cfapi_object_drain" },
161  { cfapi_object_fix, 19, "cfapi_object_fix" },
162  { cfapi_object_give_skill, 20, "cfapi_object_give_skill" },
163  { cfapi_object_transmute, 21, "cfapi_object_transmute" },
164  { cfapi_object_remove, 22, "cfapi_object_remove" },
165  { cfapi_object_delete, 23, "cfapi_object_delete" },
166  { cfapi_object_clone, 24, "cfapi_object_clone" },
167  { cfapi_object_create, 26, "cfapi_object_create" },
168  { cfapi_object_insert, 27, "cfapi_object_insert" },
169  { cfapi_object_split, 28, "cfapi_object_split" },
170  { cfapi_object_merge, 29, "cfapi_object_merge" },
171  { cfapi_object_distance, 30, "cfapi_object_distance" },
172  { cfapi_object_update, 31, "cfapi_object_update" },
173  { cfapi_object_clear, 32, "cfapi_object_clear" },
174  { cfapi_object_reset, 33, "cfapi_object_reset" },
175  { cfapi_object_spring_trap, 35, "cfapi_object_spring_trap" },
176  { cfapi_object_check_trigger, 36, "cfapi_object_check_trigger" },
177  { cfapi_object_query_money, 38, "cfapi_object_query_money" },
178  { cfapi_object_cast, 39, "cfapi_object_cast" },
179  { cfapi_object_learn_spell, 40, "cfapi_object_learn_spell" },
180  { cfapi_object_forget_spell, 41, "cfapi_object_forget_spell" },
181  { cfapi_object_check_spell, 42, "cfapi_object_check_spell" },
182  { cfapi_object_pay_amount, 43, "cfapi_object_pay_amount" },
183  { cfapi_object_pay_item, 44, "cfapi_object_pay_item" },
184  { cfapi_object_transfer, 45, "cfapi_object_transfer" },
185  { cfapi_object_drop, 46, "cfapi_object_drop" },
186  { cfapi_object_change_abil, 47, "cfapi_object_change_abil" },
187  { cfapi_object_find_archetype_inside, 48, "cfapi_object_find_archetype_inside" },
188  { cfapi_object_say, 49, "cfapi_object_say" },
189  { cfapi_map_get_map, 50, "cfapi_map_get_map" },
190  { cfapi_map_has_been_loaded, 51, "cfapi_map_has_been_loaded" },
191  { cfapi_map_create_path, 52, "cfapi_map_create_path" },
192  { cfapi_map_get_map_property, 53, "cfapi_map_get_property" },
193  { cfapi_map_set_map_property, 54, "cfapi_map_set_property" },
194  { cfapi_map_out_of_map, 55, "cfapi_map_out_of_map" },
195  { cfapi_map_update_position, 56, "cfapi_map_update_position" },
196  { cfapi_map_delete_map, 57, "cfapi_map_delete_map" },
197  { cfapi_map_message, 58, "cfapi_map_message" },
198  { cfapi_map_get_object_at, 59, "cfapi_map_get_object_at" },
199  { cfapi_map_change_light, 60, "cfapi_map_change_light" },
200  { cfapi_map_find_by_archetype_name, 61, "cfapi_map_find_by_archetype_name" },
201  { cfapi_player_find, 62, "cfapi_player_find" },
202  { cfapi_player_message, 63, "cfapi_player_message" },
203  { cfapi_object_change_exp, 64, "cfapi_object_change_exp" },
204  { cfapi_object_teleport, 65, "cfapi_object_teleport" },
205  { cfapi_object_pickup, 67, "cfapi_object_pickup" },
206  { cfapi_object_move, 68, "cfapi_object_move" },
207  { cfapi_object_apply_below, 69, "cfapi_object_apply_below" },
208  { cfapi_generate_random_map, 70, "cfapi_generate_random_map" },
209  { cfapi_archetype_get_property, 71, "cfapi_archetype_get_property" },
210  { cfapi_party_get_property, 72, "cfapi_party_get_property" },
211  { cfapi_region_get_property, 73, "cfapi_region_get_property" },
212  { cfapi_player_can_pay, 74, "cfapi_player_can_pay" },
213  { cfapi_log, 75, "cfapi_log" },
214  { cfapi_get_time, 76, "cfapi_system_get_time" },
215  { cfapi_timer_create, 77, "cfapi_system_timer_create" },
216  { cfapi_timer_destroy, 78, "cfapi_system_timer_destroy" },
217  { cfapi_friendlylist_get_next, 79, "cfapi_friendlylist_get_next" },
218  { cfapi_set_random_map_variable, 80, "cfapi_set_random_map_variable" },
219  { cfapi_system_find_face, 81, "cfapi_system_find_face" },
220  { cfapi_get_season_name, 82, "cfapi_system_get_season_name" },
221  { cfapi_get_month_name, 83, "cfapi_system_get_month_name" },
222  { cfapi_get_weekday_name, 84, "cfapi_system_get_weekday_name" },
223  { cfapi_get_periodofday_name, 85, "cfapi_system_get_periodofday_name" },
224  { cfapi_map_trigger_connected, 86, "cfapi_map_trigger_connected" },
225  { cfapi_object_user_event, 87, "cfapi_object_user_event" },
226  { cfapi_system_find_string, 88, "cfapi_system_find_string" },
227  { cfapi_cost_string_from_value, 90, "cfapi_cost_string_from_value" },
228  { cfapi_player_quest, 91, "cfapi_player_quest" },
229  { cfapi_object_remove_depletion, 92, "cfapi_object_remove_depletion" },
230  { cfapi_object_find_by_arch_name, 93, "cfapi_object_find_by_arch_name" },
231  { cfapi_object_find_by_name, 94, "cfapi_object_find_by_name" },
232  { cfapi_player_knowledge, 95, "cfapi_player_knowledge" },
233  { cfapi_object_perm_exp, 96, "cfapi_object_perm_exp" },
234 };
235 
238 
239 /*****************************************************************************/
240 /* NEW PLUGIN STUFF STARTS HERE */
241 /*****************************************************************************/
242 
248 static crossfire_plugin *plugins_find_plugin(const char *id) {
249  crossfire_plugin *cp;
250 
251  if (plugins_list == NULL)
252  return NULL;
253 
254  for (cp = plugins_list; cp != NULL; cp = cp->next) {
255  if (!strcmp(id, cp->id)) {
256  return cp;
257  }
258  }
259  return NULL;
260 }
261 
262 #ifdef WIN32
263 static const char *plugins_dlerror(void) {
264  static char buf[256];
265  DWORD err;
266  char *p;
267 
268  err = GetLastError();
269  if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof(buf), NULL) == 0)
270  snprintf(buf, sizeof(buf), "error %lu", err);
271  p = strchr(buf, '\0');
272  while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
273  p--;
274  *p = '\0';
275  return buf;
276 }
277 #endif /* WIN32 */
278 
284 static void send_changed_object(object *op) {
285  object *tmp;
286  player *pl;
287 
288  if (op->env != NULL) {
289  tmp = object_get_player_container(op->env);
290  if (!tmp) {
291  for (pl = first_player; pl; pl = pl->next)
292  if (pl->ob->container == op->env)
293  break;
294  if (pl)
295  tmp = pl->ob;
296  else
297  tmp = NULL;
298  }
299  if (tmp)
300  /* We don't know what changed, so we send everything. */
301  esrv_update_item(UPD_ALL, tmp, op);
302  } else {
303  FOR_ABOVE_PREPARE(op, tmp)
304  if (tmp->type == PLAYER)
305  tmp->contr->socket.update_look = 1;
307  }
308 }
309 
310 int user_event(object *op, object *activator, object *third, const char *message, int fix) {
311  return execute_event(op, EVENT_USER, activator, third, message, fix);
312 }
313 
314 static int do_execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix, talk_info *talk) {
315  crossfire_plugin *plugin;
316  int rv = 0;
317 
318  FOR_INV_PREPARE(op, tmp) {
319  if (tmp->type == EVENT_CONNECTOR && tmp->subtype == eventcode) {
320 #ifdef PLUGIN_DEBUG
321  LOG(llevDebug, "********** EVENT HANDLER **********\n");
322  LOG(llevDebug, " - Who am I :%s\n", op->name);
323  if (activator != NULL)
324  LOG(llevDebug, " - Activator :%s\n", activator->name);
325  if (third != NULL)
326  LOG(llevDebug, " - Other object :%s\n", third->name);
327  LOG(llevDebug, " - Event code :%d\n", tmp->subtype);
328  if (tmp->title != NULL)
329  LOG(llevDebug, " - Event plugin :%s\n", tmp->title);
330  if (tmp->slaying != NULL)
331  LOG(llevDebug, " - Event hook :%s\n", tmp->slaying);
332  if (tmp->name != NULL)
333  LOG(llevDebug, " - Event options :%s\n", tmp->name);
334 #endif
335 
336  if (tmp->title == NULL) {
337  object *env = object_get_env_recursive(tmp);
338  LOG(llevError, "Event object without title at %d/%d in map %s\n", env->x, env->y, env->map->name);
339  object_remove(tmp);
341  } else if (tmp->slaying == NULL) {
342  object *env = object_get_env_recursive(tmp);
343  LOG(llevError, "Event object without slaying at %d/%d in map %s\n", env->x, env->y, env->map->name);
344  object_remove(tmp);
346  } else {
347  plugin = plugins_find_plugin(tmp->title);
348  if (plugin == NULL) {
349  object *env = object_get_env_recursive(tmp);
350  LOG(llevError, "The requested plugin doesn't exist: %s at %d/%d in map %s\n", tmp->title, env->x, env->y, env->map->name);
351  object_remove(tmp);
353  } else {
354  int rvt = 0;
355  int rv;
356 
357  tag_t oldtag = op->count;
358  rv = plugin->eventfunc(&rvt, op, activator, third, message, fix, tmp, talk);
359  if (object_was_destroyed(op, oldtag)) {
360  return rv;
361  }
362  if (QUERY_FLAG(tmp, FLAG_UNIQUE)) {
363 #ifdef PLUGIN_DEBUG
364  LOG(llevDebug, "Removing unique event %s\n", tmp->slaying);
365 #endif
366  object_remove(tmp);
368  }
369  return rv;
370  }
371  }
372  }
373  } FOR_INV_FINISH();
374  return rv;
375 }
376 
377 int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix) {
378  return do_execute_event(op, eventcode, activator, third, message, fix, NULL);
379 }
380 
381 int plugin_event_say(object *npc, talk_info *talk) {
382  return do_execute_event(npc, EVENT_SAY, talk->who, NULL, talk->text, SCRIPT_FIX_ALL, talk);
383 }
384 
385 int execute_global_event(int eventcode, ...) {
386  va_list args;
387  mapstruct *map;
388  object *op;
389  object *op2;
390  player *pl;
391  const char *buf;
392  int i, rt;
393  crossfire_plugin *cp;
394 
395  if (plugins_list == NULL)
396  return -1;
397 
398  va_start(args, eventcode);
399 
400  switch (eventcode) {
401  case EVENT_BORN:
402  /*BORN: op*/
403  op = va_arg(args, object *);
404  for (cp = plugins_list; cp != NULL; cp = cp->next) {
405  if (cp->gevent[eventcode] != NULL)
406  cp->gevent[eventcode](&rt, eventcode, op);
407  }
408  break;
409 
410  case EVENT_CLOCK:
411  /*CLOCK: -*/
412  for (cp = plugins_list; cp != NULL; cp = cp->next) {
413  if (cp->gevent[eventcode] != NULL)
414  cp->gevent[eventcode](&rt, eventcode);
415  }
416  break;
417 
418  case EVENT_CRASH:
419  for (cp = plugins_list; cp != NULL; cp = cp->next) {
420  if (cp->gevent[eventcode] != NULL)
421  cp->gevent[eventcode](&rt, eventcode);
422  }
423  break;
424 
425  case EVENT_PLAYER_DEATH:
426  /*PLAYER_DEATH: op*/
427  op = va_arg(args, object *);
428  op2 = va_arg(args, object *);
429  for (cp = plugins_list; cp != NULL; cp = cp->next) {
430  if (cp->gevent[eventcode] != NULL)
431  cp->gevent[eventcode](&rt, eventcode, op, op2);
432  }
433  break;
434 
435  case EVENT_GKILL:
436  /*GKILL: op, hitter*/
437  op = va_arg(args, object *);
438  op2 = va_arg(args, object *);
439  for (cp = plugins_list; cp != NULL; cp = cp->next) {
440  if (cp->gevent[eventcode] != NULL)
441  cp->gevent[eventcode](&rt, eventcode, op, op2);
442  }
443  break;
444 
445  case EVENT_LOGIN:
446  /*LOGIN: pl, pl->socket.host*/
447  pl = va_arg(args, player *);
448  buf = va_arg(args, char *);
449  for (cp = plugins_list; cp != NULL; cp = cp->next) {
450  if (cp->gevent[eventcode] != NULL)
451  cp->gevent[eventcode](&rt, eventcode, pl, buf);
452  }
453  break;
454 
455  case EVENT_LOGOUT:
456  /*LOGOUT: pl, pl->socket.host*/
457  pl = va_arg(args, player *);
458  buf = va_arg(args, char *);
459  for (cp = plugins_list; cp != NULL; cp = cp->next) {
460  if (cp->gevent[eventcode] != NULL)
461  cp->gevent[eventcode](&rt, eventcode, pl, buf);
462  }
463  break;
464 
465  case EVENT_MAPENTER:
466  /*MAPENTER: op, map*/
467  op = va_arg(args, object *);
468  map = va_arg(args, mapstruct *);
469  for (cp = plugins_list; cp != NULL; cp = cp->next) {
470  if (cp->gevent[eventcode] != NULL)
471  cp->gevent[eventcode](&rt, eventcode, op, map);
472  }
473  break;
474 
475  case EVENT_MAPLEAVE:
476  /*MAPLEAVE: op, map*/
477  op = va_arg(args, object *);
478  map = va_arg(args, mapstruct *);
479  for (cp = plugins_list; cp != NULL; cp = cp->next) {
480  if (cp->gevent[eventcode] != NULL)
481  cp->gevent[eventcode](&rt, eventcode, op, map);
482  }
483  break;
484 
485  case EVENT_MAPRESET:
486  /*MAPRESET: map*/
487  map = va_arg(args, mapstruct *);
488  for (cp = plugins_list; cp != NULL; cp = cp->next) {
489  if (cp->gevent[eventcode] != NULL)
490  cp->gevent[eventcode](&rt, eventcode, map);
491  }
492  break;
493 
494  case EVENT_REMOVE:
495  /*REMOVE: op*/
496  op = va_arg(args, object *);
497  for (cp = plugins_list; cp != NULL; cp = cp->next) {
498  if (cp->gevent[eventcode] != NULL)
499  cp->gevent[eventcode](&rt, eventcode, op);
500  }
501  break;
502 
503  case EVENT_SHOUT:
504  /*SHOUT: op, parms, priority*/
505  op = va_arg(args, object *);
506  buf = va_arg(args, char *);
507  i = va_arg(args, int);
508  for (cp = plugins_list; cp != NULL; cp = cp->next) {
509  if (cp->gevent[eventcode] != NULL)
510  cp->gevent[eventcode](&rt, eventcode, op, buf, i);
511  }
512  break;
513 
514  case EVENT_TELL:
515  /* Tell: who, what, to who */
516  op = va_arg(args, object *);
517  buf = va_arg(args, const char *);
518  op2 = va_arg(args, object *);
519  for (cp = plugins_list; cp != NULL; cp = cp->next) {
520  if (cp->gevent[eventcode] != NULL)
521  cp->gevent[eventcode](&rt, eventcode, op, buf, op2);
522  }
523  break;
524 
525  case EVENT_MUZZLE:
526  /*MUZZLE: op, parms*/
527  op = va_arg(args, object *);
528  buf = va_arg(args, char *);
529  for (cp = plugins_list; cp != NULL; cp = cp->next) {
530  if (cp->gevent[eventcode] != NULL)
531  cp->gevent[eventcode](&rt, eventcode, op, buf);
532  }
533  break;
534 
535  case EVENT_KICK:
536  /*KICK: op, parms*/
537  op = va_arg(args, object *);
538  buf = va_arg(args, char *);
539  for (cp = plugins_list; cp != NULL; cp = cp->next) {
540  if (cp->gevent[eventcode] != NULL)
541  cp->gevent[eventcode](&rt, eventcode, op, buf);
542  }
543  break;
544 
545  case EVENT_MAPUNLOAD:
546  /*MAPUNLOAD: map*/
547  map = va_arg(args, mapstruct *);
548  for (cp = plugins_list; cp != NULL; cp = cp->next) {
549  if (cp->gevent[eventcode] != NULL)
550  cp->gevent[eventcode](&rt, eventcode, map);
551  }
552  break;
553 
554  case EVENT_MAPLOAD:
555  /*MAPLOAD: map*/
556  map = va_arg(args, mapstruct *);
557  for (cp = plugins_list; cp != NULL; cp = cp->next) {
558  if (cp->gevent[eventcode] != NULL)
559  cp->gevent[eventcode](&rt, eventcode, map);
560  }
561  break;
562  }
563  va_end(args);
564  return 0;
565 }
566 
567 static void cfapi_get_hooks(int *type, ...) {
568  va_list args;
569  int request_type;
570  char *buf;
571  f_plug_api *rapi;
572 
573  *type = CFAPI_NONE;
574 
575  va_start(args, type);
576  request_type = va_arg(args, int);
577  if (request_type == 0) { /* By nr */
578  size_t fid;
579 
580  fid = va_arg(args, int);
581  rapi = va_arg(args, f_plug_api *);
582  if (fid >= NR_OF_HOOKS) {
583  *rapi = NULL;
584  *type = CFAPI_NONE;
585  } else {
586  *rapi = plug_hooks[fid].func;
587  *type = CFAPI_FUNC;
588  }
589  } else { /* by name */
590  size_t i;
591 
592  buf = va_arg(args, char *);
593  rapi = va_arg(args, f_plug_api *);
594  *rapi = NULL;
595  *type = CFAPI_NONE;
596  for (i = 0; i < NR_OF_HOOKS; i++) {
597  if (!strcmp(buf, plug_hooks[i].fname)) {
598  *rapi = plug_hooks[i].func;
599  *type = CFAPI_FUNC;
600  break;
601  }
602  }
603  }
604  va_end(args);
605 }
606 
613 int plugins_init_plugin(const char *libfile) {
614  LIBPTRTYPE ptr;
615  f_plug_init initfunc;
616  f_plug_property propfunc;
617  f_plug_event eventfunc;
618  f_plug_postinit postfunc;
619  f_plug_postinit closefunc;
620  int i;
621  crossfire_plugin *cp;
622  crossfire_plugin *ccp;
623  char *svn_rev;
624 
625 
626  /* Open the plugin lib and load the required functions */
627  ptr = plugins_dlopen(libfile);
628  if (ptr == NULL) {
629  LOG(llevError, "Error trying to load %s: %s\n", libfile, plugins_dlerror());
630  return -1;
631  }
632  svn_rev = (char*) plugins_dlsym(ptr, "SvnRevPlugin");
633  if (svn_rev == NULL) {
634  LOG(llevError, "Unable to find SvnRevPlugin in %s\n", libfile);
635  plugins_dlclose(ptr);
636  return -1;
637  }
638  if (settings.ignore_plugin_compatibility == 0 && strcmp(svn_rev, SVN_REV)) {
639  LOG(llevError, "SVN Version mismatch in in %s (%s != %s)\n", libfile, svn_rev, SVN_REV);
640  plugins_dlclose(ptr);
641  return -1;
642  }
643 
644  initfunc = (f_plug_init)plugins_dlsym(ptr, "initPlugin");
645  if (initfunc == NULL) {
646  LOG(llevError, "Plugin error while requesting %s.initPlugin: %s\n", libfile, plugins_dlerror());
647  plugins_dlclose(ptr);
648  return -1;
649  }
650  propfunc = (f_plug_property)plugins_dlsym(ptr, "getPluginProperty");
651  if (propfunc == NULL) {
652  LOG(llevError, "Plugin error while requesting %s.getPluginProperty: %s\n", libfile, plugins_dlerror());
653  plugins_dlclose(ptr);
654  return -1;
655  }
656  eventfunc = (f_plug_event)plugins_dlsym(ptr, "eventListener");
657  if (eventfunc == NULL) {
658  LOG(llevError, "Plugin error while requesting %s.eventListener: %s\n", libfile, plugins_dlerror());
659  plugins_dlclose(ptr);
660  return -1;
661  }
662  postfunc = (f_plug_postinit)plugins_dlsym(ptr, "postInitPlugin");
663  if (postfunc == NULL) {
664  LOG(llevError, "Plugin error while requesting %s.postInitPlugin: %s\n", libfile, plugins_dlerror());
665  plugins_dlclose(ptr);
666  return -1;
667  }
668  closefunc = (f_plug_postinit)plugins_dlsym(ptr, "closePlugin");
669  if (closefunc == NULL) {
670  LOG(llevError, "Plugin error while requesting %s.closePlugin: %s\n", libfile, plugins_dlerror());
671  plugins_dlclose(ptr);
672  return -1;
673  }
674  i = initfunc("2.0", cfapi_get_hooks);
675  cp = malloc(sizeof(crossfire_plugin));
676  for (i = 0; i < NR_EVENTS; i++)
677  cp->gevent[i] = NULL;
678  cp->eventfunc = eventfunc;
679  cp->propfunc = propfunc;
680  cp->closefunc = closefunc;
681  cp->libptr = ptr;
682  propfunc(&i, "Identification", cp->id, sizeof(cp->id));
683  propfunc(&i, "FullName", cp->fullname, sizeof(cp->fullname));
684  cp->next = NULL;
685  cp->prev = NULL;
686  if (plugins_list == NULL) {
687  plugins_list = cp;
688  } else {
689  for (ccp = plugins_list; ccp->next != NULL; ccp = ccp->next)
690  ;
691  ccp->next = cp;
692  cp->prev = ccp;
693  }
694  postfunc();
695  return 0;
696 }
697 
704 int plugins_remove_plugin(const char *id) {
705  crossfire_plugin *cp;
706 
707  if (plugins_list == NULL)
708  return -1;
709 
710  for (cp = plugins_list; cp != NULL; cp = cp->next) {
711  if (!strcmp(id, cp->id)) {
712  crossfire_plugin *n;
713  crossfire_plugin *p;
714 
715  n = cp->next;
716  p = cp->prev;
717  if (cp->closefunc)
718  cp->closefunc();
719  plugins_dlclose(cp->libptr);
720  if (n != NULL) {
721  if (p != NULL) {
722  n->prev = p;
723  p->next = n;
724  } else {
725  n->prev = NULL;
726  plugins_list = n;
727  }
728  } else {
729  if (p != NULL)
730  p->next = NULL;
731  else
732  plugins_list = NULL;
733  }
734  free(cp);
735  return 0;
736  }
737  }
738  return -1;
739 }
740 
746 void plugins_display_list(object *op) {
747  crossfire_plugin *cp;
748 
750  "List of loaded plugins:\n-----------------------");
751 
752  if (plugins_list == NULL)
753  return;
754 
755  for (cp = plugins_list; cp != NULL; cp = cp->next) {
757  "%s, %s",
758  cp->id, cp->fullname);
759  }
760 }
761 
762 /* SYSTEM-RELATED HOOKS */
763 
769 static void cfapi_cost_string_from_value(int *type, ...) {
770  uint64_t cost;
771  char *buffer, *final;
772  int length, largest_coin;
773  va_list args;
774 
775  va_start(args, type);
776  cost = va_arg(args, uint64_t);
777  largest_coin = va_arg(args, int);
778  buffer = va_arg(args, char*);
779  length = va_arg(args, int);
780  va_end(args);
781 
782  *type = CFAPI_NONE;
783 
784  if (length < 1)
785  return;
786 
787  final = cost_string_from_value(cost, largest_coin);
788 
789  strncpy(buffer, final, length - 1);
790  buffer[length - 1] = '\0';
791  free(final);
792 }
793 
799 static void cfapi_system_find_animation(int *type, ...) {
800  va_list args;
801  const char *name;
802  int *num;
803  const Animations *anim;
804 
805  va_start(args, type);
806  name = va_arg(args, const char *);
807  num = va_arg(args, int *);
808  va_end(args);
809 
810  anim = try_find_animation(name);
811  (*num) = anim ? anim->num : 0;
812  *type = CFAPI_INT;
813 }
814 
820 static void cfapi_system_find_face(int *type, ...) {
821  va_list args;
822  const char *face;
823  int error;
824  int *num;
825  const Face *f;
826 
827  va_start(args, type);
828  face = va_arg(args, const char *);
829  error = va_arg(args, int);
830  num = va_arg(args, int *);
831  va_end(args);
832 
833  f = find_face(face, get_face_by_id(error));
834  (*num) = f ? f->number : 0;
835  *type = CFAPI_INT;
836 }
837 
843 static void cfapi_system_strdup_local(int *type, ...) {
844  va_list args;
845  const char *txt;
846  char **ret;
847 
848  va_start(args, type);
849  txt = va_arg(args, const char *);
850  ret = va_arg(args, char **);
851  va_end(args);
852 
853  *ret = strdup_local(txt);
854  *type = CFAPI_STRING;
855 }
856 
857 static void cfapi_system_register_global_event(int *type, ...) {
858  va_list args;
859  int eventcode;
860  char *pname;
861  f_plug_event hook;
862  crossfire_plugin *cp;
863 
864  va_start(args, type);
865  eventcode = va_arg(args, int);
866  pname = va_arg(args, char *);
867  hook = va_arg(args, f_plug_event);
868  va_end(args);
869 
870  *type = CFAPI_NONE;
871 
872  cp = plugins_find_plugin(pname);
873  cp->gevent[eventcode] = hook;
874 }
875 
876 static void cfapi_system_unregister_global_event(int *type, ...) {
877  va_list args;
878  int eventcode;
879  char *pname;
880  crossfire_plugin *cp;
881 
882  va_start(args, type);
883  eventcode = va_arg(args, int);
884  pname = va_arg(args, char *);
885  va_end(args);
886 
887  *type = CFAPI_NONE;
888 
889  cp = plugins_find_plugin(pname);
890  cp->gevent[eventcode] = NULL;
891 }
892 
899 static void cfapi_system_add_string(int *type, ...) {
900  va_list args;
901  const char *str;
902  sstring *rv;
903 
904  va_start(args, type);
905  str = va_arg(args, const char *);
906  rv = va_arg(args, sstring *);
907  va_end(args);
908 
909  *rv = add_string(str);
910  *type = CFAPI_SSTRING;
911 }
912 
919 static void cfapi_system_remove_string(int *type, ...) {
920  va_list args;
921  sstring str;
922 
923  va_start(args, type);
924  str = va_arg(args, sstring);
925  va_end(args);
926 
927  free_string(str);
928  *type = CFAPI_NONE;
929 }
930 
937 static void cfapi_system_find_string(int *type, ...) {
938  va_list args;
939  const char *str;
940  sstring *rv;
941 
942  va_start(args, type);
943  str = va_arg(args, const char *);
944  rv = va_arg(args, sstring *);
945  va_end(args);
946 
947  *rv = find_string(str);
948  *type = CFAPI_SSTRING;
949 }
950 
956 static void cfapi_system_check_path(int *type, ...) {
957  va_list args;
958  const char *name;
959  int prepend_dir;
960  int *ret;
961 
962  va_start(args, type);
963 
964  name = va_arg(args, char *);
965  prepend_dir = va_arg(args, int);
966  ret = va_arg(args, int *);
967 
968  *ret = check_path(name, prepend_dir);
969 
970  va_end(args);
971  *type = CFAPI_INT;
972 }
973 
979 static void cfapi_system_re_cmp(int *type, ...) {
980  va_list args;
981  const char *str;
982  const char *regexp;
983  const char **rv;
984 
985  va_start(args, type);
986 
987  str = va_arg(args, char *);
988  regexp = va_arg(args, char *);
989  rv = va_arg(args, const char **);
990 
991  *rv = re_cmp(str, regexp);
992 
993  va_end(args);
994  *type = CFAPI_STRING;
995 }
996 
997 static void cfapi_system_directory(int *type, ...) {
998  va_list args;
999  int dirtype;
1000  const char **str;
1001 
1002  va_start(args, type);
1003 
1004  dirtype = va_arg(args, int);
1005  str = va_arg(args, const char **);
1006  va_end(args);
1007 
1008  *type = CFAPI_STRING;
1009 
1010  switch (dirtype) {
1011  case 0:
1012  *str = settings.mapdir;
1013  break;
1014 
1015  case 1:
1016  *str = settings.uniquedir;
1017  break;
1018 
1019  case 2:
1020  *str = settings.tmpdir;
1021  break;
1022 
1023  case 3:
1024  *str = settings.confdir;
1025  break;
1026 
1027  case 4:
1028  *str = settings.localdir;
1029  break;
1030 
1031  case 5:
1032  *str = settings.playerdir;
1033  break;
1034 
1035  case 6:
1036  *str = settings.datadir;
1037  break;
1038 
1039  default:
1040  *str = NULL;
1041  }
1042 }
1043 
1050 static void cfapi_get_time(int *type, ...) {
1051  va_list args;
1052  timeofday_t *tod;
1053 
1054  va_start(args, type);
1055  tod = va_arg(args, timeofday_t *);
1056  va_end(args);
1057 
1058  get_tod(tod);
1059  *type = CFAPI_NONE;
1060 }
1061 
1062 #define string_get_int(name) \
1063  va_list args; \
1064  int index; \
1065  const char **str; \
1066  va_start(args, type); \
1067  index = va_arg(args, int); \
1068  str = va_arg(args, const char **); \
1069  va_end(args); \
1070  *str = name(index); \
1071  *type = CFAPI_STRING; \
1072 
1073 
1081 static void cfapi_get_season_name(int *type, ...) {
1083 }
1084 
1093 static void cfapi_get_weekday_name(int *type, ...) {
1095 }
1096 
1105 static void cfapi_get_month_name(int *type, ...) {
1107 }
1108 
1117 static void cfapi_get_periodofday_name(int *type, ...) {
1119 }
1120 
1132 static void cfapi_timer_create(int *type, ...) {
1133  va_list args;
1134  int res;
1135  object *ob;
1136  long delay;
1137  int mode;
1138  int *timer;
1139 
1140  va_start(args, type);
1141  ob = va_arg(args, object *);
1142  delay = va_arg(args, long);
1143  mode = va_arg(args, int);
1144  timer = va_arg(args, int *);
1145  va_end(args);
1146  *type = CFAPI_INT;
1147 
1148  *timer = cftimer_find_free_id();
1149  if (*timer != TIMER_ERR_ID) {
1150  res = cftimer_create(*timer, delay, ob, mode);
1151  if (res != TIMER_ERR_NONE)
1152  *timer = res;
1153  }
1154 }
1155 
1165 static void cfapi_timer_destroy(int *type, ...) {
1166  va_list args;
1167  int id;
1168  int *err;
1169 
1170  va_start(args, type);
1171  id = va_arg(args, int);
1172  err = va_arg(args, int *);
1173  va_end(args);
1174  *type = CFAPI_INT;
1175 
1176  *err = cftimer_destroy(id);
1177 }
1178 
1184 static void cfapi_log(int *type, ...) {
1185  va_list args;
1186  LogLevel logLevel;
1187  const char *message;
1188 
1189  va_start(args, type);
1190  logLevel = va_arg(args, LogLevel);
1191  message = va_arg(args, const char *);
1192  LOG(logLevel, "%s", message);
1193  va_end(args);
1194 
1195  *type = CFAPI_NONE;
1196 }
1197 
1198 /* MAP RELATED HOOKS */
1199 
1208 static void cfapi_map_get_map(int *type, ...) {
1209  va_list args;
1210  mapstruct **ret;
1211  int ctype;
1212  int x, y;
1213  int16_t nx, ny;
1214  const char *name;
1215  mapstruct *m;
1216 
1217  va_start(args, type);
1218 
1219  ctype = va_arg(args, int);
1220 
1221  switch (ctype) {
1222  case 0:
1223  x = va_arg(args, int);
1224  y = va_arg(args, int);
1225  ret = va_arg(args, mapstruct **);
1226  *ret = get_empty_map(x, y);
1227  break;
1228 
1229  case 1:
1230  name = va_arg(args, const char *);
1231  x = va_arg(args, int);
1232  ret = va_arg(args, mapstruct **);
1233  *ret = ready_map_name(name, x);
1234  break;
1235 
1236  case 2:
1237  m = va_arg(args, mapstruct *);
1238  nx = va_arg(args, int);
1239  ny = va_arg(args, int);
1240  ret = va_arg(args, mapstruct **);
1241  *ret = get_map_from_coord(m, &nx, &ny);
1242  break;
1243 
1244  default:
1245  *type = CFAPI_NONE;
1246  va_end(args);
1247  return;
1248  break;
1249  }
1250  va_end(args);
1251  *type = CFAPI_PMAP;
1252 }
1253 
1259 static void cfapi_map_has_been_loaded(int *type, ...) {
1260  va_list args;
1261  mapstruct **map;
1262  char *string;
1263 
1264  va_start(args, type);
1265  string = va_arg(args, char *);
1266  map = va_arg(args, mapstruct **);
1267  *map = has_been_loaded(string);
1268  va_end(args);
1269  *type = CFAPI_PMAP;
1270 }
1271 
1277 static void cfapi_map_create_path(int *type, ...) {
1278  va_list args;
1279  int ctype, size;
1280  const char *str;
1281  char *name;
1282 
1283  va_start(args, type);
1284 
1285  ctype = va_arg(args, int);
1286  str = va_arg(args, const char *);
1287  name = va_arg(args, char *);
1288  size = va_arg(args, int);
1289  *type = CFAPI_STRING;
1290 
1291  switch (ctype) {
1292  case 0:
1293  create_pathname(str, name, size);
1294  break;
1295 
1296  case 1:
1297  create_overlay_pathname(str, name, MAX_BUF);
1298  break;
1299 
1300 /* case 2:
1301  rv = create_items_path(str);
1302  break;*/
1303 
1304  default:
1305  *type = CFAPI_NONE;
1306  break;
1307  }
1308  va_end(args);
1309 }
1310 
1311 static void cfapi_map_get_map_property(int *type, ...) {
1312  va_list args;
1313  mapstruct *map;
1314  int property;
1315 
1316  int *rint;
1317  mapstruct **rmap;
1318  sstring *rstr;
1319  region **rreg;
1320  int16_t *nx, *ny;
1321  int x, y;
1322 
1323  va_start(args, type);
1324 
1325  map = va_arg(args, mapstruct *);
1326  property = va_arg(args, int);
1327 
1328  switch (property) {
1329  case CFAPI_MAP_PROP_FLAGS:
1330  rmap = va_arg(args, mapstruct **);
1331  x = va_arg(args, int);
1332  y = va_arg(args, int);
1333  nx = va_arg(args, int16_t *);
1334  ny = va_arg(args, int16_t *);
1335  rint = va_arg(args, int *);
1336  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1337  *type = CFAPI_INT;
1338  break;
1339 
1341  rint = va_arg(args, int *);
1342  *rint = calculate_difficulty(map);
1343  *type = CFAPI_INT;
1344  break;
1345 
1346  case CFAPI_MAP_PROP_PATH:
1347  rstr = va_arg(args, sstring *);
1348  *rstr = map->path;
1349  *type = CFAPI_SSTRING;
1350  break;
1351 
1353  rstr = va_arg(args, sstring *);
1354  *rstr = map->tmpname;
1355  *type = CFAPI_SSTRING;
1356  break;
1357 
1358  case CFAPI_MAP_PROP_NAME:
1359  rstr = va_arg(args, sstring *);
1360  *rstr = map->name;
1361  *type = CFAPI_SSTRING;
1362  break;
1363 
1365  rint = va_arg(args, int *);
1366  *rint = map->reset_time;
1367  *type = CFAPI_INT;
1368  break;
1369 
1371  rint = va_arg(args, int *);
1372  *rint = map->reset_timeout;
1373  *type = CFAPI_INT;
1374  break;
1375 
1377  rint = va_arg(args, int *);
1378  *rint = map->players;
1379  *type = CFAPI_INT;
1380  break;
1381 
1383  rint = va_arg(args, int *);
1384  *rint = map->darkness;
1385  *type = CFAPI_INT;
1386  break;
1387 
1388  case CFAPI_MAP_PROP_WIDTH:
1389  rint = va_arg(args, int *);
1390  *rint = map->width;
1391  *type = CFAPI_INT;
1392  break;
1393 
1394  case CFAPI_MAP_PROP_HEIGHT:
1395  rint = va_arg(args, int *);
1396  *rint = map->height;
1397  *type = CFAPI_INT;
1398  break;
1399 
1401  rint = va_arg(args, int *);
1402  *rint = map->enter_x;
1403  *type = CFAPI_INT;
1404  break;
1405 
1407  rint = va_arg(args, int *);
1408  *rint = map->enter_y;
1409  *type = CFAPI_INT;
1410  break;
1411 
1413  rstr = va_arg(args, sstring *);
1414  *rstr = map->msg;
1415  *type = CFAPI_SSTRING;
1416  break;
1417 
1418  case CFAPI_MAP_PROP_NEXT:
1419  rmap = va_arg(args, mapstruct **);
1420  *rmap = map ? map->next : first_map;
1421  *type = CFAPI_PMAP;
1422  break;
1423 
1424  case CFAPI_MAP_PROP_REGION:
1425  rreg = va_arg(args, region **);
1426  *rreg = get_region_by_map(map);
1427  *type = CFAPI_PREGION;
1428  break;
1429 
1430  case CFAPI_MAP_PROP_UNIQUE:
1431  rint = va_arg(args, int *);
1432  *rint = map->unique;
1433  *type = CFAPI_INT;
1434  break;
1435 
1436  default:
1437  *type = CFAPI_NONE;
1438  break;
1439  }
1440  va_end(args);
1441 }
1442 
1443 static void cfapi_map_set_map_property(int *type, ...) {
1444  va_list args;
1445  mapstruct *map;
1446  int property;
1447  const char *buf;
1448 
1449  va_start(args, type);
1450 
1451  map = va_arg(args, mapstruct *);
1452  property = va_arg(args, int);
1453 
1454  switch (property) {
1455  case CFAPI_MAP_PROP_PATH:
1456  buf = va_arg(args, const char *);
1457  strlcpy(map->path, buf, sizeof(map->path));
1458  *type = CFAPI_STRING;
1459  break;
1460 
1461  default:
1462  *type = CFAPI_NONE;
1463  break;
1464  }
1465  va_end(args);
1466 }
1467 
1473 static void cfapi_map_out_of_map(int *type, ...) {
1474  va_list args;
1475  mapstruct *map;
1476  int x, y;
1477  int *rint;
1478 
1479  va_start(args, type);
1480  map = va_arg(args, mapstruct *);
1481  x = va_arg(args, int);
1482  y = va_arg(args, int);
1483  rint = va_arg(args, int *);
1484 
1485  *rint = out_of_map(map, x, y);
1486  va_end(args);
1487  *type = CFAPI_INT;
1488 }
1489 
1495 static void cfapi_map_update_position(int *type, ...) {
1496  va_list args;
1497  mapstruct *map;
1498  int x, y;
1499 
1500  va_start(args, type);
1501 
1502  map = va_arg(args, mapstruct *);
1503  x = va_arg(args, int);
1504  y = va_arg(args, int);
1505 
1506  update_position(map, x, y);
1507  va_end(args);
1508  *type = CFAPI_NONE;
1509 }
1510 
1511 static void cfapi_map_delete_map(int *type, ...) {
1512  va_list args;
1513  mapstruct *map;
1514  va_start(args, type);
1515 
1516  map = va_arg(args, mapstruct *);
1517 
1518  delete_map(map);
1519 
1520  va_end(args);
1521  *type = CFAPI_NONE;
1522 }
1523 
1524 static void cfapi_map_message(int *type, ...) {
1525  va_list args;
1526  mapstruct *map;
1527  const char *string;
1528  int color;
1529 
1530  va_start(args, type);
1531  map = va_arg(args, mapstruct *);
1532  string = va_arg(args, const char *);
1533  color = va_arg(args, int);
1534  va_end(args);
1535 
1536  /* function should be extended to take message types probably */
1537  ext_info_map(color, map, MSG_TYPE_MISC, MSG_SUBTYPE_NONE, string);
1538  *type = CFAPI_NONE;
1539 }
1540 
1546 static void cfapi_map_get_object_at(int *type, ...) {
1547  va_list args;
1548  mapstruct *map;
1549  int x, y;
1550  int16_t sx, sy;
1551  object **robj;
1552 
1553  va_start(args, type);
1554  map = va_arg(args, mapstruct *);
1555  x = va_arg(args, int);
1556  y = va_arg(args, int);
1557  robj = va_arg(args, object **);
1558  va_end(args);
1559 
1560  sx = x;
1561  sy = y;
1562  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1563  *robj = NULL;
1564  else
1565  *robj = GET_MAP_OB(map, sx, sy);
1566  *type = CFAPI_POBJECT;
1567 }
1568 
1575 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1576  va_list args;
1577  int x, y;
1578  mapstruct *map;
1579  char *msg;
1580  object **robj;
1581 
1582  va_start(args, type);
1583 
1584  msg = va_arg(args, char *);
1585  map = va_arg(args, mapstruct *);
1586  x = va_arg(args, int);
1587  y = va_arg(args, int);
1588  robj = va_arg(args, object **);
1589 
1590  va_end(args);
1591 
1592  archetype *at = try_find_archetype(msg);
1593  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1594  *type = CFAPI_POBJECT;
1595 }
1596 
1602 static void cfapi_map_change_light(int *type, ...) {
1603  va_list args;
1604  int change;
1605  mapstruct *map;
1606  int *rint;
1607 
1608  va_start(args, type);
1609  map = va_arg(args, mapstruct *);
1610  change = va_arg(args, int);
1611  rint = va_arg(args, int *);
1612  va_end(args);
1613 
1614  *type = CFAPI_INT;
1615  *rint = change_map_light(map, change);
1616 }
1617 
1618 /* OBJECT-RELATED HOOKS */
1619 
1633 static void cfapi_object_move(int *type, ...) {
1634  va_list args;
1635  int kind;
1636  object *op;
1637  object *activator;
1638  player *pl;
1639  int direction;
1640  int *ret;
1641 
1642  va_start(args, type);
1643  kind = va_arg(args, int);
1644  switch (kind) {
1645  case 0:
1646  op = va_arg(args, object *);
1647  direction = va_arg(args, int);
1648  activator = va_arg(args, object *);
1649  ret = va_arg(args, int *);
1650  va_end(args);
1651  *ret = move_ob(op, direction, activator);
1652  break;
1653 
1654  case 1:
1655  pl = va_arg(args, player *);
1656  direction = va_arg(args, int);
1657  ret = va_arg(args, int *);
1658  va_end(args);
1659  *ret = move_player(pl->ob, direction);
1660  break;
1661 
1662  case 2:
1663  op = va_arg(args, object *);
1664  ret = va_arg(args, int *);
1665  va_end(args);
1666  *ret = player_arrest(op);
1667  break;
1668 
1669  default:
1670  // Just end the use of variable args. We got a wrong type.
1671  va_end(args);
1672  }
1673  *type = CFAPI_INT;
1674 }
1675 
1683 static void cfapi_object_get_key(int *type, ...) {
1684  va_list args;
1685  const char *keyname;
1686  const char **value;
1687  object *op;
1688 
1689  va_start(args, type);
1690  op = va_arg(args, object *);
1691  keyname = va_arg(args, const char *);
1692  value = va_arg(args, const char **);
1693  va_end(args);
1694 
1695  *value = object_get_value(op, keyname);
1696  *type = CFAPI_SSTRING;
1697 }
1698 
1705 static void cfapi_object_set_key(int *type, ...) {
1706  va_list args;
1707  const char *keyname;
1708  const char *value;
1709  int *ret;
1710  object *op;
1711  int add_key;
1712 
1713  va_start(args, type);
1714  op = va_arg(args, object *);
1715  keyname = va_arg(args, char *);
1716  value = va_arg(args, char *);
1717  add_key = va_arg(args, int);
1718  ret = va_arg(args, int *);
1719  va_end(args);
1720 
1721  *ret = object_set_value(op, keyname, value, add_key);
1722  *type = CFAPI_INT;
1723 }
1724 
1728 static void cfapi_object_get_property(int *type, ...) {
1729  va_list args;
1730  int property;
1731  object *op;
1732  int *rint;
1733  object **robject;
1734  mapstruct **rmap;
1735  float *rfloat;
1736  archetype **rarch;
1737  sstring *rsstring;
1738  char *rbuffer;
1739  int rbufsize;
1740  MoveType *rmove;
1741  int64_t *rint64;
1742  partylist **rparty;
1743  double *rdouble;
1744  long *rlong;
1745 
1746  va_start(args, type);
1747 
1748  op = va_arg(args, object *);
1749  property = va_arg(args, int);
1750  switch (property) {
1752  robject = va_arg(args, object **);
1753  *robject = op->above;
1754  *type = CFAPI_POBJECT;
1755  break;
1756 
1758  robject = va_arg(args, object **);
1759  *robject = op->below;
1760  *type = CFAPI_POBJECT;
1761  break;
1762 
1764  robject = va_arg(args, object **);
1765  *robject = op->active_next;
1766  *type = CFAPI_POBJECT;
1767  break;
1768 
1770  robject = va_arg(args, object **);
1771  *robject = op->active_prev;
1772  *type = CFAPI_POBJECT;
1773  break;
1774 
1776  robject = va_arg(args, object **);
1777  *robject = op->inv;
1778  *type = CFAPI_POBJECT;
1779  break;
1780 
1782  robject = va_arg(args, object **);
1783  *robject = op->env;
1784  *type = CFAPI_POBJECT;
1785  break;
1786 
1788  robject = va_arg(args, object **);
1789  *robject = op->head;
1790  *type = CFAPI_POBJECT;
1791  break;
1792 
1794  robject = va_arg(args, object **);
1795  *robject = op->container;
1796  *type = CFAPI_POBJECT;
1797  break;
1798 
1799  case CFAPI_OBJECT_PROP_MAP:
1800  rmap = va_arg(args, mapstruct **);
1801  *rmap = op->map;
1802  *type = CFAPI_PMAP;
1803  break;
1804 
1806  rint = va_arg(args, int *);
1807  *rint = op->count;
1808  *type = CFAPI_INT;
1809  break;
1810 
1812  rbuffer = va_arg(args, char *);
1813  rbufsize = va_arg(args, int);
1814  query_name(op, rbuffer, rbufsize);
1815  *type = CFAPI_STRING;
1816  break;
1817 
1819  rsstring = va_arg(args, sstring *);
1820  *rsstring = op->name_pl;
1821  *type = CFAPI_SSTRING;
1822  break;
1823 
1825  rsstring = va_arg(args, sstring *);
1826  *rsstring = op->title;
1827  *type = CFAPI_SSTRING;
1828  break;
1829 
1831  rsstring = va_arg(args, sstring *);
1832  *rsstring = op->race;
1833  *type = CFAPI_SSTRING;
1834  break;
1835 
1837  rsstring = va_arg(args, sstring *);
1838  *rsstring = op->slaying;
1839  *type = CFAPI_SSTRING;
1840  break;
1841 
1843  rsstring = va_arg(args, sstring *);
1844  *rsstring = op->skill;
1845  *type = CFAPI_SSTRING;
1846  break;
1847 
1849  rsstring = va_arg(args, sstring *);
1850  *rsstring = op->msg;
1851  *type = CFAPI_SSTRING;
1852  break;
1853 
1855  rsstring = va_arg(args, sstring *);
1856  *rsstring = op->lore;
1857  *type = CFAPI_SSTRING;
1858  break;
1859 
1860  case CFAPI_OBJECT_PROP_X:
1861  rint = va_arg(args, int *);
1862  *rint = op->x;
1863  *type = CFAPI_INT;
1864  break;
1865 
1866  case CFAPI_OBJECT_PROP_Y:
1867  rint = va_arg(args, int *);
1868  *rint = op->y;
1869  *type = CFAPI_INT;
1870  break;
1871 
1873  rfloat = va_arg(args, float *);
1874  *rfloat = op->speed;
1875  *type = CFAPI_FLOAT;
1876  break;
1877 
1879  rfloat = va_arg(args, float *);
1880  *rfloat = op->speed_left;
1881  *type = CFAPI_FLOAT;
1882  break;
1883 
1885  rint = va_arg(args, int *);
1886  *rint = op->nrof;
1887  *type = CFAPI_INT;
1888  break;
1889 
1891  rint = va_arg(args, int *);
1892  *rint = op->direction;
1893  *type = CFAPI_INT;
1894  break;
1895 
1897  rint = va_arg(args, int *);
1898  *rint = op->facing;
1899  *type = CFAPI_INT;
1900  break;
1901 
1903  rint = va_arg(args, int *);
1904  *rint = op->type;
1905  *type = CFAPI_INT;
1906  break;
1907 
1909  rint = va_arg(args, int *);
1910  *rint = op->subtype;
1911  *type = CFAPI_INT;
1912  break;
1913 
1915  rint = va_arg(args, int *);
1916  *rint = op->client_type;
1917  *type = CFAPI_INT;
1918  break;
1919 
1920  case CFAPI_OBJECT_PROP_RESIST: {
1921  int idx;
1922  int16_t *resist;
1923 
1924  idx = va_arg(args, int);
1925  resist = va_arg(args, int16_t *);
1926  *resist = op->resist[idx];
1927  }
1928  *type = CFAPI_INT16;
1929  break;
1930 
1932  rint = va_arg(args, int *);
1933  *rint = op->attacktype;
1934  *type = CFAPI_INT;
1935  break;
1936 
1938  rint = va_arg(args, int *);
1939  *rint = op->path_attuned;
1940  *type = CFAPI_INT;
1941  break;
1942 
1944  rint = va_arg(args, int *);
1945  *rint = op->path_repelled;
1946  *type = CFAPI_INT;
1947  break;
1948 
1950  rint = va_arg(args, int *);
1951  *rint = op->path_denied;
1952  *type = CFAPI_INT;
1953  break;
1954 
1956  rint = va_arg(args, int *);
1957  *rint = op->material;
1958  *type = CFAPI_INT;
1959  break;
1960 
1962  rsstring = va_arg(args, sstring *);
1963  *rsstring = op->materialname;
1964  *type = CFAPI_SSTRING;
1965  break;
1966 
1968  rint = va_arg(args, int *);
1969  *rint = op->magic;
1970  *type = CFAPI_INT;
1971  break;
1972 
1974  rlong = va_arg(args, long *);
1975  *rlong = op->value;
1976  *type = CFAPI_LONG;
1977  break;
1978 
1980  rint = va_arg(args, int *);
1981  *rint = op->level;
1982  *type = CFAPI_INT;
1983  break;
1984 
1986  rint = va_arg(args, int *);
1987  *rint = op->last_heal;
1988  *type = CFAPI_INT;
1989  break;
1990 
1992  rint = va_arg(args, int *);
1993  *rint = op->last_sp;
1994  *type = CFAPI_INT;
1995  break;
1996 
1998  rint = va_arg(args, int *);
1999  *rint = op->last_grace;
2000  *type = CFAPI_INT;
2001  break;
2002 
2004  rint = va_arg(args, int *);
2005  *rint = op->last_eat;
2006  *type = CFAPI_INT;
2007  break;
2008 
2010  rint = va_arg(args, int *);
2011  *rint = op->invisible;
2012  *type = CFAPI_INT;
2013  break;
2014 
2016  rint = va_arg(args, int *);
2017  *rint = op->pick_up;
2018  *type = CFAPI_INT;
2019  break;
2020 
2022  rint = va_arg(args, int *);
2023  *rint = op->item_power;
2024  *type = CFAPI_INT;
2025  break;
2026 
2028  rint = va_arg(args, int *);
2029  *rint = op->gen_sp_armour;
2030  *type = CFAPI_INT;
2031  break;
2032 
2034  rint = va_arg(args, int *);
2035  *rint = op->weight;
2036  *type = CFAPI_INT;
2037  break;
2038 
2040  rint = va_arg(args, int *);
2041  *rint = op->weight_limit;
2042  *type = CFAPI_INT;
2043  break;
2044 
2046  rint = va_arg(args, int *);
2047  *rint = op->carrying;
2048  *type = CFAPI_INT;
2049  break;
2050 
2052  rint = va_arg(args, int *);
2053  *rint = op->glow_radius;
2054  *type = CFAPI_INT;
2055  break;
2056 
2058  rint64 = va_arg(args, int64_t *);
2059  *rint64 = op->total_exp;
2060  *type = CFAPI_SINT64;
2061  break;
2062 
2064  robject = va_arg(args, object **);
2065  *robject = op->current_weapon;
2066  *type = CFAPI_POBJECT;
2067  break;
2068 
2070  robject = va_arg(args, object **);
2071  *robject = op->enemy;
2072  *type = CFAPI_POBJECT;
2073  break;
2074 
2076  robject = va_arg(args, object **);
2077  *robject = op->attacked_by;
2078  *type = CFAPI_POBJECT;
2079  break;
2080 
2082  rint = va_arg(args, int *);
2083  *rint = op->run_away;
2084  *type = CFAPI_INT;
2085  break;
2086 
2088  robject = va_arg(args, object **);
2089  *robject = op->chosen_skill;
2090  *type = CFAPI_POBJECT;
2091  break;
2092 
2094  rint = va_arg(args, int *);
2095  *rint = op->hide;
2096  *type = CFAPI_INT;
2097  break;
2098 
2100  rint = va_arg(args, int *);
2101  *rint = op->move_status;
2102  *type = CFAPI_INT;
2103  break;
2104 
2106  rint = va_arg(args, int *);
2107  *rint = op->attack_movement;
2108  *type = CFAPI_INT;
2109  break;
2110 
2112  robject = va_arg(args, object **);
2113  *robject = op->spellitem;
2114  *type = CFAPI_POBJECT;
2115  break;
2116 
2118  rdouble = va_arg(args, double *);
2119  *rdouble = op->expmul;
2120  *type = CFAPI_DOUBLE;
2121  break;
2122 
2124  rarch = va_arg(args, archetype **);
2125  *rarch = op->arch;
2126  *type = CFAPI_PARCH;
2127  break;
2128 
2130  rarch = va_arg(args, archetype **);
2131  *rarch = op->other_arch;
2132  *type = CFAPI_PARCH;
2133  break;
2134 
2136  rsstring = va_arg(args, sstring *);
2137  *rsstring = op->custom_name;
2138  *type = CFAPI_SSTRING;
2139  break;
2140 
2142  rint = va_arg(args, int *);
2143  *rint = op->anim_speed;
2144  *type = CFAPI_INT;
2145  break;
2146 
2148  rint = va_arg(args, int *);
2149  *rint = is_friendly(op);
2150  *type = CFAPI_INT;
2151  break;
2152 
2154  rbuffer = va_arg(args, char *);
2155  rbufsize = va_arg(args, int);
2156  query_short_name(op, rbuffer, rbufsize);
2157  *type = CFAPI_STRING;
2158  break;
2159 
2161  int i;
2162 
2163  i = va_arg(args, int);
2164  rbuffer = va_arg(args, char *);
2165  rbufsize = va_arg(args, int);
2166  query_base_name(op, i, rbuffer, rbufsize);
2167  *type = CFAPI_STRING;
2168  }
2169  break;
2170 
2172  rsstring = va_arg(args, sstring *);
2173  *rsstring = op->name;
2174  *type = CFAPI_SSTRING;
2175  break;
2176 
2178  rint = va_arg(args, int *);
2179  *rint = is_magical(op);
2180  *type = CFAPI_INT;
2181  break;
2182 
2184  rint = va_arg(args, int *);
2185  *rint = op->stats.luck;
2186  *type = CFAPI_INT;
2187  break;
2188 
2189  case CFAPI_OBJECT_PROP_EXP:
2190  rint64 = va_arg(args, int64_t *);
2191  *rint64 = op->stats.exp;
2192  *type = CFAPI_SINT64;
2193  break;
2194 
2196  robject = va_arg(args, object **);
2197  *robject = object_get_owner(op);
2198  *type = CFAPI_POBJECT;
2199  break;
2200 
2202  int stype;
2203 
2204  stype = va_arg(args, int);
2205  switch (stype) {
2206  unsigned char ptype;
2207  char *buf;
2208  archetype *at;
2209 
2210  case 0: /* present_in_ob */
2211  ptype = (unsigned char)(va_arg(args, int));
2212  robject = va_arg(args, object **);
2213  *robject = object_present_in_ob(ptype, op);
2214  break;
2215 
2216  case 1: /* present_in_ob_by_name */
2217  ptype = (unsigned char)(va_arg(args, int));
2218  buf = va_arg(args, char *);
2219  robject = va_arg(args, object **);
2220  *robject = object_present_in_ob_by_name(ptype, buf, op);
2221  break;
2222 
2223  case 2: /* arch_present_in_ob */
2224  at = va_arg(args, archetype *);
2225  robject = va_arg(args, object **);
2226  *robject = arch_present_in_ob(at, op);
2227  break;
2228  }
2229  }
2230  *type = CFAPI_POBJECT;
2231  break;
2232 
2234  rint = va_arg(args, int *);
2235  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2236  *type = CFAPI_INT;
2237  break;
2238 
2240  object *op2;
2241 
2242  op2 = va_arg(args, object *);
2243  rint = va_arg(args, int *);
2244  *rint = object_can_merge(op, op2);
2245  }
2246  *type = CFAPI_INT;
2247  break;
2248 
2250  object *op2;
2251 
2252  op2 = va_arg(args, object *);
2253  rint = va_arg(args, int *);
2254  *rint = object_can_pick(op2, op);
2255  }
2256  *type = CFAPI_INT;
2257  break;
2258 
2259  case CFAPI_OBJECT_PROP_FLAGS: {
2260  int fl;
2261 
2262  fl = va_arg(args, int);
2263  rint = va_arg(args, int *);
2264  *rint = QUERY_FLAG(op, fl);
2265  }
2266  *type = CFAPI_INT;
2267  break;
2268 
2269  case CFAPI_OBJECT_PROP_STR:
2270  rint = va_arg(args, int *);
2271  *rint = op->stats.Str;
2272  *type = CFAPI_INT;
2273  break;
2274 
2275  case CFAPI_OBJECT_PROP_DEX:
2276  rint = va_arg(args, int *);
2277  *rint = op->stats.Dex;
2278  *type = CFAPI_INT;
2279  break;
2280 
2281  case CFAPI_OBJECT_PROP_CON:
2282  rint = va_arg(args, int *);
2283  *rint = op->stats.Con;
2284  *type = CFAPI_INT;
2285  break;
2286 
2287  case CFAPI_OBJECT_PROP_WIS:
2288  rint = va_arg(args, int *);
2289  *rint = op->stats.Wis;
2290  *type = CFAPI_INT;
2291  break;
2292 
2293  case CFAPI_OBJECT_PROP_INT:
2294  rint = va_arg(args, int *);
2295  *rint = op->stats.Int;
2296  *type = CFAPI_INT;
2297  break;
2298 
2299  case CFAPI_OBJECT_PROP_POW:
2300  rint = va_arg(args, int *);
2301  *rint = op->stats.Pow;
2302  *type = CFAPI_INT;
2303  break;
2304 
2305  case CFAPI_OBJECT_PROP_CHA:
2306  rint = va_arg(args, int *);
2307  *rint = op->stats.Cha;
2308  *type = CFAPI_INT;
2309  break;
2310 
2311  case CFAPI_OBJECT_PROP_WC:
2312  rint = va_arg(args, int *);
2313  *rint = op->stats.wc;
2314  *type = CFAPI_INT;
2315  break;
2316 
2317  case CFAPI_OBJECT_PROP_AC:
2318  rint = va_arg(args, int *);
2319  *rint = op->stats.ac;
2320  *type = CFAPI_INT;
2321  break;
2322 
2323  case CFAPI_OBJECT_PROP_HP:
2324  rint = va_arg(args, int *);
2325  *rint = op->stats.hp;
2326  *type = CFAPI_INT;
2327  break;
2328 
2329  case CFAPI_OBJECT_PROP_SP:
2330  rint = va_arg(args, int *);
2331  *rint = op->stats.sp;
2332  *type = CFAPI_INT;
2333  break;
2334 
2335  case CFAPI_OBJECT_PROP_GP:
2336  rint = va_arg(args, int *);
2337  *rint = op->stats.grace;
2338  *type = CFAPI_INT;
2339  break;
2340 
2341  case CFAPI_OBJECT_PROP_FP:
2342  rint = va_arg(args, int *);
2343  *rint = op->stats.food;
2344  *type = CFAPI_INT;
2345  break;
2346 
2348  rint = va_arg(args, int *);
2349  *rint = op->stats.maxhp;
2350  *type = CFAPI_INT;
2351  break;
2352 
2354  rint = va_arg(args, int *);
2355  *rint = op->stats.maxsp;
2356  *type = CFAPI_INT;
2357  break;
2358 
2360  rint = va_arg(args, int *);
2361  *rint = op->stats.maxgrace;
2362  *type = CFAPI_INT;
2363  break;
2364 
2365  case CFAPI_OBJECT_PROP_DAM:
2366  rint = va_arg(args, int *);
2367  *rint = op->stats.dam;
2368  *type = CFAPI_INT;
2369  break;
2370 
2371  case CFAPI_OBJECT_PROP_GOD:
2372  rsstring = va_arg(args, sstring *);
2373  *rsstring = determine_god(op);
2374  *type = CFAPI_SSTRING;
2375  break;
2376 
2378  rsstring = va_arg(args, sstring *);
2379  *rsstring = op->arch->name;
2380  *type = CFAPI_SSTRING;
2381  break;
2382 
2384  rint = va_arg(args, int *);
2385  *rint = op->invisible;
2386  *type = CFAPI_INT;
2387  break;
2388 
2390  rbuffer = va_arg(args, char *);
2391  rbufsize = va_arg(args, int);
2392  if (rbufsize > 0) {
2393  strncpy(rbuffer, op->face->name, rbufsize);
2394  rbuffer[rbufsize - 1] = '\0';
2395  }
2396  *type = CFAPI_STRING;
2397  break;
2398 
2400  rbuffer = va_arg(args, char *);
2401  rbufsize = va_arg(args, int);
2402  if (rbufsize > 0) {
2403  if (op->animation != NULL) {
2404  strncpy(rbuffer, op->animation->name, rbufsize);
2405  rbuffer[rbufsize - 1] = '\0';
2406  }
2407  else
2408  rbuffer[0] = '\0';
2409  }
2410  *type = CFAPI_STRING;
2411  break;
2412 
2413  case CFAPI_PLAYER_PROP_IP:
2414  rsstring = va_arg(args, sstring *);
2415  *rsstring = op->contr->socket.host;
2416  *type = CFAPI_SSTRING;
2417  break;
2418 
2420  robject = va_arg(args, object **);
2421  *robject = find_marked_object(op);
2422  *type = CFAPI_POBJECT;
2423  break;
2424 
2426  rparty = va_arg(args, partylist **);
2427  *rparty = (op->contr ? op->contr->party : NULL);
2428  *type = CFAPI_PPARTY;
2429  break;
2430 
2432  robject = va_arg(args, object **);
2433  if (op)
2434  *robject = op->contr->next ? op->contr->next->ob : NULL;
2435  else
2436  /* This can be called when there is no player. */
2437  *robject = first_player ? first_player->ob : NULL;
2438  *type = CFAPI_POBJECT;
2439  break;
2440 
2442  rbuffer = va_arg(args, char *);
2443  rbufsize = va_arg(args, int);
2444  player_get_title(op->contr, rbuffer, rbufsize);
2445  *type = CFAPI_STRING;
2446  break;
2447 
2449  rmove = va_arg(args, MoveType *);
2450  *rmove = op->move_type;
2451  *type = CFAPI_MOVETYPE;
2452  break;
2453 
2455  rmove = va_arg(args, MoveType *);
2456  *rmove = op->move_block;
2457  *type = CFAPI_MOVETYPE;
2458  break;
2459 
2461  rmove = va_arg(args, MoveType *);
2462  *rmove = op->move_allow;
2463  *type = CFAPI_MOVETYPE;
2464  break;
2465 
2467  rmove = va_arg(args, MoveType *);
2468  *rmove = op->move_on;
2469  *type = CFAPI_MOVETYPE;
2470  break;
2471 
2473  rmove = va_arg(args, MoveType *);
2474  *rmove = op->move_off;
2475  *type = CFAPI_MOVETYPE;
2476  break;
2477 
2479  rmove = va_arg(args, MoveType *);
2480  *rmove = op->move_type;
2481  *type = CFAPI_MOVETYPE;
2482  break;
2483 
2485  rfloat = va_arg(args, float *);
2486  *rfloat = op->move_slow_penalty;
2487  *type = CFAPI_FLOAT;
2488  break;
2489 
2491  rbuffer = va_arg(args, char *);
2492  rbufsize = va_arg(args, int);
2493  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2494  *type = CFAPI_STRING;
2495  break;
2496 
2498  rint = va_arg(args, int *);
2499  *rint = op->contr->bed_x;
2500  *type = CFAPI_INT;
2501  break;
2502 
2504  rint = va_arg(args, int *);
2505  *rint = op->contr->bed_y;
2506  *type = CFAPI_INT;
2507  break;
2508 
2510  rint = va_arg(args, int *);
2511  *rint = op->duration;
2512  *type = CFAPI_INT;
2513  break;
2514 
2515  default:
2516  *type = CFAPI_NONE;
2517  break;
2518  }
2519  va_end(args);
2520 }
2521 
2530 static void copy_message(object *op, const char *msg) {
2531  char *temp;
2532  int size;
2533 
2534  if (!msg)
2535  return;
2536 
2537  /* need to reset parsed dialog information */
2539 
2540  size = strlen(msg);
2541 
2542  if (msg[0] != 0 && msg[size-1] == '\n') {
2543  object_set_msg(op, msg);
2544  return;
2545  }
2546 
2547  temp = malloc(size+2);
2548  if (!temp)
2550  snprintf(temp, size+2, "%s\n", msg);
2551  object_set_msg(op, temp);
2552  free(temp);
2553 }
2554 
2563 static void cfapi_object_set_property(int *type, ...) {
2564  va_list args;
2565  int iarg, *ret;
2566  long larg;
2567  char *sarg;
2568  double darg;
2569  object *oparg;
2570  object *op;
2571  int property;
2572  int64_t s64arg;
2573  partylist *partyarg;
2574  float farg;
2575  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2576 
2577  va_start(args, type);
2578  op = va_arg(args, object *);
2579  property = va_arg(args, int);
2580  *type = CFAPI_NONE;
2581 
2582  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2583  switch (property) {
2585  sarg = va_arg(args, char *);
2586  *type = CFAPI_STRING;
2587  FREE_AND_COPY(op->name, sarg);
2588  send_changed_object(op);
2589  break;
2590 
2592  sarg = va_arg(args, char *);
2593  *type = CFAPI_STRING;
2594  FREE_AND_COPY(op->name_pl, sarg);
2595  send_changed_object(op);
2596  break;
2597 
2599  sarg = va_arg(args, char *);
2600  *type = CFAPI_STRING;
2601  FREE_AND_COPY(op->title, sarg);
2602  break;
2603 
2605  sarg = va_arg(args, char *);
2606  *type = CFAPI_STRING;
2607  FREE_AND_COPY(op->race, sarg);
2608  break;
2609 
2611  sarg = va_arg(args, char *);
2612  *type = CFAPI_STRING;
2613  FREE_AND_COPY(op->slaying, sarg);
2614  break;
2615 
2617  sarg = va_arg(args, char *);
2618  *type = CFAPI_STRING;
2619  FREE_AND_COPY(op->skill, sarg);
2620  break;
2621 
2623  sarg = va_arg(args, char *);
2624  *type = CFAPI_STRING;
2625  copy_message(op, sarg);
2626  break;
2627 
2629  sarg = va_arg(args, char *);
2630  *type = CFAPI_STRING;
2631  FREE_AND_COPY(op->lore, sarg);
2632  break;
2633 
2635  farg = va_arg(args, double);
2636  *type = CFAPI_FLOAT;
2637  if (farg != op->speed) {
2638  op->speed = farg;
2639  object_update_speed(op);
2640  }
2641  break;
2642 
2644  farg = va_arg(args, double);
2645  *type = CFAPI_FLOAT;
2646  op->speed_left = farg;
2647  break;
2648 
2650  iarg = va_arg(args, int);
2651  *type = CFAPI_INT;
2652  if (iarg < 0)
2653  iarg = 0;
2654  if (op->nrof > (uint32_t)iarg)
2655  object_decrease_nrof(op, op->nrof-iarg);
2656  else if (op->nrof < (uint32_t)iarg) {
2657  object *tmp;
2658  player *pl;
2659 
2660  op->nrof = iarg;
2661  if (op->env != NULL) {
2662  tmp = object_get_player_container(op->env);
2663  if (!tmp) {
2664  for (pl = first_player; pl; pl = pl->next)
2665  if (pl->ob->container == op->env)
2666  break;
2667  if (pl)
2668  tmp = pl->ob;
2669  else
2670  tmp = NULL;
2671  } else {
2672  object_sum_weight(tmp);
2673  fix_object(tmp);
2674  }
2675  if (tmp)
2676  esrv_update_item(UPD_NROF, tmp, op);
2677  } else {
2678  FOR_ABOVE_PREPARE(op, tmp)
2679  if (tmp->type == PLAYER)
2680  tmp->contr->socket.update_look = 1;
2681  FOR_ABOVE_FINISH();
2682  }
2683  }
2684  break;
2685 
2687  iarg = va_arg(args, int);
2688  *type = CFAPI_INT;
2689  op->direction = iarg;
2690  break;
2691 
2693  iarg = va_arg(args, int);
2694  *type = CFAPI_INT;
2695  op->facing = iarg;
2696  break;
2697 
2698  case CFAPI_OBJECT_PROP_RESIST: {
2699  int iargbis = va_arg(args, int);
2700 
2701  *type = CFAPI_INT16;
2702  iarg = va_arg(args, int);
2703  op->resist[iargbis] = iarg;
2704  }
2705  break;
2706 
2708  iarg = va_arg(args, int);
2709  *type = CFAPI_INT;
2710  op->attacktype = iarg;
2711  break;
2712 
2714  iarg = va_arg(args, int);
2715  *type = CFAPI_INT;
2716  op->path_attuned = iarg;
2717  break;
2718 
2720  iarg = va_arg(args, int);
2721  *type = CFAPI_INT;
2722  op->path_repelled = iarg;
2723  break;
2724 
2726  iarg = va_arg(args, int);
2727  *type = CFAPI_INT;
2728  op->path_denied = iarg;
2729  break;
2730 
2732  iarg = va_arg(args, int);
2733  *type = CFAPI_INT;
2734  op->material = iarg;
2735  break;
2736 
2738  break;
2739 
2741  iarg = va_arg(args, int);
2742  *type = CFAPI_INT;
2743  op->magic = iarg;
2744  break;
2745 
2747  larg = va_arg(args, long);
2748  *type = CFAPI_LONG;
2749  op->value = larg;
2750  break;
2751 
2753  iarg = va_arg(args, int);
2754  *type = CFAPI_INT;
2755  op->level = iarg;
2756  send_changed_object(op);
2757  break;
2758 
2760  iarg = va_arg(args, int);
2761  *type = CFAPI_INT;
2762  op->last_heal = iarg;
2763  break;
2764 
2766  iarg = va_arg(args, int);
2767  *type = CFAPI_INT;
2768  op->last_sp = iarg;
2769  break;
2770 
2772  iarg = va_arg(args, int);
2773  *type = CFAPI_INT;
2774  op->last_grace = iarg;
2775  break;
2776 
2778  iarg = va_arg(args, int);
2779  *type = CFAPI_INT;
2780  op->last_eat = iarg;
2781  break;
2782 
2784  iarg = va_arg(args, int);
2785  *type = CFAPI_INT;
2786  op->invisible = iarg;
2787  break;
2788 
2790  iarg = va_arg(args, int);
2791  *type = CFAPI_INT;
2792  op->pick_up = iarg;
2793  break;
2794 
2796  iarg = va_arg(args, int);
2797  *type = CFAPI_INT;
2798  op->item_power = iarg;
2799  break;
2800 
2802  iarg = va_arg(args, int);
2803  *type = CFAPI_INT;
2804  op->gen_sp_armour = iarg;
2805  break;
2806 
2808  iarg = va_arg(args, int);
2809  *type = CFAPI_INT;
2810  if (op->weight != iarg) {
2811  object *tmp;
2812  player *pl;
2813 
2814  op->weight = iarg;
2815  if (op->env != NULL) {
2816  tmp = object_get_player_container(op->env);
2817  if (!tmp) {
2818  for (pl = first_player; pl; pl = pl->next)
2819  if (pl->ob->container == op->env)
2820  break;
2821  if (pl)
2822  tmp = pl->ob;
2823  else
2824  tmp = NULL;
2825  } else {
2826  object_sum_weight(tmp);
2827  fix_object(tmp);
2828  }
2829  if (tmp)
2830  esrv_update_item(UPD_WEIGHT, tmp, op);
2831  } else {
2832  FOR_ABOVE_PREPARE(op, tmp)
2833  if (tmp->type == PLAYER)
2834  esrv_update_item(UPD_WEIGHT, tmp, op);
2835  FOR_ABOVE_FINISH();
2836  }
2837  }
2838  break;
2839 
2841  iarg = va_arg(args, int);
2842  *type = CFAPI_INT;
2843  op->weight_limit = iarg;
2844  break;
2845 
2847  iarg = va_arg(args, int);
2848  *type = CFAPI_INT;
2849  if (op->glow_radius != iarg) {
2850  object *tmp;
2851 
2852  op->glow_radius = iarg;
2853  tmp = object_get_env_recursive(op);
2854  if (tmp->map != NULL) {
2855  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2856  update_position(tmp->map, tmp->x, tmp->y);
2857  update_all_los(tmp->map, tmp->x, tmp->y);
2858  }
2859  }
2860  break;
2861 
2863  s64arg = va_arg(args, int64_t);
2864  *type = CFAPI_SINT64;
2865  op->total_exp = s64arg;
2866  break;
2867 
2869  oparg = va_arg(args, object *);
2870  *type = CFAPI_POBJECT;
2871  object_set_enemy(op, oparg);
2872  break;
2873 
2875  iarg = va_arg(args, int);
2876  *type = CFAPI_INT;
2877  op->run_away = iarg;
2878  break;
2879 
2881  oparg = va_arg(args, object *);
2882  *type = CFAPI_POBJECT;
2883  op->chosen_skill = oparg;
2884  break;
2885 
2887  iarg = va_arg(args, int);
2888  *type = CFAPI_INT;
2889  op->hide = iarg;
2890  break;
2891 
2893  iarg = va_arg(args, int);
2894  *type = CFAPI_INT;
2895  op->move_status = iarg;
2896  break;
2897 
2899  iarg = va_arg(args, int);
2900  *type = CFAPI_INT;
2901  op->attack_movement = iarg;
2902  break;
2903 
2905  oparg = va_arg(args, object *);
2906  *type = CFAPI_POBJECT;
2907  op->spellitem = oparg;
2908  break;
2909 
2911  darg = va_arg(args, double);
2912  *type = CFAPI_DOUBLE;
2913  op->expmul = darg;
2914  break;
2915 
2917  sarg = va_arg(args, char *);
2918  *type = CFAPI_STRING;
2919  FREE_AND_COPY(op->custom_name, sarg);
2920  send_changed_object(op);
2921  break;
2922 
2924  iarg = va_arg(args, int);
2925  *type = CFAPI_INT;
2926  op->anim_speed = iarg;
2927  break;
2928 
2930  iarg = va_arg(args, int);
2931  *type = CFAPI_INT;
2932  if (iarg == 1 && is_friendly(op) == 0)
2933  add_friendly_object(op);
2934  else if (iarg == 0 && is_friendly(op) == 1)
2936  break;
2937 
2939  iarg = va_arg(args, int);
2940  *type = CFAPI_INT;
2941  op->stats.luck = iarg;
2942  break;
2943 
2944  case CFAPI_OBJECT_PROP_EXP:
2945  s64arg = va_arg(args, int64_t);
2946  *type = CFAPI_SINT64;
2947  op->stats.exp = s64arg;
2948  break;
2949 
2951  oparg = va_arg(args, object *);
2952  *type = CFAPI_POBJECT;
2953  object_set_owner(op, oparg);
2954  break;
2955 
2957  object_set_cheat(op);
2958  *type = CFAPI_NONE;
2959  break;
2960 
2961  case CFAPI_OBJECT_PROP_FLAGS: {
2962  int iargbis;
2963 
2964  iarg = va_arg(args, int);
2965  iargbis = va_arg(args, int);
2966  *type = CFAPI_INT;
2967 
2968  if (iargbis == 1)
2969  SET_FLAG(op, iarg);
2970  else
2971  CLEAR_FLAG(op, iarg);
2972  }
2973  break;
2974 
2975  case CFAPI_OBJECT_PROP_STR:
2976  iarg = va_arg(args, int);
2977  *type = CFAPI_INT;
2978  op->stats.Str = iarg;
2979  break;
2980 
2981  case CFAPI_OBJECT_PROP_DEX:
2982  iarg = va_arg(args, int);
2983  *type = CFAPI_INT;
2984  op->stats.Dex = iarg;
2985  break;
2986 
2987  case CFAPI_OBJECT_PROP_CON:
2988  iarg = va_arg(args, int);
2989  *type = CFAPI_INT;
2990  op->stats.Con = iarg;
2991  break;
2992 
2993  case CFAPI_OBJECT_PROP_WIS:
2994  iarg = va_arg(args, int);
2995  *type = CFAPI_INT;
2996  op->stats.Wis = iarg;
2997  break;
2998 
2999  case CFAPI_OBJECT_PROP_INT:
3000  iarg = va_arg(args, int);
3001  *type = CFAPI_INT;
3002  op->stats.Int = iarg;
3003  break;
3004 
3005  case CFAPI_OBJECT_PROP_POW:
3006  iarg = va_arg(args, int);
3007  *type = CFAPI_INT;
3008  op->stats.Pow = iarg;
3009  break;
3010 
3011  case CFAPI_OBJECT_PROP_CHA:
3012  iarg = va_arg(args, int);
3013  *type = CFAPI_INT;
3014  op->stats.Cha = iarg;
3015  break;
3016 
3017  case CFAPI_OBJECT_PROP_WC:
3018  iarg = va_arg(args, int);
3019  *type = CFAPI_INT;
3020  op->stats.wc = iarg;
3021  break;
3022 
3023  case CFAPI_OBJECT_PROP_AC:
3024  iarg = va_arg(args, int);
3025  *type = CFAPI_INT;
3026  op->stats.ac = iarg;
3027  break;
3028 
3029  case CFAPI_OBJECT_PROP_HP:
3030  iarg = va_arg(args, int);
3031  *type = CFAPI_INT;
3032  op->stats.hp = iarg;
3033  break;
3034 
3035  case CFAPI_OBJECT_PROP_SP:
3036  iarg = va_arg(args, int);
3037  *type = CFAPI_INT;
3038  op->stats.sp = iarg;
3039  break;
3040 
3041  case CFAPI_OBJECT_PROP_GP:
3042  iarg = va_arg(args, int);
3043  *type = CFAPI_INT;
3044  op->stats.grace = iarg;
3045  break;
3046 
3047  case CFAPI_OBJECT_PROP_FP:
3048  iarg = va_arg(args, int);
3049  *type = CFAPI_INT;
3050  op->stats.food = iarg;
3051  break;
3052 
3054  iarg = va_arg(args, int);
3055  *type = CFAPI_INT;
3056  op->stats.maxhp = iarg;
3057  break;
3058 
3060  iarg = va_arg(args, int);
3061  *type = CFAPI_INT;
3062  op->stats.maxsp = iarg;
3063  break;
3064 
3066  iarg = va_arg(args, int);
3067  *type = CFAPI_INT;
3068  op->stats.maxgrace = iarg;
3069  break;
3070 
3071  case CFAPI_OBJECT_PROP_DAM:
3072  iarg = va_arg(args, int);
3073  *type = CFAPI_INT;
3074  op->stats.dam = iarg;
3075  break;
3076 
3077  case CFAPI_OBJECT_PROP_FACE: {
3078  const Face *face;
3079  sarg = va_arg(args, char *);
3080  ret = va_arg(args, int *);
3081  *type = CFAPI_INT;
3082  face = find_face(sarg, 0);
3083  if (face != NULL) {
3084  op->face = face;
3085  op->state = 0;
3087  (*ret) = face->number;
3088  } else
3089  (*ret) = 0;
3090  break;
3091  }
3092 
3094  const Animations *anim;
3095  sarg = va_arg(args, char *);
3096  ret = va_arg(args, int *);
3097  *type = CFAPI_INT;
3098  anim = try_find_animation(sarg);
3099  if (anim != NULL) {
3100  op->animation = anim;
3101  SET_ANIMATION(op, 0);
3103  (*ret) = anim->num;
3104  } else {
3105  (*ret) = 0;
3106  }
3107  break;
3108  }
3109 
3111  iarg = va_arg(args, int);
3112  *type = CFAPI_INT;
3113  op->duration = iarg;
3114  break;
3115 
3117  if (op->contr) {
3118  oparg = va_arg(args, object *);
3119  *type = CFAPI_POBJECT;
3120  op->contr->mark = oparg;
3121  if (oparg) {
3122  op->contr->mark_count = oparg->count;
3123  } else {
3124  op->contr->mark_count = 0;
3125  }
3126  }
3127  break;
3128 
3130  if (op->contr) {
3131  partyarg = va_arg(args, partylist *);
3132  *type = CFAPI_PPARTY;
3133  party_join(op, partyarg);
3134  }
3135  break;
3136 
3138  sarg = va_arg(args, char *);
3139  *type = CFAPI_STRING;
3140  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
3141  break;
3142 
3144  iarg = va_arg(args, int);
3145  *type = CFAPI_INT;
3146  op->contr->bed_x = iarg;
3147  break;
3148 
3150  iarg = va_arg(args, int);
3151  *type = CFAPI_INT;
3152  op->contr->bed_y = iarg;
3153  break;
3154 
3156  sarg = va_arg(args, char *);
3157  *type = CFAPI_STRING;
3158  player_set_own_title(op->contr, sarg);
3159  break;
3160 
3162  move = va_arg(args, MoveType *);
3163  op->move_type = *move & MOVE_ALL;
3165  *type = CFAPI_MOVETYPE;
3166  break;
3167 
3169  move = va_arg(args, MoveType *);
3170  op->move_block = *move & MOVE_ALL;
3172  *type = CFAPI_MOVETYPE;
3173  break;
3174 
3176  move = va_arg(args, MoveType *);
3177  op->move_allow = *move & MOVE_ALL;
3179  *type = CFAPI_MOVETYPE;
3180  break;
3181 
3183  move = va_arg(args, MoveType *);
3184  op->move_on = *move & MOVE_ALL;
3186  *type = CFAPI_MOVETYPE;
3187  break;
3188 
3190  move = va_arg(args, MoveType *);
3191  op->move_off = *move & MOVE_ALL;
3193  *type = CFAPI_MOVETYPE;
3194  break;
3195 
3197  move = va_arg(args, MoveType *);
3198  op->move_type = *move & MOVE_ALL;
3200  *type = CFAPI_MOVETYPE;
3201  break;
3202 
3203  default:
3204  break;
3205  }
3206  }
3207  va_end(args);
3208 }
3209 
3216 static void cfapi_object_apply_below(int *type, ...) {
3217  va_list args;
3218  object *applier;
3219 
3220  va_start(args, type);
3221 
3222  applier = va_arg(args, object *);
3223 
3224  va_end(args);
3225 
3226  apply_by_living_below(applier);
3227  *type = CFAPI_NONE;
3228 }
3229 
3236 static void cfapi_object_apply(int *type, ...) {
3237  va_list args;
3238  object *applied;
3239  object *applier;
3240  int aflags;
3241  int *ret;
3242 
3243  va_start(args, type);
3244 
3245  applier = va_arg(args, object *);
3246  applied = va_arg(args, object *);
3247  aflags = va_arg(args, int);
3248  ret = va_arg(args, int *);
3249 
3250  va_end(args);
3251 
3252  *type = CFAPI_INT;
3253  *ret = apply_manual(applier, applied, aflags);
3254 }
3255 
3261 static void cfapi_object_identify(int *type, ...) {
3262  va_list args;
3263  object *op, **result;
3264 
3265  va_start(args, type);
3266 
3267  op = va_arg(args, object *);
3268  result = va_arg(args, object **);
3269 
3270  va_end(args);
3271 
3272  (*result) = identify(op);
3273  *type = CFAPI_POBJECT;
3274 }
3275 
3281 static void cfapi_object_describe(int *type, ...) {
3282  va_list args;
3283  object *op;
3284  object *owner;
3285  char *desc, *final;
3286  int size;
3287 
3288  va_start(args, type);
3289 
3290  op = va_arg(args, object *);
3291  owner = va_arg(args, object *);
3292  desc = va_arg(args, char *);
3293  size = va_arg(args, int);
3294  va_end(args);
3295 
3296  *type = CFAPI_STRING;
3297  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3298  strncpy(desc, final, size);
3299  desc[size - 1] = '\0';
3300  free(final);
3301 }
3302 
3303 static void cfapi_object_drain(int *type, ...) {
3304  va_list args;
3305 
3306  object *op;
3307  int ds;
3308 
3309  va_start(args, type);
3310 
3311  op = va_arg(args, object *);
3312  ds = va_arg(args, int);
3313 
3314  va_end(args);
3315 
3316  drain_specific_stat(op, ds);
3317 
3318  *type = CFAPI_NONE;
3319 }
3320 
3321 static void cfapi_object_remove_depletion(int *type, ...) {
3322  va_list args;
3323 
3324  object *op;
3325  int level, *result;
3326 
3327  va_start(args, type);
3328 
3329  op = va_arg(args, object *);
3330  level = va_arg(args, int);
3331  result = va_arg(args, int*);
3332 
3333  va_end(args);
3334 
3335  *result = remove_depletion(op, level);
3336 
3337  *type = CFAPI_INT;
3338 }
3339 
3340 static void cfapi_object_fix(int *type, ...) {
3341  va_list args;
3342  object *op;
3343 
3344  va_start(args, type);
3345 
3346  op = va_arg(args, object *);
3347 
3348  va_end(args);
3349 
3350  fix_object(op);
3351 
3352  *type = CFAPI_NONE;
3353 }
3354 
3356 static void cfapi_object_give_skill(int *type, ...) {
3357  va_list args;
3358 
3359  object *op;
3360  char *skillname;
3361 
3362  va_start(args, type);
3363 
3364  op = va_arg(args, object *);
3365  skillname = va_arg(args, char *);
3366 
3367  va_end(args);
3368 
3369  *type = CFAPI_POBJECT;
3370  give_skill_by_name(op, skillname);
3371 }
3372 
3373 static void cfapi_object_transmute(int *type, ...) {
3374  va_list args;
3375 
3376  object *op;
3377  object *chg;
3378 
3379  va_start(args, type);
3380 
3381  op = va_arg(args, object *);
3382  chg = va_arg(args, object *);
3383 
3384  va_end(args);
3385 
3386  transmute_materialname(op, chg);
3387  *type = CFAPI_NONE;
3388 }
3389 
3390 static void cfapi_object_remove(int *type, ...) {
3391  va_list args;
3392  object *op;
3393 
3394  va_start(args, type);
3395 
3396  op = va_arg(args, object *);
3397 
3398  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3399  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3400  va_end(args);
3401  *type = CFAPI_NONE;
3402  return;
3403  }
3404 
3405  va_end(args);
3406 
3407  object_remove(op);
3408  *type = CFAPI_NONE;
3409 }
3410 
3411 static void cfapi_object_delete(int *type, ...) {
3412  va_list args;
3413  object *op;
3414 
3415  va_start(args, type);
3416 
3417  op = va_arg(args, object *);
3418 
3419  if (QUERY_FLAG(op, FLAG_FREED) || !QUERY_FLAG(op, FLAG_REMOVED)) {
3420  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3421  *type = CFAPI_NONE;
3422  va_end(args);
3423  return;
3424  }
3425 
3426  va_end(args);
3427 
3429 
3430  *type = CFAPI_NONE;
3431 }
3432 
3438 static void cfapi_object_clone(int *type, ...) {
3439  va_list args;
3440  object *op;
3441  int kind;
3442  object **robj;
3443 
3444  va_start(args, type);
3445 
3446  op = va_arg(args, object *);
3447  kind = va_arg(args, int);
3448  robj = va_arg(args, object **);
3449 
3450  va_end(args);
3451 
3452  if (kind == 0) {
3453  *type = CFAPI_POBJECT;
3454  *robj = object_create_clone(op);
3455  } else {
3456  object *tmp;
3457  tmp = object_new();
3458  object_copy(op, tmp);
3459  *type = CFAPI_POBJECT;
3460  *robj = tmp;
3461  }
3462  return;
3463 }
3464 
3470 static void cfapi_object_create(int *type, ...) {
3471  va_list args;
3472  int ival;
3473  object **robj;
3474  va_start(args, type);
3475  ival = va_arg(args, int);
3476 
3477  *type = CFAPI_POBJECT;
3478  switch (ival) {
3479  case 0:
3480  robj = va_arg(args, object **);
3481  *robj = object_new();
3482  break;
3483 
3484  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3485  const char *sval;
3486  archetype *at;
3487 
3488  sval = va_arg(args, const char *);
3489  robj = va_arg(args, object **);
3490  va_end(args);
3491 
3492  at = try_find_archetype(sval);
3493  if (!at)
3494  at = find_archetype_by_object_name(sval);
3495  if (at) {
3496  *robj = object_create_arch(at);
3497  } else
3498  *robj = NULL;
3499  }
3500  break;
3501 
3502  default:
3503  *type = CFAPI_NONE;
3504  break;
3505  }
3506  va_end(args);
3507 }
3508 
3509 static void cfapi_object_insert(int *type, ...) {
3510  va_list args;
3511  object *op;
3512  object *orig;
3513  mapstruct *map;
3514  int flag, x, y;
3515  int itype;
3516  object **robj;
3517 
3518  va_start(args, type);
3519 
3520  op = va_arg(args, object *);
3521  if (!op) {
3522  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3523  va_end(args);
3524  return;
3525  }
3526  if (QUERY_FLAG(op, FLAG_FREED)) {
3527  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3528  va_end(args);
3529  return;
3530  }
3531  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3532  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3533  object_remove(op);
3534  }
3535  itype = va_arg(args, int);
3536 
3537  switch (itype) {
3538  case 0:
3539  map = va_arg(args, mapstruct *);
3540  orig = va_arg(args, object *);
3541  flag = va_arg(args, int);
3542  x = va_arg(args, int);
3543  y = va_arg(args, int);
3544  robj = va_arg(args, object **);
3545  if (!map) {
3546  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3548  *robj = NULL;
3549  } else
3550  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3551  *type = CFAPI_POBJECT;
3552  break;
3553 
3554  case 1:
3555  map = va_arg(args, mapstruct *);
3556  orig = va_arg(args, object *);
3557  flag = va_arg(args, int);
3558  robj = va_arg(args, object **);
3559  if (!map) {
3560  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3562  *robj = NULL;
3563  } else
3564  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3565  *type = CFAPI_POBJECT;
3566  break;
3567 
3568  case 2:
3569  map = va_arg(args, mapstruct *);
3570  orig = va_arg(args, object *);
3571  flag = va_arg(args, int);
3572  x = va_arg(args, int);
3573  y = va_arg(args, int);
3574  robj = va_arg(args, object **);
3575  if (!map) {
3576  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3578  *robj = NULL;
3579  } else {
3580  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3581  if (dir != -1) {
3582  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3583  } else {
3585  *robj = NULL;
3586  }
3587  }
3588  *type = CFAPI_POBJECT;
3589  break;
3590 
3591  case 3:
3592  orig = va_arg(args, object *);
3593  robj = va_arg(args, object **);
3594  if (!orig) {
3595  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3597  *robj = NULL;
3598  } else
3599  *robj = object_insert_in_ob(op, orig);
3600  *type = CFAPI_POBJECT;
3601  break;
3602 
3603  default:
3604  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3606  *type = CFAPI_NONE;
3607  break;
3608  }
3609 
3610  va_end(args);
3611 }
3617 static void cfapi_object_split(int *type, ...) {
3618  va_list args;
3619 
3620  int nr, size;
3621  object *op;
3622  char *buf;
3623  object **split;
3624 
3625  va_start(args, type);
3626 
3627  op = va_arg(args, object *);
3628  nr = va_arg(args, int);
3629  buf = va_arg(args, char *);
3630  size = va_arg(args, int);
3631  split = va_arg(args, object **);
3632  va_end(args);
3633 
3634  *split = object_split(op, nr, buf, size);
3635  if (*split != NULL)
3636  {
3637  *type = CFAPI_POBJECT;
3638  }
3639  else
3640  {
3641  *type = CFAPI_NONE;
3642  }
3643 }
3644 
3650 static void cfapi_object_merge(int *type, ...) {
3651  va_list args;
3652  object *op;
3653  object *op2;
3654  object **merge;
3655 
3656  va_start(args, type);
3657 
3658  op = va_arg(args, object *);
3659  op2 = va_arg(args, object *);
3660  merge = va_arg(args, object **);
3661 
3662  va_end(args);
3663 
3664  *type = CFAPI_POBJECT;
3665  *merge = object_merge(op, op2);
3666 }
3667 
3673 static void cfapi_object_distance(int *type, ...) {
3674  va_list args;
3675  object *op;
3676  object *op2;
3677  int *rint;
3678  va_start(args, type);
3679 
3680  op = va_arg(args, object *);
3681  op2 = va_arg(args, object *);
3682  rint = va_arg(args, int *);
3683 
3684  va_end(args);
3685 
3686  *type = CFAPI_INT;
3687  *rint = object_distance(op, op2);
3688 }
3694 static void cfapi_object_update(int *type, ...) {
3695  va_list args;
3696  int action;
3697  object *op;
3698  va_start(args, type);
3699 
3700  op = va_arg(args, object *);
3701  action = va_arg(args, int);
3702 
3703  va_end(args);
3704 
3705  object_update(op, action);
3706  *type = CFAPI_NONE;
3707 }
3708 
3714 static void cfapi_object_clear(int *type, ...) {
3715  va_list args;
3716  object *op;
3717  va_start(args, type);
3718 
3719  op = va_arg(args, object *);
3720 
3721  va_end(args);
3722 
3723  object_clear(op);
3724  *type = CFAPI_NONE;
3725 }
3726 
3732 static void cfapi_object_reset(int *type, ...) {
3733  va_list args;
3734  object *op;
3735 
3736  va_start(args, type);
3737 
3738  op = va_arg(args, object *);
3739 
3740  va_end(args);
3741 
3742  object_reset(op);
3743  *type = CFAPI_NONE;
3744 }
3745 
3746 static void cfapi_object_clean_object(int *type, ...) {
3747  va_list args;
3748  object *op;
3749 
3750  va_start(args, type);
3751  op = va_arg(args, object *);
3752  clean_object(op);
3753  va_end(args);
3754  *type = CFAPI_NONE;
3755 }
3756 
3757 static void cfapi_object_on_same_map(int *type, ...) {
3758  va_list args;
3759  object *op1;
3760  object *op2;
3761  int *rint;
3762 
3763  va_start(args, type);
3764  op1 = va_arg(args, object *);
3765  op2 = va_arg(args, object *);
3766  rint = va_arg(args, int *);
3767  va_end(args);
3768 
3769  *type = CFAPI_INT;
3770  *rint = on_same_map(op1, op2);
3771 }
3772 
3773 static void cfapi_object_spring_trap(int *type, ...) {
3774  object *trap;
3775  object *victim;
3776  va_list args;
3777 
3778  va_start(args, type);
3779  trap = va_arg(args, object *);
3780  victim = va_arg(args, object *);
3781  va_end(args);
3782 
3783  spring_trap(trap, victim);
3784  *type = CFAPI_NONE;
3785 }
3786 
3792 static void cfapi_object_check_trigger(int *type, ...) {
3793  object *op;
3794  object *cause;
3795  va_list args;
3796  int *rint;
3797 
3798  va_start(args, type);
3799  op = va_arg(args, object *);
3800  cause = va_arg(args, object *);
3801  rint = va_arg(args, int *);
3802  va_end(args);
3803 
3804  *rint = check_trigger(op, cause);
3805  *type = CFAPI_INT;
3806 }
3807 
3819 static void cfapi_map_trigger_connected(int *type, ...) {
3820  objectlink *ol;
3821  object *cause;
3822  int state;
3823  va_list args;
3824 
3825  va_start(args, type);
3826  ol = va_arg(args, objectlink *);
3827  cause = va_arg(args, object *);
3828  state = va_arg(args, int);
3829  va_end(args);
3830  trigger_connected(ol, cause, state);
3831  *type = CFAPI_NONE;
3832 }
3833 
3839 static void cfapi_object_query_money(int *type, ...) {
3840  object *op;
3841  va_list args;
3842  int *rint;
3843 
3844  va_start(args, type);
3845  op = va_arg(args, object *);
3846  rint = va_arg(args, int *);
3847  va_end(args);
3848 
3849  *rint = query_money(op);
3850  *type = CFAPI_INT;
3851 }
3852 
3858 static void cfapi_object_cast(int *type, ...) {
3859  object *op;
3860  object *sp;
3861  int dir;
3862  char *str;
3863  object *caster;
3864  va_list args;
3865  int *rint;
3866 
3867  va_start(args, type);
3868  op = va_arg(args, object *);
3869  caster = va_arg(args, object *);
3870  dir = va_arg(args, int);
3871  sp = va_arg(args, object *);
3872  str = va_arg(args, char *);
3873  rint = va_arg(args, int *);
3874  va_end(args);
3875 
3876  *type = CFAPI_INT;
3877 
3878  if (!op->map) {
3879  *rint = -1;
3880  return;
3881  }
3882 
3883  *rint = cast_spell(op, caster, dir, sp, str);
3884 }
3885 
3886 static void cfapi_object_learn_spell(int *type, ...) {
3887  object *op;
3888  object *sp;
3889  int prayer;
3890  va_list args;
3891 
3892  va_start(args, type);
3893  op = va_arg(args, object *);
3894  sp = va_arg(args, object *);
3895  prayer = va_arg(args, int);
3896  va_end(args);
3897  do_learn_spell(op, sp, prayer);
3898  *type = CFAPI_NONE;
3899 }
3900 
3901 static void cfapi_object_forget_spell(int *type, ...) {
3902  object *op;
3903  object *sp;
3904  va_list args;
3905  char name[MAX_BUF];
3906 
3907  va_start(args, type);
3908  op = va_arg(args, object *);
3909  sp = va_arg(args, object *);
3910  va_end(args);
3911  query_name(sp, name, MAX_BUF);
3912  do_forget_spell(op, name);
3913  *type = CFAPI_NONE;
3914 }
3915 
3921 static void cfapi_object_check_spell(int *type, ...) {
3922  object *op;
3923  char *spellname;
3924  va_list args;
3925  object **robj;
3926 
3927  va_start(args, type);
3928  op = va_arg(args, object *);
3929  spellname = va_arg(args, char *);
3930  robj = va_arg(args, object **);
3931  va_end(args);
3932  *robj = check_spell_known(op, spellname);
3933  *type = CFAPI_POBJECT;
3934 }
3935 
3941 static void cfapi_object_pay_amount(int *type, ...) {
3942  object *op;
3943  uint64_t amount;
3944  va_list args;
3945  int *rint;
3946 
3947  va_start(args, type);
3948  op = va_arg(args, object *);
3949  amount = va_arg(args, uint64_t);
3950  rint = va_arg(args, int *);
3951  va_end(args);
3952 
3953  *rint = pay_for_amount(amount, op);
3954  *type = CFAPI_INT;
3955 }
3956 
3962 static void cfapi_object_pay_item(int *type, ...) {
3963  object *op;
3964  object *tobuy;
3965  int *rint;
3966 
3967  va_list args;
3968 
3969  va_start(args, type);
3970  tobuy = va_arg(args, object *);
3971  op = va_arg(args, object *);
3972  rint = va_arg(args, int *);
3973  va_end(args);
3974 
3975  *rint = pay_for_item(tobuy, op);
3976  *type = CFAPI_INT;
3977 }
3978 
3986 static void cfapi_object_transfer(int *type, ...) {
3987  object *op;
3988  object *originator;
3989  int x, y, randompos, ttype, flag;
3990  va_list args;
3991  mapstruct *map;
3992  int *rint;
3993  object **robj;
3994 
3995  va_start(args, type);
3996  op = va_arg(args, object *);
3997  ttype = va_arg(args, int);
3998  switch (ttype) {
3999  case 0:
4000  x = va_arg(args, int);
4001  y = va_arg(args, int);
4002  randompos = va_arg(args, int);
4003  originator = va_arg(args, object *);
4004  rint = va_arg(args, int *);
4005  va_end(args);
4006 
4007  *rint = transfer_ob(op, x, y, randompos, originator);
4008  *type = CFAPI_INT;
4009  return;
4010  break;
4011 
4012  case 1:
4013  map = va_arg(args, mapstruct *);
4014  originator = va_arg(args, object *);
4015  flag = va_arg(args, int);
4016  x = va_arg(args, int);
4017  y = va_arg(args, int);
4018  robj = va_arg(args, object **);
4019  va_end(args);
4020  if (x < 0 || y < 0) {
4021  x = map->enter_x;
4022  y = map->enter_y;
4023  }
4024  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
4025  *type = CFAPI_POBJECT;
4026  return;
4027  break;
4028 
4029  case 2:
4030  x = va_arg(args, int);
4031  y = va_arg(args, int);
4032  rint = va_arg(args, int *);
4033  va_end(args);
4034 
4035  *rint = move_to(op, x, y);
4036  *type = CFAPI_INT;
4037  return;
4038 
4039  default:
4040  va_end(args);
4041  *type = CFAPI_NONE;
4042  return;
4043  break;
4044  }
4045 }
4046 
4050 static void cfapi_object_find_archetype_inside(int *type, ...) {
4051  object *op;
4052  char *str;
4053  va_list args;
4054  object **robj;
4055 
4056  *type = CFAPI_POBJECT;
4057  va_start(args, type);
4058  op = va_arg(args, object *);
4059 
4060  str = va_arg(args, char *);
4061  robj = va_arg(args, object **);
4062  archetype *at = try_find_archetype(str);
4063  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
4064  if (*robj == NULL) {
4065  char name[MAX_BUF];
4066 
4067  /* Search by name or slaying instead */
4068  FOR_INV_PREPARE(op, tmp) {
4069  query_name(tmp, name, MAX_BUF);
4070  if (!strncmp(name, str, strlen(str)))
4071  *robj = tmp;
4072  if (!strncmp(tmp->name, str, strlen(str)))
4073  *robj = tmp;
4074  if (tmp->slaying && !strcmp(tmp->slaying, str))
4075  *robj = tmp;
4076  if (*robj != NULL)
4077  break;
4078  } FOR_INV_FINISH();
4079  }
4080  va_end(args);
4081 }
4082 
4083 static void cfapi_object_find_by_arch_name(int *type, ...) {
4084  const object *who;
4085  object **result;
4086  const char *name;
4087  va_list args;
4088 
4089  va_start(args, type);
4090  who = va_arg(args, const object *);
4091  name = va_arg(args, const char *);
4092  result = va_arg(args, object **);
4093  va_end(args);
4094  *type = CFAPI_POBJECT;
4095 
4096  *result = object_find_by_arch_name(who, name);
4097 }
4098 
4099 static void cfapi_object_find_by_name(int *type, ...) {
4100  const object *who;
4101  object **result;
4102  const char *name;
4103  va_list args;
4104 
4105  va_start(args, type);
4106  who = va_arg(args, const object *);
4107  name = va_arg(args, const char *);
4108  result = va_arg(args, object **);
4109  va_end(args);
4110  *type = CFAPI_POBJECT;
4111 
4112  *result = object_find_by_name(who, name);
4113 }
4114 
4120 static void cfapi_object_drop(int *type, ...) {
4121  object *op;
4122  object *author;
4123  va_list args;
4124 
4125  va_start(args, type);
4126  op = va_arg(args, object *);
4127  author = va_arg(args, object *);
4128  va_end(args);
4129  *type = CFAPI_NONE;
4130 
4131  if (QUERY_FLAG(op, FLAG_NO_DROP))
4132  return;
4133  drop(author, op);
4134 
4135  if (author->type == PLAYER) {
4136  author->contr->count = 0;
4137  author->contr->socket.update_look = 1;
4138  }
4139 }
4140 
4144 static void cfapi_object_change_abil(int *type, ...) {
4145  object *op, *tmp;
4146  int *rint;
4147  va_list args;
4148 
4149  va_start(args, type);
4150  op = va_arg(args, object *);
4151  tmp = va_arg(args, object *);
4152  rint = va_arg(args, int *);
4153  va_end(args);
4154 
4155  *type = CFAPI_INT;
4156  *rint = change_abil(op, tmp);
4157 }
4158 
4159 static void cfapi_object_say(int *type, ...) {
4160  object *op;
4161  char *msg;
4162  va_list args;
4163  int *rint;
4164  char empty[] = "";
4165 
4166  va_start(args, type);
4167  op = va_arg(args, object *);
4168  msg = va_arg(args, char *);
4169  rint = va_arg(args, int *);
4170  va_end(args);
4171 
4172  if (op->type == PLAYER) {
4173  command_say(op, msg == NULL ? empty : msg);
4174  } else {
4175  monster_npc_say(op, msg);
4176  }
4177  *rint = 0;
4178  *type = CFAPI_INT;
4179 }
4180 
4181 /* PLAYER SUBCLASS */
4182 
4188 static void cfapi_player_find(int *type, ...) {
4189  va_list args;
4190  char *sval;
4191  player **rpl;
4192  va_start(args, type);
4193 
4194  sval = va_arg(args, char *);
4195  rpl = va_arg(args, player **);
4196  va_end(args);
4197 
4198  *rpl = find_player_partial_name(sval);
4199 
4200  *type = CFAPI_PPLAYER;
4201 }
4202 
4203 static void cfapi_player_message(int *type, ...) {
4204  va_list args;
4205  int flags;
4206  int pri;
4207  object *pl;
4208  char *buf;
4209 
4210  va_start(args, type);
4211 
4212  flags = va_arg(args, int);
4213  pri = va_arg(args, int);
4214  pl = va_arg(args, object *);
4215  buf = va_arg(args, char *);
4216  va_end(args);
4217 
4218  draw_ext_info(flags, pri, pl, MSG_TYPE_MISC, MSG_SUBTYPE_NONE,
4219  buf);
4220  *type = CFAPI_NONE;
4221 }
4222 
4229 static void cfapi_object_perm_exp(int *type, ...) {
4230  va_list args;
4231  object *op;
4232  int64_t *rlong;
4233 
4234  va_start(args, type);
4235  op = va_arg(args, object *);
4236  rlong = va_arg(args, int64_t *);
4237  va_end(args);
4238 
4239  *type = CFAPI_SINT64;
4240  *rlong = PERM_EXP(op->total_exp);
4241 }
4242 
4248 static void cfapi_object_change_exp(int *type, ...) {
4249  va_list args;
4250  int flag;
4251  object *ob;
4252  const char *skill;
4253  int64_t exp;
4254 
4255  va_start(args, type);
4256  ob = va_arg(args, object *);
4257  exp = va_arg(args, int64_t);
4258  skill = va_arg(args, const char *);
4259  flag = va_arg(args, int);
4260  va_end(args);
4261 
4262  *type = CFAPI_NONE;
4263  change_exp(ob, exp, skill, flag);
4264 }
4265 
4271 static void cfapi_player_can_pay(int *type, ...) {
4272  va_list args;
4273  object *pl;
4274  int *rint;
4275 
4276  va_start(args, type);
4277  pl = va_arg(args, object *);
4278  rint = va_arg(args, int *);
4279  va_end(args);
4280 
4281  *rint = can_pay(pl);
4282  *type = CFAPI_INT;
4283 }
4284 
4290 static void cfapi_player_knowledge(int *type, ...) {
4291  va_list args;
4292  object *pl;
4293  int *rint, what;
4294  const char *knowledge;
4295 
4296  va_start(args, type);
4297  what = va_arg(args, int);
4298 
4299  switch(what)
4300  {
4301  case 1:
4302  pl = va_arg(args, object *);
4303  knowledge = va_arg(args, const char *);
4304  rint = va_arg(args, int *);
4305 
4306  *type = CFAPI_INT;
4307 
4308  if (pl->contr == NULL) {
4309  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4310  *rint = 0;
4311  va_end(args);
4312  return;
4313  }
4314 
4315  *rint = knowledge_player_knows(pl->contr, knowledge);
4316  break;
4317 
4318  case 2:
4319  pl = va_arg(args, object *);
4320  knowledge = va_arg(args, const char *);
4321  *type = CFAPI_NONE;
4322  if (pl->contr != NULL)
4323  knowledge_give(pl->contr, knowledge, NULL);
4324 
4325  break;
4326 
4327  default:
4328  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4329  }
4330 
4331  va_end(args);
4332 }
4333 
4339 static void cfapi_object_teleport(int *type, ...) {
4340  mapstruct *map;
4341  int x, y;
4342  object *who;
4343  int *res;
4344  va_list args;
4345 
4346  va_start(args, type);
4347  who = va_arg(args, object *);
4348  map = va_arg(args, mapstruct *);
4349  x = va_arg(args, int);
4350  y = va_arg(args, int);
4351  res = va_arg(args, int *);
4352  *type = CFAPI_INT;
4353 
4354  if (!out_of_map(map, x, y)) {
4355  int k;
4356  k = object_find_first_free_spot(who, map, x, y);
4357  if (k == -1) {
4358  *res = 1;
4359  va_end(args);
4360  return;
4361  }
4362 
4363  if (!QUERY_FLAG(who, FLAG_REMOVED)) {
4364  object_remove(who);
4365  }
4366 
4367  object_insert_in_map_at(who, map, NULL, 0, x, y);
4368  if (who->type == PLAYER) {
4369  map_newmap_cmd(&who->contr->socket);
4371  }
4372  *res = 0;
4373  }
4374 
4375  va_end(args);
4376 }
4377 
4378 static void cfapi_object_pickup(int *type, ...) {
4379  object *who;
4380  object *what;
4381  va_list args;
4382 
4383  va_start(args, type);
4384  who = va_arg(args, object *);
4385  what = va_arg(args, object *);
4386  va_end(args);
4387 
4388  pick_up(who, what);
4389  *type = CFAPI_NONE;
4390 }
4391 
4392 /* Archetype-related functions */
4393 static void cfapi_archetype_get_property(int *type, ...) {
4394  int prop;
4395  archetype *arch;
4396  va_list args;
4397  sstring *rsstring;
4398  archetype **rarch;
4399  object **robject;
4400 
4401  va_start(args, type);
4402  arch = va_arg(args, archetype *);
4403  prop = va_arg(args, int);
4404  switch (prop) {
4405  case CFAPI_ARCH_PROP_NAME:
4406  *type = CFAPI_SSTRING;
4407  rsstring = va_arg(args, sstring *);
4408  *rsstring = arch->name;
4409  break;
4410 
4411  case CFAPI_ARCH_PROP_NEXT:
4412  *type = CFAPI_PARCH;
4413  rarch = va_arg(args, archetype **);
4414  *rarch = arch ? arch->next : first_archetype;
4415  break;
4416 
4417  case CFAPI_ARCH_PROP_HEAD:
4418  *type = CFAPI_PARCH;
4419  rarch = va_arg(args, archetype **);
4420  *rarch = arch->head;
4421  break;
4422 
4423  case CFAPI_ARCH_PROP_MORE:
4424  *type = CFAPI_PARCH;
4425  rarch = va_arg(args, archetype **);
4426  *rarch = arch->more;
4427  break;
4428 
4429  case CFAPI_ARCH_PROP_CLONE:
4430  *type = CFAPI_POBJECT;
4431  robject = va_arg(args, object **);
4432  *robject = &arch->clone;
4433  break;
4434 
4435  default:
4436  *type = CFAPI_NONE;
4437  break;
4438  }
4439  va_end(args);
4440 }
4441 
4448 static void cfapi_party_get_property(int *type, ...) {
4449  partylist *party;
4450  int prop;
4451  va_list args;
4452  object *obarg;
4453  sstring *rsstring;
4454  player **rplayer;
4455  partylist **rparty;
4456 
4457  va_start(args, type);
4458  party = va_arg(args, partylist *);
4459  prop = va_arg(args, int);
4460  switch (prop) {
4461  case CFAPI_PARTY_PROP_NAME:
4462  rsstring = va_arg(args, sstring *);
4463  *rsstring = party->partyname;
4464  *type = CFAPI_SSTRING;
4465  break;
4466 
4467  case CFAPI_PARTY_PROP_NEXT:
4468  rparty = va_arg(args, partylist **);
4469  *rparty = (party ? party_get_next(party) : party_get_first());
4470  *type = CFAPI_PPARTY;
4471  break;
4472 
4474  rsstring = va_arg(args, sstring *);
4475  *rsstring = party_get_password(party);
4476  *type = CFAPI_SSTRING;
4477  break;
4478 
4480  *type = CFAPI_PPLAYER;
4481  obarg = va_arg(args, object *);
4482  rplayer = va_arg(args, player **);
4483  *rplayer = (obarg ? obarg->contr : first_player);
4484  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4485  if ((*rplayer)->ob->contr->party == party) {
4486  break;
4487  }
4488  break;
4489 
4490  default:
4491  *type = CFAPI_NONE;
4492  break;
4493  }
4494  va_end(args);
4495 }
4496 
4503 static void cfapi_region_get_property(int *type, ...) {
4504  region *reg;
4505  int prop, *rint;
4506  va_list args;
4508  sstring *rsstring;
4509  region **rregion;
4510 
4511  va_start(args, type);
4512  reg = va_arg(args, region *);
4513  prop = va_arg(args, int);
4514  switch (prop) {
4516  rsstring = va_arg(args, sstring *);
4517  *rsstring = reg->name;
4518  *type = CFAPI_SSTRING;
4519  break;
4520 
4522  rregion = va_arg(args, region **);
4523  *rregion = (reg ? reg->next : first_region);
4524  *type = CFAPI_PREGION;
4525  break;
4526 
4528  rregion = va_arg(args, region **);
4529  *rregion = reg->parent;
4530  *type = CFAPI_PREGION;
4531  break;
4532 
4534  rsstring = va_arg(args, sstring *);
4535  *rsstring = reg->longname;
4536  *type = CFAPI_SSTRING;
4537  break;
4538 
4540  rsstring = va_arg(args, sstring *);
4541  *rsstring = reg->msg;
4542  *type = CFAPI_SSTRING;
4543  break;
4544 
4547  rint = va_arg(args, int*);
4548  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4549  *type = CFAPI_INT;
4550  break;
4551 
4553  rsstring = va_arg(args, sstring *);
4554  *rsstring = reg->jailmap;
4555  *type = CFAPI_SSTRING;
4556  break;
4557 
4558  default:
4559  *type = CFAPI_NONE;
4560  break;
4561  }
4562  va_end(args);
4563 }
4564 
4576 static void cfapi_friendlylist_get_next(int *type, ...) {
4577  object *ob;
4578  va_list args;
4579  objectlink *link;
4580  object **robject;
4581 
4582  va_start(args, type);
4583  ob = va_arg(args, object *);
4584  robject = va_arg(args, object **);
4585  va_end(args);
4586 
4587  *type = CFAPI_POBJECT;
4588  *robject = NULL;
4589 
4590  if (ob) {
4591  for (link = first_friendly_object; link; link = link->next) {
4592  if (ob == link->ob) {
4593  if (link->next) {
4594  *robject = link->next->ob;
4595  return;
4596  } else {
4597  return;
4598  }
4599  }
4600  }
4601  return;
4602  }
4603 
4605  *robject = first_friendly_object->ob;
4606 }
4607 
4608 /*
4609  * Random-map related stuff.
4610  */
4611 
4618 static void cfapi_set_random_map_variable(int *type, ...) {
4619  va_list args;
4620  RMParms *rp;
4621  const char *buf;
4622  int *ret;
4623 
4624  va_start(args, type);
4625  rp = va_arg(args, RMParms *);
4626  buf = va_arg(args, const char *);
4627  ret = va_arg(args, int *);
4628  va_end(args);
4629 
4630  *ret = set_random_map_variable(rp, buf);
4631  *type = CFAPI_INT;
4632 }
4633 
4640 static void cfapi_generate_random_map(int *type, ...) {
4641  va_list args;
4642  const char *name;
4643  RMParms *rp;
4644  char **use_layout;
4645  mapstruct **ret;
4646 
4647  va_start(args, type);
4648  name = va_arg(args, const char *);
4649  rp = va_arg(args, RMParms *);
4650  use_layout = va_arg(args, char **);
4651  ret = va_arg(args, mapstruct **);
4652  va_end(args);
4653 
4654  *ret = generate_random_map(name, rp, use_layout);
4655 }
4656 
4657 static void cfapi_object_user_event(int *type, ...) {
4658  object *op;
4659  object *activator;
4660  object *third;
4661  const char *message;
4662  int fix;
4663  int *ret;
4664  va_list args;
4665 
4666  va_start(args, type);
4667  op = va_arg(args, object *);
4668  activator = va_arg(args, object *);
4669  third = va_arg(args, object *);
4670  message = va_arg(args, const char *);
4671  fix = va_arg(args, int);
4672  ret = va_arg(args, int *);
4673  va_end(args);
4674 
4675  *ret = user_event(op, activator, third, message, fix);
4676  *type = CFAPI_INT;
4677 }
4678 
4681 static void cfapi_player_quest(int *type, ...) {
4682  int op;
4683  va_list args;
4684  object *player;
4685  sstring code;
4686 
4687  va_start(args, type);
4688  op = va_arg(args, int);
4689  player = va_arg(args, object *);
4690  code = va_arg(args, sstring);
4691 
4692  if (player->contr == NULL) {
4693  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4694  va_end(args);
4695  /* crash/quit? */
4696  return;
4697  }
4698 
4699  switch(op) {
4700  case CFAPI_PLAYER_QUEST_START: {
4701  int state = va_arg(args, int);
4702  quest_start(player->contr, code, state);
4703  *type = CFAPI_NONE;
4704  break;
4705  }
4707  int *ret = va_arg(args, int *);
4708  *ret = quest_get_player_state(player->contr, code);
4709  *type = CFAPI_INT;
4710  break;
4711  }
4713  int state = va_arg(args, int);
4714  quest_set_player_state(player->contr, code, state);
4715  *type = CFAPI_NONE;
4716  break;
4717  }
4719  int *ret = va_arg(args, int*);
4720  *ret = quest_was_completed(player->contr, code);
4721  *type = CFAPI_INT;
4722  break;
4723  }
4724  default:
4725  LOG(llevError, "invalid quest type: %d\n", op);
4726  *type = CFAPI_NONE;
4727  }
4728 
4729  va_end(args);
4730 }
4731 
4732 /*****************************************************************************/
4733 /* NEW PLUGIN STUFF ENDS HERE */
4734 /*****************************************************************************/
4735 
4736 
4749  int i;
4750  crossfire_plugin *cp;
4751 
4752  assert(cmd != NULL);
4753  assert(command != NULL);
4754 
4755  if (plugins_list == NULL)
4756  return NULL;
4757 
4758  for (cp = plugins_list; cp != NULL; cp = cp->next) {
4759  if (cp->propfunc(&i, "command?", cmd, command) != NULL)
4760  return command;
4761  }
4762  return NULL;
4763 }
4764 
4769 void initPlugins(void) {
4770  struct dirent *currentfile;
4771  DIR *plugdir;
4772  size_t l;
4773  char buf[MAX_BUF];
4774 
4775  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4776  LOG(llevDebug, "plugins: loading from %s\n", buf);
4777 
4778  plugdir = opendir(buf);
4779  if (plugdir == NULL)
4780  return;
4781 
4782  while ((currentfile = readdir(plugdir)) != NULL) {
4783  l = strlen(currentfile->d_name);
4784  if (l > strlen(PLUGIN_SUFFIX)) {
4786  int ignore = 0;
4787 
4788  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4789  continue;
4790 
4791  while (disable) {
4792  if (strcmp(disable->name, "All") == 0) {
4793  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4794  ignore = 1;
4795  break;
4796  }
4797  if (strncmp(disable->name, currentfile->d_name, strlen(disable->name)) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + strlen(disable->name)) {
4798  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4799  ignore = 1;
4800  break;
4801  }
4802  disable = disable->next;
4803  }
4804  if (ignore == 0) {
4805  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4806  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4807  plugins_init_plugin(buf);
4808  }
4809  }
4810  }
4811 
4812  closedir(plugdir);
4813 }
4814 
4819 void cleanupPlugins(void) {
4820  crossfire_plugin *cp;
4821 
4822  if (!plugins_list)
4823  return;
4824 
4825  for (cp = plugins_list; cp != NULL; ) {
4826  crossfire_plugin *next = cp->next;
4827  if (cp->closefunc)
4828  cp->closefunc();
4829  /* Don't actually unload plugins, it makes backtraces for memory
4830  * debugging (printed at exit) messed up. And it doesn't matter if we
4831  * don't free it here. The OS will do it for us.
4832  */
4833  /* plugins_dlclose(cp->libptr); */
4834  free(cp);
4835  cp = next;
4836  }
4837  plugins_list = NULL;
4838 }
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:249
#define CFAPI_OBJECT_PROP_MAP
Definition: plugin.h:180
#define CFAPI_OBJECT_PROP_RUN_AWAY
Definition: plugin.h:226
static void cfapi_object_clear(int *type,...)
Definition: plugins.c:3714
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:316
int object_distance(const object *ob1, const object *ob2)
Definition: object.c:3440
void spring_trap(object *trap, object *victim)
Definition: rune.c:205
static void cfapi_map_trigger_connected(int *type,...)
Definition: plugins.c:3819
static void copy_message(object *op, const char *msg)
Definition: plugins.c:2530
static void cfapi_set_random_map_variable(int *type,...)
Definition: plugins.c:4618
char path[HUGE_BUF]
Definition: map.h:365
#define CFAPI_OBJECT_PROP_MAGIC
Definition: plugin.h:207
void apply_by_living_below(object *pl)
Definition: apply.c:696
#define CFAPI_PLAYER_QUEST_GET_STATE
Definition: plugin.h:292
#define MSG_TYPE_MISC
Definition: newclient.h:389
#define FLAG_NO_DROP
Definition: define.h:289
int8_t Int
Definition: living.h:36
#define CFAPI_PARTY_PROP_PASSWORD
Definition: plugin.h:323
Definition: player.h:92
int apply_manual(object *op, object *tmp, int aflag)
Definition: apply.c:598
#define CFAPI_OBJECT_PROP_MATERIAL
Definition: plugin.h:205
const char * determine_god(object *op)
Definition: gods.c:106
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:270
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout)
Definition: random_map.c:74
int8_t ac
Definition: living.h:38
#define CFAPI_OBJECT_PROP_SP
Definition: plugin.h:259
int32_t weight_limit
Definition: object.h:368
#define UP_OBJ_FACE
Definition: object.h:519
#define CFAPI_OBJECT_PROP_CARRYING
Definition: plugin.h:220
MoveType move_type
Definition: object.h:427
#define plugins_dlopen(fname)
Definition: plugin.h:164
#define EVENT_REMOVE
Definition: plugin.h:98
#define CFAPI_OBJECT_PROP_NAME
Definition: plugin.h:182
#define CFAPI_OBJECT_PROP_OB_BELOW
Definition: plugin.h:173
#define CFAPI_PREGION
Definition: plugin.h:118
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:289
#define EVENT_SHOUT
Definition: plugin.h:99
#define CFAPI_MAP_PROP_NAME
Definition: plugin.h:300
int16_t jaily
Definition: map.h:298
void object_free(object *ob, int flags)
Definition: object.c:1336
int move_player(object *op, int dir)
Definition: player.c:3016
MoveType move_on
Definition: object.h:430
static void cfapi_object_drain(int *type,...)
Definition: plugins.c:3303
static void cfapi_system_register_global_event(int *type,...)
Definition: plugins.c:857
void quest_start(player *pl, sstring quest_code, int state)
Definition: quest.c:1096
static void cfapi_system_find_animation(int *type,...)
Definition: plugins.c:799
static void cfapi_object_move(int *type,...)
Definition: plugins.c:1633
#define CFAPI_OBJECT_PROP_RACE
Definition: plugin.h:185
object * check_spell_known(object *op, const char *name)
Definition: spell_util.c:433
const Face * get_face_by_id(uint16_t id)
Definition: image.c:653
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:309
static void cfapi_object_check_spell(int *type,...)
Definition: plugins.c:3921
Definition: object.h:444
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:330
const char * race
Definition: object.h:318
#define P_NEED_UPDATE
Definition: map.h:239
int is_magical(const object *op)
Definition: item.c:1195
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:296
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:305
#define CFAPI_OBJECT_PROP_ARCHETYPE
Definition: plugin.h:233
#define CFAPI_OBJECT_PROP_WEIGHT
Definition: plugin.h:218
static void cfapi_get_month_name(int *type,...)
Definition: plugins.c:1105
uint16_t attack_movement
Definition: object.h:394
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:201
static void cfapi_object_pickup(int *type,...)
Definition: plugins.c:4378
#define CFAPI_OBJECT_PROP_FACE
Definition: plugin.h:269
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.c:869
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.c:4393
static void cfapi_object_pay_amount(int *type,...)
Definition: plugins.c:3941
#define SET_FLAG(xyz, p)
Definition: define.h:223
#define NR_OF_HOOKS
Definition: plugins.c:43
#define EVENT_KICK
Definition: plugin.h:88
void do_forget_spell(object *op, const char *spell)
Definition: apply.c:526
MoveType move_allow
Definition: object.h:429
int16_t bed_x
Definition: player.h:98
linked_char * disabled_plugins
Definition: global.h:328
static void cfapi_object_get_property(int *type,...)
Definition: plugins.c:1728
#define plugins_dlsym(lib, name)
Definition: plugin.h:166
#define CFAPI_FUNC
Definition: plugin.h:115
#define PLUGIN_SUFFIX
Definition: win32.h:106
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.c:3773
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:266
#define CFAPI_OBJECT_PROP_PICK_UP
Definition: plugin.h:215
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:297
void player_get_title(const struct pl *pl, char *buf, size_t bufsize)
Definition: player.c:224
#define CFAPI_MAP_PROP_HEIGHT
Definition: plugin.h:307
uint16_t material
Definition: object.h:349
#define CFAPI_OBJECT_PROP_DIRECTION
Definition: plugin.h:195
const char * name
Definition: face.h:26
#define strdup_local
Definition: compat.h:25
uint8_t anim_speed
Definition: object.h:420
object * object_get_env_recursive(object *op)
Definition: object.c:360
EXTERN objectlink * first_friendly_object
Definition: global.h:121
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
Definition: plugin.h:174
struct obj * container
Definition: object.h:291
#define CFAPI_OBJECT_PROP_MAXGP
Definition: plugin.h:264
#define EVENT_LOGIN
Definition: plugin.h:89
int player_arrest(object *who)
Definition: c_wiz.c:794
#define CFAPI_OBJECT_PROP_HIDDEN
Definition: plugin.h:228
static void cfapi_region_get_property(int *type,...)
Definition: plugins.c:4503
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.c:3757
static void cfapi_system_find_face(int *type,...)
Definition: plugins.c:820
int16_t players
Definition: map.h:344
void fatal(enum fatal_error err)
Definition: utils.c:597
struct obj * who
Definition: dialog.h:52
static void cfapi_object_give_skill(int *type,...)
Definition: plugins.c:3356
#define CFAPI_OBJECT_PROP_MOVE_STATUS
Definition: plugin.h:229
const char * get_season_name(const int index)
Definition: time.c:123
int pay_for_item(object *op, object *pl)
Definition: shop.c:551
char * create_pathname(const char *name, char *buf, size_t size)
Definition: map.c:112
Definition: face.h:14
void knowledge_give(player *pl, const char *marker, const object *book)
Definition: knowledge.c:1012
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.c:1798
const char * playerdir
Definition: global.h:249
unsigned char MoveType
Definition: define.h:432
int32_t last_heal
Definition: object.h:359
#define CFAPI_OBJECT_PROP_SUBTYPE
Definition: plugin.h:198
partylist * party_get_next(const partylist *party)
Definition: party.c:208
int16_t maxgrace
Definition: living.h:45
void free_string(sstring str)
Definition: shstr.c:280
#define UP_OBJ_INSERT
Definition: object.h:516
signed long object_sum_weight(object *op)
Definition: object.c:338
#define TIMER_ERR_ID
Definition: timers.h:67
const Animations * try_find_animation(const char *name)
Definition: anim.c:188
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:331
static void cfapi_get_periodofday_name(int *type,...)
Definition: plugins.c:1117
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:318
#define SET_ANIMATION(ob, newanim)
Definition: global.h:167
static void cfapi_object_find_by_arch_name(int *type,...)
Definition: plugins.c:4083
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
Definition: map.c:2379
#define NR_EVENTS
Definition: plugin.h:101
#define EVENT_MAPLEAVE
Definition: plugin.h:92
void esrv_update_item(int flags, object *pl, object *op)
Definition: main.c:343
#define CFAPI_OBJECT_PROP_CONTAINER
Definition: plugin.h:179
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4125
#define CFAPI_INT16
Definition: plugin.h:119
void pick_up(object *op, object *alt)
Definition: c_object.c:460
f_plug_api func
Definition: plugin.h:352
#define CFAPI_OBJECT_PROP_INVENTORY
Definition: plugin.h:176
void query_base_name(const object *op, int plural, char *buf, size_t size)
Definition: item.c:680
struct pl player
static void cfapi_object_set_property(int *type,...)
Definition: plugins.c:2563
object clone
Definition: object.h:472
int16_t duration
Definition: object.h:406
#define CFAPI_OBJECT_PROP_FLAGS
Definition: plugin.h:248
static void cfapi_get_season_name(int *type,...)
Definition: plugins.c:1081
socket_struct socket
Definition: player.h:94
int16_t invisible
Definition: object.h:362
short freearr_x[SIZEOFFREE]
Definition: object.c:65
#define EVENT_LOGOUT
Definition: plugin.h:90
uint32_t reset_time
Definition: map.h:332
int calculate_difficulty(mapstruct *m)
Definition: map.c:1921
#define CFAPI_SINT64
Definition: plugin.h:121
#define CFAPI_OBJECT_PROP_NAME_PLURAL
Definition: plugin.h:183
static void cfapi_log(int *type,...)
Definition: plugins.c:1184
const char * get_weekday(const int index)
Definition: time.c:116
const char * slaying
Definition: object.h:319
region * get_region_by_map(mapstruct *m)
Definition: region.c:74
static void cfapi_object_find_archetype_inside(int *type,...)
Definition: plugins.c:4050
DIR * opendir(const char *)
Definition: win32.c:37
const char * name
Definition: face.h:19
int32_t last_sp
Definition: object.h:360
#define CFAPI_OBJECT_PROP_OWNER
Definition: plugin.h:243
static void cfapi_object_teleport(int *type,...)
Definition: plugins.c:4339
static void cfapi_system_re_cmp(int *type,...)
Definition: plugins.c:979
static int do_execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix, talk_info *talk)
Definition: plugins.c:314
const char * party_get_password(const partylist *party)
Definition: party.c:232
uint8_t subtype
Definition: object.h:341
crossfire_plugin * plugins_list
Definition: plugins.c:237
uint32_t mark_count
Definition: player.h:193
#define CFAPI_OBJECT_PROP_MOVE_ON
Definition: plugin.h:275
static void cfapi_map_get_map_property(int *type,...)
Definition: plugins.c:1311
uint8_t hide
Definition: object.h:390
int64_t exp
Definition: living.h:47
#define CFAPI_OBJECT_PROP_MESSAGE
Definition: plugin.h:188
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:533
static void cfapi_map_delete_map(int *type,...)
Definition: plugins.c:1511
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER
Definition: plugin.h:232
struct obj * above
Definition: object.h:288
double expmul
Definition: object.h:398
#define plugins_dlclose(lib)
Definition: plugin.h:165
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:302
#define object_was_destroyed(op, old_tag)
Definition: object.h:68
char id[MAX_BUF]
Definition: plugin.h:149
void initPlugins(void)
Definition: plugins.c:4769
object * arch_present_in_ob(const archetype *at, const object *op)
Definition: object.c:2943
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:291
#define CFAPI_DOUBLE
Definition: plugin.h:113
static void cfapi_object_insert(int *type,...)
Definition: plugins.c:3509
void remove_friendly_object(object *op)
Definition: friend.c:56
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:327
uint32_t path_attuned
Definition: object.h:345
void object_update(object *op, int action)
Definition: object.c:1190
static void cfapi_object_drop(int *type,...)
Definition: plugins.c:4120
static void cfapi_object_fix(int *type,...)
Definition: plugins.c:3340
int16_t sp
Definition: living.h:42
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.c:1443
#define EVENT_TELL
Definition: plugin.h:100
static void cfapi_object_set_key(int *type,...)
Definition: plugins.c:1705
#define EVENT_CRASH
Definition: plugin.h:86
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:311
static void cfapi_party_get_property(int *type,...)
Definition: plugins.c:4448
int object_can_merge(object *ob1, object *ob2)
Definition: object.c:199
#define CFAPI_OBJECT_PROP_SLAYING
Definition: plugin.h:186
static void cfapi_map_create_path(int *type,...)
Definition: plugins.c:1277
int plugin_event_say(object *npc, talk_info *talk)
Definition: plugins.c:381
Definition: win32.h:110
uint32_t path_repelled
Definition: object.h:346
#define safe_strncpy
Definition: compat.h:23
#define SCRIPT_FIX_ALL
Definition: global.h:367
void free_dialog_information(object *op)
Definition: dialog.c:32
char * partyname
Definition: party.h:14
struct obj * enemy
Definition: object.h:384
struct archt * other_arch
Definition: object.h:416
static void cfapi_system_find_string(int *type,...)
Definition: plugins.c:937
object * object_find_by_name(const object *who, const char *name)
Definition: object.c:3735
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.c:311
Definition: object.h:467
#define CFAPI_PMAP
Definition: plugin.h:111
static void cfapi_object_apply_below(int *type,...)
Definition: plugins.c:3216
void transmute_materialname(object *op, const object *change)
Definition: utils.c:267
char savebed_map[MAX_BUF]
Definition: player.h:97
static void cfapi_timer_create(int *type,...)
Definition: plugins.c:1132
Definition: plugin.h:351
char * host
Definition: newserver.h:100
static void cfapi_player_quest(int *type,...)
Definition: plugins.c:4681
#define CFAPI_POBJECT
Definition: plugin.h:110
static void cfapi_object_split(int *type,...)
Definition: plugins.c:3617
#define CFAPI_OBJECT_PROP_CHOSEN_SKILL
Definition: plugin.h:227
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:234
int16_t maxsp
Definition: living.h:43
#define CFAPI_OBJECT_PROP_LAST_SP
Definition: plugin.h:211
int8_t Con
Definition: living.h:36
int change_map_light(mapstruct *m, int change)
Definition: map.c:2003
#define CFAPI_REGION_PROP_JAIL_PATH
Definition: plugin.h:333
#define FLAG_REMOVED
Definition: define.h:232
static void cfapi_object_delete(int *type,...)
Definition: plugins.c:3411
int16_t hp
Definition: living.h:40
#define CFAPI_OBJECT_PROP_LAST_GRACE
Definition: plugin.h:212
static void cfapi_object_find_by_name(int *type,...)
Definition: plugins.c:4099
#define CFAPI_OBJECT_PROP_COUNT
Definition: plugin.h:181
short freearr_y[SIZEOFFREE]
Definition: object.c:71
partylist * party
Definition: player.h:186
static void cfapi_object_remove(int *type,...)
Definition: plugins.c:3390
#define CFAPI_NONE
Definition: plugin.h:105
#define UPD_ALL
Definition: newclient.h:297
void command_say(object *op, const char *params)
Definition: c_chat.c:34
object * ob
Definition: object.h:445
#define MOVE_ALL
Definition: define.h:413
uint16_t height
Definition: map.h:347
object * give_skill_by_name(object *op, const char *skill_name)
Definition: living.c:1773
static void cfapi_object_transmute(int *type,...)
Definition: plugins.c:3373
const char * get_month_name(const int index)
Definition: time.c:109
#define CFAPI_FLOAT
Definition: plugin.h:112
void map_newmap_cmd(socket_struct *ns)
Definition: request.c:618
struct _crossfire_plugin * next
Definition: plugin.h:152
void object_set_owner(object *op, object *owner)
Definition: object.c:604
#define CFAPI_PLAYER_PROP_BED_X
Definition: plugin.h:286
char * name
Definition: map.h:328
#define CFAPI_PARCH
Definition: plugin.h:114
const char * lore
Definition: object.h:324
static void cfapi_object_identify(int *type,...)
Definition: plugins.c:3261
struct obj * chosen_skill
Definition: object.h:389
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:4248
uint32_t update_look
Definition: newserver.h:104
void object_free_drop_inventory(object *ob)
Definition: object.c:1316
int change_abil(object *op, object *tmp)
Definition: living.c:395
const char * title
Definition: object.h:317
int16_t y
Definition: object.h:327
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.c:1838
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:303
int move_to(object *op, int x, int y)
Definition: move.c:545
int is_friendly(const object *op)
Definition: friend.c:144
int16_t maxhp
Definition: living.h:41
sstring find_string(const char *str)
Definition: shstr.c:236
char * name
Definition: map.h:278
#define CFAPI_OBJECT_PROP_FACING
Definition: plugin.h:196
int user_event(object *op, object *activator, object *third, const char *message, int fix)
Definition: plugins.c:310
#define MSG_TYPE_COMMAND
Definition: newclient.h:379
static void cfapi_object_say(int *type,...)
Definition: plugins.c:4159
#define EVENT_MAPENTER
Definition: plugin.h:91
static void cfapi_system_remove_string(int *type,...)
Definition: plugins.c:919
uint32_t path_denied
Definition: object.h:347
static void cfapi_object_change_exp(int *type,...)
Definition: plugins.c:4248
#define CFAPI_PLAYER_PROP_IP
Definition: plugin.h:282
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:177
Definition: win32.h:120
static void cfapi_object_merge(int *type,...)
Definition: plugins.c:3650
#define CFAPI_OBJECT_PROP_GP
Definition: plugin.h:260
LIBPTRTYPE libptr
Definition: plugin.h:148
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:255
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:324
object * object_new(void)
Definition: object.c:1011
const char * name_pl
Definition: object.h:315
static void cfapi_player_knowledge(int *type,...)
Definition: plugins.c:4290
int8_t direction
Definition: object.h:336
#define LIBDIR
Definition: win32.h:99
#define CFAPI_OBJECT_PROP_ATTACKED_BY
Definition: plugin.h:225
#define CFAPI_STRING
Definition: plugin.h:109
void player_set_own_title(struct pl *pl, const char *title)
Definition: player.c:264
int object_can_pick(const object *who, const object *item)
Definition: object.c:3646
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2591
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
Definition: plugin.h:278
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:313
float speed_left
Definition: object.h:330
int knowledge_player_knows(const player *pl, const char *knowledge)
Definition: knowledge.c:1314
void *(* f_plug_property)(int *type,...)
Definition: plugin.h:134
#define CFAPI_OBJECT_PROP_INT
Definition: plugin.h:253
signed short int16_t
Definition: win32.h:160
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:301
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:317
void monster_npc_say(object *npc, const char *cp)
Definition: monster.c:2307
static void cfapi_timer_destroy(int *type,...)
Definition: plugins.c:1165
const char * materialname
Definition: object.h:348
int16_t enter_x
Definition: map.h:348
int32_t weight
Definition: object.h:367
uint32_t unique
Definition: map.h:337
#define CFAPI_OBJECT_PROP_LEVEL
Definition: plugin.h:209
#define FOR_ABOVE_FINISH()
Definition: define.h:731
void update_all_los(const mapstruct *map, int x, int y)
Definition: los.c:536
const char * tmpdir
Definition: global.h:256
int8_t Wis
Definition: living.h:36
const char * text
Definition: dialog.h:53
#define CFAPI_OBJECT_PROP_HEAD
Definition: plugin.h:178
#define CFAPI_PLAYER_PROP_BED_MAP
Definition: plugin.h:285
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:274
static void cfapi_player_message(int *type,...)
Definition: plugins.c:4203
struct mapdef * map
Definition: object.h:297
struct regiondef * next
Definition: map.h:277
Definition: map.h:276
#define CFAPI_OBJECT_PROP_RAW_NAME
Definition: plugin.h:280
#define snprintf
Definition: win32.h:46
struct obj * active_prev
Definition: object.h:283
void drain_specific_stat(object *op, int deplete_stats)
Definition: living.c:725
static void cfapi_object_user_event(int *type,...)
Definition: plugins.c:4657
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:316
f_plug_postinit closefunc
Definition: plugin.h:147
#define PERM_EXP(exptotal)
Definition: global.h:234
struct linked_char * next
Definition: global.h:88
int plugins_init_plugin(const char *libfile)
Definition: plugins.c:613
uint16_t num
Definition: face.h:29
uint64_t query_money(const object *op)
Definition: shop.c:482
int(* f_plug_postinit)(void)
Definition: plugin.h:128
#define FOR_INV_FINISH()
Definition: define.h:714
char * msg
Definition: map.h:361
void update_position(mapstruct *m, int x, int y)
Definition: map.c:2127
int16_t dam
Definition: living.h:46
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Definition: plugins.c:377
void add_friendly_object(object *op)
Definition: friend.c:30
#define CFAPI_OBJECT_PROP_FP
Definition: plugin.h:261
int32_t carrying
Definition: object.h:369
const char * name
Definition: object.h:311
int16_t bed_y
Definition: player.h:98
struct obj * env
Definition: object.h:293
#define FOR_ABOVE_PREPARE(op_, it_)
Definition: define.h:724
#define CFAPI_OBJECT_PROP_MAGICAL
Definition: plugin.h:240
int8_t gen_sp_armour
Definition: object.h:365
static void cfapi_map_find_by_archetype_name(int *type,...)
Definition: plugins.c:1575
#define LIBPTRTYPE
Definition: plugin.h:137
uint8_t state
Definition: object.h:351
struct obj * below
Definition: object.h:287
struct archt * more
Definition: object.h:471
static void cfapi_object_pay_item(int *type,...)
Definition: plugins.c:3962
archetype * find_archetype_by_object_name(const char *name)
Definition: arch.c:57
#define CFAPI_OBJECT_PROP_LAST_EAT
Definition: plugin.h:213
object * object_present_in_ob(uint8_t type, const object *op)
Definition: object.c:2889
void trigger_connected(objectlink *ol, object *cause, const int state)
Definition: button.c:41
int16_t last_grace
Definition: object.h:361
const char * re_cmp(const char *, const char *)
Definition: re-cmp.c:69
void object_reset(object *op)
Definition: object.c:698
int pay_for_amount(uint64_t to_pay, object *pl)
Definition: shop.c:513
#define CFAPI_OBJECT_PROP_MOVE_OFF
Definition: plugin.h:276
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:219
#define CFAPI_PLAYER_QUEST_SET_STATE
Definition: plugin.h:293
struct obj * current_weapon
Definition: object.h:373
#define CFAPI_LONG
Definition: plugin.h:107
object * object_create_clone(object *asrc)
Definition: object.c:3688
uint32_t nrof
Definition: object.h:334
#define string_get_int(name)
Definition: plugins.c:1062
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON
Definition: plugin.h:223
#define CFAPI_SSTRING
Definition: plugin.h:122
int8_t Cha
Definition: living.h:36
struct archt * head
Definition: object.h:470
static void cfapi_player_can_pay(int *type,...)
Definition: plugins.c:4271
static void cfapi_system_check_path(int *type,...)
Definition: plugins.c:956
#define CFAPI_PPLAYER
Definition: plugin.h:116
#define SIZEOFFREE
Definition: define.h:154
#define P_OUT_OF_MAP
Definition: map.h:251
MoveType move_off
Definition: object.h:431
int move_ob(object *op, int dir, object *originator)
Definition: move.c:58
int cftimer_destroy(int id)
Definition: timers.c:128
#define CFAPI_OBJECT_PROP_X
Definition: plugin.h:190
void do_learn_spell(object *op, object *spell, int special_prayer)
Definition: apply.c:485
static void cfapi_map_out_of_map(int *type,...)
Definition: plugins.c:1473
struct pl * contr
Definition: object.h:276
#define CFAPI_OBJECT_PROP_CHEATER
Definition: plugin.h:245
static void cfapi_object_get_key(int *type,...)
Definition: plugins.c:1683
#define CFAPI_OBJECT_PROP_PICKABLE
Definition: plugin.h:247
int8_t item_power
Definition: object.h:364
static void cfapi_system_directory(int *type,...)
Definition: plugins.c:997
void cleanupPlugins(void)
Definition: plugins.c:4819
uint8_t ignore_plugin_compatibility
Definition: global.h:329
uint8_t darkness
Definition: map.h:346
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:310
void object_clear(object *op)
Definition: object.c:747
command_array_struct * find_plugin_command(const char *cmd, command_array_struct *command)
Definition: plugins.c:4748
static crossfire_plugin * plugins_find_plugin(const char *id)
Definition: plugins.c:248
#define CFAPI_OBJECT_PROP_ENEMY
Definition: plugin.h:224
#define CFAPI_REGION_PROP_JAIL_Y
Definition: plugin.h:332
object * find_marked_object(object *op)
Definition: c_object.c:1270
#define CFAPI_OBJECT_PROP_PATH_REPELLED
Definition: plugin.h:203
void plugins_display_list(object *op)
Definition: plugins.c:746
static void cfapi_object_learn_spell(int *type,...)
Definition: plugins.c:3886
uint16_t number
Definition: face.h:15
archetype * try_find_archetype(const char *name)
Definition: arch.c:666
#define UPD_WEIGHT
Definition: newclient.h:291
uint32_t tag_t
Definition: object.h:12
#define EVENT_SAY
Definition: plugin.h:73
char d_name[_MAX_FNAME+1]
Definition: win32.h:114
static void cfapi_object_create(int *type,...)
Definition: plugins.c:3470
int8_t luck
Definition: living.h:39
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h:299
float speed
Definition: object.h:329
unsigned __int64 uint64_t
Definition: win32.h:167
char fullname[MAX_BUF]
Definition: plugin.h:150
struct regiondef * parent
Definition: map.h:286
int on_same_map(const object *op1, const object *op2)
Definition: map.c:2651
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
f_plug_property propfunc
Definition: plugin.h:146
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
#define CFAPI_OBJECT_PROP_LORE
Definition: plugin.h:189
static void cfapi_player_find(int *type,...)
Definition: plugins.c:4188
#define EVENT_MAPLOAD
Definition: plugin.h:93
partylist * party_get_first(void)
Definition: party.c:196
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Definition: living.c:2162
#define CFAPI_OBJECT_PROP_ITEM_POWER
Definition: plugin.h:216
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:329
#define MSG_TYPE_COMMAND_DEBUG
Definition: newclient.h:508
static void cfapi_object_apply(int *type,...)
Definition: plugins.c:3236
static void cfapi_system_unregister_global_event(int *type,...)
Definition: plugins.c:876
#define MAX_BUF
Definition: define.h:35
const Animations * animation
Definition: object.h:419
int quest_get_player_state(player *pl, sstring quest_code)
Definition: quest.c:1076
#define CFAPI_PARTY_PROP_NAME
Definition: plugin.h:321
struct obj * active_next
Definition: object.h:279
#define CFAPI_PLAYER_PROP_PARTY
Definition: plugin.h:284
LogLevel
Definition: logger.h:10
object * object_create_arch(archetype *at)
Definition: arch.c:736
int16_t jailx
Definition: map.h:298
int16_t enter_y
Definition: map.h:348
int16_t x
Definition: object.h:327
#define EVENT_MAPUNLOAD
Definition: plugin.h:95
void drop(object *op, object *tmp)
Definition: c_object.c:924
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:242
int64_t total_exp
Definition: object.h:372
const char * skill
Definition: object.h:321
int32_t last_eat
Definition: object.h:358
static void cfapi_object_describe(int *type,...)
Definition: plugins.c:3281
#define plugins_dlerror()
Definition: plugin.h:167
#define EVENT_MAPRESET
Definition: plugin.h:94
int8_t wc
Definition: living.h:37
const char * confdir
Definition: global.h:246
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
Definition: object.c:3320
int(* f_plug_event)(int *type,...)
Definition: plugin.h:132
signed __int64 int64_t
Definition: win32.h:168
#define CFAPI_OBJECT_PROP_TOTAL_EXP
Definition: plugin.h:222
static const flag_definition flags[]
#define EVENT_GKILL
Definition: plugin.h:87
static void cfapi_system_strdup_local(int *type,...)
Definition: plugins.c:843
const char * uniquedir
Definition: global.h:254
int8_t Str
Definition: living.h:36
char * tmpname
Definition: map.h:327
int16_t resist[NROFATTACKS]
Definition: object.h:343
object * ob
Definition: player.h:158
const char * sstring
Definition: global.h:40
#define EVENT_CLOCK
Definition: plugin.h:85
#define CFAPI_OBJECT_PROP_DAM
Definition: plugin.h:265
unsigned int uint32_t
Definition: win32.h:162
#define CFAPI_OBJECT_PROP_MOVE_TYPE
Definition: plugin.h:272
Definition: object.h:107
const char * datadir
Definition: global.h:247
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:187
#define CFAPI_PLAYER_PROP_NEXT
Definition: plugin.h:288
#define CFAPI_OBJECT_PROP_AC
Definition: plugin.h:257
static void cfapi_object_check_trigger(int *type,...)
Definition: plugins.c:3792
#define SET_MAP_FLAGS(M, X, Y, C)
Definition: map.h:163
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:239
#define TIMER_ERR_NONE
Definition: timers.h:66
const char * name
Definition: global.h:87
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:328
#define CFAPI_INT
Definition: plugin.h:106
uint32_t attacktype
Definition: object.h:344
struct obj * spellitem
Definition: object.h:397
static void cfapi_friendlylist_get_next(int *type,...)
Definition: plugins.c:4576
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
Definition: object.c:2371
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:315
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.c:935
void quest_set_player_state(player *pl, sstring quest_code, int state)
Definition: quest.c:1132
object * object_decrease_nrof(object *op, uint32_t i)
Definition: object.c:2410
static void cfapi_object_perm_exp(int *type,...)
Definition: plugins.c:4229
int set_random_map_variable(RMParms *rp, const char *buf)
#define CFAPI_OBJECT_PROP_SPEED_LEFT
Definition: plugin.h:193
#define FREE_AND_COPY(sv, nv)
Definition: global.h:210
int16_t grace
Definition: living.h:44
#define UPD_NROF
Definition: newclient.h:296
void get_tod(timeofday_t *tod)
Definition: time.c:215
static void cfapi_object_query_money(int *type,...)
Definition: plugins.c:3839
const char * custom_name
Definition: object.h:435
int cftimer_create(int id, long delay, object *ob, int mode)
Definition: timers.c:97
const char * localdir
Definition: global.h:248
tag_t count
Definition: object.h:299
living stats
Definition: object.h:370
static void cfapi_map_has_been_loaded(int *type,...)
Definition: plugins.c:1259
uint16_t client_type
Definition: object.h:342
mapstruct * has_been_loaded(const char *name)
Definition: map.c:87
int8_t Dex
Definition: living.h:36
char * jailmap
Definition: map.h:297
struct archt * arch
Definition: object.h:415
#define CFAPI_OBJECT_PROP_HP
Definition: plugin.h:258
struct oblnk * next
Definition: object.h:446
static void cfapi_object_cast(int *type,...)
Definition: plugins.c:3858
#define CFAPI_OBJECT_PROP_TITLE
Definition: plugin.h:184
int cftimer_find_free_id(void)
Definition: timers.c:144
const char * mapdir
Definition: global.h:250
uint32_t reset_timeout
Definition: map.h:333
#define CFAPI_PLAYER_PROP_BED_Y
Definition: plugin.h:287
uint16_t width
Definition: map.h:347
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:192
Definition: tod.h:34
uint8_t type
Definition: object.h:340
struct Settings settings
Definition: init.c:39
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:298
static void cfapi_get_hooks(int *type,...)
Definition: plugins.c:567
void object_set_enemy(object *op, object *enemy)
Definition: object.c:679
int remove_depletion(object *op, int level)
Definition: living.c:752
#define CFAPI_OBJECT_PROP_FRIENDLY
Definition: plugin.h:237
#define CFAPI_OBJECT_PROP_ANIM_SPEED
Definition: plugin.h:236
struct archt * next
Definition: object.h:469
#define CFAPI_OBJECT_PROP_LUCK
Definition: plugin.h:241
void party_join(object *op, partylist *party)
Definition: party.c:85
struct dirent * readdir(DIR *)
Definition: win32.c:75
const char * get_periodofday(const int index)
Definition: time.c:102
object * object_merge(object *op, object *top)
Definition: object.c:1789
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:267
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.c:508
object * object_get_player_container(object *op)
Definition: object.c:377
static void cfapi_system_add_string(int *type,...)
Definition: plugins.c:899
int out_of_map(mapstruct *m, int x, int y)
Definition: map.c:2306
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME
Definition: plugin.h:214
static void cfapi_get_time(int *type,...)
Definition: plugins.c:1050
static void cfapi_map_get_object_at(int *type,...)
Definition: plugins.c:1546
#define CFAPI_OBJECT_PROP_DEX
Definition: plugin.h:250
#define CFAPI_MOVETYPE
Definition: plugin.h:123
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
Definition: plugin.h:230
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:312
static void cfapi_object_change_abil(int *type,...)
Definition: plugins.c:4144
void delete_map(mapstruct *m)
Definition: map.c:1736
const char * msg
Definition: object.h:322
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:306
#define CFAPI_OBJECT_PROP_CON
Definition: plugin.h:251
sstring add_string(const char *str)
Definition: shstr.c:124
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED
Definition: plugin.h:294
EXTERN player * first_player
Definition: global.h:115
char * cost_string_from_value(uint64_t cost, int largest_coin)
Definition: shop.c:334
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:322
object * identify(object *op)
Definition: item.c:1386
struct pl * next
Definition: player.h:93
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.c:3746
#define GET_MAP_OB(M, X, Y)
Definition: map.h:172
int check_path(const char *name, int prepend_dir)
Definition: map.c:211
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:194
int8_t glow_radius
Definition: object.h:366
#define CFAPI_OBJECT_PROP_MAXSP
Definition: plugin.h:263
f_plug_event eventfunc
Definition: plugin.h:145
void object_copy(const object *src_ob, object *dest_ob)
Definition: object.c:824
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:319
struct _crossfire_plugin * prev
Definition: plugin.h:153
static void cfapi_object_transfer(int *type,...)
Definition: plugins.c:3986
#define EVENT_PLAYER_DEATH
Definition: plugin.h:97
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.c:3321
int8_t Pow
Definition: living.h:36
int closedir(DIR *)
Definition: win32.c:108
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Definition: map.c:310
struct obj * inv
Definition: object.h:290
void object_set_cheat(object *op)
Definition: object.c:2995
#define NDI_UNIQUE
Definition: newclient.h:245
#define CFAPI_PLAYER_PROP_MARKED_ITEM
Definition: plugin.h:283
static void cfapi_map_get_map(int *type,...)
Definition: plugins.c:1208
struct obj * head
Definition: object.h:296
#define MSG_SUBTYPE_NONE
Definition: newclient.h:398
static void cfapi_object_distance(int *type,...)
Definition: plugins.c:3673
#define CFAPI_OBJECT_PROP_LAST_HEAL
Definition: plugin.h:210
#define CFAPI_OBJECT_PROP_CLIENT_TYPE
Definition: plugin.h:199
#define CFAPI_OBJECT_PROP_INVISIBLE
Definition: plugin.h:268
void player_update_bg_music(object *player)
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:197
static const hook_entry plug_hooks[]
Definition: plugins.c:141
char * msg
Definition: map.h:293
static void cfapi_object_forget_spell(int *type,...)
Definition: plugins.c:3901
#define CFAPI_OBJECT_PROP_POW
Definition: plugin.h:254
static void cfapi_get_weekday_name(int *type,...)
Definition: plugins.c:1093
static void cfapi_map_message(int *type,...)
Definition: plugins.c:1524
static void cfapi_object_update(int *type,...)
Definition: plugins.c:3694
object * mark
Definition: player.h:194
#define FLAG_WAS_WIZ
Definition: define.h:234
EXTERN region * first_region
Definition: global.h:117
uint8_t pick_up
Definition: object.h:363
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
Definition: plugin.h:217
int transfer_ob(object *op, int x, int y, int randomly, object *originator)
Definition: move.c:144
MoveType move_block
Definition: object.h:428
uint8_t run_away
Definition: object.h:387
#define CFAPI_OBJECT_PROP_GLOW_RADIUS
Definition: plugin.h:221
struct mapdef * next
Definition: map.h:326
static void cfapi_object_clone(int *type,...)
Definition: plugins.c:3438
static void cfapi_object_reset(int *type,...)
Definition: plugins.c:3732
void object_set_msg(object *op, const char *msg)
Definition: object.c:4559
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
Definition: object.c:3280
int check_trigger(object *op, object *cause)
Definition: button.c:523
#define CFAPI_OBJECT_PROP_PRESENT
Definition: plugin.h:244
float move_slow_penalty
Definition: object.h:433
#define CFAPI_OBJECT_PROP_MERGEABLE
Definition: plugin.h:246
#define CFAPI_OBJECT_PROP_WC
Definition: plugin.h:256
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:583
#define CFAPI_OBJECT_PROP_RESIST
Definition: plugin.h:200
#define CFAPI_OBJECT_PROP_SHORT_NAME
Definition: plugin.h:238
#define CFAPI_OBJECT_PROP_MOVE_SLOW
Definition: plugin.h:277
#define CFAPI_OBJECT_PROP_MATERIAL_NAME
Definition: plugin.h:206
void create_overlay_pathname(const char *name, char *buf, size_t size)
Definition: map.c:133
const Face * find_face(const char *name, const Face *error)
Definition: image.c:316
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Definition: object.c:2839
Definition: map.h:325
const Face * face
Definition: object.h:333
#define CFAPI_OBJECT_PROP_MAXHP
Definition: plugin.h:262
int can_pay(object *pl)
Definition: shop.c:830
#define FLAG_UNIQUE
Definition: define.h:288
#define CFAPI_OBJECT_PROP_VALUE
Definition: plugin.h:208
static void cfapi_cost_string_from_value(int *type,...)
Definition: plugins.c:769
void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Definition: main.c:326
#define CFAPI_OBJECT_PROP_SPELL_ITEM
Definition: plugin.h:231
#define CFAPI_OBJECT_PROP_PATH_ATTUNED
Definition: plugin.h:202
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:130
int32_t move_status
Definition: object.h:393
int16_t level
Definition: object.h:353
int8_t facing
Definition: object.h:337
void fix_object(object *op)
Definition: living.c:1120
static void send_changed_object(object *op)
Definition: plugins.c:284
player * find_player_partial_name(const char *plname)
Definition: player.c:110
#define CFAPI_OBJECT_PROP_WIS
Definition: plugin.h:252
EXTERN mapstruct * first_map
Definition: global.h:116
int quest_was_completed(player *pl, sstring quest_code)
Definition: quest.c:1142
#define CFAPI_OBJECT_PROP_DURATION
Definition: plugin.h:279
EXTERN archetype * first_archetype
Definition: global.h:120
char * longname
Definition: map.h:291
void object_update_speed(object *op)
Definition: object.c:1086
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:308
void clean_object(object *op)
Definition: map.c:1626
int32_t value
Definition: object.h:352
object * object_get_owner(object *op)
Definition: object.c:568
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:172
int8_t magic
Definition: object.h:350
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:191
#define CFAPI_OBJECT_PROP_CUSTOM_NAME
Definition: plugin.h:235
const char * name
Definition: object.h:468
#define EVENT_BORN
Definition: plugin.h:84
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
f_plug_event gevent[NR_EVENTS]
Definition: plugin.h:151
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: porting.c:366
int plugins_remove_plugin(const char *id)
Definition: plugins.c:704
void(* f_plug_api)(int *type,...)
Definition: plugin.h:126
int execute_global_event(int eventcode,...)
Definition: plugins.c:385
object * object_find_by_arch_name(const object *who, const char *name)
Definition: object.c:4031
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Definition: object.c:2924
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
Definition: plugin.h:175
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:707
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Definition: spell_util.c:1467
void object_remove(object *op)
Definition: object.c:1577
#define EVENT_USER
Definition: plugin.h:80
static void cfapi_generate_random_map(int *type,...)
Definition: plugins.c:4640
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:204
static void cfapi_map_update_position(int *type,...)
Definition: plugins.c:1495
#define CFAPI_OBJECT_PROP_MOVE_BLOCK
Definition: plugin.h:273
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:326
struct obj * attacked_by
Definition: object.h:385
#define CFAPI_PPARTY
Definition: plugin.h:117
static void cfapi_map_change_light(int *type,...)
Definition: plugins.c:1602
int32_t food
Definition: living.h:48
#define FLAG_FREED
Definition: define.h:233
#define EVENT_MUZZLE
Definition: plugin.h:96
uint32_t count
Definition: player.h:109