ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/server/plugins/common/plugin_common.C
Revision: 1.6
Committed: Thu Dec 14 22:54:35 2006 UTC (19 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.5: +2 -4 lines
Log Message:
Oh my god I hate this pile of garbage called "plug in api"

File Contents

# User Rev Content
1 elmex 1.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     #include <plugin_common.h>
37    
38     static f_plug_api cfapiSystem_register_global_event = NULL;
39     static f_plug_api cfapiSystem_unregister_global_event = NULL;
40     static f_plug_api cfapiSystem_find_animation = NULL;
41    
42     static f_plug_api cfapiMap_create_path = NULL;
43    
44     static f_plug_api cfapiObject_get_property = NULL;
45     static f_plug_api cfapiObject_set_property = NULL;
46     static f_plug_api cfapiObject_apply = NULL;
47     static f_plug_api cfapiObject_identify = NULL;
48     static f_plug_api cfapiObject_describe = NULL;
49     static f_plug_api cfapiObject_drain = NULL;
50     static f_plug_api cfapiObject_fix = NULL;
51     static f_plug_api cfapiObject_give_skill = NULL;
52     static f_plug_api cfapiObject_transmute = NULL;
53     static f_plug_api cfapiObject_remove = NULL;
54     static f_plug_api cfapiObject_delete = NULL;
55     static f_plug_api cfapiObject_clone = NULL;
56     static f_plug_api cfapiObject_find = NULL;
57     static f_plug_api cfapiObject_create = NULL;
58     static f_plug_api cfapiObject_insert = NULL;
59     static f_plug_api cfapiObject_split = NULL;
60     static f_plug_api cfapiObject_merge = NULL;
61     static f_plug_api cfapiObject_distance = NULL;
62     static f_plug_api cfapiObject_update = NULL;
63     static f_plug_api cfapiObject_clear = NULL;
64     static f_plug_api cfapiObject_reset = NULL;
65 pippijn 1.4 /* static f_plug_api cfapiCheck_inventory = NULL; */
66 elmex 1.1 static f_plug_api cfapiObject_activate_rune = NULL;
67     static f_plug_api cfapiObject_check_trigger = NULL;
68     static f_plug_api cfapiObject_query_money = NULL;
69     static f_plug_api cfapiObject_query_cost = NULL;
70     static f_plug_api cfapiObject_cast = NULL;
71     static f_plug_api cfapiObject_learn_spell = NULL;
72     static f_plug_api cfapiObject_forget_spell = NULL;
73     static f_plug_api cfapiObject_check_spell = NULL;
74     static f_plug_api cfapiObject_pay_amount = NULL;
75     static f_plug_api cfapiObject_pay_item = NULL;
76     static f_plug_api cfapiObject_transfer = NULL;
77     static f_plug_api cfapiObject_find_archetype_inside = NULL;
78     static f_plug_api cfapiObject_out_of_map = NULL;
79     static f_plug_api cfapiObject_drop = NULL;
80     static f_plug_api cfapiObject_take = NULL;
81     static f_plug_api cfapiObject_say = NULL;
82     static f_plug_api cfapiObject_speak = NULL;
83     static f_plug_api cfapiMap_get_property = NULL;
84     static f_plug_api cfapiMap_set_property = NULL;
85     static f_plug_api cfapiMap_get_map = NULL;
86     static f_plug_api cfapiMap_message = NULL;
87     static f_plug_api cfapiMap_get_object_at = NULL;
88     static f_plug_api cfapiMap_present_arch_by_name = NULL;
89     static f_plug_api cfapiMap_get_flags = NULL;
90     static f_plug_api cfapiPlayer_find = NULL;
91     static f_plug_api cfapiPlayer_message = NULL;
92     static f_plug_api cfapiPlayer_send_inventory = NULL;
93     static f_plug_api cfapiObject_teleport = NULL;
94     static f_plug_api cfapiObject_pickup = NULL;
95     static f_plug_api cfapiObject_get_key = NULL;
96     static f_plug_api cfapiObject_set_key = NULL;
97     static f_plug_api cfapiObject_move = NULL;
98     static f_plug_api cfapiObject_apply_below = NULL;
99     static f_plug_api cfapiArchetype_get_first = NULL;
100     static f_plug_api cfapiArchetype_get_property = NULL;
101     static f_plug_api cfapiParty_get_property = NULL;
102     static f_plug_api cfapiRegion_get_property = NULL;
103    
104     #define GET_HOOK( x, y, z ) \
105     { \
106     x = ( f_plug_api )getHooks( &z, 1, y ); \
107     if ( z != CFAPI_FUNC ) {\
108     printf( "unable to find hook %s!\n", y ); return 0; \
109     } }
110    
111     int cf_init_plugin( f_plug_api getHooks )
112     {
113     int z;
114     GET_HOOK( cfapiSystem_register_global_event, "cfapi_system_register_global_event", z );
115     GET_HOOK( cfapiSystem_unregister_global_event, "cfapi_system_unregister_global_event", z );
116     GET_HOOK( cfapiSystem_find_animation, "cfapi_system_find_animation", z );
117     GET_HOOK( cfapiObject_get_property, "cfapi_object_get_property", z );
118     GET_HOOK( cfapiObject_set_property, "cfapi_object_set_property", z );
119     GET_HOOK( cfapiObject_apply, "cfapi_object_apply", z );
120     GET_HOOK( cfapiObject_identify, "cfapi_object_identify", z );
121     GET_HOOK( cfapiObject_describe, "cfapi_object_describe", z );
122     GET_HOOK( cfapiObject_drain, "cfapi_object_drain", z );
123     GET_HOOK( cfapiObject_fix, "cfapi_object_fix", z );
124     GET_HOOK( cfapiObject_give_skill, "cfapi_object_give_skill", z );
125     GET_HOOK( cfapiObject_transmute, "cfapi_object_transmute", z );
126     GET_HOOK( cfapiObject_remove, "cfapi_object_remove", z );
127     GET_HOOK( cfapiObject_delete, "cfapi_object_delete", z );
128     GET_HOOK( cfapiObject_clone, "cfapi_object_clone", z );
129     GET_HOOK( cfapiObject_find, "cfapi_object_find", z );
130     GET_HOOK( cfapiObject_create, "cfapi_object_create", z );
131     GET_HOOK( cfapiObject_insert, "cfapi_object_insert", z );
132     GET_HOOK( cfapiObject_split, "cfapi_object_split", z );
133     GET_HOOK( cfapiObject_merge, "cfapi_object_merge", z );
134     GET_HOOK( cfapiObject_distance, "cfapi_object_distance", z );
135     GET_HOOK( cfapiObject_update, "cfapi_object_update", z );
136     GET_HOOK( cfapiObject_clear, "cfapi_object_clear", z );
137     GET_HOOK( cfapiObject_reset, "cfapi_object_reset", z );
138     GET_HOOK( cfapiObject_activate_rune, "cfapi_object_spring_trap", z );
139     GET_HOOK( cfapiObject_check_trigger, "cfapi_object_check_trigger", z );
140     GET_HOOK( cfapiObject_query_money,"cfapi_object_query_money", z );
141     GET_HOOK( cfapiObject_query_cost,"cfapi_object_query_cost", z );
142     GET_HOOK( cfapiObject_cast,"cfapi_object_cast", z );
143     GET_HOOK( cfapiObject_learn_spell,"cfapi_object_learn_spell", z );
144     GET_HOOK( cfapiObject_forget_spell,"cfapi_object_forget_spell", z );
145     GET_HOOK( cfapiObject_check_spell,"cfapi_object_check_spell", z );
146     GET_HOOK( cfapiObject_pay_amount,"cfapi_object_pay_amount", z );
147     GET_HOOK( cfapiObject_pay_item,"cfapi_object_pay_item", z );
148     GET_HOOK( cfapiObject_transfer, "cfapi_object_transfer", z );
149     GET_HOOK( cfapiObject_find_archetype_inside, "cfapi_object_find_archetype_inside", z );
150     GET_HOOK( cfapiObject_remove, "cfapi_object_remove", z );
151     GET_HOOK( cfapiObject_delete, "cfapi_object_delete", z );
152     GET_HOOK( cfapiObject_out_of_map, "cfapi_map_out_of_map", z );
153     GET_HOOK( cfapiObject_drop, "cfapi_object_drop", z );
154     GET_HOOK( cfapiObject_take, "cfapi_object_take", z );
155     GET_HOOK( cfapiObject_say, "cfapi_object_say", z );
156     GET_HOOK( cfapiObject_speak, "cfapi_object_speak", z );
157     /*GET_HOOK( cfapiCheck_inventory, "cfapi_check_inventory", z );*/
158     GET_HOOK( cfapiMap_create_path, "cfapi_map_create_path", z );
159     GET_HOOK( cfapiMap_get_property,"cfapi_map_get_property", z );
160     GET_HOOK( cfapiMap_set_property,"cfapi_map_set_property", z );
161     GET_HOOK( cfapiMap_get_map, "cfapi_map_get_map", z );
162     GET_HOOK( cfapiMap_message, "cfapi_map_message", z );
163     GET_HOOK( cfapiMap_get_object_at, "cfapi_map_get_object_at", z );
164     GET_HOOK( cfapiMap_present_arch_by_name, "cfapi_map_present_arch_by_name", z );
165     GET_HOOK( cfapiMap_get_flags, "cfapi_map_get_flags", z );
166     GET_HOOK( cfapiPlayer_find, "cfapi_player_find", z );
167     GET_HOOK( cfapiPlayer_message, "cfapi_player_message", z );
168     GET_HOOK( cfapiPlayer_send_inventory, "cfapi_player_send_inventory", z );
169     GET_HOOK( cfapiObject_teleport, "cfapi_object_teleport", z );
170     GET_HOOK( cfapiObject_pickup, "cfapi_object_pickup", z );
171     GET_HOOK( cfapiObject_get_key, "cfapi_object_get_key", z );
172     GET_HOOK( cfapiObject_set_key, "cfapi_object_set_key", z );
173     GET_HOOK( cfapiObject_move, "cfapi_object_move", z );
174     GET_HOOK( cfapiObject_apply_below, "cfapi_object_apply_below", z );
175     GET_HOOK( cfapiArchetype_get_first, "cfapi_archetype_get_first", z );
176     GET_HOOK( cfapiArchetype_get_property, "cfapi_archetype_get_property", z );
177     GET_HOOK( cfapiParty_get_property, "cfapi_party_get_property", z );
178     GET_HOOK( cfapiRegion_get_property, "cfapi_region_get_property", z );
179     return 1;
180     }
181    
182     /* Should get replaced by tons of more explicit wrappers */
183 root 1.3 void* cf_map_get_property(maptile* map, int propcode)
184 elmex 1.1 {
185     int val;
186     return cfapiMap_get_property(&val, propcode, map);
187     }
188     /* Should get replaced by tons of more explicit wrappers */
189 root 1.3 void* cf_map_set_int_property(maptile* map, int propcode, int value)
190 elmex 1.1 {
191     int val;
192     return cfapiMap_set_property(&val, map, propcode,value);
193     }
194     /* Should get replaced by tons of more explicit wrappers */
195     void* cf_object_get_property(object* op, int propcode)
196     {
197     int val;
198     return cfapiObject_get_property(&val, op, propcode);
199     }
200     sint16 cf_object_get_resistance(object* op, int rtype)
201     {
202     int val;
203     return *(int*)cfapiObject_get_property(&val, op, CFAPI_OBJECT_PROP_RESIST, rtype);
204     }
205     /* Should get replaced by tons of more explicit wrappers */
206     void* cf_object_set_int_property(object* op, int propcode, int value)
207     {
208     int val;
209     return cfapiObject_set_property(&val, op, propcode,value);
210     }
211     /* Should get replaced by tons of more explicit wrappers */
212     void* cf_object_set_long_property(object* op, int propcode, long value)
213     {
214     int val;
215     return cfapiObject_set_property(&val, op, propcode,value);
216     }
217     /* Should get replaced by tons of more explicit wrappers */
218     void* cf_object_set_string_property(object* op, int propcode, char* value)
219     {
220     int val;
221     return cfapiObject_set_property(&val, op, propcode,value);
222     }
223     void cf_player_move(player* pl, int dir)
224     {
225     int val;
226     cfapiObject_move(&val,1,pl,dir);
227     }
228     void cf_object_move(object* op, int dir, object*originator)
229     {
230     int val;
231     cfapiObject_move(&val,0,op,dir,originator);
232     }
233     object* cf_player_send_inventory(object* op)
234     {
235     int val;
236     return (object*) cfapiPlayer_send_inventory(&val, op);
237     }
238     void cf_object_apply(object* op, object* author, int flags)
239     {
240     int val;
241     cfapiObject_apply(&val,op,author,flags);
242     }
243     void cf_object_apply_below(object* op)
244     {
245     int val;
246     cfapiObject_apply_below(&val,op);
247     }
248     void cf_object_remove(object* op)
249     {
250     int val;
251     cfapiObject_remove(&val, op);
252     }
253     void cf_object_free(object* op)
254     {
255     int val;
256     cfapiObject_delete(&val, op);
257     }
258     object* cf_object_present_archname_inside(object* op, char* whatstr)
259     {
260     int val;
261     return (object*) cfapiObject_find_archetype_inside(&val, op, 0, whatstr);
262     }
263     int cf_object_transfer(object* op,int x,int y,int r,object* orig)
264     {
265     int val;
266     /* return *(int*)cfapiObject_transfer(&val,op,1,x,y,op->map);*/
267     return *(int*)cfapiObject_transfer(&val,op,0,x,y,r,orig);
268     }
269 root 1.3 int cf_object_change_map(object* op, int x, int y, maptile* map)
270 elmex 1.1 {
271     int val;
272     return *(int*)cfapiObject_transfer(&val,op,1,x,y,map);
273     /*cfapiObject_transfer(&val,op,1,x,y,map);
274     return 0;*/
275     }
276 root 1.3 object* cf_map_get_object_at(maptile* m, int x, int y)
277 elmex 1.1 {
278     int val;
279     return (object*) cfapiMap_get_object_at(&val, m, x, y);
280     }
281 root 1.3 void cf_map_message(maptile* m, char* msg, int color)
282 elmex 1.1 {
283     int val;
284     cfapiMap_message(&val, m, msg, color);
285     }
286     object* cf_object_clone(object* op, int clonetype)
287     {
288     int val;
289     return (object*)cfapiObject_clone(&val, op, clonetype);
290     }
291     int cf_object_pay_item(object* op, object* buyer)
292     {
293     int val;
294     return *(int*)cfapiObject_pay_item(&val, op, buyer);
295     }
296     int cf_object_pay_amount(object* op, uint64 amount)
297     {
298     int val;
299     return *(int*)cfapiObject_pay_amount(&val, op, amount);
300     }
301     int cf_object_cast_spell(object* caster, object* ctoo, int dir, object* sp, char* flags)
302     {
303     int val;
304     return *(int*)cfapiObject_cast(&val, caster, ctoo, dir, sp, flags);
305     }
306     /* Should there be a difference nowadays between that and cast_spell ? */
307     int cf_object_cast_ability(object* caster, object* ctoo, int dir, object* sp, char* flags)
308     {
309     int val;
310     return *(int*)cfapiObject_cast(&val, caster, ctoo, dir, sp, flags);
311     }
312     void cf_object_learn_spell(object* op, object* sp)
313     {
314     int val;
315     cfapiObject_learn_spell(&val, op, sp, 0);
316     }
317     void cf_object_forget_spell(object* op, object* sp)
318     {
319     int val;
320     cfapiObject_forget_spell(&val, op, sp);
321     }
322     object* cf_object_check_for_spell(object* op, char* spellname)
323     {
324     int val;
325     return (object*) cfapiObject_check_spell(&val, op, spellname);
326     }
327     void cf_player_message(object* op, char* txt, int flags)
328     {
329     int val;
330     cfapiPlayer_message(&val, flags, 0, op, txt);
331     }
332    
333     player* cf_player_find(char* txt)
334     {
335     int val;
336     return (player*) cfapiPlayer_find(&val, txt);
337     }
338     char* cf_player_get_ip(object* op)
339     {
340     int val;
341     return (char*) cfapiObject_get_property(&val, op, CFAPI_PLAYER_PROP_IP);
342     }
343     object* cf_player_get_marked_item(object* op)
344     {
345     int val;
346     return (object*) cfapiObject_get_property(&val, op, CFAPI_PLAYER_PROP_MARKED_ITEM);
347     }
348     void cf_player_set_marked_item(object* op, object* ob)
349     {
350     int val;
351     cfapiObject_set_property(&val, op, CFAPI_PLAYER_PROP_MARKED_ITEM, ob);
352     }
353     partylist* cf_player_get_party(object* op)
354     {
355     int val;
356     return (partylist*) cfapiObject_get_property(&val, op, CFAPI_PLAYER_PROP_PARTY);
357     }
358     void cf_player_set_party(object* op, partylist* party)
359     {
360     int val;
361     cfapiObject_set_property(&val, op, CFAPI_PLAYER_PROP_PARTY, party);
362     }
363    
364 root 1.3 maptile* cf_map_get_map( char* name )
365 elmex 1.1 {
366     int val;
367 root 1.3 return (maptile*) cfapiMap_get_map( &val, 1, name, 0);
368 elmex 1.1 }
369 root 1.3 maptile* cf_map_get_first(void)
370 elmex 1.1 {
371     int val;
372 root 1.3 return (maptile*) cfapiMap_get_map( &val, 3);
373 elmex 1.1 }
374     int cf_object_query_money( object* op)
375     {
376     int val;
377     return *(int*)cfapiObject_query_money( &val, op);
378     }
379     int cf_object_query_cost( object* op, object* who, int flags)
380     {
381     int val;
382     return *(int*)cfapiObject_query_cost(&val,op,who,flags);
383     }
384     void cf_object_activate_rune( object* op , object* victim)
385     {
386     int val;
387     if ( op )
388     cfapiObject_activate_rune( &val, op, victim );
389     }
390     int cf_object_check_trigger( object* op, object* cause )
391     {
392     int val;
393     return *(int*)cfapiObject_check_trigger( &val, op, cause );
394     }
395     int cf_object_out_of_map( object* op, int x, int y)
396     {
397     int val;
398     return *(int*)cfapiObject_out_of_map(&val,op->map,x,y);
399     }
400     void cf_object_drop( object* op, object* author)
401     {
402     int val;
403     cfapiObject_drop( &val, op, author );
404     }
405     void cf_object_take( object* op, object* author)
406     {
407     int val;
408     cfapiObject_take( &val, op, author );
409     }
410     void cf_object_say( object* op, char* msg)
411     {
412     int val;
413     cfapiObject_say( &val, op, msg );
414     }
415     void cf_object_speak( object* op, char* msg)
416     {
417     int val;
418     cfapiObject_speak( &val, op, msg );
419     }
420     object* cf_object_insert_object(object* op, object* container)
421     {
422     int val;
423     return (object*) cfapiObject_insert(&val, op, 3, container);
424     }
425     char* cf_get_maps_directory(char* str)
426     {
427     int val;
428    
429     /*printf("Calling with %s, type 0\n",str);
430     printf("Value of the pointer: %p\n", cfapiMap_create_path);*/
431     return (char*) cfapiMap_create_path(&val, 0, str);
432     }
433     object* cf_create_object()
434     {
435     int val;
436     return (object*) cfapiObject_create(&val, 0);
437     }
438     object* cf_create_object_by_name( const char* name )
439     {
440     int val;
441     return (object*) cfapiObject_create(&val, 1, name);
442     }
443     void cf_free_object( object* ob )
444     {
445     int val;
446     if ( ob )
447     cfapiObject_delete( &val, ob );
448     }
449    
450     void cf_system_register_global_event( int event, const char* name, f_plug_api hook )
451     {
452     int val;
453     cfapiSystem_register_global_event( &val, event, name, hook );
454     }
455    
456     void cf_fix_object( object* pl )
457     {
458     int val;
459     if ( pl )
460     cfapiObject_fix( &val, pl );
461     }
462    
463     char* cf_query_name( object* ob )
464     {
465     int val;
466     return (char*) cfapiObject_get_property( &val, ob, CFAPI_OBJECT_PROP_NAME );
467     }
468    
469     char* cf_query_name_pl( object* ob )
470     {
471     int val;
472     return (char*) cfapiObject_get_property( &val, ob, CFAPI_OBJECT_PROP_NAME_PLURAL );
473     }
474    
475     char* cf_query_base_name( object* ob, int plural )
476     {
477     int val;
478     return (char*) cfapiObject_get_property( &val, ob, CFAPI_OBJECT_PROP_BASE_NAME, plural );
479     }
480    
481     object* cf_insert_ob_in_ob( object* ob, object* where )
482     {
483     int val;
484     return (object*) cfapiObject_insert( &val, ob, 3, where );
485     }
486    
487     const char* cf_object_get_msg( object* ob )
488     {
489     int val;
490     return (const char*) cfapiObject_get_property( &val, ob, CFAPI_OBJECT_PROP_MESSAGE );
491     }
492    
493     void cf_object_set_weight( object* ob, int weight )
494     {
495     int val;
496     cfapiObject_set_property( &val, ob, CFAPI_OBJECT_PROP_WEIGHT, weight );
497     }
498    
499     void cf_object_set_weight_limit( object* ob, int weight_limit )
500     {
501     int val;
502     cfapiObject_set_property( &val, ob, CFAPI_OBJECT_PROP_WEIGHT_LIMIT, weight_limit );
503     }
504    
505     int cf_object_get_weight( object* ob )
506     {
507     int val;
508     return *( int* )cfapiObject_get_property( &val, ob, CFAPI_OBJECT_PROP_WEIGHT );
509     }
510    
511     int cf_object_get_weight_limit( object* ob )
512     {
513     int val;
514     int *dummy;
515     dummy = (int*) cfapiObject_get_property( &val, ob, CFAPI_OBJECT_PROP_WEIGHT_LIMIT );
516     return *dummy;
517     }
518    
519     /**
520     * @return -1=nrof is invalid, 0=nrof is ok#
521     */
522     int cf_object_set_nrof( object* ob, int nrof )
523     {
524     int val;
525    
526     if (nrof < 0)
527     return -1;
528    
529     cfapiObject_set_property( &val, ob, CFAPI_OBJECT_PROP_NROF, nrof );
530     return 0;
531     }
532    
533     int cf_object_get_nrof( object* ob )
534     {
535     int val;
536     return *( int* )cfapiObject_get_property( &val, ob, CFAPI_OBJECT_PROP_NROF );
537     }
538    
539     int cf_object_get_flag( object* ob, int flag )
540     {
541     int type;
542     int rv;
543     rv = *(int*)cfapiObject_get_property( &type, ob, CFAPI_OBJECT_PROP_FLAGS, flag );
544     if (rv != 0)
545     return 1;
546     else
547     return 0;
548     }
549    
550     void cf_object_set_flag( object* ob, int flag, int value )
551     {
552     int type;
553     cfapiObject_set_property( &type, ob, CFAPI_OBJECT_PROP_FLAGS, flag, value ? 1 : 0 );
554     }
555    
556     object* cf_object_insert_in_ob( object* ob, object* where )
557     {
558     int type;
559    
560     if (!cf_object_get_flag(ob,FLAG_REMOVED))
561     {
562     cfapiObject_remove( &type, ob );
563     }
564    
565     return (object*) cfapiObject_insert( &type, ob, 3, where );
566     }
567    
568 root 1.3 object* cf_map_insert_object_there(maptile* where, object* op, object* originator, int flags)
569 elmex 1.1 {
570     int val;
571     return (object*)cfapiObject_insert(&val, op, 1, where, originator, flags);
572     }
573 root 1.3 object* cf_map_insert_object(maptile* where , object* op, int x, int y)
574 elmex 1.1 {
575     int type;
576     return (object*) cfapiObject_insert( &type, op, 0, where, NULL, 0 , x, y);
577     }
578 root 1.3 int cf_object_teleport( object* op, maptile* map, int x, int y )
579 elmex 1.1 {
580     int val;
581     return *( int* )cfapiObject_teleport( &val, op, map, x, y );
582     }
583 root 1.3 object* cf_map_present_arch_by_name(const char* str, maptile* map, int nx, int ny)
584 elmex 1.1 {
585     int val;
586     return (object*)cfapiMap_present_arch_by_name(&val, str,map,nx,ny);
587     }
588    
589 root 1.3 static int cf_get_map_int_property(maptile* map, int property)
590 elmex 1.1 {
591     int type;
592     void* rv;
593     rv = cfapiMap_get_property(&type, property, map);
594     if ( !rv || type != CFAPI_INT )
595     return PLUGIN_ERROR_INT;
596     return *(int*)rv;
597     }
598    
599 root 1.3 int cf_map_get_difficulty(maptile* map)
600 elmex 1.1 {
601     return cf_get_map_int_property(map,CFAPI_MAP_PROP_DIFFICULTY);
602     }
603    
604 root 1.3 int cf_map_get_reset_time(maptile* map)
605 elmex 1.1 {
606     return cf_get_map_int_property(map,CFAPI_MAP_PROP_RESET_TIME);
607     }
608    
609 root 1.3 int cf_map_get_reset_timeout(maptile* map)
610 elmex 1.1 {
611     return cf_get_map_int_property(map,CFAPI_MAP_PROP_RESET_TIMEOUT);
612     }
613    
614 root 1.3 int cf_map_get_players(maptile* map)
615 elmex 1.1 {
616     return cf_get_map_int_property(map,CFAPI_MAP_PROP_PLAYERS);
617     }
618    
619 root 1.3 int cf_map_get_darkness(maptile* map)
620 elmex 1.1 {
621     return cf_get_map_int_property(map,CFAPI_MAP_PROP_DARKNESS);
622     }
623    
624 root 1.3 int cf_map_get_width(maptile* map)
625 elmex 1.1 {
626     return cf_get_map_int_property(map,CFAPI_MAP_PROP_WIDTH);
627     }
628    
629 root 1.3 int cf_map_get_height(maptile* map)
630 elmex 1.1 {
631     return cf_get_map_int_property(map,CFAPI_MAP_PROP_HEIGHT);
632     }
633    
634 root 1.3 int cf_map_get_enter_x(maptile* map)
635 elmex 1.1 {
636     return cf_get_map_int_property(map,CFAPI_MAP_PROP_ENTER_X);
637     }
638    
639 root 1.3 int cf_map_get_enter_y(maptile* map)
640 elmex 1.1 {
641     return cf_get_map_int_property(map,CFAPI_MAP_PROP_ENTER_Y);
642     }
643    
644 root 1.3 int cf_map_get_temperature(maptile* map)
645 elmex 1.1 {
646     return cf_get_map_int_property(map,CFAPI_MAP_PROP_TEMPERATURE);
647     }
648    
649 root 1.3 int cf_map_get_pressure(maptile* map)
650 elmex 1.1 {
651     return cf_get_map_int_property(map,CFAPI_MAP_PROP_PRESSURE);
652     }
653    
654 root 1.3 int cf_map_get_humidity(maptile* map)
655 elmex 1.1 {
656     return cf_get_map_int_property(map,CFAPI_MAP_PROP_HUMIDITY);
657     }
658    
659 root 1.3 int cf_map_get_windspeed(maptile* map)
660 elmex 1.1 {
661     return cf_get_map_int_property(map,CFAPI_MAP_PROP_WINDSPEED);
662     }
663    
664 root 1.3 int cf_map_get_winddir(maptile* map)
665 elmex 1.1 {
666     return cf_get_map_int_property(map,CFAPI_MAP_PROP_WINDDIR);
667     }
668    
669 root 1.3 int cf_map_get_sky(maptile* map)
670 elmex 1.1 {
671     return cf_get_map_int_property(map,CFAPI_MAP_PROP_SKY);
672     }
673    
674 root 1.3 int cf_map_get_wpartx(maptile* map)
675 elmex 1.1 {
676     return cf_get_map_int_property(map,CFAPI_MAP_PROP_WPARTX);
677     }
678    
679 root 1.3 int cf_map_get_wparty(maptile* map)
680 elmex 1.1 {
681     return cf_get_map_int_property(map,CFAPI_MAP_PROP_WPARTY);
682     }
683    
684     void cf_object_update( object* op, int flags)
685     {
686     int val;
687     cfapiObject_update(&val, op, flags);
688     }
689     void cf_object_pickup( object* op, object* what)
690     {
691     int val;
692     cfapiObject_pickup(&val, op, what);
693     }
694 root 1.6 char* cf_strdup(char* txt)
695 elmex 1.1 {
696     int val;
697 root 1.6 return (char*)strdup(txt);
698 elmex 1.1 }
699 root 1.3 int cf_map_get_flags( maptile* map, maptile** nmap, sint16 x, sint16 y, sint16* nx, sint16* ny )
700 elmex 1.1 {
701     int val;
702     return *( int* )cfapiMap_get_flags(&val, map, nmap, x, y, nx, ny);
703     }
704     int cf_find_animation(char* txt)
705     {
706     int val;
707     return *(int*)cfapiSystem_find_animation(&val, txt);
708     }
709     char* cf_object_get_key(object* op, char* keyname)
710     {
711     int val;
712     return (char*)cfapiObject_get_key(&val, op, keyname);
713     }
714     void cf_object_set_key(object* op, char* keyname, char* value)
715     {
716     int val;
717     cfapiObject_set_key(&val, op, keyname, value);
718     }
719    
720     /* Archetype-related functions */
721     archetype* cf_archetype_get_first()
722     {
723     int val;
724     return (archetype*) cfapiArchetype_get_first(&val);
725     }
726    
727     const char* cf_archetype_get_name(archetype* arch)
728     {
729     int val;
730     return (const char*) cfapiArchetype_get_property(&val, arch, CFAPI_ARCH_PROP_NAME);
731     }
732    
733     archetype* cf_archetype_get_next(archetype* arch)
734     {
735     int val;
736     return (archetype*) cfapiArchetype_get_property(&val, arch, CFAPI_ARCH_PROP_NEXT);
737     }
738    
739     archetype* cf_archetype_get_more(archetype* arch)
740     {
741     int val;
742     return (archetype*) cfapiArchetype_get_property(&val, arch, CFAPI_ARCH_PROP_MORE);
743     }
744    
745     archetype* cf_archetype_get_head(archetype* arch)
746     {
747     int val;
748     return (archetype*) cfapiArchetype_get_property(&val, arch, CFAPI_ARCH_PROP_HEAD);
749     }
750    
751     object* cf_archetype_get_clone(archetype* arch)
752     {
753     int val;
754     return (object*) cfapiArchetype_get_property(&val, arch, CFAPI_ARCH_PROP_CLONE);
755     }
756    
757     /* Party-related functions */
758     partylist* cf_party_get_first(void)
759     {
760     int val;
761     return (partylist*) cfapiParty_get_property(&val, NULL, CFAPI_PARTY_PROP_NEXT);
762     }
763    
764     const char* cf_party_get_name(partylist* party)
765     {
766     int val;
767     return (const char*) cfapiParty_get_property(&val, party, CFAPI_PARTY_PROP_NAME);
768     }
769    
770     partylist* cf_party_get_next(partylist* party)
771     {
772     int val;
773     return (partylist*) cfapiParty_get_property(&val, party, CFAPI_PARTY_PROP_NEXT);
774     }
775    
776     const char* cf_party_get_password(partylist* party)
777     {
778     int val;
779     return (const char*) cfapiParty_get_property(&val, party, CFAPI_PARTY_PROP_PASSWORD);
780     }
781    
782     player* cf_party_get_first_player(partylist* party)
783     {
784     int val;
785     return (player*) cfapiParty_get_property(&val, party, CFAPI_PARTY_PROP_PLAYER, NULL);
786     }
787    
788     player* cf_party_get_next_player(partylist* party, player* op)
789     {
790     int val;
791     return (player*) cfapiParty_get_property(&val, party, CFAPI_PARTY_PROP_PLAYER, op);
792     }
793    
794     region* cf_region_get_first(void)
795     {
796     int val;
797     return (region*) cfapiRegion_get_property(&val, NULL, CFAPI_REGION_PROP_NEXT);
798     }
799    
800     const char* cf_region_get_name(region* reg)
801     {
802     int val;
803     return (const char*) cfapiRegion_get_property(&val, reg, CFAPI_REGION_PROP_NAME);
804     }
805    
806     region* cf_region_get_next(region* reg)
807     {
808     int val;
809     return (region*) cfapiRegion_get_property(&val, reg, CFAPI_REGION_PROP_NEXT);
810     }
811    
812     region* cf_region_get_parent(region* reg)
813     {
814     int val;
815     return (region*) cfapiRegion_get_property(&val, reg, CFAPI_REGION_PROP_PARENT);
816     }
817    
818     const char* cf_region_get_longname(region* reg)
819     {
820     int val;
821     return (const char*) cfapiRegion_get_property(&val, reg, CFAPI_REGION_PROP_LONGNAME);
822     }
823    
824     const char* cf_region_get_message(region* reg)
825     {
826     int val;
827     return (const char*) cfapiRegion_get_property(&val, reg, CFAPI_REGION_PROP_MESSAGE);
828     }