(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
authorrubidium
Tue, 25 Dec 2007 11:26:07 +0000
changeset 8131 160939e24ed3
parent 8130 d2eb7d04f6e1
child 8132 f4c7a8e4f25a
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
src/ai/ai.h
src/ai/default/default.cpp
src/ai/trolly/build.cpp
src/ai/trolly/pathfinder.cpp
src/ai/trolly/trolly.cpp
src/aircraft_cmd.cpp
src/aircraft_gui.cpp
src/airport_gui.cpp
src/articulated_vehicles.cpp
src/autoreplace_cmd.cpp
src/autoreplace_gui.cpp
src/blitter/8bpp_debug.cpp
src/bridge_gui.cpp
src/build_vehicle_gui.cpp
src/clear_cmd.cpp
src/command.cpp
src/console.cpp
src/console_cmds.cpp
src/date.cpp
src/debug.cpp
src/debug.h
src/depot.cpp
src/depot_gui.cpp
src/disaster_cmd.cpp
src/dock_gui.cpp
src/driver.cpp
src/economy.cpp
src/elrail.cpp
src/engine.cpp
src/engine_gui.cpp
src/fileio.cpp
src/fileio.h
src/fios.cpp
src/fontcache.cpp
src/functions.h
src/genworld.cpp
src/genworld_gui.cpp
src/gfx.cpp
src/gfxinit.cpp
src/graph_gui.cpp
src/group_cmd.cpp
src/group_gui.cpp
src/gui.h
src/heightmap.cpp
src/industry_cmd.cpp
src/industry_gui.cpp
src/intro_gui.cpp
src/landscape.cpp
src/main_gui.cpp
src/map.cpp
src/misc.cpp
src/misc_cmd.cpp
src/misc_gui.cpp
src/music_gui.cpp
src/network/core/tcp.cpp
src/network/network.cpp
src/network/network_client.cpp
src/network/network_gui.cpp
src/network/network_server.cpp
src/newgrf.cpp
src/newgrf_config.cpp
src/newgrf_engine.cpp
src/newgrf_gui.cpp
src/newgrf_house.cpp
src/newgrf_industries.cpp
src/newgrf_industrytiles.cpp
src/newgrf_spritegroup.h
src/newgrf_town.cpp
src/news_gui.cpp
src/npf.cpp
src/oldloader.cpp
src/oldpool.cpp
src/openttd.cpp
src/order_cmd.cpp
src/order_gui.cpp
src/os/macosx/splash.cpp
src/os2.cpp
src/player_face.h
src/player_gui.cpp
src/players.cpp
src/rail_gui.cpp
src/road.cpp
src/road_gui.cpp
src/roadveh_cmd.cpp
src/roadveh_gui.cpp
src/saveload.cpp
src/screenshot.cpp
src/settings.cpp
src/settings.h
src/settings_gui.cpp
src/ship_cmd.cpp
src/ship_gui.cpp
src/signs.cpp
src/signs_gui.cpp
src/smallmap_gui.cpp
src/sound.cpp
src/sound/win32_s.cpp
src/spritecache.cpp
src/station.cpp
src/station_cmd.cpp
src/station_gui.cpp
src/string.cpp
src/strings.cpp
src/subsidy_gui.cpp
src/terraform_gui.cpp
src/texteff.cpp
src/tgp.cpp
src/timetable_cmd.cpp
src/timetable_gui.cpp
src/town.h
src/town_cmd.cpp
src/town_gui.cpp
src/town_map.h
src/train_cmd.cpp
src/train_gui.cpp
src/transparency_gui.cpp
src/tree_cmd.cpp
src/tunnelbridge_cmd.cpp
src/unix.cpp
src/unmovable_cmd.cpp
src/vehicle.cpp
src/vehicle.h
src/vehicle_gui.cpp
src/video/cocoa/wnd_quartz.mm
src/video/cocoa/wnd_quickdraw.mm
src/video/dedicated_v.cpp
src/video/sdl_v.cpp
src/video/win32_v.cpp
src/water_cmd.cpp
src/waypoint.cpp
src/widget.cpp
src/win32.cpp
src/window.cpp
src/window_func.h
--- a/src/ai/ai.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/ai/ai.h	Tue Dec 25 11:26:07 2007 +0000
@@ -3,10 +3,10 @@
 #ifndef AI_H
 #define AI_H
 
-#include "../functions.h"
 #include "../network/network.h"
 #include "../player.h"
 #include "../command_type.h"
+#include "../core/random_func.hpp"
 
 /* How DoCommands look like for an AI */
 struct AICommand {
--- a/src/ai/default/default.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/ai/default/default.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -26,6 +26,8 @@
 #include "../../bridge.h"
 #include "../../date.h"
 #include "../../tunnelbridge_map.h"
+#include "../../window_func.h"
+#include "../../functions.h"
 #include "default.h"
 
 
--- a/src/ai/trolly/build.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/ai/trolly/build.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -3,7 +3,6 @@
 #include "../../stdafx.h"
 #include "../../openttd.h"
 #include "../../debug.h"
-#include "../../functions.h"
 #include "../../map.h"
 #include "../../road_map.h"
 #include "../../vehicle.h"
--- a/src/ai/trolly/pathfinder.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/ai/trolly/pathfinder.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 #include "../../openttd.h"
 #include "../../bridge_map.h"
 #include "../../debug.h"
-#include "../../functions.h"
 #include "../../map.h"
 #include "../../command_func.h"
 #include "trolly.h"
--- a/src/ai/trolly/trolly.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/ai/trolly/trolly.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -20,7 +20,6 @@
 #include "../../stdafx.h"
 #include "../../openttd.h"
 #include "../../debug.h"
-#include "../../functions.h"
 #include "../../road_map.h"
 #include "../../station_map.h"
 #include "table/strings.h"
--- a/src/aircraft_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/aircraft_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -7,7 +7,6 @@
 #include "openttd.h"
 #include "aircraft.h"
 #include "debug.h"
-#include "functions.h"
 #include "landscape.h"
 #include "station_map.h"
 #include "table/strings.h"
@@ -33,6 +32,8 @@
 #include "cargotype.h"
 #include "strings_func.h"
 #include "command_func.h"
+#include "window_func.h"
+#include "functions.h"
 
 void Aircraft::UpdateDeltaXY(Direction direction)
 {
--- a/src/aircraft_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/aircraft_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "aircraft.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "map.h"
--- a/src/airport_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/airport_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "map.h"
 #include "window_gui.h"
 #include "gui.h"
@@ -18,6 +17,7 @@
 #include "station.h"
 #include "airport.h"
 #include "depot.h"
+#include "window_func.h"
 
 static byte _selected_airport_type;
 
--- a/src/articulated_vehicles.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/articulated_vehicles.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "vehicle.h"
 #include "articulated_vehicles.h"
 #include "engine.h"
--- a/src/autoreplace_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/autoreplace_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "roadveh.h"
 #include "ship.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "news.h"
 #include "player.h"
 #include "engine.h"
@@ -19,6 +18,7 @@
 #include "order.h"
 #include "strings_func.h"
 #include "command_func.h"
+#include "functions.h"
 
 /*
  * move the cargo from one engine to another if possible
--- a/src/autoreplace_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/autoreplace_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "gui.h"
@@ -16,6 +15,7 @@
 #include "group.h"
 #include "rail.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 static RailType _railtype_selected_in_replace_gui;
 
--- a/src/blitter/8bpp_debug.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/blitter/8bpp_debug.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,7 @@
 
 #include "../stdafx.h"
 #include "../zoom_func.h"
-#include "../functions.h"
+#include "../core/random_func.hpp"
 #include "8bpp_debug.hpp"
 
 static FBlitter_8bppDebug iFBlitter_8bppDebug;
--- a/src/bridge_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/bridge_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "map.h"
 #include "gui.h"
 #include "window_gui.h"
@@ -16,6 +15,7 @@
 #include "variables.h"
 #include "bridge.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 static struct BridgeData {
 	uint8 last_size;
--- a/src/build_vehicle_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/build_vehicle_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -9,7 +9,6 @@
 #include "ship.h"
 #include "aircraft.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "gui.h"
@@ -29,6 +28,7 @@
 #include "group.h"
 #include "road_map.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 
 enum BuildVehicleWidgets {
--- a/src/clear_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/clear_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -7,7 +7,6 @@
 #include "clear_map.h"
 #include "rail_map.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "map.h"
 #include "player.h"
 #include "viewport.h"
@@ -23,6 +22,8 @@
 #include "industry.h"
 #include "water_map.h"
 #include "tile_cmd.h"
+#include "vehicle.h"
+#include "functions.h"
 
 /*
  * In one terraforming command all four corners of a initial tile can be raised/lowered (though this is not available to the player).
--- a/src/command.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/command.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "landscape.h"
 #include "map.h"
 #include "tile_map.h"
@@ -18,6 +17,7 @@
 #include "newgrf_storage.h"
 #include "strings_func.h"
 #include "gfx_func.h"
+#include "functions.h"
 
 const char *_cmd_text = NULL;
 
--- a/src/console.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/console.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "gui.h"
 #include "textbuf_gui.h"
 #include "window_gui.h"
@@ -19,6 +18,7 @@
 #include "network/network_data.h"
 #include "network/network_server.h"
 #include "core/alloc_func.hpp"
+#include "window_func.h"
 
 #define ICON_BUFFER 79
 #define ICON_HISTORY_SIZE 20
--- a/src/console_cmds.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/console_cmds.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -7,7 +7,6 @@
 #include "console.h"
 #include "debug.h"
 #include "engine.h"
-#include "functions.h"
 #include "landscape.h"
 #include "saveload.h"
 #include "string.h"
@@ -28,6 +27,8 @@
 #include "network/network.h"
 #include "strings_func.h"
 #include "viewport.h"
+#include "window_func.h"
+#include "functions.h"
 
 // ** scriptfile handling ** //
 static FILE *_script_file;
--- a/src/date.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/date.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -10,8 +10,9 @@
 #include "network/network.h"
 #include "network/network_data.h"
 #include "network/network_server.h"
+#include "currency.h"
+#include "window_func.h"
 #include "functions.h"
-#include "currency.h"
 #ifdef DEBUG_DUMP_COMMANDS
 #include "saveload.h"
 #endif
--- a/src/debug.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/debug.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -8,7 +8,6 @@
 #include "openttd.h"
 #include "console.h"
 #include "debug.h"
-#include "functions.h"
 #include "string.h"
 #include "network/core/core.h"
 
--- a/src/debug.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/debug.h	Tue Dec 25 11:26:07 2007 +0000
@@ -129,4 +129,7 @@
 	}\
 }
 
+void ShowInfo(const char *str);
+void CDECL ShowInfoF(const char *str, ...);
+
 #endif /* DEBUG_H */
--- a/src/depot.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/depot.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,12 +6,12 @@
 #include "openttd.h"
 #include "vehicle.h"
 #include "depot.h"
-#include "functions.h"
 #include "landscape.h"
 #include "map.h"
 #include "table/strings.h"
 #include "saveload.h"
 #include "order.h"
+#include "window_func.h"
 
 DEFINE_OLD_POOL_GENERIC(Depot, Depot)
 
--- a/src/depot_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/depot_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "train.h"
 #include "roadveh.h"
 #include "ship.h"
@@ -22,6 +21,7 @@
 #include "newgrf_engine.h"
 #include "spritecache.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 /*
  * Since all depot window sizes aren't the same, we need to modify sizes a little.
--- a/src/disaster_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/disaster_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -39,6 +39,7 @@
 #include "table/sprites.h"
 #include "date.h"
 #include "strings_func.h"
+#include "functions.h"
 
 enum DisasterSubType {
 	ST_Zeppeliner,
--- a/src/dock_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/dock_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "map.h"
 #include "tile_map.h"
 #include "station.h"
@@ -18,6 +17,7 @@
 #include "command_func.h"
 #include "variables.h"
 #include "water.h"
+#include "window_func.h"
 
 static void ShowBuildDockStationPicker();
 static void ShowBuildDocksDepotPicker();
--- a/src/driver.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/driver.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "debug.h"
 #include "driver.h"
-#include "functions.h"
 #include "string.h"
 
 #include "sound/sound_driver.hpp"
--- a/src/economy.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/economy.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
 #include "landscape.h"
 #include "table/strings.h"
 #include "table/sprites.h"
@@ -40,6 +39,8 @@
 #include "group.h"
 #include "strings_func.h"
 #include "tile_cmd.h"
+#include "functions.h"
+#include "window_func.h"
 
 /**
  * Multiply two integer values and shift the results to right.
--- a/src/elrail.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/elrail.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -49,7 +49,6 @@
 #include "openttd.h"
 #include "station_map.h"
 #include "viewport.h"
-#include "functions.h" /* We should REALLY get rid of this goddamn file, as it is butt-ugly */
 #include "variables.h" /* ... same here */
 #include "landscape.h"
 #include "rail_type.h"
--- a/src/engine.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/engine.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "engine.h"
 #include "player.h"
@@ -24,6 +23,8 @@
 #include "misc/autoptr.hpp"
 #include "strings_func.h"
 #include "viewport.h"
+#include "functions.h"
+#include "window_func.h"
 
 EngineInfo _engine_info[TOTAL_NUM_ENGINES];
 RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
--- a/src/engine_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/engine_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "functions.h"
 #include "gui.h"
 #include "window_gui.h"
 #include "viewport.h"
--- a/src/fileio.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/fileio.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,12 +5,12 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "fileio.h"
-#include "functions.h"
 #include "string.h"
 #include "variables.h"
 #include "debug.h"
 #include "fios.h"
 #include "core/alloc_func.hpp"
+#include "core/math_func.hpp"
 #ifdef WIN32
 #include <windows.h>
 #else
@@ -764,3 +764,31 @@
 		}
 	}
 }
+
+void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize)
+{
+	FILE *in;
+	byte *mem;
+	size_t len;
+
+	in = fopen(filename, "rb");
+	if (in == NULL) return NULL;
+
+	fseek(in, 0, SEEK_END);
+	len = ftell(in);
+	fseek(in, 0, SEEK_SET);
+	if (len > maxsize || (mem = MallocT<byte>(len + 1)) == NULL) {
+		fclose(in);
+		return NULL;
+	}
+	mem[len] = 0;
+	if (fread(mem, len, 1, in) != 1) {
+		fclose(in);
+		free(mem);
+		return NULL;
+	}
+	fclose(in);
+
+	*lenp = len;
+	return mem;
+}
--- a/src/fileio.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/fileio.h	Tue Dec 25 11:26:07 2007 +0000
@@ -112,6 +112,8 @@
 void SanitizeFilename(char *filename);
 void AppendPathSeparator(char *buf, size_t buflen);
 void DeterminePaths(const char *exe);
