Crossfire Server, Branches 1.12  R18729
plugins.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_plugins_c =
3  * "$Id: plugins.c 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*****************************************************************************/
7 /* CrossFire, A Multiplayer game for X-windows */
8 /* */
9 /* Copyright (C) 2000-2006 Mark Wedel & Crossfire Development Team */
10 /* Copyright (C) 1992 Frank Tore Johansen */
11 /* */
12 /* This program is free software; you can redistribute it and/or modify */
13 /* it under the terms of the GNU General Public License as published by */
14 /* the Free Software Foundation; either version 2 of the License, or */
15 /* (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 /* */
26 /* The authors can be reached via e-mail to crossfire-devel@real-time.com */
27 /*****************************************************************************/
28 /* This is the server-side plugin management part. */
29 /*****************************************************************************/
30 /* Original code by Yann Chachkoff (yann.chachkoff@mailandnews.com). */
31 /* Special thanks to: */
32 /* David Delbecq (david.delbecq@mailandnews.com); */
33 /* Joris Bontje (jbontje@suespammers.org); */
34 /* Philip Currlin (?); */
35 /*****************************************************************************/
36 
45 #if 0
46 
47 #define PLUGIN_DEBUG
48 #endif
49 
50 /*****************************************************************************/
51 /* First, the headers. We only include plugin.h, because all other includes */
52 /* are done into it, and plugproto.h (which is used only by this file). */
53 /*****************************************************************************/
54 #include <plugin.h>
55 
56 #ifndef __CEXTRACT__
57 #include <sproto.h>
58 #include <timers.h>
59 #endif
60 
61 #define NR_OF_HOOKS 89
62 
64  { cfapi_system_add_string, 0, "cfapi_system_add_string" },
65  { cfapi_system_register_global_event, 1, "cfapi_system_register_global_event" },
66  { cfapi_system_remove_string, 2, "cfapi_system_remove_string" },
67  { cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event" },
68  { cfapi_system_check_path, 4, "cfapi_system_check_path" },
69  { cfapi_system_re_cmp, 5, "cfapi_system_re_cmp" },
70  { cfapi_system_strdup_local, 6, "cfapi_system_strdup_local" },
71  { cfapi_system_directory, 7, "cfapi_system_directory" },
72  { cfapi_system_find_animation, 8, "cfapi_system_find_animation" },
73  { cfapi_object_clean_object, 9, "cfapi_object_clean_object" },
74  { cfapi_object_on_same_map, 10, "cfapi_object_on_same_map" },
75  { cfapi_object_get_key, 11, "cfapi_object_get_key" },
76  { cfapi_object_set_key, 12, "cfapi_object_set_key" },
77  { cfapi_object_get_property, 13, "cfapi_object_get_property" },
78  { cfapi_object_set_property, 14, "cfapi_object_set_property" },
79  { cfapi_object_apply, 15, "cfapi_object_apply" },
80  { cfapi_object_identify, 16, "cfapi_object_identify" },
81  { cfapi_object_describe, 17, "cfapi_object_describe" },
82  { cfapi_object_drain, 18, "cfapi_object_drain" },
83  { cfapi_object_fix, 19, "cfapi_object_fix" },
84  { cfapi_object_give_skill, 20, "cfapi_object_give_skill" },
85  { cfapi_object_transmute, 21, "cfapi_object_transmute" },
86  { cfapi_object_remove, 22, "cfapi_object_remove" },
87  { cfapi_object_delete, 23, "cfapi_object_delete" },
88  { cfapi_object_clone, 24, "cfapi_object_clone" },
89  { cfapi_object_find, 25, "cfapi_object_find" },
90  { cfapi_object_create, 26, "cfapi_object_create" },
91  { cfapi_object_insert, 27, "cfapi_object_insert" },
92  { cfapi_object_split, 28, "cfapi_object_split" },
93  { cfapi_object_merge, 29, "cfapi_object_merge" },
94  { cfapi_object_distance, 30, "cfapi_object_distance" },
95  { cfapi_object_update, 31, "cfapi_object_update" },
96  { cfapi_object_clear, 32, "cfapi_object_clear" },
97  { cfapi_object_reset, 33, "cfapi_object_reset" },
98  { cfapi_object_check_inventory, 34, "cfapi_object_check_inventory" },
99  { cfapi_object_spring_trap, 35, "cfapi_object_spring_trap" },
100  { cfapi_object_check_trigger, 36, "cfapi_object_check_trigger" },
101  { cfapi_object_query_cost, 37, "cfapi_object_query_cost" },
102  { cfapi_object_query_money, 38, "cfapi_object_query_money" },
103  { cfapi_object_cast, 39, "cfapi_object_cast" },
104  { cfapi_object_learn_spell, 40, "cfapi_object_learn_spell" },
105  { cfapi_object_forget_spell, 41, "cfapi_object_forget_spell" },
106  { cfapi_object_check_spell, 42, "cfapi_object_check_spell" },
107  { cfapi_object_pay_amount, 43, "cfapi_object_pay_amount" },
108  { cfapi_object_pay_item, 44, "cfapi_object_pay_item" },
109  { cfapi_object_transfer, 45, "cfapi_object_transfer" },
110  { cfapi_object_drop, 46, "cfapi_object_drop" },
111  { cfapi_object_change_abil, 47, "cfapi_object_change_abil" },
112  { cfapi_object_find_archetype_inside, 48, "cfapi_object_find_archetype_inside" },
113  { cfapi_object_say, 49, "cfapi_object_say" },
114  { cfapi_map_get_map, 50, "cfapi_map_get_map" },
115  { cfapi_map_has_been_loaded, 51, "cfapi_map_has_been_loaded" },
116  { cfapi_map_create_path, 52, "cfapi_map_create_path" },
117  { cfapi_map_get_map_property, 53, "cfapi_map_get_property" },
118  { cfapi_map_set_map_property, 54, "cfapi_map_set_property" },
119  { cfapi_map_out_of_map, 55, "cfapi_map_out_of_map" },
120  { cfapi_map_update_position, 56, "cfapi_map_update_position" },
121  { cfapi_map_delete_map, 57, "cfapi_map_delete_map" },
122  { cfapi_map_message, 58, "cfapi_map_message" },
123  { cfapi_map_get_object_at, 59, "cfapi_map_get_object_at" },
124  { cfapi_map_change_light, 60, "cfapi_map_change_light" },
125  { cfapi_map_present_arch_by_name, 61, "cfapi_map_present_arch_by_name" },
126  { cfapi_player_find, 62, "cfapi_player_find" },
127  { cfapi_player_message, 63, "cfapi_player_message" },
128  { cfapi_object_change_exp, 64, "cfapi_object_change_exp" },
129  { cfapi_object_teleport, 65, "cfapi_object_teleport" },
130  { cfapi_object_pickup, 67, "cfapi_object_pickup" },
131  { cfapi_object_move, 68, "cfapi_object_move" },
132  { cfapi_object_apply_below, 69, "cfapi_object_apply_below" },
133  { cfapi_generate_random_map, 70, "cfapi_generate_random_map" },
134  { cfapi_archetype_get_property, 71, "cfapi_archetype_get_property" },
135  { cfapi_party_get_property, 72, "cfapi_party_get_property" },
136  { cfapi_region_get_property, 73, "cfapi_region_get_property" },
137  { cfapi_player_can_pay, 74, "cfapi_player_can_pay" },
138  { cfapi_log, 75, "cfapi_log" },
139  { cfapi_get_time, 76, "cfapi_system_get_time" },
140  { cfapi_timer_create, 77, "cfapi_system_timer_create" },
141  { cfapi_timer_destroy, 78, "cfapi_system_timer_destroy" },
142  { cfapi_friendlylist_get_next, 79, "cfapi_friendlylist_get_next" },
143  { cfapi_set_random_map_variable, 80, "cfapi_set_random_map_variable" },
144  { cfapi_system_find_face, 81, "cfapi_system_find_face" },
145  { cfapi_get_season_name, 82, "cfapi_system_get_season_name" },
146  { cfapi_get_month_name, 83, "cfapi_system_get_month_name" },
147  { cfapi_get_weekday_name, 84, "cfapi_system_get_weekday_name" },
148  { cfapi_get_periodofday_name, 85, "cfapi_system_get_periodofday_name" },
149  { cfapi_map_trigger_connected, 86, "cfapi_map_trigger_connected" },
150  { cfapi_object_user_event, 87, "cfapi_object_user_event" },
151  { cfapi_system_find_string, 88, "cfapi_system_find_string" }
152 };
153 
155 
157 
158 /*****************************************************************************/
159 /* NEW PLUGIN STUFF STARTS HERE */
160 /*****************************************************************************/
161 
162 #ifdef WIN32
163 static const char *plugins_dlerror(void) {
164  static char buf[256];
165  DWORD err;
166  char *p;
167 
168  err = GetLastError();
169  if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof(buf), NULL) == 0)
170  snprintf(buf, sizeof(buf), "error %lu", err);
171  p = strchr(buf, '\0');
172  while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
173  p--;
174  *p = '\0';
175  return buf;
176 }
177 #endif /* WIN32 */
178 
184 static void send_changed_object(object *op) {
185  object *tmp;
186  player *pl;
187 
188  if (op->env != NULL) {
189  tmp = get_player_container(op->env);
190  if (!tmp) {
191  for (pl = first_player; pl; pl = pl->next)
192  if (pl->ob->container == op->env)
193  break;
194  if (pl)
195  tmp = pl->ob;
196  else
197  tmp = NULL;
198  }
199  if (tmp)
200  /* We don't know what changed, so we send everything. */
201  esrv_update_item(UPD_ALL, tmp, op);
202  } else {
203  for (tmp = op->above; tmp != NULL; tmp = tmp->above)
204  if (tmp->type == PLAYER)
205  tmp->contr->socket.update_look = 1;
206  }
207 }
208 
209 int user_event(object *op, object *activator, object *third, const char *message, int fix) {
210  return execute_event(op, EVENT_USER, activator, third, message, fix);
211 }
212 
213 int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix) {
214  object *tmp, *next;
215  crossfire_plugin *plugin;
216  int rv = 0;
217 
218  for (tmp = op->inv; tmp != NULL; tmp = next) {
219  next = tmp->below;
220  if (tmp->type == EVENT_CONNECTOR && tmp->subtype == eventcode) {
221 #ifdef PLUGIN_DEBUG
222  LOG(llevDebug, "********** EVENT HANDLER **********\n");
223  LOG(llevDebug, " - Who am I :%s\n", op->name);
224  if (activator != NULL)
225  LOG(llevDebug, " - Activator :%s\n", activator->name);
226  if (third != NULL)
227  LOG(llevDebug, " - Other object :%s\n", third->name);
228  LOG(llevDebug, " - Event code :%d\n", tmp->subtype);
229  if (tmp->title != NULL)
230  LOG(llevDebug, " - Event plugin :%s\n", tmp->title);
231  if (tmp->slaying != NULL)
232  LOG(llevDebug, " - Event hook :%s\n", tmp->slaying);
233  if (tmp->name != NULL)
234  LOG(llevDebug, " - Event options :%s\n", tmp->name);
235 #endif
236 
237  if (tmp->title == NULL) {
238  object *env = object_get_env_recursive(tmp);
239  LOG(llevError, "Event object without title at %d/%d in map %s\n", env->x, env->y, env->map->name);
240  remove_ob(tmp);
241  free_object(tmp);
242  } else if (tmp->slaying == NULL) {
243  object *env = object_get_env_recursive(tmp);
244  LOG(llevError, "Event object without slaying at %d/%d in map %s\n", env->x, env->y, env->map->name);
245  remove_ob(tmp);
246  free_object(tmp);
247  } else {
248  plugin = plugins_find_plugin(tmp->title);
249  if (plugin == NULL) {
250  object *env = object_get_env_recursive(tmp);
251  LOG(llevError, "The requested plugin doesn't exit: %s at %d/%d in map %s\n", tmp->title, env->x, env->y, env->map->name);
252  remove_ob(tmp);
253  free_object(tmp);
254  } else {
255  int rvt = 0;
256  int *rv;
257 
258  rv = plugin->eventfunc(&rvt, op, /*eventcode, */ activator, third, message, fix, /*tmp->slaying, tmp->name*/ tmp);
259  if (QUERY_FLAG(tmp, FLAG_UNIQUE)) {
260 #ifdef PLUGIN_DEBUG
261  LOG(llevDebug, "Removing unique event %s\n", tmp->slaying);
262 #endif
263  remove_ob(tmp);
264  free_object(tmp);
265  }
266  return *rv;
267  }
268  }
269  }
270  }
271  return rv;
272 }
273 
274 int execute_global_event(int eventcode, ...) {
275  va_list args;
276  mapstruct *map;
277  object *op;
278  object *op2;
279  player *pl;
280  const char *buf;
281  int i, rt;
282  crossfire_plugin *cp;
283 
284  if (plugins_list == NULL)
285  return -1;
286 
287  va_start(args, eventcode);
288 
289  switch (eventcode) {
290  case EVENT_BORN:
291  /*BORN: op*/
292  op = va_arg(args, object *);
293  for (cp = plugins_list; cp != NULL; cp = cp->next) {
294  if (cp->gevent[eventcode] != NULL)
295  cp->gevent[eventcode](&rt, eventcode, op);
296  }
297  break;
298 
299  case EVENT_CLOCK:
300  /*CLOCK: -*/
301  for (cp = plugins_list; cp != NULL; cp = cp->next) {
302  if (cp->gevent[eventcode] != NULL)
303  cp->gevent[eventcode](&rt, eventcode);
304  }
305  break;
306 
307  case EVENT_CRASH:
308  for (cp = plugins_list; cp != NULL; cp = cp->next) {
309  if (cp->gevent[eventcode] != NULL)
310  cp->gevent[eventcode](&rt, eventcode);
311  }
312  break;
313 
314  case EVENT_PLAYER_DEATH:
315  /*PLAYER_DEATH: op*/
316  op = va_arg(args, object *);
317  for (cp = plugins_list; cp != NULL; cp = cp->next) {
318  if (cp->gevent[eventcode] != NULL)
319  cp->gevent[eventcode](&rt, eventcode, op);
320  }
321  break;
322 
323  case EVENT_GKILL:
324  /*GKILL: op, hitter*/
325  op = va_arg(args, object *);
326  op2 = va_arg(args, object *);
327  for (cp = plugins_list; cp != NULL; cp = cp->next) {
328  if (cp->gevent[eventcode] != NULL)
329  cp->gevent[eventcode](&rt, eventcode, op, op2);
330  }
331  break;
332 
333  case EVENT_LOGIN:
334  /*LOGIN: pl, pl->socket.host*/
335  pl = va_arg(args, player *);
336  buf = va_arg(args, char *);
337  for (cp = plugins_list; cp != NULL; cp = cp->next) {
338  if (cp->gevent[eventcode] != NULL)
339  cp->gevent[eventcode](&rt, eventcode, pl, buf);
340  }
341  break;
342 
343  case EVENT_LOGOUT:
344  /*LOGOUT: pl, pl->socket.host*/
345  pl = va_arg(args, player *);
346  buf = va_arg(args, char *);
347  for (cp = plugins_list; cp != NULL; cp = cp->next) {
348  if (cp->gevent[eventcode] != NULL)
349  cp->gevent[eventcode](&rt, eventcode, pl, buf);
350  }
351  break;
352 
353  case EVENT_MAPENTER:
354  /*MAPENTER: op, map*/
355  op = va_arg(args, object *);
356  map = va_arg(args, mapstruct *);
357  for (cp = plugins_list; cp != NULL; cp = cp->next) {
358  if (cp->gevent[eventcode] != NULL)
359  cp->gevent[eventcode](&rt, eventcode, op, map);
360  }
361  break;
362 
363  case EVENT_MAPLEAVE:
364  /*MAPLEAVE: op, map*/
365  op = va_arg(args, object *);
366  map = va_arg(args, mapstruct *);
367  for (cp = plugins_list; cp != NULL; cp = cp->next) {
368  if (cp->gevent[eventcode] != NULL)
369  cp->gevent[eventcode](&rt, eventcode, op, map);
370  }
371  break;
372 
373  case EVENT_MAPRESET:
374  /*MAPRESET: map*/
375  map = va_arg(args, mapstruct *);
376  for (cp = plugins_list; cp != NULL; cp = cp->next) {
377  if (cp->gevent[eventcode] != NULL)
378  cp->gevent[eventcode](&rt, eventcode, map);
379  }
380  break;
381 
382  case EVENT_REMOVE:
383  /*REMOVE: op*/
384  op = va_arg(args, object *);
385  for (cp = plugins_list; cp != NULL; cp = cp->next) {
386  if (cp->gevent[eventcode] != NULL)
387  cp->gevent[eventcode](&rt, eventcode, op);
388  }
389  break;
390 
391  case EVENT_SHOUT:
392  /*SHOUT: op, parms, priority*/
393  op = va_arg(args, object *);
394  buf = va_arg(args, char *);
395  i = va_arg(args, int);
396  for (cp = plugins_list; cp != NULL; cp = cp->next) {
397  if (cp->gevent[eventcode] != NULL)
398  cp->gevent[eventcode](&rt, eventcode, op, buf, i);
399  }
400  break;
401 
402  case EVENT_TELL:
403  /* Tell: who, what, to who */
404  op = va_arg(args, object *);
405  buf = va_arg(args, const char *);
406  op2 = va_arg(args, object *);
407  for (cp = plugins_list; cp != NULL; cp = cp->next) {
408  if (cp->gevent[eventcode] != NULL)
409  cp->gevent[eventcode](&rt, eventcode, op, buf, op2);
410  }
411  break;
412 
413  case EVENT_MUZZLE:
414  /*MUZZLE: op, parms*/
415  op = va_arg(args, object *);
416  buf = va_arg(args, char *);
417  for (cp = plugins_list; cp != NULL; cp = cp->next) {
418  if (cp->gevent[eventcode] != NULL)
419  cp->gevent[eventcode](&rt, eventcode, op, buf);
420  }
421  break;
422 
423  case EVENT_KICK:
424  /*KICK: op, parms*/
425  op = va_arg(args, object *);
426  buf = va_arg(args, char *);
427  for (cp = plugins_list; cp != NULL; cp = cp->next) {
428  if (cp->gevent[eventcode] != NULL)
429  cp->gevent[eventcode](&rt, eventcode, op, buf);
430  }
431  break;
432 
433  case EVENT_MAPUNLOAD:
434  /*MAPUNLOAD: map*/
435  map = va_arg(args, mapstruct *);
436  for (cp = plugins_list; cp != NULL; cp = cp->next) {
437  if (cp->gevent[eventcode] != NULL)
438  cp->gevent[eventcode](&rt, eventcode, map);
439  }
440  break;
441 
442  case EVENT_MAPLOAD:
443  /*MAPLOAD: map*/
444  map = va_arg(args, mapstruct *);
445  for (cp = plugins_list; cp != NULL; cp = cp->next) {
446  if (cp->gevent[eventcode] != NULL)
447  cp->gevent[eventcode](&rt, eventcode, map);
448  }
449  break;
450  }
451  va_end(args);
452  return 0;
453 }
454 
455 int plugins_init_plugin(const char *libfile) {
456  LIBPTRTYPE ptr;
457  f_plug_init initfunc;
458  f_plug_api propfunc;
459  f_plug_api eventfunc;
460  f_plug_postinit postfunc;
461  f_plug_postinit closefunc;
462  int i;
463  crossfire_plugin *cp;
464  crossfire_plugin *ccp;
465 
466  /* Open the plugin lib and load the required functions */
467  ptr = plugins_dlopen(libfile);
468  if (ptr == NULL) {
469  LOG(llevError, "Error trying to load %s: %s\n", libfile, plugins_dlerror());
470  return -1;
471  }
472  initfunc = (f_plug_init)plugins_dlsym(ptr, "initPlugin");
473  if (initfunc == NULL) {
474  LOG(llevError, "Plugin error while requesting %s.initPlugin: %s\n", libfile, plugins_dlerror());
475  plugins_dlclose(ptr);
476  return -1;
477  }
478  propfunc = (f_plug_api)plugins_dlsym(ptr, "getPluginProperty");
479  if (propfunc == NULL) {
480  LOG(llevError, "Plugin error while requesting %s.getPluginProperty: %s\n", libfile, plugins_dlerror());
481  plugins_dlclose(ptr);
482  return -1;
483  }
484  eventfunc = (f_plug_api)plugins_dlsym(ptr, "eventListener");
485  if (eventfunc == NULL) {
486  LOG(llevError, "Plugin error while requesting %s.eventListener: %s\n", libfile, plugins_dlerror());
487  plugins_dlclose(ptr);
488  return -1;
489  }
490  postfunc = (f_plug_postinit)plugins_dlsym(ptr, "postInitPlugin");
491  if (postfunc == NULL) {
492  LOG(llevError, "Plugin error while requesting %s.postInitPlugin: %s\n", libfile, plugins_dlerror());
493  plugins_dlclose(ptr);
494  return -1;
495  }
496  closefunc = (f_plug_postinit)plugins_dlsym(ptr, "closePlugin");
497  if (closefunc == NULL) {
498  LOG(llevError, "Plugin error while requesting %s.closePlugin: %s\n", libfile, plugins_dlerror());
499  plugins_dlclose(ptr);
500  return -1;
501  }
502  i = initfunc("2.0", cfapi_get_hooks);
503  cp = malloc(sizeof(crossfire_plugin));
504  for (i = 0; i < NR_EVENTS; i++)
505  cp->gevent[i] = NULL;
506  cp->eventfunc = eventfunc;
507  cp->propfunc = propfunc;
508  cp->closefunc = closefunc;
509  cp->libptr = ptr;
510  propfunc(&i, "Identification", cp->id, sizeof(cp->id));
511  propfunc(&i, "FullName", cp->fullname, sizeof(cp->fullname));
512  cp->next = NULL;
513  cp->prev = NULL;
514  if (plugins_list == NULL) {
515  plugins_list = cp;
516  } else {
517  for (ccp = plugins_list; ccp->next != NULL; ccp = ccp->next)
518  ;
519  ccp->next = cp;
520  cp->prev = ccp;
521  }
522  postfunc();
523  plugin_number++;
524  return 0;
525 }
526 
527 void *cfapi_get_hooks(int *type, ...) {
528  va_list args;
529  int request_type;
530  char *buf;
531  int fid;
532  f_plug_api *rapi;
533  int i;
534 
535  *type = CFAPI_NONE;
536 
537  va_start(args, type);
538  request_type = va_arg(args, int);
539  if (request_type == 0) { /* By nr */
540  fid = va_arg(args, int);
541  rapi = va_arg(args, f_plug_api *);
542  if (fid < 0 || fid >= NR_OF_HOOKS) {
543  *rapi = NULL;
544  *type = CFAPI_NONE;
545  } else {
546  *rapi = plug_hooks[fid].func;
547  *type = CFAPI_FUNC;
548  }
549  } else { /* by name */
550  buf = va_arg(args, char *);
551  rapi = va_arg(args, f_plug_api *);
552  *rapi = NULL;
553  *type = CFAPI_NONE;
554  for (i = 0; i < NR_OF_HOOKS; i++) {
555  if (!strcmp(buf, plug_hooks[i].fname)) {
556  *rapi = plug_hooks[i].func;
557  *type = CFAPI_FUNC;
558  break;
559  }
560  }
561  }
562  va_end(args);
563  return NULL;
564 }
565 
566 int plugins_remove_plugin(const char *id) {
567  crossfire_plugin *cp;
568 
569  if (plugins_list == NULL)
570  return -1;
571 
572  for (cp = plugins_list; cp != NULL; cp = cp->next) {
573  if (!strcmp(id, cp->id)) {
574  crossfire_plugin *n;
575  crossfire_plugin *p;
576 
577  n = cp->next;
578  p = cp->prev;
579  if (cp->closefunc)
580  cp->closefunc();
581  plugins_dlclose(cp->libptr);
582  if (n != NULL) {
583  if (p != NULL) {
584  n->prev = p;
585  p->next = n;
586  } else {
587  n->prev = NULL;
588  plugins_list = n;
589  }
590  } else {
591  if (p != NULL)
592  p->next = NULL;
593  else
594  plugins_list = NULL;
595  }
596  free(cp);
597  plugin_number--;
598  return 0;
599  }
600  }
601  return -1;
602 }
603 
605  crossfire_plugin *cp;
606 
607  if (plugins_list == NULL)
608  return NULL;
609 
610  for (cp = plugins_list; cp != NULL; cp = cp->next) {
611  if (!strcmp(id, cp->id)) {
612  return cp;
613  }
614  }
615  return NULL;
616 }
617 
618 /*****************************************************************************/
619 /* Displays a list of loaded plugins (keystrings and description) in the */
620 /* game log window. */
621 /*****************************************************************************/
622 void plugins_display_list(object *op) {
623  crossfire_plugin *cp;
624 
626  "List of loaded plugins:\n-----------------------", NULL);
627 
628  if (plugins_list == NULL)
629  return;
630 
631  for (cp = plugins_list; cp != NULL; cp = cp->next) {
633  "%s, %s",
634  "%s, %s",
635  cp->id, cp->fullname);
636  }
637 }
638 
639 /* SYSTEM-RELATED HOOKS */
640 
648 void *cfapi_system_find_animation(int *type, ...) {
649  va_list args;
650  const char *anim;
651  int *num;
652 
653  va_start(args, type);
654  anim = va_arg(args, const char *);
655  num = va_arg(args, int *);
656  va_end(args);
657 
658  *num = find_animation(anim);
659  *type = CFAPI_INT;
660  return NULL;
661 }
662 
670 void *cfapi_system_find_face(int *type, ...) {
671  va_list args;
672  const char *face;
673  int error;
674  int *num;
675 
676  va_start(args, type);
677  face = va_arg(args, const char *);
678  error = va_arg(args, int);
679  num = va_arg(args, int *);
680  va_end(args);
681 
682  *num = find_face(face, error);
683  *type = CFAPI_INT;
684  return NULL;
685 }
686 
694 void *cfapi_system_strdup_local(int *type, ...) {
695  va_list args;
696  const char *txt;
697  char **ret;
698 
699  va_start(args, type);
700  txt = va_arg(args, const char *);
701  ret = va_arg(args, char **);
702  va_end(args);
703 
704  *ret = strdup_local(txt);
705  *type = CFAPI_STRING;
706  return NULL;
707 }
708 
709 void *cfapi_system_register_global_event(int *type, ...) {
710  va_list args;
711  int eventcode;
712  char *pname;
713  f_plug_api hook;
714  crossfire_plugin *cp;
715 
716  va_start(args, type);
717  eventcode = va_arg(args, int);
718  pname = va_arg(args, char *);
719  hook = va_arg(args, f_plug_api);
720  va_end(args);
721 
722  *type = CFAPI_NONE;
723 
724  cp = plugins_find_plugin(pname);
725  cp->gevent[eventcode] = hook;
726  return NULL;
727 }
728 
730  va_list args;
731  int eventcode;
732  char *pname;
733  crossfire_plugin *cp;
734 
735  va_start(args, type);
736  eventcode = va_arg(args, int);
737  pname = va_arg(args, char *);
738  va_end(args);
739 
740  *type = CFAPI_NONE;
741 
742  cp = plugins_find_plugin(pname);
743  cp->gevent[eventcode] = NULL;
744 
745  return NULL;
746 }
747 
756 void *cfapi_system_add_string(int *type, ...) {
757  va_list args;
758  const char *str;
759  sstring *rv;
760 
761  va_start(args, type);
762  str = va_arg(args, const char *);
763  rv = va_arg(args, sstring *);
764  va_end(args);
765 
766  *rv = add_string(str);
767  *type = CFAPI_SSTRING;
768  return NULL;
769 }
770 
779 void *cfapi_system_remove_string(int *type, ...) {
780  va_list args;
781  sstring str;
782 
783  va_start(args, type);
784  str = va_arg(args, sstring);
785  va_end(args);
786 
787  free_string(str);
788  *type = CFAPI_NONE;
789  return NULL;
790 }
791 
800 void *cfapi_system_find_string(int *type, ...) {
801  va_list args;
802  const char *str;
803  sstring *rv;
804 
805  va_start(args, type);
806  str = va_arg(args, const char *);
807  rv = va_arg(args, sstring *);
808  va_end(args);
809 
810  *rv = find_string(str);
811  *type = CFAPI_SSTRING;
812  return NULL;
813 }
814 
822 void *cfapi_system_check_path(int *type, ...) {
823  va_list args;
824  const char *name;
825  int prepend_dir;
826  int *ret;
827 
828  va_start(args, type);
829 
830  name = va_arg(args, char *);
831  prepend_dir = va_arg(args, int);
832  ret = va_arg(args, int *);
833 
834  *ret = check_path(name, prepend_dir);
835 
836  va_end(args);
837  *type = CFAPI_INT;
838  return NULL;
839 }
840 
848 void *cfapi_system_re_cmp(int *type, ...) {
849  va_list args;
850  const char *str;
851  const char *regexp;
852  const char **rv;
853 
854  va_start(args, type);
855 
856  str = va_arg(args, char *);
857  regexp = va_arg(args, char *);
858  rv = va_arg(args, const char **);
859 
860  *rv = re_cmp(str, regexp);
861 
862  va_end(args);
863  *type = CFAPI_STRING;
864  return NULL;
865 }
866 
867 void *cfapi_system_directory(int *type, ...) {
868  va_list args;
869  int dirtype;
870  const char **str;
871 
872  va_start(args, type);
873 
874  dirtype = va_arg(args, int);
875  str = va_arg(args, const char **);
876  va_end(args);
877 
878  *type = CFAPI_STRING;
879 
880  switch (dirtype) {
881  case 0:
882  *str = settings.mapdir;
883  break;
884 
885  case 1:
886  *str = settings.uniquedir;
887  break;
888 
889  case 2:
890  *str = settings.tmpdir;
891  break;
892 
893  case 3:
894  *str = settings.confdir;
895  break;
896 
897  case 4:
898  *str = settings.localdir;
899  break;
900 
901  case 5:
902  *str = settings.playerdir;
903  break;
904 
905  case 6:
906  *str = settings.datadir;
907  break;
908 
909  default:
910  *str = NULL;
911  }
912 
913  return NULL;
914 }
915 
924 void *cfapi_get_time(int *type, ...) {
925  va_list args;
926  timeofday_t *tod;
927 
928  va_start(args, type);
929  tod = va_arg(args, timeofday_t *);
930  va_end(args);
931 
932  get_tod(tod);
933  *type = CFAPI_NONE;
934  return NULL;
935 }
936 
937 #define string_get_int(name) \
938  va_list args; \
939  int index; \
940  const char **str; \
941  va_start(args, type); \
942  index = va_arg(args, int); \
943  str = va_arg(args, const char **); \
944  va_end(args); \
945  *str = name(index); \
946  *type = CFAPI_STRING; \
947  return NULL; \
948 
949 
957 void *cfapi_get_season_name(int *type, ...) {
959 }
960 
969 void *cfapi_get_weekday_name(int *type, ...) {
971 }
972 
981 void *cfapi_get_month_name(int *type, ...) {
983 }
984 
993 void *cfapi_get_periodofday_name(int *type, ...) {
995 }
996 
1010 void *cfapi_timer_create(int *type, ...) {
1011  va_list args;
1012  int res;
1013  object *ob;
1014  long delay;
1015  int mode;
1016  int *timer;
1017 
1018  va_start(args, type);
1019  ob = va_arg(args, object *);
1020  delay = va_arg(args, long);
1021  mode = va_arg(args, int);
1022  timer = va_arg(args, int *);
1023  va_end(args);
1024  *type = CFAPI_INT;
1025 
1026  *timer = cftimer_find_free_id();
1027  if (*timer != TIMER_ERR_ID) {
1028  res = cftimer_create(*timer, delay, ob, mode);
1029  if (res != TIMER_ERR_NONE)
1030  *timer = res;
1031  }
1032  return NULL;
1033 }
1034 
1046 void *cfapi_timer_destroy(int *type, ...) {
1047  va_list args;
1048  int id;
1049  int *err;
1050 
1051  va_start(args, type);
1052  id = va_arg(args, int);
1053  err = va_arg(args, int *);
1054  va_end(args);
1055  *type = CFAPI_INT;
1056 
1057  *err = cftimer_destroy(id);
1058 
1059  return NULL;
1060 }
1061 
1069 void *cfapi_log(int *type, ...) {
1070  va_list args;
1071  LogLevel logLevel;
1072  const char *message;
1073 
1074  va_start(args, type);
1075  logLevel = va_arg(args, LogLevel);
1076  message = va_arg(args, const char *);
1077  LOG(logLevel, "%s", message);
1078  va_end(args);
1079 
1080  *type = CFAPI_NONE;
1081 
1082  return NULL;
1083 }
1084 
1085 /* MAP RELATED HOOKS */
1086 
1095 void *cfapi_map_get_map(int *type, ...) {
1096  va_list args;
1097  mapstruct **ret;
1098  int ctype;
1099  int x, y;
1100  sint16 nx, ny;
1101  const char *name;
1102  mapstruct *m;
1103 
1104  va_start(args, type);
1105 
1106  ctype = va_arg(args, int);
1107 
1108  switch (ctype) {
1109  case 0:
1110  x = va_arg(args, int);
1111  y = va_arg(args, int);
1112  ret = va_arg(args, mapstruct **);
1113  *ret = get_empty_map(x, y);
1114  break;
1115 
1116  case 1:
1117  name = va_arg(args, const char *);
1118  x = va_arg(args, int);
1119  ret = va_arg(args, mapstruct **);
1120  *ret = ready_map_name(name, x);
1121  break;
1122 
1123  case 2:
1124  m = va_arg(args, mapstruct *);
1125  nx = va_arg(args, int);
1126  ny = va_arg(args, int);
1127  ret = va_arg(args, mapstruct **);
1128  *ret = get_map_from_coord(m, &nx, &ny);
1129  break;
1130 
1131  default:
1132  *type = CFAPI_NONE;
1133  va_end(args);
1134  return NULL;
1135  break;
1136  }
1137  va_end(args);
1138  *type = CFAPI_PMAP;
1139  return NULL;
1140 }
1141 
1149 void *cfapi_map_has_been_loaded(int *type, ...) {
1150  va_list args;
1151  mapstruct **map;
1152  char *string;
1153 
1154  va_start(args, type);
1155  string = va_arg(args, char *);
1156  map = va_arg(args, mapstruct **);
1157  *map = has_been_loaded(string);
1158  va_end(args);
1159  *type = CFAPI_PMAP;
1160  return NULL;
1161 }
1162 
1170 void *cfapi_map_create_path(int *type, ...) {
1171  va_list args;
1172  int ctype, size;
1173  const char *str;
1174  char *name;
1175 
1176  va_start(args, type);
1177 
1178  ctype = va_arg(args, int);
1179  str = va_arg(args, const char *);
1180  name = va_arg(args, char *);
1181  size = va_arg(args, int);
1182  *type = CFAPI_STRING;
1183 
1184  switch (ctype) {
1185  case 0:
1186  create_pathname(str, name, size);
1187  break;
1188 
1189  case 1:
1190  create_overlay_pathname(str, name, MAX_BUF);
1191  break;
1192 
1193 /* case 2:
1194  rv = create_items_path(str);
1195  break;*/
1196 
1197  default:
1198  *type = CFAPI_NONE;
1199  break;
1200  }
1201  va_end(args);
1202  return NULL;
1203 }
1204 
1205 void *cfapi_map_get_map_property(int *type, ...) {
1206  va_list args;
1207  mapstruct *map;
1208  int property;
1209 
1210  int *rint;
1211  mapstruct **rmap;
1212  sstring *rstr;
1213  region **rreg;
1214  sint16 *nx, *ny;
1215  int x, y;
1216 
1217  va_start(args, type);
1218 
1219  map = va_arg(args, mapstruct *);
1220  property = va_arg(args, int);
1221 
1222  switch (property) {
1223  case CFAPI_MAP_PROP_FLAGS:
1224  rmap = va_arg(args, mapstruct **);
1225  x = va_arg(args, int);
1226  y = va_arg(args, int);
1227  nx = va_arg(args, sint16 *);
1228  ny = va_arg(args, sint16 *);
1229  rint = va_arg(args, int *);
1230  *rint = get_map_flags(map, rmap, x, y, nx, ny);
1231  *type = CFAPI_INT;
1232  break;
1233 
1235  rint = va_arg(args, int *);
1236  *rint = calculate_difficulty(map);
1237  *type = CFAPI_INT;
1238  break;
1239 
1240  case CFAPI_MAP_PROP_PATH:
1241  rstr = va_arg(args, sstring *);
1242  *rstr = map->path;
1243  *type = CFAPI_SSTRING;
1244  break;
1245 
1247  rstr = va_arg(args, sstring *);
1248  *rstr = map->tmpname;
1249  *type = CFAPI_SSTRING;
1250  break;
1251 
1252  case CFAPI_MAP_PROP_NAME:
1253  rstr = va_arg(args, sstring *);
1254  *rstr = map->name;
1255  *type = CFAPI_SSTRING;
1256  break;
1257 
1259  rint = va_arg(args, int *);
1260  *rint = map->reset_time;
1261  *type = CFAPI_INT;
1262  break;
1263 
1265  rint = va_arg(args, int *);
1266  *rint = map->reset_timeout;
1267  *type = CFAPI_INT;
1268  break;
1269 
1271  rint = va_arg(args, int *);
1272  *rint = map->players;
1273  *type = CFAPI_INT;
1274  break;
1275 
1277  rint = va_arg(args, int *);
1278  *rint = map->darkness;
1279  *type = CFAPI_INT;
1280  break;
1281 
1282  case CFAPI_MAP_PROP_WIDTH:
1283  rint = va_arg(args, int *);
1284  *rint = map->width;
1285  *type = CFAPI_INT;
1286  break;
1287 
1288  case CFAPI_MAP_PROP_HEIGHT:
1289  rint = va_arg(args, int *);
1290  *rint = map->height;
1291  *type = CFAPI_INT;
1292  break;
1293 
1295  rint = va_arg(args, int *);
1296  *rint = map->enter_x;
1297  *type = CFAPI_INT;
1298  break;
1299 
1301  rint = va_arg(args, int *);
1302  *rint = map->enter_y;
1303  *type = CFAPI_INT;
1304  break;
1305 
1307  rstr = va_arg(args, sstring *);
1308  *rstr = map->msg;
1309  *type = CFAPI_SSTRING;
1310  break;
1311 
1312  case CFAPI_MAP_PROP_NEXT:
1313  rmap = va_arg(args, mapstruct **);
1314  *rmap = map ? map->next : first_map;
1315  *type = CFAPI_PMAP;
1316  break;
1317 
1318  case CFAPI_MAP_PROP_REGION:
1319  rreg = va_arg(args, region **);
1320  *rreg = get_region_by_map(map);
1321  *type = CFAPI_PREGION;
1322  break;
1323 
1324  case CFAPI_MAP_PROP_UNIQUE:
1325  rint = va_arg(args, int *);
1326  *rint = map->unique;
1327  *type = CFAPI_INT;
1328  break;
1329 
1330  default:
1331  *type = CFAPI_NONE;
1332  break;
1333  }
1334  va_end(args);
1335  return NULL;
1336 }
1337 
1338 void *cfapi_map_set_map_property(int *type, ...) {
1339  va_list args;
1340  mapstruct *map;
1341  int property;
1342  const char *buf;
1343 
1344  va_start(args, type);
1345 
1346  map = va_arg(args, mapstruct *);
1347  property = va_arg(args, int);
1348 
1349  switch (property) {
1350  case CFAPI_MAP_PROP_PATH:
1351  buf = va_arg(args, const char *);
1352  snprintf(map->path, sizeof(map->path), "%s", buf);
1353  *type = CFAPI_STRING;
1354  break;
1355 
1356  default:
1357  *type = CFAPI_NONE;
1358  break;
1359  }
1360  va_end(args);
1361  return NULL;
1362 }
1363 
1371 void *cfapi_map_out_of_map(int *type, ...) {
1372  va_list args;
1373  mapstruct *map;
1374  int x, y;
1375  int *rint;
1376 
1377  va_start(args, type);
1378  map = va_arg(args, mapstruct *);
1379  x = va_arg(args, int);
1380  y = va_arg(args, int);
1381  rint = va_arg(args, int *);
1382 
1383  *rint = out_of_map(map, x, y);
1384  va_end(args);
1385  *type = CFAPI_INT;
1386  return NULL;
1387 }
1388 
1396 void *cfapi_map_update_position(int *type, ...) {
1397  va_list args;
1398  mapstruct *map;
1399  int x, y;
1400 
1401  va_start(args, type);
1402 
1403  map = va_arg(args, mapstruct *);
1404  x = va_arg(args, int);
1405  y = va_arg(args, int);
1406 
1407  update_position(map, x, y);
1408  va_end(args);
1409  *type = CFAPI_NONE;
1410  return NULL;
1411 }
1412 
1413 void *cfapi_map_delete_map(int *type, ...) {
1414  va_list args;
1415  mapstruct *map;
1416  va_start(args, type);
1417 
1418  map = va_arg(args, mapstruct *);
1419 
1420  delete_map(map);
1421 
1422  va_end(args);
1423  *type = CFAPI_NONE;
1424  return NULL;
1425 }
1426 void *cfapi_map_message(int *type, ...) {
1427  va_list args;
1428  mapstruct *map;
1429  const char *string;
1430  int color;
1431 
1432  va_start(args, type);
1433  map = va_arg(args, mapstruct *);
1434  string = va_arg(args, const char *);
1435  color = va_arg(args, int);
1436  va_end(args);
1437 
1438  /* function should be extended to take message types probably */
1439  ext_info_map(color, map, MSG_TYPE_MISC, MSG_SUBTYPE_NONE, string, string);
1440  *type = CFAPI_NONE;
1441  return NULL;
1442 }
1443 
1451 void *cfapi_map_get_object_at(int *type, ...) {
1452  va_list args;
1453  mapstruct *map;
1454  int x, y;
1455  sint16 sx, sy;
1456  object **robj;
1457 
1458  va_start(args, type);
1459  map = va_arg(args, mapstruct *);
1460  x = va_arg(args, int);
1461  y = va_arg(args, int);
1462  robj = va_arg(args, object **);
1463  va_end(args);
1464 
1465  sx = x;
1466  sy = y;
1467  if (get_map_flags(map, &map, x, y, &sx, &sy)&P_OUT_OF_MAP)
1468  *robj = NULL;
1469  else
1470  *robj = GET_MAP_OB(map, sx, sy);
1471  *type = CFAPI_POBJECT;
1472  return NULL;
1473 }
1474 
1483 void *cfapi_map_present_arch_by_name(int *type, ...) {
1484  va_list args;
1485  int x, y;
1486  mapstruct *map;
1487  char *msg;
1488  object **robj;
1489 
1490  va_start(args, type);
1491 
1492  msg = va_arg(args, char *);
1493  map = va_arg(args, mapstruct *);
1494  x = va_arg(args, int);
1495  y = va_arg(args, int);
1496  robj = va_arg(args, object **);
1497 
1498  va_end(args);
1499 
1500  *robj = present_arch(try_find_archetype(msg), map, x, y);
1501  *type = CFAPI_POBJECT;
1502  return NULL;
1503 }
1504 
1512 void *cfapi_map_change_light(int *type, ...) {
1513  va_list args;
1514  int change;
1515  mapstruct *map;
1516  int *rint;
1517 
1518  va_start(args, type);
1519  map = va_arg(args, mapstruct *);
1520  change = va_arg(args, int);
1521  rint = va_arg(args, int *);
1522  va_end(args);
1523 
1524  *type = CFAPI_INT;
1525  *rint = change_map_light(map, change);
1526 
1527  return NULL;
1528 }
1529 
1530 /* OBJECT-RELATED HOOKS */
1531 
1546 void *cfapi_object_move(int *type, ...) {
1547  va_list args;
1548  int kind;
1549  object *op;
1550  object *activator;
1551  player *pl;
1552  int direction;
1553  int *ret;
1554 
1555  va_start(args, type);
1556  kind = va_arg(args, int);
1557  switch (kind) {
1558  case 0:
1559  op = va_arg(args, object *);
1560  direction = va_arg(args, int);
1561  activator = va_arg(args, object *);
1562  ret = va_arg(args, int *);
1563  va_end(args);
1564  *ret = move_ob(op, direction, activator);
1565  break;
1566 
1567  case 1:
1568  pl = va_arg(args, player *);
1569  direction = va_arg(args, int);
1570  ret = va_arg(args, int *);
1571  va_end(args);
1572  *ret = move_player(pl->ob, direction);
1573  break;
1574  }
1575  *type = CFAPI_INT;
1576  return NULL;
1577 }
1578 
1588 void *cfapi_object_get_key(int *type, ...) {
1589  va_list args;
1590  const char *keyname;
1591  const char **value;
1592  object *op;
1593 
1594  va_start(args, type);
1595  op = va_arg(args, object *);
1596  keyname = va_arg(args, const char *);
1597  value = va_arg(args, const char **);
1598  va_end(args);
1599 
1600  *value = get_ob_key_value(op, keyname);
1601  *type = CFAPI_SSTRING;
1602  return NULL;
1603 }
1604 
1613 void *cfapi_object_set_key(int *type, ...) {
1614  va_list args;
1615  const char *keyname;
1616  const char *value;
1617  int *ret;
1618  object *op;
1619  int add_key;
1620 
1621  va_start(args, type);
1622  op = va_arg(args, object *);
1623  keyname = va_arg(args, char *);
1624  value = va_arg(args, char *);
1625  add_key = va_arg(args, int);
1626  ret = va_arg(args, int *);
1627  va_end(args);
1628 
1629  *ret = set_ob_key_value(op, keyname, value, add_key);
1630  *type = CFAPI_INT;
1631  return NULL;
1632 }
1633 
1637 void *cfapi_object_get_property(int *type, ...) {
1638  va_list args;
1639  int property;
1640  object *op;
1641  int *rint;
1642  object **robject;
1643  mapstruct **rmap;
1644  float *rfloat;
1645  archetype **rarch;
1646  sstring *rsstring;
1647  char *rbuffer;
1648  int rbufsize;
1649  MoveType *rmove;
1650  sint64 *rint64;
1651  partylist **rparty;
1652  double *rdouble;
1653  long *rlong;
1654 
1655  va_start(args, type);
1656 
1657  op = va_arg(args, object *);
1658  property = va_arg(args, int);
1659  switch (property) {
1661  robject = va_arg(args, object **);
1662  *robject = op->above;
1663  *type = CFAPI_POBJECT;
1664  break;
1665 
1667  robject = va_arg(args, object **);
1668  *robject = op->below;
1669  *type = CFAPI_POBJECT;
1670  break;
1671 
1673  robject = va_arg(args, object **);
1674  *robject = op->active_next;
1675  *type = CFAPI_POBJECT;
1676  break;
1677 
1679  robject = va_arg(args, object **);
1680  *robject = op->active_prev;
1681  *type = CFAPI_POBJECT;
1682  break;
1683 
1685  robject = va_arg(args, object **);
1686  *robject = op->inv;
1687  *type = CFAPI_POBJECT;
1688  break;
1689 
1691  robject = va_arg(args, object **);
1692  *robject = op->env;
1693  *type = CFAPI_POBJECT;
1694  break;
1695 
1697  robject = va_arg(args, object **);
1698  *robject = op->head;
1699  *type = CFAPI_POBJECT;
1700  break;
1701 
1703  robject = va_arg(args, object **);
1704  *robject = op->container;
1705  *type = CFAPI_POBJECT;
1706  break;
1707 
1708  case CFAPI_OBJECT_PROP_MAP:
1709  rmap = va_arg(args, mapstruct **);
1710  *rmap = op->map;
1711  *type = CFAPI_PMAP;
1712  break;
1713 
1715  rint = va_arg(args, int *);
1716  *rint = op->count;
1717  *type = CFAPI_INT;
1718  break;
1719 
1721  rbuffer = va_arg(args, char *);
1722  rbufsize = va_arg(args, int);
1723  query_name(op, rbuffer, rbufsize);
1724  *type = CFAPI_STRING;
1725  break;
1726 
1728  rsstring = va_arg(args, sstring *);
1729  *rsstring = op->name_pl;
1730  *type = CFAPI_SSTRING;
1731  break;
1732 
1734  rsstring = va_arg(args, sstring *);
1735  *rsstring = op->title;
1736  *type = CFAPI_SSTRING;
1737  break;
1738 
1740  rsstring = va_arg(args, sstring *);
1741  *rsstring = op->race;
1742  *type = CFAPI_SSTRING;
1743  break;
1744 
1746  rsstring = va_arg(args, sstring *);
1747  *rsstring = op->slaying;
1748  *type = CFAPI_SSTRING;
1749  break;
1750 
1752  rsstring = va_arg(args, sstring *);
1753  *rsstring = op->skill;
1754  *type = CFAPI_SSTRING;
1755  break;
1756 
1758  rsstring = va_arg(args, sstring *);
1759  *rsstring = op->msg;
1760  *type = CFAPI_SSTRING;
1761  break;
1762 
1764  rsstring = va_arg(args, sstring *);
1765  *rsstring = op->lore;
1766  *type = CFAPI_SSTRING;
1767  break;
1768 
1769  case CFAPI_OBJECT_PROP_X:
1770  rint = va_arg(args, int *);
1771  *rint = op->x;
1772  *type = CFAPI_INT;
1773  break;
1774 
1775  case CFAPI_OBJECT_PROP_Y:
1776  rint = va_arg(args, int *);
1777  *rint = op->y;
1778  *type = CFAPI_INT;
1779  break;
1780 
1782  rfloat = va_arg(args, float *);
1783  *rfloat = op->speed;
1784  *type = CFAPI_FLOAT;
1785  break;
1786 
1788  rfloat = va_arg(args, float *);
1789  *rfloat = op->speed_left;
1790  *type = CFAPI_FLOAT;
1791  break;
1792 
1794  rint = va_arg(args, int *);
1795  *rint = op->nrof;
1796  *type = CFAPI_INT;
1797  break;
1798 
1800  rint = va_arg(args, int *);
1801  *rint = op->direction;
1802  *type = CFAPI_INT;
1803  break;
1804 
1806  rint = va_arg(args, int *);
1807  *rint = op->facing;
1808  *type = CFAPI_INT;
1809  break;
1810 
1812  rint = va_arg(args, int *);
1813  *rint = op->type;
1814  *type = CFAPI_INT;
1815  break;
1816 
1818  rint = va_arg(args, int *);
1819  *rint = op->subtype;
1820  *type = CFAPI_INT;
1821  break;
1822 
1824  rint = va_arg(args, int *);
1825  *rint = op->client_type;
1826  *type = CFAPI_INT;
1827  break;
1828 
1829  case CFAPI_OBJECT_PROP_RESIST: {
1830  int idx;
1831  sint16 *resist;
1832 
1833  idx = va_arg(args, int);
1834  resist = va_arg(args, sint16 *);
1835  *resist = op->resist[idx];
1836  }
1837  *type = CFAPI_INT16;
1838  break;
1839 
1841  rint = va_arg(args, int *);
1842  *rint = op->attacktype;
1843  *type = CFAPI_INT;
1844  break;
1845 
1847  rint = va_arg(args, int *);
1848  *rint = op->path_attuned;
1849  *type = CFAPI_INT;
1850  break;
1851 
1853  rint = va_arg(args, int *);
1854  *rint = op->path_repelled;
1855  *type = CFAPI_INT;
1856  break;
1857 
1859  rint = va_arg(args, int *);
1860  *rint = op->path_denied;
1861  *type = CFAPI_INT;
1862  break;
1863 
1865  rint = va_arg(args, int *);
1866  *rint = op->material;
1867  *type = CFAPI_INT;
1868  break;
1869 
1871  rsstring = va_arg(args, sstring *);
1872  *rsstring = op->materialname;
1873  *type = CFAPI_SSTRING;
1874  break;
1875 
1877  rint = va_arg(args, int *);
1878  *rint = op->magic;
1879  *type = CFAPI_INT;
1880  break;
1881 
1883  rlong = va_arg(args, long *);
1884  *rlong = op->value;
1885  *type = CFAPI_LONG;
1886  break;
1887 
1889  rint = va_arg(args, int *);
1890  *rint = op->level;
1891  *type = CFAPI_INT;
1892  break;
1893 
1895  rint = va_arg(args, int *);
1896  *rint = op->last_heal;
1897  *type = CFAPI_INT;
1898  break;
1899 
1901  rint = va_arg(args, int *);
1902  *rint = op->last_sp;
1903  *type = CFAPI_INT;
1904  break;
1905 
1907  rint = va_arg(args, int *);
1908  *rint = op->last_grace;
1909  *type = CFAPI_INT;
1910  break;
1911 
1913  rint = va_arg(args, int *);
1914  *rint = op->last_eat;
1915  *type = CFAPI_INT;
1916  break;
1917 
1919  rint = va_arg(args, int *);
1920  *rint = op->invisible;
1921  *type = CFAPI_INT;
1922  break;
1923 
1925  rint = va_arg(args, int *);
1926  *rint = op->pick_up;
1927  *type = CFAPI_INT;
1928  break;
1929 
1931  rint = va_arg(args, int *);
1932  *rint = op->item_power;
1933  *type = CFAPI_INT;
1934  break;
1935 
1937  rint = va_arg(args, int *);
1938  *rint = op->gen_sp_armour;
1939  *type = CFAPI_INT;
1940  break;
1941 
1943  rint = va_arg(args, int *);
1944  *rint = op->weight;
1945  *type = CFAPI_INT;
1946  break;
1947 
1949  rint = va_arg(args, int *);
1950  *rint = op->weight_limit;
1951  *type = CFAPI_INT;
1952  break;
1953 
1955  rint = va_arg(args, int *);
1956  *rint = op->carrying;
1957  *type = CFAPI_INT;
1958  break;
1959 
1961  rint = va_arg(args, int *);
1962  *rint = op->glow_radius;
1963  *type = CFAPI_INT;
1964  break;
1965 
1967  rint64 = va_arg(args, sint64 *);
1968  *rint64 = op->perm_exp;
1969  *type = CFAPI_SINT64;
1970  break;
1971 
1973  robject = va_arg(args, object **);
1974  *robject = op->current_weapon;
1975  *type = CFAPI_POBJECT;
1976  break;
1977 
1979  robject = va_arg(args, object **);
1980  *robject = op->enemy;
1981  *type = CFAPI_POBJECT;
1982  break;
1983 
1985  robject = va_arg(args, object **);
1986  *robject = op->attacked_by;
1987  *type = CFAPI_POBJECT;
1988  break;
1989 
1991  rint = va_arg(args, int *);
1992  *rint = op->run_away;
1993  *type = CFAPI_INT;
1994  break;
1995 
1997  robject = va_arg(args, object **);
1998  *robject = op->chosen_skill;
1999  *type = CFAPI_POBJECT;
2000  break;
2001 
2003  rint = va_arg(args, int *);
2004  *rint = op->hide;
2005  *type = CFAPI_INT;
2006  break;
2007 
2009  rint = va_arg(args, int *);
2010  *rint = op->move_status;
2011  *type = CFAPI_INT;
2012  break;
2013 
2015  rint = va_arg(args, int *);
2016  *rint = op->attack_movement;
2017  *type = CFAPI_INT;
2018  break;
2019 
2021  robject = va_arg(args, object **);
2022  *robject = op->spellitem;
2023  *type = CFAPI_POBJECT;
2024  break;
2025 
2027  rdouble = va_arg(args, double *);
2028  *rdouble = op->expmul;
2029  *type = CFAPI_DOUBLE;
2030  break;
2031 
2033  rarch = va_arg(args, archetype **);
2034  *rarch = op->arch;
2035  *type = CFAPI_PARCH;
2036  break;
2037 
2039  rarch = va_arg(args, archetype **);
2040  *rarch = op->other_arch;
2041  *type = CFAPI_PARCH;
2042  break;
2043 
2045  rsstring = va_arg(args, sstring *);
2046  *rsstring = (char *)op->custom_name;
2047  *type = CFAPI_SSTRING;
2048  break;
2049 
2051  rint = va_arg(args, int *);
2052  *rint = op->anim_speed;
2053  *type = CFAPI_INT;
2054  break;
2055 
2057  rint = va_arg(args, int *);
2058  *rint = is_friendly(op);
2059  *type = CFAPI_INT;
2060  break;
2061 
2063  rbuffer = va_arg(args, char *);
2064  rbufsize = va_arg(args, int);
2065  query_short_name(op, rbuffer, rbufsize);
2066  *type = CFAPI_STRING;
2067  break;
2068 
2070  int i;
2071 
2072  i = va_arg(args, int);
2073  rbuffer = va_arg(args, char *);
2074  rbufsize = va_arg(args, int);
2075  query_base_name(op, i, rbuffer, rbufsize);
2076  *type = CFAPI_STRING;
2077  }
2078  break;
2079 
2081  rint = va_arg(args, int *);
2082  *rint = is_magical(op);
2083  *type = CFAPI_INT;
2084  break;
2085 
2087  rint = va_arg(args, int *);
2088  *rint = op->stats.luck;
2089  *type = CFAPI_INT;
2090  break;
2091 
2092  case CFAPI_OBJECT_PROP_EXP:
2093  rint64 = va_arg(args, sint64 *);
2094  *rint64 = op->stats.exp;
2095  *type = CFAPI_SINT64;
2096  break;
2097 
2099  robject = va_arg(args, object **);
2100  *robject = get_owner(op);
2101  *type = CFAPI_POBJECT;
2102  break;
2103 
2105  int stype;
2106 
2107  stype = va_arg(args, int);
2108  switch (stype) {
2109  unsigned char ptype;
2110  char *buf;
2111  archetype *at;
2112 
2113  case 0: /* present_in_ob */
2114  ptype = (unsigned char)(va_arg(args, int));
2115  robject = va_arg(args, object **);
2116  *robject = present_in_ob(ptype, op);
2117  break;
2118 
2119  case 1: /* present_in_ob_by_name */
2120  ptype = (unsigned char)(va_arg(args, int));
2121  buf = va_arg(args, char *);
2122  robject = va_arg(args, object **);
2123  *robject = present_in_ob_by_name(ptype, buf, op);
2124  break;
2125 
2126  case 2: /* present_arch_in_ob */
2127  at = va_arg(args, archetype *);
2128  robject = va_arg(args, object **);
2129  *robject = present_arch_in_ob(at, op);
2130  break;
2131  }
2132  }
2133  *type = CFAPI_POBJECT;
2134  break;
2135 
2137  rint = va_arg(args, int *);
2138  *rint = (QUERY_FLAG(op, FLAG_WAS_WIZ));
2139  *type = CFAPI_INT;
2140  break;
2141 
2143  object *op2;
2144 
2145  op2 = va_arg(args, object *);
2146  rint = va_arg(args, int *);
2147  *rint = can_merge(op, op2);
2148  }
2149  *type = CFAPI_INT;
2150  break;
2151 
2153  object *op2;
2154 
2155  op2 = va_arg(args, object *);
2156  rint = va_arg(args, int *);
2157  *rint = can_pick(op2, op);
2158  }
2159  *type = CFAPI_INT;
2160  break;
2161 
2162  case CFAPI_OBJECT_PROP_FLAGS: {
2163  int fl;
2164 
2165  fl = va_arg(args, int);
2166  rint = va_arg(args, int *);
2167  *rint = QUERY_FLAG(op, fl);
2168  }
2169  *type = CFAPI_INT;
2170  break;
2171 
2172  case CFAPI_OBJECT_PROP_STR:
2173  rint = va_arg(args, int *);
2174  *rint = op->stats.Str;
2175  *type = CFAPI_INT;
2176  break;
2177 
2178  case CFAPI_OBJECT_PROP_DEX:
2179  rint = va_arg(args, int *);
2180  *rint = op->stats.Dex;
2181  *type = CFAPI_INT;
2182  break;
2183 
2184  case CFAPI_OBJECT_PROP_CON:
2185  rint = va_arg(args, int *);
2186  *rint = op->stats.Con;
2187  *type = CFAPI_INT;
2188  break;
2189 
2190  case CFAPI_OBJECT_PROP_WIS:
2191  rint = va_arg(args, int *);
2192  *rint = op->stats.Wis;
2193  *type = CFAPI_INT;
2194  break;
2195 
2196  case CFAPI_OBJECT_PROP_INT:
2197  rint = va_arg(args, int *);
2198  *rint = op->stats.Int;
2199  *type = CFAPI_INT;
2200  break;
2201 
2202  case CFAPI_OBJECT_PROP_POW:
2203  rint = va_arg(args, int *);
2204  *rint = op->stats.Pow;
2205  *type = CFAPI_INT;
2206  break;
2207 
2208  case CFAPI_OBJECT_PROP_CHA:
2209  rint = va_arg(args, int *);
2210  *rint = op->stats.Cha;
2211  *type = CFAPI_INT;
2212  break;
2213 
2214  case CFAPI_OBJECT_PROP_WC:
2215  rint = va_arg(args, int *);
2216  *rint = op->stats.wc;
2217  *type = CFAPI_INT;
2218  break;
2219 
2220  case CFAPI_OBJECT_PROP_AC:
2221  rint = va_arg(args, int *);
2222  *rint = op->stats.ac;
2223  *type = CFAPI_INT;
2224  break;
2225 
2226  case CFAPI_OBJECT_PROP_HP:
2227  rint = va_arg(args, int *);
2228  *rint = op->stats.hp;
2229  *type = CFAPI_INT;
2230  break;
2231 
2232  case CFAPI_OBJECT_PROP_SP:
2233  rint = va_arg(args, int *);
2234  *rint = op->stats.sp;
2235  *type = CFAPI_INT;
2236  break;
2237 
2238  case CFAPI_OBJECT_PROP_GP:
2239  rint = va_arg(args, int *);
2240  *rint = op->stats.grace;
2241  *type = CFAPI_INT;
2242  break;
2243 
2244  case CFAPI_OBJECT_PROP_FP:
2245  rint = va_arg(args, int *);
2246  *rint = op->stats.food;
2247  *type = CFAPI_INT;
2248  break;
2249 
2251  rint = va_arg(args, int *);
2252  *rint = op->stats.maxhp;
2253  *type = CFAPI_INT;
2254  break;
2255 
2257  rint = va_arg(args, int *);
2258  *rint = op->stats.maxsp;
2259  *type = CFAPI_INT;
2260  break;
2261 
2263  rint = va_arg(args, int *);
2264  *rint = op->stats.maxgrace;
2265  *type = CFAPI_INT;
2266  break;
2267 
2268  case CFAPI_OBJECT_PROP_DAM:
2269  rint = va_arg(args, int *);
2270  *rint = op->stats.dam;
2271  *type = CFAPI_INT;
2272  break;
2273 
2274  case CFAPI_OBJECT_PROP_GOD:
2275  rsstring = va_arg(args, sstring *);
2276  *rsstring = determine_god(op);
2277  *type = CFAPI_SSTRING;
2278  break;
2279 
2281  rsstring = va_arg(args, sstring *);
2282  *rsstring = op->arch->name;
2283  *type = CFAPI_SSTRING;
2284  break;
2285 
2287  rint = va_arg(args, int *);
2288  *rint = op->invisible;
2289  *type = CFAPI_INT;
2290  break;
2291 
2293  rint = va_arg(args, int *);
2294  *rint = op->face->number;
2295  *type = CFAPI_INT;
2296  break;
2297 
2299  rint = va_arg(args, int *);
2300  *rint = op->animation_id;
2301  *type = CFAPI_INT;
2302  break;
2303 
2304  case CFAPI_PLAYER_PROP_IP:
2305  rsstring = va_arg(args, sstring *);
2306  *rsstring = op->contr->socket.host;
2307  *type = CFAPI_SSTRING;
2308  break;
2309 
2311  robject = va_arg(args, object **);
2312  *robject = find_marked_object(op);
2313  *type = CFAPI_POBJECT;
2314  break;
2315 
2317  rparty = va_arg(args, partylist **);
2318  *rparty = (op->contr ? op->contr->party : NULL);
2319  *type = CFAPI_PPARTY;
2320  break;
2321 
2323  robject = va_arg(args, object **);
2324  if (op)
2325  *robject = op->contr->next ? op->contr->next->ob : NULL;
2326  else
2327  /* This can be called when there is no player. */
2328  *robject = first_player ? first_player->ob : NULL;
2329  *type = CFAPI_POBJECT;
2330  break;
2331 
2333  rsstring = va_arg(args, sstring *);
2334  *rsstring = op->contr->title;
2335  *type = CFAPI_SSTRING;
2336  break;
2337 
2339  rint = va_arg(args, int *);
2340  *rint = op->no_save;
2341  *type = CFAPI_INT;
2342  break;
2343 
2345  rmove = va_arg(args, MoveType *);
2346  *rmove = op->move_type;
2347  *type = CFAPI_MOVETYPE;
2348  break;
2349 
2351  rmove = va_arg(args, MoveType *);
2352  *rmove = op->move_block;
2353  *type = CFAPI_MOVETYPE;
2354  break;
2355 
2357  rmove = va_arg(args, MoveType *);
2358  *rmove = op->move_allow;
2359  *type = CFAPI_MOVETYPE;
2360  break;
2361 
2363  rmove = va_arg(args, MoveType *);
2364  *rmove = op->move_on;
2365  *type = CFAPI_MOVETYPE;
2366  break;
2367 
2369  rmove = va_arg(args, MoveType *);
2370  *rmove = op->move_off;
2371  *type = CFAPI_MOVETYPE;
2372  break;
2373 
2375  rmove = va_arg(args, MoveType *);
2376  *rmove = op->move_type;
2377  *type = CFAPI_MOVETYPE;
2378  break;
2379 
2381  rfloat = va_arg(args, float *);
2382  *rfloat = op->move_slow_penalty;
2383  *type = CFAPI_FLOAT;
2384  break;
2385 
2387  rbuffer = va_arg(args, char *);
2388  rbufsize = va_arg(args, int);
2389  snprintf(rbuffer, rbufsize, "%s", op->contr->savebed_map);
2390  *type = CFAPI_STRING;
2391  break;
2392 
2394  rint = va_arg(args, int *);
2395  *rint = op->contr->bed_x;
2396  *type = CFAPI_INT;
2397  break;
2398 
2400  rint = va_arg(args, int *);
2401  *rint = op->contr->bed_y;
2402  *type = CFAPI_INT;
2403  break;
2404 
2406  rint = va_arg(args, int *);
2407  *rint = op->duration;
2408  *type = CFAPI_INT;
2409  break;
2410 
2411  default:
2412  *type = CFAPI_NONE;
2413  break;
2414  }
2415  va_end(args);
2416  return NULL;
2417 }
2418 
2427 static void copy_message(object *op, const char *msg) {
2428  char *temp;
2429  int size;
2430 
2431  if (!msg)
2432  return;
2433 
2434  size = strlen(msg);
2435 
2436  if (msg[0] != 0 && msg[size-1] == '\n') {
2437  FREE_AND_COPY(op->msg, msg);
2438  return;
2439  }
2440 
2441  temp = malloc(size+2);
2442  if (!temp)
2444  snprintf(temp, size+2, "%s\n", msg);
2445  FREE_AND_COPY(op->msg, temp);
2446  free(temp);
2447 }
2448 
2459 void *cfapi_object_set_property(int *type, ...) {
2460  va_list args;
2461  int iarg;
2462  long larg;
2463  char *sarg;
2464  double darg;
2465  object *oparg;
2466  object *op;
2467  int property;
2468  sint64 s64arg;
2469  partylist *partyarg;
2470  float farg;
2471 
2472  va_start(args, type);
2473  op = va_arg(args, object *);
2474  property = va_arg(args, int);
2475  *type = CFAPI_NONE;
2476 
2477  if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
2478  switch (property) {
2480  sarg = va_arg(args, char *);
2481  *type = CFAPI_STRING;
2482  FREE_AND_COPY(op->name, sarg);
2483  send_changed_object(op);
2484  break;
2485 
2487  sarg = va_arg(args, char *);
2488  *type = CFAPI_STRING;
2489  FREE_AND_COPY(op->name_pl, sarg);
2490  send_changed_object(op);
2491  break;
2492 
2494  sarg = va_arg(args, char *);
2495  *type = CFAPI_STRING;
2496  FREE_AND_COPY(op->title, sarg);
2497  break;
2498 
2500  sarg = va_arg(args, char *);
2501  *type = CFAPI_STRING;
2502  FREE_AND_COPY(op->race, sarg);
2503  break;
2504 
2506  sarg = va_arg(args, char *);
2507  *type = CFAPI_STRING;
2508  FREE_AND_COPY(op->slaying, sarg);
2509  break;
2510 
2512  sarg = va_arg(args, char *);
2513  *type = CFAPI_STRING;
2514  FREE_AND_COPY(op->skill, sarg);
2515  break;
2516 
2518  sarg = va_arg(args, char *);
2519  *type = CFAPI_STRING;
2520  copy_message(op, sarg);
2521  break;
2522 
2524  sarg = va_arg(args, char *);
2525  *type = CFAPI_STRING;
2526  FREE_AND_COPY(op->lore, sarg);
2527  break;
2528 
2530  farg = va_arg(args, double);
2531  *type = CFAPI_FLOAT;
2532  if (farg != op->speed) {
2533  op->speed = farg;
2534  update_ob_speed(op);
2535  }
2536  break;
2537 
2539  farg = va_arg(args, double);
2540  *type = CFAPI_FLOAT;
2541  op->speed_left = farg;
2542  break;
2543 
2545  iarg = va_arg(args, int);
2546  *type = CFAPI_INT;
2547  if (iarg < 0)
2548  iarg = 0;
2549  if (op->nrof > (uint32)iarg)
2550  decrease_ob_nr(op, op->nrof-iarg);
2551  else if (op->nrof < (uint32)iarg) {
2552  object *tmp;
2553  player *pl;
2554 
2555  op->nrof = iarg;
2556  if (op->env != NULL) {
2557  tmp = get_player_container(op->env);
2558  if (!tmp) {
2559  for (pl = first_player; pl; pl = pl->next)
2560  if (pl->ob->container == op->env)
2561  break;
2562  if (pl)
2563  tmp = pl->ob;
2564  else
2565  tmp = NULL;
2566  } else {
2567  sum_weight(tmp);
2568  fix_object(tmp);
2569  }
2570  if (tmp)
2571  esrv_update_item(UPD_NROF, tmp, op);
2572  } else {
2573  object *above = op->above;
2574 
2575  for (tmp = above; tmp != NULL; tmp = tmp->above)
2576  if (tmp->type == PLAYER)
2577  tmp->contr->socket.update_look = 1;
2578  }
2579  }
2580  break;
2581 
2583  iarg = va_arg(args, int);
2584  *type = CFAPI_INT;
2585  op->direction = iarg;
2586  break;
2587 
2589  iarg = va_arg(args, int);
2590  *type = CFAPI_INT;
2591  op->facing = iarg;
2592  break;
2593 
2594  case CFAPI_OBJECT_PROP_RESIST: {
2595  int iargbis = va_arg(args, int);
2596 
2597  *type = CFAPI_INT16;
2598  iarg = va_arg(args, int);
2599  op->resist[iargbis] = iarg;
2600  }
2601  break;
2602 
2604  iarg = va_arg(args, int);
2605  *type = CFAPI_INT;
2606  op->attacktype = iarg;
2607  break;
2608 
2610  iarg = va_arg(args, int);
2611  *type = CFAPI_INT;
2612  op->path_attuned = iarg;
2613  break;
2614 
2616  iarg = va_arg(args, int);
2617  *type = CFAPI_INT;
2618  op->path_repelled = iarg;
2619  break;
2620 
2622  iarg = va_arg(args, int);
2623  *type = CFAPI_INT;
2624  op->path_denied = iarg;
2625  break;
2626 
2628  iarg = va_arg(args, int);
2629  *type = CFAPI_INT;
2630  op->material = iarg;
2631  break;
2632 
2634  break;
2635 
2637  iarg = va_arg(args, int);
2638  *type = CFAPI_INT;
2639  op->magic = iarg;
2640  break;
2641 
2643  larg = va_arg(args, long);
2644  *type = CFAPI_LONG;
2645  op->value = larg;
2646  break;
2647 
2649  iarg = va_arg(args, int);
2650  *type = CFAPI_INT;
2651  op->level = iarg;
2652  break;
2653 
2655  iarg = va_arg(args, int);
2656  *type = CFAPI_INT;
2657  op->last_heal = iarg;
2658  break;
2659 
2661  iarg = va_arg(args, int);
2662  *type = CFAPI_INT;
2663  op->last_sp = iarg;
2664  break;
2665 
2667  iarg = va_arg(args, int);
2668  *type = CFAPI_INT;
2669  op->last_grace = iarg;
2670  break;
2671 
2673  iarg = va_arg(args, int);
2674  *type = CFAPI_INT;
2675  op->last_eat = iarg;
2676  break;
2677 
2679  iarg = va_arg(args, int);
2680  *type = CFAPI_INT;
2681  op->invisible = iarg;
2682  break;
2683 
2685  iarg = va_arg(args, int);
2686  *type = CFAPI_INT;
2687  op->pick_up = iarg;
2688  break;
2689 
2691  iarg = va_arg(args, int);
2692  *type = CFAPI_INT;
2693  op->item_power = iarg;
2694  break;
2695 
2697  iarg = va_arg(args, int);
2698  *type = CFAPI_INT;
2699  op->gen_sp_armour = iarg;
2700  break;
2701 
2703  iarg = va_arg(args, int);
2704  *type = CFAPI_INT;
2705  if (op->weight != iarg) {
2706  object *tmp;
2707  player *pl;
2708 
2709  op->weight = iarg;
2710  if (op->env != NULL) {
2711  tmp = get_player_container(op->env);
2712  if (!tmp) {
2713  for (pl = first_player; pl; pl = pl->next)
2714  if (pl->ob->container == op->env)
2715  break;
2716  if (pl)
2717  tmp = pl->ob;
2718  else
2719  tmp = NULL;
2720  } else {
2721  sum_weight(tmp);
2722  fix_object(tmp);
2723  }
2724  if (tmp)
2725  esrv_update_item(UPD_WEIGHT, tmp, op);
2726  } else {
2727  object *above = op->above;
2728 
2729  for (tmp = above; tmp != NULL; tmp = tmp->above)
2730  if (tmp->type == PLAYER)
2731  esrv_update_item(UPD_WEIGHT, tmp, op);
2732  }
2733  }
2734  break;
2735 
2737  iarg = va_arg(args, int);
2738  *type = CFAPI_INT;
2739  op->weight_limit = iarg;
2740  break;
2741 
2743  iarg = va_arg(args, int);
2744  *type = CFAPI_INT;
2745  if (op->glow_radius != iarg) {
2746  object *tmp;
2747 
2748  op->glow_radius = iarg;
2749  tmp = object_get_env_recursive(op);
2750  if (tmp->map != NULL) {
2751  SET_MAP_FLAGS(tmp->map, tmp->x, tmp->y, P_NEED_UPDATE);
2752  update_position(tmp->map, tmp->x, tmp->y);
2753  update_all_los(tmp->map, tmp->x, tmp->y);
2754  }
2755  }
2756  break;
2757 
2759  s64arg = va_arg(args, sint64);
2760  *type = CFAPI_SINT64;
2761  op->perm_exp = s64arg;
2762  break;
2763 
2765  oparg = va_arg(args, object *);
2766  *type = CFAPI_POBJECT;
2767  op->enemy = oparg;
2768  break;
2769 
2771  iarg = va_arg(args, int);
2772  *type = CFAPI_INT;
2773  op->run_away = iarg;
2774  break;
2775 
2777  oparg = va_arg(args, object *);
2778  *type = CFAPI_POBJECT;
2779  op->chosen_skill = oparg;
2780  break;
2781 
2783  iarg = va_arg(args, int);
2784  *type = CFAPI_INT;
2785  op->hide = iarg;
2786  break;
2787 
2789  iarg = va_arg(args, int);
2790  *type = CFAPI_INT;
2791  op->move_status = iarg;
2792  break;
2793 
2795  iarg = va_arg(args, int);
2796  *type = CFAPI_INT;
2797  op->attack_movement = iarg;
2798  break;
2799 
2801  oparg = va_arg(args, object *);
2802  *type = CFAPI_POBJECT;
2803  op->spellitem = oparg;
2804  break;
2805 
2807  darg = va_arg(args, double);
2808  *type = CFAPI_DOUBLE;
2809  op->expmul = darg;
2810  break;
2811 
2813  sarg = va_arg(args, char *);
2814  *type = CFAPI_STRING;
2815  FREE_AND_COPY(op->custom_name, sarg);
2816  send_changed_object(op);
2817  break;
2818 
2820  iarg = va_arg(args, int);
2821  *type = CFAPI_INT;
2822  op->anim_speed = iarg;
2823  break;
2824 
2826  iarg = va_arg(args, int);
2827  *type = CFAPI_INT;
2828  if (iarg == 1 && is_friendly(op) == 0)
2829  add_friendly_object(op);
2830  else if (iarg == 0 && is_friendly(op) == 1)
2832  break;
2833 
2835  iarg = va_arg(args, int);
2836  *type = CFAPI_INT;
2837  op->stats.luck = iarg;
2838  break;
2839 
2840  case CFAPI_OBJECT_PROP_EXP:
2841  s64arg = va_arg(args, sint64);
2842  *type = CFAPI_SINT64;
2843  op->stats.exp = s64arg;
2844  break;
2845 
2847  oparg = va_arg(args, object *);
2848  *type = CFAPI_POBJECT;
2849  set_owner(op, oparg);
2850  break;
2851 
2853  set_cheat(op);
2854  *type = CFAPI_NONE;
2855  break;
2856 
2857  case CFAPI_OBJECT_PROP_FLAGS: {
2858  int iargbis;
2859 
2860  iarg = va_arg(args, int);
2861  iargbis = va_arg(args, int);
2862  *type = CFAPI_INT;
2863 
2864  if (iargbis == 1)
2865  SET_FLAG(op, iarg);
2866  else
2867  CLEAR_FLAG(op, iarg);
2868  }
2869  break;
2870 
2871  case CFAPI_OBJECT_PROP_STR:
2872  iarg = va_arg(args, int);
2873  *type = CFAPI_INT;
2874  op->stats.Str = iarg;
2875  break;
2876 
2877  case CFAPI_OBJECT_PROP_DEX:
2878  iarg = va_arg(args, int);
2879  *type = CFAPI_INT;
2880  op->stats.Dex = iarg;
2881  break;
2882 
2883  case CFAPI_OBJECT_PROP_CON:
2884  iarg = va_arg(args, int);
2885  *type = CFAPI_INT;
2886  op->stats.Con = iarg;
2887  break;
2888 
2889  case CFAPI_OBJECT_PROP_WIS:
2890  iarg = va_arg(args, int);
2891  *type = CFAPI_INT;
2892  op->stats.Wis = iarg;
2893  break;
2894 
2895  case CFAPI_OBJECT_PROP_INT:
2896  iarg = va_arg(args, int);
2897  *type = CFAPI_INT;
2898  op->stats.Int = iarg;
2899  break;
2900 
2901  case CFAPI_OBJECT_PROP_POW:
2902  iarg = va_arg(args, int);
2903  *type = CFAPI_INT;
2904  op->stats.Pow = iarg;
2905  break;
2906 
2907  case CFAPI_OBJECT_PROP_CHA:
2908  iarg = va_arg(args, int);
2909  *type = CFAPI_INT;
2910  op->stats.Cha = iarg;
2911  break;
2912 
2913  case CFAPI_OBJECT_PROP_WC:
2914  iarg = va_arg(args, int);
2915  *type = CFAPI_INT;
2916  op->stats.wc = iarg;
2917  break;
2918 
2919  case CFAPI_OBJECT_PROP_AC:
2920  iarg = va_arg(args, int);
2921  *type = CFAPI_INT;
2922  op->stats.ac = iarg;
2923  break;
2924 
2925  case CFAPI_OBJECT_PROP_HP:
2926  iarg = va_arg(args, int);
2927  *type = CFAPI_INT;
2928  op->stats.hp = iarg;
2929  break;
2930 
2931  case CFAPI_OBJECT_PROP_SP:
2932  iarg = va_arg(args, int);
2933  *type = CFAPI_INT;
2934  op->stats.sp = iarg;
2935  break;
2936 
2937  case CFAPI_OBJECT_PROP_GP:
2938  iarg = va_arg(args, int);
2939  *type = CFAPI_INT;
2940  op->stats.grace = iarg;
2941  break;
2942 
2943  case CFAPI_OBJECT_PROP_FP:
2944  iarg = va_arg(args, int);
2945  *type = CFAPI_INT;
2946  op->stats.food = iarg;
2947  break;
2948 
2950  iarg = va_arg(args, int);
2951  *type = CFAPI_INT;
2952  op->stats.maxhp = iarg;
2953  break;
2954 
2956  iarg = va_arg(args, int);
2957  *type = CFAPI_INT;
2958  op->stats.maxsp = iarg;
2959  break;
2960 
2962  iarg = va_arg(args, int);
2963  *type = CFAPI_INT;
2964  op->stats.maxgrace = iarg;
2965  break;
2966 
2967  case CFAPI_OBJECT_PROP_DAM:
2968  iarg = va_arg(args, int);
2969  *type = CFAPI_INT;
2970  op->stats.dam = iarg;
2971  break;
2972 
2974  iarg = va_arg(args, int);
2975  *type = CFAPI_INT;
2976  op->face = &new_faces[iarg];
2977  op->state = 0;
2979  break;
2980 
2982  iarg = va_arg(args, int);
2983  *type = CFAPI_INT;
2984  op->animation_id = iarg;
2985  SET_ANIMATION(op, 0);
2987  break;
2988 
2990  iarg = va_arg(args, int);
2991  *type = CFAPI_INT;
2992  op->duration = iarg;
2993  break;
2994 
2996  if (op->contr) {
2997  oparg = va_arg(args, object *);
2998  *type = CFAPI_POBJECT;
2999  op->contr->mark = oparg;
3000  if (oparg)
3001  op->contr->mark_count = oparg->count;
3002  }
3003  break;
3004 
3006  if (op->contr) {
3007  partyarg = va_arg(args, partylist *);
3008  *type = CFAPI_PPARTY;
3009  op->contr->party = partyarg;
3010  }
3011  break;
3012 
3014  iarg = va_arg(args, int);
3015  *type = CFAPI_INT;
3016  op->no_save = iarg;
3017  break;
3018 
3020  sarg = va_arg(args, char *);
3021  *type = CFAPI_STRING;
3022  strncpy(op->contr->savebed_map, sarg, MAX_BUF);
3023  break;
3024 
3026  iarg = va_arg(args, int);
3027  *type = CFAPI_INT;
3028  op->contr->bed_x = iarg;
3029  break;
3030 
3032  iarg = va_arg(args, int);
3033  *type = CFAPI_INT;
3034  op->contr->bed_y = iarg;
3035  break;
3036 
3038  sarg = va_arg(args, char *);
3039  *type = CFAPI_STRING;
3040  strncpy(op->contr->title, sarg, sizeof(op->contr->title));
3041  op->contr->title[sizeof(op->contr->title) - 1]= '\0';
3042  break;
3043 
3044  default:
3045  break;
3046  }
3047  }
3048  va_end(args);
3049 
3050  return NULL;
3051 }
3052 
3061 void *cfapi_object_apply_below(int *type, ...) {
3062  va_list args;
3063  object *applier;
3064 
3065  va_start(args, type);
3066 
3067  applier = va_arg(args, object *);
3068 
3069  va_end(args);
3070 
3071  player_apply_below(applier);
3072  *type = CFAPI_NONE;
3073  return NULL;
3074 }
3075 
3084 void *cfapi_object_apply(int *type, ...) {
3085  va_list args;
3086  object *applied;
3087  object *applier;
3088  int aflags;
3089  int *ret;
3090 
3091  va_start(args, type);
3092 
3093  applier = va_arg(args, object *);
3094  applied = va_arg(args, object *);
3095  aflags = va_arg(args, int);
3096  ret = va_arg(args, int *);
3097 
3098  va_end(args);
3099 
3100  *type = CFAPI_INT;
3101  *ret = manual_apply(applier, applied, aflags);
3102  return NULL;
3103 }
3104 
3112 void *cfapi_object_identify(int *type, ...) {
3113  va_list args;
3114  object *op;
3115 
3116  va_start(args, type);
3117 
3118  op = va_arg(args, object *);
3119 
3120  va_end(args);
3121 
3122  identify(op);
3123  *type = CFAPI_NONE;
3124  return NULL;
3125 }
3126 
3134 void *cfapi_object_describe(int *type, ...) {
3135  va_list args;
3136  object *op;
3137  object *owner;
3138  char *desc;
3139  int size;
3140 
3141  va_start(args, type);
3142 
3143  op = va_arg(args, object *);
3144  owner = va_arg(args, object *);
3145  desc = va_arg(args, char *);
3146  size = va_arg(args, int);
3147  va_end(args);
3148 
3149  *type = CFAPI_STRING;
3150  describe_item(op, owner, desc, size);
3151  return NULL;
3152 }
3153 
3154 void *cfapi_object_drain(int *type, ...) {
3155  va_list args;
3156 
3157  object *op;
3158  int ds;
3159 
3160  va_start(args, type);
3161 
3162  op = va_arg(args, object *);
3163  ds = va_arg(args, int);
3164 
3165  va_end(args);
3166 
3167  drain_specific_stat(op, ds);
3168 
3169  *type = CFAPI_NONE;
3170  return NULL;
3171 }
3172 
3173 void *cfapi_object_fix(int *type, ...) {
3174  va_list args;
3175  object *op;
3176 
3177  va_start(args, type);
3178 
3179  op = va_arg(args, object *);
3180 
3181  va_end(args);
3182 
3183  fix_object(op);
3184 
3185  *type = CFAPI_NONE;
3186  return NULL;
3187 }
3188 
3189 void *cfapi_object_give_skill(int *type, ...) {
3190  va_list args;
3191 
3192  object *op;
3193  char *skillname;
3194 
3195  va_start(args, type);
3196 
3197  op = va_arg(args, object *);
3198  skillname = va_arg(args, char *);
3199 
3200  va_end(args);
3201 
3202  *type = CFAPI_POBJECT;
3203  return give_skill_by_name(op, skillname);
3204 }
3205 
3206 void *cfapi_object_transmute(int *type, ...) {
3207  va_list args;
3208 
3209  object *op;
3210  object *chg;
3211 
3212  va_start(args, type);
3213 
3214  op = va_arg(args, object *);
3215  chg = va_arg(args, object *);
3216 
3217  va_end(args);
3218 
3219  transmute_materialname(op, chg);
3220  *type = CFAPI_NONE;
3221  return NULL;
3222 }
3223 
3224 void *cfapi_object_remove(int *type, ...) {
3225  va_list args;
3226  object *op;
3227 
3228  va_start(args, type);
3229 
3230  op = va_arg(args, object *);
3231 
3232  if (QUERY_FLAG(op, FLAG_REMOVED)) {
3233  LOG(llevError, "Plugin trying to remove removed object %s\n", op->name);
3234  *type = CFAPI_NONE;
3235  return NULL;
3236  }
3237 
3238  va_end(args);
3239 
3240  remove_ob(op);
3241  *type = CFAPI_NONE;
3242  return NULL;
3243 }
3244 
3245 void *cfapi_object_delete(int *type, ...) {
3246  va_list args;
3247  object *op;
3248 
3249  va_start(args, type);
3250 
3251  op = va_arg(args, object *);
3252 
3253  if (QUERY_FLAG(op, FLAG_FREED) || !QUERY_FLAG(op, FLAG_REMOVED)) {
3254  LOG(llevError, "Plugin trying to free freed/non removed object %s\n", op->name);
3255  *type = CFAPI_NONE;
3256  return NULL;
3257  }
3258 
3259  va_end(args);
3260 
3261  free_object(op);
3262 
3263  *type = CFAPI_NONE;
3264  return NULL;
3265 }
3266 
3274 void *cfapi_object_clone(int *type, ...) {
3275  va_list args;
3276  object *op;
3277  int kind;
3278  object **robj;
3279 
3280  va_start(args, type);
3281 
3282  op = va_arg(args, object *);
3283  kind = va_arg(args, int);
3284  robj = va_arg(args, object **);
3285 
3286  va_end(args);
3287 
3288  if (kind == 0) {
3289  *type = CFAPI_POBJECT;
3290  *robj = object_create_clone(op);
3291  } else {
3292  object *tmp;
3293  tmp = get_object();
3294  copy_object(op, tmp);
3295  *type = CFAPI_POBJECT;
3296  *robj = tmp;
3297  }
3298  return NULL;
3299 }
3300 
3301 void *cfapi_object_find(int *type, ...) {
3302  va_list args;
3303  int ftype;
3304  void *rv;
3305  int ival;
3306  int ival2;
3307  char *sval;
3308  object *op;
3309 
3310  va_start(args, type);
3311 
3312  *type = CFAPI_POBJECT;
3313  ftype = va_arg(args, int);
3314  switch (ftype) {
3315  case 0:
3316  ival = va_arg(args, int);
3317  rv = find_object(ival);
3318  break;
3319 
3320  case 1:
3321  sval = va_arg(args, char *);
3322  rv = find_object_name(sval);
3323  break;
3324 
3325  case 2:
3326  op = va_arg(args, object *);
3327  ival = va_arg(args, int);
3328  ival2 = va_arg(args, int);
3329  rv = find_obj_by_type_subtype(op, ival, ival2);
3330  break;
3331 
3332  case 3:
3333  op = va_arg(args, object *);
3334  rv = get_player_container(op);
3335  break;
3336 
3337  default:
3338  rv = NULL;
3339  *type = CFAPI_NONE;
3340  break;
3341  }
3342 
3343  va_end(args);
3344 
3345  return rv;
3346 }
3347 
3355 void *cfapi_object_create(int *type, ...) {
3356  va_list args;
3357  int ival;
3358  object **robj;
3359  va_start(args, type);
3360  ival = va_arg(args, int);
3361 
3362  *type = CFAPI_POBJECT;
3363  switch (ival) {
3364  case 0:
3365  robj = va_arg(args, object **);
3366  *robj = get_object();
3367  break;
3368 
3369  case 1: { /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
3370  const char *sval;
3371  archetype *at;
3372 
3373  sval = va_arg(args, const char *);
3374  robj = va_arg(args, object **);
3375  va_end(args);
3376 
3377  at = try_find_archetype(sval);
3378  if (!at)
3379  at = find_archetype_by_object_name(sval);
3380  if (at) {
3381  *robj = object_create_arch(at);
3382  } else
3383  *robj = NULL;
3384  }
3385  break;
3386 
3387  default:
3388  *type = CFAPI_NONE;
3389  break;
3390  }
3391  va_end(args);
3392  return NULL;
3393 }
3394 void *cfapi_object_insert(int *type, ...) {
3395  va_list args;
3396  object *op;
3397  object *orig;
3398  mapstruct *map;
3399  int flag, x, y;
3400  int itype;
3401  object **robj;
3402 
3403  va_start(args, type);
3404 
3405  op = va_arg(args, object *);
3406  if (!op) {
3407  LOG(llevError, "cfapi_object_insert: called with NULL object!\n");
3408  va_end(args);
3409  return NULL;
3410  }
3411  if (QUERY_FLAG(op, FLAG_FREED)) {
3412  LOG(llevError, "cfapi_object_insert: called with FREED object!\n");
3413  va_end(args);
3414  return NULL;
3415  }
3416  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
3417  LOG(llevError, "cfapi_object_insert: called with not removed object %s!\n", op->name);
3418  remove_ob(op);
3419  }
3420  itype = va_arg(args, int);
3421 
3422  switch (itype) {
3423  case 0:
3424  map = va_arg(args, mapstruct *);
3425  orig = va_arg(args, object *);
3426  flag = va_arg(args, int);
3427  x = va_arg(args, int);
3428  y = va_arg(args, int);
3429  robj = va_arg(args, object **);
3430  if (!map) {
3431  LOG(llevError, "cfapi_object_insert (0): called with NULL map, object %s!\n", op->name);
3432  free_object(op);
3433  *robj = NULL;
3434  } else
3435  *robj = insert_ob_in_map_at(op, map, orig, flag, x, y);
3436  *type = CFAPI_POBJECT;
3437  break;
3438 
3439  case 1:
3440  map = va_arg(args, mapstruct *);
3441  orig = va_arg(args, object *);
3442  flag = va_arg(args, int);
3443  robj = va_arg(args, object **);
3444  if (!map) {
3445  LOG(llevError, "cfapi_object_insert (1): called with NULL map, object %s!\n", op->name);
3446  free_object(op);
3447  *robj = NULL;
3448  } else
3449  *robj = insert_ob_in_map(op, map, orig, flag);
3450  *type = CFAPI_POBJECT;
3451  break;
3452 
3453  case 3:
3454  orig = va_arg(args, object *);
3455  robj = va_arg(args, object **);
3456  if (!orig) {
3457  LOG(llevError, "cfapi_object_insert (3): called with NULL orig, object %s!\n", op->name);
3458  free_object(op);
3459  *robj = NULL;
3460  } else
3461  *robj = insert_ob_in_ob(op, orig);
3462  *type = CFAPI_POBJECT;
3463  break;
3464 
3465  default:
3466  LOG(llevError, "cfapi_object_insert (1): called with itype %d which is not valid, object %s!\n", itype, op->name);
3467  free_object(op);
3468  *type = CFAPI_NONE;
3469  break;
3470  }
3471 
3472  va_end(args);
3473 
3474  return NULL;
3475 }
3483 void *cfapi_object_split(int *type, ...) {
3484  va_list args;
3485 
3486  int nr, size;
3487  object *op;
3488  char *buf;
3489  object **split;
3490 
3491  va_start(args, type);
3492 
3493  op = va_arg(args, object *);
3494  nr = va_arg(args, int);
3495  buf = va_arg(args, char *);
3496  size = va_arg(args, int);
3497  split = va_arg(args, object **);
3498  va_end(args);
3499 
3500  *type = CFAPI_POBJECT;
3501  *split = get_split_ob(op, nr, buf, size);
3502  return NULL;
3503 }
3504 
3512 void *cfapi_object_merge(int *type, ...) {
3513  va_list args;
3514  object *op;
3515  object *op2;
3516  object **merge;
3517 
3518  va_start(args, type);
3519 
3520  op = va_arg(args, object *);
3521  op2 = va_arg(args, object *);
3522  merge = va_arg(args, object **);
3523 
3524  va_end(args);
3525 
3526  *type = CFAPI_POBJECT;
3527  *merge = merge_ob(op, op2);
3528  return NULL;
3529 }
3530 
3538 void *cfapi_object_distance(int *type, ...) {
3539  va_list args;
3540  object *op;
3541  object *op2;
3542  int *rint;
3543  va_start(args, type);
3544 
3545  op = va_arg(args, object *);
3546  op2 = va_arg(args, object *);
3547  rint = va_arg(args, int *);
3548 
3549  va_end(args);
3550 
3551  *type = CFAPI_INT;
3552  *rint = distance(op, op2);
3553  return NULL;
3554 }
3562 void *cfapi_object_update(int *type, ...) {
3563  va_list args;
3564  int action;
3565  object *op;
3566  va_start(args, type);
3567 
3568  op = va_arg(args, object *);
3569  action = va_arg(args, int);
3570 
3571  va_end(args);
3572 
3573  update_object(op, action);
3574  *type = CFAPI_NONE;
3575  return NULL;
3576 }
3577 
3585 void *cfapi_object_clear(int *type, ...) {
3586  va_list args;
3587  object *op;
3588  va_start(args, type);
3589 
3590  op = va_arg(args, object *);
3591 
3592  va_end(args);
3593 
3594  clear_object(op);
3595  *type = CFAPI_NONE;
3596  return NULL;
3597 }
3598 
3606 void *cfapi_object_reset(int *type, ...) {
3607  va_list args;
3608  object *op;
3609 
3610  va_start(args, type);
3611 
3612  op = va_arg(args, object *);
3613 
3614  va_end(args);
3615 
3616  reset_object(op);
3617  *type = CFAPI_NONE;
3618  return NULL;
3619 }
3620 
3621 void *cfapi_object_check_inventory(int *type, ...) {
3622  va_list args;
3623  object *op;
3624  object *op2;
3625  int checktype;
3626  object *ret = NULL;
3627 
3628  va_start(args, type);
3629 
3630  op = va_arg(args, object *);
3631  op2 = va_arg(args, object *);
3632  checktype = va_arg(args, int);
3633 
3634  if (checktype == 0) {
3635  check_inv(op, op2);
3636  *type = CFAPI_NONE;
3637  } else {
3638  ret = check_inv_recursive(op, op2);
3639  *type = CFAPI_POBJECT;
3640  }
3641 
3642  va_end(args);
3643 
3644  return ret;
3645 }
3646 
3647 void *cfapi_object_clean_object(int *type, ...) {
3648  va_list args;
3649  object *op;
3650 
3651  va_start(args, type);
3652  op = va_arg(args, object *);
3653  clean_object(op);
3654  va_end(args);
3655  *type = CFAPI_NONE;
3656  return NULL;
3657 }
3658 
3659 void *cfapi_object_on_same_map(int *type, ...) {
3660  va_list args;
3661  object *op1;
3662  object *op2;
3663  int *rint;
3664 
3665  va_start(args, type);
3666  op1 = va_arg(args, object *);
3667  op2 = va_arg(args, object *);
3668  rint = va_arg(args, int *);
3669  va_end(args);
3670 
3671  *type = CFAPI_INT;
3672  *rint = on_same_map(op1, op2);
3673 
3674  return NULL;
3675 }
3676 
3677 void *cfapi_object_spring_trap(int *type, ...) {
3678  object *trap;
3679  object *victim;
3680  va_list args;
3681 
3682  va_start(args, type);
3683  trap = va_arg(args, object *);
3684  victim = va_arg(args, object *);
3685  va_end(args);
3686 
3687  spring_trap(trap, victim);
3688  *type = CFAPI_NONE;
3689  return NULL;
3690 }
3691 
3699 void *cfapi_object_check_trigger(int *type, ...) {
3700  object *op;
3701  object *cause;
3702  va_list args;
3703  int *rint;
3704 
3705  va_start(args, type);
3706  op = va_arg(args, object *);
3707  cause = va_arg(args, object *);
3708  rint = va_arg(args, int *);
3709  va_end(args);
3710 
3711  *rint = check_trigger(op, cause);
3712  *type = CFAPI_INT;
3713  return NULL;
3714 }
3715 
3729 void *cfapi_map_trigger_connected(int *type, ...) {
3730  objectlink *ol;
3731  object *cause;
3732  int state;
3733  va_list args;
3734 
3735  va_start(args, type);
3736  ol = va_arg(args, objectlink *);
3737  cause = va_arg(args, object *);
3738  state = va_arg(args, int);
3739  va_end(args);
3740  trigger_connected(ol, cause, state);
3741  *type = CFAPI_NONE;
3742  return NULL;
3743 }
3744 
3752 void *cfapi_object_query_cost(int *type, ...) {
3753  object *op;
3754  object *who;
3755  int flags;
3756  va_list args;
3757  int *rint;
3758 
3759  va_start(args, type);
3760  op = va_arg(args, object *);
3761  who = va_arg(args, object *);
3762  flags = va_arg(args, int);
3763  rint = va_arg(args, int *);
3764  va_end(args);
3765 
3766  *rint = query_cost(op, who, flags);
3767  *type = CFAPI_INT;
3768  return NULL;
3769 }
3770 
3778 void *cfapi_object_query_money(int *type, ...) {
3779  object *op;
3780  va_list args;
3781  int *rint;
3782 
3783  va_start(args, type);
3784  op = va_arg(args, object *);
3785  rint = va_arg(args, int *);
3786  va_end(args);
3787 
3788  *rint = query_money(op);
3789  *type = CFAPI_INT;
3790  return NULL;
3791 }
3792 
3800 void *cfapi_object_cast(int *type, ...) {
3801  object *op;
3802  object *sp;
3803  int dir;
3804  char *str;
3805  object *caster;
3806  va_list args;
3807  int *rint;
3808 
3809  va_start(args, type);
3810  op = va_arg(args, object *);
3811  caster = va_arg(args, object *);
3812  dir = va_arg(args, int);
3813  sp = va_arg(args, object *);
3814  str = va_arg(args, char *);
3815  rint = va_arg(args, int *);
3816  va_end(args);
3817 
3818  *type = CFAPI_INT;
3819 
3820  if (!op->map) {
3821  *rint = -1;
3822  return NULL;
3823  }
3824 
3825  *rint = cast_spell(op, caster, dir, sp, str);
3826  return NULL;
3827 }
3828 
3829 void *cfapi_object_learn_spell(int *type, ...) {
3830  object *op;
3831  object *sp;
3832  int prayer;
3833  va_list args;
3834 
3835  va_start(args, type);
3836  op = va_arg(args, object *);
3837  sp = va_arg(args, object *);
3838  prayer = va_arg(args, int);
3839  va_end(args);
3840  do_learn_spell(op, sp, prayer);
3841  *type = CFAPI_NONE;
3842  return NULL;
3843 }
3844 
3845 void *cfapi_object_forget_spell(int *type, ...) {
3846  object *op;
3847  object *sp;
3848  va_list args;
3849  char name[MAX_BUF];
3850 
3851  va_start(args, type);
3852  op = va_arg(args, object *);
3853  sp = va_arg(args, object *);
3854  va_end(args);
3855  query_name(sp, name, MAX_BUF);
3856  do_forget_spell(op, name);
3857  *type = CFAPI_NONE;
3858  return NULL;
3859 }
3860 
3868 void *cfapi_object_check_spell(int *type, ...) {
3869  object *op;
3870  char *spellname;
3871  va_list args;
3872  object **robj;
3873 
3874  va_start(args, type);
3875  op = va_arg(args, object *);
3876  spellname = va_arg(args, char *);
3877  robj = va_arg(args, object **);
3878  va_end(args);
3879  *robj = check_spell_known(op, spellname);
3880  *type = CFAPI_POBJECT;
3881  return NULL;
3882 }
3883 
3891 void *cfapi_object_pay_amount(int *type, ...) {
3892  object *op;
3893  uint64 amount;
3894  va_list args;
3895  int *rint;
3896 
3897  va_start(args, type);
3898  op = va_arg(args, object *);
3899  amount = va_arg(args, uint64);
3900  rint = va_arg(args, int *);
3901  va_end(args);
3902 
3903  *rint = pay_for_amount(amount, op);
3904  *type = CFAPI_INT;
3905  return NULL;
3906 }
3914 void *cfapi_object_pay_item(int *type, ...) {
3915  object *op;
3916  object *tobuy;
3917  int *rint;
3918 
3919  va_list args;
3920 
3921  va_start(args, type);
3922  tobuy = va_arg(args, object *);
3923  op = va_arg(args, object *);
3924  rint = va_arg(args, int *);
3925  va_end(args);
3926 
3927  *rint = pay_for_item(tobuy, op);
3928  *type = CFAPI_INT;
3929  return NULL;
3930 }
3931 
3941 void *cfapi_object_transfer(int *type, ...) {
3942  object *op;
3943  object *originator;
3944  int x, y, randompos, ttype, flag;
3945  va_list args;
3946  mapstruct *map;
3947  int *rint;
3948  object **robj;
3949 
3950  va_start(args, type);
3951  op = va_arg(args, object *);
3952  ttype = va_arg(args, int);
3953  switch (ttype) {
3954  case 0:
3955  x = va_arg(args, int);
3956  y = va_arg(args, int);
3957  randompos = va_arg(args, int);
3958  originator = va_arg(args, object *);
3959  rint = va_arg(args, int *);
3960  va_end(args);
3961 
3962  *rint = transfer_ob(op, x, y, randompos, originator);
3963  *type = CFAPI_INT;
3964  return NULL;
3965  break;
3966 
3967  case 1:
3968  map = va_arg(args, mapstruct *);
3969  originator = va_arg(args, object *);
3970  flag = va_arg(args, int);
3971  x = va_arg(args, int);
3972  y = va_arg(args, int);
3973  robj = va_arg(args, object **);
3974  va_end(args);
3975  if (x < 0 || y < 0) {
3976  x = map->enter_x;
3977  y = map->enter_y;
3978  }
3979  *robj = insert_ob_in_map_at(op, map, originator, flag, x, y);
3980  *type = CFAPI_POBJECT;
3981  return NULL;
3982  break;
3983 
3984  case 2:
3985  x = va_arg(args, int);
3986  y = va_arg(args, int);
3987  rint = va_arg(args, int *);
3988  va_end(args);
3989 
3990  *rint = move_to(op, x, y);
3991  *type = CFAPI_INT;
3992  return NULL;
3993 
3994  default:
3995  *type = CFAPI_NONE;
3996  return NULL;
3997  break;
3998  }
3999 }
4000 
4004 void *cfapi_object_find_archetype_inside(int *type, ...) {
4005  object *op;
4006  char *str;
4007  va_list args;
4008  object **robj;
4009 
4010  *type = CFAPI_POBJECT;
4011  va_start(args, type);
4012  op = va_arg(args, object *);
4013 
4014  str = va_arg(args, char *);
4015  robj = va_arg(args, object **);
4016  *robj = present_arch_in_ob(try_find_archetype(str), op);
4017  if (*robj == NULL) {
4018  object *tmp;
4019  char name[MAX_BUF];
4020 
4021  /* Search by query_name instead */
4022  for (tmp = op->inv; tmp; tmp = tmp->below) {
4023  query_name(tmp, name, MAX_BUF);
4024  if (!strncmp(name, str, strlen(str)))
4025  *robj = tmp;
4026  if (!strncmp(tmp->name, str, strlen(str)))
4027  *robj = tmp;
4028  if (*robj != NULL)
4029  break;
4030  }
4031  }
4032  va_end(args);
4033 
4034  return NULL;
4035 }
4036 
4044 void *cfapi_object_drop(int *type, ...) {
4045  object *op;
4046  object *author;
4047  va_list args;
4048 
4049  va_start(args, type);
4050  op = va_arg(args, object *);
4051  author = va_arg(args, object *);
4052  va_end(args);
4053  *type = CFAPI_NONE;
4054 
4055  if (QUERY_FLAG(op, FLAG_NO_DROP))
4056  return NULL;
4057  drop(author, op);
4058 
4059  if (author->type == PLAYER) {
4060  author->contr->count = 0;
4061  author->contr->socket.update_look = 1;
4062  }
4063 
4064  return NULL;
4065 }
4066 
4070 void *cfapi_object_change_abil(int *type, ...) {
4071  object *op, *tmp;
4072  int *rint;
4073  va_list args;
4074 
4075  va_start(args, type);
4076  op = va_arg(args, object *);
4077  tmp = va_arg(args, object *);
4078  rint = va_arg(args, int *);
4079  va_end(args);
4080 
4081  *type = CFAPI_INT;
4082  *rint = change_abil(op, tmp);
4083 
4084  return NULL;
4085 }
4086 
4087 void *cfapi_object_say(int *type, ...) {
4088  object *op;
4089  char *msg;
4090  va_list args;
4091  int *rint;
4092 
4093  va_start(args, type);
4094  op = va_arg(args, object *);
4095  msg = va_arg(args, char *);
4096  rint = va_arg(args, int *);
4097  va_end(args);
4098 
4099  if (op->type == PLAYER) {
4100  *rint = command_say(op, msg);
4101  } else {
4102  npc_say(op, msg);
4103  *rint = 0;
4104  }
4105  *type = CFAPI_INT;
4106  return NULL;
4107 }
4108 
4109 /* PLAYER SUBCLASS */
4110 
4118 void *cfapi_player_find(int *type, ...) {
4119  va_list args;
4120  char *sval;
4121  player **rpl;
4122  va_start(args, type);
4123 
4124  sval = va_arg(args, char *);
4125  rpl = va_arg(args, player **);
4126  va_end(args);
4127 
4128  *rpl = find_player_partial_name(sval);
4129 
4130  *type = CFAPI_PPLAYER;
4131  return NULL;
4132 }
4133 
4134 void *cfapi_player_message(int *type, ...) {
4135  va_list args;
4136  int flags;
4137  int pri;
4138  object *pl;
4139  char *buf;
4140 
4141  va_start(args, type);
4142 
4143  flags = va_arg(args, int);
4144  pri = va_arg(args, int);
4145  pl = va_arg(args, object *);
4146  buf = va_arg(args, char *);
4147  va_end(args);
4148 
4149  draw_ext_info(flags, pri, pl, MSG_TYPE_MISC, MSG_SUBTYPE_NONE,
4150  buf, buf);
4151  *type = CFAPI_NONE;
4152  return NULL;
4153 }
4154 
4162 void *cfapi_object_change_exp(int *type, ...) {
4163  va_list(args);
4164  int flag;
4165  object *ob;
4166  const char *skill;
4167  sint64 exp;
4168 
4169  va_start(args, type);
4170  ob = va_arg(args, object *);
4171  exp = va_arg(args, sint64);
4172  skill = va_arg(args, const char *);
4173  flag = va_arg(args, int);
4174  va_end(args);
4175 
4176  *type = CFAPI_NONE;
4177  change_exp(ob, exp, skill, flag);
4178  return NULL;
4179 }
4180 
4188 void *cfapi_player_can_pay(int *type, ...) {
4189  va_list args;
4190  object *pl;
4191  int *rint;
4192 
4193  va_start(args, type);
4194  pl = va_arg(args, object *);
4195  rint = va_arg(args, int *);
4196  va_end(args);
4197 
4198  *rint = can_pay(pl);
4199  *type = CFAPI_INT;
4200  return NULL;
4201 }
4202 
4210 void *cfapi_object_teleport(int *type, ...) {
4211  mapstruct *map;
4212  int x, y;
4213  object *who;
4214  int *res;
4215  va_list args;
4216 
4217  va_start(args, type);
4218  who = va_arg(args, object *);
4219  map = va_arg(args, mapstruct *);
4220  x = va_arg(args, int);
4221  y = va_arg(args, int);
4222  res = va_arg(args, int *);
4223  *type = CFAPI_INT;
4224 
4225  if (!out_of_map(map, x, y)) {
4226  int k;
4227  k = find_first_free_spot(who, map, x, y);
4228  if (k == -1) {
4229  *res = 1;
4230  return NULL;
4231  }
4232 
4233  if (!QUERY_FLAG(who, FLAG_REMOVED)) {
4234  remove_ob(who);
4235  }
4236 
4237  insert_ob_in_map_at(who, map, NULL, 0, x, y);
4238  if (who->type == PLAYER)
4239  map_newmap_cmd(&who->contr->socket);
4240  *res = 0;
4241  }
4242 
4243  return NULL;
4244 }
4245 
4246 void *cfapi_object_pickup(int *type, ...) {
4247  object *who;
4248  object *what;
4249  va_list args;
4250 
4251  va_start(args, type);
4252  who = va_arg(args, object *);
4253  what = va_arg(args, object *);
4254  va_end(args);
4255 
4256  pick_up(who, what);
4257  *type = CFAPI_NONE;
4258  return NULL;
4259 }
4260 
4261 /* Archetype-related functions */
4262 void *cfapi_archetype_get_property(int *type, ...) {
4263  int prop;
4264  archetype *arch;
4265  va_list args;
4266  sstring *rsstring;
4267  archetype **rarch;
4268  object **robject;
4269 
4270  va_start(args, type);
4271  arch = va_arg(args, archetype *);
4272  prop = va_arg(args, int);
4273  switch (prop) {
4274  case CFAPI_ARCH_PROP_NAME:
4275  *type = CFAPI_SSTRING;
4276  rsstring = va_arg(args, sstring *);
4277  *rsstring = arch->name;
4278  break;
4279 
4280  case CFAPI_ARCH_PROP_NEXT:
4281  *type = CFAPI_PARCH;
4282  rarch = va_arg(args, archetype **);
4283  *rarch = arch ? arch->next : first_archetype;
4284  break;
4285 
4286  case CFAPI_ARCH_PROP_HEAD:
4287  *type = CFAPI_PARCH;
4288  rarch = va_arg(args, archetype **);
4289  *rarch = arch->head;
4290  break;
4291 
4292  case CFAPI_ARCH_PROP_MORE:
4293  *type = CFAPI_PARCH;
4294  rarch = va_arg(args, archetype **);
4295  *rarch = arch->more;
4296  break;
4297 
4298  case CFAPI_ARCH_PROP_CLONE:
4299  *type = CFAPI_POBJECT;
4300  robject = va_arg(args, object **);
4301  *robject = &arch->clone;
4302  break;
4303 
4304  default:
4305  *type = CFAPI_NONE;
4306  break;
4307  }
4308  va_end(args);
4309  return NULL;
4310 }
4311 
4320 void *cfapi_party_get_property(int *type, ...) {
4321  partylist *party;
4322  int prop;
4323  va_list args;
4324  object *obarg;
4325  sstring *rsstring;
4326  player **rplayer;
4327  partylist **rparty;
4328 
4329  va_start(args, type);
4330  party = va_arg(args, partylist *);
4331  prop = va_arg(args, int);
4332  switch (prop) {
4333  case CFAPI_PARTY_PROP_NAME:
4334  rsstring = va_arg(args, sstring *);
4335  *rsstring = party->partyname;
4336  *type = CFAPI_SSTRING;
4337  break;
4338 
4339  case CFAPI_PARTY_PROP_NEXT:
4340  rparty = va_arg(args, partylist **);
4341  *rparty = (party ? party->next : get_firstparty());
4342  *type = CFAPI_PPARTY;
4343  break;
4344 
4346  rsstring = va_arg(args, sstring *);
4347  *rsstring = party->passwd;
4348  *type = CFAPI_SSTRING;
4349  break;
4350 
4352  *type = CFAPI_PPLAYER;
4353  obarg = va_arg(args, object *);
4354  rplayer = va_arg(args, player **);
4355  *rplayer = (obarg ? obarg->contr : first_player);
4356  for (; *rplayer != NULL; (*rplayer) = (*rplayer)->next)
4357  if ((*rplayer)->ob->contr->party == party) {
4358  break;
4359  }
4360  break;
4361 
4362  default:
4363  *type = CFAPI_NONE;
4364  break;
4365  }
4366  va_end(args);
4367  return NULL;
4368 }
4369 
4378 void *cfapi_region_get_property(int *type, ...) {
4379  region *reg;
4380  int prop;
4381  va_list args;
4383  sstring *rsstring;
4384  region **rregion;
4385 
4386  va_start(args, type);
4387  reg = va_arg(args, region *);
4388  prop = va_arg(args, int);
4389  switch (prop) {
4391  rsstring = va_arg(args, sstring *);
4392  *rsstring = reg->name;
4393  *type = CFAPI_SSTRING;
4394  break;
4395 
4397  rregion = va_arg(args, region **);
4398  *rregion = (reg ? reg->next : first_region);
4399  *type = CFAPI_PREGION;
4400  break;
4401 
4403  rregion = va_arg(args, region **);
4404  *rregion = reg->parent;
4405  *type = CFAPI_PREGION;
4406  break;
4407 
4409  rsstring = va_arg(args, sstring *);
4410  *rsstring = reg->longname;
4411  *type = CFAPI_SSTRING;
4412  break;
4413 
4415  rsstring = va_arg(args, sstring *);
4416  *rsstring = reg->msg;
4417  *type = CFAPI_SSTRING;
4418  break;
4419 
4420  default:
4421  *type = CFAPI_NONE;
4422  break;
4423  }
4424  va_end(args);
4425  return NULL;
4426 }
4427 
4439 void *cfapi_friendlylist_get_next(int *type, ...) {
4440  object *ob;
4441  va_list args;
4442  objectlink *link;
4443  object **robject;
4444 
4445  va_start(args, type);
4446  ob = va_arg(args, object *);
4447  robject = va_arg(args, object **);
4448  va_end(args);
4449 
4450  *type = CFAPI_POBJECT;
4451  *robject = NULL;
4452 
4453  if (ob) {
4454  for (link = first_friendly_object; link; link = link->next) {
4455  if (ob == link->ob) {
4456  if (link->next) {
4457  *robject = link->next->ob;
4458  return NULL;
4459  } else {
4460  return NULL;
4461  }
4462  }
4463  }
4464  return NULL;
4465  }
4466 
4468  *robject = first_friendly_object->ob;
4469 
4470  return NULL;
4471 }
4472 
4473 /*
4474  * Random-map related stuff.
4475  */
4476 
4485 void *cfapi_set_random_map_variable(int *type, ...) {
4486  va_list args;
4487  RMParms *rp;
4488  const char *buf;
4489  int *ret;
4490 
4491  va_start(args, type);
4492  rp = va_arg(args, RMParms *);
4493  buf = va_arg(args, const char *);
4494  ret = va_arg(args, int *);
4495  va_end(args);
4496 
4497  *ret = set_random_map_variable(rp, buf);
4498  *type = CFAPI_INT;
4499 
4500  return NULL;
4501 }
4502 
4511 void *cfapi_generate_random_map(int *type, ...) {
4512  va_list args;
4513  const char *name;
4514  RMParms *rp;
4515  char **use_layout;
4516  mapstruct **ret;
4517 
4518  va_start(args, type);
4519  name = va_arg(args, const char *);
4520  rp = va_arg(args, RMParms *);
4521  use_layout = va_arg(args, char **);
4522  ret = va_arg(args, mapstruct **);
4523  va_end(args);
4524 
4525  *ret = generate_random_map(name, rp, use_layout);
4526 
4527  return NULL;
4528 }
4529 
4530 void *cfapi_object_user_event(int *type, ...) {
4531  object *op;
4532  object *activator;
4533  object *third;
4534  const char *message;
4535  int fix;
4536  int *ret;
4537  va_list args;
4538 
4539  va_start(args, type);
4540  op = va_arg(args, object *);
4541  activator = va_arg(args, object *);
4542  third = va_arg(args, object *);
4543  message = va_arg(args, const char *);
4544  fix = va_arg(args, int);
4545  ret = va_arg(args, int *);
4546  va_end(args);
4547 
4548  *ret = user_event(op, activator, third, message, fix);
4549  *type = CFAPI_INT;
4550 
4551  return NULL;
4552 }
4553 
4554 /*****************************************************************************/
4555 /* NEW PLUGIN STUFF ENDS HERE */
4556 /*****************************************************************************/
4557 
4558 
4559 /*****************************************************************************/
4560 /* Tries to find if a given command is handled by a plugin. */
4561 /* Note that find_plugin_command is called *before *the internal commands are*/
4562 /* checked, meaning that you can "overwrite" them. */
4563 /*****************************************************************************/
4569  int i;
4570  crossfire_plugin *cp;
4571  static command_array_struct rtn_cmd;
4572 
4573  if (plugins_list == NULL)
4574  return NULL;
4575 
4576  for (cp = plugins_list; cp != NULL; cp = cp->next) {
4577  if (cp->propfunc(&i, "command?", cmd, &rtn_cmd) != NULL)
4578  return &rtn_cmd;
4579  }
4580  return NULL;
4581 }
4582 
4583 /*****************************************************************************/
4584 /* Plugins initialization. Browses the plugins directory and call */
4585 /* initOnePlugin for each file found. */
4586 /* Returns 0 if at least one plugin was successfully loaded, -1 if not */
4587 /*****************************************************************************/
4588 int initPlugins(void) {
4589  struct dirent *currentfile;
4590  DIR *plugdir;
4591  size_t l;
4592  char buf[MAX_BUF];
4593  int result;
4594 
4595  LOG(llevInfo, "Initializing plugins\n");
4596  snprintf(buf, sizeof(buf), "%s/plugins/", LIBDIR);
4597  LOG(llevInfo, "Plugins directory is %s\n", buf);
4598 
4599  plugdir = opendir(buf);
4600  if (plugdir == NULL)
4601  return -1;
4602 
4603  result = -1;
4604  while ((currentfile = readdir(plugdir)) != NULL) {
4605  l = strlen(currentfile->d_name);
4606  if (l > strlen(PLUGIN_SUFFIX)) {
4607  if (strcmp(currentfile->d_name+l-strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX) == 0) {
4608  snprintf(buf, sizeof(buf), "%s/plugins/%s", LIBDIR, currentfile->d_name);
4609  LOG(llevInfo, " -> Loading plugin : %s\n", currentfile->d_name);
4610  if (plugins_init_plugin(buf) == 0)
4611  result = 0;
4612  }
4613  }
4614  }
4615 
4616  closedir(plugdir);
4617  return result;
4618 }
4619 
4623 void cleanupPlugins(void) {
4624  crossfire_plugin *cp;
4625 
4626  if (!plugins_list)
4627  return;
4628 
4629  for (cp = plugins_list; cp != NULL; ) {
4630  crossfire_plugin *next = cp->next;
4631  if (cp->closefunc)
4632  cp->closefunc();
4633  /* Don't actually unload plugins, it makes backtraces for memory
4634  * debugging (printed at exit) messed up. And it doesn't matter if we
4635  * don't free it here. The OS will do it for us.
4636  */
4637  /* plugins_dlclose(cp->libptr); */
4638  free(cp);
4639  plugin_number--;
4640  cp = next;
4641  }
4642  plugins_list = NULL;
4643 }
void * cfapi_timer_create(int *type,...)
Definition: plugins.c:1010
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:243
#define CFAPI_OBJECT_PROP_MAP
Definition: plugin.h:174
void * cfapi_system_directory(int *type,...)
Definition: plugins.c:867
#define CFAPI_OBJECT_PROP_RUN_AWAY
Definition: plugin.h:220
void * cfapi_object_insert(int *type,...)
Definition: plugins.c:3394
sint16 bed_x
Definition: player.h:152
void spring_trap(object *trap, object *victim)
Definition: rune.c:227
int plugin_number
Definition: plugins.c:154
static void copy_message(object *op, const char *msg)
Definition: plugins.c:2427
char path[HUGE_BUF]
Definition: map.h:384
#define CFAPI_OBJECT_PROP_MAGIC
Definition: plugin.h:201
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny)
Definition: map.c:330
#define FLAG_NO_DROP
Definition: define.h:585
sint8 Int
Definition: living.h:78
#define CFAPI_PARTY_PROP_PASSWORD
Definition: plugin.h:311
Definition: player.h:146
void * cfapi_system_find_string(int *type,...)
Definition: plugins.c:800
#define CFAPI_OBJECT_PROP_MATERIAL
Definition: plugin.h:199
const char * determine_god(object *op)
Definition: gods.c:118
#define CFAPI_OBJECT_PROP_NO_SAVE
Definition: plugin.h:265
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:264
void * cfapi_object_remove(int *type,...)
Definition: plugins.c:3224
sint8 ac
Definition: living.h:79
#define CFAPI_OBJECT_PROP_SP
Definition: plugin.h:253
#define UP_OBJ_FACE
Definition: object.h:356
uint64 query_money(const object *op)
Definition: shop.c:581
void * cfapi_object_reset(int *type,...)
Definition: plugins.c:3606
void * cfapi_object_clone(int *type,...)
Definition: plugins.c:3274
#define CFAPI_OBJECT_PROP_CARRYING
Definition: plugin.h:214
MoveType move_type
Definition: object.h:277
#define plugins_dlopen(fname)
Definition: plugin.h:158
#define EVENT_REMOVE
Definition: plugin.h:89
#define CFAPI_OBJECT_PROP_NAME
Definition: plugin.h:176
#define CFAPI_OBJECT_PROP_OB_BELOW
Definition: plugin.h:167
#define CFAPI_PREGION
Definition: plugin.h:113
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:282
#define EVENT_SHOUT
Definition: plugin.h:90
#define CFAPI_MAP_PROP_NAME
Definition: plugin.h:288
const char * get_ob_key_value(const object *op, const char *const key)
Definition: object.c:3701
int move_player(object *op, int dir)
Definition: player.c:2741
void npc_say(object *npc, const char *cp)
Definition: monster.c:1933
#define OUT_OF_MEMORY
Definition: define.h:94
MoveType move_on
Definition: object.h:280
void * cfapi_system_remove_string(int *type,...)
Definition: plugins.c:779
signed short sint16
Definition: global.h:72
void * cfapi_map_present_arch_by_name(int *type,...)
Definition: plugins.c:1483
void * cfapi_map_get_object_at(int *type,...)
Definition: plugins.c:1451
object * find_obj_by_type_subtype(const object *who, int type, int subtype)
Definition: object.c:3656
void change_exp(object *op, sint64 exp, const char *skill_name, int flag)
Definition: living.c:2015
#define CFAPI_OBJECT_PROP_RACE
Definition: plugin.h:179
#define MSG_SUBTYPE_NONE
Definition: newclient.h:339
object * check_spell_known(object *op, const char *name)
Definition: spell_util.c:408
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:297
Definition: object.h:298
static const hook_entry plug_hooks[NR_OF_HOOKS]
Definition: plugins.c:63
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:318
const char * race
Definition: object.h:171
#define P_NEED_UPDATE
Definition: map.h:260
void set_owner(object *op, object *owner)
Definition: object.c:564
int is_magical(const object *op)
Definition: item.c:1312
void * cfapi_map_change_light(int *type,...)
Definition: plugins.c:1512
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:284
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:293
#define CFAPI_OBJECT_PROP_ARCHETYPE
Definition: plugin.h:227
#define CFAPI_OBJECT_PROP_WEIGHT
Definition: plugin.h:212
uint16 attack_movement
Definition: object.h:242
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:195
#define CFAPI_OBJECT_PROP_FACE
Definition: plugin.h:263
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.c:884
#define SET_FLAG(xyz, p)
Definition: define.h:510
object * present_in_ob(uint8 type, const object *op)
Definition: object.c:2806
#define NR_OF_HOOKS
Definition: plugins.c:61
#define EVENT_KICK
Definition: plugin.h:93
void do_forget_spell(object *op, const char *spell)
Definition: apply.c:440
MoveType move_allow
Definition: object.h:279
char title[BIG_NAME]
Definition: player.h:216
#define plugins_dlsym(lib, name)
Definition: plugin.h:160
#define CFAPI_FUNC
Definition: plugin.h:110
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout)
Definition: random_map.c:80
#define PLUGIN_SUFFIX
Definition: win32.h:124
New_Face * new_faces
Definition: image.c:38
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:260
#define CFAPI_OBJECT_PROP_PICK_UP
Definition: plugin.h:209
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:285
#define CFAPI_MAP_PROP_HEIGHT
Definition: plugin.h:295
uint16 material
Definition: object.h:198
uint16 client_type
Definition: object.h:191
#define CFAPI_OBJECT_PROP_DIRECTION
Definition: plugin.h:189
int initPlugins(void)
Definition: plugins.c:4588
void * cfapi_object_say(int *type,...)
Definition: plugins.c:4087
void * cfapi_object_clean_object(int *type,...)
Definition: plugins.c:3647
object * object_get_env_recursive(object *op)
Definition: object.c:339
EXTERN objectlink * first_friendly_object
Definition: global.h:196
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB
Definition: plugin.h:168
struct obj * container
Definition: object.h:149
#define CFAPI_OBJECT_PROP_MAXGP
Definition: plugin.h:258
#define EVENT_LOGIN
Definition: plugin.h:84
#define CFAPI_OBJECT_PROP_HIDDEN
Definition: plugin.h:222
object * insert_ob_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.c:1761
#define CFAPI_OBJECT_PROP_MOVE_STATUS
Definition: plugin.h:223
const char * get_season_name(const int index)
Definition: time.c:134
char * create_pathname(const char *name, char *buf, size_t size)
Definition: map.c:114
void * cfapi_object_identify(int *type,...)
Definition: plugins.c:3112
void * cfapi_object_move(int *type,...)
Definition: plugins.c:1546
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.c:1809
const char * playerdir
Definition: global.h:336
unsigned char MoveType
Definition: define.h:725
sint32 move_status
Definition: object.h:241
sint32 last_heal
Definition: object.h:208
void check_inv(object *op, object *trig)
Definition: button.c:828
#define CFAPI_OBJECT_PROP_SUBTYPE
Definition: plugin.h:192
object * find_object_name(const char *str)
Definition: object.c:459
sint16 maxgrace
Definition: living.h:86
void free_string(sstring str)
Definition: shstr.c:272
#define TIMER_ERR_ID
Definition: timers.h:69
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:306
#define SET_ANIMATION(ob, newanim)
Definition: global.h:247
#define NR_EVENTS
Definition: plugin.h:96
#define EVENT_MAPLEAVE
Definition: plugin.h:87
void esrv_update_item(int flags, object *pl, object *op)
Definition: standalone.c:200
#define CFAPI_OBJECT_PROP_CONTAINER
Definition: plugin.h:173
#define CFAPI_INT16
Definition: plugin.h:114
void pick_up(object *op, object *alt)
Definition: c_object.c:462
sint16 players
Definition: map.h:365
f_plug_api func
Definition: plugin.h:337
#define CFAPI_OBJECT_PROP_INVENTORY
Definition: plugin.h:170
void query_base_name(const object *op, int plural, char *buf, size_t size)
Definition: item.c:732
object clone
Definition: object.h:326
void * cfapi_map_has_been_loaded(int *type,...)
Definition: plugins.c:1149
sint16 duration
Definition: object.h:254
#define CFAPI_OBJECT_PROP_FLAGS
Definition: plugin.h:242
socket_struct socket
Definition: player.h:148
sint16 invisible
Definition: object.h:211
#define EVENT_LOGOUT
Definition: plugin.h:85
int calculate_difficulty(mapstruct *m)
Definition: map.c:1917
object * merge_ob(object *op, object *top)
Definition: object.c:1724
#define CFAPI_SINT64
Definition: plugin.h:116
#define CFAPI_OBJECT_PROP_NAME_PLURAL
Definition: plugin.h:177
void draw_ext_info(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *message, const char *oldmessage)
Definition: standalone.c:171
const char * get_weekday(const int index)
Definition: time.c:127
const char * slaying
Definition: object.h:172
region * get_region_by_map(mapstruct *m)
Definition: region.c:85
DIR * opendir(const char *)
Definition: win32.c:78
sint32 last_sp
Definition: object.h:209
void *(* f_plug_api)(int *type,...)
Definition: plugin.h:121
#define CFAPI_OBJECT_PROP_OWNER
Definition: plugin.h:237
void update_object(object *op, int action)
Definition: object.c:1112
void * cfapi_object_set_property(int *type,...)
Definition: plugins.c:2459
uint8 subtype
Definition: object.h:190
crossfire_plugin * plugins_list
Definition: plugins.c:156
#define CFAPI_OBJECT_PROP_MOVE_ON
Definition: plugin.h:269
sint64 exp
Definition: living.h:88
#define CFAPI_OBJECT_PROP_MESSAGE
Definition: plugin.h:182
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER
Definition: plugin.h:226
struct obj * above
Definition: object.h:146
void * cfapi_object_get_key(int *type,...)
Definition: plugins.c:1588
double expmul
Definition: object.h:246
#define plugins_dlclose(lib)
Definition: plugin.h:159
void * cfapi_log(int *type,...)
Definition: plugins.c:1069
void * cfapi_get_time(int *type,...)
Definition: plugins.c:924
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:290
char id[MAX_BUF]
Definition: plugin.h:140
int manual_apply(object *op, object *tmp, int aflag)
Definition: apply.c:512
#define CFAPI_DOUBLE
Definition: plugin.h:108
void * cfapi_object_clear(int *type,...)
Definition: plugins.c:3585
f_plug_api propfunc
Definition: plugin.h:137
void * cfapi_object_query_money(int *type,...)
Definition: plugins.c:3778
void * cfapi_object_apply_below(int *type,...)
Definition: plugins.c:3061
sint16 x
Definition: object.h:179
void remove_friendly_object(object *op)
Definition: friend.c:69
signed long sum_weight(object *op)
Definition: object.c:317
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:315
uint32 path_attuned
Definition: object.h:194
sint16 sp
Definition: living.h:83
#define EVENT_TELL
Definition: plugin.h:91
object * find_object(tag_t i)
Definition: object.c:439
#define EVENT_CRASH
Definition: plugin.h:81
int distance(const object *ob1, const object *ob2)
Definition: object.c:3364
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:299
#define CFAPI_OBJECT_PROP_SLAYING
Definition: plugin.h:180
Definition: win32.h:128
uint16 height
Definition: map.h:370
uint32 path_repelled
Definition: object.h:195
void * cfapi_object_create(int *type,...)
Definition: plugins.c:3355
int(* f_plug_postinit)(void)
Definition: plugin.h:123
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
Definition: standalone.c:175
char * partyname
Definition: player.h:124
struct obj * enemy
Definition: object.h:232
struct archt * other_arch
Definition: object.h:264
Definition: object.h:321
#define CFAPI_PMAP
Definition: plugin.h:106
void transmute_materialname(object *op, const object *change)
Definition: utils.c:281
char savebed_map[MAX_BUF]
Definition: player.h:151
Definition: plugin.h:336
char * host
Definition: newserver.h:125
#define CFAPI_POBJECT
Definition: plugin.h:105
#define CFAPI_OBJECT_PROP_CHOSEN_SKILL
Definition: plugin.h:221
#define PLAYER
Definition: define.h:113
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:228
sint16 maxsp
Definition: living.h:84
#define CFAPI_OBJECT_PROP_LAST_SP
Definition: plugin.h:205
sint8 Con
Definition: living.h:78
int change_map_light(mapstruct *m, int change)
Definition: map.c:2000
#define FLAG_REMOVED
Definition: define.h:528
sint16 hp
Definition: living.h:81
#define CFAPI_OBJECT_PROP_LAST_GRACE
Definition: plugin.h:206
#define CFAPI_OBJECT_PROP_COUNT
Definition: plugin.h:175
void * cfapi_system_add_string(int *type,...)
Definition: plugins.c:756
partylist * party
Definition: player.h:237
#define CFAPI_NONE
Definition: plugin.h:100
object * ob
Definition: object.h:299
int command_say(object *op, char *params)
Definition: c_chat.c:47
object * give_skill_by_name(object *op, const char *skill_name)
Definition: living.c:1689
const char * get_month_name(const int index)
Definition: time.c:120
#define CFAPI_FLOAT
Definition: plugin.h:107
void map_newmap_cmd(socket_struct *ns)
Definition: request.c:672
void * cfapi_object_learn_spell(int *type,...)
Definition: plugins.c:3829
void * cfapi_player_can_pay(int *type,...)
Definition: plugins.c:4188
struct _crossfire_plugin * next
Definition: plugin.h:143
const char * name
Definition: map.h:299
uint16 number
Definition: face.h:43
#define CFAPI_PLAYER_PROP_BED_X
Definition: plugin.h:279
char * name
Definition: map.h:349
#define CFAPI_PARCH
Definition: plugin.h:109
const char * lore
Definition: object.h:176
crossfire_plugin * plugins_find_plugin(const char *id)
Definition: plugins.c:604
struct obj * chosen_skill
Definition: object.h:237
int change_abil(object *op, object *tmp)
Definition: living.c:443
const char * title
Definition: object.h:170
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:291
int move_to(object *op, int x, int y)
Definition: move.c:626
void remove_ob(object *op)
Definition: object.c:1515
int is_friendly(const object *op)
Definition: friend.c:157
sint16 maxhp
Definition: living.h:82
sstring find_string(const char *str)
Definition: shstr.c:228
#define CFAPI_OBJECT_PROP_FACING
Definition: plugin.h:190
void * cfapi_object_merge(int *type,...)
Definition: plugins.c:3512
int user_event(object *op, object *activator, object *third, const char *message, int fix)
Definition: plugins.c:209
#define EVENT_MAPENTER
Definition: plugin.h:86
uint32 path_denied
Definition: object.h:196
command_array_struct * find_plugin_command(char *cmd, object *op)
Definition: plugins.c:4568
#define CFAPI_PLAYER_PROP_IP
Definition: plugin.h:275
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:171
Definition: win32.h:138
#define CFAPI_OBJECT_PROP_GP
Definition: plugin.h:254
LIBPTRTYPE libptr
Definition: plugin.h:139
sint32 weight_limit
Definition: object.h:217
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:249
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:312
const char * name_pl
Definition: object.h:168
f_plug_api eventfunc
Definition: plugin.h:136
#define LIBDIR
Definition: win32.h:110
#define CFAPI_OBJECT_PROP_ATTACKED_BY
Definition: plugin.h:219
#define CFAPI_STRING
Definition: plugin.h:104
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
Definition: plugin.h:272
object * get_player_container(object *op)
Definition: object.c:356
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:301
float speed_left
Definition: object.h:182
void * cfapi_object_check_spell(int *type,...)
Definition: plugins.c:3868
struct party_struct * next
Definition: player.h:123
#define CFAPI_OBJECT_PROP_INT
Definition: plugin.h:247
void * cfapi_generate_random_map(int *type,...)
Definition: plugins.c:4511
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:289
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:305
const char * materialname
Definition: object.h:197
sint32 weight
Definition: object.h:216
void * cfapi_object_transmute(int *type,...)
Definition: plugins.c:3206
#define CFAPI_OBJECT_PROP_LEVEL
Definition: plugin.h:203
void update_all_los(const mapstruct *map, int x, int y)
Definition: los.c:544
const char * tmpdir
Definition: global.h:343
f_plug_api gevent[NR_EVENTS]
Definition: plugin.h:142
sint8 Wis
Definition: living.h:78
#define CFAPI_OBJECT_PROP_HEAD
Definition: plugin.h:172
#define CFAPI_PLAYER_PROP_BED_MAP
Definition: plugin.h:278
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:268
void * cfapi_object_drain(int *type,...)
Definition: plugins.c:3154
struct mapdef * map
Definition: object.h:155
int pay_for_item(object *op, object *pl)
Definition: shop.c:652
struct regiondef * next
Definition: map.h:298
void * cfapi_system_strdup_local(int *type,...)
Definition: plugins.c:694
Definition: map.h:297
void * cfapi_object_drop(int *type,...)
Definition: plugins.c:4044
struct obj * active_prev
Definition: object.h:141
void drain_specific_stat(object *op, int deplete_stats)
Definition: living.c:760
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:304
f_plug_postinit closefunc
Definition: plugin.h:138
int plugins_init_plugin(const char *libfile)
Definition: plugins.c:455
void identify(object *op)
Definition: item.c:1447
char * msg
Definition: map.h:380
void * cfapi_party_get_property(int *type,...)
Definition: plugins.c:4320
int find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
Definition: object.c:3240
void update_position(mapstruct *m, int x, int y)
Definition: map.c:2124
sint16 dam
Definition: living.h:87
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Definition: plugins.c:213
void * cfapi_object_on_same_map(int *type,...)
Definition: plugins.c:3659
void add_friendly_object(object *op)
Definition: friend.c:43
#define CFAPI_OBJECT_PROP_FP
Definition: plugin.h:255
sint32 carrying
Definition: object.h:218
const char * name
Definition: object.h:167
struct obj * env
Definition: object.h:151
uint32 reset_timeout
Definition: map.h:354
void * cfapi_system_find_face(int *type,...)
Definition: plugins.c:670
int can_merge(object *ob1, object *ob2)
Definition: object.c:178
#define CFAPI_OBJECT_PROP_MAGICAL
Definition: plugin.h:234
sint64 perm_exp
Definition: object.h:220
void * cfapi_map_get_map_property(int *type,...)
Definition: plugins.c:1205
uint16 run_away
Definition: object.h:235
#define LIBPTRTYPE
Definition: plugin.h:128
object * get_owner(object *op)
Definition: object.c:524
struct obj * below
Definition: object.h:145
struct archt * more
Definition: object.h:325
void * cfapi_get_month_name(int *type,...)
Definition: plugins.c:981
archetype * find_archetype_by_object_name(const char *name)
Definition: arch.c:70
#define CFAPI_OBJECT_PROP_LAST_EAT
Definition: plugin.h:207
void fatal(int err)
Definition: glue.c:60
void * cfapi_object_teleport(int *type,...)
Definition: plugins.c:4210
void trigger_connected(objectlink *ol, object *cause, const int state)
Definition: button.c:52
sint16 last_grace
Definition: object.h:210
const char * re_cmp(const char *, const char *)
Definition: re-cmp.c:70
#define CFAPI_OBJECT_PROP_MOVE_OFF
Definition: plugin.h:270
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:213
struct obj * current_weapon
Definition: object.h:221
void * cfapi_object_pay_item(int *type,...)
Definition: plugins.c:3914
#define CFAPI_LONG
Definition: plugin.h:102
object * object_create_clone(object *asrc)
Definition: object.c:3608
void * cfapi_object_get_property(int *type,...)
Definition: plugins.c:1637
uint32 nrof
Definition: object.h:184
#define string_get_int(name)
Definition: plugins.c:937
void * cfapi_object_give_skill(int *type,...)
Definition: plugins.c:3189
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON
Definition: plugin.h:217
#define CFAPI_SSTRING
Definition: plugin.h:117
sint8 Cha
Definition: living.h:78
struct archt * head
Definition: object.h:324
int find_animation(const char *name)
Definition: anim.c:146
#define UPD_ALL
Definition: newclient.h:262
object * present_in_ob_by_name(int type, const char *str, const object *op)
Definition: object.c:2840
#define CFAPI_PPLAYER
Definition: plugin.h:111
#define P_OUT_OF_MAP
Definition: map.h:272
MoveType move_off
Definition: object.h:281
mapstruct * get_map_from_coord(mapstruct *m, sint16 *x, sint16 *y)
Definition: map.c:2366
int move_ob(object *op, int dir, object *originator)
Definition: move.c:72
int cftimer_destroy(int id)
Definition: timers.c:137
#define CFAPI_OBJECT_PROP_X
Definition: plugin.h:184
sint8 facing
Definition: object.h:186
void do_learn_spell(object *op, object *spell, int special_prayer)
Definition: apply.c:398
sint16 y
Definition: object.h:179
struct pl * contr
Definition: object.h:134
#define CFAPI_OBJECT_PROP_CHEATER
Definition: plugin.h:239
#define CFAPI_OBJECT_PROP_PICKABLE
Definition: plugin.h:241
sint8 item_power
Definition: object.h:213
void cleanupPlugins(void)
Definition: plugins.c:4623
int can_pick(const object *who, const object *item)
Definition: object.c:3569
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:298
void * cfapi_object_set_key(int *type,...)
Definition: plugins.c:1613
#define CFAPI_OBJECT_PROP_ENEMY
Definition: plugin.h:218
void * cfapi_get_weekday_name(int *type,...)
Definition: plugins.c:969
#define UPD_NROF
Definition: newclient.h:261
object * find_marked_object(object *op)
Definition: c_object.c:1339
#define CFAPI_OBJECT_PROP_PATH_REPELLED
Definition: plugin.h:197
void plugins_display_list(object *op)
Definition: plugins.c:622
object * present_arch(const archetype *at, mapstruct *m, int x, int y)
Definition: object.c:2755
archetype * try_find_archetype(const char *name)
Definition: arch.c:671
uint16 enter_y
Definition: map.h:372
void player_apply_below(object *pl)
Definition: apply.c:619
uint32 count
Definition: player.h:163
char d_name[_MAX_FNAME+1]
Definition: win32.h:132
sint8 luck
Definition: living.h:80
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h:287
float speed
Definition: object.h:181
char fullname[MAX_BUF]
Definition: plugin.h:141
struct regiondef * parent
Definition: map.h:307
int on_same_map(const object *op1, const object *op2)
Definition: map.c:2609
#define QUERY_FLAG(xyz, p)
Definition: define.h:514
const char * longname
Definition: map.h:312
uint8 state
Definition: object.h:200
#define CLEAR_FLAG(xyz, p)
Definition: define.h:512
char * strdup_local(const char *str)
Definition: porting.c:310
#define CFAPI_OBJECT_PROP_LORE
Definition: plugin.h:183
#define MSG_TYPE_MISC
Definition: newclient.h:335
#define EVENT_MAPLOAD
Definition: plugin.h:95
void * cfapi_object_query_cost(int *type,...)
Definition: plugins.c:3752
#define CFAPI_OBJECT_PROP_ITEM_POWER
Definition: plugin.h:210
void * cfapi_map_out_of_map(int *type,...)
Definition: plugins.c:1371
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:317
object * insert_ob_in_ob(object *op, object *where)
Definition: object.c:2510
#define MAX_BUF
Definition: define.h:81
void * cfapi_map_message(int *type,...)
Definition: plugins.c:1426
#define CFAPI_PARTY_PROP_NAME
Definition: plugin.h:309
struct obj * active_next
Definition: object.h:137
void * cfapi_system_re_cmp(int *type,...)
Definition: plugins.c:848
#define CFAPI_PLAYER_PROP_PARTY
Definition: plugin.h:277
LogLevel
Definition: logger.h:37
void * cfapi_get_periodofday_name(int *type,...)
Definition: plugins.c:993
object * object_create_arch(archetype *at)
Definition: arch.c:741
object * get_object(void)
Definition: object.c:921
#define EVENT_MAPUNLOAD
Definition: plugin.h:94
void drop(object *op, object *tmp)
Definition: c_object.c:943
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:236
void * cfapi_system_unregister_global_event(int *type,...)
Definition: plugins.c:729
int can_pay(object *pl)
Definition: shop.c:938
#define MSG_TYPE_COMMAND_DEBUG
Definition: newclient.h:446
object * insert_ob_in_map(object *op, mapstruct *m, object *originator, int flag)
Definition: object.c:1992
const char * skill
Definition: object.h:174
sint32 last_eat
Definition: object.h:207
#define plugins_dlerror()
Definition: plugin.h:161
#define EVENT_MAPRESET
Definition: plugin.h:88
sint8 wc
Definition: living.h:79
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:125
const char * confdir
Definition: global.h:333
void * cfapi_timer_destroy(int *type,...)
Definition: plugins.c:1046
static const flag_definition flags[]
#define EVENT_GKILL
Definition: plugin.h:83
#define CFAPI_OBJECT_PROP_PERM_EXP
Definition: plugin.h:216
const char * uniquedir
Definition: global.h:341
sint8 Str
Definition: living.h:78
char * tmpname
Definition: map.h:348
void * cfapi_map_get_map(int *type,...)
Definition: plugins.c:1095
void * cfapi_object_fix(int *type,...)
Definition: plugins.c:3173
sint16 resist[NROFATTACKS]
Definition: object.h:192
uint8 darkness
Definition: map.h:369
void * cfapi_get_season_name(int *type,...)
Definition: plugins.c:957
void * cfapi_archetype_get_property(int *type,...)
Definition: plugins.c:4262
object * ob
Definition: player.h:207
uint32 unique
Definition: map.h:358
const char * sstring
Definition: global.h:84
void * cfapi_object_split(int *type,...)
Definition: plugins.c:3483
#define EVENT_CLOCK
Definition: plugin.h:80
#define CFAPI_OBJECT_PROP_DAM
Definition: plugin.h:259
#define CFAPI_OBJECT_PROP_MOVE_TYPE
Definition: plugin.h:266
const char * datadir
Definition: global.h:334
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:181
#define CFAPI_PLAYER_PROP_NEXT
Definition: plugin.h:281
object * check_inv_recursive(object *op, const object *trig)
Definition: button.c:788
uint64 query_cost(const object *tmp, object *who, int flag)
Definition: shop.c:121
int snprintf(char *dest, int max, const char *format,...)
Definition: porting.c:498
sint16 bed_y
Definition: player.h:152
#define CFAPI_OBJECT_PROP_AC
Definition: plugin.h:251
#define SET_MAP_FLAGS(M, X, Y, C)
Definition: map.h:184
void * cfapi_player_message(int *type,...)
Definition: plugins.c:4134
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:233
#define TIMER_ERR_NONE
Definition: timers.h:68
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:316
void * cfapi_map_update_position(int *type,...)
Definition: plugins.c:1396
#define CFAPI_INT
Definition: plugin.h:101
uint32 attacktype
Definition: object.h:193
struct obj * spellitem
Definition: object.h:245
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:303
void * cfapi_object_delete(int *type,...)
Definition: plugins.c:3245
sint8 direction
Definition: object.h:185
void * cfapi_object_pickup(int *type,...)
Definition: plugins.c:4246
void * cfapi_object_forget_spell(int *type,...)
Definition: plugins.c:3845
partylist * get_firstparty(void)
Definition: c_party.c:48
int set_random_map_variable(RMParms *rp, const char *buf)
uint32 update_look
Definition: newserver.h:131
void * cfapi_friendlylist_get_next(int *type,...)
Definition: plugins.c:4439
void * cfapi_region_get_property(int *type,...)
Definition: plugins.c:4378
#define CFAPI_OBJECT_PROP_SPEED_LEFT
Definition: plugin.h:187
void * cfapi_get_hooks(int *type,...)
Definition: plugins.c:527
#define FREE_AND_COPY(sv, nv)
Definition: global.h:288
sint16 grace
Definition: living.h:85
int set_ob_key_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:3826
void get_tod(timeofday_t *tod)
Definition: time.c:268
void * cfapi_object_cast(int *type,...)
Definition: plugins.c:3800
const char * custom_name
Definition: object.h:285
void * cfapi_object_change_exp(int *type,...)
Definition: plugins.c:4162
void set_cheat(object *op)
Definition: object.c:2913
int cftimer_create(int id, long delay, object *ob, int mode)
Definition: timers.c:106
const char * localdir
Definition: global.h:335
tag_t count
Definition: object.h:157
uint16 width
Definition: map.h:370
living stats
Definition: object.h:219
mapstruct * has_been_loaded(const char *name)
Definition: map.c:87
sint8 Dex
Definition: living.h:78
struct archt * arch
Definition: object.h:263
#define CFAPI_OBJECT_PROP_HP
Definition: plugin.h:252
struct oblnk * next
Definition: object.h:300
uint32 reset_time
Definition: map.h:353
void * cfapi_object_pay_amount(int *type,...)
Definition: plugins.c:3891
object * present_arch_in_ob(const archetype *at, const object *op)
Definition: object.c:2859
#define CFAPI_OBJECT_PROP_TITLE
Definition: plugin.h:178
int cftimer_find_free_id(void)
Definition: timers.c:153
object * decrease_ob_nr(object *op, uint32 i)
Definition: object.c:2345
const char * mapdir
Definition: global.h:337
#define CFAPI_PLAYER_PROP_BED_Y
Definition: plugin.h:280
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:186
Definition: tod.h:61
void reset_object(object *op)
Definition: object.c:639
struct Settings settings
Definition: init.c:48
void * cfapi_object_apply(int *type,...)
Definition: plugins.c:3084
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:286
void * cfapi_map_create_path(int *type,...)
Definition: plugins.c:1170
#define CFAPI_OBJECT_PROP_FRIENDLY
Definition: plugin.h:231
#define CFAPI_OBJECT_PROP_ANIM_SPEED
Definition: plugin.h:230
struct archt * next
Definition: object.h:323
#define CFAPI_OBJECT_PROP_LUCK
Definition: plugin.h:235
void * cfapi_object_transfer(int *type,...)
Definition: plugins.c:3941
struct dirent * readdir(DIR *)
Definition: win32.c:116
const char * get_periodofday(const int index)
Definition: time.c:113
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:261
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.c:551
int out_of_map(mapstruct *m, int x, int y)
Definition: map.c:2300
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME
Definition: plugin.h:208
#define CFAPI_OBJECT_PROP_DEX
Definition: plugin.h:244
#define CFAPI_MOVETYPE
Definition: plugin.h:118
void * cfapi_map_trigger_connected(int *type,...)
Definition: plugins.c:3729
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
Definition: plugin.h:224
#define MSG_TYPE_COMMAND
Definition: newclient.h:326
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:300
void delete_map(mapstruct *m)
Definition: map.c:1745
const char * msg
Definition: object.h:175
uint8 no_save
Definition: object.h:288
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:294
void * cfapi_object_find(int *type,...)
Definition: plugins.c:3301
uint16 animation_id
Definition: object.h:267
#define CFAPI_OBJECT_PROP_CON
Definition: plugin.h:245
void * cfapi_system_register_global_event(int *type,...)
Definition: plugins.c:709
const char * msg
Definition: map.h:314
void describe_item(const object *op, const object *owner, char *retbuf, size_t size)
Definition: item.c:1018
void update_ob_speed(object *op)
Definition: object.c:1008
void * cfapi_object_check_trigger(int *type,...)
Definition: plugins.c:3699
void * cfapi_object_find_archetype_inside(int *type,...)
Definition: plugins.c:4004
sstring add_string(const char *str)
Definition: shstr.c:116
EXTERN player * first_player
Definition: global.h:190
void * cfapi_object_describe(int *type,...)
Definition: plugins.c:3134
#define EVENT_CONNECTOR
Definition: define.h:300
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:310
void * cfapi_object_spring_trap(int *type,...)
Definition: plugins.c:3677
struct pl * next
Definition: player.h:147
#define UPD_WEIGHT
Definition: newclient.h:256
#define GET_MAP_OB(M, X, Y)
Definition: map.h:193
int check_path(const char *name, int prepend_dir)
Definition: map.c:216
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:188
void clear_object(object *op)
Definition: object.c:688
void * cfapi_object_change_abil(int *type,...)
Definition: plugins.c:4070
sint8 glow_radius
Definition: object.h:215
#define CFAPI_OBJECT_PROP_MAXSP
Definition: plugin.h:257
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:307
uint8 anim_speed
Definition: object.h:268
struct _crossfire_plugin * prev
Definition: plugin.h:144
#define EVENT_PLAYER_DEATH
Definition: plugin.h:82
sint8 Pow
Definition: living.h:78
int closedir(DIR *)
Definition: win32.c:149
struct obj * inv
Definition: object.h:148
#define NDI_UNIQUE
Definition: newclient.h:219
#define CFAPI_PLAYER_PROP_MARKED_ITEM
Definition: plugin.h:276
struct obj * head
Definition: object.h:154
#define CFAPI_OBJECT_PROP_LAST_HEAL
Definition: plugin.h:204
#define CFAPI_OBJECT_PROP_CLIENT_TYPE
Definition: plugin.h:193
#define CFAPI_OBJECT_PROP_INVISIBLE
Definition: plugin.h:262
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:63
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:191
object * get_split_ob(object *orig_ob, uint32 nr, char *err, size_t size)
Definition: object.c:2313
#define CFAPI_OBJECT_PROP_POW
Definition: plugin.h:248
object * mark
Definition: player.h:248
unsigned int uint32
Definition: global.h:58
#define FLAG_WAS_WIZ
Definition: define.h:530
EXTERN region * first_region
Definition: global.h:192
uint8 pick_up
Definition: object.h:212
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR
Definition: plugin.h:211
int transfer_ob(object *op, int x, int y, int randomly, object *originator)
Definition: move.c:197
MoveType move_block
Definition: object.h:278
void * cfapi_map_delete_map(int *type,...)
Definition: plugins.c:1413
#define CFAPI_OBJECT_PROP_GLOW_RADIUS
Definition: plugin.h:215
struct mapdef * next
Definition: map.h:347
void * cfapi_object_update(int *type,...)
Definition: plugins.c:3562
int check_trigger(object *op, object *cause)
Definition: button.c:525
#define CFAPI_OBJECT_PROP_PRESENT
Definition: plugin.h:238
void copy_object(object *op2, object *op)
Definition: object.c:758
float move_slow_penalty
Definition: object.h:283
#define CFAPI_OBJECT_PROP_MERGEABLE
Definition: plugin.h:240
#define CFAPI_OBJECT_PROP_WC
Definition: plugin.h:250
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:628
#define CFAPI_OBJECT_PROP_RESIST
Definition: plugin.h:194
#define CFAPI_OBJECT_PROP_SHORT_NAME
Definition: plugin.h:232
#define CFAPI_OBJECT_PROP_MOVE_SLOW
Definition: plugin.h:271
#define CFAPI_OBJECT_PROP_MATERIAL_NAME
Definition: plugin.h:200
void free_object(object *ob)
Definition: object.c:1238
void create_overlay_pathname(const char *name, char *buf, size_t size)
Definition: map.c:135
int pay_for_amount(uint64 to_pay, object *pl)
Definition: shop.c:613
Definition: map.h:346
void * cfapi_object_user_event(int *type,...)
Definition: plugins.c:4530
New_Face * face
Definition: object.h:183
#define CFAPI_OBJECT_PROP_MAXHP
Definition: plugin.h:256
void * cfapi_object_distance(int *type,...)
Definition: plugins.c:3538
#define FLAG_UNIQUE
Definition: define.h:584
uint32 mark_count
Definition: player.h:247
#define CFAPI_OBJECT_PROP_VALUE
Definition: plugin.h:202
#define CFAPI_OBJECT_PROP_SPELL_ITEM
Definition: plugin.h:225
void * cfapi_system_find_animation(int *type,...)
Definition: plugins.c:648
#define CFAPI_OBJECT_PROP_PATH_ATTUNED
Definition: plugin.h:196
sint16 level
Definition: object.h:202
void fix_object(object *op)
Definition: living.c:900
static void send_changed_object(object *op)
Definition: plugins.c:184
unsigned find_face(const char *name, unsigned error)
Definition: image.c:324
player * find_player_partial_name(const char *plname)
Definition: player.c:84
#define CFAPI_OBJECT_PROP_WIS
Definition: plugin.h:246
EXTERN mapstruct * first_map
Definition: global.h:191
#define CFAPI_OBJECT_PROP_DURATION
Definition: plugin.h:273
EXTERN archetype * first_archetype
Definition: global.h:195
void * cfapi_system_check_path(int *type,...)
Definition: plugins.c:822
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:296
void clean_object(object *op)
Definition: map.c:1640
void * cfapi_map_set_map_property(int *type,...)
Definition: plugins.c:1338
sint32 value
Definition: object.h:201
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:166
sint8 magic
Definition: object.h:199
void * cfapi_object_check_inventory(int *type,...)
Definition: plugins.c:3621
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:185
#define CFAPI_OBJECT_PROP_CUSTOM_NAME
Definition: plugin.h:229
void ext_info_map(int color, const mapstruct *map, uint8 type, uint8 subtype, const char *str1, const char *str2)
Definition: standalone.c:184
const char * name
Definition: object.h:322
#define EVENT_BORN
Definition: plugin.h:79
int plugins_remove_plugin(const char *id)
Definition: plugins.c:566
int execute_global_event(int eventcode,...)
Definition: plugins.c:274
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB
Definition: plugin.h:169
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Definition: spell_util.c:1308
#define EVENT_USER
Definition: plugin.h:75
uint8 type
Definition: object.h:189
#define CFAPI_OBJECT_PROP_PATH_DENIED
Definition: plugin.h:198
#define CFAPI_OBJECT_PROP_MOVE_BLOCK
Definition: plugin.h:267
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:314
sint8 gen_sp_armour
Definition: object.h:214
struct obj * attacked_by
Definition: object.h:233
void * cfapi_set_random_map_variable(int *type,...)
Definition: plugins.c:4485
#define CFAPI_PPARTY
Definition: plugin.h:112
void * cfapi_player_find(int *type,...)
Definition: plugins.c:4118
sint32 food
Definition: living.h:89
uint16 enter_x
Definition: map.h:371
#define FLAG_FREED
Definition: define.h:529
#define EVENT_MUZZLE
Definition: plugin.h:92
char passwd[9]
Definition: player.h:122
uint32 hide
Definition: object.h:238