… | |
… | |
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> |
… | |
… | |
1428 | |
1432 | |
1429 | const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) |
1433 | const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) |
1430 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1434 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1431 | |
1435 | |
1432 | const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) |
1436 | 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) |
1437 | const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_MINIMAL) |
1434 | const_iv (GT_MINIMAL) |
|
|
1435 | |
1438 | |
1436 | const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) |
1439 | const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) |
1437 | const_iv (FT_RSRC) const_iv (FT_NUM) |
1440 | const_iv (FT_RSRC) const_iv (FT_NUM) |
1438 | }; |
1441 | }; |
1439 | |
1442 | |
… | |
… | |
1612 | octet_string path_combine (octet_string base, octet_string path) |
1615 | octet_string path_combine (octet_string base, octet_string path) |
1613 | PROTOTYPE: $$ |
1616 | PROTOTYPE: $$ |
1614 | |
1617 | |
1615 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1618 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1616 | PROTOTYPE: $$ |
1619 | 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 | |
1620 | |
1641 | void |
1621 | void |
1642 | sub_generation_inc () |
1622 | sub_generation_inc () |
1643 | CODE: |
1623 | CODE: |
1644 | PL_sub_generation++; |
1624 | PL_sub_generation++; |
… | |
… | |
1681 | |
1661 | |
1682 | #if _POSIX_MEMLOCK |
1662 | #if _POSIX_MEMLOCK |
1683 | |
1663 | |
1684 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1664 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1685 | INIT: |
1665 | INIT: |
1686 | #ifdef __linux |
1666 | #if __GLIBC__ |
1687 | mallopt (M_PERTURB, 0xaa); // bug-workaround for linux glibc+mlockall+calloc |
1667 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1688 | #endif |
1668 | #endif |
1689 | |
1669 | |
1690 | int munlockall () |
1670 | int munlockall () |
1691 | |
1671 | |
1692 | #endif |
1672 | #endif |
|
|
1673 | |
|
|
1674 | int |
|
|
1675 | malloc_trim (IV pad = 0) |
|
|
1676 | |
|
|
1677 | void |
|
|
1678 | mallinfo () |
|
|
1679 | PPCODE: |
|
|
1680 | { |
|
|
1681 | #if __GLIBC__ |
|
|
1682 | struct mallinfo mai = mallinfo (); |
|
|
1683 | EXTEND (SP, 10*2); |
|
|
1684 | PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena))); |
|
|
1685 | PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks))); |
|
|
1686 | PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks))); |
|
|
1687 | PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks))); |
|
|
1688 | PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd))); |
|
|
1689 | PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks))); |
|
|
1690 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
|
|
1691 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
|
|
1692 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
|
|
1693 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
|
|
1694 | #endif |
|
|
1695 | EXTEND (SP, 2*2); |
|
|
1696 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
|
|
1697 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
|
|
1698 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
|
|
1699 | } |
1693 | |
1700 | |
1694 | int find_animation (utf8_string text) |
1701 | int find_animation (utf8_string text) |
1695 | PROTOTYPE: $ |
1702 | PROTOTYPE: $ |
1696 | |
1703 | |
1697 | int random_roll (int min, int max, object *op, int goodbad); |
1704 | int random_roll (int min, int max, object *op, int goodbad); |
… | |
… | |
1778 | EXTEND (SP, NUM_COINS); |
1785 | EXTEND (SP, NUM_COINS); |
1779 | for (int i = 0; i < NUM_COINS; ++i) |
1786 | for (int i = 0; i < NUM_COINS; ++i) |
1780 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1787 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1781 | |
1788 | |
1782 | bool |
1789 | bool |
1783 | load_resource_file (octet_string filename) |
1790 | load_resource_file_ (octet_string filename) |
1784 | |
1791 | |
1785 | MODULE = cf PACKAGE = cf::attachable |
1792 | MODULE = cf PACKAGE = cf::attachable |
1786 | |
1793 | |
1787 | int |
1794 | int |
1788 | valid (SV *obj) |
1795 | valid (SV *obj) |
… | |
… | |
1852 | object *actives (U32 index) |
1859 | object *actives (U32 index) |
1853 | CODE: |
1860 | CODE: |
1854 | RETVAL = index < actives.size () ? actives [index] : 0; |
1861 | RETVAL = index < actives.size () ? actives [index] : 0; |
1855 | OUTPUT: RETVAL |
1862 | OUTPUT: RETVAL |
1856 | |
1863 | |
|
|
1864 | int mortals_size () |
|
|
1865 | CODE: |
|
|
1866 | RETVAL = attachable::mortals.size (); |
|
|
1867 | OUTPUT: RETVAL |
|
|
1868 | |
1857 | const char *slot_use_name (U32 slot) |
1869 | const char *slot_use_name (U32 slot) |
1858 | ALIAS: |
1870 | ALIAS: |
1859 | slot_nonuse_name = 1 |
1871 | slot_nonuse_name = 1 |
1860 | CODE: |
1872 | CODE: |
1861 | { |
1873 | { |
… | |
… | |
1939 | void apply_below (object *op) |
1951 | void apply_below (object *op) |
1940 | CODE: |
1952 | CODE: |
1941 | player_apply_below (op); |
1953 | player_apply_below (op); |
1942 | |
1954 | |
1943 | int cast_heal (object *op, object *caster, object *spell, int dir = 0) |
1955 | 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 | |
1956 | |
1957 | int pay_item (object *op, object *buyer) |
1957 | int pay_item (object *op, object *buyer) |
1958 | CODE: |
1958 | CODE: |
1959 | RETVAL = pay_for_item (op, buyer); |
1959 | RETVAL = pay_for_item (op, buyer); |
1960 | OUTPUT: RETVAL |
1960 | OUTPUT: RETVAL |
… | |
… | |
2038 | CODE: |
2038 | CODE: |
2039 | { |
2039 | { |
2040 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2040 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2041 | } |
2041 | } |
2042 | |
2042 | |
2043 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
2043 | shstr |
|
|
2044 | object::kv_get (shstr key) |
2044 | |
2045 | |
2045 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
2046 | void |
|
|
2047 | object::kv_del (shstr key) |
|
|
2048 | |
|
|
2049 | void |
|
|
2050 | object::kv_set (shstr key, shstr value) |
2046 | |
2051 | |
2047 | object *get_nearest_player (object *ob) |
2052 | object *get_nearest_player (object *ob) |
2048 | ALIAS: nearest_player = 0 |
2053 | ALIAS: nearest_player = 0 |
2049 | PREINIT: |
2054 | PREINIT: |
2050 | extern object *get_nearest_player (object *); |
2055 | extern object *get_nearest_player (object *); |
… | |
… | |
2071 | const_utf8_string |
2076 | const_utf8_string |
2072 | base_name (object *op, int plural = op->nrof > 1) |
2077 | base_name (object *op, int plural = op->nrof > 1) |
2073 | CODE: |
2078 | CODE: |
2074 | RETVAL = query_base_name (op, plural); |
2079 | RETVAL = query_base_name (op, plural); |
2075 | OUTPUT: RETVAL |
2080 | OUTPUT: RETVAL |
2076 | |
|
|
2077 | object *decrease_ob_nr (object *op, unsigned long i) |
|
|
2078 | |
2081 | |
2079 | # return the tail of an object, excluding itself |
2082 | # return the tail of an object, excluding itself |
2080 | void |
2083 | void |
2081 | tail (object *op) |
2084 | tail (object *op) |
2082 | PPCODE: |
2085 | PPCODE: |