… | |
… | |
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" |
… | |
… | |
43 | # include <sys/mman.h> |
41 | # include <sys/mman.h> |
44 | #endif |
42 | #endif |
45 | |
43 | |
46 | #if HAVE_MALLOC_H |
44 | #if HAVE_MALLOC_H |
47 | # include <malloc.h> |
45 | # include <malloc.h> |
|
|
46 | #endif |
|
|
47 | |
|
|
48 | #if !__GLIBC__ |
|
|
49 | # define malloc_trim(pad) -1 |
48 | #endif |
50 | #endif |
49 | |
51 | |
50 | #include <EXTERN.h> |
52 | #include <EXTERN.h> |
51 | #include <perl.h> |
53 | #include <perl.h> |
52 | #include <XSUB.h> |
54 | #include <XSUB.h> |
… | |
… | |
940 | CALL_CALL ("ext::books::make_book", G_VOID); |
942 | CALL_CALL ("ext::books::make_book", G_VOID); |
941 | CALL_END; |
943 | CALL_END; |
942 | } |
944 | } |
943 | |
945 | |
944 | void |
946 | void |
|
|
947 | cfperl_expand_cfpod (player *pl, std::string &msg) |
|
|
948 | { |
|
|
949 | CALL_BEGIN (2); |
|
|
950 | CALL_ARG (pl); |
|
|
951 | CALL_ARG_SV (newSVpvn_utf8 (msg.data (), msg.size ())); |
|
|
952 | CALL_CALL ("cf::player::expand_cfpod", G_SCALAR); |
|
|
953 | |
|
|
954 | if (count) |
|
|
955 | { |
|
|
956 | STRLEN len; |
|
|
957 | char *data = SvPVutf8 (TOPs, len); |
|
|
958 | msg.assign (data, len); |
|
|
959 | } |
|
|
960 | |
|
|
961 | CALL_END; |
|
|
962 | } |
|
|
963 | |
|
|
964 | void |
945 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
965 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
946 | { |
966 | { |
947 | CALL_BEGIN (4); |
967 | CALL_BEGIN (4); |
948 | CALL_ARG (ns); |
968 | CALL_ARG (ns); |
949 | CALL_ARG (type); |
969 | CALL_ARG (type); |
… | |
… | |
973 | { |
993 | { |
974 | CALL_BEGIN (1); |
994 | CALL_BEGIN (1); |
975 | CALL_ARG (name); |
995 | CALL_ARG (name); |
976 | CALL_CALL ("cf::player::find", G_SCALAR); |
996 | CALL_CALL ("cf::player::find", G_SCALAR); |
977 | |
997 | |
978 | player *retval; |
998 | player *retval = 0; |
979 | |
|
|
980 | if (count) |
|
|
981 | sv_to (POPs, retval); |
999 | if (count) sv_to (POPs, retval); |
982 | else |
1000 | |
983 | retval = 0; |
1001 | CALL_END; |
|
|
1002 | |
|
|
1003 | return retval; |
|
|
1004 | } |
|
|
1005 | |
|
|
1006 | maptile * |
|
|
1007 | find_style (const char *dirname, const char *stylename, int difficulty) |
|
|
1008 | { |
|
|
1009 | CALL_BEGIN (3); |
|
|
1010 | CALL_ARG (dirname); |
|
|
1011 | CALL_ARG (stylename); |
|
|
1012 | CALL_ARG (difficulty); |
|
|
1013 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
|
|
1014 | |
|
|
1015 | maptile *retval = 0; |
|
|
1016 | if (count) sv_to (POPs, retval); |
984 | |
1017 | |
985 | CALL_END; |
1018 | CALL_END; |
986 | |
1019 | |
987 | return retval; |
1020 | return retval; |
988 | } |
1021 | } |
… | |
… | |
993 | CALL_BEGIN (2); |
1026 | CALL_BEGIN (2); |
994 | CALL_ARG (path); |
1027 | CALL_ARG (path); |
995 | CALL_ARG (origin); |
1028 | CALL_ARG (origin); |
996 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
1029 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
997 | |
1030 | |
998 | maptile *retval; |
1031 | maptile *retval = 0; |
999 | |
|
|
1000 | if (count) |
|
|
1001 | sv_to (POPs, retval); |
1032 | if (count) sv_to (POPs, retval); |
1002 | else |
|
|
1003 | retval = 0; |
|
|
1004 | |
1033 | |
1005 | CALL_END; |
1034 | CALL_END; |
1006 | |
1035 | |
1007 | return retval; |
1036 | return retval; |
1008 | } |
1037 | } |
… | |
… | |
1014 | CALL_ARG (path); |
1043 | CALL_ARG (path); |
1015 | CALL_ARG (origin); |
1044 | CALL_ARG (origin); |
1016 | CALL_ARG (load); |
1045 | CALL_ARG (load); |
1017 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1046 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1018 | |
1047 | |
1019 | maptile *retval; |
1048 | maptile *retval = 0; |
1020 | |
|
|
1021 | if (count) |
|
|
1022 | sv_to (POPs, retval); |
1049 | if (count) sv_to (POPs, retval); |
1023 | else |
|
|
1024 | retval = 0; |
|
|
1025 | |
1050 | |
1026 | CALL_END; |
1051 | CALL_END; |
1027 | |
1052 | |
1028 | return retval; |
1053 | return retval; |
1029 | } |
1054 | } |
… | |
… | |
1054 | |
1079 | |
1055 | CALL_BEGIN (2); |
1080 | CALL_BEGIN (2); |
1056 | CALL_ARG (this); |
1081 | CALL_ARG (this); |
1057 | CALL_ARG (exit); |
1082 | CALL_ARG (exit); |
1058 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
1083 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
|
|
1084 | CALL_END; |
|
|
1085 | } |
|
|
1086 | |
|
|
1087 | void |
|
|
1088 | object::player_goto (const char *path, int x, int y) |
|
|
1089 | { |
|
|
1090 | if (type != PLAYER) |
|
|
1091 | return; |
|
|
1092 | |
|
|
1093 | CALL_BEGIN (4); |
|
|
1094 | CALL_ARG (this); |
|
|
1095 | CALL_ARG (path); |
|
|
1096 | CALL_ARG (x); |
|
|
1097 | CALL_ARG (y); |
|
|
1098 | CALL_CALL ("cf::object::player::goto", G_VOID); |
1059 | CALL_END; |
1099 | CALL_END; |
1060 | } |
1100 | } |
1061 | |
1101 | |
1062 | const char * |
1102 | const char * |
1063 | object::ref () const |
1103 | object::ref () const |
… | |
… | |
1428 | |
1468 | |
1429 | const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) |
1469 | const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) |
1430 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1470 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1431 | |
1471 | |
1432 | const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) |
1472 | const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) |
1433 | const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV) |
1473 | const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_MINIMAL) |
1434 | const_iv (GT_MINIMAL) |
|
|
1435 | |
1474 | |
1436 | const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) |
1475 | const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) |
1437 | const_iv (FT_RSRC) const_iv (FT_NUM) |
1476 | const_iv (FT_RSRC) const_iv (FT_NUM) |
1438 | }; |
1477 | }; |
1439 | |
1478 | |
… | |
… | |
1570 | NV floor (NV x) |
1609 | NV floor (NV x) |
1571 | |
1610 | |
1572 | NV ceil (NV x) |
1611 | NV ceil (NV x) |
1573 | |
1612 | |
1574 | NV rndm (...) |
1613 | NV rndm (...) |
|
|
1614 | ALIAS: |
|
|
1615 | rmg_rndm = 1 |
1575 | CODE: |
1616 | CODE: |
|
|
1617 | { |
|
|
1618 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1576 | switch (items) |
1619 | switch (items) |
1577 | { |
1620 | { |
1578 | case 0: RETVAL = rndm (); break; |
1621 | case 0: RETVAL = gen (); break; |
1579 | case 1: RETVAL = rndm (SvUV (ST (0))); break; |
1622 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1580 | case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break; |
1623 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1581 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1624 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1582 | } |
1625 | } |
|
|
1626 | } |
1583 | OUTPUT: |
1627 | OUTPUT: |
1584 | RETVAL |
1628 | RETVAL |
1585 | |
1629 | |
1586 | NV clamp (NV value, NV min_value, NV max_value) |
1630 | NV clamp (NV value, NV min_value, NV max_value) |
1587 | CODE: |
1631 | CODE: |
… | |
… | |
1612 | octet_string path_combine (octet_string base, octet_string path) |
1656 | octet_string path_combine (octet_string base, octet_string path) |
1613 | PROTOTYPE: $$ |
1657 | PROTOTYPE: $$ |
1614 | |
1658 | |
1615 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1659 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1616 | PROTOTYPE: $$ |
1660 | PROTOTYPE: $$ |
1617 | |
|
|
1618 | void |
|
|
1619 | mallinfo () |
|
|
1620 | PPCODE: |
|
|
1621 | { |
|
|
1622 | #if __GLIBC__ |
|
|
1623 | struct mallinfo mai = mallinfo (); |
|
|
1624 | EXTEND (SP, 10*2); |
|
|
1625 | PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena))); |
|
|
1626 | PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks))); |
|
|
1627 | PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks))); |
|
|
1628 | PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks))); |
|
|
1629 | PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd))); |
|
|
1630 | PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks))); |
|
|
1631 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
|
|
1632 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
|
|
1633 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
|
|
1634 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
|
|
1635 | #endif |
|
|
1636 | EXTEND (SP, 2*2); |
|
|
1637 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
|
|
1638 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
|
|
1639 | } |
|
|
1640 | |
1661 | |
1641 | void |
1662 | void |
1642 | sub_generation_inc () |
1663 | sub_generation_inc () |
1643 | CODE: |
1664 | CODE: |
1644 | PL_sub_generation++; |
1665 | PL_sub_generation++; |
… | |
… | |
1681 | |
1702 | |
1682 | #if _POSIX_MEMLOCK |
1703 | #if _POSIX_MEMLOCK |
1683 | |
1704 | |
1684 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1705 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1685 | INIT: |
1706 | INIT: |
|
|
1707 | #if __GLIBC__ |
1686 | mallopt (M_PERTURB, 0xaa); // bug-workaround for linux glibc+mlockall+calloc |
1708 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
|
|
1709 | #endif |
1687 | |
1710 | |
1688 | int munlockall () |
1711 | int munlockall () |
1689 | |
1712 | |
1690 | #endif |
1713 | #endif |
|
|
1714 | |
|
|
1715 | int |
|
|
1716 | malloc_trim (IV pad = 0) |
|
|
1717 | |
|
|
1718 | void |
|
|
1719 | mallinfo () |
|
|
1720 | PPCODE: |
|
|
1721 | { |
|
|
1722 | #if __GLIBC__ |
|
|
1723 | struct mallinfo mai = mallinfo (); |
|
|
1724 | EXTEND (SP, 10*2); |
|
|
1725 | PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena))); |
|
|
1726 | PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks))); |
|
|
1727 | PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks))); |
|
|
1728 | PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks))); |
|
|
1729 | PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd))); |
|
|
1730 | PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks))); |
|
|
1731 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
|
|
1732 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
|
|
1733 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
|
|
1734 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
|
|
1735 | #endif |
|
|
1736 | EXTEND (SP, 2*2); |
|
|
1737 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
|
|
1738 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
|
|
1739 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
|
|
1740 | } |
1691 | |
1741 | |
1692 | int find_animation (utf8_string text) |
1742 | int find_animation (utf8_string text) |
1693 | PROTOTYPE: $ |
1743 | PROTOTYPE: $ |
1694 | |
1744 | |
1695 | int random_roll (int min, int max, object *op, int goodbad); |
1745 | int random_roll (int min, int max, object *op, int goodbad); |
… | |
… | |
1776 | EXTEND (SP, NUM_COINS); |
1826 | EXTEND (SP, NUM_COINS); |
1777 | for (int i = 0; i < NUM_COINS; ++i) |
1827 | for (int i = 0; i < NUM_COINS; ++i) |
1778 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1828 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1779 | |
1829 | |
1780 | bool |
1830 | bool |
1781 | load_resource_file (octet_string filename) |
1831 | load_resource_file_ (octet_string filename) |
|
|
1832 | |
|
|
1833 | void |
|
|
1834 | fix_weight () |
1782 | |
1835 | |
1783 | MODULE = cf PACKAGE = cf::attachable |
1836 | MODULE = cf PACKAGE = cf::attachable |
1784 | |
1837 | |
1785 | int |
1838 | int |
1786 | valid (SV *obj) |
1839 | valid (SV *obj) |
… | |
… | |
1850 | object *actives (U32 index) |
1903 | object *actives (U32 index) |
1851 | CODE: |
1904 | CODE: |
1852 | RETVAL = index < actives.size () ? actives [index] : 0; |
1905 | RETVAL = index < actives.size () ? actives [index] : 0; |
1853 | OUTPUT: RETVAL |
1906 | OUTPUT: RETVAL |
1854 | |
1907 | |
|
|
1908 | int mortals_size () |
|
|
1909 | CODE: |
|
|
1910 | RETVAL = attachable::mortals.size (); |
|
|
1911 | OUTPUT: RETVAL |
|
|
1912 | |
1855 | const char *slot_use_name (U32 slot) |
1913 | const char *slot_use_name (U32 slot) |
1856 | ALIAS: |
1914 | ALIAS: |
1857 | slot_nonuse_name = 1 |
1915 | slot_nonuse_name = 1 |
1858 | CODE: |
1916 | CODE: |
1859 | { |
1917 | { |
… | |
… | |
1937 | void apply_below (object *op) |
1995 | void apply_below (object *op) |
1938 | CODE: |
1996 | CODE: |
1939 | player_apply_below (op); |
1997 | player_apply_below (op); |
1940 | |
1998 | |
1941 | int cast_heal (object *op, object *caster, object *spell, int dir = 0) |
1999 | int cast_heal (object *op, object *caster, object *spell, int dir = 0) |
1942 | |
|
|
1943 | #//TODO |
|
|
1944 | object *clone_ (object *op, int recursive = 0) |
|
|
1945 | CODE: |
|
|
1946 | if (recursive) |
|
|
1947 | RETVAL = object_create_clone (op); |
|
|
1948 | else |
|
|
1949 | { |
|
|
1950 | RETVAL = object::create (); |
|
|
1951 | op->copy_to (RETVAL); |
|
|
1952 | } |
|
|
1953 | OUTPUT: RETVAL |
|
|
1954 | |
2000 | |
1955 | int pay_item (object *op, object *buyer) |
2001 | int pay_item (object *op, object *buyer) |
1956 | CODE: |
2002 | CODE: |
1957 | RETVAL = pay_for_item (op, buyer); |
2003 | RETVAL = pay_for_item (op, buyer); |
1958 | OUTPUT: RETVAL |
2004 | OUTPUT: RETVAL |
… | |
… | |
2036 | CODE: |
2082 | CODE: |
2037 | { |
2083 | { |
2038 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2084 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2039 | } |
2085 | } |
2040 | |
2086 | |
2041 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
2087 | shstr |
|
|
2088 | object::kv_get (shstr key) |
2042 | |
2089 | |
2043 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
2090 | void |
|
|
2091 | object::kv_del (shstr key) |
|
|
2092 | |
|
|
2093 | void |
|
|
2094 | object::kv_set (shstr key, shstr value) |
2044 | |
2095 | |
2045 | object *get_nearest_player (object *ob) |
2096 | object *get_nearest_player (object *ob) |
2046 | ALIAS: nearest_player = 0 |
2097 | ALIAS: nearest_player = 0 |
2047 | PREINIT: |
2098 | PREINIT: |
2048 | extern object *get_nearest_player (object *); |
2099 | extern object *get_nearest_player (object *); |
… | |
… | |
2050 | void rangevector (object *ob, object *other, int flags = 0) |
2101 | void rangevector (object *ob, object *other, int flags = 0) |
2051 | PROTOTYPE: $$;$ |
2102 | PROTOTYPE: $$;$ |
2052 | PPCODE: |
2103 | PPCODE: |
2053 | { |
2104 | { |
2054 | rv_vector rv; |
2105 | rv_vector rv; |
|
|
2106 | |
|
|
2107 | PUTBACK; |
2055 | get_rangevector (ob, other, &rv, flags); |
2108 | get_rangevector (ob, other, &rv, flags); |
|
|
2109 | SPAGAIN; |
|
|
2110 | |
2056 | EXTEND (SP, 5); |
2111 | EXTEND (SP, 5); |
2057 | PUSHs (newSVuv (rv.distance)); |
2112 | PUSHs (newSVuv (rv.distance)); |
2058 | PUSHs (newSViv (rv.distance_x)); |
2113 | PUSHs (newSViv (rv.distance_x)); |
2059 | PUSHs (newSViv (rv.distance_y)); |
2114 | PUSHs (newSViv (rv.distance_y)); |
2060 | PUSHs (newSViv (rv.direction)); |
2115 | PUSHs (newSViv (rv.direction)); |
… | |
… | |
2069 | const_utf8_string |
2124 | const_utf8_string |
2070 | base_name (object *op, int plural = op->nrof > 1) |
2125 | base_name (object *op, int plural = op->nrof > 1) |
2071 | CODE: |
2126 | CODE: |
2072 | RETVAL = query_base_name (op, plural); |
2127 | RETVAL = query_base_name (op, plural); |
2073 | OUTPUT: RETVAL |
2128 | OUTPUT: RETVAL |
2074 | |
|
|
2075 | object *decrease_ob_nr (object *op, unsigned long i) |
|
|
2076 | |
2129 | |
2077 | # return the tail of an object, excluding itself |
2130 | # return the tail of an object, excluding itself |
2078 | void |
2131 | void |
2079 | tail (object *op) |
2132 | tail (object *op) |
2080 | PPCODE: |
2133 | PPCODE: |
… | |
… | |
2369 | get_map_flags (maptile *map, int x, int y) |
2422 | get_map_flags (maptile *map, int x, int y) |
2370 | PPCODE: |
2423 | PPCODE: |
2371 | { |
2424 | { |
2372 | maptile *nmap = 0; |
2425 | maptile *nmap = 0; |
2373 | I16 nx = 0, ny = 0; |
2426 | I16 nx = 0, ny = 0; |
|
|
2427 | |
|
|
2428 | PUTBACK; |
2374 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2429 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2430 | SPAGAIN; |
2375 | |
2431 | |
2376 | EXTEND (SP, 4); |
2432 | EXTEND (SP, 4); |
2377 | PUSHs (sv_2mortal (newSViv (flags))); |
2433 | PUSHs (sv_2mortal (newSViv (flags))); |
2378 | |
2434 | |
2379 | if (GIMME_V == G_ARRAY) |
2435 | if (GIMME_V == G_ARRAY) |
… | |
… | |
2387 | void |
2443 | void |
2388 | at (maptile *map, unsigned int x, unsigned int y) |
2444 | at (maptile *map, unsigned int x, unsigned int y) |
2389 | PROTOTYPE: $$$ |
2445 | PROTOTYPE: $$$ |
2390 | PPCODE: |
2446 | PPCODE: |
2391 | { |
2447 | { |
2392 | object *o; |
|
|
2393 | maptile *nmap = 0; |
2448 | maptile *nmap = 0; |
2394 | I16 nx, ny; |
2449 | I16 nx, ny; |
2395 | |
2450 | |
|
|
2451 | PUTBACK; |
2396 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2452 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2453 | SPAGAIN; |
2397 | |
2454 | |
2398 | if (nmap) |
2455 | if (nmap) |
2399 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2456 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2400 | XPUSHs (sv_2mortal (to_sv (o))); |
2457 | XPUSHs (sv_2mortal (to_sv (o))); |
2401 | } |
2458 | } |
2402 | |
2459 | |
2403 | SV * |
2460 | SV * |
2404 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2461 | bot_at (maptile *obj, unsigned int x, unsigned int y) |