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 | |
… | |
… | |
1539 | |
1539 | |
1540 | void _gv_clear (SV *gv) |
1540 | void _gv_clear (SV *gv) |
1541 | CODE: |
1541 | CODE: |
1542 | assert (SvTYPE (gv) == SVt_PVGV); |
1542 | assert (SvTYPE (gv) == SVt_PVGV); |
1543 | # 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); |
1544 | f (GvGP (gv)->gp_form); |
1545 | f (GvGP (gv)->gp_form); |
1545 | f (GvGP (gv)->gp_io); |
1546 | f (GvGP (gv)->gp_io); |
1546 | f (GvGP (gv)->gp_sv); |
1547 | f (GvGP (gv)->gp_sv); |
1547 | f (GvGP (gv)->gp_av); |
1548 | f (GvGP (gv)->gp_av); |
1548 | f (GvGP (gv)->gp_hv); |
1549 | f (GvGP (gv)->gp_hv); |
1549 | f (GvGP (gv)->gp_cv); |
1550 | f (GvGP (gv)->gp_cv); |
1550 | GvCVGEN (gv) = 0; |
1551 | GvCVGEN (gv) = 0; |
1551 | GvMULTI_off (gv); |
1552 | GvMULTI_off (gv); |
|
|
1553 | SvREFCNT_dec (gv); |
1552 | # undef f |
1554 | # undef f |
1553 | |
1555 | |
1554 | void _connect_to_perl_1 () |
1556 | void _connect_to_perl_1 () |
1555 | |
1557 | |
1556 | void _connect_to_perl_2 () |
1558 | void _connect_to_perl_2 () |
… | |
… | |
2636 | PPCODE: |
2638 | PPCODE: |
2637 | EXTEND (SP, clients.size ()); |
2639 | EXTEND (SP, clients.size ()); |
2638 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2640 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2639 | PUSHs (sv_2mortal (to_sv (*i))); |
2641 | PUSHs (sv_2mortal (to_sv (*i))); |
2640 | |
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 | |
2641 | void |
2660 | void |
2642 | client::send_packet (SV *packet) |
2661 | client::send_packet (SV *packet) |
2643 | CODE: |
2662 | CODE: |
2644 | { |
2663 | { |
2645 | STRLEN len; |
2664 | STRLEN len; |
… | |
… | |
2711 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2730 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2712 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2731 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2713 | } |
2732 | } |
2714 | OUTPUT: RETVAL |
2733 | OUTPUT: RETVAL |
2715 | |
2734 | |
|
|
2735 | faceidx faces_size () |
|
|
2736 | CODE: |
|
|
2737 | RETVAL = faces.size (); |
|
|
2738 | OUTPUT: RETVAL |
|
|
2739 | |
2716 | void set_type (faceidx idx, int value) |
2740 | void set_type (faceidx idx, int value) |
2717 | ALIAS: |
2741 | ALIAS: |
2718 | set_type = 0 |
2742 | set_type = 0 |
2719 | set_visibility = 1 |
2743 | set_visibility = 1 |
2720 | set_magicmap = 2 |
2744 | set_magicmap = 2 |
… | |
… | |
2780 | if (!d) XSRETURN_UNDEF; |
2804 | if (!d) XSRETURN_UNDEF; |
2781 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2805 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2782 | OUTPUT: |
2806 | OUTPUT: |
2783 | RETVAL |
2807 | RETVAL |
2784 | |
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 | |
2785 | SV *get_data (faceidx idx, int faceset = 0) |
2817 | SV *get_data (faceidx idx, int faceset = 0) |
2786 | CODE: |
2818 | CODE: |
2787 | facedata *d = face_data (idx, faceset); |
2819 | facedata *d = face_data (idx, faceset); |
2788 | if (!d) XSRETURN_UNDEF; |
2820 | if (!d) XSRETURN_UNDEF; |
2789 | RETVAL = newSVpvn (d->data, d->data.size ()); |
2821 | RETVAL = newSVpvn (d->data, d->data.size ()); |
… | |
… | |
2818 | OUTPUT: RETVAL |
2850 | OUTPUT: RETVAL |
2819 | |
2851 | |
2820 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2852 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2821 | CODE: |
2853 | CODE: |
2822 | { |
2854 | { |
2823 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2855 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2824 | croak ("frames must be an arrayref"); |
2856 | croak ("frames must be an arrayref"); |
2825 | |
2857 | |
2826 | AV *av = (AV *)SvRV (frames); |
2858 | AV *av = (AV *)SvRV (frames); |
2827 | |
2859 | |
2828 | animation *anim = &animation::find (name); |
2860 | animation *anim = &animation::find (name); |
2829 | if (anim->number) |
2861 | if (anim->number) |
2830 | { |
2862 | { |
2831 | anim->resize (av_len (av) + 1); |
2863 | anim->resize (av_len (av) + 1); |
2832 | anim->facings = facings; |
2864 | anim->facings = facings; |
2833 | } |
2865 | } |