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.9 by root, Sat Feb 4 16:17:47 2006 UTC vs.
Revision 1.12 by root, Tue Feb 7 03:01: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;
57static f_plug_api map_get_map;
56 58
57typedef struct 59typedef 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);
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
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 }
1098
1099SV *
1100inv (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}
1078 1108
1079int cf_object_get_resistance (object *op, int rtype) 1109int cf_object_get_resistance (object *op, int rtype)
1080 ALIAS: resistance = 0 1110 ALIAS: resistance = 0
1081 1111
1082int cf_object_get_flag (object *op, int flag) 1112int cf_object_get_flag (object *op, int flag)
1237 break; 1267 break;
1238 default: 1268 default:
1239 croak ("unhandled type '%d' in set_property '%d'", type, idx); 1269 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1240 } 1270 }
1241 1271
1272mapstruct *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
1242mapstruct *cf_map_get_map (char *name) 1282mapstruct *cf_map_get_map (char *name)
1243 PROTOTYPE: $ 1283 PROTOTYPE: $
1244 ALIAS: map = 0 1284 ALIAS: map = 0
1245 1285
1246mapstruct *cf_map_get_first () 1286mapstruct *cf_map_get_first ()
1254object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) 1294object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1255 C_ARGS: str, map, nx, ny 1295 C_ARGS: str, map, nx, ny
1256 1296
1257#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)
1258 1298
1299SV *
1300at (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
1311SV *
1312bot_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
1259 1338
1260 1339
1261MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ 1340MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_
1262 1341
1263archetype*cf_archetype_get_first() 1342archetype *cf_archetype_get_first()
1264 PROTOTYPE: 1343 PROTOTYPE:
1265 ALIAS: first = 0 1344 ALIAS: first = 0
1266 1345
1267archetype *cf_archetype_get_next (archetype *arch) 1346archetype *cf_archetype_get_next (archetype *arch)
1268 ALIAS: next = 0 1347 ALIAS: next = 0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines