ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/plugin_common.C
Revision: 1.4
Committed: Sun Sep 30 16:24:32 2007 UTC (16 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
State: FILE REMOVED
Log Message:
finally remove the old buggy plug-in cruft

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