… | |
… | |
19 | * GNU General Public License for more details. |
19 | * GNU General Public License for more details. |
20 | * |
20 | * |
21 | * You should have received a copy of the GNU General Public License |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software |
22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 | * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 | */ |
24 | */ |
25 | |
25 | |
26 | #define PLUGIN_NAME "perl" |
26 | #define PLUGIN_NAME "perl" |
27 | #define PLUGIN_VERSION "cfperl 0.5" |
27 | #define PLUGIN_VERSION "cfperl 0.5" |
28 | |
28 | |
29 | #include <plugin_common.h> |
29 | #include <plugin_common.h> |
… | |
… | |
36 | |
36 | |
37 | #include <EXTERN.h> |
37 | #include <EXTERN.h> |
38 | #include <perl.h> |
38 | #include <perl.h> |
39 | #include <XSUB.h> |
39 | #include <XSUB.h> |
40 | |
40 | |
|
|
41 | #include "CoroAPI.h" |
41 | #include "perlxsi.c" |
42 | #include "perlxsi.c" |
42 | |
43 | |
43 | extern sint64 *levels; // the experience table |
44 | extern sint64 *levels; // the experience table |
44 | |
45 | |
45 | typedef object object_ornull; |
46 | typedef object object_ornull; |
… | |
… | |
192 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
193 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
193 | |
194 | |
194 | template<int N> |
195 | template<int N> |
195 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
196 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
196 | |
197 | |
|
|
198 | inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); } |
|
|
199 | inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } |
|
|
200 | inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } |
|
|
201 | inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } |
|
|
202 | inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } |
|
|
203 | |
197 | inline void sv_to (SV *sv, UUID &v) |
204 | inline void sv_to (SV *sv, UUID &v) |
198 | { |
205 | { |
199 | unsigned int version; |
206 | unsigned int version; |
200 | |
207 | |
201 | if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) |
208 | if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) |
202 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
209 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
203 | } |
210 | } |
|
|
211 | |
|
|
212 | inline void sv_to (SV *sv, object::flags_t::reference v) { v = boolSV (sv); } |
204 | |
213 | |
205 | static SV * |
214 | static SV * |
206 | newSVdt_va (va_list &ap, data_type type) |
215 | newSVdt_va (va_list &ap, data_type type) |
207 | { |
216 | { |
208 | SV *sv; |
217 | SV *sv; |
… | |
… | |
361 | |
370 | |
362 | HV *hv = (HV *)SvRV ((SV *)self); |
371 | HV *hv = (HV *)SvRV ((SV *)self); |
363 | |
372 | |
364 | if (SvREFCNT ((SV *)self) == 1 |
373 | if (SvREFCNT ((SV *)self) == 1 |
365 | && SvREFCNT ((SV *)hv) == 1 |
374 | && SvREFCNT ((SV *)hv) == 1 |
366 | && !HvKEYS (hv)) |
375 | && !HvTOTALKEYS (hv)) |
367 | { |
376 | { |
368 | SvREFCNT_dec ((SV *)self); |
377 | SvREFCNT_dec ((SV *)self); |
369 | self = 0; |
378 | self = 0; |
370 | } |
379 | } |
371 | } |
380 | } |
… | |
… | |
835 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
844 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
836 | |
845 | |
837 | char *argv[] = { |
846 | char *argv[] = { |
838 | "", |
847 | "", |
839 | "-e" |
848 | "-e" |
840 | "use Event;" // required for bootstrap |
849 | "use Event; use Coro;" // required for bootstrap |
841 | "cf->bootstrap;" // required for datadir :*> |
850 | "cf->bootstrap;" // required for datadir :*> |
842 | "unshift @INC, cf::datadir ();" |
851 | "unshift @INC, cf::datadir ();" |
843 | "require cf;" |
852 | "require cf;" |
844 | }; |
853 | }; |
845 | |
854 | |
846 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
855 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
… | |
… | |
1008 | |
1017 | |
1009 | switch (KLASS_OF (event)) |
1018 | switch (KLASS_OF (event)) |
1010 | { |
1019 | { |
1011 | case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; |
1020 | case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; |
1012 | case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; |
1021 | case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; |
1013 | case KLASS_CLIENT: PUSHs (sv_2mortal (newSVdt (DT_CLIENT, pl))); break; |
1022 | case KLASS_CLIENT: PUSHs (sv_2mortal (newSVdt (DT_CLIENT, ns))); break; |
1014 | case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; |
1023 | case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; |
1015 | } |
1024 | } |
1016 | |
1025 | |
1017 | for (;;) |
1026 | for (;;) |
1018 | { |
1027 | { |
… | |
… | |
1138 | { |
1147 | { |
1139 | HV *stash = gv_stashpv ("cf", 1); |
1148 | HV *stash = gv_stashpv ("cf", 1); |
1140 | |
1149 | |
1141 | I_EVENT_API (PACKAGE); |
1150 | I_EVENT_API (PACKAGE); |
1142 | watcher_base::GEventAPI = GEventAPI; |
1151 | watcher_base::GEventAPI = GEventAPI; |
|
|
1152 | I_CORO_API (PACKAGE); |
1143 | |
1153 | |
1144 | newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1154 | newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1145 | |
1155 | |
1146 | static const struct { |
1156 | static const struct { |
1147 | const char *name; |
1157 | const char *name; |
… | |
… | |
1410 | const_iv (FLAG_ACTIVATE_ON_RELEASE) |
1420 | const_iv (FLAG_ACTIVATE_ON_RELEASE) |
1411 | const_iv (FLAG_IS_WATER) |
1421 | const_iv (FLAG_IS_WATER) |
1412 | const_iv (FLAG_CONTENT_ON_GEN) |
1422 | const_iv (FLAG_CONTENT_ON_GEN) |
1413 | const_iv (FLAG_IS_A_TEMPLATE) |
1423 | const_iv (FLAG_IS_A_TEMPLATE) |
1414 | const_iv (FLAG_IS_BUILDABLE) |
1424 | const_iv (FLAG_IS_BUILDABLE) |
1415 | const_iv (FLAG_AFK) |
|
|
1416 | |
1425 | |
1417 | const_iv (NDI_BLACK) |
1426 | const_iv (NDI_BLACK) |
1418 | const_iv (NDI_WHITE) |
1427 | const_iv (NDI_WHITE) |
1419 | const_iv (NDI_NAVY) |
1428 | const_iv (NDI_NAVY) |
1420 | const_iv (NDI_RED) |
1429 | const_iv (NDI_RED) |
… | |
… | |
1621 | const_iv (KLASS_GLOBAL) |
1630 | const_iv (KLASS_GLOBAL) |
1622 | const_iv (KLASS_OBJECT) |
1631 | const_iv (KLASS_OBJECT) |
1623 | const_iv (KLASS_CLIENT) |
1632 | const_iv (KLASS_CLIENT) |
1624 | const_iv (KLASS_PLAYER) |
1633 | const_iv (KLASS_PLAYER) |
1625 | const_iv (KLASS_MAP) |
1634 | const_iv (KLASS_MAP) |
|
|
1635 | |
|
|
1636 | const_iv (CS_QUERY_YESNO) |
|
|
1637 | const_iv (CS_QUERY_SINGLECHAR) |
|
|
1638 | const_iv (CS_QUERY_HIDEINPUT) |
|
|
1639 | |
|
|
1640 | const_iv (ST_DEAD) |
|
|
1641 | const_iv (ST_SETUP) |
|
|
1642 | const_iv (ST_PLAYING) |
|
|
1643 | const_iv (ST_CUSTOM) |
|
|
1644 | |
|
|
1645 | const_iv (ST_CHANGE_CLASS) |
|
|
1646 | const_iv (ST_CONFIRM_QUIT) |
|
|
1647 | const_iv (ST_GET_PARTY_PASSWORD) |
1626 | }; |
1648 | }; |
1627 | |
1649 | |
1628 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1650 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1629 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1651 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1630 | |
1652 | |
… | |
… | |
1738 | |
1760 | |
1739 | int random_roll (int min, int max, object *op, int goodbad); |
1761 | int random_roll (int min, int max, object *op, int goodbad); |
1740 | |
1762 | |
1741 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1763 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1742 | |
1764 | |
1743 | int invoke (int event, ...) |
|
|
1744 | CODE: |
|
|
1745 | if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL"); |
|
|
1746 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
1747 | for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
|
|
1748 | RETVAL = INVOKE_((event_type)event, ARG_AV (av)); |
|
|
1749 | OUTPUT: RETVAL |
|
|
1750 | |
|
|
1751 | int |
1765 | int |
1752 | exp_to_level (val64 exp) |
1766 | exp_to_level (val64 exp) |
1753 | CODE: |
1767 | CODE: |
1754 | { |
1768 | { |
1755 | int i = 0; |
1769 | int i = 0; |
… | |
… | |
1794 | CODE: |
1808 | CODE: |
1795 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1809 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1796 | OUTPUT: |
1810 | OUTPUT: |
1797 | RETVAL |
1811 | RETVAL |
1798 | |
1812 | |
|
|
1813 | MODULE = cf PACKAGE = cf::global |
|
|
1814 | |
|
|
1815 | int invoke (SV *klass, int event, ...) |
|
|
1816 | CODE: |
|
|
1817 | if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL"); |
|
|
1818 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
1819 | for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
|
|
1820 | RETVAL = INVOKE_((event_type)event, ARG_AV (av)); |
|
|
1821 | OUTPUT: RETVAL |
|
|
1822 | |
1799 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1823 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1800 | |
1824 | |
1801 | INCLUDE: $PERL genacc object ../include/object.h | |
1825 | INCLUDE: $PERL genacc object ../include/object.h | |
1802 | |
1826 | |
1803 | int invoke (object *op, int event, ...) |
1827 | int invoke (object *op, int event, ...) |
… | |
… | |
1821 | RETVAL = object::first; |
1845 | RETVAL = object::first; |
1822 | OUTPUT: RETVAL |
1846 | OUTPUT: RETVAL |
1823 | |
1847 | |
1824 | # missing properties |
1848 | # missing properties |
1825 | |
1849 | |
1826 | int flag (object *op, int flag, int value = 1) |
|
|
1827 | PROTOTYPE: $$;$ |
|
|
1828 | CODE: |
|
|
1829 | RETVAL = QUERY_FLAG (op, flag); |
|
|
1830 | if (items >= 3) |
|
|
1831 | if (value) |
|
|
1832 | SET_FLAG (op, flag); |
|
|
1833 | else |
|
|
1834 | CLEAR_FLAG (op, flag); |
|
|
1835 | OUTPUT: RETVAL |
|
|
1836 | |
|
|
1837 | object *head (object *op) |
1850 | object *head (object *op) |
1838 | PROTOTYPE: $ |
1851 | PROTOTYPE: $ |
1839 | CODE: |
1852 | CODE: |
1840 | RETVAL = op->head ? op->head : op; |
1853 | RETVAL = op->head ? op->head : op; |
1841 | OUTPUT: RETVAL |
1854 | OUTPUT: RETVAL |
… | |
… | |
1851 | PROTOTYPE: $ |
1864 | PROTOTYPE: $ |
1852 | PPCODE: |
1865 | PPCODE: |
1853 | { |
1866 | { |
1854 | object *o; |
1867 | object *o; |
1855 | for (o = obj->inv; o; o = o->below) |
1868 | for (o = obj->inv; o; o = o->below) |
1856 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1869 | XPUSHs (sv_2mortal (to_sv (o))); |
1857 | } |
1870 | } |
|
|
1871 | |
|
|
1872 | void |
|
|
1873 | set_animation (object *op, int idx) |
|
|
1874 | CODE: |
|
|
1875 | SET_ANIMATION (op, idx); |
|
|
1876 | |
|
|
1877 | void |
|
|
1878 | object::drain_stat () |
|
|
1879 | |
|
|
1880 | void |
|
|
1881 | object::drain_specific_stat (int stat) |
|
|
1882 | |
|
|
1883 | void |
|
|
1884 | object::change_luck (int change) |
|
|
1885 | |
|
|
1886 | void |
|
|
1887 | object::add_statbonus () |
|
|
1888 | |
|
|
1889 | void |
|
|
1890 | object::remove_statbonus () |
1858 | |
1891 | |
1859 | object *find_best_object_match (object *op, const char *match) |
1892 | object *find_best_object_match (object *op, const char *match) |
1860 | |
1893 | |
1861 | object *find_marked_object (object *op) |
1894 | object *find_marked_object (object *op) |
1862 | |
|
|
1863 | int resistance (object *op, int rtype, int newval = 0) |
|
|
1864 | CODE: |
|
|
1865 | if (rtype < 0 || rtype >= NROFATTACKS) |
|
|
1866 | croak ("resistance out of bounds"); |
|
|
1867 | RETVAL = op->resist [rtype]; |
|
|
1868 | if (items >= 3) |
|
|
1869 | op->resist [rtype] = newval; |
|
|
1870 | OUTPUT: RETVAL |
|
|
1871 | |
|
|
1872 | void set_resistance (object *op, int rtype, int val) |
|
|
1873 | CODE: |
|
|
1874 | if (rtype < 0 || rtype >= NROFATTACKS) |
|
|
1875 | op->resist[rtype] = val; |
|
|
1876 | |
1895 | |
1877 | int need_identify (const object *obj); |
1896 | int need_identify (const object *obj); |
1878 | |
1897 | |
1879 | int apply_shop_mat (object *shop_mat, object *op); |
1898 | int apply_shop_mat (object *shop_mat, object *op); |
1880 | |
1899 | |
… | |
… | |
1946 | OUTPUT: RETVAL |
1965 | OUTPUT: RETVAL |
1947 | |
1966 | |
1948 | int query_money (object *op) |
1967 | int query_money (object *op) |
1949 | ALIAS: money = 0 |
1968 | ALIAS: money = 0 |
1950 | |
1969 | |
1951 | int query_cost (object *op, object *who, int flags) |
1970 | val64 query_cost (object *op, object *who, int flags) |
1952 | ALIAS: cost = 0 |
1971 | ALIAS: cost = 0 |
1953 | |
1972 | |
1954 | void spring_trap (object *op, object *victim) |
1973 | void spring_trap (object *op, object *victim) |
1955 | |
1974 | |
1956 | int check_trigger (object *op, object *cause) |
1975 | int check_trigger (object *op, object *cause) |
… | |
… | |
1963 | |
1982 | |
1964 | object *cf_object_insert_in_ob (object *ob, object *where) |
1983 | object *cf_object_insert_in_ob (object *ob, object *where) |
1965 | |
1984 | |
1966 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1985 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1967 | |
1986 | |
1968 | void update (object *op, int action) |
1987 | void update_object (object *op, int action) |
1969 | CODE: |
|
|
1970 | update_object (op, action); |
|
|
1971 | |
1988 | |
1972 | object *cf_create_object_by_name (const char *name) |
1989 | object *cf_create_object_by_name (const char *name) |
1973 | |
1990 | |
1974 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
1991 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
1975 | |
1992 | |
… | |
… | |
1987 | |
2004 | |
1988 | void remove_button_link (object *op); |
2005 | void remove_button_link (object *op); |
1989 | |
2006 | |
1990 | |
2007 | |
1991 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2008 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
1992 | |
|
|
1993 | void cf_fix_object (object *pl) |
|
|
1994 | ALIAS: fix = 0 |
|
|
1995 | |
2009 | |
1996 | object *cf_insert_ob_in_ob (object *ob, object *where) |
2010 | object *cf_insert_ob_in_ob (object *ob, object *where) |
1997 | |
2011 | |
1998 | # no clean way to get an object from an archetype - stupid idiotic |
2012 | # no clean way to get an object from an archetype - stupid idiotic |
1999 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2013 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
… | |
… | |
2022 | |
2036 | |
2023 | player *contr (object *op) |
2037 | player *contr (object *op) |
2024 | CODE: |
2038 | CODE: |
2025 | RETVAL = op->contr; |
2039 | RETVAL = op->contr; |
2026 | OUTPUT: RETVAL |
2040 | OUTPUT: RETVAL |
|
|
2041 | |
|
|
2042 | void |
|
|
2043 | object::roll_stats () |
|
|
2044 | |
|
|
2045 | void |
|
|
2046 | object::update_stats () |
|
|
2047 | |
|
|
2048 | void |
|
|
2049 | object::swap_stats (int a, int b) |
2027 | |
2050 | |
2028 | const char *get_ob_key_value (object *op, const char *key) |
2051 | const char *get_ob_key_value (object *op, const char *key) |
2029 | |
2052 | |
2030 | bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) |
2053 | bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) |
2031 | |
2054 | |
… | |
… | |
2066 | player *player (object *op) |
2089 | player *player (object *op) |
2067 | CODE: |
2090 | CODE: |
2068 | RETVAL = op->contr; |
2091 | RETVAL = op->contr; |
2069 | OUTPUT: RETVAL |
2092 | OUTPUT: RETVAL |
2070 | |
2093 | |
|
|
2094 | void check_score (object *op) |
|
|
2095 | |
2071 | void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
2096 | void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
2072 | |
2097 | |
2073 | object *cf_player_send_inventory (object *op) |
2098 | object *cf_player_send_inventory (object *op) |
2074 | |
2099 | |
2075 | char *cf_player_get_ip (object *op) |
2100 | char *cf_player_get_ip (object *op) |
… | |
… | |
2117 | RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); |
2142 | RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); |
2118 | OUTPUT: RETVAL |
2143 | OUTPUT: RETVAL |
2119 | |
2144 | |
2120 | SV *registry (player *pl) |
2145 | SV *registry (player *pl) |
2121 | |
2146 | |
|
|
2147 | player * |
|
|
2148 | create () |
|
|
2149 | CODE: |
|
|
2150 | RETVAL = player::create (); |
|
|
2151 | OUTPUT: |
|
|
2152 | RETVAL |
|
|
2153 | |
|
|
2154 | player * |
|
|
2155 | load (const char *path) |
|
|
2156 | CODE: |
|
|
2157 | RETVAL = player::load (path); |
|
|
2158 | OUTPUT: |
|
|
2159 | RETVAL |
|
|
2160 | |
|
|
2161 | void |
|
|
2162 | player::save (bool final = false) |
|
|
2163 | |
|
|
2164 | void |
|
|
2165 | player::connect (client *ns) |
|
|
2166 | |
|
|
2167 | void |
|
|
2168 | save_stats (player *pl) |
|
|
2169 | CODE: |
|
|
2170 | pl->ob->stats.hp = pl->ob->stats.maxhp; |
|
|
2171 | pl->ob->stats.sp = pl->ob->stats.maxsp; |
|
|
2172 | pl->ob->stats.grace = pl->ob->stats.maxgrace; |
|
|
2173 | pl->orig_stats = pl->ob->stats; |
|
|
2174 | |
2122 | player *cf_player_find (char *name) |
2175 | player *cf_player_find (char *name) |
2123 | PROTOTYPE: $ |
2176 | PROTOTYPE: $ |
2124 | |
2177 | |
2125 | void cf_player_move (player *pl, int dir) |
2178 | void cf_player_move (player *pl, int dir) |
2126 | |
2179 | |
… | |
… | |
2129 | player *first () |
2182 | player *first () |
2130 | CODE: |
2183 | CODE: |
2131 | RETVAL = first_player; |
2184 | RETVAL = first_player; |
2132 | OUTPUT: RETVAL |
2185 | OUTPUT: RETVAL |
2133 | |
2186 | |
2134 | player *next (player *pl) |
|
|
2135 | CODE: |
|
|
2136 | RETVAL = pl->next; |
|
|
2137 | OUTPUT: RETVAL |
|
|
2138 | |
|
|
2139 | bool |
2187 | bool |
2140 | cell_visible (player *pl, int dx, int dy) |
2188 | cell_visible (player *pl, int dx, int dy) |
2141 | CODE: |
2189 | CODE: |
2142 | RETVAL = FABS (dx) <= pl->socket->mapx / 2 && FABS (dy) <= pl->socket->mapy / 2 |
2190 | RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 |
2143 | && !pl->blocked_los [dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]; |
2191 | && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]; |
2144 | OUTPUT: |
2192 | OUTPUT: |
2145 | RETVAL |
2193 | RETVAL |
2146 | |
2194 | |
2147 | void |
2195 | void |
2148 | send (player *pl, SV *packet) |
2196 | send (player *pl, SV *packet) |
2149 | CODE: |
2197 | CODE: |
2150 | { |
2198 | { |
2151 | STRLEN len; |
2199 | STRLEN len; |
2152 | char *buf = SvPVbyte (packet, len); |
2200 | char *buf = SvPVbyte (packet, len); |
2153 | |
2201 | |
|
|
2202 | if (pl->ns) |
2154 | pl->socket->send_packet (buf, len); |
2203 | pl->ns->send_packet (buf, len); |
2155 | } |
2204 | } |
2156 | |
2205 | |
2157 | int |
2206 | int |
2158 | listening (player *pl, int new_value = -1) |
2207 | listening (player *pl, int new_value = -1) |
2159 | CODE: |
2208 | CODE: |
… | |
… | |
2178 | if (y) sv_to (y, pl->bed_y); |
2227 | if (y) sv_to (y, pl->bed_y); |
2179 | |
2228 | |
2180 | void |
2229 | void |
2181 | list () |
2230 | list () |
2182 | PPCODE: |
2231 | PPCODE: |
2183 | { |
|
|
2184 | player *pl; |
|
|
2185 | for (pl = first_player; pl; pl = pl->next) |
2232 | for (player *pl = first_player; pl; pl = pl->next) |
2186 | XPUSHs (newSVcfapi (CFAPI_PPLAYER, pl)); |
2233 | XPUSHs (sv_2mortal (to_sv (pl))); |
2187 | } |
|
|
2188 | |
2234 | |
2189 | bool |
2235 | bool |
2190 | peaceful (player *pl, bool new_setting = 0) |
2236 | peaceful (player *pl, bool new_setting = 0) |
2191 | PROTOTYPE: $;$ |
2237 | PROTOTYPE: $;$ |
2192 | CODE: |
2238 | CODE: |
… | |
… | |
2454 | RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av)); |
2500 | RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av)); |
2455 | OUTPUT: RETVAL |
2501 | OUTPUT: RETVAL |
2456 | |
2502 | |
2457 | SV *registry (client *ns) |
2503 | SV *registry (client *ns) |
2458 | |
2504 | |
|
|
2505 | void |
|
|
2506 | list () |
|
|
2507 | PPCODE: |
|
|
2508 | EXTEND (SP, clients.size ()); |
|
|
2509 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
|
|
2510 | PUSHs (sv_2mortal (to_sv (*i))); |
|
|
2511 | |
2459 | client * |
2512 | client * |
2460 | create (int fd, const char *peername) |
2513 | create (int fd, const char *peername) |
2461 | CODE: |
2514 | CODE: |
2462 | RETVAL = client::create (fd, peername); |
2515 | RETVAL = client::create (fd, peername); |
2463 | OUTPUT: |
2516 | OUTPUT: |
2464 | RETVAL |
2517 | RETVAL |
2465 | |
2518 | |
2466 | void |
2519 | void |
|
|
2520 | client::send_packet (SV *packet) |
|
|
2521 | CODE: |
|
|
2522 | { |
|
|
2523 | STRLEN len; |
|
|
2524 | char *buf = SvPVbyte (packet, len); |
|
|
2525 | |
|
|
2526 | THIS->send_packet (buf, len); |
|
|
2527 | } |
|
|
2528 | |
|
|
2529 | void |
2467 | client::destroy () |
2530 | client::destroy () |
2468 | |
2531 | |