← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1823612-llvm8-build-errors into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1823612-llvm8-build-errors into lp:widelands.

Commit message:
Fix compile errors for clang 8.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1823612 in widelands: "Widelands fails to build with LLVM 8"
  https://bugs.launchpad.net/widelands/+bug/1823612

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1823612-llvm8-build-errors/+merge/365644

I am still on Clang 6, so we have to wait for Travis to see if this is indeed fixed.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1823612-llvm8-build-errors into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/production_program.cc'
--- src/logic/map_objects/tribes/production_program.cc	2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/production_program.cc	2019-04-08 06:34:18 +0000
@@ -133,7 +133,7 @@
 				char const* const type_name = next_word(parameters, reached_end);
 				const DescriptionIndex& wareindex = tribes.ware_index(type_name);
 				if (tribes.ware_exists(wareindex)) {
-					for (int i = 0; i < static_cast<int>(tribes.nrtribes()); ++i) {
+					for (size_t i = 0; i < tribes.nrtribes(); ++i) {
 						const TribeDescr& tribe_descr = *tribes.get_tribe_descr(i);
 						if (tribe_descr.has_ware(wareindex)) {
 							tribes.set_ware_type_has_demand_check(wareindex, tribe_descr.name());
@@ -142,7 +142,7 @@
 					return new ProductionProgram::ActReturn::EconomyNeedsWare(wareindex);
 				} else if (tribes.worker_exists(tribes.worker_index(type_name))) {
 					const DescriptionIndex& workerindex = tribes.worker_index(type_name);
-					for (int i = 0; i < static_cast<int>(tribes.nrtribes()); ++i) {
+					for (size_t i = 0; i < tribes.nrtribes(); ++i) {
 						const TribeDescr* tribe_descr = tribes.get_tribe_descr(i);
 						if (tribe_descr->has_worker(workerindex)) {
 							tribes.set_worker_type_has_demand_check(workerindex);
@@ -462,13 +462,13 @@
                                         const Tribes& tribes) {
 	try {
 		if (match(parameters, "failed"))
-			result_ = Failed;
+			result_ = ProgramResult::kFailed;
 		else if (match(parameters, "completed"))
-			result_ = Completed;
+			result_ = ProgramResult::kCompleted;
 		else if (match(parameters, "skipped"))
-			result_ = Skipped;
+			result_ = ProgramResult::kSkipped;
 		else if (match(parameters, "no_stats"))
-			result_ = None;
+			result_ = ProgramResult::kNone;
 		else
 			throw GameDataError("expected %s but found \"%s\"",
 			                    "{\"failed\"|\"completed\"|\"skipped\"|\"no_stats\"}", parameters);
@@ -539,22 +539,33 @@
 		   i18n::localize_list(condition_list, i18n::ConcatenateWith::AND);
 
 		std::string result_string;
-		if (result_ == Failed) {
+		switch (result_) {
+		case ProgramResult::kFailed: {
 			/** TRANSLATORS: "Did not start working because the economy needs the ware ‘%s’" */
 			result_string = (boost::format(_("Did not start %1$s because %2$s")) %
 			                 ps.top_state().program->descname() % condition_string)
 			                   .str();
-		} else if (result_ == Completed) {
+		} break;
+		case ProgramResult::kCompleted: {
 			/** TRANSLATORS: "Completed working because the economy needs the ware ‘%s’" */
 			result_string = (boost::format(_("Completed %1$s because %2$s")) %
 			                 ps.top_state().program->descname() % condition_string)
 			                   .str();
-		} else {
+		} break;
+		case ProgramResult::kSkipped: {
 			/** TRANSLATORS: "Skipped working because the economy needs the ware ‘%s’" */
 			result_string = (boost::format(_("Skipped %1$s because %2$s")) %
 			                 ps.top_state().program->descname() % condition_string)
 			                   .str();
-		}
+		} break;
+		case ProgramResult::kNone: {
+			// TODO(GunChleoc): Same as skipped - it this on purpose?
+			result_string = (boost::format(_("Skipped %1$s because %2$s")) %
+			                 ps.top_state().program->descname() % condition_string)
+			                   .str();
+		}
+		}
+
 		ps.set_production_result(result_string);
 	}
 	return ps.program_end(game, result_);
@@ -562,9 +573,9 @@
 
 ProductionProgram::ActCall::ActCall(char* parameters, const ProductionSiteDescr& descr) {
 	//  Initialize with default handling methods.
-	handling_methods_[Failed - 1] = Continue;
-	handling_methods_[Completed - 1] = Continue;
-	handling_methods_[Skipped - 1] = Continue;
+	handling_methods_[program_result_index(ProgramResult::kFailed)] = ProgramResultHandlingMethod::kContinue;
+	handling_methods_[program_result_index(ProgramResult::kCompleted)] = ProgramResultHandlingMethod::kContinue;
+	handling_methods_[program_result_index(ProgramResult::kSkipped)] = ProgramResultHandlingMethod::kContinue;
 
 	try {
 		bool reached_end;
@@ -586,34 +597,34 @@
 
 			ProgramResult result_to_set_method_for;
 			if (match_force_skip(parameters, "failure")) {
-				if (handling_methods_[Failed - 1] != Continue)
+				if (handling_methods_[program_result_index(ProgramResult::kFailed)] != ProgramResultHandlingMethod::kContinue)
 					throw GameDataError("%s handling method already defined", "failure");
-				result_to_set_method_for = Failed;
+				result_to_set_method_for = ProgramResult::kFailed;
 			} else if (match_force_skip(parameters, "completion")) {
-				if (handling_methods_[Completed - 1] != Continue)
+				if (handling_methods_[program_result_index(ProgramResult::kCompleted)] != ProgramResultHandlingMethod::kContinue)
 					throw GameDataError("%s handling method already defined", "completion");
-				result_to_set_method_for = Completed;
+				result_to_set_method_for = ProgramResult::kCompleted;
 			} else if (match_force_skip(parameters, "skip")) {
-				if (handling_methods_[Skipped - 1] != Continue)
+				if (handling_methods_[program_result_index(ProgramResult::kSkipped)] != ProgramResultHandlingMethod::kContinue)
 					throw GameDataError("%s handling method already defined", "skip");
-				result_to_set_method_for = Skipped;
+				result_to_set_method_for = ProgramResult::kSkipped;
 			} else
 				throw GameDataError(
 				   "expected %s but found \"%s\"", "{\"failure\"|\"completion\"|\"skip\"}", parameters);
 
 			ProgramResultHandlingMethod handling_method;
 			if (match(parameters, "fail"))
-				handling_method = Fail;
+				handling_method = ProgramResultHandlingMethod::kFail;
 			else if (match(parameters, "complete"))
-				handling_method = Complete;
+				handling_method = ProgramResultHandlingMethod::kComplete;
 			else if (match(parameters, "skip"))
-				handling_method = Skip;
+				handling_method = ProgramResultHandlingMethod::kSkip;
 			else if (match(parameters, "repeat"))
-				handling_method = Repeat;
+				handling_method = ProgramResultHandlingMethod::kRepeat;
 			else
 				throw GameDataError("expected %s but found \"%s\"",
 				                    "{\"fail\"|\"complete\"|\"skip\"|\"repeat\"}", parameters);
-			handling_methods_[result_to_set_method_for - 1] = handling_method;
+			handling_methods_[program_result_index(result_to_set_method_for)] = handling_method;
 			reached_end = !*parameters;
 		}
 	} catch (const WException& e) {
@@ -624,19 +635,19 @@
 void ProductionProgram::ActCall::execute(Game& game, ProductionSite& ps) const {
 	ProgramResult const program_result = static_cast<ProgramResult>(ps.top_state().phase);
 
-	if (program_result == None) {  //  The program has not yet been called.
+	if (program_result == ProgramResult::kNone) {  //  The program has not yet been called.
 		return ps.program_start(game, program_->name());
 	}
 
-	switch (handling_methods_[program_result - 1]) {
-	case Fail:
-	case Complete:
-	case Skip:
-		return ps.program_end(game, None);
-	case Continue:
+	switch (handling_methods_[program_result_index(program_result)]) {
+	case ProgramResultHandlingMethod::kFail:
+	case ProgramResultHandlingMethod::kComplete:
+	case ProgramResultHandlingMethod::kSkip:
+		return ps.program_end(game, ProgramResult::kNone);
+	case ProgramResultHandlingMethod::kContinue:
 		return ps.program_step(game);
-	case Repeat:
-		ps.top_state().phase = None;
+	case ProgramResultHandlingMethod::kRepeat:
+		ps.top_state().phase = static_cast<unsigned int>(ProgramResult::kNone);
 		ps.program_timer_ = true;
 		ps.program_time_ = ps.schedule_act(game, 10);
 		break;
@@ -700,7 +711,7 @@
 void ProductionProgram::ActCallWorker::building_work_failed(Game& game,
                                                             ProductionSite& psite,
                                                             Worker&) const {
-	psite.program_end(game, Failed);
+	psite.program_end(game, ProgramResult::kFailed);
 }
 
 ProductionProgram::ActSleep::ActSleep(char* parameters) {
@@ -743,7 +754,7 @@
 			return ps.program_step(game, 0);
 		} else {
 			ps.set_production_result(_("No use for ships on this map!"));
-			return ps.program_end(game, Failed);
+			return ps.program_end(game, ProgramResult::kFailed);
 		}
 	}
 	default:
@@ -900,7 +911,7 @@
 		      .str();
 
 		ps.set_production_result(result_string);
-		return ps.program_end(game, Failed);
+		return ps.program_end(game, ProgramResult::kFailed);
 	} else {  //  we fulfilled all consumption requirements
 		for (size_t i = 0; i < inputqueues.size(); ++i) {
 			if (uint8_t const q = consumption_quantities[i]) {
@@ -1182,7 +1193,7 @@
 	if (digged_percentage < max_) {
 		//  mine can produce normally
 		if (totalres == 0)
-			return ps.program_end(game, Failed);
+			return ps.program_end(game, ProgramResult::kFailed);
 
 		//  second pass through nodes
 		assert(totalchance);
@@ -1210,7 +1221,7 @@
 		}
 
 		if (pick >= 0) {
-			return ps.program_end(game, Failed);
+			return ps.program_end(game, ProgramResult::kFailed);
 		}
 
 	} else {
@@ -1233,7 +1244,7 @@
 			if (training_ >= game.logic_rand() % 100) {
 				ps.train_workers(game);
 			}
-			return ps.program_end(game, Failed);
+			return ps.program_end(game, ProgramResult::kFailed);
 		}
 	}
 
@@ -1278,7 +1289,7 @@
 	const std::vector<Soldier*> soldiers = ctrl->present_soldiers();
 	if (soldiers.empty()) {
 		ps.set_production_result(_("No soldier to train!"));
-		return ps.program_end(game, Skipped);
+		return ps.program_end(game, ProgramResult::kSkipped);
 	}
 	ps.molog("  Checking soldier (%u) level %d)\n", static_cast<unsigned int>(attribute),
 	         static_cast<unsigned int>(level));
@@ -1287,7 +1298,7 @@
 	for (std::vector<Soldier*>::const_iterator it = soldiers.begin();; ++it) {
 		if (it == soldiers_end) {
 			ps.set_production_result(_("No soldier found for this training level!"));
-			return ps.program_end(game, Skipped);
+			return ps.program_end(game, ProgramResult::kSkipped);
 		}
 		if (attribute == TrainingAttribute::kHealth) {
 			if ((*it)->get_health_level() == level)
@@ -1365,7 +1376,7 @@
 	for (;; ++it) {
 		if (it == soldiers_end) {
 			ps.set_production_result(_("No soldier found for this training level!"));
-			return ps.program_end(game, Skipped);
+			return ps.program_end(game, ProgramResult::kSkipped);
 		}
 		if (attribute == TrainingAttribute::kHealth) {
 			if ((*it)->get_health_level() == level)
@@ -1481,7 +1492,7 @@
 	}
 
 	if (available_resource == INVALID_INDEX) {
-		psite.program_end(game, Failed);
+		psite.program_end(game, ProgramResult::kFailed);
 		return;
 	}
 
@@ -1534,7 +1545,7 @@
 	}
 
 	psite.molog("construct: no object or buildable field\n");
-	psite.program_end(game, Failed);
+	psite.program_end(game, ProgramResult::kFailed);
 }
 
 bool ProductionProgram::ActConstruct::get_building_work(Game& game,
@@ -1554,7 +1565,7 @@
 	if (construction) {
 		if (!construction->construct_remaining_buildcost(game, &remaining)) {
 			psite.molog("construct: immovable %u not under construction", construction->serial());
-			psite.program_end(game, Failed);
+			psite.program_end(game, ProgramResult::kFailed);
 			return false;
 		}
 	} else {
@@ -1571,7 +1582,7 @@
 	}
 
 	if (!wq) {
-		psite.program_end(game, Failed);
+		psite.program_end(game, ProgramResult::kFailed);
 		return false;
 	}
 
@@ -1594,7 +1605,7 @@
 void ProductionProgram::ActConstruct::building_work_failed(Game& game,
                                                            ProductionSite& psite,
                                                            Worker&) const {
-	psite.program_end(game, Failed);
+	psite.program_end(game, ProgramResult::kFailed);
 }
 
 ProductionProgram::ProductionProgram(const std::string& init_name,

=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc	2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/productionsite.cc	2019-04-08 06:34:18 +0000
@@ -682,7 +682,7 @@
 
 		if (!can_start_working()) {
 			while (!stack_.empty())
-				program_end(game, Failed);
+				program_end(game, ProgramResult::kFailed);
 		} else {
 			if (stack_.empty()) {
 				working_positions_[0].worker->update_task_buildingwork(game);
@@ -691,7 +691,7 @@
 
 			State& state = top_state();
 			if (state.program->size() <= state.ip)
-				return program_end(game, Completed);
+				return program_end(game, ProgramResult::kCompleted);
 
 			if (anim_ != descr().get_animation(default_anim_)) {
 				// Restart idle animation, which is the default
@@ -720,7 +720,7 @@
 	// new productions cycle. Otherwise it can lead to consumption
 	// of input wares without producing anything
 	if (is_stopped_ && state.ip == 0) {
-		program_end(game, Failed);
+		program_end(game, ProgramResult::kFailed);
 		program_timer_ = true;
 		program_time_ = schedule_act(game, 20000);
 	} else
@@ -918,17 +918,18 @@
 	const std::string& program_name = top_state().program->name();
 
 	stack_.pop_back();
-	if (!stack_.empty())
-		top_state().phase = result;
+	if (!stack_.empty()) {
+		top_state().phase = static_cast<unsigned int>(result);
+	}
 
 	switch (result) {
-	case Failed:
+	case ProgramResult::kFailed:
 		statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
 		statistics_.push_back(false);
 		calc_statistics();
 		crude_percent_ = crude_percent_ * 8 / 10;
 		break;
-	case Completed:
+	case ProgramResult::kCompleted:
 		skipped_programs_.erase(program_name);
 		statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
 		statistics_.push_back(true);
@@ -936,11 +937,11 @@
 		crude_percent_ = crude_percent_ * 8 / 10 + 1000000 * 2 / 10;
 		calc_statistics();
 		break;
-	case Skipped:
+	case ProgramResult::kSkipped:
 		skipped_programs_[program_name] = game.get_gametime();
 		crude_percent_ = crude_percent_ * 98 / 100;
 		break;
-	case None:
+	case ProgramResult::kNone:
 		skipped_programs_.erase(program_name);
 		break;
 	}

=== modified file 'src/logic/map_objects/tribes/program_result.h'
--- src/logic/map_objects/tribes/program_result.h	2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/program_result.h	2019-04-08 06:34:18 +0000
@@ -20,10 +20,25 @@
 #ifndef WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H
 #define WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H
 
+#include "base/macros.h"
+
 namespace Widelands {
-// Don't change this values, they are used as hardcoded array indices
-enum ProgramResult { None = 0, Failed = 1, Completed = 2, Skipped = 3 };
-enum ProgramResultHandlingMethod { Fail, Complete, Skip, Continue, Repeat };
+// Don't change these values, they are used as hardcoded array indices
+enum class ProgramResult { kNone = 0, kFailed = 1, kCompleted = 2, kSkipped = 3 };
+inline int program_result_index(ProgramResult result) {
+	switch (result) {
+	case ProgramResult::kFailed:
+		return 0;
+	case ProgramResult::kCompleted:
+		return 1;
+	case ProgramResult::kSkipped:
+		return 2;
+	case ProgramResult::kNone:
+		NEVER_HERE();
+	}
+}
+
+enum class ProgramResultHandlingMethod { kFail, kComplete, kSkip, kContinue, kRepeat };
 }  // namespace Widelands
 
 #endif  // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H

=== modified file 'src/logic/map_objects/tribes/trainingsite.cc'
--- src/logic/map_objects/tribes/trainingsite.cc	2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/trainingsite.cc	2019-04-08 06:34:18 +0000
@@ -270,7 +270,7 @@
      soldier_request_(nullptr),
      capacity_(descr().get_max_number_of_soldiers()),
      build_heroes_(false),
-     result_(Failed) {
+     result_(ProgramResult::kFailed) {
 	set_soldier_control(&soldier_control_);
 
 	// Initialize this in the constructor so that loading code may
@@ -543,7 +543,7 @@
 	bool leftover_soldiers_check = true;
 
 	if (current_upgrade_) {
-		if (result_ == Completed) {
+		if (result_ == ProgramResult::kCompleted) {
 			drop_unupgradable_soldiers(game);
 			leftover_soldiers_check = false;
 			current_upgrade_->lastsuccess = true;

=== modified file 'src/logic/map_objects/world/terrain_description.h'
--- src/logic/map_objects/world/terrain_description.h	2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/world/terrain_description.h	2019-04-08 06:34:18 +0000
@@ -43,7 +43,7 @@
 
 class TerrainDescription {
 public:
-	enum Is {
+	enum class Is {
 		kArable = 0,
 		kWalkable = 1,
 		kWater = 2,
@@ -149,6 +149,14 @@
 	DISALLOW_COPY_AND_ASSIGN(TerrainDescription);
 };
 
+inline TerrainDescription::Is operator|(TerrainDescription::Is left, TerrainDescription::Is right) {
+	return TerrainDescription::Is(static_cast<int>(left) | static_cast<int>(right));
+}
+inline int operator&(TerrainDescription::Is left, TerrainDescription::Is right) {
+	return static_cast<int>(left) & static_cast<int>(right);
+}
+
+
 }  // namespace Widelands
 
 #endif  // end of include guard: WL_LOGIC_MAP_OBJECTS_WORLD_TERRAIN_DESCRIPTION_H

=== modified file 'src/logic/maphollowregion.cc'
--- src/logic/maphollowregion.cc	2019-02-23 11:00:49 +0000
+++ src/logic/maphollowregion.cc	2019-04-08 06:34:18 +0000
@@ -24,7 +24,7 @@
 template <>
 MapHollowRegion<Area<>>::MapHollowRegion(const Map& map, const HollowArea<Area<>>& hollow_area)
    : hollow_area_(hollow_area),
-     phase_(Top),
+     phase_(Phase::kTop),
      delta_radius_(hollow_area.radius - hollow_area.hole_radius),
      row_(0),
      rowwidth_(hollow_area.radius + 1),
@@ -37,12 +37,12 @@
 }
 
 template <> bool MapHollowRegion<Area<>>::advance(const Map& map) {
-	if (phase_ == None)
+	if (phase_ == Phase::kNone)
 		return false;
 	++rowpos_;
 	if (rowpos_ < rowwidth_) {
 		map.get_rn(hollow_area_, &hollow_area_);
-		if ((phase_ & (Upper | Lower)) && rowpos_ == delta_radius_) {
+		if ((phase_ & (Phase::kUpper | Phase::kLower)) && rowpos_ == delta_radius_) {
 			//  Jump over the hole.
 			const uint32_t holewidth = rowwidth_ - 2 * delta_radius_;
 			for (uint32_t i = 0; i < holewidth; ++i)
@@ -51,27 +51,27 @@
 		}
 	} else {
 		++row_;
-		if (phase_ == Top && row_ == delta_radius_)
-			phase_ = Upper;
+		if (phase_ == Phase::kTop && row_ == delta_radius_)
+			phase_ = Phase::kUpper;
 
 		// If we completed the widest, center line, switch into lower mode
 		// There are radius_+1 lines in the upper "half", because the upper
 		// half includes the center line.
-		else if (phase_ == Upper && row_ > hollow_area_.radius) {
+		else if (phase_ == Phase::kUpper && row_ > hollow_area_.radius) {
 			row_ = 1;
-			phase_ = Lower;
+			phase_ = Phase::kLower;
 		}
 
-		if (phase_ & (Top | Upper)) {
+		if (phase_ & (Phase::kTop | Phase::kUpper)) {
 			map.get_bln(left_, &hollow_area_);
 			++rowwidth_;
 		} else {
 
 			if (row_ > hollow_area_.radius) {
-				phase_ = None;
+				phase_ = Phase::kNone;
 				return true;  // early out
-			} else if (phase_ == Lower && row_ > hollow_area_.hole_radius)
-				phase_ = Bottom;
+			} else if (phase_ == Phase::kLower && row_ > hollow_area_.hole_radius)
+				phase_ = Phase::kBottom;
 
 			map.get_brn(left_, &hollow_area_);
 			--rowwidth_;

=== modified file 'src/logic/maphollowregion.h'
--- src/logic/maphollowregion.h	2019-02-23 11:00:49 +0000
+++ src/logic/maphollowregion.h	2019-04-08 06:34:18 +0000
@@ -57,11 +57,11 @@
 
 private:
 	enum Phase {
-		None = 0,    // not initialized or completed
-		Top = 1,     // above the hole
-		Upper = 2,   // upper half
-		Lower = 4,   // lower half
-		Bottom = 8,  // below the hole
+		kNone = 0,    // not initialized or completed
+		kTop = 1,     // above the hole
+		kUpper = 2,   // upper half
+		kLower = 4,   // lower half
+		kBottom = 8,  // below the hole
 	};
 
 	HollowArea<AreaType> hollow_area_;

=== modified file 'src/logic/maptriangleregion.cc'
--- src/logic/maptriangleregion.cc	2019-02-23 11:00:49 +0000
+++ src/logic/maptriangleregion.cc	2019-04-08 06:34:18 +0000
@@ -36,18 +36,18 @@
 			remaining_rows_in_lower_phase_ = (area.radius - 1) / 2;
 			if (radius_is_odd_) {
 				map.get_trn(area.node, &area.node);
-				phase_ = Top;
+				phase_ = Phase::kTop;
 				row_length_ = area.radius + 2;
 				remaining_in_row_ = radius_plus_1 / 2;
 				area.t = TriangleIndex::D;
 			} else {
-				phase_ = Upper;
+				phase_ = Phase::kUpper;
 				remaining_in_row_ = row_length_ = radius_plus_1;
 				area.t = TriangleIndex::R;
 			}
 		} else {
 			assert(area.radius == 0);
-			phase_ = Bottom;
+			phase_ = Phase::kBottom;
 			remaining_in_row_ = 0;
 			area.t = TriangleIndex::R;
 		}
@@ -57,12 +57,12 @@
 		if (radius_is_odd_) {
 			map.get_ln(area.node, &area.node);
 			left_ = area.node;
-			phase_ = Upper;
+			phase_ = Phase::kUpper;
 			remaining_in_row_ = row_length_ = area.radius + 2;
 			area.t = TriangleIndex::R;
 		} else {
 			map.get_bln(area.node, &left_);
-			phase_ = Top;
+			phase_ = Phase::kTop;
 			row_length_ = area.radius + 3;
 			remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);
 			area.t = TriangleIndex::D;
@@ -77,17 +77,17 @@
 		return false;
 	--remaining_in_row_;
 	switch (phase_) {
-	case Top:
+	case Phase::kTop:
 		if (remaining_in_row_)
 			map.get_rn(location_.node, &location_.node);
 		else if (remaining_rows_in_upper_phase_) {
-			phase_ = Upper;
+			phase_ = Phase::kUpper;
 			remaining_in_row_ = row_length_;
 			assert(remaining_in_row_);
 			location_ = TCoords<>(left_, location_.t);
 		}
 		break;
-	case Upper:
+	case Phase::kUpper:
 		if (remaining_in_row_) {
 			if (location_.t == TriangleIndex::D)
 				location_.t = TriangleIndex::R;
@@ -99,11 +99,11 @@
 				left_ = map.bl_n(left_);
 			} else {
 				if (remaining_rows_in_lower_phase_) {
-					phase_ = Lower;
+					phase_ = Phase::kLower;
 					assert(row_length_ >= 2);
 					row_length_ -= 2;
 				} else if (location_.t == TriangleIndex::R) {
-					phase_ = Bottom;
+					phase_ = Phase::kBottom;
 					row_length_ /= 2;
 				} else
 					return false;
@@ -113,7 +113,7 @@
 			location_ = TCoords<>(left_, location_.t);
 		}
 		break;
-	case Lower:
+	case Phase::kLower:
 		if (remaining_in_row_) {
 			if (location_.t == TriangleIndex::D)
 				location_.t = TriangleIndex::R;
@@ -125,14 +125,14 @@
 				remaining_in_row_ = row_length_ -= 2;
 				left_ = map.br_n(left_);
 			} else if (location_.t == TriangleIndex::R) {
-				phase_ = Bottom;
+				phase_ = Phase::kBottom;
 				remaining_in_row_ = row_length_ / 2;
 				left_ = map.br_n(left_);
 			}
 			location_ = TCoords<>(left_, location_.t);
 		}
 		break;
-	case Bottom:
+	case Phase::kBottom:
 		if (remaining_in_row_)
 			map.get_rn(location_.node, &location_.node);
 		break;
@@ -156,17 +156,17 @@
 			remaining_rows_in_lower_phase_ = (area.radius - 1) / 2;
 			if (radius_is_odd_) {
 				map.get_trn(area.node, &area.node);
-				phase_ = Top;
+				phase_ = Phase::kTop;
 				row_length_ = area.radius + 2;
 				remaining_in_row_ = radius_plus_1 / 2;
 				area.t = TriangleIndex::D;
 			} else {
-				phase_ = Upper;
+				phase_ = Phase::kUpper;
 				remaining_in_row_ = row_length_ = radius_plus_1;
 				area.t = TriangleIndex::R;
 			}
 		} else {
-			phase_ = Bottom;
+			phase_ = Phase::kBottom;
 			remaining_in_row_ = 0;
 			area.t = TriangleIndex::R;
 		}
@@ -176,12 +176,12 @@
 		if (radius_is_odd_) {
 			map.get_ln(area.node, &area.node);
 			left_ = area.node;
-			phase_ = Upper;
+			phase_ = Phase::kUpper;
 			remaining_in_row_ = row_length_ = area.radius + 2;
 			area.t = TriangleIndex::R;
 		} else {
 			map.get_bln(area.node, &left_);
-			phase_ = Top;
+			phase_ = Phase::kTop;
 			row_length_ = area.radius + 3;
 			remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);
 			area.t = TriangleIndex::D;
@@ -197,17 +197,17 @@
 		return false;
 	--remaining_in_row_;
 	switch (phase_) {
-	case Top:
+	case Phase::kTop:
 		if (remaining_in_row_)
 			map.get_rn(location_.node, &location_.node);
 		else if (remaining_rows_in_upper_phase_) {
-			phase_ = Upper;
+			phase_ = Phase::kUpper;
 			remaining_in_row_ = row_length_;
 			assert(remaining_in_row_);
 			location_ = TCoords<FCoords>(left_, location_.t);
 		}
 		break;
-	case Upper:
+	case Phase::kUpper:
 		if (remaining_in_row_) {
 			if (location_.t == TriangleIndex::D)
 				location_.t = TriangleIndex::R;
@@ -219,11 +219,11 @@
 				left_ = map.bl_n(left_);
 			} else {
 				if (remaining_rows_in_lower_phase_) {
-					phase_ = Lower;
+					phase_ = Phase::kLower;
 					assert(row_length_ >= 2);
 					row_length_ -= 2;
 				} else if (location_.t == TriangleIndex::R) {
-					phase_ = Bottom;
+					phase_ = Phase::kBottom;
 					row_length_ /= 2;
 				} else
 					return false;
@@ -233,7 +233,7 @@
 			location_ = TCoords<FCoords>(left_, location_.t);
 		}
 		break;
-	case Lower:
+	case Phase::kLower:
 		if (remaining_in_row_) {
 			if (location_.t == TriangleIndex::D)
 				location_.t = TriangleIndex::R;
@@ -245,14 +245,14 @@
 				remaining_in_row_ = row_length_ -= 2;
 				left_ = map.br_n(left_);
 			} else if (location_.t == TriangleIndex::R) {
-				phase_ = Bottom;
+				phase_ = Phase::kBottom;
 				remaining_in_row_ = row_length_ / 2;
 				left_ = map.br_n(left_);
 			}
 			location_ = TCoords<FCoords>(left_, location_.t);
 		}
 		break;
-	case Bottom:
+	case Phase::kBottom:
 		if (remaining_in_row_)
 			map.get_rn(location_.node, &location_.node);
 		break;

=== modified file 'src/logic/maptriangleregion.h'
--- src/logic/maptriangleregion.h	2019-02-23 11:00:49 +0000
+++ src/logic/maptriangleregion.h	2019-04-08 06:34:18 +0000
@@ -114,7 +114,7 @@
 
 private:
 	const bool radius_is_odd_ = false;
-	enum { Top, Upper, Lower, Bottom } phase_ = Top;
+	enum class Phase { kTop, kUpper, kLower, kBottom } phase_ = Phase::kTop;
 	uint16_t remaining_rows_in_upper_phase_ = 0U;
 	uint16_t remaining_rows_in_lower_phase_ = 0U;
 	uint16_t row_length_, remaining_in_row_ = 0U;


Follow ups