… | |
… | |
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, |
… | |
… | |
122 | |
123 | |
123 | return sv; |
124 | return sv; |
124 | } |
125 | } |
125 | #endif |
126 | #endif |
126 | |
127 | |
127 | static noinline utf8_string |
128 | noinline utf8_string |
128 | cfSvPVutf8_nolen (SV *sv) |
129 | cfSvPVutf8_nolen (SV *sv) |
129 | { |
130 | { |
130 | SvGETMAGIC (sv); |
131 | SvGETMAGIC (sv); |
131 | |
132 | |
132 | if (SvPOK (sv)) |
133 | if (SvPOK (sv)) |
… | |
… | |
352 | #endif |
353 | #endif |
353 | |
354 | |
354 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | |
356 | |
356 | static SV * |
357 | static SV * |
357 | newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) |
358 | newSVptr (void *ptr, HV *stash, HV *hv) |
358 | { |
359 | { |
359 | SV *sv; |
|
|
360 | |
|
|
361 | if (!ptr) |
360 | if (!ptr) |
362 | return newSV (0); |
361 | return newSV (0); |
363 | |
362 | |
364 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
363 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
365 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
364 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
|
|
365 | } |
|
|
366 | |
|
|
367 | static SV * noinline |
|
|
368 | newSVptr (void *ptr, HV *stash) |
|
|
369 | { |
|
|
370 | return newSVptr (ptr, stash, newHV ()); |
366 | } |
371 | } |
367 | |
372 | |
368 | static int |
373 | static int |
369 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
374 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
370 | { |
375 | { |
… | |
… | |
382 | return 0; |
387 | return 0; |
383 | } |
388 | } |
384 | |
389 | |
385 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
390 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
386 | |
391 | |
387 | static SV * |
392 | static SV * noinline |
388 | newSVattachable (attachable *obj, HV *stash) |
393 | newSVattachable (attachable *obj, HV *stash) |
389 | { |
394 | { |
390 | if (!obj) |
395 | if (!obj) |
391 | return newSV (0); |
396 | return newSV (0); |
392 | |
397 | |
… | |
… | |
526 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
531 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
527 | static inline SV *to_sv (float v) { return newSVnv (v); } |
532 | static inline SV *to_sv (float v) { return newSVnv (v); } |
528 | static inline SV *to_sv (double v) { return newSVnv (v); } |
533 | static inline SV *to_sv (double v) { return newSVnv (v); } |
529 | static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
534 | static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
530 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
535 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
|
|
536 | // gcc dislikes noilnine on to_sv |
531 | static inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
537 | static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
|
|
538 | static inline SV *to_sv (object * v) { return to_sv_ni (v); } |
532 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
539 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
533 | 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); } |
534 | 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); } |
535 | 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); } |
536 | 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); } |
537 | 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); } |
538 | |
546 | |
539 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
547 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
540 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
548 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
541 | |
549 | |
542 | 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 ()); } |
… | |
… | |
588 | 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"); } |
589 | 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"); } |
590 | 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"); } |
591 | 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"); } |
592 | 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"); } |
593 | 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"); } |
594 | 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" ); } |
595 | |
604 | |
596 | //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)]; } |
597 | 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)); } |
… | |
… | |
764 | exit (EXIT_FAILURE); |
773 | exit (EXIT_FAILURE); |
765 | } |
774 | } |
766 | |
775 | |
767 | eval_pv ( |
776 | eval_pv ( |
768 | "#line 1 'cfperl init'\n" |
777 | "#line 1 'cfperl init'\n" |
769 | "use EV ();\n" |
778 | "use EV ();\n" // required by bootstrap |
770 | "use Coro ();\n" |
779 | "use Coro ();\n" // required by bootstrap |
771 | "cf->bootstrap;\n" |
780 | "cf->bootstrap;\n" // required for cf::datadir |
772 | "unshift @INC, cf::datadir ();\n" |
781 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
773 | "require cf;\n", |
782 | "require cf;\n", |
774 | 0 |
783 | 0 |
775 | ); |
784 | ); |
776 | |
785 | |
777 | if (SvTRUE (ERRSV)) |
786 | if (SvTRUE (ERRSV)) |
… | |
… | |
1391 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1400 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1392 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1401 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1393 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1402 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1394 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1403 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1395 | 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); |
1396 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1406 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1397 | |
1407 | |
1398 | 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); |
1399 | 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); |
1400 | 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); |
… | |
… | |
1449 | # include "attackinc.h" |
1459 | # include "attackinc.h" |
1450 | # undef def |
1460 | # undef def |
1451 | # define def(uc, flags) const_iv (SK_ ## uc) |
1461 | # define def(uc, flags) const_iv (SK_ ## uc) |
1452 | # include "skillinc.h" |
1462 | # include "skillinc.h" |
1453 | # undef def |
1463 | # undef def |
1454 | |
1464 | # define def(name, use, nonuse) const_iv (body_ ## name) |
1455 | const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) |
1465 | # include "slotinc.h" |
1456 | const_iv (logBacktrace) |
1466 | # undef def |
1457 | |
|
|
1458 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
|
|
1459 | |
1467 | |
1460 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1468 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1461 | |
1469 | |
1462 | const_iv (MAX_TIME) |
1470 | const_iv (MAX_TIME) |
1463 | const_iv (MAXSOCKBUF) |
1471 | const_iv (MAXSOCKBUF) |
… | |
… | |
1488 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1496 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1489 | |
1497 | |
1490 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1498 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1491 | }; |
1499 | }; |
1492 | |
1500 | |
1493 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1501 | for (civ = const_iv + array_length (const_iv); civ-- > const_iv; ) |
1494 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1502 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1495 | |
1503 | |
1496 | static const struct { |
1504 | static const struct { |
1497 | const char *name; |
1505 | const char *name; |
1498 | int skip; |
1506 | int skip; |
… | |
… | |
1504 | # undef def |
1512 | # undef def |
1505 | }; |
1513 | }; |
1506 | |
1514 | |
1507 | AV *av = get_av ("cf::EVENT", 1); |
1515 | AV *av = get_av ("cf::EVENT", 1); |
1508 | |
1516 | |
1509 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1517 | for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; ) |
1510 | { |
1518 | { |
1511 | AV *event = newAV (); |
1519 | AV *event = newAV (); |
1512 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1520 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1513 | av_push (event, newSViv (eiv->klass)); |
1521 | av_push (event, newSViv (eiv->klass)); |
1514 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1522 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1595 | |
1603 | |
1596 | void init_anim () |
1604 | void init_anim () |
1597 | |
1605 | |
1598 | void init_globals () |
1606 | void init_globals () |
1599 | |
1607 | |
1600 | void init_experience () |
|
|
1601 | |
|
|
1602 | void init_attackmess () |
1608 | void init_attackmess () |
1603 | |
1609 | |
1604 | void init_dynamic () |
1610 | void init_dynamic () |
1605 | |
1611 | |
1606 | void load_settings () |
1612 | void load_settings () |
1607 | |
1613 | |
|
|
1614 | void reload_exp_table () |
|
|
1615 | |
1608 | void load_materials () |
1616 | void reload_materials () |
1609 | |
1617 | |
1610 | void init_uuid () |
1618 | void init_uuid () |
1611 | CODE: |
1619 | CODE: |
1612 | UUID::init (); |
1620 | UUID::init (); |
1613 | |
1621 | |
… | |
… | |
1768 | |
1776 | |
1769 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1777 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1770 | INIT: |
1778 | INIT: |
1771 | #if __GLIBC__ |
1779 | #if __GLIBC__ |
1772 | mallopt (M_TOP_PAD, 1024 * 1024); |
1780 | mallopt (M_TOP_PAD, 1024 * 1024); |
1773 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); |
1781 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024); |
1774 | 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)) |
1775 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1784 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1776 | #endif |
1785 | #endif |
1777 | |
1786 | |
1778 | int munlockall () |
1787 | int munlockall () |
1779 | |
1788 | |
1780 | #endif |
1789 | #endif |
… | |
… | |
1818 | int exp_to_level (val64 exp) |
1827 | int exp_to_level (val64 exp) |
1819 | |
1828 | |
1820 | val64 level_to_min_exp (int level) |
1829 | val64 level_to_min_exp (int level) |
1821 | |
1830 | |
1822 | SV * |
1831 | SV * |
1823 | resistance_to_string (int atnr) |
1832 | attacktype_name (int atnr) |
1824 | CODE: |
1833 | CODE: |
1825 | 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) |
1826 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1851 | ? newSVpv (resist_plus [atnr], 0) |
1827 | else |
1852 | : &PL_sv_undef; |
1828 | 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; |
1829 | OUTPUT: RETVAL |
1861 | OUTPUT: RETVAL |
1830 | |
1862 | |
1831 | UUID |
1863 | UUID |
1832 | uuid_cur () |
1864 | uuid_cur () |
1833 | CODE: |
1865 | CODE: |
… | |
… | |
1956 | int mortals_size () |
1988 | int mortals_size () |
1957 | CODE: |
1989 | CODE: |
1958 | RETVAL = attachable::mortals.size (); |
1990 | RETVAL = attachable::mortals.size (); |
1959 | OUTPUT: RETVAL |
1991 | OUTPUT: RETVAL |
1960 | |
1992 | |
1961 | const_utf8_string slot_use_name (U32 slot) |
1993 | const_utf8_string slot_name (U32 slot) |
1962 | ALIAS: |
1994 | ALIAS: |
|
|
1995 | slot_name = 0 |
|
|
1996 | slot_use_name = 1 |
1963 | slot_nonuse_name = 1 |
1997 | slot_nonuse_name = 2 |
1964 | CODE: |
1998 | CODE: |
1965 | { |
1999 | { |
1966 | if (slot >= NUM_BODY_LOCATIONS) |
2000 | if (slot >= NUM_BODY_LOCATIONS) |
1967 | croak ("body slot index out of range"); |
2001 | croak ("body slot index out of range"); |
1968 | |
2002 | |
1969 | switch (ix) |
2003 | switch (ix) |
1970 | { |
2004 | { |
|
|
2005 | case 0: RETVAL = body_locations[slot].name ; break; |
1971 | case 0: RETVAL = body_locations[slot].use_name; break; |
2006 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1972 | case 1: RETVAL = body_locations[slot].nonuse_name; break; |
2007 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1973 | } |
2008 | } |
1974 | } |
2009 | } |
1975 | OUTPUT: |
2010 | OUTPUT: |
1976 | RETVAL |
2011 | RETVAL |
1977 | |
2012 | |
… | |
… | |
2083 | |
2118 | |
2084 | void pick_up (object *who, object *op) |
2119 | void pick_up (object *who, object *op) |
2085 | |
2120 | |
2086 | void update_object (object *op, int action) |
2121 | void update_object (object *op, int action) |
2087 | |
2122 | |
2088 | void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) |
2123 | void change_exp (object *op, uint64 exp, shstr_tmp skill_name = shstr_tmp (), int flag = 0) |
2089 | |
2124 | |
2090 | void player_lvl_adj (object *who, object *skill = 0) |
2125 | void player_lvl_adj (object *who, object *skill = 0) |
2091 | |
2126 | |
2092 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2127 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2093 | |
2128 | |
… | |
… | |
2531 | } |
2566 | } |
2532 | OUTPUT: RETVAL |
2567 | OUTPUT: RETVAL |
2533 | |
2568 | |
2534 | # worst xs function of my life |
2569 | # worst xs function of my life |
2535 | bool |
2570 | bool |
2536 | _create_random_map (\ |
2571 | _create_random_map (maptile *self, SV *options) |
2537 | maptile *self,\ |
|
|
2538 | utf8_string wallstyle,\ |
|
|
2539 | utf8_string wall_name,\ |
|
|
2540 | utf8_string floorstyle,\ |
|
|
2541 | utf8_string monsterstyle,\ |
|
|
2542 | utf8_string treasurestyle,\ |
|
|
2543 | utf8_string layoutstyle,\ |
|
|
2544 | utf8_string doorstyle,\ |
|
|
2545 | utf8_string decorstyle,\ |
|
|
2546 | utf8_string miningstyle,\ |
|
|
2547 | utf8_string origin_map,\ |
|
|
2548 | utf8_string final_map,\ |
|
|
2549 | utf8_string exitstyle,\ |
|
|
2550 | utf8_string this_map,\ |
|
|
2551 | utf8_string exit_on_final_map,\ |
|
|
2552 | int xsize,\ |
|
|
2553 | int ysize,\ |
|
|
2554 | int expand2x,\ |
|
|
2555 | int layoutoptions1,\ |
|
|
2556 | int layoutoptions2,\ |
|
|
2557 | int layoutoptions3,\ |
|
|
2558 | int symmetry,\ |
|
|
2559 | int difficulty,\ |
|
|
2560 | int difficulty_given,\ |
|
|
2561 | float difficulty_increase,\ |
|
|
2562 | int dungeon_level,\ |
|
|
2563 | int dungeon_depth,\ |
|
|
2564 | int decoroptions,\ |
|
|
2565 | int orientation,\ |
|
|
2566 | int origin_y,\ |
|
|
2567 | int origin_x,\ |
|
|
2568 | U32 random_seed,\ |
|
|
2569 | val64 total_map_hp,\ |
|
|
2570 | int map_layout_style,\ |
|
|
2571 | int treasureoptions,\ |
|
|
2572 | int symmetry_used,\ |
|
|
2573 | region *region,\ |
|
|
2574 | utf8_string custom\ |
|
|
2575 | ) |
|
|
2576 | CODE: |
2572 | CODE: |
2577 | { |
2573 | { |
2578 | random_map_params rmp; |
2574 | random_map_params rmp ((HV *)SvRV (options)); |
2579 | |
|
|
2580 | assign (rmp.wallstyle , wallstyle); |
|
|
2581 | assign (rmp.wall_name , wall_name); |
|
|
2582 | assign (rmp.floorstyle , floorstyle); |
|
|
2583 | assign (rmp.monsterstyle , monsterstyle); |
|
|
2584 | assign (rmp.treasurestyle , treasurestyle); |
|
|
2585 | assign (rmp.layoutstyle , layoutstyle); |
|
|
2586 | assign (rmp.doorstyle , doorstyle); |
|
|
2587 | assign (rmp.decorstyle , decorstyle); |
|
|
2588 | assign (rmp.miningstyle , miningstyle); |
|
|
2589 | assign (rmp.exitstyle , exitstyle); |
|
|
2590 | assign (rmp.exit_on_final_map, exit_on_final_map); |
|
|
2591 | |
|
|
2592 | rmp.origin_map = origin_map; |
|
|
2593 | rmp.final_map = final_map; |
|
|
2594 | rmp.this_map = this_map; |
|
|
2595 | rmp.xsize = xsize; |
|
|
2596 | rmp.ysize = ysize; |
|
|
2597 | rmp.expand2x = expand2x; |
|
|
2598 | rmp.layoutoptions1 = layoutoptions1; |
|
|
2599 | rmp.layoutoptions2 = layoutoptions2; |
|
|
2600 | rmp.layoutoptions3 = layoutoptions3; |
|
|
2601 | rmp.symmetry = symmetry; |
|
|
2602 | rmp.difficulty = difficulty; |
|
|
2603 | rmp.difficulty_given = difficulty_given; |
|
|
2604 | rmp.difficulty_increase = difficulty_increase; |
|
|
2605 | rmp.dungeon_level = dungeon_level; |
|
|
2606 | rmp.dungeon_depth = dungeon_depth; |
|
|
2607 | rmp.decoroptions = decoroptions; |
|
|
2608 | rmp.orientation = orientation; |
|
|
2609 | rmp.origin_y = origin_y; |
|
|
2610 | rmp.origin_x = origin_x; |
|
|
2611 | rmp.random_seed = random_seed; |
|
|
2612 | rmp.total_map_hp = (uint64_t) total_map_hp; |
|
|
2613 | rmp.map_layout_style = map_layout_style; |
|
|
2614 | rmp.treasureoptions = treasureoptions; |
|
|
2615 | rmp.symmetry_used = symmetry_used; |
|
|
2616 | rmp.region = region; |
|
|
2617 | rmp.custom = custom; |
|
|
2618 | |
|
|
2619 | RETVAL = self->generate_random_map (&rmp); |
2575 | RETVAL = self->generate_random_map (&rmp); |
2620 | } |
2576 | } |
2621 | OUTPUT: |
2577 | OUTPUT: |
2622 | RETVAL |
2578 | RETVAL |
2623 | |
2579 | |
… | |
… | |
2654 | void |
2610 | void |
2655 | list () |
2611 | list () |
2656 | PPCODE: |
2612 | PPCODE: |
2657 | for_all_regions (rgn) |
2613 | for_all_regions (rgn) |
2658 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2614 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2659 | |
|
|
2660 | region *find (utf8_string name) |
|
|
2661 | PROTOTYPE: $ |
|
|
2662 | CODE: |
|
|
2663 | RETVAL = region::find (name); |
|
|
2664 | OUTPUT: RETVAL |
|
|
2665 | |
2615 | |
2666 | int specificity (region *rgn) |
2616 | int specificity (region *rgn) |
2667 | CODE: |
2617 | CODE: |
2668 | RETVAL = 0; |
2618 | RETVAL = 0; |
2669 | while (rgn = rgn->parent) |
2619 | while (rgn = rgn->parent) |
… | |
… | |
2801 | |
2751 | |
2802 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2752 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2803 | CODE: |
2753 | CODE: |
2804 | { |
2754 | { |
2805 | faceinfo *f = face_info (idx); assert (f); |
2755 | faceinfo *f = face_info (idx); assert (f); |
2806 | facedata *d = &(faceset ? f->data64 : f->data32); |
2756 | facedata *d = f->face + faceset; |
2807 | sv_to (data, d->data); |
2757 | sv_to (data, d->data); |
2808 | STRLEN clen; |
2758 | STRLEN clen; |
2809 | char *cdata = SvPVbyte (chksum, clen); |
2759 | char *cdata = SvPVbyte (chksum, clen); |
2810 | clen = min (CHKSUM_MAXLEN, clen); |
2760 | clen = min (CHKSUM_MAXLEN, clen); |
2811 | |
2761 | |
… | |
… | |
2963 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2913 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2964 | |
2914 | |
2965 | self->skip (); |
2915 | self->skip (); |
2966 | } |
2916 | } |
2967 | |
2917 | |
|
|
2918 | MODULE = cf PACKAGE = cf::layout |
|
|
2919 | |
|
|
2920 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
|
|
2921 | |