+void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
+bool FileExists(const char *filename);
 
 extern char *_personal_dir; ///< custom directory for personal settings, saves, newgrf, etc.
 
--- a/src/fios.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/fios.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -8,12 +8,12 @@
 #include "openttd.h"
 #include "string.h"
 #include "variables.h"
-#include "functions.h"
 #include "heightmap.h"
 #include "table/strings.h"
 #include "fios.h"
 #include "fileio.h"
 #include "core/alloc_func.hpp"
+#include "functions.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
--- a/src/fontcache.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/fontcache.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "debug.h"
 #include "table/sprites.h"
 #include "table/control_codes.h"
@@ -15,6 +14,7 @@
 #include "blitter/factory.hpp"
 #include "gfx_func.h"
 #include "core/alloc_func.hpp"
+#include "core/math_func.hpp"
 
 #ifdef WITH_FREETYPE
 
--- a/src/functions.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/functions.h	Tue Dec 25 11:26:07 2007 +0000
@@ -7,11 +7,8 @@
 
 #include "core/random_func.hpp"
 #include "command_type.h"
-#include "window_type.h"
 #include "openttd.h"
 
-void UpdateTownMaxPass(Town *t);
-
 /* clear_land.cpp */
 void DrawHillyLandTile(const TileInfo *ti);
 void DrawClearLandTile(const TileInfo *ti, byte set);
@@ -25,10 +22,6 @@
 bool CheckOwnership(Owner owner);
 bool CheckTileOwnership(TileIndex tile);
 
-/* standard */
-void ShowInfo(const char *str);
-void CDECL ShowInfoF(const char *str, ...);
-
 /* openttd.cpp */
 static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
 static inline TileIndex RandomTile() { return TILE_MASK(Random()); }
@@ -67,14 +60,6 @@
  * @ingroup dirty
  */
 void MarkTileDirtyByTile(TileIndex tile);
-void InvalidateWindow(WindowClass cls, WindowNumber number);
-void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
-void InvalidateWindowClasses(WindowClass cls);
-void InvalidateWindowClassesData(WindowClass cls);
-void DeleteWindowById(WindowClass cls, WindowNumber number);
-void DeleteWindowByClass(WindowClass cls);
-
-bool EnsureNoVehicleOnGround(TileIndex tile);
 
 /**
  * Mark all viewports dirty for repaint.
@@ -85,15 +70,8 @@
 void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost);
 void ShowFeederIncomeAnimation(int x, int y, int z, Money cost);
 
-bool CheckIfAuthorityAllows(TileIndex tile);
-Town *ClosestTownFromTile(TileIndex tile, uint threshold);
-void ChangeTownRating(Town *t, int add, int max);
-
-uint GetTownRadiusGroup(const Town* t, TileIndex tile);
 void ShowHighscoreTable(int difficulty, int8 rank);
 
-void AfterLoadTown();
-void UpdatePatches();
 void AskExitGame();
 void AskExitToGameMenu();
 
@@ -115,13 +93,8 @@
 
 /* callback from drivers that is called if the game size changes dynamically */
 void GameSizeChanged();
-bool FileExists(const char *filename);
 const char *GetCurrentLocale(const char *param);
-void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
 
-void LoadFromConfig();
-void SaveToConfig();
-void CheckConfig();
 int ttd_main(int argc, char* argv[]);
 void HandleExitGameRequest();
 
