… | |
… | |
43 | # include <sys/mman.h> |
43 | # include <sys/mman.h> |
44 | #endif |
44 | #endif |
45 | |
45 | |
46 | #if HAVE_MALLOC_H |
46 | #if HAVE_MALLOC_H |
47 | # include <malloc.h> |
47 | # include <malloc.h> |
|
|
48 | #endif |
|
|
49 | |
|
|
50 | #if !__GLIBC__ |
|
|
51 | # define malloc_trim(pad) -1 |
48 | #endif |
52 | #endif |
49 | |
53 | |
50 | #include <EXTERN.h> |
54 | #include <EXTERN.h> |
51 | #include <perl.h> |
55 | #include <perl.h> |
52 | #include <XSUB.h> |
56 | #include <XSUB.h> |
… | |
… | |
940 | CALL_CALL ("ext::books::make_book", G_VOID); |
944 | CALL_CALL ("ext::books::make_book", G_VOID); |
941 | CALL_END; |
945 | CALL_END; |
942 | } |
946 | } |
943 | |
947 | |
944 | void |
948 | 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 |
945 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
967 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
946 | { |
968 | { |
947 | CALL_BEGIN (4); |
969 | CALL_BEGIN (4); |
948 | CALL_ARG (ns); |
970 | CALL_ARG (ns); |
949 | CALL_ARG (type); |
971 | CALL_ARG (type); |
… | |
… | |
973 | { |
995 | { |
974 | CALL_BEGIN (1); |
996 | CALL_BEGIN (1); |
975 | CALL_ARG (name); |
997 | CALL_ARG (name); |
976 | CALL_CALL ("cf::player::find", G_SCALAR); |
998 | CALL_CALL ("cf::player::find", G_SCALAR); |
977 | |
999 | |
978 | player *retval; |
1000 | player *retval = 0; |
979 | |
|
|
980 | if (count) |
|
|
981 | sv_to (POPs, retval); |
1001 | if (count) sv_to (POPs, retval); |
982 | else |
1002 | |
983 | retval = 0; |
1003 | CALL_END; |
|
|
1004 | |
|
|
1005 | return retval; |
|
|
1006 | } |
|
|
1007 | |
|
|
1008 | maptile * |
|
|
1009 | find_style (const char *dirname, const char *stylename, int difficulty) |
|
|
1010 | { |
|
|
1011 | CALL_BEGIN (3); |
|
|
1012 | CALL_ARG (dirname); |
|
|
1013 | CALL_ARG (stylename); |
|
|
1014 | CALL_ARG (difficulty); |
|
|
1015 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
|
|
1016 | |
|
|
1017 | maptile *retval = 0; |
|
|
1018 | if (count) sv_to (POPs, retval); |
984 | |
1019 | |
985 | CALL_END; |
1020 | CALL_END; |
986 | |
1021 | |
987 | return retval; |
1022 | return retval; |
988 | } |
1023 | } |
… | |
… | |
993 | CALL_BEGIN (2); |
1028 | CALL_BEGIN (2); |
994 | CALL_ARG (path); |
1029 | CALL_ARG (path); |
995 | CALL_ARG (origin); |
1030 | CALL_ARG (origin); |
996 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
1031 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
997 | |
1032 | |
998 | maptile *retval; |
1033 | maptile *retval = 0; |
999 | |
|
|
1000 | if (count) |
|
|
1001 | sv_to (POPs, retval); |
1034 | if (count) sv_to (POPs, retval); |
1002 | else |
|
|
1003 | retval = 0; |
|
|
1004 | |
1035 | |
1005 | CALL_END; |
1036 | CALL_END; |
1006 | |
1037 | |
1007 | return retval; |
1038 | return retval; |
1008 | } |
1039 | } |
… | |
… | |
1014 | CALL_ARG (path); |
1045 | CALL_ARG (path); |
1015 | CALL_ARG (origin); |
1046 | CALL_ARG (origin); |
1016 | CALL_ARG (load); |
1047 | CALL_ARG (load); |
1017 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1048 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1018 | |
1049 | |
1019 | maptile *retval; |
1050 | maptile *retval = 0; |
1020 | |
|
|
1021 | if (count) |
|
|
1022 | sv_to (POPs, retval); |
1051 | if (count) sv_to (POPs, retval); |
1023 | else |
|
|
1024 | retval = 0; |
|
|
1025 | |
1052 | |
1026 | CALL_END; |
1053 | CALL_END; |
1027 | |
1054 | |
1028 | return retval; |
1055 | return retval; |
1029 | } |
1056 | } |
… | |
… | |
1054 | |
1081 | |
1055 | CALL_BEGIN (2); |
1082 | CALL_BEGIN (2); |
1056 | CALL_ARG (this); |
1083 | CALL_ARG (this); |
1057 | CALL_ARG (exit); |
1084 | CALL_ARG (exit); |
1058 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
1085 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
|
|
1086 | CALL_END; |
|
|
1087 | } |
|
|
1088 | |
|
|
1089 | void |
|
|
1090 | object::player_goto (const char *path, int x, int y) |
|
|
1091 | { |
|
|
1092 | if (type != PLAYER) |
|
|
1093 | return; |
|
|
1094 | |
|
|
1095 | CALL_BEGIN (4); |
|
|
1096 | CALL_ARG (this); |
|
|
1097 | CALL_ARG (path); |
|
|
1098 | CALL_ARG (x); |
|
|
1099 | CALL_ARG (y); |
|
|
1100 | CALL_CALL ("cf::object::player::goto", G_VOID); |
1059 | CALL_END; |
1101 | CALL_END; |
1060 | } |
1102 | } |
1061 | |
1103 | |
1062 | const char * |
1104 | const char * |
1063 | object::ref () const |
1105 | object::ref () const |
… | |
… | |
1428 | |
1470 | |
1429 | const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) |
1471 | const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) |
1430 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1472 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1431 | |
1473 | |
1432 | const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) |
1474 | 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) |
1475 | const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_MINIMAL) |
1434 | const_iv (GT_MINIMAL) |
|
|
1435 | |
1476 | |
1436 | const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) |
1477 | const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) |
1437 | const_iv (FT_RSRC) const_iv (FT_NUM) |
1478 | const_iv (FT_RSRC) const_iv (FT_NUM) |
1438 | }; |
1479 | }; |
1439 | |
1480 | |
… | |
… | |
1570 | NV floor (NV x) |
1611 | NV floor (NV x) |
1571 | |
1612 | |
1572 | NV ceil (NV x) |
1613 | NV ceil (NV x) |
1573 | |
1614 | |
1574 | NV rndm (...) |
1615 | NV rndm (...) |
|
|
1616 | ALIAS: |
|
|
1617 | rmg_rndm = 1 |
1575 | CODE: |
1618 | CODE: |
|
|
1619 | { |
|
|
1620 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1576 | switch (items) |
1621 | switch (items) |
1577 | { |
1622 | { |
1578 | case 0: RETVAL = rndm (); break; |
1623 | case 0: RETVAL = gen (); break; |
1579 | case 1: RETVAL = rndm (SvUV (ST (0))); break; |
1624 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1580 | case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break; |
1625 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1581 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1626 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1582 | } |
1627 | } |
|
|
1628 | } |
1583 | OUTPUT: |
1629 | OUTPUT: |
1584 | RETVAL |
1630 | RETVAL |
1585 | |
1631 | |
1586 | NV clamp (NV value, NV min_value, NV max_value) |
1632 | NV clamp (NV value, NV min_value, NV max_value) |
1587 | CODE: |
1633 | CODE: |
… | |
… | |
1612 | octet_string path_combine (octet_string base, octet_string path) |
1658 | octet_string path_combine (octet_string base, octet_string path) |
1613 | PROTOTYPE: $$ |
1659 | PROTOTYPE: $$ |
1614 | |
1660 | |
1615 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1661 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1616 | PROTOTYPE: $$ |
1662 | 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 | |
1663 | |
1641 | void |
1664 | void |
1642 | sub_generation_inc () |
1665 | sub_generation_inc () |
1643 | CODE: |
1666 | CODE: |
1644 | PL_sub_generation++; |
1667 | PL_sub_generation++; |
… | |
… | |
1681 | |
1704 | |
1682 | #if _POSIX_MEMLOCK |
1705 | #if _POSIX_MEMLOCK |
1683 | |
1706 | |
1684 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1707 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1685 | INIT: |
1708 | INIT: |
1686 | #ifdef __linux |
1709 | #if __GLIBC__ |
1687 | mallopt (M_PERTURB, 0xaa); // bug-workaround for linux glibc+mlockall+calloc |
1710 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1688 | #endif |
1711 | #endif |
1689 | |
1712 | |
1690 | int munlockall () |
1713 | int munlockall () |
1691 | |
1714 | |
1692 | #endif |
1715 | #endif |
|
|
1716 | |
|
|
1717 | int |
|
|
1718 | malloc_trim (IV pad = 0) |
|
|
1719 | |
|
|
1720 | void |
|
|
1721 | mallinfo () |
|
|
1722 | PPCODE: |
|
|
1723 | { |
|
|
1724 | #if __GLIBC__ |
|
|
1725 | struct mallinfo mai = mallinfo (); |
|
|
1726 | EXTEND (SP, 10*2); |
|
|
1727 | PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena))); |
|
|
1728 | PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks))); |
|
|
1729 | PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks))); |
|
|
1730 | PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks))); |
|
|
1731 | PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd))); |
|
|
1732 | PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks))); |
|
|
1733 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
|
|
1734 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
|
|
1735 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
|
|
1736 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
|
|
1737 | #endif |
|
|
1738 | EXTEND (SP, 2*2); |
|
|
1739 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
|
|
1740 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
|
|
1741 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
|
|
1742 | } |
1693 | |
1743 | |
1694 | int find_animation (utf8_string text) |
1744 | int find_animation (utf8_string text) |
1695 | PROTOTYPE: $ |
1745 | PROTOTYPE: $ |
1696 | |
1746 | |
1697 | int random_roll (int min, int max, object *op, int goodbad); |
1747 | int random_roll (int min, int max, object *op, int goodbad); |
… | |
… | |
1778 | EXTEND (SP, NUM_COINS); |
1828 | EXTEND (SP, NUM_COINS); |
1779 | for (int i = 0; i < NUM_COINS; ++i) |
1829 | for (int i = 0; i < NUM_COINS; ++i) |
1780 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1830 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1781 | |
1831 | |
1782 | bool |
1832 | bool |
1783 | load_resource_file (octet_string filename) |
1833 | load_resource_file_ (octet_string filename) |
|
|
1834 | |
|
|
1835 | void |
|
|
1836 | fix_weight () |
1784 | |
1837 | |
1785 | MODULE = cf PACKAGE = cf::attachable |
1838 | MODULE = cf PACKAGE = cf::attachable |
1786 | |
1839 | |
1787 | int |
1840 | int |
1788 | valid (SV *obj) |
1841 | valid (SV *obj) |
… | |
… | |
1852 | object *actives (U32 index) |
1905 | object *actives (U32 index) |
1853 | CODE: |
1906 | CODE: |
1854 | RETVAL = index < actives.size () ? actives [index] : 0; |
1907 | RETVAL = index < actives.size () ? actives [index] : 0; |
1855 | OUTPUT: RETVAL |
1908 | OUTPUT: RETVAL |
1856 | |
1909 | |
|
|
1910 | int mortals_size () |
|
|
1911 | CODE: |
|
|
1912 | RETVAL = attachable::mortals.size (); |
|
|
1913 | OUTPUT: RETVAL |
|
|
1914 | |
1857 | const char *slot_use_name (U32 slot) |
1915 | const char *slot_use_name (U32 slot) |
1858 | ALIAS: |
1916 | ALIAS: |
1859 | slot_nonuse_name = 1 |
1917 | slot_nonuse_name = 1 |
1860 | CODE: |
1918 | CODE: |
1861 | { |
1919 | { |
… | |
… | |
1939 | void apply_below (object *op) |
1997 | void apply_below (object *op) |
1940 | CODE: |
1998 | CODE: |
1941 | player_apply_below (op); |
1999 | player_apply_below (op); |
1942 | |
2000 | |
1943 | int cast_heal (object *op, object *caster, object *spell, int dir = 0) |
2001 | int cast_heal (object *op, object *caster, object *spell, int dir = 0) |
1944 | |
|
|
1945 | #//TODO |
|
|
1946 | object *clone_ (object *op, int recursive = 0) |
|
|
1947 | CODE: |
|
|
1948 | if (recursive) |
|
|
1949 | RETVAL = object_create_clone (op); |
|
|
1950 | else |
|
|
1951 | { |
|
|
1952 | RETVAL = object::create (); |
|
|
1953 | op->copy_to (RETVAL); |
|
|
1954 | } |
|
|
1955 | OUTPUT: RETVAL |
|
|
1956 | |
2002 | |
1957 | int pay_item (object *op, object *buyer) |
2003 | int pay_item (object *op, object *buyer) |
1958 | CODE: |
2004 | CODE: |
1959 | RETVAL = pay_for_item (op, buyer); |
2005 | RETVAL = pay_for_item (op, buyer); |
1960 | OUTPUT: RETVAL |
2006 | OUTPUT: RETVAL |
… | |
… | |
2038 | CODE: |
2084 | CODE: |
2039 | { |
2085 | { |
2040 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2086 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2041 | } |
2087 | } |
2042 | |
2088 | |
2043 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
2089 | shstr |
|
|
2090 | object::kv_get (shstr key) |
2044 | |
2091 | |
2045 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
2092 | void |
|
|
2093 | object::kv_del (shstr key) |
|
|
2094 | |
|
|
2095 | void |
|
|
2096 | object::kv_set (shstr key, shstr value) |
2046 | |
2097 | |
2047 | object *get_nearest_player (object *ob) |
2098 | object *get_nearest_player (object *ob) |
2048 | ALIAS: nearest_player = 0 |
2099 | ALIAS: nearest_player = 0 |
2049 | PREINIT: |
2100 | PREINIT: |
2050 | extern object *get_nearest_player (object *); |
2101 | extern object *get_nearest_player (object *); |
… | |
… | |
2071 | const_utf8_string |
2122 | const_utf8_string |
2072 | base_name (object *op, int plural = op->nrof > 1) |
2123 | base_name (object *op, int plural = op->nrof > 1) |
2073 | CODE: |
2124 | CODE: |
2074 | RETVAL = query_base_name (op, plural); |
2125 | RETVAL = query_base_name (op, plural); |
2075 | OUTPUT: RETVAL |
2126 | OUTPUT: RETVAL |
2076 | |
|
|
2077 | object *decrease_ob_nr (object *op, unsigned long i) |
|
|
2078 | |
2127 | |
2079 | # return the tail of an object, excluding itself |
2128 | # return the tail of an object, excluding itself |
2080 | void |
2129 | void |
2081 | tail (object *op) |
2130 | tail (object *op) |
2082 | PPCODE: |
2131 | PPCODE: |