(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
authorrubidium
Wed, 09 Jan 2008 09:45:45 +0000
changeset 8224 c5a64d87cc54
parent 8223 2f64b8462e66
child 8225 cd84a95b6630
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
src/aircraft_cmd.cpp
src/aircraft_gui.cpp
src/airport_gui.cpp
src/autoreplace_gui.cpp
src/bridge_gui.cpp
src/build_vehicle_gui.cpp
src/clear_cmd.cpp
src/console.cpp
src/depot_gui.cpp
src/dock_gui.cpp
src/economy.cpp
src/elrail.cpp
src/engine_gui.cpp
src/genworld_gui.cpp
src/graph_gui.cpp
src/group_gui.cpp
src/gui.h
src/industry_gui.cpp
src/intro_gui.cpp
src/main_gui.cpp
src/misc.cpp
src/misc_gui.cpp
src/music_gui.cpp
src/network/network_gui.cpp
src/newgrf_gui.cpp
src/news_gui.cpp
src/openttd.cpp
src/order_gui.cpp
src/player_gui.cpp
src/rail_cmd.cpp
src/rail_gui.cpp
src/road_cmd.cpp
src/road_gui.cpp
src/roadveh_cmd.cpp
src/roadveh_gui.cpp
src/settings_gui.cpp
src/ship_cmd.cpp
src/ship_gui.cpp
src/signs_gui.cpp
src/smallmap_gui.cpp
src/sound.cpp
src/station_gui.cpp
src/subsidy_gui.cpp
src/table/autorail.h
src/terraform_gui.cpp
src/timetable_gui.cpp
src/town_cmd.cpp
src/town_gui.cpp
src/train_cmd.cpp
src/train_gui.cpp
src/transparency_gui.cpp
src/tunnelbridge_cmd.cpp
src/unmovable_cmd.cpp
src/vehicle.cpp
src/vehicle_gui.cpp
src/viewport.cpp
src/viewport.h
src/viewport_func.h
src/viewport_type.h
src/water_cmd.cpp
src/widget.cpp
src/window.cpp
src/window_gui.h
--- a/src/aircraft_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/aircraft_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -36,6 +36,7 @@
 #include "variables.h"
 #include "autoreplace_func.h"
 #include "autoreplace_gui.h"
+#include "gfx_func.h"
 
 void Aircraft::UpdateDeltaXY(Direction direction)
 {
--- a/src/aircraft_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/aircraft_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -10,13 +10,13 @@
 #include "table/strings.h"
 #include "gui.h"
 #include "engine.h"
-#include "viewport.h"
 #include "player.h"
 #include "depot.h"
 #include "vehicle_gui.h"
 #include "newgrf_engine.h"
 #include "strings_func.h"
 #include "vehicle_func.h"
+#include "gfx_func.h"
 
 /**
 * Draw the details for the given vehicle at the position (x,y)
--- a/src/airport_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/airport_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -10,7 +10,6 @@
 #include "gui.h"
 #include "station_gui.h"
 #include "terraform_gui.h"
-#include "viewport.h"
 #include "command_func.h"
 #include "station.h"
 #include "airport.h"
@@ -18,6 +17,8 @@
 #include "sound_func.h"
 #include "window_func.h"
 #include "variables.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 
 static byte _selected_airport_type;
 
--- a/src/autoreplace_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/autoreplace_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -18,6 +18,7 @@
 #include "window_func.h"
 #include "vehicle_func.h"
 #include "autoreplace_func.h"
+#include "gfx_func.h"
 
 static RailType _railtype_selected_in_replace_gui;
 
--- a/src/bridge_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/bridge_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -7,7 +7,6 @@
 #include "table/strings.h"
 #include "gui.h"
 #include "window_gui.h"
-#include "viewport.h"
 #include "command_func.h"
 #include "economy_func.h"
 #include "variables.h"
@@ -16,6 +15,8 @@
 #include "window_func.h"
 #include "sound_func.h"
 #include "map_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 
 static struct BridgeData {
 	uint8 last_size;
--- a/src/build_vehicle_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/build_vehicle_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -30,6 +30,7 @@
 #include "date_func.h"
 #include "vehicle_func.h"
 #include "settings_type.h"
+#include "gfx_func.h"
 
 struct buildvehicle_d {
 	VehicleType vehicle_type;
--- a/src/clear_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/clear_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -7,7 +7,6 @@
 #include "clear_map.h"
 #include "table/strings.h"
 #include "player.h"
-#include "viewport.h"
 #include "command_func.h"
 #include "bridge.h"
 #include "landscape.h"
@@ -21,6 +20,7 @@
 #include "functions.h"
 #include "economy_func.h"
 #include "table/clear_land.h"
+#include "viewport_func.h"
 
 static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
 {
--- a/src/console.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/console.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -19,6 +19,7 @@
 #include "core/alloc_func.hpp"
 #include "window_func.h"
 #include "string_func.h"
+#include "gfx_func.h"
 
 #define ICON_BUFFER 79
 #define ICON_HISTORY_SIZE 20
--- a/src/depot_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/depot_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -12,7 +12,8 @@
 #include "table/sprites.h"
 #include "gui.h"
 #include "textbuf_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "command_func.h"
 #include "depot.h"
 #include "vehicle_gui.h"
--- a/src/dock_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/dock_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -12,13 +12,14 @@
 #include "terraform_gui.h"
 #include "window_gui.h"
 #include "station_gui.h"
-#include "viewport.h"
 #include "command_func.h"
 #include "variables.h"
 #include "water.h"
 #include "window_func.h"
 #include "vehicle_func.h"
 #include "sound_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 
 static void ShowBuildDockStationPicker();
 static void ShowBuildDocksDepotPicker();
--- a/src/economy.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/economy.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -43,6 +43,7 @@
 #include "track_type.h"
 #include "track_func.h"
 #include "rail_map.h"
+#include "gfx_func.h"
 
 /**
  * Multiply two integer values and shift the results to right.
--- a/src/elrail.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/elrail.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -48,7 +48,7 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "station_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "variables.h" /* ... same here */
 #include "landscape.h"
 #include "rail_type.h"
--- a/src/engine_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/engine_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -8,7 +8,7 @@
 #include "table/sprites.h"
 #include "gui.h"
 #include "window_gui.h"
-#include "viewport.h"
+#include "gfx_func.h"
 #include "engine.h"
 #include "command_func.h"
 #include "economy_func.h"
--- a/src/genworld_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/genworld_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -26,6 +26,7 @@
 #include "sound_func.h"
 #include "fios.h"
 #include "string_func.h"
+#include "gfx_func.h"
 
 /**
  * In what 'mode' the GenerateLandscapeWindowProc is.
--- a/src/graph_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/graph_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -16,6 +16,7 @@
 #include "core/alloc_func.hpp"
 #include "window_func.h"
 #include "date_func.h"
+#include "gfx_func.h"
 
 /* Bitmasks of player and cargo indices that shouldn't be drawn. */
 static uint _legend_excluded_players;
--- a/src/group_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/group_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -15,7 +15,6 @@
 #include "depot.h"
 #include "train.h"
 #include "group.h"
-#include "viewport.h"
 #include "debug.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
@@ -23,6 +22,8 @@
 #include "vehicle_func.h"
 #include "autoreplace_gui.h"
 #include "string_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 
 
 struct Sorting {
--- a/src/gui.h	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/gui.h	Wed Jan 09 09:45:45 2008 +0000
@@ -49,13 +49,6 @@
 void ShowGenerateLandscape();
 void ShowHeightmapLoad();
 
-typedef void PlaceProc(TileIndex tile);
-void PlaceProc_DemolishArea(TileIndex tile);
-void PlaceProc_LevelLand(TileIndex tile);
-void PlaceProc_BuyLand(TileIndex tile);
-bool GUIPlaceProcDragXY(const WindowEvent *e);
-VARDEF PlaceProc *_place_proc;
-
 /** Drag and drop selection process, or, what to do with an area of land when
  * you've selected it. */
 enum {
--- a/src/industry_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/industry_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -11,7 +11,8 @@
 #include "window_gui.h"
 #include "textbuf_gui.h"
 #include "command_func.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "industry.h"
 #include "town.h"
 #include "variables.h"
--- a/src/intro_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/intro_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -19,6 +19,7 @@
 #include "strings_func.h"
 #include "window_func.h"
 #include "fios.h"
+#include "gfx_func.h"
 
 static const Widget _select_game_widgets[] = {
 {    WWT_CAPTION, RESIZE_NONE, 13,   0, 335,   0,  13, STR_0307_OPENTTD,         STR_NULL},
--- a/src/main_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/main_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -13,7 +13,7 @@
 #include "window_gui.h"
 #include "window_func.h"
 #include "textbuf_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "player.h"
 #include "command_func.h"
 #include "news.h"
--- a/src/misc.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/misc.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -18,7 +18,7 @@
 #include "newgrf_house.h"
 #include "cargotype.h"
 #include "group.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "economy_func.h"
 #include "zoom_func.h"
 #include "functions.h"
@@ -27,6 +27,8 @@
 #include "vehicle_func.h"
 #include "texteff.hpp"
 #include "string_func.h"
+#include "gfx_func.h"
+
 
 char _name_array[512][32];
 
--- a/src/misc_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/misc_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -18,7 +18,8 @@
 #include "window_gui.h"
 #include "station_gui.h"
 #include "textbuf_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "station.h"
 #include "command_func.h"
 #include "player.h"
--- a/src/music_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/music_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -14,6 +14,8 @@
 #include "strings_func.h"
 #include "window_func.h"
 #include "sound_func.h"
+#include "gfx_func.h"
+#include "core/math_func.hpp"
 
 static byte _music_wnd_cursong;
 static bool _song_is_active;
--- a/src/network/network_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/network/network_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -26,6 +26,7 @@
 #include "../window_func.h"
 #include "../core/alloc_func.hpp"
 #include "../string_func.h"
+#include "../gfx_func.h"
 
 #define BGC 5
 #define BTC 15
--- a/src/newgrf_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/newgrf_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -16,6 +16,7 @@
 #include "window_func.h"
 #include "core/alloc_func.hpp"
 #include "string_func.h"
+#include "gfx_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/news_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/news_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -7,7 +7,7 @@
 #include "table/strings.h"
 #include "gui.h"
 #include "window_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "news.h"
 #include "variables.h"
 #include "transparency.h"
--- a/src/openttd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/openttd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -20,7 +20,8 @@
 #include "station_map.h"
 #include "town_map.h"
 #include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "window_func.h"
 #include "window_gui.h"
 #include "player.h"
--- a/src/order_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/order_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -13,7 +13,8 @@
 #include "station.h"
 #include "town.h"
 #include "command_func.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "depot.h"
 #include "waypoint.h"
 #include "train.h"
--- a/src/player_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/player_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -9,7 +9,8 @@
 #include "gui.h"
 #include "window_gui.h"
 #include "textbuf_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "player.h"
 #include "command_func.h"
 #include "network/network.h"
--- a/src/rail_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/rail_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -16,7 +16,7 @@
 #include "landscape.h"
 #include "town_map.h"
 #include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "command_func.h"
 #include "pathfind.h"
 #include "engine.h"
--- a/src/rail_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/rail_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -12,7 +12,8 @@
 #include "window_gui.h"
 #include "station_gui.h"
 #include "terraform_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "command_func.h"
 #include "station.h"
 #include "waypoint.h"
--- a/src/road_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/road_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -16,7 +16,7 @@
 #include "tile_cmd.h"
 #include "landscape.h"
 #include "town_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "command_func.h"
 #include "player.h"
 #include "town.h"
--- a/src/road_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/road_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -10,7 +10,8 @@
 #include "window_gui.h"
 #include "station_gui.h"
 #include "terraform_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "command_func.h"
 #include "variables.h"
 #include "road_type.h"
--- a/src/roadveh_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/roadveh_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -40,6 +40,7 @@
 #include "sound_func.h"
 #include "variables.h"
 #include "autoreplace_gui.h"
+#include "gfx_func.h"
 
 
 static const uint16 _roadveh_images[63] = {
--- a/src/roadveh_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/roadveh_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -10,7 +10,8 @@
 #include "table/strings.h"
 #include "gui.h"
 #include "window_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "command_func.h"
 #include "depot.h"
 #include "vehicle_gui.h"
--- a/src/settings_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/settings_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -25,6 +25,7 @@
 #include "vehicle_base.h"
 #include "core/alloc_func.hpp"
 #include "string_func.h"
+#include "gfx_func.h"
 
 static uint32 _difficulty_click_a;
 static uint32 _difficulty_click_b;
--- a/src/ship_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/ship_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -36,6 +36,7 @@
 #include "sound_func.h"
 #include "variables.h"
 #include "autoreplace_gui.h"
+#include "gfx_func.h"
 
 
 static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
--- a/src/ship_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/ship_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -10,7 +10,8 @@
 #include "table/sprites.h"
 #include "gui.h"
 #include "window_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "depot.h"
 #include "vehicle_gui.h"
 #include "newgrf_engine.h"
--- a/src/signs_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/signs_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -18,6 +18,8 @@
 #include "core/alloc_func.hpp"
 #include "window_func.h"
 #include "map_func.h"
+#include "gfx_func.h"
+#include "viewport_func.h"
 
 static const Sign **_sign_sort;
 static uint _num_sign_sort;
--- a/src/smallmap_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/smallmap_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -16,7 +16,8 @@
 #include "window_gui.h"
 #include "tree_map.h"
 #include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "player.h"
 #include "town.h"
 #include "variables.h"
--- a/src/sound.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/sound.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -7,7 +7,6 @@
 #include "landscape.h"
 #include "mixer.h"
 #include "sound_func.h"
-#include "viewport.h"
 #include "fileio.h"
 #include "newgrf_sound.h"
 #include "fios.h"
--- a/src/station_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/station_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -23,6 +23,8 @@
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
 #include "window_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 
 typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
 
--- a/src/subsidy_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/subsidy_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -15,6 +15,8 @@
 #include "window_gui.h"
 #include "strings_func.h"
 #include "date_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 
 static void HandleSubsidyClick(int y)
 {
--- a/src/table/autorail.h	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/table/autorail.h	Wed Jan 09 09:45:45 2008 +0000
@@ -52,21 +52,21 @@
 
 // maps each pixel of a tile (16x16) to a selection type
 // (0,0) is the top corner, (16,16) the bottom corner
-static const byte _AutorailPiece[][16] = {
-	{ 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 },
-	{ 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 },
-	{ 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 },
-	{ 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 },
-	{ 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 },
-	{ 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 },
-	{ 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 },
-	{ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
-	{ 1, 1,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R_HL }
 };
--- a/src/terraform_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/terraform_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -11,7 +11,8 @@
 #include "player.h"
 #include "gui.h"
 #include "window_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "command_func.h"
 #include "signs.h"
 #include "variables.h"
--- a/src/timetable_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/timetable_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -16,6 +16,7 @@
 #include "strings_func.h"
 #include "vehicle_base.h"
 #include "string_func.h"
+#include "gfx_func.h"
 
 static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v)
 {
--- a/src/town_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/town_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -13,7 +13,7 @@
 #include "landscape.h"
 #include "town_map.h"
 #include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "town.h"
 #include "command_func.h"
 #include "industry.h"
--- a/src/town_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/town_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -8,7 +8,8 @@
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "town.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "gui.h"
 #include "window_gui.h"
 #include "textbuf_gui.h"
--- a/src/train_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/train_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -45,6 +45,7 @@
 #include "sound_func.h"
 #include "variables.h"
 #include "autoreplace_gui.h"
+#include "gfx_func.h"
 
 
 static bool TrainCheckIfLineEnds(Vehicle *v);
--- a/src/train_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/train_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -9,7 +9,7 @@
 #include "table/strings.h"
 #include "gui.h"
 #include "window_gui.h"
-#include "viewport.h"
+#include "gfx_func.h"
 #include "command_func.h"
 #include "vehicle_gui.h"
 #include "depot.h"
--- a/src/transparency_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/transparency_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -6,7 +6,6 @@
 #include "table/strings.h"
 #include "gui.h"
 #include "window_gui.h"
-#include "viewport.h"
 #include "variables.h"
 #include "transparency.h"
 #include "sound_func.h"
--- a/src/tunnelbridge_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/tunnelbridge_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -16,7 +16,7 @@
 #include "landscape.h"
 #include "tunnel_map.h"
 #include "unmovable_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "command_func.h"
 #include "player.h"
 #include "town.h"
--- a/src/unmovable_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/unmovable_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -9,7 +9,7 @@
 #include "tile_cmd.h"
 #include "landscape.h"
 #include "command_func.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "player.h"
 #include "gui.h"
 #include "station.h"
--- a/src/vehicle.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/vehicle.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -13,7 +13,8 @@
 #include "tile_cmd.h"
 #include "landscape.h"
 #include "timetable.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "news.h"
 #include "command_func.h"
 #include "saveload.h"
--- a/src/vehicle_gui.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/vehicle_gui.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -16,7 +16,8 @@
 #include "command_func.h"
 #include "variables.h"
 #include "vehicle_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "train.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_engine.h"
--- a/src/viewport.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/viewport.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -11,7 +11,7 @@
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "landscape.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "station.h"
 #include "town.h"
 #include "signs.h"
@@ -28,6 +28,8 @@
 
 #define VIEWPORT_DRAW_MEM (65536 * 2)
 
+PlaceProc *_place_proc;
+Point _tile_fract_coords;
 ZoomLevel _saved_scrollpos_zoom;
 
 /**
@@ -865,23 +867,22 @@
 	px -= _thd.selstart.x;
 	py -= _thd.selstart.y;
 
-	switch (_thd.drawstyle) {
-	case HT_LINE | HT_DIR_X:  return py == 0; // x direction
-	case HT_LINE | HT_DIR_Y:  return px == 0; // y direction
-	case HT_LINE | HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper
-	case HT_LINE | HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower
-	case HT_LINE | HT_DIR_VL: return px == py || px == py + 16; // vertival left
-	case HT_LINE | HT_DIR_VR: return px == py || px == py - 16; // vertical right
-	default:
-		NOT_REACHED();
+	if ((_thd.drawstyle & ~HT_DIR_MASK) != HT_LINE) return false;
+
+	switch (_thd.drawstyle & HT_DIR_MASK) {
+		case HT_DIR_X:  return py == 0; // x direction
+		case HT_DIR_Y:  return px == 0; // y direction
+		case HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper
+		case HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower
+		case HT_DIR_VL: return px == py || px == py + 16; // vertival left
+		case HT_DIR_VR: return px == py || px == py - 16; // vertical right
+		default:
+			NOT_REACHED();
 	}
-
-	/* useless, but avoids compiler warning this way */
-	return 0;
 }
 
 // [direction][side]
-static const int _AutorailType[6][2] = {
+static const HighLightStyle _autorail_type[6][2] = {
 	{ HT_DIR_X,  HT_DIR_X },
 	{ HT_DIR_Y,  HT_DIR_Y },
 	{ HT_DIR_HU, HT_DIR_HL },
@@ -969,7 +970,7 @@
 			/* autorail highlight piece under cursor */
 			uint type = _thd.drawstyle & 0xF;
 			assert(type <= 5);
-			DrawAutorailSelection(ti, _AutorailType[type][0]);
+			DrawAutorailSelection(ti, _autorail_type[type][0]);
 		} else if (IsPartOfAutoLine(ti->x, ti->y)) {
 			/* autorail highlighting long line */
 			int dir = _thd.drawstyle & ~0xF0;
@@ -982,7 +983,7 @@
 				side = Delta(Delta(TileX(start), TileX(ti->tile)), Delta(TileY(start), TileY(ti->tile)));
 			}
 
-			DrawAutorailSelection(ti, _AutorailType[dir][side]);
+			DrawAutorailSelection(ti, _autorail_type[dir][side]);
 		}
 		return;
 	}
@@ -2229,9 +2230,9 @@
 }
 
 /** returns the best autorail highlight type from map coordinates */
-static byte GetAutorailHT(int x, int y)
+static HighLightStyle GetAutorailHT(int x, int y)
 {
-	return HT_RAIL | _AutorailPiece[x & 0xF][y & 0xF];
+	return HT_RAIL | _autorail_piece[x & 0xF][y & 0xF];
 }
 
 /**
@@ -2376,7 +2377,7 @@
 
 /** returns information about the 2x1 piece to be build.
  * The lower bits (0-3) are the track type. */
-static byte Check2x1AutoRail(int mode)
+static HighLightStyle Check2x1AutoRail(int mode)
 {
 	int fxpy = _tile_fract_coords.x + _tile_fract_coords.y;
 	int sxpy = (_thd.selend.x & 0xF) + (_thd.selend.y & 0xF);
@@ -2384,28 +2385,27 @@
 	int sxmy = (_thd.selend.x & 0xF) - (_thd.selend.y & 0xF);
 
 	switch (mode) {
-	case 0: // end piece is lower right
-		if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return 3; }
-		if (fxmy < -3 && sxmy > 3) {/* DoRailroadTrack(0); */return 5; }
-		return 1;
-
-	case 1:
-		if (fxmy > 3 && sxmy < -3) { /*SwapSelection(); DoRailroadTrack(0); */return 4; }
-		if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return 2; }
-		return 1;
-
-	case 2:
-		if (fxmy > 3 && sxmy < -3) { /*DoRailroadTrack(3);*/ return 4; }
-		if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return 3; }
-		return 0;
-
-	case 3:
-		if (fxmy < -3 && sxmy > 3) { /*SwapSelection(); DoRailroadTrack(3);*/ return 5; }
-		if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return 2; }
-		return 0;
+		default: NOT_REACHED();
+		case 0: // end piece is lower right
+			if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_HL; }
+			if (fxmy < -3 && sxmy > 3) {/* DoRailroadTrack(0); */return HT_DIR_VR; }
+			return HT_DIR_Y;
+
+		case 1:
+			if (fxmy > 3 && sxmy < -3) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_VL; }
+			if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return HT_DIR_HU; }
+			return HT_DIR_Y;
+
+		case 2:
+			if (fxmy > 3 && sxmy < -3) { /*DoRailroadTrack(3);*/ return HT_DIR_VL; }
+			if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_HL; }
+			return HT_DIR_X;
+
+		case 3:
+			if (fxmy < -3 && sxmy > 3) { /*SwapSelection(); DoRailroadTrack(3);*/ return HT_DIR_VR; }
+			if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return HT_DIR_HU; }
+			return HT_DIR_X;
 	}
