MCPcopy Create free account
hub / github.com/crawl/crawl / check_map_validity

Function check_map_validity

crawl-ref/source/dbg-scan.cc:617–691  ·  view source on GitHub ↗

* Check the map for validity, generating a crash if not. * * This checks the loaded map to make sure all dungeon features and shops are * valid, all branch exits are generated, and all portals generated at fixed * levels in the Depths are actually present. */

Source from the content-addressed store, hash-verified

615 * levels in the Depths are actually present.
616 */
617void check_map_validity()
618{
619#if defined(ASSERTS) && !defined(DEBUG_VETO_RESUME)
620 dungeon_feature_type portal = DNGN_UNSEEN;
621 if (player_in_branch(BRANCH_DEPTHS))
622 {
623 // TODO: centralize these numbers
624 // crosscheck with _add_missing_branches when changing
625 if (you.depth == 1)
626 portal = DNGN_ENTER_HELL;
627 else if (you.depth == 2)
628 portal = DNGN_ENTER_PANDEMONIUM;
629 else if (you.depth == 3)
630 portal = DNGN_ENTER_ABYSS;
631 }
632
633 dungeon_feature_type exit = DNGN_UNSEEN;
634 if (you.depth == 1 && !player_in_branch(root_branch))
635 exit = branches[you.where_are_you].exit_stairs;
636
637 // these may require you to look farther:
638 if (exit == DNGN_EXIT_PANDEMONIUM)
639 exit = DNGN_TRANSIT_PANDEMONIUM;
640 if (exit == DNGN_EXIT_ABYSS || exit == DNGN_EXIT_CRUCIBLE)
641 exit = DNGN_UNSEEN;
642
643 for (rectangle_iterator ri(0); ri; ++ri)
644 {
645 dungeon_feature_type feat = env.grid(*ri);
646 if (feat <= DNGN_UNSEEN || feat >= NUM_FEATURES)
647 die("invalid feature %d at (%d,%d)", feat, ri->x, ri->y);
648 const char *name = dungeon_feature_name(feat);
649 ASSERT(name);
650 ASSERT(*name); // placeholders get empty names
651
652 trap_at(*ri); // this has all needed asserts already
653
654 if (shop_struct *shop = shop_at(*ri))
655 ASSERT_RANGE(shop->type, 0, NUM_SHOPS);
656
657 // border must be impassable
658 if (!in_bounds(*ri))
659 ASSERT(feat_is_solid(feat));
660
661 if (env.level_map_mask(*ri) & MMT_MIMIC)
662 continue;
663 // no mimics below
664
665 const dungeon_feature_type orig = orig_terrain(*ri);
666 if (feat == portal || orig == portal)
667 portal = DNGN_UNSEEN;
668 if (feat == exit || orig == exit)
669 exit = DNGN_UNSEEN;
670 }
671
672 if (portal)
673 {
674#ifdef DEBUG_DIAGNOSTICS

Callers 4

abyss_area_shiftFunction · 0.85
generate_abyssFunction · 0.85
_build_level_vetoableFunction · 0.85
tag_readFunction · 0.85

Calls 12

player_in_branchFunction · 0.85
dungeon_feature_nameFunction · 0.85
trap_atFunction · 0.85
shop_atFunction · 0.85
in_boundsFunction · 0.85
feat_is_solidFunction · 0.85
orig_terrainFunction · 0.85
debug_item_scanFunction · 0.85
debug_mons_scanFunction · 0.85
gridMethod · 0.80
dieFunction · 0.70
dump_mapFunction · 0.70

Tested by

no test coverage detected