… | |
… | |
51 | |
51 | |
52 | static f_plug_api gethook; |
52 | static f_plug_api gethook; |
53 | static f_plug_api registerGlobalEvent; |
53 | static f_plug_api registerGlobalEvent; |
54 | static f_plug_api unregisterGlobalEvent; |
54 | static f_plug_api unregisterGlobalEvent; |
55 | static f_plug_api systemDirectory; |
55 | static f_plug_api systemDirectory; |
56 | static f_plug_api reCmp; |
|
|
57 | |
56 | |
58 | typedef struct |
57 | typedef 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 | |
997 | char * |
997 | char * |
998 | cf_get_maps_directory (char *path) |
998 | cf_get_maps_directory (char *path) |
999 | ALIAS: maps_directory = 0 |
999 | ALIAS: maps_directory = 0 |
1000 | |
1000 | |
|
|
1001 | char * |
|
|
1002 | mapdir () |
|
|
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 | |
|
|
1019 | int |
|
|
1020 | cf_find_animation (char *text) |
|
|
1021 | |
1001 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1022 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1002 | |
1023 | |
1003 | PROTOTYPES: DISABLE |
1024 | PROTOTYPES: DISABLE |
1004 | |
1025 | |
1005 | SV * |
1026 | SV * |
1006 | cf_object_get_property (object *obj, int type, int idx) |
1027 | get_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 | |
|
|
1033 | SV * |
|
|
1034 | set_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 | |
1012 | int cf_object_get_resistance (object *op, int rtype) |
1051 | int cf_object_get_resistance (object *op, int rtype) |
1013 | ALIAS: resistance = 0 |
1052 | ALIAS: resistance = 0 |
1014 | |
1053 | |
1015 | int cf_object_get_flag (object *op, int flag) |
1054 | int cf_object_get_flag (object *op, int flag) |
… | |
… | |
1119 | |
1158 | |
1120 | void cf_player_message (object *obj, char *txt, int flags = 0) |
1159 | void cf_player_message (object *obj, char *txt, int flags = 0) |
1121 | |
1160 | |
1122 | object *cf_player_send_inventory (object *op) |
1161 | object *cf_player_send_inventory (object *op) |
1123 | |
1162 | |
|
|
1163 | void cf_player_set_marked_item(object *op, object *ob) |
|
|
1164 | |
|
|
1165 | void cf_player_set_party(object *op, partylist *party) |
|
|
1166 | |
1124 | |
1167 | |
1125 | MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ |
1168 | MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ |
1126 | |
|
|
1127 | mapstruct *cf_map_get_map (char *name) |
|
|
1128 | ALIAS: map = 0 |
|
|
1129 | |
|
|
1130 | mapstruct *cf_map_get_first () |
|
|
1131 | ALIAS: first = 0 |
|
|
1132 | |
|
|
1133 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
|
|
1134 | |
|
|
1135 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
|
|
1136 | |
|
|
1137 | object* 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 | |
1143 | MODULE = cf PACKAGE = cf::player PREFIX = cf_ |
1170 | MODULE = cf PACKAGE = cf::player PREFIX = cf_ |
1144 | |
1171 | |
1145 | player *cf_player_find (char *name) |
1172 | player *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 | |
|
|
1186 | SV * |
|
|
1187 | set_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 | |
|
|
1198 | mapstruct *cf_map_get_map (char *name) |
|
|
1199 | ALIAS: map = 0 |
|
|
1200 | |
|
|
1201 | mapstruct *cf_map_get_first () |
|
|
1202 | ALIAS: first = 0 |
|
|
1203 | |
|
|
1204 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
|
|
1205 | |
|
|
1206 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
|
|
1207 | |
|
|
1208 | object* 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 | |
1160 | MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ |
1215 | MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ |
1161 | |
1216 | |
1162 | archetype*cf_archetype_get_first() |
1217 | archetype*cf_archetype_get_first() |
1163 | ALIAS: first = 0 |
1218 | ALIAS: first = 0 |