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.97 by root, Thu Dec 21 22:41:35 2006 UTC vs.
Revision 1.103 by root, Sat Dec 23 06:21:02 2006 UTC

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}
1008 1008
1009 switch (KLASS_OF (event)) 1009 switch (KLASS_OF (event))
1010 { 1010 {
1011 case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; 1011 case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break;
1012 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, pl))); break; 1013 case KLASS_CLIENT: PUSHs (sv_2mortal (newSVdt (DT_CLIENT, ns))); break;
1014 case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; 1014 case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break;
1015 } 1015 }
1016 1016
1017 for (;;) 1017 for (;;)
1018 { 1018 {
1621 const_iv (KLASS_GLOBAL) 1621 const_iv (KLASS_GLOBAL)
1622 const_iv (KLASS_OBJECT) 1622 const_iv (KLASS_OBJECT)
1623 const_iv (KLASS_CLIENT) 1623 const_iv (KLASS_CLIENT)
1624 const_iv (KLASS_PLAYER) 1624 const_iv (KLASS_PLAYER)
1625 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)
1626 }; 1639 };
1627 1640
1628 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; )
1629 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1642 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1630 1643
1738 1751
1739int random_roll (int min, int max, object *op, int goodbad); 1752int random_roll (int min, int max, object *op, int goodbad);
1740 1753
1741const char *cost_string_from_value(uint64 cost, int approx = 0) 1754const char *cost_string_from_value(uint64 cost, int approx = 0)
1742 1755
1743int 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
1751int 1756int
1752exp_to_level (val64 exp) 1757exp_to_level (val64 exp)
1753 CODE: 1758 CODE:
1754{ 1759{
1755 int i = 0; 1760 int i = 0;
1794 CODE: 1799 CODE:
1795 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1800 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1796 OUTPUT: 1801 OUTPUT:
1797 RETVAL 1802 RETVAL
1798 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
1813
1799MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1814MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1800 1815
1801INCLUDE: $PERL genacc object ../include/object.h | 1816INCLUDE: $PERL genacc object ../include/object.h |
1802 1817
1803int invoke (object *op, int event, ...) 1818int invoke (object *op, int event, ...)
1851 PROTOTYPE: $ 1866 PROTOTYPE: $
1852 PPCODE: 1867 PPCODE:
1853{ 1868{
1854 object *o; 1869 object *o;
1855 for (o = obj->inv; o; o = o->below) 1870 for (o = obj->inv; o; o = o->below)
1856 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1871 XPUSHs (sv_2mortal (to_sv (o)));
1857} 1872}
1873
1874void
1875set_animation (object *op, int idx)
1876 CODE:
1877 SET_ANIMATION (op, idx);
1878
1879void
1880object::drain_stat ()
1881
1882void
1883object::drain_specific_stat (int stat)
1884
1885void
1886object::change_luck (int change)
1887
1888void
1889object::add_statbonus ()
1890
1891void
1892object::remove_statbonus ()
1858 1893
1859object *find_best_object_match (object *op, const char *match) 1894object *find_best_object_match (object *op, const char *match)
1860 1895
1861object *find_marked_object (object *op) 1896object *find_marked_object (object *op)
1862 1897
1963 1998
1964object *cf_object_insert_in_ob (object *ob, object *where) 1999object *cf_object_insert_in_ob (object *ob, object *where)
1965 2000
1966int cf_object_teleport (object *op, maptile *map, int x, int y) 2001int cf_object_teleport (object *op, maptile *map, int x, int y)
1967 2002
1968void update (object *op, int action) 2003void update_object (object *op, int action)
1969 CODE:
1970 update_object (op, action);
1971 2004
1972object *cf_create_object_by_name (const char *name) 2005object *cf_create_object_by_name (const char *name)
1973 2006
1974void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) 2007void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0)
1975 2008
1987 2020
1988void remove_button_link (object *op); 2021void remove_button_link (object *op);
1989 2022
1990 2023
1991MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2024MODULE = cf PACKAGE = cf::object PREFIX = cf_
1992
1993void cf_fix_object (object *pl)
1994 ALIAS: fix = 0
1995 2025
1996object *cf_insert_ob_in_ob (object *ob, object *where) 2026object *cf_insert_ob_in_ob (object *ob, object *where)
1997 2027
1998# no clean way to get an object from an archetype - stupid idiotic 2028# no clean way to get an object from an archetype - stupid idiotic
1999# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2029# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2022 2052
2023player *contr (object *op) 2053player *contr (object *op)
2024 CODE: 2054 CODE:
2025 RETVAL = op->contr; 2055 RETVAL = op->contr;
2026 OUTPUT: RETVAL 2056 OUTPUT: RETVAL
2057
2058void
2059object::roll_stats ()
2060
2061void
2062object::update_stats ()
2063
2064void
2065object::swap_stats (int a, int b)
2027 2066
2028const char *get_ob_key_value (object *op, const char *key) 2067const char *get_ob_key_value (object *op, const char *key)
2029 2068
2030bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) 2069bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1)
2031 2070
2117 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); 2156 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av));
2118 OUTPUT: RETVAL 2157 OUTPUT: RETVAL
2119 2158
2120SV *registry (player *pl) 2159SV *registry (player *pl)
2121 2160
2161player *
2162create ()
2163 CODE:
2164 RETVAL = player::create ();
2165 OUTPUT:
2166 RETVAL
2167
2168player *
2169load (const char *path)
2170 CODE:
2171 RETVAL = player::load (path);
2172 OUTPUT:
2173 RETVAL
2174
2175void
2176player::save (bool final = false)
2177
2178void
2179player::connect (client *ns)
2180
2181void
2182save_stats (player *pl)
2183 CODE:
2184 pl->ob->stats.hp = pl->ob->stats.maxhp;
2185 pl->ob->stats.sp = pl->ob->stats.maxsp;
2186 pl->ob->stats.grace = pl->ob->stats.maxgrace;
2187 pl->orig_stats = pl->ob->stats;
2188
2122player *cf_player_find (char *name) 2189player *cf_player_find (char *name)
2123 PROTOTYPE: $ 2190 PROTOTYPE: $
2124 2191
2125void cf_player_move (player *pl, int dir) 2192void cf_player_move (player *pl, int dir)
2126 2193
2129player *first () 2196player *first ()
2130 CODE: 2197 CODE:
2131 RETVAL = first_player; 2198 RETVAL = first_player;
2132 OUTPUT: RETVAL 2199 OUTPUT: RETVAL
2133 2200
2134player *next (player *pl)
2135 CODE:
2136 RETVAL = pl->next;
2137 OUTPUT: RETVAL
2138
2139bool 2201bool
2140cell_visible (player *pl, int dx, int dy) 2202cell_visible (player *pl, int dx, int dy)
2141 CODE: 2203 CODE:
2142 RETVAL = FABS (dx) <= pl->socket->mapx / 2 && FABS (dy) <= pl->socket->mapy / 2 2204 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]; 2205 && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2];
2144 OUTPUT: 2206 OUTPUT:
2145 RETVAL 2207 RETVAL
2146 2208
2147void 2209void
2148send (player *pl, SV *packet) 2210send (player *pl, SV *packet)
2149 CODE: 2211 CODE:
2150{ 2212{
2151 STRLEN len; 2213 STRLEN len;
2152 char *buf = SvPVbyte (packet, len); 2214 char *buf = SvPVbyte (packet, len);
2153 2215
2216 if (pl->ns)
2154 pl->socket->send_packet (buf, len); 2217 pl->ns->send_packet (buf, len);
2155} 2218}
2156 2219
2157int 2220int
2158listening (player *pl, int new_value = -1) 2221listening (player *pl, int new_value = -1)
2159 CODE: 2222 CODE:
2178 if (y) sv_to (y, pl->bed_y); 2241 if (y) sv_to (y, pl->bed_y);
2179 2242
2180void 2243void
2181list () 2244list ()
2182 PPCODE: 2245 PPCODE:
2183{
2184 player *pl;
2185 for (pl = first_player; pl; pl = pl->next) 2246 for (player *pl = first_player; pl; pl = pl->next)
2186 XPUSHs (newSVcfapi (CFAPI_PPLAYER, pl)); 2247 XPUSHs (sv_2mortal (to_sv (pl)));
2187}
2188 2248
2189bool 2249bool
2190peaceful (player *pl, bool new_setting = 0) 2250peaceful (player *pl, bool new_setting = 0)
2191 PROTOTYPE: $;$ 2251 PROTOTYPE: $;$
2192 CODE: 2252 CODE:
2454 RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av)); 2514 RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av));
2455 OUTPUT: RETVAL 2515 OUTPUT: RETVAL
2456 2516
2457SV *registry (client *ns) 2517SV *registry (client *ns)
2458 2518
2519void
2520list ()
2521 PPCODE:
2522 EXTEND (SP, clients.size ());
2523 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
2524 PUSHs (sv_2mortal (to_sv (*i)));
2525
2459client * 2526client *
2460create (int fd, const char *peername) 2527create (int fd, const char *peername)
2461 CODE: 2528 CODE:
2462 RETVAL = client::create (fd, peername); 2529 RETVAL = client::create (fd, peername);
2463 OUTPUT: 2530 OUTPUT:
2464 RETVAL 2531 RETVAL
2465 2532
2466void 2533void
2534client::send_packet (SV *packet)
2535 CODE:
2536{
2537 STRLEN len;
2538 char *buf = SvPVbyte (packet, len);
2539
2540 THIS->send_packet (buf, len);
2541}
2542
2543void
2467client::destroy () 2544client::destroy ()
2468 2545

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines