… | |
… | |
158 | SvREFCNT_inc (self); |
158 | SvREFCNT_inc (self); |
159 | hv_clear (self); |
159 | hv_clear (self); |
160 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
160 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
161 | SvREFCNT_dec (self); |
161 | SvREFCNT_dec (self); |
162 | |
162 | |
163 | // self *must* be null now because thats sv_unmagic's job. |
163 | // self *must* be null now because that's sv_unmagic's job. |
164 | assert (!this->self); |
164 | assert (!this->self); |
165 | } |
165 | } |
166 | } |
166 | } |
167 | |
167 | |
168 | void |
168 | void |
… | |
… | |
405 | croak ("perl code used %s object, but C object is already destroyed, caught", klass); |
405 | croak ("perl code used %s object, but C object is already destroyed, caught", klass); |
406 | |
406 | |
407 | return (long)mg->mg_ptr; |
407 | return (long)mg->mg_ptr; |
408 | } |
408 | } |
409 | |
409 | |
410 | static long |
410 | static long noinline |
411 | SvPTR_ornull (SV *sv, const char *klass) |
411 | SvPTR_ornull (SV *sv, const char *klass) |
412 | { |
412 | { |
413 | if (SvOK (sv)) |
413 | if (SvOK (sv)) |
414 | return SvPTR (sv, klass); |
414 | return SvPTR (sv, klass); |
415 | else |
415 | else |
… | |
… | |
607 | va_end (ap); |
607 | va_end (ap); |
608 | |
608 | |
609 | return sv; |
609 | return sv; |
610 | } |
610 | } |
611 | |
611 | |
|
|
612 | // typemap support, mostly to avoid excessive inlining |
|
|
613 | template<class type> |
|
|
614 | static void noinline |
|
|
615 | cf_obj_to (SV *arg, type &var) |
|
|
616 | { |
|
|
617 | sv_to (arg, var); |
|
|
618 | if (!var) |
|
|
619 | croak ("must not pass invalid/null cf_obj here"); |
|
|
620 | } |
|
|
621 | |
|
|
622 | template<class object> |
|
|
623 | static void noinline |
|
|
624 | cf_obj_ornull_to (SV *arg, object *&var) |
|
|
625 | { |
|
|
626 | if (SvOK (arg)) |
|
|
627 | { |
|
|
628 | sv_to (arg, var); |
|
|
629 | if (!var) |
|
|
630 | croak ("unable to convert perl object to C++ object"); |
|
|
631 | } |
|
|
632 | else |
|
|
633 | var = 0; |
|
|
634 | } |
|
|
635 | |
612 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
636 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
613 | |
637 | |
614 | SV * |
638 | SV * |
615 | registry (attachable *ext) |
639 | registry (attachable *ext) |
616 | { |
640 | { |
… | |
… | |
660 | printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); |
684 | printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); |
661 | exit (EXIT_FAILURE); |
685 | exit (EXIT_FAILURE); |
662 | } |
686 | } |
663 | } |
687 | } |
664 | |
688 | |
|
|
689 | void |
665 | void cfperl_main () |
690 | cfperl_main () |
666 | { |
691 | { |
667 | dSP; |
692 | dSP; |
668 | |
693 | |
669 | PUSHMARK (SP); |
694 | PUSHMARK (SP); |
670 | PUTBACK; |
695 | PUTBACK; |
… | |
… | |
695 | # undef def |
720 | # undef def |
696 | }; |
721 | }; |
697 | |
722 | |
698 | #define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) |
723 | #define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) |
699 | |
724 | |
700 | static void |
725 | static void noinline |
701 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
726 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
702 | { |
727 | { |
703 | // event must be in array |
728 | // event must be in array |
704 | if (event >= 0 && event <= AvFILLp (registry)) |
729 | if (event >= 0 && event <= AvFILLp (registry)) |
705 | { |
730 | { |
… | |
… | |
791 | { |
816 | { |
792 | attachable::gather_callbacks (callbacks, event); |
817 | attachable::gather_callbacks (callbacks, event); |
793 | ::gather_callbacks (callbacks, cb_map, event); |
818 | ::gather_callbacks (callbacks, cb_map, event); |
794 | } |
819 | } |
795 | |
820 | |
796 | void |
821 | static void noinline |
797 | _recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) |
822 | _recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) |
798 | { |
823 | { |
799 | for (int event = 0; event <= AvFILLp (registry); ++event) |
824 | for (int event = 0; event <= AvFILLp (registry); ++event) |
800 | { |
825 | { |
801 | SV *cbs_ = AvARRAY (registry)[event]; |
826 | SV *cbs_ = AvARRAY (registry)[event]; |
… | |
… | |
811 | } |
836 | } |
812 | } |
837 | } |
813 | } |
838 | } |
814 | |
839 | |
815 | // very slow and inefficient way to recalculate the global want bitsets |
840 | // very slow and inefficient way to recalculate the global want bitsets |
816 | void |
841 | static void |
817 | _recalc_want () |
842 | _recalc_want () |
818 | { |
843 | { |
819 | ev_want_event.reset (); |
844 | ev_want_event.reset (); |
820 | |
845 | |
821 | _recalc_want (ev_want_event, cb_global); |
846 | _recalc_want (ev_want_event, cb_global); |
… | |
… | |
931 | } |
956 | } |
932 | |
957 | |
933 | ///////////////////////////////////////////////////////////////////////////// |
958 | ///////////////////////////////////////////////////////////////////////////// |
934 | // various c++ => perl glue functions |
959 | // various c++ => perl glue functions |
935 | |
960 | |
|
|
961 | void |
936 | void cfperl_tick () |
962 | cfperl_tick () |
937 | { |
963 | { |
938 | tick_pending = 1; |
964 | tick_pending = 1; |
939 | |
965 | |
940 | if (tick_inhibit) |
966 | if (tick_inhibit) |
941 | return; |
967 | return; |
… | |
… | |
1003 | CALL_END; |
1029 | CALL_END; |
1004 | |
1030 | |
1005 | return can; |
1031 | return can; |
1006 | } |
1032 | } |
1007 | |
1033 | |
|
|
1034 | void |
|
|
1035 | cfperl_mapscript_activate (object *ob, object *activator, int state) |
|
|
1036 | { |
|
|
1037 | CALL_BEGIN (3); |
|
|
1038 | CALL_ARG (ob); |
|
|
1039 | CALL_ARG (activator); |
|
|
1040 | CALL_ARG (state); |
|
|
1041 | CALL_CALL ("cf::mapscript::activate", G_VOID); |
|
|
1042 | CALL_END; |
|
|
1043 | } |
|
|
1044 | |
1008 | player * |
1045 | player * |
1009 | player::find (const char *name) |
1046 | player::find (const char *name) |
1010 | { |
1047 | { |
1011 | CALL_BEGIN (1); |
1048 | CALL_BEGIN (1); |
1012 | CALL_ARG (name); |
1049 | CALL_ARG (name); |
… | |
… | |
1074 | maptile::do_load_sync () |
1111 | maptile::do_load_sync () |
1075 | { |
1112 | { |
1076 | CALL_BEGIN (1); |
1113 | CALL_BEGIN (1); |
1077 | CALL_ARG (this); |
1114 | CALL_ARG (this); |
1078 | CALL_CALL ("cf::map::do_load_sync", G_SCALAR); |
1115 | CALL_CALL ("cf::map::do_load_sync", G_SCALAR); |
1079 | CALL_END; |
|
|
1080 | } |
|
|
1081 | |
|
|
1082 | void |
|
|
1083 | maptile::change_all_map_light (int change) |
|
|
1084 | { |
|
|
1085 | CALL_BEGIN (1); |
|
|
1086 | CALL_ARG (change); |
|
|
1087 | CALL_CALL ("cf::map::change_all_map_light", G_VOID); |
|
|
1088 | CALL_END; |
1116 | CALL_END; |
1089 | } |
1117 | } |
1090 | |
1118 | |
1091 | void |
1119 | void |
1092 | object::enter_exit (object *exit) |
1120 | object::enter_exit (object *exit) |
… | |
… | |
1164 | ///////////////////////////////////////////////////////////////////////////// |
1192 | ///////////////////////////////////////////////////////////////////////////// |
1165 | |
1193 | |
1166 | struct EVAPI *evapi::GEVAPI; |
1194 | struct EVAPI *evapi::GEVAPI; |
1167 | struct CoroAPI *coroapi::GCoroAPI; |
1195 | struct CoroAPI *coroapi::GCoroAPI; |
1168 | |
1196 | |
|
|
1197 | void |
1169 | void coroapi::do_cede_to_tick () |
1198 | coroapi::do_cede_to_tick () |
1170 | { |
1199 | { |
1171 | cede_pending = 0; |
1200 | cede_pending = 0; |
1172 | cede (); |
1201 | cede (); |
1173 | } |
1202 | } |
1174 | |
1203 | |
… | |
… | |
1198 | ev_io_set ((ev_io *)this, fd, events); |
1227 | ev_io_set ((ev_io *)this, fd, events); |
1199 | if (active) start (); |
1228 | if (active) start (); |
1200 | } |
1229 | } |
1201 | } |
1230 | } |
1202 | |
1231 | |
1203 | void |
1232 | static void |
1204 | _connect_to_perl () |
1233 | _connect_to_perl () |
1205 | { |
1234 | { |
1206 | stash_cf = gv_stashpv ("cf", 1); |
1235 | stash_cf = gv_stashpv ("cf", 1); |
1207 | |
1236 | |
1208 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
1237 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
… | |
… | |
1298 | const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON) |
1327 | const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON) |
1299 | const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) |
1328 | const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) |
1300 | const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) |
1329 | const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) |
1301 | const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) |
1330 | const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) |
1302 | const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) |
1331 | const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) |
|
|
1332 | const_iv (MAPSCRIPT) const_iv (SAFE_GROUND) |
1303 | |
1333 | |
1304 | const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) |
1334 | const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) |
1305 | |
1335 | |
1306 | const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) |
1336 | const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) |
1307 | const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) |
1337 | const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) |
… | |
… | |
1339 | const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) |
1369 | const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) |
1340 | const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) |
1370 | const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) |
1341 | const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) |
1371 | const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) |
1342 | const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK) |
1372 | const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK) |
1343 | const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) |
1373 | const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) |
1344 | const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) |
1374 | const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) const_iv (FLAG_WIZLOOK) |
1345 | const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) |
1375 | const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) |
1346 | const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) |
1376 | const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) |
1347 | |
1377 | |
1348 | const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) |
1378 | const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) |
1349 | const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) |
1379 | const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) |
… | |
… | |
1600 | |
1630 | |
1601 | void init_attackmess () |
1631 | void init_attackmess () |
1602 | |
1632 | |
1603 | void init_dynamic () |
1633 | void init_dynamic () |
1604 | |
1634 | |
1605 | void init_block () |
|
|
1606 | |
|
|
1607 | void load_settings () |
1635 | void load_settings () |
1608 | |
1636 | |
1609 | void load_materials () |
1637 | void load_materials () |
1610 | |
1638 | |
1611 | void init_uuid () |
1639 | void init_uuid () |
… | |
… | |
1795 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
1823 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
1796 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
1824 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
1797 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
1825 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
1798 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
1826 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
1799 | #endif |
1827 | #endif |
1800 | EXTEND (SP, 2*2); |
1828 | EXTEND (SP, 5*2); |
1801 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
1829 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
1802 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
1830 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
1803 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
1831 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
|
|
1832 | PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count))); |
|
|
1833 | PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount))); |
1804 | } |
1834 | } |
1805 | |
1835 | |
1806 | int find_animation (utf8_string text) |
1836 | int find_animation (utf8_string text) |
1807 | PROTOTYPE: $ |
1837 | PROTOTYPE: $ |
1808 | |
1838 | |
… | |
… | |
2117 | |
2147 | |
2118 | void push_button (object *op); |
2148 | void push_button (object *op); |
2119 | |
2149 | |
2120 | void use_trigger (object *op); |
2150 | void use_trigger (object *op); |
2121 | |
2151 | |
2122 | void add_button_link (object *button, maptile *map, int connected); |
|
|
2123 | |
|
|
2124 | void remove_button_link (object *op); |
|
|
2125 | |
|
|
2126 | void handle_apply_yield (object *op); |
2152 | void handle_apply_yield (object *op); |
2127 | |
2153 | |
2128 | |
2154 | |
2129 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2155 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2130 | |
2156 | |
… | |
… | |
2248 | pl->ob->stats.hp = pl->ob->stats.maxhp; |
2274 | pl->ob->stats.hp = pl->ob->stats.maxhp; |
2249 | pl->ob->stats.sp = pl->ob->stats.maxsp; |
2275 | pl->ob->stats.sp = pl->ob->stats.maxsp; |
2250 | pl->ob->stats.grace = pl->ob->stats.maxgrace; |
2276 | pl->ob->stats.grace = pl->ob->stats.maxgrace; |
2251 | pl->orig_stats = pl->ob->stats; |
2277 | pl->orig_stats = pl->ob->stats; |
2252 | |
2278 | |
2253 | void clear_los (player *pl) |
|
|
2254 | |
|
|
2255 | # should only be temporary |
2279 | # should only be temporary |
2256 | void esrv_new_player (player *pl) |
2280 | void esrv_new_player (player *pl) |
2257 | |
2281 | |
|
|
2282 | #d# TODO: replace by blocked_los accessor, fix code using this |
2258 | bool |
2283 | bool |
2259 | cell_visible (player *pl, int dx, int dy) |
2284 | cell_visible (player *pl, int dx, int dy) |
2260 | CODE: |
2285 | CODE: |
2261 | RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 |
2286 | RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED; |
2262 | && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]; |
|
|
2263 | OUTPUT: |
2287 | OUTPUT: |
2264 | RETVAL |
2288 | RETVAL |
2265 | |
2289 | |
2266 | void |
2290 | void |
2267 | send (player *pl, SV *packet) |
2291 | send (player *pl, SV *packet) |
… | |
… | |
2335 | } |
2359 | } |
2336 | |
2360 | |
2337 | INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h | |
2361 | INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h | |
2338 | |
2362 | |
2339 | void |
2363 | void |
|
|
2364 | adjust_daylight () |
|
|
2365 | CODE: |
|
|
2366 | maptile::adjust_daylight (); |
|
|
2367 | |
|
|
2368 | void |
2340 | maptile::instantiate () |
2369 | maptile::instantiate () |
2341 | |
2370 | |
2342 | maptile *new () |
2371 | maptile *new () |
2343 | PROTOTYPE: |
2372 | PROTOTYPE: |
2344 | CODE: |
2373 | CODE: |
… | |
… | |
2451 | } |
2480 | } |
2452 | |
2481 | |
2453 | int out_of_map (maptile *map, int x, int y) |
2482 | int out_of_map (maptile *map, int x, int y) |
2454 | |
2483 | |
2455 | void |
2484 | void |
2456 | trigger (maptile *map, long connection, bool state = true) |
2485 | find_link (maptile *map, shstr_tmp connection) |
2457 | CODE: |
|
|
2458 | activate_connection (map, connection, state); |
|
|
2459 | |
|
|
2460 | void |
|
|
2461 | get_connection (maptile *map, long connection) |
|
|
2462 | PPCODE: |
2486 | PPCODE: |
2463 | oblinkpt *obp = get_connection_links (map, connection); |
2487 | if (oblinkpt *obp = map->find_link (connection)) |
2464 | if (obp) |
|
|
2465 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2488 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2466 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2489 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2467 | |
2490 | |
2468 | void |
2491 | void |
2469 | get_map_flags (maptile *map, int x, int y) |
2492 | get_map_flags (maptile *map, int x, int y) |
… | |
… | |
2523 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2546 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2524 | XPUSHs (sv_2mortal (to_sv (o))); |
2547 | XPUSHs (sv_2mortal (to_sv (o))); |
2525 | } |
2548 | } |
2526 | |
2549 | |
2527 | SV * |
2550 | SV * |
2528 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2551 | bot_at (maptile *map, unsigned int x, unsigned int y) |
2529 | PROTOTYPE: $$$ |
2552 | PROTOTYPE: $$$ |
2530 | ALIAS: |
2553 | ALIAS: |
2531 | top_at = 1 |
2554 | top_at = 1 |
2532 | flags_at = 2 |
2555 | flags_at = 2 |
2533 | light_at = 3 |
2556 | light_at = 3 |
2534 | move_block_at = 4 |
2557 | move_block_at = 4 |
2535 | move_slow_at = 5 |
2558 | move_slow_at = 5 |
2536 | move_on_at = 6 |
2559 | move_on_at = 6 |
2537 | move_off_at = 7 |
2560 | move_off_at = 7 |
2538 | INIT: |
|
|
2539 | if (x >= obj->width || y >= obj->height) XSRETURN_UNDEF; |
|
|
2540 | CODE: |
2561 | CODE: |
|
|
2562 | { |
|
|
2563 | sint16 nx = x; |
|
|
2564 | sint16 ny = y; |
|
|
2565 | |
|
|
2566 | if (!xy_normalise (map, nx, ny)) |
|
|
2567 | XSRETURN_UNDEF; |
|
|
2568 | |
|
|
2569 | mapspace &ms = map->at (nx, ny); |
|
|
2570 | |
|
|
2571 | ms.update (); |
|
|
2572 | |
2541 | switch (ix) |
2573 | switch (ix) |
2542 | { |
2574 | { |
2543 | case 0: RETVAL = to_sv (GET_MAP_OB (obj, x, y)); break; |
2575 | case 0: RETVAL = to_sv (ms.bot ); break; |
2544 | case 1: RETVAL = to_sv (GET_MAP_TOP (obj, x, y)); break; |
2576 | case 1: RETVAL = to_sv (ms.top ); break; |
2545 | case 2: RETVAL = newSVuv (GET_MAP_FLAGS (obj, x, y)); break; |
2577 | case 2: RETVAL = newSVuv (ms.flags_ ); break; |
2546 | case 3: RETVAL = newSViv (GET_MAP_LIGHT (obj, x, y)); break; |
2578 | case 3: RETVAL = newSViv (ms.light ); break; |
2547 | case 4: RETVAL = newSVuv (GET_MAP_MOVE_BLOCK (obj, x, y)); break; |
2579 | case 4: RETVAL = newSVuv (ms.move_block); break; |
2548 | case 5: RETVAL = newSVuv (GET_MAP_MOVE_SLOW (obj, x, y)); break; |
2580 | case 5: RETVAL = newSVuv (ms.move_slow ); break; |
2549 | case 6: RETVAL = newSVuv (GET_MAP_MOVE_ON (obj, x, y)); break; |
2581 | case 6: RETVAL = newSVuv (ms.move_on ); break; |
2550 | case 7: RETVAL = newSVuv (GET_MAP_MOVE_OFF (obj, x, y)); break; |
2582 | case 7: RETVAL = newSVuv (ms.move_off ); break; |
2551 | } |
2583 | } |
|
|
2584 | } |
2552 | OUTPUT: RETVAL |
2585 | OUTPUT: RETVAL |
2553 | |
2586 | |
2554 | void fix_walls (maptile *map, int x, int y) |
2587 | void fix_walls (maptile *map, int x, int y) |
2555 | |
2588 | |
2556 | void fix_walls_around (maptile *map, int x, int y) |
2589 | void fix_walls_around (maptile *map, int x, int y) |
… | |
… | |
2689 | PROTOTYPE: $ |
2722 | PROTOTYPE: $ |
2690 | CODE: |
2723 | CODE: |
2691 | RETVAL = region::find (name); |
2724 | RETVAL = region::find (name); |
2692 | OUTPUT: RETVAL |
2725 | OUTPUT: RETVAL |
2693 | |
2726 | |
2694 | region *find_fuzzy (utf8_string name) |
|
|
2695 | PROTOTYPE: $ |
|
|
2696 | CODE: |
|
|
2697 | RETVAL = region::find_fuzzy (name); |
|
|
2698 | OUTPUT: RETVAL |
|
|
2699 | |
|
|
2700 | int specificity (region *rgn) |
2727 | int specificity (region *rgn) |
2701 | CODE: |
2728 | CODE: |
2702 | RETVAL = 0; |
2729 | RETVAL = 0; |
2703 | while (rgn = rgn->parent) |
2730 | while (rgn = rgn->parent) |
2704 | RETVAL++; |
2731 | RETVAL++; |