-
-	return 0; // avoids compiler warnings
 }
 
 /** Check if the direction of start and end tile should be swapped based on
@@ -2749,7 +2749,7 @@
 
 				/* If dragging an area (eg dynamite tool) and it is actually a single
 				 * row/column, change the type to 'line' to get proper calculation for height */
-				style = _thd.next_drawstyle;
+				style = (HighLightStyle)_thd.next_drawstyle;
 				if (style & HT_RECT) {
 					if (dx == 1) {
 						style = HT_LINE | HT_DIR_Y;
--- a/src/viewport.h	Wed Jan 09 08:12:10 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-/* $Id$ */
-
-/** @file viewport.h */
-
-#ifndef VIEWPORT_H
-#define VIEWPORT_H
-
-#include "zoom_type.h"
-#include "window_type.h"
-#include "vehicle_type.h"
-#include "gfx_func.h"
-#include "gui.h"
-
-struct ViewPort {
-	int left,top;                       // screen coordinates for the viewport
-	int width, height;                  // screen width/height for the viewport
-
-	int virtual_left, virtual_top;      // virtual coordinates
-	int virtual_width, virtual_height;  // these are just width << zoom, height << zoom
-
-	ZoomLevel zoom;
-};
-
-void SetSelectionRed(bool);
-
-/* viewport.cpp */
-void InitViewports();
-void DeleteWindowViewport(Window *w);
-void AssignWindowViewport(Window *w, int x, int y,
-	int width, int height, uint32 follow_flags, ZoomLevel zoom);
-ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
-Point GetTileBelowCursor();
-void UpdateViewportPosition(Window *w);
-
-enum {
-	ZOOM_IN   = 0,
-	ZOOM_OUT  = 1,
-	ZOOM_NONE = 2, // hack, used to update the button status
-};
-
-bool DoZoomInOutWindow(int how, Window *w);
-void ZoomInOrOutToCursorWindow(bool in, Window * w);
-Point GetTileZoomCenterWindow(bool in, Window * w);
-void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
-
-static inline void MaxZoomInOut(int how, Window *w)
-{
-	while (DoZoomInOutWindow(how, w)) {};
-}
-
-/**
- * Some values for constructing bounding boxes (BB). The Z positions under bridges are:
- * z=0..5  Everything that can be built under low bridges.
- * z=6     reserved, currently unused.
- * z=7     Z separator between bridge/tunnel and the things under/above it.
- */
-enum {
-	BB_HEIGHT_UNDER_BRIDGE = 6, ///< Everything that can be built under low bridges, must not exceed this Z height.
-	BB_Z_SEPARATOR  = 7,        ///< Separates the bridge/tunnel from the things under/above it.
-};
-
-void OffsetGroundSprite(int x, int y);
-
-void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL);
-void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL);
-void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL);
-void *AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2);
-void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL);
-
-
-void StartSpriteCombine();
-void EndSpriteCombine();
-
-void HandleViewportClicked(const ViewPort *vp, int x, int y);
-void PlaceObject();
-void SetRedErrorSquare(TileIndex tile);
-void SetTileSelectSize(int w, int h);
-void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
-
-Vehicle *CheckMouseOverVehicle();
-
-/** Viewport place method (type of highlighted area and placed objects) */
-enum ViewportPlaceMethod {
-	VPM_X_OR_Y          = 0, ///< drag in X or Y direction
-	VPM_FIX_X           = 1, ///< drag only in X axis
-	VPM_FIX_Y           = 2, ///< drag only in Y axis
-	VPM_RAILDIRS        = 3, ///< all rail directions
-	VPM_X_AND_Y         = 4, ///< area of land in X and Y directions
-	VPM_X_AND_Y_LIMITED = 5, ///< area of land of limited size
-	VPM_SIGNALDIRS      = 6, ///< similiar to VMP_RAILDIRS, but with different cursor
-};
-
-/** Viewport highlight mode (for highlighting tiles below cursor) */
-enum ViewportHighlightMode {
-	VHM_NONE    = 0, ///< default
-	VHM_RECT    = 1, ///< rectangle (stations, depots, ...)
-	VHM_POINT   = 2, ///< point (lower land, raise land, level land, ...)
-	VHM_SPECIAL = 3, ///< special mode used for highlighting while dragging (and for tunnels/docks)
-	VHM_DRAG    = 4, ///< dragging items in the depot windows
-	VHM_RAIL    = 5, ///< rail pieces
-};
-
-void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method);
-void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, byte process);
-void VpSetPresizeRange(uint from, uint to);
-void VpSetPlaceSizingLimit(int limit);
-
-/* highlighting draw styles */
-typedef byte HighLightStyle;
-enum HighLightStyles {
-	HT_NONE   = 0x00,
-	HT_RECT   = 0x80,
-	HT_POINT  = 0x40,
-	HT_LINE   = 0x20,    ///< used for autorail highlighting (longer streches)
-	                     ///< (uses lower bits to indicate direction)
-	HT_RAIL   = 0x10,    ///< autorail (one piece)
-	                     ///< (uses lower bits to indicate direction)
-	HT_DRAG_MASK = 0xF0, ///< masks the drag-type
-
-	/* lower bits (used with HT_LINE and HT_RAIL):
-	 * (see ASCII art in autorail.h for a visual interpretation) */
-	HT_DIR_X  = 0,    ///< X direction
-	HT_DIR_Y  = 1,    ///< Y direction
-	HT_DIR_HU = 2,    ///< horizontal upper
-	HT_DIR_HL = 3,    ///< horizontal lower
-	HT_DIR_VL = 4,    ///< vertical left
-	HT_DIR_VR = 5,    ///< vertical right
-	HT_DIR_MASK = 0x7 ///< masks the drag-direction
-};
-
-struct TileHighlightData {
-	Point size;
-	Point outersize;
-	Point pos;
-	Point offs;
-
-	Point new_pos;
-	Point new_size;
-	Point new_outersize;
-
-	Point selend, selstart;
-
-	byte dirty;
-	byte sizelimit;
-
-	byte drawstyle;      // lower bits 0-3 are reserved for detailed highlight information information
-	byte new_drawstyle;  // only used in UpdateTileSelection() to as a buffer to compare if there was a change between old and new
-	byte next_drawstyle; // queued, but not yet drawn style
-
-	ViewportHighlightMode place_mode;
-	bool make_square_red;
-	WindowClass window_class;
-	WindowNumber window_number;
-
-	ViewportPlaceMethod select_method;
-	byte select_proc;
-
-	TileIndex redsq;
-};
-
-
-/* common button handler */
-bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
-
-VARDEF Point _tile_fract_coords;
-
-extern TileHighlightData _thd;
-
-
-void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
-
-void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
-void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num);
-
-void ResetObjectToPlace();
-
-bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
-
-bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
-bool ScrollMainWindowTo(int x, int y, bool instant = false);
-
-#endif /* VIEWPORT_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/viewport_func.h	Wed Jan 09 09:45:45 2008 +0000
@@ -0,0 +1,80 @@
+/* $Id$ */
+
+/** @file viewport_func.h Functions related to (drawing on) viewports. */
+
+#ifndef VIEWPORT_FUNC_H
+#define VIEWPORT_FUNC_H
+
+#include "viewport_type.h"
+#include "vehicle_type.h"
+
+void SetSelectionRed(bool);
+
+void InitViewports();
+void DeleteWindowViewport(Window *w);
+void AssignWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom);
+ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
+Point GetTileBelowCursor();
+void UpdateViewportPosition(Window *w);
+
+bool DoZoomInOutWindow(int how, Window *w);
+void ZoomInOrOutToCursorWindow(bool in, Window * w);
+Point GetTileZoomCenterWindow(bool in, Window * w);
+void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
+
+static inline void MaxZoomInOut(int how, Window *w)
+{
+	while (DoZoomInOutWindow(how, w)) {};
+}
+
+void OffsetGroundSprite(int x, int y);
+
+void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL);
+void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL);
+void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL);
+void *AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2);
+void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL);
+
+
+void StartSpriteCombine();
+void EndSpriteCombine();
+
+void HandleViewportClicked(const ViewPort *vp, int x, int y);
+void PlaceObject();
+void SetRedErrorSquare(TileIndex tile);
+void SetTileSelectSize(int w, int h);
+void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
+
+Vehicle *CheckMouseOverVehicle();
+
+void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method);
+void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, byte process);
+void VpSetPresizeRange(uint from, uint to);
+void VpSetPlaceSizingLimit(int limit);
+
+typedef void PlaceProc(TileIndex tile);
+void PlaceProc_DemolishArea(TileIndex tile);
+void PlaceProc_LevelLand(TileIndex tile);
+void PlaceProc_BuyLand(TileIndex tile);
+bool GUIPlaceProcDragXY(const WindowEvent *e);
+
+/* common button handler */
+bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
+
+void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
+
+void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
+void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num);
+
+void ResetObjectToPlace();
+
+bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
+
+bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
+bool ScrollMainWindowTo(int x, int y, bool instant = false);
+
+extern PlaceProc *_place_proc;
+extern Point _tile_fract_coords;
+extern TileHighlightData _thd;
+
+#endif /* VIEWPORT_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/viewport_type.h	Wed Jan 09 09:45:45 2008 +0000
@@ -0,0 +1,114 @@
+/* $Id$ */
+
+/** @file viewport_type.h Types related to viewports. */
+
+#ifndef VIEWPORT_TYPE_H
+#define VIEWPORT_TYPE_H
+
+#include "zoom_type.h"
+#include "window_type.h"
+#include "tile_type.h"
+
+struct ViewPort {
+	int left,top;                       // screen coordinates for the viewport
+	int width, height;                  // screen width/height for the viewport
+
+	int virtual_left, virtual_top;      // virtual coordinates
+	int virtual_width, virtual_height;  // these are just width << zoom, height << zoom
+
+	ZoomLevel zoom;
+};
+
+enum {
+	ZOOM_IN   = 0,
+	ZOOM_OUT  = 1,
+	ZOOM_NONE = 2, // hack, used to update the button status
+};
+
+/**
+ * Some values for constructing bounding boxes (BB). The Z positions under bridges are:
+ * z=0..5  Everything that can be built under low bridges.
+ * z=6     reserved, currently unused.
+ * z=7     Z separator between bridge/tunnel and the things under/above it.
+ */
+enum {
+	BB_HEIGHT_UNDER_BRIDGE = 6, ///< Everything that can be built under low bridges, must not exceed this Z height.
+	BB_Z_SEPARATOR  = 7,        ///< Separates the bridge/tunnel from the things under/above it.
+};
+
+/** Viewport place method (type of highlighted area and placed objects) */
+enum ViewportPlaceMethod {
+	VPM_X_OR_Y          = 0, ///< drag in X or Y direction
+	VPM_FIX_X           = 1, ///< drag only in X axis
+	VPM_FIX_Y           = 2, ///< drag only in Y axis
+	VPM_RAILDIRS        = 3, ///< all rail directions
+	VPM_X_AND_Y         = 4, ///< area of land in X and Y directions
+	VPM_X_AND_Y_LIMITED = 5, ///< area of land of limited size
+	VPM_SIGNALDIRS      = 6, ///< similiar to VMP_RAILDIRS, but with different cursor
+};
+
+/** Viewport highlight mode (for highlighting tiles below cursor) */
+enum ViewportHighlightMode {
+	VHM_NONE    = 0, ///< default
+	VHM_RECT    = 1, ///< rectangle (stations, depots, ...)
+	VHM_POINT   = 2, ///< point (lower land, raise land, level land, ...)
+	VHM_SPECIAL = 3, ///< special mode used for highlighting while dragging (and for tunnels/docks)
+	VHM_DRAG    = 4, ///< dragging items in the depot windows
+	VHM_RAIL    = 5, ///< rail pieces
+};
+
+/* highlighting draw styles */
+enum HighLightStyle {
+	HT_NONE   = 0x00,
+	HT_RECT   = 0x80,
+	HT_POINT  = 0x40,
+	HT_LINE   = 0x20,    ///< used for autorail highlighting (longer streches)
+	                     ///< (uses lower bits to indicate direction)
+	HT_RAIL   = 0x10,    ///< autorail (one piece)
+	                     ///< (uses lower bits to indicate direction)
+	HT_DRAG_MASK = 0xF0, ///< masks the drag-type
+
+	/* lower bits (used with HT_LINE and HT_RAIL):
+	 * (see ASCII art in autorail.h for a visual interpretation) */
+	HT_DIR_X  = 0,    ///< X direction
+	HT_DIR_Y  = 1,    ///< Y direction
+	HT_DIR_HU = 2,    ///< horizontal upper
+	HT_DIR_HL = 3,    ///< horizontal lower
+	HT_DIR_VL = 4,    ///< vertical left
+	HT_DIR_VR = 5,    ///< vertical right
+	HT_DIR_MASK = 0x7 ///< masks the drag-direction
+};
+DECLARE_ENUM_AS_BIT_SET(HighLightStyle);
+
+
+struct TileHighlightData {
+	Point size;
+	Point outersize;
+	Point pos;
+	Point offs;
+
+	Point new_pos;
+	Point new_size;
+	Point new_outersize;
+
+	Point selend, selstart;
+
+	byte dirty;
+	byte sizelimit;
+
+	byte drawstyle;      // lower bits 0-3 are reserved for detailed highlight information information
+	byte new_drawstyle;  // only used in UpdateTileSelection() to as a buffer to compare if there was a change between old and new
+	byte next_drawstyle; // queued, but not yet drawn style
+
+	ViewportHighlightMode place_mode;
+	bool make_square_red;
+	WindowClass window_class;
+	WindowNumber window_number;
+
+	ViewportPlaceMethod select_method;
+	byte select_proc;
+
+	TileIndex redsq;
+};
+
+#endif /* VIEWPORT_TYPE_H */
--- a/src/water_cmd.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/water_cmd.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -12,7 +12,7 @@
 #include "table/strings.h"
 #include "tile_cmd.h"
 #include "landscape.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "command_func.h"
 #include "town.h"
 #include "news.h"
--- a/src/widget.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/widget.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -7,7 +7,7 @@
 #include "player.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "viewport.h"
+#include "gfx_func.h"
 #include "window_gui.h"
 #include "window_func.h"
 
--- a/src/window.cpp	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/window.cpp	Wed Jan 09 09:45:45 2008 +0000
@@ -7,8 +7,9 @@
 #include "openttd.h"
 #include "debug.h"
 #include "player.h"
-#include "viewport.h"
+#include "gfx_func.h"
 #include "console.h"
+#include "viewport_func.h"
 #include "variables.h"
 #include "table/sprites.h"
 #include "genworld.h"
--- a/src/window_gui.h	Wed Jan 09 08:12:10 2008 +0000
+++ b/src/window_gui.h	Wed Jan 09 09:45:45 2008 +0000
@@ -7,7 +7,7 @@
 
 #include "core/bitmath_func.hpp"
 #include "vehicle_type.h"
-#include "viewport.h"
+#include "viewport_type.h"
 
 /**
  * The maximum number of windows that can be opened.