summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/place-info.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-10-15 13:52:24 +0200
committerAdam Borowski <kilobyte@angband.pl>2011-11-04 18:49:49 +0100
commitc346361417241d0e4d7531ed65a1ca5b4f497139 (patch)
tree8c76c3b32dac858b2a36df7d032ff50e49545384 /crawl-ref/source/place-info.cc
parentf4a9aed257bbdd264fb1ef43e7b29b3cc599cd65 (diff)
downloadcrawl-ref-c346361417241d0e4d7531ed65a1ca5b4f497139.tar.gz
crawl-ref-c346361417241d0e4d7531ed65a1ca5b4f497139.zip
Get rid of level_type, unify BRANCH_*, LEVEL_* and portal vaults.
Diffstat (limited to 'crawl-ref/source/place-info.cc')
-rw-r--r--crawl-ref/source/place-info.cc75
1 files changed, 9 insertions, 66 deletions
diff --git a/crawl-ref/source/place-info.cc b/crawl-ref/source/place-info.cc
index ec14cffd84..71abab9093 100644
--- a/crawl-ref/source/place-info.cc
+++ b/crawl-ref/source/place-info.cc
@@ -6,7 +6,7 @@
#include "player.h"
PlaceInfo::PlaceInfo()
- : level_type(-2), branch(-2), num_visits(0),
+ : branch((branch_type)-2), num_visits(0),
levels_seen(0), mon_kill_exp(0), mon_kill_exp_avail(0),
turns_total(0), turns_explore(0), turns_travel(0), turns_interlevel(0),
turns_resting(0), turns_other(0), elapsed_total(0),
@@ -19,40 +19,23 @@ PlaceInfo::PlaceInfo()
bool PlaceInfo::is_global() const
{
- return (level_type == -1 && branch == -1);
+ return (branch == -1);
}
void PlaceInfo::make_global()
{
- level_type = -1;
- branch = -1;
+ branch = (branch_type)-1;
}
void PlaceInfo::assert_validity() const
{
- // Check that level_type and branch match up.
- ASSERT(is_global()
- || level_type == LEVEL_DUNGEON && branch >= BRANCH_MAIN_DUNGEON
- && branch < NUM_BRANCHES
- || level_type > LEVEL_DUNGEON && level_type < NUM_LEVEL_AREA_TYPES
- && branch == -1);
-
// 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 (level_type == LEVEL_LABYRINTH || level_type == LEVEL_ABYSS)
- ASSERT(num_visits == levels_seen);
- else if (level_type == LEVEL_PANDEMONIUM)
- // Ziggurats can allow a player to return to the same
- // Pandemonium level.
- // ASSERT(num_visits <= levels_seen);
- ;
- // Commented out to allow games with broken place_info to continue.
- // Please uncomment at a later point in 0.8 development. (jpeg)
- else if (level_type == LEVEL_DUNGEON && branches[branch].depth > 0)
- ASSERT(levels_seen <= (unsigned long) branches[branch].depth);
+ if (branches[branch].depth > 1 || is_connected_branch(branch))
+ ASSERT((int)levels_seen <= branches[branch].depth);
ASSERT(turns_total == (turns_explore + turns_travel + turns_interlevel
+ turns_resting + turns_other));
@@ -64,28 +47,7 @@ void PlaceInfo::assert_validity() const
const std::string PlaceInfo::short_name() const
{
- if (level_type == LEVEL_DUNGEON)
- return branches[branch].shortname;
- else
- {
- switch (level_type)
- {
- case LEVEL_ABYSS:
- return "Abyss";
-
- case LEVEL_PANDEMONIUM:
- return "Pandemonium";
-
- case LEVEL_LABYRINTH:
- return "Labyrinth";
-
- case LEVEL_PORTAL_VAULT:
- return "Portal Chamber";
-
- default:
- return "Bug";
- }
- }
+ return branches[branch].shortname;
}
const PlaceInfo &PlaceInfo::operator += (const PlaceInfo &other)
@@ -160,30 +122,13 @@ PlaceInfo PlaceInfo::operator - (const PlaceInfo &other) const
PlaceInfo& player::get_place_info() const
{
- return get_place_info(where_are_you, level_type);
+ return get_place_info(where_are_you);
}
PlaceInfo& player::get_place_info(branch_type branch) const
{
- return get_place_info(branch, LEVEL_DUNGEON);
-}
-
-PlaceInfo& player::get_place_info(level_area_type level_type2) const
-{
- return get_place_info(NUM_BRANCHES, level_type2);
-}
-
-PlaceInfo& player::get_place_info(branch_type branch,
- level_area_type level_type2) const
-{
- ASSERT(level_type2 == LEVEL_DUNGEON && branch >= BRANCH_MAIN_DUNGEON
- && branch < NUM_BRANCHES
- || level_type2 > LEVEL_DUNGEON && level_type < NUM_LEVEL_AREA_TYPES);
-
- if (level_type2 == LEVEL_DUNGEON)
- return (PlaceInfo&) branch_info[branch];
- else
- return (PlaceInfo&) non_branch_info[level_type2 - 1];
+ ASSERT(branch < NUM_BRANCHES);
+ return (PlaceInfo&) branch_info[branch];
}
void player::clear_place_info()
@@ -191,6 +136,4 @@ void player::clear_place_info()
you.global_info = PlaceInfo();
for (unsigned int i = 0; i < NUM_BRANCHES; ++i)
branch_info[i] = PlaceInfo();
- for (unsigned int i = 0; i < NUM_LEVEL_AREA_TYPES - 1; ++i)
- non_branch_info[i] = PlaceInfo();
}