← Back to team overview

widelands-dev team mailing list archive

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

 

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

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/delete_deprecated/+merge/243174

Got rid of base/deprecated.h.

There are 2 NOCOM comments in the code with questions.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/delete_deprecated into lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc	2014-11-03 06:45:32 +0000
+++ src/ai/defaultai.cc	2014-11-28 17:01:11 +0000
@@ -330,13 +330,12 @@
 
 		// Read all interesting data from ware producing buildings
 		if (typeid(bld) == typeid(ProductionSiteDescr)) {
-			const ProductionSiteDescr& prod =
-			   ref_cast<ProductionSiteDescr const, BuildingDescr const>(bld);
+			upcast(ProductionSiteDescr const, prod, &bld);
 			bo.type = bld.get_ismine() ? BuildingObserver::MINE : BuildingObserver::PRODUCTIONSITE;
-			for (const WareAmount& temp_input : prod.inputs()) {
+			for (const WareAmount& temp_input : prod->inputs()) {
 				bo.inputs_.push_back(temp_input.first);
 			}
-			for (const WareIndex& temp_output : prod.output_ware_types()) {
+			for (const WareIndex& temp_output : prod->output_ware_types()) {
 				bo.outputs_.push_back(temp_output);
 			}
 
@@ -370,9 +369,8 @@
 		// non critical are excluded (see below)
 		if (typeid(bld) == typeid(MilitarySiteDescr)) {
 			bo.type = BuildingObserver::MILITARYSITE;
-			const MilitarySiteDescr& milit =
-			   ref_cast<MilitarySiteDescr const, BuildingDescr const>(bld);
-			for (const std::pair<unsigned char, unsigned char>& temp_buildcosts : milit.buildcost()) {
+			upcast(MilitarySiteDescr const, milit, &bld);
+			for (const std::pair<unsigned char, unsigned char>& temp_buildcosts : milit->buildcost()) {
 				// bellow are non-critical wares
 				if (tribe_->ware_index("log") == temp_buildcosts.first ||
 				    tribe_->ware_index("blackwood") == temp_buildcosts.first ||
@@ -3007,8 +3005,9 @@
 	BuildingObserver& bo = get_building_observer(b.descr().name().c_str());
 
 	if (bo.type == BuildingObserver::CONSTRUCTIONSITE) {
+		upcast(ConstructionSite const, constructionsite, &b);
 		BuildingObserver& target_bo =
-		   get_building_observer(ref_cast<ConstructionSite, Building>(b).building().name().c_str());
+			get_building_observer(constructionsite->building().name().c_str());
 		++target_bo.cnt_under_construction_;
 		++num_constructionsites_;
 		if (target_bo.type == BuildingObserver::PRODUCTIONSITE) {
@@ -3024,8 +3023,9 @@
 		++bo.cnt_built_;
 
 		if (bo.type == BuildingObserver::PRODUCTIONSITE) {
+			upcast(ProductionSite, productionsite, &b);
 			productionsites.push_back(ProductionSiteObserver());
-			productionsites.back().site = &ref_cast<ProductionSite, Building>(b);
+			productionsites.back().site = productionsite;
 			productionsites.back().bo = &bo;
 			productionsites.back().built_time_ = game().get_gametime();
 			productionsites.back().unoccupied_till_ = game().get_gametime();
@@ -3038,8 +3038,9 @@
 			for (uint32_t i = 0; i < bo.inputs_.size(); ++i)
 				++wares.at(bo.inputs_.at(i)).consumers_;
 		} else if (bo.type == BuildingObserver::MINE) {
+			upcast(ProductionSite, productionsite, &b);
 			mines_.push_back(ProductionSiteObserver());
-			mines_.back().site = &ref_cast<ProductionSite, Building>(b);
+			mines_.back().site = productionsite;
 			mines_.back().bo = &bo;
 			mines_.back().built_time_ = game().get_gametime();
 
@@ -3049,8 +3050,9 @@
 			for (uint32_t i = 0; i < bo.inputs_.size(); ++i)
 				++wares.at(bo.inputs_.at(i)).consumers_;
 		} else if (bo.type == BuildingObserver::MILITARYSITE) {
+			upcast(MilitarySite, militarysite, &b);
 			militarysites.push_back(MilitarySiteObserver());
-			militarysites.back().site = &ref_cast<MilitarySite, Building>(b);
+			militarysites.back().site = militarysite;
 			militarysites.back().bo = &bo;
 			militarysites.back().checks = bo.desc->get_size();
 			militarysites.back().enemies_nearby_ = true;
@@ -3066,8 +3068,9 @@
 	BuildingObserver& bo = get_building_observer(b.descr().name().c_str());
 
 	if (bo.type == BuildingObserver::CONSTRUCTIONSITE) {
-		BuildingObserver& target_bo = get_building_observer(
-		   ref_cast<ConstructionSite const, Building const>(b).building().name().c_str());
+		upcast(ConstructionSite const, constructionsite, &b);
+		BuildingObserver& target_bo =
+				get_building_observer(constructionsite->building().name().c_str());
 		--target_bo.cnt_under_construction_;
 		--num_constructionsites_;
 		if (target_bo.type == BuildingObserver::PRODUCTIONSITE) {

=== modified file 'src/base/CMakeLists.txt'
--- src/base/CMakeLists.txt	2014-11-26 09:36:46 +0000
+++ src/base/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -45,13 +45,6 @@
     base_macros
 )
 
-# TODO(sirver): this library should be deleted.
-wl_library(base_deprecated
-  SRCS
-    deprecated.h
-    deprecated.cc
-  DEPENDS
-)
 
 wl_library(base_scoped_timer
   SRCS

=== removed file 'src/base/deprecated.cc'
--- src/base/deprecated.cc	2014-07-05 12:17:03 +0000
+++ src/base/deprecated.cc	1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2006-2014 by the Widelands Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-// Dummy file as cmake cannot handle header only libraries :(.

=== removed file 'src/base/deprecated.h'
--- src/base/deprecated.h	2014-07-25 19:15:23 +0000
+++ src/base/deprecated.h	1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2006-2014 by the Widelands Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef WL_BASE_DEPRECATED_H
-#define WL_BASE_DEPRECATED_H
-
-// Code that is still used all over the place, but should not be used anymore.
-
-#include <cassert>
-
-// DEPRECATED: leads to unsafe code. Instead use upcast() or is_a() to check at
-// runtime for the type you are expecting.
-template<typename Derived, typename Base> Derived & ref_cast(Base & base) {
-	assert(dynamic_cast<Derived *>(&base) == static_cast<Derived *>(&base));
-	return static_cast<Derived &>(base);
-}
-
-
-#endif  // end of include guard: WL_BASE_DEPRECATED_H

=== modified file 'src/economy/CMakeLists.txt'
--- src/economy/CMakeLists.txt	2014-07-05 12:17:03 +0000
+++ src/economy/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -41,7 +41,6 @@
     wares_queue.cc
     wares_queue.h
   DEPENDS
-    base_deprecated
     base_exceptions
     base_log
     base_macros

=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc	2014-09-20 09:37:47 +0000
+++ src/economy/economy.cc	2014-11-28 17:01:11 +0000
@@ -1034,19 +1034,17 @@
 */
 void Economy::balance(uint32_t const timerid)
 {
-	if (m_request_timerid != timerid)
+	if (m_request_timerid != timerid) {
 		return;
+	}
 	++m_request_timerid;
 
-	Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
+	upcast(Game, game, &owner().egbase());
 
 	_check_splits();
-
-	_create_requested_workers (game);
-
-	_balance_requestsupply(game);
-
-	_handle_active_supplies(game);
+	_create_requested_workers(*game);
+	_balance_requestsupply(*game);
+	_handle_active_supplies(*game);
 }
 
 }

=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc	2014-09-10 10:18:46 +0000
+++ src/economy/flag.cc	2014-11-28 17:01:11 +0000
@@ -19,7 +19,6 @@
 
 #include "economy/flag.h"
 
-#include "base/deprecated.h"
 #include "base/macros.h"
 #include "base/wexception.h"
 #include "economy/economy.h"
@@ -640,15 +639,16 @@
 	}
 
 	// Deal with the normal (flag) case
-	ref_cast<Flag const, PlayerImmovable const>(*nextstep);
+	upcast(Flag const, nextflag, nextstep);
 
 	for (int32_t dir = 1; dir <= 6; ++dir) {
 		Road * const road = get_road(dir);
 		Flag *       other;
 		Road::FlagId flagid;
 
-		if (!road)
+		if (!road) {
 			continue;
+		}
 
 		if (&road->get_flag(Road::FlagStart) == this) {
 			flagid = Road::FlagStart;
@@ -658,12 +658,14 @@
 			other = &road->get_flag(Road::FlagStart);
 		}
 
-		if (other != nextstep)
+		if (other != nextflag) {
 			continue;
+		}
 
 		// Yes, this is the road we want; inform it
-		if (road->notify_ware(game, flagid))
+		if (road->notify_ware(game, flagid)) {
 			return;
+		}
 
 		// If the road doesn't react to the ware immediately, we try other roads:
 		// They might lead to the same flag!
@@ -791,24 +793,24 @@
 	 Worker          * const w,
 	 PlayerImmovable &       target)
 {
-	Flag & flag = ref_cast<Flag, PlayerImmovable>(target);
+	upcast(Flag, flag, &target);
 
 	assert(w);
 
-	for (FlagJobs::iterator flag_iter = flag.m_flag_jobs.begin();
-		  flag_iter != flag.m_flag_jobs.end();
+	for (FlagJobs::iterator flag_iter = flag->m_flag_jobs.begin();
+		  flag_iter != flag->m_flag_jobs.end();
 		  ++flag_iter) {
 		if (flag_iter->request == &rq) {
 			delete &rq;
 
 			w->start_task_program(game, flag_iter->program);
 
-			flag.m_flag_jobs.erase(flag_iter);
+			flag->m_flag_jobs.erase(flag_iter);
 			return;
 		}
 	}
 
-	flag.molog("BUG: flag_job_request_callback: worker not found in list\n");
+	flag->molog("BUG: flag_job_request_callback: worker not found in list\n");
 }
 
 void Flag::log_general_info(const Widelands::EditorGameBase & egbase)

=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc	2014-09-20 09:37:47 +0000
+++ src/economy/fleet.cc	2014-11-28 17:01:11 +0000
@@ -21,7 +21,6 @@
 
 #include <memory>
 
-#include "base/deprecated.h"
 #include "base/macros.h"
 #include "economy/economy.h"
 #include "economy/flag.h"

=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc	2014-09-20 09:37:47 +0000
+++ src/economy/portdock.cc	2014-11-28 17:01:11 +0000
@@ -21,8 +21,8 @@
 
 #include <memory>
 
-#include "base/deprecated.h"
 #include "base/log.h"
+#include "base/macros.h"
 #include "economy/fleet.h"
 #include "economy/ware_instance.h"
 #include "economy/wares_queue.h"

=== modified file 'src/economy/road.cc'
--- src/economy/road.cc	2014-09-19 12:54:54 +0000
+++ src/economy/road.cc	2014-11-28 17:01:11 +0000
@@ -382,15 +382,14 @@
 {
 	assert(w);
 
-	Road    & road    = ref_cast<Road,    PlayerImmovable>(target);
+	upcast(Road, road, &target);
+	upcast(Carrier, carrier, w);
 
-	for (CarrierSlot& slot : road.m_carrier_slots) {
+	for (CarrierSlot& slot : road->m_carrier_slots) {
 		if (slot.carrier_request == &rq) {
-			Carrier & carrier = ref_cast<Carrier, Worker> (*w);
 			slot.carrier_request = nullptr;
-			slot.carrier = &carrier;
-
-			carrier.start_task_road(game);
+			slot.carrier = carrier;
+			carrier->start_task_road(game);
 			delete &rq;
 			return;
 		}
@@ -402,7 +401,7 @@
 	 */
 	log
 		("Road(%u): got a request_callback but do not have the request\n",
-		 road.serial());
+		 road->serial());
 	delete &rq;
 	w->start_task_gowarehouse(game);
 }

=== modified file 'src/economy/routeastar.h'
--- src/economy/routeastar.h	2014-09-14 11:31:58 +0000
+++ src/economy/routeastar.h	2014-11-28 17:01:11 +0000
@@ -20,7 +20,6 @@
 #ifndef WL_ECONOMY_ROUTEASTAR_H
 #define WL_ECONOMY_ROUTEASTAR_H
 
-#include "base/deprecated.h"
 #include "economy/itransport_cost_calculator.h"
 #include "economy/routing_node.h"
 

=== modified file 'src/economy/supply_list.cc'
--- src/economy/supply_list.cc	2014-07-25 16:37:06 +0000
+++ src/economy/supply_list.cc	2014-11-28 17:01:11 +0000
@@ -19,7 +19,6 @@
 
 #include "economy/supply_list.h"
 
-#include "base/deprecated.h"
 #include "base/wexception.h"
 #include "economy/request.h"
 #include "economy/supply.h"

=== modified file 'src/economy/test/CMakeLists.txt'
--- src/economy/test/CMakeLists.txt	2014-10-28 21:14:24 +0000
+++ src/economy/test/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -4,7 +4,6 @@
     test_road.cc
     test_routing.cc
   DEPENDS
-    base_deprecated
     economy
     io_filesystem
     logic

=== modified file 'src/economy/test/test_routing.cc'
--- src/economy/test/test_routing.cc	2014-10-28 21:14:24 +0000
+++ src/economy/test/test_routing.cc	2014-11-28 17:01:11 +0000
@@ -22,7 +22,6 @@
 #include <boost/bind.hpp>
 #include <boost/test/unit_test.hpp>
 
-#include "base/deprecated.h"
 #include "economy/flag.h"
 #include "economy/iroute.h"
 #include "economy/itransport_cost_calculator.h"

=== modified file 'src/economy/ware_instance.cc'
--- src/economy/ware_instance.cc	2014-09-20 09:37:47 +0000
+++ src/economy/ware_instance.cc	2014-11-28 17:01:11 +0000
@@ -560,8 +560,8 @@
 	m_location = fr.unsigned_32();
 	m_transfer_nextstep = fr.unsigned_32();
 	if (fr.unsigned_8()) {
-		ware.m_transfer =
-			new Transfer(ref_cast<Game, EditorGameBase>(egbase()), ware);
+		upcast(Game, game, &egbase());
+		ware.m_transfer = new Transfer(*game, ware);
 		ware.m_transfer->read(fr, m_transfer);
 	}
 }

=== modified file 'src/economy/wares_queue.cc'
--- src/economy/wares_queue.cc	2014-09-20 09:37:47 +0000
+++ src/economy/wares_queue.cc	2014-11-28 17:01:11 +0000
@@ -130,8 +130,8 @@
 #endif
 	 PlayerImmovable & target)
 {
-	WaresQueue & wq =
-		ref_cast<Building, PlayerImmovable>(target).waresqueue(ware);
+	upcast(Building, building, &target);
+	WaresQueue & wq = building->waresqueue(ware);
 
 	assert(!w); // WaresQueue can't hold workers
 	assert(wq.m_filled < wq.m_max_size);

=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc	2014-11-23 14:34:38 +0000
+++ src/editor/editorinteractive.cc	2014-11-28 17:01:11 +0000
@@ -336,12 +336,15 @@
 }
 
 void EditorInteractive::set_sel_radius_and_update_menu(uint32_t const val) {
-	if (tools.current().has_size_one())
+	if (tools.current().has_size_one()) {
 		return;
-	if (UI::UniqueWindow * const w = m_toolsizemenu.window)
-		ref_cast<EditorToolsizeMenu, UI::UniqueWindow>(*w).update(val);
-	else
+	}
+	if (UI::UniqueWindow * const w = m_toolsizemenu.window) {
+		upcast(EditorToolsizeMenu, tool_size_menu, w);
+		tool_size_menu->update(val);
+	} else {
 		set_sel_radius(val);
+	}
 }
 
 

=== modified file 'src/editor/ui_menus/editor_main_menu.cc'
--- src/editor/ui_menus/editor_main_menu.cc	2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_main_menu.cc	2014-11-28 17:01:11 +0000
@@ -37,7 +37,8 @@
 #define vspacing 15
 
 inline EditorInteractive & EditorMainMenu::eia() {
-	return ref_cast<EditorInteractive, UI::Panel>(*get_parent());
+	upcast(EditorInteractive, result, get_parent());
+	return *result;
 }
 
 /**

=== modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc'
--- src/editor/ui_menus/editor_main_menu_load_map.cc	2014-10-28 14:57:52 +0000
+++ src/editor/ui_menus/editor_main_menu_load_map.cc	2014-11-28 17:01:11 +0000
@@ -146,7 +146,8 @@
 		m_mapfiles.clear();
 		fill_list();
 	} else {
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent()).load(filename);
+		upcast(EditorInteractive, eia, get_parent());
+		eia->load(filename);
 		die();
 	}
 }

=== modified file 'src/editor/ui_menus/editor_main_menu_map_options.cc'
--- src/editor/ui_menus/editor_main_menu_map_options.cc	2014-10-28 08:16:53 +0000
+++ src/editor/ui_menus/editor_main_menu_map_options.cc	2014-11-28 17:01:11 +0000
@@ -36,7 +36,8 @@
 
 
 inline EditorInteractive & MainMenuMapOptions::eia() {
-	return ref_cast<EditorInteractive, UI::Panel>(*get_parent());
+	upcast(EditorInteractive, result, get_parent());
+	return *result;
 }
 
 

=== modified file 'src/editor/ui_menus/editor_main_menu_new_map.cc'
--- src/editor/ui_menus/editor_main_menu_new_map.cc	2014-11-13 08:25:45 +0000
+++ src/editor/ui_menus/editor_main_menu_new_map.cc	2014-11-28 17:01:11 +0000
@@ -133,9 +133,8 @@
 }
 
 void MainMenuNewMap::clicked_create_map() {
-	EditorInteractive & eia =
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent());
-	Widelands::EditorGameBase & egbase = eia.egbase();
+	upcast(EditorInteractive, eia, get_parent());
+	Widelands::EditorGameBase & egbase = eia->egbase();
 	Widelands::Map              & map    = egbase.map();
 	UI::ProgressWindow loader;
 
@@ -152,7 +151,7 @@
 
 	map.recalc_whole_map(egbase.world());
 
-	eia.set_need_save(true);
+	eia->set_need_save(true);
 
 	die();
 }

=== modified file 'src/editor/ui_menus/editor_main_menu_random_map.cc'
--- src/editor/ui_menus/editor_main_menu_random_map.cc	2014-11-13 08:25:45 +0000
+++ src/editor/ui_menus/editor_main_menu_random_map.cc	2014-11-28 17:01:11 +0000
@@ -483,9 +483,8 @@
 }
 
 void MainMenuNewRandomMap::clicked_create_map() {
-	EditorInteractive & eia =
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent());
-	Widelands::EditorGameBase & egbase = eia.egbase();
+	upcast(EditorInteractive, eia, get_parent());
+	Widelands::EditorGameBase & egbase = eia->egbase();
 	Widelands::Map              & map    = egbase.map();
 	UI::ProgressWindow loader;
 
@@ -518,8 +517,8 @@
 
 	map.recalc_whole_map(egbase.world());
 
-	eia.set_need_save(true);
-	eia.register_overlays();
+	eia->set_need_save(true);
+	eia->register_overlays();
 
 	die();
 }

=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
--- src/editor/ui_menus/editor_main_menu_save_map.cc	2014-10-28 14:57:52 +0000
+++ src/editor/ui_menus/editor_main_menu_save_map.cc	2014-11-28 17:01:11 +0000
@@ -46,7 +46,8 @@
 #include "ui_basic/textarea.h"
 
 inline EditorInteractive & MainMenuSaveMap::eia() {
-	return ref_cast<EditorInteractive, UI::Panel>(*get_parent());
+	upcast(EditorInteractive, result, get_parent());
+	return *result;
 }
 
 

=== modified file 'src/editor/ui_menus/editor_player_menu.cc'
--- src/editor/ui_menus/editor_player_menu.cc	2014-11-22 10:18:20 +0000
+++ src/editor/ui_menus/editor_player_menu.cc	2014-11-28 17:01:11 +0000
@@ -38,6 +38,11 @@
 
 #define UNDEFINED_TRIBE_NAME "<undefined>"
 
+inline EditorInteractive & EditorPlayerMenu::eia() {
+	upcast(EditorInteractive, result, get_parent());
+	return *result;
+}
+
 EditorPlayerMenu::EditorPlayerMenu
 	(EditorInteractive & parent, UI::UniqueWindow::Registry & registry)
 	:
@@ -108,9 +113,7 @@
 	if (is_minimal())
 		return;
 
-	Widelands::Map & map =
-		ref_cast<EditorInteractive const, UI::Panel const>(*get_parent())
-		.egbase().map();
+	Widelands::Map & map = eia().egbase().map();
 	Widelands::PlayerNumber const nr_players = map.get_nrplayers();
 	{
 		assert(nr_players <= 99); //  2 decimal digits
@@ -194,9 +197,7 @@
 }
 
 void EditorPlayerMenu::clicked_add_player() {
-	EditorInteractive & menu =
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent());
-	Widelands::Map & map = menu.egbase().map();
+	Widelands::Map & map = eia().egbase().map();
 	Widelands::PlayerNumber const nr_players = map.get_nrplayers() + 1;
 	assert(nr_players <= MAX_PLAYERS);
 	map.set_nrplayers(nr_players);
@@ -211,7 +212,7 @@
 		map.set_scenario_player_name(nr_players, name);
 	}
 	map.set_scenario_player_tribe(nr_players, m_tribes[0]);
-	menu.set_need_save(true);
+	eia().set_need_save(true);
 	m_add_player        .set_enabled(nr_players < MAX_PLAYERS);
 	m_remove_last_player.set_enabled(true);
 	update();
@@ -219,14 +220,12 @@
 
 
 void EditorPlayerMenu::clicked_remove_last_player() {
-	EditorInteractive & menu =
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent());
-	Widelands::Map & map = menu.egbase().map();
+	Widelands::Map & map = eia().egbase().map();
 	Widelands::PlayerNumber const old_nr_players = map.get_nrplayers();
 	Widelands::PlayerNumber const nr_players     = old_nr_players - 1;
 	assert(1 <= nr_players);
 
-	if (!menu.is_player_tribe_referenced(old_nr_players)) {
+	if (!eia().is_player_tribe_referenced(old_nr_players)) {
 		if (const Widelands::Coords sp = map.get_starting_pos(old_nr_players)) {
 			//  Remove starting position marker.
 			char picsname[] = "pics/editor_player_00_starting_pos.png";
@@ -306,9 +305,8 @@
  * Player Tribe Button clicked
  */
 void EditorPlayerMenu::player_tribe_clicked(uint8_t n) {
-	EditorInteractive & menu =
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent());
-	if (!menu.is_player_tribe_referenced(n + 1)) {
+	EditorInteractive& menu = eia();
+		if (!menu.is_player_tribe_referenced(n + 1)) {
 		std::string t = m_plr_set_tribes_buts[n]->get_title();
 		if (!Widelands::TribeDescr::exists_tribe(t))
 			throw wexception
@@ -338,8 +336,7 @@
  * Set Current Start Position button selected
  */
 void EditorPlayerMenu::set_starting_pos_clicked(uint8_t n) {
-	EditorInteractive & menu =
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent());
+	EditorInteractive& menu = eia();
 	//  jump to the current node
 	Widelands::Map & map = menu.egbase().map();
 	if (Widelands::Coords const sp = map.get_starting_pos(n))
@@ -366,8 +363,7 @@
 void EditorPlayerMenu::name_changed(int32_t m) {
 	//  Player name has been changed.
 	std::string text = m_plr_names[m]->text();
-	EditorInteractive & menu =
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent());
+	EditorInteractive& menu = eia();
 	Widelands::Map & map = menu.egbase().map();
 	if (text == "") {
 		text = map.get_scenario_player_name(m + 1);

=== modified file 'src/editor/ui_menus/editor_player_menu.h'
--- src/editor/ui_menus/editor_player_menu.h	2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_player_menu.h	2014-11-28 17:01:11 +0000
@@ -44,6 +44,7 @@
 	virtual ~EditorPlayerMenu() {}
 
 private:
+	EditorInteractive & eia();
 	UI::UniqueWindow::Registry m_allow_buildings_menu;
 	UI::Textarea * m_nr_of_players_ta;
 	UI::EditBox * m_plr_names[MAX_PLAYERS];

=== modified file 'src/editor/ui_menus/editor_tool_change_resources_options_menu.cc'
--- src/editor/ui_menus/editor_tool_change_resources_options_menu.cc	2014-09-30 05:41:55 +0000
+++ src/editor/ui_menus/editor_tool_change_resources_options_menu.cc	2014-11-28 17:01:11 +0000
@@ -37,6 +37,12 @@
 const static int BUTTON_WIDTH = 20;
 const static int BUTTON_HEIGHT = 20;
 
+inline EditorInteractive & EditorToolChangeResourcesOptionsMenu::eia() {
+	upcast(EditorInteractive, result, get_parent());
+	return *result;
+}
+
+
 EditorToolChangeResourcesOptionsMenu::
 EditorToolChangeResourcesOptionsMenu
 		(EditorInteractive             & parent,
@@ -213,7 +219,7 @@
 	m_increase_tool.set_cur_res(n);
 	m_increase_tool.decrease_tool().set_cur_res(n);
 
-	Widelands::EditorGameBase& egbase = ref_cast<EditorInteractive, UI::Panel>(*get_parent()).egbase();
+	Widelands::EditorGameBase& egbase = eia().egbase();
 	Widelands::Map & map = egbase.map();
 	map.overlay_manager().register_overlay_callback_function(
 	   boost::bind(&editor_change_resource_tool_callback, _1, boost::ref(map), boost::ref(egbase.world()), n));
@@ -234,8 +240,7 @@
 										static_cast<unsigned int>(m_increase_tool.set_tool().get_set_to())));
 
 	m_cur_selection.set_text
-		(ref_cast<EditorInteractive, UI::Panel>(*get_parent()).egbase()
-		 .world().get_resource(m_increase_tool.set_tool().get_cur_res())->descname());
+		(eia().egbase().world().get_resource(m_increase_tool.set_tool().get_cur_res())->descname());
 	m_cur_selection.set_pos
 		(Point
 		 	((get_inner_w() - m_cur_selection.get_w()) / 2, get_inner_h() - 20));

=== modified file 'src/editor/ui_menus/editor_tool_change_resources_options_menu.h'
--- src/editor/ui_menus/editor_tool_change_resources_options_menu.h	2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_tool_change_resources_options_menu.h	2014-11-28 17:01:11 +0000
@@ -37,6 +37,7 @@
 		 UI::UniqueWindow::Registry     &);
 
 private:
+	EditorInteractive & eia();
 	void selected();
 	enum Button {
 		Change_By_Increase, Change_By_Decrease,

=== modified file 'src/editor/ui_menus/editor_tool_menu.cc'
--- src/editor/ui_menus/editor_tool_menu.cc	2014-09-20 09:37:47 +0000
+++ src/editor/ui_menus/editor_tool_menu.cc	2014-11-28 17:01:11 +0000
@@ -98,38 +98,37 @@
 void EditorToolMenu::changed_to() {
 	const int32_t n = m_radioselect.get_state();
 
-	EditorInteractive & parent =
-		ref_cast<EditorInteractive, UI::Panel>(*get_parent());
+	upcast(EditorInteractive, eia, get_parent());
 
 	EditorTool                * current_tool_pointer = nullptr;
 	UI::UniqueWindow::Registry * current_registry_pointer = nullptr;
 	switch (n) {
 	case 0:
-		current_tool_pointer     = &parent.tools.increase_height;
-		current_registry_pointer = &parent.m_heightmenu;
+		current_tool_pointer     = &eia->tools.increase_height;
+		current_registry_pointer = &eia->m_heightmenu;
 		break;
 	case 1:
-		current_tool_pointer     = &parent.tools.noise_height;
-		current_registry_pointer = &parent.m_noise_heightmenu;
+		current_tool_pointer     = &eia->tools.noise_height;
+		current_registry_pointer = &eia->m_noise_heightmenu;
 		break;
 	case 2:
-		current_tool_pointer     = &parent.tools.set_terrain;
-		current_registry_pointer = &parent.m_terrainmenu;
+		current_tool_pointer     = &eia->tools.set_terrain;
+		current_registry_pointer = &eia->m_terrainmenu;
 		break;
 	case 3:
-		current_tool_pointer     = &parent.tools.place_immovable;
-		current_registry_pointer = &parent.m_immovablemenu;
+		current_tool_pointer     = &eia->tools.place_immovable;
+		current_registry_pointer = &eia->m_immovablemenu;
 		break;
 	case 4:
-		current_tool_pointer     = &parent.tools.place_bob;
-		current_registry_pointer = &parent.m_bobmenu;
+		current_tool_pointer     = &eia->tools.place_bob;
+		current_registry_pointer = &eia->m_bobmenu;
 		break;
 	case 5:
-		current_tool_pointer     = &parent.tools.increase_resources;
-		current_registry_pointer = &parent.m_resourcesmenu;
+		current_tool_pointer     = &eia->tools.increase_resources;
+		current_registry_pointer = &eia->m_resourcesmenu;
 		break;
 	case 6:
-		current_tool_pointer     = &parent.tools.set_port_space;
+		current_tool_pointer     = &eia->tools.set_port_space;
 		current_registry_pointer = nullptr; // no need for a window
 		break;
 	default:
@@ -137,13 +136,13 @@
 		break;
 	}
 
-	parent.select_tool(*current_tool_pointer, EditorTool::First);
-	if (current_tool_pointer == &parent.tools.set_port_space) {
+	eia->select_tool(*current_tool_pointer, EditorTool::First);
+	if (current_tool_pointer == &eia->tools.set_port_space) {
 		// Set correct overlay
-		Widelands::Map & map = parent.egbase().map();
+		Widelands::Map & map = eia->egbase().map();
 		map.overlay_manager().register_overlay_callback_function(
 				boost::bind(&editor_Tool_set_port_space_callback, _1, boost::ref(map)));
-		map.recalc_whole_map(parent.egbase().world());
+		map.recalc_whole_map(eia->egbase().world());
 		update();
 	}
 
@@ -158,38 +157,38 @@
 			switch (n) { //  create window
 			case 0:
 				new EditorToolChangeHeightOptionsMenu
-					(parent,
-					parent.tools.increase_height,
+					(*eia,
+					eia->tools.increase_height,
 					*current_registry_pointer);
 				break;
 			case 1:
 				new EditorToolNoiseHeightOptionsMenu
-					(parent,
-					parent.tools.noise_height,
+					(*eia,
+					eia->tools.noise_height,
 					*current_registry_pointer);
 				break;
 			case 2:
 				new EditorToolSetTerrainOptionsMenu
-					(parent,
-					parent.tools.set_terrain,
+					(*eia,
+					eia->tools.set_terrain,
 					*current_registry_pointer);
 				break;
 			case 3:
 				new EditorToolPlaceImmovableOptionsMenu
-					(parent,
-					parent.tools.place_immovable,
+					(*eia,
+					eia->tools.place_immovable,
 					*current_registry_pointer);
 				break;
 			case 4:
 				new EditorToolPlaceBobOptionsMenu
-					(parent,
-					parent.tools.place_bob,
+					(*eia,
+					eia->tools.place_bob,
 					*current_registry_pointer);
 				break;
 			case 5:
 				new EditorToolChangeResourcesOptionsMenu
-					(parent,
-					parent.tools.increase_resources,
+					(*eia,
+					eia->tools.increase_resources,
 					*current_registry_pointer);
 				break;
 			default:

=== modified file 'src/editor/ui_menus/editor_tool_options_menu.cc'
--- src/editor/ui_menus/editor_tool_options_menu.cc	2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_tool_options_menu.cc	2014-11-28 17:01:11 +0000
@@ -35,6 +35,6 @@
 
 
 void EditorToolOptionsMenu::select_correct_tool() {
-	ref_cast<EditorInteractive, UI::Panel>(*get_parent())
-		.select_tool(*m_current_pointer, EditorTool::First);
+	upcast(EditorInteractive, eia, get_parent());
+	eia->select_tool(*m_current_pointer, EditorTool::First);
 }

=== modified file 'src/editor/ui_menus/editor_toolsize_menu.cc'
--- src/editor/ui_menus/editor_toolsize_menu.cc	2014-09-18 18:52:34 +0000
+++ src/editor/ui_menus/editor_toolsize_menu.cc	2014-11-28 17:01:11 +0000
@@ -29,10 +29,10 @@
 #include "graphic/graphic.h"
 
 inline EditorInteractive & EditorToolsizeMenu::eia() {
-	return ref_cast<EditorInteractive, UI::Panel>(*get_parent());
+	upcast(EditorInteractive, result, get_parent());
+	return *result;
 }
 
-
 /**
  * Create all the buttons etc...
 */

=== modified file 'src/graphic/CMakeLists.txt'
--- src/graphic/CMakeLists.txt	2014-11-24 07:25:21 +0000
+++ src/graphic/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -128,7 +128,6 @@
   USES_SDL2_IMAGE
   USES_SDL2_TTF
   DEPENDS
-    base_deprecated
     base_exceptions
     base_geometry
     base_i18n

=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc	2014-11-24 07:10:03 +0000
+++ src/graphic/animation.cc	2014-11-28 17:01:11 +0000
@@ -30,7 +30,6 @@
 #include <boost/format.hpp>
 #include <boost/lexical_cast.hpp>
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
 #include "base/log.h"
 #include "base/macros.h"

=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc	2014-11-24 07:10:03 +0000
+++ src/graphic/graphic.cc	2014-11-28 17:01:11 +0000
@@ -25,7 +25,6 @@
 
 #include <SDL_image.h>
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
 #include "base/log.h"
 #include "base/macros.h"

=== modified file 'src/graphic/terrain_texture.cc'
--- src/graphic/terrain_texture.cc	2014-11-24 07:10:03 +0000
+++ src/graphic/terrain_texture.cc	2014-11-28 17:01:11 +0000
@@ -21,7 +21,6 @@
 
 #include <SDL_image.h>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "base/wexception.h"
 #include "graphic/image_io.h"

=== modified file 'src/graphic/text_parser.cc'
--- src/graphic/text_parser.cc	2014-09-10 14:48:40 +0000
+++ src/graphic/text_parser.cc	2014-11-28 17:01:11 +0000
@@ -24,7 +24,6 @@
 #include <string>
 #include <vector>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "helper.h"
 

=== modified file 'src/io/CMakeLists.txt'
--- src/io/CMakeLists.txt	2014-10-13 15:04:50 +0000
+++ src/io/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -37,7 +37,6 @@
     filesystem/zip_filesystem.cc
     filesystem/zip_filesystem.h
   DEPENDS
-    base_deprecated
     base_exceptions
     base_log
     base_macros

=== modified file 'src/io/filesystem/layered_filesystem.cc'
--- src/io/filesystem/layered_filesystem.cc	2014-09-29 13:30:46 +0000
+++ src/io/filesystem/layered_filesystem.cc	2014-11-28 17:01:11 +0000
@@ -22,7 +22,6 @@
 #include <cstdio>
 #include <memory>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "base/wexception.h"
 #include "io/fileread.h"

=== modified file 'src/logic/CMakeLists.txt'
--- src/logic/CMakeLists.txt	2014-10-13 15:04:50 +0000
+++ src/logic/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -215,7 +215,6 @@
   USES_SDL2
   DEPENDS
     ai
-    base_deprecated
     base_exceptions
     base_geometry
     base_i18n

=== modified file 'src/logic/battle.cc'
--- src/logic/battle.cc	2014-09-20 09:37:47 +0000
+++ src/logic/battle.cc	2014-11-28 17:01:11 +0000
@@ -83,23 +83,29 @@
 
 	m_creationtime = egbase.get_gametime();
 
-	if (Battle* battle = m_first ->get_battle())
-		battle->cancel(ref_cast<Game, EditorGameBase>(egbase), *m_first);
-	m_first->set_battle(ref_cast<Game, EditorGameBase>(egbase), this);
-	if (Battle* battle = m_second->get_battle())
-		battle->cancel(ref_cast<Game, EditorGameBase>(egbase), *m_second);
-	m_second->set_battle(ref_cast<Game, EditorGameBase>(egbase), this);
+	upcast(Game, game, &egbase);
+
+	if (Battle* battle = m_first ->get_battle()) {
+		battle->cancel(*game, *m_first);
+	}
+	m_first->set_battle(*game, this);
+	if (Battle* battle = m_second->get_battle()) {
+		battle->cancel(*game, *m_second);
+	}
+	m_second->set_battle(*game, this);
 }
 
 
 void Battle::cleanup (EditorGameBase & egbase)
 {
 	if (m_first) {
-		m_first ->set_battle(ref_cast<Game, EditorGameBase>(egbase), nullptr);
+		upcast(Game, game, &egbase);
+		m_first ->set_battle(*game, nullptr);
 		m_first  = nullptr;
 	}
 	if (m_second) {
-		m_second->set_battle(ref_cast<Game, EditorGameBase>(egbase), nullptr);
+		upcast(Game, game, &egbase);
+		m_second->set_battle(*game, nullptr);
 		m_second = nullptr;
 	}
 

=== modified file 'src/logic/bob.cc'
--- src/logic/bob.cc	2014-09-20 09:37:47 +0000
+++ src/logic/bob.cc	2014-11-28 17:01:11 +0000
@@ -149,8 +149,10 @@
  */
 void Bob::cleanup(EditorGameBase & egbase)
 {
-	while (!m_stack.empty()) //  bobs in the editor do not have tasks
-		do_pop_task(ref_cast<Game, EditorGameBase>(egbase));
+	while (!m_stack.empty()) { //  bobs in the editor do not have tasks
+		upcast(Game, game, &egbase);
+		do_pop_task(*game);
+	}
 
 	set_owner(nullptr); // implicitly remove ourselves from owner's map
 

=== modified file 'src/logic/building.cc'
--- src/logic/building.cc	2014-11-24 07:25:21 +0000
+++ src/logic/building.cc	2014-11-28 17:01:11 +0000
@@ -244,11 +244,11 @@
 	BuildingDescr const * const descr =
 		m_tribe.get_building_descr
 			(m_tribe.safe_building_index("constructionsite"));
-	ConstructionSite & csite =
-		ref_cast<ConstructionSite, MapObject>(descr->create_object());
-	csite.set_building(*this);
-
-	return csite;
+
+	upcast(ConstructionSite, csite, &descr->create_object());
+	csite->set_building(*this);
+
+	return *csite;
 }
 
 
@@ -724,25 +724,24 @@
 void Building::draw_help
 	(const EditorGameBase& game, RenderTarget& dst, const FCoords&, const Point& pos)
 {
-	const InteractiveGameBase & igbase =
-		ref_cast<InteractiveGameBase const, InteractiveBase const>
-			(*game.get_ibase());
-	uint32_t const dpyflags = igbase.get_display_flags();
+	upcast(InteractiveGameBase const, igbase, game.get_ibase());
+
+	uint32_t const dpyflags = igbase->get_display_flags();
 
 	if (dpyflags & InteractiveBase::dfShowCensus) {
-		const std::string info = info_string(igbase.building_census_format());
+		const std::string info = info_string(igbase->building_census_format());
 		if (!info.empty()) {
 			dst.blit(pos - Point(0, 48), UI::g_fh1->render(info), BlendMode::UseAlpha, UI::Align_Center);
 		}
 	}
 
 	if (dpyflags & InteractiveBase::dfShowStatistics) {
-		if (upcast(InteractivePlayer const, iplayer, &igbase))
+		if (upcast(InteractivePlayer const, iplayer, igbase))
 			if
 				(!iplayer->player().see_all() &&
 				 iplayer->player().is_hostile(*get_owner()))
 				return;
-		const std::string info = info_string(igbase.building_statistics_format());
+		const std::string info = info_string(igbase->building_statistics_format());
 		if (!info.empty()) {
 			dst.blit(pos - Point(0, 35), UI::g_fh1->render(info), BlendMode::UseAlpha, UI::Align_Center);
 		}

=== modified file 'src/logic/carrier.cc'
--- src/logic/carrier.cc	2014-09-20 09:37:47 +0000
+++ src/logic/carrier.cc	2014-11-28 17:01:11 +0000
@@ -84,8 +84,6 @@
 		return pop_task(game);
 	}
 
-	Road & road = ref_cast<Road, PlayerImmovable>(*get_location(game));
-
 	// Check for pending wares
 	if (m_promised_pickup_to == NOONE)
 		find_pending_ware(game);
@@ -103,12 +101,13 @@
 		}
 	}
 
+	upcast(Road, road, get_location(game));
+
 	// Move into idle position if necessary
-	if
-		(start_task_movepath
+	if (start_task_movepath
 		 	(game,
-		 	 road.get_path(),
-		 	 road.get_idle_index(),
+			 road->get_path(),
+			 road->get_idle_index(),
 		 	 descr().get_right_walk_anims(does_carry_ware())))
 		return;
 
@@ -127,9 +126,9 @@
 void Carrier::road_pop(Game & game, State & /* state */)
 {
 	if (m_promised_pickup_to != NOONE && get_location(game)) {
-		Road & road      = ref_cast<Road, PlayerImmovable>(*get_location(game));
-		Flag & flag      = road.get_flag(static_cast<Road::FlagId>(m_promised_pickup_to));
-		Flag & otherflag = road.get_flag(static_cast<Road::FlagId>(m_promised_pickup_to ^ 1));
+		upcast(Road, road, get_location(game));
+		Flag & flag      = road->get_flag(static_cast<Road::FlagId>(m_promised_pickup_to));
+		Flag & otherflag = road->get_flag(static_cast<Road::FlagId>(m_promised_pickup_to ^ 1));
 
 		flag.cancel_pickup(game, otherflag);
 	}
@@ -176,8 +175,6 @@
 		return pop_task(game);
 	}
 
-	Road & road = ref_cast<Road, PlayerImmovable>(*get_location(game));
-
 	if (state.ivar1 == -1)
 		// If we're "in" the target building, special code applies
 		deliver_to_building(game, state);
@@ -187,9 +184,10 @@
 		pickup_from_flag(game, state);
 
 	else {
+		upcast(Road, road, get_location(game));
 		// If the ware should go to the building attached to our flag, walk
 		// directly into said building
-		Flag & flag = road.get_flag(static_cast<Road::FlagId>(state.ivar1 ^ 1));
+		Flag & flag = road->get_flag(static_cast<Road::FlagId>(state.ivar1 ^ 1));
 
 		WareInstance & ware = *get_carried_ware(game);
 		assert(ware.get_location(game) == this);
@@ -240,10 +238,11 @@
 				molog
 					("[Carrier]: Building switch from under us, return to road.\n");
 
+				upcast(Road, road, get_location(game));
 				state.ivar1 =
 					&building->base_flag()
 					==
-					&ref_cast<Road, PlayerImmovable>(*get_location(game)).get_flag
+					&road->get_flag
 						(static_cast<Road::FlagId>(0));
 				break;
 			}
@@ -277,9 +276,9 @@
 
 		m_promised_pickup_to = NOONE;
 
-		Road & road      = ref_cast<Road, PlayerImmovable>(*get_location(game));
-		Flag & flag      = road.get_flag(static_cast<Road::FlagId>(ivar1));
-		Flag & otherflag = road.get_flag(static_cast<Road::FlagId>(ivar1 ^ 1));
+		upcast(Road, road, get_location(game));
+		Flag & flag      = road->get_flag(static_cast<Road::FlagId>(ivar1));
+		Flag & otherflag = road->get_flag(static_cast<Road::FlagId>(ivar1 ^ 1));
 
 		// Are there wares to move between our flags?
 		if (WareInstance * const ware = flag.fetch_pending_ware(game, otherflag))
@@ -305,15 +304,15 @@
 void Carrier::drop_ware(Game & game, State & state)
 {
 	WareInstance * other = nullptr;
-	Road & road = ref_cast<Road, PlayerImmovable>(*get_location(game));
-	Flag & flag = road.get_flag(static_cast<Road::FlagId>(state.ivar1 ^ 1));
+	upcast(Road, road, get_location(game));
+	Flag & flag = road->get_flag(static_cast<Road::FlagId>(state.ivar1 ^ 1));
 
 	if (m_promised_pickup_to == (state.ivar1 ^ 1)) {
 		// If there's an ware we acked, we can drop ours even if the flag is
 		// flooded
 		other =
 			flag.fetch_pending_ware
-				(game, road.get_flag(static_cast<Road::FlagId>(state.ivar1)));
+				(game, road->get_flag(static_cast<Road::FlagId>(state.ivar1)));
 
 		if (!other && !flag.has_capacity()) {
 			molog
@@ -376,11 +375,11 @@
 bool Carrier::swap_or_wait(Game & game, State & state)
 {
 	// Road that employs us
-	Road & road = ref_cast<Road, PlayerImmovable>(*get_location(game));
+	upcast(Road, road, get_location(game));
 	// Flag we are delivering to
-	Flag & flag = road.get_flag(static_cast<Road::FlagId>(state.ivar1 ^ 1));
+	Flag & flag = road->get_flag(static_cast<Road::FlagId>(state.ivar1 ^ 1));
 	// The other flag of our road
-	Flag & otherflag = road.get_flag(static_cast<Road::FlagId>(state.ivar1));
+	Flag & otherflag = road->get_flag(static_cast<Road::FlagId>(state.ivar1));
 
 
 	if (m_promised_pickup_to == (state.ivar1 ^ 1)) {
@@ -456,32 +455,33 @@
  */
 void Carrier::find_pending_ware(Game & game)
 {
-	Road & road = ref_cast<Road, PlayerImmovable>(*get_location(game));
+	upcast(Road, road, get_location(game));
 	uint32_t havewarebits = 0;
 
 	assert(m_promised_pickup_to == NOONE);
 
-	if
-		(road.get_flag(Road::FlagStart).has_pending_ware
-		 	(game, road.get_flag(Road::FlagEnd)))
+	if (road->get_flag(Road::FlagStart).has_pending_ware
+			(game, road->get_flag(Road::FlagEnd))) {
 		havewarebits |= 1;
+	}
 
-	if
-		(road.get_flag(Road::FlagEnd).has_pending_ware
-		 	(game, road.get_flag(Road::FlagStart)))
+	if (road->get_flag(Road::FlagEnd).has_pending_ware
+			(game, road->get_flag(Road::FlagStart))) {
 		havewarebits |= 2;
+	}
 
 	//  If both flags have an ware, we pick the one closer to us.
-	if (havewarebits == 3)
+	if (havewarebits == 3) {
 		havewarebits = 1 << find_closest_flag(game);
+	}
 
 	// Ack our decision
 	if (havewarebits == 1) {
 		m_promised_pickup_to = START_FLAG;
 		if
 			(!
-			 road.get_flag(Road::FlagStart).ack_pickup
-			 	(game, road.get_flag(Road::FlagEnd)))
+			 road->get_flag(Road::FlagStart).ack_pickup
+				(game, road->get_flag(Road::FlagEnd)))
 			throw wexception
 				("Carrier::find_pending_ware: start flag is messed up");
 
@@ -489,8 +489,8 @@
 		m_promised_pickup_to = END_FLAG;
 		if
 			(!
-			 road.get_flag(Road::FlagEnd).ack_pickup
-			 	(game, road.get_flag(Road::FlagStart)))
+			 road->get_flag(Road::FlagEnd).ack_pickup
+				(game, road->get_flag(Road::FlagStart)))
 			throw wexception("Carrier::find_pending_ware: end flag is messed up");
 	}
 }
@@ -502,8 +502,8 @@
 int32_t Carrier::find_closest_flag(Game & game)
 {
 	Map & map = game.map();
-	CoordPath startpath
-		(map, ref_cast<Road, PlayerImmovable>(*get_location(game)).get_path());
+	upcast(Road, road, get_location(game));
+	CoordPath startpath(map, road->get_path());
 
 	CoordPath endpath;
 	int32_t startcost, endcost;
@@ -550,8 +550,8 @@
 bool Carrier::start_task_walktoflag
 	(Game & game, int32_t const flag, bool const offset)
 {
-	const Path & path =
-		ref_cast<Road, PlayerImmovable>(*get_location(game)).get_path();
+	upcast(Road, road, get_location(game));
+	const Path & path = road->get_path();
 	int32_t idx;
 
 	if (!flag) {

=== modified file 'src/logic/constructionsite.cc'
--- src/logic/constructionsite.cc	2014-09-10 17:52:49 +0000
+++ src/logic/constructionsite.cc	2014-11-28 17:01:11 +0000
@@ -172,16 +172,16 @@
 		Building & b =
 			m_building->create(egbase, owner(), m_position, false, false, m_old_buildings);
 		if (Worker * const builder = m_builder.get(egbase)) {
-			builder->reset_tasks(ref_cast<Game, EditorGameBase>(egbase));
+			upcast(Game, game, &egbase);
+			builder->reset_tasks(*game);
 			builder->set_location(&b);
 		}
 		// Open the new building window if needed
 		if (m_optionswindow) {
 			Point window_position = m_optionswindow->get_pos();
 			hide_options();
-			InteractiveGameBase & igbase =
-				ref_cast<InteractiveGameBase, InteractiveBase>(*egbase.get_ibase());
-			b.show_options(igbase, false, window_position);
+			upcast(InteractiveGameBase, igbase, egbase.get_ibase());
+			b.show_options(*igbase, false, window_position);
 		}
 	}
 }

=== modified file 'src/logic/critter.cc'
--- src/logic/critter.cc	2014-10-27 10:14:10 +0000
+++ src/logic/critter.cc	2014-11-28 17:01:11 +0000
@@ -301,14 +301,12 @@
 	}
 
 	for (;;) {
-		const CritterProgram & program =
-			ref_cast<CritterProgram const, BobProgramBase const>
-				(*state.program);
+		upcast(CritterProgram const, program, state.program);
 
-		if (state.ivar1 >= program.get_size())
+		if (state.ivar1 >= program->get_size())
 			return pop_task(game);
 
-		const CritterAction & action = program[state.ivar1];
+		const CritterAction & action = (*program)[state.ivar1];
 
 		if ((this->*(action.function))(game, state, action))
 			return;

=== modified file 'src/logic/findnode.cc'
--- src/logic/findnode.cc	2014-07-24 16:26:55 +0000
+++ src/logic/findnode.cc	2014-11-28 17:01:11 +0000
@@ -19,7 +19,6 @@
 
 #include "logic/findnode.h"
 
-#include "base/deprecated.h"
 #include "base/wexception.h"
 #include "logic/field.h"
 #include "logic/immovable.h"

=== modified file 'src/logic/immovable.cc'
--- src/logic/immovable.cc	2014-11-24 07:25:21 +0000
+++ src/logic/immovable.cc	2014-11-28 17:01:11 +0000
@@ -25,7 +25,6 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/format.hpp>
 
-#include "base/deprecated.h"
 #include "base/macros.h"
 #include "base/wexception.h"
 #include "config.h"
@@ -619,7 +618,7 @@
 {
 	BaseImmovable::Loader::load(fr);
 
-	Immovable & imm = ref_cast<Immovable, MapObject>(*get_object());
+	upcast(Immovable, imm, get_object());
 
 	if (version >= 5) {
 		PlayerNumber pn = fr.unsigned_8();
@@ -627,29 +626,29 @@
 			Player * plr = egbase().get_player(pn);
 			if (!plr)
 				throw GameDataError("Immovable::load: player %u does not exist", pn);
-			imm.set_owner(plr);
+			imm->set_owner(plr);
 		}
 	}
 
 	// Position
-	imm.m_position = read_coords_32(&fr, egbase().map().extent());
-	imm.set_position(egbase(), imm.m_position);
+	imm->m_position = read_coords_32(&fr, egbase().map().extent());
+	imm->set_position(egbase(), imm->m_position);
 
 	// Animation
 	char const * const animname = fr.c_string();
 	try {
-		imm.m_anim = imm.descr().get_animation(animname);
+		imm->m_anim = imm->descr().get_animation(animname);
 	} catch (const MapObjectDescr::AnimationNonexistent &) {
-		imm.m_anim = imm.descr().main_animation();
+		imm->m_anim = imm->descr().main_animation();
 		log
 			("Warning: (%s) Animation \"%s\" not found, using animation %s).\n",
-			 imm.descr().name().c_str(), animname, imm.descr().get_animation_name(imm.m_anim).c_str());
+			 imm->descr().name().c_str(), animname, imm->descr().get_animation_name(imm->m_anim).c_str());
 	}
-	imm.m_animstart = fr.signed_32();
+	imm->m_animstart = fr.signed_32();
 	if (version >= 4) {
-		imm.m_anim_construction_total = fr.unsigned_32();
-		if (imm.m_anim_construction_total)
-			imm.m_anim_construction_done = fr.unsigned_32();
+		imm->m_anim_construction_total = fr.unsigned_32();
+		if (imm->m_anim_construction_total)
+			imm->m_anim_construction_done = fr.unsigned_32();
 	}
 
 	{ //  program
@@ -664,14 +663,14 @@
 			if (program_name.empty())
 				program_name = "program";
 		}
-		imm.m_program = imm.descr().get_program(program_name);
+		imm->m_program = imm->descr().get_program(program_name);
 	}
-	imm.m_program_ptr = fr.unsigned_32();
+	imm->m_program_ptr = fr.unsigned_32();
 
-	if (!imm.m_program) {
-		imm.m_program_ptr = 0;
+	if (!imm->m_program) {
+		imm->m_program_ptr = 0;
 	} else {
-		if (imm.m_program_ptr >= imm.m_program->size()) {
+		if (imm->m_program_ptr >= imm->m_program->size()) {
 			// Try to not fail if the program of some immovable has changed
 			// significantly.
 			// Note that in some cases, the immovable may end up broken despite
@@ -679,20 +678,20 @@
 			log
 				("Warning: Immovable '%s', size of program '%s' seems to have "
 				 "changed.\n",
-				 imm.descr().name().c_str(), imm.m_program->name().c_str());
-			imm.m_program_ptr = 0;
+				 imm->descr().name().c_str(), imm->m_program->name().c_str());
+			imm->m_program_ptr = 0;
 		}
 	}
 
-	imm.m_program_step = fr.signed_32();
+	imm->m_program_step = fr.signed_32();
 
 	if (version >= 3)
-		imm.m_reserved_by_worker = fr.unsigned_8();
+		imm->m_reserved_by_worker = fr.unsigned_8();
 
 	if (version >= 4) {
 		std::string dataname = fr.c_string();
 		if (!dataname.empty()) {
-			imm.set_action_data(ImmovableActionData::load(fr, imm, dataname));
+			imm->set_action_data(ImmovableActionData::load(fr, *imm, dataname));
 		}
 	}
 }

=== modified file 'src/logic/instances.cc'
--- src/logic/instances.cc	2014-09-20 09:37:47 +0000
+++ src/logic/instances.cc	2014-11-28 17:01:11 +0000
@@ -24,7 +24,6 @@
 #include <cstring>
 #include <string>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "base/wexception.h"
 #include "io/fileread.h"

=== modified file 'src/logic/instances.h'
--- src/logic/instances.h	2014-09-19 12:54:54 +0000
+++ src/logic/instances.h	2014-11-28 17:01:11 +0000
@@ -30,7 +30,6 @@
 #include <boost/unordered_map.hpp>
 #include <boost/signals2.hpp>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "base/macros.h"
 #include "logic/cmd_queue.h"
@@ -181,9 +180,10 @@
 
 /// If you find a better way to do this that doesn't cost a virtual function
 /// or additional member variable, go ahead
-#define MO_DESCR(type) \
-public: const type & descr() const { \
-		return ref_cast<type const, MapObjectDescr const>(*m_descr);          \
+#define MO_DESCR(type)                     \
+public: const type & descr() const {       \
+		upcast(type const, result, m_descr); \
+		return *result;                      \
    }                                                                          \
 
 class MapObject {
@@ -311,7 +311,8 @@
 		MapObjectLoader & mol   () {return *m_mol;}
 		MapObject            * get_object() {return m_object;}
 		template<typename T> T & get() {
-			return ref_cast<T, MapObject>(*m_object);
+			upcast(T, result, m_object);
+			return *result;
 		}
 
 	protected:

=== modified file 'src/logic/militarysite.cc'
--- src/logic/militarysite.cc	2014-09-30 05:41:55 +0000
+++ src/logic/militarysite.cc	2014-11-28 17:01:11 +0000
@@ -335,9 +335,9 @@
 		// Now I know that the new guy is worthy.
 		if (nullptr != kickoutCandidate)
 		{
-			Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
-			kickoutCandidate->reset_tasks(game);
-			kickoutCandidate->start_task_leavebuilding(game, true);
+			upcast(Game, game, &owner().egbase());
+			kickoutCandidate->reset_tasks(*game);
+			kickoutCandidate->start_task_leavebuilding(*game, true);
 			return true;
 		}
 	}
@@ -355,10 +355,10 @@
 	// Call to drop_least routine has side effects: it tries to drop a soldier. Order is important!
 	if (stationed_soldiers().size() < m_capacity || drop_least_suited_soldier(true, &s))
 	{
-		Game & game = ref_cast<Game, EditorGameBase>(egbase);
+		upcast(Game, game, &egbase);
 		s.set_location(this);
-		s.reset_tasks(game);
-		s.start_task_buildingwork(game);
+		s.reset_tasks(*game);
+		s.start_task_buildingwork(*game);
 		return true;
 	}
 	return false;
@@ -376,10 +376,9 @@
 	 Worker          * const w,
 	 PlayerImmovable &       target)
 {
-	MilitarySite & msite = ref_cast<MilitarySite, PlayerImmovable>(target);
-	Soldier      & s     = ref_cast<Soldier,      Worker>         (*w);
-
-	msite.incorporate_soldier(game, s);
+	upcast(MilitarySite, msite, &target);
+	upcast(Soldier, s, w);
+	msite->incorporate_soldier(game, *s);
 }
 
 
@@ -409,11 +408,11 @@
 	}
 
 	if (m_capacity < present.size()) {
-		Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
+		upcast(Game, game, &owner().egbase());
 		for (uint32_t i = 0; i < present.size() - m_capacity; ++i) {
 			Soldier & soldier = *present[i];
-			soldier.reset_tasks(game);
-			soldier.start_task_leavebuilding(game, true);
+			soldier.reset_tasks(*game);
+			soldier.start_task_leavebuilding(*game, true);
 		}
 	}
 }
@@ -716,7 +715,7 @@
 
 void MilitarySite::drop_soldier(Soldier & soldier)
 {
-	Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
+	upcast(Game, game, &owner().egbase());
 
 	if (!is_present(soldier)) {
 		// This can happen when the "drop soldier" player command is delayed
@@ -729,8 +728,8 @@
 		return;
 	}
 
-	soldier.reset_tasks(game);
-	soldier.start_task_leavebuilding(game, true);
+	soldier.reset_tasks(*game);
+	soldier.start_task_leavebuilding(*game, true);
 
 	update_soldier_request();
 }
@@ -754,8 +753,8 @@
 
 void MilitarySite::aggressor(Soldier & enemy)
 {
-	Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
-	Map  & map  = game.map();
+	upcast(Game, game, &owner().egbase());
+	Map  & map  = game->map();
 	if
 		(enemy.get_owner() == &owner() ||
 		 enemy.get_battle() ||
@@ -784,7 +783,7 @@
 				sj.enemy = &enemy;
 				sj.stayhome = false;
 				m_soldierjobs.push_back(sj);
-				temp_soldier->update_task_buildingwork(game);
+				temp_soldier->update_task_buildingwork(*game);
 				return;
 			}
 		}
@@ -792,12 +791,12 @@
 
 	// Inform the player, that we are under attack by adding a new entry to the
 	// message queue - a sound will automatically be played.
-	notify_player(game, true);
+	notify_player(*game, true);
 }
 
 bool MilitarySite::attack(Soldier & enemy)
 {
-	Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
+	upcast(Game, game, &owner().egbase());
 
 	std::vector<Soldier *> present = present_soldiers();
 	Soldier * defender = nullptr;
@@ -832,11 +831,11 @@
 		sj.stayhome = true;
 		m_soldierjobs.push_back(sj);
 
-		defender->update_task_buildingwork(game);
+		defender->update_task_buildingwork(*game);
 
 		// Inform the player, that we are under attack by adding a new entry to
 		// the message queue - a sound will automatically be played.
-		notify_player(game);
+		notify_player(*game);
 
 		return true;
 	} else {
@@ -844,7 +843,7 @@
 		const Coords coords = get_position();
 		{
 			send_message
-				(game,
+				(*game,
 				 "site_lost",
 				 _("Militarysite lost!"),
 				 descr().m_defeated_enemy_str,
@@ -855,11 +854,11 @@
 		// we still hold the bigger military presence in that area (e.g. if there
 		// is a fortress one or two points away from our sentry, the fortress has
 		// a higher presence and thus the enemy can just burn down the sentry.
-		if (military_presence_kept(game)) {
+		if (military_presence_kept(*game)) {
 			// Okay we still got the higher military presence, so the attacked
 			// militarysite will be destroyed.
 			set_defeating_player(enemy.owner().player_number());
-			schedule_destroy(game);
+			schedule_destroy(*game);
 			return false;
 		}
 
@@ -889,16 +888,16 @@
 
 		// Now we destroy the old building before we place the new one.
 		set_defeating_player(enemy.owner().player_number());
-		schedule_destroy(game);
+		schedule_destroy(*game);
 
 		enemyplayer->force_building(coords, former_buildings);
-		BaseImmovable * const newimm = game.map()[coords].get_immovable();
+		BaseImmovable * const newimm = game->map()[coords].get_immovable();
 		upcast(MilitarySite, newsite, newimm);
-		newsite->reinit_after_conqueration(game);
+		newsite->reinit_after_conqueration(*game);
 
 		// Of course we should inform the victorious player as well
 		newsite->send_message
-			(game,
+			(*game,
 			 "site_defeated",
 			 _("Enemy at site defeated!"),
 			 newsite->descr().m_defeated_you_str,
@@ -991,8 +990,8 @@
 	sj.stayhome = false;
 	m_soldierjobs.push_back(sj);
 
-	soldier.update_task_buildingwork
-		(ref_cast<Game, EditorGameBase>(owner().egbase()));
+	upcast(Game, game, &owner().egbase());
+	soldier.update_task_buildingwork(*game);
 }
 
 

=== modified file 'src/logic/partially_finished_building.cc'
--- src/logic/partially_finished_building.cc	2014-09-10 10:18:46 +0000
+++ src/logic/partially_finished_building.cc	2014-11-28 17:01:11 +0000
@@ -201,15 +201,15 @@
 {
 	assert(w);
 
-	PartiallyFinishedBuilding & b = ref_cast<PartiallyFinishedBuilding, PlayerImmovable>(target);
+	upcast(PartiallyFinishedBuilding, b, &target);
 
-	b.m_builder = w;
+	b->m_builder = w;
 
 	delete &rq;
-	b.m_builder_request = nullptr;
+	b->m_builder_request = nullptr;
 
 	w->start_task_buildingwork(game);
-	b.set_seeing(true);
+	b->set_seeing(true);
 }
 
 

=== modified file 'src/logic/pathfield.cc'
--- src/logic/pathfield.cc	2014-09-19 12:54:54 +0000
+++ src/logic/pathfield.cc	2014-11-28 17:01:11 +0000
@@ -19,7 +19,6 @@
 
 #include "logic/pathfield.h"
 
-#include "base/deprecated.h"
 #include "base/wexception.h"
 
 namespace Widelands {

=== modified file 'src/logic/player.cc'
--- src/logic/player.cc	2014-09-20 09:37:47 +0000
+++ src/logic/player.cc	2014-11-28 17:01:11 +0000
@@ -201,14 +201,14 @@
 		const TribeDescr::Initialization & initialization =
 			tribe().initialization(m_initialization_index);
 
-		Game & game = ref_cast<Game, EditorGameBase>(egbase());
+		upcast(Game, game, &egbase());
 
 		// Run the corresponding script
-		std::unique_ptr<LuaTable> table(game.lua().run_script(initialization.script));
+		std::unique_ptr<LuaTable> table(game->lua().run_script(initialization.script));
 		table->do_not_warn_about_unaccessed_keys();
 		std::unique_ptr<LuaCoroutine> cr = table->get_coroutine("func");
 		cr->push_arg(this);
-		game.enqueue_command(new CmdLuaCoroutine(game.get_gametime(), cr.release()));
+		game->enqueue_command(new CmdLuaCoroutine(game->get_gametime(), cr.release()));
 
 		// Check if other starting positions are shared in and initialize them as well
 		for (uint8_t n = 0; n < m_further_shared_in_player.size(); ++n) {
@@ -216,12 +216,12 @@
 
 			// Run the corresponding script
 			std::unique_ptr<LuaCoroutine> ncr =
-				game.lua()
+				game->lua()
 					.run_script(tribe().initialization(m_further_initializations.at(n)).script)
 					->get_coroutine("func");
 			ncr->push_arg(this);
 			ncr->push_arg(further_pos);
-			game.enqueue_command(new CmdLuaCoroutine(game.get_gametime(), ncr.release()));
+			game->enqueue_command(new CmdLuaCoroutine(game->get_gametime(), ncr.release()));
 		}
 	} else
 		throw WLWarning
@@ -485,7 +485,8 @@
 		log("Clearing for road at (%i, %i)\n", c.x, c.y);
 
 		//  Make sure that the player owns the area around.
-		ref_cast<Game, EditorGameBase>(egbase()).conquer_area_no_building
+		upcast(Game, game, &egbase());
+		game->conquer_area_no_building
 			(PlayerArea<Area<FCoords> >(player_number(), Area<FCoords>(c, 1)));
 
 		if (BaseImmovable * const immovable = c.field->get_immovable()) {
@@ -774,11 +775,13 @@
 */
 void Player::flagaction(Flag & flag)
 {
-	if (&flag.owner() == this) //  Additional security check.
+	if (&flag.owner() == this) { //  Additional security check.
+		upcast(Game, game, &egbase());
 		flag.add_flag_job
-			(ref_cast<Game, EditorGameBase>(egbase()),
+			(*game,
 			 tribe().worker_index("geologist"),
 			 "expedition");
+	}
 }
 
 

=== modified file 'src/logic/production_program.h'
--- src/logic/production_program.h	2014-09-14 11:31:58 +0000
+++ src/logic/production_program.h	2014-11-28 17:01:11 +0000
@@ -28,7 +28,6 @@
 
 #include <stdint.h>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "base/macros.h"
 #include "logic/bill_of_materials.h"

=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc	2014-10-27 10:14:10 +0000
+++ src/logic/productionsite.cc	2014-11-28 17:01:11 +0000
@@ -517,10 +517,10 @@
 	 Worker          * const w,
 	 PlayerImmovable &       target)
 {
-	ProductionSite & psite = ref_cast<ProductionSite, PlayerImmovable>(target);
+	upcast(ProductionSite, psite, &target);
 
 	assert(w);
-	assert(w->get_location(game) == &psite);
+	assert(w->get_location(game) == psite);
 
 	// If there is more than one working position, it's possible, that different level workers are
 	// requested and therefor possible, that a higher qualified worker answers a request for a lower
@@ -531,7 +531,7 @@
 	// placed on the slot that originally requested the arrived worker.
 	bool worker_placed = false;
 	WareIndex     idx = w->descr().worker_index();
-	for (WorkingPosition * wp = psite.m_working_positions;; ++wp) {
+	for (WorkingPosition * wp = psite->m_working_positions;; ++wp) {
 		if (wp->worker_request == &rq) {
 			if (wp->worker_request->get_index() == idx) {
 				// Place worker
@@ -542,16 +542,16 @@
 				// Set new request for this slot
 				WareIndex workerid = wp->worker_request->get_index();
 				delete wp->worker_request;
-				wp->worker_request = &psite.request_worker(workerid);
+				wp->worker_request = &psite->request_worker(workerid);
 			}
 			break;
 		}
 	}
 	while (!worker_placed) {
 		{
-			uint8_t nwp = psite.descr().nr_working_positions();
+			uint8_t nwp = psite->descr().nr_working_positions();
 			uint8_t pos = 0;
-			WorkingPosition * wp = psite.m_working_positions;
+			WorkingPosition * wp = psite->m_working_positions;
 			for (; pos < nwp; ++wp, ++pos) {
 				// Find a fitting slot
 				if (!wp->worker && !worker_placed)
@@ -565,10 +565,10 @@
 		}
 		if (!worker_placed) {
 			// Find the next smaller version of this worker
-			WareIndex nuwo    = psite.descr().tribe().get_nrworkers();
+			WareIndex nuwo    = psite->descr().tribe().get_nrworkers();
 			WareIndex current = WareIndex(static_cast<size_t>(0));
 			for (; current < nuwo; ++current) {
-				WorkerDescr const * worker = psite.descr().tribe().get_worker_descr(current);
+				WorkerDescr const * worker = psite->descr().tribe().get_worker_descr(current);
 				if (worker->becomes() == idx) {
 					idx = current;
 					break;
@@ -578,8 +578,8 @@
 				throw
 					wexception
 						("Something went wrong! No fitting place for worker %s in %s at (%u, %u) found!",
-						 w->descr().descname().c_str(), psite.descr().descname().c_str(),
-						 psite.get_position().x, psite.get_position().y);
+						 w->descr().descname().c_str(), psite->descr().descname().c_str(),
+						 psite->get_position().x, psite->get_position().y);
 		}
 	}
 
@@ -588,8 +588,8 @@
 	// primary worker if the worker that has just arrived is
 	// the last one we need to start working.
 	w->start_task_idle(game, 0, -1);
-	psite.try_start_working(game);
-	psite.workers_changed();
+	psite->try_start_working(game);
+	psite->workers_changed();
 }
 
 
@@ -765,14 +765,13 @@
 			const WorkerDescr & worker_descr =
 				*descr().tribe().get_worker_descr(worker_type_with_count.first);
 			{
-				Worker & recruit =
-					ref_cast<Worker, Bob>(worker_descr.create_object());
-				recruit.set_owner(&worker.owner());
-				recruit.set_position(game, worker.get_position());
-				recruit.init(game);
-				recruit.set_location(this);
-				recruit.start_task_leavebuilding(game, true);
-				worker.start_task_releaserecruit(game, recruit);
+				upcast(Worker, recruit, &worker_descr.create_object());
+				recruit->set_owner(&worker.owner());
+				recruit->set_position(game, worker.get_position());
+				recruit->init(game);
+				recruit->set_location(this);
+				recruit->start_task_leavebuilding(game, true);
+				worker.start_task_releaserecruit(game, *recruit);
 			}
 		}
 		assert(worker_type_with_count.second);

=== modified file 'src/logic/requirements.cc'
--- src/logic/requirements.cc	2014-09-20 09:37:47 +0000
+++ src/logic/requirements.cc	2014-11-28 17:01:11 +0000
@@ -19,7 +19,6 @@
 
 #include "logic/requirements.h"
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
 #include "io/fileread.h"
 #include "io/filewrite.h"

=== modified file 'src/logic/ship.cc'
--- src/logic/ship.cc	2014-09-20 09:37:47 +0000
+++ src/logic/ship.cc	2014-11-28 17:01:11 +0000
@@ -21,7 +21,7 @@
 
 #include <memory>
 
-#include "base/deprecated.h"
+#include "base/macros.h"
 #include "economy/economy.h"
 #include "economy/flag.h"
 #include "economy/fleet.h"
@@ -1031,7 +1031,8 @@
 	// economy of all workers we're transporting so that they are in the correct
 	// economy. Also, we might are on an expedition which means that we just now
 	// created the economy of this ship and must inform all wares.
-	ship.set_economy(ref_cast<Game>(egbase()), ship.m_economy);
+	upcast(Game, game, &egbase());
+	ship.set_economy(*game, ship.m_economy);
 }
 
 

=== modified file 'src/logic/soldier.cc'
--- src/logic/soldier.cc	2014-10-27 10:14:10 +0000
+++ src/logic/soldier.cc	2014-11-28 17:01:11 +0000
@@ -700,12 +700,8 @@
 	 uint32_t const time)
 {
 	molog("[soldier] starting animation %s", animname);
-	return
-		start_task_idle
-			(ref_cast<Game, EditorGameBase>(egbase),
-			 descr().get_rand_anim
-			 	(ref_cast<Game, EditorGameBase>(egbase), animname),
-			 time);
+	upcast(Game, game, &egbase);
+	return start_task_idle(*game, descr().get_rand_anim(*game, animname), time);
 }
 
 
@@ -748,14 +744,17 @@
  */
 bool Soldier::can_be_challenged()
 {
-	if (m_hp_current < 1)  //< Soldier is dead!
-		return false;
-	if (!is_on_battlefield())
-		return false;
-	if (!m_battle)
+	if (m_hp_current < 1) {  //< Soldier is dead!
+		return false;
+	}
+	if (!is_on_battlefield()) {
+		return false;
+	}
+	if (!m_battle) {
 		return true;
-	return
-		!m_battle->locked(ref_cast<Game, EditorGameBase>(owner().egbase()));
+	}
+	upcast(Game, game, &owner().egbase());
+	return !m_battle->locked(*game);
 }
 
 /**
@@ -1805,11 +1804,8 @@
 			 FindImmovableAttackable());
 
 		for (BaseImmovable * temp_attackable : attackables) {
-			if
-				(ref_cast<PlayerImmovable const, BaseImmovable const>(*temp_attackable)
-				 .get_owner()->player_number()
-				 ==
-				 land_owner) {
+			upcast(PlayerImmovable const, imm, temp_attackable);
+			if (imm->get_owner()->player_number() == land_owner) {
 				dynamic_cast<Attackable &>(*temp_attackable).aggressor(*this);
 			}
 		}

=== modified file 'src/logic/trainingsite.cc'
--- src/logic/trainingsite.cc	2014-10-27 10:14:10 +0000
+++ src/logic/trainingsite.cc	2014-11-28 17:01:11 +0000
@@ -341,13 +341,13 @@
 	 Worker          * const w,
 	 PlayerImmovable &       target)
 {
-	TrainingSite & tsite = ref_cast<TrainingSite, PlayerImmovable>(target);
-	Soldier      & s     = ref_cast<Soldier,      Worker>         (*w);
-
-	assert(s.get_location(game) == &tsite);
-	assert(tsite.m_soldier_request == &rq);
-
-	tsite.incorporate_soldier(game, s);
+	upcast(TrainingSite, tsite, &target);
+	upcast(Soldier, s, w);
+
+	assert(s->get_location(game) == tsite);
+	assert(tsite->m_soldier_request == &rq);
+
+	tsite->incorporate_soldier(game, *s);
 }
 
 /*
@@ -416,7 +416,7 @@
  */
 void TrainingSite::drop_soldier(Soldier & soldier)
 {
-	Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
+	upcast(Game, game, &owner().egbase());
 
 	std::vector<Soldier *>::iterator it =
 		std::find(m_soldiers.begin(), m_soldiers.end(), &soldier);
@@ -427,11 +427,11 @@
 
 	m_soldiers.erase(it);
 
-	soldier.reset_tasks(game);
-	soldier.start_task_leavebuilding(game, true);
+	soldier.reset_tasks(*game);
+	soldier.start_task_leavebuilding(*game, true);
 
 	// Schedule, so that we can call new soldiers on next act()
-	schedule_act(game, 100);
+	schedule_act(*game, 100);
 }
 
 

=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc	2014-09-30 05:41:55 +0000
+++ src/logic/warehouse.cc	2014-11-28 17:01:11 +0000
@@ -23,7 +23,6 @@
 
 #include <boost/format.hpp>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "base/macros.h"
 #include "base/wexception.h"
@@ -377,11 +376,10 @@
 			(owner().is_worker_type_allowed(worker_index) &&
 			 m_next_worker_without_cost_spawn[i] == static_cast<uint32_t>(never()))
 		{
-			if (next_spawn == static_cast<uint32_t>(never()))
-				next_spawn =
-					schedule_act
-						(ref_cast<Game, EditorGameBase>(egbase),
-						 WORKER_WITHOUT_COST_SPAWN_INTERVAL);
+			upcast(Game, game, &egbase);
+			if (next_spawn == static_cast<uint32_t>(never())) {
+				next_spawn = schedule_act(*game, WORKER_WITHOUT_COST_SPAWN_INTERVAL);
+			}
 			m_next_worker_without_cost_spawn[i] = next_spawn;
 			log
 				("WARNING: player %u is allowed to create worker type %s but his "
@@ -444,17 +442,13 @@
 		// m_next_military_act is not touched in the loading code. Is only needed
 		// if there warehous is created in the game?  I assume it's for the
 		// conquer_radius thing
-		m_next_military_act =
-			schedule_act
-				(ref_cast<Game, EditorGameBase>(egbase), 1000);
+		m_next_military_act = schedule_act(*game, 1000);
 
-		m_next_stock_remove_act =
-			schedule_act
-				(ref_cast<Game, EditorGameBase>(egbase), 4000);
+		m_next_stock_remove_act = schedule_act(*game, 4000);
 
 		log("Message: adding (wh) (%s) %i \n", to_string(descr().type()).c_str(), player.player_number());
 		send_message
-			(ref_cast<Game, EditorGameBase>(egbase),
+			(*game,
 			 "warehouse",
 			 descr().descname(),
 			 (boost::format(_("A new %s was added to your economy."))
@@ -911,17 +905,17 @@
 	 Worker          * const w,
 	 PlayerImmovable &       target)
 {
-	Warehouse & wh = ref_cast<Warehouse, PlayerImmovable>(target);
+	upcast(Warehouse, wh, &target);
 
 	if (w) {
 		w->schedule_incorporate(game);
 	} else {
-		wh.m_supply->add_wares(ware, 1);
+		wh->m_supply->add_wares(ware, 1);
 
 		// This ware may be used to build planned workers,
 		// so it seems like a good idea to update the associated requests
 		// and use the ware before it is sent away again.
-		wh._update_all_planned_workers(game);
+		wh->_update_all_planned_workers(game);
 	}
 }
 
@@ -1198,8 +1192,8 @@
 	if (!descr().get_conquers())
 		return;
 
-	Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
-	Map  & map  = game.map();
+	upcast(Game, game, &owner().egbase());
+	Map  & map  = game->map();
 	if
 		(enemy.get_owner() == &owner() ||
 		 enemy.get_battle() ||
@@ -1209,7 +1203,7 @@
 		return;
 
 	if
-		(game.map().find_bobs
+		(game->map().find_bobs
 		 	(Area<FCoords>(map.get_fcoords(base_flag().get_position()), 2),
 		 	 nullptr,
 		 	 FindBobEnemySoldier(&owner())))
@@ -1218,30 +1212,28 @@
 	WareIndex const soldier_index = descr().tribe().worker_index("soldier");
 	Requirements noreq;
 
-	if (!count_workers(game, soldier_index, noreq))
+	if (!count_workers(*game, soldier_index, noreq))
 		return;
 
-	Soldier & defender =
-		ref_cast<Soldier, Worker>(launch_worker(game, soldier_index, noreq));
-	defender.start_task_defense(game, false);
+	upcast(Soldier, defender, &launch_worker(*game, soldier_index, noreq));
+	defender->start_task_defense(*game, false);
 }
 
 bool Warehouse::attack(Soldier & enemy)
 {
-	Game & game = ref_cast<Game, EditorGameBase>(owner().egbase());
+	upcast(Game, game, &owner().egbase());
 	WareIndex const soldier_index = descr().tribe().worker_index("soldier");
 	Requirements noreq;
 
-	if (count_workers(game, soldier_index, noreq)) {
-		Soldier & defender =
-			ref_cast<Soldier, Worker>(launch_worker(game, soldier_index, noreq));
-		defender.start_task_defense(game, true);
-		enemy.send_signal(game, "sleep");
+	if (count_workers(*game, soldier_index, noreq)) {
+		upcast(Soldier, defender, &launch_worker(*game, soldier_index, noreq));
+		defender->start_task_defense(*game, true);
+		enemy.send_signal(*game, "sleep");
 		return true;
 	}
 
 	set_defeating_player(enemy.owner().player_number());
-	schedule_destroy(game);
+	schedule_destroy(*game);
 	return false;
 }
 

=== modified file 'src/logic/worker.cc'
--- src/logic/worker.cc	2014-10-27 10:14:10 +0000
+++ src/logic/worker.cc	2014-11-28 17:01:11 +0000
@@ -618,7 +618,8 @@
 	int32_t max_steps = -1;
 
 	// First of all, make sure we're outside
-	if (imm == &ref_cast<Building, PlayerImmovable>(*get_location(game))) {
+	upcast(Building, building, get_location(game));
+	if (imm == building) {
 		start_task_leavebuilding(game, false);
 		return true;
 	}
@@ -902,7 +903,8 @@
 bool Worker::run_geologist(Game & game, State & state, const Action & action)
 {
 	// assert that location is of the right type.
-	ref_cast<Flag const, PlayerImmovable const>(*get_location(game));
+	// NOCOM(#gunchleoc): What's this supposed to do? There's nothing being asserted here.
+	//upcast(Flag const, flag, get_location(game));
 
 	molog
 		("  Start Geologist (%i attempts, %i radius -> %s)\n",
@@ -1902,13 +1904,12 @@
 	}
 
 	for (;;) {
-		const WorkerProgram & program =
-			ref_cast<WorkerProgram const, BobProgramBase const>(*state.program);
+		upcast(WorkerProgram const, program, state.program);
 
-		if (static_cast<uint32_t>(state.ivar1) >= program.get_size())
+		if (static_cast<uint32_t>(state.ivar1) >= program->get_size())
 			return pop_task(game);
 
-		const Action & action = *program.get_action(state.ivar1);
+		const Action & action = *program->get_action(state.ivar1);
 
 		if ((this->*(action.function))(game, state, action))
 			return;
@@ -2082,9 +2083,12 @@
 
 	WareInstance * ware = get_carried_ware(game);
 	BaseImmovable * const location = game.map()[get_position()].get_immovable();
+
 #ifndef NDEBUG
-	Building & ploc = ref_cast<Building, PlayerImmovable>(*get_location(game));
-	assert(&ploc == location || &ploc.base_flag() == location);
+	upcast(BaseImmovable, ploc, get_location(game));
+	upcast(Building, plbuild, get_location(game));
+	upcast(BaseImmovable, plflagloc, &plbuild->base_flag());
+	assert(ploc == location || plflagloc == location);
 #endif
 
 	// Deliver the ware
@@ -2205,11 +2209,10 @@
 
 		// The ware has decided that it doesn't want to go to us after all
 		// In order to return to the warehouse, we're switching to State_DropOff
-		if
-			(WareInstance * const ware =
-			 	ref_cast<Flag, PlayerImmovable>(*location).fetch_pending_ware
-			 		(game, employer))
+		upcast(Flag, flag, location);
+		if (WareInstance * const ware = flag->fetch_pending_ware(game, employer)) {
 			set_carried_ware(game, ware);
+		}
 
 		set_animation(game, descr().get_animation("idle"));
 		return schedule_act(game, 20);
@@ -2367,14 +2370,13 @@
  */
 void Worker::start_task_leavebuilding(Game & game, bool const changelocation)
 {
-	Building & building =
-		ref_cast<Building, PlayerImmovable>(*get_location(game));
+	upcast(Building, building, get_location(game));
 
 	// Set the wait task
 	push_task(game, taskLeavebuilding);
 	State & state = top_state();
 	state.ivar1   = changelocation;
-	state.objvar1 = &building;
+	state.objvar1 = building;
 }
 
 
@@ -2437,8 +2439,10 @@
 	//  The if-statement is needed because this is (unfortunately) also called
 	//  when the Worker is deallocated when shutting down the simulation. Then
 	//  the building might not exist any more.
-	if (MapObject * const building = state.objvar1.get(game))
-		ref_cast<Building, MapObject>(*building).leave_skip(game, *this);
+	if (MapObject * const building = state.objvar1.get(game)) {
+		upcast(Building, tmp_building, building);
+		tmp_building->leave_skip(game, *this);
+	}
 }
 
 
@@ -2544,7 +2548,7 @@
 		molog("[fugitive]: found a flag connected to warehouse(s)\n");
 		for (const ImmovableFound& tmp_flag : flags) {
 
-			Flag & flag = ref_cast<Flag, BaseImmovable>(*tmp_flag.object);
+			upcast(Flag, flag, tmp_flag.object);
 
 			if (game.logic_rand() % 2 == 0)
 				continue;
@@ -2553,7 +2557,7 @@
 				map.calc_distance(get_position(), tmp_flag.coords);
 
 			if (!best || bestdist > dist) {
-				best = &flag;
+				best = flag;
 				bestdist = dist;
 			}
 		}
@@ -2649,10 +2653,8 @@
 	//
 	Map & map = game.map();
 	const World & world = game.world();
-	Area<FCoords> owner_area
-		(map.get_fcoords
-		 	(ref_cast<Flag, PlayerImmovable>(*get_location(game)).get_position()),
-		 state.ivar2);
+	upcast(Flag, flag, get_location(game));
+	Area<FCoords> owner_area(map.get_fcoords(flag->get_position()), state.ivar2);
 
 	// Check if it's not time to go home
 	if (state.ivar1 > 0) {
@@ -2798,12 +2800,11 @@
 	state.ivar2   = game.get_gametime() + time;
 
 	// first get out
-	Building & building =
-		ref_cast<Building, PlayerImmovable>(*get_location(game));
+	upcast(Building, building, get_location(game));
 	push_task(game, taskLeavebuilding);
 	State & stateLeave = top_state();
 	stateLeave.ivar1 = false;
-	stateLeave.objvar1 = &building;
+	stateLeave.objvar1 = building;
 }
 
 
@@ -2958,8 +2959,8 @@
 
 	if (version >= 2) {
 		if (fr.unsigned_8()) {
-			worker.m_transfer =
-				new Transfer(ref_cast<Game, EditorGameBase>(egbase()), worker);
+			upcast(Game, game, &egbase());
+			worker.m_transfer = new Transfer(*game, worker);
 			worker.m_transfer->read(fr, m_transfer);
 		}
 	}

=== modified file 'src/logic/worker_descr.cc'
--- src/logic/worker_descr.cc	2014-09-20 09:37:47 +0000
+++ src/logic/worker_descr.cc	2014-11-28 17:01:11 +0000
@@ -19,8 +19,8 @@
 
 #include "logic/worker_descr.h"
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
+#include "base/macros.h"
 #include "base/wexception.h"
 #include "graphic/graphic.h"
 #include "logic/carrier.h"
@@ -177,12 +177,12 @@
 	 Coords             const coords)
 const
 {
-	Worker & worker = ref_cast<Worker, MapObject>(create_object());
-	worker.set_owner(&owner);
-	worker.set_location(location);
-	worker.set_position(egbase, coords);
-	worker.init(egbase);
-	return worker;
+	upcast(Worker, worker, &create_object());
+	worker->set_owner(&owner);
+	worker->set_location(location);
+	worker->set_position(egbase, coords);
+	worker->init(egbase);
+	return *worker;
 }
 
 

=== modified file 'src/map_io/CMakeLists.txt'
--- src/map_io/CMakeLists.txt	2014-11-22 15:27:45 +0000
+++ src/map_io/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -86,7 +86,6 @@
     map_version_packet.h
   USES_SDL2_IMAGE
   DEPENDS
-    base_deprecated
     base_exceptions
     base_log
     base_macros

=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc	2014-09-20 09:37:47 +0000
+++ src/map_io/map_buildingdata_packet.cc	2014-11-28 17:01:11 +0000
@@ -194,43 +194,21 @@
 					//  Set economy now, some stuff below will count on this.
 					building.set_economy(building.m_flag->get_economy());
 
+					upcast(Game, game, &egbase);
+
 					if (upcast(ConstructionSite, constructionsite, &building)) {
-						read_constructionsite
-							(*constructionsite,
-							 fr,
-							 ref_cast<Game, EditorGameBase>(egbase),
-							 mol);
+						read_constructionsite (*constructionsite, fr, *game, mol);
 					} else if (upcast(DismantleSite, dms, &building)) {
-						read_dismantlesite
-							(*dms,
-							 fr,
-							 ref_cast<Game, EditorGameBase>(egbase),
-							 mol);
+						read_dismantlesite(*dms, fr, *game, mol);
 					} else if (upcast(Warehouse, warehouse, &building)) {
-						read_warehouse
-							(*warehouse,
-							 fr,
-							 ref_cast<Game, EditorGameBase>(egbase),
-							 mol);
+						read_warehouse(*warehouse, fr, *game, mol);
 					} else if (upcast(ProductionSite, productionsite, &building)) {
 						if (upcast(MilitarySite, militarysite, productionsite)) {
-							read_militarysite
-								(*militarysite,
-								 fr,
-								 ref_cast<Game, EditorGameBase>(egbase),
-								 mol);
+							read_militarysite(*militarysite, fr, *game, mol);
 						} else if (upcast(TrainingSite, trainingsite, productionsite)) {
-							read_trainingsite
-								(*trainingsite,
-								 fr,
-								 ref_cast<Game, EditorGameBase>(egbase),
-								 mol);
+							read_trainingsite(*trainingsite, fr, *game, mol);
 						} else {
-							read_productionsite
-								(*productionsite,
-								 fr,
-								 ref_cast<Game, EditorGameBase>(egbase),
-								 mol);
+							read_productionsite(*productionsite, fr, *game, mol);
 						}
 					} else {
 						//  type of building is not one of (or derived from)
@@ -238,8 +216,7 @@
 						assert(false);
 					}
 					if (packet_version < 3) {
-						read_formerbuildings_v2
-							(building, fr, ref_cast<Game, EditorGameBase>(egbase), mol);
+						read_formerbuildings_v2(building, fr, *game, mol);
 					}
 
 					mol.mark_object_as_loaded(building);
@@ -1137,7 +1114,7 @@
 	Map & map = egbase.map();
 	const uint32_t mapwidth = map.get_width();
 	MapIndex const max_index = map.max_index();
-	for (MapIndex i = 0; i < max_index; ++i)
+	for (MapIndex i = 0; i < max_index; ++i) {
 		if (upcast(Building const, building, map[i].get_immovable())) {
 			assert(mos.is_object_known(*building));
 
@@ -1190,52 +1167,32 @@
 				fw.unsigned_8(is_stopped);
 			}
 
-			if (upcast(ConstructionSite const, constructionsite, building))
-				write_constructionsite
-					(*constructionsite,
-					 fw,
-					 ref_cast<Game, EditorGameBase>(egbase),
-					 mos);
-			else if (upcast(DismantleSite const, dms, building))
-				write_dismantlesite
-					(*dms,
-					 fw,
-					 ref_cast<Game, EditorGameBase>(egbase),
-					 mos);
-			else if (upcast(Warehouse const, warehouse, building))
-				write_warehouse
-					(*warehouse,
-					 fw,
-					 ref_cast<Game, EditorGameBase>(egbase),
-					 mos);
-			else if (upcast(ProductionSite const, productionsite, building)) {
-				if (upcast(MilitarySite const, militarysite, productionsite))
-					write_militarysite
-						(*militarysite,
-						 fw,
-						 ref_cast<Game, EditorGameBase>(egbase),
-						 mos);
-				else if (upcast(TrainingSite const, trainingsite, productionsite))
-					write_trainingsite
-						(*trainingsite,
-						 fw,
-						 ref_cast<Game, EditorGameBase>(egbase),
-						 mos);
-				else
-					write_productionsite
-						(*productionsite,
-						 fw,
-						 ref_cast<Game, EditorGameBase>(egbase),
-						 mos);
+			upcast(Game, game, &egbase);
+
+			if (upcast(ConstructionSite const, constructionsite, building)) {
+				write_constructionsite(*constructionsite, fw, *game, mos);
+			} else if (upcast(DismantleSite const, dms, building)) {
+				write_dismantlesite(*dms, fw, *game, mos);
+			} else if (upcast(Warehouse const, warehouse, building)) {
+				write_warehouse (*warehouse, fw, *game, mos);
+			} else if (upcast(ProductionSite const, productionsite, building)) {
+				if (upcast(MilitarySite const, militarysite, productionsite)) {
+					write_militarysite(*militarysite, fw, *game, mos);
+				}
+				else if (upcast(TrainingSite const, trainingsite, productionsite)) {
+					write_trainingsite(*trainingsite, fw, *game, mos);
+				}
+				else {
+					write_productionsite(*productionsite, fw, *game, mos);
+				}
 			} else {
 				assert(false);
 				//  type of building is not one of (or derived from)
 				//  {ConstructionSite, Warehouse, ProductionSite}
 			}
-
 			mos.mark_object_as_saved(*building);
 		}
-
+	}
 	fw.write(fs, "binary/building_data");
 }
 

=== modified file 'src/map_io/map_elemental_packet.cc'
--- src/map_io/map_elemental_packet.cc	2014-10-29 06:41:10 +0000
+++ src/map_io/map_elemental_packet.cc	2014-11-28 17:01:11 +0000
@@ -22,7 +22,6 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/format.hpp>
 
-#include "base/deprecated.h"
 #include "logic/editor_game_base.h"
 #include "logic/game_data_error.h"
 #include "logic/map.h"

=== modified file 'src/map_io/map_flag_packet.cc'
--- src/map_io/map_flag_packet.cc	2014-09-20 09:37:47 +0000
+++ src/map_io/map_flag_packet.cc	2014-11-28 17:01:11 +0000
@@ -106,12 +106,10 @@
 						//  packet. We always create this, no matter what skip is
 						//  since we have to read the data packets. We delete this
 						//  object later again, if it is not wanted.
+						upcast(Game, game, &egbase);
 						mol.register_object<Flag>
 							(serial,
-							 *new Flag
-							 	(ref_cast<Game, EditorGameBase>(egbase),
-							 	 egbase.player(owner),
-							 	 fc));
+							 *new Flag(*game, egbase.player(owner), fc));
 					} catch (const WException & e) {
 						throw GameDataError
 							("%u (at (%i, %i), owned by player %u): %s",

=== modified file 'src/map_io/map_flagdata_packet.cc'
--- src/map_io/map_flagdata_packet.cc	2014-09-20 09:37:47 +0000
+++ src/map_io/map_flagdata_packet.cc	2014-11-28 17:01:11 +0000
@@ -201,8 +201,8 @@
 										 0,
 										 Flag::flag_job_request_callback,
 										 wwWORKER);
-								f.request->read
-									(fr, ref_cast<Game, EditorGameBase>(egbase), mol);
+								upcast(Game, game, &egbase);
+								f.request->read(fr, *game, mol);
 							} else {
 								f.request = nullptr;
 							}
@@ -301,8 +301,8 @@
 			for (const Flag::FlagJob& temp_job : flag_jobs) {
 				if (temp_job.request) {
 					fw.unsigned_8(1);
-					temp_job.request->write
-						(fw, ref_cast<Game, EditorGameBase>(egbase), mos);
+					upcast(Game, game, &egbase);
+					temp_job.request->write(fw, *game, mos);
 				} else
 					fw.unsigned_8(0);
 

=== modified file 'src/map_io/map_object_saver.cc'
--- src/map_io/map_object_saver.cc	2014-09-14 11:31:58 +0000
+++ src/map_io/map_object_saver.cc	2014-11-28 17:01:11 +0000
@@ -19,7 +19,6 @@
 
 #include "map_io/map_object_saver.h"
 
-#include "base/deprecated.h"
 #include "base/wexception.h"
 #include "economy/flag.h"
 #include "economy/fleet.h"

=== modified file 'src/map_io/map_port_spaces_packet.cc'
--- src/map_io/map_port_spaces_packet.cc	2014-09-30 05:41:55 +0000
+++ src/map_io/map_port_spaces_packet.cc	2014-11-28 17:01:11 +0000
@@ -23,7 +23,6 @@
 
 #include <boost/algorithm/string.hpp>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "logic/editor_game_base.h"
 #include "logic/game_data_error.h"

=== modified file 'src/map_io/map_roaddata_packet.cc'
--- src/map_io/map_roaddata_packet.cc	2014-09-20 09:37:47 +0000
+++ src/map_io/map_roaddata_packet.cc	2014-11-28 17:01:11 +0000
@@ -69,6 +69,7 @@
 					break;
 				}
 				try {
+					upcast(Game, game, &egbase);
 					Road & road = mol.get<Road>(serial);
 					if (mol.is_object_loaded(road))
 						throw GameDataError("already loaded");
@@ -124,7 +125,7 @@
 
 					//  Now that all rudimentary data is set, init this road. Then
 					//  overwrite the initialization values.
-					road._link_into_flags(ref_cast<Game, EditorGameBase>(egbase));
+					road._link_into_flags(*game);
 
 					road.m_idle_index      = fr.unsigned_32();
 
@@ -166,8 +167,8 @@
 							 		(road,
 							 		 0,
 							 		 Road::_request_carrier_callback,
-							 		 wwWORKER))
-							->read(fr, ref_cast<Game, EditorGameBase>(egbase), mol);
+									 wwWORKER))
+							->read(fr, *game, mol);
 						} else {
 							carrier_request = nullptr;
 							//log("No request in this slot");
@@ -190,13 +191,8 @@
 						} else {
 							delete carrier_request;
 							if (carrier) {
-								//carrier->set_location (0);
-								carrier->reset_tasks
-									(ref_cast<Game,
-									 EditorGameBase>(egbase));
-								//carrier->send_signal
-								//(ref_cast<Game,
-								//EditorGameBase>(egbase), "location");
+								upcast(Game, game, &egbase);
+								carrier->reset_tasks(*game);
 							}
 						}
 					}
@@ -275,8 +271,8 @@
 
 					if (temp_slot.carrier_request) {
 						fw.unsigned_8(1);
-						temp_slot.carrier_request->write
-							(fw, ref_cast<Game, EditorGameBase>(egbase), mos);
+						upcast(Game, game, &egbase);
+						temp_slot.carrier_request->write(fw, *game, mos);
 					} else {
 						fw.unsigned_8(0);
 					}

=== modified file 'src/network/CMakeLists.txt'
--- src/network/CMakeLists.txt	2014-10-13 15:04:50 +0000
+++ src/network/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -23,7 +23,6 @@
   USES_SDL2_NET
   DEPENDS
     ai
-    base_deprecated
     base_exceptions
     base_i18n
     base_log

=== modified file 'src/network/network_lan_promotion.cc'
--- src/network/network_lan_promotion.cc	2014-09-20 09:37:47 +0000
+++ src/network/network_lan_promotion.cc	2014-11-28 17:01:11 +0000
@@ -22,7 +22,6 @@
 #include <cstdio>
 #include <cstring>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "base/macros.h"
 #include "build_info.h"

=== modified file 'src/scripting/CMakeLists.txt'
--- src/scripting/CMakeLists.txt	2014-07-25 20:16:31 +0000
+++ src/scripting/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -38,7 +38,6 @@
     scripting.h
   USES_BOOST_REGEX
   DEPENDS
-    base_deprecated
     base_exceptions
     base_i18n
     base_log

=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc	2014-10-27 10:14:10 +0000
+++ src/scripting/lua_map.cc	2014-11-28 17:01:11 +0000
@@ -21,8 +21,8 @@
 
 #include <boost/format.hpp>
 
-#include "base/deprecated.h"
 #include "base/log.h"
+#include "base/macros.h"
 #include "economy/wares_queue.h"
 #include "graphic/graphic.h"
 #include "logic/carrier.h"
@@ -444,11 +444,10 @@
 			lua_rawset(L, -3);
 		}
 	} else {
-		const SoldierDescr& soldier_descr = ref_cast<SoldierDescr const, WorkerDescr const>
-			(*tribe.get_worker_descr(tribe.worker_index("soldier")));
+		upcast(SoldierDescr const, soldier_descr, tribe.get_worker_descr(tribe.worker_index("soldier")));
 
 		// Only return the number of those requested
-		const SoldierMapDescr wanted = unbox_lua_soldier_description(L, 2, soldier_descr);
+		const SoldierMapDescr wanted = unbox_lua_soldier_description(L, 2, *soldier_descr);
 		uint32_t rv = 0;
 		for (const Soldier* s : soldiers) {
 			SoldierMapDescr sd
@@ -469,10 +468,8 @@
 	assert(owner != nullptr);
 
 	const TribeDescr& tribe = owner->tribe();
-	const SoldierDescr& soldier_descr =  //  soldiers
-		ref_cast<SoldierDescr const, WorkerDescr const>
-			(*tribe.get_worker_descr(tribe.worker_index("soldier")));
-	SoldiersMap setpoints = m_parse_set_soldiers_arguments(L, soldier_descr);
+	upcast(SoldierDescr const, soldier_descr, tribe.get_worker_descr(tribe.worker_index("soldier")));
+	SoldiersMap setpoints = m_parse_set_soldiers_arguments(L, *soldier_descr);
 
 	// Get information about current soldiers
 	const std::vector<Soldier*> curs = sc->stationed_soldiers();
@@ -517,12 +514,11 @@
 			}
 		} else if (d > 0) {
 			for (; d; --d) {
-				Soldier& soldier = ref_cast<Soldier, Worker>
-					(soldier_descr.create(egbase, *owner, nullptr, building_position));
-				soldier.set_level
+				upcast(Soldier, soldier, &soldier_descr->create(egbase, *owner, nullptr, building_position));
+				soldier->set_level
 					(sp.first.hp, sp.first.at, sp.first.de, sp.first.ev);
-				if (sc->incorporate_soldier(egbase, soldier)) {
-					soldier.remove(egbase);
+				if (sc->incorporate_soldier(egbase, *soldier)) {
+					soldier->remove(egbase);
 					report_error(L, "No space left for soldier!");
 				}
 			}
@@ -2586,13 +2582,13 @@
 	for (Path::StepVector::size_type i = 0; i < idle_index; ++i)
 		egbase.map().get_neighbour(idle_position, path[i], &idle_position);
 
-	Carrier & carrier = ref_cast<Carrier, Worker>
-		(wdes->create (egbase, r.owner(), &r, idle_position));
-
-	if (upcast(Game, game, &egbase))
-		carrier.start_task_road(*game);
-
-	r.assign_carrier(carrier, 0);
+	upcast(Carrier, carrier, &wdes->create(egbase, r.owner(), &r, idle_position));
+
+	if (upcast(Game, game, &egbase)) {
+		carrier->start_task_road(*game);
+	}
+
+	r.assign_carrier(*carrier, 0);
 	return 0;
 }
 

=== modified file 'src/sound/CMakeLists.txt'
--- src/sound/CMakeLists.txt	2014-10-13 15:04:50 +0000
+++ src/sound/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -10,7 +10,6 @@
   USES_SDL2
   USES_SDL2_MIXER
   DEPENDS
-    base_deprecated
     base_i18n
     base_log
     graphic

=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc	2014-10-16 16:06:37 +0000
+++ src/sound/sound_handler.cc	2014-11-28 17:01:11 +0000
@@ -28,7 +28,6 @@
 #include <windows.h>
 #endif
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
 #include "base/log.h"
 #include "graphic/graphic.h"

=== modified file 'src/ui_basic/CMakeLists.txt'
--- src/ui_basic/CMakeLists.txt	2014-11-22 11:00:04 +0000
+++ src/ui_basic/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -51,7 +51,6 @@
   USES_BOOST_REGEX
   USES_SDL2
   DEPENDS
-    base_deprecated
     base_exceptions
     base_geometry
     base_i18n

=== modified file 'src/ui_basic/listselect.cc'
--- src/ui_basic/listselect.cc	2014-11-22 10:18:20 +0000
+++ src/ui_basic/listselect.cc	2014-11-28 17:01:11 +0000
@@ -23,7 +23,6 @@
 
 #include <boost/bind.hpp>
 
-#include "base/deprecated.h"
 #include "base/log.h"
 #include "graphic/font.h"
 #include "graphic/font_handler.h"

=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc	2014-10-14 06:30:20 +0000
+++ src/ui_basic/progresswindow.cc	2014-11-28 17:01:11 +0000
@@ -23,7 +23,6 @@
 #include <sys/time.h>
 #endif
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
 #include "graphic/font.h"
 #include "graphic/font_handler.h"

=== modified file 'src/ui_basic/spinbox.cc'
--- src/ui_basic/spinbox.cc	2014-09-30 05:41:55 +0000
+++ src/ui_basic/spinbox.cc	2014-11-28 17:01:11 +0000
@@ -23,7 +23,6 @@
 
 #include <boost/format.hpp>
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
 #include "base/wexception.h"
 #include "ui_basic/button.h"

=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc	2014-11-22 10:18:20 +0000
+++ src/ui_basic/table.cc	2014-11-28 17:01:11 +0000
@@ -21,7 +21,6 @@
 
 #include <boost/bind.hpp>
 
-#include "base/deprecated.h"
 #include "graphic/font.h"
 #include "graphic/font_handler.h"
 #include "graphic/font_handler1.h"

=== modified file 'src/wui/CMakeLists.txt'
--- src/wui/CMakeLists.txt	2014-10-13 15:04:50 +0000
+++ src/wui/CMakeLists.txt	2014-11-28 17:01:11 +0000
@@ -129,7 +129,6 @@
     watchwindow.h
   USES_SDL2
   DEPENDS
-    base_deprecated
     base_exceptions
     base_geometry
     base_i18n

=== modified file 'src/wui/actionconfirm.cc'
--- src/wui/actionconfirm.cc	2014-11-13 08:25:45 +0000
+++ src/wui/actionconfirm.cc	2014-11-28 17:01:11 +0000
@@ -46,7 +46,8 @@
 		 Widelands::Ship & ship);
 
 	InteractivePlayer & iaplayer() const {
-		return ref_cast<InteractivePlayer, UI::Panel>(*get_parent());
+		upcast(InteractivePlayer, result, get_parent());
+		return *result;
 	}
 
 	virtual void think() = 0;

=== modified file 'src/wui/building_statistics_menu.cc'
--- src/wui/building_statistics_menu.cc	2014-10-28 14:57:52 +0000
+++ src/wui/building_statistics_menu.cc	2014-11-28 17:01:11 +0000
@@ -65,7 +65,8 @@
 namespace Columns {enum {Name, Size, Prod, Owned, Build};}
 
 inline InteractivePlayer & BuildingStatisticsMenu::iplayer() const {
-	return ref_cast<InteractivePlayer, UI::Panel>(*get_parent());
+	upcast(InteractivePlayer, result, get_parent());
+	return *result;
 }
 
 BuildingStatisticsMenu::BuildingStatisticsMenu
@@ -418,11 +419,10 @@
 				++nr_build;
 			else {
 				++nr_owned;
-				if (productionsite)
-					total_prod +=
-						ref_cast<Widelands::ProductionSite, Widelands::BaseImmovable>
-							(*map[vec[l].pos].get_immovable())
-						.get_statistics_percent();
+				if (productionsite) {
+					upcast(Widelands::ProductionSite, psite, map[vec[l].pos].get_immovable());
+					total_prod += psite->get_statistics_percent();
+				}
 			}
 		}
 

=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc	2014-11-24 07:25:21 +0000
+++ src/wui/buildingwindow.cc	2014-11-28 17:01:11 +0000
@@ -378,7 +378,8 @@
 			igbase().game().send_player_bulldoze(m_building);
 	}
 	else {
-		show_bulldoze_confirm(ref_cast<InteractivePlayer, InteractiveGameBase>(igbase()), m_building);
+		upcast(InteractivePlayer, iaplayer, &igbase());
+		show_bulldoze_confirm(*iaplayer, m_building);
 	}
 }
 
@@ -394,7 +395,8 @@
 			igbase().game().send_player_dismantle(m_building);
 	}
 	else {
-		show_dismantle_confirm(ref_cast<InteractivePlayer, InteractiveGameBase>(igbase()), m_building);
+		upcast(InteractivePlayer, iaplayer, &igbase());
+		show_dismantle_confirm(*iaplayer, m_building);
 	}
 }
 
@@ -437,10 +439,8 @@
 			igbase().game().send_player_enhance_building(m_building, id);
 	}
 	else {
-		show_enhance_confirm
-			(ref_cast<InteractivePlayer, InteractiveGameBase>(igbase()),
-			 m_building,
-			 id);
+		upcast(InteractivePlayer, iaplayer, &igbase());
+		show_enhance_confirm(*iaplayer, m_building, id);
 	}
 }
 

=== modified file 'src/wui/buildingwindow.h'
--- src/wui/buildingwindow.h	2014-09-10 14:48:40 +0000
+++ src/wui/buildingwindow.h	2014-11-28 17:01:11 +0000
@@ -47,7 +47,8 @@
 	Widelands::Building & building() {return m_building;}
 
 	InteractiveGameBase & igbase() const {
-		return ref_cast<InteractiveGameBase, UI::Panel>(*get_parent());
+		upcast(InteractiveGameBase, result, get_parent());
+		return *result;
 	}
 
 	void draw(RenderTarget &) override;

=== modified file 'src/wui/constructionsitewindow.cc'
--- src/wui/constructionsitewindow.cc	2014-09-10 14:48:40 +0000
+++ src/wui/constructionsitewindow.cc	2014-11-28 17:01:11 +0000
@@ -84,11 +84,8 @@
 void ConstructionSiteWindow::think()
 {
 	BuildingWindow::think();
-
-	const Widelands::ConstructionSite & cs =
-		ref_cast<Widelands::ConstructionSite, Widelands::Building>(building());
-
-	m_progress->set_state(cs.get_built_per64k());
+	upcast(Widelands::ConstructionSite, cs, &building());
+	m_progress->set_state(cs->get_built_per64k());
 }
 
 

=== modified file 'src/wui/dismantlesitewindow.cc'
--- src/wui/dismantlesitewindow.cc	2014-09-10 14:48:40 +0000
+++ src/wui/dismantlesitewindow.cc	2014-11-28 17:01:11 +0000
@@ -78,11 +78,8 @@
 void DismantleSiteWindow::think()
 {
 	BuildingWindow::think();
-
-	const Widelands::DismantleSite & ds =
-		ref_cast<Widelands::DismantleSite, Widelands::Building>(building());
-
-	m_progress->set_state(ds.get_built_per64k());
+	upcast(Widelands::DismantleSite, ds, &building());
+	m_progress->set_state(ds->get_built_per64k());
 }
 
 

=== modified file 'src/wui/encyclopedia_window.cc'
--- src/wui/encyclopedia_window.cc	2014-10-28 14:57:52 +0000
+++ src/wui/encyclopedia_window.cc	2014-11-28 17:01:11 +0000
@@ -51,7 +51,8 @@
 using namespace Widelands;
 
 inline InteractivePlayer & EncyclopediaWindow::iaplayer() const {
-	return ref_cast<InteractivePlayer, UI::Panel>(*get_parent());
+	upcast(InteractivePlayer, result, get_parent());
+	return *result;
 }
 
 
@@ -141,10 +142,8 @@
 	condTable.clear();
 	const TribeDescr & tribe = iaplayer().player().tribe();
 
-	const ProductionSiteDescr::Programs & programs =
-		ref_cast<ProductionSiteDescr const, BuildingDescr const>
-			(*tribe.get_building_descr(prodSites.get_selected()))
-		.programs();
+	upcast(ProductionSiteDescr const, descr, tribe.get_building_descr(prodSites.get_selected()));
+	const ProductionSiteDescr::Programs & programs = descr->programs();
 
 	//  TODO(unknown): This needs reworking. A program can indeed produce iron even if
 	//  the program name is not any of produce_iron, smelt_iron, prog_iron

=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc	2014-11-13 08:25:45 +0000
+++ src/wui/fieldaction.cc	2014-11-28 17:01:11 +0000
@@ -177,7 +177,8 @@
 	~FieldActionWindow();
 
 	InteractiveBase & ibase() {
-		return ref_cast<InteractiveBase, UI::Panel>(*get_parent());
+		upcast(InteractiveBase, result, get_parent());
+		return *result;
 	}
 
 	void think() override;
@@ -656,8 +657,8 @@
 */
 void FieldActionWindow::act_watch()
 {
-	show_watch_window
-		(ref_cast<InteractiveGameBase, InteractiveBase>(ibase()), m_node);
+	upcast(InteractiveGameBase, igbase, &ibase());
+	show_watch_window(*igbase, m_node);
 	okdialog();
 }
 
@@ -710,9 +711,10 @@
 
 	if (ibase().is_building_road())
 		ibase().finish_build_road();
-	else if (game)
-		ref_cast<InteractivePlayer, InteractiveBase>(ibase())
-			.set_flag_to_connect(m_node);
+	else if (game) {
+		upcast(InteractivePlayer, iaplayer, &ibase());
+		iaplayer->set_flag_to_connect(m_node);
+	}
 
 	okdialog();
 }
@@ -734,22 +736,22 @@
 {
 	okdialog();
 	Widelands::EditorGameBase & egbase = ibase().egbase();
+	upcast(Game, game, &egbase);
+	upcast(InteractivePlayer, iaplayer, &ibase());
+
 	if (upcast(Widelands::Flag, flag, m_node.field->get_immovable())) {
 		if (Building * const building = flag->get_building()) {
 			if (building->get_playercaps() & Building::PCap_Bulldoze) {
 				if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
-					ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
+					game->send_player_bulldoze
 						(*flag, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
 				}
 				else {
-					show_bulldoze_confirm
-						(ref_cast<InteractivePlayer, InteractiveBase>(ibase()),
-						 *building,
-						 flag);
+					show_bulldoze_confirm(*iaplayer, *building, flag);
 				}
 			}
 		} else {
-			ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
+			game->send_player_bulldoze
 					(*flag, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
 		}
 	}
@@ -792,9 +794,11 @@
 void FieldActionWindow::act_removeroad()
 {
 	Widelands::EditorGameBase & egbase = ibase().egbase();
-	if (upcast(Widelands::Road, road, egbase.map().get_immovable(m_node)))
-		ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
+	if (upcast(Widelands::Road, road, egbase.map().get_immovable(m_node))) {
+		upcast(Game, game, &ibase().egbase());
+		game->send_player_bulldoze
 			(*road, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
+	}
 	okdialog();
 }
 
@@ -806,15 +810,12 @@
 */
 void FieldActionWindow::act_build(Widelands::BuildingIndex idx)
 {
-	Widelands::Game & game = ref_cast<Game, EditorGameBase>(ibase().egbase());
-	game.send_player_build
-		(ref_cast<InteractivePlayer, InteractiveBase>(ibase()).player_number(),
-		 m_node,
-		 Widelands::BuildingIndex(idx));
-	ibase().reference_player_tribe
-		(m_plr->player_number(), &m_plr->tribe());
-	ref_cast<InteractivePlayer, InteractiveBase>(ibase()).set_flag_to_connect
-		(game.map().br_n(m_node));
+	upcast(Game, game, &ibase().egbase());
+	upcast(InteractivePlayer, iaplayer, &ibase());
+
+	game->send_player_build(iaplayer->player_number(), m_node, Widelands::BuildingIndex(idx));
+	ibase().reference_player_tribe(m_plr->player_number(), &m_plr->tribe());
+	iaplayer->set_flag_to_connect(game->map().br_n(m_node));
 	okdialog();
 }
 
@@ -848,10 +849,10 @@
 */
 void FieldActionWindow::act_geologist()
 {
-	Game & game = ref_cast<Game, EditorGameBase>(ibase().egbase());
-	if (upcast(Widelands::Flag, flag, game.map().get_immovable(m_node)))
-		game.send_player_flagaction (*flag);
-
+	upcast(Game, game, &ibase().egbase());
+	if (upcast(Widelands::Flag, flag, game->map().get_immovable(m_node))) {
+		game->send_player_flagaction (*flag);
+	}
 	okdialog();
 }
 
@@ -863,15 +864,16 @@
  */
 void FieldActionWindow::act_attack ()
 {
-	Game & game = ref_cast<Game, EditorGameBase>(ibase().egbase());
-
 	assert(m_attack_box);
-	if (upcast(Building, building, game.map().get_immovable(m_node)))
-		if (m_attack_box->soldiers() > 0)
-			game.send_player_enemyflagaction(
+	upcast(Game, game, &ibase().egbase());
+	if (upcast(Building, building, game->map().get_immovable(m_node)))
+		if (m_attack_box->soldiers() > 0) {
+			upcast(InteractivePlayer const, iaplayer, &ibase());
+			game->send_player_enemyflagaction(
 			   building->base_flag(),
-			   ref_cast<const InteractivePlayer, const InteractiveBase>(ibase()).player_number(),
+				iaplayer->player_number(),
 			   m_attack_box->soldiers() /*  number of soldiers */);
+		}
 	okdialog();
 }
 
@@ -933,8 +935,8 @@
 			finish = true;
 		else if (dynamic_cast<const Widelands::Road *>(i))
 			if (player->get_buildcaps(target) & Widelands::BUILDCAPS_FLAG) {
-				ref_cast<Game, EditorGameBase>(player->egbase())
-					.send_player_build_flag(player->player_number(), target);
+				upcast(Game, game, &player->egbase());
+				game->send_player_build_flag(player->player_number(), target);
 				finish = true;
 			}
 		if (finish)

=== modified file 'src/wui/game_debug_ui.cc'
--- src/wui/game_debug_ui.cc	2014-10-27 10:14:10 +0000
+++ src/wui/game_debug_ui.cc	2014-11-28 17:01:11 +0000
@@ -133,7 +133,8 @@
 	MapObjectDebugWindow(InteractiveBase & parent, Widelands::MapObject &);
 
 	InteractiveBase & ibase() {
-		return ref_cast<InteractiveBase, UI::Panel>(*get_parent());
+		upcast(InteractiveBase, result, get_parent());
+		return *result;
 	}
 
 	void think() override;
@@ -212,7 +213,8 @@
 	FieldDebugWindow(InteractiveBase & parent, Widelands::Coords);
 
 	InteractiveBase & ibase() {
-		return ref_cast<InteractiveBase, UI::Panel>(*get_parent());
+		upcast(InteractiveBase, result, get_parent());
+		return *result;
 	}
 
 	void think() override;
@@ -273,9 +275,7 @@
 	UI::Window::think();
 
 	// Select information about the field itself
-	const Widelands::EditorGameBase & egbase =
-		ref_cast<InteractiveBase const, UI::Panel const>(*get_parent())
-		.egbase();
+	const Widelands::EditorGameBase & egbase = ibase().egbase();
 	{
 		Widelands::PlayerNumber const owner = m_coords.field->get_owned_by();
 		str += (boost::format("(%i, %i)\nheight: %u\nowner: %u\n")

=== modified file 'src/wui/game_main_menu_save_game.cc'
--- src/wui/game_main_menu_save_game.cc	2014-10-27 10:31:04 +0000
+++ src/wui/game_main_menu_save_game.cc	2014-11-28 17:01:11 +0000
@@ -35,7 +35,8 @@
 #include "wui/interactive_gamebase.h"
 
 InteractiveGameBase & GameMainMenuSaveGame::igbase() {
-	return ref_cast<InteractiveGameBase, UI::Panel>(*get_parent());
+	upcast(InteractiveGameBase, result, get_parent());
+	return *result;
 }
 
 #define WINDOW_WIDTH                                                        440
@@ -262,7 +263,8 @@
 	{}
 
 	GameMainMenuSaveGame & menu_save_game() {
-		return ref_cast<GameMainMenuSaveGame, UI::Panel>(*get_parent());
+		upcast(GameMainMenuSaveGame, result, get_parent());
+		return *result;
 	}
 
 
@@ -328,7 +330,8 @@
 	void pressed_yes() override
 	{
 		g_fs->fs_unlink(m_filename);
-		ref_cast<GameMainMenuSaveGame, UI::Panel>(*get_parent()).fill_list();
+		upcast(GameMainMenuSaveGame, panel, get_parent());
+		panel->fill_list();
 		die();
 	}
 

=== modified file 'src/wui/game_main_menu_save_game.h'
--- src/wui/game_main_menu_save_game.h	2014-09-10 13:03:40 +0000
+++ src/wui/game_main_menu_save_game.h	2014-11-28 17:01:11 +0000
@@ -20,7 +20,6 @@
 #ifndef WL_WUI_GAME_MAIN_MENU_SAVE_GAME_H
 #define WL_WUI_GAME_MAIN_MENU_SAVE_GAME_H
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
 #include "ui_basic/button.h"
 #include "ui_basic/editbox.h"

=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc	2014-11-22 10:18:20 +0000
+++ src/wui/game_message_menu.cc	2014-11-28 17:01:11 +0000
@@ -21,7 +21,7 @@
 
 #include <boost/bind.hpp>
 
-#include "base/deprecated.h"
+#include "base/macros.h"
 #include "base/time_string.h"
 #include "graphic/graphic.h"
 #include "logic/instances.h"
@@ -35,7 +35,8 @@
 using Widelands::MessageQueue;
 
 inline InteractivePlayer & GameMessageMenu::iplayer() const {
-	return ref_cast<InteractivePlayer, UI::Panel>(*get_parent());
+	upcast(InteractivePlayer, result, get_parent());
+	return *result;
 }
 
 

=== modified file 'src/wui/game_message_menu.h'
--- src/wui/game_message_menu.h	2014-10-14 06:30:20 +0000
+++ src/wui/game_message_menu.h	2014-11-28 17:01:11 +0000
@@ -20,7 +20,6 @@
 #ifndef WL_WUI_GAME_MESSAGE_MENU_H
 #define WL_WUI_GAME_MESSAGE_MENU_H
 
-#include "base/deprecated.h"
 #include "base/i18n.h"
 #include "logic/message_queue.h"
 #include "ui_basic/button.h"

=== modified file 'src/wui/game_objectives_menu.cc'
--- src/wui/game_objectives_menu.cc	2014-10-27 10:31:04 +0000
+++ src/wui/game_objectives_menu.cc	2014-11-28 17:01:11 +0000
@@ -31,7 +31,8 @@
 
 
 inline InteractivePlayer & GameObjectivesMenu::iplayer() const {
-	return ref_cast<InteractivePlayer, UI::Panel>(*get_parent());
+	upcast(InteractivePlayer, result, get_parent());
+	return *result;
 }
 
 

=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc	2014-11-22 11:32:06 +0000
+++ src/wui/general_statistics_menu.cc	2014-11-28 17:01:11 +0000
@@ -284,7 +284,8 @@
 }
 
 GeneralStatisticsMenu::~GeneralStatisticsMenu() {
-	Game & game = ref_cast<InteractiveGameBase, UI::Panel>(*get_parent()).game();
+	upcast(InteractiveGameBase, igbase, get_parent());
+	Game & game = igbase->game();
 	if (game.is_loaded()) {
 		// Save informations for recreation, if window is reopened
 		m_my_registry->selected_information = m_selected_information;
@@ -320,9 +321,8 @@
  * The radiogroup has changed
  */
 void GeneralStatisticsMenu::radiogroup_changed(int32_t const id) {
-	size_t const statistics_size =
-		ref_cast<InteractiveGameBase, UI::Panel>(*get_parent()).game()
-		.get_general_statistics().size();
+	upcast(InteractiveGameBase, igbase, get_parent());
+	size_t const statistics_size = igbase->game().get_general_statistics().size();
 	for (uint32_t i = 0; i < statistics_size; ++i)
 		if (m_cbs[i]) {
 			m_plot.show_plot

=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc	2014-11-27 11:15:34 +0000
+++ src/wui/interactive_base.cc	2014-11-28 17:01:11 +0000
@@ -446,7 +446,8 @@
 			((fps_format %
 			  (1000.0 / m_frametime) % (1000.0 / (m_avg_usframetime / 1000)))
 			 .str(), UI_FONT_SIZE_SMALL);
-		dst.blit(Point(5, (is_game) ? 25 : 5), UI::g_fh1->render(fps_text), BlendMode::UseAlpha, UI::Align_Left);
+		dst.blit(Point(5, (is_game) ? 25 : 5),
+					UI::g_fh1->render(fps_text), BlendMode::UseAlpha, UI::Align_Left);
 	}
 }
 

=== modified file 'src/wui/interactive_gamebase.cc'
--- src/wui/interactive_gamebase.cc	2014-09-20 09:37:47 +0000
+++ src/wui/interactive_gamebase.cc	2014-11-28 17:01:11 +0000
@@ -53,7 +53,8 @@
 
 Widelands::Game & InteractiveGameBase::    game() const
 {
-	return ref_cast<Widelands::Game, Widelands::EditorGameBase>(egbase());
+	upcast(Widelands::Game, result, &egbase());
+	return *result;
 }
 
 void InteractiveGameBase::set_chat_provider(ChatProvider & chat)

=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc	2014-11-23 14:34:38 +0000
+++ src/wui/interactive_player.cc	2014-11-28 17:01:11 +0000
@@ -304,8 +304,8 @@
 	(Widelands::MessageId const id, const Widelands::Message & message)
 {
 	m_message_menu.create();
-	ref_cast<GameMessageMenu, UI::UniqueWindow>(*m_message_menu.window)
-	.show_new_message(id, message);
+	upcast(GameMessageMenu, menu, m_message_menu.window);
+	menu->show_new_message(id, message);
 }
 
 
@@ -470,10 +470,9 @@
 		for (uint16_t x = 0; x < extent.w; ++x)
 			overlay_manager.recalc_field_overlays
 				(map.get_fcoords(Widelands::Coords(x, y)));
-	if
-		(UI::UniqueWindow * const building_statistics_window =
-		 	m_mainm_windows.building_stats.window)
-		ref_cast<BuildingStatisticsMenu, UI::UniqueWindow>
-			(*building_statistics_window)
-			.update();
+	if (UI::UniqueWindow * const building_statistics_window =
+		 m_mainm_windows.building_stats.window) {
+		upcast(BuildingStatisticsMenu, menu, building_statistics_window);
+		menu->update();
+	}
 }

=== modified file 'src/wui/interactive_spectator.cc'
--- src/wui/interactive_spectator.cc	2014-11-23 14:34:38 +0000
+++ src/wui/interactive_spectator.cc	2014-11-28 17:01:11 +0000
@@ -275,8 +275,8 @@
 			if (!m_chat.window)
 				GameChatMenu::create_chat_console(this, m_chat, *m_chatProvider);
 
-			ref_cast<GameChatMenu, UI::UniqueWindow>(*m_chat.window)
-				.enter_chat_message();
+			// NOCOM(#gunchleoc): Compiler did not like upcast. Is dynamic_cast OK?
+			dynamic_cast<GameChatMenu*>(m_chat.window)->enter_chat_message();
 			return true;
 
 		default:

=== modified file 'src/wui/militarysitewindow.cc'
--- src/wui/militarysitewindow.cc	2014-09-10 13:03:40 +0000
+++ src/wui/militarysitewindow.cc	2014-11-28 17:01:11 +0000
@@ -38,7 +38,8 @@
 		 UI::Window *       & registry);
 
 	MilitarySite & militarysite() {
-		return ref_cast<MilitarySite, Widelands::Building>(building());
+		upcast(MilitarySite, result, &building());
+		return *result;
 	}
 
 protected:

=== modified file 'src/wui/minimap.cc'
--- src/wui/minimap.cc	2014-11-24 07:10:03 +0000
+++ src/wui/minimap.cc	2014-11-28 17:01:11 +0000
@@ -98,7 +98,8 @@
 
 	m_ibase.egbase().map().normalize_coords(c);
 
-	ref_cast<MiniMap, UI::Panel>(*get_parent()).warpview(c.x * TRIANGLE_WIDTH, c.y * TRIANGLE_HEIGHT);
+	upcast(MiniMap, minimap, get_parent());
+	minimap->warpview(c.x * TRIANGLE_WIDTH, c.y * TRIANGLE_HEIGHT);
 
 	return true;
 }

=== modified file 'src/wui/productionsitewindow.h'
--- src/wui/productionsitewindow.h	2014-09-10 13:03:40 +0000
+++ src/wui/productionsitewindow.h	2014-11-28 17:01:11 +0000
@@ -31,7 +31,8 @@
 		 UI::Window *         & registry);
 
 	Widelands::ProductionSite & productionsite() {
-		return ref_cast<Widelands::ProductionSite, Widelands::Building>(building());
+		upcast(Widelands::ProductionSite, result, &building());
+		return *result;
 	}
 	void update_worker_table();
 protected:

=== modified file 'src/wui/shipwindow.cc'
--- src/wui/shipwindow.cc	2014-11-22 10:18:20 +0000
+++ src/wui/shipwindow.cc	2014-11-28 17:01:11 +0000
@@ -295,7 +295,8 @@
 		m_igbase.game().send_player_sink_ship(m_ship);
 	}
 	else {
-		show_ship_sink_confirm(ref_cast<InteractivePlayer, InteractiveGameBase>(m_igbase), m_ship);
+		upcast(InteractivePlayer, iaplayer, &m_igbase);
+		show_ship_sink_confirm(*iaplayer, m_ship);
 	}
 }
 
@@ -306,8 +307,8 @@
 		m_igbase.game().send_player_cancel_expedition_ship(m_ship);
 	}
 	else {
-		show_ship_cancel_expedition_confirm
-			(ref_cast<InteractivePlayer, InteractiveGameBase>(m_igbase), m_ship);
+		upcast(InteractivePlayer, iaplayer, &m_igbase);
+		show_ship_cancel_expedition_confirm(*iaplayer, m_ship);
 	}
 }
 

=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc	2014-11-22 10:18:20 +0000
+++ src/wui/soldierlist.cc	2014-11-28 17:01:11 +0000
@@ -22,7 +22,6 @@
 #include <boost/bind.hpp>
 #include <boost/format.hpp>
 
-#include "base/deprecated.h"
 #include "base/macros.h"
 #include "graphic/font.h"
 #include "graphic/graphic.h"

=== modified file 'src/wui/trainingsitewindow.cc'
--- src/wui/trainingsitewindow.cc	2014-09-10 13:03:40 +0000
+++ src/wui/trainingsitewindow.cc	2014-11-28 17:01:11 +0000
@@ -37,7 +37,8 @@
 		(InteractiveGameBase & parent, TrainingSite &, UI::Window * & registry);
 
 	TrainingSite & trainingsite() {
-		return ref_cast<TrainingSite, Widelands::Building>(building());
+		upcast(TrainingSite, result, &building());
+		return *result;
 	}
 
 protected:

=== modified file 'src/wui/transport_ui.cc'
--- src/wui/transport_ui.cc	2014-11-22 11:32:06 +0000
+++ src/wui/transport_ui.cc	2014-11-28 17:01:11 +0000
@@ -159,10 +159,10 @@
 						m_economy.ware_target_quantity(id);
 					if (1 < tq.permanent) {
 						Widelands::Player & player = m_economy.owner();
-						Game & game = ref_cast<Game, EditorGameBase>(player.egbase());
-						game.send_player_command
+						upcast(Game, game, &player.egbase());
+						game->send_player_command
 							(*new Widelands::CmdSetWareTargetQuantity
-								(game.get_gametime(), player.player_number(),
+								(game->get_gametime(), player.player_number(),
 								 player.get_economy_number(&m_economy), id,
 								 tq.permanent - 1));
 					}
@@ -181,10 +181,10 @@
 					const Economy::TargetQuantity & tq =
 						m_economy.ware_target_quantity(id);
 					Widelands::Player & player = m_economy.owner();
-					Game & game = ref_cast<Game, EditorGameBase>(player.egbase());
-					game.send_player_command
+					upcast(Game, game, &player.egbase());
+					game->send_player_command
 						(*new Widelands::CmdSetWareTargetQuantity
-							(game.get_gametime(), player.player_number(),
+							(game->get_gametime(), player.player_number(),
 							 player.get_economy_number(&m_economy), id,
 							 tq.permanent + 1));
 				}
@@ -200,10 +200,10 @@
 			{
 				if (m_display.ware_selected(id)) {
 					Widelands::Player & player = m_economy.owner();
-					Game & game = ref_cast<Game, EditorGameBase>(player.egbase());
-					game.send_player_command
+					upcast(Game, game, &player.egbase());
+					game->send_player_command
 						(*new Widelands::CmdResetWareTargetQuantity
-							(game.get_gametime(), player.player_number(),
+							(game->get_gametime(), player.player_number(),
 							 player.get_economy_number(&m_economy), id));
 				}
 			}
@@ -256,10 +256,10 @@
 						m_economy.worker_target_quantity(id);
 					if (1 < tq.permanent) {
 						Widelands::Player & player = m_economy.owner();
-						Game & game = ref_cast<Game, EditorGameBase>(player.egbase());
-						game.send_player_command
+						upcast(Game, game, &player.egbase());
+						game->send_player_command
 							(*new Widelands::CmdSetWorkerTargetQuantity
-								(game.get_gametime(), player.player_number(),
+								(game->get_gametime(), player.player_number(),
 								 player.get_economy_number(&m_economy), id,
 								 tq.permanent - 1));
 					}
@@ -278,10 +278,10 @@
 					const Economy::TargetQuantity & tq =
 						m_economy.worker_target_quantity(id);
 					Widelands::Player & player = m_economy.owner();
-					Game & game = ref_cast<Game, EditorGameBase>(player.egbase());
-					game.send_player_command
+					upcast(Game, game, &player.egbase());
+					game->send_player_command
 						(*new Widelands::CmdSetWorkerTargetQuantity
-							(game.get_gametime(), player.player_number(),
+							(game->get_gametime(), player.player_number(),
 							 player.get_economy_number(&m_economy), id,
 							 tq.permanent + 1));
 				}
@@ -296,10 +296,10 @@
 			{
 				if (m_display.ware_selected(id)) {
 					Widelands::Player & player = m_economy.owner();
-					Game & game = ref_cast<Game, EditorGameBase>(player.egbase());
-					game.send_player_command
+					upcast(Game, game, &player.egbase());
+					game->send_player_command
 						(*new Widelands::CmdResetWorkerTargetQuantity
-							(game.get_gametime(), player.player_number(),
+							(game->get_gametime(), player.player_number(),
 							 player.get_economy_number(&m_economy), id));
 				}
 			}
@@ -313,11 +313,10 @@
 // users can register for change updates. The registry should be
 // moved to InteractivePlayer or some other UI component.
 void Economy::show_options_window() {
-	if (m_optionswindow_registry.window)
+	if (m_optionswindow_registry.window) {
 		m_optionswindow_registry.window->move_to_top();
-	else
-		new EconomyOptionsWindow
-			(ref_cast<InteractiveGameBase, InteractiveBase>
-			 	(*owner().egbase().get_ibase()),
-			 *this);
+	} else {
+		upcast(InteractiveGameBase, igbase, owner().egbase().get_ibase());
+		new EconomyOptionsWindow(*igbase, *this);
+	}
 }

=== modified file 'src/wui/warehousewindow.cc'
--- src/wui/warehousewindow.cc	2014-09-10 13:03:40 +0000
+++ src/wui/warehousewindow.cc	2014-11-28 17:01:11 +0000
@@ -176,7 +176,8 @@
 		(InteractiveGameBase & parent, Warehouse &, UI::Window * & registry);
 
 	Warehouse & warehouse() {
-		return ref_cast<Warehouse, Widelands::Building>(building());
+		upcast(Warehouse, result, &building());
+		return *result;
 	}
 };
 

=== modified file 'src/wui/watchwindow.cc'
--- src/wui/watchwindow.cc	2014-11-22 11:32:06 +0000
+++ src/wui/watchwindow.cc	2014-11-28 17:01:11 +0000
@@ -56,7 +56,8 @@
 	~WatchWindow();
 
 	Widelands::Game & game() const {
-		return ref_cast<InteractiveGameBase, UI::Panel>(*get_parent()).game();
+		upcast(InteractiveGameBase, igbase, get_parent());
+		return igbase->game();
 	}
 
 	boost::signals2::signal<void (Point)> warp_mainview;


Follow ups