ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/plugin_common.C
Revision: 1.2
Committed: Mon May 28 21:28:36 2007 UTC (17 years ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.1: +25 -27 lines
Log Message:
update copyrights in server/*.C

File Contents

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