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.2 by root, Fri Feb 3 07:51:14 2006 UTC vs.
Revision 1.5 by root, Fri Feb 3 19:49:32 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 reCmp;
57 56
58typedef struct 57typedef struct
59{ 58{
60 object* who; 59 object* who;
61 object* activator; 60 object* activator;
281 char *propname; 280 char *propname;
282 int i; 281 int i;
283 va_start (args, type); 282 va_start (args, type);
284 propname = va_arg (args, char *); 283 propname = va_arg (args, char *);
285 //printf ("Property name: %s\n", propname); 284 //printf ("Property name: %s\n", propname);
286 285
287 if (!strcmp (propname, "command?")) 286 if (!strcmp (propname, "command?"))
288 { 287 {
288 if (!perl)
289 return NULL;
290
289 const char *cmdname = va_arg (args, const char *); 291 const char *cmdname = va_arg (args, const char *);
290 HV *hv = get_hv ("cf::COMMAND", 1); 292 HV *hv = get_hv ("cf::COMMAND", 1);
291 SV **svp = hv_fetch (hv, cmdname, strlen (cmdname) + 1, 0); 293 SV **svp = hv_fetch (hv, cmdname, strlen (cmdname) + 1, 0);
292 294
293 va_end (args); 295 va_end (args);
329 printf (PLUGIN_VERSION " post init\n"); 331 printf (PLUGIN_VERSION " post init\n");
330 332
331 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); 333 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event");
332 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); 334 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event");
333 systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); 335 systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory");
334 reCmp = gethook (&rtype, hooktype, "cfapi_system_re_cmp");
335 cf_init_plugin (gethook); 336 cf_init_plugin (gethook);
336 337
337 /* Pick the global events you want to monitor from this plugin */ 338 /* Pick the global events you want to monitor from this plugin */
338 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); 339 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener);
339 registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); 340 registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener);
354 char *argv[] = { 355 char *argv[] = {
355 "", 356 "",
356 "-e" 357 "-e"
357 "BEGIN {" 358 "BEGIN {"
358 " cf->bootstrap;" 359 " cf->bootstrap;"
359 " unshift @INC, cf::maps_directory ('perl');" 360 " unshift @INC, cf::datadir ();"
360 "}" 361 "}"
361 "" 362 ""
362 "use cf;" 363 "use cf;"
363 }; 364 };
364 365
365 perl = perl_alloc (); 366 perl = perl_alloc ();
366 perl_construct (perl); 367 perl_construct (perl);
367 368
368 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) 369 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl))
369 || perl_run (perl))
370 { 370 {
371 printf ("unable to initialize perl-interpreter, continuing without.\n"); 371 printf ("unable to initialize perl-interpreter, continuing without.\n");
372 372
373 perl_destruct (perl); 373 perl_destruct (perl);
374 perl_free (perl); 374 perl_free (perl);
996 996
997char * 997char *
998cf_get_maps_directory (char *path) 998cf_get_maps_directory (char *path)
999 ALIAS: maps_directory = 0 999 ALIAS: maps_directory = 0
1000 1000
1001char *
1002mapdir ()
1003 ALIAS:
1004 mapdir = 0
1005 uniquedir = 1
1006 tmpdir = 2
1007 confdir = 3
1008 localdir = 4
1009 playerdir = 5
1010 datadir = 6
1011 CODE:
1012{
1013 int unused_type;
1014 RETVAL = (char *)systemDirectory (&unused_type, ix);
1015}
1016 OUTPUT:
1017 RETVAL
1018
1019int
1020cf_find_animation (char *text)
1021
1001MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1022MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1002 1023
1003PROTOTYPES: DISABLE 1024PROTOTYPES: DISABLE
1004 1025
1005SV * 1026SV *
1006cf_object_get_property (object *obj, int type, int idx) 1027get_property (object *obj, int type, int idx)
1007 CODE: 1028 CODE:
1008 RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); 1029 RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx));
1009 OUTPUT: 1030 OUTPUT:
1010 RETVAL 1031 RETVAL
1032
1033SV *
1034set_property (object *obj, int type, int idx, SV *newval)
1035 CODE:
1036 switch (type)
1037 {
1038 case CFAPI_INT:
1039 cf_object_set_int_property (obj, idx, SvIV (newval));
1040 break;
1041 case CFAPI_LONG:
1042 cf_object_set_long_property (obj, idx, SvNV (newval));
1043 break;
1044 case CFAPI_STRING:
1045 cf_object_set_string_property (obj, idx, SvPV_nolen (newval));
1046 break;
1047 default:
1048 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1049 }
1011 1050
1012int cf_object_get_resistance (object *op, int rtype) 1051int cf_object_get_resistance (object *op, int rtype)
1013 ALIAS: resistance = 0 1052 ALIAS: resistance = 0
1014 1053
1015int cf_object_get_flag (object *op, int flag) 1054int cf_object_get_flag (object *op, int flag)
1119 1158
1120void cf_player_message (object *obj, char *txt, int flags = 0) 1159void cf_player_message (object *obj, char *txt, int flags = 0)
1121 1160
1122object *cf_player_send_inventory (object *op) 1161object *cf_player_send_inventory (object *op)
1123 1162
1163void cf_player_set_marked_item(object *op, object *ob)
1164
1165void cf_player_set_party(object *op, partylist *party)
1166
1124 1167
1125MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ 1168MODULE = cf PACKAGE = cf::object::map PREFIX = cf_
1126
1127mapstruct *cf_map_get_map (char *name)
1128 ALIAS: map = 0
1129
1130mapstruct *cf_map_get_first ()
1131 ALIAS: first = 0
1132
1133object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags)
1134
1135object *cf_map_insert_object (mapstruct *where, object* op, int x, int y)
1136
1137object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1138 C_ARGS: str, map, nx, ny
1139
1140#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny)
1141
1142 1169
1143MODULE = cf PACKAGE = cf::player PREFIX = cf_ 1170MODULE = cf PACKAGE = cf::player PREFIX = cf_
1144 1171
1145player *cf_player_find (char *name) 1172player *cf_player_find (char *name)
1146 1173
1154 CODE: 1181 CODE:
1155 RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx)); 1182 RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx));
1156 OUTPUT: 1183 OUTPUT:
1157 RETVAL 1184 RETVAL
1158 1185
1186SV *
1187set_property (mapstruct *obj, int type, int idx, SV *newval)
1188 CODE:
1189 switch (type)
1190 {
1191 case CFAPI_INT:
1192 cf_map_set_int_property (obj, idx, SvIV (newval));
1193 break;
1194 default:
1195 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1196 }
1197
1198mapstruct *cf_map_get_map (char *name)
1199 ALIAS: map = 0
1200
1201mapstruct *cf_map_get_first ()
1202 ALIAS: first = 0
1203
1204object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags)
1205
1206object *cf_map_insert_object (mapstruct *where, object* op, int x, int y)
1207
1208object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1209 C_ARGS: str, map, nx, ny
1210
1211#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny)
1212
1213
1159 1214
1160MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ 1215MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_
1161 1216
1162archetype*cf_archetype_get_first() 1217archetype*cf_archetype_get_first()
1163 ALIAS: first = 0 1218 ALIAS: first = 0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines