diff options
Diffstat (limited to 'crawl-ref/source/player.cc')
-rw-r--r-- | crawl-ref/source/player.cc | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 53641b7d8b..2f3ab09187 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6765,7 +6765,7 @@ void PlaceInfo::make_global() branch = -1; } -void PlaceInfo::assert_validity() const +void PlaceInfo::assert_validity() { // Check that level_type and branch match up. ASSERT(is_global() @@ -6774,24 +6774,64 @@ void PlaceInfo::assert_validity() const || level_type > LEVEL_DUNGEON && level_type < NUM_LEVEL_AREA_TYPES && branch == -1); +#if DEBUG // Can't have visited a place without seeing any of its levels, and // vice versa. - ASSERT(num_visits == 0 && levels_seen == 0 - || num_visits > 0 && levels_seen > 0); + if(!(num_visits == 0 && levels_seen == 0 + || num_visits > 0 && levels_seen > 0)) + { + mprf(MSGCH_DIAGNOSTICS, "PlaceInfo: num_vists/levels_seen mismatch"); + num_visits = std::max((unsigned long) 1, num_visits); + levels_seen = std::max((unsigned long) 1, levels_seen); + } if (level_type == LEVEL_LABYRINTH || level_type == LEVEL_ABYSS) - ASSERT(num_visits == levels_seen); + { + if (num_visits != levels_seen) + { + mprf(MSGCH_DIAGNOSTICS, "PlaceInfo: num_visits and levels_seen " + "not identical for labyrinth or abyss"); + num_visits = std::max(num_visits, levels_seen); + levels_seen = std::max(num_visits, levels_seen); + } + } else if (level_type == LEVEL_PANDEMONIUM) - ASSERT(num_visits <= levels_seen); + { + if (num_visits > levels_seen) + { + mprf(MSGCH_DIAGNOSTICS, "PlaceInfo: Pandemonium visited more " + "times than the number of its levels that have been seen."); + num_visits = levels_seen; + } + } else if (level_type == LEVEL_DUNGEON && branches[branch].depth > 0) - ASSERT(levels_seen <= (unsigned long) branches[branch].depth); + { + if(levels_seen > (unsigned long) branches[branch].depth) + { + mprf(MSGCH_DIAGNOSTICS, "PlaceInfo: more levels of branch seen " + "than the branch actually has."); + levels_seen = branches[branch].depth; + } + } - ASSERT(turns_total == (turns_explore + turns_travel + turns_interlevel - + turns_resting + turns_other)); + if(turns_total != (turns_explore + turns_travel + turns_interlevel + + turns_resting + turns_other)) + { + mprf(MSGCH_DIAGNOSTICS, "PlaceInfo: turns breakdown doesn't sum " + "up properly."); + turns_total = (turns_explore + turns_travel + turns_interlevel + + turns_resting + turns_other); + } - ASSERT(elapsed_total == (elapsed_explore + elapsed_travel - + elapsed_interlevel + elapsed_resting - + elapsed_other)); + if(elapsed_total != (elapsed_explore + elapsed_travel + elapsed_interlevel + + elapsed_resting + elapsed_other)) + { + mprf(MSGCH_DIAGNOSTICS, "PlaceInfo: elapsed time breakdown doesn't " + "sum up properly."); + elapsed_total = (elapsed_explore + elapsed_travel + elapsed_interlevel + + elapsed_resting + elapsed_other); + } +#endif } const std::string PlaceInfo::short_name() const |