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.62 by root, Wed Sep 20 21:53:50 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);
1391 const_iv (NDI_MAX_COLOR) 1383 const_iv (NDI_MAX_COLOR)
1392 const_iv (NDI_COLOR_MASK) 1384 const_iv (NDI_COLOR_MASK)
1393 const_iv (NDI_UNIQUE) 1385 const_iv (NDI_UNIQUE)
1394 const_iv (NDI_ALL) 1386 const_iv (NDI_ALL)
1395 1387
1388 const_iv (UPD_LOCATION)
1389 const_iv (UPD_FLAGS)
1390 const_iv (UPD_WEIGHT)
1391 const_iv (UPD_FACE)
1392 const_iv (UPD_NAME)
1393 const_iv (UPD_ANIM)
1394 const_iv (UPD_ANIMSPEED)
1395 const_iv (UPD_NROF)
1396
1397 const_iv (UPD_SP_MANA)
1398 const_iv (UPD_SP_GRACE)
1399 const_iv (UPD_SP_DAMAGE)
1400
1396 const_iv (F_APPLIED) 1401 const_iv (F_APPLIED)
1397 const_iv (F_LOCATION) 1402 const_iv (F_LOCATION)
1398 const_iv (F_UNPAID) 1403 const_iv (F_UNPAID)
1399 const_iv (F_MAGIC) 1404 const_iv (F_MAGIC)
1400 const_iv (F_CURSED) 1405 const_iv (F_CURSED)
1613{ 1618{
1614 // reattach to all attachable objects in the game. 1619 // reattach to all attachable objects in the game.
1615 for (player *pl = first_player; pl; pl = pl->next) 1620 for (player *pl = first_player; pl; pl = pl->next)
1616 reattach (pl); 1621 reattach (pl);
1617 1622
1618 for (mapstruct *map = first_map; map; map = map->next) 1623 for (maptile *map = first_map; map; map = map->next)
1619 reattach (map); 1624 reattach (map);
1620 1625
1621 for (object *op = objects; op; op = op->next) 1626 for (object *op = object::first; op; op = op->next)
1622 reattach (op); 1627 reattach (op);
1623} 1628}
1624 1629
1625NV floor (NV x) 1630NV floor (NV x)
1626 1631
1674 case 5: RETVAL = settings.playerdir; break; 1679 case 5: RETVAL = settings.playerdir; break;
1675 case 6: RETVAL = settings.datadir ; break; 1680 case 6: RETVAL = settings.datadir ; break;
1676 } 1681 }
1677 OUTPUT: RETVAL 1682 OUTPUT: RETVAL
1678 1683
1679int 1684void _exit (int status = 0)
1685
1680cf_find_animation (char *text) 1686int cf_find_animation (char *text)
1681 PROTOTYPE: $ 1687 PROTOTYPE: $
1682 1688
1683int random_roll(int min, int max, object *op, int goodbad); 1689int random_roll(int min, int max, object *op, int goodbad);
1684 1690
1685const char *cost_string_from_value(uint64 cost, int approx = 0) 1691const char *cost_string_from_value(uint64 cost, int approx = 0)
1738 OUTPUT: 1744 OUTPUT:
1739 RETVAL 1745 RETVAL
1740 1746
1741MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1747MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1742 1748
1749INCLUDE: $PERL genacc object ../include/object.h |
1750
1743int invoke (object *op, int event, ...) 1751int invoke (object *op, int event, ...)
1744 CODE: 1752 CODE:
1745 if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); 1753 if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT");
1746 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 1754 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1747 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 1755 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1752 CODE: 1760 CODE:
1753 RETVAL = registry_of (op); 1761 RETVAL = registry_of (op);
1754 OUTPUT: 1762 OUTPUT:
1755 RETVAL 1763 RETVAL
1756 1764
1757INCLUDE: $PERL genacc object ../include/object.h | 1765void mortals ()
1766 PPCODE:
1767 EXTEND (SP, object::mortals.size ());
1768 for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i)
1769 PUSHs (to_sv (*i));
1770
1771object *first ()
1772 CODE:
1773 RETVAL = object::first;
1774 OUTPUT: RETVAL
1758 1775
1759# missing properties 1776# missing properties
1760 1777
1761int flag (object *op, int flag, int value = 1) 1778int flag (object *op, int flag, int value = 1)
1762 PROTOTYPE: $$;$ 1779 PROTOTYPE: $$;$
1789 object *o; 1806 object *o;
1790 for (o = obj->inv; o; o = o->below) 1807 for (o = obj->inv; o; o = o->below)
1791 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1808 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
1792} 1809}
1793 1810
1811object *find_best_object_match (object *op, const char *match)
1812
1813object *find_marked_object (object *op)
1814
1794int cf_object_get_resistance (object *op, int rtype) 1815int cf_object_get_resistance (object *op, int rtype)
1795 ALIAS: resistance = 0 1816 ALIAS: resistance = 0
1796 1817
1797int need_identify (const object *obj); 1818int need_identify (const object *obj);
1798 1819
1814 1835
1815object *cf_object_present_archname_inside (object *op, char *whatstr) 1836object *cf_object_present_archname_inside (object *op, char *whatstr)
1816 1837
1817int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) 1838int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0)
1818 1839
1819int cf_object_change_map (object *op, int x, int y, mapstruct *map) 1840int cf_object_change_map (object *op, int x, int y, maptile *map)
1820 1841
1821object *cf_object_clone (object *op, int clonetype = 0) 1842object *cf_object_clone (object *op, int clonetype = 0)
1822 1843
1823int cf_object_pay_item (object *op, object *buyer) 1844int cf_object_pay_item (object *op, object *buyer)
1824 1845
1856 1877
1857object *cf_object_insert_object (object *op, object *container) 1878object *cf_object_insert_object (object *op, object *container)
1858 1879
1859object *cf_object_insert_in_ob (object *ob, object *where) 1880object *cf_object_insert_in_ob (object *ob, object *where)
1860 1881
1861int cf_object_teleport (object *op, mapstruct *map, int x, int y) 1882int cf_object_teleport (object *op, maptile *map, int x, int y)
1862 1883
1863void cf_object_update (object *op, int flags) 1884void cf_object_update (object *op, int flags)
1864 1885
1865void cf_object_pickup (object *op, object *what) 1886void cf_object_pickup (object *op, object *what)
1866 1887
1876 1897
1877void push_button (object *op); 1898void push_button (object *op);
1878 1899
1879void use_trigger (object *op); 1900void use_trigger (object *op);
1880 1901
1881void add_button_link (object *button, mapstruct *map, int connected); 1902void add_button_link (object *button, maptile *map, int connected);
1882 1903
1883void remove_button_link (object *op); 1904void remove_button_link (object *op);
1884 1905
1885void 1906void
1886cf_object_set_resistance (object *op, int rtype, int val) 1907cf_object_set_resistance (object *op, int rtype, int val)
1904 CODE: 1925 CODE:
1905 RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); 1926 RETVAL = archetype ? get_archetype (archetype) : cf_create_object ();
1906 OUTPUT: 1927 OUTPUT:
1907 RETVAL 1928 RETVAL
1908 1929
1909object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y) 1930object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y)
1910 PROTOTYPE: $$$$$$ 1931 PROTOTYPE: $$$$$$
1911 CODE: 1932 CODE:
1912{ 1933{
1913 int unused_type; 1934 int unused_type;
1914 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); 1935 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y);
1952bool on_same_map_as (object *ob, object *other) 1973bool on_same_map_as (object *ob, object *other)
1953 CODE: 1974 CODE:
1954 RETVAL = on_same_map (ob, other); 1975 RETVAL = on_same_map (ob, other);
1955 OUTPUT: RETVAL 1976 OUTPUT: RETVAL
1956 1977
1957char * 1978const char *
1958base_name (object *ob, int plural) 1979base_name (object *op, int plural = op->nrof > 1)
1959 CODE: 1980 CODE:
1960 RETVAL = cf_query_base_name (ob, plural); 1981 RETVAL = query_base_name (op, plural);
1961 OUTPUT: RETVAL 1982 OUTPUT: RETVAL
1962 1983
1963MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 1984MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
1964 1985
1965player *player (object *op) 1986player *player (object *op)
1984 2005
1985void cf_player_set_party (object *op, partylist *party) 2006void cf_player_set_party (object *op, partylist *party)
1986 2007
1987void kill_player (object *op) 2008void kill_player (object *op)
1988 2009
2010void esrv_update_item (object *op, int what, object *item)
2011 C_ARGS: what, op, item
2012
1989MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ 2013MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
2014
2015INCLUDE: $PERL genacc player ../include/newserver.h ../include/player.h |
2016
2017char *
2018client (player *pl)
2019 CODE:
2020 RETVAL = pl->socket.client;
2021 OUTPUT:
2022 RETVAL
2023
2024char *
2025host (player *pl)
2026 CODE:
2027 RETVAL = pl->socket.host;
2028 OUTPUT:
2029 RETVAL
1990 2030
1991int invoke (player *pl, int event, ...) 2031int invoke (player *pl, int event, ...)
1992 CODE: 2032 CODE:
1993 if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); 2033 if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER");
1994 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2034 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2007 2047
2008void cf_player_move (player *pl, int dir) 2048void cf_player_move (player *pl, int dir)
2009 2049
2010void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2050void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
2011 2051
2012# nonstandard
2013object *ob (player *pl)
2014 CODE:
2015 RETVAL = pl->ob;
2016 OUTPUT: RETVAL
2017
2018player *first () 2052player *first ()
2019 CODE: 2053 CODE:
2020 RETVAL = first_player; 2054 RETVAL = first_player;
2021 OUTPUT: RETVAL 2055 OUTPUT: RETVAL
2022 2056
2028bool 2062bool
2029cell_visible (player *pl, int dx, int dy) 2063cell_visible (player *pl, int dx, int dy)
2030 CODE: 2064 CODE:
2031 RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 2065 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]; 2066 && !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: 2067 OUTPUT:
2057 RETVAL 2068 RETVAL
2058 2069
2059void 2070void
2060buggy_mapscroll (player *pl, int value = 1) 2071buggy_mapscroll (player *pl, int value = 1)
2126 OUTPUT: RETVAL 2137 OUTPUT: RETVAL
2127 2138
2128 2139
2129MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ 2140MODULE = cf PACKAGE = cf::map PREFIX = cf_map_
2130 2141
2131mapstruct *first () 2142maptile *first ()
2132 PROTOTYPE: 2143 PROTOTYPE:
2133 CODE: 2144 CODE:
2134 RETVAL = first_map; 2145 RETVAL = first_map;
2135 OUTPUT: RETVAL 2146 OUTPUT: RETVAL
2136 2147
2137int invoke (mapstruct *map, int event, ...) 2148int invoke (maptile *map, int event, ...)
2138 CODE: 2149 CODE:
2139 if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); 2150 if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP");
2140 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2151 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2141 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 2152 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)); 2153 RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av));
2143 OUTPUT: RETVAL 2154 OUTPUT: RETVAL
2144 2155
2145SV *registry (mapstruct *map) 2156SV *registry (maptile *map)
2146 CODE: 2157 CODE:
2147 RETVAL = registry_of (map); 2158 RETVAL = registry_of (map);
2148 OUTPUT: 2159 OUTPUT:
2149 RETVAL 2160 RETVAL
2150 2161
2151INCLUDE: $PERL genacc mapstruct ../include/map.h | 2162INCLUDE: $PERL genacc maptile ../include/map.h |
2152 2163
2153mapstruct *new (int width, int height) 2164maptile *new (int width, int height)
2154 PROTOTYPE: 2165 PROTOTYPE:
2155 CODE: 2166 CODE:
2156{ 2167{
2157 RETVAL = get_empty_map (width, height); 2168 RETVAL = get_empty_map (width, height);
2158} 2169}
2159 OUTPUT: 2170 OUTPUT:
2160 RETVAL 2171 RETVAL
2161 2172
2162void delete_map (mapstruct *map) 2173void delete_map (maptile *map)
2163 2174
2164void clean_tmp_map (mapstruct *map) 2175void clean_tmp_map (maptile *map)
2165 2176
2166void play_sound_map (mapstruct *map, int x, int y, int sound_num) 2177void play_sound_map (maptile *map, int x, int y, int sound_num)
2167 2178
2168mapstruct *tile_map (mapstruct *map, unsigned int dir) 2179maptile *tile_map (maptile *map, unsigned int dir)
2169 CODE: 2180 CODE:
2170 RETVAL = dir < 4 ? map->tile_map [dir] : 0; 2181 RETVAL = dir < 4 ? map->tile_map [dir] : 0;
2171 OUTPUT: 2182 OUTPUT:
2172 RETVAL 2183 RETVAL
2173 2184
2174char *tile_path (mapstruct *map, unsigned int dir) 2185char *tile_path (maptile *map, unsigned int dir)
2175 CODE: 2186 CODE:
2176 if (dir >= 4) 2187 if (dir >= 4)
2177 XSRETURN_UNDEF; 2188 XSRETURN_UNDEF;
2178 RETVAL = map->tile_path [dir]; 2189 RETVAL = map->tile_path [dir];
2179 OUTPUT: 2190 OUTPUT:
2180 RETVAL 2191 RETVAL
2181 2192
2182mapstruct *ready_map_name (char *name, int flags = 0) 2193maptile *ready_map_name (char *name, int flags = 0)
2183 PROTOTYPE: $;$ 2194 PROTOTYPE: $;$
2184 ALIAS: 2195 ALIAS:
2185 find = 0 2196 find = 0
2186 get_map = 1 2197 get_map = 1
2187 2198
2188mapstruct *has_been_loaded (char *name) 2199maptile *has_been_loaded (char *name)
2189 PROTOTYPE: $ 2200 PROTOTYPE: $
2190 2201
2191int in_memory (mapstruct *map) 2202int in_memory (maptile *map)
2192 CODE: 2203 CODE:
2193 RETVAL = map->in_memory; 2204 RETVAL = map->in_memory;
2194 OUTPUT: 2205 OUTPUT:
2195 RETVAL 2206 RETVAL
2196 2207
2197void 2208void
2198trigger (mapstruct *map, long connection, bool state = true) 2209trigger (maptile *map, long connection, bool state = true)
2199 CODE: 2210 CODE:
2200 activate_connection (map, connection, state); 2211 activate_connection (map, connection, state);
2201 2212
2202void 2213void
2203get_connection (mapstruct *map, long connection) 2214get_connection (maptile *map, long connection)
2204 PPCODE: 2215 PPCODE:
2205 oblinkpt *obp = get_connection_links (map, connection); 2216 oblinkpt *obp = get_connection_links (map, connection);
2206 if (obp) 2217 if (obp)
2207 for (objectlink *ol = obp->link; ol; ol = ol->next) 2218 for (objectlink *ol = obp->link; ol; ol = ol->next)
2208 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); 2219 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob)));
2209 2220
2210object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) 2221object *cf_map_insert_object_there (maptile *where, object *op, object *originator, int flags)
2211 2222
2212object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) 2223object *cf_map_insert_object (maptile *where, object* op, int x, int y)
2213 2224
2214object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) 2225object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny)
2215 C_ARGS: str, map, nx, ny 2226 C_ARGS: str, map, nx, ny
2216 2227
2217void 2228void
2218cf_map_normalise (mapstruct *map, int x, int y) 2229cf_map_normalise (maptile *map, int x, int y)
2219 PPCODE: 2230 PPCODE:
2220{ 2231{
2221 mapstruct *nmap = 0; 2232 maptile *nmap = 0;
2222 I16 nx = 0, ny = 0; 2233 I16 nx = 0, ny = 0;
2223 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2234 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2224 2235
2225 EXTEND (SP, 4); 2236 EXTEND (SP, 4);
2226 PUSHs (sv_2mortal (newSViv (flags))); 2237 PUSHs (sv_2mortal (newSViv (flags)));
2232 PUSHs (sv_2mortal (newSViv (ny))); 2243 PUSHs (sv_2mortal (newSViv (ny)));
2233 } 2244 }
2234} 2245}
2235 2246
2236void 2247void
2237at (mapstruct *map, unsigned int x, unsigned int y) 2248at (maptile *map, unsigned int x, unsigned int y)
2238 PROTOTYPE: $$$ 2249 PROTOTYPE: $$$
2239 PPCODE: 2250 PPCODE:
2240{ 2251{
2241 object *o; 2252 object *o;
2242 mapstruct *nmap = 0; 2253 maptile *nmap = 0;
2243 I16 nx, ny; 2254 I16 nx, ny;
2244 2255
2245 get_map_flags (map, &nmap, x, y, &nx, &ny); 2256 get_map_flags (map, &nmap, x, y, &nx, &ny);
2246 2257
2247 if (nmap) 2258 if (nmap)
2248 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) 2259 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above)
2249 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 2260 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
2250} 2261}
2251 2262
2252SV * 2263SV *
2253bot_at (mapstruct *obj, unsigned int x, unsigned int y) 2264bot_at (maptile *obj, unsigned int x, unsigned int y)
2254 PROTOTYPE: $$$ 2265 PROTOTYPE: $$$
2255 ALIAS: 2266 ALIAS:
2256 top_at = 1 2267 top_at = 1
2257 flags_at = 2 2268 flags_at = 2
2258 light_at = 3 2269 light_at = 3
2280 2291
2281MODULE = cf PACKAGE = cf::arch 2292MODULE = cf PACKAGE = cf::arch
2282 2293
2283archetype *find (const char *name) 2294archetype *find (const char *name)
2284 CODE: 2295 CODE:
2285 RETVAL = find_archetype (name); 2296 RETVAL = archetype::find (name);
2286 OUTPUT: 2297 OUTPUT:
2287 RETVAL 2298 RETVAL
2288 2299
2289archetype *first() 2300archetype *first()
2290 PROTOTYPE: 2301 PROTOTYPE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines