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

Comparing deliantra/server/plugins/cfperl/cfperl.xs (file contents):
Revision 1.7 by root, Fri Feb 3 22:52:51 2006 UTC vs.
Revision 1.10 by root, Sat Feb 4 20:38:29 2006 UTC

51 51
52static f_plug_api gethook; 52static f_plug_api gethook;
53static f_plug_api registerGlobalEvent; 53static f_plug_api registerGlobalEvent;
54static f_plug_api unregisterGlobalEvent; 54static f_plug_api unregisterGlobalEvent;
55static f_plug_api systemDirectory; 55static f_plug_api systemDirectory;
56static f_plug_api object_set_property;
56 57
57typedef struct 58typedef struct
58{ 59{
59 object* who; 60 object* who;
60 object* activator; 61 object* activator;
334 printf (PLUGIN_VERSION " post init\n"); 335 printf (PLUGIN_VERSION " post init\n");
335 336
336 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); 337 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event");
337 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); 338 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event");
338 systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); 339 systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory");
340 object_set_property = gethook (&rtype, hooktype, "cfapi_object_set_property");
339 cf_init_plugin (gethook); 341 cf_init_plugin (gethook);
340 342
341 /* Pick the global events you want to monitor from this plugin */ 343 /* Pick the global events you want to monitor from this plugin */
342 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); 344 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener);
343 registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); 345 registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener);
543 545
544BOOT: 546BOOT:
545{ 547{
546 HV *stash = gv_stashpv ("cf", 1); 548 HV *stash = gv_stashpv ("cf", 1);
547 549
548 const struct { 550 static const struct {
549 const char *name; 551 const char *name;
550 IV iv; 552 IV iv;
551 } *civ, const_iv[] = { 553 } *civ, const_iv[] = {
552# define const_iv(name) { # name, (IV)name }, 554# define const_iv(name) { # name, (IV)name },
553 const_iv (llevError) 555 const_iv (llevError)
837 }; 839 };
838 840
839 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 841 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
840 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 842 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
841 843
842 const struct { 844 static const struct {
843 const char *name; 845 const char *name;
844 IV iv; 846 IV iv;
845 } *event, event_list[] = { 847 } *event, event_list[] = {
846# define const_event(name) { # name, (IV)EVENT_ ## name }, 848# define const_event(name) { # name, (IV)EVENT_ ## name },
847 const_event (NONE) 849 const_event (NONE)
878 AV *av = get_av ("cf::EVENT", 1); 880 AV *av = get_av ("cf::EVENT", 1);
879 881
880 for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; ) 882 for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; )
881 av_store (av, event->iv, newSVpv ((char *)event->name, 0)); 883 av_store (av, event->iv, newSVpv ((char *)event->name, 0));
882 884
883 const struct { 885 static const struct {
884 int dtype; 886 int dtype;
885 const char *name; 887 const char *name;
886 IV idx; 888 IV idx;
887 } *cprop, prop_table[] = { 889 } *cprop, prop_table[] = {
888# define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, 890# define prop(type, name) { type, # name, (IV) CFAPI_ ## name },
1067 cf_object_set_int_property (obj, idx, SvIV (newval)); 1069 cf_object_set_int_property (obj, idx, SvIV (newval));
1068 break; 1070 break;
1069 case CFAPI_LONG: 1071 case CFAPI_LONG:
1070 cf_object_set_long_property (obj, idx, SvNV (newval)); 1072 cf_object_set_long_property (obj, idx, SvNV (newval));
1071 break; 1073 break;
1074 case CFAPI_DOUBLE:
1075 {
1076 int unused_type;
1077 object_set_property (&unused_type, obj, idx, (double)SvNV (newval));
1078 }
1079 break;
1072 case CFAPI_STRING: 1080 case CFAPI_STRING:
1073 cf_object_set_string_property (obj, idx, SvPV_nolen (newval)); 1081 cf_object_set_string_property (obj, idx, SvPV_nolen (newval));
1074 break; 1082 break;
1075 default: 1083 default:
1076 croak ("unhandled type '%d' in set_property '%d'", type, idx); 1084 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1160 RETVAL = cf_query_base_name (ob, plural); 1168 RETVAL = cf_query_base_name (ob, plural);
1161 OUTPUT: RETVAL 1169 OUTPUT: RETVAL
1162 1170
1163MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1171MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1164 1172
1165object *cf_create_object ()
1166 PROTOTYPE:
1167 ALIAS: new = 0
1168
1169object *cf_create_object_by_name (const char *name) 1173object *cf_create_object_by_name (const char *name = 0)
1170 PROTOTYPE: $ 1174 PROTOTYPE: ;$
1171 ALIAS: new_from_name = 0 1175 ALIAS:
1172 1176 create_object = 0
1173void cf_free_object (object *ob) 1177 new = 0
1178 CODE:
1179 RETVAL = name ? cf_create_object_by_name (name) : cf_create_object ();
1180 OUTPUT:
1181 RETVAL
1174 1182
1175void cf_fix_object (object *pl) 1183void cf_fix_object (object *pl)
1184 ALIAS: fix = 0
1176 1185
1177object *cf_insert_ob_in_ob (object *ob, object *where) 1186object *cf_insert_ob_in_ob (object *ob, object *where)
1178 1187
1179 1188
1180MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 1189MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines