summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/place-info.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-04-24 13:16:12 +0200
committerAdam Borowski <kilobyte@angband.pl>2013-04-26 17:03:16 +0200
commitaefa5b469d9c151cba17c0c9323391a6d15e9673 (patch)
tree867379928bddc77c2629f74817ecfebadded1b7c /crawl-ref/source/place-info.cc
parent4cf483e8a257eea3313a1b6c8246f178be63e459 (diff)
downloadcrawl-ref-aefa5b469d9c151cba17c0c9323391a6d15e9673.tar.gz
crawl-ref-aefa5b469d9c151cba17c0c9323391a6d15e9673.zip
Fix a misbuild with clang-3.3.
Our fault: enum types are not guaranteed to allow storing any values outside defined values, and the compiler is allowed to reduce storage size if it wants to. Since version 3.3, clang prefers unsigned types here. We used -1 and -2 as magic values, which would then fail comparison. I did not preserve the value of PlaceInfo.branch of -2 (ie, uninitialized). The whole branch field is mostly redundant, though, and we can get rid of it once get_all_place_info() is refactored.
Diffstat (limited to 'crawl-ref/source/place-info.cc')
-rw-r--r--crawl-ref/source/place-info.cc13
1 files changed, 4 insertions, 9 deletions
diff --git a/crawl-ref/source/place-info.cc b/crawl-ref/source/place-info.cc
index 647e3cb7b8..d0122e131f 100644
--- a/crawl-ref/source/place-info.cc
+++ b/crawl-ref/source/place-info.cc
@@ -6,7 +6,7 @@
#include "player.h"
PlaceInfo::PlaceInfo()
- : branch((branch_type)-2), num_visits(0),
+ : branch(NUM_BRANCHES), num_visits(0),
levels_seen(0), mon_kill_exp(0), turns_total(0), turns_explore(0),
turns_travel(0), turns_interlevel(0), turns_resting(0),
turns_other(0), elapsed_total(0), elapsed_explore(0),
@@ -19,12 +19,7 @@ PlaceInfo::PlaceInfo()
bool PlaceInfo::is_global() const
{
- return (branch == -1);
-}
-
-void PlaceInfo::make_global()
-{
- branch = (branch_type)-1;
+ return (branch == NUM_BRANCHES);
}
void PlaceInfo::assert_validity() const
@@ -34,8 +29,8 @@ void PlaceInfo::assert_validity() const
ASSERT(num_visits == 0 && levels_seen == 0
|| num_visits > 0 && levels_seen > 0);
- // global data is -1
- if (branch >= 0 && brdepth[branch] != -1 && is_connected_branch(branch))
+ // global data is NUM_BRANCHES
+ if (branch != NUM_BRANCHES && brdepth[branch] != -1 && is_connected_branch(branch))
ASSERT((int)levels_seen <= brdepth[branch]);
ASSERT(turns_total == (turns_explore + turns_travel + turns_interlevel