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.100 by root, Fri Dec 22 02:04:21 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>
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;
1410 const_iv (FLAG_ACTIVATE_ON_RELEASE) 1418 const_iv (FLAG_ACTIVATE_ON_RELEASE)
1411 const_iv (FLAG_IS_WATER) 1419 const_iv (FLAG_IS_WATER)
1412 const_iv (FLAG_CONTENT_ON_GEN) 1420 const_iv (FLAG_CONTENT_ON_GEN)
1413 const_iv (FLAG_IS_A_TEMPLATE) 1421 const_iv (FLAG_IS_A_TEMPLATE)
1414 const_iv (FLAG_IS_BUILDABLE) 1422 const_iv (FLAG_IS_BUILDABLE)
1415 const_iv (FLAG_AFK)
1416 1423
1417 const_iv (NDI_BLACK) 1424 const_iv (NDI_BLACK)
1418 const_iv (NDI_WHITE) 1425 const_iv (NDI_WHITE)
1419 const_iv (NDI_NAVY) 1426 const_iv (NDI_NAVY)
1420 const_iv (NDI_RED) 1427 const_iv (NDI_RED)
1631 const_iv (ST_DEAD) 1638 const_iv (ST_DEAD)
1632 const_iv (ST_SETUP) 1639 const_iv (ST_SETUP)
1633 const_iv (ST_PLAYING) 1640 const_iv (ST_PLAYING)
1634 const_iv (ST_CUSTOM) 1641 const_iv (ST_CUSTOM)
1635 1642
1636 const_iv (ST_PLAY_AGAIN)
1637 const_iv (ST_ROLL_STAT)
1638 const_iv (ST_CHANGE_CLASS) 1643 const_iv (ST_CHANGE_CLASS)
1639 const_iv (ST_CONFIRM_QUIT) 1644 const_iv (ST_CONFIRM_QUIT)
1640 const_iv (ST_CONFIGURE)
1641 const_iv (ST_GET_NAME)
1642 const_iv (ST_GET_PASSWORD)
1643 const_iv (ST_CONFIRM_PASSWORD)
1644 const_iv (ST_GET_PARTY_PASSWORD) 1645 const_iv (ST_GET_PARTY_PASSWORD)
1645 }; 1646 };
1646 1647
1647 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; )
1648 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1649 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1757 1758
1758int random_roll (int min, int max, object *op, int goodbad); 1759int random_roll (int min, int max, object *op, int goodbad);
1759 1760
1760const char *cost_string_from_value(uint64 cost, int approx = 0) 1761const char *cost_string_from_value(uint64 cost, int approx = 0)
1761 1762
1762int invoke (int event, ...)
1763 CODE:
1764 if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL");
1765 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1766 for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1767 RETVAL = INVOKE_((event_type)event, ARG_AV (av));
1768 OUTPUT: RETVAL
1769
1770int 1763int
1771exp_to_level (val64 exp) 1764exp_to_level (val64 exp)
1772 CODE: 1765 CODE:
1773{ 1766{
1774 int i = 0; 1767 int i = 0;
1813 CODE: 1806 CODE:
1814 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1807 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1815 OUTPUT: 1808 OUTPUT:
1816 RETVAL 1809 RETVAL
1817 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
1820
1818MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1821MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1819 1822
1820INCLUDE: $PERL genacc object ../include/object.h | 1823INCLUDE: $PERL genacc object ../include/object.h |
1821 1824
1822int invoke (object *op, int event, ...) 1825int invoke (object *op, int event, ...)
1840 RETVAL = object::first; 1843 RETVAL = object::first;
1841 OUTPUT: RETVAL 1844 OUTPUT: RETVAL
1842 1845
1843# missing properties 1846# missing properties
1844 1847
1845int flag (object *op, int flag, int value = 1)
1846 PROTOTYPE: $$;$
1847 CODE:
1848 RETVAL = QUERY_FLAG (op, flag);
1849 if (items >= 3)
1850 if (value)
1851 SET_FLAG (op, flag);
1852 else
1853 CLEAR_FLAG (op, flag);
1854 OUTPUT: RETVAL
1855
1856object *head (object *op) 1848object *head (object *op)
1857 PROTOTYPE: $ 1849 PROTOTYPE: $
1858 CODE: 1850 CODE:
1859 RETVAL = op->head ? op->head : op; 1851 RETVAL = op->head ? op->head : op;
1860 OUTPUT: RETVAL 1852 OUTPUT: RETVAL
1873 object *o; 1865 object *o;
1874 for (o = obj->inv; o; o = o->below) 1866 for (o = obj->inv; o; o = o->below)
1875 XPUSHs (sv_2mortal (to_sv (o))); 1867 XPUSHs (sv_2mortal (to_sv (o)));
1876} 1868}
1877 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 ()
1889
1878object *find_best_object_match (object *op, const char *match) 1890object *find_best_object_match (object *op, const char *match)
1879 1891
1880object *find_marked_object (object *op) 1892object *find_marked_object (object *op)
1881
1882int resistance (object *op, int rtype, int newval = 0)
1883 CODE:
1884 if (rtype < 0 || rtype >= NROFATTACKS)
1885 croak ("resistance out of bounds");
1886 RETVAL = op->resist [rtype];
1887 if (items >= 3)
1888 op->resist [rtype] = newval;
1889 OUTPUT: RETVAL
1890
1891void set_resistance (object *op, int rtype, int val)
1892 CODE:
1893 if (rtype < 0 || rtype >= NROFATTACKS)
1894 op->resist[rtype] = val;
1895 1893
1896int need_identify (const object *obj); 1894int need_identify (const object *obj);
1897 1895
1898int apply_shop_mat (object *shop_mat, object *op); 1896int apply_shop_mat (object *shop_mat, object *op);
1899 1897
1982 1980
1983object *cf_object_insert_in_ob (object *ob, object *where) 1981object *cf_object_insert_in_ob (object *ob, object *where)
1984 1982
1985int cf_object_teleport (object *op, maptile *map, int x, int y) 1983int cf_object_teleport (object *op, maptile *map, int x, int y)
1986 1984
1987void update (object *op, int action) 1985void update_object (object *op, int action)
1988 CODE:
1989 update_object (op, action);
1990 1986
1991object *cf_create_object_by_name (const char *name) 1987object *cf_create_object_by_name (const char *name)
1992 1988
1993void 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)
1994 1990
2006 2002
2007void remove_button_link (object *op); 2003void remove_button_link (object *op);
2008 2004
2009 2005
2010MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2006MODULE = cf PACKAGE = cf::object PREFIX = cf_
2011
2012void cf_fix_object (object *pl)
2013 ALIAS: fix = 0
2014 2007
2015object *cf_insert_ob_in_ob (object *ob, object *where) 2008object *cf_insert_ob_in_ob (object *ob, object *where)
2016 2009
2017# 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
2018# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2011# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2041 2034
2042player *contr (object *op) 2035player *contr (object *op)
2043 CODE: 2036 CODE:
2044 RETVAL = op->contr; 2037 RETVAL = op->contr;
2045 OUTPUT: RETVAL 2038 OUTPUT: RETVAL
2039
2040void
2041object::roll_stats ()
2042
2043void
2044object::update_stats ()
2045
2046void
2047object::swap_stats (int a, int b)
2046 2048
2047const char *get_ob_key_value (object *op, const char *key) 2049const char *get_ob_key_value (object *op, const char *key)
2048 2050
2049bool 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)
2050 2052
2085player *player (object *op) 2087player *player (object *op)
2086 CODE: 2088 CODE:
2087 RETVAL = op->contr; 2089 RETVAL = op->contr;
2088 OUTPUT: RETVAL 2090 OUTPUT: RETVAL
2089 2091
2092void check_score (object *op)
2093
2090void 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)
2091 2095
2092object *cf_player_send_inventory (object *op) 2096object *cf_player_send_inventory (object *op)
2093 2097
2094char *cf_player_get_ip (object *op) 2098char *cf_player_get_ip (object *op)
2136 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); 2140 RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av));
2137 OUTPUT: RETVAL 2141 OUTPUT: RETVAL
2138 2142
2139SV *registry (player *pl) 2143SV *registry (player *pl)
2140 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
2141player *cf_player_find (char *name) 2173player *cf_player_find (char *name)
2142 PROTOTYPE: $ 2174 PROTOTYPE: $
2143 2175
2144void cf_player_move (player *pl, int dir) 2176void cf_player_move (player *pl, int dir)
2145 2177
2146void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2178void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
2147 2179
2148player *first () 2180player *first ()
2149 CODE: 2181 CODE:
2150 RETVAL = first_player; 2182 RETVAL = first_player;
2151 OUTPUT: RETVAL
2152
2153player *next (player *pl)
2154 CODE:
2155 RETVAL = pl->next;
2156 OUTPUT: RETVAL 2183 OUTPUT: RETVAL
2157 2184
2158bool 2185bool
2159cell_visible (player *pl, int dx, int dy) 2186cell_visible (player *pl, int dx, int dy)
2160 CODE: 2187 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines