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.55 by root, Tue Sep 12 18:15:34 2006 UTC vs.
Revision 1.63 by root, Mon Oct 2 15:28:36 2006 UTC

40 40
41#include "perlxsi.c" 41#include "perlxsi.c"
42 42
43extern sint64 *levels; // the experience table 43extern sint64 *levels; // the experience table
44 44
45typedef object object_ornull; 45typedef object object_ornull;
46typedef mapstruct mapstruct_ornull; 46typedef maptile maptile_ornull;
47 47
48typedef double val64; 48typedef double val64;
49#define newSVval64 newSVnv 49#define newSVval64 newSVnv
50#define SvVAL64 SvNV 50#define SvVAL64 SvNV
51 51
55 55
56static HV *obj_cache; 56static HV *obj_cache;
57static PerlInterpreter *perl; 57static PerlInterpreter *perl;
58 58
59static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; 59static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map;
60
61#define PUSHcfapi(type,value) PUSHs (sv_2mortal (newSVcfapi (CFAPI_ ## type, (value))))
62#define PUSHcfapi_va(type,ctype) PUSHcfapi (type, va_arg (args, ctype))
63#define PUSH_OB PUSHcfapi_va(POBJECT, object *)
64#define PUSH_PL PUSHcfapi_va(PPLAYER, player *)
65#define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *)
66#define PUSH_PV PUSHcfapi_va(STRING, const char *)
67#define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int))))
68 60
69////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 61//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
70 62
71static SV * 63static SV *
72newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) 64newSVptr (void *ptr, const char *klass, HV *hv = newHV ())
177inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } 169inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
178inline SV *to_sv (float v) { return newSVnv (v); } 170inline SV *to_sv (float v) { return newSVnv (v); }
179inline SV *to_sv (double v) { return newSVnv (v); } 171inline SV *to_sv (double v) { return newSVnv (v); }
180inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } 172inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); }
181inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } 173inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); }
182inline SV *to_sv (mapstruct * v) { return newSVattachable (v, "cf::map::wrap"); } 174inline SV *to_sv (maptile * v) { return newSVattachable (v, "cf::map::wrap"); }
183inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::arch::wrap"); } 175inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::arch::wrap"); }
184inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } 176inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); }
185inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } 177inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); }
186inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } 178inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); }
187 179
190 182
191//TODO: 183//TODO:
192inline SV *to_sv (New_Face * v) { return to_sv (v->name); } 184inline SV *to_sv (New_Face * v) { return to_sv (v->name); }
193inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } 185inline SV *to_sv (treasurelist * v) { return to_sv (v->name); }
194 186
195inline void sv_to (SV *sv, shstr &v) { v = SvPV_nolen (sv); } 187inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; }
196inline void sv_to (SV *sv, char * &v) { free (v); v = strdup (SvPV_nolen (sv)); } //TODO: verify that all simple pointers are strdup-managed 188inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } //TODO: verify that all simple pointers are strdup-managed
197inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } 189inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
198inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 190inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
199inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } 191inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); }
200inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } 192inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); }
201inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } 193inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); }
208inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } 200inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
209inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 201inline void sv_to (SV *sv, double &v) { v = SvNV (sv); }
210inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); } 202inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); }
211inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); } 203inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); }
212inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::arch"); } 204inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::arch"); }
213inline void sv_to (SV *sv, mapstruct * &v) { v = (mapstruct *)SvPTR_ornull (sv, "cf::map"); } 205inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)SvPTR_ornull (sv, "cf::map"); }
214inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 206inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
215inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } 207inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); }
216inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 208inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
217 209
218inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO 210inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO
262 sv = to_sv (va_arg (ap, object *)); 254 sv = to_sv (va_arg (ap, object *));
263 break; 255 break;
264 256
265 case DT_MAP: 257 case DT_MAP:
266 // va_arg (object *) when void * is passed is an XSI extension 258 // va_arg (object *) when void * is passed is an XSI extension
267 sv = to_sv (va_arg (ap, mapstruct *)); 259 sv = to_sv (va_arg (ap, maptile *));
268 break; 260 break;
269 261
270 case DT_PLAYER: 262 case DT_PLAYER:
271 sv = to_sv (va_arg (ap, player *)); 263 sv = to_sv (va_arg (ap, player *));
272 break; 264 break;
349 { 341 {
350 if (cb) 342 if (cb)
351 if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) 343 if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1)))
352 INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); 344 INVOKE_OBJECT (DESTROY, static_cast<object *>(this));
353 else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) 345 else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1)))
354 INVOKE_MAP (DESTROY, static_cast<mapstruct *>(this)); 346 INVOKE_MAP (DESTROY, static_cast<maptile *>(this));
355 347
356 // disconnect Perl from C, to avoid crashes 348 // disconnect Perl from C, to avoid crashes
357 sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); 349 sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext);
358 350
359 // clear the perl hash, might or might not be a good idea 351 // clear the perl hash, might or might not be a good idea
939 931
940 AV *callbacks = 0; 932 AV *callbacks = 0;
941 933
942 object *op; 934 object *op;
943 player *pl; 935 player *pl;
944 mapstruct *map; 936 maptile *map;
945 937
946 // callback call ordering is: 938 // callback call ordering is:
947 // 1. per-object callback (NYI) 939 // 1. per-object callback (NYI)
948 // 2. per-class object 940 // 2. per-class object
949 // 2a. per-type callback 941 // 2a. per-type callback
999 break; 991 break;
1000 992
1001 case KLASS_MAP: 993 case KLASS_MAP:
1002 dt = (data_type) va_arg (ap, int); 994 dt = (data_type) va_arg (ap, int);
1003 assert (("first argument must be of type object", dt == DT_MAP)); 995 assert (("first argument must be of type object", dt == DT_MAP));
1004 map = va_arg (ap, mapstruct *); 996 map = va_arg (ap, maptile *);
1005 997
1006 if (map->cb) 998 if (map->cb)
1007 gather_callbacks (callbacks, map->cb, event); 999 gather_callbacks (callbacks, map->cb, event);
1008 1000
1009 gather_callbacks (callbacks, cb_map, event); 1001 gather_callbacks (callbacks, cb_map, event);
1089MODULE = cf PACKAGE = cf PREFIX = cf_ 1081MODULE = cf PACKAGE = cf PREFIX = cf_
1090 1082
1091BOOT: 1083BOOT:
1092{ 1084{
1093 HV *stash = gv_stashpv ("cf", 1); 1085 HV *stash = gv_stashpv ("cf", 1);
1086
1087 newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1094 1088
1095 static const struct { 1089 static const struct {
1096 const char *name; 1090 const char *name;
1097 IV iv; 1091 IV iv;
1098 } *civ, const_iv[] = { 1092 } *civ, const_iv[] = {
1391 const_iv (NDI_MAX_COLOR) 1385 const_iv (NDI_MAX_COLOR)
1392 const_iv (NDI_COLOR_MASK) 1386 const_iv (NDI_COLOR_MASK)
1393 const_iv (NDI_UNIQUE) 1387 const_iv (NDI_UNIQUE)
1394 const_iv (NDI_ALL) 1388 const_iv (NDI_ALL)
1395 1389
1390 const_iv (UPD_LOCATION)
1391 const_iv (UPD_FLAGS)
1392 const_iv (UPD_WEIGHT)
1393 const_iv (UPD_FACE)
1394 const_iv (UPD_NAME)
1395 const_iv (UPD_ANIM)
1396 const_iv (UPD_ANIMSPEED)
1397 const_iv (UPD_NROF)
1398
1399 const_iv (UPD_SP_MANA)
1400 const_iv (UPD_SP_GRACE)
1401 const_iv (UPD_SP_DAMAGE)
1402
1396 const_iv (F_APPLIED) 1403 const_iv (F_APPLIED)
1397 const_iv (F_LOCATION) 1404 const_iv (F_LOCATION)
1398 const_iv (F_UNPAID) 1405 const_iv (F_UNPAID)
1399 const_iv (F_MAGIC) 1406 const_iv (F_MAGIC)
1400 const_iv (F_CURSED) 1407 const_iv (F_CURSED)
1613{ 1620{
1614 // reattach to all attachable objects in the game. 1621 // reattach to all attachable objects in the game.
1615 for (player *pl = first_player; pl; pl = pl->next) 1622 for (player *pl = first_player; pl; pl = pl->next)
1616 reattach (pl); 1623 reattach (pl);
1617 1624
1618 for (mapstruct *map = first_map; map; map = map->next) 1625 for (maptile *map = first_map; map; map = map->next)
1619 reattach (map); 1626 reattach (map);
1620 1627
1621 for (object *op = objects; op; op = op->next) 1628 for (object *op = object::first; op; op = op->next)
1622 reattach (op); 1629 reattach (op);
1623} 1630}
1624 1631
1625NV floor (NV x) 1632NV floor (NV x)
1626 1633
1674 case 5: RETVAL = settings.playerdir; break; 1681 case 5: RETVAL = settings.playerdir; break;
1675 case 6: RETVAL = settings.datadir ; break; 1682 case 6: RETVAL = settings.datadir ; break;
1676 } 1683 }
1677 OUTPUT: RETVAL 1684 OUTPUT: RETVAL
1678 1685
1679int 1686void _exit (int status = 0)
1687
1680cf_find_animation (char *text) 1688int cf_find_animation (char *text)
1681 PROTOTYPE: $ 1689 PROTOTYPE: $
1682 1690
1683int random_roll(int min, int max, object *op, int goodbad); 1691int random_roll(int min, int max, object *op, int goodbad);
1684 1692
1685const char *cost_string_from_value(uint64 cost, int approx = 0) 1693const char *cost_string_from_value(uint64 cost, int approx = 0)
1738 OUTPUT: 1746 OUTPUT:
1739 RETVAL 1747 RETVAL
1740 1748
1741MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1749MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1742 1750
1751INCLUDE: $PERL genacc object ../include/object.h |
1752
1743int invoke (object *op, int event, ...) 1753int invoke (object *op, int event, ...)
1744 CODE: 1754 CODE:
1745 if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); 1755 if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT");
1746 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 1756 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1747 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 1757 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1752 CODE: 1762 CODE:
1753 RETVAL = registry_of (op); 1763 RETVAL = registry_of (op);
1754 OUTPUT: 1764 OUTPUT:
1755 RETVAL 1765 RETVAL
1756 1766
1757INCLUDE: $PERL genacc object ../include/object.h | 1767void mortals ()
1768 PPCODE:
1769 EXTEND (SP, object::mortals.size ());
1770 for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i)
1771 PUSHs (to_sv (*i));
1772
1773object *first ()
1774 CODE:
1775 RETVAL = object::first;
1776 OUTPUT: RETVAL
1758 1777
1759# missing properties 1778# missing properties
1760 1779
1761int flag (object *op, int flag, int value = 1) 1780int flag (object *op, int flag, int value = 1)
1762 PROTOTYPE: $$;$ 1781 PROTOTYPE: $$;$
1789 object *o; 1808 object *o;
1790 for (o = obj->inv; o; o = o->below) 1809 for (o = obj->inv; o; o = o->below)
1791 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1810 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
1792} 1811}
1793 1812
1813object *find_best_object_match (object *op, const char *match)
1814
1815object *find_marked_object (object *op)
1816
1794int cf_object_get_resistance (object *op, int rtype) 1817int cf_object_get_resistance (object *op, int rtype)
1795 ALIAS: resistance = 0 1818 ALIAS: resistance = 0
1796 1819
1797int need_identify (const object *obj); 1820int need_identify (const object *obj);
1798 1821
1814 1837
1815object *cf_object_present_archname_inside (object *op, char *whatstr) 1838object *cf_object_present_archname_inside (object *op, char *whatstr)
1816 1839
1817int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) 1840int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0)
1818 1841
1819int cf_object_change_map (object *op, int x, int y, mapstruct *map) 1842int cf_object_change_map (object *op, int x, int y, maptile *map)
1820 1843
1821object *cf_object_clone (object *op, int clonetype = 0) 1844object *cf_object_clone (object *op, int clonetype = 0)
1822 1845
1823int cf_object_pay_item (object *op, object *buyer) 1846int cf_object_pay_item (object *op, object *buyer)
1824 1847
1856 1879
1857object *cf_object_insert_object (object *op, object *container) 1880object *cf_object_insert_object (object *op, object *container)
1858 1881
1859object *cf_object_insert_in_ob (object *ob, object *where) 1882object *cf_object_insert_in_ob (object *ob, object *where)
1860 1883
1861int cf_object_teleport (object *op, mapstruct *map, int x, int y) 1884int cf_object_teleport (object *op, maptile *map, int x, int y)
1862 1885
1863void cf_object_update (object *op, int flags) 1886void cf_object_update (object *op, int flags)
1864 1887
1865void cf_object_pickup (object *op, object *what) 1888void cf_object_pickup (object *op, object *what)
1866 1889
1876 1899
1877void push_button (object *op); 1900void push_button (object *op);
1878 1901
1879void use_trigger (object *op); 1902void use_trigger (object *op);
1880 1903
1881void add_button_link (object *button, mapstruct *map, int connected); 1904void add_button_link (object *button, maptile *map, int connected);
1882 1905
1883void remove_button_link (object *op); 1906void remove_button_link (object *op);
1884 1907
1885void 1908void
1886cf_object_set_resistance (object *op, int rtype, int val) 1909cf_object_set_resistance (object *op, int rtype, int val)
1904 CODE: 1927 CODE:
1905 RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); 1928 RETVAL = archetype ? get_archetype (archetype) : cf_create_object ();
1906 OUTPUT: 1929 OUTPUT:
1907 RETVAL 1930 RETVAL
1908 1931
1909object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y) 1932object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y)
1910 PROTOTYPE: $$$$$$ 1933 PROTOTYPE: $$$$$$
1911 CODE: 1934 CODE:
1912{ 1935{
1913 int unused_type; 1936 int unused_type;
1914 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); 1937 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y);
1952bool on_same_map_as (object *ob, object *other) 1975bool on_same_map_as (object *ob, object *other)
1953 CODE: 1976 CODE:
1954 RETVAL = on_same_map (ob, other); 1977 RETVAL = on_same_map (ob, other);
1955 OUTPUT: RETVAL 1978 OUTPUT: RETVAL
1956 1979
1957char * 1980const char *
1958base_name (object *ob, int plural) 1981base_name (object *op, int plural = op->nrof > 1)
1959 CODE: 1982 CODE:
1960 RETVAL = cf_query_base_name (ob, plural); 1983 RETVAL = query_base_name (op, plural);
1961 OUTPUT: RETVAL 1984 OUTPUT: RETVAL
1962 1985
1963MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 1986MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
1964 1987
1965player *player (object *op) 1988player *player (object *op)
1984 2007
1985void cf_player_set_party (object *op, partylist *party) 2008void cf_player_set_party (object *op, partylist *party)
1986 2009
1987void kill_player (object *op) 2010void kill_player (object *op)
1988 2011
2012void esrv_update_item (object *op, int what, object *item)
2013 C_ARGS: what, op, item
2014
1989MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ 2015MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
2016
2017INCLUDE: $PERL genacc player ../include/newserver.h ../include/player.h |
2018
2019char *
2020client (player *pl)
2021 CODE:
2022 RETVAL = pl->socket.client;
2023 OUTPUT:
2024 RETVAL
2025
2026char *
2027host (player *pl)
2028 CODE:
2029 RETVAL = pl->socket.host;
2030 OUTPUT:
2031 RETVAL
1990 2032
1991int invoke (player *pl, int event, ...) 2033int invoke (player *pl, int event, ...)
1992 CODE: 2034 CODE:
1993 if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); 2035 if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER");
1994 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2036 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2007 2049
2008void cf_player_move (player *pl, int dir) 2050void cf_player_move (player *pl, int dir)
2009 2051
2010void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2052void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
2011 2053
2012# nonstandard
2013object *ob (player *pl)
2014 CODE:
2015 RETVAL = pl->ob;
2016 OUTPUT: RETVAL
2017
2018player *first () 2054player *first ()
2019 CODE: 2055 CODE:
2020 RETVAL = first_player; 2056 RETVAL = first_player;
2021 OUTPUT: RETVAL 2057 OUTPUT: RETVAL
2022 2058
2028bool 2064bool
2029cell_visible (player *pl, int dx, int dy) 2065cell_visible (player *pl, int dx, int dy)
2030 CODE: 2066 CODE:
2031 RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 2067 RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2
2032 && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; 2068 && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2];
2033 OUTPUT:
2034 RETVAL
2035
2036char *
2037client (player *pl)
2038 CODE:
2039 RETVAL = pl->socket.client;
2040 OUTPUT:
2041 RETVAL
2042
2043char *
2044host (player *pl)
2045 CODE:
2046 RETVAL = pl->socket.host;
2047 OUTPUT:
2048 RETVAL
2049
2050char *
2051killer (player *pl, char *killer = 0)
2052 CODE:
2053 if (killer)
2054 snprintf (pl->killer, sizeof (pl->killer), "%s", killer);
2055 RETVAL = pl->killer;
2056 OUTPUT: 2069 OUTPUT:
2057 RETVAL 2070 RETVAL
2058 2071
2059void 2072void
2060buggy_mapscroll (player *pl, int value = 1) 2073buggy_mapscroll (player *pl, int value = 1)
2126 OUTPUT: RETVAL 2139 OUTPUT: RETVAL
2127 2140
2128 2141
2129MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ 2142MODULE = cf PACKAGE = cf::map PREFIX = cf_map_
2130 2143
2131mapstruct *first () 2144maptile *first ()
2132 PROTOTYPE: 2145 PROTOTYPE:
2133 CODE: 2146 CODE:
2134 RETVAL = first_map; 2147 RETVAL = first_map;
2135 OUTPUT: RETVAL 2148 OUTPUT: RETVAL
2136 2149
2137int invoke (mapstruct *map, int event, ...) 2150int invoke (maptile *map, int event, ...)
2138 CODE: 2151 CODE:
2139 if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); 2152 if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP");
2140 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2153 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2141 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 2154 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
2142 RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av)); 2155 RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av));
2143 OUTPUT: RETVAL 2156 OUTPUT: RETVAL
2144 2157
2145SV *registry (mapstruct *map) 2158SV *registry (maptile *map)
2146 CODE: 2159 CODE:
2147 RETVAL = registry_of (map); 2160 RETVAL = registry_of (map);
2148 OUTPUT: 2161 OUTPUT:
2149 RETVAL 2162 RETVAL
2150 2163
2151INCLUDE: $PERL genacc mapstruct ../include/map.h | 2164INCLUDE: $PERL genacc maptile ../include/map.h |
2152 2165
2153mapstruct *new (int width, int height) 2166maptile *new (int width, int height)
2154 PROTOTYPE: 2167 PROTOTYPE:
2155 CODE: 2168 CODE:
2156{ 2169{
2157 RETVAL = get_empty_map (width, height); 2170 RETVAL = get_empty_map (width, height);
2158} 2171}
2159 OUTPUT: 2172 OUTPUT:
2160 RETVAL 2173 RETVAL
2161 2174
2162void delete_map (mapstruct *map) 2175void delete_map (maptile *map)
2163 2176
2164void clean_tmp_map (mapstruct *map) 2177void clean_tmp_map (maptile *map)
2165 2178
2166void play_sound_map (mapstruct *map, int x, int y, int sound_num) 2179void play_sound_map (maptile *map, int x, int y, int sound_num)
2167 2180
2168mapstruct *tile_map (mapstruct *map, unsigned int dir) 2181maptile *tile_map (maptile *map, unsigned int dir)
2169 CODE: 2182 CODE:
2170 RETVAL = dir < 4 ? map->tile_map [dir] : 0; 2183 RETVAL = dir < 4 ? map->tile_map [dir] : 0;
2171 OUTPUT: 2184 OUTPUT:
2172 RETVAL 2185 RETVAL
2173 2186
2174char *tile_path (mapstruct *map, unsigned int dir) 2187char *tile_path (maptile *map, unsigned int dir)
2175 CODE: 2188 CODE:
2176 if (dir >= 4) 2189 if (dir >= 4)
2177 XSRETURN_UNDEF; 2190 XSRETURN_UNDEF;
2178 RETVAL = map->tile_path [dir]; 2191 RETVAL = map->tile_path [dir];
2179 OUTPUT: 2192 OUTPUT:
2180 RETVAL 2193 RETVAL
2181 2194
2182mapstruct *ready_map_name (char *name, int flags = 0) 2195maptile *ready_map_name (char *name, int flags = 0)
2183 PROTOTYPE: $;$ 2196 PROTOTYPE: $;$
2184 ALIAS: 2197 ALIAS:
2185 find = 0 2198 find = 0
2186 get_map = 1 2199 get_map = 1
2187 2200
2188mapstruct *has_been_loaded (char *name) 2201maptile *has_been_loaded (char *name)
2189 PROTOTYPE: $ 2202 PROTOTYPE: $
2190 2203
2191int in_memory (mapstruct *map) 2204int in_memory (maptile *map)
2192 CODE: 2205 CODE:
2193 RETVAL = map->in_memory; 2206 RETVAL = map->in_memory;
2194 OUTPUT: 2207 OUTPUT:
2195 RETVAL 2208 RETVAL
2196 2209
2197void 2210void
2198trigger (mapstruct *map, long connection, bool state = true) 2211trigger (maptile *map, long connection, bool state = true)
2199 CODE: 2212 CODE:
2200 activate_connection (map, connection, state); 2213 activate_connection (map, connection, state);
2201 2214
2202void 2215void
2203get_connection (mapstruct *map, long connection) 2216get_connection (maptile *map, long connection)
2204 PPCODE: 2217 PPCODE:
2205 oblinkpt *obp = get_connection_links (map, connection); 2218 oblinkpt *obp = get_connection_links (map, connection);
2206 if (obp) 2219 if (obp)
2207 for (objectlink *ol = obp->link; ol; ol = ol->next) 2220 for (objectlink *ol = obp->link; ol; ol = ol->next)
2208 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); 2221 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob)));
2209 2222
2210object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) 2223object *cf_map_insert_object_there (maptile *where, object *op, object *originator, int flags)
2211 2224
2212object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) 2225object *cf_map_insert_object (maptile *where, object* op, int x, int y)
2213 2226
2214object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) 2227object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny)
2215 C_ARGS: str, map, nx, ny 2228 C_ARGS: str, map, nx, ny
2216 2229
2217void 2230void
2218cf_map_normalise (mapstruct *map, int x, int y) 2231cf_map_normalise (maptile *map, int x, int y)
2219 PPCODE: 2232 PPCODE:
2220{ 2233{
2221 mapstruct *nmap = 0; 2234 maptile *nmap = 0;
2222 I16 nx = 0, ny = 0; 2235 I16 nx = 0, ny = 0;
2223 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2236 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2224 2237
2225 EXTEND (SP, 4); 2238 EXTEND (SP, 4);
2226 PUSHs (sv_2mortal (newSViv (flags))); 2239 PUSHs (sv_2mortal (newSViv (flags)));
2232 PUSHs (sv_2mortal (newSViv (ny))); 2245 PUSHs (sv_2mortal (newSViv (ny)));
2233 } 2246 }
2234} 2247}
2235 2248
2236void 2249void
2237at (mapstruct *map, unsigned int x, unsigned int y) 2250at (maptile *map, unsigned int x, unsigned int y)
2238 PROTOTYPE: $$$ 2251 PROTOTYPE: $$$
2239 PPCODE: 2252 PPCODE:
2240{ 2253{
2241 object *o; 2254 object *o;
2242 mapstruct *nmap = 0; 2255 maptile *nmap = 0;
2243 I16 nx, ny; 2256 I16 nx, ny;
2244 2257
2245 get_map_flags (map, &nmap, x, y, &nx, &ny); 2258 get_map_flags (map, &nmap, x, y, &nx, &ny);
2246 2259
2247 if (nmap) 2260 if (nmap)
2248 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) 2261 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above)
2249 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 2262 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
2250} 2263}
2251 2264
2252SV * 2265SV *
2253bot_at (mapstruct *obj, unsigned int x, unsigned int y) 2266bot_at (maptile *obj, unsigned int x, unsigned int y)
2254 PROTOTYPE: $$$ 2267 PROTOTYPE: $$$
2255 ALIAS: 2268 ALIAS:
2256 top_at = 1 2269 top_at = 1
2257 flags_at = 2 2270 flags_at = 2
2258 light_at = 3 2271 light_at = 3
2280 2293
2281MODULE = cf PACKAGE = cf::arch 2294MODULE = cf PACKAGE = cf::arch
2282 2295
2283archetype *find (const char *name) 2296archetype *find (const char *name)
2284 CODE: 2297 CODE:
2285 RETVAL = find_archetype (name); 2298 RETVAL = archetype::find (name);
2286 OUTPUT: 2299 OUTPUT:
2287 RETVAL 2300 RETVAL
2288 2301
2289archetype *first() 2302archetype *first()
2290 PROTOTYPE: 2303 PROTOTYPE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines