… | |
… | |
28 | |
28 | |
29 | #include <cstdarg> |
29 | #include <cstdarg> |
30 | #include <typeinfo> |
30 | #include <typeinfo> |
31 | |
31 | |
32 | #include "global.h" |
32 | #include "global.h" |
33 | #include "../random_maps/random_map.h" |
33 | #include "rmg.h" |
34 | #include "evthread.h" |
34 | #include "evthread.h" |
35 | #include "sproto.h" |
35 | #include "sproto.h" |
36 | |
36 | |
37 | #include <unistd.h> |
37 | #include <unistd.h> |
38 | #if _POSIX_MEMLOCK |
38 | #if _POSIX_MEMLOCK |
… | |
… | |
51 | #include <perl.h> |
51 | #include <perl.h> |
52 | #include <XSUB.h> |
52 | #include <XSUB.h> |
53 | |
53 | |
54 | #include "CoroAPI.h" |
54 | #include "CoroAPI.h" |
55 | #include "perlxsi.c" |
55 | #include "perlxsi.c" |
56 | |
|
|
57 | extern sint64 *levels; // the experience table |
|
|
58 | |
56 | |
59 | typedef object_thawer &object_thawer_ref; |
57 | typedef object_thawer &object_thawer_ref; |
60 | typedef object_freezer &object_freezer_ref; |
58 | typedef object_freezer &object_freezer_ref; |
61 | |
59 | |
62 | typedef std::string std__string; |
60 | typedef std::string std__string; |
… | |
… | |
85 | *stash_cf_mapspace_wrap, |
83 | *stash_cf_mapspace_wrap, |
86 | *stash_cf_client_wrap, |
84 | *stash_cf_client_wrap, |
87 | *stash_cf_arch_wrap, |
85 | *stash_cf_arch_wrap, |
88 | *stash_cf_party_wrap, |
86 | *stash_cf_party_wrap, |
89 | *stash_cf_region_wrap, |
87 | *stash_cf_region_wrap, |
90 | *stash_cf_living_wrap; |
88 | *stash_cf_living_wrap, |
|
|
89 | *stash_cf_layout_wrap, |
|
|
90 | *stash_ext_map_world; |
91 | |
91 | |
92 | static SV |
92 | static SV |
93 | *cv_cf_do_invoke, |
93 | *cv_cf_do_invoke, |
94 | *cv_cf__can_merge, |
94 | *cv_cf__can_merge, |
95 | *cv_cf_client_send_msg, |
95 | *cv_cf_client_send_msg, |
… | |
… | |
123 | |
123 | |
124 | return sv; |
124 | return sv; |
125 | } |
125 | } |
126 | #endif |
126 | #endif |
127 | |
127 | |
128 | static noinline utf8_string |
128 | noinline utf8_string |
129 | cfSvPVutf8_nolen (SV *sv) |
129 | cfSvPVutf8_nolen (SV *sv) |
130 | { |
130 | { |
131 | SvGETMAGIC (sv); |
131 | SvGETMAGIC (sv); |
132 | |
132 | |
133 | if (SvPOK (sv)) |
133 | if (SvPOK (sv)) |
… | |
… | |
353 | #endif |
353 | #endif |
354 | |
354 | |
355 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
356 | |
356 | |
357 | static SV * |
357 | static SV * |
358 | newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) |
358 | newSVptr (void *ptr, HV *stash, HV *hv) |
359 | { |
359 | { |
360 | SV *sv; |
|
|
361 | |
|
|
362 | if (!ptr) |
360 | if (!ptr) |
363 | return newSV (0); |
361 | return newSV (0); |
364 | |
362 | |
365 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
363 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
366 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
364 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
|
|
365 | } |
|
|
366 | |
|
|
367 | static SV * noinline |
|
|
368 | newSVptr (void *ptr, HV *stash) |
|
|
369 | { |
|
|
370 | return newSVptr (ptr, stash, newHV ()); |
367 | } |
371 | } |
368 | |
372 | |
369 | static int |
373 | static int |
370 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
374 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
371 | { |
375 | { |
… | |
… | |
383 | return 0; |
387 | return 0; |
384 | } |
388 | } |
385 | |
389 | |
386 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
390 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
387 | |
391 | |
388 | static SV * |
392 | static SV * noinline |
389 | newSVattachable (attachable *obj, HV *stash) |
393 | newSVattachable (attachable *obj, HV *stash) |
390 | { |
394 | { |
391 | if (!obj) |
395 | if (!obj) |
392 | return newSV (0); |
396 | return newSV (0); |
393 | |
397 | |
… | |
… | |
479 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
483 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
480 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
484 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
481 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
485 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
482 | && !sv_derived_from (sv, "cf::object"))) |
486 | && !sv_derived_from (sv, "cf::object"))) |
483 | croak ("object of type cf::object expected"); |
487 | croak ("object of type cf::object expected"); |
|
|
488 | |
|
|
489 | return SvPTR_nc (sv); |
|
|
490 | } |
|
|
491 | |
|
|
492 | static long noinline |
|
|
493 | SvPTR_ornull_maptile (SV *sv) |
|
|
494 | { |
|
|
495 | if (expect_false (!SvOK (sv))) return 0; |
|
|
496 | |
|
|
497 | if (!SvROK (sv) |
|
|
498 | || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap |
|
|
499 | && SvSTASH (SvRV (sv)) != stash_ext_map_world |
|
|
500 | && !sv_derived_from (sv, "cf::map"))) |
|
|
501 | croak ("object of type cf::map expected"); |
484 | |
502 | |
485 | return SvPTR_nc (sv); |
503 | return SvPTR_nc (sv); |
486 | } |
504 | } |
487 | |
505 | |
488 | static long noinline |
506 | static long noinline |
… | |
… | |
513 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
531 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
514 | static inline SV *to_sv (float v) { return newSVnv (v); } |
532 | static inline SV *to_sv (float v) { return newSVnv (v); } |
515 | static inline SV *to_sv (double v) { return newSVnv (v); } |
533 | static inline SV *to_sv (double v) { return newSVnv (v); } |
516 | static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
534 | static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
517 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
535 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
|
|
536 | // gcc dislikes noilnine on to_sv |
518 | static inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
537 | static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
|
|
538 | static inline SV *to_sv (object * v) { return to_sv_ni (v); } |
519 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
539 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
520 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
540 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
521 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
541 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
522 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
542 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
523 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
543 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
524 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
544 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
|
|
545 | static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); } |
525 | |
546 | |
526 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
547 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
527 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
548 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
528 | |
549 | |
529 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
550 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
… | |
… | |
565 | static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
586 | static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
566 | static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
587 | static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
567 | static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
588 | static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
568 | static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
589 | static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
569 | static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
590 | static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
570 | static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } |
591 | static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } |
571 | static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } |
592 | static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } |
572 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
593 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
|
|
594 | static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull_maptile (sv); } |
573 | static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
595 | static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
574 | static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
575 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
596 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
576 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
597 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
577 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
598 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
578 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
599 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
579 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
600 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
|
|
601 | static inline void sv_to (SV *sv, layout * &v) { v = (layout *) SvPTR_ornull (sv, "cf::layout"); } |
580 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
602 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
581 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
603 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
582 | |
604 | |
583 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
605 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
584 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
606 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
695 | template<class type> |
717 | template<class type> |
696 | static void noinline |
718 | static void noinline |
697 | cf_obj_to (SV *arg, type &var) |
719 | cf_obj_to (SV *arg, type &var) |
698 | { |
720 | { |
699 | sv_to (arg, var); |
721 | sv_to (arg, var); |
700 | if (!var) |
722 | if (expect_false (!var)) |
701 | croak ("must not pass invalid/null cf_obj here"); |
723 | croak ("must not pass invalid/null cf_obj here"); |
702 | } |
724 | } |
703 | |
725 | |
704 | template<class object> |
726 | template<class object> |
705 | static void noinline |
727 | static void noinline |
706 | cf_obj_ornull_to (SV *arg, object *&var) |
728 | cf_obj_ornull_to (SV *arg, object *&var) |
707 | { |
729 | { |
708 | if (SvOK (arg)) |
730 | if (SvOK (arg)) |
709 | { |
731 | { |
710 | sv_to (arg, var); |
732 | sv_to (arg, var); |
711 | if (!var) |
733 | if (expect_false (!var)) |
712 | croak ("unable to convert perl object to C++ object"); |
734 | croak ("unable to convert perl object to C++ object"); |
713 | } |
735 | } |
714 | else |
736 | else |
715 | var = 0; |
737 | var = 0; |
716 | } |
738 | } |
… | |
… | |
751 | exit (EXIT_FAILURE); |
773 | exit (EXIT_FAILURE); |
752 | } |
774 | } |
753 | |
775 | |
754 | eval_pv ( |
776 | eval_pv ( |
755 | "#line 1 'cfperl init'\n" |
777 | "#line 1 'cfperl init'\n" |
756 | "use EV ();\n" |
778 | "use EV ();\n" // required by bootstrap |
757 | "use Coro ();\n" |
779 | "use Coro ();\n" // required by bootstrap |
758 | "cf->bootstrap;\n" |
780 | "cf->bootstrap;\n" // required for cf::datadir |
759 | "unshift @INC, cf::datadir ();\n" |
781 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
760 | "require cf;\n", |
782 | "require cf;\n", |
761 | 0 |
783 | 0 |
762 | ); |
784 | ); |
763 | |
785 | |
764 | if (SvTRUE (ERRSV)) |
786 | if (SvTRUE (ERRSV)) |
… | |
… | |
1139 | |
1161 | |
1140 | return retval; |
1162 | return retval; |
1141 | } |
1163 | } |
1142 | |
1164 | |
1143 | maptile * |
1165 | maptile * |
1144 | find_style (const_utf8_string dirname, const_utf8_string stylename, int difficulty) |
1166 | find_style (const_utf8_string dirname, const_utf8_string stylename, int difficulty, bool recurse) |
1145 | { |
1167 | { |
1146 | CALL_BEGIN (3); |
1168 | CALL_BEGIN (4); |
1147 | CALL_ARG (dirname); |
1169 | CALL_ARG (dirname); |
1148 | CALL_ARG (stylename); |
1170 | CALL_ARG (stylename); |
1149 | CALL_ARG (difficulty); |
1171 | CALL_ARG (difficulty); |
|
|
1172 | CALL_ARG (recurse); |
1150 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
1173 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
1151 | |
1174 | |
1152 | maptile *retval = 0; |
1175 | maptile *retval = 0; |
1153 | if (count) sv_to (POPs, retval); |
1176 | if (count) sv_to (POPs, retval); |
1154 | |
1177 | |
… | |
… | |
1377 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1400 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1378 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1401 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1379 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1402 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1380 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1403 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1381 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1404 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
|
|
1405 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
|
|
1406 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1382 | |
1407 | |
1383 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1408 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1384 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1409 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1385 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1410 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1386 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1411 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
… | |
… | |
1434 | # include "attackinc.h" |
1459 | # include "attackinc.h" |
1435 | # undef def |
1460 | # undef def |
1436 | # define def(uc, flags) const_iv (SK_ ## uc) |
1461 | # define def(uc, flags) const_iv (SK_ ## uc) |
1437 | # include "skillinc.h" |
1462 | # include "skillinc.h" |
1438 | # undef def |
1463 | # undef def |
1439 | |
1464 | # define def(name, use, nonuse) const_iv (body_ ## name) |
1440 | const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) |
1465 | # include "slotinc.h" |
1441 | const_iv (logBacktrace) |
1466 | # undef def |
1442 | |
|
|
1443 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
|
|
1444 | |
1467 | |
1445 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1468 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1446 | |
1469 | |
1447 | const_iv (MAX_TIME) |
1470 | const_iv (MAX_TIME) |
1448 | const_iv (MAXSOCKBUF) |
1471 | const_iv (MAXSOCKBUF) |
… | |
… | |
1473 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1496 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1474 | |
1497 | |
1475 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1498 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1476 | }; |
1499 | }; |
1477 | |
1500 | |
1478 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1501 | for (civ = const_iv + array_length (const_iv); civ-- > const_iv; ) |
1479 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1502 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1480 | |
1503 | |
1481 | static const struct { |
1504 | static const struct { |
1482 | const char *name; |
1505 | const char *name; |
1483 | int skip; |
1506 | int skip; |
… | |
… | |
1489 | # undef def |
1512 | # undef def |
1490 | }; |
1513 | }; |
1491 | |
1514 | |
1492 | AV *av = get_av ("cf::EVENT", 1); |
1515 | AV *av = get_av ("cf::EVENT", 1); |
1493 | |
1516 | |
1494 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1517 | for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; ) |
1495 | { |
1518 | { |
1496 | AV *event = newAV (); |
1519 | AV *event = newAV (); |
1497 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1520 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1498 | av_push (event, newSViv (eiv->klass)); |
1521 | av_push (event, newSViv (eiv->klass)); |
1499 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1522 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1580 | |
1603 | |
1581 | void init_anim () |
1604 | void init_anim () |
1582 | |
1605 | |
1583 | void init_globals () |
1606 | void init_globals () |
1584 | |
1607 | |
1585 | void init_experience () |
|
|
1586 | |
|
|
1587 | void init_attackmess () |
1608 | void init_attackmess () |
1588 | |
1609 | |
1589 | void init_dynamic () |
1610 | void init_dynamic () |
1590 | |
1611 | |
1591 | void load_settings () |
1612 | void load_settings () |
1592 | |
1613 | |
|
|
1614 | void reload_exp_table () |
|
|
1615 | |
1593 | void load_materials () |
1616 | void reload_materials () |
1594 | |
1617 | |
1595 | void init_uuid () |
1618 | void init_uuid () |
1596 | CODE: |
1619 | CODE: |
1597 | UUID::init (); |
1620 | UUID::init (); |
1598 | |
1621 | |
… | |
… | |
1664 | switch (items) |
1687 | switch (items) |
1665 | { |
1688 | { |
1666 | case 0: RETVAL = gen (); break; |
1689 | case 0: RETVAL = gen (); break; |
1667 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1690 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1668 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1691 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1669 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1692 | default: croak ("cf::rndm requires zero, one or two parameters."); break; |
1670 | } |
1693 | } |
1671 | } |
1694 | } |
1672 | OUTPUT: |
1695 | OUTPUT: |
1673 | RETVAL |
1696 | RETVAL |
1674 | |
1697 | |
… | |
… | |
1753 | |
1776 | |
1754 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1777 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1755 | INIT: |
1778 | INIT: |
1756 | #if __GLIBC__ |
1779 | #if __GLIBC__ |
1757 | mallopt (M_TOP_PAD, 1024 * 1024); |
1780 | mallopt (M_TOP_PAD, 1024 * 1024); |
1758 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); |
1781 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024); |
1759 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1782 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
|
|
1783 | if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10)) |
1760 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1784 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1761 | #endif |
1785 | #endif |
1762 | |
1786 | |
1763 | int munlockall () |
1787 | int munlockall () |
1764 | |
1788 | |
1765 | #endif |
1789 | #endif |
… | |
… | |
1798 | |
1822 | |
1799 | int random_roll (int min, int max, object *op, int goodbad); |
1823 | int random_roll (int min, int max, object *op, int goodbad); |
1800 | |
1824 | |
1801 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1825 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1802 | |
1826 | |
1803 | int |
|
|
1804 | exp_to_level (val64 exp) |
1827 | int exp_to_level (val64 exp) |
|
|
1828 | |
|
|
1829 | val64 level_to_min_exp (int level) |
|
|
1830 | |
|
|
1831 | SV * |
|
|
1832 | attacktype_name (int atnr) |
1805 | CODE: |
1833 | CODE: |
1806 | { |
1834 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1807 | int i = 0; |
1835 | ? newSVpv (attacktype_name [atnr], 0) |
1808 | |
1836 | : &PL_sv_undef; |
1809 | RETVAL = settings.max_level; |
|
|
1810 | |
|
|
1811 | for (i = 1; i <= settings.max_level; i++) |
|
|
1812 | { |
|
|
1813 | if (levels[i] > exp) |
|
|
1814 | { |
|
|
1815 | RETVAL = i - 1; |
|
|
1816 | break; |
|
|
1817 | } |
|
|
1818 | } |
|
|
1819 | } |
|
|
1820 | OUTPUT: RETVAL |
1837 | OUTPUT: RETVAL |
1821 | |
1838 | |
1822 | val64 |
|
|
1823 | level_to_min_exp (int level) |
|
|
1824 | CODE: |
|
|
1825 | if (level > settings.max_level) |
|
|
1826 | RETVAL = levels[settings.max_level]; |
|
|
1827 | else if (level < 1) |
|
|
1828 | RETVAL = 0; |
|
|
1829 | else |
|
|
1830 | RETVAL = levels[level]; |
|
|
1831 | OUTPUT: RETVAL |
|
|
1832 | |
|
|
1833 | SV * |
1839 | SV * |
1834 | resistance_to_string (int atnr) |
1840 | attacktype_desc (int atnr) |
1835 | CODE: |
1841 | CODE: |
1836 | if (atnr >= 0 && atnr < NROFATTACKS) |
1842 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1843 | ? newSVpv (attacktype_desc [atnr], 0) |
|
|
1844 | : &PL_sv_undef; |
|
|
1845 | OUTPUT: RETVAL |
|
|
1846 | |
|
|
1847 | SV * |
|
|
1848 | resist_plus (int atnr) |
|
|
1849 | CODE: |
|
|
1850 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1837 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1851 | ? newSVpv (resist_plus [atnr], 0) |
1838 | else |
1852 | : &PL_sv_undef; |
1839 | XSRETURN_UNDEF; |
1853 | OUTPUT: RETVAL |
|
|
1854 | |
|
|
1855 | SV * |
|
|
1856 | change_resist_msg (int atnr) |
|
|
1857 | CODE: |
|
|
1858 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1859 | ? newSVpv (change_resist_msg [atnr], 0) |
|
|
1860 | : &PL_sv_undef; |
1840 | OUTPUT: RETVAL |
1861 | OUTPUT: RETVAL |
1841 | |
1862 | |
1842 | UUID |
1863 | UUID |
1843 | uuid_cur () |
1864 | uuid_cur () |
1844 | CODE: |
1865 | CODE: |
… | |
… | |
1894 | CODE: |
1915 | CODE: |
1895 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1916 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1896 | OUTPUT: |
1917 | OUTPUT: |
1897 | RETVAL |
1918 | RETVAL |
1898 | |
1919 | |
|
|
1920 | bool should_invoke (attachable *obj, int event) |
|
|
1921 | CODE: |
|
|
1922 | RETVAL = obj->should_invoke ((event_type)event); |
|
|
1923 | OUTPUT: RETVAL |
|
|
1924 | |
1899 | void |
1925 | void |
1900 | debug_trace (attachable *obj, bool on = true) |
1926 | debug_trace (attachable *obj, bool on = true) |
1901 | CODE: |
1927 | CODE: |
1902 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1928 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1903 | if (on) |
1929 | if (on) |
… | |
… | |
1962 | int mortals_size () |
1988 | int mortals_size () |
1963 | CODE: |
1989 | CODE: |
1964 | RETVAL = attachable::mortals.size (); |
1990 | RETVAL = attachable::mortals.size (); |
1965 | OUTPUT: RETVAL |
1991 | OUTPUT: RETVAL |
1966 | |
1992 | |
1967 | const_utf8_string slot_use_name (U32 slot) |
1993 | const_utf8_string slot_name (U32 slot) |
1968 | ALIAS: |
1994 | ALIAS: |
|
|
1995 | slot_name = 0 |
|
|
1996 | slot_use_name = 1 |
1969 | slot_nonuse_name = 1 |
1997 | slot_nonuse_name = 2 |
1970 | CODE: |
1998 | CODE: |
1971 | { |
1999 | { |
1972 | if (slot >= NUM_BODY_LOCATIONS) |
2000 | if (slot >= NUM_BODY_LOCATIONS) |
1973 | croak ("body slot index out of range"); |
2001 | croak ("body slot index out of range"); |
1974 | |
2002 | |
1975 | switch (ix) |
2003 | switch (ix) |
1976 | { |
2004 | { |
|
|
2005 | case 0: RETVAL = body_locations[slot].name ; break; |
1977 | case 0: RETVAL = body_locations[slot].use_name; break; |
2006 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1978 | case 1: RETVAL = body_locations[slot].nonuse_name; break; |
2007 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1979 | } |
2008 | } |
1980 | } |
2009 | } |
1981 | OUTPUT: |
2010 | OUTPUT: |
1982 | RETVAL |
2011 | RETVAL |
1983 | |
2012 | |
… | |
… | |
2028 | OUTPUT: |
2057 | OUTPUT: |
2029 | RETVAL |
2058 | RETVAL |
2030 | |
2059 | |
2031 | object *find_best_object_match (object *op, utf8_string match) |
2060 | object *find_best_object_match (object *op, utf8_string match) |
2032 | |
2061 | |
2033 | object *find_marked_object (object *op) |
|
|
2034 | |
|
|
2035 | int need_identify (object *obj); |
|
|
2036 | |
|
|
2037 | int apply_shop_mat (object *shop_mat, object *op); |
2062 | int apply_shop_mat (object *shop_mat, object *op); |
2038 | |
2063 | |
2039 | int move (object *op, int dir, object *originator = op) |
2064 | int move (object *op, int dir, object *originator = op) |
2040 | CODE: |
2065 | CODE: |
2041 | RETVAL = op->move (dir, originator); |
2066 | RETVAL = op->move (dir, originator); |
… | |
… | |
2093 | |
2118 | |
2094 | void pick_up (object *who, object *op) |
2119 | void pick_up (object *who, object *op) |
2095 | |
2120 | |
2096 | void update_object (object *op, int action) |
2121 | void update_object (object *op, int action) |
2097 | |
2122 | |
2098 | void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) |
2123 | void change_exp (object *op, uint64 exp, shstr_tmp skill_name = shstr_tmp (), int flag = 0) |
2099 | |
2124 | |
2100 | void player_lvl_adj (object *who, object *skill = 0) |
2125 | void player_lvl_adj (object *who, object *skill = 0) |
2101 | |
2126 | |
2102 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2127 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2103 | |
2128 | |
… | |
… | |
2452 | for (int x = 0; x < THIS->width; ++x) |
2477 | for (int x = 0; x < THIS->width; ++x) |
2453 | for (int y = 0; y < THIS->height; ++y) |
2478 | for (int y = 0; y < THIS->height; ++y) |
2454 | { |
2479 | { |
2455 | region *rgn = THIS->region (x, y); |
2480 | region *rgn = THIS->region (x, y); |
2456 | |
2481 | |
2457 | //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D |
|
|
2458 | if (object *op = THIS->at (x, y).top) |
2482 | if (object *op = THIS->at (x, y).top) |
2459 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2483 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2460 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2484 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2461 | } |
2485 | } |
2462 | |
2486 | |
… | |
… | |
2468 | if (oblinkpt *obp = map->find_link (connection)) |
2492 | if (oblinkpt *obp = map->find_link (connection)) |
2469 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2493 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2470 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2494 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2471 | |
2495 | |
2472 | void |
2496 | void |
2473 | get_map_flags (maptile *map, int x, int y) |
2497 | xy_normalise (maptile *map, int x, int y, int dir = 0) |
2474 | PPCODE: |
2498 | PPCODE: |
2475 | { |
2499 | { |
2476 | maptile *nmap = 0; |
2500 | mapxy pos (map, x, y); |
2477 | I16 nx = 0, ny = 0; |
2501 | if (!pos.move (dir).normalise ()) |
|
|
2502 | XSRETURN_EMPTY; |
2478 | |
2503 | |
2479 | PUTBACK; |
|
|
2480 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2481 | SPAGAIN; |
|
|
2482 | |
|
|
2483 | EXTEND (SP, 4); |
2504 | EXTEND (SP, 3); |
2484 | PUSHs (sv_2mortal (newSViv (flags))); |
|
|
2485 | |
|
|
2486 | if (GIMME_V == G_ARRAY) |
|
|
2487 | { |
|
|
2488 | PUSHs (sv_2mortal (to_sv (nmap))); |
2505 | PUSHs (sv_2mortal (to_sv (pos.m))); |
2489 | PUSHs (sv_2mortal (newSViv (nx))); |
2506 | PUSHs (sv_2mortal (to_sv (pos.x))); |
2490 | PUSHs (sv_2mortal (newSViv (ny))); |
2507 | PUSHs (sv_2mortal (to_sv (pos.y))); |
2491 | } |
|
|
2492 | } |
2508 | } |
2493 | |
2509 | |
2494 | mapspace * |
2510 | mapspace * |
2495 | ms (maptile *map, unsigned int x, unsigned int y) |
2511 | ms (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2496 | PROTOTYPE: $$$ |
2512 | PROTOTYPE: $$$;$ |
2497 | CODE: |
2513 | CODE: |
2498 | { |
2514 | { |
2499 | maptile *nmap = 0; |
2515 | mapxy pos (map, x, y); |
2500 | I16 nx, ny; |
2516 | if (!pos.move (dir).normalise ()) |
2501 | |
|
|
2502 | PUTBACK; |
|
|
2503 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2504 | SPAGAIN; |
|
|
2505 | |
|
|
2506 | if (!nmap) |
|
|
2507 | XSRETURN_UNDEF; |
2517 | XSRETURN_UNDEF; |
2508 | |
2518 | |
2509 | RETVAL = &nmap->at (nx, ny); |
2519 | RETVAL = &*pos; |
2510 | } |
2520 | } |
2511 | OUTPUT: |
2521 | OUTPUT: |
2512 | RETVAL |
2522 | RETVAL |
2513 | |
2523 | |
2514 | void |
2524 | void |
2515 | at (maptile *map, unsigned int x, unsigned int y) |
2525 | at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2516 | PROTOTYPE: $$$ |
2526 | PROTOTYPE: $$$;$ |
2517 | PPCODE: |
2527 | PPCODE: |
2518 | { |
2528 | mapxy pos (map, x, y); |
2519 | maptile *nmap = 0; |
2529 | if (pos.move (dir).normalise ()) |
2520 | I16 nx, ny; |
|
|
2521 | |
|
|
2522 | PUTBACK; |
|
|
2523 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2524 | SPAGAIN; |
|
|
2525 | |
|
|
2526 | if (nmap) |
|
|
2527 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2530 | for (object *o = pos->bot; o; o = o->above) |
2528 | XPUSHs (sv_2mortal (to_sv (o))); |
2531 | XPUSHs (sv_2mortal (to_sv (o))); |
2529 | } |
|
|
2530 | |
2532 | |
2531 | SV * |
2533 | SV * |
2532 | bot_at (maptile *map, unsigned int x, unsigned int y) |
2534 | bot_at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2533 | PROTOTYPE: $$$ |
2535 | PROTOTYPE: $$$;$ |
2534 | ALIAS: |
2536 | ALIAS: |
2535 | top_at = 1 |
2537 | top_at = 1 |
2536 | flags_at = 2 |
2538 | flags_at = 2 |
2537 | light_at = 3 |
2539 | light_at = 3 |
2538 | move_block_at = 4 |
2540 | move_block_at = 4 |
2539 | move_slow_at = 5 |
2541 | move_slow_at = 5 |
2540 | move_on_at = 6 |
2542 | move_on_at = 6 |
2541 | move_off_at = 7 |
2543 | move_off_at = 7 |
2542 | CODE: |
2544 | CODE: |
2543 | { |
2545 | { |
2544 | sint16 nx = x; |
2546 | mapxy pos (map, x, y); |
2545 | sint16 ny = y; |
2547 | if (!pos.move (dir).normalise ()) |
2546 | |
|
|
2547 | if (!xy_normalise (map, nx, ny)) |
|
|
2548 | XSRETURN_UNDEF; |
2548 | XSRETURN_UNDEF; |
2549 | |
2549 | |
2550 | mapspace &ms = map->at (nx, ny); |
2550 | mapspace &ms = *pos; |
2551 | |
2551 | |
2552 | ms.update (); |
2552 | ms.update (); |
2553 | |
2553 | |
2554 | switch (ix) |
2554 | switch (ix) |
2555 | { |
2555 | { |
… | |
… | |
2565 | } |
2565 | } |
2566 | OUTPUT: RETVAL |
2566 | OUTPUT: RETVAL |
2567 | |
2567 | |
2568 | # worst xs function of my life |
2568 | # worst xs function of my life |
2569 | bool |
2569 | bool |
2570 | _create_random_map (\ |
2570 | _create_random_map (maptile *self, SV *options) |
2571 | maptile *self,\ |
|
|
2572 | utf8_string wallstyle,\ |
|
|
2573 | utf8_string wall_name,\ |
|
|
2574 | utf8_string floorstyle,\ |
|
|
2575 | utf8_string monsterstyle,\ |
|
|
2576 | utf8_string treasurestyle,\ |
|
|
2577 | utf8_string layoutstyle,\ |
|
|
2578 | utf8_string doorstyle,\ |
|
|
2579 | utf8_string decorstyle,\ |
|
|
2580 | utf8_string miningstyle,\ |
|
|
2581 | utf8_string origin_map,\ |
|
|
2582 | utf8_string final_map,\ |
|
|
2583 | utf8_string exitstyle,\ |
|
|
2584 | utf8_string this_map,\ |
|
|
2585 | utf8_string exit_on_final_map,\ |
|
|
2586 | int xsize,\ |
|
|
2587 | int ysize,\ |
|
|
2588 | int expand2x,\ |
|
|
2589 | int layoutoptions1,\ |
|
|
2590 | int layoutoptions2,\ |
|
|
2591 | int layoutoptions3,\ |
|
|
2592 | int symmetry,\ |
|
|
2593 | int difficulty,\ |
|
|
2594 | int difficulty_given,\ |
|
|
2595 | float difficulty_increase,\ |
|
|
2596 | int dungeon_level,\ |
|
|
2597 | int dungeon_depth,\ |
|
|
2598 | int decoroptions,\ |
|
|
2599 | int orientation,\ |
|
|
2600 | int origin_y,\ |
|
|
2601 | int origin_x,\ |
|
|
2602 | U32 random_seed,\ |
|
|
2603 | val64 total_map_hp,\ |
|
|
2604 | int map_layout_style,\ |
|
|
2605 | int treasureoptions,\ |
|
|
2606 | int symmetry_used,\ |
|
|
2607 | region *region,\ |
|
|
2608 | utf8_string custom\ |
|
|
2609 | ) |
|
|
2610 | CODE: |
2571 | CODE: |
2611 | { |
2572 | { |
2612 | random_map_params rmp; |
2573 | random_map_params rmp ((HV *)SvRV (options)); |
2613 | |
|
|
2614 | assign (rmp.wallstyle , wallstyle); |
|
|
2615 | assign (rmp.wall_name , wall_name); |
|
|
2616 | assign (rmp.floorstyle , floorstyle); |
|
|
2617 | assign (rmp.monsterstyle , monsterstyle); |
|
|
2618 | assign (rmp.treasurestyle , treasurestyle); |
|
|
2619 | assign (rmp.layoutstyle , layoutstyle); |
|
|
2620 | assign (rmp.doorstyle , doorstyle); |
|
|
2621 | assign (rmp.decorstyle , decorstyle); |
|
|
2622 | assign (rmp.miningstyle , miningstyle); |
|
|
2623 | assign (rmp.exitstyle , exitstyle); |
|
|
2624 | assign (rmp.exit_on_final_map, exit_on_final_map); |
|
|
2625 | |
|
|
2626 | rmp.origin_map = origin_map; |
|
|
2627 | rmp.final_map = final_map; |
|
|
2628 | rmp.this_map = this_map; |
|
|
2629 | rmp.xsize = xsize; |
|
|
2630 | rmp.ysize = ysize; |
|
|
2631 | rmp.expand2x = expand2x; |
|
|
2632 | rmp.layoutoptions1 = layoutoptions1; |
|
|
2633 | rmp.layoutoptions2 = layoutoptions2; |
|
|
2634 | rmp.layoutoptions3 = layoutoptions3; |
|
|
2635 | rmp.symmetry = symmetry; |
|
|
2636 | rmp.difficulty = difficulty; |
|
|
2637 | rmp.difficulty_given = difficulty_given; |
|
|
2638 | rmp.difficulty_increase = difficulty_increase; |
|
|
2639 | rmp.dungeon_level = dungeon_level; |
|
|
2640 | rmp.dungeon_depth = dungeon_depth; |
|
|
2641 | rmp.decoroptions = decoroptions; |
|
|
2642 | rmp.orientation = orientation; |
|
|
2643 | rmp.origin_y = origin_y; |
|
|
2644 | rmp.origin_x = origin_x; |
|
|
2645 | rmp.random_seed = random_seed; |
|
|
2646 | rmp.total_map_hp = (uint64_t) total_map_hp; |
|
|
2647 | rmp.map_layout_style = map_layout_style; |
|
|
2648 | rmp.treasureoptions = treasureoptions; |
|
|
2649 | rmp.symmetry_used = symmetry_used; |
|
|
2650 | rmp.region = region; |
|
|
2651 | rmp.custom = custom; |
|
|
2652 | |
|
|
2653 | RETVAL = self->generate_random_map (&rmp); |
2574 | RETVAL = self->generate_random_map (&rmp); |
2654 | } |
2575 | } |
2655 | OUTPUT: |
2576 | OUTPUT: |
2656 | RETVAL |
2577 | RETVAL |
2657 | |
2578 | |
… | |
… | |
2688 | void |
2609 | void |
2689 | list () |
2610 | list () |
2690 | PPCODE: |
2611 | PPCODE: |
2691 | for_all_regions (rgn) |
2612 | for_all_regions (rgn) |
2692 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2613 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2693 | |
|
|
2694 | region *find (utf8_string name) |
|
|
2695 | PROTOTYPE: $ |
|
|
2696 | CODE: |
|
|
2697 | RETVAL = region::find (name); |
|
|
2698 | OUTPUT: RETVAL |
|
|
2699 | |
2614 | |
2700 | int specificity (region *rgn) |
2615 | int specificity (region *rgn) |
2701 | CODE: |
2616 | CODE: |
2702 | RETVAL = 0; |
2617 | RETVAL = 0; |
2703 | while (rgn = rgn->parent) |
2618 | while (rgn = rgn->parent) |
… | |
… | |
2807 | while (!RETVAL); // crude way to leave index 0 |
2722 | while (!RETVAL); // crude way to leave index 0 |
2808 | |
2723 | |
2809 | faces [RETVAL].name = name; |
2724 | faces [RETVAL].name = name; |
2810 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2725 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2811 | |
2726 | |
2812 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2727 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2813 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2728 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
|
|
2729 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2814 | } |
2730 | } |
2815 | OUTPUT: RETVAL |
2731 | OUTPUT: RETVAL |
2816 | |
2732 | |
2817 | void set_type (faceidx idx, int value) |
2733 | void set_type (faceidx idx, int value) |
2818 | ALIAS: |
2734 | ALIAS: |
… | |
… | |
2834 | |
2750 | |
2835 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2751 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2836 | CODE: |
2752 | CODE: |
2837 | { |
2753 | { |
2838 | faceinfo *f = face_info (idx); assert (f); |
2754 | faceinfo *f = face_info (idx); assert (f); |
2839 | facedata *d = &(faceset ? f->data64 : f->data32); |
2755 | facedata *d = f->face + faceset; |
2840 | sv_to (data, d->data); |
2756 | sv_to (data, d->data); |
2841 | STRLEN clen; |
2757 | STRLEN clen; |
2842 | char *cdata = SvPVbyte (chksum, clen); |
2758 | char *cdata = SvPVbyte (chksum, clen); |
2843 | clen = min (CHKSUM_MAXLEN, clen); |
2759 | clen = min (CHKSUM_MAXLEN, clen); |
2844 | |
2760 | |
… | |
… | |
2952 | sv_to (sv, self); |
2868 | sv_to (sv, self); |
2953 | delete self; |
2869 | delete self; |
2954 | |
2870 | |
2955 | MODULE = cf PACKAGE = cf::object::thawer |
2871 | MODULE = cf PACKAGE = cf::object::thawer |
2956 | |
2872 | |
2957 | INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/cfperl.h | |
2873 | INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/freezethaw.h | |
|
|
2874 | |
|
|
2875 | bool |
|
|
2876 | errors_are_fatal (bool fatal) |
|
|
2877 | CODE: |
|
|
2878 | RETVAL = object_thawer::errors_are_fatal; |
|
|
2879 | object_thawer::errors_are_fatal = fatal; |
|
|
2880 | OUTPUT: |
|
|
2881 | RETVAL |
2958 | |
2882 | |
2959 | SV * |
2883 | SV * |
2960 | new_from_file (char *klass, octet_string path) |
2884 | new_from_file (char *klass, octet_string path) |
2961 | CODE: |
2885 | CODE: |
2962 | object_thawer *f = new object_thawer (path); |
2886 | object_thawer *f = new object_thawer (path); |
… | |
… | |
2988 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2912 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2989 | |
2913 | |
2990 | self->skip (); |
2914 | self->skip (); |
2991 | } |
2915 | } |
2992 | |
2916 | |
|
|
2917 | MODULE = cf PACKAGE = cf::layout |
|
|
2918 | |
|
|
2919 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
|
|
2920 | |