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.407 by root, Sat Oct 15 00:58:14 2011 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
92 92
93static SV 93static SV
94 *cv_cf_do_invoke, 94 *cv_cf_do_invoke,
95 *cv_cf__can_merge, 95 *cv_cf__can_merge,
96 *cv_cf_client_send_msg, 96 *cv_cf_client_send_msg,
97 *cv_cf_ix,
97 *cv_cf_tick, 98 *cv_cf_tick,
98 *cv_cf_match_match; 99 *cv_cf_match_match;
99 100
100#ifndef newSVpv_utf8 101#ifndef newSVpv_utf8
101static SV * 102static SV *
625 STRLEN len; 626 STRLEN len;
626 char *data = SvPVbyte (sv, len); 627 char *data = SvPVbyte (sv, len);
627 v.assign (data, len); 628 v.assign (data, len);
628} 629}
629 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
630static inline void sv_to (SV *sv, UUID &v) 639static inline void sv_to (SV *sv, UUID &v)
631{ 640{
632 if (!v.parse (SvPV_nolen (sv))) 641 if (!v.parse (SvPV_nolen (sv)))
633 croak ("unparsable uuid: %s", SvPV_nolen (sv)); 642 croak ("unparsable uuid: %s", SvPV_nolen (sv));
634} 643}
1149 CALL_ARG (originator); 1158 CALL_ARG (originator);
1150 CALL_CALL ("cf::mapscript::activate", G_VOID); 1159 CALL_CALL ("cf::mapscript::activate", G_VOID);
1151 CALL_END; 1160 CALL_END;
1152} 1161}
1153 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
1154player * 1174player *
1155player::find (const_utf8_string name) 1175player::find (const_utf8_string name)
1156{ 1176{
1157 CALL_BEGIN (1); 1177 CALL_BEGIN (1);
1158 CALL_ARG (name); 1178 CALL_ARG (name);
1428_connect_to_perl_2 () 1448_connect_to_perl_2 ()
1429{ 1449{
1430 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);
1431 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);
1432 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);
1433 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);
1434 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);
1435} 1456}
1436 1457
1437MODULE = cf PACKAGE = cf PREFIX = cf_ 1458MODULE = cf PACKAGE = cf PREFIX = cf_
1442 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1463 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1443 1464
1444 _connect_to_perl_1 (); 1465 _connect_to_perl_1 ();
1445 1466
1446 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1467 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1447
1448 //{
1449 // require_pv ("Time::HiRes");
1450 //
1451 // SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0);
1452 // if (!svp) croak ("Time::HiRes is required");
1453 // if (!SvIOK(*svp)) croak ("Time::NVtime isn’t a function pointer");
1454 // coroapi::time = INT2PTR (double(*)(), SvIV(*svp));
1455 //}
1456 1468
1457 static const struct { 1469 static const struct {
1458 const char *name; 1470 const char *name;
1459 IV iv; 1471 IV iv;
1460 } *civ, const_iv[] = { 1472 } *civ, const_iv[] = {
1531 1543
1532void _gv_clear (SV *gv) 1544void _gv_clear (SV *gv)
1533 CODE: 1545 CODE:
1534 assert (SvTYPE (gv) == SVt_PVGV); 1546 assert (SvTYPE (gv) == SVt_PVGV);
1535# 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);
1536 f (GvGP (gv)->gp_form); 1549 f (GvGP (gv)->gp_form);
1537 f (GvGP (gv)->gp_io); 1550 f (GvGP (gv)->gp_io);
1538 f (GvGP (gv)->gp_sv); 1551 f (GvGP (gv)->gp_sv);
1539 f (GvGP (gv)->gp_av); 1552 f (GvGP (gv)->gp_av);
1540 f (GvGP (gv)->gp_hv); 1553 f (GvGP (gv)->gp_hv);
1541 f (GvGP (gv)->gp_cv); 1554 f (GvGP (gv)->gp_cv);
1542 GvCVGEN (gv) = 0; 1555 GvCVGEN (gv) = 0;
1543 GvMULTI_off (gv); 1556 GvMULTI_off (gv);
1557 SvREFCNT_dec (gv);
1544# undef f 1558# undef f
1545 1559
1546void _connect_to_perl_1 () 1560void _connect_to_perl_1 ()
1547 1561
1548void _connect_to_perl_2 () 1562void _connect_to_perl_2 ()
1569 1583
1570void init_dynamic () 1584void init_dynamic ()
1571 1585
1572void load_settings () 1586void load_settings ()
1573 1587
1574void reload_exp_table () 1588void _reload_exp_table ()
1575 1589
1576void reload_materials () 1590void _reload_materials ()
1577 1591
1578void init_uuid () 1592void init_uuid ()
1579 CODE: 1593 CODE:
1580 UUID::init (); 1594 UUID::init ();
1581 1595
1645NV rndm (...) 1659NV rndm (...)
1646 ALIAS: 1660 ALIAS:
1647 rmg_rndm = 1 1661 rmg_rndm = 1
1648 CODE: 1662 CODE:
1649{ 1663{
1650 rand_gen &gen = ix ? rmg_rndm : rndm; 1664 rand_gen &gen = ix ? rmg_rndm : rndm;
1651 switch (items) 1665 switch (items)
1652 { 1666 {
1653 case 0: RETVAL = gen (); break; 1667 case 0: RETVAL = gen (); break;
1654 case 1: RETVAL = gen (SvUV (ST (0))); break; 1668 case 1: RETVAL = gen (SvUV (ST (0))); break;
1655 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; 1669 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break;
1779 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))));
1780 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)));
1781 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)));
1782} 1796}
1783 1797
1784int find_animation (utf8_string text)
1785 PROTOTYPE: $
1786
1787int random_roll (int min, int max, object *op, int goodbad); 1798int random_roll (int min, int max, object *op, int goodbad);
1788 1799
1789const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1800const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1790 1801
1791int exp_to_level (val64 exp) 1802int exp_to_level (val64 exp)
1792 1803
1793val64 level_to_min_exp (int level) 1804val64 level_to_min_exp (int level)
1805
1806const_utf8_string
1807spellpathnames (int idx)
1808 CODE:
1809 RETVAL = spellpathnames [idx];
1810 OUTPUT: RETVAL
1794 1811
1795SV * 1812SV *
1796attacktype_name (int atnr) 1813attacktype_name (int atnr)
1797 CODE: 1814 CODE:
1798 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) 1815 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1870load_resource_file_ (octet_string filename) 1887load_resource_file_ (octet_string filename)
1871 1888
1872void 1889void
1873fix_weight () 1890fix_weight ()
1874 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
1875MODULE = cf PACKAGE = cf::attachable 1897MODULE = cf PACKAGE = cf::attachable
1876 1898
1877int 1899int
1878valid (SV *obj) 1900valid (SV *obj)
1879 CODE: 1901 CODE:
2101int convert_item (object *item, object *converter) 2123int convert_item (object *item, object *converter)
2102 2124
2103void 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);
2104 2126
2105MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2127MODULE = cf PACKAGE = cf::object PREFIX = cf_
2106
2107# no clean way to get an object from an archetype - stupid idiotic
2108# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2109 2128
2110object *new (utf8_string archetype = 0) 2129object *new (utf8_string archetype = 0)
2111 PROTOTYPE: ;$ 2130 PROTOTYPE: ;$
2112 CODE: 2131 CODE:
2113 RETVAL = archetype 2132 RETVAL = archetype
2381 croak ("maptile::add_underlay: palette must be arrayref"); 2400 croak ("maptile::add_underlay: palette must be arrayref");
2382 2401
2383 palette = SvRV (palette); 2402 palette = SvRV (palette);
2384 2403
2385 STRLEN idxlen; 2404 STRLEN idxlen;
2386 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); 2405 const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen);
2387 2406
2388 for (int x = 0; x < THIS->width; ++x) 2407 for (int x = 0; x < THIS->width; ++x)
2389 for (int y = 0; y < THIS->height; ++y) 2408 for (int y = 0; y < THIS->height; ++y)
2390 { 2409 {
2391 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)
2431 croak ("maptile::set_regiondata: palette must be arrayref"); 2450 croak ("maptile::set_regiondata: palette must be arrayref");
2432 2451
2433 palette = SvRV (palette); 2452 palette = SvRV (palette);
2434 2453
2435 STRLEN idxlen; 2454 STRLEN idxlen;
2436 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); 2455 const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen);
2437 2456
2438 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; 2457 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1];
2439 uint8_t *regions = salloc<uint8_t> (THIS->size ()); 2458 uint8 *regions = salloc<uint8_t> (THIS->size ());
2440 2459
2441 for (int i = av_len ((AV *)palette) + 1; i--; ) 2460 for (int i = av_len ((AV *)palette) + 1; i--; )
2442 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)));
2443 2462
2444 for (int y = 0; y < THIS->height; ++y) 2463 for (int y = 0; y < THIS->height; ++y)
2570archetype *archetypes (U32 index) 2589archetype *archetypes (U32 index)
2571 CODE: 2590 CODE:
2572 RETVAL = index < archetypes.size () ? archetypes [index] : 0; 2591 RETVAL = index < archetypes.size () ? archetypes [index] : 0;
2573 OUTPUT: RETVAL 2592 OUTPUT: RETVAL
2574 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)));
2610
2575INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | 2611INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h |
2576 2612
2577MODULE = cf PACKAGE = cf::party 2613MODULE = cf PACKAGE = cf::party
2578 2614
2579partylist *first () 2615partylist *first ()
2627list () 2663list ()
2628 PPCODE: 2664 PPCODE:
2629 EXTEND (SP, clients.size ()); 2665 EXTEND (SP, clients.size ());
2630 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 2666 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
2631 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
2632 2685
2633void 2686void
2634client::send_packet (SV *packet) 2687client::send_packet (SV *packet)
2635 CODE: 2688 CODE:
2636{ 2689{
2692faceidx face_find (utf8_string name, faceidx defidx = 0) 2745faceidx face_find (utf8_string name, faceidx defidx = 0)
2693 2746
2694faceidx alloc (utf8_string name) 2747faceidx alloc (utf8_string name)
2695 CODE: 2748 CODE:
2696{ 2749{
2697 do 2750 RETVAL = face_alloc ();
2698 {
2699 RETVAL = faces.size ();
2700 faces.resize (RETVAL + 1);
2701 }
2702 while (!RETVAL); // crude way to leave index 0
2703 2751
2704 faces [RETVAL].name = name; 2752 faces [RETVAL].name = name;
2705 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); 2753 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL));
2706 2754
2707 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; 2755 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL;
2708 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; 2756 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL;
2709 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; 2757 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL;
2710} 2758}
2759 OUTPUT: RETVAL
2760
2761faceidx faces_size ()
2762 CODE:
2763 RETVAL = faces.size ();
2711 OUTPUT: RETVAL 2764 OUTPUT: RETVAL
2712 2765
2713void set_type (faceidx idx, int value) 2766void set_type (faceidx idx, int value)
2714 ALIAS: 2767 ALIAS:
2715 set_type = 0 2768 set_type = 0
2726 case 2: f->magicmap = value; break; 2779 case 2: f->magicmap = value; break;
2727 case 3: f->smooth = value; break; 2780 case 3: f->smooth = value; break;
2728 case 4: f->smoothlevel = value; break; 2781 case 4: f->smoothlevel = value; break;
2729 } 2782 }
2730 2783
2731void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2784void set_csum (faceidx idx, int faceset, SV *chksum)
2732 CODE: 2785 CODE:
2733{ 2786{
2734 faceinfo *f = face_info (idx); assert (f); 2787 faceinfo *f = face_info (idx); assert (f);
2735 facedata *d = f->face + faceset; 2788 facedata *d = f->face + faceset;
2736 sv_to (data, d->data);
2737 STRLEN clen; 2789 STRLEN clen;
2738 char *cdata = SvPVbyte (chksum, clen); 2790 char *cdata = SvPVbyte (chksum, clen);
2739 clen = min (CHKSUM_MAXLEN, clen);
2740 2791
2792 assert (("cf::face::set_data called with too long checksum", clen <= CHKSUM_MAXLEN));
2741 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));
2742 2794
2743 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) 2795 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen))
2744 { 2796 {
2745 d->chksum_len = clen; 2797 d->chksum_len = clen;
2746 memcpy (d->chksum, cdata, clen); 2798 memcpy (d->chksum, cdata, clen);
2747 2799
2748 // invalidate existing client face info 2800 // invalidate existing client face info
2749 for_all_clients (ns) 2801 for_all_clients (ns)
2750 if (ns->faceset == faceset) 2802 ns->invalidate_face (idx);
2751 {
2752 ns->faces_sent [idx] = false;
2753 ns->force_newmap = true;
2754 }
2755 } 2803 }
2756} 2804}
2757 2805
2758int get_data_size (faceidx idx, int faceset = 0) 2806SV *mangle_csum (SV *chksum)
2759 CODE: 2807 CODE:
2760 facedata *d = face_data (idx, faceset); 2808 STRLEN len;
2761 if (!d) XSRETURN_UNDEF; 2809 char *data = SvPVbyte (chksum, len);
2762 RETVAL = d->data.size (); 2810 RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN));
2763 OUTPUT: 2811 OUTPUT:
2764 RETVAL 2812 RETVAL
2765 2813
2766SV *get_chksum (faceidx idx, int faceset = 0) 2814SV *get_csum (faceidx idx, int faceset = 0)
2767 CODE: 2815 CODE:
2768 facedata *d = face_data (idx, faceset); 2816 facedata *d = face_data (idx, faceset);
2769 if (!d) XSRETURN_UNDEF; 2817 if (!d) XSRETURN_UNDEF;
2770 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); 2818 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len);
2771 OUTPUT: 2819 OUTPUT:
2772 RETVAL 2820 RETVAL
2773 2821
2774SV *get_data (faceidx idx, int faceset = 0) 2822int get_type (faceidx idx)
2775 CODE: 2823 CODE:
2776 facedata *d = face_data (idx, faceset); 2824 faceinfo *f = face_info (idx);
2777 if (!d) XSRETURN_UNDEF; 2825 if (!f) XSRETURN_UNDEF;
2778 RETVAL = newSVpvn (d->data.data (), d->data.length ()); 2826 RETVAL = f->type;
2779 OUTPUT: 2827 OUTPUT:
2780 RETVAL 2828 RETVAL
2781 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
2782void invalidate (faceidx idx) 2838void invalidate (faceidx idx)
2783 CODE: 2839 CODE:
2784 for_all_clients (ns) 2840 for_all_clients (ns)
2785 { 2841 ns->invalidate_face (idx);
2786 ns->faces_sent [idx] = false;
2787 ns->force_newmap = true;
2788 }
2789 2842
2790void invalidate_all () 2843void invalidate_all ()
2791 CODE: 2844 CODE:
2792 for_all_clients (ns) 2845 for_all_clients (ns)
2793 { 2846 ns->invalidate_all_faces ();
2794 ns->faces_sent.reset ();
2795 ns->force_newmap = true;
2796 }
2797 2847
2798MODULE = cf PACKAGE = cf::anim PREFIX = anim_ 2848MODULE = cf PACKAGE = cf::anim PREFIX = anim_
2799 2849
2800#INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | 2850#INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h |
2801 2851
2805 OUTPUT: RETVAL 2855 OUTPUT: RETVAL
2806 2856
2807animidx set (utf8_string name, SV *frames, int facings = 1) 2857animidx set (utf8_string name, SV *frames, int facings = 1)
2808 CODE: 2858 CODE:
2809{ 2859{
2810 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) 2860 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV)
2811 croak ("frames must be an arrayref"); 2861 croak ("frames must be an arrayref");
2812 2862
2813 AV *av = (AV *)SvRV (frames); 2863 AV *av = (AV *)SvRV (frames);
2814 2864
2815 animation *anim = &animation::find (name); 2865 animation *anim = &animation::find (name);
2816 if (anim->number) 2866 if (anim->number)
2817 { 2867 {
2818 anim->resize (av_len (av) + 1); 2868 anim->resize (av_len (av) + 1);
2819 anim->facings = facings; 2869 anim->facings = facings;
2820 } 2870 }
2892 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); 2942 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ())));
2893 2943
2894 self->skip (); 2944 self->skip ();
2895 } 2945 }
2896 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
2897MODULE = cf PACKAGE = cf::layout 2976MODULE = cf PACKAGE = cf::layout
2898 2977
2899INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | 2978INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h |
2900 2979

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines