ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/server/plugins/common/plugin_common.c
Revision: 1.6
Committed: Sun Aug 13 17:16:03 2006 UTC (20 years, 1 month ago) by elmex
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +0 -0 lines
State: FILE REMOVED
Log Message:
Made server compile with C++.
Removed cfanim plugin and crossedit.
C++ here we come.

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