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.253 by root, Mon Sep 10 17:24:36 2007 UTC vs.
Revision 1.262 by root, Tue Oct 16 06:15:10 2007 UTC

30 30
31#if HAVE_EXECINFO_H 31#if HAVE_EXECINFO_H
32# include <execinfo.h> 32# include <execinfo.h>
33#endif 33#endif
34 34
35#include <plugin_common.h>
36#include <sounds.h>
37#include <cstdarg> 35#include <cstdarg>
36
37#include "global.h"
38#include "loader.h"
39#include "../random_maps/random_map.h"
38#include <sproto.h> 40#include <sproto.h>
39
40#include "loader.h"
41#include "cfperl.h"
42#include "shstr.h"
43 41
44#include <unistd.h> 42#include <unistd.h>
45#if _POSIX_MEMLOCK 43#if _POSIX_MEMLOCK
46# include <sys/mman.h> 44# include <sys/mman.h>
45#endif
46
47#if HAVE_MALLOC_H
48# include <malloc.h>
47#endif 49#endif
48 50
49#include <EXTERN.h> 51#include <EXTERN.h>
50#include <perl.h> 52#include <perl.h>
51#include <XSUB.h> 53#include <XSUB.h>
67#else 69#else
68 typedef double val64; 70 typedef double val64;
69# define newSVval64 newSVnv 71# define newSVval64 newSVnv
70# define SvVAL64 SvNV 72# define SvVAL64 SvNV
71#endif 73#endif
72
73static f_plug_api gethook = cfapi_get_hooks;
74static f_plug_api object_insert = cfapi_object_insert;
75 74
76static PerlInterpreter *perl; 75static PerlInterpreter *perl;
77 76
78tstamp NOW, runtime; 77tstamp NOW, runtime;
79 78
590 va_end (ap); 589 va_end (ap);
591 590
592 return sv; 591 return sv;
593} 592}
594 593
595static SV *
596newSVcfapi (int type, ...)
597{
598 SV *sv;
599
600 va_list ap;
601 va_start (ap, type);
602
603 switch (type)
604 {
605 case CFAPI_INT: sv = newSViv (*va_arg (ap, int * )); break;
606 case CFAPI_LONG: sv = newSVval64 (*va_arg (ap, sint64 *)); break;
607 case CFAPI_DOUBLE: sv = newSVnv (*va_arg (ap, double *)); break;
608 case CFAPI_STRING: sv = newSVdt_va (ap, DT_STRING); break;
609 case CFAPI_POBJECT: sv = newSVdt_va (ap, DT_OBJECT); break;
610 case CFAPI_PMAP: sv = newSVdt_va (ap, DT_MAP ); break;
611 case CFAPI_PPLAYER: sv = newSVdt_va (ap, DT_PLAYER); break;
612 case CFAPI_PARCH: sv = newSVdt_va (ap, DT_ARCH ); break;
613 case CFAPI_PPARTY: sv = newSVdt_va (ap, DT_PARTY ); break;
614 case CFAPI_PREGION: sv = newSVdt_va (ap, DT_REGION); break;
615
616 default:
617 assert (("unhandled type in newSVcfapi", 0));
618 }
619
620 va_end (ap);
621
622 return sv;
623}
624
625////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 594//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
626 595
627SV * 596SV *
628registry (attachable *ext) 597registry (attachable *ext)
629{ 598{
632 601
633 return newRV_inc ((SV *)ext->cb); 602 return newRV_inc ((SV *)ext->cb);
634} 603}
635 604
636///////////////////////////////////////////////////////////////////////////// 605/////////////////////////////////////////////////////////////////////////////
637
638extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr)
639{
640 return 0;
641}
642
643static CommArray_s rtn_cmd;
644
645static int
646runPluginCommand (object *obj, char *params)
647{
648 return -1;
649}
650
651extern "C" void *cfperl_getPluginProperty (int *type, ...)
652{
653 va_list args;
654 char *propname;
655 int i;
656 va_start (args, type);
657 propname = va_arg (args, char *);
658 //printf ("Property name: %s\n", propname);
659
660 if (!strcmp (propname, "command?"))
661 return NULL;
662 else if (!strcmp (propname, "Identification"))
663 {
664 va_end (args);
665 return (void *)PLUGIN_NAME;
666 }
667 else if (!strcmp (propname, "FullName"))
668 {
669 va_end (args);
670 return (void *)PLUGIN_VERSION;
671 }
672 else
673 va_end (args);
674
675 return NULL;
676}
677
678extern "C" int cfperl_postInitPlugin ()
679{
680 int hooktype = 1;
681 int rtype = 0;
682
683 cf_init_plugin (gethook);
684
685 return 0;
686}
687
688extern "C" int cfperl_closePlugin ()
689{
690 return 0;
691}
692 606
693void 607void
694cfperl_init () 608cfperl_init ()
695{ 609{
696 PERL_SYS_INIT3 (&settings.argc, &settings.argv, 0); 610 PERL_SYS_INIT3 (&settings.argc, &settings.argv, 0);
1352 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1266 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd)
1353 1267
1354 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1268 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1355 1269
1356 const_iv (MAX_TIME) 1270 const_iv (MAX_TIME)
1271 const_iv (MAXSOCKBUF)
1357 1272
1358 const_iv (NUM_BODY_LOCATIONS) 1273 const_iv (NUM_BODY_LOCATIONS)
1359 const_iv (body_range) const_iv (body_shield) const_iv (body_combat) 1274 const_iv (body_range) const_iv (body_shield) const_iv (body_combat)
1360 const_iv (body_arm) const_iv (body_torso) const_iv (body_head) 1275 const_iv (body_arm) const_iv (body_torso) const_iv (body_head)
1361 const_iv (body_neck) const_iv (body_skill) const_iv (body_finger) 1276 const_iv (body_neck) const_iv (body_skill) const_iv (body_finger)
1506 const_iv (P_NO_CLERIC) const_iv (P_OUT_OF_MAP) const_iv (P_NEW_MAP) const_iv (P_UPTODATE) 1421 const_iv (P_NO_CLERIC) const_iv (P_OUT_OF_MAP) const_iv (P_NEW_MAP) const_iv (P_UPTODATE)
1507 1422
1508 const_iv (UP_OBJ_INSERT) const_iv (UP_OBJ_REMOVE) const_iv (UP_OBJ_CHANGE) const_iv (UP_OBJ_FACE) 1423 const_iv (UP_OBJ_INSERT) const_iv (UP_OBJ_REMOVE) const_iv (UP_OBJ_CHANGE) const_iv (UP_OBJ_FACE)
1509 1424
1510 const_iv (INS_NO_MERGE) const_iv (INS_ABOVE_FLOOR_ONLY) const_iv (INS_NO_WALK_ON) 1425 const_iv (INS_NO_MERGE) const_iv (INS_ABOVE_FLOOR_ONLY) const_iv (INS_NO_WALK_ON)
1511 const_iv (INS_ON_TOP) const_iv (INS_BELOW_ORIGINATOR) const_iv (INS_MAP_LOAD) 1426 const_iv (INS_ON_TOP) const_iv (INS_BELOW_ORIGINATOR)
1512 1427
1513 const_iv (WILL_APPLY_HANDLE) const_iv (WILL_APPLY_TREASURE) const_iv (WILL_APPLY_EARTHWALL) 1428 const_iv (WILL_APPLY_HANDLE) const_iv (WILL_APPLY_TREASURE) const_iv (WILL_APPLY_EARTHWALL)
1514 const_iv (WILL_APPLY_DOOR) const_iv (WILL_APPLY_FOOD) 1429 const_iv (WILL_APPLY_DOOR) const_iv (WILL_APPLY_FOOD)
1515 1430
1516 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) 1431 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE)
1732octet_string path_combine (octet_string base, octet_string path) 1647octet_string path_combine (octet_string base, octet_string path)
1733 PROTOTYPE: $$ 1648 PROTOTYPE: $$
1734 1649
1735octet_string path_combine_and_normalize (octet_string base, octet_string path) 1650octet_string path_combine_and_normalize (octet_string base, octet_string path)
1736 PROTOTYPE: $$ 1651 PROTOTYPE: $$
1652
1653int
1654malloc_trim (U32 pad = 0)
1655 CODE:
1656#if __GLIBC__
1657 RETVAL = malloc_trim (pad);
1658#else
1659 RETVAL = 0;
1660#endif
1661 OUTPUT:
1662 RETVAL
1663
1664void
1665mallinfo ()
1666 PPCODE:
1667{
1668#if __GLIBC__
1669 struct mallinfo mai = mallinfo ();
1670 EXTEND (SP, 10*2);
1671 PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena)));
1672 PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks)));
1673 PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks)));
1674 PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks)));
1675 PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd)));
1676 PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks)));
1677 PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks)));
1678 PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks)));
1679 PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks)));
1680 PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost)));
1681#endif
1682 EXTEND (SP, 2*2);
1683 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc)));
1684 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc)));
1685}
1737 1686
1738void 1687void
1739sub_generation_inc () 1688sub_generation_inc ()
1740 CODE: 1689 CODE:
1741 PL_sub_generation++; 1690 PL_sub_generation++;
1939void 1888void
1940inv (object *obj) 1889inv (object *obj)
1941 PROTOTYPE: $ 1890 PROTOTYPE: $
1942 PPCODE: 1891 PPCODE:
1943{ 1892{
1944 object *o;
1945 for (o = obj->inv; o; o = o->below) 1893 for (object *o = obj->inv; o; o = o->below)
1946 XPUSHs (sv_2mortal (to_sv (o))); 1894 XPUSHs (sv_2mortal (to_sv (o)));
1947} 1895}
1948 1896
1949void 1897void
1950set_animation (object *op, int idx) 1898set_animation (object *op, int idx)
1982 1930
1983int need_identify (object *obj); 1931int need_identify (object *obj);
1984 1932
1985int apply_shop_mat (object *shop_mat, object *op); 1933int apply_shop_mat (object *shop_mat, object *op);
1986 1934
1987int move_player (object *op, int dir)
1988 CODE:
1989 RETVAL = move_player (op, dir);
1990 OUTPUT:
1991 RETVAL
1992
1993int move (object *op, int dir, object *originator = op) 1935int move (object *op, int dir, object *originator = op)
1994 CODE: 1936 CODE:
1995 RETVAL = move_ob (op, dir, originator); 1937 RETVAL = move_ob (op, dir, originator);
1996 OUTPUT: 1938 OUTPUT:
1997 RETVAL 1939 RETVAL
2003void apply_below (object *op) 1945void apply_below (object *op)
2004 CODE: 1946 CODE:
2005 player_apply_below (op); 1947 player_apply_below (op);
2006 1948
2007int cast_heal (object *op, object *caster, object *spell, int dir = 0) 1949int cast_heal (object *op, object *caster, object *spell, int dir = 0)
2008
2009object *cf_object_present_archname_inside (object *op, utf8_string whatstr)
2010
2011int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0)
2012
2013int cf_object_change_map (object *op, int x, int y, maptile *map)
2014 1950
2015#//TODO 1951#//TODO
2016object *clone_ (object *op, int recursive = 0) 1952object *clone_ (object *op, int recursive = 0)
2017 CODE: 1953 CODE:
2018 if (recursive) 1954 if (recursive)
2065 2001
2066void drop (object *who, object *op) 2002void drop (object *who, object *op)
2067 2003
2068void pick_up (object *who, object *op) 2004void pick_up (object *who, object *op)
2069 2005
2070int cf_object_teleport (object *op, maptile *map, int x, int y)
2071
2072void update_object (object *op, int action) 2006void update_object (object *op, int action)
2073 2007
2074object *cf_create_object_by_name (utf8_string name)
2075
2076void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) 2008void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0)
2077 2009
2078void player_lvl_adj (object *who, object *skill = 0) 2010void player_lvl_adj (object *who, object *skill = 0)
2079 2011
2080int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 2012int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
2091 2023
2092void handle_apply_yield (object *op); 2024void handle_apply_yield (object *op);
2093 2025
2094 2026
2095MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2027MODULE = cf PACKAGE = cf::object PREFIX = cf_
2096
2097object *cf_insert_ob_in_ob (object *ob, object *where)
2098 2028
2099# no clean way to get an object from an archetype - stupid idiotic 2029# no clean way to get an object from an archetype - stupid idiotic
2100# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2030# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2101 2031
2102object *new (utf8_string archetype = 0) 2032object *new (utf8_string archetype = 0)
2111# TODO: nuke 2041# TODO: nuke
2112object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) 2042object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y)
2113 PROTOTYPE: $$$$$$ 2043 PROTOTYPE: $$$$$$
2114 CODE: 2044 CODE:
2115{ 2045{
2116 int unused_type; 2046 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2117 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y);
2118} 2047}
2119 2048
2120const_utf8_string get_ob_key_value (object *op, utf8_string key) 2049const_utf8_string get_ob_key_value (object *op, utf8_string key)
2121 2050
2122bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) 2051bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1)
2135 EXTEND (SP, 5); 2064 EXTEND (SP, 5);
2136 PUSHs (newSVuv (rv.distance)); 2065 PUSHs (newSVuv (rv.distance));
2137 PUSHs (newSViv (rv.distance_x)); 2066 PUSHs (newSViv (rv.distance_x));
2138 PUSHs (newSViv (rv.distance_y)); 2067 PUSHs (newSViv (rv.distance_y));
2139 PUSHs (newSViv (rv.direction)); 2068 PUSHs (newSViv (rv.direction));
2140 PUSHs (newSVcfapi (CFAPI_POBJECT, rv.part)); 2069 PUSHs (to_sv (rv.part));
2141} 2070}
2142 2071
2143bool on_same_map_as (object *ob, object *other) 2072bool on_same_map_as (object *ob, object *other)
2144 CODE: 2073 CODE:
2145 RETVAL = on_same_map (ob, other); 2074 RETVAL = on_same_map (ob, other);
2151 RETVAL = query_base_name (op, plural); 2080 RETVAL = query_base_name (op, plural);
2152 OUTPUT: RETVAL 2081 OUTPUT: RETVAL
2153 2082
2154object *decrease_ob_nr (object *op, unsigned long i) 2083object *decrease_ob_nr (object *op, unsigned long i)
2155 2084
2085# return the tail of an object, excluding itself
2086void
2087tail (object *op)
2088 PPCODE:
2089 while ((op = op->more))
2090 XPUSHs (sv_2mortal (to_sv (op)));
2091
2156MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 2092MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
2157 2093
2158player *player (object *op) 2094player *player (object *op)
2159 CODE: 2095 CODE:
2160 RETVAL = op->contr; 2096 RETVAL = op->contr;
2161 OUTPUT: RETVAL 2097 OUTPUT: RETVAL
2162 2098
2099bool move_player (object *op, int dir)
2100
2163void check_score (object *op) 2101void check_score (object *op)
2164 2102
2165void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE) 2103void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE)
2166 CODE: 2104 CODE:
2167 new_draw_info (flags, 0, op, txt); 2105 new_draw_info (flags, 0, op, txt);
2168 2106
2169void kill_player (object *op) 2107void kill_player (object *op)
2170 2108
2109void esrv_send_item (object *pl, object *item)
2110
2171void esrv_update_item (object *op, int what, object *item) 2111void esrv_update_item (object *pl, int what, object *item)
2172 C_ARGS: what, op, item 2112 C_ARGS: what, pl, item
2113
2114void esrv_del_item (object *pl, int tag)
2115 C_ARGS: pl->contr, tag
2173 2116
2174int command_summon (object *op, utf8_string params) 2117int command_summon (object *op, utf8_string params)
2175 2118
2176int command_arrest (object *op, utf8_string params) 2119int command_arrest (object *op, utf8_string params)
2177 2120
2198 pl->ob->stats.grace = pl->ob->stats.maxgrace; 2141 pl->ob->stats.grace = pl->ob->stats.maxgrace;
2199 pl->orig_stats = pl->ob->stats; 2142 pl->orig_stats = pl->ob->stats;
2200 2143
2201void clear_los (player *pl) 2144void clear_los (player *pl)
2202 2145
2203void cf_player_move (player *pl, int dir)
2204
2205bool 2146bool
2206cell_visible (player *pl, int dx, int dy) 2147cell_visible (player *pl, int dx, int dy)
2207 CODE: 2148 CODE:
2208 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 2149 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2
2209 && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]; 2150 && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2];
2215 CODE: 2156 CODE:
2216{ 2157{
2217 STRLEN len; 2158 STRLEN len;
2218 char *buf = SvPVbyte (packet, len); 2159 char *buf = SvPVbyte (packet, len);
2219 2160
2161 if (len > MAXSOCKBUF)
2162 pl->failmsg ("[packet too long for client]");
2220 if (pl->ns) 2163 else if (pl->ns)
2221 pl->ns->send_packet (buf, len); 2164 pl->ns->send_packet (buf, len);
2222} 2165}
2223 2166
2224int 2167int
2225listening (player *pl, int new_value = -1) 2168listening (player *pl, int new_value = -1)
2261 RETVAL = map->invoke ((event_type)event, ARG_AV (av), DT_END); 2204 RETVAL = map->invoke ((event_type)event, ARG_AV (av), DT_END);
2262 OUTPUT: RETVAL 2205 OUTPUT: RETVAL
2263 2206
2264SV *registry (maptile *map) 2207SV *registry (maptile *map)
2265 2208
2209void
2210find_tagged_objects (maptile *map, utf8_string tag = 0)
2211 PPCODE:
2212{
2213 if (!map->spaces)
2214 XSRETURN_EMPTY;
2215
2216 if (tag)
2217 {
2218 shstr_cmp tag_ (tag);
2219
2220 for (mapspace *ms = map->spaces + map->size (); ms-- > map->spaces; )
2221 for (object *op = ms->bot; op; op = op->above)
2222 if (op->tag == tag_)
2223 XPUSHs (sv_2mortal (to_sv (op)));
2224 }
2225 else
2226 {
2227 for (mapspace *ms = map->spaces + map->size (); ms-- > map->spaces; )
2228 for (object *op = ms->bot; op; op = op->above)
2229 if (op->tag)
2230 XPUSHs (sv_2mortal (to_sv (op)));
2231 }
2232}
2233
2266INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h | 2234INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h |
2267 2235
2268void 2236void
2269maptile::instantiate () 2237maptile::instantiate ()
2270 2238
2401get_connection (maptile *map, long connection) 2369get_connection (maptile *map, long connection)
2402 PPCODE: 2370 PPCODE:
2403 oblinkpt *obp = get_connection_links (map, connection); 2371 oblinkpt *obp = get_connection_links (map, connection);
2404 if (obp) 2372 if (obp)
2405 for (objectlink *ol = obp->link; ol; ol = ol->next) 2373 for (objectlink *ol = obp->link; ol; ol = ol->next)
2406 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, (object *)ol->ob))); 2374 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob)));
2407
2408object *cf_map_insert_object_there (maptile *where, object *op, object *originator, int flags)
2409
2410object *cf_map_insert_object (maptile *where, object* op, int x, int y)
2411
2412object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny)
2413 C_ARGS: str, map, nx, ny
2414 2375
2415void 2376void
2416get_map_flags (maptile *map, int x, int y) 2377get_map_flags (maptile *map, int x, int y)
2417 PPCODE: 2378 PPCODE:
2418{ 2379{
2423 EXTEND (SP, 4); 2384 EXTEND (SP, 4);
2424 PUSHs (sv_2mortal (newSViv (flags))); 2385 PUSHs (sv_2mortal (newSViv (flags)));
2425 2386
2426 if (GIMME_V == G_ARRAY) 2387 if (GIMME_V == G_ARRAY)
2427 { 2388 {
2428 PUSHs (sv_2mortal (newSVcfapi (CFAPI_PMAP, nmap))); 2389 PUSHs (sv_2mortal (to_sv (nmap)));
2429 PUSHs (sv_2mortal (newSViv (nx))); 2390 PUSHs (sv_2mortal (newSViv (nx)));
2430 PUSHs (sv_2mortal (newSViv (ny))); 2391 PUSHs (sv_2mortal (newSViv (ny)));
2431 } 2392 }
2432} 2393}
2433 2394
2442 2403
2443 get_map_flags (map, &nmap, x, y, &nx, &ny); 2404 get_map_flags (map, &nmap, x, y, &nx, &ny);
2444 2405
2445 if (nmap) 2406 if (nmap)
2446 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) 2407 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above)
2447 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 2408 XPUSHs (sv_2mortal (to_sv (o)));
2448} 2409}
2449 2410
2450SV * 2411SV *
2451bot_at (maptile *obj, unsigned int x, unsigned int y) 2412bot_at (maptile *obj, unsigned int x, unsigned int y)
2452 PROTOTYPE: $$$ 2413 PROTOTYPE: $$$
2461 INIT: 2422 INIT:
2462 if (x >= obj->width || y >= obj->height) XSRETURN_UNDEF; 2423 if (x >= obj->width || y >= obj->height) XSRETURN_UNDEF;
2463 CODE: 2424 CODE:
2464 switch (ix) 2425 switch (ix)
2465 { 2426 {
2466 case 0: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_OB (obj, x, y)); break; 2427 case 0: RETVAL = to_sv (GET_MAP_OB (obj, x, y)); break;
2467 case 1: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_TOP (obj, x, y)); break; 2428 case 1: RETVAL = to_sv (GET_MAP_TOP (obj, x, y)); break;
2468 case 2: RETVAL = newSVuv ( GET_MAP_FLAGS (obj, x, y)); break; 2429 case 2: RETVAL = newSVuv (GET_MAP_FLAGS (obj, x, y)); break;
2469 case 3: RETVAL = newSViv ( GET_MAP_LIGHT (obj, x, y)); break; 2430 case 3: RETVAL = newSViv (GET_MAP_LIGHT (obj, x, y)); break;
2470 case 4: RETVAL = newSVuv ( GET_MAP_MOVE_BLOCK (obj, x, y)); break; 2431 case 4: RETVAL = newSVuv (GET_MAP_MOVE_BLOCK (obj, x, y)); break;
2471 case 5: RETVAL = newSVuv ( GET_MAP_MOVE_SLOW (obj, x, y)); break; 2432 case 5: RETVAL = newSVuv (GET_MAP_MOVE_SLOW (obj, x, y)); break;
2472 case 6: RETVAL = newSVuv ( GET_MAP_MOVE_ON (obj, x, y)); break; 2433 case 6: RETVAL = newSVuv (GET_MAP_MOVE_ON (obj, x, y)); break;
2473 case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; 2434 case 7: RETVAL = newSVuv (GET_MAP_MOVE_OFF (obj, x, y)); break;
2474 } 2435 }
2475 OUTPUT: RETVAL 2436 OUTPUT: RETVAL
2476 2437
2477void fix_walls (maptile *map, int x, int y) 2438void fix_walls (maptile *map, int x, int y)
2478 2439
2659 CODE: 2620 CODE:
2660{ 2621{
2661 STRLEN len; 2622 STRLEN len;
2662 char *buf = SvPVbyte (packet, len); 2623 char *buf = SvPVbyte (packet, len);
2663 2624
2625 if (len > MAXSOCKBUF)
2626 {
2627 // ugly
2628 if (THIS->pl)
2629 THIS->pl->failmsg ("[packet too long for client]");
2630 }
2631 else
2664 THIS->send_packet (buf, len); 2632 THIS->send_packet (buf, len);
2665} 2633}
2666 2634
2667faceidx 2635faceidx
2668client::need_face (utf8_string name, int pri = 0) 2636client::need_face (utf8_string name, int pri = 0)
2669 CODE: 2637 CODE:
2874 sv_to (sv, self); 2842 sv_to (sv, self);
2875 delete self; 2843 delete self;
2876 2844
2877void 2845void
2878extract_tags (object_thawer *self) 2846extract_tags (object_thawer *self)
2879 CODE: 2847 PPCODE:
2880 while (self->kw != KW_EOF) 2848 while (self->kw != KW_EOF)
2881 { 2849 {
2850 PUTBACK;
2882 coroapi::cede_to_tick_every (5000); 2851 coroapi::cede_to_tick_every (5000);
2852 SPAGAIN;
2883 2853
2884 if (self->kw == KW_tag) 2854 if (self->kw == KW_tag)
2885 XPUSHs (sv_2mortal (to_sv (self->get_str ()))); 2855 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ())));
2886 2856
2887 self->skip (); 2857 self->skip ();
2888 } 2858 }
2889 2859

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines