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.389 by root, Fri Jul 2 15:03:57 2010 UTC vs.
Revision 1.425 by root, Wed Nov 14 06:21:39 2012 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2006,2007,2008,2009,2010,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 6 * Deliantra is free software: you can redistribute it and/or modify it under
7 * the terms of the Affero GNU General Public License as published by the 7 * the terms of the Affero GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 9 * option) any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the Affero GNU General Public License 16 * You should have received a copy of the Affero GNU General Public License
17 * and the GNU General Public License along with this program. If not, see 17 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>. 18 * <http://www.gnu.org/licenses/>.
19 * 19 *
20 * The authors can be reached via e-mail to <support@deliantra.net> 20 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 21 */
22 22
23#include "autoconf.h" 23#include "autoconf.h"
24 24
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
91 92
92static SV 93static SV
93 *cv_cf_do_invoke, 94 *cv_cf_do_invoke,
94 *cv_cf__can_merge, 95 *cv_cf__can_merge,
95 *cv_cf_client_send_msg, 96 *cv_cf_client_send_msg,
97 *cv_cf_ix,
96 *cv_cf_tick, 98 *cv_cf_tick,
97 *cv_cf_match_match; 99 *cv_cf_match_match;
98 100
99#ifndef newSVpv_utf8 101#ifndef newSVpv_utf8
100static SV * 102static SV *
252 { 254 {
253 static int last_mortalcount; 255 static int last_mortalcount;
254 if (mortals.size () != last_mortalcount) 256 if (mortals.size () != last_mortalcount)
255 { 257 {
256 last_mortalcount = mortals.size (); 258 last_mortalcount = mortals.size ();
257 LOG (llevInfo, "%d mortals.\n", (int)mortals.size ()); 259 object *specimen = is_a<object> (mortals [rndm (mortals.size ())]);
260
261 LOG (llevInfo, "%d mortals (random specimen: %s).\n",
262 (int)mortals.size (), specimen ? specimen->debug_desc () : "(not an object)");
258 263
259 if (0) 264 if (0)
260 { 265 {
261 for (int j = 0; j < mortals.size (); ++j)//D 266 for (int j = 0; j < mortals.size (); ++j)//D
262 fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D 267 fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D
621 STRLEN len; 626 STRLEN len;
622 char *data = SvPVbyte (sv, len); 627 char *data = SvPVbyte (sv, len);
623 v.assign (data, len); 628 v.assign (data, len);
624} 629}
625 630
631static inline void sv_to (SV *sv, refcnt_buf &v)
632{
633 STRLEN len;
634 char *data = SvPVbyte (sv, len);
635 refcnt_buf buf (data, len);
636 v = buf;
637}
638
626static inline void sv_to (SV *sv, UUID &v) 639static inline void sv_to (SV *sv, UUID &v)
627{ 640{
628 if (!v.parse (SvPV_nolen (sv))) 641 if (!v.parse (SvPV_nolen (sv)))
629 croak ("unparsable uuid: %s", SvPV_nolen (sv)); 642 croak ("unparsable uuid: %s", SvPV_nolen (sv));
630} 643}
1145 CALL_ARG (originator); 1158 CALL_ARG (originator);
1146 CALL_CALL ("cf::mapscript::activate", G_VOID); 1159 CALL_CALL ("cf::mapscript::activate", G_VOID);
1147 CALL_END; 1160 CALL_END;
1148} 1161}
1149 1162
1163void cfperl_ix (client *ns, int set, faceidx idx, int pri)
1164{
1165 CALL_BEGIN (3);
1166 CALL_ARG (ns);
1167 CALL_ARG (set);
1168 CALL_ARG (idx);
1169 CALL_ARG (pri);
1170 CALL_CALL (cv_cf_ix, G_VOID);
1171 CALL_END;
1172}
1173
1150player * 1174player *
1151player::find (const_utf8_string name) 1175player::find (const_utf8_string name)
1152{ 1176{
1153 CALL_BEGIN (1); 1177 CALL_BEGIN (1);
1154 CALL_ARG (name); 1178 CALL_ARG (name);
1403 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); 1427 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1);
1404 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); 1428 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1);
1405 stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); 1429 stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1);
1406 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); 1430 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1);
1407 1431
1408 sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); 1432 sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV);
1409 sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); 1433 sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV);
1434 sv_server_tick = get_sv ("cf::SERVER_TICK", 1); SvUPGRADE (sv_server_tick, SVt_IV);
1410 sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); 1435 sv_tick_start = get_sv ("cf::TICK_START" , 1); SvUPGRADE (sv_tick_start , SVt_NV);
1411 sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); 1436 sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV);
1412 1437
1413 cb_global = get_av ("cf::CB_GLOBAL", 1); 1438 cb_global = get_av ("cf::CB_GLOBAL", 1);
1414 cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); 1439 cb_attachable = get_av ("cf::CB_ATTACHABLE", 1);
1415 cb_object = get_av ("cf::CB_OBJECT", 1); 1440 cb_object = get_av ("cf::CB_OBJECT", 1);
1416 cb_player = get_av ("cf::CB_PLAYER", 1); 1441 cb_player = get_av ("cf::CB_PLAYER", 1);
1423_connect_to_perl_2 () 1448_connect_to_perl_2 ()
1424{ 1449{
1425 cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke); 1450 cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke);
1426 cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge); 1451 cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge);
1427 cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg); 1452 cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg);
1453 cv_cf_ix = (SV *)get_cv ("cf::face::ix" , 0); assert (cv_cf_ix);
1428 cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick); 1454 cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick);
1429 cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match); 1455 cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match);
1430} 1456}
1431 1457
1432MODULE = cf PACKAGE = cf PREFIX = cf_ 1458MODULE = cf PACKAGE = cf PREFIX = cf_
1437 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1463 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1438 1464
1439 _connect_to_perl_1 (); 1465 _connect_to_perl_1 ();
1440 1466
1441 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1467 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1442
1443 //{
1444 // require_pv ("Time::HiRes");
1445 //
1446 // SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0);
1447 // if (!svp) croak ("Time::HiRes is required");
1448 // if (!SvIOK(*svp)) croak ("Time::NVtime isn’t a function pointer");
1449 // coroapi::time = INT2PTR (double(*)(), SvIV(*svp));
1450 //}
1451 1468
1452 static const struct { 1469 static const struct {
1453 const char *name; 1470 const char *name;
1454 IV iv; 1471 IV iv;
1455 } *civ, const_iv[] = { 1472 } *civ, const_iv[] = {
1459# include "attackinc.h" 1476# include "attackinc.h"
1460# undef def 1477# undef def
1461# define def(uc, flags) const_iv (SK_ ## uc) 1478# define def(uc, flags) const_iv (SK_ ## uc)
1462# include "skillinc.h" 1479# include "skillinc.h"
1463# undef def 1480# undef def
1464 1481# define def(name, use, nonuse) const_iv (body_ ## name)
1465 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1482# include "slotinc.h"
1483# undef def
1466 1484
1467 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1485 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1468 1486
1469 const_iv (MAX_TIME) 1487 const_iv (MAX_TIME)
1470 const_iv (MAXSOCKBUF) 1488 const_iv (MAXSOCKBUF)
1483 1501
1484 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) 1502 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE)
1485 1503
1486 const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) 1504 const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE)
1487 const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) 1505 const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY)
1488
1489 const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING)
1490 const_iv (MAP_INACTIVE)
1491 1506
1492 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) 1507 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT)
1493 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) 1508 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP)
1494 1509
1495 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) 1510 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT)
1528 1543
1529void _gv_clear (SV *gv) 1544void _gv_clear (SV *gv)
1530 CODE: 1545 CODE:
1531 assert (SvTYPE (gv) == SVt_PVGV); 1546 assert (SvTYPE (gv) == SVt_PVGV);
1532# define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } 1547# define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); }
1548 SvREFCNT_inc (gv);
1533 f (GvGP (gv)->gp_form); 1549 f (GvGP (gv)->gp_form);
1534 f (GvGP (gv)->gp_io); 1550 f (GvGP (gv)->gp_io);
1535 f (GvGP (gv)->gp_sv); 1551 f (GvGP (gv)->gp_sv);
1536 f (GvGP (gv)->gp_av); 1552 f (GvGP (gv)->gp_av);
1537 f (GvGP (gv)->gp_hv); 1553 f (GvGP (gv)->gp_hv);
1538 f (GvGP (gv)->gp_cv); 1554 f (GvGP (gv)->gp_cv);
1539 GvCVGEN (gv) = 0; 1555 GvCVGEN (gv) = 0;
1540 GvMULTI_off (gv); 1556 GvMULTI_off (gv);
1557 SvREFCNT_dec (gv);
1541# undef f 1558# undef f
1542 1559
1543void _connect_to_perl_1 () 1560void _connect_to_perl_1 ()
1544 1561
1545void _connect_to_perl_2 () 1562void _connect_to_perl_2 ()
1556 1573
1557 for_all_objects (op) 1574 for_all_objects (op)
1558 op->reattach (); 1575 op->reattach ();
1559} 1576}
1560 1577
1561# support function for map-world.ext
1562void _quantise (SV *data_sv, SV *plt_sv)
1563 CODE:
1564{
1565 if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV)
1566 croak ("_quantise called with invalid agruments");
1567
1568 plt_sv = SvRV (plt_sv);
1569 SV **plt = AvARRAY (plt_sv);
1570 int plt_count = AvFILL (plt_sv) + 1;
1571
1572 STRLEN len;
1573 char *data = SvPVbyte (data_sv, len);
1574 char *dst = data;
1575
1576 while (len >= 3)
1577 {
1578 for (SV **val_sv = plt + plt_count; val_sv-- > plt; )
1579 {
1580 char *val = SvPVX (*val_sv);
1581
1582 if (val [0] == data [0]
1583 && val [1] == data [1]
1584 && val [2] == data [2])
1585 {
1586 *dst++ = val [3];
1587 goto next;
1588 }
1589 }
1590
1591 croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d",
1592 (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2],
1593 dst - SvPVX (data_sv), len);
1594
1595 next:
1596 data += 3;
1597 len -= 3;
1598 }
1599
1600 SvCUR_set (data_sv, dst - SvPVX (data_sv));
1601}
1602
1603void init_anim () 1578void init_anim ()
1604 1579
1605void init_globals () 1580void init_globals ()
1606 1581
1607void init_attackmess () 1582void init_attackmess ()
1608 1583
1609void init_dynamic () 1584void init_dynamic ()
1610 1585
1611void load_settings () 1586void load_settings ()
1612 1587
1613void reload_exp_table () 1588void _reload_exp_table ()
1614 1589
1615void reload_materials () 1590void _reload_materials ()
1616 1591
1617void init_uuid () 1592void init_uuid ()
1618 CODE: 1593 CODE:
1619 UUID::init (); 1594 UUID::init ();
1620 1595
1653 { 1628 {
1654 ev_async_send (EV_DEFAULT, &tick_watcher); 1629 ev_async_send (EV_DEFAULT, &tick_watcher);
1655 coroapi::cede (); 1630 coroapi::cede ();
1656 } 1631 }
1657 1632
1658void server_tick () 1633void one_tick ()
1659 CODE: 1634 CODE:
1660{ 1635{
1661 ev_now_update (EV_DEFAULT); 1636 ev_now_update (EV_DEFAULT);
1662 NOW = ev_now (EV_DEFAULT); 1637 NOW = ev_now (EV_DEFAULT);
1663 SvNV_set (sv_now, NOW); SvNOK_only (sv_now); 1638 SvNV_set (sv_now, NOW); SvNOK_only (sv_now);
1664 SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); 1639 SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start);
1665 runtime = SvNVX (sv_runtime); 1640 runtime = SvNVX (sv_runtime);
1666 1641
1642 one_tick ();
1643
1667 server_tick (); 1644 ++server_tick;
1645 SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick);
1668 1646
1669 ev_now_update (EV_DEFAULT); 1647 ev_now_update (EV_DEFAULT);
1670 NOW = ev_now (EV_DEFAULT); 1648 NOW = ev_now (EV_DEFAULT);
1671 SvNV_set (sv_now, NOW); SvNOK_only (sv_now); 1649 SvNV_set (sv_now, NOW); SvNOK_only (sv_now);
1650
1672 runtime += TICK; 1651 runtime += TICK;
1673 SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); 1652 SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime);
1674} 1653}
1675 1654
1676NV floor (NV x) 1655NV floor (NV x)
1680NV rndm (...) 1659NV rndm (...)
1681 ALIAS: 1660 ALIAS:
1682 rmg_rndm = 1 1661 rmg_rndm = 1
1683 CODE: 1662 CODE:
1684{ 1663{
1685 rand_gen &gen = ix ? rmg_rndm : rndm; 1664 rand_gen &gen = ix ? rmg_rndm : rndm;
1686 switch (items) 1665 switch (items)
1687 { 1666 {
1688 case 0: RETVAL = gen (); break; 1667 case 0: RETVAL = gen (); break;
1689 case 1: RETVAL = gen (SvUV (ST (0))); break; 1668 case 1: RETVAL = gen (SvUV (ST (0))); break;
1690 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; 1669 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break;
1775 1754
1776int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1755int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1777 INIT: 1756 INIT:
1778#if __GLIBC__ 1757#if __GLIBC__
1779 mallopt (M_TOP_PAD, 1024 * 1024); 1758 mallopt (M_TOP_PAD, 1024 * 1024);
1780 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); 1759 mallopt (M_MMAP_THRESHOLD, 1024 * 1024);
1781 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory 1760 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1761 if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10))
1782 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1762 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1783#endif 1763#endif
1784 1764
1785int munlockall () 1765int munlockall ()
1786 1766
1787#endif 1767#endif
1813 PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); 1793 PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object))));
1814 PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count))); 1794 PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count)));
1815 PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount))); 1795 PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount)));
1816} 1796}
1817 1797
1818int find_animation (utf8_string text)
1819 PROTOTYPE: $
1820
1821int random_roll (int min, int max, object *op, int goodbad); 1798int random_roll (int min, int max, object *op, int goodbad);
1822 1799
1823const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1800const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1824 1801
1825int exp_to_level (val64 exp) 1802int exp_to_level (val64 exp)
1826 1803
1827val64 level_to_min_exp (int level) 1804val64 level_to_min_exp (int level)
1828 1805
1806const_utf8_string
1807spellpathnames (int idx)
1808 CODE:
1809 RETVAL = spellpathnames [idx];
1810 OUTPUT: RETVAL
1811
1829SV * 1812SV *
1830resistance_to_string (int atnr) 1813attacktype_name (int atnr)
1831 CODE: 1814 CODE:
1832 if (atnr >= 0 && atnr < NROFATTACKS) 1815 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1816 ? newSVpv (attacktype_name [atnr], 0)
1817 : &PL_sv_undef;
1818 OUTPUT: RETVAL
1819
1820SV *
1821attacktype_desc (int atnr)
1822 CODE:
1823 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1824 ? newSVpv (attacktype_desc [atnr], 0)
1825 : &PL_sv_undef;
1826 OUTPUT: RETVAL
1827
1828SV *
1829resist_plus (int atnr)
1830 CODE:
1831 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1833 RETVAL = newSVpv (resist_plus[atnr], 0); 1832 ? newSVpv (resist_plus [atnr], 0)
1834 else 1833 : &PL_sv_undef;
1835 XSRETURN_UNDEF; 1834 OUTPUT: RETVAL
1835
1836SV *
1837change_resist_msg (int atnr)
1838 CODE:
1839 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1840 ? newSVpv (change_resist_msg [atnr], 0)
1841 : &PL_sv_undef;
1836 OUTPUT: RETVAL 1842 OUTPUT: RETVAL
1837 1843
1838UUID 1844UUID
1839uuid_cur () 1845uuid_cur ()
1840 CODE: 1846 CODE:
1881load_resource_file_ (octet_string filename) 1887load_resource_file_ (octet_string filename)
1882 1888
1883void 1889void
1884fix_weight () 1890fix_weight ()
1885 1891
1892utf8_string
1893expand_cfpod (int hintmode, int gender, const_utf8_string cfpod)
1894 PPCODE:
1895 XPUSHs (to_sv (player::expand_cfpod (hintmode, gender, cfpod)));
1896
1886MODULE = cf PACKAGE = cf::attachable 1897MODULE = cf PACKAGE = cf::attachable
1887 1898
1888int 1899int
1889valid (SV *obj) 1900valid (SV *obj)
1890 CODE: 1901 CODE:
1963int mortals_size () 1974int mortals_size ()
1964 CODE: 1975 CODE:
1965 RETVAL = attachable::mortals.size (); 1976 RETVAL = attachable::mortals.size ();
1966 OUTPUT: RETVAL 1977 OUTPUT: RETVAL
1967 1978
1968const_utf8_string slot_use_name (U32 slot) 1979const_utf8_string slot_name (U32 slot)
1969 ALIAS: 1980 ALIAS:
1981 slot_name = 0
1982 slot_use_name = 1
1970 slot_nonuse_name = 1 1983 slot_nonuse_name = 2
1971 CODE: 1984 CODE:
1972{ 1985{
1973 if (slot >= NUM_BODY_LOCATIONS) 1986 if (slot >= NUM_BODY_LOCATIONS)
1974 croak ("body slot index out of range"); 1987 croak ("body slot index out of range");
1975 1988
1976 switch (ix) 1989 switch (ix)
1977 { 1990 {
1991 case 0: RETVAL = body_locations[slot].name ; break;
1978 case 0: RETVAL = body_locations[slot].use_name; break; 1992 case 1: RETVAL = body_locations[slot].use_name ; break;
1979 case 1: RETVAL = body_locations[slot].nonuse_name; break; 1993 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1980 } 1994 }
1981} 1995}
1982 OUTPUT: 1996 OUTPUT:
1983 RETVAL 1997 RETVAL
1984 1998
2110 2124
2111void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); 2125void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags);
2112 2126
2113MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2127MODULE = cf PACKAGE = cf::object PREFIX = cf_
2114 2128
2115# no clean way to get an object from an archetype - stupid idiotic
2116# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2117
2118object *new (utf8_string archetype = 0) 2129object *new (utf8_string archetype = 0)
2119 PROTOTYPE: ;$ 2130 PROTOTYPE: ;$
2120 CODE: 2131 CODE:
2121 RETVAL = archetype ? get_archetype (archetype) : object::create (); 2132 RETVAL = archetype
2133 ? archetype::get (archetype)
2134 : object::create ();
2122 OUTPUT: 2135 OUTPUT:
2123 RETVAL 2136 RETVAL
2124 2137
2125object *generate (utf8_string arch, object *creator) 2138object *generate (utf8_string arch, object *creator)
2126 CODE: 2139 CODE:
2127 object *obj = get_archetype (arch); 2140 object *obj = archetype::get (arch);
2128 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2141 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2129 RETVAL = obj; 2142 RETVAL = obj;
2130 OUTPUT: 2143 OUTPUT:
2131 RETVAL 2144 RETVAL
2132 2145
2142 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2155 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2143 2156
2144 if (RETVAL->destroyed ()) 2157 if (RETVAL->destroyed ())
2145 RETVAL = 0; 2158 RETVAL = 0;
2146} 2159}
2160 OUTPUT:
2161 RETVAL
2147 2162
2148shstr 2163shstr
2149object::kv_get (shstr key) 2164object::kv_get (shstr key)
2165 CODE:
2166 RETVAL = THIS->kv.get (key);
2167 OUTPUT:
2168 RETVAL
2150 2169
2151void 2170void
2152object::kv_del (shstr key) 2171object::kv_del (shstr key)
2172 CODE:
2173 THIS->kv.del (key);
2153 2174
2154void 2175void
2155object::kv_set (shstr key, shstr value) 2176object::kv_set (shstr key, shstr value)
2177 CODE:
2178 THIS->kv.set (key, value);
2156 2179
2157object *get_nearest_player (object *ob) 2180object *get_nearest_player (object *ob)
2158 ALIAS: nearest_player = 0 2181 ALIAS: nearest_player = 0
2159 PREINIT: 2182 PREINIT:
2160 extern object *get_nearest_player (object *); 2183 extern object *get_nearest_player (object *);
2363 if (pl->ob && pl->ob->map == THIS) 2386 if (pl->ob && pl->ob->map == THIS)
2364 PUSHs (sv_2mortal (to_sv (pl->ob))); 2387 PUSHs (sv_2mortal (to_sv (pl->ob)));
2365 } 2388 }
2366 2389
2367void 2390void
2391maptile::gen_quadmap (int x, int y, int z)
2392 CODE:
2393 gen_quadmap (THIS, x * 50, y * 50, z);
2394
2395void
2368maptile::add_underlay (SV *data, int offset, int stride, SV *palette) 2396maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2369 CODE: 2397 CODE:
2370{ 2398{
2371 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) 2399 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2372 croak ("maptile::add_underlay: palette must be arrayref"); 2400 croak ("maptile::add_underlay: palette must be arrayref");
2373 2401
2374 palette = SvRV (palette); 2402 palette = SvRV (palette);
2375 2403
2376 STRLEN idxlen; 2404 STRLEN idxlen;
2377 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); 2405 const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen);
2378 2406
2379 for (int x = 0; x < THIS->width; ++x) 2407 for (int x = 0; x < THIS->width; ++x)
2380 for (int y = 0; y < THIS->height; ++y) 2408 for (int y = 0; y < THIS->height; ++y)
2381 { 2409 {
2382 for (object *op = THIS->at (x, y).bot; op; op = op->above) 2410 for (object *op = THIS->at (x, y).bot; op; op = op->above)
2388 2416
2389 if (IN_RANGE_EXC (offs, 0, idxlen)) 2417 if (IN_RANGE_EXC (offs, 0, idxlen))
2390 { 2418 {
2391 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2419 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2392 { 2420 {
2393 object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); 2421 object *ob = archetype::get (cfSvPVutf8_nolen (*elem));
2394 ob->flag [FLAG_NO_MAP_SAVE] = true; 2422 ob->flag [FLAG_NO_MAP_SAVE] = true;
2395 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2423 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2396 2424
2397 if (ob->randomitems && !ob->above) 2425 if (ob->randomitems && !ob->above)
2398 { 2426 {
2402 op->flag [FLAG_NO_MAP_SAVE] = true; 2430 op->flag [FLAG_NO_MAP_SAVE] = true;
2403 // TODO: if this is a pickable object, then the item 2431 // TODO: if this is a pickable object, then the item
2404 // will at a bit weird - saving inside the player 2432 // will at a bit weird - saving inside the player
2405 // will clear the flag, but when the player drops 2433 // will clear the flag, but when the player drops
2406 // it without logging out, it keeps the flag. 2434 // it without logging out, it keeps the flag.
2407 // nobody ahs reported this, but this can be rather 2435 // nobody has reported this, but this can be rather
2408 // annoying on persistent maps. 2436 // annoying on persistent maps.
2409 } 2437 }
2410 } 2438 }
2411 } 2439 }
2412 } 2440 }
2413
2414 skip: ; 2441 skip: ;
2415 } 2442 }
2416} 2443}
2417 2444
2418void 2445void
2423 croak ("maptile::set_regiondata: palette must be arrayref"); 2450 croak ("maptile::set_regiondata: palette must be arrayref");
2424 2451
2425 palette = SvRV (palette); 2452 palette = SvRV (palette);
2426 2453
2427 STRLEN idxlen; 2454 STRLEN idxlen;
2428 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); 2455 const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen);
2429 2456
2430 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; 2457 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1];
2431 uint8_t *regions = salloc<uint8_t> (THIS->size ()); 2458 uint8 *regions = salloc<uint8_t> (THIS->size ());
2432 2459
2433 for (int i = av_len ((AV *)palette) + 1; i--; ) 2460 for (int i = av_len ((AV *)palette) + 1; i--; )
2434 regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); 2461 regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1)));
2435 2462
2436 for (int y = 0; y < THIS->height; ++y) 2463 for (int y = 0; y < THIS->height; ++y)
2449 for (int x = 0; x < THIS->width; ++x) 2476 for (int x = 0; x < THIS->width; ++x)
2450 for (int y = 0; y < THIS->height; ++y) 2477 for (int y = 0; y < THIS->height; ++y)
2451 { 2478 {
2452 region *rgn = THIS->region (x, y); 2479 region *rgn = THIS->region (x, y);
2453 2480
2454 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D
2455 if (object *op = THIS->at (x, y).top) 2481 if (object *op = THIS->at (x, y).top)
2456 if (rgn->treasure && rndm () < rgn->treasure_density) 2482 if (rgn->treasure && rndm () < rgn->treasure_density)
2457 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2483 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2458 } 2484 }
2459 2485
2538} 2564}
2539 OUTPUT: RETVAL 2565 OUTPUT: RETVAL
2540 2566
2541# worst xs function of my life 2567# worst xs function of my life
2542bool 2568bool
2543_create_random_map (\ 2569_create_random_map (maptile *self, SV *options)
2544 maptile *self,\
2545 SV *options,\
2546 val64 total_map_hp,\
2547 region *region\
2548)
2549 CODE: 2570 CODE:
2550{ 2571{
2551 random_map_params rmp; 2572 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); 2573 RETVAL = self->generate_random_map (&rmp);
2586} 2574}
2587 OUTPUT: 2575 OUTPUT:
2588 RETVAL 2576 RETVAL
2589 2577
2600 2588
2601archetype *archetypes (U32 index) 2589archetype *archetypes (U32 index)
2602 CODE: 2590 CODE:
2603 RETVAL = index < archetypes.size () ? archetypes [index] : 0; 2591 RETVAL = index < archetypes.size () ? archetypes [index] : 0;
2604 OUTPUT: RETVAL 2592 OUTPUT: RETVAL
2593
2594int skillvec_size ()
2595 CODE:
2596 RETVAL = skillvec.size ();
2597 OUTPUT: RETVAL
2598
2599archetype *skillvec (U32 index)
2600 CODE:
2601 RETVAL = index < skillvec.size () ? (archetype *)(object *)skillvec [index] : 0;
2602 OUTPUT: RETVAL
2603
2604void
2605find_by_type (int type)
2606 PPCODE:
2607 for_all_archetypes (arch)
2608 if (arch->type == type)
2609 XPUSHs (sv_2mortal (to_sv (arch)));
2605 2610
2606INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | 2611INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h |
2607 2612
2608MODULE = cf PACKAGE = cf::party 2613MODULE = cf PACKAGE = cf::party
2609 2614
2658list () 2663list ()
2659 PPCODE: 2664 PPCODE:
2660 EXTEND (SP, clients.size ()); 2665 EXTEND (SP, clients.size ());
2661 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 2666 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
2662 PUSHs (sv_2mortal (to_sv (*i))); 2667 PUSHs (sv_2mortal (to_sv (*i)));
2668
2669STRLEN
2670client::inbuf_append (SV *data)
2671 CODE:
2672{
2673 STRLEN len;
2674 char *ptr = SvPVbyte (data, len);
2675
2676 min_it (len, sizeof (THIS->inbuf) - THIS->inbuf_len);
2677 memcpy (THIS->inbuf + THIS->inbuf_len, ptr, len);
2678 THIS->inbuf_len += len;
2679
2680 THIS->inbuf_handle ();
2681
2682 RETVAL = len;
2683}
2684 OUTPUT: RETVAL
2663 2685
2664void 2686void
2665client::send_packet (SV *packet) 2687client::send_packet (SV *packet)
2666 CODE: 2688 CODE:
2667{ 2689{
2723faceidx face_find (utf8_string name, faceidx defidx = 0) 2745faceidx face_find (utf8_string name, faceidx defidx = 0)
2724 2746
2725faceidx alloc (utf8_string name) 2747faceidx alloc (utf8_string name)
2726 CODE: 2748 CODE:
2727{ 2749{
2728 do 2750 RETVAL = face_alloc ();
2729 {
2730 RETVAL = faces.size ();
2731 faces.resize (RETVAL + 1);
2732 }
2733 while (!RETVAL); // crude way to leave index 0
2734 2751
2735 faces [RETVAL].name = name; 2752 faces [RETVAL].name = name;
2736 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); 2753 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL));
2737 2754
2738 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; 2755 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL;
2739 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; 2756 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL;
2740 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; 2757 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL;
2741} 2758}
2759 OUTPUT: RETVAL
2760
2761faceidx faces_size ()
2762 CODE:
2763 RETVAL = faces.size ();
2742 OUTPUT: RETVAL 2764 OUTPUT: RETVAL
2743 2765
2744void set_type (faceidx idx, int value) 2766void set_type (faceidx idx, int value)
2745 ALIAS: 2767 ALIAS:
2746 set_type = 0 2768 set_type = 0
2757 case 2: f->magicmap = value; break; 2779 case 2: f->magicmap = value; break;
2758 case 3: f->smooth = value; break; 2780 case 3: f->smooth = value; break;
2759 case 4: f->smoothlevel = value; break; 2781 case 4: f->smoothlevel = value; break;
2760 } 2782 }
2761 2783
2762void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2784void set_csum (faceidx idx, int faceset, SV *chksum)
2763 CODE: 2785 CODE:
2764{ 2786{
2765 faceinfo *f = face_info (idx); assert (f); 2787 faceinfo *f = face_info (idx); assert (f);
2766 facedata *d = &(faceset ? f->data64 : f->data32); 2788 facedata *d = f->face + faceset;
2767 sv_to (data, d->data);
2768 STRLEN clen; 2789 STRLEN clen;
2769 char *cdata = SvPVbyte (chksum, clen); 2790 char *cdata = SvPVbyte (chksum, clen);
2770 clen = min (CHKSUM_MAXLEN, clen);
2771 2791
2792 assert (("cf::face::set_data called with too long checksum", clen <= CHKSUM_MAXLEN));
2772 assert (("cf::face::set_data must be called with a non-empty checksum", clen)); 2793 assert (("cf::face::set_data must be called with a non-empty checksum", clen));
2773 2794
2774 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) 2795 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen))
2775 { 2796 {
2776 d->chksum_len = clen; 2797 d->chksum_len = clen;
2777 memcpy (d->chksum, cdata, clen); 2798 memcpy (d->chksum, cdata, clen);
2778 2799
2779 // invalidate existing client face info 2800 // invalidate existing client face info
2780 for_all_clients (ns) 2801 for_all_clients (ns)
2781 if (ns->faceset == faceset) 2802 ns->invalidate_face (idx);
2782 {
2783 ns->faces_sent [idx] = false;
2784 ns->force_newmap = true;
2785 }
2786 } 2803 }
2787} 2804}
2788 2805
2789int get_data_size (faceidx idx, int faceset = 0) 2806SV *mangle_csum (SV *chksum)
2790 CODE: 2807 CODE:
2791 facedata *d = face_data (idx, faceset); 2808 STRLEN len;
2792 if (!d) XSRETURN_UNDEF; 2809 char *data = SvPVbyte (chksum, len);
2793 RETVAL = d->data.size (); 2810 RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN));
2794 OUTPUT: 2811 OUTPUT:
2795 RETVAL 2812 RETVAL
2796 2813
2797SV *get_chksum (faceidx idx, int faceset = 0) 2814SV *get_csum (faceidx idx, int faceset = 0)
2798 CODE: 2815 CODE:
2799 facedata *d = face_data (idx, faceset); 2816 facedata *d = face_data (idx, faceset);
2800 if (!d) XSRETURN_UNDEF; 2817 if (!d) XSRETURN_UNDEF;
2801 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); 2818 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len);
2802 OUTPUT: 2819 OUTPUT:
2803 RETVAL 2820 RETVAL
2804 2821
2805SV *get_data (faceidx idx, int faceset = 0) 2822int get_type (faceidx idx)
2806 CODE: 2823 CODE:
2807 facedata *d = face_data (idx, faceset); 2824 faceinfo *f = face_info (idx);
2808 if (!d) XSRETURN_UNDEF; 2825 if (!f) XSRETURN_UNDEF;
2809 RETVAL = newSVpvn (d->data.data (), d->data.length ()); 2826 RETVAL = f->type;
2810 OUTPUT: 2827 OUTPUT:
2811 RETVAL 2828 RETVAL
2812 2829
2830SV *get_name (faceidx idx)
2831 CODE:
2832 faceinfo *f = face_info (idx);
2833 if (!f) XSRETURN_UNDEF;
2834 RETVAL = to_sv (f->name);
2835 OUTPUT:
2836 RETVAL
2837
2813void invalidate (faceidx idx) 2838void invalidate (faceidx idx)
2814 CODE: 2839 CODE:
2815 for_all_clients (ns) 2840 for_all_clients (ns)
2816 { 2841 ns->invalidate_face (idx);
2817 ns->faces_sent [idx] = false;
2818 ns->force_newmap = true;
2819 }
2820 2842
2821void invalidate_all () 2843void invalidate_all ()
2822 CODE: 2844 CODE:
2823 for_all_clients (ns) 2845 for_all_clients (ns)
2824 { 2846 ns->invalidate_all_faces ();
2825 ns->faces_sent.reset ();
2826 ns->force_newmap = true;
2827 }
2828 2847
2829MODULE = cf PACKAGE = cf::anim PREFIX = anim_ 2848MODULE = cf PACKAGE = cf::anim PREFIX = anim_
2830 2849
2831#INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | 2850#INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h |
2832 2851
2836 OUTPUT: RETVAL 2855 OUTPUT: RETVAL
2837 2856
2838animidx set (utf8_string name, SV *frames, int facings = 1) 2857animidx set (utf8_string name, SV *frames, int facings = 1)
2839 CODE: 2858 CODE:
2840{ 2859{
2841 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) 2860 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV)
2842 croak ("frames must be an arrayref"); 2861 croak ("frames must be an arrayref");
2843 2862
2844 AV *av = (AV *)SvRV (frames); 2863 AV *av = (AV *)SvRV (frames);
2845 2864
2846 animation *anim = &animation::find (name); 2865 animation *anim = &animation::find (name);
2847 if (anim->number) 2866 if (anim->number)
2848 { 2867 {
2849 anim->resize (av_len (av) + 1); 2868 anim->resize (av_len (av) + 1);
2850 anim->facings = facings; 2869 anim->facings = facings;
2851 } 2870 }
2923 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); 2942 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ())));
2924 2943
2925 self->skip (); 2944 self->skip ();
2926 } 2945 }
2927 2946
2947MODULE = cf PACKAGE = cf::treasurelist
2948
2949# quick hack, because I didn't want to implement accessors for treasurelist.
2950# this asks for even more autogen, actually.
2951
2952void
2953expand (treasurelist *list)
2954 PPCODE:
2955 EXTEND (SP, 3);
2956 PUSHs (sv_2mortal (to_sv (list->name)));
2957 PUSHs (sv_2mortal (to_sv (list->total_chance)));
2958 AV *av = newAV ();
2959 PUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
2960 for (treasure *item = list->items; item; item = item->next)
2961 {
2962 AV *iav = newAV ();
2963 av_push (av, newRV_noinc ((SV *)iav));
2964
2965 av_extend (iav, 7);
2966 av_push (iav, to_sv (item->item));
2967 av_push (iav, to_sv (item->name));
2968 av_push (iav, to_sv (item->change_arch.name));
2969 av_push (iav, to_sv (item->change_arch.title));
2970 av_push (iav, to_sv (item->change_arch.slaying));
2971 av_push (iav, to_sv (item->chance));
2972 av_push (iav, to_sv (item->nrof));
2973 av_push (iav, to_sv (item->magic));
2974 }
2975
2928MODULE = cf PACKAGE = cf::layout 2976MODULE = cf PACKAGE = cf::layout
2929 2977
2930INCLUDE: $PERL $srcdir/genacc layout $srcdir/../random_maps/random_map.h | 2978INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h |
2931 2979

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines