1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2006,2007,2008,2009,2010,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
10 | * |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
14 | * GNU General Public License for more details. |
15 | * |
15 | * |
16 | * You should have received a copy of the Affero GNU General Public License |
16 | * You should have received a copy of the Affero GNU General Public License |
17 | * and the GNU General Public License along with this program. If not, see |
17 | * and the GNU General Public License along with this program. If not, see |
18 | * <http://www.gnu.org/licenses/>. |
18 | * <http://www.gnu.org/licenses/>. |
19 | * |
19 | * |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | */ |
21 | */ |
22 | |
22 | |
23 | #include "autoconf.h" |
23 | #include "autoconf.h" |
24 | |
24 | |
… | |
… | |
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 "noise.h" |
34 | #include "evthread.h" |
35 | #include "evthread.h" |
35 | #include "sproto.h" |
36 | #include "sproto.h" |
36 | |
37 | |
37 | #include <unistd.h> |
38 | #include <unistd.h> |
38 | #if _POSIX_MEMLOCK |
39 | #if _POSIX_MEMLOCK |
… | |
… | |
52 | #include <XSUB.h> |
53 | #include <XSUB.h> |
53 | |
54 | |
54 | #include "CoroAPI.h" |
55 | #include "CoroAPI.h" |
55 | #include "perlxsi.c" |
56 | #include "perlxsi.c" |
56 | |
57 | |
57 | extern sint64 *levels; // the experience table |
|
|
58 | |
|
|
59 | typedef object_thawer &object_thawer_ref; |
58 | typedef object_thawer &object_thawer_ref; |
60 | typedef object_freezer &object_freezer_ref; |
59 | typedef object_freezer &object_freezer_ref; |
61 | |
60 | |
62 | typedef std::string std__string; |
61 | typedef std::string std__string; |
63 | |
62 | |
… | |
… | |
68 | static int tick_inhibit; |
67 | static int tick_inhibit; |
69 | static int tick_pending; |
68 | static int tick_pending; |
70 | |
69 | |
71 | global gbl_ev; |
70 | global gbl_ev; |
72 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
71 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
73 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; |
72 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now, *sv_server_tick; |
74 | static AV *av_reflect; |
73 | static AV *av_reflect; |
75 | |
74 | |
76 | bitset<NUM_EVENT_TYPES> ev_want_event; |
75 | bitset<NUM_EVENT_TYPES> ev_want_event; |
77 | bitset<NUM_TYPES> ev_want_type; |
76 | bitset<NUM_TYPES> ev_want_type; |
78 | |
77 | |
… | |
… | |
85 | *stash_cf_mapspace_wrap, |
84 | *stash_cf_mapspace_wrap, |
86 | *stash_cf_client_wrap, |
85 | *stash_cf_client_wrap, |
87 | *stash_cf_arch_wrap, |
86 | *stash_cf_arch_wrap, |
88 | *stash_cf_party_wrap, |
87 | *stash_cf_party_wrap, |
89 | *stash_cf_region_wrap, |
88 | *stash_cf_region_wrap, |
90 | *stash_cf_living_wrap; |
89 | *stash_cf_living_wrap, |
|
|
90 | *stash_cf_layout_wrap, |
|
|
91 | *stash_ext_map_world; |
91 | |
92 | |
92 | static SV |
93 | static SV |
93 | *cv_cf_do_invoke, |
94 | *cv_cf_do_invoke, |
94 | *cv_cf__can_merge, |
95 | *cv_cf__can_merge, |
95 | *cv_cf_client_send_msg, |
96 | *cv_cf_client_send_msg, |
… | |
… | |
123 | |
124 | |
124 | return sv; |
125 | return sv; |
125 | } |
126 | } |
126 | #endif |
127 | #endif |
127 | |
128 | |
128 | static noinline utf8_string |
129 | noinline utf8_string |
129 | cfSvPVutf8_nolen (SV *sv) |
130 | cfSvPVutf8_nolen (SV *sv) |
130 | { |
131 | { |
131 | SvGETMAGIC (sv); |
132 | SvGETMAGIC (sv); |
132 | |
133 | |
133 | if (SvPOK (sv)) |
134 | if (SvPOK (sv)) |
… | |
… | |
252 | { |
253 | { |
253 | static int last_mortalcount; |
254 | static int last_mortalcount; |
254 | if (mortals.size () != last_mortalcount) |
255 | if (mortals.size () != last_mortalcount) |
255 | { |
256 | { |
256 | last_mortalcount = mortals.size (); |
257 | last_mortalcount = mortals.size (); |
257 | LOG (llevInfo, "%d mortals.\n", (int)mortals.size ()); |
258 | object *specimen = is_a<object> (mortals [rndm (mortals.size ())]); |
|
|
259 | |
|
|
260 | LOG (llevInfo, "%d mortals (random specimen: %s).\n", |
|
|
261 | (int)mortals.size (), specimen ? specimen->debug_desc () : "(not an object)"); |
258 | |
262 | |
259 | if (0) |
263 | if (0) |
260 | { |
264 | { |
261 | for (int j = 0; j < mortals.size (); ++j)//D |
265 | for (int j = 0; j < mortals.size (); ++j)//D |
262 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
266 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
… | |
… | |
353 | #endif |
357 | #endif |
354 | |
358 | |
355 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
359 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
356 | |
360 | |
357 | static SV * |
361 | static SV * |
358 | newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) |
362 | newSVptr (void *ptr, HV *stash, HV *hv) |
359 | { |
363 | { |
360 | SV *sv; |
|
|
361 | |
|
|
362 | if (!ptr) |
364 | if (!ptr) |
363 | return newSV (0); |
365 | return newSV (0); |
364 | |
366 | |
365 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
367 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
366 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
368 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
|
|
369 | } |
|
|
370 | |
|
|
371 | static SV * noinline |
|
|
372 | newSVptr (void *ptr, HV *stash) |
|
|
373 | { |
|
|
374 | return newSVptr (ptr, stash, newHV ()); |
367 | } |
375 | } |
368 | |
376 | |
369 | static int |
377 | static int |
370 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
378 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
371 | { |
379 | { |
… | |
… | |
383 | return 0; |
391 | return 0; |
384 | } |
392 | } |
385 | |
393 | |
386 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
394 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
387 | |
395 | |
388 | static SV * |
396 | static SV * noinline |
389 | newSVattachable (attachable *obj, HV *stash) |
397 | newSVattachable (attachable *obj, HV *stash) |
390 | { |
398 | { |
391 | if (!obj) |
399 | if (!obj) |
392 | return newSV (0); |
400 | return newSV (0); |
393 | |
401 | |
… | |
… | |
479 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
487 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
480 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
488 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
481 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
489 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
482 | && !sv_derived_from (sv, "cf::object"))) |
490 | && !sv_derived_from (sv, "cf::object"))) |
483 | croak ("object of type cf::object expected"); |
491 | croak ("object of type cf::object expected"); |
|
|
492 | |
|
|
493 | return SvPTR_nc (sv); |
|
|
494 | } |
|
|
495 | |
|
|
496 | static long noinline |
|
|
497 | SvPTR_ornull_maptile (SV *sv) |
|
|
498 | { |
|
|
499 | if (expect_false (!SvOK (sv))) return 0; |
|
|
500 | |
|
|
501 | if (!SvROK (sv) |
|
|
502 | || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap |
|
|
503 | && SvSTASH (SvRV (sv)) != stash_ext_map_world |
|
|
504 | && !sv_derived_from (sv, "cf::map"))) |
|
|
505 | croak ("object of type cf::map expected"); |
484 | |
506 | |
485 | return SvPTR_nc (sv); |
507 | return SvPTR_nc (sv); |
486 | } |
508 | } |
487 | |
509 | |
488 | static long noinline |
510 | static long noinline |
… | |
… | |
513 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
535 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
514 | static inline SV *to_sv (float v) { return newSVnv (v); } |
536 | static inline SV *to_sv (float v) { return newSVnv (v); } |
515 | static inline SV *to_sv (double v) { return newSVnv (v); } |
537 | 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); } |
538 | 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); } |
539 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
|
|
540 | // 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); } |
541 | static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
|
|
542 | 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); } |
543 | 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); } |
544 | 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); } |
545 | 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); } |
546 | 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); } |
547 | 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); } |
548 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
|
|
549 | static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); } |
525 | |
550 | |
526 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
551 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
527 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
552 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
528 | |
553 | |
529 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
554 | 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); } |
590 | 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); } |
591 | 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); } |
592 | 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); } |
593 | 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); } |
594 | 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); } |
595 | 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); } |
596 | 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); } |
597 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
|
|
598 | 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"); } |
599 | 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"); } |
600 | 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"); } |
601 | 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"); } |
602 | 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"); } |
603 | 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"); } |
604 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
|
|
605 | 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"); } |
606 | 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" ); } |
607 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
582 | |
608 | |
583 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
609 | //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)); } |
610 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
597 | static inline void sv_to (SV *sv, std::string &v) |
623 | static inline void sv_to (SV *sv, std::string &v) |
598 | { |
624 | { |
599 | STRLEN len; |
625 | STRLEN len; |
600 | char *data = SvPVbyte (sv, len); |
626 | char *data = SvPVbyte (sv, len); |
601 | v.assign (data, len); |
627 | v.assign (data, len); |
|
|
628 | } |
|
|
629 | |
|
|
630 | static inline void sv_to (SV *sv, refcnt_buf &v) |
|
|
631 | { |
|
|
632 | STRLEN len; |
|
|
633 | char *data = SvPVbyte (sv, len); |
|
|
634 | refcnt_buf buf (data, len); |
|
|
635 | v = buf; |
602 | } |
636 | } |
603 | |
637 | |
604 | static inline void sv_to (SV *sv, UUID &v) |
638 | static inline void sv_to (SV *sv, UUID &v) |
605 | { |
639 | { |
606 | if (!v.parse (SvPV_nolen (sv))) |
640 | if (!v.parse (SvPV_nolen (sv))) |
… | |
… | |
695 | template<class type> |
729 | template<class type> |
696 | static void noinline |
730 | static void noinline |
697 | cf_obj_to (SV *arg, type &var) |
731 | cf_obj_to (SV *arg, type &var) |
698 | { |
732 | { |
699 | sv_to (arg, var); |
733 | sv_to (arg, var); |
700 | if (!var) |
734 | if (expect_false (!var)) |
701 | croak ("must not pass invalid/null cf_obj here"); |
735 | croak ("must not pass invalid/null cf_obj here"); |
702 | } |
736 | } |
703 | |
737 | |
704 | template<class object> |
738 | template<class object> |
705 | static void noinline |
739 | static void noinline |
706 | cf_obj_ornull_to (SV *arg, object *&var) |
740 | cf_obj_ornull_to (SV *arg, object *&var) |
707 | { |
741 | { |
708 | if (SvOK (arg)) |
742 | if (SvOK (arg)) |
709 | { |
743 | { |
710 | sv_to (arg, var); |
744 | sv_to (arg, var); |
711 | if (!var) |
745 | if (expect_false (!var)) |
712 | croak ("unable to convert perl object to C++ object"); |
746 | croak ("unable to convert perl object to C++ object"); |
713 | } |
747 | } |
714 | else |
748 | else |
715 | var = 0; |
749 | var = 0; |
716 | } |
750 | } |
… | |
… | |
751 | exit (EXIT_FAILURE); |
785 | exit (EXIT_FAILURE); |
752 | } |
786 | } |
753 | |
787 | |
754 | eval_pv ( |
788 | eval_pv ( |
755 | "#line 1 'cfperl init'\n" |
789 | "#line 1 'cfperl init'\n" |
756 | "use EV ();\n" |
790 | "use EV ();\n" // required by bootstrap |
757 | "use Coro ();\n" |
791 | "use Coro ();\n" // required by bootstrap |
758 | "cf->bootstrap;\n" |
792 | "cf->bootstrap;\n" // required for cf::datadir |
759 | "unshift @INC, cf::datadir ();\n" |
793 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
760 | "require cf;\n", |
794 | "require cf;\n", |
761 | 0 |
795 | 0 |
762 | ); |
796 | ); |
763 | |
797 | |
764 | if (SvTRUE (ERRSV)) |
798 | if (SvTRUE (ERRSV)) |
… | |
… | |
1139 | |
1173 | |
1140 | return retval; |
1174 | return retval; |
1141 | } |
1175 | } |
1142 | |
1176 | |
1143 | maptile * |
1177 | maptile * |
1144 | find_style (const_utf8_string dirname, const_utf8_string stylename, int difficulty) |
1178 | find_style (const_utf8_string dirname, const_utf8_string stylename, int difficulty, bool recurse) |
1145 | { |
1179 | { |
1146 | CALL_BEGIN (3); |
1180 | CALL_BEGIN (4); |
1147 | CALL_ARG (dirname); |
1181 | CALL_ARG (dirname); |
1148 | CALL_ARG (stylename); |
1182 | CALL_ARG (stylename); |
1149 | CALL_ARG (difficulty); |
1183 | CALL_ARG (difficulty); |
|
|
1184 | CALL_ARG (recurse); |
1150 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
1185 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
1151 | |
1186 | |
1152 | maptile *retval = 0; |
1187 | maptile *retval = 0; |
1153 | if (count) sv_to (POPs, retval); |
1188 | if (count) sv_to (POPs, retval); |
1154 | |
1189 | |
… | |
… | |
1377 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1412 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1378 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1413 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1379 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1414 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1380 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1415 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1381 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1416 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
|
|
1417 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
|
|
1418 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1382 | |
1419 | |
1383 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1420 | 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); |
1421 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
|
|
1422 | sv_server_tick = get_sv ("cf::SERVER_TICK", 1); SvUPGRADE (sv_server_tick, SVt_IV); |
1385 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1423 | 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); |
1424 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1387 | |
1425 | |
1388 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1426 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1389 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1427 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1390 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1428 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1391 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1429 | cb_player = get_av ("cf::CB_PLAYER", 1); |
… | |
… | |
1434 | # include "attackinc.h" |
1472 | # include "attackinc.h" |
1435 | # undef def |
1473 | # undef def |
1436 | # define def(uc, flags) const_iv (SK_ ## uc) |
1474 | # define def(uc, flags) const_iv (SK_ ## uc) |
1437 | # include "skillinc.h" |
1475 | # include "skillinc.h" |
1438 | # undef def |
1476 | # undef def |
1439 | |
1477 | # define def(name, use, nonuse) const_iv (body_ ## name) |
1440 | const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) |
1478 | # include "slotinc.h" |
1441 | const_iv (logBacktrace) |
1479 | # undef def |
1442 | |
|
|
1443 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
|
|
1444 | |
1480 | |
1445 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1481 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1446 | |
1482 | |
1447 | const_iv (MAX_TIME) |
1483 | const_iv (MAX_TIME) |
1448 | const_iv (MAXSOCKBUF) |
1484 | const_iv (MAXSOCKBUF) |
… | |
… | |
1462 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1498 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1463 | |
1499 | |
1464 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1500 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1465 | const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) |
1501 | const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) |
1466 | |
1502 | |
1467 | const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING) |
|
|
1468 | const_iv (MAP_INACTIVE) |
|
|
1469 | |
|
|
1470 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1503 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1471 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1504 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1472 | |
1505 | |
1473 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1506 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1474 | |
1507 | |
1475 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1508 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1476 | }; |
1509 | }; |
1477 | |
1510 | |
1478 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1511 | for (civ = const_iv + array_length (const_iv); civ-- > const_iv; ) |
1479 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1512 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1480 | |
1513 | |
1481 | static const struct { |
1514 | static const struct { |
1482 | const char *name; |
1515 | const char *name; |
1483 | int skip; |
1516 | int skip; |
… | |
… | |
1489 | # undef def |
1522 | # undef def |
1490 | }; |
1523 | }; |
1491 | |
1524 | |
1492 | AV *av = get_av ("cf::EVENT", 1); |
1525 | AV *av = get_av ("cf::EVENT", 1); |
1493 | |
1526 | |
1494 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1527 | for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; ) |
1495 | { |
1528 | { |
1496 | AV *event = newAV (); |
1529 | AV *event = newAV (); |
1497 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1530 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1498 | av_push (event, newSViv (eiv->klass)); |
1531 | av_push (event, newSViv (eiv->klass)); |
1499 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1532 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1506 | |
1539 | |
1507 | void _gv_clear (SV *gv) |
1540 | void _gv_clear (SV *gv) |
1508 | CODE: |
1541 | CODE: |
1509 | assert (SvTYPE (gv) == SVt_PVGV); |
1542 | assert (SvTYPE (gv) == SVt_PVGV); |
1510 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
1543 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
|
|
1544 | SvREFCNT_inc (gv); |
1511 | f (GvGP (gv)->gp_form); |
1545 | f (GvGP (gv)->gp_form); |
1512 | f (GvGP (gv)->gp_io); |
1546 | f (GvGP (gv)->gp_io); |
1513 | f (GvGP (gv)->gp_sv); |
1547 | f (GvGP (gv)->gp_sv); |
1514 | f (GvGP (gv)->gp_av); |
1548 | f (GvGP (gv)->gp_av); |
1515 | f (GvGP (gv)->gp_hv); |
1549 | f (GvGP (gv)->gp_hv); |
1516 | f (GvGP (gv)->gp_cv); |
1550 | f (GvGP (gv)->gp_cv); |
1517 | GvCVGEN (gv) = 0; |
1551 | GvCVGEN (gv) = 0; |
1518 | GvMULTI_off (gv); |
1552 | GvMULTI_off (gv); |
|
|
1553 | SvREFCNT_dec (gv); |
1519 | # undef f |
1554 | # undef f |
1520 | |
1555 | |
1521 | void _connect_to_perl_1 () |
1556 | void _connect_to_perl_1 () |
1522 | |
1557 | |
1523 | void _connect_to_perl_2 () |
1558 | void _connect_to_perl_2 () |
… | |
… | |
1534 | |
1569 | |
1535 | for_all_objects (op) |
1570 | for_all_objects (op) |
1536 | op->reattach (); |
1571 | op->reattach (); |
1537 | } |
1572 | } |
1538 | |
1573 | |
1539 | # support function for map-world.ext |
|
|
1540 | void _quantise (SV *data_sv, SV *plt_sv) |
|
|
1541 | CODE: |
|
|
1542 | { |
|
|
1543 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
|
|
1544 | croak ("_quantise called with invalid agruments"); |
|
|
1545 | |
|
|
1546 | plt_sv = SvRV (plt_sv); |
|
|
1547 | SV **plt = AvARRAY (plt_sv); |
|
|
1548 | int plt_count = AvFILL (plt_sv) + 1; |
|
|
1549 | |
|
|
1550 | STRLEN len; |
|
|
1551 | char *data = SvPVbyte (data_sv, len); |
|
|
1552 | char *dst = data; |
|
|
1553 | |
|
|
1554 | while (len >= 3) |
|
|
1555 | { |
|
|
1556 | for (SV **val_sv = plt + plt_count; val_sv-- > plt; ) |
|
|
1557 | { |
|
|
1558 | char *val = SvPVX (*val_sv); |
|
|
1559 | |
|
|
1560 | if (val [0] == data [0] |
|
|
1561 | && val [1] == data [1] |
|
|
1562 | && val [2] == data [2]) |
|
|
1563 | { |
|
|
1564 | *dst++ = val [3]; |
|
|
1565 | goto next; |
|
|
1566 | } |
|
|
1567 | } |
|
|
1568 | |
|
|
1569 | croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d", |
|
|
1570 | (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2], |
|
|
1571 | dst - SvPVX (data_sv), len); |
|
|
1572 | |
|
|
1573 | next: |
|
|
1574 | data += 3; |
|
|
1575 | len -= 3; |
|
|
1576 | } |
|
|
1577 | |
|
|
1578 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
|
|
1579 | } |
|
|
1580 | |
|
|
1581 | void init_anim () |
1574 | void init_anim () |
1582 | |
1575 | |
1583 | void init_globals () |
1576 | void init_globals () |
1584 | |
1577 | |
1585 | void init_experience () |
|
|
1586 | |
|
|
1587 | void init_attackmess () |
1578 | void init_attackmess () |
1588 | |
1579 | |
1589 | void init_dynamic () |
1580 | void init_dynamic () |
1590 | |
1581 | |
1591 | void load_settings () |
1582 | void load_settings () |
1592 | |
1583 | |
|
|
1584 | void reload_exp_table () |
|
|
1585 | |
1593 | void load_materials () |
1586 | void reload_materials () |
1594 | |
1587 | |
1595 | void init_uuid () |
1588 | void init_uuid () |
1596 | CODE: |
1589 | CODE: |
1597 | UUID::init (); |
1590 | UUID::init (); |
1598 | |
1591 | |
… | |
… | |
1631 | { |
1624 | { |
1632 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1625 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1633 | coroapi::cede (); |
1626 | coroapi::cede (); |
1634 | } |
1627 | } |
1635 | |
1628 | |
1636 | void server_tick () |
1629 | void one_tick () |
1637 | CODE: |
1630 | CODE: |
1638 | { |
1631 | { |
1639 | ev_now_update (EV_DEFAULT); |
1632 | ev_now_update (EV_DEFAULT); |
1640 | NOW = ev_now (EV_DEFAULT); |
1633 | NOW = ev_now (EV_DEFAULT); |
1641 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1634 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1642 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1635 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1643 | runtime = SvNVX (sv_runtime); |
1636 | runtime = SvNVX (sv_runtime); |
1644 | |
1637 | |
|
|
1638 | one_tick (); |
|
|
1639 | |
1645 | server_tick (); |
1640 | ++server_tick; |
|
|
1641 | SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick); |
1646 | |
1642 | |
1647 | ev_now_update (EV_DEFAULT); |
1643 | ev_now_update (EV_DEFAULT); |
1648 | NOW = ev_now (EV_DEFAULT); |
1644 | NOW = ev_now (EV_DEFAULT); |
1649 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1645 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
|
|
1646 | |
1650 | runtime += TICK; |
1647 | runtime += TICK; |
1651 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1648 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1652 | } |
1649 | } |
1653 | |
1650 | |
1654 | NV floor (NV x) |
1651 | NV floor (NV x) |
… | |
… | |
1664 | switch (items) |
1661 | switch (items) |
1665 | { |
1662 | { |
1666 | case 0: RETVAL = gen (); break; |
1663 | case 0: RETVAL = gen (); break; |
1667 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1664 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1668 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1665 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1669 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1666 | default: croak ("cf::rndm requires zero, one or two parameters."); break; |
1670 | } |
1667 | } |
1671 | } |
1668 | } |
1672 | OUTPUT: |
1669 | OUTPUT: |
1673 | RETVAL |
1670 | RETVAL |
1674 | |
1671 | |
… | |
… | |
1753 | |
1750 | |
1754 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1751 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1755 | INIT: |
1752 | INIT: |
1756 | #if __GLIBC__ |
1753 | #if __GLIBC__ |
1757 | mallopt (M_TOP_PAD, 1024 * 1024); |
1754 | mallopt (M_TOP_PAD, 1024 * 1024); |
1758 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); |
1755 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024); |
1759 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1756 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
|
|
1757 | if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10)) |
1760 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1758 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1761 | #endif |
1759 | #endif |
1762 | |
1760 | |
1763 | int munlockall () |
1761 | int munlockall () |
1764 | |
1762 | |
1765 | #endif |
1763 | #endif |
… | |
… | |
1798 | |
1796 | |
1799 | int random_roll (int min, int max, object *op, int goodbad); |
1797 | int random_roll (int min, int max, object *op, int goodbad); |
1800 | |
1798 | |
1801 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1799 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1802 | |
1800 | |
1803 | int |
|
|
1804 | exp_to_level (val64 exp) |
1801 | int exp_to_level (val64 exp) |
|
|
1802 | |
|
|
1803 | val64 level_to_min_exp (int level) |
|
|
1804 | |
|
|
1805 | SV * |
|
|
1806 | attacktype_name (int atnr) |
1805 | CODE: |
1807 | CODE: |
1806 | { |
1808 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1807 | int i = 0; |
1809 | ? newSVpv (attacktype_name [atnr], 0) |
1808 | |
1810 | : &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 |
1811 | OUTPUT: RETVAL |
1821 | |
1812 | |
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 * |
1813 | SV * |
1834 | resistance_to_string (int atnr) |
1814 | attacktype_desc (int atnr) |
1835 | CODE: |
1815 | CODE: |
1836 | if (atnr >= 0 && atnr < NROFATTACKS) |
1816 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1817 | ? newSVpv (attacktype_desc [atnr], 0) |
|
|
1818 | : &PL_sv_undef; |
|
|
1819 | OUTPUT: RETVAL |
|
|
1820 | |
|
|
1821 | SV * |
|
|
1822 | resist_plus (int atnr) |
|
|
1823 | CODE: |
|
|
1824 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1837 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1825 | ? newSVpv (resist_plus [atnr], 0) |
1838 | else |
1826 | : &PL_sv_undef; |
1839 | XSRETURN_UNDEF; |
1827 | OUTPUT: RETVAL |
|
|
1828 | |
|
|
1829 | SV * |
|
|
1830 | change_resist_msg (int atnr) |
|
|
1831 | CODE: |
|
|
1832 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1833 | ? newSVpv (change_resist_msg [atnr], 0) |
|
|
1834 | : &PL_sv_undef; |
1840 | OUTPUT: RETVAL |
1835 | OUTPUT: RETVAL |
1841 | |
1836 | |
1842 | UUID |
1837 | UUID |
1843 | uuid_cur () |
1838 | uuid_cur () |
1844 | CODE: |
1839 | CODE: |
… | |
… | |
1894 | CODE: |
1889 | CODE: |
1895 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1890 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1896 | OUTPUT: |
1891 | OUTPUT: |
1897 | RETVAL |
1892 | RETVAL |
1898 | |
1893 | |
|
|
1894 | bool should_invoke (attachable *obj, int event) |
|
|
1895 | CODE: |
|
|
1896 | RETVAL = obj->should_invoke ((event_type)event); |
|
|
1897 | OUTPUT: RETVAL |
|
|
1898 | |
1899 | void |
1899 | void |
1900 | debug_trace (attachable *obj, bool on = true) |
1900 | debug_trace (attachable *obj, bool on = true) |
1901 | CODE: |
1901 | CODE: |
1902 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1902 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1903 | if (on) |
1903 | if (on) |
… | |
… | |
1962 | int mortals_size () |
1962 | int mortals_size () |
1963 | CODE: |
1963 | CODE: |
1964 | RETVAL = attachable::mortals.size (); |
1964 | RETVAL = attachable::mortals.size (); |
1965 | OUTPUT: RETVAL |
1965 | OUTPUT: RETVAL |
1966 | |
1966 | |
1967 | const_utf8_string slot_use_name (U32 slot) |
1967 | const_utf8_string slot_name (U32 slot) |
1968 | ALIAS: |
1968 | ALIAS: |
|
|
1969 | slot_name = 0 |
|
|
1970 | slot_use_name = 1 |
1969 | slot_nonuse_name = 1 |
1971 | slot_nonuse_name = 2 |
1970 | CODE: |
1972 | CODE: |
1971 | { |
1973 | { |
1972 | if (slot >= NUM_BODY_LOCATIONS) |
1974 | if (slot >= NUM_BODY_LOCATIONS) |
1973 | croak ("body slot index out of range"); |
1975 | croak ("body slot index out of range"); |
1974 | |
1976 | |
1975 | switch (ix) |
1977 | switch (ix) |
1976 | { |
1978 | { |
|
|
1979 | case 0: RETVAL = body_locations[slot].name ; break; |
1977 | case 0: RETVAL = body_locations[slot].use_name; break; |
1980 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1978 | case 1: RETVAL = body_locations[slot].nonuse_name; break; |
1981 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1979 | } |
1982 | } |
1980 | } |
1983 | } |
1981 | OUTPUT: |
1984 | OUTPUT: |
1982 | RETVAL |
1985 | RETVAL |
1983 | |
1986 | |
… | |
… | |
2028 | OUTPUT: |
2031 | OUTPUT: |
2029 | RETVAL |
2032 | RETVAL |
2030 | |
2033 | |
2031 | object *find_best_object_match (object *op, utf8_string match) |
2034 | object *find_best_object_match (object *op, utf8_string match) |
2032 | |
2035 | |
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); |
2036 | int apply_shop_mat (object *shop_mat, object *op); |
2038 | |
2037 | |
2039 | int move (object *op, int dir, object *originator = op) |
2038 | int move (object *op, int dir, object *originator = op) |
2040 | CODE: |
2039 | CODE: |
2041 | RETVAL = op->move (dir, originator); |
2040 | RETVAL = op->move (dir, originator); |
… | |
… | |
2093 | |
2092 | |
2094 | void pick_up (object *who, object *op) |
2093 | void pick_up (object *who, object *op) |
2095 | |
2094 | |
2096 | void update_object (object *op, int action) |
2095 | void update_object (object *op, int action) |
2097 | |
2096 | |
2098 | void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) |
2097 | void change_exp (object *op, uint64 exp, shstr_tmp skill_name = shstr_tmp (), int flag = 0) |
2099 | |
2098 | |
2100 | void player_lvl_adj (object *who, object *skill = 0) |
2099 | void player_lvl_adj (object *who, object *skill = 0) |
2101 | |
2100 | |
2102 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2101 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2103 | |
2102 | |
… | |
… | |
2119 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2118 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2120 | |
2119 | |
2121 | object *new (utf8_string archetype = 0) |
2120 | object *new (utf8_string archetype = 0) |
2122 | PROTOTYPE: ;$ |
2121 | PROTOTYPE: ;$ |
2123 | CODE: |
2122 | CODE: |
2124 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
2123 | RETVAL = archetype |
|
|
2124 | ? archetype::get (archetype) |
|
|
2125 | : object::create (); |
2125 | OUTPUT: |
2126 | OUTPUT: |
2126 | RETVAL |
2127 | RETVAL |
2127 | |
2128 | |
2128 | object *generate (utf8_string arch, object *creator) |
2129 | object *generate (utf8_string arch, object *creator) |
2129 | CODE: |
2130 | CODE: |
2130 | object *obj = get_archetype (arch); |
2131 | object *obj = archetype::get (arch); |
2131 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2132 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2132 | RETVAL = obj; |
2133 | RETVAL = obj; |
2133 | OUTPUT: |
2134 | OUTPUT: |
2134 | RETVAL |
2135 | RETVAL |
2135 | |
2136 | |
… | |
… | |
2145 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2146 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2146 | |
2147 | |
2147 | if (RETVAL->destroyed ()) |
2148 | if (RETVAL->destroyed ()) |
2148 | RETVAL = 0; |
2149 | RETVAL = 0; |
2149 | } |
2150 | } |
|
|
2151 | OUTPUT: |
|
|
2152 | RETVAL |
2150 | |
2153 | |
2151 | shstr |
2154 | shstr |
2152 | object::kv_get (shstr key) |
2155 | object::kv_get (shstr key) |
|
|
2156 | CODE: |
|
|
2157 | RETVAL = THIS->kv.get (key); |
|
|
2158 | OUTPUT: |
|
|
2159 | RETVAL |
2153 | |
2160 | |
2154 | void |
2161 | void |
2155 | object::kv_del (shstr key) |
2162 | object::kv_del (shstr key) |
|
|
2163 | CODE: |
|
|
2164 | THIS->kv.del (key); |
2156 | |
2165 | |
2157 | void |
2166 | void |
2158 | object::kv_set (shstr key, shstr value) |
2167 | object::kv_set (shstr key, shstr value) |
|
|
2168 | CODE: |
|
|
2169 | THIS->kv.set (key, value); |
2159 | |
2170 | |
2160 | object *get_nearest_player (object *ob) |
2171 | object *get_nearest_player (object *ob) |
2161 | ALIAS: nearest_player = 0 |
2172 | ALIAS: nearest_player = 0 |
2162 | PREINIT: |
2173 | PREINIT: |
2163 | extern object *get_nearest_player (object *); |
2174 | extern object *get_nearest_player (object *); |
… | |
… | |
2366 | if (pl->ob && pl->ob->map == THIS) |
2377 | if (pl->ob && pl->ob->map == THIS) |
2367 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2378 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2368 | } |
2379 | } |
2369 | |
2380 | |
2370 | void |
2381 | void |
|
|
2382 | maptile::gen_quadmap (int x, int y, int z) |
|
|
2383 | CODE: |
|
|
2384 | gen_quadmap (THIS, x * 50, y * 50, z); |
|
|
2385 | |
|
|
2386 | void |
2371 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2387 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2372 | CODE: |
2388 | CODE: |
2373 | { |
2389 | { |
2374 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2390 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2375 | croak ("maptile::add_underlay: palette must be arrayref"); |
2391 | croak ("maptile::add_underlay: palette must be arrayref"); |
… | |
… | |
2391 | |
2407 | |
2392 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2408 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2393 | { |
2409 | { |
2394 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2410 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2395 | { |
2411 | { |
2396 | object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); |
2412 | object *ob = archetype::get (cfSvPVutf8_nolen (*elem)); |
2397 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2413 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2398 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2414 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2399 | |
2415 | |
2400 | if (ob->randomitems && !ob->above) |
2416 | if (ob->randomitems && !ob->above) |
2401 | { |
2417 | { |
… | |
… | |
2405 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2421 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2406 | // TODO: if this is a pickable object, then the item |
2422 | // TODO: if this is a pickable object, then the item |
2407 | // will at a bit weird - saving inside the player |
2423 | // will at a bit weird - saving inside the player |
2408 | // will clear the flag, but when the player drops |
2424 | // will clear the flag, but when the player drops |
2409 | // it without logging out, it keeps the flag. |
2425 | // it without logging out, it keeps the flag. |
2410 | // nobody ahs reported this, but this can be rather |
2426 | // nobody has reported this, but this can be rather |
2411 | // annoying on persistent maps. |
2427 | // annoying on persistent maps. |
2412 | } |
2428 | } |
2413 | } |
2429 | } |
2414 | } |
2430 | } |
2415 | } |
2431 | } |
2416 | |
|
|
2417 | skip: ; |
2432 | skip: ; |
2418 | } |
2433 | } |
2419 | } |
2434 | } |
2420 | |
2435 | |
2421 | void |
2436 | void |
… | |
… | |
2452 | for (int x = 0; x < THIS->width; ++x) |
2467 | for (int x = 0; x < THIS->width; ++x) |
2453 | for (int y = 0; y < THIS->height; ++y) |
2468 | for (int y = 0; y < THIS->height; ++y) |
2454 | { |
2469 | { |
2455 | region *rgn = THIS->region (x, y); |
2470 | region *rgn = THIS->region (x, y); |
2456 | |
2471 | |
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) |
2472 | if (object *op = THIS->at (x, y).top) |
2459 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2473 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2460 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2474 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2461 | } |
2475 | } |
2462 | |
2476 | |
… | |
… | |
2468 | if (oblinkpt *obp = map->find_link (connection)) |
2482 | if (oblinkpt *obp = map->find_link (connection)) |
2469 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2483 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2470 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2484 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2471 | |
2485 | |
2472 | void |
2486 | void |
2473 | get_map_flags (maptile *map, int x, int y) |
2487 | xy_normalise (maptile *map, int x, int y, int dir = 0) |
2474 | PPCODE: |
2488 | PPCODE: |
2475 | { |
2489 | { |
2476 | maptile *nmap = 0; |
2490 | mapxy pos (map, x, y); |
2477 | I16 nx = 0, ny = 0; |
2491 | if (!pos.move (dir).normalise ()) |
|
|
2492 | XSRETURN_EMPTY; |
2478 | |
2493 | |
2479 | PUTBACK; |
|
|
2480 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2481 | SPAGAIN; |
|
|
2482 | |
|
|
2483 | EXTEND (SP, 4); |
2494 | EXTEND (SP, 3); |
2484 | PUSHs (sv_2mortal (newSViv (flags))); |
|
|
2485 | |
|
|
2486 | if (GIMME_V == G_ARRAY) |
|
|
2487 | { |
|
|
2488 | PUSHs (sv_2mortal (to_sv (nmap))); |
2495 | PUSHs (sv_2mortal (to_sv (pos.m))); |
2489 | PUSHs (sv_2mortal (newSViv (nx))); |
2496 | PUSHs (sv_2mortal (to_sv (pos.x))); |
2490 | PUSHs (sv_2mortal (newSViv (ny))); |
2497 | PUSHs (sv_2mortal (to_sv (pos.y))); |
2491 | } |
|
|
2492 | } |
2498 | } |
2493 | |
2499 | |
2494 | mapspace * |
2500 | mapspace * |
2495 | ms (maptile *map, unsigned int x, unsigned int y) |
2501 | ms (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2496 | PROTOTYPE: $$$ |
2502 | PROTOTYPE: $$$;$ |
2497 | CODE: |
2503 | CODE: |
2498 | { |
2504 | { |
2499 | maptile *nmap = 0; |
2505 | mapxy pos (map, x, y); |
2500 | I16 nx, ny; |
2506 | 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; |
2507 | XSRETURN_UNDEF; |
2508 | |
2508 | |
2509 | RETVAL = &nmap->at (nx, ny); |
2509 | RETVAL = &*pos; |
2510 | } |
2510 | } |
2511 | OUTPUT: |
2511 | OUTPUT: |
2512 | RETVAL |
2512 | RETVAL |
2513 | |
2513 | |
2514 | void |
2514 | void |
2515 | at (maptile *map, unsigned int x, unsigned int y) |
2515 | at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2516 | PROTOTYPE: $$$ |
2516 | PROTOTYPE: $$$;$ |
2517 | PPCODE: |
2517 | PPCODE: |
2518 | { |
2518 | mapxy pos (map, x, y); |
2519 | maptile *nmap = 0; |
2519 | 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) |
2520 | for (object *o = pos->bot; o; o = o->above) |
2528 | XPUSHs (sv_2mortal (to_sv (o))); |
2521 | XPUSHs (sv_2mortal (to_sv (o))); |
2529 | } |
|
|
2530 | |
2522 | |
2531 | SV * |
2523 | SV * |
2532 | bot_at (maptile *map, unsigned int x, unsigned int y) |
2524 | bot_at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2533 | PROTOTYPE: $$$ |
2525 | PROTOTYPE: $$$;$ |
2534 | ALIAS: |
2526 | ALIAS: |
2535 | top_at = 1 |
2527 | top_at = 1 |
2536 | flags_at = 2 |
2528 | flags_at = 2 |
2537 | light_at = 3 |
2529 | light_at = 3 |
2538 | move_block_at = 4 |
2530 | move_block_at = 4 |
2539 | move_slow_at = 5 |
2531 | move_slow_at = 5 |
2540 | move_on_at = 6 |
2532 | move_on_at = 6 |
2541 | move_off_at = 7 |
2533 | move_off_at = 7 |
2542 | CODE: |
2534 | CODE: |
2543 | { |
2535 | { |
2544 | sint16 nx = x; |
2536 | mapxy pos (map, x, y); |
2545 | sint16 ny = y; |
2537 | if (!pos.move (dir).normalise ()) |
2546 | |
|
|
2547 | if (!xy_normalise (map, nx, ny)) |
|
|
2548 | XSRETURN_UNDEF; |
2538 | XSRETURN_UNDEF; |
2549 | |
2539 | |
2550 | mapspace &ms = map->at (nx, ny); |
2540 | mapspace &ms = *pos; |
2551 | |
2541 | |
2552 | ms.update (); |
2542 | ms.update (); |
2553 | |
2543 | |
2554 | switch (ix) |
2544 | switch (ix) |
2555 | { |
2545 | { |
… | |
… | |
2565 | } |
2555 | } |
2566 | OUTPUT: RETVAL |
2556 | OUTPUT: RETVAL |
2567 | |
2557 | |
2568 | # worst xs function of my life |
2558 | # worst xs function of my life |
2569 | bool |
2559 | bool |
2570 | _create_random_map (\ |
2560 | _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: |
2561 | CODE: |
2611 | { |
2562 | { |
2612 | random_map_params rmp; |
2563 | 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); |
2564 | RETVAL = self->generate_random_map (&rmp); |
2654 | } |
2565 | } |
2655 | OUTPUT: |
2566 | OUTPUT: |
2656 | RETVAL |
2567 | RETVAL |
2657 | |
2568 | |
… | |
… | |
2688 | void |
2599 | void |
2689 | list () |
2600 | list () |
2690 | PPCODE: |
2601 | PPCODE: |
2691 | for_all_regions (rgn) |
2602 | for_all_regions (rgn) |
2692 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2603 | 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 | |
2604 | |
2700 | int specificity (region *rgn) |
2605 | int specificity (region *rgn) |
2701 | CODE: |
2606 | CODE: |
2702 | RETVAL = 0; |
2607 | RETVAL = 0; |
2703 | while (rgn = rgn->parent) |
2608 | while (rgn = rgn->parent) |
… | |
… | |
2797 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2702 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2798 | |
2703 | |
2799 | faceidx alloc (utf8_string name) |
2704 | faceidx alloc (utf8_string name) |
2800 | CODE: |
2705 | CODE: |
2801 | { |
2706 | { |
2802 | do |
2707 | RETVAL = face_alloc (); |
2803 | { |
|
|
2804 | RETVAL = faces.size (); |
|
|
2805 | faces.resize (RETVAL + 1); |
|
|
2806 | } |
|
|
2807 | while (!RETVAL); // crude way to leave index 0 |
|
|
2808 | |
2708 | |
2809 | faces [RETVAL].name = name; |
2709 | faces [RETVAL].name = name; |
2810 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2710 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2811 | |
2711 | |
2812 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2712 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2813 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2713 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
|
|
2714 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2814 | } |
2715 | } |
|
|
2716 | |
|
|
2717 | faceidx faces_size () |
|
|
2718 | CODE: |
|
|
2719 | RETVAL = faces.size (); |
2815 | OUTPUT: RETVAL |
2720 | OUTPUT: RETVAL |
2816 | |
2721 | |
2817 | void set_type (faceidx idx, int value) |
2722 | void set_type (faceidx idx, int value) |
2818 | ALIAS: |
2723 | ALIAS: |
2819 | set_type = 0 |
2724 | set_type = 0 |
… | |
… | |
2834 | |
2739 | |
2835 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2740 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2836 | CODE: |
2741 | CODE: |
2837 | { |
2742 | { |
2838 | faceinfo *f = face_info (idx); assert (f); |
2743 | faceinfo *f = face_info (idx); assert (f); |
2839 | facedata *d = &(faceset ? f->data64 : f->data32); |
2744 | facedata *d = f->face + faceset; |
2840 | sv_to (data, d->data); |
2745 | sv_to (data, d->data); |
2841 | STRLEN clen; |
2746 | STRLEN clen; |
2842 | char *cdata = SvPVbyte (chksum, clen); |
2747 | char *cdata = SvPVbyte (chksum, clen); |
2843 | clen = min (CHKSUM_MAXLEN, clen); |
2748 | clen = min (CHKSUM_MAXLEN, clen); |
2844 | |
2749 | |
… | |
… | |
2865 | if (!d) XSRETURN_UNDEF; |
2770 | if (!d) XSRETURN_UNDEF; |
2866 | RETVAL = d->data.size (); |
2771 | RETVAL = d->data.size (); |
2867 | OUTPUT: |
2772 | OUTPUT: |
2868 | RETVAL |
2773 | RETVAL |
2869 | |
2774 | |
|
|
2775 | void set_meta (faceidx idx, SV *sv) |
|
|
2776 | CODE: |
|
|
2777 | { |
|
|
2778 | faceinfo *f = face_info (idx); assert (f); |
|
|
2779 | SvREFCNT_dec (f->meta_hv); |
|
|
2780 | f->meta_hv = SvOK (sv) ? (HV *)SvREFCNT_inc (SvRV (sv)) : 0; |
|
|
2781 | } |
|
|
2782 | |
2870 | SV *get_chksum (faceidx idx, int faceset = 0) |
2783 | SV *get_chksum (faceidx idx, int faceset = 0) |
2871 | CODE: |
2784 | CODE: |
2872 | facedata *d = face_data (idx, faceset); |
2785 | facedata *d = face_data (idx, faceset); |
2873 | if (!d) XSRETURN_UNDEF; |
2786 | if (!d) XSRETURN_UNDEF; |
2874 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2787 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
… | |
… | |
2877 | |
2790 | |
2878 | SV *get_data (faceidx idx, int faceset = 0) |
2791 | SV *get_data (faceidx idx, int faceset = 0) |
2879 | CODE: |
2792 | CODE: |
2880 | facedata *d = face_data (idx, faceset); |
2793 | facedata *d = face_data (idx, faceset); |
2881 | if (!d) XSRETURN_UNDEF; |
2794 | if (!d) XSRETURN_UNDEF; |
2882 | RETVAL = newSVpvn (d->data.data (), d->data.length ()); |
2795 | RETVAL = newSVpvn (d->data, d->data.size ()); |
2883 | OUTPUT: |
2796 | OUTPUT: |
2884 | RETVAL |
2797 | RETVAL |
2885 | |
2798 | |
|
|
2799 | SV *get_meta (faceidx idx) |
|
|
2800 | CODE: |
|
|
2801 | faceinfo *f = face_info (idx); assert (f); |
|
|
2802 | if (!f || !f->meta_hv) XSRETURN_UNDEF; |
|
|
2803 | RETVAL = newRV_inc ((SV *)f->meta_hv); |
|
|
2804 | OUTPUT: |
|
|
2805 | RETVAL |
|
|
2806 | |
2886 | void invalidate (faceidx idx) |
2807 | void invalidate (faceidx idx) |
2887 | CODE: |
2808 | CODE: |
2888 | for_all_clients (ns) |
2809 | for_all_clients (ns) |
2889 | { |
2810 | ns->invalidate_face (idx); |
2890 | ns->faces_sent [idx] = false; |
|
|
2891 | ns->force_newmap = true; |
|
|
2892 | } |
|
|
2893 | |
2811 | |
2894 | void invalidate_all () |
2812 | void invalidate_all () |
2895 | CODE: |
2813 | CODE: |
2896 | for_all_clients (ns) |
2814 | for_all_clients (ns) |
2897 | { |
2815 | ns->invalidate_all_faces (); |
2898 | ns->faces_sent.reset (); |
|
|
2899 | ns->force_newmap = true; |
|
|
2900 | } |
|
|
2901 | |
2816 | |
2902 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2817 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2903 | |
2818 | |
2904 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2819 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2905 | |
2820 | |
… | |
… | |
2909 | OUTPUT: RETVAL |
2824 | OUTPUT: RETVAL |
2910 | |
2825 | |
2911 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2826 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2912 | CODE: |
2827 | CODE: |
2913 | { |
2828 | { |
2914 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2829 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2915 | croak ("frames must be an arrayref"); |
2830 | croak ("frames must be an arrayref"); |
2916 | |
2831 | |
2917 | AV *av = (AV *)SvRV (frames); |
2832 | AV *av = (AV *)SvRV (frames); |
2918 | |
2833 | |
2919 | animation *anim = &animation::find (name); |
2834 | animation *anim = &animation::find (name); |
2920 | if (anim->number) |
2835 | if (anim->number) |
2921 | { |
2836 | { |
2922 | anim->resize (av_len (av) + 1); |
2837 | anim->resize (av_len (av) + 1); |
2923 | anim->facings = facings; |
2838 | anim->facings = facings; |
2924 | } |
2839 | } |
… | |
… | |
2952 | sv_to (sv, self); |
2867 | sv_to (sv, self); |
2953 | delete self; |
2868 | delete self; |
2954 | |
2869 | |
2955 | MODULE = cf PACKAGE = cf::object::thawer |
2870 | MODULE = cf PACKAGE = cf::object::thawer |
2956 | |
2871 | |
2957 | INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/cfperl.h | |
2872 | INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/freezethaw.h | |
|
|
2873 | |
|
|
2874 | bool |
|
|
2875 | errors_are_fatal (bool fatal) |
|
|
2876 | CODE: |
|
|
2877 | RETVAL = object_thawer::errors_are_fatal; |
|
|
2878 | object_thawer::errors_are_fatal = fatal; |
|
|
2879 | OUTPUT: |
|
|
2880 | RETVAL |
2958 | |
2881 | |
2959 | SV * |
2882 | SV * |
2960 | new_from_file (char *klass, octet_string path) |
2883 | new_from_file (char *klass, octet_string path) |
2961 | CODE: |
2884 | CODE: |
2962 | object_thawer *f = new object_thawer (path); |
2885 | object_thawer *f = new object_thawer (path); |
… | |
… | |
2988 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2911 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2989 | |
2912 | |
2990 | self->skip (); |
2913 | self->skip (); |
2991 | } |
2914 | } |
2992 | |
2915 | |
|
|
2916 | MODULE = cf PACKAGE = cf::layout |
|
|
2917 | |
|
|
2918 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
|
|
2919 | |