… | |
… | |
53 | #include "CoroAPI.h" |
53 | #include "CoroAPI.h" |
54 | #include "perlxsi.c" |
54 | #include "perlxsi.c" |
55 | |
55 | |
56 | extern sint64 *levels; // the experience table |
56 | extern sint64 *levels; // the experience table |
57 | |
57 | |
58 | typedef object object_ornull; |
58 | typedef object_thawer &object_thawer_ref; |
59 | typedef maptile maptile_ornull; |
59 | typedef object_freezer &object_freezer_ref; |
60 | |
|
|
61 | typedef char *octet_string; |
|
|
62 | typedef char *utf8_string; |
|
|
63 | typedef const char *const_octet_string; |
|
|
64 | typedef const char *const_utf8_string; |
|
|
65 | |
60 | |
66 | typedef std::string std__string; |
61 | typedef std::string std__string; |
67 | |
62 | |
68 | #if IVSIZE >= 8 |
63 | #if IVSIZE >= 8 |
69 | typedef IV val64; |
64 | typedef IV val64; |
… | |
… | |
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 | |
454 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } |
449 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } |
455 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
450 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
456 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
451 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
457 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
452 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
458 | inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } |
453 | inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } |
459 | inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } |
454 | inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } |
460 | inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } |
455 | inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } |
461 | inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } |
456 | inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } |
462 | inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } |
457 | inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } |
463 | inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } |
458 | inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } |
464 | inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
459 | inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
465 | inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
460 | inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
466 | inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
461 | inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
467 | inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
462 | inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
468 | inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
463 | inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
469 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
464 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
470 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
465 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
471 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
466 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
472 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
467 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
473 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
468 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
474 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
469 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
475 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
470 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
476 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
471 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
477 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
472 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
|
|
473 | inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); } |
|
|
474 | inline 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)]; } |
480 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
477 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
481 | |
478 | |
482 | template<class T> |
479 | template<class T> |
483 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
480 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
484 | |
481 | |
485 | template<int N> |
482 | template<int N> |
486 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
483 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
487 | |
484 | |
488 | inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } |
485 | inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } |
489 | inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } |
486 | inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } |
490 | inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } |
487 | inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } |
491 | inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } |
488 | inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } |
492 | |
489 | |
493 | inline void sv_to (SV *sv, std::string &v) |
490 | inline 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 | |
500 | inline void sv_to (SV *sv, UUID &v) |
497 | inline 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 | |
994 | void |
992 | void |
995 | cfperl_emergency_save () |
993 | cfperl_emergency_save () |
996 | { |
994 | { |
997 | CALL_BEGIN (0); |
995 | CALL_BEGIN (0); |
… | |
… | |
1132 | CALL_BEGIN (2); |
1130 | CALL_BEGIN (2); |
1133 | CALL_ARG (this); |
1131 | CALL_ARG (this); |
1134 | CALL_ARG (exit); |
1132 | CALL_ARG (exit); |
1135 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
1133 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
1136 | CALL_END; |
1134 | CALL_END; |
|
|
1135 | } |
|
|
1136 | |
|
|
1137 | const char * |
|
|
1138 | object::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 | |
|
|
1146 | object * |
|
|
1147 | object::deref (const char *ref) |
|
|
1148 | { |
|
|
1149 | object *retval; |
|
|
1150 | |
|
|
1151 | CALL_BEGIN (1); |
|
|
1152 | CALL_ARG (ref); |
|
|
1153 | CALL_CALL ("cf::object::deref", G_SCALAR); |
|
|
1154 | |
|
|
1155 | if (count) |
|
|
1156 | sv_to (POPs, retval); |
|
|
1157 | else |
|
|
1158 | retval = 0; |
|
|
1159 | |
|
|
1160 | CALL_END; |
|
|
1161 | |
|
|
1162 | return retval; |
1137 | } |
1163 | } |
1138 | |
1164 | |
1139 | void |
1165 | void |
1140 | log_backtrace (const char *msg) |
1166 | log_backtrace (const char *msg) |
1141 | { |
1167 | { |
… | |
… | |
2531 | OUTPUT: |
2557 | OUTPUT: |
2532 | RETVAL |
2558 | RETVAL |
2533 | |
2559 | |
2534 | MODULE = cf PACKAGE = cf::arch |
2560 | MODULE = cf PACKAGE = cf::arch |
2535 | |
2561 | |
2536 | archetype *find (utf8_string name) |
|
|
2537 | CODE: |
|
|
2538 | RETVAL = archetype::find (name); |
|
|
2539 | OUTPUT: |
|
|
2540 | RETVAL |
|
|
2541 | |
|
|
2542 | int archetypes_size () |
2562 | int archetypes_size () |
2543 | CODE: |
2563 | CODE: |
2544 | RETVAL = archetypes.size (); |
2564 | RETVAL = archetypes.size (); |
2545 | OUTPUT: RETVAL |
2565 | OUTPUT: RETVAL |
2546 | |
2566 | |
… | |
… | |
2803 | void invalidate_all () |
2823 | void invalidate_all () |
2804 | CODE: |
2824 | CODE: |
2805 | for_all_clients (ns) |
2825 | for_all_clients (ns) |
2806 | ns->anims_sent.reset (); |
2826 | ns->anims_sent.reset (); |
2807 | |
2827 | |
|
|
2828 | MODULE = cf PACKAGE = cf::object::freezer |
|
|
2829 | |
|
|
2830 | INCLUDE: $PERL $srcdir/genacc object_freezer ../include/cfperl.h | |
|
|
2831 | |
|
|
2832 | SV * |
|
|
2833 | new (char *klass) |
|
|
2834 | CODE: |
|
|
2835 | RETVAL = newSVptr (new object_freezer, gv_stashpv ("cf::object::freezer", 1)); |
|
|
2836 | OUTPUT: RETVAL |
|
|
2837 | |
|
|
2838 | void |
|
|
2839 | DESTROY (SV *sv) |
|
|
2840 | CODE: |
|
|
2841 | object_freezer *self; |
|
|
2842 | sv_to (sv, self); |
|
|
2843 | delete self; |
|
|
2844 | |
|
|
2845 | MODULE = cf PACKAGE = cf::object::thawer |
|
|
2846 | |
|
|
2847 | INCLUDE: $PERL $srcdir/genacc object_thawer ../include/cfperl.h | |
|
|
2848 | |
|
|
2849 | SV * |
|
|
2850 | new_from_file (char *klass, octet_string path) |
|
|
2851 | CODE: |
|
|
2852 | object_thawer *f = new object_thawer (path); |
|
|
2853 | if (!*f) |
|
|
2854 | { |
|
|
2855 | delete f; |
|
|
2856 | XSRETURN_UNDEF; |
|
|
2857 | } |
|
|
2858 | RETVAL = newSVptr (f, gv_stashpv ("cf::object::thawer", 1)); |
|
|
2859 | OUTPUT: RETVAL |
|
|
2860 | |
|
|
2861 | void |
|
|
2862 | DESTROY (SV *sv) |
|
|
2863 | CODE: |
|
|
2864 | object_thawer *self; |
|
|
2865 | sv_to (sv, self); |
|
|
2866 | delete self; |
|
|
2867 | |