ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/plugins/common/plugin_common.C
Revision: 1.9
Committed: Mon Mar 5 20:04:16 2007 UTC (17 years, 2 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +0 -0 lines
State: FILE REMOVED
Log Message:
move to server proper

File Contents

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