--- a/src/genworld.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/genworld.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "landscape.h"
 #include "player.h"
 #include "table/sprites.h"
--- a/src/genworld_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/genworld_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "heightmap.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "table/sprites.h"
 #include "gui.h"
@@ -25,6 +24,7 @@
 #include "date.h"
 #include "newgrf_config.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 /**
  * In what 'mode' the GenerateLandscapeWindowProc is.
--- a/src/gfx.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/gfx.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "gfx_func.h"
 #include "spritecache.h"
 #include "string.h"
@@ -20,6 +19,7 @@
 #include "blitter/factory.hpp"
 #include "video/video_driver.hpp"
 #include "strings_func.h"
+#include "core/math_func.hpp"
 
 byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
 bool _fullscreen;
--- a/src/gfxinit.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/gfxinit.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "gfxinit.h"
 #include "spritecache.h"
 #include "table/sprites.h"
--- a/src/graph_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/graph_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "functions.h"
 #include "gui.h"
 #include "window_gui.h"
 #include "player.h"
@@ -16,6 +15,7 @@
 #include "cargotype.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
+#include "window_func.h"
 
 /* Bitmasks of player and cargo indices that shouldn't be drawn. */
 static uint _legend_excluded_players;
--- a/src/group_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/group_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "variables.h"
-#include "functions.h"
 #include "player.h"
 #include "table/strings.h"
 #include "command_func.h"
@@ -19,6 +18,8 @@
 #include "vehicle_gui.h"
 #include "misc/autoptr.hpp"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 /**
  * Update the num engines of a groupID. Decrease the old one and increase the new one
--- a/src/group_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/group_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "table/sprites.h"
 #include "gui.h"
@@ -22,6 +21,7 @@
 #include "debug.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
+#include "window_func.h"
 
 
 struct Sorting {
--- a/src/gui.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/gui.h	Tue Dec 25 11:26:07 2007 +0000
@@ -8,6 +8,7 @@
 #include "window_type.h"
 #include "vehicle_type.h"
 #include "gfx_type.h"
+#include "economy_type.h"
 
 /* main_gui.cpp */
 void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);
--- a/src/heightmap.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/heightmap.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "variables.h"
-#include "functions.h"
 #include "heightmap.h"
 #include "clear_map.h"
 #include "table/strings.h"
--- a/src/industry_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/industry_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "clear_map.h"
-#include "functions.h"
 #include "industry_map.h"
 #include "station_map.h"
 #include "table/strings.h"
@@ -40,6 +39,8 @@
 #include "water.h"
 #include "strings_func.h"
 #include "tile_cmd.h"
+#include "functions.h"
+#include "window_func.h"
 
 void ShowIndustryViewWindow(int industry);
 void BuildOilRig(TileIndex tile);
--- a/src/industry_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/industry_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "table/sprites.h"
 #include "map.h"
--- a/src/intro_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/intro_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "functions.h"
 #include "gui.h"
 #include "window_gui.h"
 #include "textbuf_gui.h"
@@ -19,6 +18,8 @@
 #include "network/network_gui.h"
 #include "newgrf.h"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 static const Widget _select_game_widgets[] = {
 {    WWT_CAPTION, RESIZE_NONE, 13,   0, 335,   0,  13, STR_0307_OPENTTD,         STR_NULL},
--- a/src/landscape.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/landscape.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "heightmap.h"
 #include "clear_map.h"
 #include "date.h"
-#include "functions.h"
 #include "map.h"
 #include "player.h"
 #include "spritecache.h"
@@ -23,6 +22,9 @@
 #include "genworld.h"
 #include "tile_cmd.h"
 #include "core/alloc_func.hpp"
+#include "functions.h"
+#include "window_func.h"
+#include "functions.h"
 
 extern const TileTypeProcs
 	_tile_type_clear_procs,
--- a/src/main_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/main_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "heightmap.h"
 #include "currency.h"
-#include "functions.h"
 #include "spritecache.h"
 #include "station.h"
 #include "table/sprites.h"
@@ -42,6 +41,7 @@
 #include "newgrf_config.h"
 #include "rail_gui.h"
 #include "road_gui.h"
+#include "functions.h"
 
 #include "network/network_data.h"
 #include "network/network_client.h"
--- a/src/map.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/map.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,11 +5,11 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "map.h"
 #include "direction_func.h"
 #include "core/bitmath_func.hpp"
 #include "core/alloc_func.hpp"
+#include "core/math_func.hpp"
 
 #if defined(_MSC_VER) && _MSC_VER >= 1400 /* VStudio 2005 is stupid! */
 /* Why the hell is that not in all MSVC headers?? */
--- a/src/misc.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/misc.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
 #include "landscape.h"
 #include "news.h"
 #include "player.h"
@@ -26,6 +25,7 @@
 #include "viewport.h"
 #include "economy_func.h"
 #include "zoom_func.h"
+#include "functions.h"
 
 char _name_array[512][32];
 
--- a/src/misc_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/misc_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "string.h"
 #include "table/strings.h"
 #include "command_func.h"
@@ -20,6 +19,7 @@
 #include "strings_func.h"
 #include "vehicle.h"
 #include "gfx_func.h"
+#include "functions.h"
 
 /** Change the player's face.
  * @param tile unused
--- a/src/misc_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/misc_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "heightmap.h"
 #include "debug.h"
-#include "functions.h"
 #include "landscape.h"
 #include "newgrf.h"
 #include "newgrf_text.h"
@@ -41,6 +40,8 @@
 #include "fios.h"
 #include "tile_cmd.h"
 #include "zoom_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 /* Variables to display file lists */
 FiosItem *_fios_list;
--- a/src/music_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/music_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "functions.h"
 #include "fileio.h"
 #include "sound.h"
 #include "variables.h"
@@ -14,6 +13,7 @@
 #include "music/music_driver.hpp"
 #include "window_gui.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 static byte _music_wnd_cursong;
 static bool _song_is_active;
--- a/src/network/core/tcp.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/network/core/tcp.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -11,7 +11,6 @@
 #include "../../openttd.h"
 #include "../../variables.h"
 #include "table/strings.h"
-#include "../../functions.h"
 
 #include "../network_data.h"
 #include "packet.h"
