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 | |
… | |
… | |
29 | #include <cstdarg> |
29 | #include <cstdarg> |
30 | #include <typeinfo> |
30 | #include <typeinfo> |
31 | |
31 | |
32 | #include "global.h" |
32 | #include "global.h" |
33 | #include "rmg.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 |
… | |
… | |
66 | static int tick_inhibit; |
67 | static int tick_inhibit; |
67 | static int tick_pending; |
68 | static int tick_pending; |
68 | |
69 | |
69 | global gbl_ev; |
70 | global gbl_ev; |
70 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
71 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
71 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; |
72 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now, *sv_server_tick; |
72 | static AV *av_reflect; |
73 | static AV *av_reflect; |
73 | |
74 | |
74 | bitset<NUM_EVENT_TYPES> ev_want_event; |
75 | bitset<NUM_EVENT_TYPES> ev_want_event; |
75 | bitset<NUM_TYPES> ev_want_type; |
76 | bitset<NUM_TYPES> ev_want_type; |
76 | |
77 | |
… | |
… | |
91 | |
92 | |
92 | static SV |
93 | static 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 |
100 | static SV * |
102 | static 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 | |
|
|
631 | static 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 | |
626 | static inline void sv_to (SV *sv, UUID &v) |
639 | static 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 | |
|
|
1163 | void 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 | |
1150 | player * |
1174 | player * |
1151 | player::find (const_utf8_string name) |
1175 | player::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 | |
1432 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1458 | MODULE = 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[] = { |
… | |
… | |
1485 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1502 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1486 | |
1503 | |
1487 | 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) |
1488 | 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) |
1489 | |
1506 | |
1490 | const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING) |
|
|
1491 | const_iv (MAP_INACTIVE) |
|
|
1492 | |
|
|
1493 | 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) |
1494 | 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) |
1495 | |
1509 | |
1496 | 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) |
1497 | |
1511 | |
… | |
… | |
1529 | |
1543 | |
1530 | void _gv_clear (SV *gv) |
1544 | void _gv_clear (SV *gv) |
1531 | CODE: |
1545 | CODE: |
1532 | assert (SvTYPE (gv) == SVt_PVGV); |
1546 | assert (SvTYPE (gv) == SVt_PVGV); |
1533 | # 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); |
1534 | f (GvGP (gv)->gp_form); |
1549 | f (GvGP (gv)->gp_form); |
1535 | f (GvGP (gv)->gp_io); |
1550 | f (GvGP (gv)->gp_io); |
1536 | f (GvGP (gv)->gp_sv); |
1551 | f (GvGP (gv)->gp_sv); |
1537 | f (GvGP (gv)->gp_av); |
1552 | f (GvGP (gv)->gp_av); |
1538 | f (GvGP (gv)->gp_hv); |
1553 | f (GvGP (gv)->gp_hv); |
1539 | f (GvGP (gv)->gp_cv); |
1554 | f (GvGP (gv)->gp_cv); |
1540 | GvCVGEN (gv) = 0; |
1555 | GvCVGEN (gv) = 0; |
1541 | GvMULTI_off (gv); |
1556 | GvMULTI_off (gv); |
|
|
1557 | SvREFCNT_dec (gv); |
1542 | # undef f |
1558 | # undef f |
1543 | |
1559 | |
1544 | void _connect_to_perl_1 () |
1560 | void _connect_to_perl_1 () |
1545 | |
1561 | |
1546 | void _connect_to_perl_2 () |
1562 | void _connect_to_perl_2 () |
… | |
… | |
1557 | |
1573 | |
1558 | for_all_objects (op) |
1574 | for_all_objects (op) |
1559 | op->reattach (); |
1575 | op->reattach (); |
1560 | } |
1576 | } |
1561 | |
1577 | |
1562 | # support function for map-world.ext |
|
|
1563 | void _quantise (SV *data_sv, SV *plt_sv) |
|
|
1564 | CODE: |
|
|
1565 | { |
|
|
1566 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
|
|
1567 | croak ("_quantise called with invalid agruments"); |
|
|
1568 | |
|
|
1569 | plt_sv = SvRV (plt_sv); |
|
|
1570 | SV **plt = AvARRAY (plt_sv); |
|
|
1571 | int plt_count = AvFILL (plt_sv) + 1; |
|
|
1572 | |
|
|
1573 | STRLEN len; |
|
|
1574 | char *data = SvPVbyte (data_sv, len); |
|
|
1575 | char *dst = data; |
|
|
1576 | |
|
|
1577 | while (len >= 3) |
|
|
1578 | { |
|
|
1579 | for (SV **val_sv = plt + plt_count; val_sv-- > plt; ) |
|
|
1580 | { |
|
|
1581 | char *val = SvPVX (*val_sv); |
|
|
1582 | |
|
|
1583 | if (val [0] == data [0] |
|
|
1584 | && val [1] == data [1] |
|
|
1585 | && val [2] == data [2]) |
|
|
1586 | { |
|
|
1587 | *dst++ = val [3]; |
|
|
1588 | goto next; |
|
|
1589 | } |
|
|
1590 | } |
|
|
1591 | |
|
|
1592 | croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d", |
|
|
1593 | (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2], |
|
|
1594 | dst - SvPVX (data_sv), len); |
|
|
1595 | |
|
|
1596 | next: |
|
|
1597 | data += 3; |
|
|
1598 | len -= 3; |
|
|
1599 | } |
|
|
1600 | |
|
|
1601 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
|
|
1602 | } |
|
|
1603 | |
|
|
1604 | void init_anim () |
1578 | void init_anim () |
1605 | |
1579 | |
1606 | void init_globals () |
1580 | void init_globals () |
1607 | |
1581 | |
1608 | void init_attackmess () |
1582 | void init_attackmess () |
1609 | |
1583 | |
1610 | void init_dynamic () |
1584 | void init_dynamic () |
1611 | |
1585 | |
1612 | void load_settings () |
1586 | void load_settings () |
1613 | |
1587 | |
1614 | void reload_exp_table () |
1588 | void _reload_exp_table () |
1615 | |
1589 | |
1616 | void reload_materials () |
1590 | void _reload_materials () |
1617 | |
1591 | |
1618 | void init_uuid () |
1592 | void init_uuid () |
1619 | CODE: |
1593 | CODE: |
1620 | UUID::init (); |
1594 | UUID::init (); |
1621 | |
1595 | |
… | |
… | |
1654 | { |
1628 | { |
1655 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1629 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1656 | coroapi::cede (); |
1630 | coroapi::cede (); |
1657 | } |
1631 | } |
1658 | |
1632 | |
1659 | void server_tick () |
1633 | void one_tick () |
1660 | CODE: |
1634 | CODE: |
1661 | { |
1635 | { |
1662 | ev_now_update (EV_DEFAULT); |
1636 | ev_now_update (EV_DEFAULT); |
1663 | NOW = ev_now (EV_DEFAULT); |
1637 | NOW = ev_now (EV_DEFAULT); |
1664 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1638 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1665 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1639 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1666 | runtime = SvNVX (sv_runtime); |
1640 | runtime = SvNVX (sv_runtime); |
1667 | |
1641 | |
|
|
1642 | one_tick (); |
|
|
1643 | |
1668 | server_tick (); |
1644 | ++server_tick; |
|
|
1645 | SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick); |
1669 | |
1646 | |
1670 | ev_now_update (EV_DEFAULT); |
1647 | ev_now_update (EV_DEFAULT); |
1671 | NOW = ev_now (EV_DEFAULT); |
1648 | NOW = ev_now (EV_DEFAULT); |
1672 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1649 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
|
|
1650 | |
1673 | runtime += TICK; |
1651 | runtime += TICK; |
1674 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1652 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1675 | } |
1653 | } |
1676 | |
1654 | |
1677 | NV floor (NV x) |
1655 | NV floor (NV x) |
… | |
… | |
1681 | NV rndm (...) |
1659 | NV rndm (...) |
1682 | ALIAS: |
1660 | ALIAS: |
1683 | rmg_rndm = 1 |
1661 | rmg_rndm = 1 |
1684 | CODE: |
1662 | CODE: |
1685 | { |
1663 | { |
1686 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1664 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1687 | switch (items) |
1665 | switch (items) |
1688 | { |
1666 | { |
1689 | case 0: RETVAL = gen (); break; |
1667 | case 0: RETVAL = gen (); break; |
1690 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1668 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1691 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1669 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
… | |
… | |
1778 | INIT: |
1756 | INIT: |
1779 | #if __GLIBC__ |
1757 | #if __GLIBC__ |
1780 | mallopt (M_TOP_PAD, 1024 * 1024); |
1758 | mallopt (M_TOP_PAD, 1024 * 1024); |
1781 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024); |
1759 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024); |
1782 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1760 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1783 | if (__GLIBC_MAJOR < 2 || (__GLIBC_MAJOR == 2 && __GLIBC_MINOR < 10)) |
1761 | if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10)) |
1784 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1762 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1785 | #endif |
1763 | #endif |
1786 | |
1764 | |
1787 | int munlockall () |
1765 | int munlockall () |
1788 | |
1766 | |
… | |
… | |
1815 | 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)))); |
1816 | 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))); |
1817 | 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))); |
1818 | } |
1796 | } |
1819 | |
1797 | |
1820 | int find_animation (utf8_string text) |
|
|
1821 | PROTOTYPE: $ |
|
|
1822 | |
|
|
1823 | int random_roll (int min, int max, object *op, int goodbad); |
1798 | int random_roll (int min, int max, object *op, int goodbad); |
1824 | |
1799 | |
1825 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1800 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1826 | |
1801 | |
1827 | int exp_to_level (val64 exp) |
1802 | int exp_to_level (val64 exp) |
1828 | |
1803 | |
1829 | val64 level_to_min_exp (int level) |
1804 | val64 level_to_min_exp (int level) |
|
|
1805 | |
|
|
1806 | const_utf8_string |
|
|
1807 | spellpathnames (int idx) |
|
|
1808 | CODE: |
|
|
1809 | RETVAL = spellpathnames [idx]; |
|
|
1810 | OUTPUT: RETVAL |
1830 | |
1811 | |
1831 | SV * |
1812 | SV * |
1832 | attacktype_name (int atnr) |
1813 | attacktype_name (int atnr) |
1833 | CODE: |
1814 | CODE: |
1834 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1815 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
… | |
… | |
1906 | load_resource_file_ (octet_string filename) |
1887 | load_resource_file_ (octet_string filename) |
1907 | |
1888 | |
1908 | void |
1889 | void |
1909 | fix_weight () |
1890 | fix_weight () |
1910 | |
1891 | |
|
|
1892 | utf8_string |
|
|
1893 | expand_cfpod (int hintmode, int gender, const_utf8_string cfpod) |
|
|
1894 | PPCODE: |
|
|
1895 | XPUSHs (to_sv (player::expand_cfpod (hintmode, gender, cfpod))); |
|
|
1896 | |
1911 | MODULE = cf PACKAGE = cf::attachable |
1897 | MODULE = cf PACKAGE = cf::attachable |
1912 | |
1898 | |
1913 | int |
1899 | int |
1914 | valid (SV *obj) |
1900 | valid (SV *obj) |
1915 | CODE: |
1901 | CODE: |
… | |
… | |
2138 | |
2124 | |
2139 | void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); |
2125 | void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); |
2140 | |
2126 | |
2141 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2127 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2142 | |
2128 | |
2143 | # no clean way to get an object from an archetype - stupid idiotic |
|
|
2144 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
|
|
2145 | |
|
|
2146 | object *new (utf8_string archetype = 0) |
2129 | object *new (utf8_string archetype = 0) |
2147 | PROTOTYPE: ;$ |
2130 | PROTOTYPE: ;$ |
2148 | CODE: |
2131 | CODE: |
2149 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
2132 | RETVAL = archetype |
|
|
2133 | ? archetype::get (archetype) |
|
|
2134 | : object::create (); |
2150 | OUTPUT: |
2135 | OUTPUT: |
2151 | RETVAL |
2136 | RETVAL |
2152 | |
2137 | |
2153 | object *generate (utf8_string arch, object *creator) |
2138 | object *generate (utf8_string arch, object *creator) |
2154 | CODE: |
2139 | CODE: |
2155 | object *obj = get_archetype (arch); |
2140 | object *obj = archetype::get (arch); |
2156 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2141 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2157 | RETVAL = obj; |
2142 | RETVAL = obj; |
2158 | OUTPUT: |
2143 | OUTPUT: |
2159 | RETVAL |
2144 | RETVAL |
2160 | |
2145 | |
… | |
… | |
2170 | 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); |
2171 | |
2156 | |
2172 | if (RETVAL->destroyed ()) |
2157 | if (RETVAL->destroyed ()) |
2173 | RETVAL = 0; |
2158 | RETVAL = 0; |
2174 | } |
2159 | } |
|
|
2160 | OUTPUT: |
|
|
2161 | RETVAL |
2175 | |
2162 | |
2176 | shstr |
2163 | shstr |
2177 | object::kv_get (shstr key) |
2164 | object::kv_get (shstr key) |
|
|
2165 | CODE: |
|
|
2166 | RETVAL = THIS->kv.get (key); |
|
|
2167 | OUTPUT: |
|
|
2168 | RETVAL |
2178 | |
2169 | |
2179 | void |
2170 | void |
2180 | object::kv_del (shstr key) |
2171 | object::kv_del (shstr key) |
|
|
2172 | CODE: |
|
|
2173 | THIS->kv.del (key); |
2181 | |
2174 | |
2182 | void |
2175 | void |
2183 | object::kv_set (shstr key, shstr value) |
2176 | object::kv_set (shstr key, shstr value) |
|
|
2177 | CODE: |
|
|
2178 | THIS->kv.set (key, value); |
2184 | |
2179 | |
2185 | object *get_nearest_player (object *ob) |
2180 | object *get_nearest_player (object *ob) |
2186 | ALIAS: nearest_player = 0 |
2181 | ALIAS: nearest_player = 0 |
2187 | PREINIT: |
2182 | PREINIT: |
2188 | extern object *get_nearest_player (object *); |
2183 | extern object *get_nearest_player (object *); |
… | |
… | |
2391 | if (pl->ob && pl->ob->map == THIS) |
2386 | if (pl->ob && pl->ob->map == THIS) |
2392 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2387 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2393 | } |
2388 | } |
2394 | |
2389 | |
2395 | void |
2390 | void |
|
|
2391 | maptile::gen_quadmap (int x, int y, int z) |
|
|
2392 | CODE: |
|
|
2393 | gen_quadmap (THIS, x * 50, y * 50, z); |
|
|
2394 | |
|
|
2395 | void |
2396 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2396 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2397 | CODE: |
2397 | CODE: |
2398 | { |
2398 | { |
2399 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2399 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2400 | croak ("maptile::add_underlay: palette must be arrayref"); |
2400 | croak ("maptile::add_underlay: palette must be arrayref"); |
2401 | |
2401 | |
2402 | palette = SvRV (palette); |
2402 | palette = SvRV (palette); |
2403 | |
2403 | |
2404 | STRLEN idxlen; |
2404 | STRLEN idxlen; |
2405 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2405 | const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen); |
2406 | |
2406 | |
2407 | for (int x = 0; x < THIS->width; ++x) |
2407 | for (int x = 0; x < THIS->width; ++x) |
2408 | for (int y = 0; y < THIS->height; ++y) |
2408 | for (int y = 0; y < THIS->height; ++y) |
2409 | { |
2409 | { |
2410 | 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) |
… | |
… | |
2416 | |
2416 | |
2417 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2417 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2418 | { |
2418 | { |
2419 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2419 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2420 | { |
2420 | { |
2421 | object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); |
2421 | object *ob = archetype::get (cfSvPVutf8_nolen (*elem)); |
2422 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2422 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2423 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2423 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2424 | |
2424 | |
2425 | if (ob->randomitems && !ob->above) |
2425 | if (ob->randomitems && !ob->above) |
2426 | { |
2426 | { |
… | |
… | |
2430 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2430 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2431 | // TODO: if this is a pickable object, then the item |
2431 | // TODO: if this is a pickable object, then the item |
2432 | // will at a bit weird - saving inside the player |
2432 | // will at a bit weird - saving inside the player |
2433 | // will clear the flag, but when the player drops |
2433 | // will clear the flag, but when the player drops |
2434 | // it without logging out, it keeps the flag. |
2434 | // it without logging out, it keeps the flag. |
2435 | // nobody ahs reported this, but this can be rather |
2435 | // nobody has reported this, but this can be rather |
2436 | // annoying on persistent maps. |
2436 | // annoying on persistent maps. |
2437 | } |
2437 | } |
2438 | } |
2438 | } |
2439 | } |
2439 | } |
2440 | } |
2440 | } |
2441 | |
|
|
2442 | skip: ; |
2441 | skip: ; |
2443 | } |
2442 | } |
2444 | } |
2443 | } |
2445 | |
2444 | |
2446 | void |
2445 | void |
… | |
… | |
2451 | croak ("maptile::set_regiondata: palette must be arrayref"); |
2450 | croak ("maptile::set_regiondata: palette must be arrayref"); |
2452 | |
2451 | |
2453 | palette = SvRV (palette); |
2452 | palette = SvRV (palette); |
2454 | |
2453 | |
2455 | STRLEN idxlen; |
2454 | STRLEN idxlen; |
2456 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2455 | const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen); |
2457 | |
2456 | |
2458 | region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; |
2457 | region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; |
2459 | uint8_t *regions = salloc<uint8_t> (THIS->size ()); |
2458 | uint8 *regions = salloc<uint8_t> (THIS->size ()); |
2460 | |
2459 | |
2461 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2460 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2462 | 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))); |
2463 | |
2462 | |
2464 | for (int y = 0; y < THIS->height; ++y) |
2463 | for (int y = 0; y < THIS->height; ++y) |
… | |
… | |
2477 | for (int x = 0; x < THIS->width; ++x) |
2476 | for (int x = 0; x < THIS->width; ++x) |
2478 | for (int y = 0; y < THIS->height; ++y) |
2477 | for (int y = 0; y < THIS->height; ++y) |
2479 | { |
2478 | { |
2480 | region *rgn = THIS->region (x, y); |
2479 | region *rgn = THIS->region (x, y); |
2481 | |
2480 | |
2482 | //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D |
|
|
2483 | if (object *op = THIS->at (x, y).top) |
2481 | if (object *op = THIS->at (x, y).top) |
2484 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2482 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2485 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2483 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2486 | } |
2484 | } |
2487 | |
2485 | |
… | |
… | |
2591 | archetype *archetypes (U32 index) |
2589 | archetype *archetypes (U32 index) |
2592 | CODE: |
2590 | CODE: |
2593 | RETVAL = index < archetypes.size () ? archetypes [index] : 0; |
2591 | RETVAL = index < archetypes.size () ? archetypes [index] : 0; |
2594 | OUTPUT: RETVAL |
2592 | OUTPUT: RETVAL |
2595 | |
2593 | |
|
|
2594 | int skillvec_size () |
|
|
2595 | CODE: |
|
|
2596 | RETVAL = skillvec.size (); |
|
|
2597 | OUTPUT: RETVAL |
|
|
2598 | |
|
|
2599 | archetype *skillvec (U32 index) |
|
|
2600 | CODE: |
|
|
2601 | RETVAL = index < skillvec.size () ? (archetype *)(object *)skillvec [index] : 0; |
|
|
2602 | OUTPUT: RETVAL |
|
|
2603 | |
|
|
2604 | void |
|
|
2605 | find_by_type (int type) |
|
|
2606 | PPCODE: |
|
|
2607 | for_all_archetypes (arch) |
|
|
2608 | if (arch->type == type) |
|
|
2609 | XPUSHs (sv_2mortal (to_sv (arch))); |
|
|
2610 | |
2596 | INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | |
2611 | INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | |
2597 | |
2612 | |
2598 | MODULE = cf PACKAGE = cf::party |
2613 | MODULE = cf PACKAGE = cf::party |
2599 | |
2614 | |
2600 | partylist *first () |
2615 | partylist *first () |
… | |
… | |
2648 | list () |
2663 | list () |
2649 | PPCODE: |
2664 | PPCODE: |
2650 | EXTEND (SP, clients.size ()); |
2665 | EXTEND (SP, clients.size ()); |
2651 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2666 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2652 | PUSHs (sv_2mortal (to_sv (*i))); |
2667 | PUSHs (sv_2mortal (to_sv (*i))); |
|
|
2668 | |
|
|
2669 | STRLEN |
|
|
2670 | client::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 |
2653 | |
2685 | |
2654 | void |
2686 | void |
2655 | client::send_packet (SV *packet) |
2687 | client::send_packet (SV *packet) |
2656 | CODE: |
2688 | CODE: |
2657 | { |
2689 | { |
… | |
… | |
2713 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2745 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2714 | |
2746 | |
2715 | faceidx alloc (utf8_string name) |
2747 | faceidx alloc (utf8_string name) |
2716 | CODE: |
2748 | CODE: |
2717 | { |
2749 | { |
2718 | do |
2750 | RETVAL = face_alloc (); |
2719 | { |
|
|
2720 | RETVAL = faces.size (); |
|
|
2721 | faces.resize (RETVAL + 1); |
|
|
2722 | } |
|
|
2723 | while (!RETVAL); // crude way to leave index 0 |
|
|
2724 | |
2751 | |
2725 | faces [RETVAL].name = name; |
2752 | faces [RETVAL].name = name; |
2726 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2753 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2727 | |
2754 | |
2728 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2755 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2729 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2756 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2730 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2757 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2731 | } |
2758 | } |
|
|
2759 | OUTPUT: RETVAL |
|
|
2760 | |
|
|
2761 | faceidx faces_size () |
|
|
2762 | CODE: |
|
|
2763 | RETVAL = faces.size (); |
2732 | OUTPUT: RETVAL |
2764 | OUTPUT: RETVAL |
2733 | |
2765 | |
2734 | void set_type (faceidx idx, int value) |
2766 | void set_type (faceidx idx, int value) |
2735 | ALIAS: |
2767 | ALIAS: |
2736 | set_type = 0 |
2768 | set_type = 0 |
… | |
… | |
2747 | case 2: f->magicmap = value; break; |
2779 | case 2: f->magicmap = value; break; |
2748 | case 3: f->smooth = value; break; |
2780 | case 3: f->smooth = value; break; |
2749 | case 4: f->smoothlevel = value; break; |
2781 | case 4: f->smoothlevel = value; break; |
2750 | } |
2782 | } |
2751 | |
2783 | |
2752 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2784 | void set_csum (faceidx idx, int faceset, SV *chksum) |
2753 | CODE: |
2785 | CODE: |
2754 | { |
2786 | { |
2755 | faceinfo *f = face_info (idx); assert (f); |
2787 | faceinfo *f = face_info (idx); assert (f); |
2756 | facedata *d = f->face + faceset; |
2788 | facedata *d = f->face + faceset; |
2757 | sv_to (data, d->data); |
|
|
2758 | STRLEN clen; |
2789 | STRLEN clen; |
2759 | char *cdata = SvPVbyte (chksum, clen); |
2790 | char *cdata = SvPVbyte (chksum, clen); |
2760 | clen = min (CHKSUM_MAXLEN, clen); |
|
|
2761 | |
2791 | |
|
|
2792 | assert (("cf::face::set_data called with too long checksum", clen <= CHKSUM_MAXLEN)); |
2762 | 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)); |
2763 | |
2794 | |
2764 | if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) |
2795 | if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) |
2765 | { |
2796 | { |
2766 | d->chksum_len = clen; |
2797 | d->chksum_len = clen; |
2767 | memcpy (d->chksum, cdata, clen); |
2798 | memcpy (d->chksum, cdata, clen); |
2768 | |
2799 | |
2769 | // invalidate existing client face info |
2800 | // invalidate existing client face info |
2770 | for_all_clients (ns) |
2801 | for_all_clients (ns) |
2771 | if (ns->faceset == faceset) |
2802 | ns->invalidate_face (idx); |
2772 | { |
|
|
2773 | ns->faces_sent [idx] = false; |
|
|
2774 | ns->force_newmap = true; |
|
|
2775 | } |
|
|
2776 | } |
2803 | } |
2777 | } |
2804 | } |
2778 | |
2805 | |
2779 | int get_data_size (faceidx idx, int faceset = 0) |
2806 | SV *mangle_csum (SV *chksum) |
2780 | CODE: |
2807 | CODE: |
2781 | facedata *d = face_data (idx, faceset); |
2808 | STRLEN len; |
2782 | if (!d) XSRETURN_UNDEF; |
2809 | char *data = SvPVbyte (chksum, len); |
2783 | RETVAL = d->data.size (); |
2810 | RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN)); |
2784 | OUTPUT: |
2811 | OUTPUT: |
2785 | RETVAL |
2812 | RETVAL |
2786 | |
2813 | |
2787 | SV *get_chksum (faceidx idx, int faceset = 0) |
2814 | SV *get_csum (faceidx idx, int faceset = 0) |
2788 | CODE: |
2815 | CODE: |
2789 | facedata *d = face_data (idx, faceset); |
2816 | facedata *d = face_data (idx, faceset); |
2790 | if (!d) XSRETURN_UNDEF; |
2817 | if (!d) XSRETURN_UNDEF; |
2791 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2818 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2792 | OUTPUT: |
2819 | OUTPUT: |
2793 | RETVAL |
2820 | RETVAL |
2794 | |
2821 | |
2795 | SV *get_data (faceidx idx, int faceset = 0) |
2822 | int get_type (faceidx idx) |
2796 | CODE: |
2823 | CODE: |
2797 | facedata *d = face_data (idx, faceset); |
2824 | faceinfo *f = face_info (idx); |
2798 | if (!d) XSRETURN_UNDEF; |
2825 | if (!f) XSRETURN_UNDEF; |
2799 | RETVAL = newSVpvn (d->data.data (), d->data.length ()); |
2826 | RETVAL = f->type; |
2800 | OUTPUT: |
2827 | OUTPUT: |
2801 | RETVAL |
2828 | RETVAL |
2802 | |
2829 | |
|
|
2830 | SV *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 | |
2803 | void invalidate (faceidx idx) |
2838 | void invalidate (faceidx idx) |
2804 | CODE: |
2839 | CODE: |
2805 | for_all_clients (ns) |
2840 | for_all_clients (ns) |
2806 | { |
2841 | ns->invalidate_face (idx); |
2807 | ns->faces_sent [idx] = false; |
|
|
2808 | ns->force_newmap = true; |
|
|
2809 | } |
|
|
2810 | |
2842 | |
2811 | void invalidate_all () |
2843 | void invalidate_all () |
2812 | CODE: |
2844 | CODE: |
2813 | for_all_clients (ns) |
2845 | for_all_clients (ns) |
2814 | { |
2846 | ns->invalidate_all_faces (); |
2815 | ns->faces_sent.reset (); |
|
|
2816 | ns->force_newmap = true; |
|
|
2817 | } |
|
|
2818 | |
2847 | |
2819 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2848 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2820 | |
2849 | |
2821 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2850 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2822 | |
2851 | |
… | |
… | |
2826 | OUTPUT: RETVAL |
2855 | OUTPUT: RETVAL |
2827 | |
2856 | |
2828 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2857 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2829 | CODE: |
2858 | CODE: |
2830 | { |
2859 | { |
2831 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2860 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2832 | croak ("frames must be an arrayref"); |
2861 | croak ("frames must be an arrayref"); |
2833 | |
2862 | |
2834 | AV *av = (AV *)SvRV (frames); |
2863 | AV *av = (AV *)SvRV (frames); |
2835 | |
2864 | |
2836 | animation *anim = &animation::find (name); |
2865 | animation *anim = &animation::find (name); |
2837 | if (anim->number) |
2866 | if (anim->number) |
2838 | { |
2867 | { |
2839 | anim->resize (av_len (av) + 1); |
2868 | anim->resize (av_len (av) + 1); |
2840 | anim->facings = facings; |
2869 | anim->facings = facings; |
2841 | } |
2870 | } |
… | |
… | |
2913 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2942 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2914 | |
2943 | |
2915 | self->skip (); |
2944 | self->skip (); |
2916 | } |
2945 | } |
2917 | |
2946 | |
|
|
2947 | MODULE = 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 | |
|
|
2952 | void |
|
|
2953 | expand (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 | |
2918 | MODULE = cf PACKAGE = cf::layout |
2976 | MODULE = cf PACKAGE = cf::layout |
2919 | |
2977 | |
2920 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
2978 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
2921 | |
2979 | |