ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/plugins/common/plugin_common.C
Revision: 1.2
Committed: Sun Sep 3 08:05:39 2006 UTC (17 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.1: +0 -19 lines
Log Message:
for some unexplicable reasons, it seems to run after fixing the obvious errors

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