ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/plugins/common/plugin_common.C
(Generate patch)

Comparing deliantra/server/plugins/common/plugin_common.C (file contents):
Revision 1.2 by root, Sun Sep 3 08:05:39 2006 UTC vs.
Revision 1.8 by pippijn, Fri Mar 2 10:15:39 2007 UTC

35/*****************************************************************************/ 35/*****************************************************************************/
36#include <plugin_common.h> 36#include <plugin_common.h>
37 37
38static f_plug_api cfapiSystem_register_global_event = NULL; 38static f_plug_api cfapiSystem_register_global_event = NULL;
39static f_plug_api cfapiSystem_unregister_global_event = NULL; 39static f_plug_api cfapiSystem_unregister_global_event = NULL;
40static f_plug_api cfapiSystem_strdup_local = NULL;
41static f_plug_api cfapiSystem_find_animation = NULL; 40static f_plug_api cfapiSystem_find_animation = NULL;
42 41
43static f_plug_api cfapiMap_create_path = NULL; 42static f_plug_api cfapiMap_create_path = NULL;
44 43
45static f_plug_api cfapiObject_get_property = NULL; 44static f_plug_api cfapiObject_get_property = NULL;
61static f_plug_api cfapiObject_merge = NULL; 60static f_plug_api cfapiObject_merge = NULL;
62static f_plug_api cfapiObject_distance = NULL; 61static f_plug_api cfapiObject_distance = NULL;
63static f_plug_api cfapiObject_update = NULL; 62static f_plug_api cfapiObject_update = NULL;
64static f_plug_api cfapiObject_clear = NULL; 63static f_plug_api cfapiObject_clear = NULL;
65static f_plug_api cfapiObject_reset = NULL; 64static f_plug_api cfapiObject_reset = NULL;
66static f_plug_api cfapiCheck_inventory = NULL; 65/* static f_plug_api cfapiCheck_inventory = NULL; */
67static f_plug_api cfapiObject_activate_rune = NULL; 66static f_plug_api cfapiObject_activate_rune = NULL;
68static f_plug_api cfapiObject_check_trigger = NULL; 67static f_plug_api cfapiObject_check_trigger = NULL;
69static f_plug_api cfapiObject_query_money = NULL; 68static f_plug_api cfapiObject_query_money = NULL;
70static f_plug_api cfapiObject_query_cost = NULL; 69static f_plug_api cfapiObject_query_cost = NULL;
71static f_plug_api cfapiObject_cast = NULL; 70static f_plug_api cfapiObject_cast = NULL;
110 } } 109 } }
111 110
112int cf_init_plugin( f_plug_api getHooks ) 111int 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 */
185void* cf_map_get_property(mapstruct* map, int propcode) 183void* 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 */
191void* cf_map_set_int_property(mapstruct* map, int propcode, int value) 189void* 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}
271int cf_object_change_map(object* op, int x, int y, mapstruct* map) 269int 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}
278object* cf_map_get_object_at(mapstruct* m, int x, int y) 276object* 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}
283void cf_map_message(mapstruct* m, char* msg, int color) 281void 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}
288object* cf_object_clone(object* op, int clonetype) 286object* 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
366mapstruct* cf_map_get_map( char* name ) 364maptile* 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}
371mapstruct* cf_map_get_first(void) 369maptile* 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}
376int cf_object_query_money( object* op) 374int 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}
397int cf_object_out_of_map( object* op, int x, int y) 395int 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}
402void cf_object_drop( object* op, object* author) 399void 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
570object* cf_map_insert_object_there(mapstruct* where, object* op, object* originator, int flags) 567object* 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}
575object* cf_map_insert_object(mapstruct* where , object* op, int x, int y) 572object* 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}
580int cf_object_teleport( object* op, mapstruct* map, int x, int y ) 577int 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}
585object* cf_map_present_arch_by_name(const char* str, mapstruct* map, int nx, int ny) 582object* 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
591static int cf_get_map_int_property(mapstruct* map, int property) 588static 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
601int cf_map_get_difficulty(mapstruct* map) 598int 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
606int cf_map_get_reset_time(mapstruct* map) 603int 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
611int cf_map_get_reset_timeout(mapstruct* map) 608int 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
616int cf_map_get_players(mapstruct* map) 613int 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
621int cf_map_get_darkness(mapstruct* map) 618int 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
626int cf_map_get_width(mapstruct* map) 623int 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
631int cf_map_get_height(mapstruct* map) 628int 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
636int cf_map_get_enter_x(mapstruct* map) 633int 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
641int cf_map_get_enter_y(mapstruct* map) 638int 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
646int cf_map_get_temperature(mapstruct* map) 643int 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
651int cf_map_get_pressure(mapstruct* map) 648int 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
656int cf_map_get_humidity(mapstruct* map) 653int 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
661int cf_map_get_windspeed(mapstruct* map) 658int 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
666int cf_map_get_winddir(mapstruct* map) 663int 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
671int cf_map_get_sky(mapstruct* map) 668int 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
676int cf_map_get_wpartx(mapstruct* map) 673int 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
681int cf_map_get_wparty(mapstruct* map) 678int 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
686void cf_object_update( object* op, int flags) 683void cf_object_update( object* op, int flags)
691void cf_object_pickup( object* op, object* what) 688void 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}
696char* cf_strdup_local(char* txt) 693char* cf_strdup(char* txt)
697{ 694{
698 int val; 695 return (char*)strdup(txt);
699 return (char*)cfapiSystem_strdup_local(&val, txt);
700} 696}
701int cf_map_get_flags( mapstruct* map, mapstruct** nmap, sint16 x, sint16 y, sint16* nx, sint16* ny ) 697int 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}
706int cf_find_animation(char* txt) 702int cf_find_animation(char* txt)
826const char* cf_region_get_message(region* reg) 822const 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
833int 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines