… | |
… | |
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 object_set_property; |
|
|
57 | static f_plug_api map_get_map; |
56 | |
58 | |
57 | typedef struct |
59 | typedef struct |
58 | { |
60 | { |
59 | object* who; |
61 | object* who; |
60 | object* activator; |
62 | object* activator; |
… | |
… | |
334 | printf (PLUGIN_VERSION " post init\n"); |
336 | printf (PLUGIN_VERSION " post init\n"); |
335 | |
337 | |
336 | registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); |
338 | registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); |
337 | unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); |
339 | unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); |
338 | systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); |
340 | systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); |
|
|
341 | object_set_property = gethook (&rtype, hooktype, "cfapi_object_set_property"); |
|
|
342 | map_get_map = gethook (&rtype, hooktype, "cfapi_map_get_map"); |
|
|
343 | |
339 | cf_init_plugin (gethook); |
344 | cf_init_plugin (gethook); |
340 | |
345 | |
341 | /* Pick the global events you want to monitor from this plugin */ |
346 | /* Pick the global events you want to monitor from this plugin */ |
342 | registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); |
347 | registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); |
343 | registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); |
348 | registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); |
… | |
… | |
543 | |
548 | |
544 | BOOT: |
549 | BOOT: |
545 | { |
550 | { |
546 | HV *stash = gv_stashpv ("cf", 1); |
551 | HV *stash = gv_stashpv ("cf", 1); |
547 | |
552 | |
548 | const struct { |
553 | static const struct { |
549 | const char *name; |
554 | const char *name; |
550 | IV iv; |
555 | IV iv; |
551 | } *civ, const_iv[] = { |
556 | } *civ, const_iv[] = { |
552 | # define const_iv(name) { # name, (IV)name }, |
557 | # define const_iv(name) { # name, (IV)name }, |
553 | const_iv (llevError) |
558 | const_iv (llevError) |
… | |
… | |
832 | const_iv (F_CURSED) |
837 | const_iv (F_CURSED) |
833 | const_iv (F_DAMNED) |
838 | const_iv (F_DAMNED) |
834 | const_iv (F_OPEN) |
839 | const_iv (F_OPEN) |
835 | const_iv (F_NOPICK) |
840 | const_iv (F_NOPICK) |
836 | const_iv (F_LOCKED) |
841 | const_iv (F_LOCKED) |
|
|
842 | |
|
|
843 | const_iv (P_BLOCKSVIEW) |
|
|
844 | const_iv (P_NO_MAGIC) |
|
|
845 | const_iv (P_IS_ALIVE) |
|
|
846 | const_iv (P_NO_CLERIC) |
|
|
847 | const_iv (P_NEED_UPDATE) |
|
|
848 | const_iv (P_NO_ERROR) |
|
|
849 | const_iv (P_OUT_OF_MAP) |
|
|
850 | const_iv (P_NEW_MAP) |
837 | }; |
851 | }; |
838 | |
852 | |
839 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
853 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
840 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
854 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
841 | |
855 | |
842 | const struct { |
856 | static const struct { |
843 | const char *name; |
857 | const char *name; |
844 | IV iv; |
858 | IV iv; |
845 | } *event, event_list[] = { |
859 | } *event, event_list[] = { |
846 | # define const_event(name) { # name, (IV)EVENT_ ## name }, |
860 | # define const_event(name) { # name, (IV)EVENT_ ## name }, |
847 | const_event (NONE) |
861 | const_event (NONE) |
… | |
… | |
878 | AV *av = get_av ("cf::EVENT", 1); |
892 | AV *av = get_av ("cf::EVENT", 1); |
879 | |
893 | |
880 | for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; ) |
894 | 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)); |
895 | av_store (av, event->iv, newSVpv ((char *)event->name, 0)); |
882 | |
896 | |
883 | const struct { |
897 | static const struct { |
884 | int dtype; |
898 | int dtype; |
885 | const char *name; |
899 | const char *name; |
886 | IV idx; |
900 | IV idx; |
887 | } *cprop, prop_table[] = { |
901 | } *cprop, prop_table[] = { |
888 | # define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, |
902 | # define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, |
… | |
… | |
1067 | cf_object_set_int_property (obj, idx, SvIV (newval)); |
1081 | cf_object_set_int_property (obj, idx, SvIV (newval)); |
1068 | break; |
1082 | break; |
1069 | case CFAPI_LONG: |
1083 | case CFAPI_LONG: |
1070 | cf_object_set_long_property (obj, idx, SvNV (newval)); |
1084 | cf_object_set_long_property (obj, idx, SvNV (newval)); |
1071 | break; |
1085 | break; |
|
|
1086 | case CFAPI_DOUBLE: |
|
|
1087 | { |
|
|
1088 | int unused_type; |
|
|
1089 | object_set_property (&unused_type, obj, idx, (double)SvNV (newval)); |
|
|
1090 | } |
|
|
1091 | break; |
1072 | case CFAPI_STRING: |
1092 | case CFAPI_STRING: |
1073 | cf_object_set_string_property (obj, idx, SvPV_nolen (newval)); |
1093 | cf_object_set_string_property (obj, idx, SvPV_nolen (newval)); |
1074 | break; |
1094 | break; |
1075 | default: |
1095 | default: |
1076 | croak ("unhandled type '%d' in set_property '%d'", type, idx); |
1096 | croak ("unhandled type '%d' in set_property '%d'", type, idx); |
1077 | } |
1097 | } |
1078 | |
1098 | |
|
|
1099 | SV * |
|
|
1100 | inv (object *obj) |
|
|
1101 | PROTOTYPE: $ |
|
|
1102 | PPCODE: |
|
|
1103 | { |
|
|
1104 | object *o; |
|
|
1105 | for (o = obj->inv; o; o = o->below) |
|
|
1106 | XPUSHs (newSVcfapi (CFAPI_POBJECT, o)); |
|
|
1107 | } |
|
|
1108 | |
1079 | int cf_object_get_resistance (object *op, int rtype) |
1109 | int cf_object_get_resistance (object *op, int rtype) |
1080 | ALIAS: resistance = 0 |
1110 | ALIAS: resistance = 0 |
1081 | |
1111 | |
1082 | int cf_object_get_flag (object *op, int flag) |
1112 | int cf_object_get_flag (object *op, int flag) |
1083 | ALIAS: flag = 0 |
1113 | ALIAS: flag = 0 |
… | |
… | |
1160 | RETVAL = cf_query_base_name (ob, plural); |
1190 | RETVAL = cf_query_base_name (ob, plural); |
1161 | OUTPUT: RETVAL |
1191 | OUTPUT: RETVAL |
1162 | |
1192 | |
1163 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1193 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1164 | |
1194 | |
1165 | object *cf_create_object () |
|
|
1166 | PROTOTYPE: |
|
|
1167 | ALIAS: new = 0 |
|
|
1168 | |
|
|
1169 | object *cf_create_object_by_name (const char *name) |
1195 | object *cf_create_object_by_name (const char *name = 0) |
1170 | PROTOTYPE: $ |
1196 | PROTOTYPE: ;$ |
1171 | ALIAS: new_from_name = 0 |
1197 | ALIAS: |
1172 | |
1198 | create_object = 0 |
1173 | void cf_free_object (object *ob) |
1199 | new = 0 |
|
|
1200 | CODE: |
|
|
1201 | RETVAL = name ? cf_create_object_by_name (name) : cf_create_object (); |
|
|
1202 | OUTPUT: |
|
|
1203 | RETVAL |
1174 | |
1204 | |
1175 | void cf_fix_object (object *pl) |
1205 | void cf_fix_object (object *pl) |
|
|
1206 | ALIAS: fix = 0 |
1176 | |
1207 | |
1177 | object *cf_insert_ob_in_ob (object *ob, object *where) |
1208 | object *cf_insert_ob_in_ob (object *ob, object *where) |
1178 | |
1209 | |
1179 | |
1210 | |
1180 | MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
1211 | MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
… | |
… | |
1236 | break; |
1267 | break; |
1237 | default: |
1268 | default: |
1238 | croak ("unhandled type '%d' in set_property '%d'", type, idx); |
1269 | croak ("unhandled type '%d' in set_property '%d'", type, idx); |
1239 | } |
1270 | } |
1240 | |
1271 | |
|
|
1272 | mapstruct *new (int width, int height) |
|
|
1273 | PROTOTYPE: |
|
|
1274 | CODE: |
|
|
1275 | { |
|
|
1276 | int unused_type; |
|
|
1277 | RETVAL = map_get_map (&unused_type, 0, width, height); |
|
|
1278 | } |
|
|
1279 | OUTPUT: |
|
|
1280 | RETVAL |
|
|
1281 | |
1241 | mapstruct *cf_map_get_map (char *name) |
1282 | mapstruct *cf_map_get_map (char *name) |
1242 | PROTOTYPE: $ |
1283 | PROTOTYPE: $ |
1243 | ALIAS: map = 0 |
1284 | ALIAS: map = 0 |
1244 | |
1285 | |
1245 | mapstruct *cf_map_get_first () |
1286 | mapstruct *cf_map_get_first () |
… | |
… | |
1253 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
1294 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
1254 | C_ARGS: str, map, nx, ny |
1295 | C_ARGS: str, map, nx, ny |
1255 | |
1296 | |
1256 | #int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny) |
1297 | #int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny) |
1257 | |
1298 | |
|
|
1299 | SV * |
|
|
1300 | at (mapstruct *obj, unsigned int x, unsigned int y) |
|
|
1301 | PROTOTYPE: $$$ |
|
|
1302 | INIT: |
|
|
1303 | if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_UNDEF; |
|
|
1304 | PPCODE: |
|
|
1305 | { |
|
|
1306 | object *o; |
|
|
1307 | for (o = GET_MAP_OB (obj, x, y); o; o = o->above) |
|
|
1308 | XPUSHs (newSVcfapi (CFAPI_POBJECT, o)); |
|
|
1309 | } |
|
|
1310 | |
|
|
1311 | SV * |
|
|
1312 | bot_at (mapstruct *obj, unsigned int x, unsigned int y) |
|
|
1313 | PROTOTYPE: $$$ |
|
|
1314 | ALIAS: |
|
|
1315 | top_at = 1 |
|
|
1316 | flags_at = 2 |
|
|
1317 | light_at = 3 |
|
|
1318 | move_block_at = 4 |
|
|
1319 | move_slow_at = 5 |
|
|
1320 | move_on_at = 6 |
|
|
1321 | move_off_at = 7 |
|
|
1322 | INIT: |
|
|
1323 | if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_UNDEF; |
|
|
1324 | CODE: |
|
|
1325 | switch (ix) |
|
|
1326 | { |
|
|
1327 | case 0: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_OB (obj, x, y)); break; |
|
|
1328 | case 1: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_TOP (obj, x, y)); break; |
|
|
1329 | case 2: RETVAL = newSVuv ( GET_MAP_FLAGS (obj, x, y)); break; |
|
|
1330 | case 3: RETVAL = newSViv ( GET_MAP_LIGHT (obj, x, y)); break; |
|
|
1331 | case 4: RETVAL = newSVuv ( GET_MAP_MOVE_BLOCK (obj, x, y)); break; |
|
|
1332 | case 5: RETVAL = newSVuv ( GET_MAP_MOVE_SLOW (obj, x, y)); break; |
|
|
1333 | case 6: RETVAL = newSVuv ( GET_MAP_MOVE_ON (obj, x, y)); break; |
|
|
1334 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
|
|
1335 | } |
|
|
1336 | OUTPUT: |
|
|
1337 | RETVAL |
1258 | |
1338 | |
1259 | |
1339 | |
1260 | MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ |
1340 | MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ |
1261 | |
1341 | |
1262 | archetype*cf_archetype_get_first() |
1342 | archetype *cf_archetype_get_first() |
1263 | PROTOTYPE: |
1343 | PROTOTYPE: |
1264 | ALIAS: first = 0 |
1344 | ALIAS: first = 0 |
1265 | |
1345 | |
1266 | archetype *cf_archetype_get_next (archetype *arch) |
1346 | archetype *cf_archetype_get_next (archetype *arch) |
1267 | ALIAS: next = 0 |
1347 | ALIAS: next = 0 |