… | |
… | |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include "autoconf.h" |
24 | #include "autoconf.h" |
25 | |
25 | |
26 | #define PLUGIN_NAME "perl" |
|
|
27 | #define PLUGIN_VERSION "cfperl 0.5" |
|
|
28 | |
|
|
29 | #if HAVE_EXECINFO_H |
26 | #if HAVE_EXECINFO_H |
30 | # include <execinfo.h> |
27 | # include <execinfo.h> |
31 | #endif |
28 | #endif |
32 | |
29 | |
33 | #include <cstdarg> |
30 | #include <cstdarg> |
|
|
31 | #include <typeinfo> |
34 | |
32 | |
35 | #include "global.h" |
33 | #include "global.h" |
36 | #include "loader.h" |
34 | #include "loader.h" |
37 | #include "../random_maps/random_map.h" |
35 | #include "../random_maps/random_map.h" |
38 | #include "evthread.h" |
36 | #include "evthread.h" |
… | |
… | |
83 | *stash_cf, |
81 | *stash_cf, |
84 | *stash_cf_object_wrap, |
82 | *stash_cf_object_wrap, |
85 | *stash_cf_object_player_wrap, |
83 | *stash_cf_object_player_wrap, |
86 | *stash_cf_player_wrap, |
84 | *stash_cf_player_wrap, |
87 | *stash_cf_map_wrap, |
85 | *stash_cf_map_wrap, |
|
|
86 | *stash_cf_mapspace_wrap, |
88 | *stash_cf_client_wrap, |
87 | *stash_cf_client_wrap, |
89 | *stash_cf_arch_wrap, |
88 | *stash_cf_arch_wrap, |
90 | *stash_cf_party_wrap, |
89 | *stash_cf_party_wrap, |
91 | *stash_cf_region_wrap, |
90 | *stash_cf_region_wrap, |
92 | *stash_cf_living_wrap; |
91 | *stash_cf_living_wrap; |
… | |
… | |
431 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
430 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
432 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
431 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
433 | inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
432 | inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
434 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
433 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
435 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
434 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
|
|
435 | inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
436 | |
436 | |
437 | inline SV *to_sv (object & v) { return to_sv (&v); } |
437 | inline SV *to_sv (object & v) { return to_sv (&v); } |
438 | inline SV *to_sv (living & v) { return to_sv (&v); } |
438 | inline SV *to_sv (living & v) { return to_sv (&v); } |
439 | |
439 | |
440 | inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
440 | inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
441 | inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } |
441 | inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } |
442 | |
442 | |
443 | inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); } |
443 | inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); } |
|
|
444 | |
|
|
445 | inline 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 | |
|
|
459 | inline SV *to_sv (dynbuf_text * v) |
|
|
460 | { |
|
|
461 | SV *sv = to_sv (static_cast<dynbuf *> (v)); |
|
|
462 | SvUTF8_on (sv); |
|
|
463 | return sv; |
|
|
464 | } |
444 | |
465 | |
445 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } |
466 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } |
446 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
467 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
447 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
468 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
448 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
469 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
… | |
… | |
464 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
485 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
465 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
486 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
466 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
487 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
467 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
488 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
468 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
489 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
|
|
490 | inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *)SvPTR_ornull (sv, "cf::mapspace"); } |
469 | inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); } |
491 | inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); } |
470 | inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); } |
492 | inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); } |
471 | |
493 | |
472 | //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)]; } |
473 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
495 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
944 | CALL_CALL ("ext::books::make_book", G_VOID); |
966 | CALL_CALL ("ext::books::make_book", G_VOID); |
945 | CALL_END; |
967 | CALL_END; |
946 | } |
968 | } |
947 | |
969 | |
948 | void |
970 | void |
949 | cfperl_expand_cfpod (player *pl, std::string &msg) |
|
|
950 | { |
|
|
951 | CALL_BEGIN (2); |
|
|
952 | CALL_ARG (pl); |
|
|
953 | CALL_ARG_SV (newSVpvn_utf8 (msg.data (), msg.size ())); |
|
|
954 | CALL_CALL ("cf::player::expand_cfpod", G_SCALAR); |
|
|
955 | |
|
|
956 | if (count) |
|
|
957 | { |
|
|
958 | STRLEN len; |
|
|
959 | char *data = SvPVutf8 (TOPs, len); |
|
|
960 | msg.assign (data, len); |
|
|
961 | } |
|
|
962 | |
|
|
963 | CALL_END; |
|
|
964 | } |
|
|
965 | |
|
|
966 | void |
|
|
967 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
971 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
968 | { |
972 | { |
969 | CALL_BEGIN (4); |
973 | CALL_BEGIN (4); |
970 | CALL_ARG (ns); |
974 | CALL_ARG (ns); |
971 | CALL_ARG (type); |
975 | CALL_ARG (type); |
… | |
… | |
1192 | |
1196 | |
1193 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1197 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1194 | 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); |
1195 | stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1); |
1199 | stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1); |
1196 | 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); |
1197 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1202 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1198 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1203 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1199 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1204 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1200 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1205 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1201 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1206 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
… | |
… | |
1321 | 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) |
1322 | 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) |
1323 | 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) |
1324 | 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) |
1325 | 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) |
1326 | 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) |
1327 | 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) |
1328 | 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) |
1329 | 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) |
1330 | 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) |
1331 | |
1336 | |
1332 | 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) |
1333 | 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) |
1334 | 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) |
1335 | 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) |
1336 | 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) |
1337 | const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) |
1342 | const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) const_iv (NDI_VERBATIM) |
1338 | |
1343 | |
1339 | 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) |
1340 | 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) |
1341 | |
1346 | |
1342 | 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) |
… | |
… | |
1394 | 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) |
1395 | const_iv (F_LOCKED) |
1400 | const_iv (F_LOCKED) |
1396 | |
1401 | |
1397 | 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) |
1398 | |
1403 | |
1399 | 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) |
1400 | 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) |
1401 | |
1406 | |
1402 | 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) |
1403 | |
1408 | |
1404 | 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) |
… | |
… | |
1501 | av_push (event, newSViv (eiv->klass)); |
1506 | av_push (event, newSViv (eiv->klass)); |
1502 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1507 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1503 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1508 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1504 | } |
1509 | } |
1505 | } |
1510 | } |
|
|
1511 | |
|
|
1512 | void _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 | |
1506 | |
1526 | |
1507 | void _connect_to_perl () |
1527 | void _connect_to_perl () |
1508 | |
1528 | |
1509 | void _recalc_want () |
1529 | void _recalc_want () |
1510 | |
1530 | |
… | |
… | |
1705 | #if _POSIX_MEMLOCK |
1725 | #if _POSIX_MEMLOCK |
1706 | |
1726 | |
1707 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1727 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1708 | INIT: |
1728 | INIT: |
1709 | #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 |
1710 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1733 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1711 | #endif |
1734 | #endif |
1712 | |
1735 | |
1713 | int munlockall () |
1736 | int munlockall () |
1714 | |
1737 | |
… | |
… | |
2103 | void rangevector (object *ob, object *other, int flags = 0) |
2126 | void rangevector (object *ob, object *other, int flags = 0) |
2104 | PROTOTYPE: $$;$ |
2127 | PROTOTYPE: $$;$ |
2105 | PPCODE: |
2128 | PPCODE: |
2106 | { |
2129 | { |
2107 | rv_vector rv; |
2130 | rv_vector rv; |
|
|
2131 | |
|
|
2132 | PUTBACK; |
2108 | get_rangevector (ob, other, &rv, flags); |
2133 | get_rangevector (ob, other, &rv, flags); |
|
|
2134 | SPAGAIN; |
|
|
2135 | |
2109 | EXTEND (SP, 5); |
2136 | EXTEND (SP, 5); |
2110 | PUSHs (newSVuv (rv.distance)); |
2137 | PUSHs (newSVuv (rv.distance)); |
2111 | PUSHs (newSViv (rv.distance_x)); |
2138 | PUSHs (newSViv (rv.distance_x)); |
2112 | PUSHs (newSViv (rv.distance_y)); |
2139 | PUSHs (newSViv (rv.distance_y)); |
2113 | PUSHs (newSViv (rv.direction)); |
2140 | PUSHs (newSViv (rv.direction)); |
… | |
… | |
2204 | if (len > MAXSOCKBUF) |
2231 | if (len > MAXSOCKBUF) |
2205 | pl->failmsg ("[packet too long for client]"); |
2232 | pl->failmsg ("[packet too long for client]"); |
2206 | else if (pl->ns) |
2233 | else if (pl->ns) |
2207 | pl->ns->send_packet (buf, len); |
2234 | pl->ns->send_packet (buf, len); |
2208 | } |
2235 | } |
2209 | |
|
|
2210 | int |
|
|
2211 | listening (player *pl, int new_value = -1) |
|
|
2212 | CODE: |
|
|
2213 | RETVAL = pl->listening; |
|
|
2214 | if (new_value >= 0) |
|
|
2215 | pl->listening = new_value; |
|
|
2216 | OUTPUT: |
|
|
2217 | RETVAL |
|
|
2218 | |
2236 | |
2219 | void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) |
2237 | void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) |
2220 | PROTOTYPE: $;$$$ |
2238 | PROTOTYPE: $;$$$ |
2221 | PPCODE: |
2239 | PPCODE: |
2222 | if (GIMME_V != G_VOID) |
2240 | if (GIMME_V != G_VOID) |
… | |
… | |
2377 | } |
2395 | } |
2378 | |
2396 | |
2379 | void |
2397 | void |
2380 | maptile::create_region_treasure () |
2398 | maptile::create_region_treasure () |
2381 | CODE: |
2399 | CODE: |
2382 | { |
|
|
2383 | object *op = object::create (); |
|
|
2384 | op->type = FLOOR; |
|
|
2385 | op->map = THIS; |
|
|
2386 | |
|
|
2387 | for (int x = 0; x < THIS->width; ++x) |
2400 | for (int x = 0; x < THIS->width; ++x) |
2388 | for (int y = 0; y < THIS->height; ++y) |
2401 | for (int y = 0; y < THIS->height; ++y) |
2389 | { |
2402 | { |
2390 | region *rgn = THIS->region (x, y); |
2403 | region *rgn = THIS->region (x, y); |
2391 | |
2404 | |
2392 | //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) |
2393 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2407 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2394 | { |
|
|
2395 | op->x = x; |
|
|
2396 | op->y = y; |
|
|
2397 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2408 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2398 | } |
|
|
2399 | } |
2409 | } |
2400 | |
|
|
2401 | op->destroy (); |
|
|
2402 | } |
|
|
2403 | |
2410 | |
2404 | int out_of_map (maptile *map, int x, int y) |
2411 | int out_of_map (maptile *map, int x, int y) |
2405 | |
2412 | |
2406 | void |
2413 | void |
2407 | trigger (maptile *map, long connection, bool state = true) |
2414 | trigger (maptile *map, long connection, bool state = true) |
… | |
… | |
2420 | get_map_flags (maptile *map, int x, int y) |
2427 | get_map_flags (maptile *map, int x, int y) |
2421 | PPCODE: |
2428 | PPCODE: |
2422 | { |
2429 | { |
2423 | maptile *nmap = 0; |
2430 | maptile *nmap = 0; |
2424 | I16 nx = 0, ny = 0; |
2431 | I16 nx = 0, ny = 0; |
|
|
2432 | |
|
|
2433 | PUTBACK; |
2425 | 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; |
2426 | |
2436 | |
2427 | EXTEND (SP, 4); |
2437 | EXTEND (SP, 4); |
2428 | PUSHs (sv_2mortal (newSViv (flags))); |
2438 | PUSHs (sv_2mortal (newSViv (flags))); |
2429 | |
2439 | |
2430 | if (GIMME_V == G_ARRAY) |
2440 | if (GIMME_V == G_ARRAY) |
… | |
… | |
2433 | PUSHs (sv_2mortal (newSViv (nx))); |
2443 | PUSHs (sv_2mortal (newSViv (nx))); |
2434 | PUSHs (sv_2mortal (newSViv (ny))); |
2444 | PUSHs (sv_2mortal (newSViv (ny))); |
2435 | } |
2445 | } |
2436 | } |
2446 | } |
2437 | |
2447 | |
|
|
2448 | mapspace * |
|
|
2449 | ms (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 | |
2438 | void |
2468 | void |
2439 | at (maptile *map, unsigned int x, unsigned int y) |
2469 | at (maptile *map, unsigned int x, unsigned int y) |
2440 | PROTOTYPE: $$$ |
2470 | PROTOTYPE: $$$ |
2441 | PPCODE: |
2471 | PPCODE: |
2442 | { |
2472 | { |
2443 | object *o; |
|
|
2444 | maptile *nmap = 0; |
2473 | maptile *nmap = 0; |
2445 | I16 nx, ny; |
2474 | I16 nx, ny; |
2446 | |
2475 | |
|
|
2476 | PUTBACK; |
2447 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2477 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2478 | SPAGAIN; |
2448 | |
2479 | |
2449 | if (nmap) |
2480 | if (nmap) |
2450 | 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) |
2451 | XPUSHs (sv_2mortal (to_sv (o))); |
2482 | XPUSHs (sv_2mortal (to_sv (o))); |
2452 | } |
2483 | } |
2453 | |
2484 | |
2454 | SV * |
2485 | SV * |
2455 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2486 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
… | |
… | |
2568 | RETVAL = self->generate_random_map (&rmp); |
2599 | RETVAL = self->generate_random_map (&rmp); |
2569 | } |
2600 | } |
2570 | OUTPUT: |
2601 | OUTPUT: |
2571 | RETVAL |
2602 | RETVAL |
2572 | |
2603 | |
|
|
2604 | MODULE = cf PACKAGE = cf::mapspace |
|
|
2605 | |
|
|
2606 | INCLUDE: $PERL $srcdir/genacc mapspace ../include/map.h | |
|
|
2607 | |
2573 | MODULE = cf PACKAGE = cf::arch |
2608 | MODULE = cf PACKAGE = cf::arch |
2574 | |
2609 | |
2575 | int archetypes_size () |
2610 | int archetypes_size () |
2576 | CODE: |
2611 | CODE: |
2577 | RETVAL = archetypes.size (); |
2612 | RETVAL = archetypes.size (); |