ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/plugins/common/plugin_common.c
Revision: 1.2
Committed: Wed Feb 8 04:32:19 2006 UTC (18 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.1: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

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