… | |
… | |
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 | |
93 | #ifndef newSVpv_utf8 |
102 | #ifndef newSVpv_utf8 |
94 | static inline SV * |
103 | static inline SV * |
95 | newSVpv_utf8 (const char *s) |
104 | newSVpv_utf8 (const char *s) |
96 | { |
105 | { |
97 | if (!s) |
106 | if (!s) |
… | |
… | |
158 | SvREFCNT_inc (self); |
167 | SvREFCNT_inc (self); |
159 | hv_clear (self); |
168 | hv_clear (self); |
160 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
169 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
161 | SvREFCNT_dec (self); |
170 | SvREFCNT_dec (self); |
162 | |
171 | |
163 | // self *must* be null now because thats sv_unmagic's job. |
172 | // self *must* be null now because that's sv_unmagic's job. |
164 | assert (!this->self); |
173 | assert (!this->self); |
165 | } |
174 | } |
166 | } |
175 | } |
167 | |
176 | |
168 | void |
177 | void |
… | |
… | |
317 | fprintf (stderr, "P %p\n", pl); |
326 | fprintf (stderr, "P %p\n", pl); |
318 | |
327 | |
319 | for_all_clients (ns) |
328 | for_all_clients (ns) |
320 | if (find_backref (ptr, ns)) |
329 | if (find_backref (ptr, ns)) |
321 | fprintf (stderr, "C %p\n", ns); |
330 | fprintf (stderr, "C %p\n", ns); |
322 | |
|
|
323 | } |
331 | } |
324 | |
332 | |
325 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
333 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
326 | |
334 | |
327 | static SV * |
335 | static SV * |
… | |
… | |
405 | 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); |
406 | |
414 | |
407 | return (long)mg->mg_ptr; |
415 | return (long)mg->mg_ptr; |
408 | } |
416 | } |
409 | |
417 | |
410 | static long |
418 | static long noinline |
411 | SvPTR_ornull (SV *sv, const char *klass) |
419 | SvPTR_ornull (SV *sv, const char *klass) |
412 | { |
420 | { |
413 | if (SvOK (sv)) |
421 | if (SvOK (sv)) |
414 | return SvPTR (sv, klass); |
422 | return SvPTR (sv, klass); |
415 | else |
423 | else |
… | |
… | |
607 | va_end (ap); |
615 | va_end (ap); |
608 | |
616 | |
609 | return sv; |
617 | return sv; |
610 | } |
618 | } |
611 | |
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 | |
612 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
644 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
613 | |
645 | |
614 | SV * |
646 | SV * |
615 | registry (attachable *ext) |
647 | registry (attachable *ext) |
616 | { |
648 | { |
… | |
… | |
660 | printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); |
692 | printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); |
661 | exit (EXIT_FAILURE); |
693 | exit (EXIT_FAILURE); |
662 | } |
694 | } |
663 | } |
695 | } |
664 | |
696 | |
|
|
697 | void |
665 | void cfperl_main () |
698 | cfperl_main () |
666 | { |
699 | { |
667 | dSP; |
700 | dSP; |
668 | |
701 | |
669 | PUSHMARK (SP); |
702 | PUSHMARK (SP); |
670 | PUTBACK; |
703 | PUTBACK; |
… | |
… | |
695 | # undef def |
728 | # undef def |
696 | }; |
729 | }; |
697 | |
730 | |
698 | #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) |
699 | |
732 | |
700 | static void |
733 | static void noinline |
701 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
734 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
702 | { |
735 | { |
703 | // event must be in array |
736 | // event must be in array |
704 | if (event >= 0 && event <= AvFILLp (registry)) |
737 | if (event >= 0 && event <= AvFILLp (registry)) |
705 | { |
738 | { |
… | |
… | |
791 | { |
824 | { |
792 | attachable::gather_callbacks (callbacks, event); |
825 | attachable::gather_callbacks (callbacks, event); |
793 | ::gather_callbacks (callbacks, cb_map, event); |
826 | ::gather_callbacks (callbacks, cb_map, event); |
794 | } |
827 | } |
795 | |
828 | |
796 | void |
829 | static void noinline |
797 | _recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) |
830 | _recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) |
798 | { |
831 | { |
799 | for (int event = 0; event <= AvFILLp (registry); ++event) |
832 | for (int event = 0; event <= AvFILLp (registry); ++event) |
800 | { |
833 | { |
801 | SV *cbs_ = AvARRAY (registry)[event]; |
834 | SV *cbs_ = AvARRAY (registry)[event]; |
… | |
… | |
811 | } |
844 | } |
812 | } |
845 | } |
813 | } |
846 | } |
814 | |
847 | |
815 | // very slow and inefficient way to recalculate the global want bitsets |
848 | // very slow and inefficient way to recalculate the global want bitsets |
816 | void |
849 | static void |
817 | _recalc_want () |
850 | _recalc_want () |
818 | { |
851 | { |
819 | ev_want_event.reset (); |
852 | ev_want_event.reset (); |
820 | |
853 | |
821 | _recalc_want (ev_want_event, cb_global); |
854 | _recalc_want (ev_want_event, cb_global); |
… | |
… | |
894 | XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); |
927 | XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); |
895 | } |
928 | } |
896 | |
929 | |
897 | va_end (ap); |
930 | va_end (ap); |
898 | |
931 | |
899 | CALL_CALL ("cf::do_invoke", G_SCALAR); |
932 | CALL_CALL (cv_cf_do_invoke, G_SCALAR); |
900 | count = count > 0 ? POPi : 0; |
933 | count = count > 0 ? POPi : 0; |
901 | |
934 | |
902 | CALL_END; |
935 | CALL_END; |
903 | |
936 | |
904 | return count; |
937 | return count; |
… | |
… | |
931 | } |
964 | } |
932 | |
965 | |
933 | ///////////////////////////////////////////////////////////////////////////// |
966 | ///////////////////////////////////////////////////////////////////////////// |
934 | // various c++ => perl glue functions |
967 | // various c++ => perl glue functions |
935 | |
968 | |
|
|
969 | void |
936 | void cfperl_tick () |
970 | cfperl_tick () |
937 | { |
971 | { |
938 | tick_pending = 1; |
972 | tick_pending = 1; |
939 | |
973 | |
940 | if (tick_inhibit) |
974 | if (tick_inhibit) |
941 | return; |
975 | return; |
… | |
… | |
944 | |
978 | |
945 | dSP; |
979 | dSP; |
946 | |
980 | |
947 | PUSHMARK (SP); |
981 | PUSHMARK (SP); |
948 | PUTBACK; |
982 | PUTBACK; |
949 | call_pv ("cf::tick", G_DISCARD | G_VOID); |
983 | call_pvsv (cv_cf_tick, G_DISCARD | G_VOID); |
950 | |
984 | |
951 | 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); |
952 | } |
986 | } |
953 | |
987 | |
954 | void |
988 | void |
… | |
… | |
984 | CALL_BEGIN (4); |
1018 | CALL_BEGIN (4); |
985 | CALL_ARG (ns); |
1019 | CALL_ARG (ns); |
986 | CALL_ARG (type); |
1020 | CALL_ARG (type); |
987 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
1021 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
988 | CALL_ARG (color); |
1022 | CALL_ARG (color); |
989 | CALL_CALL ("cf::client::send_msg", G_VOID); |
1023 | CALL_CALL (cv_cf_client_send_msg, G_VOID); |
990 | CALL_END; |
1024 | CALL_END; |
991 | } |
1025 | } |
992 | |
1026 | |
993 | int |
1027 | int |
994 | cfperl_can_merge (object *ob1, object *ob2) |
1028 | cfperl_can_merge (object *ob1, object *ob2) |
… | |
… | |
996 | int can; |
1030 | int can; |
997 | |
1031 | |
998 | CALL_BEGIN (2); |
1032 | CALL_BEGIN (2); |
999 | CALL_ARG (ob1); |
1033 | CALL_ARG (ob1); |
1000 | CALL_ARG (ob2); |
1034 | CALL_ARG (ob2); |
1001 | CALL_CALL ("cf::_can_merge", G_SCALAR); |
1035 | CALL_CALL (cv_cf__can_merge, G_SCALAR); |
1002 | can = count && SvTRUE (TOPs); |
1036 | can = count && SvTRUE (TOPs); |
1003 | CALL_END; |
1037 | CALL_END; |
1004 | |
1038 | |
1005 | 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; |
1006 | } |
1052 | } |
1007 | |
1053 | |
1008 | player * |
1054 | player * |
1009 | player::find (const char *name) |
1055 | player::find (const char *name) |
1010 | { |
1056 | { |
… | |
… | |
1150 | CALL_CALL ("cf::_log_backtrace", G_VOID); |
1196 | CALL_CALL ("cf::_log_backtrace", G_VOID); |
1151 | CALL_END; |
1197 | CALL_END; |
1152 | #endif |
1198 | #endif |
1153 | } |
1199 | } |
1154 | |
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 | |
1155 | ///////////////////////////////////////////////////////////////////////////// |
1228 | ///////////////////////////////////////////////////////////////////////////// |
1156 | |
1229 | |
1157 | struct EVAPI *evapi::GEVAPI; |
1230 | struct EVAPI *evapi::GEVAPI; |
1158 | struct CoroAPI *coroapi::GCoroAPI; |
1231 | struct CoroAPI *coroapi::GCoroAPI; |
1159 | |
1232 | |
|
|
1233 | void |
1160 | void coroapi::do_cede_to_tick () |
1234 | coroapi::do_cede_to_tick () |
1161 | { |
1235 | { |
1162 | cede_pending = 0; |
1236 | cede_pending = 0; |
1163 | cede (); |
1237 | cede (); |
1164 | } |
1238 | } |
1165 | |
1239 | |
… | |
… | |
1189 | ev_io_set ((ev_io *)this, fd, events); |
1263 | ev_io_set ((ev_io *)this, fd, events); |
1190 | if (active) start (); |
1264 | if (active) start (); |
1191 | } |
1265 | } |
1192 | } |
1266 | } |
1193 | |
1267 | |
1194 | void |
1268 | static void |
1195 | _connect_to_perl () |
1269 | _connect_to_perl_1 () |
1196 | { |
1270 | { |
1197 | stash_cf = gv_stashpv ("cf", 1); |
1271 | stash_cf = gv_stashpv ("cf", 1); |
1198 | |
1272 | |
1199 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1273 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1200 | 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); |
… | |
… | |
1219 | cb_client = get_av ("cf::CB_CLIENT", 1); |
1293 | cb_client = get_av ("cf::CB_CLIENT", 1); |
1220 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1294 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1221 | cb_map = get_av ("cf::CB_MAP" , 1); |
1295 | cb_map = get_av ("cf::CB_MAP" , 1); |
1222 | } |
1296 | } |
1223 | |
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 | |
1224 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1308 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1225 | |
1309 | |
1226 | BOOT: |
1310 | BOOT: |
1227 | { |
1311 | { |
1228 | I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; |
1312 | I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; |
1229 | I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; |
1313 | I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; |
1230 | |
1314 | |
1231 | _connect_to_perl (); |
1315 | _connect_to_perl_1 (); |
1232 | |
1316 | |
1233 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1317 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1234 | |
1318 | |
1235 | //{ |
1319 | //{ |
1236 | // require_pv ("Time::HiRes"); |
1320 | // require_pv ("Time::HiRes"); |
… | |
… | |
1289 | 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) |
1290 | 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) |
1291 | 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) |
1292 | 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) |
1293 | 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) |
1294 | |
1379 | |
1295 | const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) |
1380 | const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) |
1296 | |
1381 | |
1297 | const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) |
1382 | const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) |
1298 | 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) |
… | |
… | |
1507 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1592 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1508 | av_push (event, newSViv (eiv->klass)); |
1593 | av_push (event, newSViv (eiv->klass)); |
1509 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1594 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1510 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1595 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1511 | } |
1596 | } |
|
|
1597 | |
|
|
1598 | // used by autogenerated BOOT sections from genacc |
|
|
1599 | av_reflect = get_av ("cf::REFLECT", 1); |
1512 | } |
1600 | } |
1513 | |
1601 | |
1514 | void _gv_clear (SV *gv) |
1602 | void _gv_clear (SV *gv) |
1515 | CODE: |
1603 | CODE: |
1516 | assert (SvTYPE (gv) == SVt_PVGV); |
1604 | assert (SvTYPE (gv) == SVt_PVGV); |
… | |
… | |
1523 | f (GvGP (gv)->gp_cv); |
1611 | f (GvGP (gv)->gp_cv); |
1524 | GvCVGEN (gv) = 0; |
1612 | GvCVGEN (gv) = 0; |
1525 | GvMULTI_off (gv); |
1613 | GvMULTI_off (gv); |
1526 | # undef f |
1614 | # undef f |
1527 | |
1615 | |
1528 | void _connect_to_perl () |
1616 | void _connect_to_perl_1 () |
|
|
1617 | |
|
|
1618 | void _connect_to_perl_2 () |
1529 | |
1619 | |
1530 | void _recalc_want () |
1620 | void _recalc_want () |
1531 | |
1621 | |
1532 | # not used by default anymore |
1622 | # not used by default anymore |
1533 | void _global_reattach () |
1623 | void _global_reattach () |
… | |
… | |
2104 | |
2194 | |
2105 | 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) |
2106 | |
2196 | |
2107 | int calc_skill_exp (object *who, object *op, object *skill); |
2197 | int calc_skill_exp (object *who, object *op, object *skill); |
2108 | |
2198 | |
2109 | void push_button (object *op); |
2199 | void push_button (object *op, object *originator); |
2110 | |
2200 | |
2111 | void use_trigger (object *op); |
2201 | void use_trigger (object *op, object *originator); |
2112 | |
|
|
2113 | void add_button_link (object *button, maptile *map, int connected); |
|
|
2114 | |
|
|
2115 | void remove_button_link (object *op); |
|
|
2116 | |
2202 | |
2117 | void handle_apply_yield (object *op); |
2203 | void handle_apply_yield (object *op); |
|
|
2204 | |
|
|
2205 | int convert_item (object *item, object *converter); |
2118 | |
2206 | |
2119 | |
2207 | |
2120 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2208 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2121 | |
2209 | |
2122 | # 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 |
… | |
… | |
2328 | void |
2416 | void |
2329 | adjust_daylight () |
2417 | adjust_daylight () |
2330 | CODE: |
2418 | CODE: |
2331 | maptile::adjust_daylight (); |
2419 | maptile::adjust_daylight (); |
2332 | |
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 | |
2333 | void |
2430 | void |
2334 | maptile::instantiate () |
2431 | maptile::instantiate () |
2335 | |
2432 | |
2336 | maptile *new () |
2433 | maptile *new () |
2337 | PROTOTYPE: |
2434 | PROTOTYPE: |
… | |
… | |
2445 | } |
2542 | } |
2446 | |
2543 | |
2447 | int out_of_map (maptile *map, int x, int y) |
2544 | int out_of_map (maptile *map, int x, int y) |
2448 | |
2545 | |
2449 | void |
2546 | void |
2450 | trigger (maptile *map, long connection, bool state = true) |
2547 | find_link (maptile *map, shstr_tmp connection) |
2451 | CODE: |
|
|
2452 | activate_connection (map, connection, state); |
|
|
2453 | |
|
|
2454 | void |
|
|
2455 | get_connection (maptile *map, long connection) |
|
|
2456 | PPCODE: |
2548 | PPCODE: |
2457 | oblinkpt *obp = get_connection_links (map, connection); |
2549 | if (oblinkpt *obp = map->find_link (connection)) |
2458 | if (obp) |
|
|
2459 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2550 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2460 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2551 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2461 | |
2552 | |
2462 | void |
2553 | void |
2463 | get_map_flags (maptile *map, int x, int y) |
2554 | get_map_flags (maptile *map, int x, int y) |
… | |
… | |
2693 | PROTOTYPE: $ |
2784 | PROTOTYPE: $ |
2694 | CODE: |
2785 | CODE: |
2695 | RETVAL = region::find (name); |
2786 | RETVAL = region::find (name); |
2696 | OUTPUT: RETVAL |
2787 | OUTPUT: RETVAL |
2697 | |
2788 | |
2698 | region *find_fuzzy (utf8_string name) |
|
|
2699 | PROTOTYPE: $ |
|
|
2700 | CODE: |
|
|
2701 | RETVAL = region::find_fuzzy (name); |
|
|
2702 | OUTPUT: RETVAL |
|
|
2703 | |
|
|
2704 | int specificity (region *rgn) |
2789 | int specificity (region *rgn) |
2705 | CODE: |
2790 | CODE: |
2706 | RETVAL = 0; |
2791 | RETVAL = 0; |
2707 | while (rgn = rgn->parent) |
2792 | while (rgn = rgn->parent) |
2708 | RETVAL++; |
2793 | RETVAL++; |