… | |
… | |
35 | /*****************************************************************************/ |
35 | /*****************************************************************************/ |
36 | #include <plugin_common.h> |
36 | #include <plugin_common.h> |
37 | |
37 | |
38 | static f_plug_api cfapiSystem_register_global_event = NULL; |
38 | static f_plug_api cfapiSystem_register_global_event = NULL; |
39 | static f_plug_api cfapiSystem_unregister_global_event = NULL; |
39 | static f_plug_api cfapiSystem_unregister_global_event = NULL; |
40 | static f_plug_api cfapiSystem_strdup_local = NULL; |
|
|
41 | static f_plug_api cfapiSystem_find_animation = NULL; |
40 | static f_plug_api cfapiSystem_find_animation = NULL; |
42 | |
41 | |
43 | static f_plug_api cfapiMap_create_path = NULL; |
42 | static f_plug_api cfapiMap_create_path = NULL; |
44 | |
43 | |
45 | static f_plug_api cfapiObject_get_property = NULL; |
44 | static f_plug_api cfapiObject_get_property = NULL; |
… | |
… | |
61 | static f_plug_api cfapiObject_merge = NULL; |
60 | static f_plug_api cfapiObject_merge = NULL; |
62 | static f_plug_api cfapiObject_distance = NULL; |
61 | static f_plug_api cfapiObject_distance = NULL; |
63 | static f_plug_api cfapiObject_update = NULL; |
62 | static f_plug_api cfapiObject_update = NULL; |
64 | static f_plug_api cfapiObject_clear = NULL; |
63 | static f_plug_api cfapiObject_clear = NULL; |
65 | static f_plug_api cfapiObject_reset = NULL; |
64 | static f_plug_api cfapiObject_reset = NULL; |
66 | static f_plug_api cfapiCheck_inventory = NULL; |
65 | /* static f_plug_api cfapiCheck_inventory = NULL; */ |
67 | static f_plug_api cfapiObject_activate_rune = NULL; |
66 | static f_plug_api cfapiObject_activate_rune = NULL; |
68 | static f_plug_api cfapiObject_check_trigger = NULL; |
67 | static f_plug_api cfapiObject_check_trigger = NULL; |
69 | static f_plug_api cfapiObject_query_money = NULL; |
68 | static f_plug_api cfapiObject_query_money = NULL; |
70 | static f_plug_api cfapiObject_query_cost = NULL; |
69 | static f_plug_api cfapiObject_query_cost = NULL; |
71 | static f_plug_api cfapiObject_cast = NULL; |
70 | static f_plug_api cfapiObject_cast = NULL; |
… | |
… | |
110 | } } |
109 | } } |
111 | |
110 | |
112 | int cf_init_plugin( f_plug_api getHooks ) |
111 | int cf_init_plugin( f_plug_api getHooks ) |
113 | { |
112 | { |
114 | int z; |
113 | int z; |
115 | GET_HOOK( cfapiSystem_strdup_local, "cfapi_system_strdup_local", z ); |
|
|
116 | GET_HOOK( cfapiSystem_register_global_event, "cfapi_system_register_global_event", z ); |
114 | GET_HOOK( cfapiSystem_register_global_event, "cfapi_system_register_global_event", z ); |
117 | GET_HOOK( cfapiSystem_unregister_global_event, "cfapi_system_unregister_global_event", z ); |
115 | GET_HOOK( cfapiSystem_unregister_global_event, "cfapi_system_unregister_global_event", z ); |
118 | GET_HOOK( cfapiSystem_find_animation, "cfapi_system_find_animation", z ); |
116 | GET_HOOK( cfapiSystem_find_animation, "cfapi_system_find_animation", z ); |
119 | GET_HOOK( cfapiObject_get_property, "cfapi_object_get_property", z ); |
117 | GET_HOOK( cfapiObject_get_property, "cfapi_object_get_property", z ); |
120 | GET_HOOK( cfapiObject_set_property, "cfapi_object_set_property", z ); |
118 | GET_HOOK( cfapiObject_set_property, "cfapi_object_set_property", z ); |
… | |
… | |
180 | GET_HOOK( cfapiRegion_get_property, "cfapi_region_get_property", z ); |
178 | GET_HOOK( cfapiRegion_get_property, "cfapi_region_get_property", z ); |
181 | return 1; |
179 | return 1; |
182 | } |
180 | } |
183 | |
181 | |
184 | /* Should get replaced by tons of more explicit wrappers */ |
182 | /* Should get replaced by tons of more explicit wrappers */ |
185 | void* cf_map_get_property(mapstruct* map, int propcode) |
183 | void* cf_map_get_property(maptile* map, int propcode) |
186 | { |
184 | { |
187 | int val; |
185 | int val; |
188 | return cfapiMap_get_property(&val, propcode, map); |
186 | return cfapiMap_get_property(&val, propcode, map); |
189 | } |
187 | } |
190 | /* Should get replaced by tons of more explicit wrappers */ |
188 | /* Should get replaced by tons of more explicit wrappers */ |
191 | void* cf_map_set_int_property(mapstruct* map, int propcode, int value) |
189 | void* cf_map_set_int_property(maptile* map, int propcode, int value) |
192 | { |
190 | { |
193 | int val; |
191 | int val; |
194 | return cfapiMap_set_property(&val, map, propcode,value); |
192 | return cfapiMap_set_property(&val, map, propcode,value); |
195 | } |
193 | } |
196 | /* Should get replaced by tons of more explicit wrappers */ |
194 | /* Should get replaced by tons of more explicit wrappers */ |
… | |
… | |
266 | { |
264 | { |
267 | int val; |
265 | int val; |
268 | /* return *(int*)cfapiObject_transfer(&val,op,1,x,y,op->map);*/ |
266 | /* return *(int*)cfapiObject_transfer(&val,op,1,x,y,op->map);*/ |
269 | return *(int*)cfapiObject_transfer(&val,op,0,x,y,r,orig); |
267 | return *(int*)cfapiObject_transfer(&val,op,0,x,y,r,orig); |
270 | } |
268 | } |
271 | int cf_object_change_map(object* op, int x, int y, mapstruct* map) |
269 | int cf_object_change_map(object* op, int x, int y, maptile* map) |
272 | { |
270 | { |
273 | int val; |
271 | int val; |
274 | return *(int*)cfapiObject_transfer(&val,op,1,x,y,map); |
272 | return *(int*)cfapiObject_transfer(&val,op,1,x,y,map); |
275 | /*cfapiObject_transfer(&val,op,1,x,y,map); |
273 | /*cfapiObject_transfer(&val,op,1,x,y,map); |
276 | return 0;*/ |
274 | return 0;*/ |
277 | } |
275 | } |
278 | object* cf_map_get_object_at(mapstruct* m, int x, int y) |
276 | object* cf_map_get_object_at(maptile* m, int x, int y) |
279 | { |
277 | { |
280 | int val; |
278 | int val; |
281 | return (object*) cfapiMap_get_object_at(&val, m, x, y); |
279 | return (object*) cfapiMap_get_object_at(&val, m, x, y); |
282 | } |
280 | } |
283 | void cf_map_message(mapstruct* m, char* msg, int color) |
281 | void cf_map_message(maptile* m, char* msg, int color) |
284 | { |
282 | { |
285 | int val; |
283 | int val; |
286 | cfapiMap_message(&val, m, msg, color); |
284 | cfapiMap_message(&val, m, msg, color); |
287 | } |
285 | } |
288 | object* cf_object_clone(object* op, int clonetype) |
286 | object* cf_object_clone(object* op, int clonetype) |
… | |
… | |
361 | { |
359 | { |
362 | int val; |
360 | int val; |
363 | cfapiObject_set_property(&val, op, CFAPI_PLAYER_PROP_PARTY, party); |
361 | cfapiObject_set_property(&val, op, CFAPI_PLAYER_PROP_PARTY, party); |
364 | } |
362 | } |
365 | |
363 | |
366 | mapstruct* cf_map_get_map( char* name ) |
364 | maptile* cf_map_get_map( char* name ) |
367 | { |
365 | { |
368 | int val; |
366 | int val; |
369 | return (mapstruct*) cfapiMap_get_map( &val, 1, name, 0); |
367 | return (maptile*) cfapiMap_get_map( &val, 1, name, 0); |
370 | } |
368 | } |
371 | mapstruct* cf_map_get_first(void) |
369 | maptile* cf_map_get_first(void) |
372 | { |
370 | { |
373 | int val; |
371 | int val; |
374 | return (mapstruct*) cfapiMap_get_map( &val, 3); |
372 | return (maptile*) cfapiMap_get_map( &val, 3); |
375 | } |
373 | } |
376 | int cf_object_query_money( object* op) |
374 | int cf_object_query_money( object* op) |
377 | { |
375 | { |
378 | int val; |
376 | int val; |
379 | return *(int*)cfapiObject_query_money( &val, op); |
377 | return *(int*)cfapiObject_query_money( &val, op); |
… | |
… | |
394 | int val; |
392 | int val; |
395 | return *(int*)cfapiObject_check_trigger( &val, op, cause ); |
393 | return *(int*)cfapiObject_check_trigger( &val, op, cause ); |
396 | } |
394 | } |
397 | int cf_object_out_of_map( object* op, int x, int y) |
395 | int cf_object_out_of_map( object* op, int x, int y) |
398 | { |
396 | { |
399 | int val; |
397 | abort (); |
400 | return *(int*)cfapiObject_out_of_map(&val,op->map,x,y); |
|
|
401 | } |
398 | } |
402 | void cf_object_drop( object* op, object* author) |
399 | void cf_object_drop( object* op, object* author) |
403 | { |
400 | { |
404 | int val; |
401 | int val; |
405 | cfapiObject_drop( &val, op, author ); |
402 | cfapiObject_drop( &val, op, author ); |
… | |
… | |
565 | } |
562 | } |
566 | |
563 | |
567 | return (object*) cfapiObject_insert( &type, ob, 3, where ); |
564 | return (object*) cfapiObject_insert( &type, ob, 3, where ); |
568 | } |
565 | } |
569 | |
566 | |
570 | object* cf_map_insert_object_there(mapstruct* where, object* op, object* originator, int flags) |
567 | object* cf_map_insert_object_there(maptile* where, object* op, object* originator, int flags) |
571 | { |
568 | { |
572 | int val; |
569 | int val; |
573 | return (object*)cfapiObject_insert(&val, op, 1, where, originator, flags); |
570 | return (object*)cfapiObject_insert(&val, op, 1, where, originator, flags); |
574 | } |
571 | } |
575 | object* cf_map_insert_object(mapstruct* where , object* op, int x, int y) |
572 | object* cf_map_insert_object(maptile* where , object* op, int x, int y) |
576 | { |
573 | { |
577 | int type; |
574 | int type; |
578 | return (object*) cfapiObject_insert( &type, op, 0, where, NULL, 0 , x, y); |
575 | return (object*) cfapiObject_insert( &type, op, 0, where, NULL, 0 , x, y); |
579 | } |
576 | } |
580 | int cf_object_teleport( object* op, mapstruct* map, int x, int y ) |
577 | int cf_object_teleport( object* op, maptile* map, int x, int y ) |
581 | { |
578 | { |
582 | int val; |
579 | int val; |
583 | return *( int* )cfapiObject_teleport( &val, op, map, x, y ); |
580 | return *( int* )cfapiObject_teleport( &val, op, map, x, y ); |
584 | } |
581 | } |
585 | object* cf_map_present_arch_by_name(const char* str, mapstruct* map, int nx, int ny) |
582 | object* cf_map_present_arch_by_name(const char* str, maptile* map, int nx, int ny) |
586 | { |
583 | { |
587 | int val; |
584 | int val; |
588 | return (object*)cfapiMap_present_arch_by_name(&val, str,map,nx,ny); |
585 | return (object*)cfapiMap_present_arch_by_name(&val, str,map,nx,ny); |
589 | } |
586 | } |
590 | |
587 | |
591 | static int cf_get_map_int_property(mapstruct* map, int property) |
588 | static int cf_get_map_int_property(maptile* map, int property) |
592 | { |
589 | { |
593 | int type; |
590 | int type; |
594 | void* rv; |
591 | void* rv; |
595 | rv = cfapiMap_get_property(&type, property, map); |
592 | rv = cfapiMap_get_property(&type, property, map); |
596 | if ( !rv || type != CFAPI_INT ) |
593 | if ( !rv || type != CFAPI_INT ) |
597 | return PLUGIN_ERROR_INT; |
594 | return PLUGIN_ERROR_INT; |
598 | return *(int*)rv; |
595 | return *(int*)rv; |
599 | } |
596 | } |
600 | |
597 | |
601 | int cf_map_get_difficulty(mapstruct* map) |
598 | int cf_map_get_difficulty(maptile* map) |
602 | { |
599 | { |
603 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_DIFFICULTY); |
600 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_DIFFICULTY); |
604 | } |
601 | } |
605 | |
602 | |
606 | int cf_map_get_reset_time(mapstruct* map) |
603 | int cf_map_get_reset_time(maptile* map) |
607 | { |
604 | { |
608 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_RESET_TIME); |
605 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_RESET_TIME); |
609 | } |
606 | } |
610 | |
607 | |
611 | int cf_map_get_reset_timeout(mapstruct* map) |
608 | int cf_map_get_reset_timeout(maptile* map) |
612 | { |
609 | { |
613 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_RESET_TIMEOUT); |
610 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_RESET_TIMEOUT); |
614 | } |
611 | } |
615 | |
612 | |
616 | int cf_map_get_players(mapstruct* map) |
613 | int cf_map_get_players(maptile* map) |
617 | { |
614 | { |
618 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_PLAYERS); |
615 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_PLAYERS); |
619 | } |
616 | } |
620 | |
617 | |
621 | int cf_map_get_darkness(mapstruct* map) |
618 | int cf_map_get_darkness(maptile* map) |
622 | { |
619 | { |
623 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_DARKNESS); |
620 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_DARKNESS); |
624 | } |
621 | } |
625 | |
622 | |
626 | int cf_map_get_width(mapstruct* map) |
623 | int cf_map_get_width(maptile* map) |
627 | { |
624 | { |
628 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WIDTH); |
625 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WIDTH); |
629 | } |
626 | } |
630 | |
627 | |
631 | int cf_map_get_height(mapstruct* map) |
628 | int cf_map_get_height(maptile* map) |
632 | { |
629 | { |
633 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_HEIGHT); |
630 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_HEIGHT); |
634 | } |
631 | } |
635 | |
632 | |
636 | int cf_map_get_enter_x(mapstruct* map) |
633 | int cf_map_get_enter_x(maptile* map) |
637 | { |
634 | { |
638 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_ENTER_X); |
635 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_ENTER_X); |
639 | } |
636 | } |
640 | |
637 | |
641 | int cf_map_get_enter_y(mapstruct* map) |
638 | int cf_map_get_enter_y(maptile* map) |
642 | { |
639 | { |
643 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_ENTER_Y); |
640 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_ENTER_Y); |
644 | } |
641 | } |
645 | |
642 | |
646 | int cf_map_get_temperature(mapstruct* map) |
643 | int cf_map_get_temperature(maptile* map) |
647 | { |
644 | { |
648 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_TEMPERATURE); |
645 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_TEMPERATURE); |
649 | } |
646 | } |
650 | |
647 | |
651 | int cf_map_get_pressure(mapstruct* map) |
648 | int cf_map_get_pressure(maptile* map) |
652 | { |
649 | { |
653 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_PRESSURE); |
650 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_PRESSURE); |
654 | } |
651 | } |
655 | |
652 | |
656 | int cf_map_get_humidity(mapstruct* map) |
653 | int cf_map_get_humidity(maptile* map) |
657 | { |
654 | { |
658 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_HUMIDITY); |
655 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_HUMIDITY); |
659 | } |
656 | } |
660 | |
657 | |
661 | int cf_map_get_windspeed(mapstruct* map) |
658 | int cf_map_get_windspeed(maptile* map) |
662 | { |
659 | { |
663 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WINDSPEED); |
660 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WINDSPEED); |
664 | } |
661 | } |
665 | |
662 | |
666 | int cf_map_get_winddir(mapstruct* map) |
663 | int cf_map_get_winddir(maptile* map) |
667 | { |
664 | { |
668 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WINDDIR); |
665 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WINDDIR); |
669 | } |
666 | } |
670 | |
667 | |
671 | int cf_map_get_sky(mapstruct* map) |
668 | int cf_map_get_sky(maptile* map) |
672 | { |
669 | { |
673 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_SKY); |
670 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_SKY); |
674 | } |
671 | } |
675 | |
672 | |
676 | int cf_map_get_wpartx(mapstruct* map) |
673 | int cf_map_get_wpartx(maptile* map) |
677 | { |
674 | { |
678 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WPARTX); |
675 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WPARTX); |
679 | } |
676 | } |
680 | |
677 | |
681 | int cf_map_get_wparty(mapstruct* map) |
678 | int cf_map_get_wparty(maptile* map) |
682 | { |
679 | { |
683 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WPARTY); |
680 | return cf_get_map_int_property(map,CFAPI_MAP_PROP_WPARTY); |
684 | } |
681 | } |
685 | |
682 | |
686 | void cf_object_update( object* op, int flags) |
683 | void cf_object_update( object* op, int flags) |
… | |
… | |
691 | void cf_object_pickup( object* op, object* what) |
688 | void cf_object_pickup( object* op, object* what) |
692 | { |
689 | { |
693 | int val; |
690 | int val; |
694 | cfapiObject_pickup(&val, op, what); |
691 | cfapiObject_pickup(&val, op, what); |
695 | } |
692 | } |
696 | char* cf_strdup_local(char* txt) |
693 | char* cf_strdup(char* txt) |
697 | { |
694 | { |
698 | int val; |
695 | return (char*)strdup(txt); |
699 | return (char*)cfapiSystem_strdup_local(&val, txt); |
|
|
700 | } |
696 | } |
701 | int cf_map_get_flags( mapstruct* map, mapstruct** nmap, sint16 x, sint16 y, sint16* nx, sint16* ny ) |
697 | int cf_map_get_flags( maptile* map, maptile** nmap, sint16 x, sint16 y, sint16* nx, sint16* ny ) |
702 | { |
698 | { |
703 | int val; |
699 | int val; |
704 | return *( int* )cfapiMap_get_flags(&val, map, nmap, x, y, nx, ny); |
700 | return *( int* )cfapiMap_get_flags(&val, map, nmap, x, y, nx, ny); |
705 | } |
701 | } |
706 | int cf_find_animation(char* txt) |
702 | int cf_find_animation(char* txt) |
… | |
… | |
826 | const char* cf_region_get_message(region* reg) |
822 | const char* cf_region_get_message(region* reg) |
827 | { |
823 | { |
828 | int val; |
824 | int val; |
829 | return (const char*) cfapiRegion_get_property(&val, reg, CFAPI_REGION_PROP_MESSAGE); |
825 | return (const char*) cfapiRegion_get_property(&val, reg, CFAPI_REGION_PROP_MESSAGE); |
830 | } |
826 | } |
831 | |
|
|
832 | #ifdef WIN32 |
|
|
833 | int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info) |
|
|
834 | { |
|
|
835 | /* Get the time, if they want it */ |
|
|
836 | if (time_Info != NULL) { |
|
|
837 | time_Info->tv_sec = time(NULL); |
|
|
838 | time_Info->tv_usec = timeGetTime()*1000; |
|
|
839 | } |
|
|
840 | /* Get the timezone, if they want it */ |
|
|
841 | if (timezone_Info != NULL) { |
|
|
842 | _tzset(); |
|
|
843 | timezone_Info->tz_minuteswest = _timezone; |
|
|
844 | timezone_Info->tz_dsttime = _daylight; |
|
|
845 | } |
|
|
846 | /* And return */ |
|
|
847 | return 0; |
|
|
848 | } |
|
|
849 | #endif |
|
|