… | |
… | |
28 | |
28 | |
29 | #include <cstdarg> |
29 | #include <cstdarg> |
30 | #include <typeinfo> |
30 | #include <typeinfo> |
31 | |
31 | |
32 | #include "global.h" |
32 | #include "global.h" |
33 | #include "../random_maps/random_map.h" |
33 | #include "rmg.h" |
34 | #include "evthread.h" |
34 | #include "evthread.h" |
35 | #include "sproto.h" |
35 | #include "sproto.h" |
36 | |
36 | |
37 | #include <unistd.h> |
37 | #include <unistd.h> |
38 | #if _POSIX_MEMLOCK |
38 | #if _POSIX_MEMLOCK |
… | |
… | |
1459 | # include "attackinc.h" |
1459 | # include "attackinc.h" |
1460 | # undef def |
1460 | # undef def |
1461 | # define def(uc, flags) const_iv (SK_ ## uc) |
1461 | # define def(uc, flags) const_iv (SK_ ## uc) |
1462 | # include "skillinc.h" |
1462 | # include "skillinc.h" |
1463 | # undef def |
1463 | # undef def |
1464 | |
1464 | # define def(name, use, nonuse) const_iv (body_ ## name) |
1465 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1465 | # include "slotinc.h" |
|
|
1466 | # undef def |
1466 | |
1467 | |
1467 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1468 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1468 | |
1469 | |
1469 | const_iv (MAX_TIME) |
1470 | const_iv (MAX_TIME) |
1470 | const_iv (MAXSOCKBUF) |
1471 | const_iv (MAXSOCKBUF) |
… | |
… | |
1775 | |
1776 | |
1776 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1777 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1777 | INIT: |
1778 | INIT: |
1778 | #if __GLIBC__ |
1779 | #if __GLIBC__ |
1779 | mallopt (M_TOP_PAD, 1024 * 1024); |
1780 | mallopt (M_TOP_PAD, 1024 * 1024); |
1780 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); |
1781 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024); |
1781 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1782 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
|
|
1783 | if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10)) |
1782 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1784 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1783 | #endif |
1785 | #endif |
1784 | |
1786 | |
1785 | int munlockall () |
1787 | int munlockall () |
1786 | |
1788 | |
1787 | #endif |
1789 | #endif |
… | |
… | |
1825 | int exp_to_level (val64 exp) |
1827 | int exp_to_level (val64 exp) |
1826 | |
1828 | |
1827 | val64 level_to_min_exp (int level) |
1829 | val64 level_to_min_exp (int level) |
1828 | |
1830 | |
1829 | SV * |
1831 | SV * |
1830 | resistance_to_string (int atnr) |
1832 | attacktype_name (int atnr) |
1831 | CODE: |
1833 | CODE: |
1832 | if (atnr >= 0 && atnr < NROFATTACKS) |
1834 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1835 | ? newSVpv (attacktype_name [atnr], 0) |
|
|
1836 | : &PL_sv_undef; |
|
|
1837 | OUTPUT: RETVAL |
|
|
1838 | |
|
|
1839 | SV * |
|
|
1840 | attacktype_desc (int atnr) |
|
|
1841 | CODE: |
|
|
1842 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1843 | ? newSVpv (attacktype_desc [atnr], 0) |
|
|
1844 | : &PL_sv_undef; |
|
|
1845 | OUTPUT: RETVAL |
|
|
1846 | |
|
|
1847 | SV * |
|
|
1848 | resist_plus (int atnr) |
|
|
1849 | CODE: |
|
|
1850 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1833 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1851 | ? newSVpv (resist_plus [atnr], 0) |
1834 | else |
1852 | : &PL_sv_undef; |
1835 | XSRETURN_UNDEF; |
1853 | OUTPUT: RETVAL |
|
|
1854 | |
|
|
1855 | SV * |
|
|
1856 | change_resist_msg (int atnr) |
|
|
1857 | CODE: |
|
|
1858 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1859 | ? newSVpv (change_resist_msg [atnr], 0) |
|
|
1860 | : &PL_sv_undef; |
1836 | OUTPUT: RETVAL |
1861 | OUTPUT: RETVAL |
1837 | |
1862 | |
1838 | UUID |
1863 | UUID |
1839 | uuid_cur () |
1864 | uuid_cur () |
1840 | CODE: |
1865 | CODE: |
… | |
… | |
1963 | int mortals_size () |
1988 | int mortals_size () |
1964 | CODE: |
1989 | CODE: |
1965 | RETVAL = attachable::mortals.size (); |
1990 | RETVAL = attachable::mortals.size (); |
1966 | OUTPUT: RETVAL |
1991 | OUTPUT: RETVAL |
1967 | |
1992 | |
1968 | const_utf8_string slot_use_name (U32 slot) |
1993 | const_utf8_string slot_name (U32 slot) |
1969 | ALIAS: |
1994 | ALIAS: |
|
|
1995 | slot_name = 0 |
|
|
1996 | slot_use_name = 1 |
1970 | slot_nonuse_name = 1 |
1997 | slot_nonuse_name = 2 |
1971 | CODE: |
1998 | CODE: |
1972 | { |
1999 | { |
1973 | if (slot >= NUM_BODY_LOCATIONS) |
2000 | if (slot >= NUM_BODY_LOCATIONS) |
1974 | croak ("body slot index out of range"); |
2001 | croak ("body slot index out of range"); |
1975 | |
2002 | |
1976 | switch (ix) |
2003 | switch (ix) |
1977 | { |
2004 | { |
|
|
2005 | case 0: RETVAL = body_locations[slot].name ; break; |
1978 | case 0: RETVAL = body_locations[slot].use_name; break; |
2006 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1979 | case 1: RETVAL = body_locations[slot].nonuse_name; break; |
2007 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1980 | } |
2008 | } |
1981 | } |
2009 | } |
1982 | OUTPUT: |
2010 | OUTPUT: |
1983 | RETVAL |
2011 | RETVAL |
1984 | |
2012 | |
… | |
… | |
2538 | } |
2566 | } |
2539 | OUTPUT: RETVAL |
2567 | OUTPUT: RETVAL |
2540 | |
2568 | |
2541 | # worst xs function of my life |
2569 | # worst xs function of my life |
2542 | bool |
2570 | bool |
2543 | _create_random_map (\ |
2571 | _create_random_map (maptile *self, SV *options) |
2544 | maptile *self,\ |
|
|
2545 | SV *options,\ |
|
|
2546 | val64 total_map_hp,\ |
|
|
2547 | region *region\ |
|
|
2548 | ) |
|
|
2549 | CODE: |
2572 | CODE: |
2550 | { |
2573 | { |
2551 | random_map_params rmp; |
2574 | random_map_params rmp ((HV *)SvRV (options)); |
2552 | |
|
|
2553 | rmp.hv = (HV *)SvREFCNT_inc_NN (SvRV (options)); |
|
|
2554 | |
|
|
2555 | assign (rmp.wall_name , rmp.get_str ("wall_name")); |
|
|
2556 | assign (rmp.monsterstyle , rmp.get_str ("monsterstyle")); |
|
|
2557 | assign (rmp.layoutstyle , rmp.get_str ("layoutstyle")); |
|
|
2558 | assign (rmp.doorstyle , rmp.get_str ("doorstyle")); |
|
|
2559 | assign (rmp.exit_on_final_map, rmp.get_str ("exit_on_final_map")); |
|
|
2560 | |
|
|
2561 | rmp.origin_map = rmp.get_str ("origin_map"); |
|
|
2562 | rmp.origin_x = rmp.get_iv ("origin_x"); |
|
|
2563 | rmp.origin_y = rmp.get_iv ("origin_y"); |
|
|
2564 | rmp.final_map = rmp.get_str ("final_map"); |
|
|
2565 | rmp.this_map = rmp.get_str ("this_map"); |
|
|
2566 | rmp.xsize = rmp.get_iv ("xsize"); |
|
|
2567 | rmp.ysize = rmp.get_iv ("ysize"); |
|
|
2568 | rmp.expand2x = rmp.get_iv ("expand2x"); |
|
|
2569 | rmp.layoutoptions1 = rmp.get_iv ("layoutoptions1"); |
|
|
2570 | rmp.layoutoptions2 = rmp.get_iv ("layoutoptions2"); |
|
|
2571 | rmp.layoutoptions3 = rmp.get_iv ("layoutoptions3"); |
|
|
2572 | rmp.symmetry = rmp.get_iv ("symmetry"); |
|
|
2573 | rmp.difficulty = rmp.get_iv ("difficulty"); |
|
|
2574 | rmp.difficulty_given = rmp.get_iv ("difficulty_given"); |
|
|
2575 | rmp.difficulty_increase = rmp.get_nv ("difficulty_increase"); |
|
|
2576 | rmp.dungeon_level = rmp.get_iv ("dungeon_level"); |
|
|
2577 | rmp.dungeon_depth = rmp.get_iv ("dungeon_depth"); |
|
|
2578 | rmp.orientation = rmp.get_iv ("orientation"); |
|
|
2579 | rmp.random_seed = rmp.get_uv ("random_seed"); |
|
|
2580 | rmp.total_map_hp = (uint64_t)total_map_hp; |
|
|
2581 | rmp.map_layout_style = rmp.get_iv ("map_layout_style"); |
|
|
2582 | rmp.symmetry_used = rmp.get_iv ("symmetry_used"); |
|
|
2583 | rmp.region = region; |
|
|
2584 | |
|
|
2585 | RETVAL = self->generate_random_map (&rmp); |
2575 | RETVAL = self->generate_random_map (&rmp); |
2586 | } |
2576 | } |
2587 | OUTPUT: |
2577 | OUTPUT: |
2588 | RETVAL |
2578 | RETVAL |
2589 | |
2579 | |
… | |
… | |
2761 | |
2751 | |
2762 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2752 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2763 | CODE: |
2753 | CODE: |
2764 | { |
2754 | { |
2765 | faceinfo *f = face_info (idx); assert (f); |
2755 | faceinfo *f = face_info (idx); assert (f); |
2766 | facedata *d = &(faceset ? f->data64 : f->data32); |
2756 | facedata *d = f->face + faceset; |
2767 | sv_to (data, d->data); |
2757 | sv_to (data, d->data); |
2768 | STRLEN clen; |
2758 | STRLEN clen; |
2769 | char *cdata = SvPVbyte (chksum, clen); |
2759 | char *cdata = SvPVbyte (chksum, clen); |
2770 | clen = min (CHKSUM_MAXLEN, clen); |
2760 | clen = min (CHKSUM_MAXLEN, clen); |
2771 | |
2761 | |
… | |
… | |
2925 | self->skip (); |
2915 | self->skip (); |
2926 | } |
2916 | } |
2927 | |
2917 | |
2928 | MODULE = cf PACKAGE = cf::layout |
2918 | MODULE = cf PACKAGE = cf::layout |
2929 | |
2919 | |
2930 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../random_maps/random_map.h | |
2920 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
2931 | |
2921 | |