ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.388 by root, Wed Jun 30 01:57:54 2010 UTC vs.
Revision 1.405 by root, Wed May 4 19:04:45 2011 UTC

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 "noise.h"
34#include "evthread.h" 35#include "evthread.h"
35#include "sproto.h" 36#include "sproto.h"
36 37
37#include <unistd.h> 38#include <unistd.h>
38#if _POSIX_MEMLOCK 39#if _POSIX_MEMLOCK
66static int tick_inhibit; 67static int tick_inhibit;
67static int tick_pending; 68static int tick_pending;
68 69
69global gbl_ev; 70global gbl_ev;
70static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; 71static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map;
71static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; 72static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now, *sv_server_tick;
72static AV *av_reflect; 73static AV *av_reflect;
73 74
74bitset<NUM_EVENT_TYPES> ev_want_event; 75bitset<NUM_EVENT_TYPES> ev_want_event;
75bitset<NUM_TYPES> ev_want_type; 76bitset<NUM_TYPES> ev_want_type;
76 77
84 *stash_cf_client_wrap, 85 *stash_cf_client_wrap,
85 *stash_cf_arch_wrap, 86 *stash_cf_arch_wrap,
86 *stash_cf_party_wrap, 87 *stash_cf_party_wrap,
87 *stash_cf_region_wrap, 88 *stash_cf_region_wrap,
88 *stash_cf_living_wrap, 89 *stash_cf_living_wrap,
90 *stash_cf_layout_wrap,
89 *stash_ext_map_world; 91 *stash_ext_map_world;
90 92
91static SV 93static SV
92 *cv_cf_do_invoke, 94 *cv_cf_do_invoke,
93 *cv_cf__can_merge, 95 *cv_cf__can_merge,
539static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } 541static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); }
540static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } 542static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); }
541static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } 543static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); }
542static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 544static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
543static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } 545static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); }
546static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); }
544 547
545static inline SV *to_sv (object & v) { return to_sv (&v); } 548static inline SV *to_sv (object & v) { return to_sv (&v); }
546static inline SV *to_sv (living & v) { return to_sv (&v); } 549static inline SV *to_sv (living & v) { return to_sv (&v); }
547 550
548static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } 551static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); }
594static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } 597static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); }
595static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 598static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
596static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } 599static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); }
597static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } 600static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); }
598static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } 601static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); }
602static inline void sv_to (SV *sv, layout * &v) { v = (layout *) SvPTR_ornull (sv, "cf::layout"); }
599static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } 603static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); }
600static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } 604static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); }
601 605
602//static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } 606//static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
603static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } 607static 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); 1401 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1);
1398 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); 1402 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1);
1399 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); 1403 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1);
1400 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); 1404 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1);
1401 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); 1405 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1);
1406 stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1);
1402 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); 1407 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1);
1403 1408
1404 sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); 1409 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); 1410 sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV);
1411 sv_server_tick = get_sv ("cf::SERVER_TICK", 1); SvUPGRADE (sv_server_tick, SVt_IV);
1406 sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); 1412 sv_tick_start = get_sv ("cf::TICK_START" , 1); SvUPGRADE (sv_tick_start , SVt_NV);
1407 sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); 1413 sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV);
1408 1414
1409 cb_global = get_av ("cf::CB_GLOBAL", 1); 1415 cb_global = get_av ("cf::CB_GLOBAL", 1);
1410 cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); 1416 cb_attachable = get_av ("cf::CB_ATTACHABLE", 1);
1411 cb_object = get_av ("cf::CB_OBJECT", 1); 1417 cb_object = get_av ("cf::CB_OBJECT", 1);
1412 cb_player = get_av ("cf::CB_PLAYER", 1); 1418 cb_player = get_av ("cf::CB_PLAYER", 1);
1455# include "attackinc.h" 1461# include "attackinc.h"
1456# undef def 1462# undef def
1457# define def(uc, flags) const_iv (SK_ ## uc) 1463# define def(uc, flags) const_iv (SK_ ## uc)
1458# include "skillinc.h" 1464# include "skillinc.h"
1459# undef def 1465# undef def
1460 1466# define def(name, use, nonuse) const_iv (body_ ## name)
1461 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1467# include "slotinc.h"
1468# undef def
1462 1469
1463 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1470 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1464 1471
1465 const_iv (MAX_TIME) 1472 const_iv (MAX_TIME)
1466 const_iv (MAXSOCKBUF) 1473 const_iv (MAXSOCKBUF)
1479 1486
1480 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) 1487 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE)
1481 1488
1482 const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) 1489 const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE)
1483 const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) 1490 const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY)
1484
1485 const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING)
1486 const_iv (MAP_INACTIVE)
1487 1491
1488 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) 1492 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT)
1489 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) 1493 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP)
1490 1494
1491 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) 1495 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT)
1552 1556
1553 for_all_objects (op) 1557 for_all_objects (op)
1554 op->reattach (); 1558 op->reattach ();
1555} 1559}
1556 1560
1557# support function for map-world.ext
1558void _quantise (SV *data_sv, SV *plt_sv)
1559 CODE:
1560{
1561 if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV)
1562 croak ("_quantise called with invalid agruments");
1563
1564 plt_sv = SvRV (plt_sv);
1565 SV **plt = AvARRAY (plt_sv);
1566 int plt_count = AvFILL (plt_sv) + 1;
1567
1568 STRLEN len;
1569 char *data = SvPVbyte (data_sv, len);
1570 char *dst = data;
1571
1572 while (len >= 3)
1573 {
1574 for (SV **val_sv = plt + plt_count; val_sv-- > plt; )
1575 {
1576 char *val = SvPVX (*val_sv);
1577
1578 if (val [0] == data [0]
1579 && val [1] == data [1]
1580 && val [2] == data [2])
1581 {
1582 *dst++ = val [3];
1583 goto next;
1584 }
1585 }
1586
1587 croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d",
1588 (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2],
1589 dst - SvPVX (data_sv), len);
1590
1591 next:
1592 data += 3;
1593 len -= 3;
1594 }
1595
1596 SvCUR_set (data_sv, dst - SvPVX (data_sv));
1597}
1598
1599void init_anim () 1561void init_anim ()
1600 1562
1601void init_globals () 1563void init_globals ()
1602 1564
1603void init_attackmess () 1565void init_attackmess ()
1649 { 1611 {
1650 ev_async_send (EV_DEFAULT, &tick_watcher); 1612 ev_async_send (EV_DEFAULT, &tick_watcher);
1651 coroapi::cede (); 1613 coroapi::cede ();
1652 } 1614 }
1653 1615
1654void server_tick () 1616void one_tick ()
1655 CODE: 1617 CODE:
1656{ 1618{
1657 ev_now_update (EV_DEFAULT); 1619 ev_now_update (EV_DEFAULT);
1658 NOW = ev_now (EV_DEFAULT); 1620 NOW = ev_now (EV_DEFAULT);
1659 SvNV_set (sv_now, NOW); SvNOK_only (sv_now); 1621 SvNV_set (sv_now, NOW); SvNOK_only (sv_now);
1660 SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); 1622 SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start);
1661 runtime = SvNVX (sv_runtime); 1623 runtime = SvNVX (sv_runtime);
1662 1624
1625 one_tick ();
1626
1663 server_tick (); 1627 ++server_tick;
1628 SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick);
1664 1629
1665 ev_now_update (EV_DEFAULT); 1630 ev_now_update (EV_DEFAULT);
1666 NOW = ev_now (EV_DEFAULT); 1631 NOW = ev_now (EV_DEFAULT);
1667 SvNV_set (sv_now, NOW); SvNOK_only (sv_now); 1632 SvNV_set (sv_now, NOW); SvNOK_only (sv_now);
1633
1668 runtime += TICK; 1634 runtime += TICK;
1669 SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); 1635 SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime);
1670} 1636}
1671 1637
1672NV floor (NV x) 1638NV floor (NV x)
1771 1737
1772int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1738int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1773 INIT: 1739 INIT:
1774#if __GLIBC__ 1740#if __GLIBC__
1775 mallopt (M_TOP_PAD, 1024 * 1024); 1741 mallopt (M_TOP_PAD, 1024 * 1024);
1776 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); 1742 mallopt (M_MMAP_THRESHOLD, 1024 * 1024);
1777 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory 1743 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1744 if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10))
1778 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1745 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1779#endif 1746#endif
1780 1747
1781int munlockall () 1748int munlockall ()
1782 1749
1783#endif 1750#endif
1821int exp_to_level (val64 exp) 1788int exp_to_level (val64 exp)
1822 1789
1823val64 level_to_min_exp (int level) 1790val64 level_to_min_exp (int level)
1824 1791
1825SV * 1792SV *
1826resistance_to_string (int atnr) 1793attacktype_name (int atnr)
1827 CODE: 1794 CODE:
1828 if (atnr >= 0 && atnr < NROFATTACKS) 1795 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1796 ? newSVpv (attacktype_name [atnr], 0)
1797 : &PL_sv_undef;
1798 OUTPUT: RETVAL
1799
1800SV *
1801attacktype_desc (int atnr)
1802 CODE:
1803 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1804 ? newSVpv (attacktype_desc [atnr], 0)
1805 : &PL_sv_undef;
1806 OUTPUT: RETVAL
1807
1808SV *
1809resist_plus (int atnr)
1810 CODE:
1811 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1829 RETVAL = newSVpv (resist_plus[atnr], 0); 1812 ? newSVpv (resist_plus [atnr], 0)
1830 else 1813 : &PL_sv_undef;
1831 XSRETURN_UNDEF; 1814 OUTPUT: RETVAL
1815
1816SV *
1817change_resist_msg (int atnr)
1818 CODE:
1819 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1820 ? newSVpv (change_resist_msg [atnr], 0)
1821 : &PL_sv_undef;
1832 OUTPUT: RETVAL 1822 OUTPUT: RETVAL
1833 1823
1834UUID 1824UUID
1835uuid_cur () 1825uuid_cur ()
1836 CODE: 1826 CODE:
1959int mortals_size () 1949int mortals_size ()
1960 CODE: 1950 CODE:
1961 RETVAL = attachable::mortals.size (); 1951 RETVAL = attachable::mortals.size ();
1962 OUTPUT: RETVAL 1952 OUTPUT: RETVAL
1963 1953
1964const_utf8_string slot_use_name (U32 slot) 1954const_utf8_string slot_name (U32 slot)
1965 ALIAS: 1955 ALIAS:
1956 slot_name = 0
1957 slot_use_name = 1
1966 slot_nonuse_name = 1 1958 slot_nonuse_name = 2
1967 CODE: 1959 CODE:
1968{ 1960{
1969 if (slot >= NUM_BODY_LOCATIONS) 1961 if (slot >= NUM_BODY_LOCATIONS)
1970 croak ("body slot index out of range"); 1962 croak ("body slot index out of range");
1971 1963
1972 switch (ix) 1964 switch (ix)
1973 { 1965 {
1966 case 0: RETVAL = body_locations[slot].name ; break;
1974 case 0: RETVAL = body_locations[slot].use_name; break; 1967 case 1: RETVAL = body_locations[slot].use_name ; break;
1975 case 1: RETVAL = body_locations[slot].nonuse_name; break; 1968 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1976 } 1969 }
1977} 1970}
1978 OUTPUT: 1971 OUTPUT:
1979 RETVAL 1972 RETVAL
1980 1973
2112# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2105# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2113 2106
2114object *new (utf8_string archetype = 0) 2107object *new (utf8_string archetype = 0)
2115 PROTOTYPE: ;$ 2108 PROTOTYPE: ;$
2116 CODE: 2109 CODE:
2117 RETVAL = archetype ? get_archetype (archetype) : object::create (); 2110 RETVAL = archetype
2111 ? archetype::get (archetype)
2112 : object::create ();
2118 OUTPUT: 2113 OUTPUT:
2119 RETVAL 2114 RETVAL
2120 2115
2121object *generate (utf8_string arch, object *creator) 2116object *generate (utf8_string arch, object *creator)
2122 CODE: 2117 CODE:
2123 object *obj = get_archetype (arch); 2118 object *obj = archetype::get (arch);
2124 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2119 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2125 RETVAL = obj; 2120 RETVAL = obj;
2126 OUTPUT: 2121 OUTPUT:
2127 RETVAL 2122 RETVAL
2128 2123
2141 RETVAL = 0; 2136 RETVAL = 0;
2142} 2137}
2143 2138
2144shstr 2139shstr
2145object::kv_get (shstr key) 2140object::kv_get (shstr key)
2141 CODE:
2142 RETVAL = THIS->kv.get (key);
2143 OUTPUT:
2144 RETVAL
2146 2145
2147void 2146void
2148object::kv_del (shstr key) 2147object::kv_del (shstr key)
2148 CODE:
2149 THIS->kv.del (key);
2149 2150
2150void 2151void
2151object::kv_set (shstr key, shstr value) 2152object::kv_set (shstr key, shstr value)
2153 CODE:
2154 THIS->kv.set (key, value);
2152 2155
2153object *get_nearest_player (object *ob) 2156object *get_nearest_player (object *ob)
2154 ALIAS: nearest_player = 0 2157 ALIAS: nearest_player = 0
2155 PREINIT: 2158 PREINIT:
2156 extern object *get_nearest_player (object *); 2159 extern object *get_nearest_player (object *);
2359 if (pl->ob && pl->ob->map == THIS) 2362 if (pl->ob && pl->ob->map == THIS)
2360 PUSHs (sv_2mortal (to_sv (pl->ob))); 2363 PUSHs (sv_2mortal (to_sv (pl->ob)));
2361 } 2364 }
2362 2365
2363void 2366void
2367maptile::gen_quadmap (int x, int y, int z)
2368 CODE:
2369 gen_quadmap (THIS, x * 50, y * 50, z);
2370
2371void
2364maptile::add_underlay (SV *data, int offset, int stride, SV *palette) 2372maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2365 CODE: 2373 CODE:
2366{ 2374{
2367 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) 2375 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2368 croak ("maptile::add_underlay: palette must be arrayref"); 2376 croak ("maptile::add_underlay: palette must be arrayref");
2384 2392
2385 if (IN_RANGE_EXC (offs, 0, idxlen)) 2393 if (IN_RANGE_EXC (offs, 0, idxlen))
2386 { 2394 {
2387 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2395 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2388 { 2396 {
2389 object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); 2397 object *ob = archetype::get (cfSvPVutf8_nolen (*elem));
2390 ob->flag [FLAG_NO_MAP_SAVE] = true; 2398 ob->flag [FLAG_NO_MAP_SAVE] = true;
2391 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2399 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2392 2400
2393 if (ob->randomitems && !ob->above) 2401 if (ob->randomitems && !ob->above)
2394 { 2402 {
2398 op->flag [FLAG_NO_MAP_SAVE] = true; 2406 op->flag [FLAG_NO_MAP_SAVE] = true;
2399 // TODO: if this is a pickable object, then the item 2407 // TODO: if this is a pickable object, then the item
2400 // will at a bit weird - saving inside the player 2408 // will at a bit weird - saving inside the player
2401 // will clear the flag, but when the player drops 2409 // will clear the flag, but when the player drops
2402 // it without logging out, it keeps the flag. 2410 // it without logging out, it keeps the flag.
2403 // nobody ahs reported this, but this can be rather 2411 // nobody has reported this, but this can be rather
2404 // annoying on persistent maps. 2412 // annoying on persistent maps.
2405 } 2413 }
2406 } 2414 }
2407 } 2415 }
2408 } 2416 }
2409
2410 skip: ; 2417 skip: ;
2411 } 2418 }
2412} 2419}
2413 2420
2414void 2421void
2445 for (int x = 0; x < THIS->width; ++x) 2452 for (int x = 0; x < THIS->width; ++x)
2446 for (int y = 0; y < THIS->height; ++y) 2453 for (int y = 0; y < THIS->height; ++y)
2447 { 2454 {
2448 region *rgn = THIS->region (x, y); 2455 region *rgn = THIS->region (x, y);
2449 2456
2450 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D
2451 if (object *op = THIS->at (x, y).top) 2457 if (object *op = THIS->at (x, y).top)
2452 if (rgn->treasure && rndm () < rgn->treasure_density) 2458 if (rgn->treasure && rndm () < rgn->treasure_density)
2453 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2459 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2454 } 2460 }
2455 2461
2534} 2540}
2535 OUTPUT: RETVAL 2541 OUTPUT: RETVAL
2536 2542
2537# worst xs function of my life 2543# worst xs function of my life
2538bool 2544bool
2539_create_random_map (\ 2545_create_random_map (maptile *self, SV *options)
2540 maptile *self,\
2541 SV *options,\
2542 val64 total_map_hp,\
2543 region *region\
2544)
2545 CODE: 2546 CODE:
2546{ 2547{
2547 random_map_params rmp; 2548 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); 2549 RETVAL = self->generate_random_map (&rmp);
2582} 2550}
2583 OUTPUT: 2551 OUTPUT:
2584 RETVAL 2552 RETVAL
2585 2553
2757 2725
2758void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2726void set_data (faceidx idx, int faceset, SV *data, SV *chksum)
2759 CODE: 2727 CODE:
2760{ 2728{
2761 faceinfo *f = face_info (idx); assert (f); 2729 faceinfo *f = face_info (idx); assert (f);
2762 facedata *d = &(faceset ? f->data64 : f->data32); 2730 facedata *d = f->face + faceset;
2763 sv_to (data, d->data); 2731 sv_to (data, d->data);
2764 STRLEN clen; 2732 STRLEN clen;
2765 char *cdata = SvPVbyte (chksum, clen); 2733 char *cdata = SvPVbyte (chksum, clen);
2766 clen = min (CHKSUM_MAXLEN, clen); 2734 clen = min (CHKSUM_MAXLEN, clen);
2767 2735
2919 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); 2887 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ())));
2920 2888
2921 self->skip (); 2889 self->skip ();
2922 } 2890 }
2923 2891
2892MODULE = cf PACKAGE = cf::layout
2893
2894INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h |
2895

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines