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.237 by root, Mon Jul 23 23:46:03 2007 UTC vs.
Revision 1.250 by root, Sat Sep 8 10:14:10 2007 UTC

53#include "CoroAPI.h" 53#include "CoroAPI.h"
54#include "perlxsi.c" 54#include "perlxsi.c"
55 55
56extern sint64 *levels; // the experience table 56extern sint64 *levels; // the experience table
57 57
58typedef object object_ornull; 58typedef object_thawer &object_thawer_ref;
59typedef maptile maptile_ornull; 59typedef object_freezer &object_freezer_ref;
60
61typedef char *octet_string;
62typedef char *utf8_string;
63typedef const char *const_octet_string;
64typedef const char *const_utf8_string;
65 60
66typedef std::string std__string; 61typedef std::string std__string;
67 62
68#if IVSIZE >= 8 63#if IVSIZE >= 8
69 typedef IV val64; 64 typedef IV val64;
99 *stash_cf_arch_wrap, 94 *stash_cf_arch_wrap,
100 *stash_cf_party_wrap, 95 *stash_cf_party_wrap,
101 *stash_cf_region_wrap, 96 *stash_cf_region_wrap,
102 *stash_cf_living_wrap; 97 *stash_cf_living_wrap;
103 98
99static inline SV *
100newSVpv_utf8 (const char *s)
101{
102 SV *sv = newSVpv (s, 0);
103 SvUTF8_on (sv);
104 return sv;
105}
106
107static inline SV *
108newSVpvn_utf8 (const char *s, STRLEN l)
109{
110 SV *sv = newSVpvn (s, l);
111 SvUTF8_on (sv);
112 return sv;
113}
114
104// helper cast function, returns super class * or 0 115// helper cast function, returns super class * or 0
105template<class super> 116template<class super>
106static super * 117static super *
107is_a (attachable *at) 118is_a (attachable *at)
108{ 119{
247 } 258 }
248 } 259 }
249} 260}
250 261
251void 262void
252attachable::set_key (const char *key, const char *value) 263attachable::set_key (const char *key, const char *value, bool is_utf8)
253{ 264{
254 if (!self) 265 if (!self)
255 self = newHV (); 266 self = newHV ();
256 267
257 if (value) 268 if (value)
258 hv_store (self, key, strlen (key), newSVpv (value, 0), 0); 269 hv_store (self, key, strlen (key), is_utf8 ? newSVpv_utf8 (value) : newSVpv (value, 0), 0);
259 else 270 else
260 hv_delete (self, key, strlen (key), G_DISCARD); 271 hv_delete (self, key, strlen (key), G_DISCARD);
261} 272}
262 273
263attachable & 274attachable &
396 return SvPTR (sv, klass); 407 return SvPTR (sv, klass);
397 else 408 else
398 return 0; 409 return 0;
399} 410}
400 411
401static inline SV *
402newSVpv_utf8 (const char *s)
403{
404 SV *sv = newSVpv (s, 0);
405 SvUTF8_on (sv);
406 return sv;
407}
408
409static inline SV *
410newSVpvn_utf8 (const char *s, STRLEN l)
411{
412 SV *sv = newSVpvn (s, l);
413 SvUTF8_on (sv);
414 return sv;
415}
416
417inline SV *to_sv (const shstr & v) { return v ? newSVpvn_utf8 ((const char *)v, v.length ()) : &PL_sv_undef; } 412inline SV *to_sv (const shstr & v) { return v ? newSVpvn_utf8 ((const char *)v, v.length ()) : &PL_sv_undef; }
418inline SV *to_sv (const char * v) { return newSVpv (v, 0); } 413inline SV *to_sv (const char * v) { return v ? newSVpv (v, 0) : &PL_sv_undef; }
419inline SV *to_sv (bool v) { return newSViv (v); } 414inline SV *to_sv (bool v) { return newSViv (v); }
420inline SV *to_sv ( signed char v) { return newSViv (v); } 415inline SV *to_sv ( signed char v) { return newSViv (v); }
421inline SV *to_sv (unsigned char v) { return newSViv (v); } 416inline SV *to_sv (unsigned char v) { return newSViv (v); }
422inline SV *to_sv ( signed short v) { return newSViv (v); } 417inline SV *to_sv ( signed short v) { return newSViv (v); }
423inline SV *to_sv (unsigned short v) { return newSVuv (v); } 418inline SV *to_sv (unsigned short v) { return newSVuv (v); }
449 char buf[128]; 444 char buf[128];
450 snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); 445 snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq);
451 return newSVpv (buf, 0); 446 return newSVpv (buf, 0);
452} 447}
453 448
454inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } 449inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; }
455inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } 450inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; }
456inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } 451inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
457inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 452inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
458inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } 453inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); }
459inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } 454inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); }
460inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } 455inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); }
461inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } 456inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); }
462inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } 457inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); }
463inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } 458inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); }
464inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } 459inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); }
465inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } 460inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); }
466inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } 461inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); }
467inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } 462inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
468inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 463inline void sv_to (SV *sv, double &v) { v = SvNV (sv); }
469inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } 464inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); }
470inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } 465inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); }
471inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } 466inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); }
472inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } 467inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); }
473inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } 468inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); }
474inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } 469inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); }
475inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 470inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
476inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 471inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
477inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 472inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
473inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); }
474inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); }
478 475
479//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } 476//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
480inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } 477inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); }
481 478
482template<class T> 479template<class T>
483inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 480inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
484 481
485template<int N> 482template<int N>
486inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } 483inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); }
487 484
488inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } 485inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); }
489inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } 486inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); }
490inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } 487inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); }
491inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } 488inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); }
492 489
493inline void sv_to (SV *sv, std::string &v) 490inline void sv_to (SV *sv, std::string &v)
494{ 491{
495 STRLEN len; 492 STRLEN len;
496 char *data = SvPVbyte (sv, len); 493 char *data = SvPVbyte (sv, len);
497 v.assign (data, len); 494 v.assign (data, len);
498} 495}
499 496
500inline void sv_to (SV *sv, UUID &v) 497inline void sv_to (SV *sv, UUID &v)
501{ 498{
502 unsigned int version; 499 unsigned int version;
503 500
504 if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) 501 if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version)
505 croak ("unparsable uuid: %s", SvPV_nolen (sv)); 502 croak ("unparsable uuid: %s", SvPV_nolen (sv));
988{ 985{
989 return SvNV (cfperl_result (idx)); 986 return SvNV (cfperl_result (idx));
990} 987}
991 988
992///////////////////////////////////////////////////////////////////////////// 989/////////////////////////////////////////////////////////////////////////////
990// various c++ => perl glue functions
993 991
994void 992void
995cfperl_emergency_save () 993cfperl_emergency_save ()
996{ 994{
997 CALL_BEGIN (0); 995 CALL_BEGIN (0);
1043 CALL_END; 1041 CALL_END;
1044 1042
1045 return can; 1043 return can;
1046} 1044}
1047 1045
1046player *
1047player::find (const char *name)
1048{
1049 CALL_BEGIN (1);
1050 CALL_ARG (name);
1051 CALL_CALL ("cf::player::find", G_SCALAR);
1052
1053 player *retval;
1054
1055 if (count)
1056 sv_to (POPs, retval);
1057 else
1058 retval = 0;
1059
1060 CALL_END;
1061
1062 return retval;
1063}
1064
1048maptile * 1065maptile *
1049maptile::find_sync (const char *path, maptile *origin) 1066maptile::find_sync (const char *path, maptile *origin)
1050{ 1067{
1051 CALL_BEGIN (2); 1068 CALL_BEGIN (2);
1052 CALL_ARG (path); 1069 CALL_ARG (path);
1064 1081
1065 return retval; 1082 return retval;
1066} 1083}
1067 1084
1068maptile * 1085maptile *
1069maptile::find_async (const char *path, maptile *origin) 1086maptile::find_async (const char *path, maptile *origin, bool load)
1070{ 1087{
1071 CALL_BEGIN (2); 1088 CALL_BEGIN (3);
1072 CALL_ARG (path); 1089 CALL_ARG (path);
1073 CALL_ARG (origin); 1090 CALL_ARG (origin);
1091 CALL_ARG (load);
1074 CALL_CALL ("cf::map::find_async", G_SCALAR); 1092 CALL_CALL ("cf::map::find_async", G_SCALAR);
1075 1093
1076 maptile *retval; 1094 maptile *retval;
1077 1095
1078 if (count) 1096 if (count)
1112 CALL_BEGIN (2); 1130 CALL_BEGIN (2);
1113 CALL_ARG (this); 1131 CALL_ARG (this);
1114 CALL_ARG (exit); 1132 CALL_ARG (exit);
1115 CALL_CALL ("cf::object::player::enter_exit", G_VOID); 1133 CALL_CALL ("cf::object::player::enter_exit", G_VOID);
1116 CALL_END; 1134 CALL_END;
1135}
1136
1137const char *
1138object::ref () const
1139{
1140 if (type == PLAYER)
1141 return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name);
1142 else
1143 return 0;
1144}
1145
1146object *
1147object::deref (const char *ref)
1148{
1149 object *retval = 0;
1150
1151 if (ref)
1152 {
1153 CALL_BEGIN (1);
1154 CALL_ARG (ref);
1155 CALL_CALL ("cf::object::deref", G_SCALAR);
1156
1157 if (count)
1158 sv_to (POPs, retval);
1159
1160 CALL_END;
1161 }
1162
1163 return retval;
1117} 1164}
1118 1165
1119void 1166void
1120log_backtrace (const char *msg) 1167log_backtrace (const char *msg)
1121{ 1168{
1376 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) 1423 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED)
1377 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) 1424 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON)
1378 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) 1425 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON)
1379 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_CLIENT_SENT) const_iv (FLAG_BERSERK) 1426 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_CLIENT_SENT) const_iv (FLAG_BERSERK)
1380 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) 1427 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL)
1381 const_iv (FLAG_OBJ_SAVE_ON_OVL) const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) 1428 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER)
1382 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) 1429 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE)
1383 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) 1430 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE)
1384 1431
1385 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) 1432 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED)
1386 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) 1433 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN)
1387 const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD) 1434 const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD)
1388 const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE) 1435 const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE)
1389 const_iv (NDI_ALL) 1436 const_iv (NDI_ALL) const_iv (NDI_DEF) const_iv (NDI_REPLY) const_iv (NDI_CLIENT_MASK)
1437 const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR)
1390 1438
1391 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) 1439 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE)
1392 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF) 1440 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF)
1393 1441
1394 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) 1442 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE)
1521 const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) 1569 const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY)
1522 1570
1523 const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) 1571 const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP)
1524 const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV) 1572 const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV)
1525 const_iv (GT_MINIMAL) 1573 const_iv (GT_MINIMAL)
1574
1575 const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND)
1576 const_iv (FT_RSRC) const_iv (FT_NUM)
1526 }; 1577 };
1527 1578
1528 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1579 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1529 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); 1580 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv));
1530 1581
1673octet_string path_combine (octet_string base, octet_string path) 1724octet_string path_combine (octet_string base, octet_string path)
1674 PROTOTYPE: $$ 1725 PROTOTYPE: $$
1675 1726
1676octet_string path_combine_and_normalize (octet_string base, octet_string path) 1727octet_string path_combine_and_normalize (octet_string base, octet_string path)
1677 PROTOTYPE: $$ 1728 PROTOTYPE: $$
1678
1679const_octet_string
1680get_maps_directory (octet_string path)
1681 PROTOTYPE: $
1682 ALIAS: maps_directory = 0
1683 CODE:
1684 RETVAL = create_pathname (path);
1685 OUTPUT: RETVAL
1686 1729
1687void 1730void
1688sub_generation_inc () 1731sub_generation_inc ()
1689 CODE: 1732 CODE:
1690 PL_sub_generation++; 1733 PL_sub_generation++;
1812#object *mortals (U32 index) 1855#object *mortals (U32 index)
1813# CODE: 1856# CODE:
1814# RETVAL = index < attachable::mortals.size () ? attachable::mortals [index] : 0; 1857# RETVAL = index < attachable::mortals.size () ? attachable::mortals [index] : 0;
1815# OUTPUT: RETVAL 1858# OUTPUT: RETVAL
1816 1859
1817INCLUDE: $PERL $srcdir/genacc attachable ../include/cfperl.h | 1860INCLUDE: $PERL $srcdir/genacc attachable ../include/util.h ../include/cfperl.h |
1818 1861
1819MODULE = cf PACKAGE = cf::global 1862MODULE = cf PACKAGE = cf::global
1820 1863
1821int invoke (SV *klass, int event, ...) 1864int invoke (SV *klass, int event, ...)
1822 CODE: 1865 CODE:
2148 pl->orig_stats = pl->ob->stats; 2191 pl->orig_stats = pl->ob->stats;
2149 2192
2150void clear_los (player *pl) 2193void clear_los (player *pl)
2151 2194
2152void cf_player_move (player *pl, int dir) 2195void cf_player_move (player *pl, int dir)
2153
2154void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
2155 2196
2156bool 2197bool
2157cell_visible (player *pl, int dx, int dy) 2198cell_visible (player *pl, int dx, int dy)
2158 CODE: 2199 CODE:
2159 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 2200 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2
2338 } 2379 }
2339 } 2380 }
2340 2381
2341 op->destroy (); 2382 op->destroy ();
2342} 2383}
2343
2344void play_sound_map (maptile *map, int x, int y, int sound_num)
2345 2384
2346int out_of_map (maptile *map, int x, int y) 2385int out_of_map (maptile *map, int x, int y)
2347 2386
2348void 2387void
2349trigger (maptile *map, long connection, bool state = true) 2388trigger (maptile *map, long connection, bool state = true)
2519 OUTPUT: 2558 OUTPUT:
2520 RETVAL 2559 RETVAL
2521 2560
2522MODULE = cf PACKAGE = cf::arch 2561MODULE = cf PACKAGE = cf::arch
2523 2562
2524archetype *find (utf8_string name)
2525 CODE:
2526 RETVAL = archetype::find (name);
2527 OUTPUT:
2528 RETVAL
2529
2530int archetypes_size () 2563int archetypes_size ()
2531 CODE: 2564 CODE:
2532 RETVAL = archetypes.size (); 2565 RETVAL = archetypes.size ();
2533 OUTPUT: RETVAL 2566 OUTPUT: RETVAL
2534 2567
2622 2655
2623 THIS->send_packet (buf, len); 2656 THIS->send_packet (buf, len);
2624} 2657}
2625 2658
2626faceidx 2659faceidx
2627client::find_face (utf8_string name, faceidx defidx = 0) 2660client::need_face (utf8_string name, int pri = 0)
2628 CODE: 2661 CODE:
2629 RETVAL = face_find (name, defidx); 2662 RETVAL = face_find (name, 0);
2663 if (RETVAL)
2664 {
2630 THIS->send_face (RETVAL); 2665 THIS->send_face (RETVAL, pri);
2631 THIS->flush_fx (); 2666 THIS->flush_fx ();
2667 }
2632 OUTPUT: 2668 OUTPUT:
2633 RETVAL 2669 RETVAL
2670
2671int
2672client::fx_want (int idx, int value = -1)
2673 CODE:
2674 if (0 < idx && idx < FT_NUM)
2675 {
2676 RETVAL = THIS->fx_want [idx];
2677 if (items > 2)
2678 THIS->fx_want [idx] = value;
2679 }
2680 else
2681 RETVAL = 0;
2682 OUTPUT:
2683 RETVAL
2684
2685MODULE = cf PACKAGE = cf::sound PREFIX = sound_
2686
2687faceidx sound_find (utf8_string name)
2688
2689void sound_set (utf8_string str, faceidx face)
2690
2691# dire hack
2692void old_sound_index (int idx, faceidx face)
2693 CODE:
2694 extern faceidx old_sound_index [SOUND_CAST_SPELL_0];
2695 old_sound_index [idx] = face;
2634 2696
2635MODULE = cf PACKAGE = cf::face PREFIX = face_ 2697MODULE = cf PACKAGE = cf::face PREFIX = face_
2636 2698
2637#INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | 2699#INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h |
2638 2700
2762void invalidate_all () 2824void invalidate_all ()
2763 CODE: 2825 CODE:
2764 for_all_clients (ns) 2826 for_all_clients (ns)
2765 ns->anims_sent.reset (); 2827 ns->anims_sent.reset ();
2766 2828
2829MODULE = cf PACKAGE = cf::object::freezer
2830
2831INCLUDE: $PERL $srcdir/genacc object_freezer ../include/cfperl.h |
2832
2833SV *
2834new (char *klass)
2835 CODE:
2836 RETVAL = newSVptr (new object_freezer, gv_stashpv ("cf::object::freezer", 1));
2837 OUTPUT: RETVAL
2838
2839void
2840DESTROY (SV *sv)
2841 CODE:
2842 object_freezer *self;
2843 sv_to (sv, self);
2844 delete self;
2845
2846MODULE = cf PACKAGE = cf::object::thawer
2847
2848INCLUDE: $PERL $srcdir/genacc object_thawer ../include/cfperl.h |
2849
2850SV *
2851new_from_file (char *klass, octet_string path)
2852 CODE:
2853 object_thawer *f = new object_thawer (path);
2854 if (!*f)
2855 {
2856 delete f;
2857 XSRETURN_UNDEF;
2858 }
2859 RETVAL = newSVptr (f, gv_stashpv ("cf::object::thawer", 1));
2860 OUTPUT: RETVAL
2861
2862void
2863DESTROY (SV *sv)
2864 CODE:
2865 object_thawer *self;
2866 sv_to (sv, self);
2867 delete self;
2868

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines