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.408 by root, Tue Jan 3 11:23:42 2012 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,2012 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 *
1157 CALL_ARG (originator); 1158 CALL_ARG (originator);
1158 CALL_CALL ("cf::mapscript::activate", G_VOID); 1159 CALL_CALL ("cf::mapscript::activate", G_VOID);
1159 CALL_END; 1160 CALL_END;
1160} 1161}
1161 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
1162player * 1174player *
1163player::find (const_utf8_string name) 1175player::find (const_utf8_string name)
1164{ 1176{
1165 CALL_BEGIN (1); 1177 CALL_BEGIN (1);
1166 CALL_ARG (name); 1178 CALL_ARG (name);
1436_connect_to_perl_2 () 1448_connect_to_perl_2 ()
1437{ 1449{
1438 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);
1439 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);
1440 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);
1441 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);
1442 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);
1443} 1456}
1444 1457
1445MODULE = cf PACKAGE = cf PREFIX = cf_ 1458MODULE = cf PACKAGE = cf PREFIX = cf_
1450 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1463 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1451 1464
1452 _connect_to_perl_1 (); 1465 _connect_to_perl_1 ();
1453 1466
1454 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1467 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1455
1456 //{
1457 // require_pv ("Time::HiRes");
1458 //
1459 // SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0);
1460 // if (!svp) croak ("Time::HiRes is required");
1461 // if (!SvIOK(*svp)) croak ("Time::NVtime isn’t a function pointer");
1462 // coroapi::time = INT2PTR (double(*)(), SvIV(*svp));
1463 //}
1464 1468
1465 static const struct { 1469 static const struct {
1466 const char *name; 1470 const char *name;
1467 IV iv; 1471 IV iv;
1468 } *civ, const_iv[] = { 1472 } *civ, const_iv[] = {
1539 1543
1540void _gv_clear (SV *gv) 1544void _gv_clear (SV *gv)
1541 CODE: 1545 CODE:
1542 assert (SvTYPE (gv) == SVt_PVGV); 1546 assert (SvTYPE (gv) == SVt_PVGV);
1543# 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);
1544 f (GvGP (gv)->gp_form); 1549 f (GvGP (gv)->gp_form);
1545 f (GvGP (gv)->gp_io); 1550 f (GvGP (gv)->gp_io);
1546 f (GvGP (gv)->gp_sv); 1551 f (GvGP (gv)->gp_sv);
1547 f (GvGP (gv)->gp_av); 1552 f (GvGP (gv)->gp_av);
1548 f (GvGP (gv)->gp_hv); 1553 f (GvGP (gv)->gp_hv);
1549 f (GvGP (gv)->gp_cv); 1554 f (GvGP (gv)->gp_cv);
1550 GvCVGEN (gv) = 0; 1555 GvCVGEN (gv) = 0;
1551 GvMULTI_off (gv); 1556 GvMULTI_off (gv);
1557 SvREFCNT_dec (gv);
1552# undef f 1558# undef f
1553 1559
1554void _connect_to_perl_1 () 1560void _connect_to_perl_1 ()
1555 1561
1556void _connect_to_perl_2 () 1562void _connect_to_perl_2 ()
1577 1583
1578void init_dynamic () 1584void init_dynamic ()
1579 1585
1580void load_settings () 1586void load_settings ()
1581 1587
1582void reload_exp_table () 1588void _reload_exp_table ()
1583 1589
1584void reload_materials () 1590void _reload_materials ()
1585 1591
1586void init_uuid () 1592void init_uuid ()
1587 CODE: 1593 CODE:
1588 UUID::init (); 1594 UUID::init ();
1589 1595
1653NV rndm (...) 1659NV rndm (...)
1654 ALIAS: 1660 ALIAS:
1655 rmg_rndm = 1 1661 rmg_rndm = 1
1656 CODE: 1662 CODE:
1657{ 1663{
1658 rand_gen &gen = ix ? rmg_rndm : rndm; 1664 rand_gen &gen = ix ? rmg_rndm : rndm;
1659 switch (items) 1665 switch (items)
1660 { 1666 {
1661 case 0: RETVAL = gen (); break; 1667 case 0: RETVAL = gen (); break;
1662 case 1: RETVAL = gen (SvUV (ST (0))); break; 1668 case 1: RETVAL = gen (SvUV (ST (0))); break;
1663 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; 1669 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break;
1787 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))));
1788 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)));
1789 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)));
1790} 1796}
1791 1797
1792int find_animation (utf8_string text)
1793 PROTOTYPE: $
1794
1795int random_roll (int min, int max, object *op, int goodbad); 1798int random_roll (int min, int max, object *op, int goodbad);
1796 1799
1797const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1800const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1798 1801
1799int exp_to_level (val64 exp) 1802int exp_to_level (val64 exp)
1800 1803
1801val64 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
1802 1811
1803SV * 1812SV *
1804attacktype_name (int atnr) 1813attacktype_name (int atnr)
1805 CODE: 1814 CODE:
1806 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) 1815 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1878load_resource_file_ (octet_string filename) 1887load_resource_file_ (octet_string filename)
1879 1888
1880void 1889void
1881fix_weight () 1890fix_weight ()
1882 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
1883MODULE = cf PACKAGE = cf::attachable 1897MODULE = cf PACKAGE = cf::attachable
1884 1898
1885int 1899int
1886valid (SV *obj) 1900valid (SV *obj)
1887 CODE: 1901 CODE:
2109int convert_item (object *item, object *converter) 2123int convert_item (object *item, object *converter)
2110 2124
2111void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); 2125void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags);
2112 2126
2113MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2127MODULE = cf PACKAGE = cf::object PREFIX = cf_
2114
2115# no clean way to get an object from an archetype - stupid idiotic
2116# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2117 2128
2118object *new (utf8_string archetype = 0) 2129object *new (utf8_string archetype = 0)
2119 PROTOTYPE: ;$ 2130 PROTOTYPE: ;$
2120 CODE: 2131 CODE:
2121 RETVAL = archetype 2132 RETVAL = archetype
2389 croak ("maptile::add_underlay: palette must be arrayref"); 2400 croak ("maptile::add_underlay: palette must be arrayref");
2390 2401
2391 palette = SvRV (palette); 2402 palette = SvRV (palette);
2392 2403
2393 STRLEN idxlen; 2404 STRLEN idxlen;
2394 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); 2405 const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen);
2395 2406
2396 for (int x = 0; x < THIS->width; ++x) 2407 for (int x = 0; x < THIS->width; ++x)
2397 for (int y = 0; y < THIS->height; ++y) 2408 for (int y = 0; y < THIS->height; ++y)
2398 { 2409 {
2399 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)
2439 croak ("maptile::set_regiondata: palette must be arrayref"); 2450 croak ("maptile::set_regiondata: palette must be arrayref");
2440 2451
2441 palette = SvRV (palette); 2452 palette = SvRV (palette);
2442 2453
2443 STRLEN idxlen; 2454 STRLEN idxlen;
2444 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); 2455 const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen);
2445 2456
2446 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; 2457 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1];
2447 uint8_t *regions = salloc<uint8_t> (THIS->size ()); 2458 uint8 *regions = salloc<uint8_t> (THIS->size ());
2448 2459
2449 for (int i = av_len ((AV *)palette) + 1; i--; ) 2460 for (int i = av_len ((AV *)palette) + 1; i--; )
2450 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)));
2451 2462
2452 for (int y = 0; y < THIS->height; ++y) 2463 for (int y = 0; y < THIS->height; ++y)
2578archetype *archetypes (U32 index) 2589archetype *archetypes (U32 index)
2579 CODE: 2590 CODE:
2580 RETVAL = index < archetypes.size () ? archetypes [index] : 0; 2591 RETVAL = index < archetypes.size () ? archetypes [index] : 0;
2581 OUTPUT: RETVAL 2592 OUTPUT: RETVAL
2582 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
2583INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | 2611INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h |
2584 2612
2585MODULE = cf PACKAGE = cf::party 2613MODULE = cf PACKAGE = cf::party
2586 2614
2587partylist *first () 2615partylist *first ()
2635list () 2663list ()
2636 PPCODE: 2664 PPCODE:
2637 EXTEND (SP, clients.size ()); 2665 EXTEND (SP, clients.size ());
2638 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 2666 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
2639 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
2640 2685
2641void 2686void
2642client::send_packet (SV *packet) 2687client::send_packet (SV *packet)
2643 CODE: 2688 CODE:
2644{ 2689{
2711 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; 2756 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL;
2712 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; 2757 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL;
2713} 2758}
2714 OUTPUT: RETVAL 2759 OUTPUT: RETVAL
2715 2760
2761faceidx faces_size ()
2762 CODE:
2763 RETVAL = faces.size ();
2764 OUTPUT: RETVAL
2765
2716void set_type (faceidx idx, int value) 2766void set_type (faceidx idx, int value)
2717 ALIAS: 2767 ALIAS:
2718 set_type = 0 2768 set_type = 0
2719 set_visibility = 1 2769 set_visibility = 1
2720 set_magicmap = 2 2770 set_magicmap = 2
2729 case 2: f->magicmap = value; break; 2779 case 2: f->magicmap = value; break;
2730 case 3: f->smooth = value; break; 2780 case 3: f->smooth = value; break;
2731 case 4: f->smoothlevel = value; break; 2781 case 4: f->smoothlevel = value; break;
2732 } 2782 }
2733 2783
2734void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2784void set_csum (faceidx idx, int faceset, SV *chksum)
2735 CODE: 2785 CODE:
2736{ 2786{
2737 faceinfo *f = face_info (idx); assert (f); 2787 faceinfo *f = face_info (idx); assert (f);
2738 facedata *d = f->face + faceset; 2788 facedata *d = f->face + faceset;
2739 sv_to (data, d->data);
2740 STRLEN clen; 2789 STRLEN clen;
2741 char *cdata = SvPVbyte (chksum, clen); 2790 char *cdata = SvPVbyte (chksum, clen);
2742 clen = min (CHKSUM_MAXLEN, clen);
2743 2791
2792 assert (("cf::face::set_data called with too long checksum", clen <= CHKSUM_MAXLEN));
2744 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));
2745 2794
2746 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) 2795 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen))
2747 { 2796 {
2748 d->chksum_len = clen; 2797 d->chksum_len = clen;
2749 memcpy (d->chksum, cdata, clen); 2798 memcpy (d->chksum, cdata, clen);
2750 2799
2751 // invalidate existing client face info 2800 // invalidate existing client face info
2752 for_all_clients (ns) 2801 for_all_clients (ns)
2753 if (ns->faceset == faceset) 2802 ns->invalidate_face (idx);
2754 {
2755 ns->faces_sent [idx] = false;
2756 ns->force_newmap = true;
2757 }
2758 } 2803 }
2759} 2804}
2760 2805
2761int get_data_size (faceidx idx, int faceset = 0) 2806SV *mangle_csum (SV *chksum)
2762 CODE: 2807 CODE:
2763 facedata *d = face_data (idx, faceset); 2808 STRLEN len;
2764 if (!d) XSRETURN_UNDEF; 2809 char *data = SvPVbyte (chksum, len);
2765 RETVAL = d->data.size (); 2810 RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN));
2766 OUTPUT: 2811 OUTPUT:
2767 RETVAL 2812 RETVAL
2768 2813
2769SV *get_chksum (faceidx idx, int faceset = 0) 2814SV *get_csum (faceidx idx, int faceset = 0)
2770 CODE: 2815 CODE:
2771 facedata *d = face_data (idx, faceset); 2816 facedata *d = face_data (idx, faceset);
2772 if (!d) XSRETURN_UNDEF; 2817 if (!d) XSRETURN_UNDEF;
2773 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); 2818 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len);
2774 OUTPUT: 2819 OUTPUT:
2775 RETVAL 2820 RETVAL
2776 2821
2777SV *get_data (faceidx idx, int faceset = 0) 2822int get_type (faceidx idx)
2778 CODE: 2823 CODE:
2779 facedata *d = face_data (idx, faceset); 2824 faceinfo *f = face_info (idx);
2780 if (!d) XSRETURN_UNDEF; 2825 if (!f) XSRETURN_UNDEF;
2781 RETVAL = newSVpvn (d->data, d->data.size ()); 2826 RETVAL = f->type;
2782 OUTPUT: 2827 OUTPUT:
2783 RETVAL 2828 RETVAL
2784 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
2785void invalidate (faceidx idx) 2838void invalidate (faceidx idx)
2786 CODE: 2839 CODE:
2787 for_all_clients (ns) 2840 for_all_clients (ns)
2788 ns->invalidate_face (idx); 2841 ns->invalidate_face (idx);
2789 2842
2802 OUTPUT: RETVAL 2855 OUTPUT: RETVAL
2803 2856
2804animidx set (utf8_string name, SV *frames, int facings = 1) 2857animidx set (utf8_string name, SV *frames, int facings = 1)
2805 CODE: 2858 CODE:
2806{ 2859{
2807 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) 2860 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV)
2808 croak ("frames must be an arrayref"); 2861 croak ("frames must be an arrayref");
2809 2862
2810 AV *av = (AV *)SvRV (frames); 2863 AV *av = (AV *)SvRV (frames);
2811 2864
2812 animation *anim = &animation::find (name); 2865 animation *anim = &animation::find (name);
2813 if (anim->number) 2866 if (anim->number)
2814 { 2867 {
2815 anim->resize (av_len (av) + 1); 2868 anim->resize (av_len (av) + 1);
2816 anim->facings = facings; 2869 anim->facings = facings;
2817 } 2870 }
2889 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); 2942 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ())));
2890 2943
2891 self->skip (); 2944 self->skip ();
2892 } 2945 }
2893 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
2894MODULE = cf PACKAGE = cf::layout 2976MODULE = cf PACKAGE = cf::layout
2895 2977
2896INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | 2978INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h |
2897 2979

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines