← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/compiler_warnings_201802 into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/compiler_warnings_201802 into lp:widelands.

Commit message:
Fixed some compiler warnings and refactored some pointers/references

- Unused variable in worker.cc
- Member variable shadowing in fleet.h.
- Refactored owner()/get_owner() and messages()/get_messages() to clearly distinguish between const& and *.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/compiler_warnings_201802/+merge/339498
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/compiler_warnings_201802 into lp:widelands.
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc	2017-11-09 17:37:13 +0000
+++ src/economy/flag.cc	2018-02-25 18:40:20 +0000
@@ -106,7 +106,7 @@
 /**
  * Create a flag at the given location
 */
-Flag::Flag(EditorGameBase& egbase, Player& owning_player, const Coords& coords)
+Flag::Flag(EditorGameBase& egbase, Player* owning_player, const Coords& coords)
    : PlayerImmovable(g_flag_descr),
      building_(nullptr),
      ware_capacity_(8),
@@ -116,7 +116,7 @@
 	for (uint32_t i = 0; i < 6; ++i)
 		roads_[i] = nullptr;
 
-	set_owner(&owning_player);
+	set_owner(owning_player);
 
 	set_flag_position(coords);
 
@@ -125,7 +125,7 @@
 
 	if (game) {
 		//  we split a road, or a new, standalone flag is created
-		(road ? road->get_economy() : new Economy(owning_player))->add_flag(*this);
+		(road ? road->get_economy() : new Economy(*owning_player))->add_flag(*this);
 
 		if (road)
 			road->presplit(*game, coords);

=== modified file 'src/economy/flag.h'
--- src/economy/flag.h	2017-11-12 16:00:09 +0000
+++ src/economy/flag.h	2018-02-25 18:40:20 +0000
@@ -74,7 +74,7 @@
 	const FlagDescr& descr() const;
 
 	Flag();                                               /// empty flag for savegame loading
-	Flag(EditorGameBase&, Player& owner, const Coords&);  /// create a new flag
+	Flag(EditorGameBase&, Player* owner, const Coords&);  /// create a new flag
 	~Flag() override;
 
 	void load_finish(EditorGameBase&) override;

=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc	2017-11-25 15:46:56 +0000
+++ src/economy/fleet.cc	2018-02-25 18:40:20 +0000
@@ -56,7 +56,8 @@
  * instance, then add themselves \em before calling the \ref init function.
  * The Fleet takes care of merging with existing fleets, if any.
  */
-Fleet::Fleet(Player& player) : MapObject(&g_fleet_descr), owner_(player), act_pending_(false) {
+Fleet::Fleet(Player* player) : MapObject(&g_fleet_descr), act_pending_(false) {
+	owner_ = player;
 }
 
 /**
@@ -81,7 +82,7 @@
 			assert(e == nullptr);
 #endif
 
-		if (upcast(Game, game, &owner().egbase())) {
+		if (upcast(Game, game, &get_owner()->egbase())) {
 			for (Ship* temp_ship : ships_) {
 				temp_ship->set_economy(*game, e);
 			}
@@ -309,8 +310,9 @@
 	bool reverse;
 	const PortPath& pp(portpath_bidir(startidx, endidx, reverse));
 
-	if (pp.cost < 0)
-		connect_port(owner().egbase(), startidx);
+	if (pp.cost < 0) {
+		connect_port(get_owner()->egbase(), startidx);
+	}
 
 	if (pp.cost < 0)
 		return false;
@@ -356,7 +358,7 @@
 
 		if (pp.cost < 0) {
 			// Lazily discover routes between ports
-			connect_port(owner().egbase(), idx);
+			connect_port(get_owner()->egbase(), idx);
 		}
 
 		if (pp.cost >= 0) {
@@ -371,7 +373,7 @@
 void Fleet::add_ship(Ship* ship) {
 	ships_.push_back(ship);
 	ship->set_fleet(this);
-	if (upcast(Game, game, &owner().egbase())) {
+	if (upcast(Game, game, &get_owner()->egbase())) {
 		if (ports_.empty())
 			ship->set_economy(*game, nullptr);
 		else
@@ -942,7 +944,7 @@
 			if (!owner)
 				throw GameDataError("owning player %u does not exist", owner_number);
 
-			loader->init(egbase, mol, *(new Fleet(*owner)));
+			loader->init(egbase, mol, *(new Fleet(owner)));
 			loader->load(fr);
 		} else {
 			throw UnhandledVersionError("Fleet", packet_version, kCurrentPacketVersion);
@@ -958,7 +960,7 @@
 	fw.unsigned_8(HeaderFleet);
 	fw.unsigned_8(kCurrentPacketVersion);
 
-	fw.unsigned_8(owner_.player_number());
+	fw.unsigned_8(owner_->player_number());
 
 	MapObject::save(egbase, mos, fw);
 

=== modified file 'src/economy/fleet.h'
--- src/economy/fleet.h	2017-12-02 12:42:57 +0000
+++ src/economy/fleet.h	2018-02-25 18:40:20 +0000
@@ -75,14 +75,7 @@
 
 	const FleetDescr& descr() const;
 
-	explicit Fleet(Player& player);
-
-	Player* get_owner() const {
-		return &owner_;
-	}
-	Player& owner() const {
-		return owner_;
-	}
+	explicit Fleet(Player* player);
 
 	PortDock* get_dock(Flag& flag) const;
 	PortDock* get_dock(EditorGameBase&, Coords) const;
@@ -125,7 +118,6 @@
 	PortPath& portpath_bidir(uint32_t i, uint32_t j, bool& reverse);
 	const PortPath& portpath_bidir(uint32_t i, uint32_t j, bool& reverse) const;
 
-	Player& owner_;
 	std::vector<Ship*> ships_;
 	std::vector<PortDock*> ports_;
 

=== modified file 'src/economy/input_queue.h'
--- src/economy/input_queue.h	2017-02-12 09:10:57 +0000
+++ src/economy/input_queue.h	2018-02-25 18:40:20 +0000
@@ -167,7 +167,7 @@
 	 * Returns the player owning the building containing this queue.
 	 * @return A reference to the owning player.
 	 */
-	Player& owner() const {
+	const Player& owner() const {
 		return owner_.owner();
 	}
 
@@ -198,6 +198,14 @@
 	InputQueue(PlayerImmovable& owner, DescriptionIndex index, uint8_t max_size, WareWorker type);
 
 	/**
+	 * Returns the mutable player owning the building containing this queue.
+	 * @return A pointer to the owning player.
+	 */
+	Player* get_owner() const {
+		return owner_.get_owner();
+	}
+
+	/**
 	 * Called when an item arrives at the owning building.
 	 * Most likely only one of \c i or \c w will be valid.
 	 * @param g The game the queue is part of.

=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc	2017-11-12 16:30:35 +0000
+++ src/economy/portdock.cc	2018-02-25 18:40:20 +0000
@@ -130,7 +130,7 @@
 	if (fleet_)
 		fleet_->set_economy(e);
 
-	if (upcast(Game, game, &owner().egbase())) {
+	if (upcast(Game, game, &get_owner()->egbase())) {
 		for (ShippingItem& shipping_item : waiting_) {
 			shipping_item.set_economy(*game, e);
 		}
@@ -160,7 +160,7 @@
  * that we merge with a larger fleet when possible.
  */
 void PortDock::init_fleet(EditorGameBase& egbase) {
-	Fleet* fleet = new Fleet(owner());
+	Fleet* fleet = new Fleet(get_owner());
 	fleet->add_port(egbase, this);
 	fleet->init(egbase);
 	// Note: the Fleet calls our set_fleet automatically

=== modified file 'src/economy/road.cc'
--- src/economy/road.cc	2017-08-19 22:22:20 +0000
+++ src/economy/road.cc	2018-02-25 18:40:20 +0000
@@ -86,9 +86,8 @@
 	assert(end.get_position() == path.get_end());
 	assert(start.get_owner() == end.get_owner());
 
-	Player& owner = start.owner();
 	Road& road = *new Road();
-	road.set_owner(&owner);
+	road.set_owner(start.get_owner());
 	road.type_ = RoadType::kNormal;
 	road.flags_[FlagStart] = &start;
 	road.flags_[FlagEnd] = &end;
@@ -367,7 +366,7 @@
  * If we lost our carrier, re-request it.
 */
 void Road::remove_worker(Worker& w) {
-	EditorGameBase& egbase = owner().egbase();
+	EditorGameBase& egbase = get_owner()->egbase();
 
 	for (CarrierSlot& slot : carrier_slots_) {
 		Carrier const* carrier = slot.carrier.get(egbase);

=== modified file 'src/economy/shippingitem.cc'
--- src/economy/shippingitem.cc	2017-08-18 14:27:26 +0000
+++ src/economy/shippingitem.cc	2018-02-25 18:40:20 +0000
@@ -36,7 +36,7 @@
 ShippingItem::ShippingItem(Worker& worker) : object_(&worker) {
 }
 
-void ShippingItem::get(EditorGameBase& game, WareInstance** ware, Worker** worker) const {
+void ShippingItem::get(const EditorGameBase& game, WareInstance** ware, Worker** worker) const {
 	if (ware) {
 		*ware = nullptr;
 	}

=== modified file 'src/economy/shippingitem.h'
--- src/economy/shippingitem.h	2017-08-18 14:27:26 +0000
+++ src/economy/shippingitem.h	2018-02-25 18:40:20 +0000
@@ -50,7 +50,7 @@
 	// Unboxes the item that is shipped which might be either a ware or a
 	// worker. It is safe to pass nullptr for 'ware' or 'worker' in case you are
 	// only interested in the ware if it is the one or the other.
-	void get(EditorGameBase& game, WareInstance** ware, Worker** worker) const;
+	void get(const EditorGameBase& game, WareInstance** ware, Worker** worker) const;
 
 	void set_economy(Game&, Economy* e);
 	PortDock* get_destination(Game&);

=== modified file 'src/economy/workers_queue.cc'
--- src/economy/workers_queue.cc	2017-02-12 09:10:57 +0000
+++ src/economy/workers_queue.cc	2018-02-25 18:40:20 +0000
@@ -75,7 +75,7 @@
 	assert(get_filled() < max_size_);
 	assert(index_ == index);
 
-	EditorGameBase& egbase = owner().egbase();
+	EditorGameBase& egbase = get_owner()->egbase();
 	if (worker->get_location(egbase) != &(owner_)) {
 		worker->set_location(&(owner_));
 	}
@@ -121,7 +121,7 @@
 	// Now adjust them
 	const TribeDescr& tribe = owner().tribe();
 	const WorkerDescr* worker_descr = tribe.get_worker_descr(index_);
-	EditorGameBase& egbase = owner().egbase();
+	EditorGameBase& egbase = get_owner()->egbase();
 	upcast(Game, game, &egbase);
 	assert(game != nullptr);
 
@@ -129,7 +129,7 @@
 	while (get_filled() < filled) {
 		// Create new worker
 		Worker& w =
-		   worker_descr->create(egbase, owner(), &owner_, owner_.get_positions(egbase).front());
+		   worker_descr->create(egbase, get_owner(), &owner_, owner_.get_positions(egbase).front());
 		assert(w.get_location(egbase) == &owner_);
 		w.start_task_idle(*game, 0, -1);
 		workers_.push_back(&w);
@@ -157,7 +157,7 @@
 	InputQueue::set_max_fill(q);
 
 	// If requested, kick out workers
-	upcast(Game, game, &owner().egbase());
+	upcast(Game, game, &get_owner()->egbase());
 	while (workers_.size() > max_fill_) {
 		workers_.back()->reset_tasks(*game);
 		workers_.back()->start_task_leavebuilding(*game, true);

=== modified file 'src/game_io/game_player_info_packet.cc'
--- src/game_io/game_player_info_packet.cc	2017-01-25 18:55:59 +0000
+++ src/game_io/game_player_info_packet.cc	2018-02-25 18:40:20 +0000
@@ -55,19 +55,19 @@
 					std::string const name = fr.c_string();
 
 					game.add_player(plnum, 0, tribe_name, name, team);
-					Player& player = game.player(plnum);
-					player.set_see_all(see_all);
-
-					player.set_ai(fr.c_string());
-					player.read_statistics(fr);
-					player.read_remaining_shipnames(fr);
-
-					player.casualties_ = fr.unsigned_32();
-					player.kills_ = fr.unsigned_32();
-					player.msites_lost_ = fr.unsigned_32();
-					player.msites_defeated_ = fr.unsigned_32();
-					player.civil_blds_lost_ = fr.unsigned_32();
-					player.civil_blds_defeated_ = fr.unsigned_32();
+					Player* player = game.get_player(plnum);
+					player->set_see_all(see_all);
+
+					player->set_ai(fr.c_string());
+					player->read_statistics(fr);
+					player->read_remaining_shipnames(fr);
+
+					player->casualties_ = fr.unsigned_32();
+					player->kills_ = fr.unsigned_32();
+					player->msites_lost_ = fr.unsigned_32();
+					player->msites_defeated_ = fr.unsigned_32();
+					player->civil_blds_lost_ = fr.unsigned_32();
+					player->civil_blds_defeated_ = fr.unsigned_32();
 				}
 			}
 

=== modified file 'src/graphic/gl/fields_to_draw.cc'
--- src/graphic/gl/fields_to_draw.cc	2017-08-29 10:48:24 +0000
+++ src/graphic/gl/fields_to_draw.cc	2018-02-25 18:40:20 +0000
@@ -146,8 +146,8 @@
 
 			f.brightness = field_brightness(f.fcoords);
 
-			Widelands::PlayerNumber owned_by = f.fcoords.field->get_owned_by();
-			f.owner = owned_by != 0 ? &egbase.player(owned_by) : nullptr;
+			const Widelands::PlayerNumber owned_by = f.fcoords.field->get_owned_by();
+			f.owner = owned_by != 0 ? egbase.get_player(owned_by) : nullptr;
 			f.is_border = f.fcoords.field->is_border();
 			f.vision = 2;
 			f.roads = f.fcoords.field->get_roads();

=== modified file 'src/logic/cmd_delete_message.cc'
--- src/logic/cmd_delete_message.cc	2017-01-25 18:55:59 +0000
+++ src/logic/cmd_delete_message.cc	2018-02-25 18:40:20 +0000
@@ -25,6 +25,6 @@
 namespace Widelands {
 
 void CmdDeleteMessage::execute(Game& game) {
-	game.player(player).messages().delete_message(message);
+	game.get_player(player)->get_messages()->delete_message(message);
 }
 }

=== modified file 'src/logic/cmd_luacoroutine.cc'
--- src/logic/cmd_luacoroutine.cc	2017-07-07 07:20:10 +0000
+++ src/logic/cmd_luacoroutine.cc	2018-02-25 18:40:20 +0000
@@ -57,7 +57,7 @@
 			   Message::Type::kGameLogic, game.get_gametime(), "Coroutine",
 			   "images/ui_basic/menu_help.png", "Lua Coroutine Failed",
 			   (boost::format("<rt><p font-size=12>%s</p></rt>") % e.what()).str()));
-			game.player(i).add_message(game, std::move(msg), true);
+			game.get_player(i)->add_message(game, std::move(msg), true);
 		}
 		game.game_controller()->set_desired_speed(0);
 	}

=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc	2017-11-11 18:59:55 +0000
+++ src/logic/editor_game_base.cc	2018-02-25 18:40:20 +0000
@@ -160,7 +160,7 @@
 	return player_manager_->get_player(n);
 }
 
-Player& EditorGameBase::player(const int32_t n) const {
+const Player& EditorGameBase::player(const int32_t n) const {
 	return player_manager_->player(n);
 }
 
@@ -225,8 +225,8 @@
                                         PlayerNumber const owner,
                                         DescriptionIndex const idx,
                                         Building::FormerBuildings former_buildings) {
-	Player& plr = player(owner);
-	const TribeDescr& tribe = plr.tribe();
+	Player* plr = get_player(owner);
+	const TribeDescr& tribe = plr->tribe();
 	return tribe.get_building_descr(idx)->create(*this, plr, c, false, true, former_buildings);
 }
 
@@ -242,8 +242,8 @@
                                                 DescriptionIndex idx,
                                                 bool loading,
                                                 Building::FormerBuildings former_buildings) {
-	Player& plr = player(owner);
-	const TribeDescr& tribe = plr.tribe();
+	Player* plr = get_player(owner);
+	const TribeDescr& tribe = plr->tribe();
 	return tribe.get_building_descr(idx)->create(*this, plr, c, true, loading, former_buildings);
 }
 
@@ -256,15 +256,15 @@
                                              PlayerNumber const owner,
                                              bool loading,
                                              Building::FormerBuildings former_buildings) {
-	Player& plr = player(owner);
-	const TribeDescr& tribe = plr.tribe();
+	Player* plr = get_player(owner);
+	const TribeDescr& tribe = plr->tribe();
 
 	BuildingDescr const* const descr =
 	   tribe.get_building_descr(tribe.safe_building_index("dismantlesite"));
 
 	upcast(const DismantleSiteDescr, ds_descr, descr);
 
-	return *new DismantleSite(*ds_descr, *this, c, *get_player(owner), loading, former_buildings);
+	return *new DismantleSite(*ds_descr, *this, c, plr, loading, former_buildings);
 }
 
 /**
@@ -576,7 +576,7 @@
 	assert(preferred_player <= map().get_nrplayers());
 	assert(preferred_player != player_area.player_number);
 	assert(!conquer || !preferred_player);
-	Player& conquering_player = player(player_area.player_number);
+	Player* conquering_player = get_player(player_area.player_number);
 	MapRegion<Area<FCoords>> mr(map(), player_area);
 	do {
 		MapIndex const index = mr.location().field - &first_field;
@@ -586,14 +586,14 @@
 		PlayerNumber const owner = mr.location().field->get_owned_by();
 		if (conquer) {
 			//  adds the influence
-			MilitaryInfluence new_influence_modified = conquering_player.military_influence(index) +=
+			MilitaryInfluence new_influence_modified = conquering_player->military_influence(index) +=
 			   influence;
 			if (owner && !conquer_guarded_location_by_superior_influence)
 				new_influence_modified = 1;
 			if (!owner || player(owner).military_influence(index) < new_influence_modified) {
 				change_field_owner(mr.location(), player_area.player_number);
 			}
-		} else if (!(conquering_player.military_influence(index) -= influence) &&
+		} else if (!(conquering_player->military_influence(index) -= influence) &&
 		           owner == player_area.player_number) {
 			//  The player completely lost influence over the location, which he
 			//  owned. Now we must see if some other player has influence and if

=== modified file 'src/logic/editor_game_base.h'
--- src/logic/editor_game_base.h	2017-08-20 15:45:50 +0000
+++ src/logic/editor_game_base.h	2018-02-25 18:40:20 +0000
@@ -108,7 +108,7 @@
 	                   const std::string& name,
 	                   TeamNumber team = 0);
 	Player* get_player(int32_t n) const;
-	Player& player(int32_t n) const;
+	const Player& player(int32_t n) const;
 	virtual Player* get_safe_player(PlayerNumber);
 
 	// loading stuff

=== modified file 'src/logic/map_objects/immovable.h'
--- src/logic/map_objects/immovable.h	2017-11-26 14:44:23 +0000
+++ src/logic/map_objects/immovable.h	2018-02-25 18:40:20 +0000
@@ -332,12 +332,6 @@
 	explicit PlayerImmovable(const MapObjectDescr&);
 	~PlayerImmovable() override;
 
-	Player* get_owner() const {
-		return owner_;
-	}
-	Player& owner() const {
-		return *owner_;
-	}
 	Economy* get_economy() const {
 		return economy_;
 	}

=== modified file 'src/logic/map_objects/map_object.h'
--- src/logic/map_objects/map_object.h	2018-01-23 00:23:13 +0000
+++ src/logic/map_objects/map_object.h	2018-02-25 18:40:20 +0000
@@ -208,8 +208,8 @@
  *
  * When you do create a new object yourself (i.e. when you're implementing one
  * of the create() functions), you need to allocate the object using new,
- * potentially set it up by calling basic functions like set_position(),
- * set_owner(), etc. and then call init(). After that, the object is supposed to
+ * potentially set it up by calling basic functions like set_position(), etc.
+ * and then call init(). After that, the object is supposed to
  * be fully created.
 */
 
@@ -310,6 +310,11 @@
 		return owner_;
 	}
 
+	const Player& owner() const {
+		assert(get_owner());
+		return *owner_;
+	}
+
 	// Header bytes to distinguish between data packages for the different
 	// MapObject classes. Be careful in changing those, since they are written
 	// to files.

=== modified file 'src/logic/map_objects/tribes/battle.cc'
--- src/logic/map_objects/tribes/battle.cc	2017-08-16 13:23:15 +0000
+++ src/logic/map_objects/tribes/battle.cc	2018-02-25 18:40:20 +0000
@@ -176,8 +176,8 @@
 
 	if (soldier.get_current_health() < 1) {
 		molog("[battle] soldier %u lost the battle\n", soldier.serial());
-		soldier.owner().count_casualty();
-		opponent(soldier)->owner().count_kill();
+		soldier.get_owner()->count_casualty();
+		opponent(soldier)->get_owner()->count_kill();
 		soldier.start_task_die(game);
 		molog("[battle] waking up winner %d\n", opponent(soldier)->serial());
 		opponent(soldier)->send_signal(game, "wakeup");

=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc	2018-01-11 11:40:45 +0000
+++ src/logic/map_objects/tribes/building.cc	2018-02-25 18:40:20 +0000
@@ -166,14 +166,14 @@
 }
 
 Building& BuildingDescr::create(EditorGameBase& egbase,
-                                Player& owner,
+                                Player* owner,
                                 Coords const pos,
                                 bool const construct,
                                 bool loading,
                                 Building::FormerBuildings const former_buildings) const {
 	Building& b = construct ? create_constructionsite() : create_object();
 	b.position_ = pos;
-	b.set_owner(&owner);
+	b.set_owner(owner);
 	for (DescriptionIndex idx : former_buildings) {
 		b.old_buildings_.push_back(idx);
 	}
@@ -356,7 +356,7 @@
 	{
 		Flag* flag = dynamic_cast<Flag*>(map.get_immovable(neighb));
 		if (!flag)
-			flag = new Flag(egbase, owner(), neighb);
+			flag = new Flag(egbase, get_owner(), neighb);
 		flag_ = flag;
 		flag->attach_building(egbase, *this);
 	}
@@ -370,13 +370,13 @@
 
 void Building::cleanup(EditorGameBase& egbase) {
 	if (defeating_player_) {
-		Player& defeating_player = egbase.player(defeating_player_);
+		Player* defeating_player = egbase.get_player(defeating_player_);
 		if (descr().get_conquers()) {
-			owner().count_msite_lost();
-			defeating_player.count_msite_defeated();
+			get_owner()->count_msite_lost();
+			defeating_player->count_msite_defeated();
 		} else {
-			owner().count_civil_bld_lost();
-			defeating_player.count_civil_bld_defeated();
+			get_owner()->count_civil_bld_lost();
+			defeating_player->count_civil_bld_defeated();
 		}
 	}
 
@@ -727,13 +727,14 @@
 	if (see == seeing_)
 		return;
 
-	Player& player = owner();
-	const Map& map = player.egbase().map();
+	Player* player = get_owner();
+	const Map& map = player->egbase().map();
 
-	if (see)
-		player.see_area(Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
-	else
-		player.unsee_area(Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
+	if (see) {
+		player->see_area(Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
+	} else {
+		player->unsee_area(Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
+	}
 
 	seeing_ = see;
 }
@@ -778,9 +779,9 @@
 	                                         (link_to_building_lifetime ? serial_ : 0)));
 
 	if (throttle_time) {
-		owner().add_message_with_timeout(game, std::move(msg), throttle_time, throttle_radius);
+		get_owner()->add_message_with_timeout(game, std::move(msg), throttle_time, throttle_radius);
 	} else {
-		owner().add_message(game, std::move(msg));
+		get_owner()->add_message(game, std::move(msg));
 	}
 }
 }

=== modified file 'src/logic/map_objects/tribes/building.h'
--- src/logic/map_objects/tribes/building.h	2018-01-23 00:23:13 +0000
+++ src/logic/map_objects/tribes/building.h	2018-02-25 18:40:20 +0000
@@ -143,7 +143,7 @@
 	/// Does not perform any sanity checks.
 	/// If former_buildings is not empty this is an enhancing.
 	Building& create(EditorGameBase&,
-	                 Player&,
+	                 Player*,
 	                 Coords,
 	                 bool construct,
 	                 bool loading = false,

=== modified file 'src/logic/map_objects/tribes/constructionsite.cc'
--- src/logic/map_objects/tribes/constructionsite.cc	2017-12-17 17:47:34 +0000
+++ src/logic/map_objects/tribes/constructionsite.cc	2018-02-25 18:40:20 +0000
@@ -189,7 +189,7 @@
 		// Put the real building in place
 		DescriptionIndex becomes_idx = owner().tribe().building_index(building_->name());
 		old_buildings_.push_back(becomes_idx);
-		Building& b = building_->create(egbase, owner(), position_, false, false, old_buildings_);
+		Building& b = building_->create(egbase, get_owner(), position_, false, false, old_buildings_);
 		if (Worker* const builder = builder_.get(egbase)) {
 			builder->reset_tasks(dynamic_cast<Game&>(egbase));
 			builder->set_location(&b);
@@ -294,7 +294,7 @@
 			wq.set_max_size(wq.get_max_size() - 1);
 
 			// Update consumption statistic
-			owner().ware_consumed(wq.get_index(), 1);
+			get_owner()->ware_consumed(wq.get_index(), 1);
 
 			working_ = true;
 			work_steptime_ = game.get_gametime() + CONSTRUCTIONSITE_STEP_TIME;

=== modified file 'src/logic/map_objects/tribes/dismantlesite.cc'
--- src/logic/map_objects/tribes/dismantlesite.cc	2017-12-17 17:47:34 +0000
+++ src/logic/map_objects/tribes/dismantlesite.cc	2018-02-25 18:40:20 +0000
@@ -68,12 +68,12 @@
 DismantleSite::DismantleSite(const DismantleSiteDescr& gdescr,
                              EditorGameBase& egbase,
                              const Coords& c,
-                             Player& plr,
+                             Player* plr,
                              bool loading,
                              Building::FormerBuildings& former_buildings)
    : PartiallyFinishedBuilding(gdescr) {
 	position_ = c;
-	set_owner(&plr);
+	set_owner(plr);
 
 	assert(!former_buildings.empty());
 	for (DescriptionIndex former_idx : former_buildings) {
@@ -184,7 +184,7 @@
 			wq.set_max_size(wq.get_max_size() - 1);
 
 			// Update statistics
-			owner().ware_produced(wq.get_index());
+			get_owner()->ware_produced(wq.get_index());
 
 			const WareDescr& wd = *owner().tribe().get_ware_descr(wq.get_index());
 			WareInstance& ware = *new WareInstance(wq.get_index(), &wd);

=== modified file 'src/logic/map_objects/tribes/dismantlesite.h'
--- src/logic/map_objects/tribes/dismantlesite.h	2017-08-18 17:32:16 +0000
+++ src/logic/map_objects/tribes/dismantlesite.h	2018-02-25 18:40:20 +0000
@@ -69,7 +69,7 @@
 	explicit DismantleSite(const DismantleSiteDescr& descr,
 	                       EditorGameBase&,
 	                       const Coords&,
-	                       Player&,
+	                       Player*,
 	                       bool,
 	                       Building::FormerBuildings& former_buildings);
 

=== modified file 'src/logic/map_objects/tribes/market.cc'
--- src/logic/map_objects/tribes/market.cc	2017-10-04 00:27:47 +0000
+++ src/logic/map_objects/tribes/market.cc	2018-02-25 18:40:20 +0000
@@ -243,14 +243,14 @@
 	// ware to drop it off. The carrier then leaves the building and goes home.
 	const WorkerDescr& w_desc =
 	   *game->tribes().get_worker_descr(game->tribes().worker_index("barbarians_carrier"));
-	auto& worker = w_desc.create(*game, owner(), this, position_);
+	auto& worker = w_desc.create(*game, get_owner(), this, position_);
 	worker.start_task_dropoff(*game, *ware);
 	trade_order.received_traded_wares_in_this_batch += 1;
-	owner().ware_produced(ware_index);
+	get_owner()->ware_produced(ware_index);
 
 	auto* other_market = dynamic_cast<Market*>(game->objects().get_object(trade_order.other_side));
 	assert(other_market != nullptr);
-	other_market->owner().ware_consumed(ware_index, 1);
+	other_market->get_owner()->ware_consumed(ware_index, 1);
 	auto& other_trade_order = other_market->trade_orders_.at(trade_id);
 	if (trade_order.received_traded_wares_in_this_batch == other_trade_order.num_wares_per_batch() &&
 	    other_trade_order.received_traded_wares_in_this_batch == trade_order.num_wares_per_batch()) {

=== modified file 'src/logic/map_objects/tribes/militarysite.cc'
--- src/logic/map_objects/tribes/militarysite.cc	2017-11-30 10:59:06 +0000
+++ src/logic/map_objects/tribes/militarysite.cc	2018-02-25 18:40:20 +0000
@@ -88,7 +88,7 @@
 }
 
 void MilitarySite::SoldierControl::drop_soldier(Soldier& soldier) {
-	Game& game = dynamic_cast<Game&>(military_site_->owner().egbase());
+	Game& game = dynamic_cast<Game&>(military_site_->get_owner()->egbase());
 
 	if (!military_site_->is_present(soldier)) {
 		// This can happen when the "drop soldier" player command is delayed
@@ -154,16 +154,16 @@
 }
 
 void MilitarySite::AttackTarget::enemy_soldier_approaches(const Soldier& enemy) const {
-	auto& owner = military_site_->owner();
-	Game& game = dynamic_cast<Game&>(owner.egbase());
+	Player* owner = military_site_->get_owner();
+	Game& game = dynamic_cast<Game&>(owner->egbase());
 	const Map& map = game.map();
-	if (enemy.get_owner() == &owner || enemy.get_battle() ||
+	if (enemy.get_owner() == owner || enemy.get_battle() ||
 	    military_site_->descr().get_conquers() <=
 	       map.calc_distance(enemy.get_position(), military_site_->get_position()))
 		return;
 
 	if (map.find_bobs(Area<FCoords>(map.get_fcoords(military_site_->base_flag().get_position()), 2),
-	                  nullptr, FindBobEnemySoldier(&owner)))
+	                  nullptr, FindBobEnemySoldier(owner)))
 		return;
 
 	// We're dealing with a soldier that we might want to keep busy
@@ -191,7 +191,7 @@
 }
 
 AttackTarget::AttackResult MilitarySite::AttackTarget::attack(Soldier* enemy) const {
-	Game& game = dynamic_cast<Game&>(military_site_->owner().egbase());
+	Game& game = dynamic_cast<Game&>(military_site_->get_owner()->egbase());
 
 	std::vector<Soldier*> present = military_site_->soldier_control_.present_soldiers();
 	Soldier* defender = nullptr;
@@ -519,7 +519,7 @@
 
 		// Now I know that the new guy is worthy.
 		if (nullptr != kickoutCandidate) {
-			Game& game = dynamic_cast<Game&>(owner().egbase());
+			Game& game = dynamic_cast<Game&>(get_owner()->egbase());
 			kickoutCandidate->reset_tasks(game);
 			kickoutCandidate->start_task_leavebuilding(game, true);
 			return true;
@@ -580,7 +580,7 @@
 	}
 
 	if (capacity_ < present.size()) {
-		Game& game = dynamic_cast<Game&>(owner().egbase());
+		Game& game = dynamic_cast<Game&>(get_owner()->egbase());
 		for (uint32_t i = 0; i < present.size() - capacity_; ++i) {
 			Soldier& soldier = *present[i];
 			soldier.reset_tasks(game);
@@ -812,7 +812,7 @@
  * \return \c true if the soldier is currently present and idle in the building.
  */
 bool MilitarySite::is_present(Soldier& soldier) const {
-	return soldier.get_location(owner().egbase()) == this &&
+	return soldier.get_location(get_owner()->egbase()) == this &&
 	       soldier.get_state() == soldier.get_state(Worker::taskBuildingwork) &&
 	       soldier.get_position() == get_position();
 }
@@ -894,7 +894,7 @@
 	sj.stayhome = false;
 	soldierjobs_.push_back(sj);
 
-	soldier.update_task_buildingwork(dynamic_cast<Game&>(owner().egbase()));
+	soldier.update_task_buildingwork(dynamic_cast<Game&>(get_owner()->egbase()));
 }
 
 bool MilitarySite::has_soldier_job(Soldier& soldier) {

=== modified file 'src/logic/map_objects/tribes/production_program.cc'
--- src/logic/map_objects/tribes/production_program.cc	2017-12-02 11:41:19 +0000
+++ src/logic/map_objects/tribes/production_program.cc	2018-02-25 18:40:20 +0000
@@ -912,7 +912,7 @@
 
 				// Update consumption statistics
 				if (inputqueues[i]->get_type() == wwWARE) {
-					ps.owner().ware_consumed(inputqueues[i]->get_index(), q);
+					ps.get_owner()->ware_consumed(inputqueues[i]->get_index(), q);
 				}
 			}
 		}

=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc	2017-09-15 19:45:11 +0000
+++ src/logic/map_objects/tribes/productionsite.cc	2018-02-25 18:40:20 +0000
@@ -514,7 +514,7 @@
 			continue;
 
 		// Okay, space is free and worker is fitting. Let's create him
-		Worker& worker = wdes.create(egbase, owner(), this, get_position());
+		Worker& worker = wdes.create(egbase, get_owner(), this, get_position());
 
 		if (upcast(Game, game, &egbase))
 			worker.start_task_idle(*game, 0, -1);
@@ -788,7 +788,7 @@
 				ware.init(game);
 				worker.start_task_dropoff(game, ware);
 			}
-			owner().ware_produced(ware_index);  //  for statistics
+			get_owner()->ware_produced(ware_index);  //  for statistics
 		}
 		assert(ware_type_with_count.second);
 		if (--ware_type_with_count.second == 0)
@@ -805,7 +805,7 @@
 			   *owner().tribe().get_worker_descr(worker_type_with_count.first);
 			{
 				Worker& recruit = dynamic_cast<Worker&>(worker_descr.create_object());
-				recruit.set_owner(&worker.owner());
+				recruit.set_owner(worker.get_owner());
 				recruit.set_position(game, worker.get_position());
 				recruit.init(game);
 				recruit.set_location(this);

=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc	2018-02-23 07:54:12 +0000
+++ src/logic/map_objects/tribes/ship.cc	2018-02-25 18:40:20 +0000
@@ -171,7 +171,7 @@
  */
 bool Ship::init_fleet(EditorGameBase& egbase) {
 	assert(get_owner() != nullptr);
-	Fleet* fleet = new Fleet(*get_owner());
+	Fleet* fleet = new Fleet(get_owner());
 	fleet->add_ship(this);
 	return fleet->init(egbase);
 	// fleet calls the set_fleet function appropriately

=== modified file 'src/logic/map_objects/tribes/soldier.cc'
--- src/logic/map_objects/tribes/soldier.cc	2017-12-17 17:47:34 +0000
+++ src/logic/map_objects/tribes/soldier.cc	2018-02-25 18:40:20 +0000
@@ -622,7 +622,7 @@
 	if (!battle_) {
 		return true;
 	}
-	return !battle_->locked(dynamic_cast<Game&>(owner().egbase()));
+	return !battle_->locked(dynamic_cast<Game&>(get_owner()->egbase()));
 }
 
 /**
@@ -1345,12 +1345,12 @@
 					    (immovable_dest ? immovable_dest->descr().descname().c_str() : ("no")) %
 					    descr().descname().c_str())
 					      .str();
-					owner().add_message(
+					get_owner()->add_message(
 					   game, std::unique_ptr<Message>(
 					            new Message(Message::Type::kGameLogic, game.get_gametime(),
 					                        descr().descname(), "images/ui_basic/menu_help.png",
 					                        _("Logic error"), messagetext, get_position(), serial_)));
-					opponent.owner().add_message(
+					opponent.get_owner()->add_message(
 					   game, std::unique_ptr<Message>(new Message(
 					            Message::Type::kGameLogic, game.get_gametime(), descr().descname(),
 					            "images/ui_basic/menu_help.png", _("Logic error"), messagetext,

=== modified file 'src/logic/map_objects/tribes/trainingsite.cc'
--- src/logic/map_objects/tribes/trainingsite.cc	2017-11-09 17:37:13 +0000
+++ src/logic/map_objects/tribes/trainingsite.cc	2018-02-25 18:40:20 +0000
@@ -216,7 +216,7 @@
  * soldier is actually stationed here, without breaking anything if he isn't.
  */
 void TrainingSite::SoldierControl::drop_soldier(Soldier& soldier) {
-	Game& game = dynamic_cast<Game&>(training_site_->owner().egbase());
+	Game& game = dynamic_cast<Game&>(training_site_->get_owner()->egbase());
 
 	std::vector<Soldier*>::iterator it =
 	   std::find(training_site_->soldiers_.begin(), training_site_->soldiers_.end(), &soldier);
@@ -349,13 +349,13 @@
 		if (std::find(soldiers_.begin(), soldiers_.end(), soldier) == soldiers_.end())
 			soldiers_.push_back(soldier);
 
-		if (upcast(Game, game, &owner().egbase()))
+		if (upcast(Game, game, &get_owner()->egbase()))
 			schedule_act(*game, 100);
 	}
 }
 
 void TrainingSite::remove_worker(Worker& w) {
-	upcast(Game, game, &owner().egbase());
+	upcast(Game, game, &get_owner()->egbase());
 
 	if (upcast(Soldier, soldier, &w)) {
 		std::vector<Soldier*>::iterator const it =

=== modified file 'src/logic/map_objects/tribes/warehouse.cc'
--- src/logic/map_objects/tribes/warehouse.cc	2017-08-30 12:06:20 +0000
+++ src/logic/map_objects/tribes/warehouse.cc	2018-02-25 18:40:20 +0000
@@ -78,19 +78,19 @@
 	if (!warehouse_->descr().get_conquers())
 		return;
 
-	Player& owner = warehouse_->owner();
-	Game& game = dynamic_cast<Game&>(owner.egbase());
+	Player* owner = warehouse_->get_owner();
+	Game& game = dynamic_cast<Game&>(owner->egbase());
 	const Map& map = game.map();
-	if (enemy.get_owner() == &owner || enemy.get_battle() ||
+	if (enemy.get_owner() == owner || enemy.get_battle() ||
 	    warehouse_->descr().get_conquers() <=
 	       map.calc_distance(enemy.get_position(), warehouse_->get_position()))
 		return;
 
 	if (map.find_bobs(Area<FCoords>(map.get_fcoords(warehouse_->base_flag().get_position()), 2),
-	                  nullptr, FindBobEnemySoldier(&owner)))
+	                  nullptr, FindBobEnemySoldier(owner)))
 		return;
 
-	DescriptionIndex const soldier_index = owner.tribe().soldier();
+	DescriptionIndex const soldier_index = owner->tribe().soldier();
 	Requirements noreq;
 
 	if (!warehouse_->count_workers(game, soldier_index, noreq, Match::kCompatible))
@@ -102,9 +102,9 @@
 }
 
 AttackTarget::AttackResult Warehouse::AttackTarget::attack(Soldier* enemy) const {
-	Player& owner = warehouse_->owner();
-	Game& game = dynamic_cast<Game&>(owner.egbase());
-	DescriptionIndex const soldier_index = owner.tribe().soldier();
+	Player* owner = warehouse_->get_owner();
+	Game& game = dynamic_cast<Game&>(owner->egbase());
+	DescriptionIndex const soldier_index = owner->tribe().soldier();
 	Requirements noreq;
 
 	if (warehouse_->count_workers(game, soldier_index, noreq, Match::kCompatible)) {
@@ -495,24 +495,24 @@
 bool Warehouse::init(EditorGameBase& egbase) {
 	Building::init(egbase);
 
-	Player& player = owner();
+	Player* player = get_owner();
 
-	init_containers(player);
+	init_containers(*player);
 
 	// Even though technically, a warehouse might be completely empty,
 	// we let warehouse see always for simplicity's sake (since there's
 	// almost always going to be a carrier inside, that shouldn't hurt).
 	if (upcast(Game, game, &egbase)) {
-		player.see_area(
+		player->see_area(
 		   Area<FCoords>(egbase.map().get_fcoords(get_position()), descr().vision_range()));
 
 		{
 			uint32_t const act_time = schedule_act(*game, WORKER_WITHOUT_COST_SPAWN_INTERVAL);
 			const std::vector<DescriptionIndex>& worker_types_without_cost =
-			   owner().tribe().worker_types_without_cost();
+			   player->tribe().worker_types_without_cost();
 
 			for (size_t i = 0; i < worker_types_without_cost.size(); ++i) {
-				if (owner().is_worker_type_allowed(worker_types_without_cost.at(i))) {
+				if (player->is_worker_type_allowed(worker_types_without_cost.at(i))) {
 					next_worker_without_cost_spawn_[i] = act_time;
 				}
 			}
@@ -525,7 +525,7 @@
 		next_stock_remove_act_ = schedule_act(*game, 4000);
 
 		log("Message: adding %s for player %i at (%d, %d)\n", to_string(descr().type()).c_str(),
-		    player.player_number(), position_.x, position_.y);
+		    player->player_number(), position_.x, position_.y);
 
 		if (descr().get_isport()) {
 			send_message(*game, Message::Type::kSeafaring, descr().descname(), descr().icon_filename(),
@@ -542,7 +542,7 @@
 	if (uint32_t const conquer_radius = descr().get_conquers()) {
 		egbase.conquer_area(
 		   PlayerArea<Area<FCoords>>(
-		      player.player_number(),
+		      player->player_number(),
 		      Area<FCoords>(egbase.map().get_fcoords(get_position()), conquer_radius)),
 		   true);
 	}
@@ -560,7 +560,7 @@
 	return true;
 }
 
-void Warehouse::init_containers(Player& player) {
+void Warehouse::init_containers(const Player& player) {
 	DescriptionIndex const nr_wares = player.egbase().tribes().nrwares();
 	DescriptionIndex const nr_workers = player.egbase().tribes().nrworkers();
 	supply_->set_nrwares(nr_wares);
@@ -676,8 +676,7 @@
 		   defeating_player_);
 
 	// Unsee the area that we started seeing in init()
-	Player& player = owner();
-	player.unsee_area(Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
+	get_owner()->unsee_area(Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
 
 	Building::cleanup(egbase);
 }
@@ -917,7 +916,7 @@
 				// NOTE: This code lies about the TrainingAttributes of the new worker
 				supply_->remove_workers(worker_id, 1);
 				const WorkerDescr& workerdescr = *game.tribes().get_worker_descr(worker_id);
-				return workerdescr.create(game, owner(), this, position_);
+				return workerdescr.create(game, get_owner(), this, position_);
 			}
 		}
 
@@ -934,7 +933,7 @@
 
 void Warehouse::incorporate_worker(EditorGameBase& egbase, Worker* w) {
 	assert(w != nullptr);
-	assert(w->get_owner() == &owner());
+	assert(w->get_owner() == get_owner());
 
 	if (WareInstance* ware = w->fetch_carried_ware(egbase))
 		incorporate_ware(egbase, ware);
@@ -1091,12 +1090,12 @@
 		if (owner().tribe().has_ware(id_ware)) {
 			remove_wares(id_ware, buildcost.second);
 			// Update statistics accordingly
-			owner().ware_consumed(id_ware, buildcost.second);
+			get_owner()->ware_consumed(id_ware, buildcost.second);
 		} else
 			remove_workers(owner().tribe().safe_worker_index(input), buildcost.second);
 	}
 
-	incorporate_worker(game, &w_desc.create(game, owner(), this, position_));
+	incorporate_worker(game, &w_desc.create(game, get_owner(), this, position_));
 
 	// Update PlannedWorkers::amount here if appropriate, because this function
 	// may have been called directly by the Economy.

=== modified file 'src/logic/map_objects/tribes/warehouse.h'
--- src/logic/map_objects/tribes/warehouse.h	2017-11-26 14:44:23 +0000
+++ src/logic/map_objects/tribes/warehouse.h	2018-02-25 18:40:20 +0000
@@ -253,7 +253,7 @@
 	void init_portdock(EditorGameBase& egbase);
 
 	/// Initializes the container sizes for the owner's tribe.
-	void init_containers(Player& owner);
+	void init_containers(const Player& owner);
 
 	/**
 	 * Plan to produce a certain worker type in this warehouse. This means

=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc	2018-01-29 18:10:59 +0000
+++ src/logic/map_objects/tribes/worker.cc	2018-02-25 18:40:20 +0000
@@ -994,7 +994,7 @@
 
 			//  We should add a message to the player's message queue - but only,
 			//  if there is not already a similar one in list.
-			owner().add_message_with_timeout(game,
+			get_owner()->add_message_with_timeout(game,
 			                                 std::unique_ptr<Message>(new Message(
 			                                    message_type, game.get_gametime(), rdescr->descname(),
 			                                    ri.descr().representative_image_filename(),
@@ -1049,7 +1049,7 @@
 	}
 
 	// Update consumption statistic
-	owner().ware_consumed(wareindex, 1);
+	get_owner()->ware_consumed(wareindex, 1);
 
 	ware = fetch_carried_ware(game);
 	ware->remove(game);
@@ -1143,7 +1143,7 @@
 			// Interrupt whatever we've been doing.
 			set_economy(nullptr);
 
-			EditorGameBase& egbase = owner().egbase();
+			EditorGameBase& egbase = get_owner()->egbase();
 			if (upcast(Game, game, &egbase)) {
 				send_signal(*game, "location");
 			}
@@ -1165,7 +1165,7 @@
 
 	economy_ = economy;
 
-	if (WareInstance* const ware = get_carried_ware(owner().egbase()))
+	if (WareInstance* const ware = get_carried_ware(get_owner()->egbase()))
 		ware->set_economy(economy_);
 	if (supply_)
 		supply_->set_economy(economy_);
@@ -1868,7 +1868,7 @@
 		    descr().descname().c_str())
 		      .str();
 
-		owner().add_message(
+		get_owner()->add_message(
 		   game, std::unique_ptr<Message>(new Message(
 		            Message::Type::kGameLogic, game.get_gametime(), _("Worker"),
 		            "images/ui_basic/menu_help.png", _("Worker got lost!"), message, get_position())),
@@ -2397,7 +2397,7 @@
 	}
 	bool accept(const BaseImmovable& imm) const {
 		if (upcast(Flag const, flag, &imm))
-			if (&flag->owner() == &owner_)
+			if (flag->get_owner() == &owner_)
 				if (flag->economy().warehouses().size())
 					return true;
 		return false;
@@ -2416,7 +2416,7 @@
 	const Map& map = game.map();
 	PlayerImmovable const* location = get_location(game);
 
-	if (location && &location->owner() == &owner()) {
+	if (location && location->get_owner() == get_owner()) {
 		molog("[fugitive]: we are on location\n");
 
 		if (dynamic_cast<Warehouse const*>(location))
@@ -2428,7 +2428,7 @@
 
 	// check whether we're on a flag and it's time to return home
 	if (upcast(Flag, flag, map[get_position()].get_immovable())) {
-		if (&flag->owner() == &owner() && flag->economy().warehouses().size()) {
+		if (flag->get_owner() == get_owner() && flag->economy().warehouses().size()) {
 			set_location(flag);
 			return pop_task(game);
 		}
@@ -2703,11 +2703,11 @@
 		upcast(Flag, aflag, vu.object);
 		Building* a_building = aflag->get_building();
 		// Assuming that this always succeeds.
-		if (upcast(MilitarySite const, ms, a_building)) {
+		if (a_building->descr().type() == MapObjectType::MILITARYSITE) {
 			// This would be safe even if this assert failed: Own militarysites are always visible.
 			// However: There would be something wrong with FindForeignMilitarySite or associated
 			// code. Hence, let's keep the assert.
-			assert(&ms->owner() != &player);
+			assert(a_building->get_owner() != &player);
 			const Coords buildingpos = a_building->get_positions(game)[0];
 			// Check the visibility: only invisible ones interest the scout.
 			MapIndex mx = map.get_index(buildingpos, map.get_width());

=== modified file 'src/logic/map_objects/tribes/worker.h'
--- src/logic/map_objects/tribes/worker.h	2018-01-27 14:18:07 +0000
+++ src/logic/map_objects/tribes/worker.h	2018-02-25 18:40:20 +0000
@@ -76,11 +76,7 @@
 	explicit Worker(const WorkerDescr&);
 	~Worker() override;
 
-	Player& owner() const {
-		assert(get_owner());
-		return *get_owner();
-	}
-	PlayerImmovable* get_location(EditorGameBase& egbase) {
+	PlayerImmovable* get_location(const EditorGameBase& egbase) const {
 		return location_.get(egbase);
 	}
 	OPtr<PlayerImmovable> get_location() const {

=== modified file 'src/logic/map_objects/tribes/worker_descr.cc'
--- src/logic/map_objects/tribes/worker_descr.cc	2017-11-12 16:30:35 +0000
+++ src/logic/map_objects/tribes/worker_descr.cc	2018-02-25 18:40:20 +0000
@@ -146,11 +146,11 @@
  * Custom creation routing that accounts for the location.
  */
 Worker& WorkerDescr::create(EditorGameBase& egbase,
-                            Player& owner,
+                            Player* owner,
                             PlayerImmovable* const location,
                             Coords const coords) const {
 	Worker& worker = dynamic_cast<Worker&>(create_object());
-	worker.set_owner(&owner);
+	worker.set_owner(owner);
 	worker.set_location(location);
 	worker.set_position(egbase, coords);
 	worker.init(egbase);

=== modified file 'src/logic/map_objects/tribes/worker_descr.h'
--- src/logic/map_objects/tribes/worker_descr.h	2017-11-12 14:54:46 +0000
+++ src/logic/map_objects/tribes/worker_descr.h	2018-02-25 18:40:20 +0000
@@ -106,7 +106,7 @@
 	// The buildings where this worker can work
 	const std::set<DescriptionIndex>& employers() const;
 
-	Worker& create(EditorGameBase&, Player&, PlayerImmovable*, Coords) const;
+	Worker& create(EditorGameBase&, Player*, PlayerImmovable*, Coords) const;
 
 	uint32_t movecaps() const override;
 

=== modified file 'src/logic/player.cc'
--- src/logic/player.cc	2017-12-19 14:35:00 +0000
+++ src/logic/player.cc	2018-02-25 18:40:20 +0000
@@ -324,7 +324,7 @@
 }
 
 MessageId Player::add_message(Game& game, std::unique_ptr<Message> new_message, bool const popup) {
-	MessageId id = messages().add_message(std::move(new_message));
+	MessageId id = get_messages()->add_message(std::move(new_message));
 	const Message* message = messages()[id];
 
 	// MapObject connection
@@ -410,7 +410,7 @@
 	int32_t buildcaps = get_buildcaps(egbase().map().get_fcoords(c));
 
 	if (buildcaps & BUILDCAPS_FLAG)
-		return new Flag(egbase(), *this, c);
+		return new Flag(egbase(), this, c);
 	return nullptr;
 }
 
@@ -419,7 +419,7 @@
 	const Map& map = egbase().map();
 	if (BaseImmovable* const immovable = c.field->get_immovable()) {
 		if (upcast(Flag, existing_flag, immovable)) {
-			if (&existing_flag->owner() == this)
+			if (existing_flag->get_owner() == this)
 				return *existing_flag;
 		} else if (!dynamic_cast<Road const*>(immovable))  //  A road is OK.
 			immovable->remove(egbase());                    //  Make room for the flag.
@@ -433,7 +433,7 @@
 	//  Make sure that the player owns the area around.
 	egbase().conquer_area_no_building(
 	   PlayerArea<Area<FCoords>>(player_number(), Area<FCoords>(c, 1)));
-	return *new Flag(egbase(), *this, c);
+	return *new Flag(egbase(), this, c);
 }
 
 /*
@@ -508,7 +508,7 @@
 	map.get_brn(map.get_fcoords(location), &flag_loc);
 	force_flag(flag_loc);
 
-	return descr->create(egbase(), *this, map.get_fcoords(location), false, false, former_buildings);
+	return descr->create(egbase(), this, map.get_fcoords(location), false, false, former_buildings);
 }
 
 Building& Player::force_csite(Coords const location,
@@ -574,7 +574,7 @@
 	if (constructionsite)
 		return &egbase().warp_constructionsite(c, player_number_, idx, false, former_buildings);
 	else {
-		return &descr->create(egbase(), *this, c, false, false, former_buildings);
+		return &descr->create(egbase(), this, c, false, false, former_buildings);
 	}
 }
 
@@ -669,13 +669,13 @@
 }
 
 void Player::start_stop_building(PlayerImmovable& imm) {
-	if (&imm.owner() == this)
+	if (imm.get_owner() == this)
 		if (upcast(ProductionSite, productionsite, &imm))
 			productionsite->set_stopped(!productionsite->is_stopped());
 }
 
 void Player::start_or_cancel_expedition(Warehouse& wh) {
-	if (&wh.owner() == this)
+	if (wh.get_owner() == this)
 		if (PortDock* pd = wh.get_portdock()) {
 			if (pd->expedition_started()) {
 				upcast(Game, game, &egbase());
@@ -687,7 +687,7 @@
 
 void Player::military_site_set_soldier_preference(PlayerImmovable& imm,
                                                   SoldierPreference soldier_preference) {
-	if (&imm.owner() == this)
+	if (imm.get_owner() == this)
 		if (upcast(MilitarySite, milsite, &imm))
 			milsite->set_soldier_preference(soldier_preference);
 }
@@ -709,7 +709,7 @@
 }
 void Player::enhance_or_dismantle(Building* building,
                                   DescriptionIndex const index_of_new_building) {
-	if (&building->owner() == this && (index_of_new_building == INVALID_INDEX ||
+	if (building->get_owner() == this && (index_of_new_building == INVALID_INDEX ||
 	                                   building->descr().enhancement() == index_of_new_building)) {
 		Building::FormerBuildings former_buildings = building->get_former_buildings();
 		const Coords position = building->get_position();
@@ -758,7 +758,7 @@
 ===============
 */
 void Player::flagaction(Flag& flag) {
-	if (&flag.owner() == this) {  //  Additional security check.
+	if (flag.get_owner() == this) {  //  Additional security check.
 		flag.add_flag_job(dynamic_cast<Game&>(egbase()), tribe().geologist(), "expedition");
 	}
 }
@@ -835,7 +835,7 @@
 ===========
 */
 void Player::drop_soldier(PlayerImmovable& imm, Soldier& soldier) {
-	if (&imm.owner() != this)
+	if (imm.get_owner() != this)
 		return;
 	if (soldier.descr().type() != MapObjectType::SOLDIER)
 		return;

=== modified file 'src/logic/player.h'
--- src/logic/player.h	2018-02-03 21:18:36 +0000
+++ src/logic/player.h	2018-02-25 18:40:20 +0000
@@ -88,8 +88,8 @@
 	const MessageQueue& messages() const {
 		return messages_;
 	}
-	MessageQueue& messages() {
-		return messages_;
+	MessageQueue* get_messages() {
+		return &messages_;
 	}
 
 	/// Adds the message to the queue.
@@ -108,7 +108,7 @@
 	void message_object_removed(MessageId mid) const;
 
 	void set_message_status(const MessageId& id, Message::Status const status) {
-		messages().set_message_status(id, status);
+		get_messages()->set_message_status(id, status);
 	}
 
 	const EditorGameBase& egbase() const {

=== modified file 'src/logic/playercommand.cc'
--- src/logic/playercommand.cc	2017-11-01 18:44:34 +0000
+++ src/logic/playercommand.cc	2018-02-25 18:40:20 +0000
@@ -222,7 +222,7 @@
 
 void CmdBulldoze::execute(Game& game) {
 	if (upcast(PlayerImmovable, pimm, game.objects().get_object(serial)))
-		game.player(sender()).bulldoze(*pimm, recurse);
+		game.get_player(sender())->bulldoze(*pimm, recurse);
 }
 
 void CmdBulldoze::serialize(StreamWrite& ser) {
@@ -269,7 +269,7 @@
 void CmdBuild::execute(Game& game) {
 	// Empty former vector since its a new csite.
 	Building::FormerBuildings former_buildings;
-	game.player(sender()).build(coords, bi, true, former_buildings);
+	game.get_player(sender())->build(coords, bi, true, former_buildings);
 }
 
 void CmdBuild::serialize(StreamWrite& ser) {
@@ -313,7 +313,7 @@
 }
 
 void CmdBuildFlag::execute(Game& game) {
-	game.player(sender()).build_flag(coords);
+	game.get_player(sender())->build_flag(coords);
 }
 
 void CmdBuildFlag::serialize(StreamWrite& ser) {
@@ -383,7 +383,7 @@
 			path->append(game.map(), steps[i]);
 	}
 
-	game.player(sender()).build_road(*path);
+	game.get_player(sender())->build_road(*path);
 }
 
 void CmdBuildRoad::serialize(StreamWrite& ser) {
@@ -437,10 +437,10 @@
 }
 
 void CmdFlagAction::execute(Game& game) {
-	Player& player = game.player(sender());
+	Player* player = game.get_player(sender());
 	if (upcast(Flag, flag, game.objects().get_object(serial)))
-		if (&flag->owner() == &player)
-			player.flagaction(*flag);
+		if (flag->get_owner() == player)
+			player->flagaction(*flag);
 }
 
 void CmdFlagAction::serialize(StreamWrite& ser) {
@@ -487,7 +487,7 @@
 
 void CmdStartStopBuilding::execute(Game& game) {
 	if (upcast(Building, building, game.objects().get_object(serial)))
-		game.player(sender()).start_stop_building(*building);
+		game.get_player(sender())->start_stop_building(*building);
 }
 
 void CmdStartStopBuilding::serialize(StreamWrite& ser) {
@@ -537,7 +537,7 @@
 
 void CmdMilitarySiteSetSoldierPreference::execute(Game& game) {
 	if (upcast(MilitarySite, building, game.objects().get_object(serial)))
-		game.player(sender()).military_site_set_soldier_preference(*building, preference);
+		game.get_player(sender())->military_site_set_soldier_preference(*building, preference);
 }
 
 constexpr uint16_t kCurrentPacketVersionSoldierPreference = 1;
@@ -583,7 +583,7 @@
 
 void CmdStartOrCancelExpedition::execute(Game& game) {
 	if (upcast(Warehouse, warehouse, game.objects().get_object(serial)))
-		game.player(sender()).start_or_cancel_expedition(*warehouse);
+		game.get_player(sender())->start_or_cancel_expedition(*warehouse);
 }
 
 void CmdStartOrCancelExpedition::serialize(StreamWrite& ser) {
@@ -627,7 +627,7 @@
 
 void CmdEnhanceBuilding::execute(Game& game) {
 	if (upcast(Building, building, game.objects().get_object(serial)))
-		game.player(sender()).enhance_building(building, bi);
+		game.get_player(sender())->enhance_building(building, bi);
 }
 
 void CmdEnhanceBuilding::serialize(StreamWrite& ser) {
@@ -674,7 +674,7 @@
 
 void CmdDismantleBuilding::execute(Game& game) {
 	if (upcast(Building, building, game.objects().get_object(serial)))
-		game.player(sender()).dismantle_building(building);
+		game.get_player(sender())->dismantle_building(building);
 }
 
 void CmdDismantleBuilding::serialize(StreamWrite& ser) {
@@ -1228,9 +1228,9 @@
 }
 
 void CmdSetWareTargetQuantity::execute(Game& game) {
-	Player& player = game.player(sender());
-	if (economy() < player.get_nr_economies() && game.tribes().ware_exists(ware_type())) {
-		player.get_economy_by_number(economy())->set_ware_target_quantity(
+	Player* player = game.get_player(sender());
+	if (economy() < player->get_nr_economies() && game.tribes().ware_exists(ware_type())) {
+		player->get_economy_by_number(economy())->set_ware_target_quantity(
 		   ware_type(), permanent_, duetime());
 	}
 }
@@ -1278,11 +1278,11 @@
 }
 
 void CmdResetWareTargetQuantity::execute(Game& game) {
-	Player& player = game.player(sender());
-	const TribeDescr& tribe = player.tribe();
-	if (economy() < player.get_nr_economies() && game.tribes().ware_exists(ware_type())) {
+	Player* player = game.get_player(sender());
+	const TribeDescr& tribe = player->tribe();
+	if (economy() < player->get_nr_economies() && game.tribes().ware_exists(ware_type())) {
 		const int count = tribe.get_ware_descr(ware_type())->default_target_quantity(tribe.name());
-		player.get_economy_by_number(economy())->set_ware_target_quantity(
+		player->get_economy_by_number(economy())->set_ware_target_quantity(
 		   ware_type(), count, duetime());
 	}
 }
@@ -1327,9 +1327,9 @@
 }
 
 void CmdSetWorkerTargetQuantity::execute(Game& game) {
-	Player& player = game.player(sender());
-	if (economy() < player.get_nr_economies() && game.tribes().worker_exists(ware_type())) {
-		player.get_economy_by_number(economy())->set_worker_target_quantity(
+	Player* player = game.get_player(sender());
+	if (economy() < player->get_nr_economies() && game.tribes().worker_exists(ware_type())) {
+		player->get_economy_by_number(economy())->set_worker_target_quantity(
 		   ware_type(), permanent_, duetime());
 	}
 }
@@ -1377,11 +1377,11 @@
 }
 
 void CmdResetWorkerTargetQuantity::execute(Game& game) {
-	Player& player = game.player(sender());
-	const TribeDescr& tribe = player.tribe();
-	if (economy() < player.get_nr_economies() && game.tribes().ware_exists(ware_type())) {
+	Player* player = game.get_player(sender());
+	const TribeDescr& tribe = player->tribe();
+	if (economy() < player->get_nr_economies() && game.tribes().ware_exists(ware_type())) {
 		const int count = tribe.get_ware_descr(ware_type())->default_target_quantity(tribe.name());
-		player.get_economy_by_number(economy())->set_worker_target_quantity(
+		player->get_economy_by_number(economy())->set_worker_target_quantity(
 		   ware_type(), count, duetime());
 	}
 }
@@ -1430,7 +1430,7 @@
 
 void CmdChangeTrainingOptions::execute(Game& game) {
 	if (upcast(TrainingSite, trainingsite, game.objects().get_object(serial)))
-		game.player(sender()).change_training_options(*trainingsite, attribute, value);
+		game.get_player(sender())->change_training_options(*trainingsite, attribute, value);
 }
 
 void CmdChangeTrainingOptions::serialize(StreamWrite& ser) {
@@ -1483,7 +1483,7 @@
 void CmdDropSoldier::execute(Game& game) {
 	if (upcast(PlayerImmovable, player_imm, game.objects().get_object(serial)))
 		if (upcast(Soldier, s, game.objects().get_object(soldier)))
-			game.player(sender()).drop_soldier(*player_imm, *s);
+			game.get_player(sender())->drop_soldier(*player_imm, *s);
 }
 
 void CmdDropSoldier::serialize(StreamWrite& ser) {
@@ -1534,7 +1534,7 @@
 
 void CmdChangeSoldierCapacity::execute(Game& game) {
 	if (upcast(Building, building, game.objects().get_object(serial))) {
-		if (&building->owner() == game.get_player(sender()) &&
+		if (building->get_owner() == game.get_player(sender()) &&
 		    building->soldier_control() != nullptr) {
 			SoldierControl* soldier_control = building->mutable_soldier_control();
 			Widelands::Quantity const old_capacity = soldier_control->soldier_capacity();
@@ -1598,17 +1598,17 @@
 }
 
 void CmdEnemyFlagAction::execute(Game& game) {
-	Player& player = game.player(sender());
+	Player* player = game.get_player(sender());
 
 	if (upcast(Flag, flag, game.objects().get_object(serial))) {
 		log("Cmd_EnemyFlagAction::execute player(%u): flag->owner(%d) "
 		    "number=%u\n",
-		    player.player_number(), flag->owner().player_number(), number);
+		    player->player_number(), flag->owner().player_number(), number);
 
 		if (const Building* const building = flag->get_building()) {
-			if (player.is_hostile(flag->owner()) &&
-			    1 < player.vision(Map::get_index(building->get_position(), game.map().get_width())))
-				player.enemyflagaction(*flag, sender(), number);
+			if (player->is_hostile(flag->owner()) &&
+			    1 < player->vision(Map::get_index(building->get_position(), game.map().get_width())))
+				player->enemyflagaction(*flag, sender(), number);
 			else
 				log("Cmd_EnemyFlagAction::execute: ERROR: wrong player target not "
 				    "seen or not hostile.\n");
@@ -1695,7 +1695,7 @@
 /*** struct Cmd_MessageSetStatusRead ***/
 
 void CmdMessageSetStatusRead::execute(Game& game) {
-	game.player(sender()).messages().set_message_status(message_id(), Message::Status::kRead);
+	game.get_player(sender())->get_messages()->set_message_status(message_id(), Message::Status::kRead);
 }
 
 void CmdMessageSetStatusRead::serialize(StreamWrite& ser) {
@@ -1707,7 +1707,7 @@
 /*** struct Cmd_MessageSetStatusArchived ***/
 
 void CmdMessageSetStatusArchived::execute(Game& game) {
-	game.player(sender()).messages().set_message_status(message_id(), Message::Status::kArchived);
+	game.get_player(sender())->get_messages()->set_message_status(message_id(), Message::Status::kArchived);
 }
 
 void CmdMessageSetStatusArchived::serialize(StreamWrite& ser) {
@@ -1738,7 +1738,7 @@
 	// Sanitize data that could have come from the network
 	if (Player* plr = game.get_player(sender())) {
 		if (upcast(Warehouse, warehouse, game.objects().get_object(warehouse_))) {
-			if (&warehouse->owner() != plr) {
+			if (warehouse->get_owner() != plr) {
 				log("Cmd_SetStockPolicy: sender %u, but warehouse owner %u\n", sender(),
 				    warehouse->owner().player_number());
 				return;
@@ -1834,7 +1834,7 @@
 		log("CmdProposeTrade: receiver vanished or is not a market.\n");
 		return;
 	}
-	if (&initiator->owner() == &receiver->owner()) {
+	if (initiator->get_owner() == receiver->get_owner()) {
 		log("CmdProposeTrade: Sending and receiving player are the same.\n");
 		return;
 	}

=== modified file 'src/logic/playersmanager.h'
--- src/logic/playersmanager.h	2017-06-24 08:47:46 +0000
+++ src/logic/playersmanager.h	2018-02-25 18:40:20 +0000
@@ -73,7 +73,7 @@
 		assert(n <= kMaxPlayers);
 		return players_[n - 1];
 	}
-	Player& player(int32_t n) const {
+	const Player& player(int32_t n) const {
 		assert(1 <= n);
 		assert(n <= kMaxPlayers);
 		return *players_[n - 1];

=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc	2017-12-17 17:47:34 +0000
+++ src/map_io/map_buildingdata_packet.cc	2018-02-25 18:40:20 +0000
@@ -314,9 +314,9 @@
 	try {
 		uint16_t const packet_version = fr.unsigned_16();
 		if (packet_version >= 6) {
-			Player& player = warehouse.owner();
-			warehouse.init_containers(player);
-			const TribeDescr& tribe = player.tribe();
+			Player* player = warehouse.get_owner();
+			warehouse.init_containers(*player);
+			const TribeDescr& tribe = player->tribe();
 
 			while (fr.unsigned_8()) {
 				const DescriptionIndex& id = tribe.ware_index(fr.c_string());
@@ -441,14 +441,14 @@
 				//  Add to map of military influence.
 				Area<FCoords> a(map.get_fcoords(warehouse.get_position()), conquer_radius);
 				const Field& first_map_field = map[0];
-				Player::Field* const player_fields = player.fields_;
+				Player::Field* const player_fields = player->fields_;
 				MapRegion<Area<FCoords>> mr(map, a);
 				do
 					player_fields[mr.location().field - &first_map_field].military_influence +=
 					   map.calc_influence(mr.location(), Area<>(a, a.radius));
 				while (mr.advance(map));
 			}
-			player.see_area(Area<FCoords>(
+			player->see_area(Area<FCoords>(
 			   map.get_fcoords(warehouse.get_position()), warehouse.descr().vision_range()));
 			warehouse.next_military_act_ = game.get_gametime();
 		} else {

=== modified file 'src/map_io/map_flag_packet.cc'
--- src/map_io/map_flag_packet.cc	2017-01-25 18:55:59 +0000
+++ src/map_io/map_flag_packet.cc	2018-02-25 18:40:20 +0000
@@ -100,7 +100,7 @@
 					//  since we have to read the data packets. We delete this
 					//  object later again, if it is not wanted.
 					mol.register_object<Flag>(
-					   serial, *new Flag(dynamic_cast<Game&>(egbase), egbase.player(owner), fc));
+					   serial, *new Flag(dynamic_cast<Game&>(egbase), egbase.get_player(owner), fc));
 				} catch (const WException& e) {
 					throw GameDataError(
 					   "%u (at (%i, %i), owned by player %u): %s", serial, fc.x, fc.y, owner, e.what());

=== modified file 'src/map_io/map_players_messages_packet.cc'
--- src/map_io/map_players_messages_packet.cc	2017-07-05 19:30:41 +0000
+++ src/map_io/map_players_messages_packet.cc	2018-02-25 18:40:20 +0000
@@ -59,11 +59,11 @@
 		}
 		uint32_t packet_version = prof.get_safe_section("global").get_positive("packet_version");
 		if (1 <= packet_version && packet_version <= kCurrentPacketVersion) {
-			MessageQueue& messages = player->messages();
+			MessageQueue* messages = player->get_messages();
 
 			{
-				const auto begin = messages.begin();
-				if (begin != messages.end()) {
+				const auto begin = messages->begin();
+				if (begin != messages->end()) {
 					log("ERROR: The message queue for player %u contains a message "
 					    "before any messages have been loaded into it. This is a bug "
 					    "in the savegame loading code. It created a new message and "
@@ -79,7 +79,7 @@
 					    p, static_cast<int>(begin->second->type()), begin->second->title().c_str(),
 					    begin->second->sent(), begin->second->position().x, begin->second->position().y,
 					    static_cast<int>(begin->second->status()), begin->second->body().c_str());
-					messages.clear();
+					messages->clear();
 				}
 			}
 
@@ -120,13 +120,13 @@
 					// Compatibility code needed for map loading.
 					if (packet_version == 1) {
 						const std::string name = s->get_name();
-						messages.add_message(std::unique_ptr<Message>(new Message(
+						messages->add_message(std::unique_ptr<Message>(new Message(
 						   static_cast<Message::Type>(s->get_natural("type")), sent, name,
 						   "images/wui/fieldaction/menu_build_flag.png", name, s->get_safe_string("body"),
 						   get_coords("position", extent, Coords::null(), s), serial, status)));
 					} else {
 
-						messages.add_message(std::unique_ptr<Message>(new Message(
+						messages->add_message(std::unique_ptr<Message>(new Message(
 						   static_cast<Message::Type>(s->get_natural("type")), sent, s->get_name(),
 						   s->get_safe_string("icon"), s->get_safe_string("heading"),
 						   s->get_safe_string("body"), get_coords("position", extent, Coords::null(), s),

=== modified file 'src/map_io/map_roaddata_packet.cc'
--- src/map_io/map_roaddata_packet.cc	2017-08-20 08:34:02 +0000
+++ src/map_io/map_roaddata_packet.cc	2018-02-25 18:40:20 +0000
@@ -71,9 +71,8 @@
 					if (!(0 < player_index && player_index <= nr_players)) {
 						throw GameDataError("Invalid player number: %i.", player_index);
 					}
-					Player& plr = egbase.player(player_index);
 
-					road.set_owner(&plr);
+					road.set_owner(egbase.get_player(player_index));
 					road.busyness_ = fr.unsigned_32();
 					road.busyness_last_update_ = fr.unsigned_32();
 					road.type_ = fr.unsigned_32();

=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc	2017-12-19 17:04:30 +0000
+++ src/scripting/lua_game.cc	2018-02-25 18:40:20 +0000
@@ -1228,7 +1228,7 @@
 	else
 		report_error(L, "Invalid message status <%s>!", s.c_str());
 
-	get_plr(L, get_game(L)).messages().set_message_status(message_id_, status);
+	get_plr(L, get_game(L)).get_messages()->set_message_status(message_id_, status);
 
 	return 0;
 }

=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc	2018-01-23 00:23:13 +0000
+++ src/scripting/lua_map.cc	2018-02-25 18:40:20 +0000
@@ -585,7 +585,7 @@
 		} else if (d > 0) {
 			for (; d; --d) {
 				Soldier& soldier = dynamic_cast<Soldier&>(
-				   soldier_descr.create(egbase, *owner, nullptr, building_position));
+				   soldier_descr.create(egbase, owner, nullptr, building_position));
 				soldier.set_level(sp.first.health, sp.first.attack, sp.first.defense, sp.first.evade);
 				if (sc->incorporate_soldier(egbase, soldier)) {
 					soldier.remove(egbase);
@@ -4327,7 +4327,7 @@
 	for (Path::StepVector::size_type i = 0; i < idle_index; ++i)
 		egbase.map().get_neighbour(idle_position, path[i], &idle_position);
 
-	Carrier& carrier = dynamic_cast<Carrier&>(wdes->create(egbase, r.owner(), &r, idle_position));
+	Carrier& carrier = dynamic_cast<Carrier&>(wdes->create(egbase, r.get_owner(), &r, idle_position));
 
 	if (upcast(Game, game, &egbase)) {
 		carrier.start_task_road(*game);

=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc	2018-02-23 13:38:35 +0000
+++ src/wui/game_message_menu.cc	2018-02-25 18:40:20 +0000
@@ -163,7 +163,7 @@
  * If both are identical, sort by time sent.
  */
 bool GameMessageMenu::compare_title(uint32_t a, uint32_t b) {
-	MessageQueue& mq = iplayer().player().messages();
+	const MessageQueue& mq = iplayer().player().messages();
 	const Message* msga = mq[MessageId((*list)[a])];
 	const Message* msgb = mq[MessageId((*list)[b])];
 
@@ -181,7 +181,7 @@
  * If both are identical, sort by time sent.
  */
 bool GameMessageMenu::compare_status(uint32_t a, uint32_t b) {
-	MessageQueue& mq = iplayer().player().messages();
+	const MessageQueue& mq = iplayer().player().messages();
 	const Message* msga = mq[MessageId((*list)[a])];
 	const Message* msgb = mq[MessageId((*list)[b])];
 
@@ -199,7 +199,7 @@
  * If both are identical, sort by time sent.
  */
 bool GameMessageMenu::compare_type(uint32_t a, uint32_t b) {
-	MessageQueue& mq = iplayer().player().messages();
+	const MessageQueue& mq = iplayer().player().messages();
 	const Message* msga = mq[MessageId((*list)[a])];
 	const Message* msgb = mq[MessageId((*list)[b])];
 
@@ -218,7 +218,7 @@
  * When comparing messages by time sent, older messages come before others.
  */
 bool GameMessageMenu::compare_time_sent(uint32_t a, uint32_t b) {
-	MessageQueue& mq = iplayer().player().messages();
+	const MessageQueue& mq = iplayer().player().messages();
 	const Message* msga = mq[MessageId((*list)[a])];
 	const Message* msgb = mq[MessageId((*list)[b])];
 
@@ -252,7 +252,7 @@
 }
 
 void GameMessageMenu::think() {
-	MessageQueue& mq = iplayer().player().messages();
+	const MessageQueue& mq = iplayer().player().messages();
 	size_t no_selections = list->selections().size();
 	size_t list_size = list->size();
 
@@ -310,8 +310,8 @@
  * Something has been selected
  */
 void GameMessageMenu::selected(uint32_t const t) {
-	Widelands::Player& player = iplayer().player();
-	MessageQueue& mq = player.messages();
+	const Widelands::Player& player = iplayer().player();
+	const MessageQueue& mq = player.messages();
 	if (t != UI::Table<uintptr_t>::no_selection_index()) {
 		MessageId const id = MessageId((*list)[t]);
 		if (Message const* const message = mq[id]) {

=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc	2018-01-10 16:29:00 +0000
+++ src/wui/interactive_player.cc	2018-02-25 18:40:20 +0000
@@ -302,7 +302,7 @@
 			f->roads = player_field.roads;
 			f->vision = player_field.vision;
 			if (player_field.vision == 1) {
-				f->owner = player_field.owner != 0 ? &gbase.player(player_field.owner) : nullptr;
+				f->owner = player_field.owner != 0 ? gbase.get_player(player_field.owner) : nullptr;
 				f->is_border = player_field.border;
 			}
 		}

=== modified file 'src/wui/interactive_player.h'
--- src/wui/interactive_player.h	2017-09-01 14:12:58 +0000
+++ src/wui/interactive_player.h	2018-02-25 18:40:20 +0000
@@ -57,7 +57,7 @@
 
 	bool handle_key(bool down, SDL_Keysym) override;
 
-	Widelands::Player& player() const {
+	const Widelands::Player& player() const {
 		return game().player(player_number_);
 	}
 	Widelands::Player* get_player() const override {


Follow ups