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

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.290 by root, Sat May 17 14:57:23 2008 UTC vs.
Revision 1.302 by root, Mon Sep 22 23:57:48 2008 UTC

26#if HAVE_EXECINFO_H 26#if HAVE_EXECINFO_H
27# include <execinfo.h> 27# include <execinfo.h>
28#endif 28#endif
29 29
30#include <cstdarg> 30#include <cstdarg>
31#include <typeinfo>
31 32
32#include "global.h" 33#include "global.h"
33#include "loader.h" 34#include "loader.h"
34#include "../random_maps/random_map.h" 35#include "../random_maps/random_map.h"
35#include "evthread.h" 36#include "evthread.h"
80 *stash_cf, 81 *stash_cf,
81 *stash_cf_object_wrap, 82 *stash_cf_object_wrap,
82 *stash_cf_object_player_wrap, 83 *stash_cf_object_player_wrap,
83 *stash_cf_player_wrap, 84 *stash_cf_player_wrap,
84 *stash_cf_map_wrap, 85 *stash_cf_map_wrap,
86 *stash_cf_mapspace_wrap,
85 *stash_cf_client_wrap, 87 *stash_cf_client_wrap,
86 *stash_cf_arch_wrap, 88 *stash_cf_arch_wrap,
87 *stash_cf_party_wrap, 89 *stash_cf_party_wrap,
88 *stash_cf_region_wrap, 90 *stash_cf_region_wrap,
89 *stash_cf_living_wrap; 91 *stash_cf_living_wrap;
428inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } 430inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); }
429inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } 431inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); }
430inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } 432inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); }
431inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } 433inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); }
432inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 434inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
435inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); }
433 436
434inline SV *to_sv (object & v) { return to_sv (&v); } 437inline SV *to_sv (object & v) { return to_sv (&v); }
435inline SV *to_sv (living & v) { return to_sv (&v); } 438inline SV *to_sv (living & v) { return to_sv (&v); }
436 439
437inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } 440inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); }
438inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } 441inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); }
439 442
440inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); } 443inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); }
444
445inline SV *to_sv (dynbuf * v)
446{
447 SV *sv = newSV (0);
448
449 sv_upgrade (sv, SVt_PV);
450 SvGROW (sv, v->size () + 1);
451 SvPOK_only (sv);
452 v->linearise (SvPVX (sv));
453 SvCUR_set (sv, v->size ());
454 *SvEND (sv) = 0;
455
456 return sv;
457}
458
459inline SV *to_sv (dynbuf_text * v)
460{
461 SV *sv = to_sv (static_cast<dynbuf *> (v));
462 SvUTF8_on (sv);
463 return sv;
464}
441 465
442inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } 466inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; }
443inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } 467inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; }
444inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } 468inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
445inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 469inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
461inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } 485inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); }
462inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } 486inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); }
463inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 487inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
464inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 488inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
465inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 489inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
490inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *)SvPTR_ornull (sv, "cf::mapspace"); }
466inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); } 491inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); }
467inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); } 492inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); }
468 493
469//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } 494//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
470inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } 495inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); }
941 CALL_CALL ("ext::books::make_book", G_VOID); 966 CALL_CALL ("ext::books::make_book", G_VOID);
942 CALL_END; 967 CALL_END;
943} 968}
944 969
945void 970void
946cfperl_expand_cfpod (player *pl, std::string &msg)
947{
948 CALL_BEGIN (2);
949 CALL_ARG (pl);
950 CALL_ARG_SV (newSVpvn_utf8 (msg.data (), msg.size ()));
951 CALL_CALL ("cf::player::expand_cfpod", G_SCALAR);
952
953 if (count)
954 {
955 STRLEN len;
956 char *data = SvPVutf8 (TOPs, len);
957 msg.assign (data, len);
958 }
959
960 CALL_END;
961}
962
963void
964cfperl_send_msg (client *ns, int color, const char *type, const char *msg) 971cfperl_send_msg (client *ns, int color, const char *type, const char *msg)
965{ 972{
966 CALL_BEGIN (4); 973 CALL_BEGIN (4);
967 CALL_ARG (ns); 974 CALL_ARG (ns);
968 CALL_ARG (type); 975 CALL_ARG (type);
1189 1196
1190 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); 1197 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1);
1191 stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); 1198 stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1);
1192 stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1); 1199 stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1);
1193 stash_cf_map_wrap = gv_stashpv ("cf::map::wrap" , 1); 1200 stash_cf_map_wrap = gv_stashpv ("cf::map::wrap" , 1);
1201 stash_cf_mapspace_wrap = gv_stashpv ("cf::mapspace::wrap" , 1);
1194 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); 1202 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1);
1195 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); 1203 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1);
1196 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); 1204 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1);
1197 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); 1205 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1);
1198 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); 1206 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1);
1318 const_iv (FLAG_CURSED) const_iv (FLAG_DAMNED) const_iv (FLAG_SEE_ANYWHERE) const_iv (FLAG_KNOWN_MAGICAL) 1326 const_iv (FLAG_CURSED) const_iv (FLAG_DAMNED) const_iv (FLAG_SEE_ANYWHERE) const_iv (FLAG_KNOWN_MAGICAL)
1319 const_iv (FLAG_KNOWN_CURSED) const_iv (FLAG_CAN_USE_SKILL) const_iv (FLAG_BEEN_APPLIED) const_iv (FLAG_READY_SCROLL) 1327 const_iv (FLAG_KNOWN_CURSED) const_iv (FLAG_CAN_USE_SKILL) const_iv (FLAG_BEEN_APPLIED) const_iv (FLAG_READY_SCROLL)
1320 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) 1328 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED)
1321 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) 1329 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON)
1322 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) 1330 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON)
1323 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_CLIENT_SENT) const_iv (FLAG_BERSERK) 1331 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK)
1324 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) 1332 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL)
1325 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) 1333 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER)
1326 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) 1334 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE)
1327 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) 1335 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE)
1328 1336
1329 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) 1337 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED)
1330 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) 1338 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN)
1331 const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD) 1339 const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD)
1332 const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE) 1340 const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE)
1333 const_iv (NDI_ALL) const_iv (NDI_DEF) const_iv (NDI_REPLY) const_iv (NDI_CLIENT_MASK) 1341 const_iv (NDI_ALL) const_iv (NDI_DEF) const_iv (NDI_REPLY) const_iv (NDI_CLIENT_MASK)
1334 const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) 1342 const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) const_iv (NDI_VERBATIM)
1335 1343
1336 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) 1344 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE)
1337 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF) 1345 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF)
1338 1346
1339 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) 1347 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE)
1391 const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK) 1399 const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK)
1392 const_iv (F_LOCKED) 1400 const_iv (F_LOCKED)
1393 1401
1394 const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL) 1402 const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL)
1395 1403
1396 const_iv (P_BLOCKSVIEW) const_iv (P_PLAYER) const_iv (P_NO_MAGIC) const_iv (P_IS_ALIVE) 1404 const_iv (P_BLOCKSVIEW) const_iv (P_NO_MAGIC) const_iv (P_IS_ALIVE)
1397 const_iv (P_NO_CLERIC) const_iv (P_OUT_OF_MAP) const_iv (P_NEW_MAP) const_iv (P_UPTODATE) 1405 const_iv (P_NO_CLERIC) const_iv (P_OUT_OF_MAP) const_iv (P_NEW_MAP) const_iv (P_UPTODATE)
1398 1406
1399 const_iv (UP_OBJ_INSERT) const_iv (UP_OBJ_REMOVE) const_iv (UP_OBJ_CHANGE) const_iv (UP_OBJ_FACE) 1407 const_iv (UP_OBJ_INSERT) const_iv (UP_OBJ_REMOVE) const_iv (UP_OBJ_CHANGE) const_iv (UP_OBJ_FACE)
1400 1408
1401 const_iv (INS_NO_MERGE) const_iv (INS_ABOVE_FLOOR_ONLY) const_iv (INS_NO_WALK_ON) 1409 const_iv (INS_NO_MERGE) const_iv (INS_ABOVE_FLOOR_ONLY) const_iv (INS_NO_WALK_ON)
1498 av_push (event, newSViv (eiv->klass)); 1506 av_push (event, newSViv (eiv->klass));
1499 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1507 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1500 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); 1508 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv));
1501 } 1509 }
1502} 1510}
1511
1512void _gv_clear (SV *gv)
1513 CODE:
1514 assert (SvTYPE (gv) == SVt_PVGV);
1515# define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); }
1516 f (GvGP (gv)->gp_form);
1517 f (GvGP (gv)->gp_io);
1518 f (GvGP (gv)->gp_sv);
1519 f (GvGP (gv)->gp_av);
1520 f (GvGP (gv)->gp_hv);
1521 f (GvGP (gv)->gp_cv);
1522 GvCVGEN (gv) = 0;
1523 GvMULTI_off (gv);
1524# undef f
1525
1503 1526
1504void _connect_to_perl () 1527void _connect_to_perl ()
1505 1528
1506void _recalc_want () 1529void _recalc_want ()
1507 1530
1702#if _POSIX_MEMLOCK 1725#if _POSIX_MEMLOCK
1703 1726
1704int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1727int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1705 INIT: 1728 INIT:
1706#if __GLIBC__ 1729#if __GLIBC__
1730 mallopt (M_TOP_PAD, 1024 * 1024);
1731 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128);
1732 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1707 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1733 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1708#endif 1734#endif
1709 1735
1710int munlockall () 1736int munlockall ()
1711 1737
2100void rangevector (object *ob, object *other, int flags = 0) 2126void rangevector (object *ob, object *other, int flags = 0)
2101 PROTOTYPE: $$;$ 2127 PROTOTYPE: $$;$
2102 PPCODE: 2128 PPCODE:
2103{ 2129{
2104 rv_vector rv; 2130 rv_vector rv;
2131
2132 PUTBACK;
2105 get_rangevector (ob, other, &rv, flags); 2133 get_rangevector (ob, other, &rv, flags);
2134 SPAGAIN;
2135
2106 EXTEND (SP, 5); 2136 EXTEND (SP, 5);
2107 PUSHs (newSVuv (rv.distance)); 2137 PUSHs (newSVuv (rv.distance));
2108 PUSHs (newSViv (rv.distance_x)); 2138 PUSHs (newSViv (rv.distance_x));
2109 PUSHs (newSViv (rv.distance_y)); 2139 PUSHs (newSViv (rv.distance_y));
2110 PUSHs (newSViv (rv.direction)); 2140 PUSHs (newSViv (rv.direction));
2201 if (len > MAXSOCKBUF) 2231 if (len > MAXSOCKBUF)
2202 pl->failmsg ("[packet too long for client]"); 2232 pl->failmsg ("[packet too long for client]");
2203 else if (pl->ns) 2233 else if (pl->ns)
2204 pl->ns->send_packet (buf, len); 2234 pl->ns->send_packet (buf, len);
2205} 2235}
2206
2207int
2208listening (player *pl, int new_value = -1)
2209 CODE:
2210 RETVAL = pl->listening;
2211 if (new_value >= 0)
2212 pl->listening = new_value;
2213 OUTPUT:
2214 RETVAL
2215 2236
2216void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) 2237void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0)
2217 PROTOTYPE: $;$$$ 2238 PROTOTYPE: $;$$$
2218 PPCODE: 2239 PPCODE:
2219 if (GIMME_V != G_VOID) 2240 if (GIMME_V != G_VOID)
2374} 2395}
2375 2396
2376void 2397void
2377maptile::create_region_treasure () 2398maptile::create_region_treasure ()
2378 CODE: 2399 CODE:
2379{
2380 object *op = object::create ();
2381 op->type = FLOOR;
2382 op->map = THIS;
2383
2384 for (int x = 0; x < THIS->width; ++x) 2400 for (int x = 0; x < THIS->width; ++x)
2385 for (int y = 0; y < THIS->height; ++y) 2401 for (int y = 0; y < THIS->height; ++y)
2386 { 2402 {
2387 region *rgn = THIS->region (x, y); 2403 region *rgn = THIS->region (x, y);
2388 2404
2389 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D 2405 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D
2406 if (object *op = THIS->at (x, y).top)
2390 if (rgn->treasure && rndm () < rgn->treasure_density) 2407 if (rgn->treasure && rndm () < rgn->treasure_density)
2391 {
2392 op->x = x;
2393 op->y = y;
2394 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2408 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2395 }
2396 } 2409 }
2397
2398 op->destroy ();
2399}
2400 2410
2401int out_of_map (maptile *map, int x, int y) 2411int out_of_map (maptile *map, int x, int y)
2402 2412
2403void 2413void
2404trigger (maptile *map, long connection, bool state = true) 2414trigger (maptile *map, long connection, bool state = true)
2417get_map_flags (maptile *map, int x, int y) 2427get_map_flags (maptile *map, int x, int y)
2418 PPCODE: 2428 PPCODE:
2419{ 2429{
2420 maptile *nmap = 0; 2430 maptile *nmap = 0;
2421 I16 nx = 0, ny = 0; 2431 I16 nx = 0, ny = 0;
2432
2433 PUTBACK;
2422 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2434 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2435 SPAGAIN;
2423 2436
2424 EXTEND (SP, 4); 2437 EXTEND (SP, 4);
2425 PUSHs (sv_2mortal (newSViv (flags))); 2438 PUSHs (sv_2mortal (newSViv (flags)));
2426 2439
2427 if (GIMME_V == G_ARRAY) 2440 if (GIMME_V == G_ARRAY)
2430 PUSHs (sv_2mortal (newSViv (nx))); 2443 PUSHs (sv_2mortal (newSViv (nx)));
2431 PUSHs (sv_2mortal (newSViv (ny))); 2444 PUSHs (sv_2mortal (newSViv (ny)));
2432 } 2445 }
2433} 2446}
2434 2447
2448mapspace *
2449ms (maptile *map, unsigned int x, unsigned int y)
2450 PROTOTYPE: $$$
2451 CODE:
2452{
2453 maptile *nmap = 0;
2454 I16 nx, ny;
2455
2456 PUTBACK;
2457 get_map_flags (map, &nmap, x, y, &nx, &ny);
2458 SPAGAIN;
2459
2460 if (!nmap)
2461 XSRETURN_UNDEF;
2462
2463 RETVAL = &nmap->at (nx, ny);
2464}
2465 OUTPUT:
2466 RETVAL
2467
2435void 2468void
2436at (maptile *map, unsigned int x, unsigned int y) 2469at (maptile *map, unsigned int x, unsigned int y)
2437 PROTOTYPE: $$$ 2470 PROTOTYPE: $$$
2438 PPCODE: 2471 PPCODE:
2439{ 2472{
2440 object *o;
2441 maptile *nmap = 0; 2473 maptile *nmap = 0;
2442 I16 nx, ny; 2474 I16 nx, ny;
2443 2475
2476 PUTBACK;
2444 get_map_flags (map, &nmap, x, y, &nx, &ny); 2477 get_map_flags (map, &nmap, x, y, &nx, &ny);
2478 SPAGAIN;
2445 2479
2446 if (nmap) 2480 if (nmap)
2447 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) 2481 for (object *o = nmap->at (nx, ny).bot; o; o = o->above)
2448 XPUSHs (sv_2mortal (to_sv (o))); 2482 XPUSHs (sv_2mortal (to_sv (o)));
2449} 2483}
2450 2484
2451SV * 2485SV *
2452bot_at (maptile *obj, unsigned int x, unsigned int y) 2486bot_at (maptile *obj, unsigned int x, unsigned int y)
2565 RETVAL = self->generate_random_map (&rmp); 2599 RETVAL = self->generate_random_map (&rmp);
2566} 2600}
2567 OUTPUT: 2601 OUTPUT:
2568 RETVAL 2602 RETVAL
2569 2603
2604MODULE = cf PACKAGE = cf::mapspace
2605
2606INCLUDE: $PERL $srcdir/genacc mapspace ../include/map.h |
2607
2570MODULE = cf PACKAGE = cf::arch 2608MODULE = cf PACKAGE = cf::arch
2571 2609
2572int archetypes_size () 2610int archetypes_size ()
2573 CODE: 2611 CODE:
2574 RETVAL = archetypes.size (); 2612 RETVAL = archetypes.size ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines