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.406 by root, Thu May 5 18:59:43 2011 UTC vs.
Revision 1.414 by root, Tue Oct 30 17:07:50 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
625 STRLEN len; 625 STRLEN len;
626 char *data = SvPVbyte (sv, len); 626 char *data = SvPVbyte (sv, len);
627 v.assign (data, len); 627 v.assign (data, len);
628} 628}
629 629
630static 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;
636}
637
630static inline void sv_to (SV *sv, UUID &v) 638static inline void sv_to (SV *sv, UUID &v)
631{ 639{
632 if (!v.parse (SvPV_nolen (sv))) 640 if (!v.parse (SvPV_nolen (sv)))
633 croak ("unparsable uuid: %s", SvPV_nolen (sv)); 641 croak ("unparsable uuid: %s", SvPV_nolen (sv));
634} 642}
1531 1539
1532void _gv_clear (SV *gv) 1540void _gv_clear (SV *gv)
1533 CODE: 1541 CODE:
1534 assert (SvTYPE (gv) == SVt_PVGV); 1542 assert (SvTYPE (gv) == SVt_PVGV);
1535# 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);
1536 f (GvGP (gv)->gp_form); 1545 f (GvGP (gv)->gp_form);
1537 f (GvGP (gv)->gp_io); 1546 f (GvGP (gv)->gp_io);
1538 f (GvGP (gv)->gp_sv); 1547 f (GvGP (gv)->gp_sv);
1539 f (GvGP (gv)->gp_av); 1548 f (GvGP (gv)->gp_av);
1540 f (GvGP (gv)->gp_hv); 1549 f (GvGP (gv)->gp_hv);
1541 f (GvGP (gv)->gp_cv); 1550 f (GvGP (gv)->gp_cv);
1542 GvCVGEN (gv) = 0; 1551 GvCVGEN (gv) = 0;
1543 GvMULTI_off (gv); 1552 GvMULTI_off (gv);
1553 SvREFCNT_dec (gv);
1544# undef f 1554# undef f
1545 1555
1546void _connect_to_perl_1 () 1556void _connect_to_perl_1 ()
1547 1557
1548void _connect_to_perl_2 () 1558void _connect_to_perl_2 ()
2136 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);
2137 2147
2138 if (RETVAL->destroyed ()) 2148 if (RETVAL->destroyed ())
2139 RETVAL = 0; 2149 RETVAL = 0;
2140} 2150}
2151 OUTPUT:
2152 RETVAL
2141 2153
2142shstr 2154shstr
2143object::kv_get (shstr key) 2155object::kv_get (shstr key)
2144 CODE: 2156 CODE:
2145 RETVAL = THIS->kv.get (key); 2157 RETVAL = THIS->kv.get (key);
2626 PPCODE: 2638 PPCODE:
2627 EXTEND (SP, clients.size ()); 2639 EXTEND (SP, clients.size ());
2628 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 2640 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
2629 PUSHs (sv_2mortal (to_sv (*i))); 2641 PUSHs (sv_2mortal (to_sv (*i)));
2630 2642
2643STRLEN
2644client::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
2631void 2660void
2632client::send_packet (SV *packet) 2661client::send_packet (SV *packet)
2633 CODE: 2662 CODE:
2634{ 2663{
2635 STRLEN len; 2664 STRLEN len;
2690faceidx face_find (utf8_string name, faceidx defidx = 0) 2719faceidx face_find (utf8_string name, faceidx defidx = 0)
2691 2720
2692faceidx alloc (utf8_string name) 2721faceidx alloc (utf8_string name)
2693 CODE: 2722 CODE:
2694{ 2723{
2695 do 2724 RETVAL = face_alloc ();
2696 {
2697 RETVAL = faces.size ();
2698 faces.resize (RETVAL + 1);
2699 }
2700 while (!RETVAL); // crude way to leave index 0
2701 2725
2702 faces [RETVAL].name = name; 2726 faces [RETVAL].name = name;
2703 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); 2727 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL));
2704 2728
2705 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; 2729 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL;
2706 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; 2730 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL;
2707 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; 2731 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL;
2708} 2732}
2733 OUTPUT: RETVAL
2734
2735faceidx faces_size ()
2736 CODE:
2737 RETVAL = faces.size ();
2709 OUTPUT: RETVAL 2738 OUTPUT: RETVAL
2710 2739
2711void set_type (faceidx idx, int value) 2740void set_type (faceidx idx, int value)
2712 ALIAS: 2741 ALIAS:
2713 set_type = 0 2742 set_type = 0
2759 if (!d) XSRETURN_UNDEF; 2788 if (!d) XSRETURN_UNDEF;
2760 RETVAL = d->data.size (); 2789 RETVAL = d->data.size ();
2761 OUTPUT: 2790 OUTPUT:
2762 RETVAL 2791 RETVAL
2763 2792
2793void 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
2764SV *get_chksum (faceidx idx, int faceset = 0) 2801SV *get_chksum (faceidx idx, int faceset = 0)
2765 CODE: 2802 CODE:
2766 facedata *d = face_data (idx, faceset); 2803 facedata *d = face_data (idx, faceset);
2767 if (!d) XSRETURN_UNDEF; 2804 if (!d) XSRETURN_UNDEF;
2768 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); 2805 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len);
2769 OUTPUT: 2806 OUTPUT:
2770 RETVAL 2807 RETVAL
2771 2808
2809int 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
2772SV *get_data (faceidx idx, int faceset = 0) 2817SV *get_data (faceidx idx, int faceset = 0)
2773 CODE: 2818 CODE:
2774 facedata *d = face_data (idx, faceset); 2819 facedata *d = face_data (idx, faceset);
2775 if (!d) XSRETURN_UNDEF; 2820 if (!d) XSRETURN_UNDEF;
2776 RETVAL = newSVpvn (d->data.data (), d->data.length ()); 2821 RETVAL = newSVpvn (d->data, d->data.size ());
2777 OUTPUT: 2822 OUTPUT:
2778 RETVAL 2823 RETVAL
2779 2824
2825SV *get_meta (faceidx idx)
2826 CODE:
2827 faceinfo *f = face_info (idx); assert (f);
2828 if (!f || !f->meta_hv) XSRETURN_UNDEF;
2829 RETVAL = newRV_inc ((SV *)f->meta_hv);
2830 OUTPUT:
2831 RETVAL
2832
2780void invalidate (faceidx idx) 2833void invalidate (faceidx idx)
2781 CODE: 2834 CODE:
2782 for_all_clients (ns) 2835 for_all_clients (ns)
2783 { 2836 ns->invalidate_face (idx);
2784 ns->faces_sent [idx] = false;
2785 ns->force_newmap = true;
2786 }
2787 2837
2788void invalidate_all () 2838void invalidate_all ()
2789 CODE: 2839 CODE:
2790 for_all_clients (ns) 2840 for_all_clients (ns)
2791 { 2841 ns->invalidate_all_faces ();
2792 ns->faces_sent.reset ();
2793 ns->force_newmap = true;
2794 }
2795 2842
2796MODULE = cf PACKAGE = cf::anim PREFIX = anim_ 2843MODULE = cf PACKAGE = cf::anim PREFIX = anim_
2797 2844
2798#INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | 2845#INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h |
2799 2846
2803 OUTPUT: RETVAL 2850 OUTPUT: RETVAL
2804 2851
2805animidx set (utf8_string name, SV *frames, int facings = 1) 2852animidx set (utf8_string name, SV *frames, int facings = 1)
2806 CODE: 2853 CODE:
2807{ 2854{
2808 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) 2855 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV)
2809 croak ("frames must be an arrayref"); 2856 croak ("frames must be an arrayref");
2810 2857
2811 AV *av = (AV *)SvRV (frames); 2858 AV *av = (AV *)SvRV (frames);
2812 2859
2813 animation *anim = &animation::find (name); 2860 animation *anim = &animation::find (name);
2814 if (anim->number) 2861 if (anim->number)
2815 { 2862 {
2816 anim->resize (av_len (av) + 1); 2863 anim->resize (av_len (av) + 1);
2817 anim->facings = facings; 2864 anim->facings = facings;
2818 } 2865 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines