… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001-2005,2007 by Chachkoff Yann |
5 | * Copyright (©) 2001-2005,2007 by Chachkoff Yann |
6 | * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de> |
6 | * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de> |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include "autoconf.h" |
25 | #include "autoconf.h" |
… | |
… | |
71 | static int tick_pending; |
72 | static int tick_pending; |
72 | |
73 | |
73 | global gbl_ev; |
74 | global gbl_ev; |
74 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
75 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
75 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; |
76 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; |
|
|
77 | static AV *av_reflect; |
76 | |
78 | |
77 | bitset<NUM_EVENT_TYPES> ev_want_event; |
79 | bitset<NUM_EVENT_TYPES> ev_want_event; |
78 | bitset<NUM_TYPES> ev_want_type; |
80 | bitset<NUM_TYPES> ev_want_type; |
79 | |
81 | |
80 | static HV |
82 | static HV |
… | |
… | |
88 | *stash_cf_arch_wrap, |
90 | *stash_cf_arch_wrap, |
89 | *stash_cf_party_wrap, |
91 | *stash_cf_party_wrap, |
90 | *stash_cf_region_wrap, |
92 | *stash_cf_region_wrap, |
91 | *stash_cf_living_wrap; |
93 | *stash_cf_living_wrap; |
92 | |
94 | |
|
|
95 | static SV |
|
|
96 | *cv_cf_do_invoke, |
|
|
97 | *cv_cf__can_merge, |
|
|
98 | *cv_cf_client_send_msg, |
|
|
99 | *cv_cf_tick, |
|
|
100 | *cv_cf_match_match; |
|
|
101 | |
|
|
102 | #ifndef newSVpv_utf8 |
93 | static inline SV * |
103 | static inline SV * |
94 | newSVpv_utf8 (const char *s) |
104 | newSVpv_utf8 (const char *s) |
95 | { |
105 | { |
96 | if (!s) |
106 | if (!s) |
97 | return newSV (0); |
107 | return newSV (0); |
98 | |
108 | |
99 | SV *sv = newSVpv (s, 0); |
109 | SV *sv = newSVpv (s, 0); |
100 | SvUTF8_on (sv); |
110 | SvUTF8_on (sv); |
101 | return sv; |
111 | return sv; |
102 | } |
112 | } |
|
|
113 | #endif |
103 | |
114 | |
|
|
115 | #ifndef newSVpvn_utf8 |
104 | static inline SV * |
116 | static inline SV * |
105 | newSVpvn_utf8 (const char *s, STRLEN l) |
117 | newSVpvn_utf8 (const char *s, STRLEN l, int utf8) |
106 | { |
118 | { |
107 | if (!s) |
119 | if (!s) |
108 | return newSV (0); |
120 | return newSV (0); |
109 | |
121 | |
110 | SV *sv = newSVpvn (s, l); |
122 | SV *sv = newSVpvn (s, l); |
|
|
123 | |
|
|
124 | if (utf8) |
111 | SvUTF8_on (sv); |
125 | SvUTF8_on (sv); |
|
|
126 | |
112 | return sv; |
127 | return sv; |
113 | } |
128 | } |
|
|
129 | #endif |
114 | |
130 | |
115 | // helper cast function, returns super class * or 0 |
131 | // helper cast function, returns super class * or 0 |
116 | template<class super> |
132 | template<class super> |
117 | static super * |
133 | static super * |
118 | is_a (attachable *at) |
134 | is_a (attachable *at) |
… | |
… | |
151 | SvREFCNT_inc (self); |
167 | SvREFCNT_inc (self); |
152 | hv_clear (self); |
168 | hv_clear (self); |
153 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
169 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
154 | SvREFCNT_dec (self); |
170 | SvREFCNT_dec (self); |
155 | |
171 | |
156 | // self *must* be null now because thats sv_unmagic's job. |
172 | // self *must* be null now because that's sv_unmagic's job. |
157 | assert (!this->self); |
173 | assert (!this->self); |
158 | } |
174 | } |
159 | } |
175 | } |
160 | |
176 | |
161 | void |
177 | void |
… | |
… | |
310 | fprintf (stderr, "P %p\n", pl); |
326 | fprintf (stderr, "P %p\n", pl); |
311 | |
327 | |
312 | for_all_clients (ns) |
328 | for_all_clients (ns) |
313 | if (find_backref (ptr, ns)) |
329 | if (find_backref (ptr, ns)) |
314 | fprintf (stderr, "C %p\n", ns); |
330 | fprintf (stderr, "C %p\n", ns); |
315 | |
|
|
316 | } |
331 | } |
317 | |
332 | |
318 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
333 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
319 | |
334 | |
320 | static SV * |
335 | static SV * |
… | |
… | |
398 | croak ("perl code used %s object, but C object is already destroyed, caught", klass); |
413 | croak ("perl code used %s object, but C object is already destroyed, caught", klass); |
399 | |
414 | |
400 | return (long)mg->mg_ptr; |
415 | return (long)mg->mg_ptr; |
401 | } |
416 | } |
402 | |
417 | |
403 | static long |
418 | static long noinline |
404 | SvPTR_ornull (SV *sv, const char *klass) |
419 | SvPTR_ornull (SV *sv, const char *klass) |
405 | { |
420 | { |
406 | if (SvOK (sv)) |
421 | if (SvOK (sv)) |
407 | return SvPTR (sv, klass); |
422 | return SvPTR (sv, klass); |
408 | else |
423 | else |
409 | return 0; |
424 | return 0; |
410 | } |
425 | } |
411 | |
426 | |
412 | inline SV *to_sv (const shstr & v) { return newSVpvn_utf8 ((const char *)v, v.length ()); } |
427 | inline SV *to_sv (const shstr & v) { return newSVpvn_utf8 ((const char *)v, v.length (), 1); } |
413 | inline SV *to_sv (const char * v) { return v ? newSVpv (v, 0) : newSV (0); } |
428 | inline SV *to_sv (const char * v) { return v ? newSVpv (v, 0) : newSV (0); } |
414 | inline SV *to_sv (bool v) { return newSViv (v); } |
429 | inline SV *to_sv (bool v) { return newSViv (v); } |
415 | inline SV *to_sv ( signed char v) { return newSViv (v); } |
430 | inline SV *to_sv ( signed char v) { return newSViv (v); } |
416 | inline SV *to_sv (unsigned char v) { return newSViv (v); } |
431 | inline SV *to_sv (unsigned char v) { return newSViv (v); } |
417 | inline SV *to_sv ( signed short v) { return newSViv (v); } |
432 | inline SV *to_sv ( signed short v) { return newSViv (v); } |
… | |
… | |
600 | va_end (ap); |
615 | va_end (ap); |
601 | |
616 | |
602 | return sv; |
617 | return sv; |
603 | } |
618 | } |
604 | |
619 | |
|
|
620 | // typemap support, mostly to avoid excessive inlining |
|
|
621 | template<class type> |
|
|
622 | static void noinline |
|
|
623 | cf_obj_to (SV *arg, type &var) |
|
|
624 | { |
|
|
625 | sv_to (arg, var); |
|
|
626 | if (!var) |
|
|
627 | croak ("must not pass invalid/null cf_obj here"); |
|
|
628 | } |
|
|
629 | |
|
|
630 | template<class object> |
|
|
631 | static void noinline |
|
|
632 | cf_obj_ornull_to (SV *arg, object *&var) |
|
|
633 | { |
|
|
634 | if (SvOK (arg)) |
|
|
635 | { |
|
|
636 | sv_to (arg, var); |
|
|
637 | if (!var) |
|
|
638 | croak ("unable to convert perl object to C++ object"); |
|
|
639 | } |
|
|
640 | else |
|
|
641 | var = 0; |
|
|
642 | } |
|
|
643 | |
605 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
644 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
606 | |
645 | |
607 | SV * |
646 | SV * |
608 | registry (attachable *ext) |
647 | registry (attachable *ext) |
609 | { |
648 | { |
… | |
… | |
626 | |
665 | |
627 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
666 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
628 | |
667 | |
629 | const char *argv[] = { |
668 | const char *argv[] = { |
630 | settings.argv [0], |
669 | settings.argv [0], |
631 | "-e" |
670 | "-e0" |
632 | "use EV; use Coro;" // required for bootstrap |
|
|
633 | "cf->bootstrap;" // required for datadir :*> |
|
|
634 | "unshift @INC, cf::datadir ();" |
|
|
635 | "require cf;" |
|
|
636 | }; |
671 | }; |
637 | |
672 | |
638 | if (perl_parse (perl, xs_init, 2, (char **)argv, environ) |
673 | if (perl_parse (perl, xs_init, 2, (char **)argv, environ) |
639 | || perl_run (perl)) |
674 | || perl_run (perl)) |
640 | { |
675 | { |
641 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
676 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
642 | exit (EXIT_FAILURE); |
677 | exit (EXIT_FAILURE); |
643 | } |
678 | } |
644 | |
679 | |
|
|
680 | eval_pv ( |
|
|
681 | "#line 1 'cfperl init'\n" |
|
|
682 | "use EV ();\n" |
|
|
683 | "use Coro ();\n" |
|
|
684 | "cf->bootstrap;\n" |
|
|
685 | "unshift @INC, cf::datadir ();\n" |
|
|
686 | "require cf;\n", |
|
|
687 | 0 |
|
|
688 | ); |
|
|
689 | |
|
|
690 | if (SvTRUE (ERRSV)) |
645 | { |
691 | { |
646 | dSP; |
692 | printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); |
647 | |
693 | exit (EXIT_FAILURE); |
648 | PUSHMARK (SP); |
|
|
649 | PUTBACK; |
|
|
650 | call_pv ("cf::init", G_DISCARD | G_VOID); |
|
|
651 | } |
694 | } |
652 | } |
695 | } |
653 | |
696 | |
|
|
697 | void |
654 | void cfperl_main () |
698 | cfperl_main () |
655 | { |
699 | { |
656 | dSP; |
700 | dSP; |
657 | |
701 | |
658 | PUSHMARK (SP); |
702 | PUSHMARK (SP); |
659 | PUTBACK; |
703 | PUTBACK; |
… | |
… | |
684 | # undef def |
728 | # undef def |
685 | }; |
729 | }; |
686 | |
730 | |
687 | #define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) |
731 | #define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) |
688 | |
732 | |
689 | static void |
733 | static void noinline |
690 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
734 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
691 | { |
735 | { |
692 | // event must be in array |
736 | // event must be in array |
693 | if (event >= 0 && event <= AvFILLp (registry)) |
737 | if (event >= 0 && event <= AvFILLp (registry)) |
694 | { |
738 | { |
… | |
… | |
780 | { |
824 | { |
781 | attachable::gather_callbacks (callbacks, event); |
825 | attachable::gather_callbacks (callbacks, event); |
782 | ::gather_callbacks (callbacks, cb_map, event); |
826 | ::gather_callbacks (callbacks, cb_map, event); |
783 | } |
827 | } |
784 | |
828 | |
785 | void |
829 | static void noinline |
786 | _recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) |
830 | _recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) |
787 | { |
831 | { |
788 | for (int event = 0; event <= AvFILLp (registry); ++event) |
832 | for (int event = 0; event <= AvFILLp (registry); ++event) |
789 | { |
833 | { |
790 | SV *cbs_ = AvARRAY (registry)[event]; |
834 | SV *cbs_ = AvARRAY (registry)[event]; |
… | |
… | |
800 | } |
844 | } |
801 | } |
845 | } |
802 | } |
846 | } |
803 | |
847 | |
804 | // very slow and inefficient way to recalculate the global want bitsets |
848 | // very slow and inefficient way to recalculate the global want bitsets |
805 | void |
849 | static void |
806 | _recalc_want () |
850 | _recalc_want () |
807 | { |
851 | { |
808 | ev_want_event.reset (); |
852 | ev_want_event.reset (); |
809 | |
853 | |
810 | _recalc_want (ev_want_event, cb_global); |
854 | _recalc_want (ev_want_event, cb_global); |
… | |
… | |
883 | XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); |
927 | XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); |
884 | } |
928 | } |
885 | |
929 | |
886 | va_end (ap); |
930 | va_end (ap); |
887 | |
931 | |
888 | CALL_CALL ("cf::do_invoke", G_SCALAR); |
932 | CALL_CALL (cv_cf_do_invoke, G_SCALAR); |
889 | count = count > 0 ? POPi : 0; |
933 | count = count > 0 ? POPi : 0; |
890 | |
934 | |
891 | CALL_END; |
935 | CALL_END; |
892 | |
936 | |
893 | return count; |
937 | return count; |
… | |
… | |
920 | } |
964 | } |
921 | |
965 | |
922 | ///////////////////////////////////////////////////////////////////////////// |
966 | ///////////////////////////////////////////////////////////////////////////// |
923 | // various c++ => perl glue functions |
967 | // various c++ => perl glue functions |
924 | |
968 | |
|
|
969 | void |
925 | void cfperl_tick () |
970 | cfperl_tick () |
926 | { |
971 | { |
927 | tick_pending = 1; |
972 | tick_pending = 1; |
928 | |
973 | |
929 | if (tick_inhibit) |
974 | if (tick_inhibit) |
930 | return; |
975 | return; |
… | |
… | |
933 | |
978 | |
934 | dSP; |
979 | dSP; |
935 | |
980 | |
936 | PUSHMARK (SP); |
981 | PUSHMARK (SP); |
937 | PUTBACK; |
982 | PUTBACK; |
938 | call_pv ("cf::tick", G_DISCARD | G_VOID); |
983 | call_pvsv (cv_cf_tick, G_DISCARD | G_VOID); |
939 | |
984 | |
940 | SvNV_set (sv_next_tick, get_next_tick ()); SvNOK_only (sv_next_tick); |
985 | SvNV_set (sv_next_tick, get_next_tick ()); SvNOK_only (sv_next_tick); |
941 | } |
986 | } |
942 | |
987 | |
943 | void |
988 | void |
… | |
… | |
973 | CALL_BEGIN (4); |
1018 | CALL_BEGIN (4); |
974 | CALL_ARG (ns); |
1019 | CALL_ARG (ns); |
975 | CALL_ARG (type); |
1020 | CALL_ARG (type); |
976 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
1021 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
977 | CALL_ARG (color); |
1022 | CALL_ARG (color); |
978 | CALL_CALL ("cf::client::send_msg", G_VOID); |
1023 | CALL_CALL (cv_cf_client_send_msg, G_VOID); |
979 | CALL_END; |
1024 | CALL_END; |
980 | } |
1025 | } |
981 | |
1026 | |
982 | int |
1027 | int |
983 | cfperl_can_merge (object *ob1, object *ob2) |
1028 | cfperl_can_merge (object *ob1, object *ob2) |
… | |
… | |
985 | int can; |
1030 | int can; |
986 | |
1031 | |
987 | CALL_BEGIN (2); |
1032 | CALL_BEGIN (2); |
988 | CALL_ARG (ob1); |
1033 | CALL_ARG (ob1); |
989 | CALL_ARG (ob2); |
1034 | CALL_ARG (ob2); |
990 | CALL_CALL ("cf::_can_merge", G_SCALAR); |
1035 | CALL_CALL (cv_cf__can_merge, G_SCALAR); |
991 | can = count && SvTRUE (TOPs); |
1036 | can = count && SvTRUE (TOPs); |
992 | CALL_END; |
1037 | CALL_END; |
993 | |
1038 | |
994 | return can; |
1039 | return can; |
|
|
1040 | } |
|
|
1041 | |
|
|
1042 | void |
|
|
1043 | cfperl_mapscript_activate (object *ob, int state, object *activator, object *originator) |
|
|
1044 | { |
|
|
1045 | CALL_BEGIN (4); |
|
|
1046 | CALL_ARG (ob); |
|
|
1047 | CALL_ARG (state); |
|
|
1048 | CALL_ARG (activator); |
|
|
1049 | CALL_ARG (originator); |
|
|
1050 | CALL_CALL ("cf::mapscript::activate", G_VOID); |
|
|
1051 | CALL_END; |
995 | } |
1052 | } |
996 | |
1053 | |
997 | player * |
1054 | player * |
998 | player::find (const char *name) |
1055 | player::find (const char *name) |
999 | { |
1056 | { |
… | |
… | |
1063 | maptile::do_load_sync () |
1120 | maptile::do_load_sync () |
1064 | { |
1121 | { |
1065 | CALL_BEGIN (1); |
1122 | CALL_BEGIN (1); |
1066 | CALL_ARG (this); |
1123 | CALL_ARG (this); |
1067 | CALL_CALL ("cf::map::do_load_sync", G_SCALAR); |
1124 | CALL_CALL ("cf::map::do_load_sync", G_SCALAR); |
1068 | CALL_END; |
|
|
1069 | } |
|
|
1070 | |
|
|
1071 | void |
|
|
1072 | maptile::change_all_map_light (int change) |
|
|
1073 | { |
|
|
1074 | CALL_BEGIN (1); |
|
|
1075 | CALL_ARG (change); |
|
|
1076 | CALL_CALL ("cf::map::change_all_map_light", G_VOID); |
|
|
1077 | CALL_END; |
1125 | CALL_END; |
1078 | } |
1126 | } |
1079 | |
1127 | |
1080 | void |
1128 | void |
1081 | object::enter_exit (object *exit) |
1129 | object::enter_exit (object *exit) |
… | |
… | |
1148 | CALL_CALL ("cf::_log_backtrace", G_VOID); |
1196 | CALL_CALL ("cf::_log_backtrace", G_VOID); |
1149 | CALL_END; |
1197 | CALL_END; |
1150 | #endif |
1198 | #endif |
1151 | } |
1199 | } |
1152 | |
1200 | |
|
|
1201 | bool |
|
|
1202 | is_match_expr (const char *expr) |
|
|
1203 | { |
|
|
1204 | return !strncmp (expr, "match ", sizeof ("match ") - 1); |
|
|
1205 | } |
|
|
1206 | |
|
|
1207 | bool |
|
|
1208 | match (const char *expr, object *ob, object *self, object *source, object *originator) |
|
|
1209 | { |
|
|
1210 | if (!strncmp (expr, "match ", sizeof ("match ") - 1)) |
|
|
1211 | expr += sizeof ("match ") - 1; |
|
|
1212 | |
|
|
1213 | CALL_BEGIN (5); |
|
|
1214 | CALL_ARG (expr); |
|
|
1215 | CALL_ARG (ob); |
|
|
1216 | CALL_ARG (self); |
|
|
1217 | CALL_ARG (source); |
|
|
1218 | CALL_ARG (originator); |
|
|
1219 | CALL_CALL (cv_cf_match_match, G_SCALAR); |
|
|
1220 | |
|
|
1221 | bool matched = count && SvTRUE (TOPs); |
|
|
1222 | |
|
|
1223 | CALL_END; |
|
|
1224 | |
|
|
1225 | return matched; |
|
|
1226 | } |
|
|
1227 | |
1153 | ///////////////////////////////////////////////////////////////////////////// |
1228 | ///////////////////////////////////////////////////////////////////////////// |
1154 | |
1229 | |
1155 | struct EVAPI *evapi::GEVAPI; |
1230 | struct EVAPI *evapi::GEVAPI; |
1156 | struct CoroAPI *coroapi::GCoroAPI; |
1231 | struct CoroAPI *coroapi::GCoroAPI; |
1157 | |
1232 | |
|
|
1233 | void |
1158 | void coroapi::do_cede_to_tick () |
1234 | coroapi::do_cede_to_tick () |
1159 | { |
1235 | { |
1160 | cede_pending = 0; |
1236 | cede_pending = 0; |
1161 | cede (); |
1237 | cede (); |
1162 | } |
1238 | } |
1163 | |
1239 | |
… | |
… | |
1187 | ev_io_set ((ev_io *)this, fd, events); |
1263 | ev_io_set ((ev_io *)this, fd, events); |
1188 | if (active) start (); |
1264 | if (active) start (); |
1189 | } |
1265 | } |
1190 | } |
1266 | } |
1191 | |
1267 | |
1192 | void |
1268 | static void |
1193 | _connect_to_perl () |
1269 | _connect_to_perl_1 () |
1194 | { |
1270 | { |
1195 | stash_cf = gv_stashpv ("cf", 1); |
1271 | stash_cf = gv_stashpv ("cf", 1); |
1196 | |
1272 | |
1197 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1273 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1198 | stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); |
1274 | stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); |
… | |
… | |
1217 | cb_client = get_av ("cf::CB_CLIENT", 1); |
1293 | cb_client = get_av ("cf::CB_CLIENT", 1); |
1218 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1294 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1219 | cb_map = get_av ("cf::CB_MAP" , 1); |
1295 | cb_map = get_av ("cf::CB_MAP" , 1); |
1220 | } |
1296 | } |
1221 | |
1297 | |
|
|
1298 | static void |
|
|
1299 | _connect_to_perl_2 () |
|
|
1300 | { |
|
|
1301 | cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke); |
|
|
1302 | cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge); |
|
|
1303 | cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg); |
|
|
1304 | cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick); |
|
|
1305 | cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match); |
|
|
1306 | } |
|
|
1307 | |
1222 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1308 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1223 | |
1309 | |
1224 | BOOT: |
1310 | BOOT: |
1225 | { |
1311 | { |
1226 | I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; |
1312 | I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; |
1227 | I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; |
1313 | I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; |
1228 | |
1314 | |
1229 | _connect_to_perl (); |
1315 | _connect_to_perl_1 (); |
1230 | |
1316 | |
1231 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1317 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1232 | |
1318 | |
1233 | //{ |
1319 | //{ |
1234 | // require_pv ("Time::HiRes"); |
1320 | // require_pv ("Time::HiRes"); |
… | |
… | |
1278 | const_iv (MOOD_FLOOR) const_iv (EXIT) const_iv (ENCOUNTER) const_iv (SHOP_FLOOR) |
1364 | const_iv (MOOD_FLOOR) const_iv (EXIT) const_iv (ENCOUNTER) const_iv (SHOP_FLOOR) |
1279 | const_iv (SHOP_MAT) const_iv (RING) const_iv (FLOOR) const_iv (FLESH) |
1365 | const_iv (SHOP_MAT) const_iv (RING) const_iv (FLOOR) const_iv (FLESH) |
1280 | const_iv (INORGANIC) const_iv (SKILL_TOOL) const_iv (LIGHTER) const_iv (BUILDABLE_WALL) |
1366 | const_iv (INORGANIC) const_iv (SKILL_TOOL) const_iv (LIGHTER) const_iv (BUILDABLE_WALL) |
1281 | const_iv (MISC_OBJECT) const_iv (LAMP) const_iv (DUPLICATOR) const_iv (SPELLBOOK) |
1367 | const_iv (MISC_OBJECT) const_iv (LAMP) const_iv (DUPLICATOR) const_iv (SPELLBOOK) |
1282 | const_iv (CLOAK) const_iv (SPINNER) const_iv (GATE) const_iv (BUTTON) |
1368 | const_iv (CLOAK) const_iv (SPINNER) const_iv (GATE) const_iv (BUTTON) |
1283 | const_iv (CF_HANDLE) const_iv (HOLE) const_iv (TRAPDOOR) const_iv (SIGN) |
1369 | const_iv (T_HANDLE) const_iv (HOLE) const_iv (TRAPDOOR) const_iv (SIGN) |
1284 | const_iv (BOOTS) const_iv (GLOVES) const_iv (SPELL) const_iv (SPELL_EFFECT) |
1370 | const_iv (BOOTS) const_iv (GLOVES) const_iv (SPELL) const_iv (SPELL_EFFECT) |
1285 | const_iv (CONVERTER) const_iv (BRACERS) const_iv (POISONING) const_iv (SAVEBED) |
1371 | const_iv (CONVERTER) const_iv (BRACERS) const_iv (POISONING) const_iv (SAVEBED) |
1286 | const_iv (WAND) const_iv (SCROLL) const_iv (DIRECTOR) const_iv (GIRDLE) |
1372 | const_iv (WAND) const_iv (SCROLL) const_iv (DIRECTOR) const_iv (GIRDLE) |
1287 | const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON) |
1373 | const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON) |
1288 | const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) |
1374 | const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) |
1289 | const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) |
1375 | const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) |
1290 | const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) |
1376 | const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) |
1291 | const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) |
1377 | const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) |
|
|
1378 | const_iv (MAPSCRIPT) const_iv (SAFE_GROUND) |
1292 | |
1379 | |
1293 | const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) |
1380 | const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) |
1294 | |
1381 | |
1295 | const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) |
1382 | const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) |
1296 | const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) |
1383 | const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) |
… | |
… | |
1328 | const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) |
1415 | const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) |
1329 | const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) |
1416 | const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) |
1330 | const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) |
1417 | const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) |
1331 | const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK) |
1418 | const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK) |
1332 | const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) |
1419 | const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) |
1333 | const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) |
1420 | const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) const_iv (FLAG_WIZLOOK) |
1334 | const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) |
1421 | const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) |
1335 | const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) |
1422 | const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) |
1336 | |
1423 | |
1337 | const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) |
1424 | const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) |
1338 | const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) |
1425 | const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) |
… | |
… | |
1505 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1592 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1506 | av_push (event, newSViv (eiv->klass)); |
1593 | av_push (event, newSViv (eiv->klass)); |
1507 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1594 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1508 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1595 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1509 | } |
1596 | } |
|
|
1597 | |
|
|
1598 | // used by autogenerated BOOT sections from genacc |
|
|
1599 | av_reflect = get_av ("cf::REFLECT", 1); |
1510 | } |
1600 | } |
1511 | |
1601 | |
1512 | void _gv_clear (SV *gv) |
1602 | void _gv_clear (SV *gv) |
1513 | CODE: |
1603 | CODE: |
1514 | assert (SvTYPE (gv) == SVt_PVGV); |
1604 | assert (SvTYPE (gv) == SVt_PVGV); |
… | |
… | |
1521 | f (GvGP (gv)->gp_cv); |
1611 | f (GvGP (gv)->gp_cv); |
1522 | GvCVGEN (gv) = 0; |
1612 | GvCVGEN (gv) = 0; |
1523 | GvMULTI_off (gv); |
1613 | GvMULTI_off (gv); |
1524 | # undef f |
1614 | # undef f |
1525 | |
1615 | |
1526 | |
|
|
1527 | void _connect_to_perl () |
1616 | void _connect_to_perl_1 () |
|
|
1617 | |
|
|
1618 | void _connect_to_perl_2 () |
1528 | |
1619 | |
1529 | void _recalc_want () |
1620 | void _recalc_want () |
1530 | |
1621 | |
|
|
1622 | # not used by default anymore |
1531 | void _global_reattach () |
1623 | void _global_reattach () |
1532 | CODE: |
1624 | CODE: |
1533 | { |
1625 | { |
1534 | // reattach to all attachable objects in the game. |
1626 | // reattach to all attachable objects in the game. |
1535 | for_all_clients (ns) |
1627 | for_all_clients (ns) |
… | |
… | |
1578 | len -= 3; |
1670 | len -= 3; |
1579 | } |
1671 | } |
1580 | |
1672 | |
1581 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1673 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1582 | } |
1674 | } |
|
|
1675 | |
|
|
1676 | void init_anim () |
|
|
1677 | |
|
|
1678 | void init_globals () |
|
|
1679 | |
|
|
1680 | void init_experience () |
|
|
1681 | |
|
|
1682 | void init_attackmess () |
|
|
1683 | |
|
|
1684 | void init_dynamic () |
|
|
1685 | |
|
|
1686 | void load_settings () |
|
|
1687 | |
|
|
1688 | void load_materials () |
|
|
1689 | |
|
|
1690 | void init_uuid () |
|
|
1691 | CODE: |
|
|
1692 | UUID::init (); |
|
|
1693 | |
|
|
1694 | void init_signals () |
|
|
1695 | |
|
|
1696 | void init_commands () |
|
|
1697 | |
|
|
1698 | void init_skills () |
|
|
1699 | |
|
|
1700 | void init_beforeplay () |
1583 | |
1701 | |
1584 | void evthread_start (int aiofd) |
1702 | void evthread_start (int aiofd) |
1585 | |
1703 | |
1586 | void cede_to_tick () |
1704 | void cede_to_tick () |
1587 | CODE: |
1705 | CODE: |
… | |
… | |
1756 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
1874 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
1757 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
1875 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
1758 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
1876 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
1759 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
1877 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
1760 | #endif |
1878 | #endif |
1761 | EXTEND (SP, 2*2); |
1879 | EXTEND (SP, 5*2); |
1762 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
1880 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
1763 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
1881 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
1764 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
1882 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
|
|
1883 | PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count))); |
|
|
1884 | PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount))); |
1765 | } |
1885 | } |
1766 | |
1886 | |
1767 | int find_animation (utf8_string text) |
1887 | int find_animation (utf8_string text) |
1768 | PROTOTYPE: $ |
1888 | PROTOTYPE: $ |
1769 | |
1889 | |
… | |
… | |
2074 | |
2194 | |
2075 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2195 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2076 | |
2196 | |
2077 | int calc_skill_exp (object *who, object *op, object *skill); |
2197 | int calc_skill_exp (object *who, object *op, object *skill); |
2078 | |
2198 | |
2079 | void push_button (object *op); |
2199 | void push_button (object *op, object *originator); |
2080 | |
2200 | |
2081 | void use_trigger (object *op); |
2201 | void use_trigger (object *op, object *originator); |
2082 | |
|
|
2083 | void add_button_link (object *button, maptile *map, int connected); |
|
|
2084 | |
|
|
2085 | void remove_button_link (object *op); |
|
|
2086 | |
2202 | |
2087 | void handle_apply_yield (object *op); |
2203 | void handle_apply_yield (object *op); |
|
|
2204 | |
|
|
2205 | int convert_item (object *item, object *converter); |
2088 | |
2206 | |
2089 | |
2207 | |
2090 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2208 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2091 | |
2209 | |
2092 | # no clean way to get an object from an archetype - stupid idiotic |
2210 | # no clean way to get an object from an archetype - stupid idiotic |
… | |
… | |
2209 | pl->ob->stats.hp = pl->ob->stats.maxhp; |
2327 | pl->ob->stats.hp = pl->ob->stats.maxhp; |
2210 | pl->ob->stats.sp = pl->ob->stats.maxsp; |
2328 | pl->ob->stats.sp = pl->ob->stats.maxsp; |
2211 | pl->ob->stats.grace = pl->ob->stats.maxgrace; |
2329 | pl->ob->stats.grace = pl->ob->stats.maxgrace; |
2212 | pl->orig_stats = pl->ob->stats; |
2330 | pl->orig_stats = pl->ob->stats; |
2213 | |
2331 | |
2214 | void clear_los (player *pl) |
2332 | # should only be temporary |
|
|
2333 | void esrv_new_player (player *pl) |
2215 | |
2334 | |
|
|
2335 | #d# TODO: replace by blocked_los accessor, fix code using this |
2216 | bool |
2336 | bool |
2217 | cell_visible (player *pl, int dx, int dy) |
2337 | cell_visible (player *pl, int dx, int dy) |
2218 | CODE: |
2338 | CODE: |
2219 | RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 |
2339 | RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED; |
2220 | && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]; |
|
|
2221 | OUTPUT: |
2340 | OUTPUT: |
2222 | RETVAL |
2341 | RETVAL |
2223 | |
2342 | |
2224 | void |
2343 | void |
2225 | send (player *pl, SV *packet) |
2344 | send (player *pl, SV *packet) |
… | |
… | |
2293 | } |
2412 | } |
2294 | |
2413 | |
2295 | INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h | |
2414 | INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h | |
2296 | |
2415 | |
2297 | void |
2416 | void |
|
|
2417 | adjust_daylight () |
|
|
2418 | CODE: |
|
|
2419 | maptile::adjust_daylight (); |
|
|
2420 | |
|
|
2421 | int |
|
|
2422 | outdoor_darkness (int darkness = 0) |
|
|
2423 | CODE: |
|
|
2424 | RETVAL = maptile::outdoor_darkness; |
|
|
2425 | if (items) |
|
|
2426 | maptile::outdoor_darkness = darkness; |
|
|
2427 | OUTPUT: |
|
|
2428 | RETVAL |
|
|
2429 | |
|
|
2430 | void |
2298 | maptile::instantiate () |
2431 | maptile::instantiate () |
2299 | |
2432 | |
2300 | maptile *new () |
2433 | maptile *new () |
2301 | PROTOTYPE: |
2434 | PROTOTYPE: |
2302 | CODE: |
2435 | CODE: |
… | |
… | |
2409 | } |
2542 | } |
2410 | |
2543 | |
2411 | int out_of_map (maptile *map, int x, int y) |
2544 | int out_of_map (maptile *map, int x, int y) |
2412 | |
2545 | |
2413 | void |
2546 | void |
2414 | trigger (maptile *map, long connection, bool state = true) |
2547 | find_link (maptile *map, shstr_tmp connection) |
2415 | CODE: |
|
|
2416 | activate_connection (map, connection, state); |
|
|
2417 | |
|
|
2418 | void |
|
|
2419 | get_connection (maptile *map, long connection) |
|
|
2420 | PPCODE: |
2548 | PPCODE: |
2421 | oblinkpt *obp = get_connection_links (map, connection); |
2549 | if (oblinkpt *obp = map->find_link (connection)) |
2422 | if (obp) |
|
|
2423 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2550 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2424 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2551 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2425 | |
2552 | |
2426 | void |
2553 | void |
2427 | get_map_flags (maptile *map, int x, int y) |
2554 | get_map_flags (maptile *map, int x, int y) |
… | |
… | |
2481 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2608 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2482 | XPUSHs (sv_2mortal (to_sv (o))); |
2609 | XPUSHs (sv_2mortal (to_sv (o))); |
2483 | } |
2610 | } |
2484 | |
2611 | |
2485 | SV * |
2612 | SV * |
2486 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2613 | bot_at (maptile *map, unsigned int x, unsigned int y) |
2487 | PROTOTYPE: $$$ |
2614 | PROTOTYPE: $$$ |
2488 | ALIAS: |
2615 | ALIAS: |
2489 | top_at = 1 |
2616 | top_at = 1 |
2490 | flags_at = 2 |
2617 | flags_at = 2 |
2491 | light_at = 3 |
2618 | light_at = 3 |
2492 | move_block_at = 4 |
2619 | move_block_at = 4 |
2493 | move_slow_at = 5 |
2620 | move_slow_at = 5 |
2494 | move_on_at = 6 |
2621 | move_on_at = 6 |
2495 | move_off_at = 7 |
2622 | move_off_at = 7 |
2496 | INIT: |
|
|
2497 | if (x >= obj->width || y >= obj->height) XSRETURN_UNDEF; |
|
|
2498 | CODE: |
2623 | CODE: |
|
|
2624 | { |
|
|
2625 | sint16 nx = x; |
|
|
2626 | sint16 ny = y; |
|
|
2627 | |
|
|
2628 | if (!xy_normalise (map, nx, ny)) |
|
|
2629 | XSRETURN_UNDEF; |
|
|
2630 | |
|
|
2631 | mapspace &ms = map->at (nx, ny); |
|
|
2632 | |
|
|
2633 | ms.update (); |
|
|
2634 | |
2499 | switch (ix) |
2635 | switch (ix) |
2500 | { |
2636 | { |
2501 | case 0: RETVAL = to_sv (GET_MAP_OB (obj, x, y)); break; |
2637 | case 0: RETVAL = to_sv (ms.bot ); break; |
2502 | case 1: RETVAL = to_sv (GET_MAP_TOP (obj, x, y)); break; |
2638 | case 1: RETVAL = to_sv (ms.top ); break; |
2503 | case 2: RETVAL = newSVuv (GET_MAP_FLAGS (obj, x, y)); break; |
2639 | case 2: RETVAL = newSVuv (ms.flags_ ); break; |
2504 | case 3: RETVAL = newSViv (GET_MAP_LIGHT (obj, x, y)); break; |
2640 | case 3: RETVAL = newSViv (ms.light ); break; |
2505 | case 4: RETVAL = newSVuv (GET_MAP_MOVE_BLOCK (obj, x, y)); break; |
2641 | case 4: RETVAL = newSVuv (ms.move_block); break; |
2506 | case 5: RETVAL = newSVuv (GET_MAP_MOVE_SLOW (obj, x, y)); break; |
2642 | case 5: RETVAL = newSVuv (ms.move_slow ); break; |
2507 | case 6: RETVAL = newSVuv (GET_MAP_MOVE_ON (obj, x, y)); break; |
2643 | case 6: RETVAL = newSVuv (ms.move_on ); break; |
2508 | case 7: RETVAL = newSVuv (GET_MAP_MOVE_OFF (obj, x, y)); break; |
2644 | case 7: RETVAL = newSVuv (ms.move_off ); break; |
2509 | } |
2645 | } |
|
|
2646 | } |
2510 | OUTPUT: RETVAL |
2647 | OUTPUT: RETVAL |
2511 | |
|
|
2512 | void fix_walls (maptile *map, int x, int y) |
|
|
2513 | |
|
|
2514 | void fix_walls_around (maptile *map, int x, int y) |
|
|
2515 | |
2648 | |
2516 | # worst xs function of my life |
2649 | # worst xs function of my life |
2517 | bool |
2650 | bool |
2518 | _create_random_map (\ |
2651 | _create_random_map (\ |
2519 | maptile *self,\ |
2652 | maptile *self,\ |
… | |
… | |
2647 | PROTOTYPE: $ |
2780 | PROTOTYPE: $ |
2648 | CODE: |
2781 | CODE: |
2649 | RETVAL = region::find (name); |
2782 | RETVAL = region::find (name); |
2650 | OUTPUT: RETVAL |
2783 | OUTPUT: RETVAL |
2651 | |
2784 | |
2652 | region *find_fuzzy (utf8_string name) |
|
|
2653 | PROTOTYPE: $ |
|
|
2654 | CODE: |
|
|
2655 | RETVAL = region::find_fuzzy (name); |
|
|
2656 | OUTPUT: RETVAL |
|
|
2657 | |
|
|
2658 | int specificity (region *rgn) |
2785 | int specificity (region *rgn) |
2659 | CODE: |
2786 | CODE: |
2660 | RETVAL = 0; |
2787 | RETVAL = 0; |
2661 | while (rgn = rgn->parent) |
2788 | while (rgn = rgn->parent) |
2662 | RETVAL++; |
2789 | RETVAL++; |