--- a/src/network/network.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/network/network.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -9,7 +9,6 @@
 
 #include "../openttd.h"
 #include "../debug.h"
-#include "../functions.h"
 #include "../string.h"
 #include "../strings_func.h"
 #include "../map.h"
@@ -31,6 +30,8 @@
 #include "../md5.h"
 #include "../fileio.h"
 #include "../texteff.hpp"
+#include "../core/random_func.hpp"
+#include "../window_func.h"
 
 /* Check whether NETWORK_NUM_LANDSCAPES is still in sync with NUM_LANDSCAPE */
 assert_compile((int)NETWORK_NUM_LANDSCAPES == (int)NUM_LANDSCAPE);
--- a/src/network/network_client.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/network/network_client.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -10,7 +10,6 @@
 #include "core/tcp.h"
 #include "../date.h"
 #include "table/strings.h"
-#include "../functions.h"
 #include "network_client.h"
 #include "network_gamelist.h"
 #include "network_gui.h"
@@ -23,6 +22,7 @@
 #include "../fileio.h"
 #include "../md5.h"
 #include "../strings_func.h"
+#include "../window_func.h"
 
 // This file handles all the client-commands
 
--- a/src/network/network_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/network/network_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -11,7 +11,6 @@
 
 #include "../fios.h"
 #include "table/strings.h"
-#include "../functions.h"
 #include "network_data.h"
 #include "network_client.h"
 #include "network_gui.h"
@@ -26,6 +25,8 @@
 #include "../string.h"
 #include "../town.h"
 #include "../newgrf.h"
+#include "../functions.h"
+#include "../window_func.h"
 
 #define BGC 5
 #define BTC 15
--- a/src/network/network_server.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/network/network_server.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -13,7 +13,6 @@
 #include "../aircraft.h"
 #include "../date.h"
 #include "table/strings.h"
-#include "../functions.h"
 #include "network_server.h"
 #include "network_udp.h"
 #include "../console.h"
--- a/src/newgrf.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -9,7 +9,6 @@
 #include "openttd.h"
 #include "debug.h"
 #include "fileio.h"
-#include "functions.h"
 #include "engine.h"
 #include "spritecache.h"
 #include "station.h"
--- a/src/newgrf_config.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf_config.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "debug.h"
 #include "variables.h"
 #include "string.h"
--- a/src/newgrf_engine.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf_engine.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "variables.h"
 #include "debug.h"
-#include "functions.h"
 #include "engine.h"
 #include "train.h"
 #include "player.h"
--- a/src/newgrf_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "gui.h"
 #include "window_gui.h"
@@ -14,6 +13,7 @@
 #include "newgrf.h"
 #include "newgrf_config.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 /** Parse an integerlist string and set each found value
  * @param p the string to be parsed. Each element in the list is seperated by a
--- a/src/newgrf_house.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf_house.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "debug.h"
 #include "viewport.h"
@@ -25,6 +24,7 @@
 #include "newgrf_sound.h"
 #include "newgrf_commons.h"
 #include "transparency.h"
+#include "functions.h"
 
 static BuildingCounts    _building_counts;
 static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
--- a/src/newgrf_industries.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf_industries.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "variables.h"
 #include "landscape.h"
 #include "table/strings.h"
@@ -20,6 +19,7 @@
 #include "newgrf_text.h"
 #include "newgrf_town.h"
 #include "date.h"
