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.104 by root, Sat Dec 23 06:41:39 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, ...)
1824# missing properties 1839# missing properties
1825 1840
1826int flag (object *op, int flag, int value = 1) 1841int flag (object *op, int flag, int value = 1)
1827 PROTOTYPE: $$;$ 1842 PROTOTYPE: $$;$
1828 CODE: 1843 CODE:
1829 RETVAL = QUERY_FLAG (op, flag); 1844 RETVAL = op->flag [flag];
1830 if (items >= 3) 1845 if (items >= 3)
1831 if (value) 1846 op->flag [flag] = value;
1832 SET_FLAG (op, flag);
1833 else
1834 CLEAR_FLAG (op, flag);
1835 OUTPUT: RETVAL 1847 OUTPUT: RETVAL
1836 1848
1837object *head (object *op) 1849object *head (object *op)
1838 PROTOTYPE: $ 1850 PROTOTYPE: $
1839 CODE: 1851 CODE:
1851 PROTOTYPE: $ 1863 PROTOTYPE: $
1852 PPCODE: 1864 PPCODE:
1853{ 1865{
1854 object *o; 1866 object *o;
1855 for (o = obj->inv; o; o = o->below) 1867 for (o = obj->inv; o; o = o->below)
1856 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1868 XPUSHs (sv_2mortal (to_sv (o)));
1857} 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 ()
1858 1890
1859object *find_best_object_match (object *op, const char *match) 1891object *find_best_object_match (object *op, const char *match)
1860 1892
1861object *find_marked_object (object *op) 1893object *find_marked_object (object *op)
1862 1894
1963 1995
1964object *cf_object_insert_in_ob (object *ob, object *where) 1996object *cf_object_insert_in_ob (object *ob, object *where)
1965 1997
1966int cf_object_teleport (object *op, maptile *map, int x, int y) 1998int cf_object_teleport (object *op, maptile *map, int x, int y)
1967 1999
1968void update (object *op, int action) 2000void update_object (object *op, int action)
1969 CODE:
1970 update_object (op, action);
1971 2001
1972object *cf_create_object_by_name (const char *name) 2002object *cf_create_object_by_name (const char *name)
1973 2003
1974void 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)
1975 2005
1987 2017
1988void remove_button_link (object *op); 2018void remove_button_link (object *op);
1989 2019
1990 2020
1991MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2021MODULE = cf PACKAGE = cf::object PREFIX = cf_
1992
1993void cf_fix_object (object *pl)
1994 ALIAS: fix = 0
1995 2022
1996object *cf_insert_ob_in_ob (object *ob, object *where) 2023object *cf_insert_ob_in_ob (object *ob, object *where)
1997 2024
1998# 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
1999# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2026# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2022 2049
2023player *contr (object *op) 2050player *contr (object *op)
2024 CODE: 2051 CODE:
2025 RETVAL = op->contr; 2052 RETVAL = op->contr;
2026 OUTPUT: RETVAL 2053 OUTPUT: RETVAL
2054
2055void
2056object::roll_stats ()
2057
2058void
2059object::update_stats ()
2060
2061void
2062object::swap_stats (int a, int b)
2027 2063
2028const char *get_ob_key_value (object *op, const char *key) 2064const char *get_ob_key_value (object *op, const char *key)
2029 2065
2030bool 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)
2031 2067
2117 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); 2153 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av));
2118 OUTPUT: RETVAL 2154 OUTPUT: RETVAL
2119 2155
2120SV *registry (player *pl) 2156SV *registry (player *pl)
2121 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
2122player *cf_player_find (char *name) 2186player *cf_player_find (char *name)
2123 PROTOTYPE: $ 2187 PROTOTYPE: $
2124 2188
2125void cf_player_move (player *pl, int dir) 2189void cf_player_move (player *pl, int dir)
2126 2190
2129player *first () 2193player *first ()
2130 CODE: 2194 CODE:
2131 RETVAL = first_player; 2195 RETVAL = first_player;
2132 OUTPUT: RETVAL 2196 OUTPUT: RETVAL
2133 2197
2134player *next (player *pl)
2135 CODE:
2136 RETVAL = pl->next;
2137 OUTPUT: RETVAL
2138
2139bool 2198bool
2140cell_visible (player *pl, int dx, int dy) 2199cell_visible (player *pl, int dx, int dy)
2141 CODE: 2200 CODE:
2142 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
2143 && !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];
2144 OUTPUT: 2203 OUTPUT:
2145 RETVAL 2204 RETVAL
2146 2205
2147void 2206void
2148send (player *pl, SV *packet) 2207send (player *pl, SV *packet)
2149 CODE: 2208 CODE:
2150{ 2209{
2151 STRLEN len; 2210 STRLEN len;
2152 char *buf = SvPVbyte (packet, len); 2211 char *buf = SvPVbyte (packet, len);
2153 2212
2213 if (pl->ns)
2154 pl->socket->send_packet (buf, len); 2214 pl->ns->send_packet (buf, len);
2155} 2215}
2156 2216
2157int 2217int
2158listening (player *pl, int new_value = -1) 2218listening (player *pl, int new_value = -1)
2159 CODE: 2219 CODE:
2178 if (y) sv_to (y, pl->bed_y); 2238 if (y) sv_to (y, pl->bed_y);
2179 2239
2180void 2240void
2181list () 2241list ()
2182 PPCODE: 2242 PPCODE:
2183{
2184 player *pl;
2185 for (pl = first_player; pl; pl = pl->next) 2243 for (player *pl = first_player; pl; pl = pl->next)
2186 XPUSHs (newSVcfapi (CFAPI_PPLAYER, pl)); 2244 XPUSHs (sv_2mortal (to_sv (pl)));
2187}
2188 2245
2189bool 2246bool
2190peaceful (player *pl, bool new_setting = 0) 2247peaceful (player *pl, bool new_setting = 0)
2191 PROTOTYPE: $;$ 2248 PROTOTYPE: $;$
2192 CODE: 2249 CODE:
2454 RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av)); 2511 RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av));
2455 OUTPUT: RETVAL 2512 OUTPUT: RETVAL
2456 2513
2457SV *registry (client *ns) 2514SV *registry (client *ns)
2458 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
2459client * 2523client *
2460create (int fd, const char *peername) 2524create (int fd, const char *peername)
2461 CODE: 2525 CODE:
2462 RETVAL = client::create (fd, peername); 2526 RETVAL = client::create (fd, peername);
2463 OUTPUT: 2527 OUTPUT:
2464 RETVAL 2528 RETVAL
2465 2529
2466void 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
2467client::destroy () 2541client::destroy ()
2468 2542

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines