Crossfire Server, Trunk  R20513
plugin_common.c
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* Crossfire Plugin Interface Common Parts */
3 /* Version: 2.0beta8 (also known as "Alexander") */
4 /* Contact: yann.chachkoff@myrealbox.com */
5 /*****************************************************************************/
6 /* The CPICP are the various functions of the server that can be used by all */
7 /* plugins. It is recommended that plugins do not call the server-provided */
8 /* functions directly, but instead use the wrappers provided here by the */
9 /* CPICP interface. By doing so, various validity checks can be performed */
10 /* by CPICP, protecting the server from potential nasty effects of passing */
11 /* it wrong parameter values. */
12 /*****************************************************************************/
13 /* That code is placed under the GNU General Public Licence (GPL) */
14 /* (C)2001-2005 by Chachkoff Yann (Feel free to deliver your complaints) */
15 /*****************************************************************************/
16 /* CrossFire, A Multiplayer game for X-windows */
17 /* */
18 /* Copyright (C) 2000 Mark Wedel */
19 /* Copyright (C) 1992 Frank Tore Johansen */
20 /* */
21 /* This program is free software; you can redistribute it and/or modify */
22 /* it under the terms of the GNU General Public License as published by */
23 /* the Free Software Foundation; either version 2 of the License, or */
24 /* (at your option) any later version. */
25 /* */
26 /* This program is distributed in the hope that it will be useful, */
27 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
28 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
29 /* GNU General Public License for more details. */
30 /* */
31 /* You should have received a copy of the GNU General Public License */
32 /* along with this program; if not, write to the Free Software */
33 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
34 /* */
35 /*****************************************************************************/
36 
37 #include <assert.h>
38 #include <string.h>
39 
40 #include "plugin_common.h"
41 
56 
129 
130 #define GET_HOOK(x, y, z) { \
131  getHooks(&z, 1, y, &x); \
132  if (z != CFAPI_FUNC) { \
133  printf("unable to find hook %s!\n", y); \
134  return 0; \
135  } \
136 }
137 
138 int cf_init_plugin(f_plug_api getHooks) {
139  int z;
140 
141  GET_HOOK(cfapiSystem_strdup_local, "cfapi_system_strdup_local", z);
142  GET_HOOK(cfapiSystem_add_string, "cfapi_system_add_string", z);
143  GET_HOOK(cfapiSystem_register_global_event, "cfapi_system_register_global_event", z);
144  GET_HOOK(cfapiSystem_remove_string, "cfapi_system_remove_string", z);
145  GET_HOOK(cfapiSystem_directory, "cfapi_system_directory", z);
146  GET_HOOK(cfapiSystem_unregister_global_event, "cfapi_system_unregister_global_event", z);
147  GET_HOOK(cfapiSystem_find_animation, "cfapi_system_find_animation", z);
148  GET_HOOK(cfapiSystem_find_face, "cfapi_system_find_face", z);
149  GET_HOOK(cfapiSystem_re_cmp, "cfapi_system_re_cmp", z);
150  GET_HOOK(cfapiObject_get_property, "cfapi_object_get_property", z);
151  GET_HOOK(cfapiObject_set_property, "cfapi_object_set_property", z);
152  GET_HOOK(cfapiObject_apply, "cfapi_object_apply", z);
153  GET_HOOK(cfapiObject_identify, "cfapi_object_identify", z);
154  GET_HOOK(cfapiObject_describe, "cfapi_object_describe", z);
155  GET_HOOK(cfapiObject_drain, "cfapi_object_drain", z);
156  GET_HOOK(cfapiObject_fix, "cfapi_object_fix", z);
157  GET_HOOK(cfapiObject_give_skill, "cfapi_object_give_skill", z);
158  GET_HOOK(cfapiObject_transmute, "cfapi_object_transmute", z);
159  GET_HOOK(cfapiObject_remove, "cfapi_object_remove", z);
160  GET_HOOK(cfapiObject_delete, "cfapi_object_delete", z);
161  GET_HOOK(cfapiObject_clone, "cfapi_object_clone", z);
162  GET_HOOK(cfapiObject_create, "cfapi_object_create", z);
163  GET_HOOK(cfapiObject_insert, "cfapi_object_insert", z);
164  GET_HOOK(cfapiObject_split, "cfapi_object_split", z);
165  GET_HOOK(cfapiObject_merge, "cfapi_object_merge", z);
166  GET_HOOK(cfapiObject_distance, "cfapi_object_distance", z);
167  GET_HOOK(cfapiObject_update, "cfapi_object_update", z);
168  GET_HOOK(cfapiObject_clear, "cfapi_object_clear", z);
169  GET_HOOK(cfapiObject_reset, "cfapi_object_reset", z);
170  GET_HOOK(cfapiObject_activate_rune, "cfapi_object_spring_trap", z);
171  GET_HOOK(cfapiObject_check_trigger, "cfapi_object_check_trigger", z);
172  GET_HOOK(cfapiObject_query_money, "cfapi_object_query_money", z);
173  GET_HOOK(cfapiObject_cast, "cfapi_object_cast", z);
174  GET_HOOK(cfapiObject_learn_spell, "cfapi_object_learn_spell", z);
175  GET_HOOK(cfapiObject_forget_spell, "cfapi_object_forget_spell", z);
176  GET_HOOK(cfapiObject_check_spell, "cfapi_object_check_spell", z);
177  GET_HOOK(cfapiObject_pay_amount, "cfapi_object_pay_amount", z);
178  GET_HOOK(cfapiObject_pay_item, "cfapi_object_pay_item", z);
179  GET_HOOK(cfapiObject_transfer, "cfapi_object_transfer", z);
180  GET_HOOK(cfapiObject_find_archetype_inside, "cfapi_object_find_archetype_inside", z);
181  GET_HOOK(cfapiObject_remove, "cfapi_object_remove", z);
182  GET_HOOK(cfapiObject_delete, "cfapi_object_delete", z);
183  GET_HOOK(cfapiObject_out_of_map, "cfapi_map_out_of_map", z);
184  GET_HOOK(cfapiObject_drop, "cfapi_object_drop", z);
185  GET_HOOK(cfapiObject_change_abil, "cfapi_object_change_abil", z);
186  GET_HOOK(cfapiObject_say, "cfapi_object_say", z);
187  GET_HOOK(cfapiMap_create_path, "cfapi_map_create_path", z);
188  GET_HOOK(cfapiMap_get_property, "cfapi_map_get_property", z);
189  GET_HOOK(cfapiMap_set_property, "cfapi_map_set_property", z);
190  GET_HOOK(cfapiMap_get_map, "cfapi_map_get_map", z);
191  GET_HOOK(cfapiMap_message, "cfapi_map_message", z);
192  GET_HOOK(cfapiMap_get_object_at, "cfapi_map_get_object_at", z);
193  GET_HOOK(cfapiMap_find_by_archetype_name, "cfapi_map_find_by_archetype_name", z);
194  GET_HOOK(cfapiMap_change_light, "cfapi_map_change_light", z);
195  GET_HOOK(cfapiMap_has_been_loaded, "cfapi_map_has_been_loaded", z);
196  GET_HOOK(cfapiMap_trigger_connected, "cfapi_map_trigger_connected", z);
197  GET_HOOK(cfapiPlayer_find, "cfapi_player_find", z);
198  GET_HOOK(cfapiPlayer_message, "cfapi_player_message", z);
199  GET_HOOK(cfapiObject_teleport, "cfapi_object_teleport", z);
200  GET_HOOK(cfapiObject_pickup, "cfapi_object_pickup", z);
201  GET_HOOK(cfapiObject_get_key, "cfapi_object_get_key", z);
202  GET_HOOK(cfapiObject_set_key, "cfapi_object_set_key", z);
203  GET_HOOK(cfapiObject_move, "cfapi_object_move", z);
204  GET_HOOK(cfapiObject_apply_below, "cfapi_object_apply_below", z);
205  GET_HOOK(cfapiArchetype_get_property, "cfapi_archetype_get_property", z);
206  GET_HOOK(cfapiParty_get_property, "cfapi_party_get_property", z);
207  GET_HOOK(cfapiRegion_get_property, "cfapi_region_get_property", z);
208  GET_HOOK(cfapiPlayer_can_pay, "cfapi_player_can_pay", z);
209  GET_HOOK(cfapiSystem_log, "cfapi_log", z);
210  GET_HOOK(cfapiSystem_get_time, "cfapi_system_get_time", z);
211  GET_HOOK(cfapiSystem_timer_create, "cfapi_system_timer_create", z);
212  GET_HOOK(cfapiSystem_timer_destroy, "cfapi_system_timer_destroy", z);
213  GET_HOOK(cfapiFriendlylist_get_next, "cfapi_friendlylist_get_next", z);
214  GET_HOOK(cfapiSet_random_map_variable, "cfapi_set_random_map_variable", z);
215  GET_HOOK(cfapiGenerate_random_map, "cfapi_generate_random_map", z);
216  GET_HOOK(cfapiObject_change_exp, "cfapi_object_change_exp", z);
217  GET_HOOK(cfapiSystem_get_season_name, "cfapi_system_get_season_name", z);
218  GET_HOOK(cfapiSystem_get_month_name, "cfapi_system_get_month_name", z);
219  GET_HOOK(cfapiSystem_get_weekday_name, "cfapi_system_get_weekday_name", z);
220  GET_HOOK(cfapiSystem_get_periodofday_name, "cfapi_system_get_periodofday_name", z);
221  GET_HOOK(cfapiObject_user_event, "cfapi_object_user_event", z);
222  GET_HOOK(cfapiSystem_find_string, "cfapi_system_find_string", z);
223  GET_HOOK(cfapiCost_string_from_value, "cfapi_cost_string_from_value", z);
224  GET_HOOK(cfapiPlayer_quest, "cfapi_player_quest", z);
225  GET_HOOK(cfapiObject_remove_depletion, "cfapi_object_remove_depletion", z);
226  GET_HOOK(cfapiObject_find_by_arch_name, "cfapi_object_find_by_arch_name", z);
227  GET_HOOK(cfapiObject_find_by_name, "cfapi_object_find_by_name", z);
228  GET_HOOK(cfapiPlayer_knowledge, "cfapi_player_knowledge", z);
229  return 1;
230 }
231 
232 /* Should get replaced by tons of more explicit wrappers */
233 /*void *cf_map_get_property(mapstruct *map, int propcode) {
234  int type;
235  return cfapiMap_get_property(&type, propcode, map);
236 }*/
237 
238 int cf_map_get_int_property(mapstruct *map, int property) {
239  int type, value;
240 
241  cfapiMap_get_property(&type, map, property, &value);
242  assert(type == CFAPI_INT);
243  return value;
244 }
245 
246 int cf_object_user_event(object *op, object *activator, object *third, const char *message, int fix) {
247  int type, value;
248 
249  cfapiObject_user_event(&type, op, activator, third, message, fix, &value);
250  assert(type == CFAPI_INT);
251  return value;
252 }
253 
255  int type;
256  sstring value;
257 
258  cfapiMap_get_property(&type, map, propcode, &value);
259  assert(type == CFAPI_SSTRING);
260  return value;
261 }
262 
264  int type;
265  mapstruct *value;
266 
267  cfapiMap_get_property(&type, map, propcode, &value);
268  assert(type == CFAPI_PMAP);
269  return value;
270 }
271 
273  int type;
274  region *value;
275 
276  cfapiMap_get_property(&type, map, propcode, &value);
277  assert(type == CFAPI_PREGION);
278  return value;
279 }
280 
281 /* Should get replaced by tons of more explicit wrappers */
282 void cf_map_set_int_property(mapstruct *map, int propcode, int value) {
283  int type;
284 
285  cfapiMap_set_property(&type, map, propcode, value);
286  assert(type == CFAPI_INT);
287 }
288 
289 void cf_map_set_string_property(mapstruct *map, int propcode, const char *value) {
290  int type;
291 
292  cfapiMap_set_property(&type, map, propcode, value);
293  assert(type == CFAPI_STRING);
294 }
295 
296 /* Should get replaced by tons of more explicit wrappers */
297 int16_t cf_object_get_resistance(object *op, int rtype) {
298  int type;
299  int16_t resist;
300 
301  cfapiObject_get_property(&type, op, CFAPI_OBJECT_PROP_RESIST, rtype, &resist);
302  assert(type == CFAPI_INT16);
303  return resist;
304 }
305 void cf_object_set_resistance(object *op, int rtype, int16_t value) {
306  int type;
307 
308  cfapiObject_set_property(&type, op, CFAPI_OBJECT_PROP_RESIST, rtype, value);
309  assert(type == CFAPI_INT16);
310 }
311 
312 /* Should get replaced by tons of more explicit wrappers */
313 void cf_object_set_int_property(object *op, int propcode, int value) {
314  int type;
315 
316  cfapiObject_set_property(&type, op, propcode, value);
317  assert(type == CFAPI_INT);
318 }
319 int cf_object_get_int_property(object *op, int propcode) {
320  int type, value;
321 
322  cfapiObject_get_property(&type, op, propcode, &value);
323  assert(type == CFAPI_INT);
324  return value;
325 }
326 long cf_object_get_long_property(object *op, long propcode) {
327  int type;
328  long value;
329 
330  cfapiObject_get_property(&type, op, propcode, &value);
331  assert(type == CFAPI_LONG);
332  return value;
333 }
334 void cf_object_set_movetype_property(object *op, int propcode, MoveType value) {
335  int type;
336 
337  /* note: MoveType can't be used through va_arg, so use MoveType * */
338  cfapiObject_set_property(&type, op, propcode, &value);
339  assert(type == CFAPI_MOVETYPE);
340 }
341 MoveType cf_object_get_movetype_property(object *op, int propcode) {
342  int type;
343  MoveType value;
344 
345  cfapiObject_get_property(&type, op, propcode, &value);
346  assert(type == CFAPI_MOVETYPE);
347  return value;
348 }
349 object *cf_object_get_object_property(object *op, int propcode) {
350  int type;
351  object *value;
352 
353  cfapiObject_get_property(&type, op, propcode, &value);
354  assert(type == CFAPI_POBJECT);
355  return value;
356 }
357 mapstruct *cf_object_get_map_property(object *op, int propcode) {
358  int type;
359  mapstruct *value;
360 
361  cfapiObject_get_property(&type, op, propcode, &value);
362  assert(type == CFAPI_PMAP);
363  return value;
364 }
365 int64_t cf_object_get_int64_property(object *op, int propcode) {
366  int type;
367  int64_t value;
368 
369  cfapiObject_get_property(&type, op, propcode, &value);
370  assert(type == CFAPI_SINT64);
371  return value;
372 }
373 /* Should get replaced by tons of more explicit wrappers */
374 void cf_object_set_long_property(object *op, int propcode, long value) {
375  int type;
376 
377  cfapiObject_set_property(&type, op, propcode, value);
378  assert(type == CFAPI_LONG);
379 }
380 void cf_object_set_float_property(object *op, int propcode, float value) {
381  int type;
382 
383  cfapiObject_set_property(&type, op, propcode, value);
384  assert(type == CFAPI_FLOAT);
385 }
386 void cf_object_set_int64_property(object *op, int propcode, int64_t value) {
387  int type;
388 
389  cfapiObject_set_property(&type, op, propcode, value);
390  assert(type == CFAPI_SINT64);
391 }
392 float cf_object_get_float_property(object *op, int propcode) {
393  int type;
394  float value;
395 
396  cfapiObject_get_property(&type, op, propcode, &value);
397  assert(type == CFAPI_FLOAT);
398  return value;
399 }
400 archetype *cf_object_get_archetype_property(object *op, int propcode) {
401  int type;
402  archetype *value;
403 
404  cfapiObject_get_property(&type, op, propcode, &value);
405  assert(type == CFAPI_PARCH);
406  return value;
407 }
408 partylist *cf_object_get_partylist_property(object *op, int propcode) {
409  int type;
410  partylist *value;
411 
412  cfapiObject_get_property(&type, op, propcode, &value);
413  assert(type == CFAPI_PPARTY);
414  return value;
415 }
416 double cf_object_get_double_property(object *op, int propcode) {
417  int type;
418  double value;
419 
420  cfapiObject_get_property(&type, op, propcode, &value);
421  assert(type == CFAPI_DOUBLE);
422  return value;
423 }
424 sstring cf_object_get_sstring_property(object *op, int propcode) {
425  int type;
426  sstring value;
427 
428  cfapiObject_get_property(&type, op, propcode, &value);
429  assert(type == CFAPI_SSTRING);
430  return value;
431 }
432 char *cf_object_get_string_property(object *op, int propcode, char *buf, int size) {
433  int type;
434 
435  cfapiObject_get_property(&type, op, propcode, buf, size);
436  assert(type == CFAPI_STRING);
437  return buf;
438 }
439 /* Should get replaced by tons of more explicit wrappers */
440 void cf_object_set_string_property(object *op, int propcode, const char *value) {
441  int type;
442 
443  /* use cf_object_set_face() for changing the face! */
444  assert(propcode != CFAPI_OBJECT_PROP_FACE);
445  /* use cf_object_set_animation() to change the animation */
446  assert(propcode != CFAPI_OBJECT_PROP_ANIMATION);
447 
448  cfapiObject_set_property(&type, op, propcode, value);
449  assert(type == CFAPI_STRING);
450 }
451 
458 int cf_object_set_face(object *op, const char *face) {
459  int type, ret;
460  cfapiObject_set_property(&type, op, CFAPI_OBJECT_PROP_FACE, face, &ret);
461  assert(type == CFAPI_INT);
462  return ret;
463 }
470 int cf_object_set_animation(object *op, const char *animation) {
471  int type, ret;
472  cfapiObject_set_property(&type, op, CFAPI_OBJECT_PROP_ANIMATION, animation, &ret);
473  assert(type == CFAPI_INT);
474  return ret;
475 }
476 
477 void cf_object_set_object_property(object *op, int propcode, object *value) {
478  int type;
479 
480  cfapiObject_set_property(&type, op, propcode, value);
481  assert(type == CFAPI_POBJECT);
482 }
483 
488 void cf_object_change_exp(object *op, int64_t exp, const char *skill_name, int flag) {
489  int type;
490 
491  cfapiObject_change_exp(&type, op, exp, skill_name && strlen(skill_name) > 0 ? skill_name : NULL, flag);
492  assert(type == CFAPI_NONE);
493 }
494 int cf_player_move(player *pl, int dir) {
495  int type, ret;
496 
497  cfapiObject_move(&type, 1, pl, dir, &ret);
498  assert(type == CFAPI_INT);
499  return ret;
500 }
501 int cf_object_move(object *op, int dir, object*originator) {
502  int type, ret;
503 
504  cfapiObject_move(&type, 0, op, dir, originator, &ret);
505  assert(type == CFAPI_INT);
506  return ret;
507 }
512 int cf_object_apply(object *op, object *tmp, int aflag) {
513  int type, ret;
514 
515  cfapiObject_apply(&type, op, tmp, aflag, &ret);
516  return ret;
517 }
518 
523 void cf_object_apply_below(object *pl) {
524  int type;
525 
526  cfapiObject_apply_below(&type, pl);
527 }
532 void cf_object_remove(object *op) {
533  int type;
534 
535  cfapiObject_remove(&type, op);
536 }
542  int type;
543 
544  cfapiObject_delete(&type, ob);
545 }
549 object *cf_object_present_archname_inside(object *op, char *whatstr) {
550  int type;
551  object *value;
552 
553  cfapiObject_find_archetype_inside(&type, op, whatstr, &value);
554  assert(type == CFAPI_POBJECT);
555  return value;
556 }
557 
562 object *cf_object_find_by_arch_name(const object *who, const char *name) {
563  int type;
564  object *result;
565 
566  cfapiObject_find_by_arch_name(&type, who, name, &result);
567  assert(type == CFAPI_POBJECT);
568  return result;
569 }
570 
575 object *cf_object_find_by_name(const object *who, const char *name) {
576  int type;
577  object *result;
578 
579  cfapiObject_find_by_name(&type, who, name, &result);
580  assert(type == CFAPI_POBJECT);
581  return result;
582 }
583 
588 int cf_object_transfer(object *op, int x, int y, int randomly, object *originator) {
589  int type, value;
590 
591  cfapiObject_transfer(&type, op, 0, x, y, randomly, originator, &value);
592  assert(type == CFAPI_INT);
593  return value;
594 }
595 
600 int cf_object_move_to(object *op, int x, int y) {
601  int type, value;
602 
603  cfapiObject_transfer(&type, op, 2, x, y, &value);
604  assert(type == CFAPI_INT);
605  return value;
606 }
607 
612 object *cf_object_change_map(object *op, mapstruct *m, object *originator, int flag, int x, int y) {
613  int type;
614  object *value;
615 
616  cfapiObject_transfer(&type, op, 1, m, originator, flag, x, y, &value);
617  assert(type == CFAPI_POBJECT);
618  return value;
619 }
620 
625 object *cf_map_get_object_at(mapstruct *m, int x, int y) {
626  int type;
627  object *value;
628 
629  cfapiMap_get_object_at(&type, m, x, y, &value);
630  assert(type == CFAPI_POBJECT);
631  return value;
632 }
637 void cf_map_message(mapstruct *m, const char *msg, int color) {
638  int type;
639 
640  cfapiMap_message(&type, m, msg, color);
641 }
642 
653 object *cf_object_clone(object *op, int clonetype) {
654  int type;
655  object *value;
656 
657  cfapiObject_clone(&type, op, clonetype, &value);
658  assert(type == CFAPI_POBJECT);
659  return value;
660 }
661 
662 
667 object *cf_object_split(object *orig_ob, uint32_t nr, char *err, size_t size) {
668  int type;
669  object *value;
670 
671  cfapiObject_split(&type, orig_ob, nr, err, size, &value);
672 
673  if (value == NULL)
674  {
675  assert(type == CFAPI_NONE);
676  }
677  else
678  {
679  assert(type == CFAPI_POBJECT);
680  }
681 
682  return value;
683 }
684 
685 
690 int cf_object_pay_item(object *op, object *pl) {
691  int type, value;
692 
693  cfapiObject_pay_item(&type, op, pl, &value);
694  assert(type == CFAPI_INT);
695  return value;
696 }
697 
702 int cf_object_pay_amount(object *pl, uint64_t to_pay) {
703  int type, value;
704 
705  cfapiObject_pay_amount(&type, pl, to_pay, &value);
706  assert(type == CFAPI_INT);
707  return value;
708 }
709 
714 int cf_object_cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg) {
715  int type, value;
716 
717  cfapiObject_cast(&type, op, caster, dir, spell_ob, stringarg, &value);
718  assert(type == CFAPI_INT);
719  return value;
720 }
726 int cf_object_cast_ability(object *caster, object *ctoo, int dir, object *sp, char *flags) {
727  int type, value;
728 
729  cfapiObject_cast(&type, caster, ctoo, dir, sp, flags, &value);
730  assert(type == CFAPI_INT);
731  return value;
732 }
733 
738 void cf_object_learn_spell(object *op, object *spell, int special_prayer) {
739  int type;
740 
741  cfapiObject_learn_spell(&type, op, spell, special_prayer);
742  assert(type == CFAPI_NONE);
743 }
744 
750 void cf_object_forget_spell(object *op, object *sp) {
751  int type;
752 
753  cfapiObject_forget_spell(&type, op, sp);
754 }
755 
760 object *cf_object_check_for_spell(object *op, const char *name) {
761  int type;
762  object *value;
763 
764  cfapiObject_check_spell(&type, op, name, &value);
765  assert(type == CFAPI_POBJECT);
766  return value;
767 }
768 
769 void cf_player_message(object *op, char *txt, int flags) {
770  int type;
771 
772  cfapiPlayer_message(&type, flags, 0, op, txt);
773  assert(type == CFAPI_NONE);
774 }
775 
780 int cf_object_remove_depletion(object *op, int level) {
781  int type, result;
782 
783  cfapiObject_remove_depletion(&type, op, level, &result);
784  assert(type == CFAPI_INT);
785  return result;
786 }
787 
794 object *cf_identify(object *op) {
795  int type;
796  object *result;
797 
798  cfapiObject_identify(&type, op, &result);
799  assert(type == CFAPI_POBJECT);
800  return result;
801 }
802 
807 player *cf_player_find(const char *plname) {
808  int type;
809  player *value;
810 
811  cfapiPlayer_find(&type, plname, &value);
812  assert(type == CFAPI_PPLAYER);
813  return value;
814 }
815 
816 char *cf_player_get_title(object *op, char *title, int size) {
817  int type;
818 
819  cfapiObject_get_property(&type, op, CFAPI_PLAYER_PROP_TITLE, title, size);
820  assert(type == CFAPI_STRING);
821  return title;
822 }
823 
824 void cf_player_set_title(object *op, const char *title) {
825  int type;
826 
828 }
829 
831  int type;
832  sstring value;
833 
835  assert(type == CFAPI_SSTRING);
836  return value;
837 }
838 
839 object *cf_player_get_marked_item(object *op) {
840  int type;
841  object *value;
842 
844  assert(type == CFAPI_POBJECT);
845  return value;
846 }
847 
848 void cf_player_set_marked_item(object *op, object *ob) {
849  int type;
850 
852 }
853 
856 }
857 
858 void cf_player_set_party(object *op, partylist *party) {
859  int type;
860 
862 }
863 
868 int cf_player_can_pay(object *pl) {
869  int type, value;
870 
871  cfapiPlayer_can_pay(&type, pl, &value);
872  assert(type == CFAPI_INT);
873  return value;
874 }
875 
882 int cf_player_knowledge_has(object *op, const char *knowledge) {
883  int type, value;
884 
885  cfapiPlayer_knowledge(&type, 1, op, knowledge, &value);
886  assert(type == CFAPI_INT);
887  return value;
888 }
889 
895 void cf_player_knowledge_give(object *op, const char *knowledge) {
896  int type;
897 
898  cfapiPlayer_knowledge(&type, 2, op, knowledge);
899  assert(type == CFAPI_NONE);
900 }
901 
906 int cf_player_arrest(object *who) {
907  int type, value;
908  cfapiObject_move(&type, 2, who, &value);
909  assert(type == CFAPI_INT);
910  return value;
911 }
912 
917 mapstruct *cf_map_get_map(const char *name, int flags) {
918  int type;
919  mapstruct *ret;
920 
921  cfapiMap_get_map(&type, 1, name, flags, &ret);
922  assert(type == CFAPI_PMAP);
923  return ret;
924 }
925 
930 mapstruct *cf_get_empty_map(int sizex, int sizey) {
931  int type;
932  mapstruct *ret;
933 
934  cfapiMap_get_map(&type, 0, sizex, sizey, &ret);
935  assert(type == CFAPI_PMAP);
936  return ret;
937 }
938 
943 mapstruct *cf_map_has_been_loaded(const char *name) {
944  int type;
945  mapstruct *ret;
946 
947  cfapiMap_has_been_loaded(&type, name, &ret);
948  assert(type == CFAPI_PMAP);
949  return ret;
950 }
951 
959 }
960 
965 int cf_object_query_money(const object *op) {
966  int type, value;
967 
968  cfapiObject_query_money(&type, op, &value);
969  assert(type == CFAPI_INT);
970  return value;
971 }
972 
976 void cf_cost_string_from_value(uint64_t cost, int largest_coin, char *buffer, int length) {
977  int type;
978 
979  cfapiCost_string_from_value(&type, cost, largest_coin, buffer, length);
980  assert(type == CFAPI_NONE);
981 }
982 
987 void cf_spring_trap(object *trap, object *victim) {
988  int type;
989 
990  if (trap)
991  cfapiObject_activate_rune(&type, trap, victim);
992 }
993 
998 int cf_object_check_trigger(object *op, object *cause) {
999  int type, value;
1000 
1001  cfapiObject_check_trigger(&type, op, cause, &value);
1002  assert(type == CFAPI_INT);
1003  return value;
1004 }
1005 
1010 void cf_map_trigger_connected(objectlink *ol, object *cause, int state) {
1011  int type;
1012 
1013  cfapiMap_trigger_connected(&type, ol, cause, state);
1014  assert(type == CFAPI_NONE);
1015 }
1016 
1017 int cf_object_out_of_map(object *op, int x, int y) {
1018  int type, value;
1019 
1020  cfapiObject_out_of_map(&type, op->map, x, y, &value);
1021  assert(type == CFAPI_INT);
1022  return value;
1023 }
1024 
1025 void cf_object_drop(object *op, object *author) {
1026  int type;
1027 
1028  cfapiObject_drop(&type, op, author);
1029 }
1030 
1031 void cf_object_say(object *op, char *msg) {
1032  int type, value;
1033 
1034  cfapiObject_say(&type, op, msg, &value);
1035  assert(type == CFAPI_INT);
1036 }
1037 
1038 object *cf_object_insert_object(object *op, object *container) {
1039  int type;
1040  object *value;
1041 
1042  cfapiObject_insert(&type, op, 3, container, &value);
1043  assert(type == CFAPI_POBJECT);
1044  return value;
1045 }
1046 
1051 char *cf_get_maps_directory(const char *name, char *buf, int size) {
1052  int type;
1053 
1054  cfapiMap_create_path(&type, 0, name, buf, size);
1055  assert(type == CFAPI_STRING);
1056  return buf;
1057 }
1058 
1063 object *cf_create_object(void) {
1064  int type;
1065  object *value;
1066 
1067  cfapiObject_create(&type, 0, &value);
1068  assert(type == CFAPI_POBJECT);
1069  return value;
1070 }
1071 
1075 object *cf_create_object_by_name(const char *name) {
1076  int type;
1077  object *value;
1078 
1079  cfapiObject_create(&type, 1, name, &value);
1080  assert(type == CFAPI_POBJECT);
1081  return value;
1082 }
1083 
1084 void cf_system_register_global_event(int event, const char *name, f_plug_event hook) {
1085  int type;
1086 
1087  cfapiSystem_register_global_event(&type, event, name, hook);
1088  assert(type == CFAPI_NONE);
1089 }
1090 
1091 void cf_system_unregister_global_event(int event, const char *name) {
1092  int type;
1093 
1094  cfapiSystem_unregister_global_event(&type, event, name);
1095  assert(type == CFAPI_NONE);
1096 }
1097 
1112 const char *cf_get_directory(int id) {
1113  int type;
1114  const char *ret;
1115 
1116  cfapiSystem_directory(&type, id, &ret);
1117  assert(type == CFAPI_STRING);
1118  return ret;
1119 }
1120 
1125 const char *cf_re_cmp(const char *str, const char *regexp) {
1126  int type;
1127  const char *result;
1128 
1129  cfapiSystem_re_cmp(&type, str, regexp, &result);
1130  assert(type == CFAPI_STRING);
1131  return result;
1132 }
1133 
1138 void cf_fix_object(object *op) {
1139  int type;
1140 
1141  if (op)
1142  cfapiObject_fix(&type, op);
1143 }
1144 
1149 sstring cf_add_string(const char *str) {
1150  int type;
1151  sstring ret;
1152 
1153  if (!str)
1154  return NULL;
1155  cfapiSystem_add_string(&type, str, &ret);
1156  assert(type == CFAPI_SSTRING);
1157  return ret;
1158 }
1159 
1165  int type;
1166 
1167  if (str)
1168  cfapiSystem_remove_string(&type, str);
1169 }
1170 
1171 sstring cf_find_string(const char *str) {
1172  int type;
1173  sstring ret;
1174 
1175  if (!str)
1176  return NULL;
1177 
1178  cfapiSystem_find_string(&type, str, &ret);
1179  assert(type == CFAPI_SSTRING);
1180  return ret;
1181 }
1182 
1183 char *cf_query_name(object *ob, char *name, int size) {
1184  int type;
1185 
1186  cfapiObject_get_property(&type, ob, CFAPI_OBJECT_PROP_NAME, name, size);
1187  assert(type == CFAPI_STRING);
1188  return name;
1189 }
1190 
1192  int type;
1193  sstring value;
1194 
1196  assert(type == CFAPI_SSTRING);
1197  return value;
1198 }
1199 
1200 char *cf_query_base_name(object *ob, int plural, char *name, int size) {
1201  int type;
1202 
1203  cfapiObject_get_property(&type, ob, CFAPI_OBJECT_PROP_BASE_NAME, name, size);
1204  assert(type == CFAPI_STRING);
1205  return name;
1206 }
1207 
1209  int type;
1210  sstring value;
1211 
1213  assert(type == CFAPI_SSTRING);
1214  return value;
1215 }
1216 
1217 void cf_object_set_weight(object *ob, int weight) {
1218  int type;
1219 
1221  assert(type == CFAPI_INT);
1222 }
1223 
1224 void cf_object_set_weight_limit(object *ob, int weight_limit) {
1225  int type;
1226 
1227  cfapiObject_set_property(&type, ob, CFAPI_OBJECT_PROP_WEIGHT_LIMIT, weight_limit);
1228  assert(type == CFAPI_INT);
1229 }
1230 
1231 int cf_object_get_weight(object *ob) {
1232  int type, weight;
1233 
1235  assert(type == CFAPI_INT);
1236  return weight;
1237 }
1238 
1240  int type, limit;
1241 
1243  assert(type == CFAPI_INT);
1244  return limit;
1245 }
1246 
1250 int cf_object_set_nrof(object *ob, int nrof) {
1251  int type;
1252 
1253  if (nrof < 0)
1254  return -1;
1255 
1257  return 0;
1258 }
1259 
1260 int cf_object_get_nrof(object *ob) {
1261  int type, nrof;
1262 
1264  return nrof;
1265 }
1266 
1267 int cf_object_get_flag(object *ob, int flag) {
1268  int type;
1269  int rv;
1270 
1271  cfapiObject_get_property(&type, ob, CFAPI_OBJECT_PROP_FLAGS, flag, &rv);
1272  if (rv != 0)
1273  return 1;
1274  else
1275  return 0;
1276 }
1277 
1278 void cf_object_set_flag(object *ob, int flag, int value) {
1279  int type;
1280 
1281  cfapiObject_set_property(&type, ob, CFAPI_OBJECT_PROP_FLAGS, flag, value ? 1 : 0);
1282 }
1283 
1288 object *cf_object_insert_in_ob(object *op, object *where) {
1289  int type;
1290  object *value;
1291 
1292  if (!cf_object_get_flag(op, FLAG_REMOVED)) {
1293  cfapiObject_remove(&type, op);
1294  }
1295 
1296  cfapiObject_insert(&type, op, 3, where, &value);
1297  assert(type == CFAPI_POBJECT);
1298  return value;
1299 }
1300 
1305 object *cf_map_insert_object_there(object *op, mapstruct *m, object *originator, int flag) {
1306  int type;
1307  object *value;
1308 
1309  cfapiObject_insert(&type, op, 1, m, originator, flag, &value);
1310  assert(type == CFAPI_POBJECT);
1311  return value;
1312 }
1313 
1319 object *cf_map_insert_object(mapstruct *where, object *op, int x, int y) {
1320  int type;
1321  object *value;
1322 
1323  cfapiObject_insert(&type, op, 0, where, NULL, 0 , x, y, &value);
1324  assert(type == CFAPI_POBJECT);
1325  return value;
1326 }
1327 
1341 object *cf_map_insert_object_around(mapstruct *where, object *op, int x, int y) {
1342  int type;
1343  object *value;
1344 
1345  cfapiObject_insert(&type, op, 2, where, NULL, 0 , x, y, &value);
1346  assert(type == CFAPI_POBJECT);
1347  return value;
1348 }
1349 
1350 int cf_object_teleport(object *op, mapstruct *map, int x, int y) {
1351  int type, value;
1352 
1353  cfapiObject_teleport(&type, op, map, x, y, &value);
1354  assert(type == CFAPI_INT);
1355  return value;
1356 }
1357 
1361 object *cf_map_find_by_archetype_name(const char *str, mapstruct *map, int nx, int ny) {
1362  int type;
1363  object *value;
1364 
1365  cfapiMap_find_by_archetype_name(&type, str, map, nx, ny, &value);
1366  assert(type == CFAPI_POBJECT);
1367  return value;
1368 }
1369 
1372 }
1373 
1376 }
1377 
1380 }
1381 
1384 }
1385 
1388 }
1389 
1392 }
1393 
1396 }
1397 
1400 }
1401 
1404 }
1405 
1410 int cf_map_change_light(mapstruct *m, int change) {
1411  int type, value;
1412 
1413  cfapiMap_change_light(&type, m, change, &value);
1414  assert(type == CFAPI_INT);
1415  return value;
1416 }
1417 
1418 void cf_object_update(object *op, int flags) {
1419  int type;
1420 
1421  cfapiObject_update(&type, op, flags);
1422 }
1423 
1424 void cf_object_pickup(object *op, object *what) {
1425  int type;
1426 
1427  cfapiObject_pickup(&type, op, what);
1428  assert(type == CFAPI_NONE);
1429 }
1430 
1436 char *cf_strdup_local(const char *str) {
1437  int type;
1438  char *dup;
1439 
1440  if (str == NULL)
1441  return NULL;
1442  cfapiSystem_strdup_local(&type, str, &dup);
1443  assert(type == CFAPI_STRING);
1444  return dup;
1445 }
1446 
1451 int cf_map_get_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny) {
1452  int type, value;
1453 
1454  cfapiMap_get_property(&type, oldmap, CFAPI_MAP_PROP_FLAGS, newmap, x, y, nx, ny, &value);
1455  assert(type == CFAPI_INT);
1456  return value;
1457 }
1458 
1463 int cf_random_map_set_variable(RMParms *rp, const char *buf) {
1464  int type, ret;
1465 
1466  cfapiSet_random_map_variable(&type, rp, buf, &ret);
1467  assert(type == CFAPI_INT);
1468  return ret;
1469 }
1470 
1475 mapstruct *cf_random_map_generate(const char *OutFileName, RMParms *RP, char **use_layout) {
1476  int type;
1477  mapstruct *map;
1478 
1479  cfapiGenerate_random_map(&type, OutFileName, RP, use_layout, &map);
1480  assert(type == CFAPI_PMAP);
1481  return map;
1482 }
1483 
1488 int cf_find_animation(const char *name) {
1489  int type, anim;
1490 
1491  cfapiSystem_find_animation(&type, name, &anim);
1492  assert(type == CFAPI_INT);
1493  return anim;
1494 }
1495 
1500 int cf_find_face(const char *name, int error) {
1501  int type, anim;
1502 
1503  cfapiSystem_find_face(&type, name, error, &anim);
1504  assert(type == CFAPI_INT);
1505  return anim;
1506 }
1507 
1512 void cf_log(LogLevel logLevel, const char *format, ...) {
1513  int type;
1514  /* Copied from common/logger.c */
1515  char buf[20480]; /* This needs to be really really big - larger than any other buffer, since that buffer may
1516  need to be put in this one. */
1517  va_list ap;
1518 
1519  va_start(ap, format);
1520  buf[0] = '\0';
1521  vsprintf(buf, format, ap);
1522  va_end(ap);
1523 
1524  cfapiSystem_log(&type, logLevel, buf);
1525  assert(type == CFAPI_NONE);
1526 }
1527 
1532 void cf_log_plain(LogLevel logLevel, const char *message) {
1533  int type;
1534 
1535  cfapiSystem_log(&type, logLevel, message);
1536  assert(type == CFAPI_NONE);
1537 }
1538 
1540  int type;
1541 
1542  cfapiSystem_get_time(&type, tod);
1543  assert(type == CFAPI_NONE);
1544 }
1545 
1546 const char *cf_get_season_name(int index) {
1547  int type;
1548  char *result;
1549 
1550  cfapiSystem_get_season_name(&type, index, &result);
1551  assert(type == CFAPI_STRING);
1552  return result;
1553 }
1554 
1555 const char *cf_get_month_name(int index) {
1556  int type;
1557  char *result;
1558 
1559  cfapiSystem_get_month_name(&type, index, &result);
1560  assert(type == CFAPI_STRING);
1561  return result;
1562 }
1563 
1564 const char *cf_get_weekday_name(int index) {
1565  int type;
1566  char *result;
1567 
1568  cfapiSystem_get_weekday_name(&type, index, &result);
1569  assert(type == CFAPI_STRING);
1570  return result;
1571 }
1572 
1573 const char *cf_get_periodofday_name(int index) {
1574  int type;
1575  char *result;
1576 
1577  cfapiSystem_get_periodofday_name(&type, index, &result);
1578  assert(type == CFAPI_STRING);
1579  return result;
1580 }
1581 
1594 int cf_timer_create(object *ob, long delay, int mode) {
1595  int type, timer;
1596 
1597  cfapiSystem_timer_create(&type, ob, delay, mode, &timer);
1598  assert(type == CFAPI_INT);
1599  return timer;
1600 }
1601 
1610 int cf_timer_destroy(int id) {
1611  int type, code;
1612 
1613  cfapiSystem_timer_destroy(&type, id, &code);
1614  assert(type == CFAPI_INT);
1615  return code;
1616 }
1617 
1627 const char *cf_object_get_key(object *op, const char *keyname) {
1628  int type;
1629  const char *value;
1630 
1631  cfapiObject_get_key(&type, op, keyname, &value);
1632  assert(type == CFAPI_SSTRING);
1633  return value;
1634 }
1635 
1649 int cf_object_set_key(object *op, const char *keyname, const char *value, int add_key) {
1650  int type, ret;
1651 
1652  cfapiObject_set_key(&type, op, keyname, value, add_key, &ret);
1653  assert(type == CFAPI_INT);
1654  return ret;
1655 }
1656 
1661 int cf_object_change_abil(object *op, object *tmp) {
1662  int type, ret;
1663 
1664  cfapiObject_change_abil(&type, op, tmp, &ret);
1665  assert(type == CFAPI_INT);
1666  return ret;
1667 }
1668 
1669 /* Archetype-related functions */
1670 
1677  int type;
1678  archetype *value;
1679 
1680  cfapiArchetype_get_property(&type, NULL, CFAPI_ARCH_PROP_NEXT, &value);
1681  assert(type == CFAPI_PARCH);
1682  return value;
1683 }
1684 
1693  int type;
1694  sstring name;
1695 
1697  assert(type == CFAPI_SSTRING);
1698  return name;
1699 }
1700 
1710  int type;
1711  archetype *value;
1712 
1713  cfapiArchetype_get_property(&type, arch, CFAPI_ARCH_PROP_NEXT, &value);
1714  assert(type == CFAPI_PARCH);
1715  return value;
1716 }
1717 
1726  int type;
1727  archetype *value;
1728 
1729  cfapiArchetype_get_property(&type, arch, CFAPI_ARCH_PROP_MORE, &value);
1730  assert(type == CFAPI_PARCH);
1731  return value;
1732 }
1733 
1742  int type;
1743  archetype *value;
1744 
1745  cfapiArchetype_get_property(&type, arch, CFAPI_ARCH_PROP_HEAD, &value);
1746  assert(type == CFAPI_PARCH);
1747  return value;
1748 }
1749 
1758  int type;
1759  object *value;
1760 
1761  cfapiArchetype_get_property(&type, arch, CFAPI_ARCH_PROP_CLONE, &value);
1762  assert(type == CFAPI_POBJECT);
1763  return value;
1764 }
1765 
1766 /* Party-related functions */
1767 
1774  int type;
1775  partylist *value;
1776 
1777  cfapiParty_get_property(&type, NULL, CFAPI_PARTY_PROP_NEXT, &value);
1778  assert(type == CFAPI_PPARTY);
1779  return value;
1780 }
1781 
1788 const char *cf_party_get_name(partylist *party) {
1789  int type;
1790  sstring value;
1791 
1792  cfapiParty_get_property(&type, party, CFAPI_PARTY_PROP_NAME, &value);
1793  assert(type == CFAPI_SSTRING);
1794  return value;
1795 }
1796 
1805  int type;
1806  partylist *value;
1807 
1808  cfapiParty_get_property(&type, party, CFAPI_PARTY_PROP_NEXT, &value);
1809  assert(type == CFAPI_PPARTY);
1810  return value;
1811 }
1812 
1820 const char *cf_party_get_password(partylist *party) {
1821  int type;
1822  sstring value;
1823 
1824  cfapiParty_get_property(&type, party, CFAPI_PARTY_PROP_PASSWORD, &value);
1825  assert(type == CFAPI_SSTRING);
1826  return value;
1827 }
1828 
1837  int type;
1838  player *value;
1839 
1840  cfapiParty_get_property(&type, party, CFAPI_PARTY_PROP_PLAYER, NULL, &value);
1841  assert(type == CFAPI_PPLAYER);
1842  return value;
1843 }
1844 
1855  int type;
1856  player *value;
1857 
1858  cfapiParty_get_property(&type, party, CFAPI_PARTY_PROP_PLAYER, op, &value);
1859  assert(type == CFAPI_PPLAYER);
1860  return value;
1861 }
1862 
1869  int type;
1870  region *value;
1871 
1872  cfapiRegion_get_property(&type, NULL, CFAPI_REGION_PROP_NEXT, &value);
1873  assert(type == CFAPI_PREGION);
1874  return value;
1875 }
1876 
1884 const char *cf_region_get_name(region *reg) {
1885  int type;
1886  sstring value;
1887 
1888  cfapiRegion_get_property(&type, reg, CFAPI_REGION_PROP_NAME, &value);
1889  assert(type == CFAPI_SSTRING);
1890  return value;
1891 }
1892 
1901  int type;
1902  region *value;
1903 
1904  cfapiRegion_get_property(&type, reg, CFAPI_REGION_PROP_NEXT, &value);
1905  assert(type == CFAPI_PREGION);
1906  return value;
1907 }
1908 
1917  int type;
1918  region *value;
1919 
1921  assert(type == CFAPI_PREGION);
1922  return value;
1923 }
1924 
1932 const char *cf_region_get_longname(region *reg) {
1933  int type;
1934  sstring value;
1935 
1937  assert(type == CFAPI_SSTRING);
1938  return value;
1939 }
1940 
1948 const char *cf_region_get_message(region *reg) {
1949  int type;
1950  sstring value;
1951 
1953  assert(type == CFAPI_SSTRING);
1954  return value;
1955 }
1956 
1965  int type, value;
1966 
1968  assert(type == CFAPI_INT);
1969  return value;
1970 }
1971 
1980  int type, value;
1981 
1983  assert(type == CFAPI_INT);
1984  return value;
1985 }
1986 
1994 const char *cf_region_get_jail_path(region *reg) {
1995  int type;
1996  sstring value;
1997 
1999  assert(type == CFAPI_SSTRING);
2000  return value;
2001 }
2002 
2003 /* Friendlylist functions. */
2004 
2011  int type;
2012  object *value;
2013 
2014  cfapiFriendlylist_get_next(&type, NULL, &value);
2015  assert(type == CFAPI_POBJECT);
2016  return value;
2017 }
2018 
2026 object *cf_friendlylist_get_next(object *ob) {
2027  int type;
2028  object *value;
2029 
2030  cfapiFriendlylist_get_next(&type, ob, &value);
2031  assert(type == CFAPI_POBJECT);
2032  return value;
2033 }
2034 
2035 /* Quest-related functions */
2036 
2041 int cf_quest_get_player_state(object *pl, sstring quest_code) {
2042  int type, ret;
2043 
2044  cfapiPlayer_quest(&type, CFAPI_PLAYER_QUEST_GET_STATE, pl, quest_code, &ret);
2045  assert(type == CFAPI_INT);
2046 
2047  return ret;
2048 }
2049 
2054 void cf_quest_start(object *pl, sstring quest_code, int state) {
2055  int type;
2056 
2057  cfapiPlayer_quest(&type, CFAPI_PLAYER_QUEST_START, pl, quest_code, state);
2058  assert(type == CFAPI_NONE);
2059 }
2060 
2065 void cf_quest_set_player_state(object *pl, sstring quest_code, int state) {
2066  int type;
2067 
2068  cfapiPlayer_quest(&type, CFAPI_PLAYER_QUEST_SET_STATE, pl, quest_code, state);
2069  assert(type == CFAPI_NONE);
2070 }
2071 
2076 int cf_quest_was_completed(object *pl, sstring quest_code) {
2077  int type, ret;
2078 
2079  cfapiPlayer_quest(&type, CFAPI_PLAYER_QUEST_WAS_COMPLETED, pl, quest_code, &ret);
2080  assert(type == CFAPI_INT);
2081 
2082  return ret;
2083 }
object * cf_map_insert_object_around(mapstruct *where, object *op, int x, int y)
Will insert op in the map where around the spot x, y.
partylist * cf_object_get_partylist_property(object *op, int propcode)
void cf_object_update(object *op, int flags)
region * cf_region_get_parent(region *reg)
Get parent of region.
#define CFAPI_PLAYER_QUEST_GET_STATE
Definition: plugin.h:291
#define CFAPI_PARTY_PROP_PASSWORD
Definition: plugin.h:322
One player.
Definition: player.h:92
int cf_player_arrest(object *who)
Wrapper for player_arrest().
object * cf_object_find_by_arch_name(const object *who, const char *name)
Wrapper for object_find_by_arch_name().
Random map parameters.
Definition: random_map.h:14
static f_plug_api cfapiObject_find_by_arch_name
Definition: plugin_common.c:88
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:269
const char * cf_get_directory(int id)
Gets a directory Crossfire uses.
#define CFAPI_OBJECT_PROP_NAME
Definition: plugin.h:181
object * cf_player_get_marked_item(object *op)
const char * cf_object_get_key(object *op, const char *keyname)
Gets value for specified key, equivalent of object_get_value().
#define CFAPI_PREGION
Definition: plugin.h:117
#define CFAPI_PLAYER_PROP_TITLE
Definition: plugin.h:288
void cf_player_knowledge_give(object *op, const char *knowledge)
Wrapper for knowledge_give();.
void cf_map_trigger_connected(objectlink *ol, object *cause, int state)
Wrapper for trigger_connected().
#define CFAPI_MAP_PROP_ENTER_Y
Definition: plugin.h:308
static f_plug_api cfapiSystem_register_global_event
Definition: plugin_common.c:44
Used to link together several objects.
Definition: object.h:442
#define CFAPI_REGION_PROP_MESSAGE
Definition: plugin.h:329
#define CFAPI_MAP_PROP_FLAGS
Definition: plugin.h:295
#define CFAPI_MAP_PROP_DARKNESS
Definition: plugin.h:304
void cf_object_free_drop_inventory(object *ob)
Wrapper for object_free_drop_inventory().
void cf_object_set_flag(object *ob, int flag, int value)
#define CFAPI_OBJECT_PROP_WEIGHT
Definition: plugin.h:217
static f_plug_api cfapiMap_change_light
#define CFAPI_OBJECT_PROP_FACE
Definition: plugin.h:268
static f_plug_api cfapiSystem_log
Definition: plugin_common.c:50
int cf_map_get_width(mapstruct *map)
static f_plug_api cfapiObject_pay_amount
Definition: plugin_common.c:84
static f_plug_api cfapiSystem_find_face
Definition: plugin_common.c:49
const char * cf_get_weekday_name(int index)
static f_plug_api cfapiMap_get_object_at
Definition: plugin_common.c:98
static f_plug_api cfapiObject_drain
Definition: plugin_common.c:62
#define CFAPI_MAP_PROP_DIFFICULTY
Definition: plugin.h:296
#define CFAPI_MAP_PROP_HEIGHT
Definition: plugin.h:306
void cf_spring_trap(object *trap, object *victim)
Wrapper for spring_trap().
void cf_object_set_object_property(object *op, int propcode, object *value)
player * cf_party_get_first_player(partylist *party)
Get first player in party.
sstring cf_object_get_sstring_property(object *op, int propcode)
void cf_object_set_long_property(object *op, int propcode, long value)
object * cf_object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
Wrapper for object_split().
One party.
Definition: party.h:10
object * cf_object_insert_object(object *op, object *container)
static f_plug_api cfapiPlayer_find
Information on one title.
Definition: readable.c:106
void cf_object_set_int64_property(object *op, int propcode, int64_t value)
void cf_object_say(object *op, char *msg)
static f_plug_api cfapiObject_change_exp
long cf_object_get_long_property(object *op, long propcode)
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
Definition: define.h:432
static f_plug_api cfapiObject_get_key
static f_plug_api cfapiObject_say
Definition: plugin_common.c:93
object * cf_archetype_get_clone(archetype *arch)
Get clone of archetype.
#define CFAPI_REGION_PROP_JAIL_X
Definition: plugin.h:330
mapstruct * cf_get_empty_map(int sizex, int sizey)
Wrapper for get_empty_map().
#define CFAPI_ARCH_PROP_MORE
Definition: plugin.h:317
int cf_object_set_animation(object *op, const char *animation)
Set the object&#39;s animation.
#define CFAPI_INT16
Definition: plugin.h:118
int cf_player_knowledge_has(object *op, const char *knowledge)
Wrapper for knowledge_player_has().
int64_t cf_object_get_int64_property(object *op, int propcode)
object * cf_create_object_by_name(const char *name)
Wrapper for create_archetype() and create_archetype_by_object_name().
static f_plug_api cfapiObject_distance
Definition: plugin_common.c:73
int cf_region_get_jail_x(region *reg)
Get region&#39;s jail x coordinate.
static f_plug_api cfapiObject_remove
Definition: plugin_common.c:66
void cf_object_change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Wrapper for change_exp().
static f_plug_api cfapiObject_fix
Definition: plugin_common.c:63
#define CFAPI_OBJECT_PROP_FLAGS
Definition: plugin.h:247
static f_plug_api cfapiObject_check_trigger
Definition: plugin_common.c:78
int cf_map_get_enter_x(mapstruct *map)
#define CFAPI_SINT64
Definition: plugin.h:120
const char * cf_region_get_message(region *reg)
Get message of region.
#define CFAPI_OBJECT_PROP_NAME_PLURAL
Definition: plugin.h:182
mapstruct * cf_map_has_been_loaded(const char *name)
Wrapper for has_been_loaded().
partylist * cf_player_get_party(object *op)
static f_plug_api cfapiObject_set_key
int cf_object_check_trigger(object *op, object *cause)
Wrapper for check_trigger().
mapstruct * cf_map_get_first(void)
Gives access to first_map.
int cf_object_set_face(object *op, const char *face)
Set the object&#39;s face.
region * cf_region_get_first(void)
Get first region in region list.
#define CFAPI_OBJECT_PROP_MESSAGE
Definition: plugin.h:187
void cf_player_set_marked_item(object *op, object *ob)
void cf_object_set_weight_limit(object *ob, int weight_limit)
#define CFAPI_MAP_PROP_RESET_TIMEOUT
Definition: plugin.h:301
static f_plug_api cfapiObject_move
#define CFAPI_PLAYER_QUEST_START
Definition: plugin.h:290
#define CFAPI_DOUBLE
Definition: plugin.h:112
object * cf_map_get_object_at(mapstruct *m, int x, int y)
Wrapper for GET_MAP_OB().
#define CFAPI_REGION_PROP_NEXT
Definition: plugin.h:326
void cf_player_set_party(object *op, partylist *party)
static f_plug_api cfapiSystem_get_time
Definition: plugin_common.c:51
object * cf_object_get_object_property(object *op, int propcode)
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:310
mapstruct * cf_map_get_map_property(mapstruct *map, int propcode)
void cf_fix_object(object *op)
Wrapper for fix_object().
static f_plug_api cfapiObject_remove_depletion
static f_plug_api cfapiObject_describe
Definition: plugin_common.c:61
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
#define CFAPI_PMAP
Definition: plugin.h:110
void cf_object_set_resistance(object *op, int rtype, int16_t value)
void cf_object_set_string_property(object *op, int propcode, const char *value)
int cf_object_apply(object *op, object *tmp, int aflag)
Wrapper for apply_manual().
int16_t cf_object_get_resistance(object *op, int rtype)
#define CFAPI_POBJECT
Definition: plugin.h:109
static f_plug_api cfapiObject_find_archetype_inside
Definition: plugin_common.c:87
#define CFAPI_REGION_PROP_JAIL_PATH
Definition: plugin.h:332
#define FLAG_REMOVED
Object is not in any map or invenory.
Definition: define.h:232
const char * cf_party_get_password(partylist *party)
Get party&#39;s password.
const char * cf_get_periodofday_name(int index)
static f_plug_api cfapiSystem_find_animation
Definition: plugin_common.c:48
struct titlestruct title
Information on one title.
static f_plug_api cfapiObject_pay_item
Definition: plugin_common.c:85
int cf_object_get_int_property(object *op, int propcode)
static f_plug_api cfapiObject_merge
Definition: plugin_common.c:72
static f_plug_api cfapiRegion_get_property
#define CFAPI_NONE
Definition: plugin.h:104
static f_plug_api cfapiSystem_get_weekday_name
int cf_map_get_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Wrapper for get_map_flags().
int cf_map_get_players(mapstruct *map)
void cf_map_set_string_property(mapstruct *map, int propcode, const char *value)
#define CFAPI_FLOAT
Definition: plugin.h:111
static f_plug_api cfapiSystem_timer_create
Definition: plugin_common.c:52
#define CFAPI_PARCH
Definition: plugin.h:113
static f_plug_api cfapiMap_set_property
Definition: plugin_common.c:95
void cf_object_apply_below(object *pl)
Wrapper for apply_by_living_below().
archetype * cf_archetype_get_more(archetype *arch)
Get next part of archetype.
int cf_random_map_set_variable(RMParms *rp, const char *buf)
Wrapper for set_random_map_variable().
#define CFAPI_MAP_PROP_PLAYERS
Definition: plugin.h:302
static f_plug_api cfapiObject_query_money
Definition: plugin_common.c:79
static f_plug_api cfapiSystem_remove_string
Definition: plugin_common.c:45
void cf_object_pickup(object *op, object *what)
static f_plug_api cfapiObject_out_of_map
Definition: plugin_common.c:90
static f_plug_api cfapiObject_give_skill
Definition: plugin_common.c:64
partylist * cf_party_get_next(partylist *party)
Get next party in party list.
void cf_log(LogLevel logLevel, const char *format,...)
Wrapper for LOG().
static f_plug_api cfapiObject_set_property
Definition: plugin_common.c:58
#define CFAPI_PLAYER_PROP_IP
Definition: plugin.h:281
region * cf_region_get_next(region *reg)
Get next region in region list.
void cf_object_set_weight(object *ob, int weight)
int cf_map_change_light(mapstruct *m, int change)
Wrapper for change_map_light().
int cf_map_get_reset_timeout(mapstruct *map)
#define CFAPI_PARTY_PROP_PLAYER
Definition: plugin.h:323
static f_plug_api cfapiObject_apply_below
int cf_find_animation(const char *name)
Wrapper for find_animation().
char * cf_object_get_string_property(object *op, int propcode, char *buf, int size)
#define CFAPI_STRING
Definition: plugin.h:108
sstring cf_add_string(const char *str)
Wrapper for add_string().
signed short int16_t
Definition: win32.h:160
#define CFAPI_MAP_PROP_RESET_TIME
Definition: plugin.h:300
#define CFAPI_ARCH_PROP_HEAD
Definition: plugin.h:316
int cf_object_pay_item(object *op, object *pl)
Wrapper for pay_for_item().
static f_plug_api cfapiObject_clear
Definition: plugin_common.c:75
object * cf_object_check_for_spell(object *op, const char *name)
Wrapper for check_spell_known().
static f_plug_api cfapiObject_split
Definition: plugin_common.c:71
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
This is a game region.
Definition: map.h:276
const char * cf_region_get_jail_path(region *reg)
Get jail path of region.
sstring cf_query_name_pl(object *ob)
static f_plug_api cfapiObject_reset
Definition: plugin_common.c:76
#define CFAPI_ARCH_PROP_NEXT
Definition: plugin.h:315
static f_plug_api cfapiObject_get_property
Definition: plugin_common.c:57
int cf_timer_destroy(int id)
Destroys specified timer, equivalent of calling cftimer_destroy().
object * cf_object_clone(object *op, int clonetype)
Clone an object.
static f_plug_api cfapiObject_user_event
const char * cf_get_season_name(int index)
void cf_cost_string_from_value(uint64_t cost, int largest_coin, char *buffer, int length)
Wrapper for cost_string_from_value modified to take a char* and length instead of a StringBuffer...
void cf_system_unregister_global_event(int event, const char *name)
int cf_timer_create(object *ob, long delay, int mode)
Creates a timer, equivalent of calling cftimer_create().
double cf_object_get_double_property(object *op, int propcode)
static f_plug_api cfapiArchetype_get_property
int cf_object_get_weight_limit(object *ob)
static f_plug_api cfapiMap_message
Definition: plugin_common.c:97
int cf_object_get_weight(object *ob)
int cf_object_query_money(const object *op)
Wrapper for query_money().
int cf_object_teleport(object *op, mapstruct *map, int x, int y)
static f_plug_api cfapiObject_delete
Definition: plugin_common.c:67
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:218
object * cf_identify(object *op)
Wrapper for identify().
#define CFAPI_PLAYER_QUEST_SET_STATE
Definition: plugin.h:292
#define CFAPI_LONG
Definition: plugin.h:106
object * cf_object_find_by_name(const object *who, const char *name)
Wrapper for object_find_by_name().
char * cf_get_maps_directory(const char *name, char *buf, int size)
Wrapper for create_pathname().
#define CFAPI_SSTRING
Definition: plugin.h:121
char * cf_query_name(object *ob, char *name, int size)
int cf_object_set_nrof(object *ob, int nrof)
int cf_object_transfer(object *op, int x, int y, int randomly, object *originator)
Wrapper for transfer_ob().
#define CFAPI_PPLAYER
Definition: plugin.h:115
int cf_region_get_jail_y(region *reg)
Get region&#39;s jail y coordinate.
object * cf_object_insert_in_ob(object *op, object *where)
Wrapper for object_insert_in_ob().
void * value
Definition: hashtable.h:12
object * cf_map_insert_object(mapstruct *where, object *op, int x, int y)
Wrapper for object_insert_in_map_at().
#define CFAPI_REGION_PROP_JAIL_Y
Definition: plugin.h:331
static f_plug_api cfapiSystem_timer_destroy
Definition: plugin_common.c:53
char * cf_player_get_title(object *op, char *title, int size)
int cf_map_get_reset_time(mapstruct *map)
int cf_object_set_key(object *op, const char *keyname, const char *value, int add_key)
Sets a value for specified key, equivalent to object_set_value().
static f_plug_api cfapiSystem_unregister_global_event
Definition: plugin_common.c:46
int cf_find_face(const char *name, int error)
Wrapper for find_face().
static f_plug_api cfapiObject_drop
Definition: plugin_common.c:91
unsigned __int64 uint64_t
Definition: win32.h:167
static f_plug_api cfapiMap_get_property
Definition: plugin_common.c:94
void cf_player_set_title(object *op, const char *title)
#define CFAPI_REGION_PROP_LONGNAME
Definition: plugin.h:328
static f_plug_api cfapiSystem_get_periodofday_name
const char * cf_region_get_longname(region *reg)
Get longname of region.
int cf_init_plugin(f_plug_api getHooks)
static f_plug_api cfapiPlayer_can_pay
static f_plug_api cfapiSystem_re_cmp
Definition: plugin_common.c:55
#define CFAPI_PARTY_PROP_NAME
Definition: plugin.h:320
static f_plug_api cfapiObject_transmute
Definition: plugin_common.c:65
#define CFAPI_PLAYER_PROP_PARTY
Definition: plugin.h:283
LogLevel
Log levels for the LOG() function.
Definition: logger.h:10
int cf_player_move(player *pl, int dir)
archetype * cf_archetype_get_next(archetype *arch)
Get next archetype in linked list.
int cf_object_remove_depletion(object *op, int level)
Wrapper for remove_depletion().
void cf_object_set_int_property(object *op, int propcode, int value)
player * cf_party_get_next_player(partylist *party, player *op)
Get next player in party.
int(* f_plug_event)(int *type,...)
Function to call to handle global or object-related events.
Definition: plugin.h:131
signed __int64 int64_t
Definition: win32.h:168
static const flag_definition flags[]
Flag mapping.
sstring cf_map_get_sstring_property(mapstruct *map, int propcode)
static f_plug_api cfapiObject_find_by_name
Definition: plugin_common.c:89
static f_plug_api cfapiObject_apply
Definition: plugin_common.c:59
int cf_object_get_flag(object *ob, int flag)
static f_plug_api cfapiObject_cast
Definition: plugin_common.c:80
const char * sstring
Strings that should be manipulated through add_string() and free_string().
Definition: global.h:40
void cf_object_set_movetype_property(object *op, int propcode, MoveType value)
static f_plug_api cfapiObject_insert
Definition: plugin_common.c:70
static f_plug_api cfapiParty_get_property
unsigned int uint32_t
Definition: win32.h:162
archetype * cf_archetype_get_head(archetype *arch)
Get head of archetype.
static f_plug_api cfapiObject_activate_rune
Definition: plugin_common.c:77
#define CFAPI_OBJECT_PROP_BASE_NAME
Definition: plugin.h:238
#define CFAPI_REGION_PROP_PARENT
Definition: plugin.h:327
mapstruct * cf_random_map_generate(const char *OutFileName, RMParms *RP, char **use_layout)
Wrapper for generate_random_map().
#define CFAPI_INT
Definition: plugin.h:105
static f_plug_api cfapiObject_pickup
int cf_quest_get_player_state(object *pl, sstring quest_code)
Wrapper for quest_get_player_state().
static f_plug_api cfapiMap_get_map
Definition: plugin_common.c:96
static f_plug_api cfapiMap_has_been_loaded
#define CFAPI_ARCH_PROP_NAME
Definition: plugin.h:314
static f_plug_api cfapiMap_trigger_connected
int cf_map_get_int_property(mapstruct *map, int property)
int cf_quest_was_completed(object *pl, sstring quest_code)
Wrapper for quest_was_completed().
object * cf_map_find_by_archetype_name(const char *str, mapstruct *map, int nx, int ny)
Kinda wrapper for map_find_by_archetype_name().
void cf_object_forget_spell(object *op, object *sp)
Wrapper for do_forget_spell(), except takes an object, not a string.
void cf_map_set_int_property(mapstruct *map, int propcode, int value)
const char * cf_region_get_name(region *reg)
Get name of region.
static f_plug_api cfapiObject_transfer
Definition: plugin_common.c:86
float cf_object_get_float_property(object *op, int propcode)
void cf_quest_start(object *pl, sstring quest_code, int state)
Wrapper for quest_start().
static f_plug_api cfapiObject_check_spell
Definition: plugin_common.c:83
sstring cf_archetype_get_name(archetype *arch)
Get archetype&#39;s name.
int cf_object_get_nrof(object *ob)
static f_plug_api cfapiObject_teleport
Represents the ingame time.
Definition: tod.h:32
int cf_map_get_darkness(mapstruct *map)
region * cf_map_get_region_property(mapstruct *map, int propcode)
MoveType cf_object_get_movetype_property(object *op, int propcode)
void cf_object_remove(object *op)
Wrapper for object_remove().
int cf_object_out_of_map(object *op, int x, int y)
const char * cf_party_get_name(partylist *party)
int cf_object_change_abil(object *op, object *tmp)
Wrapper for change_abil().
#define CFAPI_MOVETYPE
Definition: plugin.h:122
sstring cf_player_get_ip(object *op)
static f_plug_api cfapiCost_string_from_value
static f_plug_api cfapiObject_update
Definition: plugin_common.c:74
#define CFAPI_MAP_PROP_WIDTH
Definition: plugin.h:305
const char * cf_re_cmp(const char *str, const char *regexp)
Wrapper for re_cmp().
int cf_object_move_to(object *op, int x, int y)
Wrapper for move_to().
static f_plug_api cfapiObject_learn_spell
Definition: plugin_common.c:81
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED
Definition: plugin.h:293
#define CFAPI_PARTY_PROP_NEXT
Definition: plugin.h:321
int cf_object_cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Wrapper for cast_spell().
void cf_object_drop(object *op, object *author)
object * cf_friendlylist_get_next(object *ob)
Get next object on friendly list.
object * cf_object_present_archname_inside(object *op, char *whatstr)
Kinda wrapper for arch_present_in_ob().
void cf_get_time(timeofday_t *tod)
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:193
int cf_object_pay_amount(object *pl, uint64_t to_pay)
Wrapper for pay_for_amount().
sstring cf_object_get_msg(object *ob)
static f_plug_api cfapiObject_create
Definition: plugin_common.c:69
int cf_map_get_enter_y(mapstruct *map)
#define CFAPI_ARCH_PROP_CLONE
Definition: plugin.h:318
#define GET_HOOK(x, y, z)
#define CFAPI_PLAYER_PROP_MARKED_ITEM
Definition: plugin.h:282
static f_plug_api cfapiFriendlylist_get_next
void cf_object_set_float_property(object *op, int propcode, float value)
int cf_object_user_event(object *op, object *activator, object *third, const char *message, int fix)
player * cf_player_find(const char *plname)
Wrapper for find_player_partial_name().
mapstruct * cf_object_get_map_property(object *op, int propcode)
int cf_object_move(object *op, int dir, object *originator)
mapstruct * cf_map_get_map(const char *name, int flags)
Wrapper for ready_map_name().
static f_plug_api cfapiSet_random_map_variable
static f_plug_api cfapiSystem_get_season_name
object * cf_map_insert_object_there(object *op, mapstruct *m, object *originator, int flag)
Wrapper for object_insert_in_map().
static f_plug_api cfapiSystem_directory
Definition: plugin_common.c:54
#define CFAPI_OBJECT_PROP_RESIST
Definition: plugin.h:199
char * cf_query_base_name(object *ob, int plural, char *name, int size)
void cf_map_message(mapstruct *m, const char *msg, int color)
Partial wrapper for ext_info_map().
sstring cf_find_string(const char *str)
static f_plug_api cfapiPlayer_quest
static f_plug_api cfapiMap_find_by_archetype_name
Definition: plugin_common.c:99
This is a game-map.
Definition: map.h:325
static f_plug_api cfapiPlayer_message
object * cf_object_change_map(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Wrapper for object_insert_in_map_at().
archetype * cf_archetype_get_first(void)
Get first archetype.
void cf_player_message(object *op, char *txt, int flags)
static f_plug_api cfapiPlayer_knowledge
object * cf_create_object(void)
Wrapper for object_new().
void cf_object_learn_spell(object *op, object *spell, int special_prayer)
Wrapper for do_learn_spell().
void cf_system_register_global_event(int event, const char *name, f_plug_event hook)
archetype * cf_object_get_archetype_property(object *op, int propcode)
static f_plug_api cfapiObject_identify
Definition: plugin_common.c:60
static f_plug_api cfapiSystem_strdup_local
Definition: plugin_common.c:47
static f_plug_api cfapiObject_clone
Definition: plugin_common.c:68
static f_plug_api cfapiGenerate_random_map
void cf_log_plain(LogLevel logLevel, const char *message)
Wrapper for LOG() that uses directly a buffer, without format.
static f_plug_api cfapiSystem_get_month_name
partylist * cf_party_get_first(void)
Get first party.
void cf_free_string(sstring str)
Wrapper for free_string().
static f_plug_api cfapiMap_create_path
#define CFAPI_MAP_PROP_ENTER_X
Definition: plugin.h:307
const char * cf_get_month_name(int index)
int cf_object_cast_ability(object *caster, object *ctoo, int dir, object *sp, char *flags)
Should there be a difference nowadays between that and cast_spell ?
char * cf_strdup_local(const char *str)
Wrapper for strdup_local().
object * cf_friendlylist_get_first(void)
Get first object on friendly list.
void cf_quest_set_player_state(object *pl, sstring quest_code, int state)
Wrapper for quest_set_player_state();.
int cf_player_can_pay(object *pl)
Wrapper for can_pay().
static f_plug_api cfapiObject_forget_spell
Definition: plugin_common.c:82
void(* f_plug_api)(int *type,...)
General API function.
Definition: plugin.h:125
static f_plug_api cfapiSystem_add_string
Definition: plugin_common.c:42
static f_plug_api cfapiSystem_find_string
Definition: plugin_common.c:43
#define CFAPI_REGION_PROP_NAME
Definition: plugin.h:325
static f_plug_api cfapiObject_change_abil
Definition: plugin_common.c:92
int cf_map_get_height(mapstruct *map)
#define CFAPI_PPARTY
Definition: plugin.h:116
int cf_map_get_difficulty(mapstruct *map)