… | |
… | |
26 | #if HAVE_EXECINFO_H |
26 | #if HAVE_EXECINFO_H |
27 | # include <execinfo.h> |
27 | # include <execinfo.h> |
28 | #endif |
28 | #endif |
29 | |
29 | |
30 | #include <cstdarg> |
30 | #include <cstdarg> |
|
|
31 | #include <typeinfo> |
31 | |
32 | |
32 | #include "global.h" |
33 | #include "global.h" |
33 | #include "loader.h" |
34 | #include "loader.h" |
34 | #include "../random_maps/random_map.h" |
35 | #include "../random_maps/random_map.h" |
35 | #include "evthread.h" |
36 | #include "evthread.h" |
… | |
… | |
80 | *stash_cf, |
81 | *stash_cf, |
81 | *stash_cf_object_wrap, |
82 | *stash_cf_object_wrap, |
82 | *stash_cf_object_player_wrap, |
83 | *stash_cf_object_player_wrap, |
83 | *stash_cf_player_wrap, |
84 | *stash_cf_player_wrap, |
84 | *stash_cf_map_wrap, |
85 | *stash_cf_map_wrap, |
|
|
86 | *stash_cf_mapspace_wrap, |
85 | *stash_cf_client_wrap, |
87 | *stash_cf_client_wrap, |
86 | *stash_cf_arch_wrap, |
88 | *stash_cf_arch_wrap, |
87 | *stash_cf_party_wrap, |
89 | *stash_cf_party_wrap, |
88 | *stash_cf_region_wrap, |
90 | *stash_cf_region_wrap, |
89 | *stash_cf_living_wrap; |
91 | *stash_cf_living_wrap; |
… | |
… | |
428 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
430 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
429 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
431 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
430 | inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
432 | inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
431 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
433 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
432 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
434 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
|
|
435 | inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
433 | |
436 | |
434 | inline SV *to_sv (object & v) { return to_sv (&v); } |
437 | inline SV *to_sv (object & v) { return to_sv (&v); } |
435 | inline SV *to_sv (living & v) { return to_sv (&v); } |
438 | inline SV *to_sv (living & v) { return to_sv (&v); } |
436 | |
439 | |
437 | inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
440 | inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
438 | inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } |
441 | inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } |
439 | |
442 | |
440 | inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); } |
443 | inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); } |
|
|
444 | |
|
|
445 | inline SV *to_sv (dynbuf * v) |
|
|
446 | { |
|
|
447 | SV *sv = newSV (0); |
|
|
448 | |
|
|
449 | sv_upgrade (sv, SVt_PV); |
|
|
450 | SvGROW (sv, v->size () + 1); |
|
|
451 | SvPOK_only (sv); |
|
|
452 | v->linearise (SvPVX (sv)); |
|
|
453 | SvCUR_set (sv, v->size ()); |
|
|
454 | *SvEND (sv) = 0; |
|
|
455 | |
|
|
456 | return sv; |
|
|
457 | } |
|
|
458 | |
|
|
459 | inline SV *to_sv (dynbuf_text * v) |
|
|
460 | { |
|
|
461 | SV *sv = to_sv (static_cast<dynbuf *> (v)); |
|
|
462 | SvUTF8_on (sv); |
|
|
463 | return sv; |
|
|
464 | } |
441 | |
465 | |
442 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } |
466 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } |
443 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
467 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
444 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
468 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
445 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
469 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
… | |
… | |
461 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
485 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
462 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
486 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
463 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
487 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
464 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
488 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
465 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
489 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
|
|
490 | inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *)SvPTR_ornull (sv, "cf::mapspace"); } |
466 | inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); } |
491 | inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); } |
467 | inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); } |
492 | inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); } |
468 | |
493 | |
469 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
494 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
470 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
495 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
601 | |
626 | |
602 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
627 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
603 | |
628 | |
604 | const char *argv[] = { |
629 | const char *argv[] = { |
605 | settings.argv [0], |
630 | settings.argv [0], |
606 | "-e" |
631 | "-e0" |
607 | "use EV; use Coro;" // required for bootstrap |
|
|
608 | "cf->bootstrap;" // required for datadir :*> |
|
|
609 | "unshift @INC, cf::datadir ();" |
|
|
610 | "require cf;" |
|
|
611 | }; |
632 | }; |
612 | |
633 | |
613 | if (perl_parse (perl, xs_init, 2, (char **)argv, environ) |
634 | if (perl_parse (perl, xs_init, 2, (char **)argv, environ) |
614 | || perl_run (perl)) |
635 | || perl_run (perl)) |
615 | { |
636 | { |
616 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
637 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
617 | exit (EXIT_FAILURE); |
638 | exit (EXIT_FAILURE); |
618 | } |
639 | } |
619 | |
640 | |
|
|
641 | eval_pv ( |
|
|
642 | "#line 1 'cfperl init'\n" |
|
|
643 | "use EV ();\n" |
|
|
644 | "use Coro ();\n" |
|
|
645 | "cf->bootstrap;\n" |
|
|
646 | "unshift @INC, cf::datadir ();\n" |
|
|
647 | "require cf;\n", |
|
|
648 | 0 |
|
|
649 | ); |
|
|
650 | |
|
|
651 | if (SvTRUE (ERRSV)) |
620 | { |
652 | { |
621 | dSP; |
653 | printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); |
622 | |
654 | exit (EXIT_FAILURE); |
623 | PUSHMARK (SP); |
|
|
624 | PUTBACK; |
|
|
625 | call_pv ("cf::init", G_DISCARD | G_VOID); |
|
|
626 | } |
655 | } |
627 | } |
656 | } |
628 | |
657 | |
629 | void cfperl_main () |
658 | void cfperl_main () |
630 | { |
659 | { |
631 | dSP; |
660 | dSP; |
… | |
… | |
941 | CALL_CALL ("ext::books::make_book", G_VOID); |
970 | CALL_CALL ("ext::books::make_book", G_VOID); |
942 | CALL_END; |
971 | CALL_END; |
943 | } |
972 | } |
944 | |
973 | |
945 | void |
974 | void |
946 | cfperl_expand_cfpod (player *pl, std::string &msg) |
|
|
947 | { |
|
|
948 | CALL_BEGIN (2); |
|
|
949 | CALL_ARG (pl); |
|
|
950 | CALL_ARG_SV (newSVpvn_utf8 (msg.data (), msg.size ())); |
|
|
951 | CALL_CALL ("cf::player::expand_cfpod", G_SCALAR); |
|
|
952 | |
|
|
953 | if (count) |
|
|
954 | { |
|
|
955 | STRLEN len; |
|
|
956 | char *data = SvPVutf8 (TOPs, len); |
|
|
957 | msg.assign (data, len); |
|
|
958 | } |
|
|
959 | |
|
|
960 | CALL_END; |
|
|
961 | } |
|
|
962 | |
|
|
963 | void |
|
|
964 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
975 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
965 | { |
976 | { |
966 | CALL_BEGIN (4); |
977 | CALL_BEGIN (4); |
967 | CALL_ARG (ns); |
978 | CALL_ARG (ns); |
968 | CALL_ARG (type); |
979 | CALL_ARG (type); |
… | |
… | |
1189 | |
1200 | |
1190 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1201 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1191 | stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); |
1202 | stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); |
1192 | stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1); |
1203 | stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1); |
1193 | stash_cf_map_wrap = gv_stashpv ("cf::map::wrap" , 1); |
1204 | stash_cf_map_wrap = gv_stashpv ("cf::map::wrap" , 1); |
|
|
1205 | stash_cf_mapspace_wrap = gv_stashpv ("cf::mapspace::wrap" , 1); |
1194 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1206 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1195 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1207 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1196 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1208 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1197 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1209 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1198 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1210 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
… | |
… | |
1318 | const_iv (FLAG_CURSED) const_iv (FLAG_DAMNED) const_iv (FLAG_SEE_ANYWHERE) const_iv (FLAG_KNOWN_MAGICAL) |
1330 | const_iv (FLAG_CURSED) const_iv (FLAG_DAMNED) const_iv (FLAG_SEE_ANYWHERE) const_iv (FLAG_KNOWN_MAGICAL) |
1319 | const_iv (FLAG_KNOWN_CURSED) const_iv (FLAG_CAN_USE_SKILL) const_iv (FLAG_BEEN_APPLIED) const_iv (FLAG_READY_SCROLL) |
1331 | const_iv (FLAG_KNOWN_CURSED) const_iv (FLAG_CAN_USE_SKILL) const_iv (FLAG_BEEN_APPLIED) const_iv (FLAG_READY_SCROLL) |
1320 | const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) |
1332 | const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) |
1321 | const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) |
1333 | const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) |
1322 | const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) |
1334 | const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) |
1323 | const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_CLIENT_SENT) const_iv (FLAG_BERSERK) |
1335 | const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK) |
1324 | const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) |
1336 | const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) |
1325 | const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) |
1337 | const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) |
1326 | const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) |
1338 | const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) |
1327 | const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) |
1339 | const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) |
1328 | |
1340 | |
1329 | const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) |
1341 | const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) |
1330 | const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) |
1342 | const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) |
1331 | const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD) |
1343 | const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD) |
1332 | const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE) |
1344 | const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE) |
1333 | const_iv (NDI_ALL) const_iv (NDI_DEF) const_iv (NDI_REPLY) const_iv (NDI_CLIENT_MASK) |
1345 | const_iv (NDI_ALL) const_iv (NDI_DEF) const_iv (NDI_REPLY) const_iv (NDI_CLIENT_MASK) |
1334 | const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) |
1346 | const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) const_iv (NDI_VERBATIM) |
1335 | |
1347 | |
1336 | const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) |
1348 | const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) |
1337 | const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF) |
1349 | const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF) |
1338 | |
1350 | |
1339 | const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) |
1351 | const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) |
… | |
… | |
1391 | const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK) |
1403 | const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK) |
1392 | const_iv (F_LOCKED) |
1404 | const_iv (F_LOCKED) |
1393 | |
1405 | |
1394 | const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL) |
1406 | const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL) |
1395 | |
1407 | |
1396 | const_iv (P_BLOCKSVIEW) const_iv (P_PLAYER) const_iv (P_NO_MAGIC) const_iv (P_IS_ALIVE) |
1408 | const_iv (P_BLOCKSVIEW) const_iv (P_NO_MAGIC) const_iv (P_IS_ALIVE) |
1397 | const_iv (P_NO_CLERIC) const_iv (P_OUT_OF_MAP) const_iv (P_NEW_MAP) const_iv (P_UPTODATE) |
1409 | const_iv (P_NO_CLERIC) const_iv (P_OUT_OF_MAP) const_iv (P_NEW_MAP) const_iv (P_UPTODATE) |
1398 | |
1410 | |
1399 | const_iv (UP_OBJ_INSERT) const_iv (UP_OBJ_REMOVE) const_iv (UP_OBJ_CHANGE) const_iv (UP_OBJ_FACE) |
1411 | const_iv (UP_OBJ_INSERT) const_iv (UP_OBJ_REMOVE) const_iv (UP_OBJ_CHANGE) const_iv (UP_OBJ_FACE) |
1400 | |
1412 | |
1401 | const_iv (INS_NO_MERGE) const_iv (INS_ABOVE_FLOOR_ONLY) const_iv (INS_NO_WALK_ON) |
1413 | const_iv (INS_NO_MERGE) const_iv (INS_ABOVE_FLOOR_ONLY) const_iv (INS_NO_WALK_ON) |
… | |
… | |
1499 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1511 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1500 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1512 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1501 | } |
1513 | } |
1502 | } |
1514 | } |
1503 | |
1515 | |
|
|
1516 | void _gv_clear (SV *gv) |
|
|
1517 | CODE: |
|
|
1518 | assert (SvTYPE (gv) == SVt_PVGV); |
|
|
1519 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
|
|
1520 | f (GvGP (gv)->gp_form); |
|
|
1521 | f (GvGP (gv)->gp_io); |
|
|
1522 | f (GvGP (gv)->gp_sv); |
|
|
1523 | f (GvGP (gv)->gp_av); |
|
|
1524 | f (GvGP (gv)->gp_hv); |
|
|
1525 | f (GvGP (gv)->gp_cv); |
|
|
1526 | GvCVGEN (gv) = 0; |
|
|
1527 | GvMULTI_off (gv); |
|
|
1528 | # undef f |
|
|
1529 | |
1504 | void _connect_to_perl () |
1530 | void _connect_to_perl () |
1505 | |
1531 | |
1506 | void _recalc_want () |
1532 | void _recalc_want () |
1507 | |
1533 | |
|
|
1534 | # not used by default anymore |
1508 | void _global_reattach () |
1535 | void _global_reattach () |
1509 | CODE: |
1536 | CODE: |
1510 | { |
1537 | { |
1511 | // reattach to all attachable objects in the game. |
1538 | // reattach to all attachable objects in the game. |
1512 | for_all_clients (ns) |
1539 | for_all_clients (ns) |
… | |
… | |
1555 | len -= 3; |
1582 | len -= 3; |
1556 | } |
1583 | } |
1557 | |
1584 | |
1558 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1585 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1559 | } |
1586 | } |
|
|
1587 | |
|
|
1588 | void init_anim () |
|
|
1589 | |
|
|
1590 | void init_globals () |
|
|
1591 | |
|
|
1592 | void init_experience () |
|
|
1593 | |
|
|
1594 | void init_attackmess () |
|
|
1595 | |
|
|
1596 | void init_dynamic () |
|
|
1597 | |
|
|
1598 | void init_block () |
|
|
1599 | |
|
|
1600 | void load_settings () |
|
|
1601 | |
|
|
1602 | void load_materials () |
|
|
1603 | |
|
|
1604 | void init_uuid () |
|
|
1605 | CODE: |
|
|
1606 | UUID::init (); |
|
|
1607 | |
|
|
1608 | void init_signals () |
|
|
1609 | |
|
|
1610 | void init_commands () |
|
|
1611 | |
|
|
1612 | void init_skills () |
|
|
1613 | |
|
|
1614 | void init_beforeplay () |
1560 | |
1615 | |
1561 | void evthread_start (int aiofd) |
1616 | void evthread_start (int aiofd) |
1562 | |
1617 | |
1563 | void cede_to_tick () |
1618 | void cede_to_tick () |
1564 | CODE: |
1619 | CODE: |
… | |
… | |
1702 | #if _POSIX_MEMLOCK |
1757 | #if _POSIX_MEMLOCK |
1703 | |
1758 | |
1704 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1759 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1705 | INIT: |
1760 | INIT: |
1706 | #if __GLIBC__ |
1761 | #if __GLIBC__ |
|
|
1762 | mallopt (M_TOP_PAD, 1024 * 1024); |
|
|
1763 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); |
|
|
1764 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1707 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1765 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1708 | #endif |
1766 | #endif |
1709 | |
1767 | |
1710 | int munlockall () |
1768 | int munlockall () |
1711 | |
1769 | |
… | |
… | |
2100 | void rangevector (object *ob, object *other, int flags = 0) |
2158 | void rangevector (object *ob, object *other, int flags = 0) |
2101 | PROTOTYPE: $$;$ |
2159 | PROTOTYPE: $$;$ |
2102 | PPCODE: |
2160 | PPCODE: |
2103 | { |
2161 | { |
2104 | rv_vector rv; |
2162 | rv_vector rv; |
|
|
2163 | |
|
|
2164 | PUTBACK; |
2105 | get_rangevector (ob, other, &rv, flags); |
2165 | get_rangevector (ob, other, &rv, flags); |
|
|
2166 | SPAGAIN; |
|
|
2167 | |
2106 | EXTEND (SP, 5); |
2168 | EXTEND (SP, 5); |
2107 | PUSHs (newSVuv (rv.distance)); |
2169 | PUSHs (newSVuv (rv.distance)); |
2108 | PUSHs (newSViv (rv.distance_x)); |
2170 | PUSHs (newSViv (rv.distance_x)); |
2109 | PUSHs (newSViv (rv.distance_y)); |
2171 | PUSHs (newSViv (rv.distance_y)); |
2110 | PUSHs (newSViv (rv.direction)); |
2172 | PUSHs (newSViv (rv.direction)); |
… | |
… | |
2201 | if (len > MAXSOCKBUF) |
2263 | if (len > MAXSOCKBUF) |
2202 | pl->failmsg ("[packet too long for client]"); |
2264 | pl->failmsg ("[packet too long for client]"); |
2203 | else if (pl->ns) |
2265 | else if (pl->ns) |
2204 | pl->ns->send_packet (buf, len); |
2266 | pl->ns->send_packet (buf, len); |
2205 | } |
2267 | } |
2206 | |
|
|
2207 | int |
|
|
2208 | listening (player *pl, int new_value = -1) |
|
|
2209 | CODE: |
|
|
2210 | RETVAL = pl->listening; |
|
|
2211 | if (new_value >= 0) |
|
|
2212 | pl->listening = new_value; |
|
|
2213 | OUTPUT: |
|
|
2214 | RETVAL |
|
|
2215 | |
2268 | |
2216 | void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) |
2269 | void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) |
2217 | PROTOTYPE: $;$$$ |
2270 | PROTOTYPE: $;$$$ |
2218 | PPCODE: |
2271 | PPCODE: |
2219 | if (GIMME_V != G_VOID) |
2272 | if (GIMME_V != G_VOID) |
… | |
… | |
2374 | } |
2427 | } |
2375 | |
2428 | |
2376 | void |
2429 | void |
2377 | maptile::create_region_treasure () |
2430 | maptile::create_region_treasure () |
2378 | CODE: |
2431 | CODE: |
2379 | { |
|
|
2380 | object *op = object::create (); |
|
|
2381 | op->type = FLOOR; |
|
|
2382 | op->map = THIS; |
|
|
2383 | |
|
|
2384 | for (int x = 0; x < THIS->width; ++x) |
2432 | for (int x = 0; x < THIS->width; ++x) |
2385 | for (int y = 0; y < THIS->height; ++y) |
2433 | for (int y = 0; y < THIS->height; ++y) |
2386 | { |
2434 | { |
2387 | region *rgn = THIS->region (x, y); |
2435 | region *rgn = THIS->region (x, y); |
2388 | |
2436 | |
2389 | //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D |
2437 | //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D |
|
|
2438 | if (object *op = THIS->at (x, y).top) |
2390 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2439 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2391 | { |
|
|
2392 | op->x = x; |
|
|
2393 | op->y = y; |
|
|
2394 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2440 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2395 | } |
|
|
2396 | } |
2441 | } |
2397 | |
|
|
2398 | op->destroy (); |
|
|
2399 | } |
|
|
2400 | |
2442 | |
2401 | int out_of_map (maptile *map, int x, int y) |
2443 | int out_of_map (maptile *map, int x, int y) |
2402 | |
2444 | |
2403 | void |
2445 | void |
2404 | trigger (maptile *map, long connection, bool state = true) |
2446 | trigger (maptile *map, long connection, bool state = true) |
… | |
… | |
2417 | get_map_flags (maptile *map, int x, int y) |
2459 | get_map_flags (maptile *map, int x, int y) |
2418 | PPCODE: |
2460 | PPCODE: |
2419 | { |
2461 | { |
2420 | maptile *nmap = 0; |
2462 | maptile *nmap = 0; |
2421 | I16 nx = 0, ny = 0; |
2463 | I16 nx = 0, ny = 0; |
|
|
2464 | |
|
|
2465 | PUTBACK; |
2422 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2466 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2467 | SPAGAIN; |
2423 | |
2468 | |
2424 | EXTEND (SP, 4); |
2469 | EXTEND (SP, 4); |
2425 | PUSHs (sv_2mortal (newSViv (flags))); |
2470 | PUSHs (sv_2mortal (newSViv (flags))); |
2426 | |
2471 | |
2427 | if (GIMME_V == G_ARRAY) |
2472 | if (GIMME_V == G_ARRAY) |
… | |
… | |
2430 | PUSHs (sv_2mortal (newSViv (nx))); |
2475 | PUSHs (sv_2mortal (newSViv (nx))); |
2431 | PUSHs (sv_2mortal (newSViv (ny))); |
2476 | PUSHs (sv_2mortal (newSViv (ny))); |
2432 | } |
2477 | } |
2433 | } |
2478 | } |
2434 | |
2479 | |
|
|
2480 | mapspace * |
|
|
2481 | ms (maptile *map, unsigned int x, unsigned int y) |
|
|
2482 | PROTOTYPE: $$$ |
|
|
2483 | CODE: |
|
|
2484 | { |
|
|
2485 | maptile *nmap = 0; |
|
|
2486 | I16 nx, ny; |
|
|
2487 | |
|
|
2488 | PUTBACK; |
|
|
2489 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2490 | SPAGAIN; |
|
|
2491 | |
|
|
2492 | if (!nmap) |
|
|
2493 | XSRETURN_UNDEF; |
|
|
2494 | |
|
|
2495 | RETVAL = &nmap->at (nx, ny); |
|
|
2496 | } |
|
|
2497 | OUTPUT: |
|
|
2498 | RETVAL |
|
|
2499 | |
2435 | void |
2500 | void |
2436 | at (maptile *map, unsigned int x, unsigned int y) |
2501 | at (maptile *map, unsigned int x, unsigned int y) |
2437 | PROTOTYPE: $$$ |
2502 | PROTOTYPE: $$$ |
2438 | PPCODE: |
2503 | PPCODE: |
2439 | { |
2504 | { |
2440 | object *o; |
|
|
2441 | maptile *nmap = 0; |
2505 | maptile *nmap = 0; |
2442 | I16 nx, ny; |
2506 | I16 nx, ny; |
2443 | |
2507 | |
|
|
2508 | PUTBACK; |
2444 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2509 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2510 | SPAGAIN; |
2445 | |
2511 | |
2446 | if (nmap) |
2512 | if (nmap) |
2447 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2513 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2448 | XPUSHs (sv_2mortal (to_sv (o))); |
2514 | XPUSHs (sv_2mortal (to_sv (o))); |
2449 | } |
2515 | } |
2450 | |
2516 | |
2451 | SV * |
2517 | SV * |
2452 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2518 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
… | |
… | |
2565 | RETVAL = self->generate_random_map (&rmp); |
2631 | RETVAL = self->generate_random_map (&rmp); |
2566 | } |
2632 | } |
2567 | OUTPUT: |
2633 | OUTPUT: |
2568 | RETVAL |
2634 | RETVAL |
2569 | |
2635 | |
|
|
2636 | MODULE = cf PACKAGE = cf::mapspace |
|
|
2637 | |
|
|
2638 | INCLUDE: $PERL $srcdir/genacc mapspace ../include/map.h | |
|
|
2639 | |
2570 | MODULE = cf PACKAGE = cf::arch |
2640 | MODULE = cf PACKAGE = cf::arch |
2571 | |
2641 | |
2572 | int archetypes_size () |
2642 | int archetypes_size () |
2573 | CODE: |
2643 | CODE: |
2574 | RETVAL = archetypes.size (); |
2644 | RETVAL = archetypes.size (); |