changeset 14258:a899d4e5ee1a draft

(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
author rubidium <rubidium@openttd.org>
date Fri, 15 Jan 2010 16:41:15 +0000
parents 40b920f51dd7
children 86d759dcb37d
files src/ai/ai_config.hpp src/ai/ai_core.cpp src/ai/ai_gui.hpp src/ai/ai_info.cpp src/ai/ai_instance.cpp src/ai/ai_instance.hpp src/ai/ai_scanner.cpp src/ai/ai_scanner.hpp src/ai/ai_storage.hpp src/ai/api/ai_abstractlist.cpp src/ai/api/ai_controller.cpp src/ai/api/ai_engine.cpp src/ai/api/ai_execmode.cpp src/ai/api/ai_group.cpp src/ai/api/ai_industrytype.cpp src/ai/api/ai_list.cpp src/ai/api/ai_map.cpp src/ai/api/ai_object.cpp src/ai/api/ai_rail.cpp src/ai/api/ai_road.cpp src/ai/api/ai_station.cpp src/ai/api/ai_testmode.cpp src/ai/api/ai_tile.cpp src/ai/api/ai_vehicle.cpp src/aircraft.h src/aircraft_cmd.cpp src/aircraft_gui.cpp src/airport.h src/airport_gui.cpp src/articulated_vehicles.cpp src/autoreplace_base.h src/autoreplace_cmd.cpp src/autoreplace_func.h src/autoreplace_gui.cpp src/autoreplace_gui.h src/autoslope.h src/base_media_func.h src/base_station_base.h src/blitter/32bpp_anim.cpp src/blitter/32bpp_anim.hpp src/blitter/32bpp_base.cpp src/blitter/32bpp_base.hpp src/blitter/32bpp_optimized.cpp src/blitter/32bpp_simple.cpp src/blitter/base.hpp src/bridge.h src/bridge_gui.cpp src/bridge_map.h src/build_vehicle_gui.cpp src/cargopacket.h src/clear_cmd.cpp src/company_base.h src/company_cmd.cpp src/company_func.h src/company_gui.cpp src/console.cpp src/console_cmds.cpp src/console_gui.cpp src/console_internal.h src/core/mem_func.hpp src/core/sort_func.hpp src/crashlog.cpp src/date_gui.cpp src/date_gui.h src/debug.cpp src/depot_base.h src/depot_func.h src/depot_gui.cpp src/depot_map.h src/disaster_cmd.cpp src/dock_gui.cpp src/driver.cpp src/driver.h src/economy.cpp src/economy_func.h src/economy_type.h src/effectvehicle.cpp src/effectvehicle_func.h src/elrail.cpp src/elrail_func.h src/engine.cpp src/engine_base.h src/engine_func.h src/engine_gui.h src/engine_type.h src/fontcache.h src/functions.h src/gamelog.cpp src/gamelog_internal.h src/genworld.cpp src/genworld_gui.cpp src/gfx_type.h src/gfxinit.cpp src/graph_gui.cpp src/group_gui.cpp src/group_gui.h src/gui.h src/highscore.cpp src/highscore.h src/highscore_gui.cpp src/industry.h src/industry_cmd.cpp src/industry_gui.cpp src/industry_map.h src/industrytype.h src/intro_gui.cpp src/landscape.cpp src/landscape.h src/main_gui.cpp src/misc/array.hpp src/misc/blob.hpp src/misc/dbg_helpers.h src/misc/fixedsizearray.hpp src/misc/str.hpp src/misc_gui.cpp src/music.cpp src/music/extmidi.cpp src/music/win32_m.cpp src/music_gui.cpp src/network/core/core.cpp src/network/core/core.h src/network/core/host.h src/network/core/tcp.h src/network/core/tcp_game.cpp src/network/core/tcp_game.h src/network/core/udp.cpp src/network/core/udp.h src/network/network.cpp src/network/network.h src/network/network_base.h src/network/network_chat_gui.cpp src/network/network_client.cpp src/network/network_client.h src/network/network_command.cpp src/network/network_content.h src/network/network_content_gui.cpp src/network/network_func.h src/network/network_gui.cpp src/network/network_gui.h src/network/network_internal.h src/network/network_server.cpp src/network/network_server.h src/network/network_type.h src/network/network_udp.cpp src/network/network_udp.h src/newgrf.cpp src/newgrf.h src/newgrf_canal.cpp src/newgrf_canal.h src/newgrf_cargo.cpp src/newgrf_commons.h src/newgrf_engine.cpp src/newgrf_engine.h src/newgrf_generic.cpp src/newgrf_generic.h src/newgrf_gui.cpp src/newgrf_house.cpp src/newgrf_house.h src/newgrf_industries.cpp src/newgrf_industries.h src/newgrf_industrytiles.cpp src/newgrf_industrytiles.h src/newgrf_sound.h src/newgrf_spritegroup.cpp src/newgrf_spritegroup.h src/newgrf_station.cpp src/newgrf_station.h src/newgrf_text.h src/newgrf_town.h src/news_gui.cpp src/openttd.cpp src/order_cmd.cpp src/order_func.h src/order_gui.cpp src/os/unix/unix.cpp src/pathfinder/follow_track.hpp src/pathfinder/npf/npf.cpp src/pathfinder/npf/npf_func.h src/pathfinder/opf/opf_ship.cpp src/pathfinder/opf/opf_ship.h src/pathfinder/pathfinder_func.h src/pathfinder/pathfinder_type.h src/pathfinder/yapf/yapf.h src/pbs.cpp src/rail.h src/rail_cmd.cpp src/rail_gui.cpp src/rail_map.h src/road_cmd.cpp src/road_cmd.h src/road_func.h src/road_gui.cpp src/road_internal.h src/road_map.h src/roadstop_base.h src/roadveh.h src/roadveh_cmd.cpp src/saveload/afterload.cpp src/saveload/autoreplace_sl.cpp src/saveload/gamelog_sl.cpp src/saveload/industry_sl.cpp src/saveload/misc_sl.cpp src/saveload/oldloader.h src/saveload/oldloader_sl.cpp src/saveload/saveload.cpp src/saveload/saveload_internal.h src/saveload/signs_sl.cpp src/saveload/station_sl.cpp src/saveload/vehicle_sl.cpp src/saveload/waypoint_sl.cpp src/script/script_info.hpp src/sdl.h src/settings.cpp src/settings_func.h src/settings_gui.cpp src/settings_internal.h src/ship.h src/ship_cmd.cpp src/signal.cpp src/signs_base.h src/signs_func.h src/signs_gui.cpp src/smallmap_gui.cpp src/sound.cpp src/sound/allegro_s.cpp src/sound/win32_s.cpp src/spritecache.cpp src/spriteloader/png.cpp src/spriteloader/spriteloader.hpp src/station.cpp src/station_base.h src/station_cmd.cpp src/station_func.h src/station_gui.cpp src/station_gui.h src/station_type.h src/statusbar_gui.cpp src/strings.cpp src/subsidy.cpp src/subsidy_func.h src/subsidy_gui.cpp src/terraform_gui.cpp src/texteff.cpp src/texteff.hpp src/tile_cmd.h src/tile_map.h src/tile_type.h src/tilehighlight_func.h src/tilehighlight_type.h src/timetable.h src/timetable_gui.cpp src/toolbar_gui.cpp src/town.h src/town_cmd.cpp src/town_gui.cpp src/town_map.h src/townname.cpp src/track_func.h src/train.h src/train_cmd.cpp src/train_gui.cpp src/transparency_gui.cpp src/tree_cmd.cpp src/tree_map.h src/tunnel_map.h src/tunnelbridge.h src/tunnelbridge_cmd.cpp src/tunnelbridge_map.h src/unmovable.h src/unmovable_cmd.cpp src/unmovable_map.h src/vehicle.cpp src/vehicle_base.h src/vehicle_cmd.cpp src/vehicle_func.h src/vehicle_gui.cpp src/vehicle_gui.h src/vehicle_gui_base.h src/vehiclelist.h src/video/allegro_v.cpp src/video/dedicated_v.cpp src/video/sdl_v.cpp src/viewport.cpp src/water.h src/water_cmd.cpp src/water_map.h src/waypoint_gui.cpp src/widget.cpp src/widget_type.h src/widgets/dropdown.cpp src/widgets/dropdown_func.h src/widgets/dropdown_type.h src/window.cpp src/window_gui.h src/window_type.h
diffstat 295 files changed, 308 insertions(+), 351 deletions(-) [+]
line wrap: on
line diff
--- 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:
--- 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"
--- 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();
 
--- 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"
--- 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()
--- 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.
  */
--- 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"
--- 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 {
--- 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>
 
 /**
--- 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"
--- 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"
--- 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"
--- 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"
--- 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"
--- 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)
 {
--- 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)
--- 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"
 
--- 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"
--- 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"
 
--- 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"
--- 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"
--- 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"
--- 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"
--- 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)
--- 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;
 
--- 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"
--- 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"
 
--- 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 */
--- 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"
--- 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"
--- 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;
 
--- 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"
 
--- 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.
--- 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"
 
--- 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"
 
 /**
--- 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.
--- 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 "debug.h"
+#include "ini_type.h"
 #include "string_func.h"
-#include "ini_type.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;
--- 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"
 
--- 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"
 
--- 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:
--- 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)
--- 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:
--- 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"
 
--- 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"
 
--- 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,
--- 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,
--- 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"
 
--- 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"
 
--- 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"
 
--- 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"
--- 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"
--- 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"
--- 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"
 
--- 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);
--- 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"
 
--- 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>
 
--- 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"
--- 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"
 
 
--- 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
--- 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"
 
 /**
--- 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"
 
 /**
--- 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;
--- 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"
 
--- 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
--- 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 */
 
--- 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;
--- 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"
--- 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"
--- 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"
 
 /**
--- 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"
--- 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"
--- 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;
--- 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);
--- 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"
--- 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);
--- 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;
 
--- 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"
 
--- 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 {
--- 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"
--- a/src/elrail_func.h
+++ b/src/elrail_func.h
@@ -13,9 +13,8 @@
 #define ELRAIL_FUNC_H
 
 #include "rail.h"
+#include "tile_cmd.h"
 #include "transparency.h"
-#include "tile_cmd.h"
-#include "settings_type.h"
 
 /**
  * Test if a rail type has catenary
--- 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"
--- 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"
 
--- 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();
--- 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;
 
--- 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;
--- 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 */
--- 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 */
--- 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"
--- 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 {
--- 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"
 
--- 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"
--- 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"
 
--- 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"
--- 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"
--- 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"
--- 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);
--- 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"
--- 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"
--- 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 {
--- 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"
--- 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"
--- 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"
--- 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"
--- 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"
 
 
--- 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
--- 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"
--- 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"
 
--- 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.
--- 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"
--- 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 */
--- 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.
--- 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;
 
--- 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
--- 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 */
--- 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"
 
--- 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"
--- 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"
--- 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>
--- 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"
--- 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"
 
 
--- 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
--- 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 */
--- 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
--- 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"
 
--- 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
--- 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"
 
 /**
--- 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
 
--- 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"
--- 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
 
--- 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;
--- 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"
 
--- 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"
 
--- 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);
--- 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,
--- 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)
 
--- 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"
--- 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
 
--- 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"
--- 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"
 
--- 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"
--- 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"
--- 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);
--- 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
--- 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"
--- 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();
--- 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"
--- 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"
--- 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"
 
 
--- 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 {
--- 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)
 {
--- 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"
--- 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;
--- 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,
--- 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>
 
 
--- 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,
--- 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"
--- 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];
--- 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"
--- 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"
 
--- 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? */
--- 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"
--- 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,
--- 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,
--- 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");
--- 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"
--- 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"
 
--- 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
--- 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);
--- 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. */
 
--- 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"
 
--- 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"
 
--- 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"
 
--- 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 {
--- 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"
--- 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>
--- 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
--- 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"
--- 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"
 
 /**
--- 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;
--- 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
--- 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"
 
 /**
--- 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;
 
--- 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"
 
 /**
--- 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.
--- 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"
--- 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"
--- 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"
--- 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"
--- 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"
--- 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);
--- 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.
--- 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"
--- 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.
--- 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"
 
--- 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;
--- 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;
 
--- 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"
--- 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"
 
--- 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"
--- 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"
 
--- 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"
 
--- 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"
 
--- 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,
--- 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"
 
--- 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"
 
--- 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"
--- 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"
--- 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"
--- 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"
 
--- 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"
 
--- 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 {
--- a/src/sdl.h
+++ b/src/sdl.h
@@ -20,7 +20,6 @@
 #endif
 
 #ifdef DYNAMICALLY_LOADED_SDL
-	#include <SDL.h>
 
 	struct SDLProcs {
 		int (SDLCALL *SDL_Init)(Uint32);
--- 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"
--- 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);
--- 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"
--- 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
--- 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);
--- 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"
--- 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 */
--- 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;
--- 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;
 
--- 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"
--- 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"
--- 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"
--- 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"
--- 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>
--- 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"
--- 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"
--- 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:
--- 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"
 
--- 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;
--- 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"
 
--- 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);
 
--- 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"
--- 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 {
--- 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;
--- 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"
--- 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"
--- 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"
 
--- 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);
--- 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"
 
--- 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"
--- 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"
--- 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.
--- 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. */
--- 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"
--- 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
--- 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);
--- 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 {
--- 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);
--- 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"
--- 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"
--- 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"
--- 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"
--- 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"
--- 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"
 
 /**
--- 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"
 
--- 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"
 
 /**
--- 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;
--- 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"
--- 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"
--- 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"
--- 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"
--- 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.
  *
--- 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"
 
 
--- 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)
--- 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"
--- 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"
 
 
 /**
--- 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);
 
--- 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"
--- 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 */
--- 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"
--- 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"
--- 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"
 
--- 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)
--- 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"
--- 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);
 
--- 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;
 
--- 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;
 
--- 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>
 
--- 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"
--- 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>
 
--- 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"
--- 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);
--- 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"
--- 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,
--- 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"
--- 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"
--- 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
--- 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"
 
--- 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);
 
--- 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>
 
 /**
--- 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"
 
--- 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"
 
--- 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