… | |
… | |
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 |
… | |
… | |
84 | *stash_cf_client_wrap, |
84 | *stash_cf_client_wrap, |
85 | *stash_cf_arch_wrap, |
85 | *stash_cf_arch_wrap, |
86 | *stash_cf_party_wrap, |
86 | *stash_cf_party_wrap, |
87 | *stash_cf_region_wrap, |
87 | *stash_cf_region_wrap, |
88 | *stash_cf_living_wrap, |
88 | *stash_cf_living_wrap, |
|
|
89 | *stash_cf_layout_wrap, |
89 | *stash_ext_map_world; |
90 | *stash_ext_map_world; |
90 | |
91 | |
91 | static SV |
92 | static SV |
92 | *cv_cf_do_invoke, |
93 | *cv_cf_do_invoke, |
93 | *cv_cf__can_merge, |
94 | *cv_cf__can_merge, |
… | |
… | |
539 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
540 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
540 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
541 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
541 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
542 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
542 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
543 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
543 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
544 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
|
|
545 | static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); } |
544 | |
546 | |
545 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
547 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
546 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
548 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
547 | |
549 | |
548 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
550 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
… | |
… | |
594 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
596 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
595 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
597 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
596 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
598 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
597 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
599 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
598 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
600 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
|
|
601 | static inline void sv_to (SV *sv, layout * &v) { v = (layout *) SvPTR_ornull (sv, "cf::layout"); } |
599 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
602 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
600 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
603 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
601 | |
604 | |
602 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
605 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
603 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
606 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
1397 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1400 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1398 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1401 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1399 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1402 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1400 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1403 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1401 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1404 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
|
|
1405 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
1402 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1406 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1403 | |
1407 | |
1404 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1408 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1405 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1409 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1406 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1410 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
… | |
… | |
1455 | # include "attackinc.h" |
1459 | # include "attackinc.h" |
1456 | # undef def |
1460 | # undef def |
1457 | # define def(uc, flags) const_iv (SK_ ## uc) |
1461 | # define def(uc, flags) const_iv (SK_ ## uc) |
1458 | # include "skillinc.h" |
1462 | # include "skillinc.h" |
1459 | # undef def |
1463 | # undef def |
1460 | |
1464 | # define def(name, use, nonuse) const_iv (body_ ## name) |
1461 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1465 | # include "slotinc.h" |
|
|
1466 | # undef def |
1462 | |
1467 | |
1463 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1468 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1464 | |
1469 | |
1465 | const_iv (MAX_TIME) |
1470 | const_iv (MAX_TIME) |
1466 | const_iv (MAXSOCKBUF) |
1471 | const_iv (MAXSOCKBUF) |
… | |
… | |
1821 | int exp_to_level (val64 exp) |
1826 | int exp_to_level (val64 exp) |
1822 | |
1827 | |
1823 | val64 level_to_min_exp (int level) |
1828 | val64 level_to_min_exp (int level) |
1824 | |
1829 | |
1825 | SV * |
1830 | SV * |
1826 | resistance_to_string (int atnr) |
1831 | attacktype_name (int atnr) |
1827 | CODE: |
1832 | CODE: |
1828 | if (atnr >= 0 && atnr < NROFATTACKS) |
1833 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1834 | ? newSVpv (attacktype_name [atnr], 0) |
|
|
1835 | : &PL_sv_undef; |
|
|
1836 | OUTPUT: RETVAL |
|
|
1837 | |
|
|
1838 | SV * |
|
|
1839 | attacktype_desc (int atnr) |
|
|
1840 | CODE: |
|
|
1841 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1842 | ? newSVpv (attacktype_desc [atnr], 0) |
|
|
1843 | : &PL_sv_undef; |
|
|
1844 | OUTPUT: RETVAL |
|
|
1845 | |
|
|
1846 | SV * |
|
|
1847 | resist_plus (int atnr) |
|
|
1848 | CODE: |
|
|
1849 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1829 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1850 | ? newSVpv (resist_plus [atnr], 0) |
1830 | else |
1851 | : &PL_sv_undef; |
1831 | XSRETURN_UNDEF; |
1852 | OUTPUT: RETVAL |
|
|
1853 | |
|
|
1854 | SV * |
|
|
1855 | change_resist_msg (int atnr) |
|
|
1856 | CODE: |
|
|
1857 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1858 | ? newSVpv (change_resist_msg [atnr], 0) |
|
|
1859 | : &PL_sv_undef; |
1832 | OUTPUT: RETVAL |
1860 | OUTPUT: RETVAL |
1833 | |
1861 | |
1834 | UUID |
1862 | UUID |
1835 | uuid_cur () |
1863 | uuid_cur () |
1836 | CODE: |
1864 | CODE: |
… | |
… | |
1959 | int mortals_size () |
1987 | int mortals_size () |
1960 | CODE: |
1988 | CODE: |
1961 | RETVAL = attachable::mortals.size (); |
1989 | RETVAL = attachable::mortals.size (); |
1962 | OUTPUT: RETVAL |
1990 | OUTPUT: RETVAL |
1963 | |
1991 | |
1964 | const_utf8_string slot_use_name (U32 slot) |
1992 | const_utf8_string slot_name (U32 slot) |
1965 | ALIAS: |
1993 | ALIAS: |
|
|
1994 | slot_name = 0 |
|
|
1995 | slot_use_name = 1 |
1966 | slot_nonuse_name = 1 |
1996 | slot_nonuse_name = 2 |
1967 | CODE: |
1997 | CODE: |
1968 | { |
1998 | { |
1969 | if (slot >= NUM_BODY_LOCATIONS) |
1999 | if (slot >= NUM_BODY_LOCATIONS) |
1970 | croak ("body slot index out of range"); |
2000 | croak ("body slot index out of range"); |
1971 | |
2001 | |
1972 | switch (ix) |
2002 | switch (ix) |
1973 | { |
2003 | { |
|
|
2004 | case 0: RETVAL = body_locations[slot].name ; break; |
1974 | case 0: RETVAL = body_locations[slot].use_name; break; |
2005 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1975 | case 1: RETVAL = body_locations[slot].nonuse_name; break; |
2006 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1976 | } |
2007 | } |
1977 | } |
2008 | } |
1978 | OUTPUT: |
2009 | OUTPUT: |
1979 | RETVAL |
2010 | RETVAL |
1980 | |
2011 | |
… | |
… | |
2534 | } |
2565 | } |
2535 | OUTPUT: RETVAL |
2566 | OUTPUT: RETVAL |
2536 | |
2567 | |
2537 | # worst xs function of my life |
2568 | # worst xs function of my life |
2538 | bool |
2569 | bool |
2539 | _create_random_map (\ |
2570 | _create_random_map (maptile *self, SV *options) |
2540 | maptile *self,\ |
|
|
2541 | SV *options,\ |
|
|
2542 | val64 total_map_hp,\ |
|
|
2543 | region *region\ |
|
|
2544 | ) |
|
|
2545 | CODE: |
2571 | CODE: |
2546 | { |
2572 | { |
2547 | random_map_params rmp; |
2573 | random_map_params rmp ((HV *)SvRV (options)); |
2548 | |
|
|
2549 | rmp.hv = (HV *)SvREFCNT_inc_NN (SvRV (options)); |
|
|
2550 | |
|
|
2551 | assign (rmp.wall_name , rmp.get_str ("wall_name")); |
|
|
2552 | assign (rmp.monsterstyle , rmp.get_str ("monsterstyle")); |
|
|
2553 | assign (rmp.layoutstyle , rmp.get_str ("layoutstyle")); |
|
|
2554 | assign (rmp.doorstyle , rmp.get_str ("doorstyle")); |
|
|
2555 | assign (rmp.exit_on_final_map, rmp.get_str ("exit_on_final_map")); |
|
|
2556 | |
|
|
2557 | rmp.origin_map = rmp.get_str ("origin_map"); |
|
|
2558 | rmp.origin_x = rmp.get_iv ("origin_x"); |
|
|
2559 | rmp.origin_y = rmp.get_iv ("origin_y"); |
|
|
2560 | rmp.final_map = rmp.get_str ("final_map"); |
|
|
2561 | rmp.this_map = rmp.get_str ("this_map"); |
|
|
2562 | rmp.xsize = rmp.get_iv ("xsize"); |
|
|
2563 | rmp.ysize = rmp.get_iv ("ysize"); |
|
|
2564 | rmp.expand2x = rmp.get_iv ("expand2x"); |
|
|
2565 | rmp.layoutoptions1 = rmp.get_iv ("layoutoptions1"); |
|
|
2566 | rmp.layoutoptions2 = rmp.get_iv ("layoutoptions2"); |
|
|
2567 | rmp.layoutoptions3 = rmp.get_iv ("layoutoptions3"); |
|
|
2568 | rmp.symmetry = rmp.get_iv ("symmetry"); |
|
|
2569 | rmp.difficulty = rmp.get_iv ("difficulty"); |
|
|
2570 | rmp.difficulty_given = rmp.get_iv ("difficulty_given"); |
|
|
2571 | rmp.difficulty_increase = rmp.get_nv ("difficulty_increase"); |
|
|
2572 | rmp.dungeon_level = rmp.get_iv ("dungeon_level"); |
|
|
2573 | rmp.dungeon_depth = rmp.get_iv ("dungeon_depth"); |
|
|
2574 | rmp.orientation = rmp.get_iv ("orientation"); |
|
|
2575 | rmp.random_seed = rmp.get_uv ("random_seed"); |
|
|
2576 | rmp.total_map_hp = (uint64_t)total_map_hp; |
|
|
2577 | rmp.map_layout_style = rmp.get_iv ("map_layout_style"); |
|
|
2578 | rmp.symmetry_used = rmp.get_iv ("symmetry_used"); |
|
|
2579 | rmp.region = region; |
|
|
2580 | |
|
|
2581 | RETVAL = self->generate_random_map (&rmp); |
2574 | RETVAL = self->generate_random_map (&rmp); |
2582 | } |
2575 | } |
2583 | OUTPUT: |
2576 | OUTPUT: |
2584 | RETVAL |
2577 | RETVAL |
2585 | |
2578 | |
… | |
… | |
2757 | |
2750 | |
2758 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2751 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2759 | CODE: |
2752 | CODE: |
2760 | { |
2753 | { |
2761 | faceinfo *f = face_info (idx); assert (f); |
2754 | faceinfo *f = face_info (idx); assert (f); |
2762 | facedata *d = &(faceset ? f->data64 : f->data32); |
2755 | facedata *d = f->face + faceset; |
2763 | sv_to (data, d->data); |
2756 | sv_to (data, d->data); |
2764 | STRLEN clen; |
2757 | STRLEN clen; |
2765 | char *cdata = SvPVbyte (chksum, clen); |
2758 | char *cdata = SvPVbyte (chksum, clen); |
2766 | clen = min (CHKSUM_MAXLEN, clen); |
2759 | clen = min (CHKSUM_MAXLEN, clen); |
2767 | |
2760 | |
… | |
… | |
2919 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2912 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2920 | |
2913 | |
2921 | self->skip (); |
2914 | self->skip (); |
2922 | } |
2915 | } |
2923 | |
2916 | |
|
|
2917 | MODULE = cf PACKAGE = cf::layout |
|
|
2918 | |
|
|
2919 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
|
|
2920 | |