summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ai/ai_config.hpp1
-rw-r--r--src/ai/ai_core.cpp1
-rw-r--r--src/ai/ai_gui.hpp2
-rw-r--r--src/ai/ai_info.cpp1
-rw-r--r--src/ai/ai_instance.cpp3
-rw-r--r--src/ai/ai_instance.hpp2
-rw-r--r--src/ai/ai_scanner.cpp1
-rw-r--r--src/ai/ai_scanner.hpp2
-rw-r--r--src/ai/ai_storage.hpp2
-rw-r--r--src/ai/api/ai_abstractlist.cpp1
-rw-r--r--src/ai/api/ai_controller.cpp2
-rw-r--r--src/ai/api/ai_engine.cpp1
-rw-r--r--src/ai/api/ai_execmode.cpp1
-rw-r--r--src/ai/api/ai_group.cpp1
-rw-r--r--src/ai/api/ai_industrytype.cpp1
-rw-r--r--src/ai/api/ai_list.cpp1
-rw-r--r--src/ai/api/ai_map.cpp1
-rw-r--r--src/ai/api/ai_object.cpp2
-rw-r--r--src/ai/api/ai_rail.cpp1
-rw-r--r--src/ai/api/ai_road.cpp1
-rw-r--r--src/ai/api/ai_station.cpp1
-rw-r--r--src/ai/api/ai_testmode.cpp1
-rw-r--r--src/ai/api/ai_tile.cpp1
-rw-r--r--src/ai/api/ai_vehicle.cpp1
-rw-r--r--src/aircraft.h2
-rw-r--r--src/aircraft_cmd.cpp7
-rw-r--r--src/aircraft_gui.cpp1
-rw-r--r--src/airport.h1
-rw-r--r--src/airport_gui.cpp1
-rw-r--r--src/articulated_vehicles.cpp2
-rw-r--r--src/autoreplace_base.h2
-rw-r--r--src/autoreplace_cmd.cpp1
-rw-r--r--src/autoreplace_func.h4
-rw-r--r--src/autoreplace_gui.cpp2
-rw-r--r--src/autoreplace_gui.h2
-rw-r--r--src/autoslope.h3
-rw-r--r--src/base_media_func.h3
-rw-r--r--src/base_station_base.h5
-rw-r--r--src/blitter/32bpp_anim.cpp1
-rw-r--r--src/blitter/32bpp_anim.hpp1
-rw-r--r--src/blitter/32bpp_base.cpp1
-rw-r--r--src/blitter/32bpp_base.hpp1
-rw-r--r--src/blitter/32bpp_optimized.cpp1
-rw-r--r--src/blitter/32bpp_simple.cpp1
-rw-r--r--src/blitter/base.hpp1
-rw-r--r--src/bridge.h1
-rw-r--r--src/bridge_gui.cpp2
-rw-r--r--src/bridge_map.h3
-rw-r--r--src/build_vehicle_gui.cpp9
-rw-r--r--src/cargopacket.h1
-rw-r--r--src/clear_cmd.cpp1
-rw-r--r--src/company_base.h3
-rw-r--r--src/company_cmd.cpp1
-rw-r--r--src/company_func.h2
-rw-r--r--src/company_gui.cpp4
-rw-r--r--src/console.cpp1
-rw-r--r--src/console_cmds.cpp1
-rw-r--r--src/console_gui.cpp1
-rw-r--r--src/console_internal.h2
-rw-r--r--src/core/mem_func.hpp1
-rw-r--r--src/core/sort_func.hpp2
-rw-r--r--src/crashlog.cpp2
-rw-r--r--src/date_gui.cpp2
-rw-r--r--src/date_gui.h3
-rw-r--r--src/debug.cpp2
-rw-r--r--src/depot_base.h2
-rw-r--r--src/depot_func.h1
-rw-r--r--src/depot_gui.cpp3
-rw-r--r--src/depot_map.h3
-rw-r--r--src/disaster_cmd.cpp2
-rw-r--r--src/dock_gui.cpp1
-rw-r--r--src/driver.cpp1
-rw-r--r--src/driver.h1
-rw-r--r--src/economy.cpp4
-rw-r--r--src/economy_func.h7
-rw-r--r--src/economy_type.h1
-rw-r--r--src/effectvehicle.cpp1
-rw-r--r--src/effectvehicle_func.h2
-rw-r--r--src/elrail.cpp2
-rw-r--r--src/elrail_func.h3
-rw-r--r--src/engine.cpp4
-rw-r--r--src/engine_base.h3
-rw-r--r--src/engine_func.h2
-rw-r--r--src/engine_gui.h2
-rw-r--r--src/engine_type.h3
-rw-r--r--src/fontcache.h1
-rw-r--r--src/functions.h2
-rw-r--r--src/gamelog.cpp1
-rw-r--r--src/gamelog_internal.h1
-rw-r--r--src/genworld.cpp1
-rw-r--r--src/genworld_gui.cpp3
-rw-r--r--src/gfx_type.h1
-rw-r--r--src/gfxinit.cpp1
-rw-r--r--src/graph_gui.cpp1
-rw-r--r--src/group_gui.cpp4
-rw-r--r--src/group_gui.h1
-rw-r--r--src/gui.h1
-rw-r--r--src/highscore.cpp1
-rw-r--r--src/highscore.h2
-rw-r--r--src/highscore_gui.cpp1
-rw-r--r--src/industry.h6
-rw-r--r--src/industry_cmd.cpp3
-rw-r--r--src/industry_gui.cpp3
-rw-r--r--src/industry_map.h1
-rw-r--r--src/industrytype.h4
-rw-r--r--src/intro_gui.cpp1
-rw-r--r--src/landscape.cpp1
-rw-r--r--src/landscape.h2
-rw-r--r--src/main_gui.cpp1
-rw-r--r--src/misc/array.hpp1
-rw-r--r--src/misc/blob.hpp1
-rw-r--r--src/misc/dbg_helpers.h7
-rw-r--r--src/misc/fixedsizearray.hpp1
-rw-r--r--src/misc/str.hpp1
-rw-r--r--src/misc_gui.cpp1
-rw-r--r--src/music.cpp1
-rw-r--r--src/music/extmidi.cpp1
-rw-r--r--src/music/win32_m.cpp1
-rw-r--r--src/music_gui.cpp3
-rw-r--r--src/network/core/core.cpp1
-rw-r--r--src/network/core/core.h1
-rw-r--r--src/network/core/host.h2
-rw-r--r--src/network/core/tcp.h2
-rw-r--r--src/network/core/tcp_game.cpp1
-rw-r--r--src/network/core/tcp_game.h2
-rw-r--r--src/network/core/udp.cpp1
-rw-r--r--src/network/core/udp.h3
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network.h1
-rw-r--r--src/network/network_base.h2
-rw-r--r--src/network/network_chat_gui.cpp4
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_client.h2
-rw-r--r--src/network/network_command.cpp4
-rw-r--r--src/network/network_content.h1
-rw-r--r--src/network/network_content_gui.cpp1
-rw-r--r--src/network/network_func.h2
-rw-r--r--src/network/network_gui.cpp4
-rw-r--r--src/network/network_gui.h2
-rw-r--r--src/network/network_internal.h6
-rw-r--r--src/network/network_server.cpp5
-rw-r--r--src/network/network_server.h2
-rw-r--r--src/network/network_type.h3
-rw-r--r--src/network/network_udp.cpp2
-rw-r--r--src/network/network_udp.h2
-rw-r--r--src/newgrf.cpp3
-rw-r--r--src/newgrf.h1
-rw-r--r--src/newgrf_canal.cpp2
-rw-r--r--src/newgrf_canal.h4
-rw-r--r--src/newgrf_cargo.cpp1
-rw-r--r--src/newgrf_commons.h1
-rw-r--r--src/newgrf_engine.cpp2
-rw-r--r--src/newgrf_engine.h3
-rw-r--r--src/newgrf_generic.cpp1
-rw-r--r--src/newgrf_generic.h3
-rw-r--r--src/newgrf_gui.cpp2
-rw-r--r--src/newgrf_house.cpp4
-rw-r--r--src/newgrf_house.h1
-rw-r--r--src/newgrf_industries.cpp2
-rw-r--r--src/newgrf_industries.h1
-rw-r--r--src/newgrf_industrytiles.cpp4
-rw-r--r--src/newgrf_industrytiles.h5
-rw-r--r--src/newgrf_sound.h1
-rw-r--r--src/newgrf_spritegroup.cpp1
-rw-r--r--src/newgrf_spritegroup.h2
-rw-r--r--src/newgrf_station.cpp3
-rw-r--r--src/newgrf_station.h9
-rw-r--r--src/newgrf_text.h2
-rw-r--r--src/newgrf_town.h2
-rw-r--r--src/news_gui.cpp4
-rw-r--r--src/openttd.cpp4
-rw-r--r--src/order_cmd.cpp2
-rw-r--r--src/order_func.h1
-rw-r--r--src/order_gui.cpp4
-rw-r--r--src/os/unix/unix.cpp1
-rw-r--r--src/pathfinder/follow_track.hpp2
-rw-r--r--src/pathfinder/npf/npf.cpp6
-rw-r--r--src/pathfinder/npf/npf_func.h1
-rw-r--r--src/pathfinder/opf/opf_ship.cpp2
-rw-r--r--src/pathfinder/opf/opf_ship.h5
-rw-r--r--src/pathfinder/pathfinder_func.h1
-rw-r--r--src/pathfinder/pathfinder_type.h2
-rw-r--r--src/pathfinder/yapf/yapf.h2
-rw-r--r--src/pbs.cpp1
-rw-r--r--src/rail.h1
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/rail_gui.cpp2
-rw-r--r--src/rail_map.h1
-rw-r--r--src/road_cmd.cpp4
-rw-r--r--src/road_cmd.h1
-rw-r--r--src/road_func.h3
-rw-r--r--src/road_gui.cpp3
-rw-r--r--src/road_internal.h1
-rw-r--r--src/road_map.h1
-rw-r--r--src/roadstop_base.h2
-rw-r--r--src/roadveh.h4
-rw-r--r--src/roadveh_cmd.cpp7
-rw-r--r--src/saveload/afterload.cpp7
-rw-r--r--src/saveload/autoreplace_sl.cpp2
-rw-r--r--src/saveload/gamelog_sl.cpp1
-rw-r--r--src/saveload/industry_sl.cpp1
-rw-r--r--src/saveload/misc_sl.cpp2
-rw-r--r--src/saveload/oldloader.h1
-rw-r--r--src/saveload/oldloader_sl.cpp4
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/saveload/saveload_internal.h1
-rw-r--r--src/saveload/signs_sl.cpp1
-rw-r--r--src/saveload/station_sl.cpp1
-rw-r--r--src/saveload/vehicle_sl.cpp1
-rw-r--r--src/saveload/waypoint_sl.cpp1
-rw-r--r--src/script/script_info.hpp1
-rw-r--r--src/sdl.h1
-rw-r--r--src/settings.cpp3
-rw-r--r--src/settings_func.h1
-rw-r--r--src/settings_gui.cpp6
-rw-r--r--src/settings_internal.h1
-rw-r--r--src/ship.h3
-rw-r--r--src/ship_cmd.cpp5
-rw-r--r--src/signal.cpp1
-rw-r--r--src/signs_base.h2
-rw-r--r--src/signs_func.h1
-rw-r--r--src/signs_gui.cpp1
-rw-r--r--src/smallmap_gui.cpp2
-rw-r--r--src/sound.cpp1
-rw-r--r--src/sound/allegro_s.cpp1
-rw-r--r--src/sound/win32_s.cpp1
-rw-r--r--src/spritecache.cpp1
-rw-r--r--src/spriteloader/png.cpp1
-rw-r--r--src/spriteloader/spriteloader.hpp1
-rw-r--r--src/station.cpp1
-rw-r--r--src/station_base.h3
-rw-r--r--src/station_cmd.cpp4
-rw-r--r--src/station_func.h3
-rw-r--r--src/station_gui.cpp4
-rw-r--r--src/station_gui.h3
-rw-r--r--src/station_type.h1
-rw-r--r--src/statusbar_gui.cpp1
-rw-r--r--src/strings.cpp5
-rw-r--r--src/subsidy.cpp1
-rw-r--r--src/subsidy_func.h3
-rw-r--r--src/subsidy_gui.cpp2
-rw-r--r--src/terraform_gui.cpp2
-rw-r--r--src/texteff.cpp4
-rw-r--r--src/texteff.hpp1
-rw-r--r--src/tile_cmd.h7
-rw-r--r--src/tile_map.h2
-rw-r--r--src/tile_type.h1
-rw-r--r--src/tilehighlight_func.h2
-rw-r--r--src/tilehighlight_type.h2
-rw-r--r--src/timetable.h1
-rw-r--r--src/timetable_gui.cpp1
-rw-r--r--src/toolbar_gui.cpp2
-rw-r--r--src/town.h11
-rw-r--r--src/town_cmd.cpp4
-rw-r--r--src/town_gui.cpp1
-rw-r--r--src/town_map.h1
-rw-r--r--src/townname.cpp1
-rw-r--r--src/track_func.h1
-rw-r--r--src/train.h2
-rw-r--r--src/train_cmd.cpp9
-rw-r--r--src/train_gui.cpp1
-rw-r--r--src/transparency_gui.cpp1
-rw-r--r--src/tree_cmd.cpp2
-rw-r--r--src/tree_map.h2
-rw-r--r--src/tunnel_map.h4
-rw-r--r--src/tunnelbridge.h2
-rw-r--r--src/tunnelbridge_cmd.cpp3
-rw-r--r--src/tunnelbridge_map.h5
-rw-r--r--src/unmovable.h3
-rw-r--r--src/unmovable_cmd.cpp4
-rw-r--r--src/unmovable_map.h1
-rw-r--r--src/vehicle.cpp4
-rw-r--r--src/vehicle_base.h8
-rw-r--r--src/vehicle_cmd.cpp2
-rw-r--r--src/vehicle_func.h4
-rw-r--r--src/vehicle_gui.cpp7
-rw-r--r--src/vehicle_gui.h2
-rw-r--r--src/vehicle_gui_base.h1
-rw-r--r--src/vehiclelist.h3
-rw-r--r--src/video/allegro_v.cpp3
-rw-r--r--src/video/dedicated_v.cpp2
-rw-r--r--src/video/sdl_v.cpp1
-rw-r--r--src/viewport.cpp2
-rw-r--r--src/water.h4
-rw-r--r--src/water_cmd.cpp8
-rw-r--r--src/water_map.h1
-rw-r--r--src/waypoint_gui.cpp1
-rw-r--r--src/widget.cpp2
-rw-r--r--src/widget_type.h2
-rw-r--r--src/widgets/dropdown.cpp1
-rw-r--r--src/widgets/dropdown_func.h2
-rw-r--r--src/widgets/dropdown_type.h1
-rw-r--r--src/window.cpp1
-rw-r--r--src/window_gui.h3
-rw-r--r--src/window_type.h1
295 files changed, 308 insertions, 351 deletions
diff --git a/src/ai/ai_config.hpp b/src/ai/ai_config.hpp
index fb53b725b..302a9942d 100644
--- a/src/ai/ai_config.hpp
+++ b/src/ai/ai_config.hpp
@@ -15,6 +15,7 @@
#include <map>
#include "ai_info.hpp"
#include "../core/string_compare_type.hpp"
+#include "../company_type.h"
class AIConfig {
private:
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index eb93ecff3..9c730d867 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -17,7 +17,6 @@
#include "../network/network.h"
#include "../window_func.h"
#include "../command_func.h"
-#include "ai.hpp"
#include "ai_scanner.hpp"
#include "ai_instance.hpp"
#include "ai_config.hpp"
diff --git a/src/ai/ai_gui.hpp b/src/ai/ai_gui.hpp
index c5f0b705d..56d775a16 100644
--- a/src/ai/ai_gui.hpp
+++ b/src/ai/ai_gui.hpp
@@ -12,6 +12,8 @@
#ifndef AI_GUI_HPP
#define AI_GUI_HPP
+#include "../company_type.h"
+
void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY);
void ShowAIConfigWindow();
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp
index b753424e1..06fdc88ef 100644
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -14,7 +14,6 @@
#include <squirrel.h>
#include "../script/squirrel.hpp"
#include "../script/squirrel_helper.hpp"
-#include "ai.hpp"
#include "ai_info.hpp"
#include "ai_scanner.hpp"
#include "../settings_type.h"
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index d91fff0a1..d321214b0 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -11,10 +11,8 @@
#include "../stdafx.h"
#include "../debug.h"
-#include "../vehicle_base.h"
#include "../saveload/saveload.h"
#include "../gui.h"
-#include "table/strings.h"
#include <squirrel.h>
#include "../script/squirrel.hpp"
@@ -79,6 +77,7 @@
#include "api/ai_waypoint.hpp.sq"
#include "api/ai_waypointlist.hpp.sq"
+#include "../company_base.h"
#include "../fileio_func.h"
AIStorage::~AIStorage()
diff --git a/src/ai/ai_instance.hpp b/src/ai/ai_instance.hpp
index f0862ea9e..d9e519a7e 100644
--- a/src/ai/ai_instance.hpp
+++ b/src/ai/ai_instance.hpp
@@ -12,6 +12,8 @@
#ifndef AI_INSTANCE_HPP
#define AI_INSTANCE_HPP
+#include <squirrel.h>
+
/**
* The callback function when an AI suspends.
*/
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp
index 065d4e4c2..dc3dd0d1b 100644
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -19,7 +19,6 @@
#include "../script/squirrel.hpp"
#include "../script/squirrel_helper.hpp"
#include "../script/squirrel_class.hpp"
-#include "ai.hpp"
#include "ai_info.hpp"
#include "ai_scanner.hpp"
#include "api/ai_controller.hpp"
diff --git a/src/ai/ai_scanner.hpp b/src/ai/ai_scanner.hpp
index ff3ce7790..26fc385b4 100644
--- a/src/ai/ai_scanner.hpp
+++ b/src/ai/ai_scanner.hpp
@@ -12,8 +12,10 @@
#ifndef AI_SCANNER_HPP
#define AI_SCANNER_HPP
+#include <squirrel.h>
#include "../script/script_scanner.hpp"
#include "../core/string_compare_type.hpp"
+#include "ai.hpp"
#include <map>
class AIScanner : public ScriptScanner {
diff --git a/src/ai/ai_storage.hpp b/src/ai/ai_storage.hpp
index 2434782f6..3130418ce 100644
--- a/src/ai/ai_storage.hpp
+++ b/src/ai/ai_storage.hpp
@@ -19,8 +19,10 @@
#include "../signs_func.h"
#include "../tunnelbridge.h"
#include "../vehicle_func.h"
+#include "../road_type.h"
#include "../group.h"
+#include "table/strings.h"
#include <vector>
/**
diff --git a/src/ai/api/ai_abstractlist.cpp b/src/ai/api/ai_abstractlist.cpp
index 6194558eb..4d5cea3cb 100644
--- a/src/ai/api/ai_abstractlist.cpp
+++ b/src/ai/api/ai_abstractlist.cpp
@@ -9,7 +9,6 @@
/** @file ai_abstractlist.cpp Implementation of AIAbstractList. */
-#include <squirrel.h>
#include "ai_abstractlist.hpp"
#include "../../debug.h"
#include "../../script/squirrel.hpp"
diff --git a/src/ai/api/ai_controller.cpp b/src/ai/api/ai_controller.cpp
index 6852e1142..9084fbc4c 100644
--- a/src/ai/api/ai_controller.cpp
+++ b/src/ai/api/ai_controller.cpp
@@ -13,9 +13,7 @@
#include "../../string_func.h"
#include "../../company_base.h"
#include "../../rev.h"
-#include "table/strings.h"
-#include "../ai.hpp"
#include "ai_controller.hpp"
#include "../ai_storage.hpp"
#include "../ai_instance.hpp"
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp
index 157ee825d..3793b748c 100644
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -14,7 +14,6 @@
#include "../../company_func.h"
#include "../../company_base.h"
#include "../../strings_func.h"
-#include "../../settings_type.h"
#include "../../rail.h"
#include "../../engine_base.h"
#include "../../articulated_vehicles.h"
diff --git a/src/ai/api/ai_execmode.cpp b/src/ai/api/ai_execmode.cpp
index 680887770..0cede135f 100644
--- a/src/ai/api/ai_execmode.cpp
+++ b/src/ai/api/ai_execmode.cpp
@@ -10,7 +10,6 @@
/** @file ai_execmode.cpp Implementation of AIExecMode. */
#include "ai_execmode.hpp"
-#include "../../command_type.h"
#include "../../company_base.h"
#include "../../company_func.h"
#include "../ai_instance.hpp"
diff --git a/src/ai/api/ai_group.cpp b/src/ai/api/ai_group.cpp
index 0aad40cf5..b1ececbe1 100644
--- a/src/ai/api/ai_group.cpp
+++ b/src/ai/api/ai_group.cpp
@@ -16,7 +16,6 @@
#include "../../group.h"
#include "../../string_func.h"
#include "../../strings_func.h"
-#include "../../command_func.h"
#include "../../autoreplace_func.h"
#include "../../settings_func.h"
#include "table/strings.h"
diff --git a/src/ai/api/ai_industrytype.cpp b/src/ai/api/ai_industrytype.cpp
index 8bf892c8e..993a88993 100644
--- a/src/ai/api/ai_industrytype.cpp
+++ b/src/ai/api/ai_industrytype.cpp
@@ -14,6 +14,7 @@
#include "../../command_type.h"
#include "../../strings_func.h"
#include "../../industry.h"
+#include "../../core/random_func.hpp"
/* static */ bool AIIndustryType::IsValidIndustryType(IndustryType industry_type)
{
diff --git a/src/ai/api/ai_list.cpp b/src/ai/api/ai_list.cpp
index f93e504f1..4194d10e8 100644
--- a/src/ai/api/ai_list.cpp
+++ b/src/ai/api/ai_list.cpp
@@ -9,7 +9,6 @@
/** @file ai_list.cpp Implementation of AIList. */
-#include <squirrel.h>
#include "ai_list.hpp"
void AIList::AddItem(int32 item, int32 value)
diff --git a/src/ai/api/ai_map.cpp b/src/ai/api/ai_map.cpp
index d5728b9eb..c9432fa26 100644
--- a/src/ai/api/ai_map.cpp
+++ b/src/ai/api/ai_map.cpp
@@ -9,7 +9,6 @@
/** @file ai_map.cpp Implementation of AIMap. */
-#include "../../stdafx.h"
#include "ai_map.hpp"
#include "../../tile_map.h"
diff --git a/src/ai/api/ai_object.cpp b/src/ai/api/ai_object.cpp
index c6b0da1bc..eb9e247e7 100644
--- a/src/ai/api/ai_object.cpp
+++ b/src/ai/api/ai_object.cpp
@@ -14,8 +14,6 @@
#include "../../script/squirrel.hpp"
#include "../../company_base.h"
-#include "table/strings.h"
-#include "../ai.hpp"
#include "../ai_storage.hpp"
#include "../ai_instance.hpp"
#include "ai_error.hpp"
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp
index 39781bc44..eb2e01628 100644
--- a/src/ai/api/ai_rail.cpp
+++ b/src/ai/api/ai_rail.cpp
@@ -16,6 +16,7 @@
#include "../../debug.h"
#include "../../station_base.h"
#include "../../company_func.h"
+#include "../../newgrf.h"
#include "../../newgrf_generic.h"
#include "../../newgrf_station.h"
diff --git a/src/ai/api/ai_road.cpp b/src/ai/api/ai_road.cpp
index c221bbff0..c43eb64ec 100644
--- a/src/ai/api/ai_road.cpp
+++ b/src/ai/api/ai_road.cpp
@@ -9,7 +9,6 @@
/** @file ai_road.cpp Implementation of AIRoad. */
-#include "../../stdafx.h"
#include "ai_map.hpp"
#include "ai_station.hpp"
#include "ai_cargo.hpp"
diff --git a/src/ai/api/ai_station.cpp b/src/ai/api/ai_station.cpp
index af9d184c8..670355dff 100644
--- a/src/ai/api/ai_station.cpp
+++ b/src/ai/api/ai_station.cpp
@@ -9,7 +9,6 @@
/** @file ai_station.cpp Implementation of AIStation. */
-#include "../../stdafx.h"
#include "ai_station.hpp"
#include "ai_cargo.hpp"
#include "ai_map.hpp"
diff --git a/src/ai/api/ai_testmode.cpp b/src/ai/api/ai_testmode.cpp
index d7dc82ee3..832aff329 100644
--- a/src/ai/api/ai_testmode.cpp
+++ b/src/ai/api/ai_testmode.cpp
@@ -10,7 +10,6 @@
/** @file ai_testmode.cpp Implementation of AITestMode. */
#include "ai_testmode.hpp"
-#include "../../command_type.h"
#include "../../company_base.h"
#include "../../company_func.h"
#include "../ai_instance.hpp"
diff --git a/src/ai/api/ai_tile.cpp b/src/ai/api/ai_tile.cpp
index aeaba0b06..04c977626 100644
--- a/src/ai/api/ai_tile.cpp
+++ b/src/ai/api/ai_tile.cpp
@@ -14,7 +14,6 @@
#include "ai_town.hpp"
#include "../../station_func.h"
#include "../../company_func.h"
-#include "../../road_map.h"
#include "../../water_map.h"
#include "../../clear_map.h"
#include "../../tree_map.h"
diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp
index 03f39bae6..6784ee4b8 100644
--- a/src/ai/api/ai_vehicle.cpp
+++ b/src/ai/api/ai_vehicle.cpp
@@ -22,6 +22,7 @@
#include "../../roadveh.h"
#include "../../train.h"
#include "../../vehicle_func.h"
+#include "../../engine_base.h"
#include "table/strings.h"
/* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
diff --git a/src/aircraft.h b/src/aircraft.h
index 1f28b2ea5..049dca94f 100644
--- a/src/aircraft.h
+++ b/src/aircraft.h
@@ -14,8 +14,6 @@
#include "station_map.h"
#include "vehicle_base.h"
-#include "engine_func.h"
-#include "engine_base.h"
struct Aircraft;
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 0b2d1fcef..91e6fb88e 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -27,14 +27,15 @@
#include "sound_func.h"
#include "functions.h"
#include "cheat_type.h"
-#include "autoreplace_func.h"
+#include "company_base.h"
#include "autoreplace_gui.h"
-#include "gfx_func.h"
#include "ai/ai.hpp"
#include "company_func.h"
#include "effectvehicle_func.h"
#include "station_base.h"
-#include "cargotype.h"
+#include "engine_base.h"
+#include "engine_func.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index 202a8275d..d7f2cb88b 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -15,7 +15,6 @@
#include "newgrf_engine.h"
#include "strings_func.h"
#include "vehicle_func.h"
-#include "gfx_func.h"
#include "window_gui.h"
#include "spritecache.h"
diff --git a/src/airport.h b/src/airport.h
index 65375a9b9..2ee8d9ff5 100644
--- a/src/airport.h
+++ b/src/airport.h
@@ -14,7 +14,6 @@
#include "direction_type.h"
#include "map_type.h"
-#include "tile_type.h"
#include "date_type.h"
/** Current limits for airports */
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index f022d561c..6c036dd21 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -22,6 +22,7 @@
#include "company_func.h"
#include "tilehighlight_func.h"
#include "company_base.h"
+#include "station_type.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 80a30952b..eb20b3b81 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -14,6 +14,8 @@
#include "roadveh.h"
#include "newgrf_engine.h"
#include "vehicle_func.h"
+#include "engine_base.h"
+#include "engine_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/autoreplace_base.h b/src/autoreplace_base.h
index 11a436b99..77a31538a 100644
--- a/src/autoreplace_base.h
+++ b/src/autoreplace_base.h
@@ -14,6 +14,8 @@
#include "core/pool_type.hpp"
#include "autoreplace_type.h"
+#include "engine_type.h"
+#include "group_type.h"
typedef uint16 EngineRenewID;
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 0e7507cf6..1ba37d470 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -20,6 +20,7 @@
#include "functions.h"
#include "autoreplace_func.h"
#include "articulated_vehicles.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
diff --git a/src/autoreplace_func.h b/src/autoreplace_func.h
index 8f0bf2c56..fd5c0568b 100644
--- a/src/autoreplace_func.h
+++ b/src/autoreplace_func.h
@@ -12,8 +12,10 @@
#ifndef AUTOREPLACE_FUNC_H
#define AUTOREPLACE_FUNC_H
-#include "autoreplace_type.h"
+#include "command_type.h"
#include "company_base.h"
+#include "engine_type.h"
+#include "group_type.h"
/**
* Remove all engine replacement settings for the company.
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index cdfaff1e6..e318fe7c0 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -18,13 +18,13 @@
#include "strings_func.h"
#include "window_func.h"
#include "autoreplace_func.h"
-#include "gfx_func.h"
#include "company_func.h"
#include "widgets/dropdown_type.h"
#include "engine_base.h"
#include "window_gui.h"
#include "engine_gui.h"
#include "settings_func.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
diff --git a/src/autoreplace_gui.h b/src/autoreplace_gui.h
index ccfda132b..b9692616b 100644
--- a/src/autoreplace_gui.h
+++ b/src/autoreplace_gui.h
@@ -12,6 +12,8 @@
#ifndef AUTOREPLACE_GUI_H
#define AUTOREPLACE_GUI_H
+#include "engine_type.h"
+#include "group_type.h"
#include "vehicle_type.h"
/**
diff --git a/src/autoslope.h b/src/autoslope.h
index c67276d09..ba1c07551 100644
--- a/src/autoslope.h
+++ b/src/autoslope.h
@@ -12,10 +12,11 @@
#ifndef AUTOSLOPE_H
#define AUTOSLOPE_H
-#include "settings_type.h"
#include "company_func.h"
#include "depot_func.h"
#include "slope_func.h"
+#include "tile_map.h"
+#include "openttd.h"
/**
* Autoslope check for tiles with an entrance on an edge.
diff --git a/src/base_media_func.h b/src/base_media_func.h
index 6db7137e5..434a6c722 100644
--- a/src/base_media_func.h
+++ b/src/base_media_func.h
@@ -10,8 +10,9 @@
/** @file base_media_func.h Generic function implementations for base data (graphics, sounds). */
#include "base_media_base.h"
-#include "string_func.h"
+#include "debug.h"
#include "ini_type.h"
+#include "string_func.h"
template <class Tbase_set> /* static */ const char *BaseMedia<Tbase_set>::ini_set;
template <class Tbase_set> /* static */ const Tbase_set *BaseMedia<Tbase_set>::used_set;
diff --git a/src/base_station_base.h b/src/base_station_base.h
index f4c26fa7e..6a157dfcb 100644
--- a/src/base_station_base.h
+++ b/src/base_station_base.h
@@ -12,12 +12,7 @@
#ifndef BASE_STATION_BASE_H
#define BASE_STATION_BASE_H
-#include "station_type.h"
#include "core/pool_type.hpp"
-#include "town_type.h"
-#include "strings_type.h"
-#include "date_type.h"
-#include "company_type.h"
#include "viewport_type.h"
#include "station_map.h"
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index 3390838e0..a119eac47 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -11,7 +11,6 @@
#include "../stdafx.h"
#include "../core/math_func.hpp"
-#include "../gfx_func.h"
#include "../video/video_driver.hpp"
#include "32bpp_anim.hpp"
diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp
index 9063bf14c..51ad48ab4 100644
--- a/src/blitter/32bpp_anim.hpp
+++ b/src/blitter/32bpp_anim.hpp
@@ -13,7 +13,6 @@
#define BLITTER_32BPP_ANIM_HPP
#include "32bpp_optimized.hpp"
-#include "factory.hpp"
class Blitter_32bppAnim : public Blitter_32bppOptimized {
private:
diff --git a/src/blitter/32bpp_base.cpp b/src/blitter/32bpp_base.cpp
index 427a534c0..a7d7e34a2 100644
--- a/src/blitter/32bpp_base.cpp
+++ b/src/blitter/32bpp_base.cpp
@@ -10,7 +10,6 @@
/** @file 32bpp_base.cpp Implementation of base for 32 bpp blitters. */
#include "../stdafx.h"
-#include "../gfx_func.h"
#include "32bpp_base.hpp"
void *Blitter_32bppBase::MoveTo(const void *video, int x, int y)
diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp
index a69315abd..5967de578 100644
--- a/src/blitter/32bpp_base.hpp
+++ b/src/blitter/32bpp_base.hpp
@@ -14,6 +14,7 @@
#include "base.hpp"
#include "../core/bitmath_func.hpp"
+#include "../gfx_func.h"
class Blitter_32bppBase : public Blitter {
public:
diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp
index bfc8bd422..492e4b66f 100644
--- a/src/blitter/32bpp_optimized.cpp
+++ b/src/blitter/32bpp_optimized.cpp
@@ -11,7 +11,6 @@
#include "../stdafx.h"
#include "../zoom_func.h"
-#include "../gfx_func.h"
#include "../core/math_func.hpp"
#include "32bpp_optimized.hpp"
diff --git a/src/blitter/32bpp_simple.cpp b/src/blitter/32bpp_simple.cpp
index 03393cfbf..d75f0a0d4 100644
--- a/src/blitter/32bpp_simple.cpp
+++ b/src/blitter/32bpp_simple.cpp
@@ -10,7 +10,6 @@
/** @file 32bpp_simple.cpp Implementation of the simple 32 bpp blitter. */
#include "../stdafx.h"
-#include "../gfx_func.h"
#include "../zoom_func.h"
#include "32bpp_simple.hpp"
diff --git a/src/blitter/base.hpp b/src/blitter/base.hpp
index 278f3b7c8..c8973c542 100644
--- a/src/blitter/base.hpp
+++ b/src/blitter/base.hpp
@@ -14,7 +14,6 @@
#include "../spritecache.h"
#include "../spriteloader/spriteloader.hpp"
-#include "../zoom_type.h"
enum BlitterMode {
BM_NORMAL,
diff --git a/src/bridge.h b/src/bridge.h
index db5505075..8b374cd50 100644
--- a/src/bridge.h
+++ b/src/bridge.h
@@ -13,7 +13,6 @@
#define BRIDGE_H
#include "gfx_type.h"
-#include "direction_type.h"
#include "tile_cmd.h"
/** This enum is related to the definition of bridge pieces,
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index d94369232..0651c63d0 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -11,7 +11,6 @@
#include "stdafx.h"
#include "gui.h"
-#include "window_gui.h"
#include "command_func.h"
#include "economy_func.h"
#include "bridge.h"
@@ -22,6 +21,7 @@
#include "tunnelbridge.h"
#include "sortlist_type.h"
#include "widgets/dropdown_func.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
diff --git a/src/bridge_map.h b/src/bridge_map.h
index 695b842ad..514b405dd 100644
--- a/src/bridge_map.h
+++ b/src/bridge_map.h
@@ -12,9 +12,6 @@
#ifndef BRIDGE_MAP_H
#define BRIDGE_MAP_H
-#include "direction_func.h"
-#include "rail_type.h"
-#include "transport_type.h"
#include "road_map.h"
#include "bridge.h"
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index a0660d4ed..07b763de2 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -9,10 +9,9 @@
/** @file build_vehicle_gui.cpp GUI for building vehicles. */
-#include "train.h"
-#include "roadveh.h"
-#include "ship.h"
-#include "aircraft.h"
+#include "stdafx.h"
+#include "engine_base.h"
+#include "engine_func.h"
#include "station_base.h"
#include "articulated_vehicles.h"
#include "textbuf_gui.h"
@@ -26,9 +25,7 @@
#include "window_func.h"
#include "date_func.h"
#include "vehicle_func.h"
-#include "gfx_func.h"
#include "widgets/dropdown_func.h"
-#include "window_gui.h"
#include "engine_gui.h"
#include "cargotype.h"
diff --git a/src/cargopacket.h b/src/cargopacket.h
index 64fd7145a..dfd5e72d9 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -14,7 +14,6 @@
#include "core/pool_type.hpp"
#include "economy_type.h"
-#include "tile_type.h"
#include "station_type.h"
#include "cargo_type.h"
#include "vehicle_type.h"
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index 461cf4368..863aa4319 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -21,6 +21,7 @@
#include "economy_func.h"
#include "viewport_func.h"
#include "water.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/company_base.h b/src/company_base.h
index a88ca5800..e43186d85 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -12,12 +12,9 @@
#ifndef COMPANY_BASE_H
#define COMPANY_BASE_H
-#include "company_type.h"
#include "core/pool_type.hpp"
#include "road_type.h"
#include "rail_type.h"
-#include "date_type.h"
-#include "engine_type.h"
#include "livery.h"
#include "autoreplace_type.h"
#include "economy_type.h"
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 9629a0cb6..e968108ea 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -34,6 +34,7 @@
#include "settings_func.h"
#include "vehicle_base.h"
#include "vehicle_func.h"
+#include "sprite.h"
#include "table/strings.h"
diff --git a/src/company_func.h b/src/company_func.h
index c458048ec..4b520ce7b 100644
--- a/src/company_func.h
+++ b/src/company_func.h
@@ -12,10 +12,8 @@
#ifndef COMPANY_FUNC_H
#define COMPANY_FUNC_H
-#include "core/math_func.hpp"
#include "company_type.h"
#include "tile_type.h"
-#include "strings_type.h"
#include "gfx_type.h"
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 42a0a6cc0..642bb3e6d 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -14,7 +14,6 @@
#include "window_gui.h"
#include "textbuf_gui.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "company_func.h"
#include "command_func.h"
#include "network/network.h"
@@ -28,6 +27,9 @@
#include "date_func.h"
#include "widgets/dropdown_type.h"
#include "tilehighlight_func.h"
+#include "sprite.h"
+#include "company_base.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
diff --git a/src/console.cpp b/src/console.cpp
index c8bb2a564..6799f7dd4 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -14,6 +14,7 @@
#include "network/network.h"
#include "network/network_func.h"
#include "debug.h"
+#include "console_func.h"
#include <stdarg.h>
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 2d1261482..6e50b50db 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -34,6 +34,7 @@
#include "gamelog.h"
#include "ai/ai.hpp"
#include "ai/ai_config.hpp"
+#include "console_func.h"
#ifdef ENABLE_NETWORK
#include "table/strings.h"
diff --git a/src/console_gui.cpp b/src/console_gui.cpp
index 746e83ca3..ac0e6103c 100644
--- a/src/console_gui.cpp
+++ b/src/console_gui.cpp
@@ -18,6 +18,7 @@
#include "string_func.h"
#include "gfx_func.h"
#include "settings_type.h"
+#include "console_func.h"
#include "rev.h"
diff --git a/src/console_internal.h b/src/console_internal.h
index f36ee3950..d4b3748a0 100644
--- a/src/console_internal.h
+++ b/src/console_internal.h
@@ -12,7 +12,7 @@
#ifndef CONSOLE_INTERNAL_H
#define CONSOLE_INTERNAL_H
-#include "console_func.h"
+#include "console_type.h"
enum {
ICON_CMDLN_SIZE = 1024, ///< maximum length of a typed in command
diff --git a/src/core/mem_func.hpp b/src/core/mem_func.hpp
index 2443d9ccb..42e7b42f4 100644
--- a/src/core/mem_func.hpp
+++ b/src/core/mem_func.hpp
@@ -12,7 +12,6 @@
#ifndef MEM_FUNC_HPP
#define MEM_FUNC_HPP
-#include <string.h>
#include "math_func.hpp"
/**
diff --git a/src/core/sort_func.hpp b/src/core/sort_func.hpp
index d3bb7202a..180191f4d 100644
--- a/src/core/sort_func.hpp
+++ b/src/core/sort_func.hpp
@@ -12,8 +12,6 @@
#ifndef SORT_FUNC_HPP
#define SORT_FUNC_HPP
-#include <stdlib.h>
-#include "math_func.hpp"
#include "mem_func.hpp"
/**
diff --git a/src/crashlog.cpp b/src/crashlog.cpp
index 670d6a8dc..60dbb480e 100644
--- a/src/crashlog.cpp
+++ b/src/crashlog.cpp
@@ -26,12 +26,10 @@
#include "gfx_func.h"
#include "network/network.h"
-#include <squirrel.h>
#include "ai/ai_info.hpp"
#include "company_base.h"
#include "company_func.h"
-#include <time.h>
/* static */ const char *CrashLog::message = NULL;
/* static */ char *CrashLog::gamelog_buffer = NULL;
diff --git a/src/date_gui.cpp b/src/date_gui.cpp
index bb4d363e4..749b15c62 100644
--- a/src/date_gui.cpp
+++ b/src/date_gui.cpp
@@ -12,10 +12,10 @@
#include "stdafx.h"
#include "strings_func.h"
#include "date_func.h"
-#include "gfx_func.h"
#include "window_func.h"
#include "window_gui.h"
#include "date_gui.h"
+#include "core/geometry_func.hpp"
#include "widgets/dropdown_type.h"
diff --git a/src/date_gui.h b/src/date_gui.h
index f15f6b34a..314baba3c 100644
--- a/src/date_gui.h
+++ b/src/date_gui.h
@@ -12,6 +12,9 @@
#ifndef DATE_GUI_H
#define DATE_GUI_H
+#include "date_type.h"
+#include "window_type.h"
+
/**
* Callback for when a date has been chosen
* @param w the window that sends the callback
diff --git a/src/debug.cpp b/src/debug.cpp
index fcf716255..39bef2913 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -14,13 +14,13 @@
#include "console_func.h"
#include "debug.h"
#include "string_func.h"
-#include "network/core/core.h"
#include "fileio_func.h"
#include "settings_type.h"
#include <time.h>
#if defined(ENABLE_NETWORK)
+#include "network/core/os_abstraction.h"
SOCKET _debug_socket = INVALID_SOCKET;
#endif /* ENABLE_NETWORK */
diff --git a/src/depot_base.h b/src/depot_base.h
index 521e1e33e..82d78eb60 100644
--- a/src/depot_base.h
+++ b/src/depot_base.h
@@ -12,10 +12,8 @@
#ifndef DEPOT_BASE_H
#define DEPOT_BASE_H
-#include "tile_type.h"
#include "depot_map.h"
#include "core/pool_type.hpp"
-#include "town_type.h"
typedef Pool<Depot, DepotID, 64, 64000> DepotPool;
extern DepotPool _depot_pool;
diff --git a/src/depot_func.h b/src/depot_func.h
index 5332299db..46c754b48 100644
--- a/src/depot_func.h
+++ b/src/depot_func.h
@@ -12,7 +12,6 @@
#ifndef DEPOT_FUNC_H
#define DEPOT_FUNC_H
-#include "depot_type.h"
#include "tile_type.h"
#include "vehicle_type.h"
#include "direction_type.h"
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 2f3a57940..ee413dd59 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -9,6 +9,8 @@
/** @file depot_gui.cpp The GUI for depots. */
+#include "stdafx.h"
+#include "engine_base.h"
#include "train.h"
#include "ship.h"
#include "aircraft.h"
@@ -16,7 +18,6 @@
#include "gui.h"
#include "textbuf_gui.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "command_func.h"
#include "depot_base.h"
#include "vehicle_gui.h"
diff --git a/src/depot_map.h b/src/depot_map.h
index ecf2960e1..b4f7a11ec 100644
--- a/src/depot_map.h
+++ b/src/depot_map.h
@@ -12,9 +12,6 @@
#ifndef DEPOT_MAP_H
#define DEPOT_MAP_H
-#include "road_map.h"
-#include "rail_map.h"
-#include "water_map.h"
#include "station_map.h"
/**
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index 3dec6e5e0..873a6f421 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -41,6 +41,8 @@
#include "effectvehicle_func.h"
#include "roadveh.h"
#include "ai/ai.hpp"
+#include "company_base.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 59a17b512..bdbb12c1f 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -26,6 +26,7 @@
#include "slope_func.h"
#include "tilehighlight_func.h"
#include "company_base.h"
+#include "station_type.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/driver.cpp b/src/driver.cpp
index 96ccd761e..f0e5d70db 100644
--- a/src/driver.cpp
+++ b/src/driver.cpp
@@ -14,6 +14,7 @@
#include "sound/sound_driver.hpp"
#include "music/music_driver.hpp"
#include "video/video_driver.hpp"
+#include "string_func.h"
VideoDriver *_video_driver;
char *_ini_videodriver;
diff --git a/src/driver.h b/src/driver.h
index 17019877e..cf86051de 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -14,7 +14,6 @@
#include "core/enum_type.hpp"
#include "core/string_compare_type.hpp"
-#include "string_func.h"
#include <map>
const char *GetDriverParam(const char * const *parm, const char *name);
diff --git a/src/economy.cpp b/src/economy.cpp
index 83fa47b0b..0f814e0cf 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -10,7 +10,6 @@
/** @file economy.cpp Handling of the economy. */
#include "stdafx.h"
-#include "tile_cmd.h"
#include "company_func.h"
#include "command_func.h"
#include "industry.h"
@@ -36,7 +35,6 @@
#include "date_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
-#include "gfx_func.h"
#include "autoreplace_func.h"
#include "company_gui.h"
#include "signs_base.h"
@@ -46,6 +44,8 @@
#include "waypoint_base.h"
#include "economy_base.h"
#include "core/pool_func.hpp"
+#include "newgrf.h"
+#include "engine_base.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/economy_func.h b/src/economy_func.h
index e03d05778..dfeefbb9c 100644
--- a/src/economy_func.h
+++ b/src/economy_func.h
@@ -12,16 +12,11 @@
#ifndef ECONOMY_FUNC_H
#define ECONOMY_FUNC_H
-#include "core/geometry_type.hpp"
#include "economy_type.h"
+#include "station_type.h"
#include "cargo_type.h"
#include "vehicle_type.h"
-#include "tile_type.h"
-#include "town_type.h"
-#include "industry_type.h"
#include "company_type.h"
-#include "station_type.h"
-#include "station_func.h"
void ResetPriceBaseMultipliers();
void SetPriceBaseMultiplier(Price price, int factor);
diff --git a/src/economy_type.h b/src/economy_type.h
index fd861e0b2..450b9cc88 100644
--- a/src/economy_type.h
+++ b/src/economy_type.h
@@ -14,7 +14,6 @@
#include "core/overflowsafe_type.hpp"
#include "core/enum_type.hpp"
-#include "cargo_type.h"
typedef OverflowSafeInt64 Money;
diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp
index f6f912b35..1ad8cd297 100644
--- a/src/effectvehicle.cpp
+++ b/src/effectvehicle.cpp
@@ -17,6 +17,7 @@
#include "sound_func.h"
#include "animated_tile_func.h"
#include "effectvehicle_func.h"
+#include "effectvehicle_base.h"
#include "table/sprites.h"
diff --git a/src/effectvehicle_func.h b/src/effectvehicle_func.h
index c4564aeb2..573632a60 100644
--- a/src/effectvehicle_func.h
+++ b/src/effectvehicle_func.h
@@ -12,7 +12,7 @@
#ifndef EFFECTVEHICLE_FUNC_H
#define EFFECTVEHICLE_FUNC_H
-#include "effectvehicle_base.h"
+#include "vehicle_type.h"
/** Effect vehicle types */
enum EffectVehicleType {
diff --git a/src/elrail.cpp b/src/elrail.cpp
index d121679e6..d53ade09e 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -54,7 +54,6 @@
*/
#include "stdafx.h"
-#include "openttd.h"
#include "station_map.h"
#include "viewport_func.h"
#include "landscape.h"
@@ -64,6 +63,7 @@
#include "tunnelbridge.h"
#include "elrail_func.h"
#include "engine_base.h"
+#include "company_base.h"
#include "table/sprites.h"
#include "table/elrail_data.h"
diff --git a/src/elrail_func.h b/src/elrail_func.h
index 0f5210613..e72f78425 100644
--- a/src/elrail_func.h
+++ b/src/elrail_func.h
@@ -13,9 +13,8 @@
#define ELRAIL_FUNC_H
#include "rail.h"
-#include "transparency.h"
#include "tile_cmd.h"
-#include "settings_type.h"
+#include "transparency.h"
/**
* Test if a rail type has catenary
diff --git a/src/engine.cpp b/src/engine.cpp
index 065630475..f3d8133ec 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -18,7 +18,6 @@
#include "newgrf_engine.h"
#include "group.h"
#include "strings_func.h"
-#include "gfx_func.h"
#include "core/random_func.hpp"
#include "window_func.h"
#include "date_func.h"
@@ -27,6 +26,9 @@
#include "ai/ai.hpp"
#include "core/pool_func.hpp"
#include "engine_gui.h"
+#include "engine_func.h"
+#include "engine_base.h"
+#include "company_base.h"
#include "table/strings.h"
#include "table/engines.h"
diff --git a/src/engine_base.h b/src/engine_base.h
index f3a819277..c7e3823d5 100644
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -12,8 +12,9 @@
#ifndef ENGINE_BASE_H
#define ENGINE_BASE_H
+#include "company_type.h"
#include "engine_type.h"
-#include "economy_type.h"
+#include "vehicle_type.h"
#include "core/pool_type.hpp"
#include "core/smallvec_type.hpp"
diff --git a/src/engine_func.h b/src/engine_func.h
index 518bdc422..5b89f6cc5 100644
--- a/src/engine_func.h
+++ b/src/engine_func.h
@@ -13,6 +13,8 @@
#define ENGINE_H
#include "engine_type.h"
+#include "vehicle_type.h"
+#include "company_type.h"
void SetupEngines();
void StartupEngines();
diff --git a/src/engine_gui.h b/src/engine_gui.h
index 139b6107c..4e4b51ff6 100644
--- a/src/engine_gui.h
+++ b/src/engine_gui.h
@@ -12,7 +12,9 @@
#ifndef ENGINE_GUI_H
#define ENGINE_GUI_H
+#include "engine_type.h"
#include "sortlist_type.h"
+#include "gfx_type.h"
typedef GUIList<EngineID, CargoID> GUIEngineList;
diff --git a/src/engine_type.h b/src/engine_type.h
index 234bc27e3..48a408b6d 100644
--- a/src/engine_type.h
+++ b/src/engine_type.h
@@ -15,11 +15,8 @@
#include "economy_type.h"
#include "rail_type.h"
#include "cargo_type.h"
-#include "vehicle_type.h"
-#include "gfx_type.h"
#include "date_type.h"
#include "sound_type.h"
-#include "company_type.h"
#include "strings_type.h"
typedef uint16 EngineID;
diff --git a/src/fontcache.h b/src/fontcache.h
index c84ddb581..affc2606c 100644
--- a/src/fontcache.h
+++ b/src/fontcache.h
@@ -12,7 +12,6 @@
#ifndef FONTCACHE_H
#define FONTCACHE_H
-#include "gfx_type.h"
#include "spritecache.h"
/** Get the SpriteID mapped to the given font size and key */
diff --git a/src/functions.h b/src/functions.h
index 559f94846..28c8f16bb 100644
--- a/src/functions.h
+++ b/src/functions.h
@@ -12,8 +12,6 @@
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
-#include "core/random_func.hpp"
-#include "command_type.h"
#include "tile_cmd.h"
/* clear_land.cpp */
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index 17bc58cc4..d87bffb84 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -16,7 +16,6 @@
#include "variables.h"
#include "string_func.h"
#include "settings_type.h"
-#include "gamelog.h"
#include "gamelog_internal.h"
#include "console_func.h"
#include "debug.h"
diff --git a/src/gamelog_internal.h b/src/gamelog_internal.h
index cccda154f..ad9921f4e 100644
--- a/src/gamelog_internal.h
+++ b/src/gamelog_internal.h
@@ -13,6 +13,7 @@
#define GAMELOG_INTERNAL_H
#include "network/core/config.h"
+#include "gamelog.h"
/** Type of logged change */
enum GamelogChangeType {
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 05cac4d1a..f6f33d3da 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -33,6 +33,7 @@
#include "void_map.h"
#include "town.h"
#include "newgrf.h"
+#include "core/random_func.hpp"
#include "table/sprites.h"
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 68faeca8d..20417b68f 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -23,7 +23,6 @@
#include "sound_func.h"
#include "fios.h"
#include "string_func.h"
-#include "gfx_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "landscape_type.h"
@@ -31,6 +30,8 @@
#include "town.h"
#include "thread/thread.h"
#include "settings_func.h"
+#include "core/geometry_func.hpp"
+#include "core/random_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/gfx_type.h b/src/gfx_type.h
index dd9795af2..fd3495159 100644
--- a/src/gfx_type.h
+++ b/src/gfx_type.h
@@ -13,7 +13,6 @@
#define GFX_TYPE_H
#include "core/endian_type.hpp"
-#include "core/enum_type.hpp"
#include "core/geometry_type.hpp"
#include "zoom_type.h"
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index ae01f6571..999d24856 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -10,7 +10,6 @@
/** @file gfxinit.cpp Initializing of the (GRF) graphics. */
#include "stdafx.h"
-#include "debug.h"
#include "fios.h"
#include "newgrf.h"
#include "3rdparty/md5/md5.h"
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 4867ffa61..5f07a2b45 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -22,6 +22,7 @@
#include "date_func.h"
#include "gfx_func.h"
#include "sortlist_type.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index be0326465..d5f54826b 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -11,7 +11,6 @@
#include "stdafx.h"
#include "openttd.h"
-#include "window_gui.h"
#include "textbuf_gui.h"
#include "command_func.h"
#include "vehicle_gui.h"
@@ -21,12 +20,13 @@
#include "window_func.h"
#include "vehicle_func.h"
#include "autoreplace_gui.h"
-#include "gfx_func.h"
#include "company_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "tilehighlight_func.h"
#include "vehicle_gui_base.h"
+#include "core/geometry_func.hpp"
+#include "company_base.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/group_gui.h b/src/group_gui.h
index 1a58f3ee8..108d611e7 100644
--- a/src/group_gui.h
+++ b/src/group_gui.h
@@ -12,6 +12,7 @@
#ifndef GROUP_GUI_H
#define GROUP_GUI_H
+#include "company_type.h"
#include "vehicle_type.h"
void ShowCompanyGroup(CompanyID company, VehicleType veh);
diff --git a/src/gui.h b/src/gui.h
index 744ae02c2..3a01edba1 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -12,7 +12,6 @@
#ifndef GUI_H
#define GUI_H
-#include "window_type.h"
#include "vehicle_type.h"
#include "gfx_type.h"
#include "economy_type.h"
diff --git a/src/highscore.cpp b/src/highscore.cpp
index 51fb841a6..d56e2f511 100644
--- a/src/highscore.cpp
+++ b/src/highscore.cpp
@@ -9,6 +9,7 @@
/** @file highscore.cpp Definition of functions used for highscore handling */
+#include "stdafx.h"
#include "highscore.h"
#include "company_base.h"
#include "company_func.h"
diff --git a/src/highscore.h b/src/highscore.h
index a3e833637..d886d7648 100644
--- a/src/highscore.h
+++ b/src/highscore.h
@@ -12,9 +12,7 @@
#ifndef HIGHSCORE_H
#define HIGHSCORE_H
-#include "stdafx.h"
#include "strings_type.h"
-#include "core/math_func.hpp"
#include "company_type.h"
struct HighScore {
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp
index d4e8c4b13..c65a5eaf8 100644
--- a/src/highscore_gui.cpp
+++ b/src/highscore_gui.cpp
@@ -9,6 +9,7 @@
/** @file highscore_gui.cpp Definition of the HighScore and EndGame windows */
+#include "stdafx.h"
#include "highscore.h"
#include "table/strings.h"
#include "gfx_func.h"
diff --git a/src/industry.h b/src/industry.h
index dd81cba72..27d56af5b 100644
--- a/src/industry.h
+++ b/src/industry.h
@@ -13,13 +13,7 @@
#define INDUSTRY_H
#include "core/pool_type.hpp"
-#include "core/random_func.hpp"
#include "newgrf_storage.h"
-#include "cargo_type.h"
-#include "economy_type.h"
-#include "map_type.h"
-#include "industry_type.h"
-#include "tile_type.h"
#include "subsidy_type.h"
#include "industry_map.h"
#include "tilearea_type.h"
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 4a414ea83..b2eb905f5 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -10,7 +10,6 @@
/** @file industry_cmd.cpp Handling of industry tiles. */
#include "stdafx.h"
-#include "openttd.h"
#include "clear_map.h"
#include "industry.h"
#include "station_base.h"
@@ -30,7 +29,6 @@
#include "newgrf_industries.h"
#include "newgrf_industrytiles.h"
#include "autoslope.h"
-#include "transparency.h"
#include "water.h"
#include "strings_func.h"
#include "functions.h"
@@ -40,6 +38,7 @@
#include "sound_func.h"
#include "animated_tile_func.h"
#include "effectvehicle_func.h"
+#include "effectvehicle_base.h"
#include "ai/ai.hpp"
#include "core/pool_func.hpp"
#include "subsidy_func.h"
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 9749ae756..97b238037 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -12,7 +12,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "gui.h"
-#include "window_gui.h"
#include "textbuf_gui.h"
#include "command_func.h"
#include "viewport_func.h"
@@ -31,6 +30,8 @@
#include "sortlist_type.h"
#include "widgets/dropdown_func.h"
#include "company_base.h"
+#include "core/geometry_func.hpp"
+#include "core/random_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/industry_map.h b/src/industry_map.h
index 1e07ca072..02e7cfafe 100644
--- a/src/industry_map.h
+++ b/src/industry_map.h
@@ -13,7 +13,6 @@
#define INDUSTRY_MAP_H
#include "industrytype.h"
-#include "tile_map.h"
#include "water_map.h"
diff --git a/src/industrytype.h b/src/industrytype.h
index 8b86526e1..f4834a6cf 100644
--- a/src/industrytype.h
+++ b/src/industrytype.h
@@ -12,13 +12,13 @@
#ifndef INDUSTRYTYPE_H
#define INDUSTRYTYPE_H
-#include "core/enum_type.hpp"
#include "economy_type.h"
#include "map_type.h"
#include "slope_type.h"
#include "industry_type.h"
#include "landscape_type.h"
-#include "tile_type.h"
+#include "strings_type.h"
+#include "cargo_type.h"
enum {
CLEAN_RANDOMSOUNDS, ///< Free the dynamically allocated sounds table
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp
index f994d8bff..a643257fa 100644
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -25,6 +25,7 @@
#include "functions.h"
#include "ai/ai_gui.hpp"
#include "gfx_func.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 3cc7a6fc8..9bf1e2973 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -29,6 +29,7 @@
#include "effectvehicle_func.h"
#include "landscape_type.h"
#include "animated_tile_func.h"
+#include "core/random_func.hpp"
#include "table/sprites.h"
diff --git a/src/landscape.h b/src/landscape.h
index 46d263ae5..cc64b0cf1 100644
--- a/src/landscape.h
+++ b/src/landscape.h
@@ -14,8 +14,6 @@
#include "core/geometry_type.hpp"
#include "tile_cmd.h"
-#include "slope_type.h"
-#include "direction_type.h"
enum {
SNOW_LINE_MONTHS = 12, ///< Number of months in the snow line table.
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 64f7cebad..ed05584cf 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -10,7 +10,6 @@
/** @file main_gui.cpp Handling of the main viewport. */
#include "stdafx.h"
-#include "openttd.h"
#include "currency.h"
#include "spritecache.h"
#include "window_gui.h"
diff --git a/src/misc/array.hpp b/src/misc/array.hpp
index 5ae836a08..f5a602155 100644
--- a/src/misc/array.hpp
+++ b/src/misc/array.hpp
@@ -13,6 +13,7 @@
#define ARRAY_HPP
#include "fixedsizearray.hpp"
+#include "str.hpp"
/** Flexible array with size limit. Implemented as fixed size
* array of fixed size arrays */
diff --git a/src/misc/blob.hpp b/src/misc/blob.hpp
index 17e3a5947..d475231b6 100644
--- a/src/misc/blob.hpp
+++ b/src/misc/blob.hpp
@@ -14,6 +14,7 @@
#include "../core/alloc_func.hpp"
#include "../core/mem_func.hpp"
+#include <new>
/** Base class for simple binary blobs.
* Item is byte.
diff --git a/src/misc/dbg_helpers.h b/src/misc/dbg_helpers.h
index 56eebb247..670548d35 100644
--- a/src/misc/dbg_helpers.h
+++ b/src/misc/dbg_helpers.h
@@ -12,13 +12,16 @@
#ifndef DBG_HELPERS_H
#define DBG_HELPERS_H
-#include <new>
#include <map>
#include <stack>
-#include "blob.hpp"
#include "str.hpp"
+#include "../direction_type.h"
+#include "../signal_type.h"
+#include "../tile_type.h"
+#include "../track_type.h"
+
/** Helper template class that provides C array length and item type */
template <typename T> struct ArrayT;
diff --git a/src/misc/fixedsizearray.hpp b/src/misc/fixedsizearray.hpp
index b17755c5e..3e39cc4d9 100644
--- a/src/misc/fixedsizearray.hpp
+++ b/src/misc/fixedsizearray.hpp
@@ -12,6 +12,7 @@
#ifndef FIXEDSIZEARRAY_HPP
#define FIXEDSIZEARRAY_HPP
+#include "../core/alloc_func.hpp"
/** fixed size array
* Upon construction it preallocates fixed size block of memory
diff --git a/src/misc/str.hpp b/src/misc/str.hpp
index 64e401adb..8ef8e8f87 100644
--- a/src/misc/str.hpp
+++ b/src/misc/str.hpp
@@ -14,6 +14,7 @@
#include <errno.h>
#include <stdarg.h>
+#include "blob.hpp"
#include "../string_func.h"
/** Blob based case sensitive ANSI/UTF-8 string */
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 27b82a0c3..56e757d91 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -33,6 +33,7 @@
#include "window_func.h"
#include "tilehighlight_func.h"
#include "querystring_gui.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
diff --git a/src/music.cpp b/src/music.cpp
index f7e8bbc1c..b095a4197 100644
--- a/src/music.cpp
+++ b/src/music.cpp
@@ -10,7 +10,6 @@
/** @file music.cpp The songs that OpenTTD knows. */
#include "stdafx.h"
-#include "debug.h"
/* The type of set we're replacing */
#define SET_TYPE "music"
diff --git a/src/music/extmidi.cpp b/src/music/extmidi.cpp
index 260044268..48ee9d20e 100644
--- a/src/music/extmidi.cpp
+++ b/src/music/extmidi.cpp
@@ -12,6 +12,7 @@
#ifndef __MORPHOS__
#include "../stdafx.h"
#include "../debug.h"
+#include "../string_func.h"
#include "../sound/sound_driver.hpp"
#include "../video/video_driver.hpp"
#include "extmidi.h"
diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp
index 6a4ff3ec6..51530487c 100644
--- a/src/music/win32_m.cpp
+++ b/src/music/win32_m.cpp
@@ -10,6 +10,7 @@
/** @file win32_m.cpp Music playback for Windows. */
#include "../stdafx.h"
+#include "../string_func.h"
#include "win32_m.h"
#include <windows.h>
#include <mmsystem.h>
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 00ce891f3..333e40e33 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -11,7 +11,6 @@
#include "stdafx.h"
#include "openttd.h"
-#include "fileio_func.h"
#include "base_media_base.h"
#include "music/music_driver.hpp"
#include "window_gui.h"
@@ -21,6 +20,8 @@
#include "gfx_func.h"
#include "core/random_func.hpp"
#include "gui.h"
+#include "core/geometry_func.hpp"
+#include "string_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/network/core/core.cpp b/src/network/core/core.cpp
index 76049f6fb..4c724e47e 100644
--- a/src/network/core/core.cpp
+++ b/src/network/core/core.cpp
@@ -15,6 +15,7 @@
#include "../../stdafx.h"
#include "../../debug.h"
+#include "os_abstraction.h"
#include "packet.h"
diff --git a/src/network/core/core.h b/src/network/core/core.h
index a47ebff87..bf013909a 100644
--- a/src/network/core/core.h
+++ b/src/network/core/core.h
@@ -14,7 +14,6 @@
#ifndef NETWORK_CORE_H
#define NETWORK_CORE_H
-#include "os_abstraction.h"
#include "../../newgrf_config.h"
#ifdef ENABLE_NETWORK
diff --git a/src/network/core/host.h b/src/network/core/host.h
index 48f24e318..46bfa4e1f 100644
--- a/src/network/core/host.h
+++ b/src/network/core/host.h
@@ -14,6 +14,8 @@
#ifndef NETWORK_CORE_HOST_H
#define NETWORK_CORE_HOST_H
+#include "address.h"
+
void NetworkFindBroadcastIPs(NetworkAddressList *broadcast);
#endif /* NETWORK_CORE_HOST_H */
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index b24e241f1..b9866cc4e 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -14,9 +14,7 @@
#ifndef NETWORK_CORE_TCP_H
#define NETWORK_CORE_TCP_H
-#include "os_abstraction.h"
#include "address.h"
-#include "core.h"
#include "packet.h"
#ifdef ENABLE_NETWORK
diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp
index 027498ea1..ec41d1327 100644
--- a/src/network/core/tcp_game.cpp
+++ b/src/network/core/tcp_game.cpp
@@ -15,6 +15,7 @@
#include "../../stdafx.h"
+#include "../network.h"
#include "../network_internal.h"
#include "../../core/pool_func.hpp"
diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h
index 7c049dfe3..a678c247a 100644
--- a/src/network/core/tcp_game.h
+++ b/src/network/core/tcp_game.h
@@ -16,7 +16,7 @@
#include "os_abstraction.h"
#include "tcp.h"
-#include "packet.h"
+#include "../network_type.h"
#include "../../core/pool_type.hpp"
#ifdef ENABLE_NETWORK
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index c9bbcf353..e855bdfcf 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -15,6 +15,7 @@
#include "../../stdafx.h"
#include "../../date_func.h"
+#include "../../debug.h"
#include "udp.h"
/**
diff --git a/src/network/core/udp.h b/src/network/core/udp.h
index b36c1c8b2..82435d9ff 100644
--- a/src/network/core/udp.h
+++ b/src/network/core/udp.h
@@ -71,12 +71,9 @@
#ifndef NETWORK_CORE_UDP_H
#define NETWORK_CORE_UDP_H
-#include "os_abstraction.h"
#include "address.h"
-#include "core.h"
#include "game.h"
#include "packet.h"
-#include "../../debug.h"
#ifdef ENABLE_NETWORK
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 899ca88c8..c57703efb 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -16,12 +16,12 @@
#include "../strings_func.h"
#include "../command_func.h"
#include "../date_func.h"
-#include "network_internal.h"
#include "network_client.h"
#include "network_server.h"
#include "network_content.h"
#include "network_udp.h"
#include "network_gamelist.h"
+#include "network_base.h"
#include "core/udp.h"
#include "core/host.h"
#include "network_gui.h"
diff --git a/src/network/network.h b/src/network/network.h
index 41569b26c..3dd63d03c 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -12,7 +12,6 @@
#ifndef NETWORK_H
#define NETWORK_H
-#include "../company_type.h"
#ifdef ENABLE_NETWORK
diff --git a/src/network/network_base.h b/src/network/network_base.h
index 4ed03e1f2..ff204062f 100644
--- a/src/network/network_base.h
+++ b/src/network/network_base.h
@@ -15,7 +15,9 @@
#ifdef ENABLE_NETWORK
#include "network_type.h"
+#include "core/address.h"
#include "../core/pool_type.hpp"
+#include "../company_type.h"
typedef Pool<NetworkClientInfo, ClientIndex, 8, MAX_CLIENT_SLOTS> NetworkClientInfoPool;
extern NetworkClientInfoPool _networkclientinfo_pool;
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 522106b80..f10d51a2b 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -24,8 +24,10 @@
#include "../querystring_gui.h"
#include "../town.h"
#include "../window_func.h"
-#include "network_internal.h"
+#include "../core/geometry_func.hpp"
+#include "network.h"
#include "network_client.h"
+#include "network_base.h"
#include "table/strings.h"
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 592c210de..688a21ef0 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -26,6 +26,8 @@
#include "../company_base.h"
#include "../company_gui.h"
#include "../rev.h"
+#include "network.h"
+#include "network_base.h"
#include "table/strings.h"
diff --git a/src/network/network_client.h b/src/network/network_client.h
index c987340ca..17562fcec 100644
--- a/src/network/network_client.h
+++ b/src/network/network_client.h
@@ -14,6 +14,8 @@
#ifdef ENABLE_NETWORK
+#include "network_internal.h"
+
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_GAME_INFO);
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_COMPANY_INFO);
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(const CommandPacket *cp);
diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp
index 834d28da4..7e849cf9a 100644
--- a/src/network/network_command.cpp
+++ b/src/network/network_command.cpp
@@ -13,13 +13,13 @@
#include "../stdafx.h"
#include "../debug.h"
-#include "network_internal.h"
#include "network_client.h"
+#include "network.h"
#include "../command_func.h"
#include "../company_func.h"
/** Table with all the callbacks we'll use for conversion*/
-static const CommandCallback * const _callback_table[] = {
+static CommandCallback * const _callback_table[] = {
/* 0x00 */ NULL,
/* 0x01 */ CcBuildPrimaryVehicle,
/* 0x02 */ CcBuildAirport,
diff --git a/src/network/network_content.h b/src/network/network_content.h
index aa9a1ffbd..ad9ab3783 100644
--- a/src/network/network_content.h
+++ b/src/network/network_content.h
@@ -13,7 +13,6 @@
#define NETWORK_CONTENT_H
#include "core/tcp_content.h"
-#include "../core/smallvec_type.hpp"
#if defined(ENABLE_NETWORK)
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 7d3c223db..af6bcc9bc 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -19,6 +19,7 @@
#include "../base_media_base.h"
#include "../sortlist_type.h"
#include "../querystring_gui.h"
+#include "../core/geometry_func.hpp"
#include "network_content.h"
#include "table/strings.h"
diff --git a/src/network/network_func.h b/src/network/network_func.h
index e6e6a30fd..02cc131f5 100644
--- a/src/network/network_func.h
+++ b/src/network/network_func.h
@@ -16,8 +16,8 @@
#include "network_type.h"
#include "../console_type.h"
#include "../gfx_type.h"
-#include "../core/smallvec_type.hpp"
#include "../openttd.h"
+#include "../company_type.h"
#ifdef ENABLE_NETWORK
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 6b39c8afe..d8c8dd390 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -14,10 +14,11 @@
#include "../strings_func.h"
#include "../date_func.h"
#include "../fios.h"
-#include "network_internal.h"
#include "network_client.h"
#include "network_gui.h"
#include "network_gamelist.h"
+#include "network.h"
+#include "network_base.h"
#include "../gui.h"
#include "network_udp.h"
#include "../window_func.h"
@@ -27,6 +28,7 @@
#include "../sortlist_type.h"
#include "../company_base.h"
#include "../company_func.h"
+#include "../core/geometry_func.hpp"
#include "table/strings.h"
#include "../table/sprites.h"
diff --git a/src/network/network_gui.h b/src/network/network_gui.h
index eb64e1ed7..a196c75e9 100644
--- a/src/network/network_gui.h
+++ b/src/network/network_gui.h
@@ -12,6 +12,8 @@
#ifndef NETWORK_GUI_H
#define NETWORK_GUI_H
+#include "../company_type.h"
+#include "../economy_type.h"
#include "../window_type.h"
#include "network_type.h"
diff --git a/src/network/network_internal.h b/src/network/network_internal.h
index 6e5da115c..0d6814b60 100644
--- a/src/network/network_internal.h
+++ b/src/network/network_internal.h
@@ -12,13 +12,7 @@
#ifndef NETWORK_INTERNAL_H
#define NETWORK_INTERNAL_H
-#include "network.h"
#include "network_func.h"
-#include "network_base.h"
-#include "core/os_abstraction.h"
-#include "core/core.h"
-#include "core/config.h"
-#include "core/packet.h"
#include "core/tcp_game.h"
#include "../command_type.h"
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 89d97ae50..8e68f5c97 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -14,12 +14,13 @@
#include "../stdafx.h"
#include "../debug.h"
#include "../strings_func.h"
-#include "network_internal.h"
-#include "../vehicle_base.h"
#include "../date_func.h"
#include "network_server.h"
#include "network_udp.h"
+#include "network.h"
+#include "network_base.h"
#include "../console_func.h"
+#include "../company_base.h"
#include "../command_func.h"
#include "../saveload/saveload.h"
#include "../station_base.h"
diff --git a/src/network/network_server.h b/src/network/network_server.h
index 2e52a07b5..8e7342a9e 100644
--- a/src/network/network_server.h
+++ b/src/network/network_server.h
@@ -14,6 +14,8 @@
#ifdef ENABLE_NETWORK
+#include "network_internal.h"
+
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP);
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR_QUIT)(NetworkClientSocket *cs, ClientID client_id, NetworkErrorCode errorno);
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientSocket *cs, NetworkErrorCode error);
diff --git a/src/network/network_type.h b/src/network/network_type.h
index 4d5fcee69..f023fe985 100644
--- a/src/network/network_type.h
+++ b/src/network/network_type.h
@@ -12,9 +12,6 @@
#ifndef NETWORK_TYPE_H
#define NETWORK_TYPE_H
-#include "../company_type.h"
-#include "../economy_type.h"
-#include "core/config.h"
#include "core/game.h"
#ifdef ENABLE_NETWORK
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index be6e01e33..817fb40d6 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -19,9 +19,11 @@
#include "../stdafx.h"
#include "../date_func.h"
#include "../map_func.h"
+#include "../debug.h"
#include "network_gamelist.h"
#include "network_internal.h"
#include "network_udp.h"
+#include "network.h"
#include "../core/endian_func.hpp"
#include "../company_base.h"
#include "../thread/thread.h"
diff --git a/src/network/network_udp.h b/src/network/network_udp.h
index 4200391cb..bd315baba 100644
--- a/src/network/network_udp.h
+++ b/src/network/network_udp.h
@@ -14,6 +14,8 @@
#ifdef ENABLE_NETWORK
+#include "core/address.h"
+
void NetworkUDPInitialize();
void NetworkUDPSearchGame();
void NetworkUDPQueryMasterServer();
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 37f830b1d..45d9fab37 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -13,7 +13,6 @@
#include <stdarg.h>
-#include "openttd.h"
#include "debug.h"
#include "fileio_func.h"
#include "engine_func.h"
@@ -26,6 +25,7 @@
#include "fontcache.h"
#include "currency.h"
#include "landscape.h"
+#include "newgrf.h"
#include "newgrf_cargo.h"
#include "newgrf_house.h"
#include "newgrf_sound.h"
@@ -39,7 +39,6 @@
#include "fios.h"
#include "rail.h"
#include "strings_func.h"
-#include "gfx_func.h"
#include "date_func.h"
#include "string_func.h"
#include "network/network.h"
diff --git a/src/newgrf.h b/src/newgrf.h
index 64b8f9172..b38cf4803 100644
--- a/src/newgrf.h
+++ b/src/newgrf.h
@@ -12,7 +12,6 @@
#ifndef NEWGRF_H
#define NEWGRF_H
-#include "town_type.h"
#include "newgrf_config.h"
#include "cargotype.h"
#include "industry_type.h"
diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp
index ab2dddac7..10fb06ffa 100644
--- a/src/newgrf_canal.cpp
+++ b/src/newgrf_canal.cpp
@@ -10,12 +10,10 @@
/** @file newgrf_canal.cpp Implementation of NewGRF canals. */
#include "stdafx.h"
-#include "tile_type.h"
#include "debug.h"
#include "newgrf_commons.h"
#include "newgrf_spritegroup.h"
#include "newgrf_canal.h"
-#include "tile_map.h"
#include "water_map.h"
diff --git a/src/newgrf_canal.h b/src/newgrf_canal.h
index 8591fe26e..6a9c0c19c 100644
--- a/src/newgrf_canal.h
+++ b/src/newgrf_canal.h
@@ -12,6 +12,10 @@
#ifndef NEWGRF_CANAL_H
#define NEWGRF_CANAL_H
+#include "gfx_type.h"
+#include "tile_type.h"
+#include "newgrf_generic.h"
+
/** List of different canal 'features'.
* Each feature gets an entry in the canal spritegroup table */
enum CanalFeature {
diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp
index e0f7b05b5..e5a762cd4 100644
--- a/src/newgrf_cargo.cpp
+++ b/src/newgrf_cargo.cpp
@@ -13,6 +13,7 @@
#include "debug.h"
#include "newgrf.h"
#include "newgrf_spritegroup.h"
+#include "core/bitmath_func.hpp"
static uint32 CargoGetRandomBits(const ResolverObject *object)
{
diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h
index 8126dd8bc..6ace3d0da 100644
--- a/src/newgrf_commons.h
+++ b/src/newgrf_commons.h
@@ -14,7 +14,6 @@
#ifndef NEWGRF_COMMONS_H
#define NEWGRF_COMMONS_H
-#include "core/bitmath_func.hpp"
#include "tile_cmd.h"
#include "transparency.h"
#include "sprite.h"
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index dfd1199d5..b7650c95b 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -24,6 +24,8 @@
#include "aircraft.h"
#include "core/smallmap_type.hpp"
#include "station_base.h"
+#include "engine_base.h"
+#include "company_base.h"
struct WagonOverride {
EngineID *train_id;
diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h
index e62150ab6..91a15f4a7 100644
--- a/src/newgrf_engine.h
+++ b/src/newgrf_engine.h
@@ -15,6 +15,9 @@
#include "direction_type.h"
#include "newgrf_callbacks.h"
#include "newgrf_properties.h"
+#include "vehicle_type.h"
+#include "engine_type.h"
+#include "gfx_type.h"
enum {
TRAININFO_DEFAULT_VEHICLE_WIDTH = 29,
diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp
index 08ea37167..462db6a2d 100644
--- a/src/newgrf_generic.cpp
+++ b/src/newgrf_generic.cpp
@@ -13,6 +13,7 @@
#include "debug.h"
#include "newgrf.h"
#include "newgrf_spritegroup.h"
+#include "core/bitmath_func.hpp"
#include <list>
diff --git a/src/newgrf_generic.h b/src/newgrf_generic.h
index 598087a9d..c461a8f30 100644
--- a/src/newgrf_generic.h
+++ b/src/newgrf_generic.h
@@ -12,6 +12,9 @@
#ifndef NEWGRF_GENERIC_H
#define NEWGRF_GENERIC_H
+#include "cargo_type.h"
+#include "industry_type.h"
+
enum AIConstructionEvent {
AICE_TRAIN_CHECK_RAIL_ENGINE = 0x00, ///< Check if we should build an engine
AICE_TRAIN_CHECK_ELRAIL_ENGINE = 0x01,
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index f7bed462d..f87f7bc93 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -14,7 +14,6 @@
#include "newgrf.h"
#include "strings_func.h"
#include "window_func.h"
-#include "gfx_func.h"
#include "gamelog.h"
#include "settings_func.h"
#include "widgets/dropdown_type.h"
@@ -22,6 +21,7 @@
#include "network/network_content.h"
#include "sortlist_type.h"
#include "querystring_gui.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 2a425192a..37a85fb4f 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -10,24 +10,22 @@
/** @file newgrf_house.cpp Implementation of NewGRF houses. */
#include "stdafx.h"
-#include "openttd.h"
#include "variables.h"
#include "debug.h"
#include "viewport_func.h"
#include "landscape.h"
-#include "sprite.h"
#include "newgrf.h"
#include "newgrf_house.h"
#include "newgrf_spritegroup.h"
#include "newgrf_town.h"
#include "newgrf_sound.h"
#include "newgrf_commons.h"
-#include "transparency.h"
#include "functions.h"
#include "company_func.h"
#include "animated_tile_func.h"
#include "company_base.h"
#include "town.h"
+#include "core/random_func.hpp"
static BuildingCounts<uint32> _building_counts;
static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
diff --git a/src/newgrf_house.h b/src/newgrf_house.h
index 11a830a5a..6a6f40cb0 100644
--- a/src/newgrf_house.h
+++ b/src/newgrf_house.h
@@ -12,7 +12,6 @@
#ifndef NEWGRF_HOUSE_H
#define NEWGRF_HOUSE_H
-#include "town_type.h"
#include "newgrf_callbacks.h"
#include "tile_cmd.h"
#include "house_type.h"
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 9a8ff580c..9c099a203 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -11,7 +11,6 @@
#include "stdafx.h"
#include "debug.h"
-#include "strings_type.h"
#include "industry.h"
#include "newgrf.h"
#include "newgrf_industries.h"
@@ -24,6 +23,7 @@
#include "command_func.h"
#include "gui.h"
#include "strings_func.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h
index 3e10c80bc..ba3cc71b7 100644
--- a/src/newgrf_industries.h
+++ b/src/newgrf_industries.h
@@ -12,7 +12,6 @@
#ifndef NEWGRF_INDUSTRIES_H
#define NEWGRF_INDUSTRIES_H
-#include "industry_type.h"
#include "newgrf_spritegroup.h"
/** When should the industry(tile) be triggered for random bits? */
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index e455888e5..63a555ce5 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -10,21 +10,17 @@
/** @file newgrf_industrytiles.cpp NewGRF handling of industry tiles. */
#include "stdafx.h"
-#include "openttd.h"
#include "variables.h"
#include "debug.h"
#include "viewport_func.h"
#include "landscape.h"
#include "newgrf.h"
-#include "core/random_func.hpp"
#include "newgrf_commons.h"
#include "newgrf_industries.h"
#include "newgrf_industrytiles.h"
#include "newgrf_sound.h"
#include "newgrf_text.h"
#include "industry.h"
-#include "sprite.h"
-#include "transparency.h"
#include "functions.h"
#include "town.h"
#include "command_func.h"
diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h
index 70095118f..15751ff81 100644
--- a/src/newgrf_industrytiles.h
+++ b/src/newgrf_industrytiles.h
@@ -12,6 +12,11 @@
#ifndef NEWGRF_INDUSTRYTILES_H
#define NEWGRF_INDUSTRYTILES_H
+#include "tile_cmd.h"
+#include "industry_type.h"
+#include "newgrf_callbacks.h"
+#include "core/random_func.hpp"
+
enum IndustryAnimationTrigger {
IAT_CONSTRUCTION_STATE_CHANGE,
IAT_TILELOOP,
diff --git a/src/newgrf_sound.h b/src/newgrf_sound.h
index d67180b20..e25ca5055 100644
--- a/src/newgrf_sound.h
+++ b/src/newgrf_sound.h
@@ -14,6 +14,7 @@
#include "sound_type.h"
#include "tile_type.h"
+#include "vehicle_type.h"
enum VehicleSoundEvent {
VSE_START = 1,
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 348f8ebf0..993a75102 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -13,6 +13,7 @@
#include "newgrf.h"
#include "newgrf_spritegroup.h"
#include "sprite.h"
+#include "core/bitmath_func.hpp"
#include "core/pool_func.hpp"
SpriteGroupPool _spritegroup_pool("SpriteGroup");
diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h
index 2b337bb2f..a97405672 100644
--- a/src/newgrf_spritegroup.h
+++ b/src/newgrf_spritegroup.h
@@ -13,8 +13,6 @@
#define NEWGRF_SPRITEGROUP_H
#include "town_type.h"
-#include "industry_type.h"
-#include "core/bitmath_func.hpp"
#include "gfx_type.h"
#include "engine_type.h"
#include "tile_type.h"
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index e99925adb..418da8a6a 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -23,13 +23,14 @@
#include "newgrf_sound.h"
#include "town.h"
#include "newgrf_town.h"
-#include "gfx_func.h"
#include "date_func.h"
#include "company_func.h"
#include "animated_tile_func.h"
#include "functions.h"
#include "tunnelbridge_map.h"
#include "spritecache.h"
+#include "newgrf.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
diff --git a/src/newgrf_station.h b/src/newgrf_station.h
index b7cab7db9..84420c793 100644
--- a/src/newgrf_station.h
+++ b/src/newgrf_station.h
@@ -12,14 +12,13 @@
#ifndef NEWGRF_STATION_H
#define NEWGRF_STATION_H
-#include "engine_type.h"
#include "newgrf_callbacks.h"
-#include "tile_type.h"
-#include "station_type.h"
-#include "strings_type.h"
#include "sprite.h"
#include "direction_type.h"
-#include "newgrf.h"
+#include "cargo_type.h"
+#include "strings_type.h"
+#include "station_type.h"
+#include "rail_type.h"
enum StationClassID {
STAT_CLASS_BEGIN = 0, ///< the lowest valid value
diff --git a/src/newgrf_text.h b/src/newgrf_text.h
index 8a237c1e3..d75246e25 100644
--- a/src/newgrf_text.h
+++ b/src/newgrf_text.h
@@ -12,6 +12,8 @@
#ifndef NEWGRF_TEXT_H
#define NEWGRF_TEXT_H
+#include "strings_type.h"
+
StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid, bool new_scheme, const char *text_to_add, StringID def_string);
StringID GetGRFStringID(uint32 grfid, uint16 stringid);
const char *GetGRFStringPtr(uint16 stringid);
diff --git a/src/newgrf_town.h b/src/newgrf_town.h
index b591658e9..bf888229e 100644
--- a/src/newgrf_town.h
+++ b/src/newgrf_town.h
@@ -12,6 +12,8 @@
#ifndef NEWGRF_TOWN_H
#define NEWGRF_TOWN_H
+#include "town_type.h"
+
/* Currently there is no direct town resolver; we only need to get town
* variable results from inside stations, house tiles and industry tiles. */
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 3814626f5..753271b46 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -10,12 +10,9 @@
/** @file news_gui.cpp GUI functions related to news messages. */
#include "stdafx.h"
-#include "openttd.h"
#include "gui.h"
-#include "window_gui.h"
#include "viewport_func.h"
#include "news_type.h"
-#include "gfx_func.h"
#include "strings_func.h"
#include "window_func.h"
#include "date_func.h"
@@ -31,6 +28,7 @@
#include "company_manager_face.h"
#include "company_func.h"
#include "engine_gui.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 19b539f3f..2543edf88 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -60,6 +60,10 @@
#include "thread/thread.h"
#include "station_base.h"
#include "crashlog.h"
+#include "company_base.h"
+#include "engine_base.h"
+#include "engine_func.h"
+#include "core/random_func.hpp"
#include "newgrf_commons.h"
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 814e88be4..c347a9512 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -26,7 +26,7 @@
#include "roadveh.h"
#include "station_base.h"
#include "waypoint_base.h"
-#include "roadstop_base.h"
+#include "company_base.h"
#include "table/strings.h"
diff --git a/src/order_func.h b/src/order_func.h
index 1e016858b..e1ff810fe 100644
--- a/src/order_func.h
+++ b/src/order_func.h
@@ -16,7 +16,6 @@
#include "vehicle_type.h"
#include "tile_type.h"
#include "group_type.h"
-#include "date_type.h"
#include "company_type.h"
struct BackuppedOrders {
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index f148433c1..71c483401 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -10,12 +10,9 @@
/** @file order_gui.cpp GUI related to orders. */
#include "stdafx.h"
-#include "window_gui.h"
#include "command_func.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "depot_base.h"
-#include "vehicle_base.h"
#include "vehicle_gui.h"
#include "roadveh.h"
#include "timetable.h"
@@ -31,6 +28,7 @@
#include "network/network.h"
#include "station_base.h"
#include "waypoint_base.h"
+#include "core/geometry_func.hpp"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp
index c99f6c795..a9b81e62c 100644
--- a/src/os/unix/unix.cpp
+++ b/src/os/unix/unix.cpp
@@ -13,6 +13,7 @@
#include "../../textbuf_gui.h"
#include "../../functions.h"
#include "../../crashlog.h"
+#include "../../core/random_func.hpp"
#include <dirent.h>
diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp
index 62e36e1bc..4c0fa7805 100644
--- a/src/pathfinder/follow_track.hpp
+++ b/src/pathfinder/follow_track.hpp
@@ -12,13 +12,13 @@
#ifndef FOLLOW_TRACK_HPP
#define FOLLOW_TRACK_HPP
-#include "../depot_map.h"
#include "../pbs.h"
#include "../roadveh.h"
#include "../station_base.h"
#include "../train.h"
#include "../tunnelbridge.h"
#include "../tunnelbridge_map.h"
+#include "../depot_map.h"
#include "pf_performance_timer.hpp"
/** Track follower helper template class (can serve pathfinders and vehicle
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp
index 4a5979542..1423ae449 100644
--- a/src/pathfinder/npf/npf.cpp
+++ b/src/pathfinder/npf/npf.cpp
@@ -12,15 +12,9 @@
#include "../../stdafx.h"
#include "../../debug.h"
#include "../../landscape.h"
-#include "../../depot_base.h"
#include "../../network/network.h"
-#include "../../tunnelbridge_map.h"
#include "../../functions.h"
-#include "../../tunnelbridge.h"
-#include "../../pbs.h"
-#include "../../roadveh.h"
#include "../../ship.h"
-#include "../../train.h"
#include "../../roadstop_base.h"
#include "../pathfinder_func.h"
#include "../pathfinder_type.h"
diff --git a/src/pathfinder/npf/npf_func.h b/src/pathfinder/npf/npf_func.h
index 6684d9897..f0913dfa8 100644
--- a/src/pathfinder/npf/npf_func.h
+++ b/src/pathfinder/npf/npf_func.h
@@ -14,6 +14,7 @@
#include "../../track_type.h"
#include "../../direction_type.h"
+#include "../../vehicle_type.h"
#include "../pathfinder_type.h"
/**
diff --git a/src/pathfinder/opf/opf_ship.cpp b/src/pathfinder/opf/opf_ship.cpp
index 0d967c67a..9fee6b270 100644
--- a/src/pathfinder/opf/opf_ship.cpp
+++ b/src/pathfinder/opf/opf_ship.cpp
@@ -10,12 +10,10 @@
/** @file pathfind.cpp Implementation of the oldest supported pathfinder. */
#include "../../stdafx.h"
-#include "../../debug.h"
#include "../../tunnelbridge_map.h"
#include "../../tunnelbridge.h"
#include "../../ship.h"
#include "../../core/random_func.hpp"
-#include "opf_ship.h"
struct RememberData {
uint16 cur_length;
diff --git a/src/pathfinder/opf/opf_ship.h b/src/pathfinder/opf/opf_ship.h
index 10055067b..b124ce34e 100644
--- a/src/pathfinder/opf/opf_ship.h
+++ b/src/pathfinder/opf/opf_ship.h
@@ -12,6 +12,11 @@
#ifndef OPF_SHIP_H
#define OPF_SHIP_H
+#include "../../direction_type.h"
+#include "../../tile_type.h"
+#include "../../track_type.h"
+#include "../../vehicle_type.h"
+
/**
* Finds the best path for given ship using OPF.
* @param v the ship that needs to find a path
diff --git a/src/pathfinder/pathfinder_func.h b/src/pathfinder/pathfinder_func.h
index 411b49f25..4c0671941 100644
--- a/src/pathfinder/pathfinder_func.h
+++ b/src/pathfinder/pathfinder_func.h
@@ -12,7 +12,6 @@
#ifndef PATHFINDER_FUNC_H
#define PATHFINDER_FUNC_H
-#include "../station_base.h"
#include "../waypoint_base.h"
/**
diff --git a/src/pathfinder/pathfinder_type.h b/src/pathfinder/pathfinder_type.h
index 5943537c2..cee1fd3f6 100644
--- a/src/pathfinder/pathfinder_type.h
+++ b/src/pathfinder/pathfinder_type.h
@@ -12,6 +12,8 @@
#ifndef PATHFINDER_TYPE_H
#define PATHFINDER_TYPE_H
+#include "../tile_type.h"
+
/** Length (penalty) of one tile with NPF */
static const int NPF_TILE_LENGTH = 100;
diff --git a/src/pathfinder/yapf/yapf.h b/src/pathfinder/yapf/yapf.h
index 54e46ce75..e5615f782 100644
--- a/src/pathfinder/yapf/yapf.h
+++ b/src/pathfinder/yapf/yapf.h
@@ -14,6 +14,8 @@
#include "../../direction_type.h"
#include "../../station_type.h"
+#include "../../track_type.h"
+#include "../../vehicle_type.h"
#include "../pathfinder_type.h"
/**
diff --git a/src/pbs.cpp b/src/pbs.cpp
index 3c25dfa03..173902a80 100644
--- a/src/pbs.cpp
+++ b/src/pbs.cpp
@@ -13,7 +13,6 @@
#include "functions.h"
#include "vehicle_func.h"
#include "pathfinder/follow_track.hpp"
-//#include "depot_map.h"
/**
* Get the reserved trackbits for any tile, regardless of type.
diff --git a/src/rail.h b/src/rail.h
index 14dbdb89c..6c6feee40 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -14,7 +14,6 @@
#include "rail_type.h"
#include "track_type.h"
-#include "vehicle_type.h"
#include "gfx_type.h"
#include "core/bitmath_func.hpp"
#include "economy_func.h"
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 00b2a30bf..9ca8d17e0 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -10,7 +10,6 @@
/** @file rail_cmd.cpp Handling of rail tiles. */
#include "stdafx.h"
-#include "openttd.h"
#include "cmd_helper.h"
#include "landscape.h"
#include "viewport_func.h"
@@ -34,6 +33,7 @@
#include "elrail_func.h"
#include "town.h"
#include "pbs.h"
+#include "company_base.h"
#include "table/strings.h"
#include "table/railtypes.h"
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 3c9127a9f..0aa4d1c44 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -15,7 +15,6 @@
#include "station_gui.h"
#include "terraform_gui.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "command_func.h"
#include "waypoint_func.h"
#include "newgrf_station.h"
@@ -30,6 +29,7 @@
#include "tunnelbridge.h"
#include "tilehighlight_func.h"
#include "spritecache.h"
+#include "core/geometry_func.hpp"
#include "station_map.h"
#include "tunnelbridge_map.h"
diff --git a/src/rail_map.h b/src/rail_map.h
index f9cca02f0..7aa4282cd 100644
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -15,7 +15,6 @@
#include "rail_type.h"
#include "depot_type.h"
#include "signal_func.h"
-#include "direction_func.h"
#include "track_func.h"
#include "tile_map.h"
#include "signal_type.h"
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 1a151f33a..f6c58b165 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -10,7 +10,6 @@
/** @file road_cmd.cpp Commands related to road tiles. */
#include "stdafx.h"
-#include "openttd.h"
#include "cmd_helper.h"
#include "road_internal.h"
#include "landscape.h"
@@ -30,9 +29,12 @@
#include "cheat_type.h"
#include "functions.h"
#include "effectvehicle_func.h"
+#include "effectvehicle_base.h"
#include "elrail_func.h"
#include "roadveh.h"
#include "town.h"
+#include "company_base.h"
+#include "core/random_func.hpp"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/road_cmd.h b/src/road_cmd.h
index 5c150657f..3cf588dcd 100644
--- a/src/road_cmd.h
+++ b/src/road_cmd.h
@@ -13,6 +13,7 @@
#define ROAD_CMD_H
#include "direction_type.h"
+#include "road_type.h"
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt);
void UpdateNearestTownForRoadTiles(bool invalidate);
diff --git a/src/road_func.h b/src/road_func.h
index b2b15db2f..151ae4e9f 100644
--- a/src/road_func.h
+++ b/src/road_func.h
@@ -14,8 +14,9 @@
#include "core/bitmath_func.hpp"
#include "road_type.h"
-#include "direction_func.h"
+#include "direction_type.h"
#include "company_type.h"
+#include "tile_type.h"
/**
* Whether the given roadtype is valid.
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 3479c4618..6cd517f2f 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -10,15 +10,12 @@
/** @file road_gui.cpp GUI for building roads. */
#include "stdafx.h"
-#include "openttd.h"
#include "gui.h"
#include "window_gui.h"
#include "station_gui.h"
#include "terraform_gui.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "command_func.h"
-#include "road_type.h"
#include "road_cmd.h"
#include "road_map.h"
#include "station_func.h"
diff --git a/src/road_internal.h b/src/road_internal.h
index 359d004f5..6b0d8c8d4 100644
--- a/src/road_internal.h
+++ b/src/road_internal.h
@@ -13,6 +13,7 @@
#define ROAD_INTERNAL_H
#include "tile_cmd.h"
+#include "road_type.h"
/**
* Clean up unneccesary RoadBits of a planed tile.
diff --git a/src/road_map.h b/src/road_map.h
index bea758e2c..46060ddfd 100644
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -15,7 +15,6 @@
#include "track_func.h"
#include "depot_type.h"
#include "rail_type.h"
-#include "town_type.h"
#include "road_func.h"
#include "tile_map.h"
diff --git a/src/roadstop_base.h b/src/roadstop_base.h
index d323e79c0..7bfdba16d 100644
--- a/src/roadstop_base.h
+++ b/src/roadstop_base.h
@@ -15,6 +15,8 @@
#include "station_type.h"
#include "core/pool_type.hpp"
#include "core/bitmath_func.hpp"
+#include "direction_type.h"
+#include "vehicle_type.h"
typedef Pool<RoadStop, RoadStopID, 32, 64000> RoadStopPool;
extern RoadStopPool _roadstop_pool;
diff --git a/src/roadveh.h b/src/roadveh.h
index 09e37b6ba..da01854cc 100644
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -13,9 +13,7 @@
#define ROADVEH_H
#include "vehicle_base.h"
-#include "engine_func.h"
-#include "engine_base.h"
-#include "economy_func.h"
+#include "road_type.h"
struct RoadVehicle;
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 5df4572a6..9f87022ea 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -30,14 +30,17 @@
#include "vehicle_func.h"
#include "sound_func.h"
#include "autoreplace_gui.h"
-#include "gfx_func.h"
#include "ai/ai.hpp"
#include "depot_map.h"
#include "effectvehicle_func.h"
+#include "effectvehicle_base.h"
#include "roadstop_base.h"
#include "cargotype.h"
#include "spritecache.h"
-#include "debug.h"
+#include "core/random_func.hpp"
+#include "engine_base.h"
+#include "company_base.h"
+#include "engine_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index a7399431d..f7989849f 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -15,7 +15,6 @@
#include "../depot_base.h"
#include "../window_func.h"
#include "../fios.h"
-#include "../gamelog.h"
#include "../gamelog_internal.h"
#include "../network/network.h"
#include "../gfxinit.h"
@@ -23,8 +22,6 @@
#include "../industry.h"
#include "../clear_map.h"
#include "../vehicle_func.h"
-#include "../newgrf_station.h"
-#include "../openttd.h"
#include "../debug.h"
#include "../string_func.h"
#include "../date_func.h"
@@ -49,6 +46,10 @@
#include "../animated_tile_func.h"
#include "../subsidy_base.h"
#include "../subsidy_func.h"
+#include "../company_base.h"
+#include "../newgrf.h"
+#include "../engine_base.h"
+#include "../engine_func.h"
#include "table/strings.h"
diff --git a/src/saveload/autoreplace_sl.cpp b/src/saveload/autoreplace_sl.cpp
index 295cd77d4..afc2304b2 100644
--- a/src/saveload/autoreplace_sl.cpp
+++ b/src/saveload/autoreplace_sl.cpp
@@ -10,8 +10,6 @@
/** @file autoreplace_sl.cpp Code handling saving and loading of autoreplace rules */
#include "../stdafx.h"
-#include "../engine_type.h"
-#include "../group_type.h"
#include "../autoreplace_base.h"
#include "saveload.h"
diff --git a/src/saveload/gamelog_sl.cpp b/src/saveload/gamelog_sl.cpp
index dc0bebc5d..59820db4e 100644
--- a/src/saveload/gamelog_sl.cpp
+++ b/src/saveload/gamelog_sl.cpp
@@ -10,7 +10,6 @@
/** @file gamelog_sl.cpp Code handling saving and loading of gamelog data */
#include "../stdafx.h"
-#include "../gamelog.h"
#include "../gamelog_internal.h"
#include "../core/alloc_func.hpp"
diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp
index ab2b24f31..9fef37935 100644
--- a/src/saveload/industry_sl.cpp
+++ b/src/saveload/industry_sl.cpp
@@ -10,7 +10,6 @@
/** @file industry_sl.cpp Code handling saving and loading of industries */
#include "../stdafx.h"
-#include "../strings_type.h"
#include "../industry.h"
#include "../newgrf_commons.h"
diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp
index 06775d4e9..67ca38976 100644
--- a/src/saveload/misc_sl.cpp
+++ b/src/saveload/misc_sl.cpp
@@ -20,7 +20,7 @@
#include "../viewport_func.h"
#include "../gfx_func.h"
#include "../company_base.h"
-#include "../town.h"
+#include "../core/random_func.hpp"
#include "saveload.h"
diff --git a/src/saveload/oldloader.h b/src/saveload/oldloader.h
index eabf1332d..d1908e136 100644
--- a/src/saveload/oldloader.h
+++ b/src/saveload/oldloader.h
@@ -13,6 +13,7 @@
#define OLDLOADER_H
#include "saveload.h"
+#include "../tile_type.h"
enum {
BUFFER_SIZE = 4096,
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index a78a45244..d21a3975c 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -22,13 +22,15 @@
#include "../subsidy_base.h"
#include "../debug.h"
#include "../depot_base.h"
-#include "../zoom_func.h"
#include "../date_func.h"
#include "../vehicle_func.h"
#include "../variables.h"
#include "../effectvehicle_base.h"
#include "../core/mem_func.hpp"
#include "../core/alloc_type.hpp"
+#include "../engine_base.h"
+#include "../engine_func.h"
+#include "../company_base.h"
#include "saveload_internal.h"
#include "oldloader.h"
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 00d06ab30..c3e719bac 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -21,7 +21,6 @@
* </ol>
*/
#include "../stdafx.h"
-#include "../openttd.h"
#include "../debug.h"
#include "../station_base.h"
#include "../thread/thread.h"
@@ -30,7 +29,6 @@
#include "../variables.h"
#include "../window_func.h"
#include "../strings_func.h"
-#include "../gfx_func.h"
#include "../core/endian_func.hpp"
#include "../vehicle_base.h"
#include "../company_func.h"
@@ -42,6 +40,7 @@
#include "../gamelog.h"
#include "../string_func.h"
#include "../engine_base.h"
+#include "../company_base.h"
#include "table/strings.h"
diff --git a/src/saveload/saveload_internal.h b/src/saveload/saveload_internal.h
index 04e01de33..b400861b4 100644
--- a/src/saveload/saveload_internal.h
+++ b/src/saveload/saveload_internal.h
@@ -12,7 +12,6 @@
#ifndef SAVELOAD_INTERNAL_H
#define SAVELOAD_INTERNAL_H
-#include "../strings_type.h"
#include "../company_manager_face.h"
#include "../order_base.h"
#include "../engine_type.h"
diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp
index 8eff01293..cdd43303b 100644
--- a/src/saveload/signs_sl.cpp
+++ b/src/saveload/signs_sl.cpp
@@ -10,7 +10,6 @@
/** @file signs_sl.cpp Code handling saving and loading of economy data */
#include "../stdafx.h"
-#include "../company_func.h"
#include "../signs_base.h"
#include "saveload.h"
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index a25eb556d..99161ae1c 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -15,7 +15,6 @@
#include "../roadstop_base.h"
#include "../vehicle_base.h"
#include "../newgrf_station.h"
-#include "../station_map.h"
#include "saveload.h"
#include "table/strings.h"
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index e78742073..7fdb78e61 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -17,6 +17,7 @@
#include "../aircraft.h"
#include "../station_base.h"
#include "../effectvehicle_base.h"
+#include "../engine_base.h"
#include "saveload.h"
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index be7bf01e5..2cd95e104 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -14,6 +14,7 @@
#include "../newgrf_station.h"
#include "../vehicle_base.h"
#include "../town.h"
+#include "../newgrf.h"
#include "table/strings.h"
diff --git a/src/script/script_info.hpp b/src/script/script_info.hpp
index a812df3e5..f25158049 100644
--- a/src/script/script_info.hpp
+++ b/src/script/script_info.hpp
@@ -12,6 +12,7 @@
#ifndef SCRIPT_INFO
#define SCRIPT_INFO
+#include <squirrel.h>
#include "../misc/countedptr.hpp"
class ScriptFileInfo : public SimpleCountedObject {
diff --git a/src/sdl.h b/src/sdl.h
index 2f4131e1a..ba5a30a77 100644
--- a/src/sdl.h
+++ b/src/sdl.h
@@ -20,7 +20,6 @@ void SdlClose(uint32 x);
#endif
#ifdef DYNAMICALLY_LOADED_SDL
- #include <SDL.h>
struct SDLProcs {
int (SDLCALL *SDL_Init)(Uint32);
diff --git a/src/settings.cpp b/src/settings.cpp
index 00c0f21cc..ef179a205 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -57,10 +57,11 @@
#include "gamelog.h"
#include "settings_func.h"
#include "ini_type.h"
-#include "ai/ai.hpp"
#include "ai/ai_config.hpp"
#include "newgrf.h"
#include "ship.h"
+#include "company_base.h"
+#include "engine_base.h"
#include "void_map.h"
#include "station_base.h"
diff --git a/src/settings_func.h b/src/settings_func.h
index 3e80993fa..29c9ad836 100644
--- a/src/settings_func.h
+++ b/src/settings_func.h
@@ -13,6 +13,7 @@
#define SETTINGS_FUNC_H
#include "core/smallvec_type.hpp"
+#include "company_type.h"
void IConsoleSetSetting(const char *name, const char *value);
void IConsoleSetSetting(const char *name, int32 value);
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 9f35482a4..0d5955871 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -10,10 +10,8 @@
/** @file settings_gui.cpp GUI for settings. */
#include "stdafx.h"
-#include "openttd.h"
#include "currency.h"
#include "gui.h"
-#include "window_gui.h"
#include "textbuf_gui.h"
#include "command_func.h"
#include "screenshot.h"
@@ -24,15 +22,15 @@
#include "strings_func.h"
#include "window_func.h"
#include "string_func.h"
-#include "gfx_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
-#include "station_func.h"
+#include "openttd.h"
#include "highscore.h"
#include "base_media_base.h"
#include "company_base.h"
#include "company_func.h"
#include "viewport_func.h"
+#include "core/geometry_func.hpp"
#include <map>
#include "table/sprites.h"
diff --git a/src/settings_internal.h b/src/settings_internal.h
index 2903239c1..316c43342 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -14,6 +14,7 @@
#include "saveload/saveload.h"
#include "settings_type.h"
+#include "strings_type.h"
/** Convention/Type of settings. This is then further specified if necessary
* with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h
diff --git a/src/ship.h b/src/ship.h
index cc0973a75..2138e732e 100644
--- a/src/ship.h
+++ b/src/ship.h
@@ -13,9 +13,6 @@
#define SHIP_H
#include "vehicle_base.h"
-#include "engine_func.h"
-#include "engine_base.h"
-#include "economy_func.h"
void RecalcShipStuff(Vehicle *v);
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index acd5754ec..f060218cb 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -31,11 +31,14 @@
#include "vehicle_func.h"
#include "sound_func.h"
#include "autoreplace_gui.h"
-#include "gfx_func.h"
#include "effectvehicle_func.h"
+#include "effectvehicle_base.h"
#include "ai/ai.hpp"
#include "pathfinder/opf/opf_ship.h"
#include "landscape_type.h"
+#include "engine_base.h"
+#include "engine_func.h"
+#include "company_base.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/signal.cpp b/src/signal.cpp
index b85c38636..2eeef336c 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -16,6 +16,7 @@
#include "vehicle_func.h"
#include "functions.h"
#include "train.h"
+#include "company_base.h"
/** these are the maximums used for updating signal blocks */
diff --git a/src/signs_base.h b/src/signs_base.h
index 85938981d..548e9b837 100644
--- a/src/signs_base.h
+++ b/src/signs_base.h
@@ -14,8 +14,8 @@
#include "signs_type.h"
#include "viewport_type.h"
-#include "tile_type.h"
#include "core/pool_type.hpp"
+#include "company_type.h"
typedef Pool<Sign, SignID, 16, 64000> SignPool;
extern SignPool _sign_pool;
diff --git a/src/signs_func.h b/src/signs_func.h
index c1ae4c7d7..0b75fccee 100644
--- a/src/signs_func.h
+++ b/src/signs_func.h
@@ -13,6 +13,7 @@
#define SIGNS_FUNC_H
#include "signs_type.h"
+#include "tile_type.h"
extern SignID _new_sign_id;
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index b66eb5d0a..5d86e90f9 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -24,6 +24,7 @@
#include "querystring_gui.h"
#include "sortlist_type.h"
#include "string_func.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 5956af7f9..5f9d8b647 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -17,7 +17,6 @@
#include "window_gui.h"
#include "tree_map.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "town.h"
#include "blitter/factory.hpp"
#include "tunnelbridge_map.h"
@@ -26,6 +25,7 @@
#include "vehicle_base.h"
#include "sound_func.h"
#include "window_func.h"
+#include "company_base.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/sound.cpp b/src/sound.cpp
index 1fc5291c3..a0f386297 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -16,7 +16,6 @@
#include "fios.h"
#include "window_gui.h"
#include "vehicle_base.h"
-#include "debug.h"
/* The type of set we're replacing */
#define SET_TYPE "sounds"
diff --git a/src/sound/allegro_s.cpp b/src/sound/allegro_s.cpp
index cef716407..6bb1e756c 100644
--- a/src/sound/allegro_s.cpp
+++ b/src/sound/allegro_s.cpp
@@ -13,7 +13,6 @@
#include "../stdafx.h"
-#include "../driver.h"
#include "../mixer.h"
#include "../debug.h"
#include "allegro_s.h"
diff --git a/src/sound/win32_s.cpp b/src/sound/win32_s.cpp
index e73f511f4..3024dd03c 100644
--- a/src/sound/win32_s.cpp
+++ b/src/sound/win32_s.cpp
@@ -14,6 +14,7 @@
#include "../driver.h"
#include "../mixer.h"
#include "../core/alloc_func.hpp"
+#include "../core/bitmath_func.hpp"
#include "win32_s.h"
#include <windows.h>
#include <mmsystem.h>
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 2cf4eff2b..65b640c49 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -10,7 +10,6 @@
/** @file spritecache.cpp Caching of sprites. */
#include "stdafx.h"
-#include "gfx_type.h"
#include "fileio_func.h"
#include "spriteloader/grf.hpp"
#include "gfx_func.h"
diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp
index 51ae23b8d..92e0c6d76 100644
--- a/src/spriteloader/png.cpp
+++ b/src/spriteloader/png.cpp
@@ -12,7 +12,6 @@
#ifdef WITH_PNG
#include "../stdafx.h"
-#include "../gfx_func.h"
#include "../fileio_func.h"
#include "../debug.h"
#include "png.hpp"
diff --git a/src/spriteloader/spriteloader.hpp b/src/spriteloader/spriteloader.hpp
index 6a3d0122b..693c85329 100644
--- a/src/spriteloader/spriteloader.hpp
+++ b/src/spriteloader/spriteloader.hpp
@@ -13,6 +13,7 @@
#define SPRITELOADER_HPP
#include "../core/alloc_type.hpp"
+#include "../gfx_type.h"
class SpriteLoader {
public:
diff --git a/src/station.cpp b/src/station.cpp
index 4176a8894..e6b984d68 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -23,6 +23,7 @@
#include "station_base.h"
#include "roadstop_base.h"
#include "industry.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
diff --git a/src/station_base.h b/src/station_base.h
index 05de77560..5de946581 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -15,10 +15,7 @@
#include "base_station_base.h"
#include "airport.h"
#include "cargopacket.h"
-#include "cargo_type.h"
#include "industry_type.h"
-#include "core/geometry_type.hpp"
-#include <list>
typedef Pool<BaseStation, StationID, 32, 64000> StationPool;
extern StationPool _station_pool;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index b0bc803b2..f0191cf19 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -10,7 +10,6 @@
/** @file station_cmd.cpp Handling of station tiles. */
#include "stdafx.h"
-#include "openttd.h"
#include "aircraft.h"
#include "bridge_map.h"
#include "cmd_helper.h"
@@ -45,6 +44,9 @@
#include "waypoint_func.h"
#include "pbs.h"
#include "debug.h"
+#include "core/random_func.hpp"
+#include "company_base.h"
+#include "newgrf.h"
#include "table/strings.h"
diff --git a/src/station_func.h b/src/station_func.h
index acc124339..99aa47e5f 100644
--- a/src/station_func.h
+++ b/src/station_func.h
@@ -16,10 +16,9 @@
#include "sprite.h"
#include "rail_type.h"
#include "road_type.h"
-#include "tile_type.h"
#include "cargo_type.h"
-#include "vehicle_type.h"
#include "transparency.h"
+#include "company_type.h"
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 45208d83a..3bf2cf233 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -10,10 +10,8 @@
/** @file station_gui.cpp The GUI for stations. */
#include "stdafx.h"
-#include "openttd.h"
#include "debug.h"
#include "gui.h"
-#include "window_gui.h"
#include "textbuf_gui.h"
#include "company_func.h"
#include "command_func.h"
@@ -23,13 +21,13 @@
#include "strings_func.h"
#include "window_func.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "widgets/dropdown_func.h"
#include "station_base.h"
#include "waypoint_base.h"
#include "tilehighlight_func.h"
#include "company_base.h"
#include "sortlist_type.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/station_gui.h b/src/station_gui.h
index efd6ad166..cb8b278cf 100644
--- a/src/station_gui.h
+++ b/src/station_gui.h
@@ -13,7 +13,8 @@
#define STATION_GUI_H
#include "command_type.h"
-#include "station_type.h"
+#include "tilearea_type.h"
+#include "window_type.h"
/** Enum for StationView, referring to _station_view_widgets and _station_view_expanded_widgets */
enum StationViewWidgets {
diff --git a/src/station_type.h b/src/station_type.h
index 26e766b8c..d14bd2094 100644
--- a/src/station_type.h
+++ b/src/station_type.h
@@ -14,7 +14,6 @@
#include "core/enum_type.hpp"
#include "core/smallvec_type.hpp"
-#include "tile_type.h"
#include "tilearea_type.h"
typedef uint16 StationID;
diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp
index 93e1d50a9..c4566e44c 100644
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -25,6 +25,7 @@
#include "variables.h"
#include "window_func.h"
#include "statusbar_gui.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/strings.cpp b/src/strings.cpp
index 135ec6d90..010106601 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -10,7 +10,6 @@
/** @file strings.cpp Handling of translated strings. */
#include "stdafx.h"
-#include "openttd.h"
#include "currency.h"
#include "station_base.h"
#include "town.h"
@@ -29,11 +28,11 @@
#include "core/endian_func.hpp"
#include "date_func.h"
#include "vehicle_base.h"
-#include "video/video_driver.hpp"
#include "engine_base.h"
#include "strgen/strgen.h"
-#include "gfx_func.h"
#include "townname_func.h"
+#include "string_func.h"
+#include "company_base.h"
#include "table/strings.h"
#include "table/control_codes.h"
diff --git a/src/subsidy.cpp b/src/subsidy.cpp
index 631d80e81..66983ef30 100644
--- a/src/subsidy.cpp
+++ b/src/subsidy.cpp
@@ -22,6 +22,7 @@
#include "subsidy_base.h"
#include "subsidy_func.h"
#include "core/pool_func.hpp"
+#include "core/random_func.hpp"
#include "table/strings.h"
diff --git a/src/subsidy_func.h b/src/subsidy_func.h
index 780303a7b..31eb315cc 100644
--- a/src/subsidy_func.h
+++ b/src/subsidy_func.h
@@ -14,9 +14,8 @@
#include "core/geometry_type.hpp"
#include "station_type.h"
-#include "town_type.h"
-#include "industry_type.h"
#include "company_type.h"
+#include "cargo_type.h"
Pair SetupSubsidyDecodeParam(const struct Subsidy *s, bool mode);
void DeleteSubsidyWith(SourceType type, SourceID index);
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 0903394c7..1204b216e 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -10,7 +10,6 @@
/** @file subsidy_gui.cpp GUI for subsidies. */
#include "stdafx.h"
-#include "strings_type.h"
#include "industry.h"
#include "town.h"
#include "window_gui.h"
@@ -21,6 +20,7 @@
#include "gui.h"
#include "subsidy_func.h"
#include "subsidy_base.h"
+#include "core/geometry_func.hpp"
#include "table/strings.h"
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 9b8d3b37e..8684f287e 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -10,7 +10,6 @@
/** @file terraform_gui.cpp GUI related to terraforming the map. */
#include "stdafx.h"
-#include "openttd.h"
#include "clear_map.h"
#include "company_func.h"
#include "company_base.h"
@@ -18,7 +17,6 @@
#include "window_gui.h"
#include "window_func.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "command_func.h"
#include "signs_func.h"
#include "variables.h"
diff --git a/src/texteff.cpp b/src/texteff.cpp
index bc742924f..c1c133e8d 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -10,13 +10,9 @@
/** @file texteff.cpp Handling of text effects. */
#include "stdafx.h"
-#include "openttd.h"
-#include "strings_type.h"
#include "texteff.hpp"
-#include "core/bitmath_func.hpp"
#include "transparency.h"
#include "strings_func.h"
-#include "core/alloc_func.hpp"
#include "core/smallvec_type.hpp"
#include "viewport_func.h"
#include "settings_type.h"
diff --git a/src/texteff.hpp b/src/texteff.hpp
index 4d6b9a286..ca6a89288 100644
--- a/src/texteff.hpp
+++ b/src/texteff.hpp
@@ -13,6 +13,7 @@
#define TEXTEFF_HPP
#include "gfx_type.h"
+#include "strings_type.h"
/**
* Text effect modes.
diff --git a/src/tile_cmd.h b/src/tile_cmd.h
index 4ce9aa1a7..d8eede25d 100644
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -12,17 +12,10 @@
#ifndef TILE_CMD_H
#define TILE_CMD_H
-#include "slope_type.h"
-#include "tile_type.h"
#include "command_type.h"
#include "vehicle_type.h"
#include "cargo_type.h"
-#include "strings_type.h"
-#include "date_type.h"
-#include "company_type.h"
-#include "direction_type.h"
#include "track_type.h"
-#include "transport_type.h"
#include "tile_map.h"
/** The returned bits of VehicleEnterTile. */
diff --git a/src/tile_map.h b/src/tile_map.h
index e8559097b..fcbe2199c 100644
--- a/src/tile_map.h
+++ b/src/tile_map.h
@@ -12,9 +12,7 @@
#ifndef TILE_MAP_H
#define TILE_MAP_H
-#include "tile_type.h"
#include "slope_type.h"
-#include "company_type.h"
#include "map_func.h"
#include "core/bitmath_func.hpp"
#include "settings_type.h"
diff --git a/src/tile_type.h b/src/tile_type.h
index bd1d62dab..82e4146e0 100644
--- a/src/tile_type.h
+++ b/src/tile_type.h
@@ -12,7 +12,6 @@
#ifndef TILE_TYPE_H
#define TILE_TYPE_H
-#include "core/enum_type.hpp"
enum {
TILE_SIZE = 16, ///< Tiles are 16x16 "units" in size
diff --git a/src/tilehighlight_func.h b/src/tilehighlight_func.h
index 36576587f..778faff61 100644
--- a/src/tilehighlight_func.h
+++ b/src/tilehighlight_func.h
@@ -13,8 +13,6 @@
#define TILEHIGHLIGHT_FUNC_H
#include "gfx_type.h"
-#include "window_type.h"
-#include "viewport_type.h"
#include "tilehighlight_type.h"
typedef void PlaceProc(TileIndex tile);
diff --git a/src/tilehighlight_type.h b/src/tilehighlight_type.h
index 46569bf6e..15b26d9ed 100644
--- a/src/tilehighlight_type.h
+++ b/src/tilehighlight_type.h
@@ -13,9 +13,9 @@
#define TILEHIGHLIGHT_TYPE_H
#include "core/geometry_type.hpp"
-#include "zoom_type.h"
#include "window_type.h"
#include "tile_type.h"
+#include "viewport_type.h"
/** Highlighting draw styles */
enum HighLightStyle {
diff --git a/src/timetable.h b/src/timetable.h
index 05b76d2e3..fe0848b56 100644
--- a/src/timetable.h
+++ b/src/timetable.h
@@ -13,6 +13,7 @@
#define TIMETABLE_H
#include "date_type.h"
+#include "vehicle_type.h"
void ShowTimetableWindow(const Vehicle *v);
void UpdateVehicleTimetable(Vehicle *v, bool travelling);
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index f9de4e7eb..92eeba0c9 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -23,6 +23,7 @@
#include "date_func.h"
#include "date_gui.h"
#include "vehicle_gui.h"
+#include "settings_type.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index f5c61cdcf..fa708d507 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -10,7 +10,6 @@
/** @file toolbar_gui.cpp Code related to the (main) toolbar. */
#include "stdafx.h"
-#include "openttd.h"
#include "gui.h"
#include "window_gui.h"
#include "window_func.h"
@@ -41,6 +40,7 @@
#include "tilehighlight_func.h"
#include "rail.h"
#include "widgets/dropdown_type.h"
+#include "company_base.h"
#include "network/network.h"
#include "network/network_gui.h"
diff --git a/src/town.h b/src/town.h
index 08d376fc3..284026fd6 100644
--- a/src/town.h
+++ b/src/town.h
@@ -13,18 +13,7 @@
#define TOWN_H
#include "core/pool_type.hpp"
-#include "core/bitmath_func.hpp"
-#include "core/random_func.hpp"
-#include "cargo_type.h"
-#include "tile_type.h"
-#include "date_type.h"
-#include "town_type.h"
-#include "company_type.h"
-#include "settings_type.h"
-#include "strings_type.h"
#include "viewport_type.h"
-#include "economy_type.h"
-#include "map_type.h"
#include "command_type.h"
#include "town_map.h"
#include "subsidy_type.h"
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 0003a512f..7e00409b2 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -10,8 +10,6 @@
/** @file town_cmd.cpp Handling of town tiles. */
#include "stdafx.h"
-#include "openttd.h"
-#include "road_type.h"
#include "road_internal.h" /* Cleaning up road bits */
#include "road_cmd.h"
#include "landscape.h"
@@ -30,7 +28,6 @@
#include "newgrf_commons.h"
#include "newgrf_text.h"
#include "autoslope.h"
-#include "transparency.h"
#include "tunnelbridge_map.h"
#include "strings_func.h"
#include "window_func.h"
@@ -46,6 +43,7 @@
#include "town.h"
#include "townname_func.h"
#include "townname_type.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
#include "table/town_land.h"
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index aed340c41..3c3cd6cfe 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -33,6 +33,7 @@
#include "window_func.h"
#include "townname_func.h"
#include "townname_type.h"
+#include "core/geometry_func.hpp"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/town_map.h b/src/town_map.h
index 148fb2891..c7bd2f527 100644
--- a/src/town_map.h
+++ b/src/town_map.h
@@ -13,7 +13,6 @@
#define TOWN_MAP_H
#include "road_map.h"
-#include "town_type.h"
#include "house.h"
/**
diff --git a/src/townname.cpp b/src/townname.cpp
index 8193e3516..f734f549b 100644
--- a/src/townname.cpp
+++ b/src/townname.cpp
@@ -15,6 +15,7 @@
#include "town.h"
#include "core/alloc_func.hpp"
#include "strings_func.h"
+#include "core/random_func.hpp"
#include "table/townname.h"
diff --git a/src/track_func.h b/src/track_func.h
index 843203da9..2c2ec8e52 100644
--- a/src/track_func.h
+++ b/src/track_func.h
@@ -14,7 +14,6 @@
#include "core/bitmath_func.hpp"
#include "track_type.h"
-#include "direction_type.h"
#include "slope_func.h"
/**
diff --git a/src/train.h b/src/train.h
index 66a42dfd9..1e45ffd00 100644
--- a/src/train.h
+++ b/src/train.h
@@ -12,8 +12,6 @@
#ifndef TRAIN_H
#define TRAIN_H
-#include "stdafx.h"
-#include "core/bitmath_func.hpp"
#include "vehicle_base.h"
struct Train;
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 17a066423..b9aad48bb 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -15,8 +15,6 @@
#include "command_func.h"
#include "pathfinder/npf/npf_func.h"
#include "pathfinder/yapf/yapf.hpp"
-#include "pathfinder/follow_track.hpp"
-#include "openttd.h"
#include "news_func.h"
#include "company_func.h"
#include "vehicle_gui.h"
@@ -31,13 +29,18 @@
#include "vehicle_func.h"
#include "sound_func.h"
#include "autoreplace_gui.h"
-#include "gfx_func.h"
#include "ai/ai.hpp"
#include "newgrf_station.h"
#include "effectvehicle_func.h"
+#include "effectvehicle_base.h"
#include "gamelog.h"
#include "network/network.h"
#include "spritecache.h"
+#include "core/random_func.hpp"
+#include "company_base.h"
+#include "engine_base.h"
+#include "engine_func.h"
+#include "newgrf.h"
#include "table/strings.h"
#include "table/train_cmd.h"
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 1f923a79c..4eb6da762 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -19,6 +19,7 @@
#include "vehicle_func.h"
#include "engine_base.h"
#include "window_func.h"
+#include "settings_type.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index 9b8803c64..69f8defaf 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -10,7 +10,6 @@
/** @file transparency_gui.cpp The transparency GUI. */
#include "stdafx.h"
-#include "openttd.h"
#include "window_gui.h"
#include "transparency.h"
#include "sound_func.h"
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 800cc73c5..7ea424727 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -10,7 +10,6 @@
/** @file tree_cmd.cpp Handling of tree tiles. */
#include "stdafx.h"
-#include "openttd.h"
#include "clear_map.h"
#include "landscape.h"
#include "tree_map.h"
@@ -28,6 +27,7 @@
#include "water.h"
#include "landscape_type.h"
#include "company_base.h"
+#include "core/random_func.hpp"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/tree_map.h b/src/tree_map.h
index 35bab6177..05315ca25 100644
--- a/src/tree_map.h
+++ b/src/tree_map.h
@@ -12,6 +12,8 @@
#ifndef TREE_MAP_H
#define TREE_MAP_H
+#include "tile_map.h"
+
/**
* List of tree types along all landscape types.
*
diff --git a/src/tunnel_map.h b/src/tunnel_map.h
index 1644c0067..2a167055a 100644
--- a/src/tunnel_map.h
+++ b/src/tunnel_map.h
@@ -12,10 +12,6 @@
#ifndef TUNNEL_MAP_H
#define TUNNEL_MAP_H
-#include "direction_func.h"
-#include "rail_type.h"
-#include "road_type.h"
-#include "transport_type.h"
#include "road_map.h"
diff --git a/src/tunnelbridge.h b/src/tunnelbridge.h
index 6672e2af0..5bc417d47 100644
--- a/src/tunnelbridge.h
+++ b/src/tunnelbridge.h
@@ -12,7 +12,7 @@
#ifndef TUNNELBRIDGE_H
#define TUNNELBRIDGE_H
-#include "tile_type.h"
+#include "map_func.h"
/**
* Calculates the length of a tunnel or a bridge (without end tiles)
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index bdf7ced77..6b3c8b976 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -13,7 +13,6 @@
*/
#include "stdafx.h"
-#include "openttd.h"
#include "rail_map.h"
#include "landscape.h"
#include "unmovable_map.h"
@@ -39,6 +38,8 @@
#include "elrail_func.h"
#include "landscape_type.h"
#include "pbs.h"
+#include "company_base.h"
+#include "engine_base.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/tunnelbridge_map.h b/src/tunnelbridge_map.h
index b0b73aec9..ff3a36aac 100644
--- a/src/tunnelbridge_map.h
+++ b/src/tunnelbridge_map.h
@@ -12,13 +12,8 @@
#ifndef TUNNELBRIDGE_MAP_H
#define TUNNELBRIDGE_MAP_H
-#include "direction_func.h"
-#include "core/bitmath_func.hpp"
-#include "tile_map.h"
#include "bridge_map.h"
#include "tunnel_map.h"
-#include "transport_type.h"
-#include "track_func.h"
/**
diff --git a/src/unmovable.h b/src/unmovable.h
index 8709bdc43..0940ce691 100644
--- a/src/unmovable.h
+++ b/src/unmovable.h
@@ -12,9 +12,8 @@
#ifndef UNMOVABLE_H
#define UNMOVABLE_H
-#include "unmovable_map.h"
-#include "economy_type.h"
#include "economy_func.h"
+#include "strings_type.h"
void UpdateCompanyHQ(Company *c, uint score);
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index aab147099..598088a0f 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -10,7 +10,6 @@
/** @file unmovable_cmd.cpp Handling of unmovable tiles. */
#include "stdafx.h"
-#include "openttd.h"
#include "landscape.h"
#include "command_func.h"
#include "viewport_func.h"
@@ -28,6 +27,9 @@
#include "landscape_type.h"
#include "unmovable.h"
#include "cargopacket.h"
+#include "sprite.h"
+#include "core/random_func.hpp"
+#include "unmovable_map.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/unmovable_map.h b/src/unmovable_map.h
index 8a2953b08..72cbc3739 100644
--- a/src/unmovable_map.h
+++ b/src/unmovable_map.h
@@ -12,7 +12,6 @@
#ifndef UNMOVABLE_MAP_H
#define UNMOVABLE_MAP_H
-#include "core/bitmath_func.hpp"
#include "tile_map.h"
/** Types of unmovable structure */
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 6b625f782..844977d12 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -11,7 +11,6 @@
#include "stdafx.h"
#include "gui.h"
-#include "openttd.h"
#include "debug.h"
#include "roadveh.h"
#include "ship.h"
@@ -47,6 +46,9 @@
#include "economy_base.h"
#include "articulated_vehicles.h"
#include "roadstop_base.h"
+#include "core/random_func.hpp"
+#include "engine_base.h"
+#include "newgrf.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index b032b44e4..f3aeb3349 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -12,20 +12,12 @@
#ifndef VEHICLE_BASE_H
#define VEHICLE_BASE_H
-#include "vehicle_type.h"
#include "track_type.h"
-#include "cargo_type.h"
#include "direction_type.h"
-#include "gfx_type.h"
#include "command_type.h"
-#include "date_type.h"
-#include "company_base.h"
-#include "company_type.h"
-#include "core/pool_type.hpp"
#include "order_base.h"
#include "cargopacket.h"
#include "texteff.hpp"
-#include "group_type.h"
#include "engine_type.h"
#include "order_func.h"
#include "transport_type.h"
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 9345b8a32..325737255 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -11,7 +11,6 @@
#include "stdafx.h"
#include "roadveh.h"
-#include "gfx_func.h"
#include "news_func.h"
#include "airport.h"
#include "command_func.h"
@@ -27,6 +26,7 @@
#include "string_func.h"
#include "depot_map.h"
#include "vehiclelist.h"
+#include "engine_base.h"
#include "table/strings.h"
diff --git a/src/vehicle_func.h b/src/vehicle_func.h
index 5b58a8fef..7aa48bb3e 100644
--- a/src/vehicle_func.h
+++ b/src/vehicle_func.h
@@ -12,16 +12,14 @@
#ifndef VEHICLE_FUNC_H
#define VEHICLE_FUNC_H
-#include "tile_type.h"
-#include "strings_type.h"
#include "gfx_type.h"
#include "direction_type.h"
-#include "cargo_type.h"
#include "command_type.h"
#include "vehicle_type.h"
#include "engine_type.h"
#include "transport_type.h"
#include "newgrf_config.h"
+#include "company_type.h"
#define is_custom_sprite(x) (x >= 0xFD)
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 1415b0d7a..c0a0011e5 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -10,17 +10,14 @@
/** @file vehicle_gui.cpp The base GUI for all vehicles. */
#include "stdafx.h"
-#include "openttd.h"
#include "debug.h"
#include "company_func.h"
#include "gui.h"
-#include "window_gui.h"
#include "textbuf_gui.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "vehicle_gui_base.h"
#include "viewport_func.h"
-#include "gfx_func.h"
#include "newgrf_engine.h"
#include "newgrf_text.h"
#include "waypoint_base.h"
@@ -40,6 +37,10 @@
#include "articulated_vehicles.h"
#include "cargotype.h"
#include "spritecache.h"
+#include "core/geometry_func.hpp"
+#include "company_base.h"
+#include "engine_base.h"
+#include "engine_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index 7064fbcc1..fab4b6bb6 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -17,7 +17,7 @@
#include "order_type.h"
#include "station_type.h"
#include "engine_type.h"
-#include "tile_type.h"
+#include "company_type.h"
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent);
diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h
index 72dd8bcc3..7918cb177 100644
--- a/src/vehicle_gui_base.h
+++ b/src/vehicle_gui_base.h
@@ -13,6 +13,7 @@
#define VEHICLE_GUI_BASE_H
#include "sortlist_type.h"
+#include "window_gui.h"
typedef GUIList<const Vehicle*> GUIVehicleList;
diff --git a/src/vehiclelist.h b/src/vehiclelist.h
index d50991ac0..04caccb5a 100644
--- a/src/vehiclelist.h
+++ b/src/vehiclelist.h
@@ -13,6 +13,9 @@
#define VEHICLELIST_H
#include "core/smallvec_type.hpp"
+#include "vehicle_type.h"
+#include "company_type.h"
+#include "tile_type.h"
typedef SmallVector<const Vehicle *, 32> VehicleList;
diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp
index dac11071e..9d9ef1f57 100644
--- a/src/video/allegro_v.cpp
+++ b/src/video/allegro_v.cpp
@@ -18,16 +18,13 @@
#include "../stdafx.h"
#include "../openttd.h"
-#include "../debug.h"
#include "../gfx_func.h"
#include "../variables.h"
#include "../rev.h"
#include "../blitter/factory.hpp"
#include "../network/network.h"
-#include "../core/math_func.hpp"
#include "../core/random_func.hpp"
#include "../functions.h"
-#include "../texteff.hpp"
#include "allegro_v.h"
#include <allegro.h>
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index d7dcc36af..69de090ab 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -13,8 +13,8 @@
#ifdef ENABLE_NETWORK
-#include "../openttd.h"
#include "../gfx_func.h"
+#include "../network/network.h"
#include "../network/network_internal.h"
#include "../console_func.h"
#include "../variables.h"
diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp
index 61f37a622..399b5df12 100644
--- a/src/video/sdl_v.cpp
+++ b/src/video/sdl_v.cpp
@@ -22,6 +22,7 @@
#include "../functions.h"
#include "../thread/thread.h"
#include "../genworld.h"
+#include "../core/random_func.hpp"
#include "sdl_v.h"
#include <SDL.h>
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 7b417f942..0248ee95c 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -26,7 +26,6 @@
*/
#include "stdafx.h"
-#include "openttd.h"
#include "landscape.h"
#include "viewport_func.h"
#include "station_base.h"
@@ -38,7 +37,6 @@
#include "vehicle_base.h"
#include "vehicle_gui.h"
#include "blitter/factory.hpp"
-#include "transparency.h"
#include "strings_func.h"
#include "zoom_func.h"
#include "vehicle_func.h"
diff --git a/src/water.h b/src/water.h
index e4ca10d4d..62cfc37e2 100644
--- a/src/water.h
+++ b/src/water.h
@@ -12,6 +12,10 @@
#ifndef WATER_H
#define WATER_H
+#include "tile_type.h"
+#include "company_type.h"
+#include "slope_type.h"
+
void TileLoop_Water(TileIndex tile);
bool FloodHalftile(TileIndex t);
void DoFloodTile(TileIndex target);
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 7b9f70a50..df8c6221c 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -10,7 +10,6 @@
/** @file water_cmd.cpp Handling of water tiles. */
#include "stdafx.h"
-#include "openttd.h"
#include "cmd_helper.h"
#include "landscape.h"
#include "viewport_func.h"
@@ -19,17 +18,11 @@
#include "news_func.h"
#include "depot_base.h"
#include "depot_func.h"
-#include "vehicle_gui.h"
-#include "train.h"
-#include "roadveh.h"
#include "water.h"
#include "industry_map.h"
-#include "cargotype.h"
#include "newgrf_canal.h"
-#include "transparency.h"
#include "strings_func.h"
#include "functions.h"
-#include "window_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "company_func.h"
@@ -40,6 +33,7 @@
#include "tunnelbridge_map.h"
#include "station_base.h"
#include "ai/ai.hpp"
+#include "core/random_func.hpp"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/water_map.h b/src/water_map.h
index b266aecc1..519326269 100644
--- a/src/water_map.h
+++ b/src/water_map.h
@@ -14,6 +14,7 @@
#include "core/math_func.hpp"
#include "depot_type.h"
+#include "tile_map.h"
enum WaterTileType {
WATER_TILE_CLEAR,
diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp
index b48c3a9fb..2b96f910f 100644
--- a/src/waypoint_gui.cpp
+++ b/src/waypoint_gui.cpp
@@ -16,7 +16,6 @@
#include "vehicle_gui.h"
#include "viewport_func.h"
#include "strings_func.h"
-#include "gfx_func.h"
#include "command_func.h"
#include "company_func.h"
#include "window_func.h"
diff --git a/src/widget.cpp b/src/widget.cpp
index bf8a7d97b..de89bf263 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -10,13 +10,13 @@
/** @file widget.cpp Handling of the default/simple widgets. */
#include "stdafx.h"
-#include "openttd.h"
#include "company_func.h"
#include "window_gui.h"
#include "viewport_func.h"
#include "zoom_func.h"
#include "strings_func.h"
#include "transparency.h"
+#include "core/geometry_func.hpp"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/widget_type.h b/src/widget_type.h
index 0119f37da..820e5c268 100644
--- a/src/widget_type.h
+++ b/src/widget_type.h
@@ -12,9 +12,11 @@
#ifndef WIDGET_TYPE_H
#define WIDGET_TYPE_H
+#include "core/alloc_type.hpp"
#include "core/bitmath_func.hpp"
#include "strings_type.h"
#include "gfx_type.h"
+#include "window_type.h"
enum {
WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 72bc30856..1056ebced 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -12,7 +12,6 @@
#include "../stdafx.h"
#include "../window_gui.h"
#include "../strings_func.h"
-#include "../gfx_func.h"
#include "../window_func.h"
#include "dropdown_type.h"
diff --git a/src/widgets/dropdown_func.h b/src/widgets/dropdown_func.h
index 98971975e..4c7e13456 100644
--- a/src/widgets/dropdown_func.h
+++ b/src/widgets/dropdown_func.h
@@ -12,6 +12,8 @@
#ifndef WIDGETS_DROPDOWN_FUNC_H
#define WIDGETS_DROPDOWN_FUNC_H
+#include "../window_gui.h"
+
/* Show drop down menu containing a fixed list of strings */
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width = 0);
diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h
index 5e71012dc..5431263b0 100644
--- a/src/widgets/dropdown_type.h
+++ b/src/widgets/dropdown_type.h
@@ -13,6 +13,7 @@
#define WIDGETS_DROPDOWN_TYPE_H
#include "../window_type.h"
+#include "../gfx_func.h"
#include <list>
/**
diff --git a/src/window.cpp b/src/window.cpp
index e7ea47896..ee5b04093 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -30,6 +30,7 @@
#include "querystring_gui.h"
#include "widgets/dropdown_func.h"
#include "strings_func.h"
+#include "settings_type.h"
#include "table/sprites.h"
diff --git a/src/window_gui.h b/src/window_gui.h
index 5d58fac16..eb2a6ac7f 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -12,13 +12,10 @@
#ifndef WINDOW_GUI_H
#define WINDOW_GUI_H
-#include "core/geometry_func.hpp"
#include "core/math_func.hpp"
#include "vehicle_type.h"
#include "viewport_type.h"
#include "company_type.h"
-#include "core/alloc_type.hpp"
-#include "window_type.h"
#include "tile_type.h"
#include "widget_type.h"
diff --git a/src/window_type.h b/src/window_type.h
index 466ed69dd..7178f930b 100644
--- a/src/window_type.h
+++ b/src/window_type.h
@@ -12,7 +12,6 @@
#ifndef WINDOW_TYPE_H
#define WINDOW_TYPE_H
-#include "core/enum_type.hpp"
/**
* Window classes