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 |
… | |
… | |
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 | |
… | |
… | |
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 | |
91 | static SV |
93 | static SV |
92 | *cv_cf_do_invoke, |
94 | *cv_cf_do_invoke, |
93 | *cv_cf__can_merge, |
95 | *cv_cf__can_merge, |
… | |
… | |
251 | { |
253 | { |
252 | static int last_mortalcount; |
254 | static int last_mortalcount; |
253 | if (mortals.size () != last_mortalcount) |
255 | if (mortals.size () != last_mortalcount) |
254 | { |
256 | { |
255 | last_mortalcount = mortals.size (); |
257 | last_mortalcount = mortals.size (); |
256 | LOG (llevInfo, "%d mortals.\n", (int)mortals.size ()); |
258 | object *specimen = is_a<object> (mortals [rndm (mortals.size ())]); |
|
|
259 | |
|
|
260 | LOG (llevInfo, "%d mortals (random specimen: %s).\n", |
|
|
261 | (int)mortals.size (), specimen ? specimen->debug_desc () : "(not an object)"); |
257 | |
262 | |
258 | if (0) |
263 | if (0) |
259 | { |
264 | { |
260 | for (int j = 0; j < mortals.size (); ++j)//D |
265 | for (int j = 0; j < mortals.size (); ++j)//D |
261 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
266 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
… | |
… | |
539 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
544 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
540 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
545 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
541 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
546 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
542 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
547 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
543 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
548 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
|
|
549 | static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); } |
544 | |
550 | |
545 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
551 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
546 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
552 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
547 | |
553 | |
548 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
554 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
… | |
… | |
594 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
600 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
595 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
601 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
596 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
602 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
597 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
603 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
598 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
604 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
|
|
605 | static inline void sv_to (SV *sv, layout * &v) { v = (layout *) SvPTR_ornull (sv, "cf::layout"); } |
599 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
606 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
600 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
607 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
601 | |
608 | |
602 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
609 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
603 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
610 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
616 | static inline void sv_to (SV *sv, std::string &v) |
623 | static inline void sv_to (SV *sv, std::string &v) |
617 | { |
624 | { |
618 | STRLEN len; |
625 | STRLEN len; |
619 | char *data = SvPVbyte (sv, len); |
626 | char *data = SvPVbyte (sv, len); |
620 | v.assign (data, len); |
627 | v.assign (data, len); |
|
|
628 | } |
|
|
629 | |
|
|
630 | static inline void sv_to (SV *sv, refcnt_buf &v) |
|
|
631 | { |
|
|
632 | STRLEN len; |
|
|
633 | char *data = SvPVbyte (sv, len); |
|
|
634 | refcnt_buf buf (data, len); |
|
|
635 | v = buf; |
621 | } |
636 | } |
622 | |
637 | |
623 | static inline void sv_to (SV *sv, UUID &v) |
638 | static inline void sv_to (SV *sv, UUID &v) |
624 | { |
639 | { |
625 | if (!v.parse (SvPV_nolen (sv))) |
640 | if (!v.parse (SvPV_nolen (sv))) |
… | |
… | |
1397 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1412 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1398 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1413 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1399 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1414 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1400 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1415 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1401 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1416 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
|
|
1417 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
1402 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1418 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1403 | |
1419 | |
1404 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1420 | 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); |
1421 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
|
|
1422 | 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); |
1423 | 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); |
1424 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1408 | |
1425 | |
1409 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1426 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1410 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1427 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1411 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1428 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1412 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1429 | cb_player = get_av ("cf::CB_PLAYER", 1); |
… | |
… | |
1455 | # include "attackinc.h" |
1472 | # include "attackinc.h" |
1456 | # undef def |
1473 | # undef def |
1457 | # define def(uc, flags) const_iv (SK_ ## uc) |
1474 | # define def(uc, flags) const_iv (SK_ ## uc) |
1458 | # include "skillinc.h" |
1475 | # include "skillinc.h" |
1459 | # undef def |
1476 | # undef def |
1460 | |
1477 | # define def(name, use, nonuse) const_iv (body_ ## name) |
1461 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1478 | # include "slotinc.h" |
|
|
1479 | # undef def |
1462 | |
1480 | |
1463 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1481 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1464 | |
1482 | |
1465 | const_iv (MAX_TIME) |
1483 | const_iv (MAX_TIME) |
1466 | const_iv (MAXSOCKBUF) |
1484 | const_iv (MAXSOCKBUF) |
… | |
… | |
1479 | |
1497 | |
1480 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1498 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1481 | |
1499 | |
1482 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1500 | 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) |
1501 | 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 | |
1502 | |
1488 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1503 | 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) |
1504 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1490 | |
1505 | |
1491 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1506 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
… | |
… | |
1524 | |
1539 | |
1525 | void _gv_clear (SV *gv) |
1540 | void _gv_clear (SV *gv) |
1526 | CODE: |
1541 | CODE: |
1527 | assert (SvTYPE (gv) == SVt_PVGV); |
1542 | assert (SvTYPE (gv) == SVt_PVGV); |
1528 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
1543 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
|
|
1544 | SvREFCNT_inc (gv); |
1529 | f (GvGP (gv)->gp_form); |
1545 | f (GvGP (gv)->gp_form); |
1530 | f (GvGP (gv)->gp_io); |
1546 | f (GvGP (gv)->gp_io); |
1531 | f (GvGP (gv)->gp_sv); |
1547 | f (GvGP (gv)->gp_sv); |
1532 | f (GvGP (gv)->gp_av); |
1548 | f (GvGP (gv)->gp_av); |
1533 | f (GvGP (gv)->gp_hv); |
1549 | f (GvGP (gv)->gp_hv); |
1534 | f (GvGP (gv)->gp_cv); |
1550 | f (GvGP (gv)->gp_cv); |
1535 | GvCVGEN (gv) = 0; |
1551 | GvCVGEN (gv) = 0; |
1536 | GvMULTI_off (gv); |
1552 | GvMULTI_off (gv); |
|
|
1553 | SvREFCNT_dec (gv); |
1537 | # undef f |
1554 | # undef f |
1538 | |
1555 | |
1539 | void _connect_to_perl_1 () |
1556 | void _connect_to_perl_1 () |
1540 | |
1557 | |
1541 | void _connect_to_perl_2 () |
1558 | void _connect_to_perl_2 () |
… | |
… | |
1552 | |
1569 | |
1553 | for_all_objects (op) |
1570 | for_all_objects (op) |
1554 | op->reattach (); |
1571 | op->reattach (); |
1555 | } |
1572 | } |
1556 | |
1573 | |
1557 | # support function for map-world.ext |
|
|
1558 | void _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 | |
|
|
1599 | void init_anim () |
1574 | void init_anim () |
1600 | |
1575 | |
1601 | void init_globals () |
1576 | void init_globals () |
1602 | |
1577 | |
1603 | void init_attackmess () |
1578 | void init_attackmess () |
… | |
… | |
1649 | { |
1624 | { |
1650 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1625 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1651 | coroapi::cede (); |
1626 | coroapi::cede (); |
1652 | } |
1627 | } |
1653 | |
1628 | |
1654 | void server_tick () |
1629 | void one_tick () |
1655 | CODE: |
1630 | CODE: |
1656 | { |
1631 | { |
1657 | ev_now_update (EV_DEFAULT); |
1632 | ev_now_update (EV_DEFAULT); |
1658 | NOW = ev_now (EV_DEFAULT); |
1633 | NOW = ev_now (EV_DEFAULT); |
1659 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1634 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1660 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1635 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1661 | runtime = SvNVX (sv_runtime); |
1636 | runtime = SvNVX (sv_runtime); |
1662 | |
1637 | |
|
|
1638 | one_tick (); |
|
|
1639 | |
1663 | server_tick (); |
1640 | ++server_tick; |
|
|
1641 | SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick); |
1664 | |
1642 | |
1665 | ev_now_update (EV_DEFAULT); |
1643 | ev_now_update (EV_DEFAULT); |
1666 | NOW = ev_now (EV_DEFAULT); |
1644 | NOW = ev_now (EV_DEFAULT); |
1667 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1645 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
|
|
1646 | |
1668 | runtime += TICK; |
1647 | runtime += TICK; |
1669 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1648 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1670 | } |
1649 | } |
1671 | |
1650 | |
1672 | NV floor (NV x) |
1651 | NV floor (NV x) |
… | |
… | |
1771 | |
1750 | |
1772 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1751 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1773 | INIT: |
1752 | INIT: |
1774 | #if __GLIBC__ |
1753 | #if __GLIBC__ |
1775 | mallopt (M_TOP_PAD, 1024 * 1024); |
1754 | mallopt (M_TOP_PAD, 1024 * 1024); |
1776 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); |
1755 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024); |
1777 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1756 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
|
|
1757 | if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10)) |
1778 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1758 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1779 | #endif |
1759 | #endif |
1780 | |
1760 | |
1781 | int munlockall () |
1761 | int munlockall () |
1782 | |
1762 | |
1783 | #endif |
1763 | #endif |
… | |
… | |
1821 | int exp_to_level (val64 exp) |
1801 | int exp_to_level (val64 exp) |
1822 | |
1802 | |
1823 | val64 level_to_min_exp (int level) |
1803 | val64 level_to_min_exp (int level) |
1824 | |
1804 | |
1825 | SV * |
1805 | SV * |
1826 | resistance_to_string (int atnr) |
1806 | attacktype_name (int atnr) |
1827 | CODE: |
1807 | CODE: |
1828 | if (atnr >= 0 && atnr < NROFATTACKS) |
1808 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1809 | ? newSVpv (attacktype_name [atnr], 0) |
|
|
1810 | : &PL_sv_undef; |
|
|
1811 | OUTPUT: RETVAL |
|
|
1812 | |
|
|
1813 | SV * |
|
|
1814 | attacktype_desc (int atnr) |
|
|
1815 | CODE: |
|
|
1816 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1817 | ? newSVpv (attacktype_desc [atnr], 0) |
|
|
1818 | : &PL_sv_undef; |
|
|
1819 | OUTPUT: RETVAL |
|
|
1820 | |
|
|
1821 | SV * |
|
|
1822 | resist_plus (int atnr) |
|
|
1823 | CODE: |
|
|
1824 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1829 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1825 | ? newSVpv (resist_plus [atnr], 0) |
1830 | else |
1826 | : &PL_sv_undef; |
1831 | XSRETURN_UNDEF; |
1827 | OUTPUT: RETVAL |
|
|
1828 | |
|
|
1829 | SV * |
|
|
1830 | change_resist_msg (int atnr) |
|
|
1831 | CODE: |
|
|
1832 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1833 | ? newSVpv (change_resist_msg [atnr], 0) |
|
|
1834 | : &PL_sv_undef; |
1832 | OUTPUT: RETVAL |
1835 | OUTPUT: RETVAL |
1833 | |
1836 | |
1834 | UUID |
1837 | UUID |
1835 | uuid_cur () |
1838 | uuid_cur () |
1836 | CODE: |
1839 | CODE: |
… | |
… | |
1959 | int mortals_size () |
1962 | int mortals_size () |
1960 | CODE: |
1963 | CODE: |
1961 | RETVAL = attachable::mortals.size (); |
1964 | RETVAL = attachable::mortals.size (); |
1962 | OUTPUT: RETVAL |
1965 | OUTPUT: RETVAL |
1963 | |
1966 | |
1964 | const_utf8_string slot_use_name (U32 slot) |
1967 | const_utf8_string slot_name (U32 slot) |
1965 | ALIAS: |
1968 | ALIAS: |
|
|
1969 | slot_name = 0 |
|
|
1970 | slot_use_name = 1 |
1966 | slot_nonuse_name = 1 |
1971 | slot_nonuse_name = 2 |
1967 | CODE: |
1972 | CODE: |
1968 | { |
1973 | { |
1969 | if (slot >= NUM_BODY_LOCATIONS) |
1974 | if (slot >= NUM_BODY_LOCATIONS) |
1970 | croak ("body slot index out of range"); |
1975 | croak ("body slot index out of range"); |
1971 | |
1976 | |
1972 | switch (ix) |
1977 | switch (ix) |
1973 | { |
1978 | { |
|
|
1979 | case 0: RETVAL = body_locations[slot].name ; break; |
1974 | case 0: RETVAL = body_locations[slot].use_name; break; |
1980 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1975 | case 1: RETVAL = body_locations[slot].nonuse_name; break; |
1981 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1976 | } |
1982 | } |
1977 | } |
1983 | } |
1978 | OUTPUT: |
1984 | OUTPUT: |
1979 | RETVAL |
1985 | RETVAL |
1980 | |
1986 | |
… | |
… | |
2112 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2118 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2113 | |
2119 | |
2114 | object *new (utf8_string archetype = 0) |
2120 | object *new (utf8_string archetype = 0) |
2115 | PROTOTYPE: ;$ |
2121 | PROTOTYPE: ;$ |
2116 | CODE: |
2122 | CODE: |
2117 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
2123 | RETVAL = archetype |
|
|
2124 | ? archetype::get (archetype) |
|
|
2125 | : object::create (); |
2118 | OUTPUT: |
2126 | OUTPUT: |
2119 | RETVAL |
2127 | RETVAL |
2120 | |
2128 | |
2121 | object *generate (utf8_string arch, object *creator) |
2129 | object *generate (utf8_string arch, object *creator) |
2122 | CODE: |
2130 | CODE: |
2123 | object *obj = get_archetype (arch); |
2131 | object *obj = archetype::get (arch); |
2124 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2132 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2125 | RETVAL = obj; |
2133 | RETVAL = obj; |
2126 | OUTPUT: |
2134 | OUTPUT: |
2127 | RETVAL |
2135 | RETVAL |
2128 | |
2136 | |
… | |
… | |
2138 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2146 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2139 | |
2147 | |
2140 | if (RETVAL->destroyed ()) |
2148 | if (RETVAL->destroyed ()) |
2141 | RETVAL = 0; |
2149 | RETVAL = 0; |
2142 | } |
2150 | } |
|
|
2151 | OUTPUT: |
|
|
2152 | RETVAL |
2143 | |
2153 | |
2144 | shstr |
2154 | shstr |
2145 | object::kv_get (shstr key) |
2155 | object::kv_get (shstr key) |
|
|
2156 | CODE: |
|
|
2157 | RETVAL = THIS->kv.get (key); |
|
|
2158 | OUTPUT: |
|
|
2159 | RETVAL |
2146 | |
2160 | |
2147 | void |
2161 | void |
2148 | object::kv_del (shstr key) |
2162 | object::kv_del (shstr key) |
|
|
2163 | CODE: |
|
|
2164 | THIS->kv.del (key); |
2149 | |
2165 | |
2150 | void |
2166 | void |
2151 | object::kv_set (shstr key, shstr value) |
2167 | object::kv_set (shstr key, shstr value) |
|
|
2168 | CODE: |
|
|
2169 | THIS->kv.set (key, value); |
2152 | |
2170 | |
2153 | object *get_nearest_player (object *ob) |
2171 | object *get_nearest_player (object *ob) |
2154 | ALIAS: nearest_player = 0 |
2172 | ALIAS: nearest_player = 0 |
2155 | PREINIT: |
2173 | PREINIT: |
2156 | extern object *get_nearest_player (object *); |
2174 | extern object *get_nearest_player (object *); |
… | |
… | |
2359 | if (pl->ob && pl->ob->map == THIS) |
2377 | if (pl->ob && pl->ob->map == THIS) |
2360 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2378 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2361 | } |
2379 | } |
2362 | |
2380 | |
2363 | void |
2381 | void |
|
|
2382 | maptile::gen_quadmap (int x, int y, int z) |
|
|
2383 | CODE: |
|
|
2384 | gen_quadmap (THIS, x * 50, y * 50, z); |
|
|
2385 | |
|
|
2386 | void |
2364 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2387 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2365 | CODE: |
2388 | CODE: |
2366 | { |
2389 | { |
2367 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2390 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2368 | croak ("maptile::add_underlay: palette must be arrayref"); |
2391 | croak ("maptile::add_underlay: palette must be arrayref"); |
… | |
… | |
2384 | |
2407 | |
2385 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2408 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2386 | { |
2409 | { |
2387 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2410 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2388 | { |
2411 | { |
2389 | object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); |
2412 | object *ob = archetype::get (cfSvPVutf8_nolen (*elem)); |
2390 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2413 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2391 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2414 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2392 | |
2415 | |
2393 | if (ob->randomitems && !ob->above) |
2416 | if (ob->randomitems && !ob->above) |
2394 | { |
2417 | { |
… | |
… | |
2398 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2421 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2399 | // TODO: if this is a pickable object, then the item |
2422 | // TODO: if this is a pickable object, then the item |
2400 | // will at a bit weird - saving inside the player |
2423 | // will at a bit weird - saving inside the player |
2401 | // will clear the flag, but when the player drops |
2424 | // will clear the flag, but when the player drops |
2402 | // it without logging out, it keeps the flag. |
2425 | // it without logging out, it keeps the flag. |
2403 | // nobody ahs reported this, but this can be rather |
2426 | // nobody has reported this, but this can be rather |
2404 | // annoying on persistent maps. |
2427 | // annoying on persistent maps. |
2405 | } |
2428 | } |
2406 | } |
2429 | } |
2407 | } |
2430 | } |
2408 | } |
2431 | } |
2409 | |
|
|
2410 | skip: ; |
2432 | skip: ; |
2411 | } |
2433 | } |
2412 | } |
2434 | } |
2413 | |
2435 | |
2414 | void |
2436 | void |
… | |
… | |
2445 | for (int x = 0; x < THIS->width; ++x) |
2467 | for (int x = 0; x < THIS->width; ++x) |
2446 | for (int y = 0; y < THIS->height; ++y) |
2468 | for (int y = 0; y < THIS->height; ++y) |
2447 | { |
2469 | { |
2448 | region *rgn = THIS->region (x, y); |
2470 | region *rgn = THIS->region (x, y); |
2449 | |
2471 | |
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) |
2472 | if (object *op = THIS->at (x, y).top) |
2452 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2473 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2453 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2474 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2454 | } |
2475 | } |
2455 | |
2476 | |
… | |
… | |
2534 | } |
2555 | } |
2535 | OUTPUT: RETVAL |
2556 | OUTPUT: RETVAL |
2536 | |
2557 | |
2537 | # worst xs function of my life |
2558 | # worst xs function of my life |
2538 | bool |
2559 | bool |
2539 | _create_random_map (\ |
2560 | _create_random_map (maptile *self, SV *options) |
2540 | maptile *self,\ |
|
|
2541 | SV *options,\ |
|
|
2542 | val64 total_map_hp,\ |
|
|
2543 | region *region\ |
|
|
2544 | ) |
|
|
2545 | CODE: |
2561 | CODE: |
2546 | { |
2562 | { |
2547 | random_map_params rmp; |
2563 | 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); |
2564 | RETVAL = self->generate_random_map (&rmp); |
2582 | } |
2565 | } |
2583 | OUTPUT: |
2566 | OUTPUT: |
2584 | RETVAL |
2567 | RETVAL |
2585 | |
2568 | |
… | |
… | |
2654 | list () |
2637 | list () |
2655 | PPCODE: |
2638 | PPCODE: |
2656 | EXTEND (SP, clients.size ()); |
2639 | EXTEND (SP, clients.size ()); |
2657 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2640 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2658 | PUSHs (sv_2mortal (to_sv (*i))); |
2641 | PUSHs (sv_2mortal (to_sv (*i))); |
|
|
2642 | |
|
|
2643 | STRLEN |
|
|
2644 | client::inbuf_append (SV *data) |
|
|
2645 | CODE: |
|
|
2646 | { |
|
|
2647 | STRLEN len; |
|
|
2648 | char *ptr = SvPVbyte (data, len); |
|
|
2649 | |
|
|
2650 | min_it (len, sizeof (THIS->inbuf) - THIS->inbuf_len); |
|
|
2651 | memcpy (THIS->inbuf + THIS->inbuf_len, ptr, len); |
|
|
2652 | THIS->inbuf_len += len; |
|
|
2653 | |
|
|
2654 | THIS->inbuf_handle (); |
|
|
2655 | |
|
|
2656 | RETVAL = len; |
|
|
2657 | } |
|
|
2658 | OUTPUT: RETVAL |
2659 | |
2659 | |
2660 | void |
2660 | void |
2661 | client::send_packet (SV *packet) |
2661 | client::send_packet (SV *packet) |
2662 | CODE: |
2662 | CODE: |
2663 | { |
2663 | { |
… | |
… | |
2719 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2719 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2720 | |
2720 | |
2721 | faceidx alloc (utf8_string name) |
2721 | faceidx alloc (utf8_string name) |
2722 | CODE: |
2722 | CODE: |
2723 | { |
2723 | { |
2724 | do |
2724 | RETVAL = face_alloc (); |
2725 | { |
|
|
2726 | RETVAL = faces.size (); |
|
|
2727 | faces.resize (RETVAL + 1); |
|
|
2728 | } |
|
|
2729 | while (!RETVAL); // crude way to leave index 0 |
|
|
2730 | |
2725 | |
2731 | faces [RETVAL].name = name; |
2726 | faces [RETVAL].name = name; |
2732 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2727 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2733 | |
2728 | |
2734 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2729 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2735 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2730 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2736 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2731 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2737 | } |
2732 | } |
|
|
2733 | OUTPUT: RETVAL |
|
|
2734 | |
|
|
2735 | faceidx faces_size () |
|
|
2736 | CODE: |
|
|
2737 | RETVAL = faces.size (); |
2738 | OUTPUT: RETVAL |
2738 | OUTPUT: RETVAL |
2739 | |
2739 | |
2740 | void set_type (faceidx idx, int value) |
2740 | void set_type (faceidx idx, int value) |
2741 | ALIAS: |
2741 | ALIAS: |
2742 | set_type = 0 |
2742 | set_type = 0 |
… | |
… | |
2757 | |
2757 | |
2758 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2758 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2759 | CODE: |
2759 | CODE: |
2760 | { |
2760 | { |
2761 | faceinfo *f = face_info (idx); assert (f); |
2761 | faceinfo *f = face_info (idx); assert (f); |
2762 | facedata *d = &(faceset ? f->data64 : f->data32); |
2762 | facedata *d = f->face + faceset; |
2763 | sv_to (data, d->data); |
2763 | sv_to (data, d->data); |
2764 | STRLEN clen; |
2764 | STRLEN clen; |
2765 | char *cdata = SvPVbyte (chksum, clen); |
2765 | char *cdata = SvPVbyte (chksum, clen); |
2766 | clen = min (CHKSUM_MAXLEN, clen); |
2766 | clen = min (CHKSUM_MAXLEN, clen); |
2767 | |
2767 | |
… | |
… | |
2788 | if (!d) XSRETURN_UNDEF; |
2788 | if (!d) XSRETURN_UNDEF; |
2789 | RETVAL = d->data.size (); |
2789 | RETVAL = d->data.size (); |
2790 | OUTPUT: |
2790 | OUTPUT: |
2791 | RETVAL |
2791 | RETVAL |
2792 | |
2792 | |
|
|
2793 | void set_meta (faceidx idx, SV *sv) |
|
|
2794 | CODE: |
|
|
2795 | { |
|
|
2796 | faceinfo *f = face_info (idx); assert (f); |
|
|
2797 | SvREFCNT_dec (f->meta_hv); |
|
|
2798 | f->meta_hv = SvOK (sv) ? (HV *)SvREFCNT_inc (SvRV (sv)) : 0; |
|
|
2799 | } |
|
|
2800 | |
2793 | SV *get_chksum (faceidx idx, int faceset = 0) |
2801 | SV *get_chksum (faceidx idx, int faceset = 0) |
2794 | CODE: |
2802 | CODE: |
2795 | facedata *d = face_data (idx, faceset); |
2803 | facedata *d = face_data (idx, faceset); |
2796 | if (!d) XSRETURN_UNDEF; |
2804 | if (!d) XSRETURN_UNDEF; |
2797 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2805 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2798 | OUTPUT: |
2806 | OUTPUT: |
2799 | RETVAL |
2807 | RETVAL |
2800 | |
2808 | |
|
|
2809 | int get_type (faceidx idx) |
|
|
2810 | CODE: |
|
|
2811 | faceinfo *f = face_info (idx); |
|
|
2812 | if (!f) XSRETURN_UNDEF; |
|
|
2813 | RETVAL = f->type; |
|
|
2814 | OUTPUT: |
|
|
2815 | RETVAL |
|
|
2816 | |
|
|
2817 | SV *get_name (faceidx idx) |
|
|
2818 | CODE: |
|
|
2819 | faceinfo *f = face_info (idx); |
|
|
2820 | if (!f) XSRETURN_UNDEF; |
|
|
2821 | RETVAL = to_sv (f->name); |
|
|
2822 | OUTPUT: |
|
|
2823 | RETVAL |
|
|
2824 | |
2801 | SV *get_data (faceidx idx, int faceset = 0) |
2825 | SV *get_data (faceidx idx, int faceset = 0) |
2802 | CODE: |
2826 | CODE: |
2803 | facedata *d = face_data (idx, faceset); |
2827 | facedata *d = face_data (idx, faceset); |
2804 | if (!d) XSRETURN_UNDEF; |
2828 | if (!d) XSRETURN_UNDEF; |
2805 | RETVAL = newSVpvn (d->data.data (), d->data.length ()); |
2829 | RETVAL = newSVpvn (d->data, d->data.size ()); |
2806 | OUTPUT: |
2830 | OUTPUT: |
2807 | RETVAL |
2831 | RETVAL |
2808 | |
2832 | |
|
|
2833 | SV *get_meta (faceidx idx) |
|
|
2834 | CODE: |
|
|
2835 | faceinfo *f = face_info (idx); assert (f); |
|
|
2836 | if (!f || !f->meta_hv) XSRETURN_UNDEF; |
|
|
2837 | RETVAL = newRV_inc ((SV *)f->meta_hv); |
|
|
2838 | OUTPUT: |
|
|
2839 | RETVAL |
|
|
2840 | |
2809 | void invalidate (faceidx idx) |
2841 | void invalidate (faceidx idx) |
2810 | CODE: |
2842 | CODE: |
2811 | for_all_clients (ns) |
2843 | for_all_clients (ns) |
2812 | { |
2844 | ns->invalidate_face (idx); |
2813 | ns->faces_sent [idx] = false; |
|
|
2814 | ns->force_newmap = true; |
|
|
2815 | } |
|
|
2816 | |
2845 | |
2817 | void invalidate_all () |
2846 | void invalidate_all () |
2818 | CODE: |
2847 | CODE: |
2819 | for_all_clients (ns) |
2848 | for_all_clients (ns) |
2820 | { |
2849 | ns->invalidate_all_faces (); |
2821 | ns->faces_sent.reset (); |
|
|
2822 | ns->force_newmap = true; |
|
|
2823 | } |
|
|
2824 | |
2850 | |
2825 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2851 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2826 | |
2852 | |
2827 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2853 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2828 | |
2854 | |
… | |
… | |
2832 | OUTPUT: RETVAL |
2858 | OUTPUT: RETVAL |
2833 | |
2859 | |
2834 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2860 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2835 | CODE: |
2861 | CODE: |
2836 | { |
2862 | { |
2837 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2863 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2838 | croak ("frames must be an arrayref"); |
2864 | croak ("frames must be an arrayref"); |
2839 | |
2865 | |
2840 | AV *av = (AV *)SvRV (frames); |
2866 | AV *av = (AV *)SvRV (frames); |
2841 | |
2867 | |
2842 | animation *anim = &animation::find (name); |
2868 | animation *anim = &animation::find (name); |
2843 | if (anim->number) |
2869 | if (anim->number) |
2844 | { |
2870 | { |
2845 | anim->resize (av_len (av) + 1); |
2871 | anim->resize (av_len (av) + 1); |
2846 | anim->facings = facings; |
2872 | anim->facings = facings; |
2847 | } |
2873 | } |
… | |
… | |
2919 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2945 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2920 | |
2946 | |
2921 | self->skip (); |
2947 | self->skip (); |
2922 | } |
2948 | } |
2923 | |
2949 | |
|
|
2950 | MODULE = cf PACKAGE = cf::layout |
|
|
2951 | |
|
|
2952 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
|
|
2953 | |