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.56 by root, Tue Sep 12 22:18:56 2006 UTC vs.
Revision 1.68 by elmex, Sat Nov 18 23:16:19 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
187inline SV *to_sv (UUID v) {
188 char buf[128];
189 snprintf (buf, 128, "<1,%llx>", (unsigned long long)v.seq + UUID_SKIP * 2);
190 return newSVpv (buf, 0);
191}
192
195inline void sv_to (SV *sv, shstr &v) { v = SvPV_nolen (sv); } 193inline 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 194inline 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); } 195inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
198inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 196inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
199inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } 197inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); }
200inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } 198inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); }
201inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } 199inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); }
208inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } 206inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
209inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 207inline 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"); } 208inline 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"); } 209inline 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"); } 210inline 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"); } 211inline 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"); } 212inline 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"); } 213inline 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"); } 214inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
217 215
218inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO 216inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO
221template<class T> 219template<class T>
222inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 220inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
223 221
224template<int N> 222template<int N>
225inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } 223inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); }
224
225inline void sv_to (SV *sv, UUID &v) {
226 char *sv_str = SvOK (sv) ? SvPV_nolen (sv) : 0;
227 unsigned int version = 0;
228 unsigned long long seq = 0;
229
230 if (!sv_str)
231 return;
232
233 if (2 == sscanf (sv_str, "<%d.%llx>", &version, &seq) && version == 1)
234 {
235 v.seq = seq;
236 }
237
238 return;
239}
226 240
227static SV * 241static SV *
228newSVdt_va (va_list &ap, data_type type) 242newSVdt_va (va_list &ap, data_type type)
229{ 243{
230 SV *sv; 244 SV *sv;
262 sv = to_sv (va_arg (ap, object *)); 276 sv = to_sv (va_arg (ap, object *));
263 break; 277 break;
264 278
265 case DT_MAP: 279 case DT_MAP:
266 // va_arg (object *) when void * is passed is an XSI extension 280 // va_arg (object *) when void * is passed is an XSI extension
267 sv = to_sv (va_arg (ap, mapstruct *)); 281 sv = to_sv (va_arg (ap, maptile *));
268 break; 282 break;
269 283
270 case DT_PLAYER: 284 case DT_PLAYER:
271 sv = to_sv (va_arg (ap, player *)); 285 sv = to_sv (va_arg (ap, player *));
272 break; 286 break;
349 { 363 {
350 if (cb) 364 if (cb)
351 if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) 365 if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1)))
352 INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); 366 INVOKE_OBJECT (DESTROY, static_cast<object *>(this));
353 else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) 367 else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1)))
354 INVOKE_MAP (DESTROY, static_cast<mapstruct *>(this)); 368 INVOKE_MAP (DESTROY, static_cast<maptile *>(this));
355 369
356 // disconnect Perl from C, to avoid crashes 370 // disconnect Perl from C, to avoid crashes
357 sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); 371 sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext);
358 372
359 // clear the perl hash, might or might not be a good idea 373 // 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); 501 call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL);
488 FREETMPS; 502 FREETMPS;
489 LEAVE; 503 LEAVE;
490} 504}
491 505
506char *object_freezer::as_string ()
507{
508 dSP;
509 ENTER;
510 SAVETMPS;
511 PUSHMARK (SP);
512 EXTEND (SP, 3);
513 PUSHs (sv_2mortal (newRV_noinc (newSVpvn ((char *)linearise (), size ()))));
514 PUSHs (sv_2mortal (newRV_inc ((SV *)av)));
515 PUTBACK;
516
517 char *res = call_pv ("cf::object_freezer_as_string", G_SCALAR | G_EVAL) > 0
518 ? strdup (SvPVbyte_nolen (POPs))
519 : strdup ("[fatal error]");
520
521 FREETMPS;
522 LEAVE;
523
524 return res;
525}
526
492int fprintf (object_freezer &freezer, const char *format, ...) 527int fprintf (object_freezer &freezer, const char *format, ...)
493{ 528{
494 va_list ap; 529 va_list ap;
495 530
496 va_start (ap, format); 531 va_start (ap, format);
505 540
506int fputs (const char *s, object_freezer &freezer) 541int fputs (const char *s, object_freezer &freezer)
507{ 542{
508 freezer.add (s); 543 freezer.add (s);
509} 544}
545
546static const char thawer_eof[] = "\n\n\n\0\0\0";
510 547
511object_thawer::object_thawer (const char *filename) 548object_thawer::object_thawer (const char *filename)
512{ 549{
513 static const char eof[] = "\n\n\n\0\0\0"; 550 static const char eof[] = "\n\n\n\0\0\0";
514 551
552 589
553 PUTBACK; 590 PUTBACK;
554 FREETMPS; 591 FREETMPS;
555 LEAVE; 592 LEAVE;
556 } 593 }
594}
595
596object_thawer::object_thawer (const char *data, AV *perlav)
597{
598 av = perlav;
599 text = newSVpv (data, 0);
600 sv_catpv (text, thawer_eof);
601 line = SvPVbyte_nolen (text);
557} 602}
558 603
559void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) 604void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid)
560{ 605{
561 if (!av || oid < 0) // this is actually an error of sorts 606 if (!av || oid < 0) // this is actually an error of sorts
939 984
940 AV *callbacks = 0; 985 AV *callbacks = 0;
941 986
942 object *op; 987 object *op;
943 player *pl; 988 player *pl;
944 mapstruct *map; 989 maptile *map;
945 990
946 // callback call ordering is: 991 // callback call ordering is:
947 // 1. per-object callback (NYI) 992 // 1. per-object callback (NYI)
948 // 2. per-class object 993 // 2. per-class object
949 // 2a. per-type callback 994 // 2a. per-type callback
999 break; 1044 break;
1000 1045
1001 case KLASS_MAP: 1046 case KLASS_MAP:
1002 dt = (data_type) va_arg (ap, int); 1047 dt = (data_type) va_arg (ap, int);
1003 assert (("first argument must be of type object", dt == DT_MAP)); 1048 assert (("first argument must be of type object", dt == DT_MAP));
1004 map = va_arg (ap, mapstruct *); 1049 map = va_arg (ap, maptile *);
1005 1050
1006 if (map->cb) 1051 if (map->cb)
1007 gather_callbacks (callbacks, map->cb, event); 1052 gather_callbacks (callbacks, map->cb, event);
1008 1053
1009 gather_callbacks (callbacks, cb_map, event); 1054 gather_callbacks (callbacks, cb_map, event);
1089MODULE = cf PACKAGE = cf PREFIX = cf_ 1134MODULE = cf PACKAGE = cf PREFIX = cf_
1090 1135
1091BOOT: 1136BOOT:
1092{ 1137{
1093 HV *stash = gv_stashpv ("cf", 1); 1138 HV *stash = gv_stashpv ("cf", 1);
1139
1140 newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1094 1141
1095 static const struct { 1142 static const struct {
1096 const char *name; 1143 const char *name;
1097 IV iv; 1144 IV iv;
1098 } *civ, const_iv[] = { 1145 } *civ, const_iv[] = {
1391 const_iv (NDI_MAX_COLOR) 1438 const_iv (NDI_MAX_COLOR)
1392 const_iv (NDI_COLOR_MASK) 1439 const_iv (NDI_COLOR_MASK)
1393 const_iv (NDI_UNIQUE) 1440 const_iv (NDI_UNIQUE)
1394 const_iv (NDI_ALL) 1441 const_iv (NDI_ALL)
1395 1442
1443 const_iv (UPD_LOCATION)
1444 const_iv (UPD_FLAGS)
1445 const_iv (UPD_WEIGHT)
1446 const_iv (UPD_FACE)
1447 const_iv (UPD_NAME)
1448 const_iv (UPD_ANIM)
1449 const_iv (UPD_ANIMSPEED)
1450 const_iv (UPD_NROF)
1451
1452 const_iv (UPD_SP_MANA)
1453 const_iv (UPD_SP_GRACE)
1454 const_iv (UPD_SP_DAMAGE)
1455
1396 const_iv (F_APPLIED) 1456 const_iv (F_APPLIED)
1397 const_iv (F_LOCATION) 1457 const_iv (F_LOCATION)
1398 const_iv (F_UNPAID) 1458 const_iv (F_UNPAID)
1399 const_iv (F_MAGIC) 1459 const_iv (F_MAGIC)
1400 const_iv (F_CURSED) 1460 const_iv (F_CURSED)
1613{ 1673{
1614 // reattach to all attachable objects in the game. 1674 // reattach to all attachable objects in the game.
1615 for (player *pl = first_player; pl; pl = pl->next) 1675 for (player *pl = first_player; pl; pl = pl->next)
1616 reattach (pl); 1676 reattach (pl);
1617 1677
1618 for (mapstruct *map = first_map; map; map = map->next) 1678 for (maptile *map = first_map; map; map = map->next)
1619 reattach (map); 1679 reattach (map);
1620 1680
1621 for (object *op = objects; op; op = op->next) 1681 for (object *op = object::first; op; op = op->next)
1622 reattach (op); 1682 reattach (op);
1623} 1683}
1624 1684
1625NV floor (NV x) 1685NV floor (NV x)
1626 1686
1739 OUTPUT: 1799 OUTPUT:
1740 RETVAL 1800 RETVAL
1741 1801
1742MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1802MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1743 1803
1804INCLUDE: $PERL genacc object ../include/object.h |
1805
1744int invoke (object *op, int event, ...) 1806int invoke (object *op, int event, ...)
1745 CODE: 1807 CODE:
1746 if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); 1808 if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT");
1747 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 1809 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
1748 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 1810 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
1753 CODE: 1815 CODE:
1754 RETVAL = registry_of (op); 1816 RETVAL = registry_of (op);
1755 OUTPUT: 1817 OUTPUT:
1756 RETVAL 1818 RETVAL
1757 1819
1758INCLUDE: $PERL genacc object ../include/object.h | 1820void mortals ()
1821 PPCODE:
1822 EXTEND (SP, object::mortals.size ());
1823 for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i)
1824 PUSHs (to_sv (*i));
1825
1826object *first ()
1827 CODE:
1828 RETVAL = object::first;
1829 OUTPUT: RETVAL
1759 1830
1760# missing properties 1831# missing properties
1761 1832
1762int flag (object *op, int flag, int value = 1) 1833int flag (object *op, int flag, int value = 1)
1763 PROTOTYPE: $$;$ 1834 PROTOTYPE: $$;$
1790 object *o; 1861 object *o;
1791 for (o = obj->inv; o; o = o->below) 1862 for (o = obj->inv; o; o = o->below)
1792 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1863 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
1793} 1864}
1794 1865
1866object *find_best_object_match (object *op, const char *match)
1867
1868object *find_marked_object (object *op)
1869
1795int cf_object_get_resistance (object *op, int rtype) 1870int cf_object_get_resistance (object *op, int rtype)
1796 ALIAS: resistance = 0 1871 ALIAS: resistance = 0
1797 1872
1798int need_identify (const object *obj); 1873int need_identify (const object *obj);
1799 1874
1815 1890
1816object *cf_object_present_archname_inside (object *op, char *whatstr) 1891object *cf_object_present_archname_inside (object *op, char *whatstr)
1817 1892
1818int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) 1893int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0)
1819 1894
1820int cf_object_change_map (object *op, int x, int y, mapstruct *map) 1895int cf_object_change_map (object *op, int x, int y, maptile *map)
1821 1896
1822object *cf_object_clone (object *op, int clonetype = 0) 1897object *cf_object_clone (object *op, int clonetype = 0)
1823 1898
1824int cf_object_pay_item (object *op, object *buyer) 1899int cf_object_pay_item (object *op, object *buyer)
1825 1900
1857 1932
1858object *cf_object_insert_object (object *op, object *container) 1933object *cf_object_insert_object (object *op, object *container)
1859 1934
1860object *cf_object_insert_in_ob (object *ob, object *where) 1935object *cf_object_insert_in_ob (object *ob, object *where)
1861 1936
1862int cf_object_teleport (object *op, mapstruct *map, int x, int y) 1937int cf_object_teleport (object *op, maptile *map, int x, int y)
1863 1938
1864void cf_object_update (object *op, int flags) 1939void cf_object_update (object *op, int flags)
1865 1940
1866void cf_object_pickup (object *op, object *what) 1941void cf_object_pickup (object *op, object *what)
1867 1942
1877 1952
1878void push_button (object *op); 1953void push_button (object *op);
1879 1954
1880void use_trigger (object *op); 1955void use_trigger (object *op);
1881 1956
1882void add_button_link (object *button, mapstruct *map, int connected); 1957void add_button_link (object *button, maptile *map, int connected);
1883 1958
1884void remove_button_link (object *op); 1959void remove_button_link (object *op);
1885 1960
1886void 1961void
1887cf_object_set_resistance (object *op, int rtype, int val) 1962cf_object_set_resistance (object *op, int rtype, int val)
1905 CODE: 1980 CODE:
1906 RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); 1981 RETVAL = archetype ? get_archetype (archetype) : cf_create_object ();
1907 OUTPUT: 1982 OUTPUT:
1908 RETVAL 1983 RETVAL
1909 1984
1910object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y) 1985object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y)
1911 PROTOTYPE: $$$$$$ 1986 PROTOTYPE: $$$$$$
1912 CODE: 1987 CODE:
1913{ 1988{
1914 int unused_type; 1989 int unused_type;
1915 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); 1990 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y);
1953bool on_same_map_as (object *ob, object *other) 2028bool on_same_map_as (object *ob, object *other)
1954 CODE: 2029 CODE:
1955 RETVAL = on_same_map (ob, other); 2030 RETVAL = on_same_map (ob, other);
1956 OUTPUT: RETVAL 2031 OUTPUT: RETVAL
1957 2032
1958char * 2033const char *
1959base_name (object *ob, int plural) 2034base_name (object *op, int plural = op->nrof > 1)
1960 CODE: 2035 CODE:
1961 RETVAL = cf_query_base_name (ob, plural); 2036 RETVAL = query_base_name (op, plural);
1962 OUTPUT: RETVAL 2037 OUTPUT: RETVAL
1963 2038
1964MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 2039MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
1965 2040
1966player *player (object *op) 2041player *player (object *op)
1985 2060
1986void cf_player_set_party (object *op, partylist *party) 2061void cf_player_set_party (object *op, partylist *party)
1987 2062
1988void kill_player (object *op) 2063void kill_player (object *op)
1989 2064
2065void esrv_update_item (object *op, int what, object *item)
2066 C_ARGS: what, op, item
2067
2068void clear_los (object *op)
2069
2070int command_reset (object *op, char *params)
2071
2072int command_teleport (object *op, char *params)
2073
2074int command_summon (object *op, char *params)
2075
2076int command_arrest (object *op, char *params)
2077
2078int command_kick (object *op, char *params)
2079
2080int command_banish (object *op, char *params)
2081
2082
1990MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ 2083MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
2084
2085INCLUDE: $PERL genacc player ../include/newserver.h ../include/player.h |
2086
2087char *
2088client (player *pl)
2089 CODE:
2090 RETVAL = pl->socket.client;
2091 OUTPUT:
2092 RETVAL
2093
2094char *
2095host (player *pl)
2096 CODE:
2097 RETVAL = pl->socket.host;
2098 OUTPUT:
2099 RETVAL
1991 2100
1992int invoke (player *pl, int event, ...) 2101int invoke (player *pl, int event, ...)
1993 CODE: 2102 CODE:
1994 if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); 2103 if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER");
1995 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2104 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2008 2117
2009void cf_player_move (player *pl, int dir) 2118void cf_player_move (player *pl, int dir)
2010 2119
2011void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2120void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
2012 2121
2013# nonstandard
2014object *ob (player *pl)
2015 CODE:
2016 RETVAL = pl->ob;
2017 OUTPUT: RETVAL
2018
2019player *first () 2122player *first ()
2020 CODE: 2123 CODE:
2021 RETVAL = first_player; 2124 RETVAL = first_player;
2022 OUTPUT: RETVAL 2125 OUTPUT: RETVAL
2023 2126
2029bool 2132bool
2030cell_visible (player *pl, int dx, int dy) 2133cell_visible (player *pl, int dx, int dy)
2031 CODE: 2134 CODE:
2032 RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 2135 RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2
2033 && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; 2136 && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2];
2034 OUTPUT:
2035 RETVAL
2036
2037char *
2038client (player *pl)
2039 CODE:
2040 RETVAL = pl->socket.client;
2041 OUTPUT:
2042 RETVAL
2043
2044char *
2045host (player *pl)
2046 CODE:
2047 RETVAL = pl->socket.host;
2048 OUTPUT:
2049 RETVAL
2050
2051char *
2052killer (player *pl, char *killer = 0)
2053 CODE:
2054 if (killer)
2055 snprintf (pl->killer, sizeof (pl->killer), "%s", killer);
2056 RETVAL = pl->killer;
2057 OUTPUT: 2137 OUTPUT:
2058 RETVAL 2138 RETVAL
2059 2139
2060void 2140void
2061buggy_mapscroll (player *pl, int value = 1) 2141buggy_mapscroll (player *pl, int value = 1)
2127 OUTPUT: RETVAL 2207 OUTPUT: RETVAL
2128 2208
2129 2209
2130MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ 2210MODULE = cf PACKAGE = cf::map PREFIX = cf_map_
2131 2211
2132mapstruct *first () 2212maptile *first ()
2133 PROTOTYPE: 2213 PROTOTYPE:
2134 CODE: 2214 CODE:
2135 RETVAL = first_map; 2215 RETVAL = first_map;
2136 OUTPUT: RETVAL 2216 OUTPUT: RETVAL
2137 2217
2138int invoke (mapstruct *map, int event, ...) 2218int invoke (maptile *map, int event, ...)
2139 CODE: 2219 CODE:
2140 if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); 2220 if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP");
2141 AV *av = (AV *)sv_2mortal ((SV *)newAV ()); 2221 AV *av = (AV *)sv_2mortal ((SV *)newAV ());
2142 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); 2222 for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i)));
2143 RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av)); 2223 RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av));
2144 OUTPUT: RETVAL 2224 OUTPUT: RETVAL
2145 2225
2146SV *registry (mapstruct *map) 2226SV *registry (maptile *map)
2147 CODE: 2227 CODE:
2148 RETVAL = registry_of (map); 2228 RETVAL = registry_of (map);
2149 OUTPUT: 2229 OUTPUT:
2150 RETVAL 2230 RETVAL
2151 2231
2152INCLUDE: $PERL genacc mapstruct ../include/map.h | 2232INCLUDE: $PERL genacc maptile ../include/map.h |
2153 2233
2154mapstruct *new (int width, int height) 2234maptile *new (int width, int height)
2155 PROTOTYPE: 2235 PROTOTYPE:
2156 CODE: 2236 CODE:
2157{ 2237{
2158 RETVAL = get_empty_map (width, height); 2238 RETVAL = get_empty_map (width, height);
2159} 2239}
2160 OUTPUT: 2240 OUTPUT:
2161 RETVAL 2241 RETVAL
2162 2242
2163void delete_map (mapstruct *map) 2243void delete_map (maptile *map)
2164 2244
2165void clean_tmp_map (mapstruct *map) 2245void clean_tmp_map (maptile *map)
2166 2246
2167void play_sound_map (mapstruct *map, int x, int y, int sound_num) 2247void play_sound_map (maptile *map, int x, int y, int sound_num)
2168 2248
2169mapstruct *tile_map (mapstruct *map, unsigned int dir) 2249maptile *tile_map (maptile *map, unsigned int dir)
2170 CODE: 2250 CODE:
2171 RETVAL = dir < 4 ? map->tile_map [dir] : 0; 2251 RETVAL = dir < 4 ? map->tile_map [dir] : 0;
2172 OUTPUT: 2252 OUTPUT:
2173 RETVAL 2253 RETVAL
2174 2254
2175char *tile_path (mapstruct *map, unsigned int dir) 2255char *tile_path (maptile *map, unsigned int dir)
2176 CODE: 2256 CODE:
2177 if (dir >= 4) 2257 if (dir >= 4)
2178 XSRETURN_UNDEF; 2258 XSRETURN_UNDEF;
2179 RETVAL = map->tile_path [dir]; 2259 RETVAL = map->tile_path [dir];
2180 OUTPUT: 2260 OUTPUT:
2181 RETVAL 2261 RETVAL
2182 2262
2183mapstruct *ready_map_name (char *name, int flags = 0) 2263maptile *ready_map_name (char *name, int flags = 0)
2184 PROTOTYPE: $;$ 2264 PROTOTYPE: $;$
2185 ALIAS: 2265 ALIAS:
2186 find = 0 2266 find = 0
2187 get_map = 1 2267 get_map = 1
2188 2268
2189mapstruct *has_been_loaded (char *name) 2269maptile *has_been_loaded (char *name)
2190 PROTOTYPE: $ 2270 PROTOTYPE: $
2191 2271
2192int in_memory (mapstruct *map) 2272int in_memory (maptile *map)
2193 CODE: 2273 CODE:
2194 RETVAL = map->in_memory; 2274 RETVAL = map->in_memory;
2195 OUTPUT: 2275 OUTPUT:
2196 RETVAL 2276 RETVAL
2197 2277
2198void 2278void
2199trigger (mapstruct *map, long connection, bool state = true) 2279trigger (maptile *map, long connection, bool state = true)
2200 CODE: 2280 CODE:
2201 activate_connection (map, connection, state); 2281 activate_connection (map, connection, state);
2202 2282
2203void 2283void
2204get_connection (mapstruct *map, long connection) 2284get_connection (maptile *map, long connection)
2205 PPCODE: 2285 PPCODE:
2206 oblinkpt *obp = get_connection_links (map, connection); 2286 oblinkpt *obp = get_connection_links (map, connection);
2207 if (obp) 2287 if (obp)
2208 for (objectlink *ol = obp->link; ol; ol = ol->next) 2288 for (objectlink *ol = obp->link; ol; ol = ol->next)
2209 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); 2289 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, (object *)ol->ob)));
2210 2290
2211object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) 2291object *cf_map_insert_object_there (maptile *where, object *op, object *originator, int flags)
2212 2292
2213object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) 2293object *cf_map_insert_object (maptile *where, object* op, int x, int y)
2214 2294
2215object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) 2295object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny)
2216 C_ARGS: str, map, nx, ny 2296 C_ARGS: str, map, nx, ny
2217 2297
2218void 2298void
2219cf_map_normalise (mapstruct *map, int x, int y) 2299cf_map_normalise (maptile *map, int x, int y)
2220 PPCODE: 2300 PPCODE:
2221{ 2301{
2222 mapstruct *nmap = 0; 2302 maptile *nmap = 0;
2223 I16 nx = 0, ny = 0; 2303 I16 nx = 0, ny = 0;
2224 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2304 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2225 2305
2226 EXTEND (SP, 4); 2306 EXTEND (SP, 4);
2227 PUSHs (sv_2mortal (newSViv (flags))); 2307 PUSHs (sv_2mortal (newSViv (flags)));
2233 PUSHs (sv_2mortal (newSViv (ny))); 2313 PUSHs (sv_2mortal (newSViv (ny)));
2234 } 2314 }
2235} 2315}
2236 2316
2237void 2317void
2238at (mapstruct *map, unsigned int x, unsigned int y) 2318at (maptile *map, unsigned int x, unsigned int y)
2239 PROTOTYPE: $$$ 2319 PROTOTYPE: $$$
2240 PPCODE: 2320 PPCODE:
2241{ 2321{
2242 object *o; 2322 object *o;
2243 mapstruct *nmap = 0; 2323 maptile *nmap = 0;
2244 I16 nx, ny; 2324 I16 nx, ny;
2245 2325
2246 get_map_flags (map, &nmap, x, y, &nx, &ny); 2326 get_map_flags (map, &nmap, x, y, &nx, &ny);
2247 2327
2248 if (nmap) 2328 if (nmap)
2249 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) 2329 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above)
2250 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 2330 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
2251} 2331}
2252 2332
2253SV * 2333SV *
2254bot_at (mapstruct *obj, unsigned int x, unsigned int y) 2334bot_at (maptile *obj, unsigned int x, unsigned int y)
2255 PROTOTYPE: $$$ 2335 PROTOTYPE: $$$
2256 ALIAS: 2336 ALIAS:
2257 top_at = 1 2337 top_at = 1
2258 flags_at = 2 2338 flags_at = 2
2259 light_at = 3 2339 light_at = 3
2281 2361
2282MODULE = cf PACKAGE = cf::arch 2362MODULE = cf PACKAGE = cf::arch
2283 2363
2284archetype *find (const char *name) 2364archetype *find (const char *name)
2285 CODE: 2365 CODE:
2286 RETVAL = find_archetype (name); 2366 RETVAL = archetype::find (name);
2287 OUTPUT: 2367 OUTPUT:
2288 RETVAL 2368 RETVAL
2289 2369
2290archetype *first() 2370archetype *first()
2291 PROTOTYPE: 2371 PROTOTYPE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines