… | |
… | |
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 ()); } |
… | |
… | |
464 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
464 | 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"); } |
465 | 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"); } |
466 | 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"); } |
467 | 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"); } |
468 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
|
|
469 | 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"); } |
470 | 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" ); } |
471 | inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); } |
471 | |
472 | |
472 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
473 | //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)); } |
474 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
944 | CALL_CALL ("ext::books::make_book", G_VOID); |
945 | CALL_CALL ("ext::books::make_book", G_VOID); |
945 | CALL_END; |
946 | CALL_END; |
946 | } |
947 | } |
947 | |
948 | |
948 | void |
949 | void |
|
|
950 | cfperl_expand_cfpod (player *pl, std::string &msg) |
|
|
951 | { |
|
|
952 | CALL_BEGIN (2); |
|
|
953 | CALL_ARG (pl); |
|
|
954 | CALL_ARG_SV (newSVpvn_utf8 (msg.data (), msg.size ())); |
|
|
955 | CALL_CALL ("cf::player::expand_cfpod", G_SCALAR); |
|
|
956 | |
|
|
957 | if (count) |
|
|
958 | { |
|
|
959 | STRLEN len; |
|
|
960 | char *data = SvPVutf8 (TOPs, len); |
|
|
961 | msg.assign (data, len); |
|
|
962 | } |
|
|
963 | |
|
|
964 | CALL_END; |
|
|
965 | } |
|
|
966 | |
|
|
967 | void |
949 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
968 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
950 | { |
969 | { |
951 | CALL_BEGIN (4); |
970 | CALL_BEGIN (4); |
952 | CALL_ARG (ns); |
971 | CALL_ARG (ns); |
953 | CALL_ARG (type); |
972 | CALL_ARG (type); |
… | |
… | |
977 | { |
996 | { |
978 | CALL_BEGIN (1); |
997 | CALL_BEGIN (1); |
979 | CALL_ARG (name); |
998 | CALL_ARG (name); |
980 | CALL_CALL ("cf::player::find", G_SCALAR); |
999 | CALL_CALL ("cf::player::find", G_SCALAR); |
981 | |
1000 | |
982 | player *retval; |
1001 | player *retval = 0; |
983 | |
|
|
984 | if (count) |
|
|
985 | sv_to (POPs, retval); |
1002 | if (count) sv_to (POPs, retval); |
986 | else |
1003 | |
987 | retval = 0; |
1004 | CALL_END; |
|
|
1005 | |
|
|
1006 | return retval; |
|
|
1007 | } |
|
|
1008 | |
|
|
1009 | maptile * |
|
|
1010 | find_style (const char *dirname, const char *stylename, int difficulty) |
|
|
1011 | { |
|
|
1012 | CALL_BEGIN (3); |
|
|
1013 | CALL_ARG (dirname); |
|
|
1014 | CALL_ARG (stylename); |
|
|
1015 | CALL_ARG (difficulty); |
|
|
1016 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
|
|
1017 | |
|
|
1018 | maptile *retval = 0; |
|
|
1019 | if (count) sv_to (POPs, retval); |
988 | |
1020 | |
989 | CALL_END; |
1021 | CALL_END; |
990 | |
1022 | |
991 | return retval; |
1023 | return retval; |
992 | } |
1024 | } |
… | |
… | |
997 | CALL_BEGIN (2); |
1029 | CALL_BEGIN (2); |
998 | CALL_ARG (path); |
1030 | CALL_ARG (path); |
999 | CALL_ARG (origin); |
1031 | CALL_ARG (origin); |
1000 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
1032 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
1001 | |
1033 | |
1002 | maptile *retval; |
1034 | maptile *retval = 0; |
1003 | |
|
|
1004 | if (count) |
|
|
1005 | sv_to (POPs, retval); |
1035 | if (count) sv_to (POPs, retval); |
1006 | else |
|
|
1007 | retval = 0; |
|
|
1008 | |
1036 | |
1009 | CALL_END; |
1037 | CALL_END; |
1010 | |
1038 | |
1011 | return retval; |
1039 | return retval; |
1012 | } |
1040 | } |
… | |
… | |
1018 | CALL_ARG (path); |
1046 | CALL_ARG (path); |
1019 | CALL_ARG (origin); |
1047 | CALL_ARG (origin); |
1020 | CALL_ARG (load); |
1048 | CALL_ARG (load); |
1021 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1049 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1022 | |
1050 | |
1023 | maptile *retval; |
1051 | maptile *retval = 0; |
1024 | |
|
|
1025 | if (count) |
|
|
1026 | sv_to (POPs, retval); |
1052 | if (count) sv_to (POPs, retval); |
1027 | else |
|
|
1028 | retval = 0; |
|
|
1029 | |
1053 | |
1030 | CALL_END; |
1054 | CALL_END; |
1031 | |
1055 | |
1032 | return retval; |
1056 | return retval; |
1033 | } |
1057 | } |
… | |
… | |
1058 | |
1082 | |
1059 | CALL_BEGIN (2); |
1083 | CALL_BEGIN (2); |
1060 | CALL_ARG (this); |
1084 | CALL_ARG (this); |
1061 | CALL_ARG (exit); |
1085 | CALL_ARG (exit); |
1062 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
1086 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
|
|
1087 | CALL_END; |
|
|
1088 | } |
|
|
1089 | |
|
|
1090 | void |
|
|
1091 | object::player_goto (const char *path, int x, int y) |
|
|
1092 | { |
|
|
1093 | if (type != PLAYER) |
|
|
1094 | return; |
|
|
1095 | |
|
|
1096 | CALL_BEGIN (4); |
|
|
1097 | CALL_ARG (this); |
|
|
1098 | CALL_ARG (path); |
|
|
1099 | CALL_ARG (x); |
|
|
1100 | CALL_ARG (y); |
|
|
1101 | CALL_CALL ("cf::object::player::goto", G_VOID); |
1063 | CALL_END; |
1102 | CALL_END; |
1064 | } |
1103 | } |
1065 | |
1104 | |
1066 | const char * |
1105 | const char * |
1067 | object::ref () const |
1106 | object::ref () const |
… | |
… | |
1154 | |
1193 | |
1155 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1194 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1156 | stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); |
1195 | stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); |
1157 | stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1); |
1196 | stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1); |
1158 | stash_cf_map_wrap = gv_stashpv ("cf::map::wrap" , 1); |
1197 | stash_cf_map_wrap = gv_stashpv ("cf::map::wrap" , 1); |
|
|
1198 | stash_cf_mapspace_wrap = gv_stashpv ("cf::mapspace::wrap" , 1); |
1159 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1199 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1160 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1200 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1161 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1201 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1162 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1202 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1163 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1203 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
… | |
… | |
1356 | const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK) |
1396 | const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK) |
1357 | const_iv (F_LOCKED) |
1397 | const_iv (F_LOCKED) |
1358 | |
1398 | |
1359 | const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL) |
1399 | const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL) |
1360 | |
1400 | |
1361 | const_iv (P_BLOCKSVIEW) const_iv (P_PLAYER) const_iv (P_NO_MAGIC) const_iv (P_IS_ALIVE) |
1401 | const_iv (P_BLOCKSVIEW) const_iv (P_NO_MAGIC) const_iv (P_IS_ALIVE) |
1362 | const_iv (P_NO_CLERIC) const_iv (P_OUT_OF_MAP) const_iv (P_NEW_MAP) const_iv (P_UPTODATE) |
1402 | const_iv (P_NO_CLERIC) const_iv (P_OUT_OF_MAP) const_iv (P_NEW_MAP) const_iv (P_UPTODATE) |
1363 | |
1403 | |
1364 | const_iv (UP_OBJ_INSERT) const_iv (UP_OBJ_REMOVE) const_iv (UP_OBJ_CHANGE) const_iv (UP_OBJ_FACE) |
1404 | const_iv (UP_OBJ_INSERT) const_iv (UP_OBJ_REMOVE) const_iv (UP_OBJ_CHANGE) const_iv (UP_OBJ_FACE) |
1365 | |
1405 | |
1366 | const_iv (INS_NO_MERGE) const_iv (INS_ABOVE_FLOOR_ONLY) const_iv (INS_NO_WALK_ON) |
1406 | const_iv (INS_NO_MERGE) const_iv (INS_ABOVE_FLOOR_ONLY) const_iv (INS_NO_WALK_ON) |
… | |
… | |
1464 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1504 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1465 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1505 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1466 | } |
1506 | } |
1467 | } |
1507 | } |
1468 | |
1508 | |
|
|
1509 | void _gv_clear (SV *gv) |
|
|
1510 | CODE: |
|
|
1511 | assert (SvTYPE (gv) == SVt_PVGV); |
|
|
1512 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
|
|
1513 | f (GvGP (gv)->gp_form); |
|
|
1514 | f (GvGP (gv)->gp_io); |
|
|
1515 | f (GvGP (gv)->gp_sv); |
|
|
1516 | f (GvGP (gv)->gp_av); |
|
|
1517 | f (GvGP (gv)->gp_hv); |
|
|
1518 | f (GvGP (gv)->gp_cv); |
|
|
1519 | GvCVGEN (gv) = 0; |
|
|
1520 | GvMULTI_off (gv); |
|
|
1521 | # undef f |
|
|
1522 | |
|
|
1523 | |
1469 | void _connect_to_perl () |
1524 | void _connect_to_perl () |
1470 | |
1525 | |
1471 | void _recalc_want () |
1526 | void _recalc_want () |
1472 | |
1527 | |
1473 | void _global_reattach () |
1528 | void _global_reattach () |
… | |
… | |
1573 | NV floor (NV x) |
1628 | NV floor (NV x) |
1574 | |
1629 | |
1575 | NV ceil (NV x) |
1630 | NV ceil (NV x) |
1576 | |
1631 | |
1577 | NV rndm (...) |
1632 | NV rndm (...) |
|
|
1633 | ALIAS: |
|
|
1634 | rmg_rndm = 1 |
1578 | CODE: |
1635 | CODE: |
|
|
1636 | { |
|
|
1637 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1579 | switch (items) |
1638 | switch (items) |
1580 | { |
1639 | { |
1581 | case 0: RETVAL = rndm (); break; |
1640 | case 0: RETVAL = gen (); break; |
1582 | case 1: RETVAL = rndm (SvUV (ST (0))); break; |
1641 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1583 | case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break; |
1642 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1584 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1643 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1585 | } |
1644 | } |
|
|
1645 | } |
1586 | OUTPUT: |
1646 | OUTPUT: |
1587 | RETVAL |
1647 | RETVAL |
1588 | |
1648 | |
1589 | NV clamp (NV value, NV min_value, NV max_value) |
1649 | NV clamp (NV value, NV min_value, NV max_value) |
1590 | CODE: |
1650 | CODE: |
… | |
… | |
1787 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1847 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1788 | |
1848 | |
1789 | bool |
1849 | bool |
1790 | load_resource_file_ (octet_string filename) |
1850 | load_resource_file_ (octet_string filename) |
1791 | |
1851 | |
|
|
1852 | void |
|
|
1853 | fix_weight () |
|
|
1854 | |
1792 | MODULE = cf PACKAGE = cf::attachable |
1855 | MODULE = cf PACKAGE = cf::attachable |
1793 | |
1856 | |
1794 | int |
1857 | int |
1795 | valid (SV *obj) |
1858 | valid (SV *obj) |
1796 | CODE: |
1859 | CODE: |
… | |
… | |
2057 | void rangevector (object *ob, object *other, int flags = 0) |
2120 | void rangevector (object *ob, object *other, int flags = 0) |
2058 | PROTOTYPE: $$;$ |
2121 | PROTOTYPE: $$;$ |
2059 | PPCODE: |
2122 | PPCODE: |
2060 | { |
2123 | { |
2061 | rv_vector rv; |
2124 | rv_vector rv; |
|
|
2125 | |
|
|
2126 | PUTBACK; |
2062 | get_rangevector (ob, other, &rv, flags); |
2127 | get_rangevector (ob, other, &rv, flags); |
|
|
2128 | SPAGAIN; |
|
|
2129 | |
2063 | EXTEND (SP, 5); |
2130 | EXTEND (SP, 5); |
2064 | PUSHs (newSVuv (rv.distance)); |
2131 | PUSHs (newSVuv (rv.distance)); |
2065 | PUSHs (newSViv (rv.distance_x)); |
2132 | PUSHs (newSViv (rv.distance_x)); |
2066 | PUSHs (newSViv (rv.distance_y)); |
2133 | PUSHs (newSViv (rv.distance_y)); |
2067 | PUSHs (newSViv (rv.direction)); |
2134 | PUSHs (newSViv (rv.direction)); |
… | |
… | |
2158 | if (len > MAXSOCKBUF) |
2225 | if (len > MAXSOCKBUF) |
2159 | pl->failmsg ("[packet too long for client]"); |
2226 | pl->failmsg ("[packet too long for client]"); |
2160 | else if (pl->ns) |
2227 | else if (pl->ns) |
2161 | pl->ns->send_packet (buf, len); |
2228 | pl->ns->send_packet (buf, len); |
2162 | } |
2229 | } |
2163 | |
|
|
2164 | int |
|
|
2165 | listening (player *pl, int new_value = -1) |
|
|
2166 | CODE: |
|
|
2167 | RETVAL = pl->listening; |
|
|
2168 | if (new_value >= 0) |
|
|
2169 | pl->listening = new_value; |
|
|
2170 | OUTPUT: |
|
|
2171 | RETVAL |
|
|
2172 | |
2230 | |
2173 | void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) |
2231 | void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) |
2174 | PROTOTYPE: $;$$$ |
2232 | PROTOTYPE: $;$$$ |
2175 | PPCODE: |
2233 | PPCODE: |
2176 | if (GIMME_V != G_VOID) |
2234 | if (GIMME_V != G_VOID) |
… | |
… | |
2374 | get_map_flags (maptile *map, int x, int y) |
2432 | get_map_flags (maptile *map, int x, int y) |
2375 | PPCODE: |
2433 | PPCODE: |
2376 | { |
2434 | { |
2377 | maptile *nmap = 0; |
2435 | maptile *nmap = 0; |
2378 | I16 nx = 0, ny = 0; |
2436 | I16 nx = 0, ny = 0; |
|
|
2437 | |
|
|
2438 | PUTBACK; |
2379 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2439 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2440 | SPAGAIN; |
2380 | |
2441 | |
2381 | EXTEND (SP, 4); |
2442 | EXTEND (SP, 4); |
2382 | PUSHs (sv_2mortal (newSViv (flags))); |
2443 | PUSHs (sv_2mortal (newSViv (flags))); |
2383 | |
2444 | |
2384 | if (GIMME_V == G_ARRAY) |
2445 | if (GIMME_V == G_ARRAY) |
… | |
… | |
2387 | PUSHs (sv_2mortal (newSViv (nx))); |
2448 | PUSHs (sv_2mortal (newSViv (nx))); |
2388 | PUSHs (sv_2mortal (newSViv (ny))); |
2449 | PUSHs (sv_2mortal (newSViv (ny))); |
2389 | } |
2450 | } |
2390 | } |
2451 | } |
2391 | |
2452 | |
|
|
2453 | mapspace * |
|
|
2454 | ms (maptile *map, unsigned int x, unsigned int y) |
|
|
2455 | PROTOTYPE: $$$ |
|
|
2456 | CODE: |
|
|
2457 | { |
|
|
2458 | maptile *nmap = 0; |
|
|
2459 | I16 nx, ny; |
|
|
2460 | |
|
|
2461 | PUTBACK; |
|
|
2462 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2463 | SPAGAIN; |
|
|
2464 | |
|
|
2465 | if (!nmap) |
|
|
2466 | XSRETURN_UNDEF; |
|
|
2467 | |
|
|
2468 | RETVAL = &nmap->at (nx, ny); |
|
|
2469 | } |
|
|
2470 | OUTPUT: |
|
|
2471 | RETVAL |
|
|
2472 | |
2392 | void |
2473 | void |
2393 | at (maptile *map, unsigned int x, unsigned int y) |
2474 | at (maptile *map, unsigned int x, unsigned int y) |
2394 | PROTOTYPE: $$$ |
2475 | PROTOTYPE: $$$ |
2395 | PPCODE: |
2476 | PPCODE: |
2396 | { |
2477 | { |
2397 | object *o; |
|
|
2398 | maptile *nmap = 0; |
2478 | maptile *nmap = 0; |
2399 | I16 nx, ny; |
2479 | I16 nx, ny; |
2400 | |
2480 | |
|
|
2481 | PUTBACK; |
2401 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2482 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2483 | SPAGAIN; |
2402 | |
2484 | |
2403 | if (nmap) |
2485 | if (nmap) |
2404 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2486 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2405 | XPUSHs (sv_2mortal (to_sv (o))); |
2487 | XPUSHs (sv_2mortal (to_sv (o))); |
2406 | } |
2488 | } |
2407 | |
2489 | |
2408 | SV * |
2490 | SV * |
2409 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2491 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
… | |
… | |
2522 | RETVAL = self->generate_random_map (&rmp); |
2604 | RETVAL = self->generate_random_map (&rmp); |
2523 | } |
2605 | } |
2524 | OUTPUT: |
2606 | OUTPUT: |
2525 | RETVAL |
2607 | RETVAL |
2526 | |
2608 | |
|
|
2609 | MODULE = cf PACKAGE = cf::mapspace |
|
|
2610 | |
|
|
2611 | INCLUDE: $PERL $srcdir/genacc mapspace ../include/map.h | |
|
|
2612 | |
2527 | MODULE = cf PACKAGE = cf::arch |
2613 | MODULE = cf PACKAGE = cf::arch |
2528 | |
2614 | |
2529 | int archetypes_size () |
2615 | int archetypes_size () |
2530 | CODE: |
2616 | CODE: |
2531 | RETVAL = archetypes.size (); |
2617 | RETVAL = archetypes.size (); |