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.65 by root, Tue Nov 7 16:30:55 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
487 call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); 479 call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL);
488 FREETMPS; 480 FREETMPS;
489 LEAVE; 481 LEAVE;
490} 482}
491 483
484char *object_freezer::as_string ()
485{
486 dSP;
487 ENTER;
488 SAVETMPS;
489 PUSHMARK (SP);
490 EXTEND (SP, 3);
491 PUSHs (sv_2mortal (newRV_noinc (newSVpvn ((char *)linearise (), size ()))));
492 PUSHs (sv_2mortal (newRV_inc ((SV *)av)));
493 PUTBACK;
494
495 char *res = call_pv ("cf::object_freezer_as_string", G_SCALAR | G_EVAL) > 0
496 ? strdup (SvPVbyte_nolen (POPs))
497 : strdup ("[fatal error]");
498
499 FREETMPS;
500 LEAVE;
501
502 return res;
503}
504
492int fprintf (object_freezer &freezer, const char *format, ...) 505int fprintf (object_freezer &freezer, const char *format, ...)
493{ 506{
494 va_list ap; 507 va_list ap;
495 508
496 va_start (ap, format); 509 va_start (ap, format);
505 518
506int fputs (const char *s, object_freezer &freezer) 519int fputs (const char *s, object_freezer &freezer)
507{ 520{
508 freezer.add (s); 521 freezer.add (s);
509} 522}
523
524static const char thawer_eof[] = "\n\n\n\0\0\0";
510 525
511object_thawer::object_thawer (const char *filename) 526object_thawer::object_thawer (const char *filename)
512{ 527{
513 static const char eof[] = "\n\n\n\0\0\0"; 528 static const char eof[] = "\n\n\n\0\0\0";
514 529
552 567
553 PUTBACK; 568 PUTBACK;
554 FREETMPS; 569 FREETMPS;
555 LEAVE; 570 LEAVE;
556 } 571 }
572}
573
574object_thawer::object_thawer (const char *data, AV *perlav)
575{
576 av = perlav;
577 text = newSVpv (data, 0);
578 sv_catpv (text, thawer_eof);
579 line = SvPVbyte_nolen (text);
557} 580}
558 581
559void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) 582void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid)
560{ 583{
561 if (!av || oid < 0) // this is actually an error of sorts 584 if (!av || oid < 0) // this is actually an error of sorts
939 962
940 AV *callbacks = 0; 963 AV *callbacks = 0;
941 964
942 object *op; 965 object *op;
943 player *pl; 966 player *pl;
944 mapstruct *map; 967 maptile *map;
945 968
946 // callback call ordering is: 969 // callback call ordering is:
947 // 1. per-object callback (NYI) 970 // 1. per-object callback (NYI)
948 // 2. per-class object 971 // 2. per-class object
949 // 2a. per-type callback 972 // 2a. per-type callback
999 break; 1022 break;
1000 1023
1001 case KLASS_MAP: 1024 case KLASS_MAP:
1002 dt = (data_type) va_arg (ap, int); 1025 dt = (data_type) va_arg (ap, int);
1003 assert (("first argument must be of type object", dt == DT_MAP)); 1026 assert (("first argument must be of type object", dt == DT_MAP));
1004 map = va_arg (ap, mapstruct *); 1027 map = va_arg (ap, maptile *);
1005 1028
1006 if (map->cb) 1029 if (map->cb)
1007 gather_callbacks (callbacks, map->cb, event); 1030 gather_callbacks (callbacks, map->cb, event);
1008 1031
1009 gather_callbacks (callbacks, cb_map, event); 1032 gather_callbacks (callbacks, cb_map, event);
1089MODULE = cf PACKAGE = cf PREFIX = cf_ 1112MODULE = cf PACKAGE = cf PREFIX = cf_
1090 1113
1091BOOT: 1114BOOT:
1092{ 1115{
1093 HV *stash = gv_stashpv ("cf", 1); 1116 HV *stash = gv_stashpv ("cf", 1);
1117
1118 newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1094 1119
1095 static const struct { 1120 static const struct {
1096 const char *name; 1121 const char *name;
1097 IV iv; 1122 IV iv;
1098 } *civ, const_iv[] = { 1123 } *civ, const_iv[] = {
1391 const_iv (NDI_MAX_COLOR) 1416 const_iv (NDI_MAX_COLOR)
1392 const_iv (NDI_COLOR_MASK) 1417 const_iv (NDI_COLOR_MASK)
1393 const_iv (NDI_UNIQUE) 1418 const_iv (NDI_UNIQUE)
1394 const_iv (NDI_ALL) 1419 const_iv (NDI_ALL)
1395 1420
1421 const_iv (UPD_LOCATION)
1422 const_iv (UPD_FLAGS)
1423 const_iv (UPD_WEIGHT)
1424 const_iv (UPD_FACE)
1425 const_iv (UPD_NAME)
1426 const_iv (UPD_ANIM)
1427 const_iv (UPD_ANIMSPEED)
1428 const_iv (UPD_NROF)
1429
1430 const_iv (UPD_SP_MANA)
1431 const_iv (UPD_SP_GRACE)
1432 const_iv (UPD_SP_DAMAGE)
1433
1396 const_iv (F_APPLIED) 1434 const_iv (F_APPLIED)
1397 const_iv (F_LOCATION) 1435 const_iv (F_LOCATION)
1398 const_iv (F_UNPAID) 1436 const_iv (F_UNPAID)
1399 const_iv (F_MAGIC) 1437 const_iv (F_MAGIC)
1400 const_iv (F_CURSED) 1438 const_iv (F_CURSED)
1613{ 1651{
1614 // reattach to all attachable objects in the game. 1652 // reattach to all attachable objects in the game.
1615 for (player *pl = first_player; pl; pl = pl->next) 1653 for (player *pl = first_player; pl; pl = pl->next)
1616 reattach (pl); 1654 reattach (pl);
1617 1655
1618 for (mapstruct *map = first_map; map; map = map->next) 1656 for (maptile *map = first_map; map; map = map->next)
1619 reattach (map); 1657 reattach (map);
1620 1658
1621 for (object *op = objects; op; op = op->next) 1659 for (object *op = object::first; op; op = op->next)
1622 reattach (op); 1660 reattach (op);
1623} 1661}
1624 1662
1625NV floor (NV x) 1663NV floor (NV x)
1626 1664
1674 case 5: RETVAL = settings.playerdir; break; 1712 case 5: RETVAL = settings.playerdir; break;
1675 case 6: RETVAL = settings.datadir ; break; 1713 case 6: RETVAL = settings.datadir ; break;
1676 } 1714 }
1677 OUTPUT: RETVAL 1715 OUTPUT: RETVAL
1678 1716
1679int 1717void _exit (int status = 0)
1718
1680cf_find_animation (char *text) 1719int cf_find_animation (char *text)
1681 PROTOTYPE: $ 1720 PROTOTYPE: $
1682 1721
1683int random_roll(int min, int max, object *op, int goodbad); 1722int random_roll(int min, int max, object *op, int goodbad);
1684 1723
1685const char *cost_string_from_value(uint64 cost, int approx = 0) 1724const char *cost_string_from_value(uint64 cost, int approx = 0)
1738 OUTPUT: 1777 OUTPUT:
1739 RETVAL 1778 RETVAL
1740 1779
1741MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1780MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1742 1781
1782INCLUDE: $PERL genacc object ../include/object.h |
1783
1743int invoke (object *op, int event, ...) 1784int invoke (object *op, int event, ...)
1744 CODE: 1785 CODE:
1745 if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); 1786 if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT");
1746 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 1787 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1747 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 1788 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1752 CODE: 1793 CODE:
1753 RETVAL = registry_of (op); 1794 RETVAL = registry_of (op);
1754 OUTPUT: 1795 OUTPUT:
1755 RETVAL 1796 RETVAL
1756 1797
1757INCLUDE: $PERL genacc object ../include/object.h | 1798void mortals ()
1799 PPCODE:
1800 EXTEND (SP, object::mortals.size ());
1801 for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i)
1802 PUSHs (to_sv (*i));
1803
1804object *first ()
1805 CODE:
1806 RETVAL = object::first;
1807 OUTPUT: RETVAL
1758 1808
1759# missing properties 1809# missing properties
1760 1810
1761int flag (object *op, int flag, int value = 1) 1811int flag (object *op, int flag, int value = 1)
1762 PROTOTYPE: $$;$ 1812 PROTOTYPE: $$;$
1789 object *o; 1839 object *o;
1790 for (o = obj->inv; o; o = o->below) 1840 for (o = obj->inv; o; o = o->below)
1791 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1841 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
1792} 1842}
1793 1843
1844object *find_best_object_match (object *op, const char *match)
1845
1846object *find_marked_object (object *op)
1847
1794int cf_object_get_resistance (object *op, int rtype) 1848int cf_object_get_resistance (object *op, int rtype)
1795 ALIAS: resistance = 0 1849 ALIAS: resistance = 0
1796 1850
1797int need_identify (const object *obj); 1851int need_identify (const object *obj);
1798 1852
1814 1868
1815object *cf_object_present_archname_inside (object *op, char *whatstr) 1869object *cf_object_present_archname_inside (object *op, char *whatstr)
1816 1870
1817int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) 1871int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0)
1818 1872
1819int cf_object_change_map (object *op, int x, int y, mapstruct *map) 1873int cf_object_change_map (object *op, int x, int y, maptile *map)
1820 1874
1821object *cf_object_clone (object *op, int clonetype = 0) 1875object *cf_object_clone (object *op, int clonetype = 0)
1822 1876
1823int cf_object_pay_item (object *op, object *buyer) 1877int cf_object_pay_item (object *op, object *buyer)
1824 1878
1856 1910
1857object *cf_object_insert_object (object *op, object *container) 1911object *cf_object_insert_object (object *op, object *container)
1858 1912
1859object *cf_object_insert_in_ob (object *ob, object *where) 1913object *cf_object_insert_in_ob (object *ob, object *where)
1860 1914
1861int cf_object_teleport (object *op, mapstruct *map, int x, int y) 1915int cf_object_teleport (object *op, maptile *map, int x, int y)
1862 1916
1863void cf_object_update (object *op, int flags) 1917void cf_object_update (object *op, int flags)
1864 1918
1865void cf_object_pickup (object *op, object *what) 1919void cf_object_pickup (object *op, object *what)
1866 1920
1876 1930
1877void push_button (object *op); 1931void push_button (object *op);
1878 1932
1879void use_trigger (object *op); 1933void use_trigger (object *op);
1880 1934
1881void add_button_link (object *button, mapstruct *map, int connected); 1935void add_button_link (object *button, maptile *map, int connected);
1882 1936
1883void remove_button_link (object *op); 1937void remove_button_link (object *op);
1884 1938
1885void 1939void
1886cf_object_set_resistance (object *op, int rtype, int val) 1940cf_object_set_resistance (object *op, int rtype, int val)
1904 CODE: 1958 CODE:
1905 RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); 1959 RETVAL = archetype ? get_archetype (archetype) : cf_create_object ();
1906 OUTPUT: 1960 OUTPUT:
1907 RETVAL 1961 RETVAL
1908 1962
1909object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y) 1963object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y)
1910 PROTOTYPE: $$$$$$ 1964 PROTOTYPE: $$$$$$
1911 CODE: 1965 CODE:
1912{ 1966{
1913 int unused_type; 1967 int unused_type;
1914 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); 1968 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y);
1952bool on_same_map_as (object *ob, object *other) 2006bool on_same_map_as (object *ob, object *other)
1953 CODE: 2007 CODE:
1954 RETVAL = on_same_map (ob, other); 2008 RETVAL = on_same_map (ob, other);
1955 OUTPUT: RETVAL 2009 OUTPUT: RETVAL
1956 2010
1957char * 2011const char *
1958base_name (object *ob, int plural) 2012base_name (object *op, int plural = op->nrof > 1)
1959 CODE: 2013 CODE:
1960 RETVAL = cf_query_base_name (ob, plural); 2014 RETVAL = query_base_name (op, plural);
1961 OUTPUT: RETVAL 2015 OUTPUT: RETVAL
1962 2016
1963MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 2017MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
1964 2018
1965player *player (object *op) 2019player *player (object *op)
1984 2038
1985void cf_player_set_party (object *op, partylist *party) 2039void cf_player_set_party (object *op, partylist *party)
1986 2040
1987void kill_player (object *op) 2041void kill_player (object *op)
1988 2042
2043void esrv_update_item (object *op, int what, object *item)
2044 C_ARGS: what, op, item
2045
1989MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ 2046MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
2047
2048INCLUDE: $PERL genacc player ../include/newserver.h ../include/player.h |
2049
2050char *
2051client (player *pl)
2052 CODE:
2053 RETVAL = pl->socket.client;
2054 OUTPUT:
2055 RETVAL
2056
2057char *
2058host (player *pl)
2059 CODE:
2060 RETVAL = pl->socket.host;
2061 OUTPUT:
2062 RETVAL
1990 2063
1991int invoke (player *pl, int event, ...) 2064int invoke (player *pl, int event, ...)
1992 CODE: 2065 CODE:
1993 if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); 2066 if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER");
1994 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2067 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2007 2080
2008void cf_player_move (player *pl, int dir) 2081void cf_player_move (player *pl, int dir)
2009 2082
2010void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2083void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
2011 2084
2012# nonstandard
2013object *ob (player *pl)
2014 CODE:
2015 RETVAL = pl->ob;
2016 OUTPUT: RETVAL
2017
2018player *first () 2085player *first ()
2019 CODE: 2086 CODE:
2020 RETVAL = first_player; 2087 RETVAL = first_player;
2021 OUTPUT: RETVAL 2088 OUTPUT: RETVAL
2022 2089
2028bool 2095bool
2029cell_visible (player *pl, int dx, int dy) 2096cell_visible (player *pl, int dx, int dy)
2030 CODE: 2097 CODE:
2031 RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 2098 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]; 2099 && !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: 2100 OUTPUT:
2057 RETVAL 2101 RETVAL
2058 2102
2059void 2103void
2060buggy_mapscroll (player *pl, int value = 1) 2104buggy_mapscroll (player *pl, int value = 1)
2126 OUTPUT: RETVAL 2170 OUTPUT: RETVAL
2127 2171
2128 2172
2129MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ 2173MODULE = cf PACKAGE = cf::map PREFIX = cf_map_
2130 2174
2131mapstruct *first () 2175maptile *first ()
2132 PROTOTYPE: 2176 PROTOTYPE:
2133 CODE: 2177 CODE:
2134 RETVAL = first_map; 2178 RETVAL = first_map;
2135 OUTPUT: RETVAL 2179 OUTPUT: RETVAL
2136 2180
2137int invoke (mapstruct *map, int event, ...) 2181int invoke (maptile *map, int event, ...)
2138 CODE: 2182 CODE:
2139 if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); 2183 if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP");
2140 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2184 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2141 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 2185 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)); 2186 RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av));
2143 OUTPUT: RETVAL 2187 OUTPUT: RETVAL
2144 2188
2145SV *registry (mapstruct *map) 2189SV *registry (maptile *map)
2146 CODE: 2190 CODE:
2147 RETVAL = registry_of (map); 2191 RETVAL = registry_of (map);
2148 OUTPUT: 2192 OUTPUT:
2149 RETVAL 2193 RETVAL
2150 2194
2151INCLUDE: $PERL genacc mapstruct ../include/map.h | 2195INCLUDE: $PERL genacc maptile ../include/map.h |
2152 2196
2153mapstruct *new (int width, int height) 2197maptile *new (int width, int height)
2154 PROTOTYPE: 2198 PROTOTYPE:
2155 CODE: 2199 CODE:
2156{ 2200{
2157 RETVAL = get_empty_map (width, height); 2201 RETVAL = get_empty_map (width, height);
2158} 2202}
2159 OUTPUT: 2203 OUTPUT:
2160 RETVAL 2204 RETVAL
2161 2205
2162void delete_map (mapstruct *map) 2206void delete_map (maptile *map)
2163 2207
2164void clean_tmp_map (mapstruct *map) 2208void clean_tmp_map (maptile *map)
2165 2209
2166void play_sound_map (mapstruct *map, int x, int y, int sound_num) 2210void play_sound_map (maptile *map, int x, int y, int sound_num)
2167 2211
2168mapstruct *tile_map (mapstruct *map, unsigned int dir) 2212maptile *tile_map (maptile *map, unsigned int dir)
2169 CODE: 2213 CODE:
2170 RETVAL = dir < 4 ? map->tile_map [dir] : 0; 2214 RETVAL = dir < 4 ? map->tile_map [dir] : 0;
2171 OUTPUT: 2215 OUTPUT:
2172 RETVAL 2216 RETVAL
2173 2217
2174char *tile_path (mapstruct *map, unsigned int dir) 2218char *tile_path (maptile *map, unsigned int dir)
2175 CODE: 2219 CODE:
2176 if (dir >= 4) 2220 if (dir >= 4)
2177 XSRETURN_UNDEF; 2221 XSRETURN_UNDEF;
2178 RETVAL = map->tile_path [dir]; 2222 RETVAL = map->tile_path [dir];
2179 OUTPUT: 2223 OUTPUT:
2180 RETVAL 2224 RETVAL
2181 2225
2182mapstruct *ready_map_name (char *name, int flags = 0) 2226maptile *ready_map_name (char *name, int flags = 0)
2183 PROTOTYPE: $;$ 2227 PROTOTYPE: $;$
2184 ALIAS: 2228 ALIAS:
2185 find = 0 2229 find = 0
2186 get_map = 1 2230 get_map = 1
2187 2231
2188mapstruct *has_been_loaded (char *name) 2232maptile *has_been_loaded (char *name)
2189 PROTOTYPE: $ 2233 PROTOTYPE: $
2190 2234
2191int in_memory (mapstruct *map) 2235int in_memory (maptile *map)
2192 CODE: 2236 CODE:
2193 RETVAL = map->in_memory; 2237 RETVAL = map->in_memory;
2194 OUTPUT: 2238 OUTPUT:
2195 RETVAL 2239 RETVAL
2196 2240
2197void 2241void
2198trigger (mapstruct *map, long connection, bool state = true) 2242trigger (maptile *map, long connection, bool state = true)
2199 CODE: 2243 CODE:
2200 activate_connection (map, connection, state); 2244 activate_connection (map, connection, state);
2201 2245
2202void 2246void
2203get_connection (mapstruct *map, long connection) 2247get_connection (maptile *map, long connection)
2204 PPCODE: 2248 PPCODE:
2205 oblinkpt *obp = get_connection_links (map, connection); 2249 oblinkpt *obp = get_connection_links (map, connection);
2206 if (obp) 2250 if (obp)
2207 for (objectlink *ol = obp->link; ol; ol = ol->next) 2251 for (objectlink *ol = obp->link; ol; ol = ol->next)
2208 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); 2252 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, (object *)ol->ob)));
2209 2253
2210object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) 2254object *cf_map_insert_object_there (maptile *where, object *op, object *originator, int flags)
2211 2255
2212object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) 2256object *cf_map_insert_object (maptile *where, object* op, int x, int y)
2213 2257
2214object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) 2258object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny)
2215 C_ARGS: str, map, nx, ny 2259 C_ARGS: str, map, nx, ny
2216 2260
2217void 2261void
2218cf_map_normalise (mapstruct *map, int x, int y) 2262cf_map_normalise (maptile *map, int x, int y)
2219 PPCODE: 2263 PPCODE:
2220{ 2264{
2221 mapstruct *nmap = 0; 2265 maptile *nmap = 0;
2222 I16 nx = 0, ny = 0; 2266 I16 nx = 0, ny = 0;
2223 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2267 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2224 2268
2225 EXTEND (SP, 4); 2269 EXTEND (SP, 4);
2226 PUSHs (sv_2mortal (newSViv (flags))); 2270 PUSHs (sv_2mortal (newSViv (flags)));
2232 PUSHs (sv_2mortal (newSViv (ny))); 2276 PUSHs (sv_2mortal (newSViv (ny)));
2233 } 2277 }
2234} 2278}
2235 2279
2236void 2280void
2237at (mapstruct *map, unsigned int x, unsigned int y) 2281at (maptile *map, unsigned int x, unsigned int y)
2238 PROTOTYPE: $$$ 2282 PROTOTYPE: $$$
2239 PPCODE: 2283 PPCODE:
2240{ 2284{
2241 object *o; 2285 object *o;
2242 mapstruct *nmap = 0; 2286 maptile *nmap = 0;
2243 I16 nx, ny; 2287 I16 nx, ny;
2244 2288
2245 get_map_flags (map, &nmap, x, y, &nx, &ny); 2289 get_map_flags (map, &nmap, x, y, &nx, &ny);
2246 2290
2247 if (nmap) 2291 if (nmap)
2248 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) 2292 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above)
2249 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 2293 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
2250} 2294}
2251 2295
2252SV * 2296SV *
2253bot_at (mapstruct *obj, unsigned int x, unsigned int y) 2297bot_at (maptile *obj, unsigned int x, unsigned int y)
2254 PROTOTYPE: $$$ 2298 PROTOTYPE: $$$
2255 ALIAS: 2299 ALIAS:
2256 top_at = 1 2300 top_at = 1
2257 flags_at = 2 2301 flags_at = 2
2258 light_at = 3 2302 light_at = 3
2280 2324
2281MODULE = cf PACKAGE = cf::arch 2325MODULE = cf PACKAGE = cf::arch
2282 2326
2283archetype *find (const char *name) 2327archetype *find (const char *name)
2284 CODE: 2328 CODE:
2285 RETVAL = find_archetype (name); 2329 RETVAL = archetype::find (name);
2286 OUTPUT: 2330 OUTPUT:
2287 RETVAL 2331 RETVAL
2288 2332
2289archetype *first() 2333archetype *first()
2290 PROTOTYPE: 2334 PROTOTYPE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines