Crossfire Server, Trunk  R21466
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 *anim;
802  int *num;
803 
804  va_start(args, type);
805  anim = va_arg(args, const char *);
806  num = va_arg(args, int *);
807  va_end(args);
808 
809  *num = find_animation(anim);
810  *type = CFAPI_INT;
811 }
812 
818 static void cfapi_system_find_face(int *type, ...) {
819  va_list args;
820  const char *face;
821  int error;
822  int *num;
823 
824  va_start(args, type);
825  face = va_arg(args, const char *);
826  error = va_arg(args, int);
827  num = va_arg(args, int *);
828  va_end(args);
829 
830  *num = find_face(face, error);
831  *type = CFAPI_INT;
832 }
833 
839 static void cfapi_system_strdup_local(int *type, ...) {
840  va_list args;
841  const char *txt;
842  char **ret;
843 
844  va_start(args, type);
845  txt = va_arg(args, const char *);
846  ret = va_arg(args, char **);
847  va_end(args);
848 
849  *ret = strdup_local(txt);
850  *type = CFAPI_STRING;
851 }
852 
853 static void cfapi_system_register_global_event(int *type, ...) {
854  va_list args;
855  int eventcode;
856  char *pname;
857  f_plug_event hook;
858  crossfire_plugin *cp;
859 
860  va_start(args, type);
861  eventcode = va_arg(args, int);
862  pname = va_arg(args, char *);
863  hook = va_arg(args, f_plug_event);
864  va_end(args);
865 
866  *type = CFAPI_NONE;
867 
868  cp = plugins_find_plugin(pname);
869  cp->gevent[eventcode] = hook;
870 }
871 
872 static void cfapi_system_unregister_global_event(int *type, ...) {
873  va_list args;
874  int eventcode;
875  char *pname;
876  crossfire_plugin *cp;
877 
878  va_start(args, type);
879  eventcode = va_arg(args, int);
880  pname = va_arg(args, char *);
881  va_end(args);
882 
883  *type = CFAPI_NONE;
884 
885  cp = plugins_find_plugin(pname);
886  cp->gevent[eventcode] = NULL;
887 }
888 
895 static void cfapi_system_add_string(int *type, ...) {
896  va_list args;
897  const char *str;
898  sstring *rv;
899 
900  va_start(args, type);
901  str = va_arg(args, const char *);
902  rv = va_arg(args, sstring *);
903  va_end(args);
904 
905  *rv = add_string(str);
906  *type = CFAPI_SSTRING;
907 }
908 
915 static void cfapi_system_remove_string(int *type, ...) {
916  va_list args;
917  sstring str;
918 
919  va_start(args, type);
920  str = va_arg(args, sstring);
921  va_end(args);
922 
923  free_string(str);
924  *type = CFAPI_NONE;
925 }
926 
933 static void cfapi_system_find_string(int *type, ...) {
934  va_list args;
935  const char *str;
936  sstring *rv;
937 
938  va_start(args, type);
939  str = va_arg(args, const char *);
940  rv = va_arg(args, sstring *);
941  va_end(args);
942 
943  *rv = find_string(str);
944  *type = CFAPI_SSTRING;
945 }
946 
952 static void cfapi_system_check_path(int *type, ...) {
953  va_list args;
954  const char *name;
955  int prepend_dir;
956  int *ret;
957 
958  va_start(args, type);
959 
960  name = va_arg(args, char *);
961  prepend_dir = va_arg(args, int);
962  ret = va_arg(args, int *);
963 
964  *ret = check_path(name, prepend_dir);
965 
966  va_end(args);
967  *type = CFAPI_INT;
968 }
969 
975 static void cfapi_system_re_cmp(int *type, ...) {
976  va_list args;
977  const char *str;
978  const char *regexp;
979  const char **rv;
980 
981  va_start(args, type);
982 
983  str = va_arg(args, char *);
984  regexp = va_arg(args, char *);
985  rv = va_arg(args, const char **);
986 
987  *rv = re_cmp(str, regexp);
988 
989  va_end(args);
990  *type = CFAPI_STRING;
991 }
992 
993 static void cfapi_system_directory(int *type, ...) {
994  va_list args;
995  int dirtype;
996  const char **str;
997 
998  va_start(args, type);
999 
1000  dirtype = va_arg(args, int);
1001  str = va_arg(args, const char **);
1002  va_end(args);
1003 
1004  *type = CFAPI_STRING;
1005 
1006  switch (dirtype) {
1007  case 0:
1008  *str = settings.mapdir;
1009  break;
1010 
1011  case 1:
1012  *str = settings.uniquedir;
1013  break;
1014 
1015  case 2:
1016  *str = settings.tmpdir;
1017  break;
1018 
1019  case 3:
1020  *str = settings.confdir;
1021  break;
1022 
1023  case 4:
1024  *str = settings.localdir;
1025  break;
1026 
1027  case 5:
1028  *str = settings.playerdir;
1029  break;
1030 
1031  case 6:
1032  *str = settings.datadir;
1033  break;
1034 
1035  default:
1036  *str = NULL;
1037  }
1038 }
1039 
1046 static void cfapi_get_time(int *type, ...) {
1047  va_list args;
1048  timeofday_t *tod;
1049 
1050  va_start(args, type);
1051  tod = va_arg(args, timeofday_t *);
1052  va_end(args);
1053 
1054  get_tod(tod);
1055  *type = CFAPI_NONE;
1056 }
1057 
1058 #define string_get_int(name) \
1059  va_list args; \
1060  int index; \
1061  const char **str; \
1062  va_start(args, type); \
1063  index = va_arg(args, int); \
1064  str = va_arg(args, const char **); \
1065  va_end(args); \
1066  *str = name(index); \
1067  *type = CFAPI_STRING; \
1068 
1069 
1077 static void cfapi_get_season_name(int *type, ...) {
1079 }
1080 
1089 static void cfapi_get_weekday_name(int *type, ...) {
1091 }
1092 
1101 static void cfapi_get_month_name(int *type, ...) {
1103 }
1104 
1113 static void cfapi_get_periodofday_name(int *type, ...) {
1115 }
1116 
1128 static void cfapi_timer_create(int *type, ...) {
1129  va_list args;
1130  int res;
1131  object *ob;
1132  long delay;
1133  int mode;
1134  int *timer;
1135 
1136  va_start(args, type);
1137  ob = va_arg(args, object *);
1138  delay = va_arg(args, long);
1139  mode = va_arg(args, int);
1140  timer = va_arg(args, int *);
1141  va_end(args);
1142  *type = CFAPI_INT;
1143 
1144  *timer = cftimer_find_free_id();
1145  if (*timer != TIMER_ERR_ID) {
1146  res = cftimer_create(*timer, delay, ob, mode);
1147  if (res != TIMER_ERR_NONE)
1148  *timer = res;
1149  }
1150 }
1151 
1161 static void cfapi_timer_destroy(int *type, ...) {
1162  va_list args;
1163  int id;
1164  int *err;
1165 
1166  va_start(args, type);
1167  id = va_arg(args, int);
1168  err = va_arg(args, int *);
1169  va_end(args);
1170  *type = CFAPI_INT;
1171 
1172  *err = cftimer_destroy(id);
1173 }
1174 
1180 static void cfapi_log(int *type, ...) {
1181  va_list args;
1182  LogLevel logLevel;
1183  const char *message;
1184 
1185  va_start(args, type);
1186  logLevel = va_arg(args, LogLevel);
1187  message = va_arg(args, const char *);
1188  LOG(logLevel, "%s", message);
1189  va_end(args);
1190 
1191  *type = CFAPI_NONE;
1192 }
1193 
1194 /* MAP RELATED HOOKS */
1195 
1204 static void cfapi_map_get_map(int *type, ...) {
1205  va_list args;
1206  mapstruct **ret;
1207  int ctype;
1208  int x, y;
1209  int16_t nx, ny;
1210  const char *name;
1211  mapstruct *m;
1212 
1213  va_start(args, type);
1214 
1215  ctype = va_arg(args, int);
1216 
1217  switch (ctype) {
1218  case 0:
1219  x = va_arg(args, int);
1220  y = va_arg(args, int);
1221  ret = va_arg(args, mapstruct **);
1222  *ret = get_empty_map(x, y);
1223  break;
1224 
1225  case 1:
1226  name = va_arg(args, const char *);
1227  x = va_arg(args, int);
1228  ret = va_arg(args, mapstruct **);
1229  *ret = ready_map_name(name, x);
1230  break;
1231 
1232  case 2:
1233  m = va_arg(args, mapstruct *);
1234  nx = va_arg(args, int);
1235  ny = va_arg(args, int);
1236  ret = va_arg(args, mapstruct **);
1237  *ret = get_map_from_coord(m, &nx, &ny);
1238  break;
1239 
1240  default:
1241  *type = CFAPI_NONE;
1242  va_end(args);
1243  return;
1244  break;
1245  }
1246  va_end(args);
1247  *type = CFAPI_PMAP;
1248 }
1249 
1255 static void cfapi_map_has_been_loaded(int *type, ...) {
1256  va_list args;
1257  mapstruct **map;
1258  char *string;
1259 
1260  va_start(args, type);
1261  string = va_arg(args, char *);
1262  map = va_arg(args, mapstruct **);
1263  *map = has_been_loaded(string);
1264  va_end(args);
1265  *type = CFAPI_PMAP;
1266 }
1267 
1273 static void cfapi_map_create_path(int *type, ...) {
1274  va_list args;
1275  int ctype, size;
1276  const char *str;
1277  char *name;
1278 
1279  va_start(args, type);
1280 
1281  ctype = va_arg(args, int);
1282  str = va_arg(args, const char *);
1283  name = va_arg(args, char *);
1284  size = va_arg(args, int);
1285  *type = CFAPI_STRING;
1286 
1287  switch (ctype) {
1288  case 0:
1289  create_pathname(str, name, size);
1290  break;
1291 
1292  case 1:
1293  create_overlay_pathname(str, name, MAX_BUF);
1294  break;
1295 
1296 /* case 2:
1297  rv = create_items_path(str);
1298  break;*/
1299 
1300  default:
1301  *type = CFAPI_NONE;
1302  break;
1303  }
1304  va_end(args);
1305 }
1306 
1307 static void cfapi_map_get_map_property(int *type, ...) {
1308  va_list args;
1309  mapstruct *map;
1310  int property;
1311 
1312  int *rint;
1313  mapstruct **rmap;
1314  sstring *rstr;
1315  region **rreg;
1316  int16_t *nx, *ny;
1317  int x, y;
1318 
1319  va_start(args, type);
1320 
1321  map = va_arg(args, mapstruct *);
1322  property = va_arg(args, int);
1323 
1324  switch (property) {
1325  case CFAPI_MAP_PROP_FLAGS:
1326  rmap = va_arg(args, mapstruct **);
1327  x = va_arg(args, int);
1328  y = va_arg(args, int);
1329  nx = va_arg(args, int16_t *);
1330  ny = va_arg(args, int16_t *);
1331  rint = va_arg(args, int *);
1332  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1333  *type = CFAPI_INT;
1334  break;
1335 
1337  rint = va_arg(args, int *);
1338  *rint = calculate_difficulty(map);
1339  *type = CFAPI_INT;
1340  break;
1341 
1342  case CFAPI_MAP_PROP_PATH:
1343  rstr = va_arg(args, sstring *);
1344  *rstr = map->path;
1345  *type = CFAPI_SSTRING;
1346  break;
1347 
1349  rstr = va_arg(args, sstring *);
1350  *rstr = map->tmpname;
1351  *type = CFAPI_SSTRING;
1352  break;
1353 
1354  case CFAPI_MAP_PROP_NAME:
1355  rstr = va_arg(args, sstring *);
1356  *rstr = map->name;
1357  *type = CFAPI_SSTRING;
1358  break;
1359 
1361  rint = va_arg(args, int *);
1362  *rint = map->reset_time;
1363  *type = CFAPI_INT;
1364  break;
1365 
1367  rint = va_arg(args, int *);
1368  *rint = map->reset_timeout;
1369  *type = CFAPI_INT;
1370  break;
1371 
1373  rint = va_arg(args, int *);
1374  *rint = map->players;
1375  *type = CFAPI_INT;
1376  break;
1377 
1379  rint = va_arg(args, int *);
1380  *rint = map->darkness;
1381  *type = CFAPI_INT;
1382  break;
1383 
1384  case CFAPI_MAP_PROP_WIDTH:
1385  rint = va_arg(args, int *);
1386  *rint = map->width;
1387  *type = CFAPI_INT;
1388  break;
1389 
1390  case CFAPI_MAP_PROP_HEIGHT:
1391  rint = va_arg(args, int *);
1392  *rint = map->height;
1393  *type = CFAPI_INT;
1394  break;
1395 
1397  rint = va_arg(args, int *);
1398  *rint = map->enter_x;
1399  *type = CFAPI_INT;
1400  break;
1401 
1403  rint = va_arg(args, int *);
1404  *rint = map->enter_y;
1405  *type = CFAPI_INT;
1406  break;
1407 
1409  rstr = va_arg(args, sstring *);
1410  *rstr = map->msg;
1411  *type = CFAPI_SSTRING;
1412  break;
1413 
1414  case CFAPI_MAP_PROP_NEXT:
1415  rmap = va_arg(args, mapstruct **);
1416  *rmap = map ? map->next : first_map;
1417  *type = CFAPI_PMAP;
1418  break;
1419 
1420  case CFAPI_MAP_PROP_REGION:
1421  rreg = va_arg(args, region **);
1422  *rreg = get_region_by_map(map);
1423  *type = CFAPI_PREGION;
1424  break;
1425 
1426  case CFAPI_MAP_PROP_UNIQUE:
1427  rint = va_arg(args, int *);
1428  *rint = map->unique;
1429  *type = CFAPI_INT;
1430  break;
1431 
1432  default:
1433  *type = CFAPI_NONE;
1434  break;
1435  }
1436  va_end(args);
1437 }
1438 
1439 static void cfapi_map_set_map_property(int *type, ...) {
1440  va_list args;
1441  mapstruct *map;
1442  int property;
1443  const char *buf;
1444 
1445  va_start(args, type);
1446 
1447  map = va_arg(args, mapstruct *);
1448  property = va_arg(args, int);
1449 
1450  switch (property) {
1451  case CFAPI_MAP_PROP_PATH:
1452  buf = va_arg(args, const char *);
1453  strlcpy(map->path, buf, sizeof(map->path));
1454  *type = CFAPI_STRING;
1455  break;
1456 
1457  default:
1458  *type = CFAPI_NONE;
1459  break;
1460  }
1461  va_end(args);
1462 }
1463 
1469 static void cfapi_map_out_of_map(int *type, ...) {
1470  va_list args;
1471  mapstruct *map;
1472  int x, y;
1473  int *rint;
1474 
1475  va_start(args, type);
1476  map = va_arg(args, mapstruct *);
1477  x = va_arg(args, int);
1478  y = va_arg(args, int);
1479  rint = va_arg(args, int *);
1480 
1481  *rint = out_of_map(map, x, y);
1482  va_end(args);
1483  *type = CFAPI_INT;
1484 }
1485 
1491 static void cfapi_map_update_position(int *type, ...) {
1492  va_list args;
1493  mapstruct *map;
1494  int x, y;
1495 
1496  va_start(args, type);
1497 
1498  map = va_arg(args, mapstruct *);
1499  x = va_arg(args, int);
1500  y = va_arg(args, int);
1501 
1502  update_position(map, x, y);
1503  va_end(args);
1504  *type = CFAPI_NONE;
1505 }
1506 
1507 static void cfapi_map_delete_map(int *type, ...) {
1508  va_list args;
1509  mapstruct *map;
1510  va_start(args, type);
1511 
1512  map = va_arg(args, mapstruct *);
1513 
1514  delete_map(map);
1515 
1516  va_end(args);
1517  *type = CFAPI_NONE;
1518 }
1519 
1520 static void cfapi_map_message(int *type, ...) {
1521  va_list args;
1522  mapstruct *map;
1523  const char *string;
1524  int color;
1525 
1526  va_start(args, type);
1527  map = va_arg(args, mapstruct *);
1528  string = va_arg(args, const char *);
1529  color = va_arg(args, int);
1530  va_end(args);
1531 
1532  /* function should be extended to take message types probably */
1533  ext_info_map(color, map, MSG_TYPE_MISC, MSG_SUBTYPE_NONE, string);
1534  *type = CFAPI_NONE;
1535 }
1536 
1542 static void cfapi_map_get_object_at(int *type, ...) {
1543  va_list args;
1544  mapstruct *map;
1545  int x, y;
1546  int16_t sx, sy;
1547  object **robj;
1548 
1549  va_start(args, type);
1550  map = va_arg(args, mapstruct *);
1551  x = va_arg(args, int);
1552  y = va_arg(args, int);
1553  robj = va_arg(args, object **);
1554  va_end(args);
1555 
1556  sx = x;
1557  sy = y;
1558  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1559  *robj = NULL;
1560  else
1561  *robj = GET_MAP_OB(map, sx, sy);
1562  *type = CFAPI_POBJECT;
1563 }
1564 
1571 static void cfapi_map_find_by_archetype_name(int *type, ...) {
1572  va_list args;
1573  int x, y;
1574  mapstruct *map;
1575  char *msg;
1576  object **robj;
1577 
1578  va_start(args, type);
1579 
1580  msg = va_arg(args, char *);
1581  map = va_arg(args, mapstruct *);
1582  x = va_arg(args, int);
1583  y = va_arg(args, int);
1584  robj = va_arg(args, object **);
1585 
1586  va_end(args);
1587 
1588  archetype *at = try_find_archetype(msg);
1589  *robj = at == NULL ? NULL : map_find_by_archetype(map, x, y, at);
1590  *type = CFAPI_POBJECT;
1591 }
1592 
1598 static void cfapi_map_change_light(int *type, ...) {
1599  va_list args;
1600  int change;
1601  mapstruct *map;
1602  int *rint;
1603 
1604  va_start(args, type);
1605  map = va_arg(args, mapstruct *);
1606  change = va_arg(args, int);
1607  rint = va_arg(args, int *);
1608  va_end(args);
1609 
1610  *type = CFAPI_INT;
1611  *rint = change_map_light(map, change);
1612 }
1613 
1614 /* OBJECT-RELATED HOOKS */
1615 
1629 static void cfapi_object_move(int *type, ...) {
1630  va_list args;
1631  int kind;
1632  object *op;
1633  object *activator;
1634  player *pl;
1635  int direction;
1636  int *ret;
1637 
1638  va_start(args, type);
1639  kind = va_arg(args, int);
1640  switch (kind) {
1641  case 0:
1642  op = va_arg(args, object *);
1643  direction = va_arg(args, int);
1644  activator = va_arg(args, object *);
1645  ret = va_arg(args, int *);
1646  va_end(args);
1647  *ret = move_ob(op, direction, activator);
1648  break;
1649 
1650  case 1:
1651  pl = va_arg(args, player *);
1652  direction = va_arg(args, int);
1653  ret = va_arg(args, int *);
1654  va_end(args);
1655  *ret = move_player(pl->ob, direction);
1656  break;
1657 
1658  case 2:
1659  op = va_arg(args, object *);
1660  ret = va_arg(args, int *);
1661  va_end(args);
1662  *ret = player_arrest(op);
1663  break;
1664 
1665  default:
1666  // Just end the use of variable args. We got a wrong type.
1667  va_end(args);
1668  }
1669  *type = CFAPI_INT;
1670 }
1671 
1679 static void cfapi_object_get_key(int *type, ...) {
1680  va_list args;
1681  const char *keyname;
1682  const char **value;
1683  object *op;
1684 
1685  va_start(args, type);
1686  op = va_arg(args, object *);
1687  keyname = va_arg(args, const char *);
1688  value = va_arg(args, const char **);
1689  va_end(args);
1690 
1691  *value = object_get_value(op, keyname);
1692  *type = CFAPI_SSTRING;
1693 }
1694 
1701 static void cfapi_object_set_key(int *type, ...) {
1702  va_list args;
1703  const char *keyname;
1704  const char *value;
1705  int *ret;
1706  object *op;
1707  int add_key;
1708 
1709  va_start(args, type);
1710  op = va_arg(args, object *);
1711  keyname = va_arg(args, char *);
1712  value = va_arg(args, char *);
1713  add_key = va_arg(args, int);
1714  ret = va_arg(args, int *);
1715  va_end(args);
1716 
1717  *ret = object_set_value(op, keyname, value, add_key);
1718  *type = CFAPI_INT;
1719 }
1720 
1724 static void cfapi_object_get_property(int *type, ...) {
1725  va_list args;
1726  int property;
1727  object *op;
1728  int *rint;
1729  object **robject;
1730  mapstruct **rmap;
1731  float *rfloat;
1732  archetype **rarch;
1733  sstring *rsstring;
1734  char *rbuffer;
1735  int rbufsize;
1736  MoveType *rmove;
1737  int64_t *rint64;
1738  partylist **rparty;
1739  double *rdouble;
1740  long *rlong;
1741 
1742  va_start(args, type);
1743 
1744  op = va_arg(args, object *);
1745  property = va_arg(args, int);
1746  switch (property) {
1748  robject = va_arg(args, object **);
1749  *robject = op->above;
1750  *type = CFAPI_POBJECT;
1751  break;
1752 
1754  robject = va_arg(args, object **);
1755  *robject = op->below;
1756  *type = CFAPI_POBJECT;
1757  break;
1758 
1760  robject = va_arg(args, object **);
1761  *robject = op->active_next;
1762  *type = CFAPI_POBJECT;
1763  break;
1764 
1766  robject = va_arg(args, object **);
1767  *robject = op->active_prev;
1768  *type = CFAPI_POBJECT;
1769  break;
1770 
1772  robject = va_arg(args, object **);
1773  *robject = op->inv;
1774  *type = CFAPI_POBJECT;
1775  break;
1776 
1778  robject = va_arg(args, object **);
1779  *robject = op->env;
1780  *type = CFAPI_POBJECT;
1781  break;
1782 
1784  robject = va_arg(args, object **);
1785  *robject = op->head;
1786  *type = CFAPI_POBJECT;
1787  break;
1788 
1790  robject = va_arg(args, object **);
1791  *robject = op->container;
1792  *type = CFAPI_POBJECT;
1793  break;
1794 
1795  case CFAPI_OBJECT_PROP_MAP:
1796  rmap = va_arg(args, mapstruct **);
1797  *rmap = op->map;
1798  *type = CFAPI_PMAP;
1799  break;
1800 
1802  rint = va_arg(args, int *);
1803  *rint = op->count;
1804  *type = CFAPI_INT;
1805  break;
1806 
1808  rbuffer = va_arg(args, char *);
1809  rbufsize = va_arg(args, int);
1810  query_name(op, rbuffer, rbufsize);
1811  *type = CFAPI_STRING;
1812  break;
1813 
1815  rsstring = va_arg(args, sstring *);
1816  *rsstring = op->name_pl;
1817  *type = CFAPI_SSTRING;
1818  break;
1819 
1821  rsstring = va_arg(args, sstring *);
1822  *rsstring = op->title;
1823  *type = CFAPI_SSTRING;
1824  break;
1825 
1827  rsstring = va_arg(args, sstring *);
1828  *rsstring = op->race;
1829  *type = CFAPI_SSTRING;
1830  break;
1831 
1833  rsstring = va_arg(args, sstring *);
1834  *rsstring = op->slaying;
1835  *type = CFAPI_SSTRING;
1836  break;
1837 
1839  rsstring = va_arg(args, sstring *);
1840  *rsstring = op->skill;
1841  *type = CFAPI_SSTRING;
1842  break;
1843 
1845  rsstring = va_arg(args, sstring *);
1846  *rsstring = op->msg;
1847  *type = CFAPI_SSTRING;
1848  break;
1849 
1851  rsstring = va_arg(args, sstring *);
1852  *rsstring = op->lore;
1853  *type = CFAPI_SSTRING;
1854  break;
1855 
1856  case CFAPI_OBJECT_PROP_X:
1857  rint = va_arg(args, int *);
1858  *rint = op->x;
1859  *type = CFAPI_INT;
1860  break;
1861 
1862  case CFAPI_OBJECT_PROP_Y:
1863  rint = va_arg(args, int *);
1864  *rint = op->y;
1865  *type = CFAPI_INT;
1866  break;
1867 
1869  rfloat = va_arg(args, float *);
1870  *rfloat = op->speed;
1871  *type = CFAPI_FLOAT;
1872  break;
1873 
1875  rfloat = va_arg(args, float *);
1876  *rfloat = op->speed_left;
1877  *type = CFAPI_FLOAT;
1878  break;
1879 
1881  rint = va_arg(args, int *);
1882  *rint = op->nrof;
1883  *type = CFAPI_INT;
1884  break;
1885 
1887  rint = va_arg(args, int *);
1888  *rint = op->direction;
1889  *type = CFAPI_INT;
1890  break;
1891 
1893  rint = va_arg(args, int *);
1894  *rint = op->facing;
1895  *type = CFAPI_INT;
1896  break;
1897 
1899  rint = va_arg(args, int *);
1900  *rint = op->type;
1901  *type = CFAPI_INT;
1902  break;
1903 
1905  rint = va_arg(args, int *);
1906  *rint = op->subtype;
1907  *type = CFAPI_INT;
1908  break;
1909 
1911  rint = va_arg(args, int *);
1912  *rint = op->client_type;
1913  *type = CFAPI_INT;
1914  break;
1915 
1916  case CFAPI_OBJECT_PROP_RESIST: {
1917  int idx;
1918  int16_t *resist;
1919 
1920  idx = va_arg(args, int);
1921  resist = va_arg(args, int16_t *);
1922  *resist = op->resist[idx];
1923  }
1924  *type = CFAPI_INT16;
1925  break;
1926 
1928  rint = va_arg(args, int *);
1929  *rint = op->attacktype;
1930  *type = CFAPI_INT;
1931  break;
1932 
1934  rint = va_arg(args, int *);
1935  *rint = op->path_attuned;
1936  *type = CFAPI_INT;
1937  break;
1938 
1940  rint = va_arg(args, int *);
1941  *rint = op->path_repelled;
1942  *type = CFAPI_INT;
1943  break;
1944 
1946  rint = va_arg(args, int *);
1947  *rint = op->path_denied;
1948  *type = CFAPI_INT;
1949  break;
1950 
1952  rint = va_arg(args, int *);
1953  *rint = op->material;
1954  *type = CFAPI_INT;
1955  break;
1956 
1958  rsstring = va_arg(args, sstring *);
1959  *rsstring = op->materialname;
1960  *type = CFAPI_SSTRING;
1961  break;
1962 
1964  rint = va_arg(args, int *);
1965  *rint = op->magic;
1966  *type = CFAPI_INT;
1967  break;
1968 
1970  rlong = va_arg(args, long *);
1971  *rlong = op->value;
1972  *type = CFAPI_LONG;
1973  break;
1974 
1976  rint = va_arg(args, int *);
1977  *rint = op->level;
1978  *type = CFAPI_INT;
1979  break;
1980 
1982  rint = va_arg(args, int *);
1983  *rint = op->last_heal;
1984  *type = CFAPI_INT;
1985  break;
1986 
1988  rint = va_arg(args, int *);
1989  *rint = op->last_sp;
1990  *type = CFAPI_INT;
1991  break;
1992 
1994  rint = va_arg(args, int *);
1995  *rint = op->last_grace;
1996  *type = CFAPI_INT;
1997  break;
1998 
2000  rint = va_arg(args, int *);
2001  *rint = op->last_eat;
2002  *type = CFAPI_INT;
2003  break;
2004 
2006  rint = va_arg(args, int *);
2007  *rint = op->invisible;
2008  *type = CFAPI_INT;
2009  break;
2010 
2012  rint = va_arg(args, int *);
2013  *rint = op->pick_up;
2014  *type = CFAPI_INT;
2015  break;
2016 
2018  rint = va_arg(args, int *);
2019  *rint = op->item_power;
2020  *type = CFAPI_INT;
2021  break;
2022 
2024  rint = va_arg(args, int *);
2025  *rint = op->gen_sp_armour;
2026  *type = CFAPI_INT;
2027  break;
2028 
2030  rint = va_arg(args, int *);
2031  *rint = op->weight;
2032  *type = CFAPI_INT;
2033  break;
2034 
2036  rint = va_arg(args, int *);
2037  *rint = op->weight_limit;
2038  *type = CFAPI_INT;
2039  break;
2040 
2042  rint = va_arg(args, int *);
2043  *rint = op->carrying;
2044  *type = CFAPI_INT;
2045  break;
2046 
2048  rint = va_arg(args, int *);
2049  *rint = op->glow_radius;
2050  *type = CFAPI_INT;
2051  break;
2052 
2054  rint64 = va_arg(args, int64_t *);
2055  *rint64 = op->total_exp;
2056  *type = CFAPI_SINT64;
2057  break;
2058 
2060  robject = va_arg(args, object **);
2061  *robject = op->current_weapon;
2062  *type = CFAPI_POBJECT;
2063  break;
2064 
2066  robject = va_arg(args, object **);
2067  *robject = op->enemy;
2068  *type = CFAPI_POBJECT;
2069  break;
2070 
2072  robject = va_arg(args, object **);
2073  *robject = op->attacked_by;
2074  *type = CFAPI_POBJECT;
2075  break;
2076 
2078  rint = va_arg(args, int *);
2079  *rint = op->run_away;
2080  *type = CFAPI_INT;
2081  break;
2082 
2084  robject = va_arg(args, object **);
2085  *robject = op->chosen_skill;
2086  *type = CFAPI_POBJECT;
2087  break;
2088 
2090  rint = va_arg(args, int *);
2091  *rint = op->hide;
2092  *type = CFAPI_INT;
2093  break;
2094 
2096  rint = va_arg(args, int *);
2097  *rint = op->move_status;
2098  *type = CFAPI_INT;
2099  break;
2100 
2102  rint = va_arg(args, int *);
2103  *rint = op->attack_movement;
2104  *type = CFAPI_INT;
2105  break;
2106 
2108  robject = va_arg(args, object **);
2109  *robject = op->spellitem;
2110  *type = CFAPI_POBJECT;
2111  break;
2112 
2114  rdouble = va_arg(args, double *);
2115  *rdouble = op->expmul;
2116  *type = CFAPI_DOUBLE;
2117  break;
2118 
2120  rarch = va_arg(args, archetype **);
2121  *rarch = op->arch;
2122  *type = CFAPI_PARCH;
2123  break;
2124 
2126  rarch = va_arg(args, archetype **);
2127  *rarch = op->other_arch;
2128  *type = CFAPI_PARCH;
2129  break;
2130 
2132  rsstring = va_arg(args, sstring *);
2133  *rsstring = op->custom_name;
2134  *type = CFAPI_SSTRING;
2135  break;
2136 
2138  rint = va_arg(args, int *);
2139  *rint = op->anim_speed;
2140  *type = CFAPI_INT;
2141  break;
2142 
2144  rint = va_arg(args, int *);
2145  *rint = is_friendly(op);
2146  *type = CFAPI_INT;
2147  break;
2148 
2150  rbuffer = va_arg(args, char *);
2151  rbufsize = va_arg(args, int);
2152  query_short_name(op, rbuffer, rbufsize);
2153  *type = CFAPI_STRING;
2154  break;
2155 
2157  int i;
2158 
2159  i = va_arg(args, int);
2160  rbuffer = va_arg(args, char *);
2161  rbufsize = va_arg(args, int);
2162  query_base_name(op, i, rbuffer, rbufsize);
2163  *type = CFAPI_STRING;
2164  }
2165  break;
2166 
2168  rsstring = va_arg(args, sstring *);
2169  *rsstring = op->name;
2170  *type = CFAPI_SSTRING;
2171  break;
2172 
2174  rint = va_arg(args, int *);
2175  *rint = is_magical(op);
2176  *type = CFAPI_INT;
2177  break;
2178 
2180  rint = va_arg(args, int *);
2181  *rint = op->stats.luck;
2182  *type = CFAPI_INT;
2183  break;
2184 
2185  case CFAPI_OBJECT_PROP_EXP:
2186  rint64 = va_arg(args, int64_t *);
2187  *rint64 = op->stats.exp;
2188  *type = CFAPI_SINT64;
2189  break;
2190 
2192  robject = va_arg(args, object **);
2193  *robject = object_get_owner(op);
2194  *type = CFAPI_POBJECT;
2195  break;
2196 
2198  int stype;
2199 
2200  stype = va_arg(args, int);
2201  switch (stype) {
2202  unsigned char ptype;
2203  char *buf;
2204  archetype *at;
2205 
2206  case 0: /* present_in_ob */
2207  ptype = (unsigned char)(va_arg(args, int));
2208  robject = va_arg(args, object **);
2209  *robject = object_present_in_ob(ptype, op);
2210  break;
2211 
2212  case 1: /* present_in_ob_by_name */
2213  ptype = (unsigned char)(va_arg(args, int));
2214  buf = va_arg(args, char *);
2215  robject = va_arg(args, object **);
2216  *robject = object_present_in_ob_by_name(ptype, buf, op);
2217  break;
2218 
2219  case 2: /* arch_present_in_ob */
2220  at = va_arg(args, archetype *);
2221  robject = va_arg(args, object **);
2222  *robject = arch_present_in_ob(at, op);
2223  break;
2224  }
2225  }
2226  *type = CFAPI_POBJECT;
2227  break;
2228 
2230  rint = va_arg(args, int *);
2231  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2232  *type = CFAPI_INT;
2233  break;
2234 
2236  object *op2;
2237 
2238  op2 = va_arg(args, object *);
2239  rint = va_arg(args, int *);
2240  *rint = object_can_merge(op, op2);
2241  }
2242  *type = CFAPI_INT;
2243  break;
2244 
2246  object *op2;
2247 
2248  op2 = va_arg(args, object *);
2249  rint = va_arg(args, int *);
2250  *rint = object_can_pick(op2, op);
2251  }
2252  *type = CFAPI_INT;
2253  break;
2254 
2255  case CFAPI_OBJECT_PROP_FLAGS: {
2256  int fl;
2257 
2258  fl = va_arg(args, int);
2259  rint = va_arg(args, int *);
2260  *rint = QUERY_FLAG(op, fl);
2261  }
2262  *type = CFAPI_INT;
2263  break;
2264 
2265  case CFAPI_OBJECT_PROP_STR:
2266  rint = va_arg(args, int *);
2267  *rint = op->stats.Str;
2268  *type = CFAPI_INT;
2269  break;
2270 
2271  case CFAPI_OBJECT_PROP_DEX:
2272  rint = va_arg(args, int *);
2273  *rint = op->stats.Dex;
2274  *type = CFAPI_INT;
2275  break;
2276 
2277  case CFAPI_OBJECT_PROP_CON:
2278  rint = va_arg(args, int *);
2279  *rint = op->stats.Con;
2280  *type = CFAPI_INT;
2281  break;
2282 
2283  case CFAPI_OBJECT_PROP_WIS:
2284  rint = va_arg(args, int *);
2285  *rint = op->stats.Wis;
2286  *type = CFAPI_INT;
2287  break;
2288 
2289  case CFAPI_OBJECT_PROP_INT:
2290  rint = va_arg(args, int *);
2291  *rint = op->stats.Int;
2292  *type = CFAPI_INT;
2293  break;
2294 
2295  case CFAPI_OBJECT_PROP_POW:
2296  rint = va_arg(args, int *);
2297  *rint = op->stats.Pow;
2298  *type = CFAPI_INT;
2299  break;
2300 
2301  case CFAPI_OBJECT_PROP_CHA:
2302  rint = va_arg(args, int *);
2303  *rint = op->stats.Cha;
2304  *type = CFAPI_INT;
2305  break;
2306 
2307  case CFAPI_OBJECT_PROP_WC:
2308  rint = va_arg(args, int *);
2309  *rint = op->stats.wc;
2310  *type = CFAPI_INT;
2311  break;
2312 
2313  case CFAPI_OBJECT_PROP_AC:
2314  rint = va_arg(args, int *);
2315  *rint = op->stats.ac;
2316  *type = CFAPI_INT;
2317  break;
2318 
2319  case CFAPI_OBJECT_PROP_HP:
2320  rint = va_arg(args, int *);
2321  *rint = op->stats.hp;
2322  *type = CFAPI_INT;
2323  break;
2324 
2325  case CFAPI_OBJECT_PROP_SP:
2326  rint = va_arg(args, int *);
2327  *rint = op->stats.sp;
2328  *type = CFAPI_INT;
2329  break;
2330 
2331  case CFAPI_OBJECT_PROP_GP:
2332  rint = va_arg(args, int *);
2333  *rint = op->stats.grace;
2334  *type = CFAPI_INT;
2335  break;
2336 
2337  case CFAPI_OBJECT_PROP_FP:
2338  rint = va_arg(args, int *);
2339  *rint = op->stats.food;
2340  *type = CFAPI_INT;
2341  break;
2342 
2344  rint = va_arg(args, int *);
2345  *rint = op->stats.maxhp;
2346  *type = CFAPI_INT;
2347  break;
2348 
2350  rint = va_arg(args, int *);
2351  *rint = op->stats.maxsp;
2352  *type = CFAPI_INT;
2353  break;
2354 
2356  rint = va_arg(args, int *);
2357  *rint = op->stats.maxgrace;
2358  *type = CFAPI_INT;
2359  break;
2360 
2361  case CFAPI_OBJECT_PROP_DAM:
2362  rint = va_arg(args, int *);
2363  *rint = op->stats.dam;
2364  *type = CFAPI_INT;
2365  break;
2366 
2367  case CFAPI_OBJECT_PROP_GOD:
2368  rsstring = va_arg(args, sstring *);
2369  *rsstring = determine_god(op);
2370  *type = CFAPI_SSTRING;
2371  break;
2372 
2374  rsstring = va_arg(args, sstring *);
2375  *rsstring = op->arch->name;
2376  *type = CFAPI_SSTRING;
2377  break;
2378 
2380  rint = va_arg(args, int *);
2381  *rint = op->invisible;
2382  *type = CFAPI_INT;
2383  break;
2384 
2386  rbuffer = va_arg(args, char *);
2387  rbufsize = va_arg(args, int);
2388  if (rbufsize > 0) {
2389  strncpy(rbuffer, op->face->name, rbufsize);
2390  rbuffer[rbufsize - 1] = '\0';
2391  }
2392  *type = CFAPI_STRING;
2393  break;
2394 
2396  rbuffer = va_arg(args, char *);
2397  rbufsize = va_arg(args, int);
2398  if (rbufsize > 0) {
2399  if (op->animation_id != 0) {
2400  strncpy(rbuffer, animations[op->animation_id].name, rbufsize);
2401  rbuffer[rbufsize - 1] = '\0';
2402  }
2403  else
2404  rbuffer[0] = '\0';
2405  }
2406  *type = CFAPI_STRING;
2407  break;
2408 
2409  case CFAPI_PLAYER_PROP_IP:
2410  rsstring = va_arg(args, sstring *);
2411  *rsstring = op->contr->socket.host;
2412  *type = CFAPI_SSTRING;
2413  break;
2414 
2416  robject = va_arg(args, object **);
2417  *robject = find_marked_object(op);
2418  *type = CFAPI_POBJECT;
2419  break;
2420 
2422  rparty = va_arg(args, partylist **);
2423  *rparty = (op->contr ? op->contr->party : NULL);
2424  *type = CFAPI_PPARTY;
2425  break;
2426 
2428  robject = va_arg(args, object **);
2429  if (op)
2430  *robject = op->contr->next ? op->contr->next->ob : NULL;
2431  else
2432  /* This can be called when there is no player. */
2433  *robject = first_player ? first_player->ob : NULL;
2434  *type = CFAPI_POBJECT;
2435  break;
2436 
2438  rbuffer = va_arg(args, char *);
2439  rbufsize = va_arg(args, int);
2440  player_get_title(op->contr, rbuffer, rbufsize);
2441  *type = CFAPI_STRING;
2442  break;
2443 
2445  rmove = va_arg(args, MoveType *);
2446  *rmove = op->move_type;
2447  *type = CFAPI_MOVETYPE;
2448  break;
2449 
2451  rmove = va_arg(args, MoveType *);
2452  *rmove = op->move_block;
2453  *type = CFAPI_MOVETYPE;
2454  break;
2455 
2457  rmove = va_arg(args, MoveType *);
2458  *rmove = op->move_allow;
2459  *type = CFAPI_MOVETYPE;
2460  break;
2461 
2463  rmove = va_arg(args, MoveType *);
2464  *rmove = op->move_on;
2465  *type = CFAPI_MOVETYPE;
2466  break;
2467 
2469  rmove = va_arg(args, MoveType *);
2470  *rmove = op->move_off;
2471  *type = CFAPI_MOVETYPE;
2472  break;
2473 
2475  rmove = va_arg(args, MoveType *);
2476  *rmove = op->move_type;
2477  *type = CFAPI_MOVETYPE;
2478  break;
2479 
2481  rfloat = va_arg(args, float *);
2482  *rfloat = op->move_slow_penalty;
2483  *type = CFAPI_FLOAT;
2484  break;
2485 
2487  rbuffer = va_arg(args, char *);
2488  rbufsize = va_arg(args, int);
2489  strlcpy(rbuffer, op->contr->savebed_map, rbufsize);
2490  *type = CFAPI_STRING;
2491  break;
2492 
2494  rint = va_arg(args, int *);
2495  *rint = op->contr->bed_x;
2496  *type = CFAPI_INT;
2497  break;
2498 
2500  rint = va_arg(args, int *);
2501  *rint = op->contr->bed_y;
2502  *type = CFAPI_INT;
2503  break;
2504 
2506  rint = va_arg(args, int *);
2507  *rint = op->duration;
2508  *type = CFAPI_INT;
2509  break;
2510 
2511  default:
2512  *type = CFAPI_NONE;
2513  break;
2514  }
2515  va_end(args);
2516 }
2517 
2526 static void copy_message(object *op, const char *msg) {
2527  char *temp;
2528  int size;
2529 
2530  if (!msg)
2531  return;
2532 
2533  /* need to reset parsed dialog information */
2535 
2536  size = strlen(msg);
2537 
2538  if (msg[0] != 0 && msg[size-1] == '\n') {
2539  object_set_msg(op, msg);
2540  return;
2541  }
2542 
2543  temp = malloc(size+2);
2544  if (!temp)
2546  snprintf(temp, size+2, "%s\n", msg);
2547  object_set_msg(op, temp);
2548  free(temp);
2549 }
2550 
2559 static void cfapi_object_set_property(int *type, ...) {
2560  va_list args;
2561  int iarg, *ret;
2562  long larg;
2563  char *sarg;
2564  double darg;
2565  object *oparg;
2566  object *op;
2567  int property;
2568  int64_t s64arg;
2569  partylist *partyarg;
2570  float farg;
2571  MoveType *move; /* MoveType can't be used through va_arg so use MoveType * */
2572 
2573  va_start(args, type);
2574  op = va_arg(args, object *);
2575  property = va_arg(args, int);
2576  *type = CFAPI_NONE;
2577 
2578  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2579  switch (property) {
2581  sarg = va_arg(args, char *);
2582  *type = CFAPI_STRING;
2583  FREE_AND_COPY(op->name, sarg);
2584  send_changed_object(op);
2585  break;
2586 
2588  sarg = va_arg(args, char *);
2589  *type = CFAPI_STRING;
2590  FREE_AND_COPY(op->name_pl, sarg);
2591  send_changed_object(op);
2592  break;
2593 
2595  sarg = va_arg(args, char *);
2596  *type = CFAPI_STRING;
2597  FREE_AND_COPY(op->title, sarg);
2598  break;
2599 
2601  sarg = va_arg(args, char *);
2602  *type = CFAPI_STRING;
2603  FREE_AND_COPY(op->race, sarg);
2604  break;
2605 
2607  sarg = va_arg(args, char *);
2608  *type = CFAPI_STRING;
2609  FREE_AND_COPY(op->slaying, sarg);
2610  break;
2611 
2613  sarg = va_arg(args, char *);
2614  *type = CFAPI_STRING;
2615  FREE_AND_COPY(op->skill, sarg);
2616  break;
2617 
2619  sarg = va_arg(args, char *);
2620  *type = CFAPI_STRING;
2621  copy_message(op, sarg);
2622  break;
2623 
2625  sarg = va_arg(args, char *);
2626  *type = CFAPI_STRING;
2627  FREE_AND_COPY(op->lore, sarg);
2628  break;
2629 
2631  farg = va_arg(args, double);
2632  *type = CFAPI_FLOAT;
2633  if (farg != op->speed) {
2634  op->speed = farg;
2635  object_update_speed(op);
2636  }
2637  break;
2638 
2640  farg = va_arg(args, double);
2641  *type = CFAPI_FLOAT;
2642  op->speed_left = farg;
2643  break;
2644 
2646  iarg = va_arg(args, int);
2647  *type = CFAPI_INT;
2648  if (iarg < 0)
2649  iarg = 0;
2650  if (op->nrof > (uint32_t)iarg)
2651  object_decrease_nrof(op, op->nrof-iarg);
2652  else if (op->nrof < (uint32_t)iarg) {
2653  object *tmp;
2654  player *pl;
2655 
2656  op->nrof = iarg;
2657  if (op->env != NULL) {
2658  tmp = object_get_player_container(op->env);
2659  if (!tmp) {
2660  for (pl = first_player; pl; pl = pl->next)
2661  if (pl->ob->container == op->env)
2662  break;
2663  if (pl)
2664  tmp = pl->ob;
2665  else
2666  tmp = NULL;
2667  } else {
2668  object_sum_weight(tmp);
2669  fix_object(tmp);
2670  }
2671  if (tmp)
2672  esrv_update_item(UPD_NROF, tmp, op);
2673  } else {
2674  FOR_ABOVE_PREPARE(op, tmp)
2675  if (tmp->type == PLAYER)
2676  tmp->contr->socket.update_look = 1;
2677  FOR_ABOVE_FINISH();
2678  }
2679  }
2680  break;
2681 
2683  iarg = va_arg(args, int);
2684  *type = CFAPI_INT;
2685  op->direction = iarg;
2686  break;
2687 
2689  iarg = va_arg(args, int);
2690  *type = CFAPI_INT;
2691  op->facing = iarg;
2692  break;
2693 
2694  case CFAPI_OBJECT_PROP_RESIST: {
2695  int iargbis = va_arg(args, int);
2696 
2697  *type = CFAPI_INT16;
2698  iarg = va_arg(args, int);
2699  op->resist[iargbis] = iarg;
2700  }
2701  break;
2702 
2704  iarg = va_arg(args, int);
2705  *type = CFAPI_INT;
2706  op->attacktype = iarg;
2707  break;
2708 
2710  iarg = va_arg(args, int);
2711  *type = CFAPI_INT;
2712  op->path_attuned = iarg;
2713  break;
2714 
2716  iarg = va_arg(args, int);
2717  *type = CFAPI_INT;
2718  op->path_repelled = iarg;
2719  break;
2720 
2722  iarg = va_arg(args, int);
2723  *type = CFAPI_INT;
2724  op->path_denied = iarg;
2725  break;
2726 
2728  iarg = va_arg(args, int);
2729  *type = CFAPI_INT;
2730  op->material = iarg;
2731  break;
2732 
2734  break;
2735 
2737  iarg = va_arg(args, int);
2738  *type = CFAPI_INT;
2739  op->magic = iarg;
2740  break;
2741 
2743  larg = va_arg(args, long);
2744  *type = CFAPI_LONG;
2745  op->value = larg;
2746  break;
2747 
2749  iarg = va_arg(args, int);
2750  *type = CFAPI_INT;
2751  op->level = iarg;
2752  send_changed_object(op);
2753  break;
2754 
2756  iarg = va_arg(args, int);
2757  *type = CFAPI_INT;
2758  op->last_heal = iarg;
2759  break;
2760 
2762  iarg = va_arg(args, int);
2763  *type = CFAPI_INT;
2764  op->last_sp = iarg;
2765  break;
2766 
2768  iarg = va_arg(args, int);
2769  *type = CFAPI_INT;
2770  op->last_grace = iarg;
2771  break;
2772 
2774  iarg = va_arg(args, int);
2775  *type = CFAPI_INT;
2776  op->last_eat = iarg;
2777  break;
2778 
2780  iarg = va_arg(args, int);
2781  *type = CFAPI_INT;
2782  op->invisible = iarg;
2783  break;
2784 
2786  iarg = va_arg(args, int);
2787  *type = CFAPI_INT;
2788  op->pick_up = iarg;
2789  break;
2790 
2792  iarg = va_arg(args, int);
2793  *type = CFAPI_INT;
2794  op->item_power = iarg;
2795  break;
2796 
2798  iarg = va_arg(args, int);
2799  *type = CFAPI_INT;
2800  op->gen_sp_armour = iarg;
2801  break;
2802 
2804  iarg = va_arg(args, int);
2805  *type = CFAPI_INT;
2806  if (op->weight != iarg) {
2807  object *tmp;
2808  player *pl;
2809 
2810  op->weight = iarg;
2811  if (op->env != NULL) {
2812  tmp = object_get_player_container(op->env);
2813  if (!tmp) {
2814  for (pl = first_player; pl; pl = pl->next)
2815  if (pl->ob->container == op->env)
2816  break;
2817  if (pl)
2818  tmp = pl->ob;
2819  else
2820  tmp = NULL;
2821  } else {
2822  object_sum_weight(tmp);
2823  fix_object(tmp);
2824  }
2825  if (tmp)
2826  esrv_update_item(UPD_WEIGHT, tmp, op);
2827  } else {
2828  FOR_ABOVE_PREPARE(op, tmp)
2829  if (tmp->type == PLAYER)
2830  esrv_update_item(UPD_WEIGHT, tmp, op);
2831  FOR_ABOVE_FINISH();
2832  }
2833  }
2834  break;
2835 
2837  iarg = va_arg(args, int);
2838  *type = CFAPI_INT;
2839  op->weight_limit = iarg;
2840  break;
2841 
2843  iarg = va_arg(args, int);
2844  *type = CFAPI_INT;
2845  if (op->glow_radius != iarg) {
2846  object *tmp;
2847 
2848  op->glow_radius = iarg;
2849  tmp = object_get_env_recursive(op);
2850  if (tmp->map != NULL) {
2851  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2852  update_position(tmp->map, tmp->x, tmp->y);
2853  update_all_los(tmp->map, tmp->x, tmp->y);
2854  }
2855  }
2856  break;
2857 
2859  s64arg = va_arg(args, int64_t);
2860  *type = CFAPI_SINT64;
2861  op->total_exp = s64arg;
2862  break;
2863 
2865  oparg = va_arg(args, object *);
2866  *type = CFAPI_POBJECT;
2867  object_set_enemy(op, oparg);
2868  break;
2869 
2871  iarg = va_arg(args, int);
2872  *type = CFAPI_INT;
2873  op->run_away = iarg;
2874  break;
2875 
2877  oparg = va_arg(args, object *);
2878  *type = CFAPI_POBJECT;
2879  op->chosen_skill = oparg;
2880  break;
2881 
2883  iarg = va_arg(args, int);
2884  *type = CFAPI_INT;
2885  op->hide = iarg;
2886  break;
2887 
2889  iarg = va_arg(args, int);
2890  *type = CFAPI_INT;
2891  op->move_status = iarg;
2892  break;
2893 
2895  iarg = va_arg(args, int);
2896  *type = CFAPI_INT;
2897  op->attack_movement = iarg;
2898  break;
2899 
2901  oparg = va_arg(args, object *);
2902  *type = CFAPI_POBJECT;
2903  op->spellitem = oparg;
2904  break;
2905 
2907  darg = va_arg(args, double);
2908  *type = CFAPI_DOUBLE;
2909  op->expmul = darg;
2910  break;
2911 
2913  sarg = va_arg(args, char *);
2914  *type = CFAPI_STRING;
2915  FREE_AND_COPY(op->custom_name, sarg);
2916  send_changed_object(op);
2917  break;
2918 
2920  iarg = va_arg(args, int);
2921  *type = CFAPI_INT;
2922  op->anim_speed = iarg;
2923  break;
2924 
2926  iarg = va_arg(args, int);
2927  *type = CFAPI_INT;
2928  if (iarg == 1 && is_friendly(op) == 0)
2929  add_friendly_object(op);
2930  else if (iarg == 0 && is_friendly(op) == 1)
2932  break;
2933 
2935  iarg = va_arg(args, int);
2936  *type = CFAPI_INT;
2937  op->stats.luck = iarg;
2938  break;
2939 
2940  case CFAPI_OBJECT_PROP_EXP:
2941  s64arg = va_arg(args, int64_t);
2942  *type = CFAPI_SINT64;
2943  op->stats.exp = s64arg;
2944  break;
2945 
2947  oparg = va_arg(args, object *);
2948  *type = CFAPI_POBJECT;
2949  object_set_owner(op, oparg);
2950  break;
2951 
2953  object_set_cheat(op);
2954  *type = CFAPI_NONE;
2955  break;
2956 
2957  case CFAPI_OBJECT_PROP_FLAGS: {
2958  int iargbis;
2959 
2960  iarg = va_arg(args, int);
2961  iargbis = va_arg(args, int);
2962  *type = CFAPI_INT;
2963 
2964  if (iargbis == 1)
2965  SET_FLAG(op, iarg);
2966  else
2967  CLEAR_FLAG(op, iarg);
2968  }
2969  break;
2970 
2971  case CFAPI_OBJECT_PROP_STR:
2972  iarg = va_arg(args, int);
2973  *type = CFAPI_INT;
2974  op->stats.Str = iarg;
2975  break;
2976 
2977  case CFAPI_OBJECT_PROP_DEX:
2978  iarg = va_arg(args, int);
2979  *type = CFAPI_INT;
2980  op->stats.Dex = iarg;
2981  break;
2982 
2983  case CFAPI_OBJECT_PROP_CON:
2984  iarg = va_arg(args, int);
2985  *type = CFAPI_INT;
2986  op->stats.Con = iarg;
2987  break;
2988 
2989  case CFAPI_OBJECT_PROP_WIS:
2990  iarg = va_arg(args, int);
2991  *type = CFAPI_INT;
2992  op->stats.Wis = iarg;
2993  break;
2994 
2995  case CFAPI_OBJECT_PROP_INT:
2996  iarg = va_arg(args, int);
2997  *type = CFAPI_INT;
2998  op->stats.Int = iarg;
2999  break;
3000 
3001  case CFAPI_OBJECT_PROP_POW:
3002  iarg = va_arg(args, int);
3003  *type = CFAPI_INT;
3004  op->stats.Pow = iarg;
3005  break;
3006 
3007  case CFAPI_OBJECT_PROP_CHA:
3008  iarg = va_arg(args, int);
3009  *type = CFAPI_INT;
3010  op->stats.Cha = iarg;
3011  break;
3012 
3013  case CFAPI_OBJECT_PROP_WC:
3014  iarg = va_arg(args, int);
3015  *type = CFAPI_INT;
3016  op->stats.wc = iarg;
3017  break;
3018 
3019  case CFAPI_OBJECT_PROP_AC:
3020  iarg = va_arg(args, int);
3021  *type = CFAPI_INT;
3022  op->stats.ac = iarg;
3023  break;
3024 
3025  case CFAPI_OBJECT_PROP_HP:
3026  iarg = va_arg(args, int);
3027  *type = CFAPI_INT;
3028  op->stats.hp = iarg;
3029  break;
3030 
3031  case CFAPI_OBJECT_PROP_SP:
3032  iarg = va_arg(args, int);
3033  *type = CFAPI_INT;
3034  op->stats.sp = iarg;
3035  break;
3036 
3037  case CFAPI_OBJECT_PROP_GP:
3038  iarg = va_arg(args, int);
3039  *type = CFAPI_INT;
3040  op->stats.grace = iarg;
3041  break;
3042 
3043  case CFAPI_OBJECT_PROP_FP:
3044  iarg = va_arg(args, int);
3045  *type = CFAPI_INT;
3046  op->stats.food = iarg;
3047  break;
3048 
3050  iarg = va_arg(args, int);
3051  *type = CFAPI_INT;
3052  op->stats.maxhp = iarg;
3053  break;
3054 
3056  iarg = va_arg(args, int);
3057  *type = CFAPI_INT;
3058  op->stats.maxsp = iarg;
3059  break;
3060 
3062  iarg = va_arg(args, int);
3063  *type = CFAPI_INT;
3064  op->stats.maxgrace = iarg;
3065  break;
3066 
3067  case CFAPI_OBJECT_PROP_DAM:
3068  iarg = va_arg(args, int);
3069  *type = CFAPI_INT;
3070  op->stats.dam = iarg;
3071  break;
3072 
3073  case CFAPI_OBJECT_PROP_FACE: {
3074  sarg = va_arg(args, char *);
3075  ret = va_arg(args, int *);
3076  *type = CFAPI_INT;
3077  *ret = find_face(sarg, 0);
3078  if (*ret != 0) {
3079  op->face = &new_faces[*ret];
3080  op->state = 0;
3082  }
3083  break;
3084  }
3085 
3087  sarg = va_arg(args, char *);
3088  ret = va_arg(args, int *);
3089  *type = CFAPI_INT;
3090  *ret = try_find_animation(sarg);
3091  if (*ret != 0) {
3092  op->animation_id = *ret;
3093  SET_ANIMATION(op, 0);
3095  }
3096  break;
3097 
3099  iarg = va_arg(args, int);
3100  *type = CFAPI_INT;
3101  op->duration = iarg;
3102  break;
3103 
3105  if (op->contr) {
3106  oparg = va_arg(args, object *);
3107  *type = CFAPI_POBJECT;
3108  op->contr->mark = oparg;
3109  if (oparg) {
3110  op->contr->mark_count = oparg->count;
3111  } else {
3112  op->contr->mark_count = 0;
3113  }
3114  }
3115  break;
3116 
3118  if (op->contr) {
3119  partyarg = va_arg(args, partylist *);
3120  *type = CFAPI_PPARTY;
3121  party_join(op, partyarg);
3122  }
3123  break;
3124 
3126  sarg = va_arg(args, char *);
3127  *type = CFAPI_STRING;
3128  safe_strncpy(op->contr->savebed_map, sarg, MAX_BUF);
3129  break;
3130 
3132  iarg = va_arg(args, int);
3133  *type = CFAPI_INT;
3134  op->contr->bed_x = iarg;
3135  break;
3136 
3138  iarg = va_arg(args, int);
3139  *type = CFAPI_INT;
3140  op->contr->bed_y = iarg;
3141  break;
3142 
3144  sarg = va_arg(args, char *);
3145  *type = CFAPI_STRING;
3146  player_set_own_title(op->contr, sarg);
3147  break;
3148 
3150  move = va_arg(args, MoveType *);
3151  op->move_type = *move & MOVE_ALL;
3153  *type = CFAPI_MOVETYPE;
3154  break;
3155 
3157  move = va_arg(args, MoveType *);
3158  op->move_block = *move & MOVE_ALL;
3160  *type = CFAPI_MOVETYPE;
3161  break;
3162 
3164  move = va_arg(args, MoveType *);
3165  op->move_allow = *move & MOVE_ALL;
3167  *type = CFAPI_MOVETYPE;
3168  break;
3169 
3171  move = va_arg(args, MoveType *);
3172  op->move_on = *move & MOVE_ALL;
3174  *type = CFAPI_MOVETYPE;
3175  break;
3176 
3178  move = va_arg(args, MoveType *);
3179  op->move_off = *move & MOVE_ALL;
3181  *type = CFAPI_MOVETYPE;
3182  break;
3183 
3185  move = va_arg(args, MoveType *);
3186  op->move_type = *move & MOVE_ALL;
3188  *type = CFAPI_MOVETYPE;
3189  break;
3190 
3191  default:
3192  break;
3193  }
3194  }
3195  va_end(args);
3196 }
3197 
3204 static void cfapi_object_apply_below(int *type, ...) {
3205  va_list args;
3206  object *applier;
3207 
3208  va_start(args, type);
3209 
3210  applier = va_arg(args, object *);
3211 
3212  va_end(args);
3213 
3214  apply_by_living_below(applier);
3215  *type = CFAPI_NONE;
3216 }
3217 
3224 static void cfapi_object_apply(int *type, ...) {
3225  va_list args;
3226  object *applied;
3227  object *applier;
3228  int aflags;
3229  int *ret;
3230 
3231  va_start(args, type);
3232 
3233  applier = va_arg(args, object *);
3234  applied = va_arg(args, object *);
3235  aflags = va_arg(args, int);
3236  ret = va_arg(args, int *);
3237 
3238  va_end(args);
3239 
3240  *type = CFAPI_INT;
3241  *ret = apply_manual(applier, applied, aflags);
3242 }
3243 
3249 static void cfapi_object_identify(int *type, ...) {
3250  va_list args;
3251  object *op, **result;
3252 
3253  va_start(args, type);
3254 
3255  op = va_arg(args, object *);
3256  result = va_arg(args, object **);
3257 
3258  va_end(args);
3259 
3260  (*result) = identify(op);
3261  *type = CFAPI_POBJECT;
3262 }
3263 
3269 static void cfapi_object_describe(int *type, ...) {
3270  va_list args;
3271  object *op;
3272  object *owner;
3273  char *desc, *final;
3274  int size;
3275 
3276  va_start(args, type);
3277 
3278  op = va_arg(args, object *);
3279  owner = va_arg(args, object *);
3280  desc = va_arg(args, char *);
3281  size = va_arg(args, int);
3282  va_end(args);
3283 
3284  *type = CFAPI_STRING;
3285  final = stringbuffer_finish(describe_item(op, owner, 0, NULL));
3286  strncpy(desc, final, size);
3287  desc[size - 1] = '\0';
3288  free(final);
3289 }
3290 
3291 static void cfapi_object_drain(int *type, ...) {
3292  va_list args;
3293 
3294  object *op;
3295  int ds;
3296 
3297  va_start(args, type);
3298 
3299  op = va_arg(args, object *);
3300  ds = va_arg(args, int);
3301 
3302  va_end(args);
3303 
3304  drain_specific_stat(op, ds);
3305 
3306  *type = CFAPI_NONE;
3307 }
3308 
3309 static void cfapi_object_remove_depletion(int *type, ...) {
3310  va_list args;
3311 
3312  object *op;
3313  int level, *result;
3314 
3315  va_start(args, type);
3316 
3317  op = va_arg(args, object *);
3318  level = va_arg(args, int);
3319  result = va_arg(args, int*);
3320 
3321  va_end(args);
3322 
3323  *result = remove_depletion(op, level);
3324 
3325  *type = CFAPI_INT;
3326 }
3327 
3328 static void cfapi_object_fix(int *type, ...) {
3329  va_list args;
3330  object *op;
3331 
3332  va_start(args, type);
3333 
3334  op = va_arg(args, object *);
3335 
3336  va_end(args);
3337 
3338  fix_object(op);
3339 
3340  *type = CFAPI_NONE;
3341 }
3342 
3344 static void cfapi_object_give_skill(int *type, ...) {
3345  va_list args;
3346 
3347  object *op;
3348  char *skillname;
3349 
3350  va_start(args, type);
3351 
3352  op = va_arg(args, object *);
3353  skillname = va_arg(args, char *);
3354 
3355  va_end(args);
3356 
3357  *type = CFAPI_POBJECT;
3358  give_skill_by_name(op, skillname);
3359 }
3360 
3361 static void cfapi_object_transmute(int *type, ...) {
3362  va_list args;
3363 
3364  object *op;
3365  object *chg;
3366 
3367  va_start(args, type);
3368 
3369  op = va_arg(args, object *);
3370  chg = va_arg(args, object *);
3371 
3372  va_end(args);
3373 
3374  transmute_materialname(op, chg);
3375  *type = CFAPI_NONE;
3376 }
3377 
3378 static void cfapi_object_remove(int *type, ...) {
3379  va_list args;
3380  object *op;
3381 
3382  va_start(args, type);
3383 
3384  op = va_arg(args, object *);
3385 
3386  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3387  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3388  va_end(args);
3389  *type = CFAPI_NONE;
3390  return;
3391  }
3392 
3393  va_end(args);
3394 
3395  object_remove(op);
3396  *type = CFAPI_NONE;
3397 }
3398 
3399 static void cfapi_object_delete(int *type, ...) {
3400  va_list args;
3401  object *op;
3402 
3403  va_start(args, type);
3404 
3405  op = va_arg(args, object *);
3406 
3407  if (QUERY_FLAG(op, FLAG_FREED) || !QUERY_FLAG(op, FLAG_REMOVED)) {
3408  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3409  *type = CFAPI_NONE;
3410  va_end(args);
3411  return;
3412  }
3413 
3414  va_end(args);
3415 
3417 
3418  *type = CFAPI_NONE;
3419 }
3420 
3426 static void cfapi_object_clone(int *type, ...) {
3427  va_list args;
3428  object *op;
3429  int kind;
3430  object **robj;
3431 
3432  va_start(args, type);
3433 
3434  op = va_arg(args, object *);
3435  kind = va_arg(args, int);
3436  robj = va_arg(args, object **);
3437 
3438  va_end(args);
3439 
3440  if (kind == 0) {
3441  *type = CFAPI_POBJECT;
3442  *robj = object_create_clone(op);
3443  } else {
3444  object *tmp;
3445  tmp = object_new();
3446  object_copy(op, tmp);
3447  *type = CFAPI_POBJECT;
3448  *robj = tmp;
3449  }
3450  return;
3451 }
3452 
3458 static void cfapi_object_create(int *type, ...) {
3459  va_list args;
3460  int ival;
3461  object **robj;
3462  va_start(args, type);
3463  ival = va_arg(args, int);
3464 
3465  *type = CFAPI_POBJECT;
3466  switch (ival) {
3467  case 0:
3468  robj = va_arg(args, object **);
3469  *robj = object_new();
3470  break;
3471 
3472  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3473  const char *sval;
3474  archetype *at;
3475 
3476  sval = va_arg(args, const char *);
3477  robj = va_arg(args, object **);
3478  va_end(args);
3479 
3480  at = try_find_archetype(sval);
3481  if (!at)
3482  at = find_archetype_by_object_name(sval);
3483  if (at) {
3484  *robj = object_create_arch(at);
3485  } else
3486  *robj = NULL;
3487  }
3488  break;
3489 
3490  default:
3491  *type = CFAPI_NONE;
3492  break;
3493  }
3494  va_end(args);
3495 }
3496 
3497 static void cfapi_object_insert(int *type, ...) {
3498  va_list args;
3499  object *op;
3500  object *orig;
3501  mapstruct *map;
3502  int flag, x, y;
3503  int itype;
3504  object **robj;
3505 
3506  va_start(args, type);
3507 
3508  op = va_arg(args, object *);
3509  if (!op) {
3510  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3511  va_end(args);
3512  return;
3513  }
3514  if (QUERY_FLAG(op, FLAG_FREED)) {
3515  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3516  va_end(args);
3517  return;
3518  }
3519  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3520  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3521  object_remove(op);
3522  }
3523  itype = va_arg(args, int);
3524 
3525  switch (itype) {
3526  case 0:
3527  map = va_arg(args, mapstruct *);
3528  orig = va_arg(args, object *);
3529  flag = va_arg(args, int);
3530  x = va_arg(args, int);
3531  y = va_arg(args, int);
3532  robj = va_arg(args, object **);
3533  if (!map) {
3534  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3536  *robj = NULL;
3537  } else
3538  *robj = object_insert_in_map_at(op, map, orig, flag, x, y);
3539  *type = CFAPI_POBJECT;
3540  break;
3541 
3542  case 1:
3543  map = va_arg(args, mapstruct *);
3544  orig = va_arg(args, object *);
3545  flag = va_arg(args, int);
3546  robj = va_arg(args, object **);
3547  if (!map) {
3548  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3550  *robj = NULL;
3551  } else
3552  *robj = object_insert_in_map_at(op, map, orig, flag, op->x, op->y);
3553  *type = CFAPI_POBJECT;
3554  break;
3555 
3556  case 2:
3557  map = va_arg(args, mapstruct *);
3558  orig = va_arg(args, object *);
3559  flag = va_arg(args, int);
3560  x = va_arg(args, int);
3561  y = va_arg(args, int);
3562  robj = va_arg(args, object **);
3563  if (!map) {
3564  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3566  *robj = NULL;
3567  } else {
3568  int dir = object_find_free_spot(op, map, x, y, 0, SIZEOFFREE);
3569  if (dir != -1) {
3570  *robj = object_insert_in_map_at(op, map, orig, flag, x + freearr_x[dir], y + freearr_y[dir]);
3571  } else {
3573  *robj = NULL;
3574  }
3575  }
3576  *type = CFAPI_POBJECT;
3577  break;
3578 
3579  case 3:
3580  orig = va_arg(args, object *);
3581  robj = va_arg(args, object **);
3582  if (!orig) {
3583  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3585  *robj = NULL;
3586  } else
3587  *robj = object_insert_in_ob(op, orig);
3588  *type = CFAPI_POBJECT;
3589  break;
3590 
3591  default:
3592  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3594  *type = CFAPI_NONE;
3595  break;
3596  }
3597 
3598  va_end(args);
3599 }
3605 static void cfapi_object_split(int *type, ...) {
3606  va_list args;
3607 
3608  int nr, size;
3609  object *op;
3610  char *buf;
3611  object **split;
3612 
3613  va_start(args, type);
3614 
3615  op = va_arg(args, object *);
3616  nr = va_arg(args, int);
3617  buf = va_arg(args, char *);
3618  size = va_arg(args, int);
3619  split = va_arg(args, object **);
3620  va_end(args);
3621 
3622  *split = object_split(op, nr, buf, size);
3623  if (*split != NULL)
3624  {
3625  *type = CFAPI_POBJECT;
3626  }
3627  else
3628  {
3629  *type = CFAPI_NONE;
3630  }
3631 }
3632 
3638 static void cfapi_object_merge(int *type, ...) {
3639  va_list args;
3640  object *op;
3641  object *op2;
3642  object **merge;
3643 
3644  va_start(args, type);
3645 
3646  op = va_arg(args, object *);
3647  op2 = va_arg(args, object *);
3648  merge = va_arg(args, object **);
3649 
3650  va_end(args);
3651 
3652  *type = CFAPI_POBJECT;
3653  *merge = object_merge(op, op2);
3654 }
3655 
3661 static void cfapi_object_distance(int *type, ...) {
3662  va_list args;
3663  object *op;
3664  object *op2;
3665  int *rint;
3666  va_start(args, type);
3667 
3668  op = va_arg(args, object *);
3669  op2 = va_arg(args, object *);
3670  rint = va_arg(args, int *);
3671 
3672  va_end(args);
3673 
3674  *type = CFAPI_INT;
3675  *rint = object_distance(op, op2);
3676 }
3682 static void cfapi_object_update(int *type, ...) {
3683  va_list args;
3684  int action;
3685  object *op;
3686  va_start(args, type);
3687 
3688  op = va_arg(args, object *);
3689  action = va_arg(args, int);
3690 
3691  va_end(args);
3692 
3693  object_update(op, action);
3694  *type = CFAPI_NONE;
3695 }
3696 
3702 static void cfapi_object_clear(int *type, ...) {
3703  va_list args;
3704  object *op;
3705  va_start(args, type);
3706 
3707  op = va_arg(args, object *);
3708 
3709  va_end(args);
3710 
3711  object_clear(op);
3712  *type = CFAPI_NONE;
3713 }
3714 
3720 static void cfapi_object_reset(int *type, ...) {
3721  va_list args;
3722  object *op;
3723 
3724  va_start(args, type);
3725 
3726  op = va_arg(args, object *);
3727 
3728  va_end(args);
3729 
3730  object_reset(op);
3731  *type = CFAPI_NONE;
3732 }
3733 
3734 static void cfapi_object_clean_object(int *type, ...) {
3735  va_list args;
3736  object *op;
3737 
3738  va_start(args, type);
3739  op = va_arg(args, object *);
3740  clean_object(op);
3741  va_end(args);
3742  *type = CFAPI_NONE;
3743 }
3744 
3745 static void cfapi_object_on_same_map(int *type, ...) {
3746  va_list args;
3747  object *op1;
3748  object *op2;
3749  int *rint;
3750 
3751  va_start(args, type);
3752  op1 = va_arg(args, object *);
3753  op2 = va_arg(args, object *);
3754  rint = va_arg(args, int *);
3755  va_end(args);
3756 
3757  *type = CFAPI_INT;
3758  *rint = on_same_map(op1, op2);
3759 }
3760 
3761 static void cfapi_object_spring_trap(int *type, ...) {
3762  object *trap;
3763  object *victim;
3764  va_list args;
3765 
3766  va_start(args, type);
3767  trap = va_arg(args, object *);
3768  victim = va_arg(args, object *);
3769  va_end(args);
3770 
3771  spring_trap(trap, victim);
3772  *type = CFAPI_NONE;
3773 }
3774 
3780 static void cfapi_object_check_trigger(int *type, ...) {
3781  object *op;
3782  object *cause;
3783  va_list args;
3784  int *rint;
3785 
3786  va_start(args, type);
3787  op = va_arg(args, object *);
3788  cause = va_arg(args, object *);
3789  rint = va_arg(args, int *);
3790  va_end(args);
3791 
3792  *rint = check_trigger(op, cause);
3793  *type = CFAPI_INT;
3794 }
3795 
3807 static void cfapi_map_trigger_connected(int *type, ...) {
3808  objectlink *ol;
3809  object *cause;
3810  int state;
3811  va_list args;
3812 
3813  va_start(args, type);
3814  ol = va_arg(args, objectlink *);
3815  cause = va_arg(args, object *);
3816  state = va_arg(args, int);
3817  va_end(args);
3818  trigger_connected(ol, cause, state);
3819  *type = CFAPI_NONE;
3820 }
3821 
3827 static void cfapi_object_query_money(int *type, ...) {
3828  object *op;
3829  va_list args;
3830  int *rint;
3831 
3832  va_start(args, type);
3833  op = va_arg(args, object *);
3834  rint = va_arg(args, int *);
3835  va_end(args);
3836 
3837  *rint = query_money(op);
3838  *type = CFAPI_INT;
3839 }
3840 
3846 static void cfapi_object_cast(int *type, ...) {
3847  object *op;
3848  object *sp;
3849  int dir;
3850  char *str;
3851  object *caster;
3852  va_list args;
3853  int *rint;
3854 
3855  va_start(args, type);
3856  op = va_arg(args, object *);
3857  caster = va_arg(args, object *);
3858  dir = va_arg(args, int);
3859  sp = va_arg(args, object *);
3860  str = va_arg(args, char *);
3861  rint = va_arg(args, int *);
3862  va_end(args);
3863 
3864  *type = CFAPI_INT;
3865 
3866  if (!op->map) {
3867  *rint = -1;
3868  return;
3869  }
3870 
3871  *rint = cast_spell(op, caster, dir, sp, str);
3872 }
3873 
3874 static void cfapi_object_learn_spell(int *type, ...) {
3875  object *op;
3876  object *sp;
3877  int prayer;
3878  va_list args;
3879 
3880  va_start(args, type);
3881  op = va_arg(args, object *);
3882  sp = va_arg(args, object *);
3883  prayer = va_arg(args, int);
3884  va_end(args);
3885  do_learn_spell(op, sp, prayer);
3886  *type = CFAPI_NONE;
3887 }
3888 
3889 static void cfapi_object_forget_spell(int *type, ...) {
3890  object *op;
3891  object *sp;
3892  va_list args;
3893  char name[MAX_BUF];
3894 
3895  va_start(args, type);
3896  op = va_arg(args, object *);
3897  sp = va_arg(args, object *);
3898  va_end(args);
3899  query_name(sp, name, MAX_BUF);
3900  do_forget_spell(op, name);
3901  *type = CFAPI_NONE;
3902 }
3903 
3909 static void cfapi_object_check_spell(int *type, ...) {
3910  object *op;
3911  char *spellname;
3912  va_list args;
3913  object **robj;
3914 
3915  va_start(args, type);
3916  op = va_arg(args, object *);
3917  spellname = va_arg(args, char *);
3918  robj = va_arg(args, object **);
3919  va_end(args);
3920  *robj = check_spell_known(op, spellname);
3921  *type = CFAPI_POBJECT;
3922 }
3923 
3929 static void cfapi_object_pay_amount(int *type, ...) {
3930  object *op;
3931  uint64_t amount;
3932  va_list args;
3933  int *rint;
3934 
3935  va_start(args, type);
3936  op = va_arg(args, object *);
3937  amount = va_arg(args, uint64_t);
3938  rint = va_arg(args, int *);
3939  va_end(args);
3940 
3941  *rint = pay_for_amount(amount, op);
3942  *type = CFAPI_INT;
3943 }
3944 
3950 static void cfapi_object_pay_item(int *type, ...) {
3951  object *op;
3952  object *tobuy;
3953  int *rint;
3954 
3955  va_list args;
3956 
3957  va_start(args, type);
3958  tobuy = va_arg(args, object *);
3959  op = va_arg(args, object *);
3960  rint = va_arg(args, int *);
3961  va_end(args);
3962 
3963  *rint = pay_for_item(tobuy, op);
3964  *type = CFAPI_INT;
3965 }
3966 
3974 static void cfapi_object_transfer(int *type, ...) {
3975  object *op;
3976  object *originator;
3977  int x, y, randompos, ttype, flag;
3978  va_list args;
3979  mapstruct *map;
3980  int *rint;
3981  object **robj;
3982 
3983  va_start(args, type);
3984  op = va_arg(args, object *);
3985  ttype = va_arg(args, int);
3986  switch (ttype) {
3987  case 0:
3988  x = va_arg(args, int);
3989  y = va_arg(args, int);
3990  randompos = va_arg(args, int);
3991  originator = va_arg(args, object *);
3992  rint = va_arg(args, int *);
3993  va_end(args);
3994 
3995  *rint = transfer_ob(op, x, y, randompos, originator);
3996  *type = CFAPI_INT;
3997  return;
3998  break;
3999 
4000  case 1:
4001  map = va_arg(args, mapstruct *);
4002  originator = va_arg(args, object *);
4003  flag = va_arg(args, int);
4004  x = va_arg(args, int);
4005  y = va_arg(args, int);
4006  robj = va_arg(args, object **);
4007  va_end(args);
4008  if (x < 0 || y < 0) {
4009  x = map->enter_x;
4010  y = map->enter_y;
4011  }
4012  *robj = object_insert_in_map_at(op, map, originator, flag, x, y);
4013  *type = CFAPI_POBJECT;
4014  return;
4015  break;
4016 
4017  case 2:
4018  x = va_arg(args, int);
4019  y = va_arg(args, int);
4020  rint = va_arg(args, int *);
4021  va_end(args);
4022 
4023  *rint = move_to(op, x, y);
4024  *type = CFAPI_INT;
4025  return;
4026 
4027  default:
4028  va_end(args);
4029  *type = CFAPI_NONE;
4030  return;
4031  break;
4032  }
4033 }
4034 
4038 static void cfapi_object_find_archetype_inside(int *type, ...) {
4039  object *op;
4040  char *str;
4041  va_list args;
4042  object **robj;
4043 
4044  *type = CFAPI_POBJECT;
4045  va_start(args, type);
4046  op = va_arg(args, object *);
4047 
4048  str = va_arg(args, char *);
4049  robj = va_arg(args, object **);
4050  archetype *at = try_find_archetype(str);
4051  *robj = at == NULL ? NULL : arch_present_in_ob(at, op);
4052  if (*robj == NULL) {
4053  char name[MAX_BUF];
4054 
4055  /* Search by name or slaying instead */
4056  FOR_INV_PREPARE(op, tmp) {
4057  query_name(tmp, name, MAX_BUF);
4058  if (!strncmp(name, str, strlen(str)))
4059  *robj = tmp;
4060  if (!strncmp(tmp->name, str, strlen(str)))
4061  *robj = tmp;
4062  if (tmp->slaying && !strcmp(tmp->slaying, str))
4063  *robj = tmp;
4064  if (*robj != NULL)
4065  break;
4066  } FOR_INV_FINISH();
4067  }
4068  va_end(args);
4069 }
4070 
4071 static void cfapi_object_find_by_arch_name(int *type, ...) {
4072  const object *who;
4073  object **result;
4074  const char *name;
4075  va_list args;
4076 
4077  va_start(args, type);
4078  who = va_arg(args, const object *);
4079  name = va_arg(args, const char *);
4080  result = va_arg(args, object **);
4081  va_end(args);
4082  *type = CFAPI_POBJECT;
4083 
4084  *result = object_find_by_arch_name(who, name);
4085 }
4086 
4087 static void cfapi_object_find_by_name(int *type, ...) {
4088  const object *who;
4089  object **result;
4090  const char *name;
4091  va_list args;
4092 
4093  va_start(args, type);
4094  who = va_arg(args, const object *);
4095  name = va_arg(args, const char *);
4096  result = va_arg(args, object **);
4097  va_end(args);
4098  *type = CFAPI_POBJECT;
4099 
4100  *result = object_find_by_name(who, name);
4101 }
4102 
4108 static void cfapi_object_drop(int *type, ...) {
4109  object *op;
4110  object *author;
4111  va_list args;
4112 
4113  va_start(args, type);
4114  op = va_arg(args, object *);
4115  author = va_arg(args, object *);
4116  va_end(args);
4117  *type = CFAPI_NONE;
4118 
4119  if (QUERY_FLAG(op, FLAG_NO_DROP))
4120  return;
4121  drop(author, op);
4122 
4123  if (author->type == PLAYER) {
4124  author->contr->count = 0;
4125  author->contr->socket.update_look = 1;
4126  }
4127 }
4128 
4132 static void cfapi_object_change_abil(int *type, ...) {
4133  object *op, *tmp;
4134  int *rint;
4135  va_list args;
4136 
4137  va_start(args, type);
4138  op = va_arg(args, object *);
4139  tmp = va_arg(args, object *);
4140  rint = va_arg(args, int *);
4141  va_end(args);
4142 
4143  *type = CFAPI_INT;
4144  *rint = change_abil(op, tmp);
4145 }
4146 
4147 static void cfapi_object_say(int *type, ...) {
4148  object *op;
4149  char *msg;
4150  va_list args;
4151  int *rint;
4152  char empty[] = "";
4153 
4154  va_start(args, type);
4155  op = va_arg(args, object *);
4156  msg = va_arg(args, char *);
4157  rint = va_arg(args, int *);
4158  va_end(args);
4159 
4160  if (op->type == PLAYER) {
4161  command_say(op, msg == NULL ? empty : msg);
4162  } else {
4163  monster_npc_say(op, msg);
4164  }
4165  *rint = 0;
4166  *type = CFAPI_INT;
4167 }
4168 
4169 /* PLAYER SUBCLASS */
4170 
4176 static void cfapi_player_find(int *type, ...) {
4177  va_list args;
4178  char *sval;
4179  player **rpl;
4180  va_start(args, type);
4181 
4182  sval = va_arg(args, char *);
4183  rpl = va_arg(args, player **);
4184  va_end(args);
4185 
4186  *rpl = find_player_partial_name(sval);
4187 
4188  *type = CFAPI_PPLAYER;
4189 }
4190 
4191 static void cfapi_player_message(int *type, ...) {
4192  va_list args;
4193  int flags;
4194  int pri;
4195  object *pl;
4196  char *buf;
4197 
4198  va_start(args, type);
4199 
4200  flags = va_arg(args, int);
4201  pri = va_arg(args, int);
4202  pl = va_arg(args, object *);
4203  buf = va_arg(args, char *);
4204  va_end(args);
4205 
4206  draw_ext_info(flags, pri, pl, MSG_TYPE_MISC, MSG_SUBTYPE_NONE,
4207  buf);
4208  *type = CFAPI_NONE;
4209 }
4210 
4217 static void cfapi_object_perm_exp(int *type, ...) {
4218  va_list args;
4219  object *op;
4220  int64_t *rlong;
4221 
4222  va_start(args, type);
4223  op = va_arg(args, object *);
4224  rlong = va_arg(args, int64_t *);
4225  va_end(args);
4226 
4227  *type = CFAPI_SINT64;
4228  *rlong = PERM_EXP(op->total_exp);
4229 }
4230 
4236 static void cfapi_object_change_exp(int *type, ...) {
4237  va_list args;
4238  int flag;
4239  object *ob;
4240  const char *skill;
4241  int64_t exp;
4242 
4243  va_start(args, type);
4244  ob = va_arg(args, object *);
4245  exp = va_arg(args, int64_t);
4246  skill = va_arg(args, const char *);
4247  flag = va_arg(args, int);
4248  va_end(args);
4249 
4250  *type = CFAPI_NONE;
4251  change_exp(ob, exp, skill, flag);
4252 }
4253 
4259 static void cfapi_player_can_pay(int *type, ...) {
4260  va_list args;
4261  object *pl;
4262  int *rint;
4263 
4264  va_start(args, type);
4265  pl = va_arg(args, object *);
4266  rint = va_arg(args, int *);
4267  va_end(args);
4268 
4269  *rint = can_pay(pl);
4270  *type = CFAPI_INT;
4271 }
4272 
4278 static void cfapi_player_knowledge(int *type, ...) {
4279  va_list args;
4280  object *pl;
4281  int *rint, what;
4282  const char *knowledge;
4283 
4284  va_start(args, type);
4285  what = va_arg(args, int);
4286 
4287  switch(what)
4288  {
4289  case 1:
4290  pl = va_arg(args, object *);
4291  knowledge = va_arg(args, const char *);
4292  rint = va_arg(args, int *);
4293 
4294  *type = CFAPI_INT;
4295 
4296  if (pl->contr == NULL) {
4297  LOG(llevError, "cfapi_player_knowledge: 'has' called for non player object %s", pl->name);
4298  *rint = 0;
4299  va_end(args);
4300  return;
4301  }
4302 
4303  *rint = knowledge_player_knows(pl->contr, knowledge);
4304  break;
4305 
4306  case 2:
4307  pl = va_arg(args, object *);
4308  knowledge = va_arg(args, const char *);
4309  *type = CFAPI_NONE;
4310  if (pl->contr != NULL)
4311  knowledge_give(pl->contr, knowledge, NULL);
4312 
4313  break;
4314 
4315  default:
4316  LOG(llevError, "cfapi_player_knowledge: invalid what %d", what);
4317  }
4318 
4319  va_end(args);
4320 }
4321 
4327 static void cfapi_object_teleport(int *type, ...) {
4328  mapstruct *map;
4329  int x, y;
4330  object *who;
4331  int *res;
4332  va_list args;
4333 
4334  va_start(args, type);
4335  who = va_arg(args, object *);
4336  map = va_arg(args, mapstruct *);
4337  x = va_arg(args, int);
4338  y = va_arg(args, int);
4339  res = va_arg(args, int *);
4340  *type = CFAPI_INT;
4341 
4342  if (!out_of_map(map, x, y)) {
4343  int k;
4344  k = object_find_first_free_spot(who, map, x, y);
4345  if (k == -1) {
4346  *res = 1;
4347  va_end(args);
4348  return;
4349  }
4350 
4351  if (!QUERY_FLAG(who, FLAG_REMOVED)) {
4352  object_remove(who);
4353  }
4354 
4355  object_insert_in_map_at(who, map, NULL, 0, x, y);
4356  if (who->type == PLAYER) {
4357  map_newmap_cmd(&who->contr->socket);
4359  }
4360  *res = 0;
4361  }
4362 
4363  va_end(args);
4364 }
4365 
4366 static void cfapi_object_pickup(int *type, ...) {
4367  object *who;
4368  object *what;
4369  va_list args;
4370 
4371  va_start(args, type);
4372  who = va_arg(args, object *);
4373  what = va_arg(args, object *);
4374  va_end(args);
4375 
4376  pick_up(who, what);
4377  *type = CFAPI_NONE;
4378 }
4379 
4380 /* Archetype-related functions */
4381 static void cfapi_archetype_get_property(int *type, ...) {
4382  int prop;
4383  archetype *arch;
4384  va_list args;
4385  sstring *rsstring;
4386  archetype **rarch;
4387  object **robject;
4388 
4389  va_start(args, type);
4390  arch = va_arg(args, archetype *);
4391  prop = va_arg(args, int);
4392  switch (prop) {
4393  case CFAPI_ARCH_PROP_NAME:
4394  *type = CFAPI_SSTRING;
4395  rsstring = va_arg(args, sstring *);
4396  *rsstring = arch->name;
4397  break;
4398 
4399  case CFAPI_ARCH_PROP_NEXT:
4400  *type = CFAPI_PARCH;
4401  rarch = va_arg(args, archetype **);
4402  *rarch = arch ? arch->next : first_archetype;
4403  break;
4404 
4405  case CFAPI_ARCH_PROP_HEAD:
4406  *type = CFAPI_PARCH;
4407  rarch = va_arg(args, archetype **);
4408  *rarch = arch->head;
4409  break;
4410 
4411  case CFAPI_ARCH_PROP_MORE:
4412  *type = CFAPI_PARCH;
4413  rarch = va_arg(args, archetype **);
4414  *rarch = arch->more;
4415  break;
4416 
4417  case CFAPI_ARCH_PROP_CLONE:
4418  *type = CFAPI_POBJECT;
4419  robject = va_arg(args, object **);
4420  *robject = &arch->clone;
4421  break;
4422 
4423  default:
4424  *type = CFAPI_NONE;
4425  break;
4426  }
4427  va_end(args);
4428 }
4429 
4436 static void cfapi_party_get_property(int *type, ...) {
4437  partylist *party;
4438  int prop;
4439  va_list args;
4440  object *obarg;
4441  sstring *rsstring;
4442  player **rplayer;
4443  partylist **rparty;
4444 
4445  va_start(args, type);
4446  party = va_arg(args, partylist *);
4447  prop = va_arg(args, int);
4448  switch (prop) {
4449  case CFAPI_PARTY_PROP_NAME:
4450  rsstring = va_arg(args, sstring *);
4451  *rsstring = party->partyname;
4452  *type = CFAPI_SSTRING;
4453  break;
4454 
4455  case CFAPI_PARTY_PROP_NEXT:
4456  rparty = va_arg(args, partylist **);
4457  *rparty = (party ? party_get_next(party) : party_get_first());
4458  *type = CFAPI_PPARTY;
4459  break;
4460 
4462  rsstring = va_arg(args, sstring *);
4463  *rsstring = party_get_password(party);
4464  *type = CFAPI_SSTRING;
4465  break;
4466 
4468  *type = CFAPI_PPLAYER;
4469  obarg = va_arg(args, object *);
4470  rplayer = va_arg(args, player **);
4471  *rplayer = (obarg ? obarg->contr : first_player);
4472  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4473  if ((*rplayer)->ob->contr->party == party) {
4474  break;
4475  }
4476  break;
4477 
4478  default:
4479  *type = CFAPI_NONE;
4480  break;
4481  }
4482  va_end(args);
4483 }
4484 
4491 static void cfapi_region_get_property(int *type, ...) {
4492  region *reg;
4493  int prop, *rint;
4494  va_list args;
4496  sstring *rsstring;
4497  region **rregion;
4498 
4499  va_start(args, type);
4500  reg = va_arg(args, region *);
4501  prop = va_arg(args, int);
4502  switch (prop) {
4504  rsstring = va_arg(args, sstring *);
4505  *rsstring = reg->name;
4506  *type = CFAPI_SSTRING;
4507  break;
4508 
4510  rregion = va_arg(args, region **);
4511  *rregion = (reg ? reg->next : first_region);
4512  *type = CFAPI_PREGION;
4513  break;
4514 
4516  rregion = va_arg(args, region **);
4517  *rregion = reg->parent;
4518  *type = CFAPI_PREGION;
4519  break;
4520 
4522  rsstring = va_arg(args, sstring *);
4523  *rsstring = reg->longname;
4524  *type = CFAPI_SSTRING;
4525  break;
4526 
4528  rsstring = va_arg(args, sstring *);
4529  *rsstring = reg->msg;
4530  *type = CFAPI_SSTRING;
4531  break;
4532 
4535  rint = va_arg(args, int*);
4536  *rint = (prop == CFAPI_REGION_PROP_JAIL_X ? reg->jailx : reg->jaily);
4537  *type = CFAPI_INT;
4538  break;
4539 
4541  rsstring = va_arg(args, sstring *);
4542  *rsstring = reg->jailmap;
4543  *type = CFAPI_SSTRING;
4544  break;
4545 
4546  default:
4547  *type = CFAPI_NONE;
4548  break;
4549  }
4550  va_end(args);
4551 }
4552 
4564 static void cfapi_friendlylist_get_next(int *type, ...) {
4565  object *ob;
4566  va_list args;
4567  objectlink *link;
4568  object **robject;
4569 
4570  va_start(args, type);
4571  ob = va_arg(args, object *);
4572  robject = va_arg(args, object **);
4573  va_end(args);
4574 
4575  *type = CFAPI_POBJECT;
4576  *robject = NULL;
4577 
4578  if (ob) {
4579  for (link = first_friendly_object; link; link = link->next) {
4580  if (ob == link->ob) {
4581  if (link->next) {
4582  *robject = link->next->ob;
4583  return;
4584  } else {
4585  return;
4586  }
4587  }
4588  }
4589  return;
4590  }
4591 
4593  *robject = first_friendly_object->ob;
4594 }
4595 
4596 /*
4597  * Random-map related stuff.
4598  */
4599 
4606 static void cfapi_set_random_map_variable(int *type, ...) {
4607  va_list args;
4608  RMParms *rp;
4609  const char *buf;
4610  int *ret;
4611 
4612  va_start(args, type);
4613  rp = va_arg(args, RMParms *);
4614  buf = va_arg(args, const char *);
4615  ret = va_arg(args, int *);
4616  va_end(args);
4617 
4618  *ret = set_random_map_variable(rp, buf);
4619  *type = CFAPI_INT;
4620 }
4621 
4628 static void cfapi_generate_random_map(int *type, ...) {
4629  va_list args;
4630  const char *name;
4631  RMParms *rp;
4632  char **use_layout;
4633  mapstruct **ret;
4634 
4635  va_start(args, type);
4636  name = va_arg(args, const char *);
4637  rp = va_arg(args, RMParms *);
4638  use_layout = va_arg(args, char **);
4639  ret = va_arg(args, mapstruct **);
4640  va_end(args);
4641 
4642  *ret = generate_random_map(name, rp, use_layout);
4643 }
4644 
4645 static void cfapi_object_user_event(int *type, ...) {
4646  object *op;
4647  object *activator;
4648  object *third;
4649  const char *message;
4650  int fix;
4651  int *ret;
4652  va_list args;
4653 
4654  va_start(args, type);
4655  op = va_arg(args, object *);
4656  activator = va_arg(args, object *);
4657  third = va_arg(args, object *);
4658  message = va_arg(args, const char *);
4659  fix = va_arg(args, int);
4660  ret = va_arg(args, int *);
4661  va_end(args);
4662 
4663  *ret = user_event(op, activator, third, message, fix);
4664  *type = CFAPI_INT;
4665 }
4666 
4669 static void cfapi_player_quest(int *type, ...) {
4670  int op;
4671  va_list args;
4672  object *player;
4673  sstring code;
4674 
4675  va_start(args, type);
4676  op = va_arg(args, int);
4677  player = va_arg(args, object *);
4678  code = va_arg(args, sstring);
4679 
4680  if (player->contr == NULL) {
4681  LOG(llevError, "cfapi_player_quest called with non player object %s!\n", player->name);
4682  va_end(args);
4683  /* crash/quit? */
4684  return;
4685  }
4686 
4687  switch(op) {
4688  case CFAPI_PLAYER_QUEST_START: {
4689  int state = va_arg(args, int);
4690  quest_start(player->contr, code, state);
4691  *type = CFAPI_NONE;
4692  break;
4693  }
4695  int *ret = va_arg(args, int *);
4696  *ret = quest_get_player_state(player->contr, code);
4697  *type = CFAPI_INT;
4698  break;
4699  }
4701  int state = va_arg(args, int);
4702  quest_set_player_state(player->contr, code, state);
4703  *type = CFAPI_NONE;
4704  break;
4705  }
4707  int *ret = va_arg(args, int*);
4708  *ret = quest_was_completed(player->contr, code);
4709  *type = CFAPI_INT;
4710  break;
4711  }
4712  default:
4713  LOG(llevError, "invalid quest type: %d\n", op);
4714  *type = CFAPI_NONE;
4715  }
4716 
4717  va_end(args);
4718 }
4719 
4720 /*****************************************************************************/
4721 /* NEW PLUGIN STUFF ENDS HERE */
4722 /*****************************************************************************/
4723 
4724 
4737  int i;
4738  crossfire_plugin *cp;
4739 
4740  assert(cmd != NULL);
4741  assert(command != NULL);
4742 
4743  if (plugins_list == NULL)
4744  return NULL;
4745 
4746  for (cp = plugins_list; cp != NULL; cp = cp->next) {
4747  if (cp->propfunc(&i, "command?", cmd, command) != NULL)
4748  return command;
4749  }
4750  return NULL;
4751 }
4752 
4757 void initPlugins(void) {
4758  struct dirent *currentfile;
4759  DIR *plugdir;
4760  size_t l;
4761  char buf[MAX_BUF];
4762 
4763  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4764  LOG(llevDebug, "plugins: loading from %s\n", buf);
4765 
4766  plugdir = opendir(buf);
4767  if (plugdir == NULL)
4768  return;
4769 
4770  while ((currentfile = readdir(plugdir)) != NULL) {
4771  l = strlen(currentfile->d_name);
4772  if (l > strlen(PLUGIN_SUFFIX)) {
4774  int ignore = 0;
4775 
4776  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) != 0)
4777  continue;
4778 
4779  while (disable) {
4780  if (strcmp(disable->name, "All") == 0) {
4781  LOG(llevInfo, "plugins: disabling (all) %s\n", currentfile->d_name);
4782  ignore = 1;
4783  break;
4784  }
4785  if (strncmp(disable->name, currentfile->d_name, strlen(disable->name)) == 0 && strlen(currentfile->d_name) == strlen(PLUGIN_SUFFIX) + strlen(disable->name)) {
4786  LOG(llevInfo, "plugins: disabling %s\n", currentfile->d_name);
4787  ignore = 1;
4788  break;
4789  }
4790  disable = disable->next;
4791  }
4792  if (ignore == 0) {
4793  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4794  LOG(llevInfo, "plugins: loading %s\n", currentfile->d_name);
4795  plugins_init_plugin(buf);
4796  }
4797  }
4798  }
4799 
4800  closedir(plugdir);
4801 }
4802 
4807 void cleanupPlugins(void) {
4808  crossfire_plugin *cp;
4809 
4810  if (!plugins_list)
4811  return;
4812 
4813  for (cp = plugins_list; cp != NULL; ) {
4814  crossfire_plugin *next = cp->next;
4815  if (cp->closefunc)
4816  cp->closefunc();
4817  /* Don't actually unload plugins, it makes backtraces for memory
4818  * debugging (printed at exit) messed up. And it doesn't matter if we
4819  * don't free it here. The OS will do it for us.
4820  */
4821  /* plugins_dlclose(cp->libptr); */
4822  free(cp);
4823  cp = next;
4824  }
4825  plugins_list = NULL;
4826 }
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:248
#define CFAPI_OBJECT_PROP_MAP
Definition: plugin.h:179
#define CFAPI_OBJECT_PROP_RUN_AWAY
Definition: plugin.h:225
static void cfapi_object_clear(int *type,...)
Definition: plugins.c:3702
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:3602
void spring_trap(object *trap, object *victim)
Definition: rune.c:205
static void cfapi_map_trigger_connected(int *type,...)
Definition: plugins.c:3807
static void copy_message(object *op, const char *msg)
Definition: plugins.c:2526
static void cfapi_set_random_map_variable(int *type,...)
Definition: plugins.c:4606
char path[HUGE_BUF]
Definition: map.h:365
#define CFAPI_OBJECT_PROP_MAGIC
Definition: plugin.h:206
void apply_by_living_below(object *pl)
Definition: apply.c:709
#define CFAPI_PLAYER_QUEST_GET_STATE
Definition: plugin.h:291
#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:322
Definition: player.h:92
int apply_manual(object *op, object *tmp, int aflag)
Definition: apply.c:605
#define CFAPI_OBJECT_PROP_MATERIAL
Definition: plugin.h:204
const char * determine_god(object *op)
Definition: gods.c:106
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:269
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:258
int32_t weight_limit
Definition: object.h:367
#define UP_OBJ_FACE
Definition: object.h:519
#define CFAPI_OBJECT_PROP_CARRYING
Definition: plugin.h:219
MoveType move_type
Definition: object.h:426
#define plugins_dlopen(fname)
Definition: plugin.h:163
#define EVENT_REMOVE
Definition: plugin.h:93
#define CFAPI_OBJECT_PROP_NAME
Definition: plugin.h:181
#define CFAPI_OBJECT_PROP_OB_BELOW
Definition: plugin.h:172
#define CFAPI_PREGION
Definition: plugin.h:117
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:288
#define EVENT_SHOUT
Definition: plugin.h:94
#define CFAPI_MAP_PROP_NAME
Definition: plugin.h:299
int16_t jaily
Definition: map.h:298
void object_free(object *ob, int flags)
Definition: object.c:1411
int move_player(object *op, int dir)
Definition: player.c:3014
MoveType move_on
Definition: object.h:429
static void cfapi_object_drain(int *type,...)
Definition: plugins.c:3291
static void cfapi_system_register_global_event(int *type,...)
Definition: plugins.c:853
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:1629
#define CFAPI_OBJECT_PROP_RACE
Definition: plugin.h:184
object * check_spell_known(object *op, const char *name)
Definition: spell_util.c:433
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:308
static void cfapi_object_check_spell(int *type,...)
Definition: plugins.c:3909
Definition: object.h:444
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:329
const char * race
Definition: object.h:318
#define P_NEED_UPDATE
Definition: map.h:239
int is_magical(const object *op)
Definition: item.c:1238
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:295
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:304
#define CFAPI_OBJECT_PROP_ARCHETYPE
Definition: plugin.h:232
#define CFAPI_OBJECT_PROP_WEIGHT
Definition: plugin.h:217
static void cfapi_get_month_name(int *type,...)
Definition: plugins.c:1101
uint16_t attack_movement
Definition: object.h:393
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:200
static void cfapi_object_pickup(int *type,...)
Definition: plugins.c:4366
#define CFAPI_OBJECT_PROP_FACE
Definition: plugin.h:268
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.c:869
static void cfapi_archetype_get_property(int *type,...)
Definition: plugins.c:4381
static void cfapi_object_pay_amount(int *type,...)
Definition: plugins.c:3929
#define SET_FLAG(xyz, p)
Definition: define.h:223
#define NR_OF_HOOKS
Definition: plugins.c:43
#define EVENT_KICK
Definition: plugin.h:97
void do_forget_spell(object *op, const char *spell)
Definition: apply.c:527
MoveType move_allow
Definition: object.h:428
int16_t bed_x
Definition: player.h:98
linked_char * disabled_plugins
Definition: global.h:329
static void cfapi_object_get_property(int *type,...)
Definition: plugins.c:1724
#define plugins_dlsym(lib, name)
Definition: plugin.h:165
#define CFAPI_FUNC
Definition: plugin.h:114
#define PLUGIN_SUFFIX
Definition: win32.h:106
static void cfapi_object_spring_trap(int *type,...)
Definition: plugins.c:3761
New_Face * new_faces
Definition: image.c:33
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:265
#define CFAPI_OBJECT_PROP_PICK_UP
Definition: plugin.h:214
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:296
void player_get_title(const struct pl *pl, char *buf, size_t bufsize)
Definition: player.c:224
uint16_t animation_id
Definition: object.h:418
#define CFAPI_MAP_PROP_HEIGHT
Definition: plugin.h:306
uint16_t material
Definition: object.h:348
#define CFAPI_OBJECT_PROP_DIRECTION
Definition: plugin.h:194
const char * name
Definition: face.h:27
#define strdup_local
Definition: compat.h:25
uint8_t anim_speed
Definition: object.h:419
object * object_get_env_recursive(object *op)
Definition: object.c:366
EXTERN objectlink * first_friendly_object
Definition: global.h:123
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
Definition: plugin.h:173
struct obj * container
Definition: object.h:291
#define CFAPI_OBJECT_PROP_MAXGP
Definition: plugin.h:263
#define EVENT_LOGIN
Definition: plugin.h:88
int player_arrest(object *who)
Definition: c_wiz.c:797
#define CFAPI_OBJECT_PROP_HIDDEN
Definition: plugin.h:227
static void cfapi_region_get_property(int *type,...)
Definition: plugins.c:4491
static void cfapi_object_on_same_map(int *type,...)
Definition: plugins.c:3745
static void cfapi_system_find_face(int *type,...)
Definition: plugins.c:818
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:3344
#define CFAPI_OBJECT_PROP_MOVE_STATUS
Definition: plugin.h:228
const char * get_season_name(const int index)
Definition: time.c:123
int pay_for_item(object *op, object *pl)
Definition: shop.c:552
char * create_pathname(const char *name, char *buf, size_t size)
Definition: map.c:112
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:1821
const char * playerdir
Definition: global.h:250
unsigned char MoveType
Definition: define.h:432
int32_t last_heal
Definition: object.h:358
#define CFAPI_OBJECT_PROP_SUBTYPE
Definition: plugin.h:197
partylist * party_get_next(const partylist *party)
Definition: party.c:230
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:344
#define TIMER_ERR_ID
Definition: timers.h:67
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:330
static void cfapi_get_periodofday_name(int *type,...)
Definition: plugins.c:1113
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:317
#define SET_ANIMATION(ob, newanim)
Definition: global.h:169
static void cfapi_object_find_by_arch_name(int *type,...)
Definition: plugins.c:4071
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
Definition: map.c:2386
#define NR_EVENTS
Definition: plugin.h:100
#define EVENT_MAPLEAVE
Definition: plugin.h:91
void esrv_update_item(int flags, object *pl, object *op)
Definition: main.c:343
#define CFAPI_OBJECT_PROP_CONTAINER
Definition: plugin.h:178
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4299
#define CFAPI_INT16
Definition: plugin.h:118
void pick_up(object *op, object *alt)
Definition: c_object.c:460
f_plug_api func
Definition: plugin.h:351
#define CFAPI_OBJECT_PROP_INVENTORY
Definition: plugin.h:175
void query_base_name(const object *op, int plural, char *buf, size_t size)
Definition: item.c:723
struct pl player
static void cfapi_object_set_property(int *type,...)
Definition: plugins.c:2559
object clone
Definition: object.h:472
int16_t duration
Definition: object.h:405
#define CFAPI_OBJECT_PROP_FLAGS
Definition: plugin.h:247
static void cfapi_get_season_name(int *type,...)
Definition: plugins.c:1077
socket_struct socket
Definition: player.h:94
int16_t invisible
Definition: object.h:361
short freearr_x[SIZEOFFREE]
Definition: object.c:65
#define EVENT_LOGOUT
Definition: plugin.h:89
uint32_t reset_time
Definition: map.h:332
int calculate_difficulty(mapstruct *m)
Definition: map.c:1931
#define CFAPI_SINT64
Definition: plugin.h:120
#define CFAPI_OBJECT_PROP_NAME_PLURAL
Definition: plugin.h:182
static void cfapi_log(int *type,...)
Definition: plugins.c:1180
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:4038
DIR * opendir(const char *)
Definition: win32.c:37
int32_t last_sp
Definition: object.h:359
#define CFAPI_OBJECT_PROP_OWNER
Definition: plugin.h:242
static void cfapi_object_teleport(int *type,...)
Definition: plugins.c:4327
static void cfapi_system_re_cmp(int *type,...)
Definition: plugins.c:975
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:254
uint8_t subtype
Definition: object.h:340
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:274
static void cfapi_map_get_map_property(int *type,...)
Definition: plugins.c:1307
uint8_t hide
Definition: object.h:389
int64_t exp
Definition: living.h:47
#define CFAPI_OBJECT_PROP_MESSAGE
Definition: plugin.h:187
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:533
static void cfapi_map_delete_map(int *type,...)
Definition: plugins.c:1507
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER
Definition: plugin.h:231
struct obj * above
Definition: object.h:288
double expmul
Definition: object.h:397
#define plugins_dlclose(lib)
Definition: plugin.h:164
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:301
#define object_was_destroyed(op, old_tag)
Definition: object.h:68
char id[MAX_BUF]
Definition: plugin.h:148
void initPlugins(void)
Definition: plugins.c:4757
object * arch_present_in_ob(const archetype *at, const object *op)
Definition: object.c:3079
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:290
#define CFAPI_DOUBLE
Definition: plugin.h:112
static void cfapi_object_insert(int *type,...)
Definition: plugins.c:3497
void remove_friendly_object(object *op)
Definition: friend.c:56
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:326
uint32_t path_attuned
Definition: object.h:344
void object_update(object *op, int action)
Definition: object.c:1262
static void cfapi_object_drop(int *type,...)
Definition: plugins.c:4108
static void cfapi_object_fix(int *type,...)
Definition: plugins.c:3328
int16_t sp
Definition: living.h:42
static void cfapi_map_set_map_property(int *type,...)
Definition: plugins.c:1439
#define EVENT_TELL
Definition: plugin.h:95
static void cfapi_object_set_key(int *type,...)
Definition: plugins.c:1701
#define EVENT_CRASH
Definition: plugin.h:85
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:310
static void cfapi_party_get_property(int *type,...)
Definition: plugins.c:4436
int object_can_merge(object *ob1, object *ob2)
Definition: object.c:202
#define CFAPI_OBJECT_PROP_SLAYING
Definition: plugin.h:185
static void cfapi_map_create_path(int *type,...)
Definition: plugins.c:1273
int plugin_event_say(object *npc, talk_info *talk)
Definition: plugins.c:381
Definition: win32.h:110
uint32_t path_repelled
Definition: object.h:345
#define safe_strncpy
Definition: compat.h:23
#define SCRIPT_FIX_ALL
Definition: global.h:368
void free_dialog_information(object *op)
Definition: dialog.c:32
char * partyname
Definition: party.h:14
struct obj * enemy
Definition: object.h:383
struct archt * other_arch
Definition: object.h:415
static void cfapi_system_find_string(int *type,...)
Definition: plugins.c:933
object * object_find_by_name(const object *who, const char *name)
Definition: object.c:3900
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:110
static void cfapi_object_apply_below(int *type,...)
Definition: plugins.c:3204
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:1128
Definition: plugin.h:350
char * host
Definition: newserver.h:100
static void cfapi_player_quest(int *type,...)
Definition: plugins.c:4669
#define CFAPI_POBJECT
Definition: plugin.h:109
static void cfapi_object_split(int *type,...)
Definition: plugins.c:3605
#define CFAPI_OBJECT_PROP_CHOSEN_SKILL
Definition: plugin.h:226
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:233
int16_t maxsp
Definition: living.h:43
#define CFAPI_OBJECT_PROP_LAST_SP
Definition: plugin.h:210
int8_t Con
Definition: living.h:36
int change_map_light(mapstruct *m, int change)
Definition: map.c:2013
#define CFAPI_REGION_PROP_JAIL_PATH
Definition: plugin.h:332
#define FLAG_REMOVED
Definition: define.h:232
static void cfapi_object_delete(int *type,...)
Definition: plugins.c:3399
int16_t hp
Definition: living.h:40
#define CFAPI_OBJECT_PROP_LAST_GRACE
Definition: plugin.h:211
static void cfapi_object_find_by_name(int *type,...)
Definition: plugins.c:4087
#define CFAPI_OBJECT_PROP_COUNT
Definition: plugin.h:180
short freearr_y[SIZEOFFREE]
Definition: object.c:71
partylist * party
Definition: player.h:186
static void cfapi_object_remove(int *type,...)
Definition: plugins.c:3378
#define CFAPI_NONE
Definition: plugin.h:104
#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:3361
const char * get_month_name(const int index)
Definition: time.c:109
#define CFAPI_FLOAT
Definition: plugin.h:111
void map_newmap_cmd(socket_struct *ns)
Definition: request.c:618
int64_t total_exp
Definition: object.h:371
struct _crossfire_plugin * next
Definition: plugin.h:151
void object_set_owner(object *op, object *owner)
Definition: object.c:634
#define CFAPI_PLAYER_PROP_BED_X
Definition: plugin.h:285
char * name
Definition: map.h:328
#define CFAPI_PARCH
Definition: plugin.h:113
const char * lore
Definition: object.h:323
static void cfapi_object_identify(int *type,...)
Definition: plugins.c:3249
struct obj * chosen_skill
Definition: object.h:388
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:4428
uint32_t update_look
Definition: newserver.h:104
void object_free_drop_inventory(object *ob)
Definition: object.c:1391
int change_abil(object *op, object *tmp)
Definition: living.c:395
const char * name
Definition: face.h:20
const char * title
Definition: object.h:317
int16_t y
Definition: object.h:326
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.c:1935
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:302
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:195
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:4147
#define EVENT_MAPENTER
Definition: plugin.h:90
static void cfapi_system_remove_string(int *type,...)
Definition: plugins.c:915
uint32_t path_denied
Definition: object.h:346
static void cfapi_object_change_exp(int *type,...)
Definition: plugins.c:4236
#define CFAPI_PLAYER_PROP_IP
Definition: plugin.h:281
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:176
Definition: win32.h:120
static void cfapi_object_merge(int *type,...)
Definition: plugins.c:3638
#define CFAPI_OBJECT_PROP_GP
Definition: plugin.h:259
LIBPTRTYPE libptr
Definition: plugin.h:147
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:254
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:323
object * object_new(void)
Definition: object.c:1070
const char * name_pl
Definition: object.h:315
static void cfapi_player_knowledge(int *type,...)
Definition: plugins.c:4278
#define LIBDIR
Definition: win32.h:99
#define CFAPI_OBJECT_PROP_ATTACKED_BY
Definition: plugin.h:224
#define CFAPI_STRING
Definition: plugin.h:108
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:3811
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2709
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
Definition: plugin.h:277
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:312
float speed_left
Definition: object.h:329
int knowledge_player_knows(const player *pl, const char *knowledge)
Definition: knowledge.c:1303
void *(* f_plug_property)(int *type,...)
Definition: plugin.h:133
#define CFAPI_OBJECT_PROP_INT
Definition: plugin.h:252
signed short int16_t
Definition: win32.h:160
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:300
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:316
void monster_npc_say(object *npc, const char *cp)
Definition: monster.c:2304
static void cfapi_timer_destroy(int *type,...)
Definition: plugins.c:1161
const char * materialname
Definition: object.h:347
int16_t enter_x
Definition: map.h:348
int32_t weight
Definition: object.h:366
uint32_t unique
Definition: map.h:337
#define CFAPI_OBJECT_PROP_LEVEL
Definition: plugin.h:208
#define FOR_ABOVE_FINISH()
Definition: define.h:732
void update_all_los(const mapstruct *map, int x, int y)
Definition: los.c:536
const char * tmpdir
Definition: global.h:257
int8_t Wis
Definition: living.h:36
const char * text
Definition: dialog.h:53
#define CFAPI_OBJECT_PROP_HEAD
Definition: plugin.h:177
#define CFAPI_PLAYER_PROP_BED_MAP
Definition: plugin.h:284
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:273
static void cfapi_player_message(int *type,...)
Definition: plugins.c:4191
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:279
#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:4645
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:315
f_plug_postinit closefunc
Definition: plugin.h:146
#define PERM_EXP(exptotal)
Definition: global.h:235
struct linked_char * next
Definition: global.h:88
int plugins_init_plugin(const char *libfile)
Definition: plugins.c:613
uint64_t query_money(const object *op)
Definition: shop.c:482
int(* f_plug_postinit)(void)
Definition: plugin.h:127
#define FOR_INV_FINISH()
Definition: define.h:715
char * msg
Definition: map.h:361
void update_position(mapstruct *m, int x, int y)
Definition: map.c:2137
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:260
int32_t carrying
Definition: object.h:368
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:725
#define CFAPI_OBJECT_PROP_MAGICAL
Definition: plugin.h:239
int8_t gen_sp_armour
Definition: object.h:364
static void cfapi_map_find_by_archetype_name(int *type,...)
Definition: plugins.c:1571
#define LIBPTRTYPE
Definition: plugin.h:136
uint8_t state
Definition: object.h:350
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:3950
archetype * find_archetype_by_object_name(const char *name)
Definition: arch.c:57
#define CFAPI_OBJECT_PROP_LAST_EAT
Definition: plugin.h:212
object * object_present_in_ob(uint8_t type, const object *op)
Definition: object.c:3019
void trigger_connected(objectlink *ol, object *cause, const int state)
Definition: button.c:41
int16_t last_grace
Definition: object.h:360
const char * re_cmp(const char *, const char *)
Definition: re-cmp.c:69
void object_reset(object *op)
Definition: object.c:737
int pay_for_amount(uint64_t to_pay, object *pl)
Definition: shop.c:513
#define CFAPI_OBJECT_PROP_MOVE_OFF
Definition: plugin.h:275
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:218
#define CFAPI_PLAYER_QUEST_SET_STATE
Definition: plugin.h:292
struct obj * current_weapon
Definition: object.h:372
int8_t direction
Definition: object.h:335
#define CFAPI_LONG
Definition: plugin.h:106
object * object_create_clone(object *asrc)
Definition: object.c:3853
uint32_t nrof
Definition: object.h:333
#define string_get_int(name)
Definition: plugins.c:1058
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON
Definition: plugin.h:222
#define CFAPI_SSTRING
Definition: plugin.h:121
int8_t Cha
Definition: living.h:36
struct archt * head
Definition: object.h:470
int find_animation(const char *name)
Definition: anim.c:171
static void cfapi_player_can_pay(int *type,...)
Definition: plugins.c:4259
static void cfapi_system_check_path(int *type,...)
Definition: plugins.c:952
#define CFAPI_PPLAYER
Definition: plugin.h:115
#define SIZEOFFREE
Definition: define.h:154
#define P_OUT_OF_MAP
Definition: map.h:251
MoveType move_off
Definition: object.h:430
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:189
EXTERN Animations * animations
Definition: global.h:163
void do_learn_spell(object *op, object *spell, int special_prayer)
Definition: apply.c:486
static void cfapi_map_out_of_map(int *type,...)
Definition: plugins.c:1469
struct pl * contr
Definition: object.h:276
#define CFAPI_OBJECT_PROP_CHEATER
Definition: plugin.h:244
static void cfapi_object_get_key(int *type,...)
Definition: plugins.c:1679
#define CFAPI_OBJECT_PROP_PICKABLE
Definition: plugin.h:246
int8_t item_power
Definition: object.h:363
static void cfapi_system_directory(int *type,...)
Definition: plugins.c:993
void cleanupPlugins(void)
Definition: plugins.c:4807
uint8_t ignore_plugin_compatibility
Definition: global.h:330
uint8_t darkness
Definition: map.h:346
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:309
int try_find_animation(const char *name)
Definition: anim.c:186
void object_clear(object *op)
Definition: object.c:792
command_array_struct * find_plugin_command(const char *cmd, command_array_struct *command)
Definition: plugins.c:4736
static crossfire_plugin * plugins_find_plugin(const char *id)
Definition: plugins.c:248
#define CFAPI_OBJECT_PROP_ENEMY
Definition: plugin.h:223
#define CFAPI_REGION_PROP_JAIL_Y
Definition: plugin.h:331
object * find_marked_object(object *op)
Definition: c_object.c:1270
#define CFAPI_OBJECT_PROP_PATH_REPELLED
Definition: plugin.h:202
void plugins_display_list(object *op)
Definition: plugins.c:746
static void cfapi_object_learn_spell(int *type,...)
Definition: plugins.c:3874
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:70
char d_name[_MAX_FNAME+1]
Definition: win32.h:114
static void cfapi_object_create(int *type,...)
Definition: plugins.c:3458
int8_t luck
Definition: living.h:39
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h:298
float speed
Definition: object.h:328
unsigned __int64 uint64_t
Definition: win32.h:167
char fullname[MAX_BUF]
Definition: plugin.h:149
struct regiondef * parent
Definition: map.h:286
int on_same_map(const object *op1, const object *op2)
Definition: map.c:2658
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
f_plug_property propfunc
Definition: plugin.h:145
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
#define CFAPI_OBJECT_PROP_LORE
Definition: plugin.h:188
static void cfapi_player_find(int *type,...)
Definition: plugins.c:4176
#define EVENT_MAPLOAD
Definition: plugin.h:99
partylist * party_get_first(void)
Definition: party.c:218
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:215
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:328
#define MSG_TYPE_COMMAND_DEBUG
Definition: newclient.h:508
static void cfapi_object_apply(int *type,...)
Definition: plugins.c:3224
static void cfapi_system_unregister_global_event(int *type,...)
Definition: plugins.c:872
#define MAX_BUF
Definition: define.h:35
int quest_get_player_state(player *pl, sstring quest_code)
Definition: quest.c:1076
#define CFAPI_PARTY_PROP_NAME
Definition: plugin.h:320
struct obj * active_next
Definition: object.h:279
#define CFAPI_PLAYER_PROP_PARTY
Definition: plugin.h:283
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:326
#define EVENT_MAPUNLOAD
Definition: plugin.h:98
void drop(object *op, object *tmp)
Definition: c_object.c:924
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:241
const char * skill
Definition: object.h:321
int32_t last_eat
Definition: object.h:357
static void cfapi_object_describe(int *type,...)
Definition: plugins.c:3269
#define plugins_dlerror()
Definition: plugin.h:166
#define EVENT_MAPRESET
Definition: plugin.h:92
int8_t wc
Definition: living.h:37
const char * confdir
Definition: global.h:247
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
Definition: object.c:3476
int(* f_plug_event)(int *type,...)
Definition: plugin.h:131
signed __int64 int64_t
Definition: win32.h:168
#define CFAPI_OBJECT_PROP_TOTAL_EXP
Definition: plugin.h:221
static const flag_definition flags[]
#define EVENT_GKILL
Definition: plugin.h:87
static void cfapi_system_strdup_local(int *type,...)
Definition: plugins.c:839
const char * uniquedir
Definition: global.h:255
int8_t Str
Definition: living.h:36
char * tmpname
Definition: map.h:327
int16_t resist[NROFATTACKS]
Definition: object.h:342
object * ob
Definition: player.h:158
const char * sstring
Definition: global.h:40
#define EVENT_CLOCK
Definition: plugin.h:84
#define CFAPI_OBJECT_PROP_DAM
Definition: plugin.h:264
unsigned int uint32_t
Definition: win32.h:162
#define CFAPI_OBJECT_PROP_MOVE_TYPE
Definition: plugin.h:271
Definition: object.h:107
const char * datadir
Definition: global.h:248
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:186
#define CFAPI_PLAYER_PROP_NEXT
Definition: plugin.h:287
#define CFAPI_OBJECT_PROP_AC
Definition: plugin.h:256
static void cfapi_object_check_trigger(int *type,...)
Definition: plugins.c:3780
#define SET_MAP_FLAGS(M, X, Y, C)
Definition: map.h:163
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:238
#define TIMER_ERR_NONE
Definition: timers.h:66
const char * name
Definition: global.h:87
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:327
#define CFAPI_INT
Definition: plugin.h:105
uint32_t attacktype
Definition: object.h:343
struct obj * spellitem
Definition: object.h:396
static void cfapi_friendlylist_get_next(int *type,...)
Definition: plugins.c:4564
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
Definition: object.c:2480
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:314
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.c:978
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:2522
static void cfapi_object_perm_exp(int *type,...)
Definition: plugins.c:4217
int set_random_map_variable(RMParms *rp, const char *buf)
#define CFAPI_OBJECT_PROP_SPEED_LEFT
Definition: plugin.h:192
#define FREE_AND_COPY(sv, nv)
Definition: global.h:211
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:3827
const char * custom_name
Definition: object.h:434
int cftimer_create(int id, long delay, object *ob, int mode)
Definition: timers.c:97
const char * localdir
Definition: global.h:249
tag_t count
Definition: object.h:299
living stats
Definition: object.h:369
static void cfapi_map_has_been_loaded(int *type,...)
Definition: plugins.c:1255
uint16_t client_type
Definition: object.h:341
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:414
#define CFAPI_OBJECT_PROP_HP
Definition: plugin.h:257
struct oblnk * next
Definition: object.h:446
static void cfapi_object_cast(int *type,...)
Definition: plugins.c:3846
#define CFAPI_OBJECT_PROP_TITLE
Definition: plugin.h:183
int cftimer_find_free_id(void)
Definition: timers.c:144
const char * mapdir
Definition: global.h:251
uint32_t reset_timeout
Definition: map.h:333
#define CFAPI_PLAYER_PROP_BED_Y
Definition: plugin.h:286
uint16_t width
Definition: map.h:347
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:191
Definition: tod.h:34
uint8_t type
Definition: object.h:339
struct Settings settings
Definition: init.c:39
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:297
static void cfapi_get_hooks(int *type,...)
Definition: plugins.c:567
void object_set_enemy(object *op, object *enemy)
Definition: object.c:712
int remove_depletion(object *op, int level)
Definition: living.c:752
#define CFAPI_OBJECT_PROP_FRIENDLY
Definition: plugin.h:236
#define CFAPI_OBJECT_PROP_ANIM_SPEED
Definition: plugin.h:235
struct archt * next
Definition: object.h:469
#define CFAPI_OBJECT_PROP_LUCK
Definition: plugin.h:240
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:1883
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:266
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.c:551
object * object_get_player_container(object *op)
Definition: object.c:386
static void cfapi_system_add_string(int *type,...)
Definition: plugins.c:895
int out_of_map(mapstruct *m, int x, int y)
Definition: map.c:2313
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME
Definition: plugin.h:213
static void cfapi_get_time(int *type,...)
Definition: plugins.c:1046
static void cfapi_map_get_object_at(int *type,...)
Definition: plugins.c:1542
#define CFAPI_OBJECT_PROP_DEX
Definition: plugin.h:249
#define CFAPI_MOVETYPE
Definition: plugin.h:122
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
Definition: plugin.h:229
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:311
static void cfapi_object_change_abil(int *type,...)
Definition: plugins.c:4132
void delete_map(mapstruct *m)
Definition: map.c:1759
const char * msg
Definition: object.h:322
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:305
#define CFAPI_OBJECT_PROP_CON
Definition: plugin.h:250
sstring add_string(const char *str)
Definition: shstr.c:124
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED
Definition: plugin.h:293
EXTERN player * first_player
Definition: global.h:117
char * cost_string_from_value(uint64_t cost, int largest_coin)
Definition: shop.c:334
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:321
object * identify(object *op)
Definition: item.c:1429
struct pl * next
Definition: player.h:93
static void cfapi_object_clean_object(int *type,...)
Definition: plugins.c:3734
#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:193
int8_t glow_radius
Definition: object.h:365
#define CFAPI_OBJECT_PROP_MAXSP
Definition: plugin.h:262
f_plug_event eventfunc
Definition: plugin.h:144
void object_copy(const object *src_ob, object *dest_ob)
Definition: object.c:871
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:318
struct _crossfire_plugin * prev
Definition: plugin.h:152
static void cfapi_object_transfer(int *type,...)
Definition: plugins.c:3974
#define EVENT_PLAYER_DEATH
Definition: plugin.h:86
static void cfapi_object_remove_depletion(int *type,...)
Definition: plugins.c:3309
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:3140
#define NDI_UNIQUE
Definition: newclient.h:245
#define CFAPI_PLAYER_PROP_MARKED_ITEM
Definition: plugin.h:282
static void cfapi_map_get_map(int *type,...)
Definition: plugins.c:1204
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:3661
#define CFAPI_OBJECT_PROP_LAST_HEAL
Definition: plugin.h:209
#define CFAPI_OBJECT_PROP_CLIENT_TYPE
Definition: plugin.h:198
#define CFAPI_OBJECT_PROP_INVISIBLE
Definition: plugin.h:267
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:196
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:3889
#define CFAPI_OBJECT_PROP_POW
Definition: plugin.h:253
static void cfapi_get_weekday_name(int *type,...)
Definition: plugins.c:1089
static void cfapi_map_message(int *type,...)
Definition: plugins.c:1520
static void cfapi_object_update(int *type,...)
Definition: plugins.c:3682
object * mark
Definition: player.h:194
#define FLAG_WAS_WIZ
Definition: define.h:234
EXTERN region * first_region
Definition: global.h:119
uint8_t pick_up
Definition: object.h:362
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
Definition: plugin.h:216
int transfer_ob(object *op, int x, int y, int randomly, object *originator)
Definition: move.c:144
MoveType move_block
Definition: object.h:427
uint8_t run_away
Definition: object.h:386
#define CFAPI_OBJECT_PROP_GLOW_RADIUS
Definition: plugin.h:220
struct mapdef * next
Definition: map.h:326
static void cfapi_object_clone(int *type,...)
Definition: plugins.c:3426
static void cfapi_object_reset(int *type,...)
Definition: plugins.c:3720
void object_set_msg(object *op, const char *msg)
Definition: object.c:4748
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
Definition: object.c:3433
int check_trigger(object *op, object *cause)
Definition: button.c:523
#define CFAPI_OBJECT_PROP_PRESENT
Definition: plugin.h:243
float move_slow_penalty
Definition: object.h:432
#define CFAPI_OBJECT_PROP_MERGEABLE
Definition: plugin.h:245
#define CFAPI_OBJECT_PROP_WC
Definition: plugin.h:255
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:626
#define CFAPI_OBJECT_PROP_RESIST
Definition: plugin.h:199
#define CFAPI_OBJECT_PROP_SHORT_NAME
Definition: plugin.h:237
#define CFAPI_OBJECT_PROP_MOVE_SLOW
Definition: plugin.h:276
#define CFAPI_OBJECT_PROP_MATERIAL_NAME
Definition: plugin.h:205
void create_overlay_pathname(const char *name, char *buf, size_t size)
Definition: map.c:133
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Definition: object.c:2963
Definition: map.h:325
const New_Face * face
Definition: object.h:332
#define CFAPI_OBJECT_PROP_MAXHP
Definition: plugin.h:261
int can_pay(object *pl)
Definition: shop.c:836
#define FLAG_UNIQUE
Definition: define.h:288
#define CFAPI_OBJECT_PROP_VALUE
Definition: plugin.h:207
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:230
#define CFAPI_OBJECT_PROP_PATH_ATTUNED
Definition: plugin.h:201
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:129
int32_t move_status
Definition: object.h:392
int16_t level
Definition: object.h:352
int8_t facing
Definition: object.h:336
void fix_object(object *op)
Definition: living.c:1120
static void send_changed_object(object *op)
Definition: plugins.c:284
unsigned find_face(const char *name, unsigned error)
Definition: image.c:303
player * find_player_partial_name(const char *plname)
Definition: player.c:110
#define CFAPI_OBJECT_PROP_WIS
Definition: plugin.h:251
EXTERN mapstruct * first_map
Definition: global.h:118
int quest_was_completed(player *pl, sstring quest_code)
Definition: quest.c:1142
#define CFAPI_OBJECT_PROP_DURATION
Definition: plugin.h:278
EXTERN archetype * first_archetype
Definition: global.h:122
char * longname
Definition: map.h:291
void object_update_speed(object *op)
Definition: object.c:1152
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:307
void clean_object(object *op)
Definition: map.c:1649
int32_t value
Definition: object.h:351
object * object_get_owner(object *op)
Definition: object.c:592
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:171
int8_t magic
Definition: object.h:349
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:190
#define CFAPI_OBJECT_PROP_CUSTOM_NAME
Definition: plugin.h:234
const char * name
Definition: object.h:468
#define EVENT_BORN
Definition: plugin.h:83
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
f_plug_event gevent[NR_EVENTS]
Definition: plugin.h:150
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:125
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:4196
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Definition: object.c:3057
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
Definition: plugin.h:174
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:708
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Definition: spell_util.c:1469
void object_remove(object *op)
Definition: object.c:1668
#define EVENT_USER
Definition: plugin.h:78
static void cfapi_generate_random_map(int *type,...)
Definition: plugins.c:4628
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:203
static void cfapi_map_update_position(int *type,...)
Definition: plugins.c:1491
#define CFAPI_OBJECT_PROP_MOVE_BLOCK
Definition: plugin.h:272
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:325
struct obj * attacked_by
Definition: object.h:384
#define CFAPI_PPARTY
Definition: plugin.h:116
static void cfapi_map_change_light(int *type,...)
Definition: plugins.c:1598
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