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.85 by root, Sat Dec 16 03:08:26 2006 UTC vs.
Revision 1.104 by root, Sat Dec 23 06:41:39 2006 UTC

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 ())
243 case DT_MAP: 243 case DT_MAP:
244 // va_arg (object *) when void * is passed is an XSI extension 244 // va_arg (object *) when void * is passed is an XSI extension
245 sv = to_sv (va_arg (ap, maptile *)); 245 sv = to_sv (va_arg (ap, maptile *));
246 break; 246 break;
247 247
248 case DT_SOCKET: 248 case DT_CLIENT:
249 sv = to_sv (va_arg (ap, client *)); 249 sv = to_sv (va_arg (ap, client *));
250 break; 250 break;
251 251
252 case DT_PLAYER: 252 case DT_PLAYER:
253 sv = to_sv (va_arg (ap, player *)); 253 sv = to_sv (va_arg (ap, player *));
361 361
362 HV *hv = (HV *)SvRV ((SV *)self); 362 HV *hv = (HV *)SvRV ((SV *)self);
363 363
364 if (SvREFCNT ((SV *)self) == 1 364 if (SvREFCNT ((SV *)self) == 1
365 && SvREFCNT ((SV *)hv) == 1 365 && SvREFCNT ((SV *)hv) == 1
366 && !HvKEYS (hv)) 366 && !HvTOTALKEYS (hv))
367 { 367 {
368 SvREFCNT_dec ((SV *)self); 368 SvREFCNT_dec ((SV *)self);
369 self = 0; 369 self = 0;
370 } 370 }
371} 371}
412 412
413 switch (type) 413 switch (type)
414 { 414 {
415 case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break; 415 case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break;
416 case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break; 416 case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break;
417 case DT_CLIENT: INVOKE_CLIENT (REATTACH, obj); break;
417 case DT_MAP: INVOKE_MAP (REATTACH, obj); break; 418 case DT_MAP: INVOKE_MAP (REATTACH, obj); break;
418 } 419 }
419} 420}
420 421
421template<class subclass> 422template<class subclass>
906 AV *callbacks = 0; 907 AV *callbacks = 0;
907 908
908 object *op; 909 object *op;
909 player *pl; 910 player *pl;
910 maptile *map; 911 maptile *map;
912 client *ns;
911 913
912 // callback call ordering is: 914 // callback call ordering is:
913 // 1. per-object callback 915 // 1. per-object callback
914 // 2. per-class object 916 // 2. per-class object
915 // 3. per-type callback 917 // 3. per-type callback
973 gather_callbacks (callbacks, map->cb, event); 975 gather_callbacks (callbacks, map->cb, event);
974 976
975 gather_callbacks (callbacks, cb_map, event); 977 gather_callbacks (callbacks, cb_map, event);
976 break; 978 break;
977 979
980 case KLASS_CLIENT:
981 dt = (data_type) va_arg (ap, int);
982 assert (("first argument must be of type client", dt == DT_CLIENT));
983 ns = va_arg (ap, client *);
984
985 if (ns->cb)
986 gather_callbacks (callbacks, ns->cb, event);
987
988 gather_callbacks (callbacks, cb_client, event);
989 break;
990
978 default: 991 default:
979 assert (("unsupported event klass in cfperl_invoke", 0)); 992 assert (("unsupported event klass in cfperl_invoke", 0));
980 } 993 }
981 994
982 // short-circuit processing if no callbacks found/defined 995 // short-circuit processing if no callbacks found/defined
995 1008
996 switch (KLASS_OF (event)) 1009 switch (KLASS_OF (event))
997 { 1010 {
998 case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; 1011 case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break;
999 case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; 1012 case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break;
1013 case KLASS_CLIENT: PUSHs (sv_2mortal (newSVdt (DT_CLIENT, ns))); break;
1000 case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; 1014 case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break;
1001 } 1015 }
1002 1016
1003 for (;;) 1017 for (;;)
1004 { 1018 {
1147 const_iv (POTION) 1161 const_iv (POTION)
1148 const_iv (FOOD) 1162 const_iv (FOOD)
1149 const_iv (POISON) 1163 const_iv (POISON)
1150 const_iv (BOOK) 1164 const_iv (BOOK)
1151 const_iv (CLOCK) 1165 const_iv (CLOCK)
1152 const_iv (LIGHTNING)
1153 const_iv (ARROW) 1166 const_iv (ARROW)
1154 const_iv (BOW) 1167 const_iv (BOW)
1155 const_iv (WEAPON) 1168 const_iv (WEAPON)
1156 const_iv (ARMOUR) 1169 const_iv (ARMOUR)
1157 const_iv (PEDESTAL) 1170 const_iv (PEDESTAL)
1177 const_iv (AMULET) 1190 const_iv (AMULET)
1178 const_iv (PLAYERMOVER) 1191 const_iv (PLAYERMOVER)
1179 const_iv (TELEPORTER) 1192 const_iv (TELEPORTER)
1180 const_iv (CREATOR) 1193 const_iv (CREATOR)
1181 const_iv (SKILL) 1194 const_iv (SKILL)
1182 const_iv (EXPERIENCE)
1183 const_iv (EARTHWALL) 1195 const_iv (EARTHWALL)
1184 const_iv (GOLEM) 1196 const_iv (GOLEM)
1185 const_iv (THROWN_OBJ) 1197 const_iv (THROWN_OBJ)
1186 const_iv (BLINDNESS) 1198 const_iv (BLINDNESS)
1187 const_iv (GOD) 1199 const_iv (GOD)
1207 const_iv (FLOOR) 1219 const_iv (FLOOR)
1208 const_iv (FLESH) 1220 const_iv (FLESH)
1209 const_iv (INORGANIC) 1221 const_iv (INORGANIC)
1210 const_iv (SKILL_TOOL) 1222 const_iv (SKILL_TOOL)
1211 const_iv (LIGHTER) 1223 const_iv (LIGHTER)
1212 const_iv (TRAP_PART)
1213 const_iv (WALL) 1224 const_iv (BUILDABLE_WALL)
1214 const_iv (LIGHT_SOURCE)
1215 const_iv (MISC_OBJECT) 1225 const_iv (MISC_OBJECT)
1216 const_iv (MONSTER)
1217 const_iv (SPAWN_GENERATOR)
1218 const_iv (LAMP) 1226 const_iv (LAMP)
1219 const_iv (DUPLICATOR) 1227 const_iv (DUPLICATOR)
1220 const_iv (TOOL)
1221 const_iv (SPELLBOOK) 1228 const_iv (SPELLBOOK)
1222 const_iv (BUILDFAC)
1223 const_iv (CLOAK) 1229 const_iv (CLOAK)
1224 const_iv (SPINNER) 1230 const_iv (SPINNER)
1225 const_iv (GATE) 1231 const_iv (GATE)
1226 const_iv (BUTTON) 1232 const_iv (BUTTON)
1227 const_iv (CF_HANDLE) 1233 const_iv (CF_HANDLE)
1234 const_iv (SPELL_EFFECT) 1240 const_iv (SPELL_EFFECT)
1235 const_iv (CONVERTER) 1241 const_iv (CONVERTER)
1236 const_iv (BRACERS) 1242 const_iv (BRACERS)
1237 const_iv (POISONING) 1243 const_iv (POISONING)
1238 const_iv (SAVEBED) 1244 const_iv (SAVEBED)
1239 const_iv (POISONCLOUD)
1240 const_iv (FIREHOLES)
1241 const_iv (WAND) 1245 const_iv (WAND)
1242 const_iv (SCROLL) 1246 const_iv (SCROLL)
1243 const_iv (DIRECTOR) 1247 const_iv (DIRECTOR)
1244 const_iv (GIRDLE) 1248 const_iv (GIRDLE)
1245 const_iv (FORCE) 1249 const_iv (FORCE)
1260 const_iv (DISEASE) 1264 const_iv (DISEASE)
1261 const_iv (SYMPTOM) 1265 const_iv (SYMPTOM)
1262 const_iv (BUILDER) 1266 const_iv (BUILDER)
1263 const_iv (MATERIAL) 1267 const_iv (MATERIAL)
1264 const_iv (ITEM_TRANSFORMER) 1268 const_iv (ITEM_TRANSFORMER)
1265 const_iv (QUEST)
1266 1269
1267 const_iv (NUM_SUBTYPES) 1270 const_iv (NUM_SUBTYPES)
1268 1271
1269 const_iv (ST_BD_BUILD) 1272 const_iv (ST_BD_BUILD)
1270 const_iv (ST_BD_REMOVE) 1273 const_iv (ST_BD_REMOVE)
1323 const_iv (FLAG_MONSTER) 1326 const_iv (FLAG_MONSTER)
1324 const_iv (FLAG_FRIENDLY) 1327 const_iv (FLAG_FRIENDLY)
1325 const_iv (FLAG_GENERATOR) 1328 const_iv (FLAG_GENERATOR)
1326 const_iv (FLAG_IS_THROWN) 1329 const_iv (FLAG_IS_THROWN)
1327 const_iv (FLAG_AUTO_APPLY) 1330 const_iv (FLAG_AUTO_APPLY)
1328 const_iv (FLAG_TREASURE)
1329 const_iv (FLAG_PLAYER_SOLD) 1331 const_iv (FLAG_PLAYER_SOLD)
1330 const_iv (FLAG_SEE_INVISIBLE) 1332 const_iv (FLAG_SEE_INVISIBLE)
1331 const_iv (FLAG_CAN_ROLL) 1333 const_iv (FLAG_CAN_ROLL)
1332 const_iv (FLAG_OVERLAY_FLOOR) 1334 const_iv (FLAG_OVERLAY_FLOOR)
1333 const_iv (FLAG_IS_TURNABLE) 1335 const_iv (FLAG_IS_TURNABLE)
1456 const_iv (F_BUY) 1458 const_iv (F_BUY)
1457 const_iv (F_SHOP) 1459 const_iv (F_SHOP)
1458 const_iv (F_SELL) 1460 const_iv (F_SELL)
1459 1461
1460 const_iv (P_BLOCKSVIEW) 1462 const_iv (P_BLOCKSVIEW)
1463 const_iv (P_PLAYER)
1461 const_iv (P_NO_MAGIC) 1464 const_iv (P_NO_MAGIC)
1462 const_iv (P_IS_ALIVE) 1465 const_iv (P_IS_ALIVE)
1463 const_iv (P_NO_CLERIC) 1466 const_iv (P_NO_CLERIC)
1464 const_iv (P_NEED_UPDATE) 1467 const_iv (P_NEED_UPDATE)
1465 const_iv (P_NO_ERROR)
1466 const_iv (P_OUT_OF_MAP) 1468 const_iv (P_OUT_OF_MAP)
1467 const_iv (P_NEW_MAP) 1469 const_iv (P_NEW_MAP)
1468 1470
1469 const_iv (UP_OBJ_INSERT) 1471 const_iv (UP_OBJ_INSERT)
1470 const_iv (UP_OBJ_REMOVE) 1472 const_iv (UP_OBJ_REMOVE)
1616 const_iv (MAP_LOADING) 1618 const_iv (MAP_LOADING)
1617 const_iv (MAP_SAVING) 1619 const_iv (MAP_SAVING)
1618 1620
1619 const_iv (KLASS_GLOBAL) 1621 const_iv (KLASS_GLOBAL)
1620 const_iv (KLASS_OBJECT) 1622 const_iv (KLASS_OBJECT)
1623 const_iv (KLASS_CLIENT)
1621 const_iv (KLASS_PLAYER) 1624 const_iv (KLASS_PLAYER)
1622 const_iv (KLASS_MAP) 1625 const_iv (KLASS_MAP)
1626
1627 const_iv (CS_QUERY_YESNO)
1628 const_iv (CS_QUERY_SINGLECHAR)
1629 const_iv (CS_QUERY_HIDEINPUT)
1630
1631 const_iv (ST_DEAD)
1632 const_iv (ST_SETUP)
1633 const_iv (ST_PLAYING)
1634 const_iv (ST_CUSTOM)
1635
1636 const_iv (ST_CHANGE_CLASS)
1637 const_iv (ST_CONFIRM_QUIT)
1638 const_iv (ST_GET_PARTY_PASSWORD)
1623 }; 1639 };
1624 1640
1625 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1641 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1626 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1642 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1627 1643
1651void _init_vars () 1667void _init_vars ()
1652 CODE: 1668 CODE:
1653 cb_global = get_av ("cf::CB_GLOBAL", 1); 1669 cb_global = get_av ("cf::CB_GLOBAL", 1);
1654 cb_object = get_av ("cf::CB_OBJECT", 1); 1670 cb_object = get_av ("cf::CB_OBJECT", 1);
1655 cb_player = get_av ("cf::CB_PLAYER", 1); 1671 cb_player = get_av ("cf::CB_PLAYER", 1);
1672 cb_client = get_av ("cf::CB_CLIENT", 1);
1656 cb_type = get_av ("cf::CB_TYPE" , 1); 1673 cb_type = get_av ("cf::CB_TYPE" , 1);
1657 cb_map = get_av ("cf::CB_MAP" , 1); 1674 cb_map = get_av ("cf::CB_MAP" , 1);
1658 1675
1659void _global_reattach () 1676void _global_reattach ()
1660 CODE: 1677 CODE:
1661{ 1678{
1662 // reattach to all attachable objects in the game. 1679 // reattach to all attachable objects in the game.
1680 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
1681 reattach (*i);
1682
1663 for (player *pl = first_player; pl; pl = pl->next) 1683 for (player *pl = first_player; pl; pl = pl->next)
1664 reattach (pl); 1684 reattach (pl);
1665 1685
1666 for (maptile *map = first_map; map; map = map->next) 1686 for (maptile *map = first_map; map; map = map->next)
1667 reattach (map); 1687 reattach (map);
1668 1688
1669 for (object *op = object::first; op; op = op->next) 1689 for (object *op = object::first; op; op = op->next)
1670 reattach (op); 1690 reattach (op);
1671} 1691}
1672
1673bool
1674add_client (int fd, const char *peername)
1675 1692
1676NV floor (NV x) 1693NV floor (NV x)
1677 1694
1678NV ceil (NV x) 1695NV ceil (NV x)
1679 1696
1734 1751
1735int random_roll (int min, int max, object *op, int goodbad); 1752int random_roll (int min, int max, object *op, int goodbad);
1736 1753
1737const char *cost_string_from_value(uint64 cost, int approx = 0) 1754const char *cost_string_from_value(uint64 cost, int approx = 0)
1738 1755
1739int invoke (int event, ...)
1740 CODE:
1741 if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL");
1742 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1743 for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1744 RETVAL = INVOKE_((event_type)event, ARG_AV (av));
1745 OUTPUT: RETVAL
1746
1747int 1756int
1748exp_to_level (val64 exp) 1757exp_to_level (val64 exp)
1749 CODE: 1758 CODE:
1750{ 1759{
1751 int i = 0; 1760 int i = 0;
1781 RETVAL = newSVpv (resist_plus[atnr], 0); 1790 RETVAL = newSVpv (resist_plus[atnr], 0);
1782 else 1791 else
1783 XSRETURN_UNDEF; 1792 XSRETURN_UNDEF;
1784 OUTPUT: RETVAL 1793 OUTPUT: RETVAL
1785 1794
1795MODULE = cf PACKAGE = cf::attachable
1796
1786int 1797int
1787_valid (SV *obj) 1798valid (SV *obj)
1788 CODE: 1799 CODE:
1789 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1800 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1790 OUTPUT: 1801 OUTPUT:
1791 RETVAL 1802 RETVAL
1803
1804MODULE = cf PACKAGE = cf::global
1805
1806int invoke (SV *klass, int event, ...)
1807 CODE:
1808 if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL");
1809 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1810 for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1811 RETVAL = INVOKE_((event_type)event, ARG_AV (av));
1812 OUTPUT: RETVAL
1792 1813
1793MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1814MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1794 1815
1795INCLUDE: $PERL genacc object ../include/object.h | 1816INCLUDE: $PERL genacc object ../include/object.h |
1796 1817
1818# missing properties 1839# missing properties
1819 1840
1820int flag (object *op, int flag, int value = 1) 1841int flag (object *op, int flag, int value = 1)
1821 PROTOTYPE: $$;$ 1842 PROTOTYPE: $$;$
1822 CODE: 1843 CODE:
1823 RETVAL = QUERY_FLAG (op, flag); 1844 RETVAL = op->flag [flag];
1824 if (items >= 3) 1845 if (items >= 3)
1825 if (value) 1846 op->flag [flag] = value;
1826 SET_FLAG (op, flag);
1827 else
1828 CLEAR_FLAG (op, flag);
1829 OUTPUT: RETVAL 1847 OUTPUT: RETVAL
1830 1848
1831object *head (object *op) 1849object *head (object *op)
1832 PROTOTYPE: $ 1850 PROTOTYPE: $
1833 CODE: 1851 CODE:
1845 PROTOTYPE: $ 1863 PROTOTYPE: $
1846 PPCODE: 1864 PPCODE:
1847{ 1865{
1848 object *o; 1866 object *o;
1849 for (o = obj->inv; o; o = o->below) 1867 for (o = obj->inv; o; o = o->below)
1850 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1868 XPUSHs (sv_2mortal (to_sv (o)));
1851} 1869}
1870
1871void
1872set_animation (object *op, int idx)
1873 CODE:
1874 SET_ANIMATION (op, idx);
1875
1876void
1877object::drain_stat ()
1878
1879void
1880object::drain_specific_stat (int stat)
1881
1882void
1883object::change_luck (int change)
1884
1885void
1886object::add_statbonus ()
1887
1888void
1889object::remove_statbonus ()
1852 1890
1853object *find_best_object_match (object *op, const char *match) 1891object *find_best_object_match (object *op, const char *match)
1854 1892
1855object *find_marked_object (object *op) 1893object *find_marked_object (object *op)
1856 1894
1888 1926
1889void remove (object *op) 1927void remove (object *op)
1890 CODE: 1928 CODE:
1891 op->remove (); 1929 op->remove ();
1892 1930
1893void destroy (object *op, int recursive = 0) 1931void
1894 CODE: 1932object::destroy (int recursive = 0)
1895 op->destroy (recursive);
1896 1933
1897object *cf_object_present_archname_inside (object *op, char *whatstr) 1934object *cf_object_present_archname_inside (object *op, char *whatstr)
1898 1935
1899int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) 1936int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0)
1900 1937
1958 1995
1959object *cf_object_insert_in_ob (object *ob, object *where) 1996object *cf_object_insert_in_ob (object *ob, object *where)
1960 1997
1961int cf_object_teleport (object *op, maptile *map, int x, int y) 1998int cf_object_teleport (object *op, maptile *map, int x, int y)
1962 1999
1963void update (object *op, int action) 2000void update_object (object *op, int action)
1964 CODE:
1965 update_object (op, action);
1966 2001
1967object *cf_create_object_by_name (const char *name) 2002object *cf_create_object_by_name (const char *name)
1968 2003
1969void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) 2004void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0)
1970 2005
1982 2017
1983void remove_button_link (object *op); 2018void remove_button_link (object *op);
1984 2019
1985 2020
1986MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2021MODULE = cf PACKAGE = cf::object PREFIX = cf_
1987
1988void cf_fix_object (object *pl)
1989 ALIAS: fix = 0
1990 2022
1991object *cf_insert_ob_in_ob (object *ob, object *where) 2023object *cf_insert_ob_in_ob (object *ob, object *where)
1992 2024
1993# no clean way to get an object from an archetype - stupid idiotic 2025# no clean way to get an object from an archetype - stupid idiotic
1994# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2026# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2017 2049
2018player *contr (object *op) 2050player *contr (object *op)
2019 CODE: 2051 CODE:
2020 RETVAL = op->contr; 2052 RETVAL = op->contr;
2021 OUTPUT: RETVAL 2053 OUTPUT: RETVAL
2054
2055void
2056object::roll_stats ()
2057
2058void
2059object::update_stats ()
2060
2061void
2062object::swap_stats (int a, int b)
2022 2063
2023const char *get_ob_key_value (object *op, const char *key) 2064const char *get_ob_key_value (object *op, const char *key)
2024 2065
2025bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) 2066bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1)
2026 2067
2052base_name (object *op, int plural = op->nrof > 1) 2093base_name (object *op, int plural = op->nrof > 1)
2053 CODE: 2094 CODE:
2054 RETVAL = query_base_name (op, plural); 2095 RETVAL = query_base_name (op, plural);
2055 OUTPUT: RETVAL 2096 OUTPUT: RETVAL
2056 2097
2098object *decrease_ob_nr (object *op, unsigned long i)
2099
2057MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 2100MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
2058 2101
2059player *player (object *op) 2102player *player (object *op)
2060 CODE: 2103 CODE:
2061 RETVAL = op->contr; 2104 RETVAL = op->contr;
2110 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); 2153 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av));
2111 OUTPUT: RETVAL 2154 OUTPUT: RETVAL
2112 2155
2113SV *registry (player *pl) 2156SV *registry (player *pl)
2114 2157
2158player *
2159create ()
2160 CODE:
2161 RETVAL = player::create ();
2162 OUTPUT:
2163 RETVAL
2164
2165player *
2166load (const char *path)
2167 CODE:
2168 RETVAL = player::load (path);
2169 OUTPUT:
2170 RETVAL
2171
2172void
2173player::save (bool final = false)
2174
2175void
2176player::connect (client *ns)
2177
2178void
2179save_stats (player *pl)
2180 CODE:
2181 pl->ob->stats.hp = pl->ob->stats.maxhp;
2182 pl->ob->stats.sp = pl->ob->stats.maxsp;
2183 pl->ob->stats.grace = pl->ob->stats.maxgrace;
2184 pl->orig_stats = pl->ob->stats;
2185
2115player *cf_player_find (char *name) 2186player *cf_player_find (char *name)
2116 PROTOTYPE: $ 2187 PROTOTYPE: $
2117 2188
2118void cf_player_move (player *pl, int dir) 2189void cf_player_move (player *pl, int dir)
2119 2190
2122player *first () 2193player *first ()
2123 CODE: 2194 CODE:
2124 RETVAL = first_player; 2195 RETVAL = first_player;
2125 OUTPUT: RETVAL 2196 OUTPUT: RETVAL
2126 2197
2127player *next (player *pl)
2128 CODE:
2129 RETVAL = pl->next;
2130 OUTPUT: RETVAL
2131
2132bool 2198bool
2133cell_visible (player *pl, int dx, int dy) 2199cell_visible (player *pl, int dx, int dy)
2134 CODE: 2200 CODE:
2135 RETVAL = FABS (dx) <= pl->socket->mapx / 2 && FABS (dy) <= pl->socket->mapy / 2 2201 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2
2136 && !pl->blocked_los [dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]; 2202 && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2];
2137 OUTPUT: 2203 OUTPUT:
2138 RETVAL 2204 RETVAL
2139 2205
2140void 2206void
2141send (player *pl, SV *packet) 2207send (player *pl, SV *packet)
2142 CODE: 2208 CODE:
2143{ 2209{
2144 STRLEN len; 2210 STRLEN len;
2145 char *buf = SvPVbyte (packet, len); 2211 char *buf = SvPVbyte (packet, len);
2146 2212
2213 if (pl->ns)
2147 pl->socket->send_packet (buf, len); 2214 pl->ns->send_packet (buf, len);
2148} 2215}
2149 2216
2150int 2217int
2151listening (player *pl, int new_value = -1) 2218listening (player *pl, int new_value = -1)
2152 CODE: 2219 CODE:
2171 if (y) sv_to (y, pl->bed_y); 2238 if (y) sv_to (y, pl->bed_y);
2172 2239
2173void 2240void
2174list () 2241list ()
2175 PPCODE: 2242 PPCODE:
2176{
2177 player *pl;
2178 for (pl = first_player; pl; pl = pl->next) 2243 for (player *pl = first_player; pl; pl = pl->next)
2179 XPUSHs (newSVcfapi (CFAPI_PPLAYER, pl)); 2244 XPUSHs (sv_2mortal (to_sv (pl)));
2180}
2181 2245
2182bool 2246bool
2183peaceful (player *pl, bool new_setting = 0) 2247peaceful (player *pl, bool new_setting = 0)
2184 PROTOTYPE: $;$ 2248 PROTOTYPE: $;$
2185 CODE: 2249 CODE:
2439 2503
2440INCLUDE: $PERL genacc client ../include/client.h | 2504INCLUDE: $PERL genacc client ../include/client.h |
2441 2505
2442int invoke (client *ns, int event, ...) 2506int invoke (client *ns, int event, ...)
2443 CODE: 2507 CODE:
2444 if (KLASS_OF (event) != KLASS_SOCKET) croak ("event class must be SOCKET"); 2508 if (KLASS_OF (event) != KLASS_CLIENT) croak ("event class must be CLIENT");
2445 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2509 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2446 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 2510 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
2447 RETVAL = INVOKE_((event_type)event, ARG_SOCKET (ns), ARG_AV (av)); 2511 RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av));
2448 OUTPUT: RETVAL 2512 OUTPUT: RETVAL
2449 2513
2450SV *registry (client *ns) 2514SV *registry (client *ns)
2451 2515
2516void
2517list ()
2518 PPCODE:
2519 EXTEND (SP, clients.size ());
2520 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
2521 PUSHs (sv_2mortal (to_sv (*i)));
2522
2523client *
2524create (int fd, const char *peername)
2525 CODE:
2526 RETVAL = client::create (fd, peername);
2527 OUTPUT:
2528 RETVAL
2529
2530void
2531client::send_packet (SV *packet)
2532 CODE:
2533{
2534 STRLEN len;
2535 char *buf = SvPVbyte (packet, len);
2536
2537 THIS->send_packet (buf, len);
2538}
2539
2540void
2541client::destroy ()
2542

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines