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.91 by root, Wed Dec 20 11:36:39 2006 UTC vs.
Revision 1.106 by root, Sat Dec 23 15:49:40 2006 UTC

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>
59static f_plug_api object_set_property = cfapi_object_set_property; 59static f_plug_api object_set_property = cfapi_object_set_property;
60static f_plug_api object_insert = cfapi_object_insert; 60static f_plug_api object_insert = cfapi_object_insert;
61 61
62static PerlInterpreter *perl; 62static PerlInterpreter *perl;
63 63
64static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; 64static AV *cb_global, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map;
65 65
66////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 66//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
67 67
68static SV * 68static SV *
69newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) 69newSVptr (void *ptr, const char *klass, HV *hv = newHV ())
192inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 192inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
193 193
194template<int N> 194template<int N>
195inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } 195inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); }
196 196
197inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); }
198inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); }
199inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); }
200inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); }
201inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); }
202
197inline void sv_to (SV *sv, UUID &v) 203inline void sv_to (SV *sv, UUID &v)
198{ 204{
199 unsigned int version; 205 unsigned int version;
200 206
201 if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) 207 if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version)
202 croak ("unparsable uuid: %s", SvPV_nolen (sv)); 208 croak ("unparsable uuid: %s", SvPV_nolen (sv));
203} 209}
210
211inline void sv_to (SV *sv, object::flags_t::reference v) { v = boolSV (sv); }
204 212
205static SV * 213static SV *
206newSVdt_va (va_list &ap, data_type type) 214newSVdt_va (va_list &ap, data_type type)
207{ 215{
208 SV *sv; 216 SV *sv;
361 369
362 HV *hv = (HV *)SvRV ((SV *)self); 370 HV *hv = (HV *)SvRV ((SV *)self);
363 371
364 if (SvREFCNT ((SV *)self) == 1 372 if (SvREFCNT ((SV *)self) == 1
365 && SvREFCNT ((SV *)hv) == 1 373 && SvREFCNT ((SV *)hv) == 1
366 && !HvKEYS (hv)) 374 && !HvTOTALKEYS (hv))
367 { 375 {
368 SvREFCNT_dec ((SV *)self); 376 SvREFCNT_dec ((SV *)self);
369 self = 0; 377 self = 0;
370 } 378 }
371} 379}
412 420
413 switch (type) 421 switch (type)
414 { 422 {
415 case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break; 423 case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break;
416 case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break; 424 case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break;
425 case DT_CLIENT: INVOKE_CLIENT (REATTACH, obj); break;
417 case DT_MAP: INVOKE_MAP (REATTACH, obj); break; 426 case DT_MAP: INVOKE_MAP (REATTACH, obj); break;
418 } 427 }
419} 428}
420 429
421template<class subclass> 430template<class subclass>
906 AV *callbacks = 0; 915 AV *callbacks = 0;
907 916
908 object *op; 917 object *op;
909 player *pl; 918 player *pl;
910 maptile *map; 919 maptile *map;
920 client *ns;
911 921
912 // callback call ordering is: 922 // callback call ordering is:
913 // 1. per-object callback 923 // 1. per-object callback
914 // 2. per-class object 924 // 2. per-class object
915 // 3. per-type callback 925 // 3. per-type callback
973 gather_callbacks (callbacks, map->cb, event); 983 gather_callbacks (callbacks, map->cb, event);
974 984
975 gather_callbacks (callbacks, cb_map, event); 985 gather_callbacks (callbacks, cb_map, event);
976 break; 986 break;
977 987
988 case KLASS_CLIENT:
989 dt = (data_type) va_arg (ap, int);
990 assert (("first argument must be of type client", dt == DT_CLIENT));
991 ns = va_arg (ap, client *);
992
993 if (ns->cb)
994 gather_callbacks (callbacks, ns->cb, event);
995
996 gather_callbacks (callbacks, cb_client, event);
997 break;
998
978 default: 999 default:
979 assert (("unsupported event klass in cfperl_invoke", 0)); 1000 assert (("unsupported event klass in cfperl_invoke", 0));
980 } 1001 }
981 1002
982 // short-circuit processing if no callbacks found/defined 1003 // short-circuit processing if no callbacks found/defined
995 1016
996 switch (KLASS_OF (event)) 1017 switch (KLASS_OF (event))
997 { 1018 {
998 case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; 1019 case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break;
999 case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; 1020 case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break;
1021 case KLASS_CLIENT: PUSHs (sv_2mortal (newSVdt (DT_CLIENT, ns))); break;
1000 case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; 1022 case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break;
1001 } 1023 }
1002 1024
1003 for (;;) 1025 for (;;)
1004 { 1026 {
1205 const_iv (FLOOR) 1227 const_iv (FLOOR)
1206 const_iv (FLESH) 1228 const_iv (FLESH)
1207 const_iv (INORGANIC) 1229 const_iv (INORGANIC)
1208 const_iv (SKILL_TOOL) 1230 const_iv (SKILL_TOOL)
1209 const_iv (LIGHTER) 1231 const_iv (LIGHTER)
1210 const_iv (TRAP_PART)
1211 const_iv (WALL) 1232 const_iv (BUILDABLE_WALL)
1212 const_iv (LIGHT_SOURCE)
1213 const_iv (MISC_OBJECT) 1233 const_iv (MISC_OBJECT)
1214 const_iv (MONSTER)
1215 const_iv (SPAWN_GENERATOR)
1216 const_iv (LAMP) 1234 const_iv (LAMP)
1217 const_iv (DUPLICATOR) 1235 const_iv (DUPLICATOR)
1218 const_iv (TOOL)
1219 const_iv (SPELLBOOK) 1236 const_iv (SPELLBOOK)
1220 const_iv (BUILDFAC)
1221 const_iv (CLOAK) 1237 const_iv (CLOAK)
1222 const_iv (SPINNER) 1238 const_iv (SPINNER)
1223 const_iv (GATE) 1239 const_iv (GATE)
1224 const_iv (BUTTON) 1240 const_iv (BUTTON)
1225 const_iv (CF_HANDLE) 1241 const_iv (CF_HANDLE)
1232 const_iv (SPELL_EFFECT) 1248 const_iv (SPELL_EFFECT)
1233 const_iv (CONVERTER) 1249 const_iv (CONVERTER)
1234 const_iv (BRACERS) 1250 const_iv (BRACERS)
1235 const_iv (POISONING) 1251 const_iv (POISONING)
1236 const_iv (SAVEBED) 1252 const_iv (SAVEBED)
1237 const_iv (POISONCLOUD)
1238 const_iv (FIREHOLES)
1239 const_iv (WAND) 1253 const_iv (WAND)
1240 const_iv (SCROLL) 1254 const_iv (SCROLL)
1241 const_iv (DIRECTOR) 1255 const_iv (DIRECTOR)
1242 const_iv (GIRDLE) 1256 const_iv (GIRDLE)
1243 const_iv (FORCE) 1257 const_iv (FORCE)
1404 const_iv (FLAG_ACTIVATE_ON_RELEASE) 1418 const_iv (FLAG_ACTIVATE_ON_RELEASE)
1405 const_iv (FLAG_IS_WATER) 1419 const_iv (FLAG_IS_WATER)
1406 const_iv (FLAG_CONTENT_ON_GEN) 1420 const_iv (FLAG_CONTENT_ON_GEN)
1407 const_iv (FLAG_IS_A_TEMPLATE) 1421 const_iv (FLAG_IS_A_TEMPLATE)
1408 const_iv (FLAG_IS_BUILDABLE) 1422 const_iv (FLAG_IS_BUILDABLE)
1409 const_iv (FLAG_AFK)
1410 1423
1411 const_iv (NDI_BLACK) 1424 const_iv (NDI_BLACK)
1412 const_iv (NDI_WHITE) 1425 const_iv (NDI_WHITE)
1413 const_iv (NDI_NAVY) 1426 const_iv (NDI_NAVY)
1414 const_iv (NDI_RED) 1427 const_iv (NDI_RED)
1612 const_iv (MAP_LOADING) 1625 const_iv (MAP_LOADING)
1613 const_iv (MAP_SAVING) 1626 const_iv (MAP_SAVING)
1614 1627
1615 const_iv (KLASS_GLOBAL) 1628 const_iv (KLASS_GLOBAL)
1616 const_iv (KLASS_OBJECT) 1629 const_iv (KLASS_OBJECT)
1630 const_iv (KLASS_CLIENT)
1617 const_iv (KLASS_PLAYER) 1631 const_iv (KLASS_PLAYER)
1618 const_iv (KLASS_MAP) 1632 const_iv (KLASS_MAP)
1633
1634 const_iv (CS_QUERY_YESNO)
1635 const_iv (CS_QUERY_SINGLECHAR)
1636 const_iv (CS_QUERY_HIDEINPUT)
1637
1638 const_iv (ST_DEAD)
1639 const_iv (ST_SETUP)
1640 const_iv (ST_PLAYING)
1641 const_iv (ST_CUSTOM)
1642
1643 const_iv (ST_CHANGE_CLASS)
1644 const_iv (ST_CONFIRM_QUIT)
1645 const_iv (ST_GET_PARTY_PASSWORD)
1619 }; 1646 };
1620 1647
1621 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1648 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1622 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1649 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1623 1650
1647void _init_vars () 1674void _init_vars ()
1648 CODE: 1675 CODE:
1649 cb_global = get_av ("cf::CB_GLOBAL", 1); 1676 cb_global = get_av ("cf::CB_GLOBAL", 1);
1650 cb_object = get_av ("cf::CB_OBJECT", 1); 1677 cb_object = get_av ("cf::CB_OBJECT", 1);
1651 cb_player = get_av ("cf::CB_PLAYER", 1); 1678 cb_player = get_av ("cf::CB_PLAYER", 1);
1679 cb_client = get_av ("cf::CB_CLIENT", 1);
1652 cb_type = get_av ("cf::CB_TYPE" , 1); 1680 cb_type = get_av ("cf::CB_TYPE" , 1);
1653 cb_map = get_av ("cf::CB_MAP" , 1); 1681 cb_map = get_av ("cf::CB_MAP" , 1);
1654 1682
1655void _global_reattach () 1683void _global_reattach ()
1656 CODE: 1684 CODE:
1657{ 1685{
1658 // reattach to all attachable objects in the game. 1686 // reattach to all attachable objects in the game.
1687 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
1688 reattach (*i);
1689
1659 for (player *pl = first_player; pl; pl = pl->next) 1690 for (player *pl = first_player; pl; pl = pl->next)
1660 reattach (pl); 1691 reattach (pl);
1661 1692
1662 for (maptile *map = first_map; map; map = map->next) 1693 for (maptile *map = first_map; map; map = map->next)
1663 reattach (map); 1694 reattach (map);
1664 1695
1665 for (object *op = object::first; op; op = op->next) 1696 for (object *op = object::first; op; op = op->next)
1666 reattach (op); 1697 reattach (op);
1667} 1698}
1668
1669bool
1670add_client (int fd, const char *peername)
1671 1699
1672NV floor (NV x) 1700NV floor (NV x)
1673 1701
1674NV ceil (NV x) 1702NV ceil (NV x)
1675 1703
1730 1758
1731int random_roll (int min, int max, object *op, int goodbad); 1759int random_roll (int min, int max, object *op, int goodbad);
1732 1760
1733const char *cost_string_from_value(uint64 cost, int approx = 0) 1761const char *cost_string_from_value(uint64 cost, int approx = 0)
1734 1762
1735int invoke (int event, ...)
1736 CODE:
1737 if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL");
1738 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1739 for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1740 RETVAL = INVOKE_((event_type)event, ARG_AV (av));
1741 OUTPUT: RETVAL
1742
1743int 1763int
1744exp_to_level (val64 exp) 1764exp_to_level (val64 exp)
1745 CODE: 1765 CODE:
1746{ 1766{
1747 int i = 0; 1767 int i = 0;
1777 RETVAL = newSVpv (resist_plus[atnr], 0); 1797 RETVAL = newSVpv (resist_plus[atnr], 0);
1778 else 1798 else
1779 XSRETURN_UNDEF; 1799 XSRETURN_UNDEF;
1780 OUTPUT: RETVAL 1800 OUTPUT: RETVAL
1781 1801
1802MODULE = cf PACKAGE = cf::attachable
1803
1782int 1804int
1783_valid (SV *obj) 1805valid (SV *obj)
1784 CODE: 1806 CODE:
1785 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1807 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1786 OUTPUT: 1808 OUTPUT:
1787 RETVAL 1809 RETVAL
1810
1811MODULE = cf PACKAGE = cf::global
1812
1813int invoke (SV *klass, int event, ...)
1814 CODE:
1815 if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL");
1816 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1817 for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1818 RETVAL = INVOKE_((event_type)event, ARG_AV (av));
1819 OUTPUT: RETVAL
1788 1820
1789MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1821MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1790 1822
1791INCLUDE: $PERL genacc object ../include/object.h | 1823INCLUDE: $PERL genacc object ../include/object.h |
1792 1824
1811 RETVAL = object::first; 1843 RETVAL = object::first;
1812 OUTPUT: RETVAL 1844 OUTPUT: RETVAL
1813 1845
1814# missing properties 1846# missing properties
1815 1847
1816int flag (object *op, int flag, int value = 1)
1817 PROTOTYPE: $$;$
1818 CODE:
1819 RETVAL = QUERY_FLAG (op, flag);
1820 if (items >= 3)
1821 if (value)
1822 SET_FLAG (op, flag);
1823 else
1824 CLEAR_FLAG (op, flag);
1825 OUTPUT: RETVAL
1826
1827object *head (object *op) 1848object *head (object *op)
1828 PROTOTYPE: $ 1849 PROTOTYPE: $
1829 CODE: 1850 CODE:
1830 RETVAL = op->head ? op->head : op; 1851 RETVAL = op->head ? op->head : op;
1831 OUTPUT: RETVAL 1852 OUTPUT: RETVAL
1841 PROTOTYPE: $ 1862 PROTOTYPE: $
1842 PPCODE: 1863 PPCODE:
1843{ 1864{
1844 object *o; 1865 object *o;
1845 for (o = obj->inv; o; o = o->below) 1866 for (o = obj->inv; o; o = o->below)
1846 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1867 XPUSHs (sv_2mortal (to_sv (o)));
1847} 1868}
1869
1870void
1871set_animation (object *op, int idx)
1872 CODE:
1873 SET_ANIMATION (op, idx);
1874
1875void
1876object::drain_stat ()
1877
1878void
1879object::drain_specific_stat (int stat)
1880
1881void
1882object::change_luck (int change)
1883
1884void
1885object::add_statbonus ()
1886
1887void
1888object::remove_statbonus ()
1848 1889
1849object *find_best_object_match (object *op, const char *match) 1890object *find_best_object_match (object *op, const char *match)
1850 1891
1851object *find_marked_object (object *op) 1892object *find_marked_object (object *op)
1852
1853int resistance (object *op, int rtype, int newval = 0)
1854 CODE:
1855 if (rtype < 0 || rtype >= NROFATTACKS)
1856 croak ("resistance out of bounds");
1857 RETVAL = op->resist [rtype];
1858 if (items >= 3)
1859 op->resist [rtype] = newval;
1860 OUTPUT: RETVAL
1861
1862void set_resistance (object *op, int rtype, int val)
1863 CODE:
1864 if (rtype < 0 || rtype >= NROFATTACKS)
1865 op->resist[rtype] = val;
1866 1893
1867int need_identify (const object *obj); 1894int need_identify (const object *obj);
1868 1895
1869int apply_shop_mat (object *shop_mat, object *op); 1896int apply_shop_mat (object *shop_mat, object *op);
1870 1897
1953 1980
1954object *cf_object_insert_in_ob (object *ob, object *where) 1981object *cf_object_insert_in_ob (object *ob, object *where)
1955 1982
1956int cf_object_teleport (object *op, maptile *map, int x, int y) 1983int cf_object_teleport (object *op, maptile *map, int x, int y)
1957 1984
1958void update (object *op, int action) 1985void update_object (object *op, int action)
1959 CODE:
1960 update_object (op, action);
1961 1986
1962object *cf_create_object_by_name (const char *name) 1987object *cf_create_object_by_name (const char *name)
1963 1988
1964void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) 1989void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0)
1965 1990
1977 2002
1978void remove_button_link (object *op); 2003void remove_button_link (object *op);
1979 2004
1980 2005
1981MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2006MODULE = cf PACKAGE = cf::object PREFIX = cf_
1982
1983void cf_fix_object (object *pl)
1984 ALIAS: fix = 0
1985 2007
1986object *cf_insert_ob_in_ob (object *ob, object *where) 2008object *cf_insert_ob_in_ob (object *ob, object *where)
1987 2009
1988# no clean way to get an object from an archetype - stupid idiotic 2010# no clean way to get an object from an archetype - stupid idiotic
1989# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2011# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2012 2034
2013player *contr (object *op) 2035player *contr (object *op)
2014 CODE: 2036 CODE:
2015 RETVAL = op->contr; 2037 RETVAL = op->contr;
2016 OUTPUT: RETVAL 2038 OUTPUT: RETVAL
2039
2040void
2041object::roll_stats ()
2042
2043void
2044object::update_stats ()
2045
2046void
2047object::swap_stats (int a, int b)
2017 2048
2018const char *get_ob_key_value (object *op, const char *key) 2049const char *get_ob_key_value (object *op, const char *key)
2019 2050
2020bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) 2051bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1)
2021 2052
2056player *player (object *op) 2087player *player (object *op)
2057 CODE: 2088 CODE:
2058 RETVAL = op->contr; 2089 RETVAL = op->contr;
2059 OUTPUT: RETVAL 2090 OUTPUT: RETVAL
2060 2091
2092void check_score (object *op)
2093
2061void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) 2094void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE)
2062 2095
2063object *cf_player_send_inventory (object *op) 2096object *cf_player_send_inventory (object *op)
2064 2097
2065char *cf_player_get_ip (object *op) 2098char *cf_player_get_ip (object *op)
2107 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); 2140 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av));
2108 OUTPUT: RETVAL 2141 OUTPUT: RETVAL
2109 2142
2110SV *registry (player *pl) 2143SV *registry (player *pl)
2111 2144
2145player *
2146create ()
2147 CODE:
2148 RETVAL = player::create ();
2149 OUTPUT:
2150 RETVAL
2151
2152player *
2153load (const char *path)
2154 CODE:
2155 RETVAL = player::load (path);
2156 OUTPUT:
2157 RETVAL
2158
2159void
2160player::save (bool final = false)
2161
2162void
2163player::connect (client *ns)
2164
2165void
2166save_stats (player *pl)
2167 CODE:
2168 pl->ob->stats.hp = pl->ob->stats.maxhp;
2169 pl->ob->stats.sp = pl->ob->stats.maxsp;
2170 pl->ob->stats.grace = pl->ob->stats.maxgrace;
2171 pl->orig_stats = pl->ob->stats;
2172
2112player *cf_player_find (char *name) 2173player *cf_player_find (char *name)
2113 PROTOTYPE: $ 2174 PROTOTYPE: $
2114 2175
2115void cf_player_move (player *pl, int dir) 2176void cf_player_move (player *pl, int dir)
2116 2177
2119player *first () 2180player *first ()
2120 CODE: 2181 CODE:
2121 RETVAL = first_player; 2182 RETVAL = first_player;
2122 OUTPUT: RETVAL 2183 OUTPUT: RETVAL
2123 2184
2124player *next (player *pl)
2125 CODE:
2126 RETVAL = pl->next;
2127 OUTPUT: RETVAL
2128
2129bool 2185bool
2130cell_visible (player *pl, int dx, int dy) 2186cell_visible (player *pl, int dx, int dy)
2131 CODE: 2187 CODE:
2132 RETVAL = FABS (dx) <= pl->socket->mapx / 2 && FABS (dy) <= pl->socket->mapy / 2 2188 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2
2133 && !pl->blocked_los [dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]; 2189 && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2];
2134 OUTPUT: 2190 OUTPUT:
2135 RETVAL 2191 RETVAL
2136 2192
2137void 2193void
2138send (player *pl, SV *packet) 2194send (player *pl, SV *packet)
2139 CODE: 2195 CODE:
2140{ 2196{
2141 STRLEN len; 2197 STRLEN len;
2142 char *buf = SvPVbyte (packet, len); 2198 char *buf = SvPVbyte (packet, len);
2143 2199
2200 if (pl->ns)
2144 pl->socket->send_packet (buf, len); 2201 pl->ns->send_packet (buf, len);
2145} 2202}
2146 2203
2147int 2204int
2148listening (player *pl, int new_value = -1) 2205listening (player *pl, int new_value = -1)
2149 CODE: 2206 CODE:
2168 if (y) sv_to (y, pl->bed_y); 2225 if (y) sv_to (y, pl->bed_y);
2169 2226
2170void 2227void
2171list () 2228list ()
2172 PPCODE: 2229 PPCODE:
2173{
2174 player *pl;
2175 for (pl = first_player; pl; pl = pl->next) 2230 for (player *pl = first_player; pl; pl = pl->next)
2176 XPUSHs (newSVcfapi (CFAPI_PPLAYER, pl)); 2231 XPUSHs (sv_2mortal (to_sv (pl)));
2177}
2178 2232
2179bool 2233bool
2180peaceful (player *pl, bool new_setting = 0) 2234peaceful (player *pl, bool new_setting = 0)
2181 PROTOTYPE: $;$ 2235 PROTOTYPE: $;$
2182 CODE: 2236 CODE:
2445 OUTPUT: RETVAL 2499 OUTPUT: RETVAL
2446 2500
2447SV *registry (client *ns) 2501SV *registry (client *ns)
2448 2502
2449void 2503void
2504list ()
2505 PPCODE:
2506 EXTEND (SP, clients.size ());
2507 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
2508 PUSHs (sv_2mortal (to_sv (*i)));
2509
2510client *
2511create (int fd, const char *peername)
2512 CODE:
2513 RETVAL = client::create (fd, peername);
2514 OUTPUT:
2515 RETVAL
2516
2517void
2518client::send_packet (SV *packet)
2519 CODE:
2520{
2521 STRLEN len;
2522 char *buf = SvPVbyte (packet, len);
2523
2524 THIS->send_packet (buf, len);
2525}
2526
2527void
2450client::destroy () 2528client::destroy ()
2451 2529

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines