← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-986611-cppcheck-uninitialized-variables into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-986611-cppcheck-uninitialized-variables into lp:widelands.

Commit message:
Initialize a bunch of uninitialized member variables, adding constructors where necessary. Turned some enums into enum classes.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #986611 in widelands: "Issues reported by cppcheck"
  https://bugs.launchpad.net/widelands/+bug/986611

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-986611-cppcheck-uninitialized-variables/+merge/326256

I'm on a code cleanup rampage today... this one needs a bit of looking at to make sure that I initialized everything correctly.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-986611-cppcheck-uninitialized-variables into lp:widelands.
=== modified file 'src/ai/defaultai_warfare.cc'
--- src/ai/defaultai_warfare.cc	2017-06-23 16:16:28 +0000
+++ src/ai/defaultai_warfare.cc	2017-06-24 10:45:33 +0000
@@ -612,9 +612,9 @@
 		if (ms->economy().warehouses().size()) {
 			uint32_t const j = ms->soldier_capacity();
 
-			if (MilitarySite::kPrefersRookies != ms->get_soldier_preference()) {
+			if (SoldierPreference::kRookies != ms->get_soldier_preference()) {
 				game().send_player_militarysite_set_soldier_preference(
-				   *ms, MilitarySite::kPrefersRookies);
+				   *ms, SoldierPreference::kRookies);
 			} else if (j > 1) {
 				game().send_player_change_soldier_capacity(*ms, (j > 2) ? -2 : -1);
 			}
@@ -672,9 +672,9 @@
 			changed = true;
 
 			// and also set preference to Heroes
-			if (MilitarySite::kPrefersHeroes != ms->get_soldier_preference()) {
+			if (SoldierPreference::kHeroes != ms->get_soldier_preference()) {
 				game().send_player_militarysite_set_soldier_preference(
-				   *ms, MilitarySite::kPrefersHeroes);
+				   *ms, SoldierPreference::kHeroes);
 				changed = true;
 			}
 
@@ -683,9 +683,9 @@
 		} else {  // otherwise decrease soldiers
 			uint32_t const j = ms->soldier_capacity();
 
-			if (MilitarySite::kPrefersRookies != ms->get_soldier_preference()) {
+			if (SoldierPreference::kRookies != ms->get_soldier_preference()) {
 				game().send_player_militarysite_set_soldier_preference(
-				   *ms, MilitarySite::kPrefersRookies);
+				   *ms, SoldierPreference::kRookies);
 			} else if (j > 1) {
 				game().send_player_change_soldier_capacity(*ms, (j > 2) ? -2 : -1);
 			}

=== modified file 'src/base/md5.h'
--- src/base/md5.h	2017-01-25 18:55:59 +0000
+++ src/base/md5.h	2017-06-24 10:45:33 +0000
@@ -74,7 +74,7 @@
  */
 template <typename Base> class MD5Checksum : public Base {
 public:
-	MD5Checksum() {
+	MD5Checksum() : Base() {
 		Reset();
 	}
 	explicit MD5Checksum(const MD5Checksum& other)

=== modified file 'src/economy/shippingitem.h'
--- src/economy/shippingitem.h	2017-01-25 18:55:59 +0000
+++ src/economy/shippingitem.h	2017-06-24 10:45:33 +0000
@@ -59,6 +59,8 @@
 	void remove(EditorGameBase&);
 
 	struct Loader {
+		Loader () : serial_(0U) {
+		}
 		void load(FileRead& fr);
 		ShippingItem get(MapObjectLoader& mol);
 

=== modified file 'src/game_io/game_preload_packet.cc'
--- src/game_io/game_preload_packet.cc	2017-01-25 18:55:59 +0000
+++ src/game_io/game_preload_packet.cc	2017-06-24 10:45:33 +0000
@@ -46,6 +46,9 @@
 constexpr uint16_t kCurrentPacketVersion = 6;
 constexpr const char* kMinimapFilename = "minimap.png";
 
+GamePreloadPacket::GamePreloadPacket() : minimap_path_(""), mapname_(""), background_(""), win_condition_(""), gametime_(0), player_nr_(Widelands::neutral()), version_(""), savetimestamp_(0), gametype_(GameController::GameType::kUndefined) {
+}
+
 std::string GamePreloadPacket::get_localized_win_condition() const {
 	i18n::Textdomain td("win_conditions");
 	return _(win_condition_);

=== modified file 'src/game_io/game_preload_packet.h'
--- src/game_io/game_preload_packet.h	2017-01-25 18:55:59 +0000
+++ src/game_io/game_preload_packet.h	2017-06-24 10:45:33 +0000
@@ -36,6 +36,8 @@
  */
 
 struct GamePreloadPacket : public GameDataPacket {
+	GamePreloadPacket();
+
 	void read(FileSystem&, Game&, MapObjectLoader* = nullptr) override;
 	void write(FileSystem&, Game&, MapObjectSaver* = nullptr) override;
 

=== modified file 'src/graphic/gl/fields_to_draw.h'
--- src/graphic/gl/fields_to_draw.h	2017-05-13 18:48:26 +0000
+++ src/graphic/gl/fields_to_draw.h	2017-06-24 10:45:33 +0000
@@ -78,6 +78,7 @@
 	};
 
 	FieldsToDraw() {
+		reset(0, 0, 0, 0);
 	}
 
 	// Resize this fields to draw for reuse.

=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc	2017-05-31 21:27:07 +0000
+++ src/graphic/graphic.cc	2017-06-24 10:45:33 +0000
@@ -59,7 +59,7 @@
 
 }  // namespace
 
-Graphic::Graphic() : image_cache_(new ImageCache()), animation_manager_(new AnimationManager()) {
+Graphic::Graphic() : window_mode_width_(0), window_mode_height_(0), sdl_window_(nullptr), max_texture_size_(kMinimumSizeForTextures), image_cache_(new ImageCache()), animation_manager_(new AnimationManager()) {
 }
 
 /**

=== modified file 'src/graphic/render_queue.h'
--- src/graphic/render_queue.h	2017-01-25 18:55:59 +0000
+++ src/graphic/render_queue.h	2017-06-24 10:45:33 +0000
@@ -113,7 +113,7 @@
 	};
 
 	struct TerrainArguments {
-		TerrainArguments() {
+		TerrainArguments() : gametime(0), renderbuffer_width(0), renderbuffer_height(0), fields_to_draw(nullptr), scale(1.f) {
 		}
 
 		int gametime;

=== modified file 'src/graphic/text/rt_render.cc'
--- src/graphic/text/rt_render.cc	2017-06-01 08:52:15 +0000
+++ src/graphic/text/rt_render.cc	2017-06-24 10:45:33 +0000
@@ -779,6 +779,8 @@
 	DivTagRenderNode(NodeStyle& ns)
 	   : RenderNode(ns),
 	     desired_width_(),
+		  w_(0),
+		  h_(0),
 	     background_color_(0, 0, 0),
 	     is_background_color_set_(false),
 	     background_image_(nullptr) {

=== modified file 'src/graphic/texture_atlas.h'
--- src/graphic/texture_atlas.h	2017-01-25 18:55:59 +0000
+++ src/graphic/texture_atlas.h	2017-06-24 10:45:33 +0000
@@ -81,7 +81,7 @@
 
 	struct Block {
 		Block(int init_index, const Image* init_texture)
-		   : index(init_index), texture(init_texture), done(false) {
+		   : index(init_index), texture(init_texture), node(nullptr), done(false) {
 		}
 
 		// The index in the order the blocks have been added.

=== modified file 'src/logic/field.cc'
--- src/logic/field.cc	2017-01-25 18:55:59 +0000
+++ src/logic/field.cc	2017-06-24 10:45:33 +0000
@@ -23,6 +23,9 @@
 
 namespace Widelands {
 
+Field::Field() : bobs(nullptr), immovable(nullptr) , caps(7), roads(6), height(0), brightness(0), owner_info_and_selections(Widelands::neutral()), resources(INVALID_INDEX), initial_res_amount(0), res_amount(0), terrains{INVALID_INDEX, INVALID_INDEX} {
+}
+
 /**
  * Set the field's brightness based upon the slopes.
  * Slopes are calulated as this field's height - neighbour's height.

=== modified file 'src/logic/field.h'
--- src/logic/field.h	2017-01-25 18:55:59 +0000
+++ src/logic/field.h	2017-06-24 10:45:33 +0000
@@ -60,6 +60,8 @@
 	friend class Bob;
 	friend struct BaseImmovable;
 
+	Field();
+
 	enum BuildhelpIndex {
 		Buildhelp_Flag = 0,
 		Buildhelp_Small = 1,
@@ -236,8 +238,8 @@
 	Bob* bobs;
 	BaseImmovable* immovable;
 
-	uint8_t caps : 7;
-	uint8_t roads : 6;
+	uint8_t caps;
+	uint8_t roads;
 
 	Height height;
 	int8_t brightness;

=== modified file 'src/logic/game.cc'
--- src/logic/game.cc	2017-05-14 18:17:16 +0000
+++ src/logic/game.cc	2017-06-24 10:45:33 +0000
@@ -125,7 +125,8 @@
      state_(gs_notrunning),
      cmdqueue_(*this),
      /** TRANSLATORS: Win condition for this game has not been set. */
-     win_condition_displayname_(_("Not set")) {
+     win_condition_displayname_(_("Not set")),
+	  replay_(false) {
 }
 
 Game::~Game() {
@@ -673,7 +674,7 @@
 }
 
 void Game::send_player_militarysite_set_soldier_preference(Building& building,
-                                                           uint8_t my_preference) {
+                                                           SoldierPreference my_preference) {
 	send_player_command(*new CmdMilitarySiteSetSoldierPreference(
 	   get_gametime(), building.owner().player_number(), building, my_preference));
 }

=== modified file 'src/logic/game.h'
--- src/logic/game.h	2017-05-14 18:17:16 +0000
+++ src/logic/game.h	2017-06-24 10:45:33 +0000
@@ -45,6 +45,7 @@
 struct PlayerImmovable;
 enum class IslandExploreDirection;
 enum class ScoutingDirection;
+enum class SoldierPreference : uint8_t;
 struct Ship;
 struct PlayerEndStatus;
 class TrainingSite;
@@ -185,7 +186,7 @@
 	void send_player_build_road(int32_t, Path&);
 	void send_player_flagaction(Flag&);
 	void send_player_start_stop_building(Building&);
-	void send_player_militarysite_set_soldier_preference(Building&, uint8_t preference);
+	void send_player_militarysite_set_soldier_preference(Building&, SoldierPreference preference);
 	void send_player_start_or_cancel_expedition(Building&);
 
 	void send_player_enhance_building(Building&, DescriptionIndex);

=== modified file 'src/logic/game_controller.h'
--- src/logic/game_controller.h	2017-06-05 07:33:18 +0000
+++ src/logic/game_controller.h	2017-06-24 10:45:33 +0000
@@ -42,10 +42,11 @@
 class GameController {
 public:
 	enum class GameType : uint8_t {
-		SINGLEPLAYER = 1,  // we don't want SINGLEPLAYER just because a value is empty
-		NETCLIENT,
-		NETHOST,
-		REPLAY
+		kUndefined = 0,
+		kSingleplayer,
+		kNetClient,
+		kNetHost,
+		kReplay
 	};
 
 	virtual ~GameController() {

=== modified file 'src/logic/map_objects/tribes/battle.cc'
--- src/logic/map_objects/tribes/battle.cc	2017-06-02 08:14:40 +0000
+++ src/logic/map_objects/tribes/battle.cc	2017-06-24 10:45:33 +0000
@@ -57,9 +57,11 @@
    : MapObject(&g_battle_descr),
      first_(first_soldier),
      second_(second_soldier),
+	  creationtime_(0),
      readyflags_(0),
      damage_(0),
-     first_strikes_(true) {
+     first_strikes_(true),
+	  last_attack_hits_(false) {
 	assert(first_soldier->get_owner() != second_soldier->get_owner());
 	{
 		StreamWrite& ss = game.syncstream();

=== modified file 'src/logic/map_objects/tribes/building.h'
--- src/logic/map_objects/tribes/building.h	2017-05-25 12:31:33 +0000
+++ src/logic/map_objects/tribes/building.h	2017-06-24 10:45:33 +0000
@@ -347,7 +347,6 @@
 	//  The player who has defeated this building.
 	PlayerNumber defeating_player_;
 
-	int32_t priority_;  // base priority
 	std::map<DescriptionIndex, int32_t> ware_priorities_;
 
 	/// Whether we see our vision_range area based on workers in the building

=== modified file 'src/logic/map_objects/tribes/militarysite.cc'
--- src/logic/map_objects/tribes/militarysite.cc	2017-06-06 05:26:58 +0000
+++ src/logic/map_objects/tribes/militarysite.cc	2017-06-24 10:45:33 +0000
@@ -236,7 +236,7 @@
      didconquer_(false),
      capacity_(ms_descr.get_max_number_of_soldiers()),
      nexthealtime_(0),
-     soldier_preference_(ms_descr.prefers_heroes_at_start_ ? kPrefersHeroes : kPrefersRookies),
+     soldier_preference_(ms_descr.prefers_heroes_at_start_ ? SoldierPreference::kHeroes : SoldierPreference::kRookies),
      soldier_upgrade_try_(false),
      doing_upgrade_request_(false) {
 	next_swap_soldiers_time_ = 0;
@@ -410,7 +410,7 @@
 
 Soldier* MilitarySite::find_least_suited_soldier() {
 	const std::vector<Soldier*> present = present_soldiers();
-	const int32_t multiplier = kPrefersHeroes == soldier_preference_ ? -1 : 1;
+	const int32_t multiplier = SoldierPreference::kHeroes == soldier_preference_ ? -1 : 1;
 	int worst_soldier_level = INT_MIN;
 	Soldier* worst_soldier = nullptr;
 	for (Soldier* sld : present) {
@@ -449,9 +449,9 @@
 		if (nullptr != newguy && nullptr != kickoutCandidate) {
 			int32_t old_level = kickoutCandidate->get_level(TrainingAttribute::kTotal);
 			int32_t new_level = newguy->get_level(TrainingAttribute::kTotal);
-			if (kPrefersHeroes == soldier_preference_ && old_level >= new_level) {
+			if (SoldierPreference::kHeroes == soldier_preference_ && old_level >= new_level) {
 				return false;
-			} else if (kPrefersRookies == soldier_preference_ && old_level <= new_level) {
+			} else if (SoldierPreference::kRookies == soldier_preference_ && old_level <= new_level) {
 				return false;
 			}
 		}
@@ -836,7 +836,7 @@
 
 	// feature request 1247384 in launchpad bugs: Conquered buildings tend to
 	// be in a hostile area; typically players want heroes there.
-	set_soldier_preference(kPrefersHeroes);
+	set_soldier_preference(SoldierPreference::kHeroes);
 }
 
 /// Calculates whether the military presence is still kept and \returns true if.
@@ -938,9 +938,8 @@
 	int32_t soldier_upgrade_required_min = soldier_upgrade_requirements_.get_min();
 	int32_t soldier_upgrade_required_max = soldier_upgrade_requirements_.get_max();
 
-	if (kPrefersHeroes != soldier_preference_ && kPrefersRookies != soldier_preference_) {
-		log(
-		   "MilitarySite::swapSoldiers: error: Unknown player preference %d.\n", soldier_preference_);
+	if (soldier_preference_ == SoldierPreference::kNotSet) {
+		log("MilitarySite::swapSoldiers: error: SoldierPreference has not been set.\n");
 		soldier_upgrade_try_ = false;
 		return false;
 	}
@@ -956,7 +955,7 @@
 	// Micro-optimization: I assume that the majority of military sites have only level-zero
 	// soldiers and prefer rookies. Handle them separately.
 	soldier_upgrade_try_ = true;
-	if (kPrefersRookies == soldier_preference_) {
+	if (SoldierPreference::kRookies == soldier_preference_) {
 		if (0 == wg_level) {
 			soldier_upgrade_try_ = false;
 			return false;
@@ -964,8 +963,8 @@
 	}
 
 	// Now I actually build the new requirements.
-	int32_t reqmin = kPrefersHeroes == soldier_preference_ ? 1 + wg_level : 0;
-	int32_t reqmax = kPrefersHeroes == soldier_preference_ ? SHRT_MAX : wg_level - 1;
+	int32_t reqmin = SoldierPreference::kHeroes == soldier_preference_ ? 1 + wg_level : 0;
+	int32_t reqmax = SoldierPreference::kHeroes == soldier_preference_ ? SHRT_MAX : wg_level - 1;
 
 	bool maxchanged = reqmax != soldier_upgrade_required_max;
 	bool minchanged = reqmin != soldier_upgrade_required_min;
@@ -984,8 +983,8 @@
 
 // setters
 
-void MilitarySite::set_soldier_preference(MilitarySite::SoldierPreference p) {
-	assert(kPrefersHeroes == p || kPrefersRookies == p);
+void MilitarySite::set_soldier_preference(SoldierPreference p) {
+	assert(SoldierPreference::kHeroes == p || SoldierPreference::kRookies == p);
 	soldier_preference_ = p;
 	next_swap_soldiers_time_ = 0;
 }

=== modified file 'src/logic/map_objects/tribes/militarysite.h'
--- src/logic/map_objects/tribes/militarysite.h	2017-05-20 22:42:49 +0000
+++ src/logic/map_objects/tribes/militarysite.h	2017-06-24 10:45:33 +0000
@@ -34,6 +34,13 @@
 class Soldier;
 class World;
 
+// I assume elsewhere, that enum SoldierPreference fits to uint8_t.
+enum class SoldierPreference : uint8_t {
+	kNotSet,
+	kRookies,
+	kHeroes,
+};
+
 class MilitarySiteDescr : public BuildingDescr {
 public:
 	MilitarySiteDescr(const std::string& init_descname,
@@ -73,13 +80,6 @@
 	MO_DESCR(MilitarySiteDescr)
 
 public:
-	// I assume elsewhere, that enum SoldierPreference fits to uint8_t.
-	enum SoldierPreference : uint8_t {
-		kNoPreference,
-		kPrefersRookies,
-		kPrefersHeroes,
-	};
-
 	MilitarySite(const MilitarySiteDescr&);
 	virtual ~MilitarySite();
 

=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc	2017-06-23 16:16:28 +0000
+++ src/logic/map_objects/tribes/ship.cc	2017-06-24 10:45:33 +0000
@@ -1084,7 +1084,7 @@
 
 constexpr uint8_t kCurrentPacketVersion = 6;
 
-Ship::Loader::Loader() : lastdock_(0), destination_(0) {
+Ship::Loader::Loader() : lastdock_(0), destination_(0), ship_state_(ShipStates::kTransport) {
 }
 
 const Bob::Task* Ship::Loader::get_task(const std::string& name) {

=== modified file 'src/logic/map_objects/world/critter_program.h'
--- src/logic/map_objects/world/critter_program.h	2017-01-25 18:55:59 +0000
+++ src/logic/map_objects/world/critter_program.h	2017-06-24 10:45:33 +0000
@@ -32,6 +32,9 @@
 		walkCoords,  //  walk to coords
 	};
 
+	CritterAction() : iparam1(0), iparam2(0), sparam1("") {
+	}
+
 	CritterExecuteActionFn function;
 	int32_t iparam1;
 	int32_t iparam2;

=== modified file 'src/logic/map_objects/world/map_gen.cc'
--- src/logic/map_objects/world/map_gen.cc	2017-01-25 18:55:59 +0000
+++ src/logic/map_objects/world/map_gen.cc	2017-06-24 10:45:33 +0000
@@ -84,7 +84,7 @@
 
 MapGenAreaInfo::MapGenAreaInfo(const LuaTable& table,
                                const World& world,
-                               MapGenAreaType const areaType) {
+                               MapGenAreaType const area_type) {
 	weight_ = get_positive_int(table, "weight");
 
 	const auto read_terrains = [this, &table, &world](
@@ -97,7 +97,7 @@
 		}
 	};
 
-	switch (areaType) {
+	switch (area_type) {
 	case atWater:
 		read_terrains("ocean_terrains", &terrains1_);
 		read_terrains("shelf_terrains", &terrains2_);

=== modified file 'src/logic/map_objects/world/map_gen.h'
--- src/logic/map_objects/world/map_gen.h	2017-01-25 18:55:59 +0000
+++ src/logic/map_objects/world/map_gen.h	2017-06-24 10:45:33 +0000
@@ -69,7 +69,6 @@
 	std::vector<DescriptionIndex> terrains3_;  //  shallow, upper, snow
 
 	uint32_t weight_;
-	MapGenAreaType areaType_;
 };
 
 struct MapGenBobCategory {

=== modified file 'src/logic/player.cc'
--- src/logic/player.cc	2017-05-25 12:58:01 +0000
+++ src/logic/player.cc	2017-06-24 10:45:33 +0000
@@ -652,11 +652,10 @@
 }
 
 void Player::military_site_set_soldier_preference(PlayerImmovable& imm,
-                                                  uint8_t soldier_preference) {
+                                                  SoldierPreference soldier_preference) {
 	if (&imm.owner() == this)
 		if (upcast(MilitarySite, milsite, &imm))
-			milsite->set_soldier_preference(
-			   static_cast<MilitarySite::SoldierPreference>(soldier_preference));
+			milsite->set_soldier_preference(soldier_preference);
 }
 
 /*

=== modified file 'src/logic/player.h'
--- src/logic/player.h	2017-04-23 07:09:25 +0000
+++ src/logic/player.h	2017-06-24 10:45:33 +0000
@@ -506,7 +506,7 @@
 	void bulldoze(PlayerImmovable&, bool recurse = false);
 	void flagaction(Flag&);
 	void start_stop_building(PlayerImmovable&);
-	void military_site_set_soldier_preference(PlayerImmovable&, uint8_t soldier_preference);
+	void military_site_set_soldier_preference(PlayerImmovable&, SoldierPreference soldier_preference);
 	void start_or_cancel_expedition(Warehouse&);
 	void enhance_building(Building*, DescriptionIndex index_of_new_building);
 	void dismantle_building(Building*);

=== modified file 'src/logic/playercommand.cc'
--- src/logic/playercommand.cc	2017-02-12 09:10:57 +0000
+++ src/logic/playercommand.cc	2017-06-24 10:45:33 +0000
@@ -29,8 +29,6 @@
 #include "io/streamwrite.h"
 #include "logic/game.h"
 #include "logic/map_objects/map_object.h"
-#include "logic/map_objects/tribes/militarysite.h"
-#include "logic/map_objects/tribes/ship.h"
 #include "logic/map_objects/tribes/soldier.h"
 #include "logic/map_objects/tribes/tribe_descr.h"
 #include "logic/player.h"
@@ -506,14 +504,14 @@
 CmdMilitarySiteSetSoldierPreference::CmdMilitarySiteSetSoldierPreference(StreamRead& des)
    : PlayerCommand(0, des.unsigned_8()) {
 	serial = des.unsigned_32();
-	preference = des.unsigned_8();
+	preference = static_cast<Widelands::SoldierPreference>(des.unsigned_8());
 }
 
 void CmdMilitarySiteSetSoldierPreference::serialize(StreamWrite& ser) {
 	ser.unsigned_8(PLCMD_MILITARYSITESETSOLDIERPREFERENCE);
 	ser.unsigned_8(sender());
 	ser.unsigned_32(serial);
-	ser.unsigned_8(preference);
+	ser.unsigned_8(static_cast<uint8_t>(preference));
 }
 
 void CmdMilitarySiteSetSoldierPreference::execute(Game& game) {
@@ -531,7 +529,7 @@
 	// Write base classes
 	PlayerCommand::write(fw, egbase, mos);
 
-	fw.unsigned_8(preference);
+	fw.unsigned_8(static_cast<uint8_t>(preference));
 
 	// Now serial.
 	fw.unsigned_32(mos.get_object_file_index_or_zero(egbase.objects().get_object(serial)));
@@ -544,7 +542,7 @@
 		const uint16_t packet_version = fr.unsigned_16();
 		if (packet_version == kCurrentPacketVersionSoldierPreference) {
 			PlayerCommand::read(fr, egbase, mol);
-			preference = fr.unsigned_8();
+			preference = static_cast<Widelands::SoldierPreference>(fr.unsigned_8());
 			serial = get_object_serial_or_zero<MilitarySite>(fr.unsigned_32(), mol);
 		} else {
 			throw UnhandledVersionError("CmdMilitarySiteSetSoldierPreference", packet_version,

=== modified file 'src/logic/playercommand.h'
--- src/logic/playercommand.h	2017-01-25 18:55:59 +0000
+++ src/logic/playercommand.h	2017-06-24 10:45:33 +0000
@@ -24,6 +24,7 @@
 
 #include "economy/flag.h"
 #include "logic/cmd_queue.h"
+#include "logic/map_objects/tribes/militarysite.h"
 #include "logic/map_objects/tribes/ship.h"
 #include "logic/map_objects/tribes/trainingsite.h"
 #include "logic/map_objects/tribes/warehouse.h"
@@ -218,12 +219,12 @@
 };
 
 struct CmdMilitarySiteSetSoldierPreference : public PlayerCommand {
-	CmdMilitarySiteSetSoldierPreference() : PlayerCommand(), serial(0) {
+	CmdMilitarySiteSetSoldierPreference() : PlayerCommand(), serial(0), preference(SoldierPreference::kNotSet) {
 	}  // For savegame loading
 	CmdMilitarySiteSetSoldierPreference(const uint32_t t,
 	                                    const PlayerNumber p,
 	                                    Building& b,
-	                                    uint8_t prefs)
+	                                    SoldierPreference prefs)
 	   : PlayerCommand(t, p), serial(b.serial()), preference(prefs) {
 	}
 
@@ -241,7 +242,7 @@
 
 private:
 	Serial serial;
-	uint8_t preference;
+	Widelands::SoldierPreference preference;
 };
 struct CmdStartOrCancelExpedition : public PlayerCommand {
 	CmdStartOrCancelExpedition() : PlayerCommand() {
@@ -343,7 +344,7 @@
 };
 
 struct CmdShipScoutDirection : public PlayerCommand {
-	CmdShipScoutDirection() : PlayerCommand(), serial(0) {
+	CmdShipScoutDirection() : PlayerCommand(), serial(0), dir(WalkingDir::IDLE) {
 	}  // For savegame loading
 	CmdShipScoutDirection(uint32_t const t, PlayerNumber const p, Serial s, WalkingDir direction)
 	   : PlayerCommand(t, p), serial(s), dir(direction) {
@@ -391,7 +392,7 @@
 };
 
 struct CmdShipExploreIsland : public PlayerCommand {
-	CmdShipExploreIsland() : PlayerCommand(), serial(0) {
+	CmdShipExploreIsland() : PlayerCommand(), serial(0), island_explore_direction(IslandExploreDirection::kNotSet) {
 	}  // For savegame loading
 	CmdShipExploreIsland(uint32_t const t,
 	                     PlayerNumber const p,

=== modified file 'src/logic/replay_game_controller.cc'
--- src/logic/replay_game_controller.cc	2017-05-14 18:17:16 +0000
+++ src/logic/replay_game_controller.cc	2017-06-24 10:45:33 +0000
@@ -72,7 +72,7 @@
 }
 
 GameController::GameType ReplayGameController::get_game_type() {
-	return GameController::GameType::REPLAY;
+	return GameController::GameType::kReplay;
 }
 
 uint32_t ReplayGameController::real_speed() {

=== modified file 'src/logic/single_player_game_controller.cc'
--- src/logic/single_player_game_controller.cc	2017-03-03 11:19:16 +0000
+++ src/logic/single_player_game_controller.cc	2017-06-24 10:45:33 +0000
@@ -84,7 +84,7 @@
 }
 
 GameController::GameType SinglePlayerGameController::get_game_type() {
-	return GameController::GameType::SINGLEPLAYER;
+	return GameController::GameType::kSingleplayer;
 }
 
 uint32_t SinglePlayerGameController::real_speed() {

=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc	2017-04-22 08:02:21 +0000
+++ src/map_io/map_buildingdata_packet.cc	2017-06-24 10:45:33 +0000
@@ -506,7 +506,7 @@
 			militarysite.soldier_upgrade_requirements_ =
 			   RequireAttribute(TrainingAttribute::kTotal, reqmin, reqmax);
 			militarysite.soldier_preference_ =
-			   static_cast<MilitarySite::SoldierPreference>(fr.unsigned_8());
+			   static_cast<SoldierPreference>(fr.unsigned_8());
 			militarysite.next_swap_soldiers_time_ = fr.signed_32();
 			militarysite.soldier_upgrade_try_ = 0 != fr.unsigned_8() ? true : false;
 			militarysite.doing_upgrade_request_ = 0 != fr.unsigned_8() ? true : false;
@@ -1083,7 +1083,7 @@
 	}
 	fw.unsigned_16(militarysite.soldier_upgrade_requirements_.get_min());
 	fw.unsigned_16(militarysite.soldier_upgrade_requirements_.get_max());
-	fw.unsigned_8(militarysite.soldier_preference_);
+	fw.unsigned_8(static_cast<uint8_t>(militarysite.soldier_preference_));
 	fw.signed_32(militarysite.next_swap_soldiers_time_);
 	fw.unsigned_8(militarysite.soldier_upgrade_try_ ? 1 : 0);
 	fw.unsigned_8(militarysite.doing_upgrade_request_ ? 1 : 0);

=== modified file 'src/map_io/map_elemental_packet.cc'
--- src/map_io/map_elemental_packet.cc	2017-01-25 18:55:59 +0000
+++ src/map_io/map_elemental_packet.cc	2017-06-24 10:45:33 +0000
@@ -33,6 +33,9 @@
 constexpr int32_t kEightPlayersPacketVersion = 1;
 constexpr int32_t kSixteenPlayersPacketVersion = 2;
 
+MapElementalPacket::MapElementalPacket() : old_world_name_(""), version_(0) {
+}
+
 void MapElementalPacket::pre_read(FileSystem& fs, Map* map) {
 	Profile prof;
 	prof.read("elemental", nullptr, fs);

=== modified file 'src/map_io/map_elemental_packet.h'
--- src/map_io/map_elemental_packet.h	2017-01-25 18:55:59 +0000
+++ src/map_io/map_elemental_packet.h	2017-06-24 10:45:33 +0000
@@ -35,6 +35,8 @@
  * like number of players, map size, world name, magic bytes and so on
  */
 struct MapElementalPacket {
+	MapElementalPacket();
+
 	void read(FileSystem&, EditorGameBase&, bool, MapObjectLoader&);
 	void write(FileSystem&, EditorGameBase&, MapObjectSaver&);
 

=== modified file 'src/map_io/s2map.cc'
--- src/map_io/s2map.cc	2017-01-25 18:55:59 +0000
+++ src/map_io/s2map.cc	2017-06-24 10:45:33 +0000
@@ -213,11 +213,11 @@
 
 std::string get_world_name(S2MapLoader::WorldType world) {
 	switch (world) {
-	case S2MapLoader::GREENLAND:
+	case S2MapLoader::WorldType::kGreenland:
 		return "greenland";
-	case S2MapLoader::BLACKLAND:
+	case S2MapLoader::WorldType::kBlackland:
 		return "blackland";
-	case S2MapLoader::WINTERLAND:
+	case S2MapLoader::WorldType::kWinterland:
 		return "winterland";
 	}
 	NEVER_HERE();
@@ -245,18 +245,18 @@
    : world_legacy_lookup_table_(lookup_table),
      world_(world),
      table_{std::make_pair(
-               S2MapLoader::GREENLAND,
+               S2MapLoader::WorldType::kGreenland,
                std::vector<std::string>{
                   "summer_steppe", "summer_mountain1", "summer_snow", "summer_swamp",
                   "summer_beach", "summer_water", "summer_meadow1", "summer_meadow2",
                   "summer_meadow3", "summer_mountain2", "summer_mountain3", "summer_mountain4",
                   "summer_steppe_barren", "summer_meadow4", "lava", "summer_mountain_meadow"}),
-            std::make_pair(S2MapLoader::BLACKLAND,
+            std::make_pair(S2MapLoader::WorldType::kBlackland,
                            std::vector<std::string>{
                               "ashes", "mountain1", "lava-stone1", "lava-stone2", "strand", "water",
                               "hardground1", "hardground2", "hardground3", "mountain2", "mountain3",
                               "mountain4", "ashes2", "hardground4", "lava", "hardlava"}),
-            std::make_pair(S2MapLoader::WINTERLAND,
+            std::make_pair(S2MapLoader::WorldType::kWinterland,
                            std::vector<std::string>{
                               "tundra", "mountain1", "ice_flows", "ice_flows2", "ice", "water",
                               "tundra_taiga", "tundra2", "tundra3", "mountain2", "mountain3",
@@ -339,7 +339,7 @@
 }  // namespace
 
 S2MapLoader::S2MapLoader(const std::string& filename, Widelands::Map& M)
-   : Widelands::MapLoader(filename, M), filename_(filename) {
+   : Widelands::MapLoader(filename, M), filename_(filename), worldtype_(WorldType::kGreenland) {
 }
 
 /// Load the header. The map will then return valid information when
@@ -954,10 +954,10 @@
 				break;
 
 			case BOB_CACTUS1:
-				bobname = worldtype_ != S2MapLoader::WINTERLAND ? "cactus1" : "snowman";
+				bobname = worldtype_ != S2MapLoader::WorldType::kWinterland ? "cactus1" : "snowman";
 				break;
 			case BOB_CACTUS2:
-				bobname = worldtype_ != S2MapLoader::WINTERLAND ? "cactus2" : "track";
+				bobname = worldtype_ != S2MapLoader::WorldType::kWinterland ? "cactus2" : "track";
 				break;
 
 			case BOB_BUSH1:

=== modified file 'src/map_io/s2map.h'
--- src/map_io/s2map.h	2017-01-25 18:55:59 +0000
+++ src/map_io/s2map.h	2017-06-24 10:45:33 +0000
@@ -28,10 +28,10 @@
 class FileRead;
 
 struct S2MapLoader : public Widelands::MapLoader {
-	enum WorldType {
-		GREENLAND = 0,
-		BLACKLAND = 1,
-		WINTERLAND = 2,
+	enum class WorldType {
+		kGreenland = 0,
+		kBlackland = 1,
+		kWinterland = 2,
 	};
 
 	S2MapLoader(const std::string& filename, Widelands::Map& M);

=== modified file 'src/network/gameclient.cc'
--- src/network/gameclient.cc	2017-06-15 15:45:01 +0000
+++ src/network/gameclient.cc	2017-06-24 10:45:33 +0000
@@ -256,7 +256,7 @@
 }
 
 GameController::GameType GameClient::get_game_type() {
-	return GameController::GameType::NETCLIENT;
+	return GameController::GameType::kNetClient;
 }
 
 void GameClient::report_result(uint8_t player_nr,

=== modified file 'src/network/gamehost.cc'
--- src/network/gamehost.cc	2017-06-23 08:33:03 +0000
+++ src/network/gamehost.cc	2017-06-24 10:45:33 +0000
@@ -999,7 +999,7 @@
 }
 
 GameController::GameType GameHost::get_game_type() {
-	return GameController::GameType::NETHOST;
+	return GameController::GameType::kNetHost;
 }
 
 const GameSettings& GameHost::settings() {

=== modified file 'src/network/network.h'
--- src/network/network.h	2017-06-10 16:36:29 +0000
+++ src/network/network.h	2017-06-24 10:45:33 +0000
@@ -169,6 +169,8 @@
  */
 struct RecvPacket : public StreamRead {
 public:
+	RecvPacket() : index_(0) {
+	}
 	size_t data(void* data, size_t bufsize) override;
 	bool end_of_file() const override;
 

=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc	2017-06-20 08:18:38 +0000
+++ src/scripting/lua_game.cc	2017-06-24 10:45:33 +0000
@@ -422,7 +422,7 @@
 int LuaPlayer::message_box(lua_State* L) {
 	Game& game = get_game(L);
 	// don't show message boxes in replays, cause they crash the game
-	if (game.game_controller()->get_game_type() == GameController::GameType::REPLAY) {
+	if (game.game_controller()->get_game_type() == GameController::GameType::kReplay) {
 		return 1;
 	}
 

=== modified file 'src/scripting/lua_ui.cc'
--- src/scripting/lua_ui.cc	2017-05-13 11:25:24 +0000
+++ src/scripting/lua_ui.cc	2017-06-24 10:45:33 +0000
@@ -649,7 +649,7 @@
 int LuaMapView::scroll_to_map_pixel(lua_State* L) {
 	Widelands::Game& game = get_game(L);
 	// don't move view in replays
-	if (game.game_controller()->get_game_type() == GameController::GameType::REPLAY) {
+	if (game.game_controller()->get_game_type() == GameController::GameType::kReplay) {
 		return 0;
 	}
 

=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc	2017-06-15 16:34:58 +0000
+++ src/ui_basic/multilineeditbox.cc	2017-06-24 10:45:33 +0000
@@ -59,7 +59,7 @@
 	WordWrap ww;
 	/*@}*/
 
-	Data(MultilineEditbox&, const Image* button_background);
+	Data(MultilineEditbox&, const Image* init_background, const Image* button_background);
 	void refresh_ww();
 
 	void update();
@@ -89,8 +89,7 @@
                                    const std::string& text,
                                    const Image* background,
                                    const Image* button_background)
-   : Panel(parent, x, y, w, h), d_(new Data(*this, button_background)) {
-	d_->background = background;
+   : Panel(parent, x, y, w, h), d_(new Data(*this, background, button_background)) {
 	d_->lineheight = text_height();
 	set_handle_mouse(true);
 	set_can_focus(true);
@@ -100,8 +99,9 @@
 	set_text(text);
 }
 
-MultilineEditbox::Data::Data(MultilineEditbox& o, const Image* button_background)
+MultilineEditbox::Data::Data(MultilineEditbox& o, const Image* init_background, const Image* button_background)
    : scrollbar(&o, o.get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, o.get_h(), button_background),
+	  background(init_background),
      cursor_pos(0),
      maxbytes(std::min(g_gr->max_texture_size() / UI_FONT_SIZE_SMALL, 0xffff)),
      ww_valid(false),

=== modified file 'src/ui_basic/slider.cc'
--- src/ui_basic/slider.cc	2017-05-21 18:15:17 +0000
+++ src/ui_basic/slider.cc	2017-06-24 10:45:33 +0000
@@ -66,6 +66,7 @@
      min_value_(min_value),
      max_value_(max_value),
      value_(value),
+	  relative_move_(0),
      highlighted_(false),
      pressed_(false),
      enabled_(enabled),

=== modified file 'src/ui_basic/table.h'
--- src/ui_basic/table.h	2017-03-14 06:48:59 +0000
+++ src/ui_basic/table.h	2017-06-24 10:45:33 +0000
@@ -156,6 +156,15 @@
 		std::vector<Data> data_;
 	};
 
+	Table(Panel* parent,
+	      int32_t x,
+	      int32_t y,
+	      uint32_t w,
+	      uint32_t h,
+	      const Image* button_background = g_gr->images().get("images/ui_basic/but3.png"),
+	      TableRows rowtype = TableRows::kSingle);
+	~Table();
+
 	/**
 	 * Compare the two items at the given indices in the list.
 	 *
@@ -163,15 +172,6 @@
 	 */
 	using CompareFn = boost::function<bool(uint32_t, uint32_t)>;
 
-	Table(Panel* parent,
-	      int32_t x,
-	      int32_t y,
-	      uint32_t w,
-	      uint32_t h,
-	      const Image* button_background = g_gr->images().get("images/ui_basic/but3.png"),
-	      TableRows rowtype = TableRows::kSingle);
-	~Table();
-
 	boost::signals2::signal<void(uint32_t)> selected;
 	boost::signals2::signal<void(uint32_t)> double_clicked;
 

=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc	2017-06-01 08:52:15 +0000
+++ src/ui_basic/window.cc	2017-06-24 10:45:33 +0000
@@ -78,6 +78,7 @@
                 w + VT_B_PIXMAP_THICKNESS * 2,
                 TP_B_PIXMAP_THICKNESS + h + BT_B_PIXMAP_THICKNESS),
      is_minimal_(false),
+	  oldh_(TP_B_PIXMAP_THICKNESS + h + BT_B_PIXMAP_THICKNESS),
      dragging_(false),
      docked_left_(false),
      docked_right_(false),

=== modified file 'src/ui_basic/window.h'
--- src/ui_basic/window.h	2017-01-25 18:55:59 +0000
+++ src/ui_basic/window.h	2017-06-24 10:45:33 +0000
@@ -104,7 +104,7 @@
 
 private:
 	bool is_minimal_;
-	uint32_t oldh_;  // if it is, this is the old height
+	uint32_t oldh_;  // if it is minimized, this is the old height
 	bool dragging_, docked_left_, docked_right_, docked_bottom_;
 	int32_t drag_start_win_x_, drag_start_win_y_;
 	int32_t drag_start_mouse_x_, drag_start_mouse_y_;

=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc	2017-06-15 16:34:58 +0000
+++ src/ui_fsmenu/loadgame.cc	2017-06-24 10:45:33 +0000
@@ -531,10 +531,10 @@
 
 			if (!is_replay_) {
 				if (settings_->settings().multiplayer) {
-					if (gamedata.gametype == GameController::GameType::SINGLEPLAYER) {
+					if (gamedata.gametype == GameController::GameType::kSingleplayer) {
 						continue;
 					}
-				} else if (gamedata.gametype > GameController::GameType::SINGLEPLAYER) {
+				} else if (gamedata.gametype > GameController::GameType::kSingleplayer) {
 					continue;
 				}
 			}
@@ -601,14 +601,14 @@
 			if (is_replay_ || settings_->settings().multiplayer) {
 				std::string gametypestring;
 				switch (gamedata.gametype) {
-				case GameController::GameType::SINGLEPLAYER:
+				case GameController::GameType::kSingleplayer:
 					/** TRANSLATORS: "Single Player" entry in the Game Mode table column. */
 					/** TRANSLATORS: "Keep this to 6 letters maximum. */
 					/** TRANSLATORS: A tooltip will explain the abbreviation. */
 					/** TRANSLATORS: Make sure that this translation is consistent with the tooltip. */
 					gametypestring = _("SP");
 					break;
-				case GameController::GameType::NETHOST:
+				case GameController::GameType::kNetHost:
 					/** TRANSLATORS: "Multiplayer Host" entry in the Game Mode table column. */
 					/** TRANSLATORS: "Keep this to 2 letters maximum. */
 					/** TRANSLATORS: A tooltip will explain the abbreviation. */
@@ -618,7 +618,7 @@
 					   (boost::format(_("H (%1%)")) % static_cast<unsigned int>(gamedata.nrplayers))
 					      .str();
 					break;
-				case GameController::GameType::NETCLIENT:
+				case GameController::GameType::kNetClient:
 					/** TRANSLATORS: "Multiplayer" entry in the Game Mode table column. */
 					/** TRANSLATORS: "Keep this to 2 letters maximum. */
 					/** TRANSLATORS: A tooltip will explain the abbreviation. */
@@ -628,9 +628,11 @@
 					   (boost::format(_("MP (%1%)")) % static_cast<unsigned int>(gamedata.nrplayers))
 					      .str();
 					break;
-				case GameController::GameType::REPLAY:
+				case GameController::GameType::kReplay:
 					gametypestring = "";
 					break;
+				case GameController::GameType::kUndefined:
+					NEVER_HERE();
 				}
 				te.set_string(1, gametypestring);
 				te.set_string(2, map_filename(gamedata.filename, gamedata.mapname));

=== modified file 'src/ui_fsmenu/loadgame.h'
--- src/ui_fsmenu/loadgame.h	2017-01-26 09:28:40 +0000
+++ src/ui_fsmenu/loadgame.h	2017-06-24 10:45:33 +0000
@@ -65,7 +65,7 @@
 	   : gametime(0),
 	     nrplayers(0),
 	     savetimestamp(0),
-	     gametype(GameController::GameType::SINGLEPLAYER) {
+	     gametype(GameController::GameType::kSingleplayer) {
 	}
 };
 

=== modified file 'src/wui/debugconsole.cc'
--- src/wui/debugconsole.cc	2017-01-25 18:55:59 +0000
+++ src/wui/debugconsole.cc	2017-06-24 10:45:33 +0000
@@ -25,6 +25,7 @@
 
 #include "base/log.h"
 #include "chat/chat.h"
+#include "logic/widelands.h"
 
 namespace DebugConsole {
 
@@ -90,6 +91,7 @@
 		ChatMessage cm;
 
 		cm.time = time(nullptr);
+		cm.playern = Widelands::neutral();
 		cm.msg = msg;
 		messages.push_back(cm);
 

=== modified file 'src/wui/field_overlay_manager.cc'
--- src/wui/field_overlay_manager.cc	2017-01-25 18:55:59 +0000
+++ src/wui/field_overlay_manager.cc	2017-06-24 10:45:33 +0000
@@ -26,7 +26,7 @@
 #include "graphic/graphic.h"
 #include "logic/field.h"
 
-FieldOverlayManager::FieldOverlayManager() : current_overlay_id_(0) {
+FieldOverlayManager::FieldOverlayManager() : buildhelp_(false), current_overlay_id_(0) {
 	OverlayInfo* buildhelp_info = buildhelp_infos_;
 	const char* filenames[] = {"images/wui/overlays/set_flag.png", "images/wui/overlays/small.png",
 	                           "images/wui/overlays/medium.png",   "images/wui/overlays/big.png",

=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc	2017-05-18 21:26:29 +0000
+++ src/wui/soldierlist.cc	2017-06-24 10:45:33 +0000
@@ -143,6 +143,8 @@
 		icon.row = row;
 		icon.col = col;
 		icon.pos = calc_pos(row, col);
+		icon.cache_health = 0;
+		icon.cache_level = 0;
 		icons_.push_back(icon);
 
 		if (++col >= cols_) {
@@ -409,7 +411,7 @@
 		}
 
 		soldier_preference_.set_state(0);
-		if (ms->get_soldier_preference() == Widelands::MilitarySite::kPrefersHeroes) {
+		if (ms->get_soldier_preference() == Widelands::SoldierPreference::kHeroes) {
 			soldier_preference_.set_state(1);
 		}
 		if (can_act) {
@@ -435,13 +437,13 @@
 	}
 	if (upcast(Widelands::MilitarySite, ms, &building_)) {
 		switch (ms->get_soldier_preference()) {
-		case Widelands::MilitarySite::kPrefersRookies:
+		case Widelands::SoldierPreference::kRookies:
 			soldier_preference_.set_state(0);
 			break;
-		case Widelands::MilitarySite::kPrefersHeroes:
+		case Widelands::SoldierPreference::kHeroes:
 			soldier_preference_.set_state(1);
 			break;
-		case Widelands::MilitarySite::kNoPreference:
+		case Widelands::SoldierPreference::kNotSet:
 			soldier_preference_.set_state(-1);
 			break;
 		}
@@ -478,8 +480,8 @@
 	assert(ms);
 #endif
 	igbase_.game().send_player_militarysite_set_soldier_preference(
-	   building_, changed_to == 0 ? Widelands::MilitarySite::kPrefersRookies :
-	                                Widelands::MilitarySite::kPrefersHeroes);
+	   building_, changed_to == 0 ? Widelands::SoldierPreference::kRookies :
+	                                Widelands::SoldierPreference::kHeroes);
 }
 
 UI::Panel*

=== modified file 'src/wui/tribal_encyclopedia.cc'
--- src/wui/tribal_encyclopedia.cc	2017-01-25 18:55:59 +0000
+++ src/wui/tribal_encyclopedia.cc	2017-06-24 10:45:33 +0000
@@ -43,7 +43,7 @@
 		std::unique_ptr<LuaCoroutine> cr(table->get_coroutine("func"));
 		cr->push_arg(tribe.name());
 		upcast(Widelands::Game, game, &parent.egbase());
-		if (game->game_controller()->get_game_type() == GameController::GameType::SINGLEPLAYER) {
+		if (game->game_controller()->get_game_type() == GameController::GameType::kSingleplayer) {
 			cr->push_arg("singleplayer");
 		} else {
 			cr->push_arg("multiplayer");


Follow ups