+#include "window_func.h"
 
 /* Since the industry IDs defined by the GRF file don't necessarily correlate
  * to those used by the game, the IDs used for overriding old industries must be
--- a/src/newgrf_industrytiles.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf_industrytiles.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "debug.h"
 #include "viewport.h"
@@ -23,6 +22,7 @@
 #include "table/strings.h"
 #include "sprite.h"
 #include "transparency.h"
+#include "functions.h"
 
 static uint32 GetGRFParameter(IndustryGfx indtile_id, byte parameter)
 {
--- a/src/newgrf_spritegroup.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf_spritegroup.h	Tue Dec 25 11:26:07 2007 +0000
@@ -8,6 +8,8 @@
 #include "town.h"
 #include "industry.h"
 #include "newgrf_storage.h"
+#include "core/bitmath_func.hpp"
+#include "gfx_type.h"
 
 /**
  * Gets the value of a so-called newgrf "register".
--- a/src/newgrf_town.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/newgrf_town.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,7 @@
 #include "openttd.h"
 #include "variables.h"
 #include "debug.h"
-#include "functions.h"
+#include "core/bitmath_func.hpp"
 #include "town.h"
 
 /** This function implements the town variables that newGRF defines.
--- a/src/news_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/news_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -3,7 +3,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "gui.h"
@@ -17,6 +16,7 @@
 #include "string.h"
 #include "transparency.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 /** @file news_gui.cpp
  *
--- a/src/npf.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/npf.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -8,7 +8,6 @@
 #include "debug.h"
 #include "tile_cmd.h"
 #include "bridge.h"
-#include "functions.h"
 #include "landscape.h"
 #include "npf.h"
 #include "aystar.h"
@@ -20,6 +19,7 @@
 #include "network/network.h"
 #include "water_map.h"
 #include "tunnelbridge_map.h"
+#include "functions.h"
 
 static AyStar _npf_aystar;
 
--- a/src/oldloader.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/oldloader.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "station_map.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "map.h"
 #include "town.h"
 #include "industry.h"
@@ -25,6 +24,7 @@
 #include "ai/ai.h"
 #include "date.h"
 #include "zoom_func.h"
+#include "functions.h"
 
 enum {
 	HEADER_SIZE = 49,
--- a/src/oldpool.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/oldpool.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "oldpool.h"
 #include "core/alloc_func.hpp"
 
--- a/src/openttd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/openttd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -13,7 +13,6 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "bridge_map.h"
-#include "functions.h"
 #include "mixer.h"
 #include "spritecache.h"
 #include "gfxinit.h"
@@ -120,34 +119,6 @@
 }
 
 
-void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize)
-{
-	FILE *in;
-	byte *mem;
-	size_t len;
-
-	in = fopen(filename, "rb");
-	if (in == NULL) return NULL;
-
-	fseek(in, 0, SEEK_END);
-	len = ftell(in);
-	fseek(in, 0, SEEK_SET);
-	if (len > maxsize || (mem = MallocT<byte>(len + 1)) == NULL) {
-		fclose(in);
-		return NULL;
-	}
-	mem[len] = 0;
-	if (fread(mem, len, 1, in) != 1) {
-		fclose(in);
-		free(mem);
-		return NULL;
-	}
-	fclose(in);
-
-	*lenp = len;
-	return mem;
-}
-
 extern const char _openttd_revision[];
 static void showhelp()
 {
--- a/src/order_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/order_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -8,7 +8,6 @@
 #include "airport.h"
 #include "vehicle.h"
 #include "depot.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "waypoint.h"
 #include "command_func.h"
@@ -21,6 +20,8 @@
 #include "aircraft.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
+#include "functions.h"
+#include "window_func.h"
 
 DEFINE_OLD_POOL_GENERIC(Order, Order)
 
--- a/src/order_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/order_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -8,7 +8,6 @@
 #include "station_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "map.h"
 #include "gui.h"
 #include "window_gui.h"
@@ -26,6 +25,7 @@
 #include "cargotype.h"
 #include "order.h"
 #include "strings_func.h"
+#include "window_func.h"
 
 enum OrderWindowWidgets {
 	ORDER_WIDGET_CLOSEBOX = 0,
--- a/src/os/macosx/splash.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/os/macosx/splash.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 #include "../../openttd.h"
 #include "../../variables.h"
 #include "../../debug.h"
-#include "../../functions.h"
 #include "../../gfx_func.h"
 #include "../../fileio.h"
 #include "../../blitter/factory.hpp"
--- a/src/os2.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/os2.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -8,9 +8,10 @@
 #include "string.h"
 #include "table/strings.h"
 #include "gui.h"
-#include "functions.h"
 #include "fileio.h"
 #include "fios.h" // opendir/readdir/closedir
+#include "functions.h"
+#include "core/random_func.hpp"
 
 #include <dirent.h>
 #include <unistd.h>
--- a/src/player_face.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/player_face.h	Tue Dec 25 11:26:07 2007 +0000
@@ -5,6 +5,8 @@
 #ifndef PLAYER_FACE_H
 #define PLAYER_FACE_H
 
+#include "core/random_func.hpp"
+
 /** The gender/race combinations that we have faces for */
 enum GenderEthnicity {
 	GENDER_FEMALE    = 0, ///< This bit set means a female, otherwise male
--- a/src/player_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/player_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "gui.h"
 #include "window_gui.h"
 #include "textbuf_gui.h"
@@ -26,6 +25,8 @@
 #include "network/network_gui.h"
 #include "player_face.h"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied);
 static void DoSelectPlayerFace(PlayerID player, bool show_big);
--- a/src/players.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/players.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "engine.h"
-#include "functions.h"
 #include "string.h"
 #include "table/strings.h"
 #include "table/sprites.h"
@@ -30,6 +29,7 @@
 #include "tile_map.h"
 #include "strings_func.h"
 #include "gfx_func.h"
+#include "functions.h"
 
 /**
  * Sets the local player and updates the patch settings that are set on a
--- a/src/rail_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/rail_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "tile_cmd.h"
 #include "landscape.h"
 #include "date.h"
@@ -26,6 +25,8 @@
 #include "newgrf_station.h"
 #include "train.h"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 #include "bridge_map.h"
 #include "rail_map.h"
--- a/src/road.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/road.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -2,7 +2,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "rail_map.h"
 #include "road_map.h"
 #include "road_internal.h"
--- a/src/road_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/road_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "map.h"
 #include "gui.h"
 #include "window_gui.h"
@@ -20,6 +19,8 @@
 #include "station_map.h"
 //needed for catchments
 #include "station.h"
+#include "functions.h"
+#include "window_func.h"
 
 
 static void ShowRVStationPicker(RoadStop::Type rs);
--- a/src/roadveh_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/roadveh_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -37,6 +37,8 @@
 #include "cargotype.h"
 #include "strings_func.h"
 #include "tunnelbridge_map.h"
+#include "functions.h"
+#include "window_func.h"
 
 
 static const uint16 _roadveh_images[63] = {
--- a/src/roadveh_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/roadveh_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "roadveh.h"
 #include "table/sprites.h"
 #include "table/strings.h"
--- a/src/saveload.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/saveload.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -16,7 +16,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "vehicle.h"
 #include "station.h"
 #include "thread.h"
@@ -30,6 +29,7 @@
 #include "strings_func.h"
 #include "gfx_func.h"
 #include "core/alloc_func.hpp"
+#include "functions.h"
 #include <list>
 
 extern const uint16 SAVEGAME_VERSION = 83;
--- a/src/screenshot.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/screenshot.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -3,7 +3,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "fileio.h"
 #include "viewport.h"
--- a/src/settings.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/settings.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -22,7 +22,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
 #include "screenshot.h"
 #include "sound.h"
 #include "string.h"
--- a/src/settings.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/settings.h	Tue Dec 25 11:26:07 2007 +0000
@@ -91,4 +91,9 @@
 const SettingDesc *GetPatchFromName(const char *name, uint *i);
 bool SetPatchValue(uint index, const Patches *object, int32 value);
 
+void LoadFromConfig();
+void SaveToConfig();
+void CheckConfig();
+void UpdatePatches();
+
 #endif /* SETTINGS_H */
--- a/src/settings_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/settings_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
 #include "string.h"
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -24,6 +23,8 @@
 #include "date.h"
 #include "newgrf_townname.h"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 static uint32 _difficulty_click_a;
 static uint32 _difficulty_click_b;
--- a/src/ship_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/ship_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "ship.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "tile_cmd.h"
 #include "landscape.h"
 #include "map.h"
@@ -34,6 +33,8 @@
 #include "spritecache.h"
 #include "misc/autoptr.hpp"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
 
--- a/src/ship_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/ship_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "ship.h"
 #include "table/strings.h"
 #include "table/sprites.h"
--- a/src/signs.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/signs.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "landscape.h"
 #include "player.h"
 #include "signs.h"
@@ -17,6 +16,8 @@
 #include "strings_func.h"
 #include "viewport.h"
 #include "zoom_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 SignID _new_sign_id;
 uint _total_signs;
--- a/src/signs_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/signs_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "functions.h"
 #include "gui.h"
 #include "textbuf_gui.h"
 #include "window_gui.h"
@@ -17,6 +16,7 @@
 #include "command_func.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
+#include "window_func.h"
 
 static const Sign **_sign_sort;
 static uint _num_sign_sort;
--- a/src/smallmap_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/smallmap_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "bridge_map.h"
 #include "clear_map.h"
 #include "industry_map.h"
--- a/src/sound.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/sound.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "landscape.h"
 #include "map.h"
 #include "mixer.h"
--- a/src/sound/win32_s.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/sound/win32_s.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -3,7 +3,6 @@
 #include "../stdafx.h"
 #include "../openttd.h"
 #include "../driver.h"
-#include "../functions.h"
 #include "../mixer.h"
 #include "../core/alloc_func.hpp"
 #include "win32_s.h"
--- a/src/spritecache.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/spritecache.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -7,12 +7,12 @@
 #include "variables.h"
 #include "string.h"
 #include "debug.h"
-#include "functions.h"
 #include "spritecache.h"
 #include "table/sprites.h"
 #include "fileio.h"
 #include "spriteloader/grf.hpp"
 #include "core/alloc_func.hpp"
+#include "core/math_func.hpp"
 #ifdef WITH_PNG
 #include "spriteloader/png.hpp"
 #endif /* WITH_PNG */
--- a/src/station.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/station.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 #include "bridge_map.h"
 #include "debug.h"
-#include "functions.h"
 #include "station_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -32,6 +31,8 @@
 #include "roadveh.h"
 #include "station_gui.h"
 #include "zoom_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 Station::Station(TileIndex tile)
 {
--- a/src/station_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/station_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -43,6 +43,8 @@
 #include "water.h"
 #include "station_gui.h"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 DEFINE_OLD_POOL_GENERIC(Station, Station)
 DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
--- a/src/station_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/station_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "gui.h"
 #include "window_gui.h"
@@ -25,6 +24,7 @@
 #include "station.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
+#include "window_func.h"
 
 typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
 
--- a/src/string.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/string.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "string.h"
 #include "table/control_codes.h"
 #include "debug.h"
--- a/src/strings.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/strings.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
 #include "string.h"
 #include "table/strings.h"
 #include "namegen.h"
@@ -34,6 +33,7 @@
 #include "fontcache.h"
 #include "gui.h"
 #include "strings_func.h"
+#include "functions.h"
 #if defined(TTD_BIG_ENDIAN)
 #include "core/endian_func.hpp"
 #endif
--- a/src/subsidy_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/subsidy_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "station.h"
 #include "industry.h"
 #include "town.h"
--- a/src/terraform_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/terraform_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -8,7 +8,6 @@
 #include "clear_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "player.h"
 #include "gui.h"
 #include "window_gui.h"
@@ -18,6 +17,7 @@
 #include "vehicle.h"
 #include "signs.h"
 #include "variables.h"
+#include "functions.h"
 
 void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
--- a/src/texteff.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/texteff.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "tile_cmd.h"
 #include "landscape.h"
 #include "viewport.h"
@@ -21,6 +20,7 @@
 #include "transparency.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
+#include "functions.h"
 
 enum {
 	MAX_TEXTMESSAGE_LENGTH = 200,
--- a/src/tgp.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/tgp.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include <math.h>
 #include "openttd.h"
 #include "clear_map.h"
-#include "functions.h"
 #include "map.h"
 #include "table/strings.h"
 #include "clear_map.h"
@@ -16,6 +15,7 @@
 #include "console.h"
 #include "genworld.h"
 #include "core/alloc_func.hpp"
+#include "core/random_func.hpp"
 
 /*
  *
--- a/src/timetable_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/timetable_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,13 +4,14 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "table/strings.h"
 #include "command_func.h"
 #include "date.h"
 #include "player.h"
 #include "vehicle.h"
+#include "functions.h"
+#include "window_func.h"
 
 
 static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 time, bool is_journey)
--- a/src/timetable_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/timetable_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "table/strings.h"
 #include "command_func.h"
--- a/src/town.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/town.h	Tue Dec 25 11:26:07 2007 +0000
@@ -6,8 +6,8 @@
 #define TOWN_H
 
 #include "oldpool.h"
-#include "player.h"
-#include "functions.h"
+#include "core/random_func.hpp"
+#include "cargo_type.h"
 
 enum {
 	HOUSE_NO_CLASS   = 0,
@@ -350,5 +350,11 @@
 void ResetHouses();
 
 void ClearTownHouse(Town *t, TileIndex tile);
+void AfterLoadTown();
+void UpdateTownMaxPass(Town *t);
+bool CheckIfAuthorityAllows(TileIndex tile);
+Town *ClosestTownFromTile(TileIndex tile, uint threshold);
+void ChangeTownRating(Town *t, int add, int max);
+uint GetTownRadiusGroup(const Town* t, TileIndex tile);
 
 #endif /* TOWN_H */
--- a/src/town_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/town_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -44,6 +44,7 @@
 #include "tunnelbridge_map.h"
 #include "strings_func.h"
 #include "string.h"
+#include "window_func.h"
 
 
 /* Initialize the town-pool */
--- a/src/town_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/town_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "town.h"
--- a/src/town_map.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/town_map.h	Tue Dec 25 11:26:07 2007 +0000
@@ -8,6 +8,7 @@
 #include "town.h"
 #include "date.h"
 #include "tile_map.h"
+#include "functions.h"
 
 /**
  * Get the index of which town this house/street is attached to.
--- a/src/train_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/train_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -42,6 +42,8 @@
 #include "table/sprites.h"
 #include "tunnelbridge_map.h"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 
 static bool TrainCheckIfLineEnds(Vehicle *v);
--- a/src/train_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/train_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "gui.h"
--- a/src/transparency_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/transparency_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,7 +4,6 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "gui.h"
 #include "window_gui.h"
 #include "viewport.h"
--- a/src/tree_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/tree_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -21,6 +21,8 @@
 #include "variables.h"
 #include "genworld.h"
 #include "transparency.h"
+#include "functions.h"
+#include "player.h"
 
 /**
  * List of tree placer algorithm.
--- a/src/tunnelbridge_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/tunnelbridge_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -35,6 +35,7 @@
 #include "tunnelbridge_map.h"
 #include "table/bridge_land.h"
 #include "strings_func.h"
+#include "functions.h"
 
 
 const Bridge orig_bridge[] = {
--- a/src/unix.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/unix.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,11 +4,12 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "string.h"
 #include "table/strings.h"
 #include "variables.h"
 #include "textbuf_gui.h"
+#include "functions.h"
+#include "core/random_func.hpp"
 
 #include <dirent.h>
 #include <unistd.h>
--- a/src/unmovable_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/unmovable_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -24,6 +24,8 @@
 #include "bridge.h"
 #include "autoslope.h"
 #include "transparency.h"
+#include "functions.h"
+#include "window_func.h"
 
 /** Destroy a HQ.
  * During normal gameplay you can only implicitely destroy a HQ when you are
--- a/src/vehicle.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/vehicle.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -42,6 +42,8 @@
 #include "order.h"
 #include "strings_func.h"
 #include "zoom_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 #define INVALID_COORD (0x7fffffff)
 #define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))
--- a/src/vehicle.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/vehicle.h	Tue Dec 25 11:26:07 2007 +0000
@@ -812,6 +812,8 @@
 	return GetCmdSendToDepot(v->type);
 }
 
+bool EnsureNoVehicleOnGround(TileIndex tile);
+
 /* This one is not used anymore. */
 VARDEF VehicleID _vehicle_id_ctr_day;
 VARDEF Vehicle *_place_clicked_vehicle;
--- a/src/vehicle_gui.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/vehicle_gui.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "player.h"
 #include "station.h"
 #include "table/sprites.h"
@@ -32,6 +31,8 @@
 #include "group.h"
 #include "group_gui.h"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 struct Sorting {
 	Listing aircraft;
--- a/src/video/cocoa/wnd_quartz.mm	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/video/cocoa/wnd_quartz.mm	Tue Dec 25 11:26:07 2007 +0000
@@ -42,7 +42,6 @@
 #include "../../variables.h"
 #include "../../core/geometry_type.hpp"
 #include "cocoa_v.h"
-#include "../../functions.h"
 #include "../../core/math_func.hpp"
 #include "../../gfx_func.h"
 
--- a/src/video/cocoa/wnd_quickdraw.mm	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/video/cocoa/wnd_quickdraw.mm	Tue Dec 25 11:26:07 2007 +0000
@@ -42,7 +42,6 @@
 #include "../../variables.h"
 #include "../../core/geometry_type.hpp"
 #include "cocoa_v.h"
-#include "../../functions.h"
 #include "../../core/math_func.hpp"
 #include "../../gfx_func.h"
 
--- a/src/video/dedicated_v.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/video/dedicated_v.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 
 #include "../openttd.h"
 #include "../debug.h"
-#include "../functions.h"
 #include "../gfx_func.h"
 #include "../network/network.h"
 #include "../console.h"
--- a/src/video/sdl_v.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/video/sdl_v.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 
 #include "../openttd.h"
 #include "../debug.h"
-#include "../functions.h"
 #include "../gfx_func.h"
 #include "../sdl.h"
 #include "../variables.h"
--- a/src/video/win32_v.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/video/win32_v.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -2,7 +2,6 @@
 
 #include "../stdafx.h"
 #include "../openttd.h"
-#include "../functions.h"
 #include "../gfx_func.h"
 #include "../variables.h"
 #include "../win32.h"
--- a/src/water_cmd.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/water_cmd.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -31,6 +31,8 @@
 #include "misc/autoptr.hpp"
 #include "transparency.h"
 #include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
 
 /** Array for the shore sprites */
 static const SpriteID _water_shore_sprites[] = {
--- a/src/waypoint.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/waypoint.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include "openttd.h"
 
 #include "command_func.h"
-#include "functions.h"
 #include "landscape.h"
 #include "map.h"
 #include "order.h"
@@ -26,6 +25,8 @@
 #include "misc/autoptr.hpp"
 #include "strings_func.h"
 #include "viewport.h"
+#include "functions.h"
+#include "window_func.h"
 
 enum {
 	MAX_WAYPOINTS_PER_TOWN = 64,
--- a/src/widget.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/widget.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -4,12 +4,13 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "player.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "viewport.h"
 #include "window_gui.h"
+#include "window_func.h"
+
 
 static Point HandleScrollbarHittest(const Scrollbar *sb, int top, int bottom)
 {
--- a/src/win32.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/win32.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "saveload.h"
 #include "string.h"
 #include "gfx_func.h"
@@ -22,6 +21,8 @@
 #include "fios.h" // opendir/readdir/closedir
 #include "fileio.h"
 #include "core/alloc_func.hpp"
+#include "functions.h"
+#include "core/random_func.hpp"
 #include <ctype.h>
 #include <tchar.h>
 #include <errno.h>
--- a/src/window.cpp	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/window.cpp	Tue Dec 25 11:26:07 2007 +0000
@@ -6,7 +6,6 @@
 #include <stdarg.h>
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "map.h"
 #include "player.h"
 #include "viewport.h"
--- a/src/window_func.h	Tue Dec 25 09:48:53 2007 +0000
+++ b/src/window_func.h	Tue Dec 25 11:26:07 2007 +0000
@@ -39,4 +39,11 @@
 void ShowVitalWindows();
 Window **FindWindowZPosition(const Window *w);
 
+void InvalidateWindow(WindowClass cls, WindowNumber number);
+void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
+void InvalidateWindowClasses(WindowClass cls);
+void InvalidateWindowClassesData(WindowClass cls);
+void DeleteWindowById(WindowClass cls, WindowNumber number);
+void DeleteWindowByClass(WindowClass cls);
+
 #endif /* WINDOW_FUNC_H */