(svn r11796) [NoAI] -Sync: with trunk r11502:11795. noai
authorrubidium
Wed, 09 Jan 2008 18:11:12 +0000
branchnoai
changeset 9723 eee46cb39750
parent 9722 ebf0ece7d8f6
child 9724 b39bc69bb2f2
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
BUGS
bin/data/openttdd.grf
bin/data/openttdw.grf
changelog.txt
config.lib
configure
docs/landscape.html
docs/landscape_grid.html
known-bugs.txt
os/debian/changelog
os/win32/installer/install.nsi
projects/determineversion.vbs
projects/langs.vcproj
projects/langs_vs80.vcproj
projects/langs_vs90.vcproj
projects/openttd.vcproj
projects/openttd_vs80.vcproj
projects/openttd_vs90.vcproj
readme.txt
source.list
src/ai/ai.cpp
src/ai/ai_factory.hpp
src/ai/ai_squirrel.cpp
src/ai/ai_threads.cpp
src/ai/api/ai_airport.cpp
src/ai/api/ai_base.cpp
src/ai/api/ai_cargo.cpp
src/ai/api/ai_company.cpp
src/ai/api/ai_engine.cpp
src/ai/api/ai_industry.cpp
src/ai/api/ai_industry.hpp
src/ai/api/ai_map.cpp
src/ai/api/ai_marine.cpp
src/ai/api/ai_object.cpp
src/ai/api/ai_order.cpp
src/ai/api/ai_pathfinder_stupid.cpp
src/ai/api/ai_road.cpp
src/ai/api/ai_sign.cpp
src/ai/api/ai_station.cpp
src/ai/api/ai_stationlist.cpp
src/ai/api/ai_tile.cpp
src/ai/api/ai_tilelist.cpp
src/ai/api/ai_tilelist_valuator.cpp
src/ai/api/ai_town.cpp
src/ai/api/ai_town.hpp
src/ai/api/ai_transactionmode.cpp
src/ai/api/ai_vehicle.cpp
src/ai/api/ai_vehicle.hpp
src/ai/api/ai_vehiclelist.cpp
src/aircraft.h
src/aircraft_cmd.cpp
src/aircraft_gui.cpp
src/airport.cpp
src/airport.h
src/airport_gui.cpp
src/articulated_vehicles.cpp
src/articulated_vehicles.h
src/autoreplace_base.h
src/autoreplace_cmd.cpp
src/autoreplace_func.h
src/autoreplace_gui.cpp
src/autoreplace_gui.h
src/autoreplace_type.h
src/autoslope.h
src/aystar.cpp
src/aystar.h
src/blitter/32bpp_anim.cpp
src/blitter/32bpp_base.cpp
src/blitter/32bpp_base.hpp
src/blitter/32bpp_optimized.cpp
src/blitter/32bpp_simple.cpp
src/blitter/8bpp_base.cpp
src/blitter/8bpp_debug.cpp
src/blitter/8bpp_optimized.cpp
src/blitter/8bpp_simple.cpp
src/blitter/base.hpp
src/blitter/factory.hpp
src/blitter/null.cpp
src/bmp.cpp
src/bmp.h
src/bridge.h
src/bridge_gui.cpp
src/bridge_map.cpp
src/bridge_map.h
src/build_vehicle_gui.cpp
src/callback_table.cpp
src/callback_table.h
src/cargo_type.h
src/cargopacket.h
src/cargotype.cpp
src/cargotype.h
src/clear_cmd.cpp
src/clear_map.h
src/cmd_helper.h
src/command.cpp
src/command.h
src/command_func.h
src/command_type.h
src/console.cpp
src/console.h
src/console_cmds.cpp
src/core/alloc_func.hpp
src/core/bitmath_func.cpp
src/core/bitmath_func.hpp
src/core/endian_func.hpp
src/core/enum_type.hpp
src/core/geometry_type.hpp
src/core/math_func.hpp
src/core/overflowsafe_type.hpp
src/core/random_func.cpp
src/core/random_func.hpp
src/currency.cpp
src/currency.h
src/date.cpp
src/date.h
src/date_func.h
src/date_type.h
src/debug.cpp
src/debug.h
src/depot.cpp
src/depot.h
src/depot_gui.cpp
src/direction.h
src/direction_func.h
src/direction_type.h
src/disaster_cmd.cpp
src/dock_gui.cpp
src/driver.cpp
src/driver.h
src/dummy_land.cpp
src/economy.cpp
src/economy.h
src/economy_func.h
src/economy_type.h
src/elrail.cpp
src/engine.cpp
src/engine.h
src/engine_gui.cpp
src/fileio.cpp
src/fileio.h
src/fios.cpp
src/fios.h
src/fontcache.cpp
src/fontcache.h
src/functions.h
src/genworld.cpp
src/genworld_gui.cpp
src/gfx.cpp
src/gfx.h
src/gfx_func.h
src/gfx_type.h
src/gfxinit.cpp
src/gfxinit.h
src/graph_gui.cpp
src/group_cmd.cpp
src/group_gui.cpp
src/group_gui.h
src/gui.h
src/heightmap.cpp
src/helpers.hpp
src/industry.h
src/industry_cmd.cpp
src/industry_gui.cpp
src/industry_map.h
src/industry_type.h
src/intro_gui.cpp
src/landscape.cpp
src/landscape.h
src/lang/afrikaans.txt
src/lang/american.txt
src/lang/brazilian_portuguese.txt
src/lang/bulgarian.txt
src/lang/catalan.txt
src/lang/croatian.txt
src/lang/czech.txt
src/lang/danish.txt
src/lang/dutch.txt
src/lang/english.txt
src/lang/english_US.txt
src/lang/esperanto.txt
src/lang/estonian.txt
src/lang/finnish.txt
src/lang/french.txt
src/lang/galician.txt
src/lang/german.txt
src/lang/hungarian.txt
src/lang/icelandic.txt
src/lang/italian.txt
src/lang/japanese.txt
src/lang/korean.txt
src/lang/lithuanian.txt
src/lang/norwegian_bokmal.txt
src/lang/norwegian_nynorsk.txt
src/lang/piglatin.txt
src/lang/polish.txt
src/lang/portuguese.txt
src/lang/romanian.txt
src/lang/russian.txt
src/lang/simplified_chinese.txt
src/lang/slovak.txt
src/lang/slovenian.txt
src/lang/spanish.txt
src/lang/swedish.txt
src/lang/traditional_chinese.txt
src/lang/turkish.txt
src/lang/ukrainian.txt
src/livery.h
src/macros.h
src/main_gui.cpp
src/map.cpp
src/map.h
src/map_func.h
src/map_type.h
src/md5.cpp
src/md5.h
src/misc.cpp
src/misc/blob.hpp
src/misc/dbg_helpers.cpp
src/misc/fixedsizearray.hpp
src/misc_cmd.cpp
src/misc_gui.cpp
src/music/extmidi.cpp
src/music/libtimidity.cpp
src/music/qtmidi.cpp
src/music_gui.cpp
src/namegen.cpp
src/network/core/config.h
src/network/core/game.h
src/network/core/packet.cpp
src/network/core/tcp.cpp
src/network/core/udp.cpp
src/network/network.cpp
src/network/network.h
src/network/network_client.cpp
src/network/network_data.cpp
src/network/network_gamelist.cpp
src/network/network_gui.cpp
src/network/network_gui.h
src/network/network_server.cpp
src/network/network_udp.cpp
src/newgrf.cpp
src/newgrf.h
src/newgrf_canal.cpp
src/newgrf_cargo.h
src/newgrf_commons.cpp
src/newgrf_config.cpp
src/newgrf_config.h
src/newgrf_engine.cpp
src/newgrf_engine.h
src/newgrf_gui.cpp
src/newgrf_house.cpp
src/newgrf_house.h
src/newgrf_industries.cpp
src/newgrf_industries.h
src/newgrf_industrytiles.cpp
src/newgrf_sound.cpp
src/newgrf_sound.h
src/newgrf_spritegroup.cpp
src/newgrf_spritegroup.h
src/newgrf_station.cpp
src/newgrf_station.h
src/newgrf_storage.cpp
src/newgrf_storage.h
src/newgrf_text.cpp
src/newgrf_town.cpp
src/newgrf_townname.cpp
src/news.h
src/news_gui.cpp
src/npf.cpp
src/npf.h
src/oldloader.cpp
src/oldpool.cpp
src/oldpool.h
src/openttd.cpp
src/openttd.h
src/order.h
src/order_cmd.cpp
src/order_gui.cpp
src/os/macosx/macos.h
src/os/macosx/macos.mm
src/os/macosx/osx_stdafx.h
src/os/macosx/splash.cpp
src/os2.cpp
src/pathfind.cpp
src/pathfind.h
src/player.h
src/player_face.h
src/player_gui.cpp
src/players.cpp
src/queue.cpp
src/rail.cpp
src/rail.h
src/rail_cmd.cpp
src/rail_gui.cpp
src/rail_gui.h
src/rail_map.h
src/rail_type.h
src/railtypes.h
src/road.cpp
src/road.h
src/road_cmd.cpp
src/road_cmd.h
src/road_func.h
src/road_gui.cpp
src/road_gui.h
src/road_internal.h
src/road_map.cpp
src/road_map.h
src/road_type.h
src/roadveh.h
src/roadveh_cmd.cpp
src/roadveh_gui.cpp
src/saveload.cpp
src/screenshot.cpp
src/settings.cpp
src/settings.h
src/settings_func.h
src/settings_gui.cpp
src/settings_internal.h
src/settings_type.h
src/ship.h
src/ship_cmd.cpp
src/ship_gui.cpp
src/signal_func.h
src/signs.cpp
src/signs_gui.cpp
src/slope.h
src/slope_func.h
src/slope_type.h
src/smallmap_gui.cpp
src/sound.cpp
src/sound.h
src/sound/cocoa_s.cpp
src/sound/win32_s.cpp
src/sound_func.h
src/sound_type.h
src/sprite.h
src/spritecache.cpp
src/spritecache.h
src/spriteloader/grf.cpp
src/spriteloader/png.cpp
src/squirrel_helper.hpp
src/squirrel_std.cpp
src/station.cpp
src/station.h
src/station_cmd.cpp
src/station_gui.cpp
src/station_gui.h
src/station_map.h
src/stdafx.h
src/strgen/strgen.cpp
src/string.cpp
src/string.h
src/string_func.h
src/string_type.h
src/strings.cpp
src/strings.h
src/strings_func.h
src/strings_type.h
src/subsidy_gui.cpp
src/table/autorail.h
src/table/build_industry.h
src/table/cargo_const.h
src/table/engines.h
src/table/files.h
src/table/railtypes.h
src/table/road_land.h
src/table/sprites.h
src/table/station_land.h
src/table/tree_land.h
src/terraform_cmd.cpp
src/terraform_gui.cpp
src/terraform_gui.h
src/textbuf_gui.h
src/texteff.cpp
src/tgp.cpp
src/thread.cpp
src/tile.cpp
src/tile.h
src/tile_cmd.h
src/tile_map.cpp
src/tile_map.h
src/tile_type.h
src/timetable_cmd.cpp
src/timetable_gui.cpp
src/town.h
src/town_cmd.cpp
src/town_gui.cpp
src/town_map.h
src/town_type.h
src/track_func.h
src/track_type.h
src/train.h
src/train_cmd.cpp
src/train_gui.cpp
src/transparency.h
src/transparency_gui.cpp
src/tree_cmd.cpp
src/tree_map.h
src/tunnel_map.cpp
src/tunnel_map.h
src/tunnelbridge_cmd.cpp
src/tunnelbridge_map.h
src/unix.cpp
src/unmovable_cmd.cpp
src/unmovable_map.h
src/variables.h
src/vehicle.cpp
src/vehicle.h
src/vehicle_base.h
src/vehicle_func.h
src/vehicle_gui.cpp
src/vehicle_gui.h
src/vehicle_type.h
src/video/cocoa/cocoa_v.h
src/video/cocoa/cocoa_v.mm
src/video/cocoa/event.mm
src/video/cocoa/fullscreen.mm
src/video/cocoa/wnd_quartz.mm
src/video/cocoa/wnd_quickdraw.mm
src/video/dedicated_v.cpp
src/video/dedicated_v.h
src/video/null_v.cpp
src/video/null_v.h
src/video/sdl_v.cpp
src/video/sdl_v.h
src/video/video_driver.hpp
src/video/win32_v.cpp
src/video/win32_v.h
src/viewport.cpp
src/viewport.h
src/viewport_func.h
src/viewport_type.h
src/void_map.h
src/water.h
src/water_cmd.cpp
src/water_map.h
src/waypoint.cpp
src/widget.cpp
src/win32.cpp
src/window.cpp
src/window.h
src/window_func.h
src/window_gui.h
src/window_type.h
src/yapf/follow_track.hpp
src/yapf/track_dir.hpp
src/yapf/yapf.hpp
src/yapf/yapf_costbase.hpp
src/yapf/yapf_costcache.hpp
src/yapf/yapf_rail.cpp
src/zoom.hpp
src/zoom_func.h
src/zoom_type.h
--- a/BUGS	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/* $Id$ */
-
-KNOWN BUGS / PROBLEMS:
-
-bridges:
-- Clearing tiles which may not have a bridge above can cause random bridge pieces to appear, which leads to crash in the long run
-
-electrified rails:
-Normal and elrail depots look the same. Use 'X' (transparent buildings)
-   to distinguish between them
-Missing curors / icons for construction (currently using the conventional ones)
-
Binary file bin/data/openttdd.grf has changed
Binary file bin/data/openttdw.grf has changed
--- a/changelog.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/changelog.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -1,3 +1,48 @@
+
+0.6.0-beta2 (2007-12-09)
+------------------------------------------------------------------------
+- Feature: Allow setting a default password for new companies in network games (r11556)
+- Feature: Signal selection GUI for the ones that really like to use that over CTRL (r11547)
+- Feature: Make the bridge selection window resizable (r11539)
+- Feature: [OSX] Added support for using Quartz instead of Quickdraw in windowed mode on OS X 10.4 and higher (r11496)
+- Feature: Allow to resize on creation the smallmap gui in order to show all the types industry available, allow to enable/disable individually or all at once, the industries shown on small map (r11474)
+- Codechange: Send and store the passwords a little more secure to/in the servers (r11557)
+- Fix: Wrong error messages were shown when trying to build some industries in the scenario editor [FS#1524] (r11609)
+- Fix: [NewGRF] Do not trigger industries, but only the industry's tiles (r11608)
+- Fix: Wrong count of Kirby trains when a ship was build [FS#1482] (r11605)
+- Fix: Tiles were not marked dirty in some cases when removing a lock or flooding (r11582, r11604)
+- Fix: Make price for railtype conversion more realistic; conversion should not be more expensive than removing and rebuilding [FS#1481] (r11603)
+- Fix: Do not allow changing network only patches settings from console when not in network game (r11594)
+- Fix: IsSlopeRefused() result was half wrong causing banks to be built on wrong places (r11590)
+- Fix: When ship depots got destroyed they always returned to water, even when it should have been canals [FS#1514] (r11589)
+- Fix: The one way road button wasn't reset on abort (r11587)
+- Fix: Windows could get completely missing when one resized the window to something very small [FS#1484] (r11583)
+- Fix: Invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed so it does not become glitchy (r11577)
+- Fix: Flood train stations when there are no trains on border tiles too (r11574, r11570)
+- Fix: Reinitialise windows system before loading a savegame because not doing so can cause crashes [FS#1494] (r11572)
+- Fix: Road vehicle getting to the wrong side of a station when trying to overtake in there [FS#1493] (r11571)
+- Fix: Full paths sometimes did not work correctly [FS#1480] (r11568)
+- Fix: Break the chain before moving a vehicle after another in the same chain instead of causing an infinite loop [FS#1512] (r11566)
+- Fix: Aircraft sometimes stopped mid-air when the airport got destroyed [FS#1503] (r11562)
+- Fix: Group list was not updated when removing the last group [FS#1504] (r11561)
+- Fix: Overflow when drawing graphics with high company values [FS#1505] (r11558)
+- Fix: If ever the air/heliport is suddenly not available while the "chopper" is descending, just go back into flying instead of stopping mid air [FS#1496] (r11546)
+- Fix: Cargo translation was sometimes done when it should not be done [FS#1501] (r11544)
+- Fix: [OSX] Detect statvfs at runtime (based on OSX version) instead of compile time. This should prevent a crash on OSX 10.3 with the precompiled binaries (in the load/save windows) (r11541)
+- Fix: [OSX] Do not try to compile the quartz video driver on OSX 10.3 as it will fail (r11540)
+- Fix: Do not do all kinds of 'updates' for town, waypoint, station and other signs when you have not converted the map to the 'current' format as that means you are going to read data in the 'old' format when you assume that it is in the 'current' format, which is eventually going to break (r11525)
+- Fix: Assertion when tram reversed at a station [FS#1485] (r11524)
+- Fix: The scrollbar of the network gui could run out of bounds (r11522)
+- Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling (r11520)
+- Fix: Signs totally illegible when transparant signs is turned on and zoomed out more than one level [FS#1463] (r11507)
+- Fix: Selling vehicles could cause the window of others to scroll to that location [FS#1471] (r11506)
+- Fix: Do not do standard production change if callbacks 29/35 failed, disable smooth economy for industries using callbacks 29/35 (r11502)
+- Fix: Two small layout issues with the vehicle grouping GUI (r11478)
+- Fix: A road vehicle must not show that it is driving max speed when it is standing still waiting for the vehicle in from of it [FS#1451] (r11477)
+- Fix: OpenBSD has ALIGN already defined, causing compilation failures [FS#1450] (r11467)
+- Fix: Operator priority problem resulting in problematic autoroad placement in some cases (r11466)
+
+
 0.6.0-beta1 (2007-11-18)
 ------------------------------------------------------------------------
 - Feature: Make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing (r11442)
@@ -32,7 +77,7 @@
 - Feature: New sign editor features including switching to previous/next sign (r10401)
 - Feature: Disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overridden with a patch setting [FS#669] (r10353)
 - Feature: Add the possibility of automatically filling in timetables based on the times from the first (or subsequent) run-throughs (r10331)
-- Feature: Option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map  [FS#812] (r10329)
+- Feature: Option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map [FS#812] (r10329)
 - Feature: Give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches [FS#917] (r10300)
 - Feature: A sticky button for the client list window [FS#885] (r10293)
 - Feature: Allow double-clicking on certain places: add NewGRF window, build-vehicle and town-action (r10265, r10267)
@@ -384,7 +429,7 @@
 - Fix: Draw canal edges under buoys that are in a canal (r8635)
 - Fix: Buoys on canal tiles do not flood anymore (r8620)
 - Fix: Store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. Prevents certain abuses (r8619)
-- Fix: When the currently selected player in the performance details window is no longer active, choose the first active player instead of the first player as that may also be inactive  [FS#582] (r8612)
+- Fix: When the currently selected player in the performance details window is no longer active, choose the first active player instead of the first player as that may also be inactive [FS#582] (r8612)
 - Fix: Road vehicle very close after another (slower) road vehicle gets its speed reset to 0 when entering a tunnel, which causes a traffic jam outside of the tunnel (r8609)
 - Fix: Bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge [FS#564] (r8593)
 - Fix: Road Vehicles now can obtain a slot even if the station is very spread out [FS#577] (r8536)
@@ -1028,7 +1073,7 @@
 - Feature: scrolling credits list (in  alphabetical order)
 - Feature: Train window now shows the number of vehicles per row (mpetrov)
 - Feature: [ 1039061 ] Swiss town-names (vulvulune)
-- Feature: [ 1090950 ] Adding 16:10 resolutions for mainly laptops  (doode)
+- Feature: [ 1090950 ] Adding 16:10 resolutions for mainly laptops (doode)
 - Feature: [ 1098254 ] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
 - Fix: [ 1031451 ] Catchment area shows when buying sign
 - Fix: [ 1040119 ] Flood and wagons in depot
--- a/config.lib	Fri Nov 23 16:59:30 2007 +0000
+++ b/config.lib	Wed Jan 09 18:11:12 2008 +0000
@@ -32,6 +32,7 @@
 	personal_dir="1"
 	install_dir="/"
 	enable_debug="0"
+	enable_desync_debug="0"
 	enable_profiling="0"
 	enable_dedicated="0"
 	enable_network="1"
@@ -42,6 +43,8 @@
 	enable_universal="1"
 	enable_osx_g5="0"
 	enable_unicode="1"
+	enable_cocoa_quartz="1"
+	enable_cocoa_quickdraw="1"
 	with_distcc="1"
 	with_ccache="1"
 	with_osx_sysroot="1"
@@ -62,7 +65,7 @@
 	with_psp_config="1"
 	with_threads="1"
 
-	save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip awk lipo os cpu_type revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_distcc with_osx_sysroot enable_universal enable_osx_g5 enable_unicode with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_libtimidity with_freetype with_fontconfig with_psp_config with_threads CC CXX CFLAGS LDFLAGS"
+	save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip awk lipo os cpu_type revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir enable_debug enable_desync_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_distcc with_osx_sysroot enable_universal enable_osx_g5 enable_unicode enable_cocoa_quartz enable_cocoa_quickdraw with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_libtimidity with_freetype with_fontconfig with_psp_config with_threads CC CXX CFLAGS LDFLAGS"
 }
 
 detect_params() {
@@ -142,6 +145,8 @@
 
 			--enable-debug)               enable_debug="1";;
 			--enable-debug=*)             enable_debug="$optarg";;
+			--enable-desync-debug)        enable_desync_debug="1";;
+			--enable-desync-debug=*)      enable_desync_debug="$optarg";;
 			--enable-profiling)           enable_profiling="1";;
 			--enable-profiling=*)         enable_profiling="$optarg";;
 			--enable-dedicated)           enable_dedicated="1";;
@@ -170,6 +175,13 @@
 			--enable-unicode)             enable_unicode="2";;
 			--enable-unicode=*)           enable_unicode="$optarg";;
 
+			--disable-cocoa-quartz)       enable_cocoa_quartz="0";;
+			--enable-cocoa-quartz)        enable_cocoa_quartz="2";;
+			--enable-cocoa-quartz=*)      enable_cocoa_quartz="$optarg";;
+			--disable-cocoa-quickdraw)    enable_cocoa_quickdraw="0";;
+			--enable-cocoa-quickdraw)     enable_cocoa_quickdraw="2";;
+			--enable-cocoa-quickdraw=*)   enable_cocoa_quickdraw="$optarg";;
+
 			--with-sdl)                   with_sdl="2";;
 			--without-sdl)                with_sdl="0";;
 			--with-sdl=*)                 with_sdl="$optarg";;
@@ -337,6 +349,13 @@
 		exit 1
 	fi
 
+	# enable_desync_debug should be between 0 and 3
+	if [ -z "`echo $enable_desync_debug | egrep '^[012]$'`" ]; then
+		echo "configure: error: invalid option --enable-desync-debug=$enable_desync_debug"
+		echo " Available options are: --enable-desync-debug[=012]"
+		exit 1
+	fi
+
 	detect_awk
 
 	check_build
@@ -376,7 +395,7 @@
 	detect_cputype
 
 	if [ "$enable_static" = "1" ]; then
-		if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "OSX" ]; then
+		if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ]; then
 			enable_static="2"
 		else
 			enable_static="0"
@@ -419,6 +438,17 @@
 		log 1 "using debug level... level $enable_debug"
 	fi
 
+	if [ "$enable_desync_debug" = "0" ]; then
+		log 1 "using desync debug level... no"
+	else
+		log 1 "using desync debug level... level $enable_desync_debug"
+		log 1 "WARNING: desync debug functions slow down the game considerably."
+		log 1 "WARNING: use only when you are instructed to do so"
+		log 1 "         or when you know what you are doing."
+
+		sleep 5
+	fi
+
 	detect_sdl
 	detect_cocoa
 
@@ -799,60 +829,76 @@
 		CFLAGS="$CFLAGS -DNO_THREADS"
 	fi
 
-	# Enable some things only for certain GCC versions
-	cc_version=`$cc_host -dumpversion | cut -c 1,3`
-
-	if [ $cc_version -ge 29 ]; then
-		CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
-		CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
-		CFLAGS="$CFLAGS -Wno-uninitialized"
-
-		CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
-	fi
-
-	gcc295=""
-	if [ "$cc_version" = 29 ]; then
-		# Make sure we mark GCC 2.95 flag for Makefile.src.in, as we
-		#  need a lovely hack there to make it compile correctly.
-		gcc295="1"
-	fi
-
-	if [ $cc_version -ge 30 ]; then
-		CFLAGS="$CFLAGS -W -Wno-unused-parameter"
-	fi
-
-	if [ $cc_version -ge 34 ]; then
-		CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition"
-	fi
+	if [ `echo $cc_host | cut -c 1-3` = "icc" ]; then
+		# Enable some things only for certain ICC versions
+		cc_version=`$cc_host -dumpversion | cut -c 1-4`
 
-	if [ "$os" = "CYGWIN" ]; then
-		CFLAGS="$CFLAGS -mwin32"
-		LDFLAGS="$LDFLAGS -mwin32"
-	fi
-	if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
-		CFLAGS="$CFLAGS -mno-cygwin"
-		LDFLAGS="$LDFLAGS -mno-cygwin"
-	fi
-
-	if [ "$os" = "CYGWIN" ] || [ "$os" = "MINGW" ]; then
-		LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
-		LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
-	fi
 
-	# GCC 4.0+ complains about that we break strict-aliasing.
-	#  On most places we don't see how to fix it, and it doesn't
-	#  break anything. So disable strict-aliasing to make the
-	#  compiler all happy.
-	if [ $cc_version -ge 40 ]; then
-		CFLAGS="$CFLAGS -fno-strict-aliasing"
-	fi
+		if [ "$cc_version" = "10.1" ]; then
+			CFLAGS="$CFLAGS -Wno-multichar"
+		fi
+	else
+		# Enable some things only for certain GCC versions
+		cc_version=`$cc_host -dumpversion | cut -c 1,3`
 
-	# GCC 4.2+ automatically assumes that signed overflows do
-	# not occur in signed arithmetics, whereas we are not
-	# sure that they will not happen. It furthermore complains
-	# about it's own optimized code in some places.
-	if [ $cc_version -ge 42 ]; then
-		CFLAGS="$CFLAGS -fno-strict-overflow"
+		if [ $cc_version -ge 29 ]; then
+			CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
+			CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
+			CFLAGS="$CFLAGS -Wno-uninitialized"
+
+			CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
+		fi
+
+		gcc295=""
+		if [ "$cc_version" = 29 ]; then
+			# Make sure we mark GCC 2.95 flag for Makefile.src.in, as we
+			#  need a lovely hack there to make it compile correctly.
+			gcc295="1"
+		fi
+
+		if [ $cc_version -ge 30 ]; then
+			CFLAGS="$CFLAGS -W -Wno-unused-parameter"
+		fi
+
+		if [ $cc_version -ge 34 ]; then
+			CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition"
+		fi
+
+		if [ "$os" = "CYGWIN" ]; then
+			CFLAGS="$CFLAGS -mwin32"
+			LDFLAGS="$LDFLAGS -mwin32"
+		fi
+		if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
+			CFLAGS="$CFLAGS -mno-cygwin"
+			LDFLAGS="$LDFLAGS -mno-cygwin"
+		fi
+
+		if [ "$os" = "CYGWIN" ] || [ "$os" = "MINGW" ]; then
+			LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
+			LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
+		fi
+
+		# GCC 4.0+ complains about that we break strict-aliasing.
+		#  On most places we don't see how to fix it, and it doesn't
+		#  break anything. So disable strict-aliasing to make the
+		#  compiler all happy.
+		if [ $cc_version -ge 40 ]; then
+			CFLAGS="$CFLAGS -fno-strict-aliasing"
+		fi
+
+		# GCC 4.2+ automatically assumes that signed overflows do
+		# not occur in signed arithmetics, whereas we are not
+		# sure that they will not happen. It furthermore complains
+		# about it's own optimized code in some places.
+		if [ $cc_version -ge 42 ]; then
+			CFLAGS="$CFLAGS -fno-strict-overflow"
+		fi
+
+		# GCC 4.3+ gives a warning about empty body of
+		# loops and conditions
+		if [ $cc_version -ge 43 ]; then
+			CFLAGS="$CFLAGS -Wno-empty-body"
+		fi
 	fi
 
 	if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
@@ -922,6 +968,14 @@
 	if [ "$with_cocoa" != "0" ]; then
 		CFLAGS="$CFLAGS -DWITH_COCOA"
 		LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit"
+
+		if [ "$enable_cocoa_quartz" != "0" ]; then
+			CFLAGS="$CFLAGS -DENABLE_COCOA_QUARTZ"
+		fi
+
+		if [ "$enable_cocoa_quickdraw" != "0" ]; then
+			CFLAGS="$CFLAGS -DENABLE_COCOA_QUICKDRAW"
+		fi
 	fi
 
 	if [ "$with_zlib" != "0" ]; then
@@ -1058,6 +1112,13 @@
 		CFLAGS="$CFLAGS -DNDEBUG"
 	fi
 
+	if [ "$enable_desync_debug" = "1" ]; then
+		CFLAGS="$CFLAGS -DDEBUG_DUMP_COMMANDS"
+	fi
+	if [ "$enable_desync_debug" = "2" ]; then
+		CFLAGS="$CFLAGS -DRANDOM_DEBUG"
+	fi
+
 	if [ "$enable_osx_g5" != "0" ]; then
 		CFLAGS="$CFLAGS -mtune=970 -mcpu=970 -mpowerpc-gpopt"
 	fi
@@ -1530,6 +1591,19 @@
 	fi
 
 	log 1 "checking COCOA... found"
+
+
+	if [ "$enable_cocoa_quartz" != "0" ]; then
+		log 1 "checking whether to enable the Quartz window subdriver... yes"
+	else
+		log 1 "checking whether to enable the Quartz window subdriver... no"
+	fi
+
+	if [ "$enable_cocoa_quickdraw" != "0" ]; then
+		log 1 "checking whether to enable the Quickdraw window subdriver... yes"
+	else
+		log 1 "checking whether to enable the Quickdraw window subdriver... no"
+	fi
 }
 
 detect_library() {
@@ -1982,7 +2056,7 @@
 	ppc=`$cc_host -dumpmachine | egrep "powerpc|ppc"`
 	if [ -n "$ppc" ]; then
 		T_CFLAGS="$CFLAGS -DFOUR_BYTE_BOOL"
-		osx_sysroot_version=10.3.9
+		osx_sysroot_version=10.4u
 	else
 		T_CFLAGS="$CFLAGS"
 		osx_sysroot_version=10.4u
@@ -2181,6 +2255,8 @@
 	echo "  --enable-translator            enable extra output for translators"
 	echo "  --enable-universal             enable universal builds (OSX ONLY)"
 	echo "  --enable-osx-g5                enables optimalizations for G5 (OSX ONLY)"
+	echo "  --disable-cocoa-quartz         disable the quartz window mode driver for Cocoa (OSX ONLY)"
+	echo "  --disable-cocoa-quickdraw      disable the quickdraw window mode driver for Cocoa (OSX ONLY)"
 	echo "  --disable-unicode              disable unicode support to build win9x"
 	echo "                                 version (Win32 ONLY)"
 	echo "  --disable-network              disable network support"
--- a/configure	Fri Nov 23 16:59:30 2007 +0000
+++ b/configure	Wed Jan 09 18:11:12 2008 +0000
@@ -31,7 +31,7 @@
 MEDIA_DIR="$ROOT_DIR/media"
 SOURCE_LIST="$ROOT_DIR/source.list"
 
-if [ "$1" = "--reconfig" ]; then
+if [ "$1" = "--reconfig" ] || [ "$1" = "--reconfigure" ]; then
 	if ! [ -f "config.cache" ]; then
 		echo "can't reconfigure, because never configured before"
 		exit 1
--- a/docs/landscape.html	Fri Nov 23 16:59:30 2007 +0000
+++ b/docs/landscape.html	Wed Jan 09 18:11:12 2008 +0000
@@ -945,6 +945,7 @@
        </tr>
       </table>
      </li>
+     <li>m4: Owner of the water</li>
      <li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
      <li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
     </ul>
--- a/docs/landscape_grid.html	Fri Nov 23 16:59:30 2007 +0000
+++ b/docs/landscape_grid.html	Wed Jan 09 18:11:12 2008 +0000
@@ -194,8 +194,8 @@
       <td class="bits">XXXX XXXX</td>
       <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
       <td class="bits"><span class="free">OOOO OOOO</span></td>
-      <td class="bits"><span class="free">OOOO OOOO</span></td>
-      <td class="bits"><span class="free">OOOO OO</span>XX</td>
+      <td class="bits">XXXX XXXX</td>
+      <td class="bits">XXXX XXXX</td>
       <td class="bits">XX<span class="free">OO OO</span>XX</td>
       <td class="bits"><span class="free">OOOO OOOO</span></td>
     </tr>
--- a/known-bugs.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/known-bugs.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -15,15 +15,16 @@
 ------------------------------------------------------------------------
 URL: http://bugs.openttd.org
 
-- 1434	Network game crashes when player builds SH40
+- 1519	Full screen issues in windows
+- 1495	Long vehicles block multistop station
+- 1487	Ending_year is never written to
+- 1473	Train not going to available platform
 - 1404	Spinner widget interprets one click as many
-- 1401	Crash while scrolling screen
 - 1386	Mac OS X fails to compile out of the box on 10.5
 - 1264	Autoreplace for multiple NewGRF DMU sets fails
 - 1200	Illegal names skip comparisons for uniquity
 - 1141	[OSX] Not smooth moving map with touchpad
 - 1109	[OSX] Choppy mouse cursor movement in fullscreen mode
-- 1094	Foundations showing on 'build on slopes'
 - 1074	Large slowdown when building tracks
 - 1072	Text overflows in several windows
 -  716	Train crash in depot with long long tracks
--- a/os/debian/changelog	Fri Nov 23 16:59:30 2007 +0000
+++ b/os/debian/changelog	Wed Jan 09 18:11:12 2008 +0000
@@ -4,6 +4,12 @@
 
  -- Matthijs Kooijman <m.kooijman@student.utwente.nl>  Mon, 26 Feb 2007 21:07:05 +0100
 
+openttd (0.6.0~beta2-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Matthijs Kooijman <m.kooijman@student.utwente.nl>  Sun, 09 Dec 2007 22:05:05 +0100
+
 openttd (0.6.0~beta1-1) unstable; urgency=low
 
   * New upstream release.
--- a/os/win32/installer/install.nsi	Fri Nov 23 16:59:30 2007 +0000
+++ b/os/win32/installer/install.nsi	Wed Jan 09 18:11:12 2008 +0000
@@ -1,6 +1,6 @@
 !define APPNAME "OpenTTD"   ; Define application name
 !define APPVERSION "0.6.0"  ; Define application version
-!define INSTALLERVERSION 39 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
+!define INSTALLERVERSION 40 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
 
 !define APPURLLINK "http://www.openttd.org"
 !define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}-beta1"
--- a/projects/determineversion.vbs	Fri Nov 23 16:59:30 2007 +0000
+++ b/projects/determineversion.vbs	Wed Jan 09 18:11:12 2008 +0000
@@ -127,10 +127,7 @@
 		' svn detection failed, reset error and try git
 		Err.Clear
 		Set oExec = WshShell.Exec("git rev-parse --verify --short=8 HEAD")
-		Do While oExec.Status = 0 And Err.Number = 0
-			' Wait till command has finished
-		Loop
-		If Err.Number = 0 And oExec.ExitCode = 0 Then
+		If Err.Number = 0 Then
 			version = "g" & oExec.StdOut.ReadLine()
 			Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../src")
 			Do While oExec.Status = 0 And Err.Number = 0
--- a/projects/langs.vcproj	Fri Nov 23 16:59:30 2007 +0000
+++ b/projects/langs.vcproj	Wed Jan 09 18:11:12 2008 +0000
@@ -52,19 +52,6 @@
 			</FileConfiguration>
 		</File>
 		<File
-			RelativePath="..\src\lang\american.txt">
-			<FileConfiguration
-				Name="Debug|Win32">
-				<Tool
-					Name="VCCustomBuildTool"
-					Description="Generating american language file"
-					CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;
-"
-					AdditionalDependencies=""
-					Outputs="..\bin\lang\american.lng"/>
-			</FileConfiguration>
-		</File>
-		<File
 			RelativePath="..\src\lang\brazilian_portuguese.txt">
 			<FileConfiguration
 				Name="Debug|Win32">
@@ -169,6 +156,19 @@
 			</FileConfiguration>
 		</File>
 		<File
+			RelativePath="..\src\lang\english_US.txt">
+			<FileConfiguration
+				Name="Debug|Win32">
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Generating english_US language file"
+					CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;
+"
+					AdditionalDependencies=""
+					Outputs="..\bin\lang\english_US.lng"/>
+			</FileConfiguration>
+		</File>
+		<File
 			RelativePath="..\src\lang\esperanto.txt">
 			<FileConfiguration
 				Name="Debug|Win32">
--- a/projects/langs_vs80.vcproj	Fri Nov 23 16:59:30 2007 +0000
+++ b/projects/langs_vs80.vcproj	Wed Jan 09 18:11:12 2008 +0000
@@ -62,21 +62,6 @@
 			</FileConfiguration>
 		</File>
 		<File
-			RelativePath="..\src\lang\american.txt"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCustomBuildTool"
-					Description="Generating american language file"
-					CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
-					AdditionalDependencies=""
-					Outputs="..\bin\lang\american.lng"
-				/>
-			</FileConfiguration>
-		</File>
-		<File
 			RelativePath="..\src\lang\brazilian_portuguese.txt"
 			>
 			<FileConfiguration
@@ -197,6 +182,21 @@
 			</FileConfiguration>
 		</File>
 		<File
+			RelativePath="..\src\lang\english_US.txt"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Generating english_US language file"
+					CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+					AdditionalDependencies=""
+					Outputs="..\bin\lang\english_US.lng"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
 			RelativePath="..\src\lang\esperanto.txt"
 			>
 			<FileConfiguration
--- a/projects/langs_vs90.vcproj	Fri Nov 23 16:59:30 2007 +0000
+++ b/projects/langs_vs90.vcproj	Wed Jan 09 18:11:12 2008 +0000
@@ -63,21 +63,6 @@
 			</FileConfiguration>
 		</File>
 		<File
-			RelativePath="..\src\lang\american.txt"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCustomBuildTool"
-					Description="Generating american language file"
-					CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
-					AdditionalDependencies=""
-					Outputs="..\bin\lang\american.lng"
-				/>
-			</FileConfiguration>
-		</File>
-		<File
 			RelativePath="..\src\lang\brazilian_portuguese.txt"
 			>
 			<FileConfiguration
@@ -198,6 +183,21 @@
 			</FileConfiguration>
 		</File>
 		<File
+			RelativePath="..\src\lang\english_US.txt"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Generating english_US language file"
+					CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+					AdditionalDependencies=""
+					Outputs="..\bin\lang\english_US.lng"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
 			RelativePath="..\src\lang\esperanto.txt"
 			>
 			<FileConfiguration
--- a/projects/openttd.vcproj	Fri Nov 23 16:59:30 2007 +0000
+++ b/projects/openttd.vcproj	Wed Jan 09 18:11:12 2008 +0000
@@ -198,6 +198,9 @@
 				RelativePath=".\..\src\console_cmds.cpp">
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.cpp">
+			</File>
+			<File
 				RelativePath=".\..\src\core\random_func.cpp">
 			</File>
 			<File
@@ -375,7 +378,7 @@
 				RelativePath=".\..\src\thread.cpp">
 			</File>
 			<File
-				RelativePath=".\..\src\tile.cpp">
+				RelativePath=".\..\src\tile_map.cpp">
 			</File>
 			<File
 				RelativePath=".\..\src\vehicle.cpp">
@@ -433,6 +436,9 @@
 				RelativePath=".\..\src\console.h">
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.hpp">
+			</File>
+			<File
 				RelativePath=".\..\src\core\math_func.hpp">
 			</File>
 			<File
@@ -499,9 +505,6 @@
 				RelativePath=".\..\src\heightmap.h">
 			</File>
 			<File
-				RelativePath=".\..\src\helpers.hpp">
-			</File>
-			<File
 				RelativePath=".\..\src\industry.h">
 			</File>
 			<File
@@ -511,9 +514,6 @@
 				RelativePath=".\..\src\livery.h">
 			</File>
 			<File
-				RelativePath=".\..\src\macros.h">
-			</File>
-			<File
 				RelativePath=".\..\src\map.h">
 			</File>
 			<File
@@ -682,6 +682,9 @@
 				RelativePath=".\..\src\station.h">
 			</File>
 			<File
+				RelativePath=".\..\src\station_gui.h">
+			</File>
+			<File
 				RelativePath=".\..\src\stdafx.h">
 			</File>
 			<File
@@ -900,6 +903,9 @@
 				RelativePath=".\..\src\station_cmd.cpp">
 			</File>
 			<File
+				RelativePath=".\..\src\terraform_cmd.cpp">
+			</File>
+			<File
 				RelativePath=".\..\src\timetable_cmd.cpp">
 			</File>
 			<File
@@ -1535,6 +1541,9 @@
 				RelativePath=".\..\src\tunnel_map.h">
 			</File>
 			<File
+				RelativePath=".\..\src\tunnelbridge_map.h">
+			</File>
+			<File
 				RelativePath=".\..\src\unmovable_map.h">
 			</File>
 			<File
--- a/projects/openttd_vs80.vcproj	Fri Nov 23 16:59:30 2007 +0000
+++ b/projects/openttd_vs80.vcproj	Wed Jan 09 18:11:12 2008 +0000
@@ -496,6 +496,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\core\random_func.cpp"
 				>
 			</File>
@@ -732,7 +736,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\tile.cpp"
+				RelativePath=".\..\src\tile_map.cpp"
 				>
 			</File>
 			<File
@@ -808,6 +812,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\core\math_func.hpp"
 				>
 			</File>
@@ -896,10 +904,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\helpers.hpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\industry.h"
 				>
 			</File>
@@ -912,10 +916,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\macros.h"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\map.h"
 				>
 			</File>
@@ -1140,6 +1140,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\station_gui.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\stdafx.h"
 				>
 			</File>
@@ -1428,6 +1432,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\terraform_cmd.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\timetable_cmd.cpp"
 				>
 			</File>
@@ -2260,6 +2268,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\tunnelbridge_map.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\unmovable_map.h"
 				>
 			</File>
--- a/projects/openttd_vs90.vcproj	Fri Nov 23 16:59:30 2007 +0000
+++ b/projects/openttd_vs90.vcproj	Wed Jan 09 18:11:12 2008 +0000
@@ -493,6 +493,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\core\random_func.cpp"
 				>
 			</File>
@@ -721,7 +725,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\tile.cpp"
+				RelativePath=".\..\src\tile_map.cpp"
 				>
 			</File>
 			<File
@@ -797,6 +801,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\core\math_func.hpp"
 				>
 			</File>
@@ -885,10 +893,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\helpers.hpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\industry.h"
 				>
 			</File>
@@ -901,10 +905,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\macros.h"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\map.h"
 				>
 			</File>
@@ -1113,6 +1113,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\station_gui.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\stdafx.h"
 				>
 			</File>
@@ -1401,6 +1405,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\terraform_cmd.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\timetable_cmd.cpp"
 				>
 			</File>
@@ -1801,6 +1809,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\tunnelbridge_map.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\unmovable_map.h"
 				>
 			</File>
--- a/readme.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/readme.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -1,6 +1,6 @@
 OpenTTD README
-Last updated:    2007-11-18
-Release version: 0.6.0-beta1
+Last updated:    2007-12-09
+Release version: 0.6.0-beta2
 ------------------------------------------------------------------------
 
 
@@ -281,30 +281,35 @@
 X.X) Credits:
 ---- --------
 The OpenTTD team (in alphabetical order):
-  Jean-Francois Claeys (Belugas) - In training, not yet specialized
-  Bjarni Corfitzen (Bjarni)      - Mac OS X port, coder
-  Matthijs Kooijman (blathijs)   - Pathfinder-guru
+  Jean-Francois Claeys (Belugas) - GUI, newindustries and more
+  Bjarni Corfitzen (Bjarni)      - MacOSX port, coder and vehicles
+  Matthijs Kooijman (blathijs)   - Pathfinder-guru, pool rework
+  Loïc Guilloux (glx)            - General coding
+  Jaroslav Mazanec (KUDr)        - YAPG (Yet Another Pathfinder God) ;)
+  Jonathan Coome (Maedhros)      - High priest of the newGRF Temple
+  Attila Bán (MiHaMiX)           - WebTranslator, Nightlies, Wiki and bugtracker host
+  Owen Rudge (orudge)            - Forum host, OS/2 port
+  Peter Nelson (peter1138)       - Spiritual descendant from newGRF gods
+  Remko Bijker (Rubidium)        - Lead coder and way more
+  Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker
+  Zdenek Sojka (SmatZ)           - Bug finder and fixer
+
+Inactive Developers:
   Victor Fischer (Celestar)      - Programming everywhere you need him to
-  Tamás Faragó (Darkvater)       - Lead programmer
-  Loïc Guilloux (glx)            - In training, not yet specialized
-  Jaroslav Mazanec (KUDr)        - YAPG (Yet Another Pathfinder God) ;)
-  Kerekes Miham (MiHaMiX)        - Maintainer of translator service, and host of nightlies
-  Owen Rudge (orudge)            - Contributor, forum host, OS/2 port
-  Peter Nelson (peter1138)       - Spiritual descendant from newgrf gods
-  Remko Bijker (Rubidium)        - THE desync hunter
+  Tamás Faragó (Darkvater)       - Ex-Lead coder
   Christoph Mallon (Tron)        - Programmer, code correctness police
 
 Retired Developers:
+  Ludvig Strigeus (ludde)        - OpenTTD author, main coder (0.1 - 0.3.3)
+  Serge Paquet (vurlix)          - Assistant project manager, coder (0.1 - 0.3.3)
   Dominik Scherer (dominik81)    - Lead programmer, GUI expert (0.3.0 - 0.3.6)
   Patric Stout (TrueLight)       - Programmer, webhoster (0.3 - pre0.6)
-  Ludvig Strigeus (ludde)        - OpenTTD author, main coder (0.1 - 0.3.3)
-  Serge Paquet (vurlix)          - Assistant project manager, coder (0.1 - 0.3.3)
 
 Thanks to:
   Josef Drexler                  - For his great work on TTDPatch.
   Marcin Grzegorczyk             - For his TTDPatch work and documentation of TTD internals and graphics (signals and track foundations)
   Petr Baudis (pasky)            - Many patches, newgrf support, etc.
-  Simon Sasburg (HackyKid)       - For the many bugfixes he has blessed us with (and future PBS)
+  Simon Sasburg (HackyKid)       - For the many bugfixes he has blessed us with
   Stefan Meißner (sign_de)       - For his work on the console
   Mike Ragsdale                  - OpenTTD installer
   Cian Duffy (MYOB)              - BeOS port / manual writing
--- a/source.list	Fri Nov 23 16:59:30 2007 +0000
+++ b/source.list	Wed Jan 09 18:11:12 2008 +0000
@@ -10,6 +10,7 @@
 command.cpp
 console.cpp
 console_cmds.cpp
+core/bitmath_func.cpp
 core/random_func.cpp
 currency.cpp
 date.cpp
@@ -76,7 +77,7 @@
 texteff.cpp
 tgp.cpp
 thread.cpp
-tile.cpp
+tile_map.cpp
 #if WIN32
 #else
 	#if WINCE
@@ -110,6 +111,7 @@
 cargotype.h
 command.h
 console.h
+core/bitmath_func.hpp
 core/math_func.hpp
 core/random_func.hpp
 currency.h
@@ -132,11 +134,9 @@
 group.h
 gui.h
 heightmap.h
-helpers.hpp
 industry.h
 landscape.h
 livery.h
-macros.h
 map.h
 md5.h
 mixer.h
@@ -193,6 +193,7 @@
 sprite.h
 spritecache.h
 station.h
+station_gui.h
 stdafx.h
 string.h
 texteff.hpp
@@ -267,6 +268,7 @@
 roadveh_cmd.cpp
 ship_cmd.cpp
 station_cmd.cpp
+terraform_cmd.cpp
 timetable_cmd.cpp
 town_cmd.cpp
 train_cmd.cpp
@@ -490,6 +492,7 @@
 tree_map.h
 tunnel_map.cpp
 tunnel_map.h
+tunnelbridge_map.h
 unmovable_map.h
 void_map.h
 water_map.h
--- a/src/ai/ai.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/ai.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,10 +4,11 @@
 
 #include "../stdafx.h"
 #include "../openttd.h"
+#include "../player.h"
 #include "../variables.h"
-#include "../command.h"
+#include "../command_func.h"
 #include "../network/network.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
 #include "../debug.h"
 
 #ifndef NO_THREADS
--- a/src/ai/ai_factory.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/ai_factory.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -10,6 +10,7 @@
 #include <assert.h>
 #include "../stdafx.h"
 #include "../functions.h"
+#include "../network/network.h"
 
 class AIController;
 
--- a/src/ai/ai_squirrel.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/ai_squirrel.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,8 @@
 #include "../stdafx.h"
 #include "../debug.h"
 #include "../openttd.h"
-#include "../string.h"
+#include "../string_func.h"
+#include "../fileio.h"
 #include "../fios.h"
 #include <sys/types.h>
 #include <sys/stat.h>
--- a/src/ai/ai_threads.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/ai_threads.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,7 @@
 #include "../player.h"
 #include "../debug.h"
 #include "../thread.h"
+#include "../vehicle_func.h"
 #include "ai.h"
 #include "ai_threads.h"
 #include "api/ai_controller.hpp"
--- a/src/ai/api/ai_airport.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_airport.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,7 +1,6 @@
 /* $Id$ */
 
 #include "ai_airport.hpp"
-#include "../../command.h"
 #include "../../variables.h"
 #include "../../station_map.h"
 
--- a/src/ai/api/ai_base.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_base.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,6 +3,7 @@
 /** @file ai_base.cpp handles the functions of the AIBase class */
 
 #include "ai_base.hpp"
+#include "../../network/network.h"
 
 /* static */ uint32 AIBase::Rand()
 {
--- a/src/ai/api/ai_cargo.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_cargo.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,8 @@
 #include "ai_cargo.hpp"
 #include "../../cargotype.h"
 #include "../../player.h" // For economy.h
-#include "../../economy.h"
+#include "../../economy_func.h"
+#include "../../core/alloc_func.hpp"
 
 /* static */ bool AICargo::IsValidCargo(CargoID cargo_type)
 {
--- a/src/ai/api/ai_company.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_company.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,11 +3,12 @@
 /** @file ai_company.cpp handles the functions of the AICompany class */
 
 #include "ai_company.hpp"
-#include "../../command.h"
+#include "../../command_func.h"
 #include "../../player.h"
-#include "../../economy.h"
-#include "../../strings.h"
+#include "../../economy_func.h"
+#include "../../strings_func.h"
 #include "../../variables.h"
+#include "../../core/alloc_func.hpp"
 #include "table/strings.h"
 
 AICompany::CompanyIndex AICompany::ResolveCompanyIndex(AICompany::CompanyIndex company)
--- a/src/ai/api/ai_engine.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_engine.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,8 +6,9 @@
 #include "ai_cargo.hpp"
 #include "../../engine.h"
 #include "../../player.h"
-#include "../../variables.h"
-#include "../../strings.h"
+#include "../../strings_func.h"
+#include "../../core/alloc_func.hpp"
+#include "../../economy_func.h"
 
 /* static */ bool AIEngine::IsValidEngine(EngineID engine_id)
 {
--- a/src/ai/api/ai_industry.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_industry.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,8 +5,7 @@
 #include "ai_industry.hpp"
 #include "ai_cargo.hpp"
 #include "../../industry.h"
-#include "../../strings.h"
-#include "../../variables.h" /* For SetDParam */
+#include "../../strings_func.h"
 #include "table/strings.h"
 
 IndustryID AIIndustry::GetMaxIndustryID()
--- a/src/ai/api/ai_industry.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_industry.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,6 +6,7 @@
 #define AI_INDUSTRY_HPP
 
 #include "ai_object.hpp"
+#include "../../industry.h"
 
 /**
  * Class that handles all industry related functions.
--- a/src/ai/api/ai_map.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_map.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,7 +3,8 @@
 /** @file ai_map.cpp handles the query-related of the AIMap class */
 
 #include "ai_map.hpp"
-#include "../../command.h"
+#include "../../command_type.h"
+#include "../../map_func.h"
 
 /* static */ bool AIMap::IsValidTile(TileIndex t)
 {
--- a/src/ai/api/ai_marine.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_marine.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,7 +1,7 @@
 /* $Id$ */
 
 #include "ai_marine.hpp"
-#include "../../command.h"
+#include "../../command_type.h"
 #include "../../variables.h"
 #include "../../station_map.h"
 #include "../../water_map.h"
--- a/src/ai/api/ai_object.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_object.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,10 +3,12 @@
 /** @file ai_object.cpp handles the commands-related functions of the AIObject class */
 
 #include "ai_object.hpp"
-#include "../../command.h"
+#include "../../command_func.h"
+#include "../../network/network.h"
 #include "../../player.h"
 #include "table/strings.h" // for signs.h
 #include "../../signs.h" // for _new_sign_id
+#include "../../vehicle_func.h"
 #include "../ai.h"
 #include "../ai_threads.h"
 
--- a/src/ai/api/ai_order.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_order.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,9 +5,9 @@
 #include "ai_order.hpp"
 #include "ai_map.hpp"
 #include "ai_vehicle.hpp"
-#include "../../command.h"
+#include "../../command_type.h"
 #include "../../order.h"
-#include "../../vehicle.h"
+#include "../../vehicle_base.h"
 #include "../../depot.h"
 #include "../../landscape.h"
 #include "../../rail_map.h"
--- a/src/ai/api/ai_pathfinder_stupid.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_pathfinder_stupid.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,6 +3,7 @@
 #include "ai_pathfinder_stupid.hpp"
 #include "ai_road.hpp"
 #include "ai_testmode.hpp"
+#include "../../map_func.h"
 
 bool AIPathFinderStupid::BuildRealRoute(TileIndex start, TileIndex end, bool continue_on_error)
 {
--- a/src/ai/api/ai_road.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_road.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,7 +3,6 @@
 /** @file ai_road.cpp handles the functions of the AIRoad class */
 
 #include "ai_road.hpp"
-#include "../../command.h"
 #include "../../road_map.h"
 #include "../../station_map.h"
 
--- a/src/ai/api/ai_sign.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_sign.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,11 +4,12 @@
 
 #include "ai_sign.hpp"
 #include "table/strings.h"
-#include "../../command.h"
+#include "../../command_func.h"
+#include "../../core/alloc_func.hpp"
 #include "../../landscape.h"
 #include "../../signs.h"
-#include "../../strings.h"
-#include "../../variables.h" /* For SetDParam */
+#include "../../strings_func.h"
+#include "../../map_func.h"
 
 SignID AISign::GetMaxSignID()
 {
--- a/src/ai/api/ai_station.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_station.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,7 +8,8 @@
 #include "../../station.h"
 #include "../../station_map.h"
 #include "../../variables.h"
-#include "../../strings.h"
+#include "../../strings_func.h"
+#include "../../core/alloc_func.hpp"
 #include "table/strings.h"
 
 /* static */ bool AIStation::IsValidStation(StationID station_id)
--- a/src/ai/api/ai_stationlist.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_stationlist.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,7 @@
 #include "../../player.h"
 #include "../../station.h"
 #include "../../order.h"
-#include "../../vehicle.h"
+#include "../../vehicle_base.h"
 
 AIStationList::AIStationList(AIStation::StationType type)
 {
--- a/src/ai/api/ai_tile.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_tile.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,10 +3,11 @@
 /** @file ai_tile.cpp handles the functions of the AITile class */
 
 #include "ai_tile.hpp"
-#include "../../tile.h"
+#include "../../tile_map.h"
+#include "../../map_func.h"
 #include "../../variables.h"
 #include "../../station.h"
-#include "../../command.h"
+#include "../../command_type.h"
 
 bool AITile::IsBuildable(TileIndex tile)
 {
--- a/src/ai/api/ai_tilelist.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_tilelist.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,7 @@
 #include "ai_tilelist.hpp"
 
 #include "../../landscape.h"
+#include "../../map_func.h"
 
 void AITileList::FixRectangleSpan(TileIndex &t1, TileIndex &t2)
 {
--- a/src/ai/api/ai_tilelist_valuator.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_tilelist_valuator.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -2,7 +2,6 @@
 #include "ai_tile.hpp"
 #include "ai_road.hpp"
 #include "ai_map.hpp"
-#include "../../tile.h"
 #include "../../road_map.h"
 
 int32 AITileListBuildable::Valuate(int32 tile) const
--- a/src/ai/api/ai_town.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_town.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,8 +4,9 @@
 
 #include "ai_town.hpp"
 #include "../../town.h"
-#include "../../strings.h"
-#include "../../variables.h" /* For SetDParam */
+#include "../../strings_func.h"
+#include "../../town_type.h"
+#include "../../core/alloc_func.hpp"
 #include "table/strings.h"
 
 TownID AITown::GetMaxTownID()
--- a/src/ai/api/ai_town.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_town.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,6 +6,7 @@
 #define AI_TOWN_HPP
 
 #include "ai_object.hpp"
+#include "../../town_type.h"
 
 /**
  * Class that handles all town related functions.
--- a/src/ai/api/ai_transactionmode.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_transactionmode.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,7 +4,7 @@
 
 #include "ai_transactionmode.hpp"
 #include "ai_execmode.hpp"
-#include "../../command.h"
+#include "../../command_func.h"
 #include "../../debug.h"
 #include <stack>
 
--- a/src/ai/api/ai_vehicle.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_vehicle.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,13 +6,13 @@
 #include "ai_engine.hpp"
 #include "ai_cargo.hpp"
 #include "ai_order.hpp"
-#include "../../command.h"
-#include "../../vehicle.h"
+#include "../../command_func.h"
 #include "../../depot.h"
 #include "../../engine.h"
 #include "../../player.h"
 #include "../../aircraft.h"
-#include "../../strings.h"
+#include "../../strings_func.h"
+#include "../../core/alloc_func.hpp"
 #include "table/strings.h"
 
 /* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
--- a/src/ai/api/ai_vehicle.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_vehicle.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,7 +6,7 @@
 #define AI_VEHICLE_HPP
 
 #include "ai_object.hpp"
-#include "../../vehicle.h"
+#include "../../vehicle_type.h"
 
 /**
  * Class that handles all vehicle related functions.
--- a/src/ai/api/ai_vehiclelist.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ai/api/ai_vehiclelist.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,7 +1,7 @@
 #include "ai_vehiclelist.hpp"
 #include "../../player.h"
 #include "../../station.h"
-#include "../../vehicle.h"
+#include "../../vehicle_base.h"
 
 AIVehicleList::AIVehicleList()
 {
--- a/src/aircraft.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/aircraft.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,9 +6,8 @@
 #define AIRCRAFT_H
 
 #include "station_map.h"
-#include "vehicle.h"
+#include "vehicle_base.h"
 #include "engine.h"
-#include "variables.h"
 
 /** An aircraft can be one ot those types */
 enum AircraftSubType {
--- a/src/aircraft_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/aircraft_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -7,21 +7,14 @@
 #include "openttd.h"
 #include "aircraft.h"
 #include "debug.h"
-#include "functions.h"
 #include "landscape.h"
 #include "station_map.h"
-#include "strings.h"
 #include "table/strings.h"
-#include "map.h"
-#include "tile.h"
-#include "vehicle.h"
 #include "timetable.h"
 #include "depot.h"
 #include "engine.h"
-#include "command.h"
 #include "station.h"
 #include "news.h"
-#include "sound.h"
 #include "player.h"
 #include "aircraft.h"
 #include "airport.h"
@@ -31,9 +24,19 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_text.h"
 #include "newgrf_sound.h"
-#include "date.h"
 #include "spritecache.h"
 #include "cargotype.h"
+#include "strings_func.h"
+#include "command_func.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "functions.h"
+#include "variables.h"
+#include "autoreplace_func.h"
+#include "autoreplace_gui.h"
+#include "gfx_func.h"
 #include "ai/ai.h"
 
 void Aircraft::UpdateDeltaXY(Direction direction)
@@ -163,7 +166,7 @@
 		int sprite = GetCustomVehicleSprite(this, direction);
 
 		if (sprite != 0) return sprite;
-		spritenum = orig_aircraft_vehicle_info[this->engine_type - AIRCRAFT_ENGINES_INDEX].image_index;
+		spritenum = _orig_aircraft_vehicle_info[this->engine_type - AIRCRAFT_ENGINES_INDEX].image_index;
 	}
 	return direction + _aircraft_sprite[spritenum];
 }
@@ -191,7 +194,7 @@
 	if (is_custom_sprite(spritenum)) {
 		sprite = GetCustomVehicleIcon(engine, DIR_W);
 		if (sprite == 0) {
-			spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
+			spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
 			sprite = (6 + _aircraft_sprite[spritenum]);
 		}
 	}
@@ -219,7 +222,7 @@
 	if (is_custom_sprite(spritenum)) {
 		sprite = GetCustomVehicleIcon(engine, DIR_W);
 		if (sprite == 0) {
-			spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
+			spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
 			sprite = (6 + _aircraft_sprite[spritenum]);
 		}
 	}
@@ -232,7 +235,7 @@
 
 static CommandCost EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi)
 {
-	return CommandCost(GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
+	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
 }
 
 
@@ -280,8 +283,6 @@
 
 	if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
 	/* Prevent building aircraft types at places which can't handle them */
 	if (!CanAircraftUseStation(p1, tile)) return CMD_ERROR;
 
@@ -490,9 +491,7 @@
 
 	if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE);
 
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
-	CommandCost ret(-v->value);
+	CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
 
 	if (flags & DC_EXEC) {
 		// Invalidate depot
@@ -642,13 +641,12 @@
 
 	if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
 	if (!v->IsStoppedInDepot()) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED);
+	if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_REFIT_DESTROYED_VEHICLE);
 
 	/* Check cargo */
 	CargoID new_cid = GB(p2, 0, 8);
 	if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
-
 	/* Check the refit capacity callback */
 	uint16 callback = CALLBACK_FAILED;
 	if (HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
@@ -738,11 +736,10 @@
 
 	if (v->vehstatus & VS_STOPPED) return;
 
-	CommandCost cost = CommandCost(GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364);
+	CommandCost cost = CommandCost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364);
 
 	v->profit_this_year -= cost.GetCost() >> 8;
 
-	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
 	SubtractMoneyFromPlayerFract(v->owner, cost);
 
 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
@@ -1043,7 +1040,17 @@
 		tile = st->xy;
 
 		/* Jump into our "holding pattern" state machine if possible */
-	if (v->u.air.pos >= afc->nofelements) v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
+		if (v->u.air.pos >= afc->nofelements) {
+			v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
+		} else if (v->u.air.targetairport != v->current_order.dest) {
+			/* If not possible, just get out of here fast */
+			v->u.air.state = FLYING;
+			UpdateAircraftCache(v);
+			AircraftNextAirportPos_and_Order(v);
+			/* get aircraft back on running altitude */
+			SetAircraftPosition(v, v->x_pos, v->y_pos, GetAircraftFlyingAltitude(v));
+			return false;
+		}
 	}
 
 	/*  get airport moving data */
@@ -1256,7 +1263,7 @@
 
 	if (v->u.air.crashed_counter < 650) {
 		uint32 r;
-		if (CHANCE16R(1,32,r)) {
+		if (Chance16R(1,32,r)) {
 			static const DirDiff delta[] = {
 				DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
 			};
--- a/src/aircraft_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/aircraft_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,22 +6,17 @@
 #include "openttd.h"
 #include "aircraft.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "map.h"
-#include "window.h"
 #include "gui.h"
-#include "vehicle.h"
-#include "gfx.h"
-#include "command.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.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/airport.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,13 +5,12 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "map.h"
 #include "airport.h"
-#include "macros.h"
 #include "variables.h"
 #include "airport_movement.h"
-#include "date.h"
-#include "helpers.hpp"
+#include "core/bitmath_func.hpp"
+#include "core/alloc_func.hpp"
+#include "date_func.h"
 
 /* Uncomment this to print out a full report of the airport-structure
  * You should either use
@@ -431,18 +430,6 @@
 	"DUMMY" // extra heading for 255
 };
 
-static uint AirportBlockToString(uint32 block)
-{
-	uint i = 0;
-	if (block & 0xffff0000) { block >>= 16; i += 16; }
-	if (block & 0x0000ff00) { block >>=  8; i +=  8; }
-	if (block & 0x000000f0) { block >>=  4; i +=  4; }
-	if (block & 0x0000000c) { block >>=  2; i +=  2; }
-	if (block & 0x00000002) { i += 1; }
-	return i;
-}
-
-
 static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool full_report)
 {
 	if (!full_report) printf("(P = Current Position; NP = Next Position)\n");
@@ -453,7 +440,7 @@
 				byte heading = (current->heading == 255) ? MAX_HEADINGS + 1 : current->heading;
 				printf("\tPos:%2d NPos:%2d Heading:%15s Block:%2d\n", current->position,
 					    current->next_position, _airport_heading_strings[heading],
-							AirportBlockToString(current->block));
+							FindLastBit(current->block));
 			} else {
 				printf("P:%2d NP:%2d", current->position, current->next_position);
 			}
--- a/src/airport.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/airport.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,8 @@
 #ifndef AIRPORT_H
 #define AIRPORT_H
 
-#include "direction.h"
+#include "direction_type.h"
+#include "map_type.h"
 
 enum {MAX_TERMINALS =  10};
 enum {MAX_HELIPADS  =   4};
--- a/src/airport_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/airport_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,18 +6,19 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
-#include "map.h"
-#include "window.h"
+#include "window_gui.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
-#include "sound.h"
-#include "command.h"
-#include "vehicle.h"
+#include "station_gui.h"
+#include "terraform_gui.h"
+#include "command_func.h"
 #include "station.h"
 #include "airport.h"
 #include "depot.h"
+#include "sound_func.h"
+#include "window_func.h"
+#include "variables.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 
 static byte _selected_airport_type;
 
@@ -101,7 +102,7 @@
 		break;
 
 	case WE_ABORT_PLACE_OBJ:
-		RaiseWindowButtons(w);
+		w->RaiseButtons();
 
 		w = FindWindowById(WC_BUILD_STATION, 0);
 		if (w != 0)
@@ -145,9 +146,9 @@
 {
 	switch (e->event) {
 	case WE_CREATE:
-		SetWindowWidgetLoweredState(w, 16, !_station_show_coverage);
-		SetWindowWidgetLoweredState(w, 17, _station_show_coverage);
-		LowerWindowWidget(w, _selected_airport_type + 7);
+		w->SetWidgetLoweredState(16, !_station_show_coverage);
+		w->SetWidgetLoweredState(17, _station_show_coverage);
+		w->LowerWidget(_selected_airport_type + 7);
 		break;
 
 	case WE_PAINT: {
@@ -159,10 +160,10 @@
 
 		avail_airports = GetValidAirports();
 
-		RaiseWindowWidget(w, _selected_airport_type + 7);
+		w->RaiseWidget(_selected_airport_type + 7);
 		if (!HasBit(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE;
 		if (!HasBit(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL;
-		LowerWindowWidget(w, _selected_airport_type + 7);
+		w->LowerWidget(_selected_airport_type + 7);
 
 		/* 'Country Airport' starts at widget 7, and if its bit is set, it is
 		 * available, so take its opposite value to set the disabled state.
@@ -170,7 +171,7 @@
 		 * XXX TODO : all airports should be held in arrays, with all relevant data.
 		 * This should be part of newgrf-airports, i suppose
 		 */
-		for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HasBit(avail_airports, i));
+		for (i = 0; i < 9; i++) w->SetWidgetDisabledState(i + 7, !HasBit(avail_airports, i));
 
 		// select default the coverage area to 'Off' (16)
 		airport = GetAirport(_selected_airport_type);
@@ -190,16 +191,16 @@
 	case WE_CLICK: {
 		switch (e->we.click.widget) {
 		case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:
-			RaiseWindowWidget(w, _selected_airport_type + 7);
+			w->RaiseWidget(_selected_airport_type + 7);
 			_selected_airport_type = e->we.click.widget - 7;
-			LowerWindowWidget(w, _selected_airport_type + 7);
+			w->LowerWidget(_selected_airport_type + 7);
 			SndPlayFx(SND_15_BEEP);
 			SetWindowDirty(w);
 			break;
 		case 16: case 17:
 			_station_show_coverage = (e->we.click.widget != 16);
-			SetWindowWidgetLoweredState(w, 16, !_station_show_coverage);
-			SetWindowWidgetLoweredState(w, 17, _station_show_coverage);
+			w->SetWidgetLoweredState(16, !_station_show_coverage);
+			w->SetWidgetLoweredState(17, _station_show_coverage);
 			SndPlayFx(SND_15_BEEP);
 			SetWindowDirty(w);
 			break;
--- a/src/articulated_vehicles.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/articulated_vehicles.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,15 +4,13 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "command.h"
-#include "vehicle.h"
 #include "articulated_vehicles.h"
 #include "engine.h"
 #include "train.h"
 #include "roadveh.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_engine.h"
+#include "vehicle_func.h"
 
 
 uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
--- a/src/articulated_vehicles.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/articulated_vehicles.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef ARTICULATED_VEHICLES_H
 #define ARTICULATED_VEHICLES_H
 
+#include "vehicle_type.h"
+
 uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
 void AddArticulatedParts(Vehicle **vl, VehicleType type);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/autoreplace_base.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,38 @@
+/* $Id$ */
+
+/** @file autoreplace_base.h Base class for autoreplaces/autorenews. */
+
+#ifndef AUTOREPLACE_BASE_H
+#define AUTOREPLACE_BASE_H
+
+#include "oldpool.h"
+#include "autoreplace_type.h"
+
+/**
+ * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
+ * placed here so the only exception to this rule, the saveload code, can use
+ * it.
+ */
+DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000)
+
+/**
+ * Struct to store engine replacements. DO NOT USE outside of engine.c. Is
+ * placed here so the only exception to this rule, the saveload code, can use
+ * it.
+ */
+struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
+	EngineID from;
+	EngineID to;
+	EngineRenew *next;
+	GroupID group_id;
+
+	EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {}
+	~EngineRenew() { this->from = INVALID_ENGINE; }
+
+	inline bool IsValid() const { return this->from != INVALID_ENGINE; }
+};
+
+#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid())
+#define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
+
+#endif /* AUTOREPLACE_BASE_H */
--- a/src/autoreplace_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/autoreplace_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,9 +5,7 @@
 #include "roadveh.h"
 #include "ship.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "news.h"
-#include "command.h"
 #include "player.h"
 #include "engine.h"
 #include "debug.h"
@@ -17,8 +15,13 @@
 #include "aircraft.h"
 #include "cargotype.h"
 #include "group.h"
-#include "strings.h"
-
+#include "order.h"
+#include "strings_func.h"
+#include "command_func.h"
+#include "vehicle_func.h"
+#include "functions.h"
+#include "variables.h"
+#include "autoreplace_func.h"
 
 /*
  * move the cargo from one engine to another if possible
@@ -158,12 +161,10 @@
 	/* We give the player a loan of the same amount as the sell value.
 	 * This is needed in case he needs the income from the sale to build the new vehicle.
 	 * We take it back if building fails or when we really sell the old engine */
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 	SubtractMoneyFromPlayer(sell_value);
 
 	cost = DoCommand(old_v->tile, new_engine_type, 3, flags, GetCmdBuildVeh(old_v));
 	if (CmdFailed(cost)) {
-		SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 		/* Take back the money we just gave the player */
 		sell_value.MultiplyCost(-1);
 		SubtractMoneyFromPlayer(sell_value);
@@ -263,7 +264,6 @@
 		/* Ensure that the player will not end up having negative money while autoreplacing
 		 * This is needed because the only other check is done after the income from selling the old vehicle is substracted from the cost */
 		if (CmdFailed(tmp_move) || p->player_money < (cost.GetCost() + total_cost)) {
-			SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 			/* Pay back the loan */
 			sell_value.MultiplyCost(-1);
 			SubtractMoneyFromPlayer(sell_value);
@@ -273,7 +273,6 @@
 
 	/* Take back the money we just gave the player just before building the vehicle
 	 * The player will get the same amount now that the sale actually takes place */
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 	sell_value.MultiplyCost(-1);
 	SubtractMoneyFromPlayer(sell_value);
 
@@ -333,7 +332,7 @@
 	v->leave_depot_instantly = false;
 
 	for (;;) {
-		cost = CommandCost();
+		cost = CommandCost(EXPENSES_NEW_VEHICLES);
 		w = v;
 		do {
 			if (w->type == VEH_TRAIN && IsRearDualheaded(w)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/autoreplace_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,103 @@
+/* $Id$ */
+
+/** @file autoreplace_func.h Functions related to autoreplacing. */
+
+#ifndef AUTOREPLACE_FUNC_H
+#define AUTOREPLACE_FUNC_H
+
+#include "autoreplace_type.h"
+#include "player.h"
+
+/**
+ * Remove all engine replacement settings for the player.
+ * @param  erl The renewlist for a given player.
+ * @return The new renewlist for the player.
+ */
+void RemoveAllEngineReplacement(EngineRenewList *erl);
+
+/**
+ * Retrieve the engine replacement in a given renewlist for an original engine type.
+ * @param  erl The renewlist to search in.
+ * @param  engine Engine type to be replaced.
+ * @return The engine type to replace with, or INVALID_ENGINE if no
+ * replacement is in the list.
+ */
+EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
+
+/**
+ * Add an engine replacement to the given renewlist.
+ * @param erl The renewlist to add to.
+ * @param old_engine The original engine type.
+ * @param new_engine The replacement engine type.
+ * @param flags The calling command flags.
+ * @return 0 on success, CMD_ERROR on failure.
+ */
+CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
+
+/**
+ * Remove an engine replacement from a given renewlist.
+ * @param erl The renewlist from which to remove the replacement
+ * @param engine The original engine type.
+ * @param flags The calling command flags.
+ * @return 0 on success, CMD_ERROR on failure.
+ */
+CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags);
+
+/**
+ * Remove all engine replacement settings for the given player.
+ * @param p Player.
+ */
+static inline void RemoveAllEngineReplacementForPlayer(Player *p)
+{
+	RemoveAllEngineReplacement(&p->engine_renew_list);
+}
+
+/**
+ * Retrieve the engine replacement for the given player and original engine type.
+ * @param p Player.
+ * @param engine Engine type.
+ * @return The engine type to replace with, or INVALID_ENGINE if no
+ * replacement is in the list.
+ */
+static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
+{
+	return EngineReplacement(p->engine_renew_list, engine, group);
+}
+
+/**
+ * Check if a player has a replacement set up for the given engine.
+ * @param p Player.
+ * @param  engine Engine type to be replaced.
+ * @return true if a replacement was set up, false otherwise.
+ */
+static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
+{
+	return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE;
+}
+
+/**
+ * Add an engine replacement for the player.
+ * @param p Player.
+ * @param old_engine The original engine type.
+ * @param new_engine The replacement engine type.
+ * @param flags The calling command flags.
+ * @return 0 on success, CMD_ERROR on failure.
+ */
+static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
+{
+	return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags);
+}
+
+/**
+ * Remove an engine replacement for the player.
+ * @param p Player.
+ * @param engine The original engine type.
+ * @param flags The calling command flags.
+ * @return 0 on success, CMD_ERROR on failure.
+ */
+static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags)
+{
+	return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags);
+}
+
+#endif /* AUTOREPLACE_FUNC_H */
--- a/src/autoreplace_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/autoreplace_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,18 +5,20 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "window.h"
 #include "gui.h"
-#include "command.h"
+#include "command_func.h"
 #include "variables.h"
 #include "vehicle_gui.h"
 #include "newgrf_engine.h"
 #include "group.h"
-
+#include "rail.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "autoreplace_func.h"
+#include "gfx_func.h"
 
 static RailType _railtype_selected_in_replace_gui;
 
@@ -31,6 +33,15 @@
 	INVALID_STRING_ID
 };
 
+static int CDECL TrainEngineNumberSorter(const void *a, const void *b)
+{
+	const EngineID va = *(const EngineID*)a;
+	const EngineID vb = *(const EngineID*)b;
+	int r = ListPositionOfEngine(va) - ListPositionOfEngine(vb);
+
+	return r;
+}
+
 /* General Vehicle GUI based procedures that are independent of vehicle types */
 void InitializeVehiclesGuiList()
 {
@@ -172,6 +183,7 @@
 		if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list
 	}
 	WP(w, replaceveh_d).sel_engine[i] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
+	if (type == VEH_TRAIN) EngList_Sort(list, &TrainEngineNumberSorter);
 }
 
 /** Generate the lists
@@ -240,7 +252,7 @@
 
 			Player *p = GetPlayer(_local_player);
 			EngineID selected_id[2];
-			const GroupID selected_group = WP(w,replaceveh_d).sel_group;
+			const GroupID selected_group = WP(w, replaceveh_d).sel_group;
 
 			selected_id[0] = WP(w, replaceveh_d).sel_engine[0];
 			selected_id[1] = WP(w, replaceveh_d).sel_engine[1];
@@ -249,7 +261,7 @@
 			 *    Either list is empty
 			 * or The selected replacement engine has a replacement (to prevent loops)
 			 * or The right list (new replacement) has the existing replacement vehicle selected */
-			SetWindowWidgetDisabledState(w, 4,
+			w->SetWidgetDisabledState(4,
 										 selected_id[0] == INVALID_ENGINE ||
 										 selected_id[1] == INVALID_ENGINE ||
 										 EngineReplacementForPlayer(p, selected_id[1], selected_group) != INVALID_ENGINE ||
@@ -258,7 +270,7 @@
 			/* Disable the "Stop Replacing" button if:
 			 *   The left list (existing vehicle) is empty
 			 *   or The selected vehicle has no replacement set up */
-			SetWindowWidgetDisabledState(w, 6,
+			w->SetWidgetDisabledState(6,
 										 selected_id[0] == INVALID_ENGINE ||
 										 !EngineHasReplacementForPlayer(p, selected_id[0], selected_group));
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/autoreplace_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+/** @file autoreplace_gui.h Functions related to the autoreplace GUIs*/
+
+#ifndef AUTOREPLACE_GUI_H
+#define AUTOREPLACE_GUI_H
+
+#include "vehicle_type.h"
+
+/**
+ * When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
+ * @param type The type of engine
+ */
+void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type);
+void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g);
+void ShowReplaceVehicleWindow(VehicleType vehicletype);
+void ShowReplaceGroupVehicleWindow(GroupID group, VehicleType veh);
+
+#endif /* AUTOREPLACE_GUI_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/autoreplace_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,15 @@
+/* $Id$ */
+
+/** @file autoreplace_type.h Types related to autoreplacing. */
+
+#ifndef AUTOREPLACE_TYPE_H
+#define AUTOREPLACE_TYPE_H
+
+struct EngineRenew;
+
+/**
+ * A list to group EngineRenew directives together (such as per-player).
+ */
+typedef EngineRenew* EngineRenewList;
+
+#endif /* AUTOREPLACE_TYPE_H */
--- a/src/autoslope.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/autoslope.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,6 +6,7 @@
 #define AUTOSLOPE_H
 
 #include "depot.h"
+#include "settings_type.h"
 
 /**
  * Autoslope check for tiles with an entrance on an edge.
--- a/src/aystar.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/aystar.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -21,7 +21,7 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "aystar.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
 
 int _aystar_stats_open_size;
 int _aystar_stats_closed_size;
--- a/src/aystar.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/aystar.h	Wed Jan 09 18:11:12 2008 +0000
@@ -12,6 +12,7 @@
 #define AYSTAR_H
 
 #include "queue.h"
+#include "tile_type.h"
 
 //#define AYSTAR_DEBUG
 enum {
--- a/src/blitter/32bpp_anim.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/32bpp_anim.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,6 +1,9 @@
+/* $Id$ */
+
 #include "../stdafx.h"
-#include "../zoom.hpp"
-#include "../gfx.h"
+#include "../core/alloc_func.hpp"
+#include "../gfx_func.h"
+#include "../zoom_func.h"
 #include "../debug.h"
 #include "../table/sprites.h"
 #include "../video/video_driver.hpp"
--- a/src/blitter/32bpp_base.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/32bpp_base.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,5 +1,7 @@
+/* $Id$ */
+
 #include "../stdafx.h"
-#include "../gfx.h"
+#include "../gfx_func.h"
 #include "32bpp_base.hpp"
 
 void *Blitter_32bppBase::MoveTo(const void *video, int x, int y)
--- a/src/blitter/32bpp_base.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/32bpp_base.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,6 +6,7 @@
 #define BLITTER_32BPP_BASE_HPP
 
 #include "base.hpp"
+#include "../core/bitmath_func.hpp"
 
 class Blitter_32bppBase : public Blitter {
 public:
--- a/src/blitter/32bpp_optimized.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/32bpp_optimized.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,6 +1,8 @@
+/* $Id$ */
+
 #include "../stdafx.h"
-#include "../zoom.hpp"
-#include "../gfx.h"
+#include "../zoom_func.h"
+#include "../gfx_func.h"
 #include "../debug.h"
 #include "../table/sprites.h"
 #include "32bpp_optimized.hpp"
--- a/src/blitter/32bpp_simple.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/32bpp_simple.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,6 +1,8 @@
+/* $Id$ */
+
 #include "../stdafx.h"
-#include "../zoom.hpp"
-#include "../gfx.h"
+#include "../gfx_func.h"
+#include "../zoom_func.h"
 #include "../debug.h"
 #include "../table/sprites.h"
 #include "32bpp_simple.hpp"
--- a/src/blitter/8bpp_base.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/8bpp_base.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,5 +1,7 @@
+/* $Id$ */
+
 #include "../stdafx.h"
-#include "../gfx.h"
+#include "../gfx_func.h"
 #include "8bpp_base.hpp"
 
 void Blitter_8bppBase::DrawColorMappingRect(void *dst, int width, int height, int pal)
--- a/src/blitter/8bpp_debug.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/8bpp_debug.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,9 +3,8 @@
 /** @file 8bpp_debug.cpp */
 
 #include "../stdafx.h"
-#include "../zoom.hpp"
-#include "../gfx.h"
-#include "../functions.h"
+#include "../zoom_func.h"
+#include "../core/random_func.hpp"
 #include "8bpp_debug.hpp"
 
 static FBlitter_8bppDebug iFBlitter_8bppDebug;
--- a/src/blitter/8bpp_optimized.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/8bpp_optimized.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,9 +3,9 @@
 /** @file 8bpp_optimized.cpp */
 
 #include "../stdafx.h"
-#include "../zoom.hpp"
-#include "../gfx.h"
+#include "../zoom_func.h"
 #include "../debug.h"
+#include "../core/alloc_func.hpp"
 #include "8bpp_optimized.hpp"
 
 static FBlitter_8bppOptimized iFBlitter_8bppOptimized;
@@ -17,7 +17,7 @@
 	uint offset = 0;
 
 	/* Find the offset of this zoom-level */
-	offset = ((const uint8 *)bp->sprite)[(int)zoom * 2] | ((const byte *)bp->sprite)[(int)zoom * 2 + 1] << 8;
+	offset = ((const uint8 *)bp->sprite)[(int)(zoom - ZOOM_LVL_BEGIN) * 2] | ((const byte *)bp->sprite)[(int)(zoom - ZOOM_LVL_BEGIN) * 2 + 1] << 8;
 
 	/* Find where to start reading in the source sprite */
 	src = (const uint8 *)bp->sprite + offset;
@@ -110,9 +110,9 @@
 	uint index = 0;
 
 	/* Make memory for all zoom-levels */
-	memory += (int)ZOOM_LVL_END * sizeof(uint16);
-	for (int i = 0; i < (int)ZOOM_LVL_END; i++) {
-		memory += UnScaleByZoom(sprite->height, (ZoomLevel)i) * UnScaleByZoom(sprite->width, (ZoomLevel)i);
+	memory += (int)(ZOOM_LVL_END - ZOOM_LVL_BEGIN) * sizeof(uint16);
+	for (ZoomLevel i = ZOOM_LVL_BEGIN; i < ZOOM_LVL_END; i++) {
+		memory += UnScaleByZoom(sprite->height, i) * UnScaleByZoom(sprite->width, i);
 		index += 2;
 	}
 
@@ -121,7 +121,7 @@
 	temp_dst = MallocT<byte>(memory);
 
 	/* Make the sprites per zoom-level */
-	for (int i = 0; i < (int)ZOOM_LVL_END; i++) {
+	for (ZoomLevel i = ZOOM_LVL_BEGIN; i < ZOOM_LVL_END; i++) {
 		/* Store the scaled image */
 		const SpriteLoader::CommonPixel *src;
 
@@ -131,19 +131,19 @@
 
 		byte *dst = &temp_dst[index];
 
-		for (int y = 0; y < UnScaleByZoom(sprite->height, (ZoomLevel)i); y++) {
+		for (int y = 0; y < UnScaleByZoom(sprite->height, i); y++) {
 			uint trans = 0;
 			uint pixels = 0;
 			uint last_color = 0;
 			uint count_index = 0;
 			uint rx = 0;
-			src = &sprite->data[ScaleByZoom(y, (ZoomLevel)i) * sprite->width];
+			src = &sprite->data[ScaleByZoom(y, i) * sprite->width];
 
-			for (int x = 0; x < UnScaleByZoom(sprite->width, (ZoomLevel)i); x++) {
+			for (int x = 0; x < UnScaleByZoom(sprite->width, i); x++) {
 				uint color = 0;
 
 				/* Get the color keeping in mind the zoom-level */
-				for (int j = 0; j < ScaleByZoom(1, (ZoomLevel)i); j++) {
+				for (int j = 0; j < ScaleByZoom(1, i); j++) {
 					if (src->m != 0) color = src->m;
 					src++;
 					rx++;
--- a/src/blitter/8bpp_simple.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/8bpp_simple.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,8 +3,7 @@
 /** @file 8bpp_simple.cpp */
 
 #include "../stdafx.h"
-#include "../zoom.hpp"
-#include "../gfx.h"
+#include "../zoom_func.h"
 #include "8bpp_simple.hpp"
 
 static FBlitter_8bppSimple iFBlitter_8bppSimple;
--- a/src/blitter/base.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/base.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,7 @@
 
 #include "../spritecache.h"
 #include "../spriteloader/spriteloader.hpp"
+#include "../zoom_type.h"
 
 enum BlitterMode {
 	BM_NORMAL,
--- a/src/blitter/factory.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/factory.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,8 +4,8 @@
 #define BLITTER_FACTORY_HPP
 
 #include "base.hpp"
-#include "../string.h"
 #include "../debug.h"
+#include "../string_func.h"
 #include <string>
 #include <map>
 
@@ -41,7 +41,7 @@
 		if (name == NULL) return;
 
 		this->name = strdup(name);
-#if !defined(NDEBUG)
+#if !defined(NDEBUG) || defined(WITH_ASSERT)
 		/* NDEBUG disables asserts and gives a warning: unused variable 'P' */
 		std::pair<Blitters::iterator, bool> P =
 #endif /* !NDEBUG */
--- a/src/blitter/null.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/blitter/null.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,5 +1,8 @@
+/* $Id$ */
+
+/** @file null.cpp A blitter that doesn't blit. */
+
 #include "../stdafx.h"
-#include "../variables.h"
 #include "null.hpp"
 
 static FBlitter_Null iFBlitter_Null;
--- a/src/bmp.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/bmp.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,11 +3,9 @@
 /** @file bmp.cpp */
 
 #include "stdafx.h"
-#include "openttd.h"
-#include "gfx.h"
 #include "bmp.h"
-#include "macros.h"
-#include "helpers.hpp"
+#include "core/bitmath_func.hpp"
+#include "core/alloc_func.hpp"
 
 void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
 {
@@ -354,7 +352,7 @@
 {
 	assert(info != NULL && data != NULL);
 
-	data->bitmap = (byte*)calloc(info->width * info->height, ((info->bpp == 24) ? 3 : 1) * sizeof(byte));
+	data->bitmap = CallocT<byte>(info->width * info->height * ((info->bpp == 24) ? 3 : 1));
 	if (data->bitmap == NULL) return false;
 
 	/* Load image */
--- a/src/bmp.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/bmp.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef BMP_H
 #define BMP_H
 
+#include "gfx_type.h"
+
 struct BmpInfo {
 	uint32 offset;       ///< offset of bitmap data from .bmp file begining
 	uint32 width;        ///< bitmap width
--- a/src/bridge.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/bridge.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,10 @@
 #ifndef BRIDGE_H
 #define BRIDGE_H
 
+#include "gfx_type.h"
+#include "direction_type.h"
+#include "tile_cmd.h"
+
 enum {
 	MAX_BRIDGES = 13
 };
@@ -37,4 +41,8 @@
 
 void DrawBridgeMiddle(const TileInfo *ti);
 
+bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
+uint32 GetBridgeLength(TileIndex begin, TileIndex end);
+int CalcBridgeLenCostFactor(int x);
+
 #endif /* BRIDGE_H */
--- a/src/bridge_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/bridge_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,25 +5,32 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
-#include "map.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
-#include "command.h"
-#include "sound.h"
+#include "window_gui.h"
+#include "command_func.h"
+#include "economy_func.h"
 #include "variables.h"
 #include "bridge.h"
+#include "strings_func.h"
+#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;
 	uint count;
 	TileIndex start_tile;
 	TileIndex end_tile;
-	byte type;
-	byte indexes[MAX_BRIDGES];
+	uint8 type;
+	uint8 indexes[MAX_BRIDGES];
 	Money costs[MAX_BRIDGES];
+
+	BridgeData()
+		: last_size(4)
+		, count(0)
+		{};
 } _bridgedata;
 
 void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
@@ -39,26 +46,52 @@
 		CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
 }
 
+/* Names of the build bridge selection window */
+enum BuildBridgeSelectionWidgets {
+	BBSW_CLOSEBOX = 0,
+	BBSW_CAPTION,
+	BBSW_BRIDGE_LIST,
+	BBSW_SCROLLBAR,
+	BBSW_RESIZEBOX
+};
+
 static void BuildBridgeWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-		case WE_PAINT:
+		case WE_CREATE:
+			w->resize.step_height = 22;
+			w->vscroll.count = _bridgedata.count;
+
+			if (_bridgedata.last_size <= 4) {
+				w->vscroll.cap = 4;
+			} else {
+				/* Resize the bridge selection window if we used a bigger one the last time */
+				w->vscroll.cap = (w->vscroll.count > _bridgedata.last_size) ? _bridgedata.last_size : w->vscroll.count;
+				ResizeWindow(w, 0, (w->vscroll.cap - 4) * w->resize.step_height);
+				w->widget[BBSW_BRIDGE_LIST].data = (w->vscroll.cap << 8) + 1;
+			}
+			break;
+
+		case WE_PAINT: {
 			DrawWindowWidgets(w);
 
-			for (uint i = 0; i < 4 && i + w->vscroll.pos < _bridgedata.count; i++) {
+			uint y = 15;
+			for (uint i = 0; (i < w->vscroll.cap) && ((i + w->vscroll.pos) < _bridgedata.count); i++) {
 				const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]];
 
 				SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]);
 				SetDParam(1, b->speed * 10 / 16);
 				SetDParam(0, b->material);
-				DrawSprite(b->sprite, b->pal, 3, 15 + i * 22);
 
-				DrawString(44, 15 + i * 22 , STR_500D, TC_FROMSTRING);
+				DrawSprite(b->sprite, b->pal, 3, y);
+				DrawString(44, y, STR_500D, TC_FROMSTRING);
+				y += w->resize.step_height;
 			}
 			break;
+		}
 
 		case WE_KEYPRESS: {
-			uint i = e->we.keypress.keycode - '1';
+			const uint8 i = e->we.keypress.keycode - '1';
 			if (i < 9 && i < _bridgedata.count) {
 				e->we.keypress.cont = false;
 				BuildBridge(w, i);
@@ -68,44 +101,61 @@
 		}
 
 		case WE_CLICK:
-			if (e->we.click.widget == 2) {
-				uint ind = ((int)e->we.click.pt.y - 14) / 22;
-				if (ind < 4 && (ind += w->vscroll.pos) < _bridgedata.count)
-					BuildBridge(w, ind);
+			if (e->we.click.widget == BBSW_BRIDGE_LIST) {
+				uint ind = ((int)e->we.click.pt.y - 14) / w->resize.step_height;
+				if (ind < w->vscroll.cap) {
+					ind += w->vscroll.pos;
+					if (ind < _bridgedata.count) {
+						BuildBridge(w, ind);
+					}
+				}
 			}
 			break;
+
+		case WE_RESIZE:
+			w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
+			w->widget[BBSW_BRIDGE_LIST].data = (w->vscroll.cap << 8) + 1;
+			SetVScrollCount(w, _bridgedata.count);
+
+			_bridgedata.last_size = w->vscroll.cap;
+			break;
 	}
 }
 
+/* Widget definition for the rail bridge selection window */
 static const Widget _build_bridge_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   199,     0,    13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{     WWT_MATRIX,   RESIZE_NONE,     7,     0,   187,    14,   101, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},
-{  WWT_SCROLLBAR,   RESIZE_NONE,     7,   188,   199,    14,   101, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{   WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW},            // BBSW_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_NONE,  7,  11, 199,   0,  13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},  // BBSW_CAPTION
+{     WWT_MATRIX, RESIZE_BOTTOM,  7,   0, 187,  14, 101, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},  // BBSW_BRIDGE_LIST
+{  WWT_SCROLLBAR, RESIZE_BOTTOM,  7, 188, 199,  14,  89, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BBSW_SCROLLBAR
+{  WWT_RESIZEBOX,     RESIZE_TB,  7, 188, 199,  90, 101, 0x0,                         STR_RESIZE_BUTTON},                // BBSW_RESIZEBOX
 {   WIDGETS_END},
 };
 
+/* Window definition for the rail bridge selection window */
 static const WindowDesc _build_bridge_desc = {
 	WDP_AUTO, WDP_AUTO, 200, 102, 200, 102,
 	WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
 	_build_bridge_widgets,
 	BuildBridgeWndProc
 };
 
-
+/* Widget definition for the road bridge selection window */
 static const Widget _build_road_bridge_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   199,     0,    13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{     WWT_MATRIX,   RESIZE_NONE,     7,     0,   187,    14,   101, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},
-{  WWT_SCROLLBAR,   RESIZE_NONE,     7,   188,   199,    14,   101, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{   WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW},            // BBSW_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_NONE,  7,  11, 199,   0,  13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},  // BBSW_CAPTION
+{     WWT_MATRIX, RESIZE_BOTTOM,  7,   0, 187,  14, 101, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},  // BBSW_BRIDGE_LIST
+{  WWT_SCROLLBAR, RESIZE_BOTTOM,  7, 188, 199,  14,  89, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BBSW_SCROLLBAR
+{  WWT_RESIZEBOX,     RESIZE_TB,  7, 188, 199,  90, 101, 0x0,                         STR_RESIZE_BUTTON},                // BBSW_RESIZEBOX
 {   WIDGETS_END},
 };
 
+/* Window definition for the road bridge selection window */
 static const WindowDesc _build_road_bridge_desc = {
 	WDP_AUTO, WDP_AUTO, 200, 102, 200, 102,
 	WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
 	_build_road_bridge_widgets,
 	BuildBridgeWndProc
 };
@@ -113,52 +163,46 @@
 
 void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
 {
-	uint j = 0;
-	CommandCost ret;
-	StringID errmsg;
-
 	DeleteWindowById(WC_BUILD_BRIDGE, 0);
 
 	_bridgedata.type = bridge_type;
 	_bridgedata.start_tile = start;
 	_bridgedata.end_tile = end;
 
-	errmsg = INVALID_STRING_ID;
+	/* only query bridge building possibility once, result is the same for all bridges!
+	 * returns CMD_ERROR on failure, and price on success */
+	StringID errmsg = INVALID_STRING_ID;
+	CommandCost ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
 
-	// only query bridge building possibility once, result is the same for all bridges!
-	// returns CMD_ERROR on failure, and price on success
-	ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
-
+	uint8 j = 0;
 	if (CmdFailed(ret)) {
 		errmsg = _error_message;
 	} else {
-		// check which bridges can be built
-		// get absolute bridge length
-		// length of the middle parts of the bridge
-		int bridge_len = GetBridgeLength(start, end);
-		// total length of bridge
-		int tot_bridgedata_len = bridge_len + 2;
+		/* check which bridges can be built
+		 * get absolute bridge length
+		 * length of the middle parts of the bridge */
+		const uint bridge_len = GetBridgeLength(start, end);
+		/* total length of bridge */
+		const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2);
 
-		tot_bridgedata_len = CalcBridgeLenCostFactor(tot_bridgedata_len);
-
-		for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { // loop for all bridgetypes
+		/* loop for all bridgetypes */
+		for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) {
 			if (CheckBridge_Stuff(bridge_type, bridge_len)) {
+				/* bridge is accepted, add to list */
 				const Bridge *b = &_bridge[bridge_type];
-				// bridge is accepted, add to list
-				// add to terraforming & bulldozing costs the cost of the bridge itself (not computed with DC_QUERY_COST)
+				/* Add to terraforming & bulldozing costs the cost of the
+				 * bridge itself (not computed with DC_QUERY_COST) */
 				_bridgedata.costs[j] = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8);
 				_bridgedata.indexes[j] = bridge_type;
 				j++;
 			}
 		}
+
+		_bridgedata.count = j;
 	}
 
-	_bridgedata.count = j;
-
 	if (j != 0) {
-		Window *w = AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
-		w->vscroll.cap = 4;
-		w->vscroll.count = (byte)j;
+		AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
 	} else {
 		ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
 	}
--- a/src/bridge_map.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/bridge_map.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,7 @@
 #include "bridge.h"
 #include "variables.h"
 #include "landscape.h"
+#include "tunnelbridge_map.h"
 
 
 TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
@@ -17,7 +18,7 @@
 	dir = ReverseDiagDir(dir);
 	do {
 		tile += delta;
-	} while (!IsBridgeTile(tile) || GetBridgeRampDirection(tile) != dir);
+	} while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(tile) != dir);
 
 	return tile;
 }
@@ -38,14 +39,14 @@
 TileIndex GetOtherBridgeEnd(TileIndex tile)
 {
 	assert(IsBridgeTile(tile));
-	return GetBridgeEnd(tile, GetBridgeRampDirection(tile));
+	return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
 }
 
 uint GetBridgeHeight(TileIndex t)
 {
 	uint h;
 	Slope tileh = GetTileSlope(t, &h);
-	Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t)));
+	Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
 
 	/* one height level extra for the ramp */
 	return h + TILE_HEIGHT + ApplyFoundationToSlope(f, &tileh);
--- a/src/bridge_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/bridge_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,12 +5,9 @@
 #ifndef BRIDGE_MAP_H
 #define BRIDGE_MAP_H
 
-#include "direction.h"
-#include "macros.h"
-#include "map.h"
-#include "rail.h"
+#include "direction_func.h"
+#include "rail_type.h"
 #include "road_map.h"
-#include "tile.h"
 
 
 /**
@@ -64,7 +61,6 @@
 	return GB(_m[t].m6, 6, 2) != 0;
 }
 
-
 /**
  * Determines the type of bridge on a tile
  * @param t The tile to analyze
@@ -77,20 +73,6 @@
 	return GB(_m[t].m2, 4, 4);
 }
 
-
-/**
- * Get the direction pointing onto the bridge
- * @param t The tile to analyze
- * @pre IsBridgeTile(t)
- * @return the above mentionned direction
- */
-static inline DiagDirection GetBridgeRampDirection(TileIndex t)
-{
-	assert(IsBridgeTile(t));
-	return (DiagDirection)GB(_m[t].m5, 0, 2);
-}
-
-
 /**
  * Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
  * @param t The tile to analyze
@@ -103,45 +85,6 @@
 	return (Axis)(GB(_m[t].m6, 6, 2) - 1);
 }
 
-
-/**
- * Get the transport type of the bridge's ramp.
- * @param t The ramp tile to analyze
- * @pre IsBridgeTile(t)
- * @return the transport type of the bridge
- */
-static inline TransportType GetBridgeTransportType(TileIndex t)
-{
-	assert(IsBridgeTile(t));
-	return (TransportType)GB(_m[t].m5, 2, 2);
-}
-
-
-/**
- * Does the bridge ramp lie in a snow or desert area?
- * @param t The ramp tile to analyze
- * @pre IsBridgeTile(t)
- * @return true if and only if in a snow or desert area
- */
-static inline bool HasBridgeSnowOrDesert(TileIndex t)
-{
-	assert(IsBridgeTile(t));
-	return HasBit(_m[t].m4, 7);
-}
-
-
-/**
- * Sets whether the bridge ramp lies in a snow or desert area.
- * @param t              The ramp tile to set (un)make a snow/desert area
- * @param snow_or_desert Make (true) or unmake the tile a snow/desert area
- * @pre IsBridgeTile(t)
- */
-static inline void SetBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
-{
-	assert(IsBridgeTile(t));
-	SB(_m[t].m4, 7, 1, snow_or_desert);
-}
-
 /**
  * Finds the end of a bridge in the specified direction starting at a middle tile
  * @param t the bridge tile to find the bridge ramp for
@@ -187,7 +130,6 @@
 	ClrBit(_m[t].m6, 6 + a);
 }
 
-
 /**
  * Removes bridges from the given, that is bridges along the X and Y axis.
  * @param t the tile to remove the bridge from
--- a/src/build_vehicle_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/build_vehicle_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -9,28 +9,45 @@
 #include "ship.h"
 #include "aircraft.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "window.h"
 #include "gui.h"
-#include "vehicle.h"
 #include "articulated_vehicles.h"
-#include "gfx.h"
+#include "textbuf_gui.h"
 #include "station.h"
-#include "command.h"
+#include "command_func.h"
 #include "engine.h"
 #include "player.h"
 #include "depot.h"
 #include "airport.h"
 #include "vehicle_gui.h"
 #include "newgrf_engine.h"
-#include "date.h"
-#include "strings.h"
 #include "cargotype.h"
 #include "group.h"
 #include "road_map.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "settings_type.h"
+#include "gfx_func.h"
 
+struct buildvehicle_d {
+	VehicleType vehicle_type;
+	union {
+		RailTypeByte railtype;
+		AirportFTAClass::Flags flags;
+		RoadTypes roadtypes;
+	} filter;
+	byte sel_index;  ///< deprecated value, used for 'unified' ship and road
+	bool descending_sort_order;
+	byte sort_criteria;
+	bool regenerate_list;
+	EngineID sel_engine;
+	EngineID rename_engine;
+	EngineList eng_list;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d));
 
 enum BuildVehicleWidgets {
 	BUILD_VEHICLE_WIDGET_CLOSEBOX = 0,
@@ -269,6 +286,38 @@
 	return _internal_sort_order ? -r : r;
 }
 
+/* Road vehicle sorting functions */
+static int CDECL RoadVehEngineCostSorter(const void *a, const void *b)
+{
+	int va = RoadVehInfo(*(const EngineID*)a)->base_cost;
+	int vb = RoadVehInfo(*(const EngineID*)b)->base_cost;
+	int r = va - vb;
+
+	return _internal_sort_order ? -r : r;
+}
+
+static int CDECL RoadVehEngineSpeedSorter(const void *a, const void *b)
+{
+	int va = RoadVehInfo(*(const EngineID*)a)->max_speed;
+	int vb = RoadVehInfo(*(const EngineID*)b)->max_speed;
+	int r = va - vb;
+
+	return _internal_sort_order ? -r : r;
+}
+
+static int CDECL RoadVehEngineRunningCostSorter(const void *a, const void *b)
+{
+	const int va = RoadVehInfo(*(const EngineID*)a)->running_cost;
+	const int vb = RoadVehInfo(*(const EngineID*)b)->running_cost;
+	const int r = va - vb;
+
+	if (r == 0) {
+		/* Use EngineID to sort instead since we want consistent sorting */
+		return EngineNumberSorter(a, b);
+	}
+	return _internal_sort_order ? -r : r;
+}
+
 static int CDECL RoadVehEngineCapacitySorter(const void *a, const void *b)
 {
 	int va = RoadVehInfo(*(const EngineID*)a)->capacity;
@@ -282,6 +331,38 @@
 	return _internal_sort_order ? -r : r;
 }
 
+/* Road vehicle sorting functions */
+static int CDECL ShipEngineCostSorter(const void *a, const void *b)
+{
+	int va = ShipVehInfo(*(const EngineID*)a)->base_cost;
+	int vb = ShipVehInfo(*(const EngineID*)b)->base_cost;
+	int r = va - vb;
+
+	return _internal_sort_order ? -r : r;
+}
+
+static int CDECL ShipEngineSpeedSorter(const void *a, const void *b)
+{
+	int va = ShipVehInfo(*(const EngineID*)a)->max_speed;
+	int vb = ShipVehInfo(*(const EngineID*)b)->max_speed;
+	int r = va - vb;
+
+	return _internal_sort_order ? -r : r;
+}
+
+static int CDECL ShipEngineRunningCostSorter(const void *a, const void *b)
+{
+	const int va = ShipVehInfo(*(const EngineID*)a)->running_cost;
+	const int vb = ShipVehInfo(*(const EngineID*)b)->running_cost;
+	const int r = va - vb;
+
+	if (r == 0) {
+		/* Use EngineID to sort instead since we want consistent sorting */
+		return EngineNumberSorter(a, b);
+	}
+	return _internal_sort_order ? -r : r;
+}
+
 static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
 {
 	int va = ShipVehInfo(*(const EngineID*)a)->capacity;
@@ -367,15 +448,21 @@
 }, {
 	/* Road vehicles */
 	&EngineNumberSorter,
+	&RoadVehEngineCostSorter,
+	&RoadVehEngineSpeedSorter,
 	&EngineIntroDateSorter,
 	&EngineNameSorter,
+	&RoadVehEngineRunningCostSorter,
 	&EngineReliabilitySorter,
 	&RoadVehEngineCapacitySorter,
 }, {
 	/* Ships */
 	&EngineNumberSorter,
+	&ShipEngineCostSorter,
+	&ShipEngineSpeedSorter,
 	&EngineIntroDateSorter,
 	&EngineNameSorter,
+	&ShipEngineRunningCostSorter,
 	&EngineReliabilitySorter,
 	&ShipEngineCapacitySorter,
 }, {
@@ -406,16 +493,22 @@
 }, {
 	/* Road vehicles */
 	STR_ENGINE_SORT_ENGINE_ID,
+	STR_ENGINE_SORT_COST,
+	STR_SORT_BY_MAX_SPEED,
 	STR_ENGINE_SORT_INTRO_DATE,
 	STR_SORT_BY_DROPDOWN_NAME,
+	STR_ENGINE_SORT_RUNNING_COST,
 	STR_SORT_BY_RELIABILITY,
 	STR_ENGINE_SORT_CARGO_CAPACITY,
 	INVALID_STRING_ID
 }, {
 	/* Ships */
 	STR_ENGINE_SORT_ENGINE_ID,
+	STR_ENGINE_SORT_COST,
+	STR_SORT_BY_MAX_SPEED,
 	STR_ENGINE_SORT_INTRO_DATE,
 	STR_SORT_BY_DROPDOWN_NAME,
+	STR_ENGINE_SORT_RUNNING_COST,
 	STR_SORT_BY_RELIABILITY,
 	STR_ENGINE_SORT_CARGO_CAPACITY,
 	INVALID_STRING_ID
@@ -667,7 +760,7 @@
 /* Figure out what train EngineIDs to put in the list */
 static void GenerateBuildTrainList(Window *w)
 {
-	EngineID eid, sel_id;
+	EngineID sel_id = INVALID_ENGINE;
 	int num_engines = 0;
 	int num_wagons  = 0;
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
@@ -680,7 +773,7 @@
 	 * Also check to see if the previously selected engine is still available,
 	 * and if not, reset selection to INVALID_ENGINE. This could be the case
 	 * when engines become obsolete and are removed */
-	for (sel_id = INVALID_ENGINE, eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
+	for (EngineID eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
 		const RailVehicleInfo *rvi = RailVehInfo(eid);
 
 		if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) continue;
@@ -713,14 +806,12 @@
 /* Figure out what road vehicle EngineIDs to put in the list */
 static void GenerateBuildRoadVehList(Window *w)
 {
-	EngineID eid, sel_id;
+	EngineID sel_id = INVALID_ENGINE;
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
 
 	EngList_RemoveAll(&bv->eng_list);
 
-	sel_id = INVALID_ENGINE;
-
-	for (eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
+	for (EngineID eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
 		if (!IsEngineBuildable(eid, VEH_ROAD, _local_player)) continue;
 		if (!HasBit(bv->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
 		EngList_Add(&bv->eng_list, eid);
@@ -733,14 +824,12 @@
 /* Figure out what ship EngineIDs to put in the list */
 static void GenerateBuildShipList(Window *w)
 {
-	EngineID eid, sel_id;
+	EngineID sel_id = INVALID_ENGINE;
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
 
 	EngList_RemoveAll(&bv->eng_list);
 
-	sel_id = INVALID_ENGINE;
-
-	for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
+	for (EngineID eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
 		if (!IsEngineBuildable(eid, VEH_SHIP, _local_player)) continue;
 		EngList_Add(&bv->eng_list, eid);
 
@@ -752,7 +841,7 @@
 /* Figure out what aircraft EngineIDs to put in the list */
 static void GenerateBuildAircraftList(Window *w)
 {
-	EngineID eid, sel_id;
+	EngineID sel_id = INVALID_ENGINE;
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
 
 	EngList_RemoveAll(&bv->eng_list);
@@ -761,8 +850,7 @@
 	 * Also check to see if the previously selected plane is still available,
 	 * and if not, reset selection to INVALID_ENGINE. This could be the case
 	 * when planes become obsolete and are removed */
-	sel_id = INVALID_ENGINE;
-	for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
+	for (EngineID eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
 		if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
 		/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
 		if (w->window_number > VEH_END && !CanAircraftUseStation(eid, w->window_number)) continue;
@@ -888,7 +976,7 @@
 	const buildvehicle_d *bv = &WP(w, buildvehicle_d);
 	uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list));
 
-	SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END);
+	w->SetWidgetDisabledState(BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END);
 
 	SetVScrollCount(w, EngList_Count(&bv->eng_list));
 	SetDParam(0, bv->filter.railtype + STR_881C_NEW_RAIL_VEHICLES); // This should only affect rail vehicles
--- a/src/callback_table.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/callback_table.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "callback_table.h"
-#include "functions.h"
 
 /* If you add a callback for DoCommandP, also add the callback in here
  *   see below for the full list!
--- a/src/callback_table.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/callback_table.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,7 @@
 #ifndef CALLBACK_TABLE_H
 #define CALLBACK_TABLE_H
 
-#include "command.h"
+#include "command_type.h"
 
 extern CommandCallback *_callback_table[];
 extern const int _callback_table_count;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cargo_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,59 @@
+/* $Id$ */
+
+/** @file cargo_type.h Types related to cargos... */
+
+#ifndef CARGO_TYPE_H
+#define CARGO_TYPE_H
+
+typedef byte CargoID;
+
+enum {
+	// Temperate
+	CT_PASSENGERS   =  0,
+	CT_COAL         =  1,
+	CT_MAIL         =  2,
+	CT_OIL          =  3,
+	CT_LIVESTOCK    =  4,
+	CT_GOODS        =  5,
+	CT_GRAIN        =  6,
+	CT_WOOD         =  7,
+	CT_IRON_ORE     =  8,
+	CT_STEEL        =  9,
+	CT_VALUABLES    = 10,
+
+	// Arctic
+	CT_WHEAT        =  6,
+	CT_HILLY_UNUSED =  8,
+	CT_PAPER        =  9,
+	CT_GOLD         = 10,
+	CT_FOOD         = 11,
+
+	// Tropic
+	CT_RUBBER       =  1,
+	CT_FRUIT        =  4,
+	CT_MAIZE        =  6,
+	CT_COPPER_ORE   =  8,
+	CT_WATER        =  9,
+	CT_DIAMONDS     = 10,
+
+	// Toyland
+	CT_SUGAR        =  1,
+	CT_TOYS         =  3,
+	CT_BATTERIES    =  4,
+	CT_CANDY        =  5,
+	CT_TOFFEE       =  6,
+	CT_COLA         =  7,
+	CT_COTTON_CANDY =  8,
+	CT_BUBBLES      =  9,
+	CT_PLASTIC      = 10,
+	CT_FIZZY_DRINKS = 11,
+
+	NUM_CARGO       = 32,
+
+	CT_NO_REFIT     = 0xFE,
+	CT_INVALID      = 0xFF
+};
+
+typedef uint AcceptedCargo[NUM_CARGO];
+
+#endif /* OPENTTD_H */
--- a/src/cargopacket.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/cargopacket.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,7 @@
 #ifndef CARGOPACKET_H
 #define CARGOPACKET_H
 
+#include "economy_type.h"
 #include <list>
 
 typedef uint32 CargoPacketID;
--- a/src/cargotype.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/cargotype.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,11 +4,11 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "macros.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "newgrf_cargo.h"
 #include "cargotype.h"
+#include "core/bitmath_func.hpp"
 
 #include "table/cargo_const.h"
 
@@ -37,7 +37,7 @@
 		if (cl < lengthof(_default_cargo)) {
 			/* Copy the indexed cargo */
 			_cargo[i] = _default_cargo[cl];
-			SetBit(_cargo_mask, i);
+			if (_cargo[i].bitnum != INVALID_CARGO) SetBit(_cargo_mask, i);
 			continue;
 		}
 
--- a/src/cargotype.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/cargotype.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef CARGOTYPE_H
 #define CARGOTYPE_H
 
+#include "cargo_type.h"
+#include "gfx_type.h"
 
 typedef uint32 CargoLabel;
 
--- a/src/clear_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/clear_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,16 +5,9 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "clear_map.h"
-#include "rail_map.h"
 #include "table/strings.h"
-#include "functions.h"
-#include "map.h"
 #include "player.h"
-#include "tile.h"
-#include "viewport.h"
-#include "command.h"
-#include "tunnel_map.h"
-#include "bridge_map.h"
+#include "command_func.h"
 #include "bridge.h"
 #include "landscape.h"
 #include "variables.h"
@@ -23,437 +16,23 @@
 #include "genworld.h"
 #include "industry.h"
 #include "water_map.h"
-
-/*
- * In one terraforming command all four corners of a initial tile can be raised/lowered (though this is not available to the player).
- * The maximal amount of height modifications is archieved when raising a complete flat land from sea level to MAX_TILE_HEIGHT or vice versa.
- * This affects all corners with a manhatten distance smaller than MAX_TILE_HEIGHT to one of the initial 4 corners.
- * Their maximal amount is computed to 4 * \sum_{i=1}^{h_max} i  =  2 * h_max * (h_max + 1).
- */
-static const int TERRAFORMER_MODHEIGHT_SIZE = 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 1);
-
-/*
- * The maximal amount of affected tiles (i.e. the tiles that incident with one of the corners above, is computed similiar to
- * 1 + 4 * \sum_{i=1}^{h_max} (i+1)  =  1 + 2 * h_max + (h_max + 3).
- */
-static const int TERRAFORMER_TILE_TABLE_SIZE = 1 + 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 3);
-
-struct TerraformerHeightMod {
-	TileIndex tile;   ///< Referenced tile.
-	byte height;      ///< New TileHeight (height of north corner) of the tile.
-};
-
-struct TerraformerState {
-	int modheight_count;                                         ///< amount of entries in "modheight".
-	int tile_table_count;                                        ///< amount of entries in "tile_table".
-
-	/**
-	 * Dirty tiles, i.e.\ at least one corner changed.
-	 *
-	 * This array contains the tiles which are or will be marked as dirty.
-	 *
-	 * @ingroup dirty
-	 */
-	TileIndex tile_table[TERRAFORMER_TILE_TABLE_SIZE];
-	TerraformerHeightMod modheight[TERRAFORMER_MODHEIGHT_SIZE];  ///< Height modifications.
-};
-
-/**
- * Gets the TileHeight (height of north corner) of a tile as of current terraforming progress.
- *
- * @param ts TerraformerState.
- * @param tile Tile.
- * @return TileHeight.
- */
-static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile)
-{
-	TerraformerHeightMod *mod = ts->modheight;
-	int count;
-
-	for (count = ts->modheight_count; count != 0; count--, mod++) {
-		if (mod->tile == tile) return mod->height;
-	}
-
-	/* TileHeight unchanged so far, read value from map. */
-	return TileHeight(tile);
-}
-
-/**
- * Stores the TileHeight (height of north corner) of a tile in a TerraformerState.
- *
- * @param ts TerraformerState.
- * @param tile Tile.
- * @param height New TileHeight.
- */
-static void TerraformSetHeightOfTile(TerraformerState *ts, TileIndex tile, int height)
-{
-	/* Find tile in the "modheight" table.
-	 * Note: In a normal user-terraform command the tile will not be found in the "modheight" table.
-	 *       But during house- or industry-construction multiple corners can be terraformed at once. */
-	TerraformerHeightMod *mod = ts->modheight;
-	int count = ts->modheight_count;
-	while ((count > 0) && (mod->tile != tile)) {
-		mod++;
-		count--;
-	}
-
-	/* New entry? */
-	if (count == 0) {
-		assert(ts->modheight_count < TERRAFORMER_MODHEIGHT_SIZE);
-		ts->modheight_count++;
-	}
-
-	/* Finally store the new value */
-	mod->tile = tile;
-	mod->height = (byte)height;
-}
-
-/**
- * Adds a tile to the "tile_table" in a TerraformerState.
- *
- * @param ts TerraformerState.
- * @param tile Tile.
- * @ingroup dirty
- */
-static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
-{
-	int count;
-	TileIndex *t;
-
-	count = ts->tile_table_count;
-
-	for (t = ts->tile_table; count != 0; count--, t++) {
-		if (*t == tile) return;
-	}
-
-	assert(ts->tile_table_count < TERRAFORMER_TILE_TABLE_SIZE);
-
-	ts->tile_table[ts->tile_table_count++] = tile;
-}
-
-/**
- * Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState.
- *
- * @param ts TerraformerState.
- * @param tile Tile.
- * @ingroup dirty
- */
-static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile)
-{
-	TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1));
-	TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1));
-	TerraformAddDirtyTile(ts, tile + TileDiffXY(-1,  0));
-	TerraformAddDirtyTile(ts, tile);
-}
-
-/**
- * Terraform the north corner of a tile to a specific height.
- *
- * @param ts TerraformerState.
- * @param tile Tile.
- * @param height Aimed height.
- * @param return Error code or cost.
- */
-static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
-{
-	CommandCost total_cost = CommandCost();
-
-	assert(tile < MapSize());
-
-	/* Check range of destination height */
-	if (height < 0) return_cmd_error(STR_1003_ALREADY_AT_SEA_LEVEL);
-	if (height > MAX_TILE_HEIGHT) return_cmd_error(STR_1004_TOO_HIGH);
-
-	/*
-	 * Check if the terraforming has any effect.
-	 * This can only be true, if multiple corners of the start-tile are terraformed (i.e. the terraforming is done by towns/industries etc.).
-	 * In this case the terraforming should fail. (Don't know why.)
-	 */
-	if (height == TerraformGetHeightOfTile(ts, tile)) return CMD_ERROR;
-
-	/* Check "too close to edge of map" */
-	uint x = TileX(tile);
-	uint y = TileY(tile);
-	if ((x <= 1) || (y <= 1) || (x >= MapMaxX() - 1) || (y >= MapMaxY() - 1)) {
-		/*
-		 * Determine a sensible error tile
-		 * Note: If x and y are both zero this will disable the error tile. (Tile 0 cannot be highlighted :( )
-		 */
-		if ((x == 1) && (y != 0)) x = 0;
-		if ((y == 1) && (x != 0)) y = 0;
-		_terraform_err_tile = TileXY(x, y);
-		return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
-	}
-
-	/* Mark incident tiles, that are involved in the terraforming */
-	TerraformAddDirtyTileAround(ts, tile);
-
-	/* Store the height modification */
-	TerraformSetHeightOfTile(ts, tile, height);
-
-	/* Increment cost */
-	total_cost.AddCost(_price.terraform);
-
-	/* Recurse to neighboured corners if height difference is larger than 1 */
-	{
-		const TileIndexDiffC *ttm;
-
-		static const TileIndexDiffC _terraform_tilepos[] = {
-			{ 1,  0}, // move to tile in SE
-			{-2,  0}, // undo last move, and move to tile in NW
-			{ 1,  1}, // undo last move, and move to tile in SW
-			{ 0, -2}  // undo last move, and move to tile in NE
-		};
-
-		for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
-			tile += ToTileIndexDiff(*ttm);
-
-			/* Get TileHeight of neighboured tile as of current terraform progress */
-			int r = TerraformGetHeightOfTile(ts, tile);
-			int height_diff = height - r;
-
-			/* Is the height difference to the neighboured corner greater than 1? */
-			if (abs(height_diff) > 1) {
-				/* Terraform the neighboured corner. The resulting height difference should be 1. */
-				height_diff += (height_diff < 0 ? 1 : -1);
-				CommandCost cost = TerraformTileHeight(ts, tile, r + height_diff);
-				if (CmdFailed(cost)) return cost;
-				total_cost.AddCost(cost);
-			}
-		}
-	}
-
-	return total_cost;
-}
-
-/** Terraform land
- * @param tile tile to terraform
- * @param flags for this command type
- * @param p1 corners to terraform (SLOPE_xxx)
- * @param p2 direction; eg up (non-zero) or down (zero)
- * @return error or cost of terraforming
- */
-CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
-{
-	TerraformerState ts;
-	CommandCost total_cost = CommandCost();
-	int direction = (p2 != 0 ? 1 : -1);
-
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
-	_terraform_err_tile = 0;
-
-	ts.modheight_count = ts.tile_table_count = 0;
-
-	/* Make an extra check for map-bounds cause we add tiles to the originating tile */
-	if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;
-
-	/* Compute the costs and the terraforming result in a model of the landscape */
-	if ((p1 & SLOPE_W) != 0) {
-		TileIndex t = tile + TileDiffXY(1, 0);
-		CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
-		if (CmdFailed(cost)) return cost;
-		total_cost.AddCost(cost);
-	}
-
-	if ((p1 & SLOPE_S) != 0) {
-		TileIndex t = tile + TileDiffXY(1, 1);
-		CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
-		if (CmdFailed(cost)) return cost;
-		total_cost.AddCost(cost);
-	}
-
-	if ((p1 & SLOPE_E) != 0) {
-		TileIndex t = tile + TileDiffXY(0, 1);
-		CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
-		if (CmdFailed(cost)) return cost;
-		total_cost.AddCost(cost);
-	}
-
-	if ((p1 & SLOPE_N) != 0) {
-		TileIndex t = tile + TileDiffXY(0, 0);
-		CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
-		if (CmdFailed(cost)) return cost;
-		total_cost.AddCost(cost);
-	}
-
-	/* Check if the terraforming is valid wrt. tunnels, bridges and objects on the surface */
-	{
-		int count;
-		TileIndex *ti = ts.tile_table;
-
-		for (count = ts.tile_table_count; count != 0; count--, ti++) {
-			TileIndex tile = *ti;
-
-			/* Find new heights of tile corners */
-			uint z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
-			uint z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
-			uint z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
-			uint z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
-
-			/* Find min and max height of tile */
-			uint z_min = min(min(z_N, z_W), min(z_S, z_E));
-			uint z_max = max(max(z_N, z_W), max(z_S, z_E));
-
-			/* Compute tile slope */
-			uint tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT);
-			if (z_W > z_min) tileh += SLOPE_W;
-			if (z_S > z_min) tileh += SLOPE_S;
-			if (z_E > z_min) tileh += SLOPE_E;
-			if (z_N > z_min) tileh += SLOPE_N;
-
-			/* Check if bridge would take damage */
-			if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) &&
-					GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max * TILE_HEIGHT) {
-				_terraform_err_tile = tile; // highlight the tile under the bridge
-				return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
-			}
-			/* Check if tunnel would take damage */
-			if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) {
-				_terraform_err_tile = tile; // highlight the tile above the tunnel
-				return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
-			}
-			/* Check tiletype-specific things, and add extra-cost */
-			CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, (Slope) tileh);
-			if (CmdFailed(cost)) {
-				_terraform_err_tile = tile;
-				return cost;
-			}
-			total_cost.AddCost(cost);
-		}
-	}
-
-	if (flags & DC_EXEC) {
-		/* change the height */
-		{
-			int count;
-			TerraformerHeightMod *mod;
-
-			mod = ts.modheight;
-			for (count = ts.modheight_count; count != 0; count--, mod++) {
-				TileIndex til = mod->tile;
-
-				SetTileHeight(til, mod->height);
-			}
-		}
-
-		/* finally mark the dirty tiles dirty */
-		{
-			int count;
-			TileIndex *ti = ts.tile_table;
-			for (count = ts.tile_table_count; count != 0; count--, ti++) {
-				MarkTileDirtyByTile(*ti);
-			}
-		}
-	}
-	return total_cost;
-}
-
-
-/** Levels a selected (rectangle) area of land
- * @param tile end tile of area-drag
- * @param flags for this command type
- * @param p1 start tile of area drag
- * @param p2 unused
- * @return  error or cost of terraforming
- */
-CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
-{
-	int size_x, size_y;
-	int ex;
-	int ey;
-	int sx, sy;
-	uint h, curh;
-	CommandCost money;
-	CommandCost ret;
-	CommandCost cost;
-
-	if (p1 >= MapSize()) return CMD_ERROR;
-
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
-	/* remember level height */
-	h = TileHeight(p1);
-
-	/* make sure sx,sy are smaller than ex,ey */
-	ex = TileX(tile);
-	ey = TileY(tile);
-	sx = TileX(p1);
-	sy = TileY(p1);
-	if (ex < sx) Swap(ex, sx);
-	if (ey < sy) Swap(ey, sy);
-	tile = TileXY(sx, sy);
-
-	size_x = ex - sx + 1;
-	size_y = ey - sy + 1;
-
-	money.AddCost(GetAvailableMoneyForCommand());
-
-	BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
-		curh = TileHeight(tile2);
-		while (curh != h) {
-			ret = DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
-			if (CmdFailed(ret)) break;
-
-			if (flags & DC_EXEC) {
-				money.AddCost(-ret.GetCost());
-				if (money.GetCost() < 0) {
-					_additional_cash_required = ret.GetCost();
-					return cost;
-				}
-				DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
-			}
-
-			cost.AddCost(ret);
-			curh += (curh > h) ? -1 : 1;
-		}
-	} END_TILE_LOOP(tile2, size_x, size_y, tile)
-
-	return (cost.GetCost() == 0) ? CMD_ERROR : cost;
-}
-
-/** Purchase a land area. Actually you only purchase one tile, so
- * the name is a bit confusing ;p
- * @param tile the tile the player is purchasing
- * @param flags for this command type
- * @param p1 unused
- * @param p2 unused
- * @return error of cost of operation
- */
-CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
-{
-	CommandCost cost;
-
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
-	if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) {
-		return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
-	}
-
-	cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
-	if (CmdFailed(cost)) return CMD_ERROR;
-
-	if (flags & DC_EXEC) {
-		MakeOwnedLand(tile, _current_player);
-		MarkTileDirtyByTile(tile);
-	}
-
-	return cost.AddCost(_price.purchase_land * 10);
-}
-
+#include "tile_cmd.h"
+#include "functions.h"
+#include "economy_func.h"
+#include "table/clear_land.h"
+#include "viewport_func.h"
 
 static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
 {
 	static const Money* clear_price_table[] = {
-		&_price.clear_1,
-		&_price.purchase_land,
-		&_price.clear_2,
-		&_price.clear_3,
-		&_price.purchase_land,
-		&_price.purchase_land,
-		&_price.clear_2, // XXX unused?
+		&_price.clear_grass,
+		&_price.clear_roughland,
+		&_price.clear_rocks,
+		&_price.clear_fields,
+		&_price.clear_roughland,
+		&_price.clear_roughland,
 	};
-	CommandCost price;
+	CommandCost price(EXPENSES_CONSTRUCTION);
 
 	if (!IsClearGround(tile, CLEAR_GRASS) || GetClearDensity(tile) != 0) {
 		price.AddCost(*clear_price_table[GetClearGround(tile)]);
@@ -464,33 +43,6 @@
 	return price;
 }
 
-/** Sell a land area. Actually you only sell one tile, so
- * the name is a bit confusing ;p
- * @param tile the tile the player is selling
- * @param flags for this command type
- * @param p1 unused
- * @param p2 unused
- * @return error or cost of operation
- */
-CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
-{
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
-	if (!IsOwnedLandTile(tile)) return CMD_ERROR;
-	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
-
-
-	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
-
-	if (flags & DC_EXEC) DoClearSquare(tile);
-
-	return CommandCost(- _price.purchase_land * 2);
-}
-
-
-#include "table/clear_land.h"
-
-
 void DrawClearLandTile(const TileInfo *ti, byte set)
 {
 	DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19, PAL_NONE);
--- a/src/clear_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/clear_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,9 +5,8 @@
 #ifndef CLEAR_MAP_H
 #define CLEAR_MAP_H
 
-#include "macros.h"
-#include "tile.h"
 #include "bridge_map.h"
+#include "industry_type.h"
 
 /**
  * Ground types. Valid densities in comments after the enum.
--- a/src/cmd_helper.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/cmd_helper.h	Wed Jan 09 18:11:12 2008 +0000
@@ -3,13 +3,12 @@
 #ifndef CMD_HELPER_H
 #define CMD_HELPER_H
 
-#include "direction.h"
-#include "macros.h"
-#include "road.h"
+#include "direction_type.h"
+#include "road_type.h"
 
 
 template<uint N> static inline void ExtractValid();
-template<> static inline void ExtractValid<1>() {}
+template<> inline void ExtractValid<1>() {}
 
 
 template<typename T> struct ExtractBits;
--- a/src/command.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/command.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,17 +5,19 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
 #include "landscape.h"
-#include "map.h"
+#include "tile_map.h"
 #include "gui.h"
-#include "command.h"
+#include "command_func.h"
 #include "player.h"
 #include "network/network.h"
 #include "variables.h"
 #include "genworld.h"
 #include "newgrf_storage.h"
+#include "strings_func.h"
+#include "gfx_func.h"
+#include "functions.h"
+#include "town.h"
 
 const char *_cmd_text = NULL;
 
@@ -387,7 +389,7 @@
 	return _command_proc_table[cmd & 0xFF].flags;
 }
 
-static int _docommand_recursive;
+static int _docommand_recursive = 0;
 
 /*!
  * This function executes a given command with the parameters from the #CommandProc parameter list.
@@ -400,7 +402,7 @@
  * @param procc The command-id to execute (a value of the CMD_* enums)
  * @see CommandProc
  */
-CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
+CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
 {
 	CommandCost res;
 	CommandProc *proc;
@@ -419,7 +421,9 @@
 
 	/* only execute the test call if it's toplevel, or we're not execing. */
 	if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
+		SetTownRatingTestMode(true);
 		res = proc(tile, flags & ~DC_EXEC, p1, p2);
+		SetTownRatingTestMode(false);
 		if (CmdFailed(res)) {
 			res.SetGlobalErrorMessage();
 			goto error;
@@ -440,7 +444,7 @@
 	}
 
 	/* Execute the command here. All cost-relevant functions set the expenses type
-	 * themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
+	 * themselves to the cost object at some point */
 	res = proc(tile, flags, p1, p2);
 	if (CmdFailed(res)) {
 		res.SetGlobalErrorMessage();
@@ -539,7 +543,7 @@
 	 *  e.g.: if you demolish a whole town, the dryrun would say okay.
 	 *  but by really destroying, your rating drops and at a certain point
 	 *  it will fail. so res and res2 are different
-	 * CMD_REMOVE_ROAD: This command has special local authority
+	 * CMD_REMOVE_LONG_ROAD: This command has special local authority
 	 * restrictions which may cause the test run to fail (the previous
 	 * road fragments still stay there and the town won't let you
 	 * disconnect the road system), but the exec will succeed and this
@@ -549,9 +553,7 @@
 	 * estimate the cost of cloning a vehicle. */
 	notest =
 		(cmd & 0xFF) == CMD_CLEAR_AREA ||
-		(cmd & 0xFF) == CMD_CONVERT_RAIL ||
 		(cmd & 0xFF) == CMD_LEVEL_LAND ||
-		(cmd & 0xFF) == CMD_REMOVE_ROAD ||
 		(cmd & 0xFF) == CMD_REMOVE_LONG_ROAD ||
 		(cmd & 0xFF) == CMD_CLONE_VEHICLE;
 
@@ -581,7 +583,9 @@
 
 	if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
 		/* first test if the command can be executed. */
+		SetTownRatingTestMode(true);
 		res = proc(tile, flags, p1, p2);
+		SetTownRatingTestMode(false);
 		if (CmdFailed(res)) {
 			res.SetGlobalErrorMessage();
 			goto show_error;
@@ -609,6 +613,11 @@
 		return true;
 	}
 #endif /* ENABLE_NETWORK */
+#ifdef DEBUG_DUMP_COMMANDS
+	extern Date      _date;
+	extern DateFract _date_fract;
+	debug_dump_commands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text);
+#endif /* DUMP_COMMANDS */
 
 	/* update last build coordinate of player. */
 	if (tile != 0 && IsValidPlayer(_current_player)) {
@@ -617,7 +626,6 @@
 
 	/* Actually try and execute the command. If no cost-type is given
 	 * use the construction one */
-	_yearly_expenses_type = EXPENSES_CONSTRUCTION;
 	res2 = proc(tile, flags | DC_EXEC, p1, p2);
 
 	/* If notest is on, it means the result of the test can be different than
@@ -692,6 +700,11 @@
 	return this->cost;
 }
 
+ExpensesType CommandCost::GetExpensesType() const
+{
+	return this->expense_type;
+}
+
 void CommandCost::SetGlobalErrorMessage() const
 {
 	extern StringID _error_message;
--- a/src/command.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +0,0 @@
-/* $Id$ */
-
-/** @file command.h */
-
-#ifndef COMMAND_H
-#define COMMAND_H
-
-/**
- * List of commands.
- *
- * This enum defines all possible commands which can be executed to the game
- * engine. Observing the game like the query-tool or checking the profit of a
- * vehicle don't result in a command which should be executed in the engine
- * nor send to the server in a network game.
- *
- * @see _command_proc_table
- */
-enum {
-	CMD_BUILD_RAILROAD_TRACK         =   0, ///< build a rail track
-	CMD_REMOVE_RAILROAD_TRACK        =   1, ///< remove a rail track
-	CMD_BUILD_SINGLE_RAIL            =   2, ///< build a single rail track
-	CMD_REMOVE_SINGLE_RAIL           =   3, ///< remove a single rail track
-	CMD_LANDSCAPE_CLEAR              =   4, ///< demolish a tile
-	CMD_BUILD_BRIDGE                 =   5, ///< build a bridge
-	CMD_BUILD_RAILROAD_STATION       =   6, ///< build a railroad station
-	CMD_BUILD_TRAIN_DEPOT            =   7, ///< build a train depot
-	CMD_BUILD_SIGNALS                =   8, ///< build a signal
-	CMD_REMOVE_SIGNALS               =   9, ///< remove a signal
-	CMD_TERRAFORM_LAND               =  10, ///< terraform a tile
-	CMD_PURCHASE_LAND_AREA           =  11, ///< purchase a tile
-	CMD_SELL_LAND_AREA               =  12, ///< sell a bought tile before
-	CMD_BUILD_TUNNEL                 =  13, ///< build a tunnel
-
-	CMD_REMOVE_FROM_RAILROAD_STATION =  14, ///< remove a tile station
-	CMD_CONVERT_RAIL                 =  15, ///< convert a rail type
-
-	CMD_BUILD_TRAIN_WAYPOINT         =  16, ///< build a waypoint
-	CMD_RENAME_WAYPOINT              =  17, ///< rename a waypoint
-	CMD_REMOVE_TRAIN_WAYPOINT        =  18, ///< remove a waypoint
-
-	CMD_BUILD_ROAD_STOP              =  21, ///< build a road stop
-	CMD_REMOVE_ROAD_STOP             =  22, ///< remove a road stop
-	CMD_BUILD_LONG_ROAD              =  23, ///< build a complete road (not a "half" one)
-	CMD_REMOVE_LONG_ROAD             =  24, ///< remove a complete road (not a "half" one)
-	CMD_BUILD_ROAD                   =  25, ///< build a "half" road
-	CMD_REMOVE_ROAD                  =  26, ///< remove a "half" road
-	CMD_BUILD_ROAD_DEPOT             =  27, ///< build a road depot
-
-	CMD_BUILD_AIRPORT                =  29, ///< build an airport
-
-	CMD_BUILD_DOCK                   =  30, ///< build a dock
-
-	CMD_BUILD_SHIP_DEPOT             =  31, ///< build a ship depot
-	CMD_BUILD_BUOY                   =  32, ///< build a buoy
-
-	CMD_PLANT_TREE                   =  33, ///< plant a tree
-
-	CMD_BUILD_RAIL_VEHICLE           =  34, ///< build a rail vehicle
-	CMD_MOVE_RAIL_VEHICLE            =  35, ///< move a rail vehicle (in the depot)
-
-	CMD_START_STOP_TRAIN             =  36, ///< start or stop a train
-
-	CMD_SELL_RAIL_WAGON              =  38, ///< sell a rail wagon
-
-	CMD_SEND_TRAIN_TO_DEPOT          =  39, ///< send a train to a depot
-	CMD_FORCE_TRAIN_PROCEED          =  40, ///< proceed a train to pass a red signal
-	CMD_REVERSE_TRAIN_DIRECTION      =  41, ///< turn a train around
-
-	CMD_MODIFY_ORDER                 =  42, ///< modify an order (like set full-load)
-	CMD_SKIP_TO_ORDER                =  43, ///< skip an order to the next of specific one
-	CMD_DELETE_ORDER                 =  44, ///< delete an order
-	CMD_INSERT_ORDER                 =  45, ///< insert a new order
-
-	CMD_CHANGE_SERVICE_INT           =  46, ///< change the server interval of a vehicle
-
-	CMD_BUILD_INDUSTRY               =  47, ///< build a new industry
-
-	CMD_BUILD_COMPANY_HQ             =  48, ///< build the company headquarter
-	CMD_SET_PLAYER_FACE              =  49, ///< set the face of the player/company
-	CMD_SET_PLAYER_COLOR             =  50, ///< set the color of the player/company
-
-	CMD_INCREASE_LOAN                =  51, ///< increase the loan from the bank
-	CMD_DECREASE_LOAN                =  52, ///< decrease the loan from the bank
-
-	CMD_WANT_ENGINE_PREVIEW          =  53, ///< confirm the preview of an engine
-
-	CMD_NAME_VEHICLE                 =  54, ///< rename a whole vehicle
-	CMD_RENAME_ENGINE                =  55, ///< rename a engine (in the engine list)
-	CMD_CHANGE_COMPANY_NAME          =  56, ///< change the company name
-	CMD_CHANGE_PRESIDENT_NAME        =  57, ///< change the president name
-	CMD_RENAME_STATION               =  58, ///< rename a station
-
-	CMD_SELL_AIRCRAFT                =  59, ///< sell an aircraft
-	CMD_START_STOP_AIRCRAFT          =  60, ///< start/stop an aircraft
-	CMD_BUILD_AIRCRAFT               =  61, ///< build an aircraft
-	CMD_SEND_AIRCRAFT_TO_HANGAR      =  62, ///< send an aircraft to a hanger
-	CMD_REFIT_AIRCRAFT               =  64, ///< refit the cargo space of an aircraft
-
-	CMD_PLACE_SIGN                   =  65, ///< place a sign
-	CMD_RENAME_SIGN                  =  66, ///< rename a sign
-
-	CMD_BUILD_ROAD_VEH               =  67, ///< build a road vehicle
-	CMD_START_STOP_ROADVEH           =  68, ///< start/stop a road vehicle
-	CMD_SELL_ROAD_VEH                =  69, ///< sell a road vehicle
-	CMD_SEND_ROADVEH_TO_DEPOT        =  70, ///< send a road vehicle to the depot
-	CMD_TURN_ROADVEH                 =  71, ///< turn a road vehicle around
-	CMD_REFIT_ROAD_VEH               =  72, ///< refit the cargo space of a road vehicle
-
-	CMD_PAUSE                        =  73, ///< pause the game
-
-	CMD_BUY_SHARE_IN_COMPANY         =  74, ///< buy a share from a company
-	CMD_SELL_SHARE_IN_COMPANY        =  75, ///< sell a share from a company
-	CMD_BUY_COMPANY                  =  76, ///< buy a company which is bankrupt
-
-	CMD_BUILD_TOWN                   =  77, ///< build a town
-
-	CMD_RENAME_TOWN                  =  80, ///< rename a town
-	CMD_DO_TOWN_ACTION               =  81, ///< do a action from the town detail window (like advertises or bribe)
-
-	CMD_SET_ROAD_DRIVE_SIDE          =  82, ///< set the side where the road vehicles drive
-
-	CMD_CHANGE_DIFFICULTY_LEVEL      =  85, ///< change the difficult of a game (each setting for it own)
-
-	CMD_START_STOP_SHIP              =  86, ///< start/stop a ship
-	CMD_SELL_SHIP                    =  87, ///< sell a ship
-	CMD_BUILD_SHIP                   =  88, ///< build a new ship
-	CMD_SEND_SHIP_TO_DEPOT           =  89, ///< send a ship to a depot
-	CMD_REFIT_SHIP                   =  91, ///< refit the cargo space of a ship
-
-	CMD_ORDER_REFIT                  =  98, ///< change the refit informaction of an order (for "goto depot" )
-	CMD_CLONE_ORDER                  =  99, ///< clone (and share) an order
-	CMD_CLEAR_AREA                   = 100, ///< clear an area
-
-	CMD_MONEY_CHEAT                  = 102, ///< do the money cheat
-	CMD_BUILD_CANAL                  = 103, ///< build a canal
-
-	CMD_PLAYER_CTRL                  = 104, ///< used in multiplayer to create a new player etc.
-	CMD_LEVEL_LAND                   = 105, ///< level land
-
-	CMD_REFIT_RAIL_VEHICLE           = 106, ///< refit the cargo space of a train
-	CMD_RESTORE_ORDER_INDEX          = 107, ///< restore vehicle order-index and service interval
-	CMD_BUILD_LOCK                   = 108, ///< build a lock
-
-	CMD_BUILD_SIGNAL_TRACK           = 110, ///< add signals along a track (by dragging)
-	CMD_REMOVE_SIGNAL_TRACK          = 111, ///< remove signals along a track (by dragging)
-
-	CMD_GIVE_MONEY                   = 113, ///< give money to an other player
-	CMD_CHANGE_PATCH_SETTING         = 114, ///< change a patch setting
-
-	CMD_SET_AUTOREPLACE              = 115, ///< set an autoreplace entry
-
-	CMD_CLONE_VEHICLE                = 116, ///< clone a vehicle
-	CMD_MASS_START_STOP              = 117, ///< start/stop all vehicles (in a depot)
-	CMD_DEPOT_SELL_ALL_VEHICLES      = 118, ///< sell all vehicles which are in a given depot
-	CMD_DEPOT_MASS_AUTOREPLACE       = 119, ///< force the autoreplace to take action in a given depot
-
-	CMD_CREATE_GROUP                 = 120, ///< create a new group
-	CMD_DELETE_GROUP                 = 121, ///< delete a group
-	CMD_RENAME_GROUP                 = 122, ///< rename a group
-	CMD_ADD_VEHICLE_GROUP            = 123, ///< add a vehicle to a group
-	CMD_ADD_SHARED_VEHICLE_GROUP     = 124, ///< add all other shared vehicles to a group which are missing
-	CMD_REMOVE_ALL_VEHICLES_GROUP    = 125, ///< remove all vehicles from a group
-	CMD_SET_GROUP_REPLACE_PROTECTION = 126, ///< set the autoreplace-protection for a group
-
-	CMD_MOVE_ORDER                   = 127, ///< move an order
-	CMD_CHANGE_TIMETABLE             = 128, ///< change the timetable for a vehicle
-	CMD_SET_VEHICLE_ON_TIME          = 129, ///< set the vehicle on time feature (timetable)
-	CMD_AUTOFILL_TIMETABLE           = 130, ///< autofill the timetable
-};
-
-/**
- * List of flags for a command.
- *
- * This enums defines some flags which can be used for the commands.
- */
-enum {
-	DC_EXEC            = 0x01, ///< execute the given command
-	DC_AUTO            = 0x02, ///< don't allow building on structures
-	DC_QUERY_COST      = 0x04, ///< query cost only,  don't build.
-	DC_NO_WATER        = 0x08, ///< don't allow building on water
-	DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail)
-	DC_NO_TOWN_RATING  = 0x40, ///< town rating does not disallow you from building
-	DC_FORCETEST       = 0x80, ///< force test too.
-};
-
-/**
- * Used to combine a StringID with the command.
- *
- * This macro can be used to add a StringID (the error message to show) on a command-id
- * (CMD_xxx). Use the binary or-operator "|" to combine the command with the result from
- * this macro.
- *
- * @param x The StringID to combine with a command-id
- */
-#define CMD_MSG(x) ((x) << 16)
-
-/**
- * Defines some flags.
- *
- * This enumeration defines some flags which are binary-or'ed on a command.
- */
-enum {
-	CMD_NO_WATER              = 0x0400, ///< dont build on water
-	CMD_NETWORK_COMMAND       = 0x0800, ///< execute the command without sending it on the network
-	CMD_NO_TEST_IF_IN_NETWORK = 0x1000, ///< When enabled, the command will bypass the no-DC_EXEC round if in network
-	CMD_SHOW_NO_ERROR         = 0x2000, ///< do not show the error message
-};
-
-/**
- * Command flags for the command table _command_proc_table.
- *
- * This enumeration defines flags for the _command_proc_table.
- */
-enum {
-	CMD_SERVER  = 0x1, ///< the command can only be initiated by the server
-	CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only
-	CMD_AUTO    = 0x4, ///< set the DC_AUTO flag on this command
-};
-
-/**
- * Defines the callback type for all command handler functions.
- *
- * This type defines the function header for all functions which handles a CMD_* command.
- * A command handler use the parameters to act according to the meaning of the command.
- * The tile parameter defines the tile to perform an action on.
- * The flag parameter is filled with flags from the DC_* enumeration. The parameters
- * p1 and p2 are filled with parameters for the command like "which road type", "which
- * order" or "direction". Each function should mentioned in there doxygen comments
- * the usage of these parameters.
- *
- * @param tile The tile to apply a command on
- * @param flags Flags for the command, from the DC_* enumeration
- * @param p1 Additional data for the command
- * @param p2 Additional data for the command
- * @return The CommandCost of the command, which can be succeeded or failed.
- */
-typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
-
-/**
- * Define a command with the flags which belongs to it.
- *
- * This struct connect a command handler function with the flags created with
- * the #CMD_AUTO, #CMD_OFFLINE and #CMD_SERVER values.
- */
-struct Command {
-	CommandProc *proc;
-	byte flags;
-};
-
-/**
- * Checks if a command failes.
- *
- * As you see the parameter is not a command but the return value of a command,
- * the CommandCost class. This function checks if the command executed by
- * the CommandProc function failed and returns true if it does.
- *
- * @param cost The return value of a CommandProc call
- * @return true if the command failes
- * @see CmdSucceded
- */
-static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
-
-/**
- * Checks if a command succeeded.
- *
- * As #CmdFailed this function checks if a command succeeded
- *
- * @param cost The return value of a CommandProc call
- * @return true if the command succeeded
- * @see CmdSucceeded
- */
-static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
-
-/**
- * Define a default return value for a failed command.
- *
- * This variable contains a CommandCost object with is declared as "failed".
- * Other functions just need to return this error if there is an error,
- * which doesn't need to specific by a StringID.
- */
-static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
-
-/**
- * Returns from a function with a specific StringID as error.
- *
- * This macro is used to return from a function. The parameter contains the
- * StringID which will be returned.
- *
- * @param errcode The StringID to return
- */
-#define return_cmd_error(errcode) return CommandCost(errcode);
-
-/* command.cpp */
-/**
- * Define a callback function for the client, after the command is finished.
- *
- * Functions of this type are called after the command is finished. The parameters
- * are from the #CommandProc callback type. The boolean parameter indicates if the
- * command succeeded or failed.
- *
- * @param success If the command succeeded or not.
- * @param tile The tile of the command action
- * @param p1 Additional data of the command
- * @param p1 Additional data of the command
- * @see CommandProc
- */
-typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
-/**
- * Execute a command
- */
-CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
-
-/**
- * Execute a network safe DoCommand function
- */
-bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true);
-
-#ifdef ENABLE_NETWORK
-
-/**
- * Send a command over the network
- */
-void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
-#endif /* ENABLE_NETWORK */
-
-/**
- * Text, which gets sent with a command
- *
- * This variable contains a string (be specific a pointer of the first
- * char of this string) which will be send with a command. This is
- * used for user input data like names or chat messages.
- */
-extern const char *_cmd_text;
-
-/**
- * Checks if a integer value belongs to a command.
- */
-bool IsValidCommand(uint cmd);
-/**
- * Returns the flags from a given command.
- */
-byte GetCommandFlags(uint cmd);
-/**
- * Returns the current money available which can be used for a command.
- */
-Money GetAvailableMoneyForCommand();
-
-#endif /* COMMAND_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/command_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,94 @@
+/* $Id$ */
+
+/** @file command_func.h Functions related to commands. */
+
+#ifndef COMMAND_FUNC_H
+#define COMMAND_FUNC_H
+
+#include "command_type.h"
+
+/**
+ * Checks if a command failes.
+ *
+ * As you see the parameter is not a command but the return value of a command,
+ * the CommandCost class. This function checks if the command executed by
+ * the CommandProc function failed and returns true if it does.
+ *
+ * @param cost The return value of a CommandProc call
+ * @return true if the command failes
+ * @see CmdSucceded
+ */
+static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
+
+/**
+ * Checks if a command succeeded.
+ *
+ * As #CmdFailed this function checks if a command succeeded
+ *
+ * @param cost The return value of a CommandProc call
+ * @return true if the command succeeded
+ * @see CmdSucceeded
+ */
+static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
+
+/**
+ * Define a default return value for a failed command.
+ *
+ * This variable contains a CommandCost object with is declared as "failed".
+ * Other functions just need to return this error if there is an error,
+ * which doesn't need to specific by a StringID.
+ */
+static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
+
+/**
+ * Returns from a function with a specific StringID as error.
+ *
+ * This macro is used to return from a function. The parameter contains the
+ * StringID which will be returned.
+ *
+ * @param errcode The StringID to return
+ */
+#define return_cmd_error(errcode) return CommandCost(errcode);
+
+/**
+ * Execute a command
+ */
+CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc);
+
+/**
+ * Execute a network safe DoCommand function
+ */
+bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true);
+
+#ifdef ENABLE_NETWORK
+
+/**
+ * Send a command over the network
+ */
+void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
+#endif /* ENABLE_NETWORK */
+
+/**
+ * Text, which gets sent with a command
+ *
+ * This variable contains a string (be specific a pointer of the first
+ * char of this string) which will be send with a command. This is
+ * used for user input data like names or chat messages.
+ */
+extern const char *_cmd_text;
+extern Money _additional_cash_required;
+
+/**
+ * Checks if a integer value belongs to a command.
+ */
+bool IsValidCommand(uint32 cmd);
+/**
+ * Returns the flags from a given command.
+ */
+byte GetCommandFlags(uint32 cmd);
+/**
+ * Returns the current money available which can be used for a command.
+ */
+Money GetAvailableMoneyForCommand();
+
+#endif /* COMMAND_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/command_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,356 @@
+/* $Id$ */
+
+/** @file command_type.h Types related to commands. */
+
+#ifndef COMMAND_TYPE_H
+#define COMMAND_TYPE_H
+
+#include "economy_type.h"
+#include "strings_type.h"
+#include "tile_type.h"
+
+/**
+ * Common return value for all commands. Wraps the cost and
+ * a possible error message/state together.
+ */
+class CommandCost {
+	ExpensesType expense_type; ///< the type of expence as shown on the finances view
+	Money cost;       ///< The cost of this action
+	StringID message; ///< Warning message for when success is unset
+	bool success;     ///< Whether the comment went fine up to this moment
+
+public:
+	/**
+	 * Creates a command cost return with no cost and no error
+	 */
+	CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true) {}
+
+	/**
+	 * Creates a command return value the is failed with the given message
+	 */
+	CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false) {}
+
+	/**
+	 * Creates a command cost with given expense type and start cost of 0
+	 * @param ex_t the expense type
+	 */
+	CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true) {}
+
+	/**
+	 * Creates a command return value with the given start cost and expense type
+	 * @param ex_t the expense type
+	 * @param cst the initial cost of this command
+	 */
+	CommandCost(ExpensesType ex_t, Money cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
+
+	/**
+	 * Adds the cost of the given command return value to this cost.
+	 * Also takes a possible error message when it is set.
+	 * @param ret the command to add the cost of.
+	 * @return this class.
+	 */
+	CommandCost AddCost(CommandCost ret);
+
+	/**
+	 * Adds the given cost to the cost of the command.
+	 * @param cost the cost to add
+	 * @return this class.
+	 */
+	CommandCost AddCost(Money cost);
+
+	/**
+	 * Multiplies the cost of the command by the given factor.
+	 * @param cost factor to multiply the costs with
+	 * @return this class
+	 */
+	CommandCost MultiplyCost(int factor);
+
+	/**
+	 * The costs as made up to this moment
+	 * @return the costs
+	 */
+	Money GetCost() const;
+
+	/**
+	 * The expense type of the cost
+	 * @return the expense type
+	 */
+	ExpensesType GetExpensesType() const;
+
+	/**
+	 * Sets the global error message *if* this class has one.
+	 */
+	void SetGlobalErrorMessage() const;
+
+	/**
+	 * Did this command succeed?
+	 * @return true if and only if it succeeded
+	 */
+	bool Succeeded() const;
+
+	/**
+	 * Did this command fail?
+	 * @return true if and only if it failed
+	 */
+	bool Failed() const;
+};
+
+/**
+ * List of commands.
+ *
+ * This enum defines all possible commands which can be executed to the game
+ * engine. Observing the game like the query-tool or checking the profit of a
+ * vehicle don't result in a command which should be executed in the engine
+ * nor send to the server in a network game.
+ *
+ * @see _command_proc_table
+ */
+enum {
+	CMD_BUILD_RAILROAD_TRACK         =   0, ///< build a rail track
+	CMD_REMOVE_RAILROAD_TRACK        =   1, ///< remove a rail track
+	CMD_BUILD_SINGLE_RAIL            =   2, ///< build a single rail track
+	CMD_REMOVE_SINGLE_RAIL           =   3, ///< remove a single rail track
+	CMD_LANDSCAPE_CLEAR              =   4, ///< demolish a tile
+	CMD_BUILD_BRIDGE                 =   5, ///< build a bridge
+	CMD_BUILD_RAILROAD_STATION       =   6, ///< build a railroad station
+	CMD_BUILD_TRAIN_DEPOT            =   7, ///< build a train depot
+	CMD_BUILD_SIGNALS                =   8, ///< build a signal
+	CMD_REMOVE_SIGNALS               =   9, ///< remove a signal
+	CMD_TERRAFORM_LAND               =  10, ///< terraform a tile
+	CMD_PURCHASE_LAND_AREA           =  11, ///< purchase a tile
+	CMD_SELL_LAND_AREA               =  12, ///< sell a bought tile before
+	CMD_BUILD_TUNNEL                 =  13, ///< build a tunnel
+
+	CMD_REMOVE_FROM_RAILROAD_STATION =  14, ///< remove a tile station
+	CMD_CONVERT_RAIL                 =  15, ///< convert a rail type
+
+	CMD_BUILD_TRAIN_WAYPOINT         =  16, ///< build a waypoint
+	CMD_RENAME_WAYPOINT              =  17, ///< rename a waypoint
+	CMD_REMOVE_TRAIN_WAYPOINT        =  18, ///< remove a waypoint
+
+	CMD_BUILD_ROAD_STOP              =  21, ///< build a road stop
+	CMD_REMOVE_ROAD_STOP             =  22, ///< remove a road stop
+	CMD_BUILD_LONG_ROAD              =  23, ///< build a complete road (not a "half" one)
+	CMD_REMOVE_LONG_ROAD             =  24, ///< remove a complete road (not a "half" one)
+	CMD_BUILD_ROAD                   =  25, ///< build a "half" road
+	CMD_REMOVE_ROAD                  =  26, ///< remove a "half" road
+	CMD_BUILD_ROAD_DEPOT             =  27, ///< build a road depot
+
+	CMD_BUILD_AIRPORT                =  29, ///< build an airport
+
+	CMD_BUILD_DOCK                   =  30, ///< build a dock
+
+	CMD_BUILD_SHIP_DEPOT             =  31, ///< build a ship depot
+	CMD_BUILD_BUOY                   =  32, ///< build a buoy
+
+	CMD_PLANT_TREE                   =  33, ///< plant a tree
+
+	CMD_BUILD_RAIL_VEHICLE           =  34, ///< build a rail vehicle
+	CMD_MOVE_RAIL_VEHICLE            =  35, ///< move a rail vehicle (in the depot)
+
+	CMD_START_STOP_TRAIN             =  36, ///< start or stop a train
+
+	CMD_SELL_RAIL_WAGON              =  38, ///< sell a rail wagon
+
+	CMD_SEND_TRAIN_TO_DEPOT          =  39, ///< send a train to a depot
+	CMD_FORCE_TRAIN_PROCEED          =  40, ///< proceed a train to pass a red signal
+	CMD_REVERSE_TRAIN_DIRECTION      =  41, ///< turn a train around
+
+	CMD_MODIFY_ORDER                 =  42, ///< modify an order (like set full-load)
+	CMD_SKIP_TO_ORDER                =  43, ///< skip an order to the next of specific one
+	CMD_DELETE_ORDER                 =  44, ///< delete an order
+	CMD_INSERT_ORDER                 =  45, ///< insert a new order
+
+	CMD_CHANGE_SERVICE_INT           =  46, ///< change the server interval of a vehicle
+
+	CMD_BUILD_INDUSTRY               =  47, ///< build a new industry
+
+	CMD_BUILD_COMPANY_HQ             =  48, ///< build the company headquarter
+	CMD_SET_PLAYER_FACE              =  49, ///< set the face of the player/company
+	CMD_SET_PLAYER_COLOR             =  50, ///< set the color of the player/company
+
+	CMD_INCREASE_LOAN                =  51, ///< increase the loan from the bank
+	CMD_DECREASE_LOAN                =  52, ///< decrease the loan from the bank
+
+	CMD_WANT_ENGINE_PREVIEW          =  53, ///< confirm the preview of an engine
+
+	CMD_NAME_VEHICLE                 =  54, ///< rename a whole vehicle
+	CMD_RENAME_ENGINE                =  55, ///< rename a engine (in the engine list)
+	CMD_CHANGE_COMPANY_NAME          =  56, ///< change the company name
+	CMD_CHANGE_PRESIDENT_NAME        =  57, ///< change the president name
+	CMD_RENAME_STATION               =  58, ///< rename a station
+
+	CMD_SELL_AIRCRAFT                =  59, ///< sell an aircraft
+	CMD_START_STOP_AIRCRAFT          =  60, ///< start/stop an aircraft
+	CMD_BUILD_AIRCRAFT               =  61, ///< build an aircraft
+	CMD_SEND_AIRCRAFT_TO_HANGAR      =  62, ///< send an aircraft to a hanger
+	CMD_REFIT_AIRCRAFT               =  64, ///< refit the cargo space of an aircraft
+
+	CMD_PLACE_SIGN                   =  65, ///< place a sign
+	CMD_RENAME_SIGN                  =  66, ///< rename a sign
+
+	CMD_BUILD_ROAD_VEH               =  67, ///< build a road vehicle
+	CMD_START_STOP_ROADVEH           =  68, ///< start/stop a road vehicle
+	CMD_SELL_ROAD_VEH                =  69, ///< sell a road vehicle
+	CMD_SEND_ROADVEH_TO_DEPOT        =  70, ///< send a road vehicle to the depot
+	CMD_TURN_ROADVEH                 =  71, ///< turn a road vehicle around
+	CMD_REFIT_ROAD_VEH               =  72, ///< refit the cargo space of a road vehicle
+
+	CMD_PAUSE                        =  73, ///< pause the game
+
+	CMD_BUY_SHARE_IN_COMPANY         =  74, ///< buy a share from a company
+	CMD_SELL_SHARE_IN_COMPANY        =  75, ///< sell a share from a company
+	CMD_BUY_COMPANY                  =  76, ///< buy a company which is bankrupt
+
+	CMD_BUILD_TOWN                   =  77, ///< build a town
+
+	CMD_RENAME_TOWN                  =  80, ///< rename a town
+	CMD_DO_TOWN_ACTION               =  81, ///< do a action from the town detail window (like advertises or bribe)
+
+	CMD_SET_ROAD_DRIVE_SIDE          =  82, ///< set the side where the road vehicles drive
+
+	CMD_CHANGE_DIFFICULTY_LEVEL      =  85, ///< change the difficult of a game (each setting for it own)
+
+	CMD_START_STOP_SHIP              =  86, ///< start/stop a ship
+	CMD_SELL_SHIP                    =  87, ///< sell a ship
+	CMD_BUILD_SHIP                   =  88, ///< build a new ship
+	CMD_SEND_SHIP_TO_DEPOT           =  89, ///< send a ship to a depot
+	CMD_REFIT_SHIP                   =  91, ///< refit the cargo space of a ship
+
+	CMD_ORDER_REFIT                  =  98, ///< change the refit informaction of an order (for "goto depot" )
+	CMD_CLONE_ORDER                  =  99, ///< clone (and share) an order
+	CMD_CLEAR_AREA                   = 100, ///< clear an area
+
+	CMD_MONEY_CHEAT                  = 102, ///< do the money cheat
+	CMD_BUILD_CANAL                  = 103, ///< build a canal
+
+	CMD_PLAYER_CTRL                  = 104, ///< used in multiplayer to create a new player etc.
+	CMD_LEVEL_LAND                   = 105, ///< level land
+
+	CMD_REFIT_RAIL_VEHICLE           = 106, ///< refit the cargo space of a train
+	CMD_RESTORE_ORDER_INDEX          = 107, ///< restore vehicle order-index and service interval
+	CMD_BUILD_LOCK                   = 108, ///< build a lock
+
+	CMD_BUILD_SIGNAL_TRACK           = 110, ///< add signals along a track (by dragging)
+	CMD_REMOVE_SIGNAL_TRACK          = 111, ///< remove signals along a track (by dragging)
+
+	CMD_GIVE_MONEY                   = 113, ///< give money to an other player
+	CMD_CHANGE_PATCH_SETTING         = 114, ///< change a patch setting
+
+	CMD_SET_AUTOREPLACE              = 115, ///< set an autoreplace entry
+
+	CMD_CLONE_VEHICLE                = 116, ///< clone a vehicle
+	CMD_MASS_START_STOP              = 117, ///< start/stop all vehicles (in a depot)
+	CMD_DEPOT_SELL_ALL_VEHICLES      = 118, ///< sell all vehicles which are in a given depot
+	CMD_DEPOT_MASS_AUTOREPLACE       = 119, ///< force the autoreplace to take action in a given depot
+
+	CMD_CREATE_GROUP                 = 120, ///< create a new group
+	CMD_DELETE_GROUP                 = 121, ///< delete a group
+	CMD_RENAME_GROUP                 = 122, ///< rename a group
+	CMD_ADD_VEHICLE_GROUP            = 123, ///< add a vehicle to a group
+	CMD_ADD_SHARED_VEHICLE_GROUP     = 124, ///< add all other shared vehicles to a group which are missing
+	CMD_REMOVE_ALL_VEHICLES_GROUP    = 125, ///< remove all vehicles from a group
+	CMD_SET_GROUP_REPLACE_PROTECTION = 126, ///< set the autoreplace-protection for a group
+
+	CMD_MOVE_ORDER                   = 127, ///< move an order
+	CMD_CHANGE_TIMETABLE             = 128, ///< change the timetable for a vehicle
+	CMD_SET_VEHICLE_ON_TIME          = 129, ///< set the vehicle on time feature (timetable)
+	CMD_AUTOFILL_TIMETABLE           = 130, ///< autofill the timetable
+};
+
+/**
+ * List of flags for a command.
+ *
+ * This enums defines some flags which can be used for the commands.
+ */
+enum {
+	DC_EXEC            = 0x01, ///< execute the given command
+	DC_AUTO            = 0x02, ///< don't allow building on structures
+	DC_QUERY_COST      = 0x04, ///< query cost only,  don't build.
+	DC_NO_WATER        = 0x08, ///< don't allow building on water
+	DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail)
+	DC_AI_BUILDING     = 0x20, ///< special building rules for AI
+	DC_NO_TOWN_RATING  = 0x40, ///< town rating does not disallow you from building
+	DC_FORCETEST       = 0x80, ///< force test too.
+};
+
+/**
+ * Used to combine a StringID with the command.
+ *
+ * This macro can be used to add a StringID (the error message to show) on a command-id
+ * (CMD_xxx). Use the binary or-operator "|" to combine the command with the result from
+ * this macro.
+ *
+ * @param x The StringID to combine with a command-id
+ */
+#define CMD_MSG(x) ((x) << 16)
+
+/**
+ * Defines some flags.
+ *
+ * This enumeration defines some flags which are binary-or'ed on a command.
+ */
+enum {
+	CMD_NO_WATER              = 0x0400, ///< dont build on water
+	CMD_NETWORK_COMMAND       = 0x0800, ///< execute the command without sending it on the network
+	CMD_NO_TEST_IF_IN_NETWORK = 0x1000, ///< When enabled, the command will bypass the no-DC_EXEC round if in network
+	CMD_SHOW_NO_ERROR         = 0x2000, ///< do not show the error message
+};
+
+/**
+ * Command flags for the command table _command_proc_table.
+ *
+ * This enumeration defines flags for the _command_proc_table.
+ */
+enum {
+	CMD_SERVER  = 0x1, ///< the command can only be initiated by the server
+	CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only
+	CMD_AUTO    = 0x4, ///< set the DC_AUTO flag on this command
+};
+
+/**
+ * Defines the callback type for all command handler functions.
+ *
+ * This type defines the function header for all functions which handles a CMD_* command.
+ * A command handler use the parameters to act according to the meaning of the command.
+ * The tile parameter defines the tile to perform an action on.
+ * The flag parameter is filled with flags from the DC_* enumeration. The parameters
+ * p1 and p2 are filled with parameters for the command like "which road type", "which
+ * order" or "direction". Each function should mentioned in there doxygen comments
+ * the usage of these parameters.
+ *
+ * @param tile The tile to apply a command on
+ * @param flags Flags for the command, from the DC_* enumeration
+ * @param p1 Additional data for the command
+ * @param p2 Additional data for the command
+ * @return The CommandCost of the command, which can be succeeded or failed.
+ */
+typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
+
+/**
+ * Define a command with the flags which belongs to it.
+ *
+ * This struct connect a command handler function with the flags created with
+ * the #CMD_AUTO, #CMD_OFFLINE and #CMD_SERVER values.
+ */
+struct Command {
+	CommandProc *proc;
+	byte flags;
+};
+
+/**
+ * Define a callback function for the client, after the command is finished.
+ *
+ * Functions of this type are called after the command is finished. The parameters
+ * are from the #CommandProc callback type. The boolean parameter indicates if the
+ * command succeeded or failed.
+ *
+ * @param success If the command succeeded or not.
+ * @param tile The tile of the command action
+ * @param p1 Additional data of the command
+ * @param p1 Additional data of the command
+ * @see CommandProc
+ */
+typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
+
+#endif /* COMMAND_TYPE_H */
--- a/src/console.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/console.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,20 +5,21 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "functions.h"
-#include "window.h"
 #include "gui.h"
-#include "gfx.h"
+#include "textbuf_gui.h"
+#include "window_gui.h"
 #include "player.h"
 #include "variables.h"
-#include "string.h"
 #include <stdarg.h>
 #include <string.h>
 #include "console.h"
-#include "helpers.hpp"
 #include "network/network.h"
 #include "network/network_data.h"
 #include "network/network_server.h"
+#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
@@ -356,7 +357,7 @@
 	_iconsole_historypos = i;
 	IConsoleClearCommand();
 	/* copy history to 'command prompt / bash' */
-	assert(_iconsole_history[i] != NULL && IS_INT_INSIDE(i, 0, ICON_HISTORY_SIZE));
+	assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE));
 	ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength);
 	UpdateTextBufferSize(&_iconsole_cmdline);
 }
--- a/src/console.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/console.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef CONSOLE_H
 #define CONSOLE_H
 
+#include "window_type.h"
+
 /* maximum length of a typed in command */
 #define ICON_CMDLN_SIZE 255
 /* maximum length of a totally expanded command */
--- a/src/console_cmds.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/console_cmds.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -7,26 +7,29 @@
 #include "console.h"
 #include "debug.h"
 #include "engine.h"
-#include "functions.h"
 #include "landscape.h"
 #include "saveload.h"
-#include "string.h"
 #include "variables.h"
 #include "network/network_data.h"
 #include "network/network_client.h"
 #include "network/network_server.h"
 #include "network/network_udp.h"
-#include "command.h"
-#include "settings.h"
+#include "command_func.h"
+#include "settings_func.h"
 #include "fios.h"
 #include "fileio.h"
-#include "vehicle.h"
 #include "station.h"
-#include "strings.h"
 #include "screenshot.h"
 #include "genworld.h"
-#include "date.h"
 #include "network/network.h"
+#include "strings_func.h"
+#include "viewport_func.h"
+#include "window_func.h"
+#include "functions.h"
+#include "map_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "string_func.h"
 
 // ** scriptfile handling ** //
 static FILE *_script_file;
@@ -134,19 +137,12 @@
 
 DEF_CONSOLE_CMD(ConStopAllVehicles)
 {
-	Vehicle* v;
 	if (argc == 0) {
 		IConsoleHelp("Stops all vehicles in the game. For debugging only! Use at your own risk... Usage: 'stopall'");
 		return true;
 	}
 
-	FOR_ALL_VEHICLES(v) {
-		/* Code ripped from CmdStartStopTrain. Can't call it, because of
-		 * ownership problems, so we'll duplicate some code, for now */
-		v->vehstatus |= VS_STOPPED;
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
-		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
-	}
+	StopAllVehicles();
 	return true;
 }
 #endif /* _DEBUG */
@@ -233,7 +229,7 @@
 		if (file == endptr || *endptr != '\0') i = -1;
 	}
 
-	return IS_INT_INSIDE(i, 0, _fios_num) ? &_fios_list[i] : NULL;
+	return IsInsideMM(i, 0, _fios_num) ? &_fios_list[i] : NULL;
 }
 
 
@@ -1326,6 +1322,8 @@
 	return true;
 }
 
+extern void HashCurrentCompanyPassword();
+
 /* Also use from within player_gui to change the password graphically */
 bool NetworkChangeCompanyPassword(byte argc, char *argv[])
 {
@@ -1346,8 +1344,11 @@
 
 	ttd_strlcpy(_network_player_info[_local_player].password, argv[0], sizeof(_network_player_info[_local_player].password));
 
-	if (!_network_server)
+	if (!_network_server) {
 		SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
+	} else {
+		HashCurrentCompanyPassword();
+	}
 
 	IConsolePrintF(_icolour_warn, "'company_pw' changed to:  %s", _network_player_info[_local_player].password);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/alloc_func.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,84 @@
+/* $Id$ */
+
+/** @file alloc_func.hpp Functions related to the allocation of memory */
+
+#ifndef ALLOC_FUNC_HPP
+#define ALLOC_FUNC_HPP
+
+/**
+ * Simplified allocation function that allocates the specified number of
+ * elements of the given type. It also explicitly casts it to the requested
+ * type.
+ * @note throws an error when there is no memory anymore.
+ * @note the memory contains garbage data (i.e. possibly non-zero values).
+ * @param T the type of the variable(s) to allocation.
+ * @param num_elements the number of elements to allocate of the given type.
+ * @return NULL when num_elements == 0, non-NULL otherwise.
+ */
+template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
+{
+	/*
+	 * MorphOS cannot handle 0 elements allocations, or rather that always
+	 * returns NULL. So we do that for *all* allocations, thus causing it
+	 * to behave the same on all OSes.
+	 */
+	if (num_elements == 0) return NULL;
+
+	T *t_ptr = (T*)malloc(num_elements * sizeof(T));
+	if (t_ptr == NULL) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
+	return t_ptr;
+}
+
+/**
+ * Simplified allocation function that allocates the specified number of
+ * elements of the given type. It also explicitly casts it to the requested
+ * type.
+ * @note throws an error when there is no memory anymore.
+ * @note the memory contains all zero values.
+ * @param T the type of the variable(s) to allocation.
+ * @param num_elements the number of elements to allocate of the given type.
+ * @return NULL when num_elements == 0, non-NULL otherwise.
+ */
+template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
+{
+	/*
+	 * MorphOS cannot handle 0 elements allocations, or rather that always
+	 * returns NULL. So we do that for *all* allocations, thus causing it
+	 * to behave the same on all OSes.
+	 */
+	if (num_elements == 0) return NULL;
+
+	T *t_ptr = (T*)calloc(num_elements, sizeof(T));
+	if (t_ptr == NULL) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
+	return t_ptr;
+}
+
+/**
+ * Simplified reallocation function that allocates the specified number of
+ * elements of the given type. It also explicitly casts it to the requested
+ * type. It extends/shrinks the memory allocation given in t_ptr.
+ * @note throws an error when there is no memory anymore.
+ * @note the memory contains all zero values.
+ * @param T the type of the variable(s) to allocation.
+ * @param t_ptr the previous allocation to extend/shrink.
+ * @param num_elements the number of elements to allocate of the given type.
+ * @return NULL when num_elements == 0, non-NULL otherwise.
+ */
+template <typename T> FORCEINLINE T* ReallocT(T *t_ptr, size_t num_elements)
+{
+	/*
+	 * MorphOS cannot handle 0 elements allocations, or rather that always
+	 * returns NULL. So we do that for *all* allocations, thus causing it
+	 * to behave the same on all OSes.
+	 */
+	if (num_elements == 0) {
+		free(t_ptr);
+		return NULL;
+	}
+
+	t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
+	if (t_ptr == NULL) error("Out of memory. Cannot reallocate %i bytes", num_elements * sizeof(T));
+	return t_ptr;
+}
+
+#endif /* ALLOC_FUNC_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/bitmath_func.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,72 @@
+/* $Id$ */
+
+/** @file bitmath_func.cpp */
+
+#include "../stdafx.h"
+#include "bitmath_func.hpp"
+
+const uint8 _ffb_64[64] = {
+ 0,  0,  1,  0,  2,  0,  1,  0,
+ 3,  0,  1,  0,  2,  0,  1,  0,
+ 4,  0,  1,  0,  2,  0,  1,  0,
+ 3,  0,  1,  0,  2,  0,  1,  0,
+ 5,  0,  1,  0,  2,  0,  1,  0,
+ 3,  0,  1,  0,  2,  0,  1,  0,
+ 4,  0,  1,  0,  2,  0,  1,  0,
+ 3,  0,  1,  0,  2,  0,  1,  0,
+};
+
+/**
+ * Search the first set bit in a 32 bit variable.
+ *
+ * This algorithm is a static implementation of a log
+ * conguence search algorithm. It checks the first half
+ * if there is a bit set search there further. And this
+ * way further. If no bit is set return 0.
+ *
+ * @param x The value to search
+ * @return The position of the first bit set
+ */
+uint8 FindFirstBit(uint32 x)
+{
+	if (x == 0) return 0;
+	/* The macro FIND_FIRST_BIT is better to use when your x is
+	  not more than 128. */
+
+	uint8 pos = 0;
+
+	if ((x & 0x0000ffff) == 0) { x >>= 16; pos += 16; }
+	if ((x & 0x000000ff) == 0) { x >>= 8;  pos += 8;  }
+	if ((x & 0x0000000f) == 0) { x >>= 4;  pos += 4;  }
+	if ((x & 0x00000003) == 0) { x >>= 2;  pos += 2;  }
+	if ((x & 0x00000001) == 0) { pos += 1; }
+
+	return pos;
+}
+
+/**
+ * Search the last set bit in a 64 bit variable.
+ *
+ * This algorithm is a static implementation of a log
+ * conguence search algorithm. It checks the second half
+ * if there is a bit set search there further. And this
+ * way further. If no bit is set return 0.
+ *
+ * @param x The value to search
+ * @return The position of the last bit set
+ */
+uint8 FindLastBit(uint64 x)
+{
+	if (x == 0) return 0;
+
+	uint8 pos = 0;
+
+	if ((x & 0xffffffff00000000ULL) != 0) { x >>= 32; pos += 32; }
+	if ((x & 0x00000000ffff0000ULL) != 0) { x >>= 16; pos += 16; }
+	if ((x & 0x000000000000ff00ULL) != 0) { x >>= 8;  pos += 8;  }
+	if ((x & 0x00000000000000f0ULL) != 0) { x >>= 4;  pos += 4;  }
+	if ((x & 0x000000000000000cULL) != 0) { x >>= 2;  pos += 2;  }
+	if ((x & 0x0000000000000002ULL) != 0) { pos += 1; }
+
+	return pos;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/bitmath_func.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,324 @@
+/* $Id$ */
+
+/** @file bitmath_func.hpp */
+
+#ifndef BITMATH_FUNC_HPP
+#define BITMATH_FUNC_HPP
+
+/**
+ * Fetch n bits from x, started at bit s.
+ *
+ * This function can be used to fetch n bits from the value x. The
+ * s value set the startposition to read. The startposition is
+ * count from the LSB and starts at 0. The result starts at a
+ * LSB, as this isn't just an and-bitmask but also some
+ * bit-shifting operations. GB(0xFF, 2, 1) will so
+ * return 0x01 (0000 0001) instead of
+ * 0x04 (0000 0100).
+ *
+ * @param x The value to read some bits.
+ * @param s The startposition to read some bits.
+ * @param n The number of bits to read.
+ * @return The selected bits, aligned to a LSB.
+ */
+template<typename T> static inline uint GB(const T x, const uint8 s, const uint8 n)
+{
+	return (x >> s) & ((1U << n) - 1);
+}
+
+/** Set n bits from x starting at bit s to d
+ *
+ * This function sets n bits from x which started as bit s to the value of
+ * d. The parameters x, s and n works the same as the parameters of
+ * #GB. The result is saved in x again. Unused bits in the window
+ * provided by n are set to 0 if the value of b isn't "big" enough.
+ * This is not a bug, its a feature.
+ *
+ * @note Parameter x must be a variable as the result is saved there.
+ * @note To avoid unexpecting results the value of b should not use more
+ *       space as the provided space of n bits (log2)
+ * @param x The variable to change some bits
+ * @param s The startposition for the new bits
+ * @param n The size/window for the new bits
+ * @param d The actually new bits to save in the defined position.
+ * @return The new value of x
+ */
+template<typename T, typename U> static inline T SB(T& x, const uint8 s, const uint8 n, const U d)
+{
+	x &= (T)(~(((1U << n) - 1) << s));
+	x |= (T)(d << s);
+	return x;
+}
+
+/** Add i to n bits of x starting at bit s.
+ *
+ * This add the value of i on n bits of x starting at bit s. The parameters x,
+ * s, i are similar to #GB besides x must be a variable as the result are
+ * saved there. An overflow does not affect the following bits of the given
+ * bit window and is simply ignored.
+ *
+ * @note Parameter x must be a variable as the result is saved there.
+ * @param x The variable to add some bits at some position
+ * @param s The startposition of the addition
+ * @param n The size/window for the addition
+ * @param i The value to add at the given startposition in the given window.
+ * @return The new value of x
+ */
+template<typename T, typename U> static inline T AB(T& x, const uint8 s, const uint8 n, const U i)
+{
+	const T mask = (T)(((1U << n) - 1) << s);
+	x = (T)((x & ~mask) | ((x + (i << s)) & mask));
+	return x;
+}
+
+/**
+ * Checks if a bit in a value is set.
+ *
+ * This function checks if a bit inside a value is set or not.
+ * The y value specific the position of the bit, started at the
+ * LSB and count from 0.
+ *
+ * @param x The value to check
+ * @param y The position of the bit to check, started from the LSB
+ * @return True if the bit is set, false else.
+ */
+template<typename T> static inline bool HasBit(const T x, const uint8 y)
+{
+	return (x & ((T)1U << y)) != 0;
+}
+
+/**
+ * Check several bits in a value.
+ *
+ * This macro checks if a value contains at least one bit of an other
+ * value.
+ *
+ * @param x The first value
+ * @param y The second value
+ * @return True if at least one bit is set in both values, false else.
+ */
+#define HASBITS(x, y) ((x) & (y))
+
+/**
+ * Set a bit in a variable.
+ *
+ * This function sets a bit in a variable. The variable is changed
+ * and the value is also returned. Parameter y defines the bit and
+ * starts at the LSB with 0.
+ *
+ * @param x The variable to set a bit
+ * @param y The bit position to set
+ * @return The new value of the old value with the bit set
+ */
+template<typename T> static inline T SetBit(T& x, const uint8 y)
+{
+	return x = (T)(x | (T)(1U << y));
+}
+
+/**
+ * Sets several bits in a variable.
+ *
+ * This macro sets several bits in a variable. The bits to set are provided
+ * by a value. The new value is also returned.
+ *
+ * @param x The variable to set some bits
+ * @param y The value with set bits for setting them in the variable
+ * @return The new value of x
+ */
+#define SETBITS(x, y) ((x) |= (y))
+
+/**
+ * Clears a bit in a variable.
+ *
+ * This function clears a bit in a variable. The variable is
+ * changed and the value is also returned. Parameter y defines the bit
+ * to clear and starts at the LSB with 0.
+ *
+ * @param x The variable to clear the bit
+ * @param y The bit position to clear
+ * @return The new value of the old value with the bit cleared
+ */
+template<typename T> static inline T ClrBit(T& x, const uint8 y)
+{
+	return x = (T)(x & ~((T)1U << y));
+}
+
+/**
+ * Clears several bits in a variable.
+ *
+ * This macro clears several bits in a variable. The bits to clear are
+ * provided by a value. The new value is also returned.
+ *
+ * @param x The variable to clear some bits
+ * @param y The value with set bits for clearing them in the variable
+ * @return The new value of x
+ */
+#define CLRBITS(x, y) ((x) &= ~(y))
+
+/**
+ * Toggles a bit in a variable.
+ *
+ * This function toggles a bit in a variable. The variable is
+ * changed and the value is also returned. Parameter y defines the bit
+ * to toggle and starts at the LSB with 0.
+ *
+ * @param x The varliable to toggle the bit
+ * @param y The bit position to toggle
+ * @return The new value of the old value with the bit toggled
+ */
+template<typename T> static inline T ToggleBit(T& x, const uint8 y)
+{
+	return x = (T)(x ^ (T)(1U << y));
+}
+
+
+/** Lookup table to check which bit is set in a 6 bit variable */
+extern const uint8 _ffb_64[64];
+
+/**
+ * Returns the first occure of a bit in a 6-bit value (from right).
+ *
+ * Returns the position of the first bit that is not zero, counted from the
+ * LSB. Ie, 110100 returns 2, 000001 returns 0, etc. When x == 0 returns
+ * 0.
+ *
+ * @param x The 6-bit value to check the first zero-bit
+ * @return The first position of a bit started from the LSB or 0 if x is 0.
+ */
+#define FIND_FIRST_BIT(x) _ffb_64[(x)]
+
+/**
+ * Finds the position of the first bit in an integer.
+ *
+ * This function returns the position of the first bit set in the
+ * integer. It does only check the bits of the bitmask
+ * 0x3F3F (0011111100111111) and checks only the
+ * bits of the bitmask 0x3F00 if and only if the
+ * lower part 0x00FF is 0. This results the bits at 0x00C0 must
+ * be also zero to check the bits at 0x3F00.
+ *
+ * @param value The value to check the first bits
+ * @return The position of the first bit which is set
+ * @see FIND_FIRST_BIT
+ */
+static inline uint8 FindFirstBit2x64(const int value)
+{
+	if ((value & 0xFF) == 0) {
+		return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8;
+	} else {
+		return FIND_FIRST_BIT(value & 0x3F);
+	}
+}
+
+uint8 FindFirstBit(uint32 x);
+uint8 FindLastBit(uint64 x);
+
+/**
+ * Clear the first bit in an integer.
+ *
+ * This function returns a value where the first bit (from LSB)
+ * is cleared.
+ * So, 110100 returns 110000, 000001 returns 000000, etc.
+ *
+ * @param value The value to clear the first bit
+ * @return The new value with the first bit cleared
+ */
+template<typename T> static inline T KillFirstBit(T value)
+{
+	return value &= (T)(value - 1);
+}
+
+/**
+ * Counts the number of set bits in a variable.
+ *
+ * @param value the value to count the number of bits in.
+ * @return the number of bits.
+ */
+template<typename T> static inline uint CountBits(T value)
+{
+	uint num;
+
+	/* This loop is only called once for every bit set by clearing the lowest
+	 * bit in each loop. The number of bits is therefore equal to the number of
+	 * times the loop was called. It was found at the following website:
+	 * http://graphics.stanford.edu/~seander/bithacks.html */
+
+	for (num = 0; value != 0; num++) {
+		value &= (T)(value - 1);
+	}
+
+	return num;
+}
+
+/**
+ * ROtate x Left by n
+ *
+ * @note Assumes a byte has 8 bits
+ * @param x The value which we want to rotate
+ * @param n The number how many we waht to rotate
+ * @return A bit rotated number
+ */
+template<typename T> static inline T ROL(const T x, const uint8 n)
+{
+	return (T)(x << n | x >> (sizeof(x) * 8 - n));
+}
+
+/**
+ * ROtate x Right by n
+ *
+ * @note Assumes a byte has 8 bits
+ * @param x The value which we want to rotate
+ * @param n The number how many we waht to rotate
+ * @return A bit rotated number
+ */
+template<typename T> static inline T ROR(const T x, const uint8 n)
+{
+	return (T)(x >> n | x << (sizeof(x) * 8 - n));
+}
+
+/**
+ * Do an operation for each set set bit in a value.
+ *
+ * This macros is used to do an operation for each set
+ * bit in a variable. The first variable can be reused
+ * in the operation due to it's the bit position counter.
+ * The second variable will be cleared during the usage
+ *
+ * @param i The position counter
+ * @param b The value which we check for set bits
+ */
+#define FOR_EACH_SET_BIT(i, b)      \
+	for (i = 0; b != 0; i++, b >>= 1) \
+		if (b & 1)
+
+
+#if defined(__APPLE__)
+	/* Make endian swapping use Apple's macros to increase speed
+	 * (since it will use hardware swapping if available).
+	 * Even though they should return uint16 and uint32, we get
+	 * warnings if we don't cast those (why?) */
+	#define BSWAP32(x) ((uint32)Endian32_Swap(x))
+	#define BSWAP16(x) ((uint16)Endian16_Swap(x))
+#else
+	/**
+	 * Perform a 32 bits endianness bitswap on x.
+	 * @param x the variable to bitswap
+	 * @return the bitswapped value.
+	 */
+	static inline uint32 BSWAP32(uint32 x)
+	{
+		return ((x >> 24) & 0xFF) | ((x >> 8) & 0xFF00) | ((x << 8) & 0xFF0000) | ((x << 24) & 0xFF000000);
+	}
+
+	/**
+	 * Perform a 16 bits endianness bitswap on x.
+	 * @param x the variable to bitswap
+	 * @return the bitswapped value.
+	 */
+	static inline uint16 BSWAP16(uint16 x)
+	{
+		return (x >> 8) | (x << 8);
+	}
+#endif /* __APPLE__ */
+
+#endif /* BITMATH_FUNC_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/endian_func.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,65 @@
+/* $Id$ */
+
+/** @file endian_func.hpp */
+
+#ifndef ENDIAN_FUNC_H
+#define ENDIAN_FUNC_H
+
+#include "bitmath_func.hpp"
+
+#if defined(ARM) || defined(__arm__) || defined(__alpha__)
+	#define OTTD_ALIGNMENT
+#endif
+
+/* Windows has always LITTLE_ENDIAN */
+#if defined(WIN32) || defined(__OS2__) || defined(WIN64)
+	#define TTD_LITTLE_ENDIAN
+#elif !defined(TESTING)
+	/* Else include endian[target/host].h, which has the endian-type, autodetected by the Makefile */
+	#if defined(STRGEN)
+		#include "endian_host.h"
+	#else
+		#include "endian_target.h"
+	#endif
+#endif /* WIN32 || __OS2__ || WIN64 */
+
+/* Setup alignment and conversion macros */
+#if defined(TTD_BIG_ENDIAN)
+	#define FROM_BE16(x) (x)
+	#define FROM_BE32(x) (x)
+	#define TO_BE16(x)   (x)
+	#define TO_BE32(x)   (x)
+	#define TO_BE32X(x)  (x)
+	#define FROM_LE16(x) BSWAP16(x)
+	#define FROM_LE32(x) BSWAP32(x)
+	#define TO_LE16(x)   BSWAP16(x)
+	#define TO_LE32(x)   BSWAP32(x)
+	#define TO_LE32X(x)  BSWAP32(x)
+#else
+	#define FROM_BE16(x) BSWAP16(x)
+	#define FROM_BE32(x) BSWAP32(x)
+	#define TO_BE16(x)   BSWAP16(x)
+	#define TO_BE32(x)   BSWAP32(x)
+	#define TO_BE32X(x)  BSWAP32(x)
+	#define FROM_LE16(x) (x)
+	#define FROM_LE32(x) (x)
+	#define TO_LE16(x)   (x)
+	#define TO_LE32(x)   (x)
+	#define TO_LE32X(x)  (x)
+#endif /* TTD_BIG_ENDIAN */
+
+static inline uint16 ReadLE16Aligned(const void *x)
+{
+	return FROM_LE16(*(const uint16*)x);
+}
+
+static inline uint16 ReadLE16Unaligned(const void *x)
+{
+#ifdef OTTD_ALIGNMENT
+	return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
+#else
+	return FROM_LE16(*(const uint16*)x);
+#endif
+}
+
+#endif /* ENDIAN_FUNC_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/enum_type.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,115 @@
+/* $Id$ */
+
+/** @file enum_type.hpp Type (helpers) for enums */
+
+#ifndef ENUM_TYPE_HPP
+#define ENUM_TYPE_HPP
+
+/** Some enums need to have allowed incrementing (i.e. StationClassID) */
+#define DECLARE_POSTFIX_INCREMENT(type) \
+	FORCEINLINE type operator ++(type& e, int) \
+	{ \
+		type e_org = e; \
+		e = (type)((int)e + 1); \
+		return e_org; \
+	} \
+	FORCEINLINE type operator --(type& e, int) \
+	{ \
+		type e_org = e; \
+		e = (type)((int)e - 1); \
+		return e_org; \
+	}
+
+
+
+/** Operators to allow to work with enum as with type safe bit set in C++ */
+# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
+	FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
+	FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
+	FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
+	FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
+	FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
+	FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
+	FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
+
+
+/** Informative template class exposing basic enumeration properties used by several
+ *  other templates below. Here we have only forward declaration. For each enum type
+ *  we will create specialization derived from MakeEnumPropsT<>.
+ *  i.e.:
+ *    template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
+ *  followed by:
+ *    typedef TinyEnumT<Track> TrackByte;
+ */
+template <typename Tenum_t> struct EnumPropsT;
+
+/** Helper template class that makes basic properties of given enumeration type visible
+ *  from outsize. It is used as base class of several EnumPropsT specializations each
+ *  dedicated to one of commonly used enumeration types.
+ *  @param Tenum_t enumeration type that you want to describe
+ *  @param Tstorage_t what storage type would be sufficient (i.e. byte)
+ *  @param Tbegin first valid value from the contiguous range (i.e. TRACK_BEGIN)
+ *  @param Tend one past the last valid value from the contiguous range (i.e. TRACK_END)
+ *  @param Tinvalid value used as invalid value marker (i.e. INVALID_TRACK)
+ */
+template <typename Tenum_t, typename Tstorage_t, Tenum_t Tbegin, Tenum_t Tend, Tenum_t Tinvalid>
+struct MakeEnumPropsT {
+	typedef Tenum_t type;                     ///< enum type (i.e. Trackdir)
+	typedef Tstorage_t storage;               ///< storage type (i.e. byte)
+	static const Tenum_t begin = Tbegin;      ///< lowest valid value (i.e. TRACKDIR_BEGIN)
+	static const Tenum_t end = Tend;          ///< one after the last valid value (i.e. TRACKDIR_END)
+	static const Tenum_t invalid = Tinvalid;  ///< what value is used as invalid value (i.e. INVALID_TRACKDIR)
+};
+
+
+
+/** In some cases we use byte or uint16 to store values that are defined as enum. It is
+	*  necessary in order to control the sizeof() such values. Some compilers make enum
+	*  the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
+	*  compiler type-checking causes errors like:
+	*     'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
+	*  u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
+	*  to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
+template <typename Tenum_t> struct TinyEnumT;
+
+/** The general declaration of TinyEnumT<> (above) */
+template <typename Tenum_t> struct TinyEnumT
+{
+	typedef Tenum_t enum_type;                      ///< expose our enumeration type (i.e. Trackdir) to outside
+	typedef EnumPropsT<Tenum_t> Props;              ///< make easier access to our enumeration propeties
+	typedef typename Props::storage storage_type;   ///< small storage type
+	static const enum_type begin = Props::begin;    ///< enum beginning (i.e. TRACKDIR_BEGIN)
+	static const enum_type end = Props::end;        ///< enum end (i.e. TRACKDIR_END)
+	static const enum_type invalid = Props::invalid;///< invalid value (i.e. INVALID_TRACKDIR)
+
+	storage_type m_val;  ///< here we hold the actual value in small (i.e. byte) form
+
+	/** Cast operator - invoked then the value is assigned to the Tenum_t type */
+	FORCEINLINE operator enum_type () const
+	{
+		return (enum_type)m_val;
+	}
+
+	/** Assignment operator (from Tenum_t type) */
+	FORCEINLINE TinyEnumT& operator = (enum_type e)
+	{
+		m_val = (storage_type)e; return *this;
+	}
+
+	/** postfix ++ operator on tiny type */
+	FORCEINLINE TinyEnumT operator ++ (int)
+	{
+		TinyEnumT org = *this;
+		if (++m_val >= end) m_val -= (storage_type)(end - begin);
+		return org;
+	}
+
+	/** prefix ++ operator on tiny type */
+	FORCEINLINE TinyEnumT& operator ++ ()
+	{
+		if (++m_val >= end) m_val -= (storage_type)(end - begin);
+		return *this;
+	}
+};
+
+#endif /* HELPERS_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/geometry_type.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,49 @@
+/* $Id$ */
+
+/** @file geometry_type.hpp All geometry types in OpenTTD. */
+
+#ifndef GEOMETRY_TYPE_HPP
+#define GEOMETRY_TYPE_HPP
+
+#if defined(__AMIGA__)
+	/* AmigaOS already has a Point declared */
+	#define Point OTTD_Point
+#endif /* __AMIGA__ */
+
+#if defined(__APPLE__)
+	/* Mac OS X already has both Rect and Point declared */
+	#define Rect OTTD_Rect
+	#define Point OTTD_Point
+#endif /* __APPLE__ */
+
+
+struct Point {
+	int x;
+	int y;
+};
+
+struct Dimension {
+	int width;
+	int height;
+};
+
+struct Rect {
+	int left;
+	int top;
+	int right;
+	int bottom;
+};
+
+struct PointDimension {
+	int x;
+	int y;
+	int width;
+	int height;
+};
+
+struct Pair {
+	int a;
+	int b;
+};
+
+#endif /* GEOMETRY_TYPE_HPP */
--- a/src/core/math_func.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/core/math_func.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,6 +1,6 @@
-/* $Id */
+/* $Id$ */
 
-/** @file math_func.hpp */
+/** @file math_func.hpp Integer math functions */
 
 #ifndef MATH_FUNC_HPP
 #define MATH_FUNC_HPP
@@ -82,7 +82,7 @@
  * @param a The value we want to unsign
  * @return The unsigned value
  */
-template <typename T> static inline T abs(T a)
+template <typename T> static inline T abs(const T a)
 {
 	return (a < (T)0) ? -a : a;
 }
@@ -175,7 +175,7 @@
  * @param b The second scalar
  * @return The absolute difference between the given scalars
  */
-template <typename T> static inline T delta(const T a, const T b) {
+template <typename T> static inline T Delta(const T a, const T b) {
 	return (a < b) ? b - a : a - b;
 }
 
@@ -191,39 +191,36 @@
  * @param size The size of the interval
  * @return True if the value is in the interval, false else.
  */
-template<typename T> static inline bool IS_INSIDE_1D(const T x, const int base, const uint size)
+template<typename T> static inline bool IsInsideBS(const T x, const uint base, const uint size)
 {
 	return (uint)(x - base) < size;
 }
 
 /**
- * Checks if a byte is in an interval.
+ * Checks if a value is in an interval.
  *
- * Returns true if a byte value is in the interval of [min, max).
+ * Returns true if a value is in the interval of [min, max).
  *
- * @param a The byte value to check
+ * @param a The value to check
  * @param min The minimum of the interval
  * @param max The maximum of the interval
- * @see IS_INSIDE_1D
+ * @see IsInsideBS()
  */
-template<typename T> static inline bool IS_BYTE_INSIDE(const T x, const byte min, const byte max)
-{
-	return (byte)(x - min) < (max - min);
-}
-
-/**
- * Checks if an int is in an interval.
- *
- * Returns true if a integer value is in the interval of [min, max).
- *
- * @param a The integer value to check
- * @param min The minimum of the interval
- * @param max The maximum of the interval
- * @see IS_INSIDE_1D
- */
-template<typename T> static inline bool IS_INT_INSIDE(const T x, const int min, const uint max)
+template<typename T> static inline bool IsInsideMM(const T x, const uint min, const uint max)
 {
 	return (uint)(x - min) < (max - min);
 }
 
+/**
+ * Type safe swap operation
+ * @param a variable to swap with b
+ * @param b variable to swap with a
+ */
+template<typename T> void Swap(T& a, T& b)
+{
+	T t = a;
+	a = b;
+	b = t;
+}
+
 #endif /* MATH_FUNC_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/overflowsafe_type.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,149 @@
+/* $Id$ */
+
+/** @file overflowsafe_type.hpp An overflow safe integer-like type. */
+
+#ifndef OVERFLOWSAFE_TYPE_HPP
+#define OVERFLOWSAFE_TYPE_HPP
+
+#include "math_func.hpp"
+
+/**
+ * Overflow safe template for integers, i.e. integers that will never overflow
+ * you multiply the maximum value with 2, or add 2, or substract somethng from
+ * the minimum value, etc.
+ * @param T     the type these integers are stored with.
+ * @param T_MAX the maximum value for the integers.
+ * @param T_MIN the minimum value for the integers.
+ */
+template <class T, T T_MAX, T T_MIN>
+class OverflowSafeInt
+{
+private:
+	/** The non-overflow safe backend to store the value in. */
+	T m_value;
+public:
+	OverflowSafeInt() : m_value(0) { }
+
+	OverflowSafeInt(const OverflowSafeInt& other) { this->m_value = other.m_value; }
+	OverflowSafeInt(const int64 int_)             { this->m_value = int_; }
+
+	FORCEINLINE OverflowSafeInt& operator = (const OverflowSafeInt& other) { this->m_value = other.m_value; return *this; }
+
+	FORCEINLINE OverflowSafeInt operator - () const { return OverflowSafeInt(-this->m_value); }
+
+	/**
+	 * Safe implementation of addition.
+	 * @param other the amount to add
+	 * @note when the addition would yield more than T_MAX (or less than T_MIN),
+	 *       it will be T_MAX (respectively T_MIN).
+	 */
+	FORCEINLINE OverflowSafeInt& operator += (const OverflowSafeInt& other)
+	{
+		if ((T_MAX - abs(other.m_value)) < abs(this->m_value) &&
+				(this->m_value < 0) == (other.m_value < 0)) {
+			this->m_value = (this->m_value < 0) ? T_MIN : T_MAX ;
+		} else {
+			this->m_value += other.m_value;
+		}
+		return *this;
+	}
+
+	/* Operators for addition and substraction */
+	FORCEINLINE OverflowSafeInt  operator +  (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result += other; return result; }
+	FORCEINLINE OverflowSafeInt  operator +  (const int              other) const { OverflowSafeInt result = *this; result += (int64)other; return result; }
+	FORCEINLINE OverflowSafeInt  operator +  (const uint             other) const { OverflowSafeInt result = *this; result += (int64)other; return result; }
+	FORCEINLINE OverflowSafeInt& operator -= (const OverflowSafeInt& other)       { return *this += (-other); }
+	FORCEINLINE OverflowSafeInt  operator -  (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result -= other; return result; }
+	FORCEINLINE OverflowSafeInt  operator -  (const int              other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; }
+	FORCEINLINE OverflowSafeInt  operator -  (const uint             other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; }
+
+	FORCEINLINE OverflowSafeInt& operator ++ () { return *this += 1; }
+	FORCEINLINE OverflowSafeInt& operator -- () { return *this += -1; }
+	FORCEINLINE OverflowSafeInt operator ++ (int) { OverflowSafeInt org = *this; *this += 1; return org; }
+	FORCEINLINE OverflowSafeInt operator -- (int) { OverflowSafeInt org = *this; *this += -1; return org; }
+
+	/**
+	 * Safe implementation of multiplication.
+	 * @param factor the factor to multiply this with.
+	 * @note when the multiplication would yield more than T_MAX (or less than T_MIN),
+	 *       it will be T_MAX (respectively T_MIN).
+	 */
+	FORCEINLINE OverflowSafeInt& operator *= (const int factor)
+	{
+		if (factor != 0 && (T_MAX / abs(factor)) < abs(this->m_value)) {
+			 this->m_value = ((this->m_value < 0) == (factor < 0)) ? T_MAX : T_MIN ;
+		} else {
+			this->m_value *= factor ;
+		}
+		return *this;
+	}
+
+	/* Operators for multiplication */
+	FORCEINLINE OverflowSafeInt operator * (const int64  factor) const { OverflowSafeInt result = *this; result *= factor; return result; }
+	FORCEINLINE OverflowSafeInt operator * (const int    factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
+	FORCEINLINE OverflowSafeInt operator * (const uint   factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
+	FORCEINLINE OverflowSafeInt operator * (const uint16 factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
+	FORCEINLINE OverflowSafeInt operator * (const byte   factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
+
+	/* Operators for division */
+	FORCEINLINE OverflowSafeInt& operator /= (const int              divisor)       { this->m_value /= divisor; return *this; }
+	FORCEINLINE OverflowSafeInt  operator /  (const OverflowSafeInt& divisor) const { OverflowSafeInt result = *this; result /= divisor.m_value; return result; }
+	FORCEINLINE OverflowSafeInt  operator /  (const int              divisor) const { OverflowSafeInt result = *this; result /= divisor; return result; }
+	FORCEINLINE OverflowSafeInt  operator /  (const uint             divisor) const { OverflowSafeInt result = *this; result /= (int)divisor; return result; }
+
+	/* Operators for modulo */
+	FORCEINLINE OverflowSafeInt& operator %= (const int  divisor)       { this->m_value %= divisor; return *this; }
+	FORCEINLINE OverflowSafeInt  operator %  (const int  divisor) const { OverflowSafeInt result = *this; result %= divisor; return result; }
+
+	/* Operators for shifting */
+	FORCEINLINE OverflowSafeInt& operator <<= (const int shift)       { this->m_value <<= shift; return *this; }
+	FORCEINLINE OverflowSafeInt  operator <<  (const int shift) const { OverflowSafeInt result = *this; result <<= shift; return result; }
+	FORCEINLINE OverflowSafeInt& operator >>= (const int shift)       { this->m_value >>= shift; return *this; }
+	FORCEINLINE OverflowSafeInt  operator >>  (const int shift) const { OverflowSafeInt result = *this; result >>= shift; return result; }
+
+	/* Operators for (in)equality when comparing overflow safe ints */
+	FORCEINLINE bool operator == (const OverflowSafeInt& other) const { return this->m_value == other.m_value; }
+	FORCEINLINE bool operator != (const OverflowSafeInt& other) const { return !(*this == other); }
+	FORCEINLINE bool operator >  (const OverflowSafeInt& other) const { return this->m_value > other.m_value; }
+	FORCEINLINE bool operator >= (const OverflowSafeInt& other) const { return this->m_value >= other.m_value; }
+	FORCEINLINE bool operator <  (const OverflowSafeInt& other) const { return !(*this >= other); }
+	FORCEINLINE bool operator <= (const OverflowSafeInt& other) const { return !(*this > other); }
+
+	/* Operators for (in)equality when comparing non-overflow safe ints */
+	FORCEINLINE bool operator == (const int other) const { return this->m_value == other; }
+	FORCEINLINE bool operator != (const int other) const { return !(*this == other); }
+	FORCEINLINE bool operator >  (const int other) const { return this->m_value > other; }
+	FORCEINLINE bool operator >= (const int other) const { return this->m_value >= other; }
+	FORCEINLINE bool operator <  (const int other) const { return !(*this >= other); }
+	FORCEINLINE bool operator <= (const int other) const { return !(*this > other); }
+
+	FORCEINLINE operator int64 () const { return this->m_value; }
+};
+
+/* Sometimes we got int64 operator OverflowSafeInt instead of vice versa. Handle that properly */
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
+
+/* Sometimes we got int operator OverflowSafeInt instead of vice versa. Handle that properly */
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (int   a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (int   a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (int   a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (int   a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
+
+/* Sometimes we got uint operator OverflowSafeInt instead of vice versa. Handle that properly */
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (uint  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (uint  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (uint  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (uint  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
+
+/* Sometimes we got byte operator OverflowSafeInt instead of vice versa. Handle that properly */
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (byte  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (byte  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (byte  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
+template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (byte  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
+
+typedef OverflowSafeInt<int64, INT64_MAX, INT64_MIN> OverflowSafeInt64;
+
+#endif /* OVERFLOWSAFE_TYPE_HPP */
--- a/src/core/random_func.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/core/random_func.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,9 +3,10 @@
 /** @file random_func.cpp */
 
 #include "../stdafx.h"
-#include "../macros.h"
-#include "../variables.h"
 #include "random_func.hpp"
+#include "bitmath_func.hpp"
+
+uint32 _random_seeds[2][2];
 
 uint32 InteractiveRandom()
 {
@@ -125,7 +126,7 @@
 }
 
 #ifdef RANDOM_DEBUG
-#include "network/network_data.h"
+#include "../network/network_data.h"
 uint32 DoRandom(int line, const char *file)
 {
 	if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server))
--- a/src/core/random_func.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/core/random_func.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,11 @@
 #ifndef RANDOM_FUNC_HPP
 #define RANDOM_FUNC_HPP
 
+#if defined(__APPLE__)
+	/* Apple already has Random declared */
+	#define Random OTTD_Random
+#endif /* __APPLE__ */
+
 /**************
  * Warning: DO NOT enable this unless you understand what it does
  *
@@ -36,4 +41,65 @@
 uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
 uint InteractiveRandomRange(uint max);
 
+/**
+ * Checks if a given randomize-number is below a given probability.
+ *
+ * This function is used to check if the given probability by the fraction of (a/b)
+ * is greater than low 16 bits of the given randomize-number v.
+ *
+ * Do not use this function twice on the same random 16 bits as it will yield
+ * the same result. One can use a random number for two calls to Chance16I,
+ * where one call sends the low 16 bits and the other the high 16 bits.
+ *
+ * @param a The numerator of the fraction
+ * @param b The denominator of the fraction, must of course not be null
+ * @param r The given randomize-number
+ * @return True if v is less or equals (a/b)
+ */
+static inline bool Chance16I(const uint a, const uint b, const uint32 r)
+{
+	assert(b != 0);
+	return (uint16)r < (uint16)((a << 16) / b);
+}
+
+/**
+ * Flips a coin with a given probability.
+ *
+ * This macro can be used to get true or false randomized according to a
+ * given probability. The parameter a and b create a percent value with
+ * (a/b). The macro returns true in (a/b) percent.
+ *
+ * @see Chance16I()
+ * @param a The numerator of the fraction
+ * @param b The denominator of the fraction
+ * @return True in (a/b) percent
+ */
+static inline bool Chance16(const uint a, const uint b)
+{
+	return Chance16I(a, b, Random());
+}
+
+/**
+ * Flips a coin with a given probability and saves the randomize-number in a variable.
+ *
+ * This function uses the same parameters as Chance16. The third parameter
+ * must be a variable the randomize-number from Random() is saved in.
+ *
+ * The low 16 bits of r will already be used and can therefor not be passed to
+ * Chance16I. One can only send the high 16 bits to Chance16I.
+ *
+ * @see Chance16I()
+ * @param a The numerator of the fraction
+ * @param b The denominator of the fraction
+ * @param r The variable to save the randomize-number from Random()
+ * @return True in (a/b) percent
+ */
+static inline bool Chance16R(const uint a, const uint b, uint32 &r)
+{
+	r = Random();
+	return Chance16I(a, b, r);
+}
+
+extern uint32 _random_seeds[2][2];
+
 #endif /* RANDOM_FUNC_HPP */
--- a/src/currency.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/currency.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,7 +8,7 @@
 #include "news.h"
 #include "variables.h"
 #include "table/strings.h"
-#include "date.h"
+#include "date_func.h"
 
 	//   exchange rate    prefix             symbol_pos
 	//   |  separator        |     postfix   |
--- a/src/currency.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/currency.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef CURRENCY_H
 #define CURRENCY_H
 
+#include "date_type.h"
+
 enum {
 	CF_NOEURO = 0,
 	CF_ISEURO = 1,
--- a/src/date.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/date.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,17 +4,18 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "date.h"
 #include "variables.h"
-#include "macros.h"
-#include "vehicle.h"
 #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"
+#include "date_func.h"
+#include "vehicle_base.h"
 #ifdef DEBUG_DUMP_COMMANDS
 #include "saveload.h"
+#include "town_map.h"
 #endif
 
 Year      _cur_year;
@@ -267,6 +268,17 @@
 	/* yes, call various monthly loops */
 	if (_game_mode != GM_MENU) {
 #ifdef DEBUG_DUMP_COMMANDS
+		std::map<TownID, uint32> town_pop;
+		for (TileIndex t = 0; t < MapSize(); t++) {
+			if (GetTileType(t) == MP_HOUSE && IsHouseCompleted(t)) {
+				uint32 pop = GetHouseSpecs(GetHouseType(t))->population;
+				town_pop[GetTownIndex(t)] += pop;
+			}
+		}
+
+		Town *t;
+		FOR_ALL_TOWNS(t) assert(t->population == town_pop[t->index]);
+
 		char name[MAX_PATH];
 		snprintf(name, lengthof(name), "dmp_cmds_%d.sav", _date);
 		SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
--- a/src/date.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/* $Id$ */
-
-/** @file date.h */
-
-#ifndef DATE_H
-#define DATE_H
-
-#include "openttd.h"
-
-/**
- * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On
- *                    an overflow the new day begun and 65535 / 885 = 74.
- * 1 tick is approximately 30 ms.
- * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally
- */
-#define DAY_TICKS 74
-
-/*
- * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
- * primarily used for loading newgrf and savegame data and returning some
- * newgrf (callback) functions that were in the original (TTD) inherited
- * format, where '_date == 0' meant that it was 1920-01-01.
- */
-
-/** The minimum starting year/base year of the original TTD */
-#define ORIGINAL_BASE_YEAR 1920
-/** The maximum year of the original TTD */
-#define ORIGINAL_MAX_YEAR 2090
-
-/**
- * The offset in days from the '_date == 0' till
- * 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'
- */
-#define DAYS_TILL_ORIGINAL_BASE_YEAR (365 * ORIGINAL_BASE_YEAR + ORIGINAL_BASE_YEAR / 4 - ORIGINAL_BASE_YEAR / 100 + ORIGINAL_BASE_YEAR / 400)
-
-/* The absolute minimum & maximum years in OTTD */
-#define MIN_YEAR 0
-/* MAX_YEAR, nicely rounded value of the number of years that can
- * be encoded in a single 32 bits date, about 2^31 / 366 years. */
-#define MAX_YEAR 5000000
-
-/* Year and Date are defined elsewhere */
-typedef uint8  Month;
-typedef uint8  Day;
-typedef uint16 DateFract;
-
-struct YearMonthDay {
-	Year  year;
-	Month month;
-	Day   day;
-};
-
-extern Year      _cur_year;
-extern Month     _cur_month;
-extern Date      _date;
-extern DateFract _date_fract;
-
-
-void SetDate(Date date);
-void ConvertDateToYMD(Date date, YearMonthDay *ymd);
-Date ConvertYMDToDate(Year year, Month month, Day day);
-
-#endif /* DATE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/date_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+/** @file date_func.h Functions related to dates. */
+
+#ifndef DATE_FUNC_H
+#define DATE_FUNC_H
+
+#include "date_type.h"
+
+extern Year      _cur_year;
+extern Month     _cur_month;
+extern Date      _date;
+extern DateFract _date_fract;
+
+void SetDate(Date date);
+void ConvertDateToYMD(Date date, YearMonthDay *ymd);
+Date ConvertYMDToDate(Year year, Month month, Day day);
+
+#endif /* DATE_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/date_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,56 @@
+/* $Id$ */
+
+/** @file date_type.h Types related to the dates in OpenTTD. */
+
+#ifndef DATE_TYPE_H
+#define DATE_TYPE_H
+
+/**
+ * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On
+ *                    an overflow the new day begun and 65535 / 885 = 74.
+ * 1 tick is approximately 30 ms.
+ * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally
+ */
+#define DAY_TICKS 74
+
+/*
+ * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
+ * primarily used for loading newgrf and savegame data and returning some
+ * newgrf (callback) functions that were in the original (TTD) inherited
+ * format, where '_date == 0' meant that it was 1920-01-01.
+ */
+
+/** The minimum starting year/base year of the original TTD */
+#define ORIGINAL_BASE_YEAR 1920
+/** The maximum year of the original TTD */
+#define ORIGINAL_MAX_YEAR 2090
+
+/**
+ * The offset in days from the '_date == 0' till
+ * 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'
+ */
+#define DAYS_TILL_ORIGINAL_BASE_YEAR (365 * ORIGINAL_BASE_YEAR + ORIGINAL_BASE_YEAR / 4 - ORIGINAL_BASE_YEAR / 100 + ORIGINAL_BASE_YEAR / 400)
+
+/* The absolute minimum & maximum years in OTTD */
+#define MIN_YEAR 0
+/* MAX_YEAR, nicely rounded value of the number of years that can
+ * be encoded in a single 32 bits date, about 2^31 / 366 years. */
+#define MAX_YEAR 5000000
+
+typedef int32  Date;
+typedef uint16 DateFract;
+
+typedef int32  Year;
+typedef uint8  Month;
+typedef uint8  Day;
+
+struct YearMonthDay {
+	Year  year;
+	Month month;
+	Day   day;
+};
+
+static const Year INVALID_YEAR = -1;
+static const Date INVALID_DATE = -1;
+
+#endif /* DATE_TYPE_H */
--- a/src/debug.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/debug.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,8 +8,7 @@
 #include "openttd.h"
 #include "console.h"
 #include "debug.h"
-#include "functions.h"
-#include "string.h"
+#include "string_func.h"
 #include "network/core/core.h"
 
 #if defined(ENABLE_NETWORK)
@@ -163,7 +162,7 @@
 const char *GetDebugString()
 {
 	const DebugLevel *i;
-	static char dbgstr[100];
+	static char dbgstr[150];
 	char dbgval[20];
 
 	memset(dbgstr, 0, sizeof(dbgstr));
--- a/src/debug.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/debug.h	Wed Jan 09 18:11:12 2008 +0000
@@ -129,4 +129,7 @@
 	}\
 }
 
+void ShowInfo(const char *str);
+void CDECL ShowInfoF(const char *str, ...);
+
 #endif /* DEBUG_H */
--- a/src/depot.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/depot.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,15 +4,12 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "vehicle.h"
 #include "depot.h"
-#include "functions.h"
 #include "landscape.h"
-#include "tile.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.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/depot.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,10 +5,8 @@
 #ifndef DEPOT_H
 #define DEPOT_H
 
-#include "direction.h"
+#include "direction_type.h"
 #include "oldpool.h"
-#include "tile.h"
-#include "variables.h"
 #include "road_map.h"
 #include "rail_map.h"
 #include "water_map.h"
@@ -37,23 +35,6 @@
 #define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
 
-#define MIN_SERVINT_PERCENT  5
-#define MAX_SERVINT_PERCENT 90
-#define MIN_SERVINT_DAYS    30
-#define MAX_SERVINT_DAYS   800
-
-/**
- * Get the service interval domain.
- * Get the new proposed service interval for the vehicle is indeed, clamped
- * within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
- * @param index proposed service interval
- * @return service interval
- */
-static inline Date GetServiceIntervalClamped(uint index)
-{
-	return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
-}
-
 /**
  * Check if a tile is a depot of the given type.
  */
--- a/src/depot_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/depot_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,24 +4,25 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "train.h"
 #include "roadveh.h"
 #include "ship.h"
 #include "aircraft.h"
 #include "table/strings.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "gui.h"
-#include "gfx.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "command.h"
+#include "textbuf_gui.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
+#include "command_func.h"
 #include "depot.h"
 #include "vehicle_gui.h"
 #include "station_map.h"
 #include "newgrf_engine.h"
 #include "spritecache.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "vehicle_func.h"
 
 /*
  * Since all depot window sizes aren't the same, we need to modify sizes a little.
@@ -171,14 +172,14 @@
 
 	switch (v->type) {
 		case VEH_TRAIN:
-			DrawTrainImage(v, x + 21, sprite_y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,depot_d).sel);
+			DrawTrainImage(v, x + 21, sprite_y, WP(w, depot_d).sel, w->hscroll.cap + 4, w->hscroll.pos);
 
 			/* Number of wagons relative to a standard length wagon (rounded up) */
 			SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);
 			DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter
 			break;
 
-		case VEH_ROAD:     DrawRoadVehImage( v, x + 24, sprite_y, 1, WP(w, depot_d).sel); break;
+		case VEH_ROAD:     DrawRoadVehImage( v, x + 24, sprite_y, WP(w, depot_d).sel, 1); break;
 		case VEH_SHIP:     DrawShipImage(    v, x + 19, sprite_y - 1, WP(w, depot_d).sel); break;
 		case VEH_AIRCRAFT: {
 			const Sprite *spr = GetSprite(v->GetImage(DIR_W));
@@ -216,7 +217,7 @@
 	uint16 boxes_in_each_row = w->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
 
 	/* setup disabled buttons */
-	SetWindowWidgetsDisabledState(w, !IsTileOwner(tile, _local_player),
+	w->SetWidgetsDisabledState(!IsTileOwner(tile, _local_player),
 		DEPOT_WIDGET_STOP_ALL,
 		DEPOT_WIDGET_START_ALL,
 		DEPOT_WIDGET_SELL,
@@ -273,7 +274,7 @@
 		const Vehicle *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count];
 		const Vehicle *u;
 
-		DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w,depot_d).sel);
+		DrawTrainImage(v, x + 50, y, WP(w, depot_d).sel, w->hscroll.cap - 29, 0);
 		DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
 
 		/*Draw the train counter */
@@ -290,14 +291,14 @@
 	Vehicle *wagon;
 };
 
-enum {
-	MODE_ERROR        =  1,
-	MODE_DRAG_VEHICLE =  0,
-	MODE_SHOW_VEHICLE = -1,
-	MODE_START_STOP   = -2,
+enum DepotGUIAction {
+	MODE_ERROR,
+	MODE_DRAG_VEHICLE,
+	MODE_SHOW_VEHICLE,
+	MODE_START_STOP,
 };
 
-static int GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh, GetDepotVehiclePtData *d)
+static DepotGUIAction GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh, GetDepotVehiclePtData *d)
 {
 	Vehicle **vl = WP(w, depot_d).vehicle_list;
 	uint xt, row, xm = 0, ym = 0;
@@ -411,10 +412,10 @@
 {
 	GetDepotVehiclePtData gdvp;
 	Vehicle *v = NULL;
-	int mode = GetVehicleFromDepotWndPt(w, x, y, &v, &gdvp);
+	DepotGUIAction mode = GetVehicleFromDepotWndPt(w, x, y, &v, &gdvp);
 
 	/* share / copy orders */
-	if (_thd.place_mode != VHM_NONE && mode <= 0) {
+	if (_thd.place_mode != VHM_NONE && mode != MODE_ERROR) {
 		_place_clicked_vehicle = (WP(w, depot_d).type == VEH_TRAIN ? gdvp.head : v);
 		return;
 	}
@@ -429,7 +430,7 @@
 			VehicleID sel = WP(w, depot_d).sel;
 
 			if (WP(w, depot_d).type == VEH_TRAIN && sel != INVALID_VEHICLE) {
-				WP(w,depot_d).sel = INVALID_VEHICLE;
+				WP(w, depot_d).sel = INVALID_VEHICLE;
 				TrainDepotMoveVehicle(v, sel, gdvp.head);
 			} else if (v != NULL) {
 				int image = v->GetImage(DIR_W);
@@ -724,7 +725,7 @@
 		+ (type == VEH_TRAIN ? 1 : w->hscroll.cap); // number of boxes in each row. Trains always have just one
 
 
-	SetWindowWidgetsHiddenState(w, type != VEH_TRAIN,
+	w->SetWidgetsHiddenState(type != VEH_TRAIN,
 		DEPOT_WIDGET_H_SCROLL,
 		DEPOT_WIDGET_SELL_CHAIN,
 		WIDGET_LIST_END);
@@ -794,10 +795,10 @@
 					break;
 
 				case DEPOT_WIDGET_CLONE: // Clone button
-					InvalidateWidget(w, DEPOT_WIDGET_CLONE);
-					ToggleWidgetLoweredState(w, DEPOT_WIDGET_CLONE);
+					w->InvalidateWidget(DEPOT_WIDGET_CLONE);
+					w->ToggleWidgetLoweredState(DEPOT_WIDGET_CLONE);
 
-					if (IsWindowWidgetLowered(w, DEPOT_WIDGET_CLONE)) {
+					if (w->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
 						static const CursorID clone_icons[] = {
 							SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
 							SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
@@ -855,8 +856,8 @@
 		} break;
 
 		case WE_ABORT_PLACE_OBJ: {
-			RaiseWindowWidget(w, DEPOT_WIDGET_CLONE);
-			InvalidateWidget(w, DEPOT_WIDGET_CLONE);
+			w->RaiseWidget(DEPOT_WIDGET_CLONE);
+			w->InvalidateWidget(DEPOT_WIDGET_CLONE);
 		} break;
 
 			/* check if a vehicle in a depot was clicked.. */
@@ -864,7 +865,7 @@
 			const Vehicle *v = _place_clicked_vehicle;
 
 			/* since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button */
-			if (v != NULL && IsWindowWidgetLowered(w, DEPOT_WIDGET_CLONE)) {
+			if (v != NULL && w->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
 				_place_clicked_vehicle = NULL;
 				HandleCloneVehClick(v, w);
 			}
@@ -906,17 +907,17 @@
 				} break;
 
 				case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
-					if (!IsWindowWidgetDisabled(w, DEPOT_WIDGET_SELL) &&
+					if (!w->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
 						WP(w, depot_d).sel != INVALID_VEHICLE) {
 						Vehicle *v;
 						uint command;
 						int sell_cmd;
 						bool is_engine;
 
-						if (IsWindowWidgetDisabled(w, e->we.click.widget)) return;
+						if (w->IsWidgetDisabled(e->we.click.widget)) return;
 						if (WP(w, depot_d).sel == INVALID_VEHICLE) return;
 
-						HandleButtonClick(w, e->we.click.widget);
+						w->HandleButtonClick(e->we.click.widget);
 
 						v = GetVehicle(WP(w, depot_d).sel);
 						WP(w, depot_d).sel = INVALID_VEHICLE;
--- a/src/direction.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,322 +0,0 @@
-/* $Id$ */
-
-/** @file direction.h */
-
-#ifndef DIRECTION_H
-#define DIRECTION_H
-
-#include "helpers.hpp"
-
-/**
- * Defines the 8 directions on the map.
- *
- * This enum defines 8 possible directions which are used for
- * the vehicles in the game. The directions are aligned straight
- * to the viewport, not to the map. So north points to the top of
- * your viewport and not rotated by 45 degrees left or right to get
- * a "north" used in you games.
- */
-enum Direction {
-	DIR_BEGIN = 0,          ///< Used to iterate
-	DIR_N   = 0,            ///< North
-	DIR_NE  = 1,            ///< Northeast
-	DIR_E   = 2,            ///< East
-	DIR_SE  = 3,            ///< Southeast
-	DIR_S   = 4,            ///< South
-	DIR_SW  = 5,            ///< Southwest
-	DIR_W   = 6,            ///< West
-	DIR_NW  = 7,            ///< Northwest
-	DIR_END,                ///< Used to iterate
-	INVALID_DIR = 0xFF,     ///< Flag for an invalid direction
-};
-
-/** Define basic enum properties */
-template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR> {};
-typedef TinyEnumT<Direction> DirectionByte; //typedefing-enumification of Direction
-
-/**
- * Return the reverse of a direction
- *
- * @param d The direction to get the reverse from
- * @return The reverse Direction
- */
-static inline Direction ReverseDir(Direction d)
-{
-	return (Direction)(4 ^ d);
-}
-
-
-/**
- * Enumeration for the difference between two directions.
- *
- * This enumeration is used to mark differences between
- * two directions. If you get one direction you can align
- * a second direction in 8 different ways. This enumeration
- * only contains 6 of these 8 differences, but the remaining
- * two can be calculated by adding to differences together.
- * This also means you can add two differences together and
- * get the difference you really want to get. The difference
- * of 45 degrees left + the difference of 45 degrees right results in the
- * difference of 0 degrees.
- *
- * @note To get this mentioned addition of direction you must use
- *       modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
- * @see ChangeDirDiff(DirDiff, DirDiff)
- */
-enum DirDiff {
-	DIRDIFF_SAME    = 0,    ///< Both directions faces to the same direction
-	DIRDIFF_45RIGHT = 1,    ///< Angle of 45 degrees right
-	DIRDIFF_90RIGHT = 2,    ///< Angle of 90 degrees right
-	DIRDIFF_REVERSE = 4,    ///< One direction is the opposit of the other one
-	DIRDIFF_90LEFT  = 6,    ///< Angle of 90 degrees left
-	DIRDIFF_45LEFT  = 7     ///< Angle of 45 degrees left
-};
-
-/**
- * Calculate the difference between to directions
- *
- * @param d0 The first direction as the base
- * @param d1 The second direction as the offset from the base
- * @return The difference how the second directions drifts of the first one.
- */
-static inline DirDiff DirDifference(Direction d0, Direction d1)
-{
-	return (DirDiff)((d0 + 8 - d1) % 8);
-}
-
-/**
- * Applies two differences together
- *
- * This function adds two differences together and return the resulting
- * difference. So adding two DIRDIFF_REVERSE together results in the
- * DIRDIFF_SAME difference.
- *
- * @param d The first difference
- * @param delta The second difference to add on
- * @return The resulting difference
- */
-static inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta)
-{
-	return (DirDiff)((d + delta) % 8);
-}
-
-/**
- * Change a direction by a given difference
- *
- * This functions returns a new direction of the given direction
- * which is rotated by the given difference.
- *
- * @param d The direction to get a new direction from
- * @param delta The offset/drift applied to the direction
- * @return The new direction
- */
-static inline Direction ChangeDir(Direction d, DirDiff delta)
-{
-	return (Direction)((d + delta) % 8);
-}
-
-
-/**
- * Enumeration for diagonal directions.
- *
- * This enumeration is used for the 4 direction of the tile-edges.
- */
-enum DiagDirection {
-	DIAGDIR_BEGIN = 0,      ///< Used for iterations
-	DIAGDIR_NE  = 0,        ///< Northeast, upper right on your monitor
-	DIAGDIR_SE  = 1,        ///< Southeast
-	DIAGDIR_SW  = 2,        ///< Southwest
-	DIAGDIR_NW  = 3,        ///< Northwest
-	DIAGDIR_END,            ///< Used for iterations
-	INVALID_DIAGDIR = 0xFF, ///< Flag for an invalid DiagDirection
-};
-
-DECLARE_POSTFIX_INCREMENT(DiagDirection);
-
-/** Define basic enum properties */
-template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR> {};
-typedef TinyEnumT<DiagDirection> DiagDirectionByte; //typedefing-enumification of DiagDirection
-
-/**
- * Returns the reverse direction of the given DiagDirection
- *
- * @param d The DiagDirection to get the reverse from
- * @return The reverse direction
- */
-static inline DiagDirection ReverseDiagDir(DiagDirection d)
-{
-	return (DiagDirection)(2 ^ d);
-}
-
-/**
- * Enumeration for the difference between to DiagDirection.
- *
- * As the DiagDirection only contains 4 possible directions the
- * difference between two of these directions can only be in 4 ways.
- * As the DirDiff enumeration the values can be added together and
- * you will get the resulting difference (use modulo DIAGDIR_END).
- *
- * @see DirDiff
- */
-enum DiagDirDiff {
-	DIAGDIRDIFF_SAME    = 0,        ///< Same directions
-	DIAGDIRDIFF_90RIGHT = 1,        ///< 90 degrees right
-	DIAGDIRDIFF_REVERSE = 2,        ///< Reverse directions
-	DIAGDIRDIFF_90LEFT  = 3         ///< 90 degrees left
-};
-
-/** Allow incrementing of DiagDirDiff variables */
-DECLARE_POSTFIX_INCREMENT(DiagDirDiff);
-
-/**
- * Applies a difference on a DiagDirection
- *
- * This function applies a difference on a DiagDirection and returns
- * the new DiagDirection.
- *
- * @param d The DiagDirection
- * @param delta The difference to applie on
- * @return The new direction which was calculated
- */
-static inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
-{
-	return (DiagDirection)((d + delta) % 4);
-}
-
-/**
- * Convert a Direction to a DiagDirection.
- *
- * This function can be used to convert the 8-way Direction to
- * the 4-way DiagDirection. If the direction cannot be mapped its
- * "rounded clockwise". So DIR_N becomes DIAGDIR_NE.
- *
- * @param dir The direction to convert
- * @return The resulting DiagDirection, maybe "rounded clockwise".
- */
-static inline DiagDirection DirToDiagDir(Direction dir)
-{
-	return (DiagDirection)(dir >> 1);
-}
-
-/**
- * Convert a DiagDirection to a Direction.
- *
- * This function can be used to convert the 4-way DiagDirection
- * to the 8-way Direction. As 4-way are less than 8-way not all
- * possible directions can be calculated.
- *
- * @param dir The direction to convert
- * @return The resulting Direction
- */
-static inline Direction DiagDirToDir(DiagDirection dir)
-{
-	return (Direction)(dir * 2 + 1);
-}
-
-
-/**
- * Enumeration for the two axis X and Y
- *
- * This enumeration represente the two axis X and Y in the game.
- * The X axis is the one which goes align the north-west edge
- * (and south-east edge). The Y axis must be so the one which goes
- * align the north-east edge (and south-west) edge.
- */
-enum Axis {
-	AXIS_X = 0,     ///< The X axis
-	AXIS_Y = 1,     ///< The y axis
-	AXIS_END        ///< Used for iterations
-};
-
-
-/**
- * Select the other axis as provided.
- *
- * This is basically the not-operator for the axis.
- *
- * @param a The given axis
- * @return The other axis
- */
-static inline Axis OtherAxis(Axis a)
-{
-	return (Axis)(a ^ 1);
-}
-
-
-/**
- * Convert a DiagDirection to the axis.
- *
- * This function returns the axis which belongs to the given
- * DiagDirection. The axis X belongs to the DiagDirection
- * north-east and south-west.
- *
- * @param d The DiagDirection
- * @return The axis which belongs to the direction
- */
-static inline Axis DiagDirToAxis(DiagDirection d)
-{
-	return (Axis)(d & 1);
-}
-
-
-/**
- * Converts an Axis to a DiagDirection
- *
- * This function returns the DiagDirection which
- * belongs to the axis. As 2 directions are mapped to an axis
- * this function returns the one which points to south,
- * either south-west (on X axis) or south-east (on Y axis)
- *
- * @param a The axis
- * @return The direction pointed to south
- */
-static inline DiagDirection AxisToDiagDir(Axis a)
-{
-	return (DiagDirection)(2 - a);
-}
-
-/**
- * Convert an axis and a flag for north/south into a DiagDirection
- * @param xy axis to convert
- * @param ns north -> 0, south -> 1
- * @return the desired DiagDirection
- */
-static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
-{
-	return (DiagDirection)(xy * 3 ^ ns * 2);
-}
-
-/**
- * Checks if an interger value is a valid DiagDirection
- *
- * @param d The value to check
- * @return True if the value belongs to a DiagDirection, else false
- */
-static inline bool IsValidDiagDirection(DiagDirection d)
-{
-	return d < DIAGDIR_END;
-}
-
-/**
- * Checks if an integer value is a valid Direction
- *
- * @param d The value to check
- * @return True if the value belongs to a Direction, else false
- */
-static inline bool IsValidDirection(Direction d)
-{
-	return d < DIR_END;
-}
-
-/**
- * Checks if an integer value is a valid Axis
- *
- * @param d The value to check
- * @return True if the value belongs to an Axis, else false
- */
-static inline bool IsValidAxis(Axis d)
-{
-	return d < AXIS_END;
-}
-
-#endif /* DIRECTION_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/direction_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,214 @@
+/* $Id$ */
+
+/** @file direction_func.h Different functions related to conversions between directions. */
+
+#ifndef DIRECTION_FUNC_H
+#define DIRECTION_FUNC_H
+
+#include "direction_type.h"
+
+/**
+ * Return the reverse of a direction
+ *
+ * @param d The direction to get the reverse from
+ * @return The reverse Direction
+ */
+static inline Direction ReverseDir(Direction d)
+{
+	return (Direction)(4 ^ d);
+}
+
+
+/**
+ * Calculate the difference between to directions
+ *
+ * @param d0 The first direction as the base
+ * @param d1 The second direction as the offset from the base
+ * @return The difference how the second directions drifts of the first one.
+ */
+static inline DirDiff DirDifference(Direction d0, Direction d1)
+{
+	return (DirDiff)((d0 + 8 - d1) % 8);
+}
+
+/**
+ * Applies two differences together
+ *
+ * This function adds two differences together and return the resulting
+ * difference. So adding two DIRDIFF_REVERSE together results in the
+ * DIRDIFF_SAME difference.
+ *
+ * @param d The first difference
+ * @param delta The second difference to add on
+ * @return The resulting difference
+ */
+static inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta)
+{
+	return (DirDiff)((d + delta) % 8);
+}
+
+/**
+ * Change a direction by a given difference
+ *
+ * This functions returns a new direction of the given direction
+ * which is rotated by the given difference.
+ *
+ * @param d The direction to get a new direction from
+ * @param delta The offset/drift applied to the direction
+ * @return The new direction
+ */
+static inline Direction ChangeDir(Direction d, DirDiff delta)
+{
+	return (Direction)((d + delta) % 8);
+}
+
+
+/**
+ * Returns the reverse direction of the given DiagDirection
+ *
+ * @param d The DiagDirection to get the reverse from
+ * @return The reverse direction
+ */
+static inline DiagDirection ReverseDiagDir(DiagDirection d)
+{
+	return (DiagDirection)(2 ^ d);
+}
+
+
+/**
+ * Applies a difference on a DiagDirection
+ *
+ * This function applies a difference on a DiagDirection and returns
+ * the new DiagDirection.
+ *
+ * @param d The DiagDirection
+ * @param delta The difference to applie on
+ * @return The new direction which was calculated
+ */
+static inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
+{
+	return (DiagDirection)((d + delta) % 4);
+}
+
+/**
+ * Convert a Direction to a DiagDirection.
+ *
+ * This function can be used to convert the 8-way Direction to
+ * the 4-way DiagDirection. If the direction cannot be mapped its
+ * "rounded clockwise". So DIR_N becomes DIAGDIR_NE.
+ *
+ * @param dir The direction to convert
+ * @return The resulting DiagDirection, maybe "rounded clockwise".
+ */
+static inline DiagDirection DirToDiagDir(Direction dir)
+{
+	return (DiagDirection)(dir >> 1);
+}
+
+/**
+ * Convert a DiagDirection to a Direction.
+ *
+ * This function can be used to convert the 4-way DiagDirection
+ * to the 8-way Direction. As 4-way are less than 8-way not all
+ * possible directions can be calculated.
+ *
+ * @param dir The direction to convert
+ * @return The resulting Direction
+ */
+static inline Direction DiagDirToDir(DiagDirection dir)
+{
+	return (Direction)(dir * 2 + 1);
+}
+
+
+/**
+ * Select the other axis as provided.
+ *
+ * This is basically the not-operator for the axis.
+ *
+ * @param a The given axis
+ * @return The other axis
+ */
+static inline Axis OtherAxis(Axis a)
+{
+	return (Axis)(a ^ 1);
+}
+
+
+/**
+ * Convert a DiagDirection to the axis.
+ *
+ * This function returns the axis which belongs to the given
+ * DiagDirection. The axis X belongs to the DiagDirection
+ * north-east and south-west.
+ *
+ * @param d The DiagDirection
+ * @return The axis which belongs to the direction
+ */
+static inline Axis DiagDirToAxis(DiagDirection d)
+{
+	return (Axis)(d & 1);
+}
+
+
+/**
+ * Converts an Axis to a DiagDirection
+ *
+ * This function returns the DiagDirection which
+ * belongs to the axis. As 2 directions are mapped to an axis
+ * this function returns the one which points to south,
+ * either south-west (on X axis) or south-east (on Y axis)
+ *
+ * @param a The axis
+ * @return The direction pointed to south
+ */
+static inline DiagDirection AxisToDiagDir(Axis a)
+{
+	return (DiagDirection)(2 - a);
+}
+
+/**
+ * Convert an axis and a flag for north/south into a DiagDirection
+ * @param xy axis to convert
+ * @param ns north -> 0, south -> 1
+ * @return the desired DiagDirection
+ */
+static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
+{
+	return (DiagDirection)(xy * 3 ^ ns * 2);
+}
+
+/**
+ * Checks if an interger value is a valid DiagDirection
+ *
+ * @param d The value to check
+ * @return True if the value belongs to a DiagDirection, else false
+ */
+static inline bool IsValidDiagDirection(DiagDirection d)
+{
+	return d < DIAGDIR_END;
+}
+
+/**
+ * Checks if an integer value is a valid Direction
+ *
+ * @param d The value to check
+ * @return True if the value belongs to a Direction, else false
+ */
+static inline bool IsValidDirection(Direction d)
+{
+	return d < DIR_END;
+}
+
+/**
+ * Checks if an integer value is a valid Axis
+ *
+ * @param d The value to check
+ * @return True if the value belongs to an Axis, else false
+ */
+static inline bool IsValidAxis(Axis d)
+{
+	return d < AXIS_END;
+}
+
+#endif /* DIRECTION_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/direction_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,122 @@
+/* $Id$ */
+
+/** @file direction_type.h Different types to 'show' directions. */
+
+#ifndef DIRECTION_TYPE_H
+#define DIRECTION_TYPE_H
+
+#include "core/enum_type.hpp"
+
+/**
+ * Defines the 8 directions on the map.
+ *
+ * This enum defines 8 possible directions which are used for
+ * the vehicles in the game. The directions are aligned straight
+ * to the viewport, not to the map. So north points to the top of
+ * your viewport and not rotated by 45 degrees left or right to get
+ * a "north" used in you games.
+ */
+enum Direction {
+	DIR_BEGIN = 0,          ///< Used to iterate
+	DIR_N   = 0,            ///< North
+	DIR_NE  = 1,            ///< Northeast
+	DIR_E   = 2,            ///< East
+	DIR_SE  = 3,            ///< Southeast
+	DIR_S   = 4,            ///< South
+	DIR_SW  = 5,            ///< Southwest
+	DIR_W   = 6,            ///< West
+	DIR_NW  = 7,            ///< Northwest
+	DIR_END,                ///< Used to iterate
+	INVALID_DIR = 0xFF,     ///< Flag for an invalid direction
+};
+
+/** Define basic enum properties */
+template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR> {};
+typedef TinyEnumT<Direction> DirectionByte; //typedefing-enumification of Direction
+
+
+/**
+ * Enumeration for the difference between two directions.
+ *
+ * This enumeration is used to mark differences between
+ * two directions. If you get one direction you can align
+ * a second direction in 8 different ways. This enumeration
+ * only contains 6 of these 8 differences, but the remaining
+ * two can be calculated by adding to differences together.
+ * This also means you can add two differences together and
+ * get the difference you really want to get. The difference
+ * of 45 degrees left + the difference of 45 degrees right results in the
+ * difference of 0 degrees.
+ *
+ * @note To get this mentioned addition of direction you must use
+ *       modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
+ * @see ChangeDirDiff(DirDiff, DirDiff)
+ */
+enum DirDiff {
+	DIRDIFF_SAME    = 0,    ///< Both directions faces to the same direction
+	DIRDIFF_45RIGHT = 1,    ///< Angle of 45 degrees right
+	DIRDIFF_90RIGHT = 2,    ///< Angle of 90 degrees right
+	DIRDIFF_REVERSE = 4,    ///< One direction is the opposit of the other one
+	DIRDIFF_90LEFT  = 6,    ///< Angle of 90 degrees left
+	DIRDIFF_45LEFT  = 7     ///< Angle of 45 degrees left
+};
+
+
+/**
+ * Enumeration for diagonal directions.
+ *
+ * This enumeration is used for the 4 direction of the tile-edges.
+ */
+enum DiagDirection {
+	DIAGDIR_BEGIN = 0,      ///< Used for iterations
+	DIAGDIR_NE  = 0,        ///< Northeast, upper right on your monitor
+	DIAGDIR_SE  = 1,        ///< Southeast
+	DIAGDIR_SW  = 2,        ///< Southwest
+	DIAGDIR_NW  = 3,        ///< Northwest
+	DIAGDIR_END,            ///< Used for iterations
+	INVALID_DIAGDIR = 0xFF, ///< Flag for an invalid DiagDirection
+};
+
+DECLARE_POSTFIX_INCREMENT(DiagDirection);
+
+/** Define basic enum properties */
+template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR> {};
+typedef TinyEnumT<DiagDirection> DiagDirectionByte; //typedefing-enumification of DiagDirection
+
+
+/**
+ * Enumeration for the difference between to DiagDirection.
+ *
+ * As the DiagDirection only contains 4 possible directions the
+ * difference between two of these directions can only be in 4 ways.
+ * As the DirDiff enumeration the values can be added together and
+ * you will get the resulting difference (use modulo DIAGDIR_END).
+ *
+ * @see DirDiff
+ */
+enum DiagDirDiff {
+	DIAGDIRDIFF_SAME    = 0,        ///< Same directions
+	DIAGDIRDIFF_90RIGHT = 1,        ///< 90 degrees right
+	DIAGDIRDIFF_REVERSE = 2,        ///< Reverse directions
+	DIAGDIRDIFF_90LEFT  = 3         ///< 90 degrees left
+};
+
+/** Allow incrementing of DiagDirDiff variables */
+DECLARE_POSTFIX_INCREMENT(DiagDirDiff);
+
+
+/**
+ * Enumeration for the two axis X and Y
+ *
+ * This enumeration represente the two axis X and Y in the game.
+ * The X axis is the one which goes align the north-west edge
+ * (and south-east edge). The Y axis must be so the one which goes
+ * align the north-east edge (and south-west) edge.
+ */
+enum Axis {
+	AXIS_X = 0,     ///< The X axis
+	AXIS_Y = 1,     ///< The y axis
+	AXIS_END        ///< Used for iterations
+};
+
+#endif /* DIRECTION_TYPE_H */
--- a/src/disaster_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/disaster_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -18,16 +18,13 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "landscape.h"
+
 #include "industry_map.h"
 #include "station_map.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "map.h"
-#include "tile.h"
-#include "vehicle.h"
-#include "command.h"
+#include "command_func.h"
+#include "tile_cmd.h"
 #include "news.h"
 #include "station.h"
 #include "waypoint.h"
@@ -35,10 +32,14 @@
 #include "industry.h"
 #include "player.h"
 #include "airport.h"
-#include "sound.h"
 #include "variables.h"
 #include "table/sprites.h"
-#include "date.h"
+#include "strings_func.h"
+#include "date_func.h"
+#include "functions.h"
+#include "vehicle_func.h"
+#include "vehicle_base.h"
+#include "sound_func.h"
 
 enum DisasterSubType {
 	ST_Zeppeliner,
@@ -311,7 +312,7 @@
 		/* Fly around randomly */
 		int x = TileX(v->dest_tile) * TILE_SIZE;
 		int y = TileY(v->dest_tile) * TILE_SIZE;
-		if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) {
+		if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) {
 			v->direction = GetDirectionTowards(v, x, y);
 			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@@ -340,7 +341,7 @@
 			return;
 		}
 
-		dist = delta(v->x_pos, u->x_pos) + delta(v->y_pos, u->y_pos);
+		dist = Delta(v->x_pos, u->x_pos) + Delta(v->y_pos, u->y_pos);
 
 		if (dist < TILE_SIZE && !(u->vehstatus & VS_HIDDEN) && u->breakdown_ctr == 0) {
 			u->breakdown_ctr = 3;
@@ -567,7 +568,7 @@
 	if (v->current_order.dest == 1) {
 		int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
 		int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
-		if (delta(v->x_pos, x) + delta(v->y_pos, y) >= 8) {
+		if (Delta(v->x_pos, x) + Delta(v->y_pos, y) >= 8) {
 			v->direction = GetDirectionTowards(v, x, y);
 
 			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
@@ -585,7 +586,7 @@
 
 		FOR_ALL_VEHICLES(u) {
 			if (u->type == VEH_TRAIN || u->type == VEH_ROAD) {
-				if (delta(u->x_pos, v->x_pos) + delta(u->y_pos, v->y_pos) <= 12 * TILE_SIZE) {
+				if (Delta(u->x_pos, v->x_pos) + Delta(u->y_pos, v->y_pos) <= 12 * TILE_SIZE) {
 					u->breakdown_ctr = 5;
 					u->breakdown_delay = 0xF0;
 				}
@@ -617,7 +618,7 @@
 	} else if (v->current_order.dest == 0) {
 		int x = TileX(v->dest_tile) * TILE_SIZE;
 		int y = TileY(v->dest_tile) * TILE_SIZE;
-		if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) {
+		if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) {
 			v->direction = GetDirectionTowards(v, x, y);
 			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@@ -667,7 +668,7 @@
 
 	if (v->current_order.dest == 0) {
 		u = GetVehicle(v->u.disaster.big_ufo_destroyer_target);
-		if (delta(v->x_pos, u->x_pos) > TILE_SIZE) return;
+		if (Delta(v->x_pos, u->x_pos) > TILE_SIZE) return;
 		v->current_order.dest = 1;
 
 		CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
@@ -715,7 +716,7 @@
 	if (IsValidTile(tile)) {
 		TrackdirBits r = (TrackdirBits)GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
 
-		if (TrackdirBitsToTrackBits(r) == TRACK_BIT_ALL && !CHANCE16(1, 90)) {
+		if (TrackdirBitsToTrackBits(r) == TRACK_BIT_ALL && !Chance16(1, 90)) {
 			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 			return;
@@ -825,7 +826,7 @@
 
 	FOR_ALL_INDUSTRIES(i) {
 		if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_AIRPLANE_ATTACKS) &&
-				(found == NULL || CHANCE16(1, 2))) {
+				(found == NULL || Chance16(1, 2))) {
 			found = i;
 		}
 	}
@@ -861,7 +862,7 @@
 
 	FOR_ALL_INDUSTRIES(i) {
 		if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CHOPPER_ATTACKS) &&
-				(found == NULL || CHANCE16(1, 2))) {
+				(found == NULL || Chance16(1, 2))) {
 			found = i;
 		}
 	}
--- a/src/dock_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/dock_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,16 +6,20 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
-#include "map.h"
-#include "window.h"
+#include "tile_map.h"
 #include "station.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
-#include "sound.h"
-#include "command.h"
+#include "terraform_gui.h"
+#include "window_gui.h"
+#include "station_gui.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();
@@ -127,7 +131,7 @@
 	switch (e->event) {
 	case WE_PAINT:
 		DrawWindowWidgets(w);
-		SetWindowWidgetsDisabledState(w, !CanBuildVehicleInfrastructure(VEH_SHIP), 7, 8, 9, WIDGET_LIST_END);
+		w->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), 7, 8, 9, WIDGET_LIST_END);
 		break;
 
 	case WE_CLICK:
@@ -170,7 +174,7 @@
 		break;
 
 	case WE_ABORT_PLACE_OBJ:
-		RaiseWindowButtons(w);
+		w->RaiseButtons();
 
 		w = FindWindowById(WC_BUILD_STATION, 0);
 		if (w != NULL) WP(w, def_d).close = true;
@@ -236,7 +240,7 @@
 static void BuildDockStationWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-	case WE_CREATE: LowerWindowWidget(w, _station_show_coverage + 3); break;
+	case WE_CREATE: w->LowerWidget(_station_show_coverage + 3); break;
 
 	case WE_PAINT: {
 		int rad = (_patches.modified_catchment) ? CA_DOCK : 4;
@@ -258,9 +262,9 @@
 		switch (e->we.click.widget) {
 			case 3:
 			case 4:
-				RaiseWindowWidget(w, _station_show_coverage + 3);
+				w->RaiseWidget(_station_show_coverage + 3);
 				_station_show_coverage = (e->we.click.widget != 3);
-				LowerWindowWidget(w, _station_show_coverage + 3);
+				w->LowerWidget(_station_show_coverage + 3);
 				SndPlayFx(SND_15_BEEP);
 				SetWindowDirty(w);
 				break;
@@ -317,7 +321,7 @@
 static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-	case WE_CREATE: LowerWindowWidget(w, _ship_depot_direction + 3); break;
+	case WE_CREATE: w->LowerWidget(_ship_depot_direction + 3); break;
 
 	case WE_PAINT:
 		DrawWindowWidgets(w);
@@ -332,9 +336,9 @@
 		switch (e->we.click.widget) {
 		case 3:
 		case 4:
-			RaiseWindowWidget(w, _ship_depot_direction + 3);
+			w->RaiseWidget(_ship_depot_direction + 3);
 			_ship_depot_direction = (e->we.click.widget == 3 ? AXIS_X : AXIS_Y);
-			LowerWindowWidget(w, _ship_depot_direction + 3);
+			w->LowerWidget(_ship_depot_direction + 3);
 			SndPlayFx(SND_15_BEEP);
 			UpdateDocksDirection();
 			SetWindowDirty(w);
--- a/src/driver.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/driver.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,8 +6,6 @@
 #include "openttd.h"
 #include "debug.h"
 #include "driver.h"
-#include "functions.h"
-#include "string.h"
 
 #include "sound/sound_driver.hpp"
 #include "music/music_driver.hpp"
--- a/src/driver.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/driver.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,8 +6,8 @@
 #define DRIVER_H
 
 #include "debug.h"
-#include "helpers.hpp"
-#include "string.h"
+#include "core/enum_type.hpp"
+#include "string_func.h"
 #include <string>
 #include <map>
 
@@ -79,7 +79,7 @@
 		strecpy(buf, GetDriverTypeName(type), lastof(buf));
 		strecpy(buf + 5, name, lastof(buf));
 
-#if !defined(NDEBUG)
+#if !defined(NDEBUG) || defined(WITH_ASSERT)
 		/* NDEBUG disables asserts and gives a warning: unused variable 'P' */
 		std::pair<Drivers::iterator, bool> P =
 #endif /* !NDEBUG */
--- a/src/dummy_land.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/dummy_land.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,10 +5,10 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "functions.h"
-#include "viewport.h"
-#include "command.h"
+#include "tile_cmd.h"
+#include "command_func.h"
 #include "table/sprites.h"
+#include "viewport_func.h"
 
 static void DrawTile_Dummy(TileInfo *ti)
 {
--- a/src/economy.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/economy.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,25 +5,17 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
 #include "landscape.h"
-#include "strings.h" // XXX InjectDParam()
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "map.h"
 #include "news.h"
 #include "player.h"
 #include "station.h"
-#include "vehicle.h"
-#include "window.h"
-#include "gfx.h"
-#include "command.h"
+#include "command_func.h"
 #include "saveload.h"
-#include "economy.h"
 #include "industry.h"
 #include "town.h"
 #include "network/network.h"
-#include "sound.h"
 #include "engine.h"
 #include "network/network_data.h"
 #include "variables.h"
@@ -38,10 +30,20 @@
 #include "newgrf_industries.h"
 #include "newgrf_industrytiles.h"
 #include "unmovable.h"
-#include "date.h"
 #include "cargotype.h"
 #include "player_face.h"
 #include "group.h"
+#include "strings_func.h"
+#include "tile_cmd.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#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.
@@ -90,11 +92,17 @@
 };
 
 int _score_part[MAX_PLAYERS][SCORE_END];
+Economy _economy;
+Subsidy _subsidies[MAX_PLAYERS];
+Prices _price;
+uint16 _price_frac[NUM_PRICES];
+Money  _cargo_payment_rates[NUM_CARGO];
+uint16 _cargo_payment_rates_frac[NUM_CARGO];
+Money _additional_cash_required;
 
 Money CalculateCompanyValue(const Player* p)
 {
 	PlayerID owner = p->index;
-	/* Do a little nasty by using CommandCost, so we can use the "overflow" protection of CommandCost */
 	Money value = 0;
 
 	Station *st;
@@ -280,6 +288,7 @@
 		/* See if the old_player had shares in other companies */
 		_current_player = old_player;
 		FOR_ALL_PLAYERS(p) {
+			if (!p->is_active) continue;
 			for (i = 0; i < 4; i++) {
 				if (p->share_owners[i] == old_player) {
 					/* Sell his shares */
@@ -365,7 +374,7 @@
 		}
 
 		FOR_ALL_VEHICLES(v) {
-			if (v->owner == old_player && IS_BYTE_INSIDE(v->type, VEH_TRAIN, VEH_AIRCRAFT + 1)) {
+			if (v->owner == old_player && IsInsideMM(v->type, VEH_TRAIN, VEH_AIRCRAFT + 1)) {
 				if (new_player == PLAYER_SPECTATOR) {
 					DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 					DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
@@ -396,6 +405,7 @@
 					}
 				} else {
 					v->owner = new_player;
+					v->colormap = PAL_NONE;
 					v->group_id = DEFAULT_GROUP;
 					if (IsEngineCountable(v)) GetPlayer(new_player)->num_engines[v->engine_type]++;
 					switch (v->type) {
@@ -416,6 +426,22 @@
 		do {
 			ChangeTileOwner(tile, old_player, new_player);
 		} while (++tile != MapSize());
+
+		if (new_player != PLAYER_SPECTATOR) {
+			/* Update all signals because there can be new segment that was owned by two players
+			 * and signals were not propagated */
+			tile = 0;
+
+			do {
+				if (IsTileType(tile, MP_RAILWAY) && IsTileOwner(tile, new_player) && HasSignals(tile)) {
+					TrackBits tracks = GetTrackBits(tile);
+					do { // there may be two tracks with signals for TRACK_BIT_HORZ and TRACK_BIT_VERT
+						Track track = RemoveFirstTrack(&tracks);
+						if (HasSignalOnTrack(tile, track)) SetSignalsOnBothDir(tile, track);
+					} while (tracks != TRACK_BIT_NONE);
+				}
+			} while (++tile != MapSize());
+		}
 	}
 
 	/* Change color of existing windows */
@@ -634,8 +660,8 @@
 
 	FOR_ALL_STATIONS(st) {
 		_current_player = st->owner;
-		SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
-		SubtractMoneyFromPlayer(_price.station_value >> 1);
+		CommandCost cost(EXPENSES_PROPERTY, _price.station_value >> 1);
+		SubtractMoneyFromPlayer(cost);
 	}
 
 	if (!HasBit(1<<0|1<<3|1<<6|1<<9, _cur_month))
@@ -735,12 +761,10 @@
 		if (!p->is_active) continue;
 
 		_current_player = p->index;
-		SET_EXPENSES_TYPE(EXPENSES_LOAN_INT);
 
-		SubtractMoneyFromPlayer(CommandCost((Money)BigMulSU(p->current_loan, interest, 16)));
+		SubtractMoneyFromPlayer(CommandCost(EXPENSES_LOAN_INT, (Money)BigMulSU(p->current_loan, interest, 16)));
 
-		SET_EXPENSES_TYPE(EXPENSES_OTHER);
-		SubtractMoneyFromPlayer(_price.station_value >> 2);
+		SubtractMoneyFromPlayer(CommandCost(EXPENSES_OTHER, _price.station_value >> 2));
 	}
 }
 
@@ -790,10 +814,10 @@
 	  65000, ///< ship_base
 	     20, ///< build_trees
 	    250, ///< terraform
-	     20, ///< clear_1
-	     40, ///< purchase_land
-	    200, ///< clear_2
-	    500, ///< clear_3
+	     20, ///< clear_grass
+	     40, ///< clear_roughland
+	    200, ///< clear_rocks
+	    500, ///< clear_fields
 	     20, ///< remove_trees
 	    -70, ///< remove_rail
 	     10, ///< remove_signals
@@ -1101,7 +1125,7 @@
 	}
 
 	/* 25% chance to go on */
-	if (CHANCE16(1,4)) {
+	if (Chance16(1,4)) {
 		/*  Find a free slot*/
 		s = _subsidies;
 		while (s->cargo_type != CT_INVALID) {
@@ -1488,7 +1512,7 @@
 
 	if (route_profit != 0) {
 		front_v->profit_this_year += vehicle_profit;
-		SubtractMoneyFromPlayer(-route_profit);
+		SubtractMoneyFromPlayer(CommandCost(front_v->GetExpenseType(true), -route_profit));
 
 		if (IsLocalPlayer() && !PlayVehicleSound(front_v, VSE_LOAD_UNLOAD)) {
 			SndPlayVehicleFx(SND_14_CASHTILL, front_v);
@@ -1523,7 +1547,10 @@
 		return;
 	}
 
-	if (v->type == VEH_TRAIN && !IsTileType(v->tile, MP_STATION)) {
+	StationID last_visited = v->last_station_visited;
+	Station *st = GetStation(last_visited);
+
+	if (v->type == VEH_TRAIN && (!IsTileType(v->tile, MP_STATION) || GetStationIndex(v->tile) != st->index)) {
 		/* The train reversed in the station. Take the "easy" way
 		 * out and let the train just leave as it always did. */
 		SetBit(v->vehicle_flags, VF_LOADING_FINISHED);
@@ -1543,9 +1570,6 @@
 
 	v->cur_speed = 0;
 
-	StationID last_visited = v->last_station_visited;
-	Station *st = GetStation(last_visited);
-
 	for (; v != NULL; v = v->Next()) {
 		if (v->cargo_cap == 0) continue;
 
@@ -1797,9 +1821,8 @@
 	PlayerID old_player = _current_player;
 	for (i = 0; i != 4; i++) {
 		if (p->share_owners[i] != PLAYER_SPECTATOR) {
-			SET_EXPENSES_TYPE(EXPENSES_OTHER);
 			_current_player = p->share_owners[i];
-			SubtractMoneyFromPlayer(CommandCost(-value));
+			SubtractMoneyFromPlayer(CommandCost(EXPENSES_OTHER, -value));
 		}
 	}
 	_current_player = old_player;
@@ -1821,7 +1844,7 @@
 CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	Player *p;
-	CommandCost cost;
+	CommandCost cost(EXPENSES_OTHER);
 
 	/* Check if buying shares is allowed (protection against modified clients) */
 	/* Cannot buy own shares */
@@ -1832,8 +1855,6 @@
 	/* Cannot buy shares of non-existent nor bankrupted company */
 	if (!p->is_active) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-
 	/* Protect new companies from hostile takeovers */
 	if (_cur_year - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED);
 
@@ -1883,8 +1904,6 @@
 	/* Cannot sell shares of non-existent nor bankrupted company */
 	if (!p->is_active) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-
 	/* Those lines are here for network-protection (clients can be slow) */
 	if (GetAmountOwnedBy(p, _current_player) == 0) return CommandCost();
 
@@ -1898,7 +1917,7 @@
 		*b = PLAYER_SPECTATOR;
 		InvalidateWindow(WC_COMPANY, p1);
 	}
-	return CommandCost(cost);
+	return CommandCost(EXPENSES_OTHER, cost);
 }
 
 /** Buy up another company.
@@ -1921,7 +1940,6 @@
 	/* Do not allow players to take over themselves */
 	if (pid == _current_player) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
 	p = GetPlayer(pid);
 
 	if (!p->is_ai) return CMD_ERROR;
@@ -1929,7 +1947,7 @@
 	if (flags & DC_EXEC) {
 		DoAcquireCompany(p);
 	}
-	return CommandCost(p->bankrupt_value);
+	return CommandCost(EXPENSES_OTHER, p->bankrupt_value);
 }
 
 /** Prices */
--- a/src/economy.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/* $Id$ */
-
-/** @file economy.h */
-
-#ifndef ECONOMY_H
-#define ECONOMY_H
-
-void ResetPriceBaseMultipliers();
-void SetPriceBaseMultiplier(uint price, byte factor);
-
-struct Economy {
-	Money max_loan;         ///< Maximum possible loan
-	Money max_loan_unround; ///< Economy fluctuation status
-	uint16 max_loan_unround_fract; ///< Fraction of the unrounded max loan
-	int fluct;
-	byte interest_rate;     ///< Interest
-	byte infl_amount;       ///< inflation amount
-	byte infl_amount_pr;    ///< "floating" portion of inflation
-};
-
-VARDEF Economy _economy;
-
-struct Subsidy {
-	CargoID cargo_type;
-	byte age;
-	/* from and to can either be TownID, StationID or IndustryID */
-	uint16 from;
-	uint16 to;
-};
-
-
-enum ScoreID {
-	SCORE_BEGIN      = 0,
-	SCORE_VEHICLES   = 0,
-	SCORE_STATIONS   = 1,
-	SCORE_MIN_PROFIT = 2,
-	SCORE_MIN_INCOME = 3,
-	SCORE_MAX_INCOME = 4,
-	SCORE_DELIVERED  = 5,
-	SCORE_CARGO      = 6,
-	SCORE_MONEY      = 7,
-	SCORE_LOAN       = 8,
-	SCORE_TOTAL      = 9,  ///< This must always be the last entry
-	SCORE_END        = 10, ///< How many scores are there..
-
-	SCORE_MAX = 1000       ///< The max score that can be in the performance history
-	/* the scores together of score_info is allowed to be more! */
-};
-
-DECLARE_POSTFIX_INCREMENT(ScoreID);
-
-struct ScoreInfo {
-	byte id;    ///< Unique ID of the score
-	int needed; ///< How much you need to get the perfect score
-	int score;  ///< How much score it will give
-};
-
-extern const ScoreInfo _score_info[];
-extern int _score_part[MAX_PLAYERS][SCORE_END];
-
-int UpdateCompanyRatingAndValue(Player *p, bool update);
-
-VARDEF Subsidy _subsidies[MAX_PLAYERS];
-Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode);
-void DeleteSubsidyWithTown(TownID index);
-void DeleteSubsidyWithIndustry(IndustryID index);
-void DeleteSubsidyWithStation(StationID index);
-
-Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
-uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
-
-void VehiclePayment(Vehicle *front_v);
-void LoadUnloadStation(Station *st);
-
-#endif /* ECONOMY_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/economy_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,43 @@
+/* $Id$ */
+
+/** @file economy_func.h Functions related to the economy. */
+
+#ifndef ECONOMY_FUNC_H
+#define ECONOMY_FUNC_H
+
+#include "core/geometry_type.hpp"
+#include "economy_type.h"
+#include "cargo_type.h"
+#include "vehicle_type.h"
+#include "tile_type.h"
+#include "town_type.h"
+#include "industry_type.h"
+
+struct Player;
+
+void ResetPriceBaseMultipliers();
+void SetPriceBaseMultiplier(uint price, byte factor);
+
+extern const ScoreInfo _score_info[];
+extern int _score_part[MAX_PLAYERS][SCORE_END];
+extern Economy _economy;
+extern Subsidy _subsidies[MAX_PLAYERS];
+/* Prices and also the fractional part. */
+extern Prices _price;
+extern uint16 _price_frac[NUM_PRICES];
+extern Money  _cargo_payment_rates[NUM_CARGO];
+extern uint16 _cargo_payment_rates_frac[NUM_CARGO];
+
+int UpdateCompanyRatingAndValue(Player *p, bool update);
+Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode);
+void DeleteSubsidyWithTown(TownID index);
+void DeleteSubsidyWithIndustry(IndustryID index);
+void DeleteSubsidyWithStation(StationID index);
+
+Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
+uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
+
+void VehiclePayment(Vehicle *front_v);
+void LoadUnloadStation(Station *st);
+
+#endif /* ECONOMY_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/economy_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,130 @@
+/* $Id$ */
+
+/** @file economy_type.h Types related to the economy. */
+
+#ifndef ECONOMY_TYPE_H
+#define ECONOMY_TYPE_H
+
+#include "core/overflowsafe_type.hpp"
+#include "core/enum_type.hpp"
+#include "cargo_type.h"
+
+typedef OverflowSafeInt64 Money;
+
+struct Economy {
+	Money max_loan;         ///< Maximum possible loan
+	Money max_loan_unround; ///< Economy fluctuation status
+	uint16 max_loan_unround_fract; ///< Fraction of the unrounded max loan
+	int fluct;
+	byte interest_rate;     ///< Interest
+	byte infl_amount;       ///< inflation amount
+	byte infl_amount_pr;    ///< "floating" portion of inflation
+};
+
+struct Subsidy {
+	CargoID cargo_type;
+	byte age;
+	/* from and to can either be TownID, StationID or IndustryID */
+	uint16 from;
+	uint16 to;
+};
+
+enum ScoreID {
+	SCORE_BEGIN      = 0,
+	SCORE_VEHICLES   = 0,
+	SCORE_STATIONS   = 1,
+	SCORE_MIN_PROFIT = 2,
+	SCORE_MIN_INCOME = 3,
+	SCORE_MAX_INCOME = 4,
+	SCORE_DELIVERED  = 5,
+	SCORE_CARGO      = 6,
+	SCORE_MONEY      = 7,
+	SCORE_LOAN       = 8,
+	SCORE_TOTAL      = 9,  ///< This must always be the last entry
+	SCORE_END        = 10, ///< How many scores are there..
+
+	SCORE_MAX = 1000       ///< The max score that can be in the performance history
+	/* the scores together of score_info is allowed to be more! */
+};
+DECLARE_POSTFIX_INCREMENT(ScoreID);
+
+struct ScoreInfo {
+	byte id;    ///< Unique ID of the score
+	int needed; ///< How much you need to get the perfect score
+	int score;  ///< How much score it will give
+};
+
+struct Prices {
+	Money station_value;
+	Money build_rail;
+	Money build_road;
+	Money build_signals;
+	Money build_bridge;
+	Money build_train_depot;
+	Money build_road_depot;
+	Money build_ship_depot;
+	Money build_tunnel;
+	Money train_station_track;
+	Money train_station_length;
+	Money build_airport;
+	Money build_bus_station;
+	Money build_truck_station;
+	Money build_dock;
+	Money build_railvehicle;
+	Money build_railwagon;
+	Money aircraft_base;
+	Money roadveh_base;
+	Money ship_base;
+	Money build_trees;
+	Money terraform;
+	Money clear_grass;
+	Money clear_roughland;
+	Money clear_rocks;
+	Money clear_fields;
+	Money remove_trees;
+	Money remove_rail;
+	Money remove_signals;
+	Money clear_bridge;
+	Money remove_train_depot;
+	Money remove_road_depot;
+	Money remove_ship_depot;
+	Money clear_tunnel;
+	Money clear_water;
+	Money remove_rail_station;
+	Money remove_airport;
+	Money remove_bus_station;
+	Money remove_truck_station;
+	Money remove_dock;
+	Money remove_house;
+	Money remove_road;
+	Money running_rail[3];
+	Money aircraft_running;
+	Money roadveh_running;
+	Money ship_running;
+	Money build_industry;
+};
+
+enum {
+	NUM_PRICES = 49,
+};
+
+assert_compile(NUM_PRICES * sizeof(Money) == sizeof(Prices));
+
+enum ExpensesType {
+	EXPENSES_CONSTRUCTION =  0,
+	EXPENSES_NEW_VEHICLES =  1,
+	EXPENSES_TRAIN_RUN    =  2,
+	EXPENSES_ROADVEH_RUN  =  3,
+	EXPENSES_AIRCRAFT_RUN =  4,
+	EXPENSES_SHIP_RUN     =  5,
+	EXPENSES_PROPERTY     =  6,
+	EXPENSES_TRAIN_INC    =  7,
+	EXPENSES_ROADVEH_INC  =  8,
+	EXPENSES_AIRCRAFT_INC =  9,
+	EXPENSES_SHIP_INC     = 10,
+	EXPENSES_LOAN_INT     = 11,
+	EXPENSES_OTHER        = 12,
+	INVALID_EXPENSES      = 0xFF,
+};
+
+#endif /* ECONOMY_TYPE_H */
--- a/src/elrail.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/elrail.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -48,12 +48,10 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "station_map.h"
-#include "tile.h"
-#include "viewport.h"
-#include "functions.h" /* We should REALLY get rid of this goddamn file, as it is butt-ugly */
+#include "viewport_func.h"
 #include "variables.h" /* ... same here */
 #include "landscape.h"
-#include "rail.h"
+#include "rail_type.h"
 #include "debug.h"
 #include "tunnel_map.h"
 #include "road_map.h"
@@ -62,10 +60,12 @@
 #include "rail_map.h"
 #include "table/sprites.h"
 #include "table/elrail_data.h"
-#include "vehicle.h"
 #include "train.h"
-#include "gui.h"
+#include "rail_gui.h"
 #include "transparency.h"
+#include "tunnelbridge_map.h"
+#include "vehicle_func.h"
+
 
 static inline TLG GetTLG(TileIndex t)
 {
@@ -91,17 +91,11 @@
 			break;
 
 		case MP_TUNNELBRIDGE:
-			if (IsTunnel(t)) {
-				if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
-				if (override != NULL) *override = 1 << GetTunnelDirection(t);
-				return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(t)));
-			} else {
-				if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
-				if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) {
-					*override = 1 << GetBridgeRampDirection(t);
-				}
-				return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(t)));
+			if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
+			if (override != NULL && (IsTunnel(t) || DistanceMax(t, GetOtherBridgeEnd(t)) > 1)) {
+				*override = 1 << GetTunnelBridgeDirection(t);
 			}
+			return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
 
 		case MP_ROAD:
 			if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return TRACK_BIT_NONE;
@@ -131,7 +125,7 @@
 		} else if (*tileh != SLOPE_FLAT) {
 			*tileh = SLOPE_FLAT;
 		} else {
-			switch (GetBridgeRampDirection(tile)) {
+			switch (GetTunnelBridgeDirection(tile)) {
 				case DIAGDIR_NE: *tileh = SLOPE_NE; break;
 				case DIAGDIR_SE: *tileh = SLOPE_SE; break;
 				case DIAGDIR_SW: *tileh = SLOPE_SW; break;
@@ -188,7 +182,7 @@
 
 	if ((GetRailType(ti->tile) != RAILTYPE_ELECTRIC) || _patches.disable_elrails) return;
 
-	DiagDirection dir = GetTunnelDirection(ti->tile);
+	DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
 
 	const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[dir];
 	const int *BB_data = _tunnel_wire_BB[dir];
@@ -247,7 +241,7 @@
 		 * existing foundataions, so we do have to do that manually later on.*/
 		tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL);
 		trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
-		if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
+		if (IsTunnelTile(neighbour) && i != GetTunnelBridgeDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
 
 		/* If the neighboured tile does not smoothly connect to the current tile (because of a foundation),
 		 * we have to draw all pillars on the current tile. */
@@ -264,7 +258,7 @@
 			/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */
 			if (TrackSourceTile[i][k] == TS_NEIGHBOUR &&
 			    IsBridgeTile(neighbour) &&
-			    GetBridgeRampDirection(neighbour) == ReverseDiagDir(i)) {
+			    GetTunnelBridgeDirection(neighbour) == ReverseDiagDir(i)) {
 				continue;
 			}
 
@@ -291,7 +285,7 @@
 		/* Read the foundataions if they are present, and adjust the tileh */
 		if (trackconfig[TS_NEIGHBOUR] != TRACK_BIT_NONE && IsTileType(neighbour, MP_RAILWAY) && GetRailType(neighbour) == RAILTYPE_ELECTRIC) foundation = GetRailFoundation(tileh[TS_NEIGHBOUR], trackconfig[TS_NEIGHBOUR]);
 		if (IsBridgeTile(neighbour)) {
-			foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour)));
+			foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetTunnelBridgeDirection(neighbour)));
 		}
 
 		ApplyFoundationToSlope(foundation, &tileh[TS_NEIGHBOUR]);
@@ -443,7 +437,7 @@
 	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) {
 		TileIndex head = GetNorthernBridgeEnd(ti->tile);
 
-		if (GetBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) {
+		if (GetTunnelBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) {
 			DrawCatenaryOnBridge(ti);
 		}
 	}
--- a/src/engine.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/engine.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,25 +5,27 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "engine.h"
-#include "gfx.h"
 #include "player.h"
-#include "command.h"
-#include "vehicle.h"
+#include "command_func.h"
 #include "news.h"
 #include "saveload.h"
 #include "variables.h"
 #include "train.h"
 #include "aircraft.h"
 #include "newgrf_cargo.h"
-#include "date.h"
 #include "table/engines.h"
 #include "group.h"
-#include "string.h"
-#include "strings.h"
 #include "misc/autoptr.hpp"
+#include "strings_func.h"
+#include "gfx_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "autoreplace_base.h"
+#include "autoreplace_gui.h"
+#include "string_func.h"
 
 EngineInfo _engine_info[TOTAL_NUM_ENGINES];
 RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
@@ -36,6 +38,24 @@
 };
 
 
+void SetupEngines()
+{
+	/* Copy original static engine data */
+	memcpy(&_engine_info, &_orig_engine_info, sizeof(_orig_engine_info));
+	memcpy(&_rail_vehicle_info, &_orig_rail_vehicle_info, sizeof(_orig_rail_vehicle_info));
+	memcpy(&_ship_vehicle_info, &_orig_ship_vehicle_info, sizeof(_orig_ship_vehicle_info));
+	memcpy(&_aircraft_vehicle_info, &_orig_aircraft_vehicle_info, sizeof(_orig_aircraft_vehicle_info));
+	memcpy(&_road_vehicle_info, &_orig_road_vehicle_info, sizeof(_orig_road_vehicle_info));
+
+	/* Add type to engines */
+	Engine* e = _engines;
+	do e->type = VEH_TRAIN;    while (++e < &_engines[ROAD_ENGINES_INDEX]);
+	do e->type = VEH_ROAD;     while (++e < &_engines[SHIP_ENGINES_INDEX]);
+	do e->type = VEH_SHIP;     while (++e < &_engines[AIRCRAFT_ENGINES_INDEX]);
+	do e->type = VEH_AIRCRAFT; while (++e < &_engines[TOTAL_NUM_ENGINES]);
+}
+
+
 void ShowEnginePreviewWindow(EngineID engine);
 
 void DeleteCustomEngineNames()
@@ -106,16 +126,6 @@
 	InvalidateWindowClasses(WC_REPLACE_VEHICLE);
 }
 
-void AddTypeToEngines()
-{
-	Engine* e = _engines;
-
-	do e->type = VEH_TRAIN;    while (++e < &_engines[ROAD_ENGINES_INDEX]);
-	do e->type = VEH_ROAD;     while (++e < &_engines[SHIP_ENGINES_INDEX]);
-	do e->type = VEH_SHIP;     while (++e < &_engines[AIRCRAFT_ENGINES_INDEX]);
-	do e->type = VEH_AIRCRAFT; while (++e < &_engines[TOTAL_NUM_ENGINES]);
-}
-
 void StartupEngines()
 {
 	Engine *e;
@@ -327,15 +337,14 @@
 	/* Do not introduce new rail wagons */
 	if (IsWagon(index)) return;
 
-	if (index < NUM_TRAIN_ENGINES) {
+	if (e->type == VEH_TRAIN) {
 		/* maybe make another rail type available */
 		RailType railtype = RailVehInfo(index)->railtype;
 		assert(railtype < RAILTYPE_END);
 		FOR_ALL_PLAYERS(p) {
 			if (p->is_active) SetBit(p->avail_railtypes, railtype);
 		}
-	}
-	if ((index - NUM_TRAIN_ENGINES) < NUM_ROAD_ENGINES) {
+	} else if (e->type == VEH_ROAD) {
 		/* maybe make another road type available */
 		FOR_ALL_PLAYERS(p) {
 			if (p->is_active) SetBit(p->avail_roadtypes, HasBit(EngInfo(index)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
--- a/src/engine.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/engine.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,9 +6,13 @@
 #define ENGINE_H
 
 #include "oldpool.h"
-#include "rail.h"
-#include "sound.h"
-#include "vehicle.h"
+#include "rail_type.h"
+#include "cargo_type.h"
+#include "vehicle_type.h"
+#include "command_type.h"
+#include "gfx_type.h"
+#include "date_type.h"
+#include "sound_type.h"
 
 enum RailVehicleTypes {
 	RAILVEH_SINGLEHEAD,  ///< indicates a "standalone" locomotive
@@ -120,7 +124,7 @@
 	PlayerByte preview_player;
 	byte preview_wait;
 	byte player_avail;
-	VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc. Same as in vehicle.h
+	VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
 };
 
 /**
@@ -149,7 +153,7 @@
 static const EngineID INVALID_ENGINE = 0xFFFF;
 
 
-void AddTypeToEngines();
+void SetupEngines();
 void StartupEngines();
 
 
@@ -215,12 +219,11 @@
 }
 
 /* Access Vehicle Data */
-//#include "table/engines.h"
-extern const EngineInfo orig_engine_info[TOTAL_NUM_ENGINES];
-extern const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES];
-extern const ShipVehicleInfo orig_ship_vehicle_info[NUM_SHIP_ENGINES];
-extern const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
-extern const RoadVehicleInfo orig_road_vehicle_info[NUM_ROAD_ENGINES];
+extern const EngineInfo _orig_engine_info[TOTAL_NUM_ENGINES];
+extern const RailVehicleInfo _orig_rail_vehicle_info[NUM_TRAIN_ENGINES];
+extern const ShipVehicleInfo _orig_ship_vehicle_info[NUM_SHIP_ENGINES];
+extern const AircraftVehicleInfo _orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
+extern const RoadVehicleInfo _orig_road_vehicle_info[NUM_ROAD_ENGINES];
 
 extern EngineInfo _engine_info[TOTAL_NUM_ENGINES];
 extern RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
@@ -258,84 +261,6 @@
 	return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
 }
 
-/************************************************************************
- * Engine Replacement stuff
- ************************************************************************/
-
-struct EngineRenew;
-/**
- * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
- * placed here so the only exception to this rule, the saveload code, can use
- * it.
- */
-DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000)
-
-/**
- * Struct to store engine replacements. DO NOT USE outside of engine.c. Is
- * placed here so the only exception to this rule, the saveload code, can use
- * it.
- */
-struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
-	EngineID from;
-	EngineID to;
-	EngineRenew *next;
-	GroupID group_id;
-
-	EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {}
-	~EngineRenew() { this->from = INVALID_ENGINE; }
-
-	inline bool IsValid() const { return this->from != INVALID_ENGINE; }
-};
-
-#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid())
-#define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
-
-
-/**
- * A list to group EngineRenew directives together (such as per-player).
- */
-typedef EngineRenew* EngineRenewList;
-
-/**
- * Remove all engine replacement settings for the player.
- * @param  erl The renewlist for a given player.
- * @return The new renewlist for the player.
- */
-void RemoveAllEngineReplacement(EngineRenewList *erl);
-
-/**
- * Retrieve the engine replacement in a given renewlist for an original engine type.
- * @param  erl The renewlist to search in.
- * @param  engine Engine type to be replaced.
- * @return The engine type to replace with, or INVALID_ENGINE if no
- * replacement is in the list.
- */
-EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
-
-/**
- * Add an engine replacement to the given renewlist.
- * @param erl The renewlist to add to.
- * @param old_engine The original engine type.
- * @param new_engine The replacement engine type.
- * @param flags The calling command flags.
- * @return 0 on success, CMD_ERROR on failure.
- */
-CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
-
-/**
- * Remove an engine replacement from a given renewlist.
- * @param erl The renewlist from which to remove the replacement
- * @param engine The original engine type.
- * @param flags The calling command flags.
- * @return 0 on success, CMD_ERROR on failure.
- */
-CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags);
-
-/** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
- * @param type The type of engine
- */
-void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type);
-
 /* Engine list manipulators - current implementation is only C wrapper of CBlobT<EngineID> class (helpers.cpp) */
 void EngList_Create(EngineList *el);            ///< Creates engine list
 void EngList_Destroy(EngineList *el);           ///< Deallocate and destroy engine list
--- a/src/engine_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/engine_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,18 +5,17 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "strings.h"
 #include "table/sprites.h"
-#include "functions.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
+#include "window_gui.h"
+#include "gfx_func.h"
 #include "engine.h"
-#include "command.h"
+#include "command_func.h"
+#include "economy_func.h"
 #include "news.h"
 #include "variables.h"
 #include "newgrf_engine.h"
+#include "strings_func.h"
 
 
 static StringID GetEngineCategoryName(EngineID engine)
--- a/src/fileio.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/fileio.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,12 +5,12 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "fileio.h"
-#include "functions.h"
-#include "string.h"
-#include "macros.h"
 #include "variables.h"
 #include "debug.h"
 #include "fios.h"
+#include "core/alloc_func.hpp"
+#include "core/math_func.hpp"
+#include "string_func.h"
 #ifdef WIN32
 #include <windows.h>
 #else
@@ -350,6 +350,12 @@
 		}
 	}
 
+	/* Sometimes a full path is given. To support
+	 * the 'subdirectory' must be 'removed'. */
+	if (f == NULL && subdir != NO_DIRECTORY) {
+		f = FioFOpenFile(filename, mode, NO_DIRECTORY, filesize);
+	}
+
 	return f;
 }
 
@@ -758,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	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/fileio.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,6 @@
 #ifndef FILEIO_H
 #define FILEIO_H
 
-#include "helpers.hpp"
 #include <map>
 #include <string>
 
@@ -113,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	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/fios.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,14 +6,14 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "string.h"
 #include "variables.h"
-#include "functions.h"
 #include "heightmap.h"
-#include "helpers.hpp"
 #include "table/strings.h"
 #include "fios.h"
 #include "fileio.h"
+#include "core/alloc_func.hpp"
+#include "functions.h"
+#include "string_func.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -29,6 +29,7 @@
 
 static char *_fios_path;
 static FiosItem *_fios_items;
+SmallFiosItem _file_to_saveload;
 static int _fios_count, _fios_alloc;
 
 /* OS-specific functions are taken from their respective files (win32/unix/os2 .c) */
--- a/src/fios.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/fios.h	Wed Jan 09 18:11:12 2008 +0000
@@ -23,12 +23,21 @@
 	MAX_FILE_SLOTS = 64
 };
 
-/* Deals with finding savegames */
-struct FiosItem {
-	byte type;
-	uint64 mtime;
-	char title[64];
-	char name[256 - 12 - 64];
+enum SaveLoadDialogMode{
+	SLD_LOAD_GAME,
+	SLD_LOAD_SCENARIO,
+	SLD_SAVE_GAME,
+	SLD_SAVE_SCENARIO,
+	SLD_LOAD_HEIGHTMAP,
+	SLD_NEW_GAME,
+};
+
+/* The different types of files been handled by the system */
+enum FileType {
+	FT_NONE,      ///< nothing to do
+	FT_SAVEGAME,  ///< old or new savegame
+	FT_SCENARIO,  ///< old or new scenario
+	FT_HEIGHTMAP, ///< heightmap file
 };
 
 enum {
@@ -45,10 +54,30 @@
 	FIOS_TYPE_INVALID      = 255,
 };
 
+/* Deals with finding savegames */
+struct FiosItem {
+	byte type;
+	uint64 mtime;
+	char title[64];
+	char name[256 - 12 - 64];
+};
+
+/* Deals with the type of the savegame, independent of extension */
+struct SmallFiosItem {
+	int mode;             ///< savegame/scenario type (old, new)
+	FileType filetype;    ///< what type of file are we dealing with
+	char name[MAX_PATH];  ///< name
+	char title[255];      ///< internal name of the game
+};
+
 /* Variables to display file lists */
 extern FiosItem *_fios_list; ///< defined in misc_gui.cpp
 extern int _fios_num;        ///< defined in fios.cpp, read_only version of _fios_count
-extern int _saveload_mode;   ///< defined in misc_gui.cpp
+extern SmallFiosItem _file_to_saveload;
+extern SaveLoadDialogMode _saveload_mode;   ///< defined in misc_gui.cpp
+
+/* Launch save/load dialog */
+void ShowSaveLoadDialog(SaveLoadDialogMode mode);
 
 /* Get a list of savegames */
 FiosItem *FiosGetSavegameList(int mode);
--- a/src/fontcache.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/fontcache.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,18 +4,16 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "macros.h"
 #include "debug.h"
 #include "table/sprites.h"
 #include "table/control_codes.h"
 #include "spritecache.h"
-#include "gfx.h"
-#include "string.h"
 #include "fontcache.h"
-#include "helpers.hpp"
 #include "spriteloader/spriteloader.hpp"
 #include "blitter/factory.hpp"
+#include "gfx_func.h"
+#include "core/alloc_func.hpp"
+#include "core/math_func.hpp"
 
 #ifdef WITH_FREETYPE
 
@@ -365,7 +363,7 @@
 
 void *AllocateFont(size_t size)
 {
-	return malloc(size);
+	return MallocT<byte>(size);
 }
 
 
--- a/src/fontcache.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/fontcache.h	Wed Jan 09 18:11:12 2008 +0000
@@ -3,6 +3,8 @@
 #ifndef FONTCACHE_H
 #define FONTCACHE_H
 
+#include "gfx_type.h"
+
 /** Get the SpriteID mapped to the given font size and key */
 SpriteID GetUnicodeGlyph(FontSize size, uint32 key);
 
--- a/src/functions.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/functions.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,11 +5,10 @@
 #ifndef FUNCTIONS_H
 #define FUNCTIONS_H
 
-#include "gfx.h"
-#include "viewport.h"
+#include "openttd.h"
 #include "core/random_func.hpp"
-
-void UpdateTownMaxPass(Town *t);
+#include "command_type.h"
+#include "tile_cmd.h"
 
 /* clear_land.cpp */
 void DrawHillyLandTile(const TileInfo *ti);
@@ -17,10 +16,6 @@
 void DrawClearLandFence(const TileInfo *ti);
 void TileLoopClearHelper(TileIndex tile);
 
-/* water_land.cpp */
-void DrawShipDepotSprite(int x, int y, int image);
-void TileLoop_Water(TileIndex tile);
-
 /* players.cpp */
 bool CheckPlayerHasMoney(CommandCost cost);
 void SubtractMoneyFromPlayer(CommandCost cost);
@@ -28,25 +23,12 @@
 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()); }
-
 /* texteff.cpp */
 void AddAnimatedTile(TileIndex tile);
 void DeleteAnimatedTile(TileIndex tile);
 void AnimateAnimatedTiles();
 void InitializeAnimatedTiles();
 
-/* tunnelbridge_cmd.cpp */
-bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
-uint32 GetBridgeLength(TileIndex begin, TileIndex end);
-int CalcBridgeLenCostFactor(int x);
-
 /* misc_cmd.cpp */
 void PlaceTreesRandomly();
 
@@ -75,23 +57,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);
-
-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);
-bool EnsureNoVehicleOnGround(TileIndex tile);
 
 /**
  * Mark all viewports dirty for repaint.
@@ -102,17 +67,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);
 
-int FindFirstBit(uint32 x);
-
-void AfterLoadTown();
-void UpdatePatches();
 void AskExitGame();
 void AskExitToGameMenu();
 
@@ -122,25 +78,11 @@
 
 void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str);
 
-enum {
-	SLD_LOAD_GAME,
-	SLD_LOAD_SCENARIO,
-	SLD_SAVE_GAME,
-	SLD_SAVE_SCENARIO,
-	SLD_LOAD_HEIGHTMAP,
-	SLD_NEW_GAME,
-};
-void ShowSaveLoadDialog(int mode);
 
 /* 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	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/genworld.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,23 +4,24 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "landscape.h"
 #include "player.h"
 #include "table/sprites.h"
 #include "variables.h"
 #include "thread.h"
-#include "command.h"
+#include "command_func.h"
 #include "genworld.h"
-#include "gfx.h"
 #include "gfxinit.h"
-#include "gui.h"
+#include "window_func.h"
 #include "network/network.h"
 #include "debug.h"
-#include "settings.h"
+#include "settings_func.h"
 #include "heightmap.h"
-#include "date.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
+#include "map_func.h"
+#include "date_func.h"
+#include "core/random_func.hpp"
 
 void GenerateClearTile();
 void GenerateIndustries();
--- a/src/genworld_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/genworld_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,26 +5,28 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "heightmap.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "window.h"
 #include "gui.h"
-#include "gfx.h"
-#include "strings.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
 #include "gfxinit.h"
 #include "player.h"
-#include "command.h"
-#include "sound.h"
+#include "command_func.h"
 #include "variables.h"
-#include "string.h"
-#include "settings.h"
+#include "settings_func.h"
 #include "debug.h"
 #include "genworld.h"
 #include "network/network.h"
 #include "thread.h"
-#include "date.h"
 #include "newgrf_config.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "sound_func.h"
+#include "fios.h"
+#include "string_func.h"
+#include "gfx_func.h"
 
 /**
  * In what 'mode' the GenerateLandscapeWindowProc is.
@@ -228,7 +230,7 @@
 
 	switch (e->event) {
 	case WE_CREATE:
-		LowerWindowWidget(w, _opt_newgame.landscape + GLAND_TEMPERATE);
+		w->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
 
 		snprintf(_genseed_buffer, sizeof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
 		InitializeTextBuffer(&_genseed_query.text, _genseed_buffer, lengthof(_genseed_buffer), 120);
@@ -239,28 +241,28 @@
 	case WE_PAINT:
 		/* You can't select smoothness if not terragenesis */
 		if (mode == GLWP_GENERATE) {
-			SetWindowWidgetDisabledState(w, GLAND_SMOOTHNESS_TEXT,     _patches_newgame.land_generator == 0);
-			SetWindowWidgetDisabledState(w, GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0);
+			w->SetWidgetDisabledState(GLAND_SMOOTHNESS_TEXT,     _patches_newgame.land_generator == 0);
+			w->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0);
 		}
 		/* Disable snowline if not hilly */
-		SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC);
+		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC);
 		/* Disable town, industry and trees in SE */
-		SetWindowWidgetDisabledState(w, GLAND_TOWN_TEXT,         _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_TOWN_PULLDOWN,     _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_INDUSTRY_TEXT,     _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_TREE_TEXT,         _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_TREE_PULLDOWN,     _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_TOWN_TEXT,         _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN,     _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_INDUSTRY_TEXT,     _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_TREE_TEXT,         _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_TREE_PULLDOWN,     _game_mode == GM_EDITOR);
 
-		SetWindowWidgetDisabledState(w, GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
-		SetWindowWidgetDisabledState(w, GLAND_START_DATE_UP,   _patches_newgame.starting_year >= MAX_YEAR);
-		SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC);
-		SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_UP,   _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC);
+		w->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
+		w->SetWidgetDisabledState(GLAND_START_DATE_UP,   _patches_newgame.starting_year >= MAX_YEAR);
+		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC);
+		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP,   _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC);
 
-		SetWindowWidgetLoweredState(w, GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
-		SetWindowWidgetLoweredState(w, GLAND_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
-		SetWindowWidgetLoweredState(w, GLAND_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
-		SetWindowWidgetLoweredState(w, GLAND_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
+		w->SetWidgetLoweredState(GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
+		w->SetWidgetLoweredState(GLAND_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
+		w->SetWidgetLoweredState(GLAND_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
+		w->SetWidgetLoweredState(GLAND_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
 		DrawWindowWidgets(w);
 
 		y = (mode == GLWP_HEIGHTMAP) ? 22 : 0;
@@ -335,7 +337,7 @@
 		switch (e->we.click.widget) {
 		case 0: DeleteWindow(w); break;
 		case GLAND_TEMPERATE: case GLAND_ARCTIC: case GLAND_TROPICAL: case GLAND_TOYLAND:
-			RaiseWindowWidget(w, _opt_newgame.landscape + GLAND_TEMPERATE);
+			w->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
 			SetNewLandscapeType(e->we.click.widget - GLAND_TEMPERATE);
 			break;
 		case GLAND_MAPSIZE_X_TEXT: case GLAND_MAPSIZE_X_PULLDOWN: // Mapsize X
@@ -384,7 +386,7 @@
 		case GLAND_START_DATE_DOWN: case GLAND_START_DATE_UP: // Year buttons
 			/* Don't allow too fast scrolling */
 			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
-				HandleButtonClick(w, e->we.click.widget);
+				w->HandleButtonClick(e->we.click.widget);
 				SetWindowDirty(w);
 
 				_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
@@ -399,7 +401,7 @@
 		case GLAND_SNOW_LEVEL_DOWN: case GLAND_SNOW_LEVEL_UP: // Snow line buttons
 			/* Don't allow too fast scrolling */
 			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
-				HandleButtonClick(w, e->we.click.widget);
+				w->HandleButtonClick(e->we.click.widget);
 				SetWindowDirty(w);
 
 				_patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
@@ -493,11 +495,11 @@
 
 			switch (WP(w, generate_d).widget_id) {
 			case GLAND_START_DATE_TEXT:
-				InvalidateWidget(w, GLAND_START_DATE_TEXT);
+				w->InvalidateWidget(GLAND_START_DATE_TEXT);
 				_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 				break;
 			case GLAND_SNOW_LEVEL_TEXT:
-				InvalidateWidget(w, GLAND_SNOW_LEVEL_TEXT);
+				w->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT);
 				_patches_newgame.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
 				break;
 			}
@@ -605,18 +607,18 @@
 	static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
 
 	switch (e->event) {
-	case WE_CREATE: LowerWindowWidget(w, _opt_newgame.landscape + CSCEN_TEMPERATE); break;
+	case WE_CREATE: w->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); break;
 
 	case WE_PAINT:
-		SetWindowWidgetDisabledState(w, CSCEN_START_DATE_DOWN,       _patches_newgame.starting_year <= MIN_YEAR);
-		SetWindowWidgetDisabledState(w, CSCEN_START_DATE_UP,         _patches_newgame.starting_year >= MAX_YEAR);
-		SetWindowWidgetDisabledState(w, CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0);
-		SetWindowWidgetDisabledState(w, CSCEN_FLAT_LAND_HEIGHT_UP,   _patches_newgame.se_flat_world_height >= MAX_TILE_HEIGHT);
+		w->SetWidgetDisabledState(CSCEN_START_DATE_DOWN,       _patches_newgame.starting_year <= MIN_YEAR);
+		w->SetWidgetDisabledState(CSCEN_START_DATE_UP,         _patches_newgame.starting_year >= MAX_YEAR);
+		w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0);
+		w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP,   _patches_newgame.se_flat_world_height >= MAX_TILE_HEIGHT);
 
-		SetWindowWidgetLoweredState(w, CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
-		SetWindowWidgetLoweredState(w, CSCEN_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
-		SetWindowWidgetLoweredState(w, CSCEN_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
-		SetWindowWidgetLoweredState(w, CSCEN_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
+		w->SetWidgetLoweredState(CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
+		w->SetWidgetLoweredState(CSCEN_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
+		w->SetWidgetLoweredState(CSCEN_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
+		w->SetWidgetLoweredState(CSCEN_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
 		DrawWindowWidgets(w);
 
 		DrawStringRightAligned(211, 97, STR_MAPSIZE, TC_FROMSTRING);
@@ -636,7 +638,7 @@
 	case WE_CLICK:
 		switch (e->we.click.widget) {
 		case CSCEN_TEMPERATE: case CSCEN_ARCTIC: case CSCEN_TROPICAL: case CSCEN_TOYLAND:
-			RaiseWindowWidget(w, _opt_newgame.landscape + CSCEN_TEMPERATE);
+			w->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
 			SetNewLandscapeType(e->we.click.widget - CSCEN_TEMPERATE);
 			break;
 		case CSCEN_MAPSIZE_X_TEXT: case CSCEN_MAPSIZE_X_PULLDOWN: // Mapsize X
@@ -654,7 +656,7 @@
 		case CSCEN_START_DATE_DOWN: case CSCEN_START_DATE_UP: // Year buttons
 			/* Don't allow too fast scrolling */
 			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
-				HandleButtonClick(w, e->we.click.widget);
+				w->HandleButtonClick(e->we.click.widget);
 				SetWindowDirty(w);
 
 				_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
@@ -669,7 +671,7 @@
 		case CSCEN_FLAT_LAND_HEIGHT_DOWN: case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
 			/* Don't allow too fast scrolling */
 			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
-				HandleButtonClick(w, e->we.click.widget);
+				w->HandleButtonClick(e->we.click.widget);
 				SetWindowDirty(w);
 
 				_patches_newgame.se_flat_world_height = Clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
@@ -698,11 +700,11 @@
 
 			switch (WP(w, generate_d).widget_id) {
 			case CSCEN_START_DATE_TEXT:
-				InvalidateWidget(w, CSCEN_START_DATE_TEXT);
+				w->InvalidateWidget(CSCEN_START_DATE_TEXT);
 				_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 				break;
 			case CSCEN_FLAT_LAND_HEIGHT_TEXT:
-				InvalidateWidget(w, CSCEN_FLAT_LAND_HEIGHT_TEXT);
+				w->InvalidateWidget(CSCEN_FLAT_LAND_HEIGHT_TEXT);
 				_patches_newgame.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
 				break;
 			}
--- a/src/gfx.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/gfx.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,12 +4,8 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "macros.h"
+#include "gfx_func.h"
 #include "spritecache.h"
-#include "strings.h"
-#include "string.h"
-#include "gfx.h"
 #include "table/palettes.h"
 #include "table/sprites.h"
 #include "variables.h"
@@ -17,10 +13,12 @@
 #include "fontcache.h"
 #include "genworld.h"
 #include "debug.h"
-#include "zoom.hpp"
+#include "zoom_func.h"
 #include "texteff.hpp"
 #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;
@@ -42,6 +40,9 @@
 
 Colour _cur_palette[256];
 byte _stringwidth_table[FS_END][224];
+DrawPixelInfo *_cur_dpi;
+byte _colour_gradient[16][8];
+bool _use_dos_palette;
 
 static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = NULL);
 
@@ -515,16 +516,16 @@
 }
 
 /** Return the string dimension in pixels. The height and width are returned
- * in a single BoundingRect value. TINYFONT, BIGFONT modifiers are only
+ * in a single Dimension value. TINYFONT, BIGFONT modifiers are only
  * supported as the first character of the string. The returned dimensions
  * are therefore a rough estimation correct for all the current strings
  * but not every possible combination
  * @param str string to calculate pixel-width
  * @return string width and height in pixels */
-BoundingRect GetStringBoundingBox(const char *str)
+Dimension GetStringBoundingBox(const char *str)
 {
 	FontSize size = _cur_fontsize;
-	BoundingRect br;
+	Dimension br;
 	int max_width;
 	WChar c;
 
@@ -562,7 +563,7 @@
  * @param x offset from left side of the screen, if negative offset from the right side
  * @param y offset from top side of the screen, if negative offset from the bottom
  * @param real_color colour of the string, see _string_colormap in
- * table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx.h
+ * table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
  * @return the x-coordinates where the drawing has finished. If nothing is drawn
  * the originally passed x-coordinate is returned */
 int DoDrawString(const char *string, int x, int y, uint16 real_color)
@@ -1273,12 +1274,13 @@
 	return (_screen.width == width && _screen.height == height) || _video_driver->ChangeResolution(width, height);
 }
 
-void ToggleFullScreen(bool fs)
+bool ToggleFullScreen(bool fs)
 {
-	_video_driver->ToggleFullscreen(fs);
+	bool result = _video_driver->ToggleFullscreen(fs);
 	if (_fullscreen != fs && _num_resolutions == 0) {
 		DEBUG(driver, 0, "Could not find a suitable fullscreen resolution");
 	}
+	return result;
 }
 
 static int CDECL compare_res(const void *pa, const void *pb)
--- a/src/gfx.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,398 +0,0 @@
-/* $Id$ */
-
-/** @file gfx.h */
-
-/**
- * @defgroup dirty Dirty
- *
- * Handles the repaint of some part of the screen.
- *
- * Some places in the code are called functions which makes something "dirty".
- * This has nothing to do with making a Tile or Window darker or less visible.
- * This term comes from memory caching and is used to define an object must
- * be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever)
- * are changed which are so extensive the object must be repaint its marked
- * as "dirty". The video driver repaint this object instead of the whole screen
- * (this is btw. also possible if needed). This is used to avoid a
- * flickering of the screen by the video driver constantly repainting it.
- *
- * This whole mechanism is controlled by an rectangle defined in #_invalid_rect. This
- * rectangle defines the area on the screen which must be repaint. If a new object
- * needs to be repainted this rectangle is extended to 'catch' the object on the
- * screen. At some point (which is normaly uninteressted for patch writers) this
- * rectangle is send to the video drivers method
- * VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some
- * later point (which is uninteressted, too) the video driver
- * repaints all these saved rectangle instead of the whole screen and drop the
- * rectangle informations. Then a new round begins by marking objects "dirty".
- *
- * @see VideoDriver::MakeDirty
- * @see _invalid_rect
- * @see _screen
- */
-
-
-#ifndef GFX_H
-#define GFX_H
-
-#include "openttd.h"
-#include "zoom.hpp"
-
-enum WindowKeyCodes {
-	WKC_SHIFT = 0x8000,
-	WKC_CTRL  = 0x4000,
-	WKC_ALT   = 0x2000,
-	WKC_META  = 0x1000,
-
-	/* Special ones */
-	WKC_NONE        =  0,
-	WKC_ESC         =  1,
-	WKC_BACKSPACE   =  2,
-	WKC_INSERT      =  3,
-	WKC_DELETE      =  4,
-
-	WKC_PAGEUP      =  5,
-	WKC_PAGEDOWN    =  6,
-	WKC_END         =  7,
-	WKC_HOME        =  8,
-
-	/* Arrow keys */
-	WKC_LEFT        =  9,
-	WKC_UP          = 10,
-	WKC_RIGHT       = 11,
-	WKC_DOWN        = 12,
-
-	/* Return & tab */
-	WKC_RETURN      = 13,
-	WKC_TAB         = 14,
-
-	/* Space */
-	WKC_SPACE       = 32,
-
-	/* Function keys */
-	WKC_F1          = 33,
-	WKC_F2          = 34,
-	WKC_F3          = 35,
-	WKC_F4          = 36,
-	WKC_F5          = 37,
-	WKC_F6          = 38,
-	WKC_F7          = 39,
-	WKC_F8          = 40,
-	WKC_F9          = 41,
-	WKC_F10         = 42,
-	WKC_F11         = 43,
-	WKC_F12         = 44,
-
-	/* Backquote is the key left of "1"
-	 * we only store this key here, no matter what character is really mapped to it
-	 * on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */
-	WKC_BACKQUOTE   = 45,
-	WKC_PAUSE       = 46,
-
-	/* 0-9 are mapped to 48-57
-	 * A-Z are mapped to 65-90
-	 * a-z are mapped to 97-122 */
-
-	/* Numerical keyboard */
-	WKC_NUM_0       = 128,
-	WKC_NUM_1       = 129,
-	WKC_NUM_2       = 130,
-	WKC_NUM_3       = 131,
-	WKC_NUM_4       = 132,
-	WKC_NUM_5       = 133,
-	WKC_NUM_6       = 134,
-	WKC_NUM_7       = 135,
-	WKC_NUM_8       = 136,
-	WKC_NUM_9       = 137,
-	WKC_NUM_DIV     = 138,
-	WKC_NUM_MUL     = 139,
-	WKC_NUM_MINUS   = 140,
-	WKC_NUM_PLUS    = 141,
-	WKC_NUM_ENTER   = 142,
-	WKC_NUM_DECIMAL = 143,
-
-	/* Other keys */
-	WKC_SLASH       = 144, ///< / Forward slash
-	WKC_SEMICOLON   = 145, ///< ; Semicolon
-	WKC_EQUALS      = 146, ///< = Equals
-	WKC_L_BRACKET   = 147, ///< [ Left square bracket
-	WKC_BACKSLASH   = 148, ///< \ Backslash
-	WKC_R_BRACKET   = 149, ///< ] Right square bracket
-	WKC_SINGLEQUOTE = 150, ///< ' Single quote
-	WKC_COMMA       = 151, ///< , Comma
-	WKC_PERIOD      = 152, ///< . Period
-	WKC_MINUS       = 153, ///< - Minus
-};
-
-enum GameModes {
-	GM_MENU,
-	GM_NORMAL,
-	GM_EDITOR
-};
-
-void GameLoop();
-
-void CreateConsole();
-
-typedef int32 CursorID;
-
-struct Point {
-	int x, y;
-};
-
-struct Rect {
-	int left,top,right,bottom;
-};
-
-/** A single sprite of a list of animated cursors */
-struct AnimCursor {
-	static const CursorID LAST = MAX_UVALUE(CursorID);
-	CursorID sprite;   ///< Must be set to LAST_ANIM when it is the last sprite of the loop
-	byte display_time; ///< Amount of ticks this sprite will be shown
-};
-
-struct CursorVars {
-	Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement
-	Point draw_pos, draw_size;    ///< position and size bounding-box for drawing
-	SpriteID sprite; ///< current image of cursor
-	SpriteID pal;
-
-	int wheel;       ///< mouse wheel movement
-
-	/* We need two different vars to keep track of how far the scrollwheel moved.
-	 * OSX uses this for scrolling around the map. */
-	int v_wheel;
-	int h_wheel;
-
-	const AnimCursor *animate_list; ///< in case of animated cursor, list of frames
-	const AnimCursor *animate_cur;  ///< in case of animated cursor, current frame
-	uint animate_timeout;           ///< in case of animated cursor, number of ticks to show the current cursor
-
-	bool visible;    ///< cursor is visible
-	bool dirty;      ///< the rect occupied by the mouse is dirty (redraw)
-	bool fix_at;     ///< mouse is moving, but cursor is not (used for scrolling)
-	bool in_window;  ///< mouse inside this window, determines drawing logic
-};
-
-struct DrawPixelInfo {
-	void *dst_ptr;
-	int left, top, width, height;
-	int pitch;
-	ZoomLevel zoom;
-};
-
-struct Colour {
-	byte r;
-	byte g;
-	byte b;
-};
-
-
-
-extern byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
-extern bool _fullscreen;
-extern CursorVars _cursor;
-extern bool _ctrl_pressed;   ///< Is Ctrl pressed?
-extern bool _shift_pressed;  ///< Is Shift pressed?
-extern byte _fast_forward;
-
-extern bool _left_button_down;
-extern bool _left_button_clicked;
-extern bool _right_button_down;
-extern bool _right_button_clicked;
-
-extern DrawPixelInfo _screen;
-extern bool _exit_game;
-extern bool _networking;         ///< are we in networking mode?
-extern byte _game_mode;
-extern byte _pause_game;
-
-extern int _pal_first_dirty;
-extern int _pal_count_dirty;
-extern int _num_resolutions;
-extern uint16 _resolutions[32][2];
-extern uint16 _cur_resolution[2];
-extern Colour _cur_palette[256];
-
-void HandleKeypress(uint32 key);
-void HandleMouseEvents();
-void CSleep(int milliseconds);
-void UpdateWindows();
-
-uint32 InteractiveRandom(); //< Used for random sequences that are not the same on the other end of the multiplayer link
-uint InteractiveRandomRange(uint max);
-void DrawChatMessage();
-void DrawMouseCursor();
-void ScreenSizeChanged();
-void HandleExitGameRequest();
-void GameSizeChanged();
-void UndrawMouseCursor();
-
-#include "helpers.hpp"
-
-enum FontSize {
-	FS_NORMAL,
-	FS_SMALL,
-	FS_LARGE,
-	FS_END,
-};
-
-DECLARE_POSTFIX_INCREMENT(FontSize);
-
-void RedrawScreenRect(int left, int top, int right, int bottom);
-void GfxScroll(int left, int top, int width, int height, int xo, int yo);
-
-/**
- * Used to only draw a part of the sprite.
- * Draw the subsprite in the rect (sprite_x_offset + left, sprite_y_offset + top) to (sprite_x_offset + right, sprite_y_offset + bottom).
- * Both corners are included in the drawing area.
- */
-struct SubSprite {
-	int left, top, right, bottom;
-};
-
-void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
-
-/* XXX doesn't really belong here, but the only
- * consumers always use it in conjunction with DoDrawString() */
-#define UPARROW   "\xEE\x8A\x80"
-#define DOWNARROW "\xEE\x8A\xAA"
-
-
-int DrawStringCentered(int x, int y, StringID str, uint16 color);
-int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color);
-int DoDrawStringCentered(int x, int y, const char *str, uint16 color);
-
-int DrawString(int x, int y, StringID str, uint16 color);
-int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw);
-
-int DoDrawString(const char *string, int x, int y, uint16 color);
-int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw);
-
-void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color);
-void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color);
-
-int DrawStringRightAligned(int x, int y, StringID str, uint16 color);
-void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw);
-void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color);
-
-void GfxFillRect(int left, int top, int right, int bottom, int color);
-void GfxDrawLine(int left, int top, int right, int bottom, int color);
-void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
-
-BoundingRect GetStringBoundingBox(const char *str);
-uint32 FormatStringLinebreaks(char *str, int maxw);
-void LoadStringWidthTable();
-void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
-uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1);
-
-/**
- * Let the dirty blocks repainting by the video driver.
- *
- * @ingroup dirty
- */
-void DrawDirtyBlocks();
-
-/**
- * Set a new dirty block.
- *
- * @ingroup dirty
- */
-void SetDirtyBlocks(int left, int top, int right, int bottom);
-
-/**
- * Marks the whole screen as dirty.
- *
- * @ingroup dirty
- */
-void MarkWholeScreenDirty();
-
-void GfxInitPalettes();
-
-bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height);
-
-/* window.cpp */
-void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
-
-void SetMouseCursor(SpriteID sprite, SpriteID pal);
-void SetAnimatedMouseCursor(const AnimCursor *table);
-void CursorTick();
-void DrawMouseCursor();
-void ScreenSizeChanged();
-void UndrawMouseCursor();
-bool ChangeResInGame(int w, int h);
-void SortResolutions(int count);
-void ToggleFullScreen(bool fs);
-
-/* gfx.cpp */
-#define ASCII_LETTERSTART 32
-extern FontSize _cur_fontsize;
-
-byte GetCharacterWidth(FontSize size, uint32 key);
-
-static inline byte GetCharacterHeight(FontSize size)
-{
-	switch (size) {
-		default: NOT_REACHED();
-		case FS_NORMAL: return 10;
-		case FS_SMALL:  return 6;
-		case FS_LARGE:  return 18;
-	}
-}
-
-VARDEF DrawPixelInfo *_cur_dpi;
-
-enum {
-	COLOUR_DARK_BLUE,
-	COLOUR_PALE_GREEN,
-	COLOUR_PINK,
-	COLOUR_YELLOW,
-	COLOUR_RED,
-	COLOUR_LIGHT_BLUE,
-	COLOUR_GREEN,
-	COLOUR_DARK_GREEN,
-	COLOUR_BLUE,
-	COLOUR_CREAM,
-	COLOUR_MAUVE,
-	COLOUR_PURPLE,
-	COLOUR_ORANGE,
-	COLOUR_BROWN,
-	COLOUR_GREY,
-	COLOUR_WHITE
-};
-
-/** Colour of the strings, see _string_colormap in table/palettes.h or docs/ottd-colourtext-palette.png */
-enum TextColour {
-	TC_FROMSTRING  = 0x00,
-	TC_BLUE        = 0x00,
-	TC_SILVER      = 0x01,
-	TC_GOLD        = 0x02,
-	TC_RED         = 0x03,
-	TC_PURPLE      = 0x04,
-	TC_LIGHT_BROWN = 0x05,
-	TC_ORANGE      = 0x06,
-	TC_GREEN       = 0x07,
-	TC_YELLOW      = 0x08,
-	TC_DARK_GREEN  = 0x09,
-	TC_CREAM       = 0x0A,
-	TC_BROWN       = 0x0B,
-	TC_WHITE       = 0x0C,
-	TC_LIGHT_BLUE  = 0x0D,
-	TC_GREY        = 0x0E,
-	TC_DARK_BLUE   = 0x0F,
-	TC_BLACK       = 0x10,
-};
-
-/**
- * All 16 colour gradients
- * 8 colours per gradient from darkest (0) to lightest (7)
- */
-VARDEF byte _colour_gradient[16][8];
-
-VARDEF bool _use_dos_palette;
-
-enum StringColorFlags {
-	IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
-};
-
-#endif /* GFX_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gfx_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,182 @@
+/* $Id$ */
+
+/** @file gfx_func.h Functions related to the gfx engine. */
+
+/**
+ * @defgroup dirty Dirty
+ *
+ * Handles the repaint of some part of the screen.
+ *
+ * Some places in the code are called functions which makes something "dirty".
+ * This has nothing to do with making a Tile or Window darker or less visible.
+ * This term comes from memory caching and is used to define an object must
+ * be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever)
+ * are changed which are so extensive the object must be repaint its marked
+ * as "dirty". The video driver repaint this object instead of the whole screen
+ * (this is btw. also possible if needed). This is used to avoid a
+ * flickering of the screen by the video driver constantly repainting it.
+ *
+ * This whole mechanism is controlled by an rectangle defined in #_invalid_rect. This
+ * rectangle defines the area on the screen which must be repaint. If a new object
+ * needs to be repainted this rectangle is extended to 'catch' the object on the
+ * screen. At some point (which is normaly uninteressted for patch writers) this
+ * rectangle is send to the video drivers method
+ * VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some
+ * later point (which is uninteressted, too) the video driver
+ * repaints all these saved rectangle instead of the whole screen and drop the
+ * rectangle informations. Then a new round begins by marking objects "dirty".
+ *
+ * @see VideoDriver::MakeDirty
+ * @see _invalid_rect
+ * @see _screen
+ */
+
+
+#ifndef GFX_FUNC_H
+#define GFX_FUNC_H
+
+#include "gfx_type.h"
+#include "strings_type.h"
+
+void GameLoop();
+
+void CreateConsole();
+
+extern byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
+extern bool _fullscreen;
+extern CursorVars _cursor;
+extern bool _ctrl_pressed;   ///< Is Ctrl pressed?
+extern bool _shift_pressed;  ///< Is Shift pressed?
+extern byte _fast_forward;
+
+extern bool _left_button_down;
+extern bool _left_button_clicked;
+extern bool _right_button_down;
+extern bool _right_button_clicked;
+
+extern DrawPixelInfo _screen;
+
+extern int _pal_first_dirty;
+extern int _pal_count_dirty;
+extern int _num_resolutions;
+extern uint16 _resolutions[32][2];
+extern uint16 _cur_resolution[2];
+extern Colour _cur_palette[256];
+
+void HandleKeypress(uint32 key);
+void HandleMouseEvents();
+void CSleep(int milliseconds);
+void UpdateWindows();
+
+uint32 InteractiveRandom(); //< Used for random sequences that are not the same on the other end of the multiplayer link
+uint InteractiveRandomRange(uint max);
+void DrawChatMessage();
+void DrawMouseCursor();
+void ScreenSizeChanged();
+void HandleExitGameRequest();
+void GameSizeChanged();
+void UndrawMouseCursor();
+
+void RedrawScreenRect(int left, int top, int right, int bottom);
+void GfxScroll(int left, int top, int width, int height, int xo, int yo);
+
+void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
+
+/* XXX doesn't really belong here, but the only
+ * consumers always use it in conjunction with DoDrawString() */
+#define UPARROW   "\xEE\x8A\x80"
+#define DOWNARROW "\xEE\x8A\xAA"
+
+
+int DrawStringCentered(int x, int y, StringID str, uint16 color);
+int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color);
+int DoDrawStringCentered(int x, int y, const char *str, uint16 color);
+
+int DrawString(int x, int y, StringID str, uint16 color);
+int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw);
+
+int DoDrawString(const char *string, int x, int y, uint16 color);
+int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw);
+
+void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color);
+void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color);
+
+int DrawStringRightAligned(int x, int y, StringID str, uint16 color);
+void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw);
+void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color);
+
+void GfxFillRect(int left, int top, int right, int bottom, int color);
+void GfxDrawLine(int left, int top, int right, int bottom, int color);
+void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
+
+Dimension GetStringBoundingBox(const char *str);
+uint32 FormatStringLinebreaks(char *str, int maxw);
+void LoadStringWidthTable();
+void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
+uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1);
+
+/**
+ * Let the dirty blocks repainting by the video driver.
+ *
+ * @ingroup dirty
+ */
+void DrawDirtyBlocks();
+
+/**
+ * Set a new dirty block.
+ *
+ * @ingroup dirty
+ */
+void SetDirtyBlocks(int left, int top, int right, int bottom);
+
+/**
+ * Marks the whole screen as dirty.
+ *
+ * @ingroup dirty
+ */
+void MarkWholeScreenDirty();
+
+void GfxInitPalettes();
+
+bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height);
+
+/* window.cpp */
+void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
+
+void SetMouseCursor(SpriteID sprite, SpriteID pal);
+void SetAnimatedMouseCursor(const AnimCursor *table);
+void CursorTick();
+void DrawMouseCursor();
+void ScreenSizeChanged();
+void UndrawMouseCursor();
+bool ChangeResInGame(int w, int h);
+void SortResolutions(int count);
+bool ToggleFullScreen(bool fs);
+
+/* gfx.cpp */
+#define ASCII_LETTERSTART 32
+extern FontSize _cur_fontsize;
+
+byte GetCharacterWidth(FontSize size, uint32 key);
+
+static inline byte GetCharacterHeight(FontSize size)
+{
+	switch (size) {
+		default: NOT_REACHED();
+		case FS_NORMAL: return 10;
+		case FS_SMALL:  return 6;
+		case FS_LARGE:  return 18;
+	}
+}
+
+extern DrawPixelInfo *_cur_dpi;
+
+/**
+ * All 16 colour gradients
+ * 8 colours per gradient from darkest (0) to lightest (7)
+ */
+extern byte _colour_gradient[16][8];
+
+extern bool _use_dos_palette;
+
+#endif /* GFX_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gfx_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,210 @@
+/* $Id$ */
+
+/** @file gfx_type.h Types related to the graphics and/or input devices. */
+
+#ifndef GFX_TYPE_H
+#define GFX_TYPE_H
+
+#include "core/enum_type.hpp"
+#include "core/geometry_type.hpp"
+#include "zoom_type.h"
+
+typedef uint32 SpriteID;      ///< The number of a sprite, without mapping bits and colortables
+struct PalSpriteID {
+	SpriteID sprite;
+	SpriteID pal;
+};
+typedef int32 CursorID;
+
+enum WindowKeyCodes {
+	WKC_SHIFT = 0x8000,
+	WKC_CTRL  = 0x4000,
+	WKC_ALT   = 0x2000,
+	WKC_META  = 0x1000,
+
+	/* Special ones */
+	WKC_NONE        =  0,
+	WKC_ESC         =  1,
+	WKC_BACKSPACE   =  2,
+	WKC_INSERT      =  3,
+	WKC_DELETE      =  4,
+
+	WKC_PAGEUP      =  5,
+	WKC_PAGEDOWN    =  6,
+	WKC_END         =  7,
+	WKC_HOME        =  8,
+
+	/* Arrow keys */
+	WKC_LEFT        =  9,
+	WKC_UP          = 10,
+	WKC_RIGHT       = 11,
+	WKC_DOWN        = 12,
+
+	/* Return & tab */
+	WKC_RETURN      = 13,
+	WKC_TAB         = 14,
+
+	/* Space */
+	WKC_SPACE       = 32,
+
+	/* Function keys */
+	WKC_F1          = 33,
+	WKC_F2          = 34,
+	WKC_F3          = 35,
+	WKC_F4          = 36,
+	WKC_F5          = 37,
+	WKC_F6          = 38,
+	WKC_F7          = 39,
+	WKC_F8          = 40,
+	WKC_F9          = 41,
+	WKC_F10         = 42,
+	WKC_F11         = 43,
+	WKC_F12         = 44,
+
+	/* Backquote is the key left of "1"
+	 * we only store this key here, no matter what character is really mapped to it
+	 * on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */
+	WKC_BACKQUOTE   = 45,
+	WKC_PAUSE       = 46,
+
+	/* 0-9 are mapped to 48-57
+	 * A-Z are mapped to 65-90
+	 * a-z are mapped to 97-122 */
+
+	/* Numerical keyboard */
+	WKC_NUM_0       = 128,
+	WKC_NUM_1       = 129,
+	WKC_NUM_2       = 130,
+	WKC_NUM_3       = 131,
+	WKC_NUM_4       = 132,
+	WKC_NUM_5       = 133,
+	WKC_NUM_6       = 134,
+	WKC_NUM_7       = 135,
+	WKC_NUM_8       = 136,
+	WKC_NUM_9       = 137,
+	WKC_NUM_DIV     = 138,
+	WKC_NUM_MUL     = 139,
+	WKC_NUM_MINUS   = 140,
+	WKC_NUM_PLUS    = 141,
+	WKC_NUM_ENTER   = 142,
+	WKC_NUM_DECIMAL = 143,
+
+	/* Other keys */
+	WKC_SLASH       = 144, ///< / Forward slash
+	WKC_SEMICOLON   = 145, ///< ; Semicolon
+	WKC_EQUALS      = 146, ///< = Equals
+	WKC_L_BRACKET   = 147, ///< [ Left square bracket
+	WKC_BACKSLASH   = 148, ///< \ Backslash
+	WKC_R_BRACKET   = 149, ///< ] Right square bracket
+	WKC_SINGLEQUOTE = 150, ///< ' Single quote
+	WKC_COMMA       = 151, ///< , Comma
+	WKC_PERIOD      = 152, ///< . Period
+	WKC_MINUS       = 153, ///< - Minus
+};
+
+/** A single sprite of a list of animated cursors */
+struct AnimCursor {
+	static const CursorID LAST = MAX_UVALUE(CursorID);
+	CursorID sprite;   ///< Must be set to LAST_ANIM when it is the last sprite of the loop
+	byte display_time; ///< Amount of ticks this sprite will be shown
+};
+
+struct CursorVars {
+	Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement
+	Point draw_pos, draw_size;    ///< position and size bounding-box for drawing
+	SpriteID sprite; ///< current image of cursor
+	SpriteID pal;
+
+	int wheel;       ///< mouse wheel movement
+
+	/* We need two different vars to keep track of how far the scrollwheel moved.
+	 * OSX uses this for scrolling around the map. */
+	int v_wheel;
+	int h_wheel;
+
+	const AnimCursor *animate_list; ///< in case of animated cursor, list of frames
+	const AnimCursor *animate_cur;  ///< in case of animated cursor, current frame
+	uint animate_timeout;           ///< in case of animated cursor, number of ticks to show the current cursor
+
+	bool visible;    ///< cursor is visible
+	bool dirty;      ///< the rect occupied by the mouse is dirty (redraw)
+	bool fix_at;     ///< mouse is moving, but cursor is not (used for scrolling)
+	bool in_window;  ///< mouse inside this window, determines drawing logic
+};
+
+struct DrawPixelInfo {
+	void *dst_ptr;
+	int left, top, width, height;
+	int pitch;
+	ZoomLevel zoom;
+};
+
+struct Colour {
+	byte r;
+	byte g;
+	byte b;
+};
+
+enum FontSize {
+	FS_NORMAL,
+	FS_SMALL,
+	FS_LARGE,
+	FS_END,
+};
+DECLARE_POSTFIX_INCREMENT(FontSize);
+
+/**
+ * Used to only draw a part of the sprite.
+ * Draw the subsprite in the rect (sprite_x_offset + left, sprite_y_offset + top) to (sprite_x_offset + right, sprite_y_offset + bottom).
+ * Both corners are included in the drawing area.
+ */
+struct SubSprite {
+	int left, top, right, bottom;
+};
+
+enum {
+	COLOUR_DARK_BLUE,
+	COLOUR_PALE_GREEN,
+	COLOUR_PINK,
+	COLOUR_YELLOW,
+	COLOUR_RED,
+	COLOUR_LIGHT_BLUE,
+	COLOUR_GREEN,
+	COLOUR_DARK_GREEN,
+	COLOUR_BLUE,
+	COLOUR_CREAM,
+	COLOUR_MAUVE,
+	COLOUR_PURPLE,
+	COLOUR_ORANGE,
+	COLOUR_BROWN,
+	COLOUR_GREY,
+	COLOUR_WHITE
+};
+
+/** Colour of the strings, see _string_colormap in table/palettes.h or docs/ottd-colourtext-palette.png */
+enum TextColour {
+	TC_FROMSTRING  = 0x00,
+	TC_BLUE        = 0x00,
+	TC_SILVER      = 0x01,
+	TC_GOLD        = 0x02,
+	TC_RED         = 0x03,
+	TC_PURPLE      = 0x04,
+	TC_LIGHT_BROWN = 0x05,
+	TC_ORANGE      = 0x06,
+	TC_GREEN       = 0x07,
+	TC_YELLOW      = 0x08,
+	TC_DARK_GREEN  = 0x09,
+	TC_CREAM       = 0x0A,
+	TC_BROWN       = 0x0B,
+	TC_WHITE       = 0x0C,
+	TC_LIGHT_BLUE  = 0x0D,
+	TC_GREY        = 0x0E,
+	TC_DARK_BLUE   = 0x0F,
+	TC_BLACK       = 0x10,
+};
+
+enum StringColorFlags {
+	IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
+};
+
+#endif /* GFX_TYPE_H */
--- a/src/gfxinit.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/gfxinit.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,23 +5,22 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "gfx.h"
 #include "gfxinit.h"
 #include "spritecache.h"
 #include "table/sprites.h"
 #include "fileio.h"
 #include "fios.h"
-#include "string.h"
 #include "newgrf.h"
 #include "md5.h"
 #include "variables.h"
 #include "fontcache.h"
+#include "gfx_func.h"
+#include "core/alloc_func.hpp"
 #include <string.h>
 
 struct MD5File {
 	const char * filename;     ///< filename
-	md5_byte_t hash[16];       ///< md5 sum of the file
+	uint8 hash[16];            ///< md5 sum of the file
 };
 
 struct FileList {
@@ -109,20 +108,19 @@
 	FILE *f = FioFOpenFile(file.filename, "rb", DATA_DIR, &size);
 
 	if (f != NULL) {
-		md5_state_t filemd5state;
-		md5_byte_t buffer[1024];
-		md5_byte_t digest[16];
+		Md5 checksum;
+		uint8 buffer[1024];
+		uint8 digest[16];
 		size_t len;
 
-		md5_init(&filemd5state);
 		while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) {
 			size -= len;
-			md5_append(&filemd5state, buffer, len);
+			checksum.Append(buffer, len);
 		}
 
 		FioFCloseFile(f);
 
-		md5_finish(&filemd5state, digest);
+		checksum.Finish(digest);
 		return memcmp(file.hash, digest, sizeof(file.hash)) == 0;
 	} else { // file not found
 		return false;
--- a/src/gfxinit.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/gfxinit.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef GFXINIT_H
 #define GFXINIT_H
 
+#include "gfx_type.h"
+
 void CheckExternalFiles();
 void GfxLoadSprites();
 void LoadSpritesIndexed(int file_index, uint *sprite_id, const SpriteID *index_tbl);
--- a/src/graph_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/graph_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,18 +5,18 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "strings.h"
 #include "table/sprites.h"
-#include "functions.h"
-#include "window.h"
 #include "gui.h"
-#include "gfx.h"
+#include "window_gui.h"
 #include "player.h"
-#include "economy.h"
+#include "economy_func.h"
 #include "variables.h"
-#include "date.h"
-#include "helpers.hpp"
 #include "cargotype.h"
+#include "strings_func.h"
+#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;
@@ -65,7 +65,7 @@
 	uint height;    ///< The height of the graph in pixels.
 	StringID format_str_y_axis;
 	byte colors[GRAPH_MAX_DATASETS];
-	Money cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
+	OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
 };
 
 static void DrawGraph(const GraphDrawer *gw)
@@ -133,7 +133,7 @@
 	for (int i = 0; i < gw->num_dataset; i++) {
 		if (!HasBit(gw->excluded_data, i)) {
 			for (int j = 0; j < gw->num_on_x_axis; j++) {
-				Money datapoint = gw->cost[i][j];
+				OverflowSafeInt64 datapoint = gw->cost[i][j];
 
 				if (datapoint != INVALID_DATAPOINT) {
 					/* For now, if the graph has negative values the scaling is
@@ -215,12 +215,31 @@
 			uint prev_y = INVALID_DATAPOINT_POS;
 
 			for (int j = 0; j < gw->num_on_x_axis; j++) {
-				Money datapoint = gw->cost[i][j];
+				OverflowSafeInt64 datapoint = gw->cost[i][j];
 
 				if (datapoint != INVALID_DATAPOINT) {
-					/* XXX: This can overflow if x_axis_offset * datapoint is
-					 * too big to fit in an int64. */
-					y = gw->top + x_axis_offset - (x_axis_offset * datapoint) / highest_value;
+					/*
+					 * Check whether we need to reduce the 'accuracy' of the
+					 * datapoint value and the highest value to splut overflows.
+					 * And when 'drawing' 'one million' or 'one million and one'
+					 * there is no significant difference, so the least
+					 * significant bits can just be removed.
+					 *
+					 * If there are more bits needed than would fit in a 32 bits
+					 * integer, so at about 31 bits because of the sign bit, the
+					 * least significant bits are removed.
+					 */
+					int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint));
+					int reduce_range = max(mult_range - 31, 0);
+
+					/* Handle negative values differently (don't shift sign) */
+					if (datapoint < 0) {
+						datapoint = -(abs(datapoint) >> reduce_range);
+					} else {
+						datapoint >>= reduce_range;
+					}
+
+					y = gw->top + x_axis_offset - (x_axis_offset * datapoint) / (highest_value >> reduce_range);
 
 					/* Draw the point. */
 					GfxFillRect(x - 1, y - 1, x + 1, y + 1, color);
@@ -250,7 +269,7 @@
 	switch (e->event) {
 		case WE_CREATE:
 			for (uint i = 3; i < w->widget_count; i++) {
-				if (!HasBit(_legend_excluded_players, i - 3)) LowerWindowWidget(w, i);
+				if (!HasBit(_legend_excluded_players, i - 3)) w->LowerWidget(i);
 			}
 			break;
 
@@ -261,7 +280,7 @@
 				if (p->is_active) continue;
 
 				SetBit(_legend_excluded_players, p->index);
-				RaiseWindowWidget(w, p->index + 3);
+				w->RaiseWidget(p->index + 3);
 			}
 
 			DrawWindowWidgets(w);
@@ -279,10 +298,10 @@
 		}
 
 		case WE_CLICK:
-			if (!IS_INT_INSIDE(e->we.click.widget, 3, 11)) return;
+			if (!IsInsideMM(e->we.click.widget, 3, 11)) return;
 
 			ToggleBit(_legend_excluded_players, e->we.click.widget - 3);
-			ToggleWidgetLoweredState(w, e->we.click.widget);
+			w->ToggleWidgetLoweredState(e->we.click.widget);
 			SetWindowDirty(w);
 			InvalidateWindow(WC_INCOME_GRAPH, 0);
 			InvalidateWindow(WC_OPERATING_PROFIT, 0);
@@ -733,7 +752,7 @@
 					 * both the text and the colored box have to be manually painted.
 					 * clk_dif will move one pixel down and one pixel to the right
 					 * when the button is clicked */
-					byte clk_dif = IsWindowWidgetLowered(w, i + 3) ? 1 : 0;
+					byte clk_dif = w->IsWidgetLowered(i + 3) ? 1 : 0;
 
 					GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
 					GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
@@ -761,7 +780,7 @@
 		case WE_CLICK:
 			if (e->we.click.widget >= 3) {
 				ToggleBit(_legend_excluded_cargo, e->we.click.widget - 3);
-				ToggleWidgetLoweredState(w, e->we.click.widget);
+				w->ToggleWidgetLoweredState(e->we.click.widget);
 				SetWindowDirty(w);
 			}
 			break;
@@ -816,7 +835,7 @@
 		wi->data     = 0;
 		wi->tooltips = STR_7064_TOGGLE_GRAPH_FOR_CARGO;
 
-		if (!HasBit(_legend_excluded_cargo, i)) LowerWindowWidget(w, i + 3);
+		if (!HasBit(_legend_excluded_cargo, i)) w->LowerWidget(i + 3);
 	}
 
 	SetWindowDirty(w);
@@ -932,8 +951,8 @@
 			if (_performance_rating_detail_player == INVALID_PLAYER || !GetPlayer(_performance_rating_detail_player)->is_active) {
 				if (_performance_rating_detail_player != INVALID_PLAYER) {
 					/* Raise and disable the widget for the previous selection. */
-					RaiseWindowWidget(w, _performance_rating_detail_player + 13);
-					DisableWindowWidget(w, _performance_rating_detail_player + 13);
+					w->RaiseWidget(_performance_rating_detail_player + 13);
+					w->DisableWidget(_performance_rating_detail_player + 13);
 					SetWindowDirty(w);
 
 					_performance_rating_detail_player = INVALID_PLAYER;
@@ -942,7 +961,7 @@
 				for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
 					if (GetPlayer(i)->is_active) {
 						/* Lower the widget corresponding to this player. */
-						LowerWindowWidget(w, i + 13);
+						w->LowerWidget(i + 13);
 						SetWindowDirty(w);
 
 						_performance_rating_detail_player = i;
@@ -958,9 +977,9 @@
 			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
 				if (!GetPlayer(i)->is_active) {
 					/* Check if we have the player as an active player */
-					if (!IsWindowWidgetDisabled(w, i + 13)) {
+					if (!w->IsWidgetDisabled(i + 13)) {
 						/* Bah, player gone :( */
-						DisableWindowWidget(w, i + 13);
+						w->DisableWidget(i + 13);
 
 						/* We need a repaint */
 						SetWindowDirty(w);
@@ -969,9 +988,9 @@
 				}
 
 				/* Check if we have the player marked as inactive */
-				if (IsWindowWidgetDisabled(w, i + 13)) {
+				if (w->IsWidgetDisabled(i + 13)) {
 					/* New player! Yippie :p */
-					EnableWindowWidget(w, i + 13);
+					w->EnableWidget(i + 13);
 					/* We need a repaint */
 					SetWindowDirty(w);
 				}
@@ -1050,12 +1069,12 @@
 
 		case WE_CLICK:
 			/* Check which button is clicked */
-			if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) {
+			if (IsInsideMM(e->we.click.widget, 13, 21)) {
 				/* Is it no on disable? */
-				if (!IsWindowWidgetDisabled(w, e->we.click.widget)) {
-					RaiseWindowWidget(w, _performance_rating_detail_player + 13);
+				if (!w->IsWidgetDisabled(e->we.click.widget)) {
+					w->RaiseWidget(_performance_rating_detail_player + 13);
 					_performance_rating_detail_player = (PlayerID)(e->we.click.widget - 13);
-					LowerWindowWidget(w, _performance_rating_detail_player + 13);
+					w->LowerWidget(_performance_rating_detail_player + 13);
 					SetWindowDirty(w);
 				}
 			}
@@ -1066,7 +1085,7 @@
 
 			/* Disable the players who are not active */
 			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
-				SetWindowWidgetDisabledState(w, i + 13, !GetPlayer(i)->is_active);
+				w->SetWidgetDisabledState(i + 13, !GetPlayer(i)->is_active);
 			}
 			/* Update all player stats with the current data
 			 * (this is because _score_info is not saved to a savegame) */
@@ -1077,13 +1096,15 @@
 			w->custom[0] = DAY_TICKS;
 			w->custom[1] = 5;
 
-			if (_performance_rating_detail_player != INVALID_PLAYER) LowerWindowWidget(w, _performance_rating_detail_player + 13);
+			if (_performance_rating_detail_player != INVALID_PLAYER) w->LowerWidget(_performance_rating_detail_player + 13);
 			SetWindowDirty(w);
 
 			break;
 		}
 
 		case WE_TICK:
+			if (_pause_game != 0) break;
+
 			/* Update the player score every 5 days */
 			if (--w->custom[0] == 0) {
 				w->custom[0] = DAY_TICKS;
--- a/src/group_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/group_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,21 +5,23 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "variables.h"
-#include "functions.h"
 #include "player.h"
 #include "table/strings.h"
-#include "command.h"
-#include "vehicle.h"
+#include "command_func.h"
 #include "saveload.h"
 #include "debug.h"
 #include "group.h"
 #include "train.h"
 #include "aircraft.h"
-#include "string.h"
-#include "window.h"
 #include "vehicle_gui.h"
-#include "strings.h"
 #include "misc/autoptr.hpp"
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "autoreplace_base.h"
+#include "autoreplace_func.h"
+#include "string_func.h"
 
 /**
  * Update the num engines of a groupID. Decrease the old one and increase the new one
@@ -196,6 +198,8 @@
 		g->string_id = str;
 
 		InvalidateWindowData(GetWCForVT(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_player);
+	} else {
+		DeleteName(str);
 	}
 
 	return CommandCost();
--- a/src/group_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/group_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,24 +4,26 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "window.h"
 #include "gui.h"
-#include "gfx.h"
-#include "vehicle.h"
-#include "command.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
+#include "command_func.h"
 #include "engine.h"
 #include "vehicle_gui.h"
 #include "depot.h"
 #include "train.h"
-#include "date.h"
 #include "group.h"
-#include "helpers.hpp"
-#include "viewport.h"
-#include "strings.h"
 #include "debug.h"
+#include "strings_func.h"
+#include "core/alloc_func.hpp"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "autoreplace_gui.h"
+#include "string_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 
 
 struct Sorting {
@@ -40,12 +42,9 @@
 	const Group *g;
 	uint n = 0;
 
-	if (!(gl->l.flags & VL_REBUILD) || GetGroupArraySize() == 0) return;
+	if (!(gl->l.flags & VL_REBUILD)) return;
 
 	list = MallocT<const Group*>(GetGroupArraySize());
-	if (list == NULL) {
-		error("Could not allocate memory for the group-sorting-list");
-	}
 
 	FOR_ALL_GROUPS(g) {
 		if (g->owner == owner && g->vehicle_type == vehicle_type) list[n++] = g;
@@ -53,9 +52,6 @@
 
 	free((void*)gl->sort_list);
 	gl->sort_list = MallocT<const Group *>(n);
-	if (n != 0 && gl->sort_list == NULL) {
-		error("Could not allocate memory for the group-sorting-list");
-	}
 	gl->l.list_length = n;
 
 	for (uint i = 0; i < n; ++i) gl->sort_list[i] = list[i];
@@ -217,6 +213,7 @@
 	gl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;	// Set up resort timer
 
 	gv->group_sel = ALL_GROUP;
+	gv->vehicle_sel = INVALID_VEHICLE;
 
 	switch (gv->vehicle_type) {
 		case VEH_TRAIN:
@@ -266,7 +263,7 @@
  */
 static void UpdateGroupActionDropdown(Window *w, GroupID gid, bool refresh = true)
 {
-	if (refresh && !IsWindowWidgetLowered(w, GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) return;
+	if (refresh && !w->IsWidgetLowered(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) return;
 
 	static StringID action_str[] = {
 		STR_REPLACE_VEHICLES,
@@ -329,8 +326,8 @@
 			SetVScroll2Count(w, gv->l.list_length);
 
 			/* The drop down menu is out, *but* it may not be used, retract it. */
-			if (gv->l.list_length == 0 && IsWindowWidgetLowered(w, GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) {
-				RaiseWindowWidget(w, GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
+			if (gv->l.list_length == 0 && w->IsWidgetLowered(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) {
+				w->RaiseWidget(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
 				Window **w2;
 				FOR_ALL_WINDOWS(w2) {
 					if (w->window_class  == WP(*w2, dropdown_d).parent_wnd_class &&
@@ -342,7 +339,7 @@
 			}
 
 			/* Disable all lists management button when the list is empty */
-			SetWindowWidgetsDisabledState(w, gv->l.list_length == 0 || _local_player != owner,
+			w->SetWidgetsDisabledState(gv->l.list_length == 0 || _local_player != owner,
 					GRP_WIDGET_STOP_ALL,
 					GRP_WIDGET_START_ALL,
 					GRP_WIDGET_MANAGE_VEHICLES,
@@ -350,7 +347,7 @@
 					WIDGET_LIST_END);
 
 			/* Disable the group specific function when we select the default group or all vehicles */
-			SetWindowWidgetsDisabledState(w, IsDefaultGroupID(gv->group_sel) || IsAllGroupID(gv->group_sel) || _local_player != owner,
+			w->SetWidgetsDisabledState(IsDefaultGroupID(gv->group_sel) || IsAllGroupID(gv->group_sel) || _local_player != owner,
 					GRP_WIDGET_DELETE_GROUP,
 					GRP_WIDGET_RENAME_GROUP,
 					GRP_WIDGET_REPLACE_PROTECTION,
@@ -362,7 +359,7 @@
 			 *  verify, whether you are the owner of the vehicle,
 			 *  so it doesn't have to be disabled
 			 */
-			SetWindowWidgetsDisabledState(w, _local_player != owner,
+			w->SetWidgetsDisabledState(_local_player != owner,
 					GRP_WIDGET_CREATE_GROUP,
 					GRP_WIDGET_AVAILABLE_VEHICLES,
 					WIDGET_LIST_END);
@@ -479,7 +476,7 @@
 
 				assert(v->type == gv->vehicle_type && v->owner == owner);
 
-				DrawVehicleImage(v, x + 19, y2 + 6, w->hscroll.cap, 0, gv->vehicle_sel);
+				DrawVehicleImage(v, x + 19, y2 + 6, gv->vehicle_sel, w->hscroll.cap, 0);
 				DrawVehicleProfitButton(v, x, y2 + 13);
 
 				SetDParam(0, v->unitnumber);
@@ -758,6 +755,7 @@
 
 
 		case WE_TICK: // resort the lists every 20 seconds orso (10 days)
+			if (_pause_game != 0) break;
 			if (--gv->l.resort_timer == 0) {
 				gv->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 				gv->l.flags |= VL_RESORT;
@@ -769,7 +767,7 @@
 				SetWindowDirty(w);
 			}
 			break;
-		}
+	}
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/group_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,12 @@
+/* $Id$ */
+
+/** @file group_gui.h Functions/definitions that have something to do with groups. */
+
+#ifndef GROUP_GUI_H
+#define GROUP_GUI_H
+
+#include "vehicle_type.h"
+
+void ShowPlayerGroup(PlayerID player, VehicleType veh);
+
+#endif /* GROUP_GUI_H */
--- a/src/gui.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,15 +5,15 @@
 #ifndef GUI_H
 #define GUI_H
 
-#include "station.h"
-#include "window.h"
-#include "string.h"
+#include "window_type.h"
+#include "vehicle_type.h"
+#include "gfx_type.h"
+#include "economy_type.h"
+#include "tile_type.h"
 
 /* main_gui.cpp */
-void SetupColorsAndInitialWindow();
 void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);
 void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2);
-void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
 /* settings_gui.cpp */
 void ShowGameOptions();
@@ -36,39 +36,25 @@
 void ShowMessageOptions();
 void ShowMessageHistory();
 
-/* rail_gui.cpp */
-void ShowBuildRailToolbar(RailType railtype, int button);
-void PlaceProc_BuyLand(TileIndex tile);
-void ReinitGuiAfterToggleElrail(bool disable);
-
 /* train_gui.cpp */
 void ShowOrdersWindow(const Vehicle *v);
 
-/* road_gui.cpp */
-void ShowBuildRoadToolbar(RoadType roadtype);
-void ShowBuildRoadScenToolbar();
-
 /* dock_gui.cpp */
 void ShowBuildDocksToolbar();
 
 /* aircraft_gui.cpp */
 void ShowBuildAirToolbar();
 
-/* terraform_gui.cpp */
-void ShowTerraformToolbar(Window *link = NULL);
-
 /* tgp_gui.cpp */
 void ShowGenerateLandscape();
 void ShowHeightmapLoad();
 
-void PlaceProc_DemolishArea(TileIndex tile);
-void PlaceProc_LevelLand(TileIndex tile);
-bool GUIPlaceProcDragXY(const WindowEvent *e);
-
 /** Drag and drop selection process, or, what to do with an area of land when
  * you've selected it. */
 enum {
 	DDSP_DEMOLISH_AREA,
+	DDSP_RAISE_AND_LEVEL_AREA,
+	DDSP_LOWER_AND_LEVEL_AREA,
 	DDSP_LEVEL_AREA,
 	DDSP_CREATE_DESERT,
 	DDSP_CREATE_ROCKS,
@@ -106,15 +92,6 @@
 void ShowEstimatedCostOrIncome(Money cost, int x, int y);
 void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y);
 
-enum StationCoverageType {
-	SCT_PASSENGERS_ONLY,
-	SCT_NON_PASSENGERS_ONLY,
-	SCT_ALL
-};
-
-void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad);
-void CheckRedrawStationCoverage(const Window *w);
-
 void ShowSmallMap();
 void ShowExtraViewPortWindow();
 void SetVScrollCount(Window *w, int num);
@@ -123,19 +100,6 @@
 
 void ShowCheatWindow();
 
-void DrawEditBox(Window *w, querystr_d *string, int wid);
-void HandleEditBox(Window *w, querystr_d *string, int wid);
-int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we);
-bool HandleCaret(Textbuf *tb);
-
-void DeleteTextBufferAll(Textbuf *tb);
-bool DeleteTextBufferChar(Textbuf *tb, int delmode);
-bool InsertTextBufferChar(Textbuf *tb, uint32 key);
-bool InsertTextBufferClipboard(Textbuf *tb);
-bool MoveTextBufferPos(Textbuf *tb, int navmode);
-void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth);
-void UpdateTextBufferSize(Textbuf *tb);
-
 void BuildFileList();
 void SetFiosType(const byte fiostype);
 
@@ -146,18 +110,12 @@
 void ShowBuildBridgeWindow(uint start, uint end, byte type);
 
 void ShowBuildIndustryWindow();
-void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter);
-void ShowQuery(StringID caption, StringID message, Window *w, void (*callback)(Window*, bool));
 void ShowMusicWindow();
 
 /* main_gui.cpp */
 void HandleOnEditText(const char *str);
 VARDEF bool _station_show_coverage;
-VARDEF PlaceProc *_place_proc;
 
-/* vehicle_gui.cpp */
 void InitializeGUI();
 
-void ShowPlayerGroup(PlayerID player, VehicleType veh);
-
 #endif /* GUI_H */
--- a/src/heightmap.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/heightmap.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,17 +5,17 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "variables.h"
-#include "functions.h"
 #include "heightmap.h"
 #include "clear_map.h"
 #include "table/strings.h"
 #include "void_map.h"
 #include "debug.h"
-#include "gfx.h"
 #include "gui.h"
 #include "saveload.h"
 #include "bmp.h"
-#include "helpers.hpp"
+#include "gfx_func.h"
+#include "core/alloc_func.hpp"
+#include "fios.h"
 
 /**
  * Convert RGB colors to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue
--- a/src/helpers.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-/* $Id$ */
-
-/** @file helpers.hpp */
-
-#ifndef HELPERS_HPP
-#define HELPERS_HPP
-
-#include "macros.h"
-
-/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
-*  from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
-template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
-{
-	T *t_ptr = (T*)malloc(num_elements * sizeof(T));
-	return t_ptr;
-}
-/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
-*  from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
-template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
-{
-	T *t_ptr = (T*)calloc(num_elements, sizeof(T));
-	return t_ptr;
-}
-/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
-*  from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
-template <typename T> FORCEINLINE T* ReallocT(T* t_ptr, size_t num_elements)
-{
-	t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
-	return t_ptr;
-}
-
-
-/** type safe swap operation */
-template<typename T> void Swap(T& a, T& b)
-{
-	T t = a;
-	a = b;
-	b = t;
-}
-
-
-/** Some enums need to have allowed incrementing (i.e. StationClassID) */
-#define DECLARE_POSTFIX_INCREMENT(type) \
-	FORCEINLINE type operator ++(type& e, int) \
-	{ \
-		type e_org = e; \
-		e = (type)((int)e + 1); \
-		return e_org; \
-	} \
-	FORCEINLINE type operator --(type& e, int) \
-	{ \
-		type e_org = e; \
-		e = (type)((int)e - 1); \
-		return e_org; \
-	}
-
-
-
-/** Operators to allow to work with enum as with type safe bit set in C++ */
-# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
-	FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
-	FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
-	FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
-	FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
-	FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
-	FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
-	FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
-
-
-/** Informative template class exposing basic enumeration properties used by several
- *  other templates below. Here we have only forward declaration. For each enum type
- *  we will create specialization derived from MakeEnumPropsT<>.
- *  i.e.:
- *    template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
- *  followed by:
- *    typedef TinyEnumT<Track> TrackByte;
- */
-template <typename Tenum_t> struct EnumPropsT;
-
-/** Helper template class that makes basic properties of given enumeration type visible
- *  from outsize. It is used as base class of several EnumPropsT specializations each
- *  dedicated to one of commonly used enumeration types.
- *  @param Tenum_t enumeration type that you want to describe
- *  @param Tstorage_t what storage type would be sufficient (i.e. byte)
- *  @param Tbegin first valid value from the contiguous range (i.e. TRACK_BEGIN)
- *  @param Tend one past the last valid value from the contiguous range (i.e. TRACK_END)
- *  @param Tinvalid value used as invalid value marker (i.e. INVALID_TRACK)
- */
-template <typename Tenum_t, typename Tstorage_t, Tenum_t Tbegin, Tenum_t Tend, Tenum_t Tinvalid>
-struct MakeEnumPropsT {
-	typedef Tenum_t type;                     ///< enum type (i.e. Trackdir)
-	typedef Tstorage_t storage;               ///< storage type (i.e. byte)
-	static const Tenum_t begin = Tbegin;      ///< lowest valid value (i.e. TRACKDIR_BEGIN)
-	static const Tenum_t end = Tend;          ///< one after the last valid value (i.e. TRACKDIR_END)
-	static const Tenum_t invalid = Tinvalid;  ///< what value is used as invalid value (i.e. INVALID_TRACKDIR)
-};
-
-
-
-/** In some cases we use byte or uint16 to store values that are defined as enum. It is
-	*  necessary in order to control the sizeof() such values. Some compilers make enum
-	*  the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
-	*  compiler type-checking causes errors like:
-	*     'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
-	*  u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
-	*  to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
-template <typename Tenum_t> struct TinyEnumT;
-
-/** The general declaration of TinyEnumT<> (above) */
-template <typename Tenum_t> struct TinyEnumT
-{
-	typedef Tenum_t enum_type;                      ///< expose our enumeration type (i.e. Trackdir) to outside
-	typedef EnumPropsT<Tenum_t> Props;              ///< make easier access to our enumeration propeties
-	typedef typename Props::storage storage_type;   ///< small storage type
-	static const enum_type begin = Props::begin;    ///< enum beginning (i.e. TRACKDIR_BEGIN)
-	static const enum_type end = Props::end;        ///< enum end (i.e. TRACKDIR_END)
-	static const enum_type invalid = Props::invalid;///< invalid value (i.e. INVALID_TRACKDIR)
-
-	storage_type m_val;  ///< here we hold the actual value in small (i.e. byte) form
-
-	/** Cast operator - invoked then the value is assigned to the Tenum_t type */
-	FORCEINLINE operator enum_type () const
-	{
-		return (enum_type)m_val;
-	}
-
-	/** Assignment operator (from Tenum_t type) */
-	FORCEINLINE TinyEnumT& operator = (enum_type e)
-	{
-		m_val = (storage_type)e; return *this;
-	}
-
-	/** postfix ++ operator on tiny type */
-	FORCEINLINE TinyEnumT operator ++ (int)
-	{
-		TinyEnumT org = *this;
-		if (++m_val >= end) m_val -= (storage_type)(end - begin);
-		return org;
-	}
-
-	/** prefix ++ operator on tiny type */
-	FORCEINLINE TinyEnumT& operator ++ ()
-	{
-		if (++m_val >= end) m_val -= (storage_type)(end - begin);
-		return *this;
-	}
-};
-
-/**
- * Overflow safe template for integers, i.e. integers that will never overflow
- * you multiply the maximum value with 2, or add 2, or substract somethng from
- * the minimum value, etc.
- * @param T     the type these integers are stored with.
- * @param T_MAX the maximum value for the integers.
- * @param T_MIN the minimum value for the integers.
- */
-template <class T, T T_MAX, T T_MIN>
-class OverflowSafeInt
-{
-private:
-	/** The non-overflow safe backend to store the value in. */
-	T m_value;
-public:
-	OverflowSafeInt() : m_value(0) { }
-
-	OverflowSafeInt(const OverflowSafeInt& other) { this->m_value = other.m_value; }
-	OverflowSafeInt(const int64 int_)             { this->m_value = int_; }
-
-	FORCEINLINE OverflowSafeInt& operator = (const OverflowSafeInt& other) { this->m_value = other.m_value; return *this; }
-
-	FORCEINLINE OverflowSafeInt operator - () const { return OverflowSafeInt(-this->m_value); }
-
-	/**
-	 * Safe implementation of addition.
-	 * @param other the amount to add
-	 * @note when the addition would yield more than T_MAX (or less than T_MIN),
-	 *       it will be T_MAX (respectively T_MIN).
-	 */
-	FORCEINLINE OverflowSafeInt& operator += (const OverflowSafeInt& other)
-	{
-		if ((T_MAX - abs(other.m_value)) < abs(this->m_value) &&
-				(this->m_value < 0) == (other.m_value < 0)) {
-			this->m_value = (this->m_value < 0) ? T_MIN : T_MAX ;
-		} else {
-			this->m_value += other.m_value;
-		}
-		return *this;
-	}
-
-	/* Operators for addition and substraction */
-	FORCEINLINE OverflowSafeInt  operator +  (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result += other; return result; }
-	FORCEINLINE OverflowSafeInt  operator +  (const int              other) const { OverflowSafeInt result = *this; result += (int64)other; return result; }
-	FORCEINLINE OverflowSafeInt  operator +  (const uint             other) const { OverflowSafeInt result = *this; result += (int64)other; return result; }
-	FORCEINLINE OverflowSafeInt& operator -= (const OverflowSafeInt& other)       { return *this += (-other); }
-	FORCEINLINE OverflowSafeInt  operator -  (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result -= other; return result; }
-	FORCEINLINE OverflowSafeInt  operator -  (const int              other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; }
-	FORCEINLINE OverflowSafeInt  operator -  (const uint             other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; }
-
-	FORCEINLINE OverflowSafeInt& operator ++ () { return *this += 1; }
-	FORCEINLINE OverflowSafeInt& operator -- () { return *this += -1; }
-	FORCEINLINE OverflowSafeInt operator ++ (int) { OverflowSafeInt org = *this; *this += 1; return org; }
-	FORCEINLINE OverflowSafeInt operator -- (int) { OverflowSafeInt org = *this; *this += -1; return org; }
-
-	/**
-	 * Safe implementation of multiplication.
-	 * @param factor the factor to multiply this with.
-	 * @note when the multiplication would yield more than T_MAX (or less than T_MIN),
-	 *       it will be T_MAX (respectively T_MIN).
-	 */
-	FORCEINLINE OverflowSafeInt& operator *= (const int factor)
-	{
-		if (factor != 0 && (T_MAX / abs(factor)) < abs(this->m_value)) {
-			 this->m_value = ((this->m_value < 0) == (factor < 0)) ? T_MAX : T_MIN ;
-		} else {
-			this->m_value *= factor ;
-		}
-		return *this;
-	}
-
-	/* Operators for multiplication */
-	FORCEINLINE OverflowSafeInt operator * (const int64  factor) const { OverflowSafeInt result = *this; result *= factor; return result; }
-	FORCEINLINE OverflowSafeInt operator * (const int    factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
-	FORCEINLINE OverflowSafeInt operator * (const uint   factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
-	FORCEINLINE OverflowSafeInt operator * (const uint16 factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
-	FORCEINLINE OverflowSafeInt operator * (const byte   factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
-
-	/* Operators for division */
-	FORCEINLINE OverflowSafeInt& operator /= (const int              divisor)       { this->m_value /= divisor; return *this; }
-	FORCEINLINE OverflowSafeInt  operator /  (const OverflowSafeInt& divisor) const { OverflowSafeInt result = *this; result /= divisor.m_value; return result; }
-	FORCEINLINE OverflowSafeInt  operator /  (const int              divisor) const { OverflowSafeInt result = *this; result /= divisor; return result; }
-	FORCEINLINE OverflowSafeInt  operator /  (const uint             divisor) const { OverflowSafeInt result = *this; result /= (int)divisor; return result; }
-
-	/* Operators for modulo */
-	FORCEINLINE OverflowSafeInt& operator %= (const int  divisor)       { this->m_value %= divisor; return *this; }
-	FORCEINLINE OverflowSafeInt  operator %  (const int  divisor) const { OverflowSafeInt result = *this; result %= divisor; return result; }
-
-	/* Operators for shifting */
-	FORCEINLINE OverflowSafeInt& operator <<= (const int shift)       { this->m_value <<= shift; return *this; }
-	FORCEINLINE OverflowSafeInt  operator <<  (const int shift) const { OverflowSafeInt result = *this; result <<= shift; return result; }
-	FORCEINLINE OverflowSafeInt& operator >>= (const int shift)       { this->m_value >>= shift; return *this; }
-	FORCEINLINE OverflowSafeInt  operator >>  (const int shift) const { OverflowSafeInt result = *this; result >>= shift; return result; }
-
-	/* Operators for (in)equality when comparing overflow safe ints */
-	FORCEINLINE bool operator == (const OverflowSafeInt& other) const { return this->m_value == other.m_value; }
-	FORCEINLINE bool operator != (const OverflowSafeInt& other) const { return !(*this == other); }
-	FORCEINLINE bool operator >  (const OverflowSafeInt& other) const { return this->m_value > other.m_value; }
-	FORCEINLINE bool operator >= (const OverflowSafeInt& other) const { return this->m_value >= other.m_value; }
-	FORCEINLINE bool operator <  (const OverflowSafeInt& other) const { return !(*this >= other); }
-	FORCEINLINE bool operator <= (const OverflowSafeInt& other) const { return !(*this > other); }
-
-	/* Operators for (in)equality when comparing non-overflow safe ints */
-	FORCEINLINE bool operator == (const int other) const { return this->m_value == other; }
-	FORCEINLINE bool operator != (const int other) const { return !(*this == other); }
-	FORCEINLINE bool operator >  (const int other) const { return this->m_value > other; }
-	FORCEINLINE bool operator >= (const int other) const { return this->m_value >= other; }
-	FORCEINLINE bool operator <  (const int other) const { return !(*this >= other); }
-	FORCEINLINE bool operator <= (const int other) const { return !(*this > other); }
-
-	FORCEINLINE operator int64 () const { return this->m_value; }
-};
-
-/* Sometimes we got int64 operator OverflowSafeInt instead of vice versa. Handle that properly */
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
-
-/* Sometimes we got int operator OverflowSafeInt instead of vice versa. Handle that properly */
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (int   a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (int   a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (int   a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (int   a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
-
-/* Sometimes we got uint operator OverflowSafeInt instead of vice versa. Handle that properly */
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (uint  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (uint  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (uint  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (uint  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
-
-/* Sometimes we got byte operator OverflowSafeInt instead of vice versa. Handle that properly */
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (byte  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (byte  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (byte  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
-template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (byte  a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
-
-#endif /* HELPERS_HPP */
--- a/src/industry.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/industry.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,11 +6,15 @@
 #define INDUSTRY_H
 
 #include "oldpool.h"
-#include "helpers.hpp"
+#include "core/random_func.hpp"
 #include "newgrf_storage.h"
-
-typedef uint16 IndustryGfx;
-typedef uint8 IndustryType;
+#include "cargo_type.h"
+#include "economy_type.h"
+#include "map_type.h"
+#include "slope_type.h"
+#include "date_type.h"
+#include "town_type.h"
+#include "industry_type.h"
 
 enum {
 	INVALID_INDUSTRY       = 0xFFFF,
@@ -59,13 +63,6 @@
 	ICT_SCENARIO_EDITOR   ///< while scenarion edition
 };
 
-/** From where is callback CBID_INDUSTRY_AVAILABLE been called */
-enum IndustryAvailabilityCallType {
-	IACT_MAPGENERATION,   ///< during random map generation
-	IACT_RANDOMCREATION,  ///< during creation of random ingame industry
-	IACT_USERCREATION,    ///< from the Fund/build window
-};
-
 enum IndustryBehaviour {
 	INDUSTRYBEH_NONE                  =      0,
 	INDUSTRYBEH_PLANT_FIELDS          = 1 << 0,  ///< periodically plants fileds around itself (temp and artic farms)
@@ -92,7 +89,6 @@
 
 DECLARE_ENUM_AS_BIT_SET(IndustryBehaviour);
 
-struct Industry;
 DECLARE_OLD_POOL(Industry, Industry, 3, 8000)
 
 /**
@@ -161,7 +157,8 @@
 struct IndustrySpec {
 	const IndustryTileTable *const *table;///< List of the tiles composing the industry
 	byte num_table;                       ///< Number of elements in the table
-	uint8 cost_multiplier;                ///< Base cost multiplier.
+	uint8 cost_multiplier;                ///< Base construction cost multiplier.
+	uint32 removal_cost_multiplier;       ///< Base removal cost multiplier.
 	uint16 raw_industry_cost_multiplier;  ///< Multiplier for the raw industries cost
 	uint32 prospecting_chance;            ///< Chance prospecting succeeds
 	IndustryType conflicting[3];          ///< Industries this industry cannot be close to
@@ -202,6 +199,14 @@
 	 * @return the cost (inflation corrected etc)
 	 */
 	Money GetConstructionCost() const;
+
+	/**
+	 * Get the cost for removing this industry
+	 * Take note that the cost will always be zero for non-grf industries.
+	 * Only if the grf author did specified a cost will it be applicable.
+	 * @return the cost (inflation corrected etc)
+	 */
+	Money GetRemovalCost() const;
 };
 
 /**
--- a/src/industry_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/industry_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,30 +5,22 @@
 #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"
-#include "strings.h"
 #include "table/sprites.h"
-#include "map.h"
-#include "tile.h"
 #include "train.h"
 #include "landscape.h"
-#include "viewport.h"
-#include "command.h"
+#include "viewport_func.h"
+#include "command_func.h"
 #include "industry.h"
 #include "town.h"
-#include "vehicle.h"
 #include "news.h"
 #include "saveload.h"
-#include "economy.h"
-#include "sound.h"
 #include "variables.h"
 #include "table/industry_land.h"
 #include "table/build_industry.h"
 #include "genworld.h"
-#include "date.h"
 #include "water_map.h"
 #include "tree_map.h"
 #include "cargotype.h"
@@ -40,6 +32,14 @@
 #include "misc/autoptr.hpp"
 #include "autoslope.h"
 #include "transparency.h"
+#include "water.h"
+#include "strings_func.h"
+#include "tile_cmd.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
 
 void ShowIndustryViewWindow(int industry);
 void BuildOilRig(TileIndex tile);
@@ -400,7 +400,7 @@
 	}
 
 	if (flags & DC_EXEC) delete i;
-	return CommandCost();
+	return CommandCost(EXPENSES_CONSTRUCTION, indspec->GetRemovalCost());
 }
 
 static void TransportIndustryGoods(TileIndex tile)
@@ -557,7 +557,7 @@
 	case GFX_OILWELL_ANIMATED_2:
 	case GFX_OILWELL_ANIMATED_3:
 		if ((_tick_counter & 7) == 0) {
-			bool b = CHANCE16(1, 7);
+			bool b = Chance16(1, 7);
 			IndustryGfx gfx = GetIndustryGfx(tile);
 
 			m = GetIndustryAnimationState(tile) + 1;
@@ -737,7 +737,7 @@
 	case GFX_COAL_MINE_TOWER_NOT_ANIMATED:
 	case GFX_COPPER_MINE_TOWER_NOT_ANIMATED:
 	case GFX_GOLD_MINE_TOWER_NOT_ANIMATED:
-		if (!(_tick_counter & 0x400) && CHANCE16(1, 2)) {
+		if (!(_tick_counter & 0x400) && Chance16(1, 2)) {
 			switch (gfx) {
 				case GFX_COAL_MINE_TOWER_NOT_ANIMATED:   gfx = GFX_COAL_MINE_TOWER_ANIMATED;   break;
 				case GFX_COPPER_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_ANIMATED; break;
@@ -750,7 +750,7 @@
 		break;
 
 	case GFX_OILWELL_NOT_ANIMATED:
-		if (CHANCE16(1, 6)) {
+		if (Chance16(1, 6)) {
 			SetIndustryGfx(tile, GFX_OILWELL_ANIMATED_1);
 			SetIndustryAnimationState(tile, 0);
 			AddAnimatedTile(tile);
@@ -774,7 +774,7 @@
 		break;
 
 	case GFX_POWERPLANT_SPARKS:
-		if (CHANCE16(1, 3)) {
+		if (Chance16(1, 3)) {
 			SndPlayTileFx(SND_0C_ELECTRIC_SPARK, tile);
 			AddAnimatedTile(tile);
 		}
@@ -804,7 +804,7 @@
 		break;
 
 	case GFX_SUGAR_MINE_SIEVE:
-		if (CHANCE16(1, 3)) AddAnimatedTile(tile);
+		if (Chance16(1, 3)) AddAnimatedTile(tile);
 		break;
 	}
 }
@@ -862,7 +862,7 @@
 		if (IsTileType(tile, MP_CLEAR) || IsTileType(tile, MP_TREES)) {
 			byte or_ = type;
 
-			if (or_ == 1 && CHANCE16(1, 7)) or_ = 2;
+			if (or_ == 1 && Chance16(1, 7)) or_ = 2;
 
 			if (direction == AXIS_X) {
 				SetFenceSE(tile, or_);
@@ -989,7 +989,7 @@
 
 	/* play a sound? */
 	if ((i->counter & 0x3F) == 0) {
-		if (CHANCE16R(1, 14, r) && (num = indsp->number_of_sounds) != 0) {
+		if (Chance16R(1, 14, r) && (num = indsp->number_of_sounds) != 0) {
 			SndPlayTileFx(
 				(SoundFx)(indsp->random_sounds[((r >> 16) * num) >> 16]),
 				i->xy);
@@ -1011,7 +1011,7 @@
 			if (HasBit(indsp->callback_flags, CBM_IND_SPECIAL_EFFECT)) {
 				plant = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, Random(), 0, i, i->type, i->xy) != 0);
 			} else {
-				plant = CHANCE16(1, 8);
+				plant = Chance16(1, 8);
 			}
 
 			if (plant) PlantRandomFarmField(i);
@@ -1183,14 +1183,14 @@
 {
 	if (IsSteepSlope(current)) return true;
 	if (current != SLOPE_FLAT) {
-		if (refused & SLOPE_STEEP) return true;
+		if (IsSteepSlope(refused)) return true;
 
 		Slope t = ComplementSlope(current);
 
-		if (refused & 1 && (t & SLOPE_NW)) return false;
-		if (refused & 2 && (t & SLOPE_NE)) return false;
-		if (refused & 4 && (t & SLOPE_SW)) return false;
-		if (refused & 8 && (t & SLOPE_SE)) return false;
+		if (refused & SLOPE_W && (t & SLOPE_NW)) return true;
+		if (refused & SLOPE_S && (t & SLOPE_NE)) return true;
+		if (refused & SLOPE_E && (t & SLOPE_SW)) return true;
+		if (refused & SLOPE_N && (t & SLOPE_SE)) return true;
 	}
 
 	return false;
@@ -1237,7 +1237,7 @@
 
 			if (ind_behav & (INDUSTRYBEH_ONLY_INTOWN | INDUSTRYBEH_TOWN1200_MORE)) {
 				if (!IsTileType(cur_tile, MP_HOUSE)) {
-					_error_message = STR_029D_CAN_ONLY_BE_BUILT_IN_TOWNS;
+					_error_message = STR_030D_CAN_ONLY_BE_BUILT_IN_TOWNS;
 					return false;
 				}
 				if (CmdFailed(DoCommand(cur_tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR))) return false;
@@ -1252,7 +1252,7 @@
 	/* It is almost impossible to have a fully flat land in TG, so what we
 	 *  do is that we check if we can make the land flat later on. See
 	 *  CheckIfCanLevelIndustryPlatform(). */
-	return !refused_slope || (_patches.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape);
+	return !refused_slope || (_patches.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions);
 }
 
 static bool CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t)
@@ -1289,7 +1289,7 @@
 			return false;
 
 		/* Don't allow too big of a change if this is the sub-tile check */
-		if (internal != 0 && delta(curh, height) > 1) return false;
+		if (internal != 0 && Delta(curh, height) > 1) return false;
 
 		/* Different height, so the surrounding tiles of this tile
 		 *  has to be correct too (in level, or almost in level)
@@ -1512,7 +1512,7 @@
 
 			DoCommand(cur_tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
-			MakeIndustry(cur_tile, i->index, it->gfx);
+			MakeIndustry(cur_tile, i->index, it->gfx, Random());
 
 			if (_generating_world) {
 				SetIndustryConstructionCounter(cur_tile, 3);
@@ -1557,7 +1557,7 @@
 		if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL;
 	}
 
-	if (!custom_shape_check && _patches.land_generator == LG_TERRAGENESIS && _generating_world && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL;
+	if (!custom_shape_check && _patches.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL;
 	if (!CheckIfTooCloseToIndustry(tile, type)) return NULL;
 
 	const Town *t = CheckMultipleIndustryInTown(tile, type);
@@ -1590,8 +1590,6 @@
 {
 	const IndustrySpec *indspec;
 
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-
 	indspec = GetIndustrySpec(p1);
 
 	/* Check if the to-be built/founded industry is available for this climate. */
@@ -1612,7 +1610,11 @@
 			 * is nothing we can really do about that. */
 			if (Random() <= indspec->prospecting_chance) {
 				for (int i = 0; i < 5000; i++) {
-					const Industry *ind = CreateNewIndustryHelper(RandomTile(), p1, flags, indspec, RandomRange(indspec->num_table));
+					/* We should not have more than one Random() in a function call
+					 * because parameter evaluation order is not guaranteed in the c++ standard
+					 */
+					tile = RandomTile();
+					const Industry *ind = CreateNewIndustryHelper(tile, p1, flags, indspec, RandomRange(indspec->num_table));
 					if (ind != NULL) {
 						SetDParam(0, indspec->name);
 						if (indspec->new_industry_text > STR_LAST_STRINGID) {
@@ -1642,7 +1644,7 @@
 		if (CreateNewIndustryHelper(tile, p1, flags, indspec, num) == NULL) return CMD_ERROR;
 	}
 
-	return CommandCost(indspec->GetConstructionCost());
+	return CommandCost(EXPENSES_OTHER, indspec->GetConstructionCost());
 }
 
 
@@ -1990,6 +1992,7 @@
 
 enum {
 	PERCENT_TRANSPORTED_60 = 153,
+	PERCENT_TRANSPORTED_80 = 204,
 };
 
 /** Change industry production or do closure
@@ -2010,6 +2013,7 @@
 	                      !(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE));            // production change callbacks
 	byte div = 0;
 	byte mul = 0;
+	int8 increment = 0;
 
 	if (HasBit(indspec->callback_flags, monthly ? CBM_IND_MONTHLYPROD_CHANGE : CBM_IND_PRODUCTION_CHANGE)) {
 		uint16 res = GetIndustryCallback(monthly ? CBID_INDUSTRY_MONTHLYPROD_CHANGE : CBID_INDUSTRY_PRODUCTION_CHANGE, 0, Random(), i, i->type, i->xy);
@@ -2031,6 +2035,10 @@
 				case 0x8: div = res - 0x3; break; // Divide production by 32
 				case 0x9: case 0xA: case 0xB:     // Multiply production by 4, 8, 16
 				case 0xC: mul = res - 0x7; break; // Multiply production by 32
+				case 0xD:                         // decrement production
+				case 0xE:                         // increment production
+					increment = res == 0x0D ? -1 : 1;
+					break;
 			}
 		}
 	}
@@ -2046,14 +2054,26 @@
 		if (smooth_economy) {
 			closeit = true;
 			for (byte j = 0; j < 2 && i->produced_cargo[j] != CT_INVALID; j++){
+				uint32 r = Random();
 				int old_prod, new_prod, percent;
+				/* If over 60% is transported, mult is 1, else mult is -1. */
 				int mult = (i->last_month_pct_transported[j] > PERCENT_TRANSPORTED_60) ? 1 : -1;
 
 				new_prod = old_prod = i->production_rate[j];
 
-				if (only_decrease || CHANCE16(1, 3)) mult *= -1;
+				/* For industries with only_decrease flags (temperate terrain Oil Wells),
+				 * the multiplier will always be -1 so they will only decrease. */
+				if (only_decrease) {
+					mult = -1;
+				/* For normal industries, if over 60% is transported, 33% chance for decrease.
+				 * Bonus for very high station ratings (over 80%): 16% chance for decrease. */
+				} else if (Chance16I(1, ((i->last_month_pct_transported[j] > PERCENT_TRANSPORTED_80) ? 6 : 3), r)) {
+					mult *= -1;
+				}
 
-				if (CHANCE16(1, 22)) {
+				/* 4.5% chance for 3-23% (or 1 unit for very low productions) production change,
+				 * determined by mult value. If mult = 1 prod. increases, else (-1) it decreases. */
+				if (Chance16I(1, 22, r >> 16)) {
 					new_prod += mult * (max(((RandomRange(50) + 10) * old_prod) >> 8, 1U));
 				}
 
@@ -2080,9 +2100,9 @@
 				}
 			}
 		} else {
-			if (only_decrease || CHANCE16(1, 3)) {
-				/* If you transport > 60%, 66% chance we increase, else 33% chance we increase */
-				if (!only_decrease && (i->last_month_pct_transported[0] > PERCENT_TRANSPORTED_60) != CHANCE16(1, 3)) {
+			if (only_decrease || Chance16(1, 3)) {
+				/* If more than 60% transported, 66% chance of increase, else 33% chance of increase */
+				if (!only_decrease && (i->last_month_pct_transported[0] > PERCENT_TRANSPORTED_60) != Chance16(1, 3)) {
 					mul = 1; // Increase production
 				} else {
 					div = 1; // Decrease production
@@ -2092,7 +2112,7 @@
 	}
 
 	if (standard && indspec->life_type & INDUSTRYLIFE_PROCESSING) {
-		if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1, smooth_economy ? 180 : 2)) {
+		if ( (byte)(_cur_year - i->last_prod_year) >= 5 && Chance16(1, smooth_economy ? 180 : 2)) {
 			closeit = true;
 		}
 	}
@@ -2117,6 +2137,11 @@
 		}
 	}
 
+	if (increment != 0) {
+		i->prod_level = ClampU(i->prod_level + increment, 4, 0x80);
+		if (i->prod_level == 4) closeit = true;
+	}
+
 	/* Close if needed and allowed */
 	if (closeit && !CheckIndustryCloseDownProtection(i->type)) {
 		i->prod_level = 0;
@@ -2171,7 +2196,7 @@
 	}
 
 	/* 3% chance that we start a new industry */
-	if (CHANCE16(3, 100)) {
+	if (Chance16(3, 100)) {
 		MaybeNewIndustry();
 	} else {
 		i = GetRandomIndustry();
@@ -2212,6 +2237,11 @@
 			)) >> 8;
 }
 
+Money IndustrySpec::GetRemovalCost() const
+{
+	return (_price.remove_house * this->removal_cost_multiplier) >> 8;
+}
+
 static CommandCost TerraformTile_Industry(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
 {
 	if (AutoslopeEnabled()) {
@@ -2231,10 +2261,10 @@
 			if (HasBit(itspec->callback_flags, CBM_INDT_AUTOSLOPE)) {
 				/* If the callback fails, allow autoslope. */
 				uint16 res = GetIndustryTileCallback(CBID_INDUSTRY_AUTOSLOPE, 0, 0, gfx, GetIndustryByTile(tile), tile);
-				if ((res == 0) || (res == CALLBACK_FAILED)) return _price.terraform;
+				if ((res == 0) || (res == CALLBACK_FAILED)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 			} else {
 				/* allow autoslope */
-				return _price.terraform;
+				return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 			}
 		}
 	}
--- a/src/industry_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/industry_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,58 +5,36 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "strings.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "map.h"
 #include "gui.h"
-#include "window.h"
-#include "gfx.h"
-#include "command.h"
-#include "viewport.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
+#include "command_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "industry.h"
 #include "town.h"
 #include "variables.h"
-#include "helpers.hpp"
 #include "cargotype.h"
 #include "newgrf.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_industries.h"
 #include "newgrf_text.h"
-#include "date.h"
-
-extern Industry *CreateNewIndustry(TileIndex tile, IndustryType type);
+#include "strings_func.h"
+#include "map_func.h"
 
-/**
- * Search callback function for TryBuildIndustry
- * @param tile to test
- * @param data that is passed by the caller.  In this case, the type of industry been tested
- * @return the success (or not) of the operation
- */
-static bool SearchTileForIndustry(TileIndex tile, uint32 data)
-{
-	return CreateNewIndustry(tile, data) != NULL;
-}
-
-/**
- * Perform a 9*9 tiles circular search around a tile
- * in order to find a suitable zone to create the desired industry
- * @param tile to start search for
- * @param type of the desired industry
- * @return the success (or not) of the operation
- */
-static bool TryBuildIndustry(TileIndex tile, int type)
-{
-	return CircularTileSearch(tile, 9, SearchTileForIndustry, type);
-}
 bool _ignore_restrictions;
 
-enum {
-	DYNA_INDU_MATRIX_WIDGET = 2,
-	DYNA_INDU_INFOPANEL = 4,
-	DYNA_INDU_FUND_WIDGET,
-	DYNA_INDU_RESIZE_WIDGET,
+/** Names of the widgets of the dynamic place industries gui */
+enum DynamicPlaceIndustriesWidgets {
+	DPIW_CLOSEBOX = 0,
+	DPIW_CAPTION,
+	DPIW_MATRIX_WIDGET,
+	DPIW_SCROLLBAR,
+	DPIW_INFOPANEL,
+	DPIW_FUND_WIDGET,
+	DPIW_RESIZE_WIDGET,
 };
 
 /** Attached struct to the window extended data */
@@ -87,11 +65,11 @@
 			 * info coming from the callback.  SO it will only be available to tis full
 			 * height when newindistries are loaded */
 			if (!_loaded_newgrf_features.has_newindustries) {
-				w->widget[DYNA_INDU_INFOPANEL].bottom -= 44;
-				w->widget[DYNA_INDU_FUND_WIDGET].bottom -= 44;
-				w->widget[DYNA_INDU_FUND_WIDGET].top -= 44;
-				w->widget[DYNA_INDU_RESIZE_WIDGET].bottom -= 44;
-				w->widget[DYNA_INDU_RESIZE_WIDGET].top -= 44;
+				w->widget[DPIW_INFOPANEL].bottom -= 44;
+				w->widget[DPIW_FUND_WIDGET].bottom -= 44;
+				w->widget[DPIW_FUND_WIDGET].top -= 44;
+				w->widget[DPIW_RESIZE_WIDGET].bottom -= 44;
+				w->widget[DPIW_RESIZE_WIDGET].top -= 44;
 				w->resize.height = w->height -= 44;
 			}
 
@@ -138,9 +116,9 @@
 
 		case WE_PAINT: {
 			const IndustrySpec *indsp = (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(WP(w, fnd_d).select);
-			int x_str = w->widget[DYNA_INDU_INFOPANEL].left + 3;
-			int y_str = w->widget[DYNA_INDU_INFOPANEL].top + 3;
-			const Widget *wi = &w->widget[DYNA_INDU_INFOPANEL];
+			int x_str = w->widget[DPIW_INFOPANEL].left + 3;
+			int y_str = w->widget[DPIW_INFOPANEL].top + 3;
+			const Widget *wi = &w->widget[DPIW_INFOPANEL];
 			int max_width = wi->right - wi->left - 4;
 
 			/* Raw industries might be prospected. Show this fact by changing the string
@@ -148,11 +126,11 @@
 			if (_game_mode == GM_EDITOR) {
 				/* We've chosen many random industries but no industries have been specified */
 				if (indsp == NULL) _fund_gui.enabled[WP(w, fnd_d).index] = _opt.diff.number_industries != 0;
-				w->widget[DYNA_INDU_FUND_WIDGET].data = STR_BUILD_NEW_INDUSTRY;
+				w->widget[DPIW_FUND_WIDGET].data = STR_BUILD_NEW_INDUSTRY;
 			} else {
-				w->widget[DYNA_INDU_FUND_WIDGET].data = (_patches.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;
+				w->widget[DPIW_FUND_WIDGET].data = (_patches.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;
 			}
-			SetWindowWidgetDisabledState(w, DYNA_INDU_FUND_WIDGET, !_fund_gui.enabled[WP(w, fnd_d).index]);
+			w->SetWidgetDisabledState(DPIW_FUND_WIDGET, !_fund_gui.enabled[WP(w, fnd_d).index]);
 
 			SetVScrollCount(w, _fund_gui.count);
 
@@ -232,11 +210,16 @@
 			}
 		} break;
 
+		case WE_DOUBLE_CLICK:
+			if (e->we.click.widget != DPIW_MATRIX_WIDGET) break;
+			e->we.click.widget = DPIW_FUND_WIDGET;
+			/* Fall through */
+
 		case WE_CLICK:
 			switch (e->we.click.widget) {
-				case DYNA_INDU_MATRIX_WIDGET: {
+				case DPIW_MATRIX_WIDGET: {
 					const IndustrySpec *indsp;
-					int y = (e->we.click.pt.y - w->widget[DYNA_INDU_MATRIX_WIDGET].top) / 13 + w->vscroll.pos ;
+					int y = (e->we.click.pt.y - w->widget[DPIW_MATRIX_WIDGET].top) / 13 + w->vscroll.pos ;
 
 					if (y >= 0 && y < _fund_gui.count) { // Is it within the boundaries of available data?
 						WP(w, fnd_d).index = y;
@@ -248,15 +231,15 @@
 						if ((_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
 								WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
 							/* Reset the button state if going to prospecting or "build many industries" */
-							RaiseWindowButtons(w);
+							w->RaiseButtons();
 							ResetObjectToPlace();
 						}
 					}
 				} break;
 
-				case DYNA_INDU_FUND_WIDGET: {
+				case DPIW_FUND_WIDGET: {
 					if (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
-						HandleButtonClick(w, DYNA_INDU_FUND_WIDGET);
+						w->HandleButtonClick(DPIW_FUND_WIDGET);
 
 						if (GetNumTowns() == 0) {
 							ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST, STR_CAN_T_GENERATE_INDUSTRIES, 0, 0);
@@ -268,9 +251,9 @@
 						}
 					} else if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && GetIndustrySpec(WP(w, fnd_d).select)->IsRawIndustry()) {
 						DoCommandP(0, WP(w, fnd_d).select, 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
-						HandleButtonClick(w, DYNA_INDU_FUND_WIDGET);
+						w->HandleButtonClick(DPIW_FUND_WIDGET);
 					} else {
-						HandlePlacePushButton(w, DYNA_INDU_FUND_WIDGET, SPR_CURSOR_INDUSTRY, VHM_RECT, NULL);
+						HandlePlacePushButton(w, DPIW_FUND_WIDGET, SPR_CURSOR_INDUSTRY, VHM_RECT, NULL);
 					}
 				} break;
 			}
@@ -279,7 +262,7 @@
 		case WE_RESIZE: {
 			/* Adjust the number of items in the matrix depending of the rezise */
 			w->vscroll.cap  += e->we.sizing.diff.y / (int)w->resize.step_height;
-			w->widget[DYNA_INDU_MATRIX_WIDGET].data = (w->vscroll.cap << 8) + 1;
+			w->widget[DPIW_MATRIX_WIDGET].data = (w->vscroll.cap << 8) + 1;
 		} break;
 
 		case WE_PLACE_OBJ: {
@@ -298,7 +281,7 @@
 				_current_player = OWNER_NONE;
 				_generating_world = true;
 				_ignore_restrictions = true;
-				success = TryBuildIndustry(e->we.place.tile, WP(w, fnd_d).select);
+				success = DoCommandP(e->we.place.tile, WP(w, fnd_d).select, InteractiveRandomRange(indsp->num_table), NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
 				if (!success) {
 					SetDParam(0, indsp->name);
 					ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y);
@@ -315,6 +298,7 @@
 		} break;
 
 		case WE_TICK:
+			if (_pause_game != 0) break;
 			if (!WP(w, fnd_d).timer_enabled) break;
 			if (--WP(w, fnd_d).callback_timer == 0) {
 				/* We have just passed another day.
@@ -337,22 +321,24 @@
 
 		case WE_TIMEOUT:
 		case WE_ABORT_PLACE_OBJ:
-			RaiseWindowButtons(w);
+			w->RaiseButtons();
 			break;
 	}
 }
 
+/** Widget definition of the dynamic place industries gui */
 static const Widget _build_dynamic_industry_widgets[] = {
-{   WWT_CLOSEBOX,    RESIZE_NONE,    7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,   RESIZE_RIGHT,    7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
-{     WWT_MATRIX,      RESIZE_RB,    7,     0,   157,    14,   118, 0x801,                          STR_INDUSTRY_SELECTION_HINT},
-{  WWT_SCROLLBAR,     RESIZE_LRB,    7,   158,   169,    14,   118, 0x0,                            STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{      WWT_PANEL,     RESIZE_RTB,    7,     0,   169,   119,   199, 0x0,                            STR_NULL},
-{    WWT_TEXTBTN,     RESIZE_RTB,    7,     0,   157,   200,   211, STR_FUND_NEW_INDUSTRY,          STR_NULL},
-{  WWT_RESIZEBOX,    RESIZE_LRTB,    7,   158,   169,   200,   211, 0x0,                            STR_RESIZE_BUTTON},
+{   WWT_CLOSEBOX,    RESIZE_NONE,    7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},            // DPIW_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_RIGHT,    7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},  // DPIW_CAPTION
+{     WWT_MATRIX,      RESIZE_RB,    7,     0,   157,    14,   118, 0x801,                          STR_INDUSTRY_SELECTION_HINT},      // DPIW_MATRIX_WIDGET
+{  WWT_SCROLLBAR,     RESIZE_LRB,    7,   158,   169,    14,   118, 0x0,                            STR_0190_SCROLL_BAR_SCROLLS_LIST}, // DPIW_SCROLLBAR
+{      WWT_PANEL,     RESIZE_RTB,    7,     0,   169,   119,   199, 0x0,                            STR_NULL},                         // DPIW_INFOPANEL
+{    WWT_TEXTBTN,     RESIZE_RTB,    7,     0,   157,   200,   211, STR_FUND_NEW_INDUSTRY,          STR_NULL},                         // DPIW_FUND_WIDGET
+{  WWT_RESIZEBOX,    RESIZE_LRTB,    7,   158,   169,   200,   211, 0x0,                            STR_RESIZE_BUTTON},                // DPIW_RESIZE_WIDGET
 {   WIDGETS_END},
 };
 
+/** Window definition of the dynamic place industries gui */
 static const WindowDesc _build_industry_dynamic_desc = {
 	WDP_AUTO, WDP_AUTO, 170, 212, 170, 212,
 	WC_BUILD_INDUSTRY, WC_NONE,
@@ -385,6 +371,18 @@
 			(i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES));
 }
 
+/** Names of the widgets of the view industry gui */
+enum IndustryViewWidgets {
+	IVW_CLOSEBOX = 0,
+	IVW_CAPTION,
+	IVW_STICKY,
+	IVW_BACKGROUND,
+	IVW_VIEWPORT,
+	IVW_INFO,
+	IVW_GOTO,
+	IVW_SPACER,
+};
+
 /** Information to store about the industry window */
 struct indview_d : public vp_d {
 	byte editbox_line;        ///< The line clicked to open the edit box
@@ -530,7 +528,7 @@
 		Industry *i;
 
 		switch (e->we.click.widget) {
-		case 5: {
+		case IVW_INFO: {
 			int line, x;
 
 			i = GetIndustry(w->window_number);
@@ -539,8 +537,8 @@
 			if (!IsProductionAlterable(i)) return;
 			x = e->we.click.pt.x;
 			line = (e->we.click.pt.y - WP(w, indview_d).production_offset_y) / 10;
-			if (e->we.click.pt.y >= WP(w, indview_d).production_offset_y && IS_INT_INSIDE(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) {
-				if (IS_INT_INSIDE(x, 5, 25) ) {
+			if (e->we.click.pt.y >= WP(w, indview_d).production_offset_y && IsInsideMM(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) {
+				if (IsInsideMM(x, 5, 25) ) {
 					/* Clicked buttons, decrease or increase production */
 					if (x < 15) {
 						if (isProductionMinimum(i, line)) return;
@@ -557,7 +555,7 @@
 					w->flags4 |= 5 << WF_TIMEOUT_SHL;
 					WP(w, indview_d).clicked_line = line + 1;
 					WP(w, indview_d).clicked_button = (x < 15 ? 1 : 2);
-				} else if (IS_INT_INSIDE(x, 34, 160)) {
+				} else if (IsInsideMM(x, 34, 160)) {
 					/* clicked the text */
 					WP(w, indview_d).editbox_line = line;
 					SetDParam(0, i->production_rate[line] * 8);
@@ -565,7 +563,7 @@
 				}
 			}
 		} break;
-		case 6:
+		case IVW_GOTO:
 			i = GetIndustry(w->window_number);
 			ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1));
 		} break;
@@ -599,18 +597,20 @@
 	}
 }
 
+/** Widget definition of the view industy gui */
 static const Widget _industry_view_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,     9,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,   RESIZE_NONE,     9,    11,   247,     0,    13, STR_4801,          STR_018C_WINDOW_TITLE_DRAG_THIS},
-{  WWT_STICKYBOX,   RESIZE_NONE,     9,   248,   259,     0,    13, 0x0,               STR_STICKY_BUTTON},
-{      WWT_PANEL,   RESIZE_NONE,     9,     0,   259,    14,   105, 0x0,               STR_NULL},
-{      WWT_INSET,   RESIZE_NONE,     9,     2,   257,    16,   103, 0x0,               STR_NULL},
-{      WWT_PANEL,   RESIZE_NONE,     9,     0,   259,   106,   147, 0x0,               STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,     9,     0,   129,   148,   159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON},
-{      WWT_PANEL,   RESIZE_NONE,     9,   130,   259,   148,   159, 0x0,               STR_NULL},
+{   WWT_CLOSEBOX,   RESIZE_NONE,     9,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},            // IVW_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_NONE,     9,    11,   247,     0,    13, STR_4801,          STR_018C_WINDOW_TITLE_DRAG_THIS},  // IVW_CAPTION
+{  WWT_STICKYBOX,   RESIZE_NONE,     9,   248,   259,     0,    13, 0x0,               STR_STICKY_BUTTON},                // IVW_STICKY
+{      WWT_PANEL,   RESIZE_NONE,     9,     0,   259,    14,   105, 0x0,               STR_NULL},                         // IVW_BACKGROUND
+{      WWT_INSET,   RESIZE_NONE,     9,     2,   257,    16,   103, 0x0,               STR_NULL},                         // IVW_VIEWPORT
+{      WWT_PANEL,   RESIZE_NONE,     9,     0,   259,   106,   147, 0x0,               STR_NULL},                         // IVW_INFO
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,     9,     0,   129,   148,   159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON}, // IVW_GOTO
+{      WWT_PANEL,   RESIZE_NONE,     9,   130,   259,   148,   159, 0x0,               STR_NULL},                         // IVW_SPACER
 {   WIDGETS_END},
 };
 
+/** Window definition of the view industy gui */
 static const WindowDesc _industry_view_desc = {
 	WDP_AUTO, WDP_AUTO, 260, 160, 260, 160,
 	WC_INDUSTRY_VIEW, WC_NONE,
@@ -632,26 +632,34 @@
 	}
 }
 
-enum {
-	DIRECTORY_INDU_SORTBYNAME = 3,
-	DIRECTORY_INDU_SORTBYTYPE,
-	DIRECTORY_INDU_SORTBYPROD,
-	DIRECTORY_INDU_SORTBYTRANSPORT,
-	DIRECTORY_INDU_SHOWINDU = 8,
+/** Names of the widgets of the industry directory gui */
+enum IndustryDirectoryWidgets {
+	IDW_CLOSEBOX = 0,
+	IDW_CAPTION,
+	IDW_STICKY,
+	IDW_SORTBYNAME,
+	IDW_SORTBYTYPE,
+	IDW_SORTBYPROD,
+	IDW_SORTBYTRANSPORT,
+	IDW_SPACER,
+	IDW_INDUSRTY_LIST,
+	IDW_SCROLLBAR,
+	IDW_RESIZE,
 };
 
+/** Widget definition of the industy directory gui */
 static const Widget _industry_directory_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,   RESIZE_NONE,    13,    11,   495,     0,    13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{  WWT_STICKYBOX,   RESIZE_NONE,    13,   496,   507,     0,    13, 0x0,                     STR_STICKY_BUTTON},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,     0,   100,    14,    25, STR_SORT_BY_NAME,        STR_SORT_ORDER_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   101,   200,    14,    25, STR_SORT_BY_TYPE,        STR_SORT_ORDER_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   201,   300,    14,    25, STR_SORT_BY_PRODUCTION,  STR_SORT_ORDER_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   301,   400,    14,    25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP},
-{      WWT_PANEL,   RESIZE_NONE,    13,   401,   495,    14,    25, 0x0,                     STR_NULL},
-{      WWT_PANEL, RESIZE_BOTTOM,    13,     0,   495,    26,   189, 0x0,                     STR_200A_TOWN_NAMES_CLICK_ON_NAME},
-{  WWT_SCROLLBAR, RESIZE_BOTTOM,    13,   496,   507,    14,   177, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{  WWT_RESIZEBOX,     RESIZE_TB,    13,   496,   507,   178,   189, 0x0,                     STR_RESIZE_BUTTON},
+{   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},             // IDW_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_NONE,    13,    11,   495,     0,    13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},   // IDW_CAPTION
+{  WWT_STICKYBOX,   RESIZE_NONE,    13,   496,   507,     0,    13, 0x0,                     STR_STICKY_BUTTON},                 // IDW_STICKY
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,     0,   100,    14,    25, STR_SORT_BY_NAME,        STR_SORT_ORDER_TIP},                // IDW_SORTBYNAME
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   101,   200,    14,    25, STR_SORT_BY_TYPE,        STR_SORT_ORDER_TIP},                // IDW_SORTBYTYPE
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   201,   300,    14,    25, STR_SORT_BY_PRODUCTION,  STR_SORT_ORDER_TIP},                // IDW_SORTBYPROD
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   301,   400,    14,    25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP},                // IDW_SORTBYTRANSPORT
+{      WWT_PANEL,   RESIZE_NONE,    13,   401,   495,    14,    25, 0x0,                     STR_NULL},                          // IDW_SPACER
+{      WWT_PANEL, RESIZE_BOTTOM,    13,     0,   495,    26,   189, 0x0,                     STR_200A_TOWN_NAMES_CLICK_ON_NAME}, // IDW_INDUSRTY_LIST
+{  WWT_SCROLLBAR, RESIZE_BOTTOM,    13,   496,   507,    14,   177, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},  // IDW_SCROLLBAR
+{  WWT_RESIZEBOX,     RESIZE_TB,    13,   496,   507,   178,   189, 0x0,                     STR_RESIZE_BUTTON},                 // IDW_RESIZE
 {   WIDGETS_END},
 };
 
@@ -752,7 +760,6 @@
 
 	/* Create array for sorting */
 	_industry_sort = ReallocT(_industry_sort, GetMaxIndustryIndex() + 1);
-	if (_industry_sort == NULL) error("Could not allocate memory for the industry-sorting-list");
 
 	/* Don't attempt a sort if there are no industries */
 	if (GetNumIndustries() != 0) {
@@ -816,35 +823,35 @@
 
 	case WE_CLICK:
 		switch (e->we.click.widget) {
-			case DIRECTORY_INDU_SORTBYNAME: {
+			case IDW_SORTBYNAME: {
 				_industry_sort_order = _industry_sort_order == 0 ? 1 : 0;
 				_industry_sort_dirty = true;
 				SetWindowDirty(w);
 			} break;
 
-			case DIRECTORY_INDU_SORTBYTYPE: {
+			case IDW_SORTBYTYPE: {
 				_industry_sort_order = _industry_sort_order == 2 ? 3 : 2;
 				_industry_sort_dirty = true;
 				SetWindowDirty(w);
 			} break;
 
-			case DIRECTORY_INDU_SORTBYPROD: {
+			case IDW_SORTBYPROD: {
 				_industry_sort_order = _industry_sort_order == 4 ? 5 : 4;
 				_industry_sort_dirty = true;
 				SetWindowDirty(w);
 			} break;
 
-			case DIRECTORY_INDU_SORTBYTRANSPORT: {
+			case IDW_SORTBYTRANSPORT: {
 				_industry_sort_order = _industry_sort_order == 6 ? 7 : 6;
 				_industry_sort_dirty = true;
 				SetWindowDirty(w);
 			} break;
 
-			case DIRECTORY_INDU_SHOWINDU: {
+			case IDW_INDUSRTY_LIST: {
 				int y = (e->we.click.pt.y - 28) / 10;
 				uint16 p;
 
-				if (!IS_INT_INSIDE(y, 0, w->vscroll.cap)) return;
+				if (!IsInsideMM(y, 0, w->vscroll.cap)) return;
 				p = y + w->vscroll.pos;
 				if (p < _num_industry_sort) {
 					ScrollMainWindowToTile(_industry_sort[p]->xy);
@@ -863,8 +870,7 @@
 	}
 }
 
-
-/* Industry List */
+/** Window definition of the industy directory gui */
 static const WindowDesc _industry_directory_desc = {
 	WDP_AUTO, WDP_AUTO, 508, 190, 508, 190,
 	WC_INDUSTRY_DIRECTORY, WC_NONE,
@@ -873,7 +879,6 @@
 	IndustryDirectoryWndProc
 };
 
-
 void ShowIndustryDirectory()
 {
 	Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0);
--- a/src/industry_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/industry_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,8 +6,7 @@
 #define INDUSTRY_MAP_H
 
 #include "industry.h"
-#include "macros.h"
-#include "tile.h"
+#include "tile_map.h"
 
 
 
@@ -157,11 +156,12 @@
 
 /**
  * Make the given tile an industry tile
- * @param t     the tile to make an industry tile
- * @param index the industry this tile belongs to
- * @param gfx   the graphics to use for the tile
+ * @param t      the tile to make an industry tile
+ * @param index  the industry this tile belongs to
+ * @param gfx    the graphics to use for the tile
+ * @param random the random value
  */
-static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx)
+static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random)
 {
 	SetTileType(t, MP_INDUSTRY);
 	_m[t].m1 = 0;
@@ -169,7 +169,7 @@
 	_m[t].m3 = 0;
 	_m[t].m4 = 0;
 	SetIndustryGfx(t, gfx);
-	_me[t].m7 = Random();
+	_me[t].m7 = random;
 }
 
 /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/industry_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,16 @@
+/* $Id$ */
+
+/** @file industry_type.h Types related to the industry. */
+
+#ifndef INDUSTRY_TYPE_H
+#define INDUSTRY_TYPE_H
+
+typedef uint16 IndustryID;
+typedef uint16 IndustryGfx;
+typedef uint8 IndustryType;
+struct Industry;
+
+struct IndustrySpec;
+struct IndustryTileSpec;
+
+#endif /* INDUSTRY_TYPE_H */
--- a/src/intro_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/intro_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,20 +5,21 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "strings.h"
 #include "table/sprites.h"
-#include "functions.h"
-#include "window.h"
 #include "gui.h"
-#include "gfx.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
 #include "player.h"
 #include "network/network.h"
 #include "variables.h"
-#include "settings.h"
 #include "heightmap.h"
 #include "genworld.h"
 #include "network/network_gui.h"
 #include "newgrf.h"
+#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},
@@ -53,13 +54,13 @@
 static void SelectGameWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-	case WE_CREATE: LowerWindowWidget(w, _opt_newgame.landscape + 8); break;
+	case WE_CREATE: w->LowerWidget(_opt_newgame.landscape + 8); break;
 
 	case WE_PAINT:
-		SetWindowWidgetLoweredState(w, 8,  _opt_newgame.landscape == LT_TEMPERATE);
-		SetWindowWidgetLoweredState(w, 9,  _opt_newgame.landscape == LT_ARCTIC);
-		SetWindowWidgetLoweredState(w, 10, _opt_newgame.landscape == LT_TROPIC);
-		SetWindowWidgetLoweredState(w, 11, _opt_newgame.landscape == LT_TOYLAND);
+		w->SetWidgetLoweredState(8,  _opt_newgame.landscape == LT_TEMPERATE);
+		w->SetWidgetLoweredState(9,  _opt_newgame.landscape == LT_ARCTIC);
+		w->SetWidgetLoweredState(10, _opt_newgame.landscape == LT_TROPIC);
+		w->SetWidgetLoweredState(11, _opt_newgame.landscape == LT_TOYLAND);
 		SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
 		DrawWindowWidgets(w);
 		break;
@@ -85,7 +86,7 @@
 			}
 			break;
 		case 8: case 9: case 10: case 11:
-			RaiseWindowWidget(w, _opt_newgame.landscape + 8);
+			w->RaiseWidget(_opt_newgame.landscape + 8);
 			SetNewLandscapeType(e->we.click.widget - 8);
 			break;
 		case 12: ShowGameOptions(); break;
--- a/src/landscape.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/landscape.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,23 +5,25 @@
 #include "bridge_map.h"
 #include "heightmap.h"
 #include "clear_map.h"
-#include "date.h"
-#include "functions.h"
-#include "map.h"
 #include "player.h"
 #include "spritecache.h"
 #include "table/sprites.h"
-#include "tile.h"
 #include <stdarg.h>
-#include "viewport.h"
-#include "command.h"
+#include "viewport_func.h"
+#include "command_func.h"
 #include "landscape.h"
-#include "vehicle.h"
 #include "variables.h"
 #include "void_map.h"
 #include "water_map.h"
 #include "tgp.h"
 #include "genworld.h"
+#include "tile_cmd.h"
+#include "core/alloc_func.hpp"
+#include "fios.h"
+#include "window_func.h"
+#include "functions.h"
+#include "date_func.h"
+#include "vehicle_func.h"
 
 extern const TileTypeProcs
 	_tile_type_clear_procs,
@@ -522,8 +524,6 @@
  */
 CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
 }
 
@@ -535,7 +535,8 @@
  */
 CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	CommandCost cost, ret, money;
+	CommandCost ret, money;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	int ex;
 	int ey;
 	int sx, sy;
@@ -544,8 +545,6 @@
 
 	if (p1 >= MapSize()) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* make sure sx,sy are smaller than ex,ey */
 	ex = TileX(tile);
 	ey = TileY(tile);
--- a/src/landscape.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/landscape.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,11 @@
 #ifndef LANDSCAPE_H
 #define LANDSCAPE_H
 
+#include "core/geometry_type.hpp"
+#include "tile_cmd.h"
+#include "slope_type.h"
+#include "direction_type.h"
+
 enum {
 	SNOW_LINE_MONTHS = 12,
 	SNOW_LINE_DAYS   = 32,
@@ -47,13 +52,6 @@
 void DoClearSquare(TileIndex tile);
 void RunTileLoop();
 
-uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode);
-void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
-void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player);
-void AnimateTile(TileIndex tile);
-void ClickTile(TileIndex tile);
-void GetTileDesc(TileIndex tile, TileDesc *td);
-
 void InitializeLandscape();
 void GenerateLandscape(byte mode);
 
--- a/src/lang/afrikaans.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/afrikaans.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Kan nie die area reinig nie....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Oorspronklik kopiereg {COPYRIGHT} 1995 Chris Sawyer, Alle regte voorbehou
 STR_00B7_VERSION                                                :{BLACK}OpenTTD uitgawe {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 Die OpenTTD span
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 Die OpenTTD span
 STR_TRANSLATED_BY                                               :{BLACK}  Vertaler(s) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -2304,7 +2304,7 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Beweeg HQ
 STR_COMPANY_PASSWORD                                            :{BLACK}Wagwoord
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Wagwoord-beskerm jou maatskappy om onmagtig gebruikers te belet van verbinding
-STR_SET_COMPANY_PASSWORD                                        :Stel maatskappy wagwoord
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Stel maatskappy wagwoord
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}W�eld Insinking!{}{}Finansieel eksperte vrees ergste as ekonomie inmekaar sak!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Insinking Oor!{}{}Oplewing in sake gee vertroue na nywerhede as ekonomie versterk!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Tokkel groot/klein venster groote
--- a/src/lang/american.txt	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3437 +0,0 @@
-##name American
-##ownname English (US)
-##isocode en_US
-##plural 0
-
-#
-
-##id 0x0000
-STR_NULL                                                        :
-STR_0001_OFF_EDGE_OF_MAP                                        :{WHITE}Off edge of map
-STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP                               :{WHITE}Too close to edge of map
-STR_0003_NOT_ENOUGH_CASH_REQUIRES                               :{WHITE}Not enough cash - requires {CURRENCY}
-STR_0004                                                        :{WHITE}{CURRENCY}
-STR_EMPTY                                                       :
-STR_0007_FLAT_LAND_REQUIRED                                     :{WHITE}Flat land required
-STR_0008_WAITING                                                :{BLACK}Waiting: {WHITE}{STRING}
-STR_0009                                                        :{WHITE}{CARGO}
-STR_000A_EN_ROUTE_FROM                                          :{WHITE}{CARGO}{YELLOW}  (en-route from
-STR_000B                                                        :{YELLOW}{STATION})
-STR_000C_ACCEPTS                                                :{BLACK}Accepts: {WHITE}
-STR_000D_ACCEPTS                                                :{BLACK}Accepts: {GOLD}
-STR_000E                                                        :
-STR_000F_PASSENGERS                                             :Passengers
-STR_0010_COAL                                                   :Coal
-STR_0011_MAIL                                                   :Mail
-STR_0012_OIL                                                    :Oil
-STR_0013_LIVESTOCK                                              :Livestock
-STR_0014_GOODS                                                  :Goods
-STR_0015_GRAIN                                                  :Grain
-STR_0016_WOOD                                                   :Wood
-STR_0017_IRON_ORE                                               :Iron Ore
-STR_0018_STEEL                                                  :Steel
-STR_0019_VALUABLES                                              :Valuables
-STR_001A_COPPER_ORE                                             :Copper Ore
-STR_001B_MAIZE                                                  :Maize
-STR_001C_FRUIT                                                  :Fruit
-STR_001D_DIAMONDS                                               :Diamonds
-STR_001E_FOOD                                                   :Food
-STR_001F_PAPER                                                  :Paper
-STR_0020_GOLD                                                   :Gold
-STR_0021_WATER                                                  :Water
-STR_0022_WHEAT                                                  :Wheat
-STR_0023_RUBBER                                                 :Rubber
-STR_0024_SUGAR                                                  :Sugar
-STR_0025_TOYS                                                   :Toys
-STR_0026_CANDY                                                  :Candy
-STR_0027_COLA                                                   :Cola
-STR_0028_COTTON_CANDY                                           :Cotton Candy
-STR_0029_BUBBLES                                                :Bubbles
-STR_002A_TOFFEE                                                 :Toffee
-STR_002B_BATTERIES                                              :Batteries
-STR_002C_PLASTIC                                                :Plastic
-STR_002D_FIZZY_DRINKS                                           :Fizzy Drinks
-STR_002E                                                        :
-STR_002F_PASSENGER                                              :Passenger
-STR_0030_COAL                                                   :Coal
-STR_0031_MAIL                                                   :Mail
-STR_0032_OIL                                                    :Oil
-STR_0033_LIVESTOCK                                              :Livestock
-STR_0034_GOODS                                                  :Goods
-STR_0035_GRAIN                                                  :Grain
-STR_0036_WOOD                                                   :Wood
-STR_0037_IRON_ORE                                               :Iron Ore
-STR_0038_STEEL                                                  :Steel
-STR_0039_VALUABLES                                              :Valuables
-STR_003A_COPPER_ORE                                             :Copper Ore
-STR_003B_MAIZE                                                  :Maize
-STR_003C_FRUIT                                                  :Fruit
-STR_003D_DIAMOND                                                :Diamond
-STR_003E_FOOD                                                   :Food
-STR_003F_PAPER                                                  :Paper
-STR_0040_GOLD                                                   :Gold
-STR_0041_WATER                                                  :Water
-STR_0042_WHEAT                                                  :Wheat
-STR_0043_RUBBER                                                 :Rubber
-STR_0044_SUGAR                                                  :Sugar
-STR_0045_TOY                                                    :Toy
-STR_0046_CANDY                                                  :Candy
-STR_0047_COLA                                                   :Cola
-STR_0048_COTTON_CANDY                                           :Cotton Candy
-STR_0049_BUBBLE                                                 :Bubble
-STR_004A_TOFFEE                                                 :Toffee
-STR_004B_BATTERY                                                :Battery
-STR_004C_PLASTIC                                                :Plastic
-STR_004D_FIZZY_DRINK                                            :Fizzy Drink
-STR_QUANTITY_NOTHING                                            :
-STR_QUANTITY_PASSENGERS                                         :{COMMA} passenger{P "" s}
-STR_QUANTITY_COAL                                               :{WEIGHT} of coal
-STR_QUANTITY_MAIL                                               :{COMMA} bag{P "" s} of mail
-STR_QUANTITY_OIL                                                :{VOLUME} of oil
-STR_QUANTITY_LIVESTOCK                                          :{COMMA} item{P "" s} of livestock
-STR_QUANTITY_GOODS                                              :{COMMA} crate{P "" s} of goods
-STR_QUANTITY_GRAIN                                              :{WEIGHT} of grain
-STR_QUANTITY_WOOD                                               :{WEIGHT} of wood
-STR_QUANTITY_IRON_ORE                                           :{WEIGHT} of iron ore
-STR_QUANTITY_STEEL                                              :{WEIGHT} of steel
-STR_QUANTITY_VALUABLES                                          :{COMMA} bag{P "" s} of valuables
-STR_QUANTITY_COPPER_ORE                                         :{WEIGHT} of copper ore
-STR_QUANTITY_MAIZE                                              :{WEIGHT} of maize
-STR_QUANTITY_FRUIT                                              :{WEIGHT} of fruit
-STR_QUANTITY_DIAMONDS                                           :{COMMA} bag{P "" s} of diamonds
-STR_QUANTITY_FOOD                                               :{WEIGHT} of food
-STR_QUANTITY_PAPER                                              :{WEIGHT} of paper
-STR_QUANTITY_GOLD                                               :{COMMA} bag{P "" s} of gold
-STR_QUANTITY_WATER                                              :{VOLUME} of water
-STR_QUANTITY_WHEAT                                              :{WEIGHT} of wheat
-STR_QUANTITY_RUBBER                                             :{VOLUME} of rubber
-STR_QUANTITY_SUGAR                                              :{WEIGHT} of sugar
-STR_QUANTITY_TOYS                                               :{COMMA} toy{P "" s}
-STR_QUANTITY_SWEETS                                             :{COMMA} bag{P "" s} of candy
-STR_QUANTITY_COLA                                               :{VOLUME} of cola
-STR_QUANTITY_CANDYFLOSS                                         :{WEIGHT} of cotton candy
-STR_QUANTITY_BUBBLES                                            :{COMMA} bubble{P "" s}
-STR_QUANTITY_TOFFEE                                             :{WEIGHT} of toffee
-STR_QUANTITY_BATTERIES                                          :{COMMA} batter{P y ies}
-STR_QUANTITY_PLASTIC                                            :{VOLUME} of plastic
-STR_QUANTITY_FIZZY_DRINKS                                       :{COMMA} fizzy drink{P "" s}
-STR_ABBREV_NOTHING                                              :
-STR_ABBREV_PASSENGERS                                           :{TINYFONT}PS
-STR_ABBREV_COAL                                                 :{TINYFONT}CL
-STR_ABBREV_MAIL                                                 :{TINYFONT}ML
-STR_ABBREV_OIL                                                  :{TINYFONT}OL
-STR_ABBREV_LIVESTOCK                                            :{TINYFONT}LV
-STR_ABBREV_GOODS                                                :{TINYFONT}GD
-STR_ABBREV_GRAIN                                                :{TINYFONT}GR
-STR_ABBREV_WOOD                                                 :{TINYFONT}WD
-STR_ABBREV_IRON_ORE                                             :{TINYFONT}OR
-STR_ABBREV_STEEL                                                :{TINYFONT}ST
-STR_ABBREV_VALUABLES                                            :{TINYFONT}VL
-STR_ABBREV_COPPER_ORE                                           :{TINYFONT}CO
-STR_ABBREV_MAIZE                                                :{TINYFONT}MZ
-STR_ABBREV_FRUIT                                                :{TINYFONT}FT
-STR_ABBREV_DIAMONDS                                             :{TINYFONT}DM
-STR_ABBREV_FOOD                                                 :{TINYFONT}FD
-STR_ABBREV_PAPER                                                :{TINYFONT}PR
-STR_ABBREV_GOLD                                                 :{TINYFONT}GD
-STR_ABBREV_WATER                                                :{TINYFONT}WR
-STR_ABBREV_WHEAT                                                :{TINYFONT}WH
-STR_ABBREV_RUBBER                                               :{TINYFONT}RB
-STR_ABBREV_SUGAR                                                :{TINYFONT}SG
-STR_ABBREV_TOYS                                                 :{TINYFONT}TY
-STR_ABBREV_SWEETS                                               :{TINYFONT}SW
-STR_ABBREV_COLA                                                 :{TINYFONT}CL
-STR_ABBREV_CANDYFLOSS                                           :{TINYFONT}CF
-STR_ABBREV_BUBBLES                                              :{TINYFONT}BU
-STR_ABBREV_TOFFEE                                               :{TINYFONT}TF
-STR_ABBREV_BATTERIES                                            :{TINYFONT}BA
-STR_ABBREV_PLASTIC                                              :{TINYFONT}PL
-STR_ABBREV_FIZZY_DRINKS                                         :{TINYFONT}FZ
-STR_ABBREV_NONE                                                 :{TINYFONT}NO
-STR_ABBREV_ALL                                                  :{TINYFONT}ALL
-STR_00AE                                                        :{WHITE}{DATE_SHORT}
-STR_00AF                                                        :{WHITE}{DATE_LONG}
-STR_00B0_MAP                                                    :{WHITE}Map - {STRING}
-STR_00B1_GAME_OPTIONS                                           :{WHITE}Game Options
-STR_00B2_MESSAGE                                                :{YELLOW}Message
-STR_00B3_MESSAGE_FROM                                           :{YELLOW}Message from {STRING}
-STR_POPUP_CAUTION_CAPTION                                       :{WHITE}Caution!
-STR_00B4_CAN_T_DO_THIS                                          :{WHITE}Can't do this....
-STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Can't clear this area....
-STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Original copyright {COPYRIGHT} 1995 Chris Sawyer, All rights reserved
-STR_00B7_VERSION                                                :{BLACK}OpenTTD version {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 The OpenTTD team
-STR_TRANSLATED_BY                                               :{BLACK}  Translator(s) -
-
-STR_00C5                                                        :{BLACK}{CROSS}
-STR_00C6                                                        :{SILVER}{CROSS}
-STR_00C7_QUIT                                                   :{WHITE}Quit
-STR_00C8_YES                                                    :{BLACK}Yes
-STR_00C9_NO                                                     :{BLACK}No
-STR_00CA_ARE_YOU_SURE_YOU_WANT_TO                               :{YELLOW}Are you sure you want to abandon this game and return to {STRING}?
-STR_00CB_1                                                      :{BLACK}1
-STR_00CC_2                                                      :{BLACK}2
-STR_00CD_3                                                      :{BLACK}3
-STR_00CE_4                                                      :{BLACK}4
-STR_00CF_5                                                      :{BLACK}5
-STR_00D0_NOTHING                                                :Nothing
-STR_00D1_DARK_BLUE                                              :Dark Blue
-STR_00D2_PALE_GREEN                                             :Pale Green
-STR_00D3_PINK                                                   :Pink
-STR_00D4_YELLOW                                                 :Yellow
-STR_00D5_RED                                                    :Red
-STR_00D6_LIGHT_BLUE                                             :Light Blue
-STR_00D7_GREEN                                                  :Green
-STR_00D8_DARK_GREEN                                             :Dark Green
-STR_00D9_BLUE                                                   :Blue
-STR_00DA_CREAM                                                  :Cream
-STR_00DB_MAUVE                                                  :Mauve
-STR_00DC_PURPLE                                                 :Purple
-STR_00DD_ORANGE                                                 :Orange
-STR_00DE_BROWN                                                  :Brown
-STR_00DF_GREY                                                   :Gray
-STR_00E0_WHITE                                                  :White
-STR_00E1_TOO_MANY_VEHICLES_IN_GAME                              :{WHITE}Too many vehicles in game
-STR_00E2                                                        :{BLACK}{COMMA}
-STR_00E3                                                        :{RED}{COMMA}
-STR_00E4_LOCATION                                               :{BLACK}Location
-STR_00E5_CONTOURS                                               :Contours
-STR_00E6_VEHICLES                                               :Vehicles
-STR_00E7_INDUSTRIES                                             :Industries
-STR_00E8_ROUTES                                                 :Routes
-STR_00E9_VEGETATION                                             :Vegetation
-STR_00EA_OWNERS                                                 :Owners
-STR_00EB_ROADS                                                  :{BLACK}{TINYFONT}Roads
-STR_00EC_RAILROADS                                              :{BLACK}{TINYFONT}Railroads
-STR_00ED_STATIONS_AIRPORTS_DOCKS                                :{BLACK}{TINYFONT}Stations/Airports/Docks
-STR_00EE_BUILDINGS_INDUSTRIES                                   :{BLACK}{TINYFONT}Buildings/Industries
-STR_00EF_VEHICLES                                               :{BLACK}{TINYFONT}Vehicles
-STR_00F0_100M                                                   :{BLACK}{TINYFONT}100m
-STR_00F1_200M                                                   :{BLACK}{TINYFONT}200m
-STR_00F2_300M                                                   :{BLACK}{TINYFONT}300m
-STR_00F3_400M                                                   :{BLACK}{TINYFONT}400m
-STR_00F4_500M                                                   :{BLACK}{TINYFONT}500m
-STR_00F5_TRAINS                                                 :{BLACK}{TINYFONT}Trains
-STR_00F6_ROAD_VEHICLES                                          :{BLACK}{TINYFONT}Road Vehicles
-STR_00F7_SHIPS                                                  :{BLACK}{TINYFONT}Ships
-STR_00F8_AIRCRAFT                                               :{BLACK}{TINYFONT}Aircraft
-STR_00F9_TRANSPORT_ROUTES                                       :{BLACK}{TINYFONT}Transport Routes
-STR_00FA_COAL_MINE                                              :{BLACK}{TINYFONT}Coal Mine
-STR_00FB_POWER_STATION                                          :{BLACK}{TINYFONT}Power Station
-STR_00FC_FOREST                                                 :{BLACK}{TINYFONT}Forest
-STR_00FD_SAWMILL                                                :{BLACK}{TINYFONT}Sawmill
-STR_00FE_OIL_REFINERY                                           :{BLACK}{TINYFONT}Oil Refinery
-STR_00FF_FARM                                                   :{BLACK}{TINYFONT}Farm
-STR_0100_FACTORY                                                :{BLACK}{TINYFONT}Factory
-STR_0101_PRINTING_WORKS                                         :{BLACK}{TINYFONT}Printing Works
-STR_0102_OIL_WELLS                                              :{BLACK}{TINYFONT}Oil Wells
-STR_0103_IRON_ORE_MINE                                          :{BLACK}{TINYFONT}Iron Ore Mine
-STR_0104_STEEL_MILL                                             :{BLACK}{TINYFONT}Steel Mill
-STR_0105_BANK                                                   :{BLACK}{TINYFONT}Bank
-STR_0106_PAPER_MILL                                             :{BLACK}{TINYFONT}Paper Mill
-STR_0107_GOLD_MINE                                              :{BLACK}{TINYFONT}Gold Mine
-STR_0108_FOOD_PROCESSING_PLANT                                  :{BLACK}{TINYFONT}Food Processing Plant
-STR_0109_DIAMOND_MINE                                           :{BLACK}{TINYFONT}Diamond Mine
-STR_010A_COPPER_ORE_MINE                                        :{BLACK}{TINYFONT}Copper Ore Mine
-STR_010B_FRUIT_PLANTATION                                       :{BLACK}{TINYFONT}Fruit Plantation
-STR_010C_RUBBER_PLANTATION                                      :{BLACK}{TINYFONT}Rubber Plantation
-STR_010D_WATER_SUPPLY                                           :{BLACK}{TINYFONT}Water Supply
-STR_010E_WATER_TOWER                                            :{BLACK}{TINYFONT}Water Tower
-STR_010F_LUMBER_MILL                                            :{BLACK}{TINYFONT}Lumber Mill
-STR_0110_COTTON_CANDY_FOREST                                    :{BLACK}{TINYFONT}Cotton Candy Forest
-STR_0111_CANDY_FACTORY                                          :{BLACK}{TINYFONT}Candy Factory
-STR_0112_BATTERY_FARM                                           :{BLACK}{TINYFONT}Battery Farm
-STR_0113_COLA_WELLS                                             :{BLACK}{TINYFONT}Cola Wells
-STR_0114_TOY_SHOP                                               :{BLACK}{TINYFONT}Toy Shop
-STR_0115_TOY_FACTORY                                            :{BLACK}{TINYFONT}Toy Factory
-STR_0116_PLASTIC_FOUNTAINS                                      :{BLACK}{TINYFONT}Plastic Fountains
-STR_0117_FIZZY_DRINK_FACTORY                                    :{BLACK}{TINYFONT}Fizzy Drink Factory
-STR_0118_BUBBLE_GENERATOR                                       :{BLACK}{TINYFONT}Bubble Generator
-STR_0119_TOFFEE_QUARRY                                          :{BLACK}{TINYFONT}Toffee Quarry
-STR_011A_SUGAR_MINE                                             :{BLACK}{TINYFONT}Sugar Mine
-STR_011B_RAILROAD_STATION                                       :{BLACK}{TINYFONT}Railroad Station
-STR_011C_TRUCK_LOADING_BAY                                      :{BLACK}{TINYFONT}Truck Loading Bay
-STR_011D_BUS_STATION                                            :{BLACK}{TINYFONT}Bus Station
-STR_011E_AIRPORT_HELIPORT                                       :{BLACK}{TINYFONT}Airport/Heliport
-STR_011F_DOCK                                                   :{BLACK}{TINYFONT}Dock
-STR_0120_ROUGH_LAND                                             :{BLACK}{TINYFONT}Rough Land
-STR_0121_GRASS_LAND                                             :{BLACK}{TINYFONT}Grass Land
-STR_0122_BARE_LAND                                              :{BLACK}{TINYFONT}Bare Land
-STR_0123_FIELDS                                                 :{BLACK}{TINYFONT}Fields
-STR_0124_TREES                                                  :{BLACK}{TINYFONT}Trees
-STR_0125_ROCKS                                                  :{BLACK}{TINYFONT}Rocks
-STR_0126_WATER                                                  :{BLACK}{TINYFONT}Water
-STR_0127_NO_OWNER                                               :{BLACK}{TINYFONT}No Owner
-STR_0128_TOWNS                                                  :{BLACK}{TINYFONT}Towns
-STR_0129_INDUSTRIES                                             :{BLACK}{TINYFONT}Industries
-STR_012A_DESERT                                                 :{BLACK}{TINYFONT}Desert
-STR_012B_SNOW                                                   :{BLACK}{TINYFONT}Snow
-STR_012C_MESSAGE                                                :{WHITE}Message
-STR_012D                                                        :{WHITE}{STRING}
-STR_012E_CANCEL                                                 :{BLACK}Cancel
-STR_012F_OK                                                     :{BLACK}OK
-STR_0130_RENAME                                                 :{BLACK}Rename
-STR_0131_TOO_MANY_NAMES_DEFINED                                 :{WHITE}Too many names defined
-STR_0132_CHOSEN_NAME_IN_USE_ALREADY                             :{WHITE}Chosen name already in use
-
-STR_0133_WINDOWS                                                :Windows
-STR_0134_UNIX                                                   :Unix
-STR_0135_OSX                                                    :OS X
-STR_OSNAME_BEOS                                                 :BeOS
-STR_OSNAME_MORPHOS                                              :MorphOS
-STR_OSNAME_AMIGAOS                                              :AmigaOS
-STR_OSNAME_OS2                                                  :OS/2
-STR_OSNAME_SUNOS                                                :SunOS
-
-STR_013B_OWNED_BY                                               :{WHITE}...owned by {STRING}
-STR_013C_CARGO                                                  :{BLACK}Cargo
-STR_013D_INFORMATION                                            :{BLACK}Information
-STR_013E_CAPACITIES                                             :{BLACK}Capacities
-STR_013E_TOTAL_CARGO                                            :{BLACK}Total Cargo
-STR_013F_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}
-STR_CAPACITY_MULT                                               :{BLACK}Capacity: {LTBLUE}{CARGO} (x{NUM})
-STR_013F_TOTAL_CAPACITY_TEXT                                    :{BLACK}Total cargo (capacity) of this train:
-STR_013F_TOTAL_CAPACITY                                         :{LTBLUE}- {CARGO} ({SHORTCARGO})
-STR_TOTAL_CAPACITY_MULT                                         :{LTBLUE}- {CARGO} ({SHORTCARGO}) (x{NUM})
-STR_0140_NEW_GAME                                               :{BLACK}New Game
-STR_0141_LOAD_GAME                                              :{BLACK}Load Game
-STR_SINGLE_PLAYER                                               :{BLACK}Single player
-STR_MULTIPLAYER                                                 :{BLACK}Multiplayer
-STR_SCENARIO_EDITOR                                             :{BLACK}Scenario Editor
-
-STR_64                                                          :64
-STR_128                                                         :128
-STR_256                                                         :256
-STR_512                                                         :512
-STR_1024                                                        :1024
-STR_2048                                                        :2048
-STR_MAPSIZE                                                     :{BLACK}Map size:
-STR_BY                                                          :{BLACK}*
-STR_0148_GAME_OPTIONS                                           :{BLACK}Game Options
-
-STR_0150_SOMEONE                                                :someone{SKIP}{SKIP}
-STR_0151_MAP_OF_WORLD                                           :Map of world
-STR_0152_TOWN_DIRECTORY                                         :Town directory
-STR_0153_SUBSIDIES                                              :Subsidies
-
-STR_UNITS_IMPERIAL                                              :Imperial
-STR_UNITS_METRIC                                                :Metric
-STR_UNITS_SI                                                    :SI
-
-STR_UNITS_VELOCITY_IMPERIAL                                     :{COMMA} mph
-STR_UNITS_VELOCITY_METRIC                                       :{COMMA} km/h
-STR_UNITS_VELOCITY_SI                                           :{COMMA} m/s
-
-STR_UNITS_POWER_IMPERIAL                                        :{COMMA}hp
-STR_UNITS_POWER_METRIC                                          :{COMMA}hp
-STR_UNITS_POWER_SI                                              :{COMMA}kW
-
-STR_UNITS_WEIGHT_SHORT_IMPERIAL                                 :{COMMA}t
-STR_UNITS_WEIGHT_SHORT_METRIC                                   :{COMMA}t
-STR_UNITS_WEIGHT_SHORT_SI                                       :{COMMA}kg
-
-STR_UNITS_WEIGHT_LONG_IMPERIAL                                  :{COMMA} ton{P "" s}
-STR_UNITS_WEIGHT_LONG_METRIC                                    :{COMMA} tonne{P "" s}
-STR_UNITS_WEIGHT_LONG_SI                                        :{COMMA} kg
-
-STR_UNITS_VOLUME_SHORT_IMPERIAL                                 :{COMMA}gal
-STR_UNITS_VOLUME_SHORT_METRIC                                   :{COMMA}l
-STR_UNITS_VOLUME_SHORT_SI                                       :{COMMA}m³
-
-STR_UNITS_VOLUME_LONG_IMPERIAL                                  :{COMMA} gallon{P "" s}
-STR_UNITS_VOLUME_LONG_METRIC                                    :{COMMA} litre{P "" s}
-STR_UNITS_VOLUME_LONG_SI                                        :{COMMA} m³
-
-STR_UNITS_FORCE_IMPERIAL                                        :{COMMA}x10³lbf
-STR_UNITS_FORCE_METRIC                                          :{COMMA} tonne force
-STR_UNITS_FORCE_SI                                              :{COMMA} kN
-
-############ range for menu starts
-STR_0154_OPERATING_PROFIT_GRAPH                                 :Operating profit graph
-STR_0155_INCOME_GRAPH                                           :Income graph
-STR_0156_DELIVERED_CARGO_GRAPH                                  :Delivered cargo graph
-STR_0157_PERFORMANCE_HISTORY_GRAPH                              :Performance history graph
-STR_0158_COMPANY_VALUE_GRAPH                                    :Company value graph
-STR_0159_CARGO_PAYMENT_RATES                                    :Cargo payment rates
-STR_015A_COMPANY_LEAGUE_TABLE                                   :Company league table
-STR_PERFORMANCE_DETAIL_MENU                                     :Detailed performance rating
-############ range for menu ends
-
-STR_015B_OPENTTD                                                :{WHITE}OpenTTD
-STR_015C_SAVE_GAME                                              :Save game
-STR_015D_LOAD_GAME                                              :Load game
-STR_015E_QUIT_GAME                                              :Quit game
-STR_015F_QUIT                                                   :Quit
-STR_ABANDON_GAME_QUERY                                          :{YELLOW}Are you sure you want to quit this game ?
-STR_0161_QUIT_GAME                                              :{WHITE}Quit Game
-STR_SORT_ORDER_TIP                                              :{BLACK}Select sorting order (descending/ascending)
-STR_SORT_CRITERIA_TIP                                           :{BLACK}Select sorting criteria
-STR_SORT_BY                                                     :{BLACK}Sort by
-
-STR_SORT_BY_POPULATION                                          :{BLACK}Population
-STR_SORT_BY_PRODUCTION                                          :{BLACK}Production
-STR_SORT_BY_TYPE                                                :{BLACK}Type
-STR_SORT_BY_TRANSPORTED                                         :{BLACK}Transported
-STR_SORT_BY_NAME                                                :{BLACK}Name
-STR_SORT_BY_DROPDOWN_NAME                                       :Name
-STR_SORT_BY_DATE                                                :{BLACK}Date
-STR_SORT_BY_NUMBER                                              :Number
-STR_SORT_BY_PROFIT_LAST_YEAR                                    :Profit last year
-STR_SORT_BY_PROFIT_THIS_YEAR                                    :Profit this year
-STR_SORT_BY_AGE                                                 :Age
-STR_SORT_BY_RELIABILITY                                         :Reliability
-STR_SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE                        :Total capacity per cargo type
-STR_SORT_BY_MAX_SPEED                                           :Maximum speed
-STR_SORT_BY_MODEL                                               :Model
-STR_SORT_BY_VALUE                                               :Value
-STR_SORT_BY_FACILITY                                            :Station type
-STR_SORT_BY_WAITING                                             :Waiting cargo value
-STR_SORT_BY_RATING_MAX                                          :Cargo rating
-STR_ENGINE_SORT_ENGINE_ID                                       :EngineID (classic sort)
-STR_ENGINE_SORT_COST                                            :Cost
-STR_ENGINE_SORT_POWER                                           :Power
-STR_ENGINE_SORT_INTRO_DATE                                      :Introduction Date
-STR_ENGINE_SORT_RUNNING_COST                                    :Running Cost
-STR_ENGINE_SORT_POWER_VS_RUNNING_COST                           :Power/Running Cost
-STR_ENGINE_SORT_CARGO_CAPACITY                                  :Cargo Capacity
-STR_NO_WAITING_CARGO                                            :{BLACK}No cargo of any type is waiting
-STR_SELECT_ALL_FACILITIES                                       :{BLACK}Select all facilities
-STR_SELECT_ALL_TYPES                                            :{BLACK}Select all cargo types (including no waiting cargo)
-STR_AVAILABLE_TRAINS                                            :{BLACK}Available Trains
-STR_AVAILABLE_ROAD_VEHICLES                                     :{BLACK}Available Road Vehicles
-STR_AVAILABLE_SHIPS                                             :{BLACK}Available Ships
-STR_AVAILABLE_AIRCRAFT                                          :{BLACK}Available Aircraft
-STR_AVAILABLE_ENGINES_TIP                                       :{BLACK}See a list of available engine designs for this vehicle type.
-STR_MANAGE_LIST                                                 :{BLACK}Manage list
-STR_MANAGE_LIST_TIP                                             :{BLACK}Send instructions to all vehicles in this list
-STR_REPLACE_VEHICLES                                            :Replace vehicles
-STR_SEND_TRAIN_TO_DEPOT                                         :Send to Depot
-STR_SEND_ROAD_VEHICLE_TO_DEPOT                                  :Send to Depot
-STR_SEND_SHIP_TO_DEPOT                                          :Send to Depot
-STR_SEND_AIRCRAFT_TO_HANGAR                                     :Send to Hangar
-STR_SEND_FOR_SERVICING                                          :Send for Servicing
-
-############ range for months starts
-STR_0162_JAN                                                    :Jan
-STR_0163_FEB                                                    :Feb
-STR_0164_MAR                                                    :Mar
-STR_0165_APR                                                    :Apr
-STR_0166_MAY                                                    :May
-STR_0167_JUN                                                    :Jun
-STR_0168_JUL                                                    :Jul
-STR_0169_AUG                                                    :Aug
-STR_016A_SEP                                                    :Sep
-STR_016B_OCT                                                    :Oct
-STR_016C_NOV                                                    :Nov
-STR_016D_DEC                                                    :Dec
-############ range for months ends
-
-STR_016E                                                        :{TINYFONT}{STRING}{} {STRING}
-STR_016F                                                        :{TINYFONT}{STRING}{} {STRING}{}{NUM}
-STR_0170                                                        :{TINYFONT}{STRING}-
-STR_0171_PAUSE_GAME                                             :{BLACK}Pause game
-STR_0172_SAVE_GAME_ABANDON_GAME                                 :{BLACK}Save game, quit game, quit
-STR_0173_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's stations
-STR_0174_DISPLAY_MAP                                            :{BLACK}Display map
-STR_0175_DISPLAY_MAP_TOWN_DIRECTORY                             :{BLACK}Display map, town directory
-STR_0176_DISPLAY_TOWN_DIRECTORY                                 :{BLACK}Display town directory
-STR_0177_DISPLAY_COMPANY_FINANCES                               :{BLACK}Display company finances information
-STR_0178_DISPLAY_COMPANY_GENERAL                                :{BLACK}Display general company information
-STR_0179_DISPLAY_GRAPHS                                         :{BLACK}Display graphs
-STR_017A_DISPLAY_COMPANY_LEAGUE                                 :{BLACK}Display company league table
-STR_017B_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's trains
-STR_017C_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's road vehicles
-STR_017D_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's ships
-STR_017E_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's aircraft
-STR_017F_ZOOM_THE_VIEW_IN                                       :{BLACK}Zoom the view in
-STR_0180_ZOOM_THE_VIEW_OUT                                      :{BLACK}Zoom the view out
-STR_0181_BUILD_RAILROAD_TRACK                                   :{BLACK}Build railroad track
-STR_0182_BUILD_ROADS                                            :{BLACK}Build roads
-STR_0183_BUILD_SHIP_DOCKS                                       :{BLACK}Build ship docks
-STR_0184_BUILD_AIRPORTS                                         :{BLACK}Build airports
-STR_0185_PLANT_TREES_PLACE_SIGNS                                :{BLACK}Plant trees, place signs etc.
-STR_0186_LAND_BLOCK_INFORMATION                                 :{BLACK}Land area information
-STR_0187_OPTIONS                                                :{BLACK}Options
-STR_0188                                                        :{BLACK}{SMALLUPARROW}
-STR_0189                                                        :{BLACK}{SMALLDOWNARROW}
-STR_018A_CAN_T_CHANGE_SERVICING                                 :{WHITE}Can't change servicing interval...
-STR_018B_CLOSE_WINDOW                                           :{BLACK}Close window
-STR_018C_WINDOW_TITLE_DRAG_THIS                                 :{BLACK}Window title - drag this to move window
-STR_STICKY_BUTTON                                               :{BLACK}Mark this window as uncloseable for the 'Close All Windows' key
-STR_RESIZE_BUTTON                                               :{BLACK}Click and drag to resize this window
-STR_SAVELOAD_HOME_BUTTON                                        :{BLACK}Click here to jump to the current default save/load directory
-STR_018D_DEMOLISH_BUILDINGS_ETC                                 :{BLACK}Demolish buildings etc. on a square of land
-STR_018E_LOWER_A_CORNER_OF_LAND                                 :{BLACK}Lower a corner of land
-STR_018F_RAISE_A_CORNER_OF_LAND                                 :{BLACK}Raise a corner of land
-STR_0190_SCROLL_BAR_SCROLLS_LIST                                :{BLACK}Scroll bar - scrolls list up/down
-STR_HSCROLL_BAR_SCROLLS_LIST                                    :{BLACK}Scroll bar - scrolls list left/right
-STR_0191_SHOW_LAND_CONTOURS_ON_MAP                              :{BLACK}Show land contours on map
-STR_0192_SHOW_VEHICLES_ON_MAP                                   :{BLACK}Show vehicles on map
-STR_0193_SHOW_INDUSTRIES_ON_MAP                                 :{BLACK}Show industries on map
-STR_0194_SHOW_TRANSPORT_ROUTES_ON                               :{BLACK}Show transport routes on map
-STR_0195_SHOW_VEGETATION_ON_MAP                                 :{BLACK}Show vegetation on map
-STR_0196_SHOW_LAND_OWNERS_ON_MAP                                :{BLACK}Show land owners on map
-STR_0197_TOGGLE_TOWN_NAMES_ON_OFF                               :{BLACK}Toggle town names on/off on map
-STR_0198_PROFIT_THIS_YEAR_LAST_YEAR                             :{TINYFONT}{BLACK}Profit this year: {CURRENCY} (last year: {CURRENCY})
-
-############ range for service numbers starts
-STR_AGE                                                         :{COMMA} year{P "" s} ({COMMA})
-STR_AGE_RED                                                     :{RED}{COMMA} year{P "" s} ({COMMA})
-############ range for service numbers ends
-
-STR_019C_ROAD_VEHICLE                                           :Road vehicle
-STR_019D_AIRCRAFT                                               :Aircraft
-STR_019E_SHIP                                                   :Ship
-STR_019F_TRAIN                                                  :Train
-STR_01A0_IS_GETTING_OLD                                         :{WHITE}{STRING} {COMMA} is getting old
-STR_01A1_IS_GETTING_VERY_OLD                                    :{WHITE}{STRING} {COMMA} is getting very old
-STR_01A2_IS_GETTING_VERY_OLD_AND                                :{WHITE}{STRING} {COMMA} is getting very old and urgently needs replacing
-STR_01A3_LAND_AREA_INFORMATION                                  :{WHITE}Land Area Information
-STR_01A4_COST_TO_CLEAR_N_A                                      :{BLACK}Cost to clear: {LTBLUE}N/A
-STR_01A5_COST_TO_CLEAR                                          :{BLACK}Cost to clear: {LTBLUE}{CURRENCY}
-STR_01A6_N_A                                                    :N/A
-STR_01A7_OWNER                                                  :{BLACK}Owner: {LTBLUE}{STRING}
-STR_01A8_LOCAL_AUTHORITY                                        :{BLACK}Local authority: {LTBLUE}{STRING}
-STR_01A9_NONE                                                   :None
-STR_01AA_NAME                                                   :{BLACK}Name
-STR_01AB                                                        :{BLACK}{TINYFONT}{VEHICLE}
-
-############ range for days starts
-STR_01AC_1ST                                                    :1st
-STR_01AD_2ND                                                    :2nd
-STR_01AE_3RD                                                    :3rd
-STR_01AF_4TH                                                    :4th
-STR_01B0_5TH                                                    :5th
-STR_01B1_6TH                                                    :6th
-STR_01B2_7TH                                                    :7th
-STR_01B3_8TH                                                    :8th
-STR_01B4_9TH                                                    :9th
-STR_01B5_10TH                                                   :10th
-STR_01B6_11TH                                                   :11th
-STR_01B7_12TH                                                   :12th
-STR_01B8_13TH                                                   :13th
-STR_01B9_14TH                                                   :14th
-STR_01BA_15TH                                                   :15th
-STR_01BB_16TH                                                   :16th
-STR_01BC_17TH                                                   :17th
-STR_01BD_18TH                                                   :18th
-STR_01BE_19TH                                                   :19th
-STR_01BF_20TH                                                   :20th
-STR_01C0_21ST                                                   :21st
-STR_01C1_22ND                                                   :22nd
-STR_01C2_23RD                                                   :23rd
-STR_01C3_24TH                                                   :24th
-STR_01C4_25TH                                                   :25th
-STR_01C5_26TH                                                   :26th
-STR_01C6_27TH                                                   :27th
-STR_01C7_28TH                                                   :28th
-STR_01C8_29TH                                                   :29th
-STR_01C9_30TH                                                   :30th
-STR_01CA_31ST                                                   :31st
-############ range for days ends
-
-STR_01CB                                                        :{TINYFONT}{COMMA}
-
-STR_01CE_CARGO_ACCEPTED                                         :{BLACK}Cargo accepted: {LTBLUE}
-
-STR_01D1_8                                                      :({COMMA}/8 {STRING})
-STR_01D2_JAZZ_JUKEBOX                                           :{WHITE}Jazz Jukebox
-STR_01D3_SOUND_MUSIC                                            :Sound/music
-STR_01D4_SHOW_SOUND_MUSIC_WINDOW                                :{BLACK}Show sound/music window
-STR_01D5_ALL                                                    :{TINYFONT}All
-STR_01D6_OLD_STYLE                                              :{TINYFONT}Old Style
-STR_01D7_NEW_STYLE                                              :{TINYFONT}New Style
-STR_01D8_EZY_STREET                                             :{TINYFONT}Ezy Street
-STR_01D9_CUSTOM_1                                               :{TINYFONT}Custom 1
-STR_01DA_CUSTOM_2                                               :{TINYFONT}Custom 2
-STR_01DB_MUSIC_VOLUME                                           :{BLACK}{TINYFONT}Music Volume
-STR_01DC_EFFECTS_VOLUME                                         :{BLACK}{TINYFONT}Effects Volume
-STR_01DD_MIN_MAX                                                :{BLACK}{TINYFONT}MIN  '  '  ' '  '  '  MAX
-STR_01DE_SKIP_TO_PREVIOUS_TRACK                                 :{BLACK}Skip to previous track in selection
-STR_01DF_SKIP_TO_NEXT_TRACK_IN_SELECTION                        :{BLACK}Skip to next track in selection
-STR_01E0_STOP_PLAYING_MUSIC                                     :{BLACK}Stop playing music
-STR_01E1_START_PLAYING_MUSIC                                    :{BLACK}Start playing music
-STR_01E2_DRAG_SLIDERS_TO_SET_MUSIC                              :{BLACK}Drag sliders to set music and sound effect volumes
-STR_01E3                                                        :{DKGREEN}{TINYFONT}--
-STR_01E4_0                                                      :{DKGREEN}{TINYFONT}0{COMMA}
-STR_01E5                                                        :{DKGREEN}{TINYFONT}{COMMA}
-STR_01E6                                                        :{DKGREEN}{TINYFONT}------
-STR_01E7                                                        :{DKGREEN}{TINYFONT}"{STRING}"
-STR_01E8_TRACK_XTITLE                                           :{BLACK}{TINYFONT}Track{SETX 88}Title
-STR_01E9_SHUFFLE                                                :{TINYFONT}Shuffle
-STR_01EA_PROGRAM                                                :{TINYFONT}{BLACK}Program
-STR_01EB_MUSIC_PROGRAM_SELECTION                                :{WHITE}Music Program Selection
-STR_01EC_0                                                      :{TINYFONT}{LTBLUE}0{COMMA} "{STRING}"
-STR_01ED                                                        :{TINYFONT}{LTBLUE}{COMMA} "{STRING}"
-STR_01EE_TRACK_INDEX                                            :{TINYFONT}{BLACK}Track Index
-STR_01EF_PROGRAM                                                :{TINYFONT}{BLACK}Program - '{STRING}'
-STR_01F0_CLEAR                                                  :{TINYFONT}{BLACK}Clear
-STR_01F1_SAVE                                                   :{TINYFONT}{BLACK}Save
-STR_01F2_CURRENT_PROGRAM_OF_MUSIC                               :{BLACK}Current program of music tracks
-STR_01F3_SELECT_ALL_TRACKS_PROGRAM                              :{BLACK}Select 'all tracks' program
-STR_01F4_SELECT_OLD_STYLE_MUSIC                                 :{BLACK}Select 'old style music' program
-STR_01F5_SELECT_NEW_STYLE_MUSIC                                 :{BLACK}Select 'new style music' program
-STR_01F6_SELECT_CUSTOM_1_USER_DEFINED                           :{BLACK}Select 'Custom 1' (user-defined) program
-STR_01F7_SELECT_CUSTOM_2_USER_DEFINED                           :{BLACK}Select 'Custom 2' (user-defined) program
-STR_01F8_CLEAR_CURRENT_PROGRAM_CUSTOM1                          :{BLACK}Clear current program (Custom1 or Custom2 only)
-STR_01F9_SAVE_MUSIC_SETTINGS                                    :{BLACK}Save music settings
-STR_01FA_CLICK_ON_MUSIC_TRACK_TO                                :{BLACK}Click on music track to add to current program (Custom1 or Custom2 only)
-STR_CLICK_ON_TRACK_TO_REMOVE                                    :{BLACK}Click on music track to remove it from current program (Custom1 or Custom2 only)
-STR_01FB_TOGGLE_PROGRAM_SHUFFLE                                 :{BLACK}Toggle program shuffle on/off
-STR_01FC_SHOW_MUSIC_TRACK_SELECTION                             :{BLACK}Show music track selection window
-STR_01FD_CLICK_ON_SERVICE_TO_CENTER                             :{BLACK}Click on service to center view on industry/town
-STR_01FE_DIFFICULTY                                             :{BLACK}Difficulty ({STRING})
-STR_01FF                                                        :{TINYFONT}{BLACK}{DATE_LONG}
-STR_0200_LAST_MESSAGE_NEWS_REPORT                               :Last message/news report
-STR_0201_MESSAGE_SETTINGS                                       :Message settings
-STR_MESSAGE_HISTORY_MENU                                        :Message History
-STR_0203_SHOW_LAST_MESSAGE_NEWS                                 :{BLACK}Show last message/news report, show message options
-STR_0204_MESSAGE_OPTIONS                                        :{WHITE}Message Options
-STR_0205_MESSAGE_TYPES                                          :{BLACK}Message types:
-STR_0206_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Arrival of first vehicle at player's station
-STR_0207_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Arrival of first vehicle at competitor's station
-STR_0208_ACCIDENTS_DISASTERS                                    :{YELLOW}Accidents / disasters
-STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Company information
-STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Open / close of industries
-STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Economy changes
-STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Advice / information on player's vehicles
-STR_020C_NEW_VEHICLES                                           :{YELLOW}New vehicles
-STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Changes of cargo acceptance
-STR_020E_SUBSIDIES                                              :{YELLOW}Subsidies
-STR_020F_GENERAL_INFORMATION                                    :{YELLOW}General information
-STR_MESSAGES_ALL                                                :{YELLOW}Setting for all messagetypes (off/summary/full)
-STR_MESSAGE_SOUND                                               :{YELLOW}Play sound for summarized newsmessages
-STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO                       :{WHITE}...too far from previous destination
-STR_0211_TOP_COMPANIES_WHO_REACHED                              :{BIGFONT}{BLACK}Top companies who reached {NUM}{}({STRING} Level)
-STR_TOP_COMPANIES_NETWORK_GAME                                  :{BIGFONT}{BLACK}Company League Table in {NUM}
-STR_0212                                                        :{BIGFONT}{COMMA}.
-STR_0213_BUSINESSMAN                                            :Businessman
-STR_0214_ENTREPRENEUR                                           :Entrepreneur
-STR_0215_INDUSTRIALIST                                          :Industrialist
-STR_0216_CAPITALIST                                             :Capitalist
-STR_0217_MAGNATE                                                :Magnate
-STR_0218_MOGUL                                                  :Mogul
-STR_0219_TYCOON_OF_THE_CENTURY                                  :Tycoon of the Century
-STR_HIGHSCORE_NAME                                              :{BIGFONT}{PLAYERNAME}, {COMPANY}
-STR_HIGHSCORE_STATS                                             :{BIGFONT}'{STRING}'   ({COMMA})
-STR_021B_ACHIEVES_STATUS                                        :{BLACK}{BIGFONT}{COMPANY} achieves '{STRING}' status!
-STR_021C_OF_ACHIEVES_STATUS                                     :{WHITE}{BIGFONT}{PLAYERNAME} of {COMPANY} achieves '{STRING}' status!
-STR_021F                                                        :{BLUE}{COMMA}
-STR_0221_OPENTTD                                                :{YELLOW}OpenTTD
-STR_0222_SCENARIO_EDITOR                                        :{YELLOW}Scenario Editor
-STR_0223_LAND_GENERATION                                        :{WHITE}Land Generation
-STR_0224                                                        :{BLACK}{UPARROW}
-STR_0225                                                        :{BLACK}{DOWNARROW}
-STR_0228_INCREASE_SIZE_OF_LAND_AREA                             :{BLACK}Increase area of land to lower/raise
-STR_0229_DECREASE_SIZE_OF_LAND_AREA                             :{BLACK}Decrease area of land to lower/raise
-STR_022A_GENERATE_RANDOM_LAND                                   :{BLACK}Generate random land
-STR_022B_RESET_LANDSCAPE                                        :{BLACK}Reset landscape
-STR_022C_RESET_LANDSCAPE                                        :{WHITE}Reset Landscape
-STR_RESET_LANDSCAPE_TOOLTIP                                     :{BLACK}Remove all player-owned property from the map
-STR_RESET_LANDSCAPE_CONFIRMATION_TEXT                           :{WHITE}Are you sure you want to remove all player-owned property?
-STR_022E_LANDSCAPE_GENERATION                                   :{BLACK}Landscape generation
-STR_022F_TOWN_GENERATION                                        :{BLACK}Town generation
-STR_0230_INDUSTRY_GENERATION                                    :{BLACK}Industry generation
-STR_0231_ROAD_CONSTRUCTION                                      :{BLACK}Road construction
-STR_0233_TOWN_GENERATION                                        :{WHITE}Town Generation
-STR_0234_NEW_TOWN                                               :{BLACK}New Town
-STR_0235_CONSTRUCT_NEW_TOWN                                     :{BLACK}Construct new town
-STR_0236_CAN_T_BUILD_TOWN_HERE                                  :{WHITE}Can't build town here...
-STR_0237_TOO_CLOSE_TO_EDGE_OF_MAP                               :{WHITE}...too close to edge of map
-STR_0238_TOO_CLOSE_TO_ANOTHER_TOWN                              :{WHITE}...too close to another town
-STR_0239_SITE_UNSUITABLE                                        :{WHITE}...site unsuitable
-STR_023A_TOO_MANY_TOWNS                                         :{WHITE}...too many towns
-STR_CANNOT_GENERATE_TOWN                                        :{WHITE}Can't build any towns
-STR_NO_SPACE_FOR_TOWN                                           :{WHITE}...there is no more space on the map
-STR_023B_INCREASE_SIZE_OF_TOWN                                  :{BLACK}Increase size of town
-STR_023C_EXPAND                                                 :{BLACK}Expand
-STR_023D_RANDOM_TOWN                                            :{BLACK}Random Town
-STR_023E_BUILD_TOWN_IN_RANDOM_LOCATION                          :{BLACK}Build town in random location
-STR_023F_INDUSTRY_GENERATION                                    :{WHITE}Industry Generation
-STR_0240_COAL_MINE                                              :{BLACK}Coal Mine
-STR_0241_POWER_STATION                                          :{BLACK}Power Station
-STR_0242_SAWMILL                                                :{BLACK}Sawmill
-STR_0243_FOREST                                                 :{BLACK}Forest
-STR_0244_OIL_REFINERY                                           :{BLACK}Oil Refinery
-STR_0245_OIL_RIG                                                :{BLACK}Oil Rig
-STR_0246_FACTORY                                                :{BLACK}Factory
-STR_0247_STEEL_MILL                                             :{BLACK}Steel Mill
-STR_0248_FARM                                                   :{BLACK}Farm
-STR_0249_IRON_ORE_MINE                                          :{BLACK}Iron Ore Mine
-STR_024A_OIL_WELLS                                              :{BLACK}Oil Wells
-STR_024B_BANK                                                   :{BLACK}Bank
-STR_024C_PAPER_MILL                                             :{BLACK}Paper Mill
-STR_024D_FOOD_PROCESSING_PLANT                                  :{BLACK}Food Processing Plant
-STR_024E_PRINTING_WORKS                                         :{BLACK}Printing Works
-STR_024F_GOLD_MINE                                              :{BLACK}Gold Mine
-STR_0250_LUMBER_MILL                                            :{BLACK}Lumber Mill
-STR_0251_FRUIT_PLANTATION                                       :{BLACK}Fruit Plantation
-STR_0252_RUBBER_PLANTATION                                      :{BLACK}Rubber Plantation
-STR_0253_WATER_SUPPLY                                           :{BLACK}Water Supply
-STR_0254_WATER_TOWER                                            :{BLACK}Water Tower
-STR_0255_DIAMOND_MINE                                           :{BLACK}Diamond Mine
-STR_0256_COPPER_ORE_MINE                                        :{BLACK}Copper Ore Mine
-STR_0257_COTTON_CANDY_FOREST                                    :{BLACK}Cotton Candy Forest
-STR_0258_CANDY_FACTORY                                          :{BLACK}Candy Factory
-STR_0259_BATTERY_FARM                                           :{BLACK}Battery Farm
-STR_025A_COLA_WELLS                                             :{BLACK}Cola Wells
-STR_025B_TOY_SHOP                                               :{BLACK}Toy Shop
-STR_025C_TOY_FACTORY                                            :{BLACK}Toy Factory
-STR_025D_PLASTIC_FOUNTAINS                                      :{BLACK}Plastic Fountains
-STR_025E_FIZZY_DRINK_FACTORY                                    :{BLACK}Fizzy Drink Factory
-STR_025F_BUBBLE_GENERATOR                                       :{BLACK}Bubble Generator
-STR_0260_TOFFEE_QUARRY                                          :{BLACK}Toffee Quarry
-STR_0261_SUGAR_MINE                                             :{BLACK}Sugar Mine
-STR_0262_CONSTRUCT_COAL_MINE                                    :{BLACK}Construct Coal Mine
-STR_0263_CONSTRUCT_POWER_STATION                                :{BLACK}Construct Power Station
-STR_0264_CONSTRUCT_SAWMILL                                      :{BLACK}Construct Sawmill
-STR_0265_PLANT_FOREST                                           :{BLACK}Plant Forest
-STR_0266_CONSTRUCT_OIL_REFINERY                                 :{BLACK}Construct Oil Refinery
-STR_0267_CONSTRUCT_OIL_RIG_CAN_ONLY                             :{BLACK}Construct Oil Rig (Can only be built near the edges of the map)
-STR_0268_CONSTRUCT_FACTORY                                      :{BLACK}Construct Factory
-STR_0269_CONSTRUCT_STEEL_MILL                                   :{BLACK}Construct Steel Mill
-STR_026A_CONSTRUCT_FARM                                         :{BLACK}Construct Farm
-STR_026B_CONSTRUCT_IRON_ORE_MINE                                :{BLACK}Construct Iron Ore Mine
-STR_026C_CONSTRUCT_OIL_WELLS                                    :{BLACK}Construct Oil Wells
-STR_026D_CONSTRUCT_BANK_CAN_ONLY                                :{BLACK}Construct Bank (Can only be built in towns with a population greater than 1200)
-STR_026E_CONSTRUCT_PAPER_MILL                                   :{BLACK}Construct Paper Mill
-STR_026F_CONSTRUCT_FOOD_PROCESSING                              :{BLACK}Construct Food Processing Plant
-STR_0270_CONSTRUCT_PRINTING_WORKS                               :{BLACK}Construct Printing Works
-STR_0271_CONSTRUCT_GOLD_MINE                                    :{BLACK}Construct Gold Mine
-STR_0272_CONSTRUCT_BANK_CAN_ONLY                                :{BLACK}Construct Bank (Can only be built in towns)
-STR_0273_CONSTRUCT_LUMBER_MILL_TO                               :{BLACK}Construct Lumber Mill (to clear rainforest and produce Wood)
-STR_0274_PLANT_FRUIT_PLANTATION                                 :{BLACK}Plant Fruit Plantation
-STR_0275_PLANT_RUBBER_PLANTATION                                :{BLACK}Plant Rubber Plantation
-STR_0276_CONSTRUCT_WATER_SUPPLY                                 :{BLACK}Construct Water Supply
-STR_0277_CONSTRUCT_WATER_TOWER_CAN                              :{BLACK}Construct Water Tower (Can only be built in towns)
-STR_0278_CONSTRUCT_DIAMOND_MINE                                 :{BLACK}Construct Diamond Mine
-STR_0279_CONSTRUCT_COPPER_ORE_MINE                              :{BLACK}Construct Copper Ore Mine
-STR_027A_PLANT_COTTON_CANDY_FOREST                              :{BLACK}Plant Cotton Candy Forest
-STR_027B_CONSTRUCT_CANDY_FACTORY                                :{BLACK}Construct Candy Factory
-STR_027C_CONSTRUCT_BATTERY_FARM                                 :{BLACK}Construct Battery Farm
-STR_027D_CONSTRUCT_COLA_WELLS                                   :{BLACK}Construct Cola Wells
-STR_027E_CONSTRUCT_TOY_SHOP                                     :{BLACK}Construct Toy Shop
-STR_027F_CONSTRUCT_TOY_FACTORY                                  :{BLACK}Construct Toy Factory
-STR_0280_CONSTRUCT_PLASTIC_FOUNTAINS                            :{BLACK}Construct Plastic Fountains
-STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY                          :{BLACK}Construct Fizzy Drink Factory
-STR_0282_CONSTRUCT_BUBBLE_GENERATOR                             :{BLACK}Construct Bubble Generator
-STR_0283_CONSTRUCT_TOFFEE_QUARRY                                :{BLACK}Construct Toffee Quarry
-STR_0284_CONSTRUCT_SUGAR_MINE                                   :{BLACK}Construct Sugar Mine
-STR_0285_CAN_T_BUILD_HERE                                       :{WHITE}Can't build {STRING} here...
-STR_0286_MUST_BUILD_TOWN_FIRST                                  :{WHITE}...must build town first
-STR_0287_ONLY_ONE_ALLOWED_PER_TOWN                              :{WHITE}...only one allowed per town
-STR_0288_PLANT_TREES                                            :{BLACK}Plant trees
-STR_0289_PLACE_SIGN                                             :{BLACK}Place sign
-STR_028A_RANDOM_TREES                                           :{BLACK}Random Trees
-STR_028B_PLANT_TREES_RANDOMLY_OVER                              :{BLACK}Plant trees randomly over landscape
-STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE                         :{BLACK}Place rocky areas on landscape
-STR_028D_PLACE_LIGHTHOUSE                                       :{BLACK}Place lighthouse
-STR_028E_PLACE_TRANSMITTER                                      :{BLACK}Place transmitter
-STR_028F_DEFINE_DESERT_AREA                                     :{BLACK}Define desert area.{}Press and hold CTRL to remove it
-STR_CREATE_LAKE                                                 :{BLACK}Define water area.{}Make a canal, unless CTRL is held down at sea level, when it will flood the surroundings instead
-STR_0290_DELETE                                                 :{BLACK}Delete
-STR_0291_DELETE_THIS_TOWN_COMPLETELY                            :{BLACK}Delete this town completely
-STR_0292_SAVE_SCENARIO                                          :Save scenario
-STR_0293_LOAD_SCENARIO                                          :Load scenario
-STR_LOAD_HEIGHTMAP                                              :Load heightmap
-STR_0294_QUIT_EDITOR                                            :Quit editor
-STR_0295                                                        :
-STR_0296_QUIT                                                   :Quit
-STR_0297_SAVE_SCENARIO_LOAD_SCENARIO                            :{BLACK}Save scenario, load scenario, abandon scenario editor, quit
-STR_0298_LOAD_SCENARIO                                          :{WHITE}Load Scenario
-STR_0299_SAVE_SCENARIO                                          :{WHITE}Save Scenario
-STR_029A_PLAY_SCENARIO                                          :{BLACK}Play Scenario
-STR_PLAY_HEIGHTMAP                                              :{BLACK}Play Heightmap
-STR_PLAY_HEIGHTMAP_HINT                                         :{BLACK}Start a new game, using a heightmap as landscape
-STR_QUIT_SCENARIO_QUERY                                         :{YELLOW}Are you sure you want to quit this scenario ?
-STR_029C_QUIT_EDITOR                                            :{WHITE}Quit Editor
-STR_029D_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...can only be built in towns with a population of at least 1200
-STR_029E_MOVE_THE_STARTING_DATE                                 :{BLACK}Move the starting date backward 1 year
-STR_029F_MOVE_THE_STARTING_DATE                                 :{BLACK}Move the starting date forward 1 year
-STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH                               :{WHITE}...ends of bridge must both be on land
-STR_02A1_SMALL                                                  :{BLACK}Small
-STR_02A2_MEDIUM                                                 :{BLACK}Medium
-STR_02A3_LARGE                                                  :{BLACK}Large
-STR_SCENARIO_EDITOR_CITY                                        :{BLACK}City
-STR_02A4_SELECT_TOWN_SIZE                                       :{BLACK}Select town size
-STR_02A5_TOWN_SIZE                                              :{YELLOW}Town size:
-
-STR_02B6                                                        :{STRING}  -  {STRING}
-STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS                              :{BLACK}Show last message or news report
-STR_OFF                                                         :Off
-STR_SUMMARY                                                     :Summary
-STR_FULL                                                        :Full
-STR_02BA                                                        :{SILVER}- -  {COMPANY}  - -
-STR_02BB_TOWN_DIRECTORY                                         :Town directory
-STR_02BC_VEHICLE_DESIGN_NAMES                                   :{BLACK}Vehicle design names
-STR_02BD                                                        :{BLACK}{STRING}
-STR_02BE_DEFAULT                                                :Default
-STR_02BF_CUSTOM                                                 :Custom
-STR_02C0_SAVE_CUSTOM_NAMES                                      :{BLACK}Save custom names
-STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION                         :{BLACK}Vehicle design names selection
-STR_02C2_SAVE_CUSTOMIZED_VEHICLE                                :{BLACK}Save customized vehicle design names
-
-STR_CHECKMARK                                                   :{CHECKMARK}
-############ range for menu starts
-STR_02C3_GAME_OPTIONS                                           :Game options
-STR_02C5_DIFFICULTY_SETTINGS                                    :Difficulty settings
-STR_02C7_CONFIG_PATCHES                                         :Configure patches
-STR_NEWGRF_SETTINGS                                             :Newgrf settings
-STR_TRANSPARENCY_OPTIONS                                        :Transparency options
-STR_GAMEOPTMENU_0A                                              :
-STR_02CA_TOWN_NAMES_DISPLAYED                                   :{SETX 12}Town names displayed
-STR_02CC_STATION_NAMES_DISPLAYED                                :{SETX 12}Station names displayed
-STR_02CE_SIGNS_DISPLAYED                                        :{SETX 12}Signs displayed
-STR_WAYPOINTS_DISPLAYED2                                        :{SETX 12}Waypoints displayed
-STR_02D0_FULL_ANIMATION                                         :{SETX 12}Full animation
-STR_02D2_FULL_DETAIL                                            :{SETX 12}Full detail
-STR_02D4_TRANSPARENT_BUILDINGS                                  :{SETX 12}Transparent buildings
-STR_TRANSPARENT_SIGNS                                           :{SETX 12}Transparent station signs
-############ range ends here
-
-############ range for menu starts
-STR_02D5_LAND_BLOCK_INFO                                        :Land area information
-STR_02D6                                                        :
-STR_CONSOLE_SETTING                                             :Toggle Console
-STR_02D7_SCREENSHOT_CTRL_S                                      :Screenshot (Ctrl-S)
-STR_02D8_GIANT_SCREENSHOT_CTRL_G                                :Giant Screenshot (Ctrl-G)
-STR_02D9_ABOUT_OPENTTD                                          :About 'OpenTTD'
-############ range ends here
-
-STR_02DB_OFF                                                    :{BLACK}Off
-STR_02DA_ON                                                     :{BLACK}On
-STR_02DC_DISPLAY_SUBSIDIES                                      :{BLACK}Display subsidies
-STR_02DD_SUBSIDIES                                              :Subsidies
-STR_02DE_MAP_OF_WORLD                                           :Map of world
-STR_EXTRA_VIEW_PORT                                             :Extra viewport
-STR_SIGN_LIST                                                   :Sign list
-STR_02DF_TOWN_DIRECTORY                                         :Town directory
-STR_TOWN_POPULATION                                             :{BLACK}World population: {COMMA}
-STR_EXTRA_VIEW_PORT_TITLE                                       :{WHITE}Viewport {COMMA}
-STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN                                :{BLACK}Copy to viewport
-STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN_TT                             :{BLACK}Copy the location of the global view to this viewport
-STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW                                :{BLACK}Paste from viewport
-STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT                             :{BLACK}Paste the location of this viewport to the global view
-
-STR_02E0_CURRENCY_UNITS                                         :{BLACK}Currency units
-STR_02E1                                                        :{BLACK}{SKIP}{STRING}
-STR_02E2_CURRENCY_UNITS_SELECTION                               :{BLACK}Currency units selection
-STR_MEASURING_UNITS                                             :{BLACK}Measuring units
-STR_02E4                                                        :{BLACK}{SKIP}{SKIP}{STRING}
-STR_MEASURING_UNITS_SELECTION                                   :{BLACK}Measuring units selection
-STR_02E6_ROAD_VEHICLES                                          :{BLACK}Road vehicles
-STR_02E7                                                        :{BLACK}{SKIP}{SKIP}{SKIP}{STRING}
-STR_02E8_SELECT_SIDE_OF_ROAD_FOR                                :{BLACK}Select side of road for vehicles to drive on
-STR_02E9_DRIVE_ON_LEFT                                          :Drive on left
-STR_02EA_DRIVE_ON_RIGHT                                         :Drive on right
-STR_02EB_TOWN_NAMES                                             :{BLACK}Town names
-STR_02EC                                                        :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
-STR_02ED_SELECT_STYLE_OF_TOWN_NAMES                             :{BLACK}Select style of town names
-
-STR_02F4_AUTOSAVE                                               :{BLACK}Autosave
-STR_02F5                                                        :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
-STR_02F6_SELECT_INTERVAL_BETWEEN                                :{BLACK}Select interval between automatic game saves
-STR_02F7_OFF                                                    :Off
-STR_02F8_EVERY_3_MONTHS                                         :Every 3 months
-STR_02F9_EVERY_6_MONTHS                                         :Every 6 months
-STR_02FA_EVERY_12_MONTHS                                        :Every 12 months
-STR_02FB_START_A_NEW_GAME                                       :{BLACK}Start a new game
-STR_02FC_LOAD_A_SAVED_GAME                                      :{BLACK}Load a saved game
-STR_02FE_CREATE_A_CUSTOMIZED_GAME                               :{BLACK}Create a customized game world/scenario
-STR_02FF_SELECT_SINGLE_PLAYER_GAME                              :{BLACK}Select single-player game
-STR_0300_SELECT_MULTIPLAYER_GAME                                :{BLACK}Select multiplayer game of 2-8 players
-STR_0301_DISPLAY_GAME_OPTIONS                                   :{BLACK}Display game options
-STR_0302_DISPLAY_DIFFICULTY_OPTIONS                             :{BLACK}Display difficulty options
-STR_0303_START_A_NEW_GAME_USING                                 :{BLACK}Start a new game, using a customized scenario
-STR_0304_QUIT                                                   :{BLACK}Quit
-STR_0305_QUIT_OPENTTD                                           :{BLACK}Quit 'OpenTTD'
-STR_0307_OPENTTD                                                :{WHITE}OpenTTD {REV}
-STR_030D_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...can only be built in towns
-STR_030E_SELECT_TEMPERATE_LANDSCAPE                             :{BLACK}Select 'temperate' landscape style
-STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE                            :{BLACK}Select 'sub-arctic' landscape style
-STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE                          :{BLACK}Select 'sub-tropical' landscape style
-STR_0311_SELECT_TOYLAND_LANDSCAPE                               :{BLACK}Select 'toyland' landscape style
-STR_0312_FUND_CONSTRUCTION_OF_NEW                               :{BLACK}Fund construction of new industry
-
-############ range for menu starts
-STR_INDUSTRY_DIR                                                :Industry Directory
-STR_0313_FUND_NEW_INDUSTRY                                      :Fund new industry
-############ range ends here
-
-STR_0314_FUND_NEW_INDUSTRY                                      :{WHITE}Fund new industry
-STR_JUST_STRING                                                 :{STRING}
-STR_JUST_INT                                                    :{NUM}
-STR_0316_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...can only be built in towns
-STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST                        :{WHITE}...can only be built in rainforest areas
-STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT                            :{WHITE}...can only be built in desert areas
-STR_0319_PAUSED                                                 :{YELLOW}* *  PAUSED  *  *
-
-STR_031B_SCREENSHOT_SUCCESSFULLY                                :{WHITE}Screenshot successfully saved as '{STRING}'
-STR_031C_SCREENSHOT_FAILED                                      :{WHITE}Screenshot failed!
-
-STR_0329_PURCHASE_LAND_FOR_FUTURE                               :{BLACK}Purchase land for future use
-STR_032F_AUTOSAVE                                               :{RED}AUTOSAVE
-STR_SAVING_GAME                                                 :{RED}*  *  SAVING GAME  *  *
-STR_SAVE_STILL_IN_PROGRESS                                      :{WHITE}Saving still in progress,{}please wait until it is finished!
-STR_0330_SELECT_EZY_STREET_STYLE                                :{BLACK}Select 'Ezy Street style music' program
-
-STR_0335_6                                                      :{BLACK}6
-STR_0336_7                                                      :{BLACK}7
-
-############ start of townname region
-STR_TOWNNAME_ORIGINAL_ENGLISH                                   :English (Original)
-STR_TOWNNAME_FRENCH                                             :French
-STR_TOWNNAME_GERMAN                                             :German
-STR_TOWNNAME_ADDITIONAL_ENGLISH                                 :English (Additional)
-STR_TOWNNAME_LATIN_AMERICAN                                     :Latin-American
-STR_TOWNNAME_SILLY                                              :Silly
-STR_TOWNNAME_SWEDISH                                            :Swedish
-STR_TOWNNAME_DUTCH                                              :Dutch
-STR_TOWNNAME_FINNISH                                            :Finnish
-STR_TOWNNAME_POLISH                                             :Polish
-STR_TOWNNAME_SLOVAKISH                                          :Slovakish
-STR_TOWNNAME_NORWEGIAN                                          :Norwegian
-STR_TOWNNAME_HUNGARIAN                                          :Hungarian
-STR_TOWNNAME_AUSTRIAN                                           :Austrian
-STR_TOWNNAME_ROMANIAN                                           :Romanian
-STR_TOWNNAME_CZECH                                              :Czech
-STR_TOWNNAME_SWISS                                              :Swiss
-STR_TOWNNAME_DANISH                                             :Danish
-STR_TOWNNAME_TURKISH                                            :Turkish
-STR_TOWNNAME_ITALIAN                                            :Italian
-STR_TOWNNAME_CATALAN                                            :Catalan
-############ end of townname region
-
-STR_CURR_GBP                                                    :Pounds (£)
-STR_CURR_USD                                                    :Dollars ($)
-STR_CURR_EUR                                                    :Euro (€)
-STR_CURR_YEN                                                    :Yen (¥)
-STR_CURR_ATS                                                    :Austrian Shilling (ATS)
-STR_CURR_BEF                                                    :Belgian Franc (BEF)
-STR_CURR_CHF                                                    :Swiss Franc (CHF)
-STR_CURR_CZK                                                    :Czech Koruna (CZK)
-STR_CURR_DEM                                                    :Deutschmark (DEM)
-STR_CURR_DKK                                                    :Danish Krone (DKK)
-STR_CURR_ESP                                                    :Peseta (ESP)
-STR_CURR_FIM                                                    :Finnish Markka (FIM)
-STR_CURR_FRF                                                    :Franc (FRF)
-STR_CURR_GRD                                                    :Greek Drachma (GRD)
-STR_CURR_HUF                                                    :Hungarian Forint (HUF)
-STR_CURR_ISK                                                    :Icelandic Krona (ISK)
-STR_CURR_ITL                                                    :Italian Lira (ITL)
-STR_CURR_NLG                                                    :Dutch Guilder (NLG)
-STR_CURR_NOK                                                    :Norwegian Krone (NOK)
-STR_CURR_PLN                                                    :Polish Zloty (PLN)
-STR_CURR_ROL                                                    :Romanian Leu (ROL)
-STR_CURR_RUR                                                    :Russian Rubel (RUR)
-STR_CURR_SIT                                                    :Slovenian Tolar (SIT)
-STR_CURR_SEK                                                    :Swedish Krona (SEK)
-STR_CURR_YTL                                                    :Turkish Lira (YTL)
-STR_CURR_SKK                                                    :Slovak Koruna (SKK)
-STR_CURR_BRR                                                    :Brazilian Real (BRL)
-
-STR_CURR_CUSTOM                                                 :Custom...
-
-STR_OPTIONS_LANG                                                :{BLACK}Language
-STR_OPTIONS_LANG_CBO                                            :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
-STR_OPTIONS_LANG_TIP                                            :{BLACK}Select the interface language to use
-
-STR_OPTIONS_FULLSCREEN                                          :{BLACK}Fullscreen
-STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Check this box to play OpenTTD fullscreen mode
-
-STR_OPTIONS_RES                                                 :{BLACK}Screen resolution
-STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
-STR_OPTIONS_RES_TIP                                             :{BLACK}Select the screen resolution to use
-
-STR_OPTIONS_SCREENSHOT_FORMAT                                   :{BLACK}Screenshot format
-STR_OPTIONS_SCREENSHOT_FORMAT_CBO                               :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
-STR_OPTIONS_SCREENSHOT_FORMAT_TIP                               :{BLACK}Select the screenshot format to use
-
-STR_AUTOSAVE_1_MONTH                                            :Every month
-STR_AUTOSAVE_FAILED                                             :{WHITE}Autosave failed
-
-STR_MONTH_JAN                                                   :January
-STR_MONTH_FEB                                                   :February
-STR_MONTH_MAR                                                   :March
-STR_MONTH_APR                                                   :April
-STR_MONTH_MAY                                                   :May
-STR_MONTH_JUN                                                   :June
-STR_MONTH_JUL                                                   :July
-STR_MONTH_AUG                                                   :August
-STR_MONTH_SEP                                                   :September
-STR_MONTH_OCT                                                   :October
-STR_MONTH_NOV                                                   :November
-STR_MONTH_DEC                                                   :December
-
-STR_HEADING_FOR_STATION                                         :{LTBLUE}Heading for {STATION}
-STR_HEADING_FOR_STATION_VEL                                     :{LTBLUE}Heading for {STATION}, {VELOCITY}
-STR_NO_ORDERS                                                   :{LTBLUE}No orders
-STR_NO_ORDERS_VEL                                               :{LTBLUE}No orders, {VELOCITY}
-
-STR_PASSENGERS                                                  :passengers
-STR_BAGS                                                        :bags
-STR_TONS                                                        :tonnes
-STR_LITERS                                                      :liters
-STR_ITEMS                                                       :items
-STR_CRATES                                                      :crates
-STR_RES_OTHER                                                   :other
-STR_NOTHING                                                     :
-
-STR_SMALL_RIGHT_ARROW                                           :{TINYFONT}{RIGHTARROW}
-
-STR_CANT_SHARE_ORDER_LIST                                       :{WHITE}Can't share order list...
-STR_CANT_COPY_ORDER_LIST                                        :{WHITE}Can't copy order list...
-STR_END_OF_SHARED_ORDERS                                        :{SETX 10}- - End of Shared Orders - -
-
-STR_TRAIN_IS_LOST                                               :{WHITE}Train {COMMA} is lost.
-STR_TRAIN_IS_UNPROFITABLE                                       :{WHITE}Train {COMMA}'s profit last year was {CURRENCY}
-STR_EURO_INTRODUCE                                              :{BLACK}{BIGFONT}European Monetary Union!{}{}The Euro is introduced as the sole currency for everyday transactions in your country!
-
-# Start of order review system.
-# DON'T ADD OR REMOVE LINES HERE
-STR_TRAIN_HAS_TOO_FEW_ORDERS                                    :{WHITE}Train {COMMA} has too few orders in the schedule
-STR_TRAIN_HAS_VOID_ORDER                                        :{WHITE}Train {COMMA} has a void order
-STR_TRAIN_HAS_DUPLICATE_ENTRY                                   :{WHITE}Train {COMMA} has duplicate orders
-STR_TRAIN_HAS_INVALID_ENTRY                                     :{WHITE}Train {COMMA} has an invalid station in its orders
-STR_ROADVEHICLE_HAS_TOO_FEW_ORDERS                              :{WHITE}Road Vehicle {COMMA} has too few orders in the schedule
-STR_ROADVEHICLE_HAS_VOID_ORDER                                  :{WHITE}Road Vehicle {COMMA} has a void order
-STR_ROADVEHICLE_HAS_DUPLICATE_ENTRY                             :{WHITE}Road Vehicle {COMMA} has duplicate orders
-STR_ROADVEHICLE_HAS_INVALID_ENTRY                               :{WHITE}Road Vehicle {COMMA} has an invalid station in its orders
-STR_SHIP_HAS_TOO_FEW_ORDERS                                     :{WHITE}Ship {COMMA} has too few orders in the schedule
-STR_SHIP_HAS_VOID_ORDER                                         :{WHITE}Ship {COMMA} has a void order
-STR_SHIP_HAS_DUPLICATE_ENTRY                                    :{WHITE}Ship {COMMA} has duplicate orders
-STR_SHIP_HAS_INVALID_ENTRY                                      :{WHITE}Ship {COMMA} has an invalid station in its orders
-STR_AIRCRAFT_HAS_TOO_FEW_ORDERS                                 :{WHITE}Aircraft {COMMA} has too few orders in the schedule
-STR_AIRCRAFT_HAS_VOID_ORDER                                     :{WHITE}Aircraft {COMMA} has a void order
-STR_AIRCRAFT_HAS_DUPLICATE_ENTRY                                :{WHITE}Aircraft {COMMA} has duplicate orders
-STR_AIRCRAFT_HAS_INVALID_ENTRY                                  :{WHITE}Aircraft {COMMA} has an invalid station in its orders
-# end of order system
-
-STR_TRAIN_AUTORENEW_FAILED                                      :{WHITE}Autorenew failed on train {COMMA} (money limit)
-STR_ROADVEHICLE_AUTORENEW_FAILED                                :{WHITE}Autorenew failed on road vehicle {COMMA} (money limit)
-STR_SHIP_AUTORENEW_FAILED                                       :{WHITE}Autorenew failed on ship {COMMA} (money limit)
-STR_AIRCRAFT_AUTORENEW_FAILED                                   :{WHITE}Autorenew failed on aircraft {COMMA} (money limit)
-STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT                            :{WHITE}Train {COMMA} is too long after replacement
-
-STR_CONFIG_PATCHES                                              :{BLACK}Configure Patches
-STR_CONFIG_PATCHES_TIP                                          :{BLACK}Configure the patches
-STR_CONFIG_PATCHES_CAPTION                                      :{WHITE}Configure Patches
-
-STR_CONFIG_PATCHES_OFF                                          :Off
-STR_CONFIG_PATCHES_ON                                           :On
-STR_CONFIG_PATCHES_VEHICLESPEED                                 :{LTBLUE}Show vehicle speed in status bar: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_BUILDONSLOPES                                :{LTBLUE}Allow building on slopes and coasts: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_AUTOSLOPE                                    :{LTBLUE}Allow terraforming under buildings, tracks, etc. (autoslope): {ORANGE}{STRING}
-STR_CONFIG_PATCHES_CATCHMENT                                    :{LTBLUE}Allow more realistically sized catchment areas: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_EXTRADYNAMITE                                :{LTBLUE}Allow removal of more town-owned roads, bridges, etc: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MAMMOTHTRAINS                                :{LTBLUE}Enable building very long trains: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_REALISTICACCEL                               :{LTBLUE}Enable realistic acceleration for trains: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_FORBID_90_DEG                                :{LTBLUE}Forbid trains and ships to make 90 deg turns: {ORANGE}{STRING} {LTBLUE} (requires NPF)
-STR_CONFIG_PATCHES_JOINSTATIONS                                 :{LTBLUE}Join train stations built next to each other: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_FULLLOADANY                                  :{LTBLUE}Leave station when any cargo is full, if 'full load': {ORANGE}{STRING}
-STR_CONFIG_PATCHES_IMPROVEDLOAD                                 :{LTBLUE}Use improved loading algorithm: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_GRADUAL_LOADING                              :{LTBLUE}Load vehicles gradually: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_INFLATION                                    :{LTBLUE}Inflation: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SELECTGOODS                                  :{LTBLUE}Deliver cargo to a station only when there is a demand: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_LONGBRIDGES                                  :{LTBLUE}Allow building very long bridges: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_GOTODEPOT                                    :{LTBLUE}Allow goto depot orders: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD             :{LTBLUE}Manual primary industry construction method: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_NONE        :none
-STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_NORMAL      :as other industries
-STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_PROSPECTING :prospecting
-STR_CONFIG_PATCHES_MULTIPINDTOWN                                :{LTBLUE}Allow multiple similar industries per town: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SAMEINDCLOSE                                 :{LTBLUE}Industries of the same type can be built close to each other: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_LONGDATE                                     :{LTBLUE}Always show long date in the status bar: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SIGNALSIDE                                   :{LTBLUE}Show signals on the drive side: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SHOWFINANCES                                 :{LTBLUE}Show finances window at the end of the year: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_NONSTOP                                  :{LTBLUE}TTDPatch compatible nonstop handling: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ROADVEH_QUEUE                                :{LTBLUE}Road vehicle queueing (with quantum effects): {ORANGE}{STRING}
-STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Pan window when mouse is at the edge: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Allow bribing of the local authority: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Allow buying exclusive transport rights: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Allow sending money to other companies: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Nonuniform stations: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}New global pathfinding (NPF, overrides NTP): {ORANGE}{STRING}
-STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Weight multiplier for freight to simulate heavy trains: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Allow drive-through road stops on town owned roads: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Allow building adjacent stations: {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_SMALL_AIRPORTS                               :{LTBLUE}Always allow small airports: {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_WARN_LOST_TRAIN                              :{LTBLUE}Warn if train is lost: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ORDER_REVIEW                                 :{LTBLUE}Review vehicles' orders: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ORDER_REVIEW_OFF                             :no
-STR_CONFIG_PATCHES_ORDER_REVIEW_EXDEPOT                         :yes, but exclude stopped vehicles
-STR_CONFIG_PATCHES_ORDER_REVIEW_ON                              :of all vehicles
-STR_CONFIG_PATCHES_WARN_INCOME_LESS                             :{LTBLUE}Warn if a train's income is negative: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES                        :{LTBLUE}Vehicles never expire: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_AUTORENEW_VEHICLE                            :{LTBLUE}Autorenew vehicle when it gets old
-STR_CONFIG_PATCHES_AUTORENEW_MONTHS                             :{LTBLUE}Autorenew when vehice is {ORANGE}{STRING}{LTBLUE} months before/after max age
-STR_CONFIG_PATCHES_AUTORENEW_MONEY                              :{LTBLUE}Autorenew minimum needed money for renew: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ERRMSG_DURATION                              :{LTBLUE}Duration of error message: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_POPULATION_IN_LABEL                          :{LTBLUE}Show town population in the town name label: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_INVISIBLE_TREES                              :{LTBLUE}Invisible trees (with transparent buildings): {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_LAND_GENERATOR                               :{LTBLUE}Land generator: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_LAND_GENERATOR_ORIGINAL                      :Original
-STR_CONFIG_PATCHES_LAND_GENERATOR_TERRA_GENESIS                 :TerraGenesis
-STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE                        :{LTBLUE}Oil Refineries' max distance from edge of map {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SNOWLINE_HEIGHT                              :{LTBLUE}Snow line height: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN                         :{LTBLUE}Roughness of terrain (TerraGenesis only) : {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH             :Very Smooth
-STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_SMOOTH                  :Smooth
-STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_ROUGH                   :Rough
-STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_VERY_ROUGH              :Very Rough
-STR_CONFIG_PATCHES_TREE_PLACER                                  :{LTBLUE}Tree placer algorithm: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_TREE_PLACER_NONE                             :None
-STR_CONFIG_PATCHES_TREE_PLACER_ORIGINAL                         :Original
-STR_CONFIG_PATCHES_TREE_PLACER_IMPROVED                         :Improved
-STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION                           :{LTBLUE}Heightmap rotation: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE         :Anti-clockwise
-STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_CLOCKWISE                 :Clockwise
-STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT                         :{LTBLUE}The height level a flat scenario map gets: {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_STATION_SPREAD                               :{LTBLUE}Max station spread: {ORANGE}{STRING} {RED}Warning: High setting slows game
-STR_CONFIG_PATCHES_SERVICEATHELIPAD                             :{LTBLUE}Service helicopters at helipads automatically: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR                       :{LTBLUE}Link landscape toolbar to rail/road/water/airport toolbars: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_REVERSE_SCROLLING                            :{LTBLUE}Reverse scroll direction: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SMOOTH_SCROLLING                             :{LTBLUE}Smooth viewport scrolling: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MEASURE_TOOLTIP                              :{LTBLUE}Show a measurement tooltip when using various build-tools: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_LIVERIES                                     :{LTBLUE}Show company liveries: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_LIVERIES_NONE                                :None
-STR_CONFIG_PATCHES_LIVERIES_OWN                                 :Own company
-STR_CONFIG_PATCHES_LIVERIES_ALL                                 :All companies
-STR_CONFIG_PATCHES_PREFER_TEAMCHAT                              :{LTBLUE}Prefer team chat with <ENTER>: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING                        :{LTBLUE}Function of scrollwheel: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SCROLLWHEEL_ZOOM                             :Zoom map
-STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLL                           :Scroll map
-STR_CONFIG_PATCHES_SCROLLWHEEL_OFF                              :Off
-STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER                       :{LTBLUE}Map scrollwheel speed: {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU                          :{LTBLUE}Right-click emulation: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_COMMAND                  :Command-click
-STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_CONTROL                  :Control-click
-STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF                      :Off
-
-STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME                            :{LTBLUE}Automatically pause when starting a new game: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS                       :{LTBLUE}Use the advanced vehicle list: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF                   :Off
-STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OWN                   :Own company
-STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_ALL                   :All companies
-STR_CONFIG_PATCHES_LOADING_INDICATORS                           :{LTBLUE}Use loading indicators: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_LOADING_INDICATORS_OFF                       :Off
-STR_CONFIG_PATCHES_LOADING_INDICATORS_OWN                       :Own company
-STR_CONFIG_PATCHES_LOADING_INDICATORS_ALL                       :All companies
-STR_CONFIG_PATCHES_TIMETABLE_ALLOW                              :{LTBLUE}Enable timetabling for vehicles: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS                           :{LTBLUE}Show timetable in ticks rather than days: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}Default rail type (after new game/game load): {ORANGE}{STRING}
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_RAIL                       :Normal Rail
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_ELRAIL                     :Electrified Rail
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MONORAIL                   :Monorail
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MAGLEV                     :Maglev
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_FIRST                      :First available
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_LAST                       :Last available
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MOST_USED                  :Most used
-
-STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE                  :{LTBLUE}Show building tools when no suitable vehicles are available: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MAX_TRAINS                                   :{LTBLUE}Max trains per player: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MAX_ROADVEH                                  :{LTBLUE}Max road vehicles per player: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MAX_AIRCRAFT                                 :{LTBLUE}Max aircraft per player: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MAX_SHIPS                                    :{LTBLUE}Max ships per player: {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_AI_BUILDS_TRAINS                             :{LTBLUE}Disable trains for computer: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH                            :{LTBLUE}Disable road vehicles for computer: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT                           :{LTBLUE}Disable aircraft for computer: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_AI_BUILDS_SHIPS                              :{LTBLUE}Disable ships for computer: {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_AINEW_ACTIVE                                 :{LTBLUE}Enable new AI (alpha): {ORANGE}{STRING}
-STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER                            :{LTBLUE}Allow AIs in multiplayer (experimental): {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_SERVINT_TRAINS                               :{LTBLUE}Default service interval for trains: {ORANGE}{STRING} days/%
-STR_CONFIG_PATCHES_SERVINT_TRAINS_DISABLED                      :{LTBLUE}Default service interval for trains: {ORANGE}disabled
-STR_CONFIG_PATCHES_SERVINT_ROADVEH                              :{LTBLUE}Default service interval for road vehicles: {ORANGE}{STRING} days/%
-STR_CONFIG_PATCHES_SERVINT_ROADVEH_DISABLED                     :{LTBLUE}Default service interval for road vehicles: {ORANGE}disabled
-STR_CONFIG_PATCHES_SERVINT_AIRCRAFT                             :{LTBLUE}Default service interval for aircraft: {ORANGE}{STRING} days/%
-STR_CONFIG_PATCHES_SERVINT_AIRCRAFT_DISABLED                    :{LTBLUE}Default service interval for aircraft: {ORANGE}disabled
-STR_CONFIG_PATCHES_SERVINT_SHIPS                                :{LTBLUE}Default service interval for ships: {ORANGE}{STRING} days/%
-STR_CONFIG_PATCHES_SERVINT_SHIPS_DISABLED                       :{LTBLUE}Default service interval for ships: {ORANGE}disabled
-STR_CONFIG_PATCHES_NOSERVICE                                    :{LTBLUE}Disable servicing when breakdowns set to none: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_WAGONSPEEDLIMITS                             :{LTBLUE}Enable railroad car speed limits: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_DISABLE_ELRAILS                              :{LTBLUE}Disable electric rails: {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_COLORED_NEWS_YEAR                            :{LTBLUE}Colored news appears in: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_STARTING_YEAR                                :{LTBLUE}Starting date: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ENDING_YEAR                                  :{LTBLUE}End game in: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SMOOTH_ECONOMY                               :{LTBLUE}Enable smooth economy (more, smaller changes)
-STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Allow buying shares from other companies
-STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}When dragging place signals every: {ORANGE}{STRING} tile(s)
-STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automatically build semaphores before: {ORANGE}{STRING}
-
-STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}The town layout "no more roads" isn't valid in the scenario editor
-STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Select town-road layout: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_TOWN_LAYOUT_NO_ROADS                         :no more roads
-STR_CONFIG_PATCHES_TOWN_LAYOUT_DEFAULT                          :default
-STR_CONFIG_PATCHES_TOWN_LAYOUT_BETTER_ROADS                     :better roads
-STR_CONFIG_PATCHES_TOWN_LAYOUT_2X2_GRID                         :2x2 grid
-STR_CONFIG_PATCHES_TOWN_LAYOUT_3X3_GRID                         :3x3 grid
-
-STR_CONFIG_PATCHES_TOOLBAR_POS                                  :{LTBLUE}Position of main toolbar: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT                             :Left
-STR_CONFIG_PATCHES_TOOLBAR_POS_CENTER                           :Centre
-STR_CONFIG_PATCHES_TOOLBAR_POS_RIGHT                            :Right
-STR_CONFIG_PATCHES_SNAP_RADIUS                                  :{LTBLUE}Window snap radius: {ORANGE}{STRING} px
-STR_CONFIG_PATCHES_SNAP_RADIUS_DISABLED                         :{LTBLUE}Window snap radius: {ORANGE}disabled
-STR_CONFIG_PATCHES_TOWN_GROWTH                                  :{LTBLUE}Town growth speed: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_TOWN_GROWTH_NONE                             :None
-STR_CONFIG_PATCHES_TOWN_GROWTH_SLOW                             :Slow
-STR_CONFIG_PATCHES_TOWN_GROWTH_NORMAL                           :Normal
-STR_CONFIG_PATCHES_TOWN_GROWTH_FAST                             :Fast
-STR_CONFIG_PATCHES_TOWN_GROWTH_VERY_FAST                        :Very fast
-STR_CONFIG_PATCHES_LARGER_TOWNS                                 :{LTBLUE}Proportion of towns that will grow twice as fast: {ORANGE}1 in {STRING}
-STR_CONFIG_PATCHES_LARGER_TOWNS_DISABLED                        :{LTBLUE}Proportion of towns that will grow twice as fast: {ORANGE}None
-STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER                         :{LTBLUE}Initial city size multiplier: {ORANGE}{STRING}
-STR_CONFIG_MODIFIED_ROAD_REBUILD                                :{LTBLUE}Remove absurd road-elements during the road construction
-
-STR_CONFIG_PATCHES_GUI                                          :{BLACK}Interface
-STR_CONFIG_PATCHES_CONSTRUCTION                                 :{BLACK}Construction
-STR_CONFIG_PATCHES_VEHICLES                                     :{BLACK}Vehicles
-STR_CONFIG_PATCHES_STATIONS                                     :{BLACK}Stations
-STR_CONFIG_PATCHES_ECONOMY                                      :{BLACK}Economy
-STR_CONFIG_PATCHES_AI                                           :{BLACK}Competitors
-
-STR_CONFIG_PATCHES_DISABLED                                     :disabled
-STR_CONFIG_PATCHES_INT32                                        :{NUM}
-STR_CONFIG_PATCHES_CURRENCY                                     :{CURRENCY}
-
-STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Change setting value
-STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Some or all of the default service interval(s) below are incompatible with chosen setting! 5-90% and 30-800 days are valid
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Use YAPF for ships: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Use YAPF for roadvehs: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Use YAPF for trains: {ORANGE}{STRING}
-
-STR_TEMPERATE_LANDSCAPE                                         :Temperate landscape
-STR_SUB_ARCTIC_LANDSCAPE                                        :Sub-arctic landscape
-STR_SUB_TROPICAL_LANDSCAPE                                      :Sub-tropical landscape
-STR_TOYLAND_LANDSCAPE                                           :Toyland landscape
-
-STR_CHEATS                                                      :{WHITE}Cheats
-STR_CHEATS_TIP                                                  :{BLACK}Checkboxes indicate if you have used this cheat before
-STR_CHEATS_WARNING                                              :{BLACK}Warning! You are about to betray your fellow competitors. Keep in mind that such a disgrace will be remembered for eternity.
-STR_CHEAT_MONEY                                                 :{LTBLUE}Increase money by {CURRENCY}
-STR_CHEAT_CHANGE_PLAYER                                         :{LTBLUE}Playing as player: {ORANGE}{COMMA}
-STR_CHEAT_EXTRA_DYNAMITE                                        :{LTBLUE}Magic bulldozer (remove industries, unmovables): {ORANGE}{STRING}
-STR_CHEAT_CROSSINGTUNNELS                                       :{LTBLUE}Tunnels may cross each other: {ORANGE}{STRING}
-STR_CHEAT_BUILD_IN_PAUSE                                        :{LTBLUE}Build while in pause mode: {ORANGE}{STRING}
-STR_CHEAT_NO_JETCRASH                                           :{LTBLUE}Jetplanes will not crash (frequently) on small airports: {ORANGE} {STRING}
-STR_CHEAT_SWITCH_CLIMATE                                        :{LTBLUE}Switch climate: {ORANGE} {STRING}
-STR_CHEAT_CHANGE_DATE                                           :{LTBLUE}Change date: {ORANGE} {DATE_SHORT}
-STR_CHEAT_SETUP_PROD                                            :{LTBLUE}Enable modifying production values: {ORANGE}{STRING}
-
-STR_HEADING_FOR_WAYPOINT                                        :{LTBLUE}Heading for {WAYPOINT}
-STR_HEADING_FOR_WAYPOINT_VEL                                    :{LTBLUE}Heading for {WAYPOINT}, {VELOCITY}
-
-STR_GO_TO_WAYPOINT                                              :Go via {WAYPOINT}
-STR_GO_NON_STOP_TO_WAYPOINT                                     :Go non-stop via {WAYPOINT}
-
-STR_WAYPOINTNAME_CITY                                           :Waypoint {TOWN}
-STR_WAYPOINTNAME_CITY_SERIAL                                    :Waypoint {TOWN} #{COMMA}
-STR_LANDINFO_WAYPOINT                                           :Waypoint
-
-STR_WAYPOINT                                                    :{WHITE}Waypoint
-STR_WAYPOINT_GRAPHICS_TIP                                       :{BLACK}Select waypoint type
-
-STR_WAYPOINT_VIEWPORT                                           :{WHITE}{WAYPOINT}
-STR_WAYPOINT_VIEWPORT_TINY                                      :{TINYFONT}{WHITE}{WAYPOINT}
-STR_WAYPOINT_RAW                                                :{WAYPOINT}
-STR_EDIT_WAYPOINT_NAME                                          :{WHITE}Edit waypoint name
-
-STR_CANT_CHANGE_WAYPOINT_NAME                                   :{WHITE}Can't change waypoint name...
-STR_CONVERT_RAIL_TO_WAYPOINT_TIP                                :{BLACK}Convert rail to waypoint
-STR_CANT_BUILD_TRAIN_WAYPOINT                                   :{WHITE}Can't build train waypoint here...
-STR_CANT_REMOVE_TRAIN_WAYPOINT                                  :{WHITE}Can't remove train waypoint here...
-
-STR_BUILD_AUTORAIL_TIP                                          :{BLACK}Build railroad track using the Autorail mode
-
-STR_NO_TOWN_IN_SCENARIO                                         :{WHITE}...there is no town in this scenario
-
-STR_GENERATE_RANDOM_LANDSCAPE                                   :{WHITE}Are you sure you want to create a random landscape?
-STR_MANY_RANDOM_TOWNS                                           :{BLACK}Many random towns
-STR_RANDOM_TOWNS_TIP                                            :{BLACK}Cover the map with randomly placed towns
-STR_MANY_RANDOM_INDUSTRIES                                      :Many random industries
-STR_RANDOM_INDUSTRIES_TIP                                       :{BLACK}Cover the map with randomly placed industries
-STR_CAN_T_GENERATE_INDUSTRIES                                   :{WHITE}Can't generate industries...
-
-STR_LANDSCAPING_TOOLBAR_TIP                                     :{BLACK}Open the landscaping toolbar to raise/lower land, plant trees, etc.
-STR_LANDSCAPING_TOOLBAR                                         :{WHITE}Landscaping
-STR_LEVEL_LAND_TOOLTIP                                          :{BLACK}Level land
-
-
-STR_TREES_RANDOM_TYPE                                           :{BLACK}Trees of random type
-STR_TREES_RANDOM_TYPE_TIP                                       :{BLACK}Place trees of random type
-
-STR_CANT_BUILD_CANALS                                           :{WHITE}Can't build canals here...
-STR_BUILD_CANALS_TIP                                            :{BLACK}Build canals.
-STR_LANDINFO_CANAL                                              :Canal
-
-STR_CANT_BUILD_LOCKS                                            :{WHITE}Can't build locks here...
-STR_BUILD_LOCKS_TIP                                             :{BLACK}Build locks
-STR_LANDINFO_LOCK                                               :Lock
-
-STR_BUOY_IS_IN_USE                                              :{WHITE}... buoy is in use!
-
-STR_LANDINFO_COORDS                                             :{BLACK}Co-ordinates: {LTBLUE}{NUM}x{NUM}x{NUM} ({STRING})
-
-STR_CANT_REMOVE_PART_OF_STATION                                 :{WHITE}Can't remove part of station...
-STR_CANT_CONVERT_RAIL                                           :{WHITE}Can't convert railtype here...
-STR_CONVERT_RAIL_TIP                                            :{BLACK}Convert/Upgrade the type of the rail
-
-STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP                                :{BLACK}Drag train engine here to sell the whole train
-
-STR_DRAG_DROP                                                   :{BLACK}Drag & Drop
-STR_STATION_DRAG_DROP                                           :{BLACK}Build a station with drag & drop
-STR_SELECT_STATION_CLASS_TIP                                    :{BLACK}Select a station class to display
-STR_SELECT_STATION_TYPE_TIP                                     :{BLACK}Select the station type to build
-
-STR_FAST_FORWARD                                                :{BLACK}Fast forward the game
-STR_MESSAGE_HISTORY                                             :{WHITE}Message History
-STR_MESSAGE_HISTORY_TIP                                         :{BLACK}A list of the recent news messages
-STR_MESSAGES_DISABLE_ALL                                        :{BLACK}Disable all
-STR_MESSAGES_ENABLE_ALL                                         :{BLACK}Enable all
-
-STR_CONSTRUCT_COAL_MINE_TIP                                     :{BLACK}Construct Coal Mine
-STR_CONSTRUCT_FOREST_TIP                                        :{BLACK}Plant Forest
-STR_CONSTRUCT_OIL_RIG_TIP                                       :{BLACK}Construct Oil Rig
-STR_CONSTRUCT_FARM_TIP                                          :{BLACK}Fund Farm
-STR_CONSTRUCT_COPPER_ORE_MINE_TIP                               :{BLACK}Construct Copper Ore Mine
-STR_CONSTRUCT_OIL_WELLS_TIP                                     :{BLACK}Drill for Oil
-STR_CONSTRUCT_GOLD_MINE_TIP                                     :{BLACK}Construct Gold Mine
-STR_CONSTRUCT_DIAMOND_MINE_TIP                                  :{BLACK}Construct Diamond Mine
-STR_CONSTRUCT_IRON_ORE_MINE_TIP                                 :{BLACK}Construct Iron Ore Mine
-STR_CONSTRUCT_FRUIT_PLANTATION_TIP                              :{BLACK}Fund Fruit Plantation
-STR_CONSTRUCT_RUBBER_PLANTATION_TIP                             :{BLACK}Fund Rubber Plantation
-STR_CONSTRUCT_WATER_SUPPLY_TIP                                  :{BLACK}Fund Water Supply
-STR_CONSTRUCT_COTTON_CANDY_TIP                                  :{BLACK}Plant Cotton Candy Forest
-STR_CONSTRUCT_BATTERY_FARM_TIP                                  :{BLACK}Fund Battery Farm
-STR_CONSTRUCT_COLA_WELLS_TIP                                    :{BLACK}Drill for Cola
-STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP                             :{BLACK}Fund Plastic Fountains
-STR_CONSTRUCT_BUBBLE_GENERATOR_TIP                              :{BLACK}Construct Bubble Generator
-STR_CONSTRUCT_TOFFEE_QUARRY_TIP                                 :{BLACK}Fund Toffee Quarry
-STR_CONSTRUCT_SUGAR_MINE_TIP                                    :{BLACK}Construct Sugar Mine
-
-STR_INDUSTRYDIR_CAPTION                                         :{WHITE}Industries
-STR_INDUSTRYDIR_ITEM                                            :{ORANGE}{INDUSTRY}{BLACK} ({CARGO}){YELLOW} ({COMMA}% transported)
-STR_INDUSTRYDIR_ITEM_TWO                                        :{ORANGE}{INDUSTRY}{BLACK} ({CARGO}/{CARGO}){YELLOW} ({COMMA}%/{COMMA}% transported)
-STR_INDUSTRYDIR_ITEM_NOPROD                                     :{ORANGE}{INDUSTRY}
-
-STR_INDUSTRY_TOO_CLOSE                                          :{WHITE}...too close to another industry
-
-STR_RAIL_REFIT_VEHICLE_TO_CARRY                                 :{BLACK}Refit train to carry a different cargo type
-STR_RAIL_REFIT_VEHICLE                                          :{BLACK}Refit train
-STR_RAIL_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Select type of cargo for train to carry
-STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED                             :{BLACK}Refit train to carry highlighted cargo type
-STR_RAIL_CAN_T_REFIT_VEHICLE                                    :{WHITE}Can't refit train...
-STR_CONFIG_PATCHES_SERVINT_ISPERCENT                            :{LTBLUE}Service intervals are in percents: {ORANGE}{STRING}
-STR_CONFIG_GAME_PRODUCTION                                      :{WHITE}Change production
-
-TEMP_AI_IN_PROGRESS                                             :{WHITE}Welcome to the new AI under development. If you encounter problems, take a screenshot and post it in the forum.
-TEMP_AI_ACTIVATED                                               :{WHITE}Warning: this new AI is still alpha! Currently, only trucks and busses work!
-TEMP_AI_MULTIPLAYER                                             :{WHITE}Warning: implementation is still experimental (using new AI). Please report any problems to truelight@openttd.org.
-
-############ network gui strings
-
-STR_NETWORK_MULTIPLAYER                                         :{WHITE}Multiplayer
-
-STR_NETWORK_PLAYER_NAME                                         :{BLACK}Player name:
-STR_NETWORK_ENTER_NAME_TIP                                      :{BLACK}This is the name other players will identify you by
-STR_NETWORK_CONNECTION                                          :{BLACK}Connection:
-STR_NETWORK_CONNECTION_TIP                                      :{BLACK}Choose between an internet game or a local area nework game
-
-STR_NETWORK_START_SERVER                                        :{BLACK}Start server
-STR_NETWORK_START_SERVER_TIP                                    :{BLACK}Start an own server
-
-STR_NETWORK_GAME_NAME                                           :{BLACK}Name
-STR_NETWORK_GAME_NAME_TIP                                       :{BLACK}Name of the game
-STR_NETWORK_INFO_ICONS_TIP                                      :{BLACK}Language, server version, etc.
-STR_NETWORK_CLICK_GAME_TO_SELECT                                :{BLACK}Click a game from the list to select it
-
-STR_NETWORK_FIND_SERVER                                         :{BLACK}Find server
-STR_NETWORK_FIND_SERVER_TIP                                     :{BLACK}Search network for a server
-STR_NETWORK_ADD_SERVER                                          :{BLACK}Add server
-STR_NETWORK_ADD_SERVER_TIP                                      :{BLACK}Adds a server to the list which will always be checked for running games.
-STR_NETWORK_ENTER_IP                                            :{BLACK}Enter the IP address of the server
-
-STR_NETWORK_GENERAL_ONLINE                                      :{BLACK}{COMMA}/{COMMA} - {COMMA}/{COMMA}
-STR_NETWORK_CLIENTS_CAPTION                                     :{BLACK}Clients
-STR_NETWORK_CLIENTS_CAPTION_TIP                                 :{BLACK}Clients online / clients max
-STR_NETWORK_GAME_INFO                                           :{SILVER}GAME INFO
-STR_ORANGE                                                      :{ORANGE}{STRING}
-STR_NETWORK_CLIENTS                                             :{SILVER}Clients:  {WHITE}{COMMA} / {COMMA} - {COMMA} / {COMMA}
-STR_NETWORK_LANGUAGE                                            :{SILVER}Language:  {WHITE}{STRING}
-STR_NETWORK_TILESET                                             :{SILVER}Tileset:  {WHITE}{STRING}
-STR_NETWORK_MAP_SIZE                                            :{SILVER}Map size:  {WHITE}{COMMA}x{COMMA}
-STR_NETWORK_SERVER_VERSION                                      :{SILVER}Server version:  {WHITE}{STRING}
-STR_NETWORK_SERVER_ADDRESS                                      :{SILVER}Server address:  {WHITE}{STRING} : {NUM}
-STR_NETWORK_START_DATE                                          :{SILVER}Start date:  {WHITE}{DATE_SHORT}
-STR_NETWORK_CURRENT_DATE                                        :{SILVER}Current date:  {WHITE}{DATE_SHORT}
-STR_NETWORK_PASSWORD                                            :{SILVER}Password protected!
-STR_NETWORK_SERVER_OFFLINE                                      :{SILVER}SERVER OFFLINE
-STR_NETWORK_SERVER_FULL                                         :{SILVER}SERVER FULL
-STR_NETWORK_VERSION_MISMATCH                                    :{SILVER}VERSION MISMATCH
-STR_NETWORK_GRF_MISMATCH                                        :{SILVER}NEWGRF MISMATCH
-
-STR_NETWORK_JOIN_GAME                                           :{BLACK}Join game
-
-
-STR_NETWORK_START_GAME_WINDOW                                   :{WHITE}Start new game
-
-STR_NETWORK_NEW_GAME_NAME                                       :{BLACK}Game name:
-STR_NETWORK_NEW_GAME_NAME_TIP                                   :{BLACK}The game name will be displayed to other players in the multiplayer game selection menu
-STR_NETWORK_SET_PASSWORD                                        :{BLACK}Set password
-STR_NETWORK_PASSWORD_TIP                                        :{BLACK}Protect your game with a password if you don't want other people to join it
-STR_NETWORK_SELECT_MAP                                          :{BLACK}Select a map:
-STR_NETWORK_SELECT_MAP_TIP                                      :{BLACK}Which map do you want to play?
-STR_NETWORK_LAN_INTERNET_COMBO                                  :{BLACK}{SKIP}{STRING}
-STR_NETWORK_LAN                                                 :LAN
-STR_NETWORK_INTERNET                                            :Internet
-STR_NETWORK_LAN_INTERNET                                        :LAN / Internet
-STR_NETWORK_INTERNET_ADVERTISE                                  :Internet (advertize)
-STR_NETWORK_CLIENTS_SELECT                                      :{BLACK}{SKIP}{SKIP}{NUM} client{P "" s}
-STR_NETWORK_NUMBER_OF_CLIENTS                                   :{BLACK}Maximum allowed clients:
-STR_NETWORK_NUMBER_OF_CLIENTS_TIP                               :{BLACK}Choose a maximum number of clients. Not all slots need to be filled.
-STR_NETWORK_COMPANIES_SELECT                                    :{BLACK}{SKIP}{SKIP}{SKIP}{NUM} compan{P y ies}
-STR_NETWORK_NUMBER_OF_COMPANIES                                 :{BLACK}Max companies:
-STR_NETWORK_NUMBER_OF_COMPANIES_TIP                             :{BLACK}Limit the server to a certain number of companies
-STR_NETWORK_SPECTATORS_SELECT                                   :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{NUM} spectator{P "" s}
-STR_NETWORK_NUMBER_OF_SPECTATORS                                :{BLACK}Max spectators:
-STR_NETWORK_NUMBER_OF_SPECTATORS_TIP                            :{BLACK}Limit the server to a certain number of spectators
-STR_NETWORK_LANGUAGE_SPOKEN                                     :{BLACK}Language spoken:
-STR_NETWORK_LANGUAGE_TIP                                        :{BLACK}Other players will know which language is spoken on the server.
-STR_NETWORK_LANGUAGE_COMBO                                      :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
-STR_NETWORK_START_GAME                                          :{BLACK}Start Game
-STR_NETWORK_START_GAME_TIP                                      :{BLACK}Start a new network game from a random map, or scenario
-STR_NETWORK_LOAD_GAME                                           :{BLACK}Load Game
-STR_NETWORK_LOAD_GAME_TIP                                       :{BLACK}Resume an earlier saved multiplayer game (be sure to connect as the correct player)
-
-############ Leave those lines in this order!!
-STR_NETWORK_LANG_ANY                                            :Any
-STR_NETWORK_LANG_ENGLISH                                        :English
-STR_NETWORK_LANG_GERMAN                                         :German
-STR_NETWORK_LANG_FRENCH                                         :French
-STR_NETWORK_LANG_BRAZILIAN                                      :Brazilian
-STR_NETWORK_LANG_BULGARIAN                                      :Bulgarian
-STR_NETWORK_LANG_CHINESE                                        :Chinese
-STR_NETWORK_LANG_CZECH                                          :Czech
-STR_NETWORK_LANG_DANISH                                         :Danish
-STR_NETWORK_LANG_DUTCH                                          :Dutch
-STR_NETWORK_LANG_ESPERANTO                                      :Esperanto
-STR_NETWORK_LANG_FINNISH                                        :Finnish
-STR_NETWORK_LANG_HUNGARIAN                                      :Hungarian
-STR_NETWORK_LANG_ICELANDIC                                      :Icelandic
-STR_NETWORK_LANG_ITALIAN                                        :Italian
-STR_NETWORK_LANG_JAPANESE                                       :Japanese
-STR_NETWORK_LANG_KOREAN                                         :Korean
-STR_NETWORK_LANG_LITHUANIAN                                     :Lithuanian
-STR_NETWORK_LANG_NORWEGIAN                                      :Norwegian
-STR_NETWORK_LANG_POLISH                                         :Polish
-STR_NETWORK_LANG_PORTUGUESE                                     :Portuguese
-STR_NETWORK_LANG_ROMANIAN                                       :Romanian
-STR_NETWORK_LANG_RUSSIAN                                        :Russian
-STR_NETWORK_LANG_SLOVAK                                         :Slovak
-STR_NETWORK_LANG_SLOVENIAN                                      :Slovenian
-STR_NETWORK_LANG_SPANISH                                        :Spanish
-STR_NETWORK_LANG_SWEDISH                                        :Swedish
-STR_NETWORK_LANG_TURKISH                                        :Turkish
-STR_NETWORK_LANG_UKRAINIAN                                      :Ukrainian
-############ End of leave-in-this-order
-
-STR_NETWORK_GAME_LOBBY                                          :{WHITE}Multiplayer game lobby
-
-STR_NETWORK_PREPARE_TO_JOIN                                     :{BLACK}Preparing to join:   {ORANGE}{STRING}
-STR_NETWORK_COMPANY_LIST_TIP                                    :{BLACK}A list of all companies currently in this game. You can either join one or start a
-STR_NETWORK_NEW_COMPANY                                         :{BLACK}New company
-STR_NETWORK_NEW_COMPANY_TIP                                     :{BLACK}Open a new company
-STR_NETWORK_SPECTATE_GAME                                       :{BLACK}Watch game
-STR_NETWORK_SPECTATE_GAME_TIP                                   :{BLACK}Watch the game as a spectator
-STR_NETWORK_JOIN_COMPANY                                        :{BLACK}Join company
-STR_NETWORK_JOIN_COMPANY_TIP                                    :{BLACK}Help managing this company
-STR_NETWORK_REFRESH                                             :{BLACK}Refresh server
-STR_NETWORK_REFRESH_TIP                                         :{BLACK}Refresh the server info
-
-STR_NETWORK_COMPANY_INFO                                        :{SILVER}COMPANY INFO
-
-STR_NETWORK_COMPANY_NAME                                        :{SILVER}Company name:  {WHITE}{STRING}
-STR_NETWORK_INAUGURATION_YEAR                                   :{SILVER}Inauguration:  {WHITE}{NUM}
-STR_NETWORK_VALUE                                               :{SILVER}Company value:  {WHITE}{CURRENCY}
-STR_NETWORK_CURRENT_BALANCE                                     :{SILVER}Current balance:  {WHITE}{CURRENCY}
-STR_NETWORK_LAST_YEARS_INCOME                                   :{SILVER}Last year's income:  {WHITE}{CURRENCY}
-STR_NETWORK_PERFORMANCE                                         :{SILVER}Performance:  {WHITE}{NUM}
-
-STR_NETWORK_VEHICLES                                            :{SILVER}Vehicles:  {WHITE}{NUM} {TRAIN}, {NUM} {LORRY}, {NUM} {BUS}, {NUM} {PLANE}, {NUM} {SHIP}
-STR_NETWORK_STATIONS                                            :{SILVER}Stations:  {WHITE}{NUM} {TRAIN}, {NUM} {LORRY}, {NUM} {BUS}, {NUM} {PLANE}, {NUM} {SHIP}
-STR_NETWORK_PLAYERS                                             :{SILVER}Players:  {WHITE}{STRING}
-
-STR_NETWORK_CONNECTING                                          :{WHITE}Connecting...
-
-############ Leave those lines in this order!!
-STR_NETWORK_CONNECTING_1                                        :{BLACK}(1/6) Connecting..
-STR_NETWORK_CONNECTING_2                                        :{BLACK}(2/6) Authorizing..
-STR_NETWORK_CONNECTING_3                                        :{BLACK}(3/6) Waiting..
-STR_NETWORK_CONNECTING_4                                        :{BLACK}(4/6) Downloading map..
-STR_NETWORK_CONNECTING_5                                        :{BLACK}(5/6) Processing data..
-STR_NETWORK_CONNECTING_6                                        :{BLACK}(6/6) Registering..
-
-STR_NETWORK_CONNECTING_SPECIAL_1                                :{BLACK}Fetching game info..
-STR_NETWORK_CONNECTING_SPECIAL_2                                :{BLACK}Fetching company info..
-############ End of leave-in-this-order
-STR_NETWORK_CONNECTING_WAITING                                  :{BLACK}{NUM} client{P "" s} in front of us
-STR_NETWORK_CONNECTING_DOWNLOADING                              :{BLACK}{NUM} / {NUM} kbytes downloaded so far
-
-STR_NETWORK_DISCONNECT                                          :{BLACK}Disconnect
-
-STR_NETWORK_GIVE_MONEY_CAPTION                                  :{WHITE}Enter the amount of money you want to give
-STR_NETWORK_NEED_GAME_PASSWORD_CAPTION                          :{WHITE}Server is protected. Enter password
-STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION                       :{WHITE}Company is protected. Enter password
-STR_NETWORK_CLIENT_LIST                                         :{WHITE}Client List
-
-STR_NETWORK_ERR_NOTAVAILABLE                                    :{WHITE} No network devices found or compiled without ENABLE_NETWORK
-STR_NETWORK_ERR_NOSERVER                                        :{WHITE} Could not find any network games
-STR_NETWORK_ERR_NOCONNECTION                                    :{WHITE} The server didn't answer the request
-STR_NETWORK_ERR_NEWGRF_MISMATCH                                 :{WHITE} Could not connect due to NewGRF mismatch
-STR_NETWORK_ERR_DESYNC                                          :{WHITE} Network-Game synchronization failed.
-STR_NETWORK_ERR_LOSTCONNECTION                                  :{WHITE} Network-Game connection lost.
-STR_NETWORK_ERR_SAVEGAMEERROR                                   :{WHITE} Could not load server-savegame.
-STR_NETWORK_ERR_SERVER_START                                    :{WHITE} Could not start the server.
-STR_NETWORK_ERR_CLIENT_START                                    :{WHITE} Could not connect.
-STR_NETWORK_ERR_TIMEOUT                                         :{WHITE} Connection #{NUM} timed out.
-STR_NETWORK_ERR_SERVER_ERROR                                    :{WHITE} We made a protocol-error and our connection is closed.
-STR_NETWORK_ERR_WRONG_REVISION                                  :{WHITE} The revision of this client does not match the revision of the server.
-STR_NETWORK_ERR_WRONG_PASSWORD                                  :{WHITE} Wrong password.
-STR_NETWORK_ERR_SERVER_FULL                                     :{WHITE} The server is full
-STR_NETWORK_ERR_SERVER_BANNED                                   :{WHITE} You are banned from this server
-STR_NETWORK_ERR_KICKED                                          :{WHITE} You are kicked out of the server
-STR_NETWORK_ERR_CHEATER                                         :{WHITE} Cheating is not allowed on this server
-
-STR_NETWORK_ERR_LEFT                                            :has left the game
-############ Leave those lines in this order!!
-STR_NETWORK_ERR_CLIENT_GENERAL                                  :general error
-STR_NETWORK_ERR_CLIENT_DESYNC                                   :desync error
-STR_NETWORK_ERR_CLIENT_SAVEGAME                                 :could not load map
-STR_NETWORK_ERR_CLIENT_CONNECTION_LOST                          :connection lost
-STR_NETWORK_ERR_CLIENT_PROTOCOL_ERROR                           :protocol error
-STR_NETWORK_ERR_CLIENT_NEWGRF_MISMATCH                          :NewGRF mismatch
-STR_NETWORK_ERR_CLIENT_NOT_AUTHORIZED                           :not authorized
-STR_NETWORK_ERR_CLIENT_NOT_EXPECTED                             :received strange packet
-STR_NETWORK_ERR_CLIENT_WRONG_REVISION                           :wrong revision
-STR_NETWORK_ERR_CLIENT_NAME_IN_USE                              :name already in use
-STR_NETWORK_ERR_CLIENT_WRONG_PASSWORD                           :wrong game-password
-STR_NETWORK_ERR_CLIENT_PLAYER_MISMATCH                          :wrong player-id in DoCommand
-STR_NETWORK_ERR_CLIENT_KICKED                                   :kicked by server
-STR_NETWORK_ERR_CLIENT_CHEATER                                  :was trying to use a cheat
-STR_NETWORK_ERR_CLIENT_SERVER_FULL                              :server full
-############ End of leave-in-this-order
-STR_NETWORK_CLIENT_JOINED                                       :has joined the game
-STR_NETWORK_GIVE_MONEY                                          :gave you some money ({CURRENCY})
-STR_NETWORK_GAVE_MONEY_AWAY                                     :you gave {STRING} some money ({CURRENCY})
-STR_NETWORK_CHAT_COMPANY_CAPTION                                :[Team] :
-STR_NETWORK_CHAT_COMPANY                                        :[Team] {STRING}: {GRAY}{STRING}
-STR_NETWORK_CHAT_TO_COMPANY                                     :[Team] To {STRING}: {GRAY}{STRING}
-STR_NETWORK_CHAT_CLIENT_CAPTION                                 :[Private] :
-STR_NETWORK_CHAT_CLIENT                                         :[Private] {STRING}: {GRAY}{STRING}
-STR_NETWORK_CHAT_TO_CLIENT                                      :[Private] To {STRING}: {GRAY}{STRING}
-STR_NETWORK_CHAT_ALL_CAPTION                                    :[All] :
-STR_NETWORK_CHAT_ALL                                            :[All] {STRING}: {GRAY}{STRING}
-STR_NETWORK_NAME_CHANGE                                         :has changed his name to
-STR_NETWORK_SERVER_SHUTDOWN                                     :{WHITE} The server closed the session
-STR_NETWORK_SERVER_REBOOT                                       :{WHITE} The server is restarting...{}Please wait...
-
-STR_NETWORK_SERVER                                              :Server
-STR_NETWORK_CLIENT                                              :Client
-STR_NETWORK_SPECTATORS                                          :Spectators
-
-STR_NETWORK_CLIENTLIST_NONE                                     :(none)
-STR_NETWORK_CLIENTLIST_KICK                                     :Kick
-STR_NETWORK_CLIENTLIST_GIVE_MONEY                               :Give money
-STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL                             :Speak to all
-STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY                         :Speak to company
-STR_NETWORK_CLIENTLIST_SPEAK_TO_CLIENT                          :Private message
-
-
-STR_NETWORK_SEND                                                :{BLACK}Send
-
-############ end network gui strings
-
-
-STR_CONFIG_PATCHES_MAP_X                                        :{LTBLUE}X-size of map: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MAP_Y                                        :{LTBLUE}Y-size of map: {ORANGE}{STRING}
-
-
-##### PNG-MAP-Loader
-
-STR_PNGMAP_ERROR                                                :{WHITE}Cannot load landscape from PNG...
-STR_PNGMAP_ERR_FILE_NOT_FOUND                                   :{WHITE}...file not found.
-STR_PNGMAP_ERR_IMAGE_TYPE                                       :{WHITE}...could not convert image type. 8 or 24-bit PNG image needed.
-STR_PNGMAP_ERR_MISC                                             :{WHITE}...something just went wrong. Sorry. (probably corrupted file)
-
-STR_BMPMAP_ERROR                                                :{WHITE}Cannot load landscape from BMP...
-STR_BMPMAP_ERR_IMAGE_TYPE                                       :{WHITE}...could not convert image type.
-
-##id 0x0800
-STR_0800_COST                                                   :{TINYFONT}{RED}Cost: {CURRENCY}
-STR_0801_COST                                                   :{RED}Cost: {CURRENCY}
-STR_0802_INCOME                                                 :{TINYFONT}{GREEN}Income: {CURRENCY}
-STR_0803_INCOME                                                 :{GREEN}Income: {CURRENCY}
-STR_FEEDER_TINY                                                 :{TINYFONT}{YELLOW}Transfer: {CURRENCY}
-STR_FEEDER                                                      :{YELLOW}Transfer: {CURRENCY}
-STR_0805_ESTIMATED_COST                                         :{WHITE}Estimated Cost: {CURRENCY}
-STR_0807_ESTIMATED_INCOME                                       :{WHITE}Estimated Income: {CURRENCY}
-STR_0808_CAN_T_RAISE_LAND_HERE                                  :{WHITE}Can't raise land here...
-STR_0809_CAN_T_LOWER_LAND_HERE                                  :{WHITE}Can't lower land here...
-STR_080A_ROCKS                                                  :Rocks
-STR_080B_ROUGH_LAND                                             :Rough land
-STR_080C_BARE_LAND                                              :Bare land
-STR_080D_GRASS                                                  :Grass
-STR_080E_FIELDS                                                 :Fields
-STR_080F_SNOW_COVERED_LAND                                      :Snow-covered land
-STR_0810_DESERT                                                 :Desert
-
-##id 0x1000
-STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION                         :{WHITE}Land sloped in wrong direction
-STR_1001_IMPOSSIBLE_TRACK_COMBINATION                           :{WHITE}Impossible track combination
-STR_1002_EXCAVATION_WOULD_DAMAGE                                :{WHITE}Excavation would damage tunnel
-STR_1003_ALREADY_AT_SEA_LEVEL                                   :{WHITE}Already at sea-level
-STR_1004_TOO_HIGH                                               :{WHITE}Too high
-STR_1005_NO_SUITABLE_RAILROAD_TRACK                             :{WHITE}No suitable railroad track
-STR_1007_ALREADY_BUILT                                          :{WHITE}...already built
-STR_1008_MUST_REMOVE_RAILROAD_TRACK                             :{WHITE}Must remove railroad track first
-STR_100A_RAILROAD_CONSTRUCTION                                  :{WHITE}Railroad Construction
-STR_TITLE_ELRAIL_CONSTRUCTION                                   :{WHITE}Electrified Railroad Construction
-STR_100B_MONORAIL_CONSTRUCTION                                  :{WHITE}Monorail Construction
-STR_100C_MAGLEV_CONSTRUCTION                                    :{WHITE}MagLev Construction
-STR_100D_SELECT_RAIL_BRIDGE                                     :{WHITE}Select Rail Bridge
-STR_100E_CAN_T_BUILD_TRAIN_DEPOT                                :{WHITE}Can't build train depot here...
-STR_100F_CAN_T_BUILD_RAILROAD_STATION                           :{WHITE}Can't build railroad station here...
-STR_1010_CAN_T_BUILD_SIGNALS_HERE                               :{WHITE}Can't build signals here...
-STR_1011_CAN_T_BUILD_RAILROAD_TRACK                             :{WHITE}Can't build railroad track here...
-STR_1012_CAN_T_REMOVE_RAILROAD_TRACK                            :{WHITE}Can't remove railroad track from here...
-STR_1013_CAN_T_REMOVE_SIGNALS_FROM                              :{WHITE}Can't remove signals from here...
-STR_1014_TRAIN_DEPOT_ORIENTATION                                :{WHITE}Train Depot Orientation
-STR_1015_RAILROAD_CONSTRUCTION                                  :Railroad construction
-STR_TOOLB_ELRAIL_CONSTRUCTION                                   :Electrified Railroad construction
-STR_1016_MONORAIL_CONSTRUCTION                                  :Monorail construction
-STR_1017_MAGLEV_CONSTRUCTION                                    :MagLev construction
-STR_1018_BUILD_RAILROAD_TRACK                                   :{BLACK}Build railroad track
-STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING                         :{BLACK}Build train depot (for building and servicing trains)
-STR_101A_BUILD_RAILROAD_STATION                                 :{BLACK}Build railroad station
-STR_101B_BUILD_RAILROAD_SIGNALS                                 :{BLACK}Build railroad signals
-STR_101C_BUILD_RAILROAD_BRIDGE                                  :{BLACK}Build railroad bridge
-STR_101D_BUILD_RAILROAD_TUNNEL                                  :{BLACK}Build railroad tunnel
-STR_101E_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Toggle build/remove for railroad track and signals
-STR_101F_BRIDGE_SELECTION_CLICK                                 :{BLACK}Bridge selection - click on your prefered bridge to build it
-STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO                       :{BLACK}Select railroad depot orientation
-STR_1021_RAILROAD_TRACK                                         :Railroad track
-STR_1023_RAILROAD_TRAIN_DEPOT                                   :Railroad train depot
-STR_1024_AREA_IS_OWNED_BY_ANOTHER                               :{WHITE}...area is owned by another company
-STR_RAILROAD_TRACK_WITH_NORMAL_SIGNALS                          :Railroad track with normal signals
-STR_RAILROAD_TRACK_WITH_PRESIGNALS                              :Railroad track with pre-signals
-STR_RAILROAD_TRACK_WITH_EXITSIGNALS                             :Railroad track with exit-signals
-STR_RAILROAD_TRACK_WITH_COMBOSIGNALS                            :Railway track with combo-signals
-STR_RAILROAD_TRACK_WITH_NORMAL_PRESIGNALS                       :Railway track with normal and pre-signals
-STR_RAILROAD_TRACK_WITH_NORMAL_EXITSIGNALS                      :Railway track with normal and exit-signals
-STR_RAILROAD_TRACK_WITH_NORMAL_COMBOSIGNALS                     :Railway track with normal and combo-signals
-STR_RAILROAD_TRACK_WITH_PRE_EXITSIGNALS                         :Railway track with pre- and exit-signals
-STR_RAILROAD_TRACK_WITH_PRE_COMBOSIGNALS                        :Railway track with pre- and combo-signals
-STR_RAILROAD_TRACK_WITH_EXIT_COMBOSIGNALS                       :Railway track with exit- and combo-signals
-STR_MUST_REMOVE_RAILWAY_STATION_FIRST                           :{WHITE}Must remove railway station first
-
-
-
-##id 0x1800
-STR_1801_MUST_REMOVE_ROAD_FIRST                                 :{WHITE}Must remove road first
-STR_ROAD_WORKS_IN_PROGRESS                                      :{WHITE}Road works in progress
-STR_1802_ROAD_CONSTRUCTION                                      :{WHITE}Road Construction
-STR_1802_TRAMWAY_CONSTRUCTION                                   :{WHITE}Tramway Construction
-STR_1803_SELECT_ROAD_BRIDGE                                     :{WHITE}Select Road Bridge
-STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION                        :{WHITE}... one way roads can't have junctions
-STR_1804_CAN_T_BUILD_ROAD_HERE                                  :{WHITE}Can't build road here...
-STR_1804_CAN_T_BUILD_TRAMWAY_HERE                               :{WHITE}Can't build tramway here...
-STR_1805_CAN_T_REMOVE_ROAD_FROM                                 :{WHITE}Can't remove road from here...
-STR_1805_CAN_T_REMOVE_TRAMWAY_FROM                              :{WHITE}Can't remove tramway from here...
-STR_1806_ROAD_DEPOT_ORIENTATION                                 :{WHITE}Road Depot Orientation
-STR_1806_TRAM_DEPOT_ORIENTATION                                 :{WHITE}Tram Depot Orientation
-STR_1807_CAN_T_BUILD_ROAD_VEHICLE                               :{WHITE}Can't build road vehicle depot here...
-STR_1807_CAN_T_BUILD_TRAM_VEHICLE                               :{WHITE}Can't build tram vehicle depot here...
-STR_1808_CAN_T_BUILD_BUS_STATION                                :{WHITE}Can't build bus station...
-STR_1809_CAN_T_BUILD_TRUCK_STATION                              :{WHITE}Can't build truck station...
-STR_1808_CAN_T_BUILD_PASSENGER_TRAM_STATION                     :{WHITE}Can't build passenger tram station...
-STR_1809_CAN_T_BUILD_CARGO_TRAM_STATION                         :{WHITE}Can't build freight tram station...
-STR_180A_ROAD_CONSTRUCTION                                      :Road construction
-STR_180A_TRAMWAY_CONSTRUCTION                                   :Tramway construction
-STR_180B_BUILD_ROAD_SECTION                                     :{BLACK}Build road section
-STR_180B_BUILD_TRAMWAY_SECTION                                  :{BLACK}Build tramway section
-STR_180C_BUILD_ROAD_VEHICLE_DEPOT                               :{BLACK}Build road vehicle depot (for building and servicing vehicles)
-STR_180C_BUILD_TRAM_VEHICLE_DEPOT                               :{BLACK}Build tram vehicle depot (for building and servicing trams)
-STR_180D_BUILD_BUS_STATION                                      :{BLACK}Build bus station
-STR_180E_BUILD_TRUCK_LOADING_BAY                                :{BLACK}Build truck loading bay
-STR_180D_BUILD_PASSENGER_TRAM_STATION                           :{BLACK}Build passenger tram station
-STR_180E_BUILD_CARGO_TRAM_STATION                               :{BLACK}Build freight tram station
-STR_180F_BUILD_ROAD_BRIDGE                                      :{BLACK}Build road bridge
-STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Build tramway bridge
-STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Build road tunnel
-STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Build tramway tunnel
-STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Toggle build/remove for road construction
-STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Toggle build/remove for tramway construction
-STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Select road vehicle depot orientation
-STR_1813_SELECT_TRAM_VEHICLE_DEPOT                              :{BLACK}Select tram vehicle depot orientation
-STR_1814_ROAD                                                   :Road
-STR_1815_ROAD_WITH_STREETLIGHTS                                 :Road with streetlights
-STR_1816_TREE_LINED_ROAD                                        :Tree-lined road
-STR_1817_ROAD_VEHICLE_DEPOT                                     :Road vehicle depot
-STR_1818_ROAD_RAIL_LEVEL_CROSSING                               :Road/rail grade crossing
-STR_CAN_T_REMOVE_BUS_STATION                                    :{WHITE}Can't remove bus station...
-STR_CAN_T_REMOVE_TRUCK_STATION                                  :{WHITE}Can't remove truck station...
-STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION                         :{WHITE}Can't remove passenger tram station...
-STR_CAN_T_REMOVE_CARGO_TRAM_STATION                             :{WHITE}Can't remove freight tram station...
-
-##id 0x2000
-STR_2000_TOWNS                                                  :{WHITE}Towns
-STR_TOWN_LABEL_POP                                              :{WHITE}{TOWN} ({COMMA})
-STR_TOWN_LABEL                                                  :{WHITE}{TOWN}
-STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
-STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
-STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
-STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Building must be demolished first
-STR_2005                                                        :{WHITE}{TOWN}
-STR_2006_POPULATION                                             :{BLACK}Population: {ORANGE}{COMMA}{BLACK}  Houses: {ORANGE}{COMMA}
-STR_2007_RENAME_TOWN                                            :Rename Town
-STR_2008_CAN_T_RENAME_TOWN                                      :{WHITE}Can't rename town...
-STR_2009_LOCAL_AUTHORITY_REFUSES                                :{WHITE}{TOWN} local authority refuses to allow this
-STR_200A_TOWN_NAMES_CLICK_ON_NAME                               :{BLACK}Town names - click on name to center view on town
-STR_200B_CENTER_THE_MAIN_VIEW_ON                                :{BLACK}Center the main view on town location
-STR_200C_CHANGE_TOWN_NAME                                       :{BLACK}Change town name
-STR_200D_PASSENGERS_LAST_MONTH_MAX                              :{BLACK}Passengers last month: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
-STR_200E_MAIL_LAST_MONTH_MAX                                    :{BLACK}Mail last month: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
-STR_200F_TALL_OFFICE_BLOCK                                      :Tall office block
-STR_2010_OFFICE_BLOCK                                           :Office block
-STR_2011_SMALL_BLOCK_OF_FLATS                                   :Small block of apartments
-STR_2012_CHURCH                                                 :Church
-STR_2013_LARGE_OFFICE_BLOCK                                     :Large office block
-STR_2014_TOWN_HOUSES                                            :Town houses
-STR_2015_HOTEL                                                  :Hotel
-STR_2016_STATUE                                                 :Statue
-STR_2017_FOUNTAIN                                               :Fountain
-STR_2018_PARK                                                   :Park
-STR_2019_OFFICE_BLOCK                                           :Office block
-STR_201A_SHOPS_AND_OFFICES                                      :Shops and offices
-STR_201B_MODERN_OFFICE_BUILDING                                 :Modern office building
-STR_201C_WAREHOUSE                                              :Warehouse
-STR_201D_OFFICE_BLOCK                                           :Office block
-STR_201E_STADIUM                                                :Stadium
-STR_201F_OLD_HOUSES                                             :Old houses
-STR_2020_LOCAL_AUTHORITY                                        :{BLACK}Local authority
-STR_2021_SHOW_INFORMATION_ON_LOCAL                              :{BLACK}Show information on local authority
-STR_2022_LOCAL_AUTHORITY                                        :{WHITE}{TOWN} local authority
-STR_2023_TRANSPORT_COMPANY_RATINGS                              :{BLACK}Transport company ratings:
-STR_2024                                                        :{YELLOW}{COMPANY} {COMPANYNUM}: {ORANGE}{STRING}
-STR_2025_SUBSIDIES                                              :{WHITE}Subsidies
-STR_2026_SUBSIDIES_ON_OFFER_FOR                                 :{BLACK}Subsidies on offer for services taking:
-STR_2027_FROM_TO                                                :{ORANGE}{STRING} from {STRING} to {STRING}
-STR_2028_BY                                                     :{YELLOW} (by {DATE_SHORT})
-STR_202A_NONE                                                   :{ORANGE}None
-STR_202B_SERVICES_ALREADY_SUBSIDISED                            :{BLACK}Services already subsidized:
-STR_202C_FROM_TO                                                :{ORANGE}{STRING} from {STATION} to {STATION}{YELLOW} ({COMPANY}
-STR_202D_UNTIL                                                  :{YELLOW}, until {DATE_SHORT})
-STR_202E_OFFER_OF_SUBSIDY_EXPIRED                               :{BLACK}{BIGFONT}Offer of subsidy expired:{}{}{STRING} from {STRING} to {STRING} will now not attract a subsidy.
-STR_202F_SUBSIDY_WITHDRAWN_SERVICE                              :{BLACK}{BIGFONT}Subsidy withdrawn:{}{}{STRING} service from {STATION} to {STATION} is no longer subsidized.
-STR_2030_SERVICE_SUBSIDY_OFFERED                                :{BLACK}{BIGFONT}Service subsidy offered:{}{}First {STRING} service from {STRING} to {STRING} will attract a year's subsidy from the local authority!
-STR_2031_SERVICE_SUBSIDY_AWARDED                                :{BLACK}{BIGFONT}Service subsidy awarded to {COMPANY}!{}{}{STRING} service from {STATION} to {STATION} will pay 50% extra for the next year!
-STR_2032_SERVICE_SUBSIDY_AWARDED                                :{BLACK}{BIGFONT}Service subsidy awarded to {COMPANY}!{}{}{STRING} service from {STATION} to {STATION} will pay double rates for the next year!
-STR_2033_SERVICE_SUBSIDY_AWARDED                                :{BLACK}{BIGFONT}Service subsidy awarded to {COMPANY}!{}{}{STRING} service from {STATION} to {STATION} will pay triple rates for the next year!
-STR_2034_SERVICE_SUBSIDY_AWARDED                                :{BLACK}{BIGFONT}Service subsidy awarded to {COMPANY}!{}{}{STRING} service from {STATION} to {STATION} will pay quadruple rates for the next year!
-STR_2035_LOCAL_AUTHORITY_REFUSES                                :{WHITE}{TOWN} local authority refuses to allow another airport to be built in this town
-STR_2036_COTTAGES                                               :Cottages
-STR_2037_HOUSES                                                 :Houses
-STR_2038_FLATS                                                  :Apartments
-STR_2039_TALL_OFFICE_BLOCK                                      :Tall office block
-STR_203A_SHOPS_AND_OFFICES                                      :Shops and offices
-STR_203B_SHOPS_AND_OFFICES                                      :Shops and offices
-STR_203C_THEATER                                                :Theater
-STR_203D_STADIUM                                                :Stadium
-STR_203E_OFFICES                                                :Offices
-STR_203F_HOUSES                                                 :Houses
-STR_2040_CINEMA                                                 :Cinema
-STR_2041_SHOPPING_MALL                                          :Shopping mall
-STR_2042_DO_IT                                                  :{BLACK}Do it
-STR_2043_LIST_OF_THINGS_TO_DO_AT                                :{BLACK}List of things to do at this town - click on item for more details
-STR_2044_CARRY_OUT_THE_HIGHLIGHTED                              :{BLACK}Carry out the highlighted action in the list above
-STR_2045_ACTIONS_AVAILABLE                                      :{BLACK}Actions available:
-STR_2046_SMALL_ADVERTISING_CAMPAIGN                             :Small advertising campaign
-STR_2047_MEDIUM_ADVERTISING_CAMPAIGN                            :Medium advertising campaign
-STR_2048_LARGE_ADVERTISING_CAMPAIGN                             :Large advertising campaign
-STR_2049_FUND_LOCAL_ROAD_RECONSTRUCTION                         :Fund local road reconstruction
-STR_204A_BUILD_STATUE_OF_COMPANY                                :Build statue of company owner
-STR_204B_FUND_NEW_BUILDINGS                                     :Fund new buildings
-STR_204C_BUY_EXCLUSIVE_TRANSPORT                                :Buy exclusive transport rights
-STR_TOWN_BRIBE_THE_LOCAL_AUTHORITY                              :Bribe the local authority
-STR_204D_INITIATE_A_SMALL_LOCAL                                 :{WHITE}{STRING}{}{YELLOW} Initiate a small local advertising campaign, to attract more passengers and cargo to your transport services.{}  Cost: {CURRENCY}
-STR_204E_INITIATE_A_MEDIUM_LOCAL                                :{WHITE}{STRING}{}{YELLOW} Initiate a medium local advertising campaign, to attract more passengers and cargo to your transport services.{}  Cost: {CURRENCY}
-STR_204F_INITIATE_A_LARGE_LOCAL                                 :{WHITE}{STRING}{}{YELLOW} Initiate a large local advertising campaign, to attract more passengers and cargo to your transport services.{}  Cost: {CURRENCY}
-STR_2050_FUND_THE_RECONSTRUCTION                                :{WHITE}{STRING}{}{YELLOW} Fund the reconstruction of the urban road network. Causes considerable disruption to road traffic for up to 6 months.{}  Cost: {CURRENCY}
-STR_2051_BUILD_A_STATUE_IN_HONOR                                :{WHITE}{STRING}{}{YELLOW} Build a statue in honor of your company.{} Cost: {CURRENCY}
-STR_2052_FUND_THE_CONSTRUCTION_OF                               :{WHITE}{STRING}{}{YELLOW} Fund the construction of new commercial buildings in the town.{}  Cost: {CURRENCY}
-STR_2053_BUY_1_YEAR_S_EXCLUSIVE                                 :{WHITE}{STRING}{}{YELLOW} Buy 1 year's exclusive transport rights in town. Town authority will only allow passengers and cargo to use your company's stations.{} Cost: {CURRENCY}
-STR_TOWN_BRIBE_THE_LOCAL_AUTHORITY_DESC                         :{WHITE}{STRING}{}{YELLOW} Bribe the local authority to increase your rating, at the risk of a severe penalty if caught.{}  Cost: {CURRENCY}
-STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING                       :{BIGFONT}{BLACK}Traffic chaos in {TOWN}!{}{}Road rebuilding program funded by {COMPANY} brings 6 months of misery to motorists!
-STR_2056                                                        :{TINYFONT}{WHITE}{TOWN}
-STR_2057                                                        :{ORANGE}{TOWN}{BLACK} ({COMMA})
-STR_2058_UNDER_CONSTRUCTION                                     :{STRING} (under construction)
-STR_2059_IGLOO                                                  :Igloo
-STR_205A_TEPEES                                                 :Tepees
-STR_205B_TEAPOT_HOUSE                                           :Teapot-House
-STR_205C_PIGGY_BANK                                             :Piggy-Bank
-
-STR_INDUSTRY                                                    :{INDUSTRY}
-STR_TOWN                                                        :{TOWN}
-STR_INDUSTRY_FORMAT                                             :{TOWN} {STRING}
-STR_STATION                                                     :{STATION}
-
-##id 0x2800
-STR_LANDSCAPING                                                 :Landscaping
-STR_2800_PLANT_TREES                                            :Plant trees
-STR_2801_PLACE_SIGN                                             :Place sign
-STR_2802_TREES                                                  :{WHITE}Trees
-STR_2803_TREE_ALREADY_HERE                                      :{WHITE}...tree already here
-STR_2804_SITE_UNSUITABLE                                        :{WHITE}...site unsuitable
-STR_2805_CAN_T_PLANT_TREE_HERE                                  :{WHITE}Can't plant tree here...
-STR_2806                                                        :{WHITE}{SIGN}
-STR_2808_TOO_MANY_SIGNS                                         :{WHITE}...too many signs
-STR_2809_CAN_T_PLACE_SIGN_HERE                                  :{WHITE}Can't place sign here...
-STR_280A_SIGN                                                   :Sign
-STR_280B_EDIT_SIGN_TEXT                                         :{WHITE}Edit sign text
-STR_280C_CAN_T_CHANGE_SIGN_NAME                                 :{WHITE}Can't change sign name...
-STR_280D_SELECT_TREE_TYPE_TO_PLANT                              :{BLACK}Select tree type to plant
-STR_280E_TREES                                                  :Trees
-STR_280F_RAINFOREST                                             :Rainforest
-STR_2810_CACTUS_PLANTS                                          :Cactuses
-
-##id 0x3000
-STR_3000_RAIL_STATION_SELECTION                                 :{WHITE}Rail Station Selection
-STR_3001_AIRPORT_SELECTION                                      :{WHITE}Airport Selection
-STR_3002_ORIENTATION                                            :{BLACK}Orientation
-STR_3003_NUMBER_OF_TRACKS                                       :{BLACK}Number of tracks
-STR_3004_PLATFORM_LENGTH                                        :{BLACK}Platform length
-STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD                          :{WHITE}Too close to another railroad station
-STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING                         :{WHITE}Adjoins more than one existing station/loading area
-STR_3007_TOO_MANY_STATIONS_LOADING                              :{WHITE}Too many stations/loading areas in this town
-STR_3008_TOO_MANY_STATIONS_LOADING                              :{WHITE}Too many stations/loading areas
-STR_3008A_TOO_MANY_BUS_STOPS                                    :{WHITE}Too many bus stops
-STR_3008B_TOO_MANY_TRUCK_STOPS                                  :{WHITE}Too many truck stations
-STR_3009_TOO_CLOSE_TO_ANOTHER_STATION                           :{WHITE}Too close to another station/loading area
-STR_300A_0                                                      :{WHITE}{STATION} {STATIONFEATURES}
-STR_300B_MUST_DEMOLISH_RAILROAD                                 :{WHITE}Must demolish railroad station first
-STR_300D_TOO_CLOSE_TO_ANOTHER_AIRPORT                           :{WHITE}Too close to another airport
-STR_300E_MUST_DEMOLISH_AIRPORT_FIRST                            :{WHITE}Must demolish airport first
-
-STR_3030_RENAME_STATION_LOADING                                 :Rename station/loading area
-STR_3031_CAN_T_RENAME_STATION                                   :{WHITE}Can't rename station...
-STR_3032_RATINGS                                                :{BLACK}Ratings
-STR_3033_ACCEPTS                                                :{BLACK}Accepts
-STR_3034_LOCAL_RATING_OF_TRANSPORT                              :{BLACK}Local rating of transport service:
-
-############ range for rating starts
-STR_3035_APPALLING                                              :Appalling
-STR_3036_VERY_POOR                                              :Very Poor
-STR_3037_POOR                                                   :Poor
-STR_3038_MEDIOCRE                                               :Mediocre
-STR_3039_GOOD                                                   :Good
-STR_303A_VERY_GOOD                                              :Very Good
-STR_303B_EXCELLENT                                              :Excellent
-STR_303C_OUTSTANDING                                            :Outstanding
-############ range for rating ends
-
-STR_303D                                                        :{WHITE}{STRING}: {YELLOW}{STRING} ({COMMA}%)
-STR_303E_NO_LONGER_ACCEPTS                                      :{WHITE}{STATION} no longer accepts {STRING}
-STR_303F_NO_LONGER_ACCEPTS_OR                                   :{WHITE}{STATION} no longer accepts {STRING} or {STRING}
-STR_3040_NOW_ACCEPTS                                            :{WHITE}{STATION} now accepts {STRING}
-STR_3041_NOW_ACCEPTS_AND                                        :{WHITE}{STATION} now accepts {STRING} and {STRING}
-STR_3042_BUS_STATION_ORIENTATION                                :{WHITE}Bus Station Orientation
-STR_3043_TRUCK_STATION_ORIENT                                   :{WHITE}Truck Station Orient.
-STR_3042_PASSENGER_TRAM_STATION_ORIENTATION                     :{WHITE}Passenger Tram Orientation
-STR_3043_CARGO_TRAM_STATION_ORIENT                              :{WHITE}Freight Tram Orientation
-STR_3046_MUST_DEMOLISH_BUS_STATION                              :{WHITE}Must demolish bus station first
-STR_3047_MUST_DEMOLISH_TRUCK_STATION                            :{WHITE}Must demolish truck station first
-STR_3046_MUST_DEMOLISH_PASSENGER_TRAM_STATION                   :{WHITE}Must demolish passenger tram station first
-STR_3047_MUST_DEMOLISH_CARGO_TRAM_STATION                       :{WHITE}Must demolish freight tram station first
-STR_3048_STATIONS                                               :{WHITE}{COMPANY} - {COMMA} Station{P "" s}
-STR_3049_0                                                      :{YELLOW}{STATION} {STATIONFEATURES}
-STR_304A_NONE                                                   :{YELLOW}- None -
-STR_304B_SITE_UNSUITABLE                                        :{WHITE}...site unsuitable
-STR_304C_TOO_CLOSE_TO_ANOTHER_DOCK                              :{WHITE}Too close to another dock
-STR_304D_MUST_DEMOLISH_DOCK_FIRST                               :{WHITE}Must demolish dock first
-STR_304E_SELECT_RAILROAD_STATION                                :{BLACK}Select railroad station orientation
-STR_304F_SELECT_NUMBER_OF_PLATFORMS                             :{BLACK}Select number of platforms for railroad station
-STR_3050_SELECT_LENGTH_OF_RAILROAD                              :{BLACK}Select length of railroad station
-STR_3051_SELECT_BUS_STATION_ORIENTATION                         :{BLACK}Select bus station orientation
-STR_3052_SELECT_TRUCK_LOADING_BAY                               :{BLACK}Select truck loading bay orientation
-STR_3051_SELECT_PASSENGER_TRAM_STATION_ORIENTATION              :{BLACK}Select passenger tram station orientation
-STR_3052_SELECT_CARGO_TRAM_STATION_ORIENTATION                  :{BLACK}Select freight tram station orientation
-STR_3053_CENTER_MAIN_VIEW_ON_STATION                            :{BLACK}Center main view on station location
-STR_3054_SHOW_STATION_RATINGS                                   :{BLACK}Show station ratings
-STR_3055_CHANGE_NAME_OF_STATION                                 :{BLACK}Change name of station
-STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO                            :{BLACK}Show list of accepted cargo
-STR_3057_STATION_NAMES_CLICK_ON                                 :{BLACK}Station names - click on name to center main view on station
-STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT                            :{BLACK}Select size/type of airport
-STR_305C_0                                                      :{STATION} {STATIONFEATURES}
-STR_STATION_SIGN_TINY                                           :{TINYFONT}{STATION}
-STR_305E_RAILROAD_STATION                                       :Railroad station
-STR_305F_AIRCRAFT_HANGAR                                        :Aircraft hangar
-STR_3060_AIRPORT                                                :Airport
-STR_3061_TRUCK_LOADING_AREA                                     :Truck loading area
-STR_3062_BUS_STATION                                            :Bus station
-STR_3063_SHIP_DOCK                                              :Ship dock
-STR_3064_HIGHLIGHT_COVERAGE_AREA                                :{BLACK}Highlight coverage area of proposed site
-STR_3065_DON_T_HIGHLIGHT_COVERAGE                               :{BLACK}Don't highlight coverage area of proposed site
-STR_3066_COVERAGE_AREA_HIGHLIGHT                                :{BLACK}Coverage area highlight
-STR_3068_DOCK                                                   :{WHITE}Dock
-STR_3069_BUOY                                                   :Buoy
-STR_306A_BUOY_IN_THE_WAY                                        :{WHITE}...buoy in the way
-STR_306C_STATION_TOO_SPREAD_OUT                                 :{WHITE}...station too spread out
-STR_306D_NONUNIFORM_STATIONS_DISALLOWED                         :{WHITE}...nonuniform stations disabled
-STR_USE_CTRL_TO_SELECT_MORE                                     :{BLACK}Hold down CTRL to select more than one item
-
-STR_UNDEFINED                                                   :(undefined string)
-STR_STAT_CLASS_DFLT                                             :Default station
-STR_STAT_CLASS_WAYP                                             :Waypoints
-
-##id 0x3800
-STR_3800_SHIP_DEPOT_ORIENTATION                                 :{WHITE}Ship Depot Orientation
-STR_3801_MUST_BE_BUILT_ON_WATER                                 :{WHITE}...must be built on water
-STR_3802_CAN_T_BUILD_SHIP_DEPOT                                 :{WHITE}Can't build ship depot here...
-STR_3803_SELECT_SHIP_DEPOT_ORIENTATION                          :{BLACK}Select ship depot orientation
-STR_3804_WATER                                                  :Water
-STR_3805_COAST_OR_RIVERBANK                                     :Coast or riverbank
-STR_3806_SHIP_DEPOT                                             :Ship depot
-STR_3807_CAN_T_BUILD_ON_WATER                                   :{WHITE}...Can't build on water
-STR_MUST_DEMOLISH_CANAL_FIRST                                   :{WHITE}Must demolish canal first
-
-##id 0x4000
-STR_4000_SAVE_GAME                                              :{WHITE}Save Game
-STR_4001_LOAD_GAME                                              :{WHITE}Load Game
-STR_4002_SAVE                                                   :{BLACK}Save
-STR_4003_DELETE                                                 :{BLACK}Delete
-STR_4004                                                        :{COMPANY}, {DATE_LONG}
-STR_4005_BYTES_FREE                                             :{BLACK}{COMMA} megabyte{P "" s} free
-STR_4006_UNABLE_TO_READ_DRIVE                                   :{BLACK}Unable to read drive
-STR_4007_GAME_SAVE_FAILED                                       :{WHITE}Game Save Failed{}{STRING}
-STR_4008_UNABLE_TO_DELETE_FILE                                  :{WHITE}Unable to delete file
-STR_4009_GAME_LOAD_FAILED                                       :{WHITE}Game Load Failed{}{STRING}
-STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR                   :Internal error: {STRING}
-STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME                         :Broken savegame - {STRING}
-STR_GAME_SAVELOAD_ERROR_TOO_NEW_SAVEGAME                        :Savegame is made with newer version
-STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE                       :File not readable
-STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE                      :File not writable
-STR_400A_LIST_OF_DRIVES_DIRECTORIES                             :{BLACK}List of drives, directories and saved-game files
-STR_400B_CURRENTLY_SELECTED_NAME                                :{BLACK}Currently selected name for saved-game
-STR_400C_DELETE_THE_CURRENTLY_SELECTED                          :{BLACK}Delete the currently selected saved-game
-STR_400D_SAVE_THE_CURRENT_GAME_USING                            :{BLACK}Save the current game, using the selected name
-STR_400E_SELECT_NEW_GAME_TYPE                                   :{WHITE}Select New Game Type
-STR_400F_SELECT_SCENARIO_GREEN_PRE                              :{BLACK}Select scenario (green), pre-set game (blue), or random new game
-STR_4010_GENERATE_RANDOM_NEW_GAME                               :Generate random new game
-STR_4011_LOAD_HEIGHTMAP                                         :{WHITE}Load Heightmap
-
-##id 0x4800
-STR_4800_IN_THE_WAY                                             :{WHITE}{STRING} in the way
-STR_4801                                                        :{WHITE}{INDUSTRY}
-STR_4802_COAL_MINE                                              :Coal Mine
-STR_4803_POWER_STATION                                          :Power Station
-STR_4804_SAWMILL                                                :Sawmill
-STR_4805_FOREST                                                 :Forest
-STR_4806_OIL_REFINERY                                           :Oil Refinery
-STR_4807_OIL_RIG                                                :Oil Rig
-STR_4808_FACTORY                                                :Factory
-STR_4809_PRINTING_WORKS                                         :Printing Works
-STR_480A_STEEL_MILL                                             :Steel Mill
-STR_480B_FARM                                                   :Farm
-STR_480C_COPPER_ORE_MINE                                        :Copper Ore Mine
-STR_480D_OIL_WELLS                                              :Oil Wells
-STR_480E_BANK                                                   :Bank
-STR_480F_FOOD_PROCESSING_PLANT                                  :Food Processing Plant
-STR_4810_PAPER_MILL                                             :Paper Mill
-STR_4811_GOLD_MINE                                              :Gold Mine
-STR_4812_BANK                                                   :Bank
-STR_4813_DIAMOND_MINE                                           :Diamond Mine
-STR_4814_IRON_ORE_MINE                                          :Iron Ore Mine
-STR_4815_FRUIT_PLANTATION                                       :Fruit Plantation
-STR_4816_RUBBER_PLANTATION                                      :Rubber Plantation
-STR_4817_WATER_SUPPLY                                           :Water Supply
-STR_4818_WATER_TOWER                                            :Water Tower
-STR_4819_FACTORY                                                :Factory
-STR_481A_FARM                                                   :Farm
-STR_481B_LUMBER_MILL                                            :Lumber Mill
-STR_481C_COTTON_CANDY_FOREST                                    :Cotton Candy Forest
-STR_481D_CANDY_FACTORY                                          :Candy Factory
-STR_481E_BATTERY_FARM                                           :Battery Farm
-STR_481F_COLA_WELLS                                             :Cola Wells
-STR_4820_TOY_SHOP                                               :Toy Shop
-STR_4821_TOY_FACTORY                                            :Toy Factory
-STR_4822_PLASTIC_FOUNTAINS                                      :Plastic Fountains
-STR_4823_FIZZY_DRINK_FACTORY                                    :Fizzy Drink Factory
-STR_4824_BUBBLE_GENERATOR                                       :Bubble Generator
-STR_4825_TOFFEE_QUARRY                                          :Toffee Quarry
-STR_4826_SUGAR_MINE                                             :Sugar Mine
-
-############ range for requires starts
-STR_4827_REQUIRES                                               :{BLACK}Requires: {YELLOW}{STRING}
-STR_4828_REQUIRES                                               :{BLACK}Requires: {YELLOW}{STRING}, {STRING}
-STR_4829_REQUIRES                                               :{BLACK}Requires: {YELLOW}{STRING}, {STRING}, {STRING}
-############ range for requires ends
-
-############ range for produces starts
-STR_INDUSTRY_WINDOW_WAITING_FOR_PROCESSING                      :{BLACK}Cargo waiting to be processed:
-STR_INDUSTRY_WINDOW_WAITING_STOCKPILE_CARGO                     :{YELLOW}{CARGO}{BLACK}
-STR_4827_PRODUCES                                               :{BLACK}Produces: {YELLOW}{STRING}
-STR_4828_PRODUCES                                               :{BLACK}Produces: {YELLOW}{STRING}, {STRING}
-############ range for produces ends
-
-STR_482A_PRODUCTION_LAST_MONTH                                  :{BLACK}Production last month:
-STR_482B_TRANSPORTED                                            :{YELLOW}{CARGO}{BLACK} ({COMMA}% transported)
-STR_482C_CENTER_THE_MAIN_VIEW_ON                                :{BLACK}Center the main view on industry location
-STR_482D_NEW_UNDER_CONSTRUCTION                                 :{BLACK}{BIGFONT}New {STRING} under construction near {TOWN}!
-STR_482E_NEW_BEING_PLANTED_NEAR                                 :{BLACK}{BIGFONT}New {STRING} being planted near {TOWN}!
-STR_482F_COST                                                   :{BLACK}Cost: {YELLOW}{CURRENCY}
-STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY                          :{WHITE}Can't construct this industry type here...
-STR_4831_FOREST_CAN_ONLY_BE_PLANTED                             :{WHITE}...forest can only be planted above snow-line
-STR_4832_ANNOUNCES_IMMINENT_CLOSURE                             :{BLACK}{BIGFONT}{STRING} announces imminent closure!
-STR_4833_SUPPLY_PROBLEMS_CAUSE_TO                               :{BLACK}{BIGFONT}Supply problems cause {STRING} to announce imminent closure!
-STR_4834_LACK_OF_NEARBY_TREES_CAUSES                            :{BLACK}{BIGFONT}Lack of nearby trees causes {STRING} to announce imminent closure!
-STR_4835_INCREASES_PRODUCTION                                   :{BLACK}{BIGFONT}{INDUSTRY} increases production!
-STR_4836_NEW_COAL_SEAM_FOUND_AT                                 :{BLACK}{BIGFONT}New coal seam found at {INDUSTRY}!{}Production is expected to double!
-STR_4837_NEW_OIL_RESERVES_FOUND                                 :{BLACK}{BIGFONT}New oil reserves found at {INDUSTRY}!{}Production is expected to double!
-STR_4838_IMPROVED_FARMING_METHODS                               :{BLACK}{BIGFONT}Improved farming methods at {INDUSTRY} are expected to double production!
-STR_4839_PRODUCTION_DOWN_BY_50                                  :{BLACK}{BIGFONT}{INDUSTRY} production down by 50%
-STR_483A_INSECT_INFESTATION_CAUSES                              :{BLACK}{BIGFONT}Insect infestation causes havoc at {INDUSTRY}!{}Production down by 50%
-STR_483B_CAN_ONLY_BE_POSITIONED                                 :{WHITE}...can only be positioned near edges of map
-STR_INDUSTRY_PROD_GOUP                                          :{BLACK}{BIGFONT}{STRING} production at {INDUSTRY} increases by {COMMA}%!
-STR_INDUSTRY_PROD_GODOWN                                        :{BLACK}{BIGFONT}{STRING} production at {INDUSTRY} goes down by {COMMA}%!
-
-##id 0x5000
-STR_5000_TRAIN_IN_TUNNEL                                        :{WHITE}Train in tunnel
-STR_5001_ROAD_VEHICLE_IN_TUNNEL                                 :{WHITE}Road vehicle in tunnel
-STR_5003_ANOTHER_TUNNEL_IN_THE_WAY                              :{WHITE}Another tunnel in the way
-STR_5005_UNABLE_TO_EXCAVATE_LAND                                :{WHITE}Unable to excavate land for other end of tunnel
-STR_5006_MUST_DEMOLISH_TUNNEL_FIRST                             :{WHITE}Must demolish tunnel first
-STR_5007_MUST_DEMOLISH_BRIDGE_FIRST                             :{WHITE}Must demolish bridge first
-STR_5008_CANNOT_START_AND_END_ON                                :{WHITE}Cannot start and end on same position
-STR_BRIDGEHEADS_NOT_SAME_HEIGHT                                 :{WHITE}Bridge heads not at the same level
-STR_BRIDGE_TOO_LOW_FOR_TERRAIN                                  :{WHITE}Bridge is too low for the terrain
-STR_500A_START_AND_END_MUST_BE_IN                               :{WHITE}Start and end must be in line
-STR_500B_SITE_UNSUITABLE_FOR_TUNNEL                             :{WHITE}Site unsuitable for tunnel entrance
-STR_500D                                                        :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY}
-STR_500E_SUSPENSION_STEEL                                       :Suspension, Steel
-STR_500F_GIRDER_STEEL                                           :Girder, Steel
-STR_5010_CANTILEVER_STEEL                                       :Cantilever, Steel
-STR_5011_SUSPENSION_CONCRETE                                    :Suspension, Concrete
-STR_5012_WOODEN                                                 :Wooden
-STR_5013_CONCRETE                                               :Concrete
-STR_5014_TUBULAR_STEEL                                          :Tubular, Steel
-STR_BRIDGE_TUBULAR_SILICON                                      :Tubular, Silicon
-STR_5015_CAN_T_BUILD_BRIDGE_HERE                                :{WHITE}Can't build bridge here...
-STR_5016_CAN_T_BUILD_TUNNEL_HERE                                :{WHITE}Can't build tunnel here...
-STR_5017_RAILROAD_TUNNEL                                        :Railroad tunnel
-STR_5018_ROAD_TUNNEL                                            :Road tunnel
-STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE                           :Steel suspension rail bridge
-STR_501C_STEEL_GIRDER_RAIL_BRIDGE                               :Steel girder rail bridge
-STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE                           :Steel cantilever rail bridge
-STR_501E_REINFORCED_CONCRETE_SUSPENSION                         :Reinforced concrete suspension rail bridge
-STR_501F_WOODEN_RAIL_BRIDGE                                     :Wooden rail bridge
-STR_5020_CONCRETE_RAIL_BRIDGE                                   :Concrete rail bridge
-STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE                           :Steel suspension road bridge
-STR_5022_STEEL_GIRDER_ROAD_BRIDGE                               :Steel girder road bridge
-STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE                           :Steel cantilever road bridge
-STR_5024_REINFORCED_CONCRETE_SUSPENSION                         :Reinforced concrete suspension road bridge
-STR_5025_WOODEN_ROAD_BRIDGE                                     :Wooden road bridge
-STR_5026_CONCRETE_ROAD_BRIDGE                                   :Concrete road bridge
-STR_5027_TUBULAR_RAIL_BRIDGE                                    :Tubular rail bridge
-STR_5028_TUBULAR_ROAD_BRIDGE                                    :Tubular road bridge
-
-##id 0x5800
-STR_5800_OBJECT_IN_THE_WAY                                      :{WHITE}Object in the way
-STR_5801_TRANSMITTER                                            :Transmitter
-STR_5802_LIGHTHOUSE                                             :Lighthouse
-STR_5803_COMPANY_HEADQUARTERS                                   :Company Headquarters
-STR_5804_COMPANY_HEADQUARTERS_IN                                :{WHITE}...company headquarters in the way
-STR_5805_COMPANY_OWNED_LAND                                     :Company-owned land
-STR_5806_CAN_T_PURCHASE_THIS_LAND                               :{WHITE}Can't purchase this land area...
-STR_5807_YOU_ALREADY_OWN_IT                                     :{WHITE}...you already own it!
-
-
-############ WARNING, using range 0x6000 for strings that are stored in the savegame
-############ These strings may never get a new id, or savegames will break!
-##id 0x6000
-STR_SV_EMPTY                                                    :
-STR_SV_UNNAMED                                                  :Unnamed
-STR_SV_TRAIN_NAME                                               :Train {COMMA}
-STR_SV_ROADVEH_NAME                                             :Road Vehicle {COMMA}
-STR_SV_SHIP_NAME                                                :Ship {COMMA}
-STR_SV_AIRCRAFT_NAME                                            :Aircraft {COMMA}
-
-STR_SV_STNAME                                                   :{STRING}
-STR_SV_STNAME_NORTH                                             :{STRING} North
-STR_SV_STNAME_SOUTH                                             :{STRING} South
-STR_SV_STNAME_EAST                                              :{STRING} East
-STR_SV_STNAME_WEST                                              :{STRING} West
-STR_SV_STNAME_CENTRAL                                           :{STRING} Central
-STR_SV_STNAME_TRANSFER                                          :{STRING} Transfer
-STR_SV_STNAME_HALT                                              :{STRING} Halt
-STR_SV_STNAME_VALLEY                                            :{STRING} Valley
-STR_SV_STNAME_HEIGHTS                                           :{STRING} Heights
-STR_SV_STNAME_WOODS                                             :{STRING} Woods
-STR_SV_STNAME_LAKESIDE                                          :{STRING} Lakeside
-STR_SV_STNAME_EXCHANGE                                          :{STRING} Exchange
-STR_SV_STNAME_AIRPORT                                           :{STRING} Airport
-STR_SV_STNAME_OILFIELD                                          :{STRING} Oilfield
-STR_SV_STNAME_MINES                                             :{STRING} Mines
-STR_SV_STNAME_DOCKS                                             :{STRING} Docks
-STR_SV_STNAME_BUOY_1                                            :{STRING} Buoy 1
-STR_SV_STNAME_BUOY_2                                            :{STRING} Buoy 2
-STR_SV_STNAME_BUOY_3                                            :{STRING} Buoy 3
-STR_SV_STNAME_BUOY_4                                            :{STRING} Buoy 4
-STR_SV_STNAME_BUOY_5                                            :{STRING} Buoy 5
-STR_SV_STNAME_BUOY_6                                            :{STRING} Buoy 6
-STR_SV_STNAME_BUOY_7                                            :{STRING} Buoy 7
-STR_SV_STNAME_BUOY_8                                            :{STRING} Buoy 8
-STR_SV_STNAME_BUOY_9                                            :{STRING} Buoy 9
-STR_SV_STNAME_ANNEXE                                            :{STRING} Annexe
-STR_SV_STNAME_SIDINGS                                           :{STRING} Sidings
-STR_SV_STNAME_BRANCH                                            :{STRING} Branch
-STR_SV_STNAME_UPPER                                             :Upper {STRING}
-STR_SV_STNAME_LOWER                                             :Lower {STRING}
-STR_SV_STNAME_HELIPORT                                          :{STRING} Heliport
-STR_SV_STNAME_FOREST                                            :{STRING} Forest
-STR_SV_STNAME_FALLBACK                                          :{STRING} Station #{NUM}
-
-############ end of savegame specific region!
-
-##id 0x6800
-STR_6800_DIFFICULTY_LEVEL                                       :{WHITE}Difficulty Level
-STR_OPTIONS_SAVE_CHANGES                                        :{BLACK}Save
-
-############ range for difficulty levels starts
-STR_6801_EASY                                                   :{BLACK}Easy
-STR_6802_MEDIUM                                                 :{BLACK}Medium
-STR_6803_HARD                                                   :{BLACK}Hard
-STR_6804_CUSTOM                                                 :{BLACK}Custom
-############ range for difficulty levels ends
-
-############ range for difficulty settings starts
-STR_6805_MAXIMUM_NO_COMPETITORS                                 :{LTBLUE}Maximum no. competitors: {ORANGE}{COMMA}
-STR_6806_COMPETITOR_START_TIME                                  :{LTBLUE}Competitor start time: {ORANGE}{STRING}
-STR_6807_NO_OF_TOWNS                                            :{LTBLUE}No. of towns: {ORANGE}{STRING}
-STR_6808_NO_OF_INDUSTRIES                                       :{LTBLUE}No. of industries: {ORANGE}{STRING}
-STR_6809_MAXIMUM_INITIAL_LOAN_000                               :{LTBLUE}Maximum initial loan: {ORANGE}{CURRENCY}
-STR_680A_INITIAL_INTEREST_RATE                                  :{LTBLUE}Initial interest rate: {ORANGE}{COMMA}%
-STR_680B_VEHICLE_RUNNING_COSTS                                  :{LTBLUE}Vehicle running costs: {ORANGE}{STRING}
-STR_680C_CONSTRUCTION_SPEED_OF_COMPETITOR                       :{LTBLUE}Construction speed of competitors: {ORANGE}{STRING}
-STR_680D_INTELLIGENCE_OF_COMPETITORS                            :{LTBLUE}Intelligence of competitors: {ORANGE}{STRING}
-STR_680E_VEHICLE_BREAKDOWNS                                     :{LTBLUE}Vehicle breakdowns: {ORANGE}{STRING}
-STR_680F_SUBSIDY_MULTIPLIER                                     :{LTBLUE}Subsidy multiplier: {ORANGE}{STRING}
-STR_6810_COST_OF_CONSTRUCTION                                   :{LTBLUE}Cost of construction: {ORANGE}{STRING}
-STR_6811_TERRAIN_TYPE                                           :{LTBLUE}Terrain type: {ORANGE}{STRING}
-STR_6812_QUANTITY_OF_SEA_LAKES                                  :{LTBLUE}Quantity of sea/lakes: {ORANGE}{STRING}
-STR_6813_ECONOMY                                                :{LTBLUE}Economy: {ORANGE}{STRING}
-STR_6814_TRAIN_REVERSING                                        :{LTBLUE}Train reversing: {ORANGE}{STRING}
-STR_6815_DISASTERS                                              :{LTBLUE}Disasters: {ORANGE}{STRING}
-STR_16816_CITY_APPROVAL                                         :{LTBLUE}City council's attitude towards area restructuring: {ORANGE}{STRING}
-############ range for difficulty settings ends
-
-STR_26816_NONE                                                  :None
-STR_NUM_VERY_LOW                                                :Very low
-STR_6816_LOW                                                    :Low
-STR_6817_NORMAL                                                 :Normal
-STR_6818_HIGH                                                   :High
-STR_6819                                                        :{BLACK}{SMALLLEFTARROW}
-STR_681A                                                        :{BLACK}{SMALLRIGHTARROW}
-STR_681B_VERY_SLOW                                              :Very Slow
-STR_681C_SLOW                                                   :Slow
-STR_681D_MEDIUM                                                 :Medium
-STR_681E_FAST                                                   :Fast
-STR_681F_VERY_FAST                                              :Very Fast
-STR_VERY_LOW                                                    :Very Low
-STR_6820_LOW                                                    :Low
-STR_6821_MEDIUM                                                 :Medium
-STR_6822_HIGH                                                   :High
-STR_6823_NONE                                                   :None
-STR_6824_REDUCED                                                :Reduced
-STR_6825_NORMAL                                                 :Normal
-STR_6826_X1_5                                                   :x1.5
-STR_6827_X2                                                     :x2
-STR_6828_X3                                                     :x3
-STR_6829_X4                                                     :x4
-STR_682A_VERY_FLAT                                              :Very Flat
-STR_682B_FLAT                                                   :Flat
-STR_682C_HILLY                                                  :Hilly
-STR_682D_MOUNTAINOUS                                            :Mountainous
-STR_682E_STEADY                                                 :Steady
-STR_682F_FLUCTUATING                                            :Fluctuating
-STR_6830_IMMEDIATE                                              :Immediate
-STR_6831_3_MONTHS_AFTER_PLAYER                                  :3 months after player
-STR_6832_6_MONTHS_AFTER_PLAYER                                  :6 months after player
-STR_6833_9_MONTHS_AFTER_PLAYER                                  :9 months after player
-STR_6834_AT_END_OF_LINE_AND_AT_STATIONS                         :At end of line, and at stations
-STR_6835_AT_END_OF_LINE_ONLY                                    :At end of line only
-STR_6836_OFF                                                    :Off
-STR_6837_ON                                                     :On
-STR_6838_SHOW_HI_SCORE_CHART                                    :{BLACK}Show hi-score chart
-STR_6839_PERMISSIVE                                             :Permissive
-STR_683A_TOLERANT                                               :Tolerant
-STR_683B_HOSTILE                                                :Hostile
-
-##id 0x7000
-STR_7000                                                        :
-STR_7001                                                        :{WHITE}{COMPANY} {BLACK}{COMPANYNUM}
-STR_7002_PLAYER                                                 :(Player {COMMA})
-STR_7004_NEW_FACE                                               :{BLACK}New Face
-STR_7005_COLOR_SCHEME                                           :{BLACK}Color Scheme
-STR_7006_COLOR_SCHEME                                           :{GOLD}Color Scheme:
-STR_7007_NEW_COLOR_SCHEME                                       :{WHITE}New Color Scheme
-STR_7008_COMPANY_NAME                                           :{BLACK}Company Name
-STR_7009_PRESIDENT_NAME                                         :{BLACK}President Name
-STR_700A_COMPANY_NAME                                           :Company Name
-STR_700B_PRESIDENT_S_NAME                                       :President's Name
-STR_700C_CAN_T_CHANGE_COMPANY_NAME                              :{WHITE}Can't change company name...
-STR_700D_CAN_T_CHANGE_PRESIDENT                                 :{WHITE}Can't change president's name...
-STR_700E_FINANCES                                               :{WHITE}{COMPANY} Finances {BLACK}{COMPANYNUM}
-STR_700F_EXPENDITURE_INCOME                                     :{WHITE}Expenditure/Income
-STR_7010                                                        :{WHITE}{NUM}
-STR_7011_CONSTRUCTION                                           :{GOLD}Construction
-STR_7012_NEW_VEHICLES                                           :{GOLD}New Vehicles
-STR_7013_TRAIN_RUNNING_COSTS                                    :{GOLD}Train Running Costs
-STR_7014_ROAD_VEH_RUNNING_COSTS                                 :{GOLD}Road Veh. Running Costs
-STR_7015_AIRCRAFT_RUNNING_COSTS                                 :{GOLD}Aircraft Running Costs
-STR_7016_SHIP_RUNNING_COSTS                                     :{GOLD}Ship Running Costs
-STR_7017_PROPERTY_MAINTENANCE                                   :{GOLD}Property Maintenance
-STR_7018_TRAIN_INCOME                                           :{GOLD}Train Income
-STR_7019_ROAD_VEHICLES_INCOME                                   :{GOLD}Road Vehicle Income
-STR_701A_AIRCRAFT_INCOME                                        :{GOLD}Aircraft Income
-STR_701B_SHIP_INCOME                                            :{GOLD}Ship Income
-STR_701C_LOAN_INTEREST                                          :{GOLD}Loan Interest
-STR_701D_OTHER                                                  :{GOLD}Other
-STR_701E                                                        :{BLACK}-{CURRENCY}
-STR_701F                                                        :{BLACK}+{CURRENCY}
-STR_7020_TOTAL                                                  :{WHITE}Total:
-STR_7021                                                        :{COMPANY} {COMPANYNUM}
-STR_7022_INCOME_GRAPH                                           :{WHITE}Income Graph
-STR_CURRCOMPACT                                                 :{CURRCOMPACT}
-STR_7024                                                        :{COMMA}
-STR_7025_OPERATING_PROFIT_GRAPH                                 :{WHITE}Operating Profit Graph
-STR_7026_BANK_BALANCE                                           :{WHITE}Bank Balance
-STR_7027_LOAN                                                   :{WHITE}Loan
-STR_MAX_LOAN                                                    :{WHITE}Max Loan:  {BLACK}{CURRENCY}
-STR_7028                                                        :{BLACK}{CURRENCY}
-STR_7029_BORROW                                                 :{BLACK}Borrow {SKIP}{SKIP}{CURRENCY}
-STR_702A_REPAY                                                  :{BLACK}Repay {SKIP}{SKIP}{CURRENCY}
-STR_702B_MAXIMUM_PERMITTED_LOAN                                 :{WHITE}...maximum permitted loan size is {CURRENCY}
-STR_702C_CAN_T_BORROW_ANY_MORE_MONEY                            :{WHITE}Can't borrow any more money...
-STR_702D_LOAN_ALREADY_REPAYED                                   :{WHITE}...no loan to repay
-STR_702E_REQUIRED                                               :{WHITE}...{CURRENCY} required
-STR_702F_CAN_T_REPAY_LOAN                                       :{WHITE}Can't repay loan...
-STR_INSUFFICIENT_FUNDS                                          :{WHITE}Can't give away money that is loaned from the bank...
-STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT                          :{BLACK}Select new face for president
-STR_7031_CHANGE_THE_COMPANY_VEHICLE                             :{BLACK}Change the company vehicle livery
-STR_7032_CHANGE_THE_PRESIDENT_S                                 :{BLACK}Change the president's name
-STR_7033_CHANGE_THE_COMPANY_NAME                                :{BLACK}Change the company name
-STR_7034_CLICK_ON_SELECTED_NEW_COLOR                            :{BLACK}Click on desired color scheme
-STR_7035_INCREASE_SIZE_OF_LOAN                                  :{BLACK}Increase size of loan
-STR_7036_REPAY_PART_OF_LOAN                                     :{BLACK}Repay part of loan
-STR_7037_PRESIDENT                                              :{WHITE}{PLAYERNAME}{}{GOLD}(President)
-STR_7038_INAUGURATED                                            :{GOLD}Inaugurated: {WHITE}{NUM}
-STR_7039_VEHICLES                                               :{GOLD}Vehicles:
-STR_TRAINS                                                      :{WHITE}{COMMA} train{P "" s}
-STR_ROAD_VEHICLES                                               :{WHITE}{COMMA} road vehicle{P "" s}
-STR_AIRCRAFT                                                    :{WHITE}{COMMA} aircraft
-STR_SHIPS                                                       :{WHITE}{COMMA} ship{P "" s}
-STR_7042_NONE                                                   :{WHITE}None
-STR_7043_FACE_SELECTION                                         :{WHITE}Face Selection
-STR_7044_MALE                                                   :{BLACK}Male
-STR_7045_FEMALE                                                 :{BLACK}Female
-STR_7046_NEW_FACE                                               :{BLACK}New Face
-STR_7047_CANCEL_NEW_FACE_SELECTION                              :{BLACK}Cancel new face selection
-STR_7048_ACCEPT_NEW_FACE_SELECTION                              :{BLACK}Accept new face selection
-STR_7049_SELECT_MALE_FACES                                      :{BLACK}Select male faces
-STR_704A_SELECT_FEMALE_FACES                                    :{BLACK}Select female faces
-STR_704B_GENERATE_RANDOM_NEW_FACE                               :{BLACK}Generate random new face
-STR_704C_KEY                                                    :{BLACK}Key
-STR_704D_SHOW_KEY_TO_GRAPHS                                     :{BLACK}Show key to graphs
-STR_704E_KEY_TO_COMPANY_GRAPHS                                  :{WHITE}Key to company graphs
-STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY                           :{BLACK}Click here to toggle company's entry on graph on/off
-STR_7050_UNITS_OF_CARGO_DELIVERED                               :{WHITE}Units of cargo delivered
-STR_7051_COMPANY_PERFORMANCE_RATINGS                            :{WHITE}Company performance ratings (maximum rating=1000)
-STR_7052_COMPANY_VALUES                                         :{WHITE}Company values
-STR_7053_COMPANY_LEAGUE_TABLE                                   :{WHITE}Company League Table
-STR_7054                                                        :{WHITE}{STRING}{SETX 45}{ORANGE}{COMPANY} {BLACK}{COMPANYNUM} '{STRING}'
-STR_7055                                                        :{YELLOW}{STRING}{SETX 45}{ORANGE}{COMPANY} {BLACK}{COMPANYNUM}  '{STRING}'
-STR_7056_TRANSPORT_COMPANY_IN_TROUBLE                           :{BLACK}{BIGFONT}Transport company in trouble!
-STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED                           :{BLACK}{BIGFONT}{COMPANY} will be sold off or declared bankrupt unless performance increases soon!
-STR_7058_PRESIDENT                                              :{BLACK}{PLAYERNAME}{}(President)
-STR_7059_TRANSPORT_COMPANY_MERGER                               :{BLACK}{BIGFONT}Transport company merger!
-STR_705A_HAS_BEEN_SOLD_TO_FOR                                   :{BLACK}{BIGFONT}{COMPANY} has been sold to {COMPANY} for {CURRENCY}!
-STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT                         :{WHITE}We are looking for a transport company to take-over our company{}{}Do you want to purchase {COMPANY} for {CURRENCY}?
-STR_705C_BANKRUPT                                               :{BLACK}{BIGFONT}Bankrupt!
-STR_705D_HAS_BEEN_CLOSED_DOWN_BY                                :{BLACK}{BIGFONT}{COMPANY} has been closed down by creditors and all assets sold off!
-STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED                         :{BLACK}{BIGFONT}New transport company launched!
-STR_705F_STARTS_CONSTRUCTION_NEAR                               :{BLACK}{BIGFONT}{COMPANY} starts construction near {TOWN}!
-STR_7060_CAN_T_BUY_COMPANY                                      :{WHITE}Can't buy company...
-STR_7061_CARGO_PAYMENT_RATES                                    :{WHITE}Cargo Payment Rates
-STR_7062_DAYS_IN_TRANSIT                                        :{BLACK}{TINYFONT}Days in transit
-STR_7063_PAYMENT_FOR_DELIVERING                                 :{BLACK}{TINYFONT}Payment for delivering 10 units (or 10,000 litres) of cargo a distance of 20 squares
-STR_7064_TOGGLE_GRAPH_FOR_CARGO                                 :{BLACK}Toggle graph for cargo type on/off
-STR_7065                                                        :{BLACK}{TINYFONT}{STRING}
-STR_7066_ENGINEER                                               :Engineer
-STR_7067_TRAFFIC_MANAGER                                        :Traffic Manager
-STR_7068_TRANSPORT_COORDINATOR                                  :Transport Coordinator
-STR_7069_ROUTE_SUPERVISOR                                       :Route Supervisor
-STR_706A_DIRECTOR                                               :Director
-STR_706B_CHIEF_EXECUTIVE                                        :Chief Executive
-STR_706C_CHAIRMAN                                               :Chairman
-STR_706D_PRESIDENT                                              :President
-STR_706E_TYCOON                                                 :Tycoon
-STR_706F_BUILD_HQ                                               :{BLACK}Build HQ
-STR_7070_BUILD_COMPANY_HEADQUARTERS                             :{BLACK}Build company headquarters / view company headquarters
-STR_RELOCATE_COMPANY_HEADQUARTERS                               :{BLACK}Rebuild company headquarters elsewhere for 1% cost of company value
-STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS                       :{WHITE}Can't build company headquarters...
-STR_7072_VIEW_HQ                                                :{BLACK}View HQ
-STR_RELOCATE_HQ                                                 :{BLACK}Relocate HQ
-STR_COMPANY_PASSWORD                                            :{BLACK}Password
-STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Password-protect your company to prevent unauthorized users from joining.
-STR_SET_COMPANY_PASSWORD                                        :Set company password
-STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}World Recession!{}{}Financial experts fear worst as economy slumps!
-STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recession Over!{}{}Upturn in trade gives confidence to industries as economy strengthens!
-STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Toggle large/small window size
-STR_7076_COMPANY_VALUE                                          :{GOLD}Company value: {WHITE}{CURRENCY}
-STR_7077_BUY_25_SHARE_IN_COMPANY                                :{BLACK}Buy 25% share in company
-STR_7078_SELL_25_SHARE_IN_COMPANY                               :{BLACK}Sell 25% share in company
-STR_7079_BUY_25_SHARE_IN_THIS_COMPANY                           :{BLACK}Buy 25% share in this company
-STR_707A_SELL_25_SHARE_IN_THIS_COMPANY                          :{BLACK}Sell 25% share in this company
-STR_707B_CAN_T_BUY_25_SHARE_IN_THIS                             :{WHITE}Can't buy 25% share in this company...
-STR_707C_CAN_T_SELL_25_SHARE_IN                                 :{WHITE}Can't sell 25% share in this company...
-STR_707D_OWNED_BY                                               :{WHITE}({COMMA}% owned by {COMPANY})
-STR_707F_HAS_BEEN_TAKEN_OVER_BY                                 :{BLACK}{BIGFONT}{COMPANY} has been taken over by {COMPANY}!
-STR_7080_PROTECTED                                              :{WHITE}This company is not old enough to trade shares yet...
-
-STR_LIVERY_DEFAULT                                              :Standard Livery
-STR_LIVERY_STEAM                                                :Steam Engine
-STR_LIVERY_DIESEL                                               :Diesel Engine
-STR_LIVERY_ELECTRIC                                             :Electric Engine
-STR_LIVERY_MONORAIL                                             :Monorail Engine
-STR_LIVERY_MAGLEV                                               :Maglev Engine
-STR_LIVERY_DMU                                                  :DMU
-STR_LIVERY_EMU                                                  :EMU
-STR_LIVERY_PASSENGER_WAGON_STEAM                                :Passenger/Mail Car (Steam)
-STR_LIVERY_PASSENGER_WAGON_DIESEL                               :Passenger/Mail Car (Diesel)
-STR_LIVERY_PASSENGER_WAGON_ELECTRIC                             :Passenger/Mail Car (Electric)
-STR_LIVERY_FREIGHT_WAGON                                        :Freight Car
-STR_LIVERY_BUS                                                  :Bus
-STR_LIVERY_TRUCK                                                :Truck
-STR_LIVERY_PASSENGER_SHIP                                       :Passenger Ship
-STR_LIVERY_FREIGHT_SHIP                                         :Freight Ship
-STR_LIVERY_HELICOPTER                                           :Helicopter
-STR_LIVERY_SMALL_PLANE                                          :Small Airplane
-STR_LIVERY_LARGE_PLANE                                          :Large Airplane
-STR_LIVERY_PASSENGER_TRAM                                       :Passenger Tram
-STR_LIVERY_FREIGHT_TRAM                                         :Freight Tram
-
-STR_LIVERY_GENERAL_TIP                                          :{BLACK}Show general color schemes
-STR_LIVERY_TRAIN_TIP                                            :{BLACK}Show train color schemes
-STR_LIVERY_ROADVEH_TIP                                          :{BLACK}Show road vehicle color schemes
-STR_LIVERY_SHIP_TIP                                             :{BLACK}Show ship color schemes
-STR_LIVERY_AIRCRAFT_TIP                                         :{BLACK}Show aircraft color schemes
-STR_LIVERY_PRIMARY_TIP                                          :{BLACK}Choose the primary color for the selected scheme
-STR_LIVERY_SECONDARY_TIP                                        :{BLACK}Choose the secondary color for the selected scheme
-STR_LIVERY_PANEL_TIP                                            :{BLACK}Select a color scheme to change, or multiple schemes with CTRL+click. Click on the box to toggle use of the scheme
-
-##id 0x8000
-STR_8000_KIRBY_PAUL_TANK_STEAM                                  :Kirby Paul Tank (Steam)
-STR_8001_MJS_250_DIESEL                                         :MJS 250 (Diesel)
-STR_8002_PLODDYPHUT_CHOO_CHOO                                   :Ploddyphut Choo-Choo
-STR_8003_POWERNAUT_CHOO_CHOO                                    :Powernaut Choo-Choo
-STR_8004_MIGHTYMOVER_CHOO_CHOO                                  :Mightymover Choo-Choo
-STR_8005_PLODDYPHUT_DIESEL                                      :Ploddyphut Diesel
-STR_8006_POWERNAUT_DIESEL                                       :Powernaut Diesel
-STR_8007_WILLS_2_8_0_STEAM                                      :Wills 2-8-0 (Steam)
-STR_8008_CHANEY_JUBILEE_STEAM                                   :Chaney 'Jubilee' (Steam)
-STR_8009_GINZU_A4_STEAM                                         :Ginzu 'A4' (Steam)
-STR_800A_SH_8P_STEAM                                            :SH '8P' (Steam)
-STR_800B_MANLEY_MOREL_DMU_DIESEL                                :Manley-Morel DMU (Diesel)
-STR_800C_DASH_DIESEL                                            :'Dash' (Diesel)
-STR_800D_SH_HENDRY_25_DIESEL                                    :SH/Hendry '25' (Diesel)
-STR_800E_UU_37_DIESEL                                           :UU '37' (Diesel)
-STR_800F_FLOSS_47_DIESEL                                        :Floss '47' (Diesel)
-STR_8010_CS_4000_DIESEL                                         :CS 4000 (Diesel)
-STR_8011_CS_2400_DIESEL                                         :CS 2400 (Diesel)
-STR_8012_CENTENNIAL_DIESEL                                      :Centennial (Diesel)
-STR_8013_KELLING_3100_DIESEL                                    :Kelling 3100 (Diesel)
-STR_8014_TURNER_TURBO_DIESEL                                    :Turner Turbo (Diesel)
-STR_8015_MJS_1000_DIESEL                                        :MJS 1000 (Diesel)
-STR_8016_SH_125_DIESEL                                          :SH '125' (Diesel)
-STR_8017_SH_30_ELECTRIC                                         :SH '30' (Electric)
-STR_8018_SH_40_ELECTRIC                                         :SH '40' (Electric)
-STR_8019_T_I_M_ELECTRIC                                         :'T.I.M.' (Electric)
-STR_801A_ASIASTAR_ELECTRIC                                      :'AsiaStar' (Electric)
-STR_801B_PASSENGER_CAR                                          :Passenger Car
-STR_801C_MAIL_VAN                                               :Mail Van
-STR_801D_COAL_CAR                                               :Coal Car
-STR_801E_OIL_TANKER                                             :Oil Tanker
-STR_801F_LIVESTOCK_VAN                                          :Livestock Van
-STR_8020_GOODS_VAN                                              :Goods Van
-STR_8021_GRAIN_HOPPER                                           :Grain Hopper
-STR_8022_WOOD_TRUCK                                             :Wood Truck
-STR_8023_IRON_ORE_HOPPER                                        :Iron Ore Hopper
-STR_8024_STEEL_TRUCK                                            :Steel Truck
-STR_8025_ARMORED_VAN                                            :Armored Van
-STR_8026_FOOD_VAN                                               :Food Van
-STR_8027_PAPER_TRUCK                                            :Paper Truck
-STR_8028_COPPER_ORE_HOPPER                                      :Copper Ore Hopper
-STR_8029_WATER_TANKER                                           :Water Tanker
-STR_802A_FRUIT_TRUCK                                            :Fruit Truck
-STR_802B_RUBBER_TRUCK                                           :Rubber Truck
-STR_802C_SUGAR_TRUCK                                            :Sugar Truck
-STR_802D_COTTON_CANDY_HOPPER                                    :Cotton Candy Hopper
-STR_802E_TOFFEE_HOPPER                                          :Toffee Hopper
-STR_802F_BUBBLE_VAN                                             :Bubble Van
-STR_8030_COLA_TANKER                                            :Cola Tanker
-STR_8031_CANDY_VAN                                              :Candy Van
-STR_8032_TOY_VAN                                                :Toy Van
-STR_8033_BATTERY_TRUCK                                          :Battery Truck
-STR_8034_FIZZY_DRINK_TRUCK                                      :Fizzy Drink Truck
-STR_8035_PLASTIC_TRUCK                                          :Plastic Truck
-STR_8036_X2001_ELECTRIC                                         :'X2001' (Electric)
-STR_8037_MILLENNIUM_Z1_ELECTRIC                                 :'Millennium Z1' (Electric)
-STR_8038_WIZZOWOW_Z99                                           :Wizzowow Z99
-STR_8039_PASSENGER_CAR                                          :Passenger Car
-STR_803A_MAIL_VAN                                               :Mail Van
-STR_803B_COAL_CAR                                               :Coal Car
-STR_803C_OIL_TANKER                                             :Oil Tanker
-STR_803D_LIVESTOCK_VAN                                          :Livestock Van
-STR_803E_GOODS_VAN                                              :Goods Van
-STR_803F_GRAIN_HOPPER                                           :Grain Hopper
-STR_8040_WOOD_TRUCK                                             :Wood Truck
-STR_8041_IRON_ORE_HOPPER                                        :Iron Ore Hopper
-STR_8042_STEEL_TRUCK                                            :Steel Truck
-STR_8043_ARMORED_VAN                                            :Armored Van
-STR_8044_FOOD_VAN                                               :Food Van
-STR_8045_PAPER_TRUCK                                            :Paper Truck
-STR_8046_COPPER_ORE_HOPPER                                      :Copper Ore Hopper
-STR_8047_WATER_TANKER                                           :Water Tanker
-STR_8048_FRUIT_TRUCK                                            :Fruit Truck
-STR_8049_RUBBER_TRUCK                                           :Rubber Truck
-STR_804A_SUGAR_TRUCK                                            :Sugar Truck
-STR_804B_COTTON_CANDY_HOPPER                                    :Cotton Candy Hopper
-STR_804C_TOFFEE_HOPPER                                          :Toffee Hopper
-STR_804D_BUBBLE_VAN                                             :Bubble Van
-STR_804E_COLA_TANKER                                            :Cola Tanker
-STR_804F_CANDY_VAN                                              :Candy Van
-STR_8050_TOY_VAN                                                :Toy Van
-STR_8051_BATTERY_TRUCK                                          :Battery Truck
-STR_8052_FIZZY_DRINK_TRUCK                                      :Fizzy Drink Truck
-STR_8053_PLASTIC_TRUCK                                          :Plastic Truck
-STR_8054_LEV1_LEVIATHAN_ELECTRIC                                :Lev1 'Leviathan' (Electric)
-STR_8055_LEV2_CYCLOPS_ELECTRIC                                  :Lev2 'Cyclops' (Electric)
-STR_8056_LEV3_PEGASUS_ELECTRIC                                  :Lev3 'Pegasus' (Electric)
-STR_8057_LEV4_CHIMAERA_ELECTRIC                                 :Lev4 'Chimaera' (Electric)
-STR_8058_WIZZOWOW_ROCKETEER                                     :Wizzowow Rocketeer
-STR_8059_PASSENGER_CAR                                          :Passenger Car
-STR_805A_MAIL_VAN                                               :Mail Van
-STR_805B_COAL_CAR                                               :Coal Car
-STR_805C_OIL_TANKER                                             :Oil Tanker
-STR_805D_LIVESTOCK_VAN                                          :Livestock Van
-STR_805E_GOODS_VAN                                              :Goods Van
-STR_805F_GRAIN_HOPPER                                           :Grain Hopper
-STR_8060_WOOD_TRUCK                                             :Wood Truck
-STR_8061_IRON_ORE_HOPPER                                        :Iron Ore Hopper
-STR_8062_STEEL_TRUCK                                            :Steel Truck
-STR_8063_ARMORED_VAN                                            :Armored Van
-STR_8064_FOOD_VAN                                               :Food Van
-STR_8065_PAPER_TRUCK                                            :Paper Truck
-STR_8066_COPPER_ORE_HOPPER                                      :Copper Ore Hopper
-STR_8067_WATER_TANKER                                           :Water Tanker
-STR_8068_FRUIT_TRUCK                                            :Fruit Truck
-STR_8069_RUBBER_TRUCK                                           :Rubber Truck
-STR_806A_SUGAR_TRUCK                                            :Sugar Truck
-STR_806B_COTTON_CANDY_HOPPER                                    :Cotton Candy Hopper
-STR_806C_TOFFEE_HOPPER                                          :Toffee Hopper
-STR_806D_BUBBLE_VAN                                             :Bubble Van
-STR_806E_COLA_TANKER                                            :Cola Tanker
-STR_806F_CANDY_VAN                                              :Candy Van
-STR_8070_TOY_VAN                                                :Toy Van
-STR_8071_BATTERY_TRUCK                                          :Battery Truck
-STR_8072_FIZZY_DRINK_TRUCK                                      :Fizzy Drink Truck
-STR_8073_PLASTIC_TRUCK                                          :Plastic Truck
-STR_8074_MPS_REGAL_BUS                                          :MPS Regal Bus
-STR_8075_HEREFORD_LEOPARD_BUS                                   :Hereford Leopard Bus
-STR_8076_FOSTER_BUS                                             :Foster Bus
-STR_8077_FOSTER_MKII_SUPERBUS                                   :Foster MkII Superbus
-STR_8078_PLODDYPHUT_MKI_BUS                                     :Ploddyphut MkI Bus
-STR_8079_PLODDYPHUT_MKII_BUS                                    :Ploddyphut MkII Bus
-STR_807A_PLODDYPHUT_MKIII_BUS                                   :Ploddyphut MkIII Bus
-STR_807B_BALOGH_COAL_TRUCK                                      :Balogh Coal Truck
-STR_807C_UHL_COAL_TRUCK                                         :Uhl Coal Truck
-STR_807D_DW_COAL_TRUCK                                          :DW Coal Truck
-STR_807E_MPS_MAIL_TRUCK                                         :MPS Mail Truck
-STR_807F_REYNARD_MAIL_TRUCK                                     :Reynard Mail Truck
-STR_8080_PERRY_MAIL_TRUCK                                       :Perry Mail Truck
-STR_8081_MIGHTYMOVER_MAIL_TRUCK                                 :MightyMover Mail Truck
-STR_8082_POWERNAUGHT_MAIL_TRUCK                                 :Powernaught Mail Truck
-STR_8083_WIZZOWOW_MAIL_TRUCK                                    :Wizzowow Mail Truck
-STR_8084_WITCOMBE_OIL_TANKER                                    :Witcombe Oil Tanker
-STR_8085_FOSTER_OIL_TANKER                                      :Foster Oil Tanker
-STR_8086_PERRY_OIL_TANKER                                       :Perry Oil Tanker
-STR_8087_TALBOTT_LIVESTOCK_VAN                                  :Talbott Livestock Van
-STR_8088_UHL_LIVESTOCK_VAN                                      :Uhl Livestock Van
-STR_8089_FOSTER_LIVESTOCK_VAN                                   :Foster Livestock Van
-STR_808A_BALOGH_GOODS_TRUCK                                     :Balogh Goods Truck
-STR_808B_CRAIGHEAD_GOODS_TRUCK                                  :Craighead Goods Truck
-STR_808C_GOSS_GOODS_TRUCK                                       :Goss Goods Truck
-STR_808D_HEREFORD_GRAIN_TRUCK                                   :Hereford Grain Truck
-STR_808E_THOMAS_GRAIN_TRUCK                                     :Thomas Grain Truck
-STR_808F_GOSS_GRAIN_TRUCK                                       :Goss Grain Truck
-STR_8090_WITCOMBE_WOOD_TRUCK                                    :Witcombe Wood Truck
-STR_8091_FOSTER_WOOD_TRUCK                                      :Foster Wood Truck
-STR_8092_MORELAND_WOOD_TRUCK                                    :Moreland Wood Truck
-STR_8093_MPS_IRON_ORE_TRUCK                                     :MPS Iron Ore Truck
-STR_8094_UHL_IRON_ORE_TRUCK                                     :Uhl Iron Ore Truck
-STR_8095_CHIPPY_IRON_ORE_TRUCK                                  :Chippy Iron Ore Truck
-STR_8096_BALOGH_STEEL_TRUCK                                     :Balogh Steel Truck
-STR_8097_UHL_STEEL_TRUCK                                        :Uhl Steel Truck
-STR_8098_KELLING_STEEL_TRUCK                                    :Kelling Steel Truck
-STR_8099_BALOGH_ARMORED_TRUCK                                   :Balogh Armored Truck
-STR_809A_UHL_ARMORED_TRUCK                                      :Uhl Armored Truck
-STR_809B_FOSTER_ARMORED_TRUCK                                   :Foster Armored Truck
-STR_809C_FOSTER_FOOD_VAN                                        :Foster Food Van
-STR_809D_PERRY_FOOD_VAN                                         :Perry Food Van
-STR_809E_CHIPPY_FOOD_VAN                                        :Chippy Food Van
-STR_809F_UHL_PAPER_TRUCK                                        :Uhl Paper Truck
-STR_80A0_BALOGH_PAPER_TRUCK                                     :Balogh Paper Truck
-STR_80A1_MPS_PAPER_TRUCK                                        :MPS Paper Truck
-STR_80A2_MPS_COPPER_ORE_TRUCK                                   :MPS Copper Ore Truck
-STR_80A3_UHL_COPPER_ORE_TRUCK                                   :Uhl Copper Ore Truck
-STR_80A4_GOSS_COPPER_ORE_TRUCK                                  :Goss Copper Ore Truck
-STR_80A5_UHL_WATER_TANKER                                       :Uhl Water Tanker
-STR_80A6_BALOGH_WATER_TANKER                                    :Balogh Water Tanker
-STR_80A7_MPS_WATER_TANKER                                       :MPS Water Tanker
-STR_80A8_BALOGH_FRUIT_TRUCK                                     :Balogh Fruit Truck
-STR_80A9_UHL_FRUIT_TRUCK                                        :Uhl Fruit Truck
-STR_80AA_KELLING_FRUIT_TRUCK                                    :Kelling Fruit Truck
-STR_80AB_BALOGH_RUBBER_TRUCK                                    :Balogh Rubber Truck
-STR_80AC_UHL_RUBBER_TRUCK                                       :Uhl Rubber Truck
-STR_80AD_RMT_RUBBER_TRUCK                                       :RMT Rubber Truck
-STR_80AE_MIGHTYMOVER_SUGAR_TRUCK                                :MightyMover Sugar Truck
-STR_80AF_POWERNAUGHT_SUGAR_TRUCK                                :Powernaught Sugar Truck
-STR_80B0_WIZZOWOW_SUGAR_TRUCK                                   :Wizzowow Sugar Truck
-STR_80B1_MIGHTYMOVER_COLA_TRUCK                                 :MightyMover Cola Truck
-STR_80B2_POWERNAUGHT_COLA_TRUCK                                 :Powernaught Cola Truck
-STR_80B3_WIZZOWOW_COLA_TRUCK                                    :Wizzowow Cola Truck
-STR_80B4_MIGHTYMOVER_COTTON_CANDY                               :MightyMover Cotton Candy Truck
-STR_80B5_POWERNAUGHT_COTTON_CANDY                               :Powernaught Cotton Candy Truck
-STR_80B6_WIZZOWOW_COTTON_CANDY_TRUCK                            :Wizzowow Cotton Candy Truck
-STR_80B7_MIGHTYMOVER_TOFFEE_TRUCK                               :MightyMover Toffee Truck
-STR_80B8_POWERNAUGHT_TOFFEE_TRUCK                               :Powernaught Toffee Truck
-STR_80B9_WIZZOWOW_TOFFEE_TRUCK                                  :Wizzowow Toffee Truck
-STR_80BA_MIGHTYMOVER_TOY_VAN                                    :MightyMover Toy Van
-STR_80BB_POWERNAUGHT_TOY_VAN                                    :Powernaught Toy Van
-STR_80BC_WIZZOWOW_TOY_VAN                                       :Wizzowow Toy Van
-STR_80BD_MIGHTYMOVER_CANDY_TRUCK                                :MightyMover Candy Truck
-STR_80BE_POWERNAUGHT_CANDY_TRUCK                                :Powernaught Candy Truck
-STR_80BF_WIZZOWOW_CANDY_TRUCK                                   :Wizzowow Candy Truck
-STR_80C0_MIGHTYMOVER_BATTERY_TRUCK                              :MightyMover Battery Truck
-STR_80C1_POWERNAUGHT_BATTERY_TRUCK                              :Powernaught Battery Truck
-STR_80C2_WIZZOWOW_BATTERY_TRUCK                                 :Wizzowow Battery Truck
-STR_80C3_MIGHTYMOVER_FIZZY_DRINK                                :MightyMover Fizzy Drink Truck
-STR_80C4_POWERNAUGHT_FIZZY_DRINK                                :Powernaught Fizzy Drink Truck
-STR_80C5_WIZZOWOW_FIZZY_DRINK_TRUCK                             :Wizzowow Fizzy Drink Truck
-STR_80C6_MIGHTYMOVER_PLASTIC_TRUCK                              :MightyMover Plastic Truck
-STR_80C7_POWERNAUGHT_PLASTIC_TRUCK                              :Powernaught Plastic Truck
-STR_80C8_WIZZOWOW_PLASTIC_TRUCK                                 :Wizzowow Plastic Truck
-STR_80C9_MIGHTYMOVER_BUBBLE_TRUCK                               :MightyMover Bubble Truck
-STR_80CA_POWERNAUGHT_BUBBLE_TRUCK                               :Powernaught Bubble Truck
-STR_80CB_WIZZOWOW_BUBBLE_TRUCK                                  :Wizzowow Bubble Truck
-STR_80CC_MPS_OIL_TANKER                                         :MPS Oil Tanker
-STR_80CD_CS_INC_OIL_TANKER                                      :CS-Inc. Oil Tanker
-STR_80CE_MPS_PASSENGER_FERRY                                    :MPS Passenger Ferry
-STR_80CF_FFP_PASSENGER_FERRY                                    :FFP Passenger Ferry
-STR_80D0_BAKEWELL_300_HOVERCRAFT                                :Bakewell 300 Hovercraft
-STR_80D1_CHUGGER_CHUG_PASSENGER                                 :Chugger-Chug Passenger Ferry
-STR_80D2_SHIVERSHAKE_PASSENGER_FERRY                            :Shivershake Passenger Ferry
-STR_80D3_YATE_CARGO_SHIP                                        :Yate Cargo ship
-STR_80D4_BAKEWELL_CARGO_SHIP                                    :Bakewell Cargo ship
-STR_80D5_MIGHTYMOVER_CARGO_SHIP                                 :Mightymover Cargo ship
-STR_80D6_POWERNAUT_CARGO_SHIP                                   :Powernaut Cargo ship
-STR_80D7_SAMPSON_U52                                            :Sampson U52
-STR_80D8_COLEMAN_COUNT                                          :Coleman Count
-STR_80D9_FFP_DART                                               :FFP Dart
-STR_80DA_YATE_HAUGAN                                            :Yate Haugan
-STR_80DB_BAKEWELL_COTSWALD_LB_3                                 :Bakewell Cotswald LB-3
-STR_80DC_BAKEWELL_LUCKETT_LB_8                                  :Bakewell Luckett LB-8
-STR_80DD_BAKEWELL_LUCKETT_LB_9                                  :Bakewell Luckett LB-9
-STR_80DE_BAKEWELL_LUCKETT_LB80                                  :Bakewell Luckett LB80
-STR_80DF_BAKEWELL_LUCKETT_LB_10                                 :Bakewell Luckett LB-10
-STR_80E0_BAKEWELL_LUCKETT_LB_11                                 :Bakewell Luckett LB-11
-STR_80E1_YATE_AEROSPACE_YAC_1_11                                :Yate Aerospace YAC 1-11
-STR_80E2_DARWIN_100                                             :Darwin 100
-STR_80E3_DARWIN_200                                             :Darwin 200
-STR_80E4_DARWIN_300                                             :Darwin 300
-STR_80E5_DARWIN_400                                             :Darwin 400
-STR_80E6_DARWIN_500                                             :Darwin 500
-STR_80E7_DARWIN_600                                             :Darwin 600
-STR_80E8_GURU_GALAXY                                            :Guru Galaxy
-STR_80E9_AIRTAXI_A21                                            :Airtaxi A21
-STR_80EA_AIRTAXI_A31                                            :Airtaxi A31
-STR_80EB_AIRTAXI_A32                                            :Airtaxi A32
-STR_80EC_AIRTAXI_A33                                            :Airtaxi A33
-STR_80ED_YATE_AEROSPACE_YAE46                                   :Yate Aerospace YAe46
-STR_80EE_DINGER_100                                             :Dinger 100
-STR_80EF_AIRTAXI_A34_1000                                       :AirTaxi A34-1000
-STR_80F0_YATE_Z_SHUTTLE                                         :Yate Z-Shuttle
-STR_80F1_KELLING_K1                                             :Kelling K1
-STR_80F2_KELLING_K6                                             :Kelling K6
-STR_80F3_KELLING_K7                                             :Kelling K7
-STR_80F4_DARWIN_700                                             :Darwin 700
-STR_80F5_FFP_HYPERDART_2                                        :FFP Hyperdart 2
-STR_80F6_DINGER_200                                             :Dinger 200
-STR_80F7_DINGER_1000                                            :Dinger 1000
-STR_80F8_PLODDYPHUT_100                                         :Ploddyphut 100
-STR_80F9_PLODDYPHUT_500                                         :Ploddyphut 500
-STR_80FA_FLASHBANG_X1                                           :Flashbang X1
-STR_80FB_JUGGERPLANE_M1                                         :Juggerplane M1
-STR_80FC_FLASHBANG_WIZZER                                       :Flashbang Wizzer
-STR_80FD_TRICARIO_HELICOPTER                                    :Tricario Helicopter
-STR_80FE_GURU_X2_HELICOPTER                                     :Guru X2 Helicopter
-STR_80FF_POWERNAUT_HELICOPTER                                   :Powernaut Helicopter
-STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE                       :{WHITE}Message from vehicle manufacturer
-STR_8101_WE_HAVE_JUST_DESIGNED_A                                :{GOLD}We have just designed a new {STRING} - would you be interested in a year's exclusive use of this vehicle, so we can see how it performs before making it universally available ?
-STR_8102_RAILROAD_LOCOMOTIVE                                    :railroad locomotive
-STR_8103_ROAD_VEHICLE                                           :road vehicle
-STR_8104_AIRCRAFT                                               :aircraft
-STR_8105_SHIP                                                   :ship
-STR_8106_MONORAIL_LOCOMOTIVE                                    :monorail locomotive
-STR_8107_MAGLEV_LOCOMOTIVE                                      :maglev locomotive
-
-##id 0x8800
-STR_8800_TRAIN_DEPOT                                            :{WHITE}{TOWN} Train Depot
-STR_8801_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First train arrives at {STATION}!
-STR_8802_DETAILS                                                :{WHITE}{VEHICLE} (Details)
-STR_8803_TRAIN_IN_THE_WAY                                       :{WHITE}Train in the way
-STR_8804                                                        :{SETX 10}{COMMA}: {STRING} {STRING}
-STR_8805                                                        :{RIGHTARROW}{SETX 10}{COMMA}: {STRING} {STRING}
-STR_8806_GO_TO                                                  :Go to {STATION}
-STR_8807_GO_TO_TRANSFER                                         :Go to {STATION} (Transfer and take cargo)
-STR_8808_GO_TO_UNLOAD                                           :Go to {STATION} (Unload)
-STR_8809_GO_TO_TRANSFER_UNLOAD                                  :Go to {STATION} (Transfer and leave empty)
-STR_880A_GO_TO_LOAD                                             :Go to {STATION} (Load)
-STR_880B_GO_TO_TRANSFER_LOAD                                    :Go to {STATION} (Transfer and wait for full load)
-STR_880C_GO_NON_STOP_TO                                         :Go non-stop to {STATION}
-STR_880D_GO_TO_NON_STOP_TRANSFER                                :Go non-stop to {STATION} (Transfer and take cargo)
-STR_880E_GO_NON_STOP_TO_UNLOAD                                  :Go non-stop to {STATION} (Unload)
-STR_880F_GO_TO_NON_STOP_TRANSFER_UNLOAD                         :Go non-stop to {STATION} (Transfer and leave empty)
-STR_8810_GO_NON_STOP_TO_LOAD                                    :Go non-stop to {STATION} (Load)
-STR_8811_GO_TO_NON_STOP_TRANSFER_LOAD                           :Go non-stop to {STATION} (Transfer and wait for full load)
-STR_GO_TO_TRAIN_DEPOT                                           :Go to {TOWN} Train Depot
-STR_SERVICE_AT_TRAIN_DEPOT                                      :Service at {TOWN} Train Depot
-STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT                             :Go non-stop to {TOWN} Train Depot
-STR_SERVICE_NON_STOP_AT_TRAIN_DEPOT                             :Service non-stop at {TOWN} Train Depot
-
-STR_TIMETABLE_GO_TO                                             :{STRING} {STRING}
-STR_TIMETABLE_TRAVEL_NOT_TIMETABLED                             :Travel (not timetabled)
-STR_TIMETABLE_TRAVEL_FOR                                        :Travel for {STRING}
-STR_TIMETABLE_STAY_FOR                                          :and stay for {STRING}
-STR_TIMETABLE_DAYS                                              :{COMMA} day{P "" s}
-STR_TIMETABLE_TICKS                                             :{COMMA} tick{P "" s}
-
-STR_HEADING_FOR_TRAIN_DEPOT                                     :{ORANGE}Heading for {TOWN} Train Depot
-STR_HEADING_FOR_TRAIN_DEPOT_VEL                                 :{ORANGE}Heading for {TOWN} Train Depot, {VELOCITY}
-STR_HEADING_FOR_TRAIN_DEPOT_SERVICE                             :{LTBLUE}Service at {TOWN} Train Depot
-STR_HEADING_FOR_TRAIN_DEPOT_SERVICE_VEL                         :{LTBLUE}Service at {TOWN} Train Depot, {VELOCITY}
-
-STR_INVALID_ORDER                                               :{RED} (Invalid Order)
-
-STR_UNKNOWN_DESTINATION                                         :unknown destination
-STR_8812_EMPTY                                                  :{LTBLUE}Empty
-STR_8813_FROM                                                   :{LTBLUE}{CARGO} from {STATION}
-STR_FROM_MULT                                                   :{LTBLUE}{CARGO} from {STATION} (x{NUM})
-STR_8814_TRAIN_IS_WAITING_IN_DEPOT                              :{WHITE}Train {COMMA} is waiting in depot
-STR_8815_NEW_VEHICLES                                           :{BLACK}New Vehicles
-STR_8816                                                        :{BLACK}-
-STR_8819_TRAIN_TOO_LONG                                         :{WHITE}Train too long
-STR_881A_TRAINS_CAN_ONLY_BE_ALTERED                             :{WHITE}Trains can only be altered when stopped inside a depot
-STR_881B_TRAINS                                                 :{WHITE}{COMPANY} - {COMMA} Train{P "" s}
-
-STR_881C_NEW_RAIL_VEHICLES                                      :{WHITE}New Rail Vehicles
-STR_NEW_ELRAIL_VEHICLES                                         :{WHITE}New Electric Rail Vehicles
-STR_881D_NEW_MONORAIL_VEHICLES                                  :{WHITE}New Monorail Vehicles
-STR_881E_NEW_MAGLEV_VEHICLES                                    :{WHITE}New Maglev Vehicles
-STR_ALL_AVAIL_RAIL_VEHICLES                                     :{WHITE}Rail Vehicles
-
-STR_881F_BUILD_VEHICLE                                          :{BLACK}Build Vehicle
-STR_CLONE_ROAD_VEHICLE                                          :{BLACK}Clone Vehicle
-STR_CLONE_ROAD_VEHICLE_INFO                                     :{BLACK}This will build a copy of the road vehicle. Control-click will share the orders
-STR_CLONE_ROAD_VEHICLE_DEPOT_INFO                               :{BLACK}This will build a copy of a road vehicle. Click this button and then on a road vehicle inside or outside the depot. Control-click will share the orders
-STR_CLONE_TRAIN                                                 :{BLACK}Clone Train
-STR_CLONE_TRAIN_INFO                                            :{BLACK}This will build a copy of the train including all cars. Control-click will share the orders
-STR_CLONE_TRAIN_DEPOT_INFO                                      :{BLACK}This will build a copy of a train including all cars. Click this button and then on a train inside or outside the depot. Control-click will share the orders
-STR_8820_RENAME                                                 :{BLACK}Rename
-STR_8823_SKIP                                                   :{BLACK}Skip
-STR_8824_DELETE                                                 :{BLACK}Delete
-STR_8825_NON_STOP                                               :{BLACK}Non-Stop
-STR_8826_GO_TO                                                  :{BLACK}Go To
-STR_8827_FULL_LOAD                                              :{BLACK}Full Load
-STR_8828_UNLOAD                                                 :{BLACK}Unload
-STR_REFIT                                                       :{BLACK}Refit
-STR_REFIT_TIP                                                   :{BLACK}Select what cargo type to refit to in this order. Control click to remove refit instruction
-STR_REFIT_ORDER                                                 :(Refit to {STRING})
-STR_TIMETABLE_VIEW                                              :{BLACK}Timetable
-STR_TIMETABLE_VIEW_TOOLTIP                                      :{BLACK}Switch to the timetable view
-STR_8829_ORDERS                                                 :{WHITE}{VEHICLE} (Orders)
-STR_882A_END_OF_ORDERS                                          :{SETX 10}- - End of Orders - -
-STR_FULLLOAD_OR_SERVICE                                         :{SKIP}{SKIP}{STRING}
-STR_SERVICE                                                     :{BLACK}Service
-STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE                           :{WHITE}Can't build railroad vehicle...
-STR_882C_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY}
-STR_882D_VALUE                                                  :{LTBLUE}{ENGINE}{BLACK}   Value: {LTBLUE}{CURRENCY}
-STR_882E                                                        :{WHITE}{VEHICLE}
-STR_882F_LOADING_UNLOADING                                      :{LTBLUE}Loading / Unloading
-STR_TRAIN_MUST_BE_STOPPED                                       :{WHITE}Train must be stopped inside a depot
-STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT                              :{WHITE}Can't send train to depot...
-STR_8831_NO_MORE_SPACE_FOR_ORDERS                               :{WHITE}No more space for orders
-STR_8832_TOO_MANY_ORDERS                                        :{WHITE}Too many orders
-STR_8833_CAN_T_INSERT_NEW_ORDER                                 :{WHITE}Can't insert new order...
-STR_8834_CAN_T_DELETE_THIS_ORDER                                :{WHITE}Can't delete this order...
-STR_8835_CAN_T_MODIFY_THIS_ORDER                                :{WHITE}Can't modify this order...
-STR_CAN_T_MOVE_THIS_ORDER                                       :{WHITE}Can't move this order...
-STR_CAN_T_SKIP_ORDER                                            :{WHITE}Can't skip current order...
-STR_CAN_T_SKIP_TO_ORDER                                         :{WHITE}Can't skip to selected order...
-STR_8837_CAN_T_MOVE_VEHICLE                                     :{WHITE}Can't move vehicle...
-STR_REAR_ENGINE_FOLLOW_FRONT_ERROR                              :{WHITE}The rear engine will always follow its front counterpart
-STR_8838_N_A                                                    :N/A{SKIP}
-STR_8839_CAN_T_SELL_RAILROAD_VEHICLE                            :{WHITE}Can't sell railroad vehicle...
-STR_883A_UNABLE_TO_FIND_ROUTE_TO                                :{WHITE}Unable to find route to local depot
-STR_883B_CAN_T_STOP_START_TRAIN                                 :{WHITE}Can't stop/start train...
-STR_883C_SERVICING_INTERVAL_DAYS                                :{BLACK}Servicing interval: {LTBLUE}{COMMA}days{BLACK}   Last service: {LTBLUE}{DATE_LONG}
-STR_SERVICING_INTERVAL_PERCENT                                  :{BLACK}Servicing interval: {LTBLUE}{COMMA}%{BLACK}   Last service: {LTBLUE}{DATE_LONG}
-STR_883D_TRAINS_CLICK_ON_TRAIN_FOR                              :{BLACK}Trains - click on train for information
-STR_883E_BUILD_NEW_TRAINS_REQUIRES                              :{BLACK}Build new trains (requires train depot)
-STR_883F_TRAINS_CLICK_ON_TRAIN_FOR                              :{BLACK}Trains - click on train for info., drag vehicle to add/remove from train
-STR_8840_BUILD_NEW_TRAIN_VEHICLE                                :{BLACK}Build new train vehicle
-STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE                             :{BLACK}Drag train vehicle to here to sell it
-STR_8842_CENTER_MAIN_VIEW_ON_TRAIN                              :{BLACK}Center main view on train depot location
-STR_8843_TRAIN_VEHICLE_SELECTION                                :{BLACK}Train vehicle selection list - click on vehicle for information
-STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN                            :{BLACK}Build the highlighted train vehicle
-STR_8845_RENAME_TRAIN_VEHICLE_TYPE                              :{BLACK}Rename train vehicle type
-STR_8846_CURRENT_TRAIN_ACTION_CLICK                             :{BLACK}Current train action - click here to stop/start train
-STR_8847_SHOW_TRAIN_S_ORDERS                                    :{BLACK}Show train's orders
-STR_8848_CENTER_MAIN_VIEW_ON_TRAIN                              :{BLACK}Center main view on train's location
-STR_8849_SEND_TRAIN_TO_DEPOT                                    :{BLACK}Send train to depot
-STR_884A_FORCE_TRAIN_TO_PROCEED                                 :{BLACK}Force train to proceed without waiting for signal to clear
-STR_884B_REVERSE_DIRECTION_OF_TRAIN                             :{BLACK}Reverse direction of train
-STR_884C_SHOW_TRAIN_DETAILS                                     :{BLACK}Show train details
-STR_884D_INCREASE_SERVICING_INTERVAL                            :{BLACK}Increase servicing interval
-STR_884E_DECREASE_SERVICING_INTERVAL                            :{BLACK}Decrease servicing interval
-STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED                          :{BLACK}Show details of cargo carried
-STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES                         :{BLACK}Show details of train vehicles
-STR_8851_SHOW_CAPACITIES_OF_EACH                                :{BLACK}Show capacities of each vehicle
-STR_8852_SHOW_TOTAL_CARGO                                       :{BLACK}Show total capacity of train, split by cargo type
-STR_8852_ORDERS_LIST_CLICK_ON_ORDER                             :{BLACK}Orders list - click on order to highlight it
-STR_8853_SKIP_THE_CURRENT_ORDER                                 :{BLACK}Skip the current order, and start the next. CTRL + click skips to the selected order)
-STR_8854_DELETE_THE_HIGHLIGHTED                                 :{BLACK}Delete the highlighted order
-STR_8855_MAKE_THE_HIGHLIGHTED_ORDER                             :{BLACK}Make the highlighted order non-stop
-STR_8856_INSERT_A_NEW_ORDER_BEFORE                              :{BLACK}Insert a new order before the highlighted order, or add to end of list
-STR_8857_MAKE_THE_HIGHLIGHTED_ORDER                             :{BLACK}Make the highlighted order force the vehicle to wait for a full load
-STR_8858_MAKE_THE_HIGHLIGHTED_ORDER                             :{BLACK}Make the highlighted order force the vehicle to unload
-STR_TIMETABLE_TOOLTIP                                           :{BLACK}Timetable - click on an order to highlight it.
-STR_TIMETABLE_WAIT_TIME_TOOLTIP                                 :{BLACK}Change the amount of time that the highlighted order should take
-STR_TIMETABLE_CLEAR_TIME_TOOLTIP                                :{BLACK}Clear the amount of time for the highlighted order
-STR_TIMETABLE_RESET_LATENESS_TOOLTIP                            :{BLACK}Reset the lateness counter, so the vehicle will be on time
-STR_SERVICE_HINT                                                :{BLACK}Skip this order unless a service is needed
-STR_VEHICLE_INFO_COST_WEIGHT_SPEED_POWER                        :{BLACK}Cost: {CURRENCY} Weight: {WEIGHT_S}{}Speed: {VELOCITY}  Power: {POWER}{}Running Cost: {CURRENCY}/yr{}Capacity: {CARGO}
-STR_885C_BROKEN_DOWN                                            :{RED}Broken down
-STR_885D_AGE_RUNNING_COST_YR                                    :{BLACK}Age: {LTBLUE}{STRING}{BLACK}   Running Cost: {LTBLUE}{CURRENCY}/yr
-STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED                         :{BLACK}Weight: {LTBLUE}{WEIGHT_S}  {BLACK}Power: {LTBLUE}{POWER}{BLACK} Max. speed: {LTBLUE}{VELOCITY}
-STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE                  :{BLACK}Weight: {LTBLUE}{WEIGHT_S} {BLACK}Power: {LTBLUE}{POWER}{BLACK} Max. speed: {LTBLUE}{VELOCITY} {BLACK}Max. T.E.: {LTBLUE}{FORCE}
-STR_885F_PROFIT_THIS_YEAR_LAST_YEAR                             :{BLACK}Profit this year: {LTBLUE}{CURRENCY}  (last year: {CURRENCY})
-STR_8860_RELIABILITY_BREAKDOWNS                                 :{BLACK}Reliability: {LTBLUE}{COMMA}%  {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
-STR_8861_STOPPED                                                :{RED}Stopped
-STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL                           :{WHITE}Can't make train pass signal at danger...
-STR_8863_CRASHED                                                :{RED}Crashed!
-
-STR_8865_NAME_TRAIN                                             :{WHITE}Name train
-STR_8866_CAN_T_NAME_TRAIN                                       :{WHITE}Can't name train...
-STR_8867_NAME_TRAIN                                             :{BLACK}Name train
-STR_8868_TRAIN_CRASH_DIE_IN_FIREBALL                            :{BLACK}{BIGFONT}Train Crash!{}{COMMA} die in fireball after collision
-STR_8869_CAN_T_REVERSE_DIRECTION                                :{WHITE}Can't reverse direction of train...
-STR_886A_RENAME_TRAIN_VEHICLE_TYPE                              :{WHITE}Rename train vehicle type
-STR_886B_CAN_T_RENAME_TRAIN_VEHICLE                             :{WHITE}Can't rename train vehicle type...
-STR_886D_MAKE_THE_HIGHLIGHTED_ORDER                             :{BLACK}Make the highlighted order force the vehicle to dump cargo
-STR_886F_TRANSFER                                               :{BLACK}Transfer
-STR_CLEAR_TIME                                                  :{BLACK}Clear Time
-STR_RESET_LATENESS                                              :{BLACK}Reset Late Counter
-
-STR_TRAIN_STOPPING                                              :{RED}Stopping
-STR_TRAIN_STOPPING_VEL                                          :{RED}Stopping, {VELOCITY}
-STR_INCOMPATIBLE_RAIL_TYPES                                     :Incompatible rail types
-STR_TRAIN_NO_POWER                                              :{RED}No power
-STR_TRAIN_START_NO_CATENARY                                     :This track lacks catenary, so the train can't start
-
-STR_NEW_VEHICLE_NOW_AVAILABLE                                   :{BLACK}{BIGFONT}New {STRING} now available!
-STR_NEW_VEHICLE_TYPE                                            :{BLACK}{BIGFONT}{ENGINE}
-STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}New {STRING} now available!  -  {ENGINE}
-
-STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Can't sell destroyed vehicle...
-
-STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Can't timetable vehicle...
-STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Vehicles can only wait at stations.
-STR_TIMETABLE_NOT_STOPPING_HERE                                 :{WHITE}This vehicle is not stopping at this station.
-STR_TIMETABLE_CHANGE_TIME                                       :{BLACK}Change Time
-STR_TIMETABLE_STATUS_ON_TIME                                    :This vehicle is currently running on time
-STR_TIMETABLE_STATUS_LATE                                       :This vehicle is currently running {STRING} late
-STR_TIMETABLE_STATUS_EARLY                                      :This vehicle is currently running {STRING} early
-STR_TIMETABLE_TOTAL_TIME                                        :This timetable will take {STRING} to complete
-STR_TIMETABLE_TOTAL_TIME_INCOMPLETE                             :This timetable will take at least {STRING} to complete (not all timetabled)
-STR_TIMETABLE_AUTOFILL                                          :{BLACK}Autofill
-STR_TIMETABLE_AUTOFILL_TOOLTIP                                  :{BLACK}Fill the timetable automatically with the values from the first journey
-
-##id 0x9000
-STR_9000_ROAD_VEHICLE_IN_THE_WAY                                :{WHITE}Road vehicle in the way
-STR_9001_ROAD_VEHICLES                                          :{WHITE}{COMPANY} - {COMMA} Road Vehicle{P "" s}
-STR_9002                                                        :{WHITE}{VEHICLE}
-STR_9003_ROAD_VEHICLE_DEPOT                                     :{WHITE}{TOWN} Road Vehicle Depot
-STR_9004_NEW_VEHICLES                                           :{BLACK}New Vehicles
-STR_9006_NEW_ROAD_VEHICLES                                      :{WHITE}New Road Vehicles
-STR_9007_BUILD_VEHICLE                                          :{BLACK}Build Vehicle
-STR_9009_CAN_T_BUILD_ROAD_VEHICLE                               :{WHITE}Can't build road vehicle...
-STR_900C_DETAILS                                                :{WHITE}{VEHICLE} (Details)
-STR_900D_AGE_RUNNING_COST_YR                                    :{BLACK}Age: {LTBLUE}{STRING}{BLACK}   Running Cost: {LTBLUE}{CURRENCY}/yr
-STR_900E_MAX_SPEED                                              :{BLACK}Max. speed: {LTBLUE}{VELOCITY}
-STR_900F_PROFIT_THIS_YEAR_LAST_YEAR                             :{BLACK}Profit this year: {LTBLUE}{CURRENCY}  (last year: {CURRENCY})
-STR_9010_RELIABILITY_BREAKDOWNS                                 :{BLACK}Reliability: {LTBLUE}{COMMA}%  {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
-STR_9011_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY}
-STR_9012_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}
-STR_9013_MUST_BE_STOPPED_INSIDE                                 :{WHITE}...must be stopped inside a road vehicle depot
-STR_9014_CAN_T_SELL_ROAD_VEHICLE                                :{WHITE}Can't sell road vehicle...
-STR_9015_CAN_T_STOP_START_ROAD_VEHICLE                          :{WHITE}Can't stop/start road vehicle...
-STR_9016_ROAD_VEHICLE_IS_WAITING                                :{WHITE}Road Vehicle {COMMA} is waiting in depot
-STR_HEADING_FOR_ROAD_DEPOT                                      :{ORANGE}Heading for {TOWN} Road Depot
-STR_HEADING_FOR_ROAD_DEPOT_VEL                                  :{ORANGE}Heading for {TOWN} Road Depot, {VELOCITY}
-STR_HEADING_FOR_ROAD_DEPOT_SERVICE                              :{LTBLUE}Service at {TOWN} Road Depot
-STR_HEADING_FOR_ROAD_DEPOT_SERVICE_VEL                          :{LTBLUE}Service at {TOWN} Road Depot, {VELOCITY}
-STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT                            :{WHITE}Can't send vehicle to depot...
-STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT                             :{WHITE}Unable to find local depot
-STR_901A_ROAD_VEHICLES_CLICK_ON                                 :{BLACK}Road vehicles - click on vehicle for information
-STR_901B_BUILD_NEW_ROAD_VEHICLES                                :{BLACK}Build new road vehicles (requires road vehicle depot)
-STR_901C_CURRENT_VEHICLE_ACTION                                 :{BLACK}Current vehicle action - click here to stop/start vehicle
-STR_901D_SHOW_VEHICLE_S_ORDERS                                  :{BLACK}Show vehicle's orders
-STR_901E_CENTER_MAIN_VIEW_ON_VEHICLE                            :{BLACK}Center main view on vehicle's location
-STR_901F_SEND_VEHICLE_TO_DEPOT                                  :{BLACK}Send vehicle to depot
-STR_9020_FORCE_VEHICLE_TO_TURN_AROUND                           :{BLACK}Force vehicle to turn around
-STR_9021_SHOW_ROAD_VEHICLE_DETAILS                              :{BLACK}Show road vehicle details
-STR_9022_VEHICLES_CLICK_ON_VEHICLE                              :{BLACK}Vehicles - click on vehicle for information
-STR_9023_BUILD_NEW_ROAD_VEHICLE                                 :{BLACK}Build new road vehicle
-STR_9024_DRAG_ROAD_VEHICLE_TO_HERE                              :{BLACK}Drag road vehicle to here to sell it
-STR_9025_CENTER_MAIN_VIEW_ON_ROAD                               :{BLACK}Center main view on road vehicle depot location
-STR_9026_ROAD_VEHICLE_SELECTION                                 :{BLACK}Road vehicle selection list - click on vehicle for information
-STR_9027_BUILD_THE_HIGHLIGHTED_ROAD                             :{BLACK}Build the highlighted road vehicle
-STR_902A_COST_SPEED_RUNNING_COST                                :{BLACK}Cost: {CURRENCY}{}Speed: {VELOCITY}{}Running Cost: {CURRENCY}/yr{}Capacity: {CARGO}
-STR_ARTICULATED_RV_CAPACITY                                     :{BLACK}Capacity: {LTBLUE}
-STR_BARE_CARGO                                                  :{CARGO}
-
-STR_902C_NAME_ROAD_VEHICLE                                      :{WHITE}Name road vehicle
-STR_902D_CAN_T_NAME_ROAD_VEHICLE                                :{WHITE}Can't name road vehicle...
-STR_902E_NAME_ROAD_VEHICLE                                      :{BLACK}Name road vehicle
-STR_902F_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First bus arrives at {STATION}!
-STR_9030_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First truck arrives at {STATION}!
-STR_902F_CITIZENS_CELEBRATE_FIRST_TRAM                          :{BLACK}{BIGFONT}Citizens celebrate . . .{}First passenger tram arrives at {STATION}!
-STR_9030_CITIZENS_CELEBRATE_FIRST_TRAM                          :{BLACK}{BIGFONT}Citizens celebrate . . .{}First freight tram arrives at {STATION}!
-STR_9031_ROAD_VEHICLE_CRASH_DRIVER                              :{BLACK}{BIGFONT}Road Vehicle Crash!{}Driver dies in fireball after collision with train
-STR_9032_ROAD_VEHICLE_CRASH_DIE                                 :{BLACK}{BIGFONT}Road Vehicle Crash!{}{COMMA} die in fireball after collision with train
-STR_9033_CAN_T_MAKE_VEHICLE_TURN                                :{WHITE}Can't make vehicle turn around...
-STR_ONLY_TURN_SINGLE_UNIT                                       :{WHITE}Can't turn vehicles consisting of multiple units
-STR_9034_RENAME                                                 :{BLACK}Rename
-STR_9035_RENAME_ROAD_VEHICLE_TYPE                               :{BLACK}Rename road vehicle type
-STR_9036_RENAME_ROAD_VEHICLE_TYPE                               :{WHITE}Rename road vehicle type
-STR_9037_CAN_T_RENAME_ROAD_VEHICLE                              :{WHITE}Can't rename road vehicle type...
-STR_9038_GO_TO_ROADVEH_DEPOT                                    :Go to {TOWN} Road Vehicle Depot
-STR_SERVICE_AT_ROADVEH_DEPOT                                    :Service at {TOWN} Road Vehicle Depot
-
-STR_REFIT_ROAD_VEHICLE_TO_CARRY                                 :{BLACK}Refit road vehicle to carry a different cargo type
-STR_REFIT_ROAD_VEHICLE                                          :{BLACK}Refit road vehicle
-STR_REFIT_ROAD_VEHICLE_TO_CARRY_HIGHLIGHTED                     :{BLACK}Refit road vehicle to carry highlighted cargo type
-STR_REFIT_ROAD_VEHICLE_CAN_T                                    :{WHITE}Can't refit road vehicle...
-STR_ROAD_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Select type of cargo for road vehicle to carry
-
-##id 0x9800
-STR_9800_DOCK_CONSTRUCTION                                      :Dock construction
-STR_9801_DOCK_CONSTRUCTION                                      :{WHITE}Dock construction
-STR_9802_CAN_T_BUILD_DOCK_HERE                                  :{WHITE}Can't build dock here...
-STR_9803_SHIP_DEPOT                                             :{WHITE}{TOWN} Ship Depot
-STR_9804_NEW_SHIPS                                              :{BLACK}New Ships
-STR_9805_SHIPS                                                  :{WHITE}{COMPANY} - {COMMA} Ship{P "" s}
-STR_9808_NEW_SHIPS                                              :{WHITE}New Ships
-STR_9809_BUILD_SHIP                                             :{BLACK}Build Ship
-STR_CLONE_SHIP                                                  :{BLACK}Clone Ship
-STR_CLONE_SHIP_INFO                                             :{BLACK}This will build a copy of the ship. Control-click will share the orders
-STR_CLONE_SHIP_DEPOT_INFO                                       :{BLACK}This will build a copy of a ship. Click this button and then on a ship inside or outside the depot. Control-click will share the orders
-STR_980B_SHIP_MUST_BE_STOPPED_IN                                :{WHITE}Ship must be stopped in depot
-STR_980C_CAN_T_SELL_SHIP                                        :{WHITE}Can't sell ship...
-STR_980D_CAN_T_BUILD_SHIP                                       :{WHITE}Can't build ship...
-STR_980E_SHIP_IN_THE_WAY                                        :{WHITE}Ship in the way
-STR_980F                                                        :{WHITE}{VEHICLE}
-STR_9811_DETAILS                                                :{WHITE}{VEHICLE} (Details)
-STR_9812_AGE_RUNNING_COST_YR                                    :{BLACK}Age: {LTBLUE}{STRING}{BLACK}   Running Cost: {LTBLUE}{CURRENCY}/yr
-STR_9813_MAX_SPEED                                              :{BLACK}Max. speed: {LTBLUE}{VELOCITY}
-STR_9814_PROFIT_THIS_YEAR_LAST_YEAR                             :{BLACK}Profit this year: {LTBLUE}{CURRENCY}  (last year: {CURRENCY})
-STR_9815_RELIABILITY_BREAKDOWNS                                 :{BLACK}Reliability: {LTBLUE}{COMMA}%  {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
-STR_9816_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY}
-STR_9817_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}
-STR_9818_CAN_T_STOP_START_SHIP                                  :{WHITE}Can't stop/start ship...
-STR_9819_CAN_T_SEND_SHIP_TO_DEPOT                               :{WHITE}Can't send ship to depot...
-STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT                             :{WHITE}Unable to find local depot
-STR_HEADING_FOR_SHIP_DEPOT                                      :{ORANGE}Heading for {TOWN} Ship Depot
-STR_HEADING_FOR_SHIP_DEPOT_VEL                                  :{ORANGE}Heading for {TOWN} Ship Depot, {VELOCITY}
-STR_HEADING_FOR_SHIP_DEPOT_SERVICE                              :{LTBLUE}Service at {TOWN} Ship Depot
-STR_HEADING_FOR_SHIP_DEPOT_SERVICE_VEL                          :{LTBLUE}Service at {TOWN} Ship Depot, {VELOCITY}
-STR_981C_SHIP_IS_WAITING_IN_DEPOT                               :{WHITE}Ship {COMMA} is waiting in depot
-STR_981D_BUILD_SHIP_DOCK                                        :{BLACK}Build ship dock
-STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING                          :{BLACK}Build ship depot (for building and servicing ships)
-STR_981F_SHIPS_CLICK_ON_SHIP_FOR                                :{BLACK}Ships - click on ship for information
-STR_9820_BUILD_NEW_SHIP                                         :{BLACK}Build new ship
-STR_9821_DRAG_SHIP_TO_HERE_TO_SELL                              :{BLACK}Drag ship to here to sell it
-STR_9822_CENTER_MAIN_VIEW_ON_SHIP                               :{BLACK}Center main view on ship depot location
-STR_9823_SHIPS_CLICK_ON_SHIP_FOR                                :{BLACK}Ships - click on ship for information
-STR_9824_BUILD_NEW_SHIPS_REQUIRES                               :{BLACK}Build new ships (requires ship depot)
-STR_9825_SHIP_SELECTION_LIST_CLICK                              :{BLACK}Ship selection list - click on ship for information
-STR_9826_BUILD_THE_HIGHLIGHTED_SHIP                             :{BLACK}Build the highlighted ship
-STR_9827_CURRENT_SHIP_ACTION_CLICK                              :{BLACK}Current ship action - click here to stop/start ship
-STR_9828_SHOW_SHIP_S_ORDERS                                     :{BLACK}Show ship's orders
-STR_9829_CENTER_MAIN_VIEW_ON_SHIP                               :{BLACK}Center main view on ship's location
-STR_982A_SEND_SHIP_TO_DEPOT                                     :{BLACK}Send ship to depot
-STR_982B_SHOW_SHIP_DETAILS                                      :{BLACK}Show ship details
-STR_982E_COST_MAX_SPEED_CAPACITY                                :{BLACK}Cost: {CURRENCY} Max. Speed: {VELOCITY}{}Capacity: {CARGO}{}Running Cost: {CURRENCY}/yr
-STR_982F_NAME_SHIP                                              :{BLACK}Name ship
-
-STR_9831_NAME_SHIP                                              :{WHITE}Name ship
-STR_9832_CAN_T_NAME_SHIP                                        :{WHITE}Can't name ship...
-STR_9833_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First ship arrives at {STATION}!
-STR_9834_POSITION_BUOY_WHICH_CAN                                :{BLACK}Place a buoy which can be used as a waypoint
-STR_9835_CAN_T_POSITION_BUOY_HERE                               :{WHITE}Can't place buoy here...
-STR_9836_RENAME                                                 :{BLACK}Rename
-STR_9837_RENAME_SHIP_TYPE                                       :{BLACK}Rename ship type
-STR_9838_RENAME_SHIP_TYPE                                       :{WHITE}Rename ship type
-STR_9839_CAN_T_RENAME_SHIP_TYPE                                 :{WHITE}Can't rename ship type...
-STR_983A_REFIT_CARGO_SHIP_TO_CARRY                              :{BLACK}Refit cargo ship to carry a different cargo type
-STR_983B_REFIT                                                  :{WHITE}{VEHICLE} (Refit)
-STR_983C_REFIT_SHIP                                             :{BLACK}Refit ship
-STR_983D_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Select type of cargo for ship to carry
-STR_983E_REFIT_SHIP_TO_CARRY_HIGHLIGHTED                        :{BLACK}Refit ship to carry highlighted cargo type
-STR_983F_SELECT_CARGO_TYPE_TO_CARRY                             :{GOLD}Select cargo type to carry:
-STR_9840_NEW_CAPACITY_COST_OF_REFIT                             :{BLACK}New capacity: {GOLD}{CARGO}{}{BLACK}Cost of refit: {GOLD}{CURRENCY}
-STR_9841_CAN_T_REFIT_SHIP                                       :{WHITE}Can't refit ship...
-STR_9842_REFITTABLE                                             :(refittable)
-STR_GO_TO_SHIP_DEPOT                                            :Go to {TOWN} Ship Depot
-SERVICE_AT_SHIP_DEPOT                                           :Service at {TOWN} Ship Depot
-
-##id 0xA000
-STR_A000_AIRPORTS                                               :{WHITE}Airports
-STR_A001_CAN_T_BUILD_AIRPORT_HERE                               :{WHITE}Can't build airport here...
-STR_A002_AIRCRAFT_HANGAR                                        :{WHITE}{STATION} Aircraft Hangar
-STR_A003_NEW_AIRCRAFT                                           :{BLACK}New Aircraft
-STR_CLONE_AIRCRAFT                                              :{BLACK}Clone Aircraft
-STR_CLONE_AIRCRAFT_INFO                                         :{BLACK}This will build a copy of the aircraft. Control-click will share the orders
-STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW                           :{BLACK}This will build a copy of an aircraft. Click this button and then on an aircraft inside or outside the hangar. Control-click will share the orders
-STR_A005_NEW_AIRCRAFT                                           :{WHITE}New Aircraft
-STR_A006_BUILD_AIRCRAFT                                         :{BLACK}Build Aircraft
-STR_A008_CAN_T_BUILD_AIRCRAFT                                   :{WHITE}Can't build aircraft...
-STR_A009_AIRCRAFT                                               :{WHITE}{COMPANY} - {COMMA} Aircraft
-STR_A00A                                                        :{WHITE}{VEHICLE}
-STR_A00B_ORDERS                                                 :{WHITE}{VEHICLE} (Orders)
-STR_A00C_DETAILS                                                :{WHITE}{VEHICLE} (Details)
-STR_A00D_AGE_RUNNING_COST_YR                                    :{BLACK}Age: {LTBLUE}{STRING}{BLACK}   Running Cost: {LTBLUE}{CURRENCY}/yr
-STR_A00E_MAX_SPEED                                              :{BLACK}Max. speed: {LTBLUE}{VELOCITY}
-STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR                             :{BLACK}Profit this year: {LTBLUE}{CURRENCY}  (last year: {CURRENCY})
-STR_A010_RELIABILITY_BREAKDOWNS                                 :{BLACK}Reliability: {LTBLUE}{COMMA}%  {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
-STR_A011_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY}
-STR_A012_CAN_T_SEND_AIRCRAFT_TO                                 :{WHITE}Can't send aircraft to hangar...
-STR_HEADING_FOR_HANGAR                                          :{ORANGE}Heading for {STATION} Hangar
-STR_HEADING_FOR_HANGAR_VEL                                      :{ORANGE}Heading for {STATION} Hangar, {VELOCITY}
-STR_HEADING_FOR_HANGAR_SERVICE                                  :{LTBLUE}Service at {STATION} Hangar
-STR_HEADING_FOR_HANGAR_SERVICE_VEL                              :{LTBLUE}Service at {STATION} Hangar, {VELOCITY}
-STR_A014_AIRCRAFT_IS_WAITING_IN                                 :{WHITE}Aircraft {COMMA} is waiting in the aircraft hangar
-STR_A015_AIRCRAFT_IN_THE_WAY                                    :{WHITE}Aircraft in the way
-STR_A016_CAN_T_STOP_START_AIRCRAFT                              :{WHITE}Can't stop/start aircraft...
-STR_A017_AIRCRAFT_IS_IN_FLIGHT                                  :{WHITE}Aircraft is in flight
-STR_A019_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}, {CARGO}
-STR_A01A_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}
-STR_A01B_AIRCRAFT_MUST_BE_STOPPED                               :{WHITE}Aircraft must be stopped in hangar
-STR_A01C_CAN_T_SELL_AIRCRAFT                                    :{WHITE}Can't sell aircraft...
-STR_A01D_AIRPORT_CONSTRUCTION                                   :Airport construction
-STR_A01E_BUILD_AIRPORT                                          :{BLACK}Build airport
-STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT                             :{BLACK}Aircraft - click on aircraft for information
-STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES                            :{BLACK}Build new aircraft (requires airport with hangar)
-STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT                             :{BLACK}Aircraft - click on aircraft for information
-STR_A022_BUILD_NEW_AIRCRAFT                                     :{BLACK}Build new aircraft
-STR_A023_DRAG_AIRCRAFT_TO_HERE_TO                               :{BLACK}Drag aircraft to here to sell it
-STR_A024_CENTER_MAIN_VIEW_ON_HANGAR                             :{BLACK}Center main view on hangar location
-STR_A025_AIRCRAFT_SELECTION_LIST                                :{BLACK}Aircraft selection list - click on aircraft for information
-STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT                         :{BLACK}Build the highlighted aircraft
-STR_A027_CURRENT_AIRCRAFT_ACTION                                :{BLACK}Current aircraft action - click here to stop/start aircraft
-STR_A028_SHOW_AIRCRAFT_S_ORDERS                                 :{BLACK}Show aircraft's orders
-STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT                           :{BLACK}Center main view on aircraft's location
-STR_A02A_SEND_AIRCRAFT_TO_HANGAR                                :{BLACK}Send aircraft to hangar
-STR_A02B_SHOW_AIRCRAFT_DETAILS                                  :{BLACK}Show aircraft details
-STR_A02E_COST_MAX_SPEED_CAPACITY                                :{BLACK}Cost: {CURRENCY} Max. Speed: {VELOCITY}{}Capacity: {COMMA} passengers, {COMMA} bags of mail{}Running Cost: {CURRENCY}/yr
-
-STR_A030_NAME_AIRCRAFT                                          :{WHITE}Name aircraft
-STR_A031_CAN_T_NAME_AIRCRAFT                                    :{WHITE}Can't name aircraft...
-STR_A032_NAME_AIRCRAFT                                          :{BLACK}Name aircraft
-STR_A033_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First aircraft arrives at {STATION}!
-STR_A034_PLANE_CRASH_DIE_IN_FIREBALL                            :{BLACK}{BIGFONT}Plane Crash!{}{COMMA} die in fireball at {STATION}
-STR_PLANE_CRASH_OUT_OF_FUEL                                     :{BLACK}{BIGFONT}Plane Crash!{}Aircraft ran out of fuel, {COMMA} die in fireball!
-STR_A036                                                        :{TINYFONT}{BLACK}{STATION}
-STR_A037_RENAME                                                 :{BLACK}Rename
-STR_A038_RENAME_AIRCRAFT_TYPE                                   :{BLACK}Rename aircraft type
-STR_A039_RENAME_AIRCRAFT_TYPE                                   :{WHITE}Rename aircraft type
-STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE                             :{WHITE}Can't rename aircraft type...
-STR_A03B_REFIT_AIRCRAFT_TO_CARRY                                :{BLACK}Refit aircraft to carry a different cargo type
-STR_A03C_REFIT                                                  :{WHITE}{VEHICLE} (Refit)
-STR_A03D_REFIT_AIRCRAFT                                         :{BLACK}Refit aircraft
-STR_A03E_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Select type of cargo for aircraft to carry
-STR_A03F_REFIT_AIRCRAFT_TO_CARRY                                :{BLACK}Refit aircraft to carry highlighted cargo type
-STR_A040_SELECT_CARGO_TYPE_TO_CARRY                             :{GOLD}Select cargo type to carry:
-STR_A041_NEW_CAPACITY_COST_OF_REFIT                             :{BLACK}New capacity: {GOLD}{STRING}{}{BLACK}Cost of refit: {GOLD}{CURRENCY}
-STR_A042_CAN_T_REFIT_AIRCRAFT                                   :{WHITE}Can't refit aircraft...
-STR_GO_TO_AIRPORT_HANGAR                                        :Go to {STATION} Hangar
-SERVICE_AT_AIRPORT_HANGAR                                       :Service at {STATION} Hangar
-
-STR_TIMETABLE_TITLE                                             :{WHITE}{VEHICLE} (Timetable)
-
-##id 0xB000
-STR_B000_ZEPPELIN_DISASTER_AT                                   :{BLACK}{BIGFONT}Zeppelin disaster at {STATION}!
-STR_B001_ROAD_VEHICLE_DESTROYED                                 :{BLACK}{BIGFONT}Road vehicle destroyed in 'UFO' collision!
-STR_B002_OIL_REFINERY_EXPLOSION                                 :{BLACK}{BIGFONT}Oil refinery explosion near {TOWN}!
-STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS                        :{BLACK}{BIGFONT}Factory destroyed in suspicious circumstances near {TOWN}!
-STR_B004_UFO_LANDS_NEAR                                         :{BLACK}{BIGFONT}'UFO' lands near {TOWN}!
-STR_B005_COAL_MINE_SUBSIDENCE_LEAVES                            :{BLACK}{BIGFONT}Coal mine subsidence leaves trail of destruction near {TOWN}!
-STR_B006_FLOOD_VEHICLE_DESTROYED                                :{BLACK}{BIGFONT}Floods!{}At least {COMMA} missing, presumed dead after significant flooding!
-
-STR_BRIBE_FAILED                                                :{WHITE}Your attempted bribery has been
-STR_BRIBE_FAILED_2                                              :{WHITE}discovered by a regional investigator
-STR_BUILD_DATE                                                  :{BLACK}Built: {LTBLUE}{DATE_LONG}
-
-STR_PERFORMANCE_DETAIL                                          :{WHITE}Detailed performance rating
-STR_PERFORMANCE_DETAIL_KEY                                      :{BLACK}Detail
-STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY                          :{BLACK}({CURRCOMPACT}/{CURRCOMPACT})
-STR_PERFORMANCE_DETAIL_AMOUNT_INT                               :{BLACK}({COMMA}/{COMMA})
-STR_PERFORMANCE_DETAIL_PERCENT                                  :{WHITE}{NUM}%
-SET_PERFORMANCE_DETAIL_INT                                      :{BLACK}{NUM}
-############ Those following lines need to be in this order!!
-STR_PERFORMANCE_DETAIL_VEHICLES                                 :{BLACK}Vehicles:
-STR_PERFORMANCE_DETAIL_STATIONS                                 :{BLACK}Stations:
-STR_PERFORMANCE_DETAIL_MIN_PROFIT                               :{BLACK}Min. profit:
-STR_PERFORMANCE_DETAIL_MIN_INCOME                               :{BLACK}Min. income:
-STR_PERFORMANCE_DETAIL_MAX_INCOME                               :{BLACK}Max. income:
-STR_PERFORMANCE_DETAIL_DELIVERED                                :{BLACK}Delivered:
-STR_PERFORMANCE_DETAIL_CARGO                                    :{BLACK}Cargo:
-STR_PERFORMANCE_DETAIL_MONEY                                    :{BLACK}Money:
-STR_PERFORMANCE_DETAIL_LOAN                                     :{BLACK}Loan:
-STR_PERFORMANCE_DETAIL_TOTAL                                    :{BLACK}Total:
-############ End of order list
-STR_PERFORMANCE_DETAIL_VEHICLES_TIP                             :{BLACK}Number of vehicles; this includes road vehicles, trains, ships and aircraft
-STR_PERFORMANCE_DETAIL_STATIONS_TIP                             :{BLACK}Number of station parts. Every part of a station (e.g. train station, bus stop, airport) is counted, even if they are connected to one station.
-STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP                           :{BLACK}The profit of the vehicle with the lowest income (of all vehicles older than 2 years)
-STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP                           :{BLACK}Amount of cash made in the month with the lowest profit of the past 12 quarters
-STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP                           :{BLACK}Amount of cash made in the month with the highest profit of the past 12 quarters
-STR_PERFORMANCE_DETAIL_DELIVERED_TIP                            :{BLACK}Units of cargo delivered in the past four quarters.
-STR_PERFORMANCE_DETAIL_CARGO_TIP                                :{BLACK}Number of types of cargo delivered in the past quarter.
-STR_PERFORMANCE_DETAIL_MONEY_TIP                                :{BLACK}Amount of money this company has in the bank
-STR_PERFORMANCE_DETAIL_LOAN_TIP                                 :{BLACK}The amount of money this company has taken on loan
-STR_PERFORMANCE_DETAIL_TOTAL_TIP                                :{BLACK}Total points out of possible points
-
-STR_NEWGRF_SETTINGS_BUTTON                                      :{BLACK}NewGRF Settings
-STR_NEWGRF_SETTINGS_CAPTION                                     :{WHITE}Newgrf settings
-STR_NEWGRF_APPLY_CHANGES                                        :{BLACK}Apply changes
-STR_NEWGRF_SET_PARAMETERS                                       :{BLACK}Set parameters
-STR_NEWGRF_TIP                                                  :{BLACK}A list of all the Newgrf sets that you have installed. Click a set to change the settings.
-STR_NEWGRF_NO_FILES_INSTALLED                                   :{BLACK}There are currently no newgrf files installed! Please refer to the manual for instructions to install new graphics.
-STR_NEWGRF_FILENAME                                             :{BLACK}Filename: {SILVER}{STRING}
-STR_NEWGRF_GRF_ID                                               :{BLACK}GRF ID: {SILVER}{STRING}
-STR_NEWGRF_MD5SUM                                               :{BLACK}MD5sum: {SILVER}{STRING}
-STR_NEWGRF_CONFIRMATION_TEXT                                    :{YELLOW}You are about to make changes to a running game; this can crash OpenTTD.{}Are you absolutely sure about this?
-
-STR_NEWGRF_ERROR_MSG_INFO                                       :{SILVER}{STRING}
-STR_NEWGRF_ERROR_MSG_WARNING                                    :{RED}Warning: {SILVER}{STRING}
-STR_NEWGRF_ERROR_MSG_ERROR                                      :{RED}Error: {SILVER}{STRING}
-STR_NEWGRF_ERROR_MSG_FATAL                                      :{RED}Fatal: {SILVER}{STRING}
-STR_NEWGRF_ERROR_VERSION_NUMBER                                 :{STRING} will not work with the TTDPatch version reported by OpenTTD.
-STR_NEWGRF_ERROR_DOS_OR_WINDOWS                                 :{STRING} is for the {STRING} version of TTD.
-STR_NEWGRF_ERROR_UNSET_SWITCH                                   :{STRING} is designed to be used with {STRING}
-STR_NEWGRF_ERROR_INVALID_PARAMETER                              :Invalid parameter for {STRING}: parameter {STRING} ({NUM})
-STR_NEWGRF_ERROR_LOAD_BEFORE                                    :{STRING} must be loaded before {STRING}.
-STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} must be loaded after {STRING}.
-STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :the GRF file it was designed to translate
-
-STR_NEWGRF_ADD                                                  :{BLACK}Add
-STR_NEWGRF_ADD_TIP                                              :{BLACK}Add a NewGRF file to the list
-STR_NEWGRF_REMOVE                                               :{BLACK}Remove
-STR_NEWGRF_REMOVE_TIP                                           :{BLACK}Remove the selected NewGRF file from the list
-STR_NEWGRF_MOVEUP                                               :{BLACK}Move Up
-STR_NEWGRF_MOVEUP_TIP                                           :{BLACK}Move the selected NewGRF file up the list
-STR_NEWGRF_MOVEDOWN                                             :{BLACK}Move Down
-STR_NEWGRF_MOVEDOWN_TIP                                         :{BLACK}Move the selected NewGRF file down the list
-STR_NEWGRF_FILE_TIP                                             :{BLACK}A list of the NewGRF files that are installed. Click a file to change its parameters
-STR_NEWGRF_PARAMETER                                            :{BLACK}Parameters: {SILVER}{STRING}
-STR_NEWGRF_PARAMETER_QUERY                                      :{BLACK}Enter NewGRF parameters
-STR_NEWGRF_NO_INFO                                              :{BLACK}No information available
-
-STR_NEWGRF_ADD_CAPTION                                          :{WHITE}Available NewGRF files
-STR_NEWGRF_ADD_FILE                                             :{BLACK}Add to selection
-STR_NEWGRF_ADD_FILE_TIP                                         :{BLACK}Add the selected NewGRF file to your configuration
-STR_NEWGRF_RESCAN_FILES                                         :{BLACK}Rescan files
-STR_NEWGRF_RESCAN_FILES_TIP                                     :{BLACK}Update the list of available NewGRF files
-STR_NEWGRF_DUPLICATE_GRFID                                      :{WHITE}Cannot add file: duplicate GRF ID
-
-STR_NEWGRF_NOT_FOUND                                            :{RED}Matching file not found
-STR_NEWGRF_DISABLED                                             :{RED}Disabled
-STR_NEWGRF_COMPATIBLE_LOADED                                    :{ORANGE}Matching file not found (compatible GRF loaded)
-
-STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Compatible GRF(s) loaded for missing files
-STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Missing GRF file(s) have been disabled
-STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Missing GRF file(s) to be able to load game
-
-STR_CURRENCY_WINDOW                                             :{WHITE}Custom currency
-STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Exchange rate: {ORANGE}{CURRENCY} = £ {COMMA}
-STR_CURRENCY_SEPARATOR                                          :{LTBLUE}Separator:
-STR_CURRENCY_PREFIX                                             :{LTBLUE}Prefix:
-STR_CURRENCY_SUFFIX                                             :{LTBLUE}Suffix:
-STR_CURRENCY_SWITCH_TO_EURO                                     :{LTBLUE}Switch to Euro: {ORANGE}{NUM}
-STR_CURRENCY_SWITCH_TO_EURO_NEVER                               :{LTBLUE}Switch to Euro: {ORANGE}never
-STR_CURRENCY_PREVIEW                                            :{LTBLUE}Preview: {ORANGE}{CURRENCY}
-STR_CURRENCY_CHANGE_PARAMETER                                   :{BLACK}Change custom currency parameter
-
-STR_TRAIN                                                       :{BLACK}{TRAIN}
-STR_BUS                                                         :{BLACK}{BUS}
-STR_LORRY                                                       :{BLACK}{LORRY}
-STR_PLANE                                                       :{BLACK}{PLANE}
-STR_SHIP                                                        :{BLACK}{SHIP}
-
-STR_SCHEDULED_TRAINS                                            :{WHITE}{STATION} - {COMMA} Train{P "" s}
-STR_SCHEDULED_ROAD_VEHICLES                                     :{WHITE}{STATION} - {COMMA} Road Vehicle{P "" s}
-STR_SCHEDULED_AIRCRAFT                                          :{WHITE}{STATION} - {COMMA} Aircraft
-STR_SCHEDULED_SHIPS                                             :{WHITE}{STATION} - {COMMA} Ship{P "" s}
-
-STR_SCHEDULED_TRAINS_TIP                                        :{BLACK}Show all trains which have this station on their schedule
-STR_SCHEDULED_ROAD_VEHICLES_TIP                                 :{BLACK}Show all road vehicles which have this station on their schedule
-STR_SCHEDULED_AIRCRAFT_TIP                                      :{BLACK}Show all aircraft which have this station on their schedule
-STR_SCHEDULED_SHIPS_TIP                                         :{BLACK}Show all ships which have this station on their schedule
-
-STR_VEH_WITH_SHARED_ORDERS_LIST                                 :{WHITE}Shared orders of {COMMA} Vehicle{P "" s}
-STR_VEH_WITH_SHARED_ORDERS_LIST_TIP                             :{BLACK}Show all vehicles which have the same schedule
-
-### depot strings
-STR_DEPOT_SELL_CONFIRMATION_TEXT                                :{YELLOW}You are about to sell all the vehicles in the depot. Are you sure?
-STR_DEPOT_WRONG_DEPOT_TYPE                                      :Wrong depot type
-
-STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TIP                             :{BLACK}Sell all trains in the depot
-STR_DEPOT_SELL_ALL_BUTTON_ROADVEH_TIP                           :{BLACK}Sell all road vehicles in the depot
-STR_DEPOT_SELL_ALL_BUTTON_SHIP_TIP                              :{BLACK}Sell all ships in the depot
-STR_DEPOT_SELL_ALL_BUTTON_AIRCRAFT_TIP                          :{BLACK}Sell all aircraft in the hangar
-
-STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TIP                          :{BLACK}Get a list of all trains with the current depot in their orders
-STR_DEPOT_VEHICLE_ORDER_LIST_ROADVEH_TIP                        :{BLACK}Get a list of all road vehicles with the current depot in their orders
-STR_DEPOT_VEHICLE_ORDER_LIST_SHIP_TIP                           :{BLACK}Get a list of all ships with the current depot in their orders
-STR_DEPOT_VEHICLE_ORDER_LIST_AIRCRAFT_TIP                       :{BLACK}Get a list of all aircraft with any hangar at this airport in their orders
-
-STR_DEPOT_AUTOREPLACE_TRAIN_TIP                                 :{BLACK}Autoreplace all trains in the depot
-STR_DEPOT_AUTOREPLACE_ROADVEH_TIP                               :{BLACK}Autoreplace all road vehicles in the depot
-STR_DEPOT_AUTOREPLACE_SHIP_TIP                                  :{BLACK}Autoreplace all ships in the depot
-STR_DEPOT_AUTOREPLACE_AIRCRAFT_TIP                              :{BLACK}Autoreplace all aircraft in the hangar
-
-STR_VEHICLE_LIST_TRAIN_DEPOT                                    :{BLACK}{STRING} - {COMMA} Train{P "" s}
-STR_VEHICLE_LIST_ROADVEH_DEPOT                                  :{BLACK}{STRING} - {COMMA} Road Vehicle{P "" s}
-STR_VEHICLE_LIST_SHIP_DEPOT                                     :{BLACK}{STRING} - {COMMA} Ship{P "" s}
-STR_VEHICLE_LIST_AIRCRAFT_DEPOT                                 :{BLACK}{STRING} - {COMMA} Aircraft
-
-STR_REPLACE_VEHICLES_WHITE                                      :{WHITE}Replace {STRING}
-STR_REPLACE_VEHICLES_START                                      :{BLACK}Start Replacing Vehicles
-STR_REPLACE_VEHICLES_STOP                                       :{BLACK}Stop Replacing Vehicles
-STR_NOT_REPLACING                                               :{BLACK}Not replacing
-STR_NOT_REPLACING_VEHICLE_SELECTED                              :{BLACK}No vehicle selected
-STR_REPLACE_HELP_LEFT_ARRAY                                     :{BLACK}Select the engine type to replace
-STR_REPLACE_HELP_RIGHT_ARRAY                                    :{BLACK}Select the new engine type you would like to use in place of the left selected engine type
-STR_REPLACE_HELP_STOP_BUTTON                                    :{BLACK}Press to stop the replacement of the engine type selected on the left
-STR_REPLACE_HELP_START_BUTTON                                   :{BLACK}Press to begin replacement of the left selected engine type with the right selected engine type
-STR_REPLACE_HELP_RAILTYPE                                       :{BLACK}Choose the railtype you want to replace engines for
-STR_REPLACE_HELP_REPLACE_INFO_TAB                               :{BLACK}Displays which engine the left selected engine is being replaced with, if any
-STR_REPLACE_HELP                                                :{BLACK}This allows you to replace one engine type with another type, when trains of the original type enter a depot
-STR_REPLACE_REMOVE_WAGON                                        :{BLACK}Car removal: {ORANGE}{SKIP}{STRING}
-STR_REPLACE_REMOVE_WAGON_HELP                                   :{BLACK}Make autoreplace keep the length of a train the same by removing cars (starting at the front), if replacing the engine would make the train longer.
-STR_REPLACE_ENGINE_WAGON_SELECT                                 :{BLACK}Replacing: {ORANGE}{SKIP}{SKIP}{STRING}
-STR_REPLACE_ENGINE_WAGON_SELECT_HELP                            :{BLACK} EXPERIMENTAL FEATURE {}Switch between engine and car replacement windows.{}Car replacement will only be done if the new car can be refitted into carrying the same type of cargo as the old one. This is checked for each car when the actual replacement takes place.
-STR_RAIL_VEHICLE_NOT_AVAILABLE                                  :{WHITE}Vehicle is not available
-STR_ROAD_VEHICLE_NOT_AVAILABLE                                  :{WHITE}Vehicle is not available
-STR_SHIP_NOT_AVAILABLE                                          :{WHITE}Ship is not available
-STR_AIRCRAFT_NOT_AVAILABLE                                      :{WHITE}Aircraft is not available
-
-STR_ENGINES                                                     :Engines
-STR_WAGONS                                                      :Cars
-
-STR_MASS_STOP_DEPOT_TRAIN_TIP                                   :{BLACK}Click to stop all trains inside the depot
-STR_MASS_STOP_DEPOT_ROADVEH_TIP                                 :{BLACK}Click to stop all road vehicles inside the depot
-STR_MASS_STOP_DEPOT_SHIP_TIP                                    :{BLACK}Click to stop all ships inside the depot
-STR_MASS_STOP_HANGAR_TIP                                        :{BLACK}Click to stop all aircraft inside the hangar
-
-STR_MASS_START_DEPOT_TRAIN_TIP                                  :{BLACK}Click to start all trains inside the depot
-STR_MASS_START_DEPOT_ROADVEH_TIP                                :{BLACK}Click to start all the road vehicles inside the depot
-STR_MASS_START_DEPOT_SHIP_TIP                                   :{BLACK}Click to start all ships inside the depot
-STR_MASS_START_HANGAR_TIP                                       :{BLACK}Click to start all aircraft inside the hangar
-
-STR_MASS_STOP_LIST_TIP                                          :{BLACK}Click to stop all vehicles in the list
-STR_MASS_START_LIST_TIP                                         :{BLACK}Click to start all listed vehicles
-
-STR_SHORT_DATE                                                  :{WHITE}{DATE_TINY}
-STR_SIGN_LIST_CAPTION                                           :{WHITE}Sign List - {COMMA} Sign{P "" s}
-
-STR_ORDER_REFIT_FAILED                                          :{WHITE}Order refit failure stopped {STRING} {COMMA}
-
-############ Lists rail types
-
-STR_RAIL_VEHICLES                                               :Rail Vehicles
-STR_ELRAIL_VEHICLES                                             :Electrified Rail Vehicles
-STR_MONORAIL_VEHICLES                                           :Monorail Vehicles
-STR_MAGLEV_VEHICLES                                             :Maglev Vehicles
-
-############ End of list of rail types
-
-STR_TINY_BLACK                                                  :{BLACK}{TINYFONT}{COMMA}
-
-STR_PURCHASE_INFO_COST_WEIGHT                                   :{BLACK}Cost: {GOLD}{CURRENCY}{BLACK} Weight: {GOLD}{WEIGHT_S}
-STR_PURCHASE_INFO_SPEED_POWER                                   :{BLACK}Speed: {GOLD}{VELOCITY}{BLACK}   Power: {GOLD}{POWER}
-STR_PURCHASE_INFO_SPEED                                         :{BLACK}Speed: {GOLD}{VELOCITY}
-STR_PURCHASE_INFO_RUNNINGCOST                                   :{BLACK}Running Cost: {GOLD}{CURRENCY}/yr
-STR_PURCHASE_INFO_CAPACITY                                      :{BLACK}Capacity: {GOLD}{CARGO} {STRING}
-STR_PURCHASE_INFO_DESIGNED_LIFE                                 :{BLACK}Designed: {GOLD}{NUM}{BLACK} Life: {GOLD}{COMMA} years
-STR_PURCHASE_INFO_RELIABILITY                                   :{BLACK}Max. Reliability: {GOLD}{COMMA}%
-STR_PURCHASE_INFO_COST                                          :{BLACK}Cost: {GOLD}{CURRENCY}
-STR_PURCHASE_INFO_WEIGHT_CWEIGHT                                :{BLACK}Weight: {GOLD}{WEIGHT_S}  ({WEIGHT_S})
-STR_PURCHASE_INFO_COST_SPEED                                    :{BLACK}Cost: {GOLD}{CURRENCY}{BLACK} Speed: {GOLD}{VELOCITY}
-STR_PURCHASE_INFO_AIRCRAFT_CAPACITY                             :{BLACK}Capacity: {GOLD}{COMMA} passengers, {COMMA} bags of mail
-STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT                          :{BLACK}Powered Wagons: {GOLD}+{POWER}{BLACK} Weight: {GOLD}+{WEIGHT_S}
-STR_PURCHASE_INFO_REFITTABLE_TO                                 :{BLACK}Refittable to: {GOLD}
-STR_PURCHASE_INFO_ALL_TYPES                                     :All cargo types
-STR_PURCHASE_INFO_ALL_BUT                                       :All but {GOLD}
-STR_PURCHASE_INFO_MAX_TE                                        :{BLACK}Max. Tractive Effort: {GOLD}{FORCE}
-
-########### String for New Landscape Generator
-
-STR_GENERATE                                                    :{WHITE}Generate
-STR_RANDOM                                                      :{BLACK}Randomize
-STR_RANDOM_HELP                                                 :{BLACK}Change the random seed used for Terrain Generation
-STR_WORLD_GENERATION_CAPTION                                    :{WHITE}World generation
-STR_RANDOM_SEED                                                 :{BLACK}Random Seed:
-STR_RANDOM_SEED_HELP                                            :{BLACK}Click to enter a random seed
-STR_LAND_GENERATOR                                              :{BLACK}Land generator:
-STR_TREE_PLACER                                                 :{BLACK}Tree algorithm:
-STR_HEIGHTMAP_ROTATION                                          :{BLACK}Heightmap rotation:
-STR_TERRAIN_TYPE                                                :{BLACK}Terrain type:
-STR_QUANTITY_OF_SEA_LAKES                                       :{BLACK}Sea level:
-STR_SMOOTHNESS                                                  :{BLACK}Smoothness:
-STR_SNOW_LINE_HEIGHT                                            :{BLACK}Snow line height:
-STR_DATE                                                        :{BLACK}Date:
-STR_NUMBER_OF_TOWNS                                             :{BLACK}No. of towns:
-STR_NUMBER_OF_INDUSTRIES                                        :{BLACK}No. of industries:
-STR_GENERATE_DATE                                               :{BLACK}{DATE_LONG}
-STR_SNOW_LINE_UP                                                :{BLACK}Move the snow line height up one
-STR_SNOW_LINE_DOWN                                              :{BLACK}Move the snow line height down one
-STR_SNOW_LINE_QUERY_CAPT                                        :{WHITE}Change snow line height
-STR_START_DATE_QUERY_CAPT                                       :{WHITE}Change starting year
-STR_HEIGHTMAP_SCALE_WARNING_CAPTION                             :{WHITE}Scale warning
-STR_HEIGHTMAP_SCALE_WARNING_MESSAGE                             :{YELLOW}Resizing source map too much is not recommended. Continue with the generation?
-STR_TOWN_LAYOUT_WARNING_CAPTION                                 :{WHITE}Town layout warning
-STR_TOWN_LAYOUT_WARNING_MESSAGE                                 :{YELLOW}The town layout "no more roads" is not recommended. Continue with the generation?
-STR_SNOW_LINE_HEIGHT_NUM                                        :{NUM}
-STR_HEIGHTMAP_NAME                                              :{BLACK}Heightmap name:
-STR_HEIGHTMAP_SIZE                                              :{BLACK}Size: {ORANGE}{NUM} x {NUM}
-STR_GENERATION_WORLD                                            :{WHITE}Generating world...
-STR_GENERATION_ABORT                                            :{BLACK}Cancel
-STR_GENERATION_ABORT_CAPTION                                    :{WHITE}Cancel World Generation
-STR_GENERATION_ABORT_MESSAGE                                    :{YELLOW}Do you really want to cancel the generation?
-STR_PROGRESS                                                    :{WHITE}{NUM}% complete
-STR_GENERATION_PROGRESS                                         :{BLACK}{NUM} / {NUM}
-STR_WORLD_GENERATION                                            :{BLACK}World generation
-STR_TREE_GENERATION                                             :{BLACK}Tree generation
-STR_UNMOVABLE_GENERATION                                        :{BLACK}Unmovable generation
-STR_CLEARING_TILES                                              :{BLACK}Rough and rocky area generation
-STR_SETTINGUP_GAME                                              :{BLACK}Setting up game
-STR_PREPARING_TILELOOP                                          :{BLACK}Running tile-loop
-STR_PREPARING_GAME                                              :{BLACK}Preparing game
-STR_DIFFICULTY_TO_CUSTOM                                        :{WHITE}This action changed the difficulty level to custom
-STR_SE_FLAT_WORLD                                               :{WHITE}Flat land
-STR_SE_FLAT_WORLD_TIP                                           :{BLACK}Generate a flat land
-STR_SE_RANDOM_LAND                                              :{WHITE}Random land
-STR_SE_NEW_WORLD                                                :{BLACK}Create new scenario
-STR_SE_CAPTION                                                  :{WHITE}Scenario type
-STR_FLAT_WORLD_HEIGHT_DOWN                                      :{BLACK}Move the height of flat land down one
-STR_FLAT_WORLD_HEIGHT_UP                                        :{BLACK}Move the height of flat land up one
-STR_FLAT_WORLD_HEIGHT_QUERY_CAPT                                :{WHITE}Change height of flat land
-STR_FLAT_WORLD_HEIGHT                                           :{BLACK}Height of flat land:
-STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
-
-STR_SMALLMAP_CENTER                                             :{BLACK}Center the smallmap on the current position
-
-########### String for new airports
-STR_SMALL_AIRPORT                                               :{BLACK}Small
-STR_CITY_AIRPORT                                                :{BLACK}City
-STR_METRO_AIRPORT                                               :{BLACK}Metropolitan airport
-STR_INTERNATIONAL_AIRPORT                                       :{BLACK}International airport
-STR_COMMUTER_AIRPORT                                            :{BLACK}Commuter
-STR_INTERCONTINENTAL_AIRPORT                                    :{BLACK}Intercontinental
-STR_HELIPORT                                                    :{BLACK}Heliport
-STR_HELIDEPOT                                                   :{BLACK}Helidepot
-STR_HELISTATION                                                 :{BLACK}Helistation
-
-STR_SMALL_AIRPORTS                                              :{BLACK}Small airports
-STR_LARGE_AIRPORTS                                              :{BLACK}Large airports
-STR_HUB_AIRPORTS                                                :{BLACK}Hub airports
-STR_HELIPORTS                                                   :{BLACK}Helicopter airports
-
-############ Tooltip measurment
-
-STR_MEASURE_LENGTH                                              :{BLACK}Length: {NUM}
-STR_MEASURE_AREA                                                :{BLACK}Area: {NUM} x {NUM}
-STR_MEASURE_LENGTH_HEIGHTDIFF                                   :{BLACK}Length: {NUM}{}Height difference: {NUM} m
-STR_MEASURE_AREA_HEIGHTDIFF                                     :{BLACK}Area: {NUM} x {NUM}{}Height difference: {NUM} m
-
-############ Date formatting
-STR_DATE_TINY                                                   :{STRING}-{STRING}-{NUM}
-STR_DATE_SHORT                                                  :{STRING} {NUM}
-STR_DATE_LONG                                                   :{STRING} {STRING} {NUM}
-
-########
-
-STR_FEEDER_CARGO_VALUE                                          :{BLACK}Transfer Credits: {LTBLUE}{CURRENCY}
-STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD                            :{WHITE}...this is a town owned road
-STR_DRIVE_THROUGH_ERROR_DIRECTION                               :{WHITE}...road facing in the wrong direction
-
-STR_TRANSPARENCY_TOOLB                                          :{WHITE}Transparency Options
-STR_TRANSPARENT_SIGNS_DESC                                      :{BLACK}Toggle transparency for station signs
-STR_TRANSPARENT_TREES_DESC                                      :{BLACK}Toggle transparency for trees
-STR_TRANSPARENT_HOUSES_DESC                                     :{BLACK}Toggle transparency for houses
-STR_TRANSPARENT_INDUSTRIES_DESC                                 :{BLACK}Toggle transparency for industries
-STR_TRANSPARENT_BUILDINGS_DESC                                  :{BLACK}Toggle transparency for buildables like stations, depots, waypoints and catenary
-STR_TRANSPARENT_BRIDGES_DESC                                    :{BLACK}Toggle transparency for bridges
-STR_TRANSPARENT_STRUCTURES_DESC                                 :{BLACK}Toggle transparency for structures like lighthouses and antennas, maybe in future for eyecandy
-STR_TRANSPARENT_LOADING_DESC                                    :{BLACK}Toggle transparency for loading indicators
-
-STR_PERCENT_UP_SMALL                                            :{TINYFONT}{WHITE}{NUM}%{UPARROW}
-STR_PERCENT_UP                                                  :{WHITE}{NUM}%{UPARROW}
-STR_PERCENT_DOWN_SMALL                                          :{TINYFONT}{WHITE}{NUM}%{DOWNARROW}
-STR_PERCENT_DOWN                                                :{WHITE}{NUM}%{DOWNARROW}
-STR_PERCENT_UP_DOWN_SMALL                                       :{TINYFONT}{WHITE}{NUM}%{UPARROW}{DOWNARROW}
-STR_PERCENT_UP_DOWN                                             :{WHITE}{NUM}%{UPARROW}{DOWNARROW}
-
-##### Mass Order
-STR_GROUP_NAME_FORMAT                                           :Group {COMMA}
-STR_GROUP_TINY_NAME                                             :{TINYFONT}{GROUP}
-STR_GROUP_ALL_TRAINS                                            :All trains
-STR_GROUP_ALL_ROADS                                             :All road vehicles
-STR_GROUP_ALL_SHIPS                                             :All ships
-STR_GROUP_ALL_AIRCRAFTS                                         :All aircraft
-STR_GROUP_DEFAULT_TRAINS                                        :Ungrouped trains
-STR_GROUP_DEFAULT_ROADS                                         :Ungrouped road vehicles
-STR_GROUP_DEFAULT_SHIPS                                         :Ungrouped ships
-STR_GROUP_DEFAULT_AIRCRAFTS                                     :Ungrouped aircraft
-STR_GROUP_TINY_NUM                                              :{TINYFONT}{COMMA}
-STR_GROUP_ADD_SHARED_VEHICLE                                    :Add shared vehicles
-STR_GROUP_REMOVE_ALL_VEHICLES                                   :Remove all vehicles
-
-STR_GROUP_TRAINS_CAPTION                                        :{WHITE}{GROUP} - {COMMA} Train{P "" s}
-STR_GROUP_ROADVEH_CAPTION                                       :{WHITE}{GROUP} - {COMMA} Road Vehicle{P "" s}
-STR_GROUP_SHIPS_CAPTION                                         :{WHITE}{GROUP} - {COMMA} Ship{P "" s}
-STR_GROUP_AIRCRAFTS_CAPTION                                     :{WHITE}{GROUP} - {COMMA} Aircraft
-STR_GROUP_RENAME_CAPTION                                        :{BLACK}Rename a group
-STR_GROUP_REPLACE_CAPTION                                       :{WHITE}Replace Vehicles of "{GROUP}"
-
-STR_GROUP_CAN_T_CREATE                                          :{WHITE}Can't create group...
-STR_GROUP_CAN_T_DELETE                                          :{WHITE}Can't delete this group...
-STR_GROUP_CAN_T_RENAME                                          :{WHITE}Can't rename group...
-STR_GROUP_CAN_T_REMOVE_ALL_VEHICLES                             :{WHITE}Can't remove all vehicles from this group...
-STR_GROUP_CAN_T_ADD_VEHICLE                                     :{WHITE}Can't add the vehicle to this group...
-STR_GROUP_CAN_T_ADD_SHARED_VEHICLE                              :{WHITE}Can't add shared vehicles to group...
-
-STR_GROUPS_CLICK_ON_GROUP_FOR_TIP                               :{BLACK}Groups - Click on a group to list all of its vehicles
-STR_GROUP_CREATE_TIP                                            :{BLACK}Click to create a group
-STR_GROUP_DELETE_TIP                                            :{BLACK}Delete the selected group
-STR_GROUP_RENAME_TIP                                            :{BLACK}Rename the selected group
-STR_GROUP_REPLACE_PROTECTION_TIP                                :{BLACK}Click to protect this group from global autoreplace
-
-STR_COMPANY_NAME                                                :{COMPANY}
-STR_ENGINE_NAME                                                 :{ENGINE}
-STR_GROUP_NAME                                                  :{GROUP}
-STR_PLAYER_NAME                                                 :{PLAYERNAME}
-STR_SIGN_NAME                                                   :{SIGN}
-STR_VEHICLE_NAME                                                :{VEHICLE}
-
-STR_NAME_MUST_BE_UNIQUE                                         :{WHITE}Name must be unique
-
-#### Improved sign GUI
-STR_NEXT_SIGN_TOOLTIP                                           :{BLACK}Go to next sign
-STR_PREVIOUS_SIGN_TOOLTIP                                       :{BLACK}Go to previous sign
-
-########
-
-STR_FUND_NEW_INDUSTRY                                           :{BLACK}Fund
-STR_PROSPECT_NEW_INDUSTRY                                       :{BLACK}Prospect
-STR_BUILD_NEW_INDUSTRY                                          :{BLACK}Build
-STR_INDUSTRY_SELECTION_HINT                                     :{BLACK}Choose the appropriate industry from this list
-
-############ Face formatting
-STR_FACE_ADVANCED                                               :{BLACK}Advanced
-STR_FACE_ADVANCED_TIP                                           :{BLACK}Advanced face selection.
-STR_FACE_SIMPLE                                                 :{BLACK}Simple
-STR_FACE_SIMPLE_TIP                                             :{BLACK}Simple face selection.
-STR_FACE_LOAD                                                   :{BLACK}Load
-STR_FACE_LOAD_TIP                                               :{BLACK}Load favorite face
-STR_FACE_LOAD_DONE                                              :{WHITE}Your favorite face has been loaded from the OpenTTD config file.
-STR_FACE_FACECODE                                               :{BLACK}Player face no.
-STR_FACE_FACECODE_TIP                                           :{BLACK}View and/or set player face number
-STR_FACE_FACECODE_CAPTION                                       :{WHITE}View and/or set player face number
-STR_FACE_FACECODE_SET                                           :{WHITE}New face number code has been set.
-STR_FACE_FACECODE_ERR                                           :{WHITE}Couldn't set player face number - must be numeric between 0 and 4,294,967,295!
-STR_FACE_SAVE                                                   :{BLACK}Save
-STR_FACE_SAVE_TIP                                               :{BLACK}Save favorite face
-STR_FACE_SAVE_DONE                                              :{WHITE}This face will be saved as your favorite in the OpenTTD config file.
-STR_FACE_EUROPEAN                                               :{BLACK}European
-STR_FACE_SELECT_EUROPEAN                                        :{BLACK}Select European faces
-STR_FACE_AFRICAN                                                :{BLACK}African
-STR_FACE_SELECT_AFRICAN                                         :{BLACK}Select African faces
-STR_FACE_YES                                                    :Yes
-STR_FACE_NO                                                     :No
-STR_FACE_MOUSTACHE_EARRING_TIP                                  :{BLACK}Enable mustache or earring
-STR_FACE_HAIR                                                   :Hair:
-STR_FACE_HAIR_TIP                                               :{BLACK}Change hair
-STR_FACE_EYEBROWS                                               :Eyebrows:
-STR_FACE_EYEBROWS_TIP                                           :{BLACK}Change eyebrows
-STR_FACE_EYECOLOUR                                              :Eye color:
-STR_FACE_EYECOLOUR_TIP                                          :{BLACK}Change eyecolor
-STR_FACE_GLASSES                                                :Glasses:
-STR_FACE_GLASSES_TIP                                            :{BLACK}Enable glasses
-STR_FACE_GLASSES_TIP_2                                          :{BLACK}Change glasses
-STR_FACE_NOSE                                                   :Nose:
-STR_FACE_NOSE_TIP                                               :{BLACK}Change nose
-STR_FACE_LIPS                                                   :Lips:
-STR_FACE_MOUSTACHE                                              :Mustache:
-STR_FACE_LIPS_MOUSTACHE_TIP                                     :{BLACK}Change lips or mustache
-STR_FACE_CHIN                                                   :Chin:
-STR_FACE_CHIN_TIP                                               :{BLACK}Change chin
-STR_FACE_JACKET                                                 :Jacket:
-STR_FACE_JACKET_TIP                                             :{BLACK}Change jacket
-STR_FACE_COLLAR                                                 :Collar:
-STR_FACE_COLLAR_TIP                                             :{BLACK}Change collar
-STR_FACE_TIE                                                    :Tie:
-STR_FACE_EARRING                                                :Earring:
-STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Change tie or earring
-########
--- a/src/lang/brazilian_portuguese.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/brazilian_portuguese.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -162,7 +162,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Impossível limpar esta área....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright original {COPYRIGHT} 1995 Chris Sawyer, Todos os direitos reservados
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versão {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 A equipe do OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 A equipe do OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Tradutor(es) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -872,7 +872,7 @@
 STR_0319_PAUSED                                                 :{YELLOW}* *  PAUSADO *  *
 
 STR_031B_SCREENSHOT_SUCCESSFULLY                                :{WHITE}Foto salvado com sucesso como '{STRING}'
-STR_031C_SCREENSHOT_FAILED                                      :{WHITE}A foto falhou!
+STR_031C_SCREENSHOT_FAILED                                      :{WHITE}Falha ao tirar foto!
 
 STR_0329_PURCHASE_LAND_FOR_FUTURE                               :{BLACK}Comprar terreno para uso futuro
 STR_032F_AUTOSAVE                                               :{RED}Gravado automaticamente
@@ -941,8 +941,9 @@
 STR_OPTIONS_LANG_CBO                                            :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
 STR_OPTIONS_LANG_TIP                                            :{BLACK}Selecionar o idioma da interface do jogo
 
-STR_OPTIONS_FULLSCREEN                                          :{BLACK}Tela Inteira
-STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Selecione esta opção para jogar o OpenTTD em modo de tela inteiro
+STR_OPTIONS_FULLSCREEN                                          :{BLACK}Tela cheia
+STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Selecione esta opção para jogar o OpenTTD em modo de tela cheia
+STR_FULLSCREEN_FAILED                                           :{WHITE}Falha no modo de tela cheia
 
 STR_OPTIONS_RES                                                 :{BLACK}Resolução da tela
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1012,10 +1013,10 @@
 STR_AIRCRAFT_HAS_INVALID_ENTRY                                  :{WHITE}Aeronave {COMMA} possui uma estação inválida em suas ordens
 # end of order system
 
-STR_TRAIN_AUTORENEW_FAILED                                      :{WHITE}A auto-renovação do trem {COMMA} falhou (limite de dinheiro)
-STR_ROADVEHICLE_AUTORENEW_FAILED                                :{WHITE}A auto-renovação do automóvel {COMMA} falhou (falta de dinheiro)
-STR_SHIP_AUTORENEW_FAILED                                       :{WHITE}A auto-renovação da embarcação {COMMA} falhou (limite de dinheiro)
-STR_AIRCRAFT_AUTORENEW_FAILED                                   :{WHITE}A auto-renovação da aeronave {COMMA} falhou (limite de dinheiro)
+STR_TRAIN_AUTORENEW_FAILED                                      :{WHITE}Falha na auto-renovação do trem {COMMA} (limite de dinheiro)
+STR_ROADVEHICLE_AUTORENEW_FAILED                                :{WHITE}Falha na auto-renovação do automóvel {COMMA} (falta de dinheiro)
+STR_SHIP_AUTORENEW_FAILED                                       :{WHITE}Falha na auto-renovação da embarcação {COMMA} (limite de dinheiro)
+STR_AIRCRAFT_AUTORENEW_FAILED                                   :{WHITE}Falha na auto-renovação da aeronave {COMMA} (limite de dinheiro)
 STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT                            :{WHITE}O trem {COMMA} ficará muito longo após a substituição
 
 STR_CONFIG_PATCHES                                              :{BLACK}Configurar Correções
@@ -1171,6 +1172,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Permite comprar ações de outras companhias
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Ao arrastar colocar sinais a cada: {ORANGE}{STRING} quadrado(s)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automaticamente constroi semáforos anteriores: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Ativar interface de sinais: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}O layout de cidade "sem mais estradas" não é válido no editor
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Selecione o layout das estradas {ORANGE}{STRING}
@@ -1707,6 +1709,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}O edifício necessita ser demolido primeiro
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}População: {ORANGE}{COMMA}{BLACK}  Casas: {ORANGE}{COMMA}
@@ -2312,7 +2315,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Mover sede
 STR_COMPANY_PASSWORD                                            :{BLACK}Senha
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Usar senha na empresa para prevenir utilizadores não autorizados.
-STR_SET_COMPANY_PASSWORD                                        :Definir senha para empresa
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Definir senha para empresa
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Não salvar a senha digitada
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Dar à empresa uma nova senha
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Senha da empresa
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Senha padrão da empresa
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Usar esta senha de empresa como padrão para novas empresas
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Recesso Mundial!{}{}Economistas temem crise!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Fim do recesso!{}{}Melhoras no comércio inspiram confiança nas indústrias à medida que a economia se fortalece!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Alternar entre janela grande/pequena
@@ -2693,9 +2701,9 @@
 STR_8826_GO_TO                                                  :{BLACK}Ir Para
 STR_8827_FULL_LOAD                                              :{BLACK}Carga
 STR_8828_UNLOAD                                                 :{BLACK}Descarga
-STR_REFIT                                                       :{BLACK}Readaptar
+STR_REFIT                                                       :{BLACK}Adaptar
 STR_REFIT_TIP                                                   :{BLACK}Selecionar a adaptação na ordem atual. CTRL + Clique para remover a instrução
-STR_REFIT_ORDER                                                 :(Readaptar para {STRING})
+STR_REFIT_ORDER                                                 :(Adaptar para {STRING})
 STR_TIMETABLE_VIEW                                              :{BLACK}Plano de horário
 STR_TIMETABLE_VIEW_TOOLTIP                                      :{BLACK}Exibe o plano de horário
 STR_8829_ORDERS                                                 :{WHITE}{VEHICLE} (Ordens)
@@ -2793,6 +2801,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Novo {STRING} agora disponível!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Impossível vender veículo destruído...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Impossível adptar veículo destruído...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Impossível programar veículo...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Veículos só podem aguardar em estações
@@ -2868,10 +2877,10 @@
 STR_9038_GO_TO_ROADVEH_DEPOT                                    :Ir para a garagem de {TOWN}
 STR_SERVICE_AT_ROADVEH_DEPOT                                    :Manutenção na garagem de {TOWN}
 
-STR_REFIT_ROAD_VEHICLE_TO_CARRY                                 :{BLACK}Reacondicionar automóvel para carregar tipo de carga diferente
-STR_REFIT_ROAD_VEHICLE                                          :{BLACK}Reacondicionar automóvel
-STR_REFIT_ROAD_VEHICLE_TO_CARRY_HIGHLIGHTED                     :{BLACK}Reacondicionar automóvel para carregar o tipo de carga selecionado
-STR_REFIT_ROAD_VEHICLE_CAN_T                                    :{WHITE}Impossível reacondicionar automóvel...
+STR_REFIT_ROAD_VEHICLE_TO_CARRY                                 :{BLACK}Adaptar automóvel para carregar tipo de carga diferente
+STR_REFIT_ROAD_VEHICLE                                          :{BLACK}Adaptar automóvel
+STR_REFIT_ROAD_VEHICLE_TO_CARRY_HIGHLIGHTED                     :{BLACK}Adaptar automóvel para carregar o tipo de carga selecionado
+STR_REFIT_ROAD_VEHICLE_CAN_T                                    :{WHITE}Impossível adaptar automóvel...
 STR_ROAD_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Selecionar tipo de carga para o automóvel
 
 ##id 0x9800
@@ -3113,6 +3122,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Carregado compativel com GRF(s)  por falta de arquivo
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}arquivo(s) GRF em falta foram desativados
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Falta(m) arquivo(s) GRF para carregar o jogo
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Arquivo(s) GRF faltantes
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Despausar pode travar OpenTTD. Não envie relatórios de erros sobre travas subseqüentes.{}Você realmente quer despausar?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Moeda Modificada
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Taxa de câmbio: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3207,7 +3218,7 @@
 STR_SHORT_DATE                                                  :{WHITE}{DATE_TINY}
 STR_SIGN_LIST_CAPTION                                           :{WHITE}Lista de Placas - {COMMA} Placa{P "" s}
 
-STR_ORDER_REFIT_FAILED                                          :{WHITE}Erro na ordem de readaptação {STRING} {COMMA}
+STR_ORDER_REFIT_FAILED                                          :{WHITE}Falha na parada de ordem de adaptação {STRING} {COMMA}
 
 ############ Lists rail types
 
@@ -3232,7 +3243,7 @@
 STR_PURCHASE_INFO_COST_SPEED                                    :{BLACK}Custo: {GOLD}{CURRENCY}{BLACK} Velocidade: {GOLD}{VELOCITY}
 STR_PURCHASE_INFO_AIRCRAFT_CAPACITY                             :{BLACK}Capacidade: {GOLD}{COMMA} passageiros, {COMMA} sacos de cartas
 STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT                          :{BLACK}Vagões energizados: {GOLD}+{POWER}{BLACK} Peso: {GOLD}+{WEIGHT_S}
-STR_PURCHASE_INFO_REFITTABLE_TO                                 :{BLACK}Readaptável para: {GOLD}
+STR_PURCHASE_INFO_REFITTABLE_TO                                 :{BLACK}Adaptável para: {GOLD}
 STR_PURCHASE_INFO_ALL_TYPES                                     :Todos as cargas
 STR_PURCHASE_INFO_ALL_BUT                                       :Todas menos {GOLD}
 STR_PURCHASE_INFO_MAX_TE                                        :{BLACK}Max. Tração : {GOLD}{FORCE}
@@ -3448,3 +3459,20 @@
 STR_FACE_EARRING                                                :Brinco:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Alterar gravata ou brinco
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Seleção de Sinais
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Impossível converter sinais aqui...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Sinais padrão (semáforos){}Sinais são necessários para manter trens de colidirem nas malhas ferroviárias com mais de um trem.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Sinal de Entrada (semáforo){}Verde contanto que haja um ou mais sinais de saída verdes na atual seção dos trilhos. Do contrário, fica vermelho.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Sinal de saída (semáforo){}Funciona como um sinal normal, porém é necessário para o funcionamento correto do sistema de sinais combo ou de entrada.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Sinal combo (semáforo){}O sinal combo funciona tanto como um sinal de entrada quanto de saída. Permite construir várias ramificações.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Sinal Padrão (elétrico){}Sinais são necessários para impedir que trens batam em redes de ferrovias com mais de uma máquina.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Sinal de entrada (elétrico){}Verde contanto que haja um ou mais sinais de saída verdes na atual seção dos trilhos. Do contrário, fica vermelho.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Sinal de saída(elétrico){}Funciona como um sinal normal, porém é necessário para o funcionamento correto do sistema de sinais combo ou de entrada.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Sinal combo (elétrico){}O sinal combo funciona tanto como um sinal de entrada quanto de saída. Permite construir várias ramificações.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Converter sinal{}Quando selecionado, clicar num sinal existente converte-o para o tipo selecionado e suas variantes. CTRL+clique muda a variante atual.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Densidade dos sinais ao clicar e arrastar
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Diminuir a densidade dos sinais
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Aumentar a densidade dos sinais
+########
--- a/src/lang/bulgarian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/bulgarian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -162,7 +162,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Изчистването е невъзможно....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Авторски права {COPYRIGHT} 1995 Крис Сойер (Chris Sawyer), Всички права са запазени
 STR_00B7_VERSION                                                :{BLACK}OpenTTD версия {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 The OpenTTD team
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 The OpenTTD team
 STR_TRANSLATED_BY                                               :{BLACK}  Преводач(и) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -590,12 +590,15 @@
 STR_0203_SHOW_LAST_MESSAGE_NEWS                                 :{BLACK}Покажи последното съобщение/новини, покажи настройките на съобщенията
 STR_0204_MESSAGE_OPTIONS                                        :{WHITE}Настройки на съобщенията
 STR_0205_MESSAGE_TYPES                                          :{BLACK}Типове съобщения:
-STR_0206_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Първо пристигане на превозно средство в станция
+STR_0206_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Първа кола пристигнала в станция
 STR_0207_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Първо пристигане на превозно средство в конкурентна станция
 STR_0208_ACCIDENTS_DISASTERS                                    :{YELLOW}Инциденти / бедствия
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Информация за компанията
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Отворени / затворени промишлености
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Промени в икономиката
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Промяна в производството на индустрия обслужвана от играча
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Промяна в производството на индустрия обслужвана от конкуренцията
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Промяна в производството на индустрия
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Съвет / информация за превозните средства
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Нови превозни средства
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Промени в приемането на товари
@@ -834,9 +837,9 @@
 STR_02F5                                                        :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
 STR_02F6_SELECT_INTERVAL_BETWEEN                                :{BLACK}Интервала между две автозаписваня
 STR_02F7_OFF                                                    :изключено
-STR_02F8_EVERY_3_MONTHS                                         :на всеки 3 месеца
-STR_02F9_EVERY_6_MONTHS                                         :На всеки 6 месеца
-STR_02FA_EVERY_12_MONTHS                                        :На всеки 12 месеца
+STR_02F8_EVERY_3_MONTHS                                         :всеки 3 месеца
+STR_02F9_EVERY_6_MONTHS                                         :всеки 6 месеца
+STR_02FA_EVERY_12_MONTHS                                        :всеки 12 месеца
 STR_02FB_START_A_NEW_GAME                                       :{BLACK}Започни нова игра
 STR_02FC_LOAD_A_SAVED_GAME                                      :{BLACK}Отвори запасена игра
 STR_02FE_CREATE_A_CUSTOMIZED_GAME                               :{BLACK}Създай свой собствен карта-свят
@@ -932,7 +935,7 @@
 STR_CURR_SKK                                                    :словашка крона (SKK)
 STR_CURR_BRR                                                    :бразилски реал (BRL)
 
-STR_CURR_CUSTOM                                                 :Друга...
+STR_CURR_CUSTOM                                                 :друга...
 
 STR_OPTIONS_LANG                                                :{BLACK}Език
 STR_OPTIONS_LANG_CBO                                            :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -940,6 +943,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Цял екран
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Изберете тази опция за да играете OpenTTD в цял екран
+STR_FULLSCREEN_FAILED                                           :{WHITE}Проблем при включване на режим "цял екран"
 
 STR_OPTIONS_RES                                                 :{BLACK}Размер на екрана
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -949,7 +953,7 @@
 STR_OPTIONS_SCREENSHOT_FORMAT_CBO                               :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
 STR_OPTIONS_SCREENSHOT_FORMAT_TIP                               :{BLACK}Избор на формата на екранните снимки
 
-STR_AUTOSAVE_1_MONTH                                            :Всеки месец
+STR_AUTOSAVE_1_MONTH                                            :всеки месец
 STR_AUTOSAVE_FAILED                                             :{WHITE}Автозапазването е неуспешно
 
 STR_MONTH_JAN                                                   :Януари
@@ -1023,6 +1027,7 @@
 STR_CONFIG_PATCHES_ON                                           :Включено
 STR_CONFIG_PATCHES_VEHICLESPEED                                 :{LTBLUE}Показване скоростта на автомобилите в лента за състоянието: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BUILDONSLOPES                                :{LTBLUE}Позволяване строенето на склонове и брегове: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AUTOSLOPE                                    :{LTBLUE}Тераформиране под сгради, пътища и др. (autoslope): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_CATCHMENT                                    :{LTBLUE}По-реалистична зона за обслужване: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_EXTRADYNAMITE                                :{LTBLUE}Премахване на повече неща собственост на град: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAMMOTHTRAINS                                :{LTBLUE}Строене на много дълги влакове: {ORANGE}{STRING}
@@ -1036,6 +1041,7 @@
 STR_CONFIG_PATCHES_SELECTGOODS                                  :{LTBLUE}Доставяне на стока до станция само ако има търсене: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LONGBRIDGES                                  :{LTBLUE}Строене на много дълги мостове: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_GOTODEPOT                                    :{LTBLUE}Сервиз в маршрута: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD             :{LTBLUE}Ръчен строеж на първични индустрии: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_NONE        :нищо
 STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_NORMAL      :като други промишлености
 STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_PROSPECTING :предстоящ
@@ -1133,6 +1139,7 @@
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_LAST                       :Последно на разположение
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MOST_USED                  :Най-много използван
 
+STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE                  :{LTBLUE}Показване на инструментите за строене при липса на съответни превозни средства: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAX_TRAINS                                   :{LTBLUE}Макс. влакове на играч: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAX_ROADVEH                                  :{LTBLUE}Макс. брой коли на играч: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAX_AIRCRAFT                                 :{LTBLUE}Макс. брой самолети на играч: {ORANGE}{STRING}
@@ -1165,6 +1172,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Позволяване покупката на акции от други компании
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}При влачене, поставяне на семафори всеки: {ORANGE}{STRING} плочка(и)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Автоматично построй семафори преди: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Вклучи GUI за сигналите: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Грацкиа план "няма повече пътища" е невалиден в сценарий редакторат
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Избери грацки пътформат: {ORANGE}{STRING}
@@ -1679,7 +1687,9 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Построи трамвайен мост
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Построй тунел
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Построи трамвайен тунел
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Активирай/Деактивирай еднопосочни пътища
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Премахване на асфалтов път
+STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Превключване строене/разрушаване на трамвайни консктрукции
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Ориентация на гараж
 STR_1813_SELECT_TRAM_VEHICLE_DEPOT                              :{BLACK}Избери посоката на трамвайното депо
 STR_1814_ROAD                                                   :път
@@ -1699,6 +1709,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Сградата първо трябва да бъде разрушена
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Население: {ORANGE}{COMMA}{BLACK}  Жилища: {ORANGE}{COMMA}
@@ -1791,7 +1802,7 @@
 
 STR_INDUSTRY                                                    :{INDUSTRY}
 STR_TOWN                                                        :{TOWN}
-STR_INDUSTRY_FORMAT                                             :{TOWN} {STRING}
+STR_INDUSTRY_FORMAT                                             :{1:STRING} {0:TOWN}
 STR_STATION                                                     :{STATION}
 
 ##id 0x2800
@@ -2010,8 +2021,8 @@
 STR_4839_PRODUCTION_DOWN_BY_50                                  :{BLACK}{BIGFONT}Прозиводството в {INDUSTRY} спадна с 50%
 STR_483A_INSECT_INFESTATION_CAUSES                              :{BLACK}{BIGFONT}Напаст от насекоми предизвика опустошение в {INDUSTRY}!{}Производството намаля с 50%
 STR_483B_CAN_ONLY_BE_POSITIONED                                 :{WHITE}...може да бъде поставено само до краищата на картата
-STR_INDUSTRY_PROD_GOUP                                          :{BLACK}{BIGFONT}{STRING} продукция в {INDUSTRY} нарасна с {COMMA}%!
-STR_INDUSTRY_PROD_GODOWN                                        :{BLACK}{BIGFONT}{STRING} продукция в {INDUSTRY} намаля с {COMMA}%!
+STR_INDUSTRY_PROD_GOUP                                          :{BLACK}{BIGFONT}Производството на {STRING} в {INDUSTRY} нарасна с {COMMA}%!
+STR_INDUSTRY_PROD_GODOWN                                        :{BLACK}{BIGFONT}Производството на {STRING} в {INDUSTRY} намаля с {COMMA}%!
 
 ##id 0x5000
 STR_5000_TRAIN_IN_TUNNEL                                        :{WHITE}Влак в тунела
@@ -2302,7 +2313,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Преместване ЦК
 STR_COMPANY_PASSWORD                                            :{BLACK}Парола
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Постави парола за да предпазиш компанията си от неоторизирани потребители.
-STR_SET_COMPANY_PASSWORD                                        :Поставяне парола на компанията
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Поставяне парола на компанията
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Незапазвай паролата
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Дай на компанията новата парола
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Парола на компанията
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Парола по подразбиране за компания
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Използване на тази парола по подразбиране за нови компании
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Световна икономическа криза!{}{}Финансовите експерти очакват най-лошото от сриващата се световна икономика!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Световната икономическа криза отмина!{}{}Възходът на търговията дава увереност на индустриите в новата засилваща се икономическа реалност!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Активирай голям/малък размер на прозореца
@@ -2783,7 +2799,9 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Нов {STRING} е на разположение! - {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Унищожено превозно средство не може да се продаде...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Не може да се преустройва разрушено превозно средство...
 
+STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Не може да добави разписание на превозно средство...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Превозни средства могат да чакат само на гари.
 STR_TIMETABLE_NOT_STOPPING_HERE                                 :{WHITE}Това превознот средство не спира на тази гара.
 STR_TIMETABLE_CHANGE_TIME                                       :{BLACK}Промени времето
@@ -2793,6 +2811,7 @@
 STR_TIMETABLE_TOTAL_TIME                                        :Ще трябва {STRING} за това разписание да бъде приклучено
 STR_TIMETABLE_TOTAL_TIME_INCOMPLETE                             :Това разписание ще вземе най-малко {STRING} за да приклучи (не всичко е планирано)
 STR_TIMETABLE_AUTOFILL                                          :{BLACK}Афтонапълване
+STR_TIMETABLE_AUTOFILL_TOOLTIP                                  :{BLACK}Автоматично попълване на разписанието със стойности от първото пътуване
 
 ##id 0x9000
 STR_9000_ROAD_VEHICLE_IN_THE_WAY                                :{WHITE}Кола на пътя
@@ -2841,7 +2860,7 @@
 STR_902C_NAME_ROAD_VEHICLE                                      :{WHITE}Преименувай МПС-то
 STR_902D_CAN_T_NAME_ROAD_VEHICLE                                :{WHITE}Не може да преименуваш МПС-то...
 STR_902E_NAME_ROAD_VEHICLE                                      :{BLACK}Преименувай МПС-то
-STR_902F_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Хората празнуват . . .{}Първи автобус пристигна на {STATION}!
+STR_902F_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Гражданите празнуват . . .{}Първият автобус пристигнал в {STATION}!
 STR_9030_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Хората празнуват . . .{}Първи камион пристигна на {STATION}!
 STR_902F_CITIZENS_CELEBRATE_FIRST_TRAM                          :{BLACK}{BIGFONT}Гражданите празнуват . . .{}Първиат пътнически трамвай пристига на {STATION}!
 STR_9030_CITIZENS_CELEBRATE_FIRST_TRAM                          :{BLACK}{BIGFONT}Гражданите празнуват . . .{}Първиат товарен трамвай пристига на {STATION}!
@@ -3072,6 +3091,7 @@
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} трябва да бъде зареден след {STRING}.
 STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} поискай OpenTTD версиа {STRING} или по-добра.
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :GRF файлат беше предназначен да преведе
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Прекалено много графики (NewGRF) са заредени.
 
 STR_NEWGRF_ADD                                                  :{BLACK}Добави
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Добавяне на NewGRF файл към списъка
@@ -3100,6 +3120,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Съвместими GRF файлове за заредени вместо липсващите
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Липсващите GRF файлове за изключени
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Липсващи GRF файлове при зареждане на игра
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Липсва GRF файл(ове)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Може да счупи OpenTTD. Не пускайте съобщение за грешка за последвали счупвания.{}Желаете ли да се махне паузата?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Парична единица
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Обменен курс: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3280,6 +3302,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Центриране на малката карта на текущата позиция
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Малко
@@ -3434,3 +3457,20 @@
 STR_FACE_EARRING                                                :Oбица:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Cмени вратовръзкатa или oбицатa
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Сигнал селекция
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Тук не може да се конвертират сигналите...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Нормален сигнал (семафор){}Сигналите са необходими за да предпазват влаковете от катастрофи по ЖП мрежата.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Входен сигнал (семафор){}Свети зелено докато има поне един зелен изходен сигнал от следващия сегмент от пътя. В противен случай свети червено.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Изходен сигнал (семафор){}Действа като нормален сигнал, но е необходим за да работят входните и комбинираните сигнали.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Комбиниран сигнал (семафор){}Комбинирания сигнал действа едновременно като входен и изходен сигнал. Това позволява за изграждането на големи "дървета" от сигнали.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Нормален сигнал (електрически){}Сигналите са необходими за да предпазват влаковете от катастрофи по ЖП мрежата.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Входен сигнал (електрически){}Свети зелено докато има поне един зелен изходен сигнал от следващия сегмент от пътя. В противен случай свети червено.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Изходен сигнал (електрически){}Действа като нормален сигнал, но е необходим за да работят входните и комбинираните сигнали.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Комбиниран сигнал (електрически){}Комбинирания сигнал действа едновременно като входен и изходен сигнал. Това позволява за изграждането на големи "дървета" от сигнали.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Конвертиране на сигнал{}Когато е избран, натискането на съществуващ сигнал ще го конвертира в избрания тип и вариант, CTRL-click ще смени съществуващия вариант.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Плътност на сигналите при влачене
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Намалява плътноста на сигналите при влачене
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Увеличава плътноста на сигналите при влачене
+########
--- a/src/lang/catalan.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/catalan.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}No es pot netejar l'àrea....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright original {COPYRIGHT} 1995 Chris Sawyer, Tots els drets reservats
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versió {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 L'equip d'OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 L'equip d'OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Traductor(s) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -594,8 +594,8 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Informació de l'Empresa
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Obrir / tancar d'indústries
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Canvis de l'Economia
-STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Canvis de producció de l'indústria controlats pel jugador
-STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Canvis de producció de l'indústria controlats pel competidor(s)
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Canvis de producció en indústries proveïdes pel jugador
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Canvis de producció en indústries proveïdes pel competidor(s)
 STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Altres canvis de producció de l'indústria
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Avisos / informació dels teus vehicles
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Nous vehicles
@@ -941,6 +941,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Pantalla Completa
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Marca la casella per tenir l'OpenTTD en pantalla completa
+STR_FULLSCREEN_FAILED                                           :{WHITE}El mode en pantalla completa ha fallat
 
 STR_OPTIONS_RES                                                 :{BLACK}Resolució de Pantalla
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1169,6 +1170,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Permet comprar participacions d'altres empreses
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Arrossegant, sitúa senyals cada: {ORANGE}{STRING} quadre(s)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Construir semàfors automàticament abans de: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Activa la interfície de les senyals: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}El format de poble "no més carreteres" no és vàlid a l'editor d'escenaris
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Selecciona el format poble-carretera: {ORANGE}{STRING}
@@ -1705,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}L'edifici s'ha d'enderrocar primer
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Població: {ORANGE}{COMMA}{BLACK}  Cases: {ORANGE}{COMMA}
@@ -2308,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Trasllada la Seu
 STR_COMPANY_PASSWORD                                            :{BLACK}Contrasenya
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Protegeix la teva Empresa amb contrasenya per tal d'evitar que la utilitzin usuaris no autoritzats.
-STR_SET_COMPANY_PASSWORD                                        :Estableix la contrasenya de l'Empresa
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Estableix la contrasenya de l'Empresa
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}No desis la contrasenya introduïda
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Dóna a la companyia una nova contrasenya
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Contrasenya de la companyia
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Contrasenya de la companyia predeterminada
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Utilitza la contrasenya d'aquesta companyia com a predeterminada per a noves companyies
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Recessió Mundial!{}{}Economistes experts temen que l'economia es desplomi!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recessió Acabada!{}{}La millora als negocis dóna confiança a les indústries a la vegada que l'economia s'enforteix!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Intercanvia mida gran/petita de finestra
@@ -2789,6 +2797,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Nou/Nova {STRING} disponible!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}No es pot vendre el vehicle destruït...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}No es pot remodelar el vehicle destruït...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Impossible establir l'horari del vehicle...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Els vehicles només poden esperar a les estacions.
@@ -3109,6 +3118,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}S'han carregat els GRF(s) compatibles pels arxius faltants
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Els arxius GRF(s) faltants han estat desactivats
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Arxius GRF(s) faltants per poder carregar el joc
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Falten arxiu(s) GRF
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Treure la pausa pot provocar fallades d'OpenTTD. No informis d'errors a causa de fallades subseqüents.{}Estàs segur de voler treure la pausa?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Moneda personalitzada
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Canvi de moneda: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3444,3 +3455,20 @@
 STR_FACE_EARRING                                                :Arracades:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Canvia la corbata o les arracades
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Selecció de senyals
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Aquí no es pot convertir les senyals...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Senyal estàndard (semàfor){}Les senyals són necessàries per impedir que els trens s'accidentin en xarxes de ferrocarrils amb més d'un tren.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Senyal d'endrada (semàfor){}En verd mentre hi hagi una o més senyals de sortida en verd en la secció següent de vies. En cas contrari està en vermell.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Senyal de Sortida (semàfor){}Es comporta com una senyal normal però és necessari actuar sobre el color correcte en les pre-senyals d'entrada i combinada.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Senyal Combinada (semàfor){}La senyal combinada simplement actua com a senyal d'entrada i sortida. Això permet construir grans extensions de pre-senyals.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Senyal estàndard (elèctrica){}Les senyals són necessàries per impedir que els trens s'accidentin en xarxes de ferrocarrils amb més d'un tren.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Senyal d'endrada (elèctrica){}En verd mentre hi hagi una o més senyals de sortida en verd en la secció següent de vies. En cas contrari està en vermell.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Senyal de Sortida (elèctrica){}Es comporta com una senyal normal però és necessari actuar sobre el color correcte en les pre-senyals d'entrada i combinada.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Senyal Combinada (elèctrica){}La senyal combinada simplement actua com a senyal d'entrada i sortida. Això permet construir grans extensions de pre-senyals.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Conversió de senyals{}Quan esta seleccionat, clicant una senyal existent la converteix en el tipus de senyal seleccionada i variants, CTRL-clic commuta la variant existent.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Densitat de senyals en arrossegar
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Disminueix la densitat de senyals en arrossegar
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Incrementa la densitat de senyals en arrossegar
+########
--- a/src/lang/croatian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/croatian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -596,6 +596,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Podatci vezani za tvrtku
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Otvaranje / zatvaranje industrija
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Promjene u gospodarstvu
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Izmjene u produktivnosti industrija djelovanjem igrača
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Izmjene u produktivnosti industrija djelovanjem suparnika
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Ostale izmjene u produktivnosti industrija
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Savjet / informacija o vozilima igrača
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Nova vozila
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Promjene u prihvaćanju tereta
@@ -940,6 +943,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Cijeli ekran
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Označi ovu kućicu kako bi igrao OpenTTD preko cijelog ekrana
+STR_FULLSCREEN_FAILED                                           :{WHITE}Neuspješan prelazak na prikaz na cijelom ekranu
 
 STR_OPTIONS_RES                                                 :{BLACK}Razlučivost ekrana
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1168,6 +1172,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Dopusti kupovanje udjela u drugim tvrtkama
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Kod povlačenja, postavi signale svakih; {ORANGE}{STRING} pločica
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automatski izgradi semafore prije: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Omogući signalni GUI: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Raspored grada "nema više cesta" nije valjan u editoru scenarija
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Odaberi grad-cesta raspored: {ORANGE}{STRING}
@@ -1682,6 +1687,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Izgradi tramvajski most
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Izgradi cestovni tunel
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Izgradi tramvajski tunel
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Aktiviraj/deaktiviraj jednosmjerne ceste
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Aktiviraj izgradnju/uklanjanje ceste
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Aktiviraj izgradnju/brisanje za izgradnju tramvaja
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Odaberi smjer spremišta cestovnih vozila
@@ -1703,6 +1709,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Najprije moraš srušiti građevinu
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Stanovništvo: {ORANGE}{COMMA}{BLACK}  Kuće: {ORANGE}{COMMA}
@@ -2306,7 +2313,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Premjesti sjedište kompanije
 STR_COMPANY_PASSWORD                                            :{BLACK}Zaporka
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Zaštiti svoju tvrtku od neovlaštenog korištenja pomoću zaporke.
-STR_SET_COMPANY_PASSWORD                                        :Postavi zaporku tvrtke
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Postavi zaporku tvrtke
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Nemoj spremiti upisanu zaporku
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Daj tvrtci novu zaporku
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Zaporka tvrtke
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Inicijalna zaporka tvrtke
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Uporabi zaporku ove tvrtke kao inicijalnu za nove tvrtke
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Svjetska recesija!{}{}Financijski stručnjaci očekuju najgore zbog ekonomske krize!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recesija završena!{}{}Obrat  u trgovanu daje samopouzdanje gospodarstvu jer ekonomija jača!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Namjesti veliku/malu veličinu prozora
@@ -2787,6 +2799,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Novi {STRING} je sada dostupan! - {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Ne mogu prodati uništeno vozilo...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Ne mogu prenamijeniti uništeno vozilo...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Nije moguće rasporediti vozilo...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Vozila mogu čekati samo na stanicama.
@@ -3107,6 +3120,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatibilni GRF(ovi) učitani umjesto nepronađenih datoteka
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Nepronađene GRF datoteke su isključene
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Nedostaje(u) datoteka(e) GRF za učitavanje igre
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Nedostaje GRF datoteka(e)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Odpauziranje može uzrokovati rušenje OpenTTD-a. Nemojte slati prijave bugova za posljedična rušenja.{}Želite li stvarno odpauzirati?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Proizvoljna valuta
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Devizni tečaj: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3287,6 +3302,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Centriraj malu mapu na trenutni položaj
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Mala
@@ -3441,3 +3457,20 @@
 STR_FACE_EARRING                                                :Naušnica:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Promijeni kravatu ili naušnicu
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Izbornik signala
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Ovdje nije moguće konvertirati signale...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standardni signal (semafor){}Signali su nužni kako bi spriječili vlakove da se sudaraju na pružnim mrežama s više od jednog vlaka.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Ulazni signal (semafor){}Zeleno sve dok je jedan ili više zelenih izlaznih signala na narednom dijelu pruge. U protivnom pokazuje crveno.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Izlazni signal (semafor){}Ponaša se na isti način kao i normalni signali, ali je nužno potrefiti točnu boju na ulaznim & kombo pre-signalima.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Kombo signal (semafor){}Kombo singal jednostavno radi kao ulazni i izlazni signal. Ovo omogućava izgradnju velike "šume" pre-signala.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standardni signal (električni){}Signali su nužni kako bi spriječili vlakove da se sudaraju na pružnim mrežama s više od jednog vlaka
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Ulazni signal (električni){}Zeleno sve dok je jedan ili više zelenih izlaznih signala na narednom dijelu pruge. U protivnom pokazuje crveno.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Izlazni signal (električni){}Ponaša se na isti način kao i normalni signali, ali je nužno potrefiti točnu boju na ulaznim & kombo pre-signalima.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Kombo signal (električni){}Kombo signal jednostavno radi kao ulazni i izlazni signal. Ovo omogućava izgradnju velike "šume" pre-signala.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Pretvaranje signala{}Kada je označeno, klikanjem na bilo koji postojeći signal pretvara taj signal u odabrani tip i varijantu, CRTL+klik mijenja postojeću varijantu.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Gustoća signala prilikom izgradnje
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Smanji gustoću signala prilikom izgradnje
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Povećaj gustoću signala prilikom izgradnje
+########
--- a/src/lang/czech.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/czech.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -218,7 +218,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Nemůžeš vyčistit tuto oblast...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Původní copyright: {COPYRIGHT} 1995 Chris Sawyer, všechna práva vyhrazena
 STR_00B7_VERSION                                                :{BLACK}OpenTTD verze {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 Tým OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 Tým OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Překladatel(é) - Hadez, iSteve
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -999,6 +999,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Na celou obrazovku
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Zaškrtnutím této volby poběží OpenTTD na celé obrazovce
+STR_FULLSCREEN_FAILED                                           :{WHITE}Selhalo přepnutí na celou obrazovku
 
 STR_OPTIONS_RES                                                 :{BLACK}Rozlišení obrazovky
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1227,6 +1228,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Povolit kupování podílu z ostatních společností
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Při tažení umisťovat signály každých(é): {ORANGE}{STRING} dilků(y)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Semafory automaticky stavět do roku: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Okno pro stavbu signálů: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Vzor "žádné silnice" se neuplatňuje v editoru scénářů
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Vyber vzor městských silnic: {ORANGE}{STRING}
@@ -1763,6 +1765,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Budova musí být nejprve zničena
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Populace: {ORANGE}{COMMA}{BLACK} Domů: {ORANGE}{COMMA}
@@ -2366,7 +2369,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Přesídlit
 STR_COMPANY_PASSWORD                                            :{BLACK}Heslo
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Heslo - zabrání neautorizovaným uživatelům v připojení se k tvé společnosti.
-STR_SET_COMPANY_PASSWORD                                        :Nastav heslo společnosti.
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Nastav heslo společnosti.
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Neukládat zadané heslo
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Změnit heslo společnosti
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Heslo společnosti
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Výchozí heslo společností
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Použít toto heslo jako výchozí pro nově založené společnosti
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Celosvětový hospodářský úpadek!{}{}Finanční experti se kvůli prudkému poklesu ekonomiky obávají nejhoršího!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Konec hospodářského úpadku!{}{}Posílení trhu zvýšilo u průmyslu důvěru!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Přepnout velké/malé okno
@@ -2853,6 +2861,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Nov{G á ý é} {STRING} k dispozici!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Nelze prodat zničené vozidlo...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Nelze přestavět zničené vozidlo...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Tomuto vozidlu nejde nastavit jízdní řád...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Vozidla mohou čekat jen ve stanicích.
@@ -3173,6 +3182,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatibilní GRF načteny místo chybějících
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Chybějící soubory GRF byly vyřazeny
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Pro načtení hry chybí GRF soubory
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Chybějící grafické soubory
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Spuštění hry může shodit OpenTTD. Nehlaš chybu kvůli pádům způsobeným touto akcí.{}Opravdu chceš rozjet hru?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Vlastní měna
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Kurz měny: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3508,3 +3519,20 @@
 STR_FACE_EARRING                                                :Náušnice:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Změnit kravatu nebo náušnice
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Výběr signálů
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Zde nelze změnit signály...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standardní signál (semafor){}Signály jsou nutné, aby nedocházelo ke srážkám vlaků na tratích, kde jezdí více než jeden vlak.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Vjezdový signál (semafor){}Svítí zeleně do té doby, kdy v dalším úseku trati je alespoň jeden zeleně svítící výjezdový signál. Jinak svítí červeně.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Výjezdový signál (semafor){}Chová se stejně jako normální signál, ale musí se aktivovat správné světlo na vjezdovém a kombinovaném presignálu.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Kombinovaný signál (semafor){}Kombinovaný signál jednoduše slouží jako zároveň vjezdový a výjezdový signál. Tím je možné postavit velké "řetězce" presignálů.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standardní signál (elektrický){}Signály jsou nutné, aby nedocházelo ke srážkám vlaků na tratích, kde jezdí více než jeden vlak.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Vjezdový signál (elektrický){}Svítí zeleně do té doby, kdy v dalším úseku trati je alespoň jeden zeleně svítící výjezdový signál. Jinak svítí červeně.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Výjezdový signál (elektrický){}Chová se stejně jako normální signál, ale musí se aktivovat správné světlo na vjezdovém a kombinovaném presignálu.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Kombinovaný signál (elektrický){}Kombinovaný signál jednoduše slouží jako zároveň vjezdový a výjezdový signál. Tím je možné postavit velké "řetězce" presignálů.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Změna signálů{}Pokud je vybrána, signál se změní kliknutím na něj. Při kliknutí s CTRL se bude přepínat mezi variantami existujícího signálu.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Rozestup při stavbě signálů tažením
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Snížit rozestup mezi signály
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Zvýšit rozestup mezi signály
+########
--- a/src/lang/danish.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/danish.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Kan ikke rydde området....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Original copyright {COPYRIGHT} 1995 Chris Sawyer, Alle rettigheder reserveret
 STR_00B7_VERSION                                                :{BLACK}OpenTTD version {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD teamet
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD teamet
 STR_TRANSLATED_BY                                               :{BLACK}  Oversætter(e) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -1010,10 +1010,10 @@
 STR_AIRCRAFT_HAS_INVALID_ENTRY                                  :{WHITE}Fly {COMMA} har en ugyldig lufthavn i sin ordreliste
 # end of order system
 
-STR_TRAIN_AUTORENEW_FAILED                                      :{WHITE}Automatisk fornyelse af tog mislykkedes {COMMA} (ikke penge nok)
-STR_ROADVEHICLE_AUTORENEW_FAILED                                :{WHITE}Automatisk fornyelse af køretøj mislykkedes {COMMA} (ikke penge nok)
-STR_SHIP_AUTORENEW_FAILED                                       :{WHITE}Automatisk fornyelse af skib mislykkedes {COMMA} (ikke penge nok)
-STR_AIRCRAFT_AUTORENEW_FAILED                                   :{WHITE}Automatisk fornyelse af fly mislykkedes {COMMA} (ikke penge nok)
+STR_TRAIN_AUTORENEW_FAILED                                      :{WHITE}Automatisk fornyelse af tog {COMMA} mislykkedes (ikke penge nok)
+STR_ROADVEHICLE_AUTORENEW_FAILED                                :{WHITE}Automatisk fornyelse af køretøj {COMMA} mislykkedes (ikke penge nok)
+STR_SHIP_AUTORENEW_FAILED                                       :{WHITE}Automatisk fornyelse af skib {COMMA} mislykkedes (ikke penge nok)
+STR_AIRCRAFT_AUTORENEW_FAILED                                   :{WHITE}Automatisk fornyelse af fly {COMMA} mislykkedes (ikke penge nok)
 STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT                            :{WHITE}Tog {COMMA} er for langt efter udskiftning
 
 STR_CONFIG_PATCHES                                              :{BLACK}Indstil programrettelser
@@ -1169,6 +1169,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Tillad at købe aktier i andre selskaber
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Ved trækning placer signal hvert: {ORANGE}{STRING} felt
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Byg automatisk semaforer før: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Slå signalbrugerfladen til: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Vejlayoutet "ikke flere veje" er ikke gyldigt i scenarieeditoren
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Vælg layout for veje i byer: {ORANGE}{STRING}
@@ -1705,6 +1706,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Det er nødvendigt at nedrive bygningen først
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Indbyggere: {ORANGE}{COMMA}{BLACK}  Huse: {ORANGE}{COMMA}
@@ -2308,7 +2310,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Flyt hovedkvarter
 STR_COMPANY_PASSWORD                                            :{BLACK}Kodeord
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Beskyt dit selskab med et kodeord for at undgå, at fremmede slutter sig til spillet.
-STR_SET_COMPANY_PASSWORD                                        :Sæt selskabets kodeord
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Sæt selskabets kodeord
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Gem ikke den indtastede adgangskode
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Giv firmaet den nye adgangskode
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Firma-adgangskode
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Standard firma-adgangskode
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Brug denne firma-adgangskode som standard for nye firmaer
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Lavkonjuktur over hele verden!{}{}Vismændende frygter det værste, økonomien skrumper!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Økonomisk krise overvundet!{}{}Stigning i forbrug giver industrien selvtilliden tilbage, produktionen øges!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Skift mellem stort/lille vindue
@@ -3109,6 +3116,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatible GRF fil(er) indlæst i stedet for manglende fil(er)
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Manglende GRF fil(er) er blevet slået fra
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Mangler GRF fil(er) for at kunne indlæse spillet
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Manglende GRF-fil(er)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}OpenTTD kan gå ned, når spillet sættes i gang igen. Undlad at indsende fejlrapporter for efterfølgende nedbrud.{}Vil du virkelig sætte spillet i gang igen?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Brugerdefineret møntfod
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Kurs: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3444,3 +3453,20 @@
 STR_FACE_EARRING                                                :Ørering:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Ændre slips eller ørering
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Signalvalg
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Kan ikke konvertere signaler her...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standardsignal (semafor){}Signaler er nødvendige for at undgå sammenstød mellem tog på jernbanenetværk med mere end et tog.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Indgangssignal (semafor){}Grønt så længe der er et eller flere grønne udgangssignaler fra den efterfølgende sporsektion. Ellers vises rødt.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Udgangssignal (semafor){}Fungerer som et normalt signal men er nødvendigt for at vise den korrekte farve ved indgangs- og kombisignaler.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Kombisignal (semafor){}Kombisignalet fungerer både som indgangs- og udgangssignal. Dette muliggør opbygning af store forgreninger af signaler.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standardsignal (electrisk){}Signaler er nødvendige for at undgå sammenstød mellem tog på jernbanenetværk med mere end et tog.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Indgangssignal (elektrisk){}Grønt så længe der er et eller flere grønne udgangssignaler fra den efterfølgende sporsektion. Ellers vises rødt.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Udgangssignal (elektrisk){}Fungerer som et normalt signal men er nødvendigt for at vise den korrekte farve ved indgangs- og kombisignaler.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Kombisignal (elektrisk){}Kombisignalet fungerer både som indgangs- og udgangssignal. Dette muliggør opbygning af store forgreninger af signaler.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Signalkonvertering{}Når denne er valgt, vil klik på et eksisterende signal konvertere det til den valgte signaltype og -variant. CTRL-klik vil skifte den eksisterende signalvariant.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Træk-og-slip signaltæthed
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Formindsk træk-og-slip signaltæthed
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Forøg træk-og-slip signaltæthed
+########
--- a/src/lang/dutch.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/dutch.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Kan gebied niet ontruimen....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Originele copyright {COPYRIGHT} 1995 Chris Sawyer, alle rechten voorbehouden
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versie {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 Het OpenTTD team
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 Het OpenTTD team
 STR_TRANSLATED_BY                                               :{BLACK}  Vertaler(s) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -941,6 +941,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Volledig scherm
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Vink dit vakje aan om OpenTTD in het volledige scherm te spelen
+STR_FULLSCREEN_FAILED                                           :{WHITE}Modus volledigscherm is mislukt
 
 STR_OPTIONS_RES                                                 :{BLACK}Schermresolutie
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1169,6 +1170,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Sta het kopen van aandelen toe
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Bij slepen, plaats seinen elke: {ORANGE}{STRING} tegel(s)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Plaats automatisch semaphore seinen voor: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Activeer sein GUI: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}De stadsindeling "geen wegen" is niet geldig in de scenario editor
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Selecteer stedelijke wegindeling: {ORANGE}{STRING}
@@ -1705,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Gebouw moet eerst gesloopt worden
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Bevolking: {ORANGE}{COMMA}{BLACK}  Huizen: {ORANGE}{COMMA}
@@ -2308,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Verplaats HQ
 STR_COMPANY_PASSWORD                                            :{BLACK}Wachtwoord
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Bescherm het bedrijf met een wachtwoord zodat niet geautoriseerde personen niet mee kunnen doen.
-STR_SET_COMPANY_PASSWORD                                        :Geef bedrijfswachtwoord op
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Geef bedrijfswachtwoord op
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Sla het ingegeven wachtwoord niet op
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Geef het bedrijf het nieuwe wachtwoord
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Bedrijfswachtwoord
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Standaard bedrijfswachtwoord
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Gebruik dit bedrijfswachtwoord als standaard voor nieuwe bedrijven
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Wereld Recessie!{}{}Financiële experts vrezen het ergste terwijl economie ineen stort!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recessie Voorbij!{}{}Stijgende handel geeft industrie vertrouwen terwijl economie verstevigt!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Schakel tussen groot/klein venster
@@ -2789,6 +2797,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Nieuw {STRING} nu beschikbaar!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Kan verwoest voertuig niet verkopen...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Kan vernietigd voortuig niet aanpassen...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Kan geen dienstregeling opzetten voor dit voertuig...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Voertuigen kunnen alleen wachten op stations.
@@ -3109,6 +3118,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Compatibele GRF(s) geladen voor ontbrekende bestanden
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Missend(e) GRF bestand(en) zijn uitgeschakeld
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Er zijn missende GRF bestanden om het spel te laden
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Ontbrekende GRF bestand(en)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Pauze uit zetten kan OpenTTD laten vastlopen. Geef geen fout rapporten bij herhaaldelijk vastlopen.{}Weet je zeker dat je pauze wilt uit zetten?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Aangepaste valuta
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Wisselkoers: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3444,3 +3455,20 @@
 STR_FACE_EARRING                                                :Oorbel:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Verander das of oorbel
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Sein keuze
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Kan sein hier niet ombouwen...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standaard sein (semaphore){}Seinen zijn nodig om te voorkomen dat treinen botsen bij een netwerk met meer dan een trein.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Ingangssein (semaphore){}Groen zolang als er een of meer groene exitseinen zijn volgend na dit sein. Anders is deze rood.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Exitsein (semaphore){}Gedraagt zich hetzelfde als een gewoon sein, maar is nodig om ingangs- en combo-voor-seinen te sturen.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Combo-Sein (semaphore){}Het combo sein gedraagt zicht als zowel Ingangs- als exit-sein. Zo kun je grote netwerken van voorseinen maken.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standaard sein (electric){}Seinen zijn nodig om te voorkomen dat treinen botsen bij netwerken met meer dan een trein.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Ingangssein (electric){}Groen wanneer er meer dan een groen exit-sein is in het volgende traject. Anders is deze rood.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Exit-sein (electric){}Gedraagt zich hetzelfde als een standaard sein, maar is nodig om ingangs- & combo voorseinen aan te sturen.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Combo-sein (electric){}Het combo sein gedraagt zicht als zowel ingangs- als exit-sein. Zo kun je grote netwerken van voorseinen maken.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Sein ombouwen{}Wanneer geselecteerd, door te klikken op een bestaand seintype, zal het sein worden omgebouwd naar het geselecteerde seintype en varianten, CTRL-klik schakeld tussen de bestaande varianten.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Sleep sein dichtheid
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Verklein gesleepte sein dichtheid
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Vergroot gesleepte sein dichtheid
+########
--- a/src/lang/english.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/english.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -1,4 +1,4 @@
-##name English
+##name English (UK)
 ##ownname English (UK)
 ##isocode en_GB
 ##plural 0
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Can't clear this area....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Original copyright {COPYRIGHT} 1995 Chris Sawyer, All rights reserved
 STR_00B7_VERSION                                                :{BLACK}OpenTTD version {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 The OpenTTD team
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 The OpenTTD team
 STR_TRANSLATED_BY                                               :{BLACK}  Translator(s) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -432,7 +432,7 @@
 STR_0171_PAUSE_GAME                                             :{BLACK}Pause game
 STR_0172_SAVE_GAME_ABANDON_GAME                                 :{BLACK}Save game, abandon game, quit
 STR_0173_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's stations
-STR_0174_DISPLAY_MAP                                            :{BLACK}Display map
+STR_0174_DISPLAY_MAP                                            :{BLACK}Display map, extra viewport or list of signs
 STR_0175_DISPLAY_MAP_TOWN_DIRECTORY                             :{BLACK}Display map, town directory
 STR_0176_DISPLAY_TOWN_DIRECTORY                                 :{BLACK}Display town directory
 STR_0177_DISPLAY_COMPANY_FINANCES                               :{BLACK}Display company finances information
@@ -854,7 +854,7 @@
 STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE                            :{BLACK}Select 'sub-arctic' landscape style
 STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE                          :{BLACK}Select 'sub-tropical' landscape style
 STR_0311_SELECT_TOYLAND_LANDSCAPE                               :{BLACK}Select 'toyland' landscape style
-STR_0312_FUND_CONSTRUCTION_OF_NEW                               :{BLACK}Fund construction of new industry
+STR_0312_FUND_CONSTRUCTION_OF_NEW                               :{BLACK}Fund construction of new industry or list all industries
 
 ############ range for menu starts
 STR_INDUSTRY_DIR                                                :Industry Directory
@@ -941,6 +941,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Fullscreen
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Check this box to play OpenTTD fullscreen mode
+STR_FULLSCREEN_FAILED                                           :{WHITE}Fullscreen mode failed
 
 STR_OPTIONS_RES                                                 :{BLACK}Screen resolution
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1169,6 +1170,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Allow buying shares from other companies
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}When dragging, place signals every: {ORANGE}{STRING1} tile(s)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automatically build semaphores before: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Enable the signal GUI: {ORANGE}{STRING1}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}The town layout "no more roads" isn't valid in the scenario editor
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Select town-road layout: {ORANGE}{STRING1}
@@ -1705,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Building must be demolished first
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Population: {ORANGE}{COMMA}{BLACK}  Houses: {ORANGE}{COMMA}
@@ -2308,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Relocate HQ
 STR_COMPANY_PASSWORD                                            :{BLACK}Password
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Password-protect your company to prevent unauthorised users from joining.
-STR_SET_COMPANY_PASSWORD                                        :Set company password
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Set company password
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Do not save the entered password
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Give the company the new password
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Company password
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Default company password
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Use this company password as default for new companies
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}World Recession!{}{}Financial experts fear worst as economy slumps!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recession Over!{}{}Upturn in trade gives confidence to industries as economy strengthens!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Toggle large/small window size
@@ -2789,6 +2797,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}New {STRING} now available!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Can't sell destroyed vehicle...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Can't refit destroyed vehicle...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Can't timetable vehicle...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Vehicles can only wait at stations.
@@ -3109,6 +3118,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Compatible GRF(s) loaded for missing files
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Missing GRF file(s) have been disabled
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Missing GRF file(s) to be able to load game
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Missing GRF file(s)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Unpausing can crash OpenTTD. Do not file bug reports for subsequent crashes.{}Do you really want to unpause?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Custom currency
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Exchange rate: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3444,3 +3455,20 @@
 STR_FACE_EARRING                                                :Earring:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Change tie or earring
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Signal Selection
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Can't convert signals here...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standard Signal (semaphore){}Signals are necessary to keep trains from crashing on railway networks with more than one train.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Entry-Signal (semaphore){}Green as long as there is one or more green exit-signal from the following section of track. Otherwise it shows red.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Exit-Signal (semaphore){}Behaves in the same way as a normal signal but is necessary to trigger the correct colour on entry & combo pre-signals.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Combo-Signal (semaphore){}The combo signal simply acts as both an entry and exit signal. This allows you to build large "trees" of presignals.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standard Signal (electric){}Signals are necessary to keep trains from crashing on railway networks with more than one train.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Entry-Signal (electric){}Green as long as there is one or more green exit-signal from the following section of track. Otherwise it shows red.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Exit-Signal (electric){}Behaves in the same way as a normal signal but is necessary to trigger the correct colour on entry & combo pre-signals.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Combo-Signal (electric){}The combo signal simply acts as both an entry and exit signal. This allows you to build large "trees" of presignals.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Signal Convert{}When selected, clicking an existing signal will convert it to the selected signal type and variant, CTRL-click will toggle the existing variant.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Dragging signal density
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Decrease dragging signal density
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Increase dragging signal density
+########
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lang/english_US.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,3470 @@
+##name English (US)
+##ownname English (US)
+##isocode en_US
+##plural 0
+
+#
+
+##id 0x0000
+STR_NULL                                                        :
+STR_0001_OFF_EDGE_OF_MAP                                        :{WHITE}Off edge of map
+STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP                               :{WHITE}Too close to edge of map
+STR_0003_NOT_ENOUGH_CASH_REQUIRES                               :{WHITE}Not enough cash - requires {CURRENCY}
+STR_0004                                                        :{WHITE}{CURRENCY}
+STR_EMPTY                                                       :
+STR_0007_FLAT_LAND_REQUIRED                                     :{WHITE}Flat land required
+STR_0008_WAITING                                                :{BLACK}Waiting: {WHITE}{STRING}
+STR_0009                                                        :{WHITE}{CARGO}
+STR_000A_EN_ROUTE_FROM                                          :{WHITE}{CARGO}{YELLOW}  (en-route from
+STR_000B                                                        :{YELLOW}{STATION})
+STR_000C_ACCEPTS                                                :{BLACK}Accepts: {WHITE}
+STR_000D_ACCEPTS                                                :{BLACK}Accepts: {GOLD}
+STR_000E                                                        :
+STR_000F_PASSENGERS                                             :Passengers
+STR_0010_COAL                                                   :Coal
+STR_0011_MAIL                                                   :Mail
+STR_0012_OIL                                                    :Oil
+STR_0013_LIVESTOCK                                              :Livestock
+STR_0014_GOODS                                                  :Goods
+STR_0015_GRAIN                                                  :Grain
+STR_0016_WOOD                                                   :Wood
+STR_0017_IRON_ORE                                               :Iron Ore
+STR_0018_STEEL                                                  :Steel
+STR_0019_VALUABLES                                              :Valuables
+STR_001A_COPPER_ORE                                             :Copper Ore
+STR_001B_MAIZE                                                  :Maize
+STR_001C_FRUIT                                                  :Fruit
+STR_001D_DIAMONDS                                               :Diamonds
+STR_001E_FOOD                                                   :Food
+STR_001F_PAPER                                                  :Paper
+STR_0020_GOLD                                                   :Gold
+STR_0021_WATER                                                  :Water
+STR_0022_WHEAT                                                  :Wheat
+STR_0023_RUBBER                                                 :Rubber
+STR_0024_SUGAR                                                  :Sugar
+STR_0025_TOYS                                                   :Toys
+STR_0026_CANDY                                                  :Candy
+STR_0027_COLA                                                   :Cola
+STR_0028_COTTON_CANDY                                           :Cotton Candy
+STR_0029_BUBBLES                                                :Bubbles
+STR_002A_TOFFEE                                                 :Toffee
+STR_002B_BATTERIES                                              :Batteries
+STR_002C_PLASTIC                                                :Plastic
+STR_002D_FIZZY_DRINKS                                           :Fizzy Drinks
+STR_002E                                                        :
+STR_002F_PASSENGER                                              :Passenger
+STR_0030_COAL                                                   :Coal
+STR_0031_MAIL                                                   :Mail
+STR_0032_OIL                                                    :Oil
+STR_0033_LIVESTOCK                                              :Livestock
+STR_0034_GOODS                                                  :Goods
+STR_0035_GRAIN                                                  :Grain
+STR_0036_WOOD                                                   :Wood
+STR_0037_IRON_ORE                                               :Iron Ore
+STR_0038_STEEL                                                  :Steel
+STR_0039_VALUABLES                                              :Valuables
+STR_003A_COPPER_ORE                                             :Copper Ore
+STR_003B_MAIZE                                                  :Maize
+STR_003C_FRUIT                                                  :Fruit
+STR_003D_DIAMOND                                                :Diamond
+STR_003E_FOOD                                                   :Food
+STR_003F_PAPER                                                  :Paper
+STR_0040_GOLD                                                   :Gold
+STR_0041_WATER                                                  :Water
+STR_0042_WHEAT                                                  :Wheat
+STR_0043_RUBBER                                                 :Rubber
+STR_0044_SUGAR                                                  :Sugar
+STR_0045_TOY                                                    :Toy
+STR_0046_CANDY                                                  :Candy
+STR_0047_COLA                                                   :Cola
+STR_0048_COTTON_CANDY                                           :Cotton Candy
+STR_0049_BUBBLE                                                 :Bubble
+STR_004A_TOFFEE                                                 :Toffee
+STR_004B_BATTERY                                                :Battery
+STR_004C_PLASTIC                                                :Plastic
+STR_004D_FIZZY_DRINK                                            :Fizzy Drink
+STR_QUANTITY_NOTHING                                            :
+STR_QUANTITY_PASSENGERS                                         :{COMMA} passenger{P "" s}
+STR_QUANTITY_COAL                                               :{WEIGHT} of coal
+STR_QUANTITY_MAIL                                               :{COMMA} bag{P "" s} of mail
+STR_QUANTITY_OIL                                                :{VOLUME} of oil
+STR_QUANTITY_LIVESTOCK                                          :{COMMA} item{P "" s} of livestock
+STR_QUANTITY_GOODS                                              :{COMMA} crate{P "" s} of goods
+STR_QUANTITY_GRAIN                                              :{WEIGHT} of grain
+STR_QUANTITY_WOOD                                               :{WEIGHT} of wood
+STR_QUANTITY_IRON_ORE                                           :{WEIGHT} of iron ore
+STR_QUANTITY_STEEL                                              :{WEIGHT} of steel
+STR_QUANTITY_VALUABLES                                          :{COMMA} bag{P "" s} of valuables
+STR_QUANTITY_COPPER_ORE                                         :{WEIGHT} of copper ore
+STR_QUANTITY_MAIZE                                              :{WEIGHT} of maize
+STR_QUANTITY_FRUIT                                              :{WEIGHT} of fruit
+STR_QUANTITY_DIAMONDS                                           :{COMMA} bag{P "" s} of diamonds
+STR_QUANTITY_FOOD                                               :{WEIGHT} of food
+STR_QUANTITY_PAPER                                              :{WEIGHT} of paper
+STR_QUANTITY_GOLD                                               :{COMMA} bag{P "" s} of gold
+STR_QUANTITY_WATER                                              :{VOLUME} of water
+STR_QUANTITY_WHEAT                                              :{WEIGHT} of wheat
+STR_QUANTITY_RUBBER                                             :{VOLUME} of rubber
+STR_QUANTITY_SUGAR                                              :{WEIGHT} of sugar
+STR_QUANTITY_TOYS                                               :{COMMA} toy{P "" s}
+STR_QUANTITY_SWEETS                                             :{COMMA} bag{P "" s} of candy
+STR_QUANTITY_COLA                                               :{VOLUME} of cola
+STR_QUANTITY_CANDYFLOSS                                         :{WEIGHT} of cotton candy
+STR_QUANTITY_BUBBLES                                            :{COMMA} bubble{P "" s}
+STR_QUANTITY_TOFFEE                                             :{WEIGHT} of toffee
+STR_QUANTITY_BATTERIES                                          :{COMMA} batter{P y ies}
+STR_QUANTITY_PLASTIC                                            :{VOLUME} of plastic
+STR_QUANTITY_FIZZY_DRINKS                                       :{COMMA} fizzy drink{P "" s}
+STR_ABBREV_NOTHING                                              :
+STR_ABBREV_PASSENGERS                                           :{TINYFONT}PS
+STR_ABBREV_COAL                                                 :{TINYFONT}CL
+STR_ABBREV_MAIL                                                 :{TINYFONT}ML
+STR_ABBREV_OIL                                                  :{TINYFONT}OL
+STR_ABBREV_LIVESTOCK                                            :{TINYFONT}LV
+STR_ABBREV_GOODS                                                :{TINYFONT}GD
+STR_ABBREV_GRAIN                                                :{TINYFONT}GR
+STR_ABBREV_WOOD                                                 :{TINYFONT}WD
+STR_ABBREV_IRON_ORE                                             :{TINYFONT}OR
+STR_ABBREV_STEEL                                                :{TINYFONT}ST
+STR_ABBREV_VALUABLES                                            :{TINYFONT}VL
+STR_ABBREV_COPPER_ORE                                           :{TINYFONT}CO
+STR_ABBREV_MAIZE                                                :{TINYFONT}MZ
+STR_ABBREV_FRUIT                                                :{TINYFONT}FT
+STR_ABBREV_DIAMONDS                                             :{TINYFONT}DM
+STR_ABBREV_FOOD                                                 :{TINYFONT}FD
+STR_ABBREV_PAPER                                                :{TINYFONT}PR
+STR_ABBREV_GOLD                                                 :{TINYFONT}GD
+STR_ABBREV_WATER                                                :{TINYFONT}WR
+STR_ABBREV_WHEAT                                                :{TINYFONT}WH
+STR_ABBREV_RUBBER                                               :{TINYFONT}RB
+STR_ABBREV_SUGAR                                                :{TINYFONT}SG
+STR_ABBREV_TOYS                                                 :{TINYFONT}TY
+STR_ABBREV_SWEETS                                               :{TINYFONT}SW
+STR_ABBREV_COLA                                                 :{TINYFONT}CL
+STR_ABBREV_CANDYFLOSS                                           :{TINYFONT}CF
+STR_ABBREV_BUBBLES                                              :{TINYFONT}BU
+STR_ABBREV_TOFFEE                                               :{TINYFONT}TF
+STR_ABBREV_BATTERIES                                            :{TINYFONT}BA
+STR_ABBREV_PLASTIC                                              :{TINYFONT}PL
+STR_ABBREV_FIZZY_DRINKS                                         :{TINYFONT}FZ
+STR_ABBREV_NONE                                                 :{TINYFONT}NO
+STR_ABBREV_ALL                                                  :{TINYFONT}ALL
+STR_00AE                                                        :{WHITE}{DATE_SHORT}
+STR_00AF                                                        :{WHITE}{DATE_LONG}
+STR_00B0_MAP                                                    :{WHITE}Map - {STRING}
+STR_00B1_GAME_OPTIONS                                           :{WHITE}Game Options
+STR_00B2_MESSAGE                                                :{YELLOW}Message
+STR_00B3_MESSAGE_FROM                                           :{YELLOW}Message from {STRING}
+STR_POPUP_CAUTION_CAPTION                                       :{WHITE}Caution!
+STR_00B4_CAN_T_DO_THIS                                          :{WHITE}Can't do this....
+STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Can't clear this area....
+STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Original copyright {COPYRIGHT} 1995 Chris Sawyer, All rights reserved
+STR_00B7_VERSION                                                :{BLACK}OpenTTD version {REV}
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 The OpenTTD team
+STR_TRANSLATED_BY                                               :{BLACK}  Translator(s) -
+
+STR_00C5                                                        :{BLACK}{CROSS}
+STR_00C6                                                        :{SILVER}{CROSS}
+STR_00C7_QUIT                                                   :{WHITE}Quit
+STR_00C8_YES                                                    :{BLACK}Yes
+STR_00C9_NO                                                     :{BLACK}No
+STR_00CA_ARE_YOU_SURE_YOU_WANT_TO                               :{YELLOW}Are you sure you want to abandon this game and return to {STRING}?
+STR_00CB_1                                                      :{BLACK}1
+STR_00CC_2                                                      :{BLACK}2
+STR_00CD_3                                                      :{BLACK}3
+STR_00CE_4                                                      :{BLACK}4
+STR_00CF_5                                                      :{BLACK}5
+STR_00D0_NOTHING                                                :Nothing
+STR_00D1_DARK_BLUE                                              :Dark Blue
+STR_00D2_PALE_GREEN                                             :Pale Green
+STR_00D3_PINK                                                   :Pink
+STR_00D4_YELLOW                                                 :Yellow
+STR_00D5_RED                                                    :Red
+STR_00D6_LIGHT_BLUE                                             :Light Blue
+STR_00D7_GREEN                                                  :Green
+STR_00D8_DARK_GREEN                                             :Dark Green
+STR_00D9_BLUE                                                   :Blue
+STR_00DA_CREAM                                                  :Cream
+STR_00DB_MAUVE                                                  :Mauve
+STR_00DC_PURPLE                                                 :Purple
+STR_00DD_ORANGE                                                 :Orange
+STR_00DE_BROWN                                                  :Brown
+STR_00DF_GREY                                                   :Gray
+STR_00E0_WHITE                                                  :White
+STR_00E1_TOO_MANY_VEHICLES_IN_GAME                              :{WHITE}Too many vehicles in game
+STR_00E2                                                        :{BLACK}{COMMA}
+STR_00E3                                                        :{RED}{COMMA}
+STR_00E4_LOCATION                                               :{BLACK}Location
+STR_00E5_CONTOURS                                               :Contours
+STR_00E6_VEHICLES                                               :Vehicles
+STR_00E7_INDUSTRIES                                             :Industries
+STR_00E8_ROUTES                                                 :Routes
+STR_00E9_VEGETATION                                             :Vegetation
+STR_00EA_OWNERS                                                 :Owners
+STR_00EB_ROADS                                                  :{BLACK}{TINYFONT}Roads
+STR_00EC_RAILROADS                                              :{BLACK}{TINYFONT}Railroads
+STR_00ED_STATIONS_AIRPORTS_DOCKS                                :{BLACK}{TINYFONT}Stations/Airports/Docks
+STR_00EE_BUILDINGS_INDUSTRIES                                   :{BLACK}{TINYFONT}Buildings/Industries
+STR_00EF_VEHICLES                                               :{BLACK}{TINYFONT}Vehicles
+STR_00F0_100M                                                   :{BLACK}{TINYFONT}100m
+STR_00F1_200M                                                   :{BLACK}{TINYFONT}200m
+STR_00F2_300M                                                   :{BLACK}{TINYFONT}300m
+STR_00F3_400M                                                   :{BLACK}{TINYFONT}400m
+STR_00F4_500M                                                   :{BLACK}{TINYFONT}500m
+STR_00F5_TRAINS                                                 :{BLACK}{TINYFONT}Trains
+STR_00F6_ROAD_VEHICLES                                          :{BLACK}{TINYFONT}Road Vehicles
+STR_00F7_SHIPS                                                  :{BLACK}{TINYFONT}Ships
+STR_00F8_AIRCRAFT                                               :{BLACK}{TINYFONT}Aircraft
+STR_00F9_TRANSPORT_ROUTES                                       :{BLACK}{TINYFONT}Transport Routes
+STR_00FA_COAL_MINE                                              :{BLACK}{TINYFONT}Coal Mine
+STR_00FB_POWER_STATION                                          :{BLACK}{TINYFONT}Power Station
+STR_00FC_FOREST                                                 :{BLACK}{TINYFONT}Forest
+STR_00FD_SAWMILL                                                :{BLACK}{TINYFONT}Sawmill
+STR_00FE_OIL_REFINERY                                           :{BLACK}{TINYFONT}Oil Refinery
+STR_00FF_FARM                                                   :{BLACK}{TINYFONT}Farm
+STR_0100_FACTORY                                                :{BLACK}{TINYFONT}Factory
+STR_0101_PRINTING_WORKS                                         :{BLACK}{TINYFONT}Printing Works
+STR_0102_OIL_WELLS                                              :{BLACK}{TINYFONT}Oil Wells
+STR_0103_IRON_ORE_MINE                                          :{BLACK}{TINYFONT}Iron Ore Mine
+STR_0104_STEEL_MILL                                             :{BLACK}{TINYFONT}Steel Mill
+STR_0105_BANK                                                   :{BLACK}{TINYFONT}Bank
+STR_0106_PAPER_MILL                                             :{BLACK}{TINYFONT}Paper Mill
+STR_0107_GOLD_MINE                                              :{BLACK}{TINYFONT}Gold Mine
+STR_0108_FOOD_PROCESSING_PLANT                                  :{BLACK}{TINYFONT}Food Processing Plant
+STR_0109_DIAMOND_MINE                                           :{BLACK}{TINYFONT}Diamond Mine
+STR_010A_COPPER_ORE_MINE                                        :{BLACK}{TINYFONT}Copper Ore Mine
+STR_010B_FRUIT_PLANTATION                                       :{BLACK}{TINYFONT}Fruit Plantation
+STR_010C_RUBBER_PLANTATION                                      :{BLACK}{TINYFONT}Rubber Plantation
+STR_010D_WATER_SUPPLY                                           :{BLACK}{TINYFONT}Water Supply
+STR_010E_WATER_TOWER                                            :{BLACK}{TINYFONT}Water Tower
+STR_010F_LUMBER_MILL                                            :{BLACK}{TINYFONT}Lumber Mill
+STR_0110_COTTON_CANDY_FOREST                                    :{BLACK}{TINYFONT}Cotton Candy Forest
+STR_0111_CANDY_FACTORY                                          :{BLACK}{TINYFONT}Candy Factory
+STR_0112_BATTERY_FARM                                           :{BLACK}{TINYFONT}Battery Farm
+STR_0113_COLA_WELLS                                             :{BLACK}{TINYFONT}Cola Wells
+STR_0114_TOY_SHOP                                               :{BLACK}{TINYFONT}Toy Shop
+STR_0115_TOY_FACTORY                                            :{BLACK}{TINYFONT}Toy Factory
+STR_0116_PLASTIC_FOUNTAINS                                      :{BLACK}{TINYFONT}Plastic Fountains
+STR_0117_FIZZY_DRINK_FACTORY                                    :{BLACK}{TINYFONT}Fizzy Drink Factory
+STR_0118_BUBBLE_GENERATOR                                       :{BLACK}{TINYFONT}Bubble Generator
+STR_0119_TOFFEE_QUARRY                                          :{BLACK}{TINYFONT}Toffee Quarry
+STR_011A_SUGAR_MINE                                             :{BLACK}{TINYFONT}Sugar Mine
+STR_011B_RAILROAD_STATION                                       :{BLACK}{TINYFONT}Railroad Station
+STR_011C_TRUCK_LOADING_BAY                                      :{BLACK}{TINYFONT}Truck Loading Bay
+STR_011D_BUS_STATION                                            :{BLACK}{TINYFONT}Bus Station
+STR_011E_AIRPORT_HELIPORT                                       :{BLACK}{TINYFONT}Airport/Heliport
+STR_011F_DOCK                                                   :{BLACK}{TINYFONT}Dock
+STR_0120_ROUGH_LAND                                             :{BLACK}{TINYFONT}Rough Land
+STR_0121_GRASS_LAND                                             :{BLACK}{TINYFONT}Grass Land
+STR_0122_BARE_LAND                                              :{BLACK}{TINYFONT}Bare Land
+STR_0123_FIELDS                                                 :{BLACK}{TINYFONT}Fields
+STR_0124_TREES                                                  :{BLACK}{TINYFONT}Trees
+STR_0125_ROCKS                                                  :{BLACK}{TINYFONT}Rocks
+STR_0126_WATER                                                  :{BLACK}{TINYFONT}Water
+STR_0127_NO_OWNER                                               :{BLACK}{TINYFONT}No Owner
+STR_0128_TOWNS                                                  :{BLACK}{TINYFONT}Towns
+STR_0129_INDUSTRIES                                             :{BLACK}{TINYFONT}Industries
+STR_012A_DESERT                                                 :{BLACK}{TINYFONT}Desert
+STR_012B_SNOW                                                   :{BLACK}{TINYFONT}Snow
+STR_012C_MESSAGE                                                :{WHITE}Message
+STR_012D                                                        :{WHITE}{STRING}
+STR_012E_CANCEL                                                 :{BLACK}Cancel
+STR_012F_OK                                                     :{BLACK}OK
+STR_0130_RENAME                                                 :{BLACK}Rename
+STR_0131_TOO_MANY_NAMES_DEFINED                                 :{WHITE}Too many names defined
+STR_0132_CHOSEN_NAME_IN_USE_ALREADY                             :{WHITE}Chosen name already in use
+
+STR_0133_WINDOWS                                                :Windows
+STR_0134_UNIX                                                   :Unix
+STR_0135_OSX                                                    :OS X
+STR_OSNAME_BEOS                                                 :BeOS
+STR_OSNAME_MORPHOS                                              :MorphOS
+STR_OSNAME_AMIGAOS                                              :AmigaOS
+STR_OSNAME_OS2                                                  :OS/2
+STR_OSNAME_SUNOS                                                :SunOS
+
+STR_013B_OWNED_BY                                               :{WHITE}...owned by {STRING}
+STR_013C_CARGO                                                  :{BLACK}Cargo
+STR_013D_INFORMATION                                            :{BLACK}Information
+STR_013E_CAPACITIES                                             :{BLACK}Capacities
+STR_013E_TOTAL_CARGO                                            :{BLACK}Total Cargo
+STR_013F_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}
+STR_CAPACITY_MULT                                               :{BLACK}Capacity: {LTBLUE}{CARGO} (x{NUM})
+STR_013F_TOTAL_CAPACITY_TEXT                                    :{BLACK}Total cargo (capacity) of this train:
+STR_013F_TOTAL_CAPACITY                                         :{LTBLUE}- {CARGO} ({SHORTCARGO})
+STR_TOTAL_CAPACITY_MULT                                         :{LTBLUE}- {CARGO} ({SHORTCARGO}) (x{NUM})
+STR_0140_NEW_GAME                                               :{BLACK}New Game
+STR_0141_LOAD_GAME                                              :{BLACK}Load Game
+STR_SINGLE_PLAYER                                               :{BLACK}Single player
+STR_MULTIPLAYER                                                 :{BLACK}Multiplayer
+STR_SCENARIO_EDITOR                                             :{BLACK}Scenario Editor
+
+STR_64                                                          :64
+STR_128                                                         :128
+STR_256                                                         :256
+STR_512                                                         :512
+STR_1024                                                        :1024
+STR_2048                                                        :2048
+STR_MAPSIZE                                                     :{BLACK}Map size:
+STR_BY                                                          :{BLACK}*
+STR_0148_GAME_OPTIONS                                           :{BLACK}Game Options
+
+STR_0150_SOMEONE                                                :someone{SKIP}{SKIP}
+STR_0151_MAP_OF_WORLD                                           :Map of world
+STR_0152_TOWN_DIRECTORY                                         :Town directory
+STR_0153_SUBSIDIES                                              :Subsidies
+
+STR_UNITS_IMPERIAL                                              :Imperial
+STR_UNITS_METRIC                                                :Metric
+STR_UNITS_SI                                                    :SI
+
+STR_UNITS_VELOCITY_IMPERIAL                                     :{COMMA} mph
+STR_UNITS_VELOCITY_METRIC                                       :{COMMA} km/h
+STR_UNITS_VELOCITY_SI                                           :{COMMA} m/s
+
+STR_UNITS_POWER_IMPERIAL                                        :{COMMA}hp
+STR_UNITS_POWER_METRIC                                          :{COMMA}hp
+STR_UNITS_POWER_SI                                              :{COMMA}kW
+
+STR_UNITS_WEIGHT_SHORT_IMPERIAL                                 :{COMMA}t
+STR_UNITS_WEIGHT_SHORT_METRIC                                   :{COMMA}t
+STR_UNITS_WEIGHT_SHORT_SI                                       :{COMMA}kg
+
+STR_UNITS_WEIGHT_LONG_IMPERIAL                                  :{COMMA} ton{P "" s}
+STR_UNITS_WEIGHT_LONG_METRIC                                    :{COMMA} tonne{P "" s}
+STR_UNITS_WEIGHT_LONG_SI                                        :{COMMA} kg
+
+STR_UNITS_VOLUME_SHORT_IMPERIAL                                 :{COMMA}gal
+STR_UNITS_VOLUME_SHORT_METRIC                                   :{COMMA}l
+STR_UNITS_VOLUME_SHORT_SI                                       :{COMMA}m³
+
+STR_UNITS_VOLUME_LONG_IMPERIAL                                  :{COMMA} gallon{P "" s}
+STR_UNITS_VOLUME_LONG_METRIC                                    :{COMMA} litre{P "" s}
+STR_UNITS_VOLUME_LONG_SI                                        :{COMMA} m³
+
+STR_UNITS_FORCE_IMPERIAL                                        :{COMMA}x10³lbf
+STR_UNITS_FORCE_METRIC                                          :{COMMA} tonne force
+STR_UNITS_FORCE_SI                                              :{COMMA} kN
+
+############ range for menu starts
+STR_0154_OPERATING_PROFIT_GRAPH                                 :Operating profit graph
+STR_0155_INCOME_GRAPH                                           :Income graph
+STR_0156_DELIVERED_CARGO_GRAPH                                  :Delivered cargo graph
+STR_0157_PERFORMANCE_HISTORY_GRAPH                              :Performance history graph
+STR_0158_COMPANY_VALUE_GRAPH                                    :Company value graph
+STR_0159_CARGO_PAYMENT_RATES                                    :Cargo payment rates
+STR_015A_COMPANY_LEAGUE_TABLE                                   :Company league table
+STR_PERFORMANCE_DETAIL_MENU                                     :Detailed performance rating
+############ range for menu ends
+
+STR_015B_OPENTTD                                                :{WHITE}OpenTTD
+STR_015C_SAVE_GAME                                              :Save game
+STR_015D_LOAD_GAME                                              :Load game
+STR_015E_QUIT_GAME                                              :Quit game
+STR_015F_QUIT                                                   :Quit
+STR_ABANDON_GAME_QUERY                                          :{YELLOW}Are you sure you want to quit this game ?
+STR_0161_QUIT_GAME                                              :{WHITE}Quit Game
+STR_SORT_ORDER_TIP                                              :{BLACK}Select sorting order (descending/ascending)
+STR_SORT_CRITERIA_TIP                                           :{BLACK}Select sorting criteria
+STR_SORT_BY                                                     :{BLACK}Sort by
+
+STR_SORT_BY_POPULATION                                          :{BLACK}Population
+STR_SORT_BY_PRODUCTION                                          :{BLACK}Production
+STR_SORT_BY_TYPE                                                :{BLACK}Type
+STR_SORT_BY_TRANSPORTED                                         :{BLACK}Transported
+STR_SORT_BY_NAME                                                :{BLACK}Name
+STR_SORT_BY_DROPDOWN_NAME                                       :Name
+STR_SORT_BY_DATE                                                :{BLACK}Date
+STR_SORT_BY_NUMBER                                              :Number
+STR_SORT_BY_PROFIT_LAST_YEAR                                    :Profit last year
+STR_SORT_BY_PROFIT_THIS_YEAR                                    :Profit this year
+STR_SORT_BY_AGE                                                 :Age
+STR_SORT_BY_RELIABILITY                                         :Reliability
+STR_SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE                        :Total capacity per cargo type
+STR_SORT_BY_MAX_SPEED                                           :Maximum speed
+STR_SORT_BY_MODEL                                               :Model
+STR_SORT_BY_VALUE                                               :Value
+STR_SORT_BY_FACILITY                                            :Station type
+STR_SORT_BY_WAITING                                             :Waiting cargo value
+STR_SORT_BY_RATING_MAX                                          :Cargo rating
+STR_ENGINE_SORT_ENGINE_ID                                       :EngineID (classic sort)
+STR_ENGINE_SORT_COST                                            :Cost
+STR_ENGINE_SORT_POWER                                           :Power
+STR_ENGINE_SORT_INTRO_DATE                                      :Introduction Date
+STR_ENGINE_SORT_RUNNING_COST                                    :Running Cost
+STR_ENGINE_SORT_POWER_VS_RUNNING_COST                           :Power/Running Cost
+STR_ENGINE_SORT_CARGO_CAPACITY                                  :Cargo Capacity
+STR_NO_WAITING_CARGO                                            :{BLACK}No cargo of any type is waiting
+STR_SELECT_ALL_FACILITIES                                       :{BLACK}Select all facilities
+STR_SELECT_ALL_TYPES                                            :{BLACK}Select all cargo types (including no waiting cargo)
+STR_AVAILABLE_TRAINS                                            :{BLACK}Available Trains
+STR_AVAILABLE_ROAD_VEHICLES                                     :{BLACK}Available Road Vehicles
+STR_AVAILABLE_SHIPS                                             :{BLACK}Available Ships
+STR_AVAILABLE_AIRCRAFT                                          :{BLACK}Available Aircraft
+STR_AVAILABLE_ENGINES_TIP                                       :{BLACK}See a list of available engine designs for this vehicle type.
+STR_MANAGE_LIST                                                 :{BLACK}Manage list
+STR_MANAGE_LIST_TIP                                             :{BLACK}Send instructions to all vehicles in this list
+STR_REPLACE_VEHICLES                                            :Replace vehicles
+STR_SEND_TRAIN_TO_DEPOT                                         :Send to Depot
+STR_SEND_ROAD_VEHICLE_TO_DEPOT                                  :Send to Depot
+STR_SEND_SHIP_TO_DEPOT                                          :Send to Depot
+STR_SEND_AIRCRAFT_TO_HANGAR                                     :Send to Hangar
+STR_SEND_FOR_SERVICING                                          :Send for Servicing
+
+############ range for months starts
+STR_0162_JAN                                                    :Jan
+STR_0163_FEB                                                    :Feb
+STR_0164_MAR                                                    :Mar
+STR_0165_APR                                                    :Apr
+STR_0166_MAY                                                    :May
+STR_0167_JUN                                                    :Jun
+STR_0168_JUL                                                    :Jul
+STR_0169_AUG                                                    :Aug
+STR_016A_SEP                                                    :Sep
+STR_016B_OCT                                                    :Oct
+STR_016C_NOV                                                    :Nov
+STR_016D_DEC                                                    :Dec
+############ range for months ends
+
+STR_016E                                                        :{TINYFONT}{STRING}{} {STRING}
+STR_016F                                                        :{TINYFONT}{STRING}{} {STRING}{}{NUM}
+STR_0170                                                        :{TINYFONT}{STRING}-
+STR_0171_PAUSE_GAME                                             :{BLACK}Pause game
+STR_0172_SAVE_GAME_ABANDON_GAME                                 :{BLACK}Save game, quit game, quit
+STR_0173_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's stations
+STR_0174_DISPLAY_MAP                                            :{BLACK}Display map
+STR_0175_DISPLAY_MAP_TOWN_DIRECTORY                             :{BLACK}Display map, town directory
+STR_0176_DISPLAY_TOWN_DIRECTORY                                 :{BLACK}Display town directory
+STR_0177_DISPLAY_COMPANY_FINANCES                               :{BLACK}Display company finances information
+STR_0178_DISPLAY_COMPANY_GENERAL                                :{BLACK}Display general company information
+STR_0179_DISPLAY_GRAPHS                                         :{BLACK}Display graphs
+STR_017A_DISPLAY_COMPANY_LEAGUE                                 :{BLACK}Display company league table
+STR_017B_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's trains
+STR_017C_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's road vehicles
+STR_017D_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's ships
+STR_017E_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Display list of company's aircraft
+STR_017F_ZOOM_THE_VIEW_IN                                       :{BLACK}Zoom the view in
+STR_0180_ZOOM_THE_VIEW_OUT                                      :{BLACK}Zoom the view out
+STR_0181_BUILD_RAILROAD_TRACK                                   :{BLACK}Build railroad track
+STR_0182_BUILD_ROADS                                            :{BLACK}Build roads
+STR_0183_BUILD_SHIP_DOCKS                                       :{BLACK}Build ship docks
+STR_0184_BUILD_AIRPORTS                                         :{BLACK}Build airports
+STR_0185_PLANT_TREES_PLACE_SIGNS                                :{BLACK}Plant trees, place signs etc.
+STR_0186_LAND_BLOCK_INFORMATION                                 :{BLACK}Land area information
+STR_0187_OPTIONS                                                :{BLACK}Options
+STR_0188                                                        :{BLACK}{SMALLUPARROW}
+STR_0189                                                        :{BLACK}{SMALLDOWNARROW}
+STR_018A_CAN_T_CHANGE_SERVICING                                 :{WHITE}Can't change servicing interval...
+STR_018B_CLOSE_WINDOW                                           :{BLACK}Close window
+STR_018C_WINDOW_TITLE_DRAG_THIS                                 :{BLACK}Window title - drag this to move window
+STR_STICKY_BUTTON                                               :{BLACK}Mark this window as uncloseable for the 'Close All Windows' key
+STR_RESIZE_BUTTON                                               :{BLACK}Click and drag to resize this window
+STR_SAVELOAD_HOME_BUTTON                                        :{BLACK}Click here to jump to the current default save/load directory
+STR_018D_DEMOLISH_BUILDINGS_ETC                                 :{BLACK}Demolish buildings etc. on a square of land
+STR_018E_LOWER_A_CORNER_OF_LAND                                 :{BLACK}Lower a corner of land
+STR_018F_RAISE_A_CORNER_OF_LAND                                 :{BLACK}Raise a corner of land
+STR_0190_SCROLL_BAR_SCROLLS_LIST                                :{BLACK}Scroll bar - scrolls list up/down
+STR_HSCROLL_BAR_SCROLLS_LIST                                    :{BLACK}Scroll bar - scrolls list left/right
+STR_0191_SHOW_LAND_CONTOURS_ON_MAP                              :{BLACK}Show land contours on map
+STR_0192_SHOW_VEHICLES_ON_MAP                                   :{BLACK}Show vehicles on map
+STR_0193_SHOW_INDUSTRIES_ON_MAP                                 :{BLACK}Show industries on map
+STR_0194_SHOW_TRANSPORT_ROUTES_ON                               :{BLACK}Show transport routes on map
+STR_0195_SHOW_VEGETATION_ON_MAP                                 :{BLACK}Show vegetation on map
+STR_0196_SHOW_LAND_OWNERS_ON_MAP                                :{BLACK}Show land owners on map
+STR_0197_TOGGLE_TOWN_NAMES_ON_OFF                               :{BLACK}Toggle town names on/off on map
+STR_0198_PROFIT_THIS_YEAR_LAST_YEAR                             :{TINYFONT}{BLACK}Profit this year: {CURRENCY} (last year: {CURRENCY})
+
+############ range for service numbers starts
+STR_AGE                                                         :{COMMA} year{P "" s} ({COMMA})
+STR_AGE_RED                                                     :{RED}{COMMA} year{P "" s} ({COMMA})
+############ range for service numbers ends
+
+STR_019C_ROAD_VEHICLE                                           :Road vehicle
+STR_019D_AIRCRAFT                                               :Aircraft
+STR_019E_SHIP                                                   :Ship
+STR_019F_TRAIN                                                  :Train
+STR_01A0_IS_GETTING_OLD                                         :{WHITE}{STRING} {COMMA} is getting old
+STR_01A1_IS_GETTING_VERY_OLD                                    :{WHITE}{STRING} {COMMA} is getting very old
+STR_01A2_IS_GETTING_VERY_OLD_AND                                :{WHITE}{STRING} {COMMA} is getting very old and urgently needs replacing
+STR_01A3_LAND_AREA_INFORMATION                                  :{WHITE}Land Area Information
+STR_01A4_COST_TO_CLEAR_N_A                                      :{BLACK}Cost to clear: {LTBLUE}N/A
+STR_01A5_COST_TO_CLEAR                                          :{BLACK}Cost to clear: {LTBLUE}{CURRENCY}
+STR_01A6_N_A                                                    :N/A
+STR_01A7_OWNER                                                  :{BLACK}Owner: {LTBLUE}{STRING}
+STR_01A8_LOCAL_AUTHORITY                                        :{BLACK}Local authority: {LTBLUE}{STRING}
+STR_01A9_NONE                                                   :None
+STR_01AA_NAME                                                   :{BLACK}Name
+STR_01AB                                                        :{BLACK}{TINYFONT}{VEHICLE}
+
+############ range for days starts
+STR_01AC_1ST                                                    :1st
+STR_01AD_2ND                                                    :2nd
+STR_01AE_3RD                                                    :3rd
+STR_01AF_4TH                                                    :4th
+STR_01B0_5TH                                                    :5th
+STR_01B1_6TH                                                    :6th
+STR_01B2_7TH                                                    :7th
+STR_01B3_8TH                                                    :8th
+STR_01B4_9TH                                                    :9th
+STR_01B5_10TH                                                   :10th
+STR_01B6_11TH                                                   :11th
+STR_01B7_12TH                                                   :12th
+STR_01B8_13TH                                                   :13th
+STR_01B9_14TH                                                   :14th
+STR_01BA_15TH                                                   :15th
+STR_01BB_16TH                                                   :16th
+STR_01BC_17TH                                                   :17th
+STR_01BD_18TH                                                   :18th
+STR_01BE_19TH                                                   :19th
+STR_01BF_20TH                                                   :20th
+STR_01C0_21ST                                                   :21st
+STR_01C1_22ND                                                   :22nd
+STR_01C2_23RD                                                   :23rd
+STR_01C3_24TH                                                   :24th
+STR_01C4_25TH                                                   :25th
+STR_01C5_26TH                                                   :26th
+STR_01C6_27TH                                                   :27th
+STR_01C7_28TH                                                   :28th
+STR_01C8_29TH                                                   :29th
+STR_01C9_30TH                                                   :30th
+STR_01CA_31ST                                                   :31st
+############ range for days ends
+
+STR_01CB                                                        :{TINYFONT}{COMMA}
+
+STR_01CE_CARGO_ACCEPTED                                         :{BLACK}Cargo accepted: {LTBLUE}
+
+STR_01D1_8                                                      :({COMMA}/8 {STRING})
+STR_01D2_JAZZ_JUKEBOX                                           :{WHITE}Jazz Jukebox
+STR_01D3_SOUND_MUSIC                                            :Sound/music
+STR_01D4_SHOW_SOUND_MUSIC_WINDOW                                :{BLACK}Show sound/music window
+STR_01D5_ALL                                                    :{TINYFONT}All
+STR_01D6_OLD_STYLE                                              :{TINYFONT}Old Style
+STR_01D7_NEW_STYLE                                              :{TINYFONT}New Style
+STR_01D8_EZY_STREET                                             :{TINYFONT}Ezy Street
+STR_01D9_CUSTOM_1                                               :{TINYFONT}Custom 1
+STR_01DA_CUSTOM_2                                               :{TINYFONT}Custom 2
+STR_01DB_MUSIC_VOLUME                                           :{BLACK}{TINYFONT}Music Volume
+STR_01DC_EFFECTS_VOLUME                                         :{BLACK}{TINYFONT}Effects Volume
+STR_01DD_MIN_MAX                                                :{BLACK}{TINYFONT}MIN  '  '  ' '  '  '  MAX
+STR_01DE_SKIP_TO_PREVIOUS_TRACK                                 :{BLACK}Skip to previous track in selection
+STR_01DF_SKIP_TO_NEXT_TRACK_IN_SELECTION                        :{BLACK}Skip to next track in selection
+STR_01E0_STOP_PLAYING_MUSIC                                     :{BLACK}Stop playing music
+STR_01E1_START_PLAYING_MUSIC                                    :{BLACK}Start playing music
+STR_01E2_DRAG_SLIDERS_TO_SET_MUSIC                              :{BLACK}Drag sliders to set music and sound effect volumes
+STR_01E3                                                        :{DKGREEN}{TINYFONT}--
+STR_01E4_0                                                      :{DKGREEN}{TINYFONT}0{COMMA}
+STR_01E5                                                        :{DKGREEN}{TINYFONT}{COMMA}
+STR_01E6                                                        :{DKGREEN}{TINYFONT}------
+STR_01E7                                                        :{DKGREEN}{TINYFONT}"{STRING}"
+STR_01E8_TRACK_XTITLE                                           :{BLACK}{TINYFONT}Track{SETX 88}Title
+STR_01E9_SHUFFLE                                                :{TINYFONT}Shuffle
+STR_01EA_PROGRAM                                                :{TINYFONT}{BLACK}Program
+STR_01EB_MUSIC_PROGRAM_SELECTION                                :{WHITE}Music Program Selection
+STR_01EC_0                                                      :{TINYFONT}{LTBLUE}0{COMMA} "{STRING}"
+STR_01ED                                                        :{TINYFONT}{LTBLUE}{COMMA} "{STRING}"
+STR_01EE_TRACK_INDEX                                            :{TINYFONT}{BLACK}Track Index
+STR_01EF_PROGRAM                                                :{TINYFONT}{BLACK}Program - '{STRING}'
+STR_01F0_CLEAR                                                  :{TINYFONT}{BLACK}Clear
+STR_01F1_SAVE                                                   :{TINYFONT}{BLACK}Save
+STR_01F2_CURRENT_PROGRAM_OF_MUSIC                               :{BLACK}Current program of music tracks
+STR_01F3_SELECT_ALL_TRACKS_PROGRAM                              :{BLACK}Select 'all tracks' program
+STR_01F4_SELECT_OLD_STYLE_MUSIC                                 :{BLACK}Select 'old style music' program
+STR_01F5_SELECT_NEW_STYLE_MUSIC                                 :{BLACK}Select 'new style music' program
+STR_01F6_SELECT_CUSTOM_1_USER_DEFINED                           :{BLACK}Select 'Custom 1' (user-defined) program
+STR_01F7_SELECT_CUSTOM_2_USER_DEFINED                           :{BLACK}Select 'Custom 2' (user-defined) program
+STR_01F8_CLEAR_CURRENT_PROGRAM_CUSTOM1                          :{BLACK}Clear current program (Custom1 or Custom2 only)
+STR_01F9_SAVE_MUSIC_SETTINGS                                    :{BLACK}Save music settings
+STR_01FA_CLICK_ON_MUSIC_TRACK_TO                                :{BLACK}Click on music track to add to current program (Custom1 or Custom2 only)
+STR_CLICK_ON_TRACK_TO_REMOVE                                    :{BLACK}Click on music track to remove it from current program (Custom1 or Custom2 only)
+STR_01FB_TOGGLE_PROGRAM_SHUFFLE                                 :{BLACK}Toggle program shuffle on/off
+STR_01FC_SHOW_MUSIC_TRACK_SELECTION                             :{BLACK}Show music track selection window
+STR_01FD_CLICK_ON_SERVICE_TO_CENTER                             :{BLACK}Click on service to center view on industry/town
+STR_01FE_DIFFICULTY                                             :{BLACK}Difficulty ({STRING})
+STR_01FF                                                        :{TINYFONT}{BLACK}{DATE_LONG}
+STR_0200_LAST_MESSAGE_NEWS_REPORT                               :Last message/news report
+STR_0201_MESSAGE_SETTINGS                                       :Message settings
+STR_MESSAGE_HISTORY_MENU                                        :Message History
+STR_0203_SHOW_LAST_MESSAGE_NEWS                                 :{BLACK}Show last message/news report, show message options
+STR_0204_MESSAGE_OPTIONS                                        :{WHITE}Message Options
+STR_0205_MESSAGE_TYPES                                          :{BLACK}Message types:
+STR_0206_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Arrival of first vehicle at player's station
+STR_0207_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Arrival of first vehicle at competitor's station
+STR_0208_ACCIDENTS_DISASTERS                                    :{YELLOW}Accidents / disasters
+STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Company information
+STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Open / close of industries
+STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Economy changes
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Production changes of industries served by the player
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Production changes of industries served by competitor(s)
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Other industry production changes
+STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Advice / information on player's vehicles
+STR_020C_NEW_VEHICLES                                           :{YELLOW}New vehicles
+STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Changes of cargo acceptance
+STR_020E_SUBSIDIES                                              :{YELLOW}Subsidies
+STR_020F_GENERAL_INFORMATION                                    :{YELLOW}General information
+STR_MESSAGES_ALL                                                :{YELLOW}Setting for all messagetypes (off/summary/full)
+STR_MESSAGE_SOUND                                               :{YELLOW}Play sound for summarized newsmessages
+STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO                       :{WHITE}...too far from previous destination
+STR_0211_TOP_COMPANIES_WHO_REACHED                              :{BIGFONT}{BLACK}Top companies who reached {NUM}{}({STRING} Level)
+STR_TOP_COMPANIES_NETWORK_GAME                                  :{BIGFONT}{BLACK}Company League Table in {NUM}
+STR_0212                                                        :{BIGFONT}{COMMA}.
+STR_0213_BUSINESSMAN                                            :Businessman
+STR_0214_ENTREPRENEUR                                           :Entrepreneur
+STR_0215_INDUSTRIALIST                                          :Industrialist
+STR_0216_CAPITALIST                                             :Capitalist
+STR_0217_MAGNATE                                                :Magnate
+STR_0218_MOGUL                                                  :Mogul
+STR_0219_TYCOON_OF_THE_CENTURY                                  :Tycoon of the Century
+STR_HIGHSCORE_NAME                                              :{BIGFONT}{PLAYERNAME}, {COMPANY}
+STR_HIGHSCORE_STATS                                             :{BIGFONT}'{STRING}'   ({COMMA})
+STR_021B_ACHIEVES_STATUS                                        :{BLACK}{BIGFONT}{COMPANY} achieves '{STRING}' status!
+STR_021C_OF_ACHIEVES_STATUS                                     :{WHITE}{BIGFONT}{PLAYERNAME} of {COMPANY} achieves '{STRING}' status!
+STR_021F                                                        :{BLUE}{COMMA}
+STR_0221_OPENTTD                                                :{YELLOW}OpenTTD
+STR_0222_SCENARIO_EDITOR                                        :{YELLOW}Scenario Editor
+STR_0223_LAND_GENERATION                                        :{WHITE}Land Generation
+STR_0224                                                        :{BLACK}{UPARROW}
+STR_0225                                                        :{BLACK}{DOWNARROW}
+STR_0228_INCREASE_SIZE_OF_LAND_AREA                             :{BLACK}Increase area of land to lower/raise
+STR_0229_DECREASE_SIZE_OF_LAND_AREA                             :{BLACK}Decrease area of land to lower/raise
+STR_022A_GENERATE_RANDOM_LAND                                   :{BLACK}Generate random land
+STR_022B_RESET_LANDSCAPE                                        :{BLACK}Reset landscape
+STR_022C_RESET_LANDSCAPE                                        :{WHITE}Reset Landscape
+STR_RESET_LANDSCAPE_TOOLTIP                                     :{BLACK}Remove all player-owned property from the map
+STR_RESET_LANDSCAPE_CONFIRMATION_TEXT                           :{WHITE}Are you sure you want to remove all player-owned property?
+STR_022E_LANDSCAPE_GENERATION                                   :{BLACK}Landscape generation
+STR_022F_TOWN_GENERATION                                        :{BLACK}Town generation
+STR_0230_INDUSTRY_GENERATION                                    :{BLACK}Industry generation
+STR_0231_ROAD_CONSTRUCTION                                      :{BLACK}Road construction
+STR_0233_TOWN_GENERATION                                        :{WHITE}Town Generation
+STR_0234_NEW_TOWN                                               :{BLACK}New Town
+STR_0235_CONSTRUCT_NEW_TOWN                                     :{BLACK}Construct new town
+STR_0236_CAN_T_BUILD_TOWN_HERE                                  :{WHITE}Can't build town here...
+STR_0237_TOO_CLOSE_TO_EDGE_OF_MAP                               :{WHITE}...too close to edge of map
+STR_0238_TOO_CLOSE_TO_ANOTHER_TOWN                              :{WHITE}...too close to another town
+STR_0239_SITE_UNSUITABLE                                        :{WHITE}...site unsuitable
+STR_023A_TOO_MANY_TOWNS                                         :{WHITE}...too many towns
+STR_CANNOT_GENERATE_TOWN                                        :{WHITE}Can't build any towns
+STR_NO_SPACE_FOR_TOWN                                           :{WHITE}...there is no more space on the map
+STR_023B_INCREASE_SIZE_OF_TOWN                                  :{BLACK}Increase size of town
+STR_023C_EXPAND                                                 :{BLACK}Expand
+STR_023D_RANDOM_TOWN                                            :{BLACK}Random Town
+STR_023E_BUILD_TOWN_IN_RANDOM_LOCATION                          :{BLACK}Build town in random location
+STR_023F_INDUSTRY_GENERATION                                    :{WHITE}Industry Generation
+STR_0240_COAL_MINE                                              :{BLACK}Coal Mine
+STR_0241_POWER_STATION                                          :{BLACK}Power Station
+STR_0242_SAWMILL                                                :{BLACK}Sawmill
+STR_0243_FOREST                                                 :{BLACK}Forest
+STR_0244_OIL_REFINERY                                           :{BLACK}Oil Refinery
+STR_0245_OIL_RIG                                                :{BLACK}Oil Rig
+STR_0246_FACTORY                                                :{BLACK}Factory
+STR_0247_STEEL_MILL                                             :{BLACK}Steel Mill
+STR_0248_FARM                                                   :{BLACK}Farm
+STR_0249_IRON_ORE_MINE                                          :{BLACK}Iron Ore Mine
+STR_024A_OIL_WELLS                                              :{BLACK}Oil Wells
+STR_024B_BANK                                                   :{BLACK}Bank
+STR_024C_PAPER_MILL                                             :{BLACK}Paper Mill
+STR_024D_FOOD_PROCESSING_PLANT                                  :{BLACK}Food Processing Plant
+STR_024E_PRINTING_WORKS                                         :{BLACK}Printing Works
+STR_024F_GOLD_MINE                                              :{BLACK}Gold Mine
+STR_0250_LUMBER_MILL                                            :{BLACK}Lumber Mill
+STR_0251_FRUIT_PLANTATION                                       :{BLACK}Fruit Plantation
+STR_0252_RUBBER_PLANTATION                                      :{BLACK}Rubber Plantation
+STR_0253_WATER_SUPPLY                                           :{BLACK}Water Supply
+STR_0254_WATER_TOWER                                            :{BLACK}Water Tower
+STR_0255_DIAMOND_MINE                                           :{BLACK}Diamond Mine
+STR_0256_COPPER_ORE_MINE                                        :{BLACK}Copper Ore Mine
+STR_0257_COTTON_CANDY_FOREST                                    :{BLACK}Cotton Candy Forest
+STR_0258_CANDY_FACTORY                                          :{BLACK}Candy Factory
+STR_0259_BATTERY_FARM                                           :{BLACK}Battery Farm
+STR_025A_COLA_WELLS                                             :{BLACK}Cola Wells
+STR_025B_TOY_SHOP                                               :{BLACK}Toy Shop
+STR_025C_TOY_FACTORY                                            :{BLACK}Toy Factory
+STR_025D_PLASTIC_FOUNTAINS                                      :{BLACK}Plastic Fountains
+STR_025E_FIZZY_DRINK_FACTORY                                    :{BLACK}Fizzy Drink Factory
+STR_025F_BUBBLE_GENERATOR                                       :{BLACK}Bubble Generator
+STR_0260_TOFFEE_QUARRY                                          :{BLACK}Toffee Quarry
+STR_0261_SUGAR_MINE                                             :{BLACK}Sugar Mine
+STR_0262_CONSTRUCT_COAL_MINE                                    :{BLACK}Construct Coal Mine
+STR_0263_CONSTRUCT_POWER_STATION                                :{BLACK}Construct Power Station
+STR_0264_CONSTRUCT_SAWMILL                                      :{BLACK}Construct Sawmill
+STR_0265_PLANT_FOREST                                           :{BLACK}Plant Forest
+STR_0266_CONSTRUCT_OIL_REFINERY                                 :{BLACK}Construct Oil Refinery
+STR_0267_CONSTRUCT_OIL_RIG_CAN_ONLY                             :{BLACK}Construct Oil Rig (Can only be built near the edges of the map)
+STR_0268_CONSTRUCT_FACTORY                                      :{BLACK}Construct Factory
+STR_0269_CONSTRUCT_STEEL_MILL                                   :{BLACK}Construct Steel Mill
+STR_026A_CONSTRUCT_FARM                                         :{BLACK}Construct Farm
+STR_026B_CONSTRUCT_IRON_ORE_MINE                                :{BLACK}Construct Iron Ore Mine
+STR_026C_CONSTRUCT_OIL_WELLS                                    :{BLACK}Construct Oil Wells
+STR_026D_CONSTRUCT_BANK_CAN_ONLY                                :{BLACK}Construct Bank (Can only be built in towns with a population greater than 1200)
+STR_026E_CONSTRUCT_PAPER_MILL                                   :{BLACK}Construct Paper Mill
+STR_026F_CONSTRUCT_FOOD_PROCESSING                              :{BLACK}Construct Food Processing Plant
+STR_0270_CONSTRUCT_PRINTING_WORKS                               :{BLACK}Construct Printing Works
+STR_0271_CONSTRUCT_GOLD_MINE                                    :{BLACK}Construct Gold Mine
+STR_0272_CONSTRUCT_BANK_CAN_ONLY                                :{BLACK}Construct Bank (Can only be built in towns)
+STR_0273_CONSTRUCT_LUMBER_MILL_TO                               :{BLACK}Construct Lumber Mill (to clear rainforest and produce Wood)
+STR_0274_PLANT_FRUIT_PLANTATION                                 :{BLACK}Plant Fruit Plantation
+STR_0275_PLANT_RUBBER_PLANTATION                                :{BLACK}Plant Rubber Plantation
+STR_0276_CONSTRUCT_WATER_SUPPLY                                 :{BLACK}Construct Water Supply
+STR_0277_CONSTRUCT_WATER_TOWER_CAN                              :{BLACK}Construct Water Tower (Can only be built in towns)
+STR_0278_CONSTRUCT_DIAMOND_MINE                                 :{BLACK}Construct Diamond Mine
+STR_0279_CONSTRUCT_COPPER_ORE_MINE                              :{BLACK}Construct Copper Ore Mine
+STR_027A_PLANT_COTTON_CANDY_FOREST                              :{BLACK}Plant Cotton Candy Forest
+STR_027B_CONSTRUCT_CANDY_FACTORY                                :{BLACK}Construct Candy Factory
+STR_027C_CONSTRUCT_BATTERY_FARM                                 :{BLACK}Construct Battery Farm
+STR_027D_CONSTRUCT_COLA_WELLS                                   :{BLACK}Construct Cola Wells
+STR_027E_CONSTRUCT_TOY_SHOP                                     :{BLACK}Construct Toy Shop
+STR_027F_CONSTRUCT_TOY_FACTORY                                  :{BLACK}Construct Toy Factory
+STR_0280_CONSTRUCT_PLASTIC_FOUNTAINS                            :{BLACK}Construct Plastic Fountains
+STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY                          :{BLACK}Construct Fizzy Drink Factory
+STR_0282_CONSTRUCT_BUBBLE_GENERATOR                             :{BLACK}Construct Bubble Generator
+STR_0283_CONSTRUCT_TOFFEE_QUARRY                                :{BLACK}Construct Toffee Quarry
+STR_0284_CONSTRUCT_SUGAR_MINE                                   :{BLACK}Construct Sugar Mine
+STR_0285_CAN_T_BUILD_HERE                                       :{WHITE}Can't build {STRING} here...
+STR_0286_MUST_BUILD_TOWN_FIRST                                  :{WHITE}...must build town first
+STR_0287_ONLY_ONE_ALLOWED_PER_TOWN                              :{WHITE}...only one allowed per town
+STR_0288_PLANT_TREES                                            :{BLACK}Plant trees
+STR_0289_PLACE_SIGN                                             :{BLACK}Place sign
+STR_028A_RANDOM_TREES                                           :{BLACK}Random Trees
+STR_028B_PLANT_TREES_RANDOMLY_OVER                              :{BLACK}Plant trees randomly over landscape
+STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE                         :{BLACK}Place rocky areas on landscape
+STR_028D_PLACE_LIGHTHOUSE                                       :{BLACK}Place lighthouse
+STR_028E_PLACE_TRANSMITTER                                      :{BLACK}Place transmitter
+STR_028F_DEFINE_DESERT_AREA                                     :{BLACK}Define desert area.{}Press and hold CTRL to remove it
+STR_CREATE_LAKE                                                 :{BLACK}Define water area.{}Make a canal, unless CTRL is held down at sea level, when it will flood the surroundings instead
+STR_0290_DELETE                                                 :{BLACK}Delete
+STR_0291_DELETE_THIS_TOWN_COMPLETELY                            :{BLACK}Delete this town completely
+STR_0292_SAVE_SCENARIO                                          :Save scenario
+STR_0293_LOAD_SCENARIO                                          :Load scenario
+STR_LOAD_HEIGHTMAP                                              :Load heightmap
+STR_0294_QUIT_EDITOR                                            :Quit editor
+STR_0295                                                        :
+STR_0296_QUIT                                                   :Quit
+STR_0297_SAVE_SCENARIO_LOAD_SCENARIO                            :{BLACK}Save scenario, load scenario, abandon scenario editor, quit
+STR_0298_LOAD_SCENARIO                                          :{WHITE}Load Scenario
+STR_0299_SAVE_SCENARIO                                          :{WHITE}Save Scenario
+STR_029A_PLAY_SCENARIO                                          :{BLACK}Play Scenario
+STR_PLAY_HEIGHTMAP                                              :{BLACK}Play Heightmap
+STR_PLAY_HEIGHTMAP_HINT                                         :{BLACK}Start a new game, using a heightmap as landscape
+STR_QUIT_SCENARIO_QUERY                                         :{YELLOW}Are you sure you want to quit this scenario ?
+STR_029C_QUIT_EDITOR                                            :{WHITE}Quit Editor
+STR_029D_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...can only be built in towns with a population of at least 1200
+STR_029E_MOVE_THE_STARTING_DATE                                 :{BLACK}Move the starting date backward 1 year
+STR_029F_MOVE_THE_STARTING_DATE                                 :{BLACK}Move the starting date forward 1 year
+STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH                               :{WHITE}...ends of bridge must both be on land
+STR_02A1_SMALL                                                  :{BLACK}Small
+STR_02A2_MEDIUM                                                 :{BLACK}Medium
+STR_02A3_LARGE                                                  :{BLACK}Large
+STR_SCENARIO_EDITOR_CITY                                        :{BLACK}City
+STR_02A4_SELECT_TOWN_SIZE                                       :{BLACK}Select town size
+STR_02A5_TOWN_SIZE                                              :{YELLOW}Town size:
+
+STR_02B6                                                        :{STRING}  -  {STRING}
+STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS                              :{BLACK}Show last message or news report
+STR_OFF                                                         :Off
+STR_SUMMARY                                                     :Summary
+STR_FULL                                                        :Full
+STR_02BA                                                        :{SILVER}- -  {COMPANY}  - -
+STR_02BB_TOWN_DIRECTORY                                         :Town directory
+STR_02BC_VEHICLE_DESIGN_NAMES                                   :{BLACK}Vehicle design names
+STR_02BD                                                        :{BLACK}{STRING}
+STR_02BE_DEFAULT                                                :Default
+STR_02BF_CUSTOM                                                 :Custom
+STR_02C0_SAVE_CUSTOM_NAMES                                      :{BLACK}Save custom names
+STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION                         :{BLACK}Vehicle design names selection
+STR_02C2_SAVE_CUSTOMIZED_VEHICLE                                :{BLACK}Save customized vehicle design names
+
+STR_CHECKMARK                                                   :{CHECKMARK}
+############ range for menu starts
+STR_02C3_GAME_OPTIONS                                           :Game options
+STR_02C5_DIFFICULTY_SETTINGS                                    :Difficulty settings
+STR_02C7_CONFIG_PATCHES                                         :Configure patches
+STR_NEWGRF_SETTINGS                                             :Newgrf settings
+STR_TRANSPARENCY_OPTIONS                                        :Transparency options
+STR_GAMEOPTMENU_0A                                              :
+STR_02CA_TOWN_NAMES_DISPLAYED                                   :{SETX 12}Town names displayed
+STR_02CC_STATION_NAMES_DISPLAYED                                :{SETX 12}Station names displayed
+STR_02CE_SIGNS_DISPLAYED                                        :{SETX 12}Signs displayed
+STR_WAYPOINTS_DISPLAYED2                                        :{SETX 12}Waypoints displayed
+STR_02D0_FULL_ANIMATION                                         :{SETX 12}Full animation
+STR_02D2_FULL_DETAIL                                            :{SETX 12}Full detail
+STR_02D4_TRANSPARENT_BUILDINGS                                  :{SETX 12}Transparent buildings
+STR_TRANSPARENT_SIGNS                                           :{SETX 12}Transparent station signs
+############ range ends here
+
+############ range for menu starts
+STR_02D5_LAND_BLOCK_INFO                                        :Land area information
+STR_02D6                                                        :
+STR_CONSOLE_SETTING                                             :Toggle Console
+STR_02D7_SCREENSHOT_CTRL_S                                      :Screenshot (Ctrl-S)
+STR_02D8_GIANT_SCREENSHOT_CTRL_G                                :Giant Screenshot (Ctrl-G)
+STR_02D9_ABOUT_OPENTTD                                          :About 'OpenTTD'
+############ range ends here
+
+STR_02DB_OFF                                                    :{BLACK}Off
+STR_02DA_ON                                                     :{BLACK}On
+STR_02DC_DISPLAY_SUBSIDIES                                      :{BLACK}Display subsidies
+STR_02DD_SUBSIDIES                                              :Subsidies
+STR_02DE_MAP_OF_WORLD                                           :Map of world
+STR_EXTRA_VIEW_PORT                                             :Extra viewport
+STR_SIGN_LIST                                                   :Sign list
+STR_02DF_TOWN_DIRECTORY                                         :Town directory
+STR_TOWN_POPULATION                                             :{BLACK}World population: {COMMA}
+STR_EXTRA_VIEW_PORT_TITLE                                       :{WHITE}Viewport {COMMA}
+STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN                                :{BLACK}Copy to viewport
+STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN_TT                             :{BLACK}Copy the location of the global view to this viewport
+STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW                                :{BLACK}Paste from viewport
+STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT                             :{BLACK}Paste the location of this viewport to the global view
+
+STR_02E0_CURRENCY_UNITS                                         :{BLACK}Currency units
+STR_02E1                                                        :{BLACK}{SKIP}{STRING}
+STR_02E2_CURRENCY_UNITS_SELECTION                               :{BLACK}Currency units selection
+STR_MEASURING_UNITS                                             :{BLACK}Measuring units
+STR_02E4                                                        :{BLACK}{SKIP}{SKIP}{STRING}
+STR_MEASURING_UNITS_SELECTION                                   :{BLACK}Measuring units selection
+STR_02E6_ROAD_VEHICLES                                          :{BLACK}Road vehicles
+STR_02E7                                                        :{BLACK}{SKIP}{SKIP}{SKIP}{STRING}
+STR_02E8_SELECT_SIDE_OF_ROAD_FOR                                :{BLACK}Select side of road for vehicles to drive on
+STR_02E9_DRIVE_ON_LEFT                                          :Drive on left
+STR_02EA_DRIVE_ON_RIGHT                                         :Drive on right
+STR_02EB_TOWN_NAMES                                             :{BLACK}Town names
+STR_02EC                                                        :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
+STR_02ED_SELECT_STYLE_OF_TOWN_NAMES                             :{BLACK}Select style of town names
+
+STR_02F4_AUTOSAVE                                               :{BLACK}Autosave
+STR_02F5                                                        :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
+STR_02F6_SELECT_INTERVAL_BETWEEN                                :{BLACK}Select interval between automatic game saves
+STR_02F7_OFF                                                    :Off
+STR_02F8_EVERY_3_MONTHS                                         :Every 3 months
+STR_02F9_EVERY_6_MONTHS                                         :Every 6 months
+STR_02FA_EVERY_12_MONTHS                                        :Every 12 months
+STR_02FB_START_A_NEW_GAME                                       :{BLACK}Start a new game
+STR_02FC_LOAD_A_SAVED_GAME                                      :{BLACK}Load a saved game
+STR_02FE_CREATE_A_CUSTOMIZED_GAME                               :{BLACK}Create a customized game world/scenario
+STR_02FF_SELECT_SINGLE_PLAYER_GAME                              :{BLACK}Select single-player game
+STR_0300_SELECT_MULTIPLAYER_GAME                                :{BLACK}Select multiplayer game of 2-8 players
+STR_0301_DISPLAY_GAME_OPTIONS                                   :{BLACK}Display game options
+STR_0302_DISPLAY_DIFFICULTY_OPTIONS                             :{BLACK}Display difficulty options
+STR_0303_START_A_NEW_GAME_USING                                 :{BLACK}Start a new game, using a customized scenario
+STR_0304_QUIT                                                   :{BLACK}Quit
+STR_0305_QUIT_OPENTTD                                           :{BLACK}Quit 'OpenTTD'
+STR_0307_OPENTTD                                                :{WHITE}OpenTTD {REV}
+STR_030D_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...can only be built in towns
+STR_030E_SELECT_TEMPERATE_LANDSCAPE                             :{BLACK}Select 'temperate' landscape style
+STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE                            :{BLACK}Select 'sub-arctic' landscape style
+STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE                          :{BLACK}Select 'sub-tropical' landscape style
+STR_0311_SELECT_TOYLAND_LANDSCAPE                               :{BLACK}Select 'toyland' landscape style
+STR_0312_FUND_CONSTRUCTION_OF_NEW                               :{BLACK}Fund construction of new industry
+
+############ range for menu starts
+STR_INDUSTRY_DIR                                                :Industry Directory
+STR_0313_FUND_NEW_INDUSTRY                                      :Fund new industry
+############ range ends here
+
+STR_0314_FUND_NEW_INDUSTRY                                      :{WHITE}Fund new industry
+STR_JUST_STRING                                                 :{STRING}
+STR_JUST_INT                                                    :{NUM}
+STR_0316_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...can only be built in towns
+STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST                        :{WHITE}...can only be built in rainforest areas
+STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT                            :{WHITE}...can only be built in desert areas
+STR_0319_PAUSED                                                 :{YELLOW}* *  PAUSED  *  *
+
+STR_031B_SCREENSHOT_SUCCESSFULLY                                :{WHITE}Screenshot successfully saved as '{STRING}'
+STR_031C_SCREENSHOT_FAILED                                      :{WHITE}Screenshot failed!
+
+STR_0329_PURCHASE_LAND_FOR_FUTURE                               :{BLACK}Purchase land for future use
+STR_032F_AUTOSAVE                                               :{RED}AUTOSAVE
+STR_SAVING_GAME                                                 :{RED}*  *  SAVING GAME  *  *
+STR_SAVE_STILL_IN_PROGRESS                                      :{WHITE}Saving still in progress,{}please wait until it is finished!
+STR_0330_SELECT_EZY_STREET_STYLE                                :{BLACK}Select 'Ezy Street style music' program
+
+STR_0335_6                                                      :{BLACK}6
+STR_0336_7                                                      :{BLACK}7
+
+############ start of townname region
+STR_TOWNNAME_ORIGINAL_ENGLISH                                   :English (Original)
+STR_TOWNNAME_FRENCH                                             :French
+STR_TOWNNAME_GERMAN                                             :German
+STR_TOWNNAME_ADDITIONAL_ENGLISH                                 :English (Additional)
+STR_TOWNNAME_LATIN_AMERICAN                                     :Latin-American
+STR_TOWNNAME_SILLY                                              :Silly
+STR_TOWNNAME_SWEDISH                                            :Swedish
+STR_TOWNNAME_DUTCH                                              :Dutch
+STR_TOWNNAME_FINNISH                                            :Finnish
+STR_TOWNNAME_POLISH                                             :Polish
+STR_TOWNNAME_SLOVAKISH                                          :Slovakish
+STR_TOWNNAME_NORWEGIAN                                          :Norwegian
+STR_TOWNNAME_HUNGARIAN                                          :Hungarian
+STR_TOWNNAME_AUSTRIAN                                           :Austrian
+STR_TOWNNAME_ROMANIAN                                           :Romanian
+STR_TOWNNAME_CZECH                                              :Czech
+STR_TOWNNAME_SWISS                                              :Swiss
+STR_TOWNNAME_DANISH                                             :Danish
+STR_TOWNNAME_TURKISH                                            :Turkish
+STR_TOWNNAME_ITALIAN                                            :Italian
+STR_TOWNNAME_CATALAN                                            :Catalan
+############ end of townname region
+
+STR_CURR_GBP                                                    :Pounds (£)
+STR_CURR_USD                                                    :Dollars ($)
+STR_CURR_EUR                                                    :Euro (€)
+STR_CURR_YEN                                                    :Yen (¥)
+STR_CURR_ATS                                                    :Austrian Shilling (ATS)
+STR_CURR_BEF                                                    :Belgian Franc (BEF)
+STR_CURR_CHF                                                    :Swiss Franc (CHF)
+STR_CURR_CZK                                                    :Czech Koruna (CZK)
+STR_CURR_DEM                                                    :Deutschmark (DEM)
+STR_CURR_DKK                                                    :Danish Krone (DKK)
+STR_CURR_ESP                                                    :Peseta (ESP)
+STR_CURR_FIM                                                    :Finnish Markka (FIM)
+STR_CURR_FRF                                                    :Franc (FRF)
+STR_CURR_GRD                                                    :Greek Drachma (GRD)
+STR_CURR_HUF                                                    :Hungarian Forint (HUF)
+STR_CURR_ISK                                                    :Icelandic Krona (ISK)
+STR_CURR_ITL                                                    :Italian Lira (ITL)
+STR_CURR_NLG                                                    :Dutch Guilder (NLG)
+STR_CURR_NOK                                                    :Norwegian Krone (NOK)
+STR_CURR_PLN                                                    :Polish Zloty (PLN)
+STR_CURR_ROL                                                    :Romanian Leu (ROL)
+STR_CURR_RUR                                                    :Russian Rubel (RUR)
+STR_CURR_SIT                                                    :Slovenian Tolar (SIT)
+STR_CURR_SEK                                                    :Swedish Krona (SEK)
+STR_CURR_YTL                                                    :Turkish Lira (YTL)
+STR_CURR_SKK                                                    :Slovak Koruna (SKK)
+STR_CURR_BRR                                                    :Brazilian Real (BRL)
+
+STR_CURR_CUSTOM                                                 :Custom...
+
+STR_OPTIONS_LANG                                                :{BLACK}Language
+STR_OPTIONS_LANG_CBO                                            :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
+STR_OPTIONS_LANG_TIP                                            :{BLACK}Select the interface language to use
+
+STR_OPTIONS_FULLSCREEN                                          :{BLACK}Fullscreen
+STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Check this box to play OpenTTD fullscreen mode
+
+STR_OPTIONS_RES                                                 :{BLACK}Screen resolution
+STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
+STR_OPTIONS_RES_TIP                                             :{BLACK}Select the screen resolution to use
+
+STR_OPTIONS_SCREENSHOT_FORMAT                                   :{BLACK}Screenshot format
+STR_OPTIONS_SCREENSHOT_FORMAT_CBO                               :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
+STR_OPTIONS_SCREENSHOT_FORMAT_TIP                               :{BLACK}Select the screenshot format to use
+
+STR_AUTOSAVE_1_MONTH                                            :Every month
+STR_AUTOSAVE_FAILED                                             :{WHITE}Autosave failed
+
+STR_MONTH_JAN                                                   :January
+STR_MONTH_FEB                                                   :February
+STR_MONTH_MAR                                                   :March
+STR_MONTH_APR                                                   :April
+STR_MONTH_MAY                                                   :May
+STR_MONTH_JUN                                                   :June
+STR_MONTH_JUL                                                   :July
+STR_MONTH_AUG                                                   :August
+STR_MONTH_SEP                                                   :September
+STR_MONTH_OCT                                                   :October
+STR_MONTH_NOV                                                   :November
+STR_MONTH_DEC                                                   :December
+
+STR_HEADING_FOR_STATION                                         :{LTBLUE}Heading for {STATION}
+STR_HEADING_FOR_STATION_VEL                                     :{LTBLUE}Heading for {STATION}, {VELOCITY}
+STR_NO_ORDERS                                                   :{LTBLUE}No orders
+STR_NO_ORDERS_VEL                                               :{LTBLUE}No orders, {VELOCITY}
+
+STR_PASSENGERS                                                  :passengers
+STR_BAGS                                                        :bags
+STR_TONS                                                        :tonnes
+STR_LITERS                                                      :liters
+STR_ITEMS                                                       :items
+STR_CRATES                                                      :crates
+STR_RES_OTHER                                                   :other
+STR_NOTHING                                                     :
+
+STR_SMALL_RIGHT_ARROW                                           :{TINYFONT}{RIGHTARROW}
+
+STR_CANT_SHARE_ORDER_LIST                                       :{WHITE}Can't share order list...
+STR_CANT_COPY_ORDER_LIST                                        :{WHITE}Can't copy order list...
+STR_END_OF_SHARED_ORDERS                                        :{SETX 10}- - End of Shared Orders - -
+
+STR_TRAIN_IS_LOST                                               :{WHITE}Train {COMMA} is lost.
+STR_TRAIN_IS_UNPROFITABLE                                       :{WHITE}Train {COMMA}'s profit last year was {CURRENCY}
+STR_EURO_INTRODUCE                                              :{BLACK}{BIGFONT}European Monetary Union!{}{}The Euro is introduced as the sole currency for everyday transactions in your country!
+
+# Start of order review system.
+# DON'T ADD OR REMOVE LINES HERE
+STR_TRAIN_HAS_TOO_FEW_ORDERS                                    :{WHITE}Train {COMMA} has too few orders in the schedule
+STR_TRAIN_HAS_VOID_ORDER                                        :{WHITE}Train {COMMA} has a void order
+STR_TRAIN_HAS_DUPLICATE_ENTRY                                   :{WHITE}Train {COMMA} has duplicate orders
+STR_TRAIN_HAS_INVALID_ENTRY                                     :{WHITE}Train {COMMA} has an invalid station in its orders
+STR_ROADVEHICLE_HAS_TOO_FEW_ORDERS                              :{WHITE}Road Vehicle {COMMA} has too few orders in the schedule
+STR_ROADVEHICLE_HAS_VOID_ORDER                                  :{WHITE}Road Vehicle {COMMA} has a void order
+STR_ROADVEHICLE_HAS_DUPLICATE_ENTRY                             :{WHITE}Road Vehicle {COMMA} has duplicate orders
+STR_ROADVEHICLE_HAS_INVALID_ENTRY                               :{WHITE}Road Vehicle {COMMA} has an invalid station in its orders
+STR_SHIP_HAS_TOO_FEW_ORDERS                                     :{WHITE}Ship {COMMA} has too few orders in the schedule
+STR_SHIP_HAS_VOID_ORDER                                         :{WHITE}Ship {COMMA} has a void order
+STR_SHIP_HAS_DUPLICATE_ENTRY                                    :{WHITE}Ship {COMMA} has duplicate orders
+STR_SHIP_HAS_INVALID_ENTRY                                      :{WHITE}Ship {COMMA} has an invalid station in its orders
+STR_AIRCRAFT_HAS_TOO_FEW_ORDERS                                 :{WHITE}Aircraft {COMMA} has too few orders in the schedule
+STR_AIRCRAFT_HAS_VOID_ORDER                                     :{WHITE}Aircraft {COMMA} has a void order
+STR_AIRCRAFT_HAS_DUPLICATE_ENTRY                                :{WHITE}Aircraft {COMMA} has duplicate orders
+STR_AIRCRAFT_HAS_INVALID_ENTRY                                  :{WHITE}Aircraft {COMMA} has an invalid station in its orders
+# end of order system
+
+STR_TRAIN_AUTORENEW_FAILED                                      :{WHITE}Autorenew failed on train {COMMA} (money limit)
+STR_ROADVEHICLE_AUTORENEW_FAILED                                :{WHITE}Autorenew failed on road vehicle {COMMA} (money limit)
+STR_SHIP_AUTORENEW_FAILED                                       :{WHITE}Autorenew failed on ship {COMMA} (money limit)
+STR_AIRCRAFT_AUTORENEW_FAILED                                   :{WHITE}Autorenew failed on aircraft {COMMA} (money limit)
+STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT                            :{WHITE}Train {COMMA} is too long after replacement
+
+STR_CONFIG_PATCHES                                              :{BLACK}Configure Patches
+STR_CONFIG_PATCHES_TIP                                          :{BLACK}Configure the patches
+STR_CONFIG_PATCHES_CAPTION                                      :{WHITE}Configure Patches
+
+STR_CONFIG_PATCHES_OFF                                          :Off
+STR_CONFIG_PATCHES_ON                                           :On
+STR_CONFIG_PATCHES_VEHICLESPEED                                 :{LTBLUE}Show vehicle speed in status bar: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_BUILDONSLOPES                                :{LTBLUE}Allow building on slopes and coasts: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AUTOSLOPE                                    :{LTBLUE}Allow terraforming under buildings, tracks, etc. (autoslope): {ORANGE}{STRING}
+STR_CONFIG_PATCHES_CATCHMENT                                    :{LTBLUE}Allow more realistically sized catchment areas: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_EXTRADYNAMITE                                :{LTBLUE}Allow removal of more town-owned roads, bridges, etc: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MAMMOTHTRAINS                                :{LTBLUE}Enable building very long trains: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_REALISTICACCEL                               :{LTBLUE}Enable realistic acceleration for trains: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_FORBID_90_DEG                                :{LTBLUE}Forbid trains and ships to make 90 deg turns: {ORANGE}{STRING} {LTBLUE} (requires NPF)
+STR_CONFIG_PATCHES_JOINSTATIONS                                 :{LTBLUE}Join train stations built next to each other: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_FULLLOADANY                                  :{LTBLUE}Leave station when any cargo is full, if 'full load': {ORANGE}{STRING}
+STR_CONFIG_PATCHES_IMPROVEDLOAD                                 :{LTBLUE}Use improved loading algorithm: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_GRADUAL_LOADING                              :{LTBLUE}Load vehicles gradually: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_INFLATION                                    :{LTBLUE}Inflation: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SELECTGOODS                                  :{LTBLUE}Deliver cargo to a station only when there is a demand: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LONGBRIDGES                                  :{LTBLUE}Allow building very long bridges: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_GOTODEPOT                                    :{LTBLUE}Allow goto depot orders: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD             :{LTBLUE}Manual primary industry construction method: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_NONE        :none
+STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_NORMAL      :as other industries
+STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_PROSPECTING :prospecting
+STR_CONFIG_PATCHES_MULTIPINDTOWN                                :{LTBLUE}Allow multiple similar industries per town: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SAMEINDCLOSE                                 :{LTBLUE}Industries of the same type can be built close to each other: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LONGDATE                                     :{LTBLUE}Always show long date in the status bar: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SIGNALSIDE                                   :{LTBLUE}Show signals on the drive side: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SHOWFINANCES                                 :{LTBLUE}Show finances window at the end of the year: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_NEW_NONSTOP                                  :{LTBLUE}TTDPatch compatible nonstop handling: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ROADVEH_QUEUE                                :{LTBLUE}Road vehicle queueing (with quantum effects): {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Pan window when mouse is at the edge: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Allow bribing of the local authority: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Allow buying exclusive transport rights: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Allow sending money to other companies: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Nonuniform stations: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}New global pathfinding (NPF, overrides NTP): {ORANGE}{STRING}
+STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Weight multiplier for freight to simulate heavy trains: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Allow drive-through road stops on town owned roads: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Allow building adjacent stations: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_SMALL_AIRPORTS                               :{LTBLUE}Always allow small airports: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_WARN_LOST_TRAIN                              :{LTBLUE}Warn if train is lost: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ORDER_REVIEW                                 :{LTBLUE}Review vehicles' orders: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ORDER_REVIEW_OFF                             :no
+STR_CONFIG_PATCHES_ORDER_REVIEW_EXDEPOT                         :yes, but exclude stopped vehicles
+STR_CONFIG_PATCHES_ORDER_REVIEW_ON                              :of all vehicles
+STR_CONFIG_PATCHES_WARN_INCOME_LESS                             :{LTBLUE}Warn if a train's income is negative: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES                        :{LTBLUE}Vehicles never expire: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AUTORENEW_VEHICLE                            :{LTBLUE}Autorenew vehicle when it gets old
+STR_CONFIG_PATCHES_AUTORENEW_MONTHS                             :{LTBLUE}Autorenew when vehice is {ORANGE}{STRING}{LTBLUE} months before/after max age
+STR_CONFIG_PATCHES_AUTORENEW_MONEY                              :{LTBLUE}Autorenew minimum needed money for renew: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ERRMSG_DURATION                              :{LTBLUE}Duration of error message: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_POPULATION_IN_LABEL                          :{LTBLUE}Show town population in the town name label: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_INVISIBLE_TREES                              :{LTBLUE}Invisible trees (with transparent buildings): {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_LAND_GENERATOR                               :{LTBLUE}Land generator: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LAND_GENERATOR_ORIGINAL                      :Original
+STR_CONFIG_PATCHES_LAND_GENERATOR_TERRA_GENESIS                 :TerraGenesis
+STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE                        :{LTBLUE}Oil Refineries' max distance from edge of map {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SNOWLINE_HEIGHT                              :{LTBLUE}Snow line height: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN                         :{LTBLUE}Roughness of terrain (TerraGenesis only) : {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH             :Very Smooth
+STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_SMOOTH                  :Smooth
+STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_ROUGH                   :Rough
+STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_VERY_ROUGH              :Very Rough
+STR_CONFIG_PATCHES_TREE_PLACER                                  :{LTBLUE}Tree placer algorithm: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_TREE_PLACER_NONE                             :None
+STR_CONFIG_PATCHES_TREE_PLACER_ORIGINAL                         :Original
+STR_CONFIG_PATCHES_TREE_PLACER_IMPROVED                         :Improved
+STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION                           :{LTBLUE}Heightmap rotation: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE         :Anti-clockwise
+STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_CLOCKWISE                 :Clockwise
+STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT                         :{LTBLUE}The height level a flat scenario map gets: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_STATION_SPREAD                               :{LTBLUE}Max station spread: {ORANGE}{STRING} {RED}Warning: High setting slows game
+STR_CONFIG_PATCHES_SERVICEATHELIPAD                             :{LTBLUE}Service helicopters at helipads automatically: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR                       :{LTBLUE}Link landscape toolbar to rail/road/water/airport toolbars: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_REVERSE_SCROLLING                            :{LTBLUE}Reverse scroll direction: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SMOOTH_SCROLLING                             :{LTBLUE}Smooth viewport scrolling: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MEASURE_TOOLTIP                              :{LTBLUE}Show a measurement tooltip when using various build-tools: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LIVERIES                                     :{LTBLUE}Show company liveries: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LIVERIES_NONE                                :None
+STR_CONFIG_PATCHES_LIVERIES_OWN                                 :Own company
+STR_CONFIG_PATCHES_LIVERIES_ALL                                 :All companies
+STR_CONFIG_PATCHES_PREFER_TEAMCHAT                              :{LTBLUE}Prefer team chat with <ENTER>: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING                        :{LTBLUE}Function of scrollwheel: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SCROLLWHEEL_ZOOM                             :Zoom map
+STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLL                           :Scroll map
+STR_CONFIG_PATCHES_SCROLLWHEEL_OFF                              :Off
+STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER                       :{LTBLUE}Map scrollwheel speed: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU                          :{LTBLUE}Right-click emulation: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_COMMAND                  :Command-click
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_CONTROL                  :Control-click
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF                      :Off
+
+STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME                            :{LTBLUE}Automatically pause when starting a new game: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS                       :{LTBLUE}Use the advanced vehicle list: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF                   :Off
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OWN                   :Own company
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_ALL                   :All companies
+STR_CONFIG_PATCHES_LOADING_INDICATORS                           :{LTBLUE}Use loading indicators: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LOADING_INDICATORS_OFF                       :Off
+STR_CONFIG_PATCHES_LOADING_INDICATORS_OWN                       :Own company
+STR_CONFIG_PATCHES_LOADING_INDICATORS_ALL                       :All companies
+STR_CONFIG_PATCHES_TIMETABLE_ALLOW                              :{LTBLUE}Enable timetabling for vehicles: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS                           :{LTBLUE}Show timetable in ticks rather than days: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}Default rail type (after new game/game load): {ORANGE}{STRING}
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_RAIL                       :Normal Rail
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_ELRAIL                     :Electrified Rail
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MONORAIL                   :Monorail
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MAGLEV                     :Maglev
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_FIRST                      :First available
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_LAST                       :Last available
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MOST_USED                  :Most used
+
+STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE                  :{LTBLUE}Show building tools when no suitable vehicles are available: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MAX_TRAINS                                   :{LTBLUE}Max trains per player: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MAX_ROADVEH                                  :{LTBLUE}Max road vehicles per player: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MAX_AIRCRAFT                                 :{LTBLUE}Max aircraft per player: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MAX_SHIPS                                    :{LTBLUE}Max ships per player: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_AI_BUILDS_TRAINS                             :{LTBLUE}Disable trains for computer: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH                            :{LTBLUE}Disable road vehicles for computer: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT                           :{LTBLUE}Disable aircraft for computer: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AI_BUILDS_SHIPS                              :{LTBLUE}Disable ships for computer: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_AINEW_ACTIVE                                 :{LTBLUE}Enable new AI (alpha): {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER                            :{LTBLUE}Allow AIs in multiplayer (experimental): {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_SERVINT_TRAINS                               :{LTBLUE}Default service interval for trains: {ORANGE}{STRING} days/%
+STR_CONFIG_PATCHES_SERVINT_TRAINS_DISABLED                      :{LTBLUE}Default service interval for trains: {ORANGE}disabled
+STR_CONFIG_PATCHES_SERVINT_ROADVEH                              :{LTBLUE}Default service interval for road vehicles: {ORANGE}{STRING} days/%
+STR_CONFIG_PATCHES_SERVINT_ROADVEH_DISABLED                     :{LTBLUE}Default service interval for road vehicles: {ORANGE}disabled
+STR_CONFIG_PATCHES_SERVINT_AIRCRAFT                             :{LTBLUE}Default service interval for aircraft: {ORANGE}{STRING} days/%
+STR_CONFIG_PATCHES_SERVINT_AIRCRAFT_DISABLED                    :{LTBLUE}Default service interval for aircraft: {ORANGE}disabled
+STR_CONFIG_PATCHES_SERVINT_SHIPS                                :{LTBLUE}Default service interval for ships: {ORANGE}{STRING} days/%
+STR_CONFIG_PATCHES_SERVINT_SHIPS_DISABLED                       :{LTBLUE}Default service interval for ships: {ORANGE}disabled
+STR_CONFIG_PATCHES_NOSERVICE                                    :{LTBLUE}Disable servicing when breakdowns set to none: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_WAGONSPEEDLIMITS                             :{LTBLUE}Enable railroad car speed limits: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_DISABLE_ELRAILS                              :{LTBLUE}Disable electric rails: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_COLORED_NEWS_YEAR                            :{LTBLUE}Colored news appears in: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_STARTING_YEAR                                :{LTBLUE}Starting date: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENDING_YEAR                                  :{LTBLUE}End game in: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SMOOTH_ECONOMY                               :{LTBLUE}Enable smooth economy (more, smaller changes)
+STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Allow buying shares from other companies
+STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}When dragging place signals every: {ORANGE}{STRING} tile(s)
+STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automatically build semaphores before: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Enable the signal GUI: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}The town layout "no more roads" isn't valid in the scenario editor
+STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Select town-road layout: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_TOWN_LAYOUT_NO_ROADS                         :no more roads
+STR_CONFIG_PATCHES_TOWN_LAYOUT_DEFAULT                          :default
+STR_CONFIG_PATCHES_TOWN_LAYOUT_BETTER_ROADS                     :better roads
+STR_CONFIG_PATCHES_TOWN_LAYOUT_2X2_GRID                         :2x2 grid
+STR_CONFIG_PATCHES_TOWN_LAYOUT_3X3_GRID                         :3x3 grid
+
+STR_CONFIG_PATCHES_TOOLBAR_POS                                  :{LTBLUE}Position of main toolbar: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT                             :Left
+STR_CONFIG_PATCHES_TOOLBAR_POS_CENTER                           :Centre
+STR_CONFIG_PATCHES_TOOLBAR_POS_RIGHT                            :Right
+STR_CONFIG_PATCHES_SNAP_RADIUS                                  :{LTBLUE}Window snap radius: {ORANGE}{STRING} px
+STR_CONFIG_PATCHES_SNAP_RADIUS_DISABLED                         :{LTBLUE}Window snap radius: {ORANGE}disabled
+STR_CONFIG_PATCHES_TOWN_GROWTH                                  :{LTBLUE}Town growth speed: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_TOWN_GROWTH_NONE                             :None
+STR_CONFIG_PATCHES_TOWN_GROWTH_SLOW                             :Slow
+STR_CONFIG_PATCHES_TOWN_GROWTH_NORMAL                           :Normal
+STR_CONFIG_PATCHES_TOWN_GROWTH_FAST                             :Fast
+STR_CONFIG_PATCHES_TOWN_GROWTH_VERY_FAST                        :Very fast
+STR_CONFIG_PATCHES_LARGER_TOWNS                                 :{LTBLUE}Proportion of towns that will grow twice as fast: {ORANGE}1 in {STRING}
+STR_CONFIG_PATCHES_LARGER_TOWNS_DISABLED                        :{LTBLUE}Proportion of towns that will grow twice as fast: {ORANGE}None
+STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER                         :{LTBLUE}Initial city size multiplier: {ORANGE}{STRING}
+STR_CONFIG_MODIFIED_ROAD_REBUILD                                :{LTBLUE}Remove absurd road-elements during the road construction
+
+STR_CONFIG_PATCHES_GUI                                          :{BLACK}Interface
+STR_CONFIG_PATCHES_CONSTRUCTION                                 :{BLACK}Construction
+STR_CONFIG_PATCHES_VEHICLES                                     :{BLACK}Vehicles
+STR_CONFIG_PATCHES_STATIONS                                     :{BLACK}Stations
+STR_CONFIG_PATCHES_ECONOMY                                      :{BLACK}Economy
+STR_CONFIG_PATCHES_AI                                           :{BLACK}Competitors
+
+STR_CONFIG_PATCHES_DISABLED                                     :disabled
+STR_CONFIG_PATCHES_INT32                                        :{NUM}
+STR_CONFIG_PATCHES_CURRENCY                                     :{CURRENCY}
+
+STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Change setting value
+STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Some or all of the default service interval(s) below are incompatible with chosen setting! 5-90% and 30-800 days are valid
+STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Use YAPF for ships: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Use YAPF for roadvehs: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Use YAPF for trains: {ORANGE}{STRING}
+
+STR_TEMPERATE_LANDSCAPE                                         :Temperate landscape
+STR_SUB_ARCTIC_LANDSCAPE                                        :Sub-arctic landscape
+STR_SUB_TROPICAL_LANDSCAPE                                      :Sub-tropical landscape
+STR_TOYLAND_LANDSCAPE                                           :Toyland landscape
+
+STR_CHEATS                                                      :{WHITE}Cheats
+STR_CHEATS_TIP                                                  :{BLACK}Checkboxes indicate if you have used this cheat before
+STR_CHEATS_WARNING                                              :{BLACK}Warning! You are about to betray your fellow competitors. Keep in mind that such a disgrace will be remembered for eternity.
+STR_CHEAT_MONEY                                                 :{LTBLUE}Increase money by {CURRENCY}
+STR_CHEAT_CHANGE_PLAYER                                         :{LTBLUE}Playing as player: {ORANGE}{COMMA}
+STR_CHEAT_EXTRA_DYNAMITE                                        :{LTBLUE}Magic bulldozer (remove industries, unmovables): {ORANGE}{STRING}
+STR_CHEAT_CROSSINGTUNNELS                                       :{LTBLUE}Tunnels may cross each other: {ORANGE}{STRING}
+STR_CHEAT_BUILD_IN_PAUSE                                        :{LTBLUE}Build while in pause mode: {ORANGE}{STRING}
+STR_CHEAT_NO_JETCRASH                                           :{LTBLUE}Jetplanes will not crash (frequently) on small airports: {ORANGE} {STRING}
+STR_CHEAT_SWITCH_CLIMATE                                        :{LTBLUE}Switch climate: {ORANGE} {STRING}
+STR_CHEAT_CHANGE_DATE                                           :{LTBLUE}Change date: {ORANGE} {DATE_SHORT}
+STR_CHEAT_SETUP_PROD                                            :{LTBLUE}Enable modifying production values: {ORANGE}{STRING}
+
+STR_HEADING_FOR_WAYPOINT                                        :{LTBLUE}Heading for {WAYPOINT}
+STR_HEADING_FOR_WAYPOINT_VEL                                    :{LTBLUE}Heading for {WAYPOINT}, {VELOCITY}
+
+STR_GO_TO_WAYPOINT                                              :Go via {WAYPOINT}
+STR_GO_NON_STOP_TO_WAYPOINT                                     :Go non-stop via {WAYPOINT}
+
+STR_WAYPOINTNAME_CITY                                           :Waypoint {TOWN}
+STR_WAYPOINTNAME_CITY_SERIAL                                    :Waypoint {TOWN} #{COMMA}
+STR_LANDINFO_WAYPOINT                                           :Waypoint
+
+STR_WAYPOINT                                                    :{WHITE}Waypoint
+STR_WAYPOINT_GRAPHICS_TIP                                       :{BLACK}Select waypoint type
+
+STR_WAYPOINT_VIEWPORT                                           :{WHITE}{WAYPOINT}
+STR_WAYPOINT_VIEWPORT_TINY                                      :{TINYFONT}{WHITE}{WAYPOINT}
+STR_WAYPOINT_RAW                                                :{WAYPOINT}
+STR_EDIT_WAYPOINT_NAME                                          :{WHITE}Edit waypoint name
+
+STR_CANT_CHANGE_WAYPOINT_NAME                                   :{WHITE}Can't change waypoint name...
+STR_CONVERT_RAIL_TO_WAYPOINT_TIP                                :{BLACK}Convert rail to waypoint
+STR_CANT_BUILD_TRAIN_WAYPOINT                                   :{WHITE}Can't build train waypoint here...
+STR_CANT_REMOVE_TRAIN_WAYPOINT                                  :{WHITE}Can't remove train waypoint here...
+
+STR_BUILD_AUTORAIL_TIP                                          :{BLACK}Build railroad track using the Autorail mode
+
+STR_NO_TOWN_IN_SCENARIO                                         :{WHITE}...there is no town in this scenario
+
+STR_GENERATE_RANDOM_LANDSCAPE                                   :{WHITE}Are you sure you want to create a random landscape?
+STR_MANY_RANDOM_TOWNS                                           :{BLACK}Many random towns
+STR_RANDOM_TOWNS_TIP                                            :{BLACK}Cover the map with randomly placed towns
+STR_MANY_RANDOM_INDUSTRIES                                      :Many random industries
+STR_RANDOM_INDUSTRIES_TIP                                       :{BLACK}Cover the map with randomly placed industries
+STR_CAN_T_GENERATE_INDUSTRIES                                   :{WHITE}Can't generate industries...
+
+STR_LANDSCAPING_TOOLBAR_TIP                                     :{BLACK}Open the landscaping toolbar to raise/lower land, plant trees, etc.
+STR_LANDSCAPING_TOOLBAR                                         :{WHITE}Landscaping
+STR_LEVEL_LAND_TOOLTIP                                          :{BLACK}Level land
+
+
+STR_TREES_RANDOM_TYPE                                           :{BLACK}Trees of random type
+STR_TREES_RANDOM_TYPE_TIP                                       :{BLACK}Place trees of random type
+
+STR_CANT_BUILD_CANALS                                           :{WHITE}Can't build canals here...
+STR_BUILD_CANALS_TIP                                            :{BLACK}Build canals.
+STR_LANDINFO_CANAL                                              :Canal
+
+STR_CANT_BUILD_LOCKS                                            :{WHITE}Can't build locks here...
+STR_BUILD_LOCKS_TIP                                             :{BLACK}Build locks
+STR_LANDINFO_LOCK                                               :Lock
+
+STR_BUOY_IS_IN_USE                                              :{WHITE}... buoy is in use!
+
+STR_LANDINFO_COORDS                                             :{BLACK}Co-ordinates: {LTBLUE}{NUM}x{NUM}x{NUM} ({STRING})
+
+STR_CANT_REMOVE_PART_OF_STATION                                 :{WHITE}Can't remove part of station...
+STR_CANT_CONVERT_RAIL                                           :{WHITE}Can't convert railtype here...
+STR_CONVERT_RAIL_TIP                                            :{BLACK}Convert/Upgrade the type of the rail
+
+STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP                                :{BLACK}Drag train engine here to sell the whole train
+
+STR_DRAG_DROP                                                   :{BLACK}Drag & Drop
+STR_STATION_DRAG_DROP                                           :{BLACK}Build a station with drag & drop
+STR_SELECT_STATION_CLASS_TIP                                    :{BLACK}Select a station class to display
+STR_SELECT_STATION_TYPE_TIP                                     :{BLACK}Select the station type to build
+
+STR_FAST_FORWARD                                                :{BLACK}Fast forward the game
+STR_MESSAGE_HISTORY                                             :{WHITE}Message History
+STR_MESSAGE_HISTORY_TIP                                         :{BLACK}A list of the recent news messages
+STR_MESSAGES_DISABLE_ALL                                        :{BLACK}Disable all
+STR_MESSAGES_ENABLE_ALL                                         :{BLACK}Enable all
+
+STR_CONSTRUCT_COAL_MINE_TIP                                     :{BLACK}Construct Coal Mine
+STR_CONSTRUCT_FOREST_TIP                                        :{BLACK}Plant Forest
+STR_CONSTRUCT_OIL_RIG_TIP                                       :{BLACK}Construct Oil Rig
+STR_CONSTRUCT_FARM_TIP                                          :{BLACK}Fund Farm
+STR_CONSTRUCT_COPPER_ORE_MINE_TIP                               :{BLACK}Construct Copper Ore Mine
+STR_CONSTRUCT_OIL_WELLS_TIP                                     :{BLACK}Drill for Oil
+STR_CONSTRUCT_GOLD_MINE_TIP                                     :{BLACK}Construct Gold Mine
+STR_CONSTRUCT_DIAMOND_MINE_TIP                                  :{BLACK}Construct Diamond Mine
+STR_CONSTRUCT_IRON_ORE_MINE_TIP                                 :{BLACK}Construct Iron Ore Mine
+STR_CONSTRUCT_FRUIT_PLANTATION_TIP                              :{BLACK}Fund Fruit Plantation
+STR_CONSTRUCT_RUBBER_PLANTATION_TIP                             :{BLACK}Fund Rubber Plantation
+STR_CONSTRUCT_WATER_SUPPLY_TIP                                  :{BLACK}Fund Water Supply
+STR_CONSTRUCT_COTTON_CANDY_TIP                                  :{BLACK}Plant Cotton Candy Forest
+STR_CONSTRUCT_BATTERY_FARM_TIP                                  :{BLACK}Fund Battery Farm
+STR_CONSTRUCT_COLA_WELLS_TIP                                    :{BLACK}Drill for Cola
+STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP                             :{BLACK}Fund Plastic Fountains
+STR_CONSTRUCT_BUBBLE_GENERATOR_TIP                              :{BLACK}Construct Bubble Generator
+STR_CONSTRUCT_TOFFEE_QUARRY_TIP                                 :{BLACK}Fund Toffee Quarry
+STR_CONSTRUCT_SUGAR_MINE_TIP                                    :{BLACK}Construct Sugar Mine
+
+STR_INDUSTRYDIR_CAPTION                                         :{WHITE}Industries
+STR_INDUSTRYDIR_ITEM                                            :{ORANGE}{INDUSTRY}{BLACK} ({CARGO}){YELLOW} ({COMMA}% transported)
+STR_INDUSTRYDIR_ITEM_TWO                                        :{ORANGE}{INDUSTRY}{BLACK} ({CARGO}/{CARGO}){YELLOW} ({COMMA}%/{COMMA}% transported)
+STR_INDUSTRYDIR_ITEM_NOPROD                                     :{ORANGE}{INDUSTRY}
+
+STR_INDUSTRY_TOO_CLOSE                                          :{WHITE}...too close to another industry
+
+STR_RAIL_REFIT_VEHICLE_TO_CARRY                                 :{BLACK}Refit train to carry a different cargo type
+STR_RAIL_REFIT_VEHICLE                                          :{BLACK}Refit train
+STR_RAIL_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Select type of cargo for train to carry
+STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED                             :{BLACK}Refit train to carry highlighted cargo type
+STR_RAIL_CAN_T_REFIT_VEHICLE                                    :{WHITE}Can't refit train...
+STR_CONFIG_PATCHES_SERVINT_ISPERCENT                            :{LTBLUE}Service intervals are in percents: {ORANGE}{STRING}
+STR_CONFIG_GAME_PRODUCTION                                      :{WHITE}Change production
+
+TEMP_AI_IN_PROGRESS                                             :{WHITE}Welcome to the new AI under development. If you encounter problems, take a screenshot and post it in the forum.
+TEMP_AI_ACTIVATED                                               :{WHITE}Warning: this new AI is still alpha! Currently, only trucks and busses work!
+TEMP_AI_MULTIPLAYER                                             :{WHITE}Warning: implementation is still experimental (using new AI). Please report any problems to truelight@openttd.org.
+
+############ network gui strings
+
+STR_NETWORK_MULTIPLAYER                                         :{WHITE}Multiplayer
+
+STR_NETWORK_PLAYER_NAME                                         :{BLACK}Player name:
+STR_NETWORK_ENTER_NAME_TIP                                      :{BLACK}This is the name other players will identify you by
+STR_NETWORK_CONNECTION                                          :{BLACK}Connection:
+STR_NETWORK_CONNECTION_TIP                                      :{BLACK}Choose between an internet game or a local area nework game
+
+STR_NETWORK_START_SERVER                                        :{BLACK}Start server
+STR_NETWORK_START_SERVER_TIP                                    :{BLACK}Start an own server
+
+STR_NETWORK_GAME_NAME                                           :{BLACK}Name
+STR_NETWORK_GAME_NAME_TIP                                       :{BLACK}Name of the game
+STR_NETWORK_INFO_ICONS_TIP                                      :{BLACK}Language, server version, etc.
+STR_NETWORK_CLICK_GAME_TO_SELECT                                :{BLACK}Click a game from the list to select it
+
+STR_NETWORK_FIND_SERVER                                         :{BLACK}Find server
+STR_NETWORK_FIND_SERVER_TIP                                     :{BLACK}Search network for a server
+STR_NETWORK_ADD_SERVER                                          :{BLACK}Add server
+STR_NETWORK_ADD_SERVER_TIP                                      :{BLACK}Adds a server to the list which will always be checked for running games.
+STR_NETWORK_ENTER_IP                                            :{BLACK}Enter the IP address of the server
+
+STR_NETWORK_GENERAL_ONLINE                                      :{BLACK}{COMMA}/{COMMA} - {COMMA}/{COMMA}
+STR_NETWORK_CLIENTS_CAPTION                                     :{BLACK}Clients
+STR_NETWORK_CLIENTS_CAPTION_TIP                                 :{BLACK}Clients online / clients max
+STR_NETWORK_GAME_INFO                                           :{SILVER}GAME INFO
+STR_ORANGE                                                      :{ORANGE}{STRING}
+STR_NETWORK_CLIENTS                                             :{SILVER}Clients:  {WHITE}{COMMA} / {COMMA} - {COMMA} / {COMMA}
+STR_NETWORK_LANGUAGE                                            :{SILVER}Language:  {WHITE}{STRING}
+STR_NETWORK_TILESET                                             :{SILVER}Tileset:  {WHITE}{STRING}
+STR_NETWORK_MAP_SIZE                                            :{SILVER}Map size:  {WHITE}{COMMA}x{COMMA}
+STR_NETWORK_SERVER_VERSION                                      :{SILVER}Server version:  {WHITE}{STRING}
+STR_NETWORK_SERVER_ADDRESS                                      :{SILVER}Server address:  {WHITE}{STRING} : {NUM}
+STR_NETWORK_START_DATE                                          :{SILVER}Start date:  {WHITE}{DATE_SHORT}
+STR_NETWORK_CURRENT_DATE                                        :{SILVER}Current date:  {WHITE}{DATE_SHORT}
+STR_NETWORK_PASSWORD                                            :{SILVER}Password protected!
+STR_NETWORK_SERVER_OFFLINE                                      :{SILVER}SERVER OFFLINE
+STR_NETWORK_SERVER_FULL                                         :{SILVER}SERVER FULL
+STR_NETWORK_VERSION_MISMATCH                                    :{SILVER}VERSION MISMATCH
+STR_NETWORK_GRF_MISMATCH                                        :{SILVER}NEWGRF MISMATCH
+
+STR_NETWORK_JOIN_GAME                                           :{BLACK}Join game
+
+
+STR_NETWORK_START_GAME_WINDOW                                   :{WHITE}Start new game
+
+STR_NETWORK_NEW_GAME_NAME                                       :{BLACK}Game name:
+STR_NETWORK_NEW_GAME_NAME_TIP                                   :{BLACK}The game name will be displayed to other players in the multiplayer game selection menu
+STR_NETWORK_SET_PASSWORD                                        :{BLACK}Set password
+STR_NETWORK_PASSWORD_TIP                                        :{BLACK}Protect your game with a password if you don't want other people to join it
+STR_NETWORK_SELECT_MAP                                          :{BLACK}Select a map:
+STR_NETWORK_SELECT_MAP_TIP                                      :{BLACK}Which map do you want to play?
+STR_NETWORK_LAN_INTERNET_COMBO                                  :{BLACK}{SKIP}{STRING}
+STR_NETWORK_LAN                                                 :LAN
+STR_NETWORK_INTERNET                                            :Internet
+STR_NETWORK_LAN_INTERNET                                        :LAN / Internet
+STR_NETWORK_INTERNET_ADVERTISE                                  :Internet (advertize)
+STR_NETWORK_CLIENTS_SELECT                                      :{BLACK}{SKIP}{SKIP}{NUM} client{P "" s}
+STR_NETWORK_NUMBER_OF_CLIENTS                                   :{BLACK}Maximum allowed clients:
+STR_NETWORK_NUMBER_OF_CLIENTS_TIP                               :{BLACK}Choose a maximum number of clients. Not all slots need to be filled.
+STR_NETWORK_COMPANIES_SELECT                                    :{BLACK}{SKIP}{SKIP}{SKIP}{NUM} compan{P y ies}
+STR_NETWORK_NUMBER_OF_COMPANIES                                 :{BLACK}Max companies:
+STR_NETWORK_NUMBER_OF_COMPANIES_TIP                             :{BLACK}Limit the server to a certain number of companies
+STR_NETWORK_SPECTATORS_SELECT                                   :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{NUM} spectator{P "" s}
+STR_NETWORK_NUMBER_OF_SPECTATORS                                :{BLACK}Max spectators:
+STR_NETWORK_NUMBER_OF_SPECTATORS_TIP                            :{BLACK}Limit the server to a certain number of spectators
+STR_NETWORK_LANGUAGE_SPOKEN                                     :{BLACK}Language spoken:
+STR_NETWORK_LANGUAGE_TIP                                        :{BLACK}Other players will know which language is spoken on the server.
+STR_NETWORK_LANGUAGE_COMBO                                      :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
+STR_NETWORK_START_GAME                                          :{BLACK}Start Game
+STR_NETWORK_START_GAME_TIP                                      :{BLACK}Start a new network game from a random map, or scenario
+STR_NETWORK_LOAD_GAME                                           :{BLACK}Load Game
+STR_NETWORK_LOAD_GAME_TIP                                       :{BLACK}Resume an earlier saved multiplayer game (be sure to connect as the correct player)
+
+############ Leave those lines in this order!!
+STR_NETWORK_LANG_ANY                                            :Any
+STR_NETWORK_LANG_ENGLISH                                        :English
+STR_NETWORK_LANG_GERMAN                                         :German
+STR_NETWORK_LANG_FRENCH                                         :French
+STR_NETWORK_LANG_BRAZILIAN                                      :Brazilian
+STR_NETWORK_LANG_BULGARIAN                                      :Bulgarian
+STR_NETWORK_LANG_CHINESE                                        :Chinese
+STR_NETWORK_LANG_CZECH                                          :Czech
+STR_NETWORK_LANG_DANISH                                         :Danish
+STR_NETWORK_LANG_DUTCH                                          :Dutch
+STR_NETWORK_LANG_ESPERANTO                                      :Esperanto
+STR_NETWORK_LANG_FINNISH                                        :Finnish
+STR_NETWORK_LANG_HUNGARIAN                                      :Hungarian
+STR_NETWORK_LANG_ICELANDIC                                      :Icelandic
+STR_NETWORK_LANG_ITALIAN                                        :Italian
+STR_NETWORK_LANG_JAPANESE                                       :Japanese
+STR_NETWORK_LANG_KOREAN                                         :Korean
+STR_NETWORK_LANG_LITHUANIAN                                     :Lithuanian
+STR_NETWORK_LANG_NORWEGIAN                                      :Norwegian
+STR_NETWORK_LANG_POLISH                                         :Polish
+STR_NETWORK_LANG_PORTUGUESE                                     :Portuguese
+STR_NETWORK_LANG_ROMANIAN                                       :Romanian
+STR_NETWORK_LANG_RUSSIAN                                        :Russian
+STR_NETWORK_LANG_SLOVAK                                         :Slovak
+STR_NETWORK_LANG_SLOVENIAN                                      :Slovenian
+STR_NETWORK_LANG_SPANISH                                        :Spanish
+STR_NETWORK_LANG_SWEDISH                                        :Swedish
+STR_NETWORK_LANG_TURKISH                                        :Turkish
+STR_NETWORK_LANG_UKRAINIAN                                      :Ukrainian
+############ End of leave-in-this-order
+
+STR_NETWORK_GAME_LOBBY                                          :{WHITE}Multiplayer game lobby
+
+STR_NETWORK_PREPARE_TO_JOIN                                     :{BLACK}Preparing to join:   {ORANGE}{STRING}
+STR_NETWORK_COMPANY_LIST_TIP                                    :{BLACK}A list of all companies currently in this game. You can either join one or start a
+STR_NETWORK_NEW_COMPANY                                         :{BLACK}New company
+STR_NETWORK_NEW_COMPANY_TIP                                     :{BLACK}Open a new company
+STR_NETWORK_SPECTATE_GAME                                       :{BLACK}Watch game
+STR_NETWORK_SPECTATE_GAME_TIP                                   :{BLACK}Watch the game as a spectator
+STR_NETWORK_JOIN_COMPANY                                        :{BLACK}Join company
+STR_NETWORK_JOIN_COMPANY_TIP                                    :{BLACK}Help managing this company
+STR_NETWORK_REFRESH                                             :{BLACK}Refresh server
+STR_NETWORK_REFRESH_TIP                                         :{BLACK}Refresh the server info
+
+STR_NETWORK_COMPANY_INFO                                        :{SILVER}COMPANY INFO
+
+STR_NETWORK_COMPANY_NAME                                        :{SILVER}Company name:  {WHITE}{STRING}
+STR_NETWORK_INAUGURATION_YEAR                                   :{SILVER}Inauguration:  {WHITE}{NUM}
+STR_NETWORK_VALUE                                               :{SILVER}Company value:  {WHITE}{CURRENCY}
+STR_NETWORK_CURRENT_BALANCE                                     :{SILVER}Current balance:  {WHITE}{CURRENCY}
+STR_NETWORK_LAST_YEARS_INCOME                                   :{SILVER}Last year's income:  {WHITE}{CURRENCY}
+STR_NETWORK_PERFORMANCE                                         :{SILVER}Performance:  {WHITE}{NUM}
+
+STR_NETWORK_VEHICLES                                            :{SILVER}Vehicles:  {WHITE}{NUM} {TRAIN}, {NUM} {LORRY}, {NUM} {BUS}, {NUM} {PLANE}, {NUM} {SHIP}
+STR_NETWORK_STATIONS                                            :{SILVER}Stations:  {WHITE}{NUM} {TRAIN}, {NUM} {LORRY}, {NUM} {BUS}, {NUM} {PLANE}, {NUM} {SHIP}
+STR_NETWORK_PLAYERS                                             :{SILVER}Players:  {WHITE}{STRING}
+
+STR_NETWORK_CONNECTING                                          :{WHITE}Connecting...
+
+############ Leave those lines in this order!!
+STR_NETWORK_CONNECTING_1                                        :{BLACK}(1/6) Connecting..
+STR_NETWORK_CONNECTING_2                                        :{BLACK}(2/6) Authorizing..
+STR_NETWORK_CONNECTING_3                                        :{BLACK}(3/6) Waiting..
+STR_NETWORK_CONNECTING_4                                        :{BLACK}(4/6) Downloading map..
+STR_NETWORK_CONNECTING_5                                        :{BLACK}(5/6) Processing data..
+STR_NETWORK_CONNECTING_6                                        :{BLACK}(6/6) Registering..
+
+STR_NETWORK_CONNECTING_SPECIAL_1                                :{BLACK}Fetching game info..
+STR_NETWORK_CONNECTING_SPECIAL_2                                :{BLACK}Fetching company info..
+############ End of leave-in-this-order
+STR_NETWORK_CONNECTING_WAITING                                  :{BLACK}{NUM} client{P "" s} in front of us
+STR_NETWORK_CONNECTING_DOWNLOADING                              :{BLACK}{NUM} / {NUM} kbytes downloaded so far
+
+STR_NETWORK_DISCONNECT                                          :{BLACK}Disconnect
+
+STR_NETWORK_GIVE_MONEY_CAPTION                                  :{WHITE}Enter the amount of money you want to give
+STR_NETWORK_NEED_GAME_PASSWORD_CAPTION                          :{WHITE}Server is protected. Enter password
+STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION                       :{WHITE}Company is protected. Enter password
+STR_NETWORK_CLIENT_LIST                                         :{WHITE}Client List
+
+STR_NETWORK_ERR_NOTAVAILABLE                                    :{WHITE} No network devices found or compiled without ENABLE_NETWORK
+STR_NETWORK_ERR_NOSERVER                                        :{WHITE} Could not find any network games
+STR_NETWORK_ERR_NOCONNECTION                                    :{WHITE} The server didn't answer the request
+STR_NETWORK_ERR_NEWGRF_MISMATCH                                 :{WHITE} Could not connect due to NewGRF mismatch
+STR_NETWORK_ERR_DESYNC                                          :{WHITE} Network-Game synchronization failed.
+STR_NETWORK_ERR_LOSTCONNECTION                                  :{WHITE} Network-Game connection lost.
+STR_NETWORK_ERR_SAVEGAMEERROR                                   :{WHITE} Could not load server-savegame.
+STR_NETWORK_ERR_SERVER_START                                    :{WHITE} Could not start the server.
+STR_NETWORK_ERR_CLIENT_START                                    :{WHITE} Could not connect.
+STR_NETWORK_ERR_TIMEOUT                                         :{WHITE} Connection #{NUM} timed out.
+STR_NETWORK_ERR_SERVER_ERROR                                    :{WHITE} We made a protocol-error and our connection is closed.
+STR_NETWORK_ERR_WRONG_REVISION                                  :{WHITE} The revision of this client does not match the revision of the server.
+STR_NETWORK_ERR_WRONG_PASSWORD                                  :{WHITE} Wrong password.
+STR_NETWORK_ERR_SERVER_FULL                                     :{WHITE} The server is full
+STR_NETWORK_ERR_SERVER_BANNED                                   :{WHITE} You are banned from this server
+STR_NETWORK_ERR_KICKED                                          :{WHITE} You are kicked out of the server
+STR_NETWORK_ERR_CHEATER                                         :{WHITE} Cheating is not allowed on this server
+
+STR_NETWORK_ERR_LEFT                                            :has left the game
+############ Leave those lines in this order!!
+STR_NETWORK_ERR_CLIENT_GENERAL                                  :general error
+STR_NETWORK_ERR_CLIENT_DESYNC                                   :desync error
+STR_NETWORK_ERR_CLIENT_SAVEGAME                                 :could not load map
+STR_NETWORK_ERR_CLIENT_CONNECTION_LOST                          :connection lost
+STR_NETWORK_ERR_CLIENT_PROTOCOL_ERROR                           :protocol error
+STR_NETWORK_ERR_CLIENT_NEWGRF_MISMATCH                          :NewGRF mismatch
+STR_NETWORK_ERR_CLIENT_NOT_AUTHORIZED                           :not authorized
+STR_NETWORK_ERR_CLIENT_NOT_EXPECTED                             :received strange packet
+STR_NETWORK_ERR_CLIENT_WRONG_REVISION                           :wrong revision
+STR_NETWORK_ERR_CLIENT_NAME_IN_USE                              :name already in use
+STR_NETWORK_ERR_CLIENT_WRONG_PASSWORD                           :wrong game-password
+STR_NETWORK_ERR_CLIENT_PLAYER_MISMATCH                          :wrong player-id in DoCommand
+STR_NETWORK_ERR_CLIENT_KICKED                                   :kicked by server
+STR_NETWORK_ERR_CLIENT_CHEATER                                  :was trying to use a cheat
+STR_NETWORK_ERR_CLIENT_SERVER_FULL                              :server full
+############ End of leave-in-this-order
+STR_NETWORK_CLIENT_JOINED                                       :has joined the game
+STR_NETWORK_GIVE_MONEY                                          :gave you some money ({CURRENCY})
+STR_NETWORK_GAVE_MONEY_AWAY                                     :you gave {STRING} some money ({CURRENCY})
+STR_NETWORK_CHAT_COMPANY_CAPTION                                :[Team] :
+STR_NETWORK_CHAT_COMPANY                                        :[Team] {STRING}: {GRAY}{STRING}
+STR_NETWORK_CHAT_TO_COMPANY                                     :[Team] To {STRING}: {GRAY}{STRING}
+STR_NETWORK_CHAT_CLIENT_CAPTION                                 :[Private] :
+STR_NETWORK_CHAT_CLIENT                                         :[Private] {STRING}: {GRAY}{STRING}
+STR_NETWORK_CHAT_TO_CLIENT                                      :[Private] To {STRING}: {GRAY}{STRING}
+STR_NETWORK_CHAT_ALL_CAPTION                                    :[All] :
+STR_NETWORK_CHAT_ALL                                            :[All] {STRING}: {GRAY}{STRING}
+STR_NETWORK_NAME_CHANGE                                         :has changed his name to
+STR_NETWORK_SERVER_SHUTDOWN                                     :{WHITE} The server closed the session
+STR_NETWORK_SERVER_REBOOT                                       :{WHITE} The server is restarting...{}Please wait...
+
+STR_NETWORK_SERVER                                              :Server
+STR_NETWORK_CLIENT                                              :Client
+STR_NETWORK_SPECTATORS                                          :Spectators
+
+STR_NETWORK_CLIENTLIST_NONE                                     :(none)
+STR_NETWORK_CLIENTLIST_KICK                                     :Kick
+STR_NETWORK_CLIENTLIST_GIVE_MONEY                               :Give money
+STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL                             :Speak to all
+STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY                         :Speak to company
+STR_NETWORK_CLIENTLIST_SPEAK_TO_CLIENT                          :Private message
+
+
+STR_NETWORK_SEND                                                :{BLACK}Send
+
+############ end network gui strings
+
+
+STR_CONFIG_PATCHES_MAP_X                                        :{LTBLUE}X-size of map: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MAP_Y                                        :{LTBLUE}Y-size of map: {ORANGE}{STRING}
+
+
+##### PNG-MAP-Loader
+
+STR_PNGMAP_ERROR                                                :{WHITE}Cannot load landscape from PNG...
+STR_PNGMAP_ERR_FILE_NOT_FOUND                                   :{WHITE}...file not found.
+STR_PNGMAP_ERR_IMAGE_TYPE                                       :{WHITE}...could not convert image type. 8 or 24-bit PNG image needed.
+STR_PNGMAP_ERR_MISC                                             :{WHITE}...something just went wrong. Sorry. (probably corrupted file)
+
+STR_BMPMAP_ERROR                                                :{WHITE}Cannot load landscape from BMP...
+STR_BMPMAP_ERR_IMAGE_TYPE                                       :{WHITE}...could not convert image type.
+
+##id 0x0800
+STR_0800_COST                                                   :{TINYFONT}{RED}Cost: {CURRENCY}
+STR_0801_COST                                                   :{RED}Cost: {CURRENCY}
+STR_0802_INCOME                                                 :{TINYFONT}{GREEN}Income: {CURRENCY}
+STR_0803_INCOME                                                 :{GREEN}Income: {CURRENCY}
+STR_FEEDER_TINY                                                 :{TINYFONT}{YELLOW}Transfer: {CURRENCY}
+STR_FEEDER                                                      :{YELLOW}Transfer: {CURRENCY}
+STR_0805_ESTIMATED_COST                                         :{WHITE}Estimated Cost: {CURRENCY}
+STR_0807_ESTIMATED_INCOME                                       :{WHITE}Estimated Income: {CURRENCY}
+STR_0808_CAN_T_RAISE_LAND_HERE                                  :{WHITE}Can't raise land here...
+STR_0809_CAN_T_LOWER_LAND_HERE                                  :{WHITE}Can't lower land here...
+STR_080A_ROCKS                                                  :Rocks
+STR_080B_ROUGH_LAND                                             :Rough land
+STR_080C_BARE_LAND                                              :Bare land
+STR_080D_GRASS                                                  :Grass
+STR_080E_FIELDS                                                 :Fields
+STR_080F_SNOW_COVERED_LAND                                      :Snow-covered land
+STR_0810_DESERT                                                 :Desert
+
+##id 0x1000
+STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION                         :{WHITE}Land sloped in wrong direction
+STR_1001_IMPOSSIBLE_TRACK_COMBINATION                           :{WHITE}Impossible track combination
+STR_1002_EXCAVATION_WOULD_DAMAGE                                :{WHITE}Excavation would damage tunnel
+STR_1003_ALREADY_AT_SEA_LEVEL                                   :{WHITE}Already at sea-level
+STR_1004_TOO_HIGH                                               :{WHITE}Too high
+STR_1005_NO_SUITABLE_RAILROAD_TRACK                             :{WHITE}No suitable railroad track
+STR_1007_ALREADY_BUILT                                          :{WHITE}...already built
+STR_1008_MUST_REMOVE_RAILROAD_TRACK                             :{WHITE}Must remove railroad track first
+STR_100A_RAILROAD_CONSTRUCTION                                  :{WHITE}Railroad Construction
+STR_TITLE_ELRAIL_CONSTRUCTION                                   :{WHITE}Electrified Railroad Construction
+STR_100B_MONORAIL_CONSTRUCTION                                  :{WHITE}Monorail Construction
+STR_100C_MAGLEV_CONSTRUCTION                                    :{WHITE}MagLev Construction
+STR_100D_SELECT_RAIL_BRIDGE                                     :{WHITE}Select Rail Bridge
+STR_100E_CAN_T_BUILD_TRAIN_DEPOT                                :{WHITE}Can't build train depot here...
+STR_100F_CAN_T_BUILD_RAILROAD_STATION                           :{WHITE}Can't build railroad station here...
+STR_1010_CAN_T_BUILD_SIGNALS_HERE                               :{WHITE}Can't build signals here...
+STR_1011_CAN_T_BUILD_RAILROAD_TRACK                             :{WHITE}Can't build railroad track here...
+STR_1012_CAN_T_REMOVE_RAILROAD_TRACK                            :{WHITE}Can't remove railroad track from here...
+STR_1013_CAN_T_REMOVE_SIGNALS_FROM                              :{WHITE}Can't remove signals from here...
+STR_1014_TRAIN_DEPOT_ORIENTATION                                :{WHITE}Train Depot Orientation
+STR_1015_RAILROAD_CONSTRUCTION                                  :Railroad construction
+STR_TOOLB_ELRAIL_CONSTRUCTION                                   :Electrified Railroad construction
+STR_1016_MONORAIL_CONSTRUCTION                                  :Monorail construction
+STR_1017_MAGLEV_CONSTRUCTION                                    :MagLev construction
+STR_1018_BUILD_RAILROAD_TRACK                                   :{BLACK}Build railroad track
+STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING                         :{BLACK}Build train depot (for building and servicing trains)
+STR_101A_BUILD_RAILROAD_STATION                                 :{BLACK}Build railroad station
+STR_101B_BUILD_RAILROAD_SIGNALS                                 :{BLACK}Build railroad signals
+STR_101C_BUILD_RAILROAD_BRIDGE                                  :{BLACK}Build railroad bridge
+STR_101D_BUILD_RAILROAD_TUNNEL                                  :{BLACK}Build railroad tunnel
+STR_101E_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Toggle build/remove for railroad track and signals
+STR_101F_BRIDGE_SELECTION_CLICK                                 :{BLACK}Bridge selection - click on your prefered bridge to build it
+STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO                       :{BLACK}Select railroad depot orientation
+STR_1021_RAILROAD_TRACK                                         :Railroad track
+STR_1023_RAILROAD_TRAIN_DEPOT                                   :Railroad train depot
+STR_1024_AREA_IS_OWNED_BY_ANOTHER                               :{WHITE}...area is owned by another company
+STR_RAILROAD_TRACK_WITH_NORMAL_SIGNALS                          :Railroad track with normal signals
+STR_RAILROAD_TRACK_WITH_PRESIGNALS                              :Railroad track with pre-signals
+STR_RAILROAD_TRACK_WITH_EXITSIGNALS                             :Railroad track with exit-signals
+STR_RAILROAD_TRACK_WITH_COMBOSIGNALS                            :Railway track with combo-signals
+STR_RAILROAD_TRACK_WITH_NORMAL_PRESIGNALS                       :Railway track with normal and pre-signals
+STR_RAILROAD_TRACK_WITH_NORMAL_EXITSIGNALS                      :Railway track with normal and exit-signals
+STR_RAILROAD_TRACK_WITH_NORMAL_COMBOSIGNALS                     :Railway track with normal and combo-signals
+STR_RAILROAD_TRACK_WITH_PRE_EXITSIGNALS                         :Railway track with pre- and exit-signals
+STR_RAILROAD_TRACK_WITH_PRE_COMBOSIGNALS                        :Railway track with pre- and combo-signals
+STR_RAILROAD_TRACK_WITH_EXIT_COMBOSIGNALS                       :Railway track with exit- and combo-signals
+STR_MUST_REMOVE_RAILWAY_STATION_FIRST                           :{WHITE}Must remove railway station first
+
+
+
+##id 0x1800
+STR_1801_MUST_REMOVE_ROAD_FIRST                                 :{WHITE}Must remove road first
+STR_ROAD_WORKS_IN_PROGRESS                                      :{WHITE}Road works in progress
+STR_1802_ROAD_CONSTRUCTION                                      :{WHITE}Road Construction
+STR_1802_TRAMWAY_CONSTRUCTION                                   :{WHITE}Tramway Construction
+STR_1803_SELECT_ROAD_BRIDGE                                     :{WHITE}Select Road Bridge
+STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION                        :{WHITE}... one way roads can't have junctions
+STR_1804_CAN_T_BUILD_ROAD_HERE                                  :{WHITE}Can't build road here...
+STR_1804_CAN_T_BUILD_TRAMWAY_HERE                               :{WHITE}Can't build tramway here...
+STR_1805_CAN_T_REMOVE_ROAD_FROM                                 :{WHITE}Can't remove road from here...
+STR_1805_CAN_T_REMOVE_TRAMWAY_FROM                              :{WHITE}Can't remove tramway from here...
+STR_1806_ROAD_DEPOT_ORIENTATION                                 :{WHITE}Road Depot Orientation
+STR_1806_TRAM_DEPOT_ORIENTATION                                 :{WHITE}Tram Depot Orientation
+STR_1807_CAN_T_BUILD_ROAD_VEHICLE                               :{WHITE}Can't build road vehicle depot here...
+STR_1807_CAN_T_BUILD_TRAM_VEHICLE                               :{WHITE}Can't build tram vehicle depot here...
+STR_1808_CAN_T_BUILD_BUS_STATION                                :{WHITE}Can't build bus station...
+STR_1809_CAN_T_BUILD_TRUCK_STATION                              :{WHITE}Can't build truck station...
+STR_1808_CAN_T_BUILD_PASSENGER_TRAM_STATION                     :{WHITE}Can't build passenger tram station...
+STR_1809_CAN_T_BUILD_CARGO_TRAM_STATION                         :{WHITE}Can't build freight tram station...
+STR_180A_ROAD_CONSTRUCTION                                      :Road construction
+STR_180A_TRAMWAY_CONSTRUCTION                                   :Tramway construction
+STR_180B_BUILD_ROAD_SECTION                                     :{BLACK}Build road section
+STR_BUILD_AUTOROAD_TIP                                          :{BLACK}Build road section using the Autoroad mode
+STR_180B_BUILD_TRAMWAY_SECTION                                  :{BLACK}Build tramway section
+STR_BUILD_AUTOTRAM_TIP                                          :{BLACK}Build tramway section using the Autotram mode
+STR_180C_BUILD_ROAD_VEHICLE_DEPOT                               :{BLACK}Build road vehicle depot (for building and servicing vehicles)
+STR_180C_BUILD_TRAM_VEHICLE_DEPOT                               :{BLACK}Build tram vehicle depot (for building and servicing trams)
+STR_180D_BUILD_BUS_STATION                                      :{BLACK}Build bus station
+STR_180E_BUILD_TRUCK_LOADING_BAY                                :{BLACK}Build truck loading bay
+STR_180D_BUILD_PASSENGER_TRAM_STATION                           :{BLACK}Build passenger tram station
+STR_180E_BUILD_CARGO_TRAM_STATION                               :{BLACK}Build freight tram station
+STR_180F_BUILD_ROAD_BRIDGE                                      :{BLACK}Build road bridge
+STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Build tramway bridge
+STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Build road tunnel
+STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Build tramway tunnel
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Activate/Deactivate one way roads
+STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Toggle build/remove for road construction
+STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Toggle build/remove for tramway construction
+STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Select road vehicle depot orientation
+STR_1813_SELECT_TRAM_VEHICLE_DEPOT                              :{BLACK}Select tram vehicle depot orientation
+STR_1814_ROAD                                                   :Road
+STR_1815_ROAD_WITH_STREETLIGHTS                                 :Road with streetlights
+STR_1816_TREE_LINED_ROAD                                        :Tree-lined road
+STR_1817_ROAD_VEHICLE_DEPOT                                     :Road vehicle depot
+STR_1818_ROAD_RAIL_LEVEL_CROSSING                               :Road/rail grade crossing
+STR_CAN_T_REMOVE_BUS_STATION                                    :{WHITE}Can't remove bus station...
+STR_CAN_T_REMOVE_TRUCK_STATION                                  :{WHITE}Can't remove truck station...
+STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION                         :{WHITE}Can't remove passenger tram station...
+STR_CAN_T_REMOVE_CARGO_TRAM_STATION                             :{WHITE}Can't remove freight tram station...
+
+##id 0x2000
+STR_2000_TOWNS                                                  :{WHITE}Towns
+STR_TOWN_LABEL_POP                                              :{WHITE}{TOWN} ({COMMA})
+STR_TOWN_LABEL                                                  :{WHITE}{TOWN}
+STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
+STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
+STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
+STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Building must be demolished first
+STR_2005                                                        :{WHITE}{TOWN}
+STR_2006_POPULATION                                             :{BLACK}Population: {ORANGE}{COMMA}{BLACK}  Houses: {ORANGE}{COMMA}
+STR_2007_RENAME_TOWN                                            :Rename Town
+STR_2008_CAN_T_RENAME_TOWN                                      :{WHITE}Can't rename town...
+STR_2009_LOCAL_AUTHORITY_REFUSES                                :{WHITE}{TOWN} local authority refuses to allow this
+STR_200A_TOWN_NAMES_CLICK_ON_NAME                               :{BLACK}Town names - click on name to center view on town
+STR_200B_CENTER_THE_MAIN_VIEW_ON                                :{BLACK}Center the main view on town location
+STR_200C_CHANGE_TOWN_NAME                                       :{BLACK}Change town name
+STR_200D_PASSENGERS_LAST_MONTH_MAX                              :{BLACK}Passengers last month: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
+STR_200E_MAIL_LAST_MONTH_MAX                                    :{BLACK}Mail last month: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
+STR_200F_TALL_OFFICE_BLOCK                                      :Tall office block
+STR_2010_OFFICE_BLOCK                                           :Office block
+STR_2011_SMALL_BLOCK_OF_FLATS                                   :Small block of apartments
+STR_2012_CHURCH                                                 :Church
+STR_2013_LARGE_OFFICE_BLOCK                                     :Large office block
+STR_2014_TOWN_HOUSES                                            :Town houses
+STR_2015_HOTEL                                                  :Hotel
+STR_2016_STATUE                                                 :Statue
+STR_2017_FOUNTAIN                                               :Fountain
+STR_2018_PARK                                                   :Park
+STR_2019_OFFICE_BLOCK                                           :Office block
+STR_201A_SHOPS_AND_OFFICES                                      :Shops and offices
+STR_201B_MODERN_OFFICE_BUILDING                                 :Modern office building
+STR_201C_WAREHOUSE                                              :Warehouse
+STR_201D_OFFICE_BLOCK                                           :Office block
+STR_201E_STADIUM                                                :Stadium
+STR_201F_OLD_HOUSES                                             :Old houses
+STR_2020_LOCAL_AUTHORITY                                        :{BLACK}Local authority
+STR_2021_SHOW_INFORMATION_ON_LOCAL                              :{BLACK}Show information on local authority
+STR_2022_LOCAL_AUTHORITY                                        :{WHITE}{TOWN} local authority
+STR_2023_TRANSPORT_COMPANY_RATINGS                              :{BLACK}Transport company ratings:
+STR_2024                                                        :{YELLOW}{COMPANY} {COMPANYNUM}: {ORANGE}{STRING}
+STR_2025_SUBSIDIES                                              :{WHITE}Subsidies
+STR_2026_SUBSIDIES_ON_OFFER_FOR                                 :{BLACK}Subsidies on offer for services taking:
+STR_2027_FROM_TO                                                :{ORANGE}{STRING} from {STRING} to {STRING}
+STR_2028_BY                                                     :{YELLOW} (by {DATE_SHORT})
+STR_202A_NONE                                                   :{ORANGE}None
+STR_202B_SERVICES_ALREADY_SUBSIDISED                            :{BLACK}Services already subsidized:
+STR_202C_FROM_TO                                                :{ORANGE}{STRING} from {STATION} to {STATION}{YELLOW} ({COMPANY}
+STR_202D_UNTIL                                                  :{YELLOW}, until {DATE_SHORT})
+STR_202E_OFFER_OF_SUBSIDY_EXPIRED                               :{BLACK}{BIGFONT}Offer of subsidy expired:{}{}{STRING} from {STRING} to {STRING} will now not attract a subsidy.
+STR_202F_SUBSIDY_WITHDRAWN_SERVICE                              :{BLACK}{BIGFONT}Subsidy withdrawn:{}{}{STRING} service from {STATION} to {STATION} is no longer subsidized.
+STR_2030_SERVICE_SUBSIDY_OFFERED                                :{BLACK}{BIGFONT}Service subsidy offered:{}{}First {STRING} service from {STRING} to {STRING} will attract a year's subsidy from the local authority!
+STR_2031_SERVICE_SUBSIDY_AWARDED                                :{BLACK}{BIGFONT}Service subsidy awarded to {COMPANY}!{}{}{STRING} service from {STATION} to {STATION} will pay 50% extra for the next year!
+STR_2032_SERVICE_SUBSIDY_AWARDED                                :{BLACK}{BIGFONT}Service subsidy awarded to {COMPANY}!{}{}{STRING} service from {STATION} to {STATION} will pay double rates for the next year!
+STR_2033_SERVICE_SUBSIDY_AWARDED                                :{BLACK}{BIGFONT}Service subsidy awarded to {COMPANY}!{}{}{STRING} service from {STATION} to {STATION} will pay triple rates for the next year!
+STR_2034_SERVICE_SUBSIDY_AWARDED                                :{BLACK}{BIGFONT}Service subsidy awarded to {COMPANY}!{}{}{STRING} service from {STATION} to {STATION} will pay quadruple rates for the next year!
+STR_2035_LOCAL_AUTHORITY_REFUSES                                :{WHITE}{TOWN} local authority refuses to allow another airport to be built in this town
+STR_2036_COTTAGES                                               :Cottages
+STR_2037_HOUSES                                                 :Houses
+STR_2038_FLATS                                                  :Apartments
+STR_2039_TALL_OFFICE_BLOCK                                      :Tall office block
+STR_203A_SHOPS_AND_OFFICES                                      :Shops and offices
+STR_203B_SHOPS_AND_OFFICES                                      :Shops and offices
+STR_203C_THEATER                                                :Theater
+STR_203D_STADIUM                                                :Stadium
+STR_203E_OFFICES                                                :Offices
+STR_203F_HOUSES                                                 :Houses
+STR_2040_CINEMA                                                 :Cinema
+STR_2041_SHOPPING_MALL                                          :Shopping mall
+STR_2042_DO_IT                                                  :{BLACK}Do it
+STR_2043_LIST_OF_THINGS_TO_DO_AT                                :{BLACK}List of things to do at this town - click on item for more details
+STR_2044_CARRY_OUT_THE_HIGHLIGHTED                              :{BLACK}Carry out the highlighted action in the list above
+STR_2045_ACTIONS_AVAILABLE                                      :{BLACK}Actions available:
+STR_2046_SMALL_ADVERTISING_CAMPAIGN                             :Small advertising campaign
+STR_2047_MEDIUM_ADVERTISING_CAMPAIGN                            :Medium advertising campaign
+STR_2048_LARGE_ADVERTISING_CAMPAIGN                             :Large advertising campaign
+STR_2049_FUND_LOCAL_ROAD_RECONSTRUCTION                         :Fund local road reconstruction
+STR_204A_BUILD_STATUE_OF_COMPANY                                :Build statue of company owner
+STR_204B_FUND_NEW_BUILDINGS                                     :Fund new buildings
+STR_204C_BUY_EXCLUSIVE_TRANSPORT                                :Buy exclusive transport rights
+STR_TOWN_BRIBE_THE_LOCAL_AUTHORITY                              :Bribe the local authority
+STR_204D_INITIATE_A_SMALL_LOCAL                                 :{WHITE}{STRING}{}{YELLOW} Initiate a small local advertising campaign, to attract more passengers and cargo to your transport services.{}  Cost: {CURRENCY}
+STR_204E_INITIATE_A_MEDIUM_LOCAL                                :{WHITE}{STRING}{}{YELLOW} Initiate a medium local advertising campaign, to attract more passengers and cargo to your transport services.{}  Cost: {CURRENCY}
+STR_204F_INITIATE_A_LARGE_LOCAL                                 :{WHITE}{STRING}{}{YELLOW} Initiate a large local advertising campaign, to attract more passengers and cargo to your transport services.{}  Cost: {CURRENCY}
+STR_2050_FUND_THE_RECONSTRUCTION                                :{WHITE}{STRING}{}{YELLOW} Fund the reconstruction of the urban road network. Causes considerable disruption to road traffic for up to 6 months.{}  Cost: {CURRENCY}
+STR_2051_BUILD_A_STATUE_IN_HONOR                                :{WHITE}{STRING}{}{YELLOW} Build a statue in honor of your company.{} Cost: {CURRENCY}
+STR_2052_FUND_THE_CONSTRUCTION_OF                               :{WHITE}{STRING}{}{YELLOW} Fund the construction of new commercial buildings in the town.{}  Cost: {CURRENCY}
+STR_2053_BUY_1_YEAR_S_EXCLUSIVE                                 :{WHITE}{STRING}{}{YELLOW} Buy 1 year's exclusive transport rights in town. Town authority will only allow passengers and cargo to use your company's stations.{} Cost: {CURRENCY}
+STR_TOWN_BRIBE_THE_LOCAL_AUTHORITY_DESC                         :{WHITE}{STRING}{}{YELLOW} Bribe the local authority to increase your rating, at the risk of a severe penalty if caught.{}  Cost: {CURRENCY}
+STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING                       :{BIGFONT}{BLACK}Traffic chaos in {TOWN}!{}{}Road rebuilding program funded by {COMPANY} brings 6 months of misery to motorists!
+STR_2056                                                        :{TINYFONT}{WHITE}{TOWN}
+STR_2057                                                        :{ORANGE}{TOWN}{BLACK} ({COMMA})
+STR_2058_UNDER_CONSTRUCTION                                     :{STRING} (under construction)
+STR_2059_IGLOO                                                  :Igloo
+STR_205A_TEPEES                                                 :Tepees
+STR_205B_TEAPOT_HOUSE                                           :Teapot-House
+STR_205C_PIGGY_BANK                                             :Piggy-Bank
+
+STR_INDUSTRY                                                    :{INDUSTRY}
+STR_TOWN                                                        :{TOWN}
+STR_INDUSTRY_FORMAT                                             :{TOWN} {STRING}
+STR_STATION                                                     :{STATION}
+
+##id 0x2800
+STR_LANDSCAPING                                                 :Landscaping
+STR_2800_PLANT_TREES                                            :Plant trees
+STR_2801_PLACE_SIGN                                             :Place sign
+STR_2802_TREES                                                  :{WHITE}Trees
+STR_2803_TREE_ALREADY_HERE                                      :{WHITE}...tree already here
+STR_2804_SITE_UNSUITABLE                                        :{WHITE}...site unsuitable
+STR_2805_CAN_T_PLANT_TREE_HERE                                  :{WHITE}Can't plant tree here...
+STR_2806                                                        :{WHITE}{SIGN}
+STR_2808_TOO_MANY_SIGNS                                         :{WHITE}...too many signs
+STR_2809_CAN_T_PLACE_SIGN_HERE                                  :{WHITE}Can't place sign here...
+STR_280A_SIGN                                                   :Sign
+STR_280B_EDIT_SIGN_TEXT                                         :{WHITE}Edit sign text
+STR_280C_CAN_T_CHANGE_SIGN_NAME                                 :{WHITE}Can't change sign name...
+STR_280D_SELECT_TREE_TYPE_TO_PLANT                              :{BLACK}Select tree type to plant
+STR_280E_TREES                                                  :Trees
+STR_280F_RAINFOREST                                             :Rainforest
+STR_2810_CACTUS_PLANTS                                          :Cactuses
+
+##id 0x3000
+STR_3000_RAIL_STATION_SELECTION                                 :{WHITE}Rail Station Selection
+STR_3001_AIRPORT_SELECTION                                      :{WHITE}Airport Selection
+STR_3002_ORIENTATION                                            :{BLACK}Orientation
+STR_3003_NUMBER_OF_TRACKS                                       :{BLACK}Number of tracks
+STR_3004_PLATFORM_LENGTH                                        :{BLACK}Platform length
+STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD                          :{WHITE}Too close to another railroad station
+STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING                         :{WHITE}Adjoins more than one existing station/loading area
+STR_3007_TOO_MANY_STATIONS_LOADING                              :{WHITE}Too many stations/loading areas in this town
+STR_3008_TOO_MANY_STATIONS_LOADING                              :{WHITE}Too many stations/loading areas
+STR_3008A_TOO_MANY_BUS_STOPS                                    :{WHITE}Too many bus stops
+STR_3008B_TOO_MANY_TRUCK_STOPS                                  :{WHITE}Too many truck stations
+STR_3009_TOO_CLOSE_TO_ANOTHER_STATION                           :{WHITE}Too close to another station/loading area
+STR_300A_0                                                      :{WHITE}{STATION} {STATIONFEATURES}
+STR_300B_MUST_DEMOLISH_RAILROAD                                 :{WHITE}Must demolish railroad station first
+STR_300D_TOO_CLOSE_TO_ANOTHER_AIRPORT                           :{WHITE}Too close to another airport
+STR_300E_MUST_DEMOLISH_AIRPORT_FIRST                            :{WHITE}Must demolish airport first
+
+STR_3030_RENAME_STATION_LOADING                                 :Rename station/loading area
+STR_3031_CAN_T_RENAME_STATION                                   :{WHITE}Can't rename station...
+STR_3032_RATINGS                                                :{BLACK}Ratings
+STR_3033_ACCEPTS                                                :{BLACK}Accepts
+STR_3034_LOCAL_RATING_OF_TRANSPORT                              :{BLACK}Local rating of transport service:
+
+############ range for rating starts
+STR_3035_APPALLING                                              :Appalling
+STR_3036_VERY_POOR                                              :Very Poor
+STR_3037_POOR                                                   :Poor
+STR_3038_MEDIOCRE                                               :Mediocre
+STR_3039_GOOD                                                   :Good
+STR_303A_VERY_GOOD                                              :Very Good
+STR_303B_EXCELLENT                                              :Excellent
+STR_303C_OUTSTANDING                                            :Outstanding
+############ range for rating ends
+
+STR_303D                                                        :{WHITE}{STRING}: {YELLOW}{STRING} ({COMMA}%)
+STR_303E_NO_LONGER_ACCEPTS                                      :{WHITE}{STATION} no longer accepts {STRING}
+STR_303F_NO_LONGER_ACCEPTS_OR                                   :{WHITE}{STATION} no longer accepts {STRING} or {STRING}
+STR_3040_NOW_ACCEPTS                                            :{WHITE}{STATION} now accepts {STRING}
+STR_3041_NOW_ACCEPTS_AND                                        :{WHITE}{STATION} now accepts {STRING} and {STRING}
+STR_3042_BUS_STATION_ORIENTATION                                :{WHITE}Bus Station Orientation
+STR_3043_TRUCK_STATION_ORIENT                                   :{WHITE}Truck Station Orient.
+STR_3042_PASSENGER_TRAM_STATION_ORIENTATION                     :{WHITE}Passenger Tram Orientation
+STR_3043_CARGO_TRAM_STATION_ORIENT                              :{WHITE}Freight Tram Orientation
+STR_3046_MUST_DEMOLISH_BUS_STATION                              :{WHITE}Must demolish bus station first
+STR_3047_MUST_DEMOLISH_TRUCK_STATION                            :{WHITE}Must demolish truck station first
+STR_3046_MUST_DEMOLISH_PASSENGER_TRAM_STATION                   :{WHITE}Must demolish passenger tram station first
+STR_3047_MUST_DEMOLISH_CARGO_TRAM_STATION                       :{WHITE}Must demolish freight tram station first
+STR_3048_STATIONS                                               :{WHITE}{COMPANY} - {COMMA} Station{P "" s}
+STR_3049_0                                                      :{YELLOW}{STATION} {STATIONFEATURES}
+STR_304A_NONE                                                   :{YELLOW}- None -
+STR_304B_SITE_UNSUITABLE                                        :{WHITE}...site unsuitable
+STR_304C_TOO_CLOSE_TO_ANOTHER_DOCK                              :{WHITE}Too close to another dock
+STR_304D_MUST_DEMOLISH_DOCK_FIRST                               :{WHITE}Must demolish dock first
+STR_304E_SELECT_RAILROAD_STATION                                :{BLACK}Select railroad station orientation
+STR_304F_SELECT_NUMBER_OF_PLATFORMS                             :{BLACK}Select number of platforms for railroad station
+STR_3050_SELECT_LENGTH_OF_RAILROAD                              :{BLACK}Select length of railroad station
+STR_3051_SELECT_BUS_STATION_ORIENTATION                         :{BLACK}Select bus station orientation
+STR_3052_SELECT_TRUCK_LOADING_BAY                               :{BLACK}Select truck loading bay orientation
+STR_3051_SELECT_PASSENGER_TRAM_STATION_ORIENTATION              :{BLACK}Select passenger tram station orientation
+STR_3052_SELECT_CARGO_TRAM_STATION_ORIENTATION                  :{BLACK}Select freight tram station orientation
+STR_3053_CENTER_MAIN_VIEW_ON_STATION                            :{BLACK}Center main view on station location
+STR_3054_SHOW_STATION_RATINGS                                   :{BLACK}Show station ratings
+STR_3055_CHANGE_NAME_OF_STATION                                 :{BLACK}Change name of station
+STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO                            :{BLACK}Show list of accepted cargo
+STR_3057_STATION_NAMES_CLICK_ON                                 :{BLACK}Station names - click on name to center main view on station
+STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT                            :{BLACK}Select size/type of airport
+STR_305C_0                                                      :{STATION} {STATIONFEATURES}
+STR_STATION_SIGN_TINY                                           :{TINYFONT}{STATION}
+STR_305E_RAILROAD_STATION                                       :Railroad station
+STR_305F_AIRCRAFT_HANGAR                                        :Aircraft hangar
+STR_3060_AIRPORT                                                :Airport
+STR_3061_TRUCK_LOADING_AREA                                     :Truck loading area
+STR_3062_BUS_STATION                                            :Bus station
+STR_3063_SHIP_DOCK                                              :Ship dock
+STR_3064_HIGHLIGHT_COVERAGE_AREA                                :{BLACK}Highlight coverage area of proposed site
+STR_3065_DON_T_HIGHLIGHT_COVERAGE                               :{BLACK}Don't highlight coverage area of proposed site
+STR_3066_COVERAGE_AREA_HIGHLIGHT                                :{BLACK}Coverage area highlight
+STR_3068_DOCK                                                   :{WHITE}Dock
+STR_3069_BUOY                                                   :Buoy
+STR_306A_BUOY_IN_THE_WAY                                        :{WHITE}...buoy in the way
+STR_306C_STATION_TOO_SPREAD_OUT                                 :{WHITE}...station too spread out
+STR_306D_NONUNIFORM_STATIONS_DISALLOWED                         :{WHITE}...nonuniform stations disabled
+STR_USE_CTRL_TO_SELECT_MORE                                     :{BLACK}Hold down CTRL to select more than one item
+
+STR_UNDEFINED                                                   :(undefined string)
+STR_STAT_CLASS_DFLT                                             :Default station
+STR_STAT_CLASS_WAYP                                             :Waypoints
+
+##id 0x3800
+STR_3800_SHIP_DEPOT_ORIENTATION                                 :{WHITE}Ship Depot Orientation
+STR_3801_MUST_BE_BUILT_ON_WATER                                 :{WHITE}...must be built on water
+STR_3802_CAN_T_BUILD_SHIP_DEPOT                                 :{WHITE}Can't build ship depot here...
+STR_3803_SELECT_SHIP_DEPOT_ORIENTATION                          :{BLACK}Select ship depot orientation
+STR_3804_WATER                                                  :Water
+STR_3805_COAST_OR_RIVERBANK                                     :Coast or riverbank
+STR_3806_SHIP_DEPOT                                             :Ship depot
+STR_3807_CAN_T_BUILD_ON_WATER                                   :{WHITE}...Can't build on water
+STR_MUST_DEMOLISH_CANAL_FIRST                                   :{WHITE}Must demolish canal first
+
+##id 0x4000
+STR_4000_SAVE_GAME                                              :{WHITE}Save Game
+STR_4001_LOAD_GAME                                              :{WHITE}Load Game
+STR_4002_SAVE                                                   :{BLACK}Save
+STR_4003_DELETE                                                 :{BLACK}Delete
+STR_4004                                                        :{COMPANY}, {DATE_LONG}
+STR_4005_BYTES_FREE                                             :{BLACK}{COMMA} megabyte{P "" s} free
+STR_4006_UNABLE_TO_READ_DRIVE                                   :{BLACK}Unable to read drive
+STR_4007_GAME_SAVE_FAILED                                       :{WHITE}Game Save Failed{}{STRING}
+STR_4008_UNABLE_TO_DELETE_FILE                                  :{WHITE}Unable to delete file
+STR_4009_GAME_LOAD_FAILED                                       :{WHITE}Game Load Failed{}{STRING}
+STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR                   :Internal error: {STRING}
+STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME                         :Broken savegame - {STRING}
+STR_GAME_SAVELOAD_ERROR_TOO_NEW_SAVEGAME                        :Savegame is made with newer version
+STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE                       :File not readable
+STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE                      :File not writable
+STR_400A_LIST_OF_DRIVES_DIRECTORIES                             :{BLACK}List of drives, directories and saved-game files
+STR_400B_CURRENTLY_SELECTED_NAME                                :{BLACK}Currently selected name for saved-game
+STR_400C_DELETE_THE_CURRENTLY_SELECTED                          :{BLACK}Delete the currently selected saved-game
+STR_400D_SAVE_THE_CURRENT_GAME_USING                            :{BLACK}Save the current game, using the selected name
+STR_400E_SELECT_NEW_GAME_TYPE                                   :{WHITE}Select New Game Type
+STR_400F_SELECT_SCENARIO_GREEN_PRE                              :{BLACK}Select scenario (green), pre-set game (blue), or random new game
+STR_4010_GENERATE_RANDOM_NEW_GAME                               :Generate random new game
+STR_4011_LOAD_HEIGHTMAP                                         :{WHITE}Load Heightmap
+
+##id 0x4800
+STR_4800_IN_THE_WAY                                             :{WHITE}{STRING} in the way
+STR_4801                                                        :{WHITE}{INDUSTRY}
+STR_4802_COAL_MINE                                              :Coal Mine
+STR_4803_POWER_STATION                                          :Power Station
+STR_4804_SAWMILL                                                :Sawmill
+STR_4805_FOREST                                                 :Forest
+STR_4806_OIL_REFINERY                                           :Oil Refinery
+STR_4807_OIL_RIG                                                :Oil Rig
+STR_4808_FACTORY                                                :Factory
+STR_4809_PRINTING_WORKS                                         :Printing Works
+STR_480A_STEEL_MILL                                             :Steel Mill
+STR_480B_FARM                                                   :Farm
+STR_480C_COPPER_ORE_MINE                                        :Copper Ore Mine
+STR_480D_OIL_WELLS                                              :Oil Wells
+STR_480E_BANK                                                   :Bank
+STR_480F_FOOD_PROCESSING_PLANT                                  :Food Processing Plant
+STR_4810_PAPER_MILL                                             :Paper Mill
+STR_4811_GOLD_MINE                                              :Gold Mine
+STR_4812_BANK                                                   :Bank
+STR_4813_DIAMOND_MINE                                           :Diamond Mine
+STR_4814_IRON_ORE_MINE                                          :Iron Ore Mine
+STR_4815_FRUIT_PLANTATION                                       :Fruit Plantation
+STR_4816_RUBBER_PLANTATION                                      :Rubber Plantation
+STR_4817_WATER_SUPPLY                                           :Water Supply
+STR_4818_WATER_TOWER                                            :Water Tower
+STR_4819_FACTORY                                                :Factory
+STR_481A_FARM                                                   :Farm
+STR_481B_LUMBER_MILL                                            :Lumber Mill
+STR_481C_COTTON_CANDY_FOREST                                    :Cotton Candy Forest
+STR_481D_CANDY_FACTORY                                          :Candy Factory
+STR_481E_BATTERY_FARM                                           :Battery Farm
+STR_481F_COLA_WELLS                                             :Cola Wells
+STR_4820_TOY_SHOP                                               :Toy Shop
+STR_4821_TOY_FACTORY                                            :Toy Factory
+STR_4822_PLASTIC_FOUNTAINS                                      :Plastic Fountains
+STR_4823_FIZZY_DRINK_FACTORY                                    :Fizzy Drink Factory
+STR_4824_BUBBLE_GENERATOR                                       :Bubble Generator
+STR_4825_TOFFEE_QUARRY                                          :Toffee Quarry
+STR_4826_SUGAR_MINE                                             :Sugar Mine
+
+############ range for requires starts
+STR_4827_REQUIRES                                               :{BLACK}Requires: {YELLOW}{STRING}
+STR_4828_REQUIRES                                               :{BLACK}Requires: {YELLOW}{STRING}, {STRING}
+STR_4829_REQUIRES                                               :{BLACK}Requires: {YELLOW}{STRING}, {STRING}, {STRING}
+############ range for requires ends
+
+############ range for produces starts
+STR_INDUSTRY_WINDOW_WAITING_FOR_PROCESSING                      :{BLACK}Cargo waiting to be processed:
+STR_INDUSTRY_WINDOW_WAITING_STOCKPILE_CARGO                     :{YELLOW}{CARGO}{BLACK}
+STR_4827_PRODUCES                                               :{BLACK}Produces: {YELLOW}{STRING}
+STR_4828_PRODUCES                                               :{BLACK}Produces: {YELLOW}{STRING}, {STRING}
+############ range for produces ends
+
+STR_482A_PRODUCTION_LAST_MONTH                                  :{BLACK}Production last month:
+STR_482B_TRANSPORTED                                            :{YELLOW}{CARGO}{BLACK} ({COMMA}% transported)
+STR_482C_CENTER_THE_MAIN_VIEW_ON                                :{BLACK}Center the main view on industry location
+STR_482D_NEW_UNDER_CONSTRUCTION                                 :{BLACK}{BIGFONT}New {STRING} under construction near {TOWN}!
+STR_482E_NEW_BEING_PLANTED_NEAR                                 :{BLACK}{BIGFONT}New {STRING} being planted near {TOWN}!
+STR_482F_COST                                                   :{BLACK}Cost: {YELLOW}{CURRENCY}
+STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY                          :{WHITE}Can't construct this industry type here...
+STR_4831_FOREST_CAN_ONLY_BE_PLANTED                             :{WHITE}...forest can only be planted above snow-line
+STR_4832_ANNOUNCES_IMMINENT_CLOSURE                             :{BLACK}{BIGFONT}{STRING} announces imminent closure!
+STR_4833_SUPPLY_PROBLEMS_CAUSE_TO                               :{BLACK}{BIGFONT}Supply problems cause {STRING} to announce imminent closure!
+STR_4834_LACK_OF_NEARBY_TREES_CAUSES                            :{BLACK}{BIGFONT}Lack of nearby trees causes {STRING} to announce imminent closure!
+STR_4835_INCREASES_PRODUCTION                                   :{BLACK}{BIGFONT}{INDUSTRY} increases production!
+STR_4836_NEW_COAL_SEAM_FOUND_AT                                 :{BLACK}{BIGFONT}New coal seam found at {INDUSTRY}!{}Production is expected to double!
+STR_4837_NEW_OIL_RESERVES_FOUND                                 :{BLACK}{BIGFONT}New oil reserves found at {INDUSTRY}!{}Production is expected to double!
+STR_4838_IMPROVED_FARMING_METHODS                               :{BLACK}{BIGFONT}Improved farming methods at {INDUSTRY} are expected to double production!
+STR_4839_PRODUCTION_DOWN_BY_50                                  :{BLACK}{BIGFONT}{INDUSTRY} production down by 50%
+STR_483A_INSECT_INFESTATION_CAUSES                              :{BLACK}{BIGFONT}Insect infestation causes havoc at {INDUSTRY}!{}Production down by 50%
+STR_483B_CAN_ONLY_BE_POSITIONED                                 :{WHITE}...can only be positioned near edges of map
+STR_INDUSTRY_PROD_GOUP                                          :{BLACK}{BIGFONT}{STRING} production at {INDUSTRY} increases by {COMMA}%!
+STR_INDUSTRY_PROD_GODOWN                                        :{BLACK}{BIGFONT}{STRING} production at {INDUSTRY} goes down by {COMMA}%!
+
+##id 0x5000
+STR_5000_TRAIN_IN_TUNNEL                                        :{WHITE}Train in tunnel
+STR_5001_ROAD_VEHICLE_IN_TUNNEL                                 :{WHITE}Road vehicle in tunnel
+STR_5003_ANOTHER_TUNNEL_IN_THE_WAY                              :{WHITE}Another tunnel in the way
+STR_5005_UNABLE_TO_EXCAVATE_LAND                                :{WHITE}Unable to excavate land for other end of tunnel
+STR_5006_MUST_DEMOLISH_TUNNEL_FIRST                             :{WHITE}Must demolish tunnel first
+STR_5007_MUST_DEMOLISH_BRIDGE_FIRST                             :{WHITE}Must demolish bridge first
+STR_5008_CANNOT_START_AND_END_ON                                :{WHITE}Cannot start and end on same position
+STR_BRIDGEHEADS_NOT_SAME_HEIGHT                                 :{WHITE}Bridge heads not at the same level
+STR_BRIDGE_TOO_LOW_FOR_TERRAIN                                  :{WHITE}Bridge is too low for the terrain
+STR_500A_START_AND_END_MUST_BE_IN                               :{WHITE}Start and end must be in line
+STR_500B_SITE_UNSUITABLE_FOR_TUNNEL                             :{WHITE}Site unsuitable for tunnel entrance
+STR_500D                                                        :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY}
+STR_500E_SUSPENSION_STEEL                                       :Suspension, Steel
+STR_500F_GIRDER_STEEL                                           :Girder, Steel
+STR_5010_CANTILEVER_STEEL                                       :Cantilever, Steel
+STR_5011_SUSPENSION_CONCRETE                                    :Suspension, Concrete
+STR_5012_WOODEN                                                 :Wooden
+STR_5013_CONCRETE                                               :Concrete
+STR_5014_TUBULAR_STEEL                                          :Tubular, Steel
+STR_BRIDGE_TUBULAR_SILICON                                      :Tubular, Silicon
+STR_5015_CAN_T_BUILD_BRIDGE_HERE                                :{WHITE}Can't build bridge here...
+STR_5016_CAN_T_BUILD_TUNNEL_HERE                                :{WHITE}Can't build tunnel here...
+STR_5017_RAILROAD_TUNNEL                                        :Railroad tunnel
+STR_5018_ROAD_TUNNEL                                            :Road tunnel
+STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE                           :Steel suspension rail bridge
+STR_501C_STEEL_GIRDER_RAIL_BRIDGE                               :Steel girder rail bridge
+STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE                           :Steel cantilever rail bridge
+STR_501E_REINFORCED_CONCRETE_SUSPENSION                         :Reinforced concrete suspension rail bridge
+STR_501F_WOODEN_RAIL_BRIDGE                                     :Wooden rail bridge
+STR_5020_CONCRETE_RAIL_BRIDGE                                   :Concrete rail bridge
+STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE                           :Steel suspension road bridge
+STR_5022_STEEL_GIRDER_ROAD_BRIDGE                               :Steel girder road bridge
+STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE                           :Steel cantilever road bridge
+STR_5024_REINFORCED_CONCRETE_SUSPENSION                         :Reinforced concrete suspension road bridge
+STR_5025_WOODEN_ROAD_BRIDGE                                     :Wooden road bridge
+STR_5026_CONCRETE_ROAD_BRIDGE                                   :Concrete road bridge
+STR_5027_TUBULAR_RAIL_BRIDGE                                    :Tubular rail bridge
+STR_5028_TUBULAR_ROAD_BRIDGE                                    :Tubular road bridge
+
+##id 0x5800
+STR_5800_OBJECT_IN_THE_WAY                                      :{WHITE}Object in the way
+STR_5801_TRANSMITTER                                            :Transmitter
+STR_5802_LIGHTHOUSE                                             :Lighthouse
+STR_5803_COMPANY_HEADQUARTERS                                   :Company Headquarters
+STR_5804_COMPANY_HEADQUARTERS_IN                                :{WHITE}...company headquarters in the way
+STR_5805_COMPANY_OWNED_LAND                                     :Company-owned land
+STR_5806_CAN_T_PURCHASE_THIS_LAND                               :{WHITE}Can't purchase this land area...
+STR_5807_YOU_ALREADY_OWN_IT                                     :{WHITE}...you already own it!
+
+
+############ WARNING, using range 0x6000 for strings that are stored in the savegame
+############ These strings may never get a new id, or savegames will break!
+##id 0x6000
+STR_SV_EMPTY                                                    :
+STR_SV_UNNAMED                                                  :Unnamed
+STR_SV_TRAIN_NAME                                               :Train {COMMA}
+STR_SV_ROADVEH_NAME                                             :Road Vehicle {COMMA}
+STR_SV_SHIP_NAME                                                :Ship {COMMA}
+STR_SV_AIRCRAFT_NAME                                            :Aircraft {COMMA}
+
+STR_SV_STNAME                                                   :{STRING}
+STR_SV_STNAME_NORTH                                             :{STRING} North
+STR_SV_STNAME_SOUTH                                             :{STRING} South
+STR_SV_STNAME_EAST                                              :{STRING} East
+STR_SV_STNAME_WEST                                              :{STRING} West
+STR_SV_STNAME_CENTRAL                                           :{STRING} Central
+STR_SV_STNAME_TRANSFER                                          :{STRING} Transfer
+STR_SV_STNAME_HALT                                              :{STRING} Halt
+STR_SV_STNAME_VALLEY                                            :{STRING} Valley
+STR_SV_STNAME_HEIGHTS                                           :{STRING} Heights
+STR_SV_STNAME_WOODS                                             :{STRING} Woods
+STR_SV_STNAME_LAKESIDE                                          :{STRING} Lakeside
+STR_SV_STNAME_EXCHANGE                                          :{STRING} Exchange
+STR_SV_STNAME_AIRPORT                                           :{STRING} Airport
+STR_SV_STNAME_OILFIELD                                          :{STRING} Oilfield
+STR_SV_STNAME_MINES                                             :{STRING} Mines
+STR_SV_STNAME_DOCKS                                             :{STRING} Docks
+STR_SV_STNAME_BUOY_1                                            :{STRING} Buoy 1
+STR_SV_STNAME_BUOY_2                                            :{STRING} Buoy 2
+STR_SV_STNAME_BUOY_3                                            :{STRING} Buoy 3
+STR_SV_STNAME_BUOY_4                                            :{STRING} Buoy 4
+STR_SV_STNAME_BUOY_5                                            :{STRING} Buoy 5
+STR_SV_STNAME_BUOY_6                                            :{STRING} Buoy 6
+STR_SV_STNAME_BUOY_7                                            :{STRING} Buoy 7
+STR_SV_STNAME_BUOY_8                                            :{STRING} Buoy 8
+STR_SV_STNAME_BUOY_9                                            :{STRING} Buoy 9
+STR_SV_STNAME_ANNEXE                                            :{STRING} Annexe
+STR_SV_STNAME_SIDINGS                                           :{STRING} Sidings
+STR_SV_STNAME_BRANCH                                            :{STRING} Branch
+STR_SV_STNAME_UPPER                                             :Upper {STRING}
+STR_SV_STNAME_LOWER                                             :Lower {STRING}
+STR_SV_STNAME_HELIPORT                                          :{STRING} Heliport
+STR_SV_STNAME_FOREST                                            :{STRING} Forest
+STR_SV_STNAME_FALLBACK                                          :{STRING} Station #{NUM}
+
+############ end of savegame specific region!
+
+##id 0x6800
+STR_6800_DIFFICULTY_LEVEL                                       :{WHITE}Difficulty Level
+STR_OPTIONS_SAVE_CHANGES                                        :{BLACK}Save
+
+############ range for difficulty levels starts
+STR_6801_EASY                                                   :{BLACK}Easy
+STR_6802_MEDIUM                                                 :{BLACK}Medium
+STR_6803_HARD                                                   :{BLACK}Hard
+STR_6804_CUSTOM                                                 :{BLACK}Custom
+############ range for difficulty levels ends
+
+############ range for difficulty settings starts
+STR_6805_MAXIMUM_NO_COMPETITORS                                 :{LTBLUE}Maximum no. competitors: {ORANGE}{COMMA}
+STR_6806_COMPETITOR_START_TIME                                  :{LTBLUE}Competitor start time: {ORANGE}{STRING}
+STR_6807_NO_OF_TOWNS                                            :{LTBLUE}No. of towns: {ORANGE}{STRING}
+STR_6808_NO_OF_INDUSTRIES                                       :{LTBLUE}No. of industries: {ORANGE}{STRING}
+STR_6809_MAXIMUM_INITIAL_LOAN_000                               :{LTBLUE}Maximum initial loan: {ORANGE}{CURRENCY}
+STR_680A_INITIAL_INTEREST_RATE                                  :{LTBLUE}Initial interest rate: {ORANGE}{COMMA}%
+STR_680B_VEHICLE_RUNNING_COSTS                                  :{LTBLUE}Vehicle running costs: {ORANGE}{STRING}
+STR_680C_CONSTRUCTION_SPEED_OF_COMPETITOR                       :{LTBLUE}Construction speed of competitors: {ORANGE}{STRING}
+STR_680D_INTELLIGENCE_OF_COMPETITORS                            :{LTBLUE}Intelligence of competitors: {ORANGE}{STRING}
+STR_680E_VEHICLE_BREAKDOWNS                                     :{LTBLUE}Vehicle breakdowns: {ORANGE}{STRING}
+STR_680F_SUBSIDY_MULTIPLIER                                     :{LTBLUE}Subsidy multiplier: {ORANGE}{STRING}
+STR_6810_COST_OF_CONSTRUCTION                                   :{LTBLUE}Cost of construction: {ORANGE}{STRING}
+STR_6811_TERRAIN_TYPE                                           :{LTBLUE}Terrain type: {ORANGE}{STRING}
+STR_6812_QUANTITY_OF_SEA_LAKES                                  :{LTBLUE}Quantity of sea/lakes: {ORANGE}{STRING}
+STR_6813_ECONOMY                                                :{LTBLUE}Economy: {ORANGE}{STRING}
+STR_6814_TRAIN_REVERSING                                        :{LTBLUE}Train reversing: {ORANGE}{STRING}
+STR_6815_DISASTERS                                              :{LTBLUE}Disasters: {ORANGE}{STRING}
+STR_16816_CITY_APPROVAL                                         :{LTBLUE}City council's attitude towards area restructuring: {ORANGE}{STRING}
+############ range for difficulty settings ends
+
+STR_26816_NONE                                                  :None
+STR_NUM_VERY_LOW                                                :Very low
+STR_6816_LOW                                                    :Low
+STR_6817_NORMAL                                                 :Normal
+STR_6818_HIGH                                                   :High
+STR_6819                                                        :{BLACK}{SMALLLEFTARROW}
+STR_681A                                                        :{BLACK}{SMALLRIGHTARROW}
+STR_681B_VERY_SLOW                                              :Very Slow
+STR_681C_SLOW                                                   :Slow
+STR_681D_MEDIUM                                                 :Medium
+STR_681E_FAST                                                   :Fast
+STR_681F_VERY_FAST                                              :Very Fast
+STR_VERY_LOW                                                    :Very Low
+STR_6820_LOW                                                    :Low
+STR_6821_MEDIUM                                                 :Medium
+STR_6822_HIGH                                                   :High
+STR_6823_NONE                                                   :None
+STR_6824_REDUCED                                                :Reduced
+STR_6825_NORMAL                                                 :Normal
+STR_6826_X1_5                                                   :x1.5
+STR_6827_X2                                                     :x2
+STR_6828_X3                                                     :x3
+STR_6829_X4                                                     :x4
+STR_682A_VERY_FLAT                                              :Very Flat
+STR_682B_FLAT                                                   :Flat
+STR_682C_HILLY                                                  :Hilly
+STR_682D_MOUNTAINOUS                                            :Mountainous
+STR_682E_STEADY                                                 :Steady
+STR_682F_FLUCTUATING                                            :Fluctuating
+STR_6830_IMMEDIATE                                              :Immediate
+STR_6831_3_MONTHS_AFTER_PLAYER                                  :3 months after player
+STR_6832_6_MONTHS_AFTER_PLAYER                                  :6 months after player
+STR_6833_9_MONTHS_AFTER_PLAYER                                  :9 months after player
+STR_6834_AT_END_OF_LINE_AND_AT_STATIONS                         :At end of line, and at stations
+STR_6835_AT_END_OF_LINE_ONLY                                    :At end of line only
+STR_6836_OFF                                                    :Off
+STR_6837_ON                                                     :On
+STR_6838_SHOW_HI_SCORE_CHART                                    :{BLACK}Show hi-score chart
+STR_6839_PERMISSIVE                                             :Permissive
+STR_683A_TOLERANT                                               :Tolerant
+STR_683B_HOSTILE                                                :Hostile
+
+##id 0x7000
+STR_7000                                                        :
+STR_7001                                                        :{WHITE}{COMPANY} {BLACK}{COMPANYNUM}
+STR_7002_PLAYER                                                 :(Player {COMMA})
+STR_7004_NEW_FACE                                               :{BLACK}New Face
+STR_7005_COLOR_SCHEME                                           :{BLACK}Color Scheme
+STR_7006_COLOR_SCHEME                                           :{GOLD}Color Scheme:
+STR_7007_NEW_COLOR_SCHEME                                       :{WHITE}New Color Scheme
+STR_7008_COMPANY_NAME                                           :{BLACK}Company Name
+STR_7009_PRESIDENT_NAME                                         :{BLACK}President Name
+STR_700A_COMPANY_NAME                                           :Company Name
+STR_700B_PRESIDENT_S_NAME                                       :President's Name
+STR_700C_CAN_T_CHANGE_COMPANY_NAME                              :{WHITE}Can't change company name...
+STR_700D_CAN_T_CHANGE_PRESIDENT                                 :{WHITE}Can't change president's name...
+STR_700E_FINANCES                                               :{WHITE}{COMPANY} Finances {BLACK}{COMPANYNUM}
+STR_700F_EXPENDITURE_INCOME                                     :{WHITE}Expenditure/Income
+STR_7010                                                        :{WHITE}{NUM}
+STR_7011_CONSTRUCTION                                           :{GOLD}Construction
+STR_7012_NEW_VEHICLES                                           :{GOLD}New Vehicles
+STR_7013_TRAIN_RUNNING_COSTS                                    :{GOLD}Train Running Costs
+STR_7014_ROAD_VEH_RUNNING_COSTS                                 :{GOLD}Road Veh. Running Costs
+STR_7015_AIRCRAFT_RUNNING_COSTS                                 :{GOLD}Aircraft Running Costs
+STR_7016_SHIP_RUNNING_COSTS                                     :{GOLD}Ship Running Costs
+STR_7017_PROPERTY_MAINTENANCE                                   :{GOLD}Property Maintenance
+STR_7018_TRAIN_INCOME                                           :{GOLD}Train Income
+STR_7019_ROAD_VEHICLES_INCOME                                   :{GOLD}Road Vehicle Income
+STR_701A_AIRCRAFT_INCOME                                        :{GOLD}Aircraft Income
+STR_701B_SHIP_INCOME                                            :{GOLD}Ship Income
+STR_701C_LOAN_INTEREST                                          :{GOLD}Loan Interest
+STR_701D_OTHER                                                  :{GOLD}Other
+STR_701E                                                        :{BLACK}-{CURRENCY}
+STR_701F                                                        :{BLACK}+{CURRENCY}
+STR_7020_TOTAL                                                  :{WHITE}Total:
+STR_7021                                                        :{COMPANY} {COMPANYNUM}
+STR_7022_INCOME_GRAPH                                           :{WHITE}Income Graph
+STR_CURRCOMPACT                                                 :{CURRCOMPACT}
+STR_7024                                                        :{COMMA}
+STR_7025_OPERATING_PROFIT_GRAPH                                 :{WHITE}Operating Profit Graph
+STR_7026_BANK_BALANCE                                           :{WHITE}Bank Balance
+STR_7027_LOAN                                                   :{WHITE}Loan
+STR_MAX_LOAN                                                    :{WHITE}Max Loan:  {BLACK}{CURRENCY}
+STR_7028                                                        :{BLACK}{CURRENCY}
+STR_7029_BORROW                                                 :{BLACK}Borrow {SKIP}{SKIP}{CURRENCY}
+STR_702A_REPAY                                                  :{BLACK}Repay {SKIP}{SKIP}{CURRENCY}
+STR_702B_MAXIMUM_PERMITTED_LOAN                                 :{WHITE}...maximum permitted loan size is {CURRENCY}
+STR_702C_CAN_T_BORROW_ANY_MORE_MONEY                            :{WHITE}Can't borrow any more money...
+STR_702D_LOAN_ALREADY_REPAYED                                   :{WHITE}...no loan to repay
+STR_702E_REQUIRED                                               :{WHITE}...{CURRENCY} required
+STR_702F_CAN_T_REPAY_LOAN                                       :{WHITE}Can't repay loan...
+STR_INSUFFICIENT_FUNDS                                          :{WHITE}Can't give away money that is loaned from the bank...
+STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT                          :{BLACK}Select new face for president
+STR_7031_CHANGE_THE_COMPANY_VEHICLE                             :{BLACK}Change the company vehicle livery
+STR_7032_CHANGE_THE_PRESIDENT_S                                 :{BLACK}Change the president's name
+STR_7033_CHANGE_THE_COMPANY_NAME                                :{BLACK}Change the company name
+STR_7034_CLICK_ON_SELECTED_NEW_COLOR                            :{BLACK}Click on desired color scheme
+STR_7035_INCREASE_SIZE_OF_LOAN                                  :{BLACK}Increase size of loan
+STR_7036_REPAY_PART_OF_LOAN                                     :{BLACK}Repay part of loan
+STR_7037_PRESIDENT                                              :{WHITE}{PLAYERNAME}{}{GOLD}(President)
+STR_7038_INAUGURATED                                            :{GOLD}Inaugurated: {WHITE}{NUM}
+STR_7039_VEHICLES                                               :{GOLD}Vehicles:
+STR_TRAINS                                                      :{WHITE}{COMMA} train{P "" s}
+STR_ROAD_VEHICLES                                               :{WHITE}{COMMA} road vehicle{P "" s}
+STR_AIRCRAFT                                                    :{WHITE}{COMMA} aircraft
+STR_SHIPS                                                       :{WHITE}{COMMA} ship{P "" s}
+STR_7042_NONE                                                   :{WHITE}None
+STR_7043_FACE_SELECTION                                         :{WHITE}Face Selection
+STR_7044_MALE                                                   :{BLACK}Male
+STR_7045_FEMALE                                                 :{BLACK}Female
+STR_7046_NEW_FACE                                               :{BLACK}New Face
+STR_7047_CANCEL_NEW_FACE_SELECTION                              :{BLACK}Cancel new face selection
+STR_7048_ACCEPT_NEW_FACE_SELECTION                              :{BLACK}Accept new face selection
+STR_7049_SELECT_MALE_FACES                                      :{BLACK}Select male faces
+STR_704A_SELECT_FEMALE_FACES                                    :{BLACK}Select female faces
+STR_704B_GENERATE_RANDOM_NEW_FACE                               :{BLACK}Generate random new face
+STR_704C_KEY                                                    :{BLACK}Key
+STR_704D_SHOW_KEY_TO_GRAPHS                                     :{BLACK}Show key to graphs
+STR_704E_KEY_TO_COMPANY_GRAPHS                                  :{WHITE}Key to company graphs
+STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY                           :{BLACK}Click here to toggle company's entry on graph on/off
+STR_7050_UNITS_OF_CARGO_DELIVERED                               :{WHITE}Units of cargo delivered
+STR_7051_COMPANY_PERFORMANCE_RATINGS                            :{WHITE}Company performance ratings (maximum rating=1000)
+STR_7052_COMPANY_VALUES                                         :{WHITE}Company values
+STR_7053_COMPANY_LEAGUE_TABLE                                   :{WHITE}Company League Table
+STR_7054                                                        :{WHITE}{STRING}{SETX 45}{ORANGE}{COMPANY} {BLACK}{COMPANYNUM} '{STRING}'
+STR_7055                                                        :{YELLOW}{STRING}{SETX 45}{ORANGE}{COMPANY} {BLACK}{COMPANYNUM}  '{STRING}'
+STR_7056_TRANSPORT_COMPANY_IN_TROUBLE                           :{BLACK}{BIGFONT}Transport company in trouble!
+STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED                           :{BLACK}{BIGFONT}{COMPANY} will be sold off or declared bankrupt unless performance increases soon!
+STR_7058_PRESIDENT                                              :{BLACK}{PLAYERNAME}{}(President)
+STR_7059_TRANSPORT_COMPANY_MERGER                               :{BLACK}{BIGFONT}Transport company merger!
+STR_705A_HAS_BEEN_SOLD_TO_FOR                                   :{BLACK}{BIGFONT}{COMPANY} has been sold to {COMPANY} for {CURRENCY}!
+STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT                         :{WHITE}We are looking for a transport company to take-over our company{}{}Do you want to purchase {COMPANY} for {CURRENCY}?
+STR_705C_BANKRUPT                                               :{BLACK}{BIGFONT}Bankrupt!
+STR_705D_HAS_BEEN_CLOSED_DOWN_BY                                :{BLACK}{BIGFONT}{COMPANY} has been closed down by creditors and all assets sold off!
+STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED                         :{BLACK}{BIGFONT}New transport company launched!
+STR_705F_STARTS_CONSTRUCTION_NEAR                               :{BLACK}{BIGFONT}{COMPANY} starts construction near {TOWN}!
+STR_7060_CAN_T_BUY_COMPANY                                      :{WHITE}Can't buy company...
+STR_7061_CARGO_PAYMENT_RATES                                    :{WHITE}Cargo Payment Rates
+STR_7062_DAYS_IN_TRANSIT                                        :{BLACK}{TINYFONT}Days in transit
+STR_7063_PAYMENT_FOR_DELIVERING                                 :{BLACK}{TINYFONT}Payment for delivering 10 units (or 10,000 litres) of cargo a distance of 20 squares
+STR_7064_TOGGLE_GRAPH_FOR_CARGO                                 :{BLACK}Toggle graph for cargo type on/off
+STR_7065                                                        :{BLACK}{TINYFONT}{STRING}
+STR_7066_ENGINEER                                               :Engineer
+STR_7067_TRAFFIC_MANAGER                                        :Traffic Manager
+STR_7068_TRANSPORT_COORDINATOR                                  :Transport Coordinator
+STR_7069_ROUTE_SUPERVISOR                                       :Route Supervisor
+STR_706A_DIRECTOR                                               :Director
+STR_706B_CHIEF_EXECUTIVE                                        :Chief Executive
+STR_706C_CHAIRMAN                                               :Chairman
+STR_706D_PRESIDENT                                              :President
+STR_706E_TYCOON                                                 :Tycoon
+STR_706F_BUILD_HQ                                               :{BLACK}Build HQ
+STR_7070_BUILD_COMPANY_HEADQUARTERS                             :{BLACK}Build company headquarters / view company headquarters
+STR_RELOCATE_COMPANY_HEADQUARTERS                               :{BLACK}Rebuild company headquarters elsewhere for 1% cost of company value
+STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS                       :{WHITE}Can't build company headquarters...
+STR_7072_VIEW_HQ                                                :{BLACK}View HQ
+STR_RELOCATE_HQ                                                 :{BLACK}Relocate HQ
+STR_COMPANY_PASSWORD                                            :{BLACK}Password
+STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Password-protect your company to prevent unauthorized users from joining.
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Set company password
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Do not save the entered password
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Give the company the new password
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Company password
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Default company password
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Use this company password as default for new companies
+STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}World Recession!{}{}Financial experts fear worst as economy slumps!
+STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recession Over!{}{}Upturn in trade gives confidence to industries as economy strengthens!
+STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Toggle large/small window size
+STR_7076_COMPANY_VALUE                                          :{GOLD}Company value: {WHITE}{CURRENCY}
+STR_7077_BUY_25_SHARE_IN_COMPANY                                :{BLACK}Buy 25% share in company
+STR_7078_SELL_25_SHARE_IN_COMPANY                               :{BLACK}Sell 25% share in company
+STR_7079_BUY_25_SHARE_IN_THIS_COMPANY                           :{BLACK}Buy 25% share in this company
+STR_707A_SELL_25_SHARE_IN_THIS_COMPANY                          :{BLACK}Sell 25% share in this company
+STR_707B_CAN_T_BUY_25_SHARE_IN_THIS                             :{WHITE}Can't buy 25% share in this company...
+STR_707C_CAN_T_SELL_25_SHARE_IN                                 :{WHITE}Can't sell 25% share in this company...
+STR_707D_OWNED_BY                                               :{WHITE}({COMMA}% owned by {COMPANY})
+STR_707F_HAS_BEEN_TAKEN_OVER_BY                                 :{BLACK}{BIGFONT}{COMPANY} has been taken over by {COMPANY}!
+STR_7080_PROTECTED                                              :{WHITE}This company is not old enough to trade shares yet...
+
+STR_LIVERY_DEFAULT                                              :Standard Livery
+STR_LIVERY_STEAM                                                :Steam Engine
+STR_LIVERY_DIESEL                                               :Diesel Engine
+STR_LIVERY_ELECTRIC                                             :Electric Engine
+STR_LIVERY_MONORAIL                                             :Monorail Engine
+STR_LIVERY_MAGLEV                                               :Maglev Engine
+STR_LIVERY_DMU                                                  :DMU
+STR_LIVERY_EMU                                                  :EMU
+STR_LIVERY_PASSENGER_WAGON_STEAM                                :Passenger/Mail Car (Steam)
+STR_LIVERY_PASSENGER_WAGON_DIESEL                               :Passenger/Mail Car (Diesel)
+STR_LIVERY_PASSENGER_WAGON_ELECTRIC                             :Passenger/Mail Car (Electric)
+STR_LIVERY_FREIGHT_WAGON                                        :Freight Car
+STR_LIVERY_BUS                                                  :Bus
+STR_LIVERY_TRUCK                                                :Truck
+STR_LIVERY_PASSENGER_SHIP                                       :Passenger Ship
+STR_LIVERY_FREIGHT_SHIP                                         :Freight Ship
+STR_LIVERY_HELICOPTER                                           :Helicopter
+STR_LIVERY_SMALL_PLANE                                          :Small Airplane
+STR_LIVERY_LARGE_PLANE                                          :Large Airplane
+STR_LIVERY_PASSENGER_TRAM                                       :Passenger Tram
+STR_LIVERY_FREIGHT_TRAM                                         :Freight Tram
+
+STR_LIVERY_GENERAL_TIP                                          :{BLACK}Show general color schemes
+STR_LIVERY_TRAIN_TIP                                            :{BLACK}Show train color schemes
+STR_LIVERY_ROADVEH_TIP                                          :{BLACK}Show road vehicle color schemes
+STR_LIVERY_SHIP_TIP                                             :{BLACK}Show ship color schemes
+STR_LIVERY_AIRCRAFT_TIP                                         :{BLACK}Show aircraft color schemes
+STR_LIVERY_PRIMARY_TIP                                          :{BLACK}Choose the primary color for the selected scheme
+STR_LIVERY_SECONDARY_TIP                                        :{BLACK}Choose the secondary color for the selected scheme
+STR_LIVERY_PANEL_TIP                                            :{BLACK}Select a color scheme to change, or multiple schemes with CTRL+click. Click on the box to toggle use of the scheme
+
+##id 0x8000
+STR_8000_KIRBY_PAUL_TANK_STEAM                                  :Kirby Paul Tank (Steam)
+STR_8001_MJS_250_DIESEL                                         :MJS 250 (Diesel)
+STR_8002_PLODDYPHUT_CHOO_CHOO                                   :Ploddyphut Choo-Choo
+STR_8003_POWERNAUT_CHOO_CHOO                                    :Powernaut Choo-Choo
+STR_8004_MIGHTYMOVER_CHOO_CHOO                                  :Mightymover Choo-Choo
+STR_8005_PLODDYPHUT_DIESEL                                      :Ploddyphut Diesel
+STR_8006_POWERNAUT_DIESEL                                       :Powernaut Diesel
+STR_8007_WILLS_2_8_0_STEAM                                      :Wills 2-8-0 (Steam)
+STR_8008_CHANEY_JUBILEE_STEAM                                   :Chaney 'Jubilee' (Steam)
+STR_8009_GINZU_A4_STEAM                                         :Ginzu 'A4' (Steam)
+STR_800A_SH_8P_STEAM                                            :SH '8P' (Steam)
+STR_800B_MANLEY_MOREL_DMU_DIESEL                                :Manley-Morel DMU (Diesel)
+STR_800C_DASH_DIESEL                                            :'Dash' (Diesel)
+STR_800D_SH_HENDRY_25_DIESEL                                    :SH/Hendry '25' (Diesel)
+STR_800E_UU_37_DIESEL                                           :UU '37' (Diesel)
+STR_800F_FLOSS_47_DIESEL                                        :Floss '47' (Diesel)
+STR_8010_CS_4000_DIESEL                                         :CS 4000 (Diesel)
+STR_8011_CS_2400_DIESEL                                         :CS 2400 (Diesel)
+STR_8012_CENTENNIAL_DIESEL                                      :Centennial (Diesel)
+STR_8013_KELLING_3100_DIESEL                                    :Kelling 3100 (Diesel)
+STR_8014_TURNER_TURBO_DIESEL                                    :Turner Turbo (Diesel)
+STR_8015_MJS_1000_DIESEL                                        :MJS 1000 (Diesel)
+STR_8016_SH_125_DIESEL                                          :SH '125' (Diesel)
+STR_8017_SH_30_ELECTRIC                                         :SH '30' (Electric)
+STR_8018_SH_40_ELECTRIC                                         :SH '40' (Electric)
+STR_8019_T_I_M_ELECTRIC                                         :'T.I.M.' (Electric)
+STR_801A_ASIASTAR_ELECTRIC                                      :'AsiaStar' (Electric)
+STR_801B_PASSENGER_CAR                                          :Passenger Car
+STR_801C_MAIL_VAN                                               :Mail Van
+STR_801D_COAL_CAR                                               :Coal Car
+STR_801E_OIL_TANKER                                             :Oil Tanker
+STR_801F_LIVESTOCK_VAN                                          :Livestock Van
+STR_8020_GOODS_VAN                                              :Goods Van
+STR_8021_GRAIN_HOPPER                                           :Grain Hopper
+STR_8022_WOOD_TRUCK                                             :Wood Truck
+STR_8023_IRON_ORE_HOPPER                                        :Iron Ore Hopper
+STR_8024_STEEL_TRUCK                                            :Steel Truck
+STR_8025_ARMORED_VAN                                            :Armored Van
+STR_8026_FOOD_VAN                                               :Food Van
+STR_8027_PAPER_TRUCK                                            :Paper Truck
+STR_8028_COPPER_ORE_HOPPER                                      :Copper Ore Hopper
+STR_8029_WATER_TANKER                                           :Water Tanker
+STR_802A_FRUIT_TRUCK                                            :Fruit Truck
+STR_802B_RUBBER_TRUCK                                           :Rubber Truck
+STR_802C_SUGAR_TRUCK                                            :Sugar Truck
+STR_802D_COTTON_CANDY_HOPPER                                    :Cotton Candy Hopper
+STR_802E_TOFFEE_HOPPER                                          :Toffee Hopper
+STR_802F_BUBBLE_VAN                                             :Bubble Van
+STR_8030_COLA_TANKER                                            :Cola Tanker
+STR_8031_CANDY_VAN                                              :Candy Van
+STR_8032_TOY_VAN                                                :Toy Van
+STR_8033_BATTERY_TRUCK                                          :Battery Truck
+STR_8034_FIZZY_DRINK_TRUCK                                      :Fizzy Drink Truck
+STR_8035_PLASTIC_TRUCK                                          :Plastic Truck
+STR_8036_X2001_ELECTRIC                                         :'X2001' (Electric)
+STR_8037_MILLENNIUM_Z1_ELECTRIC                                 :'Millennium Z1' (Electric)
+STR_8038_WIZZOWOW_Z99                                           :Wizzowow Z99
+STR_8039_PASSENGER_CAR                                          :Passenger Car
+STR_803A_MAIL_VAN                                               :Mail Van
+STR_803B_COAL_CAR                                               :Coal Car
+STR_803C_OIL_TANKER                                             :Oil Tanker
+STR_803D_LIVESTOCK_VAN                                          :Livestock Van
+STR_803E_GOODS_VAN                                              :Goods Van
+STR_803F_GRAIN_HOPPER                                           :Grain Hopper
+STR_8040_WOOD_TRUCK                                             :Wood Truck
+STR_8041_IRON_ORE_HOPPER                                        :Iron Ore Hopper
+STR_8042_STEEL_TRUCK                                            :Steel Truck
+STR_8043_ARMORED_VAN                                            :Armored Van
+STR_8044_FOOD_VAN                                               :Food Van
+STR_8045_PAPER_TRUCK                                            :Paper Truck
+STR_8046_COPPER_ORE_HOPPER                                      :Copper Ore Hopper
+STR_8047_WATER_TANKER                                           :Water Tanker
+STR_8048_FRUIT_TRUCK                                            :Fruit Truck
+STR_8049_RUBBER_TRUCK                                           :Rubber Truck
+STR_804A_SUGAR_TRUCK                                            :Sugar Truck
+STR_804B_COTTON_CANDY_HOPPER                                    :Cotton Candy Hopper
+STR_804C_TOFFEE_HOPPER                                          :Toffee Hopper
+STR_804D_BUBBLE_VAN                                             :Bubble Van
+STR_804E_COLA_TANKER                                            :Cola Tanker
+STR_804F_CANDY_VAN                                              :Candy Van
+STR_8050_TOY_VAN                                                :Toy Van
+STR_8051_BATTERY_TRUCK                                          :Battery Truck
+STR_8052_FIZZY_DRINK_TRUCK                                      :Fizzy Drink Truck
+STR_8053_PLASTIC_TRUCK                                          :Plastic Truck
+STR_8054_LEV1_LEVIATHAN_ELECTRIC                                :Lev1 'Leviathan' (Electric)
+STR_8055_LEV2_CYCLOPS_ELECTRIC                                  :Lev2 'Cyclops' (Electric)
+STR_8056_LEV3_PEGASUS_ELECTRIC                                  :Lev3 'Pegasus' (Electric)
+STR_8057_LEV4_CHIMAERA_ELECTRIC                                 :Lev4 'Chimaera' (Electric)
+STR_8058_WIZZOWOW_ROCKETEER                                     :Wizzowow Rocketeer
+STR_8059_PASSENGER_CAR                                          :Passenger Car
+STR_805A_MAIL_VAN                                               :Mail Van
+STR_805B_COAL_CAR                                               :Coal Car
+STR_805C_OIL_TANKER                                             :Oil Tanker
+STR_805D_LIVESTOCK_VAN                                          :Livestock Van
+STR_805E_GOODS_VAN                                              :Goods Van
+STR_805F_GRAIN_HOPPER                                           :Grain Hopper
+STR_8060_WOOD_TRUCK                                             :Wood Truck
+STR_8061_IRON_ORE_HOPPER                                        :Iron Ore Hopper
+STR_8062_STEEL_TRUCK                                            :Steel Truck
+STR_8063_ARMORED_VAN                                            :Armored Van
+STR_8064_FOOD_VAN                                               :Food Van
+STR_8065_PAPER_TRUCK                                            :Paper Truck
+STR_8066_COPPER_ORE_HOPPER                                      :Copper Ore Hopper
+STR_8067_WATER_TANKER                                           :Water Tanker
+STR_8068_FRUIT_TRUCK                                            :Fruit Truck
+STR_8069_RUBBER_TRUCK                                           :Rubber Truck
+STR_806A_SUGAR_TRUCK                                            :Sugar Truck
+STR_806B_COTTON_CANDY_HOPPER                                    :Cotton Candy Hopper
+STR_806C_TOFFEE_HOPPER                                          :Toffee Hopper
+STR_806D_BUBBLE_VAN                                             :Bubble Van
+STR_806E_COLA_TANKER                                            :Cola Tanker
+STR_806F_CANDY_VAN                                              :Candy Van
+STR_8070_TOY_VAN                                                :Toy Van
+STR_8071_BATTERY_TRUCK                                          :Battery Truck
+STR_8072_FIZZY_DRINK_TRUCK                                      :Fizzy Drink Truck
+STR_8073_PLASTIC_TRUCK                                          :Plastic Truck
+STR_8074_MPS_REGAL_BUS                                          :MPS Regal Bus
+STR_8075_HEREFORD_LEOPARD_BUS                                   :Hereford Leopard Bus
+STR_8076_FOSTER_BUS                                             :Foster Bus
+STR_8077_FOSTER_MKII_SUPERBUS                                   :Foster MkII Superbus
+STR_8078_PLODDYPHUT_MKI_BUS                                     :Ploddyphut MkI Bus
+STR_8079_PLODDYPHUT_MKII_BUS                                    :Ploddyphut MkII Bus
+STR_807A_PLODDYPHUT_MKIII_BUS                                   :Ploddyphut MkIII Bus
+STR_807B_BALOGH_COAL_TRUCK                                      :Balogh Coal Truck
+STR_807C_UHL_COAL_TRUCK                                         :Uhl Coal Truck
+STR_807D_DW_COAL_TRUCK                                          :DW Coal Truck
+STR_807E_MPS_MAIL_TRUCK                                         :MPS Mail Truck
+STR_807F_REYNARD_MAIL_TRUCK                                     :Reynard Mail Truck
+STR_8080_PERRY_MAIL_TRUCK                                       :Perry Mail Truck
+STR_8081_MIGHTYMOVER_MAIL_TRUCK                                 :MightyMover Mail Truck
+STR_8082_POWERNAUGHT_MAIL_TRUCK                                 :Powernaught Mail Truck
+STR_8083_WIZZOWOW_MAIL_TRUCK                                    :Wizzowow Mail Truck
+STR_8084_WITCOMBE_OIL_TANKER                                    :Witcombe Oil Tanker
+STR_8085_FOSTER_OIL_TANKER                                      :Foster Oil Tanker
+STR_8086_PERRY_OIL_TANKER                                       :Perry Oil Tanker
+STR_8087_TALBOTT_LIVESTOCK_VAN                                  :Talbott Livestock Van
+STR_8088_UHL_LIVESTOCK_VAN                                      :Uhl Livestock Van
+STR_8089_FOSTER_LIVESTOCK_VAN                                   :Foster Livestock Van
+STR_808A_BALOGH_GOODS_TRUCK                                     :Balogh Goods Truck
+STR_808B_CRAIGHEAD_GOODS_TRUCK                                  :Craighead Goods Truck
+STR_808C_GOSS_GOODS_TRUCK                                       :Goss Goods Truck
+STR_808D_HEREFORD_GRAIN_TRUCK                                   :Hereford Grain Truck
+STR_808E_THOMAS_GRAIN_TRUCK                                     :Thomas Grain Truck
+STR_808F_GOSS_GRAIN_TRUCK                                       :Goss Grain Truck
+STR_8090_WITCOMBE_WOOD_TRUCK                                    :Witcombe Wood Truck
+STR_8091_FOSTER_WOOD_TRUCK                                      :Foster Wood Truck
+STR_8092_MORELAND_WOOD_TRUCK                                    :Moreland Wood Truck
+STR_8093_MPS_IRON_ORE_TRUCK                                     :MPS Iron Ore Truck
+STR_8094_UHL_IRON_ORE_TRUCK                                     :Uhl Iron Ore Truck
+STR_8095_CHIPPY_IRON_ORE_TRUCK                                  :Chippy Iron Ore Truck
+STR_8096_BALOGH_STEEL_TRUCK                                     :Balogh Steel Truck
+STR_8097_UHL_STEEL_TRUCK                                        :Uhl Steel Truck
+STR_8098_KELLING_STEEL_TRUCK                                    :Kelling Steel Truck
+STR_8099_BALOGH_ARMORED_TRUCK                                   :Balogh Armored Truck
+STR_809A_UHL_ARMORED_TRUCK                                      :Uhl Armored Truck
+STR_809B_FOSTER_ARMORED_TRUCK                                   :Foster Armored Truck
+STR_809C_FOSTER_FOOD_VAN                                        :Foster Food Van
+STR_809D_PERRY_FOOD_VAN                                         :Perry Food Van
+STR_809E_CHIPPY_FOOD_VAN                                        :Chippy Food Van
+STR_809F_UHL_PAPER_TRUCK                                        :Uhl Paper Truck
+STR_80A0_BALOGH_PAPER_TRUCK                                     :Balogh Paper Truck
+STR_80A1_MPS_PAPER_TRUCK                                        :MPS Paper Truck
+STR_80A2_MPS_COPPER_ORE_TRUCK                                   :MPS Copper Ore Truck
+STR_80A3_UHL_COPPER_ORE_TRUCK                                   :Uhl Copper Ore Truck
+STR_80A4_GOSS_COPPER_ORE_TRUCK                                  :Goss Copper Ore Truck
+STR_80A5_UHL_WATER_TANKER                                       :Uhl Water Tanker
+STR_80A6_BALOGH_WATER_TANKER                                    :Balogh Water Tanker
+STR_80A7_MPS_WATER_TANKER                                       :MPS Water Tanker
+STR_80A8_BALOGH_FRUIT_TRUCK                                     :Balogh Fruit Truck
+STR_80A9_UHL_FRUIT_TRUCK                                        :Uhl Fruit Truck
+STR_80AA_KELLING_FRUIT_TRUCK                                    :Kelling Fruit Truck
+STR_80AB_BALOGH_RUBBER_TRUCK                                    :Balogh Rubber Truck
+STR_80AC_UHL_RUBBER_TRUCK                                       :Uhl Rubber Truck
+STR_80AD_RMT_RUBBER_TRUCK                                       :RMT Rubber Truck
+STR_80AE_MIGHTYMOVER_SUGAR_TRUCK                                :MightyMover Sugar Truck
+STR_80AF_POWERNAUGHT_SUGAR_TRUCK                                :Powernaught Sugar Truck
+STR_80B0_WIZZOWOW_SUGAR_TRUCK                                   :Wizzowow Sugar Truck
+STR_80B1_MIGHTYMOVER_COLA_TRUCK                                 :MightyMover Cola Truck
+STR_80B2_POWERNAUGHT_COLA_TRUCK                                 :Powernaught Cola Truck
+STR_80B3_WIZZOWOW_COLA_TRUCK                                    :Wizzowow Cola Truck
+STR_80B4_MIGHTYMOVER_COTTON_CANDY                               :MightyMover Cotton Candy Truck
+STR_80B5_POWERNAUGHT_COTTON_CANDY                               :Powernaught Cotton Candy Truck
+STR_80B6_WIZZOWOW_COTTON_CANDY_TRUCK                            :Wizzowow Cotton Candy Truck
+STR_80B7_MIGHTYMOVER_TOFFEE_TRUCK                               :MightyMover Toffee Truck
+STR_80B8_POWERNAUGHT_TOFFEE_TRUCK                               :Powernaught Toffee Truck
+STR_80B9_WIZZOWOW_TOFFEE_TRUCK                                  :Wizzowow Toffee Truck
+STR_80BA_MIGHTYMOVER_TOY_VAN                                    :MightyMover Toy Van
+STR_80BB_POWERNAUGHT_TOY_VAN                                    :Powernaught Toy Van
+STR_80BC_WIZZOWOW_TOY_VAN                                       :Wizzowow Toy Van
+STR_80BD_MIGHTYMOVER_CANDY_TRUCK                                :MightyMover Candy Truck
+STR_80BE_POWERNAUGHT_CANDY_TRUCK                                :Powernaught Candy Truck
+STR_80BF_WIZZOWOW_CANDY_TRUCK                                   :Wizzowow Candy Truck
+STR_80C0_MIGHTYMOVER_BATTERY_TRUCK                              :MightyMover Battery Truck
+STR_80C1_POWERNAUGHT_BATTERY_TRUCK                              :Powernaught Battery Truck
+STR_80C2_WIZZOWOW_BATTERY_TRUCK                                 :Wizzowow Battery Truck
+STR_80C3_MIGHTYMOVER_FIZZY_DRINK                                :MightyMover Fizzy Drink Truck
+STR_80C4_POWERNAUGHT_FIZZY_DRINK                                :Powernaught Fizzy Drink Truck
+STR_80C5_WIZZOWOW_FIZZY_DRINK_TRUCK                             :Wizzowow Fizzy Drink Truck
+STR_80C6_MIGHTYMOVER_PLASTIC_TRUCK                              :MightyMover Plastic Truck
+STR_80C7_POWERNAUGHT_PLASTIC_TRUCK                              :Powernaught Plastic Truck
+STR_80C8_WIZZOWOW_PLASTIC_TRUCK                                 :Wizzowow Plastic Truck
+STR_80C9_MIGHTYMOVER_BUBBLE_TRUCK                               :MightyMover Bubble Truck
+STR_80CA_POWERNAUGHT_BUBBLE_TRUCK                               :Powernaught Bubble Truck
+STR_80CB_WIZZOWOW_BUBBLE_TRUCK                                  :Wizzowow Bubble Truck
+STR_80CC_MPS_OIL_TANKER                                         :MPS Oil Tanker
+STR_80CD_CS_INC_OIL_TANKER                                      :CS-Inc. Oil Tanker
+STR_80CE_MPS_PASSENGER_FERRY                                    :MPS Passenger Ferry
+STR_80CF_FFP_PASSENGER_FERRY                                    :FFP Passenger Ferry
+STR_80D0_BAKEWELL_300_HOVERCRAFT                                :Bakewell 300 Hovercraft
+STR_80D1_CHUGGER_CHUG_PASSENGER                                 :Chugger-Chug Passenger Ferry
+STR_80D2_SHIVERSHAKE_PASSENGER_FERRY                            :Shivershake Passenger Ferry
+STR_80D3_YATE_CARGO_SHIP                                        :Yate Cargo ship
+STR_80D4_BAKEWELL_CARGO_SHIP                                    :Bakewell Cargo ship
+STR_80D5_MIGHTYMOVER_CARGO_SHIP                                 :Mightymover Cargo ship
+STR_80D6_POWERNAUT_CARGO_SHIP                                   :Powernaut Cargo ship
+STR_80D7_SAMPSON_U52                                            :Sampson U52
+STR_80D8_COLEMAN_COUNT                                          :Coleman Count
+STR_80D9_FFP_DART                                               :FFP Dart
+STR_80DA_YATE_HAUGAN                                            :Yate Haugan
+STR_80DB_BAKEWELL_COTSWALD_LB_3                                 :Bakewell Cotswald LB-3
+STR_80DC_BAKEWELL_LUCKETT_LB_8                                  :Bakewell Luckett LB-8
+STR_80DD_BAKEWELL_LUCKETT_LB_9                                  :Bakewell Luckett LB-9
+STR_80DE_BAKEWELL_LUCKETT_LB80                                  :Bakewell Luckett LB80
+STR_80DF_BAKEWELL_LUCKETT_LB_10                                 :Bakewell Luckett LB-10
+STR_80E0_BAKEWELL_LUCKETT_LB_11                                 :Bakewell Luckett LB-11
+STR_80E1_YATE_AEROSPACE_YAC_1_11                                :Yate Aerospace YAC 1-11
+STR_80E2_DARWIN_100                                             :Darwin 100
+STR_80E3_DARWIN_200                                             :Darwin 200
+STR_80E4_DARWIN_300                                             :Darwin 300
+STR_80E5_DARWIN_400                                             :Darwin 400
+STR_80E6_DARWIN_500                                             :Darwin 500
+STR_80E7_DARWIN_600                                             :Darwin 600
+STR_80E8_GURU_GALAXY                                            :Guru Galaxy
+STR_80E9_AIRTAXI_A21                                            :Airtaxi A21
+STR_80EA_AIRTAXI_A31                                            :Airtaxi A31
+STR_80EB_AIRTAXI_A32                                            :Airtaxi A32
+STR_80EC_AIRTAXI_A33                                            :Airtaxi A33
+STR_80ED_YATE_AEROSPACE_YAE46                                   :Yate Aerospace YAe46
+STR_80EE_DINGER_100                                             :Dinger 100
+STR_80EF_AIRTAXI_A34_1000                                       :AirTaxi A34-1000
+STR_80F0_YATE_Z_SHUTTLE                                         :Yate Z-Shuttle
+STR_80F1_KELLING_K1                                             :Kelling K1
+STR_80F2_KELLING_K6                                             :Kelling K6
+STR_80F3_KELLING_K7                                             :Kelling K7
+STR_80F4_DARWIN_700                                             :Darwin 700
+STR_80F5_FFP_HYPERDART_2                                        :FFP Hyperdart 2
+STR_80F6_DINGER_200                                             :Dinger 200
+STR_80F7_DINGER_1000                                            :Dinger 1000
+STR_80F8_PLODDYPHUT_100                                         :Ploddyphut 100
+STR_80F9_PLODDYPHUT_500                                         :Ploddyphut 500
+STR_80FA_FLASHBANG_X1                                           :Flashbang X1
+STR_80FB_JUGGERPLANE_M1                                         :Juggerplane M1
+STR_80FC_FLASHBANG_WIZZER                                       :Flashbang Wizzer
+STR_80FD_TRICARIO_HELICOPTER                                    :Tricario Helicopter
+STR_80FE_GURU_X2_HELICOPTER                                     :Guru X2 Helicopter
+STR_80FF_POWERNAUT_HELICOPTER                                   :Powernaut Helicopter
+STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE                       :{WHITE}Message from vehicle manufacturer
+STR_8101_WE_HAVE_JUST_DESIGNED_A                                :{GOLD}We have just designed a new {STRING} - would you be interested in a year's exclusive use of this vehicle, so we can see how it performs before making it universally available ?
+STR_8102_RAILROAD_LOCOMOTIVE                                    :railroad locomotive
+STR_8103_ROAD_VEHICLE                                           :road vehicle
+STR_8104_AIRCRAFT                                               :aircraft
+STR_8105_SHIP                                                   :ship
+STR_8106_MONORAIL_LOCOMOTIVE                                    :monorail locomotive
+STR_8107_MAGLEV_LOCOMOTIVE                                      :maglev locomotive
+
+##id 0x8800
+STR_8800_TRAIN_DEPOT                                            :{WHITE}{TOWN} Train Depot
+STR_8801_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First train arrives at {STATION}!
+STR_8802_DETAILS                                                :{WHITE}{VEHICLE} (Details)
+STR_8803_TRAIN_IN_THE_WAY                                       :{WHITE}Train in the way
+STR_8804                                                        :{SETX 10}{COMMA}: {STRING} {STRING}
+STR_8805                                                        :{RIGHTARROW}{SETX 10}{COMMA}: {STRING} {STRING}
+STR_8806_GO_TO                                                  :Go to {STATION}
+STR_8807_GO_TO_TRANSFER                                         :Go to {STATION} (Transfer and take cargo)
+STR_8808_GO_TO_UNLOAD                                           :Go to {STATION} (Unload)
+STR_8809_GO_TO_TRANSFER_UNLOAD                                  :Go to {STATION} (Transfer and leave empty)
+STR_880A_GO_TO_LOAD                                             :Go to {STATION} (Load)
+STR_880B_GO_TO_TRANSFER_LOAD                                    :Go to {STATION} (Transfer and wait for full load)
+STR_880C_GO_NON_STOP_TO                                         :Go non-stop to {STATION}
+STR_880D_GO_TO_NON_STOP_TRANSFER                                :Go non-stop to {STATION} (Transfer and take cargo)
+STR_880E_GO_NON_STOP_TO_UNLOAD                                  :Go non-stop to {STATION} (Unload)
+STR_880F_GO_TO_NON_STOP_TRANSFER_UNLOAD                         :Go non-stop to {STATION} (Transfer and leave empty)
+STR_8810_GO_NON_STOP_TO_LOAD                                    :Go non-stop to {STATION} (Load)
+STR_8811_GO_TO_NON_STOP_TRANSFER_LOAD                           :Go non-stop to {STATION} (Transfer and wait for full load)
+STR_GO_TO_TRAIN_DEPOT                                           :Go to {TOWN} Train Depot
+STR_SERVICE_AT_TRAIN_DEPOT                                      :Service at {TOWN} Train Depot
+STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT                             :Go non-stop to {TOWN} Train Depot
+STR_SERVICE_NON_STOP_AT_TRAIN_DEPOT                             :Service non-stop at {TOWN} Train Depot
+
+STR_TIMETABLE_GO_TO                                             :{STRING} {STRING}
+STR_TIMETABLE_TRAVEL_NOT_TIMETABLED                             :Travel (not timetabled)
+STR_TIMETABLE_TRAVEL_FOR                                        :Travel for {STRING}
+STR_TIMETABLE_STAY_FOR                                          :and stay for {STRING}
+STR_TIMETABLE_DAYS                                              :{COMMA} day{P "" s}
+STR_TIMETABLE_TICKS                                             :{COMMA} tick{P "" s}
+
+STR_HEADING_FOR_TRAIN_DEPOT                                     :{ORANGE}Heading for {TOWN} Train Depot
+STR_HEADING_FOR_TRAIN_DEPOT_VEL                                 :{ORANGE}Heading for {TOWN} Train Depot, {VELOCITY}
+STR_HEADING_FOR_TRAIN_DEPOT_SERVICE                             :{LTBLUE}Service at {TOWN} Train Depot
+STR_HEADING_FOR_TRAIN_DEPOT_SERVICE_VEL                         :{LTBLUE}Service at {TOWN} Train Depot, {VELOCITY}
+
+STR_INVALID_ORDER                                               :{RED} (Invalid Order)
+
+STR_UNKNOWN_DESTINATION                                         :unknown destination
+STR_8812_EMPTY                                                  :{LTBLUE}Empty
+STR_8813_FROM                                                   :{LTBLUE}{CARGO} from {STATION}
+STR_FROM_MULT                                                   :{LTBLUE}{CARGO} from {STATION} (x{NUM})
+STR_8814_TRAIN_IS_WAITING_IN_DEPOT                              :{WHITE}Train {COMMA} is waiting in depot
+STR_8815_NEW_VEHICLES                                           :{BLACK}New Vehicles
+STR_8816                                                        :{BLACK}-
+STR_8819_TRAIN_TOO_LONG                                         :{WHITE}Train too long
+STR_881A_TRAINS_CAN_ONLY_BE_ALTERED                             :{WHITE}Trains can only be altered when stopped inside a depot
+STR_881B_TRAINS                                                 :{WHITE}{COMPANY} - {COMMA} Train{P "" s}
+
+STR_881C_NEW_RAIL_VEHICLES                                      :{WHITE}New Rail Vehicles
+STR_NEW_ELRAIL_VEHICLES                                         :{WHITE}New Electric Rail Vehicles
+STR_881D_NEW_MONORAIL_VEHICLES                                  :{WHITE}New Monorail Vehicles
+STR_881E_NEW_MAGLEV_VEHICLES                                    :{WHITE}New Maglev Vehicles
+STR_ALL_AVAIL_RAIL_VEHICLES                                     :{WHITE}Rail Vehicles
+
+STR_881F_BUILD_VEHICLE                                          :{BLACK}Build Vehicle
+STR_CLONE_ROAD_VEHICLE                                          :{BLACK}Clone Vehicle
+STR_CLONE_ROAD_VEHICLE_INFO                                     :{BLACK}This will build a copy of the road vehicle. Control-click will share the orders
+STR_CLONE_ROAD_VEHICLE_DEPOT_INFO                               :{BLACK}This will build a copy of a road vehicle. Click this button and then on a road vehicle inside or outside the depot. Control-click will share the orders
+STR_CLONE_TRAIN                                                 :{BLACK}Clone Train
+STR_CLONE_TRAIN_INFO                                            :{BLACK}This will build a copy of the train including all cars. Control-click will share the orders
+STR_CLONE_TRAIN_DEPOT_INFO                                      :{BLACK}This will build a copy of a train including all cars. Click this button and then on a train inside or outside the depot. Control-click will share the orders
+STR_8820_RENAME                                                 :{BLACK}Rename
+STR_8823_SKIP                                                   :{BLACK}Skip
+STR_8824_DELETE                                                 :{BLACK}Delete
+STR_8825_NON_STOP                                               :{BLACK}Non-Stop
+STR_8826_GO_TO                                                  :{BLACK}Go To
+STR_8827_FULL_LOAD                                              :{BLACK}Full Load
+STR_8828_UNLOAD                                                 :{BLACK}Unload
+STR_REFIT                                                       :{BLACK}Refit
+STR_REFIT_TIP                                                   :{BLACK}Select what cargo type to refit to in this order. Control click to remove refit instruction
+STR_REFIT_ORDER                                                 :(Refit to {STRING})
+STR_TIMETABLE_VIEW                                              :{BLACK}Timetable
+STR_TIMETABLE_VIEW_TOOLTIP                                      :{BLACK}Switch to the timetable view
+STR_8829_ORDERS                                                 :{WHITE}{VEHICLE} (Orders)
+STR_882A_END_OF_ORDERS                                          :{SETX 10}- - End of Orders - -
+STR_FULLLOAD_OR_SERVICE                                         :{SKIP}{SKIP}{STRING}
+STR_SERVICE                                                     :{BLACK}Service
+STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE                           :{WHITE}Can't build railroad vehicle...
+STR_882C_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY}
+STR_882D_VALUE                                                  :{LTBLUE}{ENGINE}{BLACK}   Value: {LTBLUE}{CURRENCY}
+STR_882E                                                        :{WHITE}{VEHICLE}
+STR_882F_LOADING_UNLOADING                                      :{LTBLUE}Loading / Unloading
+STR_TRAIN_MUST_BE_STOPPED                                       :{WHITE}Train must be stopped inside a depot
+STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT                              :{WHITE}Can't send train to depot...
+STR_8831_NO_MORE_SPACE_FOR_ORDERS                               :{WHITE}No more space for orders
+STR_8832_TOO_MANY_ORDERS                                        :{WHITE}Too many orders
+STR_8833_CAN_T_INSERT_NEW_ORDER                                 :{WHITE}Can't insert new order...
+STR_8834_CAN_T_DELETE_THIS_ORDER                                :{WHITE}Can't delete this order...
+STR_8835_CAN_T_MODIFY_THIS_ORDER                                :{WHITE}Can't modify this order...
+STR_CAN_T_MOVE_THIS_ORDER                                       :{WHITE}Can't move this order...
+STR_CAN_T_SKIP_ORDER                                            :{WHITE}Can't skip current order...
+STR_CAN_T_SKIP_TO_ORDER                                         :{WHITE}Can't skip to selected order...
+STR_8837_CAN_T_MOVE_VEHICLE                                     :{WHITE}Can't move vehicle...
+STR_REAR_ENGINE_FOLLOW_FRONT_ERROR                              :{WHITE}The rear engine will always follow its front counterpart
+STR_8838_N_A                                                    :N/A{SKIP}
+STR_8839_CAN_T_SELL_RAILROAD_VEHICLE                            :{WHITE}Can't sell railroad vehicle...
+STR_883A_UNABLE_TO_FIND_ROUTE_TO                                :{WHITE}Unable to find route to local depot
+STR_883B_CAN_T_STOP_START_TRAIN                                 :{WHITE}Can't stop/start train...
+STR_883C_SERVICING_INTERVAL_DAYS                                :{BLACK}Servicing interval: {LTBLUE}{COMMA}days{BLACK}   Last service: {LTBLUE}{DATE_LONG}
+STR_SERVICING_INTERVAL_PERCENT                                  :{BLACK}Servicing interval: {LTBLUE}{COMMA}%{BLACK}   Last service: {LTBLUE}{DATE_LONG}
+STR_883D_TRAINS_CLICK_ON_TRAIN_FOR                              :{BLACK}Trains - click on train for information
+STR_883E_BUILD_NEW_TRAINS_REQUIRES                              :{BLACK}Build new trains (requires train depot)
+STR_883F_TRAINS_CLICK_ON_TRAIN_FOR                              :{BLACK}Trains - click on train for info., drag vehicle to add/remove from train
+STR_8840_BUILD_NEW_TRAIN_VEHICLE                                :{BLACK}Build new train vehicle
+STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE                             :{BLACK}Drag train vehicle to here to sell it
+STR_8842_CENTER_MAIN_VIEW_ON_TRAIN                              :{BLACK}Center main view on train depot location
+STR_8843_TRAIN_VEHICLE_SELECTION                                :{BLACK}Train vehicle selection list - click on vehicle for information
+STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN                            :{BLACK}Build the highlighted train vehicle
+STR_8845_RENAME_TRAIN_VEHICLE_TYPE                              :{BLACK}Rename train vehicle type
+STR_8846_CURRENT_TRAIN_ACTION_CLICK                             :{BLACK}Current train action - click here to stop/start train
+STR_8847_SHOW_TRAIN_S_ORDERS                                    :{BLACK}Show train's orders
+STR_8848_CENTER_MAIN_VIEW_ON_TRAIN                              :{BLACK}Center main view on train's location
+STR_8849_SEND_TRAIN_TO_DEPOT                                    :{BLACK}Send train to depot
+STR_884A_FORCE_TRAIN_TO_PROCEED                                 :{BLACK}Force train to proceed without waiting for signal to clear
+STR_884B_REVERSE_DIRECTION_OF_TRAIN                             :{BLACK}Reverse direction of train
+STR_884C_SHOW_TRAIN_DETAILS                                     :{BLACK}Show train details
+STR_884D_INCREASE_SERVICING_INTERVAL                            :{BLACK}Increase servicing interval
+STR_884E_DECREASE_SERVICING_INTERVAL                            :{BLACK}Decrease servicing interval
+STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED                          :{BLACK}Show details of cargo carried
+STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES                         :{BLACK}Show details of train vehicles
+STR_8851_SHOW_CAPACITIES_OF_EACH                                :{BLACK}Show capacities of each vehicle
+STR_8852_SHOW_TOTAL_CARGO                                       :{BLACK}Show total capacity of train, split by cargo type
+STR_8852_ORDERS_LIST_CLICK_ON_ORDER                             :{BLACK}Orders list - click on order to highlight it
+STR_8853_SKIP_THE_CURRENT_ORDER                                 :{BLACK}Skip the current order, and start the next. CTRL + click skips to the selected order)
+STR_8854_DELETE_THE_HIGHLIGHTED                                 :{BLACK}Delete the highlighted order
+STR_8855_MAKE_THE_HIGHLIGHTED_ORDER                             :{BLACK}Make the highlighted order non-stop
+STR_8856_INSERT_A_NEW_ORDER_BEFORE                              :{BLACK}Insert a new order before the highlighted order, or add to end of list
+STR_8857_MAKE_THE_HIGHLIGHTED_ORDER                             :{BLACK}Make the highlighted order force the vehicle to wait for a full load
+STR_8858_MAKE_THE_HIGHLIGHTED_ORDER                             :{BLACK}Make the highlighted order force the vehicle to unload
+STR_TIMETABLE_TOOLTIP                                           :{BLACK}Timetable - click on an order to highlight it.
+STR_TIMETABLE_WAIT_TIME_TOOLTIP                                 :{BLACK}Change the amount of time that the highlighted order should take
+STR_TIMETABLE_CLEAR_TIME_TOOLTIP                                :{BLACK}Clear the amount of time for the highlighted order
+STR_TIMETABLE_RESET_LATENESS_TOOLTIP                            :{BLACK}Reset the lateness counter, so the vehicle will be on time
+STR_SERVICE_HINT                                                :{BLACK}Skip this order unless a service is needed
+STR_VEHICLE_INFO_COST_WEIGHT_SPEED_POWER                        :{BLACK}Cost: {CURRENCY} Weight: {WEIGHT_S}{}Speed: {VELOCITY}  Power: {POWER}{}Running Cost: {CURRENCY}/yr{}Capacity: {CARGO}
+STR_885C_BROKEN_DOWN                                            :{RED}Broken down
+STR_885D_AGE_RUNNING_COST_YR                                    :{BLACK}Age: {LTBLUE}{STRING}{BLACK}   Running Cost: {LTBLUE}{CURRENCY}/yr
+STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED                         :{BLACK}Weight: {LTBLUE}{WEIGHT_S}  {BLACK}Power: {LTBLUE}{POWER}{BLACK} Max. speed: {LTBLUE}{VELOCITY}
+STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE                  :{BLACK}Weight: {LTBLUE}{WEIGHT_S} {BLACK}Power: {LTBLUE}{POWER}{BLACK} Max. speed: {LTBLUE}{VELOCITY} {BLACK}Max. T.E.: {LTBLUE}{FORCE}
+STR_885F_PROFIT_THIS_YEAR_LAST_YEAR                             :{BLACK}Profit this year: {LTBLUE}{CURRENCY}  (last year: {CURRENCY})
+STR_8860_RELIABILITY_BREAKDOWNS                                 :{BLACK}Reliability: {LTBLUE}{COMMA}%  {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
+STR_8861_STOPPED                                                :{RED}Stopped
+STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL                           :{WHITE}Can't make train pass signal at danger...
+STR_8863_CRASHED                                                :{RED}Crashed!
+
+STR_8865_NAME_TRAIN                                             :{WHITE}Name train
+STR_8866_CAN_T_NAME_TRAIN                                       :{WHITE}Can't name train...
+STR_8867_NAME_TRAIN                                             :{BLACK}Name train
+STR_8868_TRAIN_CRASH_DIE_IN_FIREBALL                            :{BLACK}{BIGFONT}Train Crash!{}{COMMA} die in fireball after collision
+STR_8869_CAN_T_REVERSE_DIRECTION                                :{WHITE}Can't reverse direction of train...
+STR_886A_RENAME_TRAIN_VEHICLE_TYPE                              :{WHITE}Rename train vehicle type
+STR_886B_CAN_T_RENAME_TRAIN_VEHICLE                             :{WHITE}Can't rename train vehicle type...
+STR_886D_MAKE_THE_HIGHLIGHTED_ORDER                             :{BLACK}Make the highlighted order force the vehicle to dump cargo
+STR_886F_TRANSFER                                               :{BLACK}Transfer
+STR_CLEAR_TIME                                                  :{BLACK}Clear Time
+STR_RESET_LATENESS                                              :{BLACK}Reset Late Counter
+
+STR_TRAIN_STOPPING                                              :{RED}Stopping
+STR_TRAIN_STOPPING_VEL                                          :{RED}Stopping, {VELOCITY}
+STR_INCOMPATIBLE_RAIL_TYPES                                     :Incompatible rail types
+STR_TRAIN_NO_POWER                                              :{RED}No power
+STR_TRAIN_START_NO_CATENARY                                     :This track lacks catenary, so the train can't start
+
+STR_NEW_VEHICLE_NOW_AVAILABLE                                   :{BLACK}{BIGFONT}New {STRING} now available!
+STR_NEW_VEHICLE_TYPE                                            :{BLACK}{BIGFONT}{ENGINE}
+STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}New {STRING} now available!  -  {ENGINE}
+
+STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Can't sell destroyed vehicle...
+
+STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Can't timetable vehicle...
+STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Vehicles can only wait at stations.
+STR_TIMETABLE_NOT_STOPPING_HERE                                 :{WHITE}This vehicle is not stopping at this station.
+STR_TIMETABLE_CHANGE_TIME                                       :{BLACK}Change Time
+STR_TIMETABLE_STATUS_ON_TIME                                    :This vehicle is currently running on time
+STR_TIMETABLE_STATUS_LATE                                       :This vehicle is currently running {STRING} late
+STR_TIMETABLE_STATUS_EARLY                                      :This vehicle is currently running {STRING} early
+STR_TIMETABLE_TOTAL_TIME                                        :This timetable will take {STRING} to complete
+STR_TIMETABLE_TOTAL_TIME_INCOMPLETE                             :This timetable will take at least {STRING} to complete (not all timetabled)
+STR_TIMETABLE_AUTOFILL                                          :{BLACK}Autofill
+STR_TIMETABLE_AUTOFILL_TOOLTIP                                  :{BLACK}Fill the timetable automatically with the values from the first journey
+
+##id 0x9000
+STR_9000_ROAD_VEHICLE_IN_THE_WAY                                :{WHITE}Road vehicle in the way
+STR_9001_ROAD_VEHICLES                                          :{WHITE}{COMPANY} - {COMMA} Road Vehicle{P "" s}
+STR_9002                                                        :{WHITE}{VEHICLE}
+STR_9003_ROAD_VEHICLE_DEPOT                                     :{WHITE}{TOWN} Road Vehicle Depot
+STR_9004_NEW_VEHICLES                                           :{BLACK}New Vehicles
+STR_9006_NEW_ROAD_VEHICLES                                      :{WHITE}New Road Vehicles
+STR_9007_BUILD_VEHICLE                                          :{BLACK}Build Vehicle
+STR_9009_CAN_T_BUILD_ROAD_VEHICLE                               :{WHITE}Can't build road vehicle...
+STR_900C_DETAILS                                                :{WHITE}{VEHICLE} (Details)
+STR_900D_AGE_RUNNING_COST_YR                                    :{BLACK}Age: {LTBLUE}{STRING}{BLACK}   Running Cost: {LTBLUE}{CURRENCY}/yr
+STR_900E_MAX_SPEED                                              :{BLACK}Max. speed: {LTBLUE}{VELOCITY}
+STR_900F_PROFIT_THIS_YEAR_LAST_YEAR                             :{BLACK}Profit this year: {LTBLUE}{CURRENCY}  (last year: {CURRENCY})
+STR_9010_RELIABILITY_BREAKDOWNS                                 :{BLACK}Reliability: {LTBLUE}{COMMA}%  {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
+STR_9011_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY}
+STR_9012_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}
+STR_9013_MUST_BE_STOPPED_INSIDE                                 :{WHITE}...must be stopped inside a road vehicle depot
+STR_9014_CAN_T_SELL_ROAD_VEHICLE                                :{WHITE}Can't sell road vehicle...
+STR_9015_CAN_T_STOP_START_ROAD_VEHICLE                          :{WHITE}Can't stop/start road vehicle...
+STR_9016_ROAD_VEHICLE_IS_WAITING                                :{WHITE}Road Vehicle {COMMA} is waiting in depot
+STR_HEADING_FOR_ROAD_DEPOT                                      :{ORANGE}Heading for {TOWN} Road Depot
+STR_HEADING_FOR_ROAD_DEPOT_VEL                                  :{ORANGE}Heading for {TOWN} Road Depot, {VELOCITY}
+STR_HEADING_FOR_ROAD_DEPOT_SERVICE                              :{LTBLUE}Service at {TOWN} Road Depot
+STR_HEADING_FOR_ROAD_DEPOT_SERVICE_VEL                          :{LTBLUE}Service at {TOWN} Road Depot, {VELOCITY}
+STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT                            :{WHITE}Can't send vehicle to depot...
+STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT                             :{WHITE}Unable to find local depot
+STR_901A_ROAD_VEHICLES_CLICK_ON                                 :{BLACK}Road vehicles - click on vehicle for information
+STR_901B_BUILD_NEW_ROAD_VEHICLES                                :{BLACK}Build new road vehicles (requires road vehicle depot)
+STR_901C_CURRENT_VEHICLE_ACTION                                 :{BLACK}Current vehicle action - click here to stop/start vehicle
+STR_901D_SHOW_VEHICLE_S_ORDERS                                  :{BLACK}Show vehicle's orders
+STR_901E_CENTER_MAIN_VIEW_ON_VEHICLE                            :{BLACK}Center main view on vehicle's location
+STR_901F_SEND_VEHICLE_TO_DEPOT                                  :{BLACK}Send vehicle to depot
+STR_9020_FORCE_VEHICLE_TO_TURN_AROUND                           :{BLACK}Force vehicle to turn around
+STR_9021_SHOW_ROAD_VEHICLE_DETAILS                              :{BLACK}Show road vehicle details
+STR_9022_VEHICLES_CLICK_ON_VEHICLE                              :{BLACK}Vehicles - click on vehicle for information
+STR_9023_BUILD_NEW_ROAD_VEHICLE                                 :{BLACK}Build new road vehicle
+STR_9024_DRAG_ROAD_VEHICLE_TO_HERE                              :{BLACK}Drag road vehicle to here to sell it
+STR_9025_CENTER_MAIN_VIEW_ON_ROAD                               :{BLACK}Center main view on road vehicle depot location
+STR_9026_ROAD_VEHICLE_SELECTION                                 :{BLACK}Road vehicle selection list - click on vehicle for information
+STR_9027_BUILD_THE_HIGHLIGHTED_ROAD                             :{BLACK}Build the highlighted road vehicle
+STR_902A_COST_SPEED_RUNNING_COST                                :{BLACK}Cost: {CURRENCY}{}Speed: {VELOCITY}{}Running Cost: {CURRENCY}/yr{}Capacity: {CARGO}
+STR_ARTICULATED_RV_CAPACITY                                     :{BLACK}Capacity: {LTBLUE}
+STR_BARE_CARGO                                                  :{CARGO}
+
+STR_902C_NAME_ROAD_VEHICLE                                      :{WHITE}Name road vehicle
+STR_902D_CAN_T_NAME_ROAD_VEHICLE                                :{WHITE}Can't name road vehicle...
+STR_902E_NAME_ROAD_VEHICLE                                      :{BLACK}Name road vehicle
+STR_902F_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First bus arrives at {STATION}!
+STR_9030_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First truck arrives at {STATION}!
+STR_902F_CITIZENS_CELEBRATE_FIRST_TRAM                          :{BLACK}{BIGFONT}Citizens celebrate . . .{}First passenger tram arrives at {STATION}!
+STR_9030_CITIZENS_CELEBRATE_FIRST_TRAM                          :{BLACK}{BIGFONT}Citizens celebrate . . .{}First freight tram arrives at {STATION}!
+STR_9031_ROAD_VEHICLE_CRASH_DRIVER                              :{BLACK}{BIGFONT}Road Vehicle Crash!{}Driver dies in fireball after collision with train
+STR_9032_ROAD_VEHICLE_CRASH_DIE                                 :{BLACK}{BIGFONT}Road Vehicle Crash!{}{COMMA} die in fireball after collision with train
+STR_9033_CAN_T_MAKE_VEHICLE_TURN                                :{WHITE}Can't make vehicle turn around...
+STR_ONLY_TURN_SINGLE_UNIT                                       :{WHITE}Can't turn vehicles consisting of multiple units
+STR_9034_RENAME                                                 :{BLACK}Rename
+STR_9035_RENAME_ROAD_VEHICLE_TYPE                               :{BLACK}Rename road vehicle type
+STR_9036_RENAME_ROAD_VEHICLE_TYPE                               :{WHITE}Rename road vehicle type
+STR_9037_CAN_T_RENAME_ROAD_VEHICLE                              :{WHITE}Can't rename road vehicle type...
+STR_9038_GO_TO_ROADVEH_DEPOT                                    :Go to {TOWN} Road Vehicle Depot
+STR_SERVICE_AT_ROADVEH_DEPOT                                    :Service at {TOWN} Road Vehicle Depot
+
+STR_REFIT_ROAD_VEHICLE_TO_CARRY                                 :{BLACK}Refit road vehicle to carry a different cargo type
+STR_REFIT_ROAD_VEHICLE                                          :{BLACK}Refit road vehicle
+STR_REFIT_ROAD_VEHICLE_TO_CARRY_HIGHLIGHTED                     :{BLACK}Refit road vehicle to carry highlighted cargo type
+STR_REFIT_ROAD_VEHICLE_CAN_T                                    :{WHITE}Can't refit road vehicle...
+STR_ROAD_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Select type of cargo for road vehicle to carry
+
+##id 0x9800
+STR_9800_DOCK_CONSTRUCTION                                      :Dock construction
+STR_9801_DOCK_CONSTRUCTION                                      :{WHITE}Dock construction
+STR_9802_CAN_T_BUILD_DOCK_HERE                                  :{WHITE}Can't build dock here...
+STR_9803_SHIP_DEPOT                                             :{WHITE}{TOWN} Ship Depot
+STR_9804_NEW_SHIPS                                              :{BLACK}New Ships
+STR_9805_SHIPS                                                  :{WHITE}{COMPANY} - {COMMA} Ship{P "" s}
+STR_9808_NEW_SHIPS                                              :{WHITE}New Ships
+STR_9809_BUILD_SHIP                                             :{BLACK}Build Ship
+STR_CLONE_SHIP                                                  :{BLACK}Clone Ship
+STR_CLONE_SHIP_INFO                                             :{BLACK}This will build a copy of the ship. Control-click will share the orders
+STR_CLONE_SHIP_DEPOT_INFO                                       :{BLACK}This will build a copy of a ship. Click this button and then on a ship inside or outside the depot. Control-click will share the orders
+STR_980B_SHIP_MUST_BE_STOPPED_IN                                :{WHITE}Ship must be stopped in depot
+STR_980C_CAN_T_SELL_SHIP                                        :{WHITE}Can't sell ship...
+STR_980D_CAN_T_BUILD_SHIP                                       :{WHITE}Can't build ship...
+STR_980E_SHIP_IN_THE_WAY                                        :{WHITE}Ship in the way
+STR_980F                                                        :{WHITE}{VEHICLE}
+STR_9811_DETAILS                                                :{WHITE}{VEHICLE} (Details)
+STR_9812_AGE_RUNNING_COST_YR                                    :{BLACK}Age: {LTBLUE}{STRING}{BLACK}   Running Cost: {LTBLUE}{CURRENCY}/yr
+STR_9813_MAX_SPEED                                              :{BLACK}Max. speed: {LTBLUE}{VELOCITY}
+STR_9814_PROFIT_THIS_YEAR_LAST_YEAR                             :{BLACK}Profit this year: {LTBLUE}{CURRENCY}  (last year: {CURRENCY})
+STR_9815_RELIABILITY_BREAKDOWNS                                 :{BLACK}Reliability: {LTBLUE}{COMMA}%  {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
+STR_9816_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY}
+STR_9817_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}
+STR_9818_CAN_T_STOP_START_SHIP                                  :{WHITE}Can't stop/start ship...
+STR_9819_CAN_T_SEND_SHIP_TO_DEPOT                               :{WHITE}Can't send ship to depot...
+STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT                             :{WHITE}Unable to find local depot
+STR_HEADING_FOR_SHIP_DEPOT                                      :{ORANGE}Heading for {TOWN} Ship Depot
+STR_HEADING_FOR_SHIP_DEPOT_VEL                                  :{ORANGE}Heading for {TOWN} Ship Depot, {VELOCITY}
+STR_HEADING_FOR_SHIP_DEPOT_SERVICE                              :{LTBLUE}Service at {TOWN} Ship Depot
+STR_HEADING_FOR_SHIP_DEPOT_SERVICE_VEL                          :{LTBLUE}Service at {TOWN} Ship Depot, {VELOCITY}
+STR_981C_SHIP_IS_WAITING_IN_DEPOT                               :{WHITE}Ship {COMMA} is waiting in depot
+STR_981D_BUILD_SHIP_DOCK                                        :{BLACK}Build ship dock
+STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING                          :{BLACK}Build ship depot (for building and servicing ships)
+STR_981F_SHIPS_CLICK_ON_SHIP_FOR                                :{BLACK}Ships - click on ship for information
+STR_9820_BUILD_NEW_SHIP                                         :{BLACK}Build new ship
+STR_9821_DRAG_SHIP_TO_HERE_TO_SELL                              :{BLACK}Drag ship to here to sell it
+STR_9822_CENTER_MAIN_VIEW_ON_SHIP                               :{BLACK}Center main view on ship depot location
+STR_9823_SHIPS_CLICK_ON_SHIP_FOR                                :{BLACK}Ships - click on ship for information
+STR_9824_BUILD_NEW_SHIPS_REQUIRES                               :{BLACK}Build new ships (requires ship depot)
+STR_9825_SHIP_SELECTION_LIST_CLICK                              :{BLACK}Ship selection list - click on ship for information
+STR_9826_BUILD_THE_HIGHLIGHTED_SHIP                             :{BLACK}Build the highlighted ship
+STR_9827_CURRENT_SHIP_ACTION_CLICK                              :{BLACK}Current ship action - click here to stop/start ship
+STR_9828_SHOW_SHIP_S_ORDERS                                     :{BLACK}Show ship's orders
+STR_9829_CENTER_MAIN_VIEW_ON_SHIP                               :{BLACK}Center main view on ship's location
+STR_982A_SEND_SHIP_TO_DEPOT                                     :{BLACK}Send ship to depot
+STR_982B_SHOW_SHIP_DETAILS                                      :{BLACK}Show ship details
+STR_982E_COST_MAX_SPEED_CAPACITY                                :{BLACK}Cost: {CURRENCY} Max. Speed: {VELOCITY}{}Capacity: {CARGO}{}Running Cost: {CURRENCY}/yr
+STR_982F_NAME_SHIP                                              :{BLACK}Name ship
+
+STR_9831_NAME_SHIP                                              :{WHITE}Name ship
+STR_9832_CAN_T_NAME_SHIP                                        :{WHITE}Can't name ship...
+STR_9833_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First ship arrives at {STATION}!
+STR_9834_POSITION_BUOY_WHICH_CAN                                :{BLACK}Place a buoy which can be used as a waypoint
+STR_9835_CAN_T_POSITION_BUOY_HERE                               :{WHITE}Can't place buoy here...
+STR_9836_RENAME                                                 :{BLACK}Rename
+STR_9837_RENAME_SHIP_TYPE                                       :{BLACK}Rename ship type
+STR_9838_RENAME_SHIP_TYPE                                       :{WHITE}Rename ship type
+STR_9839_CAN_T_RENAME_SHIP_TYPE                                 :{WHITE}Can't rename ship type...
+STR_983A_REFIT_CARGO_SHIP_TO_CARRY                              :{BLACK}Refit cargo ship to carry a different cargo type
+STR_983B_REFIT                                                  :{WHITE}{VEHICLE} (Refit)
+STR_983C_REFIT_SHIP                                             :{BLACK}Refit ship
+STR_983D_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Select type of cargo for ship to carry
+STR_983E_REFIT_SHIP_TO_CARRY_HIGHLIGHTED                        :{BLACK}Refit ship to carry highlighted cargo type
+STR_983F_SELECT_CARGO_TYPE_TO_CARRY                             :{GOLD}Select cargo type to carry:
+STR_9840_NEW_CAPACITY_COST_OF_REFIT                             :{BLACK}New capacity: {GOLD}{CARGO}{}{BLACK}Cost of refit: {GOLD}{CURRENCY}
+STR_9841_CAN_T_REFIT_SHIP                                       :{WHITE}Can't refit ship...
+STR_9842_REFITTABLE                                             :(refittable)
+STR_GO_TO_SHIP_DEPOT                                            :Go to {TOWN} Ship Depot
+SERVICE_AT_SHIP_DEPOT                                           :Service at {TOWN} Ship Depot
+
+##id 0xA000
+STR_A000_AIRPORTS                                               :{WHITE}Airports
+STR_A001_CAN_T_BUILD_AIRPORT_HERE                               :{WHITE}Can't build airport here...
+STR_A002_AIRCRAFT_HANGAR                                        :{WHITE}{STATION} Aircraft Hangar
+STR_A003_NEW_AIRCRAFT                                           :{BLACK}New Aircraft
+STR_CLONE_AIRCRAFT                                              :{BLACK}Clone Aircraft
+STR_CLONE_AIRCRAFT_INFO                                         :{BLACK}This will build a copy of the aircraft. Control-click will share the orders
+STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW                           :{BLACK}This will build a copy of an aircraft. Click this button and then on an aircraft inside or outside the hangar. Control-click will share the orders
+STR_A005_NEW_AIRCRAFT                                           :{WHITE}New Aircraft
+STR_A006_BUILD_AIRCRAFT                                         :{BLACK}Build Aircraft
+STR_A008_CAN_T_BUILD_AIRCRAFT                                   :{WHITE}Can't build aircraft...
+STR_A009_AIRCRAFT                                               :{WHITE}{COMPANY} - {COMMA} Aircraft
+STR_A00A                                                        :{WHITE}{VEHICLE}
+STR_A00B_ORDERS                                                 :{WHITE}{VEHICLE} (Orders)
+STR_A00C_DETAILS                                                :{WHITE}{VEHICLE} (Details)
+STR_A00D_AGE_RUNNING_COST_YR                                    :{BLACK}Age: {LTBLUE}{STRING}{BLACK}   Running Cost: {LTBLUE}{CURRENCY}/yr
+STR_A00E_MAX_SPEED                                              :{BLACK}Max. speed: {LTBLUE}{VELOCITY}
+STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR                             :{BLACK}Profit this year: {LTBLUE}{CURRENCY}  (last year: {CURRENCY})
+STR_A010_RELIABILITY_BREAKDOWNS                                 :{BLACK}Reliability: {LTBLUE}{COMMA}%  {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
+STR_A011_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY}
+STR_A012_CAN_T_SEND_AIRCRAFT_TO                                 :{WHITE}Can't send aircraft to hangar...
+STR_HEADING_FOR_HANGAR                                          :{ORANGE}Heading for {STATION} Hangar
+STR_HEADING_FOR_HANGAR_VEL                                      :{ORANGE}Heading for {STATION} Hangar, {VELOCITY}
+STR_HEADING_FOR_HANGAR_SERVICE                                  :{LTBLUE}Service at {STATION} Hangar
+STR_HEADING_FOR_HANGAR_SERVICE_VEL                              :{LTBLUE}Service at {STATION} Hangar, {VELOCITY}
+STR_A014_AIRCRAFT_IS_WAITING_IN                                 :{WHITE}Aircraft {COMMA} is waiting in the aircraft hangar
+STR_A015_AIRCRAFT_IN_THE_WAY                                    :{WHITE}Aircraft in the way
+STR_A016_CAN_T_STOP_START_AIRCRAFT                              :{WHITE}Can't stop/start aircraft...
+STR_A017_AIRCRAFT_IS_IN_FLIGHT                                  :{WHITE}Aircraft is in flight
+STR_A019_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}, {CARGO}
+STR_A01A_CAPACITY                                               :{BLACK}Capacity: {LTBLUE}{CARGO}
+STR_A01B_AIRCRAFT_MUST_BE_STOPPED                               :{WHITE}Aircraft must be stopped in hangar
+STR_A01C_CAN_T_SELL_AIRCRAFT                                    :{WHITE}Can't sell aircraft...
+STR_A01D_AIRPORT_CONSTRUCTION                                   :Airport construction
+STR_A01E_BUILD_AIRPORT                                          :{BLACK}Build airport
+STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT                             :{BLACK}Aircraft - click on aircraft for information
+STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES                            :{BLACK}Build new aircraft (requires airport with hangar)
+STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT                             :{BLACK}Aircraft - click on aircraft for information
+STR_A022_BUILD_NEW_AIRCRAFT                                     :{BLACK}Build new aircraft
+STR_A023_DRAG_AIRCRAFT_TO_HERE_TO                               :{BLACK}Drag aircraft to here to sell it
+STR_A024_CENTER_MAIN_VIEW_ON_HANGAR                             :{BLACK}Center main view on hangar location
+STR_A025_AIRCRAFT_SELECTION_LIST                                :{BLACK}Aircraft selection list - click on aircraft for information
+STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT                         :{BLACK}Build the highlighted aircraft
+STR_A027_CURRENT_AIRCRAFT_ACTION                                :{BLACK}Current aircraft action - click here to stop/start aircraft
+STR_A028_SHOW_AIRCRAFT_S_ORDERS                                 :{BLACK}Show aircraft's orders
+STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT                           :{BLACK}Center main view on aircraft's location
+STR_A02A_SEND_AIRCRAFT_TO_HANGAR                                :{BLACK}Send aircraft to hangar
+STR_A02B_SHOW_AIRCRAFT_DETAILS                                  :{BLACK}Show aircraft details
+STR_A02E_COST_MAX_SPEED_CAPACITY                                :{BLACK}Cost: {CURRENCY} Max. Speed: {VELOCITY}{}Capacity: {COMMA} passengers, {COMMA} bags of mail{}Running Cost: {CURRENCY}/yr
+
+STR_A030_NAME_AIRCRAFT                                          :{WHITE}Name aircraft
+STR_A031_CAN_T_NAME_AIRCRAFT                                    :{WHITE}Can't name aircraft...
+STR_A032_NAME_AIRCRAFT                                          :{BLACK}Name aircraft
+STR_A033_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Citizens celebrate . . .{}First aircraft arrives at {STATION}!
+STR_A034_PLANE_CRASH_DIE_IN_FIREBALL                            :{BLACK}{BIGFONT}Plane Crash!{}{COMMA} die in fireball at {STATION}
+STR_PLANE_CRASH_OUT_OF_FUEL                                     :{BLACK}{BIGFONT}Plane Crash!{}Aircraft ran out of fuel, {COMMA} die in fireball!
+STR_A036                                                        :{TINYFONT}{BLACK}{STATION}
+STR_A037_RENAME                                                 :{BLACK}Rename
+STR_A038_RENAME_AIRCRAFT_TYPE                                   :{BLACK}Rename aircraft type
+STR_A039_RENAME_AIRCRAFT_TYPE                                   :{WHITE}Rename aircraft type
+STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE                             :{WHITE}Can't rename aircraft type...
+STR_A03B_REFIT_AIRCRAFT_TO_CARRY                                :{BLACK}Refit aircraft to carry a different cargo type
+STR_A03C_REFIT                                                  :{WHITE}{VEHICLE} (Refit)
+STR_A03D_REFIT_AIRCRAFT                                         :{BLACK}Refit aircraft
+STR_A03E_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Select type of cargo for aircraft to carry
+STR_A03F_REFIT_AIRCRAFT_TO_CARRY                                :{BLACK}Refit aircraft to carry highlighted cargo type
+STR_A040_SELECT_CARGO_TYPE_TO_CARRY                             :{GOLD}Select cargo type to carry:
+STR_A041_NEW_CAPACITY_COST_OF_REFIT                             :{BLACK}New capacity: {GOLD}{STRING}{}{BLACK}Cost of refit: {GOLD}{CURRENCY}
+STR_A042_CAN_T_REFIT_AIRCRAFT                                   :{WHITE}Can't refit aircraft...
+STR_GO_TO_AIRPORT_HANGAR                                        :Go to {STATION} Hangar
+SERVICE_AT_AIRPORT_HANGAR                                       :Service at {STATION} Hangar
+
+STR_TIMETABLE_TITLE                                             :{WHITE}{VEHICLE} (Timetable)
+
+##id 0xB000
+STR_B000_ZEPPELIN_DISASTER_AT                                   :{BLACK}{BIGFONT}Zeppelin disaster at {STATION}!
+STR_B001_ROAD_VEHICLE_DESTROYED                                 :{BLACK}{BIGFONT}Road vehicle destroyed in 'UFO' collision!
+STR_B002_OIL_REFINERY_EXPLOSION                                 :{BLACK}{BIGFONT}Oil refinery explosion near {TOWN}!
+STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS                        :{BLACK}{BIGFONT}Factory destroyed in suspicious circumstances near {TOWN}!
+STR_B004_UFO_LANDS_NEAR                                         :{BLACK}{BIGFONT}'UFO' lands near {TOWN}!
+STR_B005_COAL_MINE_SUBSIDENCE_LEAVES                            :{BLACK}{BIGFONT}Coal mine subsidence leaves trail of destruction near {TOWN}!
+STR_B006_FLOOD_VEHICLE_DESTROYED                                :{BLACK}{BIGFONT}Floods!{}At least {COMMA} missing, presumed dead after significant flooding!
+
+STR_BRIBE_FAILED                                                :{WHITE}Your attempted bribery has been
+STR_BRIBE_FAILED_2                                              :{WHITE}discovered by a regional investigator
+STR_BUILD_DATE                                                  :{BLACK}Built: {LTBLUE}{DATE_LONG}
+
+STR_PERFORMANCE_DETAIL                                          :{WHITE}Detailed performance rating
+STR_PERFORMANCE_DETAIL_KEY                                      :{BLACK}Detail
+STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY                          :{BLACK}({CURRCOMPACT}/{CURRCOMPACT})
+STR_PERFORMANCE_DETAIL_AMOUNT_INT                               :{BLACK}({COMMA}/{COMMA})
+STR_PERFORMANCE_DETAIL_PERCENT                                  :{WHITE}{NUM}%
+SET_PERFORMANCE_DETAIL_INT                                      :{BLACK}{NUM}
+############ Those following lines need to be in this order!!
+STR_PERFORMANCE_DETAIL_VEHICLES                                 :{BLACK}Vehicles:
+STR_PERFORMANCE_DETAIL_STATIONS                                 :{BLACK}Stations:
+STR_PERFORMANCE_DETAIL_MIN_PROFIT                               :{BLACK}Min. profit:
+STR_PERFORMANCE_DETAIL_MIN_INCOME                               :{BLACK}Min. income:
+STR_PERFORMANCE_DETAIL_MAX_INCOME                               :{BLACK}Max. income:
+STR_PERFORMANCE_DETAIL_DELIVERED                                :{BLACK}Delivered:
+STR_PERFORMANCE_DETAIL_CARGO                                    :{BLACK}Cargo:
+STR_PERFORMANCE_DETAIL_MONEY                                    :{BLACK}Money:
+STR_PERFORMANCE_DETAIL_LOAN                                     :{BLACK}Loan:
+STR_PERFORMANCE_DETAIL_TOTAL                                    :{BLACK}Total:
+############ End of order list
+STR_PERFORMANCE_DETAIL_VEHICLES_TIP                             :{BLACK}Number of vehicles; this includes road vehicles, trains, ships and aircraft
+STR_PERFORMANCE_DETAIL_STATIONS_TIP                             :{BLACK}Number of station parts. Every part of a station (e.g. train station, bus stop, airport) is counted, even if they are connected to one station.
+STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP                           :{BLACK}The profit of the vehicle with the lowest income (of all vehicles older than 2 years)
+STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP                           :{BLACK}Amount of cash made in the month with the lowest profit of the past 12 quarters
+STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP                           :{BLACK}Amount of cash made in the month with the highest profit of the past 12 quarters
+STR_PERFORMANCE_DETAIL_DELIVERED_TIP                            :{BLACK}Units of cargo delivered in the past four quarters.
+STR_PERFORMANCE_DETAIL_CARGO_TIP                                :{BLACK}Number of types of cargo delivered in the past quarter.
+STR_PERFORMANCE_DETAIL_MONEY_TIP                                :{BLACK}Amount of money this company has in the bank
+STR_PERFORMANCE_DETAIL_LOAN_TIP                                 :{BLACK}The amount of money this company has taken on loan
+STR_PERFORMANCE_DETAIL_TOTAL_TIP                                :{BLACK}Total points out of possible points
+
+STR_NEWGRF_SETTINGS_BUTTON                                      :{BLACK}NewGRF Settings
+STR_NEWGRF_SETTINGS_CAPTION                                     :{WHITE}Newgrf settings
+STR_NEWGRF_APPLY_CHANGES                                        :{BLACK}Apply changes
+STR_NEWGRF_SET_PARAMETERS                                       :{BLACK}Set parameters
+STR_NEWGRF_TIP                                                  :{BLACK}A list of all the Newgrf sets that you have installed. Click a set to change the settings.
+STR_NEWGRF_NO_FILES_INSTALLED                                   :{BLACK}There are currently no newgrf files installed! Please refer to the manual for instructions to install new graphics.
+STR_NEWGRF_FILENAME                                             :{BLACK}Filename: {SILVER}{STRING}
+STR_NEWGRF_GRF_ID                                               :{BLACK}GRF ID: {SILVER}{STRING}
+STR_NEWGRF_MD5SUM                                               :{BLACK}MD5sum: {SILVER}{STRING}
+STR_NEWGRF_CONFIRMATION_TEXT                                    :{YELLOW}You are about to make changes to a running game; this can crash OpenTTD.{}Are you absolutely sure about this?
+
+STR_NEWGRF_ERROR_MSG_INFO                                       :{SILVER}{STRING}
+STR_NEWGRF_ERROR_MSG_WARNING                                    :{RED}Warning: {SILVER}{STRING}
+STR_NEWGRF_ERROR_MSG_ERROR                                      :{RED}Error: {SILVER}{STRING}
+STR_NEWGRF_ERROR_MSG_FATAL                                      :{RED}Fatal: {SILVER}{STRING}
+STR_NEWGRF_ERROR_VERSION_NUMBER                                 :{STRING} will not work with the TTDPatch version reported by OpenTTD.
+STR_NEWGRF_ERROR_DOS_OR_WINDOWS                                 :{STRING} is for the {STRING} version of TTD.
+STR_NEWGRF_ERROR_UNSET_SWITCH                                   :{STRING} is designed to be used with {STRING}
+STR_NEWGRF_ERROR_INVALID_PARAMETER                              :Invalid parameter for {STRING}: parameter {STRING} ({NUM})
+STR_NEWGRF_ERROR_LOAD_BEFORE                                    :{STRING} must be loaded before {STRING}.
+STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} must be loaded after {STRING}.
+STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} requires OpenTTD version {STRING} or better.
+STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :the GRF file it was designed to translate
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Too many NewGRFs are loaded.
+
+STR_NEWGRF_ADD                                                  :{BLACK}Add
+STR_NEWGRF_ADD_TIP                                              :{BLACK}Add a NewGRF file to the list
+STR_NEWGRF_REMOVE                                               :{BLACK}Remove
+STR_NEWGRF_REMOVE_TIP                                           :{BLACK}Remove the selected NewGRF file from the list
+STR_NEWGRF_MOVEUP                                               :{BLACK}Move Up
+STR_NEWGRF_MOVEUP_TIP                                           :{BLACK}Move the selected NewGRF file up the list
+STR_NEWGRF_MOVEDOWN                                             :{BLACK}Move Down
+STR_NEWGRF_MOVEDOWN_TIP                                         :{BLACK}Move the selected NewGRF file down the list
+STR_NEWGRF_FILE_TIP                                             :{BLACK}A list of the NewGRF files that are installed. Click a file to change its parameters
+STR_NEWGRF_PARAMETER                                            :{BLACK}Parameters: {SILVER}{STRING}
+STR_NEWGRF_PARAMETER_QUERY                                      :{BLACK}Enter NewGRF parameters
+STR_NEWGRF_NO_INFO                                              :{BLACK}No information available
+
+STR_NEWGRF_ADD_CAPTION                                          :{WHITE}Available NewGRF files
+STR_NEWGRF_ADD_FILE                                             :{BLACK}Add to selection
+STR_NEWGRF_ADD_FILE_TIP                                         :{BLACK}Add the selected NewGRF file to your configuration
+STR_NEWGRF_RESCAN_FILES                                         :{BLACK}Rescan files
+STR_NEWGRF_RESCAN_FILES_TIP                                     :{BLACK}Update the list of available NewGRF files
+STR_NEWGRF_DUPLICATE_GRFID                                      :{WHITE}Cannot add file: duplicate GRF ID
+
+STR_NEWGRF_NOT_FOUND                                            :{RED}Matching file not found
+STR_NEWGRF_DISABLED                                             :{RED}Disabled
+STR_NEWGRF_COMPATIBLE_LOADED                                    :{ORANGE}Matching file not found (compatible GRF loaded)
+
+STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Compatible GRF(s) loaded for missing files
+STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Missing GRF file(s) have been disabled
+STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Missing GRF file(s) to be able to load game
+
+STR_CURRENCY_WINDOW                                             :{WHITE}Custom currency
+STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Exchange rate: {ORANGE}{CURRENCY} = £ {COMMA}
+STR_CURRENCY_SEPARATOR                                          :{LTBLUE}Separator:
+STR_CURRENCY_PREFIX                                             :{LTBLUE}Prefix:
+STR_CURRENCY_SUFFIX                                             :{LTBLUE}Suffix:
+STR_CURRENCY_SWITCH_TO_EURO                                     :{LTBLUE}Switch to Euro: {ORANGE}{NUM}
+STR_CURRENCY_SWITCH_TO_EURO_NEVER                               :{LTBLUE}Switch to Euro: {ORANGE}never
+STR_CURRENCY_PREVIEW                                            :{LTBLUE}Preview: {ORANGE}{CURRENCY}
+STR_CURRENCY_CHANGE_PARAMETER                                   :{BLACK}Change custom currency parameter
+
+STR_TRAIN                                                       :{BLACK}{TRAIN}
+STR_BUS                                                         :{BLACK}{BUS}
+STR_LORRY                                                       :{BLACK}{LORRY}
+STR_PLANE                                                       :{BLACK}{PLANE}
+STR_SHIP                                                        :{BLACK}{SHIP}
+
+STR_SCHEDULED_TRAINS                                            :{WHITE}{STATION} - {COMMA} Train{P "" s}
+STR_SCHEDULED_ROAD_VEHICLES                                     :{WHITE}{STATION} - {COMMA} Road Vehicle{P "" s}
+STR_SCHEDULED_AIRCRAFT                                          :{WHITE}{STATION} - {COMMA} Aircraft
+STR_SCHEDULED_SHIPS                                             :{WHITE}{STATION} - {COMMA} Ship{P "" s}
+
+STR_SCHEDULED_TRAINS_TIP                                        :{BLACK}Show all trains which have this station on their schedule
+STR_SCHEDULED_ROAD_VEHICLES_TIP                                 :{BLACK}Show all road vehicles which have this station on their schedule
+STR_SCHEDULED_AIRCRAFT_TIP                                      :{BLACK}Show all aircraft which have this station on their schedule
+STR_SCHEDULED_SHIPS_TIP                                         :{BLACK}Show all ships which have this station on their schedule
+
+STR_VEH_WITH_SHARED_ORDERS_LIST                                 :{WHITE}Shared orders of {COMMA} Vehicle{P "" s}
+STR_VEH_WITH_SHARED_ORDERS_LIST_TIP                             :{BLACK}Show all vehicles which have the same schedule
+
+### depot strings
+STR_DEPOT_SELL_CONFIRMATION_TEXT                                :{YELLOW}You are about to sell all the vehicles in the depot. Are you sure?
+STR_DEPOT_WRONG_DEPOT_TYPE                                      :Wrong depot type
+
+STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TIP                             :{BLACK}Sell all trains in the depot
+STR_DEPOT_SELL_ALL_BUTTON_ROADVEH_TIP                           :{BLACK}Sell all road vehicles in the depot
+STR_DEPOT_SELL_ALL_BUTTON_SHIP_TIP                              :{BLACK}Sell all ships in the depot
+STR_DEPOT_SELL_ALL_BUTTON_AIRCRAFT_TIP                          :{BLACK}Sell all aircraft in the hangar
+
+STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TIP                          :{BLACK}Get a list of all trains with the current depot in their orders
+STR_DEPOT_VEHICLE_ORDER_LIST_ROADVEH_TIP                        :{BLACK}Get a list of all road vehicles with the current depot in their orders
+STR_DEPOT_VEHICLE_ORDER_LIST_SHIP_TIP                           :{BLACK}Get a list of all ships with the current depot in their orders
+STR_DEPOT_VEHICLE_ORDER_LIST_AIRCRAFT_TIP                       :{BLACK}Get a list of all aircraft with any hangar at this airport in their orders
+
+STR_DEPOT_AUTOREPLACE_TRAIN_TIP                                 :{BLACK}Autoreplace all trains in the depot
+STR_DEPOT_AUTOREPLACE_ROADVEH_TIP                               :{BLACK}Autoreplace all road vehicles in the depot
+STR_DEPOT_AUTOREPLACE_SHIP_TIP                                  :{BLACK}Autoreplace all ships in the depot
+STR_DEPOT_AUTOREPLACE_AIRCRAFT_TIP                              :{BLACK}Autoreplace all aircraft in the hangar
+
+STR_VEHICLE_LIST_TRAIN_DEPOT                                    :{BLACK}{STRING} - {COMMA} Train{P "" s}
+STR_VEHICLE_LIST_ROADVEH_DEPOT                                  :{BLACK}{STRING} - {COMMA} Road Vehicle{P "" s}
+STR_VEHICLE_LIST_SHIP_DEPOT                                     :{BLACK}{STRING} - {COMMA} Ship{P "" s}
+STR_VEHICLE_LIST_AIRCRAFT_DEPOT                                 :{BLACK}{STRING} - {COMMA} Aircraft
+
+STR_REPLACE_VEHICLES_WHITE                                      :{WHITE}Replace {STRING}
+STR_REPLACE_VEHICLES_START                                      :{BLACK}Start Replacing Vehicles
+STR_REPLACE_VEHICLES_STOP                                       :{BLACK}Stop Replacing Vehicles
+STR_NOT_REPLACING                                               :{BLACK}Not replacing
+STR_NOT_REPLACING_VEHICLE_SELECTED                              :{BLACK}No vehicle selected
+STR_REPLACE_HELP_LEFT_ARRAY                                     :{BLACK}Select the engine type to replace
+STR_REPLACE_HELP_RIGHT_ARRAY                                    :{BLACK}Select the new engine type you would like to use in place of the left selected engine type
+STR_REPLACE_HELP_STOP_BUTTON                                    :{BLACK}Press to stop the replacement of the engine type selected on the left
+STR_REPLACE_HELP_START_BUTTON                                   :{BLACK}Press to begin replacement of the left selected engine type with the right selected engine type
+STR_REPLACE_HELP_RAILTYPE                                       :{BLACK}Choose the railtype you want to replace engines for
+STR_REPLACE_HELP_REPLACE_INFO_TAB                               :{BLACK}Displays which engine the left selected engine is being replaced with, if any
+STR_REPLACE_HELP                                                :{BLACK}This allows you to replace one engine type with another type, when trains of the original type enter a depot
+STR_REPLACE_REMOVE_WAGON                                        :{BLACK}Car removal: {ORANGE}{SKIP}{STRING}
+STR_REPLACE_REMOVE_WAGON_HELP                                   :{BLACK}Make autoreplace keep the length of a train the same by removing cars (starting at the front), if replacing the engine would make the train longer.
+STR_REPLACE_ENGINE_WAGON_SELECT                                 :{BLACK}Replacing: {ORANGE}{SKIP}{SKIP}{STRING}
+STR_REPLACE_ENGINE_WAGON_SELECT_HELP                            :{BLACK} EXPERIMENTAL FEATURE {}Switch between engine and car replacement windows.{}Car replacement will only be done if the new car can be refitted into carrying the same type of cargo as the old one. This is checked for each car when the actual replacement takes place.
+STR_RAIL_VEHICLE_NOT_AVAILABLE                                  :{WHITE}Vehicle is not available
+STR_ROAD_VEHICLE_NOT_AVAILABLE                                  :{WHITE}Vehicle is not available
+STR_SHIP_NOT_AVAILABLE                                          :{WHITE}Ship is not available
+STR_AIRCRAFT_NOT_AVAILABLE                                      :{WHITE}Aircraft is not available
+
+STR_ENGINES                                                     :Engines
+STR_WAGONS                                                      :Cars
+
+STR_MASS_STOP_DEPOT_TRAIN_TIP                                   :{BLACK}Click to stop all trains inside the depot
+STR_MASS_STOP_DEPOT_ROADVEH_TIP                                 :{BLACK}Click to stop all road vehicles inside the depot
+STR_MASS_STOP_DEPOT_SHIP_TIP                                    :{BLACK}Click to stop all ships inside the depot
+STR_MASS_STOP_HANGAR_TIP                                        :{BLACK}Click to stop all aircraft inside the hangar
+
+STR_MASS_START_DEPOT_TRAIN_TIP                                  :{BLACK}Click to start all trains inside the depot
+STR_MASS_START_DEPOT_ROADVEH_TIP                                :{BLACK}Click to start all the road vehicles inside the depot
+STR_MASS_START_DEPOT_SHIP_TIP                                   :{BLACK}Click to start all ships inside the depot
+STR_MASS_START_HANGAR_TIP                                       :{BLACK}Click to start all aircraft inside the hangar
+
+STR_MASS_STOP_LIST_TIP                                          :{BLACK}Click to stop all vehicles in the list
+STR_MASS_START_LIST_TIP                                         :{BLACK}Click to start all listed vehicles
+
+STR_SHORT_DATE                                                  :{WHITE}{DATE_TINY}
+STR_SIGN_LIST_CAPTION                                           :{WHITE}Sign List - {COMMA} Sign{P "" s}
+
+STR_ORDER_REFIT_FAILED                                          :{WHITE}Order refit failure stopped {STRING} {COMMA}
+
+############ Lists rail types
+
+STR_RAIL_VEHICLES                                               :Rail Vehicles
+STR_ELRAIL_VEHICLES                                             :Electrified Rail Vehicles
+STR_MONORAIL_VEHICLES                                           :Monorail Vehicles
+STR_MAGLEV_VEHICLES                                             :Maglev Vehicles
+
+############ End of list of rail types
+
+STR_TINY_BLACK                                                  :{BLACK}{TINYFONT}{COMMA}
+
+STR_PURCHASE_INFO_COST_WEIGHT                                   :{BLACK}Cost: {GOLD}{CURRENCY}{BLACK} Weight: {GOLD}{WEIGHT_S}
+STR_PURCHASE_INFO_SPEED_POWER                                   :{BLACK}Speed: {GOLD}{VELOCITY}{BLACK}   Power: {GOLD}{POWER}
+STR_PURCHASE_INFO_SPEED                                         :{BLACK}Speed: {GOLD}{VELOCITY}
+STR_PURCHASE_INFO_RUNNINGCOST                                   :{BLACK}Running Cost: {GOLD}{CURRENCY}/yr
+STR_PURCHASE_INFO_CAPACITY                                      :{BLACK}Capacity: {GOLD}{CARGO} {STRING}
+STR_PURCHASE_INFO_DESIGNED_LIFE                                 :{BLACK}Designed: {GOLD}{NUM}{BLACK} Life: {GOLD}{COMMA} years
+STR_PURCHASE_INFO_RELIABILITY                                   :{BLACK}Max. Reliability: {GOLD}{COMMA}%
+STR_PURCHASE_INFO_COST                                          :{BLACK}Cost: {GOLD}{CURRENCY}
+STR_PURCHASE_INFO_WEIGHT_CWEIGHT                                :{BLACK}Weight: {GOLD}{WEIGHT_S}  ({WEIGHT_S})
+STR_PURCHASE_INFO_COST_SPEED                                    :{BLACK}Cost: {GOLD}{CURRENCY}{BLACK} Speed: {GOLD}{VELOCITY}
+STR_PURCHASE_INFO_AIRCRAFT_CAPACITY                             :{BLACK}Capacity: {GOLD}{COMMA} passengers, {COMMA} bags of mail
+STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT                          :{BLACK}Powered Wagons: {GOLD}+{POWER}{BLACK} Weight: {GOLD}+{WEIGHT_S}
+STR_PURCHASE_INFO_REFITTABLE_TO                                 :{BLACK}Refittable to: {GOLD}
+STR_PURCHASE_INFO_ALL_TYPES                                     :All cargo types
+STR_PURCHASE_INFO_ALL_BUT                                       :All but {GOLD}
+STR_PURCHASE_INFO_MAX_TE                                        :{BLACK}Max. Tractive Effort: {GOLD}{FORCE}
+
+########### String for New Landscape Generator
+
+STR_GENERATE                                                    :{WHITE}Generate
+STR_RANDOM                                                      :{BLACK}Randomize
+STR_RANDOM_HELP                                                 :{BLACK}Change the random seed used for Terrain Generation
+STR_WORLD_GENERATION_CAPTION                                    :{WHITE}World generation
+STR_RANDOM_SEED                                                 :{BLACK}Random Seed:
+STR_RANDOM_SEED_HELP                                            :{BLACK}Click to enter a random seed
+STR_LAND_GENERATOR                                              :{BLACK}Land generator:
+STR_TREE_PLACER                                                 :{BLACK}Tree algorithm:
+STR_HEIGHTMAP_ROTATION                                          :{BLACK}Heightmap rotation:
+STR_TERRAIN_TYPE                                                :{BLACK}Terrain type:
+STR_QUANTITY_OF_SEA_LAKES                                       :{BLACK}Sea level:
+STR_SMOOTHNESS                                                  :{BLACK}Smoothness:
+STR_SNOW_LINE_HEIGHT                                            :{BLACK}Snow line height:
+STR_DATE                                                        :{BLACK}Date:
+STR_NUMBER_OF_TOWNS                                             :{BLACK}No. of towns:
+STR_NUMBER_OF_INDUSTRIES                                        :{BLACK}No. of industries:
+STR_GENERATE_DATE                                               :{BLACK}{DATE_LONG}
+STR_SNOW_LINE_UP                                                :{BLACK}Move the snow line height up one
+STR_SNOW_LINE_DOWN                                              :{BLACK}Move the snow line height down one
+STR_SNOW_LINE_QUERY_CAPT                                        :{WHITE}Change snow line height
+STR_START_DATE_QUERY_CAPT                                       :{WHITE}Change starting year
+STR_HEIGHTMAP_SCALE_WARNING_CAPTION                             :{WHITE}Scale warning
+STR_HEIGHTMAP_SCALE_WARNING_MESSAGE                             :{YELLOW}Resizing source map too much is not recommended. Continue with the generation?
+STR_TOWN_LAYOUT_WARNING_CAPTION                                 :{WHITE}Town layout warning
+STR_TOWN_LAYOUT_WARNING_MESSAGE                                 :{YELLOW}The town layout "no more roads" is not recommended. Continue with the generation?
+STR_SNOW_LINE_HEIGHT_NUM                                        :{NUM}
+STR_HEIGHTMAP_NAME                                              :{BLACK}Heightmap name:
+STR_HEIGHTMAP_SIZE                                              :{BLACK}Size: {ORANGE}{NUM} x {NUM}
+STR_GENERATION_WORLD                                            :{WHITE}Generating world...
+STR_GENERATION_ABORT                                            :{BLACK}Cancel
+STR_GENERATION_ABORT_CAPTION                                    :{WHITE}Cancel World Generation
+STR_GENERATION_ABORT_MESSAGE                                    :{YELLOW}Do you really want to cancel the generation?
+STR_PROGRESS                                                    :{WHITE}{NUM}% complete
+STR_GENERATION_PROGRESS                                         :{BLACK}{NUM} / {NUM}
+STR_WORLD_GENERATION                                            :{BLACK}World generation
+STR_TREE_GENERATION                                             :{BLACK}Tree generation
+STR_UNMOVABLE_GENERATION                                        :{BLACK}Unmovable generation
+STR_CLEARING_TILES                                              :{BLACK}Rough and rocky area generation
+STR_SETTINGUP_GAME                                              :{BLACK}Setting up game
+STR_PREPARING_TILELOOP                                          :{BLACK}Running tile-loop
+STR_PREPARING_GAME                                              :{BLACK}Preparing game
+STR_DIFFICULTY_TO_CUSTOM                                        :{WHITE}This action changed the difficulty level to custom
+STR_SE_FLAT_WORLD                                               :{WHITE}Flat land
+STR_SE_FLAT_WORLD_TIP                                           :{BLACK}Generate a flat land
+STR_SE_RANDOM_LAND                                              :{WHITE}Random land
+STR_SE_NEW_WORLD                                                :{BLACK}Create new scenario
+STR_SE_CAPTION                                                  :{WHITE}Scenario type
+STR_FLAT_WORLD_HEIGHT_DOWN                                      :{BLACK}Move the height of flat land down one
+STR_FLAT_WORLD_HEIGHT_UP                                        :{BLACK}Move the height of flat land up one
+STR_FLAT_WORLD_HEIGHT_QUERY_CAPT                                :{WHITE}Change height of flat land
+STR_FLAT_WORLD_HEIGHT                                           :{BLACK}Height of flat land:
+STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
+
+STR_SMALLMAP_CENTER                                             :{BLACK}Center the smallmap on the current position
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
+
+########### String for new airports
+STR_SMALL_AIRPORT                                               :{BLACK}Small
+STR_CITY_AIRPORT                                                :{BLACK}City
+STR_METRO_AIRPORT                                               :{BLACK}Metropolitan airport
+STR_INTERNATIONAL_AIRPORT                                       :{BLACK}International airport
+STR_COMMUTER_AIRPORT                                            :{BLACK}Commuter
+STR_INTERCONTINENTAL_AIRPORT                                    :{BLACK}Intercontinental
+STR_HELIPORT                                                    :{BLACK}Heliport
+STR_HELIDEPOT                                                   :{BLACK}Helidepot
+STR_HELISTATION                                                 :{BLACK}Helistation
+
+STR_SMALL_AIRPORTS                                              :{BLACK}Small airports
+STR_LARGE_AIRPORTS                                              :{BLACK}Large airports
+STR_HUB_AIRPORTS                                                :{BLACK}Hub airports
+STR_HELIPORTS                                                   :{BLACK}Helicopter airports
+
+############ Tooltip measurment
+
+STR_MEASURE_LENGTH                                              :{BLACK}Length: {NUM}
+STR_MEASURE_AREA                                                :{BLACK}Area: {NUM} x {NUM}
+STR_MEASURE_LENGTH_HEIGHTDIFF                                   :{BLACK}Length: {NUM}{}Height difference: {NUM} m
+STR_MEASURE_AREA_HEIGHTDIFF                                     :{BLACK}Area: {NUM} x {NUM}{}Height difference: {NUM} m
+
+############ Date formatting
+STR_DATE_TINY                                                   :{STRING}-{STRING}-{NUM}
+STR_DATE_SHORT                                                  :{STRING} {NUM}
+STR_DATE_LONG                                                   :{STRING} {STRING} {NUM}
+
+########
+
+STR_FEEDER_CARGO_VALUE                                          :{BLACK}Transfer Credits: {LTBLUE}{CURRENCY}
+STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD                            :{WHITE}...this is a town owned road
+STR_DRIVE_THROUGH_ERROR_DIRECTION                               :{WHITE}...road facing in the wrong direction
+
+STR_TRANSPARENCY_TOOLB                                          :{WHITE}Transparency Options
+STR_TRANSPARENT_SIGNS_DESC                                      :{BLACK}Toggle transparency for station signs
+STR_TRANSPARENT_TREES_DESC                                      :{BLACK}Toggle transparency for trees
+STR_TRANSPARENT_HOUSES_DESC                                     :{BLACK}Toggle transparency for houses
+STR_TRANSPARENT_INDUSTRIES_DESC                                 :{BLACK}Toggle transparency for industries
+STR_TRANSPARENT_BUILDINGS_DESC                                  :{BLACK}Toggle transparency for buildables like stations, depots, waypoints and catenary
+STR_TRANSPARENT_BRIDGES_DESC                                    :{BLACK}Toggle transparency for bridges
+STR_TRANSPARENT_STRUCTURES_DESC                                 :{BLACK}Toggle transparency for structures like lighthouses and antennas, maybe in future for eyecandy
+STR_TRANSPARENT_LOADING_DESC                                    :{BLACK}Toggle transparency for loading indicators
+
+STR_PERCENT_UP_SMALL                                            :{TINYFONT}{WHITE}{NUM}%{UPARROW}
+STR_PERCENT_UP                                                  :{WHITE}{NUM}%{UPARROW}
+STR_PERCENT_DOWN_SMALL                                          :{TINYFONT}{WHITE}{NUM}%{DOWNARROW}
+STR_PERCENT_DOWN                                                :{WHITE}{NUM}%{DOWNARROW}
+STR_PERCENT_UP_DOWN_SMALL                                       :{TINYFONT}{WHITE}{NUM}%{UPARROW}{DOWNARROW}
+STR_PERCENT_UP_DOWN                                             :{WHITE}{NUM}%{UPARROW}{DOWNARROW}
+
+##### Mass Order
+STR_GROUP_NAME_FORMAT                                           :Group {COMMA}
+STR_GROUP_TINY_NAME                                             :{TINYFONT}{GROUP}
+STR_GROUP_ALL_TRAINS                                            :All trains
+STR_GROUP_ALL_ROADS                                             :All road vehicles
+STR_GROUP_ALL_SHIPS                                             :All ships
+STR_GROUP_ALL_AIRCRAFTS                                         :All aircraft
+STR_GROUP_DEFAULT_TRAINS                                        :Ungrouped trains
+STR_GROUP_DEFAULT_ROADS                                         :Ungrouped road vehicles
+STR_GROUP_DEFAULT_SHIPS                                         :Ungrouped ships
+STR_GROUP_DEFAULT_AIRCRAFTS                                     :Ungrouped aircraft
+STR_GROUP_TINY_NUM                                              :{TINYFONT}{COMMA}
+STR_GROUP_ADD_SHARED_VEHICLE                                    :Add shared vehicles
+STR_GROUP_REMOVE_ALL_VEHICLES                                   :Remove all vehicles
+
+STR_GROUP_TRAINS_CAPTION                                        :{WHITE}{GROUP} - {COMMA} Train{P "" s}
+STR_GROUP_ROADVEH_CAPTION                                       :{WHITE}{GROUP} - {COMMA} Road Vehicle{P "" s}
+STR_GROUP_SHIPS_CAPTION                                         :{WHITE}{GROUP} - {COMMA} Ship{P "" s}
+STR_GROUP_AIRCRAFTS_CAPTION                                     :{WHITE}{GROUP} - {COMMA} Aircraft
+STR_GROUP_RENAME_CAPTION                                        :{BLACK}Rename a group
+STR_GROUP_REPLACE_CAPTION                                       :{WHITE}Replace Vehicles of "{GROUP}"
+
+STR_GROUP_CAN_T_CREATE                                          :{WHITE}Can't create group...
+STR_GROUP_CAN_T_DELETE                                          :{WHITE}Can't delete this group...
+STR_GROUP_CAN_T_RENAME                                          :{WHITE}Can't rename group...
+STR_GROUP_CAN_T_REMOVE_ALL_VEHICLES                             :{WHITE}Can't remove all vehicles from this group...
+STR_GROUP_CAN_T_ADD_VEHICLE                                     :{WHITE}Can't add the vehicle to this group...
+STR_GROUP_CAN_T_ADD_SHARED_VEHICLE                              :{WHITE}Can't add shared vehicles to group...
+
+STR_GROUPS_CLICK_ON_GROUP_FOR_TIP                               :{BLACK}Groups - Click on a group to list all of its vehicles
+STR_GROUP_CREATE_TIP                                            :{BLACK}Click to create a group
+STR_GROUP_DELETE_TIP                                            :{BLACK}Delete the selected group
+STR_GROUP_RENAME_TIP                                            :{BLACK}Rename the selected group
+STR_GROUP_REPLACE_PROTECTION_TIP                                :{BLACK}Click to protect this group from global autoreplace
+
+STR_COMPANY_NAME                                                :{COMPANY}
+STR_ENGINE_NAME                                                 :{ENGINE}
+STR_GROUP_NAME                                                  :{GROUP}
+STR_PLAYER_NAME                                                 :{PLAYERNAME}
+STR_SIGN_NAME                                                   :{SIGN}
+STR_VEHICLE_NAME                                                :{VEHICLE}
+
+STR_NAME_MUST_BE_UNIQUE                                         :{WHITE}Name must be unique
+
+#### Improved sign GUI
+STR_NEXT_SIGN_TOOLTIP                                           :{BLACK}Go to next sign
+STR_PREVIOUS_SIGN_TOOLTIP                                       :{BLACK}Go to previous sign
+
+########
+
+STR_FUND_NEW_INDUSTRY                                           :{BLACK}Fund
+STR_PROSPECT_NEW_INDUSTRY                                       :{BLACK}Prospect
+STR_BUILD_NEW_INDUSTRY                                          :{BLACK}Build
+STR_INDUSTRY_SELECTION_HINT                                     :{BLACK}Choose the appropriate industry from this list
+
+############ Face formatting
+STR_FACE_ADVANCED                                               :{BLACK}Advanced
+STR_FACE_ADVANCED_TIP                                           :{BLACK}Advanced face selection.
+STR_FACE_SIMPLE                                                 :{BLACK}Simple
+STR_FACE_SIMPLE_TIP                                             :{BLACK}Simple face selection.
+STR_FACE_LOAD                                                   :{BLACK}Load
+STR_FACE_LOAD_TIP                                               :{BLACK}Load favorite face
+STR_FACE_LOAD_DONE                                              :{WHITE}Your favorite face has been loaded from the OpenTTD config file.
+STR_FACE_FACECODE                                               :{BLACK}Player face no.
+STR_FACE_FACECODE_TIP                                           :{BLACK}View and/or set player face number
+STR_FACE_FACECODE_CAPTION                                       :{WHITE}View and/or set player face number
+STR_FACE_FACECODE_SET                                           :{WHITE}New face number code has been set.
+STR_FACE_FACECODE_ERR                                           :{WHITE}Couldn't set player face number - must be numeric between 0 and 4,294,967,295!
+STR_FACE_SAVE                                                   :{BLACK}Save
+STR_FACE_SAVE_TIP                                               :{BLACK}Save favorite face
+STR_FACE_SAVE_DONE                                              :{WHITE}This face will be saved as your favorite in the OpenTTD config file.
+STR_FACE_EUROPEAN                                               :{BLACK}European
+STR_FACE_SELECT_EUROPEAN                                        :{BLACK}Select European faces
+STR_FACE_AFRICAN                                                :{BLACK}African
+STR_FACE_SELECT_AFRICAN                                         :{BLACK}Select African faces
+STR_FACE_YES                                                    :Yes
+STR_FACE_NO                                                     :No
+STR_FACE_MOUSTACHE_EARRING_TIP                                  :{BLACK}Enable mustache or earring
+STR_FACE_HAIR                                                   :Hair:
+STR_FACE_HAIR_TIP                                               :{BLACK}Change hair
+STR_FACE_EYEBROWS                                               :Eyebrows:
+STR_FACE_EYEBROWS_TIP                                           :{BLACK}Change eyebrows
+STR_FACE_EYECOLOUR                                              :Eye color:
+STR_FACE_EYECOLOUR_TIP                                          :{BLACK}Change eyecolor
+STR_FACE_GLASSES                                                :Glasses:
+STR_FACE_GLASSES_TIP                                            :{BLACK}Enable glasses
+STR_FACE_GLASSES_TIP_2                                          :{BLACK}Change glasses
+STR_FACE_NOSE                                                   :Nose:
+STR_FACE_NOSE_TIP                                               :{BLACK}Change nose
+STR_FACE_LIPS                                                   :Lips:
+STR_FACE_MOUSTACHE                                              :Mustache:
+STR_FACE_LIPS_MOUSTACHE_TIP                                     :{BLACK}Change lips or mustache
+STR_FACE_CHIN                                                   :Chin:
+STR_FACE_CHIN_TIP                                               :{BLACK}Change chin
+STR_FACE_JACKET                                                 :Jacket:
+STR_FACE_JACKET_TIP                                             :{BLACK}Change jacket
+STR_FACE_COLLAR                                                 :Collar:
+STR_FACE_COLLAR_TIP                                             :{BLACK}Change collar
+STR_FACE_TIE                                                    :Tie:
+STR_FACE_EARRING                                                :Earring:
+STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Change tie or earring
+########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Signal Selection
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Can't convert signals here...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standard Signal (semaphore){}Signals are necessary to keep trains from crashing on railway networks with more than one train.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Entry-Signal (semaphore){}Green as long as there is one or more green exit-signal from the following section of track. Otherwise it shows red.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Exit-Signal (semaphore){}Behaves in the same way as a normal signal but is necessary to trigger the correct color on entry & combo pre-signals.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Combo-Signal (semaphore){}The combo signal simply acts as both an entry and exit signal. This allows you to build large "trees" of presignals.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standard Signal (electric){}Signals are necessary to keep trains from crashing on railway networks with more than one train.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Entry-Signal (electric){}Green as long as there is one or more green exit-signal from the following section of track. Otherwise it shows red.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Exit-Signal (electric){}Behaves in the same way as a normal signal but is necessary to trigger the correct color on entry & combo pre-signals.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Combo-Signal (electric){}The combo signal simply acts as both an entry and exit signal. This allows you to build large "trees" of presignals.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Signal Convert{}When selected, clicking an existing signal will convert it to the selected signal type and variant, CTRL-click will toggle the existing variant.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Dragging signal density
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Decrease dragging signal density
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Increase dragging signal density
+########
--- a/src/lang/esperanto.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/esperanto.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -161,7 +161,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Ne eblas malplenigi la regionon....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Origina kopirajto {COPYRIGHT} 1995 Chris Sawyer, Ĉiuj rajtoj rezervitaj
 STR_00B7_VERSION                                                :{BLACK}OpenTTD-versio {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 La teamo de OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 La teamo de OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Tradukanto(j) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -2189,7 +2189,7 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Relokigu HQ
 STR_COMPANY_PASSWORD                                            :{BLACK}Pasvorto
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Pasvorte protektu vian kompanion por eviti ke eksteruloj aliĝu.
-STR_SET_COMPANY_PASSWORD                                        :Agordu kompanian pasvorton
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Agordu kompanian pasvorton
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Monda Recesio!{}{}Financaj spertuloj timas ke malpliboniĝas treege! Ekonomio malboniĝadas!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recesio finiĝis!{}{}Komerca pliboniĝos donas konfidon al industrioj! Ekonomio pliboniĝas!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Ŝaltu inter granda kaj malgranda fenestro
--- a/src/lang/estonian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/estonian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -260,7 +260,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Seda ala ei saa puhastada....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Algupärane autorikaitse {COPYRIGHT} 1995 Chris Sawyer, kõik õigused kaitstud
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versioon {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD meeskond
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD meeskond
 STR_TRANSLATED_BY                                               :{BLACK}  Tõlgi(d) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -370,7 +370,7 @@
 STR_012D                                                        :{WHITE}{STRING}
 STR_012E_CANCEL                                                 :{BLACK}Loobu
 STR_012F_OK                                                     :{BLACK}OK
-STR_0130_RENAME                                                 :{BLACK}Muuda nime
+STR_0130_RENAME                                                 :{BLACK}Nime muutmine
 STR_0131_TOO_MANY_NAMES_DEFINED                                 :{WHITE}Liiga palju määratletud nimesid
 STR_0132_CHOSEN_NAME_IN_USE_ALREADY                             :{WHITE}Valitud nimi on juba kasutusel
 
@@ -393,8 +393,8 @@
 STR_013F_TOTAL_CAPACITY_TEXT                                    :{BLACK}Selle rongi kandevõime:
 STR_013F_TOTAL_CAPACITY                                         :{LTBLUE}- {CARGO} ({SHORTCARGO})
 STR_TOTAL_CAPACITY_MULT                                         :{LTBLUE}- {CARGO} ({SHORTCARGO}) (x{NUM})
-STR_0140_NEW_GAME                                               :{BLACK}Alusta mängu
-STR_0141_LOAD_GAME                                              :{BLACK}Laadi mängu
+STR_0140_NEW_GAME                                               :{BLACK}Uus mäng
+STR_0141_LOAD_GAME                                              :{BLACK}Mängu laadimine
 STR_SINGLE_PLAYER                                               :{BLACK}Üksikmängija
 STR_MULTIPLAYER                                                 :{BLACK}Võrgumäng
 STR_SCENARIO_EDITOR                                             :{BLACK}Stsenaariumiredaktor
@@ -468,7 +468,7 @@
 STR_SORT_CRITERIA_TIP                                           :{BLACK}Sorteerimistingimuse valimine
 STR_SORT_BY                                                     :{BLACK}Sorteeri:
 
-STR_SORT_BY_POPULATION                                          :{BLACK}Rahvastik
+STR_SORT_BY_POPULATION                                          :{BLACK}Rahvaarv
 STR_SORT_BY_PRODUCTION                                          :{BLACK}Toodang
 STR_SORT_BY_TYPE                                                :{BLACK}Tüüp
 STR_SORT_BY_TRANSPORTED                                         :{BLACK}Veetud
@@ -694,6 +694,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Ettevõtte teave
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Tööstuste avamised ja sulgemised
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Muutused majanduses
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Mängija poolt teenindavate tööstuste toodangumuutused
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Konkurentide poolt teenindavate tööstuste toodangumuutused
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Ülejäänud tööstuste toodangumuutused
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Soovitused ja teated mängija veovahendite kohta
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Uus veerem
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Veoste vastuvõtutingimuste muutumine
@@ -840,8 +843,8 @@
 STR_0297_SAVE_SCENARIO_LOAD_SCENARIO                            :{BLACK}Kaardi salvestamine, kaardi laadimine, kaarditegemisest lahkumine, mängust väljumine
 STR_0298_LOAD_SCENARIO                                          :{WHITE}Laadi stsenaariumit
 STR_0299_SAVE_SCENARIO                                          :{WHITE}Salvesta stsenaarium
-STR_029A_PLAY_SCENARIO                                          :{BLACK}Mängi stsenaariumit
-STR_PLAY_HEIGHTMAP                                              :{BLACK}Mängi kõrguskaardil
+STR_029A_PLAY_SCENARIO                                          :{BLACK}Stsenaariumi mängimine
+STR_PLAY_HEIGHTMAP                                              :{BLACK}Kõrguskaardil mängimine
 STR_PLAY_HEIGHTMAP_HINT                                         :{BLACK}Alusta uut mängu kasutades kõrguskaarti maastikuna
 STR_QUIT_SCENARIO_QUERY                                         :{YELLOW}Kas sa oled kindel, et sa tahad kaardi tegemise lõpetada?
 STR_029C_QUIT_EDITOR                                            :{WHITE}Lahku redaktorist
@@ -875,7 +878,7 @@
 ############ range for menu starts
 STR_02C3_GAME_OPTIONS                                           :Mängu valikud
 STR_02C5_DIFFICULTY_SETTINGS                                    :Raskusastme seadistused
-STR_02C7_CONFIG_PATCHES                                         :Seadista paikasid
+STR_02C7_CONFIG_PATCHES                                         :Paikade seadistamine
 STR_NEWGRF_SETTINGS                                             :NewGRF seadistused
 STR_TRANSPARENCY_OPTIONS                                        :Läbipaistvuse valikud
 STR_GAMEOPTMENU_0A                                              :
@@ -967,7 +970,7 @@
 STR_0319_PAUSED                                                 :{YELLOW}* *  PEATUS  *  *
 
 STR_031B_SCREENSHOT_SUCCESSFULLY                                :{WHITE}Ekraanitõmmis edukalt salvestatud nimega '{STRING}'
-STR_031C_SCREENSHOT_FAILED                                      :{WHITE}Ekraanitõmmise tegemine ebaõnnestus!
+STR_031C_SCREENSHOT_FAILED                                      :{WHITE}Ekraanitõmmise võtmine nurjus!
 
 STR_0329_PURCHASE_LAND_FOR_FUTURE                               :{BLACK}Maa ostmine tulevaseks kasutamiseks
 STR_032F_AUTOSAVE                                               :{RED}AUTOMAATSALVESTUS
@@ -1038,6 +1041,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Täisekraan
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Märgi see kast, et OpenTTD täisekraanirežiimis mängida
+STR_FULLSCREEN_FAILED                                           :{WHITE}Täisekraanrežiim ebaõnnestus
 
 STR_OPTIONS_RES                                                 :{BLACK}Ekraanilahutus
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1048,7 +1052,7 @@
 STR_OPTIONS_SCREENSHOT_FORMAT_TIP                               :{BLACK}Vali kasutatav ekraanipildi vorming
 
 STR_AUTOSAVE_1_MONTH                                            :Iga kuu
-STR_AUTOSAVE_FAILED                                             :{WHITE}Isesalvestus ebaõnnestus
+STR_AUTOSAVE_FAILED                                             :{WHITE}Automaatne salvestus nurjus
 
 STR_MONTH_JAN                                                   :Jaanuar
 STR_MONTH_FEB                                                   :Veebruar
@@ -1107,19 +1111,19 @@
 STR_AIRCRAFT_HAS_INVALID_ENTRY                                  :{WHITE}Õhusõiduki {COMMA} sõidugraafikus on kehtetu jaam
 # end of order system
 
-STR_TRAIN_AUTORENEW_FAILED                                      :{WHITE}Rongi iseuuendamine {COMMA} ebaõnnestus (rahapiirang)
-STR_ROADVEHICLE_AUTORENEW_FAILED                                :{WHITE}Mootorsõiduki iseuuendamine ebaõnnestus {COMMA} (rahapiirang)
-STR_SHIP_AUTORENEW_FAILED                                       :{WHITE}Laeva iseuuendamine ebaõnnestus {COMMA} (rahapiirang)
-STR_AIRCRAFT_AUTORENEW_FAILED                                   :{WHITE}Õhusõiduki iseuuendamine ebaõnnestus{COMMA} (rahapiirang)
+STR_TRAIN_AUTORENEW_FAILED                                      :{WHITE}Rongi {COMMA} automaatne uuendamine nurjus (rahapiirang)
+STR_ROADVEHICLE_AUTORENEW_FAILED                                :{WHITE}Mootorsõiduki {COMMA} automaatne uuendamine nurjus (rahapiirang)
+STR_SHIP_AUTORENEW_FAILED                                       :{WHITE}Laeva {COMMA} automaatne uuendamine nurjus (rahapiirang)
+STR_AIRCRAFT_AUTORENEW_FAILED                                   :{WHITE}Õhusõiduki iseuuendamine nurjus{COMMA} (rahapiirang)
 STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT                            :{WHITE}Rong {COMMA} on peale asendust liiga pikk
 
-STR_CONFIG_PATCHES                                              :{BLACK}Seadista paikasid
-STR_CONFIG_PATCHES_TIP                                          :{BLACK}Seadista paikasid
-STR_CONFIG_PATCHES_CAPTION                                      :{WHITE}Seadista paikasid
+STR_CONFIG_PATCHES                                              :{BLACK}Paikade seadistamine
+STR_CONFIG_PATCHES_TIP                                          :{BLACK}Paikade seadistamine
+STR_CONFIG_PATCHES_CAPTION                                      :{WHITE}Paikade seadistamine
 
 STR_CONFIG_PATCHES_OFF                                          :Väljas
 STR_CONFIG_PATCHES_ON                                           :Sees
-STR_CONFIG_PATCHES_VEHICLESPEED                                 :{LTBLUE}Näita olekuribal veovahendi kiirust: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_VEHICLESPEED                                 :{LTBLUE}Olekuribal näidatakse veovahendi kiirust: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BUILDONSLOPES                                :{LTBLUE}Luba ehitised nõlvadele ja kallastele: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_AUTOSLOPE                                    :{LTBLUE}Võimalda maastikujunduse teostust majade, rööbaste jms. all (autoslope): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_CATCHMENT                                    :{LTBLUE}Võimalda reaalsemaid veekogu alasid: {ORANGE}{STRING}
@@ -1141,12 +1145,12 @@
 STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_PROSPECTING :uurides
 STR_CONFIG_PATCHES_MULTIPINDTOWN                                :{LTBLUE}Luba mitu sama liiki tööstust linna kohta: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_SAMEINDCLOSE                                 :{LTBLUE}Sama liiki tööstusi saab ehitada üksteise lähedale: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_LONGDATE                                     :{LTBLUE}Alati näita olekuribal pikka kuupäeva: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LONGDATE                                     :{LTBLUE}Olekuribal näidatakse alati täispikka kuupäeva: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_SIGNALSIDE                                   :{LTBLUE}Paiguta signaalid rööbasteele sõidusuunda arvestades: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SHOWFINANCES                                 :{LTBLUE}Näita rahaliste seisude akent iga aasta lõpus: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SHOWFINANCES                                 :{LTBLUE}Aasta lõpus näidatakse rahavoogude aruannet: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NEW_NONSTOP                                  :{LTBLUE}TTDPatchiga ühilduv 'mittepeatumine': {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ROADVEH_QUEUE                                :{LTBLUE}Mootorsõidukite järjekorrad (koos mahueffektidega): {ORANGE}{STRING}
-STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Keri vaadet, kui hiir on viidud ekraani serva: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Kursori ekraani serva viimisel keritakse vaadet: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Luba kohalikule omavalitsusele altkäemaksu maksmine: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Luba eksklusiivseid veoõiguseid osta: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Luba teistele ettevõtetele raha saata: {ORANGE}{STRING}
@@ -1169,7 +1173,7 @@
 STR_CONFIG_PATCHES_AUTORENEW_MONTHS                             :{LTBLUE}Uuenda {ORANGE}{STRING}{LTBLUE} kuud enne/pärast veovahendi suurimat vanust
 STR_CONFIG_PATCHES_AUTORENEW_MONEY                              :{LTBLUE}Iseuuendusele kuluv väikseim summa: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ERRMSG_DURATION                              :{LTBLUE}Veateate kuvamise kestus: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_POPULATION_IN_LABEL                          :{LTBLUE}Näita linna nimesildil rahvaarvu: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_POPULATION_IN_LABEL                          :{LTBLUE}Linna nimesildil näidatakse rahvaarvu: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_INVISIBLE_TREES                              :{LTBLUE}Nähtamatud puud (läbipaistvate ehitistega): {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_LAND_GENERATOR                               :{LTBLUE}Maaala Generaator: {ORANGE}{STRING}
@@ -1194,15 +1198,15 @@
 STR_CONFIG_PATCHES_STATION_SPREAD                               :{LTBLUE}Suurim jaama ala: {ORANGE}{STRING} {RED}Hoiatus: kõrged seadistused aeglustavad mängu
 STR_CONFIG_PATCHES_SERVICEATHELIPAD                             :{LTBLUE}Hoolda maandumisplatsidel ise helikoptereid: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR                       :{LTBLUE}Liida maastikuriba raudtee/tee/vee/lennujaamade tööriistaribaga: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_REVERSE_SCROLLING                            :{LTBLUE}Kui kerid hiirega, liiguta vaade vastassuunda: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SMOOTH_SCROLLING                             :{LTBLUE}Sujuv vaatevälja liigutamine: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MEASURE_TOOLTIP                              :{LTBLUE}Näita mitmesuguste ehitusvahendite kasutamisel mõõtmise kohtspikrit: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_REVERSE_SCROLLING                            :{LTBLUE}Vaadet keritakse vastassuunas: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SMOOTH_SCROLLING                             :{LTBLUE}Vaatevälja liigutatakse sujuvalt: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MEASURE_TOOLTIP                              :{LTBLUE}Mitmete ehitusvahendite kasutamisel näidatakse mõõtmise kohtspikrit: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LIVERIES                                     :{LTBLUE}Näita firma livree: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LIVERIES_NONE                                :Mitte ükski
-STR_CONFIG_PATCHES_LIVERIES_OWN                                 :Enda firma
-STR_CONFIG_PATCHES_LIVERIES_ALL                                 :Kõik Firmad
-STR_CONFIG_PATCHES_PREFER_TEAMCHAT                              :{LTBLUE}Eelista Meeskonnajututuba <ENTER>i vajutamisega: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING                        :{LTBLUE}Kerimisratta funktsioon: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LIVERIES_OWN                                 :Enda ettevõte
+STR_CONFIG_PATCHES_LIVERIES_ALL                                 :Kõik ettevõtted
+STR_CONFIG_PATCHES_PREFER_TEAMCHAT                              :{LTBLUE}Vajutades <ENTER> eelistatakse meeskonna jututuba: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING                        :{LTBLUE}Kerimisrulliku otstarve: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_SCROLLWHEEL_ZOOM                             :Suurenda kaarti
 STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLL                           :Keri kaarti
 STR_CONFIG_PATCHES_SCROLLWHEEL_OFF                              :Väljas
@@ -1266,6 +1270,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Luba teiste ettevõtete aktsiate ostmine
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Venitades rajatavate signaalide paigutustihedus: {ORANGE}{STRING} ühik(ut)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Ehita ise semaforid enne: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Näita signalisatsiooni GUI-d: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Stsenaariumiredaktor ei tunnista "ilma teedeta" linnaplaneeringut
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Vali linnale teedeplaneering: {ORANGE}{STRING}
@@ -1382,7 +1387,7 @@
 STR_LANDINFO_COORDS                                             :{BLACK}Koordinaadid: {LTBLUE}{NUM}x{NUM}x{NUM} ({STRING})
 
 STR_CANT_REMOVE_PART_OF_STATION                                 :{WHITE}Siinset jaamablokki ei saa lammutada...
-STR_CANT_CONVERT_RAIL                                           :{WHITE}Siin ei saa raudteetüüpi muuta...
+STR_CANT_CONVERT_RAIL                                           :{WHITE}Siin ei saa raudtee tüüpi muuta...
 STR_CONVERT_RAIL_TIP                                            :{BLACK}Muuda/uuenda rööpaliiki
 
 STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP                                :{BLACK}Tõsta vedur siia, et kogu rong maha müüa
@@ -1596,10 +1601,10 @@
 STR_NETWORK_ERR_NOTAVAILABLE                                    :{WHITE} Võrgukaarti ei leitud või kompileeritud ilma võtmeta ENABLE_NETWORK
 STR_NETWORK_ERR_NOSERVER                                        :{WHITE} Ei leidnud ühtegi võrgumängu
 STR_NETWORK_ERR_NOCONNECTION                                    :{WHITE} Server ei vastanud päringule
-STR_NETWORK_ERR_NEWGRF_MISMATCH                                 :{WHITE} Ühendus ebaõnnestus NewGRF-i kokkusobimatuse tõttu
+STR_NETWORK_ERR_NEWGRF_MISMATCH                                 :{WHITE} Ühendus nurjus NewGRF-i kokkusobimatuse tõttu
 STR_NETWORK_ERR_DESYNC                                          :{WHITE} Võrgumäng läks sünkroonist välja
 STR_NETWORK_ERR_LOSTCONNECTION                                  :{WHITE} Võrgumängu ühendus katkes
-STR_NETWORK_ERR_SAVEGAMEERROR                                   :{WHITE} Mängu laadimine ebaõnnestus
+STR_NETWORK_ERR_SAVEGAMEERROR                                   :{WHITE} Mängu laadimine nurjus
 STR_NETWORK_ERR_SERVER_START                                    :{WHITE} Ei saa uut serverit alustada
 STR_NETWORK_ERR_CLIENT_START                                    :{WHITE} Ei õnneust ühendada
 STR_NETWORK_ERR_TIMEOUT                                         :{WHITE} Ühendusel #{NUM} sai aeg otsa
@@ -1703,7 +1708,7 @@
 STR_1005_NO_SUITABLE_RAILROAD_TRACK                             :{WHITE}Sobiv rongitee puudub
 STR_1007_ALREADY_BUILT                                          :{WHITE}...juba ehitatud
 STR_1008_MUST_REMOVE_RAILROAD_TRACK                             :{WHITE}Rööbastee tuleb eelnevalt lammutada
-STR_100A_RAILROAD_CONSTRUCTION                                  :{WHITE}Rööbastee ehitamine
+STR_100A_RAILROAD_CONSTRUCTION                                  :{WHITE}Rööbasteede ehitus
 STR_TITLE_ELRAIL_CONSTRUCTION                                   :{WHITE}Elektrifitseeritud rööbastee ehitus
 STR_100B_MONORAIL_CONSTRUCTION                                  :{WHITE}Monorelsi ehitamine
 STR_100C_MAGLEV_CONSTRUCTION                                    :{WHITE}Elektromageetilise rööbastee ehitamine
@@ -1780,6 +1785,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Ehita trammisild
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Ehita tunnel
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Ehita trammitunnel
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Lülita ühesuunalised teed sisse/välja
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Tee-ehituse ja -lammutamise vahetamine
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Lülitu trammitee ehitamise ja lammutamise vahel
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Vali depoole suund
@@ -1801,9 +1807,10 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Ehitis tuleb eelnevalt hävitada
 STR_2005                                                        :{WHITE}{TOWN}
-STR_2006_POPULATION                                             :{BLACK}Rahvastik: {ORANGE}{COMMA}{BLACK}  Ehitisi: {ORANGE}{COMMA}
+STR_2006_POPULATION                                             :{BLACK}Rahvaarv: {ORANGE}{COMMA}{BLACK}  Ehitisi: {ORANGE}{COMMA}
 STR_2007_RENAME_TOWN                                            :Linnanime muutmine
 STR_2008_CAN_T_RENAME_TOWN                                      :{WHITE}Linnanime ei saa muuta...
 STR_2009_LOCAL_AUTHORITY_REFUSES                                :{WHITE}{TOWN} kohalik omavalitsus keeldub seda lubamast
@@ -2005,7 +2012,7 @@
 STR_STAT_CLASS_WAYP                                             :Meldepunktid
 
 ##id 0x3800
-STR_3800_SHIP_DEPOT_ORIENTATION                                 :{WHITE}Paadikuuri Orientatsioon
+STR_3800_SHIP_DEPOT_ORIENTATION                                 :{WHITE}Laevaangaari suund
 STR_3801_MUST_BE_BUILT_ON_WATER                                 :{WHITE}...peab ehitama vette
 STR_3802_CAN_T_BUILD_SHIP_DEPOT                                 :{WHITE}Siia ei saa laevaangaari ehitada...
 STR_3803_SELECT_SHIP_DEPOT_ORIENTATION                          :{BLACK}Laevaangaarile suuna valimine
@@ -2023,9 +2030,9 @@
 STR_4004                                                        :{COMPANY}, {DATE_LONG}
 STR_4005_BYTES_FREE                                             :{BLACK}{COMMA} megabaiti{P "" i} vaba
 STR_4006_UNABLE_TO_READ_DRIVE                                   :{BLACK}Ei suuda kettalt lugeda
-STR_4007_GAME_SAVE_FAILED                                       :{WHITE}Mängu salvestamine ebaõnnestus{}{STRING}
+STR_4007_GAME_SAVE_FAILED                                       :{WHITE}Mängu salvestamine nurjus{}{STRING}
 STR_4008_UNABLE_TO_DELETE_FILE                                  :{WHITE}Faili ei saa kustutada
-STR_4009_GAME_LOAD_FAILED                                       :{WHITE}Mängu laadimine ebaõnnestus{}{STRING}
+STR_4009_GAME_LOAD_FAILED                                       :{WHITE}Mängu laadimine nurjus{}{STRING}
 STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR                   :Süsteemi viga: {STRING}
 STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME                         :Katkine salvestus - {STRING}
 STR_GAME_SAVELOAD_ERROR_TOO_NEW_SAVEGAME                        :Salvestus on tehtud uuemas versioonis
@@ -2227,7 +2234,7 @@
 ############ range for difficulty settings starts
 STR_6805_MAXIMUM_NO_COMPETITORS                                 :{LTBLUE}Suurim konkurentide arv: {ORANGE}{COMMA}
 STR_6806_COMPETITOR_START_TIME                                  :{LTBLUE}Konkurentide tulemise aeg: {ORANGE}{STRING}
-STR_6807_NO_OF_TOWNS                                            :{LTBLUE}Linnade arv: {ORANGE}{STRING}
+STR_6807_NO_OF_TOWNS                                            :{LTBLUE}Linnade sagedus: {ORANGE}{STRING}
 STR_6808_NO_OF_INDUSTRIES                                       :{LTBLUE}Tööstuste arv: {ORANGE}{STRING}
 STR_6809_MAXIMUM_INITIAL_LOAN_000                               :{LTBLUE}Suurim alustuslaen: {ORANGE}{CURRENCY}
 STR_680A_INITIAL_INTEREST_RATE                                  :{LTBLUE}Intress alguses: {ORANGE}{COMMA}%
@@ -2404,7 +2411,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Liiguta peakorterit
 STR_COMPANY_PASSWORD                                            :{BLACK}Salasõna
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Ettevõtte kaitsmine salasõnaga, et võõrad ei saaks ilma loata ühineda.
-STR_SET_COMPANY_PASSWORD                                        :Vali ettevõttele salasõna
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Vali ettevõttele salasõna
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Sisestatud salasõna ei salvestata
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Määra ettevõtte uus salasõna
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Ettevõtte salasõna
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Vaikimisi määratud ettevõtte salasõna
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Kasuta selle ettevõtte salasõna uute ettevõtete vaikimisi määratud salasõnana
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Majanduslik tagasilöök!{}{}Finantseksperdid ennustavad suurt majanduslangust!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Madalseis on läbi!{}{}Suurem kauplemine julgustab majanduse tugevnemisega ettevõtteid!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Lülita aken suureks/väikseks
@@ -2713,7 +2725,7 @@
 STR_8103_ROAD_VEHICLE                                           :mootorsõiduk
 STR_8104_AIRCRAFT                                               :lennuk
 STR_8105_SHIP                                                   :laev
-STR_8106_MONORAIL_LOCOMOTIVE                                    :monorelsivedur
+STR_8106_MONORAIL_LOCOMOTIVE                                    :monorelssvedur
 STR_8107_MAGLEV_LOCOMOTIVE                                      :maglevivedur
 
 ##id 0x8800
@@ -2765,20 +2777,20 @@
 STR_881A_TRAINS_CAN_ONLY_BE_ALTERED                             :{WHITE}Ronge saab ainult siis muuta kui nad on peatatud depoo sees
 STR_881B_TRAINS                                                 :{WHITE}{COMPANY} - {COMMA} rong{P "" i}
 
-STR_881C_NEW_RAIL_VEHICLES                                      :{WHITE}Uus raudteeveerem
+STR_881C_NEW_RAIL_VEHICLES                                      :{WHITE}Uued rööbassõidukid
 STR_NEW_ELRAIL_VEHICLES                                         :{WHITE}Uus elektriraudteeveerem
 STR_881D_NEW_MONORAIL_VEHICLES                                  :{WHITE}Uued monorelsi sõidukid
 STR_881E_NEW_MAGLEV_VEHICLES                                    :{WHITE}Uus maglevi sõiduk
-STR_ALL_AVAIL_RAIL_VEHICLES                                     :{WHITE}Raudteesõidukid
+STR_ALL_AVAIL_RAIL_VEHICLES                                     :{WHITE}Rööbassõidukid
 
 STR_881F_BUILD_VEHICLE                                          :{BLACK}Ehita veovahend
-STR_CLONE_ROAD_VEHICLE                                          :{BLACK}Klooni veovahendit
+STR_CLONE_ROAD_VEHICLE                                          :{BLACK}Kloonimine
 STR_CLONE_ROAD_VEHICLE_INFO                                     :{BLACK}See paljundab mootorsõidukit. CTRL-klõps jagab sihtpunkte
 STR_CLONE_ROAD_VEHICLE_DEPOT_INFO                               :{BLACK}See paljundab mootorsõidukit. Klõpsa seda nuppu, ning seejärel mootorsõidukil depoos või sellest väljas. CTRL-klõps jagab sihtpunkte
 STR_CLONE_TRAIN                                                 :{BLACK}Klooni rong
 STR_CLONE_TRAIN_INFO                                            :{BLACK}See ehitab koopia rongist koos kõikide vagunitega. CTRL-klikk jagab sihtpunkte
 STR_CLONE_TRAIN_DEPOT_INFO                                      :{BLACK}See ehitab koopia rongist koos kõikide vagunitega. Vajuta sellele nuppule, ning seejärel rongile depoo sees või väljas. CTRL-klikk jagab sihtpunkte
-STR_8820_RENAME                                                 :{BLACK}Muuda nime
+STR_8820_RENAME                                                 :{BLACK}Nime muutmine
 STR_8823_SKIP                                                   :{BLACK}Jäta vahele
 STR_8824_DELETE                                                 :{BLACK}Kustuta
 STR_8825_NON_STOP                                               :{BLACK}Peatusteta
@@ -2794,7 +2806,7 @@
 STR_882A_END_OF_ORDERS                                          :{SETX 10}- - Käskude Lõpp - -
 STR_FULLLOAD_OR_SERVICE                                         :{SKIP}{SKIP}{STRING}
 STR_SERVICE                                                     :{BLACK}Hooldus
-STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE                           :{WHITE}Raudteesõidukit ei saa ehitada...
+STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE                           :{WHITE}Rööbassõidukit ei saa ehitada...
 STR_882C_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Ehitatud: {LTBLUE}{NUM}{BLACK} Väärtus: {LTBLUE}{CURRENCY}
 STR_882D_VALUE                                                  :{LTBLUE}{ENGINE}{BLACK}   Väärtus: {LTBLUE}{CURRENCY}
 STR_882E                                                        :{WHITE}{VEHICLE}
@@ -2812,7 +2824,7 @@
 STR_8837_CAN_T_MOVE_VEHICLE                                     :{WHITE}Transpordivahendit ei saa liigutada...
 STR_REAR_ENGINE_FOLLOW_FRONT_ERROR                              :{WHITE}Tagumine vedur järgneb alati eesmisele
 STR_8838_N_A                                                    :N/A{SKIP}
-STR_8839_CAN_T_SELL_RAILROAD_VEHICLE                            :{WHITE}Raudteesõidukit ei saa müüa...
+STR_8839_CAN_T_SELL_RAILROAD_VEHICLE                            :{WHITE}Rööbassõidukit ei saa müüa...
 STR_883A_UNABLE_TO_FIND_ROUTE_TO                                :{WHITE}Ei leia teed kohalikku depoosse
 STR_883B_CAN_T_STOP_START_TRAIN                                 :{WHITE}Ei saa peatada/startida rongi...
 STR_883C_SERVICING_INTERVAL_DAYS                                :{BLACK}Hooldusperiood: {LTBLUE}{COMMA} päeva{BLACK}  Viimati hooldatud: {LTBLUE}{DATE_LONG}
@@ -2885,6 +2897,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Uus {STRING} saadaval!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Hävinenud sõidukit ei saa müüa...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Hävitatud sõidukit pole võimalik ümber seadistada...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Sõidukile ei saa sõiduplaani anda...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Sõidukid saavad ainult peatustes oodata.
@@ -2903,7 +2916,7 @@
 STR_9001_ROAD_VEHICLES                                          :{WHITE}{COMPANY} - {COMMA} mootorsõiduk{P "" it}
 STR_9002                                                        :{WHITE}{VEHICLE}
 STR_9003_ROAD_VEHICLE_DEPOT                                     :{WHITE}Linna {TOWN} mootorsõidukidepoo
-STR_9004_NEW_VEHICLES                                           :{BLACK}Uus mootorsõiduk
+STR_9004_NEW_VEHICLES                                           :{BLACK}Ostmine
 STR_9006_NEW_ROAD_VEHICLES                                      :{WHITE}Uued mootorsõidukid
 STR_9007_BUILD_VEHICLE                                          :{BLACK}Ehita veovahend
 STR_9009_CAN_T_BUILD_ROAD_VEHICLE                               :{WHITE}Mootorsõidukit ei saa ehitada...
@@ -2922,8 +2935,8 @@
 STR_HEADING_FOR_ROAD_DEPOT_VEL                                  :{ORANGE}Suundub {TOWN} garaaþi, {VELOCITY}
 STR_HEADING_FOR_ROAD_DEPOT_SERVICE                              :{LTBLUE}Hooldus linna {TOWN} depoos
 STR_HEADING_FOR_ROAD_DEPOT_SERVICE_VEL                          :{LTBLUE}Hooldus linna {TOWN} depoos, {VELOCITY}
-STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT                            :{WHITE}Ei saa veokit garaaþi saata
-STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT                             :{WHITE}Ei leia kohalikku garaaþi üles
+STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT                            :{WHITE}Ei saa veokit garaaži saata
+STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT                             :{WHITE}Ei leia kohalikku garaaži üles
 STR_901A_ROAD_VEHICLES_CLICK_ON                                 :{BLACK}Veokid - info saamiseks vajuta veokile
 STR_901B_BUILD_NEW_ROAD_VEHICLES                                :{BLACK}Osta uus veok (vajab garaaþi)
 STR_901C_CURRENT_VEHICLE_ACTION                                 :{BLACK}Transpordivahendi praegune tegevus - selle peatamiseks või startimiseks klõpsa siia
@@ -2953,11 +2966,11 @@
 STR_9032_ROAD_VEHICLE_CRASH_DIE                                 :{BLACK}{BIGFONT}Mootorsõiduki kokkupõrge rongiga!{}{COMMA} inimest suri õnnetuses
 STR_9033_CAN_T_MAKE_VEHICLE_TURN                                :{WHITE}Transpordivahendit ei saa ümber pöörata...
 STR_ONLY_TURN_SINGLE_UNIT                                       :{WHITE}Mitmest osast koosnevaid veovahendeid ei saa ümber pöörata
-STR_9034_RENAME                                                 :{BLACK}Muuda nime
+STR_9034_RENAME                                                 :{BLACK}Nime muutmine
 STR_9035_RENAME_ROAD_VEHICLE_TYPE                               :{BLACK}Muuda mootorsõiduki tüübinime
 STR_9036_RENAME_ROAD_VEHICLE_TYPE                               :{WHITE}Muuda mootorsõiduki tüübinime
 STR_9037_CAN_T_RENAME_ROAD_VEHICLE                              :{WHITE}Mootorsõiduki tüübinime ei saa muuta...
-STR_9038_GO_TO_ROADVEH_DEPOT                                    :Mine linna {TOWN} garaaþi
+STR_9038_GO_TO_ROADVEH_DEPOT                                    :Mine linna {TOWN} garaaži
 STR_SERVICE_AT_ROADVEH_DEPOT                                    :Hoolda linna {TOWN} mootorsõidukidepoos
 
 STR_REFIT_ROAD_VEHICLE_TO_CARRY                                 :{BLACK}Seadista mootorsõidukit kandmaks teist tüüpi veost
@@ -2970,7 +2983,7 @@
 STR_9800_DOCK_CONSTRUCTION                                      :Sadamaehitus
 STR_9801_DOCK_CONSTRUCTION                                      :{WHITE}Sadama ehitus
 STR_9802_CAN_T_BUILD_DOCK_HERE                                  :{WHITE}Siia ei saa sadamat ehitada
-STR_9803_SHIP_DEPOT                                             :{WHITE}{TOWN} Paadikuur
+STR_9803_SHIP_DEPOT                                             :{WHITE}{TOWN} Laevaangaar
 STR_9804_NEW_SHIPS                                              :{BLACK}Uus laev
 STR_9805_SHIPS                                                  :{WHITE}{COMPANY} - {COMMA} laev{P "" a}
 STR_9808_NEW_SHIPS                                              :{WHITE}Uued laevad
@@ -2991,15 +3004,15 @@
 STR_9816_BUILT_VALUE                                            :{LTBLUE}{ENGINE}{BLACK}   Ehitati: {LTBLUE}{NUM}{BLACK} Väärtus: {LTBLUE}{CURRENCY}
 STR_9817_CAPACITY                                               :{BLACK}Kandevõime: {LTBLUE}{CARGO}
 STR_9818_CAN_T_STOP_START_SHIP                                  :{WHITE}Ei saa peatada/käivitada laeva...
-STR_9819_CAN_T_SEND_SHIP_TO_DEPOT                               :{WHITE}Ei saa laeva paadikuuri saata...
-STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT                             :{WHITE}Ei leia kohalikku paadikuuri
+STR_9819_CAN_T_SEND_SHIP_TO_DEPOT                               :{WHITE}Ei saa laeva angaari saata...
+STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT                             :{WHITE}Ei leia kohalikku laevaangaari
 STR_HEADING_FOR_SHIP_DEPOT                                      :{ORANGE}Suundub {TOWN}a paadikuuri
 STR_HEADING_FOR_SHIP_DEPOT_VEL                                  :{ORANGE}Suundub {TOWN}a paadikuuri, {VELOCITY}
 STR_HEADING_FOR_SHIP_DEPOT_SERVICE                              :{LTBLUE}Hooldus linna {TOWN} sadamas
 STR_HEADING_FOR_SHIP_DEPOT_SERVICE_VEL                          :{LTBLUE}Hooldus linna {TOWN} sadamas, {VELOCITY}
 STR_981C_SHIP_IS_WAITING_IN_DEPOT                               :{WHITE}Laev {COMMA} ootab sadamas
 STR_981D_BUILD_SHIP_DOCK                                        :{BLACK}Ehita laevakuur
-STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING                          :{BLACK}Ehita laevakuur (laevade ehitamiseks ja hoolduseks)
+STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING                          :{BLACK}Ehita laevaangaar (laevade ehitamiseks ja hoolduseks)
 STR_981F_SHIPS_CLICK_ON_SHIP_FOR                                :{BLACK}Laevad - info saamiseks klõpsa laevale
 STR_9820_BUILD_NEW_SHIP                                         :{BLACK}Ehita uus laev
 STR_9821_DRAG_SHIP_TO_HERE_TO_SELL                              :{BLACK}Müügiks tiri laev siia
@@ -3011,7 +3024,7 @@
 STR_9827_CURRENT_SHIP_ACTION_CLICK                              :{BLACK}Praegune laeva tegevus - vajuta siia, et peatada/käivitada laeva
 STR_9828_SHOW_SHIP_S_ORDERS                                     :{BLACK}Näita laeva sihtpunkte
 STR_9829_CENTER_MAIN_VIEW_ON_SHIP                               :{BLACK}Vii vaade laeva asukohale
-STR_982A_SEND_SHIP_TO_DEPOT                                     :{BLACK}Saada laev paadikuuri
+STR_982A_SEND_SHIP_TO_DEPOT                                     :{BLACK}Saada laev angaari. CTRL+klikk ainult teenindab.
 STR_982B_SHOW_SHIP_DETAILS                                      :{BLACK}Näita laeva detaile
 STR_982E_COST_MAX_SPEED_CAPACITY                                :{BLACK}Hind: {CURRENCY} Tippkiirus: {VELOCITY}{}Kandevõime: {CARGO}{}Käituskulud: {CURRENCY}/aastas
 STR_982F_NAME_SHIP                                              :{BLACK}Anna laevale nimi
@@ -3021,7 +3034,7 @@
 STR_9833_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Rahvas rõõmustab . . .{}{STATION} terminali saabus esimene laev!
 STR_9834_POSITION_BUOY_WHICH_CAN                                :{BLACK}Raja teemärgisena kasutatav poi
 STR_9835_CAN_T_POSITION_BUOY_HERE                               :{WHITE}Poid ei saa siia asetada...
-STR_9836_RENAME                                                 :{BLACK}Muuda nime
+STR_9836_RENAME                                                 :{BLACK}Nime muutmine
 STR_9837_RENAME_SHIP_TYPE                                       :{BLACK}Nimeta laeva tüüp ümber
 STR_9838_RENAME_SHIP_TYPE                                       :{WHITE}Nimeta laeva tüüp ümber
 STR_9839_CAN_T_RENAME_SHIP_TYPE                                 :{WHITE}Ei saa laeva tüüpi ümber nimetada...
@@ -3035,7 +3048,7 @@
 STR_9841_CAN_T_REFIT_SHIP                                       :{WHITE}Ei saa laeva ümber seadistada...
 STR_9842_REFITTABLE                                             :(ümberseadistatav)
 STR_GO_TO_SHIP_DEPOT                                            :Mine {TOWN} paadikuuri
-SERVICE_AT_SHIP_DEPOT                                           :Hooldus {TOWN} paadikuuris
+SERVICE_AT_SHIP_DEPOT                                           :Hooldus {TOWN} laevaangaaris
 
 ##id 0xA000
 STR_A000_AIRPORTS                                               :{WHITE}Lennuväljad
@@ -3094,7 +3107,7 @@
 STR_A034_PLANE_CRASH_DIE_IN_FIREBALL                            :{BLACK}{BIGFONT}Lennuõnnetus!{}{COMMA} surid tules {STATION}s
 STR_PLANE_CRASH_OUT_OF_FUEL                                     :{BLACK}{BIGFONT}Lennuõnnetus!{}Lennukil lõppes kütus, {COMMA} surid tules!
 STR_A036                                                        :{TINYFONT}{BLACK}{STATION}
-STR_A037_RENAME                                                 :{BLACK}Muuda nime
+STR_A037_RENAME                                                 :{BLACK}Nime muutmine
 STR_A038_RENAME_AIRCRAFT_TYPE                                   :{BLACK}Nimeta lennuki tüüp ümber
 STR_A039_RENAME_AIRCRAFT_TYPE                                   :{WHITE}Nimeta lennuki tüüp ümber
 STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE                             :{WHITE}Ei saa lennuki tüüpi ümber nimetada...
@@ -3205,6 +3218,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Puuduvatele failidele on laaditud ühilduvad GRF failid
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Puuduvad GRF failid on välja lülitatud
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Mängu laadimiseks puudu olevad GRF failid
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Puuduolevad GRF failid
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Pausi lõpetamine võib põhjustada OpenTTD krahhi. Ära teavita järgnevatest krahhidest.{}Oled sa tõepoolest veendunud, et sa soovid pausi lõpetada?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Isiklik valuuta
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Vahetuskurss: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3245,7 +3260,7 @@
 STR_DEPOT_SELL_ALL_BUTTON_AIRCRAFT_TIP                          :{BLACK}Müü kõik lennukid angaarist
 
 STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TIP                          :{BLACK}Võta nimekiri kõikidest rongidest selles jaamas nende käskude järgi
-STR_DEPOT_VEHICLE_ORDER_LIST_ROADVEH_TIP                        :{BLACK}Hangi kõikidest autodest nimekiri, kus käskude all on nende praegune depoo
+STR_DEPOT_VEHICLE_ORDER_LIST_ROADVEH_TIP                        :{BLACK}Hangi kõikidest autodest nimekiri, kus praegune depoo on üks sihtpunktidest
 STR_DEPOT_VEHICLE_ORDER_LIST_SHIP_TIP                           :{BLACK}Võta nimekiri kõikidest laevadest selles sadamas nende käskude järgi
 STR_DEPOT_VEHICLE_ORDER_LIST_AIRCRAFT_TIP                       :{BLACK}Võta nimekiri kõikidest lennukitest suvalistest angaaridest selles lennujaamas nende käskude järgi
 
@@ -3332,21 +3347,21 @@
 ########### String for New Landscape Generator
 
 STR_GENERATE                                                    :{WHITE}Tekita
-STR_RANDOM                                                      :{BLACK}Muuda suvaliseks
+STR_RANDOM                                                      :{BLACK}Suvaline
 STR_RANDOM_HELP                                                 :{BLACK}Muuda maastiku loomisel kasutatavat suvalist seemet
 STR_WORLD_GENERATION_CAPTION                                    :{WHITE}Maailma genereerimine
 STR_RANDOM_SEED                                                 :{BLACK}Juhuarv:
 STR_RANDOM_SEED_HELP                                            :{BLACK}Klõpsa juhuarvu sisestamiseks
 STR_LAND_GENERATOR                                              :{BLACK}Maa generaator:
-STR_TREE_PLACER                                                 :{BLACK}Puu algoritm:
+STR_TREE_PLACER                                                 :{BLACK}Puude algoritm:
 STR_HEIGHTMAP_ROTATION                                          :{BLACK}Kõrgustekaardi pööre:
 STR_TERRAIN_TYPE                                                :{BLACK}Maapinna tüüp:
 STR_QUANTITY_OF_SEA_LAKES                                       :{BLACK}Merepinna tase:
 STR_SMOOTHNESS                                                  :{BLACK}Tasapinnalisus:
 STR_SNOW_LINE_HEIGHT                                            :{BLACK}Lumepiiri kõrgus:
 STR_DATE                                                        :{BLACK}Algus:
-STR_NUMBER_OF_TOWNS                                             :{BLACK}Linnade arv:
-STR_NUMBER_OF_INDUSTRIES                                        :{BLACK}Tehaste arv
+STR_NUMBER_OF_TOWNS                                             :{BLACK}Linnade sagedus:
+STR_NUMBER_OF_INDUSTRIES                                        :{BLACK}Tehaste sagedus:
 STR_GENERATE_DATE                                               :{BLACK}{DATE_LONG}
 STR_SNOW_LINE_UP                                                :{BLACK}Liiguta lumepiiri ühe ühiku võrra üles
 STR_SNOW_LINE_DOWN                                              :{BLACK}Liiguta lumepiiri ühe ühiku võrra alla
@@ -3385,6 +3400,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Vii väikekaart praegusele asukohale
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Väike
@@ -3515,7 +3531,7 @@
 STR_FACE_YES                                                    :Jah
 STR_FACE_NO                                                     :Ei
 STR_FACE_MOUSTACHE_EARRING_TIP                                  :{BLACK}Vuntsid või kõrvarõngad on lubatud
-STR_FACE_HAIR                                                   :Juuksed:
+STR_FACE_HAIR                                                   :Soeng:
 STR_FACE_HAIR_TIP                                               :{BLACK}Vaheta juukseid
 STR_FACE_EYEBROWS                                               :Kulmud:
 STR_FACE_EYEBROWS_TIP                                           :{BLACK}Vaheta kulmusid
@@ -3539,3 +3555,20 @@
 STR_FACE_EARRING                                                :Kõrvarõngas:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Vaheta kraed või kõrvarõngast
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Signalisatsiooni valimine
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Siin ei saa signalisatsiooni teisendada...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Läbisõidusignalisatsioon (semafor){}Signalisatsiooni läheb tarvis vältimaks kokkupõrkeid enam kui ühe rongiga rööbasteedel.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Sissesõidusignalisatsioon (semafor){}Roheline, kuni vähemalt üks väljasõidusignalisatsioon on roheline. Muudel juhtudel näitab punast.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Väljasõidusignalisatsioon (semafor){}Käitub samamoodi, nagu tavapärane signalsatsioon, kuid läheb vaja et sissesõidu- ja mitmikeelsignaalid näitaksid õiget värvi.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Mitmiksignalisatsioon (semafor){}Mitmiksignalisatsioon toimib nii sissesõidu-, kui ka läbisõidusignalisatsioonina. See võimaldab ehitada laialiulatuvaid sissesõidusignalisatsioonide
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Läbisõidusignalisatsioon (elektriline){}Signalisatsiooni läheb tarvis vältimaks kokkupõrkeid enam kui ühe rongiga rööbasteedel.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Sissesõidusignalisatsioon (elektriline){}Roheline, kuni vähemalt üks väljasõidusignalisatsioon on roheline. Muudel juhtudel näitab punast.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Väljasõidusignalisatsioon (elektriline){}Käitub samamoodi, nagu tavapärane signalsatsioon, kuid läheb vaja et sissesõidu- ja mitmikeelsignaalid näitaksid õiget värvi.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Mitmiksignalisatsioon (elektriline){}Mitmiksignalisatsioon toimib nii sissesõidu-, kui ka läbisõidusignalisatsioonina. See võimaldab ehitada laialiulatuvaid sissesõidusignalisatsioonide harusid.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Signalisatsiooni teisendamine{}Kui see on valitud, siis olemasolevad signalisatsioonil klõpsates teisendatakse see määratud signalisatsioonitüübiks ja -variandiks. Samal ajal CTRL klahvi all hoides lülitutakse olemasoleva variandi vahel.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Signalisatsioonide sagedus lohistades
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Vähenda signalisatsioonide sagedust lohistades
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Suurenda signalisatsioonide sagedust lohistades
+########
--- a/src/lang/finnish.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/finnish.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Aluetta ei voi tyhjentää....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Alkuperäiset oikeudet {COPYRIGHT} 1995 Chris Sawyer, kaikki oikeudet pidätetään
 STR_00B7_VERSION                                                :{BLACK}OpenTTD-versio {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 The OpenTTD team
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 The OpenTTD team
 STR_TRANSLATED_BY                                               :{BLACK}  Kääntäjä(t) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -2295,7 +2295,7 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Sijoita päämaja
 STR_COMPANY_PASSWORD                                            :{BLACK}Salasana
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Salasanalla voit suojata yhtiösi, jotta kukaan vieras ei pääse liittymään.
-STR_SET_COMPANY_PASSWORD                                        :Aseta yhtiön salasana
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Aseta yhtiön salasana
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Maailmanlaajuinen laskukausi!{}{}Rahoitusasiantuntijat pelkäävät pahinta talouden laskiessa!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Laskukausi ohi!{}{}Kaupankäynnin käänne parempaan lisää luottamusta teollisuuteen talouden vahvistuessa!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Suuri/pieni ikkunan koko
--- a/src/lang/french.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/french.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -161,7 +161,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Impossible de démolir....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright original {COPYRIGHT} 1995 Chris Sawyer, Tous droits réservés
 STR_00B7_VERSION                                                :{BLACK}OpenTTD version {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 L'équipe OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 L'équipe OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Traducteur(s) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -433,7 +433,7 @@
 STR_0171_PAUSE_GAME                                             :{BLACK}Mettre le jeu en pause
 STR_0172_SAVE_GAME_ABANDON_GAME                                 :{BLACK}Sauvegarder, abandonner, quitter
 STR_0173_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Afficher la liste des stations de la compagnie
-STR_0174_DISPLAY_MAP                                            :{BLACK}Afficher la carte
+STR_0174_DISPLAY_MAP                                            :{BLACK}Afficher la carte, vue supplémentaire ou liste des panneaux
 STR_0175_DISPLAY_MAP_TOWN_DIRECTORY                             :{BLACK}Afficher la carte, annuaire des villes
 STR_0176_DISPLAY_TOWN_DIRECTORY                                 :{BLACK}Afficher l'annuaire des villes
 STR_0177_DISPLAY_COMPANY_FINANCES                               :{BLACK}Afficher les informations financières
@@ -855,7 +855,7 @@
 STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE                            :{BLACK}Sélectionner l'environnement 'Arctique'
 STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE                          :{BLACK}Sélectionner l'environnement 'Tropical'
 STR_0311_SELECT_TOYLAND_LANDSCAPE                               :{BLACK}Sélectionner l'environnement 'Monde des jouets'
-STR_0312_FUND_CONSTRUCTION_OF_NEW                               :{BLACK}Financer la construction de nouvelles industries
+STR_0312_FUND_CONSTRUCTION_OF_NEW                               :{BLACK}Financer la construction de nouvelles industries ou liste les industries
 
 ############ range for menu starts
 STR_INDUSTRY_DIR                                                :Annuaire des industries
@@ -941,7 +941,8 @@
 STR_OPTIONS_LANG_TIP                                            :{BLACK}Sélectionner la langue d'interface à utiliser
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Plein écran
-STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Cocher cette case pour jouer à OpenTTD plein écran
+STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Cocher cette case pour jouer à OpenTTD en plein écran
+STR_FULLSCREEN_FAILED                                           :{WHITE}Echec du mode plein écran
 
 STR_OPTIONS_RES                                                 :{BLACK}Résolution
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1170,6 +1171,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Permettre d'acheter des actions d'autres compagnies
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Espacements des signaux en mode drag & drop : {ORANGE}{STRING} case(s)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Construire automatiquement des sémaphores avant: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Activer le GUI des signaux: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Le schéma de ville "pas de routes" n'est pas autorisé dans l'éditeur de scénario
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Choisir un schéma de ville: {ORANGE}{STRING}
@@ -1706,6 +1708,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}L'édifice doit d'abord être démolit
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Population: {ORANGE}{COMMA}{BLACK}  Maisons: {ORANGE}{COMMA}
@@ -2309,7 +2312,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Déménager le QG
 STR_COMPANY_PASSWORD                                            :{BLACK}Mot de passe
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Permet de protéger par mot de passe votre compagnie pour empêcher des utilisateurs non-autorisés de rejoindre. Utilisez '*' pour vider le mot de passe.
-STR_SET_COMPANY_PASSWORD                                        :Choisir le mot de passe de la compagnie
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Choisir le mot de passe de la compagnie
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Ne pas sauver le mot de passe entré
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Donner un nouveau mot de passe à la compagnie
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Mot de passe de compagnie
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Mot de passe de compagnie par défaut
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Utiliser ce mot de passe de compagnie comme défaut pour les nouvelles compagnies
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Récession mondiale!{}{}Les experts financiers craignent le pire!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Fin de la récession!{}{}La reprise redonne confiance aux industries!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Bascule entre une grande/petite fenêtre
@@ -2790,6 +2798,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Nouv{G eau el elle} {STRING} disponible!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Impossible de vendre le véhicule détruit...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Impossible de réaménager un véhicule détruit...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Impossible d'affecter un horaire au véhicule...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Les véhicules ne peuvent attendre qu'aux stations.
@@ -3022,7 +3031,7 @@
 STR_B002_OIL_REFINERY_EXPLOSION                                 :{BLACK}{BIGFONT}Explosion d'une raffinerie pétrolière près de {TOWN}!
 STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS                        :{BLACK}{BIGFONT}Usine détruite dans des circonstances suspectes près de {TOWN}!
 STR_B004_UFO_LANDS_NEAR                                         :{BLACK}{BIGFONT}Un 'OVNI' a été découvert près de {TOWN}!
-STR_B005_COAL_MINE_SUBSIDENCE_LEAVES                            :{BLACK}{BIGFONT}Affaissement d'une veine de charbon entraîne la desctruction de la mine de {TOWN}!
+STR_B005_COAL_MINE_SUBSIDENCE_LEAVES                            :{BLACK}{BIGFONT}L'affaissement d'une veine de charbon entraîne la destruction de la mine de {TOWN}!
 STR_B006_FLOOD_VEHICLE_DESTROYED                                :{BLACK}{BIGFONT}Inondations!{}Au moins {COMMA} présumé{P "" s} manquant{P "" s} ou mort{P "" s} après des inondations meurtrières!
 
 STR_BRIBE_FAILED                                                :{WHITE}Votre tentative de corruption à été
@@ -3110,6 +3119,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}GRF(s) compatible(s) chargé(s) pour les fichiers absents
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Fichier(s) GRF absent(s) désactivés
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Fichier(s) GRF absent(s) pour pouvoir charger la partie
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Fichier(s) GRF manquant(s)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Retirer la pause peut faire planter OpenTTD. Ne créez pas de rapport de bug pour ceux-ci.{}Voulez-vous vraiment retirer la pause?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Devise personnalisée
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Taux de change : {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3445,3 +3456,20 @@
 STR_FACE_EARRING                                                :Boucle d'oreille:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Modifier la cravate ou la boucle d'oreille
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Sélection des signaux
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Impossible de convertir les signaux...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Signal normal (sémaphore){}Les signaux sont nécessaires pour éviter les collisions sur les réseaux avec plus d'un train.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Signal d'entrée (sémaphore){}Vert tant qu'un ou plusieurs signaux de sortie sont verts dans le bloc. Rouge sinon.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Signal de sortie (sémaphore){}Fonctionne comme un signal normal, mais est nécessaire pour commander les signaux d'entrée et combinés.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Signal combiné (sémaphore){}Le signal combiné est simplement l'unification d'un signal d'entrée et d'un signal de sortie. Cela vous permet de construire de larges "arbres" de pré-signaux.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Signal normal (électrique){}Les signaux sont nécessaires pour éviter les collisions sur les réseaux avec plus d'un train.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Signal d'entrée (électrique){}Vert tant qu'un ou plusieurs signaux de sortie sont verts dans le bloc. Rouge sinon.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Signal de sortie (électrique){}Fonctionne comme un signal normal, mais est nécessaire pour commander les signaux d'entrée et combinés.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Signal combiné (électrique){}Le signal combiné est simplement l'unification d'un signal d'entrée et d'un signal de sortie. Cela vous permet de construire de larges "arbres" de pré-signaux.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Conversion de signal{}Si sélectionné, cliquer sur un signal existant pour le convertir vers le type et la variante choisis, Ctrl-clic pour basculer la variante.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Densité de signal
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Réduire la densité de signal
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Augmenter la densité de signal
+########
--- a/src/lang/galician.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/galician.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Non podes limpar esta área....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright Orixinal {COPYRIGHT} 1995 Chris Sawyer, Tódolos dereitos reservados
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versión {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 O Equipo de OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 O Equipo de OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Traductor(es) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -1050,6 +1050,8 @@
 STR_CONFIG_PATCHES_LIVERIES_NONE                                :Ningunha
 STR_CONFIG_PATCHES_LIVERIES_ALL                                 :Tódalas compañías
 
+
+
 STR_CONFIG_PATCHES_MAX_TRAINS                                   :{LTBLUE}Nº máximo de trens por xogador: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAX_ROADVEH                                  :{LTBLUE}Nº máximo de vehículos de estrada por xogador: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAX_AIRCRAFT                                 :{LTBLUE}Nº máximo de aeronaves por xogador: {ORANGE}{STRING}
@@ -1287,12 +1289,12 @@
 STR_NETWORK_PASSWORD_TIP                                        :{BLACK}Protexe a túa partida cun contrasinal se non queres que outras persoas se unan
 STR_NETWORK_SELECT_MAP                                          :{BLACK}Selecciona un mapa:
 STR_NETWORK_SELECT_MAP_TIP                                      :{BLACK}¿Que mapa queres xogar?
-STR_NETWORK_NUMBER_OF_CLIENTS                                   :{BLACK}Máximo de clientes permitidos:
-STR_NETWORK_NUMBER_OF_CLIENTS_TIP                               :{BLACK}Escolle o máximo número de clientes. Non tódolas liñas teñen que estar cubertas
 STR_NETWORK_LAN                                                 :LAN
 STR_NETWORK_INTERNET                                            :Internet
 STR_NETWORK_LAN_INTERNET                                        :LAN / Internet
 STR_NETWORK_INTERNET_ADVERTISE                                  :Internet (anunciar)
+STR_NETWORK_NUMBER_OF_CLIENTS                                   :{BLACK}Máximo de clientes permitidos:
+STR_NETWORK_NUMBER_OF_CLIENTS_TIP                               :{BLACK}Escolle o máximo número de clientes. Non tódolas liñas teñen que estar cubertas
 STR_NETWORK_NUMBER_OF_COMPANIES                                 :{BLACK}Nº máx. de compañías:
 STR_NETWORK_NUMBER_OF_COMPANIES_TIP                             :{BLACK}Limita-lo servidor a unha certa cantidade de compañías
 STR_NETWORK_NUMBER_OF_SPECTATORS                                :{BLACK}Nº máx. de espectadores:
@@ -2132,7 +2134,7 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Reposicionar CX
 STR_COMPANY_PASSWORD                                            :{BLACK}Contrasinal
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Protexe a atúa compañía cun contrasinal para evitar que usuarios non autorizados se unan
-STR_SET_COMPANY_PASSWORD                                        :Establece o contrasinal da compañía
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Establece o contrasinal da compañía
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}¡Recesión Mundial!{}{}¡Os expertos en finanzas témense o peor a medida que a economía afúndese!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}¡Fin da Recesión!{}{}¡A mellora no comercio inspira confianza nas industrias a media que a economía reforzase!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Intercambiar entre fiestra grande/pequena
@@ -2494,6 +2496,7 @@
 STR_8826_GO_TO                                                  :{BLACK}Ir a
 STR_8827_FULL_LOAD                                              :{BLACK}Cargar
 STR_8828_UNLOAD                                                 :{BLACK}Descarga
+STR_TIMETABLE_VIEW                                              :{BLACK}Táboa de tempo
 STR_8829_ORDERS                                                 :{WHITE}{VEHICLE} (Ordes)
 STR_882A_END_OF_ORDERS                                          :{SETX 10}- - Fin das Ordes - -
 STR_FULLLOAD_OR_SERVICE                                         :{SKIP}{SKIP}{STRING}
@@ -2572,7 +2575,14 @@
 
 STR_NEW_VEHICLE_NOW_AVAILABLE                                   :{BLACK}{BIGFONT}¡Novo {STRING} agora dispoñible!
 STR_NEW_VEHICLE_TYPE                                            :{BLACK}{BIGFONT}{ENGINE}
+STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}¡Nova{STRING} dispoñible!  -  {ENGINE}
 
+STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Non se pode vender un vehículo destruido...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Non se pode actualizar un vehículo destruido...
+
+STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Os vehículos só poden parar nas estacións.
+STR_TIMETABLE_NOT_STOPPING_HERE                                 :{WHITE}Este vehículo non para nesta estación.
+STR_TIMETABLE_CHANGE_TIME                                       :{BLACK}Cambiar Tempo
 
 ##id 0x9000
 STR_9000_ROAD_VEHICLE_IN_THE_WAY                                :{WHITE}Haí un vehículo de estrada no camiño
@@ -2781,6 +2791,7 @@
 STR_GO_TO_AIRPORT_HANGAR                                        :Ir ó hangar de {STATION}
 SERVICE_AT_AIRPORT_HANGAR                                       :Face-lo servicio no hangar de {STATION}
 
+STR_TIMETABLE_TITLE                                             :{WHITE}{VEHICLE} (Táboa de tempo)
 
 ##id 0xB000
 STR_B000_ZEPPELIN_DISASTER_AT                                   :{BLACK}{BIGFONT}¡Desastre cun Zeppelin en {STATION}!
@@ -2835,6 +2846,8 @@
 STR_NEWGRF_ERROR_MSG_WARNING                                    :{RED}Aviso: {SILVER}{STRING}
 STR_NEWGRF_ERROR_MSG_ERROR                                      :{RED}Erro: {SILVER}{STRING}
 STR_NEWGRF_ERROR_UNSET_SWITCH                                   :{STRING} está deseñado para ser usado con {STRING}
+STR_NEWGRF_ERROR_LOAD_BEFORE                                    :{STRING} debe cargarse antes de {STRING}.
+STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} debe cargarse despois de {STRING}.
 
 STR_NEWGRF_ADD                                                  :{BLACK}Engadir
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Engadir un novo arquivo NewGRF á lista
@@ -2844,8 +2857,13 @@
 STR_NEWGRF_MOVEUP_TIP                                           :{BLACK}Move-lo arquivo NewGRF seleccionado arriba na lista
 STR_NEWGRF_MOVEDOWN                                             :{BLACK}Baixar
 STR_NEWGRF_MOVEDOWN_TIP                                         :{BLACK}Move-lo arquivo NewGRF seleccionado abaixo na lista
+STR_NEWGRF_FILE_TIP                                             :{BLACK}Lista dos ficheiros NewGRF instalados. Pincha nun ficheiro para cambiar os parámetros
 STR_NEWGRF_PARAMETER                                            :{BLACK}Parámetros: {SILVER}{STRING}
 
+STR_NEWGRF_ADD_FILE                                             :{BLACK}Engadir á selección
+STR_NEWGRF_RESCAN_FILES                                         :{BLACK}Actualizar ficheiros
+STR_NEWGRF_RESCAN_FILES_TIP                                     :{BLACK}Actualiza a lista dos ficheiros NewGRF dispoñibles
+STR_NEWGRF_DUPLICATE_GRFID                                      :{WHITE}Non se pode engadir o ficheiro: ID do GRF duplicado
 
 STR_NEWGRF_DISABLED                                             :{RED}Desactivado
 
@@ -2883,6 +2901,7 @@
 STR_DEPOT_WRONG_DEPOT_TYPE                                      :Tipo de depósito erróneo
 
 STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TIP                             :{BLACK}Vender tódolos trens do depósito
+STR_DEPOT_SELL_ALL_BUTTON_ROADVEH_TIP                           :{BLACK}Vender tódolos vehículos que hai no depósito
 STR_DEPOT_SELL_ALL_BUTTON_SHIP_TIP                              :{BLACK}Vender tódolos barcos no depósito
 STR_DEPOT_SELL_ALL_BUTTON_AIRCRAFT_TIP                          :{BLACK}Vender tódalas aeronaves do hangar
 
@@ -2903,6 +2922,9 @@
 STR_REPLACE_HELP                                                :{BLACK}Permíteche reemplazar untipo de máquina cunha doutro tipo, cando trens do tipo orixinal entran nun depósito
 STR_REPLACE_REMOVE_WAGON                                        :{BLACK}Eliminar os vagóns: {ORANGE}{SKIP}{STRING}
 STR_REPLACE_ENGINE_WAGON_SELECT                                 :{BLACK}Reemprazando: {ORANGE}{SKIP}{SKIP}{STRING}
+STR_RAIL_VEHICLE_NOT_AVAILABLE                                  :{WHITE}O vehículo non está dispoñible
+STR_ROAD_VEHICLE_NOT_AVAILABLE                                  :{WHITE}O vehículo non está dispoñible
+STR_SHIP_NOT_AVAILABLE                                          :{WHITE}O barco non está dispoñible
 
 STR_ENGINES                                                     :Máquinas
 STR_WAGONS                                                      :Vagóns
@@ -2946,6 +2968,7 @@
 STR_PURCHASE_INFO_COST_SPEED                                    :{BLACK}Coste: {GOLD}{CURRENCY}{BLACK} Velocidade: {GOLD}{VELOCITY}
 STR_PURCHASE_INFO_AIRCRAFT_CAPACITY                             :{BLACK}Capacidade: {GOLD}{COMMA} pasaxeiros, {COMMA} sacos de correo
 STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT                          :{BLACK}Vagóns tractores: {GOLD}+{POWER}{BLACK} Peso: {GOLD}+{WEIGHT_S}
+STR_PURCHASE_INFO_REFITTABLE_TO                                 :{BLACK}Actualizable a: {GOLD}
 STR_PURCHASE_INFO_ALL_BUT                                       :Todo excepto {GOLD}
 
 ########### String for New Landscape Generator
@@ -2965,6 +2988,9 @@
 STR_NUMBER_OF_TOWNS                                             :{BLACK}Num. de cidades:
 STR_NUMBER_OF_INDUSTRIES                                        :{BLACK}Num. de industrias:
 STR_GENERATE_DATE                                               :{BLACK}{DATE_LONG}
+STR_SNOW_LINE_UP                                                :{BLACK}Subir a altura da liña de neve
+STR_SNOW_LINE_DOWN                                              :{BLACK}Baixar a altura da liña de neve
+STR_SNOW_LINE_QUERY_CAPT                                        :{WHITE}Cambiar a altura da liña de neve
 STR_START_DATE_QUERY_CAPT                                       :{WHITE}Cambia-lo ano de inicio
 STR_SNOW_LINE_HEIGHT_NUM                                        :{NUM}
 STR_HEIGHTMAP_SIZE                                              :{BLACK}Tamaño: {ORANGE}{NUM} x {NUM}
@@ -2979,12 +3005,18 @@
 STR_PREPARING_GAME                                              :{BLACK}Preparando partida
 STR_DIFFICULTY_TO_CUSTOM                                        :{WHITE}Esta acción cambiou o nivel de dificultade a Personalizado
 STR_SE_FLAT_WORLD                                               :{WHITE}Terreo Chan
+STR_SE_FLAT_WORLD_TIP                                           :{BLACK}Xerar terreo chan
 STR_SE_RANDOM_LAND                                              :{WHITE}Terreo aleatorio
 STR_SE_NEW_WORLD                                                :{BLACK}Crear novo escenario
 STR_SE_CAPTION                                                  :{WHITE}Tipo de escenario
+STR_FLAT_WORLD_HEIGHT_DOWN                                      :{BLACK}Subir a altura do terreo chan un nivel
+STR_FLAT_WORLD_HEIGHT_UP                                        :{BLACK}Baixar a altura do terreo chan un nivel
+STR_FLAT_WORLD_HEIGHT_QUERY_CAPT                                :{WHITE}Cambiar a altura do terreo chan
+STR_FLAT_WORLD_HEIGHT                                           :{BLACK}Altura do terreo chan:
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Centra-lo mapa pequeno na posición actual
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Pequeno
@@ -3040,6 +3072,7 @@
 STR_GROUP_ALL_SHIPS                                             :Tódolos barcos
 STR_GROUP_ALL_AIRCRAFTS                                         :Tódolos avións
 STR_GROUP_TINY_NUM                                              :{TINYFONT}{COMMA}
+STR_GROUP_REMOVE_ALL_VEHICLES                                   :Borrar tódolos vehículos
 
 STR_GROUP_RENAME_CAPTION                                        :{BLACK}Renomear un grupo
 
@@ -3049,11 +3082,11 @@
 STR_GROUP_CAN_T_REMOVE_ALL_VEHICLES                             :{WHITE}Non se pode borrar tódolos vehículos deste grupo...
 STR_GROUP_CAN_T_ADD_VEHICLE                                     :{WHITE}Non se pode engadir o vehículo a este grupo...
 
+STR_GROUPS_CLICK_ON_GROUP_FOR_TIP                               :{BLACK}Grupos - Pincha nun grupo para ver unha lista dos vehículos dese grupo
 STR_GROUP_CREATE_TIP                                            :{BLACK}Pincha para crear un grupo
 STR_GROUP_DELETE_TIP                                            :{BLACK}Borrar o grupo seleccionado
 STR_GROUP_RENAME_TIP                                            :{BLACK}Renomear o grupo seleccionado
 
-
 STR_COMPANY_NAME                                                :{COMPANY}
 STR_ENGINE_NAME                                                 :{ENGINE}
 STR_GROUP_NAME                                                  :{GROUP}
@@ -3066,3 +3099,18 @@
 
 ########
 
+
+############ Face formatting
+STR_FACE_SIMPLE                                                 :{BLACK}Simple
+STR_FACE_LOAD                                                   :{BLACK}Cargar
+STR_FACE_FACECODE_ERR                                           :{WHITE}¡Non se pode axustar o número da cara - debe estar entre 0 e 4.294.967.295!
+STR_FACE_SAVE                                                   :{BLACK}Grabar
+STR_FACE_EUROPEAN                                               :{BLACK}Europea
+STR_FACE_SELECT_EUROPEAN                                        :{BLACK}Seleccionar caras europeas
+STR_FACE_AFRICAN                                                :{BLACK}Africana
+STR_FACE_YES                                                    :Si
+STR_FACE_NO                                                     :Non
+########
+
+############ signal GUI
+########
--- a/src/lang/german.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/german.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -161,7 +161,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Gebiet kann nicht geräumt werden...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Ursprüngliches Urheberrecht {COPYRIGHT} 1995 Chris Sawyer, Alle Rechte vorbehalten
 STR_00B7_VERSION                                                :{BLACK}OpenTTD Version {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD-Team
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD-Team
 STR_TRANSLATED_BY                                               :{BLACK}  Übersetzer -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -595,6 +595,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Firmendaten
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Öffnen und Schließen von Industrien
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Änderungen der Wirtschaftslage
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Produktionsänderungen bei vom Spieler belieferten Industriebetrieben
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Produktionsänderungen bei von Wettbewerbern belieferten Industriebetrieben
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Andere Produktionsänderungen
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Rat / Informationen zu Fahrzeugen des Spielers
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Neue Fahrzeuge
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Änderungen akzeptierter Fracht
@@ -939,6 +942,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Vollbild
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}OpenTTD im Vollbildmodus spielen
+STR_FULLSCREEN_FAILED                                           :{WHITE}Vollbildmodus nicht möglich
 
 STR_OPTIONS_RES                                                 :{BLACK}Bildschirmauflösung
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1167,6 +1171,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Erlaube Anteile an anderen Firmen zu kaufen
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Errichte Signale alle {ORANGE}{STRING} Felder beim Ziehen mit der Maus
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automatischer Bau von Formsignalen bis: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Aktiviere Signal-Menü: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Der Stadtaufbau "keine weiteren Straßen" ist im Szenarieneditor nicht möglich
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Stadtstraßenaufbau auswählen: {ORANGE}{STRING}
@@ -1681,6 +1686,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Straßenbahnbrücke bauen
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Straßentunnel bauen
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Straßenbahntunnel bauen
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Aktiviere/Deaktiviere Einbahnstraßen
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Zwischen Bau/Abriss der Straße umschalten
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Umschalten zwischen Bauen/Entfernen für Straßenbahnbau
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Ausrichtung des Fahrzeugdepots wählen
@@ -1702,6 +1708,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Gebäude muss erst abgerissen werden
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Bevölkerung: {ORANGE}{COMMA}{BLACK}  Häuser: {ORANGE}{COMMA}
@@ -2305,7 +2312,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Firmensitz verlegen
 STR_COMPANY_PASSWORD                                            :{BLACK}Passwort
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Sie können Ihre Firma mit einem Passwort schützen, sodass nur ausgewählte Spieler beitreten können.
-STR_SET_COMPANY_PASSWORD                                        :Firmenpasswort setzen
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Firmenpasswort setzen
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}eingegebenes Passwort nicht speichern
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Passwort der Firma zuweisen
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Firmenpasswort
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Standard-Firmenpasswort
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Benutze dieses Firmenpasswort als Standard für neue Firmen
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Weltwirtschaftskrise!{}{}Finanzexperten befürchten schlimmsten Zusammenbruch der Wirtschaft!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Wirtschaftskrise beendet!{}{}Aufschwung des Handels gibt Vertrauen in die Industrie und stärkt die Wirtschaft!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Schalter für großes/kleines Fenster
@@ -2786,6 +2798,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Neue{G r "" s} {STRING} jetzt erhältlich!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Kann dieses Schrottfahrzeug nicht mehr verkaufen ...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Kann zerstörtes Fahrzeug nicht nachrüsten...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Kein Fahrplan für das Fahrzeug...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Fahrzeuge halten nur an Stationen.
@@ -3077,6 +3090,7 @@
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} muss nach {STRING} geladen werden.
 STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} Benötigt OpenTTD-Version {STRING} oder höher.
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :der GRF-Datei, die es übersetzen soll,
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Zu viele NewGRFs geladen.
 
 STR_NEWGRF_ADD                                                  :{BLACK}Hinzufügen
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Eine neue NewGRF-Datei zur Liste hinzufügen
@@ -3105,6 +3119,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatible GRF(s) für fehlende Dateien geladen
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Fehlende GRF-Dateien wurden deaktiviert.
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Es fehlen GRF-Dateien um das Spiel zu laden
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}GRF-Datei(en) fehlen
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Das beenden der PAuse kann OpenTTD zum Abstürzen bringen. Bitte sende keine Fehlerberichte bei auftretenden Fehlern. {}Willst du die Pause wirklich beenden?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Eigene Währung
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Wechselkurs: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3285,6 +3301,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Zusatzansicht zur akutellen Position scrollen
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}klein
@@ -3439,3 +3456,20 @@
 STR_FACE_EARRING                                                :Ohrring:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Krawatte oder Ohrring ändern
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Signalauswahl
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Kann Signale hier nicht umbauen...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standardsignal (Formsignal){}Signale ermöglichen den unfallfreien Betrieb mehrerer Züge in einem Schienensystem.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Einfahrsignal (Formsignal){}Zeigt grün, wenn im folgenden Block mindestens Ausfahrsignal grün zeigt. Andernfalls zeigt es rot.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Ausfahrsignal (Formsignal){}Verhält sich wie ein normales Signal, wird jedoch benötigt, um Einfahr- oder Combosignalen den Block als "frei" zu melden.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Combosignal (Formsignal){}Das Combosignal ist gleichzeitig Ausfahr- und Einfahrsignal. Somit werden umfangreiche Signalverschaltungen möglich.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standardsignal (Lichtsignal){}Signale ermöglichen den unfallfreien Betrieb mehrerer Züge in einem Schienensystem.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Einfahrsignal (Lichtsignal){}Zeigt grün, wenn im folgenden Block mindestens Ausfahrsignal grün zeigt. Andernfalls zeigt es rot.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Ausfahrsignal (Lichtsignal){}Verhält sich wie ein normales Signal, gibt jedoch das Signal an Einfahr- und Combosignale im vorherliegenden Block weiter.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Combosignal (Lichtsignal){}Das Combosignal ist gleichzeitig Ausfahr- und Einfahrsignal. Somit werden umfangreiche Signalverschaltungen möglich.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Signalumbau{}Wenn ausgewählt, werden bestehende Signale durch Anklicken zum ausgewählten Signaltyp umgebaut. Strg.+Klicken ändert die bestehende Bauform.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Abstand der Signale
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Signalabstand verringern
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Signalabstand erhöhen
+########
--- a/src/lang/hungarian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/hungarian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -193,7 +193,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Nem tisztíthatod meg a területet...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright {COPYRIGHT} 1995 Chris Sawyer, Minden jog fenntartva
 STR_00B7_VERSION                                                :{BLACK}OpenTTD version {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 Az OpenTTD csapat
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 Az OpenTTD csapat
 STR_TRANSLATED_BY                                               :{BLACK}  Fordítók -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -1232,6 +1232,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Másik cégekből részvényt lehet vásárolni
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Amikor megragadom helyezzen lámpákat minden {ORANGE}{STRING}. mezőre
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automatikusan szemafor épüljön eddig: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Szignálkezelő engedélyezése: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}A "nincs több út" városkinézeti séma a pályaszerkesztőben nem elérhető
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Válassz városi úthálózat-sémát: {ORANGE}{STRING}
@@ -1733,7 +1734,9 @@
 STR_180A_ROAD_CONSTRUCTION                                      :Útépítés
 STR_180A_TRAMWAY_CONSTRUCTION                                   :Villamospálya építés
 STR_180B_BUILD_ROAD_SECTION                                     :{BLACK}Út építése
+STR_BUILD_AUTOROAD_TIP                                          :{BLACK}Közút-szakasz megépítése automata módon
 STR_180B_BUILD_TRAMWAY_SECTION                                  :{BLACK}Villamos-sín építése
+STR_BUILD_AUTOTRAM_TIP                                          :{BLACK}Villamos-sín szakasz megépítése automata módon
 STR_180C_BUILD_ROAD_VEHICLE_DEPOT                               :{BLACK}Garázs építése (járművek vételére és karbantartására)
 STR_180C_BUILD_TRAM_VEHICLE_DEPOT                               :{BLACK}Villamos-depó építése (járművek megépítésére és szervizelésére)
 STR_180D_BUILD_BUS_STATION                                      :{BLACK}Buszmegálló építése
@@ -1744,6 +1747,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Villamos-híd építése
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Közúti alagút építése
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Villamos-alagút építése
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Egyirányú utak ki/be kapcsolása
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Építés/felszedés közötti váltás utaknál
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Építő/bontó üzemmód váltása a villamospályákhoz
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Válaszd ki a garázs helyzetét
@@ -1765,6 +1769,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Előbb le kell rombolnod az épületet
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Lakosság: {ORANGE}{COMMA}{BLACK} Házak: {ORANGE}{COMMA}
@@ -2124,6 +2129,7 @@
 STR_5006_MUST_DEMOLISH_TUNNEL_FIRST                             :{WHITE}Előbb le kell rombolnod az alagutat
 STR_5007_MUST_DEMOLISH_BRIDGE_FIRST                             :{WHITE}Előbb le kell rombolnod a hidat
 STR_5008_CANNOT_START_AND_END_ON                                :{WHITE}Nem kezdődhet és végződhet ugyanott
+STR_BRIDGEHEADS_NOT_SAME_HEIGHT                                 :{WHITE}Hídfők nem egy szinten vannak
 STR_BRIDGE_TOO_LOW_FOR_TERRAIN                                  :{WHITE}A híd túl alacsony a terepre
 STR_500A_START_AND_END_MUST_BE_IN                               :{WHITE}A kezdetének és a végének egy vonalban kell lennie
 STR_500B_SITE_UNSUITABLE_FOR_TUNNEL                             :{WHITE}Nem alkalmas a hely alagút bejáratának
@@ -2404,7 +2410,10 @@
 STR_RELOCATE_HQ                                                 :{BLACK}FH áthelyezése
 STR_COMPANY_PASSWORD                                            :{BLACK}Jelszó
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Védd le a vállalatodat jelszóval ha nem akarod hogy mások csatlakozzanak hozzá.
-STR_SET_COMPANY_PASSWORD                                        :Vállalati jelszó beállítása
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Vállalati jelszó beállítása
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Ne mentsd el a megadott jelszót
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Cég jelszó
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Alapértelmezett cég jelszó
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Gazdasági visszaesés!{}{}A közgazdászok gazdasági válságtól tartanak!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Vége a visszaesésnek!{}{}A kereskedelem fellendül, ami önbizalmat ad az iparnak, és erősödik a gazdaság!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Kicsi/nagy ablakméret közötti váltás
@@ -3174,7 +3183,9 @@
 STR_NEWGRF_ERROR_INVALID_PARAMETER                              :Hibás paraméterérték ehhez: {STRING}: paraméter {STRING} ({NUM})
 STR_NEWGRF_ERROR_LOAD_BEFORE                                    :{STRING} muszáj hogy betöltődjön ezelőtt: {STRING}.
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} muszáj hogy ezután töltődjön be: {STRING}.
+STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} csak a {STRING} vagy nagyobb verziójú OpenTTD-vel működik.
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :az adott GRF fájl célja egy másik lefordítása
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Túl sok NewGRF van betöltve.
 
 STR_NEWGRF_ADD                                                  :{BLACK}Hozzáad
 STR_NEWGRF_ADD_TIP                                              :{BLACK}A NewGRF-et hozzáadja a listához
@@ -3203,6 +3214,7 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatibilis GRF(ek) betöltve a hiányzó fájl(ok) helyett
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Hiányzó GRF fájl(oka)t kikapcsoltam
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Kritikus GRF fájl(ok) hiányoznak, a játék nem betölthető
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Hiányzó GRF fájl(ok)
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Saját pénznem
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Értékarány: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3383,6 +3395,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}A kistérkép közepét a jelenlegi helyre állítja
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Kicsi
@@ -3499,15 +3512,26 @@
 STR_FACE_LOAD_TIP                                               :{BLACK}Kedvenc arcd betöltése
 STR_FACE_LOAD_DONE                                              :{WHITE}A kedvenc arcod az OpenTTD konfig-fájlból be lett töltve.
 STR_FACE_FACECODE                                               :{BLACK}Játékos arc szám
+STR_FACE_FACECODE_TIP                                           :{BLACK}Játékos arc-számának megtekintését/módosítását teszi lehetővé
+STR_FACE_FACECODE_CAPTION                                       :{WHITE}Játékos arcszámának megtekintése/módosítása
+STR_FACE_FACECODE_SET                                           :{WHITE}Az új arcszám-kód beállítása megtörtént.
+STR_FACE_FACECODE_ERR                                           :{WHITE}Játékos arc-szám beállítás sikertelen - A megadott értéknek 0 és 4.294.967.295 közé eső számnak kell lennie!
 STR_FACE_SAVE                                                   :{BLACK}Mentés
 STR_FACE_SAVE_TIP                                               :{BLACK}Kedvenc arc elmentése
 STR_FACE_SAVE_DONE                                              :{WHITE}Ez az arc mint a kedvenc arcod fog az OpenTTD konfig-fájlba elmentődni.
 STR_FACE_EUROPEAN                                               :{BLACK}Európai
+STR_FACE_SELECT_EUROPEAN                                        :{BLACK}Európai arc választása
 STR_FACE_AFRICAN                                                :{BLACK}Afrikai
+STR_FACE_SELECT_AFRICAN                                         :{BLACK}Afrikai arc választása
 STR_FACE_YES                                                    :Igen
 STR_FACE_NO                                                     :Nem
+STR_FACE_MOUSTACHE_EARRING_TIP                                  :{BLACK}Engedélyezi a bajuszt és/vagy a fülbevalót
 STR_FACE_HAIR                                                   :Haj:
 STR_FACE_HAIR_TIP                                               :{BLACK}Haj váltása
+STR_FACE_EYEBROWS                                               :Szemöldök:
+STR_FACE_EYEBROWS_TIP                                           :{BLACK}Szemöldök módosítása
+STR_FACE_EYECOLOUR                                              :Szemszín:
+STR_FACE_EYECOLOUR_TIP                                          :{BLACK}Szemszín cseréje
 STR_FACE_GLASSES                                                :Szemüveg:
 STR_FACE_GLASSES_TIP                                            :{BLACK}Szemüveg engedélyezése
 STR_FACE_GLASSES_TIP_2                                          :{BLACK}Szemüveg váltása
@@ -3518,4 +3542,27 @@
 STR_FACE_LIPS_MOUSTACHE_TIP                                     :{BLACK}Ajkak vagy bajusz váltása
 STR_FACE_CHIN                                                   :Ál:
 STR_FACE_CHIN_TIP                                               :{BLACK}Ál váltása
+STR_FACE_JACKET                                                 :Kabát
+STR_FACE_JACKET_TIP                                             :{BLACK}Babát cseréje
+STR_FACE_COLLAR                                                 :Gallér
+STR_FACE_COLLAR_TIP                                             :{BLACK}Gallér cseréje
+STR_FACE_TIE                                                    :Nyakkendő:
+STR_FACE_EARRING                                                :Fülbevaló:
+STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Nyakkendő vagy fülbevaló cseréje
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Szignál választó
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Nem lehet konvertálni a szignálokat itt...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Általános szignál (szemafor){}A szignálok feladata a vonatok összeütközésének megakadályozása a többvonatos vasúti hálózatokon.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Belépő-szignál (szemafor){}Mindaddig zöld, amíg van legalább egy zöld kilépő-szignál az utánakövetkező szakaszon. Egyébként pirosat mutat.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Kilépő-szignál (szemafor){}Ugyanúgy viselkedik mint az általános szignál, de megléte elengedhetetlenül szükséges a belépő- és a kombó-szignálok működéséhez.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Kombó-szignál (szemafor){}A kombó szignál voltaképpen egy kilépő- és egy belépő-szignál egybeépítve. Segítségével előjelző szignálokból lehet nagy "fákat" kialakítani.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Általános szignál (lámpa){}A szignálok feladata a vonatok összeütközésének megakadályozása a többvonatos vasúti hálózatokon.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Belépő-szignál (lámpa){}Mindaddig zöld, amíg van legalább egy zöld kilépő-szignál az utánakövetkező szakaszon. Egyébként pirosat mutat.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Kilépő-szignál (lámpa){}Ugyanúgy viselkedik mint az általános szignál, de megléte elengedhetetlenül szükséges a belépő- és a kombó-szignálok működéséhez.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Kombó-szignál (lámpa){}A kombó szignál voltaképpen egy kilépő- és egy belépő-szignál egybeépítve. Segítségével előjelző szignálokból lehet nagy "fákat" kialakítani.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Szignál Átalakító{}Amikor ki van jelölve, egy meglévő szignálra kattintással átkonvertálja a kiválasztott szignál-típusra és -variációra, CTRL+kattintás a variációt fogja változtatni.
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Automata szignáltávolság csökkentése
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Automata szignáltávolság növelése
+########
--- a/src/lang/icelandic.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/icelandic.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -159,7 +159,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Get ekki hreinsað þetta svæði....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Upphaflegur höfundarréttur {COPYRIGHT} 1995 Chris Sawyer, Öll réttindi áskilin
 STR_00B7_VERSION                                                :{BLACK}OpenTTD útgáfa {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD hópurinn
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD hópurinn
 STR_TRANSLATED_BY                                               :{BLACK}  Þýðendur -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -2154,7 +2154,7 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Flytja HS
 STR_COMPANY_PASSWORD                                            :{BLACK}Lykilorð
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Til að vernda fyrirtæki þitt frá óboðnum notendum geturðu sett lykilorð á það
-STR_SET_COMPANY_PASSWORD                                        :Setja lykilorð á fyrirtæki
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Setja lykilorð á fyrirtæki
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Heimssamdráttur!{}{}Hagfræðingar hræddir um efnahagshrun!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Samdráttur!{}{}Uppslag í viðskiptum gefur bjartari von um betri efnahag!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Stækka/smækka gluggastærð
--- a/src/lang/italian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/italian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -162,7 +162,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Impossibile ripulire l'area....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright originale {COPYRIGHT} 1995 Chris Sawyer, Tutti i diritti riservati
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versione {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 Il team OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 Il team OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Traduttori - Sidew, LorenzoDV e altri, senza nome, che ci hanno preceduti.
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -434,7 +434,7 @@
 STR_0171_PAUSE_GAME                                             :{BLACK}Pausa
 STR_0172_SAVE_GAME_ABANDON_GAME                                 :{BLACK}Salva la partita, abandona la partita, esci
 STR_0173_DISPLAY_LIST_OF_COMPANY                                :{BLACK}Mostra l'elenco delle stazioni di una compagnia
-STR_0174_DISPLAY_MAP                                            :{BLACK}Mostra la mappa
+STR_0174_DISPLAY_MAP                                            :{BLACK}Mostra la mappa, apre una mini visuale extra o mostra l'elenco dei cartelli
 STR_0175_DISPLAY_MAP_TOWN_DIRECTORY                             :{BLACK}Mostra la mappa, l'elenco delle città
 STR_0176_DISPLAY_TOWN_DIRECTORY                                 :{BLACK}Mostra l'elenco delle città
 STR_0177_DISPLAY_COMPANY_FINANCES                               :{BLACK}Mostra informazioni finanziare sulle compagnie
@@ -856,7 +856,7 @@
 STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE                            :{BLACK}Seleziona il paesaggio 'sub-artico'
 STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE                          :{BLACK}Seleziona il paesaggio 'sub-tropicale'
 STR_0311_SELECT_TOYLAND_LANDSCAPE                               :{BLACK}Seleziona il paesaggio 'città dei giocattoli'
-STR_0312_FUND_CONSTRUCTION_OF_NEW                               :{BLACK}Finanzia la costruzione di una nuova industria
+STR_0312_FUND_CONSTRUCTION_OF_NEW                               :{BLACK}Finanzia la costruzione di una nuova industria o mostra l'elenco delle industrie
 
 ############ range for menu starts
 STR_INDUSTRY_DIR                                                :Elenco industrie
@@ -943,6 +943,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Schermo intero
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Attiva questa casella per giocate a OpenTTD in modalità schermo intero
+STR_FULLSCREEN_FAILED                                           :{WHITE}Attivazione modalità schermo intero fallita
 
 STR_OPTIONS_RES                                                 :{BLACK}Risoluzione schermo
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1171,6 +1172,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Permetti l'acquisto di azioni di altre compagnie
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Trascinando il cursore, piazza i segnali ogni: {ORANGE}{STRING} quadrato/i
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Costruisci automaticamente i semafori prima del: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Abilita l'interfaccia di selezione segnali: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}L'opzione "Nessuna nuova strada" non è valida nell'editor di scenari
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Disposizione delle strade cittadine: {ORANGE}{STRING}
@@ -1393,8 +1395,8 @@
 STR_NETWORK_NEW_GAME_NAME_TIP                                   :{BLACK}Il nome della partita sarà mostrato dagli altri giocatori nel menu di selezione delle partite multigiocatore
 STR_NETWORK_SET_PASSWORD                                        :{BLACK}Imposta password
 STR_NETWORK_PASSWORD_TIP                                        :{BLACK}Protegge la partita con una password in modo che non sia accessibile pubblicamente
-STR_NETWORK_SELECT_MAP                                          :{BLACK}Seleziona una mappa:
-STR_NETWORK_SELECT_MAP_TIP                                      :{BLACK}Con quale mappa vuoi giocare?
+STR_NETWORK_SELECT_MAP                                          :{BLACK}Seleziona mappa:
+STR_NETWORK_SELECT_MAP_TIP                                      :{BLACK}Selezionare la mappa con la quale si desidera giocare
 STR_NETWORK_LAN_INTERNET_COMBO                                  :{BLACK}{SKIP}{STRING}
 STR_NETWORK_LAN                                                 :LAN
 STR_NETWORK_INTERNET                                            :Internet
@@ -1707,6 +1709,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}L'edificio deve essere demolito prima
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Popolazione: {ORANGE}{COMMA}{BLACK}  Case: {ORANGE}{COMMA}
@@ -2309,8 +2312,13 @@
 STR_7072_VIEW_HQ                                                :{BLACK}Vedi sede
 STR_RELOCATE_HQ                                                 :{BLACK}Sposta sede
 STR_COMPANY_PASSWORD                                            :{BLACK}Password
-STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Protegge la compagnia con una password per impedire ad utenti non autorizzati di accedervi.
-STR_SET_COMPANY_PASSWORD                                        :Imposta password compagnia
+STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Protegge la compagnia con una password per impedire ad utenti non autorizzati di accedervi
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Imposta password compagnia
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Non salvare la password inserita
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Assegna la nuova password alla compagnia
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Password della compagnia
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Password predefinita compagnia
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Usa questa password come predefinita per le nuove compagnie
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Recessione mondiale!{}{}Il crollo dell'economia porta gli analisti finanziari a temere il peggio!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recessione finita!{}{}La ripresa del commercio da fiducia alle industrie e rafforza l'economia!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Seleziona dimensione grande/piccola della finestra
@@ -2791,6 +2799,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Nuov{G o a} {STRING} disponibile! -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Impossibile vendere un veicolo distrutto...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Impossibile riadattare un veicolo distrutto...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Impossibile dare un orario al veicolo...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}I veicoli possono attendere solo alle stazioni.
@@ -3111,6 +3120,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}File GRF compatibili caricati al posto dei file mancanti
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}I file GRF mancanti sono stati disabilitati
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Mancano file GRF necessari per caricare la partita
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}File GRF mancanti
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Uscire dalla pausa può causare un crash: nel caso, si prega di non inviare segnalazioni bug al riguardo.{}Uscire dalla pausa?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Valuta personalizzata
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Cambio: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3446,3 +3457,20 @@
 STR_FACE_EARRING                                                :Orecchino:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Cambia la cravatta o l'orecchino
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Selezione segnale
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Impossibile convertire i segnali qui...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Segnale normale (semaforico){}I segnali sono necessari per impedire ai treni di scontrarsi su reti ferroviarie con più di un treno.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Pre-segnale (semaforico){}Verde se è presente almeno un segnale di uscita verde al termine della sezione di blocco successiva. Altrimenti presenta il rosso.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Segnale di uscita (semaforico){}Si comporta come un segnale normale, ma è necessario per far funzionare correttamente i pre-segnali e i segnali combinati all'ingresso della sezione di blocco.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Segnale combinato (semaforico){}Un segnale combinato funziona contemporaneamente da segnale d'uscita e da pre-segnale. In questo modo è possibile costruire "alberi" di pre-segnali.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Segnale normale (luminoso){}I segnali sono necessari per impedire ai treni di scontrarsi su reti ferroviarie con più di un treno.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Pre-segnale (luminoso){}Verde se è presente almeno un segnale di uscita verde al termine della sezione di blocco successiva. Altrimenti presenta il rosso.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Segnale di uscita (luminoso){}Si comporta come un segnale normale, ma è necessario per far funzionare correttamente i pre-segnali e i segnali combinati all'ingresso della sezione di blocco.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Segnale combinato (luminoso){}Un segnale combinato funziona contemporaneamente da segnale d'uscita e da pre-segnale. In questo modo è possibile costruire "alberi" di pre-segnali.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Conversione segnali - Se attivato, facendo clic su un segnale esistente lo si converte nel tipo selezionato, mentre con CTRL+clic se ne modifica la variante.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Distanza fra i segnali costruiti automaticamente trascinando il cursore
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Riduce la distanza fra i segnali costruiti
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Aumenta la distanza fra i segnali costruiti
+########
--- a/src/lang/japanese.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/japanese.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -941,6 +941,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}フルスクリーン
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}OpenTTD をフルスクリーンでプレイするにはチックします
+STR_FULLSCREEN_FAILED                                           :{WHITE}フルスクリーンモードが設定できません
 
 STR_OPTIONS_RES                                                 :{BLACK}画面の解像度
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1169,6 +1170,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}他の会社が所有している株式の購入を入にする
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}ドラッグするときの信号設備頻度:{ORANGE}{STRING}
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}次の年まで腕木式信号を建設:{ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}信号のインタフェースを使用:{ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}シナリオエディタを使用時に、「道路網を拡大せず」という道路網が選択できません
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}道路網の選択:{ORANGE}{STRING}
@@ -1705,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}まずは建物を破壊しなければなりません
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}人口:{ORANGE}{COMMA}人{BLACK} 建物:{ORANGE}{COMMA}戸
@@ -2308,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}本部ビルを移動
 STR_COMPANY_PASSWORD                                            :{BLACK}パスワード
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}他のプレヤーがこの会社の経営に参加できないようにするには、パスワードで保護します
-STR_SET_COMPANY_PASSWORD                                        :会社のパスワードを設定
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}会社のパスワードを設定
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}入力したパスワードを保存しない
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}選択した交通会社の新しいパスワードを設定
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}交通会社のパスワード
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}デフォルトの交通会社のパスワード
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}このパスワードを新しい交通会社のパスワードとして使用
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}世界中不景気!{}{}経済がスランプに陥る、アナリストの不安説!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}スランプの終わり!{}{}経済が上昇気流、産業が好転!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}大きい/小さいウィンドウサイズを切り替えます
@@ -2789,6 +2797,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}{STRING}が新登場!ー{ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}破壊した車両が売却できません...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}破壊した車両が再装備できません...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}この車両に時刻表が設定できません...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}車両が駅/バス停のみで停車できます。
@@ -3109,6 +3118,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}見つからないファイルの代わりに対応している代替 GRF ファイルを使用しています
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}見つからない GRF ファイルを切にしています
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}ゲームを開くには次の GRF ファイルが必要
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}GRF ファイルが見つかりません
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}ポーズを解除した場合は、OpenTTD の安定性に悪影響を与える可能性があります。この後クラッシュが行った場合は、バグレポートの報告をご遠慮ください。{}ポーズを解除してもよろしいですか?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}カスタム通貨
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}為替レート:{ORANGE}{CURRENCY} = £ {COMMA}
@@ -3444,3 +3455,20 @@
 STR_FACE_EARRING                                                :イヤリング:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}ネクタイ/イヤリングを変更
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}信号の選択
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}ここに信号が交換できません...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}通常の信号(腕木式){}線路上に複数の電車が走った場合は、事故を避けるために信号が必要となります。
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}入り口の信号(腕木式){}信号の後ろにある部分にせめて一つの青い出口の信号があった場合は青いです。
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}出口の信号(腕木式){}通常の信号と同様の信号ですが、入り口、コンボの信号を使用した場合は、必要となります。
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}コンボ信号(腕木式){}コンボの信号は入り口信号と出口信号の機能を結合します。
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}通常の信号(電子式){}線路上に複数の電車が走った場合は、事故を避けるために信号が必要となります。
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}入り口の信号(電子式){}信号の後ろにある部分にせめて一つの青い出口の信号があった場合は青いです。
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}出口の信号(電子式){}通常の信号と同様の信号ですが、入り口、コンボの信号を使用した場合は、必要となります。
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}コンボ信号(電子式){}コンボの信号は入り口信号と出口信号の機能を結合します。
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}信号を交換{}すでに設置した信号をクリックしたときに選択した信号の書類に交換します。
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}ドラッグ時の信号設置密度
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}ドラッグ時の信号設置密度を減らす
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}ドラッグ時の信号設置密度を増やす
+########
--- a/src/lang/korean.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/korean.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -161,7 +161,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}이 지역을 파괴할 수 없습니다....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Original copyright {COPYRIGHT} 1995 Chris Sawyer, All rights reserved
 STR_00B7_VERSION                                                :{BLACK}OpenTTD 버전 {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 The OpenTTD team
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 The OpenTTD team
 STR_TRANSLATED_BY                                               :{BLACK}  한글화 -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -595,6 +595,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}회사 정보
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}산업 띄우기 / 끄기
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}경제적 변화
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}플레이어에 의한 산업시설의 생산품 변화
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}경쟁자에 의한 산업시설의 생산품 변화
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}다른 산업 생산물 변화
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}조언 / 당신 차량에 대한 정보
 STR_020C_NEW_VEHICLES                                           :{YELLOW}새로운 차량
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}역에서 받는 화물의 변경
@@ -861,6 +864,7 @@
 
 STR_0314_FUND_NEW_INDUSTRY                                      :{WHITE}새로운 산업시설 건설
 STR_JUST_STRING                                                 :{STRING}
+STR_JUST_INT                                                    :{NUM}
 STR_0316_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...도시에만 건설할 수 있습니다!
 STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST                        :{WHITE}...열대우림 지역에만 건설할 수 있습니다!
 STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT                            :{WHITE}...사막 지역에만 건설할 수 있습니다!
@@ -1021,6 +1025,7 @@
 STR_CONFIG_PATCHES_ON                                           :On
 STR_CONFIG_PATCHES_VEHICLESPEED                                 :{LTBLUE}상태바에 차량 속도를 표시 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BUILDONSLOPES                                :{LTBLUE}경사/해안가 건설을 허용 : {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AUTOSLOPE                                    :{LTBLUE}건물, 트랙 등의 하부 지형 편집 허용 (자동 슬로프): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_CATCHMENT                                    :{LTBLUE}드래그로 철도역 크기 설정 허용 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_EXTRADYNAMITE                                :{LTBLUE}도시 소유의 도로, 다리 등의 제거를 허용 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAMMOTHTRAINS                                :{LTBLUE}매우 긴 열차 허용 : {ORANGE}{STRING}
@@ -1041,12 +1046,14 @@
 STR_CONFIG_PATCHES_MULTIPINDTOWN                                :{LTBLUE}한 도시당 같은 종류의 산업시설의 중복 건설을 허용 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_SAMEINDCLOSE                                 :{LTBLUE}같은 종류의 산업 시설이 가까이에 지어지는 것을 허용 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LONGDATE                                     :{LTBLUE}날짜를 일(日)단위까지 상세하게 표시 : {ORANGE}{STRING}
-STR_CONFIG_PATCHES_SIGNALSIDE                                   :{LTBLUE}신호등을 통행 방식에 따라 달리 위치함. (좌측통행시 좌측에, 우측통행시 우측에) : {ORANGE}{STRING}
+STR_CONFIG_PATCHES_SIGNALSIDE                                   :{LTBLUE}신호등을 통행 방식에 따라 다른 위치에 설치 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_SHOWFINANCES                                 :{LTBLUE}연말에 재정 창을 띄움 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NEW_NONSTOP                                  :{LTBLUE}TTD패치에 적합한 급행(논스톱) 처리 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ROADVEH_QUEUE                                :{LTBLUE}(획기적 방법으로) 자동차를 대기하게 하기 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}가장자리에 마우스를 가져가면 화면을 움직이게 하기 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}지역 당국에 뇌물을 주는 행위 허용 : {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}독점 운송권 구입 허용: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}다른 회사에게 돈을 송금하는 것을 허용: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}이미 지어진 역에 추가로 역을 증축하는 것을 허용 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}향상된 글로벌 경로탐색 (NPF, NTP 우선) : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}무거운 열차를 운행하기 위해 화물에 무게를 가함 : {ORANGE}{STRING}
@@ -1093,7 +1100,7 @@
 STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR                       :{LTBLUE}철도/도로/항만/공항 툴바에 지형 정보 링크 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_REVERSE_SCROLLING                            :{LTBLUE}스크롤 방향 뒤집기 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_SMOOTH_SCROLLING                             :{LTBLUE}부드러운 뷰포인트 스크롤: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_MEASURE_TOOLTIP                              :{LTBLUE}다양한 건설도구를 사용시에 거리측정 툴팁 표시 : {ORANGE}{STRING}
+STR_CONFIG_PATCHES_MEASURE_TOOLTIP                              :{LTBLUE}건설도구 사용시 거리측정 툴팁 표시 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LIVERIES                                     :{LTBLUE}회사 조합원 표시 : {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LIVERIES_NONE                                :없음
 STR_CONFIG_PATCHES_LIVERIES_OWN                                 :내 회사
@@ -1112,13 +1119,16 @@
 
 STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME                            :{LTBLUE}새로운 게임 시작할 때 자동으로 일시정지: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS                       :{LTBLUE}진보된 차량 목록 사용: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF                   :끄기
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OWN                   :내 회사만
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_ALL                   :모든 회사에
 STR_CONFIG_PATCHES_LOADING_INDICATORS                           :{LTBLUE}적재 정도 표시: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LOADING_INDICATORS_OFF                       :끄기
 STR_CONFIG_PATCHES_LOADING_INDICATORS_OWN                       :소유한 회사
 STR_CONFIG_PATCHES_LOADING_INDICATORS_ALL                       :모든 회사
 STR_CONFIG_PATCHES_TIMETABLE_ALLOW                              :{LTBLUE}차량에 시간표 사용: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS                           :{LTBLUE}시간표를 일(日)이 아닌 틱으로 표시: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}기본 철도 종류 (새 게임/불러오기 후): {ORANGE}{STRING}
+STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}기본값으로 사용할 철도의 종류 (새 게임/불러오기 후): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_RAIL                       :보통 철도
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_ELRAIL                     :전개 철도
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MONORAIL                   :모노레일
@@ -1159,7 +1169,8 @@
 STR_CONFIG_PATCHES_SMOOTH_ECONOMY                               :{LTBLUE}부드러운 경제 설정 사용 (좀더 적은 변화)
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}다른 회사가 주식을 사는 것을 허용
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}드래그 할때 신호등을 매 {ORANGE}{STRING}타일마다 설치
-STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}자동으로 신호기 설치 : {ORANGE}{STRING} 이전에
+STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}전자식 신호기의 사용 : {ORANGE}{STRING}년 이후에
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}신호기 GUI를 사용: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}도시설계 "도로건설 안함"은 시나리오 에디터에서 유효하지 않습니다
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}도시도로 설계: {ORANGE}{STRING}
@@ -1389,13 +1400,13 @@
 STR_NETWORK_INTERNET                                            :인터넷
 STR_NETWORK_LAN_INTERNET                                        :LAN / 인터넷
 STR_NETWORK_INTERNET_ADVERTISE                                  :인터넷 (광고 허용)
-STR_NETWORK_CLIENTS_SELECT                                      :{BLACK}{SKIP}{SKIP}{NUM}명 접속중
+STR_NETWORK_CLIENTS_SELECT                                      :{BLACK}{SKIP}{SKIP}{NUM}명
 STR_NETWORK_NUMBER_OF_CLIENTS                                   :{BLACK}최대 접속자 수:
 STR_NETWORK_NUMBER_OF_CLIENTS_TIP                               :{BLACK}최대 접속자수를 선택합니다. 모든 슬롯이 차있을 필요는 없습니다.
-STR_NETWORK_COMPANIES_SELECT                                    :{BLACK}{SKIP}{SKIP}{SKIP}{NUM}개의 회사
+STR_NETWORK_COMPANIES_SELECT                                    :{BLACK}{SKIP}{SKIP}{SKIP}{NUM}개
 STR_NETWORK_NUMBER_OF_COMPANIES                                 :{BLACK}최대 회사수:
 STR_NETWORK_NUMBER_OF_COMPANIES_TIP                             :{BLACK}서버의 회사의 수를 제한합니다
-STR_NETWORK_SPECTATORS_SELECT                                   :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{NUM}명 참관중
+STR_NETWORK_SPECTATORS_SELECT                                   :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{NUM}명
 STR_NETWORK_NUMBER_OF_SPECTATORS                                :{BLACK}최대 관전자수:
 STR_NETWORK_NUMBER_OF_SPECTATORS_TIP                            :{BLACK}게임을 관전하는 접속자의 수를 제한합니다
 STR_NETWORK_LANGUAGE_SPOKEN                                     :{BLACK}대화 언어:
@@ -1696,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}건물을 먼저 제거하십시오!
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}인구: {ORANGE}{COMMA}{BLACK}  가구수: {ORANGE}{COMMA}
@@ -2299,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}본사 재위치
 STR_COMPANY_PASSWORD                                            :{BLACK}암호
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}다른 참가자가 이 회사로의 플레이를 하지 못하도록 암호로 보호합니다
-STR_SET_COMPANY_PASSWORD                                        :회사 암호 설정
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}회사 암호 설정
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}입력한 비밀번호는 저장하지 않기
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}이 회사에 새 비밀번호 부여
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}회사 비밀번호
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}회사 비밀번호 기본값
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}이 회사 비밀번호를 새 회사의 비밀번호 기본값으로 사용
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}세계 공황!{}{}경제 전문가들이 경제 슬럼프에 대해 우려를 표망하고 있습니다!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}공황 종료!{}{}무역량의 증대로 경제를 살려낸 결과 산업시설에 대한 신뢰를 가져왔습니다!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}대형/소형 창 크기 토글
@@ -2780,6 +2797,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}신형 {STRING} 이(가) 출시되었습니다!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}폭발한 차량을 팔 수 없습니다...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}파괴된 차량은 개조할 수 없습니다...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}차량의 시간표를 정할 수 없습니다...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}정거장에서만 기다릴 수 있습니다.
@@ -3100,6 +3118,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}사라진 파일의 자리에 알맞은 GRF가 로드되었습니다
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}사라진 GRF 파일은 사용불가능합니다
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}사라진 GRF 파일이 게임 로드에 사용될 수 있습니다
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}GRF 파일 손실
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}일시정지는 OpenTTD를 망가뜨릴 수 있습니다. 차후에 나오는 버그를 위해 버그 리포트를 파일로 만들지 마십시오.{}일시정지하시겠습니까?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}사용자 화폐 단위
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}환율: {ORANGE}{CURRENCY} = {COMMA}파운드
@@ -3435,3 +3455,20 @@
 STR_FACE_EARRING                                                :귀걸이:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}넥타이/귀걸이 변경
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}신호기 선택
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}이곳의 신호기를 변환할 수 없습니다...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}표준 신호기 (구식){}신호등은 하나 이상의 열차가 한 철도 네트워크상에서 폭발사고를 일으키지 않게 해줍니다.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}입구 신호기 (구식){}다음 폐색 구간에 출구 신호등이 하나라도 파란불이면 파란불이 뜨고 그렇지 않으면 빨간불이 됩니다.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}출구-신호기 (구식){}일반 신호등과 같은 방법으로 만들되, 입구 & 콤보 전면 신호기와 올바르게 연계되어야 합니다.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}콤보-신호기 (구식){}콤보-신호기는 입구/출구 신호기의 역할을 동시에 합니다. 이 신호기는 거대한 전면신호기의 "나무구조"를 건설할 수 있게 합니다.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}표준 신호기 (전자식){}신호등은 하나 이상의 열차가 한 철도 네트워크상에서 폭발사고를 일으키지 않게 해줍니다.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}입구-신호기 (전자식){}다음 폐색 구간에 출구 신호등이 하나라도 파란불이면 파란불이 뜨고 그렇지 않으면 빨간불이 됩니다.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}출구-신호기 (전자식){}일반 신호등과 같은 방법으로 만들되, 입구 & 콤보 전면 신호기와 올바르게 연계되어야 합니다.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}콤보-신호기 (전자식){}콤보-신호기는 입구/출구 신호기의 역할을 동시에 합니다. 이 신호기는 거대한 전면신호기의 "나무구조"를 건설할 수 있게 합니다.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}신호기 변환{}선택했을 때, 이미 설치한 신호기를 클릭하면 선택한 신호기의 타입과 종류를 변경하게 되고, CTRL+클릭은 존재하는 종류를 토글할 것입니다.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}드래그시 신호기 간격
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}드래그시 신호기 간격 감소
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}드래그시 신호기 증가
+########
--- a/src/lang/lithuanian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/lithuanian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 ##case kas ko kam ka kuo kur kreip
 ##gender vyr mot
 
+#
+
 ##id 0x0000
 STR_NULL                                                        :
 STR_0001_OFF_EDGE_OF_MAP                                        :{WHITE}Už žemelapio kraštų
@@ -192,7 +194,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Negalima griauti šios teritorijos....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Pradinės versijos teisės priklauso {COPYRIGHT} 1995 Chris Sawyer, Visos teisės saugomos
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versija {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD komanda
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD komanda
 STR_TRANSLATED_BY                                               :{BLACK}  Vertejai: Mindaugas Surdokas (L781), Vytautas Liuolia
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -313,6 +315,7 @@
 STR_OSNAME_MORPHOS                                              :MorphOS
 STR_OSNAME_AMIGAOS                                              :AmigaOS
 STR_OSNAME_OS2                                                  :OS/2
+STR_OSNAME_SUNOS                                                :SunOS
 
 STR_013B_OWNED_BY                                               :{WHITE}...priklauso {STRING}
 STR_013C_CARGO                                                  :{BLACK}Keliamoji galia
@@ -781,6 +784,7 @@
 STR_02A1_SMALL                                                  :{BLACK}Mažas
 STR_02A2_MEDIUM                                                 :{BLACK}Vidutinis
 STR_02A3_LARGE                                                  :{BLACK}Didelis
+STR_SCENARIO_EDITOR_CITY                                        :{BLACK}Miestas
 STR_02A4_SELECT_TOWN_SIZE                                       :{BLACK}Išsirinkite miesto dydį
 STR_02A5_TOWN_SIZE                                              :{YELLOW}Miesto dydis:
 
@@ -805,6 +809,7 @@
 STR_02C5_DIFFICULTY_SETTINGS                                    :Sunkumo lygio nustatymai
 STR_02C7_CONFIG_PATCHES                                         :Papildomi nustatymai
 STR_NEWGRF_SETTINGS                                             :Papild. grafikos nustatymai (NewGRF)
+STR_TRANSPARENCY_OPTIONS                                        :Permatomumo nustatymai
 STR_GAMEOPTMENU_0A                                              :
 STR_02CA_TOWN_NAMES_DISPLAYED                                   :{SETX 12}Rodyti miestų pavadinimus
 STR_02CC_STATION_NAMES_DISPLAYED                                :{SETX 12}Rodyti stotelių pavadinimus
@@ -1060,6 +1065,7 @@
 STR_CONFIG_PATCHES_SELECTGOODS                                  :{LTBLUE}Pristatyti krovini stotelei tiktai tuomet, kai yra poreikis: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LONGBRIDGES                                  :{LTBLUE}Leisti statyti labai ilgus tiltus: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_GOTODEPOT                                    :{LTBLUE}Leisti naudoti uzduoti 'Keliauti i depa': {ORANGE}{STRING}
+STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD_NONE        :nėra
 STR_CONFIG_PATCHES_MULTIPINDTOWN                                :{LTBLUE}Leisti kelias panašias pramonės įmones viename mieste: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_SAMEINDCLOSE                                 :{LTBLUE}Leisti statyti to paties tipo fabrikus arti vienas kito: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_LONGDATE                                     :{LTBLUE}Rodyti pilna data busenos eiluteje: {ORANGE}{STRING}
@@ -1119,6 +1125,8 @@
 STR_CONFIG_PATCHES_LIVERIES_ALL                                 :Visų kompanijų
 STR_CONFIG_PATCHES_PREFER_TEAMCHAT                              :{LTBLUE}Rašyti komandai naudojant <ĮVESTI> (ENTER): {ORANGE}{STRING}
 
+
+
 STR_CONFIG_PATCHES_MAX_TRAINS                                   :{LTBLUE}Maks. traukiniu vienam zaidejui: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAX_ROADVEH                                  :{LTBLUE}Maks. automobiliu zaidejui: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAX_AIRCRAFT                                 :{LTBLUE}Maks. lektuvu zaidejui: {ORANGE}{STRING}
@@ -1151,6 +1159,8 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Leisti pirkti kitų kompanijų akcijas
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Tempiant, kopijuoti šviesoforus kas: {ORANGE}{STRING} langel{P į lius lių}
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automatiškai pastatyti semaforus prieš: {ORANGE}{STRING}
+
+
 STR_CONFIG_PATCHES_TOOLBAR_POS                                  :{LTBLUE}Pagrindines irankiu juostos pozicija: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT                             :Kaireje
 STR_CONFIG_PATCHES_TOOLBAR_POS_CENTER                           :Centruoti
@@ -1354,12 +1364,12 @@
 STR_NETWORK_PASSWORD_TIP                                        :{BLACK}Apsaugokite savo zaidima slaptazodziu, jei nenorite, kad jis butu viesai prieinamas
 STR_NETWORK_SELECT_MAP                                          :{BLACK}Pasirinkite zemelapi:
 STR_NETWORK_SELECT_MAP_TIP                                      :{BLACK}Kuriame zemelapyje norite zaisti?
-STR_NETWORK_NUMBER_OF_CLIENTS                                   :{BLACK}Maksimalus klientu skaicius:
-STR_NETWORK_NUMBER_OF_CLIENTS_TIP                               :{BLACK}Pasirinkite maksimalu klientu skaiciu. Nebutinai visos jungtys turi buti uzpildytos
 STR_NETWORK_LAN                                                 :Vietinis tinklas
 STR_NETWORK_INTERNET                                            :Internetas
 STR_NETWORK_LAN_INTERNET                                        :Vietinis tinklas/ Internetas
 STR_NETWORK_INTERNET_ADVERTISE                                  :Internetas (visiems)
+STR_NETWORK_NUMBER_OF_CLIENTS                                   :{BLACK}Maksimalus klientu skaicius:
+STR_NETWORK_NUMBER_OF_CLIENTS_TIP                               :{BLACK}Pasirinkite maksimalu klientu skaiciu. Nebutinai visos jungtys turi buti uzpildytos
 STR_NETWORK_NUMBER_OF_COMPANIES                                 :{BLACK}Maksimum kompaniju:
 STR_NETWORK_NUMBER_OF_COMPANIES_TIP                             :{BLACK}Riboti serveri iki tam tikro skaiciaus kompaniju
 STR_NETWORK_NUMBER_OF_SPECTATORS                                :{BLACK}Maksimum ziurovu:
@@ -1878,6 +1888,9 @@
 STR_4829_REQUIRES                                               :{BLACK}Reikalauja: {YELLOW}{STRING.ko}, {STRING.ko}, {STRING.ko}
 ############ range for requires ends
 
+############ range for produces starts
+############ range for produces ends
+
 STR_482A_PRODUCTION_LAST_MONTH                                  :{BLACK}Praėjusio mėnesio produkcija:
 STR_482B_TRANSPORTED                                            :{YELLOW}{CARGO}{BLACK} ({COMMA}% transportuota)
 STR_482C_CENTER_THE_MAIN_VIEW_ON                                :{BLACK}Rodyti gamykla ekrano centre
@@ -2184,7 +2197,7 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Perkelti bustine
 STR_COMPANY_PASSWORD                                            :{BLACK}Slaptazodis
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Slaptazodis apsaugo tavo kompanija nuo neleistinu vartotoju prisijungimo.
-STR_SET_COMPANY_PASSWORD                                        :Ivesti slaptazodi
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Ivesti slaptazodi
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Pasauline krize!{}{}Ekonomikai griuvant, finansu ekspertai bijo paties blogiausio!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Krize iveikta!{}{}Prekybos pagyvejimas suteikia naujas viltis pramones imonems!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Pakeisti lango dydi
@@ -2518,6 +2531,7 @@
 STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT                             :Važiuoti nestojant į {TOWN} traukinių depą
 STR_SERVICE_NON_STOP_AT_TRAIN_DEPOT                             :Remontas nestojant {TOWN} traukiniu depe
 
+
 STR_HEADING_FOR_TRAIN_DEPOT                                     :{ORANGE}Kursas i {TOWN} depa
 STR_HEADING_FOR_TRAIN_DEPOT_VEL                                 :{ORANGE}Kursas i {TOWN} depa, {VELOCITY}
 STR_HEADING_FOR_TRAIN_DEPOT_SERVICE                             :{LTBLUE}Servisas {TOWN} Traukiniu Depe
@@ -2639,6 +2653,9 @@
 STR_TRAIN_NO_POWER                                              :{RED}Nėra energijos
 STR_TRAIN_START_NO_CATENARY                                     :Šiuose bėgiuose trūkta grandies, taigi traukiniai negali judėti
 
+
+
+
 ##id 0x9000
 STR_9000_ROAD_VEHICLE_IN_THE_WAY                                :{WHITE}Automobilis kelyje
 STR_9001_ROAD_VEHICLES                                          :{WHITE}{COMPANY} - {COMMA} Automobiliai
@@ -2846,6 +2863,7 @@
 STR_GO_TO_AIRPORT_HANGAR                                        :Kursas: {STATION} angaras
 SERVICE_AT_AIRPORT_HANGAR                                       :Remontas {STATION} angare
 
+
 ##id 0xB000
 STR_B000_ZEPPELIN_DISASTER_AT                                   :{BLACK}{BIGFONT} Dirizablio katastrofa {STATION}!
 STR_B001_ROAD_VEHICLE_DESTROYED                                 :{BLACK}{BIGFONT}Automobilis sunaikintas ateiviu!
@@ -2899,6 +2917,7 @@
 STR_NEWGRF_MD5SUM                                               :{BLACK}MD5suma: {SILVER}{STRING}
 STR_NEWGRF_CONFIRMATION_TEXT                                    :{YELLOW}Jūs norite atlikti pakeitimus veikiančiam žaidimui: OpenTTD gali pakibti.{}Ar jūs tikrai norite tai atlikti?
 
+
 STR_NEWGRF_ADD                                                  :{BLACK}Pridėti
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Pridėti Papild. grafikos failą į sąrašą
 STR_NEWGRF_REMOVE                                               :{BLACK}Pašalinti
@@ -3123,4 +3142,24 @@
 STR_MEASURE_LENGTH_HEIGHTDIFF                                   :{BLACK}Atstumas: {NUM}{}Aukščių skirtumas: {NUM} m
 STR_MEASURE_AREA_HEIGHTDIFF                                     :{BLACK}Sritis: {NUM} x {NUM}{}Aukščių skirtumas: {NUM} m
 
+############ Date formatting
+
 ########
+
+
+
+
+##### Mass Order
+
+
+
+
+
+
+#### Improved sign GUI
+
+########
+
+
+############ Face formatting
+########
--- a/src/lang/norwegian_bokmal.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/norwegian_bokmal.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -161,7 +161,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Kan ikke rydde dette området...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Opprinnelig opphavsbeskyttet {COPYRIGHT} 1995 Chris Sawyer, Alle rettigheter reservert
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versjon {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD-teamet
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD-teamet
 STR_TRANSLATED_BY                                               :{BLACK}  Oversetter(e) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -595,6 +595,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Firmainformasjon
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Åpninger / Stengninger av industrier
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Økonomiske endringer
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Produksjonsendringer hos industrier som får leveranser av spilleren
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Produksjonsendringer hos industrier som får leveranser av motspiller(e)
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Andre produksjonsendringer
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Råd/informasjon om spillers kjøretøy
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Nye kjøretøy
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Endringer i godtatte varer
@@ -939,6 +942,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Fullskjerm
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Kryss av i denne boksen for å spille OpenTTD i fullskjermmodus
+STR_FULLSCREEN_FAILED                                           :{WHITE}Fullskjerm modus mislykkes
 
 STR_OPTIONS_RES                                                 :{BLACK}Skjermoppløsning
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1167,6 +1171,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Tillat aksjekjøp i andre selskaper
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Ved dra-og-slipp, plasser signal på hver {ORANGE}{STRING}. rute
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Bygg signalsystem med mast automatisk før: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Slå på signalgrensesnittet: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Byutlegget «ingen flere veier» er ikke gyldig i scenariobyggeren
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Velg byvei-layout: {ORANGE}{STRING}
@@ -1681,6 +1686,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Bygg bro for trikkespor
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Bygg tunnel
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Bygg tunnel for trikkespor
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Aktiver/deaktiver énveiskjørte veier
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Velg mellom bygging/fjerning for veibygging
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Velg mellom bygging/fjerning for trikkesporkonstruksjon
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Velg garasjens retning
@@ -1702,6 +1708,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Bygningen må rives først
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Innbyggertall: {ORANGE}{COMMA}{BLACK}  Antall hus: {ORANGE}{COMMA}
@@ -2305,7 +2312,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Omplasser hovedkvarter
 STR_COMPANY_PASSWORD                                            :{BLACK}Passord
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Passordbeskytt ditt firma for å forhindre uautoriserte brukere fra å bli med. Bruk '*' for å tømme passord.
-STR_SET_COMPANY_PASSWORD                                        :Velg firmapassord
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Velg firmapassord
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Ikke lagre passordet
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Gi firmaet nytt passord
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Firmapassord
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Standard firmapassord
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Bruk dette passordet som standard for nye firmaer
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Verdenskrise!{}{}Økonomer frykter det verste. Nedgangstider i møte.
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Verdenskrise over!{}{}Opptur i markedet gir industrien selvsikkerheten tilbake.
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Bytte mellom stor/liten vindustørrelse
@@ -2786,6 +2798,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Ny {STRING} Nå tilgjengelig!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Kan ikke selge ødelagt kjøretøy...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Kan ikke ombygge ødelagt kjøretøy...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Kan ikke gi kjøretøy tidstabell...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Kjøretøy kan bare vente på stasjoner.
@@ -3106,6 +3119,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatibel GRF lastet for manglende filer
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Manglende GRF-fil(er) har blitt slått av
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Mangler GRF-fil(er) nødvendige for å laste spillet
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Mangler GRF-fil(er)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Å slå av pause kan gjøre at OpenTTD krasjer. Ikke rapporter feil for etterfølgende krasje.{}Ønsker du virkelig å slå av pause?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Vanlig valuta
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Valutakurs: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3286,6 +3301,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Midstill oversiktskartet på den gjeldende posisjonen
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Liten
@@ -3440,3 +3456,20 @@
 STR_FACE_EARRING                                                :Ørering:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Endre slips eller ørering
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Signalvalg
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Kan ikke konvertere signaler her...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standardsignal{}Signaler trengs for å forhindre tog fra å kræsje med hverandre på spor med mer enn ett tog.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Grønt så lenge det er mer enn ett grønt utgangssignal fra etterfølgende sporseksjon. Ellers rødt.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Utgangssignal (semafor){}Oppfører seg på samme måte som et vanlig signal ville gjort, men er nødvendig for å riktig farge på inngangs- og kombinasjonspresignaler.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Kombinasjonssignal (semafor){}Kombinasjonssignalet fungerer både som inn- og utgangssignal. Dette gjør at du kan bygge «trær» av presignaler.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Vanlig signal (elektrisk){}Signaler trengs for å forhindre togkrasj på jernbanenettverk med mer enn ett tog.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Inngangssignal (elektrisk){}Grønt så lenge det er mer enn ett grønt utgangssignal fra etterfølgende sporseksjon. Ellers rødt.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Utgangssignal (elektrisk){}Oppfører seg på samme måte som et vanlig signal ville gjort, men er nødvendig for å riktig farge på inngangs- og kombinasjonspresignaler.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Kombinasjonssignal (elektrisk){}Kombinasjonssignalet fungerer både som inn- og utgangssignal. Dette gjør at du kan bygge «trær» av presignaler.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Signalkonvertering{}Konverterer signaler til den valgte signaltypen; Ctrl-klikk vil endre eksisterende variant.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Signaltetthet ved dra-og-slipp
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Senk signaltetthet ved dra-og-slipp
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Øk signaltetthet ved dra-og-slipp
+########
--- a/src/lang/norwegian_nynorsk.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/norwegian_nynorsk.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -161,7 +161,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Kan ikkje rydde dette området...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Opphaveleg opphavsbeskytta {COPYRIGHT} 1995 Chris Sawyer, Alle rettigheter reservert
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versjon {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD-teamet
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD-teamet
 STR_TRANSLATED_BY                                               :{BLACK}  Omsett av -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -595,6 +595,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Firma informasjon
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Opning / stenging av industriar
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Økonomiske endringar
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Produksjonsendringar for industriar betente av spelaren sjølve
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Produksjonsendringar for industriar betente av konkurrent(ar)
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Produksonsendringar for andre industriar
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Råd/informasjon om køyretøya til spelaren
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Nye køyretøy
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Endringar i godtekne varer
@@ -1167,6 +1170,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Tillat kjøping av aksjar i andre selskap
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Ved opptrekking, plasser signal hver: {ORANGE}{STRING} rute{P "" r}
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Bygg semaforer automatisk før: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Bruk signal GUI: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Byoppsettet " ingen fleire vegar" kan ikkje brukast i scenarioredigeringsprogrammet
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Velg oppsett for byvegar: {ORANGE}{STRING}
@@ -1681,6 +1685,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Bygg bro for trikk
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Bygg tunnel
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Bygg tunell for trikk
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Aktiver / Deaktiver envegskøyrde vegar
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Vel mellom bygging/fjerning for vegbygging
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Byt mellom bygge / fjerne for trikk
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Vel retninga på garasjen
@@ -1702,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Bygningen må rivst først
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Innbyggjartal: {ORANGE}{COMMA}{BLACK}  Antal hus: {ORANGE}{COMMA}
@@ -2305,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Omplasser hovudkvarter
 STR_COMPANY_PASSWORD                                            :{BLACK}Passord
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Passordbeskytt firmaet ditt slik at ikkje alle og einkvar kan verte med. Bruk '*' for å tømme passord.
-STR_SET_COMPANY_PASSWORD                                        :Vel firmapassord
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Vel firmapassord
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK} Ikkje lagre passordet
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Gje firmaet nytt passord
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Firmapassord
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Standard passord for firma
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Bruk passordet fra dette firmaet som standard for nye firma
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Verdskrise!{}{}Økonomar fryktar det verste. Nedgangstider i kjømda.
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Verdskrise over!{}{}Opptur i marknaden gjer industrien sjølvkjensla attende.
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Byt mellom stor/liten storleik på vindauga
@@ -3077,6 +3088,7 @@
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} må være lasta etter {STRING}.
 STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} Behøver OpenTTD versjon {STRING} eller betre.
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :GRF fila den var laga for å omsetje
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :For mange NewGRF lasta
 
 STR_NEWGRF_ADD                                                  :{BLACK}Legg til
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Legg ei ny NewGRF-fil til lista
@@ -3105,6 +3117,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Ein eller fleire kompatible GRF-filar har vorte lasta inn i plassen for manglande filar
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Ein eller fleire manglande GRF-filar har vorte deaktiverte
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Manglar ein eller fleire GRF-filer for å kunne laste inn spelet
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Manglar GRF fil(er)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Unpausing can crash OpenTTD. Do not file bug reports for subsequent crashes.{}Do you really want to unpause?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Vanleg valuta
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Valutakurs: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3285,6 +3299,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Still oversiktskartet midt på på den gjeldande posisjonen
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Liten
@@ -3439,3 +3454,20 @@
 STR_FACE_EARRING                                                :Øyrering:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Bytt slips eller øyrering
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Signal Selection
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Kan ikkje endre signal her
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standard Signal (semaphore){}Signals are necessary to keep trains from crashing on railway networks with more than one train.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Entry-Signal (semaphore){}Grønt så lenge det er eit eller fleir grøne ut-signal i den følgande seksjonen. Ellers syner det raudt.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Ut-Signal (semaphore){}Virker på samme måte som normale signal, men er naudsynte for å få rett farge på inn og combo pre-signal.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Combo-Signal (semaphore){}Combo signal fungerer som både inn og ut signal. Det gjer deg moglegheit til å bygge store "tre" av presignal.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standard Signal (elektrisk){}Signals er naudsynte for at tog ikkje skal kollidere når det er meir en ett på linja.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}In-Signal (elektrisk){}Grøn så lenge det er eit eller fleir grønne ut signal fra den følgande seksjonen. Ellers synar det raudt.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Ut-Signal (elektrisk){}Verker på samme måte som vanlege signal, men er naudsynt for å gje rett farge på in og combo pre-signal
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Combo-Signal (elektrisk){}Verker som både inn og ut signaler og gjer det moglegheit til å lage store "tre" av presignal
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Signal Konvertering{}Klikk på eit signal for å endra det til valde type, CTRL-klikk  skifter mellom forskjellige variantar.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Tettleik for dra og slepp signalbygging
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Minsk tettleik for dra og slepp signalbygging
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Auk tettleik for dra og slepp signalbygging
+########
--- a/src/lang/piglatin.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/piglatin.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}An'tcay earclay isthay areaway....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Originalway opyrightcay {COPYRIGHT} 1995 Ischray Awyersay, Allway ightsray eservedray
 STR_00B7_VERSION                                                :{BLACK}OpenTTDWAY ersionvay {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTDWAY {COPYRIGHT}2002-2007 Ethay OpenTTDWAY eamtay
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTDWAY {COPYRIGHT}2002-2008 Ethay OpenTTDWAY eamtay
 STR_TRANSLATED_BY                                               :{BLACK}  Anslatortray(say) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -2295,7 +2295,7 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Elocateray HQay
 STR_COMPANY_PASSWORD                                            :{BLACK}Asswordpay
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Asswordpay-otectpray ouryay ompanycay otay eventpray unauthorisedway usersway omfray oiningjay.
-STR_SET_COMPANY_PASSWORD                                        :Etsay ompanycay asswordpay
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Etsay ompanycay asswordpay
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Orldway Ecessionray!{}{}Inancialfay expertsway earfay orstway asway economyway umpsslay!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Ecessionray Overway!{}{}Upturnway inway adetray ivesgay onfidencecay otay industriesway asway economyway engthensstray!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Oggletay argelay/allsmay indowway izesay
--- a/src/lang/polish.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/polish.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -204,7 +204,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Nie można wyczyścić terenu...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Prawa Autorskie {COPYRIGHT} 1995 Chris Sawyer, Wszelkie Prawa Zastrzeżone
 STR_00B7_VERSION                                                :{BLACK}OpenTTD wersja {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 Zespół OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 Zespół OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Tłumacz(e) - : Tom PolPot Spooqy MeusH
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -647,6 +647,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Informacja firmy
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Otwarcie / zamknięcie przedsiębiorstw
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Zmiany ekonomiczne
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Zmiany produkcji przedsiębiorstw obsługiwanych przez gracza
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Zmiany produkcji przedsiębiorstw obsługiwanych przez przeciwników
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Zmiany produkcji pozostałych przedsiębiorstw
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Porady / informacje o pojazdach gracza
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Nowe pojazdy
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Zamiany w akceptowaniu ładunku
@@ -699,7 +702,7 @@
 STR_023B_INCREASE_SIZE_OF_TOWN                                  :{BLACK}Zwiększ rozmiar miasta
 STR_023C_EXPAND                                                 :{BLACK}Rozszerz
 STR_023D_RANDOM_TOWN                                            :{BLACK}Losowe miasto
-STR_023E_BUILD_TOWN_IN_RANDOM_LOCATION                          :{BLACK}Budowanie miasta w losowym miejscu
+STR_023E_BUILD_TOWN_IN_RANDOM_LOCATION                          :{BLACK}Budowa miasta w losowym miejscu
 STR_023F_INDUSTRY_GENERATION                                    :{WHITE}Tworzenie przedsiębiorstw
 STR_0240_COAL_MINE                                              :{BLACK}{G=f}Kopalnia Węgla
 STR_0240_COAL_MINE.d                                            :{BLACK}{G=f}kopalni węgla
@@ -947,6 +950,7 @@
 
 STR_0314_FUND_NEW_INDUSTRY                                      :{WHITE}Ufunduj nowe przedsięb.
 STR_JUST_STRING                                                 :{STRING}
+STR_JUST_INT                                                    :{NUM}
 STR_0316_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...może być wybudowane tylko w mieście
 STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST                        :{WHITE}...może być wybudowane tylko w lasach deszczowych
 STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT                            :{WHITE}...może być wybudowane tylko na pustyni
@@ -1107,6 +1111,7 @@
 STR_CONFIG_PATCHES_ON                                           :wł.
 STR_CONFIG_PATCHES_VEHICLESPEED                                 :{LTBLUE}Pokazuj prędkość pojazdów w pasku statusu: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BUILDONSLOPES                                :{LTBLUE}Pozwól budować na pochyłościach i wybrzeżach: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AUTOSLOPE                                    :{LTBLUE}Pozwól na zmiany terenu pod budynkami, torami (autoslope): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_CATCHMENT                                    :{LTBLUE}Zezwól na bardziej realistyczny zasięg obejmowania: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_EXTRADYNAMITE                                :{LTBLUE}Pozwól usuwać drogi, mosty, tunele, itp. należące do miasta: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAMMOTHTRAINS                                :{LTBLUE}Pozwól budować bardzo długie pociągi: {ORANGE}{STRING}
@@ -1133,6 +1138,8 @@
 STR_CONFIG_PATCHES_ROADVEH_QUEUE                                :{LTBLUE}Ustawianie się samochodów w kolejkach (z efektem quantum): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Przesuń okno, kiedy kursor jest przy krawędzi: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Pozwól dawać łapówki lokalnym władzom: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Pozwól na kupno wyłączności transportowej: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Pozwól na wysyłanie pieniędzy do innych firm:: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Niejednolite stacje: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nowe szukanie drogi (NPF, zastępuje NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Mnożnik wagi dla symulacji ciężkich pociągów towarowych: {ORANGE}{STRING}
@@ -1190,9 +1197,21 @@
 STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLL                           :Przesuń widok
 STR_CONFIG_PATCHES_SCROLLWHEEL_OFF                              :Rolka wyłączona
 STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER                       :{LTBLUE}Prędkość przesuwania widoku: {ORANGE}{STRING}
+
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU                          :{LTBLUE}Emulacjia prawego przycisku myszy: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_COMMAND                  :Command-klik
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_CONTROL                  :Control-klik
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF                      :Wyłączona
+
 STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME                            :{LTBLUE}Automatycznie włącz pauzę przy rozpoczęciu nowej gry: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS                       :{LTBLUE}Używaj zaawansowanej listy pojazdów: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF                   :Nie używaj
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OWN                   :Dla własnej firmy
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_ALL                   :Dla wszystkich firm
 STR_CONFIG_PATCHES_LOADING_INDICATORS                           :{LTBLUE}Pokazuj wskaźniki załadunku: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LOADING_INDICATORS_OFF                       :Nie pokazuj
+STR_CONFIG_PATCHES_LOADING_INDICATORS_OWN                       :Dla własnej firmy
+STR_CONFIG_PATCHES_LOADING_INDICATORS_ALL                       :Dla wszystkich firm
 STR_CONFIG_PATCHES_TIMETABLE_ALLOW                              :{LTBLUE}Uaktywnij rozkłady jazdy pojazdów: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS                           :{LTBLUE}Pokazuj rozkłady jazdy w tickach, a nie w dniach: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}Domyślny typ torowiska (w nowej grze/po wczytaniu gry): {ORANGE}{STRING}
@@ -1237,6 +1256,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Pozwól kupować udziały w innych firmach
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}W trakcie przeciągania ustaw sygnały co: {ORANGE}{STRING} kratk{P e i ek}
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automatycznie buduj semafory przed: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Uaktywnij okno budowania sygnałów: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Plan sieci dróg "bez nowych dróg" nie jest poprawny dla edytora scenariuszy
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Wybierz plan sieci dróg miejskich: {ORANGE}{STRING}
@@ -1261,6 +1281,7 @@
 STR_CONFIG_PATCHES_LARGER_TOWNS                                 :{LTBLUE}Ilość miast które staną się metropoliami: {ORANGE}1 na {STRING}
 STR_CONFIG_PATCHES_LARGER_TOWNS_DISABLED                        :{LTBLUE}Ilość miast które staną się metropoliami: {ORANGE}Brak
 STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER                         :{LTBLUE}Początkowy mnożnik rozmiarów metropolii: {ORANGE}{STRING}
+STR_CONFIG_MODIFIED_ROAD_REBUILD                                :{LTBLUE}Usuwaj absurdalne fragmenty ulicy podczas rekonstrukcji dróg
 
 STR_CONFIG_PATCHES_GUI                                          :{BLACK}Interfejs
 STR_CONFIG_PATCHES_CONSTRUCTION                                 :{BLACK}Konstrukcje
@@ -1291,7 +1312,7 @@
 STR_CHEAT_CHANGE_PLAYER                                         :{LTBLUE}Graj jako gracz: {ORANGE}{COMMA}
 STR_CHEAT_EXTRA_DYNAMITE                                        :{LTBLUE}Magiczny buldożer (usuwanie przedsiębiorstw, itp.): {ORANGE}{STRING}
 STR_CHEAT_CROSSINGTUNNELS                                       :{LTBLUE}Tunele mogą się krzyżować: {ORANGE}{STRING}
-STR_CHEAT_BUILD_IN_PAUSE                                        :{LTBLUE}Budowanie w czasie pauzy: {ORANGE}{STRING}
+STR_CHEAT_BUILD_IN_PAUSE                                        :{LTBLUE}Budowa w czasie pauzy: {ORANGE}{STRING}
 STR_CHEAT_NO_JETCRASH                                           :{LTBLUE}Odrzutowce nie będą się często rozbijać na małych lotniskach: {ORANGE} {STRING}
 STR_CHEAT_SWITCH_CLIMATE                                        :{LTBLUE}Zmień klimat: {ORANGE} {STRING}
 STR_CHEAT_CHANGE_DATE                                           :{LTBLUE}Zmień datę: {ORANGE} {DATE_SHORT}
@@ -1320,7 +1341,7 @@
 STR_CANT_BUILD_TRAIN_WAYPOINT                                   :{WHITE}Nie można tutaj zbudować pkt. kontolnego...
 STR_CANT_REMOVE_TRAIN_WAYPOINT                                  :{WHITE}Nie można usunąć pkt. kontrolnego z tego miejsca...
 
-STR_BUILD_AUTORAIL_TIP                                          :{BLACK}Budowanie torów używając trybu Autorail
+STR_BUILD_AUTORAIL_TIP                                          :{BLACK}Budowa torów używając trybu Autorail
 
 STR_NO_TOWN_IN_SCENARIO                                         :{WHITE}...nie ma żadnego miasta w scenariuszu
 
@@ -1358,7 +1379,7 @@
 STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP                                :{BLACK}Przeciągnij tutaj lokomotywę by sprzedać cały pociąg
 
 STR_DRAG_DROP                                                   :{BLACK}Przeciągnij i upuść
-STR_STATION_DRAG_DROP                                           :{BLACK}Budowanie stacji używając przeciągnij i upuść
+STR_STATION_DRAG_DROP                                           :{BLACK}Budowj stację używając "przeciągnij i upuść"
 STR_SELECT_STATION_CLASS_TIP                                    :{BLACK}Wybierz rodzaj stacji do pokazania
 STR_SELECT_STATION_TYPE_TIP                                     :{BLACK}Wybierz typ stacji do zbudowania
 
@@ -1736,8 +1757,10 @@
 STR_1809_CAN_T_BUILD_CARGO_TRAM_STATION                         :{WHITE}Nie można zbudować tramwajowej stacji załadunkowej...
 STR_180A_ROAD_CONSTRUCTION                                      :Budowa drogi
 STR_180A_TRAMWAY_CONSTRUCTION                                   :Budowa torowiska tramwajowego
-STR_180B_BUILD_ROAD_SECTION                                     :{BLACK}Sekcja budowy dróg
+STR_180B_BUILD_ROAD_SECTION                                     :{BLACK}Budowa dróg
+STR_BUILD_AUTOROAD_TIP                                          :{BLACK}Budowa drogi używając trybu Autoroad
 STR_180B_BUILD_TRAMWAY_SECTION                                  :{BLACK}Zbuduj fragment torowiska tramwajowego
+STR_BUILD_AUTOTRAM_TIP                                          :{BLACK}Budowa torów tramwajowych używając trybu Autotram
 STR_180C_BUILD_ROAD_VEHICLE_DEPOT                               :{BLACK}Zbuduj zajezdnię samochodową (do budowania i serwisowania pojazdów)
 STR_180C_BUILD_TRAM_VEHICLE_DEPOT                               :{BLACK}Zbuduj zajezdnię tramwajową (do budowania i serwisowania pojazdów)
 STR_180D_BUILD_BUS_STATION                                      :{BLACK}Budowa przystanku
@@ -1748,6 +1771,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Zbuduj most tramwajowy
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Budowa tunelu drogowego
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Zbuduj tunel tramwajowy
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Włącz/Wyłącz drogi jednokierunkowe
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Przełącz buduj/usuń dla konstrukcji dróg
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Przełącz buduj/usuń dla konstrukcji torowiska tramwajowego
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Wybierz umiejscowienie zajezdni samochodowej
@@ -1769,6 +1793,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Należy najpierw zburzyć budynek
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Populacja: {ORANGE}{COMMA}{BLACK}  Domów: {ORANGE}{COMMA}
@@ -2127,6 +2152,8 @@
 STR_5006_MUST_DEMOLISH_TUNNEL_FIRST                             :{WHITE}Należy najpierw usunąć tunel
 STR_5007_MUST_DEMOLISH_BRIDGE_FIRST                             :{WHITE}Należy najpierw usunąć most
 STR_5008_CANNOT_START_AND_END_ON                                :{WHITE}Nie można zaczynać i kończyć w tym samym miejscu
+STR_BRIDGEHEADS_NOT_SAME_HEIGHT                                 :{WHITE}Początki mostu nie są na tej samej wysokości
+STR_BRIDGE_TOO_LOW_FOR_TERRAIN                                  :{WHITE}Most jest za nisko dla tego terenu
 STR_500A_START_AND_END_MUST_BE_IN                               :{WHITE}Początek i koniec muszą być w jednej linii
 STR_500B_SITE_UNSUITABLE_FOR_TUNNEL                             :{WHITE}Nieodpowiednie miejsce na wejście tunelu
 STR_500D                                                        :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY}
@@ -2406,7 +2433,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Przenieś SG
 STR_COMPANY_PASSWORD                                            :{BLACK}Hasło
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Ochrona hasłem Twojej firmy zapobiega nieautoryzowanemu przyłączeniu się
-STR_SET_COMPANY_PASSWORD                                        :Ustaw hasło firmy
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Ustaw hasło firmy
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Nie zapisuj podanego hasła
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Nadaj firmie nowe hasło
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Hasło firmy
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Hasło domyślne
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Użyj tego hasła jako domyślnego dla nowych firm
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Światowa recesja!{}{}Eksperci finansowi obawiają się najgorszego z powodu kryzysu!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Koniec recesji!{}{}Polepszenie się transakcji handlowych daje pewność przedsiębiorstwom dzięki umacniającej się ekonomii!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Przełącz duży/mały rozmiar okna
@@ -2892,6 +2924,9 @@
 STR_NEW_VEHICLE_TYPE                                            :{BLACK}{BIGFONT}{ENGINE}
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Dostępn{G y a e} now{G y a e} {STRING} - {ENGINE}!
 
+STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Nie można sprzedać zniszczonego pojazdu...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Nie można przebudować zniszczonego pojazdu...
+
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Nie można wyznaczyć rozkładu jazdy pojazdu...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Pojazdy mogą czekać tylko na stacjach.
 STR_TIMETABLE_NOT_STOPPING_HERE                                 :{WHITE}Ten pojazd nie zatrzymuje się na tej stacji.
@@ -3098,7 +3133,7 @@
 STR_A032_NAME_AIRCRAFT                                          :{BLACK}Nazwa samolotu
 STR_A033_CITIZENS_CELEBRATE_FIRST                               :{BLACK}{BIGFONT}Mieszkańcy świętują . . .{}Pierwszy samolot przyleciał na {STATION}!
 STR_A034_PLANE_CRASH_DIE_IN_FIREBALL                            :{BLACK}{BIGFONT}Katastrofa lotnicza!{}{COMMA} ofiar{P a y ""} na {STATION}
-STR_PLANE_CRASH_OUT_OF_FUEL                                     :{BLACK}{BIGFONT}Wypadek lotniczy!{}Samolot rozbił się z powodu braku paliwa, zginęło {COMMA} osób!
+STR_PLANE_CRASH_OUT_OF_FUEL                                     :{BLACK}{BIGFONT}Wypadek lotniczy!{}Samolot rozbił się z powodu braku paliwa, zginęł{P 0 a y o} {COMMA} os{P oba oby ób}!
 STR_A036                                                        :{TINYFONT}{BLACK}{STATION}
 STR_A037_RENAME                                                 :{BLACK}Zmień nazwę
 STR_A038_RENAME_AIRCRAFT_TYPE                                   :{BLACK}Zmień nazwę typu samolotu
@@ -3180,7 +3215,9 @@
 STR_NEWGRF_ERROR_INVALID_PARAMETER                              :Niewłaściwy parametr dla {STRING}: parametr {STRING} ({NUM})
 STR_NEWGRF_ERROR_LOAD_BEFORE                                    :{STRING} musi być wczytany przed {STRING}.
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} musi być wczytany po {STRING}.
+STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} wymaga OpenTTD w wersji {STRING} lub nowszej.
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :pliku GRF który miał być tłumaczony
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Wczytano za dużo NewGRF.
 
 STR_NEWGRF_ADD                                                  :{BLACK}Dodaj
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Dodaj plik NewGRF do listy
@@ -3209,6 +3246,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Wczytano kompatybilne GRF dla brakujących plików
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Brakujące pliki GRF zostały wyłączone
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Brak plików GRF potrzebnych do wczytania gry
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Brakujące pliki GRF
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Wyłączenie pauzy może zawiesić OpenTTD. Nie zgłaszaj błędów o powtarzających się zawieszeniach.{}Czy na pewno chcesz wyłączyć pauzę?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Własna waluta
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Współczynnik wymiany: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3389,6 +3428,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Wyśrodkuj mapę na aktualnej lokalizacji
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Małe
@@ -3495,3 +3535,68 @@
 STR_PROSPECT_NEW_INDUSTRY                                       :{BLACK}Zleć poszukiwanie
 STR_BUILD_NEW_INDUSTRY                                          :{BLACK}Wybuduj
 STR_INDUSTRY_SELECTION_HINT                                     :{BLACK}Wybierz przedsiębiorstwo z listy
+
+############ Face formatting
+STR_FACE_ADVANCED                                               :{BLACK}Zaawansowane
+STR_FACE_ADVANCED_TIP                                           :{BLACK}Zaawansowany widok wyboru twarzy.
+STR_FACE_SIMPLE                                                 :{BLACK}Prosty widok
+STR_FACE_SIMPLE_TIP                                             :{BLACK}Prosty widok wyboru twarzy.
+STR_FACE_LOAD                                                   :{BLACK}Wczytaj
+STR_FACE_LOAD_TIP                                               :{BLACK}Wczytaj ulubioną twarz
+STR_FACE_LOAD_DONE                                              :{WHITE}Twoja ulubiona twarz została wczytana z pliku konfiguracyjnego OpenTTD.
+STR_FACE_FACECODE                                               :{BLACK}Numer twarzy gracza
+STR_FACE_FACECODE_TIP                                           :{BLACK}Obejrzyj i/lub ustaw numer twarzy gracza
+STR_FACE_FACECODE_CAPTION                                       :{WHITE}Obejrzyj i/lub ustaw numer twarzy gracza
+STR_FACE_FACECODE_SET                                           :{WHITE}Ustawiono nowy numer twarzy gracza.
+STR_FACE_FACECODE_ERR                                           :{WHITE}Nie można ustawić numeru twarzy gracza - musi być liczbą pomiędzy 0 a 4'294'967'295!
+STR_FACE_SAVE                                                   :{BLACK}Zapisz
+STR_FACE_SAVE_TIP                                               :{BLACK}Zapisz ulubioną twarz
+STR_FACE_SAVE_DONE                                              :{WHITE}Ta twarz będzie zapisana w pliku konfiguracyjnym OpenTTD jako Twoja ulubiona
+STR_FACE_EUROPEAN                                               :{BLACK}Europejska
+STR_FACE_SELECT_EUROPEAN                                        :{BLACK}Wybierz twarz o karnacji europejskiej
+STR_FACE_AFRICAN                                                :{BLACK}Afrykańska
+STR_FACE_SELECT_AFRICAN                                         :{BLACK}Wybierz twarz o karnacji afrykańskiej
+STR_FACE_YES                                                    :Tak
+STR_FACE_NO                                                     :Nie
+STR_FACE_MOUSTACHE_EARRING_TIP                                  :{BLACK}Pokaż wąsy lub kolczyk
+STR_FACE_HAIR                                                   :Włosy:
+STR_FACE_HAIR_TIP                                               :{BLACK}Zmień włosy
+STR_FACE_EYEBROWS                                               :Rzęsy:
+STR_FACE_EYEBROWS_TIP                                           :{BLACK}Zmień rzęsy
+STR_FACE_EYECOLOUR                                              :Kolor oczu:
+STR_FACE_EYECOLOUR_TIP                                          :{BLACK}Zmień kolor oczu
+STR_FACE_GLASSES                                                :Okulary
+STR_FACE_GLASSES_TIP                                            :{BLACK}Uaktywnij okulary
+STR_FACE_GLASSES_TIP_2                                          :{BLACK}Zmień okulary
+STR_FACE_NOSE                                                   :Nos:
+STR_FACE_NOSE_TIP                                               :{BLACK}Zmień nos
+STR_FACE_LIPS                                                   :Usta:
+STR_FACE_MOUSTACHE                                              :Wąsy:
+STR_FACE_LIPS_MOUSTACHE_TIP                                     :{BLACK}Zmień usta lub wąsy
+STR_FACE_CHIN                                                   :Broda:
+STR_FACE_CHIN_TIP                                               :{BLACK}Zmień brodę
+STR_FACE_JACKET                                                 :Marynarka:
+STR_FACE_JACKET_TIP                                             :{BLACK}Zmień marynarkę
+STR_FACE_COLLAR                                                 :Kołnierz:
+STR_FACE_COLLAR_TIP                                             :{BLACK}Zmień kołnierz
+STR_FACE_TIE                                                    :Krawat:
+STR_FACE_EARRING                                                :Kolczyk:
+STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Zmień krawat lub kolczyk
+########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Wybór sygnałów
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Nie można tutaj zmienić sygnałów...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Zwykły sygnał (semafor){}Sygnały są potrzebne aby uniknąć zderzeń pociągów na liniach z więcej niż jednym pociągiem.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Pre-sygnał (semafor){}Jest zielony jeżeli zielony jest przynajmniej jeden exit-sygnał przy pobliskim skrzyżowaniu. W przeciwnym wypadku, jest czerwony.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Exit-sygnał (semafor){}Zachowuje się tak jak zwykły sygnał, ale wpływa na pobliskie pre- i combo-sygnały.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Combo-sygnał(semafor){}Sygnał combo skupia działanie zarówno pre- jak i exit-sygnałów. Pozwala to na budowę zaawansowanych układów sygnałów.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Zwykły sygnał (świetlny){}Sygnały są potrzebne aby uniknąć zderzeń pociągów na liniach z więcej niż jednym pociągiem.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Pre-sygnał (świetlny){}Jest zielony jeżeli zielony jest przynajmniej jeden exit-sygnał przy pobliskim skrzyżowaniu. W przeciwnym wypadku, jest czerwony.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Exit-sygnał (świetlny){}Zachowuje się tak jak zwykły sygnał, ale wpływa na pobliskie pre- i combo-sygnały.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Combo-sygnał(świetlny){}Sygnał combo skupia działanie zarówno pre- jak i exit-sygnałów. Pozwala to na budowę zaawansowanych układów sygnałów.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Zamiana sygnałów{}Jeżeli włączone, kliknięcie na istniejący sygnał spowoduje zamianę jego typu na wybrany obok. CTRL-klik przełącza wygląd semafor/świetlny.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Gęstość sygnałów przy przeciąganiu. CTRL-przeciągnij aby wypełnić trasę sygnałami.
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Zmniejsz gęstość sygnałów przy przeciąganiu
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Zwiększ gęstość sygnałów przy przeciąganiu
+########
--- a/src/lang/portuguese.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/portuguese.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Não é possível limpar esta área....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright original {COPYRIGHT} 1995 Chris Sawyer, Todos os direitos reservados
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versão {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 A equipa do OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 A equipa do OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Tradutor(es) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -594,6 +594,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Informações da empresa
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Abertura / Fecho de indústrias
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Alterações económicas
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Mudanças na produção das industrias servidas pelo jogador
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Mudanças na produção das industrias servidas pelo(s) oponentes
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Mudanças na produção de outras industrias
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Avisos / informações dos veículos do jogador
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Novos veículos
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Alterações de aceitação de carga
@@ -860,6 +863,7 @@
 
 STR_0314_FUND_NEW_INDUSTRY                                      :{WHITE}Financiar nova indústria
 STR_JUST_STRING                                                 :{STRING}
+STR_JUST_INT                                                    :{NUM}
 STR_0316_CAN_ONLY_BE_BUILT_IN_TOWNS                             :{WHITE}...só se pode construir em cidades
 STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST                        :{WHITE}...só se pode construir em zonas de floresta
 STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT                            :{WHITE}...só se pode construir em zonas de deserto
@@ -1020,6 +1024,7 @@
 STR_CONFIG_PATCHES_ON                                           :Ligado
 STR_CONFIG_PATCHES_VEHICLESPEED                                 :{LTBLUE}Mostrar velocidade do veículo na barra de estado: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BUILDONSLOPES                                :{LTBLUE}Permitir a construção em declives e encostas: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_AUTOSLOPE                                    :{LTBLUE}Permitir formação de terra em construções, linhas, etc. (auto-declive): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_CATCHMENT                                    :{LTBLUE}Dimensionamento mais realista de áreas de abrangência: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_EXTRADYNAMITE                                :{LTBLUE}Permitir remoção de mais estradas, pontes, etc: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_MAMMOTHTRAINS                                :{LTBLUE}Permitir a construção de comboios muito longos: {ORANGE}{STRING}
@@ -1046,6 +1051,8 @@
 STR_CONFIG_PATCHES_ROADVEH_QUEUE                                :{LTBLUE}Fila de veículos de estrada (com efeitos de quantidade): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Deslocar janela quando o rato está na borda do mapa: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Permitir o suborno da autoridade local: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Permitir comprar exclusivo dos direitos de transportes: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Permitir enviar dinheiro para outras empresas: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Estações não uniformes: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nova procura de caminho global (NPF, substitui NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Multiplicador de peso para simular comboios pesados: {ORANGE}{STRING}
@@ -1104,6 +1111,7 @@
 STR_CONFIG_PATCHES_SCROLLWHEEL_OFF                              :Desligado
 STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER                       :{LTBLUE}Velocidade do scrollwheel no mapa: {ORANGE}{STRING}
 
+STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU                          :{LTBLUE}Emulação de clique de botão direito: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_COMMAND                  :Clique para comando
 STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_CONTROL                  :Clique para controlo
 STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF                      :Desligado
@@ -1112,7 +1120,11 @@
 STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS                       :{LTBLUE}Usar a lista avançada de veículos: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF                   :Desligado
 STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OWN                   :Sua companhia
+STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_ALL                   :Todas as empresas
 STR_CONFIG_PATCHES_LOADING_INDICATORS                           :{LTBLUE}Usar indicadores de carga: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_LOADING_INDICATORS_OFF                       :Desligado
+STR_CONFIG_PATCHES_LOADING_INDICATORS_OWN                       :Própria empresa
+STR_CONFIG_PATCHES_LOADING_INDICATORS_ALL                       :Todas as empresas
 STR_CONFIG_PATCHES_TIMETABLE_ALLOW                              :{LTBLUE}Activar plano de horários para veículos: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS                           :{LTBLUE}Mostrar horário em tics em vez dias: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}Tipo padrão de ferrovia (ao criar ou carregar jogo): {ORANGE}{STRING}
@@ -1157,6 +1169,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Permite comprar acções de outras companhias
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Ao arrastar colocar sinais a cada: {ORANGE}{STRING} quadrado(s)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Construir automaticamente semáforos antes de: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Activar ferramenta de sinais: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}A disposição de cidade "sem mais estradas" não é válida no editor de cenários
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Seleccionar disposição das estradas na cidade: {ORANGE}{STRING}
@@ -1181,6 +1194,7 @@
 STR_CONFIG_PATCHES_LARGER_TOWNS                                 :{LTBLUE}Proporção de cidades que se tornarão metrópoles: {ORANGE}1 em {STRING}
 STR_CONFIG_PATCHES_LARGER_TOWNS_DISABLED                        :{LTBLUE}Proporção de cidades que se tornarão metrópoles: {ORANGE}Nenhuma
 STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER                         :{LTBLUE}Multiplicador inicial para dimensão da cidade: {ORANGE}{STRING}
+STR_CONFIG_MODIFIED_ROAD_REBUILD                                :{LTBLUE}Remover partes absurdas durante a construção de estradas
 
 STR_CONFIG_PATCHES_GUI                                          :{BLACK}Interface
 STR_CONFIG_PATCHES_CONSTRUCTION                                 :{BLACK}Construção
@@ -1315,11 +1329,11 @@
 
 STR_INDUSTRY_TOO_CLOSE                                          :{WHITE}...muito perto de outra indústria
 
-STR_RAIL_REFIT_VEHICLE_TO_CARRY                                 :{BLACK}Adaptar comboio para um tipo de carga diferente
-STR_RAIL_REFIT_VEHICLE                                          :{BLACK}Adaptar comboio
+STR_RAIL_REFIT_VEHICLE_TO_CARRY                                 :{BLACK}Converter comboio para um tipo de carga diferente
+STR_RAIL_REFIT_VEHICLE                                          :{BLACK}Converter comboio
 STR_RAIL_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Seleccionar tipo de carga do comboio
-STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED                             :{BLACK}Adaptar comboio para transportar a carga seleccionada
-STR_RAIL_CAN_T_REFIT_VEHICLE                                    :{WHITE}Não é possível ajustar comboio...
+STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED                             :{BLACK}Converter comboio para transportar a carga seleccionada
+STR_RAIL_CAN_T_REFIT_VEHICLE                                    :{WHITE}Não é possível converter comboio...
 STR_CONFIG_PATCHES_SERVINT_ISPERCENT                            :{LTBLUE}Os intervalos de serviço são em percentagem: {ORANGE}{STRING}
 STR_CONFIG_GAME_PRODUCTION                                      :{WHITE}Modificar produção
 
@@ -1380,18 +1394,23 @@
 STR_NETWORK_PASSWORD_TIP                                        :{BLACK}Proteja o jogo com uma senha se não desejar que pessoas indesejadas se juntem
 STR_NETWORK_SELECT_MAP                                          :{BLACK}Seleccione um mapa:
 STR_NETWORK_SELECT_MAP_TIP                                      :{BLACK}Em que mapa deseja jogar?
+STR_NETWORK_LAN_INTERNET_COMBO                                  :{BLACK}{SKIP}{STRING}
 STR_NETWORK_LAN                                                 :Rede Local
 STR_NETWORK_INTERNET                                            :Internet
 STR_NETWORK_LAN_INTERNET                                        :Rede Local / Internet
 STR_NETWORK_INTERNET_ADVERTISE                                  :Internet (divulgar)
+STR_NETWORK_CLIENTS_SELECT                                      :{BLACK}{SKIP}{SKIP}{NUM} cliente{P "" s}
 STR_NETWORK_NUMBER_OF_CLIENTS                                   :{BLACK}Máximo de clientes:
 STR_NETWORK_NUMBER_OF_CLIENTS_TIP                               :{BLACK}Escolha o número máximo de clientes. Não necessitam estar todos presentes.
+STR_NETWORK_COMPANIES_SELECT                                    :{BLACK}{SKIP}{SKIP}{SKIP}{NUM} empresa{P "" s}
 STR_NETWORK_NUMBER_OF_COMPANIES                                 :{BLACK}Máximo de Companhias:
 STR_NETWORK_NUMBER_OF_COMPANIES_TIP                             :{BLACK}Limitar o servidor a um certo número de Companhias
+STR_NETWORK_SPECTATORS_SELECT                                   :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{NUM} espectador{P "" es}
 STR_NETWORK_NUMBER_OF_SPECTATORS                                :{BLACK}Máximo de espectadores:
 STR_NETWORK_NUMBER_OF_SPECTATORS_TIP                            :{BLACK}Limitar o servidor a um certo número de espectadores
 STR_NETWORK_LANGUAGE_SPOKEN                                     :{BLACK}Idioma falado:
 STR_NETWORK_LANGUAGE_TIP                                        :{BLACK}Outros jogadores ficarão a conhecer o idioma utilizado no servidor.
+STR_NETWORK_LANGUAGE_COMBO                                      :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
 STR_NETWORK_START_GAME                                          :{BLACK}Iniciar Jogo
 STR_NETWORK_START_GAME_TIP                                      :{BLACK}Iniciar um novo jogo em rede de um mapa aleatório, ou cenário
 STR_NETWORK_LOAD_GAME                                           :{BLACK}Abrir Jogo
@@ -1652,7 +1671,9 @@
 STR_180A_ROAD_CONSTRUCTION                                      :Construir estradas
 STR_180A_TRAMWAY_CONSTRUCTION                                   :Construção de carris para eléctricos
 STR_180B_BUILD_ROAD_SECTION                                     :{BLACK}Construir estradas
+STR_BUILD_AUTOROAD_TIP                                          :{BLACK}Construir estradas usando o modo automático
 STR_180B_BUILD_TRAMWAY_SECTION                                  :{BLACK}Construir secção de carris para eléctricos
+STR_BUILD_AUTOTRAM_TIP                                          :{BLACK}Construir carris para eléctricos usando o modo automático
 STR_180C_BUILD_ROAD_VEHICLE_DEPOT                               :{BLACK}Construir depósito (para criação e manutenção de veículos de estrada)
 STR_180C_BUILD_TRAM_VEHICLE_DEPOT                               :{BLACK}Construir depósito de eléctricos (para construção e manutenção)
 STR_180D_BUILD_BUS_STATION                                      :{BLACK}Construir estação de autocarros
@@ -1663,6 +1684,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Construir ponte para eléctricos
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Construir túnel de estrada
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Construir túnel para eléctricos
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Activar/Desactivar estradas de sentido único
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Alternar entre construir/remover estradas
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Alternar construir/remover linhas de eléctricos e sinais
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Seleccionar a orientação do depósito
@@ -1684,6 +1706,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}O edifício deve ser demolido primeiro
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}População: {ORANGE}{COMMA}{BLACK}  Casas: {ORANGE}{COMMA}
@@ -2006,6 +2029,8 @@
 STR_5006_MUST_DEMOLISH_TUNNEL_FIRST                             :{WHITE}Deverá demolir o túnel primeiro
 STR_5007_MUST_DEMOLISH_BRIDGE_FIRST                             :{WHITE}Deverá demolir a ponte primeiro
 STR_5008_CANNOT_START_AND_END_ON                                :{WHITE}Não é posível iniciar e finalizar no mesmo ponto
+STR_BRIDGEHEADS_NOT_SAME_HEIGHT                                 :{WHITE}Extremos da ponte não estão ao mesmo nível
+STR_BRIDGE_TOO_LOW_FOR_TERRAIN                                  :{WHITE}Ponte muito baixa para o terreno
 STR_500A_START_AND_END_MUST_BE_IN                               :{WHITE}Inicio e fim devem estar alinhados
 STR_500B_SITE_UNSUITABLE_FOR_TUNNEL                             :{WHITE}O sítio não é adequado para a entrada do túnel
 STR_500D                                                        :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY}
@@ -2285,7 +2310,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Mover sede
 STR_COMPANY_PASSWORD                                            :{BLACK}Palavra passe
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Usar palavra passe na empresa para prevenir utilizadores não autorizados.
-STR_SET_COMPANY_PASSWORD                                        :Definir palavra passe da empresa
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Definir palavra passe da empresa
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Não gravar a password introduzida
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Atribuir nova password à empresa
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Password da empresa
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Password pre-definida da empresa
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Usar a password desta empresa como pre-definida para novas empresas
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Retrocesso Mundial!{}{}Especialistas financeiros temem crise económica!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Fim do retrocesso!{}{}Melhoras no comércio inspiram confiança nas indústrias à medida que a economia se fortalece!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Alternar entre janela grande/pequena
@@ -2765,6 +2795,8 @@
 STR_NEW_VEHICLE_TYPE                                            :{BLACK}{BIGFONT}{ENGINE}
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Novo {STRING} agora disponível! - {ENGINE}
 
+STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Não é possível vender um veículo destruido...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Não é possível converter um veículo destruido...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Impossível programar veículo...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Veículos apenas podem esperar em estações.
@@ -2982,10 +3014,10 @@
 STR_A03C_REFIT                                                  :{WHITE}{VEHICLE} (Adaptar)
 STR_A03D_REFIT_AIRCRAFT                                         :{BLACK}Adaptar aeronave
 STR_A03E_SELECT_TYPE_OF_CARGO_FOR                               :{BLACK}Seleccionar tipo de carga da aeronave
-STR_A03F_REFIT_AIRCRAFT_TO_CARRY                                :{BLACK}Adaptar aeronave para transportar a carga seleccionada
+STR_A03F_REFIT_AIRCRAFT_TO_CARRY                                :{BLACK}Converter aeronave para transportar a carga seleccionada
 STR_A040_SELECT_CARGO_TYPE_TO_CARRY                             :{GOLD}Seleccionar tipo de carga:
-STR_A041_NEW_CAPACITY_COST_OF_REFIT                             :{BLACK}Nova capacidade: {GOLD}{STRING}{}{BLACK}Custo da adaptação: {GOLD}{CURRENCY}
-STR_A042_CAN_T_REFIT_AIRCRAFT                                   :{WHITE}Não é possível adaptar aeronave...
+STR_A041_NEW_CAPACITY_COST_OF_REFIT                             :{BLACK}Nova capacidade: {GOLD}{STRING}{}{BLACK}Custo da conversão: {GOLD}{CURRENCY}
+STR_A042_CAN_T_REFIT_AIRCRAFT                                   :{WHITE}Não é possível converter aeronave...
 STR_GO_TO_AIRPORT_HANGAR                                        :Ir para o hangar de {STATION}
 SERVICE_AT_AIRPORT_HANGAR                                       :Manutenção no hangar de {STATION}
 
@@ -3054,7 +3086,9 @@
 STR_NEWGRF_ERROR_INVALID_PARAMETER                              :Parâmetro inválido para {STRING}: parâmetro {STRING} ({NUM})
 STR_NEWGRF_ERROR_LOAD_BEFORE                                    :{STRING} deve ser carregado antes de {STRING}.
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} deve ser carregado antes de {STRING}.
+STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} necessita da versão {STRING} ou superior do OpenTTD.
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :O ficheiro GRF foi desenhado para traduzir
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Demasiados NewGRFs carregados.
 
 STR_NEWGRF_ADD                                                  :{BLACK}Adicionar
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Adicionar um ficheiro NewGRF à lista
@@ -3083,6 +3117,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}GRF(s) compatíveis carregados para ficheiros ausentes
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Ficheiro(s) GRF ausentes foram desactivados
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Falta(m) ficheiro(s) GRF para carregar jogo
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Ficheiro(s) GRF em falta
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Sair da pausa pode causar problemas ao OpenTTD. Não envie informações sobre este tipo de problemas.{}Deseja realmente sair da pausa?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Moeda Modificada
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Taxa de troca: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3263,6 +3299,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Centrar o mapa na posição actual
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Pequeno
@@ -3371,4 +3408,66 @@
 STR_INDUSTRY_SELECTION_HINT                                     :{BLACK}Escolha a indústria apropriada desta lista
 
 ############ Face formatting
+STR_FACE_ADVANCED                                               :{BLACK}Avançado
+STR_FACE_ADVANCED_TIP                                           :{BLACK}Selecção avançadade de cara
+STR_FACE_SIMPLE                                                 :{BLACK}Simples
+STR_FACE_SIMPLE_TIP                                             :{BLACK}Selecção simples de cara
+STR_FACE_LOAD                                                   :{BLACK}Carregar
+STR_FACE_LOAD_TIP                                               :{BLACK}Carregar cara preferida
+STR_FACE_LOAD_DONE                                              :{WHITE}A sua cara preferida foi carregada a partir do ficheiro de configuração do OpenTTD.
+STR_FACE_FACECODE                                               :{BLACK}Nº de cara
+STR_FACE_FACECODE_TIP                                           :{BLACK}Ver e/ou definir número de cara do jogador
+STR_FACE_FACECODE_CAPTION                                       :{WHITE}Ver e/ou definir número de cara do jogador
+STR_FACE_FACECODE_SET                                           :{WHITE}Novo número de código de cara foi definido
+STR_FACE_FACECODE_ERR                                           :{WHITE}Não foi possível definir o número de cara do jogador - deverá ser numérico entre 0 e 4,294,967,295!
+STR_FACE_SAVE                                                   :{BLACK}Gravar
+STR_FACE_SAVE_TIP                                               :{BLACK}Gravar cara preferida
+STR_FACE_SAVE_DONE                                              :{WHITE}Esta cara será gravada como a sua preferida no ficheiro de configuração do OpenTTD.
+STR_FACE_EUROPEAN                                               :{BLACK}Europeu
+STR_FACE_SELECT_EUROPEAN                                        :{BLACK}Seleccionar caras europeias
+STR_FACE_AFRICAN                                                :{BLACK}Africano
+STR_FACE_SELECT_AFRICAN                                         :{BLACK}Seleccionar caras africanas
+STR_FACE_YES                                                    :Sim
+STR_FACE_NO                                                     :Não
+STR_FACE_MOUSTACHE_EARRING_TIP                                  :{BLACK}Activar bigode ou brinco
+STR_FACE_HAIR                                                   :Cabelo:
+STR_FACE_HAIR_TIP                                               :{BLACK}Mudar cabelo
+STR_FACE_EYEBROWS                                               :Sobrancelhas:
+STR_FACE_EYEBROWS_TIP                                           :{BLACK}Mudar sobrancelhas
+STR_FACE_EYECOLOUR                                              :Cor dos olhos:
+STR_FACE_EYECOLOUR_TIP                                          :{BLACK}Mudar cor dos olhos
+STR_FACE_GLASSES                                                :Óculos:
+STR_FACE_GLASSES_TIP                                            :{BLACK}Activar óculos
+STR_FACE_GLASSES_TIP_2                                          :{BLACK}Mudar óculos
+STR_FACE_NOSE                                                   :Nariz:
+STR_FACE_NOSE_TIP                                               :{BLACK}Mudar nariz
+STR_FACE_LIPS                                                   :Lábios:
+STR_FACE_MOUSTACHE                                              :Bigode:
+STR_FACE_LIPS_MOUSTACHE_TIP                                     :{BLACK}Mudar lábios ou bigode
+STR_FACE_CHIN                                                   :Queixo:
+STR_FACE_CHIN_TIP                                               :{BLACK}Mudar queixo
+STR_FACE_JACKET                                                 :Casaco:
+STR_FACE_JACKET_TIP                                             :{BLACK}Mudar casaco
+STR_FACE_COLLAR                                                 :Colarinho:
+STR_FACE_COLLAR_TIP                                             :{BLACK}Mudar colarinho
+STR_FACE_TIE                                                    :Gravata:
+STR_FACE_EARRING                                                :Brinco:
+STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Mudar gravata ou brinco
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Selecção de Sinal
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Não é possível converter sinais aqui...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Sinal Normal (semáforo){}Os sinais são necessarios para evitar que os comboios choquem nas linhas ferroviárias com mais de um comboio.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Sinal de Entrada (semáforo){}Verde enquanto existir um ou mais sinais de saída verdes no seguimento da linha. De outro modo ficará vermelho.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Sinal de Saída (semáforo){}Funciona da mesma forma que o sinal normal mas é necessário para conseguir a cor correcta nos pre-sinais de entrada e combinado.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Sinal Combinado (semáforo){}O sinal combinado funciona como um sinal de entrada e de saída. Este permite construir grandes "árvores" de pre-sinais.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Sinal Normal(eléctrico){}Os sinais são necessarios para evitar que os comboios choquem nas linhas ferroviárias com mais de um comboio.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Sinal de Entrada (eléctrico){}Verde enquanto existir um ou mais sinais de saída verdes no seguimento da linha. De outro modo ficará vermelho.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Sinal de Saída (eléctrico){}Funciona da mesma forma que o sinal normal mas é necessário para conseguir a cor correcta nos pre-sinais de entrada e combinado.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Sinal Combinado (eléctrico){}O sinal combinado funciona como um sinal de entrada e de saída. Este permite construir grandes "árvores" de pre-sinais.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Converter Sinal{}Quando seleccionado, ao fazer clique em um sinal existente este será convertido no tipo e variante de sinal seleccionado, CTRL-clique irá comutar a variante existente.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Densidade de sinais
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Diminuir densidade de sinais
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Aumentar densidade de sinais
+########
--- a/src/lang/romanian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/romanian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Nu pot curăţa terenul....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright original {COPYRIGHT} 1995 Chris Sawyer, toate drepturile rezervate
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versiunea {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 Echipa OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 Echipa OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Translator(i) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -594,6 +594,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Informatii despre companie
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Deschidere / inchidere industrii
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Schimbãri economice
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Schimbări de producţie la industrii partenere cu jucătorul
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Schimbări de producţie la industrii partenere cu concurenţa
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Alte schimbari in productia industriala
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Sfaturi/informatii despre vehiculele tale
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Vehicule noi
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Schimbãri ale acceptãrii mãrfurilor
@@ -938,6 +941,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Ecran intreg
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Bifeaza aceasta casuta pentru a juca in modul
+STR_FULLSCREEN_FAILED                                           :{WHITE}Comutarea in ecran-complet a esuat
 
 STR_OPTIONS_RES                                                 :{BLACK}Rezolutia ecranului
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1166,6 +1170,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Permite cumpararea de actiuni de la alte companii
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Plasare automată a semafoarelor la fiecare: {ORANGE}{STRING} pătrăţele
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Construieste automat semafaore înainte de: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Activare GUI pentru semnale: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Apectul de oras "fara alte drumuri" nu este valid in editorul de scenarii
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Alege aspect drum-de-oras: {ORANGE}{STRING}
@@ -1680,6 +1685,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Construieşte pod pentru tramvaie
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Construieşte tunel rutier
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Construieşte tunel pentru tramvaie
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Activare/Dezactivare sensuri unice
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Comutator pentru construcţie/înlăturare şosele
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Comuta constructie/stergere pentru constructia de linii de tramvaie
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Alege orientarea autobazei
@@ -1701,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Mai întâi trebuie demolată clădirea
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Populaţia: {ORANGE}{COMMA}{BLACK}  Locuinţe: {ORANGE}{COMMA}
@@ -2304,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Muta sediu
 STR_COMPANY_PASSWORD                                            :{BLACK}Parola
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Protejeaza-ti compania cu o parola pentru a preveni accesul neautorizat.
-STR_SET_COMPANY_PASSWORD                                        :Alege parola companiei
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Alege parola companiei
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Parola introdusă nu se va salva
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Schimbarea parolei pentru companie
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Parola pentru companie
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Parola implicită pentru companie
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Foloseste implicit parola acestei comanii pentru cele nou create
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Recesiune mondială!{}{}Experţii financiari se tem de ceea ce e mai rău odată cu prăbuşirea economică!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Recesiunea s-a încheiat!{}{}Creşterea comerţului dă încredere industriei, iar economia se redresează!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Comutator pentru mărimea ferestrei
@@ -2785,6 +2797,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Un nou {STRING} este acum disponibil!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Vehiculul distrus nu poate fi vandut...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Nu putem repara vehiculele distruse...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Nu pot programa vehiculul...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Vehiculele pot astepta numai in statii.
@@ -3076,6 +3089,7 @@
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} trebuie sa fie incarcat dupa {STRING}.
 STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} necesita OpenTTD versiunea {STRING} sau mai noua.
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :fisierul GRF conceput pentru traducere
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Prea multe NewGRF-uri încărcate.
 
 STR_NEWGRF_ADD                                                  :{BLACK}Adauga
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Adauga un fisier NewGRF in lista
@@ -3104,6 +3118,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Fisier(e) GRF compatibil(e) incarcate pentru fisierele lipsa
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Fisierele GRF lipsa au fost dezactivate
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Fisierele GRF lipsa pentru permiterea incarcarii jocului
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Fisier(e) GRF lipsa
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Reluarea jocului poate bloca OpenTTD. Nu raportati raporturi cu probleme pentru blocari succesive.{}Sigur doresti sa reiei jocul?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Monedă proprie
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Curs de schimb: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3160,7 +3176,7 @@
 
 STR_REPLACE_VEHICLES_WHITE                                      :{WHITE}Înlocuieste {STRING}
 STR_REPLACE_VEHICLES_START                                      :{BLACK}Incepere inlocuire vehicule
-STR_REPLACE_VEHICLES_STOP                                       :{BLACK}Oprire inlocuire vehicuke
+STR_REPLACE_VEHICLES_STOP                                       :{BLACK}Oprire inlocuire vehicule
 STR_NOT_REPLACING                                               :{BLACK}Neinlocuire
 STR_NOT_REPLACING_VEHICLE_SELECTED                              :{BLACK}Nici un vehicul selectat
 STR_REPLACE_HELP_LEFT_ARRAY                                     :{BLACK}Alege tipul de motor pentru inlocuire
@@ -3173,7 +3189,7 @@
 STR_REPLACE_REMOVE_WAGON                                        :{BLACK}Retragere vagoane: {ORANGE}{SKIP}{STRING}
 STR_REPLACE_REMOVE_WAGON_HELP                                   :{BLACK}Fã optiunea de autoînlocuire sã pãstreze identicã lungimea unui tren prin eliminarea vagoanelor (începând din fatã), dacã înlocuirea motorului ar face trenul mai lung.
 STR_REPLACE_ENGINE_WAGON_SELECT                                 :{BLACK}Înlocuire: {ORANGE}{SKIP}{SKIP}{STRING}
-STR_REPLACE_ENGINE_WAGON_SELECT_HELP                            :{BLACK} ELEMENT EXPERIMENTAL {}Comutã între ferestrele de ]nlocuire motoare si vagoane.{}Înlocuirea de vagoane va fi efectuatã numai dacã noul vagon poate transporta acelasi tip de încãrcãturã ca cel vechi. Aceast lucru este verificat pentru fiecare vagon atunci când este fãcutã înlocuirea efectivã.
+STR_REPLACE_ENGINE_WAGON_SELECT_HELP                            :{BLACK} ELEMENT EXPERIMENTAL {}Comutã între ferestrele de înlocuire motoare si vagoane.{}Înlocuirea de vagoane va fi efectuatã numai dacã noul vagon poate transporta acelasi tip de încãrcãturã ca cel vechi. Aceast lucru este verificat pentru fiecare vagon atunci când este fãcutã înlocuirea efectivã.
 STR_RAIL_VEHICLE_NOT_AVAILABLE                                  :{WHITE}Vehiculul nu este disponibil
 STR_ROAD_VEHICLE_NOT_AVAILABLE                                  :{WHITE}Vehiculul nu este disponibil
 STR_SHIP_NOT_AVAILABLE                                          :{WHITE}Vasul nu este disponibil
@@ -3284,6 +3300,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Centreaza harta mica la pozitia actuala
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Mic
@@ -3430,11 +3447,28 @@
 STR_FACE_LIPS_MOUSTACHE_TIP                                     :{BLACK}Schimba buzele sau mustata
 STR_FACE_CHIN                                                   :Barbie:
 STR_FACE_CHIN_TIP                                               :{BLACK}Schimba barbia
-STR_FACE_JACKET                                                 :Jacheta
-STR_FACE_JACKET_TIP                                             :{BLACK}Schimba jacheta
+STR_FACE_JACKET                                                 :Haină:
+STR_FACE_JACKET_TIP                                             :{BLACK}Schimbă haina
 STR_FACE_COLLAR                                                 :Guler:
-STR_FACE_COLLAR_TIP                                             :{BLACK}Schimba gulerul
+STR_FACE_COLLAR_TIP                                             :{BLACK}Schimbă gulerul
 STR_FACE_TIE                                                    :Cravata:
 STR_FACE_EARRING                                                :Cercei:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Schimba cravata sau cerceii
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Alegere Semnal
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Nu se pot transforma semnalele...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Semnal standard (semafor){}Semnalele sunt necesare pentru prevenirea deraierii trenurilor pe retele de cai ferate cu mai mult decat un tren.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Semnal de intrare (semafor){}Verde, atat timp cat exista unul sau mai multe semnale verzi de iesire din sectiunea urmatoare a caii ferate. Altfel indica rosu.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Semnal de iesire (semafor){}Se comporta in acelasi fel ca semnalul normal but este necesar pentru declansarea culorii corecte la intrari si presemnalizatoare combinate.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Semnal combinat (semafor){}Semnalul combinat se comporta atat ca semnal de intrare si iesire. Acest lucru permite constructiile "arborilor" mari de presemnalizare.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Semnal standard (electric){}Semnalele sunt necesare pentru prevenirea deraierii trenurilor pe retele de cai ferate cu mai mult decat un tren.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Semnal de intrare (electric){}Verde atat timp cat exista unul sau mai multe semnale de iesire in sectiunea urmatoare a caii ferate. Altfel indica rosu.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Semnal de iesire (electric){}Se comporta in acelasi fel ca semnalul normal, dar este necesar pentru declansarea culorii corecte la intrari si presemnalizatoare combinate.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Semnal combinat (electric){}Semnalul combinat se comporta atat ca semnalul de intrare si iesire. Acest lucru permite construirea "arborilor" mari de presemnalizare.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Conversie semnal{}Cand este selectat, click-ul pe un semafor existent il va converti in tipul si varianta aleasa de semnalizare, iar CTRL-click va comuta varianta existenta.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Densitate semnal tractare
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Scade densitatea semnalului de tractare
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Mareste densitatea semnalului de tractare
+########
--- a/src/lang/russian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/russian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -162,7 +162,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Невозможно расчистить...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Оригинальные авторские права {COPYRIGHT} 1995 Chris Sawyer, Все права защищены
 STR_00B7_VERSION                                                :{BLACK}OpenTTD v{REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 Команда разработчиков OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 Команда разработчиков OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Переводчики - Назаров Дмитрий (aka Smoky555), Олег Попков (aka Oleg)  - http://forums.ttdrussia.net
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -596,6 +596,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Информация о Компании
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Открытие / закрытие промышленности
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Изменения в экономике
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Изменения уровня производства предприятий, обслуживаемых игроком
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Изменения уровня производства предприятий, обслуживаемых соперниками
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Изменения уровня производства предприятий, никем не обслуживаемых
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Сообщения о транспорте игрока
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Новый транспорт
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Изменения в списке принимаемых грузов
@@ -1168,6 +1171,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Разрешить торговлю акциями других компаний
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}При установке светофоров линией, ставить кажд{P 1 ую ые ые}: {ORANGE}{STRING} клет{P 1 ку ки ок}
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Строить семафоры старого стиля: {ORANGE}до {STRING} года
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Включить меню сигналов: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Расположение дорог "не строить дороги" не действительно в редакторе сценариев
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Расположение дорог у городов: {ORANGE}{STRING}
@@ -1682,6 +1686,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Построить трамвайный мост
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Построить туннель (авто)
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Построить трамвайный туннель
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Включить/Отключить односторонние дороги
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Переключение строительства/удаления автомобильной инфраструктуры
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Переключение строительства/удаления трамвайной инфраструктуры
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Выбор ориентации гаража
@@ -1703,6 +1708,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Сначала надо уничтожить здания
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Население: {ORANGE}{COMMA}{BLACK}  Зданий: {ORANGE}{COMMA}
@@ -2317,7 +2323,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Переместить
 STR_COMPANY_PASSWORD                                            :{BLACK}Пароль
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Защитить вашу компанию паролем, чтобы неавторизованные пользователи не могли присоединиться
-STR_SET_COMPANY_PASSWORD                                        :Установить пароль компании
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Установить пароль компании
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Не сохранять пароль
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Задать новый пароль компании
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Пароль компании
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Пароль компании по умолчанию
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Использовать этот пароль компании по умолчанию для всех новых компаний
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Мировой спад{}{}Финансовые эксперты дают ужасные прогнозы в связи с кризисом экономики!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Спад закончился!{}{}Увеличение объемов торговли внушает уверенность владельцам предприятий. Экономика укрепляет свои позиции.
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Большое/маленькое окно
@@ -3089,6 +3100,7 @@
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} должен быть загружен после {STRING}.
 STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} требует OpenTTD версии {STRING} или выше.
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :файл GRF, который им переводится.
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Слишком много загружено новой графики
 
 STR_NEWGRF_ADD                                                  :{BLACK}Добавить
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Добавить файл NewGRF в список
@@ -3117,6 +3129,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Вместо отсутствующих загружены совместимые файлы NewGRF
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Отсутствующие файлы NewGRF были отключены
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Не найдены файлы NewGRF, необходимые для загрузки игры
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Пропущенные GRF файлы
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Снятие с паузы может привести к ошибке OpenTTD.{}Вы хотите запустить игру?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Своя валюта
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Обменный курс: {ORANGE}{CURRENCY} = £{COMMA}
@@ -3297,6 +3311,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Центрировать миникарту по этой позиции
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Малый
@@ -3451,3 +3466,20 @@
 STR_FACE_EARRING                                                :Серьга:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Изменить галстук или серьгу
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Выбор сигналов
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Не могу преобразовать сигнал здесь...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Стандартный светофор (семофор){}Сигналы необходимы для предотвращения аварий поездов на путях.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Входной сигнал (семафор){}Горит зеленым, если хотя бы один из выходных сигналов зеленый на следующей секции путей. Во всех других случаях горит красным.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Выходной светофор (семафор).{} Работает как обычный светофор, но его значение (цвет) необходимы для нормальной работы входящих и комбинированных пресигналов.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Комбо-светофор (семафор){}Комбо-светофор работает как сдвоенный входной и выходной светофор. Это позволяет построить большую разветвленную сеть.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Стандартный светофор (электро){}Сигналы необходимы для предотвращения аварий поездов на путях.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Входной светофор (элетро){}Горит зеленым, если хотя бы один из выходных сигналов зеленый на следующей секции путей. Во всех других случаях горит красным.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Выходной светофор (электро){}Работает как обычный светофор, но его значение (цвет) необходимы для нормальной работы входящих и комбинированных пресигналов.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Комбо-светофор (электро){}Комбо-светофор работает как сдвоенный входной и выходной светофор. Это позволяет построить большую разветвленную сеть.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Изменение типа сигнала{}Когда кнопка нажата, щелкните для преобразования существующего сигнала в сигнал выбранного типа и варианта,  или щелкните с нажатым Ctrl для переборов существующих вариантов.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Плотность расстановки сигналов при протягивании.
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Уменьшить плотность сигналов при протягивании
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Увеличить плотность сигналов при протягивании
+########
--- a/src/lang/simplified_chinese.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/simplified_chinese.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}不能清除这个区域……
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}原始版权由 {COPYRIGHT} 1995 Chris Sawyer 所有,保留一切权力。
 STR_00B7_VERSION                                                :{BLACK}OpenTTD 版本 {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 The OpenTTD team
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 The OpenTTD team
 STR_TRANSLATED_BY                                               :{BLACK}简体中文翻译者:Fishingsnow@yjrg.net
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -2177,7 +2177,7 @@
 STR_RELOCATE_HQ                                                 :{BLACK}重置总部
 STR_COMPANY_PASSWORD                                            :{BLACK}密码
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}设置密码可以防止未经授权的用户随意加入。
-STR_SET_COMPANY_PASSWORD                                        :设置公司密码
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}设置公司密码
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}大萧条!{}{}金融专家预测世界经济将全面倒退!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}大萧条结束!{}{}贸易复苏带动经济全面启动!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}切换窗口大小
--- a/src/lang/slovak.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/slovak.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -224,7 +224,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Oblast nie je možné vycistit ...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Povodný copyright: {COPYRIGHT} 1995 Chris Sawyer, vsetky prava vyhradene
 STR_00B7_VERSION                                                :{BLACK}OpenTTD verzia {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 team OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 team OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK} Preklad - Lukas Lengyel & gpsoft
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -1005,6 +1005,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Celá obrazovka
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Zaskrtnite, ak chcete hrat OpenTTD na celej obrazovke
+STR_FULLSCREEN_FAILED                                           :{WHITE}Zobrazovanie na celú obrazovku zlyhalo
 
 STR_OPTIONS_RES                                                 :{BLACK}Rozlíšenie obrazovky
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1135,7 +1136,7 @@
 STR_CONFIG_PATCHES_AUTORENEW_VEHICLE                            :{LTBLUE}Automaticka obnova dopravnych prostriedkov, ked su stare
 STR_CONFIG_PATCHES_AUTORENEW_MONTHS                             :{LTBLUE}Obnovit vozidlo {ORANGE}{STRING}{LTBLUE} mesiacov pred/po dosiahnuti max. veku
 STR_CONFIG_PATCHES_AUTORENEW_MONEY                              :{LTBLUE}Min. mnozstvo penazi pre aut. obnovovanie vozidiel: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_ERRMSG_DURATION                              :{LTBLUE}Dĺžka zobrazenia chybovej správy: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ERRMSG_DURATION                              :{LTBLUE}Dlžka zobrazenia chybovej správy: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_POPULATION_IN_LABEL                          :{LTBLUE}Zobrazit pocet obyvatelov mesta v jeho nazve: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_INVISIBLE_TREES                              :{LTBLUE}Neviditelne stromy (pri priesvitnych budovach): {ORANGE}{STRING}
 
@@ -1233,6 +1234,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Povolit kupovanie podielov v ostatných spolocnostiach
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Pri stavbe tahaním umiestnit signály na každé: {ORANGE}{STRING}. pole
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Automaticky stavat semafóry namiesto signálov pred rokom: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Zapnút grafické rozhranie stavby signálov: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Struktúra mesta "žiadne cesty naviac" nie je platná v editore scenárov
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Struktúra mestských ciest: {ORANGE}{STRING}
@@ -1769,6 +1771,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Budova sa musi zburat
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Obyvatelstvo: {ORANGE}{COMMA}{BLACK}  Domov: {ORANGE}{COMMA}
@@ -2372,7 +2375,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Premiestnit sidlo
 STR_COMPANY_PASSWORD                                            :{BLACK}Heslo
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Heslo-ochrana vasej spolocnosti proti neautorizovanemu pripojeniu hracov
-STR_SET_COMPANY_PASSWORD                                        :Nastavte heslo spolocnosti
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Nastavte heslo spolocnosti
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Neukladat zadané heslo
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Nastavit spolocnosti nové heslo
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Heslo spolocnosti
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Standardné heslo spolocnosti
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Použit toto heslo ako štandardné heslo spolocnosti
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Svetova kriza!{}{}Financni experti maju obavy z prepadu ekonomiky!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Koniec krizy!{}{}Ocakava sa vzostup predaja a posilnenie ekonomiky!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Prepnut velkost okna
@@ -2853,6 +2861,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Nové {STRING} dostupné!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Nie je možné predat znicené vozidlo ...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Nie je možné prestavat znicené vozidlo ...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Vozidlu nie je možné zadat cestovný poriadok ...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Vozidlá možu cakat len v staniciach.
@@ -3173,6 +3182,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatibilné GRF použité namiesto chýbajúcich súborov
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Chýbajúce GRF súbory boli vypnuté
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Cýbajú GRF súbory potrebné pre nahratie hry
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Chýba(jú) GRF súbor(y)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Odpauzovanie môže spôsobit pád OpenTTD. Nezaznamenávajte nasledujúce chyby.{}Naozaj chcete odpauzovat?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Vlastná mena
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Kurz meny: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3508,3 +3519,20 @@
 STR_FACE_EARRING                                                :Náušnica:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Zmenit kravatu alebo náušnicu
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Výber signálu
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Nie je možné zmenit typ signálov ...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standardný signál (semafór){}Signály sú nevyhnutné pre zabránenie zrážke v železnicnej sieti s viac ako 1 vlakom.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Vstupný signál (semafór){}Zelený ak je na danom úseku trate 1 alebo viac zelených výstupných signálov, inak je cervený.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Výstupný signál (semafór){}Funguje rovnako ako štandardný signál, avšak je nevyhnutný pre urcenie správnej farby na na vstupných a kombinovaných signáloch.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Kombinovaný signál (semafór){}Funguje jednoducho ako vstupný a výstupný signál zároven, co umožnuje budovat "stromové" štruktúry.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standardný signál (elektrický){}Signály sú nevyhnutné pre zabránenie zrážke v železnicnej sieti s viac ako 1 vlakom.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Vstupný signál (elektrický){}Zelený ak je na danom úseku trate 1 alebo viac zelených výstupných signálov, inak je cervený.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Výstupný signál (elektrický){}Funguje rovnako ako štandardný signál, avšak je nevyhnutný pre urcenie správnej farby na na vstupných a kombinovaných signáloch.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Kombinovaný signál (elektrický){}Funguje jednoducho ako vstupný a výstupný signál zároven, co umožnuje budovat "stromové" štruktúry.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Konverzia signálu{}Pri vybraní, kliknutie na existujúci signál ho zmení na vybraný typ a variant, CTRL+klik prepne existujúci variant.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Hustota signálov pri stavbe tahaním
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Znižit hustotu signálov
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Zvýšit hustotu signálov
+########
--- a/src/lang/slovenian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/slovenian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -1211,6 +1211,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Dovoli kupovanje delnic od drugih podjetij
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Med vlečenjem postavi signale vsakih: {ORANGE}{STRING} ploščic
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Samodejno postavi semaforje pred: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Omogoči vmesnik signalov: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Mestna razporeditev "nič več cest" ni veljavna v urejevalniku terena
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Izberi razporeditev mestnih cest: {ORANGE}{STRING}
@@ -1747,6 +1748,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Najprej mora biti stavba porušena
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Prebivalstvo: {ORANGE}{COMMA}{BLACK}  Število stavb: {ORANGE}{COMMA}
@@ -2388,7 +2390,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Preseli sedež
 STR_COMPANY_PASSWORD                                            :{BLACK}Geslo
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Zaščiti svoje podjetje z geslom, da preprečiš priključitev drugih uporabnikov k podjetju.
-STR_SET_COMPANY_PASSWORD                                        :Nastavi geslo podjetja
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Nastavi geslo podjetja
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Ne shrani vnešenega gesla
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Dodeli družbi novo geslo
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Geslo družbe
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Privzeto geslo družbe
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Uporabi geslo te družbe kot privzeto za nove družbe
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Svetovna recesija!{}{}Ekonomisti se bojijo najhujšega ob trenutnem poteku dogodkov!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Konec recesije!{}{}Izboljšanje trgovanja povečuje zaupanje domače industrije, gospodarstvo napreduje!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Preklopi veliko/majhno velikost okna
@@ -2869,6 +2876,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Novo! {STRING} sedaj na razpolago!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Ni mogoča prodaja uničenega vozila...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Nemogoča predelava uničenega vozila...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Nemogoče določiti časa vozilu...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Vozila lahko čakajo le na postajah.
@@ -3189,6 +3197,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatibilni GRF-ji so naloženi namesto manjkajočih datotek
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Manjkajoče GRF datoteke so bile onemogočene
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Manjkajoče datoteke GRF, ki omogočajo nalaganje igre
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Manjkajoče GRF datoteke
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Izklop pavze lahko sesuje OpenTTD. Ne poročaj o napaki zaradi takih problemov.{}Zagotovo želiš izklopiti pavzo?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Valuta po meri
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Menjalni tečaj: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3524,3 +3534,20 @@
 STR_FACE_EARRING                                                :Uhani:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Spremeni kravato ali uhane
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Izbor signalov
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Nemogoča sprememba vrste signalov tukaj...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standardni signal (semafor){}Signali so potrebni, da preprečijo vlaku trčenje na progi z več vlaki.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Vhodni signal (semafor){}Zelen v kolikor je vsaj en ali več  izhodnih signalov v nadaljevanju proge. Če ne, je rdeč.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Izhodni signal (semafor){}Deluje kot normalen semafor, le da mora biti povezan z ustreznim vhodnim ali kombiniranim signalom.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Kombinirani signal (semafor){}Kombinirani signal deluje kot vhodni in izhodni. To omogoča gradnjo velikih vej signalizacije.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Standardni signal (električni){}Signali so potrebni, da preprečijo vlaku trčenje na progi z več vlaki.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Vhodni signal (električni){}Zelen v kolikor je vsaj en ali več  izhodnih signalov v nadaljevanju proge. Če ne, je rdeč.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Izhodni signal (električni){}Deluje kot normalen semafor, le da mora biti povezan z ustreznim vhodnim ali kombiniranim signalom.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Kombinirani signal (električni){}Kombinirani signal deluje kot vhodni in izhodni. To omogoča gradnjo velikih vej signalizacije.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Zamenjava signala{}Ko je možnost izbrana, se ob kliku na obstoječi signal le ta spremeni v izbrano vrsto. CTRL-klik preklaplja obstoječo vrsto.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Gostota vlečnih signalov
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Zmanjšaj gostoto signala za vlečenje
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Povečaj gostoto signala za vlečenjeIncrease dragging signal density
+########
--- a/src/lang/spanish.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/spanish.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -161,7 +161,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}No se puede desbrozar esta zona....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Copyright Original {COPYRIGHT} 1995 Chris Sawyer, Todos los derechos reservados
 STR_00B7_VERSION                                                :{BLACK}OpenTTD versión {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 El equipo OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 El equipo OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK}  Traductor(es) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -1170,6 +1170,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Permitir comprar acciones de otras empresas
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Cuando arrastre colocar señales cada: {ORANGE}{STRING} casilla(s)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Coloca automáticamente semáforos antes de: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Activar la GUI de señales: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}El trazado de ciudad "no más carreteras" no es válido en el editor de escenarios
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Selecciona trazado de carretera en ciudad: {ORANGE}{STRING}
@@ -1706,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}El edificio debe demolerse primero
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Habitantes: {ORANGE}{COMMA}{BLACK}  Casas: {ORANGE}{COMMA}
@@ -2309,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Reubicar Sede
 STR_COMPANY_PASSWORD                                            :{BLACK}Contraseña
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Protege por contraseña tu empresa para prevenir que usuarios no autorizados se unan a ella.
-STR_SET_COMPANY_PASSWORD                                        :Configurar contraseña de empresa
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Configurar contraseña de empresa
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}No grabar la contraseña introducida
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Asignar a la empresa una nueva contraseña
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Contraseña de la empresa
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Contraseña por defecto de la empresa
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Usa la contraseña de esta empresa para el resto de nuevas empresas
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}¡Recesión Mundial!{}{}¡Los expertos financieros son pesimistas mientras la economía se hunde!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}¡Fin de la Recesión!{}{}¡Mejora en el comercio da ánimos a las industrias mientras la economía se fortalece!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Cambiar entre tamaño de ventana grande/pequeño
@@ -2790,6 +2797,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Nuevo {STRING} ahora disponible!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}No se puede vender un vehículo destruido...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}No se puede rellenar un vehículo destruido...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}No se puede ajustar horarios al vehículo...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Los vehículos solo pueden esperar en las estaciones.
@@ -3110,6 +3118,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}GRF(s) compatibles cargos para ficheros que faltan
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Fichero(s) GRF perdidos han sido desactivados
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Fichero(s) GRF para poder cargar el juego
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Fichero(s) GRF que faltan
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Quitar la pausa puede hacer que se cierre OpenTTD. No notifique este error.{}¿Desea realmente quitar la pausa?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Moneda personalizada
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Tasa de cambio: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3445,3 +3455,20 @@
 STR_FACE_EARRING                                                :Pendientes:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Cambiar corbata o pendientes
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Selección de Señales
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}No se pueden convertir las señales aquí...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Señales standard (semaforos){}Las señales son necesarias para evitar los choques de trenes en vías con más de un tren.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Señal de entrada (semáforo){}Verde si existe una o más señales de salida en el tramo en verde, de lo contrario estará en rojo
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Señal de salida (semáforo){}Se comporta de la misma manera que una señal normal, pero es necesario para activar el color correcto a la entrada y antes de la combinación de señales.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Señales combo (semáforos){}Las señales combo simplemente actúan como una señal de entrada y de salida. Esto permite construir grandes "árboles" de preseñales.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Señal normal (eléctrica){}Las señales son necesarias para evitar accidentes de trenes en vías con más de un tren.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Señal de entrada (eléctrica){}Verde si existe una o más señales verdes en el siguiente segmento de vía. Si no, mostrará el rojo.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Señal de salida (eléctrica){}Actua igual que una señal normal solo pero es necesaria para cambiar el color correcto en preseñales de entrada y combo.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Combo señal (eléctrica){}La señal combo actua como señal de entrada y salida. Esto permite construir grandes "árboles" de preseñales.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Convertir señal{}Cuando es seleccionado, pulsando sobre una señal existente la convertiremos a la variante indicada. Pulsa CTRL-click para cambiar de variante.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Arrastrar densidad de señales
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Decrementar arrastre de intensidad de señales
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Incrementar arrastre de intensidad de señales
+########
--- a/src/lang/swedish.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/swedish.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Kan inte röja området...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Ursprunglig äganderätt {COPYRIGHT} 1995 Chris Sawyer, Alla rättigheter reserverade
 STR_00B7_VERSION                                                :{BLACK}OpenTTD version {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD-teamet
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD-teamet
 STR_TRANSLATED_BY                                               :{BLACK}  Översättare -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -941,6 +941,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}Helskärm
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Kryssa i den här rutan för att spela OpenTTD i helskärmsläge
+STR_FULLSCREEN_FAILED                                           :{WHITE}Fullskärmsläge misslyckades
 
 STR_OPTIONS_RES                                                 :{BLACK}Skärmupplösning
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1169,6 +1170,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Tillåt inköp av aktier från andra företag
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Vid utdragning av signaler, placera en signal var: {ORANGE}{STRING} ruta
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Bygg automatiskt semaforer innan: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Använd signal-GUI: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Det går ej att använda "inga fler vägar" i scenario editorn
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Välj stadens väg-inställningar: {ORANGE}{STRING}
@@ -1705,6 +1707,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Byggnad måste rivas först
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Invånare: {ORANGE}{COMMA}{BLACK}  Hus: {ORANGE}{COMMA}
@@ -2308,7 +2311,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Flytta högkvarter
 STR_COMPANY_PASSWORD                                            :{BLACK}Lösenord
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Lösenordsskydda ditt företag för att förhindra att obehöriga spelare ansluter.
-STR_SET_COMPANY_PASSWORD                                        :Ange företagets lösenord
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Ange företagets lösenord
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Spara inte det inmatade lösenordet
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Ge företaget det nya lösenordet
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Företagslösenord
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Förvalt företagslösenord
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Använd detta företagslösenord som förval för nya företag
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Lågkonjuktur!{}{}Finansexperter befarar det värsta när ekonomin sjunker!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Lågkonjuktur Över!{}{}Uppsving i byteshandeln ger tillförsikt till industrier när ekonomin stärks!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Växla stor/liten fönsterstorlek
@@ -2789,6 +2797,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Nya {STRING} är nu tillgänglig  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Kan inte sälja förstört fordon...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Kan inte bygga om ett förstörd fordon...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Kan inte lägga till fordonet i en tidtabell...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Fordon kan enbart vänta vid stationer.
@@ -3109,6 +3118,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Kompatibel GRF laddad för saknade filer
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Saknad GRF fil har stängts av
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Saknas GRF fil för att kunna ladda spel
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Saknad(e) GRF-fil(er)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Avpausning kan krascha OpenTTD. Skicka ej igen bugg-rapport för möjlig krasch.{}Är du säker att du vill avpausa?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Egen valuta
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Växlingskurs: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3444,3 +3455,20 @@
 STR_FACE_EARRING                                                :Örhänge:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Ändra slips eller örhänge
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Signalval
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Kan inte konvertera signaler här...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Standardsignal (semafor){}Signaler är nödvändiga för att tåg inte skall krasha i järnvägsnät innehållande mer än ett tåg.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}För-signal (semafor){}Grön så länge det finns en eller flera gröna utfarts-signaler på efterföljande bit av spår, annars visas rött.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Utfarts-signal (semafor){}Fungerar på samma sätt som en vanlig signal men behövs för att utlösa korrekt färg på In- eller kombinations-signaler.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Kombinationssignal (semafor){}Kombinationssignalen fungerar helt enkelt som både en För- och Utfarts-signal. Denna tillåter dig att bygga stora "träd" av För-signaler.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Normal signal (elektrisk){}Signaler behövs för att se till att tåg inte kraschar på nätverk med mer än ett tåg.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}För-signal (elektrisk){}Grön så länge det finns en eller flera gröna utfarts-signaler på efterföljande bit av spår, annars visas rött.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Utfarts-signal (elektrisk){}Fungerar på samma sätt som en vanlig signal men behövs för att utlösa korrekt färg på In- eller kombinations-signaler.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Kombinationssignal (elektrisk){}Kombinationssignalen fungerar helt enkelt som både en För- och Utfarts-signal. Denna tillåter dig att bygga stora "träd" av För-signaler.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Konvertera Signal{}När markerad, klicka på en existerande signal för att konvertera den till vald signal-typ och variant. CTRL-klick ändrar den existerande varianten
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Dragen signals täthet
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Minska dragen signals täthet
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Öka dragen signals täthet
+########
--- a/src/lang/traditional_chinese.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/traditional_chinese.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}不能清除這個地段....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}原著作權為{COPYRIGHT} 1995 Chris Sawyer, 版權所有
 STR_00B7_VERSION                                                :{BLACK}OpenTTD 版本 {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD 小組
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD 小組
 STR_TRANSLATED_BY                                               :{BLACK}  翻譯 -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -213,7 +213,7 @@
 STR_00F4_500M                                                   :{BLACK}{TINYFONT}500米
 STR_00F5_TRAINS                                                 :{BLACK}{TINYFONT}列車
 STR_00F6_ROAD_VEHICLES                                          :{BLACK}{TINYFONT}公車/貨車
-STR_00F7_SHIPS                                                  :{BLACK}{TINYFONT}輪船
+STR_00F7_SHIPS                                                  :{BLACK}{TINYFONT}船隻
 STR_00F8_AIRCRAFT                                               :{BLACK}{TINYFONT}飛機
 STR_00F9_TRANSPORT_ROUTES                                       :{BLACK}{TINYFONT}運輸路線
 STR_00FA_COAL_MINE                                              :{BLACK}{TINYFONT}煤礦場
@@ -312,7 +312,7 @@
 STR_0150_SOMEONE                                                :某人{SKIP}{SKIP}
 STR_0151_MAP_OF_WORLD                                           :世界地圖
 STR_0152_TOWN_DIRECTORY                                         :市鎮目錄
-STR_0153_SUBSIDIES                                              :補貼
+STR_0153_SUBSIDIES                                              :補助
 
 STR_UNITS_IMPERIAL                                              :英制
 STR_UNITS_METRIC                                                :公制
@@ -441,7 +441,7 @@
 STR_017A_DISPLAY_COMPANY_LEAGUE                                 :{BLACK}顯示公司排行榜
 STR_017B_DISPLAY_LIST_OF_COMPANY                                :{BLACK}顯示公司擁有的列車
 STR_017C_DISPLAY_LIST_OF_COMPANY                                :{BLACK}顯示公司擁有的公車/貨車
-STR_017D_DISPLAY_LIST_OF_COMPANY                                :{BLACK}顯示公司擁有的輪船
+STR_017D_DISPLAY_LIST_OF_COMPANY                                :{BLACK}顯示公司擁有的船隻
 STR_017E_DISPLAY_LIST_OF_COMPANY                                :{BLACK}顯示公司擁有的飛機
 STR_017F_ZOOM_THE_VIEW_IN                                       :{BLACK}拉近視域
 STR_0180_ZOOM_THE_VIEW_OUT                                      :{BLACK}拉遠視域
@@ -481,7 +481,7 @@
 
 STR_019C_ROAD_VEHICLE                                           :車輛
 STR_019D_AIRCRAFT                                               :飛機
-STR_019E_SHIP                                                   :船舶
+STR_019E_SHIP                                                   :船隻
 STR_019F_TRAIN                                                  :列車
 STR_01A0_IS_GETTING_OLD                                         :{WHITE}{STRING} {COMMA}使用年限將近
 STR_01A1_IS_GETTING_VERY_OLD                                    :{WHITE}{STRING} {COMMA}使用年限已過
@@ -1166,6 +1166,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}可以從對手購入股份
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}拖放時訊號燈之間距離:{ORANGE}{STRING} 格
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}於日期前自動建立舊式號誌臂:{ORANGE}{STRING}年
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}啟用號誌介面:{ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}在場景編輯器中,"市鎮道路不再規劃" 是不可行的
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}選擇市鎮道路規劃:{ORANGE}{STRING}
@@ -1680,6 +1681,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}架設電車橋
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}挖掘公路隧道
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}開鐅電車隧道
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}切換單行道/雙向道
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}切換鋪設/移除公路
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}鋪設電車軌開關
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}選擇車庫方向
@@ -1701,6 +1703,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}必須先摧毀建物
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}人口:{ORANGE}{COMMA}{BLACK}  房屋:{ORANGE}{COMMA}
@@ -2304,7 +2307,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}搬移總部
 STR_COMPANY_PASSWORD                                            :{BLACK}密碼
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}以密碼保護您的公司,避免其他玩家隨意接手。
-STR_SET_COMPANY_PASSWORD                                        :設定公司密碼
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}設定公司密碼
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}不要儲存輸入的密碼
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}為公司設定新的密碼
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}公司密碼
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}預設公司密碼
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}使用此密碼當作未來新公司的預設密碼
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}世界不景氣!{}{}財務專家對經濟蕭條做出最壞打算!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}景氣回升!{}{}湧現的訂單讓工業對經濟熱絡充滿信心!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}切換大/小視窗
@@ -3076,6 +3084,7 @@
 STR_NEWGRF_ERROR_LOAD_AFTER                                     :{STRING} 必須在 {STRING} 之後載入。
 STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER                            :{STRING} 需要 {STRING} 或更新的 OpenTTD 版本。
 STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE                          :GRF 檔案翻譯後出現錯誤
+STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :已載入太多的 NewGRF。
 
 STR_NEWGRF_ADD                                                  :{BLACK}新增
 STR_NEWGRF_ADD_TIP                                              :{BLACK}為清單加入新的 NewGRF 檔
@@ -3104,6 +3113,7 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}已為找不到的檔案載入相容 GRF 檔
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}找不到的 GRF 檔已被關閉
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}找不到載入遊戲所需的 GRF 檔案
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}一個或多個 GRF 檔案遺失
 
 STR_CURRENCY_WINDOW                                             :{WHITE}自訂幣值
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}匯率:{ORANGE}{CURRENCY} = £ {COMMA}
@@ -3284,6 +3294,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}將小地圖移到目前地點位置
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}小
@@ -3438,3 +3449,20 @@
 STR_FACE_EARRING                                                :耳飾:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}改變領帶或耳飾
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}號誌選擇
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}無法轉換這裡的號誌...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}標準號誌 (旗號){}當軌道網路中有多餘一列的列車時,為了避免發生相撞意外,號誌是必要的。
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}入口號誌 (旗號){}當綠燈亮時,代表此號誌後有一個以上的出口號誌呈現綠燈,否則將會是紅燈。
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}出口號誌 (旗號){}與一般號誌類似,但它還得負責切換前頭的入口號誌及組合號誌。
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}組合號誌 (旗號){}組合號誌同時具有入口/出口號誌特性。這可讓玩家設置一卡車的預告號誌。
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}標準號誌 (電氣){}當軌道網路中有多餘一列的列車時,為了避免發生相撞意外,號誌是必要的。
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}入口號誌 (電氣){}當綠燈亮時,代表此號誌後有一個以上的出口號誌呈現綠燈,否則將會是紅燈。
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}出口號誌 (電氣){}與一般號誌類似,但它還得負責切換前頭的入口號誌及組合號誌。
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}組合號誌 (電氣){}組合號誌同時具有入口/出口號誌特性。這可讓玩家設置一卡車的預告號誌。
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}號誌轉換{}當選取時,在現有的號誌上點選,將會轉換成面板上所選取的類型及樣式;若按住 CTRL 點選,只會變更樣式。
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}變更等距號誌拖曳間隔
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}減少 (拉近)
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}增加 (拉遠)
+########
--- a/src/lang/turkish.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/turkish.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -160,7 +160,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Burası temizlenemez....
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Orjinal kopyalama hakkı {COPYRIGHT} 1995 Chris Sawyer, Her Hakkı Saklıdır
 STR_00B7_VERSION                                                :{BLACK}OpenTTD sürüm {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD takımı
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 OpenTTD takımı
 STR_TRANSLATED_BY                                               :{BLACK}  Çevirenler -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -1168,6 +1168,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Diğer şirketlerin hisseleri alınabilsin
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}Sürüklerken her: {ORANGE}{STRING} karede bir sinyal koy
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Bu tarihten önce ışık yerine semafor kullan: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Sinyal arayüzünü etkinleştir: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Senaryo düzenleyicisinde "yolsuz" şehir seçeneği kullanılamaz
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Şehir yol yerleşimini seç: {ORANGE}{STRING}
@@ -1704,6 +1705,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Önce bina yıkılmalı
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Nüfus: {ORANGE}{COMMA}{BLACK}  Ev: {ORANGE}{COMMA}
@@ -2307,7 +2309,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Binayı Taşı
 STR_COMPANY_PASSWORD                                            :{BLACK}Parola
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Başkalarınin girmemesi için parola koy.
-STR_SET_COMPANY_PASSWORD                                        :Şirket parolası
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Şirket parolası
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Girilen parolayı kaydetme
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Yeni parolayı şirkete ver
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Şirket parolası
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Öntanımlı şirket parolası
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Bu şirketin parolasını yeni şirketlerde öntanımlı olarak kullan
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Dünyada Kriz!{}{}Çok büyük bir ekonomik kriz yaşanacağı öngörüldü!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Kriz Atlatıldı!{}{}Ekonomi yine eski güzel günlerine döndü!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Pencere boyutunu büyült/küçült
@@ -3107,6 +3114,7 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Eksik dosyalar için uyumlu GRF(ler) yüklendi
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Eksik GRF dosyaları etkisizleştirildi
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Oyunu yüklemek için gerekli olan GRF dosyaları eksik
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Eksik GRF dosyası
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Özel Para Birimi
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Çarpan: {ORANGE}{CURRENCY} = £ {COMMA}
@@ -3285,6 +3293,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Küçük haritayı burada ortala
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Küçük
@@ -3400,19 +3409,47 @@
 STR_FACE_LOAD_TIP                                               :{BLACK}Tercih edilen yüzü yükle
 STR_FACE_LOAD_DONE                                              :{WHITE}Tercih edilen yüz OpenTTD ayar dosyasından yüklendi.
 STR_FACE_FACECODE                                               :{BLACK}Oyuncu yüzü no.
+STR_FACE_FACECODE_SET                                           :{WHITE}Surat numarası ayarlandı.
+STR_FACE_FACECODE_ERR                                           :{WHITE}Oyuncu surat numarası ayarlanamadı - 0 ve 4.294.967.295 arasında bir sayı olmalı!
 STR_FACE_SAVE                                                   :{BLACK}Kaydet
 STR_FACE_SAVE_TIP                                               :{BLACK}Tercih edilen yüzü kaydet
+STR_FACE_SAVE_DONE                                              :{WHITE}Bu surat OpenTTD ayar dosyasına kaydedilecek.
 STR_FACE_EUROPEAN                                               :{BLACK}Avrupalı
+STR_FACE_SELECT_EUROPEAN                                        :{BLACK}Beyaz yüz seç
 STR_FACE_AFRICAN                                                :{BLACK}Afrikalı
+STR_FACE_SELECT_AFRICAN                                         :{BLACK}Siyah yüz seç
 STR_FACE_YES                                                    :Evet
 STR_FACE_NO                                                     :Hayır
+STR_FACE_MOUSTACHE_EARRING_TIP                                  :{BLACK}Bıyık veya küpeyi etkinleştir
 STR_FACE_HAIR                                                   :Saç:
+STR_FACE_HAIR_TIP                                               :{BLACK}Saçı değiştir
 STR_FACE_EYEBROWS                                               :Kaşlar:
+STR_FACE_EYEBROWS_TIP                                           :{BLACK}Kaşları değiştir
 STR_FACE_EYECOLOUR                                              :Göz rengi:
+STR_FACE_EYECOLOUR_TIP                                          :{BLACK}Göz rengini değiştir
 STR_FACE_GLASSES                                                :Gözlük:
+STR_FACE_GLASSES_TIP                                            :{BLACK}Gözlüğü etkinleştir
+STR_FACE_GLASSES_TIP_2                                          :{BLACK}Gözlüğü değiştir
 STR_FACE_NOSE                                                   :Burun:
+STR_FACE_NOSE_TIP                                               :{BLACK}Burnu değiştir
 STR_FACE_LIPS                                                   :Dudak:
 STR_FACE_MOUSTACHE                                              :Bıyık:
+STR_FACE_LIPS_MOUSTACHE_TIP                                     :{BLACK}Dudakları veya bıyığı değiştir
 STR_FACE_CHIN                                                   :Çene:
+STR_FACE_CHIN_TIP                                               :{BLACK}Çeneyi değiştir
 STR_FACE_JACKET                                                 :Ceket:
+STR_FACE_JACKET_TIP                                             :{BLACK}Ceketi değiştir
+STR_FACE_COLLAR                                                 :Yaka:
+STR_FACE_COLLAR_TIP                                             :{BLACK}Yakayı değiştir
+STR_FACE_TIE                                                    :Kravat:
+STR_FACE_EARRING                                                :Küpe:
+STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Kravatı veya küpeyi değiştir
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Sinyal Seçimi
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Buradaki sinyaller dönüştürülemez...
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Sinyal sürükleme yoğunluğu
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Sinyal sürükleme yoğunluğunu azalt
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Sinyal sürükleme yoğunluğunu arttır
+########
--- a/src/lang/ukrainian.txt	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/lang/ukrainian.txt	Wed Jan 09 18:11:12 2008 +0000
@@ -286,7 +286,7 @@
 STR_00B5_CAN_T_CLEAR_THIS_AREA                                  :{WHITE}Неможливо очистити цю ділянку...
 STR_00B6_ORIGINAL_COPYRIGHT                                     :{BLACK}Авторське право {COPYRIGHT} 1995 Кріс Сойєр, Всі права захищені
 STR_00B7_VERSION                                                :{BLACK}OpenTTD версія {REV}
-STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2007 команда OpenTTD
+STR_00BA_COPYRIGHT_OPENTTD                                      :{BLACK}OpenTTD {COPYRIGHT}2002-2008 команда OpenTTD
 STR_TRANSLATED_BY                                               :{BLACK} Перекладач(і) -
 
 STR_00C5                                                        :{BLACK}{CROSS}
@@ -720,6 +720,9 @@
 STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Інформація компанії
 STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Відкриття / закриття підприємств
 STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Зміни в економіці
+STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER                           :{YELLOW}Зміна обсягів виробництва на підприємствах гравця
+STR_INDUSTRY_CHANGES_SERVED_BY_OTHER                            :{YELLOW}Зміна обсягів виробництва на підприємствах суперників
+STR_OTHER_INDUSTRY_PRODUCTION_CHANGES                           :{YELLOW}Інші зміни обсягів виробництва
 STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Поради/інформація про транспорт гравця
 STR_020C_NEW_VEHICLES                                           :{YELLOW}Новий транспорт
 STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Зміни в попиті на перевезення
@@ -1064,6 +1067,7 @@
 
 STR_OPTIONS_FULLSCREEN                                          :{BLACK}В повний екран
 STR_OPTIONS_FULLSCREEN_TIP                                      :{BLACK}Натисніть цю кнопку щоб грати в повний екран
+STR_FULLSCREEN_FAILED                                           :{WHITE}Повноекранний режим не працює
 
 STR_OPTIONS_RES                                                 :{BLACK}Роздільна здатність
 STR_OPTIONS_RES_CBO                                             :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
@@ -1292,6 +1296,7 @@
 STR_CONFIG_PATCHES_ALLOW_SHARES                                 :{LTBLUE}Можна купувати інші компанії
 STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY                         :{LTBLUE}При протаскуванні сигнали ставляться через:{ORANGE}{STRING} клітки(ок)
 STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE                  :{LTBLUE}Автоматично будувати семафори до: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI                            :{LTBLUE}Використовувати графічний інтерфейс для сигналів: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID                          :{WHITE}Схема міста "не треба більше доріг" недійсна у редакторі сценаріїв
 STR_CONFIG_PATCHES_TOWN_LAYOUT                                  :{LTBLUE}Виберіть схему доріг у місті: {ORANGE}{STRING}
@@ -1806,6 +1811,7 @@
 STR_180F_BUILD_TRAMWAY_BRIDGE                                   :{BLACK}Побудувати трамвайний міст
 STR_1810_BUILD_ROAD_TUNNEL                                      :{BLACK}Будувати тунель
 STR_1810_BUILD_TRAMWAY_TUNNEL                                   :{BLACK}Побудувати трамвайний тунель
+STR_TOGGLE_ONE_WAY_ROAD                                         :{BLACK}Вкл./відкл. односторонні дороги
 STR_1811_TOGGLE_BUILD_REMOVE_FOR                                :{BLACK}Будувати/зруйнувати дорогу
 STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS                       :{BLACK}Будувати/демонтувати колію
 STR_1813_SELECT_ROAD_VEHICLE_DEPOT                              :{BLACK}Виберіть направлення депо
@@ -1827,6 +1833,7 @@
 STR_TOWN_LABEL_TINY_BLACK                                       :{TINYFONT}{BLACK}{TOWN}
 STR_TOWN_LABEL_TINY_WHITE                                       :{TINYFONT}{WHITE}{TOWN}
 STR_2002                                                        :{TINYFONT}{BLACK}{SIGN}
+STR_2002_WHITE                                                  :{TINYFONT}{WHITE}{SIGN}
 STR_2004_BUILDING_MUST_BE_DEMOLISHED                            :{WHITE}Спочатку зруйнуйте споруду
 STR_2005                                                        :{WHITE}{TOWN}
 STR_2006_POPULATION                                             :{BLACK}Населення: {ORANGE}{COMMA}{BLACK}  Будинки: {ORANGE}{COMMA}
@@ -2467,7 +2474,12 @@
 STR_RELOCATE_HQ                                                 :{BLACK}Перенести Офіс
 STR_COMPANY_PASSWORD                                            :{BLACK}Пароль
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Пароль захищає вашу компанію від приєднання інших гравців.
-STR_SET_COMPANY_PASSWORD                                        :Встановлення паролю
+STR_SET_COMPANY_PASSWORD                                        :{BLACK}Встановлення паролю
+STR_COMPANY_PASSWORD_CANCEL                                     :{BLACK}Не запам'ятовувати введений пароль
+STR_COMPANY_PASSWORD_OK                                         :{BLACK}Дати компанії новий пароль
+STR_COMPANY_PASSWORD_CAPTION                                    :{WHITE}Пароль компанії
+STR_MAKE_DEFAULT_COMPANY_PASSWORD                               :{BLACK}Пароль компанії за замовчуванням
+STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP                           :{BLACK}Використовувати цей пароль компанії за замовчуванням для нових компаній
 STR_7073_WORLD_RECESSION_FINANCIAL                              :{BIGFONT}{BLACK}Світова економічна криза!{}{}Фінансисти очікують спад виробництва та попиту!
 STR_7074_RECESSION_OVER_UPTURN_IN                               :{BIGFONT}{BLACK}Криза минула!{}{}Збільшення виробництва внаслідок стабілізації економіки надає впевненості підприємствам!
 STR_7075_TOGGLE_LARGE_SMALL_WINDOW                              :{BLACK}Розмір вікна великий/малий
@@ -2948,6 +2960,7 @@
 STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE                         :{BLACK}Став доступним новий {STRING}!  -  {ENGINE}
 
 STR_CAN_T_SELL_DESTROYED_VEHICLE                                :{WHITE}Не можна продати знищений транспорт...
+STR_CAN_T_REFIT_DESTROYED_VEHICLE                               :{WHITE}Не можна переобладнати знищений транспорт...
 
 STR_CAN_T_TIMETABLE_VEHICLE                                     :{WHITE}Не можна встановити розклад для транспорту...
 STR_TIMETABLE_ONLY_WAIT_AT_STATIONS                             :{WHITE}Транспорт може чекати тільки на станціях.
@@ -3268,6 +3281,8 @@
 STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Для відсутніх GRF-файлів завантажені сумісні
 STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Відсутні GRF-файли деактивовані
 STR_NEWGRF_NOT_FOUND_WARNING                                    :{WHITE}Відсутні GRF-файли  для завантаження гри
+STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Відсутній GRF файл(и)
+STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Зняття з паузи може привести до аварійної відмови OpenTTD. Не рапортуйте про наступні відмови.{}Ви дійсно хочете зняти з паузи?
 
 STR_CURRENCY_WINDOW                                             :{WHITE}Вибір грошової одиниці
 STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Валютний курс: {ORANGE}{CURRENCY} = Ј {COMMA}
@@ -3448,6 +3463,7 @@
 STR_FLAT_WORLD_HEIGHT_NUM                                       :{NUM}
 
 STR_SMALLMAP_CENTER                                             :{BLACK}Центрувати мінікарту сюди
+STR_SMALLMAP_INDUSTRY                                           :{TINYFONT}{STRING} ({NUM})
 
 ########### String for new airports
 STR_SMALL_AIRPORT                                               :{BLACK}Малий
@@ -3602,3 +3618,20 @@
 STR_FACE_EARRING                                                :Сережки:
 STR_FACE_TIE_EARRING_TIP                                        :{BLACK}Змінити комір або сережки
 ########
+
+############ signal GUI
+STR_SIGNAL_SELECTION                                            :{WHITE}Вибір сигналів
+STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                           :{WHITE}Не можна сконвертувати сигнали тут...
+STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP                             :{BLACK}Звичайний сигнал (семафор){}Сигнали необхідні для того, щоб уникнути зіткнень поїздів на залізницях, де більше одного поїзда.
+STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP                            :{BLACK}Вхідний сигнал (семафор){}Зелений, доки є один або більше зелених вихідних сигналів з наступної секції колії. Якщо нема - червоний.
+STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP                             :{BLACK}Вихідний сигнал (семафор){}Поводиться, як звичайний сигнал, але необхідний для нормальної роботи вхідного або комбінованого сигналів.
+STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP                            :{BLACK}Комбінований сигнал (семафор){}Комбінований сигнал працює як пара вхідний-вихідний сигнал. Це дозволяє будувати великі "дерева" сигналів.
+STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP                              :{BLACK}Звичайний сигнал (електричний){}Сигнали необхідні для того, щоб уникнути зіткнень поїздів на залізницях, де більше одного поїзда.
+STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP                             :{BLACK}Вхідний сигнал (електричний){}Зелений, доки є один або більше зелених вихідних сигналів з наступної секції колії. Якщо нема - червоний.
+STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP                              :{BLACK}Вихідний сигнал (електричний){}Поводиться, як звичайний сигнал, але необхідний для нормальної роботи вхідного або комбінованого сигналів.
+STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP                             :{BLACK}Комбінований сигнал (електричний){}Комбінований сигнал працює як пара вхідний-вихідний сигнал. Це дозволяє будувати великі "дерева" сигналів.
+STR_SIGNAL_CONVERT_TIP                                          :{BLACK}Заміна сигналів{}Якщо активна, натискання на існуючому сигналі замінить його на обраний тип сигналу, CTRL-натискання буде переключати існуючий варіант.
+STR_DRAG_SIGNALS_DENSITY_TIP                                    :{BLACK}Частота сигналів при перетаскуванні
+STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP                           :{BLACK}Зменшити частоту сигналів
+STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP                           :{BLACK}Збільшити частоту сигналів
+########
--- a/src/livery.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/livery.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,6 @@
 #ifndef LIVERY_H
 #define LIVERY_H
 
-#include "helpers.hpp"
 
 /* List of different livery schemes. */
 enum LiveryScheme {
--- a/src/macros.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,364 +0,0 @@
-/* $Id$ */
-
-/** @file macros.h */
-
-#ifndef MACROS_H
-#define MACROS_H
-
-#include "core/math_func.hpp"
-
-/**
- * Fetch n bits from x, started at bit s.
- *
- * This function can be used to fetch n bits from the value x. The
- * s value set the startposition to read. The startposition is
- * count from the LSB and starts at 0. The result starts at a
- * LSB, as this isn't just an and-bitmask but also some
- * bit-shifting operations. GB(0xFF, 2, 1) will so
- * return 0x01 (0000 0001) instead of
- * 0x04 (0000 0100).
- *
- * @param x The value to read some bits.
- * @param s The startposition to read some bits.
- * @param n The number of bits to read.
- * @return The selected bits, aligned to a LSB.
- */
-template<typename T> static inline uint GB(const T x, const uint8 s, const uint8 n)
-{
-	return (x >> s) & ((1U << n) - 1);
-}
-
-/** Set n bits from x starting at bit s to d
- *
- * This function sets n bits from x which started as bit s to the value of
- * d. The parameters x, s and n works the same as the parameters of
- * #GB. The result is saved in x again. Unused bits in the window
- * provided by n are set to 0 if the value of b isn't "big" enough.
- * This is not a bug, its a feature.
- *
- * @note Parameter x must be a variable as the result is saved there.
- * @note To avoid unexpecting results the value of b should not use more
- *       space as the provided space of n bits (log2)
- * @param x The variable to change some bits
- * @param s The startposition for the new bits
- * @param n The size/window for the new bits
- * @param d The actually new bits to save in the defined position.
- * @return The new value of x
- */
-template<typename T, typename U> static inline T SB(T& x, const uint8 s, const uint8 n, const U d)
-{
-	x &= (T)(~(((1U << n) - 1) << s));
-	x |= (T)(d << s);
-	return x;
-}
-
-/** Add i to n bits of x starting at bit s.
- *
- * This add the value of i on n bits of x starting at bit s. The parameters x,
- * s, i are similar to #GB besides x must be a variable as the result are
- * saved there. An overflow does not affect the following bits of the given
- * bit window and is simply ignored.
- *
- * @note Parameter x must be a variable as the result is saved there.
- * @param x The variable to add some bits at some position
- * @param s The startposition of the addition
- * @param n The size/window for the addition
- * @param i The value to add at the given startposition in the given window.
- * @return The new value of x
- */
-template<typename T, typename U> static inline T AB(T& x, const uint8 s, const uint8 n, const U i)
-{
-	const T mask = (T)(((1U << n) - 1) << s);
-	x = (T)((x & ~mask) | ((x + (i << s)) & mask));
-	return x;
-}
-
-/**
- * Checks if a bit in a value is set.
- *
- * This function checks if a bit inside a value is set or not.
- * The y value specific the position of the bit, started at the
- * LSB and count from 0.
- *
- * @param x The value to check
- * @param y The position of the bit to check, started from the LSB
- * @return True if the bit is set, false else.
- */
-template<typename T> static inline bool HasBit(const T x, const uint8 y)
-{
-	return (x & ((T)1U << y)) != 0;
-}
-
-/**
- * Set a bit in a variable.
- *
- * This function sets a bit in a variable. The variable is changed
- * and the value is also returned. Parameter y defines the bit and
- * starts at the LSB with 0.
- *
- * @param x The variable to set a bit
- * @param y The bit position to set
- * @return The new value of the old value with the bit set
- */
-template<typename T> static inline T SetBit(T& x, const uint8 y)
-{
-	return x = (T)(x | (T)(1U << y));
-}
-
-/**
- * Clears a bit in a variable.
- *
- * This function clears a bit in a variable. The variable is
- * changed and the value is also returned. Parameter y defines the bit
- * to clear and starts at the LSB with 0.
- *
- * @param x The variable to clear the bit
- * @param y The bit position to clear
- * @return The new value of the old value with the bit cleared
- */
-template<typename T> static inline T ClrBit(T& x, const uint8 y)
-{
-	return x = (T)(x & ~((T)1U << y));
-}
-
-/**
- * Toggles a bit in a variable.
- *
- * This function toggles a bit in a variable. The variable is
- * changed and the value is also returned. Parameter y defines the bit
- * to toggle and starts at the LSB with 0.
- *
- * @param x The varliable to toggle the bit
- * @param y The bit position to toggle
- * @return The new value of the old value with the bit toggled
- */
-template<typename T> static inline T ToggleBit(T& x, const uint8 y)
-{
-	return x = (T)(x ^ (T)(1U << y));
-}
-
-
-/* checking more bits. Maybe unneccessary, but easy to use */
-/**
- * Check several bits in a value.
- *
- * This macro checks if a value contains at least one bit of an other
- * value.
- *
- * @param x The first value
- * @param y The second value
- * @return True if at least one bit is set in both values, false else.
- */
-#define HASBITS(x, y) ((x) & (y))
-
-/**
- * Sets several bits in a variable.
- *
- * This macro sets several bits in a variable. The bits to set are provided
- * by a value. The new value is also returned.
- *
- * @param x The variable to set some bits
- * @param y The value with set bits for setting them in the variable
- * @return The new value of x
- */
-#define SETBITS(x, y) ((x) |= (y))
-
-/**
- * Clears several bits in a variable.
- *
- * This macro clears several bits in a variable. The bits to clear are
- * provided by a value. The new value is also returned.
- *
- * @param x The variable to clear some bits
- * @param y The value with set bits for clearing them in the variable
- * @return The new value of x
- */
-#define CLRBITS(x, y) ((x) &= ~(y))
-
-#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
-#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
-
-/**
- * Whether a sprite comes from the original graphics files or a new grf file
- * (either supplied by OpenTTD or supplied by the user).
- *
- * @param sprite The sprite to check
- * @return True if it is a new sprite, or false if it is original.
- */
-#define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE)
-
-extern const byte _ffb_64[64];
-
-/**
- * Returns the first occure of a bit in a 6-bit value (from right).
- *
- * Returns the position of the first bit that is not zero, counted from the
- * LSB. Ie, 110100 returns 2, 000001 returns 0, etc. When x == 0 returns
- * 0.
- *
- * @param x The 6-bit value to check the first zero-bit
- * @return The first position of a bit started from the LSB or 0 if x is 0.
- */
-#define FIND_FIRST_BIT(x) _ffb_64[(x)]
-
-/**
- * Finds the position of the first bit in an integer.
- *
- * This function returns the position of the first bit set in the
- * integer. It does only check the bits of the bitmask
- * 0x3F3F (0011111100111111) and checks only the
- * bits of the bitmask 0x3F00 if and only if the
- * lower part 0x00FF is 0. This results the bits at 0x00C0 must
- * be also zero to check the bits at 0x3F00.
- *
- * @param value The value to check the first bits
- * @return The position of the first bit which is set
- * @see FIND_FIRST_BIT
- */
-static inline int FindFirstBit2x64(int value)
-{
-	if ((value & 0xFF) == 0) {
-		return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8;
-	} else {
-		return FIND_FIRST_BIT(value & 0x3F);
-	}
-}
-
-/**
- * Clear the first bit in an integer.
- *
- * This function returns a value where the first bit (from LSB)
- * is cleared.
- * So, 110100 returns 110000, 000001 returns 000000, etc.
- *
- * @param value The value to clear the first bit
- * @return The new value with the first bit cleared
- */
-template<typename T> static inline T KillFirstBit(T value)
-{
-	return value &= (T)(value - 1);
-}
-
-/**
- * Counts the number of set bits in a variable.
- *
- * @param value the value to count the number of bits in.
- * @return the number of bits.
- */
-template<typename T> static inline uint CountBits(T value)
-{
-	uint num;
-
-	/* This loop is only called once for every bit set by clearing the lowest
-	 * bit in each loop. The number of bits is therefore equal to the number of
-	 * times the loop was called. It was found at the following website:
-	 * http://graphics.stanford.edu/~seander/bithacks.html */
-
-	for (num = 0; value != 0; num++) {
-		value &= (T)(value - 1);
-	}
-
-	return num;
-}
-
-/**
- * Flips a coin with a given probability.
- *
- * This macro can be used to get true or false randomized according to a
- * given probability. The parameter a and b create a percent value with
- * (a/b). The macro returns true in (a/b) percent.
- *
- * @param a The numerator of the fraction
- * @param b The denominator of the fraction, must of course not be null
- * @return True in (a/b) percent
- */
-#define CHANCE16(a, b) CHANCE16I(a, b, Random())
-
-/**
- * Flips a coin with a given probability and saves the randomize-number in a variable.
- *
- * This macro uses the same parameters as the CHANCE16 marco. The third parameter
- * must be a variable the randomize-number from Random() is saved in.
- *
- * The low 16 bits of r will already be used and can therefor not be passed to
- * CHANCE16I. One can only send the high 16 bits to CHANCE16I.
- *
- * @param a The numerator of the fraction, see CHANCE16
- * @param b The denominator of the fraction, see CHANCE16
- * @param r The variable to save the randomize-number from Random()
- * @return True in (a/b) percent
- */
-#define CHANCE16R(a, b, r) CHANCE16I(a, b, r = Random())
-
-/**
- * Checks if a given randomize-number is below a given probability.
- *
- * This macro is used to check if the given probability by the fraction of (a/b)
- * is greater than low 16 bits of the given randomize-number v.
- *
- * Do not use this function twice on the same random 16 bits as it will yield
- * the same result. One can use a random number for two calls to CHANCE16I,
- * where one call sends the low 16 bits and the other the high 16 bits.
- *
- * @param a The numerator of the fraction, see CHANCE16
- * @param b The denominator of the fraction, see CHANCE16
- * @param r The given randomize-number
- * @return True if v is less or equals (a/b)
- */
-static inline bool CHANCE16I(const uint a, const uint b, const uint32 r)
-{
-	return (uint16)r < (uint16)((65536 * a) / b);
-}
-
-
-#define for_each_bit(_i, _b)            \
-	for (_i = 0; _b != 0; _i++, _b >>= 1) \
-		if (_b & 1)
-
-
-static inline uint16 ReadLE16Aligned(const void* x)
-{
-	return FROM_LE16(*(const uint16*)x);
-}
-
-static inline uint16 ReadLE16Unaligned(const void* x)
-{
-#ifdef OTTD_ALIGNMENT
-	return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
-#else
-	return FROM_LE16(*(const uint16*)x);
-#endif
-}
-
-
-/**
- * ROtate x Left by n
- *
- * @note Assumes a byte has 8 bits
- * @param x The value which we want to rotate
- * @param n The number how many we waht to rotate
- * @return A bit rotated number
- */
-template<typename T> static inline T ROL(const T x, const uint8 n)
-{
-	return (T)(x << n | x >> (sizeof(x) * 8 - n));
-}
-
-/**
- * ROtate x Right by n
- *
- * @note Assumes a byte has 8 bits
- * @param x The value which we want to rotate
- * @param n The number how many we waht to rotate
- * @return A bit rotated number
- */
-template<typename T> static inline T ROR(const T x, const uint8 n)
-{
-	return (T)(x >> n | x << (sizeof(x) * 8 - n));
-}
-
-/** return the largest value that can be entered in a variable.
- */
-#define MAX_UVALUE(type) ((type)~(type)0)
-
-#endif /* MACROS_H */
--- a/src/main_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/main_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,26 +6,19 @@
 #include "openttd.h"
 #include "heightmap.h"
 #include "currency.h"
-#include "functions.h"
 #include "spritecache.h"
-#include "station.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "map.h"
-#include "tile.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
+#include "window_gui.h"
+#include "window_func.h"
+#include "textbuf_gui.h"
+#include "viewport_func.h"
 #include "player.h"
-#include "road.h"
-#include "command.h"
+#include "command_func.h"
 #include "news.h"
 #include "town.h"
-#include "vehicle.h"
 #include "console.h"
-#include "sound.h"
 #include "network/network.h"
 #include "signs.h"
 #include "waypoint.h"
@@ -33,15 +26,19 @@
 #include "train.h"
 #include "roadveh.h"
 #include "bridge_map.h"
-#include "unmovable_map.h"
-#include "string.h"
 #include "screenshot.h"
 #include "genworld.h"
-#include "settings.h"
-#include "date.h"
 #include "vehicle_gui.h"
 #include "transparency_gui.h"
 #include "newgrf_config.h"
+#include "rail_gui.h"
+#include "road_gui.h"
+#include "date_func.h"
+#include "functions.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "fios.h"
+#include "terraform_gui.h"
 
 #include "network/network_data.h"
 #include "network/network_client.h"
@@ -49,11 +46,13 @@
 #include "network/network_gui.h"
 #include "industry.h"
 #include "transparency.h"
+#include "strings_func.h"
+#include "zoom_func.h"
+#include "string_func.h"
 
 static int _rename_id = 1;
 static int _rename_what = -1;
 
-static byte _terraform_size = 1;
 RailType _last_built_railtype;
 RoadType _last_built_roadtype;
 static int _scengen_town_size = 1; // depress medium-sized towns per default
@@ -121,18 +120,18 @@
  */
 bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc)
 {
-	if (IsWindowWidgetDisabled(w, widget)) return false;
+	if (w->IsWidgetDisabled(widget)) return false;
 
 	SndPlayFx(SND_15_BEEP);
 	SetWindowDirty(w);
 
-	if (IsWindowWidgetLowered(w, widget)) {
+	if (w->IsWidgetLowered(widget)) {
 		ResetObjectToPlace();
 		return false;
 	}
 
 	SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number);
-	LowerWindowWidget(w, widget);
+	w->LowerWidget(widget);
 	_place_proc = placeproc;
 	return true;
 }
@@ -468,7 +467,7 @@
 
 	case WE_DESTROY: {
 			Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
-			RaiseWindowWidget(v, WP(w,menu_d).main_button);
+			v->RaiseWidget(WP(w, menu_d).main_button);
 			SetWindowDirty(v);
 			return;
 		}
@@ -480,11 +479,11 @@
 
 		if (index < 0) {
 			Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
-			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button)
-				index = WP(w,menu_d).sel_index;
+			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
+				index = WP(w, menu_d).sel_index;
 		}
 
-		action_id = WP(w,menu_d).action_id;
+		action_id = WP(w, menu_d).action_id;
 		DeleteWindow(w);
 
 		if (index >= 0) {
@@ -498,9 +497,9 @@
 	case WE_POPUPMENU_OVER: {
 		int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
 
-		if (index == -1 || index == WP(w,menu_d).sel_index) return;
+		if (index == -1 || index == WP(w, menu_d).sel_index) return;
 
-		WP(w,menu_d).sel_index = index;
+		WP(w, menu_d).sel_index = index;
 		SetWindowDirty(w);
 		return;
 		}
@@ -538,10 +537,10 @@
 	byte num = ActivePlayerCount();
 
 	/* Increase one to fit in PlayerList in the menu when in network */
-	if (_networking && WP(w,menu_d).main_button == 9) num++;
+	if (_networking && WP(w, menu_d).main_button == 9) num++;
 
-	if (WP(w,menu_d).item_count != num) {
-		WP(w,menu_d).item_count = num;
+	if (WP(w, menu_d).item_count != num) {
+		WP(w, menu_d).item_count = num;
 		SetWindowDirty(w);
 		num = num * 10 + 2;
 		w->height = num;
@@ -565,11 +564,11 @@
 
 		x = 1;
 		y = 1;
-		sel = WP(w,menu_d).sel_index;
-		chk = WP(w,menu_d).checked_items; // let this mean gray items.
+		sel = WP(w, menu_d).sel_index;
+		chk = WP(w, menu_d).checked_items; // let this mean gray items.
 
 		/* 9 = playerlist */
-		if (_networking && WP(w,menu_d).main_button == 9) {
+		if (_networking && WP(w, menu_d).main_button == 9) {
 			if (sel == 0) {
 				GfxFillRect(x, y, x + 238, y + 9, 0);
 			}
@@ -603,18 +602,18 @@
 
 	case WE_DESTROY: {
 		Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
-		RaiseWindowWidget(v, WP(w,menu_d).main_button);
+		v->RaiseWidget(WP(w, menu_d).main_button);
 		SetWindowDirty(v);
 		return;
 		}
 
 	case WE_POPUPMENU_SELECT: {
 		int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
-		int action_id = WP(w,menu_d).action_id;
+		int action_id = WP(w, menu_d).action_id;
 
 		/* We have a new entry at the top of the list of menu 9 when networking
 		 *  so keep that in count */
-		if (_networking && WP(w,menu_d).main_button == 9) {
+		if (_networking && WP(w, menu_d).main_button == 9) {
 			if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
 		} else {
 			index = GetPlayerIndexFromMenu(index);
@@ -622,8 +621,8 @@
 
 		if (index < 0) {
 			Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
-			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button)
-				index = WP(w,menu_d).sel_index;
+			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
+				index = WP(w, menu_d).sel_index;
 		}
 
 		DeleteWindow(w);
@@ -641,15 +640,15 @@
 
 		/* We have a new entry at the top of the list of menu 9 when networking
 		 * so keep that in count */
-		if (_networking && WP(w,menu_d).main_button == 9) {
+		if (_networking && WP(w, menu_d).main_button == 9) {
 			if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
 		} else {
 			index = GetPlayerIndexFromMenu(index);
 		}
 
-		if (index == -1 || index == WP(w,menu_d).sel_index) return;
+		if (index == -1 || index == WP(w, menu_d).sel_index) return;
 
-		WP(w,menu_d).sel_index = index;
+		WP(w, menu_d).sel_index = index;
 		SetWindowDirty(w);
 		return;
 		}
@@ -705,8 +704,8 @@
 	int x = w->widget[GB(parent_button, 0, 8)].left;
 
 	assert(disabled_mask == 0 || item_count <= 8);
-	LowerWindowWidget(w, parent_button);
-	InvalidateWidget(w, parent_button);
+	w->LowerWidget(parent_button);
+	w->InvalidateWidget(parent_button);
 
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
 
@@ -722,13 +721,13 @@
 	w->widget[0].bottom = item_count * 10 + 1;
 	w->flags4 &= ~WF_WHITE_BORDER_MASK;
 
-	WP(w,menu_d).item_count = item_count;
-	WP(w,menu_d).sel_index = 0;
-	WP(w,menu_d).main_button = GB(parent_button, 0, 8);
-	WP(w,menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button;
-	WP(w,menu_d).string_id = base_string;
-	WP(w,menu_d).checked_items = 0;
-	WP(w,menu_d).disabled_items = disabled_mask;
+	WP(w, menu_d).item_count = item_count;
+	WP(w, menu_d).sel_index = 0;
+	WP(w, menu_d).main_button = GB(parent_button, 0, 8);
+	WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button;
+	WP(w, menu_d).string_id = base_string;
+	WP(w, menu_d).checked_items = 0;
+	WP(w, menu_d).disabled_items = disabled_mask;
 
 	_popup_menu_active = true;
 
@@ -740,26 +739,26 @@
 {
 	int x = w->widget[main_button].left + w->left;
 
-	LowerWindowWidget(w, main_button);
-	InvalidateWidget(w, main_button);
+	w->LowerWidget(main_button);
+	w->InvalidateWidget(main_button);
 
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
 	w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
 	w->flags4 &= ~WF_WHITE_BORDER_MASK;
-	WP(w,menu_d).item_count = 0;
-	WP(w,menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
+	WP(w, menu_d).item_count = 0;
+	WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
 	if (_networking && main_button == 9) {
 		if (_local_player != PLAYER_SPECTATOR) {
-			WP(w,menu_d).sel_index++;
+			WP(w, menu_d).sel_index++;
 		} else {
 			/* Select client list by default for spectators */
-			WP(w,menu_d).sel_index = 0;
+			WP(w, menu_d).sel_index = 0;
 		}
 	}
-	WP(w,menu_d).action_id = main_button;
-	WP(w,menu_d).main_button = main_button;
-	WP(w,menu_d).checked_items = gray;
-	WP(w,menu_d).disabled_items = 0;
+	WP(w, menu_d).action_id = main_button;
+	WP(w, menu_d).main_button = main_button;
+	WP(w, menu_d).checked_items = gray;
+	WP(w, menu_d).disabled_items = 0;
 	_popup_menu_active = true;
 	SndPlayFx(SND_15_BEEP);
 	return w;
@@ -872,23 +871,23 @@
 	switch (how) {
 		case ZOOM_IN:
 			if (vp->zoom == ZOOM_LVL_MIN) return false;
-			vp->zoom = (ZoomLevel)((byte)vp->zoom - 1);
+			vp->zoom = (ZoomLevel)((int)vp->zoom - 1);
 			vp->virtual_width >>= 1;
 			vp->virtual_height >>= 1;
 
-			WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1;
-			WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1;
-			WP(w,vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x;
-			WP(w,vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
+			WP(w, vp_d).scrollpos_x += vp->virtual_width >> 1;
+			WP(w, vp_d).scrollpos_y += vp->virtual_height >> 1;
+			WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x;
+			WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
 			break;
 		case ZOOM_OUT:
 			if (vp->zoom == ZOOM_LVL_MAX) return false;
-			vp->zoom = (ZoomLevel)((byte)vp->zoom + 1);
+			vp->zoom = (ZoomLevel)((int)vp->zoom + 1);
 
-			WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1;
-			WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1;
-			WP(w,vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x;
-			WP(w,vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
+			WP(w, vp_d).scrollpos_x -= vp->virtual_width >> 1;
+			WP(w, vp_d).scrollpos_y -= vp->virtual_height >> 1;
+			WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x;
+			WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
 
 			vp->virtual_width <<= 1;
 			vp->virtual_height <<= 1;
@@ -907,7 +906,7 @@
 static void ToolbarZoomInClick(Window *w)
 {
 	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
-		HandleButtonClick(w, 17);
+		w->HandleButtonClick(17);
 		SndPlayFx(SND_15_BEEP);
 	}
 }
@@ -915,7 +914,7 @@
 static void ToolbarZoomOutClick(Window *w)
 {
 	if (DoZoomInOutWindow(ZOOM_OUT,FindWindowById(WC_MAIN_WINDOW, 0))) {
-		HandleButtonClick(w, 18);
+		w->HandleButtonClick(18);
 		SndPlayFx(SND_15_BEEP);
 	}
 }
@@ -979,7 +978,7 @@
 	if (HasBit(_display_opt, DO_FULL_DETAIL))        SetBit(x, 11);
 	if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SetBit(x, 12);
 	if (IsTransparencySet(TO_SIGNS))                     SetBit(x, 13);
-	WP(w,menu_d).checked_items = x;
+	WP(w, menu_d).checked_items = x;
 }
 
 
@@ -992,7 +991,7 @@
 {
 	/* don't allow too fast scrolling */
 	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
-		HandleButtonClick(w, 6);
+		w->HandleButtonClick(6);
 		SetWindowDirty(w);
 
 		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
@@ -1005,7 +1004,7 @@
 {
 	/* don't allow too fast scrolling */
 	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
-		HandleButtonClick(w, 7);
+		w->HandleButtonClick(7);
 		SetWindowDirty(w);
 
 		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
@@ -1023,7 +1022,7 @@
 static void ToolbarScenZoomIn(Window *w)
 {
 	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
-		HandleButtonClick(w, 9);
+		w->HandleButtonClick(9);
 		SndPlayFx(SND_15_BEEP);
 	}
 }
@@ -1031,7 +1030,7 @@
 static void ToolbarScenZoomOut(Window *w)
 {
 	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
-		HandleButtonClick(w, 10);
+		w->HandleButtonClick(10);
 		SndPlayFx(SND_15_BEEP);
 	}
 }
@@ -1058,362 +1057,12 @@
 	}
 }
 
-/**
- * Raise/Lower a bigger chunk of land at the same time in the editor. When
- * raising get the lowest point, when lowering the highest point, and set all
- * tiles in the selection to that height.
- * @todo : Incorporate into game itself to allow for ingame raising/lowering of
- *         larger chunks at the same time OR remove altogether, as we have 'level land' ?
- * @param tile The top-left tile where the terraforming will start
- * @param mode 1 for raising, 0 for lowering land
- */
-static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
-{
-	int sizex, sizey;
-	uint h;
-
-	_generating_world = true; // used to create green terraformed land
-
-	if (_terraform_size == 1) {
-		StringID msg =
-			mode ? STR_0808_CAN_T_RAISE_LAND_HERE : STR_0809_CAN_T_LOWER_LAND_HERE;
-
-		DoCommandP(tile, SLOPE_N, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_MSG(msg));
-	} else {
-		SndPlayTileFx(SND_1F_SPLAT, tile);
-
-		assert(_terraform_size != 0);
-		/* check out for map overflows */
-		sizex = min(MapSizeX() - TileX(tile) - 1, _terraform_size);
-		sizey = min(MapSizeY() - TileY(tile) - 1, _terraform_size);
-
-		if (sizex == 0 || sizey == 0) return;
-
-		if (mode != 0) {
-			/* Raise land */
-			h = 15; // XXX - max height
-			BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
-				h = min(h, TileHeight(tile2));
-			} END_TILE_LOOP(tile2, sizex, sizey, tile)
-		} else {
-			/* Lower land */
-			h = 0;
-			BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
-				h = max(h, TileHeight(tile2));
-			} END_TILE_LOOP(tile2, sizex, sizey, tile)
-		}
-
-		BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
-			if (TileHeight(tile2) == h) {
-				DoCommandP(tile2, SLOPE_N, (uint32)mode, NULL, CMD_TERRAFORM_LAND);
-			}
-		} END_TILE_LOOP(tile2, sizex, sizey, tile)
-	}
-
-	_generating_world = false;
-}
-
-static void PlaceProc_RaiseBigLand(TileIndex tile)
-{
-	CommonRaiseLowerBigLand(tile, 1);
-}
-
-static void PlaceProc_LowerBigLand(TileIndex tile)
-{
-	CommonRaiseLowerBigLand(tile, 0);
-}
-
-static void PlaceProc_RockyArea(TileIndex tile)
-{
-	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_ROCKS);
-}
-
-static void PlaceProc_LightHouse(TileIndex tile)
-{
-	if (!IsTileType(tile, MP_CLEAR) || IsSteepSlope(GetTileSlope(tile, NULL)) || IsBridgeAbove(tile)) {
-		return;
-	}
-
-	MakeLighthouse(tile);
-	MarkTileDirtyByTile(tile);
-	SndPlayTileFx(SND_1F_SPLAT, tile);
-}
-
-static void PlaceProc_Transmitter(TileIndex tile)
-{
-	if (!IsTileType(tile, MP_CLEAR) || IsSteepSlope(GetTileSlope(tile, NULL)) || IsBridgeAbove(tile)) {
-		return;
-	}
-
-	MakeTransmitter(tile);
-	MarkTileDirtyByTile(tile);
-	SndPlayTileFx(SND_1F_SPLAT, tile);
-}
-
-static void PlaceProc_DesertArea(TileIndex tile)
-{
-	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_DESERT);
-}
-
-static void PlaceProc_WaterArea(TileIndex tile)
-{
-	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_WATER);
-}
-
-static const Widget _scen_edit_land_gen_widgets[] = {
-{  WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                  STR_018B_CLOSE_WINDOW},
-{   WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0223_LAND_GENERATION,  STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_STICKYBOX,   RESIZE_NONE,     7,   170,   181,     0,    13, STR_NULL,                  STR_STICKY_BUTTON},
-{     WWT_PANEL,   RESIZE_NONE,     7,     0,   181,    14,   102, 0x0,                       STR_NULL},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,     2,    23,    16,    37, SPR_IMG_DYNAMITE,          STR_018D_DEMOLISH_BUILDINGS_ETC},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,    24,    45,    16,    37, SPR_IMG_TERRAFORM_DOWN,    STR_018E_LOWER_A_CORNER_OF_LAND},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,    46,    67,    16,    37, SPR_IMG_TERRAFORM_UP,      STR_018F_RAISE_A_CORNER_OF_LAND},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,    68,    89,    16,    37, SPR_IMG_LEVEL_LAND,        STR_LEVEL_LAND_TOOLTIP},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,    90,   111,    16,    37, SPR_IMG_BUILD_CANAL,       STR_CREATE_LAKE},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,   112,   134,    16,    37, SPR_IMG_ROCKS,             STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,   135,   157,    16,    37, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, // XXX - dynamic
-{    WWT_IMGBTN,   RESIZE_NONE,    14,   158,   179,    16,    37, SPR_IMG_TRANSMITTER,       STR_028E_PLACE_TRANSMITTER},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,   139,   150,    45,    56, SPR_ARROW_UP,              STR_0228_INCREASE_SIZE_OF_LAND_AREA},
-{    WWT_IMGBTN,   RESIZE_NONE,    14,   139,   150,    58,    69, SPR_ARROW_DOWN,            STR_0229_DECREASE_SIZE_OF_LAND_AREA},
-{   WWT_TEXTBTN,   RESIZE_NONE,    14,    24,   157,    76,    87, STR_SE_NEW_WORLD,          STR_022A_GENERATE_RANDOM_LAND},
-{   WWT_TEXTBTN,   RESIZE_NONE,    14,    24,   157,    89,   100, STR_022B_RESET_LANDSCAPE,  STR_RESET_LANDSCAPE_TOOLTIP},
-{   WIDGETS_END},
-};
-
-static const int8 _multi_terraform_coords[][2] = {
-	{  0, -2},
-	{  4,  0}, { -4,  0}, {  0,  2},
-	{ -8,  2}, { -4,  4}, {  0,  6}, {  4,  4}, {  8,  2},
-	{-12,  0}, { -8, -2}, { -4, -4}, {  0, -6}, {  4, -4}, {  8, -2}, { 12,  0},
-	{-16,  2}, {-12,  4}, { -8,  6}, { -4,  8}, {  0, 10}, {  4,  8}, {  8,  6}, { 12,  4}, { 16,  2},
-	{-20,  0}, {-16, -2}, {-12, -4}, { -8, -6}, { -4, -8}, {  0,-10}, {  4, -8}, {  8, -6}, { 12, -4}, { 16, -2}, { 20,  0},
-	{-24,  2}, {-20,  4}, {-16,  6}, {-12,  8}, { -8, 10}, { -4, 12}, {  0, 14}, {  4, 12}, {  8, 10}, { 12,  8}, { 16,  6}, { 20,  4}, { 24,  2},
-	{-28,  0}, {-24, -2}, {-20, -4}, {-16, -6}, {-12, -8}, { -8,-10}, { -4,-12}, {  0,-14}, {  4,-12}, {  8,-10}, { 12, -8}, { 16, -6}, { 20, -4}, { 24, -2}, { 28,  0},
-};
-
-/**
- * @todo Merge with terraform_gui.cpp (move there) after I have cooled down at its braindeadness
- * and changed OnButtonClick to include the widget as well in the function declaration. Post 0.4.0 - Darkvater
- */
-static void EditorTerraformClick_Dynamite(Window *w)
-{
-	HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
-}
-
-static void EditorTerraformClick_LowerBigLand(Window *w)
-{
-	HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerBigLand);
-}
-
-static void EditorTerraformClick_RaiseBigLand(Window *w)
-{
-	HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseBigLand);
-}
-
-static void EditorTerraformClick_LevelLand(Window *w)
-{
-	HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
-}
-
-static void EditorTerraformClick_WaterArea(Window *w)
-{
-	HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, VHM_RECT, PlaceProc_WaterArea);
-}
-
-static void EditorTerraformClick_RockyArea(Window *w)
-{
-	HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, VHM_RECT, PlaceProc_RockyArea);
-}
-
-static void EditorTerraformClick_DesertLightHouse(Window *w)
-{
-	HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
-}
-
-static void EditorTerraformClick_Transmitter(Window *w)
-{
-	HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, VHM_RECT, PlaceProc_Transmitter);
-}
-
-static const uint16 _editor_terraform_keycodes[] = {
-	'D',
-	'Q',
-	'W',
-	'E',
-	'R',
-	'T',
-	'Y',
-	'U'
-};
-
-typedef void OnButtonClick(Window *w);
-static OnButtonClick * const _editor_terraform_button_proc[] = {
-	EditorTerraformClick_Dynamite,
-	EditorTerraformClick_LowerBigLand,
-	EditorTerraformClick_RaiseBigLand,
-	EditorTerraformClick_LevelLand,
-	EditorTerraformClick_WaterArea,
-	EditorTerraformClick_RockyArea,
-	EditorTerraformClick_DesertLightHouse,
-	EditorTerraformClick_Transmitter
-};
-
-
-/** Callback function for the scenario editor 'reset landscape' confirmation window
- * @param w Window unused
- * @param confirmed boolean value, true when yes was clicked, false otherwise */
-static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
-{
-	if (confirmed) {
-		Player *p;
-
-		/* Set generating_world to true to get instant-green grass after removing
-		 * player property. */
-		_generating_world = true;
-		/* Delete all players */
-		FOR_ALL_PLAYERS(p) {
-			if (p->is_active) {
-				ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
-				p->is_active = false;
-			}
-		}
-		_generating_world = false;
-
-		/* Delete all stations owned by a player */
-		Station *st;
-		FOR_ALL_STATIONS(st) {
-			if (IsValidPlayer(st->owner)) delete st;
-		}
-	}
-}
-
-static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
-{
-	switch (e->event) {
-	case WE_CREATE:
-		/* XXX - lighthouse button is widget 10!! Don't forget when changing */
-		w->widget[10].tooltips = (_opt.landscape == LT_TROPIC) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE;
-		break;
-
-	case WE_PAINT:
-		DrawWindowWidgets(w);
-
-		{
-			int n = _terraform_size * _terraform_size;
-			const int8 *coords = &_multi_terraform_coords[0][0];
-
-			assert(n != 0);
-			do {
-				DrawSprite(SPR_WHITE_POINT, PAL_NONE, 77 + coords[0], 55 + coords[1]);
-				coords += 2;
-			} while (--n);
-		}
-
-		if (IsWindowWidgetLowered(w, 5) || IsWindowWidgetLowered(w, 6)) // change area-size if raise/lower corner is selected
-			SetTileSelectSize(_terraform_size, _terraform_size);
-
-		break;
-
-	case WE_KEYPRESS: {
-		uint i;
-
-		for (i = 0; i != lengthof(_editor_terraform_keycodes); i++) {
-			if (e->we.keypress.keycode == _editor_terraform_keycodes[i]) {
-				e->we.keypress.cont = false;
-				_editor_terraform_button_proc[i](w);
-				break;
-			}
-		}
-	} break;
-
-	case WE_CLICK:
-		switch (e->we.click.widget) {
-		case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11:
-			_editor_terraform_button_proc[e->we.click.widget - 4](w);
-			break;
-		case 12: case 13: { // Increase/Decrease terraform size
-			int size = (e->we.click.widget == 12) ? 1 : -1;
-			HandleButtonClick(w, e->we.click.widget);
-			size += _terraform_size;
-
-			if (!IS_INT_INSIDE(size, 1, 8 + 1)) return;
-			_terraform_size = size;
-
-			SndPlayFx(SND_15_BEEP);
-			SetWindowDirty(w);
-		} break;
-		case 14: // gen random land
-			HandleButtonClick(w, 14);
-			ShowCreateScenario();
-			break;
-		case 15: // Reset landscape
-			ShowQuery(
-			  STR_022C_RESET_LANDSCAPE,
-			  STR_RESET_LANDSCAPE_CONFIRMATION_TEXT,
-			  NULL,
-			  ResetLandscapeConfirmationCallback);
-			break;
-		}
-		break;
-
-	case WE_TIMEOUT: {
-		uint i;
-		for (i = 0; i < w->widget_count; i++) {
-			if (IsWindowWidgetLowered(w, i)) {
-				RaiseWindowWidget(w, i);
-				InvalidateWidget(w, i);
-			}
-			if (i == 3) i = 11;
-		}
-		break;
-	}
-	case WE_PLACE_OBJ:
-		_place_proc(e->we.place.tile);
-		break;
-	case WE_PLACE_DRAG:
-		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
-		break;
-
-	case WE_PLACE_MOUSEUP:
-		if (e->we.place.pt.x != -1) {
-			switch (e->we.place.select_proc) {
-				case DDSP_CREATE_ROCKS:
-				case DDSP_CREATE_DESERT:
-				case DDSP_CREATE_WATER:
-				case DDSP_LEVEL_AREA:
-				case DDSP_DEMOLISH_AREA:
-					GUIPlaceProcDragXY(e);
-					break;
-			}
-		}
-		break;
-
-	case WE_ABORT_PLACE_OBJ:
-		RaiseWindowButtons(w);
-		SetWindowDirty(w);
-		break;
-	}
-}
-
-static const WindowDesc _scen_edit_land_gen_desc = {
-	WDP_AUTO, WDP_AUTO, 182, 103, 182, 103,
-	WC_SCEN_LAND_GEN, WC_NONE,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
-	_scen_edit_land_gen_widgets,
-	ScenEditLandGenWndProc,
-};
-
-static inline void ShowEditorTerraformToolBar()
-{
-	AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0);
-}
-
 static void ToolbarScenGenLand(Window *w)
 {
-	HandleButtonClick(w, 11);
+	w->HandleButtonClick(11);
 	SndPlayFx(SND_15_BEEP);
 
-	ShowEditorTerraformToolBar();
+	ShowEditorTerraformToolbar();
 }
 
 void CcBuildTown(bool success, TileIndex tile, uint32 p1, uint32 p2)
@@ -1456,7 +1105,7 @@
 		break;
 
 	case WE_CREATE:
-		LowerWindowWidget(w, _scengen_town_size + 7);
+		w->LowerWidget(_scengen_town_size + 7);
 		break;
 
 	case WE_CLICK:
@@ -1469,7 +1118,7 @@
 			uint size = min(_scengen_town_size, (int)TSM_CITY);
 			TownSizeMode mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;
 
-			HandleButtonClick(w, 5);
+			w->HandleButtonClick(5);
 			_generating_world = true;
 			t = CreateRandomTown(20, mode, size);
 			_generating_world = false;
@@ -1483,7 +1132,7 @@
 			break;
 		}
 		case 6: {// many random towns
-			HandleButtonClick(w, 6);
+			w->HandleButtonClick(6);
 
 			_generating_world = true;
 			if (!GenerateTowns()) ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
@@ -1492,25 +1141,25 @@
 		}
 
 		case 7: case 8: case 9: case 10:
-			RaiseWindowWidget(w, _scengen_town_size + 7);
+			w->RaiseWidget(_scengen_town_size + 7);
 			_scengen_town_size = e->we.click.widget - 7;
-			LowerWindowWidget(w, _scengen_town_size + 7);
+			w->LowerWidget(_scengen_town_size + 7);
 			SetWindowDirty(w);
 			break;
 		}
 		break;
 
 	case WE_TIMEOUT:
-		RaiseWindowWidget(w, 5);
-		RaiseWindowWidget(w, 6);
+		w->RaiseWidget(5);
+		w->RaiseWidget(6);
 		SetWindowDirty(w);
 		break;
 	case WE_PLACE_OBJ:
 		_place_proc(e->we.place.tile);
 		break;
 	case WE_ABORT_PLACE_OBJ:
-		RaiseWindowButtons(w);
-		LowerWindowWidget(w, _scengen_town_size + 7);
+		w->RaiseButtons();
+		w->LowerWidget(_scengen_town_size + 7);
 		SetWindowDirty(w);
 		break;
 	}
@@ -1526,7 +1175,7 @@
 
 static void ToolbarScenGenTown(Window *w)
 {
-	HandleButtonClick(w, 12);
+	w->HandleButtonClick(12);
 	SndPlayFx(SND_15_BEEP);
 
 	AllocateWindowDescFront(&_scen_edit_town_gen_desc, 0);
@@ -1534,28 +1183,28 @@
 
 static void ToolbarScenGenIndustry(Window *w)
 {
-	HandleButtonClick(w, 13);
+	w->HandleButtonClick(13);
 	SndPlayFx(SND_15_BEEP);
 	ShowBuildIndustryWindow();
 }
 
 static void ToolbarScenBuildRoad(Window *w)
 {
-	HandleButtonClick(w, 14);
+	w->HandleButtonClick(14);
 	SndPlayFx(SND_15_BEEP);
 	ShowBuildRoadScenToolbar();
 }
 
 static void ToolbarScenPlantTrees(Window *w)
 {
-	HandleButtonClick(w, 15);
+	w->HandleButtonClick(15);
 	SndPlayFx(SND_15_BEEP);
 	ShowBuildTreesScenToolbar();
 }
 
 static void ToolbarScenPlaceSign(Window *w)
 {
-	HandleButtonClick(w, 16);
+	w->HandleButtonClick(16);
 	SndPlayFx(SND_15_BEEP);
 	SelectSignTool();
 }
@@ -1608,18 +1257,18 @@
 		/* If spectator, disable all construction buttons
 		 * ie : Build road, rail, ships, airports and landscaping
 		 * Since enabled state is the default, just disable when needed */
-		SetWindowWidgetsDisabledState(w, _current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
+		w->SetWidgetsDisabledState(_current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
 		/* disable company list drop downs, if there are no companies */
-		SetWindowWidgetsDisabledState(w, ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
+		w->SetWidgetsDisabledState(ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
 
-		SetWindowWidgetDisabledState(w, 19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
-		SetWindowWidgetDisabledState(w, 22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
+		w->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
+		w->SetWidgetDisabledState(22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
 
 		DrawWindowWidgets(w);
 		break;
 
 	case WE_CLICK: {
-		if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget))
+		if (_game_mode != GM_MENU && !w->IsWidgetDisabled(e->we.click.widget))
 			_toolbar_button_procs[e->we.click.widget](w);
 	} break;
 
@@ -1672,19 +1321,19 @@
 	} break;
 
 	case WE_ABORT_PLACE_OBJ: {
-		RaiseWindowWidget(w, 25);
+		w->RaiseWidget(25);
 		SetWindowDirty(w);
 	} break;
 
 	case WE_MOUSELOOP:
-		if (IsWindowWidgetLowered(w, 0) != !!_pause_game) {
-			ToggleWidgetLoweredState(w, 0);
-			InvalidateWidget(w, 0);
+		if (w->IsWidgetLowered(0) != !!_pause_game) {
+			w->ToggleWidgetLoweredState(0);
+			w->InvalidateWidget(0);
 		}
 
-		if (IsWindowWidgetLowered(w, 1) != !!_fast_forward) {
-			ToggleWidgetLoweredState(w, 1);
-			InvalidateWidget(w, 1);
+		if (w->IsWidgetLowered(1) != !!_fast_forward) {
+			w->ToggleWidgetLoweredState(1);
+			w->InvalidateWidget(1);
 		}
 		break;
 
@@ -1718,9 +1367,9 @@
 	case WE_TIMEOUT: {
 		uint i;
 		for (i = 2; i < w->widget_count; i++) {
-			if (IsWindowWidgetLowered(w, i)) {
-				RaiseWindowWidget(w, i);
-				InvalidateWidget(w, i);
+			if (w->IsWidgetLowered(i)) {
+				w->RaiseWidget(i);
+				w->InvalidateWidget(i);
 			}
 		}
 		break;
@@ -1849,8 +1498,8 @@
 {
 	switch (e->event) {
 	case WE_PAINT:
-		SetWindowWidgetDisabledState(w, 6, _patches_newgame.starting_year <= MIN_YEAR);
-		SetWindowWidgetDisabledState(w, 7, _patches_newgame.starting_year >= MAX_YEAR);
+		w->SetWidgetDisabledState(6, _patches_newgame.starting_year <= MIN_YEAR);
+		w->SetWidgetDisabledState(7, _patches_newgame.starting_year >= MAX_YEAR);
 
 		/* Draw brown-red toolbar bg. */
 		GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
@@ -1889,7 +1538,22 @@
 			case WKC_F11: PlaceLandBlockInfo(); break;
 			case WKC_CTRL | 'S': MenuClickSmallScreenshot(); break;
 			case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break;
-			case 'L': ShowEditorTerraformToolBar(); break;
+
+			/* those following are all fall through */
+			case WKC_NUM_PLUS:
+			case WKC_EQUALS:
+			case WKC_SHIFT | WKC_EQUALS:
+			case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
+
+			/* those following are all fall through */
+			case WKC_NUM_MINUS:
+			case WKC_MINUS:
+			case WKC_SHIFT | WKC_MINUS:
+			case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
+
+			case 'L': ShowEditorTerraformToolbar(); break;
+			case 'M': ShowSmallMap(); break;
+			case 'V': ShowExtraViewPortWindow(); break;
 			default: return;
 		}
 		e->we.keypress.cont = false;
@@ -1900,7 +1564,7 @@
 	} break;
 
 	case WE_ABORT_PLACE_OBJ: {
-		RaiseWindowWidget(w, 25);
+		w->RaiseWidget(25);
 		SetWindowDirty(w);
 	} break;
 
@@ -1971,13 +1635,13 @@
 	} break;
 
 	case WE_MOUSELOOP:
-		if (IsWindowWidgetLowered(w, 0) != !!_pause_game) {
-			ToggleWidgetLoweredState(w, 0);
+		if (w->IsWidgetLowered(0) != !!_pause_game) {
+			w->ToggleWidgetLoweredState(0);
 			SetWindowDirty(w);
 		}
 
-		if (IsWindowWidgetLowered(w, 1) != !!_fast_forward) {
-			ToggleWidgetLoweredState(w, 1);
+		if (w->IsWidgetLowered(1) != !!_fast_forward) {
+			w->ToggleWidgetLoweredState(1);
 			SetWindowDirty(w);
 		}
 		break;
@@ -2070,10 +1734,10 @@
 			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING);
 		} else if (_pause_game) {
 			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING);
-		} else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
+		} else if (WP(w, def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
 			/* Draw the scrolling news text */
-			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) {
-				WP(w,def_d).data_1 = -1280;
+			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w, def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) {
+				WP(w, def_d).data_1 = -1280;
 				if (p != NULL) {
 					/* This is the default text */
 					SetDParam(0, p->index);
@@ -2109,14 +1773,14 @@
 
 		if (WP(w, def_d).data_1 > -1280) { // Scrolling text
 			WP(w, def_d).data_1 -= 2;
-			InvalidateWidget(w, 1);
+			w->InvalidateWidget(1);
 		}
 
 		if (WP(w, def_d).data_2 > 0) { // Red blot to show there are new unread newsmessages
 			WP(w, def_d).data_2 -= 2;
 		} else if (WP(w, def_d).data_2 < 0) {
 			WP(w, def_d).data_2 = 0;
-			InvalidateWidget(w, 1);
+			w->InvalidateWidget(1);
 		}
 
 		break;
@@ -2214,8 +1878,8 @@
 			case 'Z': {
 				Point pt = GetTileBelowCursor();
 				if (pt.x != -1) {
+					if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w);
 					ScrollMainWindowTo(pt.x, pt.y);
-					if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w);
 				}
 				break;
 			}
@@ -2374,8 +2038,8 @@
 
 	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
 
-	SetWindowWidgetDisabledState(w, 0, _networking && !_network_server); // if not server, disable pause button
-	SetWindowWidgetDisabledState(w, 1, _networking); // if networking, disable fast-forward button
+	w->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
+	w->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
 
 	/* 'w' is for sure a WC_MAIN_TOOLBAR */
 	PositionMainToolbar(w);
@@ -2387,7 +2051,7 @@
 	w = AllocateWindowDesc(&_main_status_desc);
 	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
 
-	WP(w,def_d).data_1 = -1280;
+	WP(w, def_d).data_1 = -1280;
 }
 
 void GameSizeChanged()
@@ -2409,3 +2073,4 @@
 
 
 
+
--- a/src/map.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/map.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,13 +3,12 @@
 /** @file map.cpp */
 
 #include "stdafx.h"
-#include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "macros.h"
-#include "map.h"
-#include "direction.h"
-#include "helpers.hpp"
+#include "direction_func.h"
+#include "core/bitmath_func.hpp"
+#include "core/alloc_func.hpp"
+#include "core/math_func.hpp"
+#include "map_func.h"
 
 #if defined(_MSC_VER) && _MSC_VER >= 1400 /* VStudio 2005 is stupid! */
 /* Why the hell is that not in all MSVC headers?? */
@@ -52,14 +51,13 @@
 	free(_m);
 	free(_me);
 
-	_m = CallocT<Tile>(_map_size);
-	_me = CallocT<TileExtended>(_map_size);
-
 	/* XXX @todo handle memory shortage more gracefully
+	 * CallocT does the out-of-memory check
 	 * Maybe some attemps could be made to try with smaller maps down to 64x64
 	 * Maybe check for available memory before doing the calls, after all, we know how big
 	 * the map is */
-	if ((_m == NULL) || (_me == NULL)) error("Failed to allocate memory for the map");
+	_m = CallocT<Tile>(_map_size);
+	_me = CallocT<TileExtended>(_map_size);
 }
 
 
@@ -184,8 +182,8 @@
  */
 uint DistanceManhattan(TileIndex t0, TileIndex t1)
 {
-	const uint dx = delta(TileX(t0), TileX(t1));
-	const uint dy = delta(TileY(t0), TileY(t1));
+	const uint dx = Delta(TileX(t0), TileX(t1));
+	const uint dy = Delta(TileY(t0), TileY(t1));
 	return dx + dy;
 }
 
@@ -216,8 +214,8 @@
  */
 uint DistanceMax(TileIndex t0, TileIndex t1)
 {
-	const uint dx = delta(TileX(t0), TileX(t1));
-	const uint dy = delta(TileY(t0), TileY(t1));
+	const uint dx = Delta(TileX(t0), TileX(t1));
+	const uint dy = Delta(TileY(t0), TileY(t1));
 	return max(dx, dy);
 }
 
@@ -232,8 +230,8 @@
  */
 uint DistanceMaxPlusManhattan(TileIndex t0, TileIndex t1)
 {
-	const uint dx = delta(TileX(t0), TileX(t1));
-	const uint dy = delta(TileY(t0), TileY(t1));
+	const uint dx = Delta(TileX(t0), TileX(t1));
+	const uint dy = Delta(TileY(t0), TileY(t1));
 	return dx > dy ? 2 * dx + dy : 2 * dy + dx;
 }
 
--- a/src/map.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,428 +0,0 @@
-/* $Id$ */
-
-/** @file map.h */
-
-#ifndef MAP_H
-#define MAP_H
-
-#include "stdafx.h"
-#include "direction.h"
-
-extern uint _map_tile_mask;
-
-/**
- * 'Wraps' the given tile to it is within the map. It does
- * this by masking the 'high' bits of.
- * @param x the tile to 'wrap'
- */
-
-#define TILE_MASK(x) ((x) & _map_tile_mask)
-/**
- * Asserts when the tile is outside of the map.
- * @param x the tile to check
- */
-#define TILE_ASSERT(x) assert(TILE_MASK(x) == (x));
-
-/**
- * Data that is stored per tile. Also used TileExtended for this.
- * Look at docs/landscape.html for the exact meaning of the members.
- */
-struct Tile {
-	byte type_height; ///< The type (bits 4..7) and height of the northern corner
-	byte m1;   ///< Primarily used for ownership information
-	uint16 m2; ///< Primarily used for indices to towns, industries and stations
-	byte m3;   ///< General purpose
-	byte m4;   ///< General purpose
-	byte m5;   ///< General purpose
-	byte m6;   ///< Primarily used for bridges and rainforest/desert
-};
-
-/**
- * Data that is stored per tile. Also used Tile for this.
- * Look at docs/landscape.html for the exact meaning of the members.
- */
-struct TileExtended {
-	byte m7; ///< Primarily used for newgrf support
-};
-
-/**
- * Pointer to the tile-array.
- *
- * This variable points to the tile-array which contains the tiles of
- * the map.
- */
-extern Tile *_m;
-
-/**
- * Pointer to the extended tile-array.
- *
- * This variable points to the extended tile-array which contains the tiles
- * of the map.
- */
-extern TileExtended *_me;
-
-/**
- * Allocate a new map with the given size.
- */
-void AllocateMap(uint size_x, uint size_y);
-
-/**
- * Logarithm of the map size along the X side.
- * @note try to avoid using this one
- * @return 2^"return value" == MapSizeX()
- */
-static inline uint MapLogX()
-{
-	extern uint _map_log_x;
-	return _map_log_x;
-}
-
-/**
- * Get the size of the map along the X
- * @return the number of tiles along the X of the map
- */
-static inline uint MapSizeX()
-{
-	extern uint _map_size_x;
-	return _map_size_x;
-}
-
-/**
- * Get the size of the map along the Y
- * @return the number of tiles along the Y of the map
- */
-static inline uint MapSizeY()
-{
-	extern uint _map_size_y;
-	return _map_size_y;
-}
-
-/**
- * Get the size of the map
- * @return the number of tiles of the map
- */
-static inline uint MapSize()
-{
-	extern uint _map_size;
-	return _map_size;
-}
-
-/**
- * Gets the maximum X coordinate within the map, including MP_VOID
- * @return the maximum X coordinate
- */
-static inline uint MapMaxX()
-{
-	return MapSizeX() - 1;
-}
-
-/**
- * Gets the maximum X coordinate within the map, including MP_VOID
- * @return the maximum X coordinate
- */
-static inline uint MapMaxY()
-{
-	return MapSizeY() - 1;
-}
-
-/**
- * Scales relative to the number of tiles.
- */
-uint ScaleByMapSize(uint);
-
-/**
- * Scale relative to the circumference of the map.
- */
-uint ScaleByMapSize1D(uint);
-
-/**
- * The index/ID of a Tile.
- */
-typedef uint32 TileIndex;
-
-/**
- * An offset value between to tiles.
- *
- * This value is used fro the difference between
- * to tiles. It can be added to a tileindex to get
- * the resulting tileindex of the start tile applied
- * with this saved difference.
- *
- * @see TileDiffXY(int, int)
- */
-typedef int32 TileIndexDiff;
-
-/**
- * Returns the TileIndex of a coordinate.
- *
- * @param x The x coordinate of the tile
- * @param y The y coordinate of the tile
- * @return The TileIndex calculated by the coordinate
- */
-static inline TileIndex TileXY(uint x, uint y)
-{
-	return (y * MapSizeX()) + x;
-}
-
-/**
- * Calculates an offset for the given coordinate(-offset).
- *
- * This function calculate an offset value which can be added to an
- * #TileIndex. The coordinates can be negative.
- *
- * @param x The offset in x direction
- * @param y The offset in y direction
- * @return The resulting offset value of the given coordinate
- * @see ToTileIndexDiff(TileIndexDiffC)
- */
-static inline TileIndexDiff TileDiffXY(int x, int y)
-{
-	/* Multiplication gives much better optimization on MSVC than shifting.
-	 * 0 << shift isn't optimized to 0 properly.
-	 * Typically x and y are constants, and then this doesn't result
-	 * in any actual multiplication in the assembly code.. */
-	return (y * MapSizeX()) + x;
-}
-
-static inline TileIndex TileVirtXY(uint x, uint y)
-{
-	return (y >> 4 << MapLogX()) + (x >> 4);
-}
-
-
-enum {
-	INVALID_TILE = (TileIndex)-1 ///< The very nice invalid tile marker
-};
-
-enum {
-	TILE_SIZE   = 16,   ///< Tiles are 16x16 "units" in size
-	TILE_PIXELS = 32,   ///< a tile is 32x32 pixels
-	TILE_HEIGHT =  8,   ///< The standard height-difference between tiles on two levels is 8 (z-diff 8)
-};
-
-
-/**
- * Get the X component of a tile
- * @param tile the tile to get the X component of
- * @return the X component
- */
-static inline uint TileX(TileIndex tile)
-{
-	return tile & MapMaxX();
-}
-
-/**
- * Get the Y component of a tile
- * @param tile the tile to get the Y component of
- * @return the Y component
- */
-static inline uint TileY(TileIndex tile)
-{
-	return tile >> MapLogX();
-}
-
-/**
- * A pair-construct of a TileIndexDiff.
- *
- * This can be used to save the difference between to
- * tiles as a pair of x and y value.
- */
-struct TileIndexDiffC {
-	int16 x;        ///< The x value of the coordinate
-	int16 y;        ///< The y value of the coordinate
-};
-
-/**
- * Return the offset between to tiles from a TileIndexDiffC struct.
- *
- * This function works like #TileDiffXY(int, int) and returns the
- * difference between two tiles.
- *
- * @param tidc The coordinate of the offset as TileIndexDiffC
- * @return The difference between two tiles.
- * @see TileDiffXY(int, int)
- */
-static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
-{
-	return (tidc.y << MapLogX()) + tidc.x;
-}
-
-
-#ifndef _DEBUG
-        /**
-         * Adds to tiles together.
-         *
-         * @param x One tile
-         * @param y An other tile to add
-         * @return The resulting tile(index)
-         */
-	#define TILE_ADD(x,y) ((x) + (y))
-#else
-	extern TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
-		const char *exp, const char *file, int line);
-	#define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__))
-#endif
-
-/**
- * Adds a given offset to a tile.
- *
- * @param tile The tile to add an offset on it
- * @param x The x offset to add to the tile
- * @param y The y offset to add to the tile
- */
-#define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y))
-
-/**
- * Adds an offset to a tile and check if we are still on the map.
- */
-uint TileAddWrap(TileIndex tile, int addx, int addy);
-
-/**
- * Returns the TileIndexDiffC offset from a DiagDirection.
- *
- * @param dir The given direction
- * @return The offset as TileIndexDiffC value
- */
-static inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
-{
-	extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END];
-
-	assert(IsValidDiagDirection(dir));
-	return _tileoffs_by_diagdir[dir];
-}
-/**
- * Add a TileIndexDiffC to a TileIndex and returns the new one.
- *
- * Returns tile + the diff given in diff. If the result tile would end up
- * outside of the map, INVALID_TILE is returned instead.
- *
- * @param tile The base tile to add the offset on
- * @param diff The offset to add on the tile
- * @return The resulting TileIndex
- */
-static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
-{
-	int x = TileX(tile) + diff.x;
-	int y = TileY(tile) + diff.y;
-	if (x < 0 || y < 0 || x > (int)MapMaxX() || y > (int)MapMaxY())
-		return INVALID_TILE;
-	else
-		return TileXY(x, y);
-}
-
-/**
- * Returns the diff between two tiles
- *
- * @param tile_a from tile
- * @param tile_b to tile
- * @return the difference between tila_a and tile_b
- */
-static inline TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b)
-{
-	TileIndexDiffC difference;
-
-	difference.x = TileX(tile_a) - TileX(tile_b);
-	difference.y = TileY(tile_a) - TileY(tile_b);
-
-	return difference;
-}
-
-/* Functions to calculate distances */
-uint DistanceManhattan(TileIndex, TileIndex); ///< also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)
-uint DistanceSquare(TileIndex, TileIndex); ///< euclidian- or L2-Norm squared
-uint DistanceMax(TileIndex, TileIndex); ///< also known as L-Infinity-Norm
-uint DistanceMaxPlusManhattan(TileIndex, TileIndex); ///< Max + Manhattan
-uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map
-
-/**
- * Starts a loop which iterates to a square of tiles
- *
- * This macro starts 2 nested loops which iterates over a square of tiles.
- *
- * @param var The name of the variable which contains the current tile
- * @param w The width (x-width) of the square
- * @param h The heigth (y-width) of the square
- * @param tile The start tile of the square
- */
-#define BEGIN_TILE_LOOP(var, w, h, tile)                      \
-	{                                                        \
-		int h_cur = h;                                         \
-		uint var = tile;                                       \
-		do {                                                   \
-			int w_cur = w;                                       \
-			do {
-/**
- * Ends the square-loop used before
- *
- * @see BEGIN_TILE_LOOP
- */
-#define END_TILE_LOOP(var, w, h, tile)                        \
-			} while (++var, --w_cur != 0);                       \
-		} while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \
-	}
-/**
- * Convert a DiagDirection to a TileIndexDiff
- *
- * @param dir The DiagDirection
- * @return The resulting TileIndexDiff
- * @see TileIndexDiffCByDiagDir
- */
-static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
-{
-	extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END];
-
-	assert(IsValidDiagDirection(dir));
-	return ToTileIndexDiff(_tileoffs_by_diagdir[dir]);
-}
-
-/**
- * Convert a Direction to a TileIndexDiff.
- *
- * @param dir The direction to convert from
- * @return The resulting TileIndexDiff
- */
-static inline TileIndexDiff TileOffsByDir(Direction dir)
-{
-	extern const TileIndexDiffC _tileoffs_by_dir[DIR_END];
-
-	assert(IsValidDirection(dir));
-	return ToTileIndexDiff(_tileoffs_by_dir[dir]);
-}
-
-/**
- * Adds a DiagDir to a tile.
- *
- * @param tile The current tile
- * @param dir The direction in which we want to step
- * @return the moved tile
- */
-static inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
-{
-	return TILE_ADD(tile, TileOffsByDiagDir(dir));
-}
-
-/**
- * A callback function type for searching tiles.
- *
- * @param tile The tile to test
- * @param data additional data for the callback function to use
- * @return A boolean value, depend on the definition of the function.
- */
-typedef bool TestTileOnSearchProc(TileIndex tile, uint32 data);
-
-/**
- * Searches for some cirumstances of a tile around a given tile with a helper function.
- */
-bool CircularTileSearch(TileIndex tile, uint size, TestTileOnSearchProc proc, uint32 data);
-
-/** Approximation of the length of a straight track, relative to a diagonal
- * track (ie the size of a tile side).
- *
- * #defined instead of const so it can
- * stay integer. (no runtime float operations) Is this needed?
- * Watch out! There are _no_ brackets around here, to prevent intermediate
- * rounding! Be careful when using this!
- * This value should be sqrt(2)/2 ~ 0.7071 */
-#define STRAIGHT_TRACK_LENGTH 7071/10000
-
-#endif /* MAP_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/map_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,389 @@
+/* $Id$ */
+
+/** @file map.h */
+
+#ifndef MAP_FUNC_H
+#define MAP_FUNC_H
+
+#include "tile_type.h"
+#include "map_type.h"
+#include "direction_func.h"
+
+extern uint _map_tile_mask;
+
+/**
+ * 'Wraps' the given tile to it is within the map. It does
+ * this by masking the 'high' bits of.
+ * @param x the tile to 'wrap'
+ */
+
+#define TILE_MASK(x) ((x) & _map_tile_mask)
+/**
+ * Asserts when the tile is outside of the map.
+ * @param x the tile to check
+ */
+#define TILE_ASSERT(x) assert(TILE_MASK(x) == (x));
+
+/**
+ * Pointer to the tile-array.
+ *
+ * This variable points to the tile-array which contains the tiles of
+ * the map.
+ */
+extern Tile *_m;
+
+/**
+ * Pointer to the extended tile-array.
+ *
+ * This variable points to the extended tile-array which contains the tiles
+ * of the map.
+ */
+extern TileExtended *_me;
+
+/**
+ * Allocate a new map with the given size.
+ */
+void AllocateMap(uint size_x, uint size_y);
+
+/**
+ * Logarithm of the map size along the X side.
+ * @note try to avoid using this one
+ * @return 2^"return value" == MapSizeX()
+ */
+static inline uint MapLogX()
+{
+	extern uint _map_log_x;
+	return _map_log_x;
+}
+
+/**
+ * Get the size of the map along the X
+ * @return the number of tiles along the X of the map
+ */
+static inline uint MapSizeX()
+{
+	extern uint _map_size_x;
+	return _map_size_x;
+}
+
+/**
+ * Get the size of the map along the Y
+ * @return the number of tiles along the Y of the map
+ */
+static inline uint MapSizeY()
+{
+	extern uint _map_size_y;
+	return _map_size_y;
+}
+
+/**
+ * Get the size of the map
+ * @return the number of tiles of the map
+ */
+static inline uint MapSize()
+{
+	extern uint _map_size;
+	return _map_size;
+}
+
+/**
+ * Gets the maximum X coordinate within the map, including MP_VOID
+ * @return the maximum X coordinate
+ */
+static inline uint MapMaxX()
+{
+	return MapSizeX() - 1;
+}
+
+/**
+ * Gets the maximum X coordinate within the map, including MP_VOID
+ * @return the maximum X coordinate
+ */
+static inline uint MapMaxY()
+{
+	return MapSizeY() - 1;
+}
+
+/**
+ * Scales relative to the number of tiles.
+ */
+uint ScaleByMapSize(uint);
+
+/**
+ * Scale relative to the circumference of the map.
+ */
+uint ScaleByMapSize1D(uint);
+
+/**
+ * An offset value between to tiles.
+ *
+ * This value is used fro the difference between
+ * to tiles. It can be added to a tileindex to get
+ * the resulting tileindex of the start tile applied
+ * with this saved difference.
+ *
+ * @see TileDiffXY(int, int)
+ */
+typedef int32 TileIndexDiff;
+
+/**
+ * Returns the TileIndex of a coordinate.
+ *
+ * @param x The x coordinate of the tile
+ * @param y The y coordinate of the tile
+ * @return The TileIndex calculated by the coordinate
+ */
+static inline TileIndex TileXY(uint x, uint y)
+{
+	return (y * MapSizeX()) + x;
+}
+
+/**
+ * Calculates an offset for the given coordinate(-offset).
+ *
+ * This function calculate an offset value which can be added to an
+ * #TileIndex. The coordinates can be negative.
+ *
+ * @param x The offset in x direction
+ * @param y The offset in y direction
+ * @return The resulting offset value of the given coordinate
+ * @see ToTileIndexDiff(TileIndexDiffC)
+ */
+static inline TileIndexDiff TileDiffXY(int x, int y)
+{
+	/* Multiplication gives much better optimization on MSVC than shifting.
+	 * 0 << shift isn't optimized to 0 properly.
+	 * Typically x and y are constants, and then this doesn't result
+	 * in any actual multiplication in the assembly code.. */
+	return (y * MapSizeX()) + x;
+}
+
+static inline TileIndex TileVirtXY(uint x, uint y)
+{
+	return (y >> 4 << MapLogX()) + (x >> 4);
+}
+
+
+/**
+ * Get the X component of a tile
+ * @param tile the tile to get the X component of
+ * @return the X component
+ */
+static inline uint TileX(TileIndex tile)
+{
+	return tile & MapMaxX();
+}
+
+/**
+ * Get the Y component of a tile
+ * @param tile the tile to get the Y component of
+ * @return the Y component
+ */
+static inline uint TileY(TileIndex tile)
+{
+	return tile >> MapLogX();
+}
+
+/**
+ * Return the offset between to tiles from a TileIndexDiffC struct.
+ *
+ * This function works like #TileDiffXY(int, int) and returns the
+ * difference between two tiles.
+ *
+ * @param tidc The coordinate of the offset as TileIndexDiffC
+ * @return The difference between two tiles.
+ * @see TileDiffXY(int, int)
+ */
+static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
+{
+	return (tidc.y << MapLogX()) + tidc.x;
+}
+
+
+#ifndef _DEBUG
+	/**
+	 * Adds to tiles together.
+	 *
+	 * @param x One tile
+	 * @param y An other tile to add
+	 * @return The resulting tile(index)
+	 */
+	#define TILE_ADD(x,y) ((x) + (y))
+#else
+	extern TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
+		const char *exp, const char *file, int line);
+	#define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__))
+#endif
+
+/**
+ * Adds a given offset to a tile.
+ *
+ * @param tile The tile to add an offset on it
+ * @param x The x offset to add to the tile
+ * @param y The y offset to add to the tile
+ */
+#define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y))
+
+/**
+ * Adds an offset to a tile and check if we are still on the map.
+ */
+uint TileAddWrap(TileIndex tile, int addx, int addy);
+
+/**
+ * Returns the TileIndexDiffC offset from a DiagDirection.
+ *
+ * @param dir The given direction
+ * @return The offset as TileIndexDiffC value
+ */
+static inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
+{
+	extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END];
+
+	assert(IsValidDiagDirection(dir));
+	return _tileoffs_by_diagdir[dir];
+}
+
+/**
+ * Add a TileIndexDiffC to a TileIndex and returns the new one.
+ *
+ * Returns tile + the diff given in diff. If the result tile would end up
+ * outside of the map, INVALID_TILE is returned instead.
+ *
+ * @param tile The base tile to add the offset on
+ * @param diff The offset to add on the tile
+ * @return The resulting TileIndex
+ */
+static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
+{
+	int x = TileX(tile) + diff.x;
+	int y = TileY(tile) + diff.y;
+	if (x < 0 || y < 0 || x > (int)MapMaxX() || y > (int)MapMaxY())
+		return INVALID_TILE;
+	else
+		return TileXY(x, y);
+}
+
+/**
+ * Returns the diff between two tiles
+ *
+ * @param tile_a from tile
+ * @param tile_b to tile
+ * @return the difference between tila_a and tile_b
+ */
+static inline TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b)
+{
+	TileIndexDiffC difference;
+
+	difference.x = TileX(tile_a) - TileX(tile_b);
+	difference.y = TileY(tile_a) - TileY(tile_b);
+
+	return difference;
+}
+
+/* Functions to calculate distances */
+uint DistanceManhattan(TileIndex, TileIndex); ///< also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)
+uint DistanceSquare(TileIndex, TileIndex); ///< euclidian- or L2-Norm squared
+uint DistanceMax(TileIndex, TileIndex); ///< also known as L-Infinity-Norm
+uint DistanceMaxPlusManhattan(TileIndex, TileIndex); ///< Max + Manhattan
+uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map
+
+/**
+ * Starts a loop which iterates to a square of tiles
+ *
+ * This macro starts 2 nested loops which iterates over a square of tiles.
+ *
+ * @param var The name of the variable which contains the current tile
+ * @param w The width (x-width) of the square
+ * @param h The heigth (y-width) of the square
+ * @param tile The start tile of the square
+ */
+#define BEGIN_TILE_LOOP(var, w, h, tile)                      \
+	{                                                        \
+		int h_cur = h;                                         \
+		uint var = tile;                                       \
+		do {                                                   \
+			int w_cur = w;                                       \
+			do {
+/**
+ * Ends the square-loop used before
+ *
+ * @see BEGIN_TILE_LOOP
+ */
+#define END_TILE_LOOP(var, w, h, tile)                        \
+			} while (++var, --w_cur != 0);                       \
+		} while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \
+	}
+/**
+ * Convert a DiagDirection to a TileIndexDiff
+ *
+ * @param dir The DiagDirection
+ * @return The resulting TileIndexDiff
+ * @see TileIndexDiffCByDiagDir
+ */
+static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
+{
+	extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END];
+
+	assert(IsValidDiagDirection(dir));
+	return ToTileIndexDiff(_tileoffs_by_diagdir[dir]);
+}
+
+/**
+ * Convert a Direction to a TileIndexDiff.
+ *
+ * @param dir The direction to convert from
+ * @return The resulting TileIndexDiff
+ */
+static inline TileIndexDiff TileOffsByDir(Direction dir)
+{
+	extern const TileIndexDiffC _tileoffs_by_dir[DIR_END];
+
+	assert(IsValidDirection(dir));
+	return ToTileIndexDiff(_tileoffs_by_dir[dir]);
+}
+
+/**
+ * Adds a DiagDir to a tile.
+ *
+ * @param tile The current tile
+ * @param dir The direction in which we want to step
+ * @return the moved tile
+ */
+static inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
+{
+	return TILE_ADD(tile, TileOffsByDiagDir(dir));
+}
+
+/**
+ * A callback function type for searching tiles.
+ *
+ * @param tile The tile to test
+ * @param data additional data for the callback function to use
+ * @return A boolean value, depend on the definition of the function.
+ */
+typedef bool TestTileOnSearchProc(TileIndex tile, uint32 data);
+
+/**
+ * Searches for some cirumstances of a tile around a given tile with a helper function.
+ */
+bool CircularTileSearch(TileIndex tile, uint size, TestTileOnSearchProc proc, uint32 data);
+
+/**
+ * Get a random tile out of a given seed.
+ * @param r the random 'seed'
+ * @return a valid tile
+ */
+static inline TileIndex RandomTileSeed(uint32 r)
+{
+	return TILE_MASK(r);
+}
+
+/**
+ * Get a valid random tile.
+ * @note a define so 'random' gets inserted in the place where it is actually
+ *       called, thus making the random traces more explicit.
+ * @return a valid tile
+ */
+#define RandomTile() RandomTileSeed(Random())
+
+#endif /* MAP_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/map_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,65 @@
+/* $Id$ */
+
+/** @file map_type.h Types related to maps. */
+
+#ifndef MAP_TYPE_H
+#define MAP_TYPE_H
+
+/**
+ * Data that is stored per tile. Also used TileExtended for this.
+ * Look at docs/landscape.html for the exact meaning of the members.
+ */
+struct Tile {
+	byte   type_height; ///< The type (bits 4..7) and height of the northern corner
+	byte   m1;          ///< Primarily used for ownership information
+	uint16 m2;          ///< Primarily used for indices to towns, industries and stations
+	byte   m3;          ///< General purpose
+	byte   m4;          ///< General purpose
+	byte   m5;          ///< General purpose
+	byte   m6;          ///< Primarily used for bridges and rainforest/desert
+};
+
+/**
+ * Data that is stored per tile. Also used Tile for this.
+ * Look at docs/landscape.html for the exact meaning of the members.
+ */
+struct TileExtended {
+	byte m7; ///< Primarily used for newgrf support
+};
+
+/**
+ * An offset value between to tiles.
+ *
+ * This value is used fro the difference between
+ * to tiles. It can be added to a tileindex to get
+ * the resulting tileindex of the start tile applied
+ * with this saved difference.
+ *
+ * @see TileDiffXY(int, int)
+ */
+typedef int32 TileIndexDiff;
+
+/**
+ * A pair-construct of a TileIndexDiff.
+ *
+ * This can be used to save the difference between to
+ * tiles as a pair of x and y value.
+ */
+struct TileIndexDiffC {
+	int16 x;        ///< The x value of the coordinate
+	int16 y;        ///< The y value of the coordinate
+};
+
+/**
+ * Approximation of the length of a straight track, relative to a diagonal
+ * track (ie the size of a tile side).
+ *
+ * #defined instead of const so it can
+ * stay integer. (no runtime float operations) Is this needed?
+ * Watch out! There are _no_ brackets around here, to prevent intermediate
+ * rounding! Be careful when using this!
+ * This value should be sqrt(2)/2 ~ 0.7071
+ */
+#define STRAIGHT_TRACK_LENGTH 7071/10000
+
+#endif /* MAP_TYPE_H */
--- a/src/md5.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/md5.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -31,7 +31,7 @@
 
   This code implements the MD5 Algorithm defined in RFC 1321, whose
   text is available at
-	http://www.ietf.org/rfc/rfc1321.txt
+  http://www.ietf.org/rfc/rfc1321.txt
   The code is derived from the text of the RFC, including the test suite
   (section A.5) but excluding the rest of Appendix A.  It does not include
   any code or documentation that is identified in the RFC as being
@@ -41,32 +41,27 @@
   <ghost@aladdin.com>.  Other authors are noted in the change history
   that follows (in reverse chronological order):
 
+  2007-12-24 Changed to C++ and adapted to OpenTTD source
   2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order
-	either statically or dynamically; added missing #include <string.h>
-	in library.
+             either statically or dynamically; added missing #include <string.h>
+             in library.
   2002-03-11 lpd Corrected argument list for main(), and added int return
-	type, in test program and T value program.
+             type, in test program and T value program.
   2002-02-21 lpd Added missing #include <stdio.h> in test program.
   2000-07-03 lpd Patched to eliminate warnings about "constant is
-	unsigned in ANSI C, signed in traditional"; made test program
-	self-checking.
+             unsigned in ANSI C, signed in traditional"; made test program
+             self-checking.
   1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
   1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
   1999-05-03 lpd Original version.
  */
 
 #include "stdafx.h"
+#include "core/bitmath_func.hpp"
+#include "core/endian_func.hpp"
 #include "md5.h"
-#include <string.h>
 
-#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
-#if defined(TTD_BIG_ENDIAN)
-#  define BYTE_ORDER 1
-#else
-#  define BYTE_ORDER -1
-#endif
-
-#define T_MASK ((md5_word_t)~0)
+#define T_MASK ((uint32)~0)
 #define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
 #define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
 #define T3    0x242070db
@@ -132,255 +127,197 @@
 #define T63    0x2ad7d2bb
 #define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
 
-
-static void
-md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
+static inline void Md5Set1(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti)
 {
-    md5_word_t
-	a = pms->abcd[0], b = pms->abcd[1],
-	c = pms->abcd[2], d = pms->abcd[3];
-    md5_word_t t;
-#if BYTE_ORDER > 0
-    /* Define storage only for big-endian CPUs. */
-    md5_word_t X[16];
-#else
-    /* Define storage for little-endian or both types of CPUs. */
-    md5_word_t xbuf[16];
-    const md5_word_t *X;
-#endif
-
-    {
-#if BYTE_ORDER == 0
-	/*
-	 * Determine dynamically whether this is a big-endian or
-	 * little-endian machine, since we can use a more efficient
-	 * algorithm on the latter.
-	 */
-	static const int w = 1;
-
-	if (*((const md5_byte_t *)&w)) /* dynamic little-endian */
-#endif
-#if BYTE_ORDER <= 0 /* little-endian */
-	{
-	    /*
-	     * On little-endian machines, we can process properly aligned
-	     * data without copying it.
-	     */
-	    if (!((data - (const md5_byte_t *)0) & 3)) {
-		/* data are properly aligned */
-		X = (const md5_word_t *)data;
-	    } else {
-		/* not aligned */
-		memcpy(xbuf, data, 64);
-		X = xbuf;
-	    }
-	}
-#endif
-#if BYTE_ORDER == 0
-	else /* dynamic big-endian */
-#endif
-#if BYTE_ORDER >= 0 /* big-endian */
-	{
-	    /*
-	     * On big-endian machines, we must arrange the bytes in the
-	     * right order.
-	     */
-	    const md5_byte_t *xp = data;
-	    int i;
-
-#  if BYTE_ORDER == 0
-	    X = xbuf; /* (dynamic only) */
-#  else
-#    define xbuf X /* (static only) */
-#  endif
-	    for (i = 0; i < 16; ++i, xp += 4)
-		xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
-	}
-#endif
-    }
-
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
-
-    /* Round 1. */
-    /* Let [abcd k s i] denote the operation
-       a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
-#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
-#define SET(a, b, c, d, k, s, Ti)\
-  t = a + F(b,c,d) + X[k] + Ti;\
-  a = ROTATE_LEFT(t, s) + b
-    /* Do the following 16 operations. */
-    SET(a, b, c, d,  0,  7,  T1);
-    SET(d, a, b, c,  1, 12,  T2);
-    SET(c, d, a, b,  2, 17,  T3);
-    SET(b, c, d, a,  3, 22,  T4);
-    SET(a, b, c, d,  4,  7,  T5);
-    SET(d, a, b, c,  5, 12,  T6);
-    SET(c, d, a, b,  6, 17,  T7);
-    SET(b, c, d, a,  7, 22,  T8);
-    SET(a, b, c, d,  8,  7,  T9);
-    SET(d, a, b, c,  9, 12, T10);
-    SET(c, d, a, b, 10, 17, T11);
-    SET(b, c, d, a, 11, 22, T12);
-    SET(a, b, c, d, 12,  7, T13);
-    SET(d, a, b, c, 13, 12, T14);
-    SET(c, d, a, b, 14, 17, T15);
-    SET(b, c, d, a, 15, 22, T16);
-#undef SET
-
-     /* Round 2. */
-     /* Let [abcd k s i] denote the operation
-          a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
-#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
-#define SET(a, b, c, d, k, s, Ti)\
-  t = a + G(b,c,d) + X[k] + Ti;\
-  a = ROTATE_LEFT(t, s) + b
-     /* Do the following 16 operations. */
-    SET(a, b, c, d,  1,  5, T17);
-    SET(d, a, b, c,  6,  9, T18);
-    SET(c, d, a, b, 11, 14, T19);
-    SET(b, c, d, a,  0, 20, T20);
-    SET(a, b, c, d,  5,  5, T21);
-    SET(d, a, b, c, 10,  9, T22);
-    SET(c, d, a, b, 15, 14, T23);
-    SET(b, c, d, a,  4, 20, T24);
-    SET(a, b, c, d,  9,  5, T25);
-    SET(d, a, b, c, 14,  9, T26);
-    SET(c, d, a, b,  3, 14, T27);
-    SET(b, c, d, a,  8, 20, T28);
-    SET(a, b, c, d, 13,  5, T29);
-    SET(d, a, b, c,  2,  9, T30);
-    SET(c, d, a, b,  7, 14, T31);
-    SET(b, c, d, a, 12, 20, T32);
-#undef SET
-
-     /* Round 3. */
-     /* Let [abcd k s t] denote the operation
-          a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define SET(a, b, c, d, k, s, Ti)\
-  t = a + H(b,c,d) + X[k] + Ti;\
-  a = ROTATE_LEFT(t, s) + b
-     /* Do the following 16 operations. */
-    SET(a, b, c, d,  5,  4, T33);
-    SET(d, a, b, c,  8, 11, T34);
-    SET(c, d, a, b, 11, 16, T35);
-    SET(b, c, d, a, 14, 23, T36);
-    SET(a, b, c, d,  1,  4, T37);
-    SET(d, a, b, c,  4, 11, T38);
-    SET(c, d, a, b,  7, 16, T39);
-    SET(b, c, d, a, 10, 23, T40);
-    SET(a, b, c, d, 13,  4, T41);
-    SET(d, a, b, c,  0, 11, T42);
-    SET(c, d, a, b,  3, 16, T43);
-    SET(b, c, d, a,  6, 23, T44);
-    SET(a, b, c, d,  9,  4, T45);
-    SET(d, a, b, c, 12, 11, T46);
-    SET(c, d, a, b, 15, 16, T47);
-    SET(b, c, d, a,  2, 23, T48);
-#undef SET
-
-     /* Round 4. */
-     /* Let [abcd k s t] denote the operation
-          a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
-#define I(x, y, z) ((y) ^ ((x) | ~(z)))
-#define SET(a, b, c, d, k, s, Ti)\
-  t = a + I(b,c,d) + X[k] + Ti;\
-  a = ROTATE_LEFT(t, s) + b
-     /* Do the following 16 operations. */
-    SET(a, b, c, d,  0,  6, T49);
-    SET(d, a, b, c,  7, 10, T50);
-    SET(c, d, a, b, 14, 15, T51);
-    SET(b, c, d, a,  5, 21, T52);
-    SET(a, b, c, d, 12,  6, T53);
-    SET(d, a, b, c,  3, 10, T54);
-    SET(c, d, a, b, 10, 15, T55);
-    SET(b, c, d, a,  1, 21, T56);
-    SET(a, b, c, d,  8,  6, T57);
-    SET(d, a, b, c, 15, 10, T58);
-    SET(c, d, a, b,  6, 15, T59);
-    SET(b, c, d, a, 13, 21, T60);
-    SET(a, b, c, d,  4,  6, T61);
-    SET(d, a, b, c, 11, 10, T62);
-    SET(c, d, a, b,  2, 15, T63);
-    SET(b, c, d, a,  9, 21, T64);
-#undef SET
-
-     /* Then perform the following additions. (That is increment each
-        of the four registers by the value it had before this block
-        was started.) */
-    pms->abcd[0] += a;
-    pms->abcd[1] += b;
-    pms->abcd[2] += c;
-    pms->abcd[3] += d;
+	uint32 t = (*b & *c) | (~*b & *d);
+	t += *a + X[k] + Ti;
+	*a = ROL(t, s) + *b;
 }
 
-void
-md5_init(md5_state_t *pms)
+static inline void Md5Set2(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti)
 {
-    pms->count[0] = pms->count[1] = 0;
-    pms->abcd[0] = 0x67452301;
-    pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
-    pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
-    pms->abcd[3] = 0x10325476;
+	uint32 t = (*b & *d) | (*c & ~*d);
+	t += *a + X[k] + Ti;
+	*a = ROL(t, s) + *b;
 }
 
-void
-md5_append(md5_state_t *pms, const void *data, size_t nbytes)
-{
-    const md5_byte_t *p = (const md5_byte_t *)data;
-    size_t left = nbytes;
-    size_t offset = (pms->count[0] >> 3) & 63;
-    md5_word_t nbits = (md5_word_t)(nbytes << 3);
-
-    if (nbytes <= 0)
-	return;
-
-    /* Update the message length. */
-    pms->count[1] += (md5_word_t)(nbytes >> 29);
-    pms->count[0] += nbits;
-    if (pms->count[0] < nbits)
-	pms->count[1]++;
 
-    /* Process an initial partial block. */
-    if (offset) {
-	size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
-
-	memcpy(pms->buf + offset, p, copy);
-	if (offset + copy < 64)
-	    return;
-	p += copy;
-	left -= copy;
-	md5_process(pms, pms->buf);
-    }
-
-    /* Process full blocks. */
-    for (; left >= 64; p += 64, left -= 64)
-	md5_process(pms, p);
-
-    /* Process a final partial block. */
-    if (left)
-	memcpy(pms->buf, p, left);
+static inline void Md5Set3(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti)
+{
+	uint32 t = *b ^ *c ^ *d;
+	t += *a + X[k] + Ti;
+	*a = ROL(t, s) + *b;
 }
 
-void
-md5_finish(md5_state_t *pms, md5_byte_t digest[16])
+static inline void Md5Set4(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti)
 {
-    static const md5_byte_t pad[64] = {
-	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-    };
-    md5_byte_t data[8];
-    int i;
+	uint32 t = *c ^ (*b | ~*d);
+	t += *a + X[k] + Ti;
+	*a = ROL(t, s) + *b;
+}
 
-    /* Save the length before padding. */
-    for (i = 0; i < 8; ++i)
-	data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
-    /* Pad to 56 bytes mod 64. */
-    md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
-    /* Append the length. */
-    md5_append(pms, data, 8);
-    for (i = 0; i < 16; ++i)
-	digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+Md5::Md5()
+{
+	count[0] = 0;
+	count[1] = 0;
+	abcd[0] = 0x67452301;
+	abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
+	abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
+	abcd[3] = 0x10325476;
 }
+
+void Md5::Process(const uint8 *data /*[64]*/)
+{
+	uint32 a = this->abcd[0];
+	uint32 b = this->abcd[1];
+	uint32 c = this->abcd[2];
+	uint32 d = this->abcd[3];
+
+	uint32 X[16];
+
+	/* Convert the uint8 data to uint32 LE */
+	uint32 *px = (uint32 *)data;
+	for (uint i = 0; i < 16; i++) {
+		X[i] = TO_LE32(*px);
+		px++;
+	}
+
+	/* Round 1. */
+	Md5Set1(X, &a, &b, &c, &d,  0,  7,  T1);
+	Md5Set1(X, &d, &a, &b, &c,  1, 12,  T2);
+	Md5Set1(X, &c, &d, &a, &b,  2, 17,  T3);
+	Md5Set1(X, &b, &c, &d, &a,  3, 22,  T4);
+	Md5Set1(X, &a, &b, &c, &d,  4,  7,  T5);
+	Md5Set1(X, &d, &a, &b, &c,  5, 12,  T6);
+	Md5Set1(X, &c, &d, &a, &b,  6, 17,  T7);
+	Md5Set1(X, &b, &c, &d, &a,  7, 22,  T8);
+	Md5Set1(X, &a, &b, &c, &d,  8,  7,  T9);
+	Md5Set1(X, &d, &a, &b, &c,  9, 12, T10);
+	Md5Set1(X, &c, &d, &a, &b, 10, 17, T11);
+	Md5Set1(X, &b, &c, &d, &a, 11, 22, T12);
+	Md5Set1(X, &a, &b, &c, &d, 12,  7, T13);
+	Md5Set1(X, &d, &a, &b, &c, 13, 12, T14);
+	Md5Set1(X, &c, &d, &a, &b, 14, 17, T15);
+	Md5Set1(X, &b, &c, &d, &a, 15, 22, T16);
+
+	/* Round 2. */
+	Md5Set2(X, &a, &b, &c, &d,  1,  5, T17);
+	Md5Set2(X, &d, &a, &b, &c,  6,  9, T18);
+	Md5Set2(X, &c, &d, &a, &b, 11, 14, T19);
+	Md5Set2(X, &b, &c, &d, &a,  0, 20, T20);
+	Md5Set2(X, &a, &b, &c, &d,  5,  5, T21);
+	Md5Set2(X, &d, &a, &b, &c, 10,  9, T22);
+	Md5Set2(X, &c, &d, &a, &b, 15, 14, T23);
+	Md5Set2(X, &b, &c, &d, &a,  4, 20, T24);
+	Md5Set2(X, &a, &b, &c, &d,  9,  5, T25);
+	Md5Set2(X, &d, &a, &b, &c, 14,  9, T26);
+	Md5Set2(X, &c, &d, &a, &b,  3, 14, T27);
+	Md5Set2(X, &b, &c, &d, &a,  8, 20, T28);
+	Md5Set2(X, &a, &b, &c, &d, 13,  5, T29);
+	Md5Set2(X, &d, &a, &b, &c,  2,  9, T30);
+	Md5Set2(X, &c, &d, &a, &b,  7, 14, T31);
+	Md5Set2(X, &b, &c, &d, &a, 12, 20, T32);
+
+	/* Round 3. */
+	Md5Set3(X, &a, &b, &c, &d,  5,  4, T33);
+	Md5Set3(X, &d, &a, &b, &c,  8, 11, T34);
+	Md5Set3(X, &c, &d, &a, &b, 11, 16, T35);
+	Md5Set3(X, &b, &c, &d, &a, 14, 23, T36);
+	Md5Set3(X, &a, &b, &c, &d,  1,  4, T37);
+	Md5Set3(X, &d, &a, &b, &c,  4, 11, T38);
+	Md5Set3(X, &c, &d, &a, &b,  7, 16, T39);
+	Md5Set3(X, &b, &c, &d, &a, 10, 23, T40);
+	Md5Set3(X, &a, &b, &c, &d, 13,  4, T41);
+	Md5Set3(X, &d, &a, &b, &c,  0, 11, T42);
+	Md5Set3(X, &c, &d, &a, &b,  3, 16, T43);
+	Md5Set3(X, &b, &c, &d, &a,  6, 23, T44);
+	Md5Set3(X, &a, &b, &c, &d,  9,  4, T45);
+	Md5Set3(X, &d, &a, &b, &c, 12, 11, T46);
+	Md5Set3(X, &c, &d, &a, &b, 15, 16, T47);
+	Md5Set3(X, &b, &c, &d, &a,  2, 23, T48);
+
+	/* Round 4. */
+	Md5Set4(X, &a, &b, &c, &d,  0,  6, T49);
+	Md5Set4(X, &d, &a, &b, &c,  7, 10, T50);
+	Md5Set4(X, &c, &d, &a, &b, 14, 15, T51);
+	Md5Set4(X, &b, &c, &d, &a,  5, 21, T52);
+	Md5Set4(X, &a, &b, &c, &d, 12,  6, T53);
+	Md5Set4(X, &d, &a, &b, &c,  3, 10, T54);
+	Md5Set4(X, &c, &d, &a, &b, 10, 15, T55);
+	Md5Set4(X, &b, &c, &d, &a,  1, 21, T56);
+	Md5Set4(X, &a, &b, &c, &d,  8,  6, T57);
+	Md5Set4(X, &d, &a, &b, &c, 15, 10, T58);
+	Md5Set4(X, &c, &d, &a, &b,  6, 15, T59);
+	Md5Set4(X, &b, &c, &d, &a, 13, 21, T60);
+	Md5Set4(X, &a, &b, &c, &d,  4,  6, T61);
+	Md5Set4(X, &d, &a, &b, &c, 11, 10, T62);
+	Md5Set4(X, &c, &d, &a, &b,  2, 15, T63);
+	Md5Set4(X, &b, &c, &d, &a,  9, 21, T64);
+
+	/* Then perform the following additions. (That is increment each
+	 * of the four registers by the value it had before this block
+	 * was started.) */
+	this->abcd[0] += a;
+	this->abcd[1] += b;
+	this->abcd[2] += c;
+	this->abcd[3] += d;
+}
+
+void Md5::Append(const void *data, const size_t nbytes)
+{
+	const uint8 *p = (const uint8 *)data;
+	size_t left = nbytes;
+	const size_t offset = (this->count[0] >> 3) & 63;
+	const uint32 nbits = (uint32)(nbytes << 3);
+
+	if (nbytes <= 0) return;
+
+	/* Update the message length. */
+	this->count[1] += (uint32)(nbytes >> 29);
+	this->count[0] += nbits;
+
+	if (this->count[0] < nbits) this->count[1]++;
+
+	/* Process an initial partial block. */
+	if (offset) {
+		size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
+
+		memcpy(this->buf + offset, p, copy);
+
+		if (offset + copy < 64) return;
+
+		p += copy;
+		left -= copy;
+		this->Process(this->buf);
+	}
+
+	/* Process full blocks. */
+	for (; left >= 64; p += 64, left -= 64) this->Process(p);
+
+	/* Process a final partial block. */
+	if (left) memcpy(this->buf, p, left);
+}
+
+void Md5::Finish(uint8 digest[16])
+{
+	static const uint8 pad[64] = {
+		0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	};
+	uint8 data[8];
+	uint i;
+
+	/* Save the length before padding. */
+	for (i = 0; i < 8; ++i)
+		data[i] = (uint8)(this->count[i >> 2] >> ((i & 3) << 3));
+
+	/* Pad to 56 bytes mod 64. */
+	this->Append(pad, ((55 - (this->count[0] >> 3)) & 63) + 1);
+	/* Append the length. */
+	this->Append(data, 8);
+
+	for (i = 0; i < 16; ++i)
+		digest[i] = (uint8)(this->abcd[i >> 2] >> ((i & 3) << 3));
+}
--- a/src/md5.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/md5.h	Wed Jan 09 18:11:12 2008 +0000
@@ -31,7 +31,7 @@
 
   This code implements the MD5 Algorithm defined in RFC 1321, whose
   text is available at
-	http://www.ietf.org/rfc/rfc1321.txt
+  http://www.ietf.org/rfc/rfc1321.txt
   The code is derived from the text of the RFC, including the test suite
   (section A.5) but excluding the rest of Appendix A.  It does not include
   any code or documentation that is identified in the RFC as being
@@ -41,13 +41,14 @@
   <ghost@aladdin.com>.  Other authors are noted in the change history
   that follows (in reverse chronological order):
 
+  2007-12-24 Changed to C++ and adapted to OpenTTD source
   2002-04-13 lpd Removed support for non-ANSI compilers; removed
-	references to Ghostscript; clarified derivation from RFC 1321;
-	now handles byte order either statically or dynamically.
+             references to Ghostscript; clarified derivation from RFC 1321;
+             now handles byte order either statically or dynamically.
   1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
   1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
-	added conditionalization for C++ compilation from Martin
-	Purschke <purschke@bnl.gov>.
+             added conditionalization for C++ compilation from Martin
+             Purschke <purschke@bnl.gov>.
   1999-05-03 lpd Original version.
  */
 
@@ -64,23 +65,18 @@
  * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
  */
 
-typedef unsigned char md5_byte_t; /* 8-bit byte */
-typedef unsigned int md5_word_t; /* 32-bit word */
+struct Md5 {
+private:
+	uint32 count[2]; ///< message length in bits, lsw first
+	uint32 abcd[4];  ///< digest buffer
+	uint8 buf[64];   ///< accumulate block
 
-/* Define the state of the MD5 Algorithm. */
-struct md5_state_t {
-    md5_word_t count[2]; /* message length in bits, lsw first */
-    md5_word_t abcd[4];  /* digest buffer */
-    md5_byte_t buf[64];  /* accumulate block */
+	void Process(const uint8 *data);
+
+public:
+	Md5();
+	void Append(const void *data, const size_t nbytes);
+	void Finish(uint8 digest[16]);
 };
 
-/* Initialize the algorithm. */
-void md5_init(md5_state_t *pms);
-
-/* Append a string to the message. */
-void md5_append(md5_state_t *pms, const void *data, size_t nbytes);
-
-/* Finish the message and return the digest. */
-void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
-
 #endif /* MD5_INCLUDED */
--- a/src/misc.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/misc.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,25 +5,30 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
 #include "landscape.h"
 #include "news.h"
 #include "player.h"
-#include "string.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "map.h"
-#include "vehicle.h"
 #include "saveload.h"
 #include "engine.h"
 #include "vehicle_gui.h"
 #include "variables.h"
 #include "ai/ai.h"
 #include "newgrf_house.h"
-#include "date.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"
+#include "map_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "texteff.hpp"
+#include "string_func.h"
+#include "gfx_func.h"
+
 
 char _name_array[512][32];
 
@@ -53,8 +58,6 @@
 {
 	AllocateMap(size_x, size_y);
 
-	AddTypeToEngines(); // make sure all engines have a type
-
 	SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
 
 	_pause_game = 0;
@@ -205,24 +208,6 @@
 }
 
 
-
-int FindFirstBit(uint32 value)
-{
-	/* The macro FIND_FIRST_BIT is better to use when your value is
-	  not more than 128. */
-	byte i = 0;
-
-	if (value == 0) return 0;
-
-	if ((value & 0x0000ffff) == 0) { value >>= 16; i += 16; }
-	if ((value & 0x000000ff) == 0) { value >>= 8;  i += 8;  }
-	if ((value & 0x0000000f) == 0) { value >>= 4;  i += 4;  }
-	if ((value & 0x00000003) == 0) { value >>= 2;  i += 2;  }
-	if ((value & 0x00000001) == 0) { i += 1; }
-
-	return i;
-}
-
 static void Save_NAME()
 {
 	int i;
--- a/src/misc/blob.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/misc/blob.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -2,8 +2,10 @@
 
 /** @file blob.hpp */
 
-#ifndef  BLOB_HPP
-#define  BLOB_HPP
+#ifndef BLOB_HPP
+#define BLOB_HPP
+
+#include "../core/alloc_func.hpp"
 
 /** Type-safe version of memcpy().
  * @param d destination buffer
@@ -298,7 +300,7 @@
 	/** all allocation should happen here */
 	static FORCEINLINE CHdr* RawAlloc(bsize_t num_bytes)
 	{
-		return (CHdr*)malloc(num_bytes);
+		return (CHdr*)MallocT<byte>(num_bytes);
 	}
 
 	/** all deallocations should happen here */
--- a/src/misc/dbg_helpers.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/misc/dbg_helpers.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -2,7 +2,8 @@
 
 /** @file dbg_helpers.cpp */
 #include "../stdafx.h"
-#include "../direction.h"
+#include "../openttd.h"
+#include "../direction_type.h"
 #include "../rail.h"
 #include "../rail_map.h"
 #include "dbg_helpers.h"
--- a/src/misc/fixedsizearray.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/misc/fixedsizearray.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -34,7 +34,7 @@
 	CFixedSizeArrayT()
 	{
 		// allocate block for header + items (don't construct items)
-		m_items = (Titem*)(((int8*)malloc(ThdrSize + Tcapacity * sizeof(Titem))) + ThdrSize);
+		m_items = (Titem*)((MallocT<int8>(ThdrSize + Tcapacity * sizeof(Titem))) + ThdrSize);
 		SizeRef() = 0; // initial number of items
 		RefCnt() = 1; // initial reference counter
 	}
--- a/src/misc_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/misc_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,20 +4,22 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "string.h"
 #include "table/strings.h"
-#include "command.h"
+#include "command_func.h"
+#include "economy_func.h"
 #include "player.h"
-#include "gfx.h"
-#include "window.h"
 #include "gui.h"
-#include "economy.h"
+#include "window_func.h"
+#include "textbuf_gui.h"
 #include "network/network.h"
 #include "variables.h"
 #include "livery.h"
 #include "player_face.h"
-#include "strings.h"
+#include "strings_func.h"
+#include "gfx_func.h"
+#include "functions.h"
+#include "vehicle_func.h"
+#include "string_func.h"
 
 /** Change the player's face.
  * @param tile unused
@@ -160,7 +162,7 @@
 		InvalidatePlayerWindows(p);
 	}
 
-	return CommandCost();
+	return CommandCost(EXPENSES_OTHER);
 }
 
 /** Decrease the loan of your company.
@@ -304,6 +306,17 @@
 	return CommandCost();
 }
 
+/**
+ * In case of an unsafe unpause, we want the
+ * user to confirm that it might crash.
+ * @param w         unused
+ * @param confirmed whether the user confirms his/her action
+ */
+static void AskUnsafeUnpauseCallback(Window *w, bool confirmed)
+{
+	DoCommandP(0, confirmed ? 0 : 1, 0, NULL, CMD_PAUSE);
+}
+
 /** Pause/Unpause the game (server-only).
  * Increase or decrease the pause counter. If the counter is zero,
  * the game is unpaused. A counter is used instead of a boolean value
@@ -316,8 +329,25 @@
 CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	if (flags & DC_EXEC) {
-		_pause_game += (p1 == 1) ? 1 : -1;
-		if (_pause_game == (byte)-1) _pause_game = 0;
+		_pause_game += (p1 == 0) ? -1 : 1;
+
+		switch (_pause_game) {
+			case (byte)-4:
+			case (byte)-1:
+				_pause_game = 0;
+				break;
+			case (byte)-3:
+				ShowQuery(
+					STR_NEWGRF_UNPAUSE_WARNING_TITLE,
+					STR_NEWGRF_UNPAUSE_WARNING,
+					NULL,
+					AskUnsafeUnpauseCallback
+				);
+				break;
+
+			default: break;
+		}
+
 		InvalidateWindow(WC_STATUS_BAR, 0);
 		InvalidateWindow(WC_MAIN_TOOLBAR, 0);
 	}
@@ -337,8 +367,7 @@
 #ifndef _DEBUG
 	if (_networking) return CMD_ERROR;
 #endif
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-	return CommandCost(-(Money)p1);
+	return CommandCost(EXPENSES_OTHER, -(Money)p1);
 }
 
 /** Transfer funds (money) from one player to another.
@@ -355,9 +384,7 @@
 	if (!_patches.give_money) return CMD_ERROR;
 
 	const Player *p = GetPlayer(_current_player);
-	CommandCost amount(min((Money)p1, (Money)20000000LL));
-
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
+	CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
 
 	/* You can only transfer funds that is in excess of your loan */
 	if (p->player_money - p->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR;
@@ -367,7 +394,7 @@
 		/* Add money to player */
 		PlayerID old_cp = _current_player;
 		_current_player = (PlayerID)p2;
-		SubtractMoneyFromPlayer(CommandCost(-amount.GetCost()));
+		SubtractMoneyFromPlayer(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
 		_current_player = old_cp;
 	}
 
--- a/src/misc_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/misc_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,43 +6,44 @@
 #include "openttd.h"
 #include "heightmap.h"
 #include "debug.h"
-#include "functions.h"
 #include "landscape.h"
 #include "newgrf.h"
 #include "newgrf_text.h"
 #include "saveload.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
 #include "table/tree_land.h"
-#include "map.h"
-#include "window.h"
+#include "tile_map.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
+#include "window_gui.h"
+#include "station_gui.h"
+#include "textbuf_gui.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "station.h"
-#include "command.h"
+#include "command_func.h"
 #include "player.h"
 #include "town.h"
-#include "sound.h"
 #include "network/network.h"
-#include "string.h"
 #include "variables.h"
-#include "vehicle.h"
 #include "train.h"
 #include "tgp.h"
-#include "settings.h"
-#include "date.h"
 #include "cargotype.h"
 #include "player_face.h"
-#include "fileio.h"
-
+#include "strings_func.h"
 #include "fileio.h"
 #include "fios.h"
+#include "tile_cmd.h"
+#include "zoom_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "sound_func.h"
+#include "string_func.h"
+
 /* Variables to display file lists */
 FiosItem *_fios_list;
-int _saveload_mode;
+SaveLoadDialogMode _saveload_mode;
 
 
 static bool _fios_path_changed;
@@ -210,18 +211,22 @@
 	"Original graphics by Simon Foster",
 	"",
 	"The OpenTTD team (in alphabetical order):",
-	"  Jean-Francois Claeys (Belugas) - In training, not yet specialized",
-	"  Bjarni Corfitzen (Bjarni) - MacOSX port, coder",
-	"  Matthijs Kooijman (blathijs) - Pathfinder-guru",
-	"  Victor Fischer (Celestar) - Programming everywhere you need him to",
-	"  Tamás Faragó (Darkvater) - Lead coder",
-	"  Loïc Guilloux (glx) - In training, not yet specialized",
+	"  Jean-Francois Claeys (Belugas) - GUI, newindustries and more",
+	"  Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles",
+	"  Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework",
+	"  Loïc Guilloux (glx) - General coding",
 	"  Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
 	"  Jonathan Coome (Maedhros) - High priest of the newGRF Temple",
 	"  Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
 	"  Owen Rudge (orudge) - Forum host, OS/2 port",
-	"  Peter Nelson (peter1138) - Spiritual descendant from newgrf gods",
-	"  Remko Bijker (Rubidium) - THE desync hunter",
+	"  Peter Nelson (peter1138) - Spiritual descendant from newGRF gods",
+	"  Remko Bijker (Rubidium) - Lead coder and way more",
+	"  Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker",
+	"  Zdenek Sojka (SmatZ) - Bug finder and fixer",
+	"",
+	"Inactive Developers:",
+	"  Victor Fischer (Celestar) - Programming everywhere you need him to",
+	"  Tamás Faragó (Darkvater) - Ex-Lead coder",
 	"  Christoph Mallon (Tron) - Programmer, code correctness police",
 	"",
 	"Retired Developers:",
@@ -233,9 +238,9 @@
 	"Special thanks go out to:",
 	"  Josef Drexler - For his great work on TTDPatch",
 	"  Marcin Grzegorczyk - For his documentation of TTD internals",
-	"  Petr Baudis (pasky) - Many patches, newgrf support",
+	"  Petr Baudis (pasky) - Many patches, newGRF support",
 	"  Stefan Meißner (sign_de) - For his work on the console",
-	"  Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with (and PBS)",
+	"  Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with",
 	"  Cian Duffy (MYOB) - BeOS port / manual writing",
 	"  Christian Rosentreter (tokai) - MorphOS / AmigaOS port",
 	"  Richard Kempton (richK) - additional airports, initial TGP implementation",
@@ -256,7 +261,7 @@
 {
 	switch (e->event) {
 	case WE_CREATE: // Set up window counter and start position of scroller
-		WP(w, scroller_d).counter = 0;
+		WP(w, scroller_d).counter = 5;
 		WP(w, scroller_d).height = w->height - 40;
 		break;
 	case WE_PAINT: {
@@ -282,8 +287,9 @@
 		DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", TC_BLACK);
 		DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING);
 	} break;
-	case WE_MOUSELOOP: // Timer to scroll the text and adjust the new top
-		if (WP(w, scroller_d).counter++ % 3 == 0) {
+	case WE_TICK: // Timer to scroll the text and adjust the new top
+		if (--WP(w, scroller_d).counter == 0) {
+			WP(w, scroller_d).counter = 5;
 			WP(w, scroller_d).height--;
 			SetWindowDirty(w);
 		}
@@ -338,8 +344,8 @@
 
 		DrawWindowWidgets(w);
 
-		WP(w,tree_d).base = i = _tree_base_by_landscape[_opt.landscape];
-		WP(w,tree_d).count = count = _tree_count_by_landscape[_opt.landscape];
+		WP(w, tree_d).base = i = _tree_base_by_landscape[_opt.landscape];
+		WP(w, tree_d).count = count = _tree_count_by_landscape[_opt.landscape];
 
 		x = 18;
 		y = 54;
@@ -364,10 +370,10 @@
 		case 3: case 4: case 5: case 6:
 		case 7: case 8: case 9: case 10:
 		case 11:case 12: case 13: case 14:
-			if (wid - 3 >= WP(w,tree_d).count) break;
+			if (wid - 3 >= WP(w, tree_d).count) break;
 
 			if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL))
-				_tree_to_plant = WP(w,tree_d).base + wid - 3;
+				_tree_to_plant = WP(w, tree_d).base + wid - 3;
 			break;
 
 		case 15: // tree of random type.
@@ -376,7 +382,7 @@
 			break;
 
 		case 16: // place trees randomly over the landscape
-			LowerWindowWidget(w, 16);
+			w->LowerWidget(16);
 			w->flags4 |= 5 << WF_TIMEOUT_SHL;
 			SndPlayFx(SND_15_BEEP);
 			PlaceTreesRandomly();
@@ -402,11 +408,11 @@
 		break;
 
 	case WE_TIMEOUT:
-		RaiseWindowWidget(w, 16);
+		w->RaiseWidget(16);
 		break;
 
 	case WE_ABORT_PLACE_OBJ:
-		RaiseWindowButtons(w);
+		w->RaiseButtons();
 		break;
 	}
 }
@@ -721,7 +727,7 @@
 void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[])
 {
 	char buffer[512];
-	BoundingRect br;
+	Dimension br;
 	Window *w;
 	uint i;
 	int x, y;
@@ -772,7 +778,7 @@
 	b = InlineString(b, STR_000D_ACCEPTS);
 
 	for (CargoID i = 0; i < NUM_CARGO; i++) {
-		if (b >= lastof(_userstring) - 5) break;
+		if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
 		switch (sct) {
 			case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break;
 			case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break;
@@ -795,6 +801,10 @@
 	if (first) b = InlineString(b, STR_00D0_NOTHING);
 
 	*b = '\0';
+
+	/* Make sure we detect any buffer overflow */
+	assert(b < endof(_userstring));
+
 	DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144);
 }
 
@@ -1016,24 +1026,24 @@
 	case WKC_RETURN: case WKC_NUM_ENTER: return 1;
 	case (WKC_CTRL | 'V'):
 		if (InsertTextBufferClipboard(&string->text))
-			InvalidateWidget(w, wid);
+			w->InvalidateWidget(wid);
 		break;
 	case (WKC_CTRL | 'U'):
 		DeleteTextBufferAll(&string->text);
-		InvalidateWidget(w, wid);
+		w->InvalidateWidget(wid);
 		break;
 	case WKC_BACKSPACE: case WKC_DELETE:
 		if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode))
-			InvalidateWidget(w, wid);
+			w->InvalidateWidget(wid);
 		break;
 	case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
 		if (MoveTextBufferPos(&string->text, e->we.keypress.keycode))
-			InvalidateWidget(w, wid);
+			w->InvalidateWidget(wid);
 		break;
 	default:
 		if (IsValidChar(e->we.keypress.key, string->afilter)) {
 			if (InsertTextBufferChar(&string->text, e->we.keypress.key)) {
-				InvalidateWidget(w, wid);
+				w->InvalidateWidget(wid);
 			}
 		} else { // key wasn't caught. Continue only if standard entry specified
 			e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL);
@@ -1057,7 +1067,7 @@
 
 void HandleEditBox(Window *w, querystr_d *string, int wid)
 {
-	if (HandleCaret(&string->text)) InvalidateWidget(w, wid);
+	if (HandleCaret(&string->text)) w->InvalidateWidget(wid);
 }
 
 void DrawEditBox(Window *w, querystr_d *string, int wid)
@@ -1220,7 +1230,7 @@
 		WP(w, querystr_d).orig = orig_str_buf;
 	}
 
-	LowerWindowWidget(w, QUERY_STR_WIDGET_TEXT);
+	w->LowerWidget(QUERY_STR_WIDGET_TEXT);
 	WP(w, querystr_d).caption = caption;
 	WP(w, querystr_d).afilter = afilter;
 	InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, realmaxlen, maxwidth);
@@ -1564,7 +1574,7 @@
 					/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
 					ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
 					UpdateTextBufferSize(&WP(w, querystr_d).text);
-					InvalidateWidget(w, 10);
+					w->InvalidateWidget(10);
 				}
 			} else {
 				/* Changed directory, need repaint. */
@@ -1591,7 +1601,7 @@
 
 		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
 			if (HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) // Press Enter
-					HandleButtonClick(w, 12);
+					w->HandleButtonClick(12);
 		}
 		break;
 	case WE_TIMEOUT:
@@ -1599,7 +1609,7 @@
 		 * in those two saveload mode  */
 		if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) break;
 
-		if (IsWindowWidgetLowered(w, 11)) { // Delete button clicked
+		if (w->IsWidgetLowered(11)) { // Delete button clicked
 			if (!FiosDelete(WP(w, querystr_d).text.buf)) {
 				ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
 			} else {
@@ -1610,7 +1620,7 @@
 
 			UpdateTextBufferSize(&WP(w, querystr_d).text);
 			SetWindowDirty(w);
-		} else if (IsWindowWidgetLowered(w, 12)) { // Save button clicked
+		} else if (w->IsWidgetLowered(12)) { // Save button clicked
 			_switch_mode = SM_SAVE;
 			FiosMakeSavegameName(_file_to_saveload.name, WP(w, querystr_d).text.buf, sizeof(_file_to_saveload.name));
 
@@ -1661,7 +1671,18 @@
 	SaveLoadDlgWndProc,
 };
 
-void ShowSaveLoadDialog(int mode)
+/** These values are used to convert the file/operations mode into a corresponding file type.
+ * So each entry, as expressed by the related comment, is based on the enum   */
+static const FileType _file_modetotype[] = {
+	FT_SAVEGAME,  ///< used for SLD_LOAD_GAME
+	FT_SCENARIO,  ///< used for SLD_LOAD_SCENARIO
+	FT_SAVEGAME,  ///< used for SLD_SAVE_GAME
+	FT_SCENARIO,  ///< used for SLD_SAVE_SCENARIO
+	FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP
+	FT_SAVEGAME,  ///< SLD_NEW_GAME
+};
+
+void ShowSaveLoadDialog(SaveLoadDialogMode mode)
 {
 	static const StringID saveload_captions[] = {
 		STR_4001_LOAD_GAME,
@@ -1682,6 +1703,9 @@
 	_saveload_mode = mode;
 	SetBit(_no_scroll, SCROLL_SAVE);
 
+	/* Use an array to define what will be the current file type being handled
+	 * by current file mode */
+	_file_to_saveload.filetype = _file_modetotype[mode];
 	switch (mode) {
 		case SLD_SAVE_GAME:     GenerateFileName(); break;
 		case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break;
@@ -1691,7 +1715,7 @@
 	assert((uint)mode < lengthof(saveload_captions));
 	w = AllocateWindowDesc(sld);
 	w->widget[1].data = saveload_captions[mode];
-	LowerWindowWidget(w, 7);
+	w->LowerWidget(7);
 
 	WP(w, querystr_d).afilter = CS_ALPHANUMERAL;
 	InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 240);
@@ -1847,7 +1871,7 @@
 {
 	switch (e->event) {
 	case WE_PAINT: {
-		int clk = WP(w,def_d).data_1;
+		int clk = WP(w, def_d).data_1;
 		int x, y;
 		int i;
 
@@ -1917,7 +1941,7 @@
 			uint x = e->we.click.pt.x;
 
 			/* not clicking a button? */
-			if (!IS_INT_INSIDE(x, 20, 40) || btn >= lengthof(_cheats_ui)) break;
+			if (!IsInsideMM(x, 20, 40) || btn >= lengthof(_cheats_ui)) break;
 
 			ce = &_cheats_ui[btn];
 			oldvalue = value = (int32)ReadValue(ce->variable, ce->type);
@@ -1926,7 +1950,7 @@
 
 			switch (ce->type) {
 			case SLE_BOOL:
-				if (ce->flags & CE_CLICK) WP(w,def_d).data_1 = btn * 2 + 1;
+				if (ce->flags & CE_CLICK) WP(w, def_d).data_1 = btn * 2 + 1;
 				value ^= 1;
 				if (ce->proc != NULL) ce->proc(value, 0);
 				break;
@@ -1944,7 +1968,7 @@
 				value = ce->proc(value, (x >= 30) ? 1 : -1);
 
 				if (value != oldvalue) {
-					WP(w,def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0);
+					WP(w, def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0);
 				}
 			} break;
 			}
@@ -1960,7 +1984,7 @@
 		}
 		break;
 	case WE_TIMEOUT:
-		WP(w,def_d).data_1 = 0;
+		WP(w, def_d).data_1 = 0;
 		SetWindowDirty(w);
 		break;
 	}
--- a/src/music/extmidi.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/music/extmidi.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,8 +3,7 @@
 #ifndef __MORPHOS__
 #include "../stdafx.h"
 #include "../openttd.h"
-#include "../sound.h"
-#include "../string.h"
+#include "../sound_func.h"
 #include "../variables.h"
 #include "../debug.h"
 #include "extmidi.h"
--- a/src/music/libtimidity.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/music/libtimidity.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,7 +3,6 @@
 #include "../stdafx.h"
 #include "../openttd.h"
 #include "../sound.h"
-#include "../string.h"
 #include "../variables.h"
 #include "../debug.h"
 #include "libtimidity.h"
--- a/src/music/qtmidi.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/music/qtmidi.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -19,6 +19,9 @@
  */
 
 
+#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
+#include <AvailabilityMacros.h>
+
 /*
  * OpenTTD includes.
  */
--- a/src/music_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/music_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,16 +6,16 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "strings.h"
-#include "functions.h"
 #include "fileio.h"
-#include "window.h"
-#include "gfx.h"
-#include "sound.h"
-#include "macros.h"
 #include "variables.h"
 #include "music.h"
 #include "music/music_driver.hpp"
+#include "window_gui.h"
+#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;
@@ -199,9 +199,9 @@
 		uint i;
 		int y;
 
-		SetWindowWidgetDisabledState(w, 11, msf.playlist <= 3);
-		LowerWindowWidget(w, 3);
-		LowerWindowWidget(w, 4);
+		w->SetWidgetDisabledState(11, msf.playlist <= 3);
+		w->LowerWidget(3);
+		w->LowerWidget(4);
 		DrawWindowWidgets(w);
 
 		GfxFillRect(3, 23, 3 + 177, 23 + 191, 0);
@@ -247,7 +247,7 @@
 			byte *p;
 
 			if (msf.playlist < 4) return;
-			if (!IS_INT_INSIDE(y, 0, NUM_SONGS_AVAILABLE)) return;
+			if (!IsInsideMM(y, 0, NUM_SONGS_AVAILABLE)) return;
 
 			p = _playlists[msf.playlist];
 			for (i = 0; i != NUM_SONGS_PLAYLIST - 1; i++) {
@@ -267,7 +267,7 @@
 			byte *p;
 
 			if (msf.playlist < 4) return;
-			if (!IS_INT_INSIDE(y, 0, NUM_SONGS_AVAILABLE)) return;
+			if (!IsInsideMM(y, 0, NUM_SONGS_AVAILABLE)) return;
 
 			p = _playlists[msf.playlist];
 			for (i = y; i != NUM_SONGS_PLAYLIST - 1; i++) {
@@ -342,8 +342,8 @@
 		uint i;
 		StringID str;
 
-		RaiseWindowWidget(w, 7);
-		RaiseWindowWidget(w, 9);
+		w->RaiseWidget(7);
+		w->RaiseWidget(9);
 		DrawWindowWidgets(w);
 
 		GfxFillRect(187, 16, 200, 33, 0);
--- a/src/namegen.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/namegen.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,10 +5,9 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "macros.h"
 #include "namegen.h"
 #include "table/namegen.h"
-#include "string.h"
+#include "string_func.h"
 
 static inline uint32 SeedChance(int shift_by, int max, uint32 seed)
 {
--- a/src/network/core/config.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/core/config.h	Wed Jan 09 18:11:12 2008 +0000
@@ -29,7 +29,7 @@
 	NETWORK_HOSTNAME_LENGTH       =   80, ///< The maximum length of the host name, in bytes including '\0'
 	NETWORK_UNIQUE_ID_LENGTH      =   33, ///< The maximum length of the unique id of the clients, in bytes including '\0'
 	NETWORK_REVISION_LENGTH       =   15, ///< The maximum length of the revision, in bytes including '\0'
-	NETWORK_PASSWORD_LENGTH       =   20, ///< The maximum length of the password, in bytes including '\0'
+	NETWORK_PASSWORD_LENGTH       =   33, ///< The maximum length of the password, in bytes including '\0' (must be >= NETWORK_UNIQUE_ID_LENGTH)
 	NETWORK_PLAYERS_LENGTH        =  200, ///< The maximum length for the list of players that controls a company, in bytes including '\0'
 	NETWORK_CLIENT_NAME_LENGTH    =   25, ///< The maximum length of a player, in bytes including '\0'
 	NETWORK_RCONCOMMAND_LENGTH    =  500, ///< The maximum length of a rconsole command, in bytes including '\0'
--- a/src/network/core/game.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/core/game.h	Wed Jan 09 18:11:12 2008 +0000
@@ -11,8 +11,8 @@
 #ifdef ENABLE_NETWORK
 
 #include "config.h"
-#include "../../date.h"
 #include "../../newgrf_config.h"
+#include "../../date_type.h"
 
 /**
  * This is the struct used by both client and server
--- a/src/network/core/packet.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/core/packet.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -7,9 +7,7 @@
 #ifdef ENABLE_NETWORK
 
 #include "../../stdafx.h"
-#include "../../macros.h"
-#include "../../string.h"
-#include "../../helpers.hpp"
+#include "../../string_func.h"
 
 #include "packet.h"
 
--- a/src/network/core/tcp.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/core/tcp.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -11,12 +11,10 @@
 #include "../../openttd.h"
 #include "../../variables.h"
 #include "table/strings.h"
-#include "../../functions.h"
 
 #include "../network_data.h"
 #include "packet.h"
 #include "tcp.h"
-#include "../../helpers.hpp"
 
 /** Very ugly temporary hack !!! */
 void NetworkTCPSocketHandler::Initialize()
--- a/src/network/core/udp.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/core/udp.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,8 +8,10 @@
 
 #include "../../stdafx.h"
 #include "../../debug.h"
-#include "../../macros.h"
-#include "../../helpers.hpp"
+#include "../../core/bitmath_func.hpp"
+#include "../../core/math_func.hpp"
+#include "../../core/alloc_func.hpp"
+#include "../../date_func.h"
 #include "packet.h"
 #include "udp.h"
 
--- a/src/network/network.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -9,13 +9,11 @@
 
 #include "../openttd.h"
 #include "../debug.h"
-#include "../functions.h"
-#include "../string.h"
-#include "../strings.h"
-#include "../map.h"
-#include "../command.h"
+#include "../strings_func.h"
+#include "../map_func.h"
+#include "../command_func.h"
 #include "../variables.h"
-#include "../date.h"
+#include "../date_func.h"
 #include "../newgrf_config.h"
 #include "table/strings.h"
 #include "network_client.h"
@@ -30,6 +28,13 @@
 #include <stdarg.h> /* va_list */
 #include "../md5.h"
 #include "../fileio.h"
+#include "../texteff.hpp"
+#include "../core/random_func.hpp"
+#include "../window_func.h"
+#include "../string_func.h"
+#ifdef DEBUG_DUMP_COMMANDS
+	#include "../core/alloc_func.hpp"
+#endif
 
 /* Check whether NETWORK_NUM_LANDSCAPES is still in sync with NUM_LANDSCAPE */
 assert_compile((int)NETWORK_NUM_LANDSCAPES == (int)NUM_LANDSCAPE);
@@ -1350,8 +1355,8 @@
 
 static void NetworkGenerateUniqueId()
 {
-	md5_state_t state;
-	md5_byte_t digest[16];
+	Md5 checksum;
+	uint8 digest[16];
 	char hex_output[16*2 + 1];
 	char coding_string[NETWORK_NAME_LENGTH];
 	int di;
@@ -1359,9 +1364,8 @@
 	snprintf(coding_string, sizeof(coding_string), "%d%s", (uint)Random(), "OpenTTD Unique ID");
 
 	/* Generate the MD5 hash */
-	md5_init(&state);
-	md5_append(&state, (const md5_byte_t*)coding_string, strlen(coding_string));
-	md5_finish(&state, digest);
+	checksum.Append((const uint8*)coding_string, strlen(coding_string));
+	checksum.Finish(digest);
 
 	for (di = 0; di < 16; ++di)
 		sprintf(hex_output + di * 2, "%02x", digest[di]);
@@ -1466,7 +1470,7 @@
 #ifdef DEBUG_DUMP_COMMANDS
 void CDECL debug_dump_commands(const char *s, ...)
 {
-	static FILE *f = FioFOpenFile("commands-out.log", "wb", SAVE_DIR);
+	static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
 	if (f == NULL) return;
 
 	va_list va;
--- a/src/network/network.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network.h	Wed Jan 09 18:11:12 2008 +0000
@@ -147,6 +147,7 @@
 VARDEF char _network_server_name[NETWORK_NAME_LENGTH];
 VARDEF char _network_server_password[NETWORK_PASSWORD_LENGTH];
 VARDEF char _network_rcon_password[NETWORK_PASSWORD_LENGTH];
+VARDEF char _network_default_company_pass[NETWORK_PASSWORD_LENGTH];
 
 VARDEF uint16 _network_max_join_time;             ///< Time a client can max take to join
 VARDEF bool _network_pause_on_join;               ///< Pause the game when a client tries to join (more chance of succeeding join)
@@ -215,6 +216,7 @@
 
 bool IsNetworkCompatibleVersion(const char *version);
 
+extern bool _networking;         ///< are we in networking mode?
 VARDEF bool _network_server;     ///< network-server is active
 VARDEF bool _network_available;  ///< is network mode available?
 VARDEF bool _network_dedicated;  ///< are we a dedicated server?
@@ -234,7 +236,7 @@
 
 #endif /* ENABLE_NETWORK */
 
-/* Thss variable must always be registered! */
+/* This variable must always be registered! */
 VARDEF PlayerID _network_playas; ///< an id to play as.. (see players.h:Players)
 
 #endif /* NETWORK_H */
--- a/src/network/network_client.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network_client.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,24 +4,23 @@
 
 #include "../stdafx.h"
 #include "../debug.h"
-#include "../string.h"
 #include "../openttd.h"
-#include "../strings.h"
 #include "network_data.h"
 #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"
 #include "../saveload.h"
-#include "../command.h"
-#include "../window.h"
+#include "../command_func.h"
 #include "../console.h"
 #include "../variables.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
 #include "../fileio.h"
+#include "../md5.h"
+#include "../strings_func.h"
+#include "../window_func.h"
+#include "../string_func.h"
 
 // This file handles all the client-commands
 
@@ -31,6 +30,58 @@
 
 static uint32 last_ack_frame;
 
+/** One bit of 'entropy' used to generate a salt for the company passwords. */
+static uint32 _password_game_seed;
+/** The other bit of 'entropy' used to generate a salt for the company passwords. */
+static char _password_server_unique_id[NETWORK_UNIQUE_ID_LENGTH];
+
+/** Make sure the unique ID length is the same as a md5 hash. */
+assert_compile(NETWORK_UNIQUE_ID_LENGTH == 16 * 2 + 1);
+
+/**
+ * Generates a hashed password for the company name.
+ * @param password the password to 'encrypt'.
+ * @return the hashed password.
+ */
+static const char *GenerateCompanyPasswordHash(const char *password)
+{
+	if (StrEmpty(password)) return password;
+
+	char salted_password[NETWORK_UNIQUE_ID_LENGTH];
+
+	memset(salted_password, 0, sizeof(salted_password));
+	snprintf(salted_password, sizeof(salted_password), "%s", password);
+	/* Add the game seed and the server's unique ID as the salt. */
+	for (uint i = 0; i < NETWORK_UNIQUE_ID_LENGTH; i++) salted_password[i] ^= _password_server_unique_id[i] ^ (_password_game_seed >> i);
+
+	Md5 checksum;
+	uint8 digest[16];
+	static char hashed_password[NETWORK_UNIQUE_ID_LENGTH];
+
+	/* Generate the MD5 hash */
+	checksum.Append((const uint8*)salted_password, sizeof(salted_password));
+	checksum.Finish(digest);
+
+	for (int di = 0; di < 16; di++) sprintf(hashed_password + di * 2, "%02x", digest[di]);
+
+	return hashed_password;
+}
+
+/**
+ * Hash the current company password; used when the server 'player' sets his/her password.
+ */
+void HashCurrentCompanyPassword()
+{
+	if (StrEmpty(_network_player_info[_local_player].password)) return;
+
+	_password_game_seed = _patches.generation_seed;
+	snprintf(_password_server_unique_id, sizeof(_password_server_unique_id), _network_unique_id);
+
+	const char *new_pw = GenerateCompanyPasswordHash(_network_player_info[_local_player].password);
+	snprintf(_network_player_info[_local_player].password, sizeof(_network_player_info[_local_player].password), new_pw);
+}
+
+
 // **********
 // Sending functions
 //   DEF_CLIENT_SEND_COMMAND has no parameters
@@ -102,7 +153,7 @@
 	//
 	Packet *p = NetworkSend_Init(PACKET_CLIENT_PASSWORD);
 	p->Send_uint8 (type);
-	p->Send_string(password);
+	p->Send_string(type == NETWORK_GAME_PASSWORD ? password : GenerateCompanyPasswordHash(password));
 	MY_CLIENT->Send_Packet(p);
 }
 
@@ -223,7 +274,7 @@
 	//
 	Packet *p = NetworkSend_Init(PACKET_CLIENT_SET_PASSWORD);
 
-	p->Send_string(password);
+	p->Send_string(GenerateCompanyPasswordHash(password));
 	MY_CLIENT->Send_Packet(p);
 }
 
@@ -457,8 +508,13 @@
 	NetworkPasswordType type = (NetworkPasswordType)p->Recv_uint8();
 
 	switch (type) {
+		case NETWORK_COMPANY_PASSWORD:
+			/* Initialize the password hash salting variables. */
+			_password_game_seed = p->Recv_uint32();
+			p->Recv_string(_password_server_unique_id, sizeof(_password_server_unique_id));
+			if (MY_CLIENT->has_quit) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
+
 		case NETWORK_GAME_PASSWORD:
-		case NETWORK_COMPANY_PASSWORD:
 			ShowNetworkNeedPassword(type);
 			return NETWORK_RECV_STATUS_OKAY;
 
@@ -470,6 +526,10 @@
 {
 	_network_own_client_index = p->Recv_uint16();
 
+	/* Initialize the password hash salting variables, even if they were previously. */
+	_password_game_seed = p->Recv_uint32();
+	p->Recv_string(_password_server_unique_id, sizeof(_password_server_unique_id));
+
 	// Start receiving the map
 	SEND_COMMAND(PACKET_CLIENT_GETMAP)();
 	return NETWORK_RECV_STATUS_OKAY;
--- a/src/network/network_data.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network_data.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,11 +5,11 @@
 #include "../stdafx.h"
 #include "../debug.h"
 #include "network_data.h"
-#include "../string.h"
 #include "network_client.h"
-#include "../command.h"
+#include "../command_func.h"
 #include "../callback_table.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
+#include "../string_func.h"
 
 // Add a command to the local command queue
 void NetworkAddCommandQueue(NetworkTCPSocketHandler *cs, CommandPacket *cp)
@@ -100,6 +100,8 @@
 	}
 
 #ifdef DEBUG_DUMP_COMMANDS
+	extern Date      _date;
+	extern DateFract _date_fract;
 	debug_dump_commands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->player, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text);
 #endif /* DUMP_COMMANDS */
 
--- a/src/network/network_gamelist.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network_gamelist.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -10,7 +10,7 @@
 #include "../stdafx.h"
 #include "../debug.h"
 #include "../newgrf_config.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
 #include "core/game.h"
 #include "network_udp.h"
 #include "network_gamelist.h"
--- a/src/network/network_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,35 +3,39 @@
 #ifdef ENABLE_NETWORK
 #include "../stdafx.h"
 #include "../openttd.h"
-#include "../string.h"
-#include "../strings.h"
+#include "../strings_func.h"
 #include "../table/sprites.h"
 #include "network.h"
-#include "../date.h"
+#include "../date_func.h"
 
 #include "../fios.h"
 #include "table/strings.h"
-#include "../functions.h"
 #include "network_data.h"
 #include "network_client.h"
 #include "network_gui.h"
 #include "network_gamelist.h"
-#include "../window.h"
 #include "../gui.h"
-#include "../gfx.h"
-#include "../command.h"
+#include "../window_gui.h"
+#include "../textbuf_gui.h"
 #include "../variables.h"
 #include "network_server.h"
 #include "network_udp.h"
-#include "../settings.h"
-#include "../string.h"
 #include "../town.h"
 #include "../newgrf.h"
-#include "../helpers.hpp"
+#include "../functions.h"
+#include "../window_func.h"
+#include "../core/alloc_func.hpp"
+#include "../string_func.h"
+#include "../gfx_func.h"
 
 #define BGC 5
 #define BTC 15
 
+struct chatquerystr_d : public querystr_d {
+	int dest;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d));
+
 struct network_d {
 	PlayerID company;        // select company in network lobby
 	byte field;              // select text-field in start-server and game-listing
@@ -167,7 +171,6 @@
 	/* Create temporary array of games to use for listing */
 	free(nqld->sort_list);
 	nqld->sort_list = MallocT<NetworkGameList*>(n);
-	if (nqld->sort_list == NULL) error("Could not allocate memory for the network-game-sorting-list");
 	nqld->l.list_length = n;
 
 	for (n = 0, ngl_temp = _network_game_list; ngl_temp != NULL; ngl_temp = ngl_temp->next) {
@@ -209,18 +212,51 @@
 	nqld->l.flags &= ~VL_RESORT;
 }
 
-/* Uses network_ql_d (network_d, querystr_d and list_d) WP macro */
+/** Enum for NetworkGameWindow, referring to _network_game_window_widgets */
+enum NetworkGameWindowWidgets {
+	NGWW_CLOSE    = 0,  ///< Close 'X' button
+	NGWW_CONN_TXT = 4,  ///< 'Connection' droplist
+	NGWW_CONN_BTN = 5,  ///< 'Connection' droplist button
+	NGWW_PLAYER   = 6,  ///< Panel with editbox to set player name
+
+	NGWW_NAME     = 7,  ///< 'Name' button
+	NGWW_CLIENTS,       ///< 'Clients' button
+	NGWW_INFO,          ///< Third button in the game list panel
+
+	NGWW_MATRIX   = 10, ///< Panel with list of games
+
+	NGWW_DETAILS  = 12, ///< Panel with game details
+	NGWW_JOIN     = 13, ///< 'Join game' button
+	NGWW_REFRESH  = 14, ///< 'Refresh server' button
+	NGWW_NEWGRF   = 15, ///< 'NewGRF Settings' button
+
+	NGWW_FIND     = 16, ///< 'Find server' button
+	NGWW_ADD,           ///< 'Add server' button
+	NGWW_START,         ///< 'Start server' button
+	NGWW_CANCEL,        ///< 'Cancel' button
+};
+
+/**
+ * Handler of actions done in the NetworkStartServer window
+ *
+ * @param w pointer to the Window structure
+ * @param e pointer to window event
+ * @note    Uses network_ql_d (network_d, querystr_d and list_d) WP macro
+ * @see     struct _network_game_window_widgets
+ * @see     enum NetworkGameWindowWidgets
+ */
+
 static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
 {
 	network_d *nd = &WP(w, network_ql_d).n;
 	list_d *ld = &WP(w, network_ql_d).l;
 
 	switch (e->event) {
-	case WE_CREATE: /* Focus input box */
+	case WE_CREATE: // Focus input box
 		w->vscroll.cap = 13;
 		w->resize.step_height = NET_PRC__SIZE_OF_ROW;
 
-		nd->field = 3;
+		nd->field = NGWW_PLAYER;
 		nd->server = NULL;
 
 		WP(w, network_ql_d).sort_list = NULL;
@@ -238,14 +274,16 @@
 		}
 		if (ld->flags & VL_RESORT) SortNetworkGameList(&WP(w, network_ql_d));
 
-		SetWindowWidgetDisabledState(w, 17, sel == NULL);
-		/* Join Button disabling conditions */
-		SetWindowWidgetDisabledState(w, 16, sel == NULL || // no Selected Server
+		/* 'Refresh' button invisible if no server selected */
+		w->SetWidgetDisabledState(NGWW_REFRESH, sel == NULL);
+		/* 'Join' button disabling conditions */
+		w->SetWidgetDisabledState(NGWW_JOIN, sel == NULL || // no Selected Server
 				!sel->online || // Server offline
 				sel->info.clients_on >= sel->info.clients_max || // Server full
 				!sel->info.compatible); // Revision mismatch
 
-		SetWindowWidgetHiddenState(w, 18, sel == NULL ||
+		/* 'NewGRF Settings' button invisible if no NewGRF is used */
+		w->SetWidgetHiddenState(NGWW_NEWGRF, sel == NULL ||
 				!sel->online ||
 				sel->info.grfconfig == NULL);
 
@@ -253,23 +291,23 @@
 		SetDParam(1, _lan_internet_types_dropdown[_network_lan_internet]);
 		DrawWindowWidgets(w);
 
-		DrawEditBox(w, &WP(w, network_ql_d).q, 3);
+		/* Edit box to set player name */
+		DrawEditBox(w, &WP(w, network_ql_d).q, NGWW_PLAYER);
 
-		DrawString(9, 23, STR_NETWORK_CONNECTION, TC_GOLD);
-		DrawString(w->widget[3].left - 100, 23, STR_NETWORK_PLAYER_NAME, TC_GOLD);
+		DrawString(w->widget[NGWW_PLAYER].left - 100, 23, STR_NETWORK_PLAYER_NAME, TC_GOLD);
 
 		/* Sort based on widgets: name, clients, compatibility */
 		switch (ld->sort_type) {
-			case 6 - 6: DoDrawString(arrow, w->widget[6].right - 10, 42, TC_BLACK); break;
-			case 7 - 6: DoDrawString(arrow, w->widget[7].right - 10, 42, TC_BLACK); break;
-			case 8 - 6: DoDrawString(arrow, w->widget[8].right - 10, 42, TC_BLACK); break;
+			case NGWW_NAME    - NGWW_NAME: DoDrawString(arrow, w->widget[NGWW_NAME].right    - 10, 42, TC_BLACK); break;
+			case NGWW_CLIENTS - NGWW_NAME: DoDrawString(arrow, w->widget[NGWW_CLIENTS].right - 10, 42, TC_BLACK); break;
+			case NGWW_INFO    - NGWW_NAME: DoDrawString(arrow, w->widget[NGWW_INFO].right    - 10, 42, TC_BLACK); break;
 		}
 
 		{ // draw list of games
 			uint16 y = NET_PRC__OFFSET_TOP_WIDGET + 3;
 			int32 n = 0;
 			int32 pos = w->vscroll.pos;
-			uint max_name_width = w->widget[6].right - w->widget[6].left - 5;
+			uint max_name_width = w->widget[NGWW_NAME].right - w->widget[NGWW_NAME].left - 5;
 			const NetworkGameList *cur_item = _network_game_list;
 
 			while (pos > 0 && cur_item != NULL) {
@@ -278,28 +316,28 @@
 			}
 
 			while (cur_item != NULL) {
-				// show highlighted item with a different colour
-				if (cur_item == sel) GfxFillRect(w->widget[6].left + 1, y - 2, w->widget[8].right - 1, y + 9, 10);
+				/* show highlighted item with a different colour */
+				if (cur_item == sel) GfxFillRect(w->widget[NGWW_NAME].left + 1, y - 2, w->widget[NGWW_INFO].right - 1, y + 9, 10);
 
 				SetDParamStr(0, cur_item->info.server_name);
-				DrawStringTruncated(w->widget[6].left + 5, y, STR_02BD, TC_BLACK, max_name_width);
+				DrawStringTruncated(w->widget[NGWW_NAME].left + 5, y, STR_02BD, TC_BLACK, max_name_width);
 
 				SetDParam(0, cur_item->info.clients_on);
 				SetDParam(1, cur_item->info.clients_max);
 				SetDParam(2, cur_item->info.companies_on);
 				SetDParam(3, cur_item->info.companies_max);
-				DrawStringCentered(w->widget[7].left + 39, y, STR_NETWORK_GENERAL_ONLINE, TC_GOLD);
+				DrawStringCentered(w->widget[NGWW_CLIENTS].left + 39, y, STR_NETWORK_GENERAL_ONLINE, TC_GOLD);
 
-				// only draw icons if the server is online
+				/* only draw icons if the server is online */
 				if (cur_item->online) {
-					// draw a lock if the server is password protected.
-					if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[8].left + 5, y - 1);
+					/* draw a lock if the server is password protected */
+					if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[NGWW_INFO].left + 5, y - 1);
 
-					// draw red or green icon, depending on compatibility with server.
-					DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), w->widget[8].left + 15, y);
+					/* draw red or green icon, depending on compatibility with server */
+					DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), w->widget[NGWW_INFO].left + 15, y);
 
-					// draw flag according to server language
-					DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, w->widget[8].left + 25, y);
+					/* draw flag according to server language */
+					DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, w->widget[NGWW_INFO].left + 25, y);
 				}
 
 				cur_item = cur_item->next;
@@ -309,26 +347,26 @@
 		}
 
 		/* Draw the right menu */
-		GfxFillRect(w->widget[15].left + 1, 43, w->widget[15].right - 1, 92, 157);
+		GfxFillRect(w->widget[NGWW_DETAILS].left + 1, 43, w->widget[NGWW_DETAILS].right - 1, 92, 157);
 		if (sel == NULL) {
-			DrawStringCentered(w->widget[15].left + 115, 58, STR_NETWORK_GAME_INFO, TC_FROMSTRING);
+			DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, 58, STR_NETWORK_GAME_INFO, TC_FROMSTRING);
 		} else if (!sel->online) {
 			SetDParamStr(0, sel->info.server_name);
-			DrawStringCentered(w->widget[15].left + 115, 68, STR_ORANGE, TC_FROMSTRING); // game name
+			DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, 68, STR_ORANGE, TC_FROMSTRING); // game name
 
-			DrawStringCentered(w->widget[15].left + 115, 132, STR_NETWORK_SERVER_OFFLINE, TC_FROMSTRING); // server offline
+			DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, 132, STR_NETWORK_SERVER_OFFLINE, TC_FROMSTRING); // server offline
 		} else { // show game info
 			uint16 y = 100;
-			const uint16 x = w->widget[15].left + 5;
+			const uint16 x = w->widget[NGWW_DETAILS].left + 5;
 
-			DrawStringCentered(w->widget[15].left + 115, 48, STR_NETWORK_GAME_INFO, TC_FROMSTRING);
+			DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, 48, STR_NETWORK_GAME_INFO, TC_FROMSTRING);
 
 
 			SetDParamStr(0, sel->info.server_name);
-			DrawStringCenteredTruncated(w->widget[15].left, w->widget[15].right, 62, STR_ORANGE, TC_BLACK); // game name
+			DrawStringCenteredTruncated(w->widget[NGWW_DETAILS].left, w->widget[NGWW_DETAILS].right, 62, STR_ORANGE, TC_BLACK); // game name
 
 			SetDParamStr(0, sel->info.map_name);
-			DrawStringCenteredTruncated(w->widget[15].left, w->widget[15].right, 74, STR_02BD, TC_BLACK); // map name
+			DrawStringCenteredTruncated(w->widget[NGWW_DETAILS].left, w->widget[NGWW_DETAILS].right, 74, STR_02BD, TC_BLACK); // map name
 
 			SetDParam(0, sel->info.clients_on);
 			SetDParam(1, sel->info.clients_max);
@@ -370,12 +408,12 @@
 			y += 2;
 
 			if (!sel->info.compatible) {
-				DrawStringCentered(w->widget[15].left + 115, y, sel->info.version_compatible ? STR_NETWORK_GRF_MISMATCH : STR_NETWORK_VERSION_MISMATCH, TC_FROMSTRING); // server mismatch
+				DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, y, sel->info.version_compatible ? STR_NETWORK_GRF_MISMATCH : STR_NETWORK_VERSION_MISMATCH, TC_FROMSTRING); // server mismatch
 			} else if (sel->info.clients_on == sel->info.clients_max) {
-				// Show: server full, when clients_on == clients_max
-				DrawStringCentered(w->widget[15].left + 115, y, STR_NETWORK_SERVER_FULL, TC_FROMSTRING); // server full
+				/* Show: server full, when clients_on == clients_max */
+				DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, y, STR_NETWORK_SERVER_FULL, TC_FROMSTRING); // server full
 			} else if (sel->info.use_password) {
-				DrawStringCentered(w->widget[15].left + 115, y, STR_NETWORK_PASSWORD, TC_FROMSTRING); // password warning
+				DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, y, STR_NETWORK_PASSWORD, TC_FROMSTRING); // password warning
 			}
 
 			y += 10;
@@ -385,24 +423,24 @@
 	case WE_CLICK:
 		nd->field = e->we.click.widget;
 		switch (e->we.click.widget) {
-		case 14: // Cancel button
+		case NGWW_CANCEL: // Cancel button
 			DeleteWindowById(WC_NETWORK_WINDOW, 0);
 			break;
-		case 4: case 5:
-			ShowDropDownMenu(w, _lan_internet_types_dropdown, _network_lan_internet, 5, 0, 0); // do it for widget 5
+		case NGWW_CONN_TXT: case NGWW_CONN_BTN: // 'Connection' droplist
+			ShowDropDownMenu(w, _lan_internet_types_dropdown, _network_lan_internet, NGWW_CONN_BTN, 0, 0); // do it for widget NSSW_CONN_BTN
 			break;
-		case 6: /* Sort by name */
-		case 7: /* Sort by connected clients */
-		case 8: /* Connectivity (green dot) */
-			if (ld->sort_type == e->we.click.widget - 6) ld->flags ^= VL_DESC;
+		case NGWW_NAME: // Sort by name
+		case NGWW_CLIENTS: // Sort by connected clients
+		case NGWW_INFO: // Connectivity (green dot)
+			if (ld->sort_type == e->we.click.widget - NGWW_NAME) ld->flags ^= VL_DESC;
 			ld->flags |= VL_RESORT;
-			ld->sort_type = e->we.click.widget - 6;
+			ld->sort_type = e->we.click.widget - NGWW_NAME;
 
 			_ng_sorting.order = !!(ld->flags & VL_DESC);
 			_ng_sorting.criteria = ld->sort_type;
 			SetWindowDirty(w);
 			break;
-		case 9: { /* Matrix to show networkgames */
+		case NGWW_MATRIX: { // Matrix to show networkgames
 			NetworkGameList *cur_item;
 			uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW;
 
@@ -415,52 +453,54 @@
 			nd->server = cur_item;
 			SetWindowDirty(w);
 		} break;
-		case 11: /* Find server automatically */
+		case NGWW_FIND: // Find server automatically
 			switch (_network_lan_internet) {
 				case 0: NetworkUDPSearchGame(); break;
 				case 1: NetworkUDPQueryMasterServer(); break;
 			}
 			break;
-		case 12: { // Add a server
-				ShowQueryString(
+		case NGWW_ADD: { // Add a server
+			ShowQueryString(
 				BindCString(_network_default_ip),
 				STR_NETWORK_ENTER_IP,
 				31 | 0x1000,  // maximum number of characters OR
 				250, // characters up to this width pixels, whichever is satisfied first
 				w, CS_ALPHANUMERAL);
 		} break;
-		case 13: /* Start server */
+		case NGWW_START: // Start server
 			ShowNetworkStartServerWindow();
 			break;
-		case 16: /* Join Game */
+		case NGWW_JOIN: // Join Game
 			if (nd->server != NULL) {
 				snprintf(_network_last_host, sizeof(_network_last_host), "%s", inet_ntoa(*(struct in_addr *)&nd->server->ip));
 				_network_last_port = nd->server->port;
 				ShowNetworkLobbyWindow(nd->server);
 			}
 			break;
-		case 17: // Refresh
+		case NGWW_REFRESH: // Refresh
 			if (nd->server != NULL)
 				NetworkUDPQueryServer(nd->server->info.hostname, nd->server->port);
 			break;
-		case 18: // NewGRF Settings
+		case NGWW_NEWGRF: // NewGRF Settings
 			if (nd->server != NULL) ShowNewGRFSettings(false, false, false, &nd->server->info.grfconfig);
 			break;
 
 	} break;
 
-	case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
+	case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list
 		switch (e->we.dropdown.button) {
-			case 5:
+			case NGWW_CONN_BTN:
 				_network_lan_internet = e->we.dropdown.index;
 				break;
+			default:
+				NOT_REACHED();
 		}
 
 		SetWindowDirty(w);
 		break;
 
 	case WE_MOUSELOOP:
-		if (nd->field == 3) HandleEditBox(w, &WP(w, network_ql_d).q, 3);
+		if (nd->field == NGWW_PLAYER) HandleEditBox(w, &WP(w, network_ql_d).q, NGWW_PLAYER);
 		break;
 
 	case WE_MESSAGE:
@@ -470,9 +510,9 @@
 		break;
 
 	case WE_KEYPRESS:
-		if (nd->field != 3) {
+		if (nd->field != NGWW_PLAYER) {
 			if (nd->server != NULL) {
-				if (e->we.keypress.keycode == WKC_DELETE) { /* Press 'delete' to remove servers */
+				if (e->we.keypress.keycode == WKC_DELETE) { // Press 'delete' to remove servers
 					NetworkGameListRemoveItem(nd->server);
 					NetworkRebuildHostList();
 					nd->server = NULL;
@@ -481,9 +521,9 @@
 			break;
 		}
 
-		if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, 3, e) == 1) break; // enter pressed
+		if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, NGWW_PLAYER, e) == 1) break; // enter pressed
 
-		// The name is only allowed when it starts with a letter!
+		/* The name is only allowed when it starts with a letter! */
 		if (_edit_str_buf[0] != '\0' && _edit_str_buf[0] != ' ') {
 			ttd_strlcpy(_network_player_name, _edit_str_buf, lengthof(_network_player_name));
 		} else {
@@ -500,57 +540,61 @@
 	case WE_RESIZE: {
 		w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
 
-		w->widget[9].data = (w->vscroll.cap << 8) + 1;
+		w->widget[NGWW_MATRIX].data = (w->vscroll.cap << 8) + 1;
 
-		int widget_width = w->widget[11].right - w->widget[11].left;
+		SetVScrollCount(w, ld->list_length);
+
+		int widget_width = w->widget[NGWW_FIND].right - w->widget[NGWW_FIND].left;
 		int space = (w->width - 4 * widget_width - 25) / 3;
 
 		int offset = 10;
 		for (uint i = 0; i < 4; i++) {
-			w->widget[11 + i].left  = offset;
+			w->widget[NGWW_FIND + i].left  = offset;
 			offset += widget_width;
-			w->widget[11 + i].right = offset;
+			w->widget[NGWW_FIND + i].right = offset;
 			offset += space;
 		}
 	} break;
 
-	case WE_DESTROY: /* Nicely clean up the sort-list */
+	case WE_DESTROY: // Nicely clean up the sort-list
 		free(WP(w, network_ql_d).sort_list);
 		break;
 	}
 }
 
 static const Widget _network_game_window_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
+/* TOP */
+{   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},            // NGWW_CLOSE
 {    WWT_CAPTION,   RESIZE_RIGHT,  BGC,    11,   449,     0,    13, STR_NETWORK_MULTIPLAYER,        STR_NULL},
 {      WWT_PANEL,   RESIZE_RB,     BGC,     0,   449,    14,   263, 0x0,                            STR_NULL},
 
-/* LEFT SIDE */
-{      WWT_PANEL,   RESIZE_LR,     BGC,   290,   440,    22,    33, 0x0,                            STR_NETWORK_ENTER_NAME_TIP},
-
-{      WWT_INSET,   RESIZE_NONE,   BGC,    90,   181,    22,    33, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP},
-{    WWT_TEXTBTN,   RESIZE_NONE,   BGC,   170,   180,    23,    32, STR_0225,                       STR_NETWORK_CONNECTION_TIP},
+{       WWT_TEXT,   RESIZE_NONE,   BGC,     9,    85,    23,    35, STR_NETWORK_CONNECTION,         STR_NULL},
+{      WWT_INSET,   RESIZE_NONE,   BGC,    90,   181,    22,    33, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP},       // NGWW_CONN_TXT
+{    WWT_TEXTBTN,   RESIZE_NONE,   BGC,   170,   180,    23,    32, STR_0225,                       STR_NETWORK_CONNECTION_TIP},       // NGWW_CONN_BTN
 
-{ WWT_PUSHTXTBTN,   RESIZE_RIGHT,  BTC,    10,    70,    42,    53, STR_NETWORK_GAME_NAME,          STR_NETWORK_GAME_NAME_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_LR,     BTC,    71,   150,    42,    53, STR_NETWORK_CLIENTS_CAPTION,    STR_NETWORK_CLIENTS_CAPTION_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_LR,     BTC,   151,   190,    42,    53, STR_EMPTY,                      STR_NETWORK_INFO_ICONS_TIP},
+{      WWT_PANEL,   RESIZE_LR,     BGC,   290,   440,    22,    33, 0x0,                            STR_NETWORK_ENTER_NAME_TIP},       // NGWW_PLAYER
 
-{     WWT_MATRIX,   RESIZE_RB,     BGC,    10,   190,    54,   236, (13 << 8) + 1,                  STR_NETWORK_CLICK_GAME_TO_SELECT},
-{  WWT_SCROLLBAR,   RESIZE_LRB,    BGC,   191,   202,    42,   236, STR_NULL,                       STR_0190_SCROLL_BAR_SCROLLS_LIST},
+/* LEFT SIDE */
+{ WWT_PUSHTXTBTN,   RESIZE_RIGHT,  BTC,    10,    70,    42,    53, STR_NETWORK_GAME_NAME,          STR_NETWORK_GAME_NAME_TIP},        // NGWW_NAME
+{ WWT_PUSHTXTBTN,   RESIZE_LR,     BTC,    71,   150,    42,    53, STR_NETWORK_CLIENTS_CAPTION,    STR_NETWORK_CLIENTS_CAPTION_TIP},  // NGWW_CLIENTS
+{ WWT_PUSHTXTBTN,   RESIZE_LR,     BTC,   151,   190,    42,    53, STR_EMPTY,                      STR_NETWORK_INFO_ICONS_TIP},       // NGWW_INFO
 
-{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,    10,   110,   246,   257, STR_NETWORK_FIND_SERVER,        STR_NETWORK_FIND_SERVER_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   118,   218,   246,   257, STR_NETWORK_ADD_SERVER,         STR_NETWORK_ADD_SERVER_TIP},
+{     WWT_MATRIX,   RESIZE_RB,     BGC,    10,   190,    54,   236, (13 << 8) + 1,                  STR_NETWORK_CLICK_GAME_TO_SELECT}, // NGWW_MATRIX
+{  WWT_SCROLLBAR,   RESIZE_LRB,    BGC,   191,   202,    42,   236, 0x0,                            STR_0190_SCROLL_BAR_SCROLLS_LIST},
 
 /* RIGHT SIDE */
-{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   226,   326,   246,   257, STR_NETWORK_START_SERVER,       STR_NETWORK_START_SERVER_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   334,   434,   246,   257, STR_012E_CANCEL,                STR_NULL},
+{      WWT_PANEL,   RESIZE_LRB,    BGC,   210,   440,    42,   236, 0x0,                            STR_NULL},                         // NGWW_DETAILS
 
-{      WWT_PANEL,   RESIZE_LRB,    BGC,   210,   440,    42,   236, 0x0,                            STR_NULL},
+{ WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   215,   315,   215,   226, STR_NETWORK_JOIN_GAME,          STR_NULL},                         // NGWW_JOIN
+{ WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   330,   435,   215,   226, STR_NETWORK_REFRESH,            STR_NETWORK_REFRESH_TIP},          // NGWW_REFRESH
 
-{ WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   215,   315,   215,   226, STR_NETWORK_JOIN_GAME,          STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   330,   435,   215,   226, STR_NETWORK_REFRESH,            STR_NETWORK_REFRESH_TIP},
+{ WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   330,   435,   197,   208, STR_NEWGRF_SETTINGS_BUTTON,     STR_NULL},                         // NGWW_NEWGRF
 
-{ WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   330,   435,   197,   208, STR_NEWGRF_SETTINGS_BUTTON,     STR_NULL},
+/* BOTTOM */
+{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,    10,   110,   246,   257, STR_NETWORK_FIND_SERVER,        STR_NETWORK_FIND_SERVER_TIP},      // NGWW_FIND
+{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   118,   218,   246,   257, STR_NETWORK_ADD_SERVER,         STR_NETWORK_ADD_SERVER_TIP},       // NGWW_ADD
+{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   226,   326,   246,   257, STR_NETWORK_START_SERVER,       STR_NETWORK_START_SERVER_TIP},     // NGWW_START
+{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   334,   434,   246,   257, STR_012E_CANCEL,                STR_NULL},                         // NGWW_CANCEL
 
 {  WWT_RESIZEBOX,   RESIZE_LRTB,   BGC,   438,   449,   252,   263, 0x0,                            STR_RESIZE_BUTTON },
 
@@ -602,14 +646,46 @@
 	NSSWND_ROWSIZE = 12
 };
 
-/* Uses network_ql_d (network_d, querystr_d and list_d) WP macro */
+/** Enum for NetworkStartServerWindow, referring to _network_start_server_window_widgets */
+enum NetworkStartServerWidgets {
+	NSSW_CLOSE           =  0,   ///< Close 'X' button
+	NSSW_GAMENAME        =  4,   ///< Background for editbox to set game name
+	NSSW_SETPWD          =  5,   ///< 'Set password' button
+	NSSW_SELMAP          =  7,   ///< 'Select map' list
+	NSSW_CONNTYPE_TXT    = 10,   ///< 'Connection type' droplist
+	NSSW_CONNTYPE_BTN    = 11,   ///< 'Connection type' droplist button
+	NSSW_CLIENTS_BTND    = 13,   ///< 'Max clients' downarrow
+	NSSW_CLIENTS_TXT     = 14,   ///< 'Max clients' text
+	NSSW_CLIENTS_BTNU    = 15,   ///< 'Max clients' uparrow
+	NSSW_COMPANIES_BTND  = 17,   ///< 'Max companies' downarrow
+	NSSW_COMPANIES_TXT   = 18,   ///< 'Max companies' text
+	NSSW_COMPANIES_BTNU  = 19,   ///< 'Max companies' uparrow
+	NSSW_SPECTATORS_BTND = 21,   ///< 'Max spectators' downarrow
+	NSSW_SPECTATORS_TXT  = 22,   ///< 'Max spectators' text
+	NSSW_SPECTATORS_BTNU = 23,   ///< 'Max spectators' uparrow
+	NSSW_LANGUAGE_TXT    = 25,   ///< 'Language spoken' droplist
+	NSSW_LANGUAGE_BTN    = 26,   ///< 'Language spoken' droplist button
+	NSSW_START           = 27,   ///< 'Start' button
+	NSSW_LOAD            = 28,   ///< 'Load' button
+	NSSW_CANCEL          = 29,   ///< 'Cancel' button
+};
+
+/**
+ * Handler of actions done in the NetworkStartServer window
+ *
+ * @param w pointer to the Window structure
+ * @param e pointer to window event
+ * @note    Uses network_ql_d (network_d, querystr_d and list_d) WP macro
+ * @see     struct _network_start_server_window_widgets
+ * @see     enum NetworkStartServerWidgets
+ */
 static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
 {
 	network_d *nd = &WP(w, network_ql_d).n;
 
 	switch (e->event) {
-	case WE_CREATE: /* focus input box */
-		nd->field = 3;
+	case WE_CREATE: // focus input box
+		nd->field = NSSW_GAMENAME;
 		_network_game_info.use_password = (_network_server_password[0] != '\0');
 		break;
 
@@ -617,6 +693,7 @@
 		int y = NSSWND_START, pos;
 		const FiosItem *item;
 
+		/* draw basic widgets */
 		SetDParam(1, _connection_types_dropdown[_network_advertise]);
 		SetDParam(2, _network_game_info.clients_max);
 		SetDParam(3, _network_game_info.companies_max);
@@ -624,22 +701,15 @@
 		SetDParam(5, STR_NETWORK_LANG_ANY + _network_game_info.server_lang);
 		DrawWindowWidgets(w);
 
-		GfxFillRect(11, 63, 258, 215, 0xD7);
-		DrawEditBox(w, &WP(w, network_ql_d).q, 3);
-
-		DrawString(10, 22, STR_NETWORK_NEW_GAME_NAME, TC_GOLD);
+		/* editbox to set game name */
+		DrawEditBox(w, &WP(w, network_ql_d).q, NSSW_GAMENAME);
 
-		DrawString(10, 43, STR_NETWORK_SELECT_MAP, TC_GOLD);
-
-		DrawString(280,  63, STR_NETWORK_CONNECTION, TC_GOLD);
-		DrawString(280,  95, STR_NETWORK_NUMBER_OF_CLIENTS, TC_GOLD);
-		DrawString(280, 127, STR_NETWORK_NUMBER_OF_COMPANIES, TC_GOLD);
-		DrawString(280, 159, STR_NETWORK_NUMBER_OF_SPECTATORS, TC_GOLD);
-		DrawString(280, 191, STR_NETWORK_LANGUAGE_SPOKEN, TC_GOLD);
-
+		/* if password is set, draw red '*' next to 'Set password' button */
 		if (_network_game_info.use_password) DoDrawString("*", 408, 23, TC_RED);
 
-		// draw list of maps
+		/* draw list of maps */
+		GfxFillRect(11, 63, 258, 215, 0xD7);  // black background of maps list
+
 		pos = w->vscroll.pos;
 		while (pos < _fios_num + 1) {
 			item = _fios_list + pos - 1;
@@ -661,17 +731,17 @@
 	case WE_CLICK:
 		nd->field = e->we.click.widget;
 		switch (e->we.click.widget) {
-		case 0: /* Close 'X' */
-		case 22: /* Cancel button */
+		case NSSW_CLOSE:  // Close 'X'
+		case NSSW_CANCEL: // Cancel button
 			ShowNetworkGameWindow();
 			break;
 
-		case 4: /* Set password button */
-			nd->widget_id = 4;
+		case NSSW_SETPWD: // Set password button
+			nd->widget_id = NSSW_SETPWD;
 			ShowQueryString(BindCString(_network_server_password), STR_NETWORK_SET_PASSWORD, 20, 250, w, CS_ALPHANUMERAL);
 			break;
 
-		case 5: { /* Select map */
+		case NSSW_SELMAP: { // Select map
 			int y = (e->we.click.pt.y - NSSWND_START) / NSSWND_ROWSIZE;
 
 			y += w->vscroll.pos;
@@ -680,41 +750,47 @@
 			nd->map = (y == 0) ? NULL : _fios_list + y - 1;
 			SetWindowDirty(w);
 			} break;
-		case 7: case 8: /* Connection type */
-			ShowDropDownMenu(w, _connection_types_dropdown, _network_advertise, 8, 0, 0); // do it for widget 8
+		case NSSW_CONNTYPE_TXT: case NSSW_CONNTYPE_BTN: // Connection type
+			ShowDropDownMenu(w, _connection_types_dropdown, _network_advertise, NSSW_CONNTYPE_BTN, 0, 0); // do it for widget NSSW_CONNTYPE_BTN
 			break;
-		case  9: case 11: // Click on up/down button for number of players
-		case 12: case 14: // Click on up/down button for number of companies
-		case 15: case 17: // Click on up/down button for number of spectators
+		case NSSW_CLIENTS_BTND:    case NSSW_CLIENTS_BTNU:    // Click on up/down button for number of clients
+		case NSSW_COMPANIES_BTND:  case NSSW_COMPANIES_BTNU:  // Click on up/down button for number of companies
+		case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators
 			/* Don't allow too fast scrolling */
 			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
-				HandleButtonClick(w, e->we.click.widget);
+				w->HandleButtonClick(e->we.click.widget);
 				SetWindowDirty(w);
 				switch (e->we.click.widget) {
 					default: NOT_REACHED();
-					case  9: case 11: _network_game_info.clients_max    = Clamp(_network_game_info.clients_max    + e->we.click.widget - 10, 2, MAX_CLIENTS); break;
-					case 12: case 14: _network_game_info.companies_max  = Clamp(_network_game_info.companies_max  + e->we.click.widget - 13, 1, MAX_PLAYERS); break;
-					case 15: case 17: _network_game_info.spectators_max = Clamp(_network_game_info.spectators_max + e->we.click.widget - 16, 0, MAX_CLIENTS); break;
+					case NSSW_CLIENTS_BTND: case NSSW_CLIENTS_BTNU:
+						_network_game_info.clients_max    = Clamp(_network_game_info.clients_max    + e->we.click.widget - NSSW_CLIENTS_TXT,    2, MAX_CLIENTS);
+						break;
+					case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU:
+						_network_game_info.companies_max  = Clamp(_network_game_info.companies_max  + e->we.click.widget - NSSW_COMPANIES_TXT,  1, MAX_PLAYERS);
+						break;
+					case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU:
+						_network_game_info.spectators_max = Clamp(_network_game_info.spectators_max + e->we.click.widget - NSSW_SPECTATORS_TXT, 0, MAX_CLIENTS);
+						break;
 				}
 			}
 			_left_button_clicked = false;
 			break;
-		case 10: // Click on number of players
-			nd->widget_id = 10;
+		case NSSW_CLIENTS_TXT:    // Click on number of players
+			nd->widget_id = NSSW_CLIENTS_TXT;
 			SetDParam(0, _network_game_info.clients_max);
-			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_CLIENTS, 3, 50, w, CS_NUMERAL);
+			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_CLIENTS,    3, 50, w, CS_NUMERAL);
 			break;
-		case 13: // Click on number of companies
-			nd->widget_id = 13;
+		case NSSW_COMPANIES_TXT:  // Click on number of companies
+			nd->widget_id = NSSW_COMPANIES_TXT;
 			SetDParam(0, _network_game_info.companies_max);
-			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_COMPANIES, 3, 50, w, CS_NUMERAL);
+			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_COMPANIES,  3, 50, w, CS_NUMERAL);
 			break;
-		case 16: // Click on number of companies
-			nd->widget_id = 16;
+		case NSSW_SPECTATORS_TXT: // Click on number of spectators
+			nd->widget_id = NSSW_SPECTATORS_TXT;
 			SetDParam(0, _network_game_info.spectators_max);
 			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_SPECTATORS, 3, 50, w, CS_NUMERAL);
 			break;
-		case 18: case 19: { /* Language */
+		case NSSW_LANGUAGE_TXT: case NSSW_LANGUAGE_BTN: { // Language
 			uint sel = 0;
 			for (uint i = 0; i < lengthof(_language_dropdown) - 1; i++) {
 				if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _network_game_info.server_lang) {
@@ -722,10 +798,10 @@
 					break;
 				}
 			}
-			ShowDropDownMenu(w, _language_dropdown, sel, 19, 0, 0);
+			ShowDropDownMenu(w, _language_dropdown, sel, NSSW_LANGUAGE_BTN, 0, 0);
 			break;
 		}
-		case 20: /* Start game */
+		case NSSW_START: // Start game
 			_is_network_server = true;
 
 			if (nd->map == NULL) { // start random new game
@@ -734,6 +810,7 @@
 				char *name = FiosBrowseTo(nd->map);
 				if (name != NULL) {
 					SetFiosType(nd->map->type);
+					_file_to_saveload.filetype = FT_SCENARIO;
 					ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
 					ttd_strlcpy(_file_to_saveload.title, nd->map->title, sizeof(_file_to_saveload.title));
 
@@ -742,37 +819,38 @@
 				}
 			}
 			break;
-		case 21: /* Load game */
+		case NSSW_LOAD: // Load game
 			_is_network_server = true;
-			/* XXX - WC_NETWORK_WINDOW should stay, but if it stays, it gets
+			/* XXX - WC_NETWORK_WINDOW (this window) should stay, but if it stays, it gets
 			 * copied all the elements of 'load game' and upon closing that, it segfaults */
-			DeleteWindowById(WC_NETWORK_WINDOW, 0);
+			DeleteWindow(w);
 			ShowSaveLoadDialog(SLD_LOAD_GAME);
 			break;
 		}
 		break;
 
-	case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
+	case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list
 		switch (e->we.dropdown.button) {
-			case  8: _network_advertise                = (e->we.dropdown.index != 0); break;
-			case 10: _network_game_info.clients_max    = e->we.dropdown.index;        break;
-			case 12: _network_game_info.companies_max  = e->we.dropdown.index;        break;
-			case 14: _network_game_info.spectators_max = e->we.dropdown.index;        break;
-			case 16:
+			case NSSW_CONNTYPE_BTN:
+				_network_advertise = (e->we.dropdown.index != 0);
+				break;
+			case NSSW_LANGUAGE_BTN:
 				_network_game_info.server_lang = _language_dropdown[e->we.dropdown.index] - STR_NETWORK_LANG_ANY;
 				break;
+			default:
+				NOT_REACHED();
 		}
 
 		SetWindowDirty(w);
 		break;
 
 	case WE_MOUSELOOP:
-		if (nd->field == 3) HandleEditBox(w, &WP(w, network_ql_d).q, 3);
+		if (nd->field == NSSW_GAMENAME) HandleEditBox(w, &WP(w, network_ql_d).q, NSSW_GAMENAME);
 		break;
 
 	case WE_KEYPRESS:
-		if (nd->field == 3) {
-			if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, 3, e) == 1) break; // enter pressed
+		if (nd->field == NSSW_GAMENAME) {
+			if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, NSSW_GAMENAME, e) == 1) break; // enter pressed
 
 			ttd_strlcpy(_network_server_name, WP(w, network_ql_d).q.text.buf, sizeof(_network_server_name));
 		}
@@ -781,17 +859,17 @@
 	case WE_ON_EDIT_TEXT:
 		if (e->we.edittext.str == NULL) break;
 
-		if (nd->widget_id == 4) {
+		if (nd->widget_id == NSSW_SETPWD) {
 			ttd_strlcpy(_network_server_password, e->we.edittext.str, lengthof(_network_server_password));
 			_network_game_info.use_password = (_network_server_password[0] != '\0');
 		} else {
 			int32 value = atoi(e->we.edittext.str);
-			InvalidateWidget(w, nd->widget_id);
+			w->InvalidateWidget(nd->widget_id);
 			switch (nd->widget_id) {
 				default: NOT_REACHED();
-				case 10: _network_game_info.clients_max    = Clamp(value, 2, MAX_CLIENTS); break;
-				case 13: _network_game_info.companies_max  = Clamp(value, 1, MAX_PLAYERS); break;
-				case 16: _network_game_info.spectators_max = Clamp(value, 0, MAX_CLIENTS); break;
+				case NSSW_CLIENTS_TXT:    _network_game_info.clients_max    = Clamp(value, 2, MAX_CLIENTS); break;
+				case NSSW_COMPANIES_TXT:  _network_game_info.companies_max  = Clamp(value, 1, MAX_PLAYERS); break;
+				case NSSW_SPECTATORS_TXT: _network_game_info.spectators_max = Clamp(value, 0, MAX_CLIENTS); break;
 			}
 		}
 
@@ -801,34 +879,50 @@
 }
 
 static const Widget _network_start_server_window_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW },
-{    WWT_CAPTION,   RESIZE_NONE,   BGC,    11,   419,     0,    13, STR_NETWORK_START_GAME_WINDOW,  STR_NULL},
-{      WWT_PANEL,   RESIZE_NONE,   BGC,     0,   419,    14,   243, 0x0,                            STR_NULL},
+/* Window decoration and background panel */
+{   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW },               // NSSW_CLOSE
+{    WWT_CAPTION,   RESIZE_NONE,   BGC,    11,   419,     0,    13, STR_NETWORK_START_GAME_WINDOW,    STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,   BGC,     0,   419,    14,   243, 0x0,                              STR_NULL},
 
-{      WWT_PANEL,   RESIZE_NONE,   BGC,   100,   272,    22,    33, 0x0,                            STR_NETWORK_NEW_GAME_NAME_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   285,   405,    22,    33, STR_NETWORK_SET_PASSWORD,       STR_NETWORK_PASSWORD_TIP},
+/* Set game name and password widgets */
+{       WWT_TEXT,   RESIZE_NONE,   BGC,    10,    90,    22,    34, STR_NETWORK_NEW_GAME_NAME,        STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,   BGC,   100,   272,    22,    33, 0x0,                              STR_NETWORK_NEW_GAME_NAME_TIP},        // NSSW_GAMENAME
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   285,   405,    22,    33, STR_NETWORK_SET_PASSWORD,         STR_NETWORK_PASSWORD_TIP},             // NSSW_SETPWD
 
-{      WWT_INSET,   RESIZE_NONE,   BGC,    10,   271,    62,   216, 0x0,                            STR_NETWORK_SELECT_MAP_TIP},
-{  WWT_SCROLLBAR,   RESIZE_NONE,   BGC,   259,   270,    63,   215, 0x0,                            STR_0190_SCROLL_BAR_SCROLLS_LIST},
+/* List of playable scenarios */
+{       WWT_TEXT,   RESIZE_NONE,   BGC,    10,   110,    43,    55, STR_NETWORK_SELECT_MAP,           STR_NULL},
+{      WWT_INSET,   RESIZE_NONE,   BGC,    10,   271,    62,   216, STR_NULL,                         STR_NETWORK_SELECT_MAP_TIP},           // NSSW_SELMAP
+{  WWT_SCROLLBAR,   RESIZE_NONE,   BGC,   259,   270,    63,   215, 0x0,                              STR_0190_SCROLL_BAR_SCROLLS_LIST},
+
 /* Combo/selection boxes to control Connection Type / Max Clients / Max Companies / Max Observers / Language */
-{      WWT_INSET,   RESIZE_NONE,   BGC,   280,   410,    77,    88, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP},
-{    WWT_TEXTBTN,   RESIZE_NONE,   BGC,   399,   409,    78,    87, STR_0225,                       STR_NETWORK_CONNECTION_TIP},
-{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   280,   291,   109,   120, SPR_ARROW_DOWN,                 STR_NETWORK_NUMBER_OF_CLIENTS_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BGC,   292,   397,   109,   120, STR_NETWORK_CLIENTS_SELECT,     STR_NETWORK_NUMBER_OF_CLIENTS_TIP},
-{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   398,   410,   109,   120, SPR_ARROW_UP,                   STR_NETWORK_NUMBER_OF_CLIENTS_TIP},
-{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   280,   291,   141,   152, SPR_ARROW_DOWN,                 STR_NETWORK_NUMBER_OF_COMPANIES_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BGC,   292,   397,   141,   152, STR_NETWORK_COMPANIES_SELECT,   STR_NETWORK_NUMBER_OF_COMPANIES_TIP},
-{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   398,   410,   141,   152, SPR_ARROW_UP,                   STR_NETWORK_NUMBER_OF_COMPANIES_TIP},
-{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   280,   291,   173,   184, SPR_ARROW_DOWN,                 STR_NETWORK_NUMBER_OF_SPECTATORS_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BGC,   292,   397,   173,   184, STR_NETWORK_SPECTATORS_SELECT,  STR_NETWORK_NUMBER_OF_SPECTATORS_TIP},
-{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   398,   410,   173,   184, SPR_ARROW_UP,                   STR_NETWORK_NUMBER_OF_SPECTATORS_TIP},
+{       WWT_TEXT,   RESIZE_NONE,   BGC,   280,   419,    63,    75, STR_NETWORK_CONNECTION,           STR_NULL},
+{      WWT_INSET,   RESIZE_NONE,   BGC,   280,   410,    77,    88, STR_NETWORK_LAN_INTERNET_COMBO,   STR_NETWORK_CONNECTION_TIP},           // NSSW_CONNTYPE_TXT
+{    WWT_TEXTBTN,   RESIZE_NONE,   BGC,   399,   409,    78,    87, STR_0225,                         STR_NETWORK_CONNECTION_TIP},           // NSSW_CONNTYPE_BTN
 
-{      WWT_INSET,   RESIZE_NONE,   BGC,   280,   410,   205,   216, STR_NETWORK_LANGUAGE_COMBO,     STR_NETWORK_LANGUAGE_TIP},
-{    WWT_TEXTBTN,   RESIZE_NONE,   BGC,   399,   409,   206,   215, STR_0225,                       STR_NETWORK_LANGUAGE_TIP},
+{       WWT_TEXT,   RESIZE_NONE,   BGC,   280,   419,    95,   107, STR_NETWORK_NUMBER_OF_CLIENTS,    STR_NULL},
+{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   280,   291,   109,   120, SPR_ARROW_DOWN,                   STR_NETWORK_NUMBER_OF_CLIENTS_TIP},    // NSSW_CLIENTS_BTND
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BGC,   292,   397,   109,   120, STR_NETWORK_CLIENTS_SELECT,       STR_NETWORK_NUMBER_OF_CLIENTS_TIP},    // NSSW_CLIENTS_TXT
+{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   398,   410,   109,   120, SPR_ARROW_UP,                     STR_NETWORK_NUMBER_OF_CLIENTS_TIP},    // NSSW_CLIENTS_BTNU
 
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    40,   140,   224,   235, STR_NETWORK_START_GAME,         STR_NETWORK_START_GAME_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   150,   250,   224,   235, STR_NETWORK_LOAD_GAME,          STR_NETWORK_LOAD_GAME_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   260,   360,   224,   235, STR_012E_CANCEL,                STR_NULL},
+{       WWT_TEXT,   RESIZE_NONE,   BGC,   280,   419,   127,   139, STR_NETWORK_NUMBER_OF_COMPANIES,  STR_NULL},
+{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   280,   291,   141,   152, SPR_ARROW_DOWN,                   STR_NETWORK_NUMBER_OF_COMPANIES_TIP},  // NSSW_COMPANIES_BTND
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BGC,   292,   397,   141,   152, STR_NETWORK_COMPANIES_SELECT,     STR_NETWORK_NUMBER_OF_COMPANIES_TIP},  // NSSW_COMPANIES_TXT
+{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   398,   410,   141,   152, SPR_ARROW_UP,                     STR_NETWORK_NUMBER_OF_COMPANIES_TIP},  // NSSW_COMPANIES_BTNU
+
+{       WWT_TEXT,   RESIZE_NONE,   BGC,   280,   419,   159,   171, STR_NETWORK_NUMBER_OF_SPECTATORS, STR_NULL},
+{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   280,   291,   173,   184, SPR_ARROW_DOWN,                   STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, // NSSW_SPECTATORS_BTND
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BGC,   292,   397,   173,   184, STR_NETWORK_SPECTATORS_SELECT,    STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, // NSSW_SPECTATORS_TXT
+{     WWT_IMGBTN,   RESIZE_NONE,   BGC,   398,   410,   173,   184, SPR_ARROW_UP,                     STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, // NSSW_SPECTATORS_BTNU
+
+{       WWT_TEXT,   RESIZE_NONE,   BGC,   280,   419,   191,   203, STR_NETWORK_LANGUAGE_SPOKEN,      STR_NULL},
+{      WWT_INSET,   RESIZE_NONE,   BGC,   280,   410,   205,   216, STR_NETWORK_LANGUAGE_COMBO,       STR_NETWORK_LANGUAGE_TIP},             // NSSW_LANGUAGE_TXT
+{    WWT_TEXTBTN,   RESIZE_NONE,   BGC,   399,   409,   206,   215, STR_0225,                         STR_NETWORK_LANGUAGE_TIP},             // NSSW_LANGUAGE_BTN
+
+/* Buttons Start / Load / Cancel */
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    40,   140,   224,   235, STR_NETWORK_START_GAME,           STR_NETWORK_START_GAME_TIP},           // NSSW_START
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   150,   250,   224,   235, STR_NETWORK_LOAD_GAME,            STR_NETWORK_LOAD_GAME_TIP},            // NSSW_LOAD
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   260,   360,   224,   235, STR_012E_CANCEL,                  STR_NULL},                             // NSSW_CANCEL
+
 {   WIDGETS_END},
 };
 
@@ -872,7 +966,27 @@
 	return PLAYER_FIRST;
 }
 
-/* uses network_d WP macro */
+/** Enum for NetworkLobbyWindow, referring to _network_lobby_window_widgets */
+enum NetworkLobbyWindowWidgets {
+	NLWW_CLOSE    =  0, ///< Close 'X' button
+	NLWW_MATRIX   =  5, ///< List of companies
+	NLWW_DETAILS  =  7, ///< Company details
+	NLWW_JOIN     =  8, ///< 'Join company' button
+	NLWW_NEW      =  9, ///< 'New company' button
+	NLWW_SPECTATE = 10, ///< 'Spectate game' button
+	NLWW_REFRESH  = 11, ///< 'Refresh server' button
+	NLWW_CANCEL   = 12, ///< 'Cancel' button
+};
+
+/**
+ * Handler of actions done in the NetworkLobby window
+ *
+ * @param w pointer to the Window structure
+ * @param e pointer to window event
+ * @note    uses network_d WP macro
+ * @see     struct _network_lobby_window_widgets
+ * @see     enum NetworkLobbyWindowWidgets
+ */
 static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
 {
 	network_d *nd = &WP(w, network_d);
@@ -886,18 +1000,17 @@
 		const NetworkGameInfo *gi = &nd->server->info;
 		int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos;
 
-		SetWindowWidgetDisabledState(w, 7, nd->company == (byte)-1);
-		SetWindowWidgetDisabledState(w, 8, gi->companies_on >= gi->companies_max);
-		/* You can not join a server as spectator when it has no companies active..
-		 * it causes some nasty crashes */
-		SetWindowWidgetDisabledState(w, 9, gi->spectators_on >= gi->spectators_max ||
-				gi->companies_on == 0);
+		/* Join button is disabled when no company is selected */
+		w->SetWidgetDisabledState(NLWW_JOIN, nd->company == INVALID_PLAYER);
+		/* Cannot start new company if there are too many */
+		w->SetWidgetDisabledState(NLWW_NEW, gi->companies_on >= gi->companies_max);
+		/* Cannot spectate if there are too many spectators */
+		w->SetWidgetDisabledState(NLWW_SPECTATE, gi->spectators_on >= gi->spectators_max);
 
+		/* Draw window widgets */
+		SetDParamStr(0, gi->server_name);
 		DrawWindowWidgets(w);
 
-		SetDParamStr(0, gi->server_name);
-		DrawString(10, 22, STR_NETWORK_PREPARE_TO_JOIN, TC_GOLD);
-
 		/* Draw company list */
 		pos = w->vscroll.pos;
 		while (pos < gi->companies_on) {
@@ -921,9 +1034,9 @@
 		/* Draw info about selected company when it is selected in the left window */
 		GfxFillRect(174, 39, 403, 75, 157);
 		DrawStringCentered(290, 50, STR_NETWORK_COMPANY_INFO, TC_FROMSTRING);
-		if (nd->company != (byte)-1) {
+		if (nd->company != INVALID_PLAYER) {
 			const uint x = 183;
-			const uint trunc_width = w->widget[6].right - x;
+			const uint trunc_width = w->widget[NLWW_DETAILS].right - x;
 			y = 80;
 
 			SetDParam(0, nd->server->info.clients_on);
@@ -980,33 +1093,33 @@
 
 	case WE_CLICK:
 		switch (e->we.click.widget) {
-		case 0: case 11: /* Close 'X' | Cancel button */
+		case NLWW_CLOSE:    // Close 'X'
+		case NLWW_CANCEL:   // Cancel button
 			ShowNetworkGameWindow();
 			break;
-		case 4: { /* Company list */
+		case NLWW_MATRIX: { // Company list
 			uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET_COMPANY) / NET_PRC__SIZE_OF_ROW;
 
-			if (id_v >= w->vscroll.cap) return;
+			if (id_v >= w->vscroll.cap) break;
 
 			id_v += w->vscroll.pos;
 			nd->company = (id_v >= nd->server->info.companies_on) ? INVALID_PLAYER : NetworkLobbyFindCompanyIndex(id_v);
 			SetWindowDirty(w);
 		} break;
-		case 7: /* Join company */
-			if (nd->company != (byte)-1) {
-				_network_playas = nd->company;
-				NetworkClientConnectGame(_network_last_host, _network_last_port);
-			}
+		case NLWW_JOIN:     // Join company
+			/* Button can be clicked only when it is enabled */
+			_network_playas = nd->company;
+			NetworkClientConnectGame(_network_last_host, _network_last_port);
 			break;
-		case 8: /* New company */
+		case NLWW_NEW:      // New company
 			_network_playas = PLAYER_NEW_COMPANY;
 			NetworkClientConnectGame(_network_last_host, _network_last_port);
 			break;
-		case 9: /* Spectate game */
+		case NLWW_SPECTATE: // Spectate game
 			_network_playas = PLAYER_SPECTATOR;
 			NetworkClientConnectGame(_network_last_host, _network_last_port);
 			break;
-		case 10: /* Refresh */
+		case NLWW_REFRESH:  // Refresh
 			NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info
 			NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data
 			break;
@@ -1019,24 +1132,25 @@
 }
 
 static const Widget _network_lobby_window_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
-{    WWT_CAPTION,   RESIZE_NONE,   BGC,    11,   419,     0,    13, STR_NETWORK_GAME_LOBBY,    STR_NULL},
-{      WWT_PANEL,   RESIZE_NONE,   BGC,     0,   419,    14,   234, 0x0,                       STR_NULL},
-
-// company list
-{      WWT_PANEL,   RESIZE_NONE,   BTC,    10,   155,    38,    49, 0x0,                       STR_NULL},
-{     WWT_MATRIX,   RESIZE_NONE,   BGC,    10,   155,    50,   190, (10 << 8) + 1,             STR_NETWORK_COMPANY_LIST_TIP},
-{  WWT_SCROLLBAR,   RESIZE_NONE,   BGC,   156,   167,    38,   190, STR_NULL,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW },           // NLWW_CLOSE
+{    WWT_CAPTION,   RESIZE_NONE,   BGC,    11,   419,     0,    13, STR_NETWORK_GAME_LOBBY,      STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,   BGC,     0,   419,    14,   234, 0x0,                         STR_NULL},
+{       WWT_TEXT,   RESIZE_NONE,   BGC,    10,   419,    22,    34, STR_NETWORK_PREPARE_TO_JOIN, STR_NULL},
 
-// company/player info
-{      WWT_PANEL,   RESIZE_NONE,   BGC,   173,   404,    38,   190, 0x0,                       STR_NULL},
+/* company list */
+{      WWT_PANEL,   RESIZE_NONE,   BTC,    10,   155,    38,    49, 0x0,                         STR_NULL},
+{     WWT_MATRIX,   RESIZE_NONE,   BGC,    10,   155,    50,   190, (10 << 8) + 1,               STR_NETWORK_COMPANY_LIST_TIP},     // NLWW_MATRIX
+{  WWT_SCROLLBAR,   RESIZE_NONE,   BGC,   156,   167,    38,   190, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST},
 
-// buttons
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    10,   151,   200,   211, STR_NETWORK_JOIN_COMPANY,  STR_NETWORK_JOIN_COMPANY_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    10,   151,   215,   226, STR_NETWORK_NEW_COMPANY,   STR_NETWORK_NEW_COMPANY_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   158,   268,   200,   211, STR_NETWORK_SPECTATE_GAME, STR_NETWORK_SPECTATE_GAME_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   158,   268,   215,   226, STR_NETWORK_REFRESH,       STR_NETWORK_REFRESH_TIP},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   278,   388,   200,   211, STR_012E_CANCEL,           STR_NULL},
+/* company/player info */
+{      WWT_PANEL,   RESIZE_NONE,   BGC,   173,   404,    38,   190, 0x0,                         STR_NULL},                         // NLWW_DETAILS
+
+/* buttons */
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    10,   151,   200,   211, STR_NETWORK_JOIN_COMPANY,    STR_NETWORK_JOIN_COMPANY_TIP},     // NLWW_JOIN
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    10,   151,   215,   226, STR_NETWORK_NEW_COMPANY,     STR_NETWORK_NEW_COMPANY_TIP},      // NLWW_NEW
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   158,   268,   200,   211, STR_NETWORK_SPECTATE_GAME,   STR_NETWORK_SPECTATE_GAME_TIP},    // NLWW_SPECTATE
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   158,   268,   215,   226, STR_NETWORK_REFRESH,         STR_NETWORK_REFRESH_TIP},          // NLWW_REFRESH
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   278,   388,   200,   211, STR_012E_CANCEL,             STR_NULL},                         // NLWW_CANCEL
 
 {   WIDGETS_END},
 };
@@ -1294,10 +1408,10 @@
 	w->widget[0].right = w->widget[0].left + 150;
 
 	w->flags4 &= ~WF_WHITE_BORDER_MASK;
-	WP(w,menu_d).item_count = 0;
+	WP(w, menu_d).item_count = 0;
 	// Save our client
-	WP(w,menu_d).main_button = client_no;
-	WP(w,menu_d).sel_index = 0;
+	WP(w, menu_d).main_button = client_no;
+	WP(w, menu_d).sel_index = 0;
 	// We are a popup
 	_popup_menu_active = true;
 
@@ -1315,7 +1429,7 @@
 		DrawWindowWidgets(w);
 
 		// Draw the actions
-		sel = WP(w,menu_d).sel_index;
+		sel = WP(w, menu_d).sel_index;
 		y = 1;
 		for (i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) {
 			if (_clientlist_action[i][0] == '\0') continue;
@@ -1337,7 +1451,7 @@
 		int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE;
 
 		if (index >= 0 && e->we.popupmenu.pt.y >= w->top)
-			HandleClientListPopupClick(index, WP(w,menu_d).main_button);
+			HandleClientListPopupClick(index, WP(w, menu_d).main_button);
 
 		DeleteWindowById(WC_TOOLBAR_MENU, 0);
 	} break;
@@ -1346,9 +1460,9 @@
 		// Our mouse hoovers over an action? Select it!
 		int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE;
 
-		if (index == -1 || index == WP(w,menu_d).sel_index) return;
+		if (index == -1 || index == WP(w, menu_d).sel_index) return;
 
-		WP(w,menu_d).sel_index = index;
+		WP(w, menu_d).sel_index = index;
 		SetWindowDirty(w);
 	} break;
 
@@ -1770,11 +1884,106 @@
 
 	w = AllocateWindowDesc(&_chat_window_desc);
 
-	LowerWindowWidget(w, 2);
+	w->LowerWidget(2);
 	WP(w, chatquerystr_d).caption = type; // Misuse of caption
 	WP(w, chatquerystr_d).dest    = dest;
 	WP(w, chatquerystr_d).afilter = CS_ALPHANUMERAL;
 	InitializeTextBuffer(&WP(w, chatquerystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 0);
 }
 
+/** Enum for NetworkGameWindow, referring to _network_game_window_widgets */
+enum NetworkCompanyPasswordWindowWidgets {
+	NCPWW_CLOSE,                    ///< Close 'X' button
+	NCPWW_CAPTION,                  ///< Caption of the whole window
+	NCPWW_BACKGROUND,               ///< The background of the interface
+	NCPWW_LABEL,                    ///< Label in front of the password field
+	NCPWW_PASSWORD,                 ///< Input field for the password
+	NCPWW_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password
+	NCPWW_CANCEL,                   ///< Close the window without changing anything
+	NCPWW_OK,                       ///< Safe the password etc.
+};
+
+static void NetworkCompanyPasswordWindowWndProc(Window *w, WindowEvent *e)
+{
+	switch (e->event) {
+		case WE_PAINT:
+			DrawWindowWidgets(w);
+			DrawEditBox(w, &WP(w, chatquerystr_d), 4);
+			break;
+
+		case WE_CLICK:
+			switch (e->we.click.widget) {
+				case NCPWW_OK: {
+					if (w->IsWidgetLowered(NCPWW_SAVE_AS_DEFAULT_PASSWORD)) {
+						snprintf(_network_default_company_pass, lengthof(_network_default_company_pass), "%s", _edit_str_buf);
+					}
+
+					/* empty password is a '*' because of console argument */
+					if (StrEmpty(_edit_str_buf)) snprintf(_edit_str_buf, lengthof(_edit_str_buf), "*");
+					char *password = _edit_str_buf;
+					NetworkChangeCompanyPassword(1, &password);
+				}
+
+				/* FALL THROUGH */
+				case NCPWW_CANCEL:
+					DeleteWindow(w);
+					break;
+
+				case NCPWW_SAVE_AS_DEFAULT_PASSWORD:
+					w->ToggleWidgetLoweredState(NCPWW_SAVE_AS_DEFAULT_PASSWORD);
+					SetWindowDirty(w);
+					break;
+			}
+			break;
+
+		case WE_MOUSELOOP:
+			HandleEditBox(w, &WP(w, chatquerystr_d), 4);
+			break;
+
+		case WE_KEYPRESS:
+			switch (HandleEditBoxKey(w, &WP(w, chatquerystr_d), 4, e)) {
+				case 1: // Return
+					e->event = WE_CLICK;
+					e->we.click.widget = NCPWW_OK;
+					NetworkCompanyPasswordWindowWndProc(w, e);
+					break;
+
+				case 2: // Escape
+					DeleteWindow(w);
+					break;
+			}
+			break;
+	}
+}
+
+static const Widget _ncp_window_widgets[] = {
+{   WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,  0, 13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
+{    WWT_CAPTION, RESIZE_NONE, 14,  11, 299,  0, 13, STR_COMPANY_PASSWORD_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
+{      WWT_PANEL, RESIZE_NONE, 14,   0, 299, 14, 50, 0x0,                               STR_NULL},
+{       WWT_TEXT, RESIZE_NONE, 14,   5, 100, 19, 30, STR_COMPANY_PASSWORD,              STR_NULL},
+{      WWT_PANEL, RESIZE_NONE, 14, 101, 294, 19, 30, 0x0,                               STR_NULL},
+{    WWT_TEXTBTN, RESIZE_NONE, 14, 101, 294, 35, 46, STR_MAKE_DEFAULT_COMPANY_PASSWORD, STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP},
+{ WWT_PUSHTXTBTN, RESIZE_NONE, 14,   0, 149, 51, 62, STR_012E_CANCEL,                   STR_COMPANY_PASSWORD_CANCEL},
+{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 150, 299, 51, 62, STR_012F_OK,                       STR_COMPANY_PASSWORD_OK},
+{   WIDGETS_END},
+};
+
+static const WindowDesc _ncp_window_desc = {
+	WDP_AUTO, WDP_AUTO, 300, 63, 300, 63,
+	WC_COMPANY_PASSWORD_WINDOW, WC_NONE,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
+	_ncp_window_widgets,
+	NetworkCompanyPasswordWindowWndProc
+};
+
+void ShowNetworkCompanyPasswordWindow()
+{
+	DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0);
+
+	_edit_str_buf[0] = '\0';
+	Window *w = AllocateWindowDesc(&_ncp_window_desc);
+	WP(w, chatquerystr_d).afilter = CS_ALPHANUMERAL;
+	InitializeTextBuffer(&WP(w, chatquerystr_d).text, _edit_str_buf, min(lengthof(_network_default_company_pass), lengthof(_edit_str_buf)), 0);
+}
+
 #endif /* ENABLE_NETWORK */
--- a/src/network/network_gui.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -13,6 +13,7 @@
 void ShowJoinStatusWindow();
 void ShowNetworkGameWindow();
 void ShowClientList();
+void ShowNetworkCompanyPasswordWindow();
 
 #else /* ENABLE_NETWORK */
 /* Network function stubs when networking is disabled */
@@ -20,6 +21,7 @@
 static inline void ShowNetworkChatQueryWindow(byte desttype, int dest) {}
 static inline void ShowClientList() {}
 static inline void ShowNetworkGameWindow() {}
+static inline void ShowNetworkCompanyPasswordWindow() {}
 
 #endif /* ENABLE_NETWORK */
 
--- a/src/network/network_server.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network_server.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,26 +5,24 @@
 #include "../stdafx.h"
 #include "../openttd.h" // XXX StringID
 #include "../debug.h"
-#include "../string.h"
-#include "../strings.h"
+#include "../strings_func.h"
 #include "network_data.h"
 #include "core/tcp.h"
 #include "../train.h"
 #include "../aircraft.h"
-#include "../date.h"
+#include "../date_func.h"
 #include "table/strings.h"
-#include "../functions.h"
 #include "network_server.h"
 #include "network_udp.h"
 #include "../console.h"
-#include "../command.h"
+#include "../command_func.h"
 #include "../saveload.h"
-#include "../vehicle.h"
 #include "../station.h"
 #include "../variables.h"
 #include "../genworld.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
 #include "../fileio.h"
+#include "../string_func.h"
 
 // This file handles all the server-commands
 
@@ -224,6 +222,8 @@
 
 	Packet *p = NetworkSend_Init(PACKET_SERVER_NEED_PASSWORD);
 	p->Send_uint8(type);
+	p->Send_uint32(_patches.generation_seed);
+	p->Send_string(_network_unique_id);
 	cs->Send_Packet(p);
 }
 
@@ -247,6 +247,8 @@
 
 	p = NetworkSend_Init(PACKET_SERVER_WELCOME);
 	p->Send_uint16(cs->index);
+	p->Send_uint32(_patches.generation_seed);
+	p->Send_string(_network_unique_id);
 	cs->Send_Packet(p);
 
 		// Transmit info about all the active clients
--- a/src/network/network_udp.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/network/network_udp.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -11,14 +11,15 @@
 
 #include "../stdafx.h"
 #include "../debug.h"
-#include "../string.h"
 #include "network_data.h"
-#include "../date.h"
-#include "../map.h"
+#include "../date_func.h"
+#include "../map_func.h"
 #include "network_gamelist.h"
 #include "network_udp.h"
 #include "../variables.h"
 #include "../newgrf_config.h"
+#include "../core/endian_func.hpp"
+#include "../string_func.h"
 
 #include "core/udp.h"
 
--- a/src/newgrf.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,35 +8,26 @@
 
 #include "openttd.h"
 #include "debug.h"
-#include "gfx.h"
 #include "fileio.h"
-#include "functions.h"
 #include "engine.h"
 #include "spritecache.h"
 #include "station.h"
 #include "sprite.h"
 #include "newgrf.h"
 #include "variables.h"
-#include "string.h"
-#include "strings.h"
 #include "table/strings.h"
 #include "bridge.h"
 #include "town.h"
-#include "economy.h"
 #include "newgrf_engine.h"
-#include "vehicle.h"
 #include "newgrf_text.h"
 #include "table/sprites.h"
 #include "fontcache.h"
-#include "date.h"
 #include "currency.h"
 #include "landscape.h"
-#include "sound.h"
 #include "newgrf_config.h"
 #include "newgrf_house.h"
 #include "newgrf_sound.h"
 #include "newgrf_spritegroup.h"
-#include "helpers.hpp"
 #include "table/town_land.h"
 #include "cargotype.h"
 #include "industry.h"
@@ -48,6 +39,13 @@
 #include "table/landscape_sprite.h"
 #include "gfxinit.h"
 #include "fios.h"
+#include "rail.h"
+#include "strings_func.h"
+#include "gfx_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "string_func.h"
 
 /* TTDPatch extended GRF format codec
  * (c) Petr Baudis 2004 (GPL'd)
@@ -61,7 +59,6 @@
 
 static int _skip_sprites; // XXX
 static uint _file_index; // XXX
-SpriteID _coast_base;
 
 static GRFFile *_cur_grffile;
 GRFFile *_first_grffile;
@@ -274,12 +271,12 @@
 	TEXID_TO_STRINGID(0x006E, 0x008D, STR_QUANTITY_NOTHING);
 	TEXID_TO_STRINGID(0x008E, 0x00AD, STR_ABBREV_NOTHING);
 
-	/* Map building names according to our lang file changes
-	 * 0x200F = Tall Office Block, first house name in the original data, the one that TTDPatch stil uses
-	 * 0x201F = Old houses is the last house name.
-	 * OpenTTD does not have exactly the same order aymore, so, the code below allows
-	 * to compensate for the difference */
+	/* Map building names according to our lang file changes. There are several
+	 * ranges of house ids, all of which need to be remapped to allow newgrfs
+	 * to use original house names. */
 	TEXID_TO_STRINGID(0x200F, 0x201F, STR_200F_TALL_OFFICE_BLOCK);
+	TEXID_TO_STRINGID(0x2036, 0x2041, STR_2036_COTTAGES);
+	TEXID_TO_STRINGID(0x2059, 0x205C, STR_2059_IGLOO);
 
 	/* Same thing for industries, since the introduction of 4 new strings above STR_482A_PRODUCTION_LAST_MONTH */
 	TEXID_TO_STRINGID(0x482A, 0x483B, STR_482A_PRODUCTION_LAST_MONTH);
@@ -952,6 +949,18 @@
 						ClrBit(dts->ground_pal, 15);
 						SetBit(dts->ground_sprite, SPRITE_MODIFIER_USE_OFFSET);
 					}
+					if (HasBit(dts->ground_pal, 14)) {
+						ClrBit(dts->ground_pal, 14);
+						SetBit(dts->ground_sprite, SPRITE_MODIFIER_OPAQUE);
+					}
+					if (HasBit(dts->ground_sprite, 15)) {
+						ClrBit(dts->ground_sprite, 15);
+						SetBit(dts->ground_sprite, PALETTE_MODIFIER_COLOR);
+					}
+					if (HasBit(dts->ground_sprite, 14)) {
+						ClrBit(dts->ground_sprite, 14);
+						SetBit(dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT);
+					}
 
 					while (buf < *bufp + len) {
 						DrawTileSeqStruct *dtss;
@@ -975,6 +984,10 @@
 							ClrBit(dtss->pal, 15);
 							SetBit(dtss->image, SPRITE_MODIFIER_USE_OFFSET);
 						}
+						if (HasBit(dtss->pal, 14)) {
+							ClrBit(dtss->pal, 14);
+							SetBit(dtss->image, SPRITE_MODIFIER_OPAQUE);
+						}
 
 						if (HasBit(dtss->image, 15)) {
 							ClrBit(dtss->image, 15);
@@ -1768,6 +1781,13 @@
 
 					memcpy(tsp, &_industry_tile_specs[subs_id], sizeof(_industry_tile_specs[subs_id]));
 					tsp->enabled = true;
+
+					/* A copied tile should not have the animation infos copied too.
+					 * The anim_state should be left untouched, though
+					 * It is up to the author to animate them himself */
+					tsp->anim_production = INDUSTRYTILE_NOANIM;
+					tsp->anim_next = INDUSTRYTILE_NOANIM;
+
 					tsp->grf_prop.local_id = indtid + i;
 					tsp->grf_prop.subst_id = subs_id;
 					tsp->grf_prop.grffile = _cur_grffile;
@@ -1791,7 +1811,7 @@
 			case 0x0B:
 			case 0x0C: {
 				uint16 acctp = grf_load_word(&buf);
-				tsp->accepts_cargo[prop - 0x0A] = GB(acctp, 0, 8);
+				tsp->accepts_cargo[prop - 0x0A] = GetCargoTranslation(GB(acctp, 0, 8), _cur_grffile);
 				tsp->acceptance[prop - 0x0A] = GB(acctp, 8, 8);
 			} break;
 
@@ -1991,13 +2011,13 @@
 
 			case 0x10: // Production cargo types
 				for (byte j = 0; j < 2; j++) {
-					indsp->produced_cargo[j] = grf_load_byte(&buf);
+					indsp->produced_cargo[j] = GetCargoTranslation(grf_load_byte(&buf), _cur_grffile);
 				}
 				break;
 
 			case 0x11: // Acceptance cargo types
 				for (byte j = 0; j < 3; j++) {
-					indsp->accepts_cargo[j] = grf_load_byte(&buf);
+					indsp->accepts_cargo[j] = GetCargoTranslation(grf_load_byte(&buf), _cur_grffile);
 				}
 				grf_load_byte(&buf); // Unnused, eat it up
 				break;
@@ -2066,6 +2086,10 @@
 				SB(indsp->callback_flags, (prop - 0x21) * 8, 8, aflag);
 			} break;
 
+			case 0x23: // removal cost multiplier
+				indsp->removal_cost_multiplier = grf_load_dword(&buf);
+				break;
+
 			default:
 				ret = true;
 				break;
@@ -2191,7 +2215,7 @@
 				break;
 		}
 
-		if (ignoring) grfmsg(2, "FeatureChangeInfo: Ignoring property 0x%02X (not implemented)", prop);
+		if (ignoring) grfmsg(1, "FeatureChangeInfo: Ignoring property 0x%02X of feature 0x%02X (not implemented)", prop, feature);
 	}
 }
 
@@ -2321,8 +2345,8 @@
 	);
 
 	for (uint16 i = 0; i < num_sets * num_ents; i++) {
+		_nfo_line++;
 		LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line);
-		_nfo_line++;
 	}
 }
 
@@ -2465,7 +2489,7 @@
 					/* Link subroutine group */
 					adjust->subroutine = GetGroupFromGroupID(setid, type, grf_load_byte(&buf));
 				} else {
-					adjust->parameter = IS_BYTE_INSIDE(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0;
+					adjust->parameter = IsInsideMM(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0;
 				}
 
 				varadjust = grf_load_byte(&buf);
@@ -2748,8 +2772,8 @@
 
 static void VehicleMapSpriteGroup(byte *buf, byte feature, uint8 idcount, uint8 cidcount, bool wagover)
 {
-	static byte *last_engines;
-	static int last_engines_count;
+	static EngineID *last_engines;
+	static uint last_engines_count;
 
 	if (!wagover) {
 		if (last_engines_count != idcount) {
@@ -3248,6 +3272,25 @@
 	return 0;
 }
 
+/** Allows to reposition the loaded sprite to its correct placment.
+ * @param load_index SpriteID of the sprite to be relocated */
+static inline void TranslateShoreSprites(SpriteID load_index)
+{
+	/** Contains the displacement required for the corresponding initial sprite*/
+	static const SpriteID shore_dup[8] = {
+		SPR_SHORE_BASE +  4,  ///< 4062
+		SPR_SHORE_BASE +  1,  ///< 4063
+		SPR_SHORE_BASE +  2,  ///< 4064
+		SPR_SHORE_BASE +  8,  ///< 4065
+		SPR_SHORE_BASE +  6,  ///< 4066
+		SPR_SHORE_BASE + 12,  ///< 4067
+		SPR_SHORE_BASE +  3,  ///< 4068
+		SPR_SHORE_BASE +  9,  ///< 4069
+	};
+
+	DupSprite(load_index, shore_dup[load_index - SPR_ORIGINALSHORE_START]);
+}
+
 /* Action 0x05 */
 static void GraphicsNew(byte *buf, int len)
 {
@@ -3330,12 +3373,47 @@
 		/* case 0x0C: // Snowy temperate trees. Not yet used by OTTD. */
 
 		case 0x0D: // Coast graphics
-			if (num != 16) {
-				grfmsg(1, "GraphicsNew: Coast graphics sprite count must be 16, skipping");
-				return;
+			switch (num) {
+				case 10:
+					if (!_cur_grffile->is_ottdfile) {
+						grfmsg(2, "GraphicsNew: feature is reserved only for OpenTTD, skipping");
+						return;
+					}
+
+					/* openttd(d/w).grf missing shore sprites and initialisation of SPR_SHORE_BASE */
+					LoadNextSprite(      SPR_SHORE_BASE +  0, _file_index, _nfo_line++); // SLOPE_STEEP_S
+					TranslateShoreSprites(SPR_ORIGINALSHORE_START + 1); // SLOPE_W
+					TranslateShoreSprites(SPR_ORIGINALSHORE_START + 2); // SLOPE_S
+					TranslateShoreSprites(SPR_ORIGINALSHORE_START + 6); // SLOPE_SW
+					TranslateShoreSprites(SPR_ORIGINALSHORE_START); // SLOPE_E
+					LoadNextSprite(      SPR_SHORE_BASE +  5, _file_index, _nfo_line++); // SLOPE_STEEP_W
+					TranslateShoreSprites(SPR_ORIGINALSHORE_START + 4); // SLOPE_SE
+					LoadNextSprite(      SPR_SHORE_BASE +  7, _file_index, _nfo_line++); // SLOPE_WSE
+					TranslateShoreSprites(SPR_ORIGINALSHORE_START + 3); // SLOPE_N
+					TranslateShoreSprites(SPR_ORIGINALSHORE_START + 7); // SLOPE_NW
+					LoadNextSprite(      SPR_SHORE_BASE + 10, _file_index, _nfo_line++); // SLOPE_STEEP_N
+					LoadNextSprite(      SPR_SHORE_BASE + 11, _file_index, _nfo_line++); // SLOPE_NWS
+					TranslateShoreSprites(SPR_ORIGINALSHORE_START + 5); // SLOPE_NE
+					LoadNextSprite(      SPR_SHORE_BASE + 13, _file_index, _nfo_line++); // SLOPE_ENW
+					LoadNextSprite(      SPR_SHORE_BASE + 14, _file_index, _nfo_line++); // SLOPE_SEN
+					LoadNextSprite(      SPR_SHORE_BASE + 15, _file_index, _nfo_line++); // SLOPE_STEEP_E
+					LoadNextSprite(      SPR_SHORE_BASE + 16, _file_index, _nfo_line++); // SLOPE_EW
+					LoadNextSprite(      SPR_SHORE_BASE + 17, _file_index, _nfo_line++); // SLOPE_NS
+
+					grfmsg(2, "GraphicsNew: Loading all standard shore sprites");
+					break;
+
+				case 16:
+				case 18:
+					/* 'normal' newWater newGRF */
+					replace = SPR_SHORE_BASE;
+					break;
+
+				default:
+					/* no valid shore sprite count */
+					grfmsg(1, "GraphicsNew: Shore graphics sprite count must be 10, 16 or 18, skipping");
+					return;
 			}
-			_coast_base = _cur_spriteid;
-			_loaded_newgrf_features.has_newwater = true;
 			break;
 
 		/* case 0x0E: // New Signals. Not yet used by OTTD. */
@@ -3392,8 +3470,8 @@
 	}
 
 	for (; num > 0; num--) {
+		_nfo_line++;
 		LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index, _nfo_line);
-		_nfo_line++;
 	}
 
 	_skip_sprites = skip_num;
@@ -3725,7 +3803,7 @@
 		_skip_sprites = -1;
 
 		/* If an action 8 hasn't been encountered yet, disable the grf. */
-		if (_cur_grfconfig->status != GCS_ACTIVATED && _cur_grfconfig->status != GCS_INITIALISED) {
+		if (_cur_grfconfig->status != GCS_ACTIVATED) {
 			_cur_grfconfig->status = GCS_DISABLED;
 		}
 	}
@@ -3806,8 +3884,13 @@
 		);
 
 		for (uint j = 0; j < num_sprites; j++) {
-			LoadNextSprite(first_sprite + j, _file_index, _nfo_line); // XXX
+			int load_index = first_sprite + j;
 			_nfo_line++;
+			LoadNextSprite(load_index, _file_index, _nfo_line); // XXX
+
+			/*  Shore sprites now located at different addresses.
+			 * So apply the required displacements */
+			if (IsInsideMM(load_index, SPR_ORIGINALSHORE_START, SPR_ORIGINALSHORE_END + 1)) TranslateShoreSprites(load_index);
 		}
 	}
 }
@@ -4642,8 +4725,8 @@
 
 		for (uint c = 0; c < num_char; c++) {
 			SetUnicodeGlyph(size, base_char + c, _cur_spriteid);
+			_nfo_line++;
 			LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line);
-			_nfo_line++;
 		}
 	}
 }
@@ -4980,11 +5063,7 @@
 	CleanUpGRFTownNames();
 
 	/* Copy/reset original engine info data */
-	memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info));
-	memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info));
-	memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info));
-	memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info));
-	memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info));
+	SetupEngines();
 
 	/* Copy/reset original bridge info data
 	 * First, free sprite table data */
@@ -5041,9 +5120,6 @@
 	/* Reset NewGRF errors. */
 	ResetNewGRFErrors();
 
-	/* Add engine type to engine data. This is needed for the refit precalculation. */
-	AddTypeToEngines();
-
 	/* Set up the default cargo types */
 	SetupCargoForClimate(_opt.landscape);
 
@@ -5058,8 +5134,6 @@
 	_loaded_newgrf_features.has_2CC           = false;
 	_loaded_newgrf_features.has_newhouses     = false;
 	_loaded_newgrf_features.has_newindustries = false;
-	_loaded_newgrf_features.has_newwater      = false;
-	_coast_base = 0;
 
 	InitializeSoundPool();
 	InitializeSpriteGroupPool();
@@ -5269,8 +5343,11 @@
 	 * compatible with TTDPatch, where if no houses have start dates before
 	 * 1930 and the date is before 1930, the game pretends that this is 1930.
 	 * If there have been any houses defined with start dates before 1930 then
-	 * the dates are left alone. */
-	bool reset_dates = true;
+	 * the dates are left alone.
+	 * On the other hand, why 1930? Just 'fix' the houses with the lowest
+	 * minimum introduction date to 0.
+	 */
+	Year min_date = MAX_YEAR;
 
 	for (GRFFile *file = _first_grffile; file != NULL; file = file->next) {
 		if (file->housespec == NULL) continue;
@@ -5279,16 +5356,16 @@
 			HouseSpec *hs = file->housespec[i];
 			if (hs != NULL) {
 				_house_mngr.SetEntitySpec(hs);
-				if (hs->min_date < 1930) reset_dates = false;
+				if (hs->min_date < min_date) min_date = hs->min_date;
 			}
 		}
 	}
 
-	if (reset_dates) {
-		for (int i = NEW_HOUSE_OFFSET; i < HOUSE_MAX; i++) {
+	if (min_date != 0) {
+		for (int i = 0; i < HOUSE_MAX; i++) {
 			HouseSpec *hs = GetHouseSpecs(i);
 
-			if (hs->enabled && hs->min_date == 1930) hs->min_date = 0;
+			if (hs->enabled && hs->min_date == min_date) hs->min_date = 0;
 		}
 	}
 }
@@ -5323,15 +5400,6 @@
 					strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->new_industry_text);
 					if (strid != STR_UNDEFINED) indsp->new_industry_text = strid;
 
-					for (byte j = 0; j < 2; j++) {
-						CargoID c = GetCargoTranslation(indsp->produced_cargo[j], indsp->grf_prop.grffile);
-						indsp->produced_cargo[j] = c;
-					}
-					for (byte j = 0; j < 3; j++) {
-						CargoID c = GetCargoTranslation(indsp->accepts_cargo[j], indsp->grf_prop.grffile);
-						indsp->accepts_cargo[j] = c;
-					}
-
 					_industry_mngr.SetEntitySpec(indsp);
 					_loaded_newgrf_features.has_newindustries = true;
 				}
@@ -5342,10 +5410,6 @@
 			for (int i = 0; i < NUM_INDUSTRYTILES; i++) {
 				IndustryTileSpec *indtsp = file->indtspec[i];
 				if (indtsp != NULL) {
-					for (byte j = 0; j < 3; j++) {
-						CargoID c = GetCargoTranslation(indtsp->accepts_cargo[j], indtsp->grf_prop.grffile);
-						indtsp->accepts_cargo[j] = c;
-					}
 					_industile_mngr.SetEntitySpec(indtsp);
 				}
 			}
@@ -5430,7 +5494,6 @@
 		/* No preloaded sprite to work with; allocate and read the
 		 * pseudo sprite content. */
 		buf = MallocT<byte>(num);
-		if (buf == NULL) error("DecodeSpecialSprite: Could not allocate memory");
 		FioReadBlock(buf, num);
 	} else {
 		/* Use the preloaded sprite data. */
@@ -5481,6 +5544,7 @@
 		if (_cur_grffile == NULL) error("File '%s' lost in cache.\n", filename);
 		if (stage == GLS_RESERVE && config->status != GCS_INITIALISED) return;
 		if (stage == GLS_ACTIVATION && !HasBit(config->flags, GCF_RESERVED)) return;
+		_cur_grffile->is_ottdfile = config->IsOpenTTDBaseGRF();
 	}
 
 	if (file_index > LAST_GRF_SLOT) {
@@ -5596,6 +5660,17 @@
 
 	ResetNewGRFData();
 
+	/*
+	 * Reset the status of all files, so we can 'retry' to load them.
+	 * This is needed when one for example rearranges the NewGRFs in-game
+	 * and a previously disabled NewGRF becomes useable. If it would not
+	 * be reset, the NewGRF would remain disabled even though it should
+	 * have been enabled.
+	 */
+	for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
+		if (c->status != GCS_NOT_FOUND) c->status = GCS_UNKNOWN;
+	}
+
 	/* Load newgrf sprites
 	 * in each loading stage, (try to) open each file specified in the config
 	 * and load information from it. */
--- a/src/newgrf.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,11 +6,10 @@
 #define NEWGRF_H
 
 #include "station.h"
-#include "town.h"
+#include "town_type.h"
 #include "newgrf_config.h"
-#include "helpers.hpp"
 #include "cargotype.h"
-#include "industry.h"
+#include "industry_type.h"
 
 enum GrfLoadingStage {
 	GLS_FILESCAN,
@@ -42,6 +41,7 @@
 
 struct GRFFile {
 	char *filename;
+	bool is_ottdfile;
 	uint32 grfid;
 	uint16 sprite_offset;
 	byte grf_version;
@@ -85,13 +85,10 @@
 
 extern GRFFile *_first_grffile;
 
-extern SpriteID _coast_base;
-
 struct GRFLoadedFeatures {
 	bool has_2CC;             ///< Set if any vehicle is loaded which uses 2cc (two company colours).
 	bool has_newhouses;       ///< Set if there are any newhouses loaded.
 	bool has_newindustries;   ///< Set if there are any newindustries loaded.
-	bool has_newwater;        ///< Set it there are any newwater grf loaded
 };
 
 /* Indicates which are the newgrf features currently loaded ingame */
--- a/src/newgrf_canal.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_canal.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -10,6 +10,7 @@
 #include "newgrf_commons.h"
 #include "newgrf_spritegroup.h"
 #include "newgrf_canal.h"
+#include "tile_map.h"
 
 
 /** Table of canal 'feature' sprite groups */
--- a/src/newgrf_cargo.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_cargo.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,17 +6,21 @@
 #define NEWGRF_CARGO_H
 
 #include "newgrf_callbacks.h"
+#include "cargo_type.h"
 
 enum {
-	CC_NOAVAILABLE  = 0,
-	CC_PASSENGERS   = 1 << 0,
-	CC_MAIL         = 1 << 1,
-	CC_EXPRESS      = 1 << 2,
-	CC_ARMOURED     = 1 << 3,
-	CC_BULK         = 1 << 4,
-	CC_PIECE_GOODS  = 1 << 5,
-	CC_LIQUID       = 1 << 6,
-	CC_REFRIGERATED = 1 << 7,
+	CC_NOAVAILABLE  = 0,       ///< No cargo class has been specified
+	CC_PASSENGERS   = 1 <<  0, ///< Passengers
+	CC_MAIL         = 1 <<  1, ///< Mail
+	CC_EXPRESS      = 1 <<  2, ///< Express cargo (Goods, Food, Candy, but also possible for passengers)
+	CC_ARMOURED     = 1 <<  3, ///< Armoured cargo (Valuables, Gold, Diamonds)
+	CC_BULK         = 1 <<  4, ///< Bulk cargo (Coal, Grain etc., Ores, Fruit)
+	CC_PIECE_GOODS  = 1 <<  5, ///< Piece goods (Livestock, Wood, Steel, Paper)
+	CC_LIQUID       = 1 <<  6, ///< Liquids (Oil, Water, Rubber)
+	CC_REFRIGERATED = 1 <<  7, ///< Refrigerated cargo (Food, Fruit)
+	CC_HAZARDOUS    = 1 <<  8, ///< Hazardous cargo (Nucleair Fuel, Explosives, etc.)
+	CC_COVERED      = 1 <<  9, ///< Covered/Sheltered Freight (Transporation in Box Vans, Silo Wagons, etc.)
+	CC_SPECIAL      = 1 << 15  ///< Special bit used for livery refit tricks instead of normal cargoes.
 };
 
 static const CargoID CT_DEFAULT      = NUM_CARGO + 0;
--- a/src/newgrf_commons.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_commons.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -12,6 +12,8 @@
 #include "industry.h"
 #include "newgrf.h"
 #include "newgrf_commons.h"
+#include "tile_map.h"
+#include "station_map.h"
 
 /** Constructor of generic class
  * @param offset end of original data for this entity. i.e: houses = 110
@@ -276,6 +278,9 @@
 	if (x >= 8) x -= 16;
 	if (y >= 8) y -= 16;
 
+	/* Swap width and height depending on axis for railway stations */
+	if (IsRailwayStationTile(tile) && GetRailStationAxis(tile) == AXIS_X) Swap(x, y);
+
 	/* Make sure we never roam outside of the map */
 	return TILE_MASK(tile + TileDiffXY(x, y));
 }
--- a/src/newgrf_config.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_config.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,17 +4,15 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "macros.h"
 #include "debug.h"
 #include "variables.h"
-#include "string.h"
 #include "saveload.h"
 #include "md5.h"
 #include "network/network_data.h"
 #include "newgrf.h"
 #include "newgrf_config.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
+#include "string_func.h"
 
 #include "fileio.h"
 #include "fios.h"
@@ -35,8 +33,8 @@
 static bool CalcGRFMD5Sum(GRFConfig *config)
 {
 	FILE *f;
-	md5_state_t md5state;
-	md5_byte_t buffer[1024];
+	Md5 checksum;
+	uint8 buffer[1024];
 	size_t len, size;
 
 	/* open the file */
@@ -44,12 +42,11 @@
 	if (f == NULL) return false;
 
 	/* calculate md5sum */
-	md5_init(&md5state);
 	while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) {
 		size -= len;
-		md5_append(&md5state, buffer, len);
+		checksum.Append(buffer, len);
 	}
-	md5_finish(&md5state, config->md5sum);
+	checksum.Finish(config->md5sum);
 
 	FioFCloseFile(f);
 
--- a/src/newgrf_config.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_config.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,7 @@
 #ifndef NEWGRF_CONFIG_H
 #define NEWGRF_CONFIG_H
 
-#include "openttd.h"
+#include "strings_type.h"
 
 /* GRF config bit flags */
 enum GCF_Flags {
--- a/src/newgrf_engine.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_engine.cpp	Wed Jan 09 18:11:12 2008 +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"
@@ -18,29 +17,30 @@
 #include "newgrf_station.h"
 #include "newgrf_spritegroup.h"
 #include "newgrf_cargo.h"
-#include "date.h"
-#include "helpers.hpp"
 #include "cargotype.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "core/random_func.hpp"
 
 
 int _traininfo_vehicle_pitch = 0;
 int _traininfo_vehicle_width = 29;
 
 struct WagonOverride {
-	byte *train_id;
-	int trains;
+	EngineID *train_id;
+	uint trains;
 	CargoID cargo;
 	const SpriteGroup *group;
 };
 
 struct WagonOverrides {
-	int overrides_count;
+	uint overrides_count;
 	WagonOverride *overrides;
 };
 
 static WagonOverrides _engine_wagon_overrides[TOTAL_NUM_ENGINES];
 
-void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const SpriteGroup *group, byte *train_id, int trains)
+void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const SpriteGroup *group, EngineID *train_id, uint trains)
 {
 	WagonOverrides *wos;
 	WagonOverride *wo;
@@ -59,11 +59,11 @@
 	wo->group = group;
 	wo->cargo = cargo;
 	wo->trains = trains;
-	wo->train_id = MallocT<byte>(trains);
-	memcpy(wo->train_id, train_id, trains);
+	wo->train_id = MallocT<EngineID>(trains);
+	memcpy(wo->train_id, train_id, trains * sizeof *train_id);
 }
 
-const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, byte overriding_engine)
+const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine)
 {
 	const WagonOverrides *wos = &_engine_wagon_overrides[engine];
 
@@ -72,12 +72,12 @@
 	 * for O(1). Or O(logMlogN) and searching binary tree or smt. like
 	 * that. --pasky */
 
-	for (int i = 0; i < wos->overrides_count; i++) {
+	for (uint i = 0; i < wos->overrides_count; i++) {
 		const WagonOverride *wo = &wos->overrides[i];
 
 		if (wo->cargo != cargo && wo->cargo != CT_DEFAULT) continue;
 
-		for (int j = 0; j < wo->trains; j++) {
+		for (uint j = 0; j < wo->trains; j++) {
 			if (wo->train_id[j] == overriding_engine) return wo->group;
 		}
 	}
@@ -89,16 +89,10 @@
  */
 void UnloadWagonOverrides()
 {
-	WagonOverrides *wos;
-	WagonOverride *wo;
-	EngineID engine;
-	int i;
-
-	for (engine = 0; engine < TOTAL_NUM_ENGINES; engine++) {
-		wos = &_engine_wagon_overrides[engine];
-		for (i = 0; i < wos->overrides_count; i++) {
-			wo = &wos->overrides[i];
-			wo->group = NULL;
+	for (EngineID engine = 0; engine < TOTAL_NUM_ENGINES; engine++) {
+		WagonOverrides *wos = &_engine_wagon_overrides[engine];
+		for (uint i = 0; i < wos->overrides_count; i++) {
+			WagonOverride *wo = &wos->overrides[i];
 			free(wo->train_id);
 		}
 		free(wos->overrides);
@@ -804,7 +798,7 @@
 
 	totalsets = in_motion ? group->g.real.num_loaded : group->g.real.num_loading;
 
-	if (v->cargo.Count() == v->cargo_cap || totalsets == 1) {
+	if (v->cargo.Count() >= v->cargo_cap || totalsets == 1) {
 		set = totalsets - 1;
 	} else if (v->cargo.Empty() || totalsets == 2) {
 		set = 0;
--- a/src/newgrf_engine.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_engine.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,15 +6,15 @@
 #define NEWGRF_ENGINE_H
 
 #include "newgrf.h"
-#include "direction.h"
+#include "direction_type.h"
 #include "newgrf_cargo.h"
 
 extern int _traininfo_vehicle_pitch;
 extern int _traininfo_vehicle_width;
 
 
-void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, byte *train_id, int trains);
-const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, byte overriding_engine);
+void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains);
+const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine);
 void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group);
 void SetRotorOverrideSprites(EngineID engine, const struct SpriteGroup *group);
 SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle* v, Direction direction);
--- a/src/newgrf_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,17 +4,19 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
-#include "gfx.h"
 #include "gui.h"
-#include "window.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
 #include "table/strings.h"
 #include "table/sprites.h"
 #include "newgrf.h"
 #include "newgrf_config.h"
-#include "strings.h"
-#include "helpers.hpp"
+#include "strings_func.h"
+#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
@@ -112,31 +114,41 @@
 	const GRFConfig *sel;
 };
 
+/* Names of the add a newgrf window widgets */
+enum AddNewGRFWindowWidgets {
+	ANGRFW_CLOSEBOX = 0,
+	ANGRFW_CAPTION,
+	ANGRFW_BACKGROUND,
+	ANGRFW_GRF_LIST,
+	ANGRFW_SCROLLBAR,
+	ANGRFW_GRF_INFO,
+	ANGRFW_ADD,
+	ANGRFW_RESCAN,
+	ANGRFW_RESIZE,
+};
 
 static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
 			const GRFConfig *c;
-			int y;
+			const Widget *wl = &w->widget[ANGRFW_GRF_LIST];
 			int n = 0;
 
 			/* Count the number of GRFs */
 			for (c = _all_grfs; c != NULL; c = c->next) n++;
 
-			w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10;
+			w->vscroll.cap = (wl->bottom - wl->top) / 10;
 			SetVScrollCount(w, n);
 
-			SetWindowWidgetDisabledState(w, 6, WP(w, newgrf_add_d).sel == NULL || WP(w, newgrf_add_d).sel->IsOpenTTDBaseGRF());
+			w->SetWidgetDisabledState(ANGRFW_ADD, WP(w, newgrf_add_d).sel == NULL || WP(w, newgrf_add_d).sel->IsOpenTTDBaseGRF());
 			DrawWindowWidgets(w);
 
-			GfxFillRect(w->widget[3].left + 1, w->widget[3].top + 1, w->widget[3].right, w->widget[3].bottom, 0xD7);
+			GfxFillRect(wl->left + 1, wl->top + 1, wl->right, wl->bottom, 0xD7);
 
-			n = 0;
-			y = w->widget[3].top + 1;
-
-			for (c = _all_grfs; c != NULL; c = c->next) {
-				if (n >= w->vscroll.pos && n < w->vscroll.pos + w->vscroll.cap) {
+			uint y = wl->top + 1;
+			for (c = _all_grfs, n = 0; c != NULL && n < (w->vscroll.pos + w->vscroll.cap); c = c->next, n++) {
+				if (n >= w->vscroll.pos) {
 					bool h = c == WP(w, newgrf_add_d).sel;
 					const char *text = (c->name != NULL && !StrEmpty(c->name)) ? c->name : c->filename;
 
@@ -145,27 +157,26 @@
 					DoDrawStringTruncated(text, 4, y, h ? TC_WHITE : TC_ORANGE, w->width - 18);
 					y += 10;
 				}
-				n++;
 			}
 
 			if (WP(w, newgrf_add_d).sel != NULL) {
-				const Widget *wi = &w->widget[5];
+				const Widget *wi = &w->widget[ANGRFW_GRF_INFO];
 				ShowNewGRFInfo(WP(w, newgrf_add_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, wi->bottom, false);
 			}
 			break;
 		}
 
 		case WE_DOUBLE_CLICK:
-			if (e->we.click.widget != 3) break;
-			e->we.click.widget = 6;
+			if (e->we.click.widget != ANGRFW_GRF_LIST) break;
+			e->we.click.widget = ANGRFW_ADD;
 			/* Fall through */
 
 		case WE_CLICK:
 			switch (e->we.click.widget) {
-				case 3: {
+				case ANGRFW_GRF_LIST: {
 					/* Get row... */
 					const GRFConfig *c;
-					uint i = (e->we.click.pt.y - w->widget[3].top) / 10 + w->vscroll.pos;
+					uint i = (e->we.click.pt.y - w->widget[ANGRFW_GRF_LIST].top) / 10 + w->vscroll.pos;
 
 					for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--);
 					WP(w, newgrf_add_d).sel = c;
@@ -173,7 +184,7 @@
 					break;
 				}
 
-				case 6: // Add selection to list
+				case ANGRFW_ADD: // Add selection to list
 					if (WP(w, newgrf_add_d).sel != NULL) {
 						const GRFConfig *src = WP(w, newgrf_add_d).sel;
 						GRFConfig **list;
@@ -202,7 +213,7 @@
 					}
 					break;
 
-				case 7: // Rescan list
+				case ANGRFW_RESCAN: // Rescan list
 					WP(w, newgrf_add_d).sel = NULL;
 					ScanNewGRFFiles();
 					SetWindowDirty(w);
@@ -212,26 +223,21 @@
 	}
 }
 
-
+/* Widget definition for the add a newgrf window */
 static const Widget _newgrf_add_dlg_widgets[] = {
-{   WWT_CLOSEBOX,    RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW },
-{    WWT_CAPTION,   RESIZE_RIGHT, 14,  11, 306,   0,  13, STR_NEWGRF_ADD_CAPTION,  STR_018C_WINDOW_TITLE_DRAG_THIS },
-
-/* List of files */
-{      WWT_PANEL,      RESIZE_RB, 14,   0, 294,  14, 121, 0x0,                     STR_NULL },
-{      WWT_INSET,      RESIZE_RB, 14,   2, 292,  16, 119, 0x0,                     STR_NULL },
-{  WWT_SCROLLBAR,     RESIZE_LRB, 14, 295, 306,  14, 121, 0x0,                     STR_NULL },
-
-/* NewGRF file info */
-{      WWT_PANEL,     RESIZE_RTB, 14,   0, 306, 122, 224, 0x0,                     STR_NULL },
-
-{ WWT_PUSHTXTBTN,     RESIZE_RTB, 14,   0, 146, 225, 236, STR_NEWGRF_ADD_FILE,     STR_NEWGRF_ADD_FILE_TIP },
-{ WWT_PUSHTXTBTN,    RESIZE_LRTB, 14, 147, 294, 225, 236, STR_NEWGRF_RESCAN_FILES, STR_NEWGRF_RESCAN_FILES_TIP },
-{  WWT_RESIZEBOX,    RESIZE_LRTB, 14, 295, 306, 225, 236, 0x0,                     STR_RESIZE_BUTTON },
+{   WWT_CLOSEBOX,    RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW },           // ANGRFW_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_RIGHT, 14,  11, 306,   0,  13, STR_NEWGRF_ADD_CAPTION,  STR_018C_WINDOW_TITLE_DRAG_THIS }, // ANGRFW_CAPTION
+{      WWT_PANEL,      RESIZE_RB, 14,   0, 294,  14, 121, 0x0,                     STR_NULL },                        // ANGRFW_BACKGROUND
+{      WWT_INSET,      RESIZE_RB, 14,   2, 292,  16, 119, 0x0,                     STR_NULL },                        // ANGRFW_GRF_LIST
+{  WWT_SCROLLBAR,     RESIZE_LRB, 14, 295, 306,  14, 121, 0x0,                     STR_NULL },                        // ANGRFW_SCROLLBAR
+{      WWT_PANEL,     RESIZE_RTB, 14,   0, 306, 122, 224, 0x0,                     STR_NULL },                        // ANGRFW_GRF_INFO
+{ WWT_PUSHTXTBTN,     RESIZE_RTB, 14,   0, 146, 225, 236, STR_NEWGRF_ADD_FILE,     STR_NEWGRF_ADD_FILE_TIP },         // ANGRFW_ADD
+{ WWT_PUSHTXTBTN,    RESIZE_LRTB, 14, 147, 294, 225, 236, STR_NEWGRF_RESCAN_FILES, STR_NEWGRF_RESCAN_FILES_TIP },     // ANGRFW_RESCAN
+{  WWT_RESIZEBOX,    RESIZE_LRTB, 14, 295, 306, 225, 236, 0x0,                     STR_RESIZE_BUTTON },               // ANGRFW_RESIZE
 {   WIDGETS_END },
 };
 
-
+/* Window definition for the add a newgrf window */
 static const WindowDesc _newgrf_add_dlg_desc = {
 	WDP_CENTER, WDP_CENTER, 307, 237, 307, 337,
 	WC_SAVELOAD, WC_NONE,
@@ -253,36 +259,41 @@
 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(newgrf_d));
 
 
+/* Names of the manage newgrfs window widgets */
 enum ShowNewGRFStateWidgets {
-	SNGRFS_ADD = 3,
+	SNGRFS_CLOSEBOX = 0,
+	SNGRFS_CAPTION,
+	SNGRFS_BACKGROUND,
+	SNGRFS_ADD,
 	SNGRFS_REMOVE,
 	SNGRFS_MOVE_UP,
 	SNGRFS_MOVE_DOWN,
-	SNGRFS_FILE_LIST = 7,
-	SNGRFS_NEWGRF_INFO = 9,
+	SNGRFS_FILE_LIST,
+	SNGRFS_SCROLLBAR,
+	SNGRFS_NEWGRF_INFO,
 	SNGRFS_SET_PARAMETERS,
 	SNGRFS_APPLY_CHANGES,
+	SNGRFS_RESIZE,
 };
 
-
 static void SetupNewGRFState(Window *w)
 {
 	bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable;
 
-	SetWindowWidgetDisabledState(w, 3, !WP(w, newgrf_d).editable);
-	SetWindowWidgetsDisabledState(w, disable_all,
+	w->SetWidgetDisabledState(3, !WP(w, newgrf_d).editable);
+	w->SetWidgetsDisabledState(disable_all,
 		SNGRFS_REMOVE,
 		SNGRFS_MOVE_UP,
 		SNGRFS_MOVE_DOWN,
 		WIDGET_LIST_END
 	);
-	SetWindowWidgetDisabledState(w, SNGRFS_SET_PARAMETERS, !WP(w, newgrf_d).show_params || disable_all);
+	w->SetWidgetDisabledState(SNGRFS_SET_PARAMETERS, !WP(w, newgrf_d).show_params || disable_all);
 
 	if (!disable_all) {
 		/* All widgets are now enabled, so disable widgets we can't use */
-		if (WP(w, newgrf_d).sel == *WP(w, newgrf_d).list) DisableWindowWidget(w, SNGRFS_MOVE_UP);
-		if (WP(w, newgrf_d).sel->next == NULL) DisableWindowWidget(w, SNGRFS_MOVE_DOWN);
-		if (WP(w, newgrf_d).sel->IsOpenTTDBaseGRF()) DisableWindowWidget(w, SNGRFS_REMOVE);
+		if (WP(w, newgrf_d).sel == *WP(w, newgrf_d).list) w->DisableWidget(SNGRFS_MOVE_UP);
+		if (WP(w, newgrf_d).sel->next == NULL) w->DisableWidget(SNGRFS_MOVE_DOWN);
+		if (WP(w, newgrf_d).sel->IsOpenTTDBaseGRF()) w->DisableWidget(SNGRFS_REMOVE);
 	}
 }
 
@@ -296,7 +307,7 @@
 
 	w->vscroll.cap = (w->widget[SNGRFS_FILE_LIST].bottom - w->widget[SNGRFS_FILE_LIST].top) / 14 + 1;
 	SetVScrollCount(w, i);
-	SetWindowWidgetDisabledState(w, SNGRFS_APPLY_CHANGES, !WP(w, newgrf_d).editable);
+	w->SetWidgetDisabledState(SNGRFS_APPLY_CHANGES, !WP(w, newgrf_d).editable);
 }
 
 
@@ -525,35 +536,25 @@
 	}
 }
 
-
+/* Widget definition of the manage newgrfs window */
 static const Widget _newgrf_widgets[] = {
-{   WWT_CLOSEBOX,  RESIZE_NONE, 10,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW },
-{    WWT_CAPTION, RESIZE_RIGHT, 10,  11, 299,   0,  13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },
-
-/* NewGRF file Add, Remove, Move up, Move down */
-{      WWT_PANEL, RESIZE_RIGHT, 10,   0, 299,  14,  29, STR_NULL,                    STR_NULL },
-{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  10,  79,  16,  27, STR_NEWGRF_ADD,              STR_NEWGRF_ADD_TIP },
-{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  80, 149,  16,  27, STR_NEWGRF_REMOVE,           STR_NEWGRF_REMOVE_TIP },
-{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3, 150, 219,  16,  27, STR_NEWGRF_MOVEUP,           STR_NEWGRF_MOVEUP_TIP },
-{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3, 220, 289,  16,  27, STR_NEWGRF_MOVEDOWN,         STR_NEWGRF_MOVEDOWN_TIP },
-
-/* NewGRF file list */
-{     WWT_MATRIX,    RESIZE_RB, 10,   0, 287,  30,  99, 0x501,                       STR_NEWGRF_FILE_TIP },
-{  WWT_SCROLLBAR,   RESIZE_LRB, 10, 288, 299,  30,  99, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST },
-
-/* NewGRF file info */
-{      WWT_PANEL,   RESIZE_RTB, 10,   0, 299, 100, 212, STR_NULL,                    STR_NULL },
-
-/* Edit parameter and apply changes button... */
-{ WWT_PUSHTXTBTN,    RESIZE_TB, 10,   0, 143, 213, 224, STR_NEWGRF_SET_PARAMETERS,   STR_NULL },
-{ WWT_PUSHTXTBTN,   RESIZE_RTB, 10, 144, 287, 213, 224, STR_NEWGRF_APPLY_CHANGES,    STR_NULL },
-
-{  WWT_RESIZEBOX,  RESIZE_LRTB, 10, 288, 299, 213, 224, 0x0,                         STR_RESIZE_BUTTON },
-
+{   WWT_CLOSEBOX,  RESIZE_NONE, 10,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW },            // SNGRFS_CLOSEBOX
+{    WWT_CAPTION, RESIZE_RIGHT, 10,  11, 299,   0,  13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },  // SNGRFS_CAPTION
+{      WWT_PANEL, RESIZE_RIGHT, 10,   0, 299,  14,  29, STR_NULL,                    STR_NULL },                         // SNGRFS_BACKGROUND
+{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  10,  79,  16,  27, STR_NEWGRF_ADD,              STR_NEWGRF_ADD_TIP },               // SNGRFS_ADD
+{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  80, 149,  16,  27, STR_NEWGRF_REMOVE,           STR_NEWGRF_REMOVE_TIP },            // SNGRFS_REMOVE
+{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3, 150, 219,  16,  27, STR_NEWGRF_MOVEUP,           STR_NEWGRF_MOVEUP_TIP },            // SNGRFS_MOVE_UP
+{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3, 220, 289,  16,  27, STR_NEWGRF_MOVEDOWN,         STR_NEWGRF_MOVEDOWN_TIP },          // SNGRFS_MOVE_DOWN
+{     WWT_MATRIX,    RESIZE_RB, 10,   0, 287,  30,  99, 0x501,                       STR_NEWGRF_FILE_TIP },              // SNGRFS_FILE_LIST
+{  WWT_SCROLLBAR,   RESIZE_LRB, 10, 288, 299,  30,  99, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST }, // SNGRFS_SCROLLBAR
+{      WWT_PANEL,   RESIZE_RTB, 10,   0, 299, 100, 212, STR_NULL,                    STR_NULL },                         // SNGRFS_NEWGRF_INFO
+{ WWT_PUSHTXTBTN,    RESIZE_TB, 10,   0, 143, 213, 224, STR_NEWGRF_SET_PARAMETERS,   STR_NULL },                         // SNGRFS_SET_PARAMETERS
+{ WWT_PUSHTXTBTN,   RESIZE_RTB, 10, 144, 287, 213, 224, STR_NEWGRF_APPLY_CHANGES,    STR_NULL },                         // SNGRFS_APPLY_CHANGES
+{  WWT_RESIZEBOX,  RESIZE_LRTB, 10, 288, 299, 213, 224, 0x0,                         STR_RESIZE_BUTTON },                // SNGRFS_RESIZE
 { WIDGETS_END },
 };
 
-
+/* Window definition of the manage newgrfs window */
 static const WindowDesc _newgrf_desc = {
 	WDP_CENTER, WDP_CENTER, 300, 225, 300, 225,
 	WC_GAME_OPTIONS, WC_NONE,
--- a/src/newgrf_house.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_house.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,17 +4,13 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "debug.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "landscape.h"
-#include "date.h"
 #include "town.h"
 #include "town_map.h"
-#include "sound.h"
 #include "sprite.h"
-#include "strings.h"
 #include "table/strings.h"
 #include "table/sprites.h"
 #include "table/town_land.h"
@@ -26,6 +22,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_house.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_house.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,7 @@
 #ifndef NEWGRF_HOUSE_H
 #define NEWGRF_HOUSE_H
 
-#include "town.h"
+#include "town_type.h"
 #include "newgrf_callbacks.h"
 
 /**
--- a/src/newgrf_industries.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_industries.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,8 +5,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "macros.h"
 #include "variables.h"
 #include "landscape.h"
 #include "table/strings.h"
@@ -20,7 +18,8 @@
 #include "newgrf_commons.h"
 #include "newgrf_text.h"
 #include "newgrf_town.h"
-#include "date.h"
+#include "window_func.h"
+#include "town.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
@@ -36,6 +35,15 @@
 	return _industry_mngr.GetID(GB(grf_type, 0, 6), grf_id);
 }
 
+static uint32 GetGRFParameter(IndustryType ind_id, byte parameter)
+{
+	const IndustrySpec *indspec = GetIndustrySpec(ind_id);
+	const GRFFile *file = indspec->grf_prop.grffile;
+
+	if (parameter >= file->param_end) return 0;
+	return file->param[parameter];
+}
+
 /**
  * Finds the distance for the closest tile with water/land given a tile
  * @param tile  the tile to find the distance too
@@ -201,7 +209,11 @@
 		case 0x42: { // waiting cargo, but only if those two callback flags are set
 			uint16 callback = indspec->callback_flags;
 			if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(callback, CBM_IND_PRODUCTION_256_TICKS)) {
-				return min(industry->incoming_cargo_waiting[variable - 0x40], (uint16)0xFFFF);
+				if ((indspec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) {
+					return min(industry->incoming_cargo_waiting[variable - 0x40] / industry->prod_level, (uint16)0xFFFF);
+				} else {
+					return min(industry->incoming_cargo_waiting[variable - 0x40], (uint16)0xFFFF);
+				}
 			} else {
 				return 0;
 			}
@@ -265,6 +277,9 @@
 		/* Get a variable from the persistent storage */
 		case 0x7C: return industry->psa.Get(parameter);
 
+		/* Read GRF parameter */
+		case 0x7F: return GetGRFParameter(industry->type, parameter);
+
 		/* Industry structure access*/
 		case 0x80: return industry->xy;
 		case 0x81: return GB(industry->xy, 8, 8);
@@ -315,7 +330,7 @@
 		case 0xA6: return industry->type;
 		case 0xA7: return industry->founder;
 		case 0xA8: return industry->random_color;
-		case 0xA9: return Clamp(0, industry->last_prod_year - 1920, 255);
+		case 0xA9: return Clamp(0, industry->last_prod_year - ORIGINAL_BASE_YEAR, 255);
 		case 0xAA: return industry->counter;
 		case 0xAB: return GB(industry->counter, 8, 8);
 		case 0xAC: return industry->was_cargo_delivered;
@@ -505,6 +520,8 @@
 	ResolverObject object;
 	NewIndustryResolver(&object, ind->xy, ind);
 	if ((spec->behaviour & INDUSTRYBEH_PRODCALLBACK_RANDOM) != 0) object.callback_param1 = Random();
+	int multiplier = 1;
+	if ((spec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) multiplier = ind->prod_level;
 	object.callback_param2 = reason;
 
 	for (uint loop = 0;; loop++) {
@@ -515,10 +532,10 @@
 		bool deref = (group->g.indprod.version == 1);
 
 		for (uint i = 0; i < 3; i++) {
-			ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->g.indprod.substract_input[i], deref), 0, 0xFFFF);
+			ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->g.indprod.substract_input[i], deref) * multiplier, 0, 0xFFFF);
 		}
 		for (uint i = 0; i < 2; i++) {
-			ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + DerefIndProd(group->g.indprod.add_output[i], deref), 0, 0xFFFF);
+			ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + max(DerefIndProd(group->g.indprod.add_output[i], deref), 0) * multiplier, 0, 0xFFFF);
 		}
 
 		int32 again = DerefIndProd(group->g.indprod.again, deref);
@@ -529,19 +546,3 @@
 
 	InvalidateWindow(WC_INDUSTRY_VIEW, ind->index);
 }
-
-void DoTriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
-{
-	ResolverObject object;
-
-	NewIndustryResolver(&object, ind->xy, ind);
-	object.callback = CBID_RANDOM_TRIGGER;
-	object.trigger = trigger;
-
-	const SpriteGroup *group = Resolve(GetIndustrySpec(ind->type)->grf_prop.spritegroup, &object);
-	if (group == NULL) return;
-
-	byte new_random_bits = Random();
-	ind->random &= ~object.reseed;
-	ind->random |= new_random_bits & object.reseed;
-}
--- a/src/newgrf_industries.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_industries.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,7 @@
 #ifndef NEWGRF_INDUSTRIES_H
 #define NEWGRF_INDUSTRIES_H
 
-#include "industry.h"
+#include "industry_type.h"
 #include "newgrf_spritegroup.h"
 
 /** When should the industry(tile) be triggered for random bits? */
@@ -18,6 +18,13 @@
 	INDUSTRY_TRIGGER_CARGO_DELIVERY   = 4,
 };
 
+/** From where is callback CBID_INDUSTRY_AVAILABLE been called */
+enum IndustryAvailabilityCallType {
+	IACT_MAPGENERATION,   ///< during random map generation
+	IACT_RANDOMCREATION,  ///< during creation of random ingame industry
+	IACT_USERCREATION,    ///< from the Fund/build window
+};
+
 /* in newgrf_industry.cpp */
 uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available);
 uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile);
--- a/src/newgrf_industrytiles.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_industrytiles.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,10 +4,9 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "debug.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "landscape.h"
 #include "newgrf.h"
 #include "industry.h"
@@ -23,6 +22,17 @@
 #include "table/strings.h"
 #include "sprite.h"
 #include "transparency.h"
+#include "functions.h"
+#include "town.h"
+
+static uint32 GetGRFParameter(IndustryGfx indtile_id, byte parameter)
+{
+	const IndustryTileSpec *indtspec = GetIndustryTileSpec(indtile_id);
+	const GRFFile *file = indtspec->grf_prop.grffile;
+
+	if (parameter >= file->param_end) return 0;
+	return file->param[parameter];
+}
 
 /**
  * Based on newhouses equivalent, but adapted for newindustries
@@ -101,6 +111,9 @@
 
 		/* Get industry tile ID at offset */
 		case 0x62 : return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), inds);
+
+		/* Read GRF parameter */
+		case 0x7F: return GetGRFParameter(GetIndustryGfx(tile), parameter);
 	}
 
 	DEBUG(grf, 1, "Unhandled industry tile property 0x%X", variable);
@@ -413,8 +426,6 @@
 	DoTriggerIndustryTile(tile, trigger, GetIndustryByTile(tile));
 }
 
-extern void DoTriggerIndustry(Industry *ind, IndustryTileTrigger trigger);
-
 void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
 {
 	BEGIN_TILE_LOOP(tile, ind->width, ind->height, ind->xy)
@@ -422,6 +433,4 @@
 			DoTriggerIndustryTile(tile, trigger, ind);
 		}
 	END_TILE_LOOP(tile, ind->width, ind->height, ind->xy)
-
-	DoTriggerIndustry(ind, trigger);
 }
--- a/src/newgrf_sound.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_sound.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,12 +5,12 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "oldpool.h"
-#include "sound.h"
 #include "engine.h"
-#include "vehicle.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_engine.h"
 #include "newgrf_sound.h"
+#include "vehicle_base.h"
+#include "sound_func.h"
 
 static uint _sound_count = 0;
 STATIC_OLD_POOL(SoundInternal, FileEntry, 3, 1000, NULL, NULL)
--- a/src/newgrf_sound.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_sound.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef NEWGRF_SOUND_H
 #define NEWGRF_SOUND_H
 
+#include "sound_type.h"
+
 enum VehicleSoundEvent {
 	VSE_START        = 1,
 	VSE_TUNNEL       = 2,
--- a/src/newgrf_spritegroup.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_spritegroup.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,13 +5,12 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "variables.h"
-#include "macros.h"
 #include "landscape.h"
 #include "oldpool.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_spritegroup.h"
-#include "date.h"
 #include "sprite.h"
+#include "date_func.h"
 
 static void SpriteGroupPoolCleanBlock(uint start_item, uint end_item);
 
--- a/src/newgrf_spritegroup.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_spritegroup.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,9 +5,11 @@
 #ifndef NEWGRF_SPRITEGROUP_H
 #define NEWGRF_SPRITEGROUP_H
 
-#include "town.h"
-#include "industry.h"
+#include "town_type.h"
+#include "industry_type.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_station.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_station.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,7 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "variables.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
 #include "debug.h"
 #include "sprite.h"
@@ -18,11 +18,11 @@
 #include "newgrf_commons.h"
 #include "newgrf_station.h"
 #include "newgrf_spritegroup.h"
-#include "date.h"
-#include "helpers.hpp"
 #include "cargotype.h"
 #include "town_map.h"
 #include "newgrf_town.h"
+#include "gfx_func.h"
+#include "date_func.h"
 
 static StationClass station_classes[STAT_CLASS_MAX];
 
@@ -439,6 +439,34 @@
 
 		/* Variables which use the parameter */
 		/* Variables 0x60 to 0x65 are handled separately below */
+		case 0x67: { // Land info of nearby tiles
+			Axis axis = GetRailStationAxis(tile);
+
+			if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
+			byte tile_type = GetTerrainType(tile) << 2 | (IsTileType(tile, MP_WATER) ? 1 : 0) << 1;
+
+			uint z;
+			Slope tileh = GetTileSlope(tile, &z);
+			bool swap = (axis == AXIS_Y && HasBit(tileh, 0) != HasBit(tileh, 2));
+			return GetTileType(tile) << 24 | z << 16 | tile_type << 8 | (tileh ^ (swap ? 5 : 0));
+		}
+
+		case 0x68: { // Station info of nearby tiles
+			TileIndex nearby_tile = GetNearbyTile(parameter, tile);
+
+			if (!IsRailwayStationTile(nearby_tile)) return 0xFFFFFFFF;
+
+			uint32 grfid = st->speclist[GetCustomStationSpecIndex(tile)].grfid;
+			bool perpendicular = GetRailStationAxis(tile) != GetRailStationAxis(nearby_tile);
+			bool same_station = st->TileBelongsToRailStation(nearby_tile);
+			uint32 res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10;
+
+			if (IsCustomStationSpecIndex(nearby_tile)) {
+				const StationSpecList ssl = GetStationByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
+				res |= 1 << (ssl.grfid != grfid ? 9 : 8) | ssl.localidx;
+			}
+			return res;
+		}
 
 		/* General station properties */
 		case 0x82: return 50;
--- a/src/newgrf_station.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_station.h	Wed Jan 09 18:11:12 2008 +0000
@@ -8,7 +8,6 @@
 #include "engine.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_cargo.h"
-#include "helpers.hpp"
 
 enum StationClassID {
 	STAT_CLASS_BEGIN = 0,    ///< the lowest valid value
--- a/src/newgrf_storage.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_storage.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,7 +3,6 @@
 /** @file newgrf_storage.cpp Functionality related to the temporary and persistent storage arrays for NewGRFs. */
 
 #include "stdafx.h"
-#include "helpers.hpp"
 #include "newgrf_storage.h"
 #include <set>
 
--- a/src/newgrf_storage.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_storage.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef NEWGRF_STORAGE_H
 #define NEWGRF_STORAGE_H
 
+#include "core/alloc_func.hpp"
+
 /**
  * Base class for all NewGRF storage arrays. Nothing fancy, only here
  * so we have a generalised class to use.
--- a/src/newgrf_text.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_text.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -12,16 +12,15 @@
 #include "stdafx.h"
 #include "debug.h"
 #include "openttd.h"
-#include "string.h"
-#include "strings.h"
 #include "variables.h"
-#include "macros.h"
 #include "table/strings.h"
 #include "newgrf.h"
 #include "newgrf_text.h"
 #include "table/control_codes.h"
-#include "helpers.hpp"
-#include "date.h"
+#include "strings_func.h"
+#include "core/alloc_func.hpp"
+#include "newgrf_storage.h"
+#include "string_func.h"
 
 #define GRFTAB  28
 #define TABSIZE 11
@@ -207,9 +206,13 @@
 	}
 
 	for (;;) {
-		const char *tmp = str; // Used for UTF-8 decoding
-
-		c = (byte)*str++;
+		if (unicode && Utf8EncodedCharLen(*str) != 0) {
+			c = Utf8Consume(&str);
+			/* 'Magic' range of control codes. */
+			if (GB(c, 8, 8) == 0xE0) c = GB(c, 0, 8);
+		} else {
+			c = (byte)*str++;
+		}
 		if (c == 0) break;
 
 		switch (c) {
@@ -290,12 +293,6 @@
 			case 0xB7: d += Utf8Encode(d, SCC_PLANE); break;
 			case 0xB8: d += Utf8Encode(d, SCC_SHIP); break;
 			default:
-				if (unicode) {
-					d += Utf8Encode(d, Utf8Consume(&tmp));
-					str = tmp;
-					break;
-				}
-
 				/* Validate any unhandled character */
 				if (!IsValidChar(c, CS_ALPHANUMERAL)) c = '?';
 				d += Utf8Encode(d, c);
@@ -507,13 +504,25 @@
 	uint8  PopUnsignedByte()  { assert(this->position < lengthof(this->stack)); return this->stack[this->position++]; }
 	int8   PopSignedByte()    { return (int8)this->PopUnsignedByte(); }
 
-	uint16 PopUnsignedWord()  { return this->PopUnsignedByte()  | (((uint16)this->PopUnsignedByte())  <<  8); }
+	uint16 PopUnsignedWord()
+	{
+		uint16 val = this->PopUnsignedByte();
+		return val | (this->PopUnsignedByte() << 8);
+	}
 	int16  PopSignedWord()    { return (int32)this->PopUnsignedWord(); }
 
-	uint32 PopUnsignedDWord() { return this->PopUnsignedWord()  | (((uint32)this->PopUnsignedWord())  << 16); }
+	uint32 PopUnsignedDWord()
+	{
+		uint32 val = this->PopUnsignedWord();
+		return val | (this->PopUnsignedWord() << 16);
+	}
 	int32  PopSignedDWord()   { return (int32)this->PopUnsignedDWord(); }
 
-	uint64 PopUnsignedQWord() { return this->PopUnsignedDWord() | (((uint64)this->PopUnsignedDWord()) << 32); }
+	uint64 PopUnsignedQWord()
+	{
+		uint64 val = this->PopUnsignedDWord();
+		return val | (((uint64)this->PopUnsignedDWord()) << 32);
+	}
 	int64  PopSignedQWord()   { return (int64)this->PopUnsignedQWord(); }
 
 	/** Rotate the top four words down: W1, W2, W3, W4 -> W4, W1, W2, W3 */
--- a/src/newgrf_town.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_town.cpp	Wed Jan 09 18:11:12 2008 +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/newgrf_townname.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_townname.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -10,7 +10,8 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "newgrf_townname.h"
-#include "string.h"
+#include "core/alloc_func.hpp"
+#include "string_func.h"
 
 static GRFTownName *_grf_townnames = NULL;
 
--- a/src/news.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/news.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,11 @@
 #ifndef NEWS_H
 #define NEWS_H
 
+#include "window_type.h"
+#include "vehicle_type.h"
+#include "tile_type.h"
+#include "date_type.h"
+
 struct NewsItem {
 	StringID string_id; ///< Message text (sometimes also used for storing other info)
 	uint16 duration;    ///< Remaining time for showing this news message
--- a/src/news_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/news_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,21 +3,20 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
+#include "window_gui.h"
+#include "viewport_func.h"
 #include "news.h"
-#include "vehicle.h"
-#include "sound.h"
 #include "variables.h"
-#include "date.h"
-#include "string.h"
 #include "transparency.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_base.h"
+#include "sound_func.h"
+#include "string_func.h"
 
 /** @file news_gui.cpp
  *
@@ -220,7 +219,7 @@
 		if (w->viewport != NULL)
 			w->viewport->top += y - w->top;
 
-		diff = delta(w->top, y);
+		diff = Delta(w->top, y);
 		w->top = y;
 
 		SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
@@ -801,8 +800,8 @@
 {
 	element *= NB_WIDG_PER_SETTING;
 
-	SetWindowWidgetDisabledState(w, element + WIDGET_NEWSOPT_START_OPTION, value == 0);
-	SetWindowWidgetDisabledState(w, element + WIDGET_NEWSOPT_START_OPTION + 2, value == 2);
+	w->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION, value == 0);
+	w->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION + 2, value == 2);
 }
 
 /**
@@ -836,7 +835,7 @@
 			uint32 val = _news_display_opt;
 			int i, y;
 
-			if (_news_ticker_sound) LowerWindowWidget(w, WIDGET_NEWSOPT_SOUNDTICKER);
+			if (_news_ticker_sound) w->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER);
 			DrawWindowWidgets(w);
 
 			/* Draw the string of each setting on each button. */
@@ -859,8 +858,8 @@
 
 				case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off
 					_news_ticker_sound ^= 1;
-					ToggleWidgetLoweredState(w, e->we.click.widget);
-					InvalidateWidget(w, e->we.click.widget);
+					w->ToggleWidgetLoweredState(e->we.click.widget);
+					w->InvalidateWidget(e->we.click.widget);
 					break;
 
 				default: { // Clicked on the [<] .. [>] widgets
--- a/src/npf.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/npf.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,21 +4,24 @@
 
 #include "stdafx.h"
 #include "openttd.h"
+#include "npf.h"
 #include "bridge_map.h"
 #include "debug.h"
-#include "functions.h"
+#include "tile_cmd.h"
+#include "bridge.h"
 #include "landscape.h"
-#include "npf.h"
 #include "aystar.h"
-#include "macros.h"
 #include "pathfind.h"
 #include "station.h"
 #include "station_map.h"
-#include "tile.h"
 #include "depot.h"
 #include "tunnel_map.h"
 #include "network/network.h"
 #include "water_map.h"
+#include "tunnelbridge_map.h"
+#include "functions.h"
+#include "vehicle_base.h"
+#include "settings_type.h"
 
 static AyStar _npf_aystar;
 
@@ -40,8 +43,8 @@
  */
 static uint NPFDistanceTrack(TileIndex t0, TileIndex t1)
 {
-	const uint dx = delta(TileX(t0), TileX(t1));
-	const uint dy = delta(TileY(t0), TileY(t1));
+	const uint dx = Delta(TileX(t0), TileX(t1));
+	const uint dy = Delta(TileY(t0), TileY(t1));
 
 	const uint straightTracks = 2 * min(dx, dy); /* The number of straight (not full length) tracks */
 	/* OPTIMISATION:
@@ -170,7 +173,7 @@
 {
 	DiagDirection exitdir = TrackdirToExitdir((Trackdir)current->direction);
 	TileIndex tile = current->tile;
-	if (GetTunnelDirection(tile) == ReverseDiagDir(exitdir)) {
+	if (GetTunnelBridgeDirection(tile) == ReverseDiagDir(exitdir)) {
 		/* We just popped out if this tunnel, since were
 		 * facing the tunnel exit */
 		FindLengthOfTunnelResult flotr;
@@ -480,8 +483,7 @@
 			break;
 
 		case MP_TUNNELBRIDGE:
-			if ((IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) ||
-					(IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL)) {
+			if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
 				return IsTileOwner(tile, owner);
 			}
 			break;
@@ -533,14 +535,11 @@
 	DEBUG(npf, 4, "Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile);
 
 	/* Find dest tile */
-	if (IsTunnelTile(src_tile) && GetTunnelDirection(src_tile) == src_exitdir) {
-		/* This is a tunnel. We know this tunnel is our type,
+	if (IsTileType(src_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(src_tile) == src_exitdir) {
+		/* This is a tunnel/bridge. We know this tunnel/bridge is our type,
 		 * otherwise we wouldn't have got here. It is also facing us,
 		 * so we should skip it's body */
-		dst_tile = GetOtherTunnelEnd(src_tile);
-		override_dst_check = true;
-	} else if (IsBridgeTile(src_tile) && GetBridgeRampDirection(src_tile) == src_exitdir) {
-		dst_tile = GetOtherBridgeEnd(src_tile);
+		dst_tile = GetOtherTunnelBridgeEnd(src_tile);
 		override_dst_check = true;
 	} else if (type != TRANSPORT_WATER && (IsStandardRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) {
 		/* This is a road station (non drive-through) or a train or road depot. We can enter and exit
@@ -589,14 +588,9 @@
 	/* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note
 	 * that I can enter the tunnel from a tile below the tunnel entrance. This
 	 * solves the problem of vehicles wanting to drive off a tunnel entrance */
-	if (!override_dst_check) {
-		if (IsTileType(dst_tile, MP_TUNNELBRIDGE)) {
-			if (IsTunnel(dst_tile)) {
-				if (GetTunnelDirection(dst_tile) != src_exitdir) return;
-			} else {
-				if (GetBridgeRampDirection(dst_tile) != src_exitdir) return;
-			}
-		}
+	if (!override_dst_check && IsTileType(dst_tile, MP_TUNNELBRIDGE) &&
+			GetTunnelBridgeDirection(dst_tile) != src_exitdir) {
+		return;
 	}
 
 	/* check correct rail type (mono, maglev, etc) */
--- a/src/npf.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/npf.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,11 +5,11 @@
 #ifndef NPF_H
 #define NPF_H
 
-#include "openttd.h"
 #include "aystar.h"
 #include "station.h"
-#include "vehicle.h"
-#include "tile.h"
+#include "vehicle_type.h"
+#include "tile_type.h"
+#include "track_type.h"
 
 /* mowing grass */
 enum {
--- a/src/oldloader.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/oldloader.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,15 +6,11 @@
 #include "openttd.h"
 #include "station_map.h"
 #include "table/strings.h"
-#include "functions.h"
-#include "map.h"
 #include "town.h"
 #include "industry.h"
 #include "station.h"
-#include "economy.h"
 #include "player.h"
 #include "engine.h"
-#include "vehicle.h"
 #include "aircraft.h"
 #include "roadveh.h"
 #include "ship.h"
@@ -24,7 +20,11 @@
 #include "depot.h"
 #include "newgrf_config.h"
 #include "ai/ai.h"
-#include "date.h"
+#include "zoom_func.h"
+#include "functions.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "variables.h"
 
 enum {
 	HEADER_SIZE = 49,
@@ -302,7 +302,7 @@
 
 	/* Convert town-names if needed */
 	FOR_ALL_TOWNS(town) {
-		if (IS_INT_INSIDE(town->townnametype, 0x20C1, 0x20C3)) {
+		if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
 			town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _opt.town_name;
 			town->townnameparts = GetOldTownName(town->townnameparts, _opt.town_name);
 		}
@@ -1475,7 +1475,6 @@
 	for (Engine *e = _engines; e != endof(_engines); e++) {
 		if (_date >= (e->intro_date + 365)) {
 			e->flags = (e->flags & ~ENGINE_EXCLUSIVE_PREVIEW) | ENGINE_AVAILABLE;
-			AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
 			e->player_avail = (byte)-1;
 		}
 	}
@@ -1485,8 +1484,6 @@
 	FixOldStations();
 	FixOldVehicles();
 
-	AddTypeToEngines();
-
 	/* We have a new difficulty setting */
 	_opt.diff.town_council_tolerance = Clamp(_opt.diff_level, 0, 2);
 
--- a/src/oldpool.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/oldpool.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,9 +5,8 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "oldpool.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
 
 /**
  * Clean a pool in a safe way (does free all blocks)
@@ -55,12 +54,9 @@
 
 	/* Increase the poolsize */
 	this->blocks = ReallocT(this->blocks, this->current_blocks + 1);
-	if (this->blocks == NULL) error("Pool: (%s) could not allocate memory for blocks", this->name);
 
 	/* Allocate memory to the new block item */
 	this->blocks[this->current_blocks] = MallocT<byte>(this->item_size * (1 << this->block_size_bits));
-	if (this->blocks[this->current_blocks] == NULL)
-		error("Pool: (%s) could not allocate memory for blocks", this->name);
 
 	/* Clean the content of the new block */
 	memset(this->blocks[this->current_blocks], 0, this->item_size * (1 << this->block_size_bits));
--- a/src/oldpool.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/oldpool.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef OLDPOOL_H
 #define OLDPOOL_H
 
+#include "core/math_func.hpp"
+
 /* The function that is called after a new block is added
      start_item is the first item of the new made block */
 typedef void OldMemoryPoolNewBlock(uint start_item);
@@ -47,6 +49,16 @@
 	byte **blocks;              ///< An array of blocks (one block hold all the items)
 
 	/**
+	 * Check if the index of pool item being deleted is lower than cached first_free_index
+	 * @param index index of pool item
+	 * @note usage of min() will result in better code on some architectures
+	 */
+	inline void UpdateFirstFreeIndex(uint index)
+	{
+		first_free_index = min(first_free_index, index);
+	}
+
+	/**
 	 * Get the size of this pool, i.e. the total number of items you
 	 * can put into it at the current moment; the pool might still
 	 * be able to increase the size of the pool.
@@ -157,10 +169,26 @@
 
 	/**
 	 * We like to have the correct class destructed.
+	 * @warning It is called even for object allocated on stack,
+	 *          so it is not present in the TPool!
+	 *          Then, index is undefined, not associated with TPool in any way.
+	 * @note    The idea is to free up allocated memory etc.
 	 */
 	virtual ~PoolItem()
 	{
-		if (this->index < Tpool->first_free_index) Tpool->first_free_index = this->index;
+
+	}
+
+	/**
+	 * Constructor of given class.
+	 * @warning It is called even for object allocated on stack,
+	 *          so it may not be present in TPool!
+	 *          Then, index is undefined, not associated with TPool in any way.
+	 * @note    The idea is to initialize variables (except index)
+	 */
+	PoolItem()
+	{
+
 	}
 
 	/**
@@ -176,9 +204,11 @@
 	/**
 	 * 'Free' the memory allocated by the overriden new.
 	 * @param p the memory to 'free'
+	 * @note we only update Tpool->first_free_index
 	 */
 	void operator delete(void *p)
 	{
+		Tpool->UpdateFirstFreeIndex(((T*)p)->index);
 	}
 
 	/**
@@ -199,9 +229,11 @@
 	 * 'Free' the memory allocated by the overriden new.
 	 * @param p     the memory to 'free'
 	 * @param index the original parameter given to create the memory
+	 * @note we only update Tpool->first_free_index
 	 */
 	void operator delete(void *p, int index)
 	{
+		Tpool->UpdateFirstFreeIndex(index);
 	}
 
 	/**
@@ -220,9 +252,11 @@
 	 * 'Free' the memory allocated by the overriden new.
 	 * @param p  the memory to 'free'
 	 * @param pn the pointer that was given to 'new' on creation.
+	 * @note we only update Tpool->first_free_index
 	 */
 	void operator delete(void *p, T *pn)
 	{
+		Tpool->UpdateFirstFreeIndex(pn->index);
 	}
 
 private:
--- a/src/openttd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/openttd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,25 +4,16 @@
 
 #include "stdafx.h"
 #define VARDEF
-#include "string.h"
 #include "debug.h"
 #include "driver.h"
 #include "saveload.h"
-#include "map.h"
-#include "tile.h"
-#include "void_map.h"
-#include "helpers.hpp"
 #include "ai/ai_factory.hpp"
 
 #include "openttd.h"
 #include "table/strings.h"
-#include "strings.h"
 #include "bridge_map.h"
-#include "functions.h"
 #include "mixer.h"
 #include "spritecache.h"
-#include "strings.h"
-#include "gfx.h"
 #include "gfxinit.h"
 #include "gui.h"
 #include "landscape.h"
@@ -30,18 +21,18 @@
 #include "station_map.h"
 #include "town_map.h"
 #include "tunnel_map.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "window.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
+#include "window_func.h"
+#include "window_gui.h"
 #include "player.h"
-#include "command.h"
+#include "command_func.h"
 #include "town.h"
 #include "industry.h"
 #include "news.h"
 #include "engine.h"
-#include "sound.h"
-#include "economy.h"
 #include "fileio.h"
+#include "fios.h"
 #include "airport.h"
 #include "aircraft.h"
 #include "console.h"
@@ -53,9 +44,8 @@
 #include "ai/ai.h"
 #include "train.h"
 #include "yapf/yapf.h"
-#include "settings.h"
+#include "settings_func.h"
 #include "genworld.h"
-#include "date.h"
 #include "clear_map.h"
 #include "fontcache.h"
 #include "newgrf.h"
@@ -69,6 +59,12 @@
 #include "sound/sound_driver.hpp"
 #include "music/music_driver.hpp"
 #include "video/video_driver.hpp"
+#include "strings_func.h"
+#include "zoom_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "variables.h"
 
 #include "bridge_map.h"
 #include "clear_map.h"
@@ -78,6 +74,8 @@
 #include "industry_map.h"
 #include "unmovable_map.h"
 #include "tree_map.h"
+#include "tunnelbridge_map.h"
+#include "void_map.h"
 
 #include <stdarg.h>
 
@@ -123,34 +121,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()
 {
@@ -348,6 +318,8 @@
 	_cursor.fix_at = false;
 	MarkWholeScreenDirty();
 
+	CheckForMissingGlyphsInLoadedLanguagePack();
+
 	/* Play main theme */
 	if (_music_driver->IsSongPlaying()) ResetMusic();
 }
@@ -733,6 +705,13 @@
 	SettingsDisableElrail(_patches.disable_elrails);
 	SetDefaultRailGui();
 
+	/* We are the server, we start a new player (not dedicated),
+	 * so set the default password *if* needed. */
+	if (_network_server && !StrEmpty(_network_default_company_pass)) {
+		char *password = _network_default_company_pass;
+		NetworkChangeCompanyPassword(1, &password);
+	}
+
 	MarkWholeScreenDirty();
 }
 
@@ -904,6 +883,7 @@
 	case SM_LOAD: { /* Load game, Play Scenario */
 		_opt_ptr = &_opt;
 		ResetGRFConfig(true);
+		ResetWindowSystem();
 
 		if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL, NO_DIRECTORY)) {
 			LoadIntroGame();
@@ -913,7 +893,8 @@
 			/* Update the local player for a loaded game. It is either always
 			 * player #1 (eg 0) or in the case of a dedicated server a spectator */
 			SetLocalPlayer(_network_dedicated ? PLAYER_SPECTATOR : PLAYER_FIRST);
-			DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // decrease pause counter (was increased from opening load dialog)
+			/* Decrease pause counter (was increased from opening load dialog) */
+			DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
 #ifdef ENABLE_NETWORK
 			if (_network_server) {
 				snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title);
@@ -957,12 +938,15 @@
 		break;
 
 	case SM_SAVE: /* Save game */
+		/* Make network saved games on pause compatible to singleplayer */
+		if (_networking && _pause_game == 1) _pause_game = 2;
 		if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) {
 			SetDParamStr(0, GetSaveLoadErrorString());
 			ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
 		} else {
 			DeleteWindowById(WC_SAVELOAD, 0);
 		}
+		if (_networking && _pause_game == 2) _pause_game = 1;
 		break;
 
 	case SM_GENRANDLAND: /* Generate random land within scenario editor */
@@ -988,7 +972,10 @@
 	ClearStorageChanges(false);
 
 	/* dont execute the state loop during pause */
-	if (_pause_game) return;
+	if (_pause_game) {
+		CallWindowTickEvent();
+		return;
+	}
 	if (IsGeneratingWorld()) return;
 
 	if (_game_mode == GM_EDITOR) {
@@ -1052,28 +1039,36 @@
 		Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 		assert(w);
 
-		WP(w,vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
-		WP(w,vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
+		WP(w, vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
+		WP(w, vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
 	}
 }
-
+/**
+ * Describes all the different arrow key combinations the game allows
+ * when it is in scrolling mode.
+ * The real arrow keys are bitwise numbered as
+ * 1 = left
+ * 2 = up
+ * 4 = right
+ * 8 = down
+ */
 static const int8 scrollamt[16][2] = {
-	{ 0,  0},
+	{ 0,  0}, ///<  no key specified
 	{-2,  0}, ///<  1 : left
 	{ 0, -2}, ///<  2 : up
-	{-2, -1}, ///<  3 : left + up
+	{-2, -1}, ///<  3 : left  + up
 	{ 2,  0}, ///<  4 : right
-	{ 0,  0}, ///<  5 : left + right
+	{ 0,  0}, ///<  5 : left  + right = nothing
 	{ 2, -1}, ///<  6 : right + up
-	{ 0, -2}, ///<  7 : left + right + up = up
+	{ 0, -2}, ///<  7 : right + left  + up = up
 	{ 0  ,2}, ///<  8 : down
-	{-2  ,1}, ///<  9 : down+left
-	{ 0,  0}, ///< 10 : impossible
-	{-2,  0}, ///< 11 : left + up + down = left
-	{ 2,  1}, ///< 12 : down+right
-	{ 0,  2}, ///< 13 : left + right + down = down
-	{ 0, -2}, ///< 14 : left + right + up = up
-	{ 0,  0}, ///< 15 : impossible
+	{-2  ,1}, ///<  9 : down  + left
+	{ 0,  0}, ///< 10 : down  + up    = nothing
+	{-2,  0}, ///< 11 : left  + up    +  down = left
+	{ 2,  1}, ///< 12 : down  + right
+	{ 0,  2}, ///< 13 : left  + right +  down = down
+	{ 2,  0}, ///< 14 : right + up    +  down = right
+	{ 0,  0}, ///< 15 : left  + up    +  right + down  = nothing
 };
 
 static void HandleKeyScrolling()
@@ -1252,6 +1247,79 @@
 	return rt >= min ? (RailType)(rt + 1): rt;
 }
 
+/**
+ * Initialization of the windows and several kinds of caches.
+ * This is not done directly in AfterLoadGame because these
+ * functions require that all saveload conversions have been
+ * done. As people tend to add savegame conversion stuff after
+ * the intialization of the windows and caches quite some bugs
+ * had been made.
+ * Moving this out of there is both cleaner and less bug-prone.
+ *
+ * @return true if everything went according to plan, otherwise false.
+ */
+static bool InitializeWindowsAndCaches()
+{
+	/* Initialize windows */
+	ResetWindowSystem();
+	SetupColorsAndInitialWindow();
+
+	Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
+
+	WP(w, vp_d).scrollpos_x = _saved_scrollpos_x;
+	WP(w, vp_d).scrollpos_y = _saved_scrollpos_y;
+	WP(w, vp_d).dest_scrollpos_x = _saved_scrollpos_x;
+	WP(w, vp_d).dest_scrollpos_y = _saved_scrollpos_y;
+
+	ViewPort *vp = w->viewport;
+	vp->zoom = min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
+	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
+	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
+
+	DoZoomInOutWindow(ZOOM_NONE, w); // update button status
+	MarkWholeScreenDirty();
+
+	/* Update coordinates of the signs. */
+	UpdateAllStationVirtCoord();
+	UpdateAllSignVirtCoords();
+	UpdateAllTownVirtCoords();
+	UpdateAllWaypointSigns();
+
+	/* Recalculate */
+	Group *g;
+	FOR_ALL_GROUPS(g) {
+		const Vehicle *v;
+		FOR_ALL_VEHICLES(v) {
+			if (!IsEngineCountable(v)) continue;
+
+			if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue;
+
+			g->num_engines[v->engine_type]++;
+		}
+	}
+
+	/* Set up the engine count for all players */
+	Player *players[MAX_PLAYERS];
+	const Vehicle *v;
+
+	for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
+		players[i] = GetPlayer(i);
+
+		/* For each player, verify (while loading a scenario) that the inauguration date is the current year and set it
+		 * accordingly if it is not the case.  No need to set it on players that are not been used already,
+		 * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */
+		if (_file_to_saveload.filetype == FT_SCENARIO && players[i]->inaugurated_year != MIN_YEAR)
+			players[i]->inaugurated_year = _cur_year;
+	}
+
+	FOR_ALL_VEHICLES(v) {
+		if (!IsEngineCountable(v)) continue;
+		players[v->owner]->num_engines[v->engine_type]++;
+	}
+
+	return true;
+}
+
 bool AfterLoadGame()
 {
 	TileIndex map_size = MapSize();
@@ -1293,7 +1361,7 @@
 
 	switch (gcf_res) {
 		case GLC_COMPATIBLE: _switch_mode_errorstr = STR_NEWGRF_COMPATIBLE_LOAD_WARNING; break;
-		case GLC_NOT_FOUND: _switch_mode_errorstr = STR_NEWGRF_DISABLED_WARNING; break;
+		case GLC_NOT_FOUND: _switch_mode_errorstr = STR_NEWGRF_DISABLED_WARNING; _pause_game = (byte)-1; break;
 		default: break;
 	}
 
@@ -1316,21 +1384,15 @@
 	InitializeLandscapeVariables(true);
 
 	/* Update all vehicles */
-	AfterLoadVehicles();
+	AfterLoadVehicles(true);
 
 	/* Update all waypoints */
 	if (CheckSavegameVersion(12)) FixOldWaypoints();
 
-	UpdateAllWaypointSigns();
-
 	/* in version 2.2 of the savegame, we have new airports */
 	if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft();
 
-	UpdateAllStationVirtCoord();
-
-	/* Setup town coords */
 	AfterLoadTown();
-	UpdateAllSignVirtCoords();
 
 	/* make sure there is a town in the game */
 	if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) {
@@ -1366,34 +1428,34 @@
 					if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2);
 					StationGfx gfx = GetStationGfx(t);
 					StationType st;
-					if (       IS_INT_INSIDE(gfx,   0,   8)) { // Railway station
+					if (       IsInsideMM(gfx,   0,   8)) { // Railway station
 						st = STATION_RAIL;
 						SetStationGfx(t, gfx - 0);
-					} else if (IS_INT_INSIDE(gfx,   8,  67)) { // Airport
+					} else if (IsInsideMM(gfx,   8,  67)) { // Airport
 						st = STATION_AIRPORT;
 						SetStationGfx(t, gfx - 8);
-					} else if (IS_INT_INSIDE(gfx,  67,  71)) { // Truck
+					} else if (IsInsideMM(gfx,  67,  71)) { // Truck
 						st = STATION_TRUCK;
 						SetStationGfx(t, gfx - 67);
-					} else if (IS_INT_INSIDE(gfx,  71,  75)) { // Bus
+					} else if (IsInsideMM(gfx,  71,  75)) { // Bus
 						st = STATION_BUS;
 						SetStationGfx(t, gfx - 71);
 					} else if (gfx == 75) {                    // Oil rig
 						st = STATION_OILRIG;
 						SetStationGfx(t, gfx - 75);
-					} else if (IS_INT_INSIDE(gfx,  76,  82)) { // Dock
+					} else if (IsInsideMM(gfx,  76,  82)) { // Dock
 						st = STATION_DOCK;
 						SetStationGfx(t, gfx - 76);
 					} else if (gfx == 82) {                    // Buoy
 						st = STATION_BUOY;
 						SetStationGfx(t, gfx - 82);
-					} else if (IS_INT_INSIDE(gfx,  83, 168)) { // Extended airport
+					} else if (IsInsideMM(gfx,  83, 168)) { // Extended airport
 						st = STATION_AIRPORT;
 						SetStationGfx(t, gfx - 83 + 67 - 8);
-					} else if (IS_INT_INSIDE(gfx, 168, 170)) { // Drive through truck
+					} else if (IsInsideMM(gfx, 168, 170)) { // Drive through truck
 						st = STATION_TRUCK;
 						SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
-					} else if (IS_INT_INSIDE(gfx, 170, 172)) { // Drive through bus
+					} else if (IsInsideMM(gfx, 170, 172)) { // Drive through bus
 						st = STATION_BUS;
 						SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
 					} else {
@@ -1569,7 +1631,7 @@
 				case MP_TUNNELBRIDGE:
 					/* Middle part of "old" bridges */
 					if (old_bridge && IsBridgeTile(t) && HasBit(_m[t].m5, 6)) break;
-					if ((IsTunnel(t) ? GetTunnelTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetBridgeTransportType(t))) == TRANSPORT_ROAD) {
+					if ((IsTunnel(t) ? GetTunnelBridgeTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t))) == TRANSPORT_ROAD) {
 						SetRoadTypes(t, ROADTYPES_ROAD);
 					}
 					break;
@@ -1629,7 +1691,7 @@
 		FOR_ALL_VEHICLES(v) {
 			if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue;
 			if (IsBridgeTile(v->tile)) {
-				DiagDirection dir = GetBridgeRampDirection(v->tile);
+				DiagDirection dir = GetTunnelBridgeDirection(v->tile);
 
 				if (dir != DirToDiagDir(v->direction)) continue;
 				switch (dir) {
@@ -1686,14 +1748,8 @@
 					break;
 
 				case MP_TUNNELBRIDGE:
-					if (IsTunnel(t)) {
-						if (GetTunnelTransportType(t) == TRANSPORT_RAIL) {
-							SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
-						}
-					} else {
-						if (GetBridgeTransportType(t) == TRANSPORT_RAIL) {
-							SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
-						}
+					if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
+						SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
 					}
 					break;
 
@@ -1824,19 +1880,6 @@
 
 	if (!CheckSavegameVersion(27)) AfterLoadStations();
 
-	{
-		/* Set up the engine count for all players */
-		Player *players[MAX_PLAYERS];
-		const Vehicle *v;
-
-		for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) players[i] = GetPlayer(i);
-
-		FOR_ALL_VEHICLES(v) {
-			if (!IsEngineCountable(v)) continue;
-			players[v->owner]->num_engines[v->engine_type]++;
-		}
-	}
-
 	/* Time starts at 0 instead of 1920.
 	 * Account for this in older games by adding an offset */
 	if (CheckSavegameVersion(31)) {
@@ -2158,6 +2201,20 @@
 		}
 	}
 
+	/*
+	 * Add the 'previous' owner to the ship depots so we can reset it with
+	 * the correct values when it gets destroyed. This prevents that
+	 * someone can remove canals owned by somebody else and it prevents
+	 * making floods using the removal of ship depots.
+	 */
+	if (CheckSavegameVersion(83)) {
+		for (TileIndex t = 0; t < map_size; t++) {
+			if (IsTileType(t, MP_WATER) && IsShipDepot(t)) {
+				_m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
+			}
+		}
+	}
+
 	if (CheckSavegameVersion(74)) {
 		Station *st;
 		FOR_ALL_STATIONS(st) {
@@ -2195,39 +2252,36 @@
 		}
 	}
 
-	/* Initialize windows */
-	ResetWindowSystem();
-	SetupColorsAndInitialWindow();
-
-	Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
-
-	WP(w, vp_d).scrollpos_x = _saved_scrollpos_x;
-	WP(w, vp_d).scrollpos_y = _saved_scrollpos_y;
-	WP(w, vp_d).dest_scrollpos_x = _saved_scrollpos_x;
-	WP(w, vp_d).dest_scrollpos_y = _saved_scrollpos_y;
+	if (CheckSavegameVersion(84)) {
+		/* Update go to buoy orders because they are just waypoints */
+		Order *order;
+		FOR_ALL_ORDERS(order) {
+			if (order->type == OT_GOTO_STATION && GetStation(order->dest)->IsBuoy()) {
+				order->flags = 0;
+			}
+		}
 
-	ViewPort *vp = w->viewport;
-	vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
-	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
-	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
-
-	DoZoomInOutWindow(ZOOM_NONE, w); // update button status
-	MarkWholeScreenDirty();
-
-	/* Recalculate */
-	Group *g;
-	FOR_ALL_GROUPS(g) {
-		const Vehicle *v;
-		FOR_ALL_VEHICLES(v) {
-			if (!IsEngineCountable(v)) continue;
-
-			if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue;
-
-			g->num_engines[v->engine_type]++;
+		/* Set all share owners to PLAYER_SPECTATOR for
+		 * 1) all inactive players
+		 *     (when inactive players were stored in the savegame - TTD, TTDP and some
+		 *      *really* old revisions of OTTD; else it is already set in InitializePlayers())
+		 * 2) shares that are owned by inactive players or self
+		 *     (caused by cheating players in earlier revisions) */
+		Player *p;
+		FOR_ALL_PLAYERS(p) {
+			if (!p->is_active) {
+				for (uint i = 0; i < 4; i++) { p->share_owners[i] = PLAYER_SPECTATOR; }
+			} else {
+				for (uint i = 0; i < 4; i++) {
+					PlayerID o = p->share_owners[i];
+					if (o == PLAYER_SPECTATOR) continue;
+					if (!IsValidPlayer(o) || o == p->index || !GetPlayer(o)->is_active) p->share_owners[i] = PLAYER_SPECTATOR;
+				}
+			}
 		}
 	}
 
-	return true;
+	return InitializeWindowsAndCaches();
 }
 
 /** Reload all NewGRF files during a running game. This is a cut-down
@@ -2243,7 +2297,7 @@
 	LoadStringWidthTable();
 	/* reload vehicles */
 	ResetVehiclePosHash();
-	AfterLoadVehicles();
+	AfterLoadVehicles(false);
 	StartupEngines();
 	/* update station and waypoint graphics */
 	AfterLoadWaypoints();
--- a/src/openttd.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/openttd.h	Wed Jan 09 18:11:12 2008 +0000
@@ -8,60 +8,28 @@
 #define VARDEF extern
 #endif
 
-#include "helpers.hpp"
-
-struct Oblong {
-	int x, y;
-	int width, height;
-};
-
-struct BoundingRect {
-	int width;
-	int height;
-};
-
-struct Pair {
-	int a;
-	int b;
-};
-
-#include "map.h"
-#include "slope.h"
+#include "core/enum_type.hpp"
+#include "strings_type.h"
 
 // Forward declarations of structs.
-struct Vehicle;
 struct Depot;
 struct Waypoint;
-struct Window;
 struct Station;
 struct ViewPort;
-struct Town;
 struct NewsItem;
-struct Industry;
 struct DrawPixelInfo;
 struct Group;
 typedef byte VehicleOrderID;  ///< The index of an order within its current vehicle (not pool related)
-typedef byte CargoID;
 typedef byte LandscapeID;
-typedef uint32 SpriteID;      ///< The number of a sprite, without mapping bits and colortables
-struct PalSpriteID {
-	SpriteID sprite;
-	SpriteID pal;
-};
 typedef uint16 EngineID;
 typedef uint16 UnitID;
-typedef uint16 StringID;
-static const StringID INVALID_STRING_ID = 0xFFFF;
 
 typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C code (see helpers.cpp)
 
 /* IDs used in Pools */
-typedef uint16 VehicleID;
 typedef uint16 StationID;
 static const StationID INVALID_STATION = 0xFFFF;
 typedef uint16 RoadStopID;
-typedef uint16 TownID;
-typedef uint16 IndustryID;
 typedef uint16 DepotID;
 typedef uint16 WaypointID;
 typedef uint16 OrderID;
@@ -70,9 +38,6 @@
 typedef uint16 EngineRenewID;
 typedef uint16 DestinationID;
 
-typedef OverflowSafeInt<int64, INT64_MAX, INT64_MIN> OverflowSafeInt64;
-typedef OverflowSafeInt64 Money;
-
 /* DestinationID must be at least as large as every these below, because it can
  * be any of them
  */
@@ -80,18 +45,14 @@
 assert_compile(sizeof(DestinationID) == sizeof(WaypointID));
 assert_compile(sizeof(DestinationID) == sizeof(StationID));
 
-typedef int32 WindowNumber;
+typedef uint32 PlayerFace; ///< player face bits, info see in player_face.h
 
-enum {
-	INVALID_YEAR = -1,
-	INVALID_DATE = -1,
+enum GameModes {
+	GM_MENU,
+	GM_NORMAL,
+	GM_EDITOR
 };
 
-typedef int32 Year;
-typedef int32 Date;
-
-typedef uint32 PlayerFace; ///< player face bits, info see in player_face.h
-
 enum SwitchModes {
 	SM_NONE            =  0,
 	SM_NEWGAME         =  1,
@@ -168,15 +129,6 @@
 typedef TinyEnumT<TransportType> TransportTypeByte;
 
 
-struct TileInfo {
-	uint x;
-	uint y;
-	Slope tileh;
-	TileIndex tile;
-	uint z;
-};
-
-
 /* Display Options */
 enum {
 	DO_SHOW_TOWN_NAMES    = 0,
@@ -197,78 +149,6 @@
 	NUM_LANDSCAPE = 4,
 };
 
-/**
- * Town Layouts
- */
-enum TownLayout {
-	TL_NO_ROADS     = 0, ///< Build no more roads, but still build houses
-	TL_ORIGINAL,         ///< Original algorithm (min. 1 distance between roads)
-	TL_BETTER_ROADS,     ///< Extended original algorithm (min. 2 distance between roads)
-	TL_2X2_GRID,         ///< Geometric 2x2 grid algorithm
-	TL_3X3_GRID,         ///< Geometric 3x3 grid algorithm
-
-	NUM_TLS,             ///< Number of town layouts
-};
-
-/* It needs to be 8bits, because we save and load it as such */
-/** Define basic enum properties */
-template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {};
-typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
-
-enum {
-	NUM_PRICES = 49,
-};
-
-struct Prices {
-	Money station_value;
-	Money build_rail;
-	Money build_road;
-	Money build_signals;
-	Money build_bridge;
-	Money build_train_depot;
-	Money build_road_depot;
-	Money build_ship_depot;
-	Money build_tunnel;
-	Money train_station_track;
-	Money train_station_length;
-	Money build_airport;
-	Money build_bus_station;
-	Money build_truck_station;
-	Money build_dock;
-	Money build_railvehicle;
-	Money build_railwagon;
-	Money aircraft_base;
-	Money roadveh_base;
-	Money ship_base;
-	Money build_trees;
-	Money terraform;
-	Money clear_1;
-	Money purchase_land;
-	Money clear_2;
-	Money clear_3;
-	Money remove_trees;
-	Money remove_rail;
-	Money remove_signals;
-	Money clear_bridge;
-	Money remove_train_depot;
-	Money remove_road_depot;
-	Money remove_ship_depot;
-	Money clear_tunnel;
-	Money clear_water;
-	Money remove_rail_station;
-	Money remove_airport;
-	Money remove_bus_station;
-	Money remove_truck_station;
-	Money remove_dock;
-	Money remove_house;
-	Money remove_road;
-	Money running_rail[3];
-	Money aircraft_running;
-	Money roadveh_running;
-	Money ship_running;
-	Money build_industry;
-};
-
 #define GAME_DIFFICULTY_NUM 18
 
 /** Specific type for Game Difficulty to ease changing the type */
@@ -294,377 +174,12 @@
 	GDType town_council_tolerance; // minimum required town ratings to be allowed to demolish stuff
 };
 
-enum {
-	// Temperate
-	CT_PASSENGERS   =  0,
-	CT_COAL         =  1,
-	CT_MAIL         =  2,
-	CT_OIL          =  3,
-	CT_LIVESTOCK    =  4,
-	CT_GOODS        =  5,
-	CT_GRAIN        =  6,
-	CT_WOOD         =  7,
-	CT_IRON_ORE     =  8,
-	CT_STEEL        =  9,
-	CT_VALUABLES    = 10,
-
-	// Arctic
-	CT_WHEAT        =  6,
-	CT_HILLY_UNUSED =  8,
-	CT_PAPER        =  9,
-	CT_GOLD         = 10,
-	CT_FOOD         = 11,
-
-	// Tropic
-	CT_RUBBER       =  1,
-	CT_FRUIT        =  4,
-	CT_MAIZE        =  6,
-	CT_COPPER_ORE   =  8,
-	CT_WATER        =  9,
-	CT_DIAMONDS     = 10,
-
-	// Toyland
-	CT_SUGAR        =  1,
-	CT_TOYS         =  3,
-	CT_BATTERIES    =  4,
-	CT_CANDY        =  5,
-	CT_TOFFEE       =  6,
-	CT_COLA         =  7,
-	CT_COTTON_CANDY =  8,
-	CT_BUBBLES      =  9,
-	CT_PLASTIC      = 10,
-	CT_FIZZY_DRINKS = 11,
-
-	NUM_CARGO       = 32,
-
-	CT_NO_REFIT     = 0xFE,
-	CT_INVALID      = 0xFF
-};
-
-typedef uint AcceptedCargo[NUM_CARGO];
-
-struct TileDesc {
-	StringID str;
-	Owner owner;
-	Date build_date;
-	uint64 dparam[2];
-};
-
 struct ViewportSign {
 	int32 left;
 	int32 top;
 	byte width_1, width_2;
 };
 
-/**
- * Common return value for all commands. Wraps the cost and
- * a possible error message/state together.
- */
-class CommandCost {
-	Money cost;       ///< The cost of this action
-	StringID message; ///< Warning message for when success is unset
-	bool success;     ///< Whether the comment went fine up to this moment
-
-public:
-	/**
-	 * Creates a command cost return with no cost and no error
-	 */
-	CommandCost() : cost(0), message(INVALID_STRING_ID), success(true) {}
-
-	/**
-	 * Creates a command return value the is failed with the given message
-	 */
-	CommandCost(StringID msg) : cost(0), message(msg), success(false) {}
-
-	/**
-	 * Creates a command return value with the given start cost
-	 * @param cst the initial cost of this command
-	 */
-	CommandCost(Money cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
-
-	/**
-	 * Adds the cost of the given command return value to this cost.
-	 * Also takes a possible error message when it is set.
-	 * @param ret the command to add the cost of.
-	 * @return this class.
-	 */
-	CommandCost AddCost(CommandCost ret);
-
-	/**
-	 * Adds the given cost to the cost of the command.
-	 * @param cost the cost to add
-	 * @return this class.
-	 */
-	CommandCost AddCost(Money cost);
-
-	/**
-	 * Multiplies the cost of the command by the given factor.
-	 * @param cost factor to multiply the costs with
-	 * @return this class
-	 */
-	CommandCost MultiplyCost(int factor);
-
-	/**
-	 * The costs as made up to this moment
-	 * @return the costs
-	 */
-	Money GetCost() const;
-
-	/**
-	 * Sets the global error message *if* this class has one.
-	 */
-	void SetGlobalErrorMessage() const;
-
-	/**
-	 * Did this command succeed?
-	 * @return true if and only if it succeeded
-	 */
-	bool Succeeded() const;
-
-	/**
-	 * Did this command fail?
-	 * @return true if and only if it failed
-	 */
-	bool Failed() const;
-};
-
-
-typedef void DrawTileProc(TileInfo *ti);
-typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
-typedef CommandCost ClearTileProc(TileIndex tile, byte flags);
-typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
-typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
-/**
- * GetTileTrackStatusProcs return a value that contains the possible tracks
- * that can be taken on a given tile by a given transport. The return value is
- * composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs,
- * where bit n corresponds to trackdir n. ccdd are the trackdirs that are
- * present in the tile (1==present, 0==not present), aabb is the signal
- * status, if applicable (0==green/no signal, 1==red, note that this is
- * reversed from map3/2[tile] for railway signals).
- *
- * The result (let's call it ts) is often used as follows:
- * tracks = (byte)(ts | ts >>8)
- * This effectively converts the present part of the result (ccdd) to a
- * track bitmask, which disregards directions. Normally, this is the same as just
- * doing (byte)ts I think, although I am not really sure
- *
- * A trackdir is combination of a track and a dir, where the lower three bits
- * are a track, the fourth bit is the direction. these give 12 (or 14)
- * possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask
- * above.
- * @param tile     the tile to get the track status from
- * @param mode     the mode of transportation
- * @param sub_mode used to differentiate between different kinds within the mode
- * @return the above mentions track status information
- */
-typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode);
-typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
-typedef void ClickTileProc(TileIndex tile);
-typedef void AnimateTileProc(TileIndex tile);
-typedef void TileLoopProc(TileIndex tile);
-typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
-/** @see VehicleEnterTileStatus to see what the return values mean */
-typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
-typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
-/**
- * Called when a tile is affected by a terraforming operation.
- * The function has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype.
- * With DC_EXEC in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).
- *
- * @note The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation.
- *
- * @param tile      The involved tile.
- * @param flags     Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.).
- * @param z_new     TileZ after terraforming.
- * @param tileh_new Slope after terraforming.
- * @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
- */
-typedef CommandCost TerraformTileProc(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new);
-
-struct TileTypeProcs {
-	DrawTileProc *draw_tile_proc;
-	GetSlopeZProc *get_slope_z_proc;
-	ClearTileProc *clear_tile_proc;
-	GetAcceptedCargoProc *get_accepted_cargo_proc;
-	GetTileDescProc *get_tile_desc_proc;
-	GetTileTrackStatusProc *get_tile_track_status_proc;
-	ClickTileProc *click_tile_proc;
-	AnimateTileProc *animate_tile_proc;
-	TileLoopProc *tile_loop_proc;
-	ChangeTileOwnerProc *change_tile_owner_proc;
-	GetProducedCargoProc *get_produced_cargo_proc;
-	VehicleEnterTileProc *vehicle_enter_tile_proc;
-	GetFoundationProc *get_foundation_proc;
-	TerraformTileProc *terraform_tile_proc;
-};
-
-
-enum WindowClass {
-	WC_NONE,
-	WC_MAIN_WINDOW = WC_NONE,
-	WC_MAIN_TOOLBAR,
-	WC_STATUS_BAR,
-	WC_BUILD_TOOLBAR,
-	WC_NEWS_WINDOW,
-	WC_TOWN_DIRECTORY,
-	WC_STATION_LIST,
-	WC_TOWN_VIEW,
-	WC_SMALLMAP,
-	WC_TRAINS_LIST,
-	WC_ROADVEH_LIST,
-	WC_SHIPS_LIST,
-	WC_AIRCRAFT_LIST,
-	WC_VEHICLE_VIEW,
-	WC_VEHICLE_DETAILS,
-	WC_VEHICLE_REFIT,
-	WC_VEHICLE_ORDERS,
-	WC_STATION_VIEW,
-	WC_VEHICLE_DEPOT,
-	WC_BUILD_VEHICLE,
-	WC_BUILD_BRIDGE,
-	WC_ERRMSG,
-	WC_BUILD_STATION,
-	WC_BUS_STATION,
-	WC_TRUCK_STATION,
-	WC_BUILD_DEPOT,
-	WC_COMPANY,
-	WC_FINANCES,
-	WC_PLAYER_COLOR,
-	WC_QUERY_STRING,
-	WC_SAVELOAD,
-	WC_SELECT_GAME,
-	WC_TOOLBAR_MENU,
-	WC_INCOME_GRAPH,
-	WC_OPERATING_PROFIT,
-	WC_TOOLTIPS,
-	WC_INDUSTRY_VIEW,
-	WC_PLAYER_FACE,
-	WC_LAND_INFO,
-	WC_TOWN_AUTHORITY,
-	WC_SUBSIDIES_LIST,
-	WC_GRAPH_LEGEND,
-	WC_DELIVERED_CARGO,
-	WC_PERFORMANCE_HISTORY,
-	WC_COMPANY_VALUE,
-	WC_COMPANY_LEAGUE,
-	WC_BUY_COMPANY,
-	WC_PAYMENT_RATES,
-	WC_ENGINE_PREVIEW,
-	WC_MUSIC_WINDOW,
-	WC_MUSIC_TRACK_SELECTION,
-	WC_SCEN_LAND_GEN,
-	WC_SCEN_TOWN_GEN,
-	WC_SCEN_INDUSTRY,
-	WC_SCEN_BUILD_ROAD,
-	WC_BUILD_TREES,
-	WC_SEND_NETWORK_MSG,
-	WC_DROPDOWN_MENU,
-	WC_BUILD_INDUSTRY,
-	WC_GAME_OPTIONS,
-	WC_NETWORK_WINDOW,
-	WC_INDUSTRY_DIRECTORY,
-	WC_MESSAGE_HISTORY,
-	WC_CHEATS,
-	WC_PERFORMANCE_DETAIL,
-	WC_CONSOLE,
-	WC_EXTRA_VIEW_PORT,
-	WC_CLIENT_LIST,
-	WC_NETWORK_STATUS_WINDOW,
-	WC_CUSTOM_CURRENCY,
-	WC_REPLACE_VEHICLE,
-	WC_HIGHSCORE,
-	WC_ENDSCREEN,
-	WC_SIGN_LIST,
-	WC_GENERATE_LANDSCAPE,
-	WC_GENERATE_PROGRESS_WINDOW,
-	WC_CONFIRM_POPUP_QUERY,
-	WC_TRANSPARENCY_TOOLBAR,
-	WC_VEHICLE_TIMETABLE,
-};
-
-
-enum ExpensesType {
-	EXPENSES_CONSTRUCTION =  0,
-	EXPENSES_NEW_VEHICLES =  1,
-	EXPENSES_TRAIN_RUN    =  2,
-	EXPENSES_ROADVEH_RUN  =  3,
-	EXPENSES_AIRCRAFT_RUN =  4,
-	EXPENSES_SHIP_RUN     =  5,
-	EXPENSES_PROPERTY     =  6,
-	EXPENSES_TRAIN_INC    =  7,
-	EXPENSES_ROADVEH_INC  =  8,
-	EXPENSES_AIRCRAFT_INC =  9,
-	EXPENSES_SHIP_INC     = 10,
-	EXPENSES_LOAN_INT     = 11,
-	EXPENSES_OTHER        = 12,
-};
-
-enum {
-	MAX_LANG = 64,
-};
-
-// special string constants
-enum SpecialStrings {
-
-	// special strings for town names. the town name is generated dynamically on request.
-	SPECSTR_TOWNNAME_START     = 0x20C0,
-	SPECSTR_TOWNNAME_ENGLISH   = SPECSTR_TOWNNAME_START,
-	SPECSTR_TOWNNAME_FRENCH,
-	SPECSTR_TOWNNAME_GERMAN,
-	SPECSTR_TOWNNAME_AMERICAN,
-	SPECSTR_TOWNNAME_LATIN,
-	SPECSTR_TOWNNAME_SILLY,
-	SPECSTR_TOWNNAME_SWEDISH,
-	SPECSTR_TOWNNAME_DUTCH,
-	SPECSTR_TOWNNAME_FINNISH,
-	SPECSTR_TOWNNAME_POLISH,
-	SPECSTR_TOWNNAME_SLOVAKISH,
-	SPECSTR_TOWNNAME_NORWEGIAN,
-	SPECSTR_TOWNNAME_HUNGARIAN,
-	SPECSTR_TOWNNAME_AUSTRIAN,
-	SPECSTR_TOWNNAME_ROMANIAN,
-	SPECSTR_TOWNNAME_CZECH,
-	SPECSTR_TOWNNAME_SWISS,
-	SPECSTR_TOWNNAME_DANISH,
-	SPECSTR_TOWNNAME_TURKISH,
-	SPECSTR_TOWNNAME_ITALIAN,
-	SPECSTR_TOWNNAME_CATALAN,
-	SPECSTR_TOWNNAME_LAST      = SPECSTR_TOWNNAME_CATALAN,
-
-	// special strings for player names on the form "TownName transport".
-	SPECSTR_PLAYERNAME_START   = 0x70EA,
-	SPECSTR_PLAYERNAME_ENGLISH = SPECSTR_PLAYERNAME_START,
-	SPECSTR_PLAYERNAME_FRENCH,
-	SPECSTR_PLAYERNAME_GERMAN,
-	SPECSTR_PLAYERNAME_AMERICAN,
-	SPECSTR_PLAYERNAME_LATIN,
-	SPECSTR_PLAYERNAME_SILLY,
-	SPECSTR_PLAYERNAME_LAST    = SPECSTR_PLAYERNAME_SILLY,
-
-	SPECSTR_ANDCO_NAME         = 0x70E6,
-	SPECSTR_PRESIDENT_NAME     = 0x70E7,
-	SPECSTR_SONGNAME           = 0x70E8,
-
-	// reserve MAX_LANG strings for the *.lng files
-	SPECSTR_LANGUAGE_START     = 0x7100,
-	SPECSTR_LANGUAGE_END       = SPECSTR_LANGUAGE_START + MAX_LANG - 1,
-
-	// reserve 32 strings for various screen resolutions
-	SPECSTR_RESOLUTION_START   = SPECSTR_LANGUAGE_END + 1,
-	SPECSTR_RESOLUTION_END     = SPECSTR_RESOLUTION_START + 0x1F,
-
-	// reserve 32 strings for screenshot formats
-	SPECSTR_SCREENSHOT_START   = SPECSTR_RESOLUTION_END + 1,
-	SPECSTR_SCREENSHOT_END     = SPECSTR_SCREENSHOT_START + 0x1F,
-
-	// Used to implement SetDParamStr
-	STR_SPEC_DYNSTRING         = 0xF800,
-	STR_SPEC_USERSTRING        = 0xF808,
-};
-
-typedef void PlaceProc(TileIndex tile);
-
 enum {
 	SORT_ASCENDING  = 0,
 	SORT_DESCENDING = 1,
@@ -701,4 +216,8 @@
 
 void OTTD_SendThreadMessage(ThreadMsg msg);
 
+extern byte _game_mode;
+extern bool _exit_game;
+extern byte _pause_game;
+
 #endif /* OPENTTD_H */
--- a/src/order.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/order.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,8 +5,12 @@
 #ifndef ORDER_H
 #define ORDER_H
 
-#include "macros.h"
 #include "oldpool.h"
+#include "core/bitmath_func.hpp"
+#include "cargo_type.h"
+#include "vehicle_type.h"
+#include "tile_type.h"
+#include "date_type.h"
 
 enum {
 	INVALID_VEH_ORDER_ID = 0xFF,
@@ -213,4 +217,18 @@
 
 Order UnpackOldOrder(uint16 packed);
 
+#define MIN_SERVINT_PERCENT  5
+#define MAX_SERVINT_PERCENT 90
+#define MIN_SERVINT_DAYS    30
+#define MAX_SERVINT_DAYS   800
+
+/**
+ * Get the service interval domain.
+ * Get the new proposed service interval for the vehicle is indeed, clamped
+ * within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
+ * @param index proposed service interval
+ * @return service interval
+ */
+Date GetServiceIntervalClamped(uint index);
+
 #endif /* ORDER_H */
--- a/src/order_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/order_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,20 +6,23 @@
 #include "openttd.h"
 #include "order.h"
 #include "airport.h"
-#include "vehicle.h"
 #include "depot.h"
-#include "functions.h"
 #include "table/strings.h"
 #include "waypoint.h"
-#include "command.h"
+#include "command_func.h"
 #include "station.h"
 #include "player.h"
 #include "news.h"
 #include "saveload.h"
 #include "vehicle_gui.h"
 #include "cargotype.h"
-#include "strings.h"
 #include "aircraft.h"
+#include "strings_func.h"
+#include "core/alloc_func.hpp"
+#include "functions.h"
+#include "window_func.h"
+#include "settings_type.h"
+#include "string_func.h"
 
 DEFINE_OLD_POOL_GENERIC(Order, Order)
 
@@ -676,7 +679,7 @@
 	if (sel_ord >= v->num_orders) return CMD_ERROR;
 
 	order = GetVehicleOrder(v, sel_ord);
-	if (order->type != OT_GOTO_STATION &&
+	if ((order->type != OT_GOTO_STATION  || GetStation(order->dest)->IsBuoy()) &&
 			(order->type != OT_GOTO_DEPOT    || p2 == OFB_UNLOAD) &&
 			(order->type != OT_GOTO_WAYPOINT || p2 != OFB_NON_STOP)) {
 		return CMD_ERROR;
@@ -983,7 +986,7 @@
 
 	/* If we had shared orders, recover that */
 	if (bak->clone != INVALID_VEHICLE) {
-		DoCommandP(0, v->index | (bak->clone << 16), 0, NULL, CMD_CLONE_ORDER);
+		DoCommandP(0, v->index | (bak->clone << 16), CO_SHARE, NULL, CMD_CLONE_ORDER);
 	} else {
 
 		/* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the
@@ -1250,6 +1253,11 @@
 	}
 }
 
+Date GetServiceIntervalClamped(uint index)
+{
+	return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
+}
+
 /**
  *
  * Check if we share our orders with an other vehicle
--- a/src/order_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/order_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,18 +8,13 @@
 #include "station_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
-#include "map.h"
-#include "tile.h"
-#include "window.h"
 #include "gui.h"
-#include "gfx.h"
-#include "vehicle.h"
+#include "window_gui.h"
 #include "station.h"
 #include "town.h"
-#include "command.h"
-#include "viewport.h"
+#include "command_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "depot.h"
 #include "waypoint.h"
 #include "train.h"
@@ -27,6 +22,11 @@
 #include "vehicle_gui.h"
 #include "timetable.h"
 #include "cargotype.h"
+#include "order.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "settings_type.h"
 
 enum OrderWindowWidgets {
 	ORDER_WIDGET_CLOSEBOX = 0,
@@ -57,7 +57,7 @@
 static int OrderGetSel(const Window *w)
 {
 	const Vehicle *v = GetVehicle(w->window_number);
-	int num = WP(w,order_d).sel;
+	int num = WP(w, order_d).sel;
 
 	return (num >= 0 && num < v->num_orders) ? num : v->num_orders;
 }
@@ -129,50 +129,52 @@
 
 	if (v->owner == _local_player) {
 		/* skip */
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_SKIP, v->num_orders <= 1);
+		w->SetWidgetDisabledState(ORDER_WIDGET_SKIP, v->num_orders <= 1);
 
 		/* delete */
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_DELETE,
+		w->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
 				(uint)v->num_orders + ((shared_orders || v->num_orders != 0) ? 1 : 0) <= (uint)WP(w, order_d).sel);
 
 		/* non-stop only for trains */
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_NON_STOP,  v->type != VEH_TRAIN || order == NULL);
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_FULL_LOAD, order == NULL); // full load
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_UNLOAD,    order == NULL); // unload
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_TRANSFER,  order == NULL); // transfer
+		w->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP,  v->type != VEH_TRAIN || order == NULL);
+		w->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL); // full load
+		w->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD,    order == NULL); // unload
+		w->SetWidgetDisabledState(ORDER_WIDGET_TRANSFER,  order == NULL); // transfer
 		/* Disable list of vehicles with the same shared orders if there is no list */
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL);
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_REFIT,     order == NULL); // Refit
-		HideWindowWidget(w, ORDER_WIDGET_REFIT); // Refit
+		w->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL);
+		w->SetWidgetDisabledState(ORDER_WIDGET_REFIT,     order == NULL); // Refit
+		w->HideWidget(ORDER_WIDGET_REFIT); // Refit
 	} else {
-		DisableWindowWidget(w, ORDER_WIDGET_TRANSFER);
+		w->DisableWidget(ORDER_WIDGET_TRANSFER);
 	}
 
-	ShowWindowWidget(w, ORDER_WIDGET_UNLOAD); // Unload
+	w->ShowWidget(ORDER_WIDGET_UNLOAD); // Unload
 
 	if (order != NULL) {
 		switch (order->type) {
-			case OT_GOTO_STATION: break;
+			case OT_GOTO_STATION:
+				if (!GetStation(order->dest)->IsBuoy()) break;
+				/* Fall-through */
+
+			case OT_GOTO_WAYPOINT:
+				w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
+				w->DisableWidget(ORDER_WIDGET_UNLOAD);
+				w->DisableWidget(ORDER_WIDGET_TRANSFER);
+				break;
 
 			case OT_GOTO_DEPOT:
-				DisableWindowWidget(w, ORDER_WIDGET_TRANSFER);
+				w->DisableWidget(ORDER_WIDGET_TRANSFER);
 
 				/* Remove unload and replace it with refit */
-				HideWindowWidget(w, ORDER_WIDGET_UNLOAD);
-				ShowWindowWidget(w, ORDER_WIDGET_REFIT);
+				w->HideWidget(ORDER_WIDGET_UNLOAD);
+				w->ShowWidget(ORDER_WIDGET_REFIT);
 				SetDParam(2,STR_SERVICE);
 				break;
 
-			case OT_GOTO_WAYPOINT:
-				DisableWindowWidget(w, ORDER_WIDGET_FULL_LOAD);
-				DisableWindowWidget(w, ORDER_WIDGET_UNLOAD);
-				DisableWindowWidget(w, ORDER_WIDGET_TRANSFER);
-				break;
-
 			default: // every other orders
-				DisableWindowWidget(w, ORDER_WIDGET_NON_STOP);
-				DisableWindowWidget(w, ORDER_WIDGET_FULL_LOAD);
-				DisableWindowWidget(w, ORDER_WIDGET_UNLOAD);
+				w->DisableWidget(ORDER_WIDGET_NON_STOP);
+				w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
+				w->DisableWidget(ORDER_WIDGET_UNLOAD);
 		}
 	}
 
@@ -239,7 +241,7 @@
 			}
 
 			SetDParam(0, i + 1);
-			DrawString(2, y, str, (i == WP(w,order_d).sel) ? TC_WHITE : TC_BLACK);
+			DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
 
 			y += 10;
 		}
@@ -250,7 +252,7 @@
 
 	if (i - w->vscroll.pos < w->vscroll.cap) {
 		str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
-		DrawString(2, y, str, (i == WP(w,order_d).sel) ? TC_WHITE : TC_BLACK);
+		DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
 	}
 }
 
@@ -362,9 +364,9 @@
 	// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
 	if (v->num_orders != 0 && _ctrl_pressed == 0) return false;
 
-	if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL,
+	if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL,
 		_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
-		WP(w,order_d).sel = -1;
+		WP(w, order_d).sel = -1;
 		ResetObjectToPlace();
 	}
 
@@ -384,7 +386,7 @@
 	if (!cmd.IsValid()) return;
 
 	if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
-		if (WP(w,order_d).sel != -1) WP(w,order_d).sel++;
+		if (WP(w, order_d).sel != -1) WP(w,order_d).sel++;
 		ResetObjectToPlace();
 	}
 }
@@ -397,9 +399,9 @@
  */
 static void OrderClick_Goto(Window *w, const Vehicle *v)
 {
-	InvalidateWidget(w, ORDER_WIDGET_GOTO);
-	ToggleWidgetLoweredState(w, ORDER_WIDGET_GOTO);
-	if (IsWindowWidgetLowered(w, ORDER_WIDGET_GOTO)) {
+	w->InvalidateWidget(ORDER_WIDGET_GOTO);
+	w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
+	if (w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
 		_place_clicked_vehicle = NULL;
 		SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
 	} else {
@@ -491,9 +493,9 @@
 {
 	if (_ctrl_pressed) {
 		/* Cancel refitting */
-		DoCommandP(v->tile, v->index, (WP(w,order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
+		DoCommandP(v->tile, v->index, (WP(w, order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
 	} else {
-		ShowVehicleRefitWindow(v, WP(w,order_d).sel);
+		ShowVehicleRefitWindow(v, WP(w, order_d).sel);
 	}
 }
 
@@ -543,7 +545,7 @@
 			if (_patches.timetabling) {
 				w->widget[ORDER_WIDGET_CAPTION].right -= 61;
 			} else {
-				HideWindowWidget(w, ORDER_WIDGET_TIMETABLE_VIEW);
+				w->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW);
 			}
 
 			break;
@@ -563,7 +565,7 @@
 			if (sel == INVALID_ORDER) {
 				/* This was a click on an empty part of the orders window, so
 				 * deselect the currently selected order. */
-				WP(w,order_d).sel = -1;
+				WP(w, order_d).sel = -1;
 				SetWindowDirty(w);
 				return;
 			}
@@ -582,12 +584,12 @@
 				if (xy != 0) ScrollMainWindowToTile(xy);
 				return;
 			} else {
-				if (sel == WP(w,order_d).sel) {
+				if (sel == WP(w, order_d).sel) {
 					/* Deselect clicked order */
-					WP(w,order_d).sel = -1;
+					WP(w, order_d).sel = -1;
 				} else {
 					/* Select clicked order */
-					WP(w,order_d).sel = sel;
+					WP(w, order_d).sel = sel;
 
 					if (v->owner == _local_player) {
 						/* Activate drag and drop */
@@ -675,7 +677,7 @@
 			if (e->we.keypress.keycode == _order_keycodes[i]) {
 				e->we.keypress.cont = false;
 				//see if the button is disabled
-				if (!IsWindowWidgetDisabled(w, i + ORDER_WIDGET_SKIP)) _order_button_proc[i](w, v);
+				if (!w->IsWidgetDisabled(i + ORDER_WIDGET_SKIP)) _order_button_proc[i](w, v);
 				break;
 			}
 		}
@@ -699,8 +701,8 @@
 	} break;
 
 	case WE_ABORT_PLACE_OBJ: {
-		RaiseWindowWidget(w, ORDER_WIDGET_GOTO);
-		InvalidateWidget( w, ORDER_WIDGET_GOTO);
+		w->RaiseWidget(ORDER_WIDGET_GOTO);
+		w->InvalidateWidget(ORDER_WIDGET_GOTO);
 	} break;
 
 	// check if a vehicle in a depot was clicked..
@@ -714,7 +716,7 @@
 		 * the order is copied to the last open window instead of the
 		 * one where GOTO is enabled
 		 */
-		if (v != NULL && IsWindowWidgetLowered(w, ORDER_WIDGET_GOTO)) {
+		if (v != NULL && w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
 			_place_clicked_vehicle = NULL;
 			HandleOrderVehClick(GetVehicle(w->window_number), v, w);
 		}
@@ -729,9 +731,9 @@
 		// unclick all buttons except for the 'goto' button (ORDER_WIDGET_GOTO), which is 'persistent'
 		uint i;
 		for (i = 0; i < w->widget_count; i++) {
-			if (IsWindowWidgetLowered(w, i) && i != ORDER_WIDGET_GOTO) {
-				RaiseWindowWidget(w, i);
-				InvalidateWidget(w, i);
+			if (w->IsWidgetLowered(i) && i != ORDER_WIDGET_GOTO) {
+				w->RaiseWidget(i);
+				w->InvalidateWidget(i);
 			}
 		}
 	} break;
@@ -867,6 +869,6 @@
 		w->caption_color = v->owner;
 		w->vscroll.cap = 6;
 		w->resize.step_height = 10;
-		WP(w,order_d).sel = -1;
+		WP(w, order_d).sel = -1;
 	}
 }
--- a/src/os/macosx/macos.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/os/macosx/macos.h	Wed Jan 09 18:11:12 2008 +0000
@@ -27,4 +27,44 @@
 		(__builtin_expect(!(e), 0) ? ShowMacAssertDialog ( __func__, __FILE__, __LINE__, #e ): (void)0 )
 #endif
 
+
+
+/**
+ * Get the major version of Mac OS we are running under. Useful for things like the cocoa driver.
+ * @return major version of the os. This would be 10 in the case of 10.4.11.
+ */
+long GetMacOSVersionMajor();
+
+/**
+ * Get the minor version of Mac OS we are running under. Useful for things like the cocoa driver.
+ * @return minor version of the os. This would be 4 in the case of 10.4.11.
+ */
+long GetMacOSVersionMinor();
+
+/**
+ * Get the bugfix version of Mac OS we are running under. Useful for things like the cocoa driver.
+ * @return bugfix version of the os. This would be 11 in the case of 10.4.11.
+ */
+long GetMacOSVersionBugfix();
+
+/**
+ * Check if we are at least running on the specified version of Mac OS.
+ * @param major major version of the os. This would be 10 in the case of 10.4.11.
+ * @param minor minor version of the os. This would be 4 in the case of 10.4.11.
+ * @param bugfix bugfix version of the os. This would be 11 in the case of 10.4.11.
+ * @return true if the running os is at least what we asked, false otherwise.
+ */
+static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
+{
+	long maj = GetMacOSVersionMajor();
+	long min = GetMacOSVersionMinor();
+	long bf = GetMacOSVersionBugfix();
+
+	if (maj < major) return false;
+	if (maj == major && min < minor) return false;
+	if (maj == major && min == minor && bf < bugfix) return false;
+
+	return true;
+}
+
 #endif /* MACOS_H */
--- a/src/os/macosx/macos.mm	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/os/macosx/macos.mm	Wed Jan 09 18:11:12 2008 +0000
@@ -1,5 +1,7 @@
 /* $Id$ */
 
+#include <AvailabilityMacros.h>
+
 #include <AppKit/AppKit.h>
 
 #include <mach/mach.h>
@@ -8,7 +10,7 @@
 #include <mach/machine.h>
 #include <stdio.h>
 #include "../../stdafx.h"
-#include "../../macros.h"
+#include "../../core/bitmath_func.hpp"
 
 #ifndef CPU_SUBTYPE_POWERPC_970
 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
@@ -168,6 +170,90 @@
 	NSArray* languages = [defs objectForKey:@"AppleLanguages"];
 	NSString* preferredLang = [languages objectAtIndex:0];
 	/* preferredLang is either 2 or 5 characters long ("xx" or "xx_YY"). */
-	[ preferredLang getCString:retbuf maxLength:32 encoding:NSASCIIStringEncoding ];
+
+	/* MacOS 10.3.9 can't handle encoding:NSASCIIStringEncoding
+	 * we will completely disable compiling it for such old targets to avoid a warning */
+#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_3)
+	/* Note: MAC_OS_X_VERSION_MAX_ALLOWED is the current OSX version/SDK by default */
+	if (MacOSVersionIsAtLeast(10, 4, 0)) {
+		[ preferredLang getCString:retbuf maxLength:32 encoding:NSASCIIStringEncoding ];
+	} else {
+#else
+	/* 10.3.9 needs to start the { too */
+	{
+#endif
+		[ preferredLang getCString:retbuf maxLength:32 ];
+	}
 	return retbuf;
 }
+
+
+/*
+ * This will only give an accurate result for versions before OS X 10.8 since it uses bcd encoding
+ * for the minor and bugfix version numbers and a scheme of representing all numbers from 9 and up
+ * with 9. This means we can't tell OS X 10.9 from 10.9 or 10.11. Please use GetMacOSVersionMajor()
+ * and GetMacOSVersionMinor() instead.
+ */
+static long GetMacOSVersion()
+{
+	static long sysVersion = -1;
+
+	if (sysVersion != -1) return sysVersion;
+
+	if (Gestalt(gestaltSystemVersion, &sysVersion) != noErr) sysVersion = -1;
+	 return sysVersion;
+}
+
+long GetMacOSVersionMajor()
+{
+	static long sysVersion = -1;
+
+	if (sysVersion != -1) return sysVersion;
+
+	sysVersion = GetMacOSVersion();
+	if (sysVersion == -1) return -1;
+
+	if (sysVersion >= 0x1040) {
+		if (Gestalt(gestaltSystemVersionMajor, &sysVersion) != noErr) sysVersion = -1;
+	} else {
+		sysVersion = GB(sysVersion, 12, 4) * 10 + GB(sysVersion,  8, 4);
+	}
+
+	return sysVersion;
+}
+
+long GetMacOSVersionMinor()
+{
+	static long sysVersion = -1;
+
+	if (sysVersion != -1) return sysVersion;
+
+	sysVersion = GetMacOSVersion();
+	if (sysVersion == -1) return -1;
+
+	if (sysVersion >= 0x1040) {
+		if (Gestalt(gestaltSystemVersionMinor, &sysVersion) != noErr) sysVersion = -1;
+	} else {
+		sysVersion = GB(sysVersion,  4, 4);
+	}
+
+	return sysVersion;
+}
+
+long GetMacOSVersionBugfix()
+{
+	static long sysVersion = -1;
+
+	if (sysVersion != -1) return sysVersion;
+
+	sysVersion = GetMacOSVersion();
+	if (sysVersion == -1) return -1;
+
+	if (sysVersion >= 0x1040) {
+		if (Gestalt(gestaltSystemVersionBugFix, &sysVersion) != noErr) sysVersion = -1;
+	} else {
+		sysVersion = GB(sysVersion,  0, 4);
+	}
+
+	return sysVersion;
+}
--- a/src/os/macosx/osx_stdafx.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/os/macosx/osx_stdafx.h	Wed Jan 09 18:11:12 2008 +0000
@@ -10,9 +10,7 @@
 #undef true
 
 /* Name conflict */
-#define Rect		OTTDRect
-#define Point		OTTDPoint
-#define GetTime		OTTDGetTime
+#define GetTime		OTTD_GetTime
 
 #define SL_ERROR OSX_SL_ERROR
 
--- a/src/os/macosx/splash.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/os/macosx/splash.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,10 +3,8 @@
 #include "../../stdafx.h"
 #include "../../openttd.h"
 #include "../../variables.h"
-#include "../../macros.h"
 #include "../../debug.h"
-#include "../../functions.h"
-#include "../../gfx.h"
+#include "../../gfx_func.h"
 #include "../../fileio.h"
 #include "../../blitter/factory.hpp"
 
--- a/src/os2.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/os2.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,14 +5,12 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "variables.h"
-#include "string.h"
 #include "table/strings.h"
-#include "gfx.h"
 #include "gui.h"
-#include "functions.h"
-#include "macros.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/pathfind.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/pathfind.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -7,16 +7,16 @@
 #include "bridge_map.h"
 #include "station_map.h"
 #include "depot.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "map.h"
-#include "tile.h"
 #include "pathfind.h"
-#include "rail.h"
+#include "rail_type.h"
 #include "debug.h"
 #include "tunnel_map.h"
 #include "variables.h"
 #include "depot.h"
+#include "tunnelbridge_map.h"
+#include "core/random_func.hpp"
 
 /* remember which tiles we have already visited so we don't visit them again. */
 static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir)
@@ -210,7 +210,7 @@
 		tile += delta;
 	} while(
 		!IsTunnelTile(tile) ||
-		GetTunnelDirection(tile) != dir ||
+		GetTunnelBridgeDirection(tile) != dir ||
 		GetTileZ(tile) != z
 	);
 
@@ -230,17 +230,6 @@
 	return flotr.tile;
 }
 
-const byte _ffb_64[64] = {
- 0,  0,  1,  0,  2,  0,  1,  0,
- 3,  0,  1,  0,  2,  0,  1,  0,
- 4,  0,  1,  0,  2,  0,  1,  0,
- 3,  0,  1,  0,  2,  0,  1,  0,
- 5,  0,  1,  0,  2,  0,  1,  0,
- 3,  0,  1,  0,  2,  0,  1,  0,
- 4,  0,  1,  0,  2,  0,  1,  0,
- 3,  0,  1,  0,  2,  0,  1,  0,
-};
-
 static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection direction);
 
 /** Most code of the "Normal" case of TPF Mode 1; for signals special tricks
@@ -270,16 +259,9 @@
 	/* Check if the new tile is a tunnel or bridge head and that the direction
 	 * and transport type match */
 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
-		if (IsTunnel(tile)) {
-			if (GetTunnelDirection(tile) != direction ||
-					GetTunnelTransportType(tile) != tpf->tracktype) {
-				return;
-			}
-		} else if (IsBridge(tile)) {
-			if (GetBridgeRampDirection(tile) != direction ||
-					GetBridgeTransportType(tile) != tpf->tracktype) {
-				return;
-			}
+		if (GetTunnelBridgeDirection(tile) != direction ||
+				GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
+			return;
 		}
 	}
 
@@ -318,23 +300,23 @@
 
 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		if (IsTunnel(tile)) {
-			if (GetTunnelTransportType(tile) != tpf->tracktype) {
+			if (GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 				return;
 			}
 			/* Only skip through the tunnel if heading inwards. We can
 			 * be headed outwards if our starting position was in a
 			 * tunnel and we're pathfinding backwards */
-			if (GetTunnelDirection(tile) == direction) {
+			if (GetTunnelBridgeDirection(tile) == direction) {
 				tile = SkipToEndOfTunnel(tpf, tile, direction);
-			} else if (GetTunnelDirection(tile) != ReverseDiagDir(direction)) {
+			} else if (GetTunnelBridgeDirection(tile) != ReverseDiagDir(direction)) {
 				/* We don't support moving through the sides of a tunnel
 				 * entrance :-) */
 				return;
 			}
 		} else {
 			TileIndex tile_end;
-			if (GetBridgeRampDirection(tile) != direction ||
-					GetBridgeTransportType(tile) != tpf->tracktype) {
+			if (GetTunnelBridgeDirection(tile) != direction ||
+					GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 				return;
 			}
 			//fprintf(stderr, "%s: Planning over bridge\n", __func__);
@@ -663,8 +645,8 @@
 
 static uint DistanceMoo(TileIndex t0, TileIndex t1)
 {
-	const uint dx = delta(TileX(t0), TileX(t1));
-	const uint dy = delta(TileY(t0), TileY(t1));
+	const uint dx = Delta(TileX(t0), TileX(t1));
+	const uint dy = Delta(TileY(t0), TileY(t1));
 
 	const uint straightTracks = 2 * min(dx, dy); // The number of straight (not full length) tracks
 	/* OPTIMISATION:
@@ -733,12 +715,12 @@
 		 *   need to find the exit of the tunnel. */
 		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 			if (IsTunnel(tile)) {
-				if (GetTunnelDirection(tile) != ReverseDiagDir(direction)) {
+				if (GetTunnelBridgeDirection(tile) != ReverseDiagDir(direction)) {
 					FindLengthOfTunnelResult flotr;
 
 					/* We are not just driving out of the tunnel */
-					if (GetTunnelDirection(tile) != direction ||
-							GetTunnelTransportType(tile) != tpf->tracktype) {
+					if (GetTunnelBridgeDirection(tile) != direction ||
+							GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 						/* We are not driving into the tunnel, or it is an invalid tunnel */
 						continue;
 					}
@@ -753,10 +735,10 @@
 				}
 			} else {
 				TileIndex tile_end;
-				if (GetBridgeRampDirection(tile) != ReverseDiagDir(direction)) {
+				if (GetTunnelBridgeDirection(tile) != ReverseDiagDir(direction)) {
 					/* We are not just leaving the bridge */
-					if (GetBridgeRampDirection(tile) != direction ||
-							GetBridgeTransportType(tile) != tpf->tracktype) {
+					if (GetTunnelBridgeDirection(tile) != direction ||
+							GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 						/* Not entering the bridge or not compatible */
 						continue;
 					}
--- a/src/pathfind.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/pathfind.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,8 +5,7 @@
 #ifndef PATHFIND_H
 #define PATHFIND_H
 
-#include "direction.h"
-#include "openttd.h"
+#include "direction_type.h"
 
 enum {
 	STR_FACTOR  = 2,
--- a/src/player.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/player.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,14 +5,12 @@
 #ifndef PLAYER_H
 #define PLAYER_H
 
-#include "oldpool.h"
-#include "aystar.h"
-#include "rail.h"
-#include "road.h"
+#include "road_func.h"
+#include "date_type.h"
 #include "engine.h"
 #include "livery.h"
 #include "genworld.h"
-#include "gfx.h"
+#include "autoreplace_type.h"
 
 struct PlayerEconomyEntry {
 	Money income;
@@ -107,7 +105,7 @@
 
 static inline Player *GetPlayer(PlayerID i)
 {
-	assert(IS_INSIDE_1D(i, PLAYER_FIRST, lengthof(_players)));
+	assert(IsInsideBS(i, PLAYER_FIRST, lengthof(_players)));
 	return &_players[i];
 }
 
@@ -118,7 +116,7 @@
 
 static inline bool IsValidPlayer(PlayerID pi)
 {
-	return IS_INSIDE_1D(pi, PLAYER_FIRST, MAX_PLAYERS);
+	return IsInsideBS(pi, PLAYER_FIRST, MAX_PLAYERS);
 }
 
 byte GetPlayerRailtypes(PlayerID p);
@@ -196,50 +194,6 @@
 int8 SaveHighScoreValue(const Player *p);
 int8 SaveHighScoreValueNetwork();
 
-/* Engine Replacement Functions */
-
-/**
- * Remove all engine replacement settings for the given player.
- * @param p Player.
- */
-static inline void RemoveAllEngineReplacementForPlayer(Player *p) { RemoveAllEngineReplacement(&p->engine_renew_list); }
-
-/**
- * Retrieve the engine replacement for the given player and original engine type.
- * @param p Player.
- * @param engine Engine type.
- * @return The engine type to replace with, or INVALID_ENGINE if no
- * replacement is in the list.
- */
-static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group) { return EngineReplacement(p->engine_renew_list, engine, group); }
-
-/**
- * Check if a player has a replacement set up for the given engine.
- * @param p Player.
- * @param  engine Engine type to be replaced.
- * @return true if a replacement was set up, false otherwise.
- */
-static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group) { return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE; }
-
-/**
- * Add an engine replacement for the player.
- * @param p Player.
- * @param old_engine The original engine type.
- * @param new_engine The replacement engine type.
- * @param flags The calling command flags.
- * @return 0 on success, CMD_ERROR on failure.
- */
-static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags) { return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags); }
-
-/**
- * Remove an engine replacement for the player.
- * @param p Player.
- * @param engine The original engine type.
- * @param flags The calling command flags.
- * @return 0 on success, CMD_ERROR on failure.
- */
-static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags) {return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags); }
-
 /**
  * Reset the livery schemes to the player's primary colour.
  * This is used on loading games without livery information and on new player start up.
--- a/src/player_face.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/player_face.h	Wed Jan 09 18:11:12 2008 +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	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/player_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,26 +6,28 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "player.h"
-#include "command.h"
-#include "vehicle.h"
-#include "economy.h"
+#include "command_func.h"
 #include "network/network.h"
 #include "variables.h"
 #include "roadveh.h"
 #include "train.h"
 #include "aircraft.h"
-#include "date.h"
 #include "newgrf.h"
 #include "network/network_data.h"
 #include "network/network_client.h"
+#include "network/network_gui.h"
 #include "player_face.h"
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "string_func.h"
 
 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied);
 static void DoSelectPlayerFace(PlayerID player, bool show_big);
@@ -146,15 +148,15 @@
 			w->height = new_height;
 			SetWindowDirty(w);
 
-			SetWindowWidgetHiddenState(w, 6, player != _local_player);
-			SetWindowWidgetHiddenState(w, 7, player != _local_player);
+			w->SetWidgetHiddenState(6, player != _local_player);
+			w->SetWidgetHiddenState(7, player != _local_player);
 		}
 
 		/* Borrow button only shows when there is any more money to loan */
-		SetWindowWidgetDisabledState(w, 6, p->current_loan == _economy.max_loan);
+		w->SetWidgetDisabledState(6, p->current_loan == _economy.max_loan);
 
 		/* Repay button only shows when there is any more money to repay */
-		SetWindowWidgetDisabledState(w, 7, player != _local_player || p->current_loan == 0);
+		w->SetWidgetDisabledState(7, player != _local_player || p->current_loan == 0);
 
 		SetDParam(0, p->index);
 		SetDParam(1, p->index);
@@ -293,10 +295,10 @@
 {
 	switch (e->event) {
 		case WE_CREATE:
-			LowerWindowWidget(w, WP(w, livery_d).livery_class + 2);
+			w->LowerWidget(WP(w, livery_d).livery_class + 2);
 			if (!_loaded_newgrf_features.has_2CC) {
-				HideWindowWidget(w, 11);
-				HideWindowWidget(w, 12);
+				w->HideWidget(11);
+				w->HideWidget(12);
 			}
 			break;
 
@@ -306,10 +308,10 @@
 			int y = 51;
 
 			/* Disable dropdown controls if no scheme is selected */
-			SetWindowWidgetDisabledState(w,  9, (WP(w, livery_d).sel == 0));
-			SetWindowWidgetDisabledState(w, 10, (WP(w, livery_d).sel == 0));
-			SetWindowWidgetDisabledState(w, 11, (WP(w, livery_d).sel == 0));
-			SetWindowWidgetDisabledState(w, 12, (WP(w, livery_d).sel == 0));
+			w->SetWidgetDisabledState( 9, (WP(w, livery_d).sel == 0));
+			w->SetWidgetDisabledState(10, (WP(w, livery_d).sel == 0));
+			w->SetWidgetDisabledState(11, (WP(w, livery_d).sel == 0));
+			w->SetWidgetDisabledState(12, (WP(w, livery_d).sel == 0));
 
 			if (!(WP(w, livery_d).sel == 0)) {
 				for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
@@ -357,10 +359,10 @@
 				case 6: {
 					LiveryScheme scheme;
 
-					RaiseWindowWidget(w, WP(w, livery_d).livery_class + 2);
+					w->RaiseWidget(WP(w, livery_d).livery_class + 2);
 					WP(w, livery_d).livery_class = (LiveryClass)(e->we.click.widget - 2);
 					WP(w, livery_d).sel = 0;
-					LowerWindowWidget(w, WP(w, livery_d).livery_class + 2);
+					w->LowerWidget(WP(w, livery_d).livery_class + 2);
 
 					/* Select the first item in the list */
 					for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
@@ -660,7 +662,7 @@
 	/* Write the label in gold (0x2) to the left of the button. */
 	DrawStringRightAligned(w->widget[widget_index].left - (is_bool_widget ? 5 : 14), w->widget[widget_index].top + 1, str, TC_GOLD);
 
-	if (!IsWindowWidgetDisabled(w, widget_index)) {
+	if (!w->IsWidgetDisabled(widget_index)) {
 		if (is_bool_widget) {
 			/* if it a bool button write yes or no */
 			str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
@@ -672,7 +674,7 @@
 
 		/* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
 		DrawStringCentered(w->widget[widget_index].left + (w->widget[widget_index].right - w->widget[widget_index].left) / 2 +
-			IsWindowWidgetLowered(w, widget_index), w->widget[widget_index].top + 1 + IsWindowWidgetLowered(w, widget_index), str, TC_WHITE);
+			w->IsWidgetLowered(widget_index), w->widget[widget_index].top + 1 + w->IsWidgetLowered(widget_index), str, TC_WHITE);
 	}
 }
 
@@ -692,14 +694,14 @@
 	switch (e->event) {
 		case WE_PAINT:
 			/* lower the non-selected gender button */
-			SetWindowWidgetLoweredState(w, PFW_WIDGET_MALE,  !is_female);
-			SetWindowWidgetLoweredState(w, PFW_WIDGET_FEMALE, is_female);
+			w->SetWidgetLoweredState(PFW_WIDGET_MALE,  !is_female);
+			w->SetWidgetLoweredState(PFW_WIDGET_FEMALE, is_female);
 
 			/* advanced player face selection window */
 			if (WP(w, facesel_d).advanced) {
 				/* lower the non-selected ethnicity button */
-				SetWindowWidgetLoweredState(w, PFW_WIDGET_ETHNICITY_EUR, !HasBit(ge, ETHNICITY_BLACK));
-				SetWindowWidgetLoweredState(w, PFW_WIDGET_ETHNICITY_AFR,  HasBit(ge, ETHNICITY_BLACK));
+				w->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_EUR, !HasBit(ge, ETHNICITY_BLACK));
+				w->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_AFR,  HasBit(ge, ETHNICITY_BLACK));
 
 
 				/* Disable dynamically the widgets which PlayerFaceVariable has less than 2 options
@@ -707,44 +709,44 @@
 				* If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */
 
 				/* Eye colour buttons */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2,
+				w->SetWidgetsDisabledState(_pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2,
 					PFW_WIDGET_EYECOLOUR, PFW_WIDGET_EYECOLOUR_L, PFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END);
 
 				/* Chin buttons */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_CHIN].valid_values[ge] < 2,
+				w->SetWidgetsDisabledState(_pf_info[PFV_CHIN].valid_values[ge] < 2,
 					PFW_WIDGET_CHIN, PFW_WIDGET_CHIN_L, PFW_WIDGET_CHIN_R, WIDGET_LIST_END);
 
 				/* Eyebrows buttons */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_EYEBROWS].valid_values[ge] < 2,
+				w->SetWidgetsDisabledState(_pf_info[PFV_EYEBROWS].valid_values[ge] < 2,
 					PFW_WIDGET_EYEBROWS, PFW_WIDGET_EYEBROWS_L, PFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END);
 
 				/* Lips or (if it a male face with a moustache) moustache buttons */
-				SetWindowWidgetsDisabledState(w, _pf_info[is_moust_male ? PFV_MOUSTACHE : PFV_LIPS].valid_values[ge] < 2,
+				w->SetWidgetsDisabledState(_pf_info[is_moust_male ? PFV_MOUSTACHE : PFV_LIPS].valid_values[ge] < 2,
 					PFW_WIDGET_LIPS_MOUSTACHE, PFW_WIDGET_LIPS_MOUSTACHE_L, PFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END);
 
 				/* Nose buttons | male faces with moustache haven't any nose options */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_NOSE].valid_values[ge] < 2 || is_moust_male,
+				w->SetWidgetsDisabledState(_pf_info[PFV_NOSE].valid_values[ge] < 2 || is_moust_male,
 					PFW_WIDGET_NOSE, PFW_WIDGET_NOSE_L, PFW_WIDGET_NOSE_R, WIDGET_LIST_END);
 
 				/* Hair buttons */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_HAIR].valid_values[ge] < 2,
+				w->SetWidgetsDisabledState(_pf_info[PFV_HAIR].valid_values[ge] < 2,
 					PFW_WIDGET_HAIR, PFW_WIDGET_HAIR_L, PFW_WIDGET_HAIR_R, WIDGET_LIST_END);
 
 				/* Jacket buttons */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_JACKET].valid_values[ge] < 2,
+				w->SetWidgetsDisabledState(_pf_info[PFV_JACKET].valid_values[ge] < 2,
 					PFW_WIDGET_JACKET, PFW_WIDGET_JACKET_L, PFW_WIDGET_JACKET_R, WIDGET_LIST_END);
 
 				/* Collar buttons */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_COLLAR].valid_values[ge] < 2,
+				w->SetWidgetsDisabledState(_pf_info[PFV_COLLAR].valid_values[ge] < 2,
 					PFW_WIDGET_COLLAR, PFW_WIDGET_COLLAR_L, PFW_WIDGET_COLLAR_R, WIDGET_LIST_END);
 
 				/* Tie/earring buttons | female faces without earring haven't any earring options */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_TIE_EARRING].valid_values[ge] < 2 ||
+				w->SetWidgetsDisabledState(_pf_info[PFV_TIE_EARRING].valid_values[ge] < 2 ||
 						(is_female && GetPlayerFaceBits(*pf, PFV_HAS_TIE_EARRING, ge) == 0),
 					PFW_WIDGET_TIE_EARRING, PFW_WIDGET_TIE_EARRING_L, PFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END);
 
 				/* Glasses buttons | faces without glasses haven't any glasses options */
-				SetWindowWidgetsDisabledState(w, _pf_info[PFV_GLASSES].valid_values[ge] < 2 || GetPlayerFaceBits(*pf, PFV_HAS_GLASSES, ge) == 0,
+				w->SetWidgetsDisabledState(_pf_info[PFV_GLASSES].valid_values[ge] < 2 || GetPlayerFaceBits(*pf, PFV_HAS_GLASSES, ge) == 0,
 					PFW_WIDGET_GLASSES, PFW_WIDGET_GLASSES_L, PFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
 			}
 
@@ -1074,34 +1076,34 @@
 			const Player *p = GetPlayer((PlayerID)w->window_number);
 			bool local = w->window_number == _local_player;
 
-			SetWindowWidgetHiddenState(w, PCW_WIDGET_NEW_FACE,       !local);
-			SetWindowWidgetHiddenState(w, PCW_WIDGET_COLOR_SCHEME,   !local);
-			SetWindowWidgetHiddenState(w, PCW_WIDGET_PRESIDENT_NAME, !local);
-			SetWindowWidgetHiddenState(w, PCW_WIDGET_COMPANY_NAME,   !local);
+			w->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE,       !local);
+			w->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME,   !local);
+			w->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local);
+			w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME,   !local);
 			w->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_house == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
 			if (local && p->location_of_house != 0) w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
-			SetWindowWidgetDisabledState(w, PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
-			SetWindowWidgetHiddenState(w, PCW_WIDGET_RELOCATE_HQ,      !local || p->location_of_house == 0);
-			SetWindowWidgetHiddenState(w, PCW_WIDGET_BUY_SHARE,        local);
-			SetWindowWidgetHiddenState(w, PCW_WIDGET_SELL_SHARE,       local);
-			SetWindowWidgetHiddenState(w, PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
+			w->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
+			w->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ,      !local || p->location_of_house == 0);
+			w->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE,        local);
+			w->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE,       local);
+			w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
 
 			if (!local) {
 				if (_patches.allow_shares) { // Shares are allowed
 					/* If all shares are owned by someone (none by nobody), disable buy button */
-					SetWindowWidgetDisabledState(w, PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
+					w->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
 							/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
 							(GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
 							/* Spectators cannot do anything of course */
 							_local_player == PLAYER_SPECTATOR);
 
 					/* If the player doesn't own any shares, disable sell button */
-					SetWindowWidgetDisabledState(w, PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
+					w->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
 							/* Spectators cannot do anything of course */
 							_local_player == PLAYER_SPECTATOR);
 				} else { // Shares are not allowed, disable buy/sell buttons
-					DisableWindowWidget(w, PCW_WIDGET_BUY_SHARE);
-					DisableWindowWidget(w, PCW_WIDGET_SELL_SHARE);
+					w->DisableWidget(PCW_WIDGET_BUY_SHARE);
+					w->DisableWidget(PCW_WIDGET_SELL_SHARE);
 				}
 			}
 
@@ -1149,7 +1151,7 @@
 						wf->caption_color = wf->window_number;
 						WP(wf, livery_d).livery_class = LC_OTHER;
 						WP(wf, livery_d).sel = 1;
-						LowerWindowWidget(wf, 2);
+						wf->LowerWidget(2);
 					}
 					break;
 				}
@@ -1177,8 +1179,8 @@
 							return;
 						SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
 						SetTileSelectSize(2, 2);
-						LowerWindowWidget(w, PCW_WIDGET_BUILD_VIEW_HQ);
-						InvalidateWidget(w, PCW_WIDGET_BUILD_VIEW_HQ);
+						w->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ);
+						w->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ);
 					} else {
 						ScrollMainWindowToTile(tile);
 					}
@@ -1188,8 +1190,8 @@
 				case PCW_WIDGET_RELOCATE_HQ:
 					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
 					SetTileSelectSize(2, 2);
-					LowerWindowWidget(w, PCW_WIDGET_RELOCATE_HQ);
-					InvalidateWidget(w, PCW_WIDGET_RELOCATE_HQ);
+					w->LowerWidget(PCW_WIDGET_RELOCATE_HQ);
+					w->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ);
 					break;
 
 				case PCW_WIDGET_BUY_SHARE:
@@ -1200,15 +1202,11 @@
 					DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
 					break;
 
-				#ifdef ENABLE_NETWORK
+#ifdef ENABLE_NETWORK
 				case PCW_WIDGET_COMPANY_PASSWORD:
-					if (w->window_number == _local_player) {
-						WP(w, def_d).byte_1 = 2;
-						ShowQueryString(BindCString(_network_player_info[_local_player].password),
-							STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w, CS_ALPHANUMERAL);
-					}
+					if (w->window_number == _local_player) ShowNetworkCompanyPasswordWindow();
 					break;
-				#endif /* ENABLE_NETWORK */
+#endif /* ENABLE_NETWORK */
 			}
 			break;
 
@@ -1221,24 +1219,22 @@
 			if (DoCommandP(e->we.place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
 				ResetObjectToPlace();
 				w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
-				RaiseWindowButtons(w);
+				w->RaiseButtons();
 			break;
 
 		case WE_ABORT_PLACE_OBJ:
-			RaiseWindowButtons(w);
+			w->RaiseButtons();
 			break;
 
 		case WE_DESTROY:
 			DeleteWindowById(WC_PLAYER_FACE, w->window_number);
+			if (w->window_number == _local_player) DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0);
 			break;
 
-		case WE_ON_EDIT_TEXT: {
-			char *b = e->we.edittext.str;
+		case WE_ON_EDIT_TEXT:
+			if (StrEmpty(e->we.edittext.str)) return;
 
-			/* empty string is allowed for password */
-			if (*b == '\0' && WP(w, def_d).byte_1 != 2) return;
-
-			_cmd_text = b;
+			_cmd_text = e->we.edittext.str;
 			switch (WP(w, def_d).byte_1) {
 				case 0: /* Change president name */
 					DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
@@ -1246,15 +1242,8 @@
 				case 1: /* Change company name */
 					DoCommandP(0, 0, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
 					break;
-				#ifdef ENABLE_NETWORK
-				case 2: /* Change company password */
-					if (*b == '\0') *b = '*'; // empty password is a '*' because of console argument
-					NetworkChangeCompanyPassword(1, &b);
-					break;
-				#endif /* ENABLE_NETWORK */
 			}
 			break;
-		}
 	}
 }
 
--- a/src/players.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/players.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,30 +5,31 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "engine.h"
-#include "functions.h"
-#include "string.h"
-#include "strings.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "map.h"
 #include "player.h"
 #include "town.h"
-#include "vehicle.h"
 #include "station.h"
-#include "gfx.h"
 #include "news.h"
 #include "saveload.h"
-#include "command.h"
-#include "sound.h"
+#include "command_func.h"
 #include "network/network.h"
 #include "variables.h"
 #include "engine.h"
 #include "ai/ai.h"
-#include "date.h"
-#include "window.h"
 #include "player_face.h"
 #include "group.h"
-#include "settings.h"
+#include "window_func.h"
+#include "tile_map.h"
+#include "strings_func.h"
+#include "gfx_func.h"
+#include "functions.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "autoreplace_func.h"
+#include "autoreplace_gui.h"
+#include "string_func.h"
 
 /**
  * Sets the local player and updates the patch settings that are set on a
@@ -189,30 +190,24 @@
 
 static void SubtractMoneyFromAnyPlayer(Player *p, CommandCost cost)
 {
-	CommandCost tmp(p->player_money);
-	tmp.AddCost(-cost.GetCost());
-	p->player_money = tmp.GetCost();
+	if (cost.GetCost() == 0) return;
+	assert(cost.GetExpensesType() != INVALID_EXPENSES);
 
-	tmp = CommandCost(p->yearly_expenses[0][_yearly_expenses_type]);
-	tmp.AddCost(cost);
-	p->yearly_expenses[0][_yearly_expenses_type] = tmp.GetCost();
+	p->player_money -= cost.GetCost();
+	p->yearly_expenses[0][cost.GetExpensesType()] += cost.GetCost();
 
 	if (HasBit(1 << EXPENSES_TRAIN_INC    |
 	           1 << EXPENSES_ROADVEH_INC  |
 	           1 << EXPENSES_AIRCRAFT_INC |
-	           1 << EXPENSES_SHIP_INC, _yearly_expenses_type)) {
-		tmp = CommandCost(p->cur_economy.income);
-		tmp.AddCost(-cost.GetCost());
-		p->cur_economy.income = tmp.GetCost();
+	           1 << EXPENSES_SHIP_INC, cost.GetExpensesType())) {
+		p->cur_economy.income += cost.GetCost();
 	} else if (HasBit(1 << EXPENSES_TRAIN_RUN    |
 	                  1 << EXPENSES_ROADVEH_RUN  |
 	                  1 << EXPENSES_AIRCRAFT_RUN |
 	                  1 << EXPENSES_SHIP_RUN     |
 	                  1 << EXPENSES_PROPERTY     |
-	                  1 << EXPENSES_LOAN_INT, _yearly_expenses_type)) {
-		tmp = CommandCost(p->cur_economy.expenses);
-		tmp.AddCost(-cost.GetCost());
-		p->cur_economy.expenses = tmp.GetCost();
+	                  1 << EXPENSES_LOAN_INT, cost.GetExpensesType())) {
+		p->cur_economy.expenses += cost.GetCost();
 	}
 
 	InvalidatePlayerWindows(p);
@@ -234,7 +229,7 @@
 	p->player_money_fraction = m - (byte)cost;
 	cost >>= 8;
 	if (p->player_money_fraction > m) cost++;
-	if (cost != 0) SubtractMoneyFromAnyPlayer(p, CommandCost(cost));
+	if (cost != 0) SubtractMoneyFromAnyPlayer(p, CommandCost(cst.GetExpensesType(), cost));
 }
 
 void GetNameOfOwner(Owner owner, TileIndex tile)
@@ -299,7 +294,7 @@
 
 	t = ClosestTownFromTile(tile, (uint)-1);
 
-	if (IS_INT_INSIDE(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST+1)) {
+	if (IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST+1)) {
 		str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_PLAYERNAME_START;
 		strp = t->townnameparts;
 
@@ -543,7 +538,10 @@
 void InitializePlayers()
 {
 	memset(_players, 0, sizeof(_players));
-	for (PlayerID i = PLAYER_FIRST; i != MAX_PLAYERS; i++) _players[i].index = i;
+	for (PlayerID i = PLAYER_FIRST; i != MAX_PLAYERS; i++) {
+		_players[i].index = i;
+		for (uint j = 0; j < 4; j++) _players[i].share_owners[j] = PLAYER_SPECTATOR;
+	}
 	_cur_player_tick_index = 0;
 }
 
@@ -847,6 +845,10 @@
 		if (_local_player != _network_playas && _network_playas == p->index) {
 			assert(_local_player == PLAYER_SPECTATOR);
 			SetLocalPlayer(p->index);
+			if (!StrEmpty(_network_default_company_pass)) {
+				char *password = _network_default_company_pass;
+				NetworkChangeCompanyPassword(1, &password);
+			}
 			MarkWholeScreenDirty();
 		}
 
--- a/src/queue.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/queue.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,7 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "queue.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
 
 
 /*
@@ -310,7 +310,7 @@
 	h->hash = hash;
 	h->size = 0;
 	h->num_buckets = num_buckets;
-	h->buckets = (HashNode*)malloc(num_buckets * (sizeof(*h->buckets) + sizeof(*h->buckets_in_use)));
+	h->buckets = (HashNode*)MallocT<byte>(num_buckets * (sizeof(*h->buckets) + sizeof(*h->buckets_in_use)));
 #ifdef HASH_DEBUG
 	debug("Buckets = %p", h->buckets);
 #endif
--- a/src/rail.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/rail.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,18 +8,20 @@
 #include "rail.h"
 #include "station_map.h"
 #include "tunnel_map.h"
+#include "tunnelbridge_map.h"
+
 
 /* XXX: Below 3 tables store duplicate data. Maybe remove some? */
 /* Maps a trackdir to the bit that stores its status in the map arrays, in the
  * direction along with the trackdir */
-extern const byte _signal_along_trackdir[] = {
+extern const byte _signal_along_trackdir[TRACKDIR_END] = {
 	0x8, 0x8, 0x8, 0x2, 0x4, 0x1, 0, 0,
 	0x4, 0x4, 0x4, 0x1, 0x8, 0x2
 };
 
 /* Maps a trackdir to the bit that stores its status in the map arrays, in the
  * direction against the trackdir */
-extern const byte _signal_against_trackdir[] = {
+extern const byte _signal_against_trackdir[TRACKDIR_END] = {
 	0x4, 0x4, 0x4, 0x1, 0x8, 0x2, 0, 0,
 	0x8, 0x8, 0x8, 0x2, 0x4, 0x1
 };
@@ -40,13 +42,13 @@
 	TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_LOWER_W  /* DIAGDIR_NW */
 };
 
-extern const Trackdir _next_trackdir[] = {
+extern const Trackdir _next_trackdir[TRACKDIR_END] = {
 	TRACKDIR_X_NE,  TRACKDIR_Y_SE,  TRACKDIR_LOWER_E, TRACKDIR_UPPER_E, TRACKDIR_RIGHT_S, TRACKDIR_LEFT_S, INVALID_TRACKDIR, INVALID_TRACKDIR,
 	TRACKDIR_X_SW,  TRACKDIR_Y_NW,  TRACKDIR_LOWER_W, TRACKDIR_UPPER_W, TRACKDIR_RIGHT_N, TRACKDIR_LEFT_N
 };
 
 /* Maps a trackdir to all trackdirs that make 90 deg turns with it. */
-extern const TrackdirBits _track_crosses_trackdirs[] = {
+extern const TrackdirBits _track_crosses_trackdirs[TRACKDIR_END] = {
 	TRACKDIR_BIT_Y_SE     | TRACKDIR_BIT_Y_NW,                                                   /* TRACK_X     */
 	TRACKDIR_BIT_X_NE     | TRACKDIR_BIT_X_SW,                                                   /* TRACK_Y     */
 	TRACKDIR_BIT_RIGHT_N  | TRACKDIR_BIT_RIGHT_S  | TRACKDIR_BIT_LEFT_N  | TRACKDIR_BIT_LEFT_S,  /* TRACK_UPPER */
@@ -67,7 +69,7 @@
 
 /* Maps a trackdir to the (4-way) direction the tile is exited when following
  * that trackdir */
-extern const DiagDirection _trackdir_to_exitdir[] = {
+extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END] = {
 	DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_NE,
 	DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE,
 };
@@ -130,11 +132,7 @@
 			break;
 
 		case MP_TUNNELBRIDGE:
-			if (IsTunnel(tile)) {
-				if (GetTunnelTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
-			} else {
-				if (GetBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
-			}
+			if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
 			break;
 
 		default:
--- a/src/rail.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/rail.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,200 +5,13 @@
 #ifndef RAIL_H
 #define RAIL_H
 
-#include "gfx.h"
-#include "direction.h"
-#include "tile.h"
-#include "variables.h"
-
-/**
- * Enumeration for all possible railtypes.
- *
- * This enumeration defines all 4 possible railtypes.
- */
-enum RailType {
-	RAILTYPE_BEGIN    = 0,          ///< Used for iterations
-	RAILTYPE_RAIL     = 0,          ///< Standard non-electric rails
-	RAILTYPE_ELECTRIC = 1,          ///< Electric rails
-	RAILTYPE_MONO     = 2,          ///< Monorail
-	RAILTYPE_MAGLEV   = 3,          ///< Maglev
-	RAILTYPE_END,                   ///< Used for iterations
-	INVALID_RAILTYPE  = 0xFF        ///< Flag for invalid railtype
-};
-
-typedef byte RailTypeMask;
-
-/** Allow incrementing of Track variables */
-DECLARE_POSTFIX_INCREMENT(RailType);
-/** Define basic enum properties */
-template <> struct EnumPropsT<RailType> : MakeEnumPropsT<RailType, byte, RAILTYPE_BEGIN, RAILTYPE_END, INVALID_RAILTYPE> {};
-typedef TinyEnumT<RailType> RailTypeByte;
-
-
-/**
- * These are used to specify a single track.
- * Can be translated to a trackbit with TrackToTrackbit
- */
-enum Track {
-	TRACK_BEGIN = 0,        ///< Used for iterations
-	TRACK_X     = 0,        ///< Track along the x-axis (north-east to south-west)
-	TRACK_Y     = 1,        ///< Track along the y-axis (north-west to south-east)
-	TRACK_UPPER = 2,        ///< Track in the upper corner of the tile (north)
-	TRACK_LOWER = 3,        ///< Track in the lower corner of the tile (south)
-	TRACK_LEFT  = 4,        ///< Track in the left corner of the tile (west)
-	TRACK_RIGHT = 5,        ///< Track in the right corner of the tile (east)
-	TRACK_END,              ///< Used for iterations
-	INVALID_TRACK = 0xFF    ///< Flag for an invalid track
-};
-
-/** Allow incrementing of Track variables */
-DECLARE_POSTFIX_INCREMENT(Track);
-/** Define basic enum properties */
-template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
-typedef TinyEnumT<Track> TrackByte;
-
-
-/**
- * Convert an Axis to the corresponding Track
- * AXIS_X -> TRACK_X
- * AXIS_Y -> TRACK_Y
- * Uses the fact that they share the same internal encoding
- *
- * @param a the axis to convert
- * @return the track corresponding to the axis
- */
-static inline Track AxisToTrack(Axis a)
-{
-	return (Track)a;
-}
-
-
-/** Bitfield corresponding to Track */
-enum TrackBits {
-	TRACK_BIT_NONE    = 0U,                                                 ///< No track
-	TRACK_BIT_X       = 1U << TRACK_X,                                      ///< X-axis track
-	TRACK_BIT_Y       = 1U << TRACK_Y,                                      ///< Y-axis track
-	TRACK_BIT_UPPER   = 1U << TRACK_UPPER,                                  ///< Upper track
-	TRACK_BIT_LOWER   = 1U << TRACK_LOWER,                                  ///< Lower track
-	TRACK_BIT_LEFT    = 1U << TRACK_LEFT,                                   ///< Left track
-	TRACK_BIT_RIGHT   = 1U << TRACK_RIGHT,                                  ///< Right track
-	TRACK_BIT_CROSS   = TRACK_BIT_X     | TRACK_BIT_Y,                      ///< X-Y-axis cross
-	TRACK_BIT_HORZ    = TRACK_BIT_UPPER | TRACK_BIT_LOWER,                  ///< Upper and lower track
-	TRACK_BIT_VERT    = TRACK_BIT_LEFT  | TRACK_BIT_RIGHT,                  ///< Left and right track
-	TRACK_BIT_3WAY_NE = TRACK_BIT_X     | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,///< "Arrow" to the north-east
-	TRACK_BIT_3WAY_SE = TRACK_BIT_Y     | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,///< "Arrow" to the south-east
-	TRACK_BIT_3WAY_SW = TRACK_BIT_X     | TRACK_BIT_LOWER | TRACK_BIT_LEFT, ///< "Arrow" to the south-west
-	TRACK_BIT_3WAY_NW = TRACK_BIT_Y     | TRACK_BIT_UPPER | TRACK_BIT_LEFT, ///< "Arrow" to the north-west
-	TRACK_BIT_ALL     = TRACK_BIT_CROSS | TRACK_BIT_HORZ  | TRACK_BIT_VERT, ///< All possible tracks
-	TRACK_BIT_MASK    = 0x3FU,                                              ///< Bitmask for the first 6 bits
-	TRACK_BIT_WORMHOLE = 0x40U,                                             ///< Bitflag for a wormhole (used for tunnels)
-	TRACK_BIT_DEPOT   = 0x80U,                                              ///< Bitflag for a depot
-	INVALID_TRACK_BIT = 0xFF                                                ///< Flag for an invalid trackbits value
-};
-
-/** Define basic enum properties */
-template <> struct EnumPropsT<TrackBits> : MakeEnumPropsT<TrackBits, byte, TRACK_BIT_NONE, TRACK_BIT_ALL, INVALID_TRACK_BIT> {};
-typedef TinyEnumT<TrackBits> TrackBitsByte;
-
-DECLARE_ENUM_AS_BIT_SET(TrackBits);
-
-/**
- * Maps a Track to the corresponding TrackBits value
- * @param track the track to convert
- * @return the converted TrackBits value of the track
- */
-static inline TrackBits TrackToTrackBits(Track track)
-{
-	return (TrackBits)(1 << track);
-}
-
-/**
- * Maps an Axis to the corresponding TrackBits value
- * @param a the axis to convert
- * @return the converted TrackBits value of the axis
- */
-static inline TrackBits AxisToTrackBits(Axis a)
-{
-	return TrackToTrackBits(AxisToTrack(a));
-}
-
-/**
- * Returns a single horizontal/vertical trackbit, that is in a specific tile corner.
- *
- * @param corner The corner of a tile.
- * @return The TrackBits of the track in the corner.
- */
-static inline TrackBits CornerToTrackBits(Corner corner)
-{
-	extern const TrackBits _corner_to_trackbits[];
-	assert(IsValidCorner(corner));
-	return _corner_to_trackbits[corner];
-}
-
-
-/**
- * Enumeration for tracks and directions.
- *
- * These are a combination of tracks and directions. Values are 0-5 in one
- * direction (corresponding to the Track enum) and 8-13 in the other direction.
- * 6, 7, 14 and 15 are used to encode the reversing of road vehicles. Those
- * reversing track dirs are not considered to be 'valid' except in a small
- * corner in the road vehicle controller.
- */
-enum Trackdir {
-	TRACKDIR_BEGIN    =  0,         ///< Used for iterations
-	TRACKDIR_X_NE     =  0,         ///< X-axis and direction to north-east
-	TRACKDIR_Y_SE     =  1,         ///< Y-axis and direction to south-east
-	TRACKDIR_UPPER_E  =  2,         ///< Upper track and direction to east
-	TRACKDIR_LOWER_E  =  3,         ///< Lower track and direction to east
-	TRACKDIR_LEFT_S   =  4,         ///< Left track and direction to south
-	TRACKDIR_RIGHT_S  =  5,         ///< Right track and direction to south
-	TRACKDIR_RVREV_NE =  6,         ///< (Road vehicle) reverse direction north-east
-	TRACKDIR_RVREV_SE =  7,         ///< (Road vehicle) reverse direction south-east
-	TRACKDIR_X_SW     =  8,         ///< X-axis and direction to south-west
-	TRACKDIR_Y_NW     =  9,         ///< Y-axis and direction to north-west
-	TRACKDIR_UPPER_W  = 10,         ///< Upper track and direction to west
-	TRACKDIR_LOWER_W  = 11,         ///< Lower track and direction to west
-	TRACKDIR_LEFT_N   = 12,         ///< Left track and direction to north
-	TRACKDIR_RIGHT_N  = 13,         ///< Right track and direction to north
-	TRACKDIR_RVREV_SW = 14,         ///< (Road vehicle) reverse direction south-west
-	TRACKDIR_RVREV_NW = 15,         ///< (Road vehicle) reverse direction north-west
-	TRACKDIR_END,                   ///< Used for iterations
-	INVALID_TRACKDIR  = 0xFF,       ///< Flag for an invalid trackdir
-};
-
-/** Define basic enum properties */
-template <> struct EnumPropsT<Trackdir> : MakeEnumPropsT<Trackdir, byte, TRACKDIR_BEGIN, TRACKDIR_END, INVALID_TRACKDIR> {};
-typedef TinyEnumT<Trackdir> TrackdirByte;
-
-/**
- * Enumeration of bitmasks for the TrackDirs
- *
- * These are a combination of tracks and directions. Values are 0-5 in one
- * direction (corresponding to the Track enum) and 8-13 in the other direction.
- */
-enum TrackdirBits {
-	TRACKDIR_BIT_NONE     = 0x0000, ///< No track build
-	TRACKDIR_BIT_X_NE     = 0x0001, ///< Track x-axis, direction north-east
-	TRACKDIR_BIT_Y_SE     = 0x0002, ///< Track y-axis, direction south-east
-	TRACKDIR_BIT_UPPER_E  = 0x0004, ///< Track upper, direction east
-	TRACKDIR_BIT_LOWER_E  = 0x0008, ///< Track lower, direction east
-	TRACKDIR_BIT_LEFT_S   = 0x0010, ///< Track left, direction south
-	TRACKDIR_BIT_RIGHT_S  = 0x0020, ///< Track right, direction south
-	/* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
-	TRACKDIR_BIT_X_SW     = 0x0100, ///< Track x-axis, direction south-west
-	TRACKDIR_BIT_Y_NW     = 0x0200, ///< Track y-axis, direction north-west
-	TRACKDIR_BIT_UPPER_W  = 0x0400, ///< Track upper, direction west
-	TRACKDIR_BIT_LOWER_W  = 0x0800, ///< Track lower, direction west
-	TRACKDIR_BIT_LEFT_N   = 0x1000, ///< Track left, direction north
-	TRACKDIR_BIT_RIGHT_N  = 0x2000, ///< Track right, direction north
-	TRACKDIR_BIT_MASK     = 0x3F3F, ///< Bitmask for bit-operations
-	INVALID_TRACKDIR_BIT  = 0xFFFF, ///< Flag for an invalid trackdirbit value
-};
-
-/** Define basic enum properties */
-template <> struct EnumPropsT<TrackdirBits> : MakeEnumPropsT<TrackdirBits, uint16, TRACKDIR_BIT_NONE, TRACKDIR_BIT_MASK, INVALID_TRACKDIR_BIT> {};
-typedef TinyEnumT<TrackdirBits> TrackdirBitsShort;
-DECLARE_ENUM_AS_BIT_SET(TrackdirBits);
+#include "rail_type.h"
+#include "track_type.h"
+#include "vehicle_type.h"
+#include "gfx_type.h"
+#include "core/bitmath_func.hpp"
+#include "economy_func.h"
+#include "tile_cmd.h"
 
 /** This struct contains all the info that is needed to draw and construct tracks.
  */
@@ -275,6 +88,11 @@
 	 * Offset to add to ground sprite when drawing custom waypoints / stations
 	 */
 	byte custom_ground_offset;
+
+	/**
+	 * Multiplier for curve maximum speed advantage
+	 */
+	byte curve_speed;
 };
 
 
@@ -284,458 +102,7 @@
 	NUM_SSD_STACK =  32, ///< max amount of blocks to check recursively
 };
 
-/**
- * Maps a Trackdir to the corresponding TrackdirBits value
- * @param trackdir the track direction to convert
- * @return the converted TrackdirBits value
- */
-static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
-{
-	return (TrackdirBits)(1 << trackdir);
-}
-
-/**
- * Removes first Track from TrackBits and returns it
- *
- * This function searchs for the first bit in the TrackBits,
- * remove this bit from the parameter and returns the found
- * bit as Track value. It returns INVALID_TRACK if the
- * parameter was TRACK_BIT_NONE or INVALID_TRACK_BIT. This
- * is basically used in while-loops to get up to 6 possible
- * tracks on a tile until the parameter becomes TRACK_BIT_NONE.
- *
- * @param tracks The value with the TrackBits
- * @return The first Track from the TrackBits value
- * @see FindFirstTrack
- */
-static inline Track RemoveFirstTrack(TrackBits *tracks)
-{
-	if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) {
-		Track first = (Track)FIND_FIRST_BIT(*tracks);
-		ClrBit(*tracks, first);
-		return first;
-	}
-	return INVALID_TRACK;
-}
-
-/**
- * Removes first Trackdir from TrackdirBits and returns it
- *
- * This function searchs for the first bit in the TrackdirBits parameter,
- * remove this bit from the parameter and returns the fnound bit as
- * Trackdir value. It returns INVALID_TRACKDIR if the trackdirs is
- * TRACKDIR_BIT_NONE or INVALID_TRACKDIR_BIT. This is basically used in a
- * while-loop to get all track-directions step by step until the value
- * reaches TRACKDIR_BIT_NONE.
- *
- * @param trackdirs The value with the TrackdirBits
- * @return The first Trackdir from the TrackdirBits value
- * @see FindFirstTrackdir
- */
-static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
-{
-	if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) {
-		Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs);
-		ClrBit(*trackdirs, first);
-		return first;
-	}
-	return INVALID_TRACKDIR;
-}
-
-/**
- * Returns first Track from TrackBits or INVALID_TRACK
- *
- * This function returns the first Track found in the TrackBits value as Track-value.
- * It returns INVALID_TRACK if the parameter is TRACK_BIT_NONE or INVALID_TRACK_BIT.
- *
- * @param tracks The TrackBits value
- * @return The first Track found or INVALID_TRACK
- * @see RemoveFirstTrack
- */
-static inline Track FindFirstTrack(TrackBits tracks)
-{
-	return (tracks != TRACK_BIT_NONE && tracks != INVALID_TRACK_BIT) ? (Track)FIND_FIRST_BIT(tracks) : INVALID_TRACK;
-}
-
-/**
- * Converts TrackBits to Track.
- *
- * This function converts a TrackBits value to a Track value. As it
- * is not possible to convert two or more tracks to one track the
- * parameter must contain only one track or be the INVALID_TRACK_BIT value.
- *
- * @param tracks The TrackBits value to convert
- * @return The Track from the value or INVALID_TRACK
- * @pre tracks must contains only one Track or be INVALID_TRACK_BIT
- */
-static inline Track TrackBitsToTrack(TrackBits tracks)
-{
-	assert(tracks == INVALID_TRACK_BIT || (tracks != TRACK_BIT_NONE && KillFirstBit(tracks & TRACK_BIT_MASK) == TRACK_BIT_NONE));
-	return tracks != INVALID_TRACK_BIT ? (Track)FIND_FIRST_BIT(tracks & TRACK_BIT_MASK) : INVALID_TRACK;
-}
-
-/**
- * Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR
- *
- * This function returns the first Trackdir in the given TrackdirBits value or
- * INVALID_TRACKDIR if the value is TRACKDIR_BIT_NONE. The TrackdirBits must
- * not be INVALID_TRACKDIR_BIT.
- *
- * @param trackdirs The TrackdirBits value
- * @return The first Trackdir from the TrackdirBits or INVALID_TRACKDIR on TRACKDIR_BIT_NONE.
- * @pre trackdirs must not be INVALID_TRACKDIR_BIT
- * @see RemoveFirstTrackdir
- */
-static inline Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
-{
-	assert((trackdirs & ~TRACKDIR_BIT_MASK) == TRACKDIR_BIT_NONE);
-	return (trackdirs != TRACKDIR_BIT_NONE) ? (Trackdir)FindFirstBit2x64(trackdirs) : INVALID_TRACKDIR;
-}
-
-/**
- * Checks if a Track is valid.
- *
- * @param track The value to check
- * @return true if the given value is a valid track.
- * @note Use this in an assert()
- */
-static inline bool IsValidTrack(Track track)
-{
-	return track < TRACK_END;
-}
-
-/**
- * Checks if a Trackdir is valid.
- *
- * @param trackdir The value to check
- * @return true if the given valie is a valid Trackdir
- * @note Use this in an assert()
- */
-static inline bool IsValidTrackdir(Trackdir trackdir)
-{
-	return (TrackdirToTrackdirBits(trackdir) & TRACKDIR_BIT_MASK) != 0;
-}
-
-/*
- * Functions to map tracks to the corresponding bits in the signal
- * presence/status bytes in the map. You should not use these directly, but
- * wrapper functions below instead. XXX: Which are these?
- */
-
-/**
- * Maps a trackdir to the bit that stores its status in the map arrays, in the
- * direction along with the trackdir.
- */
-static inline byte SignalAlongTrackdir(Trackdir trackdir)
-{
-	extern const byte _signal_along_trackdir[TRACKDIR_END];
-	return _signal_along_trackdir[trackdir];
-}
-
-/**
- * Maps a trackdir to the bit that stores its status in the map arrays, in the
- * direction against the trackdir.
- */
-static inline byte SignalAgainstTrackdir(Trackdir trackdir)
-{
-	extern const byte _signal_against_trackdir[TRACKDIR_END];
-	return _signal_against_trackdir[trackdir];
-}
-
-/**
- * Maps a Track to the bits that store the status of the two signals that can
- * be present on the given track.
- */
-static inline byte SignalOnTrack(Track track)
-{
-	extern const byte _signal_on_track[TRACK_END];
-	return _signal_on_track[track];
-}
-
-
-/*
- * Functions describing logical relations between Tracks, TrackBits, Trackdirs
- * TrackdirBits, Direction and DiagDirections.
- */
-
-/**
- * Maps a trackdir to the reverse trackdir.
- *
- * Returns the reverse trackdir of a Trackdir value. The reverse trackdir
- * is the same track with the other direction on it.
- *
- * @param trackdir The Trackdir value
- * @return The reverse trackdir
- * @pre trackdir must not be INVALID_TRACKDIR
- */
-static inline Trackdir ReverseTrackdir(Trackdir trackdir)
-{
-	assert(trackdir != INVALID_TRACKDIR);
-	return (Trackdir)(trackdir ^ 8);
-}
-
-/**
- * Returns the Track that a given Trackdir represents
- *
- * This function filters the Track which is used in the Trackdir value and
- * returns it as a Track value.
- *
- * @param trackdir The trackdir value
- * @return The Track which is used in the value
- */
-static inline Track TrackdirToTrack(Trackdir trackdir)
-{
-	return (Track)(trackdir & 0x7);
-}
-
-/**
- * Returns a Trackdir for the given Track
- *
- * Since every Track corresponds to two Trackdirs, we choose the
- * one which points between NE and S. Note that the actual
- * implementation is quite futile, but this might change
- * in the future.
- *
- * @param track The given Track
- * @return The Trackdir from the given Track
- */
-static inline Trackdir TrackToTrackdir(Track track)
-{
-	return (Trackdir)track;
-}
 
-/**
- * Returns a TrackdirBit mask from a given Track
- *
- * The TrackdirBit mask contains the two TrackdirBits that
- * correspond with the given Track (one for each direction).
- *
- * @param track The track to get the TrackdirBits from
- * @return The TrackdirBits which the selected tracks
- */
-static inline TrackdirBits TrackToTrackdirBits(Track track)
-{
-	Trackdir td = TrackToTrackdir(track);
-	return (TrackdirBits)(TrackdirToTrackdirBits(td) | TrackdirToTrackdirBits(ReverseTrackdir(td)));
-}
-
-/**
- * Discards all directional information from a TrackdirBits value
- *
- * Any Track which is present in either direction will be present in the result.
- *
- * @param bits The TrackdirBits to get the TrackBits from
- * @return The TrackBits
- */
-static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
-{
-	return (TrackBits)((bits | (bits >> 8)) & TRACK_BIT_MASK);
-}
-
-/**
- * Maps a trackdir to the trackdir that you will end up on if you go straight
- * ahead.
- *
- * This will be the same trackdir for diagonal trackdirs, but a
- * different (alternating) one for straight trackdirs
- *
- * @param trackdir The given trackdir
- * @return The next Trackdir value of the next tile.
- */
-static inline Trackdir NextTrackdir(Trackdir trackdir)
-{
-	extern const Trackdir _next_trackdir[TRACKDIR_END];
-	return _next_trackdir[trackdir];
-}
-
-/**
- * Maps a track to all tracks that make 90 deg turns with it.
- *
- * For the diagonal directions these are the complement of the
- * direction, for the straight directions these are the
- * two vertical or horizontal tracks, depend on the given direction
- *
- * @param track The given track
- * @return The TrackBits with the tracks marked which cross the given track by 90 deg.
- */
-static inline TrackBits TrackCrossesTracks(Track track)
-{
-	extern const TrackBits _track_crosses_tracks[TRACK_END];
-	return _track_crosses_tracks[track];
-}
-
-/**
- * Maps a trackdir to the (4-way) direction the tile is exited when following
- * that trackdir.
- *
- * For the diagonal directions these are the same directions. For
- * the straight directions these are the directions from the imagined
- * base-tile to the bordering tile which will be joined if the given
- * straight direction is leaved from the base-tile.
- *
- * @param trackdir The given track direction
- * @return The direction which points to the resulting tile if following the Trackdir
- */
-static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
-{
-	extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
-	return _trackdir_to_exitdir[trackdir];
-}
-
-/**
- * Maps a track and an (4-way) dir to the trackdir that represents the track
- * with the exit in the given direction.
- *
- * For the diagonal tracks the resulting track direction are clear for a given
- * DiagDirection. It either matches the direction or it returns INVALID_TRACKDIR,
- * as a TRACK_X cannot be applied with DIAG_SE.
- * For the straight tracks the resulting track direction will be the
- * direction which the DiagDirection is pointing. But this will be INVALID_TRACKDIR
- * if the DiagDirection is pointing 'away' the track.
- *
- * @param track The track to applie an direction on
- * @param diagdir The DiagDirection to applie on
- * @return The resulting track direction or INVALID_TRACKDIR if not possible.
- */
-static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir)
-{
-	extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END];
-	return _track_exitdir_to_trackdir[track][diagdir];
-}
-
-/**
- * Maps a track and an (4-way) dir to the trackdir that represents the track
- * with the entry in the given direction.
- *
- * For the diagonal tracks the return value is clear, its either the matching
- * track direction or INVALID_TRACKDIR.
- * For the straight tracks this returns the track direction which results if
- * you follow the DiagDirection and then turn by 45 deg left or right on the
- * next tile. The new direction on the new track will be the returning Trackdir
- * value. If the parameters makes no sense like the track TRACK_UPPER and the
- * diraction DIAGDIR_NE (target track cannot be reached) this function returns
- * INVALID_TRACKDIR.
- *
- * @param track The target track
- * @param diagdir The direction to "come from"
- * @return the resulting Trackdir or INVALID_TRACKDIR if not possible.
- */
-static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir)
-{
-	extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END];
-	return _track_enterdir_to_trackdir[track][diagdir];
-}
-
-/**
- * Maps a track and a full (8-way) direction to the trackdir that represents
- * the track running in the given direction.
- */
-static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
-{
-	extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
-	return _track_direction_to_trackdir[track][dir];
-}
-
-/**
- * Maps a (4-way) direction to the diagonal trackdir that runs in that
- * direction.
- *
- * @param diagdir The direction
- * @return The resulting Trackdir direction
- */
-static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir)
-{
-	extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
-	return _dir_to_diag_trackdir[diagdir];
-}
-
-/**
- * Returns all trackdirs that can be reached when entering a tile from a given
- * (diagonal) direction.
- *
- * This will obviously include 90 degree turns, since no information is available
- * about the exact angle of entering
- *
- * @param diagdir The joining direction
- * @return The TrackdirBits which can be used from the given direction
- * @see DiagdirReachesTracks
- */
-static inline TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
-{
-	extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
-	return _exitdir_reaches_trackdirs[diagdir];
-}
-
-/**
- * Returns all tracks that can be reached when entering a tile from a given
- * (diagonal) direction.
- *
- * This will obviously include 90 degree turns, since no
- * information is available about the exact angle of entering
- *
- * @param diagdir The joining irection
- * @return The tracks which can be used
- * @see DiagdirReachesTrackdirs
- */
-static inline TrackBits DiagdirReachesTracks(DiagDirection diagdir) { return TrackdirBitsToTrackBits(DiagdirReachesTrackdirs(diagdir)); }
-
-/**
- * Maps a trackdir to the trackdirs that can be reached from it (ie, when
- * entering the next tile.
- *
- * This will include 90 degree turns!
- *
- * @param trackdir The track direction which will be leaved
- * @return The track directions which can be used from this direction (in the next tile)
- */
-static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
-{
-	extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
-	return _exitdir_reaches_trackdirs[TrackdirToExitdir(trackdir)];
-}
-/* Note that there is no direct table for this function (there used to be),
- * but it uses two simpeler tables to achieve the result */
-
-/**
- * Maps a trackdir to all trackdirs that make 90 deg turns with it.
- *
- * For the diagonal tracks this returns the track direction bits
- * of the other axis in both directions, which cannot be joined by
- * the given track direction.
- * For the straight tracks this returns all possible 90 deg turns
- * either on the current tile (which no train can joined) or on the
- * bordering tiles.
- *
- * @param trackdir The track direction
- * @return The TrackdirBits which are (more or less) 90 deg turns.
- */
-static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
-{
-	extern const TrackdirBits _track_crosses_trackdirs[TRACKDIR_END];
-	return _track_crosses_trackdirs[TrackdirToTrack(trackdir)];
-}
-
-/**
- * Checks if a given Track is diagonal
- *
- * @param track The given track to check
- * @return true if diagonal, else false
- */
-static inline bool IsDiagonalTrack(Track track)
-{
-	return (track == TRACK_X) || (track == TRACK_Y);
-}
-
-/**
- * Checks if a given Trackdir is diagonal.
- *
- * @param trackdir The given trackdir
- * @return true if the trackdir use a diagonal track
- */
-static inline bool IsDiagonalTrackdir(Trackdir trackdir)
-{
-	return IsDiagonalTrack(TrackdirToTrack(trackdir));
-}
 
 /**
  * Returns a pointer to the Railtype information for a given railtype
@@ -775,23 +142,6 @@
 	return HasBit(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype);
 }
 
-/**
- * Checks if the given tracks overlap, ie form a crossing. Basically this
- * means when there is more than one track on the tile, exept when there are
- * two parallel tracks.
- * @param  bits The tracks present.
- * @return Whether the tracks present overlap in any way.
- */
-static inline bool TracksOverlap(TrackBits bits)
-{
-	/* With no, or only one track, there is no overlap */
-	if (bits == TRACK_BIT_NONE || KillFirstBit(bits) == TRACK_BIT_NONE) return false;
-	/* We know that there are at least two tracks present. When there are more
-	 * than 2 tracks, they will surely overlap. When there are two, they will
-	 * always overlap unless they are lower & upper or right & left. */
-	return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT;
-}
-
 
 extern int _railtype_cost_multiplier[RAILTYPE_END];
 extern const int _default_railtype_cost_multiplier[RAILTYPE_END];
@@ -807,6 +157,34 @@
 	return (_price.build_rail * _railtype_cost_multiplier[railtype]) >> 3;
 }
 
+/**
+ * Calculates the cost of rail conversion
+ * @param from The railtype we are converting from
+ * @param to   The railtype we are converting to
+ * @return Cost per TrackBit
+ */
+static inline Money RailConvertCost(RailType from, RailType to)
+{
+	/* rail -> el. rail
+	 * calculate the price as 5 / 4 of (cost build el. rail) - (cost build rail)
+	 * (the price of workers to get to place is that 1/4)
+	 */
+	if (HasPowerOnRail(from, to)) {
+		return ((RailBuildCost(to) - RailBuildCost(from)) * 5) >> 2;
+	}
+
+	/* el. rail -> rail
+	 * calculate the price as 1 / 4 of (cost build el. rail) - (cost build rail)
+	 * (the price of workers is 1 / 4 + price of copper sold to a recycle center)
+	 */
+	if (HasPowerOnRail(to, from)) {
+		return (RailBuildCost(from) - RailBuildCost(to)) >> 2;
+	}
+
+	/* make the price the same as remove + build new type */
+	return RailBuildCost(to) + _price.remove_rail;
+}
+
 void *UpdateTrainPowerProc(Vehicle *v, void *data);
 void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
 void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
@@ -821,8 +199,6 @@
 
 Foundation GetRailFoundation(Slope tileh, TrackBits bits);
 
-void FloodHalftile(TileIndex t);
-
 int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
 
 #endif /* RAIL_H */
--- a/src/rail_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/rail_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,30 +8,25 @@
 #include "bridge.h"
 #include "cmd_helper.h"
 #include "debug.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "rail_map.h"
 #include "road_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "map.h"
 #include "landscape.h"
-#include "tile.h"
 #include "town_map.h"
 #include "tunnel_map.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "command.h"
+#include "viewport_func.h"
+#include "command_func.h"
 #include "pathfind.h"
 #include "engine.h"
 #include "town.h"
-#include "sound.h"
 #include "station.h"
 #include "sprite.h"
 #include "depot.h"
 #include "waypoint.h"
-#include "window.h"
 #include "rail.h"
-#include "railtypes.h" // include table for railtypes
+#include "table/railtypes.h" // include table for railtypes
 #include "newgrf.h"
 #include "yapf/yapf.h"
 #include "newgrf_engine.h"
@@ -39,8 +34,15 @@
 #include "newgrf_station.h"
 #include "train.h"
 #include "misc/autoptr.hpp"
+#include "variables.h"
 #include "autoslope.h"
 #include "transparency.h"
+#include "water.h"
+#include "tunnelbridge_map.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+
 
 const byte _track_sloped_sprites[14] = {
 	14, 15, 22, 13,
@@ -81,21 +83,14 @@
  *               11uuuudd => rail depot
  */
 
-/** Struct used in EnsureNoTrainOnTrack() */
-struct TrainOnTrackData {
-	TileIndex tile;       ///< tile to check
-	uint z;               ///< tile max Z
-	TrackBits rail_bits;  ///< trackbits of interest
-};
 
 static void *EnsureNoTrainOnTrackProc(Vehicle *v, void *data)
 {
-	const TrainOnTrackData *info = (const TrainOnTrackData *)data;
-
-	if (v->tile != info->tile || v->type != VEH_TRAIN) return NULL;
-	if (v->z_pos > info->z) return NULL;
-
-	if ((v->u.rail.track != info->rail_bits) && !TracksOverlap(v->u.rail.track | info->rail_bits)) return NULL;
+	TrackBits rail_bits = *(TrackBits *)data;
+
+	if (v->type != VEH_TRAIN) return NULL;
+
+	if ((v->u.rail.track != rail_bits) && !TracksOverlap(v->u.rail.track | rail_bits)) return NULL;
 
 	_error_message = VehicleInTheWayErrMsg(v);
 	return v;
@@ -110,13 +105,9 @@
  */
 static bool EnsureNoTrainOnTrack(TileIndex tile, Track track)
 {
-	TrainOnTrackData info;
-
-	info.tile = tile;
-	info.z = GetTileMaxZ(tile);
-	info.rail_bits = TrackToTrackBits(track);
-
-	return VehicleFromPos(tile, &info, EnsureNoTrainOnTrackProc) == NULL;
+	TrackBits rail_bits = TrackToTrackBits(track);
+
+	return VehicleFromPos(tile, &rail_bits, &EnsureNoTrainOnTrackProc) == NULL;
 }
 
 static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags)
@@ -297,7 +288,7 @@
 	   ) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 
 	Foundation f_old = GetRailFoundation(tileh, existing);
-	return CommandCost(f_new != f_old ? _price.terraform : (Money)0);
+	return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? _price.terraform : (Money)0);
 }
 
 /* Validate functions for rail building */
@@ -315,7 +306,7 @@
 	RailType railtype;
 	Track track;
 	TrackBits trackbit;
-	CommandCost cost;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	CommandCost ret;
 
 	if (!ValParamRailtype(p1) || !ValParamTrackOrientation((Track)p2)) return CMD_ERROR;
@@ -325,8 +316,6 @@
 	tileh = GetTileSlope(tile, NULL);
 	trackbit = TrackToTrackBits(track);
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	switch (GetTileType(tile)) {
 		case MP_RAILWAY:
 			if (!CheckTrackCombination(tile, trackbit, flags) ||
@@ -418,7 +407,7 @@
 
 			if (water_ground) {
 				cost.AddCost(-_price.clear_water);
-				cost.AddCost(_price.purchase_land);
+				cost.AddCost(_price.clear_roughland);
 			}
 
 			if (flags & DC_EXEC) {
@@ -447,14 +436,12 @@
 {
 	Track track = (Track)p2;
 	TrackBits trackbit;
-	CommandCost cost(_price.remove_rail);
+	CommandCost cost(EXPENSES_CONSTRUCTION, _price.remove_rail );
 	bool crossing = false;
 
 	if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR;
 	trackbit = TrackToTrackBits(track);
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	switch (GetTileType(tile)) {
 		case MP_ROAD: {
 			if (!IsLevelCrossing(tile) ||
@@ -633,7 +620,7 @@
  */
 static CommandCost CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	CommandCost ret, total_cost;
+	CommandCost ret, total_cost(EXPENSES_CONSTRUCTION);
 	Track track = (Track)GB(p2, 4, 3);
 	Trackdir trackdir;
 	byte mode = HasBit(p2, 7);
@@ -645,8 +632,6 @@
 	end_tile = p1;
 	trackdir = TrackToTrackdir(track);
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
 
 	if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, tile);
@@ -715,11 +700,8 @@
  */
 CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	CommandCost cost;
 	Slope tileh;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* check railtype and valid direction for depot (0 through 3), 4 in total */
 	if (!ValParamRailtype(p1)) return CMD_ERROR;
 
@@ -743,7 +725,7 @@
 		return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 	}
 
-	cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+	CommandCost cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 	if (CmdFailed(cost)) return CMD_ERROR;
 
 	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
@@ -774,16 +756,20 @@
  * @param flags operation to perform
  * @param p1 various bitstuffed elements
  * - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum)
- * - p1 = (bit 3)   - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
+ * - p1 = (bit 3)   - 1 = override signal/semaphore, or pre/exit/combo signal or (for bit 7) toggle variant (CTRL-toggle)
  * - p1 = (bit 4)   - 0 = signals, 1 = semaphores
+ * - p1 = (bit 5-6) - type of the signal, for valid values see enum SignalType in rail_map.h
+ * - p1 = (bit 7)   - convert the present signal type and variant
  * @param p2 used for CmdBuildManySignals() to copy direction of first signal
  * TODO: p2 should be replaced by two bits for "along" and "against" the track.
  */
 CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	Track track = (Track)GB(p1, 0, 3);
-	bool pre_signal = HasBit(p1, 3);
-	SignalVariant sigvar = (pre_signal ^ HasBit(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC;
+	bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed
+	SignalVariant sigvar = (ctrl_pressed ^ HasBit(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC; // the signal variant of the new signal
+	SignalType sigtype = (SignalType)GB(p1, 5, 2); // the signal type of the new signal
+	bool convert_signal = HasBit(p1, 7); // convert button pressed
 	CommandCost cost;
 
 	if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoTrainOnTrack(tile, track))
@@ -797,27 +783,37 @@
 
 	if (!CheckTileOwnership(tile)) return CMD_ERROR;
 
-	_error_message = STR_1005_NO_SUITABLE_RAILROAD_TRACK;
-
 	{
 		/* See if this is a valid track combination for signals, (ie, no overlap) */
 		TrackBits trackbits = GetTrackBits(tile);
 		if (KillFirstBit(trackbits) != TRACK_BIT_NONE && /* More than one track present */
 				trackbits != TRACK_BIT_HORZ &&
 				trackbits != TRACK_BIT_VERT) {
-			return CMD_ERROR;
+			return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK);
 		}
 	}
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+	/* you can not convert a signal if no signal is on track */
+	if (convert_signal && !HasSignalOnTrack(tile, track)) return CMD_ERROR;
 
 	if (!HasSignalOnTrack(tile, track)) {
 		/* build new signals */
-		cost = CommandCost(_price.build_signals);
+		cost = CommandCost(EXPENSES_CONSTRUCTION, _price.build_signals);
 	} else {
 		if (p2 != 0 && sigvar != GetSignalVariant(tile, track)) {
 			/* convert signals <-> semaphores */
-			cost = CommandCost(_price.build_signals + _price.remove_signals);
+			cost = CommandCost(EXPENSES_CONSTRUCTION, _price.build_signals + _price.remove_signals);
+
+		} else if (convert_signal) {
+			/* convert button pressed */
+			if (ctrl_pressed || GetSignalVariant(tile, track) != sigvar) {
+				/* convert electric <-> semaphore */
+				cost = CommandCost(EXPENSES_CONSTRUCTION, _price.build_signals + _price.remove_signals);
+			} else {
+				/* it is free to change signal type: normal-pre-exit-combo */
+				cost = CommandCost();
+			}
+
 		} else {
 			/* it is free to change orientation/pre-exit-combo signals */
 			cost = CommandCost();
@@ -830,7 +826,7 @@
 			SetHasSignals(tile, true);
 			SetSignalStates(tile, 0xF); // all signals are on
 			SetPresentSignals(tile, 0); // no signals built by default
-			SetSignalType(tile, track, SIGTYPE_NORMAL);
+			SetSignalType(tile, track, sigtype);
 			SetSignalVariant(tile, track, sigvar);
 		}
 
@@ -838,15 +834,28 @@
 			if (!HasSignalOnTrack(tile, track)) {
 				/* build new signals */
 				SetPresentSignals(tile, GetPresentSignals(tile) | SignalOnTrack(track));
-				SetSignalType(tile, track, SIGTYPE_NORMAL);
+				SetSignalType(tile, track, sigtype);
 				SetSignalVariant(tile, track, sigvar);
 			} else {
-				if (pre_signal) {
+				if (convert_signal) {
+					/* convert signal button pressed */
+					if (ctrl_pressed) {
+						/* toggle the pressent signal variant: SIG_ELECTRIC <-> SIG_SEMAPHORE */
+						SetSignalVariant(tile, track, (GetSignalVariant(tile, track) == SIG_ELECTRIC) ? SIG_SEMAPHORE : SIG_ELECTRIC);
+
+					} else {
+						/* convert the present signal to the chosen type and variant */
+						SetSignalType(tile, track, sigtype);
+						SetSignalVariant(tile, track, sigvar);
+					}
+
+				} else if (ctrl_pressed) {
 					/* cycle between normal -> pre -> exit -> combo -> ... */
-					SignalType type = GetSignalType(tile, track);
-
-					SetSignalType(tile, track, type == SIGTYPE_COMBO ? SIGTYPE_NORMAL : (SignalType)(type + 1));
+					sigtype = GetSignalType(tile, track);
+
+					SetSignalType(tile, track, sigtype == SIGTYPE_COMBO ? SIGTYPE_NORMAL : (SignalType)(sigtype + 1));
 				} else {
+					/* cycle the signal side: both -> left -> right -> both -> ... */
 					CycleSignalSide(tile, track);
 				}
 			}
@@ -904,17 +913,15 @@
 			return true;
 
 		case MP_TUNNELBRIDGE: {
-			TileIndex orig_tile = tile;
-			/* Skip to end of tunnel or bridge */
-			if (IsBridge(tile)) {
-				if (GetBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
-				if (GetBridgeRampDirection(tile) != TrackdirToExitdir(trackdir)) return false;
-				tile = GetOtherBridgeEnd(tile);
-			} else {
-				if (GetTunnelTransportType(tile) != TRANSPORT_RAIL) return false;
-				if (GetTunnelDirection(tile) != TrackdirToExitdir(trackdir)) return false;
-				tile = GetOtherTunnelEnd(tile);
-			}
+			TileIndex orig_tile = tile; // backup old value
+
+			if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
+			if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(trackdir)) return false;
+
+			/* Skip to end of tunnel or bridge
+			 * note that tile is a parameter by reference, so it must be updated */
+			tile = GetOtherTunnelBridgeEnd(tile);
+
 			signal_ctr += 2 + DistanceMax(orig_tile, tile) * 2;
 			return true;
 		}
@@ -937,7 +944,7 @@
  */
 static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	CommandCost ret, total_cost;
+	CommandCost ret, total_cost(EXPENSES_CONSTRUCTION);
 	int signal_ctr;
 	byte signals;
 	bool error = true;
@@ -958,8 +965,6 @@
 
 	if (!IsTileType(tile, MP_RAILWAY)) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* for vertical/horizontal tracks, double the given signals density
 	 * since the original amount will be too dense (shorter tracks) */
 	signal_density *= 2;
@@ -1082,8 +1087,6 @@
 	/* Only water can remove signals from anyone */
 	if (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* Do it? */
 	if (flags & DC_EXEC) {
 		SetPresentSignals(tile, GetPresentSignals(tile) & ~SignalOnTrack(track));
@@ -1101,7 +1104,7 @@
 		MarkTileDirtyByTile(tile);
 	}
 
-	return CommandCost(_price.remove_signals);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_signals);
 }
 
 /** Remove signals on a stretch of track.
@@ -1123,13 +1126,12 @@
 	return CmdSignalTrackHelper(tile, flags, p1, SetBit(p2, 5)); // bit 5 is remove bit
 }
 
-typedef CommandCost DoConvertRailProc(TileIndex tile, RailType totype, bool exec);
-
+/** Update power of train under which is the railtype being converted */
 void *UpdateTrainPowerProc(Vehicle *v, void *data)
 {
 	/* Similiar checks as in TrainPowerChanged() */
 
-	if (v->type == VEH_TRAIN && v->tile == *(TileIndex*)data && !IsArticulatedPart(v)) {
+	if (v->type == VEH_TRAIN && !IsArticulatedPart(v)) {
 		const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
 		if (GetVehicleProperty(v, 0x0B, rvi->power) != 0) TrainPowerChanged(v->First());
 	}
@@ -1137,46 +1139,6 @@
 	return NULL;
 }
 
-/**
- * Switches the rail type.
- * Railtypes are stored on a per-tile basis, not on a per-track basis, so
- * all the tracks in the given tile will be converted.
- * @param tile        The tile on which the railtype is to be convert.
- * @param totype      The railtype we want to convert to
- * @param exec        Switches between test and execute mode
- * @return            The cost and state of the operation
- * @retval CMD_ERROR  An error occured during the operation.
- */
-static CommandCost DoConvertRail(TileIndex tile, RailType totype, bool exec)
-{
-	/* change type. */
-	if (exec) {
-		SetRailType(tile, totype);
-		MarkTileDirtyByTile(tile);
-
-		/* notify YAPF about the track layout change */
-		TrackBits tracks = GetTrackBits(tile);
-		while (tracks != TRACK_BIT_NONE) {
-			YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
-		}
-
-		if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
-			/* Update build vehicle window related to this depot */
-			InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
-			InvalidateWindowData(WC_BUILD_VEHICLE, tile);
-		}
-
-		/* update power of train engines on this tile */
-		VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
-	}
-
-	return CommandCost(RailBuildCost(totype) / 2);
-}
-
-extern CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec);
-extern CommandCost DoConvertStreetRail(TileIndex tile, RailType totype, bool exec);
-extern CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec);
-
 /** Convert one rail type to the other. You can convert normal rail to
  * monorail/maglev easily or vice-versa.
  * @param tile end tile of rail conversion drag
@@ -1186,72 +1148,152 @@
  */
 CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	CommandCost ret, cost;
-	Money money;
-	int ex;
-	int ey;
-	int sx, sy, x, y;
-
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 
 	if (!ValParamRailtype(p2)) return CMD_ERROR;
 	if (p1 >= MapSize()) return CMD_ERROR;
 
+	RailType totype = (RailType)p2;
+
+	uint ex = TileX(tile);
+	uint ey = TileY(tile);
+	uint sx = TileX(p1);
+	uint sy = TileY(p1);
+
 	/* make sure sx,sy are smaller than ex,ey */
-	ex = TileX(tile);
-	ey = TileY(tile);
-	sx = TileX(p1);
-	sy = TileY(p1);
 	if (ex < sx) Swap(ex, sx);
 	if (ey < sy) Swap(ey, sy);
 
-	money = GetAvailableMoneyForCommand();
-
-	for (x = sx; x <= ex; ++x) {
-		for (y = sy; y <= ey; ++y) {
+	_error_message = STR_1005_NO_SUITABLE_RAILROAD_TRACK; // by default, there is no track to convert
+
+	for (uint x = sx; x <= ex; ++x) {
+		for (uint y = sy; y <= ey; ++y) {
 			TileIndex tile = TileXY(x, y);
-			DoConvertRailProc *proc;
-			RailType totype = (RailType)p2;
-
-			switch (GetTileType(tile)) {
-				case MP_RAILWAY:      proc = DoConvertRail;             break;
-				case MP_STATION:      proc = DoConvertStationRail;      break;
-				case MP_ROAD:         proc = DoConvertStreetRail;       break;
-				case MP_TUNNELBRIDGE: proc = DoConvertTunnelBridgeRail; break;
+			TileType tt = GetTileType(tile);
+
+			/* Check if there is any track on tile */
+			switch (tt) {
+				case MP_RAILWAY:
+					break;
+				case MP_STATION:
+					if (!IsRailwayStation(tile)) continue;
+					break;
+				case MP_ROAD:
+					if (!IsLevelCrossing(tile)) continue;
+					break;
+				case MP_TUNNELBRIDGE:
+					if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) continue;
+					break;
 				default: continue;
 			}
 
-			/* It is possible that 'type' is invalid when there is no rail on the tile,
-			 * but this situation will be detected in proc()
-			 */
+			/* Original railtype we are converting from */
 			RailType type = GetRailType(tile);
 
-			/* Not own tile or track is already converted */
-			if ((!CheckTileOwnership(tile) || type == totype) ||
-				/* 'hidden' elrails can't be downgraded to normal rail when elrails are disabled */
-				(_patches.disable_elrails && totype == RAILTYPE_RAIL && type == RAILTYPE_ELECTRIC) ||
-				/* Vehicle on a tile while not converting Rail <-> ElRail */
-				(!IsCompatibleRail(type, totype) && !EnsureNoVehicleOnGround(tile))) {
-					ret = CMD_ERROR;
-					continue;
+			/* Converting to the same type or converting 'hidden' elrail -> rail */
+			if (type == totype || (_patches.disable_elrails && totype == RAILTYPE_RAIL && type == RAILTYPE_ELECTRIC)) continue;
+
+			/* Trying to convert other's rail */
+			if (!CheckTileOwnership(tile)) continue;
+
+			/* Vehicle on the tile when not converting Rail <-> ElRail
+			 * Tunnels and bridges have special check later */
+			if (tt != MP_TUNNELBRIDGE) {
+				if (!IsCompatibleRail(type, totype) && !EnsureNoVehicleOnGround(tile)) continue;
+				if (flags & DC_EXEC) { // we can safely convert, too
+					SetRailType(tile, totype);
+					MarkTileDirtyByTile(tile);
+					/* update power of train engines on this tile */
+					VehicleFromPos(tile, NULL, &UpdateTrainPowerProc);
+				}
 			}
 
-			ret = proc(tile, totype, false);
-			if (CmdFailed(ret)) continue;
-
-			if (flags & DC_EXEC) {
-				money -= ret.GetCost();
-				if (money < 0) {
-					_additional_cash_required = ret.GetCost();
-					return cost;
-				}
-				proc(tile, totype, true);
+			switch (tt) {
+				case MP_RAILWAY:
+					switch (GetRailTileType(tile)) {
+						case RAIL_TILE_WAYPOINT:
+							if (flags & DC_EXEC) {
+								/* notify YAPF about the track layout change */
+								YapfNotifyTrackLayoutChange(tile, AxisToTrack(GetWaypointAxis(tile)));
+							}
+							cost.AddCost(RailConvertCost(type, totype));
+							break;
+
+						case RAIL_TILE_DEPOT:
+							if (flags & DC_EXEC) {
+								/* notify YAPF about the track layout change */
+								YapfNotifyTrackLayoutChange(tile, AxisToTrack(DiagDirToAxis(GetRailDepotDirection(tile))));
+
+								/* Update build vehicle window related to this depot */
+								InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
+								InvalidateWindowData(WC_BUILD_VEHICLE, tile);
+							}
+							cost.AddCost(RailConvertCost(type, totype));
+							break;
+
+						default: // RAIL_TILE_NORMAL, RAIL_TILE_SIGNALS
+							if (flags & DC_EXEC) {
+								/* notify YAPF about the track layout change */
+								TrackBits tracks = GetTrackBits(tile);
+								while (tracks != TRACK_BIT_NONE) {
+									YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
+								}
+							}
+							cost.AddCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile)));
+							break;
+					}
+					break;
+
+				case MP_TUNNELBRIDGE: {
+					TileIndex endtile = GetOtherTunnelBridgeEnd(tile);
+
+					/* If both ends of tunnel/bridge are in the range, do not try to convert twice -
+					 * it would cause assert because of different test and exec runs */
+					if (endtile < tile && TileX(endtile) >= sx && TileX(endtile) <= ex &&
+							TileY(endtile) >= sy && TileY(endtile) <= ey) continue;
+
+					/* When not coverting rail <-> el. rail, any vehicle cannot be in tunnel/bridge */
+					if (!IsCompatibleRail(GetRailType(tile), totype) &&
+							GetVehicleTunnelBridge(tile, endtile) != NULL) continue;
+
+					if (flags & DC_EXEC) {
+						SetRailType(tile, totype);
+						SetRailType(endtile, totype);
+
+						VehicleFromPos(tile, NULL, &UpdateTrainPowerProc);
+						VehicleFromPos(endtile, NULL, &UpdateTrainPowerProc);
+
+						Track track = AxisToTrack(DiagDirToAxis(GetTunnelBridgeDirection(tile)));
+
+						YapfNotifyTrackLayoutChange(tile, track);
+						YapfNotifyTrackLayoutChange(endtile, track);
+
+						MarkTileDirtyByTile(tile);
+						MarkTileDirtyByTile(endtile);
+
+						if (IsBridge(tile)) {
+							TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
+							TileIndex t = tile + delta;
+							for (; t != endtile; t += delta) MarkTileDirtyByTile(t); // TODO encapsulate this into a function
+						}
+					}
+
+					cost.AddCost((DistanceManhattan(tile, endtile) + 1) * RailConvertCost(type, totype));
+				} break;
+
+				default: // MP_STATION, MP_ROAD
+					if (flags & DC_EXEC) {
+						Track track = (tt == MP_STATION) ? GetRailStationTrack(tile) : AxisToTrack(OtherAxis(GetCrossingRoadAxis(tile)));
+						YapfNotifyTrackLayoutChange(tile, track);
+					}
+
+					cost.AddCost(RailConvertCost(type, totype));
+					break;
 			}
-			cost.AddCost(ret);
 		}
 	}
 
-	return (cost.GetCost() == 0) ? ret : cost;
+	return (cost.GetCost() == 0) ? CMD_ERROR : cost;
 }
 
 static CommandCost RemoveTrainDepot(TileIndex tile, uint32 flags)
@@ -1271,12 +1313,12 @@
 		YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir)));
 	}
 
-	return CommandCost(_price.remove_train_depot);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot);
 }
 
 static CommandCost ClearTile_Track(TileIndex tile, byte flags)
 {
-	CommandCost cost;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	CommandCost ret;
 
 	if (flags & DC_AUTO) {
@@ -1752,7 +1794,7 @@
 				image += relocation;
 			}
 
-			if (!IsTransparencySet(TO_BUILDINGS) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
+			if (!(!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
 				pal = _drawtile_track_palette;
 			} else {
 				pal = dtss->pal;
@@ -1764,7 +1806,7 @@
 					ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 					dtss->size_x, dtss->size_y,
 					dtss->size_z, ti->z + dtss->delta_z,
-					IsTransparencySet(TO_BUILDINGS)
+					!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)
 				);
 			} else {
 				AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
@@ -1862,23 +1904,14 @@
 	return false;
 }
 
-/* Struct to parse data from VehicleFromPos to SignalVehicleCheckProc */
-struct SignalVehicleCheckStruct {
-	TileIndex tile;
-	uint track;
-};
-
 static void *SignalVehicleCheckProc(Vehicle *v, void *data)
 {
-	const SignalVehicleCheckStruct* dest = (SignalVehicleCheckStruct*)data;
+	uint track = *(uint*)data;
 
 	if (v->type != VEH_TRAIN) return NULL;
 
-	/* Wrong tile, or no train? Not a match */
-	if (v->tile != dest->tile) return NULL;
-
 	/* Are we on the same piece of track? */
-	if (dest->track & v->u.rail.track * 0x101) return v;
+	if (track & v->u.rail.track * 0x101) return v;
 
 	return NULL;
 }
@@ -1886,42 +1919,12 @@
 /* Special check for SetSignalsAfterProc, to see if there is a vehicle on this tile */
 static bool SignalVehicleCheck(TileIndex tile, uint track)
 {
-	SignalVehicleCheckStruct dest;
-
-	dest.tile = tile;
-	dest.track = track;
-
-	/* Locate vehicles in tunnels or on bridges */
-	if (IsTunnelTile(tile) || IsBridgeTile(tile)) {
-		TileIndex end;
-		DiagDirection direction;
-
-		if (IsTunnelTile(tile)) {
-			end = GetOtherTunnelEnd(tile);
-			direction = GetTunnelDirection(tile);
-		} else {
-			end = GetOtherBridgeEnd(tile);
-			direction = GetBridgeRampDirection(tile);
-		}
-
-		dest.track = 1 << (direction & 1); // get the trackbit the vehicle would have if it has not entered the tunnel yet (ie is still visible)
-
-		/* check for a vehicle with that trackdir on the start tile of the tunnel */
-		if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
-
-		/* check for a vehicle with that trackdir on the end tile of the tunnel */
-		if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
-
-		/* now check all tiles from start to end for a warping vehicle */
-		dest.track = 0x40;   //Vehicle inside a tunnel or on a bridge
-		if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
-		if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
-
-		/* no vehicle found */
-		return false;
+	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
+		/* Locate vehicles in tunnels or on bridges */
+		return GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL;
+	} else {
+		return VehicleFromPos(tile, &track, &SignalVehicleCheckProc) != NULL;
 	}
-
-	return VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL;
 }
 
 static void SetSignalsAfterProc(TrackPathFinder *tpf)
@@ -2329,7 +2332,7 @@
 	 0,  1,  0, -1  /* y */
 };
 
-static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
+static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
 {
 	byte fract_coord;
 	byte fract_coord_leave;
@@ -2412,7 +2415,7 @@
 		case TRACK_BIT_UPPER: track_corner = CORNER_N; break;
 
 		/* Surface slope must not be changed */
-		default: return (((z_old != z_new) || (tileh_old != tileh_new)) ? CMD_ERROR : _price.terraform);
+		default: return (((z_old != z_new) || (tileh_old != tileh_new)) ? CMD_ERROR : CommandCost(EXPENSES_CONSTRUCTION, _price.terraform));
 	}
 
 	/* The height of the track_corner must not be changed. The rest ensures GetRailFoundation() already. */
@@ -2420,7 +2423,7 @@
 	z_new += GetSlopeZInCorner((Slope)(tileh_new & ~SLOPE_HALFTILE_MASK), track_corner);
 	if (z_old != z_new) return CMD_ERROR;
 
-	CommandCost cost = CommandCost(_price.terraform);
+	CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 	/* Make the ground dirty, if surface slope has changed */
 	if (tileh_old != tileh_new) {
 		if (GetRailGroundType(tile) == RAIL_GROUND_WATER) cost.AddCost(_price.clear_water);
@@ -2467,7 +2470,7 @@
 		if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
 
 		/* allow terraforming */
-		return (was_water ? CommandCost(_price.clear_water) : CommandCost());
+		return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price.clear_water : (Money)0);
 	} else {
 		if (_patches.build_on_slopes && AutoslopeEnabled()) {
 			switch (GetRailTileType(tile)) {
@@ -2478,7 +2481,7 @@
 				}
 
 				case RAIL_TILE_DEPOT:
-					if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRailDepotDirection(tile))) return _price.terraform;
+					if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRailDepotDirection(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 					break;
 
 				default: NOT_REACHED();
--- a/src/rail_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/rail_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,19 +6,15 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "date.h"
-#include "map.h"
-#include "tile.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
-#include "sound.h"
-#include "command.h"
-#include "vehicle.h"
+#include "window_gui.h"
+#include "station_gui.h"
+#include "terraform_gui.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
+#include "command_func.h"
 #include "station.h"
 #include "waypoint.h"
 #include "debug.h"
@@ -26,18 +22,28 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_station.h"
 #include "train.h"
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "sound_func.h"
 
 #include "bridge_map.h"
 #include "rail_map.h"
 #include "road_map.h"
 #include "station_map.h"
 #include "tunnel_map.h"
+#include "tunnelbridge_map.h"
+
 
 static RailType _cur_railtype;
 static bool _remove_button_clicked;
 static DiagDirection _build_depot_direction;
 static byte _waypoint_count = 1;
 static byte _cur_waypoint_type;
+static bool _convert_signal_button; // convert signal button in the signal GUI pressed
+static SignalVariant _cur_signal_variant; // set the signal variant (for signal GUI)
+static SignalType _cur_signal_type; // set the signal type (for signal GUI)
 
 static struct {
 	byte orientation;
@@ -56,6 +62,7 @@
 static void ShowBuildTrainDepotPicker();
 static void ShowBuildWaypointPicker();
 static void ShowStationBuilder();
+static void ShowSignalBuilder();
 
 void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
@@ -65,7 +72,7 @@
 static void GenericPlaceRail(TileIndex tile, int cmd)
 {
 	DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E,
-		_remove_button_clicked ?
+		(_remove_button_clicked || _ctrl_pressed) ?
 		CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_NO_WATER :
 		CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_NO_WATER
 	);
@@ -139,10 +146,10 @@
 
 static void PlaceRail_Waypoint(TileIndex tile)
 {
-	if (!_remove_button_clicked) {
+	if (_remove_button_clicked || _ctrl_pressed) {
+		DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT));
+	} else {
 		DoCommandP(tile, _cur_waypoint_type, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT));
-	} else {
-		DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT));
 	}
 }
 
@@ -170,6 +177,11 @@
 	}
 }
 
+/**
+ * Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp
+ *
+ * @param tile The tile where the signal will build or edit
+ */
 static void GenericPlaceSignals(TileIndex tile)
 {
 	TrackBits trackbits = (TrackBits)GB(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0), 0, 6);
@@ -184,16 +196,21 @@
 
 	Track track = FindFirstTrack(trackbits);
 
-	if (!_remove_button_clicked) {
+	if (_remove_button_clicked) {
+		DoCommandP(tile, track, 0, CcPlaySound1E,
+			CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
+	} else {
+		if (!_patches.enable_signal_gui) _cur_signal_variant = _cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
+
+		/* various bitstuffed elements for CmdBuildSingleSignal() */
 		uint32 p1 = track;
 		SB(p1, 3, 1, _ctrl_pressed);
-		SB(p1, 4, 1, _cur_year < _patches.semaphore_build_before);
+		SB(p1, 4, 1, _cur_signal_variant);
+		SB(p1, 5, 2, _patches.enable_signal_gui ? _cur_signal_type : SIGTYPE_NORMAL);
+		SB(p1, 7, 1, _convert_signal_button);
 
-		DoCommandP(tile, p1, 0, CcPlaySound1E,
-			CMD_BUILD_SIGNALS | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE));
-	} else {
-		DoCommandP(tile, track, 0, CcPlaySound1E,
-			CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
+		DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS |
+			CMD_MSG(_convert_signal_button ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE));
 	}
 }
 
@@ -307,9 +324,14 @@
 	if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder();
 }
 
+/** The "build signal"-button proc from BuildRailToolbWndProc() (start ShowSignalBuilder() and/or HandleAutoSignalPlacement()) */
 static void BuildRailClick_AutoSignals(Window *w)
 {
-	HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
+	if (_patches.enable_signal_gui) {
+		if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder();
+	} else {
+		HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
+	}
 }
 
 static void BuildRailClick_Bridge(Window *w)
@@ -324,12 +346,12 @@
 
 static void BuildRailClick_Remove(Window *w)
 {
-	if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return;
+	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
 	SetWindowDirty(w);
 	SndPlayFx(SND_15_BEEP);
 
-	ToggleWidgetLoweredState(w, RTW_REMOVE);
-	_remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE);
+	w->ToggleWidgetLoweredState(RTW_REMOVE);
+	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
 	SetSelectionRed(_remove_button_clicked);
 
 	// handle station builder
@@ -347,7 +369,7 @@
 static void DoRailroadTrack(int mode)
 {
 	DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL,
-		_remove_button_clicked ?
+		(_remove_button_clicked || _ctrl_pressed) ?
 		CMD_REMOVE_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) :
 		CMD_BUILD_RAILROAD_TRACK  | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK)
 	);
@@ -366,6 +388,12 @@
 	DoRailroadTrack(trackstat);
 }
 
+/**
+ * Build new signals or remove signals or (if only one tile marked) edit a signal.
+ *
+ * If one tile marked abort and use GenericPlaceSignals()
+ * else use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp to build many signals
+ */
 static void HandleAutoSignalPlacement()
 {
 	TileHighlightData *thd = &_thd;
@@ -451,22 +479,28 @@
 		case RTW_BUILD_SIGNALS:
 			/* Removal button is enabled only if the rail/signal/waypoint/station
 			 * button is still lowered.  Once raised, it has to be disabled */
-			SetWindowWidgetDisabledState(w, RTW_REMOVE, !IsWindowWidgetLowered(w, clicked_widget));
+			w->SetWidgetDisabledState(RTW_REMOVE, !w->IsWidgetLowered(clicked_widget));
 			break;
 
 		default:
 			/* When any other buttons than rail/signal/waypoint/station, raise and
 			 * disable the removal button */
-			DisableWindowWidget(w, RTW_REMOVE);
-			RaiseWindowWidget(w, RTW_REMOVE);
+			w->DisableWidget(RTW_REMOVE);
+			w->RaiseWidget(RTW_REMOVE);
 			break;
 	}
 }
 
+/**
+ * Railway toolbar window event definition
+ *
+ * @param w window pointer
+ * @param e event been triggered
+ */
 static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-	case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break;
+	case WE_CREATE: w->DisableWidget(RTW_REMOVE); break;
 
 	case WE_PAINT: DrawWindowWidgets(w); break;
 
@@ -496,6 +530,9 @@
 		return;
 
 	case WE_PLACE_DRAG: {
+		/* no dragging if you have pressed the convert button */
+		if (_convert_signal_button && w->IsWidgetLowered(RTW_BUILD_SIGNALS)) return;
+
 		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
 		return;
 	}
@@ -511,12 +548,9 @@
 					ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
 					break;
 
-				case DDSP_PLACE_AUTORAIL: {
-					bool old = _remove_button_clicked;
-					if (_ctrl_pressed) _remove_button_clicked = true;
+				case DDSP_PLACE_AUTORAIL:
 					HandleAutodirPlacement();
-					_remove_button_clicked = old;
-				} break;
+					break;
 
 				case DDSP_BUILD_SIGNALS:
 					HandleAutoSignalPlacement();
@@ -539,25 +573,24 @@
 					break;
 
 				case DDSP_PLACE_RAIL_NE:
-				case DDSP_PLACE_RAIL_NW: {
-					bool old = _remove_button_clicked;
-					if (_ctrl_pressed) _remove_button_clicked = true;
+				case DDSP_PLACE_RAIL_NW:
 					DoRailroadTrack(e->we.place.select_proc == DDSP_PLACE_RAIL_NE ? TRACK_X : TRACK_Y);
-					_remove_button_clicked = old;
-				} break;
+					break;
 			}
 		}
 		break;
 
 	case WE_ABORT_PLACE_OBJ:
-		RaiseWindowButtons(w);
-		DisableWindowWidget(w, RTW_REMOVE);
-		InvalidateWidget(w, RTW_REMOVE);
+		w->RaiseButtons();
+		w->DisableWidget(RTW_REMOVE);
+		w->InvalidateWidget(RTW_REMOVE);
 
+		w = FindWindowById(WC_BUILD_SIGNAL, 0);
+		if (w != NULL) WP(w, def_d).close = true;
 		w = FindWindowById(WC_BUILD_STATION, 0);
-		if (w != NULL) WP(w,def_d).close = true;
+		if (w != NULL) WP(w, def_d).close = true;
 		w = FindWindowById(WC_BUILD_DEPOT, 0);
-		if (w != NULL) WP(w,def_d).close = true;
+		if (w != NULL) WP(w, def_d).close = true;
 		break;
 
 	case WE_PLACE_PRESIZE: {
@@ -720,21 +753,21 @@
 	if (statspec == NULL || _railstation.dragdrop) return;
 
 	if (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
-		RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
+		w->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
 		_railstation.numtracks = 1;
 		while (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
 			_railstation.numtracks++;
 		}
-		LowerWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
+		w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
 	}
 
 	if (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
-		RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
+		w->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 		_railstation.platlength = 1;
 		while (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
 			_railstation.platlength++;
 		}
-		LowerWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
+		w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 	}
 }
 
@@ -742,15 +775,15 @@
 {
 	switch (e->event) {
 	case WE_CREATE:
-		LowerWindowWidget(w, _railstation.orientation + BRSW_PLATFORM_DIR_X);
+		w->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
 		if (_railstation.dragdrop) {
-			LowerWindowWidget(w, BRSW_PLATFORM_DRAG_N_DROP);
+			w->LowerWidget(BRSW_PLATFORM_DRAG_N_DROP);
 		} else {
-			LowerWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
-			LowerWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
+			w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
+			w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 		}
-		SetWindowWidgetLoweredState(w, BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
-		SetWindowWidgetLoweredState(w, BRSW_HIGHLIGHT_ON, _station_show_coverage);
+		w->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
+		w->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage);
 		break;
 
 	case WE_PAINT: {
@@ -758,7 +791,7 @@
 		DrawPixelInfo tmp_dpi, *old_dpi;
 		const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
 
-		if (WP(w,def_d).close) return;
+		if (WP(w, def_d).close) return;
 
 		if (_railstation.dragdrop) {
 			SetTileSelectSize(1, 1);
@@ -778,11 +811,11 @@
 		for (uint bits = 0; bits < 7; bits++) {
 			bool disable = bits >= _patches.station_spread;
 			if (statspec == NULL) {
-				SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_NUM_1, disable);
-				SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_LEN_1, disable);
+				w->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, disable);
+				w->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, disable);
 			} else {
-				SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
-				SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths,   bits) || disable);
+				w->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
+				w->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths,   bits) || disable);
 			}
 		}
 
@@ -843,9 +876,9 @@
 		switch (e->we.click.widget) {
 		case BRSW_PLATFORM_DIR_X:
 		case BRSW_PLATFORM_DIR_Y:
-			RaiseWindowWidget(w, _railstation.orientation + BRSW_PLATFORM_DIR_X);
+			w->RaiseWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
 			_railstation.orientation = e->we.click.widget - BRSW_PLATFORM_DIR_X;
-			LowerWindowWidget(w, _railstation.orientation + BRSW_PLATFORM_DIR_X);
+			w->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
 			SndPlayFx(SND_15_BEEP);
 			SetWindowDirty(w);
 			break;
@@ -857,8 +890,8 @@
 		case BRSW_PLATFORM_NUM_5:
 		case BRSW_PLATFORM_NUM_6:
 		case BRSW_PLATFORM_NUM_7: {
-			RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
-			RaiseWindowWidget(w, BRSW_PLATFORM_DRAG_N_DROP);
+			w->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
+			w->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP);
 
 			_railstation.numtracks = e->we.click.widget - BRSW_PLATFORM_NUM_BEGIN;
 			_railstation.dragdrop = false;
@@ -868,15 +901,15 @@
 				/* The previously selected number of platforms in invalid */
 				for (uint i = 0; i < 7; i++) {
 					if (!HasBit(statspec->disallowed_lengths, i)) {
-						RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
+						w->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 						_railstation.platlength = i + 1;
 						break;
 					}
 				}
 			}
 
-			LowerWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
-			LowerWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
+			w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
+			w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 			SndPlayFx(SND_15_BEEP);
 			SetWindowDirty(w);
 			break;
@@ -889,8 +922,8 @@
 		case BRSW_PLATFORM_LEN_5:
 		case BRSW_PLATFORM_LEN_6:
 		case BRSW_PLATFORM_LEN_7: {
-			RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
-			RaiseWindowWidget(w, BRSW_PLATFORM_DRAG_N_DROP);
+			w->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
+			w->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP);
 
 			_railstation.platlength = e->we.click.widget - BRSW_PLATFORM_LEN_BEGIN;
 			_railstation.dragdrop = false;
@@ -900,15 +933,15 @@
 				/* The previously selected number of tracks in invalid */
 				for (uint i = 0; i < 7; i++) {
 					if (!HasBit(statspec->disallowed_platforms, i)) {
-						RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
+						w->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
 						_railstation.numtracks = i + 1;
 						break;
 					}
 				}
 			}
 
-			LowerWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
-			LowerWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
+			w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
+			w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 			SndPlayFx(SND_15_BEEP);
 			SetWindowDirty(w);
 			break;
@@ -916,14 +949,14 @@
 
 		case BRSW_PLATFORM_DRAG_N_DROP: {
 			_railstation.dragdrop ^= true;
-			ToggleWidgetLoweredState(w, BRSW_PLATFORM_DRAG_N_DROP);
+			w->ToggleWidgetLoweredState(BRSW_PLATFORM_DRAG_N_DROP);
 
 			/* get the first allowed length/number of platforms */
 			const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
 			if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
 				for (uint i = 0; i < 7; i++) {
 					if (!HasBit(statspec->disallowed_lengths, i)) {
-						RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
+						w->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 						_railstation.platlength = i + 1;
 						break;
 					}
@@ -932,15 +965,15 @@
 			if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
 				for (uint i = 0; i < 7; i++) {
 					if (!HasBit(statspec->disallowed_platforms, i)) {
-						RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
+						w->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
 						_railstation.numtracks = i + 1;
 						break;
 					}
 				}
 			}
 
-			SetWindowWidgetLoweredState(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN, !_railstation.dragdrop);
-			SetWindowWidgetLoweredState(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN, !_railstation.dragdrop);
+			w->SetWidgetLoweredState(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN, !_railstation.dragdrop);
+			w->SetWidgetLoweredState(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN, !_railstation.dragdrop);
 			SndPlayFx(SND_15_BEEP);
 			SetWindowDirty(w);
 		} break;
@@ -948,8 +981,8 @@
 		case BRSW_HIGHLIGHT_OFF:
 		case BRSW_HIGHLIGHT_ON:
 			_station_show_coverage = (e->we.click.widget != BRSW_HIGHLIGHT_OFF);
-			SetWindowWidgetLoweredState(w, BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
-			SetWindowWidgetLoweredState(w, BRSW_HIGHLIGHT_ON, _station_show_coverage);
+			w->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
+			w->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage);
 			SndPlayFx(SND_15_BEEP);
 			SetWindowDirty(w);
 			break;
@@ -1001,7 +1034,7 @@
 		break;
 
 	case WE_MOUSELOOP:
-		if (WP(w,def_d).close) {
+		if (WP(w, def_d).close) {
 			DeleteWindow(w);
 			return;
 		}
@@ -1009,7 +1042,7 @@
 		break;
 
 	case WE_DESTROY:
-		if (!WP(w,def_d).close) ResetObjectToPlace();
+		if (!WP(w, def_d).close) ResetObjectToPlace();
 		break;
 	}
 }
@@ -1113,6 +1146,166 @@
 	}
 }
 
+/** Enum referring to the widgets of the signal window */
+enum BuildSignalWidgets {
+	BSW_CLOSEBOX = 0,
+	BSW_CAPTION,
+	BSW_SEMAPHORE_NORM,
+	BSW_SEMAPHORE_ENTRY,
+	BSW_SEMAPHORE_EXIT,
+	BSW_SEMAPHORE_COMBO,
+	BSW_ELECTRIC_NORM,
+	BSW_ELECTRIC_ENTRY,
+	BSW_ELECTRIC_EXIT,
+	BSW_ELECTRIC_COMBO,
+	BSW_CONVERT,
+	BSW_DRAG_SIGNALS_DENSITY,
+	BSW_DRAG_SIGNALS_DENSITY_DECREASE,
+	BSW_DRAG_SIGNALS_DENSITY_INCREASE,
+};
+
+/**
+ * Draw dynamic a signal-sprite in a button in the signal GUI
+ * Draw the sprite +1px to the right and down if the button is lowered and change the sprite to sprite + 1 (red to green light)
+ *
+ * @param w            Window on which the widget is located
+ * @param widget_index index of this widget in the window
+ * @param image        the sprite to draw
+ * @param xrel         the relativ x value of the sprite in the grf
+ * @param xsize        the width of the sprite
+ */
+static void DrawSignalSprite(const Window *w, byte widget_index, SpriteID image, int8 xrel, uint8 xsize)
+{
+	DrawSprite(image + w->IsWidgetLowered(widget_index), PAL_NONE,
+			w->widget[widget_index].left + (w->widget[widget_index].right - w->widget[widget_index].left) / 2 - xrel - xsize / 2 +
+			w->IsWidgetLowered(widget_index), w->widget[widget_index].bottom - 3 + w->IsWidgetLowered(widget_index));
+}
+
+/**
+ * Signal selection window event definition
+ *
+ * @param w window pointer
+ * @param e event been triggered
+ */
+static void SignalBuildWndProc(Window *w, WindowEvent *e)
+{
+	switch (e->event) {
+		case WE_PAINT:
+			w->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
+
+			w->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
+
+			w->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _patches.drag_signals_density == 1);
+			w->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _patches.drag_signals_density == 20);
+
+			DrawWindowWidgets(w);
+
+			/* The 'hardcoded' off sets are needed because they are reused sprites. */
+			DrawSignalSprite(w, BSW_SEMAPHORE_NORM,  SPR_IMG_SIGNAL_SEMAPHORE_NORM,   0, 12); // xsize of sprite + 1 ==  9
+			DrawSignalSprite(w, BSW_SEMAPHORE_ENTRY, SPR_IMG_SIGNAL_SEMAPHORE_ENTRY, -1, 13); // xsize of sprite + 1 == 10
+			DrawSignalSprite(w, BSW_SEMAPHORE_EXIT,  SPR_IMG_SIGNAL_SEMAPHORE_EXIT,   0, 12); // xsize of sprite + 1 ==  9
+			DrawSignalSprite(w, BSW_SEMAPHORE_COMBO, SPR_IMG_SIGNAL_SEMAPHORE_COMBO,  0, 12); // xsize of sprite + 1 ==  9
+			DrawSignalSprite(w, BSW_ELECTRIC_NORM,   SPR_IMG_SIGNAL_ELECTRIC_NORM,   -1,  4);
+			DrawSignalSprite(w, BSW_ELECTRIC_ENTRY,  SPR_IMG_SIGNAL_ELECTRIC_ENTRY,  -2,  6);
+			DrawSignalSprite(w, BSW_ELECTRIC_EXIT,   SPR_IMG_SIGNAL_ELECTRIC_EXIT,   -2,  6);
+			DrawSignalSprite(w, BSW_ELECTRIC_COMBO,  SPR_IMG_SIGNAL_ELECTRIC_COMBO,  -2,  6);
+
+			/* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */
+			SetDParam(0, _patches.drag_signals_density);
+			DrawStringCentered(w->widget[BSW_DRAG_SIGNALS_DENSITY].left + (w->widget[BSW_DRAG_SIGNALS_DENSITY].right -
+					w->widget[BSW_DRAG_SIGNALS_DENSITY].left) / 2 + 1,
+					w->widget[BSW_DRAG_SIGNALS_DENSITY].top + 2, STR_JUST_INT, TC_ORANGE);
+			break;
+
+		case WE_CLICK:
+			switch (e->we.click.widget) {
+				case BSW_SEMAPHORE_NORM:
+				case BSW_SEMAPHORE_ENTRY:
+				case BSW_SEMAPHORE_EXIT:
+				case BSW_SEMAPHORE_COMBO:
+				case BSW_ELECTRIC_NORM:
+				case BSW_ELECTRIC_ENTRY:
+				case BSW_ELECTRIC_EXIT:
+				case BSW_ELECTRIC_COMBO:
+					w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
+
+					_cur_signal_type = (SignalType)((uint)((e->we.click.widget - BSW_SEMAPHORE_NORM) % (SIGTYPE_COMBO + 1)));
+					_cur_signal_variant = e->we.click.widget >= BSW_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE;
+					break;
+
+				case BSW_CONVERT:
+					_convert_signal_button = !_convert_signal_button;
+					break;
+
+				case BSW_DRAG_SIGNALS_DENSITY_DECREASE:
+					if (_patches.drag_signals_density > 1) _patches.drag_signals_density--;
+					break;
+
+				case BSW_DRAG_SIGNALS_DENSITY_INCREASE:
+					if (_patches.drag_signals_density < 20) _patches.drag_signals_density++;
+					break;
+
+				default: break;
+			}
+
+			SetWindowDirty(w);
+			break;
+
+		case WE_MOUSELOOP:
+			if (WP(w, def_d).close) DeleteWindow(w);
+			return;
+
+		case WE_DESTROY:
+			if (!WP(w, def_d).close) ResetObjectToPlace();
+			break;
+		}
+}
+
+/** Widget definition of the build signal window */
+static const Widget _signal_builder_widgets[] = {
+{   WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,               STR_018B_CLOSE_WINDOW},                 // BSW_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_NONE,  7,  11, 109,   0,  13, STR_SIGNAL_SELECTION,   STR_018C_WINDOW_TITLE_DRAG_THIS},       // BSW_CAPTION
+
+{      WWT_PANEL,   RESIZE_NONE,  7,   0,  21,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP},   // BSW_SEMAPHORE_NORM
+{      WWT_PANEL,   RESIZE_NONE,  7,  22,  43,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP},  // BSW_SEMAPHORE_ENTRY
+{      WWT_PANEL,   RESIZE_NONE,  7,  44,  65,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP},   // BSW_SEMAPHORE_EXIT
+{      WWT_PANEL,   RESIZE_NONE,  7,  66,  87,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP},  // BSW_SEMAPHORE_COMBO
+
+{      WWT_PANEL,   RESIZE_NONE,  7,   0,  21,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP},    // BSW_ELECTRIC_NORM
+{      WWT_PANEL,   RESIZE_NONE,  7,  22,  43,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP},   // BSW_ELECTRIC_ENTRY
+{      WWT_PANEL,   RESIZE_NONE,  7,  44,  65,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP},    // BSW_ELECTRIC_EXIT
+{      WWT_PANEL,   RESIZE_NONE,  7,  66,  87,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP},   // BSW_ELECTRIC_COMBO
+
+{     WWT_IMGBTN,   RESIZE_NONE,  7,  88, 109,  14,  40, SPR_IMG_SIGNAL_CONVERT, STR_SIGNAL_CONVERT_TIP},                // BSW_CONVERT
+{      WWT_PANEL,   RESIZE_NONE,  7,  88, 109,  41,  67, STR_NULL,               STR_DRAG_SIGNALS_DENSITY_TIP},          // BSW_DRAG_SIGNALS_DENSITY
+{ WWT_PUSHIMGBTN,   RESIZE_NONE, 14,  90,  98,  54,  65, SPR_ARROW_LEFT,         STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP}, // BSW_DRAG_SIGNALS_DENSITY_DECREASE
+{ WWT_PUSHIMGBTN,   RESIZE_NONE, 14,  99, 107,  54,  65, SPR_ARROW_RIGHT,        STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP}, // BSW_DRAG_SIGNALS_DENSITY_INCREASE
+
+{   WIDGETS_END},
+};
+
+/** Signal selection window description */
+static const WindowDesc _signal_builder_desc = {
+	WDP_AUTO, WDP_AUTO, 110, 68, 110, 68,
+	WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
+	_signal_builder_widgets,
+	SignalBuildWndProc
+};
+
+/**
+ * Open the signal selection window
+ * @pre reset all signal GUI relevant variables
+ */
+static void ShowSignalBuilder()
+{
+	_convert_signal_button = false;
+	_cur_signal_variant = _cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
+	_cur_signal_type = SIGTYPE_NORMAL;
+
+	AllocateWindowDesc(&_signal_builder_desc);
+}
+
 /** Enum referring to the widgets of the build rail depot window */
 enum BuildRailDepotWidgets {
 	BRDW_CLOSEBOX = 0,
@@ -1127,7 +1320,7 @@
 static void BuildTrainDepotWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-	case WE_CREATE: LowerWindowWidget(w, _build_depot_direction + BRDW_DEPOT_NE); break;
+	case WE_CREATE: w->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE); break;
 
 	case WE_PAINT: {
 		DrawWindowWidgets(w);
@@ -1145,9 +1338,9 @@
 			case BRDW_DEPOT_SE:
 			case BRDW_DEPOT_SW:
 			case BRDW_DEPOT_NW:
-				RaiseWindowWidget(w, _build_depot_direction + BRDW_DEPOT_NE);
+				w->RaiseWidget(_build_depot_direction + BRDW_DEPOT_NE);
 				_build_depot_direction = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE);
-				LowerWindowWidget(w, _build_depot_direction + BRDW_DEPOT_NE);
+				w->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE);
 				SndPlayFx(SND_15_BEEP);
 				SetWindowDirty(w);
 				break;
@@ -1155,11 +1348,11 @@
 		break;
 
 	case WE_MOUSELOOP:
-		if (WP(w,def_d).close) DeleteWindow(w);
+		if (WP(w, def_d).close) DeleteWindow(w);
 		return;
 
 	case WE_DESTROY:
-		if (!WP(w,def_d).close) ResetObjectToPlace();
+		if (!WP(w, def_d).close) ResetObjectToPlace();
 		break;
 	}
 }
@@ -1209,7 +1402,7 @@
 		uint i;
 
 		for (i = 0; i < w->hscroll.cap; i++) {
-			SetWindowWidgetLoweredState(w, i + BRWW_WAYPOINT_1, (w->hscroll.pos + i) == _cur_waypoint_type);
+			w->SetWidgetLoweredState(i + BRWW_WAYPOINT_1, (w->hscroll.pos + i) == _cur_waypoint_type);
 		}
 
 		DrawWindowWidgets(w);
@@ -1254,11 +1447,11 @@
 	}
 
 	case WE_MOUSELOOP:
-		if (WP(w,def_d).close) DeleteWindow(w);
+		if (WP(w, def_d).close) DeleteWindow(w);
 		break;
 
 	case WE_DESTROY:
-		if (!WP(w,def_d).close) ResetObjectToPlace();
+		if (!WP(w, def_d).close) ResetObjectToPlace();
 		break;
 	}
 }
@@ -1330,12 +1523,8 @@
 			RailType count[RAILTYPE_END];
 			memset(count, 0, sizeof(count));
 			for (TileIndex t = 0; t < MapSize(); t++) {
-				if (IsTileType(t, MP_RAILWAY) ||
-						IsLevelCrossingTile(t) ||
-						IsRailwayStationTile(t) ||
-						(IsTunnelTile(t) && GetTunnelTransportType(t) == TRANSPORT_RAIL) ||
-						(IsBridgeTile(t) && GetBridgeTransportType(t) == TRANSPORT_RAIL)
-						) {
+				if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || IsRailwayStationTile(t) ||
+						(IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
 					count[GetRailType(t)]++;
 				}
 			}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/rail_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,13 @@
+/* $Id$ */
+
+/** @file rail_gui.h Functions/types etc. related to the rail GUI. */
+
+#ifndef RAIL_GUI_H
+#define RAIL_GUI_H
+
+#include "rail_type.h"
+
+void ShowBuildRailToolbar(RailType railtype, int button);
+void ReinitGuiAfterToggleElrail(bool disable);
+
+#endif /* RAIL_GUI_H */
--- a/src/rail_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/rail_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,9 +5,11 @@
 #ifndef RAIL_MAP_H
 #define RAIL_MAP_H
 
-#include "direction.h"
-#include "rail.h"
-#include "tile.h"
+#include "rail_type.h"
+#include "signal_func.h"
+#include "direction_func.h"
+#include "track_func.h"
+#include "tile_map.h"
 
 
 /** Different types of Rail-related tiles */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/rail_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,31 @@
+/* $Id$ */
+
+/** @file rail_type.h The different types of rail */
+
+#ifndef RAIL_TYPE_H
+#define RAIL_TYPE_H
+
+/**
+ * Enumeration for all possible railtypes.
+ *
+ * This enumeration defines all 4 possible railtypes.
+ */
+enum RailType {
+	RAILTYPE_BEGIN    = 0,          ///< Used for iterations
+	RAILTYPE_RAIL     = 0,          ///< Standard non-electric rails
+	RAILTYPE_ELECTRIC = 1,          ///< Electric rails
+	RAILTYPE_MONO     = 2,          ///< Monorail
+	RAILTYPE_MAGLEV   = 3,          ///< Maglev
+	RAILTYPE_END,                   ///< Used for iterations
+	INVALID_RAILTYPE  = 0xFF        ///< Flag for invalid railtype
+};
+
+typedef byte RailTypeMask;
+
+/** Allow incrementing of Track variables */
+DECLARE_POSTFIX_INCREMENT(RailType);
+/** Define basic enum properties */
+template <> struct EnumPropsT<RailType> : MakeEnumPropsT<RailType, byte, RAILTYPE_BEGIN, RAILTYPE_END, INVALID_RAILTYPE> {};
+typedef TinyEnumT<RailType> RailTypeByte;
+
+#endif /* RAIL_TYPE_H */
--- a/src/railtypes.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,214 +0,0 @@
-/* $Id$ */
-
-/** @file railtypes.h
- * All the railtype-specific information is stored here.
- */
-
-#ifndef RAILTYPES_H
-#define RAILTYPES_H
-
-/** Global Railtype definition
- */
-RailtypeInfo _railtypes[] = {
-	/** Railway */
-	{ /* Main Sprites */
-		{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,
-			SPR_RAIL_SINGLE_NORTH, SPR_RAIL_SINGLE_SOUTH, SPR_RAIL_SINGLE_EAST, SPR_RAIL_SINGLE_WEST,
-			SPR_CROSSING_OFF_X_RAIL,
-			SPR_TUNNEL_ENTRY_REAR_RAIL
-		},
-
-		/* GUI sprites */
-		{ 0x4E3, 0x4E4, 0x4E5, 0x4E6,
-			SPR_IMG_AUTORAIL,
-			SPR_IMG_DEPOT_RAIL,
-			SPR_IMG_TUNNEL_RAIL,
-			SPR_IMG_CONVERT_RAIL
-		},
-
-		{
-			SPR_CURSOR_NS_TRACK,
-			SPR_CURSOR_SWNE_TRACK,
-			SPR_CURSOR_EW_TRACK,
-			SPR_CURSOR_NWSE_TRACK,
-			SPR_CURSOR_AUTORAIL,
-			SPR_CURSOR_RAIL_DEPOT,
-			SPR_CURSOR_TUNNEL_RAIL,
-			SPR_CURSOR_CONVERT_RAIL
-		},
-
-		/* strings */
-		{ STR_100A_RAILROAD_CONSTRUCTION },
-
-		/* Offset of snow tiles */
-		SPR_RAIL_SNOW_OFFSET,
-
-		/* Powered railtypes */
-		1 << RAILTYPE_RAIL | 1 << RAILTYPE_ELECTRIC,
-
-		/* Compatible railtypes */
-		1 << RAILTYPE_RAIL | 1 << RAILTYPE_ELECTRIC,
-
-		/* main offset */
-		0,
-
-		/* bridge offset */
-		0,
-
-		/* custom ground offset */
-		0,
-	},
-
-	/** Electrified railway */
-	{ /* Main Sprites */
-		{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,
-			SPR_RAIL_SINGLE_NORTH, SPR_RAIL_SINGLE_SOUTH, SPR_RAIL_SINGLE_EAST, SPR_RAIL_SINGLE_WEST,
-			SPR_CROSSING_OFF_X_RAIL,
-			SPR_TUNNEL_ENTRY_REAR_RAIL
-		},
-
-		/* GUI sprites */
-		{
-			SPR_BUILD_NS_ELRAIL,
-			SPR_BUILD_X_ELRAIL,
-			SPR_BUILD_EW_ELRAIL,
-			SPR_BUILD_Y_ELRAIL,
-			SPR_IMG_AUTOELRAIL,
-			SPR_IMG_DEPOT_ELRAIL,
-			SPR_BUILD_TUNNEL_ELRAIL,
-			SPR_IMG_CONVERT_ELRAIL
-		},
-
-		{
-			SPR_CURSOR_NS_ELRAIL,
-			SPR_CURSOR_SWNE_ELRAIL,
-			SPR_CURSOR_EW_ELRAIL,
-			SPR_CURSOR_NWSE_ELRAIL,
-			SPR_CURSOR_AUTOELRAIL,
-			SPR_CURSOR_ELRAIL_DEPOT,
-			SPR_CURSOR_TUNNEL_ELRAIL,
-			SPR_CURSOR_CONVERT_ELRAIL
-		},
-
-		/* strings */
-		{ STR_TITLE_ELRAIL_CONSTRUCTION },
-
-		/* Offset of snow tiles */
-		SPR_RAIL_SNOW_OFFSET,
-
-		/* Powered railtypes */
-		1 << RAILTYPE_ELECTRIC,
-
-		/* Compatible railtypes */
-		1 << RAILTYPE_ELECTRIC | 1 << RAILTYPE_RAIL,
-
-		/* main offset */
-		0,
-
-		/* bridge offset */
-		0,
-
-		/* custom ground offset */
-		0,
-	},
-
-	/** Monorail */
-	{ /* Main Sprites */
-		{ SPR_MONO_TRACK_Y, SPR_MONO_TRACK_N_S, SPR_MONO_TRACK_BASE, SPR_MONO_SINGLE_Y, SPR_MONO_SINGLE_X,
-			SPR_MONO_SINGLE_NORTH, SPR_MONO_SINGLE_SOUTH, SPR_MONO_SINGLE_EAST, SPR_MONO_SINGLE_WEST,
-			SPR_CROSSING_OFF_X_MONO,
-			SPR_TUNNEL_ENTRY_REAR_MONO
-		},
-
-		/* GUI sprites */
-		{ 0x4E7, 0x4E8, 0x4E9, 0x4EA,
-			SPR_IMG_AUTOMONO,
-			SPR_IMG_DEPOT_MONO,
-			SPR_IMG_TUNNEL_MONO,
-			SPR_IMG_CONVERT_MONO
-		},
-
-		{
-			SPR_CURSOR_NS_MONO,
-			SPR_CURSOR_SWNE_MONO,
-			SPR_CURSOR_EW_MONO,
-			SPR_CURSOR_NWSE_MONO,
-			SPR_CURSOR_AUTOMONO,
-			SPR_CURSOR_MONO_DEPOT,
-			SPR_CURSOR_TUNNEL_MONO,
-			SPR_CURSOR_CONVERT_MONO
-		},
-
-		/* strings */
-		{ STR_100B_MONORAIL_CONSTRUCTION },
-
-		/* Offset of snow tiles */
-		SPR_MONO_SNOW_OFFSET,
-
-		/* Powered railtypes */
-		1 << RAILTYPE_MONO,
-
-		/* Compatible Railtypes */
-		1 << RAILTYPE_MONO,
-
-		/* main offset */
-		82,
-
-		/* bridge offset */
-		16,
-
-		/* custom ground offset */
-		1,
-	},
-
-	/** Maglev */
-	{ /* Main sprites */
-		{ SPR_MGLV_TRACK_Y, SPR_MGLV_TRACK_N_S, SPR_MGLV_TRACK_BASE, SPR_MGLV_SINGLE_Y, SPR_MGLV_SINGLE_X,
-			SPR_MGLV_SINGLE_NORTH, SPR_MGLV_SINGLE_SOUTH, SPR_MGLV_SINGLE_EAST, SPR_MGLV_SINGLE_WEST,
-			SPR_CROSSING_OFF_X_MAGLEV,
-			SPR_TUNNEL_ENTRY_REAR_MAGLEV
-		},
-
-		/* GUI sprites */
-		{ 0x4EB, 0x4EC, 0x4EE, 0x4ED,
-			SPR_IMG_AUTOMAGLEV,
-			SPR_IMG_DEPOT_MAGLEV,
-			SPR_IMG_TUNNEL_MAGLEV,
-			SPR_IMG_CONVERT_MAGLEV
-		},
-
-		{
-			SPR_CURSOR_NS_MAGLEV,
-			SPR_CURSOR_SWNE_MAGLEV,
-			SPR_CURSOR_EW_MAGLEV,
-			SPR_CURSOR_NWSE_MAGLEV,
-			SPR_CURSOR_AUTOMAGLEV,
-			SPR_CURSOR_MAGLEV_DEPOT,
-			SPR_CURSOR_TUNNEL_MAGLEV,
-			SPR_CURSOR_CONVERT_MAGLEV
-		},
-
-		/* strings */
-		{ STR_100C_MAGLEV_CONSTRUCTION },
-
-		/* Offset of snow tiles */
-		SPR_MGLV_SNOW_OFFSET,
-
-		/* Powered railtypes */
-		1 << RAILTYPE_MAGLEV,
-
-		/* Compatible Railtypes */
-		1 << RAILTYPE_MAGLEV,
-
-		/* main offset */
-		164,
-
-		/* bridge offset */
-		24,
-
-		/* custom ground offset */
-		2,
-	},
-};
-
-#endif /* RAILTYPES_H */
--- a/src/road.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/road.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,11 +1,11 @@
+/* $Id$ */
+
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "rail_map.h"
-#include "road.h"
 #include "road_map.h"
+#include "road_internal.h"
 #include "water_map.h"
-#include "macros.h"
 
 bool IsPossibleCrossing(const TileIndex tile, Axis ax)
 {
--- a/src/road.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +0,0 @@
-/* $Id$ */
-
-/** @file road.h */
-
-#ifndef ROAD_H
-#define ROAD_H
-
-#include "helpers.hpp"
-
-/**
- * The different roadtypes we support
- *
- * @note currently only ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
- */
-enum RoadType {
-	ROADTYPE_ROAD = 0,      ///< Basic road type
-	ROADTYPE_TRAM = 1,      ///< Trams
-	ROADTYPE_HWAY = 2,      ///< Only a placeholder. Not sure what we are going to do with this road type.
-	ROADTYPE_END,           ///< Used for iterations
-	INVALID_ROADTYPE = 0xFF ///< flag for invalid roadtype
-};
-DECLARE_POSTFIX_INCREMENT(RoadType);
-
-/**
- * The different roadtypes we support, but then a bitmask of them
- * @note currently only roadtypes with ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
- */
-enum RoadTypes {
-	ROADTYPES_NONE     = 0,                                                 ///< No roadtypes
-	ROADTYPES_ROAD     = 1 << ROADTYPE_ROAD,                                ///< Road
-	ROADTYPES_TRAM     = 1 << ROADTYPE_TRAM,                                ///< Trams
-	ROADTYPES_HWAY     = 1 << ROADTYPE_HWAY,                                ///< Highway (or whatever substitute)
-	ROADTYPES_ROADTRAM = ROADTYPES_ROAD | ROADTYPES_TRAM,                   ///< Road + trams
-	ROADTYPES_ROADHWAY = ROADTYPES_ROAD | ROADTYPES_HWAY,                   ///< Road + highway (or whatever substitute)
-	ROADTYPES_TRAMHWAY = ROADTYPES_TRAM | ROADTYPES_HWAY,                   ///< Trams + highway (or whatever substitute)
-	ROADTYPES_ALL      = ROADTYPES_ROAD | ROADTYPES_TRAM | ROADTYPES_HWAY,  ///< Road + trams + highway (or whatever substitute)
-};
-DECLARE_ENUM_AS_BIT_SET(RoadTypes);
-
-/**
- * Whether the given roadtype is valid.
- * @param rt the roadtype to check for validness
- * @return true if and only if valid
- */
-static inline bool IsValidRoadType(RoadType rt)
-{
-	return rt == ROADTYPE_ROAD || rt == ROADTYPE_TRAM;
-}
-
-/**
- * Are the given bits pointing to valid roadtypes?
- * @param rts the roadtypes to check for validness
- * @return true if and only if valid
- */
-static inline bool AreValidRoadTypes(RoadTypes rts)
-{
-	return HasBit(rts, ROADTYPE_ROAD) || HasBit(rts, ROADTYPE_TRAM);
-}
-
-/**
- * Maps a RoadType to the corresponding RoadTypes value
- *
- * @param rt the roadtype to get the roadtypes from
- * @return the roadtypes with the given roadtype
- */
-static inline RoadTypes RoadTypeToRoadTypes(RoadType rt)
-{
-	return (RoadTypes)(1 << rt);
-}
-
-/**
- * Returns the RoadTypes which are not present in the given RoadTypes
- *
- * This function returns the complement of a given RoadTypes.
- *
- * @param r The given RoadTypes
- * @return The complement of the given RoadTypes
- * @note The unused value ROADTYPES_HWAY will be used, too.
- */
-static inline RoadTypes ComplementRoadTypes(RoadTypes r)
-{
-	return (RoadTypes)(ROADTYPES_ALL ^ r);
-}
-
-/**
- * Enumeration for the road parts on a tile.
- *
- * This enumeration defines the possible road parts which
- * can be build on a tile.
- */
-enum RoadBits {
-	ROAD_NONE = 0U,                  ///< No road-part is build
-	ROAD_NW   = 1U,                  ///< North-west part
-	ROAD_SW   = 2U,                  ///< South-west part
-	ROAD_SE   = 4U,                  ///< South-east part
-	ROAD_NE   = 8U,                  ///< North-east part
-	ROAD_X    = ROAD_SW | ROAD_NE,   ///< Full road along the x-axis (south-west + north-east)
-	ROAD_Y    = ROAD_NW | ROAD_SE,   ///< Full road along the y-axis (north-west + south-east)
-	ROAD_ALL  = ROAD_X  | ROAD_Y     ///< Full 4-way crossing
-};
-
-DECLARE_ENUM_AS_BIT_SET(RoadBits);
-
-/**
- * Calculate the complement of a RoadBits value
- *
- * Simply flips all bits in the RoadBits value to get the complement
- * of the RoadBits.
- *
- * @param r The given RoadBits value
- * @return the complement
- */
-static inline RoadBits ComplementRoadBits(RoadBits r)
-{
-	return (RoadBits)(ROAD_ALL ^ r);
-}
-
-/**
- * Calculate the mirrored RoadBits
- *
- * Simply move the bits to their new position.
- *
- * @param r The given RoadBits value
- * @return the mirrored
- */
-static inline RoadBits MirrorRoadBits(RoadBits r)
-{
-	return (RoadBits)(GB(r, 0, 2) << 2 | GB(r, 2, 2));
-}
-
-/**
- * Calculate rotated RoadBits
- *
- * Move the Roadbits clockwise til they are in their final position.
- *
- * @param r The given RoadBits value
- * @param rot The given Rotation angle
- * @return the rotated
- */
-static inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
-{
-	for (; rot > (DiagDirDiff)0; rot--){
-		r = (RoadBits)(GB(r, 0, 1) << 3 | GB(r, 1, 3));
-	}
-	return r;
-}
-
-/**
- * Create the road-part which belongs to the given DiagDirection
- *
- * This function returns a RoadBits value which belongs to
- * the given DiagDirection.
- *
- * @param d The DiagDirection
- * @return The result RoadBits which the selected road-part set
- */
-static inline RoadBits DiagDirToRoadBits(DiagDirection d)
-{
-	return (RoadBits)(ROAD_NW << (3 ^ d));
-}
-
-/**
- * Return if the tile is a valid tile for a crossing.
- *
- * @note function is overloaded
- * @param tile the curent tile
- * @param ax the axis of the road over the rail
- * @return true if it is a valid tile
- */
-bool IsPossibleCrossing(const TileIndex tile, Axis ax);
-
-/**
- * Checks whether the trackdir means that we are reversing.
- * @param dir the trackdir to check
- * @return true if it is a reversing road trackdir
- */
-static inline bool IsReversingRoadTrackdir(Trackdir dir)
-{
-	return (dir & 0x07) >= 6;
-}
-
-/**
- * Checks whether the given trackdir is a straight road
- * @param dir the trackdir to check
- * @return true if it is a straight road trackdir
- */
-static inline bool IsStraightRoadTrackdir(Trackdir dir)
-{
-	return (dir & 0x06) == 0;
-}
-
-/**
- * Clean up unneccesary RoadBits of a planed tile.
- * @param tile current tile
- * @param org_rb planed RoadBits
- * @return optimised RoadBits
- */
-RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb);
-
-/**
- * Is it allowed to remove the given road bits from the given tile?
- * @param tile      the tile to remove the road from
- * @param remove    the roadbits that are going to be removed
- * @param owner     the actual owner of the roadbits of the tile
- * @param edge_road are the removed bits from a town?
- * @param rt        the road type to remove the bits from
- * @return true when it is allowed to remove the road bits
- */
-bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt);
-
-/**
- * Draw the catenary for tram road bits
- * @param ti   information about the tile (position, slope)
- * @param tram the roadbits to draw the catenary for
- */
-void DrawTramCatenary(TileInfo *ti, RoadBits tram);
-
-#endif /* ROAD_H */
--- a/src/road_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/road_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -9,31 +9,33 @@
 #include "cmd_helper.h"
 #include "rail_map.h"
 #include "road_map.h"
+#include "road_internal.h"
 #include "sprite.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
-#include "window.h"
-#include "map.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "tile.h"
 #include "town_map.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "command.h"
+#include "viewport_func.h"
+#include "command_func.h"
 #include "player.h"
 #include "town.h"
-#include "gfx.h"
-#include "sound.h"
 #include "yapf/yapf.h"
 #include "depot.h"
 #include "newgrf.h"
 #include "station_map.h"
 #include "tunnel_map.h"
 #include "misc/autoptr.hpp"
+#include "variables.h"
 #include "autoslope.h"
 #include "transparency.h"
+#include "tunnelbridge_map.h"
+#include "window_func.h"
+#include "strings_func.h"
+#include "vehicle_func.h"
+#include "vehicle_base.h"
+#include "sound_func.h"
+
 
 #define M(x) (1 << (x))
 /* Level crossings may only be built on these slopes */
@@ -112,8 +114,6 @@
 	 * false if it was a center piece. Affects town ratings drop */
 	bool edge_road;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	RoadType rt = (RoadType)GB(p1, 4, 2);
 	if (!IsValidRoadType(rt)) return CMD_ERROR;
 
@@ -121,16 +121,19 @@
 	switch (GetTileType(tile)) {
 		case MP_ROAD:
 			if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile);
+			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 			break;
 
 		case MP_STATION:
 			if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
+			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 			break;
 
 		case MP_TUNNELBRIDGE:
-			if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) ||
-					(IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR;
-			break;
+			{
+				if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
+				if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR;
+			} break;
 
 		default:
 			return CMD_ERROR;
@@ -143,8 +146,6 @@
 
 	if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) return CMD_ERROR;
 
-	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
-
 	/* check if you're allowed to remove the street owned by a town
 	 * removal allowance depends on difficulty setting */
 	if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR;
@@ -153,11 +154,11 @@
 		/* If it's the last roadtype, just clear the whole tile */
 		if (rts == RoadTypeToRoadTypes(rt)) return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
-		CommandCost cost;
+		CommandCost cost(EXPENSES_CONSTRUCTION);
 		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
-			TileIndex other_end = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
+			TileIndex other_end = GetOtherTunnelBridgeEnd(tile);
 			/* Pay for *every* tile of the bridge or tunnel */
-			cost.AddCost((DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile) + 1) * _price.remove_road);
+			cost.AddCost((DistanceManhattan(other_end, tile) + 1) * _price.remove_road);
 			if (flags & DC_EXEC) {
 				SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt));
 				SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
@@ -166,7 +167,7 @@
 				MarkTileDirtyByTile(tile);
 				MarkTileDirtyByTile(other_end);
 				if (IsBridge(tile)) {
-					TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
+					TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
 
 					for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
 				}
@@ -178,7 +179,7 @@
 				MarkTileDirtyByTile(tile);
 			}
 		}
-		return CommandCost(cost);
+		return cost;
 	}
 
 	switch (GetRoadTileType(tile)) {
@@ -198,9 +199,8 @@
 			c &= present;
 			if (c == ROAD_NONE) return CMD_ERROR;
 
+			ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
 			if (flags & DC_EXEC) {
-				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
-
 				present ^= c;
 				if (present == ROAD_NONE) {
 					RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
@@ -221,7 +221,7 @@
 					MarkTileDirtyByTile(tile);
 				}
 			}
-			return CommandCost(CountBits(c) * _price.remove_road);
+			return CommandCost(EXPENSES_CONSTRUCTION, CountBits(c) * _price.remove_road);
 		}
 
 		case ROAD_TILE_CROSSING: {
@@ -233,11 +233,11 @@
 			 * we can't draw the crossing without trambits ;) */
 			if (rt == ROADTYPE_ROAD && HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) && ((flags & DC_EXEC) || !HasBit(p1, 6))) return CMD_ERROR;
 
+			if (rt == ROADTYPE_ROAD) {
+				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
+			}
+
 			if (flags & DC_EXEC) {
-				if (rt == ROADTYPE_ROAD) {
-					ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
-				}
-
 				RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
 				if (rts == ROADTYPES_NONE) {
 					MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile));
@@ -247,7 +247,7 @@
 				MarkTileDirtyByTile(tile);
 				YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
 			}
-			return CommandCost(_price.remove_road * 2);
+			return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road * 2);
 		}
 
 		default:
@@ -343,7 +343,7 @@
 		*pieces |= MirrorRoadBits(*pieces);
 
 		if (existing == ROAD_NONE || existing == *pieces) {
-			if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform;
+			if (*pieces == ROAD_X || *pieces == ROAD_Y) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 		}
 		return CMD_ERROR;
 	}
@@ -355,7 +355,7 @@
 	if (_patches.build_on_slopes &&
 			existing == ROAD_NONE && CountBits(*pieces) == 1 &&
 			(_valid_tileh_slopes_road[2][tileh] & *pieces) == ROAD_NONE) {
-		return CommandCost(_price.terraform);
+		return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 	}
 
 	/* no special foundation */
@@ -367,7 +367,7 @@
 
 	/* foundation is used. Whole tile is leveled up */
 	if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == ROAD_NONE) {
-		return CommandCost(existing != ROAD_NONE ? (Money)0 : _price.terraform);
+		return CommandCost(EXPENSES_CONSTRUCTION, existing != ROAD_NONE ? (Money)0 : _price.terraform);
 	}
 
 	/* Force straight roads. */
@@ -375,7 +375,7 @@
 
 	/* partly leveled up tile, only if there's no road on that tile */
 	if ((existing == ROAD_NONE || existing == *pieces) && (tileh == SLOPE_W || tileh == SLOPE_S || tileh == SLOPE_E || tileh == SLOPE_N)) {
-		if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform;
+		if (*pieces == ROAD_X || *pieces == ROAD_Y) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 	}
 	return CMD_ERROR;
 }
@@ -390,14 +390,12 @@
  */
 CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	CommandCost cost;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	CommandCost ret;
 	RoadBits existing = ROAD_NONE;
 	RoadBits all_bits = ROAD_NONE;
 	Slope tileh;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* Road pieces are max 4 bitset values (NE, NW, SE, SW) and town can only be non-zero
 	 * if a non-player is building the road */
 	if ((IsValidPlayer(_current_player) && p2 != 0) || (_current_player == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR;
@@ -491,7 +489,7 @@
 				MakeRoadCrossing(tile, _current_player, _current_player, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2);
 				MarkTileDirtyByTile(tile);
 			}
-			return CommandCost(_price.build_road * (rt == ROADTYPE_ROAD ? 2 : 4));
+			return CommandCost(EXPENSES_CONSTRUCTION, _price.build_road * (rt == ROADTYPE_ROAD ? 2 : 4));
 		}
 
 		case MP_STATION:
@@ -502,12 +500,13 @@
 			break;
 
 		case MP_TUNNELBRIDGE:
-			if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) ||
-					(IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR;
-			if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
-			/* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */
-			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
-			break;
+			{
+				if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
+				if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
+
+				/* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */
+				if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR;
+			} break;
 
 		default:
 do_clear:;
@@ -535,7 +534,7 @@
 	cost.AddCost(CountBits(pieces) * _price.build_road);
 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		/* Pay for *every* tile of the bridge or tunnel */
-		cost.MultiplyCost(DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile));
+		cost.MultiplyCost(DistanceManhattan(GetOtherTunnelBridgeEnd(tile), tile) + 1);
 	}
 
 	if (flags & DC_EXEC) {
@@ -551,7 +550,7 @@
 			} break;
 
 			case MP_TUNNELBRIDGE: {
-				TileIndex other_end = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
+				TileIndex other_end = GetOtherTunnelBridgeEnd(tile);
 
 				SetRoadTypes(other_end, GetRoadTypes(other_end) | RoadTypeToRoadTypes(rt));
 				SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
@@ -560,7 +559,7 @@
 				MarkTileDirtyByTile(other_end);
 				MarkTileDirtyByTile(tile);
 				if (IsBridge(tile)) {
-					TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
+					TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
 
 					for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
 				}
@@ -586,30 +585,6 @@
 	return cost;
 }
 
-/**
- * Switches the rail type on a level crossing.
- * @param tile        The tile on which the railtype is to be convert.
- * @param totype      The railtype we want to convert to
- * @param exec        Switches between test and execute mode
- * @return            The cost and state of the operation
- * @retval CMD_ERROR  An error occured during the operation.
- */
-CommandCost DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
-{
-	/* not a railroad crossing? */
-	if (!IsLevelCrossing(tile)) return CMD_ERROR;
-
-	if (exec) {
-		SetRailType(tile, totype);
-		MarkTileDirtyByTile(tile);
-		YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile)));
-		VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
-	}
-
-	return CommandCost(RailBuildCost(totype) / 2);
-}
-
-
 /** Build a long piece of road.
  * @param end_tile end tile of drag
  * @param flags operation to perform
@@ -624,14 +599,12 @@
 CommandCost CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	TileIndex start_tile, tile;
-	CommandCost cost, ret;
+	CommandCost ret, cost(EXPENSES_CONSTRUCTION);
 	bool had_bridge = false;
 	bool had_tunnel = false;
 	bool had_success = false;
 	DisallowedRoadDirections drd = DRD_NORTHBOUND;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	if (p1 >= MapSize()) return CMD_ERROR;
 
 	start_tile = p1;
@@ -647,7 +620,7 @@
 		TileIndex t = start_tile;
 		start_tile = end_tile;
 		end_tile = t;
-		p2 ^= IS_INT_INSIDE(p2 & 3, 1, 3) ? 3 : 0;
+		p2 ^= IsInsideMM(p2 & 3, 1, 3) ? 3 : 0;
 		drd = DRD_SOUTHBOUND;
 	}
 
@@ -675,12 +648,12 @@
 			/* Only pay for the upgrade on one side of the bridges and tunnels */
 			if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 				if (IsBridge(tile)) {
-					if ((!had_bridge || GetBridgeRampDirection(tile) == DIAGDIR_SE || GetBridgeRampDirection(tile) == DIAGDIR_SW)) {
+					if ((!had_bridge || GetTunnelBridgeDirection(tile) == DIAGDIR_SE || GetTunnelBridgeDirection(tile) == DIAGDIR_SW)) {
 						cost.AddCost(ret);
 					}
 					had_bridge = true;
 				} else {
-					if ((!had_tunnel || GetTunnelDirection(tile) == DIAGDIR_SE || GetTunnelDirection(tile) == DIAGDIR_SW)) {
+					if ((!had_tunnel || GetTunnelBridgeDirection(tile) == DIAGDIR_SE || GetTunnelBridgeDirection(tile) == DIAGDIR_SW)) {
 						cost.AddCost(ret);
 					}
 					had_tunnel = true;
@@ -711,9 +684,8 @@
 CommandCost CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	TileIndex start_tile, tile;
-	CommandCost cost, ret, money;
-
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+	CommandCost ret, cost(EXPENSES_CONSTRUCTION);
+	Money money;
 
 	if (p1 >= MapSize()) return CMD_ERROR;
 
@@ -730,10 +702,10 @@
 		TileIndex t = start_tile;
 		start_tile = end_tile;
 		end_tile = t;
-		p2 ^= IS_INT_INSIDE(p2 & 3, 1, 3) ? 3 : 0;
+		p2 ^= IsInsideMM(p2 & 3, 1, 3) ? 3 : 0;
 	}
 
-	money.AddCost(GetAvailableMoneyForCommand());
+	money = GetAvailableMoneyForCommand();
 	tile = start_tile;
 	/* Start tile is the small number. */
 	for (;;) {
@@ -747,8 +719,8 @@
 			ret = DoCommand(tile, rt << 4 | bits, 0, flags & ~DC_EXEC, CMD_REMOVE_ROAD);
 			if (CmdSucceeded(ret)) {
 				if (flags & DC_EXEC) {
-					money.AddCost(-ret.GetCost());
-					if (money.GetCost() < 0) {
+					money -= ret.GetCost();
+					if (money < 0) {
 						_additional_cash_required = DoCommand(end_tile, start_tile, p2, flags & ~DC_EXEC, CMD_REMOVE_LONG_ROAD).GetCost();
 						return cost;
 					}
@@ -781,8 +753,6 @@
 	CommandCost cost;
 	Slope tileh;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	DiagDirection dir = Extract<DiagDirection, 0>(p1);
 	RoadType rt = (RoadType)GB(p1, 2, 2);
 
@@ -828,7 +798,7 @@
 		delete GetDepotByTile(tile);
 	}
 
-	return CommandCost(_price.remove_road_depot);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot);
 }
 
 static CommandCost ClearTile_Road(TileIndex tile, byte flags)
@@ -843,7 +813,7 @@
 			    IsTileOwner(tile, OWNER_TOWN) || !(flags & DC_AUTO)
 				) {
 				RoadTypes rts = GetRoadTypes(tile);
-				CommandCost ret;
+				CommandCost ret(EXPENSES_CONSTRUCTION);
 				for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
 					if (HasBit(rts, rt)) {
 						CommandCost tmp_ret = DoCommand(tile, rt << 4 | GetRoadBits(tile, rt), 0, flags, CMD_REMOVE_ROAD);
@@ -858,7 +828,7 @@
 
 		case ROAD_TILE_CROSSING: {
 			RoadTypes rts = GetRoadTypes(tile);
-			CommandCost ret;
+			CommandCost ret(EXPENSES_CONSTRUCTION);
 
 			if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
 
@@ -1242,7 +1212,7 @@
 			if (t->road_build_months != 0 &&
 					(DistanceManhattan(t->xy, tile) < 8 || grp != 0) &&
 					GetRoadTileType(tile) == ROAD_TILE_NORMAL && CountBits(GetAllRoadBits(tile)) > 1 ) {
-				if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && CHANCE16(1, 40)) {
+				if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && Chance16(1, 40)) {
 					StartRoadWorks(tile);
 
 					SndPlayTileFx(SND_21_JACKHAMMER, tile);
@@ -1369,7 +1339,7 @@
 	TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE
 };
 
-static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
+static VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
 {
 	switch (GetRoadTileType(tile)) {
 		case ROAD_TILE_CROSSING:
@@ -1439,11 +1409,11 @@
 	if (_patches.build_on_slopes && AutoslopeEnabled()) {
 		switch (GetRoadTileType(tile)) {
 			case ROAD_TILE_CROSSING:
-				if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh_new)) return _price.terraform;
+				if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 				break;
 
 			case ROAD_TILE_DEPOT:
-				if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRoadDepotDirection(tile))) return _price.terraform;
+				if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRoadDepotDirection(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 				break;
 
 			case ROAD_TILE_NORMAL: {
@@ -1461,7 +1431,7 @@
 						z_new += ApplyFoundationToSlope(GetRoadFoundation(tileh_new, bits), &tileh_new);
 
 						/* The surface slope must not be changed */
-						if ((z_old == z_new) && (tileh_old == tileh_new)) return _price.terraform;
+						if ((z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 					}
 				}
 				break;
--- a/src/road_cmd.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/road_cmd.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,7 @@
 #ifndef ROAD_CMD_H
 #define ROAD_CMD_H
 
-#include "direction.h"
+#include "direction_type.h"
 
 void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/road_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,116 @@
+/* $Id$ */
+
+/** @file road_func.h Functions related to roads. */
+
+#ifndef ROAD_FUNC_H
+#define ROAD_FUNC_H
+
+#include "core/bitmath_func.hpp"
+#include "road_type.h"
+#include "direction_func.h"
+
+/**
+ * Whether the given roadtype is valid.
+ * @param rt the roadtype to check for validness
+ * @return true if and only if valid
+ */
+static inline bool IsValidRoadType(RoadType rt)
+{
+	return rt == ROADTYPE_ROAD || rt == ROADTYPE_TRAM;
+}
+
+/**
+ * Are the given bits pointing to valid roadtypes?
+ * @param rts the roadtypes to check for validness
+ * @return true if and only if valid
+ */
+static inline bool AreValidRoadTypes(RoadTypes rts)
+{
+	return HasBit(rts, ROADTYPE_ROAD) || HasBit(rts, ROADTYPE_TRAM);
+}
+
+/**
+ * Maps a RoadType to the corresponding RoadTypes value
+ *
+ * @param rt the roadtype to get the roadtypes from
+ * @return the roadtypes with the given roadtype
+ */
+static inline RoadTypes RoadTypeToRoadTypes(RoadType rt)
+{
+	return (RoadTypes)(1 << rt);
+}
+
+/**
+ * Returns the RoadTypes which are not present in the given RoadTypes
+ *
+ * This function returns the complement of a given RoadTypes.
+ *
+ * @param r The given RoadTypes
+ * @return The complement of the given RoadTypes
+ * @note The unused value ROADTYPES_HWAY will be used, too.
+ */
+static inline RoadTypes ComplementRoadTypes(RoadTypes r)
+{
+	return (RoadTypes)(ROADTYPES_ALL ^ r);
+}
+
+
+/**
+ * Calculate the complement of a RoadBits value
+ *
+ * Simply flips all bits in the RoadBits value to get the complement
+ * of the RoadBits.
+ *
+ * @param r The given RoadBits value
+ * @return the complement
+ */
+static inline RoadBits ComplementRoadBits(RoadBits r)
+{
+	return (RoadBits)(ROAD_ALL ^ r);
+}
+
+/**
+ * Calculate the mirrored RoadBits
+ *
+ * Simply move the bits to their new position.
+ *
+ * @param r The given RoadBits value
+ * @return the mirrored
+ */
+static inline RoadBits MirrorRoadBits(RoadBits r)
+{
+	return (RoadBits)(GB(r, 0, 2) << 2 | GB(r, 2, 2));
+}
+
+/**
+ * Calculate rotated RoadBits
+ *
+ * Move the Roadbits clockwise til they are in their final position.
+ *
+ * @param r The given RoadBits value
+ * @param rot The given Rotation angle
+ * @return the rotated
+ */
+static inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
+{
+	for (; rot > (DiagDirDiff)0; rot--){
+		r = (RoadBits)(GB(r, 0, 1) << 3 | GB(r, 1, 3));
+	}
+	return r;
+}
+
+/**
+ * Create the road-part which belongs to the given DiagDirection
+ *
+ * This function returns a RoadBits value which belongs to
+ * the given DiagDirection.
+ *
+ * @param d The DiagDirection
+ * @return The result RoadBits which the selected road-part set
+ */
+static inline RoadBits DiagDirToRoadBits(DiagDirection d)
+{
+	return (RoadBits)(ROAD_NW << (3 ^ d));
+}
+
+#endif /* ROAD_FUNC_H */
--- a/src/road_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/road_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,23 +6,23 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
-#include "map.h"
-#include "tile.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
-#include "sound.h"
-#include "command.h"
+#include "window_gui.h"
+#include "station_gui.h"
+#include "terraform_gui.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
+#include "command_func.h"
 #include "variables.h"
-#include "road.h"
+#include "road_type.h"
 #include "road_cmd.h"
 #include "road_map.h"
 #include "station_map.h"
-//needed for catchments
 #include "station.h"
+#include "functions.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
 
 
 static void ShowRVStationPicker(RoadStop::Type rs);
@@ -317,9 +317,9 @@
  */
 static void BuildRoadClick_OneWay(Window *w)
 {
-	if (IsWindowWidgetDisabled(w, RTW_ONE_WAY)) return;
+	if (w->IsWidgetDisabled(RTW_ONE_WAY)) return;
 	SetWindowDirty(w);
-	ToggleWidgetLoweredState(w, RTW_ONE_WAY);
+	w->ToggleWidgetLoweredState(RTW_ONE_WAY);
 	SetSelectionRed(false);
 }
 
@@ -335,11 +335,11 @@
 
 static void BuildRoadClick_Remove(Window *w)
 {
-	if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return;
+	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
 	SetWindowDirty(w);
 	SndPlayFx(SND_15_BEEP);
-	ToggleWidgetLoweredState(w, RTW_REMOVE);
-	SetSelectionRed(IsWindowWidgetLowered(w, RTW_REMOVE));
+	w->ToggleWidgetLoweredState(RTW_REMOVE);
+	SetSelectionRed(w->IsWidgetLowered(RTW_REMOVE));
 }
 
 /** Array with the handlers of the button-clicks for the road-toolbar */
@@ -385,20 +385,20 @@
 	 * Both are only valid if they are able to apply as options. */
 	switch (clicked_widget) {
 		case RTW_REMOVE:
-			RaiseWindowWidget(w, RTW_ONE_WAY);
+			w->RaiseWidget(RTW_ONE_WAY);
 			break;
 		case RTW_ONE_WAY:
-			RaiseWindowWidget(w, RTW_REMOVE);
+			w->RaiseWidget(RTW_REMOVE);
 			break;
 		case RTW_BUS_STATION:
 		case RTW_TRUCK_STATION:
-			DisableWindowWidget(w, RTW_ONE_WAY);
-			SetWindowWidgetDisabledState(w, RTW_REMOVE, !IsWindowWidgetLowered(w, clicked_widget));
+			w->DisableWidget(RTW_ONE_WAY);
+			w->SetWidgetDisabledState(RTW_REMOVE, !w->IsWidgetLowered(clicked_widget));
 			break;
 		case RTW_ROAD_X:
 		case RTW_ROAD_Y:
 		case RTW_AUTOROAD:
-			SetWindowWidgetsDisabledState(w, !IsWindowWidgetLowered(w, clicked_widget),
+			w->SetWidgetsDisabledState(!w->IsWidgetLowered(clicked_widget),
 				RTW_REMOVE,
 				RTW_ONE_WAY,
 				WIDGET_LIST_END);
@@ -406,11 +406,11 @@
 		default:
 			/* When any other buttons than road/station, raise and
 			 * disable the removal button */
-			SetWindowWidgetsDisabledState(w, true,
+			w->SetWidgetsDisabledState(true,
 				RTW_REMOVE,
 				RTW_ONE_WAY,
 				WIDGET_LIST_END);
-			SetWindowWidgetsLoweredState (w, false,
+			w->SetWidgetsLoweredState (false,
 				RTW_REMOVE,
 				RTW_ONE_WAY,
 				WIDGET_LIST_END);
@@ -422,14 +422,14 @@
 {
 	switch (e->event) {
 	case WE_CREATE:
-		SetWindowWidgetsDisabledState(w, true,
+		w->SetWidgetsDisabledState(true,
 			RTW_REMOVE,
 			RTW_ONE_WAY,
 			WIDGET_LIST_END);
 		break;
 
 	case WE_PAINT:
-		SetWindowWidgetsDisabledState(w, !CanBuildVehicleInfrastructure(VEH_ROAD),
+		w->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
 			RTW_DEPOT,
 			RTW_BUS_STATION,
 			RTW_TRUCK_STATION,
@@ -461,15 +461,19 @@
 		break;
 
 	case WE_PLACE_OBJ:
-		_remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE);
-		_one_way_button_clicked = IsWindowWidgetLowered(w, RTW_ONE_WAY);
+		_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
+		_one_way_button_clicked = w->IsWidgetLowered(RTW_ONE_WAY);
 		_place_proc(e->we.place.tile);
 		break;
 
 	case WE_ABORT_PLACE_OBJ:
-		RaiseWindowButtons(w);
-		DisableWindowWidget(w, RTW_REMOVE);
-		InvalidateWidget(w, RTW_REMOVE);
+		w->RaiseButtons();
+		w->SetWidgetsDisabledState(true,
+			RTW_REMOVE,
+			RTW_ONE_WAY,
+			WIDGET_LIST_END);
+		w->InvalidateWidget(RTW_REMOVE);
+		w->InvalidateWidget(RTW_ONE_WAY);
 
 		w = FindWindowById(WC_BUS_STATION, 0);
 		if (w != NULL) WP(w, def_d).close = true;
@@ -681,7 +685,7 @@
 static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-	case WE_CREATE: LowerWindowWidget(w, _road_depot_orientation + BRDW_DEPOT_NE); break;
+	case WE_CREATE: w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE); break;
 
 	case WE_PAINT:
 		DrawWindowWidgets(w);
@@ -698,9 +702,9 @@
 			case BRDW_DEPOT_NE:
 			case BRDW_DEPOT_SW:
 			case BRDW_DEPOT_SE:
-				RaiseWindowWidget(w, _road_depot_orientation + BRDW_DEPOT_NE);
+				w->RaiseWidget(_road_depot_orientation + BRDW_DEPOT_NE);
 				_road_depot_orientation = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE);
-				LowerWindowWidget(w, _road_depot_orientation + BRDW_DEPOT_NE);
+				w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
 				SndPlayFx(SND_15_BEEP);
 				SetWindowDirty(w);
 				break;
@@ -786,15 +790,15 @@
 		if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
 			_road_station_picker_orientation = DIAGDIR_END;
 		}
-		SetWindowWidgetsDisabledState(w, _cur_roadtype == ROADTYPE_TRAM,
+		w->SetWidgetsDisabledState(_cur_roadtype == ROADTYPE_TRAM,
 			BRSW_STATION_NE,
 			BRSW_STATION_SE,
 			BRSW_STATION_SW,
 			BRSW_STATION_NW,
 			WIDGET_LIST_END);
 
-		LowerWindowWidget(w, _road_station_picker_orientation + BRSW_STATION_NE);
-		LowerWindowWidget(w, _station_show_coverage + BRSW_LT_OFF);
+		w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
+		w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
 		break;
 
 	case WE_PAINT: {
@@ -811,13 +815,13 @@
 
 		StationType st = (w->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
 
-		StationPickerDrawSprite(103, 35, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 0);
-		StationPickerDrawSprite(103, 85, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 1);
-		StationPickerDrawSprite( 35, 85, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 2);
-		StationPickerDrawSprite( 35, 35, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 3);
+		StationPickerDrawSprite(103, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 0);
+		StationPickerDrawSprite(103, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 1);
+		StationPickerDrawSprite( 35, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 2);
+		StationPickerDrawSprite( 35, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 3);
 
-		StationPickerDrawSprite(171, 35, st, RAILTYPE_BEGIN, _cur_roadtype, 4);
-		StationPickerDrawSprite(171, 85, st, RAILTYPE_BEGIN, _cur_roadtype, 5);
+		StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4);
+		StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5);
 
 		DrawStationCoverageAreaText(2, 146,
 			(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
@@ -833,18 +837,18 @@
 			case BRSW_STATION_NW:
 			case BRSW_STATION_X:
 			case BRSW_STATION_Y:
-				RaiseWindowWidget(w, _road_station_picker_orientation + BRSW_STATION_NE);
+				w->RaiseWidget(_road_station_picker_orientation + BRSW_STATION_NE);
 				_road_station_picker_orientation = (DiagDirection)(e->we.click.widget - BRSW_STATION_NE);
-				LowerWindowWidget(w, _road_station_picker_orientation + BRSW_STATION_NE);
+				w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
 				SndPlayFx(SND_15_BEEP);
 				SetWindowDirty(w);
 				break;
 
 			case BRSW_LT_OFF:
 			case BRSW_LT_ON:
-				RaiseWindowWidget(w, _station_show_coverage + BRSW_LT_OFF);
+				w->RaiseWidget(_station_show_coverage + BRSW_LT_OFF);
 				_station_show_coverage = (e->we.click.widget != BRSW_LT_OFF);
-				LowerWindowWidget(w, _station_show_coverage + BRSW_LT_OFF);
+				w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
 				SndPlayFx(SND_15_BEEP);
 				SetWindowDirty(w);
 				break;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/road_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,13 @@
+/* $Id$ */
+
+/** @file road_gui.h Functions/types related to the road GUIs. */
+
+#ifndef ROAD_GUI_H
+#define ROAD_GUI_H
+
+#include "road_type.h"
+
+void ShowBuildRoadToolbar(RoadType roadtype);
+void ShowBuildRoadScenToolbar();
+
+#endif /* ROAD_GUI_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/road_internal.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,36 @@
+/* $Id$ */
+
+/** @file road_internal.h Functions used internally by the roads. */
+
+#ifndef ROAD_INTERNAL_H
+#define ROAD_INTERNAL_H
+
+#include "tile_cmd.h"
+
+/**
+ * Clean up unneccesary RoadBits of a planed tile.
+ * @param tile current tile
+ * @param org_rb planed RoadBits
+ * @return optimised RoadBits
+ */
+RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb);
+
+/**
+ * Is it allowed to remove the given road bits from the given tile?
+ * @param tile      the tile to remove the road from
+ * @param remove    the roadbits that are going to be removed
+ * @param owner     the actual owner of the roadbits of the tile
+ * @param edge_road are the removed bits from a town?
+ * @param rt        the road type to remove the bits from
+ * @return true when it is allowed to remove the road bits
+ */
+bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt);
+
+/**
+ * Draw the catenary for tram road bits
+ * @param ti   information about the tile (position, slope)
+ * @param tram the roadbits to draw the catenary for
+ */
+void DrawTramCatenary(TileInfo *ti, RoadBits tram);
+
+#endif /* ROAD_INTERNAL_H */
--- a/src/road_map.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/road_map.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,13 +5,13 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "bridge_map.h"
-#include "functions.h"
-#include "landscape.h"
+#include "tile_cmd.h"
 #include "road_map.h"
 #include "station.h"
 #include "tunnel_map.h"
 #include "station_map.h"
 #include "depot.h"
+#include "tunnelbridge_map.h"
 
 
 RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt)
@@ -33,13 +33,8 @@
 			return DiagDirToRoadBits(GetRoadStopDir(tile));
 
 		case MP_TUNNELBRIDGE:
-			if (IsTunnel(tile)) {
-				if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
-				return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile)));
-			} else {
-				if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
-				return DiagDirToRoadBits(ReverseDiagDir(GetBridgeRampDirection(tile)));
-			}
+			if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
+			return DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
 
 		default: return ROAD_NONE;
 	}
--- a/src/road_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/road_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,10 +5,11 @@
 #ifndef ROAD_MAP_H
 #define ROAD_MAP_H
 
-#include "macros.h"
-#include "rail.h"
-#include "road.h"
-#include "tile.h"
+#include "track_func.h"
+#include "rail_type.h"
+#include "town_type.h"
+#include "road_func.h"
+#include "tile_map.h"
 
 
 enum RoadTileType {
@@ -304,6 +305,16 @@
  */
 TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt);
 
+/**
+ * Return if the tile is a valid tile for a crossing.
+ *
+ * @note function is overloaded
+ * @param tile the curent tile
+ * @param ax the axis of the road over the rail
+ * @return true if it is a valid tile
+ */
+bool IsPossibleCrossing(const TileIndex tile, Axis ax);
+
 
 static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram, Owner hway)
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/road_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,59 @@
+/* $Id$ */
+
+/** @file road.h Enums and other types related to roads. */
+
+#ifndef ROAD_TYPE_H
+#define ROAD_TYPE_H
+
+#include "core/enum_type.hpp"
+
+/**
+ * The different roadtypes we support
+ *
+ * @note currently only ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
+ */
+enum RoadType {
+	ROADTYPE_ROAD = 0,      ///< Basic road type
+	ROADTYPE_TRAM = 1,      ///< Trams
+	ROADTYPE_HWAY = 2,      ///< Only a placeholder. Not sure what we are going to do with this road type.
+	ROADTYPE_END,           ///< Used for iterations
+	INVALID_ROADTYPE = 0xFF ///< flag for invalid roadtype
+};
+DECLARE_POSTFIX_INCREMENT(RoadType);
+
+/**
+ * The different roadtypes we support, but then a bitmask of them
+ * @note currently only roadtypes with ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
+ */
+enum RoadTypes {
+	ROADTYPES_NONE     = 0,                                                 ///< No roadtypes
+	ROADTYPES_ROAD     = 1 << ROADTYPE_ROAD,                                ///< Road
+	ROADTYPES_TRAM     = 1 << ROADTYPE_TRAM,                                ///< Trams
+	ROADTYPES_HWAY     = 1 << ROADTYPE_HWAY,                                ///< Highway (or whatever substitute)
+	ROADTYPES_ROADTRAM = ROADTYPES_ROAD | ROADTYPES_TRAM,                   ///< Road + trams
+	ROADTYPES_ROADHWAY = ROADTYPES_ROAD | ROADTYPES_HWAY,                   ///< Road + highway (or whatever substitute)
+	ROADTYPES_TRAMHWAY = ROADTYPES_TRAM | ROADTYPES_HWAY,                   ///< Trams + highway (or whatever substitute)
+	ROADTYPES_ALL      = ROADTYPES_ROAD | ROADTYPES_TRAM | ROADTYPES_HWAY,  ///< Road + trams + highway (or whatever substitute)
+};
+DECLARE_ENUM_AS_BIT_SET(RoadTypes);
+
+
+/**
+ * Enumeration for the road parts on a tile.
+ *
+ * This enumeration defines the possible road parts which
+ * can be build on a tile.
+ */
+enum RoadBits {
+	ROAD_NONE = 0U,                  ///< No road-part is build
+	ROAD_NW   = 1U,                  ///< North-west part
+	ROAD_SW   = 2U,                  ///< South-west part
+	ROAD_SE   = 4U,                  ///< South-east part
+	ROAD_NE   = 8U,                  ///< North-east part
+	ROAD_X    = ROAD_SW | ROAD_NE,   ///< Full road along the x-axis (south-west + north-east)
+	ROAD_Y    = ROAD_NW | ROAD_SE,   ///< Full road along the y-axis (north-west + south-east)
+	ROAD_ALL  = ROAD_X  | ROAD_Y     ///< Full 4-way crossing
+};
+DECLARE_ENUM_AS_BIT_SET(RoadBits);
+
+#endif /* ROAD_TYPE_H */
--- a/src/roadveh.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/roadveh.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,9 +5,9 @@
 #ifndef ROADVEH_H
 #define ROADVEH_H
 
-#include "vehicle.h"
+#include "vehicle_base.h"
 #include "engine.h"
-#include "variables.h"
+#include "economy_func.h"
 
 enum RoadVehicleSubType {
 	RVST_FRONT,
--- a/src/roadveh_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/roadveh_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,25 +5,20 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
 #include "road_map.h"
 #include "roadveh.h"
 #include "station_map.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "map.h"
-#include "tile.h"
-#include "vehicle.h"
 #include "timetable.h"
 #include "engine.h"
-#include "command.h"
+#include "command_func.h"
 #include "station.h"
 #include "news.h"
 #include "pathfind.h"
 #include "npf.h"
 #include "player.h"
-#include "sound.h"
 #include "depot.h"
 #include "bridge.h"
 #include "tunnel_map.h"
@@ -35,10 +30,20 @@
 #include "newgrf_text.h"
 #include "newgrf_sound.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "cargotype.h"
+#include "strings_func.h"
+#include "tunnelbridge_map.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "variables.h"
+#include "autoreplace_gui.h"
+#include "gfx_func.h"
 #include "ai/ai.h"
 
+
 static const uint16 _roadveh_images[63] = {
 	0xCD4, 0xCDC, 0xCE4, 0xCEC, 0xCF4, 0xCFC, 0xD0C, 0xD14,
 	0xD24, 0xD1C, 0xD2C, 0xD04, 0xD1C, 0xD24, 0xD6C, 0xD74,
@@ -95,7 +100,7 @@
 	if (is_custom_sprite(img)) {
 		image = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(img)));
 		if (image != 0) return image;
-		img = orig_road_vehicle_info[this->engine_type - ROAD_ENGINES_INDEX].image_index;
+		img = _orig_road_vehicle_info[this->engine_type - ROAD_ENGINES_INDEX].image_index;
 	}
 
 	image = direction + _roadveh_images[img];
@@ -114,14 +119,14 @@
 			DrawSprite(sprite, pal, x, y);
 			return;
 		}
-		spritenum = orig_road_vehicle_info[engine - ROAD_ENGINES_INDEX].image_index;
+		spritenum = _orig_road_vehicle_info[engine - ROAD_ENGINES_INDEX].image_index;
 	}
 	DrawSprite(6 + _roadveh_images[spritenum], pal, x, y);
 }
 
 static CommandCost EstimateRoadVehCost(EngineID engine_type)
 {
-	return CommandCost(((_price.roadveh_base >> 3) * GetEngineProperty(engine_type, 0x11, RoadVehInfo(engine_type)->base_cost)) >> 5);
+	return CommandCost(EXPENSES_NEW_VEHICLES, ((_price.roadveh_base >> 3) * GetEngineProperty(engine_type, 0x11, RoadVehInfo(engine_type)->base_cost)) >> 5);
 }
 
 byte GetRoadVehLength(const Vehicle *v)
@@ -168,8 +173,6 @@
 
 	if (!IsEngineBuildable(p1, VEH_ROAD, _current_player)) return_cmd_error(STR_ROAD_VEHICLE_NOT_AVAILABLE);
 
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
 	cost = EstimateRoadVehCost(p1);
 	if (flags & DC_QUERY_COST) return cost;
 
@@ -234,7 +237,7 @@
 
 		v->last_station_visited = INVALID_STATION;
 		v->max_speed = rvi->max_speed;
-		v->engine_type = (byte)p1;
+		v->engine_type = (EngineID)p1;
 
 		e = GetEngine(p1);
 		v->reliability = e->reliability;
@@ -275,7 +278,7 @@
 		GetPlayer(_current_player)->num_engines[p1]++;
 	}
 
-	return CommandCost(cost);
+	return cost;
 }
 
 /** Start/Stop a road vehicle.
@@ -362,13 +365,11 @@
 
 	if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE);
 
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
 	if (!CheckRoadVehInDepotStopped(v)) {
 		return_cmd_error(STR_9013_MUST_BE_STOPPED_INSIDE);
 	}
 
-	CommandCost ret(-v->value);
+	CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
 
 	if (flags & DC_EXEC) {
 		// Invalidate depot
@@ -550,8 +551,7 @@
 
 	if (IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) return CMD_ERROR;
 
-	if (IsTunnelTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelDirection(v->tile)) return CMD_ERROR;
-	if (IsBridgeTile(v->tile) && DirToDiagDir(v->direction) == GetBridgeRampDirection(v->tile)) return CMD_ERROR;
+	if (IsTileType(v->tile, MP_TUNNELBRIDGE) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR;
 
 	if (flags & DC_EXEC) v->u.road.reverse_ctr = 180;
 
@@ -1018,7 +1018,7 @@
 	const OvertakeData* od = (OvertakeData*)data;
 
 	return
-		v->tile == od->tile && v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v ?
+		v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v ?
 			v : NULL;
 }
 
@@ -1276,18 +1276,17 @@
 		uint best_dist = (uint)-1;
 		uint best_maxlen = (uint)-1;
 		uint bitmask = (uint)trackdirs;
-		for (int i = 0; bitmask != 0; bitmask >>= 1, i++) {
-			if (HasBit(bitmask, 0)) {
-				if (best_track == INVALID_TRACKDIR) best_track = (Trackdir)i; // in case we don't find the path, just pick a track
-				frd.maxtracklen = (uint)-1;
-				frd.mindist = (uint)-1;
-				FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, v->u.road.compatible_roadtypes, _road_pf_directions[i], EnumRoadTrackFindDist, NULL, &frd);
+		uint i;
+		FOR_EACH_SET_BIT(i, bitmask) {
+			if (best_track == INVALID_TRACKDIR) best_track = (Trackdir)i; // in case we don't find the path, just pick a track
+			frd.maxtracklen = (uint)-1;
+			frd.mindist = (uint)-1;
+			FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, v->u.road.compatible_roadtypes, _road_pf_directions[i], EnumRoadTrackFindDist, NULL, &frd);
 
-				if (frd.mindist < best_dist || (frd.mindist == best_dist && frd.maxtracklen < best_maxlen)) {
-					best_dist = frd.mindist;
-					best_maxlen = frd.maxtracklen;
-					best_track = (Trackdir)i;
-				}
+			if (frd.mindist < best_dist || (frd.mindist == best_dist && frd.maxtracklen < best_maxlen)) {
+				best_dist = frd.mindist;
+				best_maxlen = frd.maxtracklen;
+				best_track = (Trackdir)i;
 			}
 		}
 	}
@@ -1409,10 +1408,8 @@
 	if (prev_state == RVSB_WORMHOLE || prev_state == RVSB_IN_DEPOT) {
 		DiagDirection diag_dir = INVALID_DIAGDIR;
 
-		if (IsTunnelTile(tile)) {
-			diag_dir = GetTunnelDirection(tile);
-		} else if (IsBridgeTile(tile)) {
-			diag_dir = GetBridgeRampDirection(tile);
+		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
+			diag_dir = GetTunnelBridgeDirection(tile);
 		} else if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
 			diag_dir = ReverseDiagDir(GetRoadDepotDirection(tile));
 		}
@@ -1465,25 +1462,21 @@
 
 /**
  * Can a tram track build without destruction on the given tile?
+ * @param p the player that would be building the tram tracks
  * @param t the tile to build on.
+ * @param r the road bits needed.
  * @return true when a track track can be build on 't'
  */
-static bool CanBuildTramTrackOnTile(TileIndex t)
+static bool CanBuildTramTrackOnTile(PlayerID p, TileIndex t, RoadBits r)
 {
-	switch (GetTileType(t)) {
-		case MP_CLEAR:
-		case MP_TREES:
-			return true;
+	/* The 'current' player is not necessarily the owner of the vehicle. */
+	PlayerID original_player = _current_player;
+	_current_player = p;
 
-		case MP_ROAD:
-			return GetRoadTileType(t) == ROAD_TILE_NORMAL;
+	CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, 0, CMD_BUILD_ROAD);
 
-		case MP_WATER:
-			return IsCoast(t);
-
-		default:
-			return false;
-	}
+	_current_player = original_player;
+	return CmdSucceeded(ret);
 }
 
 static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev)
@@ -1495,13 +1488,17 @@
 	uint32 r;
 
 	if (v->u.road.overtaking != 0)  {
-		if (++v->u.road.overtaking_ctr >= 35)
+		if (IsTileType(v->tile, MP_STATION)) {
+			/* Force us to be not overtaking! */
+			v->u.road.overtaking = 0;
+		} else if (++v->u.road.overtaking_ctr >= 35) {
 			/* If overtaking just aborts at a random moment, we can have a out-of-bound problem,
 			 *  if the vehicle started a corner. To protect that, only allow an abort of
 			 *  overtake if we are on straight roads */
 			if (v->u.road.state < RVSB_IN_ROAD_STOP && IsStraightRoadTrackdir((Trackdir)v->u.road.state)) {
 				v->u.road.overtaking = 0;
 			}
+		}
 	}
 
 	/* If this vehicle is in a depot and we've reached this point it must be
@@ -1593,7 +1590,7 @@
 					 *   going to cause the tram to split up.
 					 * - Or the front of the tram can drive over the next tile.
 					 */
-				} else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(tile)) {
+				} else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(v->owner, tile, needed)) {
 					/*
 					 * Taking the 'small' corner for trams only happens when:
 					 * - We are not the from vehicle of an articulated tram.
@@ -1646,8 +1643,8 @@
 			goto again;
 		}
 
-		if (IS_BYTE_INSIDE(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) && IsTileType(v->tile, MP_STATION)) {
-			if (IsReversingRoadTrackdir(dir) && IS_BYTE_INSIDE(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
+		if (IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) && IsTileType(v->tile, MP_STATION)) {
+			if (IsReversingRoadTrackdir(dir) && IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
 				/* New direction is trying to turn vehicle around.
 				 * We can't turn at the exit of a road stop so wait.*/
 				v->cur_speed = 0;
@@ -1692,7 +1689,7 @@
 		uint turn_around_start_frame = RVC_TURN_AROUND_START_FRAME;
 
 		RoadBits tram;
-		if (v->u.road.roadtype == ROADTYPE_TRAM && CountBits(tram = GetRoadBits(v->tile, ROADTYPE_TRAM)) == 1) {
+		if (v->u.road.roadtype == ROADTYPE_TRAM && CountBits(tram = GetAnyRoadBits(v->tile, ROADTYPE_TRAM)) == 1) {
 			/*
 			 * The tram is turning around with one tram 'roadbit'. This means that
 			 * it is using the 'big' corner 'drive data'. However, to support the
@@ -1769,7 +1766,7 @@
 
 	new_dir = RoadVehGetSlidingDirection(v, x, y);
 
-	if (IsRoadVehFront(v) && !IS_BYTE_INSIDE(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
+	if (IsRoadVehFront(v) && !IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
 		/* Vehicle is not in a road stop.
 		 * Check for another vehicle to overtake */
 		Vehicle* u = RoadVehFindCloseTo(v, x, y, new_dir);
@@ -1804,9 +1801,9 @@
 	 * and it's the correct type of stop (bus or truck) and the frame equals the stop frame...
 	 * (the station test and stop type test ensure that other vehicles, using the road stop as
 	 * a through route, do not stop) */
-	if (IsRoadVehFront(v) && ((IS_BYTE_INSIDE(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) &&
+	if (IsRoadVehFront(v) && ((IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) &&
 			_road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_opt.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) ||
-			(IS_BYTE_INSIDE(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
+			(IsInsideMM(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
 			v->current_order.dest == GetStationIndex(v->tile) &&
 			GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK) &&
 			v->u.road.frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
@@ -1992,7 +1989,7 @@
 
 	if (v->current_order.type == OT_GOTO_DEPOT &&
 			v->current_order.flags & OF_NON_STOP &&
-			!CHANCE16(1, 20)) {
+			!Chance16(1, 20)) {
 		return;
 	}
 
@@ -2008,7 +2005,7 @@
 
 void OnNewDay_RoadVeh(Vehicle *v)
 {
-	CommandCost cost;
+	CommandCost cost(EXPENSES_ROADVEH_RUN);
 
 	if (!IsRoadVehFront(v)) return;
 
@@ -2088,12 +2085,11 @@
 		}
 	}
 
-	cost = RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364;
+	cost = CommandCost(EXPENSES_ROADVEH_RUN, RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364);
 
 	v->profit_this_year -= cost.GetCost() >> 8;
 
-	SET_EXPENSES_TYPE(EXPENSES_ROADVEH_RUN);
-	SubtractMoneyFromPlayerFract(v->owner, CommandCost(cost));
+	SubtractMoneyFromPlayerFract(v->owner, cost);
 
 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 	InvalidateWindowClasses(WC_ROADVEH_LIST);
@@ -2126,7 +2122,7 @@
 CommandCost CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	Vehicle *v;
-	CommandCost cost;
+	CommandCost cost(EXPENSES_ROADVEH_RUN);
 	CargoID new_cid = GB(p2, 0, 8);
 	byte new_subtype = GB(p2, 8, 8);
 	bool only_this = HasBit(p2, 16);
@@ -2139,11 +2135,10 @@
 
 	if (v->type != VEH_ROAD || !CheckOwnership(v->owner)) return CMD_ERROR;
 	if (!CheckRoadVehInDepotStopped(v)) return_cmd_error(STR_9013_MUST_BE_STOPPED_INSIDE);
+	if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_REFIT_DESTROYED_VEHICLE);
 
 	if (new_cid >= NUM_CARGO) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_ROADVEH_RUN);
-
 	for (; v != NULL; v = v->Next()) {
 		/* XXX: We refit all the attached wagons en-masse if they can be
 		 * refitted. This is how TTDPatch does it.  TODO: Have some nice
--- a/src/roadveh_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/roadveh_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,19 +5,20 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "roadveh.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "window.h"
 #include "gui.h"
-#include "strings.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "command.h"
+#include "window_gui.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
+#include "command_func.h"
 #include "depot.h"
 #include "vehicle_gui.h"
 #include "newgrf_engine.h"
+#include "strings_func.h"
+#include "vehicle_func.h"
+#include "string_func.h"
 
 
 void DrawRoadVehDetails(const Vehicle *v, int x, int y)
@@ -100,7 +101,7 @@
 	return (length * 28) / 8;
 }
 
-void DrawRoadVehImage(const Vehicle *v, int x, int y, int count, VehicleID selection)
+void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int count)
 {
 	/* Road vehicle lengths are measured in eighths of the standard length, so
 	 * count is the number of standard vehicles that should be drawn. If it is
--- a/src/saveload.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/saveload.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -16,8 +16,6 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "vehicle.h"
 #include "station.h"
 #include "thread.h"
 #include "town.h"
@@ -26,10 +24,17 @@
 #include "network/network.h"
 #include "variables.h"
 #include "table/strings.h"
-#include "strings.h"
+#include "window_func.h"
+#include "strings_func.h"
+#include "gfx_func.h"
+#include "core/alloc_func.hpp"
+#include "functions.h"
+#include "core/endian_func.hpp"
+#include "vehicle_base.h"
+#include "autoreplace_base.h"
 #include <list>
 
-extern const uint16 SAVEGAME_VERSION = 82;
+extern const uint16 SAVEGAME_VERSION = 83;
 uint16 _sl_version;       ///< the major savegame version identifier
 byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 
@@ -575,7 +580,7 @@
 				if (len == 0) {
 					*(char**)ptr = NULL;
 				} else {
-					*(char**)ptr = (char*)malloc(len + 1); // terminating '\0'
+					*(char**)ptr = MallocT<char>(len + 1); // terminating '\0'
 					ptr = *(char**)ptr;
 					SlCopyBytes(ptr, len);
 				}
@@ -1060,7 +1065,7 @@
 static bool InitLZO()
 {
 	_sl.bufsize = LZO_SIZE;
-	_sl.buf = _sl.buf_ori = (byte*)malloc(LZO_SIZE);
+	_sl.buf = _sl.buf_ori = MallocT<byte>(LZO_SIZE);
 	return true;
 }
 
@@ -1085,7 +1090,7 @@
 static bool InitNoComp()
 {
 	_sl.bufsize = LZO_SIZE;
-	_sl.buf = _sl.buf_ori = (byte*)malloc(LZO_SIZE);
+	_sl.buf = _sl.buf_ori = MallocT<byte>(LZO_SIZE);
 	return true;
 }
 
@@ -1099,7 +1104,6 @@
  ********************************************/
 
 #include "table/sprites.h"
-#include "gfx.h"
 #include "gui.h"
 
 struct ThreadedSave {
@@ -1154,7 +1158,7 @@
 	if (inflateInit(&_z) != Z_OK) return false;
 
 	_sl.bufsize = 4096;
-	_sl.buf = _sl.buf_ori = (byte*)malloc(4096 + 4096); // also contains fread buffer
+	_sl.buf = _sl.buf_ori = MallocT<byte>(4096 + 4096); // also contains fread buffer
 	return true;
 }
 
@@ -1194,7 +1198,7 @@
 	if (deflateInit(&_z, 6) != Z_OK) return false;
 
 	_sl.bufsize = 4096;
-	_sl.buf = _sl.buf_ori = (byte*)malloc(4096); // also contains fread buffer
+	_sl.buf = _sl.buf_ori = MallocT<byte>(4096); // also contains fread buffer
 	return true;
 }
 
--- a/src/screenshot.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/screenshot.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,20 +3,21 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "strings.h"
 #include "table/strings.h"
-#include "gfx.h"
 #include "fileio.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "player.h"
 #include "screenshot.h"
 #include "variables.h"
-#include "date.h"
-#include "string.h"
-#include "helpers.hpp"
 #include "blitter/factory.hpp"
 #include "fileio.h"
+#include "strings_func.h"
+#include "zoom_func.h"
+#include "core/alloc_func.hpp"
+#include "core/endian_func.hpp"
+#include "map_func.h"
+#include "date_func.h"
 
 char _screenshot_format_name[8];
 uint _num_screenshot_formats;
--- a/src/settings.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/settings.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -22,16 +22,11 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
-#include "macros.h"
 #include "screenshot.h"
-#include "sound.h"
-#include "string.h"
 #include "variables.h"
 #include "network/network.h"
-#include "strings.h"
-#include "settings.h"
-#include "command.h"
+#include "settings_internal.h"
+#include "command_func.h"
 #include "console.h"
 #include "saveload.h"
 #include "npf.h"
@@ -39,19 +34,25 @@
 #include "newgrf.h"
 #include "newgrf_config.h"
 #include "genworld.h"
-#include "date.h"
 #include "rail.h"
 #include "train.h"
-#include "helpers.hpp"
 #include "news.h"
+#include "window_func.h"
+#include "strings_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "core/alloc_func.hpp"
 #ifdef WITH_FREETYPE
-#include "gfx.h"
 #include "fontcache.h"
 #endif
 #include "spritecache.h"
 #include "transparency.h"
+#include "string_func.h"
 
-/** The patch values that are used for new games and/or modified in config file */
+GameOptions _opt;
+GameOptions _opt_newgame;
+GameOptions *_opt_ptr;
+Patches _patches;
 Patches _patches_newgame;
 
 struct IniFile;
@@ -80,7 +81,7 @@
 	SettingsMemoryPool *p;
 	if (minsize < 4096 - 12) minsize = 4096 - 12;
 
-	p = (SettingsMemoryPool*)malloc(sizeof(SettingsMemoryPool) - 1 + minsize);
+	p = (SettingsMemoryPool*)MallocT<byte>(sizeof(SettingsMemoryPool) - 1 + minsize);
 	p->pos = 0;
 	p->size = minsize;
 	p->next = NULL;
@@ -1086,10 +1087,8 @@
 #include "table/strings.h"
 
 /* Begin - Callback Functions for the various settings */
-#include "window.h"
 #include "gui.h"
 #include "town.h"
-#include "gfx.h"
 /* virtual PositionMainToolbar function, calls the right one.*/
 static int32 v_PositionMainToolbar(int32 p1)
 {
@@ -1149,15 +1148,15 @@
 	const Patches *ptc = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
 
 	if (p1) {
-		warning = ( (IS_INT_INSIDE(ptc->servint_trains,   5, 90 + 1) || ptc->servint_trains   == 0) &&
-								(IS_INT_INSIDE(ptc->servint_roadveh,  5, 90 + 1) || ptc->servint_roadveh  == 0) &&
-								(IS_INT_INSIDE(ptc->servint_aircraft, 5, 90 + 1) || ptc->servint_aircraft == 0) &&
-								(IS_INT_INSIDE(ptc->servint_ships,    5, 90 + 1) || ptc->servint_ships    == 0) );
+		warning = ( (IsInsideMM(ptc->servint_trains,   5, 90 + 1) || ptc->servint_trains   == 0) &&
+								(IsInsideMM(ptc->servint_roadveh,  5, 90 + 1) || ptc->servint_roadveh  == 0) &&
+								(IsInsideMM(ptc->servint_aircraft, 5, 90 + 1) || ptc->servint_aircraft == 0) &&
+								(IsInsideMM(ptc->servint_ships,    5, 90 + 1) || ptc->servint_ships    == 0) );
 	} else {
-		warning = ( (IS_INT_INSIDE(ptc->servint_trains,   30, 800 + 1) || ptc->servint_trains   == 0) &&
-								(IS_INT_INSIDE(ptc->servint_roadveh,  30, 800 + 1) || ptc->servint_roadveh  == 0) &&
-								(IS_INT_INSIDE(ptc->servint_aircraft, 30, 800 + 1) || ptc->servint_aircraft == 0) &&
-								(IS_INT_INSIDE(ptc->servint_ships,    30, 800 + 1) || ptc->servint_ships    == 0) );
+		warning = ( (IsInsideMM(ptc->servint_trains,   30, 800 + 1) || ptc->servint_trains   == 0) &&
+								(IsInsideMM(ptc->servint_roadveh,  30, 800 + 1) || ptc->servint_roadveh  == 0) &&
+								(IsInsideMM(ptc->servint_aircraft, 30, 800 + 1) || ptc->servint_aircraft == 0) &&
+								(IsInsideMM(ptc->servint_ships,    30, 800 + 1) || ptc->servint_ships    == 0) );
 	}
 
 	if (!warning)
@@ -1288,6 +1287,7 @@
 	  SDTG_STR("player_name",           SLE_STRB, S, 0, _network_player_name,          NULL,               STR_NULL, NULL),
 	  SDTG_STR("server_password",       SLE_STRB, S, 0, _network_server_password,      NULL,               STR_NULL, NULL),
 	  SDTG_STR("rcon_password",         SLE_STRB, S, 0, _network_rcon_password,        NULL,               STR_NULL, NULL),
+	  SDTG_STR("default_company_pass",  SLE_STRB, S, 0, _network_default_company_pass, NULL,               STR_NULL, NULL),
 	  SDTG_STR("server_name",           SLE_STRB, S, 0, _network_server_name,          NULL,               STR_NULL, NULL),
 	  SDTG_STR("connect_to_ip",         SLE_STRB, S, 0, _network_default_ip,           NULL,               STR_NULL, NULL),
 	  SDTG_STR("network_id",            SLE_STRB, S, 0, _network_unique_id,            NULL,               STR_NULL, NULL),
@@ -1358,10 +1358,6 @@
 	SDT_BOOL(Patches, prefer_teamchat,               S, 0, false,        STR_CONFIG_PATCHES_PREFER_TEAMCHAT,       NULL),
 	SDT_VAR(Patches, scrollwheel_scrolling,SLE_UINT8,S,MS, 0,  0,  2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING, NULL),
 	SDT_VAR(Patches,scrollwheel_multiplier,SLE_UINT8,S, 0, 5,  1, 15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,NULL),
-#ifdef __APPLE__
-	/* We might need to emulate a right mouse button on mac */
-	SDT_VAR(Patches,right_mouse_btn_emulation,SLE_UINT8,S,MS,0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU,   NULL),
-#endif
 	SDT_BOOL(Patches, pause_on_newgame,              S, 0, false,        STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME,     NULL),
 	 SDT_VAR(Patches,advanced_vehicle_list,SLE_UINT8,S,MS, 1,  0,  2, 0, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS,NULL),
 	SDT_BOOL(Patches, timetable_in_ticks,            S, 0, false,        STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS,    NULL),
@@ -1376,6 +1372,7 @@
 	SDT_BOOL(Patches, longbridges,                   0,NN,  true,        STR_CONFIG_PATCHES_LONGBRIDGES,         NULL),
 	SDT_BOOL(Patches, signal_side,                   N,NN,  true,        STR_CONFIG_PATCHES_SIGNALSIDE,          RedrawScreen),
 	SDT_BOOL(Patches, always_small_airport,          0,NN, false,        STR_CONFIG_PATCHES_SMALL_AIRPORTS,      NULL),
+	SDT_BOOL(Patches, enable_signal_gui,             S, 0, false,        STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI,   NULL),
 	 SDT_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0,  4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,NULL),
 	 SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, NULL),
 	SDT_CONDVAR(Patches, town_layout, SLE_UINT8, 59, SL_MAX_VERSION, 0, MS, TL_ORIGINAL, TL_NO_ROADS, NUM_TLS - 1, 1, STR_CONFIG_PATCHES_TOWN_LAYOUT, CheckTownLayout),
@@ -1574,6 +1571,18 @@
 	SDT_VAR    (Patches,      heightmap_rotation,       SLE_UINT8,                      S, MS,   0,                   0,    1,               0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION,       NULL),
 	SDT_VAR    (Patches,      se_flat_world_height,     SLE_UINT8,                      S, 0,    0,                   0,   15,               0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT,     NULL),
 
+	/*
+	 * Since the network code (CmdChangePatchSetting and friends) use the index in this array to decide
+	 * which patch the server is talking about all conditional compilation of this array must be at the
+	 * end. This isn't really the best solution, the patches the server can tell the client about should
+	 * either use a seperate array or some other form of identifier.
+	 */
+
+#ifdef __APPLE__
+	/* We might need to emulate a right mouse button on mac */
+	SDT_VAR(Patches,right_mouse_btn_emulation,SLE_UINT8,S,MS,0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU,   NULL),
+#endif
+
 	SDT_END()
 };
 
@@ -1798,6 +1807,7 @@
 	if (sd == NULL) return CMD_ERROR;
 	if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) return CMD_ERROR;
 
+	if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return CMD_ERROR;
 	if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return CMD_ERROR;
 
 	if (flags & DC_EXEC) {
--- a/src/settings.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/* $Id$ */
-
-/** @file settings.h */
-
-#ifndef SETTINGS_H
-#define SETTINGS_H
-
-#include "saveload.h"
-
-/** Convention/Type of settings. This is then further specified if necessary
- * with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h
- * @see VarTypes
- * @see SettingDescBase */
-enum SettingDescTypeLong {
-	/* 4 bytes allocated a maximum of 16 types for GenericType */
-	SDT_BEGIN       = 0,
-	SDT_NUMX        = 0, ///< any number-type
-	SDT_BOOLX       = 1, ///< a boolean number
-	SDT_ONEOFMANY   = 2, ///< bitmasked number where only ONE bit may be set
-	SDT_MANYOFMANY  = 3, ///< bitmasked number where MULTIPLE bits may be set
-	SDT_INTLIST     = 4, ///< list of integers seperated by a comma ','
-	SDT_STRING      = 5, ///< string with a pre-allocated buffer
-	SDT_END,
-	/* 10 more possible primitives */
-};
-
-template <> struct EnumPropsT<SettingDescTypeLong> : MakeEnumPropsT<SettingDescTypeLong, byte, SDT_BEGIN, SDT_END, SDT_END> {};
-typedef TinyEnumT<SettingDescTypeLong> SettingDescType;
-
-
-enum SettingGuiFlagLong {
-	/* 8 bytes allocated for a maximum of 8 flags
-	 * Flags directing saving/loading of a variable */
-	SGF_NONE = 0,
-	SGF_0ISDISABLED  = 1 << 0, ///< a value of zero means the feature is disabled
-	SGF_NOCOMMA      = 1 << 1, ///< number without any thousand seperators (no formatting)
-	SGF_MULTISTRING  = 1 << 2, ///< the value represents a limited number of string-options (internally integer)
-	SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
-	SGF_CURRENCY     = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
-	SGF_NO_NETWORK   = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
-	SGF_END          = 1 << 6,
-	/* 3 more possible flags */
-};
-
-DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong);
-template <> struct EnumPropsT<SettingGuiFlagLong> : MakeEnumPropsT<SettingGuiFlagLong, byte, SGF_NONE, SGF_END, SGF_END> {};
-typedef TinyEnumT<SettingGuiFlagLong> SettingGuiFlag;
-
-
-typedef int32 OnChange(int32 var);          ///< callback prototype on data modification
-typedef int32 OnConvert(const char *value); ///< callback prototype for convertion error
-
-struct SettingDescBase {
-	const char *name;       ///< name of the setting. Used in configuration file and for console
-	const void *def;        ///< default value given when none is present
-	SettingDescType cmd;    ///< various flags for the variable
-	SettingGuiFlag flags;   ///< handles how a setting would show up in the GUI (text/currency, etc.)
-	int32 min, max;         ///< minimum and maximum values
-	int32 interval;         ///< the interval to use between settings in the 'patches' window. If interval is '0' the interval is dynamically determined
-	const char *many;       ///< ONE/MANY_OF_MANY: string of possible values for this type
-	StringID str;           ///< (translated) string with descriptive text; gui and console
-	OnChange *proc;         ///< callback procedure for when the value is changed
-	OnConvert *proc_cnvt;   ///< callback procedure when loading value mechanism fails
-};
-
-struct SettingDesc {
-	SettingDescBase desc;   ///< Settings structure (going to configuration file)
-	SaveLoad save;          ///< Internal structure (going to savegame, parts to config)
-};
-
-/* NOTE: The only difference between SettingDesc and SettingDescGlob is
- * that one uses global variables as a source and the other offsets
- * in a struct which are bound to a certain variable during runtime.
- * The only way to differentiate between these two is to check if an object
- * has been passed to the function or not. If not, then it is a global variable
- * and save->variable has its address, otherwise save->variable only holds the
- * offset in a certain struct */
-typedef SettingDesc SettingDescGlobVarList;
-
-enum IniGroupType {
-	IGT_VARIABLES = 0, ///< values of the form "landscape = hilly"
-	IGT_LIST      = 1, ///< a list of values, seperated by \n and terminated by the next group block
-};
-
-/** The patch values that are used for new games and/or modified in config file */
-extern Patches _patches_newgame;
-
-bool IConsoleSetPatchSetting(const char *name, int32 value);
-void IConsoleGetPatchSetting(const char *name);
-void IConsoleListPatches();
-const SettingDesc *GetPatchFromName(const char *name, uint *i);
-bool SetPatchValue(uint index, const Patches *object, int32 value);
-
-#endif /* SETTINGS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/settings_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,17 @@
+/* $Id$ */
+
+/** @file settings_func.h Functions related to setting/changing the settings. */
+
+#ifndef SETTINGS_FUNC_H
+#define SETTINGS_FUNC_H
+
+bool IConsoleSetPatchSetting(const char *name, int32 value);
+void IConsoleGetPatchSetting(const char *name);
+void IConsoleListPatches();
+
+void LoadFromConfig();
+void SaveToConfig();
+void CheckConfig();
+void UpdatePatches();
+
+#endif /* SETTINGS_FUNC_H */
--- a/src/settings_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/settings_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,26 +5,27 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
-#include "string.h"
-#include "strings.h" // XXX GetCurrentCurrencyRate()
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "window.h"
 #include "gui.h"
-#include "gfx.h"
-#include "command.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
+#include "command_func.h"
 #include "engine.h"
 #include "screenshot.h"
 #include "newgrf.h"
 #include "network/network.h"
 #include "town.h"
 #include "variables.h"
-#include "settings.h"
-#include "vehicle.h"
-#include "date.h"
-#include "helpers.hpp"
+#include "settings_internal.h"
 #include "newgrf_townname.h"
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#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;
@@ -131,147 +132,191 @@
 }
 
 
+enum GameOptionsWidgets {
+	GAMEOPT_CURRENCY_TXT    =  4,
+	GAMEOPT_CURRENCY_BTN,
+	GAMEOPT_DISTANCE_TXT    =  7,
+	GAMEOPT_DISTANCE_BTN,
+	GAMEOPT_ROADSIDE_TXT    = 10,
+	GAMEOPT_ROADSIDE_BTN,
+	GAMEOPT_TOWNNAME_TXT    = 13,
+	GAMEOPT_TOWNNAME_BTN,
+	GAMEOPT_AUTOSAVE_TXT    = 16,
+	GAMEOPT_AUTOSAVE_BTN,
+	GAMEOPT_VEHICLENAME_TXT = 19,
+	GAMEOPT_VEHICLENAME_BTN,
+	GAMEOPT_VEHICLENAME_SAVE,
+	GAMEOPT_LANG_TXT        = 23,
+	GAMEOPT_LANG_BTN,
+	GAMEOPT_RESOLUTION_TXT  = 26,
+	GAMEOPT_RESOLUTION_BTN,
+	GAMEOPT_FULLSCREEN,
+	GAMEOPT_SCREENSHOT_TXT  = 30,
+	GAMEOPT_SCREENSHOT_BTN,
+};
+
 static void ShowCustCurrency();
 
 static void GameOptionsWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-	case WE_PAINT: {
-		int i;
-		StringID str = STR_02BE_DEFAULT;
-
-		SetWindowWidgetDisabledState(w, 21, !(_vehicle_design_names & 1));
-		if (!IsWindowWidgetDisabled(w, 21)) str = STR_02BF_CUSTOM;
-		SetDParam(0, str);
-		SetDParam(1, _currency_specs[_opt_ptr->currency].name);
-		SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units);
-		SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side);
-		SetDParam(4, TownName(_opt_ptr->town_name));
-		SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]);
-		SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
-		i = GetCurRes();
-		SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
-		SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
-		SetWindowWidgetLoweredState(w, 28, _fullscreen);
-
-		DrawWindowWidgets(w);
-		DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen
-	} break;
-
-	case WE_CLICK:
-		switch (e->we.click.widget) {
-		case 4: case 5: /* Setup currencies dropdown */
-			ShowDropDownMenu(w, BuildCurrencyDropdown(), _opt_ptr->currency, 5, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);;
-			return;
-		case 7: case 8: /* Setup distance unit dropdown */
-			ShowDropDownMenu(w, _units_dropdown, _opt_ptr->units, 8, 0, 0);
-			return;
-		case 10: case 11: { /* Setup road-side dropdown */
-			int i = 0;
-
-			/* You can only change the drive side if you are in the menu or ingame with
-			 * no vehicles present. In a networking game only the server can change it */
-			if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server))
-				i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value
+		case WE_PAINT: {
+			int i;
+			StringID str = STR_02BE_DEFAULT;
 
-			ShowDropDownMenu(w, _driveside_dropdown, _opt_ptr->road_side, 11, i, 0);
-		} return;
-		case 13: case 14: { /* Setup townname dropdown */
-			uint sel = 0;
-			for (uint i = 0; _town_names[i] != INVALID_STRING_ID; i++) {
-				if (_town_names[i] == TownName(_opt_ptr->town_name)) {
-					sel = i;
+			w->SetWidgetDisabledState(21, !(_vehicle_design_names & 1));
+			if (!w->IsWidgetDisabled(21)) str = STR_02BF_CUSTOM;
+			SetDParam(0, str);
+			SetDParam(1, _currency_specs[_opt_ptr->currency].name);
+			SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units);
+			SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side);
+			SetDParam(4, TownName(_opt_ptr->town_name));
+			SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]);
+			SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
+			i = GetCurRes();
+			SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
+			SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
+			w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
+
+			DrawWindowWidgets(w);
+			DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen
+		} break;
+
+		case WE_CLICK:
+			switch (e->we.click.widget) {
+				case GAMEOPT_CURRENCY_TXT: case GAMEOPT_CURRENCY_BTN: /* Setup currencies dropdown */
+					ShowDropDownMenu(w, BuildCurrencyDropdown(), _opt_ptr->currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
 					break;
-				}
-			}
-			ShowDropDownMenu(w, _town_names, sel, 14, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << sel), 0);
-			return;
-		}
-		case 16: case 17: /* Setup autosave dropdown */
-			ShowDropDownMenu(w, _autosave_dropdown, _opt_ptr->autosave, 17, 0, 0);
-			return;
-		case 19: case 20: /* Setup customized vehicle-names dropdown */
-			ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, 20, (_vehicle_design_names & 2) ? 0 : 2, 0);
-			return;
-		case 21: /* Save customized vehicle-names to disk */
-			return;
-		case 23: case 24: /* Setup interface language dropdown */
-			ShowDropDownMenu(w, _dynlang.dropdown, _dynlang.curr, 24, 0, 0);
-			return;
-		case 26: case 27: /* Setup resolution dropdown */
-			ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), 27, 0, 0);
-			return;
-		case 28: /* Click fullscreen on/off */
-			SetWindowWidgetLoweredState(w, 28, !_fullscreen);
-			ToggleFullScreen(!_fullscreen); // toggle full-screen on/off
-			SetWindowDirty(w);
-			return;
-		case 30: case 31: /* Setup screenshot format dropdown */
-			ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, 31, 0, 0);
-			return;
-		}
-		break;
 
-	case WE_DROPDOWN_SELECT:
-		switch (e->we.dropdown.button) {
-		case 20: /* Vehicle design names */
-			if (e->we.dropdown.index == 0) {
-				DeleteCustomEngineNames();
-				MarkWholeScreenDirty();
-			} else if (!(_vehicle_design_names & 1)) {
-				LoadCustomEngineNames();
-				MarkWholeScreenDirty();
+				case GAMEOPT_DISTANCE_TXT: case GAMEOPT_DISTANCE_BTN: /* Setup distance unit dropdown */
+					ShowDropDownMenu(w, _units_dropdown, _opt_ptr->units, GAMEOPT_DISTANCE_BTN, 0, 0);
+					break;
+
+				case GAMEOPT_ROADSIDE_TXT: case GAMEOPT_ROADSIDE_BTN: { /* Setup road-side dropdown */
+					int i = 0;
+
+					/* You can only change the drive side if you are in the menu or ingame with
+					 * no vehicles present. In a networking game only the server can change it */
+					if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server))
+						i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value
+
+					ShowDropDownMenu(w, _driveside_dropdown, _opt_ptr->road_side, GAMEOPT_ROADSIDE_BTN, i, 0);
+				} break;
+
+				case GAMEOPT_TOWNNAME_TXT: case GAMEOPT_TOWNNAME_BTN: { /* Setup townname dropdown */
+					uint sel = 0;
+					for (uint i = 0; _town_names[i] != INVALID_STRING_ID; i++) {
+						if (_town_names[i] == TownName(_opt_ptr->town_name)) {
+							sel = i;
+							break;
+						}
+					}
+					ShowDropDownMenu(w, _town_names, sel, GAMEOPT_TOWNNAME_BTN, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << sel), 0);
+				} break;
+
+				case GAMEOPT_AUTOSAVE_TXT: case GAMEOPT_AUTOSAVE_BTN: /* Setup autosave dropdown */
+					ShowDropDownMenu(w, _autosave_dropdown, _opt_ptr->autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0);
+					break;
+
+				case GAMEOPT_VEHICLENAME_TXT: case GAMEOPT_VEHICLENAME_BTN: /* Setup customized vehicle-names dropdown */
+					ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, GAMEOPT_VEHICLENAME_BTN, (_vehicle_design_names & 2) ? 0 : 2, 0);
+					break;
+
+				case GAMEOPT_VEHICLENAME_SAVE: /* Save customized vehicle-names to disk */
+					break;  // not implemented
+
+				case GAMEOPT_LANG_TXT: case GAMEOPT_LANG_BTN: /* Setup interface language dropdown */
+					ShowDropDownMenu(w, _dynlang.dropdown, _dynlang.curr, GAMEOPT_LANG_BTN, 0, 0);
+					break;
+
+				case GAMEOPT_RESOLUTION_TXT: case GAMEOPT_RESOLUTION_BTN: /* Setup resolution dropdown */
+					ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), GAMEOPT_RESOLUTION_BTN, 0, 0);
+					break;
+
+				case GAMEOPT_FULLSCREEN: /* Click fullscreen on/off */
+					/* try to toggle full-screen on/off */
+					if (!ToggleFullScreen(!_fullscreen)) {
+						ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0);
+					}
+					w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
+					SetWindowDirty(w);
+					break;
+
+				case GAMEOPT_SCREENSHOT_TXT: case GAMEOPT_SCREENSHOT_BTN: /* Setup screenshot format dropdown */
+					ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GAMEOPT_SCREENSHOT_BTN, 0, 0);
+					break;
 			}
 			break;
-		case 5: /* Currency */
-			if (e->we.dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
-			_opt_ptr->currency = e->we.dropdown.index;
-			MarkWholeScreenDirty();
-			break;
-		case 8: /* Measuring units */
-			_opt_ptr->units = e->we.dropdown.index;
-			MarkWholeScreenDirty();
-			break;
-		case 11: /* Road side */
-			if (_opt_ptr->road_side != e->we.dropdown.index) { // only change if setting changed
-				DoCommandP(0, e->we.dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
-				MarkWholeScreenDirty();
+
+		case WE_DROPDOWN_SELECT:
+			switch (e->we.dropdown.button) {
+				case GAMEOPT_VEHICLENAME_BTN: /* Vehicle design names */
+					if (e->we.dropdown.index == 0) {
+						DeleteCustomEngineNames();
+						MarkWholeScreenDirty();
+					} else if (!(_vehicle_design_names & 1)) {
+						LoadCustomEngineNames();
+						MarkWholeScreenDirty();
+					}
+					break;
+
+				case GAMEOPT_CURRENCY_BTN: /* Currency */
+					if (e->we.dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
+					_opt_ptr->currency = e->we.dropdown.index;
+					MarkWholeScreenDirty();
+					break;
+
+				case GAMEOPT_DISTANCE_BTN: /* Measuring units */
+					_opt_ptr->units = e->we.dropdown.index;
+					MarkWholeScreenDirty();
+					break;
+
+				case GAMEOPT_ROADSIDE_BTN: /* Road side */
+					if (_opt_ptr->road_side != e->we.dropdown.index) { // only change if setting changed
+						DoCommandP(0, e->we.dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
+						MarkWholeScreenDirty();
+					}
+					break;
+
+				case GAMEOPT_TOWNNAME_BTN: /* Town names */
+					if (_game_mode == GM_MENU) {
+						for (uint i = 0; _town_names[i] != INVALID_STRING_ID; i++) {
+							if (_town_names[e->we.dropdown.index] == TownName(i)) {
+								_opt_ptr->town_name = i;
+								break;
+							}
+						}
+						InvalidateWindow(WC_GAME_OPTIONS, 0);
+					}
+					break;
+
+				case GAMEOPT_AUTOSAVE_BTN: /* Autosave options */
+					_opt.autosave = _opt_newgame.autosave = e->we.dropdown.index;
+					SetWindowDirty(w);
+					break;
+
+				case GAMEOPT_LANG_BTN: /* Change interface language */
+					ReadLanguagePack(e->we.dropdown.index);
+					CheckForMissingGlyphsInLoadedLanguagePack();
+					UpdateAllStationVirtCoord();
+					MarkWholeScreenDirty();
+					break;
+
+				case GAMEOPT_RESOLUTION_BTN: /* Change resolution */
+					if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0],_resolutions[e->we.dropdown.index][1]))
+						SetWindowDirty(w);
+					break;
+
+				case GAMEOPT_SCREENSHOT_BTN: /* Change screenshot format */
+					SetScreenshotFormat(e->we.dropdown.index);
+					SetWindowDirty(w);
+					break;
 			}
 			break;
-		case 14: /* Town names */
-			if (_game_mode == GM_MENU) {
-				for (uint i = 0; _town_names[i] != INVALID_STRING_ID; i++) {
-					if (_town_names[e->we.dropdown.index] == TownName(i)) {
-						_opt_ptr->town_name = i;
-						break;
-					}
-				}
-				InvalidateWindow(WC_GAME_OPTIONS, 0);
-			}
-			break;
-		case 17: /* Autosave options */
-			_opt.autosave = _opt_newgame.autosave = e->we.dropdown.index;
-			SetWindowDirty(w);
+
+		case WE_DESTROY:
+			DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
 			break;
-		case 24: /* Change interface language */
-			ReadLanguagePack(e->we.dropdown.index);
-			UpdateAllStationVirtCoord();
-			MarkWholeScreenDirty();
-			break;
-		case 27: /* Change resolution */
-			if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0],_resolutions[e->we.dropdown.index][1]))
-				SetWindowDirty(w);
-			break;
-		case 31: /* Change screenshot format */
-			SetScreenshotFormat(e->we.dropdown.index);
-			SetWindowDirty(w);
-			break;
-		}
-		break;
-
-	case WE_DESTROY:
-		DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
-		break;
 	}
 
 }
@@ -447,171 +492,187 @@
 // 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
 #define DIFF_INGAME_DISABLED_BUTTONS 0x383E
 
+/* Names of the game difficulty settings window */
+enum GameDifficultyWidgets {
+	GDW_CLOSEBOX = 0,
+	GDW_CAPTION,
+	GDW_UPPER_BG,
+	GDW_LVL_EASY,
+	GDW_LVL_MEDIUM,
+	GDW_LVL_HARD,
+	GDW_LVL_CUSTOM,
+	GDW_HIGHSCORE,
+	GDW_SETTING_BG,
+	GDW_LOWER_BG,
+	GDW_ACCEPT,
+	GDW_CANCEL,
+};
+
 static void GameDifficultyWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
-	case WE_CREATE: // Setup disabled buttons when creating window
-		/* disable all other difficulty buttons during gameplay except for 'custom' */
-		SetWindowWidgetDisabledState(w,  3, _game_mode == GM_NORMAL);
-		SetWindowWidgetDisabledState(w,  4, _game_mode == GM_NORMAL);
-		SetWindowWidgetDisabledState(w,  5, _game_mode == GM_NORMAL);
-		SetWindowWidgetDisabledState(w,  6, _game_mode == GM_NORMAL);
-		SetWindowWidgetDisabledState(w,  7, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
-		SetWindowWidgetDisabledState(w, 10, _networking && !_network_server); // Save-button in multiplayer (and if client)
-		LowerWindowWidget(w, _opt_mod_temp.diff_level + 3);
-
-		break;
-	case WE_PAINT: {
-		uint32 click_a, click_b, disabled;
-		int i;
-		int y, value;
+		case WE_CREATE:
+			/* Hide the closebox to make sure that the user aborts or confirms his changes */
+			w->HideWidget(GDW_CLOSEBOX);
+			w->widget[GDW_CAPTION].left = 0;
+			/* Setup disabled buttons when creating window
+			 * disable all other difficulty buttons during gameplay except for 'custom' */
+			w->SetWidgetsDisabledState(_game_mode == GM_NORMAL,
+				GDW_LVL_EASY,
+				GDW_LVL_MEDIUM,
+				GDW_LVL_HARD,
+				GDW_LVL_CUSTOM,
+				WIDGET_LIST_END);
+			w->SetWidgetDisabledState(GDW_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
+			w->SetWidgetDisabledState(GDW_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client)
+			w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
+			break;
 
-		DrawWindowWidgets(w);
-
-		click_a = _difficulty_click_a;
-		click_b = _difficulty_click_b;
+		case WE_PAINT: {
+			DrawWindowWidgets(w);
 
-		/* XXX - Disabled buttons in normal gameplay. Bitshifted for each button to see if
-		 * that bit is set. If it is set, the button is disabled */
-		disabled = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0;
-
-		y = GAMEDIFF_WND_TOP_OFFSET;
-		for (i = 0; i != GAME_DIFFICULTY_NUM; i++) {
-			DrawFrameRect( 5, y,  5 + 8, y + 8, 3, HasBit(click_a, i) ? FR_LOWERED : FR_NONE);
-			DrawFrameRect(15, y, 15 + 8, y + 8, 3, HasBit(click_b, i) ? FR_LOWERED : FR_NONE);
-			if (HasBit(disabled, i) || (_networking && !_network_server)) {
-				int color = (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[COLOUR_YELLOW][2];
-				GfxFillRect( 6, y + 1,  6 + 8, y + 8, color);
-				GfxFillRect(16, y + 1, 16 + 8, y + 8, color);
+			/* XXX - Disabled buttons in normal gameplay or during muliplayer as non server.
+			 *       Bitshifted for each button to see if that bit is set. If it is set, the
+			 *       button is disabled */
+			uint32 disabled = 0;
+			if (_networking && !_network_server) {
+				disabled = MAX_UVALUE(uint32); // Disable all
+			} else if (_game_mode == GM_NORMAL) {
+				disabled = DIFF_INGAME_DISABLED_BUTTONS;
 			}
 
-			DrawStringCentered(10, y, STR_6819, TC_FROMSTRING);
-			DrawStringCentered(20, y, STR_681A, TC_FROMSTRING);
-
-
-			value = _game_setting_info[i].str + ((GDType*)&_opt_mod_temp.diff)[i];
-			if (i == 4) value *= 1000; // XXX - handle currency option
-			SetDParam(0, value);
-			DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, TC_FROMSTRING);
-
-			y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit
-		}
-	} break;
-
-	case WE_CLICK:
-		switch (e->we.click.widget) {
-		case 8: { /* Difficulty settings widget, decode click */
-			const GameSettingData *info;
-			int x, y;
-			uint btn, dis;
-			int16 val;
-
-			/* Don't allow clients to make any changes */
-			if  (_networking && !_network_server)
-				return;
-
-			x = e->we.click.pt.x - 5;
-			if (!IS_INT_INSIDE(x, 0, 21)) // Button area
-				return;
-
-			y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET;
-			if (y < 0)
-				return;
-
-			/* Get button from Y coord. */
-			btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
-			if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9)
-				return;
-
-			/* Clicked disabled button? */
-			dis = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0;
-
-			if (HasBit(dis, btn))
-				return;
-
-			_difficulty_timeout = 5;
-
-			val = ((GDType*)&_opt_mod_temp.diff)[btn];
+			int value;
+			int y = GAMEDIFF_WND_TOP_OFFSET;
+			for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) {
+				const GameSettingData *gsd = &_game_setting_info[i];
+				value = ((GDType*)&_opt_mod_temp.diff)[i];
 
-			info = &_game_setting_info[btn]; // get information about the difficulty setting
-			if (x >= 10) {
-				// Increase button clicked
-				val = min(val + info->step, info->max);
-				SetBit(_difficulty_click_b, btn);
-			} else {
-				// Decrease button clicked
-				val -= info->step;
-				val = max(val,  info->min);
-				SetBit(_difficulty_click_a, btn);
-			}
+				DrawArrowButtons(5, y, 3,
+						!!HasBit(_difficulty_click_a, i) | !!HasBit(_difficulty_click_b, i) << 1,
+						!(HasBit(disabled, i) || gsd->min == value),
+						!(HasBit(disabled, i) || gsd->max == value));
 
-			// save value in temporary variable
-			((GDType*)&_opt_mod_temp.diff)[btn] = val;
-			RaiseWindowWidget(w, _opt_mod_temp.diff_level + 3);
-			SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
-			LowerWindowWidget(w, _opt_mod_temp.diff_level + 3);
-			SetWindowDirty(w);
+				value += _game_setting_info[i].str;
+				if (i == 4) value *= 1000; // XXX - handle currency option
+				SetDParam(0, value);
+				DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, TC_FROMSTRING);
+
+				y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit
+			}
 		} break;
-		case 3: case 4: case 5: case 6: /* Easy / Medium / Hard / Custom */
-			// temporarily change difficulty level
-			RaiseWindowWidget(w, _opt_mod_temp.diff_level + 3);
-			SetDifficultyLevel(e->we.click.widget - 3, &_opt_mod_temp);
-			LowerWindowWidget(w, _opt_mod_temp.diff_level + 3);
-			SetWindowDirty(w);
-			break;
-		case 7: /* Highscore Table */
-			ShowHighscoreTable(_opt_mod_temp.diff_level, -1);
+
+		case WE_CLICK:
+			switch (e->we.click.widget) {
+				case GDW_SETTING_BG: { /* Difficulty settings widget, decode click */
+					/* Don't allow clients to make any changes */
+					if (_networking && !_network_server) return;
+
+					const int x = e->we.click.pt.x - 5;
+					if (!IsInsideMM(x, 0, 21)) // Button area
+						return;
+
+					const int y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET;
+					if (y < 0) return;
+
+					/* Get button from Y coord. */
+					const uint btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
+					if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9)
+						return;
+
+					/* Clicked disabled button? */
+					if (_game_mode == GM_NORMAL && HasBit(DIFF_INGAME_DISABLED_BUTTONS, btn))
+						return;
+
+					_difficulty_timeout = 5;
+
+					int16 val = ((GDType*)&_opt_mod_temp.diff)[btn];
+
+					const GameSettingData *info = &_game_setting_info[btn]; // get information about the difficulty setting
+					if (x >= 10) {
+						/* Increase button clicked */
+						val = min(val + info->step, info->max);
+						SetBit(_difficulty_click_b, btn);
+					} else {
+						/* Decrease button clicked */
+						val -= info->step;
+						val = max(val,  info->min);
+						SetBit(_difficulty_click_a, btn);
+					}
+
+					/* save value in temporary variable */
+					((GDType*)&_opt_mod_temp.diff)[btn] = val;
+					w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
+					SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
+					w->LowerWidget(GDW_LVL_CUSTOM);
+					SetWindowDirty(w);
+				} break;
+
+				case GDW_LVL_EASY:
+				case GDW_LVL_MEDIUM:
+				case GDW_LVL_HARD:
+				case GDW_LVL_CUSTOM:
+					/* temporarily change difficulty level */
+					w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
+					SetDifficultyLevel(e->we.click.widget - GDW_LVL_EASY, &_opt_mod_temp);
+					w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
+					SetWindowDirty(w);
+					break;
+
+				case GDW_HIGHSCORE: // Highscore Table
+					ShowHighscoreTable(_opt_mod_temp.diff_level, -1);
+					break;
+
+				case GDW_ACCEPT: { // Save button - save changes
+					GDType btn, val;
+					for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
+						val = ((GDType*)&_opt_mod_temp.diff)[btn];
+						/* if setting has changed, change it */
+						if (val != ((GDType*)&_opt_ptr->diff)[btn])
+							DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+					}
+					DoCommandP(0, UINT_MAX, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+					DeleteWindow(w);
+					/* If we are in the editor, we should reload the economy.
+					 * This way when you load a game, the max loan and interest rate
+					 * are loaded correctly. */
+					if (_game_mode == GM_EDITOR) StartupEconomy();
+					break;
+				}
+
+				case GDW_CANCEL: // Cancel button - close window, abandon changes
+					DeleteWindow(w);
+					break;
+			} break;
+
+		case WE_MOUSELOOP: /* Handle the visual 'clicking' of the buttons */
+			if (_difficulty_timeout != 0 && !--_difficulty_timeout) {
+				_difficulty_click_a = 0;
+				_difficulty_click_b = 0;
+				SetWindowDirty(w);
+			}
 			break;
-		case 10: { /* Save button - save changes */
-			GDType btn, val;
-			for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
-				val = ((GDType*)&_opt_mod_temp.diff)[btn];
-				// if setting has changed, change it
-				if (val != ((GDType*)&_opt_ptr->diff)[btn])
-					DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
-			}
-			DoCommandP(0, UINT_MAX, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
-			DeleteWindow(w);
-			// If we are in the editor, we should reload the economy.
-			//  This way when you load a game, the max loan and interest rate
-			//  are loaded correctly.
-			if (_game_mode == GM_EDITOR)
-				StartupEconomy();
-			break;
-		}
-		case 11: /* Cancel button - close window, abandon changes */
-			DeleteWindow(w);
-			break;
-	} break;
-
-	case WE_MOUSELOOP: /* Handle the visual 'clicking' of the buttons */
-		if (_difficulty_timeout != 0 && !--_difficulty_timeout) {
-			_difficulty_click_a = 0;
-			_difficulty_click_b = 0;
-			SetWindowDirty(w);
-		}
-		break;
 	}
 }
-
 #undef DIFF_INGAME_DISABLED_BUTTONS
 
+/* Widget definition for the game difficulty settings window */
 static const Widget _game_difficulty_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS},
-{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    29, 0x0,                          STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_6803_HARD,                STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_6804_CUSTOM,              STR_NULL},
-{    WWT_TEXTBTN,   RESIZE_NONE,    10,     0,   369,    30,    41, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL},
-{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   262, 0x0,                          STR_NULL},
-{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,   263,   278, 0x0,                          STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   105,   185,   265,   276, STR_OPTIONS_SAVE_CHANGES,     STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   186,   266,   265,   276, STR_012E_CANCEL,              STR_NULL},
+{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},           // GDW_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS}, // GDW_CAPTION
+{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                          STR_NULL},                        // GDW_UPPER_BG
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},                        // GDW_LVL_EASY
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},                        // GDW_LVL_MEDIUM
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_6803_HARD,                STR_NULL},                        // GDW_LVL_HARD
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_6804_CUSTOM,              STR_NULL},                        // GDW_LVL_CUSTOM
+{    WWT_TEXTBTN,   RESIZE_NONE,     6,    10,   357,    28,    39, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL},                        // GDW_HIGHSCORE
+{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   262, 0x0,                          STR_NULL},                        // GDW_SETTING_BG
+{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,   263,   278, 0x0,                          STR_NULL},                        // GDW_LOWER_BG
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   105,   185,   265,   276, STR_OPTIONS_SAVE_CHANGES,     STR_NULL},                        // GDW_ACCEPT
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   186,   266,   265,   276, STR_012E_CANCEL,              STR_NULL},                        // GDW_CANCEL
 {   WIDGETS_END},
 };
 
+/* Window definition for the game difficulty settings window */
 static const WindowDesc _game_difficulty_desc = {
 	WDP_CENTER, WDP_CENTER, 370, 279, 370, 279,
 	WC_GAME_OPTIONS, WC_NONE,
@@ -669,6 +730,7 @@
 	"longbridges",
 	"signal_side",
 	"always_small_airport",
+	"enable_signal_gui",
 	"drag_signals_density",
 	"oil_refinery_limit",
 	"semaphore_build_before",
@@ -772,6 +834,16 @@
 	{_patches_ai,           NULL, lengthof(_patches_ai)},
 };
 
+enum PatchesSelectionWidgets {
+	PATCHSEL_OPTIONSPANEL = 3,
+	PATCHSEL_INTERFACE,
+	PATCHSEL_CONSTRUCTION,
+	PATCHSEL_VEHICLES,
+	PATCHSEL_STATIONS,
+	PATCHSEL_ECONOMY,
+	PATCHSEL_COMPETITORS
+};
+
 /** The main patches window. Shows a number of categories on top and
  * a selection of patches in that category.
  * Uses WP(w, def_d) macro - data_1, data_2, data_3 */
@@ -780,210 +852,208 @@
 	static Patches *patches_ptr;
 
 	switch (e->event) {
-	case WE_CREATE: {
-		static bool first_time = true;
-
-		patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
-
-		/* Build up the dynamic settings-array only once per OpenTTD session */
-		if (first_time) {
-			PatchPage *page;
-			for (page = &_patches_page[0]; page != endof(_patches_page); page++) {
-				uint i;
-
-				page->entries = MallocT<PatchEntry>(page->num);
-				for (i = 0; i != page->num; i++) {
-					uint index;
-					const SettingDesc *sd = GetPatchFromName(page->names[i], &index);
-					assert(sd != NULL);
-
-					page->entries[i].setting = sd;
-					page->entries[i].index = index;
-				}
-			}
-			first_time = false;
-		}
-		LowerWindowWidget(w, 4);
-	} break;
-
-	case WE_PAINT: {
-		int x, y;
-		const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
-		uint i;
-
-		/* Set up selected category */
-		DrawWindowWidgets(w);
+		case WE_CREATE: {
+			static bool first_time = true;
 
-		x = 5;
-		y = 47;
-		for (i = 0; i != page->num; i++) {
-			const SettingDesc *sd = page->entries[i].setting;
-			const SettingDescBase *sdb = &sd->desc;
-			const void *var = GetVariableAddress(patches_ptr, &sd->save);
-			bool editable = true;
-			bool disabled = false;
-
-			// We do not allow changes of some items when we are a client in a networkgame
-			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
-			if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
-			if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
-
-			if (sdb->cmd == SDT_BOOLX) {
-				static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}};
-				/* Draw checkbox for boolean-value either on/off */
-				bool on = (*(bool*)var);
+			patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
 
-				DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE);
-				SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
-			} else {
-				int32 value;
-
-				value = (int32)ReadValue(var, sd->save.conv);
-
-				/* Draw [<][>] boxes for settings of an integer-type */
-				DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
+			/* Build up the dynamic settings-array only once per OpenTTD session */
+			if (first_time) {
+				PatchPage *page;
+				for (page = &_patches_page[0]; page != endof(_patches_page); page++) {
+					uint i;
 
-				disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
-				if (disabled) {
-					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
-				} else {
-					if (sdb->flags & SGF_CURRENCY) {
-						SetDParam(0, STR_CONFIG_PATCHES_CURRENCY);
-					} else if (sdb->flags & SGF_MULTISTRING) {
-						SetDParam(0, sdb->str + value + 1);
-					} else {
-						SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024);
+					page->entries = MallocT<PatchEntry>(page->num);
+					for (i = 0; i != page->num; i++) {
+						uint index;
+						const SettingDesc *sd = GetPatchFromName(page->names[i], &index);
+						assert(sd != NULL);
+
+						page->entries[i].setting = sd;
+						page->entries[i].index = index;
 					}
-					SetDParam(1, value);
 				}
+				first_time = false;
 			}
-			DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING);
-			y += 11;
-		}
-		break;
-	}
-
-	case WE_CLICK:
-		switch (e->we.click.widget) {
-		case 3: {
-			const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
-			const SettingDesc *sd;
-			void *var;
-			int32 value;
-			int x, y;
-			byte btn;
-
-			y = e->we.click.pt.y - 46 - 1;
-			if (y < 0) return;
-
-			x = e->we.click.pt.x - 5;
-			if (x < 0) return;
-
-			btn = y / 11;
-			if (y % 11 > 9) return;
-			if (btn >= page->num) return;
-
-			sd = page->entries[btn].setting;
-
-			/* return if action is only active in network, or only settable by server */
-			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
-			if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
-			if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return;
+			w->LowerWidget(4);
+		} break;
 
-			var = GetVariableAddress(patches_ptr, &sd->save);
-			value = (int32)ReadValue(var, sd->save.conv);
-
-			/* clicked on the icon on the left side. Either scroller or bool on/off */
-			if (x < 21) {
-				const SettingDescBase *sdb = &sd->desc;
-				int32 oldvalue = value;
-
-				switch (sdb->cmd) {
-				case SDT_BOOLX: value ^= 1; break;
-				case SDT_NUMX: {
-					/* Add a dynamic step-size to the scroller. In a maximum of
-					 * 50-steps you should be able to get from min to max,
-					 * unless specified otherwise in the 'interval' variable
-					 * of the current patch. */
-					uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
-					if (step == 0) step = 1;
+		case WE_PAINT: {
+			int x, y;
+			const PatchPage *page = &_patches_page[WP(w, def_d).data_1];
+			uint i;
 
-					// don't allow too fast scrolling
-					if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) {
-						_left_button_clicked = false;
-						return;
-					}
+			/* Set up selected category */
+			DrawWindowWidgets(w);
 
-					/* Increase or decrease the value and clamp it to extremes */
-					if (x >= 10) {
-						value += step;
-						if (value > sdb->max) value = sdb->max;
+			x = 5;
+			y = 47;
+			for (i = 0; i != page->num; i++) {
+				const SettingDesc *sd = page->entries[i].setting;
+				const SettingDescBase *sdb = &sd->desc;
+				const void *var = GetVariableAddress(patches_ptr, &sd->save);
+				bool editable = true;
+				bool disabled = false;
+
+				// We do not allow changes of some items when we are a client in a networkgame
+				if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
+				if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
+				if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
+
+				if (sdb->cmd == SDT_BOOLX) {
+					static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}};
+					/* Draw checkbox for boolean-value either on/off */
+					bool on = (*(bool*)var);
+
+					DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE);
+					SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
+				} else {
+					int32 value;
+
+					value = (int32)ReadValue(var, sd->save.conv);
+
+					/* Draw [<][>] boxes for settings of an integer-type */
+					DrawArrowButtons(x, y, 3, WP(w, def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
+
+					disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
+					if (disabled) {
+						SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
 					} else {
-						value -= step;
-						if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
+						if (sdb->flags & SGF_CURRENCY) {
+							SetDParam(0, STR_CONFIG_PATCHES_CURRENCY);
+						} else if (sdb->flags & SGF_MULTISTRING) {
+							SetDParam(0, sdb->str + value + 1);
+						} else {
+							SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024);
+						}
+						SetDParam(1, value);
 					}
+				}
+				DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING);
+				y += 11;
+			}
+		} break;
 
-					/* Set up scroller timeout for numeric values */
-					if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) {
-						WP(w,def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
-						w->flags4 |= 5 << WF_TIMEOUT_SHL;
-						_left_button_clicked = false;
+		case WE_CLICK:
+			switch (e->we.click.widget) {
+				case PATCHSEL_OPTIONSPANEL: {
+					const PatchPage *page = &_patches_page[WP(w, def_d).data_1];
+					const SettingDesc *sd;
+					void *var;
+					int32 value;
+					int x, y;
+					byte btn;
+
+					y = e->we.click.pt.y - 46 - 1;
+					if (y < 0) return;
+
+					x = e->we.click.pt.x - 5;
+					if (x < 0) return;
+
+					btn = y / 11;
+					if (y % 11 > 9) return;
+					if (btn >= page->num) return;
+
+					sd = page->entries[btn].setting;
+
+					/* return if action is only active in network, or only settable by server */
+					if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
+					if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
+					if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return;
+
+					var = GetVariableAddress(patches_ptr, &sd->save);
+					value = (int32)ReadValue(var, sd->save.conv);
+
+					/* clicked on the icon on the left side. Either scroller or bool on/off */
+					if (x < 21) {
+						const SettingDescBase *sdb = &sd->desc;
+						int32 oldvalue = value;
+
+						switch (sdb->cmd) {
+						case SDT_BOOLX: value ^= 1; break;
+						case SDT_NUMX: {
+							/* Add a dynamic step-size to the scroller. In a maximum of
+							 * 50-steps you should be able to get from min to max,
+							 * unless specified otherwise in the 'interval' variable
+							 * of the current patch. */
+							uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
+							if (step == 0) step = 1;
+
+							// don't allow too fast scrolling
+							if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) {
+								_left_button_clicked = false;
+								return;
+							}
+
+							/* Increase or decrease the value and clamp it to extremes */
+							if (x >= 10) {
+								value += step;
+								if (value > sdb->max) value = sdb->max;
+							} else {
+								value -= step;
+								if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
+							}
+
+							/* Set up scroller timeout for numeric values */
+							if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) {
+								WP(w, def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
+								w->flags4 |= 5 << WF_TIMEOUT_SHL;
+								_left_button_clicked = false;
+							}
+						} break;
+						default: NOT_REACHED();
+						}
+
+						if (value != oldvalue) {
+							SetPatchValue(page->entries[btn].index, patches_ptr, value);
+							SetWindowDirty(w);
+						}
+					} else {
+						/* only open editbox for types that its sensible for */
+						if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
+							/* Show the correct currency-translated value */
+							if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
+
+							WP(w, def_d).data_3 = btn;
+							SetDParam(0, value);
+							ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL);
+						}
 					}
 				} break;
-				default: NOT_REACHED();
-				}
-
-				if (value != oldvalue) {
-					SetPatchValue(page->entries[btn].index, patches_ptr, value);
-					SetWindowDirty(w);
-				}
-			} else {
-				/* only open editbox for types that its sensible for */
-				if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
-					/* Show the correct currency-translated value */
-					if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
 
-					WP(w,def_d).data_3 = btn;
-					SetDParam(0, value);
-					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL);
-				}
+				case PATCHSEL_INTERFACE: case PATCHSEL_CONSTRUCTION: case PATCHSEL_VEHICLES:
+				case PATCHSEL_STATIONS:  case PATCHSEL_ECONOMY:      case PATCHSEL_COMPETITORS:
+					w->RaiseWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE);
+					WP(w, def_d).data_1 = e->we.click.widget - PATCHSEL_INTERFACE;
+					w->LowerWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE);
+					DeleteWindowById(WC_QUERY_STRING, 0);
+					SetWindowDirty(w);
+					break;
 			}
+			break;
 
-			break;
-		}
-		case 4: case 5: case 6: case 7: case 8: case 9:
-			RaiseWindowWidget(w, WP(w, def_d).data_1 + 4);
-			WP(w, def_d).data_1 = e->we.click.widget - 4;
-			LowerWindowWidget(w, WP(w, def_d).data_1 + 4);
-			DeleteWindowById(WC_QUERY_STRING, 0);
+		case WE_TIMEOUT:
+			WP(w, def_d).data_2 = 0;
 			SetWindowDirty(w);
 			break;
-		}
-		break;
-
-	case WE_TIMEOUT:
-		WP(w,def_d).data_2 = 0;
-		SetWindowDirty(w);
-		break;
 
-	case WE_ON_EDIT_TEXT: {
-		if (e->we.edittext.str != NULL) {
-			const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3];
-			const SettingDesc *sd = pe->setting;
-			int32 value = atoi(e->we.edittext.str);
-
-			/* Save the correct currency-translated value */
-			if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
+		case WE_ON_EDIT_TEXT:
+			if (e->we.edittext.str != NULL) {
+				const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w,def_d).data_3];
+				const SettingDesc *sd = pe->setting;
+				int32 value = atoi(e->we.edittext.str);
 
-			SetPatchValue(pe->index, patches_ptr, value);
-			SetWindowDirty(w);
-		}
-		break;
-	}
+				/* Save the correct currency-translated value */
+				if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
 
-	case WE_DESTROY:
-		DeleteWindowById(WC_QUERY_STRING, 0);
-		break;
+				SetPatchValue(pe->index, patches_ptr, value);
+				SetWindowDirty(w);
+			}
+			break;
+
+		case WE_DESTROY:
+			DeleteWindowById(WC_QUERY_STRING, 0);
+			break;
 	}
 }
 
@@ -1042,6 +1112,17 @@
 		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
 }
 
+/** These are not, strickly speaking, widget enums,
+ *  since they have been changed as line coordinates.
+ *  So, rather, they are more like order of appearance */
+enum CustomCurrenciesWidgets {
+	CUSTCURR_EXCHANGERATE = 0,
+	CUSTCURR_SEPARATOR,
+	CUSTCURR_PREFIX,
+	CUSTCURR_SUFFIX,
+	CUSTCURR_TO_EURO,
+};
+
 static char _str_separator[2];
 
 static void CustCurrencyWndProc(Window *w, WindowEvent *e)
@@ -1050,46 +1131,45 @@
 		case WE_PAINT: {
 			int x;
 			int y = 20;
-			int clk = WP(w,def_d).data_1;
+			int clk = WP(w, def_d).data_1;
 			DrawWindowWidgets(w);
 
-			// exchange rate
+			/* exchange rate */
 			DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true);
 			SetDParam(0, 1);
 			SetDParam(1, 1);
 			DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING);
 			y += 12;
 
-			// separator
+			/* separator */
 			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 2, 2) ? FR_LOWERED : FR_NONE);
 			x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, TC_FROMSTRING);
 			DoDrawString(_str_separator, x + 4, y + 1, TC_ORANGE);
 			y += 12;
 
-			// prefix
+			/* prefix */
 			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 4, 2) ? FR_LOWERED : FR_NONE);
 			x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, TC_FROMSTRING);
 			DoDrawString(_custom_currency.prefix, x + 4, y + 1, TC_ORANGE);
 			y += 12;
 
-			// suffix
+			/* suffix */
 			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 6, 2) ? FR_LOWERED : FR_NONE);
 			x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING);
 			DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE);
 			y += 12;
 
-			// switch to euro
+			/* switch to euro */
 			DrawArrowButtons(10, y, 3, GB(clk, 8, 2), true, true);
 			SetDParam(0, _custom_currency.to_euro);
 			DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING);
 			y += 12;
 
-			// Preview
+			/* Preview */
 			y += 12;
 			SetDParam(0, 10000);
 			DrawString(35, y + 1, STR_CURRENCY_PREVIEW, TC_FROMSTRING);
-			break;
-		}
+		} break;
 
 		case WE_CLICK: {
 			int line = (e->we.click.pt.y - 20) / 12;
@@ -1099,14 +1179,14 @@
 			CharSetFilter afilter = CS_ALPHANUMERAL;
 
 			switch (line) {
-				case 0: // rate
-					if (IS_INT_INSIDE(x, 10, 30)) { // clicked buttons
+				case CUSTCURR_EXCHANGERATE:
+					if (IsInsideMM(x, 10, 30)) { // clicked buttons
 						if (x < 20) {
 							if (_custom_currency.rate > 1) _custom_currency.rate--;
-							WP(w,def_d).data_1 = 1 << (line * 2 + 0);
+							WP(w, def_d).data_1 = 1 << (line * 2 + 0);
 						} else {
 							if (_custom_currency.rate < 5000) _custom_currency.rate++;
-							WP(w,def_d).data_1 = 1 << (line * 2 + 1);
+							WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 						}
 					} else { // enter text
 						SetDParam(0, _custom_currency.rate);
@@ -1116,40 +1196,40 @@
 					}
 					break;
 
-				case 1: // separator
-					if (IS_INT_INSIDE(x, 10, 30)) { // clicked button
-						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
+				case CUSTCURR_SEPARATOR:
+					if (IsInsideMM(x, 10, 30)) { // clicked button
+						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 					}
 					str = BindCString(_str_separator);
 					len = 1;
 					break;
 
-				case 2: // prefix
-					if (IS_INT_INSIDE(x, 10, 30)) { // clicked button
-						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
+				case CUSTCURR_PREFIX:
+					if (IsInsideMM(x, 10, 30)) { // clicked button
+						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 					}
 					str = BindCString(_custom_currency.prefix);
 					len = 12;
 					break;
 
-				case 3: // suffix
-					if (IS_INT_INSIDE(x, 10, 30)) { // clicked button
-						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
+				case CUSTCURR_SUFFIX:
+					if (IsInsideMM(x, 10, 30)) { // clicked button
+						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 					}
 					str = BindCString(_custom_currency.suffix);
 					len = 12;
 					break;
 
-				case 4: // to euro
-					if (IS_INT_INSIDE(x, 10, 30)) { // clicked buttons
+				case CUSTCURR_TO_EURO:
+					if (IsInsideMM(x, 10, 30)) { // clicked buttons
 						if (x < 20) {
 							_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
 								CF_NOEURO : _custom_currency.to_euro - 1;
-							WP(w,def_d).data_1 = 1 << (line * 2 + 0);
+							WP(w, def_d).data_1 = 1 << (line * 2 + 0);
 						} else {
 							_custom_currency.to_euro =
 								Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
-							WP(w,def_d).data_1 = 1 << (line * 2 + 1);
+							WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 						}
 					} else { // enter text
 						SetDParam(0, _custom_currency.to_euro);
@@ -1167,44 +1247,41 @@
 
 			w->flags4 |= 5 << WF_TIMEOUT_SHL;
 			SetWindowDirty(w);
-			break;
-		}
+		} break;
 
 		case WE_ON_EDIT_TEXT: {
-				const char *b = e->we.edittext.str;
-
-				switch (WP(w,def_d).data_2) {
-					case 0: /* Exchange rate */
-						_custom_currency.rate = Clamp(atoi(b), 1, 5000);
-						break;
-
-					case 1: /* Thousands seperator */
-						_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
-						ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
-						break;
+			const char *b = e->we.edittext.str;
 
-					case 2: /* Currency prefix */
-						ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix));
-						break;
-
-					case 3: /* Currency suffix */
-						ttd_strlcpy(_custom_currency.suffix, b, lengthof(_custom_currency.suffix));
-						break;
+			switch (WP(w, def_d).data_2) {
+				case CUSTCURR_EXCHANGERATE:
+					_custom_currency.rate = Clamp(atoi(b), 1, 5000);
+					break;
 
-					case 4: { /* Year to switch to euro */
-						int val = atoi(b);
+				case CUSTCURR_SEPARATOR: /* Thousands seperator */
+					_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
+					ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
+					break;
 
-						_custom_currency.to_euro =
-							(val < 2000 ? CF_NOEURO : min(val, MAX_YEAR));
-						break;
-					}
+				case CUSTCURR_PREFIX:
+					ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix));
+					break;
+
+				case CUSTCURR_SUFFIX:
+					ttd_strlcpy(_custom_currency.suffix, b, lengthof(_custom_currency.suffix));
+					break;
+
+				case CUSTCURR_TO_EURO: { /* Year to switch to euro */
+					int val = atoi(b);
+
+					_custom_currency.to_euro = (val < 2000 ? CF_NOEURO : min(val, MAX_YEAR));
+					break;
 				}
+			}
 			MarkWholeScreenDirty();
-			break;
-		}
+		} break;
 
 		case WE_TIMEOUT:
-			WP(w,def_d).data_1 = 0;
+			WP(w, def_d).data_1 = 0;
 			SetWindowDirty(w);
 			break;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/settings_internal.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,88 @@
+/* $Id$ */
+
+/** @file settings_internal.h Functions and types used internally for the settings configurations. */
+
+#ifndef SETTINGS_INTERNAL_H
+#define SETTINGS_INTERNAL_H
+
+#include "saveload.h"
+
+/** Convention/Type of settings. This is then further specified if necessary
+ * with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h
+ * @see VarTypes
+ * @see SettingDescBase */
+enum SettingDescTypeLong {
+	/* 4 bytes allocated a maximum of 16 types for GenericType */
+	SDT_BEGIN       = 0,
+	SDT_NUMX        = 0, ///< any number-type
+	SDT_BOOLX       = 1, ///< a boolean number
+	SDT_ONEOFMANY   = 2, ///< bitmasked number where only ONE bit may be set
+	SDT_MANYOFMANY  = 3, ///< bitmasked number where MULTIPLE bits may be set
+	SDT_INTLIST     = 4, ///< list of integers seperated by a comma ','
+	SDT_STRING      = 5, ///< string with a pre-allocated buffer
+	SDT_END,
+	/* 10 more possible primitives */
+};
+
+template <> struct EnumPropsT<SettingDescTypeLong> : MakeEnumPropsT<SettingDescTypeLong, byte, SDT_BEGIN, SDT_END, SDT_END> {};
+typedef TinyEnumT<SettingDescTypeLong> SettingDescType;
+
+
+enum SettingGuiFlagLong {
+	/* 8 bytes allocated for a maximum of 8 flags
+	 * Flags directing saving/loading of a variable */
+	SGF_NONE = 0,
+	SGF_0ISDISABLED  = 1 << 0, ///< a value of zero means the feature is disabled
+	SGF_NOCOMMA      = 1 << 1, ///< number without any thousand seperators (no formatting)
+	SGF_MULTISTRING  = 1 << 2, ///< the value represents a limited number of string-options (internally integer)
+	SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
+	SGF_CURRENCY     = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
+	SGF_NO_NETWORK   = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
+	SGF_END          = 1 << 6,
+	/* 3 more possible flags */
+};
+
+DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong);
+template <> struct EnumPropsT<SettingGuiFlagLong> : MakeEnumPropsT<SettingGuiFlagLong, byte, SGF_NONE, SGF_END, SGF_END> {};
+typedef TinyEnumT<SettingGuiFlagLong> SettingGuiFlag;
+
+
+typedef int32 OnChange(int32 var);          ///< callback prototype on data modification
+typedef int32 OnConvert(const char *value); ///< callback prototype for convertion error
+
+struct SettingDescBase {
+	const char *name;       ///< name of the setting. Used in configuration file and for console
+	const void *def;        ///< default value given when none is present
+	SettingDescType cmd;    ///< various flags for the variable
+	SettingGuiFlag flags;   ///< handles how a setting would show up in the GUI (text/currency, etc.)
+	int32 min, max;         ///< minimum and maximum values
+	int32 interval;         ///< the interval to use between settings in the 'patches' window. If interval is '0' the interval is dynamically determined
+	const char *many;       ///< ONE/MANY_OF_MANY: string of possible values for this type
+	StringID str;           ///< (translated) string with descriptive text; gui and console
+	OnChange *proc;         ///< callback procedure for when the value is changed
+	OnConvert *proc_cnvt;   ///< callback procedure when loading value mechanism fails
+};
+
+struct SettingDesc {
+	SettingDescBase desc;   ///< Settings structure (going to configuration file)
+	SaveLoad save;          ///< Internal structure (going to savegame, parts to config)
+};
+
+/* NOTE: The only difference between SettingDesc and SettingDescGlob is
+ * that one uses global variables as a source and the other offsets
+ * in a struct which are bound to a certain variable during runtime.
+ * The only way to differentiate between these two is to check if an object
+ * has been passed to the function or not. If not, then it is a global variable
+ * and save->variable has its address, otherwise save->variable only holds the
+ * offset in a certain struct */
+typedef SettingDesc SettingDescGlobVarList;
+
+enum IniGroupType {
+	IGT_VARIABLES = 0, ///< values of the form "landscape = hilly"
+	IGT_LIST      = 1, ///< a list of values, seperated by \n and terminated by the next group block
+};
+
+const SettingDesc *GetPatchFromName(const char *name, uint *i);
+bool SetPatchValue(uint index, const Patches *object, int32 value);
+
+#endif /* SETTINGS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/settings_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,210 @@
+/* $Id$ */
+
+/** @file settings_type.h Types related to global configuration settings. */
+
+#ifndef SETTINGS_TYPE_H
+#define SETTINGS_TYPE_H
+
+#include "yapf/yapf_settings.h"
+#include "date_type.h"
+#include "town_type.h"
+
+struct GameOptions {
+	GameDifficulty diff;
+	byte diff_level;
+	byte currency;
+	byte units;
+	byte town_name;
+	byte landscape;
+	byte snow_line;
+	byte autosave;
+	byte road_side;
+};
+
+/* These are the options for the current game
+ * either ingame, or loaded. Also used for networking games */
+extern GameOptions _opt;
+
+/* These are the default options for a new game */
+extern GameOptions _opt_newgame;
+
+/* Pointer to one of the two _opt OR _opt_newgame structs */
+extern GameOptions *_opt_ptr;
+
+struct Patches {
+	bool modified_catchment;            // different-size catchment areas
+	bool vehicle_speed;                 // show vehicle speed
+	bool build_on_slopes;               // allow building on slopes
+	bool mammoth_trains;                // allow very long trains
+	bool join_stations;                 // allow joining of train stations
+	bool full_load_any;                 // new full load calculation, any cargo must be full
+	bool improved_load;                 // improved loading algorithm
+	bool gradual_loading;               // load vehicles gradually
+	byte station_spread;                // amount a station may spread
+	bool inflation;                     // disable inflation
+	bool selectgoods;                   // only send the goods to station if a train has been there
+	bool longbridges;                   // allow 100 tile long bridges
+	bool gotodepot;                     // allow goto depot in orders
+	uint8 raw_industry_construction;    ///< Type of (raw) industry construction (none, "normal", prospecting)
+	bool multiple_industry_per_town;    // allow many industries of the same type per town
+	bool same_industry_close;           // allow same type industries to be built close to each other
+	bool lost_train_warn;               // if a train can't find its destination, show a warning
+	uint8 order_review_system;
+	bool train_income_warn;             // if train is generating little income, show a warning
+	bool status_long_date;              // always show long date in status bar
+	bool signal_side;                   // show signals on right side
+	bool show_finances;                 // show finances at end of year
+	bool new_nonstop;                   // ttdpatch compatible nonstop handling
+	bool roadveh_queue;                 // buggy road vehicle queueing
+	bool autoscroll;                    // scroll when moving mouse to the edge.
+	byte errmsg_duration;               // duration of error message
+	byte land_generator;                // the landscape generator
+	byte oil_refinery_limit;            // distance oil refineries allowed from map edge
+	byte snow_line_height;              // a number 0-15 that configured snow line height
+	byte tgen_smoothness;               // how rough is the terrain from 0-3
+	uint32 generation_seed;             // noise seed for world generation
+	byte tree_placer;                   // the tree placer algorithm
+	byte heightmap_rotation;            // rotation director for the heightmap
+	byte se_flat_world_height;          // land height a flat world gets in SE
+	bool bribe;                         // enable bribing the local authority
+	bool nonuniform_stations;           // allow nonuniform train stations
+	bool adjacent_stations;             // allow stations to be built directly adjacent to other stations
+	bool always_small_airport;          // always allow small airports
+	bool realistic_acceleration;        // realistic acceleration for trains
+	bool wagon_speed_limits;            // enable wagon speed limits
+	bool forbid_90_deg;                 // forbid trains to make 90 deg turns
+	bool invisible_trees;               // don't show trees when buildings are transparent
+	bool no_servicing_if_no_breakdowns; // dont send vehicles to depot when breakdowns are disabled
+	bool link_terraform_toolbar;        // display terraform toolbar when displaying rail, road, water and airport toolbars
+	bool reverse_scroll;                // Right-Click-Scrolling scrolls in the opposite direction
+	bool smooth_scroll;                 ///< Smooth scroll viewports
+	bool disable_elrails;               // when true, the elrails are disabled
+	bool measure_tooltip;               // Show a permanent tooltip when dragging tools
+	byte liveries;                      // Options for displaying company liveries, 0=none, 1=self, 2=all
+	bool prefer_teamchat;               // Choose the chat message target with <ENTER>, true=all players, false=your team
+	uint8 advanced_vehicle_list;        // Use the "advanced" vehicle list
+	uint8 loading_indicators;           // Show loading indicators
+	uint8 default_rail_type;            ///< The default rail type for the rail GUI
+
+	uint8 toolbar_pos;                  // position of toolbars, 0=left, 1=center, 2=right
+	uint8 window_snap_radius;           // Windows snap at each other if closer than this
+
+	bool always_build_infrastructure;   ///< Always allow building of infrastructure, even when you do not have the vehicles for it
+	UnitID max_trains;                  // max trains in game per player (these are 16bit because the unitnumber field can't hold more)
+	UnitID max_roadveh;                 // max trucks in game per player
+	UnitID max_aircraft;                // max planes in game per player
+	UnitID max_ships;                   // max ships in game per player
+
+	bool servint_ispercent;             // service intervals are in percents
+	uint16 servint_trains;              // service interval for trains
+	uint16 servint_roadveh;             // service interval for road vehicles
+	uint16 servint_aircraft;            // service interval for aircraft
+	uint16 servint_ships;               // service interval for ships
+
+	bool autorenew;
+	int16 autorenew_months;
+	int32 autorenew_money;
+
+	byte pf_maxdepth;                   // maximum recursion depth when searching for a train route for new pathfinder
+	uint16 pf_maxlength;                // maximum length when searching for a train route for new pathfinder
+
+	bool bridge_pillars;                // show bridge pillars for high bridges
+
+	bool ai_disable_veh_train;          // disable types for AI
+	bool ai_disable_veh_roadveh;        // disable types for AI
+	bool ai_disable_veh_aircraft;       // disable types for AI
+	bool ai_disable_veh_ship;           // disable types for AI
+	Year starting_year;                 // starting date
+	Year ending_year;                   // end of the game (just show highscore)
+	Year colored_news_year;             // when does newspaper become colored?
+
+	bool keep_all_autosave;             // name the autosave in a different way.
+	bool autosave_on_exit;              // save an autosave when you quit the game, but do not ask "Do you really want to quit?"
+	byte max_num_autosaves;             // controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
+	bool extra_dynamite;                // extra dynamite
+	bool road_stop_on_town_road;        // allow building of drive-through road stops on town owned roads
+
+	bool never_expire_vehicles;         // never expire vehicles
+	byte extend_vehicle_life;           // extend vehicle life by this many years
+
+	bool auto_euro;                     // automatically switch to euro in 2002
+	bool serviceathelipad;              // service helicopters at helipads automatically (no need to send to depot)
+	bool smooth_economy;                // smooth economy
+	bool allow_shares;                  // allow the buying/selling of shares
+	byte dist_local_authority;          // distance for town local authority, default 20
+
+	byte wait_oneway_signal;            // waitingtime in days before a oneway signal
+	byte wait_twoway_signal;            // waitingtime in days before a twoway signal
+
+	uint8 map_x;                        // Size of map
+	uint8 map_y;
+
+	byte drag_signals_density;          // many signals density
+	Year semaphore_build_before;        // Build semaphore signals automatically before this year
+	bool ai_in_multiplayer;             // Do we allow AIs in multiplayer
+
+	/*
+	 * New Path Finding
+	 */
+	bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */
+
+	/**
+	 * The maximum amount of search nodes a single NPF run should take. This
+	 * limit should make sure performance stays at acceptable levels at the cost
+	 * of not being perfect anymore. This will probably be fixed in a more
+	 * sophisticated way sometime soon
+	 */
+	uint32 npf_max_search_nodes;
+
+	uint32 npf_rail_firstred_penalty;      // The penalty for when the first signal is red (and it is not an exit or combo signal)
+	uint32 npf_rail_firstred_exit_penalty; // The penalty for when the first signal is red (and it is an exit or combo signal)
+	uint32 npf_rail_lastred_penalty;       // The penalty for when the last signal is red
+	uint32 npf_rail_station_penalty;       // The penalty for station tiles
+	uint32 npf_rail_slope_penalty;         // The penalty for sloping upwards
+	uint32 npf_rail_curve_penalty;         // The penalty for curves
+	uint32 npf_rail_depot_reverse_penalty; // The penalty for reversing in depots
+	uint32 npf_buoy_penalty;               // The penalty for going over (through) a buoy
+	uint32 npf_water_curve_penalty;        // The penalty for curves
+	uint32 npf_road_curve_penalty;         // The penalty for curves
+	uint32 npf_crossing_penalty;           // The penalty for level crossings
+	uint32 npf_road_drive_through_penalty; // The penalty for going through a drive-through road stop
+
+	bool population_in_label; // Show the population of a town in his label?
+
+	uint8 freight_trains; // Value to multiply the weight of cargo by
+
+	/** YAPF settings */
+	YapfSettings  yapf;
+
+	uint8 right_mouse_btn_emulation;
+
+	uint8 scrollwheel_scrolling;
+	uint8 scrollwheel_multiplier;
+
+	uint8 town_growth_rate;  ///< Town growth rate
+	uint8 larger_towns;      ///< The number of cities to build. These start off larger and grow twice as fast
+	uint8 initial_city_size; ///< Multiplier for the initial size of the cities compared to towns
+
+	bool pause_on_newgame;   ///< Whether to start new games paused or not.
+
+	TownLayoutByte town_layout;  ///< Select town layout
+
+	bool timetabling;        ///< Whether to allow timetabling.
+	bool timetable_in_ticks; ///< Whether to show the timetable in ticks rather than days.
+
+	bool autoslope;          ///< Allow terraforming under things.
+
+	bool mod_road_rebuild;   ///< Roadworks remove unneccesary RoadBits
+
+	bool exclusive_rights;   ///< allow buying exclusive rights
+	bool give_money;         ///< allow giving other players money
+
+	bool enable_signal_gui;  ///< Show the signal GUI when the signal button is pressed
+};
+
+extern Patches _patches;
+
+/** The patch values that are used for new games and/or modified in config file */
+extern Patches _patches_newgame;
+
+#endif /* SETTINGS_TYPE_H */
--- a/src/ship.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ship.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,9 +5,9 @@
 #ifndef SHIP_H
 #define SHIP_H
 
-#include "vehicle.h"
+#include "vehicle_base.h"
 #include "engine.h"
-#include "variables.h"
+#include "economy_func.h"
 
 void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
 void RecalcShipStuff(Vehicle *v);
--- a/src/ship_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ship_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,21 +6,16 @@
 #include "openttd.h"
 #include "ship.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "map.h"
-#include "tile.h"
-#include "vehicle.h"
 #include "timetable.h"
-#include "command.h"
+#include "command_func.h"
 #include "pathfind.h"
 #include "station_map.h"
 #include "station.h"
 #include "news.h"
 #include "engine.h"
 #include "player.h"
-#include "sound.h"
 #include "npf.h"
 #include "depot.h"
 #include "vehicle_gui.h"
@@ -31,9 +26,18 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_text.h"
 #include "newgrf_sound.h"
-#include "date.h"
 #include "spritecache.h"
 #include "misc/autoptr.hpp"
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "variables.h"
+#include "autoreplace_gui.h"
+#include "gfx_func.h"
+
 
 static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
 
@@ -61,7 +65,7 @@
 			DrawSprite(sprite, pal, x, y);
 			return;
 		}
-		spritenum = orig_ship_vehicle_info[engine - SHIP_ENGINES_INDEX].image_index;
+		spritenum = _orig_ship_vehicle_info[engine - SHIP_ENGINES_INDEX].image_index;
 	}
 	DrawSprite(6 + _ship_sprites[spritenum], pal, x, y);
 }
@@ -78,7 +82,7 @@
 
 	if (is_custom_sprite(spritenum)) {
 		custom_sprite = GetCustomVehicleIcon(engine, DIR_W);
-		spritenum = orig_ship_vehicle_info[engine - SHIP_ENGINES_INDEX].image_index;
+		spritenum = _orig_ship_vehicle_info[engine - SHIP_ENGINES_INDEX].image_index;
 	}
 	if (custom_sprite == 0) {
 		spritenum = 6 + _ship_sprites[spritenum];
@@ -100,7 +104,7 @@
 		int sprite = GetCustomVehicleSprite(this, direction);
 
 		if (sprite != 0) return sprite;
-		spritenum = orig_ship_vehicle_info[this->engine_type - SHIP_ENGINES_INDEX].image_index;
+		spritenum = _orig_ship_vehicle_info[this->engine_type - SHIP_ENGINES_INDEX].image_index;
 	}
 	return _ship_sprites[spritenum] + direction;
 }
@@ -166,7 +170,7 @@
 
 void OnNewDay_Ship(Vehicle *v)
 {
-	CommandCost cost;
+	CommandCost cost(EXPENSES_SHIP_RUN);
 
 	if ((++v->day_counter & 7) == 0)
 		DecreaseVehicleValue(v);
@@ -182,8 +186,7 @@
 	cost.AddCost(GetVehicleProperty(v, 0x0F, ShipVehInfo(v->engine_type)->running_cost) * _price.ship_running / 364);
 	v->profit_this_year -= cost.GetCost() >> 8;
 
-	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
-	SubtractMoneyFromPlayerFract(v->owner, CommandCost(cost));
+	SubtractMoneyFromPlayerFract(v->owner, cost);
 
 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 	/* we need this for the profit */
@@ -397,7 +400,7 @@
 
 static CommandCost EstimateShipCost(EngineID engine_type)
 {
-	return CommandCost(GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base >> 3) >> 5);
+	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base >> 3) >> 5);
 }
 
 static void ShipArrivesAt(const Vehicle* v, Station* st)
@@ -806,14 +809,11 @@
 CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	CommandCost value;
-	Vehicle *v;
 	UnitID unit_num;
 	Engine *e;
 
 	if (!IsEngineBuildable(p1, VEH_SHIP, _current_player)) return_cmd_error(STR_SHIP_NOT_AVAILABLE);
 
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
 	value = EstimateShipCost(p1);
 	if (flags & DC_QUERY_COST) return value;
 
@@ -822,11 +822,9 @@
 	if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR;
 	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
-	v = new Ship();
 	unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
-	AutoPtrT<Vehicle> v_auto_delete = v;
 
-	if (v == NULL || unit_num > _patches.max_ships)
+	if (!Vehicle::AllocateList(NULL, 1) || unit_num > _patches.max_ships)
 		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 
 	if (flags & DC_EXEC) {
@@ -835,7 +833,7 @@
 
 		const ShipVehicleInfo *svi = ShipVehInfo(p1);
 
-		v = new (v) Ship();
+		Vehicle *v = new Ship();
 		v->unitnumber = unit_num;
 
 		v->owner = _current_player;
@@ -888,8 +886,6 @@
 			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
 
 		GetPlayer(_current_player)->num_engines[p1]++;
-
-		v_auto_delete.Detach();
 	}
 
 	return value;
@@ -913,13 +909,11 @@
 
 	if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE);
 
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
 	if (!v->IsStoppedInDepot()) {
 		return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
 	}
 
-	CommandCost ret(-v->value);
+	CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
 
 	if (flags & DC_EXEC) {
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
@@ -1062,7 +1056,7 @@
 CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	Vehicle *v;
-	CommandCost cost;
+	CommandCost cost(EXPENSES_SHIP_RUN);
 	CargoID new_cid = GB(p2, 0, 8); //gets the cargo number
 	byte new_subtype = GB(p2, 8, 8);
 	uint16 capacity = CALLBACK_FAILED;
@@ -1072,17 +1066,13 @@
 	v = GetVehicle(p1);
 
 	if (v->type != VEH_SHIP || !CheckOwnership(v->owner)) return CMD_ERROR;
-
-	if (!v->IsStoppedInDepot()) {
-		return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
-	}
+	if (!v->IsStoppedInDepot()) return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
+	if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_REFIT_DESTROYED_VEHICLE);
 
 	/* Check cargo */
 	if (!ShipVehInfo(v->engine_type)->refittable) return CMD_ERROR;
 	if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
-
 	/* Check the refit capacity callback */
 	if (HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
 		/* Back up the existing cargo type */
--- a/src/ship_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/ship_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,18 +5,18 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "ship.h"
 #include "table/strings.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "gui.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "command.h"
+#include "window_gui.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "depot.h"
 #include "vehicle_gui.h"
 #include "newgrf_engine.h"
+#include "strings_func.h"
+#include "vehicle_func.h"
 
 void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/signal_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,40 @@
+/* $Id$ */
+
+/** @file signal_func.h Functions related to signals. */
+
+#ifndef SIGNAL_FUNC_H
+#define SIGNAL_FUNC_H
+
+#include "track_type.h"
+
+/**
+ * Maps a trackdir to the bit that stores its status in the map arrays, in the
+ * direction along with the trackdir.
+ */
+static inline byte SignalAlongTrackdir(Trackdir trackdir)
+{
+	extern const byte _signal_along_trackdir[TRACKDIR_END];
+	return _signal_along_trackdir[trackdir];
+}
+
+/**
+ * Maps a trackdir to the bit that stores its status in the map arrays, in the
+ * direction against the trackdir.
+ */
+static inline byte SignalAgainstTrackdir(Trackdir trackdir)
+{
+	extern const byte _signal_against_trackdir[TRACKDIR_END];
+	return _signal_against_trackdir[trackdir];
+}
+
+/**
+ * Maps a Track to the bits that store the status of the two signals that can
+ * be present on the given track.
+ */
+static inline byte SignalOnTrack(Track track)
+{
+	extern const byte _signal_on_track[TRACK_END];
+	return _signal_on_track[track];
+}
+
+#endif /* SIGNAL_FUNC_H */
--- a/src/signs.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/signs.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,16 +5,20 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
 #include "landscape.h"
 #include "player.h"
 #include "signs.h"
 #include "saveload.h"
-#include "command.h"
+#include "command_func.h"
 #include "variables.h"
-#include "string.h"
 #include "misc/autoptr.hpp"
+#include "strings_func.h"
+#include "viewport_func.h"
+#include "zoom_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "map_func.h"
+#include "string_func.h"
 
 SignID _new_sign_id;
 uint _total_signs;
--- a/src/signs_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/signs_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,17 +6,20 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "functions.h"
-#include "window.h"
 #include "gui.h"
-#include "gfx.h"
+#include "textbuf_gui.h"
+#include "window_gui.h"
 #include "player.h"
 #include "signs.h"
-#include "strings.h"
 #include "debug.h"
 #include "variables.h"
-#include "helpers.hpp"
-#include "command.h"
+#include "command_func.h"
+#include "strings_func.h"
+#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;
@@ -47,7 +50,6 @@
 
 	/* Create array for sorting */
 	_sign_sort = ReallocT(_sign_sort, GetMaxSignIndex() + 1);
-	if (_sign_sort == NULL) error("Could not allocate memory for the sign-sorting-list");
 
 	FOR_ALL_SIGNS(si) _sign_sort[n++] = si;
 	_num_sign_sort = n;
@@ -184,7 +186,7 @@
 	WP(w, editsign_d).cur_sign = si->index;
 	InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, 31, 255); // Allow 31 characters (including \0)
 
-	InvalidateWidget(w, QUERY_EDIT_SIGN_WIDGET_TEXT);
+	w->InvalidateWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
 }
 
 static void RenameSign(SignID index, const char *text)
@@ -315,7 +317,7 @@
 
 	WP(w, editsign_d).caption = STR_280B_EDIT_SIGN_TEXT;
 	WP(w, editsign_d).afilter = CS_ALPHANUMERAL;
-	LowerWindowWidget(w, QUERY_EDIT_SIGN_WIDGET_TEXT);
+	w->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
 
 	UpdateSignEditWindow(w, si);
 }
--- a/src/slope.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,386 +0,0 @@
-/* $Id$ */
-
-/** @file slope.h Definitions of a slope.
- * This file defines the enumeration and helper functions for handling
- * the slope info of a tile.
- */
-
-#ifndef SLOPE_H
-#define SLOPE_H
-
-/**
- * Enumeration of tile corners
- */
-enum Corner {
-	CORNER_W = 0,
-	CORNER_S = 1,
-	CORNER_E = 2,
-	CORNER_N = 3,
-	CORNER_END,
-	CORNER_INVALID = 0xFF
-};
-
-/**
- * Enumeration for the slope-type.
- *
- * This enumeration use the chars N,E,S,W corresponding the
- * direction north, east, south and west. The top corner of a tile
- * is the north-part of the tile. The whole slope is encoded with
- * 5 bits, 4 bits for each corner and 1 bit for a steep-flag.
- *
- * For halftile slopes an extra 3 bits are used to represent this
- * properly; 1 bit for a halftile-flag and 2 bits to encode which
- * extra side (corner) is leveled when the slope of the first 5
- * bits is applied. This means that there can only be one leveled
- * slope for steep slopes, which is logical because two leveled
- * slopes would mean that it is not a steep slope as halftile
- * slopes only span one height level.
- */
-enum Slope {
-	SLOPE_FLAT     = 0x00,                                  ///< a flat tile
-	SLOPE_W        = 0x01,                                  ///< the west corner of the tile is raised
-	SLOPE_S        = 0x02,                                  ///< the south corner of the tile is raised
-	SLOPE_E        = 0x04,                                  ///< the east corner of the tile is raised
-	SLOPE_N        = 0x08,                                  ///< the north corner of the tile is raised
-	SLOPE_STEEP    = 0x10,                                  ///< indicates the slope is steep
-	SLOPE_NW       = SLOPE_N | SLOPE_W,                     ///< north and west corner are raised
-	SLOPE_SW       = SLOPE_S | SLOPE_W,                     ///< south and west corner are raised
-	SLOPE_SE       = SLOPE_S | SLOPE_E,                     ///< south and east corner are raised
-	SLOPE_NE       = SLOPE_N | SLOPE_E,                     ///< north and east corner are raised
-	SLOPE_EW       = SLOPE_E | SLOPE_W,                     ///< east and west corner are raised
-	SLOPE_NS       = SLOPE_N | SLOPE_S,                     ///< north and south corner are raised
-	SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT
-	SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,           ///< north, west and south corner are raised
-	SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,           ///< west, south and east corner are raised
-	SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,           ///< south, east and north corner are raised
-	SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,           ///< east, north and west corner are raised
-	SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,               ///< a steep slope falling to east (from west)
-	SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,               ///< a steep slope falling to north (from south)
-	SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,               ///< a steep slope falling to west (from east)
-	SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,               ///< a steep slope falling to south (from north)
-
-	SLOPE_HALFTILE = 0x20,                                  ///< one halftile is leveled (non continuous slope)
-	SLOPE_HALFTILE_MASK = 0xE0,                             ///< three bits used for halftile slopes
-	SLOPE_HALFTILE_W = SLOPE_HALFTILE | (CORNER_W << 6),    ///< the west halftile is leveled (non continuous slope)
-	SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6),    ///< the south halftile is leveled (non continuous slope)
-	SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6),    ///< the east halftile is leveled (non continuous slope)
-	SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6),    ///< the north halftile is leveled (non continuous slope)
-};
-
-/**
- * Rangecheck for Corner enumeration.
- *
- * @param corner A #Corner.
- * @return true iff corner is in a valid range.
- */
-static inline bool IsValidCorner(Corner corner)
-{
-	return IS_INT_INSIDE(corner, 0, CORNER_END);
-}
-
-/**
- * Checks if a slope is steep.
- *
- * @param s The given #Slope.
- * @return True if the slope is steep, else false.
- */
-static inline bool IsSteepSlope(Slope s)
-{
-	return (s & SLOPE_STEEP) != 0;
-}
-
-/**
- * Checks for non-continuous slope on halftile foundations.
- *
- * @param s The given #Slope.
- * @return True if the slope is non-continuous, else false.
- */
-static inline bool IsHalftileSlope(Slope s)
-{
-	return (s & SLOPE_HALFTILE) != 0;
-}
-
-/**
- * Return the complement of a slope.
- *
- * This method returns the complement of a slope. The complement of a
- * slope is a slope with raised corner which aren't raised in the given
- * slope.
- *
- * @pre The slope must neither be steep nor a halftile slope.
- * @param s The #Slope to get the complement.
- * @return a complement Slope of the given slope.
- */
-static inline Slope ComplementSlope(Slope s)
-{
-	assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
-	return (Slope)(0xF ^ s);
-}
-
-/**
- * Tests if a slope has a highest corner (i.e. one corner raised or a steep slope).
- *
- * Note: A halftile slope is ignored.
- *
- * @param s The #Slope.
- * @return  true iff the slope has a highest corner.
- */
-static inline bool HasSlopeHighestCorner(Slope s)
-{
-	s = (Slope)(s & ~SLOPE_HALFTILE_MASK);
-	return IsSteepSlope(s) || (s == SLOPE_W) || (s == SLOPE_S) || (s == SLOPE_E) || (s == SLOPE_N);
-}
-
-/**
- * Returns the highest corner of a slope (one corner raised or a steep slope).
- *
- * @pre      The slope must be a slope with one corner raised or a steep slope. A halftile slope is ignored.
- * @param s  The #Slope.
- * @return   Highest corner.
- */
-static inline Corner GetHighestSlopeCorner(Slope s)
-{
-	switch (s & ~SLOPE_HALFTILE_MASK) {
-		case SLOPE_W:
-		case SLOPE_STEEP_W: return CORNER_W;
-		case SLOPE_S:
-		case SLOPE_STEEP_S: return CORNER_S;
-		case SLOPE_E:
-		case SLOPE_STEEP_E: return CORNER_E;
-		case SLOPE_N:
-		case SLOPE_STEEP_N: return CORNER_N;
-		default: NOT_REACHED();
-	}
-}
-
-/**
- * Returns the leveled halftile of a halftile slope.
- *
- * @pre     The slope must be a halftile slope.
- * @param s The #Slope.
- * @return  The corner of the leveled halftile.
- */
-static inline Corner GetHalftileSlopeCorner(Slope s)
-{
-	assert(IsHalftileSlope(s));
-	return (Corner)((s >> 6) & 3);
-}
-
-/**
- * Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
- *
- * @param s The #Slope.
- * @return Relative height of highest corner.
- */
-static inline uint GetSlopeMaxZ(Slope s)
-{
-	if (s == SLOPE_FLAT) return 0;
-	if (IsSteepSlope(s)) return 2 * TILE_HEIGHT;
-	return TILE_HEIGHT;
-}
-
-/**
- * Returns the opposite corner.
- *
- * @param corner A #Corner.
- * @return The opposite corner to "corner".
- */
-static inline Corner OppositeCorner(Corner corner)
-{
-	return (Corner)(corner ^ 2);
-}
-
-/**
- * Returns the slope with a specific corner raised.
- *
- * @param corner The #Corner.
- * @return The #Slope with corner "corner" raised.
- */
-static inline Slope SlopeWithOneCornerRaised(Corner corner)
-{
-	assert(IsValidCorner(corner));
-	return (Slope)(1 << corner);
-}
-
-/**
- * Returns the slope with all except one corner raised.
- *
- * @param corner The #Corner.
- * @return The #Slope with all corners but "corner" raised.
- */
-static inline Slope SlopeWithThreeCornersRaised(Corner corner)
-{
-	return ComplementSlope(SlopeWithOneCornerRaised(corner));
-}
-
-/**
- * Adds a halftile slope to a slope.
- *
- * @param s #Slope without a halftile slope.
- * @param corner The #Corner of the halftile.
- * @return The #Slope s with the halftile slope added.
- */
-static inline Slope HalftileSlope(Slope s, Corner corner)
-{
-	assert(IsValidCorner(corner));
-	return (Slope)(s | SLOPE_HALFTILE | (corner << 6));
-}
-
-
-/**
- * Enumeration for Foundations.
- */
-enum Foundation {
-	FOUNDATION_NONE,             ///< The tile has no foundation, the slope remains unchanged.
-	FOUNDATION_LEVELED,          ///< The tile is leveled up to a flat slope.
-	FOUNDATION_INCLINED_X,       ///< The tile has an along X-axis inclined foundation.
-	FOUNDATION_INCLINED_Y,       ///< The tile has an along Y-axis inclined foundation.
-	FOUNDATION_STEEP_LOWER,      ///< The tile has a steep slope. The lowest corner is raised by a foundation to allow building railroad on the lower halftile.
-
-/* Halftile foundations */
-	FOUNDATION_STEEP_BOTH,       ///< The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is leveled.
-	FOUNDATION_HALFTILE_W,       ///< Level west halftile non-continuously.
-	FOUNDATION_HALFTILE_S,       ///< Level south halftile non-continuously.
-	FOUNDATION_HALFTILE_E,       ///< Level east halftile non-continuously.
-	FOUNDATION_HALFTILE_N,       ///< Level north halftile non-continuously.
-
-/* Special anti-zig-zag foundations for single horizontal/vertical track */
-	FOUNDATION_RAIL_W,           ///< Foundation for TRACK_BIT_LEFT, but not a leveled foundation.
-	FOUNDATION_RAIL_S,           ///< Foundation for TRACK_BIT_LOWER, but not a leveled foundation.
-	FOUNDATION_RAIL_E,           ///< Foundation for TRACK_BIT_RIGHT, but not a leveled foundation.
-	FOUNDATION_RAIL_N,           ///< Foundation for TRACK_BIT_UPPER, but not a leveled foundation.
-
-	FOUNDATION_INVALID = 0xFF    ///< Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
-};
-
-/**
- * Tests for FOUNDATION_NONE.
- *
- * @param f  Maybe a #Foundation.
- * @return   true iff f is a foundation.
- */
-static inline bool IsFoundation(Foundation f)
-{
-	return f != FOUNDATION_NONE;
-}
-
-/**
- * Tests if the foundation is a leveled foundation.
- *
- * @param f  The #Foundation.
- * @return   true iff f is a leveled foundation.
- */
-static inline bool IsLeveledFoundation(Foundation f)
-{
-	return f == FOUNDATION_LEVELED;
-}
-
-/**
- * Tests if the foundation is an inclined foundation.
- *
- * @param f  The #Foundation.
- * @return   true iff f is an inclined foundation.
- */
-static inline bool IsInclinedFoundation(Foundation f)
-{
-	return (f == FOUNDATION_INCLINED_X) || (f == FOUNDATION_INCLINED_Y);
-}
-
-/**
- * Tests if a foundation is a non-continuous foundation, i.e. halftile-foundation or FOUNDATION_STEEP_BOTH.
- *
- * @param f  The #Foundation.
- * @return   true iff f is a non-continuous foundation
- */
-static inline bool IsNonContinuousFoundation(Foundation f)
-{
-	return IS_INT_INSIDE(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1);
-}
-
-/**
- * Returns the halftile corner of a halftile-foundation
- *
- * @pre f != FOUNDATION_STEEP_BOTH
- *
- * @param f  The #Foundation.
- * @return   The #Corner with track.
- */
-static inline Corner GetHalftileFoundationCorner(Foundation f)
-{
-	assert(IS_INT_INSIDE(f, FOUNDATION_HALFTILE_W, FOUNDATION_HALFTILE_N + 1));
-	return (Corner)(f - FOUNDATION_HALFTILE_W);
-}
-
-/**
- * Tests if a foundation is a special rail foundation for single horizontal/vertical track.
- *
- * @param f  The #Foundation.
- * @return   true iff f is a special rail foundation for single horizontal/vertical track.
- */
-static inline bool IsSpecialRailFoundation(Foundation f)
-{
-	return IS_INT_INSIDE(f, FOUNDATION_RAIL_W, FOUNDATION_RAIL_N + 1);
-}
-
-/**
- * Returns the track corner of a special rail foundation
- *
- * @param f  The #Foundation.
- * @return   The #Corner with track.
- */
-static inline Corner GetRailFoundationCorner(Foundation f)
-{
-	assert(IsSpecialRailFoundation(f));
-	return (Corner)(f - FOUNDATION_RAIL_W);
-}
-
-/**
- * Returns the foundation needed to flatten a slope.
- * The returned foundation is either FOUNDATION_NONE if the tile was already flat, or FOUNDATION_LEVELED.
- *
- * @pre      The slope must not be steep.
- * @param s  The current #Slope.
- * @return   The needed #Foundation.
- */
-static inline Foundation FlatteningFoundation(Slope s)
-{
-	assert(!IsSteepSlope(s));
-	return (s == SLOPE_FLAT ? FOUNDATION_NONE : FOUNDATION_LEVELED);
-}
-
-/**
- * Returns the along a specific axis inclined foundation.
- *
- * @param axis  The #Axis.
- * @return      The needed #Foundation.
- */
-static inline Foundation InclinedFoundation(Axis axis)
-{
-	return (axis == AXIS_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y);
-}
-
-/**
- * Returns the halftile foundation for single horizontal/vertical track.
- *
- * @param corner The #Corner with the track.
- * @return       The wanted #Foundation.
- */
-static inline Foundation HalftileFoundation(Corner corner)
-{
-	assert(IsValidCorner(corner));
-	return (Foundation)(FOUNDATION_HALFTILE_W + corner);
-}
-
-/**
- * Returns the special rail foundation for single horizontal/vertical track.
- *
- * @param corner The #Corner with the track.
- * @return       The wanted #Foundation.
- */
-static inline Foundation SpecialRailFoundation(Corner corner)
-{
-	assert(IsValidCorner(corner));
-	return (Foundation)(FOUNDATION_RAIL_W + corner);
-}
-
-#endif /* SLOPE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/slope_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,304 @@
+/* $Id$ */
+
+/** @file slope_func.h Functions related to slopes. */
+
+#ifndef SLOPE_FUNC_H
+#define SLOPE_FUNC_H
+
+#include "core/math_func.hpp"
+#include "slope_type.h"
+#include "direction_type.h"
+#include "tile_type.h"
+
+/**
+ * Rangecheck for Corner enumeration.
+ *
+ * @param corner A #Corner.
+ * @return true iff corner is in a valid range.
+ */
+static inline bool IsValidCorner(Corner corner)
+{
+	return IsInsideMM(corner, 0, CORNER_END);
+}
+
+
+/**
+ * Checks if a slope is steep.
+ *
+ * @param s The given #Slope.
+ * @return True if the slope is steep, else false.
+ */
+static inline bool IsSteepSlope(Slope s)
+{
+	return (s & SLOPE_STEEP) != 0;
+}
+
+/**
+ * Checks for non-continuous slope on halftile foundations.
+ *
+ * @param s The given #Slope.
+ * @return True if the slope is non-continuous, else false.
+ */
+static inline bool IsHalftileSlope(Slope s)
+{
+	return (s & SLOPE_HALFTILE) != 0;
+}
+
+/**
+ * Return the complement of a slope.
+ *
+ * This method returns the complement of a slope. The complement of a
+ * slope is a slope with raised corner which aren't raised in the given
+ * slope.
+ *
+ * @pre The slope must neither be steep nor a halftile slope.
+ * @param s The #Slope to get the complement.
+ * @return a complement Slope of the given slope.
+ */
+static inline Slope ComplementSlope(Slope s)
+{
+	assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
+	return (Slope)(0xF ^ s);
+}
+
+/**
+ * Tests if a slope has a highest corner (i.e. one corner raised or a steep slope).
+ *
+ * Note: A halftile slope is ignored.
+ *
+ * @param s The #Slope.
+ * @return  true iff the slope has a highest corner.
+ */
+static inline bool HasSlopeHighestCorner(Slope s)
+{
+	s = (Slope)(s & ~SLOPE_HALFTILE_MASK);
+	return IsSteepSlope(s) || (s == SLOPE_W) || (s == SLOPE_S) || (s == SLOPE_E) || (s == SLOPE_N);
+}
+
+/**
+ * Returns the highest corner of a slope (one corner raised or a steep slope).
+ *
+ * @pre      The slope must be a slope with one corner raised or a steep slope. A halftile slope is ignored.
+ * @param s  The #Slope.
+ * @return   Highest corner.
+ */
+static inline Corner GetHighestSlopeCorner(Slope s)
+{
+	switch (s & ~SLOPE_HALFTILE_MASK) {
+		case SLOPE_W:
+		case SLOPE_STEEP_W: return CORNER_W;
+		case SLOPE_S:
+		case SLOPE_STEEP_S: return CORNER_S;
+		case SLOPE_E:
+		case SLOPE_STEEP_E: return CORNER_E;
+		case SLOPE_N:
+		case SLOPE_STEEP_N: return CORNER_N;
+		default: NOT_REACHED();
+	}
+}
+
+/**
+ * Returns the leveled halftile of a halftile slope.
+ *
+ * @pre     The slope must be a halftile slope.
+ * @param s The #Slope.
+ * @return  The corner of the leveled halftile.
+ */
+static inline Corner GetHalftileSlopeCorner(Slope s)
+{
+	assert(IsHalftileSlope(s));
+	return (Corner)((s >> 6) & 3);
+}
+
+/**
+ * Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
+ *
+ * @param s The #Slope.
+ * @return Relative height of highest corner.
+ */
+static inline uint GetSlopeMaxZ(Slope s)
+{
+	if (s == SLOPE_FLAT) return 0;
+	if (IsSteepSlope(s)) return 2 * TILE_HEIGHT;
+	return TILE_HEIGHT;
+}
+
+/**
+ * Returns the opposite corner.
+ *
+ * @param corner A #Corner.
+ * @return The opposite corner to "corner".
+ */
+static inline Corner OppositeCorner(Corner corner)
+{
+	return (Corner)(corner ^ 2);
+}
+
+/**
+ * Returns the slope with a specific corner raised.
+ *
+ * @param corner The #Corner.
+ * @return The #Slope with corner "corner" raised.
+ */
+static inline Slope SlopeWithOneCornerRaised(Corner corner)
+{
+	assert(IsValidCorner(corner));
+	return (Slope)(1 << corner);
+}
+
+/**
+ * Returns the slope with all except one corner raised.
+ *
+ * @param corner The #Corner.
+ * @return The #Slope with all corners but "corner" raised.
+ */
+static inline Slope SlopeWithThreeCornersRaised(Corner corner)
+{
+	return ComplementSlope(SlopeWithOneCornerRaised(corner));
+}
+
+/**
+ * Adds a halftile slope to a slope.
+ *
+ * @param s #Slope without a halftile slope.
+ * @param corner The #Corner of the halftile.
+ * @return The #Slope s with the halftile slope added.
+ */
+static inline Slope HalftileSlope(Slope s, Corner corner)
+{
+	assert(IsValidCorner(corner));
+	return (Slope)(s | SLOPE_HALFTILE | (corner << 6));
+}
+
+
+/**
+ * Tests for FOUNDATION_NONE.
+ *
+ * @param f  Maybe a #Foundation.
+ * @return   true iff f is a foundation.
+ */
+static inline bool IsFoundation(Foundation f)
+{
+	return f != FOUNDATION_NONE;
+}
+
+/**
+ * Tests if the foundation is a leveled foundation.
+ *
+ * @param f  The #Foundation.
+ * @return   true iff f is a leveled foundation.
+ */
+static inline bool IsLeveledFoundation(Foundation f)
+{
+	return f == FOUNDATION_LEVELED;
+}
+
+/**
+ * Tests if the foundation is an inclined foundation.
+ *
+ * @param f  The #Foundation.
+ * @return   true iff f is an inclined foundation.
+ */
+static inline bool IsInclinedFoundation(Foundation f)
+{
+	return (f == FOUNDATION_INCLINED_X) || (f == FOUNDATION_INCLINED_Y);
+}
+
+/**
+ * Tests if a foundation is a non-continuous foundation, i.e. halftile-foundation or FOUNDATION_STEEP_BOTH.
+ *
+ * @param f  The #Foundation.
+ * @return   true iff f is a non-continuous foundation
+ */
+static inline bool IsNonContinuousFoundation(Foundation f)
+{
+	return IsInsideMM(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1);
+}
+
+/**
+ * Returns the halftile corner of a halftile-foundation
+ *
+ * @pre f != FOUNDATION_STEEP_BOTH
+ *
+ * @param f  The #Foundation.
+ * @return   The #Corner with track.
+ */
+static inline Corner GetHalftileFoundationCorner(Foundation f)
+{
+	assert(IsInsideMM(f, FOUNDATION_HALFTILE_W, FOUNDATION_HALFTILE_N + 1));
+	return (Corner)(f - FOUNDATION_HALFTILE_W);
+}
+
+/**
+ * Tests if a foundation is a special rail foundation for single horizontal/vertical track.
+ *
+ * @param f  The #Foundation.
+ * @return   true iff f is a special rail foundation for single horizontal/vertical track.
+ */
+static inline bool IsSpecialRailFoundation(Foundation f)
+{
+	return IsInsideMM(f, FOUNDATION_RAIL_W, FOUNDATION_RAIL_N + 1);
+}
+
+/**
+ * Returns the track corner of a special rail foundation
+ *
+ * @param f  The #Foundation.
+ * @return   The #Corner with track.
+ */
+static inline Corner GetRailFoundationCorner(Foundation f)
+{
+	assert(IsSpecialRailFoundation(f));
+	return (Corner)(f - FOUNDATION_RAIL_W);
+}
+
+/**
+ * Returns the foundation needed to flatten a slope.
+ * The returned foundation is either FOUNDATION_NONE if the tile was already flat, or FOUNDATION_LEVELED.
+ *
+ * @pre      The slope must not be steep.
+ * @param s  The current #Slope.
+ * @return   The needed #Foundation.
+ */
+static inline Foundation FlatteningFoundation(Slope s)
+{
+	assert(!IsSteepSlope(s));
+	return (s == SLOPE_FLAT ? FOUNDATION_NONE : FOUNDATION_LEVELED);
+}
+
+/**
+ * Returns the along a specific axis inclined foundation.
+ *
+ * @param axis  The #Axis.
+ * @return      The needed #Foundation.
+ */
+static inline Foundation InclinedFoundation(Axis axis)
+{
+	return (axis == AXIS_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y);
+}
+
+/**
+ * Returns the halftile foundation for single horizontal/vertical track.
+ *
+ * @param corner The #Corner with the track.
+ * @return       The wanted #Foundation.
+ */
+static inline Foundation HalftileFoundation(Corner corner)
+{
+	assert(IsValidCorner(corner));
+	return (Foundation)(FOUNDATION_HALFTILE_W + corner);
+}
+
+/**
+ * Returns the special rail foundation for single horizontal/vertical track.
+ *
+ * @param corner The #Corner with the track.
+ * @return       The wanted #Foundation.
+ */
+static inline Foundation SpecialRailFoundation(Corner corner)
+{
+	assert(IsValidCorner(corner));
+	return (Foundation)(FOUNDATION_RAIL_W + corner);
+}
+
+#endif /* SLOPE_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/slope_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,101 @@
+/* $Id$ */
+
+/**
+ * @file slope_type.h Definitions of a slope.
+ * This file defines the enumeration and helper functions for handling
+ * the slope info of a tile.
+ */
+
+#ifndef SLOPE_TYPE_H
+#define SLOPE_TYPE_H
+
+#include "core/enum_type.hpp"
+
+/**
+ * Enumeration of tile corners
+ */
+enum Corner {
+	CORNER_W = 0,
+	CORNER_S = 1,
+	CORNER_E = 2,
+	CORNER_N = 3,
+	CORNER_END,
+	CORNER_INVALID = 0xFF
+};
+
+
+/**
+ * Enumeration for the slope-type.
+ *
+ * This enumeration use the chars N,E,S,W corresponding the
+ * direction north, east, south and west. The top corner of a tile
+ * is the north-part of the tile. The whole slope is encoded with
+ * 5 bits, 4 bits for each corner and 1 bit for a steep-flag.
+ *
+ * For halftile slopes an extra 3 bits are used to represent this
+ * properly; 1 bit for a halftile-flag and 2 bits to encode which
+ * extra side (corner) is leveled when the slope of the first 5
+ * bits is applied. This means that there can only be one leveled
+ * slope for steep slopes, which is logical because two leveled
+ * slopes would mean that it is not a steep slope as halftile
+ * slopes only span one height level.
+ */
+enum Slope {
+	SLOPE_FLAT     = 0x00,                                  ///< a flat tile
+	SLOPE_W        = 0x01,                                  ///< the west corner of the tile is raised
+	SLOPE_S        = 0x02,                                  ///< the south corner of the tile is raised
+	SLOPE_E        = 0x04,                                  ///< the east corner of the tile is raised
+	SLOPE_N        = 0x08,                                  ///< the north corner of the tile is raised
+	SLOPE_STEEP    = 0x10,                                  ///< indicates the slope is steep
+	SLOPE_NW       = SLOPE_N | SLOPE_W,                     ///< north and west corner are raised
+	SLOPE_SW       = SLOPE_S | SLOPE_W,                     ///< south and west corner are raised
+	SLOPE_SE       = SLOPE_S | SLOPE_E,                     ///< south and east corner are raised
+	SLOPE_NE       = SLOPE_N | SLOPE_E,                     ///< north and east corner are raised
+	SLOPE_EW       = SLOPE_E | SLOPE_W,                     ///< east and west corner are raised
+	SLOPE_NS       = SLOPE_N | SLOPE_S,                     ///< north and south corner are raised
+	SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT
+	SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,           ///< north, west and south corner are raised
+	SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,           ///< west, south and east corner are raised
+	SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,           ///< south, east and north corner are raised
+	SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,           ///< east, north and west corner are raised
+	SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,               ///< a steep slope falling to east (from west)
+	SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,               ///< a steep slope falling to north (from south)
+	SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,               ///< a steep slope falling to west (from east)
+	SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,               ///< a steep slope falling to south (from north)
+
+	SLOPE_HALFTILE = 0x20,                                  ///< one halftile is leveled (non continuous slope)
+	SLOPE_HALFTILE_MASK = 0xE0,                             ///< three bits used for halftile slopes
+	SLOPE_HALFTILE_W = SLOPE_HALFTILE | (CORNER_W << 6),    ///< the west halftile is leveled (non continuous slope)
+	SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6),    ///< the south halftile is leveled (non continuous slope)
+	SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6),    ///< the east halftile is leveled (non continuous slope)
+	SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6),    ///< the north halftile is leveled (non continuous slope)
+};
+
+
+/**
+ * Enumeration for Foundations.
+ */
+enum Foundation {
+	FOUNDATION_NONE,             ///< The tile has no foundation, the slope remains unchanged.
+	FOUNDATION_LEVELED,          ///< The tile is leveled up to a flat slope.
+	FOUNDATION_INCLINED_X,       ///< The tile has an along X-axis inclined foundation.
+	FOUNDATION_INCLINED_Y,       ///< The tile has an along Y-axis inclined foundation.
+	FOUNDATION_STEEP_LOWER,      ///< The tile has a steep slope. The lowest corner is raised by a foundation to allow building railroad on the lower halftile.
+
+	/* Halftile foundations */
+	FOUNDATION_STEEP_BOTH,       ///< The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is leveled.
+	FOUNDATION_HALFTILE_W,       ///< Level west halftile non-continuously.
+	FOUNDATION_HALFTILE_S,       ///< Level south halftile non-continuously.
+	FOUNDATION_HALFTILE_E,       ///< Level east halftile non-continuously.
+	FOUNDATION_HALFTILE_N,       ///< Level north halftile non-continuously.
+
+	/* Special anti-zig-zag foundations for single horizontal/vertical track */
+	FOUNDATION_RAIL_W,           ///< Foundation for TRACK_BIT_LEFT, but not a leveled foundation.
+	FOUNDATION_RAIL_S,           ///< Foundation for TRACK_BIT_LOWER, but not a leveled foundation.
+	FOUNDATION_RAIL_E,           ///< Foundation for TRACK_BIT_RIGHT, but not a leveled foundation.
+	FOUNDATION_RAIL_N,           ///< Foundation for TRACK_BIT_UPPER, but not a leveled foundation.
+
+	FOUNDATION_INVALID = 0xFF    ///< Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
+};
+
+#endif /* SLOPE_TYPE_H */
--- a/src/smallmap_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/smallmap_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,30 +4,31 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "bridge_map.h"
 #include "clear_map.h"
 #include "industry_map.h"
 #include "industry.h"
 #include "station_map.h"
 #include "table/strings.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "landscape.h"
-#include "map.h"
-#include "tile.h"
 #include "gui.h"
+#include "window_gui.h"
 #include "tree_map.h"
 #include "tunnel_map.h"
-#include "window.h"
-#include "gfx.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "player.h"
-#include "vehicle.h"
 #include "town.h"
-#include "sound.h"
 #include "variables.h"
 #include "blitter/factory.hpp"
+#include "tunnelbridge_map.h"
+#include "strings_func.h"
+#include "zoom_func.h"
+#include "core/endian_func.hpp"
+#include "vehicle_base.h"
+#include "sound_func.h"
+
 
 static const Widget _smallmap_widgets[] = {
 {  WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
@@ -337,13 +338,8 @@
 	TileType t = GetTileType(tile);
 
 	if (t == MP_TUNNELBRIDGE) {
-		TransportType tt;
+		TransportType tt = GetTunnelBridgeTransportType(tile);
 
-		if (IsTunnel(tile)) {
-			tt = GetTunnelTransportType(tile);
-		} else {
-			tt = GetBridgeTransportType(tile);
-		}
 		switch (tt) {
 			case TRANSPORT_RAIL: t = MP_RAILWAY; break;
 			case TRANSPORT_ROAD: t = MP_ROAD;    break;
@@ -612,10 +608,10 @@
 		}
 	}
 
-	tile_x = WP(w,smallmap_d).scroll_x / TILE_SIZE;
-	tile_y = WP(w,smallmap_d).scroll_y / TILE_SIZE;
+	tile_x = WP(w, smallmap_d).scroll_x / TILE_SIZE;
+	tile_y = WP(w, smallmap_d).scroll_y / TILE_SIZE;
 
-	dx = dpi->left + WP(w,smallmap_d).subscroll;
+	dx = dpi->left + WP(w, smallmap_d).subscroll;
 	tile_x -= dx / 4;
 	tile_y += dx / 4;
 	dx &= 3;
@@ -689,21 +685,21 @@
 					(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
 				/* Remap into flat coordinates. */
 				Point pt = RemapCoords(
-					v->x_pos / TILE_SIZE - WP(w,smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world
-					v->y_pos / TILE_SIZE - WP(w,smallmap_d).scroll_y / TILE_SIZE, //    dtto
+					v->x_pos / TILE_SIZE - WP(w, smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world
+					v->y_pos / TILE_SIZE - WP(w, smallmap_d).scroll_y / TILE_SIZE, //    dtto
 					0);
 				x = pt.x;
 				y = pt.y;
 
 				/* Check if y is out of bounds? */
 				y -= dpi->top;
-				if (!IS_INT_INSIDE(y, 0, dpi->height)) continue;
+				if (!IsInsideMM(y, 0, dpi->height)) continue;
 
 				/* Default is to draw both pixels. */
 				skip = false;
 
 				/* Offset X coordinate */
-				x -= WP(w,smallmap_d).subscroll + 3 + dpi->left;
+				x -= WP(w, smallmap_d).subscroll + 3 + dpi->left;
 
 				if (x < 0) {
 					/* if x+1 is 0, that means we're on the very left edge,
@@ -735,7 +731,7 @@
 				(int)(TileX(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_x) / TILE_SIZE,
 				(int)(TileY(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_y) / TILE_SIZE,
 				0);
-			x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
+			x = pt.x - WP(w, smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
 			y = pt.y;
 
 			/* Check if the town sign is within bounds */
@@ -766,8 +762,8 @@
 		x /= TILE_SIZE;
 		y /= TILE_SIZE;
 
-		x -= WP(w,smallmap_d).subscroll;
-		x2 -= WP(w,smallmap_d).subscroll;
+		x -= WP(w, smallmap_d).subscroll;
+		x2 -= WP(w, smallmap_d).subscroll;
 
 		DrawVertMapIndicator(x, y, x, y2);
 		DrawVertMapIndicator(x2, y, x2, y2);
@@ -805,8 +801,8 @@
 			DrawPixelInfo new_dpi;
 
 			/* Hide Enable all/Disable all buttons if is not industry type small map*/
-			SetWindowWidgetHiddenState(w, SM_WIDGET_ENABLEINDUSTRIES, _smallmap_type != SMT_INDUSTRY);
-			SetWindowWidgetHiddenState(w, SM_WIDGET_DISABLEINDUSTRIES, _smallmap_type != SMT_INDUSTRY);
+			w->SetWidgetHiddenState(SM_WIDGET_ENABLEINDUSTRIES, _smallmap_type != SMT_INDUSTRY);
+			w->SetWidgetHiddenState(SM_WIDGET_DISABLEINDUSTRIES, _smallmap_type != SMT_INDUSTRY);
 
 			/* draw the window */
 			SetDParam(0, STR_00E5_CONTOURS + _smallmap_type);
@@ -878,7 +874,7 @@
 					 */
 					_left_button_clicked = false;
 
-					pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0);
+					pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0);
 					WP(w2, vp_d).dest_scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
 					WP(w2, vp_d).dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
 
@@ -891,9 +887,9 @@
 				case SM_WIDGET_ROUTES:     // Show transport routes
 				case SM_WIDGET_VEGETATION: // Show vegetation
 				case SM_WIDGET_OWNERS:     // Show land owners
-					RaiseWindowWidget(w, _smallmap_type + SM_WIDGET_CONTOUR);
+					w->RaiseWidget(_smallmap_type + SM_WIDGET_CONTOUR);
 					_smallmap_type = e->we.click.widget - SM_WIDGET_CONTOUR;
-					LowerWindowWidget(w, _smallmap_type + SM_WIDGET_CONTOUR);
+					w->LowerWidget(_smallmap_type + SM_WIDGET_CONTOUR);
 
 					SetWindowDirty(w);
 					SndPlayFx(SND_15_BEEP);
@@ -907,8 +903,8 @@
 					break;
 
 				case SM_WIDGET_TOGGLETOWNNAME: // Toggle town names
-					ToggleWidgetLoweredState(w, SM_WIDGET_TOGGLETOWNNAME);
-					_smallmap_show_towns = IsWindowWidgetLowered(w, SM_WIDGET_TOGGLETOWNNAME);
+					w->ToggleWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME);
+					_smallmap_show_towns = w->IsWidgetLowered(SM_WIDGET_TOGGLETOWNNAME);
 
 					SetWindowDirty(w);
 					SndPlayFx(SND_15_BEEP);
@@ -940,8 +936,8 @@
 							}
 						}
 						/* Raise the two buttons "all", as we have done a specific choice */
-						RaiseWindowWidget(w, SM_WIDGET_ENABLEINDUSTRIES);
-						RaiseWindowWidget(w, SM_WIDGET_DISABLEINDUSTRIES);
+						w->RaiseWidget(SM_WIDGET_ENABLEINDUSTRIES);
+						w->RaiseWidget(SM_WIDGET_DISABLEINDUSTRIES);
 						SetWindowDirty(w);
 					}
 					break;
@@ -951,8 +947,8 @@
 						_legend_from_industries[i].show_on_map = true;
 					}
 					/* toggle appeareance indicating the choice */
-					LowerWindowWidget(w, SM_WIDGET_ENABLEINDUSTRIES);
-					RaiseWindowWidget(w, SM_WIDGET_DISABLEINDUSTRIES);
+					w->LowerWidget(SM_WIDGET_ENABLEINDUSTRIES);
+					w->RaiseWidget(SM_WIDGET_DISABLEINDUSTRIES);
 					SetWindowDirty(w);
 					break;
 
@@ -961,8 +957,8 @@
 						_legend_from_industries[i].show_on_map = false;
 					}
 					/* toggle appeareance indicating the choice */
-					RaiseWindowWidget(w, SM_WIDGET_ENABLEINDUSTRIES);
-					LowerWindowWidget(w, SM_WIDGET_DISABLEINDUSTRIES);
+					w->RaiseWidget(SM_WIDGET_ENABLEINDUSTRIES);
+					w->LowerWidget(SM_WIDGET_DISABLEINDUSTRIES);
 					SetWindowDirty(w);
 					break;
 				}
@@ -1085,8 +1081,8 @@
 		}
 	}
 
-	LowerWindowWidget(w, _smallmap_type + SMT_OWNER);
-	SetWindowWidgetLoweredState(w, SM_WIDGET_TOGGLETOWNNAME, _smallmap_show_towns);
+	w->LowerWidget(_smallmap_type + SMT_OWNER);
+	w->SetWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME, _smallmap_show_towns);
 
 	SmallMapCenterOnCurrentPos(w);
 }
@@ -1115,7 +1111,7 @@
 		/* New viewport start at (zero,zero) */
 		AssignWindowViewport(w, 3, 17, w->widget[4].right - w->widget[4].left - 1, w->widget[4].bottom - w->widget[4].top - 1, 0, ZOOM_LVL_VIEWPORT);
 
-		DisableWindowWidget(w, 5);
+		w->DisableWidget(5);
 		break;
 
 	case WE_PAINT:
--- a/src/sound.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/sound.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,21 +4,20 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "landscape.h"
-#include "map.h"
 #include "mixer.h"
-#include "sound.h"
-#include "vehicle.h"
-#include "window.h"
-#include "viewport.h"
+#include "sound_func.h"
 #include "fileio.h"
 #include "newgrf_sound.h"
-#include "helpers.hpp"
 #include "fios.h"
+#include "window_gui.h"
+#include "core/alloc_func.hpp"
+#include "map_func.h"
+#include "vehicle_base.h"
 
 static uint _file_count;
 static FileEntry *_files;
+MusicFileSettings msf;
 
 // Number of levels of panning per side
 #define PANNING_LEVELS 16
@@ -157,7 +156,7 @@
 
 
 static const byte _vol_factor_by_zoom[] = {255, 190, 134, 87};
-assert_compile(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END);
+assert_compile(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END - ZOOM_LVL_BEGIN);
 
 static const byte _sound_base_vol[] = {
 	128,  90, 128, 128, 128, 128, 128, 128,
@@ -209,14 +208,14 @@
 		const ViewPort *vp = (*wz)->viewport;
 
 		if (vp != NULL &&
-				IS_INSIDE_1D(x, vp->virtual_left, vp->virtual_width) &&
-				IS_INSIDE_1D(y, vp->virtual_top, vp->virtual_height)) {
+				IsInsideBS(x, vp->virtual_left, vp->virtual_width) &&
+				IsInsideBS(y, vp->virtual_top, vp->virtual_height)) {
 			int left = (x - vp->virtual_left);
 
 			StartSound(
 				sound,
 				left / max(1, vp->virtual_width / ((PANNING_LEVELS << 1) + 1)) - PANNING_LEVELS,
-				(GetSound(sound)->volume * msf.effect_vol * _vol_factor_by_zoom[vp->zoom]) >> 15
+				(GetSound(sound)->volume * msf.effect_vol * _vol_factor_by_zoom[vp->zoom - ZOOM_LVL_BEGIN]) >> 15
 			);
 			return;
 		}
--- a/src/sound.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/* $Id$ */
-
-/** @file sound.h */
-
-#ifndef SOUND_H
-#define SOUND_H
-
-#include "helpers.hpp"
-
-struct MusicFileSettings {
-	byte playlist;
-	byte music_vol;
-	byte effect_vol;
-	byte custom_1[33];
-	byte custom_2[33];
-	bool playing;
-	bool shuffle;
-	char extmidi[80];
-};
-
-VARDEF MusicFileSettings msf;
-
-struct FileEntry {
-	uint8 file_slot;
-	uint32 file_offset;
-	uint32 file_size;
-	uint16 rate;
-	uint8 bits_per_sample;
-	uint8 channels;
-	uint8 volume;
-	uint8 priority;
-};
-
-bool SoundInitialize(const char *filename);
-uint GetNumOriginalSounds();
-
-enum SoundFx {
-	SND_BEGIN = 0,
-	SND_02_SPLAT = 0,                          //  0 == 0x00 !
-	SND_03_FACTORY_WHISTLE,
-	SND_04_TRAIN,
-	SND_05_TRAIN_THROUGH_TUNNEL,
-	SND_06_SHIP_HORN,
-	SND_07_FERRY_HORN,
-	SND_08_PLANE_TAKE_OFF,
-	SND_09_JET,
-	SND_0A_TRAIN_HORN,
-	SND_0B_MINING_MACHINERY,
-	SND_0C_ELECTRIC_SPARK,
-	SND_0D_STEAM,
-	SND_0E_LEVEL_CROSSING,
-	SND_0F_VEHICLE_BREAKDOWN,
-	SND_10_TRAIN_BREAKDOWN,
-	SND_11_CRASH,
-	SND_12_EXPLOSION,                      // 16 == 0x10
-	SND_13_BIG_CRASH,
-	SND_14_CASHTILL,
-	SND_15_BEEP,                           // 19 == 0x13
-	SND_16_MORSE,                          // 20 == 0x14
-	SND_17_SKID_PLANE,
-	SND_18_HELICOPTER,
-	SND_19_BUS_START_PULL_AWAY,
-	SND_1A_BUS_START_PULL_AWAY_WITH_HORN,
-	SND_1B_TRUCK_START,
-	SND_1C_TRUCK_START_2,
-	SND_1D_APPLAUSE,
-	SND_1E_OOOOH,
-	SND_1F_SPLAT,                          // 29 == 0x1D
-	SND_20_SPLAT_2,                        // 30 == 0x1E
-	SND_21_JACKHAMMER,
-	SND_22_CAR_HORN,
-	SND_23_CAR_HORN_2,
-	SND_24_SHEEP,
-	SND_25_COW,
-	SND_26_HORSE,
-	SND_27_BLACKSMITH_ANVIL,
-	SND_28_SAWMILL,                        // 38 == 0x26 !
-	SND_00_GOOD_YEAR,                      // 39 == 0x27 !
-	SND_01_BAD_YEAR,                       // 40 == 0x28 !
-	SND_29_RIP,                            // 41 == 0x29 !
-	SND_2A_EXTRACT_AND_POP,
-	SND_2B_COMEDY_HIT,
-	SND_2C_MACHINERY,
-	SND_2D_RIP_2,
-	SND_2E_EXTRACT_AND_POP,
-	SND_2F_POP,
-	SND_30_CARTOON_SOUND,
-	SND_31_EXTRACT,
-	SND_32_POP_2,
-	SND_33_PLASTIC_MINE,
-	SND_34_WIND,
-	SND_35_COMEDY_BREAKDOWN,
-	SND_36_CARTOON_CRASH,
-	SND_37_BALLOON_SQUEAK,
-	SND_38_CHAINSAW,
-	SND_39_HEAVY_WIND,
-	SND_3A_COMEDY_BREAKDOWN_2,
-	SND_3B_JET_OVERHEAD,
-	SND_3C_COMEDY_CAR,
-	SND_3D_ANOTHER_JET_OVERHEAD,
-	SND_3E_COMEDY_CAR_2,
-	SND_3F_COMEDY_CAR_3,
-	SND_40_COMEDY_CAR_START_AND_PULL_AWAY,
-	SND_41_MAGLEV,
-	SND_42_LOON_BIRD,
-	SND_43_LION,
-	SND_44_MONKEYS,
-	SND_45_PLANE_CRASHING,
-	SND_46_PLANE_ENGINE_SPUTTERING,
-	SND_47_MAGLEV_2,
-	SND_48_DISTANT_BIRD,                    // 72 == 0x48
-	SND_END
-};
-
-/** Define basic enum properties */
-template <> struct EnumPropsT<SoundFx> : MakeEnumPropsT<SoundFx, byte, SND_BEGIN, SND_END, SND_END> {};
-typedef TinyEnumT<SoundFx> SoundFxByte;
-
-void SndPlayTileFx(SoundFx sound, TileIndex tile);
-void SndPlayVehicleFx(SoundFx sound, const Vehicle *v);
-void SndPlayFx(SoundFx sound);
-void SndCopyToPool();
-
-#endif /* SOUND_H */
--- a/src/sound/cocoa_s.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/sound/cocoa_s.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,9 @@
 
 #ifdef WITH_COCOA
 
+#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
+#include <AvailabilityMacros.h>
+
 #include <AudioUnit/AudioUnit.h>
 
 /* Name conflict */
@@ -19,6 +22,7 @@
 #include "../debug.h"
 #include "../driver.h"
 #include "../mixer.h"
+#include "../core/endian_func.hpp"
 
 #include "cocoa_s.h"
 
--- a/src/sound/win32_s.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/sound/win32_s.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,9 +3,8 @@
 #include "../stdafx.h"
 #include "../openttd.h"
 #include "../driver.h"
-#include "../functions.h"
 #include "../mixer.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
 #include "win32_s.h"
 #include <windows.h>
 #include <mmsystem.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sound_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,22 @@
+/* $Id$ */
+
+/** @file sound_func.h Functions related to sound. */
+
+#ifndef SOUND_FUNC_H
+#define SOUND_FUNC_H
+
+#include "sound_type.h"
+#include "vehicle_type.h"
+#include "tile_type.h"
+
+extern MusicFileSettings msf;
+
+bool SoundInitialize(const char *filename);
+uint GetNumOriginalSounds();
+
+void SndPlayTileFx(SoundFx sound, TileIndex tile);
+void SndPlayVehicleFx(SoundFx sound, const Vehicle *v);
+void SndPlayFx(SoundFx sound);
+void SndCopyToPool();
+
+#endif /* SOUND_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sound_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,114 @@
+/* $Id$ */
+
+/** @file sound_type.h Types related to sounds. */
+
+#ifndef SOUND_TYPE_H
+#define SOUND_TYPE_H
+
+#include "core/enum_type.hpp"
+
+struct MusicFileSettings {
+	byte playlist;
+	byte music_vol;
+	byte effect_vol;
+	byte custom_1[33];
+	byte custom_2[33];
+	bool playing;
+	bool shuffle;
+	char extmidi[80];
+};
+
+struct FileEntry {
+	uint8 file_slot;
+	uint32 file_offset;
+	uint32 file_size;
+	uint16 rate;
+	uint8 bits_per_sample;
+	uint8 channels;
+	uint8 volume;
+	uint8 priority;
+};
+
+enum SoundFx {
+	SND_BEGIN = 0,
+	SND_02_SPLAT = 0,                          //  0 == 0x00 !
+	SND_03_FACTORY_WHISTLE,
+	SND_04_TRAIN,
+	SND_05_TRAIN_THROUGH_TUNNEL,
+	SND_06_SHIP_HORN,
+	SND_07_FERRY_HORN,
+	SND_08_PLANE_TAKE_OFF,
+	SND_09_JET,
+	SND_0A_TRAIN_HORN,
+	SND_0B_MINING_MACHINERY,
+	SND_0C_ELECTRIC_SPARK,
+	SND_0D_STEAM,
+	SND_0E_LEVEL_CROSSING,
+	SND_0F_VEHICLE_BREAKDOWN,
+	SND_10_TRAIN_BREAKDOWN,
+	SND_11_CRASH,
+	SND_12_EXPLOSION,                      // 16 == 0x10
+	SND_13_BIG_CRASH,
+	SND_14_CASHTILL,
+	SND_15_BEEP,                           // 19 == 0x13
+	SND_16_MORSE,                          // 20 == 0x14
+	SND_17_SKID_PLANE,
+	SND_18_HELICOPTER,
+	SND_19_BUS_START_PULL_AWAY,
+	SND_1A_BUS_START_PULL_AWAY_WITH_HORN,
+	SND_1B_TRUCK_START,
+	SND_1C_TRUCK_START_2,
+	SND_1D_APPLAUSE,
+	SND_1E_OOOOH,
+	SND_1F_SPLAT,                          // 29 == 0x1D
+	SND_20_SPLAT_2,                        // 30 == 0x1E
+	SND_21_JACKHAMMER,
+	SND_22_CAR_HORN,
+	SND_23_CAR_HORN_2,
+	SND_24_SHEEP,
+	SND_25_COW,
+	SND_26_HORSE,
+	SND_27_BLACKSMITH_ANVIL,
+	SND_28_SAWMILL,                        // 38 == 0x26 !
+	SND_00_GOOD_YEAR,                      // 39 == 0x27 !
+	SND_01_BAD_YEAR,                       // 40 == 0x28 !
+	SND_29_RIP,                            // 41 == 0x29 !
+	SND_2A_EXTRACT_AND_POP,
+	SND_2B_COMEDY_HIT,
+	SND_2C_MACHINERY,
+	SND_2D_RIP_2,
+	SND_2E_EXTRACT_AND_POP,
+	SND_2F_POP,
+	SND_30_CARTOON_SOUND,
+	SND_31_EXTRACT,
+	SND_32_POP_2,
+	SND_33_PLASTIC_MINE,
+	SND_34_WIND,
+	SND_35_COMEDY_BREAKDOWN,
+	SND_36_CARTOON_CRASH,
+	SND_37_BALLOON_SQUEAK,
+	SND_38_CHAINSAW,
+	SND_39_HEAVY_WIND,
+	SND_3A_COMEDY_BREAKDOWN_2,
+	SND_3B_JET_OVERHEAD,
+	SND_3C_COMEDY_CAR,
+	SND_3D_ANOTHER_JET_OVERHEAD,
+	SND_3E_COMEDY_CAR_2,
+	SND_3F_COMEDY_CAR_3,
+	SND_40_COMEDY_CAR_START_AND_PULL_AWAY,
+	SND_41_MAGLEV,
+	SND_42_LOON_BIRD,
+	SND_43_LION,
+	SND_44_MONKEYS,
+	SND_45_PLANE_CRASHING,
+	SND_46_PLANE_ENGINE_SPUTTERING,
+	SND_47_MAGLEV_2,
+	SND_48_DISTANT_BIRD,                    // 72 == 0x48
+	SND_END
+};
+
+/** Define basic enum properties */
+template <> struct EnumPropsT<SoundFx> : MakeEnumPropsT<SoundFx, byte, SND_BEGIN, SND_END, SND_END> {};
+typedef TinyEnumT<SoundFx> SoundFxByte;
+
+#endif /* SOUND_TYPE_H */
--- a/src/sprite.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/sprite.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,19 @@
 #ifndef SPRITE_H
 #define SPRITE_H
 
+#include "gfx_type.h"
+
+#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
+#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
+
+/**
+ * Whether a sprite comes from the original graphics files or a new grf file
+ * (either supplied by OpenTTD or supplied by the user).
+ *
+ * @param sprite The sprite to check
+ * @return True if it is a new sprite, or false if it is original.
+ */
+#define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE)
 
 /* The following describes bunch of sprites to be drawn together in a single 3D
  * bounding box. Used especially for various multi-sprite buildings (like
--- a/src/spritecache.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/spritecache.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,15 +5,13 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "variables.h"
-#include "string.h"
 #include "debug.h"
-#include "functions.h"
-#include "macros.h"
 #include "spritecache.h"
 #include "table/sprites.h"
 #include "fileio.h"
-#include "helpers.hpp"
 #include "spriteloader/grf.hpp"
+#include "core/alloc_func.hpp"
+#include "core/math_func.hpp"
 #ifdef WITH_PNG
 #include "spriteloader/png.hpp"
 #endif /* WITH_PNG */
@@ -53,10 +51,6 @@
 
 		_spritecache = ReallocT(_spritecache, items);
 
-		if (_spritecache == NULL) {
-			error("Unable to allocate sprite cache of %d items (%d bytes)", items, items * sizeof(*_spritecache));
-		}
-
 		/* Reset the new items and update the count */
 		memset(_spritecache + _spritecache_items, 0, (items - _spritecache_items) * sizeof(*_spritecache));
 		_spritecache_items = items;
@@ -411,8 +405,7 @@
 
 	/* Display an error message and die, in case we found no sprite at all.
 	 * This shouldn't really happen, unless all sprites are locked. */
-	if (best == (uint)-1)
-		error("Out of sprite memory");
+	if (best == (uint)-1) error("Out of sprite memory");
 
 	/* Mark the block as free (the block must be in use) */
 	s = (MemBlock*)GetSpriteCache(best)->ptr - 1;
@@ -491,7 +484,7 @@
 void GfxInitSpriteMem()
 {
 	/* initialize sprite cache heap */
-	if (_spritecache_ptr == NULL) _spritecache_ptr = (MemBlock*)malloc(_sprite_cache_size * 1024 * 1024);
+	if (_spritecache_ptr == NULL) _spritecache_ptr = (MemBlock*)MallocT<byte>(_sprite_cache_size * 1024 * 1024);
 
 	/* A big free block */
 	_spritecache_ptr->size = ((_sprite_cache_size * 1024 * 1024) - sizeof(MemBlock)) | S_FREE_MASK;
--- a/src/spritecache.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/spritecache.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef SPRITECACHE_H
 #define SPRITECACHE_H
 
+#include "gfx_type.h"
+
 struct Sprite {
 	byte height;
 	uint16 width;
--- a/src/spriteloader/grf.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/spriteloader/grf.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,9 +3,10 @@
 /** @file grf.cpp */
 
 #include "../stdafx.h"
-#include "../gfx.h"
+#include "../gfx_func.h"
 #include "../fileio.h"
 #include "../debug.h"
+#include "../core/alloc_func.hpp"
 #include "grf.hpp"
 
 bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, const char *filename, uint8 file_slot, uint32 file_pos)
--- a/src/spriteloader/png.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/spriteloader/png.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,10 +5,11 @@
 #ifdef WITH_PNG
 
 #include "../stdafx.h"
-#include "../gfx.h"
+#include "../gfx_func.h"
 #include "../fileio.h"
-#include "../variables.h"
 #include "../debug.h"
+#include "../core/alloc_func.hpp"
+#include "../core/endian_func.hpp"
 #include "png.hpp"
 #include <png.h>
 
@@ -144,7 +145,7 @@
 		pixelsize = sizeof(uint8);
 	}
 
-	row_pointer = (png_byte *)malloc(info_ptr->width * pixelsize);
+	row_pointer = (png_byte *)MallocT<byte>(info_ptr->width * pixelsize);
 	if (row_pointer == NULL) {
 		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
 		return false;
--- a/src/squirrel_helper.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/squirrel_helper.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,6 +6,8 @@
 #define SQUIRREL_HELPER_HPP
 
 #include <squirrel.h>
+#include "core/math_func.hpp"
+#include "economy_type.h"
 
 /**
  * The Squirrel convert routines
--- a/src/squirrel_std.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/squirrel_std.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,7 +5,6 @@
 #include "debug.h"
 #include "squirrel.hpp"
 #include "squirrel_std.hpp"
-#include "helpers.hpp"
 
 /* abs() is normally defined to myabs(), which we don't want in this file */
 #undef abs
--- a/src/station.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/station.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,22 +6,13 @@
 #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"
-#include "map.h"
-#include "tile.h"
 #include "station.h"
-#include "gfx.h"
-#include "window.h"
-#include "viewport.h"
-#include "command.h"
 #include "town.h"
-#include "vehicle.h"
 #include "news.h"
 #include "saveload.h"
-#include "economy.h"
 #include "player.h"
 #include "airport.h"
 #include "sprite.h"
@@ -32,10 +23,14 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_station.h"
 #include "yapf/yapf.h"
-#include "date.h"
-#include "helpers.hpp"
 #include "cargotype.h"
 #include "roadveh.h"
+#include "station_gui.h"
+#include "zoom_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "variables.h"
 
 Station::Station(TileIndex tile)
 {
@@ -133,7 +128,7 @@
 void Station::MarkDirty() const
 {
 	if (sign.width_1 != 0) {
-		InvalidateWindowWidget(WC_STATION_VIEW, index, 1);
+		InvalidateWindowWidget(WC_STATION_VIEW, index, SVW_CAPTION);
 
 		/* We use ZOOM_LVL_MAX here, as every viewport can have an other zoom,
 		 *  and there is no way for us to know which is the biggest. So make the
--- a/src/station.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/station.h	Wed Jan 09 18:11:12 2008 +0000
@@ -9,10 +9,12 @@
 #include "player.h"
 #include "oldpool.h"
 #include "sprite.h"
-#include "tile.h"
-#include "road.h"
+#include "road_type.h"
 #include "newgrf_station.h"
 #include "cargopacket.h"
+#include "cargo_type.h"
+#include "town_type.h"
+#include "core/geometry_type.hpp"
 #include <list>
 #include <set>
 
@@ -250,10 +252,6 @@
 void ShowStationViewWindow(StationID station);
 void UpdateAllStationVirtCoord();
 
-/* sorter stuff */
-void RebuildStationLists();
-void ResortStationLists();
-
 static inline StationID GetMaxStationIndex()
 {
 	/* TODO - This isn't the real content of the function, but
@@ -299,6 +297,8 @@
 RoadStop * AllocateRoadStop();
 void ClearSlot(Vehicle *v);
 
+bool HasStationInUse(StationID station, PlayerID player);
+
 void DeleteOilRig(TileIndex t);
 
 #endif /* STATION_H */
--- a/src/station_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/station_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,23 +8,17 @@
 #include "bridge_map.h"
 #include "cmd_helper.h"
 #include "debug.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
 #include "station_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "map.h"
-#include "tile.h"
 #include "station.h"
-#include "gfx.h"
-#include "window.h"
-#include "viewport.h"
-#include "command.h"
+#include "viewport_func.h"
+#include "command_func.h"
 #include "town.h"
-#include "vehicle.h"
 #include "news.h"
 #include "saveload.h"
-#include "economy.h"
 #include "player.h"
 #include "airport.h"
 #include "sprite.h"
@@ -36,14 +30,21 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_station.h"
 #include "yapf/yapf.h"
-#include "date.h"
-#include "helpers.hpp"
 #include "misc/autoptr.hpp"
-#include "road.h"
+#include "road_type.h"
+#include "road_internal.h" /* For drawing catenary/checking road removal */
 #include "cargotype.h"
-#include "strings.h"
+#include "variables.h"
 #include "autoslope.h"
 #include "transparency.h"
+#include "water.h"
+#include "station_gui.h"
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "string_func.h"
 
 DEFINE_OLD_POOL_GENERIC(Station, Station)
 DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
@@ -464,7 +465,7 @@
 
 	for (int yc = y1; yc != y2; yc++) {
 		for (int xc = x1; xc != x2; xc++) {
-			if (!(IS_INSIDE_1D(xc, x, w) && IS_INSIDE_1D(yc, y, h))) {
+			if (!(IsInsideBS(xc, x, w) && IsInsideBS(yc, y, h))) {
 				TileIndex tile = TileXY(xc, yc);
 
 				GetProducedCargoProc *gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc;
@@ -661,7 +662,7 @@
 	}
 
 	/* redraw the station view since acceptance changed */
-	InvalidateWindowWidget(WC_STATION_VIEW, st->index, 4);
+	InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ACCEPTLIST);
 }
 
 static void UpdateStationSignCoord(Station *st)
@@ -705,7 +706,7 @@
  */
 CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID *station, bool check_clear = true)
 {
-	CommandCost cost;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	int allowed_z = -1;
 
 	BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
@@ -792,6 +793,15 @@
 		curh = max(TileY(st->train_tile) + curh, TileY(tile) + h) - y;
 		tile = TileXY(x, y);
 	} else {
+		/* do not allow modifying non-uniform stations,
+		 * the uniform-stations code wouldn't handle it well */
+		BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
+			if (!st->TileBelongsToRailStation(t)) { // there may be adjoined station
+				_error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED;
+				return false;
+			}
+		END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
+
 		/* check so the orientation is the same */
 		if (GetRailStationAxis(st->train_tile) != axis) {
 			_error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED;
@@ -893,8 +903,6 @@
 	int w_org, h_org;
 	CommandCost ret;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* Does the authority allow this? */
 	if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR;
 	if (!ValParamRailtype(p2 & 0xF)) return CMD_ERROR;
@@ -926,7 +934,7 @@
 	 * https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365 */
 	ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
 	if (CmdFailed(ret)) return ret;
-	CommandCost cost(ret.GetCost() + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len);
+	CommandCost cost(EXPENSES_CONSTRUCTION, ret.GetCost() + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len);
 
 	Station *st = NULL;
 	bool check_surrounding = true;
@@ -1074,6 +1082,7 @@
 		UpdateStationAcceptance(st, false);
 		RebuildStationLists();
 		InvalidateWindow(WC_STATION_LIST, st->owner);
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 		/* success, so don't delete the new station */
 		st_auto_delete.Detach();
 	}
@@ -1165,21 +1174,29 @@
 	int size_x = ex - sx + 1;
 	int size_y = ey - sy + 1;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* Do the action for every tile into the area */
 	BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
-		/* Make sure the specified tile belongs to the current player, and that it is a railroad station. */
-		if (!IsTileType(tile2, MP_STATION) || !IsRailwayStation(tile2) || !_patches.nonuniform_stations) {
+		/* Make sure the specified tile is a railroad station */
+		if (!IsTileType(tile2, MP_STATION) || !IsRailwayStation(tile2)) {
+			continue;
+		}
+
+		/* If there is a vehicle on ground, do not allow to remove (flood) the tile */
+		if (!EnsureNoVehicleOnGround(tile2)) {
 			continue;
 		}
 
 		/* Check ownership of station */
 		Station *st = GetStationByTile(tile2);
-		if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicleOnGround(tile2))) {
+		if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) {
 			continue;
 		}
 
+		/* Do not allow removing from stations if non-uniform stations are not enabled
+		 * The check must be here to give correct error message
+ 		 */
+		if (!_patches.nonuniform_stations) return_cmd_error(STR_306D_NONUNIFORM_STATIONS_DISALLOWED);
+
 		/* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
 		quantity++;
 
@@ -1203,6 +1220,7 @@
 			/* if we deleted the whole station, delete the train facility. */
 			if (st->train_tile == 0) {
 				st->facilities &= ~FACIL_TRAIN;
+				InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 				UpdateStationVirtCoordDirty(st);
 				DeleteStationIfEmpty(st);
 			}
@@ -1212,7 +1230,7 @@
 	/* If we've not removed any tiles, give an error */
 	if (quantity == 0) return CMD_ERROR;
 
-	return CommandCost(_price.remove_rail_station * quantity);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_rail_station * quantity);
 }
 
 
@@ -1233,7 +1251,7 @@
 
 	assert(w != 0 && h != 0);
 
-	CommandCost cost;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	/* clear all areas of the station */
 	do {
 		int w_bak = w;
@@ -1267,6 +1285,7 @@
 		st->num_specs = 0;
 		st->speclist  = NULL;
 
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 		UpdateStationVirtCoordDirty(st);
 		DeleteStationIfEmpty(st);
 	}
@@ -1275,29 +1294,6 @@
 }
 
 /**
- * Switches the rail type at a railway station tile.
- * @param tile        The tile on which the railtype is to be convert.
- * @param totype      The railtype we want to convert to
- * @param exec        Switches between test and execute mode
- * @return            The cost and state of the operation
- * @retval CMD_ERROR  An error occured during the operation.
- */
-CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
-{
-	/* Tile is not a railroad station? */
-	if (!IsRailwayStation(tile)) return CMD_ERROR;
-
-	if (exec) {
-		SetRailType(tile, totype);
-		MarkTileDirtyByTile(tile);
-		YapfNotifyTrackLayoutChange(tile, GetRailStationTrack(tile));
-		VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
-	}
-
-	return CommandCost(RailBuildCost(totype) / 2);
-}
-
-/**
  * @param truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK
  * @param st The Station to do the whole procedure for
  * @return a pointer to where to link a new RoadStop*
@@ -1346,8 +1342,6 @@
 	/* Road bits in the wrong direction */
 	if (build_over_road && (GetAllRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_DRIVE_THROUGH_ERROR_DIRECTION);
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
 
 	CommandCost cost;
@@ -1446,6 +1440,7 @@
 		UpdateStationAcceptance(st, false);
 		RebuildStationLists();
 		InvalidateWindow(WC_STATION_LIST, st->owner);
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
 		/* success, so don't delete the new station and the new road stop */
 		st_auto_delete.Detach();
 		rs_auto_delete.Detach();
@@ -1496,6 +1491,7 @@
 			pred->next = cur_stop->next;
 		}
 
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
 		delete cur_stop;
 		DoClearSquare(tile);
 		st->rect.AfterRemoveTile(st, tile);
@@ -1504,7 +1500,7 @@
 		DeleteStationIfEmpty(st);
 	}
 
-	return CommandCost((is_truck) ? _price.remove_truck_station : _price.remove_bus_station);
+	return CommandCost(EXPENSES_CONSTRUCTION, (is_truck) ? _price.remove_truck_station : _price.remove_bus_station);
 }
 
 /** Remove a bus or truck stop
@@ -1643,8 +1639,6 @@
 {
 	bool airport_upgrade = true;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* Check if a valid, buildable airport was chosen for construction */
 	if (p1 > lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
 
@@ -1671,9 +1665,8 @@
 	int w = afc->size_x;
 	int h = afc->size_y;
 
-	CommandCost ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
-	if (CmdFailed(ret)) return ret;
-	CommandCost cost(ret.GetCost());
+	CommandCost cost = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
+	if (CmdFailed(cost)) return cost;
 
 	Station *st = NULL;
 
@@ -1759,6 +1752,7 @@
 		UpdateStationAcceptance(st, false);
 		RebuildStationLists();
 		InvalidateWindow(WC_STATION_LIST, st->owner);
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
 		/* success, so don't delete the new station */
 		st_auto_delete.Detach();
 	}
@@ -1777,7 +1771,7 @@
 	int w = afc->size_x;
 	int h = afc->size_y;
 
-	CommandCost cost(w * h * _price.remove_airport);
+	CommandCost cost(EXPENSES_CONSTRUCTION, w * h * _price.remove_airport);
 
 	Vehicle *v;
 	FOR_ALL_VEHICLES(v) {
@@ -1807,6 +1801,7 @@
 		st->airport_tile = 0;
 		st->facilities &= ~FACIL_AIRPORT;
 
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
 		UpdateStationVirtCoordDirty(st);
 		DeleteStationIfEmpty(st);
 	}
@@ -1822,8 +1817,6 @@
  */
 CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	if (!IsWaterTile(tile) || tile == 0) return_cmd_error(STR_304B_SITE_UNSUITABLE);
 	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
 
@@ -1855,22 +1848,28 @@
 		UpdateStationAcceptance(st, false);
 		RebuildStationLists();
 		InvalidateWindow(WC_STATION_LIST, st->owner);
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
 		/* success, so don't delete the new station */
 		st_auto_delete.Detach();
 	}
 
-	return CommandCost(_price.build_dock);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
 }
 
-/* Checks if any ship is servicing the buoy specified. Returns yes or no */
-static bool CheckShipsOnBuoy(Station *st)
+/**
+ * Tests whether the player's vehicles have this station in orders
+ * When player == INVALID_PLAYER, then check all vehicles
+ * @param station station ID
+ * @param player player ID, INVALID_PLAYER to disable the check
+ */
+bool HasStationInUse(StationID station, PlayerID player)
 {
 	const Vehicle *v;
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_SHIP) {
+		if (player == INVALID_PLAYER || v->owner == player) {
 			const Order *order;
 			FOR_VEHICLE_ORDERS(v, order) {
-				if (order->type == OT_GOTO_STATION && order->dest == st->index) {
+				if (order->type == OT_GOTO_STATION && order->dest == station) {
 					return true;
 				}
 			}
@@ -1886,7 +1885,7 @@
 
 	TileIndex tile = st->dock_tile;
 
-	if (CheckShipsOnBuoy(st))   return_cmd_error(STR_BUOY_IS_IN_USE);
+	if (HasStationInUse(st->index, INVALID_PLAYER)) return_cmd_error(STR_BUOY_IS_IN_USE);
 	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
 	if (flags & DC_EXEC) {
@@ -1896,22 +1895,19 @@
 		st->facilities &= ~FACIL_DOCK;
 		st->had_vehicle_of_type &= ~HVOT_BUOY;
 
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
+
 		/* We have to set the water tile's state to the same state as before the
 		 * buoy was placed. Otherwise one could plant a buoy on a canal edge,
 		 * remove it and flood the land (if the canal edge is at level 0) */
-		Owner o = GetTileOwner(tile);
-		if (o == OWNER_WATER) {
-			MakeWater(tile);
-		} else {
-			MakeCanal(tile, o);
-		}
+		MakeWaterOrCanalDependingOnOwner(tile, GetTileOwner(tile));
 		MarkTileDirtyByTile(tile);
 
 		UpdateStationVirtCoordDirty(st);
 		DeleteStationIfEmpty(st);
 	}
 
-	return CommandCost(_price.remove_truck_station);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_truck_station);
 }
 
 static const TileIndexDiffC _dock_tileoffs_chkaround[] = {
@@ -1933,8 +1929,6 @@
 {
 	CommandCost cost;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	DiagDirection direction;
 	switch (GetTileSlope(tile, NULL)) {
 		case SLOPE_SW: direction = DIAGDIR_NE; break;
@@ -2022,10 +2016,11 @@
 		UpdateStationAcceptance(st, false);
 		RebuildStationLists();
 		InvalidateWindow(WC_STATION_LIST, st->owner);
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
 		/* success, so don't delete the new station */
 		st_auto_delete.Detach();
 	}
-	return CommandCost(_price.build_dock);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
 }
 
 static CommandCost RemoveDock(Station *st, uint32 flags)
@@ -2040,7 +2035,7 @@
 
 	if (flags & DC_EXEC) {
 		DoClearSquare(tile1);
-		MakeWater(tile2);
+		MakeWaterOrCanalDependingOnSurroundings(tile2, st->owner);
 
 		st->rect.AfterRemoveTile(st, tile1);
 		st->rect.AfterRemoveTile(st, tile2);
@@ -2050,11 +2045,12 @@
 		st->dock_tile = 0;
 		st->facilities &= ~FACIL_DOCK;
 
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
 		UpdateStationVirtCoordDirty(st);
 		DeleteStationIfEmpty(st);
 	}
 
-	return CommandCost(_price.remove_dock);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_dock);
 }
 
 #include "table/station_land.h"
@@ -2064,22 +2060,23 @@
 	return &_station_display_datas[st][gfx];
 }
 
-/* For drawing canal edges on buoys */
-extern void DrawCanalWater(TileIndex tile);
-
 static void DrawTile_Station(TileInfo *ti)
 {
 	const DrawTileSprites *t = NULL;
-	RailType railtype;
 	RoadTypes roadtypes;
+	int32 total_offset;
+	int32 custom_ground_offset;
+
 	if (IsRailwayStation(ti->tile)) {
-		railtype = GetRailType(ti->tile);
+		const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
 		roadtypes = ROADTYPES_NONE;
+		total_offset = rti->total_offset;
+		custom_ground_offset = rti->custom_ground_offset;
 	} else {
 		roadtypes = GetRoadTypes(ti->tile);
-		railtype = RAILTYPE_BEGIN;
+		total_offset = 0;
+		custom_ground_offset = 0;
 	}
-	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
 	uint32 relocation = 0;
 	const Station *st = NULL;
 	const StationSpec *statspec = NULL;
@@ -2126,9 +2123,9 @@
 	SpriteID image = t->ground_sprite;
 	if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
 		image += GetCustomStationGroundRelocation(statspec, st, ti->tile);
-		image += rti->custom_ground_offset;
+		image += custom_ground_offset;
 	} else {
-		image += rti->total_offset;
+		image += total_offset;
 	}
 
 	/* station_land array has been increased from 82 elements to 114
@@ -2149,13 +2146,13 @@
 	foreach_draw_tile_seq(dtss, t->seq) {
 		image = dtss->image;
 		if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
-			image += rti->total_offset;
+			image += total_offset;
 		} else {
 			image += relocation;
 		}
 
 		SpriteID pal;
-		if (!IsTransparencySet(TO_BUILDINGS) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
+		if (!(!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
 			pal = palette;
 		} else {
 			pal = dtss->pal;
@@ -2167,7 +2164,7 @@
 				ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 				dtss->size_x, dtss->size_y,
 				dtss->size_z, ti->z + dtss->delta_z,
-				IsTransparencySet(TO_BUILDINGS)
+				!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)
 			);
 		} else {
 			AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, IsTransparencySet(TO_BUILDINGS));
@@ -2177,12 +2174,17 @@
 
 void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
 {
-	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
+	int32 total_offset = 0;
 	SpriteID pal = PLAYER_SPRITE_COLOR(_local_player);
 	const DrawTileSprites *t = &_station_display_datas[st][image];
 
+	if (railtype != INVALID_RAILTYPE) {
+		const RailtypeInfo *rti = GetRailTypeInfo(railtype);
+		total_offset = rti->total_offset;
+	}
+
 	SpriteID img = t->ground_sprite;
-	DrawSprite(img + rti->total_offset, HasBit(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y);
+	DrawSprite(img + total_offset, HasBit(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y);
 
 	if (roadtype == ROADTYPE_TRAM) {
 		DrawSprite(SPR_TRAMWAY_TRAM + (t->ground_sprite == SPR_ROAD_PAVED_STRAIGHT_X ? 1 : 0), PAL_NONE, x, y);
@@ -2191,7 +2193,7 @@
 	const DrawTileSeqStruct *dtss;
 	foreach_draw_tile_seq(dtss, t->seq) {
 		Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
-		DrawSprite(dtss->image + rti->total_offset, pal, x + pt.x, y + pt.y);
+		DrawSprite(dtss->image + total_offset, pal, x + pt.x, y + pt.y);
 	}
 }
 
@@ -2339,7 +2341,7 @@
 	215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
 };
 
-static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
+static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
 {
 	if (v->type == VEH_TRAIN) {
 		if (IsRailwayStation(tile) && IsFrontEngine(v) &&
@@ -2359,7 +2361,7 @@
 					if (DiagDirToAxis(dir) != AXIS_X) Swap(x, y);
 					if (y == TILE_SIZE / 2) {
 						if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x;
-						if (x == 12) return VETSB_ENTERED_STATION | (station_id << VETS_STATION_ID_OFFSET); /* enter station */
+						if (x == 12) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); /* enter station */
 						if (x < 12) {
 							uint16 spd;
 
@@ -2530,9 +2532,9 @@
 
 	StationID index = st->index;
 	if (waiting_changed) {
-		InvalidateWindow(WC_STATION_VIEW, index);
+		InvalidateWindow(WC_STATION_VIEW, index); // update whole window
 	} else {
-		InvalidateWindowWidget(WC_STATION_VIEW, index, 5);
+		InvalidateWindowWidget(WC_STATION_VIEW, index, SVW_RATINGLIST); // update only ratings list
 	}
 }
 
@@ -2966,11 +2968,11 @@
 					DiagDirection direction = AxisToDiagDir(GetRailStationAxis(tile));
 					if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break;
 					if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break;
-					return _price.terraform;
+					return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 				}
 
 				case STATION_AIRPORT:
-					return _price.terraform;
+					return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 
 				case STATION_TRUCK:
 				case STATION_BUS: {
@@ -2979,7 +2981,7 @@
 					if (IsDriveThroughStopTile(tile)) {
 						if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break;
 					}
-					return _price.terraform;
+					return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 				}
 
 				default: break;
--- a/src/station_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/station_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,41 +5,26 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "strings.h"
 #include "table/strings.h"
-#include "window.h"
 #include "gui.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
 #include "station.h"
-#include "gfx.h"
 #include "player.h"
-#include "economy.h"
+#include "economy_func.h"
 #include "town.h"
-#include "command.h"
+#include "command_func.h"
 #include "variables.h"
 #include "vehicle_gui.h"
-#include "date.h"
-#include "vehicle.h"
 #include "table/sprites.h"
-#include "helpers.hpp"
 #include "cargotype.h"
-
-enum StationListWidgets {
-	STATIONLIST_WIDGET_CLOSEBOX = 0,
-	STATIONLIST_WIDGET_LIST = 3,
-	STATIONLIST_WIDGET_TRAIN =6,
-	STATIONLIST_WIDGET_TRUCK,
-	STATIONLIST_WIDGET_BUS,
-	STATIONLIST_WIDGET_AIRPLANE,
-	STATIONLIST_WIDGET_SHIP,
-	STATIONLIST_WIDGET_CARGOSTART = 20,
-	STATIONLIST_WIDGET_NOCARGOWAITING = 12,
-	STATIONLIST_WIDGET_FACILALL = 14,
-	STATIONLIST_WIDGET_CARGOALL,
-	STATIONLIST_WIDGET_SORTBY,
-	STATIONLIST_WIDGET_SORTCRITERIA,
-	STATIONLIST_WIDGET_SORTDROPBTN,
-};
+#include "station_gui.h"
+#include "station.h"
+#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*);
 
@@ -48,23 +33,30 @@
 static StationSortListingTypeFunction StationWaitingSorter;
 static StationSortListingTypeFunction StationRatingMaxSorter;
 
-/** Draw small boxes of cargo amount and ratings data at the given
+/**
+ * Draw small boxes of cargo amount and ratings data at the given
  * coordinates. If amount exceeds 576 units, it is shown 'full', same
  * goes for the rating: at above 90% orso (224) it is also 'full'
- * Each cargo-bar is 16 pixels wide and 6 pixels high
- * Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
+ *
  * @param x coordinate to draw the box at
  * @param y coordinate to draw the box at
  * @param type Cargo type
  * @param amount Cargo amount
- * @param rating ratings data for that particular cargo */
+ * @param rating ratings data for that particular cargo
+ *
+ * @note Each cargo-bar is 16 pixels wide and 6 pixels high
+ * @note Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
+ */
 static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating)
 {
+	static const uint units_full  = 576; ///< number of units to show station as 'full'
+	static const uint rating_full = 224; ///< rating needed so it is shown as 'full'
+
 	const CargoSpec *cs = GetCargo(type);
 	if (!cs->IsValid()) return;
 
 	int colour = cs->rating_colour;
-	uint w = (minu(amount, 576) + 5) / 36;
+	uint w = (minu(amount, units_full) + 5) / 36;
 
 	/* Draw total cargo (limited) on station (fits into 16 pixels) */
 	if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour);
@@ -84,7 +76,7 @@
 	/* Draw green/red ratings bar (fits into 14 pixels) */
 	y += 8;
 	GfxFillRect(x + 1, y, x + 14, y, 0xB8);
-	rating = minu(rating,  224) / 16;
+	rating = minu(rating, rating_full) / 16;
 	if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0);
 }
 
@@ -168,23 +160,28 @@
 	return (_internal_sort_order & 1) ? maxr2 - maxr1 : maxr1 - maxr2;
 }
 
+/** Flags for station list */
 enum StationListFlags {
-	SL_ORDER   = 0x01,
-	SL_RESORT  = 0x02,
-	SL_REBUILD = 0x04,
+	SL_ORDER   = 1 << 0, ///< Order - ascending (=0), descending (=1)
+	SL_RESORT  = 1 << 1, ///< Resort the list
+	SL_REBUILD = 1 << 2, ///< Rebuild the list
 };
 
 DECLARE_ENUM_AS_BIT_SET(StationListFlags);
 
+/** Information about station list */
 struct plstations_d {
-	const Station** sort_list;
-	uint16 list_length;
-	byte sort_type;
-	StationListFlags flags;
-	uint16 resort_timer;  //was byte refresh_counter;
+	const Station** sort_list; ///< Pointer to list of stations
+	uint16 list_length;        ///< Number of stations in list
+	uint16 resort_timer;       ///< Tick counter to resort the list
+	byte sort_type;            ///< Sort type - name, waiting, ...
+	byte flags;                ///< Flags - SL_ORDER, SL_RESORT, SL_REBUILD
 };
 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(plstations_d));
 
+/**
+ * Set the 'SL_REBUILD' flag for all station lists
+ */
 void RebuildStationLists()
 {
 	Window* const *wz;
@@ -198,6 +195,9 @@
 	}
 }
 
+/**
+ * Set the 'SL_RESORT' flag for all station lists
+ */
 void ResortStationLists()
 {
 	Window* const *wz;
@@ -211,6 +211,15 @@
 	}
 }
 
+/**
+ * Rebuild station list if the SL_REBUILD flag is set
+ *
+ * @param sl pointer to plstations_d (station list and flags)
+ * @param owner player whose stations are to be in list
+ * @param facilities types of stations of interest
+ * @param cargo_filter bitmap of cargo types to include
+ * @param include_empty whether we should include stations without waiting cargo
+ */
 static void BuildStationsList(plstations_d* sl, PlayerID owner, byte facilities, uint32 cargo_filter, bool include_empty)
 {
 	uint n = 0;
@@ -220,12 +229,11 @@
 
 	/* Create array for sorting */
 	const Station** station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
-	if (station_sort == NULL) error("Could not allocate memory for the station-sorting-list");
 
 	DEBUG(misc, 3, "Building station list for player %d", owner);
 
 	FOR_ALL_STATIONS(st) {
-		if (st->owner == owner) {
+		if (st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy() && HasStationInUse(st->index, owner))) {
 			if (facilities & st->facilities) { //only stations with selected facilities
 				int num_waiting_cargo = 0;
 				for (CargoID j = 0; j < NUM_CARGO; j++) {
@@ -247,7 +255,6 @@
 
 	free((void*)sl->sort_list);
 	sl->sort_list = MallocT<const Station*>(n);
-	if (n != 0 && sl->sort_list == NULL) error("Could not allocate memory for the station-sorting-list");
 	sl->list_length = n;
 
 	for (uint i = 0; i < n; ++i) sl->sort_list[i] = station_sort[i];
@@ -257,6 +264,12 @@
 	free((void*)station_sort);
 }
 
+
+/**
+ * Sort station list if the SL_RESORT flag is set
+ *
+ * @param sl pointer to plstations_d (station list and flags)
+ */
 static void SortStationsList(plstations_d *sl)
 {
 	static StationSortListingTypeFunction* const _station_sorter[] = {
@@ -276,6 +289,12 @@
 	sl->flags &= ~SL_RESORT;
 }
 
+/**
+ * Fuction called when any WindowEvent occurs for PlayerStations window
+ *
+ * @param w pointer to the PlayerStations window
+ * @param e pointer to window event
+ */
 static void PlayerStationsWndProc(Window *w, WindowEvent *e)
 {
 	const PlayerID owner = (PlayerID)w->window_number;
@@ -286,20 +305,22 @@
 	plstations_d *sl = &WP(w, plstations_d);
 
 	switch (e->event) {
-		case WE_CREATE: /* set up resort timer */
+		case WE_CREATE:
 			if (_cargo_filter == _cargo_filter_max) _cargo_filter = _cargo_mask;
 
 			for (uint i = 0; i < 5; i++) {
-				if (HasBit(facilities, i)) LowerWindowWidget(w, i + STATIONLIST_WIDGET_TRAIN);
+				if (HasBit(facilities, i)) w->LowerWidget(i + SLW_TRAIN);
 			}
-			SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
-			SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
-			SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_NOCARGOWAITING, include_empty);
+			w->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
+			w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
+			w->SetWidgetLoweredState(SLW_NOCARGOWAITING, include_empty);
 
 			sl->sort_list = NULL;
 			sl->flags = SL_REBUILD;
 			sl->sort_type = station_sort.criteria;
 			if (station_sort.order) sl->flags |= SL_ORDER;
+
+			/* set up resort timer */
 			sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 			break;
 
@@ -337,13 +358,13 @@
 			}
 
 			x += 6;
-			cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_NOCARGOWAITING) ? 2 : 1;
+			cg_ofst = w->IsWidgetLowered(SLW_NOCARGOWAITING) ? 2 : 1;
 			DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, TC_BLACK);
 			x += 14;
-			cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_CARGOALL) ? 2 : 1;
+			cg_ofst = w->IsWidgetLowered(SLW_CARGOALL) ? 2 : 1;
 			DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
 
-			cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_FACILALL) ? 2 : 1;
+			cg_ofst = w->IsWidgetLowered(SLW_FACILALL) ? 2 : 1;
 			DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
 
 			if (w->vscroll.count == 0) { // player has no stations
@@ -359,7 +380,10 @@
 				int x;
 
 				assert(st->xy != 0);
-				assert(st->owner == owner);
+
+ 				/* Do not do the complex check HasStationInUse here, it may be even false
+				 * when the order had been removed and the station list hasn't been removed yet */
+				assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
 
 				SetDParam(0, st->index);
 				SetDParam(1, st->facilities);
@@ -379,7 +403,7 @@
 
 		case WE_CLICK:
 			switch (e->we.click.widget) {
-				case STATIONLIST_WIDGET_LIST: {
+				case SLW_LIST: {
 					uint32 id_v = (e->we.click.pt.y - 41) / 10;
 
 					if (id_v >= w->vscroll.cap) return; // click out of bounds
@@ -389,51 +413,53 @@
 					if (id_v >= sl->list_length) return; // click out of list bound
 
 					const Station *st = sl->sort_list[id_v];
-					assert(st->owner == owner);
+					/* do not check HasStationInUse - it is slow and may be invalid */
+					assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
 					ScrollMainWindowToTile(st->xy);
 					break;
 				}
 
-				case STATIONLIST_WIDGET_TRAIN:
-				case STATIONLIST_WIDGET_TRUCK:
-				case STATIONLIST_WIDGET_BUS:
-				case STATIONLIST_WIDGET_AIRPLANE:
-				case STATIONLIST_WIDGET_SHIP:
+				case SLW_TRAIN:
+				case SLW_TRUCK:
+				case SLW_BUS:
+				case SLW_AIRPLANE:
+				case SLW_SHIP:
 					if (_ctrl_pressed) {
-						ToggleBit(facilities, e->we.click.widget - STATIONLIST_WIDGET_TRAIN);
-						ToggleWidgetLoweredState(w, e->we.click.widget);
+						ToggleBit(facilities, e->we.click.widget - SLW_TRAIN);
+						w->ToggleWidgetLoweredState(e->we.click.widget);
 					} else {
-						for (uint i = 0; facilities != 0; i++, facilities >>= 1) {
-							if (HasBit(facilities, 0)) RaiseWindowWidget(w, i + STATIONLIST_WIDGET_TRAIN);
+						uint i;
+						FOR_EACH_SET_BIT(i, facilities) {
+							w->RaiseWidget(i + SLW_TRAIN);
 						}
-						SetBit(facilities, e->we.click.widget - STATIONLIST_WIDGET_TRAIN);
-						LowerWindowWidget(w, e->we.click.widget);
+						SetBit(facilities, e->we.click.widget - SLW_TRAIN);
+						w->LowerWidget(e->we.click.widget);
 					}
-					SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
+					w->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
 					sl->flags |= SL_REBUILD;
 					SetWindowDirty(w);
 					break;
 
-				case STATIONLIST_WIDGET_FACILALL:
+				case SLW_FACILALL:
 					for (uint i = 0; i < 5; i++) {
-						LowerWindowWidget(w, i + STATIONLIST_WIDGET_TRAIN);
+						w->LowerWidget(i + SLW_TRAIN);
 					}
-					LowerWindowWidget(w, STATIONLIST_WIDGET_FACILALL);
+					w->LowerWidget(SLW_FACILALL);
 
 					facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
 					sl->flags |= SL_REBUILD;
 					SetWindowDirty(w);
 					break;
 
-				case STATIONLIST_WIDGET_CARGOALL: {
+				case SLW_CARGOALL: {
 					uint i = 0;
 					for (CargoID c = 0; c < NUM_CARGO; c++) {
 						if (!GetCargo(c)->IsValid()) continue;
-						LowerWindowWidget(w, i + STATIONLIST_WIDGET_CARGOSTART);
+						w->LowerWidget(i + SLW_CARGOSTART);
 						i++;
 					}
-					LowerWindowWidget(w, STATIONLIST_WIDGET_NOCARGOWAITING);
-					LowerWindowWidget(w, STATIONLIST_WIDGET_CARGOALL);
+					w->LowerWidget(SLW_NOCARGOWAITING);
+					w->LowerWidget(SLW_CARGOALL);
 
 					_cargo_filter = _cargo_mask;
 					include_empty = true;
@@ -442,74 +468,74 @@
 					break;
 				}
 
-				case STATIONLIST_WIDGET_SORTBY: /*flip sorting method asc/desc*/
+				case SLW_SORTBY: // flip sorting method asc/desc
 					sl->flags ^= SL_ORDER; //DESC-flag
 					station_sort.order = HasBit(sl->flags, 0);
 					sl->flags |= SL_RESORT;
 					w->flags4 |= 5 << WF_TIMEOUT_SHL;
-					LowerWindowWidget(w, STATIONLIST_WIDGET_SORTBY);
+					w->LowerWidget(SLW_SORTBY);
 					SetWindowDirty(w);
 					break;
 
-				case STATIONLIST_WIDGET_SORTCRITERIA:
-				case STATIONLIST_WIDGET_SORTDROPBTN: /* select sorting criteria dropdown menu */
-					ShowDropDownMenu(w, _station_sort_listing, sl->sort_type, STATIONLIST_WIDGET_SORTDROPBTN, 0, 0);
+				case SLW_SORTCRITERIA:
+				case SLW_SORTDROPBTN: // select sorting criteria dropdown menu
+					ShowDropDownMenu(w, _station_sort_listing, sl->sort_type, SLW_SORTDROPBTN, 0, 0);
 					break;
 
-				case STATIONLIST_WIDGET_NOCARGOWAITING:
+				case SLW_NOCARGOWAITING:
 					if (_ctrl_pressed) {
 						include_empty = !include_empty;
-						ToggleWidgetLoweredState(w, STATIONLIST_WIDGET_NOCARGOWAITING);
+						w->ToggleWidgetLoweredState(SLW_NOCARGOWAITING);
 					} else {
-						for (uint i = STATIONLIST_WIDGET_CARGOSTART; i < w->widget_count; i++) {
-							RaiseWindowWidget(w, i);
+						for (uint i = SLW_CARGOSTART; i < w->widget_count; i++) {
+							w->RaiseWidget(i);
 						}
 
 						_cargo_filter = 0;
 						include_empty = true;
 
-						LowerWindowWidget(w, STATIONLIST_WIDGET_NOCARGOWAITING);
+						w->LowerWidget(SLW_NOCARGOWAITING);
 					}
 					sl->flags |= SL_REBUILD;
-					SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
+					w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
 					SetWindowDirty(w);
 					break;
 
 				default:
-					if (e->we.click.widget >= STATIONLIST_WIDGET_CARGOSTART) { //change cargo_filter
+					if (e->we.click.widget >= SLW_CARGOSTART) { // change cargo_filter
 						/* Determine the selected cargo type */
 						CargoID c;
 						int i = 0;
 						for (c = 0; c < NUM_CARGO; c++) {
 							if (!GetCargo(c)->IsValid()) continue;
-							if (e->we.click.widget - STATIONLIST_WIDGET_CARGOSTART == i) break;
+							if (e->we.click.widget - SLW_CARGOSTART == i) break;
 							i++;
 						}
 
 						if (_ctrl_pressed) {
 							ToggleBit(_cargo_filter, c);
-							ToggleWidgetLoweredState(w, e->we.click.widget);
+							w->ToggleWidgetLoweredState(e->we.click.widget);
 						} else {
-							for (uint i = STATIONLIST_WIDGET_CARGOSTART; i < w->widget_count; i++) {
-								RaiseWindowWidget(w, i);
+							for (uint i = SLW_CARGOSTART; i < w->widget_count; i++) {
+								w->RaiseWidget(i);
 							}
-							RaiseWindowWidget(w, STATIONLIST_WIDGET_NOCARGOWAITING);
+							w->RaiseWidget(SLW_NOCARGOWAITING);
 
 							_cargo_filter = 0;
 							include_empty = false;
 
 							SetBit(_cargo_filter, c);
-							LowerWindowWidget(w, e->we.click.widget);
+							w->LowerWidget(e->we.click.widget);
 						}
 						sl->flags |= SL_REBUILD;
-						SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
+						w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
 						SetWindowDirty(w);
 					}
 					break;
 			}
 			break;
 
-		case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
+		case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list
 			if (sl->sort_type != e->we.dropdown.index) {
 				/* value has changed -> resort */
 				sl->sort_type = e->we.dropdown.index;
@@ -520,6 +546,7 @@
 			break;
 
 		case WE_TICK:
+			if (_pause_game != 0) break;
 			if (--sl->resort_timer == 0) {
 				DEBUG(misc, 3, "Periodic rebuild station list player %d", owner);
 				sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
@@ -529,7 +556,7 @@
 			break;
 
 		case WE_TIMEOUT:
-			RaiseWindowWidget(w, STATIONLIST_WIDGET_SORTBY);
+			w->RaiseWidget(SLW_SORTBY);
 			SetWindowDirty(w);
 			break;
 
@@ -540,32 +567,29 @@
 }
 
 static const Widget _player_stations_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
+{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},            // SLW_CLOSEBOX
 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   345,     0,    13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,     RESIZE_LR,    14,   346,   357,     0,    13, 0x0,               STR_STICKY_BUTTON},
-{      WWT_PANEL,     RESIZE_RB,    14,     0,   345,    37,   161, 0x0,               STR_3057_STATION_NAMES_CLICK_ON},
+{      WWT_PANEL,     RESIZE_RB,    14,     0,   345,    37,   161, 0x0,               STR_3057_STATION_NAMES_CLICK_ON},  // SLW_LIST
 {  WWT_SCROLLBAR,    RESIZE_LRB,    14,   346,   357,    37,   149, 0x0,               STR_0190_SCROLL_BAR_SCROLLS_LIST},
 {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   346,   357,   150,   161, 0x0,               STR_RESIZE_BUTTON},
-//Index 6
-{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    13,    14,    24, STR_TRAIN,         STR_USE_CTRL_TO_SELECT_MORE},
-{    WWT_TEXTBTN,   RESIZE_NONE,    14,    14,    27,    14,    24, STR_LORRY,         STR_USE_CTRL_TO_SELECT_MORE},
-{    WWT_TEXTBTN,   RESIZE_NONE,    14,    28,    41,    14,    24, STR_BUS,           STR_USE_CTRL_TO_SELECT_MORE},
-{    WWT_TEXTBTN,   RESIZE_NONE,    14,    42,    55,    14,    24, STR_PLANE,         STR_USE_CTRL_TO_SELECT_MORE},
-{    WWT_TEXTBTN,   RESIZE_NONE,    14,    56,    69,    14,    24, STR_SHIP,          STR_USE_CTRL_TO_SELECT_MORE},
-//Index 11
-{      WWT_PANEL,   RESIZE_NONE,    14,    83,    88,    14,    24, 0x0,               STR_USE_CTRL_TO_SELECT_MORE},
-{      WWT_PANEL,   RESIZE_NONE,    14,    89,   102,    14,    24, 0x0,               STR_NO_WAITING_CARGO},
-{      WWT_PANEL,  RESIZE_RIGHT,    14,   117,   357,    14,    24, 0x0,               STR_NULL},
 
-//14
-{      WWT_PANEL,   RESIZE_NONE,    14,    70,    83,    14,    24, 0x0,               STR_SELECT_ALL_FACILITIES},
-{      WWT_PANEL,   RESIZE_NONE,    14,   103,   116,    14,    24, 0x0,               STR_SELECT_ALL_TYPES},
+{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    13,    14,    24, STR_TRAIN,         STR_USE_CTRL_TO_SELECT_MORE},      // SLW_TRAIN
+{    WWT_TEXTBTN,   RESIZE_NONE,    14,    14,    27,    14,    24, STR_LORRY,         STR_USE_CTRL_TO_SELECT_MORE},      // SLW_TRUCK
+{    WWT_TEXTBTN,   RESIZE_NONE,    14,    28,    41,    14,    24, STR_BUS,           STR_USE_CTRL_TO_SELECT_MORE},      // SLW_BUS
+{    WWT_TEXTBTN,   RESIZE_NONE,    14,    42,    55,    14,    24, STR_PLANE,         STR_USE_CTRL_TO_SELECT_MORE},      // SLW_AIRPLANE
+{    WWT_TEXTBTN,   RESIZE_NONE,    14,    56,    69,    14,    24, STR_SHIP,          STR_USE_CTRL_TO_SELECT_MORE},      // SLW_SHIP
+{      WWT_PANEL,   RESIZE_NONE,    14,    70,    83,    14,    24, 0x0,               STR_SELECT_ALL_FACILITIES},        // SLW_FACILALL
 
-//16
-{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    80,    25,    36, STR_SORT_BY,       STR_SORT_ORDER_TIP},
-{      WWT_PANEL,   RESIZE_NONE,    14,    81,   232,    25,    36, 0x0,               STR_SORT_CRITERIA_TIP},
-{    WWT_TEXTBTN,   RESIZE_NONE,    14,   233,   243,    25,    36, STR_0225,          STR_SORT_CRITERIA_TIP},
-{      WWT_PANEL,  RESIZE_RIGHT,    14,   244,   357,    25,    36, 0x0,               STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,    14,    83,    88,    14,    24, 0x0,               STR_NULL},                         // SLW_PAN_BETWEEN
+{      WWT_PANEL,   RESIZE_NONE,    14,    89,   102,    14,    24, 0x0,               STR_NO_WAITING_CARGO},             // SLW_NOCARGOWAITING
+{      WWT_PANEL,   RESIZE_NONE,    14,   103,   116,    14,    24, 0x0,               STR_SELECT_ALL_TYPES},             // SLW_CARGOALL
+{      WWT_PANEL,  RESIZE_RIGHT,    14,   117,   357,    14,    24, 0x0,               STR_NULL},                         // SLW_PAN_RIGHT
+
+{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    80,    25,    36, STR_SORT_BY,       STR_SORT_ORDER_TIP},               // SLW_SORTBY
+{      WWT_PANEL,   RESIZE_NONE,    14,    81,   232,    25,    36, 0x0,               STR_SORT_CRITERIA_TIP},            // SLW_SORTCRITERIA
+{    WWT_TEXTBTN,   RESIZE_NONE,    14,   233,   243,    25,    36, STR_0225,          STR_SORT_CRITERIA_TIP},            // SLW_SORTDROPBTN
+{      WWT_PANEL,  RESIZE_RIGHT,    14,   244,   357,    25,    36, 0x0,               STR_NULL},                         // SLW_PAN_SORT_RIGHT
 {   WIDGETS_END},
 };
 
@@ -577,7 +601,11 @@
 	PlayerStationsWndProc
 };
 
-
+/**
+ * Opens window with list of player's stations
+ *
+ * @param player player whose stations' list show
+ */
 void ShowPlayerStations(PlayerID player)
 {
 	if (!IsValidPlayer(player)) return;
@@ -604,7 +632,7 @@
 	for (CargoID c = 0; c < NUM_CARGO; c++) {
 		if (!GetCargo(c)->IsValid()) continue;
 
-		Widget *wi = &w->widget[STATIONLIST_WIDGET_CARGOSTART + i];
+		Widget *wi = &w->widget[SLW_CARGOSTART + i];
 		wi->type     = WWT_PANEL;
 		wi->display_flags = RESIZE_NONE;
 		wi->color    = 14;
@@ -615,15 +643,15 @@
 		wi->data     = 0;
 		wi->tooltips = STR_USE_CTRL_TO_SELECT_MORE;
 
-		if (HasBit(_cargo_filter, c)) LowerWindowWidget(w, STATIONLIST_WIDGET_CARGOSTART + i);
+		if (HasBit(_cargo_filter, c)) w->LowerWidget(SLW_CARGOSTART + i);
 		i++;
 	}
 
-	w->widget[STATIONLIST_WIDGET_NOCARGOWAITING].left += num_active * 14;
-	w->widget[STATIONLIST_WIDGET_NOCARGOWAITING].right += num_active * 14;
-	w->widget[STATIONLIST_WIDGET_CARGOALL].left += num_active * 14;
-	w->widget[STATIONLIST_WIDGET_CARGOALL].right += num_active * 14;
-	w->widget[13].left += num_active * 14;
+	w->widget[SLW_NOCARGOWAITING].left += num_active * 14;
+	w->widget[SLW_NOCARGOWAITING].right += num_active * 14;
+	w->widget[SLW_CARGOALL].left += num_active * 14;
+	w->widget[SLW_CARGOALL].right += num_active * 14;
+	w->widget[SLW_PAN_RIGHT].left += num_active * 14;
 
 	if (num_active > 15) {
 		/* Resize and fix the minimum width, if necessary */
@@ -633,45 +661,52 @@
 }
 
 static const Widget _station_view_expanded_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
+{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},                // SVW_CLOSEBOX
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   236,     0,    13, STR_300A_0,        STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   237,   248,     0,    13, 0x0,               STR_STICKY_BUTTON},
-{      WWT_PANEL,   RESIZE_NONE,    14,     0,   236,    14,    65, 0x0,               STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,    14,     0,   236,    14,    65, 0x0,               STR_NULL},                             // SVW_WAITING
 {  WWT_SCROLLBAR,   RESIZE_NONE,    14,   237,   248,    14,    65, 0x0,               STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,               STR_NULL},
-{      WWT_PANEL,   RESIZE_NONE,    14,     0,   248,    66,   197, 0x0,               STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    63,   198,   209, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    64,   128,   198,   209, STR_3033_ACCEPTS,  STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   129,   192,   198,   209, STR_0130_RENAME,   STR_3055_CHANGE_NAME_OF_STATION},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   193,   206,   198,   209, STR_TRAIN,         STR_SCHEDULED_TRAINS_TIP },
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   207,   220,   198,   209, STR_LORRY,         STR_SCHEDULED_ROAD_VEHICLES_TIP },
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   221,   234,   198,   209, STR_PLANE,         STR_SCHEDULED_AIRCRAFT_TIP },
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   235,   248,   198,   209, STR_SHIP,          STR_SCHEDULED_SHIPS_TIP },
+{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,               STR_NULL},                             // SVW_ACCEPTLIST
+{      WWT_PANEL,   RESIZE_NONE,    14,     0,   248,    66,   197, 0x0,               STR_NULL},                             // SVW_RATINGLIST
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    63,   198,   209, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    64,   128,   198,   209, STR_3033_ACCEPTS,  STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO}, // SVW_ACCEPTS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   129,   192,   198,   209, STR_0130_RENAME,   STR_3055_CHANGE_NAME_OF_STATION},      // SVW_RENAME
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   193,   206,   198,   209, STR_TRAIN,         STR_SCHEDULED_TRAINS_TIP },            // SVW_TRAINS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   207,   220,   198,   209, STR_LORRY,         STR_SCHEDULED_ROAD_VEHICLES_TIP },     // SVW_ROADVEHS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   221,   234,   198,   209, STR_PLANE,         STR_SCHEDULED_AIRCRAFT_TIP },          // SVW_PLANES
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   235,   248,   198,   209, STR_SHIP,          STR_SCHEDULED_SHIPS_TIP },             // SVW_SHIPS
 {   WIDGETS_END},
 };
 
 static const Widget _station_view_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
+{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},                // SVW_CLOSEBOX
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   236,     0,    13, STR_300A_0,        STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   237,   248,     0,    13, 0x0,               STR_STICKY_BUTTON},
-{      WWT_PANEL,   RESIZE_NONE,    14,     0,   236,    14,    65, 0x0,               STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,    14,     0,   236,    14,    65, 0x0,               STR_NULL},                             // SVW_WAITING
 {  WWT_SCROLLBAR,   RESIZE_NONE,    14,   237,   248,    14,    65, 0x0,               STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{      WWT_PANEL,   RESIZE_NONE,    14,     0,   248,    66,    97, 0x0,               STR_NULL},
-{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,               STR_NULL},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    63,    98,   109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    64,   128,    98,   109, STR_3032_RATINGS,  STR_3054_SHOW_STATION_RATINGS},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   129,   192,    98,   109, STR_0130_RENAME,   STR_3055_CHANGE_NAME_OF_STATION},
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   193,   206,    98,   109, STR_TRAIN,         STR_SCHEDULED_TRAINS_TIP },
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   207,   220,    98,   109, STR_LORRY,         STR_SCHEDULED_ROAD_VEHICLES_TIP },
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   221,   234,    98,   109, STR_PLANE,         STR_SCHEDULED_AIRCRAFT_TIP },
-{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   235,   248,    98,   109, STR_SHIP,          STR_SCHEDULED_SHIPS_TIP },
+{      WWT_PANEL,   RESIZE_NONE,    14,     0,   248,    66,    97, 0x0,               STR_NULL},                             // SVW_ACCEPTLIST
+{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,               STR_NULL},                             // SVW_RATINGLIST
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    63,    98,   109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    64,   128,    98,   109, STR_3032_RATINGS,  STR_3054_SHOW_STATION_RATINGS},        // SVW_RATINGS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   129,   192,    98,   109, STR_0130_RENAME,   STR_3055_CHANGE_NAME_OF_STATION},      // SVW_RENAME
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   193,   206,    98,   109, STR_TRAIN,         STR_SCHEDULED_TRAINS_TIP },            // SVW_TRAINS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   207,   220,    98,   109, STR_LORRY,         STR_SCHEDULED_ROAD_VEHICLES_TIP },     // SVW_ROADVEHS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   221,   234,    98,   109, STR_PLANE,         STR_SCHEDULED_AIRCRAFT_TIP },          // SVW_PLANES
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   235,   248,    98,   109, STR_SHIP,          STR_SCHEDULED_SHIPS_TIP },             // SVW_SHIPS
 {   WIDGETS_END},
 };
 
-
+/**
+ * Draws icons of wainting cargo in the StationView window
+ *
+ * @param i type of cargo
+ * @param waiting number of wainting units
+ * @param x x on-screen coordinate where to start with drawing icons
+ * @param y y coordinate
+ */
 static void DrawCargoIcons(CargoID i, uint waiting, int x, int y)
 {
-	uint num = min((waiting + 5) / 10, 23);
+	uint num = min((waiting + 5) / 10, 23); // maximum is 23 icons so it won't overflow
 	if (num == 0) return;
 
 	const CargoSpec *cs = GetCargo(i);
@@ -692,15 +727,21 @@
 	} while (--num);
 }
 
+/**
+ * Redraws whole StationView window
+ *
+ * @param w pointer to window
+ */
 static void DrawStationViewWindow(Window *w)
 {
 	StationID station_id = w->window_number;
 	const Station* st = GetStation(station_id);
-	uint num;
-	int x,y;
-	int pos;
+	uint num;     ///< number of cargo types waiting at station
+	int x, y;     ///< coordinates used for printing waiting/accepted/rating of cargo
+	int pos;      ///< = w->vscroll.pos
 	StringID str;
 
+	/* count types of cargos waiting in station */
 	num = 1;
 	for (CargoID i = 0; i < NUM_CARGO; i++) {
 		if (!st->goods[i].cargo.Empty()) {
@@ -708,13 +749,14 @@
 			if (st->goods[i].cargo.Source() != station_id) num++;
 		}
 	}
-	SetVScrollCount(w, num);
+	SetVScrollCount(w, num); // update scrollbar
 
-	SetWindowWidgetDisabledState(w,  9, st->owner != _local_player);
-	SetWindowWidgetDisabledState(w, 10, !(st->facilities & FACIL_TRAIN));
-	SetWindowWidgetDisabledState(w, 11, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
-	SetWindowWidgetDisabledState(w, 12, !(st->facilities & FACIL_AIRPORT));
-	SetWindowWidgetDisabledState(w, 13, !(st->facilities & FACIL_DOCK));
+	/* disable some buttons */
+	w->SetWidgetDisabledState(SVW_RENAME,   st->owner != _local_player);
+	w->SetWidgetDisabledState(SVW_TRAINS,   !(st->facilities & FACIL_TRAIN));
+	w->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
+	w->SetWidgetDisabledState(SVW_PLANES,   !(st->facilities & FACIL_AIRPORT));
+	w->SetWidgetDisabledState(SVW_SHIPS,    !(st->facilities & FACIL_DOCK));
 
 	SetDParam(0, st->index);
 	SetDParam(1, st->facilities);
@@ -764,14 +806,14 @@
 		}
 	}
 
-	if (IsWindowOfPrototype(w, _station_view_widgets)) {
+	if (IsWindowOfPrototype(w, _station_view_widgets)) { // small window with list of accepted cargo
 		char *b = _userstring;
 		bool first = true;
 
 		b = InlineString(b, STR_000C_ACCEPTS);
 
 		for (CargoID i = 0; i < NUM_CARGO; i++) {
-			if (b >= endof(_userstring) - 5 - 1) break;
+			if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
 			if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE)) {
 				if (first) {
 					first = false;
@@ -788,8 +830,12 @@
 		if (first) b = InlineString(b, STR_00D0_NOTHING);
 
 		*b = '\0';
+
+		/* Make sure we detect any buffer overflow */
+		assert(b < endof(_userstring));
+
 		DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245);
-	} else {
+	} else { // extended window with list of cargo ratings
 		DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING);
 
 		y = 77;
@@ -810,6 +856,12 @@
 }
 
 
+/**
+ * Fuction called when any WindowEvent occurs for any StationView window
+ *
+ * @param w pointer to the StationView window
+ * @param e pointer to window event
+ */
 static void StationViewWndProc(Window *w, WindowEvent *e)
 {
 	switch (e->event) {
@@ -819,11 +871,11 @@
 
 		case WE_CLICK:
 			switch (e->we.click.widget) {
-				case 7:
+				case SVW_LOCATION:
 					ScrollMainWindowToTile(GetStation(w->window_number)->xy);
 					break;
 
-				case 8:
+				case SVW_RATINGS:
 					SetWindowDirty(w);
 
 					/* toggle height/widget set */
@@ -838,24 +890,24 @@
 					SetWindowDirty(w);
 					break;
 
-				case 9:
+				case SVW_RENAME:
 					SetDParam(0, w->window_number);
 					ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, w, CS_ALPHANUMERAL);
 					break;
 
-				case 10: { /* Show a list of scheduled trains to this station */
+				case SVW_TRAINS: { // Show a list of scheduled trains to this station
 					const Station *st = GetStation(w->window_number);
 					ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)w->window_number);
 					break;
 				}
 
-				case 11: { /* Show a list of scheduled road-vehicles to this station */
+				case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station
 					const Station *st = GetStation(w->window_number);
 					ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)w->window_number);
 					break;
 				}
 
-				case 12: { /* Show a list of scheduled aircraft to this station */
+				case SVW_PLANES: { // Show a list of scheduled aircraft to this station
 					const Station *st = GetStation(w->window_number);
 					/* Since oilrigs have no owners, show the scheduled aircraft of current player */
 					PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
@@ -863,7 +915,7 @@
 					break;
 				}
 
-				case 13: { /* Show a list of scheduled ships to this station */
+				case SVW_SHIPS: { // Show a list of scheduled ships to this station
 					const Station *st = GetStation(w->window_number);
 					/* Since oilrigs/bouys have no owners, show the scheduled ships of current player */
 					PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
@@ -903,6 +955,11 @@
 	StationViewWndProc
 };
 
+/**
+ * Opens StationViewWindow for given station
+ *
+ * @param station station which window should be opened
+ */
 void ShowStationViewWindow(StationID station)
 {
 	Window *w = AllocateWindowDescFront(&_station_view_desc, station);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/station_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,64 @@
+/* $Id$ */
+
+/** @file station_gui.h Contains enums and function declarations connected with stations GUI */
+
+#ifndef STATION_GUI_H
+#define STATION_GUI_H
+
+/** Enum for PlayerStations, referring to _player_stations_widgets */
+enum StationListWidgets {
+	SLW_CLOSEBOX       =  0, ///< Close 'X' button
+
+	SLW_LIST           =  3, ///< The main panel, list of stations
+
+	SLW_TRAIN          =  6, ///< 'TRAIN' button - list only facilities where is a railroad station
+	SLW_TRUCK,
+	SLW_BUS,
+	SLW_AIRPLANE,
+	SLW_SHIP,
+	SLW_FACILALL,            ///< 'ALL' button - list all facilities
+
+	SLW_PAN_BETWEEN    = 12, ///< Small panel between list of types of ficilities and list of cargo types
+	SLW_NOCARGOWAITING = 13, ///< 'NO' button - list stations where no cargo is waiting
+	SLW_CARGOALL       = 14, ///< 'ALL' button - list all stations
+	SLW_PAN_RIGHT      = 15, ///< Panel right of list of cargo types
+
+	SLW_SORTBY         = 16, ///< 'Sort by' button - reverse sort direction
+	SLW_SORTCRITERIA   = 17, ///< Button - list of criteria
+	SLW_SORTDROPBTN    = 18, ///< Dropdown button
+	SLW_PAN_SORT_RIGHT = 19, ///< Panel right of sorting options
+
+	SLW_CARGOSTART     = 20, ///< Widget numbers used for list of cargo types (not present in _player_stations_widgets)
+};
+
+/** Enum for StationView, referring to _station_view_widgets and _station_view_expanded_widgets */
+enum StationViewWidgets {
+	SVW_CLOSEBOX   =  0, ///< Close 'X' button
+	SVW_CAPTION    =  1, ///< Caption of the window
+	SVW_WAITING    =  3, ///< List of waiting cargo
+	SVW_ACCEPTLIST =  5, ///< List of accepted cargos
+	SVW_RATINGLIST =  6, ///< Ratings of cargos
+	SVW_LOCATION   =  7, ///< 'Location' button
+	SVW_RATINGS    =  8, ///< 'Ratings' button
+	SVW_ACCEPTS    =  8, ///< 'Accepts' button
+	SVW_RENAME     =  9, ///< 'Rename' button
+	SVW_TRAINS     = 10, ///< List of scheduled trains button
+	SVW_ROADVEHS,        ///< List of scheduled road vehs button
+	SVW_PLANES,          ///< List of scheduled planes button
+	SVW_SHIPS,           ///< List of scheduled ships button
+};
+
+/* sorter stuff */
+void RebuildStationLists();
+void ResortStationLists();
+
+enum StationCoverageType {
+	SCT_PASSENGERS_ONLY,
+	SCT_NON_PASSENGERS_ONLY,
+	SCT_ALL
+};
+
+void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad);
+void CheckRedrawStationCoverage(const Window *w);
+
+#endif /* STATION_GUI_H */
--- a/src/station_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/station_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,7 @@
 #include "rail_map.h"
 #include "road_map.h"
 #include "station.h"
+#include "rail.h"
 
 typedef byte StationGfx;
 
--- a/src/stdafx.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/stdafx.h	Wed Jan 09 18:11:12 2008 +0000
@@ -4,6 +4,7 @@
 
 #ifndef STDAFX_H
 #define STDAFX_H
+#define DEBUG_DUMP_COMMANDS
 
 /* It seems that we need to include stdint.h before anything else
  * We need INT64_MAX, which for most systems comes from stdint.h. However, MSVC
@@ -13,17 +14,17 @@
  * __STDC_LIMIT_MACROS so it will be without INT64_*. We need to define those
  * too if this is the case. */
 #if !defined(_MSC_VER) && !defined( __MORPHOS__) && !defined(_STDINT_H_)
-# if defined (SUNOS)
-/* SunOS/Solaris does not have stdint.h, but inttypes.h defines everything
- * stdint.h defines and we need. */
-#  include <inttypes.h>
-# else
-#  define __STDC_LIMIT_MACROS
-#  include <stdint.h>
-# endif
+	#if defined(SUNOS)
+		/* SunOS/Solaris does not have stdint.h, but inttypes.h defines everything
+		 * stdint.h defines and we need. */
+		#include <inttypes.h>
+	# else
+		#define __STDC_LIMIT_MACROS
+		#include <stdint.h>
+	#endif
 #else
-# define INT64_MAX 9223372036854775807LL
-# define INT64_MIN (-INT64_MAX - 1)
+	#define INT64_MAX 9223372036854775807LL
+	#define INT64_MIN (-INT64_MAX - 1)
 #endif
 
 #include <cstdio>
@@ -35,289 +36,240 @@
 /* MacOS X will use an NSAlert to display failed assertaions since they're lost unless running from a terminal
  * strgen always runs from terminal and don't need a window for asserts */
 #if !defined(__APPLE__) || defined(STRGEN)
-# include <cassert>
+	#include <cassert>
 #else
-# include "os/macosx/macos.h"
+	#include "os/macosx/macos.h"
 #endif
 
 #if defined(UNIX) || defined(__MINGW32__)
-# include <sys/types.h>
+	#include <sys/types.h>
 #endif
 
 #if defined(__OS2__)
-# include <types.h>
-# define strcasecmp stricmp
+	#include <types.h>
+	#define strcasecmp stricmp
 #endif
 
 #if defined(PSP)
-# include <psptypes.h>
-# include <pspdebug.h>
-# include <pspthreadman.h>
-#endif /* PSP */
-
-#ifdef __BEOS__
-# include <SupportDefs.h>
-#endif
-
-#ifdef SUNOS
-# include <alloca.h>
+	#include <psptypes.h>
+	#include <pspdebug.h>
+	#include <pspthreadman.h>
 #endif
 
-#ifdef __MORPHOS__
-/* MorphOS defines certain Amiga defines per default, we undefine them
- * here to make the rest of source less messy and more clear what is
- * required for morphos and what for AmigaOS */
-# ifdef amigaos
-#  undef amigaos
-# endif
-# ifdef __amigaos__
-#  undef __amigaos__
-# endif
-# ifdef __AMIGA__
-#  undef __AMIGA__
-# endif
-# ifdef AMIGA
-#  undef AMIGA
-# endif
-# ifdef amiga
-#  undef amiga
-# endif
-/* Act like we already included this file, as it somehow gives linkage problems
- *  (mismatch linkage of C++ and C between this include and unistd.h). */
-#define CLIB_USERGROUP_PROTOS_H
+#if defined(__BEOS__)
+	#include <SupportDefs.h>
+#endif
+
+#if defined(SUNOS)
+	#include <alloca.h>
+#endif
+
+#if defined(__MORPHOS__)
+	/* MorphOS defines certain Amiga defines per default, we undefine them
+	 * here to make the rest of source less messy and more clear what is
+	 * required for morphos and what for AmigaOS */
+	#if defined(amigaos)
+		#undef amigaos
+	#endif
+	#if defined(__amigaos__)
+		#undef __amigaos__
+	# endif
+	#if defined(__AMIGA__)
+		#undef __AMIGA__
+	#endif
+	#if defined(AMIGA)
+		#undef AMIGA
+	#endif
+	#if defined(amiga)
+		#undef amiga
+	#endif
+	/* Act like we already included this file, as it somehow gives linkage problems
+	 *  (mismatch linkage of C++ and C between this include and unistd.h). */
+	#define CLIB_USERGROUP_PROTOS_H
 #endif /* __MORPHOS__ */
 
-#ifdef __APPLE__
-# include "os/macosx/osx_stdafx.h"
-/* Make endian swapping use Apple's macros to increase speed (since it will use hardware swapping if available)
- * Even though they should return uint16 and uint32, we get warnings if we don't cast those (why?) */
-# define BSWAP32(x) ((uint32)Endian32_Swap(x))
-# define BSWAP16(x) ((uint16)Endian16_Swap(x))
-#else
-# define BSWAP32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) << 8) & 0xFF0000) | (((x) << 24) & 0xFF000000))
-# define BSWAP16(x) ((x) >> 8 | (x) << 8)
+#if defined(__APPLE__)
+	#include "os/macosx/osx_stdafx.h"
 #endif /* __APPLE__ */
 
 #if defined(PSP)
-/* PSP can only have 10 file-descriptors open at any given time, but this
- *  switch only limits reads via the Fio system. So keep 2 fds free for things
- *  like saving a game. */
-# define LIMITED_FDS 8
-# define printf pspDebugScreenPrintf
+	/* PSP can only have 10 file-descriptors open at any given time, but this
+	 *  switch only limits reads via the Fio system. So keep 2 fds free for things
+	 *  like saving a game. */
+	#define LIMITED_FDS 8
+	#define printf pspDebugScreenPrintf
 #endif /* PSP */
 
 /* by default we use [] var arrays */
 #define VARARRAY_SIZE
 
-
 /* Stuff for GCC */
 #if defined(__GNUC__)
-# define NORETURN __attribute__ ((noreturn))
-# define FORCEINLINE inline
-# define CDECL
-# define __int64 long long
-# define GCC_PACK __attribute__((packed))
+	#define NORETURN __attribute__ ((noreturn))
+	#define FORCEINLINE inline
+	#define CDECL
+	#define __int64 long long
+	#define GCC_PACK __attribute__((packed))
 
-# if (__GNUC__ == 2)
-#  undef VARARRAY_SIZE
-#  define VARARRAY_SIZE 0
-# endif
+	#if (__GNUC__ == 2)
+		#undef VARARRAY_SIZE
+		#define VARARRAY_SIZE 0
+	#endif
 #endif /* __GNUC__ */
 
 #if defined(__WATCOMC__)
-# define NORETURN
-# define FORCEINLINE inline
-# define CDECL
-# define GCC_PACK
-# include <malloc.h>
+	#define NORETURN
+	#define FORCEINLINE inline
+	#define CDECL
+	#define GCC_PACK
+	#include <malloc.h>
 #endif /* __WATCOMC__ */
 
 #if defined(__MINGW32__) || defined(__CYGWIN__)
-# include <malloc.h> // alloca()
+	#include <malloc.h> // alloca()
 #endif
 
 /* Stuff for MSVC */
 #if defined(_MSC_VER)
-# pragma once
-/* Define a win32 target platform, to override defaults of the SDK
- * We need to define NTDDI version for Vista SDK, but win2k is minimum */
-# define NTDDI_VERSION NTDDI_WIN2K // Windows 2000
-# define _WIN32_WINNT 0x0500       // Windows 2000
-
-# define _WIN32_WINDOWS 0x400      // Windows 95
-#if !defined(WINCE)
-# define WINVER 0x0400             // Windows NT 4.0 / Windows 95
-#endif
-# define _WIN32_IE_ 0x0401         // 4.01 (win98 and NT4SP5+)
-
-# define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
-# pragma warning(disable: 4244)  // 'conversion' conversion from 'type1' to 'type2', possible loss of data
-# pragma warning(disable: 4761)  // integral size mismatch in argument : conversion supplied
-# pragma warning(disable: 4200)  // nonstandard extension used : zero-sized array in struct/union
-
-# if _MSC_VER >= 1400              // MSVC 2005 safety checks
-#  pragma warning(disable: 4996)   // 'strdup' was declared deprecated
-#  define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
-#  define _CRT_NON_CONFORMING_SWPRINTFS // another deprecated stuff
-#  pragma warning(disable: 6308)   // code analyzer: 'realloc' might return null pointer: assigning null pointer to 't_ptr', which is passed as an argument to 'realloc', will cause the original memory block to be leaked
-#  pragma warning(disable: 6011)   // code analyzer: Dereferencing NULL pointer 'pfGetAddrInfo': Lines: 995, 996, 998, 999, 1001
-#  pragma warning(disable: 6326)   // code analyzer: potential comparison of a constant with another constant
-#  pragma warning(disable: 6031)   // code analyzer: Return value ignored: 'ReadFile'
-#  pragma warning(disable: 6255)   // code analyzer: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
-#  pragma warning(disable: 6246)   // code analyzer: Local declaration of 'statspec' hides declaration of the same name in outer scope. For additional information, see previous declaration at ...
-# else /* _MSC_VER >= 1400  ( <1400 for MSVC2003) */
-#  pragma warning(disable: 4288)   // nonstandard extension used : 'y' : loop control variable declared in the for-loop is used outside the for-loop scope; it conflicts with the declaration in the outer scope
-#  pragma warning(disable: 4292)   // compiler limit : terminating debug information emission for enum 'StringIdEnum' with member 'STR_801D_COAL_CAR'
-# endif /* _MSC_VER >= 1400 */
+	#pragma once
+	/* Define a win32 target platform, to override defaults of the SDK
+	 * We need to define NTDDI version for Vista SDK, but win2k is minimum */
+	#define NTDDI_VERSION NTDDI_WIN2K // Windows 2000
+	#define _WIN32_WINNT 0x0500       // Windows 2000
+	#define _WIN32_WINDOWS 0x400      // Windows 95
+	#if !defined(WINCE)
+		#define WINVER 0x0400     // Windows NT 4.0 / Windows 95
+	#endif
+	#define _WIN32_IE_ 0x0401         // 4.01 (win98 and NT4SP5+)
 
-# include <malloc.h> // alloca()
-# define NORETURN __declspec(noreturn)
-# define FORCEINLINE __forceinline
-# define inline _inline
-# if !defined(WINCE)
-#  define CDECL _cdecl
-# endif
-  int CDECL snprintf(char *str, size_t size, const char *format, ...);
-# if _MSC_VER < 1400 || defined(WINCE)
-   int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
-# endif
+	#define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
+	#pragma warning(disable: 4244)  // 'conversion' conversion from 'type1' to 'type2', possible loss of data
+	#pragma warning(disable: 4761)  // integral size mismatch in argument : conversion supplied
+	#pragma warning(disable: 4200)  // nonstandard extension used : zero-sized array in struct/union
 
-# if defined(WIN32) && !defined(_WIN64) && !defined(WIN64)
-#  ifndef _W64
-#   define _W64
-#  endif
-   typedef _W64 int INT_PTR, *PINT_PTR;
-   typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
-# endif /* WIN32 && !_WIN64 && !WIN64 */
-
-# define GCC_PACK
+	#if (_MSC_VER >= 1400)                   // MSVC 2005 safety checks
+		#pragma warning(disable: 4996)   // 'strdup' was declared deprecated
+		#define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
+		#pragma warning(disable: 6308)   // code analyzer: 'realloc' might return null pointer: assigning null pointer to 't_ptr', which is passed as an argument to 'realloc', will cause the original memory block to be leaked
+		#pragma warning(disable: 6011)   // code analyzer: Dereferencing NULL pointer 'pfGetAddrInfo': Lines: 995, 996, 998, 999, 1001
+		#pragma warning(disable: 6326)   // code analyzer: potential comparison of a constant with another constant
+		#pragma warning(disable: 6031)   // code analyzer: Return value ignored: 'ReadFile'
+		#pragma warning(disable: 6255)   // code analyzer: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
+		#pragma warning(disable: 6246)   // code analyzer: Local declaration of 'statspec' hides declaration of the same name in outer scope. For additional information, see previous declaration at ...
+	#else /* _MSC_VER >= 1400  ( <1400 for MSVC2003) */
+		#pragma warning(disable: 4288)   // nonstandard extension used : 'y' : loop control variable declared in the for-loop is used outside the for-loop scope; it conflicts with the declaration in the outer scope
+		#pragma warning(disable: 4292)   // compiler limit : terminating debug information emission for enum 'StringIdEnum' with member 'STR_801D_COAL_CAR'
+	#endif /* _MSC_VER >= 1400 */
 
-/* This is needed to zlib uses the stdcall calling convention on visual studio */
-# if defined(WITH_ZLIB) || defined(WITH_PNG)
-#  ifndef ZLIB_WINAPI
-#   define ZLIB_WINAPI
-#  endif
-# endif
+	#include <malloc.h> // alloca()
+	#define NORETURN __declspec(noreturn)
+	#define FORCEINLINE __forceinline
+	#define inline _inline
 
-# if defined(WINCE)
-#  define strcasecmp _stricmp
-#  define strncasecmp _strnicmp
-#  undef DEBUG
-# else
-#  define strcasecmp stricmp
-#  define strncasecmp strnicmp
-# endif
-/* suppress: warning C4005: 'offsetof' : macro redefinition (VC8) */
+	#if !defined(WINCE)
+		#define CDECL _cdecl
+	#endif
+
+	int CDECL snprintf(char *str, size_t size, const char *format, ...);
+	#if (_MSC_VER < 1400) || defined(WINCE)
+		int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
+	#endif
+
+	#if defined(WIN32) && !defined(_WIN64) && !defined(WIN64)
+		#if !defined(_W64)
+			#define _W64
+		#endif
+
+		typedef _W64 int INT_PTR, *PINT_PTR;
+		typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
+	#endif /* WIN32 && !_WIN64 && !WIN64 */
+
+	#define GCC_PACK
+
+	/* This is needed to zlib uses the stdcall calling convention on visual studio */
+	#if defined(WITH_ZLIB) || defined(WITH_PNG)
+		#if !defined(ZLIB_WINAPI)
+			#define ZLIB_WINAPI
+		#endif
+	#endif
+
+	#if defined(WINCE)
+		#define strcasecmp _stricmp
+		#define strncasecmp _strnicmp
+		#undef DEBUG
+	#else
+		#define strcasecmp stricmp
+		#define strncasecmp strnicmp
+	#endif
+
+	void SetExceptionString(const char* s, ...);
+
+	#if defined(NDEBUG) && defined(WITH_ASSERT)
+		#undef assert
+		#define assert(expression) if (!(expression)) { SetExceptionString("Assertion failed at %s:%d: %s", __FILE__, __LINE__, #expression); *(byte*)0 = 0; }
+	#endif
 #endif /* defined(_MSC_VER) */
 
 #if defined(WINCE)
-# define strdup _strdup
+	#define strdup _strdup
 #endif /* WINCE */
 
 /* NOTE: the string returned by these functions is only valid until the next
  * call to the same function and is not thread- or reentrancy-safe */
 #if !defined(STRGEN)
-# if defined(WIN32) || defined(WIN64)
-char *getcwd(char *buf, size_t size);
-#  include <tchar.h>
-/* XXX - WinCE without MSVCRT doesn't support wfopen, so it seems */
-#  if !defined(WINCE)
-#   define fopen(file, mode) _tfopen(OTTD2FS(file), _T(mode))
-#  endif /* WINCE */
+	#if defined(WIN32) || defined(WIN64)
+		char *getcwd(char *buf, size_t size);
+		#include <tchar.h>
 
-   const char *FS2OTTD(const TCHAR *name);
-   const TCHAR *OTTD2FS(const char *name);
-# else
+		/* XXX - WinCE without MSVCRT doesn't support wfopen, so it seems */
+		#if !defined(WINCE)
+			#define fopen(file, mode) _tfopen(OTTD2FS(file), _T(mode))
+		#endif /* WINCE */
 
-#  define fopen(file, mode) fopen(OTTD2FS(file), mode)
-   const char *FS2OTTD(const char *name);
-   const char *OTTD2FS(const char *name);
-# endif /* WIN32 */
+		const char *FS2OTTD(const TCHAR *name);
+		const TCHAR *OTTD2FS(const char *name);
+	#else
+		#define fopen(file, mode) fopen(OTTD2FS(file), mode)
+		const char *FS2OTTD(const char *name);
+		const char *OTTD2FS(const char *name);
+	#endif /* WIN32 */
 #endif /* STRGEN */
 
-/* Windows has always LITTLE_ENDIAN */
-#if defined(WIN32) || defined(__OS2__) || defined(WIN64)
-# define TTD_LITTLE_ENDIAN
-#elif defined(TESTING)
+#if defined(WIN32) || defined(WIN64) || defined(__OS2__) && !defined(__INNOTEK_LIBC__)
+	#define PATHSEP "\\"
+	#define PATHSEPCHAR '\\'
 #else
-/* Else include endian[target/host].h, which has the endian-type, autodetected by the Makefile */
-# if defined(STRGEN)
-#  include "endian_host.h"
-# else
-#  include "endian_target.h"
-# endif
-#endif /* WIN32 || __OS2__ || WIN64 */
-
-#if defined(WIN32) || defined(WIN64) || defined(__OS2__) && !defined(__INNOTEK_LIBC__)
-# define PATHSEP "\\"
-# define PATHSEPCHAR '\\'
-#else
-# define PATHSEP "/"
-# define PATHSEPCHAR '/'
+	#define PATHSEP "/"
+	#define PATHSEPCHAR '/'
 #endif
 
 typedef unsigned char byte;
-#ifndef __BEOS__ /* already defined */
-  typedef unsigned char uint8;
-  typedef unsigned short uint16;
-  typedef unsigned int uint32;
-#endif
 
-/* This is already defined in unix */
-#if !defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__MORPHOS__)
-  typedef unsigned int uint;
-#endif
-/* Not defined in QNX Neutrino (6.x) */
-#if defined(__QNXNTO__)
-  typedef unsigned int uint;
-#endif
-
-#ifndef __BEOS__
-	typedef signed char int8;
-	typedef signed short int16;
-	typedef signed int int32;
-	typedef signed __int64 int64;
-	typedef unsigned __int64 uint64;
-#endif /* !__BEOS__ */
-
-#if defined(ARM) || defined(__arm__) || defined(__alpha__)
-# define OTTD_ALIGNMENT
+/* This is already defined in unix, but not in QNX Neutrino (6.x)*/
+#if (!defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__MORPHOS__)) || defined(__QNXNTO__)
+	typedef unsigned int uint;
 #endif
 
-/* Setup alignment and conversion macros */
-#if defined(TTD_BIG_ENDIAN)
-  static inline uint32 TO_LE32(uint32 x) { return BSWAP32(x); }
-  static inline uint16 TO_LE16(uint16 x) { return BSWAP16(x); }
-  static inline uint32 FROM_LE32(uint32 x) { return BSWAP32(x); }
-  static inline uint16 FROM_LE16(uint16 x) { return BSWAP16(x); }
-# define TO_BE32(x)   (x)
-# define TO_BE16(x)   (x)
-# define FROM_BE32(x) (x)
-# define FROM_BE16(x) (x)
-# define TO_LE32X(x)  BSWAP32(x)
-# define TO_BE32X(x)  (x)
-#else
-  static inline uint32 TO_BE32(uint32 x) { return BSWAP32(x); }
-  static inline uint16 TO_BE16(uint16 x) { return BSWAP16(x); }
-  static inline uint32 FROM_BE32(uint32 x) { return BSWAP32(x); }
-  static inline uint16 FROM_BE16(uint16 x) { return BSWAP16(x); }
-# define TO_LE32(x)   (x)
-# define TO_LE16(x)   (x)
-# define FROM_LE32(x) (x)
-# define FROM_LE16(x) (x)
-# define TO_LE32X(x)  (x)
-# define TO_BE32X(x)  BSWAP32(x)
-#endif /* TTD_BIG_ENDIAN */
+#if !defined(__BEOS__) /* Already defined on BEOS */
+	typedef unsigned char    uint8;
+	typedef   signed char     int8;
+	typedef unsigned short   uint16;
+	typedef   signed short    int16;
+	typedef unsigned int     uint32;
+	typedef   signed int      int32;
+	typedef unsigned __int64 uint64;
+	typedef   signed __int64  int64;
+#endif
 
 #if !defined(WITH_PERSONAL_DIR)
-# define PERSONAL_DIR ""
+	#define PERSONAL_DIR ""
 #endif
 
 /* Compile time assertions */
-#ifdef __OS2__
-# define assert_compile(expr)
+#if defined(__OS2__)
+	#define assert_compile(expr)
 #else
-# define assert_compile(expr) extern "C" void __ct_assert__(int a[1 - 2 * !(expr)])
+	#define assert_compile(expr) extern "C" void __ct_assert__(int a[1 - 2 * !(expr)])
 #endif /* __OS2__ */
 
 assert_compile(sizeof(uint32) == 4);
@@ -329,47 +281,48 @@
 #define lastof(x) (&x[lengthof(x) - 1])
 
 #define cpp_offsetof(s,m)   (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8)
-#ifndef offsetof
-# define offsetof(s,m)       cpp_offsetof(s, m)
+#if !defined(offsetof)
+	#define offsetof(s,m) cpp_offsetof(s, m)
 #endif /* offsetof */
 
 
 /* take care of some name clashes on MacOS */
 #if defined(__APPLE__)
-# define GetString OTTD_GetString
-# define DrawString OTTD_DrawString
-# define Random OTTD_Random
-# define CloseConnection OTTD_CloseConnection
-#endif /* __APPLE */
+	#define GetString OTTD_GetString
+	#define DrawString OTTD_DrawString
+	#define CloseConnection OTTD_CloseConnection
+#endif /* __APPLE__ */
 
-#ifdef __AMIGA__
-/* it seems AmigaOS already have a Point declared */
-# define Point OTTD_AMIGA_POINT
+#if !defined(STRGEN)
+	/* In strgen error is not fatal and returns */
+	void NORETURN CDECL error(const char *str, ...);
+#else
+	void CDECL error(const char *str, ...);
 #endif
 
-void
-#ifndef STRGEN
-/* In strgen error is not fatal and returns */
-NORETURN
-#endif /* STRGEN */
-CDECL error(const char *str, ...);
 #define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
 
 #if defined(MORPHOS)
-/* MorphOS doesn't have C++ conformant _stricmp... */
-#define _stricmp stricmp
+	/* MorphOS doesn't have C++ conformant _stricmp... */
+	#define _stricmp stricmp
 #elif defined(OPENBSD)
-/* OpenBSD uses strcasecmp(3) */
-#define _stricmp strcasecmp
+	/* OpenBSD uses strcasecmp(3) */
+	#define _stricmp strcasecmp
 #endif
 
 #if !defined(MORPHOS) && !defined(OPENBSD)
-/* MorphOS & OpenBSD don't know wchars, the rest does :( */
-#define HAS_WCHAR
+	/* MorphOS & OpenBSD don't know wchars, the rest does :( */
+	#define HAS_WCHAR
 #endif /* !defined(MORPHOS) && !defined(OPENBSD) */
 
 #if !defined(MAX_PATH)
-# define MAX_PATH 260
+	#define MAX_PATH 260
 #endif
 
+/**
+ * The largest value that can be entered in a variable
+ * @param type the type of the variable
+ */
+#define MAX_UVALUE(type) ((type)~(type)0)
+
 #endif /* STDAFX_H */
--- a/src/strgen/strgen.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/strgen/strgen.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -1,10 +1,10 @@
 /* $Id$ */
 
 #include "../stdafx.h"
-#include "../macros.h"
-#include "../string.h"
 #include "../table/control_codes.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
+#include "../core/endian_func.hpp"
+#include "../string_func.h"
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
--- a/src/string.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/string.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,12 +4,10 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "string.h"
-#include "macros.h"
 #include "table/control_codes.h"
-#include "helpers.hpp"
 #include "debug.h"
+#include "core/alloc_func.hpp"
+#include "string_func.h"
 
 #include <stdarg.h>
 #include <ctype.h> // required for tolower()
@@ -155,6 +153,8 @@
 }
 
 #ifdef WIN32
+/* Since version 3.14, MinGW Runtime has snprintf() and vsnprintf() conform to C99 but it's not the case for older versions */
+#if (__MINGW32_MAJOR_VERSION < 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION < 14))
 int CDECL snprintf(char *str, size_t size, const char *format, ...)
 {
 	va_list ap;
@@ -165,6 +165,7 @@
 	va_end(ap);
 	return ret;
 }
+#endif /* MinGW Runtime < 3.14 */
 
 #ifdef _MSC_VER
 /* *nprintf broken, not POSIX compliant, MSDN description
--- a/src/string.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-/* $Id$ */
-
-/** @file string.h */
-
-#ifndef STRING_H
-#define STRING_H
-
-#include "macros.h"
-
-/**
- * usage ttd_strlcpy(dst, src, lengthof(dst));
- * @param dst destination buffer
- * @param src string to copy/concatenate
- * @param size size of the destination buffer
- */
-void ttd_strlcat(char *dst, const char *src, size_t size);
-void ttd_strlcpy(char *dst, const char *src, size_t size);
-
-/**
- * usage: strecpy(dst, src, lastof(dst));
- * @param dst destination buffer
- * @param src string to copy
- * @param last pointer to the last element in the dst array
- *             if NULL no boundary check is performed
- * @return a pointer to the terminating \0 in the destination buffer
- */
-char *strecat(char *dst, const char *src, const char *last);
-char *strecpy(char *dst, const char *src, const char *last);
-
-char *CDECL str_fmt(const char *str, ...);
-
-/** Scans the string for valid characters and if it finds invalid ones,
- * replaces them with a question mark '?' */
-void str_validate(char *str);
-
-/** Scans the string for colour codes and strips them */
-void str_strip_colours(char *str);
-
-/**
- * Valid filter types for IsValidChar.
- */
-enum CharSetFilter {
-	CS_ALPHANUMERAL,      ///< Both numeric and alphabetic and spaces and stuff
-	CS_NUMERAL,           ///< Only numeric ones
-	CS_ALPHA,             ///< Only alphabetic values
-};
-
-/** Convert the given string to lowercase, only works with ASCII! */
-void strtolower(char *str);
-
-
-static inline bool StrEmpty(const char *s) { return s == NULL || s[0] == '\0'; }
-
-
-/** Get the length of a string, within a limited buffer */
-static inline int ttd_strnlen(const char *str, int maxlen)
-{
-	const char *t;
-	for (t = str; *t != '\0' && t - str < maxlen; t++);
-	return t - str;
-}
-
-/** Convert the md5sum number to a 'hexadecimal' string, return next pos in buffer */
-char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16]);
-
-typedef uint32 WChar;
-
-/**
- * Only allow certain keys. You can define the filter to be used. This makes
- *  sure no invalid keys can get into an editbox, like BELL.
- * @param key character to be checked
- * @param afilter the filter to use
- * @return true or false depending if the character is printable/valid or not
- */
-bool IsValidChar(WChar key, CharSetFilter afilter);
-
-size_t Utf8Decode(WChar *c, const char *s);
-size_t Utf8Encode(char *buf, WChar c);
-size_t Utf8TrimString(char *s, size_t maxlen);
-
-
-static inline WChar Utf8Consume(const char **s)
-{
-	WChar c;
-	*s += Utf8Decode(&c, *s);
-	return c;
-}
-
-
-/** Return the length of a UTF-8 encoded character.
- * @param c Unicode character.
- * @return Length of UTF-8 encoding for character.
- */
-static inline size_t Utf8CharLen(WChar c)
-{
-	if (c < 0x80)       return 1;
-	if (c < 0x800)      return 2;
-	if (c < 0x10000)    return 3;
-	if (c < 0x110000)   return 4;
-
-	/* Invalid valid, we encode as a '?' */
-	return 1;
-}
-
-
-/**
- * Return the length of an UTF-8 encoded value based on a single char. This
- * char should be the first byte of the UTF-8 encoding. If not, or encoding
- * is invalid, return value is 0
- * @param c char to query length of
- * @return requested size
- */
-static inline size_t Utf8EncodedCharLen(char c)
-{
-	if (GB(c, 3, 5) == 0x1E) return 4;
-	if (GB(c, 4, 4) == 0x0E) return 3;
-	if (GB(c, 5, 3) == 0x06) return 2;
-	if (GB(c, 7, 1) == 0x00) return 1;
-
-	/* Invalid UTF8 start encoding */
-	return 0;
-}
-
-
-/* Check if the given character is part of a UTF8 sequence */
-static inline bool IsUtf8Part(char c)
-{
-	return GB(c, 6, 2) == 2;
-}
-
-/**
- * Retrieve the previous UNICODE character in an UTF-8 encoded string.
- * @param s char pointer pointing to (the first char of) the next character
- * @return a pointer in 's' to the previous UNICODE character's first byte
- * @note The function should not be used to determine the length of the previous
- * encoded char because it might be an invalid/corrupt start-sequence
- */
-static inline char *Utf8PrevChar(const char *s)
-{
-	const char *ret = s;
-	while (IsUtf8Part(*--ret));
-	return (char*)ret;
-}
-
-
-static inline bool IsPrintable(WChar c)
-{
-	if (c < 0x20)   return false;
-	if (c < 0xE000) return true;
-	if (c < 0xE200) return false;
-	return true;
-}
-
-/**
- * Check whether UNICODE character is whitespace or not
- * @param c UNICODE character to check
- * @return a boolean value whether 'c' is a whitespace character or not
- * @see http://www.fileformat.info/info/unicode/category/Zs/list.htm
- */
-static inline bool IsWhitespace(WChar c)
-{
-	return
-	  c == 0x0020 /* SPACE */ ||
-	  c == 0x00A0 /* NO-BREAK SPACE */ ||
-	  c == 0x3000 /* IDEOGRAPHIC SPACE */
-	;
-}
-
-
-#endif /* STRING_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/string_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,159 @@
+/* $Id$ */
+
+/** @file string.h Functions related to low-level strings. */
+
+#ifndef STRING_FUNC_H
+#define STRING_FUNC_H
+
+#include "core/bitmath_func.hpp"
+#include "string_type.h"
+
+/**
+ * usage ttd_strlcpy(dst, src, lengthof(dst));
+ * @param dst destination buffer
+ * @param src string to copy/concatenate
+ * @param size size of the destination buffer
+ */
+void ttd_strlcat(char *dst, const char *src, size_t size);
+void ttd_strlcpy(char *dst, const char *src, size_t size);
+
+/**
+ * usage: strecpy(dst, src, lastof(dst));
+ * @param dst destination buffer
+ * @param src string to copy
+ * @param last pointer to the last element in the dst array
+ *             if NULL no boundary check is performed
+ * @return a pointer to the terminating \0 in the destination buffer
+ */
+char *strecat(char *dst, const char *src, const char *last);
+char *strecpy(char *dst, const char *src, const char *last);
+
+char *CDECL str_fmt(const char *str, ...);
+
+/** Scans the string for valid characters and if it finds invalid ones,
+ * replaces them with a question mark '?' */
+void str_validate(char *str);
+
+/** Scans the string for colour codes and strips them */
+void str_strip_colours(char *str);
+
+/** Convert the given string to lowercase, only works with ASCII! */
+void strtolower(char *str);
+
+
+static inline bool StrEmpty(const char *s) { return s == NULL || s[0] == '\0'; }
+
+
+/** Get the length of a string, within a limited buffer */
+static inline int ttd_strnlen(const char *str, int maxlen)
+{
+	const char *t;
+	for (t = str; *t != '\0' && t - str < maxlen; t++);
+	return t - str;
+}
+
+/** Convert the md5sum number to a 'hexadecimal' string, return next pos in buffer */
+char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16]);
+
+/**
+ * Only allow certain keys. You can define the filter to be used. This makes
+ *  sure no invalid keys can get into an editbox, like BELL.
+ * @param key character to be checked
+ * @param afilter the filter to use
+ * @return true or false depending if the character is printable/valid or not
+ */
+bool IsValidChar(WChar key, CharSetFilter afilter);
+
+size_t Utf8Decode(WChar *c, const char *s);
+size_t Utf8Encode(char *buf, WChar c);
+size_t Utf8TrimString(char *s, size_t maxlen);
+
+
+static inline WChar Utf8Consume(const char **s)
+{
+	WChar c;
+	*s += Utf8Decode(&c, *s);
+	return c;
+}
+
+
+/** Return the length of a UTF-8 encoded character.
+ * @param c Unicode character.
+ * @return Length of UTF-8 encoding for character.
+ */
+static inline size_t Utf8CharLen(WChar c)
+{
+	if (c < 0x80)       return 1;
+	if (c < 0x800)      return 2;
+	if (c < 0x10000)    return 3;
+	if (c < 0x110000)   return 4;
+
+	/* Invalid valid, we encode as a '?' */
+	return 1;
+}
+
+
+/**
+ * Return the length of an UTF-8 encoded value based on a single char. This
+ * char should be the first byte of the UTF-8 encoding. If not, or encoding
+ * is invalid, return value is 0
+ * @param c char to query length of
+ * @return requested size
+ */
+static inline size_t Utf8EncodedCharLen(char c)
+{
+	if (GB(c, 3, 5) == 0x1E) return 4;
+	if (GB(c, 4, 4) == 0x0E) return 3;
+	if (GB(c, 5, 3) == 0x06) return 2;
+	if (GB(c, 7, 1) == 0x00) return 1;
+
+	/* Invalid UTF8 start encoding */
+	return 0;
+}
+
+
+/* Check if the given character is part of a UTF8 sequence */
+static inline bool IsUtf8Part(char c)
+{
+	return GB(c, 6, 2) == 2;
+}
+
+/**
+ * Retrieve the previous UNICODE character in an UTF-8 encoded string.
+ * @param s char pointer pointing to (the first char of) the next character
+ * @return a pointer in 's' to the previous UNICODE character's first byte
+ * @note The function should not be used to determine the length of the previous
+ * encoded char because it might be an invalid/corrupt start-sequence
+ */
+static inline char *Utf8PrevChar(const char *s)
+{
+	const char *ret = s;
+	while (IsUtf8Part(*--ret));
+	return (char*)ret;
+}
+
+
+static inline bool IsPrintable(WChar c)
+{
+	if (c < 0x20)   return false;
+	if (c < 0xE000) return true;
+	if (c < 0xE200) return false;
+	return true;
+}
+
+/**
+ * Check whether UNICODE character is whitespace or not
+ * @param c UNICODE character to check
+ * @return a boolean value whether 'c' is a whitespace character or not
+ * @see http://www.fileformat.info/info/unicode/category/Zs/list.htm
+ */
+static inline bool IsWhitespace(WChar c)
+{
+	return
+	  c == 0x0020 /* SPACE */ ||
+	  c == 0x00A0 /* NO-BREAK SPACE */ ||
+	  c == 0x3000 /* IDEOGRAPHIC SPACE */
+	;
+}
+
+#endif /* STRING_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/string_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+/** @file string_type.h Types for strings. */
+
+#ifndef STRING_TYPE_H
+#define STRING_TYPE_H
+
+/**
+ * Valid filter types for IsValidChar.
+ */
+enum CharSetFilter {
+	CS_ALPHANUMERAL,      ///< Both numeric and alphabetic and spaces and stuff
+	CS_NUMERAL,           ///< Only numeric ones
+	CS_ALPHA,             ///< Only alphabetic values
+};
+
+typedef uint32 WChar;
+
+#endif /* STRING_TYPE_H */
--- a/src/strings.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/strings.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,14 +5,10 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "currency.h"
-#include "functions.h"
-#include "string.h"
-#include "strings.h"
 #include "table/strings.h"
 #include "namegen.h"
 #include "station.h"
 #include "town.h"
-#include "vehicle.h"
 #include "news.h"
 #include "screenshot.h"
 #include "waypoint.h"
@@ -21,17 +17,23 @@
 #include "newgrf_text.h"
 #include "table/control_codes.h"
 #include "music.h"
-#include "date.h"
 #include "industry.h"
 #include "fileio.h"
-#include "helpers.hpp"
 #include "cargotype.h"
 #include "group.h"
 #include "debug.h"
 #include "newgrf_townname.h"
 #include "signs.h"
-#include "vehicle.h"
 #include "newgrf_engine.h"
+#include "spritecache.h"
+#include "fontcache.h"
+#include "gui.h"
+#include "strings_func.h"
+#include "functions.h"
+#include "core/endian_func.hpp"
+#include "date_func.h"
+#include "vehicle_base.h"
+#include "string_func.h"
 
 /* for opendir/readdir/closedir */
 # include "fios.h"
@@ -1120,20 +1122,20 @@
 	}
 
 	/* town name? */
-	if (IS_INT_INSIDE(ind - 6, 0, SPECSTR_TOWNNAME_LAST-SPECSTR_TOWNNAME_START + 1)) {
+	if (IsInsideMM(ind - 6, 0, SPECSTR_TOWNNAME_LAST-SPECSTR_TOWNNAME_START + 1)) {
 		buff = GetSpecialTownNameString(buff, ind - 6, GetInt32(&argv), last);
 		return strecpy(buff, " Transport", last);
 	}
 
 	/* language name? */
-	if (IS_INT_INSIDE(ind, (SPECSTR_LANGUAGE_START - 0x70E4), (SPECSTR_LANGUAGE_END - 0x70E4) + 1)) {
+	if (IsInsideMM(ind, (SPECSTR_LANGUAGE_START - 0x70E4), (SPECSTR_LANGUAGE_END - 0x70E4) + 1)) {
 		int i = ind - (SPECSTR_LANGUAGE_START - 0x70E4);
 		return strecpy(buff,
 			i == _dynlang.curr ? _langpack->own_name : _dynlang.ent[i].name, last);
 	}
 
 	/* resolution size? */
-	if (IS_INT_INSIDE(ind, (SPECSTR_RESOLUTION_START - 0x70E4), (SPECSTR_RESOLUTION_END - 0x70E4) + 1)) {
+	if (IsInsideMM(ind, (SPECSTR_RESOLUTION_START - 0x70E4), (SPECSTR_RESOLUTION_END - 0x70E4) + 1)) {
 		int i = ind - (SPECSTR_RESOLUTION_START - 0x70E4);
 		buff += snprintf(
 			buff, last - buff + 1, "%dx%d", _resolutions[i][0], _resolutions[i][1]
@@ -1142,7 +1144,7 @@
 	}
 
 	/* screenshot format name? */
-	if (IS_INT_INSIDE(ind, (SPECSTR_SCREENSHOT_START - 0x70E4), (SPECSTR_SCREENSHOT_END - 0x70E4) + 1)) {
+	if (IsInsideMM(ind, (SPECSTR_SCREENSHOT_START - 0x70E4), (SPECSTR_SCREENSHOT_END - 0x70E4) + 1)) {
 		int i = ind - (SPECSTR_SCREENSHOT_START - 0x70E4);
 		return strecpy(buff, GetScreenshotFormatDesc(i), last);
 	}
@@ -1168,7 +1170,7 @@
 		case 0xA02F: return STR_SV_AIRCRAFT_NAME;
 
 		default:
-			if (IS_INT_INSIDE(s, 0x300F, 0x3030)) {
+			if (IsInsideMM(s, 0x300F, 0x3030)) {
 				return s - 0x300F + STR_SV_STNAME;
 			} else {
 				return s;
@@ -1435,3 +1437,57 @@
 
 	if (!ReadLanguagePack(chosen_language)) error("Can't read language pack '%s'", dl->ent[chosen_language].file);
 }
+
+/**
+ * Check whether the currently loaded language pack
+ * uses characters that the currently loaded font
+ * does not support. If this is the case an error
+ * message will be shown in English. The error
+ * message will not be localized because that would
+ * mean it might use characters that are not in the
+ * font, which is the whole reason this check has
+ * been added.
+ */
+void CheckForMissingGlyphsInLoadedLanguagePack()
+{
+	const Sprite *question_mark = GetGlyph(FS_NORMAL, '?');
+
+	for (uint i = 0; i != 32; i++) {
+		for (uint j = 0; j < _langtab_num[i]; j++) {
+			const char *string = _langpack_offs[_langtab_start[i] + j];
+			WChar c;
+			while ((c = Utf8Consume(&string)) != '\0') {
+				if (c == SCC_SETX) {
+					/*
+					 * SetX is, together with SetXY as special character that
+					 * uses the next (two) characters as data points. We have
+					 * to skip those, otherwise the UTF8 reading will go
+					 * haywire.
+					 */
+					string++;
+				} else if (c == SCC_SETXY) {
+					string += 2;
+				} else if (IsPrintable(c) && c != '?' && GetGlyph(FS_NORMAL, c) == question_mark) {
+					/*
+					 * The character is printable, but not in the normal font.
+					 * This is the case we were testing for. In this case we
+					 * have to show the error. As we do not want the string to
+					 * be translated by the translators, we 'force' it into the
+					 * binary and 'load' it via a BindCString. To do this
+					 * properly we have to set the color of the string,
+					 * otherwise we end up with a lot of artefacts. The color
+					 * 'character' might change in the future, so for safety
+					 * we just Utf8 Encode it into the string, which takes
+					 * exactly three characters, so it replaces the "XXX" with
+					 * the color marker.
+					 */
+					static char *err_str = strdup("XXXThe current font is missing some of the characters used in the texts for this language. Read the readme to see how to solve this.");
+					Utf8Encode(err_str, SCC_YELLOW);
+					StringID err_msg = BindCString(err_str);
+					ShowErrorMessage(INVALID_STRING_ID, err_msg, 0, 0);
+					return;
+				}
+			}
+		}
+	}
+}
--- a/src/strings.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/* $Id$ */
-
-/** @file strings.h */
-
-#ifndef STRINGS_H
-#define STRINGS_H
-
-char *InlineString(char *buf, StringID string);
-char *GetString(char *buffr, StringID string, const char *last);
-
-extern char _userstring[128];
-
-void InjectDParam(int amount);
-
-static inline void SetDParamX(uint64 *s, uint n, uint64 v)
-{
-	s[n] = v;
-}
-
-static inline void SetDParam(uint n, uint64 v)
-{
-	extern uint64 _decode_parameters[20];
-
-	assert(n < lengthof(_decode_parameters));
-	_decode_parameters[n] = v;
-}
-
-/* Used to bind a C string name to a dparam number.
- * NOTE: This has a short lifetime. You can't
- *       use this string much later or it will be gone. */
-void SetDParamStr(uint n, const char *str);
-
-/** This function takes a C-string and allocates a temporary string ID.
- * The duration of the bound string is valid only until the next call to GetString,
- * so be careful. */
-StringID BindCString(const char *str);
-
-static inline uint64 GetDParamX(const uint64 *s, uint n)
-{
-	return s[n];
-}
-
-static inline uint64 GetDParam(uint n)
-{
-	extern uint64 _decode_parameters[20];
-
-	assert(n < lengthof(_decode_parameters));
-	return _decode_parameters[n];
-}
-
-static inline void CopyInDParam(int offs, const uint64 *src, int num)
-{
-	extern uint64 _decode_parameters[20];
-	memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num));
-}
-
-static inline void CopyOutDParam(uint64 *dst, int offs, int num)
-{
-	extern uint64 _decode_parameters[20];
-	memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num));
-}
-
-
-/** Information about a language */
-struct Language {
-	char *name; ///< The internal name of the language
-	char *file; ///< The name of the language as it appears on disk
-};
-
-/** Used for dynamic language support */
-struct DynamicLanguages {
-	int num;                         ///< Number of languages
-	int curr;                        ///< Currently selected language index
-	char curr_file[MAX_PATH];        ///< Currently selected language file name without path (needed for saving the filename of the loaded language).
-	StringID dropdown[MAX_LANG + 1]; ///< List of languages in the settings gui
-	Language ent[MAX_LANG];          ///< Information about the languages
-};
-
-extern DynamicLanguages _dynlang; // defined in strings.cpp
-
-bool ReadLanguagePack(int index);
-void InitializeLanguagePacks();
-
-int CDECL StringIDSorter(const void *a, const void *b);
-
-#endif /* STRINGS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/strings_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,74 @@
+/* $Id$ */
+
+/** @file strings_func.h Functions related to OTTD's strings. */
+
+#ifndef STRINGS_FUNC_H
+#define STRINGS_FUNC_H
+
+#include "strings_type.h"
+
+char *InlineString(char *buf, StringID string);
+char *GetString(char *buffr, StringID string, const char *last);
+
+extern char _userstring[128];
+
+void InjectDParam(int amount);
+
+static inline void SetDParamX(uint64 *s, uint n, uint64 v)
+{
+	s[n] = v;
+}
+
+static inline void SetDParam(uint n, uint64 v)
+{
+	extern uint64 _decode_parameters[20];
+
+	assert(n < lengthof(_decode_parameters));
+	_decode_parameters[n] = v;
+}
+
+/* Used to bind a C string name to a dparam number.
+ * NOTE: This has a short lifetime. You can't
+ *       use this string much later or it will be gone. */
+void SetDParamStr(uint n, const char *str);
+
+/** This function takes a C-string and allocates a temporary string ID.
+ * The duration of the bound string is valid only until the next call to GetString,
+ * so be careful. */
+StringID BindCString(const char *str);
+
+static inline uint64 GetDParamX(const uint64 *s, uint n)
+{
+	return s[n];
+}
+
+static inline uint64 GetDParam(uint n)
+{
+	extern uint64 _decode_parameters[20];
+
+	assert(n < lengthof(_decode_parameters));
+	return _decode_parameters[n];
+}
+
+static inline void CopyInDParam(int offs, const uint64 *src, int num)
+{
+	extern uint64 _decode_parameters[20];
+	memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num));
+}
+
+static inline void CopyOutDParam(uint64 *dst, int offs, int num)
+{
+	extern uint64 _decode_parameters[20];
+	memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num));
+}
+
+extern DynamicLanguages _dynlang; // defined in strings.cpp
+
+bool ReadLanguagePack(int index);
+void InitializeLanguagePacks();
+
+int CDECL StringIDSorter(const void *a, const void *b);
+
+void CheckForMissingGlyphsInLoadedLanguagePack();
+
+#endif /* STRINGS_TYPE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/strings_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,89 @@
+/* $Id$ */
+
+/** @file strings_type.h Types related to strings. */
+
+#ifndef STRINGS_TYPE_H
+#define STRINGS_TYPE_H
+
+typedef uint16 StringID;
+static const StringID INVALID_STRING_ID = 0xFFFF;
+
+enum {
+	MAX_LANG = 64,
+};
+
+/** Information about a language */
+struct Language {
+	char *name; ///< The internal name of the language
+	char *file; ///< The name of the language as it appears on disk
+};
+
+/** Used for dynamic language support */
+struct DynamicLanguages {
+	int num;                         ///< Number of languages
+	int curr;                        ///< Currently selected language index
+	char curr_file[MAX_PATH];        ///< Currently selected language file name without path (needed for saving the filename of the loaded language).
+	StringID dropdown[MAX_LANG + 1]; ///< List of languages in the settings gui
+	Language ent[MAX_LANG];          ///< Information about the languages
+};
+
+// special string constants
+enum SpecialStrings {
+
+	// special strings for town names. the town name is generated dynamically on request.
+	SPECSTR_TOWNNAME_START     = 0x20C0,
+	SPECSTR_TOWNNAME_ENGLISH   = SPECSTR_TOWNNAME_START,
+	SPECSTR_TOWNNAME_FRENCH,
+	SPECSTR_TOWNNAME_GERMAN,
+	SPECSTR_TOWNNAME_AMERICAN,
+	SPECSTR_TOWNNAME_LATIN,
+	SPECSTR_TOWNNAME_SILLY,
+	SPECSTR_TOWNNAME_SWEDISH,
+	SPECSTR_TOWNNAME_DUTCH,
+	SPECSTR_TOWNNAME_FINNISH,
+	SPECSTR_TOWNNAME_POLISH,
+	SPECSTR_TOWNNAME_SLOVAKISH,
+	SPECSTR_TOWNNAME_NORWEGIAN,
+	SPECSTR_TOWNNAME_HUNGARIAN,
+	SPECSTR_TOWNNAME_AUSTRIAN,
+	SPECSTR_TOWNNAME_ROMANIAN,
+	SPECSTR_TOWNNAME_CZECH,
+	SPECSTR_TOWNNAME_SWISS,
+	SPECSTR_TOWNNAME_DANISH,
+	SPECSTR_TOWNNAME_TURKISH,
+	SPECSTR_TOWNNAME_ITALIAN,
+	SPECSTR_TOWNNAME_CATALAN,
+	SPECSTR_TOWNNAME_LAST      = SPECSTR_TOWNNAME_CATALAN,
+
+	// special strings for player names on the form "TownName transport".
+	SPECSTR_PLAYERNAME_START   = 0x70EA,
+	SPECSTR_PLAYERNAME_ENGLISH = SPECSTR_PLAYERNAME_START,
+	SPECSTR_PLAYERNAME_FRENCH,
+	SPECSTR_PLAYERNAME_GERMAN,
+	SPECSTR_PLAYERNAME_AMERICAN,
+	SPECSTR_PLAYERNAME_LATIN,
+	SPECSTR_PLAYERNAME_SILLY,
+	SPECSTR_PLAYERNAME_LAST    = SPECSTR_PLAYERNAME_SILLY,
+
+	SPECSTR_ANDCO_NAME         = 0x70E6,
+	SPECSTR_PRESIDENT_NAME     = 0x70E7,
+	SPECSTR_SONGNAME           = 0x70E8,
+
+	// reserve MAX_LANG strings for the *.lng files
+	SPECSTR_LANGUAGE_START     = 0x7100,
+	SPECSTR_LANGUAGE_END       = SPECSTR_LANGUAGE_START + MAX_LANG - 1,
+
+	// reserve 32 strings for various screen resolutions
+	SPECSTR_RESOLUTION_START   = SPECSTR_LANGUAGE_END + 1,
+	SPECSTR_RESOLUTION_END     = SPECSTR_RESOLUTION_START + 0x1F,
+
+	// reserve 32 strings for screenshot formats
+	SPECSTR_SCREENSHOT_START   = SPECSTR_RESOLUTION_END + 1,
+	SPECSTR_SCREENSHOT_END     = SPECSTR_SCREENSHOT_START + 0x1F,
+
+	// Used to implement SetDParamStr
+	STR_SPEC_DYNSTRING         = 0xF800,
+	STR_SPEC_USERSTRING        = 0xF808,
+};
+
+#endif /* STRINGS_TYPE_H */
--- a/src/subsidy_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/subsidy_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,18 +5,18 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
-#include "window.h"
 #include "station.h"
 #include "industry.h"
 #include "town.h"
 #include "player.h"
-#include "gfx.h"
-#include "economy.h"
+#include "economy_func.h"
 #include "variables.h"
-#include "date.h"
 #include "cargotype.h"
+#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)
 {
@@ -92,9 +92,10 @@
 
 	ConvertDateToYMD(_date, &ymd);
 
+	int width = w->width - 2;
 	y = 15;
 	x = 1;
-	DrawString(x, y, STR_2026_SUBSIDIES_ON_OFFER_FOR, TC_FROMSTRING);
+	DrawStringTruncated(x, y, STR_2026_SUBSIDIES_ON_OFFER_FOR, TC_FROMSTRING, width);
 	y += 10;
 	num = 0;
 
@@ -103,21 +104,21 @@
 			int x2;
 
 			SetupSubsidyDecodeParam(s, 1);
-			x2 = DrawString(x + 2, y, STR_2027_FROM_TO, TC_FROMSTRING);
+			x2 = DrawStringTruncated(x + 2, y, STR_2027_FROM_TO, TC_FROMSTRING, width);
 
 			SetDParam(0, _date - ymd.day + 384 - s->age * 32);
-			DrawString(x2, y, STR_2028_BY, TC_FROMSTRING);
+			DrawStringTruncated(x2, y, STR_2028_BY, TC_FROMSTRING, width - x2);
 			y += 10;
 			num++;
 		}
 	}
 
 	if (num == 0) {
-		DrawString(x + 2, y, STR_202A_NONE, TC_FROMSTRING);
+		DrawStringTruncated(x + 2, y, STR_202A_NONE, TC_FROMSTRING, width - 2);
 		y += 10;
 	}
 
-	DrawString(x, y + 1, STR_202B_SERVICES_ALREADY_SUBSIDISED, TC_FROMSTRING);
+	DrawStringTruncated(x, y + 1, STR_202B_SERVICES_ALREADY_SUBSIDISED, TC_FROMSTRING, width);
 	y += 10;
 	num = 0;
 
@@ -130,16 +131,16 @@
 			PlayerID player = GetStation(s->to)->owner;
 			SetDParam(3, player);
 
-			xt = DrawString(x + 2, y, STR_202C_FROM_TO, TC_FROMSTRING);
+			xt = DrawStringTruncated(x + 2, y, STR_202C_FROM_TO, TC_FROMSTRING, width - 2);
 
 			SetDParam(0, _date - ymd.day + 768 - s->age * 32);
-			DrawString(xt, y, STR_202D_UNTIL, TC_FROMSTRING);
+			DrawStringTruncated(xt, y, STR_202D_UNTIL, TC_FROMSTRING, width - xt);
 			y += 10;
 			num++;
 		}
 	}
 
-	if (num == 0) DrawString(x + 2, y, STR_202A_NONE, TC_FROMSTRING);
+	if (num == 0) DrawStringTruncated(x + 2, y, STR_202A_NONE, TC_FROMSTRING, width - 2);
 }
 
 static void SubsidiesListWndProc(Window *w, WindowEvent *e)
@@ -158,15 +159,15 @@
 }
 
 static const Widget _subsidies_list_widgets[] = {
-{   WWT_CLOSEBOX,   RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,           STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,   RESIZE_NONE, 13,  11, 617,   0,  13, STR_2025_SUBSIDIES, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{  WWT_STICKYBOX,   RESIZE_NONE, 13, 618, 629,   0,  13, STR_NULL,           STR_STICKY_BUTTON},
-{      WWT_PANEL,   RESIZE_NONE, 13,   0, 629,  14, 126, 0x0,                STR_01FD_CLICK_ON_SERVICE_TO_CENTER},
+{   WWT_CLOSEBOX, RESIZE_NONE,  13,   0,  10,   0,  13, STR_00C5,           STR_018B_CLOSE_WINDOW},
+{    WWT_CAPTION, RESIZE_RIGHT, 13,  11, 307,   0,  13, STR_2025_SUBSIDIES, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{  WWT_STICKYBOX, RESIZE_LR,    13, 308, 319,   0,  13, STR_NULL,           STR_STICKY_BUTTON},
+{      WWT_PANEL, RESIZE_RIGHT, 13,   0, 319,  14, 126, 0x0,                STR_01FD_CLICK_ON_SERVICE_TO_CENTER},
 {   WIDGETS_END},
 };
 
 static const WindowDesc _subsidies_list_desc = {
-	WDP_AUTO, WDP_AUTO, 630, 127, 630, 127,
+	WDP_AUTO, WDP_AUTO, 320, 127, 630, 127,
 	WC_SUBSIDIES_LIST, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
 	_subsidies_list_widgets,
--- a/src/table/autorail.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/autorail.h	Wed Jan 09 18:11:12 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, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 },
-	{ 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 },
-	{ 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 },
-	{ 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 },
-	{ 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 },
-	{ 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 },
-	{ 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 },
-	{ 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 }
+static const HighLightStyle _autorail_piece[][16] = {
+	{ HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR },
+	{ HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR },
+	{ HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR },
+	{ HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR },
+	{ HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR },
+	{ HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR },
+	{ HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_Y, HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y  },
+	{ HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y, HT_DIR_X, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y  },
+	{ HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y, HT_DIR_Y, HT_DIR_X, HT_DIR_Y, HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y  },
+	{ HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y,  HT_DIR_Y  },
+	{ HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL },
+	{ HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL },
+	{ HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL },
+	{ HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL },
+	{ HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL },
+	{ HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL }
 };
--- a/src/table/build_industry.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/build_industry.h	Wed Jan 09 18:11:12 2008 +0000
@@ -1175,7 +1175,7 @@
 
 #define MI(tbl, sndc, snd, d, pc, ai1, ai2, ai3, ai4, ag1, ag2, ag3, ag4, col, \
            c1, c2, c3, proc, p1, r1, p2, r2, m, a1, im1, a2, im2, a3, im3, pr, clim, bev, in, intx, s1, s2, s3) \
-	 {tbl, lengthof(tbl), min(255, d), d, pc, {c1, c2, c3}, proc, {p1, p2}, {r1, r2}, m,            \
+	 {tbl, lengthof(tbl), min(255, d), 0, d, pc, {c1, c2, c3}, proc, {p1, p2}, {r1, r2}, m,            \
 	 {a1, a2, a3}, {{im1, 0}, {im2, 0}, {im3, 0}}, pr, clim, bev, col, in, intx, s1, s2, s3, {ai1, ai2, ai3, ai4}, {ag1, ag2, ag3, ag4}, \
 	 sndc, snd, 0, 0, true, {INVALID_INDUSTRYTYPE, 0, NULL, NULL, INVALID_INDUSTRYTYPE}}
 	/* Format:
--- a/src/table/cargo_const.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/cargo_const.h	Wed Jan 09 18:11:12 2008 +0000
@@ -141,13 +141,23 @@
 		STR_002D_FIZZY_DRINKS,   STR_004D_FIZZY_DRINK,    STR_NOTHING,    STR_QUANTITY_FIZZY_DRINKS, STR_ABBREV_FIZZY_DRINKS,
 		SPR_CARGO_FIZZYDRINK,    CC_PIECE_GOODS ),
 
+	/* Void slot in temperate */
+	MK( 0xFF,    0,   1,  0, 5688,  0,  30, true,  TE_NONE,
+		STR_000E,                STR_002E,                STR_TONS,       STR_QUANTITY_NOTHING,      STR_ABBREV_NOTHING,
+		SPR_ASCII_SPACE,         CC_NOAVAILABLE ),
+
+	/* Void slot in arctic */
+	MK( 0xFF,    0, 184,  0, 5120,  9, 255, true,  TE_NONE,
+		STR_000E,                STR_002E,                STR_TONS,       STR_QUANTITY_NOTHING,      STR_ABBREV_NOTHING,
+		SPR_ASCII_SPACE,         CC_NOAVAILABLE ),
+
 };
 
 
 /* Table of which cargo types are available in each climate, by default */
 static const CargoLabel _default_climate_cargo[NUM_LANDSCAPE][12] = {
-	{ 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'GRAI', 'WOOD', 'IORE', 'STEL', 'VALU', 'VOID', },
-	{ 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'WHEA', 'WOOD', 'VOID', 'PAPR', 'GOLD', 'FOOD', },
+	{ 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'GRAI', 'WOOD', 'IORE', 'STEL', 'VALU',     33, },
+	{ 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'WHEA', 'WOOD',     34, 'PAPR', 'GOLD', 'FOOD', },
 	{ 'PASS', 'RUBR', 'MAIL',      4, 'FRUT', 'GOOD', 'MAIZ',     11, 'CORE', 'WATR', 'DIAM', 'FOOD', },
 	{ 'PASS', 'SUGR', 'MAIL', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', },
 };
--- a/src/table/engines.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/engines.h	Wed Jan 09 18:11:12 2008 +0000
@@ -7,8 +7,6 @@
  *  This file contains all the data for vehicles
  */
 
-#include "../sound.h"
-
 /** Writes the properties of a train or road vehicle into the EngineInfo struct.
  * @see EngineInfo
  * @param a Introduction date
@@ -63,7 +61,7 @@
 #define A 2
 #define S 4
 #define Y 8
-const EngineInfo orig_engine_info[] = {
+const EngineInfo _orig_engine_info[] = {
 	MK(  1827,  20,  15,  30, T      ), /*   0 Kirby Paul Tank (Steam) */
 	MK( 12784,  20,  22,  30,   A|S  ), /*   1 MJS 250 (Diesel) */
 	MK(  9497,  20,  20,  50,       Y), /*   2 Ploddyphut Choo-Choo */
@@ -364,7 +362,7 @@
 #define O RAILTYPE_MONO
 #define L RAILTYPE_MAGLEV
 
-const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES] = {
+const RailVehicleInfo _orig_rail_vehicle_info[NUM_TRAIN_ENGINES] = {
 	//   image_index  max_speed (kph)      running_cost_base           ai_rank
 	//   |  flags     |        power (hp)  |  running_cost_class       |  railtype
 	//   |  |    base_cost     |    weight |  |   capacity             |  |
@@ -513,7 +511,7 @@
  * @param h refittable
  */
 #define SVI(a, b, c, d, e, f, g, h) { a, b, c, d, e, f, {g}, h }
-const ShipVehicleInfo orig_ship_vehicle_info[NUM_SHIP_ENGINES] = {
+const ShipVehicleInfo _orig_ship_vehicle_info[NUM_SHIP_ENGINES] = {
 	//   image_index  cargo_type     cargo_amount                 refittable
 	//   |    base_cost |              |    running_cost          |
 	//   |    |    max_speed           |    |  sfx                |
@@ -548,7 +546,7 @@
 #define H AIR_HELI
 #define P AIR_CTOL
 #define J AIR_CTOL | AIR_FAST
-const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES] = {
+const AircraftVehicleInfo _orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES] = {
 	//    image_index         sfx                         acceleration
 	//    |   base_cost       |                           |   max_speed
 	//    |   |    running_cost                           |   |    mail_capacity
@@ -612,7 +610,7 @@
  * @param g cargo_type
  */
 #define ROV(a, b, c, d, e, f, g) { a, b, c, {d}, e, f, g }
-const RoadVehicleInfo orig_road_vehicle_info[NUM_ROAD_ENGINES] = {
+const RoadVehicleInfo _orig_road_vehicle_info[NUM_ROAD_ENGINES] = {
 	//    image_index       sfx                                 max_speed
 	//    |    base_cost    |                                   |   capacity
 	//    |    |    running_cost                                |   |  cargo_type
--- a/src/table/files.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/files.h	Wed Jan 09 18:11:12 2008 +0000
@@ -34,7 +34,7 @@
 	},
 	{ "SAMPLE.CAT",    {0x42, 0x2e, 0xa3, 0xdd, 0x07, 0x4d, 0x28, 0x59, 0xbb, 0x51, 0x63, 0x9a, 0x6e, 0x0e, 0x85, 0xda} },
 	{ "CHARS.GRF",     {0x5f, 0x2e, 0xbf, 0x05, 0xb6, 0x12, 0x65, 0x81, 0xd2, 0x10, 0xa9, 0x19, 0x62, 0x41, 0x70, 0x64} },
-	{ "OPENTTDD.GRF",  {0x4a, 0x9e, 0x0d, 0x41, 0x9e, 0x66, 0x13, 0x17, 0xb9, 0x61, 0x81, 0xc7, 0xca, 0xef, 0x6b, 0xdc} }
+	{ "OPENTTDD.GRF",  {0x9a, 0x26, 0xc9, 0xd1, 0xa2, 0x39, 0xb8, 0xaa, 0x57, 0xac, 0x0f, 0xf0, 0xe4, 0x4b, 0x37, 0xb2} }
 };
 
 static FileList files_win = {
@@ -48,5 +48,5 @@
 	},
 	{ "SAMPLE.CAT",    {0x92, 0x12, 0xe8, 0x1e, 0x72, 0xba, 0xdd, 0x4b, 0xbe, 0x1e, 0xae, 0xae, 0x66, 0x45, 0x8e, 0x10} },
 	{ "CHARS.GRF",     {0x5f, 0x2e, 0xbf, 0x05, 0xb6, 0x12, 0x65, 0x81, 0xd2, 0x10, 0xa9, 0x19, 0x62, 0x41, 0x70, 0x64} },
-	{ "OPENTTDW.GRF",  {0xe7, 0xe5, 0x4a, 0x12, 0x5c, 0xec, 0x46, 0x53, 0x1d, 0x37, 0x0a, 0xf4, 0x69, 0xf7, 0x4a, 0x9c} }
+	{ "OPENTTDW.GRF",  {0xa1, 0x9c, 0xaa, 0xfc, 0x6b, 0xd2, 0x09, 0xc3, 0xd4, 0x84, 0x33, 0x43, 0x3f, 0xd1, 0xbd, 0xd5} }
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/table/railtypes.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,226 @@
+/* $Id$ */
+
+/** @file railtypes.h
+ * All the railtype-specific information is stored here.
+ */
+
+#ifndef RAILTYPES_H
+#define RAILTYPES_H
+
+/** Global Railtype definition
+ */
+RailtypeInfo _railtypes[] = {
+	/** Railway */
+	{ /* Main Sprites */
+		{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,
+			SPR_RAIL_SINGLE_NORTH, SPR_RAIL_SINGLE_SOUTH, SPR_RAIL_SINGLE_EAST, SPR_RAIL_SINGLE_WEST,
+			SPR_CROSSING_OFF_X_RAIL,
+			SPR_TUNNEL_ENTRY_REAR_RAIL
+		},
+
+		/* GUI sprites */
+		{ 0x4E3, 0x4E4, 0x4E5, 0x4E6,
+			SPR_IMG_AUTORAIL,
+			SPR_IMG_DEPOT_RAIL,
+			SPR_IMG_TUNNEL_RAIL,
+			SPR_IMG_CONVERT_RAIL
+		},
+
+		{
+			SPR_CURSOR_NS_TRACK,
+			SPR_CURSOR_SWNE_TRACK,
+			SPR_CURSOR_EW_TRACK,
+			SPR_CURSOR_NWSE_TRACK,
+			SPR_CURSOR_AUTORAIL,
+			SPR_CURSOR_RAIL_DEPOT,
+			SPR_CURSOR_TUNNEL_RAIL,
+			SPR_CURSOR_CONVERT_RAIL
+		},
+
+		/* strings */
+		{ STR_100A_RAILROAD_CONSTRUCTION },
+
+		/* Offset of snow tiles */
+		SPR_RAIL_SNOW_OFFSET,
+
+		/* Powered railtypes */
+		1 << RAILTYPE_RAIL | 1 << RAILTYPE_ELECTRIC,
+
+		/* Compatible railtypes */
+		1 << RAILTYPE_RAIL | 1 << RAILTYPE_ELECTRIC,
+
+		/* main offset */
+		0,
+
+		/* bridge offset */
+		0,
+
+		/* custom ground offset */
+		0,
+
+		/* curve speed advantage (multiplier) */
+		0,
+	},
+
+	/** Electrified railway */
+	{ /* Main Sprites */
+		{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,
+			SPR_RAIL_SINGLE_NORTH, SPR_RAIL_SINGLE_SOUTH, SPR_RAIL_SINGLE_EAST, SPR_RAIL_SINGLE_WEST,
+			SPR_CROSSING_OFF_X_RAIL,
+			SPR_TUNNEL_ENTRY_REAR_RAIL
+		},
+
+		/* GUI sprites */
+		{
+			SPR_BUILD_NS_ELRAIL,
+			SPR_BUILD_X_ELRAIL,
+			SPR_BUILD_EW_ELRAIL,
+			SPR_BUILD_Y_ELRAIL,
+			SPR_IMG_AUTOELRAIL,
+			SPR_IMG_DEPOT_ELRAIL,
+			SPR_BUILD_TUNNEL_ELRAIL,
+			SPR_IMG_CONVERT_ELRAIL
+		},
+
+		{
+			SPR_CURSOR_NS_ELRAIL,
+			SPR_CURSOR_SWNE_ELRAIL,
+			SPR_CURSOR_EW_ELRAIL,
+			SPR_CURSOR_NWSE_ELRAIL,
+			SPR_CURSOR_AUTOELRAIL,
+			SPR_CURSOR_ELRAIL_DEPOT,
+			SPR_CURSOR_TUNNEL_ELRAIL,
+			SPR_CURSOR_CONVERT_ELRAIL
+		},
+
+		/* strings */
+		{ STR_TITLE_ELRAIL_CONSTRUCTION },
+
+		/* Offset of snow tiles */
+		SPR_RAIL_SNOW_OFFSET,
+
+		/* Powered railtypes */
+		1 << RAILTYPE_ELECTRIC,
+
+		/* Compatible railtypes */
+		1 << RAILTYPE_ELECTRIC | 1 << RAILTYPE_RAIL,
+
+		/* main offset */
+		0,
+
+		/* bridge offset */
+		0,
+
+		/* custom ground offset */
+		0,
+
+		/* curve speed advantage (multiplier) */
+		0,
+	},
+
+	/** Monorail */
+	{ /* Main Sprites */
+		{ SPR_MONO_TRACK_Y, SPR_MONO_TRACK_N_S, SPR_MONO_TRACK_BASE, SPR_MONO_SINGLE_Y, SPR_MONO_SINGLE_X,
+			SPR_MONO_SINGLE_NORTH, SPR_MONO_SINGLE_SOUTH, SPR_MONO_SINGLE_EAST, SPR_MONO_SINGLE_WEST,
+			SPR_CROSSING_OFF_X_MONO,
+			SPR_TUNNEL_ENTRY_REAR_MONO
+		},
+
+		/* GUI sprites */
+		{ 0x4E7, 0x4E8, 0x4E9, 0x4EA,
+			SPR_IMG_AUTOMONO,
+			SPR_IMG_DEPOT_MONO,
+			SPR_IMG_TUNNEL_MONO,
+			SPR_IMG_CONVERT_MONO
+		},
+
+		{
+			SPR_CURSOR_NS_MONO,
+			SPR_CURSOR_SWNE_MONO,
+			SPR_CURSOR_EW_MONO,
+			SPR_CURSOR_NWSE_MONO,
+			SPR_CURSOR_AUTOMONO,
+			SPR_CURSOR_MONO_DEPOT,
+			SPR_CURSOR_TUNNEL_MONO,
+			SPR_CURSOR_CONVERT_MONO
+		},
+
+		/* strings */
+		{ STR_100B_MONORAIL_CONSTRUCTION },
+
+		/* Offset of snow tiles */
+		SPR_MONO_SNOW_OFFSET,
+
+		/* Powered railtypes */
+		1 << RAILTYPE_MONO,
+
+		/* Compatible Railtypes */
+		1 << RAILTYPE_MONO,
+
+		/* main offset */
+		82,
+
+		/* bridge offset */
+		16,
+
+		/* custom ground offset */
+		1,
+
+		/* curve speed advantage (multiplier) */
+		1,
+	},
+
+	/** Maglev */
+	{ /* Main sprites */
+		{ SPR_MGLV_TRACK_Y, SPR_MGLV_TRACK_N_S, SPR_MGLV_TRACK_BASE, SPR_MGLV_SINGLE_Y, SPR_MGLV_SINGLE_X,
+			SPR_MGLV_SINGLE_NORTH, SPR_MGLV_SINGLE_SOUTH, SPR_MGLV_SINGLE_EAST, SPR_MGLV_SINGLE_WEST,
+			SPR_CROSSING_OFF_X_MAGLEV,
+			SPR_TUNNEL_ENTRY_REAR_MAGLEV
+		},
+
+		/* GUI sprites */
+		{ 0x4EB, 0x4EC, 0x4EE, 0x4ED,
+			SPR_IMG_AUTOMAGLEV,
+			SPR_IMG_DEPOT_MAGLEV,
+			SPR_IMG_TUNNEL_MAGLEV,
+			SPR_IMG_CONVERT_MAGLEV
+		},
+
+		{
+			SPR_CURSOR_NS_MAGLEV,
+			SPR_CURSOR_SWNE_MAGLEV,
+			SPR_CURSOR_EW_MAGLEV,
+			SPR_CURSOR_NWSE_MAGLEV,
+			SPR_CURSOR_AUTOMAGLEV,
+			SPR_CURSOR_MAGLEV_DEPOT,
+			SPR_CURSOR_TUNNEL_MAGLEV,
+			SPR_CURSOR_CONVERT_MAGLEV
+		},
+
+		/* strings */
+		{ STR_100C_MAGLEV_CONSTRUCTION },
+
+		/* Offset of snow tiles */
+		SPR_MGLV_SNOW_OFFSET,
+
+		/* Powered railtypes */
+		1 << RAILTYPE_MAGLEV,
+
+		/* Compatible Railtypes */
+		1 << RAILTYPE_MAGLEV,
+
+		/* main offset */
+		164,
+
+		/* bridge offset */
+		24,
+
+		/* custom ground offset */
+		2,
+
+		/* curve speed advantage (multiplier) */
+		2,
+	},
+};
+
+#endif /* RAILTYPES_H */
--- a/src/table/road_land.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/road_land.h	Wed Jan 09 18:11:12 2008 +0000
@@ -33,24 +33,24 @@
 };
 
 static const DrawTileSeqStruct _tram_depot_NE[] = {
-	TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x35 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 15, 16, 1)
+	TILE_SEQ_LINE((SPR_TRAMWAY_BASE + 0x35) | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 15, 16, 1)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _tram_depot_SE[] = {
 	TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x31, PAL_NONE, 0, 0, 1, 16)
-	TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x32 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 15, 0, 1, 16)
+	TILE_SEQ_LINE((SPR_TRAMWAY_BASE + 0x32) | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 15, 0, 1, 16)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _tram_depot_SW[] = {
 	TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x33, PAL_NONE, 0, 0, 16, 1)
-	TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x34 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 15, 16, 1)
+	TILE_SEQ_LINE((SPR_TRAMWAY_BASE + 0x34) | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 15, 16, 1)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _tram_depot_NW[] = {
-	TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x36 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 15, 0, 1, 16)
+	TILE_SEQ_LINE((SPR_TRAMWAY_BASE + 0x36) | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 15, 0, 1, 16)
 	TILE_SEQ_END()
 };
 
--- a/src/table/sprites.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/sprites.h	Wed Jan 09 18:11:12 2008 +0000
@@ -32,6 +32,8 @@
  * @todo Split the "Sprites" enum into smaller chunks and document them
  */
 
+#include "../gfx_type.h"
+
 enum Sprites {
 	SPR_SELECT_TILE  = 752,
 	SPR_DOT          = 774, // corner marker for lower/raise land
@@ -47,7 +49,7 @@
 
 	/* Extra graphic spritenumbers */
 	SPR_OPENTTD_BASE     = 4896,
-	OPENTTD_SPRITE_COUNT = 135,
+	OPENTTD_SPRITE_COUNT = 136,
 
 	/* Halftile-selection sprites */
 	SPR_HALFTILE_SELECTION_FLAT = SPR_OPENTTD_BASE,
@@ -139,7 +141,13 @@
 	SPR_2CCMAP_BASE   = SPR_ELRAIL_BASE + ELRAIL_SPRITE_COUNT,
 	TWOCCMAP_SPRITE_COUNT = 256,
 
-	SPR_AIRPORTX_BASE     = SPR_2CCMAP_BASE + TWOCCMAP_SPRITE_COUNT, // The sprites used for other airport angles
+	/* shore tiles - action 05-0D */
+	SPR_SHORE_BASE                  = SPR_2CCMAP_BASE + TWOCCMAP_SPRITE_COUNT,
+	SPR_SHORE_SPRITE_COUNT          = 18,
+	SPR_ORIGINALSHORE_START         = 4062,
+	SPR_ORIGINALSHORE_END           = 4069,
+
+	SPR_AIRPORTX_BASE     = SPR_SHORE_BASE + SPR_SHORE_SPRITE_COUNT, // The sprites used for other airport angles
 	SPR_NEWAIRPORT_TARMAC = SPR_AIRPORTX_BASE,
 	SPR_NSRUNWAY1         = SPR_AIRPORTX_BASE + 1,
 	SPR_NSRUNWAY2         = SPR_AIRPORTX_BASE + 2,
@@ -551,17 +559,6 @@
 	SPR_FARMLAND_STATE_7        = 4259,
 	SPR_FARMLAND_HAYPACKS       = 4278,
 
-	/* Shores */
-	SPR_NO_SHORE                = 0,  //used for tileh which have no shore
-	SPR_SHORE_TILEH_4           = 4062, // SLOPE_E
-	SPR_SHORE_TILEH_1           = 4063, // SLOPE_W
-	SPR_SHORE_TILEH_2           = 4064, // SLOPE_S
-	SPR_SHORE_TILEH_8           = 4065, // SLOPE_N
-	SPR_SHORE_TILEH_6           = 4066, // SLOPE_SE
-	SPR_SHORE_TILEH_12          = 4067, // SLOPE_NE
-	SPR_SHORE_TILEH_3           = 4068, // SLOPE_SW
-	SPR_SHORE_TILEH_9           = 4069, // SLOPE_NW
-
 	/* Water-related sprites */
 	SPR_SHIP_DEPOT_SE_FRONT     = 4070,
 	SPR_SHIP_DEPOT_SW_FRONT     = 4071,
@@ -1263,6 +1260,16 @@
 	SPR_IMG_RAIL_STATION = 1298,
 	SPR_IMG_RAIL_SIGNALS = 1291,
 
+	SPR_IMG_SIGNAL_ELECTRIC_NORM   = 1287,
+	SPR_IMG_SIGNAL_ELECTRIC_ENTRY  = SPR_SIGNALS_BASE +  12,
+	SPR_IMG_SIGNAL_ELECTRIC_EXIT   = SPR_SIGNALS_BASE +  28,
+	SPR_IMG_SIGNAL_ELECTRIC_COMBO  = SPR_SIGNALS_BASE +  44,
+	SPR_IMG_SIGNAL_SEMAPHORE_NORM  = SPR_SIGNALS_BASE +  60,
+	SPR_IMG_SIGNAL_SEMAPHORE_ENTRY = SPR_SIGNALS_BASE +  76,
+	SPR_IMG_SIGNAL_SEMAPHORE_EXIT  = SPR_SIGNALS_BASE +  92,
+	SPR_IMG_SIGNAL_SEMAPHORE_COMBO = SPR_SIGNALS_BASE + 108,
+	SPR_IMG_SIGNAL_CONVERT         = SPR_OPENTTD_BASE + 135,
+
 	SPR_IMG_TUNNEL_RAIL   = 2430,
 	SPR_IMG_TUNNEL_MONO   = 2431,
 	SPR_IMG_TUNNEL_MAGLEV = 2432,
@@ -1403,6 +1410,7 @@
 	TRANSPARENT_BIT = 31,       ///< toggles transparency in the sprite
 	RECOLOR_BIT = 30,           ///< toggles recoloring in the sprite
 	OFFSET_BIT = 29,
+	OPAQUE_BIT = 28,
 
 	PALETTE_WIDTH = 24,         ///< number of bits of the sprite containing the recolor palette
 	SPRITE_WIDTH = 24,          ///< number of bits for the sprite number
@@ -1418,7 +1426,8 @@
  */
 enum Modifiers {
 	SPRITE_MODIFIER_USE_OFFSET    = OFFSET_BIT,
-	SPRITE_MODIFIER_OPAQUE        = OFFSET_BIT,
+	/// Set when a sprite must not ever be displayed transparently
+	SPRITE_MODIFIER_OPAQUE        = OPAQUE_BIT,
 	///when a sprite is to be displayed transparently, this bit needs to be set.
 	PALETTE_MODIFIER_TRANSPARENT  = TRANSPARENT_BIT,
 	///this bit is set when a recoloring process is in action
--- a/src/table/station_land.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/station_land.h	Wed Jan 09 18:11:12 2008 +0000
@@ -1168,10 +1168,10 @@
 };
 
 static const DrawTileSprites _station_display_datas_dock[] = {
-	{ SPR_SHORE_TILEH_3,              PAL_NONE, _station_display_datas_76 },
-	{ SPR_SHORE_TILEH_9,              PAL_NONE, _station_display_datas_77 },
-	{ SPR_SHORE_TILEH_12,             PAL_NONE, _station_display_datas_78 },
-	{ SPR_SHORE_TILEH_6,              PAL_NONE, _station_display_datas_79 },
+	{ SPR_SHORE_BASE + SLOPE_SW,      PAL_NONE, _station_display_datas_76 },
+	{ SPR_SHORE_BASE + SLOPE_NW,      PAL_NONE, _station_display_datas_77 },
+	{ SPR_SHORE_BASE + SLOPE_NE,      PAL_NONE, _station_display_datas_78 },
+	{ SPR_SHORE_BASE + SLOPE_SE,      PAL_NONE, _station_display_datas_79 },
 	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_80 },
 	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_81 },
 };
--- a/src/table/tree_land.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/table/tree_land.h	Wed Jan 09 18:11:12 2008 +0000
@@ -154,42 +154,42 @@
 	{ { 0x794, PAL_NONE }, { 0x794, PAL_NONE }, { 0x75c, PAL_NONE }, { 0x71d, PAL_NONE } }, /* 125 */
 	{ { 0x794, PAL_NONE }, { 0x724, PAL_NONE }, { 0x794, PAL_NONE }, { 0x71d, PAL_NONE } }, /* 126 */
 	{ { 0x794, PAL_NONE }, { 0x794, PAL_NONE }, { 0x771, PAL_NONE }, { 0x78d, PAL_NONE } }, /* 127 */
-	{ { 0x79b, PALETTE_TO_RED }, { 0x79b, PALETTE_TO_PALE_GREEN }, { 0x79b, PALETTE_TO_MAUVE }, { 0x79b, PALETTE_TO_PURPLE } }, /* 128 */
-	{ { 0x79b, PAL_NONE }, { 0x79b, PALETTE_TO_GREY }, { 0x79b, PALETTE_TO_GREEN }, { 0x79b, PALETTE_TO_WHITE } }, /* 129 */
-	{ { 0x79b, PALETTE_TO_GREEN }, { 0x79b, PALETTE_TO_ORANGE }, { 0x79b, PALETTE_TO_PINK }, { 0x79b, PAL_NONE } }, /* 130 */
-	{ { 0x79b, PALETTE_TO_YELLOW }, { 0x79b, PALETTE_TO_RED }, { 0x79b, PALETTE_TO_CREAM }, { 0x79b, PALETTE_TO_RED } }, /* 131 */
-	{ { 0x7a2, PAL_NONE }, { 0x7a2, PALETTE_TO_RED }, { 0x7a2, PALETTE_TO_PINK }, { 0x7a2, PALETTE_TO_PURPLE } }, /* 132 */
-	{ { 0x7a2, PALETTE_TO_MAUVE }, { 0x7a2, PALETTE_TO_GREEN }, { 0x7a2, PALETTE_TO_PINK }, { 0x7a2, PALETTE_TO_GREY } }, /* 133 */
-	{ { 0x7a2, PALETTE_TO_RED }, { 0x7a2, PALETTE_TO_PALE_GREEN }, { 0x7a2, PALETTE_TO_YELLOW }, { 0x7a2, PALETTE_TO_WHITE } }, /* 134 */
-	{ { 0x7a2, PALETTE_TO_ORANGE }, { 0x7a2, PALETTE_TO_MAUVE }, { 0x7a2, PALETTE_TO_CREAM }, { 0x7a2, PALETTE_TO_BROWN } }, /* 135 */
-	{ { 0x7a9, PALETTE_TO_RED }, { 0x7a9, PAL_NONE }, { 0x7a9, PALETTE_TO_ORANGE }, { 0x7a9, PALETTE_TO_GREY } }, /* 136 */
-	{ { 0x7a9, PALETTE_TO_ORANGE }, { 0x7a9, PALETTE_TO_GREEN }, { 0x7a9, PALETTE_TO_PALE_GREEN }, { 0x7a9, PALETTE_TO_MAUVE } }, /* 137 */
-	{ { 0x7a9, PALETTE_TO_PINK }, { 0x7a9, PALETTE_TO_RED }, { 0x7a9, PALETTE_TO_GREEN }, { 0x7a9, PALETTE_TO_BROWN } }, /* 138 */
-	{ { 0x7a9, PALETTE_TO_GREEN }, { 0x7a9, PAL_NONE }, { 0x7a9, PALETTE_TO_RED }, { 0x7a9, PALETTE_TO_CREAM } }, /* 139 */
-	{ { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE } }, /* 140 */
-	{ { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE } }, /* 141 */
-	{ { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE } }, /* 142 */
-	{ { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE }, { 0x7b0, PAL_NONE } }, /* 143 */
-	{ { 0x7b7, PALETTE_TO_PINK }, { 0x7b7, PALETTE_TO_RED }, { 0x7b7, PALETTE_TO_ORANGE }, { 0x7b7, PALETTE_TO_MAUVE } }, /* 144 */
-	{ { 0x7b7, PALETTE_TO_RED }, { 0x7b7, PAL_NONE }, { 0x7b7, PALETTE_TO_GREY }, { 0x7b7, PALETTE_TO_CREAM } }, /* 145 */
-	{ { 0x7b7, PALETTE_TO_GREEN }, { 0x7b7, PALETTE_TO_BROWN }, { 0x7b7, PALETTE_TO_PINK }, { 0x7b7, PALETTE_TO_RED } }, /* 146 */
-	{ { 0x7b7, PAL_NONE }, { 0x7b7, PALETTE_TO_PALE_GREEN }, { 0x7b7, PALETTE_TO_ORANGE }, { 0x7b7, PALETTE_TO_RED } }, /* 147 */
-	{ { 0x7be, PALETTE_TO_RED }, { 0x7be, PALETTE_TO_PINK }, { 0x7be, PALETTE_TO_GREEN }, { 0x7be, PAL_NONE } }, /* 148 */
-	{ { 0x7be, PALETTE_TO_GREEN }, { 0x7be, PALETTE_TO_BROWN }, { 0x7be, PALETTE_TO_PURPLE }, { 0x7be, PALETTE_TO_GREY } }, /* 149 */
-	{ { 0x7be, PALETTE_TO_MAUVE }, { 0x7be, PALETTE_TO_CREAM }, { 0x7be, PALETTE_TO_ORANGE }, { 0x7be, PALETTE_TO_RED } }, /* 150 */
-	{ { 0x7be, PAL_NONE }, { 0x7be, PALETTE_TO_RED }, { 0x7be, PALETTE_TO_PALE_GREEN }, { 0x7be, PALETTE_TO_PINK } }, /* 151 */
-	{ { 0x7c5, PALETTE_TO_YELLOW }, { 0x7c5, PALETTE_TO_RED }, { 0x7c5, PALETTE_TO_WHITE }, { 0x7c5, PALETTE_TO_CREAM } }, /* 152 */
-	{ { 0x7c5, PALETTE_TO_RED }, { 0x7c5, PALETTE_TO_PALE_GREEN }, { 0x7c5, PALETTE_TO_BROWN }, { 0x7c5, PALETTE_TO_YELLOW } }, /* 153 */
-	{ { 0x7c5, PAL_NONE }, { 0x7c5, PALETTE_TO_PURPLE }, { 0x7c5, PALETTE_TO_GREEN }, { 0x7c5, PALETTE_TO_YELLOW } }, /* 154 */
-	{ { 0x7c5, PALETTE_TO_PINK }, { 0x7c5, PALETTE_TO_CREAM }, { 0x7c5, PAL_NONE }, { 0x7c5, PALETTE_TO_GREY } }, /* 155 */
-	{ { 0x7cc, PALETTE_TO_YELLOW }, { 0x7cc, PALETTE_TO_GREY }, { 0x7cc, PALETTE_TO_PURPLE }, { 0x7cc, PALETTE_TO_BROWN } }, /* 156 */
-	{ { 0x7cc, PALETTE_TO_GREEN }, { 0x7cc, PAL_NONE }, { 0x7cc, PALETTE_TO_CREAM }, { 0x7cc, PALETTE_TO_WHITE } }, /* 157 */
-	{ { 0x7cc, PALETTE_TO_RED }, { 0x7cc, PALETTE_TO_PALE_GREEN }, { 0x7cc, PALETTE_TO_MAUVE }, { 0x7cc, PALETTE_TO_RED } }, /* 158 */
-	{ { 0x7cc, PALETTE_TO_PINK }, { 0x7cc, PALETTE_TO_ORANGE }, { 0x7cc, PALETTE_TO_GREEN }, { 0x7cc, PALETTE_TO_YELLOW } }, /* 159 */
-	{ { 0x7d3, PALETTE_TO_RED }, { 0x7d3, PALETTE_TO_PINK }, { 0x7d3, PALETTE_TO_BROWN }, { 0x7d3, PALETTE_TO_WHITE } }, /* 160 */
-	{ { 0x7d3, PALETTE_TO_GREEN }, { 0x7d3, PALETTE_TO_ORANGE }, { 0x7d3, PALETTE_TO_GREY }, { 0x7d3, PALETTE_TO_MAUVE } }, /* 161 */
-	{ { 0x7d3, PALETTE_TO_YELLOW }, { 0x7d3, PALETTE_TO_PALE_GREEN }, { 0x7d3, PAL_NONE }, { 0x7d3, PALETTE_TO_CREAM } }, /* 162 */
-	{ { 0x7d3, PALETTE_TO_GREY }, { 0x7d3, PALETTE_TO_RED }, { 0x7d3, PALETTE_TO_WHITE }, { 0x7d3, PAL_NONE } }, /* 163 */
+	{ { 0x79b, PALETTE_TO_RED },    { 0x79b, PALETTE_TO_PALE_GREEN }, { 0x79b, PALETTE_TO_MAUVE },      { 0x79b, PALETTE_TO_PURPLE } }, /* 128 */
+	{ { 0x79b, PAL_NONE },          { 0x79b, PALETTE_TO_GREY },       { 0x79b, PALETTE_TO_GREEN },      { 0x79b, PALETTE_TO_WHITE } },  /* 129 */
+	{ { 0x79b, PALETTE_TO_GREEN },  { 0x79b, PALETTE_TO_ORANGE },     { 0x79b, PALETTE_TO_PINK },       { 0x79b, PAL_NONE } },          /* 130 */
+	{ { 0x79b, PALETTE_TO_YELLOW }, { 0x79b, PALETTE_TO_RED },        { 0x79b, PALETTE_TO_CREAM },      { 0x79b, PALETTE_TO_RED } },    /* 131 */
+	{ { 0x7a2, PAL_NONE },          { 0x7a2, PALETTE_TO_RED },        { 0x7a2, PALETTE_TO_PINK },       { 0x7a2, PALETTE_TO_PURPLE } }, /* 132 */
+	{ { 0x7a2, PALETTE_TO_MAUVE },  { 0x7a2, PALETTE_TO_GREEN },      { 0x7a2, PALETTE_TO_PINK },       { 0x7a2, PALETTE_TO_GREY } },   /* 133 */
+	{ { 0x7a2, PALETTE_TO_RED },    { 0x7a2, PALETTE_TO_PALE_GREEN }, { 0x7a2, PALETTE_TO_YELLOW },     { 0x7a2, PALETTE_TO_WHITE } },  /* 134 */
+	{ { 0x7a2, PALETTE_TO_ORANGE }, { 0x7a2, PALETTE_TO_MAUVE },      { 0x7a2, PALETTE_TO_CREAM },      { 0x7a2, PALETTE_TO_BROWN } },  /* 135 */
+	{ { 0x7a9, PALETTE_TO_RED },    { 0x7a9, PAL_NONE },              { 0x7a9, PALETTE_TO_ORANGE },     { 0x7a9, PALETTE_TO_GREY } },   /* 136 */
+	{ { 0x7a9, PALETTE_TO_ORANGE }, { 0x7a9, PALETTE_TO_GREEN },      { 0x7a9, PALETTE_TO_PALE_GREEN }, { 0x7a9, PALETTE_TO_MAUVE } },  /* 137 */
+	{ { 0x7a9, PALETTE_TO_PINK },   { 0x7a9, PALETTE_TO_RED },        { 0x7a9, PALETTE_TO_GREEN },      { 0x7a9, PALETTE_TO_BROWN } },  /* 138 */
+	{ { 0x7a9, PALETTE_TO_GREEN },  { 0x7a9, PAL_NONE },              { 0x7a9, PALETTE_TO_RED },        { 0x7a9, PALETTE_TO_CREAM } },  /* 139 */
+	{ { 0x7b0, PAL_NONE },          { 0x7b0, PAL_NONE },              { 0x7b0, PAL_NONE },              { 0x7b0, PAL_NONE } },          /* 140 */
+	{ { 0x7b0, PAL_NONE },          { 0x7b0, PAL_NONE },              { 0x7b0, PAL_NONE },              { 0x7b0, PAL_NONE } },          /* 141 */
+	{ { 0x7b0, PAL_NONE },          { 0x7b0, PAL_NONE },              { 0x7b0, PAL_NONE },              { 0x7b0, PAL_NONE } },          /* 142 */
+	{ { 0x7b0, PAL_NONE },          { 0x7b0, PAL_NONE },              { 0x7b0, PAL_NONE },              { 0x7b0, PAL_NONE } },          /* 143 */
+	{ { 0x7b7, PALETTE_TO_PINK },   { 0x7b7, PALETTE_TO_RED },        { 0x7b7, PALETTE_TO_ORANGE },     { 0x7b7, PALETTE_TO_MAUVE } },  /* 144 */
+	{ { 0x7b7, PALETTE_TO_RED },    { 0x7b7, PAL_NONE },              { 0x7b7, PALETTE_TO_GREY },       { 0x7b7, PALETTE_TO_CREAM } },  /* 145 */
+	{ { 0x7b7, PALETTE_TO_GREEN },  { 0x7b7, PALETTE_TO_BROWN },      { 0x7b7, PALETTE_TO_PINK },       { 0x7b7, PALETTE_TO_RED } },    /* 146 */
+	{ { 0x7b7, PAL_NONE },          { 0x7b7, PALETTE_TO_PALE_GREEN }, { 0x7b7, PALETTE_TO_ORANGE },     { 0x7b7, PALETTE_TO_RED } },    /* 147 */
+	{ { 0x7be, PALETTE_TO_RED },    { 0x7be, PALETTE_TO_PINK },       { 0x7be, PALETTE_TO_GREEN },      { 0x7be, PAL_NONE } },          /* 148 */
+	{ { 0x7be, PALETTE_TO_GREEN },  { 0x7be, PALETTE_TO_BROWN },      { 0x7be, PALETTE_TO_PURPLE },     { 0x7be, PALETTE_TO_GREY } },   /* 149 */
+	{ { 0x7be, PALETTE_TO_MAUVE },  { 0x7be, PALETTE_TO_CREAM },      { 0x7be, PALETTE_TO_ORANGE },     { 0x7be, PALETTE_TO_RED } },    /* 150 */
+	{ { 0x7be, PAL_NONE },          { 0x7be, PALETTE_TO_RED },        { 0x7be, PALETTE_TO_PALE_GREEN }, { 0x7be, PALETTE_TO_PINK } },   /* 151 */
+	{ { 0x7c5, PALETTE_TO_YELLOW }, { 0x7c5, PALETTE_TO_RED },        { 0x7c5, PALETTE_TO_WHITE },      { 0x7c5, PALETTE_TO_CREAM } },  /* 152 */
+	{ { 0x7c5, PALETTE_TO_RED },    { 0x7c5, PALETTE_TO_PALE_GREEN }, { 0x7c5, PALETTE_TO_BROWN },      { 0x7c5, PALETTE_TO_YELLOW } }, /* 153 */
+	{ { 0x7c5, PAL_NONE },          { 0x7c5, PALETTE_TO_PURPLE },     { 0x7c5, PALETTE_TO_GREEN },      { 0x7c5, PALETTE_TO_YELLOW } }, /* 154 */
+	{ { 0x7c5, PALETTE_TO_PINK },   { 0x7c5, PALETTE_TO_CREAM },      { 0x7c5, PAL_NONE },              { 0x7c5, PALETTE_TO_GREY } },   /* 155 */
+	{ { 0x7cc, PALETTE_TO_YELLOW }, { 0x7cc, PALETTE_TO_GREY },       { 0x7cc, PALETTE_TO_PURPLE },     { 0x7cc, PALETTE_TO_BROWN } },  /* 156 */
+	{ { 0x7cc, PALETTE_TO_GREEN },  { 0x7cc, PAL_NONE },              { 0x7cc, PALETTE_TO_CREAM },      { 0x7cc, PALETTE_TO_WHITE } },  /* 157 */
+	{ { 0x7cc, PALETTE_TO_RED },    { 0x7cc, PALETTE_TO_PALE_GREEN }, { 0x7cc, PALETTE_TO_MAUVE },      { 0x7cc, PALETTE_TO_RED } },    /* 158 */
+	{ { 0x7cc, PALETTE_TO_PINK },   { 0x7cc, PALETTE_TO_ORANGE },     { 0x7cc, PALETTE_TO_GREEN },      { 0x7cc, PALETTE_TO_YELLOW } }, /* 159 */
+	{ { 0x7d3, PALETTE_TO_RED },    { 0x7d3, PALETTE_TO_PINK },       { 0x7d3, PALETTE_TO_BROWN },      { 0x7d3, PALETTE_TO_WHITE } },  /* 160 */
+	{ { 0x7d3, PALETTE_TO_GREEN },  { 0x7d3, PALETTE_TO_ORANGE },     { 0x7d3, PALETTE_TO_GREY },       { 0x7d3, PALETTE_TO_MAUVE } },  /* 161 */
+	{ { 0x7d3, PALETTE_TO_YELLOW }, { 0x7d3, PALETTE_TO_PALE_GREEN }, { 0x7d3, PAL_NONE },              { 0x7d3, PALETTE_TO_CREAM } },  /* 162 */
+	{ { 0x7d3, PALETTE_TO_GREY },   { 0x7d3, PALETTE_TO_RED },        { 0x7d3, PALETTE_TO_WHITE },      { 0x7d3, PAL_NONE } },          /* 163 */
 	/* the extra things follow */
 	{ { 0x6e5, PAL_NONE }, { 0x6e5, PAL_NONE }, { 0x6e5, PAL_NONE }, { 0x6e5, PAL_NONE } }, /* 0 */
 	{ { 0x6e5, PAL_NONE }, { 0x6e5, PAL_NONE }, { 0x6fa, PAL_NONE }, { 0x708, PAL_NONE } }, /* 1 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/terraform_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,407 @@
+/* $Id$ */
+
+/** @file terraform_cmd.cpp Commands related to terraforming. */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "strings_type.h"
+#include "table/strings.h"
+#include "command_func.h"
+#include "tile_map.h"
+#include "tunnel_map.h"
+#include "bridge_map.h"
+#include "variables.h"
+#include "functions.h"
+#include "economy_func.h"
+
+/*
+ * In one terraforming command all four corners of a initial tile can be raised/lowered (though this is not available to the player).
+ * The maximal amount of height modifications is archieved when raising a complete flat land from sea level to MAX_TILE_HEIGHT or vice versa.
+ * This affects all corners with a manhatten distance smaller than MAX_TILE_HEIGHT to one of the initial 4 corners.
+ * Their maximal amount is computed to 4 * \sum_{i=1}^{h_max} i  =  2 * h_max * (h_max + 1).
+ */
+static const int TERRAFORMER_MODHEIGHT_SIZE = 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 1);
+
+/*
+ * The maximal amount of affected tiles (i.e. the tiles that incident with one of the corners above, is computed similiar to
+ * 1 + 4 * \sum_{i=1}^{h_max} (i+1)  =  1 + 2 * h_max + (h_max + 3).
+ */
+static const int TERRAFORMER_TILE_TABLE_SIZE = 1 + 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 3);
+
+struct TerraformerHeightMod {
+	TileIndex tile;   ///< Referenced tile.
+	byte height;      ///< New TileHeight (height of north corner) of the tile.
+};
+
+struct TerraformerState {
+	int modheight_count;                                         ///< amount of entries in "modheight".
+	int tile_table_count;                                        ///< amount of entries in "tile_table".
+
+	/**
+	 * Dirty tiles, i.e.\ at least one corner changed.
+	 *
+	 * This array contains the tiles which are or will be marked as dirty.
+	 *
+	 * @ingroup dirty
+	 */
+	TileIndex tile_table[TERRAFORMER_TILE_TABLE_SIZE];
+	TerraformerHeightMod modheight[TERRAFORMER_MODHEIGHT_SIZE];  ///< Height modifications.
+};
+
+TileIndex _terraform_err_tile;
+
+/**
+ * Gets the TileHeight (height of north corner) of a tile as of current terraforming progress.
+ *
+ * @param ts TerraformerState.
+ * @param tile Tile.
+ * @return TileHeight.
+ */
+static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile)
+{
+	TerraformerHeightMod *mod = ts->modheight;
+	int count;
+
+	for (count = ts->modheight_count; count != 0; count--, mod++) {
+		if (mod->tile == tile) return mod->height;
+	}
+
+	/* TileHeight unchanged so far, read value from map. */
+	return TileHeight(tile);
+}
+
+/**
+ * Stores the TileHeight (height of north corner) of a tile in a TerraformerState.
+ *
+ * @param ts TerraformerState.
+ * @param tile Tile.
+ * @param height New TileHeight.
+ */
+static void TerraformSetHeightOfTile(TerraformerState *ts, TileIndex tile, int height)
+{
+	/* Find tile in the "modheight" table.
+	 * Note: In a normal user-terraform command the tile will not be found in the "modheight" table.
+	 *       But during house- or industry-construction multiple corners can be terraformed at once. */
+	TerraformerHeightMod *mod = ts->modheight;
+	int count = ts->modheight_count;
+	while ((count > 0) && (mod->tile != tile)) {
+		mod++;
+		count--;
+	}
+
+	/* New entry? */
+	if (count == 0) {
+		assert(ts->modheight_count < TERRAFORMER_MODHEIGHT_SIZE);
+		ts->modheight_count++;
+	}
+
+	/* Finally store the new value */
+	mod->tile = tile;
+	mod->height = (byte)height;
+}
+
+/**
+ * Adds a tile to the "tile_table" in a TerraformerState.
+ *
+ * @param ts TerraformerState.
+ * @param tile Tile.
+ * @ingroup dirty
+ */
+static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
+{
+	int count;
+	TileIndex *t;
+
+	count = ts->tile_table_count;
+
+	for (t = ts->tile_table; count != 0; count--, t++) {
+		if (*t == tile) return;
+	}
+
+	assert(ts->tile_table_count < TERRAFORMER_TILE_TABLE_SIZE);
+
+	ts->tile_table[ts->tile_table_count++] = tile;
+}
+
+/**
+ * Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState.
+ *
+ * @param ts TerraformerState.
+ * @param tile Tile.
+ * @ingroup dirty
+ */
+static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile)
+{
+	TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1));
+	TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1));
+	TerraformAddDirtyTile(ts, tile + TileDiffXY(-1,  0));
+	TerraformAddDirtyTile(ts, tile);
+}
+
+/**
+ * Terraform the north corner of a tile to a specific height.
+ *
+ * @param ts TerraformerState.
+ * @param tile Tile.
+ * @param height Aimed height.
+ * @param return Error code or cost.
+ */
+static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
+{
+	CommandCost total_cost(EXPENSES_CONSTRUCTION);
+
+	assert(tile < MapSize());
+
+	/* Check range of destination height */
+	if (height < 0) return_cmd_error(STR_1003_ALREADY_AT_SEA_LEVEL);
+	if (height > MAX_TILE_HEIGHT) return_cmd_error(STR_1004_TOO_HIGH);
+
+	/*
+	 * Check if the terraforming has any effect.
+	 * This can only be true, if multiple corners of the start-tile are terraformed (i.e. the terraforming is done by towns/industries etc.).
+	 * In this case the terraforming should fail. (Don't know why.)
+	 */
+	if (height == TerraformGetHeightOfTile(ts, tile)) return CMD_ERROR;
+
+	/* Check "too close to edge of map" */
+	uint x = TileX(tile);
+	uint y = TileY(tile);
+	if ((x <= 1) || (y <= 1) || (x >= MapMaxX() - 1) || (y >= MapMaxY() - 1)) {
+		/*
+		 * Determine a sensible error tile
+		 * Note: If x and y are both zero this will disable the error tile. (Tile 0 cannot be highlighted :( )
+		 */
+		if ((x == 1) && (y != 0)) x = 0;
+		if ((y == 1) && (x != 0)) y = 0;
+		_terraform_err_tile = TileXY(x, y);
+		return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
+	}
+
+	/* Mark incident tiles, that are involved in the terraforming */
+	TerraformAddDirtyTileAround(ts, tile);
+
+	/* Store the height modification */
+	TerraformSetHeightOfTile(ts, tile, height);
+
+	/* Increment cost */
+	total_cost.AddCost(_price.terraform);
+
+	/* Recurse to neighboured corners if height difference is larger than 1 */
+	{
+		const TileIndexDiffC *ttm;
+
+		static const TileIndexDiffC _terraform_tilepos[] = {
+			{ 1,  0}, // move to tile in SE
+			{-2,  0}, // undo last move, and move to tile in NW
+			{ 1,  1}, // undo last move, and move to tile in SW
+			{ 0, -2}  // undo last move, and move to tile in NE
+		};
+
+		for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
+			tile += ToTileIndexDiff(*ttm);
+
+			/* Get TileHeight of neighboured tile as of current terraform progress */
+			int r = TerraformGetHeightOfTile(ts, tile);
+			int height_diff = height - r;
+
+			/* Is the height difference to the neighboured corner greater than 1? */
+			if (abs(height_diff) > 1) {
+				/* Terraform the neighboured corner. The resulting height difference should be 1. */
+				height_diff += (height_diff < 0 ? 1 : -1);
+				CommandCost cost = TerraformTileHeight(ts, tile, r + height_diff);
+				if (CmdFailed(cost)) return cost;
+				total_cost.AddCost(cost);
+			}
+		}
+	}
+
+	return total_cost;
+}
+
+/** Terraform land
+ * @param tile tile to terraform
+ * @param flags for this command type
+ * @param p1 corners to terraform (SLOPE_xxx)
+ * @param p2 direction; eg up (non-zero) or down (zero)
+ * @return error or cost of terraforming
+ */
+CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+{
+	TerraformerState ts;
+	CommandCost total_cost(EXPENSES_CONSTRUCTION);
+	int direction = (p2 != 0 ? 1 : -1);
+
+	_terraform_err_tile = 0;
+
+	ts.modheight_count = ts.tile_table_count = 0;
+
+	/* Make an extra check for map-bounds cause we add tiles to the originating tile */
+	if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;
+
+	/* Compute the costs and the terraforming result in a model of the landscape */
+	if ((p1 & SLOPE_W) != 0) {
+		TileIndex t = tile + TileDiffXY(1, 0);
+		CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
+		if (CmdFailed(cost)) return cost;
+		total_cost.AddCost(cost);
+	}
+
+	if ((p1 & SLOPE_S) != 0) {
+		TileIndex t = tile + TileDiffXY(1, 1);
+		CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
+		if (CmdFailed(cost)) return cost;
+		total_cost.AddCost(cost);
+	}
+
+	if ((p1 & SLOPE_E) != 0) {
+		TileIndex t = tile + TileDiffXY(0, 1);
+		CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
+		if (CmdFailed(cost)) return cost;
+		total_cost.AddCost(cost);
+	}
+
+	if ((p1 & SLOPE_N) != 0) {
+		TileIndex t = tile + TileDiffXY(0, 0);
+		CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
+		if (CmdFailed(cost)) return cost;
+		total_cost.AddCost(cost);
+	}
+
+	/* Check if the terraforming is valid wrt. tunnels, bridges and objects on the surface */
+	{
+		int count;
+		TileIndex *ti = ts.tile_table;
+
+		for (count = ts.tile_table_count; count != 0; count--, ti++) {
+			TileIndex tile = *ti;
+
+			/* Find new heights of tile corners */
+			uint z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
+			uint z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
+			uint z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
+			uint z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
+
+			/* Find min and max height of tile */
+			uint z_min = min(min(z_N, z_W), min(z_S, z_E));
+			uint z_max = max(max(z_N, z_W), max(z_S, z_E));
+
+			/* Compute tile slope */
+			uint tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT);
+			if (z_W > z_min) tileh += SLOPE_W;
+			if (z_S > z_min) tileh += SLOPE_S;
+			if (z_E > z_min) tileh += SLOPE_E;
+			if (z_N > z_min) tileh += SLOPE_N;
+
+			/* Check if bridge would take damage */
+			if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) &&
+					GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max * TILE_HEIGHT) {
+				_terraform_err_tile = tile; // highlight the tile under the bridge
+				return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
+			}
+			/* Check if tunnel would take damage */
+			if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) {
+				_terraform_err_tile = tile; // highlight the tile above the tunnel
+				return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
+			}
+			/* Check tiletype-specific things, and add extra-cost */
+			CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, (Slope) tileh);
+			if (CmdFailed(cost)) {
+				_terraform_err_tile = tile;
+				return cost;
+			}
+			total_cost.AddCost(cost);
+		}
+	}
+
+	if (flags & DC_EXEC) {
+		/* change the height */
+		{
+			int count;
+			TerraformerHeightMod *mod;
+
+			mod = ts.modheight;
+			for (count = ts.modheight_count; count != 0; count--, mod++) {
+				TileIndex til = mod->tile;
+
+				SetTileHeight(til, mod->height);
+			}
+		}
+
+		/* finally mark the dirty tiles dirty */
+		{
+			int count;
+			TileIndex *ti = ts.tile_table;
+			for (count = ts.tile_table_count; count != 0; count--, ti++) {
+				MarkTileDirtyByTile(*ti);
+			}
+		}
+	}
+	return total_cost;
+}
+
+
+/** Levels a selected (rectangle) area of land
+ * @param tile end tile of area-drag
+ * @param flags for this command type
+ * @param p1 start tile of area drag
+ * @param p2 height difference; eg raise (+1), lower (-1) or level (0)
+ * @return  error or cost of terraforming
+ */
+CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+{
+	int size_x, size_y;
+	int ex;
+	int ey;
+	int sx, sy;
+	uint h, oldh, curh;
+	CommandCost money;
+	CommandCost ret;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
+
+	if (p1 >= MapSize()) return CMD_ERROR;
+
+	/* remember level height */
+	oldh = TileHeight(p1);
+
+	/* compute new height */
+	h = oldh + p2;
+
+	/* Check range of destination height */
+	if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_1003_ALREADY_AT_SEA_LEVEL : STR_1004_TOO_HIGH);
+
+	/* make sure sx,sy are smaller than ex,ey */
+	ex = TileX(tile);
+	ey = TileY(tile);
+	sx = TileX(p1);
+	sy = TileY(p1);
+	if (ex < sx) Swap(ex, sx);
+	if (ey < sy) Swap(ey, sy);
+	tile = TileXY(sx, sy);
+
+	size_x = ex - sx + 1;
+	size_y = ey - sy + 1;
+
+	money.AddCost(GetAvailableMoneyForCommand());
+
+	BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
+		curh = TileHeight(tile2);
+		while (curh != h) {
+			ret = DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
+			if (CmdFailed(ret)) break;
+
+			if (flags & DC_EXEC) {
+				money.AddCost(-ret.GetCost());
+				if (money.GetCost() < 0) {
+					_additional_cash_required = ret.GetCost();
+					return cost;
+				}
+				DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
+			}
+
+			cost.AddCost(ret);
+			curh += (curh > h) ? -1 : 1;
+		}
+	} END_TILE_LOOP(tile2, size_x, size_y, tile)
+
+	return (cost.GetCost() == 0) ? CMD_ERROR : cost;
+}
--- a/src/terraform_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/terraform_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,24 +8,26 @@
 #include "clear_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
 #include "player.h"
-#include "tile.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
-#include "sound.h"
-#include "command.h"
-#include "vehicle.h"
+#include "window_gui.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
+#include "command_func.h"
 #include "signs.h"
 #include "variables.h"
+#include "functions.h"
+#include "sound_func.h"
+#include "station.h"
+#include "unmovable_map.h"
+#include "textbuf_gui.h"
 
 void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
 	if (success) {
 		SndPlayTileFx(SND_1F_SPLAT, tile);
 	} else {
+		extern TileIndex _terraform_err_tile;
 		SetRedErrorSquare(_terraform_err_tile);
 	}
 }
@@ -108,6 +110,12 @@
 		case DDSP_DEMOLISH_AREA:
 			DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
 			break;
+		case DDSP_RAISE_AND_LEVEL_AREA:
+			DoCommandP(end_tile, start_tile, 1, CcTerraform, CMD_LEVEL_LAND | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE));
+			break;
+		case DDSP_LOWER_AND_LEVEL_AREA:
+			DoCommandP(end_tile, start_tile, (uint32)-1, CcTerraform, CMD_LEVEL_LAND | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE));
+			break;
 		case DDSP_LEVEL_AREA:
 			DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND);
 			break;
@@ -146,18 +154,12 @@
 
 static void PlaceProc_RaiseLand(TileIndex tile)
 {
-	DoCommandP(
-		tile, SLOPE_N, 1, CcTerraform,
-		CMD_TERRAFORM_LAND | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE)
-	);
+	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_RAISE_AND_LEVEL_AREA);
 }
 
 static void PlaceProc_LowerLand(TileIndex tile)
 {
-	DoCommandP(
-		tile, SLOPE_N, 0, CcTerraform,
-		CMD_TERRAFORM_LAND | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE)
-	);
+	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LOWER_AND_LEVEL_AREA);
 }
 
 void PlaceProc_LevelLand(TileIndex tile)
@@ -247,6 +249,8 @@
 		if (e->we.place.pt.x != -1) {
 			switch (e->we.place.select_proc) {
 				case DDSP_DEMOLISH_AREA:
+				case DDSP_RAISE_AND_LEVEL_AREA:
+				case DDSP_LOWER_AND_LEVEL_AREA:
 				case DDSP_LEVEL_AREA:
 					GUIPlaceProcDragXY(e);
 					break;
@@ -255,7 +259,7 @@
 		break;
 
 	case WE_ABORT_PLACE_OBJ:
-		RaiseWindowButtons(w);
+		w->RaiseButtons();
 		break;
 	}
 }
@@ -299,3 +303,353 @@
 		SetWindowDirty(link);
 	}
 }
+
+static byte _terraform_size = 1;
+
+/**
+ * Raise/Lower a bigger chunk of land at the same time in the editor. When
+ * raising get the lowest point, when lowering the highest point, and set all
+ * tiles in the selection to that height.
+ * @todo : Incorporate into game itself to allow for ingame raising/lowering of
+ *         larger chunks at the same time OR remove altogether, as we have 'level land' ?
+ * @param tile The top-left tile where the terraforming will start
+ * @param mode 1 for raising, 0 for lowering land
+ */
+static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
+{
+	int sizex, sizey;
+	uint h;
+
+	_generating_world = true; // used to create green terraformed land
+
+	if (_terraform_size == 1) {
+		StringID msg =
+			mode ? STR_0808_CAN_T_RAISE_LAND_HERE : STR_0809_CAN_T_LOWER_LAND_HERE;
+
+		DoCommandP(tile, SLOPE_N, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_MSG(msg));
+	} else {
+		SndPlayTileFx(SND_1F_SPLAT, tile);
+
+		assert(_terraform_size != 0);
+		/* check out for map overflows */
+		sizex = min(MapSizeX() - TileX(tile) - 1, _terraform_size);
+		sizey = min(MapSizeY() - TileY(tile) - 1, _terraform_size);
+
+		if (sizex == 0 || sizey == 0) return;
+
+		if (mode != 0) {
+			/* Raise land */
+			h = 15; // XXX - max height
+			BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
+				h = min(h, TileHeight(tile2));
+			} END_TILE_LOOP(tile2, sizex, sizey, tile)
+		} else {
+			/* Lower land */
+			h = 0;
+			BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
+				h = max(h, TileHeight(tile2));
+			} END_TILE_LOOP(tile2, sizex, sizey, tile)
+		}
+
+		BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
+			if (TileHeight(tile2) == h) {
+				DoCommandP(tile2, SLOPE_N, (uint32)mode, NULL, CMD_TERRAFORM_LAND);
+			}
+		} END_TILE_LOOP(tile2, sizex, sizey, tile)
+	}
+
+	_generating_world = false;
+}
+
+static void PlaceProc_RaiseBigLand(TileIndex tile)
+{
+	CommonRaiseLowerBigLand(tile, 1);
+}
+
+static void PlaceProc_LowerBigLand(TileIndex tile)
+{
+	CommonRaiseLowerBigLand(tile, 0);
+}
+
+static void PlaceProc_RockyArea(TileIndex tile)
+{
+	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_ROCKS);
+}
+
+static void PlaceProc_LightHouse(TileIndex tile)
+{
+	if (!IsTileType(tile, MP_CLEAR) || IsSteepSlope(GetTileSlope(tile, NULL)) || IsBridgeAbove(tile)) {
+		return;
+	}
+
+	MakeLighthouse(tile);
+	MarkTileDirtyByTile(tile);
+	SndPlayTileFx(SND_1F_SPLAT, tile);
+}
+
+static void PlaceProc_Transmitter(TileIndex tile)
+{
+	if (!IsTileType(tile, MP_CLEAR) || IsSteepSlope(GetTileSlope(tile, NULL)) || IsBridgeAbove(tile)) {
+		return;
+	}
+
+	MakeTransmitter(tile);
+	MarkTileDirtyByTile(tile);
+	SndPlayTileFx(SND_1F_SPLAT, tile);
+}
+
+static void PlaceProc_DesertArea(TileIndex tile)
+{
+	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_DESERT);
+}
+
+static void PlaceProc_WaterArea(TileIndex tile)
+{
+	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_WATER);
+}
+
+static const Widget _scen_edit_land_gen_widgets[] = {
+{  WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                  STR_018B_CLOSE_WINDOW},
+{   WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0223_LAND_GENERATION,  STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_STICKYBOX,   RESIZE_NONE,     7,   170,   181,     0,    13, STR_NULL,                  STR_STICKY_BUTTON},
+{     WWT_PANEL,   RESIZE_NONE,     7,     0,   181,    14,   102, 0x0,                       STR_NULL},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,     2,    23,    16,    37, SPR_IMG_DYNAMITE,          STR_018D_DEMOLISH_BUILDINGS_ETC},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,    24,    45,    16,    37, SPR_IMG_TERRAFORM_DOWN,    STR_018E_LOWER_A_CORNER_OF_LAND},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,    46,    67,    16,    37, SPR_IMG_TERRAFORM_UP,      STR_018F_RAISE_A_CORNER_OF_LAND},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,    68,    89,    16,    37, SPR_IMG_LEVEL_LAND,        STR_LEVEL_LAND_TOOLTIP},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,    90,   111,    16,    37, SPR_IMG_BUILD_CANAL,       STR_CREATE_LAKE},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,   112,   134,    16,    37, SPR_IMG_ROCKS,             STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,   135,   157,    16,    37, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, // XXX - dynamic
+{    WWT_IMGBTN,   RESIZE_NONE,    14,   158,   179,    16,    37, SPR_IMG_TRANSMITTER,       STR_028E_PLACE_TRANSMITTER},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,   139,   150,    45,    56, SPR_ARROW_UP,              STR_0228_INCREASE_SIZE_OF_LAND_AREA},
+{    WWT_IMGBTN,   RESIZE_NONE,    14,   139,   150,    58,    69, SPR_ARROW_DOWN,            STR_0229_DECREASE_SIZE_OF_LAND_AREA},
+{   WWT_TEXTBTN,   RESIZE_NONE,    14,    24,   157,    76,    87, STR_SE_NEW_WORLD,          STR_022A_GENERATE_RANDOM_LAND},
+{   WWT_TEXTBTN,   RESIZE_NONE,    14,    24,   157,    89,   100, STR_022B_RESET_LANDSCAPE,  STR_RESET_LANDSCAPE_TOOLTIP},
+{   WIDGETS_END},
+};
+
+static const int8 _multi_terraform_coords[][2] = {
+	{  0, -2},
+	{  4,  0}, { -4,  0}, {  0,  2},
+	{ -8,  2}, { -4,  4}, {  0,  6}, {  4,  4}, {  8,  2},
+	{-12,  0}, { -8, -2}, { -4, -4}, {  0, -6}, {  4, -4}, {  8, -2}, { 12,  0},
+	{-16,  2}, {-12,  4}, { -8,  6}, { -4,  8}, {  0, 10}, {  4,  8}, {  8,  6}, { 12,  4}, { 16,  2},
+	{-20,  0}, {-16, -2}, {-12, -4}, { -8, -6}, { -4, -8}, {  0,-10}, {  4, -8}, {  8, -6}, { 12, -4}, { 16, -2}, { 20,  0},
+	{-24,  2}, {-20,  4}, {-16,  6}, {-12,  8}, { -8, 10}, { -4, 12}, {  0, 14}, {  4, 12}, {  8, 10}, { 12,  8}, { 16,  6}, { 20,  4}, { 24,  2},
+	{-28,  0}, {-24, -2}, {-20, -4}, {-16, -6}, {-12, -8}, { -8,-10}, { -4,-12}, {  0,-14}, {  4,-12}, {  8,-10}, { 12, -8}, { 16, -6}, { 20, -4}, { 24, -2}, { 28,  0},
+};
+
+/**
+ * @todo Merge with terraform_gui.cpp (move there) after I have cooled down at its braindeadness
+ * and changed OnButtonClick to include the widget as well in the function declaration. Post 0.4.0 - Darkvater
+ */
+static void EditorTerraformClick_Dynamite(Window *w)
+{
+	HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
+}
+
+static void EditorTerraformClick_LowerBigLand(Window *w)
+{
+	HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerBigLand);
+}
+
+static void EditorTerraformClick_RaiseBigLand(Window *w)
+{
+	HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseBigLand);
+}
+
+static void EditorTerraformClick_LevelLand(Window *w)
+{
+	HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
+}
+
+static void EditorTerraformClick_WaterArea(Window *w)
+{
+	HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, VHM_RECT, PlaceProc_WaterArea);
+}
+
+static void EditorTerraformClick_RockyArea(Window *w)
+{
+	HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, VHM_RECT, PlaceProc_RockyArea);
+}
+
+static void EditorTerraformClick_DesertLightHouse(Window *w)
+{
+	HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
+}
+
+static void EditorTerraformClick_Transmitter(Window *w)
+{
+	HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, VHM_RECT, PlaceProc_Transmitter);
+}
+
+static const uint16 _editor_terraform_keycodes[] = {
+	'D',
+	'Q',
+	'W',
+	'E',
+	'R',
+	'T',
+	'Y',
+	'U'
+};
+
+typedef void OnButtonClick(Window *w);
+static OnButtonClick * const _editor_terraform_button_proc[] = {
+	EditorTerraformClick_Dynamite,
+	EditorTerraformClick_LowerBigLand,
+	EditorTerraformClick_RaiseBigLand,
+	EditorTerraformClick_LevelLand,
+	EditorTerraformClick_WaterArea,
+	EditorTerraformClick_RockyArea,
+	EditorTerraformClick_DesertLightHouse,
+	EditorTerraformClick_Transmitter
+};
+
+
+/** Callback function for the scenario editor 'reset landscape' confirmation window
+ * @param w Window unused
+ * @param confirmed boolean value, true when yes was clicked, false otherwise */
+static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
+{
+	if (confirmed) {
+		Player *p;
+
+		/* Set generating_world to true to get instant-green grass after removing
+		 * player property. */
+		_generating_world = true;
+		/* Delete all players */
+		FOR_ALL_PLAYERS(p) {
+			if (p->is_active) {
+				ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
+				p->is_active = false;
+			}
+		}
+		_generating_world = false;
+
+		/* Delete all stations owned by a player */
+		Station *st;
+		FOR_ALL_STATIONS(st) {
+			if (IsValidPlayer(st->owner)) delete st;
+		}
+	}
+}
+
+static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
+{
+	switch (e->event) {
+		case WE_CREATE:
+			/* XXX - lighthouse button is widget 10!! Don't forget when changing */
+			w->widget[10].tooltips = (_opt.landscape == LT_TROPIC) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE;
+			break;
+
+		case WE_PAINT: {
+			DrawWindowWidgets(w);
+
+			int n = _terraform_size * _terraform_size;
+			const int8 *coords = &_multi_terraform_coords[0][0];
+
+			assert(n != 0);
+			do {
+				DrawSprite(SPR_WHITE_POINT, PAL_NONE, 77 + coords[0], 55 + coords[1]);
+				coords += 2;
+			} while (--n);
+
+			if (w->IsWidgetLowered(5) || w->IsWidgetLowered(6)) // change area-size if raise/lower corner is selected
+				SetTileSelectSize(_terraform_size, _terraform_size);
+
+		} break;
+
+		case WE_KEYPRESS:
+			for (uint i = 0; i != lengthof(_editor_terraform_keycodes); i++) {
+				if (e->we.keypress.keycode == _editor_terraform_keycodes[i]) {
+					e->we.keypress.cont = false;
+					_editor_terraform_button_proc[i](w);
+					break;
+				}
+			}
+			break;
+
+		case WE_CLICK:
+			switch (e->we.click.widget) {
+				case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11:
+					_editor_terraform_button_proc[e->we.click.widget - 4](w);
+					break;
+				case 12: case 13: { // Increase/Decrease terraform size
+					int size = (e->we.click.widget == 12) ? 1 : -1;
+					w->HandleButtonClick(e->we.click.widget);
+					size += _terraform_size;
+
+					if (!IsInsideMM(size, 1, 8 + 1)) return;
+					_terraform_size = size;
+
+					SndPlayFx(SND_15_BEEP);
+					SetWindowDirty(w);
+				} break;
+				case 14: // gen random land
+					w->HandleButtonClick(14);
+					ShowCreateScenario();
+					break;
+				case 15: // Reset landscape
+					ShowQuery(
+						STR_022C_RESET_LANDSCAPE,
+						STR_RESET_LANDSCAPE_CONFIRMATION_TEXT,
+						NULL,
+						ResetLandscapeConfirmationCallback);
+					break;
+			}
+			break;
+
+		case WE_TIMEOUT:
+			for (uint i = 0; i < w->widget_count; i++) {
+				if (w->IsWidgetLowered(i)) {
+					w->RaiseWidget(i);
+					w->InvalidateWidget(i);
+				}
+				if (i == 3) i = 11;
+			}
+			break;
+
+		case WE_PLACE_OBJ:
+			_place_proc(e->we.place.tile);
+			break;
+
+		case WE_PLACE_DRAG:
+			VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
+			break;
+
+		case WE_PLACE_MOUSEUP:
+			if (e->we.place.pt.x != -1) {
+				switch (e->we.place.select_proc) {
+					case DDSP_CREATE_ROCKS:
+					case DDSP_CREATE_DESERT:
+					case DDSP_CREATE_WATER:
+					case DDSP_RAISE_AND_LEVEL_AREA:
+					case DDSP_LOWER_AND_LEVEL_AREA:
+					case DDSP_LEVEL_AREA:
+					case DDSP_DEMOLISH_AREA:
+						GUIPlaceProcDragXY(e);
+						break;
+				}
+			}
+			break;
+
+		case WE_ABORT_PLACE_OBJ:
+			w->RaiseButtons();
+			SetWindowDirty(w);
+			break;
+	}
+}
+
+static const WindowDesc _scen_edit_land_gen_desc = {
+	WDP_AUTO, WDP_AUTO, 182, 103, 182, 103,
+	WC_SCEN_LAND_GEN, WC_NONE,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
+	_scen_edit_land_gen_widgets,
+	ScenEditLandGenWndProc,
+};
+
+void ShowEditorTerraformToolbar()
+{
+	AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/terraform_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,15 @@
+/* $Id$ */
+
+/** @file terraform_gui.h GUI stuff related to terraforming. */
+
+#ifndef TERRAFORM_GUI_H
+#define TERRAFORM_GUI_H
+
+#include "window_type.h"
+
+void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
+
+void ShowTerraformToolbar(Window *link = NULL);
+void ShowEditorTerraformToolbar();
+
+#endif /* GUI_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/textbuf_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,46 @@
+/* $Id$ */
+
+/** @file textbuf_gui.h Stuff related to the text buffer GUI. */
+
+#ifndef TEXTBUF_GUI_H
+#define TEXTBUF_GUI_H
+
+#include "window_type.h"
+#include "string_type.h"
+
+struct Textbuf {
+	char *buf;                  ///< buffer in which text is saved
+	uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes
+	uint16 length, width;       ///< the current size of the string. Width specifies screensize in pixels, length is in bytes
+	bool caret;                 ///< is the caret ("_") visible or not
+	uint16 caretpos;            ///< the current position of the caret in the buffer, in bytes
+	uint16 caretxoffs;          ///< the current position of the caret in pixels
+};
+
+struct querystr_d {
+	StringID caption;
+	Textbuf text;
+	const char *orig;
+	CharSetFilter afilter;
+	bool handled;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
+
+
+void DrawEditBox(Window *w, querystr_d *string, int wid);
+void HandleEditBox(Window *w, querystr_d *string, int wid);
+int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we);
+bool HandleCaret(Textbuf *tb);
+
+void DeleteTextBufferAll(Textbuf *tb);
+bool DeleteTextBufferChar(Textbuf *tb, int delmode);
+bool InsertTextBufferChar(Textbuf *tb, uint32 key);
+bool InsertTextBufferClipboard(Textbuf *tb);
+bool MoveTextBufferPos(Textbuf *tb, int navmode);
+void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth);
+void UpdateTextBufferSize(Textbuf *tb);
+
+void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter);
+void ShowQuery(StringID caption, StringID message, Window *w, void (*callback)(Window*, bool));
+
+#endif /* TEXTBUF_GUI_H */
--- a/src/texteff.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/texteff.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,23 +4,23 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "macros.h"
-#include "strings.h"
-#include "gfx.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "viewport.h"
+#include "gfx_func.h"
 #include "saveload.h"
 #include "console.h"
-#include "string.h"
 #include "variables.h"
 #include "table/sprites.h"
 #include "blitter/factory.hpp"
 #include <stdarg.h> /* va_list */
-#include "date.h"
 #include "texteff.hpp"
 #include "video/video_driver.hpp"
 #include "transparency.h"
+#include "strings_func.h"
+#include "core/alloc_func.hpp"
+#include "date_func.h"
+#include "functions.h"
+#include "viewport_func.h"
 
 enum {
 	MAX_TEXTMESSAGE_LENGTH = 200,
@@ -58,7 +58,7 @@
 
 /* The chatbox grows from the bottom so the coordinates are pixels from
  * the left and pixels from the bottom. The height is the maximum height */
-static const Oblong _chatmsg_box = {10, 30, 500, 150};
+static const PointDimension _chatmsg_box = {10, 30, 500, 150};
 static uint8 _chatmessage_backup[150 * 500 * 6]; // (height * width)
 
 static inline uint GetChatMessageCount()
@@ -292,7 +292,7 @@
 	/* If there is none found, we grow the array */
 	if (i == _num_text_effects) {
 		_num_text_effects += 25;
-		_text_effect_list = (TextEffect*) realloc(_text_effect_list, _num_text_effects * sizeof(TextEffect));
+		_text_effect_list = ReallocT<TextEffect>(_text_effect_list, _num_text_effects);
 		for (; i < _num_text_effects; i++) _text_effect_list[i].string_id = INVALID_STRING_ID;
 		i = _num_text_effects - 1;
 	}
--- a/src/tgp.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/tgp.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,17 +6,15 @@
 #include <math.h>
 #include "openttd.h"
 #include "clear_map.h"
-#include "functions.h"
-#include "map.h"
 #include "table/strings.h"
 #include "clear_map.h"
-#include "tile.h"
 #include "variables.h"
 #include "void_map.h"
 #include "tgp.h"
 #include "console.h"
 #include "genworld.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
+#include "core/random_func.hpp"
 
 /*
  *
--- a/src/thread.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/thread.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,8 +5,8 @@
 #include "stdafx.h"
 #include "thread.h"
 #include "debug.h"
+#include "core/alloc_func.hpp"
 #include <stdlib.h>
-#include "helpers.hpp"
 
 #if defined(__AMIGA__) || defined(__MORPHOS__) || defined(PSP) || defined(NO_THREADS)
 OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg) { return NULL; }
--- a/src/tile.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/* $Id$ */
-
-/** @file tile.cpp */
-
-#include "stdafx.h"
-#include "tile.h"
-
-Slope GetTileSlope(TileIndex tile, uint *h)
-{
-	uint a;
-	uint b;
-	uint c;
-	uint d;
-	uint min;
-	uint r;
-
-	assert(tile < MapSize());
-
-	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) {
-		if (h != NULL) *h = 0;
-		return SLOPE_FLAT;
-	}
-
-	min = a = TileHeight(tile);
-	b = TileHeight(tile + TileDiffXY(1, 0));
-	if (min > b) min = b;
-	c = TileHeight(tile + TileDiffXY(0, 1));
-	if (min > c) min = c;
-	d = TileHeight(tile + TileDiffXY(1, 1));
-	if (min > d) min = d;
-
-	r = SLOPE_FLAT;
-	if ((a -= min) != 0) r += (--a << 4) + SLOPE_N;
-	if ((c -= min) != 0) r += (--c << 4) + SLOPE_E;
-	if ((d -= min) != 0) r += (--d << 4) + SLOPE_S;
-	if ((b -= min) != 0) r += (--b << 4) + SLOPE_W;
-
-	if (h != NULL) *h = min * TILE_HEIGHT;
-
-	return (Slope)r;
-}
-
-uint GetTileZ(TileIndex tile)
-{
-	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return 0;
-
-	uint h = TileHeight(tile);
-	h = min(h, TileHeight(tile + TileDiffXY(1, 0)));
-	h = min(h, TileHeight(tile + TileDiffXY(0, 1)));
-	h = min(h, TileHeight(tile + TileDiffXY(1, 1)));
-
-	return h * TILE_HEIGHT;
-}
-
-
-uint GetTileMaxZ(TileIndex t)
-{
-	if (TileX(t) == MapMaxX() || TileY(t) == MapMaxY()) return 0;
-
-	uint h = TileHeight(t);
-	h = max(h, TileHeight(t + TileDiffXY(1, 0)));
-	h = max(h, TileHeight(t + TileDiffXY(0, 1)));
-	h = max(h, TileHeight(t + TileDiffXY(1, 1)));
-
-	return h * TILE_HEIGHT;
-}
--- a/src/tile.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,229 +0,0 @@
-/* $Id$ */
-
-/** @file tile.h */
-
-#ifndef TILE_H
-#define TILE_H
-
-#include "macros.h"
-#include "openttd.h"
-#include "map.h"
-#include "slope.h"
-
-/** Maximum allowed tile height */
-#define MAX_TILE_HEIGHT 15
-
-/** Maximum allowed snowline height */
-#define MAX_SNOWLINE_HEIGHT (MAX_TILE_HEIGHT - 2)
-
-/**
- * The different type of a tile.
- *
- * Each tile belongs to one type, according whatever is build on it.
- *
- * @note A railway with a crossing street is marked as MP_ROAD.
- */
-enum TileType {
-	MP_CLEAR,               ///< A tile without any structures, i.e. grass, rocks, farm fields etc.
-	MP_RAILWAY,             ///< A railway
-	MP_ROAD,                ///< A tile with road (or tram tracks)
-	MP_HOUSE,               ///< A house by a town
-	MP_TREES,               ///< Tile got trees
-	MP_STATION,             ///< A tile of a station
-	MP_WATER,               ///< Water tile
-	MP_VOID,                ///< Invisible tiles at the SW and SE border
-	MP_INDUSTRY,            ///< Part of an industry
-	MP_TUNNELBRIDGE,        ///< Tunnel entry/exit and bridge heads
-	MP_UNMOVABLE,           ///< Contains an object with cannot be removed like transmitters
-};
-
-/**
- * Additional infos of a tile on a tropic game.
- *
- * Each non-water tile in a tropic game is either a rainforest tile or a
- * desert one.
- */
-enum TropicZone {
-	TROPICZONE_INVALID    = 0,      ///< Invalid tropiczone-type
-	TROPICZONE_DESERT     = 1,      ///< Tile is desert
-	TROPICZONE_RAINFOREST = 2,      ///< Rainforest tile
-};
-
-Slope GetTileSlope(TileIndex tile, uint *h);
-uint GetTileZ(TileIndex tile);
-uint GetTileMaxZ(TileIndex tile);
-
-/**
- * Returns the height of a tile
- *
- * This function returns the height of the northern corner of a tile.
- * This is saved in the global map-array. It does not take affect by
- * any slope-data of the tile.
- *
- * @param tile The tile to get the height from
- * @return the height of the tile
- * @pre tile < MapSize()
- */
-static inline uint TileHeight(TileIndex tile)
-{
-	assert(tile < MapSize());
-	return GB(_m[tile].type_height, 0, 4);
-}
-
-/**
- * Sets the height of a tile.
- *
- * This function sets the height of the northern corner of a tile.
- *
- * @param tile The tile to change the height
- * @param height The new height value of the tile
- * @pre tile < MapSize()
- * @pre heigth <= MAX_TILE_HEIGHT
- */
-static inline void SetTileHeight(TileIndex tile, uint height)
-{
-	assert(tile < MapSize());
-	assert(height <= MAX_TILE_HEIGHT);
-	SB(_m[tile].type_height, 0, 4, height);
-}
-
-/**
- * Returns the height of a tile in pixels.
- *
- * This function returns the height of the northern corner of a tile in pixels.
- *
- * @param tile The tile to get the height
- * @return The height of the tile in pixel
- */
-static inline uint TilePixelHeight(TileIndex tile)
-{
-	return TileHeight(tile) * TILE_HEIGHT;
-}
-
-/**
- * Get the tiletype of a given tile.
- *
- * @param tile The tile to get the TileType
- * @return The tiletype of the tile
- * @pre tile < MapSize()
- */
-static inline TileType GetTileType(TileIndex tile)
-{
-	assert(tile < MapSize());
-	return (TileType)GB(_m[tile].type_height, 4, 4);
-}
-
-/**
- * Set the type of a tile
- *
- * This functions sets the type of a tile. If the type
- * MP_VOID is selected the tile must be at the south-west or
- * south-east edges of the map and vice versa.
- *
- * @param tile The tile to save the new type
- * @param type The type to save
- * @pre tile < MapSize()
- * @pre type MP_VOID <=> tile is on the south-east or south-west edge.
- */
-static inline void SetTileType(TileIndex tile, TileType type)
-{
-	assert(tile < MapSize());
-	/* VOID tiles (and no others) are exactly allowed at the lower left and right
-	 * edges of the map */
-	assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID));
-	SB(_m[tile].type_height, 4, 4, type);
-}
-
-/**
- * Checks if a tile is a give tiletype.
- *
- * This function checks if a tile got the given tiletype.
- *
- * @param tile The tile to check
- * @param type The type to check agains
- * @return true If the type matches agains the type of the tile
- */
-static inline bool IsTileType(TileIndex tile, TileType type)
-{
-	return GetTileType(tile) == type;
-}
-
-/**
- * Returns the owner of a tile
- *
- * This function returns the owner of a tile. This cannot used
- * for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY
- * as no player owned any of these buildings.
- *
- * @param tile The tile to check
- * @return The owner of the tile
- * @pre tile < MapSize()
- * @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY
- */
-static inline Owner GetTileOwner(TileIndex tile)
-{
-	assert(tile < MapSize());
-	assert(!IsTileType(tile, MP_HOUSE));
-	assert(!IsTileType(tile, MP_VOID));
-	assert(!IsTileType(tile, MP_INDUSTRY));
-
-	return (Owner)_m[tile].m1;
-}
-
-/**
- * Sets the owner of a tile
- *
- * This function sets the owner status of a tile. Note that you cannot
- * set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY.
- *
- * @param tile The tile to change the owner status.
- * @param owner The new owner.
- * @pre tile < MapSize()
- * @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY
- */
-static inline void SetTileOwner(TileIndex tile, Owner owner)
-{
-	assert(tile < MapSize());
-	assert(!IsTileType(tile, MP_HOUSE));
-	assert(!IsTileType(tile, MP_VOID));
-	assert(!IsTileType(tile, MP_INDUSTRY));
-
-	_m[tile].m1 = owner;
-}
-
-/**
- * Checks if a tile belongs to the given owner
- *
- * @param tile The tile to check
- * @param owner The owner to check agains
- * @return True if a tile belongs the the given owner
- */
-static inline bool IsTileOwner(TileIndex tile, Owner owner)
-{
-	return GetTileOwner(tile) == owner;
-}
-
-/**
- * Set the tropic zone
- * @param tile the tile to set the zone of
- * @param type the new type
- * @pre assert(tile < MapSize());
- */
-static inline void SetTropicZone(TileIndex tile, TropicZone type)
-{
-	assert(tile < MapSize());
-	SB(_m[tile].m6, 0, 2, type);
-}
-
-/**
- * Get the tropic zone
- * @param tile the tile to get the zone of
- * @pre assert(tile < MapSize());
- * @return the zone type
- */
-static inline TropicZone GetTropicZone(TileIndex tile)
-{
-	assert(tile < MapSize());
-	return (TropicZone)GB(_m[tile].m6, 0, 2);
-}
-#endif /* TILE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tile_cmd.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,134 @@
+/* $Id$ */
+
+/** @file tile_cmd.h Generic 'commands' that can be performed on all tiles. */
+
+#ifndef TILE_CMD_H
+#define TILE_CMD_H
+
+#include "slope_type.h"
+#include "tile_type.h"
+#include "command_type.h"
+#include "vehicle_type.h"
+#include "cargo_type.h"
+#include "strings_type.h"
+#include "date_type.h"
+
+/** The returned bits of VehicleEnterTile. */
+enum VehicleEnterTileStatus {
+	VETS_ENTERED_STATION  = 1, ///< The vehicle entered a station
+	VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
+	VETS_CANNOT_ENTER     = 3, ///< The vehicle cannot enter the tile
+
+	/**
+	 * Shift the VehicleEnterTileStatus this many bits
+	 * to the right to get the station ID when
+	 * VETS_ENTERED_STATION is set
+	 */
+	VETS_STATION_ID_OFFSET = 8,
+
+	/** Bit sets of the above specified bits */
+	VETSB_CONTINUE         = 0,                          ///< The vehicle can continue normally
+	VETSB_ENTERED_STATION  = 1 << VETS_ENTERED_STATION,  ///< The vehicle entered a station
+	VETSB_ENTERED_WORMHOLE = 1 << VETS_ENTERED_WORMHOLE, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
+	VETSB_CANNOT_ENTER     = 1 << VETS_CANNOT_ENTER,     ///< The vehicle cannot enter the tile
+};
+DECLARE_ENUM_AS_BIT_SET(VehicleEnterTileStatus);
+
+struct TileInfo {
+	uint x;
+	uint y;
+	Slope tileh;
+	TileIndex tile;
+	uint z;
+};
+
+struct TileDesc {
+	StringID str;
+	Owner owner;
+	Date build_date;
+	uint64 dparam[2];
+};
+
+typedef void DrawTileProc(TileInfo *ti);
+typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
+typedef CommandCost ClearTileProc(TileIndex tile, byte flags);
+typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
+typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
+
+/**
+ * GetTileTrackStatusProcs return a value that contains the possible tracks
+ * that can be taken on a given tile by a given transport. The return value is
+ * composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs,
+ * where bit n corresponds to trackdir n. ccdd are the trackdirs that are
+ * present in the tile (1==present, 0==not present), aabb is the signal
+ * status, if applicable (0==green/no signal, 1==red, note that this is
+ * reversed from map3/2[tile] for railway signals).
+ *
+ * The result (let's call it ts) is often used as follows:
+ * tracks = (byte)(ts | ts >>8)
+ * This effectively converts the present part of the result (ccdd) to a
+ * track bitmask, which disregards directions. Normally, this is the same as just
+ * doing (byte)ts I think, although I am not really sure
+ *
+ * A trackdir is combination of a track and a dir, where the lower three bits
+ * are a track, the fourth bit is the direction. these give 12 (or 14)
+ * possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask
+ * above.
+ * @param tile     the tile to get the track status from
+ * @param mode     the mode of transportation
+ * @param sub_mode used to differentiate between different kinds within the mode
+ * @return the above mentions track status information
+ */
+typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode);
+typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
+typedef void ClickTileProc(TileIndex tile);
+typedef void AnimateTileProc(TileIndex tile);
+typedef void TileLoopProc(TileIndex tile);
+typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
+
+/** @see VehicleEnterTileStatus to see what the return values mean */
+typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
+typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
+
+/**
+ * Called when a tile is affected by a terraforming operation.
+ * The function has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype.
+ * With DC_EXEC in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).
+ *
+ * @note The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation.
+ *
+ * @param tile      The involved tile.
+ * @param flags     Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.).
+ * @param z_new     TileZ after terraforming.
+ * @param tileh_new Slope after terraforming.
+ * @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
+ */
+typedef CommandCost TerraformTileProc(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new);
+
+struct TileTypeProcs {
+	DrawTileProc *draw_tile_proc;
+	GetSlopeZProc *get_slope_z_proc;
+	ClearTileProc *clear_tile_proc;
+	GetAcceptedCargoProc *get_accepted_cargo_proc;
+	GetTileDescProc *get_tile_desc_proc;
+	GetTileTrackStatusProc *get_tile_track_status_proc;
+	ClickTileProc *click_tile_proc;
+	AnimateTileProc *animate_tile_proc;
+	TileLoopProc *tile_loop_proc;
+	ChangeTileOwnerProc *change_tile_owner_proc;
+	GetProducedCargoProc *get_produced_cargo_proc;
+	VehicleEnterTileProc *vehicle_enter_tile_proc;
+	GetFoundationProc *get_foundation_proc;
+	TerraformTileProc *terraform_tile_proc;
+};
+
+extern const TileTypeProcs * const _tile_type_procs[16];
+
+uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode);
+void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
+void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player);
+void AnimateTile(TileIndex tile);
+void ClickTile(TileIndex tile);
+void GetTileDesc(TileIndex tile, TileDesc *td);
+
+#endif /* TILE_CMD_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tile_map.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,68 @@
+/* $Id$ */
+
+/** @file tile.cpp */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "tile_map.h"
+#include "core/math_func.hpp"
+
+Slope GetTileSlope(TileIndex tile, uint *h)
+{
+	uint a;
+	uint b;
+	uint c;
+	uint d;
+	uint min;
+	uint r;
+
+	assert(tile < MapSize());
+
+	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) {
+		if (h != NULL) *h = 0;
+		return SLOPE_FLAT;
+	}
+
+	min = a = TileHeight(tile);
+	b = TileHeight(tile + TileDiffXY(1, 0));
+	if (min > b) min = b;
+	c = TileHeight(tile + TileDiffXY(0, 1));
+	if (min > c) min = c;
+	d = TileHeight(tile + TileDiffXY(1, 1));
+	if (min > d) min = d;
+
+	r = SLOPE_FLAT;
+	if ((a -= min) != 0) r += (--a << 4) + SLOPE_N;
+	if ((c -= min) != 0) r += (--c << 4) + SLOPE_E;
+	if ((d -= min) != 0) r += (--d << 4) + SLOPE_S;
+	if ((b -= min) != 0) r += (--b << 4) + SLOPE_W;
+
+	if (h != NULL) *h = min * TILE_HEIGHT;
+
+	return (Slope)r;
+}
+
+uint GetTileZ(TileIndex tile)
+{
+	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return 0;
+
+	uint h = TileHeight(tile);
+	h = min(h, TileHeight(tile + TileDiffXY(1, 0)));
+	h = min(h, TileHeight(tile + TileDiffXY(0, 1)));
+	h = min(h, TileHeight(tile + TileDiffXY(1, 1)));
+
+	return h * TILE_HEIGHT;
+}
+
+
+uint GetTileMaxZ(TileIndex t)
+{
+	if (TileX(t) == MapMaxX() || TileY(t) == MapMaxY()) return 0;
+
+	uint h = TileHeight(t);
+	h = max(h, TileHeight(t + TileDiffXY(1, 0)));
+	h = max(h, TileHeight(t + TileDiffXY(0, 1)));
+	h = max(h, TileHeight(t + TileDiffXY(1, 1)));
+
+	return h * TILE_HEIGHT;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tile_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,191 @@
+/* $Id$ */
+
+/** @file tile_map.h Map writing/reading functions for tiles. */
+
+#ifndef TILE_MAP_H
+#define TILE_MAP_H
+
+#include "tile_type.h"
+#include "slope_type.h"
+#include "map_func.h"
+#include "core/bitmath_func.hpp"
+
+/**
+ * Returns the height of a tile
+ *
+ * This function returns the height of the northern corner of a tile.
+ * This is saved in the global map-array. It does not take affect by
+ * any slope-data of the tile.
+ *
+ * @param tile The tile to get the height from
+ * @return the height of the tile
+ * @pre tile < MapSize()
+ */
+static inline uint TileHeight(TileIndex tile)
+{
+	assert(tile < MapSize());
+	return GB(_m[tile].type_height, 0, 4);
+}
+
+/**
+ * Sets the height of a tile.
+ *
+ * This function sets the height of the northern corner of a tile.
+ *
+ * @param tile The tile to change the height
+ * @param height The new height value of the tile
+ * @pre tile < MapSize()
+ * @pre heigth <= MAX_TILE_HEIGHT
+ */
+static inline void SetTileHeight(TileIndex tile, uint height)
+{
+	assert(tile < MapSize());
+	assert(height <= MAX_TILE_HEIGHT);
+	SB(_m[tile].type_height, 0, 4, height);
+}
+
+/**
+ * Returns the height of a tile in pixels.
+ *
+ * This function returns the height of the northern corner of a tile in pixels.
+ *
+ * @param tile The tile to get the height
+ * @return The height of the tile in pixel
+ */
+static inline uint TilePixelHeight(TileIndex tile)
+{
+	return TileHeight(tile) * TILE_HEIGHT;
+}
+
+/**
+ * Get the tiletype of a given tile.
+ *
+ * @param tile The tile to get the TileType
+ * @return The tiletype of the tile
+ * @pre tile < MapSize()
+ */
+static inline TileType GetTileType(TileIndex tile)
+{
+	assert(tile < MapSize());
+	return (TileType)GB(_m[tile].type_height, 4, 4);
+}
+
+/**
+ * Set the type of a tile
+ *
+ * This functions sets the type of a tile. If the type
+ * MP_VOID is selected the tile must be at the south-west or
+ * south-east edges of the map and vice versa.
+ *
+ * @param tile The tile to save the new type
+ * @param type The type to save
+ * @pre tile < MapSize()
+ * @pre type MP_VOID <=> tile is on the south-east or south-west edge.
+ */
+static inline void SetTileType(TileIndex tile, TileType type)
+{
+	assert(tile < MapSize());
+	/* VOID tiles (and no others) are exactly allowed at the lower left and right
+	 * edges of the map */
+	assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID));
+	SB(_m[tile].type_height, 4, 4, type);
+}
+
+/**
+ * Checks if a tile is a give tiletype.
+ *
+ * This function checks if a tile got the given tiletype.
+ *
+ * @param tile The tile to check
+ * @param type The type to check agains
+ * @return true If the type matches agains the type of the tile
+ */
+static inline bool IsTileType(TileIndex tile, TileType type)
+{
+	return GetTileType(tile) == type;
+}
+
+/**
+ * Returns the owner of a tile
+ *
+ * This function returns the owner of a tile. This cannot used
+ * for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY
+ * as no player owned any of these buildings.
+ *
+ * @param tile The tile to check
+ * @return The owner of the tile
+ * @pre tile < MapSize()
+ * @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY
+ */
+static inline Owner GetTileOwner(TileIndex tile)
+{
+	assert(tile < MapSize());
+	assert(!IsTileType(tile, MP_HOUSE));
+	assert(!IsTileType(tile, MP_VOID));
+	assert(!IsTileType(tile, MP_INDUSTRY));
+
+	return (Owner)_m[tile].m1;
+}
+
+/**
+ * Sets the owner of a tile
+ *
+ * This function sets the owner status of a tile. Note that you cannot
+ * set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY.
+ *
+ * @param tile The tile to change the owner status.
+ * @param owner The new owner.
+ * @pre tile < MapSize()
+ * @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY
+ */
+static inline void SetTileOwner(TileIndex tile, Owner owner)
+{
+	assert(tile < MapSize());
+	assert(!IsTileType(tile, MP_HOUSE));
+	assert(!IsTileType(tile, MP_VOID));
+	assert(!IsTileType(tile, MP_INDUSTRY));
+
+	_m[tile].m1 = owner;
+}
+
+/**
+ * Checks if a tile belongs to the given owner
+ *
+ * @param tile The tile to check
+ * @param owner The owner to check agains
+ * @return True if a tile belongs the the given owner
+ */
+static inline bool IsTileOwner(TileIndex tile, Owner owner)
+{
+	return GetTileOwner(tile) == owner;
+}
+
+/**
+ * Set the tropic zone
+ * @param tile the tile to set the zone of
+ * @param type the new type
+ * @pre assert(tile < MapSize());
+ */
+static inline void SetTropicZone(TileIndex tile, TropicZone type)
+{
+	assert(tile < MapSize());
+	SB(_m[tile].m6, 0, 2, type);
+}
+
+/**
+ * Get the tropic zone
+ * @param tile the tile to get the zone of
+ * @pre assert(tile < MapSize());
+ * @return the zone type
+ */
+static inline TropicZone GetTropicZone(TileIndex tile)
+{
+	assert(tile < MapSize());
+	return (TropicZone)GB(_m[tile].m6, 0, 2);
+}
+
+Slope GetTileSlope(TileIndex tile, uint *h);
+uint GetTileZ(TileIndex tile);
+uint GetTileMaxZ(TileIndex tile);
+
+#endif /* TILE_TYPE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tile_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,63 @@
+/* $Id$ */
+
+/** @file tile_type.h Types related to tiles. */
+
+#ifndef TILE_TYPE_H
+#define TILE_TYPE_H
+
+#include "core/enum_type.hpp"
+
+enum {
+	TILE_SIZE   = 16,   ///< Tiles are 16x16 "units" in size
+	TILE_PIXELS = 32,   ///< a tile is 32x32 pixels
+	TILE_HEIGHT =  8,   ///< The standard height-difference between tiles on two levels is 8 (z-diff 8)
+
+	MAX_TILE_HEIGHT     = 15,                    ///< Maximum allowed tile height
+	MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2), ///< Maximum allowed snowline height
+};
+
+
+/**
+ * The different type of a tile.
+ *
+ * Each tile belongs to one type, according whatever is build on it.
+ *
+ * @note A railway with a crossing street is marked as MP_ROAD.
+ */
+enum TileType {
+	MP_CLEAR,               ///< A tile without any structures, i.e. grass, rocks, farm fields etc.
+	MP_RAILWAY,             ///< A railway
+	MP_ROAD,                ///< A tile with road (or tram tracks)
+	MP_HOUSE,               ///< A house by a town
+	MP_TREES,               ///< Tile got trees
+	MP_STATION,             ///< A tile of a station
+	MP_WATER,               ///< Water tile
+	MP_VOID,                ///< Invisible tiles at the SW and SE border
+	MP_INDUSTRY,            ///< Part of an industry
+	MP_TUNNELBRIDGE,        ///< Tunnel entry/exit and bridge heads
+	MP_UNMOVABLE,           ///< Contains an object with cannot be removed like transmitters
+};
+
+/**
+ * Additional infos of a tile on a tropic game.
+ *
+ * Each non-water tile in a tropic game is either a rainforest tile or a
+ * desert one.
+ */
+enum TropicZone {
+	TROPICZONE_INVALID    = 0,      ///< Invalid tropiczone-type
+	TROPICZONE_DESERT     = 1,      ///< Tile is desert
+	TROPICZONE_RAINFOREST = 2,      ///< Rainforest tile
+};
+
+/**
+ * The index/ID of a Tile.
+ */
+typedef uint32 TileIndex;
+
+/**
+ * The very nice invalid tile marker
+ */
+static const TileIndex INVALID_TILE = (TileIndex)-1;
+
+#endif /* TILE_TYPE_H */
--- a/src/timetable_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/timetable_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,13 +4,14 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "table/strings.h"
-#include "command.h"
-#include "date.h"
+#include "command_func.h"
 #include "player.h"
-#include "vehicle.h"
+#include "functions.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "vehicle_base.h"
 
 
 static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 time, bool is_journey)
--- a/src/timetable_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/timetable_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,19 +4,19 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "variables.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "command.h"
-#include "date.h"
+#include "command_func.h"
 #include "engine.h"
 #include "gui.h"
-#include "string.h"
-#include "window.h"
-#include "vehicle.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
 #include "cargotype.h"
 #include "depot.h"
+#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)
 {
@@ -48,35 +48,35 @@
 static void DrawTimetableWindow(Window *w)
 {
 	const Vehicle *v = GetVehicle(w->window_number);
-	int selected = WP(w,order_d).sel;
+	int selected = WP(w, order_d).sel;
 
 	SetVScrollCount(w, v->num_orders * 2);
 
 	if (v->owner == _local_player) {
 		if (selected == -1) {
-			DisableWindowWidget(w, 6);
-			DisableWindowWidget(w, 7);
+			w->DisableWidget(6);
+			w->DisableWidget(7);
 		} else if (selected % 2 == 1) {
-			EnableWindowWidget(w, 6);
-			EnableWindowWidget(w, 7);
+			w->EnableWidget(6);
+			w->EnableWidget(7);
 		} else {
 			const Order *order = GetVehicleOrder(v, (selected + 1) / 2);
 			bool disable = order == NULL || order->type != OT_GOTO_STATION || (_patches.new_nonstop && (order->flags & OF_NON_STOP));
 
-			SetWindowWidgetDisabledState(w, 6, disable);
-			SetWindowWidgetDisabledState(w, 7, disable);
+			w->SetWidgetDisabledState(6, disable);
+			w->SetWidgetDisabledState(7, disable);
 		}
 
-		EnableWindowWidget(w, 8);
-		EnableWindowWidget(w, 9);
+		w->EnableWidget(8);
+		w->EnableWidget(9);
 	} else {
-		DisableWindowWidget(w, 6);
-		DisableWindowWidget(w, 7);
-		DisableWindowWidget(w, 8);
-		DisableWindowWidget(w, 9);
+		w->DisableWidget(6);
+		w->DisableWidget(7);
+		w->DisableWidget(8);
+		w->DisableWidget(9);
 	}
 
-	SetWindowWidgetLoweredState(w, 9, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
+	w->SetWidgetLoweredState(9, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
 
 	SetDParam(0, v->index);
 	DrawWindowWidgets(w);
@@ -221,17 +221,17 @@
 				case 3: { /* Main panel. */
 					int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v);
 
-					if (selected == INVALID_ORDER || selected == WP(w,order_d).sel) {
+					if (selected == INVALID_ORDER || selected == WP(w, order_d).sel) {
 						/* Deselect clicked order */
-						WP(w,order_d).sel = -1;
+						WP(w, order_d).sel = -1;
 					} else {
 						/* Select clicked order */
-						WP(w,order_d).sel = selected;
+						WP(w, order_d).sel = selected;
 					}
 				} break;
 
 				case 6: { /* "Wait For" button. */
-					int selected = WP(w,order_d).sel;
+					int selected = WP(w, order_d).sel;
 					VehicleOrderID real = (selected + 1) / 2;
 
 					if (real >= v->num_orders) real = 0;
@@ -253,7 +253,7 @@
 				} break;
 
 				case 7: { /* Clear waiting time button. */
-					uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel);
+					uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
 					DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
 				} break;
 
@@ -272,7 +272,7 @@
 		case WE_ON_EDIT_TEXT: {
 			const Vehicle *v = GetVehicle(w->window_number);
 
-			uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel);
+			uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
 
 			uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
 			if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
@@ -327,6 +327,6 @@
 		w->caption_color = v->owner;
 		w->vscroll.cap = 8;
 		w->resize.step_height = 10;
-		WP(w,order_d).sel = -1;
+		WP(w, order_d).sel = -1;
 	}
 }
--- a/src/town.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/town.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,9 +6,11 @@
 #define TOWN_H
 
 #include "oldpool.h"
-#include "player.h"
-#include "functions.h"
-#include "helpers.hpp"
+#include "core/random_func.hpp"
+#include "cargo_type.h"
+#include "tile_type.h"
+#include "date_type.h"
+#include "town_type.h"
 
 enum {
 	HOUSE_NO_CLASS   = 0,
@@ -67,15 +69,11 @@
 
 DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags)
 
-typedef uint16 HouseID;
-typedef uint16 HouseClassID;
-
 struct BuildingCounts {
 	uint8 id_count[HOUSE_MAX];
 	uint8 class_count[HOUSE_CLASS_MAX];
 };
 
-struct Town;
 DECLARE_OLD_POOL(Town, Town, 3, 8000)
 
 struct Town : PoolItem<Town, TownID, &_Town_pool> {
@@ -108,6 +106,7 @@
 	PlayerByte exclusivity;      ///< which player has exslusivity
 	uint8 exclusive_counter;     ///< months till the exclusivity expires
 	int16 ratings[MAX_PLAYERS];
+	int16 test_rating;
 
 	/* Maximum amount of passengers and mail that can be transported. */
 	uint32 max_pass;
@@ -196,17 +195,12 @@
 	const struct GRFFile *grffile;     ///< grf file that introduced this house
 };
 
-enum TownSizeMode {
-	TSM_RANDOM,
-	TSM_FIXED,
-	TSM_CITY
-};
-
 VARDEF HouseSpec _house_specs[HOUSE_MAX];
 
 uint32 GetWorldPopulation();
 
 void UpdateTownVirtCoord(Town *t);
+void UpdateAllTownVirtCoords();
 void InitializeTown();
 void ShowTownViewWindow(TownID town);
 void ExpandTown(Town *t);
@@ -219,42 +213,6 @@
 	INDUSTRY_REMOVE = 2
 };
 
-enum {
-	/* These refer to the maximums, so Appalling is -1000 to -400
-	 * MAXIMUM RATINGS BOUNDARIES */
-	RATING_MINIMUM     = -1000,
-	RATING_APPALLING   =  -400,
-	RATING_VERYPOOR    =  -200,
-	RATING_POOR        =     0,
-	RATING_MEDIOCRE    =   200,
-	RATING_GOOD        =   400,
-	RATING_VERYGOOD    =   600,
-	RATING_EXCELLENT   =   800,
-	RATING_OUTSTANDING =  1000,         ///< OUTSTANDING
-
-	RATING_MAXIMUM = RATING_OUTSTANDING,
-
-	/* RATINGS AFFECTING NUMBERS */
-	RATING_TREE_DOWN_STEP = -35,
-	RATING_TREE_MINIMUM   = RATING_MINIMUM,
-	RATING_TREE_UP_STEP   = 7,
-	RATING_TREE_MAXIMUM   = 220,
-
-	RATING_TUNNEL_BRIDGE_DOWN_STEP = -250,
-	RATING_TUNNEL_BRIDGE_MINIMUM   = 0,
-
-	RATING_INDUSTRY_DOWN_STEP = -1500,
-	RATING_INDUSTRY_MINIMUM   = RATING_MINIMUM,
-
-	RATING_ROAD_DOWN_STEP = -50,
-	RATING_ROAD_MINIMUM   = -100,
-	RATING_HOUSE_MINIMUM  = RATING_MINIMUM,
-
-	RATING_BRIBE_UP_STEP = 200,
-	RATING_BRIBE_MAXIMUM = 800,
-	RATING_BRIBE_DOWN_TO = -50        // XXX SHOULD BE SOMETHING LOWER?
-};
-
 /** This is the number of ticks between towns being processed for building new
  * houses or roads. This value originally came from the size of the town array
  * in TTD. */
@@ -350,5 +308,12 @@
 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);
+void SetTownRatingTestMode(bool mode);
 
 #endif /* TOWN_H */
--- a/src/town_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/town_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,35 +4,29 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "debug.h"
-#include "strings.h"
 #include "road_map.h"
+#include "road_internal.h" /* Cleaning up road bits */
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "map.h"
 #include "landscape.h"
-#include "tile.h"
 #include "town_map.h"
 #include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
 #include "town.h"
-#include "command.h"
-#include "gfx.h"
+#include "command_func.h"
 #include "industry.h"
 #include "station.h"
-#include "vehicle.h"
 #include "player.h"
 #include "news.h"
 #include "saveload.h"
-#include "economy.h"
 #include "gui.h"
 #include "unmovable_map.h"
 #include "water_map.h"
 #include "variables.h"
 #include "bridge.h"
 #include "bridge_map.h"
-#include "date.h"
 #include "table/town_land.h"
 #include "genworld.h"
 #include "newgrf.h"
@@ -44,6 +38,11 @@
 #include "autoslope.h"
 #include "waypoint.h"
 #include "transparency.h"
+#include "tunnelbridge_map.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "string_func.h"
+
 
 /* Initialize the town-pool */
 DEFINE_OLD_POOL_GENERIC(Town, Town)
@@ -311,6 +310,15 @@
 	MarkTownSignDirty(t);
 }
 
+/** Update the virtual coords needed to draw the town sign for all towns. */
+void UpdateAllTownVirtCoords()
+{
+	Town *t;
+	FOR_ALL_TOWNS(t) {
+		UpdateTownVirtCoord(t);
+	}
+}
+
 /**
  * Change the towns population
  * @param t Town which polulation has changed
@@ -406,7 +414,7 @@
 	if ((hs->building_flags & BUILDING_IS_ANIMATED) &&
 			house_id < NEW_HOUSE_OFFSET &&
 			!LiftHasDestination(tile) &&
-			CHANCE16(1, 2))
+			Chance16(1, 2))
 		AddAnimatedTile(tile);
 
 	t = GetTownByTile(tile);
@@ -494,7 +502,7 @@
 static CommandCost ClearTile_Town(TileIndex tile, byte flags)
 {
 	int rating;
-	CommandCost cost;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	Town *t;
 	HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
 
@@ -514,8 +522,8 @@
 		}
 	}
 
+	ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM);
 	if (flags & DC_EXEC) {
-		ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM);
 		ClearTownHouse(t, tile);
 	}
 
@@ -731,14 +739,14 @@
 		 * maybe terraform some. */
 		desired_slope = (dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? SLOPE_NW : SLOPE_NE;
 		if (desired_slope != cur_slope && ComplementSlope(desired_slope) != cur_slope) {
-			if (CHANCE16(1, 8)) {
+			if (Chance16(1, 8)) {
 				CommandCost res = CMD_ERROR;
-				if (!_generating_world && CHANCE16(1, 10)) {
+				if (!_generating_world && Chance16(1, 10)) {
 					/* Note: Do not replace " ^ 0xF" with ComplementSlope(). The slope might be steep. */
-					res = DoCommand(tile, CHANCE16(1, 16) ? cur_slope : cur_slope ^ 0xF, 0,
+					res = DoCommand(tile, Chance16(1, 16) ? cur_slope : cur_slope ^ 0xF, 0,
 							DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
 				}
-				if (CmdFailed(res) && CHANCE16(1, 3)) {
+				if (CmdFailed(res) && Chance16(1, 3)) {
 					/* We can consider building on the slope, though. */
 					goto no_slope;
 				}
@@ -1002,7 +1010,7 @@
 
 				DiagDirection source_dir = ReverseDiagDir(target_dir);
 
-				if (CHANCE16(1, 4)) {
+				if (Chance16(1, 4)) {
 					/* Randomize a new target dir */
 					do target_dir = RandomDiagDir(); while (target_dir == source_dir);
 				}
@@ -1053,10 +1061,8 @@
 
 		/* Reached a tunnel/bridge? Then continue at the other side of it. */
 		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
-			if (IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) {
-				*tile_ptr = GetOtherTunnelEnd(tile);
-			} else if (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_ROAD) {
-				*tile_ptr = GetOtherBridgeEnd(tile);
+			if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
+				*tile_ptr = GetOtherTunnelBridgeEnd(tile);
 			}
 			return;
 		}
@@ -1096,7 +1102,7 @@
 				 /* Allow a house at the edge. 60% chance or
 				  * always ok if no road allowed. */
 				rcmd = DiagDirToRoadBits(target_dir);
-				allow_house = (!IsRoadAllowedHere(house_tile, target_dir) || CHANCE16(6, 10));
+				allow_house = (!IsRoadAllowedHere(house_tile, target_dir) || Chance16(6, 10));
 				break;
 		}
 
@@ -1104,7 +1110,7 @@
 			/* Build a house, but not if there already is a house there. */
 			if (!IsTileType(house_tile, MP_HOUSE)) {
 				/* Level the land if possible */
-				if (CHANCE16(1, 6)) LevelTownLand(house_tile);
+				if (Chance16(1, 6)) LevelTownLand(house_tile);
 
 				/* And build a house.
 				 * Set result to -1 if we managed to build it. */
@@ -1490,8 +1496,6 @@
 	if (_game_mode != GM_EDITOR) return CMD_ERROR;
 	if (p2 > TSM_CITY) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-
 	/* Check if too close to the edge of map */
 	if (DistanceFromEdge(tile) < 12)
 		return_cmd_error(STR_0237_TOO_CLOSE_TO_EDGE_OF_MAP);
@@ -1778,7 +1782,7 @@
 			uint32 r = Random();
 
 			construction_stage = TOWN_HOUSE_COMPLETED;
-			if (CHANCE16(1, 7)) construction_stage = GB(r, 0, 2);
+			if (Chance16(1, 7)) construction_stage = GB(r, 0, 2);
 
 			if (construction_stage == TOWN_HOUSE_COMPLETED) {
 				ChangePopulation(t, hs->population);
@@ -1786,7 +1790,7 @@
 				construction_counter = GB(r, 2, 2);
 			}
 		}
-		MakeTownHouse(tile, t->index, construction_counter, construction_stage, house, VehicleRandomBits());
+		MakeTownHouse(tile, t->index, construction_counter, construction_stage, house, Random());
 	}
 }
 
@@ -2091,7 +2095,6 @@
  */
 CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	CommandCost cost;
 	Town *t;
 
 	if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR;
@@ -2100,9 +2103,7 @@
 
 	if (!HasBit(GetMaskOfTownActions(NULL, _current_player, t), p2)) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-
-	cost.AddCost((_price.build_industry >> 8) * _town_action_costs[p2]);
+	CommandCost cost(EXPENSES_OTHER, (_price.build_industry >> 8) * _town_action_costs[p2]);
 
 	if (flags & DC_EXEC) {
 		_town_action_proc[p2](t);
@@ -2155,7 +2156,7 @@
 		t->fund_buildings_months--;
 	} else {
 		m = _grow_count_values[1][min(n, 5)];
-		if (n == 0 && !CHANCE16(1, 12)) return;
+		if (n == 0 && !Chance16(1, 12)) return;
 	}
 
 	if (_opt.landscape == LT_ARCTIC) {
@@ -2255,6 +2256,23 @@
 	}
 }
 
+static bool _town_rating_test = false;
+
+void SetTownRatingTestMode(bool mode)
+{
+	static int ref_count = 0;
+	if (mode) {
+		if (ref_count == 0) {
+			Town *t;
+			FOR_ALL_TOWNS(t) t->test_rating = t->ratings[_current_player];
+		}
+		ref_count++;
+	} else {
+		assert(ref_count > 0);
+		ref_count--;
+	}
+	_town_rating_test = !(ref_count == 0);
+}
 
 void ChangeTownRating(Town *t, int add, int max)
 {
@@ -2269,7 +2287,7 @@
 
 	SetBit(t->have_ratings, _current_player);
 
-	rating = t->ratings[_current_player];
+	rating = _town_rating_test ? t->test_rating : t->ratings[_current_player];
 
 	if (add < 0) {
 		if (rating > max) {
@@ -2282,7 +2300,11 @@
 			if (rating > max) rating = max;
 		}
 	}
-	t->ratings[_current_player] = rating;
+	if (_town_rating_test) {
+		t->test_rating = rating;
+	} else {
+		t->ratings[_current_player] = rating;
+	}
 }
 
 /* penalty for removing town-owned stuff */
@@ -2307,7 +2329,7 @@
 	 */
 	modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type];
 
-	if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
+	if ((_town_rating_test ? t->test_rating : t->ratings[_current_player]) < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
 		SetDParam(0, t->index);
 		_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
 		return false;
@@ -2358,7 +2380,7 @@
 
 		/* Here we differ from TTDP by checking TILE_NOT_SLOPED */
 		if (((hs->building_flags & TILE_NOT_SLOPED) == 0) && !IsSteepSlope(tileh_new) &&
-			(GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) return _price.terraform;
+			(GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 	}
 
 	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -2521,7 +2543,6 @@
 	Town *t;
 	FOR_ALL_TOWNS(t) {
 		UpdateTownRadius(t);
-		UpdateTownVirtCoord(t);
 	}
 	_town_sort_dirty = true;
 }
--- a/src/town_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/town_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,20 +5,21 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "town.h"
-#include "window.h"
-#include "gfx.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "gui.h"
-#include "command.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
+#include "command_func.h"
 #include "player.h"
 #include "network/network.h"
 #include "variables.h"
-#include "helpers.hpp"
+#include "strings_func.h"
+#include "economy_func.h"
+#include "core/alloc_func.hpp"
 
 enum TownAuthorityWidget {
 	TWA_CLOSEBOX = 0,
@@ -109,15 +110,23 @@
 	return buttons;
 }
 
+/**
+ * Get the position of the Nth set bit.
+ *
+ * If there is no Nth bit set return -1
+ *
+ * @param bits The value to search in
+ * @param n The Nth set bit from which we want to know the position
+ * @return The position of the Nth set bit
+ */
 static int GetNthSetBit(uint32 bits, int n)
 {
-	int i = 0;
-
 	if (n >= 0) {
-		do {
-			if (bits & 1 && --n < 0) return i;
-			i++;
-		} while (bits >>= 1);
+		uint i;
+		FOR_EACH_SET_BIT(i, bits) {
+			n--;
+			if (n < 0) return i;
+		}
 	}
 	return -1;
 }
@@ -132,10 +141,10 @@
 
 		SetVScrollCount(w, numact + 1);
 
-		if (WP(w,def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1))
-			WP(w,def_d).data_1 = -1;
+		if (WP(w, def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1))
+			WP(w, def_d).data_1 = -1;
 
-		SetWindowWidgetDisabledState(w, 6, WP(w, def_d).data_1 == -1);
+		w->SetWidgetDisabledState(6, WP(w, def_d).data_1 == -1);
 
 		{
 			int y;
@@ -198,7 +207,7 @@
 		}
 
 		{
-			int i = WP(w,def_d).data_1;
+			int i = WP(w, def_d).data_1;
 
 			if (i != -1) {
 				SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]);
@@ -216,11 +225,11 @@
 			const Town *t = GetTown(w->window_number);
 			int y = (e->we.click.pt.y - 0x6B) / 10;
 
-			if (!IS_INT_INSIDE(y, 0, 5)) return;
+			if (!IsInsideMM(y, 0, 5)) return;
 
 			y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1);
 			if (y >= 0) {
-				WP(w,def_d).data_1 = y;
+				WP(w, def_d).data_1 = y;
 				SetWindowDirty(w);
 			}
 			/* Fall through to clicking in case we are double-clicked */
@@ -228,7 +237,7 @@
 		}
 
 		case TWA_EXECUTE: {
-			DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w,def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
+			DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w, def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
 			break;
 		}
 		}
@@ -254,7 +263,7 @@
 
 	if (w != NULL) {
 		w->vscroll.cap = 5;
-		WP(w,def_d).data_1 = -1;
+		WP(w, def_d).data_1 = -1;
 	}
 }
 
@@ -265,7 +274,7 @@
 	switch (e->event) {
 	case WE_PAINT:
 		/* disable renaming town in network games if you are not the server */
-		SetWindowWidgetDisabledState(w, 8, _networking && !_network_server);
+		w->SetWidgetDisabledState(8, _networking && !_network_server);
 
 		SetDParam(0, t->index);
 		DrawWindowWidgets(w);
@@ -441,7 +450,6 @@
 
 	/* Create array for sorting */
 	_town_sort = ReallocT(_town_sort, GetMaxTownIndex() + 1);
-	if (_town_sort == NULL) error("Could not allocate memory for the town-sorting-list");
 
 	FOR_ALL_TOWNS(t) _town_sort[n++] = t;
 
--- a/src/town_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/town_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,7 +6,9 @@
 #define TOWN_MAP_H
 
 #include "town.h"
-#include "date.h"
+#include "date_func.h"
+#include "tile_map.h"
+#include "functions.h"
 
 /**
  * Get the index of which town this house/street is attached to.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/town_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,77 @@
+/* $Id$ */
+
+/** @file town_type.h Types related to towns. */
+
+#ifndef TOWN_TYPE_H
+#define TOWN_TYPE_H
+
+#include "core/enum_type.hpp"
+
+typedef uint16 TownID;
+typedef uint16 HouseID;
+typedef uint16 HouseClassID;
+
+struct Town;
+struct HouseSpec;
+
+enum TownSizeMode {
+	TSM_RANDOM,
+	TSM_FIXED,
+	TSM_CITY
+};
+
+enum {
+	/* These refer to the maximums, so Appalling is -1000 to -400
+	 * MAXIMUM RATINGS BOUNDARIES */
+	RATING_MINIMUM     = -1000,
+	RATING_APPALLING   =  -400,
+	RATING_VERYPOOR    =  -200,
+	RATING_POOR        =     0,
+	RATING_MEDIOCRE    =   200,
+	RATING_GOOD        =   400,
+	RATING_VERYGOOD    =   600,
+	RATING_EXCELLENT   =   800,
+	RATING_OUTSTANDING =  1000,         ///< OUTSTANDING
+
+	RATING_MAXIMUM = RATING_OUTSTANDING,
+
+	/* RATINGS AFFECTING NUMBERS */
+	RATING_TREE_DOWN_STEP = -35,
+	RATING_TREE_MINIMUM   = RATING_MINIMUM,
+	RATING_TREE_UP_STEP   = 7,
+	RATING_TREE_MAXIMUM   = 220,
+
+	RATING_TUNNEL_BRIDGE_DOWN_STEP = -250,
+	RATING_TUNNEL_BRIDGE_MINIMUM   = 0,
+
+	RATING_INDUSTRY_DOWN_STEP = -1500,
+	RATING_INDUSTRY_MINIMUM   = RATING_MINIMUM,
+
+	RATING_ROAD_DOWN_STEP = -50,
+	RATING_ROAD_MINIMUM   = -100,
+	RATING_HOUSE_MINIMUM  = RATING_MINIMUM,
+
+	RATING_BRIBE_UP_STEP = 200,
+	RATING_BRIBE_MAXIMUM = 800,
+	RATING_BRIBE_DOWN_TO = -50        // XXX SHOULD BE SOMETHING LOWER?
+};
+
+/**
+ * Town Layouts
+ */
+enum TownLayout {
+	TL_NO_ROADS     = 0, ///< Build no more roads, but still build houses
+	TL_ORIGINAL,         ///< Original algorithm (min. 1 distance between roads)
+	TL_BETTER_ROADS,     ///< Extended original algorithm (min. 2 distance between roads)
+	TL_2X2_GRID,         ///< Geometric 2x2 grid algorithm
+	TL_3X3_GRID,         ///< Geometric 3x3 grid algorithm
+
+	NUM_TLS,             ///< Number of town layouts
+};
+
+/* It needs to be 8bits, because we save and load it as such */
+/** Define basic enum properties */
+template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {};
+typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
+
+#endif /* TOWN_TYPE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/track_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,519 @@
+/* $Id$ */
+
+/** @file track_func.h Different conversion functions from one kind of track to another. */
+
+#ifndef TRACK_FUNC_H
+#define TRACK_FUNC_H
+
+#include "core/bitmath_func.hpp"
+#include "track_type.h"
+#include "direction_type.h"
+#include "slope_func.h"
+
+/**
+ * Convert an Axis to the corresponding Track
+ * AXIS_X -> TRACK_X
+ * AXIS_Y -> TRACK_Y
+ * Uses the fact that they share the same internal encoding
+ *
+ * @param a the axis to convert
+ * @return the track corresponding to the axis
+ */
+static inline Track AxisToTrack(Axis a)
+{
+	return (Track)a;
+}
+
+
+
+/**
+ * Maps a Track to the corresponding TrackBits value
+ * @param track the track to convert
+ * @return the converted TrackBits value of the track
+ */
+static inline TrackBits TrackToTrackBits(Track track)
+{
+	return (TrackBits)(1 << track);
+}
+
+/**
+ * Maps an Axis to the corresponding TrackBits value
+ * @param a the axis to convert
+ * @return the converted TrackBits value of the axis
+ */
+static inline TrackBits AxisToTrackBits(Axis a)
+{
+	return TrackToTrackBits(AxisToTrack(a));
+}
+
+/**
+ * Returns a single horizontal/vertical trackbit, that is in a specific tile corner.
+ *
+ * @param corner The corner of a tile.
+ * @return The TrackBits of the track in the corner.
+ */
+static inline TrackBits CornerToTrackBits(Corner corner)
+{
+	extern const TrackBits _corner_to_trackbits[];
+	assert(IsValidCorner(corner));
+	return _corner_to_trackbits[corner];
+}
+
+
+
+/**
+ * Maps a Trackdir to the corresponding TrackdirBits value
+ * @param trackdir the track direction to convert
+ * @return the converted TrackdirBits value
+ */
+static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
+{
+	return (TrackdirBits)(1 << trackdir);
+}
+
+/**
+ * Removes first Track from TrackBits and returns it
+ *
+ * This function searchs for the first bit in the TrackBits,
+ * remove this bit from the parameter and returns the found
+ * bit as Track value. It returns INVALID_TRACK if the
+ * parameter was TRACK_BIT_NONE or INVALID_TRACK_BIT. This
+ * is basically used in while-loops to get up to 6 possible
+ * tracks on a tile until the parameter becomes TRACK_BIT_NONE.
+ *
+ * @param tracks The value with the TrackBits
+ * @return The first Track from the TrackBits value
+ * @see FindFirstTrack
+ */
+static inline Track RemoveFirstTrack(TrackBits *tracks)
+{
+	if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) {
+		Track first = (Track)FIND_FIRST_BIT(*tracks);
+		ClrBit(*tracks, first);
+		return first;
+	}
+	return INVALID_TRACK;
+}
+
+/**
+ * Removes first Trackdir from TrackdirBits and returns it
+ *
+ * This function searchs for the first bit in the TrackdirBits parameter,
+ * remove this bit from the parameter and returns the fnound bit as
+ * Trackdir value. It returns INVALID_TRACKDIR if the trackdirs is
+ * TRACKDIR_BIT_NONE or INVALID_TRACKDIR_BIT. This is basically used in a
+ * while-loop to get all track-directions step by step until the value
+ * reaches TRACKDIR_BIT_NONE.
+ *
+ * @param trackdirs The value with the TrackdirBits
+ * @return The first Trackdir from the TrackdirBits value
+ * @see FindFirstTrackdir
+ */
+static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
+{
+	if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) {
+		Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs);
+		ClrBit(*trackdirs, first);
+		return first;
+	}
+	return INVALID_TRACKDIR;
+}
+
+/**
+ * Returns first Track from TrackBits or INVALID_TRACK
+ *
+ * This function returns the first Track found in the TrackBits value as Track-value.
+ * It returns INVALID_TRACK if the parameter is TRACK_BIT_NONE or INVALID_TRACK_BIT.
+ *
+ * @param tracks The TrackBits value
+ * @return The first Track found or INVALID_TRACK
+ * @see RemoveFirstTrack
+ */
+static inline Track FindFirstTrack(TrackBits tracks)
+{
+	return (tracks != TRACK_BIT_NONE && tracks != INVALID_TRACK_BIT) ? (Track)FIND_FIRST_BIT(tracks) : INVALID_TRACK;
+}
+
+/**
+ * Converts TrackBits to Track.
+ *
+ * This function converts a TrackBits value to a Track value. As it
+ * is not possible to convert two or more tracks to one track the
+ * parameter must contain only one track or be the INVALID_TRACK_BIT value.
+ *
+ * @param tracks The TrackBits value to convert
+ * @return The Track from the value or INVALID_TRACK
+ * @pre tracks must contains only one Track or be INVALID_TRACK_BIT
+ */
+static inline Track TrackBitsToTrack(TrackBits tracks)
+{
+	assert(tracks == INVALID_TRACK_BIT || (tracks != TRACK_BIT_NONE && KillFirstBit(tracks & TRACK_BIT_MASK) == TRACK_BIT_NONE));
+	return tracks != INVALID_TRACK_BIT ? (Track)FIND_FIRST_BIT(tracks & TRACK_BIT_MASK) : INVALID_TRACK;
+}
+
+/**
+ * Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR
+ *
+ * This function returns the first Trackdir in the given TrackdirBits value or
+ * INVALID_TRACKDIR if the value is TRACKDIR_BIT_NONE. The TrackdirBits must
+ * not be INVALID_TRACKDIR_BIT.
+ *
+ * @param trackdirs The TrackdirBits value
+ * @return The first Trackdir from the TrackdirBits or INVALID_TRACKDIR on TRACKDIR_BIT_NONE.
+ * @pre trackdirs must not be INVALID_TRACKDIR_BIT
+ * @see RemoveFirstTrackdir
+ */
+static inline Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
+{
+	assert((trackdirs & ~TRACKDIR_BIT_MASK) == TRACKDIR_BIT_NONE);
+	return (trackdirs != TRACKDIR_BIT_NONE) ? (Trackdir)FindFirstBit2x64(trackdirs) : INVALID_TRACKDIR;
+}
+
+/**
+ * Checks if a Track is valid.
+ *
+ * @param track The value to check
+ * @return true if the given value is a valid track.
+ * @note Use this in an assert()
+ */
+static inline bool IsValidTrack(Track track)
+{
+	return track < TRACK_END;
+}
+
+/**
+ * Checks if a Trackdir is valid.
+ *
+ * @param trackdir The value to check
+ * @return true if the given valie is a valid Trackdir
+ * @note Use this in an assert()
+ */
+static inline bool IsValidTrackdir(Trackdir trackdir)
+{
+	return (TrackdirToTrackdirBits(trackdir) & TRACKDIR_BIT_MASK) != 0;
+}
+
+
+/*
+ * Functions describing logical relations between Tracks, TrackBits, Trackdirs
+ * TrackdirBits, Direction and DiagDirections.
+ */
+
+/**
+ * Maps a trackdir to the reverse trackdir.
+ *
+ * Returns the reverse trackdir of a Trackdir value. The reverse trackdir
+ * is the same track with the other direction on it.
+ *
+ * @param trackdir The Trackdir value
+ * @return The reverse trackdir
+ * @pre trackdir must not be INVALID_TRACKDIR
+ */
+static inline Trackdir ReverseTrackdir(Trackdir trackdir)
+{
+	assert(trackdir != INVALID_TRACKDIR);
+	return (Trackdir)(trackdir ^ 8);
+}
+
+/**
+ * Returns the Track that a given Trackdir represents
+ *
+ * This function filters the Track which is used in the Trackdir value and
+ * returns it as a Track value.
+ *
+ * @param trackdir The trackdir value
+ * @return The Track which is used in the value
+ */
+static inline Track TrackdirToTrack(Trackdir trackdir)
+{
+	return (Track)(trackdir & 0x7);
+}
+
+/**
+ * Returns a Trackdir for the given Track
+ *
+ * Since every Track corresponds to two Trackdirs, we choose the
+ * one which points between NE and S. Note that the actual
+ * implementation is quite futile, but this might change
+ * in the future.
+ *
+ * @param track The given Track
+ * @return The Trackdir from the given Track
+ */
+static inline Trackdir TrackToTrackdir(Track track)
+{
+	return (Trackdir)track;
+}
+
+/**
+ * Returns a TrackdirBit mask from a given Track
+ *
+ * The TrackdirBit mask contains the two TrackdirBits that
+ * correspond with the given Track (one for each direction).
+ *
+ * @param track The track to get the TrackdirBits from
+ * @return The TrackdirBits which the selected tracks
+ */
+static inline TrackdirBits TrackToTrackdirBits(Track track)
+{
+	Trackdir td = TrackToTrackdir(track);
+	return (TrackdirBits)(TrackdirToTrackdirBits(td) | TrackdirToTrackdirBits(ReverseTrackdir(td)));
+}
+
+/**
+ * Discards all directional information from a TrackdirBits value
+ *
+ * Any Track which is present in either direction will be present in the result.
+ *
+ * @param bits The TrackdirBits to get the TrackBits from
+ * @return The TrackBits
+ */
+static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
+{
+	return (TrackBits)((bits | (bits >> 8)) & TRACK_BIT_MASK);
+}
+
+/**
+ * Maps a trackdir to the trackdir that you will end up on if you go straight
+ * ahead.
+ *
+ * This will be the same trackdir for diagonal trackdirs, but a
+ * different (alternating) one for straight trackdirs
+ *
+ * @param trackdir The given trackdir
+ * @return The next Trackdir value of the next tile.
+ */
+static inline Trackdir NextTrackdir(Trackdir trackdir)
+{
+	extern const Trackdir _next_trackdir[TRACKDIR_END];
+	return _next_trackdir[trackdir];
+}
+
+/**
+ * Maps a track to all tracks that make 90 deg turns with it.
+ *
+ * For the diagonal directions these are the complement of the
+ * direction, for the straight directions these are the
+ * two vertical or horizontal tracks, depend on the given direction
+ *
+ * @param track The given track
+ * @return The TrackBits with the tracks marked which cross the given track by 90 deg.
+ */
+static inline TrackBits TrackCrossesTracks(Track track)
+{
+	extern const TrackBits _track_crosses_tracks[TRACK_END];
+	return _track_crosses_tracks[track];
+}
+
+/**
+ * Maps a trackdir to the (4-way) direction the tile is exited when following
+ * that trackdir.
+ *
+ * For the diagonal directions these are the same directions. For
+ * the straight directions these are the directions from the imagined
+ * base-tile to the bordering tile which will be joined if the given
+ * straight direction is leaved from the base-tile.
+ *
+ * @param trackdir The given track direction
+ * @return The direction which points to the resulting tile if following the Trackdir
+ */
+static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
+{
+	extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
+	return _trackdir_to_exitdir[trackdir];
+}
+
+/**
+ * Maps a track and an (4-way) dir to the trackdir that represents the track
+ * with the exit in the given direction.
+ *
+ * For the diagonal tracks the resulting track direction are clear for a given
+ * DiagDirection. It either matches the direction or it returns INVALID_TRACKDIR,
+ * as a TRACK_X cannot be applied with DIAG_SE.
+ * For the straight tracks the resulting track direction will be the
+ * direction which the DiagDirection is pointing. But this will be INVALID_TRACKDIR
+ * if the DiagDirection is pointing 'away' the track.
+ *
+ * @param track The track to applie an direction on
+ * @param diagdir The DiagDirection to applie on
+ * @return The resulting track direction or INVALID_TRACKDIR if not possible.
+ */
+static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir)
+{
+	extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END];
+	return _track_exitdir_to_trackdir[track][diagdir];
+}
+
+/**
+ * Maps a track and an (4-way) dir to the trackdir that represents the track
+ * with the entry in the given direction.
+ *
+ * For the diagonal tracks the return value is clear, its either the matching
+ * track direction or INVALID_TRACKDIR.
+ * For the straight tracks this returns the track direction which results if
+ * you follow the DiagDirection and then turn by 45 deg left or right on the
+ * next tile. The new direction on the new track will be the returning Trackdir
+ * value. If the parameters makes no sense like the track TRACK_UPPER and the
+ * diraction DIAGDIR_NE (target track cannot be reached) this function returns
+ * INVALID_TRACKDIR.
+ *
+ * @param track The target track
+ * @param diagdir The direction to "come from"
+ * @return the resulting Trackdir or INVALID_TRACKDIR if not possible.
+ */
+static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir)
+{
+	extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END];
+	return _track_enterdir_to_trackdir[track][diagdir];
+}
+
+/**
+ * Maps a track and a full (8-way) direction to the trackdir that represents
+ * the track running in the given direction.
+ */
+static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
+{
+	extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
+	return _track_direction_to_trackdir[track][dir];
+}
+
+/**
+ * Maps a (4-way) direction to the diagonal trackdir that runs in that
+ * direction.
+ *
+ * @param diagdir The direction
+ * @return The resulting Trackdir direction
+ */
+static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir)
+{
+	extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
+	return _dir_to_diag_trackdir[diagdir];
+}
+
+/**
+ * Returns all trackdirs that can be reached when entering a tile from a given
+ * (diagonal) direction.
+ *
+ * This will obviously include 90 degree turns, since no information is available
+ * about the exact angle of entering
+ *
+ * @param diagdir The joining direction
+ * @return The TrackdirBits which can be used from the given direction
+ * @see DiagdirReachesTracks
+ */
+static inline TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
+{
+	extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
+	return _exitdir_reaches_trackdirs[diagdir];
+}
+
+/**
+ * Returns all tracks that can be reached when entering a tile from a given
+ * (diagonal) direction.
+ *
+ * This will obviously include 90 degree turns, since no
+ * information is available about the exact angle of entering
+ *
+ * @param diagdir The joining irection
+ * @return The tracks which can be used
+ * @see DiagdirReachesTrackdirs
+ */
+static inline TrackBits DiagdirReachesTracks(DiagDirection diagdir) { return TrackdirBitsToTrackBits(DiagdirReachesTrackdirs(diagdir)); }
+
+/**
+ * Maps a trackdir to the trackdirs that can be reached from it (ie, when
+ * entering the next tile.
+ *
+ * This will include 90 degree turns!
+ *
+ * @param trackdir The track direction which will be leaved
+ * @return The track directions which can be used from this direction (in the next tile)
+ */
+static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
+{
+	extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
+	return _exitdir_reaches_trackdirs[TrackdirToExitdir(trackdir)];
+}
+/* Note that there is no direct table for this function (there used to be),
+ * but it uses two simpeler tables to achieve the result */
+
+/**
+ * Maps a trackdir to all trackdirs that make 90 deg turns with it.
+ *
+ * For the diagonal tracks this returns the track direction bits
+ * of the other axis in both directions, which cannot be joined by
+ * the given track direction.
+ * For the straight tracks this returns all possible 90 deg turns
+ * either on the current tile (which no train can joined) or on the
+ * bordering tiles.
+ *
+ * @param trackdir The track direction
+ * @return The TrackdirBits which are (more or less) 90 deg turns.
+ */
+static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
+{
+	extern const TrackdirBits _track_crosses_trackdirs[TRACKDIR_END];
+	return _track_crosses_trackdirs[TrackdirToTrack(trackdir)];
+}
+
+/**
+ * Checks if a given Track is diagonal
+ *
+ * @param track The given track to check
+ * @return true if diagonal, else false
+ */
+static inline bool IsDiagonalTrack(Track track)
+{
+	return (track == TRACK_X) || (track == TRACK_Y);
+}
+
+/**
+ * Checks if a given Trackdir is diagonal.
+ *
+ * @param trackdir The given trackdir
+ * @return true if the trackdir use a diagonal track
+ */
+static inline bool IsDiagonalTrackdir(Trackdir trackdir)
+{
+	return IsDiagonalTrack(TrackdirToTrack(trackdir));
+}
+
+
+/**
+ * Checks if the given tracks overlap, ie form a crossing. Basically this
+ * means when there is more than one track on the tile, exept when there are
+ * two parallel tracks.
+ * @param  bits The tracks present.
+ * @return Whether the tracks present overlap in any way.
+ */
+static inline bool TracksOverlap(TrackBits bits)
+{
+	/* With no, or only one track, there is no overlap */
+	if (bits == TRACK_BIT_NONE || KillFirstBit(bits) == TRACK_BIT_NONE) return false;
+	/* We know that there are at least two tracks present. When there are more
+	 * than 2 tracks, they will surely overlap. When there are two, they will
+	 * always overlap unless they are lower & upper or right & left. */
+	return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT;
+}
+
+/**
+ * Checks whether the trackdir means that we are reversing.
+ * @param dir the trackdir to check
+ * @return true if it is a reversing road trackdir
+ */
+static inline bool IsReversingRoadTrackdir(Trackdir dir)
+{
+	return (dir & 0x07) >= 6;
+}
+
+/**
+ * Checks whether the given trackdir is a straight road
+ * @param dir the trackdir to check
+ * @return true if it is a straight road trackdir
+ */
+static inline bool IsStraightRoadTrackdir(Trackdir dir)
+{
+	return (dir & 0x06) == 0;
+}
+
+#endif /* TRACK_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/track_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,125 @@
+/* $Id$ */
+
+/** @file track_type.h All types related to tracks */
+
+#ifndef TRACK_TYPE_H
+#define TRACK_TYPE_H
+
+/**
+ * These are used to specify a single track.
+ * Can be translated to a trackbit with TrackToTrackbit
+ */
+enum Track {
+	TRACK_BEGIN = 0,        ///< Used for iterations
+	TRACK_X     = 0,        ///< Track along the x-axis (north-east to south-west)
+	TRACK_Y     = 1,        ///< Track along the y-axis (north-west to south-east)
+	TRACK_UPPER = 2,        ///< Track in the upper corner of the tile (north)
+	TRACK_LOWER = 3,        ///< Track in the lower corner of the tile (south)
+	TRACK_LEFT  = 4,        ///< Track in the left corner of the tile (west)
+	TRACK_RIGHT = 5,        ///< Track in the right corner of the tile (east)
+	TRACK_END,              ///< Used for iterations
+	INVALID_TRACK = 0xFF    ///< Flag for an invalid track
+};
+
+/** Allow incrementing of Track variables */
+DECLARE_POSTFIX_INCREMENT(Track);
+/** Define basic enum properties */
+template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
+typedef TinyEnumT<Track> TrackByte;
+
+
+/** Bitfield corresponding to Track */
+enum TrackBits {
+	TRACK_BIT_NONE    = 0U,                                                 ///< No track
+	TRACK_BIT_X       = 1U << TRACK_X,                                      ///< X-axis track
+	TRACK_BIT_Y       = 1U << TRACK_Y,                                      ///< Y-axis track
+	TRACK_BIT_UPPER   = 1U << TRACK_UPPER,                                  ///< Upper track
+	TRACK_BIT_LOWER   = 1U << TRACK_LOWER,                                  ///< Lower track
+	TRACK_BIT_LEFT    = 1U << TRACK_LEFT,                                   ///< Left track
+	TRACK_BIT_RIGHT   = 1U << TRACK_RIGHT,                                  ///< Right track
+	TRACK_BIT_CROSS   = TRACK_BIT_X     | TRACK_BIT_Y,                      ///< X-Y-axis cross
+	TRACK_BIT_HORZ    = TRACK_BIT_UPPER | TRACK_BIT_LOWER,                  ///< Upper and lower track
+	TRACK_BIT_VERT    = TRACK_BIT_LEFT  | TRACK_BIT_RIGHT,                  ///< Left and right track
+	TRACK_BIT_3WAY_NE = TRACK_BIT_X     | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,///< "Arrow" to the north-east
+	TRACK_BIT_3WAY_SE = TRACK_BIT_Y     | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,///< "Arrow" to the south-east
+	TRACK_BIT_3WAY_SW = TRACK_BIT_X     | TRACK_BIT_LOWER | TRACK_BIT_LEFT, ///< "Arrow" to the south-west
+	TRACK_BIT_3WAY_NW = TRACK_BIT_Y     | TRACK_BIT_UPPER | TRACK_BIT_LEFT, ///< "Arrow" to the north-west
+	TRACK_BIT_ALL     = TRACK_BIT_CROSS | TRACK_BIT_HORZ  | TRACK_BIT_VERT, ///< All possible tracks
+	TRACK_BIT_MASK    = 0x3FU,                                              ///< Bitmask for the first 6 bits
+	TRACK_BIT_WORMHOLE = 0x40U,                                             ///< Bitflag for a wormhole (used for tunnels)
+	TRACK_BIT_DEPOT   = 0x80U,                                              ///< Bitflag for a depot
+	INVALID_TRACK_BIT = 0xFF                                                ///< Flag for an invalid trackbits value
+};
+
+/** Define basic enum properties */
+template <> struct EnumPropsT<TrackBits> : MakeEnumPropsT<TrackBits, byte, TRACK_BIT_NONE, TRACK_BIT_ALL, INVALID_TRACK_BIT> {};
+typedef TinyEnumT<TrackBits> TrackBitsByte;
+
+DECLARE_ENUM_AS_BIT_SET(TrackBits);
+
+/**
+ * Enumeration for tracks and directions.
+ *
+ * These are a combination of tracks and directions. Values are 0-5 in one
+ * direction (corresponding to the Track enum) and 8-13 in the other direction.
+ * 6, 7, 14 and 15 are used to encode the reversing of road vehicles. Those
+ * reversing track dirs are not considered to be 'valid' except in a small
+ * corner in the road vehicle controller.
+ */
+enum Trackdir {
+	TRACKDIR_BEGIN    =  0,         ///< Used for iterations
+	TRACKDIR_X_NE     =  0,         ///< X-axis and direction to north-east
+	TRACKDIR_Y_SE     =  1,         ///< Y-axis and direction to south-east
+	TRACKDIR_UPPER_E  =  2,         ///< Upper track and direction to east
+	TRACKDIR_LOWER_E  =  3,         ///< Lower track and direction to east
+	TRACKDIR_LEFT_S   =  4,         ///< Left track and direction to south
+	TRACKDIR_RIGHT_S  =  5,         ///< Right track and direction to south
+	TRACKDIR_RVREV_NE =  6,         ///< (Road vehicle) reverse direction north-east
+	TRACKDIR_RVREV_SE =  7,         ///< (Road vehicle) reverse direction south-east
+	TRACKDIR_X_SW     =  8,         ///< X-axis and direction to south-west
+	TRACKDIR_Y_NW     =  9,         ///< Y-axis and direction to north-west
+	TRACKDIR_UPPER_W  = 10,         ///< Upper track and direction to west
+	TRACKDIR_LOWER_W  = 11,         ///< Lower track and direction to west
+	TRACKDIR_LEFT_N   = 12,         ///< Left track and direction to north
+	TRACKDIR_RIGHT_N  = 13,         ///< Right track and direction to north
+	TRACKDIR_RVREV_SW = 14,         ///< (Road vehicle) reverse direction south-west
+	TRACKDIR_RVREV_NW = 15,         ///< (Road vehicle) reverse direction north-west
+	TRACKDIR_END,                   ///< Used for iterations
+	INVALID_TRACKDIR  = 0xFF,       ///< Flag for an invalid trackdir
+};
+
+/** Define basic enum properties */
+template <> struct EnumPropsT<Trackdir> : MakeEnumPropsT<Trackdir, byte, TRACKDIR_BEGIN, TRACKDIR_END, INVALID_TRACKDIR> {};
+typedef TinyEnumT<Trackdir> TrackdirByte;
+
+/**
+ * Enumeration of bitmasks for the TrackDirs
+ *
+ * These are a combination of tracks and directions. Values are 0-5 in one
+ * direction (corresponding to the Track enum) and 8-13 in the other direction.
+ */
+enum TrackdirBits {
+	TRACKDIR_BIT_NONE     = 0x0000, ///< No track build
+	TRACKDIR_BIT_X_NE     = 0x0001, ///< Track x-axis, direction north-east
+	TRACKDIR_BIT_Y_SE     = 0x0002, ///< Track y-axis, direction south-east
+	TRACKDIR_BIT_UPPER_E  = 0x0004, ///< Track upper, direction east
+	TRACKDIR_BIT_LOWER_E  = 0x0008, ///< Track lower, direction east
+	TRACKDIR_BIT_LEFT_S   = 0x0010, ///< Track left, direction south
+	TRACKDIR_BIT_RIGHT_S  = 0x0020, ///< Track right, direction south
+	/* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
+	TRACKDIR_BIT_X_SW     = 0x0100, ///< Track x-axis, direction south-west
+	TRACKDIR_BIT_Y_NW     = 0x0200, ///< Track y-axis, direction north-west
+	TRACKDIR_BIT_UPPER_W  = 0x0400, ///< Track upper, direction west
+	TRACKDIR_BIT_LOWER_W  = 0x0800, ///< Track lower, direction west
+	TRACKDIR_BIT_LEFT_N   = 0x1000, ///< Track left, direction north
+	TRACKDIR_BIT_RIGHT_N  = 0x2000, ///< Track right, direction north
+	TRACKDIR_BIT_MASK     = 0x3F3F, ///< Bitmask for bit-operations
+	INVALID_TRACKDIR_BIT  = 0xFFFF, ///< Flag for an invalid trackdirbit value
+};
+
+/** Define basic enum properties */
+template <> struct EnumPropsT<TrackdirBits> : MakeEnumPropsT<TrackdirBits, uint16, TRACKDIR_BIT_NONE, TRACKDIR_BIT_MASK, INVALID_TRACKDIR_BIT> {};
+typedef TinyEnumT<TrackdirBits> TrackdirBitsShort;
+DECLARE_ENUM_AS_BIT_SET(TrackdirBits);
+
+#endif /* TRACK_TYPE_H */
--- a/src/train.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/train.h	Wed Jan 09 18:11:12 2008 +0000
@@ -6,7 +6,8 @@
 #define TRAIN_H
 
 #include "stdafx.h"
-#include "vehicle.h"
+#include "core/bitmath_func.hpp"
+#include "vehicle_base.h"
 
 
 /*
--- a/src/train_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/train_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,19 +6,15 @@
 #include "openttd.h"
 #include "bridge_map.h"
 #include "debug.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
 #include "gui.h"
 #include "station_map.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "map.h"
-#include "tile.h"
 #include "tunnel_map.h"
-#include "vehicle.h"
 #include "timetable.h"
 #include "articulated_vehicles.h"
-#include "command.h"
+#include "command_func.h"
 #include "pathfind.h"
 #include "npf.h"
 #include "station.h"
@@ -26,7 +22,6 @@
 #include "news.h"
 #include "engine.h"
 #include "player.h"
-#include "sound.h"
 #include "depot.h"
 #include "waypoint.h"
 #include "vehicle_gui.h"
@@ -36,14 +31,24 @@
 #include "newgrf_engine.h"
 #include "newgrf_sound.h"
 #include "newgrf_text.h"
-#include "direction.h"
+#include "direction_func.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "cargotype.h"
 #include "group.h"
 #include "table/sprites.h"
+#include "tunnelbridge_map.h"
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "variables.h"
+#include "autoreplace_gui.h"
+#include "gfx_func.h"
 #include "ai/ai.h"
 
+
 static bool TrainCheckIfLineEnds(Vehicle *v);
 static void TrainController(Vehicle *v, bool update_image);
 
@@ -163,12 +168,16 @@
 	v->u.rail.cached_total_length = 0;
 	v->u.rail.compatible_railtypes = 0;
 
+	bool train_can_tilt = true;
+
 	for (Vehicle *u = v; u != NULL; u = u->Next()) {
 		const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
 
 		/* Check the v->first cache. */
 		assert(u->First() == v);
 
+		if (!HasBit(EngInfo(u->engine_type)->misc_flags, EF_RAIL_TILTS)) train_can_tilt = false;
+
 		/* update the 'first engine' */
 		u->u.rail.first_engine = v == u ? INVALID_ENGINE : first_engine;
 		u->u.rail.railtype = rvi_u->railtype;
@@ -252,35 +261,12 @@
 
 	/* store consist weight/max speed in cache */
 	v->u.rail.cached_max_speed = max_speed;
+	v->u.rail.cached_tilt = train_can_tilt;
 
 	/* recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added) */
 	TrainCargoChanged(v);
 }
 
-/* These two arrays are used for realistic acceleration. XXX: How should they
- * be interpreted? */
-static const byte _curve_neighbours45[8][2] = {
-	{7, 1},
-	{0, 2},
-	{1, 3},
-	{2, 4},
-	{3, 5},
-	{4, 6},
-	{5, 7},
-	{6, 0},
-};
-
-static const byte _curve_neighbours90[8][2] = {
-	{6, 2},
-	{7, 3},
-	{0, 4},
-	{1, 5},
-	{2, 6},
-	{3, 7},
-	{4, 0},
-	{5, 1},
-};
-
 enum AccelType {
 	AM_ACCEL,
 	AM_BRAKE
@@ -310,7 +296,8 @@
 /** new acceleration*/
 static int GetTrainAcceleration(Vehicle *v, bool mode)
 {
-	int max_speed = 2000;
+	static const int absolute_max_speed = 2000;
+	int max_speed = absolute_max_speed;
 	int speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h
 	int curvecount[2] = {0, 0};
 
@@ -320,57 +307,66 @@
 	int pos = 0;
 	int lastpos = -1;
 	for (const Vehicle *u = v; u->Next() != NULL; u = u->Next(), pos++) {
-		Direction dir = u->direction;
-		Direction ndir = u->Next()->direction;
-		int i;
-
-		for (i = 0; i < 2; i++) {
-			if ( _curve_neighbours45[dir][i] == ndir) {
-				curvecount[i]++;
-				if (lastpos != -1) {
-					numcurve++;
-					sum += pos - lastpos;
-					if (pos - lastpos == 1) {
-						max_speed = 88;
-					}
+		Direction this_dir = u->direction;
+		Direction next_dir = u->Next()->direction;
+
+		DirDiff dirdiff = DirDifference(this_dir, next_dir);
+		if (dirdiff == DIRDIFF_SAME) continue;
+
+		if (dirdiff == DIRDIFF_45LEFT) curvecount[0]++;
+		if (dirdiff == DIRDIFF_45RIGHT) curvecount[1]++;
+		if (dirdiff == DIRDIFF_45LEFT || dirdiff == DIRDIFF_45RIGHT) {
+			if (lastpos != -1) {
+				numcurve++;
+				sum += pos - lastpos;
+				if (pos - lastpos == 1) {
+					max_speed = 88;
 				}
-				lastpos = pos;
 			}
+			lastpos = pos;
 		}
 
 		/*if we have a 90 degree turn, fix the speed limit to 60 */
-		if (_curve_neighbours90[dir][0] == ndir ||
-				_curve_neighbours90[dir][1] == ndir) {
+		if (dirdiff == DIRDIFF_90LEFT || dirdiff == DIRDIFF_90RIGHT) {
 			max_speed = 61;
 		}
 	}
 
-	if (numcurve > 0) sum /= numcurve;
-
 	if ((curvecount[0] != 0 || curvecount[1] != 0) && max_speed > 88) {
 		int total = curvecount[0] + curvecount[1];
 
 		if (curvecount[0] == 1 && curvecount[1] == 1) {
-			max_speed = 0xFFFF;
+			max_speed = absolute_max_speed;
 		} else if (total > 1) {
+			if (numcurve > 0) sum /= numcurve;
 			max_speed = 232 - (13 - Clamp(sum, 1, 12)) * (13 - Clamp(sum, 1, 12));
 		}
 	}
 
-	max_speed += (max_speed / 2) * v->u.rail.railtype;
+	if (max_speed != absolute_max_speed) {
+		/* Apply the engine's rail type curve speed advantage, if it slowed by curves */
+		const RailtypeInfo *rti = GetRailTypeInfo(v->u.rail.railtype);
+		max_speed += (max_speed / 2) * rti->curve_speed;
+
+		if (v->u.rail.cached_tilt) {
+			/* Apply max_speed bonus of 20% for a tilting train */
+			max_speed += max_speed / 5;
+		}
+	}
 
 	if (IsTileType(v->tile, MP_STATION) && IsFrontEngine(v)) {
 		if (TrainShouldStop(v, v->tile)) {
 			int station_length = GetStationByTile(v->tile)->GetPlatformLength(v->tile, DirToDiagDir(v->direction));
-			int delta_v;
-
-			max_speed = 120;
-
-			delta_v = v->cur_speed / (station_length + 1);
-			if (v->max_speed > (v->cur_speed - delta_v))
-				max_speed = v->cur_speed - (delta_v / 10);
-
-			max_speed = max(max_speed, 25 * station_length);
+
+			int st_max_speed = 120;
+
+			int delta_v = v->cur_speed / (station_length + 1);
+			if (v->max_speed > (v->cur_speed - delta_v)) {
+				st_max_speed = v->cur_speed - (delta_v / 10);
+			}
+
+			st_max_speed = max(st_max_speed, 25 * station_length);
+			max_speed = min(max_speed, st_max_speed);
 		}
 	}
 
@@ -469,7 +465,7 @@
 	if (is_custom_sprite(img)) {
 		base = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(img)));
 		if (base != 0) return base;
-		img = orig_rail_vehicle_info[this->engine_type].image_index;
+		img = _orig_rail_vehicle_info[this->engine_type].image_index;
 	}
 
 	base = _engine_sprite_base[img] + ((direction + _engine_sprite_add[img]) & _engine_sprite_and[img]);
@@ -488,7 +484,7 @@
 	if (is_custom_sprite(img)) {
 		image = GetCustomVehicleIcon(engine, DIR_W);
 		if (image == 0) {
-			img = orig_rail_vehicle_info[engine].image_index;
+			img = _orig_rail_vehicle_info[engine].image_index;
 		} else {
 			y += _traininfo_vehicle_pitch;
 		}
@@ -503,7 +499,7 @@
 		image = 0;
 		if (is_custom_sprite(img)) {
 			image = GetCustomVehicleIcon(engine, DIR_E);
-			if (image == 0) img = orig_rail_vehicle_info[engine].image_index;
+			if (image == 0) img = _orig_rail_vehicle_info[engine].image_index;
 		}
 		if (image == 0) {
 			image =
@@ -516,10 +512,8 @@
 
 static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
 {
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
 	const RailVehicleInfo *rvi = RailVehInfo(engine);
-	CommandCost value((GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8);
+	CommandCost value(EXPENSES_NEW_VEHICLES, (GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8);
 
 	uint num_vehicles = 1 + CountArticulatedParts(engine, false);
 
@@ -605,7 +599,7 @@
 		}
 	}
 
-	return CommandCost(value);
+	return value;
 }
 
 /** Move all free vehicles in the depot to the train */
@@ -626,7 +620,7 @@
 
 static CommandCost EstimateTrainCost(EngineID engine, const RailVehicleInfo* rvi)
 {
-	return CommandCost(GetEngineProperty(engine, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5);
+	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5);
 }
 
 static void AddRearEngineToMultiheadedTrain(Vehicle* v, Vehicle* u, bool building)
@@ -676,8 +670,6 @@
 		if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 	}
 
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
 	const RailVehicleInfo *rvi = RailVehInfo(p1);
 
 	/* Check if depot and new engine uses the same kind of tracks */
@@ -886,6 +878,7 @@
 	if (dest == NULL) return;
 
 	Vehicle *next = dest->Next();
+	v->SetNext(NULL);
 	dest->SetNext(v);
 	v->SetNext(next);
 	ClearFreeWagon(v);
@@ -1025,16 +1018,101 @@
 		if (flags & DC_EXEC) src->unitnumber = unit_num;
 	}
 
-	if (dst_head != NULL) {
-		/* Check NewGRF Callback 0x1D */
-		uint16 callback = GetVehicleCallbackParent(CBID_TRAIN_ALLOW_WAGON_ATTACH, 0, 0, dst_head->engine_type, src, dst_head);
-		if (callback != CALLBACK_FAILED) {
-			if (callback == 0xFD) return_cmd_error(STR_INCOMPATIBLE_RAIL_TYPES);
-			if (callback < 0xFD) {
-				StringID error = GetGRFStringID(GetEngineGRFID(dst_head->engine_type), 0xD000 + callback);
-				return_cmd_error(error);
+	/*
+	 * Check whether the vehicles in the source chain are in the destination
+	 * chain. This can easily be done by checking whether the first vehicle
+	 * of the source chain is in the destination chain as the Next/Previous
+	 * pointers always make a doubly linked list of it where the assumption
+	 * v->Next()->Previous() == v holds (assuming v->Next() != NULL).
+	 */
+	bool src_in_dst = false;
+	for (Vehicle *v = dst_head; !src_in_dst && v != NULL; v = v->Next()) src_in_dst = v == src;
+
+	/*
+	 * If the source chain is in the destination chain then the user is
+	 * only reordering the vehicles, thus not attaching a new vehicle.
+	 * Therefor the 'allow wagon attach' callback does not need to be
+	 * called. If it would be called strange things would happen because
+	 * one 'attaches' an already 'attached' vehicle causing more trouble
+	 * than it actually solves (infinite loops and such).
+	 */
+	if (dst_head != NULL && !src_in_dst) {
+		/*
+		 * When performing the 'allow wagon attach' callback, we have to check
+		 * that for each and every wagon, not only the first one. This means
+		 * that we have to test one wagon, attach it to the train and then test
+		 * the next wagon till we have reached the end. We have to restore it
+		 * to the state it was before we 'tried' attaching the train when the
+		 * attaching fails or succeeds because we are not 'only' doing this
+		 * in the DC_EXEC state.
+		 */
+		Vehicle *dst_tail = dst_head;
+		while (dst_tail->Next() != NULL) dst_tail = dst_tail->Next();
+
+		Vehicle *orig_tail = dst_tail;
+		Vehicle *next_to_attach = src;
+		Vehicle *src_previous = src->Previous();
+
+		while (next_to_attach != NULL) {
+			/* Back up and clear the first_engine data to avoid using wagon override group */
+			EngineID first_engine = next_to_attach->u.rail.first_engine;
+			next_to_attach->u.rail.first_engine = INVALID_ENGINE;
+
+			uint16 callback = GetVehicleCallbackParent(CBID_TRAIN_ALLOW_WAGON_ATTACH, 0, 0, dst_head->engine_type, next_to_attach, dst_head);
+
+			/* Restore original first_engine data */
+			next_to_attach->u.rail.first_engine = first_engine;
+
+			if (callback != CALLBACK_FAILED) {
+				StringID error = STR_NULL;
+
+				if (callback == 0xFD) error = STR_INCOMPATIBLE_RAIL_TYPES;
+				if (callback < 0xFD) error = GetGRFStringID(GetEngineGRFID(dst_head->engine_type), 0xD000 + callback);
+
+				if (error != STR_NULL) {
+					/*
+					 * The attaching is not allowed. In this case 'next_to_attach'
+					 * can contain some vehicles of the 'source' and the destination
+					 * train can have some too. We 'just' add the to-be added wagons
+					 * to the chain and then split it where it was previously
+					 * separated, i.e. the tail of the original destination train.
+					 * Furthermore the 'previous' link of the original source vehicle needs
+					 * to be restored, otherwise the train goes missing in the depot.
+					 */
+					dst_tail->SetNext(next_to_attach);
+					orig_tail->SetNext(NULL);
+					if (src_previous != NULL) src_previous->SetNext(src);
+
+					return_cmd_error(error);
+				}
 			}
+
+			/* Only check further wagons if told to move the chain */
+			if (!HasBit(p2, 0)) break;
+
+			/*
+			 * Adding a next wagon to the chain so we can test the other wagons.
+			 * First 'take' the first wagon from 'next_to_attach' and move it
+			 * to the next wagon. Then add that to the tail of the destination
+			 * train and update the tail with the new vehicle.
+			 */
+			Vehicle *to_add = next_to_attach;
+			next_to_attach = next_to_attach->Next();
+
+			to_add->SetNext(NULL);
+			dst_tail->SetNext(to_add);
+			dst_tail = dst_tail->Next();
 		}
+
+		/*
+		 * When we reach this the attaching is allowed. It also means that the
+		 * chain of vehicles to attach is empty, so we do not need to merge that.
+		 * This means only the splitting needs to be done.
+		 * Furthermore the 'previous' link of the original source vehicle needs
+		 * to be restored, otherwise the train goes missing in the depot.
+		 */
+		orig_tail->SetNext(NULL);
+		if (src_previous != NULL) src_previous->SetNext(src);
 	}
 
 	/* do it? */
@@ -1232,8 +1310,6 @@
 
 	if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE);
 
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
 	while (IsArticulatedPart(v)) v = v->Previous();
 	Vehicle *first = v->First();
 
@@ -1253,7 +1329,7 @@
 		RebuildVehicleLists();
 	}
 
-	CommandCost cost;
+	CommandCost cost(EXPENSES_NEW_VEHICLES);
 	switch (p2) {
 		case 0: case 2: { /* Delete given wagon */
 			bool switch_engine = false;    // update second wagon to engine?
@@ -1528,15 +1604,15 @@
 /* Check if the vehicle is a train and is on the tile we are testing */
 static void *TestTrainOnCrossing(Vehicle *v, void *data)
 {
-	if (v->tile != *(const TileIndex*)data || v->type != VEH_TRAIN) return NULL;
+	if (v->type != VEH_TRAIN) return NULL;
 	return v;
 }
 
 static void DisableTrainCrossing(TileIndex tile)
 {
 	if (IsLevelCrossingTile(tile) &&
-			VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL && // empty?
-			IsCrossingBarred(tile)) {
+			IsCrossingBarred(tile) &&
+			VehicleFromPos(tile, NULL, &TestTrainOnCrossing) == NULL) { // empty?
 		UnbarCrossing(tile);
 		MarkTileDirtyByTile(tile);
 	}
@@ -1568,6 +1644,8 @@
 			Vehicle *tempnext = last->Next();
 			last->SetNext(NULL);
 
+			/* do not update images now because the wagons are disconnected
+			 * and that could cause problems with NewGRFs */
 			for (int i = 0; i < differential; i++) TrainController(first, false);
 
 			last->SetNext(tempnext);
@@ -1603,9 +1681,8 @@
 	}
 
 	/* count number of vehicles */
-	int r = -1;
-	const Vehicle *u = v;
-	do r++; while ((u = u->Next()) != NULL);
+	int r = 0;  ///< number of vehicles - 1
+	for (const Vehicle *u = v; (u = u->Next()) != NULL;) { r++; }
 
 	AdvanceWagons(v, true);
 
@@ -1621,6 +1698,9 @@
 		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 	}
 
+	/* update all images */
+	for (Vehicle *u = v; u != NULL; u = u->Next()) { u->cur_image = u->GetImage(u->direction); }
+
 	ClrBit(v->u.rail.flags, VRF_REVERSING);
 }
 
@@ -1714,13 +1794,12 @@
 
 	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
 	if (CheckTrainStoppedInDepot(v) < 0) return_cmd_error(STR_TRAIN_MUST_BE_STOPPED);
+	if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_REFIT_DESTROYED_VEHICLE);
 
 	/* Check cargo */
 	if (new_cid >= NUM_CARGO) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_TRAIN_RUN);
-
-	CommandCost cost;
+	CommandCost cost(EXPENSES_TRAIN_RUN);
 	uint num = 0;
 
 	do {
@@ -2016,7 +2095,7 @@
 
 		case 1:
 			/* diesel smoke */
-			if (u->cur_speed <= 40 && CHANCE16(15, 128)) {
+			if (u->cur_speed <= 40 && Chance16(15, 128)) {
 				CreateEffectVehicleRel(v, 0, 0, 10, EV_DIESEL_SMOKE);
 				sound = true;
 			}
@@ -2024,7 +2103,7 @@
 
 		case 2:
 			/* blue spark */
-			if (GB(v->tick_counter, 0, 2) == 0 && CHANCE16(1, 45)) {
+			if (GB(v->tick_counter, 0, 2) == 0 && Chance16(1, 45)) {
 				CreateEffectVehicleRel(v, 0, 0, 10, EV_ELECTRIC_SPARK);
 				sound = true;
 			}
@@ -2595,13 +2674,6 @@
 	return _new_vehicle_direction_table[offs];
 }
 
-static Direction GetNewVehicleDirection(const Vehicle *v, int x, int y)
-{
-	uint offs = (y - v->y_pos + 1) * 4 + (x - v->x_pos + 1);
-	assert(offs < 11);
-	return _new_vehicle_direction_table[offs];
-}
-
 static int GetDirectionToVehicle(const Vehicle *v, int x, int y)
 {
 	byte offs;
@@ -2775,11 +2847,7 @@
 	/* find colliding vehicles */
 	if (v->u.rail.track == TRACK_BIT_WORMHOLE) {
 		VehicleFromPos(v->tile, &tcc, FindTrainCollideEnum);
-		if (IsBridgeTile(v->tile)) {
-			VehicleFromPos(GetOtherBridgeEnd(v->tile), &tcc, FindTrainCollideEnum);
-		} else {
-			VehicleFromPos(GetOtherTunnelEnd(v->tile), &tcc, FindTrainCollideEnum);
-		}
+		VehicleFromPos(GetOtherTunnelBridgeEnd(v->tile), &tcc, FindTrainCollideEnum);
 	} else {
 		VehicleFromPosXY(v->x_pos, v->y_pos, &tcc, FindTrainCollideEnum);
 	}
@@ -2799,17 +2867,12 @@
 	SndPlayVehicleFx(SND_13_BIG_CRASH, v);
 }
 
-struct VehicleAtSignalData {
-	TileIndex tile;
-	Direction direction;
-};
-
 static void *CheckVehicleAtSignal(Vehicle *v, void *data)
 {
-	const VehicleAtSignalData* vasd = (VehicleAtSignalData*)data;
-
-	if (v->type == VEH_TRAIN && IsFrontEngine(v) && v->tile == vasd->tile) {
-		DirDiff diff = ChangeDirDiff(DirDifference(v->direction, vasd->direction), DIRDIFF_90RIGHT);
+	Direction dir = *(Direction*)data;
+
+	if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
+		DirDiff diff = ChangeDirDiff(DirDifference(v->direction, dir), DIRDIFF_90RIGHT);
 
 		if (diff == DIRDIFF_90RIGHT || (v->cur_speed <= 5 && diff <= DIRDIFF_REVERSE)) return v;
 	}
@@ -2908,12 +2971,10 @@
 							v->progress = 255 - 10;
 							if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) {
 								TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir);
-								VehicleAtSignalData vasd;
-								vasd.tile = o_tile;
-								vasd.direction = ReverseDir(dir);
+								Direction rdir = ReverseDir(dir);
 
 								/* check if a train is waiting on the other side */
-								if (VehicleFromPos(o_tile, &vasd, CheckVehicleAtSignal) == NULL) return;
+								if (VehicleFromPos(o_tile, &rdir, &CheckVehicleAtSignal) == NULL) return;
 							}
 						}
 						goto reverse_train_direction;
@@ -2975,7 +3036,9 @@
 				v->direction = chosen_dir;
 			}
 		} else {
-			/* In tunnel or on a bridge */
+			/* In a tunnel or on a bridge
+			 * - for tunnels, only the part when the vehicle is not visible (part of enter/exit tile too)
+			 * - for bridges, only the middle part - without the bridge heads */
 			if (!(v->vehstatus & VS_HIDDEN)) {
 				v->cur_speed =
 					min(v->cur_speed, GetBridge(GetBridgeType(v->tile))->speed);
@@ -2991,9 +3054,8 @@
 		}
 
 		/* update image of train, as well as delta XY */
-		Direction newdir = GetNewVehicleDirection(v, gp.x, gp.y);
-		v->UpdateDeltaXY(newdir);
-		if (update_image) v->cur_image = v->GetImage(newdir);
+		v->UpdateDeltaXY(v->direction);
+		if (update_image) v->cur_image = v->GetImage(v->direction);
 
 		v->x_pos = gp.x;
 		v->y_pos = gp.y;
@@ -3027,13 +3089,11 @@
 	ReverseTrainDirection(v);
 }
 
-extern TileIndex CheckTunnelBusy(TileIndex tile, uint *length);
-
 /**
  * Deletes/Clears the last wagon of a crashed train. It takes the engine of the
  * train, then goes to the last wagon and deletes that. Each call to this function
  * will remove the last wagon of a crashed train. If this wagon was on a crossing,
- * or inside a tunnel, recalculate the signals as they might need updating
+ * or inside a tunnel/bridge, recalculate the signals as they might need updating
  * @param v the Vehicle of which last wagon is to be removed
  */
 static void DeleteLastWagon(Vehicle *v)
@@ -3062,27 +3122,16 @@
 	 * others are on it */
 	DisableTrainCrossing(v->tile);
 
-	if ((v->u.rail.track == TRACK_BIT_WORMHOLE && v->vehstatus & VS_HIDDEN)) { // inside a tunnel
-		TileIndex endtile = CheckTunnelBusy(v->tile, NULL);
-
-		if (endtile == INVALID_TILE) return; // tunnel is busy (error returned)
-
-		switch (v->direction) {
-			case 1:
-			case 5:
-				SetSignalsOnBothDir(v->tile, 0);
-				SetSignalsOnBothDir(endtile, 0);
-				break;
-
-			case 3:
-			case 7:
-				SetSignalsOnBothDir(v->tile, 1);
-				SetSignalsOnBothDir(endtile, 1);
-				break;
-
-			default:
-				break;
-		}
+	if (v->u.rail.track == TRACK_BIT_WORMHOLE) { // inside a tunnel / bridge
+		TileIndex endtile = GetOtherTunnelBridgeEnd(v->tile);
+
+		if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy
+
+		DiagDirection dir = GetTunnelBridgeDirection(v->tile);
+
+		/* v->direction is "random", so it cannot be used to determine the direction of the track */
+		UpdateSignalsOnSegment(v->tile, dir);
+		UpdateSignalsOnSegment(endtile, ReverseDiagDir(dir));
 	}
 }
 
@@ -3116,7 +3165,7 @@
 	}
 
 	uint32 r;
-	if (state <= 200 && CHANCE16R(1, 7, r)) {
+	if (state <= 200 && Chance16R(1, 7, r)) {
 		int index = (r * 10 >> 16);
 
 		Vehicle *u = v;
@@ -3195,7 +3244,7 @@
 	TileIndex tile = v->tile;
 
 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
-		DiagDirection dir = IsTunnel(tile) ? GetTunnelDirection(tile) : GetBridgeRampDirection(tile);
+		DiagDirection dir = GetTunnelBridgeDirection(tile);
 		if (DiagDirToDir(dir) == v->direction) return true;
 	}
 
@@ -3241,8 +3290,9 @@
 			return false;
 		}
 		if ((ts &= (ts >> 16)) == 0) {
-			/* make a rail/road crossing red */
-			if (IsLevelCrossingTile(tile)) {
+			/* make a rail/road crossing red
+			 * do not make crossing red behind depot the train is entering */
+			if (IsLevelCrossingTile(tile) && (!IsTileDepotType(v->tile, TRANSPORT_RAIL) || GetRailDepotDirection(v->tile) == dir)) {
 				if (!IsCrossingBarred(tile)) {
 					BarCrossing(tile);
 					SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
@@ -3394,7 +3444,7 @@
 
 	if (v->current_order.type == OT_GOTO_DEPOT &&
 			v->current_order.dest != depot->index &&
-			!CHANCE16(3, 16)) {
+			!Chance16(3, 16)) {
 		return;
 	}
 
@@ -3425,11 +3475,10 @@
 
 		if ((v->vehstatus & VS_STOPPED) == 0) {
 			/* running costs */
-			CommandCost cost(v->GetRunningCost() / 364);
+			CommandCost cost(EXPENSES_TRAIN_RUN, v->GetRunningCost() / 364);
 
 			v->profit_this_year -= cost.GetCost() >> 8;
 
-			SET_EXPENSES_TYPE(EXPENSES_TRAIN_RUN);
 			SubtractMoneyFromPlayerFract(v->owner, cost);
 
 			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
--- a/src/train_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/train_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,19 +5,19 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "window.h"
 #include "gui.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "command.h"
+#include "window_gui.h"
+#include "gfx_func.h"
+#include "command_func.h"
 #include "vehicle_gui.h"
 #include "depot.h"
 #include "train.h"
 #include "newgrf_engine.h"
+#include "strings_func.h"
+#include "vehicle_func.h"
+#include "settings_type.h"
 
 void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
@@ -69,7 +69,7 @@
 	return (len * _traininfo_vehicle_width) / 8;
 }
 
-void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
+void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip)
 {
 	DrawPixelInfo tmp_dpi, *old_dpi;
 	int dx = -(skip * 8) / _traininfo_vehicle_width;
--- a/src/transparency.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/transparency.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef TRANSPARENCY_H
 #define TRANSPARENCY_H
 
+#include "gfx_func.h"
+
 /**
  * Transparency option bits: which position in _transparency_opt stands for which transparency.
  * If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too.
--- a/src/transparency_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/transparency_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,14 +4,11 @@
 #include "openttd.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
-#include "window.h"
 #include "gui.h"
-#include "viewport.h"
-#include "gfx.h"
-#include "sound.h"
+#include "window_gui.h"
 #include "variables.h"
 #include "transparency.h"
+#include "sound_func.h"
 
 TransparencyOptionBits _transparency_opt;
 
@@ -37,7 +34,7 @@
 			/* must be sure that the widgets show the transparency variable changes
 			 * also when we use shortcuts */
 			for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) {
-				SetWindowWidgetLoweredState(w, i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_SIGNS)));
+				w->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_SIGNS)));
 			}
 			DrawWindowWidgets(w);
 			break;
--- a/src/tree_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/tree_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -9,18 +9,19 @@
 #include "table/strings.h"
 #include "table/sprites.h"
 #include "table/tree_land.h"
-#include "functions.h"
-#include "map.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "tile.h"
 #include "tree_map.h"
-#include "viewport.h"
-#include "command.h"
+#include "viewport_func.h"
+#include "command_func.h"
+#include "economy_func.h"
 #include "town.h"
-#include "sound.h"
 #include "variables.h"
 #include "genworld.h"
 #include "transparency.h"
+#include "functions.h"
+#include "player.h"
+#include "sound_func.h"
 
 /**
  * List of tree placer algorithm.
@@ -164,7 +165,7 @@
 			continue;
 
 		/* Not too much height difference */
-		if (delta(GetTileZ(cur_tile), height) > 2) continue;
+		if (Delta(GetTileZ(cur_tile), height) > 2) continue;
 
 		/* Place one tree and quit */
 		PlaceTree(cur_tile, r);
@@ -272,7 +273,7 @@
 CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	StringID msg = INVALID_STRING_ID;
-	CommandCost cost;
+	CommandCost cost(EXPENSES_OTHER);
 	int ex;
 	int ey;
 	int sx, sy, x, y;
@@ -281,8 +282,6 @@
 	/* Check the tree type. It can be random or some valid value within the current climate */
 	if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_opt.landscape] >= _tree_count_by_landscape[_opt.landscape]) return CMD_ERROR;
 
-	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-
 	// make sure sx,sy are smaller than ex,ey
 	ex = TileX(tile);
 	ey = TileY(tile);
@@ -324,21 +323,20 @@
 					}
 
 					switch (GetClearGround(tile)) {
-						case CLEAR_FIELDS: cost.AddCost(_price.clear_3); break;
-						case CLEAR_ROCKS:  cost.AddCost(_price.clear_2); break;
+						case CLEAR_FIELDS: cost.AddCost(_price.clear_fields); break;
+						case CLEAR_ROCKS:  cost.AddCost(_price.clear_rocks); break;
 						default: break;
 					}
 
+					if (_game_mode != GM_EDITOR && IsValidPlayer(_current_player)) {
+						Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
+						if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
+					}
+
 					if (flags & DC_EXEC) {
 						TreeType treetype;
 						uint growth;
 
-						if (_game_mode != GM_EDITOR && IsValidPlayer(_current_player)) {
-							Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
-							if (t != NULL)
-								ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
-						}
-
 						treetype = (TreeType)p1;
 						if (treetype == TREE_INVALID) {
 							treetype = GetRandomTreeType(tile, GB(Random(), 24, 8));
@@ -354,7 +352,7 @@
 						}
 						MarkTileDirtyByTile(tile);
 
-						if (_game_mode == GM_EDITOR && IS_INT_INSIDE(treetype, TREE_RAINFOREST, TREE_CACTUS))
+						if (_game_mode == GM_EDITOR && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS))
 							SetTropicZone(tile, TROPICZONE_RAINFOREST);
 					}
 					cost.AddCost(_price.build_trees);
@@ -418,7 +416,7 @@
 		/* different tree styles above one of the grounds */
 		if (GetTreeGround(ti->tile) == TREE_GROUND_SNOW_DESERT &&
 				GetTreeDensity(ti->tile) >= 2 &&
-				IS_INT_INSIDE(index, TREE_SUB_ARCTIC << 2, TREE_RAINFOREST << 2)) {
+				IsInsideMM(index, TREE_SUB_ARCTIC << 2, TREE_RAINFOREST << 2)) {
 			index += 164 - (TREE_SUB_ARCTIC << 2);
 		}
 
@@ -487,18 +485,17 @@
 {
 	uint num;
 
-	if ((flags & DC_EXEC) && IsValidPlayer(_current_player)) {
+	if (IsValidPlayer(_current_player)) {
 		Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
-		if (t != NULL)
-			ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
+		if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
 	}
 
 	num = GetTreeCount(tile) + 1;
-	if (IS_INT_INSIDE(GetTreeType(tile), TREE_RAINFOREST, TREE_CACTUS)) num *= 4;
+	if (IsInsideMM(GetTreeType(tile), TREE_RAINFOREST, TREE_CACTUS)) num *= 4;
 
 	if (flags & DC_EXEC) DoClearSquare(tile);
 
-	return CommandCost(num * _price.remove_trees);
+	return CommandCost(EXPENSES_CONSTRUCTION, num * _price.remove_trees);
 }
 
 static void GetAcceptedCargo_Trees(TileIndex tile, AcceptedCargo ac)
@@ -510,7 +507,7 @@
 {
 	TreeType tt = GetTreeType(tile);
 
-	if (IS_INT_INSIDE(tt, TREE_RAINFOREST, TREE_CACTUS)) {
+	if (IsInsideMM(tt, TREE_RAINFOREST, TREE_CACTUS)) {
 		td->str = STR_280F_RAINFOREST;
 	} else {
 		td->str = tt == TREE_CACTUS ? STR_2810_CACTUS_PLANTS : STR_280E_TREES;
@@ -543,7 +540,7 @@
 			};
 			uint32 r = Random();
 
-			if (CHANCE16I(1, 200, r)) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile);
+			if (Chance16I(1, 200, r)) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile);
 			break;
 		}
 
@@ -567,7 +564,7 @@
 		} else {
 			if (GetTreeDensity(tile) == 3) {
 				uint32 r = Random();
-				if (CHANCE16I(1, 200, r)) {
+				if (Chance16I(1, 200, r)) {
 					SndPlayTileFx((r & 0x80000000) ? SND_39_HEAVY_WIND : SND_34_WIND, tile);
 				}
 			}
--- a/src/tree_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/tree_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,8 +5,6 @@
 #ifndef TREE_MAP_H
 #define TREE_MAP_H
 
-#include "macros.h"
-
 /**
  * List of tree types along all landscape types.
  *
--- a/src/tunnel_map.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/tunnel_map.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,8 +4,9 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "tile.h"
 #include "tunnel_map.h"
+#include "tunnelbridge_map.h"
+
 
 /**
  * Gets the other end of the tunnel. Where a vehicle would reappear when it
@@ -15,7 +16,7 @@
  */
 TileIndex GetOtherTunnelEnd(TileIndex tile)
 {
-	DiagDirection dir = GetTunnelDirection(tile);
+	DiagDirection dir = GetTunnelBridgeDirection(tile);
 	TileIndexDiff delta = TileOffsByDiagDir(dir);
 	uint z = GetTileZ(tile);
 
@@ -24,7 +25,7 @@
 		tile += delta;
 	} while (
 		!IsTunnelTile(tile) ||
-		GetTunnelDirection(tile) != dir ||
+		GetTunnelBridgeDirection(tile) != dir ||
 		GetTileZ(tile) != z
 	);
 
@@ -52,7 +53,7 @@
 	return
 		z == height &&
 		IsTunnelTile(tile) &&
-		GetTunnelDirection(tile) == dir;
+		GetTunnelBridgeDirection(tile) == dir;
 }
 
 /**
--- a/src/tunnel_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/tunnel_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,11 +5,11 @@
 #ifndef TUNNEL_MAP_H
 #define TUNNEL_MAP_H
 
-#include "direction.h"
-#include "macros.h"
-#include "map.h"
-#include "rail.h"
-#include "road.h"
+#include "direction_func.h"
+#include "rail_type.h"
+#include "road_type.h"
+#include "tile_map.h"
+
 
 /**
  * Is this a tunnel (entrance)?
@@ -23,7 +23,6 @@
 	return !HasBit(_m[t].m5, 7);
 }
 
-
 /**
  * Is this a tunnel (entrance)?
  * @param t the tile that might be a tunnel
@@ -34,62 +33,10 @@
 	return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
 }
 
-/**
- * Gets the direction facing out of the tunnel
- * @param t the tile to get the tunnel facing direction of
- * @pre IsTunnelTile(t)
- * @return the direction the tunnel is facing
- */
-static inline DiagDirection GetTunnelDirection(TileIndex t)
-{
-	assert(IsTunnelTile(t));
-	return (DiagDirection)GB(_m[t].m5, 0, 2);
-}
-
-/**
- * Gets the transport type of the tunnel (road or rail)
- * @param t the tunnel entrance tile to get the type of
- * @pre IsTunnelTile(t)
- * @return the transport type in the tunnel
- */
-static inline TransportType GetTunnelTransportType(TileIndex t)
-{
-	assert(IsTunnelTile(t));
-	return (TransportType)GB(_m[t].m5, 2, 2);
-}
-
-/**
- * Is this tunnel entrance in a snowy or desert area?
- * @param t the tunnel entrance tile
- * @pre IsTunnelTile(t)
- * @return true if and only if the tunnel entrance is in a snowy/desert area
- */
-static inline bool HasTunnelSnowOrDesert(TileIndex t)
-{
-	assert(IsTunnelTile(t));
-	return HasBit(_m[t].m4, 7);
-}
-
-/**
- * Places this tunnel entrance in a snowy or desert area,
- * or takes it out of there.
- * @param t the tunnel entrance tile
- * @param snow_or_desert is the entrance in snow or desert (true), when
- *                       not in snow and not in desert false
- * @pre IsTunnelTile(t)
- */
-static inline void SetTunnelSnowOrDesert(TileIndex t, bool snow_or_desert)
-{
-	assert(IsTunnelTile(t));
-	SB(_m[t].m4, 7, 1, snow_or_desert);
-}
-
-
 TileIndex GetOtherTunnelEnd(TileIndex);
 bool IsTunnelInWay(TileIndex, uint z);
 bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir);
 
-
 /**
  * Makes a road tunnel entrance
  * @param t the entrance of the tunnel
--- a/src/tunnelbridge_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/tunnelbridge_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -12,30 +12,30 @@
 #include "road_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
-#include "map.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "tile.h"
 #include "tunnel_map.h"
 #include "unmovable_map.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "command.h"
+#include "viewport_func.h"
+#include "command_func.h"
 #include "player.h"
 #include "town.h"
-#include "sound.h"
 #include "variables.h"
 #include "bridge.h"
 #include "train.h"
 #include "water_map.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "newgrf_sound.h"
 #include "autoslope.h"
 #include "transparency.h"
+#include "tunnelbridge_map.h"
+#include "table/bridge_land.h"
+#include "strings_func.h"
+#include "date_func.h"
+#include "functions.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
 
-#include "table/bridge_land.h"
 
 const Bridge orig_bridge[] = {
 /*
@@ -123,7 +123,7 @@
 	valid =
 		BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_N) | M(SLOPE_STEEP_N) |
 		(axis == AXIS_X ? M(SLOPE_E) | M(SLOPE_STEEP_E) : M(SLOPE_W) | M(SLOPE_STEEP_W));
-	if (HasBit(valid, tileh)) return CommandCost(_price.terraform);
+	if (HasBit(valid, tileh)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 
 	return CMD_ERROR;
 }
@@ -138,7 +138,7 @@
 	valid =
 		BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_S) | M(SLOPE_STEEP_S) |
 		(axis == AXIS_X ? M(SLOPE_W) | M(SLOPE_STEEP_W) : M(SLOPE_E) | M(SLOPE_STEEP_E));
-	if (HasBit(valid, tileh)) return CommandCost(_price.terraform);
+	if (HasBit(valid, tileh)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 
 	return CMD_ERROR;
 }
@@ -197,13 +197,12 @@
 	TileIndexDiff delta;
 	uint bridge_len;
 	Axis direction;
-	CommandCost cost, terraformcost, ret;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
+	CommandCost terraformcost, ret;
 	bool allow_on_slopes;
 	bool replace_bridge = false;
 	uint replaced_bridge_type;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* unpack parameters */
 	bridge_type = GB(p2, 0, 8);
 
@@ -265,7 +264,7 @@
 
 	if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) &&
 			GetOtherBridgeEnd(tile_start) == tile_end &&
-			GetBridgeTransportType(tile_start) == transport_type) {
+			GetTunnelBridgeTransportType(tile_start) == transport_type) {
 		/* Replace a current bridge. */
 
 		/* If this is a railway bridge, make sure the railtypes match. */
@@ -390,7 +389,7 @@
 			case MP_TUNNELBRIDGE:
 				if (IsTunnel(tile)) break;
 				if (replace_bridge) break;
-				if (direction == DiagDirToAxis(GetBridgeRampDirection(tile))) goto not_valid_below;
+				if (direction == DiagDirToAxis(GetTunnelBridgeDirection(tile))) goto not_valid_below;
 				if (z_start < GetBridgeHeight(tile)) goto not_valid_below;
 				break;
 
@@ -417,7 +416,7 @@
 		}
 	}
 
-	if (flags & DC_EXEC) {
+	if (flags & DC_EXEC && railtype != INVALID_RAILTYPE) {
 		Track track = AxisToTrack(direction);
 		SetSignalsOnBothDir(tile_start, track);
 		YapfNotifyTrackLayoutChange(tile_start, track);
@@ -457,7 +456,7 @@
 	Slope end_tileh;
 	uint start_z;
 	uint end_z;
-	CommandCost cost;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	CommandCost ret;
 
 	_build_tunnel_endtile = 0;
@@ -560,34 +559,6 @@
 	return cost;
 }
 
-TileIndex CheckTunnelBusy(TileIndex tile, uint *length)
-{
-	uint z = GetTileZ(tile);
-	DiagDirection dir = GetTunnelDirection(tile);
-	TileIndexDiff delta = TileOffsByDiagDir(dir);
-	uint len = 0;
-	TileIndex starttile = tile;
-	Vehicle *v;
-
-	do {
-		tile += delta;
-		len++;
-	} while (
-		!IsTunnelTile(tile) ||
-		ReverseDiagDir(GetTunnelDirection(tile)) != dir ||
-		GetTileZ(tile) != z
-	);
-
-	v = FindVehicleBetween(starttile, tile, z);
-	if (v != NULL) {
-		_error_message = v->type == VEH_TRAIN ?
-			STR_5000_TRAIN_IN_TUNNEL : STR_5001_ROAD_VEHICLE_IN_TUNNEL;
-		return INVALID_TILE;
-	}
-
-	if (length != NULL) *length = len;
-	return tile;
-}
 
 static inline bool CheckAllowRemoveTunnelBridge(TileIndex tile)
 {
@@ -604,14 +575,12 @@
 {
 	Town *t = NULL;
 	TileIndex endtile;
-	uint length;
-
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
 	if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR;
 
-	endtile = CheckTunnelBusy(tile, &length);
-	if (endtile == INVALID_TILE) return CMD_ERROR;
+	endtile = GetOtherTunnelEnd(tile);
+
+	if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR;
 
 	_build_tunnel_endtile = endtile;
 
@@ -626,16 +595,18 @@
 		}
 	}
 
+	/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
+	 * you have a "Poor" (0) town rating */
+	if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
+		ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
+	}
+
 	if (flags & DC_EXEC) {
 		/* We first need to request the direction before calling DoClearSquare
 		 *  else the direction is always 0.. dah!! ;) */
-		DiagDirection dir = GetTunnelDirection(tile);
+		DiagDirection dir = GetTunnelBridgeDirection(tile);
 		Track track;
 
-		/* Adjust the town's player rating. Do this before removing the tile owner info. */
-		if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
-			ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
-
 		DoClearSquare(tile);
 		DoClearSquare(endtile);
 		UpdateSignalsOnSegment(tile, ReverseDiagDir(dir));
@@ -644,22 +615,10 @@
 		YapfNotifyTrackLayoutChange(tile, track);
 		YapfNotifyTrackLayoutChange(endtile, track);
 	}
-	return CommandCost(_price.clear_tunnel * (length + 1));
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1));
 }
 
 
-static bool IsVehicleOnBridge(TileIndex starttile, TileIndex endtile, uint z)
-{
-	const Vehicle *v;
-	FOR_ALL_VEHICLES(v) {
-		if ((v->tile == starttile || v->tile == endtile) && v->z_pos == z) {
-			_error_message = VehicleInTheWayErrMsg(v);
-			return true;
-		}
-	}
-	return false;
-}
-
 static CommandCost DoClearBridge(TileIndex tile, uint32 flags)
 {
 	DiagDirection direction;
@@ -667,20 +626,13 @@
 	TileIndex endtile;
 	Town *t = NULL;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR;
 
 	endtile = GetOtherBridgeEnd(tile);
-	byte bridge_height = GetBridgeHeight(tile);
 
-	if (FindVehicleOnTileZ(tile, bridge_height) != NULL ||
-			FindVehicleOnTileZ(endtile, bridge_height) != NULL ||
-			IsVehicleOnBridge(tile, endtile, bridge_height)) {
-		return CMD_ERROR;
-	}
+	if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR;
 
-	direction = GetBridgeRampDirection(tile);
+	direction = GetTunnelBridgeDirection(tile);
 	delta = TileOffsByDiagDir(direction);
 
 	if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
@@ -694,15 +646,16 @@
 		}
 	}
 
+	/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
+	 * you have a "Poor" (0) town rating */
+	if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
+		ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
+	}
+
 	if (flags & DC_EXEC) {
 		TileIndex c;
 		Track track;
 
-		/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
-		 * you have a "Poor" (0) town rating */
-		if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
-			ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
-
 		DoClearSquare(tile);
 		DoClearSquare(endtile);
 		for (c = tile + delta; c != endtile; c += delta) {
@@ -717,7 +670,7 @@
 		YapfNotifyTrackLayoutChange(endtile, track);
 	}
 
-	return CommandCost((DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge);
+	return CommandCost(EXPENSES_CONSTRUCTION, (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge);
 }
 
 static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags)
@@ -734,85 +687,6 @@
 }
 
 /**
- * Switches the rail type for a tunnel or a bridgehead. As the railtype
- * on the bridge are determined by the one of the bridgehead, this
- * functions converts the railtype on the entire bridge.
- * @param tile        The tile on which the railtype is to be convert.
- * @param totype      The railtype we want to convert to
- * @param exec        Switches between test and execute mode
- * @return            The cost and state of the operation
- * @retval CMD_ERROR  An error occured during the operation.
- */
-CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
-{
-	if (IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) {
-		uint length;
-		TileIndex endtile;
-
-		/* If not coverting rail <-> el. rail, any vehicle cannot be in tunnel */
-		if (!IsCompatibleRail(GetRailType(tile), totype)) {
-			endtile = CheckTunnelBusy(tile, &length);
-			if (endtile == INVALID_TILE) return CMD_ERROR;
-		} else {
-			endtile = GetOtherTunnelEnd(tile);
-			length = DistanceManhattan(tile, endtile);
-		}
-
-		if (exec) {
-			SetRailType(tile, totype);
-			SetRailType(endtile, totype);
-			MarkTileDirtyByTile(tile);
-			MarkTileDirtyByTile(endtile);
-
-			Track track = AxisToTrack(DiagDirToAxis(GetTunnelDirection(tile)));
-
-			YapfNotifyTrackLayoutChange(tile, track);
-			YapfNotifyTrackLayoutChange(endtile, track);
-
-			VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
-			VehicleFromPos(endtile, &endtile, UpdateTrainPowerProc);
-		}
-
-		return CommandCost((length + 1) * (RailBuildCost(totype) / 2));
-	} else if (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
-		TileIndex endtile = GetOtherBridgeEnd(tile);
-		byte bridge_height = GetBridgeHeight(tile);
-
-		if (!IsCompatibleRail(GetRailType(tile), totype) &&
-				(FindVehicleOnTileZ(tile, bridge_height) != NULL ||
-				FindVehicleOnTileZ(endtile, bridge_height) != NULL ||
-				IsVehicleOnBridge(tile, endtile, bridge_height))) {
-			return CMD_ERROR;
-		}
-
-		if (exec) {
-			SetRailType(tile, totype);
-			SetRailType(endtile, totype);
-			MarkTileDirtyByTile(tile);
-			MarkTileDirtyByTile(endtile);
-
-			Track track = AxisToTrack(DiagDirToAxis(GetBridgeRampDirection(tile)));
-			TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
-
-			YapfNotifyTrackLayoutChange(tile, track);
-			YapfNotifyTrackLayoutChange(endtile, track);
-
-			VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
-			VehicleFromPos(endtile, &endtile, UpdateTrainPowerProc);
-
-			for (tile += delta; tile != endtile; tile += delta) {
-				MarkTileDirtyByTile(tile); // TODO encapsulate this into a function
-			}
-		}
-
-		return CommandCost((DistanceManhattan(tile, endtile) + 1) * (RailBuildCost(totype) / 2));
-	} else {
-		return CMD_ERROR;
-	}
-}
-
-
-/**
  * Draws the pillars under high bridges.
  *
  * @param psid Image and palette of a bridge pillar.
@@ -945,22 +819,22 @@
 			{  1,  0, -15, -14,  0, 15, 16,  1, 0, 1, 16, 15 }, // SW
 			{  0,  1, -14, -15, 15,  0,  1, 16, 1, 0, 15, 16 }, // NW
 		};
-		const int *BB_data = _tunnel_BB[GetTunnelDirection(ti->tile)];
+		const int *BB_data = _tunnel_BB[GetTunnelBridgeDirection(ti->tile)];
 
 		bool catenary = false;
 
-		if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
+		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
 			image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
 		} else {
 			image = SPR_TUNNEL_ENTRY_REAR_ROAD;
 		}
 
-		if (HasTunnelSnowOrDesert(ti->tile)) image += 32;
+		if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += 32;
 
-		image += GetTunnelDirection(ti->tile) * 2;
+		image += GetTunnelBridgeDirection(ti->tile) * 2;
 		DrawGroundSprite(image, PAL_NONE);
-		if (GetTunnelTransportType(ti->tile) == TRANSPORT_ROAD) {
-			DiagDirection dir = GetTunnelDirection(ti->tile);
+		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
+			DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
 			RoadTypes rts = GetRoadTypes(ti->tile);
 
 			if (HasBit(rts, ROADTYPE_TRAM)) {
@@ -992,9 +866,9 @@
 	} else if (IsBridge(ti->tile)) { // XXX is this necessary?
 		const PalSpriteID *psid;
 		int base_offset;
-		bool ice = HasBridgeSnowOrDesert(ti->tile);
+		bool ice = HasTunnelBridgeSnowOrDesert(ti->tile);
 
-		if (GetBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
+		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
 			base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset;
 			assert(base_offset != 8); // This one is used for roads
 		} else {
@@ -1004,10 +878,10 @@
 		/* as the lower 3 bits are used for other stuff, make sure they are clear */
 		assert( (base_offset & 0x07) == 0x00);
 
-		DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetBridgeRampDirection(ti->tile))));
+		DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetTunnelBridgeDirection(ti->tile))));
 
 		/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */
-		base_offset += (6 - GetBridgeRampDirection(ti->tile)) % 4;
+		base_offset += (6 - GetTunnelBridgeDirection(ti->tile)) % 4;
 
 		if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head
 
@@ -1023,7 +897,7 @@
 		/* draw ramp */
 
 		/* Draw Trambits as SpriteCombine */
-		if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) StartSpriteCombine();
+		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) StartSpriteCombine();
 
 		/* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on
 		 * it doesn't disappear behind it
@@ -1032,11 +906,11 @@
 			psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, IsTransparencySet(TO_BRIDGES)
 		);
 
-		if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
+		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
 			RoadTypes rts = GetRoadTypes(ti->tile);
 
 			if (HasBit(rts, ROADTYPE_TRAM)) {
-				uint offset = GetBridgeRampDirection(ti->tile);
+				uint offset = GetTunnelBridgeDirection(ti->tile);
 				uint z = ti->z;
 				if (ti->tileh != SLOPE_FLAT) {
 					offset = (offset + 1) & 1;
@@ -1135,7 +1009,7 @@
 	);
 	type = GetBridgeType(rampsouth);
 
-	if (GetBridgeTransportType(rampsouth) == TRANSPORT_RAIL) {
+	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_RAIL) {
 		base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset;
 	} else {
 		base_offset = 8;
@@ -1153,7 +1027,7 @@
 	AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR);
 
 	/* Draw Trambits as SpriteCombine */
-	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) StartSpriteCombine();
+	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) StartSpriteCombine();
 
 	/* Draw floor and far part of bridge*/
 	if (axis == AXIS_X) {
@@ -1164,7 +1038,7 @@
 
 	psid++;
 
-	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
+	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
 		RoadTypes rts = GetRoadTypes(rampsouth);
 
 		if (HasBit(rts, ROADTYPE_TRAM)) {
@@ -1188,7 +1062,7 @@
 	}
 
 	/* Draw TramFront as SpriteCombine */
-	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) EndSpriteCombine();
+	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) EndSpriteCombine();
 
 	psid++;
 	if (ti->z + 5 == z) {
@@ -1219,12 +1093,12 @@
 	y &= 0xF;
 
 	if (IsTunnel(tile)) {
-		uint pos = (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? y : x);
+		uint pos = (DiagDirToAxis(GetTunnelBridgeDirection(tile)) == AXIS_X ? y : x);
 
 		/* In the tunnel entrance? */
 		if (5 <= pos && pos <= 10) return z;
 	} else {
-		DiagDirection dir = GetBridgeRampDirection(tile);
+		DiagDirection dir = GetTunnelBridgeDirection(tile);
 		uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x);
 
 		z += ApplyFoundationToSlope(GetBridgeFoundation(tileh, DiagDirToAxis(dir)), &tileh);
@@ -1251,7 +1125,7 @@
 
 static Foundation GetFoundation_TunnelBridge(TileIndex tile, Slope tileh)
 {
-	return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
+	return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(tile)));
 }
 
 
@@ -1295,10 +1169,10 @@
 static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td)
 {
 	if (IsTunnel(tile)) {
-		td->str = (GetTunnelTransportType(tile) == TRANSPORT_RAIL) ?
+		td->str = (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) ?
 			STR_5017_RAILROAD_TUNNEL : STR_5018_ROAD_TUNNEL;
 	} else {
-		td->str = _bridge_tile_str[GetBridgeTransportType(tile) << 4 | GetBridgeType(tile)];
+		td->str = _bridge_tile_str[GetTunnelBridgeTransportType(tile) << 4 | GetBridgeType(tile)];
 	}
 	td->owner = GetTileOwner(tile);
 }
@@ -1311,29 +1185,24 @@
 
 static void TileLoop_TunnelBridge(TileIndex tile)
 {
-	bool snow_or_desert = IsTunnelTile(tile) ? HasTunnelSnowOrDesert(tile) : HasBridgeSnowOrDesert(tile);
+	bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile);
 	switch (_opt.landscape) {
 		case LT_ARCTIC:
 			if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) {
-				if (IsTunnelTile(tile)) {
-					SetTunnelSnowOrDesert(tile, !snow_or_desert);
-				} else {
-					SetBridgeSnowOrDesert(tile, !snow_or_desert);
-				}
+				SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
 				MarkTileDirtyByTile(tile);
 			}
 			break;
 
 		case LT_TROPIC:
 			if (GetTropicZone(tile) == TROPICZONE_DESERT && !snow_or_desert) {
-				if (IsTunnelTile(tile)) {
-					SetTunnelSnowOrDesert(tile, true);
-				} else {
-					SetBridgeSnowOrDesert(tile, true);
-				}
+				SetTunnelBridgeSnowOrDesert(tile, true);
 				MarkTileDirtyByTile(tile);
 			}
 			break;
+
+		default:
+			break;
 	}
 }
 
@@ -1345,15 +1214,9 @@
 
 static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode)
 {
-	if (IsTunnel(tile)) {
-		if (GetTunnelTransportType(tile) != mode) return 0;
-		if (GetTunnelTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
-		return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(tile))) * 0x101;
-	} else {
-		if (GetBridgeTransportType(tile) != mode) return 0;
-		if (GetBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
-		return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(tile))) * 0x101;
-	}
+	if (GetTunnelBridgeTransportType(tile) != mode) return 0;
+	if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
+	return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101;
 }
 
 static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
@@ -1368,7 +1231,7 @@
 			 * the bridge/tunnel. As all *our* vehicles are already removed, they
 			 * must be of another owner. Therefor this must be a road bridge/tunnel.
 			 * In that case we can safely reassign the ownership to OWNER_NONE. */
-			assert((IsTunnel(tile) ? GetTunnelTransportType(tile) : GetBridgeTransportType(tile)) == TRANSPORT_ROAD);
+			assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD);
 			SetTileOwner(tile, OWNER_NONE);
 		}
 	}
@@ -1391,7 +1254,7 @@
 static const byte _tunnel_fractcoord_6[4]    = {0x92, 0x89, 0x56, 0x45};
 static const byte _tunnel_fractcoord_7[4]    = {0x52, 0x85, 0x96, 0x49};
 
-static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y)
+static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y)
 {
 	int z = GetSlopeZ(x, y) - v->z_pos;
 
@@ -1405,7 +1268,7 @@
 		if (v->type == VEH_TRAIN) {
 			fc = (x & 0xF) + (y << 4);
 
-			dir = GetTunnelDirection(tile);
+			dir = GetTunnelBridgeDirection(tile);
 			vdir = DirToDiagDir(v->direction);
 
 			if (v->u.rail.track != TRACK_BIT_WORMHOLE && dir == vdir) {
@@ -1433,7 +1296,7 @@
 			}
 		} else if (v->type == VEH_ROAD) {
 			fc = (x & 0xF) + (y << 4);
-			dir = GetTunnelDirection(tile);
+			dir = GetTunnelBridgeDirection(tile);
 			vdir = DirToDiagDir(v->direction);
 
 			/* Enter tunnel? */
@@ -1473,7 +1336,7 @@
 			if (v->cur_speed > spd) v->cur_speed = spd;
 		}
 
-		dir = GetBridgeRampDirection(tile);
+		dir = GetTunnelBridgeDirection(tile);
 		if (DirToDiagDir(v->direction) == dir) {
 			switch (dir) {
 				default: NOT_REACHED();
@@ -1513,7 +1376,7 @@
 static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
 {
 	if (_patches.build_on_slopes && AutoslopeEnabled() && IsBridge(tile)) {
-		DiagDirection direction = GetBridgeRampDirection(tile);
+		DiagDirection direction = GetTunnelBridgeDirection(tile);
 		Axis axis = DiagDirToAxis(direction);
 		CommandCost res;
 
@@ -1532,7 +1395,7 @@
 			z_new += ApplyFoundationToSlope(GetBridgeFoundation(tileh_new, axis), &tileh_new);
 
 			/* Surface slope remains unchanged? */
-			if ((z_old == z_new) && (tileh_old == tileh_new)) return _price.terraform;
+			if ((z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 		}
 	}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tunnelbridge_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,80 @@
+/* $Id$ */
+
+/** @file tunnelbridge_map.h Functions that have tunnels and bridges in common */
+
+#ifndef TUNNELBRIDGE_MAP_H
+#define TUNNELBRIDGE_MAP_H
+
+#include "direction_func.h"
+#include "core/bitmath_func.hpp"
+#include "tile_map.h"
+#include "bridge_map.h"
+#include "tunnel_map.h"
+
+
+/**
+ * Tunnel: Get the direction facing out of the tunnel
+ * Bridge: Get the direction pointing onto the bridge
+ * @param t The tile to analyze
+ * @pre IsTileType(t, MP_TUNNELBRIDGE)
+ * @return the above mentionned direction
+ */
+static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
+{
+	assert(IsTileType(t, MP_TUNNELBRIDGE));
+	return (DiagDirection)GB(_m[t].m5, 0, 2);
+}
+
+/**
+ * Tunnel: Get the transport type of the tunnel (road or rail)
+ * Bridge: Get the transport type of the bridge's ramp
+ * @param t The tile to analyze
+ * @pre IsTileType(t, MP_TUNNELBRIDGE)
+ * @return the transport type in the tunnel/bridge
+ */
+static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
+{
+	assert(IsTileType(t, MP_TUNNELBRIDGE));
+	return (TransportType)GB(_m[t].m5, 2, 2);
+}
+
+/**
+ * Tunnel: Is this tunnel entrance in a snowy or desert area?
+ * Bridge: Does the bridge ramp lie in a snow or desert area?
+ * @param t The tile to analyze
+ * @pre IsTileType(t, MP_TUNNELBRIDGE)
+ * @return true if and only if the tile is in a snowy/desert area
+ */
+static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
+{
+	assert(IsTileType(t, MP_TUNNELBRIDGE));
+	return HasBit(_m[t].m4, 7);
+}
+
+/**
+ * Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there.
+ * Bridge: Sets whether the bridge ramp lies in a snow or desert area.
+ * @param t the tunnel entrance / bridge ramp tile
+ * @param snow_or_desert is the entrance/ramp in snow or desert (true), when
+ *                       not in snow and not in desert false
+ * @pre IsTileType(t, MP_TUNNELBRIDGE)
+ */
+static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
+{
+	assert(IsTileType(t, MP_TUNNELBRIDGE));
+	SB(_m[t].m4, 7, 1, snow_or_desert);
+}
+
+/**
+ * Determines type of the wormhole and returns its other end
+ * @param t one end
+ * @pre IsTileType(t, MP_TUNNELBRIDGE)
+ * @return other end
+ */
+static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
+{
+	assert(IsTileType(t, MP_TUNNELBRIDGE));
+	return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
+}
+
+#endif /* TUNNELBRIDGE_MAP_H */
--- a/src/unix.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/unix.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,11 +4,11 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
-#include "window.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>
@@ -67,6 +67,10 @@
 	uint32 free = 0;
 
 #ifdef HAS_STATVFS
+# ifdef __APPLE__
+	/* OSX 10.3 lacks statvfs so don't try to use it even though later versions of OSX has it. */
+	if (MacOSVersionIsAtLeast(10, 4, 0))
+# endif
 	{
 		struct statvfs s;
 
@@ -199,6 +203,7 @@
 #include <iconv.h>
 #include <errno.h>
 #include "debug.h"
+#include "string_func.h"
 
 #define INTERNALCODE "UTF-8"
 
--- a/src/unmovable_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/unmovable_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,16 +6,13 @@
 #include "openttd.h"
 #include "table/strings.h"
 #include "table/sprites.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "map.h"
-#include "tile.h"
-#include "command.h"
-#include "viewport.h"
+#include "command_func.h"
+#include "viewport_func.h"
 #include "player.h"
 #include "gui.h"
 #include "station.h"
-#include "economy.h"
 #include "town.h"
 #include "sprite.h"
 #include "bridge_map.h"
@@ -26,6 +23,9 @@
 #include "bridge.h"
 #include "autoslope.h"
 #include "transparency.h"
+#include "functions.h"
+#include "window_func.h"
+#include "vehicle_func.h"
 
 /** Destroy a HQ.
  * During normal gameplay you can only implicitely destroy a HQ when you are
@@ -38,8 +38,6 @@
 {
 	Player* p = GetPlayer(pid);
 
-	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
-
 	if (flags & DC_EXEC) {
 		TileIndex t = p->location_of_house;
 
@@ -52,7 +50,7 @@
 	}
 
 	/* cost of relocating company is 1% of company value */
-	return CommandCost(CalculateCompanyValue(p) / 100);
+	return CommandCost(EXPENSES_PROPERTY, CalculateCompanyValue(p) / 100);
 }
 
 void UpdateCompanyHQ(Player *p, uint score)
@@ -87,9 +85,7 @@
 CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	Player *p = GetPlayer(_current_player);
-	CommandCost cost;
-
-	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
+	CommandCost cost(EXPENSES_PROPERTY);
 
 	cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
 	if (CmdFailed(cost)) return cost;
@@ -112,6 +108,54 @@
 	return cost;
 }
 
+/** Purchase a land area. Actually you only purchase one tile, so
+ * the name is a bit confusing ;p
+ * @param tile the tile the player is purchasing
+ * @param flags for this command type
+ * @param p1 unused
+ * @param p2 unused
+ * @return error of cost of operation
+ */
+CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+{
+	CommandCost cost(EXPENSES_CONSTRUCTION);
+
+	if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) {
+		return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
+	}
+
+	cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+	if (CmdFailed(cost)) return CMD_ERROR;
+
+	if (flags & DC_EXEC) {
+		MakeOwnedLand(tile, _current_player);
+		MarkTileDirtyByTile(tile);
+	}
+
+	return cost.AddCost(_price.clear_roughland * 10);
+}
+
+/** Sell a land area. Actually you only sell one tile, so
+ * the name is a bit confusing ;p
+ * @param tile the tile the player is selling
+ * @param flags for this command type
+ * @param p1 unused
+ * @param p2 unused
+ * @return error or cost of operation
+ */
+CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+{
+	if (!IsOwnedLandTile(tile)) return CMD_ERROR;
+	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
+
+
+	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+
+	if (flags & DC_EXEC) DoClearSquare(tile);
+
+	return CommandCost(EXPENSES_CONSTRUCTION,- _price.clear_roughland * 2);
+}
+
 static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh);
 
 static void DrawTile_Unmovable(TileInfo *ti)
@@ -411,7 +455,7 @@
 	if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost();
 
 	if (AutoslopeEnabled() && (IsStatue(tile) || IsCompanyHQ(tile))) {
-		if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return _price.terraform;
+		if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 	}
 
 	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
--- a/src/unmovable_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/unmovable_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,9 @@
 #ifndef UNMOVABLE_MAP_H
 #define UNMOVABLE_MAP_H
 
+#include "core/bitmath_func.hpp"
+#include "tile_map.h"
+
 enum {
 	HQ_NUM_TILE = 4, ///< Number of HQ tiles
 	HQ_NUM_SIZE = 5  ///< Number of stages of an HQ
@@ -21,7 +24,7 @@
 	UNMOVABLE_HQ_EAST     = 0x82, ///< Offset for the eastern HQ tile
 	UNMOVABLE_HQ_SOUTH    = 0x83, ///< Offset for the southern HQ tile
 
-	/** End of the HQ (rather end + 1 for IS_INT_INSIDE) */
+	/** End of the HQ (rather end + 1 for IsInside) */
 	UNMOVABLE_HQ_END      = UNMOVABLE_HQ_NORTH + HQ_NUM_SIZE * HQ_NUM_TILE
 };
 
@@ -80,7 +83,7 @@
 static inline bool IsCompanyHQ(TileIndex t)
 {
 	assert(IsTileType(t, MP_UNMOVABLE));
-	return IS_INT_INSIDE(GetUnmovableType(t), UNMOVABLE_HQ_NORTH, UNMOVABLE_HQ_END);
+	return IsInsideMM(GetUnmovableType(t), UNMOVABLE_HQ_NORTH, UNMOVABLE_HQ_END);
 }
 
 /**
--- a/src/variables.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/variables.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,47 +5,13 @@
 #ifndef VARIABLES_H
 #define VARIABLES_H
 
-#include "yapf/yapf_settings.h"
-
-/* ********* START OF SAVE REGION */
-
-#include "gfx.h"
-
-/* Prices and also the fractional part. */
-VARDEF Prices _price;
-VARDEF uint16 _price_frac[NUM_PRICES];
-
-VARDEF Money  _cargo_payment_rates[NUM_CARGO];
-VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO];
-
-struct GameOptions {
-	GameDifficulty diff;
-	byte diff_level;
-	byte currency;
-	byte units;
-	byte town_name;
-	byte landscape;
-	byte snow_line;
-	byte autosave;
-	byte road_side;
-};
-
-/* These are the options for the current game
- * either ingame, or loaded. Also used for networking games */
-VARDEF GameOptions _opt;
-
-/* These are the default options for a new game */
-VARDEF GameOptions _opt_newgame;
-
-/* Pointer to one of the two _opt OR _opt_newgame structs */
-VARDEF GameOptions *_opt_ptr;
+#include "settings_type.h"
+#include "tile_type.h"
+#include "strings_type.h"
 
 /* Amount of game ticks */
 VARDEF uint16 _tick_counter;
 
-/* This one is not used anymore. */
-VARDEF VehicleID _vehicle_id_ctr_day;
-
 /* Skip aging of cargo? */
 VARDEF byte _age_cargo_skip_counter;
 
@@ -59,8 +25,6 @@
  *  tick handler. */
 VARDEF uint16 _station_tick_ctr;
 
-VARDEF uint32 _random_seeds[2][2];
-
 /* Iterator through all towns in OnTick_Town */
 VARDEF uint32 _cur_town_ctr;
 /* Frequency iterator at the same place */
@@ -76,181 +40,6 @@
 VARDEF int _saved_scrollpos_x;
 VARDEF int _saved_scrollpos_y;
 
-/* ********* END OF SAVE REGION */
-
-struct Patches {
-	bool modified_catchment;            // different-size catchment areas
-	bool vehicle_speed;                 // show vehicle speed
-	bool build_on_slopes;               // allow building on slopes
-	bool mammoth_trains;                // allow very long trains
-	bool join_stations;                 // allow joining of train stations
-	bool full_load_any;                 // new full load calculation, any cargo must be full
-	bool improved_load;                 // improved loading algorithm
-	bool gradual_loading;               // load vehicles gradually
-	byte station_spread;                // amount a station may spread
-	bool inflation;                     // disable inflation
-	bool selectgoods;                   // only send the goods to station if a train has been there
-	bool longbridges;                   // allow 100 tile long bridges
-	bool gotodepot;                     // allow goto depot in orders
-	uint8 raw_industry_construction;    ///< Type of (raw) industry construction (none, "normal", prospecting)
-	bool multiple_industry_per_town;    // allow many industries of the same type per town
-	bool same_industry_close;           // allow same type industries to be built close to each other
-	bool lost_train_warn;               // if a train can't find its destination, show a warning
-	uint8 order_review_system;
-	bool train_income_warn;             // if train is generating little income, show a warning
-	bool status_long_date;              // always show long date in status bar
-	bool signal_side;                   // show signals on right side
-	bool show_finances;                 // show finances at end of year
-	bool new_nonstop;                   // ttdpatch compatible nonstop handling
-	bool roadveh_queue;                 // buggy road vehicle queueing
-	bool autoscroll;                    // scroll when moving mouse to the edge.
-	byte errmsg_duration;               // duration of error message
-	byte land_generator;                // the landscape generator
-	byte oil_refinery_limit;            // distance oil refineries allowed from map edge
-	byte snow_line_height;              // a number 0-15 that configured snow line height
-	byte tgen_smoothness;               // how rough is the terrain from 0-3
-	uint32 generation_seed;             // noise seed for world generation
-	byte tree_placer;                   // the tree placer algorithm
-	byte heightmap_rotation;            // rotation director for the heightmap
-	byte se_flat_world_height;          // land height a flat world gets in SE
-	bool bribe;                         // enable bribing the local authority
-	bool nonuniform_stations;           // allow nonuniform train stations
-	bool adjacent_stations;             // allow stations to be built directly adjacent to other stations
-	bool always_small_airport;          // always allow small airports
-	bool realistic_acceleration;        // realistic acceleration for trains
-	bool wagon_speed_limits;            // enable wagon speed limits
-	bool forbid_90_deg;                 // forbid trains to make 90 deg turns
-	bool invisible_trees;               // don't show trees when buildings are transparent
-	bool no_servicing_if_no_breakdowns; // dont send vehicles to depot when breakdowns are disabled
-	bool link_terraform_toolbar;        // display terraform toolbar when displaying rail, road, water and airport toolbars
-	bool reverse_scroll;                // Right-Click-Scrolling scrolls in the opposite direction
-	bool smooth_scroll;                 ///< Smooth scroll viewports
-	bool disable_elrails;               // when true, the elrails are disabled
-	bool measure_tooltip;               // Show a permanent tooltip when dragging tools
-	byte liveries;                      // Options for displaying company liveries, 0=none, 1=self, 2=all
-	bool prefer_teamchat;               // Choose the chat message target with <ENTER>, true=all players, false=your team
-	uint8 advanced_vehicle_list;        // Use the "advanced" vehicle list
-	uint8 loading_indicators;           // Show loading indicators
-	uint8 default_rail_type;            ///< The default rail type for the rail GUI
-
-	uint8 toolbar_pos;                  // position of toolbars, 0=left, 1=center, 2=right
-	uint8 window_snap_radius;           // Windows snap at each other if closer than this
-
-	bool always_build_infrastructure;   ///< Always allow building of infrastructure, even when you do not have the vehicles for it
-	UnitID max_trains;                  // max trains in game per player (these are 16bit because the unitnumber field can't hold more)
-	UnitID max_roadveh;                 // max trucks in game per player
-	UnitID max_aircraft;                // max planes in game per player
-	UnitID max_ships;                   // max ships in game per player
-
-	bool servint_ispercent;             // service intervals are in percents
-	uint16 servint_trains;              // service interval for trains
-	uint16 servint_roadveh;             // service interval for road vehicles
-	uint16 servint_aircraft;            // service interval for aircraft
-	uint16 servint_ships;               // service interval for ships
-
-	bool autorenew;
-	int16 autorenew_months;
-	int32 autorenew_money;
-
-	byte pf_maxdepth;                   // maximum recursion depth when searching for a train route for new pathfinder
-	uint16 pf_maxlength;                // maximum length when searching for a train route for new pathfinder
-
-
-	bool bridge_pillars;                // show bridge pillars for high bridges
-
-	bool ai_disable_veh_train;          // disable types for AI
-	bool ai_disable_veh_roadveh;        // disable types for AI
-	bool ai_disable_veh_aircraft;       // disable types for AI
-	bool ai_disable_veh_ship;           // disable types for AI
-	Year starting_year;                 // starting date
-	Year ending_year;                   // end of the game (just show highscore)
-	Year colored_news_year;             // when does newspaper become colored?
-
-	bool keep_all_autosave;             // name the autosave in a different way.
-	bool autosave_on_exit;              // save an autosave when you quit the game, but do not ask "Do you really want to quit?"
-	byte max_num_autosaves;             // controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
-	bool extra_dynamite;                // extra dynamite
-	bool road_stop_on_town_road;        // allow building of drive-through road stops on town owned roads
-
-	bool never_expire_vehicles;         // never expire vehicles
-	byte extend_vehicle_life;           // extend vehicle life by this many years
-
-	bool auto_euro;                     // automatically switch to euro in 2002
-	bool serviceathelipad;              // service helicopters at helipads automatically (no need to send to depot)
-	bool smooth_economy;                // smooth economy
-	bool allow_shares;                  // allow the buying/selling of shares
-	byte dist_local_authority;          // distance for town local authority, default 20
-
-	byte wait_oneway_signal;            // waitingtime in days before a oneway signal
-	byte wait_twoway_signal;            // waitingtime in days before a twoway signal
-
-	uint8 map_x;                        // Size of map
-	uint8 map_y;
-
-	byte drag_signals_density;          // many signals density
-	Year semaphore_build_before;        // Build semaphore signals automatically before this year
-	bool ai_in_multiplayer;             // Do we allow AIs in multiplayer
-
-	/*
-	 * New Path Finding
-	 */
-	bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */
-
-	/**
-	 * The maximum amount of search nodes a single NPF run should take. This
-	 * limit should make sure performance stays at acceptable levels at the cost
-	 * of not being perfect anymore. This will probably be fixed in a more
-	 * sophisticated way sometime soon
-	 */
-	uint32 npf_max_search_nodes;
-
-	uint32 npf_rail_firstred_penalty;      // The penalty for when the first signal is red (and it is not an exit or combo signal)
-	uint32 npf_rail_firstred_exit_penalty; // The penalty for when the first signal is red (and it is an exit or combo signal)
-	uint32 npf_rail_lastred_penalty;       // The penalty for when the last signal is red
-	uint32 npf_rail_station_penalty;       // The penalty for station tiles
-	uint32 npf_rail_slope_penalty;         // The penalty for sloping upwards
-	uint32 npf_rail_curve_penalty;         // The penalty for curves
-	uint32 npf_rail_depot_reverse_penalty; // The penalty for reversing in depots
-	uint32 npf_buoy_penalty;               // The penalty for going over (through) a buoy
-	uint32 npf_water_curve_penalty;        // The penalty for curves
-	uint32 npf_road_curve_penalty;         // The penalty for curves
-	uint32 npf_crossing_penalty;           // The penalty for level crossings
-	uint32 npf_road_drive_through_penalty; // The penalty for going through a drive-through road stop
-
-	bool population_in_label; // Show the population of a town in his label?
-
-	uint8 freight_trains; // Value to multiply the weight of cargo by
-
-	/** YAPF settings */
-	YapfSettings  yapf;
-
-	uint8 right_mouse_btn_emulation;
-
-	uint8 scrollwheel_scrolling;
-	uint8 scrollwheel_multiplier;
-
-	uint8 town_growth_rate;  ///< Town growth rate
-	uint8 larger_towns;      ///< The number of cities to build. These start off larger and grow twice as fast
-	uint8 initial_city_size; ///< Multiplier for the initial size of the cities compared to towns
-
-	bool pause_on_newgame;   ///< Whether to start new games paused or not.
-
-	TownLayoutByte town_layout;  ///< Select town layout
-
-	bool timetabling;        ///< Whether to allow timetabling.
-	bool timetable_in_ticks; ///< Whether to show the timetable in ticks rather than days.
-
-	bool autoslope;          ///< Allow terraforming under things.
-
-	bool mod_road_rebuild;   ///< Roadworks remove unneccesary RoadBits
-
-	bool exclusive_rights;   ///< allow buying exclusive rights
-	bool give_money;         ///< allow giving other players money
-};
-
-VARDEF Patches _patches;
-
-
 struct Cheat {
 	bool been_used; // has this cheat been used before?
 	bool value;     // tells if the bool cheat is active or not
@@ -292,33 +81,18 @@
 VARDEF bool _news_ticker_sound;
 
 VARDEF StringID _error_message;
-VARDEF Money _additional_cash_required;
 
 VARDEF bool _rightclick_emulate;
 
 VARDEF PlayerFace _player_face; ///< for player face storage in openttd.cfg
 
 /* IN/OUT parameters to commands */
-VARDEF byte _yearly_expenses_type;
-VARDEF TileIndex _terraform_err_tile;
 VARDEF TileIndex _build_tunnel_endtile;
 VARDEF bool _generating_world;
 
-/* Deals with the type of the savegame, independent of extension */
-struct SmallFiosItem {
-	int mode;             // savegame/scenario type (old, new)
-	char name[MAX_PATH];  // name
-	char title[255];      // internal name of the game
-};
-
 /* Used when switching from the intro menu. */
 VARDEF byte _switch_mode;
 VARDEF StringID _switch_mode_errorstr;
-VARDEF SmallFiosItem _file_to_saveload;
-
-
-
-VARDEF Vehicle *_place_clicked_vehicle;
 
 VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32], _ini_blitter[32];
 
@@ -333,13 +107,9 @@
 VARDEF char *_log_file;
 
 
-#define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x;
-
 /* landscape.cpp */
 extern const byte _tileh_to_sprite[32];
 
-extern const TileTypeProcs * const _tile_type_procs[16];
-
 extern bool _draw_bounding_boxes;
 
 /* misc */
--- a/src/vehicle.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/vehicle.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -10,25 +10,21 @@
 #include "spritecache.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "map.h"
-#include "tile.h"
-#include "vehicle.h"
 #include "timetable.h"
-#include "gfx.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
 #include "news.h"
-#include "command.h"
+#include "command_func.h"
 #include "saveload.h"
 #include "player.h"
 #include "engine.h"
-#include "sound.h"
 #include "debug.h"
 #include "vehicle_gui.h"
 #include "depot.h"
 #include "station.h"
-#include "rail.h"
+#include "rail_type.h"
 #include "train.h"
 #include "aircraft.h"
 #include "industry_map.h"
@@ -36,18 +32,31 @@
 #include "water_map.h"
 #include "network/network.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_engine.h"
 #include "newgrf_sound.h"
-#include "helpers.hpp"
 #include "group.h"
-#include "economy.h"
-#include "strings.h"
+#include "order.h"
+#include "strings_func.h"
+#include "zoom_func.h"
+#include "functions.h"
+#include "date_func.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "variables.h"
+#include "autoreplace_func.h"
+#include "autoreplace_gui.h"
+#include "string_func.h"
 
 #define INVALID_COORD (0x7fffffff)
 #define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))
 
+VehicleID _vehicle_id_ctr_day;
+Vehicle *_place_clicked_vehicle;
+VehicleID _new_vehicle_id;
+uint16 _returned_refit_capacity;
+
 
 /* Tables used in vehicle.h to find the right command for a certain vehicle type */
 const uint32 _veh_build_proc_table[] = {
@@ -119,33 +128,23 @@
 
 static void *EnsureNoVehicleProcZ(Vehicle *v, void *data)
 {
-	const TileInfo *ti = (const TileInfo*)data;
-
-	if (v->tile != ti->tile || v->type == VEH_DISASTER || (v->type == VEH_AIRCRAFT && v->subtype == AIR_SHADOW)) return NULL;
-	if (v->z_pos > ti->z) return NULL;
+	byte z = *(byte*)data;
+
+	if (v->type == VEH_DISASTER || (v->type == VEH_AIRCRAFT && v->subtype == AIR_SHADOW)) return NULL;
+	if (v->z_pos > z) return NULL;
 
 	_error_message = VehicleInTheWayErrMsg(v);
 	return v;
 }
 
+Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z)
+{
+	return (Vehicle*)VehicleFromPos(tile, &z, &EnsureNoVehicleProcZ);
+}
 
 bool EnsureNoVehicleOnGround(TileIndex tile)
 {
-	TileInfo ti;
-
-	ti.tile = tile;
-	ti.z = GetTileMaxZ(tile);
-	return VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ) == NULL;
-}
-
-Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z)
-{
-	TileInfo ti;
-
-	ti.tile = tile;
-	ti.z = z;
-
-	return (Vehicle*)VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ);
+	return FindVehicleOnTileZ(tile, GetTileMaxZ(tile)) == NULL;
 }
 
 Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_crashed)
@@ -174,6 +173,30 @@
 }
 
 
+/** Procedure called for every vehicle found in tunnel/bridge in the hash map */
+static void *GetVehicleTunnelBridgeProc(Vehicle *v, void *data)
+{
+	if (v->type != VEH_TRAIN && v->type != VEH_ROAD) return NULL;
+
+	_error_message = VehicleInTheWayErrMsg(v);
+	return v;
+}
+
+/**
+ * Finds vehicle in tunnel / bridge
+ * @param tile first end
+ * @param endtile second end
+ * @return pointer to vehicle found
+ */
+Vehicle *GetVehicleTunnelBridge(TileIndex tile, TileIndex endtile)
+{
+	Vehicle *v = (Vehicle*)VehicleFromPos(tile, NULL, &GetVehicleTunnelBridgeProc);
+	if (v != NULL) return v;
+
+	return (Vehicle*)VehicleFromPos(endtile, NULL, &GetVehicleTunnelBridgeProc);
+}
+
+
 static void UpdateVehiclePosHash(Vehicle* v, int x, int y);
 
 void VehiclePositionChanged(Vehicle *v)
@@ -194,7 +217,7 @@
 }
 
 /** Called after load to update coordinates */
-void AfterLoadVehicles()
+void AfterLoadVehicles(bool clear_te_id)
 {
 	Vehicle *v;
 
@@ -204,7 +227,7 @@
 
 		v->UpdateDeltaXY(v->direction);
 
-		v->fill_percent_te_id = INVALID_TE_ID;
+		if (clear_te_id) v->fill_percent_te_id = INVALID_TE_ID;
 		v->first = NULL;
 		if (v->type == VEH_TRAIN) v->u.rail.first_engine = INVALID_ENGINE;
 		if (v->type == VEH_ROAD)  v->u.road.first_engine = INVALID_ENGINE;
@@ -537,13 +560,10 @@
 		delete this->Next();
 	}
 
-	Window **wp;
-	FOR_ALL_WINDOWS(wp) {
-		Window *w = *wp;
-		if (w->viewport != NULL && WP(w, vp_d).follow_vehicle == this->index) {
-			ScrollMainWindowTo(this->x_pos, this->y_pos); // lock the main view on the vehicle's last position
-			WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
-		}
+	Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
+	if (WP(w, vp_d).follow_vehicle == this->index) {
+		ScrollMainWindowTo(this->x_pos, this->y_pos, true); // lock the main view on the vehicle's last position
+		WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
 	}
 }
 
@@ -573,6 +593,11 @@
 
 	do {
 		Vehicle *u = v;
+		if (!(v->vehstatus & VS_HIDDEN)) {
+			/* sometimes, eg. for disaster vehicles, when company bankrupts, when removing crashed/flooded vehicles,
+			 * it may happen that vehicle chain is deleted when visible */
+			MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1);
+		}
 		v = v->Next();
 		delete u;
 	} while (v != NULL);
@@ -681,19 +706,33 @@
 */
 CommandCost GetRefitCost(EngineID engine_type)
 {
-	CommandCost base_cost;
-
+	Money base_cost;
+	ExpensesType expense_type;
 	switch (GetEngine(engine_type)->type) {
-		case VEH_SHIP: base_cost.AddCost(_price.ship_base); break;
-		case VEH_ROAD: base_cost.AddCost(_price.roadveh_base); break;
-		case VEH_AIRCRAFT: base_cost.AddCost(_price.aircraft_base); break;
+		case VEH_SHIP:
+			base_cost = _price.ship_base;
+			expense_type = EXPENSES_SHIP_RUN;
+			break;
+
+		case VEH_ROAD:
+			base_cost = _price.roadveh_base;
+			expense_type = EXPENSES_ROADVEH_RUN;
+			break;
+
+		case VEH_AIRCRAFT:
+			base_cost = _price.aircraft_base;
+			expense_type = EXPENSES_AIRCRAFT_RUN;
+			break;
+
 		case VEH_TRAIN:
-			base_cost.AddCost(2 * ((RailVehInfo(engine_type)->railveh_type == RAILVEH_WAGON) ?
-							 _price.build_railwagon : _price.build_railvehicle));
+			base_cost = 2 * ((RailVehInfo(engine_type)->railveh_type == RAILVEH_WAGON) ?
+							 _price.build_railwagon : _price.build_railvehicle);
+			expense_type = EXPENSES_TRAIN_RUN;
 			break;
-		default: NOT_REACHED(); break;
+
+		default: NOT_REACHED();
 	}
-	return CommandCost((EngInfo(engine_type)->refit_cost * base_cost.GetCost()) >> 10);
+	return CommandCost(expense_type, (EngInfo(engine_type)->refit_cost * base_cost) >> 10);
 }
 
 static void DoDrawVehicle(const Vehicle *v)
@@ -1267,7 +1306,7 @@
 	}
 
 	if (b->y == 4 && b->x == 1) {
-		if (v->z_pos > 180 || CHANCE16I(1, 96, InteractiveRandom())) {
+		if (v->z_pos > 180 || Chance16I(1, 96, InteractiveRandom())) {
 			v->spritenum = 5;
 			SndPlayVehicleFx(SND_2F_POP, v);
 		}
@@ -1446,7 +1485,7 @@
 
 	/* increase chance of failure */
 	chance = v->breakdown_chance + 1;
-	if (CHANCE16I(1,25,r)) chance += 25;
+	if (Chance16I(1,25,r)) chance += 25;
 	v->breakdown_chance = min(255, chance);
 
 	/* calculate reliability value to use in comparison */
@@ -1672,7 +1711,6 @@
 			 * Because of this, we can't estimate costs due to wagon removal and we will have to always return 0 and pay manually
 			 * Since we pay after each vehicle is replaced and MaybeReplaceVehicle() check if the player got enough money
 			 * we should never reach a condition where the player will end up with negative money from doing this */
-			SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 			SubtractMoneyFromPlayer(ret);
 		}
 	}
@@ -1701,7 +1739,7 @@
 {
 	Vehicle *v_front, *v;
 	Vehicle *w_front, *w, *w_rear;
-	CommandCost cost, total_cost;
+	CommandCost cost, total_cost(EXPENSES_NEW_VEHICLES);
 	uint32 build_argument = 2;
 
 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
@@ -1855,9 +1893,6 @@
 		return CMD_ERROR;
 	}
 
-	/* Set the expense type last as refitting will make the cost go towards
-	 * running costs... */
-	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 	return total_cost;
 }
 
@@ -3080,7 +3115,6 @@
 	current_order.type = OT_LOADING;
 	GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
 
-	SET_EXPENSES_TYPE(this->GetExpenseType(true));
 	VehiclePayment(this);
 
 	InvalidateWindow(this->GetVehicleListWindowClass(), this->owner);
@@ -3167,3 +3201,15 @@
 	this->sprite_height = 1;
 	this->z_height      = 1;
 }
+
+void StopAllVehicles()
+{
+	Vehicle *v;
+	FOR_ALL_VEHICLES(v) {
+		/* Code ripped from CmdStartStopTrain. Can't call it, because of
+		 * ownership problems, so we'll duplicate some code, for now */
+		v->vehstatus |= VS_STOPPED;
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
+		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
+	}
+}
--- a/src/vehicle.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,843 +0,0 @@
-/* $Id$ */
-
-/** @vehicle.h */
-
-#ifndef VEHICLE_H
-#define VEHICLE_H
-
-#include "oldpool.h"
-#include "order.h"
-#include "rail.h"
-#include "road.h"
-#include "cargopacket.h"
-#include "texteff.hpp"
-
-/** The returned bits of VehicleEnterTile. */
-enum VehicleEnterTileStatus {
-	VETS_ENTERED_STATION  = 1, ///< The vehicle entered a station
-	VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
-	VETS_CANNOT_ENTER     = 3, ///< The vehicle cannot enter the tile
-
-	/**
-	 * Shift the VehicleEnterTileStatus this many bits
-	 * to the right to get the station ID when
-	 * VETS_ENTERED_STATION is set
-	 */
-	VETS_STATION_ID_OFFSET = 8,
-
-	/** Bit sets of the above specified bits */
-	VETSB_CONTINUE         = 0,                          ///< The vehicle can continue normally
-	VETSB_ENTERED_STATION  = 1 << VETS_ENTERED_STATION,  ///< The vehicle entered a station
-	VETSB_ENTERED_WORMHOLE = 1 << VETS_ENTERED_WORMHOLE, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
-	VETSB_CANNOT_ENTER     = 1 << VETS_CANNOT_ENTER,     ///< The vehicle cannot enter the tile
-};
-
-/** Road vehicle states */
-enum RoadVehicleStates {
-	/*
-	 * Lower 4 bits are used for vehicle track direction. (Trackdirs)
-	 * When in a road stop (bit 5 or bit 6 set) these bits give the
-	 * track direction of the entry to the road stop.
-	 * As the entry direction will always be a diagonal
-	 * direction (X_NE, Y_SE, X_SW or Y_NW) only bits 0 and 3
-	 * are needed to hold this direction. Bit 1 is then used to show
-	 * that the vehicle is using the second road stop bay.
-	 * Bit 2 is then used for drive-through stops to show the vehicle
-	 * is stopping at this road stop.
-	 */
-
-	/* Numeric values */
-	RVSB_IN_DEPOT                = 0xFE,                      ///< The vehicle is in a depot
-	RVSB_WORMHOLE                = 0xFF,                      ///< The vehicle is in a tunnel and/or bridge
-
-	/* Bit numbers */
-	RVS_USING_SECOND_BAY         =    1,                      ///< Only used while in a road stop
-	RVS_IS_STOPPING              =    2,                      ///< Only used for drive-through stops. Vehicle will stop here
-	RVS_DRIVE_SIDE               =    4,                      ///< Only used when retrieving move data
-	RVS_IN_ROAD_STOP             =    5,                      ///< The vehicle is in a road stop
-	RVS_IN_DT_ROAD_STOP          =    6,                      ///< The vehicle is in a drive-through road stop
-
-	/* Bit sets of the above specified bits */
-	RVSB_IN_ROAD_STOP            = 1 << RVS_IN_ROAD_STOP,     ///< The vehicle is in a road stop
-	RVSB_IN_ROAD_STOP_END        = RVSB_IN_ROAD_STOP + TRACKDIR_END,
-	RVSB_IN_DT_ROAD_STOP         = 1 << RVS_IN_DT_ROAD_STOP,  ///< The vehicle is in a drive-through road stop
-	RVSB_IN_DT_ROAD_STOP_END     = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END,
-
-	RVSB_TRACKDIR_MASK           = 0x0F,                      ///< The mask used to extract track dirs
-	RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09                       ///< Only bits 0 and 3 are used to encode the trackdir for road stops
-};
-
-enum VehicleType {
-	VEH_TRAIN,
-	VEH_ROAD,
-	VEH_SHIP,
-	VEH_AIRCRAFT,
-	VEH_SPECIAL,
-	VEH_DISASTER,
-	VEH_END,
-	VEH_INVALID = 0xFF,
-};
-DECLARE_POSTFIX_INCREMENT(VehicleType);
-template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID> {};
-typedef TinyEnumT<VehicleType> VehicleTypeByte;
-
-enum VehStatus {
-	VS_HIDDEN          = 0x01,
-	VS_STOPPED         = 0x02,
-	VS_UNCLICKABLE     = 0x04,
-	VS_DEFPAL          = 0x08,
-	VS_TRAIN_SLOWING   = 0x10,
-	VS_SHADOW          = 0x20,
-	VS_AIRCRAFT_BROKEN = 0x40,
-	VS_CRASHED         = 0x80,
-};
-
-enum VehicleFlags {
-	VF_LOADING_FINISHED,
-	VF_CARGO_UNLOADING,
-	VF_BUILT_AS_PROTOTYPE,
-	VF_TIMETABLE_STARTED,  ///< Whether the vehicle has started running on the timetable yet.
-	VF_AUTOFILL_TIMETABLE, ///< Whether the vehicle should fill in the timetable automatically.
-};
-
-/* Effect vehicle types */
-enum EffectVehicle {
-	EV_CHIMNEY_SMOKE   = 0,
-	EV_STEAM_SMOKE     = 1,
-	EV_DIESEL_SMOKE    = 2,
-	EV_ELECTRIC_SPARK  = 3,
-	EV_SMOKE           = 4,
-	EV_EXPLOSION_LARGE = 5,
-	EV_BREAKDOWN_SMOKE = 6,
-	EV_EXPLOSION_SMALL = 7,
-	EV_BULLDOZER       = 8,
-	EV_BUBBLE          = 9
-};
-
-struct VehicleRail {
-	uint16 last_speed; // NOSAVE: only used in UI
-	uint16 crash_anim_pos;
-
-	/* cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */
-	uint16 cached_max_speed;  // max speed of the consist. (minimum of the max speed of all vehicles in the consist)
-	uint32 cached_power;      // total power of the consist.
-	uint8 cached_veh_length;  // length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback
-	uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
-
-	/* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */
-	uint32 cached_weight;     // total weight of the consist.
-	uint32 cached_veh_weight; // weight of the vehicle.
-	uint32 cached_max_te;     // max tractive effort of consist
-	/**
-	 * Position/type of visual effect.
-	 * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear)
-	 * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric)
-	 * bit     6 = disable visual effect.
-	 * bit     7 = disable powered wagons.
-	 */
-	byte cached_vis_effect;
-	byte user_def_data;
-
-	/* NOSAVE: for wagon override - id of the first engine in train
-	 * 0xffff == not in train */
-	EngineID first_engine;
-
-	TrackBitsByte track;
-	byte force_proceed;
-	RailTypeByte railtype;
-	RailTypeMask compatible_railtypes;
-
-	byte flags;
-
-	/* Link between the two ends of a multiheaded engine */
-	Vehicle *other_multiheaded_part;
-
-	/* Cached wagon override spritegroup */
-	const struct SpriteGroup *cached_override;
-};
-
-enum {
-	VRF_REVERSING         = 0,
-
-	/* used to calculate if train is going up or down */
-	VRF_GOINGUP           = 1,
-	VRF_GOINGDOWN         = 2,
-
-	/* used to store if a wagon is powered or not */
-	VRF_POWEREDWAGON      = 3,
-
-	/* used to reverse the visible direction of the vehicle */
-	VRF_REVERSE_DIRECTION = 4,
-
-	/* used to mark train as lost because PF can't find the route */
-	VRF_NO_PATH_TO_DESTINATION = 5,
-
-	/* used to mark that electric train engine is allowed to run on normal rail */
-	VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
-};
-
-struct VehicleAir {
-	uint16 crashed_counter;
-	uint16 cached_max_speed;
-	byte pos;
-	byte previous_pos;
-	StationID targetairport;
-	byte state;
-};
-
-struct VehicleRoad {
-	byte state;             ///< @see RoadVehicleStates
-	byte frame;
-	uint16 blocked_ctr;
-	byte overtaking;
-	byte overtaking_ctr;
-	uint16 crashed_ctr;
-	byte reverse_ctr;
-	struct RoadStop *slot;
-	byte slot_age;
-	EngineID first_engine;
-	byte cached_veh_length;
-
-	RoadType roadtype;
-	RoadTypes compatible_roadtypes;
-};
-
-struct VehicleSpecial {
-	uint16 animation_state;
-	byte animation_substate;
-};
-
-struct VehicleDisaster {
-	uint16 image_override;
-	VehicleID big_ufo_destroyer_target;
-};
-
-struct VehicleShip {
-	TrackBitsByte state;
-};
-
-struct Vehicle;
-DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
-
-/* Some declarations of functions, so we can make them friendly */
-struct SaveLoad;
-extern const SaveLoad *GetVehicleDescription(VehicleType vt);
-extern void AfterLoadVehicles();
-struct LoadgameState;
-extern bool LoadOldVehicle(LoadgameState *ls, int num);
-
-struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool> {
-	VehicleTypeByte type;    ///< Type of vehicle
-	byte subtype;            // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
-
-private:
-	Vehicle *next;           // pointer to the next vehicle in the chain
-	Vehicle *previous;       // NOSAVE: pointer to the previous vehicle in the chain
-	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
-public:
-	friend const SaveLoad *GetVehicleDescription(VehicleType vt); // So we can use private/protected variables in the saveload code
-	friend void AfterLoadVehicles();                              // So we can set the previous and first pointers while loading
-	friend bool LoadOldVehicle(LoadgameState *ls, int num);       // So we can set the proper next pointer while loading
-
-	Vehicle *depot_list;     // NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
-
-	StringID string_id;      // Displayed string
-
-	UnitID unitnumber;       // unit number, for display purposes only
-	PlayerByte owner;        // which player owns the vehicle?
-
-	TileIndex tile;          // Current tile index
-	TileIndex dest_tile;     // Heading for this tile
-
-	int32 x_pos;             // coordinates
-	int32 y_pos;
-	byte z_pos;
-	DirectionByte direction; // facing
-
-	byte spritenum;          // currently displayed sprite index
-	                         // 0xfd == custom sprite, 0xfe == custom second head sprite
-	                         // 0xff == reserved for another custom sprite
-	uint16 cur_image;        // sprite number for this vehicle
-	byte sprite_width;       // width of vehicle sprite
-	byte sprite_height;      // height of vehicle sprite
-	byte z_height;           // z-height of vehicle sprite
-	int8 x_offs;             // x offset for vehicle sprite
-	int8 y_offs;             // y offset for vehicle sprite
-	EngineID engine_type;
-
-	TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object
-
-	/* for randomized variational spritegroups
-	 * bitmask used to resolve them; parts of it get reseeded when triggers
-	 * of corresponding spritegroups get matched */
-	byte random_bits;
-	byte waiting_triggers;   // triggers to be yet matched
-
-	uint16 max_speed;        // maximum speed
-	uint16 cur_speed;        // current speed
-	byte subspeed;           // fractional speed
-	byte acceleration;       // used by train & aircraft
-	byte progress;
-	uint32 motion_counter;
-
-	byte vehstatus;          // Status
-	StationID last_station_visited;
-
-	CargoID cargo_type;      // type of cargo this vehicle is carrying
-	uint16 cargo_cap;        // total capacity
-	byte cargo_subtype;      ///< Used for livery refits (NewGRF variations)
-	CargoList cargo;         ///< The cargo this vehicle is carrying
-
-
-	byte day_counter;        // increased by one for each day
-	byte tick_counter;       // increased by one for each tick
-
-	/* Begin Order-stuff */
-	Order current_order;     ///< The current order (+ status, like: loading)
-	VehicleOrderID cur_order_index; ///< The index to the current order
-
-	Order *orders;           ///< Pointer to the first order for this vehicle
-	VehicleOrderID num_orders;      ///< How many orders there are in the list
-
-	Vehicle *next_shared;    ///< If not NULL, this points to the next vehicle that shared the order
-	Vehicle *prev_shared;    ///< If not NULL, this points to the prev vehicle that shared the order
-	/* End Order-stuff */
-
-	/* Boundaries for the current position in the world and a next hash link.
-	 * NOSAVE: All of those can be updated with VehiclePositionChanged() */
-	int32 left_coord;
-	int32 top_coord;
-	int32 right_coord;
-	int32 bottom_coord;
-	Vehicle *next_hash;
-	Vehicle *next_new_hash;
-	Vehicle **old_new_hash;
-
-	/* Related to age and service time */
-	Date age;     // Age in days
-	Date max_age; // Maximum age
-	Date date_of_last_service;
-	Date service_interval;
-	uint16 reliability;
-	uint16 reliability_spd_dec;
-	byte breakdown_ctr;
-	byte breakdown_delay;
-	byte breakdowns_since_last_service;
-	byte breakdown_chance;
-	Year build_year;
-
-	bool leave_depot_instantly; // NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace
-
-	uint16 load_unload_time_rem;
-	byte vehicle_flags;         // Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
-
-	Money profit_this_year;
-	Money profit_last_year;
-	Money value;
-
-	GroupID group_id;              ///< Index of group Pool array
-
-	/* Used for timetabling. */
-	uint32 current_order_time;     ///< How many ticks have passed since this order started.
-	int32 lateness_counter;        ///< How many ticks late (or early if negative) this vehicle is.
-
-	SpriteID colormap; // NOSAVE: cached color mapping
-
-	union {
-		VehicleRail rail;
-		VehicleAir air;
-		VehicleRoad road;
-		VehicleSpecial special;
-		VehicleDisaster disaster;
-		VehicleShip ship;
-	} u;
-
-
-	/**
-	 * Allocates a lot of vehicles.
-	 * @param vl pointer to an array of vehicles to get allocated. Can be NULL if the vehicles aren't needed (makes it test only)
-	 * @param num number of vehicles to allocate room for
-	 * @return true if there is room to allocate all the vehicles
-	 */
-	static bool AllocateList(Vehicle **vl, int num);
-
-	/** Create a new vehicle */
-	Vehicle();
-
-	/** Destroy all stuff that (still) needs the virtual functions to work properly */
-	void PreDestructor();
-	/** We want to 'destruct' the right class. */
-	virtual ~Vehicle();
-
-	void BeginLoading();
-	void LeaveStation();
-
-	/**
-	 * Handle the loading of the vehicle; when not it skips through dummy
-	 * orders and does nothing in all other cases.
-	 * @param mode is the non-first call for this vehicle in this tick?
-	 */
-	void HandleLoading(bool mode = false);
-
-	/**
-	 * Get a string 'representation' of the vehicle type.
-	 * @return the string representation.
-	 */
-	virtual const char* GetTypeString() const { return "base vehicle"; }
-
-	/**
-	 * Marks the vehicles to be redrawn and updates cached variables
-	 *
-	 * This method marks the area of the vehicle on the screen as dirty.
-	 * It can be use to repaint the vehicle.
-	 *
-	 * @ingroup dirty
-	 */
-	virtual void MarkDirty() {}
-
-	/**
-	 * Updates the x and y offsets and the size of the sprite used
-	 * for this vehicle.
-	 * @param direction the direction the vehicle is facing
-	 */
-	virtual void UpdateDeltaXY(Direction direction) {}
-
-	/**
-	 * Sets the expense type associated to this vehicle type
-	 * @param income whether this is income or (running) expenses of the vehicle
-	 */
-	virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; }
-
-	/**
-	 * Invalidates the vehicle list window of this type of vehicle
-	 */
-	virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
-
-	/**
-	 * Play the sound associated with leaving the station
-	 */
-	virtual void PlayLeaveStationSound() const {}
-
-	/**
-	 * Whether this is the primary vehicle in the chain.
-	 */
-	virtual bool IsPrimaryVehicle() const { return false; }
-
-	/**
-	 * Gets the sprite to show for the given direction
-	 * @param direction the direction the vehicle is facing
-	 * @return the sprite for the given vehicle in the given direction
-	 */
-	virtual int GetImage(Direction direction) const { return 0; }
-
-	/**
-	 * Gets the speed in mph that can be sent into SetDParam for string processing.
-	 * @return the vehicle's speed
-	 */
-	virtual int GetDisplaySpeed() const { return 0; }
-
-	/**
-	 * Gets the maximum speed in mph that can be sent into SetDParam for string processing.
-	 * @return the vehicle's maximum speed
-	 */
-	virtual int GetDisplayMaxSpeed() const { return 0; }
-
-	/**
-	 * Gets the running cost of a vehicle
-	 * @return the vehicle's running cost
-	 */
-	virtual Money GetRunningCost() const { return 0; }
-
-	/**
-	 * Check whether the vehicle is in the depot.
-	 * @return true if and only if the vehicle is in the depot.
-	 */
-	virtual bool IsInDepot() const { return false; }
-
-	/**
-	 * Check whether the vehicle is in the depot *and* stopped.
-	 * @return true if and only if the vehicle is in the depot and stopped.
-	 */
-	virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; }
-
-	/**
-	 * Calls the tick handler of the vehicle
-	 */
-	virtual void Tick() {};
-
-	/**
-	 * Gets the running cost of a vehicle  that can be sent into SetDParam for string processing.
-	 * @return the vehicle's running cost
-	 */
-	Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
-
-	/**
-	 * Is this vehicle a valid vehicle?
-	 * @return true if and only if the vehicle is valid.
-	 */
-	inline bool IsValid() const { return this->type != VEH_INVALID; }
-
-	/**
-	 * Set the next vehicle of this vehicle.
-	 * @param next the next vehicle. NULL removes the next vehicle.
-	 */
-	void SetNext(Vehicle *next);
-
-	/**
-	 * Get the next vehicle of this vehicle.
-	 * @note articulated parts are also counted as vehicles.
-	 * @return the next vehicle or NULL when there isn't a next vehicle.
-	 */
-	inline Vehicle *Next() const { return this->next; }
-
-	/**
-	 * Get the previous vehicle of this vehicle.
-	 * @note articulated parts are also counted as vehicles.
-	 * @return the previous vehicle or NULL when there isn't a previous vehicle.
-	 */
-	inline Vehicle *Previous() const { return this->previous; }
-
-	/**
-	 * Get the first vehicle of this vehicle chain.
-	 * @return the first vehicle of the chain.
-	 */
-	inline Vehicle *First() const { return this->first; }
-};
-
-/**
- * This class 'wraps' Vehicle; you do not actually instantiate this class.
- * You create a Vehicle using AllocateVehicle, so it is added to the pool
- * and you reinitialize that to a Train using:
- *   v = new (v) Train();
- *
- * As side-effect the vehicle type is set correctly.
- *
- * A special vehicle is one of the following:
- *  - smoke
- *  - electric sparks for trains
- *  - explosions
- *  - bulldozer (road works)
- *  - bubbles (industry)
- */
-struct SpecialVehicle : public Vehicle {
-	/** Initializes the Vehicle to a special vehicle */
-	SpecialVehicle() { this->type = VEH_SPECIAL; }
-
-	/** We want to 'destruct' the right class. */
-	virtual ~SpecialVehicle() {}
-
-	const char *GetTypeString() const { return "special vehicle"; }
-	void UpdateDeltaXY(Direction direction);
-	void Tick();
-};
-
-/**
- * This class 'wraps' Vehicle; you do not actually instantiate this class.
- * You create a Vehicle using AllocateVehicle, so it is added to the pool
- * and you reinitialize that to a Train using:
- *   v = new (v) Train();
- *
- * As side-effect the vehicle type is set correctly.
- */
-struct DisasterVehicle : public Vehicle {
-	/** Initializes the Vehicle to a disaster vehicle */
-	DisasterVehicle() { this->type = VEH_DISASTER; }
-
-	/** We want to 'destruct' the right class. */
-	virtual ~DisasterVehicle() {}
-
-	const char *GetTypeString() const { return "disaster vehicle"; }
-	void UpdateDeltaXY(Direction direction);
-	void Tick();
-};
-
-/**
- * This class 'wraps' Vehicle; you do not actually instantiate this class.
- * You create a Vehicle using AllocateVehicle, so it is added to the pool
- * and you reinitialize that to a Train using:
- *   v = new (v) Train();
- *
- * As side-effect the vehicle type is set correctly.
- */
-struct InvalidVehicle : public Vehicle {
-	/** Initializes the Vehicle to a invalid vehicle */
-	InvalidVehicle() { this->type = VEH_INVALID; }
-
-	/** We want to 'destruct' the right class. */
-	virtual ~InvalidVehicle() {}
-
-	const char *GetTypeString() const { return "invalid vehicle"; }
-	void Tick() {}
-};
-
-#define is_custom_sprite(x) (x >= 0xFD)
-#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
-#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
-
-typedef void *VehicleFromPosProc(Vehicle *v, void *data);
-
-void VehicleServiceInDepot(Vehicle *v);
-void VehiclePositionChanged(Vehicle *v);
-Vehicle *GetLastVehicleInChain(Vehicle *v);
-uint CountVehiclesInChain(const Vehicle *v);
-bool IsEngineCountable(const Vehicle *v);
-void DeleteVehicleChain(Vehicle *v);
-void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
-void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc);
-void CallVehicleTicks();
-Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
-uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color);
-
-void InitializeTrains();
-byte VehicleRandomBits();
-void ResetVehiclePosHash();
-void ResetVehicleColorMap();
-void CheckVehicle32Day(Vehicle *v);
-
-bool CanRefitTo(EngineID engine_type, CargoID cid_to);
-CargoID FindFirstRefittableCargo(EngineID engine_type);
-CommandCost GetRefitCost(EngineID engine_type);
-
-void ViewportAddVehicles(DrawPixelInfo *dpi);
-
-SpriteID GetRotorImage(const Vehicle *v);
-
-Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
-Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
-Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type);
-
-uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
-
-StringID VehicleInTheWayErrMsg(const Vehicle* v);
-Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_crashed = false);
-
-bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection direction);
-void SetSignalsOnBothDir(TileIndex tile, byte track);
-
-Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y);
-
-void DecreaseVehicleValue(Vehicle *v);
-void CheckVehicleBreakdown(Vehicle *v);
-void AgeVehicle(Vehicle *v);
-void VehicleEnteredDepotThisTick(Vehicle *v);
-
-void BeginVehicleMove(Vehicle *v);
-void EndVehicleMove(Vehicle *v);
-
-UnitID GetFreeUnitNumber(VehicleType type);
-
-void TrainConsistChanged(Vehicle *v);
-void TrainPowerChanged(Vehicle *v);
-Money GetTrainRunningCost(const Vehicle *v);
-
-bool VehicleNeedsService(const Vehicle *v);
-
-uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
-void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
-CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
-void VehicleEnterDepot(Vehicle *v);
-
-void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g);
-
-CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
-bool CanBuildVehicleInfrastructure(VehicleType type);
-
-void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
-/* Flags to add to p2 for goto depot commands */
-/* Note: bits 8-10 are used for VLW flags */
-enum {
-	DEPOT_SERVICE       = (1 << 0), // The vehicle will leave the depot right after arrival (serivce only)
-	DEPOT_MASS_SEND     = (1 << 1), // Tells that it's a mass send to depot command (type in VLW flag)
-	DEPOT_DONT_CANCEL   = (1 << 2), // Don't cancel current goto depot command if any
-	DEPOT_LOCATE_HANGAR = (1 << 3), // Find another airport if the target one lacks a hangar
-};
-
-struct GetNewVehiclePosResult {
-	int x, y;
-	TileIndex old_tile;
-	TileIndex new_tile;
-};
-
-/**
- * Returns the Trackdir on which the vehicle is currently located.
- * Works for trains and ships.
- * Currently works only sortof for road vehicles, since they have a fuzzy
- * concept of being "on" a trackdir. Dunno really what it returns for a road
- * vehicle that is halfway a tile, never really understood that part. For road
- * vehicles that are at the beginning or end of the tile, should just return
- * the diagonal trackdir on which they are driving. I _think_.
- * For other vehicles types, or vehicles with no clear trackdir (such as those
- * in depots), returns 0xFF.
- */
-Trackdir GetVehicleTrackdir(const Vehicle* v);
-
-/* returns true if staying in the same tile */
-GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v);
-Direction GetDirectionTowards(const Vehicle *v, int x, int y);
-
-#define BEGIN_ENUM_WAGONS(v) do {
-#define END_ENUM_WAGONS(v) } while ((v = v->Next()) != NULL);
-
-static inline VehicleID GetMaxVehicleIndex()
-{
-	/* TODO - This isn't the real content of the function, but
-	 *  with the new pool-system this will be replaced with one that
-	 *  _really_ returns the highest index. Now it just returns
-	 *  the next safe value we are sure about everything is below.
-	 */
-	return GetVehiclePoolSize() - 1;
-}
-
-static inline uint GetNumVehicles()
-{
-	return GetVehiclePoolSize();
-}
-
-static inline bool IsPlayerBuildableVehicleType(VehicleType type)
-{
-	switch (type) {
-		case VEH_TRAIN:
-		case VEH_ROAD:
-		case VEH_SHIP:
-		case VEH_AIRCRAFT:
-			return true;
-
-		default: return false;
-	}
-}
-
-static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
-{
-	return IsPlayerBuildableVehicleType(v->type);
-}
-
-#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (v->IsValid())
-#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
-
-/**
- * Check if an index is a vehicle-index (so between 0 and max-vehicles)
- * @param index of the vehicle to query
- * @return Returns true if the vehicle-id is in range
- */
-static inline bool IsValidVehicleID(uint index)
-{
-	return index < GetVehiclePoolSize() && GetVehicle(index)->IsValid();
-}
-
-/* Returns order 'index' of a vehicle or NULL when it doesn't exists */
-static inline Order *GetVehicleOrder(const Vehicle *v, int index)
-{
-	Order *order = v->orders;
-
-	if (index < 0) return NULL;
-
-	while (order != NULL && index-- > 0)
-		order = order->next;
-
-	return order;
-}
-
-/**
- * Returns the last order of a vehicle, or NULL if it doesn't exists
- * @param v Vehicle to query
- * @return last order of a vehicle, if available
- */
-static inline Order *GetLastVehicleOrder(const Vehicle *v)
-{
-	Order *order = v->orders;
-
-	if (order == NULL) return NULL;
-
-	while (order->next != NULL)
-		order = order->next;
-
-	return order;
-}
-
-/** Get the first vehicle of a shared-list, so we only have to walk forwards
- * @param v Vehicle to query
- * @return first vehicle of a shared-list
- */
-static inline Vehicle *GetFirstVehicleFromSharedList(const Vehicle *v)
-{
-	Vehicle *u = (Vehicle *)v;
-	while (u->prev_shared != NULL) u = u->prev_shared;
-
-	return u;
-}
-
-/* NOSAVE: Return values from various commands. */
-VARDEF VehicleID _new_vehicle_id;
-VARDEF uint16 _returned_refit_capacity;
-
-static const VehicleID INVALID_VEHICLE = 0xFFFF;
-
-const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v);
-
-/**
- * Get the colour map for an engine. This used for unbuilt engines in the user interface.
- * @param engine_type ID of engine
- * @param player ID of player
- * @return A ready-to-use palette modifier
- */
-SpriteID GetEnginePalette(EngineID engine_type, PlayerID player);
-
-/**
- * Get the colour map for a vehicle.
- * @param v Vehicle to get colour map for
- * @return A ready-to-use palette modifier
- */
-SpriteID GetVehiclePalette(const Vehicle *v);
-
-/* A lot of code calls for the invalidation of the status bar, which is widget 5.
- * Best is to have a virtual value for it when it needs to change again */
-#define STATUS_BAR 5
-
-extern const uint32 _veh_build_proc_table[];
-extern const uint32 _veh_sell_proc_table[];
-extern const uint32 _veh_refit_proc_table[];
-extern const uint32 _send_to_depot_proc_table[];
-
-/* Functions to find the right command for certain vehicle type */
-static inline uint32 GetCmdBuildVeh(VehicleType type)
-{
-	return _veh_build_proc_table[type];
-}
-
-static inline uint32 GetCmdBuildVeh(const Vehicle *v)
-{
-	return GetCmdBuildVeh(v->type);
-}
-
-static inline uint32 GetCmdSellVeh(VehicleType type)
-{
-	return _veh_sell_proc_table[type];
-}
-
-static inline uint32 GetCmdSellVeh(const Vehicle *v)
-{
-	return GetCmdSellVeh(v->type);
-}
-
-static inline uint32 GetCmdRefitVeh(VehicleType type)
-{
-	return _veh_refit_proc_table[type];
-}
-
-static inline uint32 GetCmdRefitVeh(const Vehicle *v)
-{
-	return GetCmdRefitVeh(v->type);
-}
-
-static inline uint32 GetCmdSendToDepot(VehicleType type)
-{
-	return _send_to_depot_proc_table[type];
-}
-
-static inline uint32 GetCmdSendToDepot(const Vehicle *v)
-{
-	return GetCmdSendToDepot(v->type);
-}
-
-#endif /* VEHICLE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vehicle_base.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,614 @@
+/* $Id$ */
+
+/** @file  vehicle_base.h Base class for all vehicles. */
+
+#ifndef VEHICLE_BASE_H
+#define VEHICLE_BASE_H
+
+#include "vehicle_type.h"
+#include "track_type.h"
+#include "rail_type.h"
+#include "road_type.h"
+#include "cargo_type.h"
+#include "direction_type.h"
+#include "window_type.h"
+#include "gfx_type.h"
+#include "command_type.h"
+#include "date_type.h"
+#include "oldpool.h"
+#include "order.h"
+#include "cargopacket.h"
+#include "texteff.hpp"
+
+/** Road vehicle states */
+enum RoadVehicleStates {
+	/*
+	 * Lower 4 bits are used for vehicle track direction. (Trackdirs)
+	 * When in a road stop (bit 5 or bit 6 set) these bits give the
+	 * track direction of the entry to the road stop.
+	 * As the entry direction will always be a diagonal
+	 * direction (X_NE, Y_SE, X_SW or Y_NW) only bits 0 and 3
+	 * are needed to hold this direction. Bit 1 is then used to show
+	 * that the vehicle is using the second road stop bay.
+	 * Bit 2 is then used for drive-through stops to show the vehicle
+	 * is stopping at this road stop.
+	 */
+
+	/* Numeric values */
+	RVSB_IN_DEPOT                = 0xFE,                      ///< The vehicle is in a depot
+	RVSB_WORMHOLE                = 0xFF,                      ///< The vehicle is in a tunnel and/or bridge
+
+	/* Bit numbers */
+	RVS_USING_SECOND_BAY         =    1,                      ///< Only used while in a road stop
+	RVS_IS_STOPPING              =    2,                      ///< Only used for drive-through stops. Vehicle will stop here
+	RVS_DRIVE_SIDE               =    4,                      ///< Only used when retrieving move data
+	RVS_IN_ROAD_STOP             =    5,                      ///< The vehicle is in a road stop
+	RVS_IN_DT_ROAD_STOP          =    6,                      ///< The vehicle is in a drive-through road stop
+
+	/* Bit sets of the above specified bits */
+	RVSB_IN_ROAD_STOP            = 1 << RVS_IN_ROAD_STOP,     ///< The vehicle is in a road stop
+	RVSB_IN_ROAD_STOP_END        = RVSB_IN_ROAD_STOP + TRACKDIR_END,
+	RVSB_IN_DT_ROAD_STOP         = 1 << RVS_IN_DT_ROAD_STOP,  ///< The vehicle is in a drive-through road stop
+	RVSB_IN_DT_ROAD_STOP_END     = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END,
+
+	RVSB_TRACKDIR_MASK           = 0x0F,                      ///< The mask used to extract track dirs
+	RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09                       ///< Only bits 0 and 3 are used to encode the trackdir for road stops
+};
+
+enum VehStatus {
+	VS_HIDDEN          = 0x01,
+	VS_STOPPED         = 0x02,
+	VS_UNCLICKABLE     = 0x04,
+	VS_DEFPAL          = 0x08,
+	VS_TRAIN_SLOWING   = 0x10,
+	VS_SHADOW          = 0x20,
+	VS_AIRCRAFT_BROKEN = 0x40,
+	VS_CRASHED         = 0x80,
+};
+
+enum VehicleFlags {
+	VF_LOADING_FINISHED,
+	VF_CARGO_UNLOADING,
+	VF_BUILT_AS_PROTOTYPE,
+	VF_TIMETABLE_STARTED,  ///< Whether the vehicle has started running on the timetable yet.
+	VF_AUTOFILL_TIMETABLE, ///< Whether the vehicle should fill in the timetable automatically.
+};
+
+struct VehicleRail {
+	uint16 last_speed; // NOSAVE: only used in UI
+	uint16 crash_anim_pos;
+
+	/* cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */
+	uint16 cached_max_speed;  // max speed of the consist. (minimum of the max speed of all vehicles in the consist)
+	uint32 cached_power;      // total power of the consist.
+	bool cached_tilt;         // train can tilt; feature provides a bonus in curves
+	uint8 cached_veh_length;  // length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback
+	uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
+
+	/* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */
+	uint32 cached_weight;     // total weight of the consist.
+	uint32 cached_veh_weight; // weight of the vehicle.
+	uint32 cached_max_te;     // max tractive effort of consist
+	/**
+	 * Position/type of visual effect.
+	 * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear)
+	 * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric)
+	 * bit     6 = disable visual effect.
+	 * bit     7 = disable powered wagons.
+	 */
+	byte cached_vis_effect;
+	byte user_def_data;
+
+	/* NOSAVE: for wagon override - id of the first engine in train
+	 * 0xffff == not in train */
+	EngineID first_engine;
+
+	TrackBitsByte track;
+	byte force_proceed;
+	RailTypeByte railtype;
+	RailTypeMask compatible_railtypes;
+
+	byte flags;
+
+	/* Link between the two ends of a multiheaded engine */
+	Vehicle *other_multiheaded_part;
+
+	/* Cached wagon override spritegroup */
+	const struct SpriteGroup *cached_override;
+};
+
+enum {
+	VRF_REVERSING         = 0,
+
+	/* used to calculate if train is going up or down */
+	VRF_GOINGUP           = 1,
+	VRF_GOINGDOWN         = 2,
+
+	/* used to store if a wagon is powered or not */
+	VRF_POWEREDWAGON      = 3,
+
+	/* used to reverse the visible direction of the vehicle */
+	VRF_REVERSE_DIRECTION = 4,
+
+	/* used to mark train as lost because PF can't find the route */
+	VRF_NO_PATH_TO_DESTINATION = 5,
+
+	/* used to mark that electric train engine is allowed to run on normal rail */
+	VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
+};
+
+struct VehicleAir {
+	uint16 crashed_counter;
+	uint16 cached_max_speed;
+	byte pos;
+	byte previous_pos;
+	StationID targetairport;
+	byte state;
+};
+
+struct VehicleRoad {
+	byte state;             ///< @see RoadVehicleStates
+	byte frame;
+	uint16 blocked_ctr;
+	byte overtaking;
+	byte overtaking_ctr;
+	uint16 crashed_ctr;
+	byte reverse_ctr;
+	struct RoadStop *slot;
+	byte slot_age;
+	EngineID first_engine;
+	byte cached_veh_length;
+
+	RoadType roadtype;
+	RoadTypes compatible_roadtypes;
+};
+
+struct VehicleSpecial {
+	uint16 animation_state;
+	byte animation_substate;
+};
+
+struct VehicleDisaster {
+	uint16 image_override;
+	VehicleID big_ufo_destroyer_target;
+};
+
+struct VehicleShip {
+	TrackBitsByte state;
+};
+
+DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
+
+/* Some declarations of functions, so we can make them friendly */
+struct SaveLoad;
+extern const SaveLoad *GetVehicleDescription(VehicleType vt);
+extern void AfterLoadVehicles(bool clear_te_id);
+struct LoadgameState;
+extern bool LoadOldVehicle(LoadgameState *ls, int num);
+
+struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool>, BaseVehicle {
+	byte subtype;            // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
+
+private:
+	Vehicle *next;           // pointer to the next vehicle in the chain
+	Vehicle *previous;       // NOSAVE: pointer to the previous vehicle in the chain
+	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
+public:
+	friend const SaveLoad *GetVehicleDescription(VehicleType vt); // So we can use private/protected variables in the saveload code
+	friend void AfterLoadVehicles(bool clear_te_id);              // So we can set the previous and first pointers while loading
+	friend bool LoadOldVehicle(LoadgameState *ls, int num);       // So we can set the proper next pointer while loading
+
+	Vehicle *depot_list;     // NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
+
+	StringID string_id;      // Displayed string
+
+	UnitID unitnumber;       // unit number, for display purposes only
+	PlayerByte owner;        // which player owns the vehicle?
+
+	TileIndex tile;          // Current tile index
+	TileIndex dest_tile;     // Heading for this tile
+
+	int32 x_pos;             // coordinates
+	int32 y_pos;
+	byte z_pos;
+	DirectionByte direction; // facing
+
+	byte spritenum;          // currently displayed sprite index
+	                         // 0xfd == custom sprite, 0xfe == custom second head sprite
+	                         // 0xff == reserved for another custom sprite
+	uint16 cur_image;        // sprite number for this vehicle
+	byte sprite_width;       // width of vehicle sprite
+	byte sprite_height;      // height of vehicle sprite
+	byte z_height;           // z-height of vehicle sprite
+	int8 x_offs;             // x offset for vehicle sprite
+	int8 y_offs;             // y offset for vehicle sprite
+	EngineID engine_type;
+
+	TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object
+
+	/* for randomized variational spritegroups
+	 * bitmask used to resolve them; parts of it get reseeded when triggers
+	 * of corresponding spritegroups get matched */
+	byte random_bits;
+	byte waiting_triggers;   // triggers to be yet matched
+
+	uint16 max_speed;        // maximum speed
+	uint16 cur_speed;        // current speed
+	byte subspeed;           // fractional speed
+	byte acceleration;       // used by train & aircraft
+	byte progress;
+	uint32 motion_counter;
+
+	byte vehstatus;          // Status
+	StationID last_station_visited;
+
+	CargoID cargo_type;      // type of cargo this vehicle is carrying
+	uint16 cargo_cap;        // total capacity
+	byte cargo_subtype;      ///< Used for livery refits (NewGRF variations)
+	CargoList cargo;         ///< The cargo this vehicle is carrying
+
+
+	byte day_counter;        // increased by one for each day
+	byte tick_counter;       // increased by one for each tick
+
+	/* Begin Order-stuff */
+	Order current_order;     ///< The current order (+ status, like: loading)
+	VehicleOrderID cur_order_index; ///< The index to the current order
+
+	Order *orders;           ///< Pointer to the first order for this vehicle
+	VehicleOrderID num_orders;      ///< How many orders there are in the list
+
+	Vehicle *next_shared;    ///< If not NULL, this points to the next vehicle that shared the order
+	Vehicle *prev_shared;    ///< If not NULL, this points to the prev vehicle that shared the order
+	/* End Order-stuff */
+
+	/* Boundaries for the current position in the world and a next hash link.
+	 * NOSAVE: All of those can be updated with VehiclePositionChanged() */
+	int32 left_coord;
+	int32 top_coord;
+	int32 right_coord;
+	int32 bottom_coord;
+	Vehicle *next_hash;
+	Vehicle *next_new_hash;
+	Vehicle **old_new_hash;
+
+	/* Related to age and service time */
+	Date age;     // Age in days
+	Date max_age; // Maximum age
+	Date date_of_last_service;
+	Date service_interval;
+	uint16 reliability;
+	uint16 reliability_spd_dec;
+	byte breakdown_ctr;
+	byte breakdown_delay;
+	byte breakdowns_since_last_service;
+	byte breakdown_chance;
+	Year build_year;
+
+	bool leave_depot_instantly; // NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace
+
+	uint16 load_unload_time_rem;
+	byte vehicle_flags;         // Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
+
+	Money profit_this_year;
+	Money profit_last_year;
+	Money value;
+
+	GroupID group_id;              ///< Index of group Pool array
+
+	/* Used for timetabling. */
+	uint32 current_order_time;     ///< How many ticks have passed since this order started.
+	int32 lateness_counter;        ///< How many ticks late (or early if negative) this vehicle is.
+
+	SpriteID colormap; // NOSAVE: cached color mapping
+
+	union {
+		VehicleRail rail;
+		VehicleAir air;
+		VehicleRoad road;
+		VehicleSpecial special;
+		VehicleDisaster disaster;
+		VehicleShip ship;
+	} u;
+
+
+	/**
+	 * Allocates a lot of vehicles.
+	 * @param vl pointer to an array of vehicles to get allocated. Can be NULL if the vehicles aren't needed (makes it test only)
+	 * @param num number of vehicles to allocate room for
+	 * @return true if there is room to allocate all the vehicles
+	 */
+	static bool AllocateList(Vehicle **vl, int num);
+
+	/** Create a new vehicle */
+	Vehicle();
+
+	/** Destroy all stuff that (still) needs the virtual functions to work properly */
+	void PreDestructor();
+	/** We want to 'destruct' the right class. */
+	virtual ~Vehicle();
+
+	void BeginLoading();
+	void LeaveStation();
+
+	/**
+	 * Handle the loading of the vehicle; when not it skips through dummy
+	 * orders and does nothing in all other cases.
+	 * @param mode is the non-first call for this vehicle in this tick?
+	 */
+	void HandleLoading(bool mode = false);
+
+	/**
+	 * Get a string 'representation' of the vehicle type.
+	 * @return the string representation.
+	 */
+	virtual const char* GetTypeString() const { return "base vehicle"; }
+
+	/**
+	 * Marks the vehicles to be redrawn and updates cached variables
+	 *
+	 * This method marks the area of the vehicle on the screen as dirty.
+	 * It can be use to repaint the vehicle.
+	 *
+	 * @ingroup dirty
+	 */
+	virtual void MarkDirty() {}
+
+	/**
+	 * Updates the x and y offsets and the size of the sprite used
+	 * for this vehicle.
+	 * @param direction the direction the vehicle is facing
+	 */
+	virtual void UpdateDeltaXY(Direction direction) {}
+
+	/**
+	 * Sets the expense type associated to this vehicle type
+	 * @param income whether this is income or (running) expenses of the vehicle
+	 */
+	virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; }
+
+	/**
+	 * Invalidates the vehicle list window of this type of vehicle
+	 */
+	virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
+
+	/**
+	 * Play the sound associated with leaving the station
+	 */
+	virtual void PlayLeaveStationSound() const {}
+
+	/**
+	 * Whether this is the primary vehicle in the chain.
+	 */
+	virtual bool IsPrimaryVehicle() const { return false; }
+
+	/**
+	 * Gets the sprite to show for the given direction
+	 * @param direction the direction the vehicle is facing
+	 * @return the sprite for the given vehicle in the given direction
+	 */
+	virtual int GetImage(Direction direction) const { return 0; }
+
+	/**
+	 * Gets the speed in mph that can be sent into SetDParam for string processing.
+	 * @return the vehicle's speed
+	 */
+	virtual int GetDisplaySpeed() const { return 0; }
+
+	/**
+	 * Gets the maximum speed in mph that can be sent into SetDParam for string processing.
+	 * @return the vehicle's maximum speed
+	 */
+	virtual int GetDisplayMaxSpeed() const { return 0; }
+
+	/**
+	 * Gets the running cost of a vehicle
+	 * @return the vehicle's running cost
+	 */
+	virtual Money GetRunningCost() const { return 0; }
+
+	/**
+	 * Check whether the vehicle is in the depot.
+	 * @return true if and only if the vehicle is in the depot.
+	 */
+	virtual bool IsInDepot() const { return false; }
+
+	/**
+	 * Check whether the vehicle is in the depot *and* stopped.
+	 * @return true if and only if the vehicle is in the depot and stopped.
+	 */
+	virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; }
+
+	/**
+	 * Calls the tick handler of the vehicle
+	 */
+	virtual void Tick() {};
+
+	/**
+	 * Gets the running cost of a vehicle  that can be sent into SetDParam for string processing.
+	 * @return the vehicle's running cost
+	 */
+	Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
+
+	/**
+	 * Set the next vehicle of this vehicle.
+	 * @param next the next vehicle. NULL removes the next vehicle.
+	 */
+	void SetNext(Vehicle *next);
+
+	/**
+	 * Get the next vehicle of this vehicle.
+	 * @note articulated parts are also counted as vehicles.
+	 * @return the next vehicle or NULL when there isn't a next vehicle.
+	 */
+	inline Vehicle *Next() const { return this->next; }
+
+	/**
+	 * Get the previous vehicle of this vehicle.
+	 * @note articulated parts are also counted as vehicles.
+	 * @return the previous vehicle or NULL when there isn't a previous vehicle.
+	 */
+	inline Vehicle *Previous() const { return this->previous; }
+
+	/**
+	 * Get the first vehicle of this vehicle chain.
+	 * @return the first vehicle of the chain.
+	 */
+	inline Vehicle *First() const { return this->first; }
+};
+
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ *   v = new (v) Train();
+ *
+ * As side-effect the vehicle type is set correctly.
+ *
+ * A special vehicle is one of the following:
+ *  - smoke
+ *  - electric sparks for trains
+ *  - explosions
+ *  - bulldozer (road works)
+ *  - bubbles (industry)
+ */
+struct SpecialVehicle : public Vehicle {
+	/** Initializes the Vehicle to a special vehicle */
+	SpecialVehicle() { this->type = VEH_SPECIAL; }
+
+	/** We want to 'destruct' the right class. */
+	virtual ~SpecialVehicle() {}
+
+	const char *GetTypeString() const { return "special vehicle"; }
+	void UpdateDeltaXY(Direction direction);
+	void Tick();
+};
+
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ *   v = new (v) Train();
+ *
+ * As side-effect the vehicle type is set correctly.
+ */
+struct DisasterVehicle : public Vehicle {
+	/** Initializes the Vehicle to a disaster vehicle */
+	DisasterVehicle() { this->type = VEH_DISASTER; }
+
+	/** We want to 'destruct' the right class. */
+	virtual ~DisasterVehicle() {}
+
+	const char *GetTypeString() const { return "disaster vehicle"; }
+	void UpdateDeltaXY(Direction direction);
+	void Tick();
+};
+
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ *   v = new (v) Train();
+ *
+ * As side-effect the vehicle type is set correctly.
+ */
+struct InvalidVehicle : public Vehicle {
+	/** Initializes the Vehicle to a invalid vehicle */
+	InvalidVehicle() { this->type = VEH_INVALID; }
+
+	/** We want to 'destruct' the right class. */
+	virtual ~InvalidVehicle() {}
+
+	const char *GetTypeString() const { return "invalid vehicle"; }
+	void Tick() {}
+};
+
+#define BEGIN_ENUM_WAGONS(v) do {
+#define END_ENUM_WAGONS(v) } while ((v = v->Next()) != NULL);
+
+static inline VehicleID GetMaxVehicleIndex()
+{
+	/* TODO - This isn't the real content of the function, but
+	 *  with the new pool-system this will be replaced with one that
+	 *  _really_ returns the highest index. Now it just returns
+	 *  the next safe value we are sure about everything is below.
+	 */
+	return GetVehiclePoolSize() - 1;
+}
+
+static inline uint GetNumVehicles()
+{
+	return GetVehiclePoolSize();
+}
+
+#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (v->IsValid())
+#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
+
+/**
+ * Check if an index is a vehicle-index (so between 0 and max-vehicles)
+ * @param index of the vehicle to query
+ * @return Returns true if the vehicle-id is in range
+ */
+static inline bool IsValidVehicleID(uint index)
+{
+	return index < GetVehiclePoolSize() && GetVehicle(index)->IsValid();
+}
+
+/* Returns order 'index' of a vehicle or NULL when it doesn't exists */
+static inline Order *GetVehicleOrder(const Vehicle *v, int index)
+{
+	Order *order = v->orders;
+
+	if (index < 0) return NULL;
+
+	while (order != NULL && index-- > 0)
+		order = order->next;
+
+	return order;
+}
+
+/**
+ * Returns the last order of a vehicle, or NULL if it doesn't exists
+ * @param v Vehicle to query
+ * @return last order of a vehicle, if available
+ */
+static inline Order *GetLastVehicleOrder(const Vehicle *v)
+{
+	Order *order = v->orders;
+
+	if (order == NULL) return NULL;
+
+	while (order->next != NULL)
+		order = order->next;
+
+	return order;
+}
+
+/** Get the first vehicle of a shared-list, so we only have to walk forwards
+ * @param v Vehicle to query
+ * @return first vehicle of a shared-list
+ */
+static inline Vehicle *GetFirstVehicleFromSharedList(const Vehicle *v)
+{
+	Vehicle *u = (Vehicle *)v;
+	while (u->prev_shared != NULL) u = u->prev_shared;
+
+	return u;
+}
+
+/**
+ * Returns the Trackdir on which the vehicle is currently located.
+ * Works for trains and ships.
+ * Currently works only sortof for road vehicles, since they have a fuzzy
+ * concept of being "on" a trackdir. Dunno really what it returns for a road
+ * vehicle that is halfway a tile, never really understood that part. For road
+ * vehicles that are at the beginning or end of the tile, should just return
+ * the diagonal trackdir on which they are driving. I _think_.
+ * For other vehicles types, or vehicles with no clear trackdir (such as those
+ * in depots), returns 0xFF.
+ */
+Trackdir GetVehicleTrackdir(const Vehicle* v);
+
+void CheckVehicle32Day(Vehicle *v);
+
+#endif /* VEHICLE_BASE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vehicle_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,200 @@
+/* $Id$ */
+
+/** @vehicle.h Functions related to vehicles. */
+
+#ifndef VEHICLE_FUNC_H
+#define VEHICLE_FUNC_H
+
+#include "tile_type.h"
+#include "strings_type.h"
+#include "gfx_type.h"
+#include "direction_type.h"
+#include "cargo_type.h"
+#include "command_type.h"
+#include "vehicle_type.h"
+
+#define is_custom_sprite(x) (x >= 0xFD)
+#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
+#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
+
+typedef void *VehicleFromPosProc(Vehicle *v, void *data);
+
+void VehicleServiceInDepot(Vehicle *v);
+void VehiclePositionChanged(Vehicle *v);
+Vehicle *GetLastVehicleInChain(Vehicle *v);
+uint CountVehiclesInChain(const Vehicle *v);
+bool IsEngineCountable(const Vehicle *v);
+void DeleteVehicleChain(Vehicle *v);
+void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
+void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc);
+void CallVehicleTicks();
+Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
+uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color);
+
+void InitializeTrains();
+byte VehicleRandomBits();
+void ResetVehiclePosHash();
+void ResetVehicleColorMap();
+
+bool CanRefitTo(EngineID engine_type, CargoID cid_to);
+CargoID FindFirstRefittableCargo(EngineID engine_type);
+CommandCost GetRefitCost(EngineID engine_type);
+
+void ViewportAddVehicles(DrawPixelInfo *dpi);
+
+SpriteID GetRotorImage(const Vehicle *v);
+
+uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
+
+StringID VehicleInTheWayErrMsg(const Vehicle* v);
+Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_crashed = false);
+Vehicle *GetVehicleTunnelBridge(TileIndex tile, TileIndex endtile);
+
+bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection direction);
+void SetSignalsOnBothDir(TileIndex tile, byte track);
+
+Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y);
+
+void DecreaseVehicleValue(Vehicle *v);
+void CheckVehicleBreakdown(Vehicle *v);
+void AgeVehicle(Vehicle *v);
+void VehicleEnteredDepotThisTick(Vehicle *v);
+
+void BeginVehicleMove(Vehicle *v);
+void EndVehicleMove(Vehicle *v);
+
+UnitID GetFreeUnitNumber(VehicleType type);
+
+void TrainConsistChanged(Vehicle *v);
+void TrainPowerChanged(Vehicle *v);
+Money GetTrainRunningCost(const Vehicle *v);
+
+bool VehicleNeedsService(const Vehicle *v);
+
+uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
+void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
+CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
+void VehicleEnterDepot(Vehicle *v);
+
+CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
+bool CanBuildVehicleInfrastructure(VehicleType type);
+
+void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
+
+/* Flags to add to p2 for goto depot commands */
+/* Note: bits 8-10 are used for VLW flags */
+enum {
+	DEPOT_SERVICE       = (1 << 0), // The vehicle will leave the depot right after arrival (serivce only)
+	DEPOT_MASS_SEND     = (1 << 1), // Tells that it's a mass send to depot command (type in VLW flag)
+	DEPOT_DONT_CANCEL   = (1 << 2), // Don't cancel current goto depot command if any
+	DEPOT_LOCATE_HANGAR = (1 << 3), // Find another airport if the target one lacks a hangar
+};
+
+struct GetNewVehiclePosResult {
+	int x, y;
+	TileIndex old_tile;
+	TileIndex new_tile;
+};
+
+/* returns true if staying in the same tile */
+GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v);
+Direction GetDirectionTowards(const Vehicle *v, int x, int y);
+
+static inline bool IsPlayerBuildableVehicleType(VehicleType type)
+{
+	switch (type) {
+		case VEH_TRAIN:
+		case VEH_ROAD:
+		case VEH_SHIP:
+		case VEH_AIRCRAFT:
+			return true;
+
+		default: return false;
+	}
+}
+
+static inline bool IsPlayerBuildableVehicleType(const BaseVehicle *v)
+{
+	return IsPlayerBuildableVehicleType(v->type);
+}
+
+const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v);
+
+/**
+ * Get the colour map for an engine. This used for unbuilt engines in the user interface.
+ * @param engine_type ID of engine
+ * @param player ID of player
+ * @return A ready-to-use palette modifier
+ */
+SpriteID GetEnginePalette(EngineID engine_type, PlayerID player);
+
+/**
+ * Get the colour map for a vehicle.
+ * @param v Vehicle to get colour map for
+ * @return A ready-to-use palette modifier
+ */
+SpriteID GetVehiclePalette(const Vehicle *v);
+
+/* A lot of code calls for the invalidation of the status bar, which is widget 5.
+ * Best is to have a virtual value for it when it needs to change again */
+#define STATUS_BAR 5
+
+extern const uint32 _veh_build_proc_table[];
+extern const uint32 _veh_sell_proc_table[];
+extern const uint32 _veh_refit_proc_table[];
+extern const uint32 _send_to_depot_proc_table[];
+
+/* Functions to find the right command for certain vehicle type */
+static inline uint32 GetCmdBuildVeh(VehicleType type)
+{
+	return _veh_build_proc_table[type];
+}
+
+static inline uint32 GetCmdBuildVeh(const BaseVehicle *v)
+{
+	return GetCmdBuildVeh(v->type);
+}
+
+static inline uint32 GetCmdSellVeh(VehicleType type)
+{
+	return _veh_sell_proc_table[type];
+}
+
+static inline uint32 GetCmdSellVeh(const BaseVehicle *v)
+{
+	return GetCmdSellVeh(v->type);
+}
+
+static inline uint32 GetCmdRefitVeh(VehicleType type)
+{
+	return _veh_refit_proc_table[type];
+}
+
+static inline uint32 GetCmdRefitVeh(const BaseVehicle *v)
+{
+	return GetCmdRefitVeh(v->type);
+}
+
+static inline uint32 GetCmdSendToDepot(VehicleType type)
+{
+	return _send_to_depot_proc_table[type];
+}
+
+static inline uint32 GetCmdSendToDepot(const BaseVehicle *v)
+{
+	return GetCmdSendToDepot(v->type);
+}
+
+bool EnsureNoVehicleOnGround(TileIndex tile);
+void StopAllVehicles();
+
+Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
+Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
+Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type);
+
+extern VehicleID _vehicle_id_ctr_day;
+extern Vehicle *_place_clicked_vehicle;
+extern VehicleID _new_vehicle_id;
+extern uint16 _returned_refit_capacity;
+
+#endif /* VEHICLE_H */
--- a/src/vehicle_gui.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/vehicle_gui.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,33 +5,37 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
 #include "player.h"
 #include "station.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "vehicle.h"
-#include "window.h"
 #include "engine.h"
 #include "gui.h"
-#include "command.h"
-#include "gfx.h"
+#include "window_gui.h"
+#include "textbuf_gui.h"
+#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"
 #include "newgrf_text.h"
-#include "date.h"
 #include "ship.h"
 #include "aircraft.h"
 #include "roadveh.h"
 #include "depot.h"
-#include "helpers.hpp"
 #include "cargotype.h"
 #include "group.h"
+#include "group_gui.h"
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "autoreplace_gui.h"
+#include "core/alloc_func.hpp"
+#include "string_func.h"
 
 struct Sorting {
 	Listing aircraft;
@@ -506,6 +510,8 @@
 		for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
 			if (!HasBit(cmask, cid)) continue;
 
+			if (b >= lastof(_userstring) - (2 + 2 * 4)) break; // ", " and two calls to Utf8Encode()
+
 			if (!first) b = strecpy(b, ", ", lastof(_userstring));
 			first = false;
 
@@ -515,6 +521,10 @@
 
 	/* Terminate and display the completed string */
 	*b = '\0';
+
+	/* Make sure we detect any buffer overflow */
+	assert(b < endof(_userstring));
+
 	return DrawStringMultiLine(x, y, STR_SPEC_USERSTRING, w);
 }
 
@@ -789,10 +799,10 @@
 	/* Hide the widgets that we will not use in this window
 	 * Some windows contains actions only fit for the owner */
 	if (player == _local_player) {
-		HideWindowWidget(w, VLW_WIDGET_OTHER_PLAYER_FILLER);
-		SetWindowWidgetDisabledState(w, VLW_WIDGET_AVAILABLE_VEHICLES, window_type != VLW_STANDARD);
+		w->HideWidget(VLW_WIDGET_OTHER_PLAYER_FILLER);
+		w->SetWidgetDisabledState(VLW_WIDGET_AVAILABLE_VEHICLES, window_type != VLW_STANDARD);
 	} else {
-		SetWindowWidgetsHiddenState(w, true,
+		w->SetWidgetsHiddenState(true,
 			VLW_WIDGET_AVAILABLE_VEHICLES,
 			VLW_WIDGET_MANAGE_VEHICLES,
 			VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN,
@@ -976,7 +986,7 @@
 		default: NOT_REACHED(); break;
 	}
 
-	SetWindowWidgetsDisabledState(w, vl->l.list_length == 0,
+	w->SetWidgetsDisabledState(vl->l.list_length == 0,
 		VLW_WIDGET_MANAGE_VEHICLES,
 		VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN,
 		VLW_WIDGET_STOP_ALL,
@@ -998,7 +1008,7 @@
 		SetDParam(0, v->profit_this_year);
 		SetDParam(1, v->profit_last_year);
 
-		DrawVehicleImage(v, x + 19, y + 6, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0, INVALID_VEHICLE);
+		DrawVehicleImage(v, x + 19, y + 6, INVALID_VEHICLE, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0);
 		DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
 
 		if ((v->type == VEH_TRAIN    && v->string_id != STR_SV_TRAIN_NAME)   ||
@@ -1151,6 +1161,7 @@
 			break;
 
 		case WE_TICK: /* resort the list every 20 seconds orso (10 days) */
+			if (_pause_game != 0) break;
 			if (--vl->l.resort_timer == 0) {
 				StationID station = ((w->window_number & VLW_MASK) == VLW_STATION_LIST) ? GB(w->window_number, 16, 16) : INVALID_STATION;
 				PlayerID owner = (PlayerID)w->caption_color;
@@ -1460,14 +1471,14 @@
 	const Vehicle *v = GetVehicle(w->window_number);
 	byte det_tab = WP(w, vehicledetails_d).tab;
 
-	SetWindowWidgetDisabledState(w, VLD_WIDGET_RENAME_VEHICLE, v->owner != _local_player);
+	w->SetWidgetDisabledState(VLD_WIDGET_RENAME_VEHICLE, v->owner != _local_player);
 
 	if (v->type == VEH_TRAIN) {
-		DisableWindowWidget(w, det_tab + VLD_WIDGET_DETAILS_CARGO_CARRIED);
+		w->DisableWidget(det_tab + VLD_WIDGET_DETAILS_CARGO_CARRIED);
 		SetVScrollCount(w, GetTrainDetailsWndVScroll(v->index, det_tab));
 	}
 
-	SetWindowWidgetsHiddenState(w, v->type != VEH_TRAIN,
+	w->SetWidgetsHiddenState(v->type != VEH_TRAIN,
 		VLD_WIDGET_SCROLLBAR,
 		VLD_WIDGET_DETAILS_CARGO_CARRIED,
 		VLD_WIDGET_DETAILS_TRAIN_VEHICLES,
@@ -1477,7 +1488,7 @@
 		WIDGET_LIST_END);
 
 	/* Disable service-scroller when interval is set to disabled */
-	SetWindowWidgetsDisabledState(w, !IsVehicleServiceIntervalEnabled(v->type),
+	w->SetWidgetsDisabledState(!IsVehicleServiceIntervalEnabled(v->type),
 		VLD_WIDGET_INCREASE_SERVICING_INTERVAL,
 		VLD_WIDGET_DECREASE_SERVICING_INTERVAL,
 		WIDGET_LIST_END);
@@ -1538,7 +1549,7 @@
 		case VEH_ROAD:
 		case VEH_SHIP:
 		case VEH_AIRCRAFT:
-			DrawVehicleImage(v, 3, 57, 0, 0, INVALID_VEHICLE);
+			DrawVehicleImage(v, 3, 57, INVALID_VEHICLE, 0, 0);
 			DrawVehicleDetails(v, 75, 57, w->vscroll.pos, w->vscroll.cap, det_tab);
 			break;
 
@@ -1598,7 +1609,7 @@
 				case VLD_WIDGET_DETAILS_TRAIN_VEHICLES:
 				case VLD_WIDGET_DETAILS_CAPACITY_OF_EACH:
 				case VLD_WIDGET_DETAILS_TOTAL_CARGO:
-					SetWindowWidgetsDisabledState(w, false,
+					w->SetWidgetsDisabledState(false,
 						VLD_WIDGET_DETAILS_CARGO_CARRIED,
 						VLD_WIDGET_DETAILS_TRAIN_VEHICLES,
 						VLD_WIDGET_DETAILS_CAPACITY_OF_EACH,
@@ -1826,7 +1837,7 @@
 			w->widget[VVW_WIDGET_CLONE_VEH].data = SPR_CLONE_ROADVEH;
 			w->widget[VVW_WIDGET_CLONE_VEH].tooltips = STR_CLONE_ROAD_VEHICLE_INFO;
 
-			SetWindowWidgetHiddenState(w, VVW_WIDGET_FORCE_PROCEED, true);
+			w->SetWidgetHiddenState(VVW_WIDGET_FORCE_PROCEED, true);
 			break;
 
 		case VEH_SHIP:
@@ -1848,7 +1859,7 @@
 			w->widget[VVW_WIDGET_CLONE_VEH].data = SPR_CLONE_SHIP;
 			w->widget[VVW_WIDGET_CLONE_VEH].tooltips = STR_CLONE_SHIP_INFO;
 
-			SetWindowWidgetsHiddenState(w, true,
+			w->SetWidgetsHiddenState(true,
 																	VVW_WIDGET_TURN_AROUND,
 																	VVW_WIDGET_FORCE_PROCEED,
 																	WIDGET_LIST_END);
@@ -1873,7 +1884,7 @@
 			w->widget[VVW_WIDGET_CLONE_VEH].data = SPR_CLONE_AIRCRAFT;
 			w->widget[VVW_WIDGET_CLONE_VEH].tooltips = STR_CLONE_AIRCRAFT_INFO;
 
-			SetWindowWidgetsHiddenState(w, true,
+			w->SetWidgetsHiddenState(true,
 																	VVW_WIDGET_TURN_AROUND,
 																	VVW_WIDGET_FORCE_PROCEED,
 																	WIDGET_LIST_END);
@@ -1922,14 +1933,14 @@
 	bool is_localplayer = v->owner == _local_player;
 	bool refitable_and_stopped_in_depot = IsVehicleRefitable(v);
 
-	SetWindowWidgetDisabledState(w, VVW_WIDGET_GOTO_DEPOT, !is_localplayer);
-	SetWindowWidgetDisabledState(w, VVW_WIDGET_REFIT_VEH,
+	w->SetWidgetDisabledState(VVW_WIDGET_GOTO_DEPOT, !is_localplayer);
+	w->SetWidgetDisabledState(VVW_WIDGET_REFIT_VEH,
 															 !refitable_and_stopped_in_depot || !is_localplayer);
-	SetWindowWidgetDisabledState(w, VVW_WIDGET_CLONE_VEH, !is_localplayer);
+	w->SetWidgetDisabledState(VVW_WIDGET_CLONE_VEH, !is_localplayer);
 
 	if (v->type == VEH_TRAIN) {
-		SetWindowWidgetDisabledState(w, VVW_WIDGET_FORCE_PROCEED, !is_localplayer);
-		SetWindowWidgetDisabledState(w, VVW_WIDGET_TURN_AROUND, !is_localplayer);
+		w->SetWidgetDisabledState(VVW_WIDGET_FORCE_PROCEED, !is_localplayer);
+		w->SetWidgetDisabledState(VVW_WIDGET_TURN_AROUND, !is_localplayer);
 
 		/* Cargo refit button is disabled, until we know we can enable it below. */
 
@@ -1938,7 +1949,7 @@
 			for (const Vehicle *u = v; u != NULL; u = u->Next()) {
 				if (EngInfo(u->engine_type)->refit_mask != 0 ||
 						(RailVehInfo(v->engine_type)->railveh_type != RAILVEH_WAGON && v->cargo_cap != 0)) {
-					EnableWindowWidget(w, VVW_WIDGET_REFIT_VEH);
+					w->EnableWidget(VVW_WIDGET_REFIT_VEH);
 					/* We have a refittable carriage, bail out */
 					break;
 				}
@@ -2150,15 +2161,26 @@
 			 * allowed only while in depot and stopped.
 			 * This sytem allows to have two buttons, on top of each other.
 			 * The same system applies to widget VVW_WIDGET_REFIT_VEH and VVW_WIDGET_TURN_AROUND.*/
-			if (veh_stopped != IsWindowWidgetHidden(w, VVW_WIDGET_GOTO_DEPOT) || veh_stopped == IsWindowWidgetHidden(w, VVW_WIDGET_CLONE_VEH)) {
-				SetWindowWidgetHiddenState(w,  VVW_WIDGET_GOTO_DEPOT, veh_stopped);  // send to depot
-				SetWindowWidgetHiddenState(w, VVW_WIDGET_CLONE_VEH, !veh_stopped); // clone
+			if (veh_stopped != w->IsWidgetHidden(VVW_WIDGET_GOTO_DEPOT) || veh_stopped == w->IsWidgetHidden(VVW_WIDGET_CLONE_VEH)) {
+				w->SetWidgetHiddenState( VVW_WIDGET_GOTO_DEPOT, veh_stopped);  // send to depot
+				w->SetWidgetHiddenState(VVW_WIDGET_CLONE_VEH, !veh_stopped); // clone
 				if (v->type == VEH_ROAD || v->type == VEH_TRAIN) {
-					SetWindowWidgetHiddenState(w,  VVW_WIDGET_REFIT_VEH, !veh_stopped); // refit
-					SetWindowWidgetHiddenState(w, VVW_WIDGET_TURN_AROUND, veh_stopped);  // force turn around
+					w->SetWidgetHiddenState( VVW_WIDGET_REFIT_VEH, !veh_stopped); // refit
+					w->SetWidgetHiddenState(VVW_WIDGET_TURN_AROUND, veh_stopped);  // force turn around
 				}
 				SetWindowDirty(w);
 			}
 		} break;
 	}
 }
+
+void DrawVehicleImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip)
+{
+	switch (v->type) {
+		case VEH_TRAIN:    DrawTrainImage(v, x, y, selection, count, skip); break;
+		case VEH_ROAD:     DrawRoadVehImage(v, x, y, selection, count);     break;
+		case VEH_SHIP:     DrawShipImage(v, x, y, selection);               break;
+		case VEH_AIRCRAFT: DrawAircraftImage(v, x, y, selection);           break;
+		default: NOT_REACHED();
+	}
+}
--- a/src/vehicle_gui.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/vehicle_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,8 +5,8 @@
 #ifndef VEHICLE_GUI_H
 #define VEHICLE_GUI_H
 
-#include "window.h"
-#include "vehicle.h"
+#include "window_gui.h"
+#include "vehicle_type.h"
 
 void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
 void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order);
@@ -50,8 +50,8 @@
 
 int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number);
 
-void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection);
-void DrawRoadVehImage(const Vehicle *v, int x, int y, int count, VehicleID selection);
+void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip);
+void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int count);
 void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection);
 void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection);
 
@@ -67,20 +67,9 @@
 void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station);
 void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile);
 
-void ShowReplaceVehicleWindow(VehicleType vehicletype);
 void DrawSmallOrderList(const Vehicle *v, int x, int y);
-void ShowReplaceGroupVehicleWindow(GroupID group, VehicleType veh);
 
-static inline void DrawVehicleImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
-{
-	switch (v->type) {
-		case VEH_TRAIN:    DrawTrainImage(v, x, y, count, skip, selection); break;
-		case VEH_ROAD:     DrawRoadVehImage(v, x, y, count, selection);     break;
-		case VEH_SHIP:     DrawShipImage(v, x, y, selection);               break;
-		case VEH_AIRCRAFT: DrawAircraftImage(v, x, y, selection);           break;
-		default: NOT_REACHED();
-	}
-}
+void DrawVehicleImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip);
 
 static inline uint GetVehicleListHeight(VehicleType type)
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vehicle_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,55 @@
+/* $Id$ */
+
+/** @file vehicle_type.h Types related to vehicles. */
+
+#ifndef VEHICLE_TYPE_H
+#define VEHICLE_TYPE_H
+
+#include "core/enum_type.hpp"
+
+typedef uint16 VehicleID;
+
+enum VehicleType {
+	VEH_TRAIN,
+	VEH_ROAD,
+	VEH_SHIP,
+	VEH_AIRCRAFT,
+	VEH_SPECIAL,
+	VEH_DISASTER,
+	VEH_END,
+	VEH_INVALID = 0xFF,
+};
+DECLARE_POSTFIX_INCREMENT(VehicleType);
+template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID> {};
+typedef TinyEnumT<VehicleType> VehicleTypeByte;
+
+struct Vehicle;
+
+struct BaseVehicle
+{
+	VehicleTypeByte type;    ///< Type of vehicle
+
+	/**
+	 * Is this vehicle a valid vehicle?
+	 * @return true if and only if the vehicle is valid.
+	 */
+	inline bool IsValid() const { return this->type != VEH_INVALID; }
+};
+
+static const VehicleID INVALID_VEHICLE = 0xFFFF;
+
+/* Effect vehicle types */
+enum EffectVehicle {
+	EV_CHIMNEY_SMOKE   = 0,
+	EV_STEAM_SMOKE     = 1,
+	EV_DIESEL_SMOKE    = 2,
+	EV_ELECTRIC_SPARK  = 3,
+	EV_SMOKE           = 4,
+	EV_EXPLOSION_LARGE = 5,
+	EV_BREAKDOWN_SMOKE = 6,
+	EV_EXPLOSION_SMALL = 7,
+	EV_BULLDOZER       = 8,
+	EV_BUBBLE          = 9
+};
+
+#endif /* VEHICLE_TYPE_H */
--- a/src/video/cocoa/cocoa_v.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/cocoa/cocoa_v.h	Wed Jan 09 18:11:12 2008 +0000
@@ -3,6 +3,8 @@
 #ifndef VIDEO_COCOA_H
 #define VIDEO_COCOA_H
 
+#include <AvailabilityMacros.h>
+
 #include "../video_driver.hpp"
 
 class VideoDriver_Cocoa: public VideoDriver {
@@ -17,7 +19,7 @@
 
 	/* virtual */ bool ChangeResolution(int w, int h);
 
-	/* virtual */ void ToggleFullscreen(bool fullscreen);
+	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 };
 
 class FVideoDriver_Cocoa: public VideoDriverFactory<FVideoDriver_Cocoa> {
@@ -38,7 +40,7 @@
 	virtual void MakeDirty(int left, int top, int width, int height) = 0;
 	virtual void UpdatePalette(uint first_color, uint num_colors) = 0;
 
-	virtual uint ListModes(OTTDPoint* modes, uint max_modes) = 0;
+	virtual uint ListModes(OTTD_Point* modes, uint max_modes) = 0;
 
 	virtual bool ChangeResolution(int w, int h) = 0;
 
@@ -59,8 +61,16 @@
 extern CocoaSubdriver* _cocoa_subdriver;
 
 CocoaSubdriver *QZ_CreateFullscreenSubdriver(int width, int height, int bpp);
+
+#ifdef ENABLE_COCOA_QUICKDRAW
+CocoaSubdriver *QZ_CreateWindowQuickdrawSubdriver(int width, int height, int bpp);
+#endif
+
+#ifdef ENABLE_COCOA_QUARTZ
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
 CocoaSubdriver *QZ_CreateWindowQuartzSubdriver(int width, int height, int bpp);
-CocoaSubdriver *QZ_CreateWindowQuickdrawSubdriver(int width, int height, int bpp);
+#endif
+#endif
 
 void QZ_GameSizeChanged();
 
@@ -69,4 +79,6 @@
 void QZ_ShowMouse();
 void QZ_HideMouse();
 
+uint QZ_ListModes(OTTD_Point* modes, uint max_modes, CGDirectDisplayID display_id, int display_depth);
+
 #endif /* VIDEO_COCOA_H */
--- a/src/video/cocoa/cocoa_v.mm	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/cocoa/cocoa_v.mm	Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,7 @@
 
 #ifdef WITH_COCOA
 
+#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
 #include <AvailabilityMacros.h>
 
 #import <Cocoa/Cocoa.h>
@@ -55,17 +56,12 @@
 #include "../../stdafx.h"
 #include "../../openttd.h"
 #include "../../debug.h"
-#include "../../macros.h"
-#include "../../os/macosx/splash.h"
 #include "../../variables.h"
-#include "../../gfx.h"
+#include "../../core/geometry_type.hpp"
 #include "cocoa_v.h"
-#include "cocoa_keys.h"
 #include "../../blitter/factory.hpp"
 #include "../../fileio.h"
-
-#undef Point
-#undef Rect
+#include "../../gfx_func.h"
 
 
 @interface OTTDMain : NSObject
@@ -202,7 +198,7 @@
 static void QZ_UpdateVideoModes()
 {
 	uint i, count;
-	OTTDPoint modes[32];
+	OTTD_Point modes[32];
 
 	assert(_cocoa_subdriver != NULL);
 
@@ -233,13 +229,37 @@
 
 static CocoaSubdriver *QZ_CreateWindowSubdriver(int width, int height, int bpp)
 {
-	long sysVersion;
+	CocoaSubdriver *ret;
 
-	if (Gestalt(gestaltSystemVersion, &sysVersion) == noErr && sysVersion >= 0x1040) {
-		return QZ_CreateWindowQuartzSubdriver(width, height, bpp);
+#ifdef ENABLE_COCOA_QUARTZ
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+	/* The reason for the version mismatch is due to the fact that the 10.4 binary needs to work on 10.5 as well. */
+	if (MacOSVersionIsAtLeast(10, 5, 0)) {
+		ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
+		if (ret != NULL) return ret;
 	}
+#endif
+#endif
 
-	return QZ_CreateWindowQuickdrawSubdriver(width, height, bpp);
+#ifdef ENABLE_COCOA_QUICKDRAW
+	ret = QZ_CreateWindowQuickdrawSubdriver(width, height, bpp);
+	if (ret != NULL) return ret;
+#endif
+
+#ifdef ENABLE_COCOA_QUARTZ
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+        /*
+	 * If we get here we are running 10.4 or earlier and either openttd was compiled without the quickdraw driver
+	 * or it failed to load for some reason. Fall back to Quartz if possible even though that driver is slower.
+	 */
+        if (MacOSVersionIsAtLeast(10, 4, 0)) {
+                ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
+                if (ret != NULL) return ret;
+        }
+#endif
+#endif
+
+	return NULL;
 }
 
 
@@ -286,6 +306,8 @@
 {
 	int width, height, bpp;
 
+	if (!MacOSVersionIsAtLeast(10, 3, 0)) return "The Cocoa video driver requires Mac OS X 10.3 or later.";
+
 	if (_cocoa_video_started) return "Already started";
 	_cocoa_video_started = true;
 
@@ -339,7 +361,7 @@
 	return ret;
 }
 
-void VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
+bool VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
 {
 	bool oldfs;
 
@@ -364,6 +386,7 @@
 	QZ_GameSizeChanged();
 
 	QZ_UpdateVideoModes();
+	return _cocoa_subdriver->IsFullscreen() == full_screen;
 }
 
 
--- a/src/video/cocoa/event.mm	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/cocoa/event.mm	Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,9 @@
 
 #ifdef WITH_COCOA
 
+#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
+#include <AvailabilityMacros.h>
+
 #import <Cocoa/Cocoa.h>
 #import <sys/time.h> /* gettimeofday */
 #import <sys/param.h> /* for MAXPATHLEN */
@@ -35,17 +38,15 @@
 #include "../../stdafx.h"
 #include "../../openttd.h"
 #include "../../debug.h"
-#include "../../macros.h"
 #include "../../os/macosx/splash.h"
 #include "../../variables.h"
-#include "../../gfx.h"
+#include "../../core/geometry_type.hpp"
 #include "cocoa_v.h"
 #include "cocoa_keys.h"
 #include "../../blitter/factory.hpp"
-#include "../../fileio.h"
+#include "../../gfx_func.h"
+#include "../../network/network.h"
 
-#undef Point
-#undef Rect
 
 /* Right Mouse Button Emulation enum */
 enum {
@@ -433,7 +434,6 @@
 	switch ([event type]) {
 		case NSMouseMoved:
 		case NSOtherMouseDragged:
-		case NSRightMouseDragged:
 		case NSLeftMouseDragged:
 			pt = _cocoa_subdriver->GetMouseLocation(event);
 			if (!_cocoa_subdriver->MouseIsInsideView(&pt) &&
@@ -447,6 +447,12 @@
 			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
 			break;
 
+		case NSRightMouseDragged:
+			pt = _cocoa_subdriver->GetMouseLocation(event);
+			QZ_HideMouse();
+			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
+			break;
+
 		case NSLeftMouseDown:
 		{
 			uint32 keymask = 0;
--- a/src/video/cocoa/fullscreen.mm	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/cocoa/fullscreen.mm	Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,7 @@
 
 #ifdef WITH_COCOA
 
+#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
 #include <AvailabilityMacros.h>
 
 #import <Cocoa/Cocoa.h>
@@ -39,18 +40,11 @@
 
 
 #include "../../stdafx.h"
-#include "../../openttd.h"
 #include "../../debug.h"
-#include "../../macros.h"
-#include "../../os/macosx/splash.h"
-#include "../../variables.h"
-#include "../../gfx.h"
+#include "../../core/geometry_type.hpp"
 #include "cocoa_v.h"
-#include "cocoa_keys.h"
-#include "../../blitter/factory.hpp"
-#include "../../fileio.h"
+#include "../../gfx_func.h"
 
-#undef Point
 #undef Rect
 
 
@@ -82,6 +76,86 @@
 @end
 
 
+
+uint QZ_ListModes(OTTD_Point* modes, uint max_modes, CGDirectDisplayID display_id, int display_depth)
+{
+	CFArrayRef mode_list;
+	CFIndex num_modes;
+	CFIndex i;
+	uint count = 0;
+
+	mode_list  = CGDisplayAvailableModes(display_id);
+	num_modes = CFArrayGetCount(mode_list);
+
+	/* Build list of modes with the requested bpp */
+	for (i = 0; i < num_modes && count < max_modes; i++) {
+		CFDictionaryRef onemode;
+		CFNumberRef     number;
+		int bpp;
+		int intvalue;
+		bool hasMode;
+		uint16 width, height;
+
+		onemode = (const __CFDictionary*)CFArrayGetValueAtIndex(mode_list, i);
+		number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayBitsPerPixel);
+		CFNumberGetValue (number, kCFNumberSInt32Type, &bpp);
+
+		if (bpp != display_depth) continue;
+
+		number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayWidth);
+		CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
+		width = (uint16)intvalue;
+
+		number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayHeight);
+		CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
+		height = (uint16)intvalue;
+
+		/* Check if mode is already in the list */
+		{
+			uint i;
+			hasMode = false;
+			for (i = 0; i < count; i++) {
+				if (modes[i].x == width &&  modes[i].y == height) {
+					hasMode = true;
+					break;
+				}
+			}
+		}
+
+		if (hasMode) continue;
+
+		/* Add mode to the list */
+		modes[count].x = width;
+		modes[count].y = height;
+		count++;
+	}
+
+	/* Sort list smallest to largest */
+	{
+		uint i, j;
+		for (i = 0; i < count; i++) {
+			for (j = 0; j < count-1; j++) {
+				if (modes[j].x > modes[j + 1].x || (
+					modes[j].x == modes[j + 1].x &&
+					modes[j].y >  modes[j + 1].y
+					)) {
+					uint tmpw = modes[j].x;
+					uint tmph = modes[j].y;
+
+					modes[j].x = modes[j + 1].x;
+					modes[j].y = modes[j + 1].y;
+
+					modes[j + 1].x = tmpw;
+					modes[j + 1].y = tmph;
+				}
+			}
+		}
+	}
+
+	return count;
+}
+
+
 class FullscreenSubdriver: public CocoaSubdriver {
 	int                display_width;
 	int                display_height;
@@ -453,82 +527,9 @@
 		CGDisplaySetPalette(display_id, palette);
 	}
 
-	virtual uint ListModes(OTTDPoint* modes, uint max_modes)
+	virtual uint ListModes(OTTD_Point* modes, uint max_modes)
 	{
-		CFArrayRef mode_list;
-		CFIndex num_modes;
-		CFIndex i;
-		uint count = 0;
-
-		mode_list  = CGDisplayAvailableModes(display_id);
-		num_modes = CFArrayGetCount(mode_list);
-
-		/* Build list of modes with the requested bpp */
-		for (i = 0; i < num_modes && count < max_modes; i++) {
-			CFDictionaryRef onemode;
-			CFNumberRef     number;
-			int bpp;
-			int intvalue;
-			bool hasMode;
-			uint16 width, height;
-
-			onemode = (const __CFDictionary*)CFArrayGetValueAtIndex(mode_list, i);
-			number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayBitsPerPixel);
-			CFNumberGetValue (number, kCFNumberSInt32Type, &bpp);
-
-			if (bpp != display_depth) continue;
-
-			number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayWidth);
-			CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
-			width = (uint16)intvalue;
-
-			number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayHeight);
-			CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
-			height = (uint16)intvalue;
-
-			/* Check if mode is already in the list */
-			{
-				uint i;
-				hasMode = false;
-				for (i = 0; i < count; i++) {
-					if (modes[i].x == width &&  modes[i].y == height) {
-						hasMode = true;
-						break;
-					}
-				}
-			}
-
-			if (hasMode) continue;
-
-			/* Add mode to the list */
-			modes[count].x = width;
-			modes[count].y = height;
-			count++;
-		}
-
-		/* Sort list smallest to largest */
-		{
-			uint i, j;
-			for (i = 0; i < count; i++) {
-				for (j = 0; j < count-1; j++) {
-					if (modes[j].x > modes[j + 1].x || (
-						modes[j].x == modes[j + 1].x &&
-						modes[j].y >  modes[j + 1].y
-						)) {
-						uint tmpw = modes[j].x;
-						uint tmph = modes[j].y;
-
-						modes[j].x = modes[j + 1].x;
-						modes[j].y = modes[j + 1].y;
-
-						modes[j + 1].x = tmpw;
-						modes[j + 1].y = tmph;
-					}
-				}
-			}
-		}
-
-		return count;
+		return QZ_ListModes(modes, max_modes, display_id, display_depth);
 	}
 
 	virtual bool ChangeResolution(int w, int h)
--- a/src/video/cocoa/wnd_quartz.mm	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/cocoa/wnd_quartz.mm	Wed Jan 09 18:11:12 2008 +0000
@@ -7,9 +7,12 @@
  ******************************************************************************/
 
 #ifdef WITH_COCOA
+#ifdef ENABLE_COCOA_QUARTZ
 
 #include <AvailabilityMacros.h>
 
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+
 #import <Cocoa/Cocoa.h>
 #import <sys/time.h> /* gettimeofday */
 #import <sys/param.h> /* for MAXPATHLEN */
@@ -35,18 +38,12 @@
 
 
 #include "../../stdafx.h"
-#include "../../openttd.h"
 #include "../../debug.h"
-#include "../../macros.h"
-#include "../../os/macosx/splash.h"
-#include "../../variables.h"
-#include "../../gfx.h"
+#include "../../core/geometry_type.hpp"
 #include "cocoa_v.h"
-#include "cocoa_keys.h"
-#include "../../blitter/factory.hpp"
-#include "../../fileio.h"
+#include "../../core/math_func.hpp"
+#include "../../gfx_func.h"
 
-#undef Point
 #undef Rect
 
 
@@ -140,7 +137,7 @@
 	virtual void MakeDirty(int left, int top, int width, int height);
 	virtual void UpdatePalette(uint first_color, uint num_colors);
 
-	virtual uint ListModes(OTTDPoint* modes, uint max_modes);
+	virtual uint ListModes(OTTD_Point* modes, uint max_modes);
 
 	virtual bool ChangeResolution(int w, int h);
 
@@ -661,14 +658,9 @@
 	num_dirty_rects = MAX_DIRTY_RECTS;
 }
 
-uint WindowQuartzSubdriver::ListModes(OTTDPoint* modes, uint max_modes)
+uint WindowQuartzSubdriver::ListModes(OTTD_Point* modes, uint max_modes)
 {
-	if (max_modes == 0) return 0;
-
-	modes[0].x = window_width;
-	modes[0].y = window_height;
-
-	return 1;
+	return QZ_ListModes(modes, max_modes, kCGDirectMainDisplay, buffer_depth);
 }
 
 bool WindowQuartzSubdriver::ChangeResolution(int w, int h)
@@ -692,6 +684,7 @@
 
 	p->y = window_height - p->y;
 	*p = [ qzview convertPoint:*p toView: nil ];
+
 	*p = [ window convertBaseToScreen:*p ];
 	p->y = device_height - p->y;
 
@@ -786,6 +779,11 @@
 {
 	WindowQuartzSubdriver *ret;
 
+	if (!MacOSVersionIsAtLeast(10, 4, 0)) {
+		DEBUG(driver, 0, "The cocoa quartz subdriver requires Mac OS X 10.4 or later.");
+		return NULL;
+	}
+
 	if (bpp != 8 && bpp != 32) {
 		DEBUG(driver, 0, "The cocoa quartz subdriver only supports 8 and 32 bpp.");
 		return NULL;
@@ -801,4 +799,7 @@
 	return ret;
 }
 
+
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 */
+#endif /* ENABLE_COCOA_QUARTZ */
 #endif /* WITH_COCOA */
--- a/src/video/cocoa/wnd_quickdraw.mm	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/cocoa/wnd_quickdraw.mm	Wed Jan 09 18:11:12 2008 +0000
@@ -7,7 +7,10 @@
  ******************************************************************************/
 
 #ifdef WITH_COCOA
+#ifdef ENABLE_COCOA_QUICKDRAW
 
+#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
+#define MAC_OS_X_VERSION_MAX_ALLOWED     MAC_OS_X_VERSION_10_3
 #include <AvailabilityMacros.h>
 
 #import <Cocoa/Cocoa.h>
@@ -35,18 +38,12 @@
 
 
 #include "../../stdafx.h"
-#include "../../openttd.h"
 #include "../../debug.h"
-#include "../../macros.h"
-#include "../../os/macosx/splash.h"
-#include "../../variables.h"
-#include "../../gfx.h"
+#include "../../core/geometry_type.hpp"
 #include "cocoa_v.h"
-#include "cocoa_keys.h"
-#include "../../blitter/factory.hpp"
-#include "../../fileio.h"
+#include "../../core/math_func.hpp"
+#include "../../gfx_func.h"
 
-#undef Point
 #undef Rect
 
 
@@ -155,7 +152,7 @@
 	virtual void MakeDirty(int left, int top, int width, int height);
 	virtual void UpdatePalette(uint first_color, uint num_colors);
 
-	virtual uint ListModes(OTTDPoint* modes, uint max_modes);
+	virtual uint ListModes(OTTD_Point* modes, uint max_modes);
 
 	virtual bool ChangeResolution(int w, int h);
 
@@ -686,14 +683,9 @@
 	num_dirty_rects = MAX_DIRTY_RECTS;
 }
 
-uint WindowQuickdrawSubdriver::ListModes(OTTDPoint* modes, uint max_modes)
+uint WindowQuickdrawSubdriver::ListModes(OTTD_Point* modes, uint max_modes)
 {
-	if (max_modes == 0) return 0;
-
-	modes[0].x = window_width;
-	modes[0].y = window_height;
-
-	return 1;
+	return QZ_ListModes(modes, max_modes, kCGDirectMainDisplay, buffer_depth);
 }
 
 bool WindowQuickdrawSubdriver::ChangeResolution(int w, int h)
@@ -803,6 +795,10 @@
 {
 	WindowQuickdrawSubdriver *ret;
 
+	if (MacOSVersionIsAtLeast(10, 5, 0)) {
+		DEBUG(driver, 0, "The cocoa quickdraw subdriver is not recommended for Mac OS X 10.5 or later.");
+	}
+
 	if (bpp != 8 && bpp != 32) {
 		DEBUG(driver, 0, "The cocoa quickdraw subdriver only supports 8 and 32 bpp.");
 		return NULL;
@@ -818,4 +814,5 @@
 	return ret;
 }
 
+#endif /* ENABLE_COCOA_QUICKDRAW */
 #endif /* WITH_COCOA */
--- a/src/video/dedicated_v.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/dedicated_v.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,15 +6,15 @@
 
 #include "../openttd.h"
 #include "../debug.h"
-#include "../functions.h"
-#include "../gfx.h"
+#include "../gfx_func.h"
 #include "../network/network.h"
-#include "../window.h"
 #include "../console.h"
 #include "../variables.h"
 #include "../genworld.h"
 #include "../fileio.h"
+#include "../fios.h"
 #include "../blitter/factory.hpp"
+#include "../core/alloc_func.hpp"
 #include "dedicated_v.h"
 
 #ifdef BEOS_NET_SERVER
@@ -133,7 +133,7 @@
 {
 	int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
 	if (bpp == 0) _dedicated_video_mem = NULL;
-	else          _dedicated_video_mem = malloc(_cur_resolution[0] * _cur_resolution[1] * (bpp / 8));
+	else          _dedicated_video_mem = MallocT<byte>(_cur_resolution[0] * _cur_resolution[1] * (bpp / 8));
 
 	_screen.width = _screen.pitch = _cur_resolution[0];
 	_screen.height = _cur_resolution[1];
@@ -168,7 +168,7 @@
 
 void VideoDriver_Dedicated::MakeDirty(int left, int top, int width, int height) {}
 bool VideoDriver_Dedicated::ChangeResolution(int w, int h) { return false; }
-void VideoDriver_Dedicated::ToggleFullscreen(bool fs) {}
+bool VideoDriver_Dedicated::ToggleFullscreen(bool fs) { return false; }
 
 #if defined(UNIX) || defined(__OS2__) || defined(PSP)
 static bool InputWaiting()
@@ -235,7 +235,7 @@
 			if (input_line[i] == '\0')
 				break;
 
-			if (!IS_INT_INSIDE(input_line[i], ' ', 256))
+			if (!IsInsideMM(input_line[i], ' ', 256))
 				input_line[i] = ' ';
 		}
 	}
--- a/src/video/dedicated_v.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/dedicated_v.h	Wed Jan 09 18:11:12 2008 +0000
@@ -17,12 +17,18 @@
 
 	/* virtual */ bool ChangeResolution(int w, int h);
 
-	/* virtual */ void ToggleFullscreen(bool fullscreen);
+	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 };
 
 class FVideoDriver_Dedicated: public VideoDriverFactory<FVideoDriver_Dedicated> {
 public:
+#ifdef DEDICATED
+	/* Automatically select this dedicated driver when making a dedicated
+	 * server build. */
+	static const int priority = 10;
+#else
 	static const int priority = 0;
+#endif
 	/* virtual */ const char *GetName() { return "dedicated"; }
 	/* virtual */ const char *GetDescription() { return "Dedicated Video Driver"; }
 	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Dedicated(); }
--- a/src/video/null_v.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/null_v.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -2,9 +2,8 @@
 
 #include "../stdafx.h"
 #include "../openttd.h"
-#include "../gfx.h"
+#include "../gfx_func.h"
 #include "../variables.h"
-#include "../window.h"
 #include "../debug.h"
 #include "../blitter/factory.hpp"
 #include "null_v.h"
@@ -39,4 +38,4 @@
 
 bool VideoDriver_Null::ChangeResolution(int w, int h) { return false; }
 
-void VideoDriver_Null::ToggleFullscreen(bool fs) {}
+bool VideoDriver_Null::ToggleFullscreen(bool fs) { return false; }
--- a/src/video/null_v.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/null_v.h	Wed Jan 09 18:11:12 2008 +0000
@@ -20,7 +20,7 @@
 
 	/* virtual */ bool ChangeResolution(int w, int h);
 
-	/* virtual */ void ToggleFullscreen(bool fullscreen);
+	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 };
 
 class FVideoDriver_Null: public VideoDriverFactory<FVideoDriver_Null> {
--- a/src/video/sdl_v.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/sdl_v.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,14 +6,11 @@
 
 #include "../openttd.h"
 #include "../debug.h"
-#include "../functions.h"
-#include "../gfx.h"
-#include "../macros.h"
+#include "../gfx_func.h"
 #include "../sdl.h"
-#include "../window.h"
-#include "../network/network.h"
 #include "../variables.h"
 #include "../blitter/factory.hpp"
+#include "../network/network.h"
 #include "sdl_v.h"
 #include <SDL.h>
 
@@ -128,8 +125,8 @@
 		for (i = 0; modes[i]; i++) {
 			int w = modes[i]->w;
 			int h = modes[i]->h;
-			if (IS_INT_INSIDE(w, 640, MAX_SCREEN_WIDTH + 1) &&
-					IS_INT_INSIDE(h, 480, MAX_SCREEN_HEIGHT + 1)) {
+			if (IsInsideMM(w, 640, MAX_SCREEN_WIDTH + 1) &&
+					IsInsideMM(h, 480, MAX_SCREEN_HEIGHT + 1)) {
 				int j;
 				for (j = 0; j < n; j++) {
 					if (_resolutions[j][0] == w && _resolutions[j][1] == h) break;
@@ -524,14 +521,16 @@
 	return CreateMainSurface(w, h);
 }
 
-void VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
+bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
 {
 	_fullscreen = fullscreen;
 	GetVideoModes(); // get the list of available video modes
 	if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution[0], _cur_resolution[1])) {
 		// switching resolution failed, put back full_screen to original status
 		_fullscreen ^= true;
+		return false;
 	}
+	return true;
 }
 
 #endif /* WITH_SDL */
--- a/src/video/sdl_v.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/sdl_v.h	Wed Jan 09 18:11:12 2008 +0000
@@ -17,7 +17,7 @@
 
 	/* virtual */ bool ChangeResolution(int w, int h);
 
-	/* virtual */ void ToggleFullscreen(bool fullscreen);
+	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 };
 
 class FVideoDriver_SDL: public VideoDriverFactory<FVideoDriver_SDL> {
--- a/src/video/video_driver.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/video_driver.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -13,7 +13,7 @@
 
 	virtual bool ChangeResolution(int w, int h) = 0;
 
-	virtual void ToggleFullscreen(bool fullscreen) = 0;
+	virtual bool ToggleFullscreen(bool fullscreen) = 0;
 };
 
 class VideoDriverFactoryBase: public DriverFactoryBase {
--- a/src/video/win32_v.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/win32_v.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -2,14 +2,11 @@
 
 #include "../stdafx.h"
 #include "../openttd.h"
-#include "../functions.h"
-#include "../gfx.h"
-#include "../macros.h"
-#include "../network/network.h"
+#include "../gfx_func.h"
 #include "../variables.h"
 #include "../win32.h"
-#include "../window.h"
 #include "../blitter/factory.hpp"
+#include "../network/network.h"
 #include "win32_v.h"
 #include <windows.h>
 #include <tchar.h>
@@ -213,7 +210,7 @@
 	}
 }
 
-static void MakeWindow(bool full_screen)
+static bool MakeWindow(bool full_screen)
 {
 	_fullscreen = full_screen;
 
@@ -245,8 +242,8 @@
 		settings.dmDisplayFrequency = _display_hz;
 
 		if (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
-			MakeWindow(false);
-			return;
+			MakeWindow(false);  // don't care about the result
+			return false;  // the request failed
 		}
 	} else if (_wnd.fullscreen) {
 		// restore display?
@@ -294,6 +291,7 @@
 		}
 	}
 	GameSizeChanged(); // invalidate all windows, force redraw
+	return true; // the request succedded
 }
 
 static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -737,8 +735,8 @@
 	 * Doesn't really matter since we don't pass a string anyways, but still
 	 * a letdown */
 	for (i = 0; EnumDisplaySettingsA(NULL, i, &dm) != 0; i++) {
-		if (dm.dmBitsPerPel == BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() && IS_INT_INSIDE(dm.dmPelsWidth, 640, MAX_SCREEN_WIDTH + 1) &&
-				IS_INT_INSIDE(dm.dmPelsHeight, 480, MAX_SCREEN_HEIGHT + 1)) {
+		if (dm.dmBitsPerPel == BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() && IsInsideMM(dm.dmPelsWidth, 640, MAX_SCREEN_WIDTH + 1) &&
+				IsInsideMM(dm.dmPelsHeight, 480, MAX_SCREEN_HEIGHT + 1)) {
 			uint j;
 
 			for (j = 0; j < n; j++) {
@@ -898,12 +896,10 @@
 	_wnd.width = _wnd.width_org = w;
 	_wnd.height = _wnd.height_org = h;
 
-	MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching
-
-	return true;
+	return MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching
 }
 
-void VideoDriver_Win32::ToggleFullscreen(bool full_screen)
+bool VideoDriver_Win32::ToggleFullscreen(bool full_screen)
 {
-	MakeWindow(full_screen);
+	return MakeWindow(full_screen);
 }
--- a/src/video/win32_v.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/win32_v.h	Wed Jan 09 18:11:12 2008 +0000
@@ -17,7 +17,7 @@
 
 	/* virtual */ bool ChangeResolution(int w, int h);
 
-	/* virtual */ void ToggleFullscreen(bool fullscreen);
+	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 };
 
 class FVideoDriver_Win32: public VideoDriverFactory<FVideoDriver_Win32> {
--- a/src/viewport.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/viewport.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,19 +5,14 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "gui.h"
 #include "spritecache.h"
-#include "strings.h"
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "landscape.h"
-#include "map.h"
-#include "viewport.h"
-#include "window.h"
-#include "vehicle.h"
+#include "viewport_func.h"
 #include "station.h"
-#include "gfx.h"
 #include "town.h"
 #include "signs.h"
 #include "waypoint.h"
@@ -27,13 +22,32 @@
 #include "vehicle_gui.h"
 #include "blitter/factory.hpp"
 #include "transparency.h"
+#include "strings_func.h"
+#include "zoom_func.h"
+#include "vehicle_func.h"
 
 #define VIEWPORT_DRAW_MEM (65536 * 2)
 
+PlaceProc *_place_proc;
+Point _tile_fract_coords;
 ZoomLevel _saved_scrollpos_zoom;
 
-/* XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar) */
-static ViewPort _viewports[25 - 2];
+/**
+ * The maximum number of viewports depends on the maximum number
+ * of windows. Technically is could be the maximum number of
+ * windows, but there is always at least one window that does
+ * not need a viewport. Not having 'support' for that viewport
+ * saves some time and memory.
+ * For the introduction GUI and create game GUIs there is no
+ * need for more than one viewport, however in the normal game
+ * and scenario editor one can make a lot of viewports. For the
+ * normal game one always has a main toolbar and a status bar,
+ * however the statusbar does not exist on the scenario editor.
+ *
+ * This means that we can only safely assume that there is one
+ * window without viewport.
+ */
+static ViewPort _viewports[MAX_NUMBER_OF_WINDOWS - 1];
 static uint32 _active_viewports;    ///< bitmasked variable where each bit signifies if a viewport is in use or not
 assert_compile(lengthof(_viewports) < sizeof(_active_viewports) * 8);
 
@@ -344,8 +358,8 @@
 	ViewPort *vp = w->viewport;
 
 	if (vp != NULL &&
-	    IS_INT_INSIDE(x, vp->left, vp->left + vp->width) &&
-			IS_INT_INSIDE(y, vp->top, vp->top + vp->height))
+	    IsInsideMM(x, vp->left, vp->left + vp->width) &&
+			IsInsideMM(y, vp->top, vp->top + vp->height))
 		return vp;
 
 	return NULL;
@@ -442,11 +456,11 @@
  * @param widget_zoom_out widget index for window with zoom-out button */
 void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
 {
-	SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == ZOOM_LVL_MIN);
-	InvalidateWidget(w, widget_zoom_in);
-
-	SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == ZOOM_LVL_MAX);
-	InvalidateWidget(w, widget_zoom_out);
+	w->SetWidgetDisabledState(widget_zoom_in, vp->zoom == ZOOM_LVL_MIN);
+	w->InvalidateWidget(widget_zoom_in);
+
+	w->SetWidgetDisabledState(widget_zoom_out, vp->zoom == ZOOM_LVL_MAX);
+	w->InvalidateWidget(widget_zoom_out);
 }
 
 /**
@@ -501,7 +515,7 @@
 static void AddChildSpriteToFoundation(SpriteID image, SpriteID pal, const SubSprite *sub, FoundationPart foundation_part, int extra_offs_x, int extra_offs_y)
 {
 	ViewportDrawer *vd = _cur_vd;
-	assert(IS_INT_INSIDE(foundation_part, 0, FOUNDATION_PART_END));
+	assert(IsInsideMM(foundation_part, 0, FOUNDATION_PART_END));
 	assert(vd->foundation[foundation_part] != NULL);
 	Point offs = vd->foundation_offset[foundation_part];
 
@@ -853,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 },
@@ -932,8 +945,8 @@
 	if (_thd.drawstyle == 0) return;
 
 	/* Inside the inner area? */
-	if (IS_INSIDE_1D(ti->x, _thd.pos.x, _thd.size.x) &&
-			IS_INSIDE_1D(ti->y, _thd.pos.y, _thd.size.y)) {
+	if (IsInsideBS(ti->x, _thd.pos.x, _thd.size.x) &&
+			IsInsideBS(ti->y, _thd.pos.y, _thd.size.y)) {
 		if (_thd.drawstyle & HT_RECT) {
 			DrawTileSelectionRect(ti, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE);
 		} else if (_thd.drawstyle & HT_POINT) {
@@ -957,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;
@@ -967,10 +980,10 @@
 				side = 0;
 			} else {
 				TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y);
-				side = delta(delta(TileX(start), TileX(ti->tile)), delta(TileY(start), TileY(ti->tile)));
+				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;
 	}
@@ -978,8 +991,8 @@
 	/* Check if it's inside the outer area? */
 	if (_thd.outersize.x &&
 			_thd.size.x < _thd.size.x + _thd.outersize.x &&
-			IS_INSIDE_1D(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) &&
-			IS_INSIDE_1D(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) {
+			IsInsideBS(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) &&
+			IsInsideBS(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) {
 		/* Draw a blue rect. */
 		DrawTileSelectionRect(ti, PALETTE_SEL_TILE_BLUE);
 		return;
@@ -1251,7 +1264,7 @@
 						top    < si->sign.top + ScaleByZoom(12, dpi->zoom) &&
 						right  > si->sign.left &&
 						left   < si->sign.left + ScaleByZoom(si->sign.width_2, dpi->zoom)) {
-					AddSign(si, STR_2002, si->sign.width_2 | 0x8000);
+					AddSign(si, IsTransparencySet(TO_SIGNS) ? STR_2002_WHITE : STR_2002, si->sign.width_2 | 0x8000);
 				}
 			}
 			break;
@@ -1666,7 +1679,7 @@
 	const ViewPort *vp = w->viewport;
 
 	if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE) {
-		const Vehicle* veh = GetVehicle(WP(w,vp_d).follow_vehicle);
+		const Vehicle* veh = GetVehicle(WP(w, vp_d).follow_vehicle);
 		Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
 
 		SetViewportPosition(w, pt.x, pt.y);
@@ -1754,8 +1767,8 @@
 	uint z = 0;
 	Point pt;
 
-	if (IS_INT_INSIDE(x, 0, MapSizeX() * TILE_SIZE) &&
-			IS_INT_INSIDE(y, 0, MapSizeY() * TILE_SIZE))
+	if (IsInsideMM(x, 0, MapSizeX() * TILE_SIZE) &&
+			IsInsideMM(y, 0, MapSizeY() * TILE_SIZE))
 		z = GetTileZ(TileVirtXY(x, y));
 	pt = RemapCoords(x, y, z);
 
@@ -2217,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];
 }
 
 /**
@@ -2364,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);
@@ -2372,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
@@ -2730,14 +2742,14 @@
 
 				TileIndex t0 = TileVirtXY(sx, sy);
 				TileIndex t1 = TileVirtXY(x, y);
-				uint dx = delta(TileX(t0), TileX(t1)) + 1;
-				uint dy = delta(TileY(t0), TileY(t1)) + 1;
+				uint dx = Delta(TileX(t0), TileX(t1)) + 1;
+				uint dy = Delta(TileY(t0), TileY(t1)) + 1;
 				byte index = 0;
 				uint64 params[3];
 
 				/* 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	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,168 +0,0 @@
-/* $Id$ */
-
-/** @file viewport.h */
-
-#ifndef VIEWPORT_H
-#define VIEWPORT_H
-
-#include "zoom.hpp"
-
-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);
-
-#endif /* VIEWPORT_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/viewport_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,81 @@
+/* $Id$ */
+
+/** @file viewport_func.h Functions related to (drawing on) viewports. */
+
+#ifndef VIEWPORT_FUNC_H
+#define VIEWPORT_FUNC_H
+
+#include "gfx_type.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 18:11:12 2008 +0000
@@ -0,0 +1,115 @@
+/* $Id$ */
+
+/** @file viewport_type.h Types related to viewports. */
+
+#ifndef VIEWPORT_TYPE_H
+#define VIEWPORT_TYPE_H
+
+#include "core/geometry_type.hpp"
+#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/void_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/void_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,8 @@
 #ifndef VOID_MAP_H
 #define VOID_MAP_H
 
+#include "tile_map.h"
+
 /**
  * Make a nice void tile ;)
  * @param t the tile to make void
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/water.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,15 @@
+/* $Id$ */
+
+/** @file water.h Functions related to water (management) */
+
+#ifndef WATER_H
+#define WATER_H
+
+void TileLoop_Water(TileIndex tile);
+void DrawShipDepotSprite(int x, int y, int image);
+void DrawCanalWater(TileIndex tile);
+void MakeWaterOrCanalDependingOnOwner(TileIndex tile, Owner o);
+void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o);
+void FloodHalftile(TileIndex t);
+
+#endif /* WATER_H */
--- a/src/water_cmd.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/water_cmd.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -10,51 +10,72 @@
 #include "station_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
+#include "tile_cmd.h"
 #include "landscape.h"
-#include "map.h"
-#include "tile.h"
-#include "vehicle.h"
-#include "viewport.h"
-#include "command.h"
+#include "viewport_func.h"
+#include "command_func.h"
 #include "town.h"
 #include "news.h"
-#include "sound.h"
 #include "depot.h"
 #include "vehicle_gui.h"
 #include "train.h"
 #include "roadveh.h"
+#include "water.h"
 #include "water_map.h"
 #include "industry_map.h"
 #include "newgrf.h"
 #include "newgrf_canal.h"
 #include "misc/autoptr.hpp"
 #include "transparency.h"
-
-/** Array for the shore sprites */
-static const SpriteID _water_shore_sprites[] = {
-	0,
-	SPR_SHORE_TILEH_1,  // SLOPE_W
-	SPR_SHORE_TILEH_2,  // SLOPE_S
-	SPR_SHORE_TILEH_3,  // SLOPE_SW
-	SPR_SHORE_TILEH_4,  // SLOPE_E
-	0,
-	SPR_SHORE_TILEH_6,  // SLOPE_SE
-	0,
-	SPR_SHORE_TILEH_8,  // SLOPE_N
-	SPR_SHORE_TILEH_9,  // SLOPE_NW
-	0,
-	0,
-	SPR_SHORE_TILEH_12, // SLOPE_NE
-	0,
-	0
-};
+#include "strings_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "sound_func.h"
+#include "variables.h"
 
 
 static Vehicle *FindFloodableVehicleOnTile(TileIndex tile);
 static void FloodVehicle(Vehicle *v);
 
+/**
+ * Makes a tile canal or water depending on the surroundings.
+ * This as for example docks and shipdepots do not store
+ * whether the tile used to be canal or 'normal' water.
+ * @param t the tile to change.
+ * @param o the owner of the new tile.
+ */
+void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o)
+{
+	assert(GetTileSlope(t, NULL) == SLOPE_FLAT);
+
+	/* Mark tile dirty in all cases */
+	MarkTileDirtyByTile(t);
+
+	/* Non-sealevel -> canal */
+	if (TileHeight(t) != 0) {
+		MakeCanal(t, o);
+		return;
+	}
+
+	bool has_water = false;
+	bool has_canal = false;
+
+	for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
+		TileIndex neighbour = TileAddByDiagDir(t, dir);
+		if (IsTileType(neighbour, MP_WATER)) {
+			has_water |= IsSea(neighbour) || IsCoast(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) == OWNER_WATER);
+			has_canal |= IsCanal(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) != OWNER_WATER);
+		}
+	}
+	if (has_canal || !has_water) {
+		MakeCanal(t, o);
+	} else {
+		MakeWater(t);
+	}
+}
+
+
 /** Build a ship depot.
  * @param tile tile where ship depot is built
  * @param flags type of operation
@@ -65,9 +86,7 @@
 {
 	TileIndex tile2;
 
-	CommandCost cost, ret;
-
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+	CommandCost ret;
 
 	Axis axis = Extract<Axis, 0>(p1);
 
@@ -78,6 +97,8 @@
 
 	if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
 
+	Owner o1 = GetTileOwner(tile);
+	Owner o2 = GetTileOwner(tile2);
 	ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 	if (CmdFailed(ret)) return CMD_ERROR;
 	ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -90,14 +111,23 @@
 	if (flags & DC_EXEC) {
 		depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
 
-		MakeShipDepot(tile,  _current_player, DEPOT_NORTH, axis);
-		MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis);
+		MakeShipDepot(tile,  _current_player, DEPOT_NORTH, axis, o1);
+		MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, o2);
 		MarkTileDirtyByTile(tile);
 		MarkTileDirtyByTile(tile2);
 		d_auto_delete.Detach();
 	}
 
-	return cost.AddCost(_price.build_ship_depot);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot);
+}
+
+void MakeWaterOrCanalDependingOnOwner(TileIndex tile, Owner o)
+{
+	if (o == OWNER_WATER) {
+		MakeWater(tile);
+	} else {
+		MakeCanal(tile, o);
+	}
 }
 
 static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
@@ -116,13 +146,13 @@
 		/* Kill the depot, which is registered at the northernmost tile. Use that one */
 		delete GetDepotByTile(tile2 < tile ? tile2 : tile);
 
-		MakeWater(tile);
-		MakeWater(tile2);
+		MakeWaterOrCanalDependingOnOwner(tile,  GetShipDepotWaterOwner(tile));
+		MakeWaterOrCanalDependingOnOwner(tile2, GetShipDepotWaterOwner(tile2));
 		MarkTileDirtyByTile(tile);
 		MarkTileDirtyByTile(tile2);
 	}
 
-	return CommandCost(_price.remove_ship_depot);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot);
 }
 
 /** build a shiplift */
@@ -163,7 +193,7 @@
 		MarkTileDirtyByTile(tile + delta);
 	}
 
-	return CommandCost(_price.clear_water * 22 >> 3);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 22 >> 3);
 }
 
 static CommandCost RemoveShiplift(TileIndex tile, uint32 flags)
@@ -178,11 +208,11 @@
 
 	if (flags & DC_EXEC) {
 		DoClearSquare(tile);
-		DoClearSquare(tile + delta);
-		DoClearSquare(tile - delta);
+		MakeWaterOrCanalDependingOnSurroundings(tile + delta, _current_player);
+		MakeWaterOrCanalDependingOnSurroundings(tile - delta, _current_player);
 	}
 
-	return CommandCost(_price.clear_water * 2);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 2);
 }
 
 /**
@@ -212,8 +242,6 @@
 {
 	DiagDirection dir;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	switch (GetTileSlope(tile, NULL)) {
 		case SLOPE_SW: dir = DIAGDIR_SW; break;
 		case SLOPE_SE: dir = DIAGDIR_SE; break;
@@ -232,7 +260,7 @@
  */
 CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	CommandCost cost;
+	CommandCost cost(EXPENSES_CONSTRUCTION);
 	int size_x, size_y;
 	int x;
 	int y;
@@ -247,8 +275,6 @@
 	sx = TileX(p1);
 	sy = TileY(p1);
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	if (x < sx) Swap(x, sx);
 	if (y < sy) Swap(y, sy);
 	size_x = (x - sx) + 1;
@@ -298,8 +324,8 @@
 			if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
 
 			/* Make sure it's not an edge tile. */
-			if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) ||
-					!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) {
+			if (!IsInsideMM(TileX(tile), 1, MapMaxX() - 1) ||
+					!IsInsideMM(TileY(tile), 1, MapMaxY() - 1)) {
 				return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
 			}
 
@@ -309,7 +335,7 @@
 			if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE && !CheckTileOwnership(tile)) return CMD_ERROR;
 
 			if (flags & DC_EXEC) DoClearSquare(tile);
-			return CommandCost(_price.clear_water);
+			return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water);
 
 		case WATER_TILE_COAST: {
 			Slope slope = GetTileSlope(tile, NULL);
@@ -319,9 +345,9 @@
 
 			if (flags & DC_EXEC) DoClearSquare(tile);
 			if (slope == SLOPE_N || slope == SLOPE_E || slope == SLOPE_S || slope == SLOPE_W) {
-				return CommandCost(_price.clear_water);
+				return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water);
 			} else {
-				return CommandCost(_price.purchase_land);
+				return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_roughland);
 			}
 		}
 
@@ -463,15 +489,18 @@
 			DrawBridgeMiddle(ti);
 			break;
 
-		case WATER_TILE_COAST:
+		case WATER_TILE_COAST: {
+			/* Converts the enum Slope into an offset based on SPR_SHORE_BASE.
+			 * This allows to calculate the proper sprite to display for this Slope */
+			static const byte tileh_to_shoresprite[32] = {
+				0, 1, 2, 3, 4, 16, 6, 7, 8, 9, 17, 11, 12, 13, 14, 0,
+				0, 0, 0, 0, 0,  0, 0, 0, 0, 0,  0,  5,  0, 10, 15, 0,
+			};
+
 			assert(!IsSteepSlope(ti->tileh));
-			if (_loaded_newgrf_features.has_newwater) {
-				DrawGroundSprite(_coast_base + ti->tileh, PAL_NONE);
-			} else {
-				DrawGroundSprite(_water_shore_sprites[ti->tileh], PAL_NONE);
-			}
+			DrawGroundSprite(SPR_SHORE_BASE + tileh_to_shoresprite[ti->tileh], PAL_NONE);
 			DrawBridgeMiddle(ti);
-			break;
+		} break;
 
 		case WATER_TILE_LOCK: {
 			const WaterDrawTileStruct *t = _shiplift_display_seq[GetSection(ti->tile)];
@@ -540,6 +569,16 @@
 }
 
 /**
+ * Marks tile dirty if it is a canal tile.
+ * Called to avoid glitches when flooding tiles next to canal tile.
+ *
+ * @param tile tile to check
+ */
+static inline void MarkTileDirtyIfCanal(TileIndex tile) {
+	if (IsTileType(tile, MP_WATER) && IsCanal(tile)) MarkTileDirtyByTile(tile);
+}
+
+/**
  * Floods neighboured floodable tiles
  *
  * @param tile The water source tile that causes the flooding.
@@ -601,6 +640,11 @@
 		if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
 			MakeWater(target);
 			MarkTileDirtyByTile(target);
+			/* Mark surrounding canal tiles dirty too to avoid glitches */
+			MarkTileDirtyIfCanal(target + TileDiffXY(0, 1));
+			MarkTileDirtyIfCanal(target + TileDiffXY(1, 0));
+			MarkTileDirtyIfCanal(target + TileDiffXY(0, -1));
+			MarkTileDirtyIfCanal(target + TileDiffXY(-1, 0));
 		}
 	}
 }
@@ -628,6 +672,20 @@
 		return NULL;
 	}
 
+	/* if non-uniform stations are disabled, flood some train in this train station (if there is any) */
+	if (!_patches.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) {
+		const Station *st = GetStationByTile(tile);
+
+		BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
+			if (st->TileBelongsToRailStation(t)) {
+				Vehicle *v = FindVehicleOnTileZ(t, 0);
+				if (v != NULL && (v->vehstatus & VS_CRASHED) == 0) return v;
+			}
+		END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
+
+		return NULL;
+	}
+
 	if (!IsBridgeTile(tile)) return FindVehicleOnTileZ(tile, 0);
 
 	TileIndex end = GetOtherBridgeEnd(tile);
@@ -735,8 +793,8 @@
 	if (IsTileType(tile, MP_WATER) && !(IsSea(tile) || IsCoast(tile))) return;
 
 	/* floods in all four diagonal directions with the exception of the edges */
-	if (IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1) &&
-			IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) {
+	if (IsInsideMM(TileX(tile), 1, MapSizeX() - 3 + 1) &&
+			IsInsideMM(TileY(tile), 1, MapSizeY() - 3 + 1)) {
 		uint i;
 
 		for (i = 0; i != lengthof(_tile_loop_offs_array); i++) {
@@ -748,19 +806,19 @@
 	_current_player = OWNER_NONE;
 
 	/* edges */
-	if (TileX(tile) == 0 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //NE
+	if (TileX(tile) == 0 && IsInsideMM(TileY(tile), 1, MapSizeY() - 3 + 1)) { //NE
 		TileLoopWaterHelper(tile, _tile_loop_offs_array[2]);
 	}
 
-	if (TileX(tile) == MapSizeX() - 2 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //SW
+	if (TileX(tile) == MapSizeX() - 2 && IsInsideMM(TileY(tile), 1, MapSizeY() - 3 + 1)) { //SW
 		TileLoopWaterHelper(tile, _tile_loop_offs_array[0]);
 	}
 
-	if (TileY(tile) == 0 && IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1)) { //NW
+	if (TileY(tile) == 0 && IsInsideMM(TileX(tile), 1, MapSizeX() - 3 + 1)) { //NW
 		TileLoopWaterHelper(tile, _tile_loop_offs_array[1]);
 	}
 
-	if (TileY(tile) == MapSizeY() - 2 && IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1)) { //SE
+	if (TileY(tile) == MapSizeY() - 2 && IsInsideMM(TileX(tile), 1, MapSizeX() - 3 + 1)) { //SE
 		TileLoopWaterHelper(tile, _tile_loop_offs_array[3]);
 	}
 }
@@ -813,7 +871,7 @@
 	}
 }
 
-static uint32 VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
+static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
 {
 	return VETSB_CONTINUE;
 }
--- a/src/water_map.h	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/water_map.h	Wed Jan 09 18:11:12 2008 +0000
@@ -31,9 +31,9 @@
 
 	if (_m[t].m5 == 0) return WATER_TILE_CLEAR;
 	if (_m[t].m5 == 1) return WATER_TILE_COAST;
-	if (IS_INT_INSIDE(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK;
+	if (IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK;
 
-	assert(IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END));
+	assert(IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END));
 	return WATER_TILE_DEPOT;
 }
 
@@ -72,7 +72,7 @@
 
 static inline TileIndex IsShipDepot(TileIndex t)
 {
-	return IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END);
+	return IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END);
 }
 
 static inline Axis GetShipDepotAxis(TileIndex t)
@@ -85,6 +85,11 @@
 	return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1));
 }
 
+static inline Owner GetShipDepotWaterOwner(TileIndex t)
+{
+	return (Owner)_m[t].m4;
+}
+
 static inline DiagDirection GetLockDirection(TileIndex t)
 {
 	return (DiagDirection)GB(_m[t].m5, 0, 2);
@@ -128,13 +133,13 @@
 	_m[t].m5 = 0;
 }
 
-static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a)
+static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, Owner original_owner)
 {
 	SetTileType(t, MP_WATER);
 	SetTileOwner(t, o);
 	_m[t].m2 = 0;
 	_m[t].m3 = 0;
-	_m[t].m4 = 0;
+	_m[t].m4 = original_owner;
 	_m[t].m5 = base + a * 2;
 }
 
--- a/src/waypoint.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/waypoint.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,28 +5,30 @@
 #include "stdafx.h"
 #include "openttd.h"
 
-#include "command.h"
-#include "functions.h"
-#include "gfx.h"
+#include "command_func.h"
 #include "landscape.h"
-#include "map.h"
 #include "order.h"
 #include "rail_map.h"
+#include "rail.h"
 #include "bridge_map.h"
 #include "saveload.h"
 #include "station.h"
-#include "tile.h"
 #include "town.h"
 #include "waypoint.h"
 #include "variables.h"
 #include "table/strings.h"
-#include "vehicle.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "newgrf.h"
-#include "string.h"
-#include "strings.h"
 #include "misc/autoptr.hpp"
+#include "strings_func.h"
+#include "gfx_func.h"
+#include "functions.h"
+#include "window_func.h"
+#include "economy_func.h"
+#include "date_func.h"
+#include "vehicle_func.h"
+#include "vehicle_base.h"
+#include "string_func.h"
 
 enum {
 	MAX_WAYPOINTS_PER_TOWN = 64,
@@ -161,8 +163,6 @@
 	Slope tileh;
 	Axis axis;
 
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
 	/* if custom gfx are used, make sure it is within bounds */
 	if (p1 >= GetNumCustomStations(STAT_CLASS_WAYP)) return CMD_ERROR;
 
@@ -245,7 +245,7 @@
 		wp_auto_delete.Detach();
 	}
 
-	return CommandCost(_price.build_train_depot);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_train_depot);
 }
 
 /**
@@ -297,7 +297,7 @@
 		YapfNotifyTrackLayoutChange(tile, track);
 	}
 
-	return CommandCost(_price.remove_train_depot);
+	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot);
 }
 
 /**
@@ -310,7 +310,6 @@
  */
 CommandCost CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 	return RemoveTrainWaypoint(tile, flags, true);
 }
 
--- a/src/widget.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/widget.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -4,13 +4,13 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "functions.h"
 #include "player.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "window.h"
-#include "gfx.h"
-#include "viewport.h"
+#include "gfx_func.h"
+#include "window_gui.h"
+#include "window_func.h"
+
 
 static Point HandleScrollbarHittest(const Scrollbar *sb, int top, int bottom)
 {
@@ -140,7 +140,7 @@
 		if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue;
 
 		if (x >= wi->left && x <= wi->right && y >= wi->top &&  y <= wi->bottom &&
-				!IsWindowWidgetHidden(w, index)) {
+				!w->IsWidgetHidden(index)) {
 			found_index = index;
 		}
 	}
@@ -184,25 +184,24 @@
 void DrawWindowWidgets(const Window *w)
 {
 	const DrawPixelInfo* dpi = _cur_dpi;
-	Rect r;
-	uint i;
 
-	for (i = 0; i < w->widget_count; i++) {
+	for (uint i = 0; i < w->widget_count; i++) {
 		const Widget *wi = &w->widget[i];
-		bool clicked = IsWindowWidgetLowered(w, i);
+		bool clicked = w->IsWidgetLowered(i);
+		Rect r;
 
-		if (dpi->left > (r.right=/*w->left + */wi->right) ||
-				dpi->left + dpi->width <= (r.left=wi->left/* + w->left*/) ||
-				dpi->top > (r.bottom=/*w->top +*/ wi->bottom) ||
-				dpi->top + dpi->height <= (r.top = /*w->top +*/ wi->top) ||
-				IsWindowWidgetHidden(w, i)) {
+		if (dpi->left > (r.right = wi->right) ||
+				dpi->left + dpi->width <= (r.left = wi->left) ||
+				dpi->top > (r.bottom = wi->bottom) ||
+				dpi->top + dpi->height <= (r.top = wi->top) ||
+				w->IsWidgetHidden(i)) {
 			continue;
 		}
 
 		switch (wi->type & WWT_MASK) {
 		case WWT_IMGBTN:
 		case WWT_IMGBTN_2: {
-			int img = wi->data;
+			SpriteID img = wi->data;
 			assert(img != 0);
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 
@@ -234,14 +233,14 @@
 		}
 
 		case WWT_TEXT: {
-			StringID str = wi->data;
+			const StringID str = wi->data;
 
 			if (str != STR_NULL) DrawStringTruncated(r.left, r.top, str, wi->color, r.right - r.left);
 			break;
 		}
 
 		case WWT_INSET: {
-			StringID str = wi->data;
+			const StringID str = wi->data;
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED);
 
 			if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 1, str, TC_FROMSTRING, r.right - r.left - 10);
@@ -275,7 +274,7 @@
 				GfxFillRect(r.left + 1, x, r.right - 1, x, color);
 			}
 
-			color = _colour_gradient[wi->color&0xF][4];
+			color = _colour_gradient[wi->color & 0xF][4];
 
 			x = r.left - 1;
 			for (ctr = c; ctr > 1; ctr--) {
@@ -286,7 +285,7 @@
 			x = r.top - 1;
 			for (ctr = d; ctr > 1; ctr--) {
 				x += amt2;
-				GfxFillRect(r.left+1, x, r.right-1, x, color);
+				GfxFillRect(r.left + 1, x, r.right - 1, x, color);
 			}
 
 			goto draw_default;
@@ -295,8 +294,9 @@
 		/* vertical scrollbar */
 		case WWT_SCROLLBAR: {
 			Point pt;
-			int c1,c2;
+			int c1, c2;
 
+			assert(wi->data == 0);
 			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
 
 			/* draw up/down buttons */
@@ -308,18 +308,18 @@
 			DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 			DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, TC_BLACK);
 
-			c1 = _colour_gradient[wi->color&0xF][3];
-			c2 = _colour_gradient[wi->color&0xF][7];
+			c1 = _colour_gradient[wi->color & 0xF][3];
+			c2 = _colour_gradient[wi->color & 0xF][7];
 
 			/* draw "shaded" background */
-			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2);
-			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
+			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c2);
+			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
 
 			/* draw shaded lines */
-			GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
-			GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2);
-			GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1);
-			GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2);
+			GfxFillRect(r.left + 2, r.top + 10, r.left + 2, r.bottom - 10, c1);
+			GfxFillRect(r.left + 3, r.top + 10, r.left + 3, r.bottom - 10, c2);
+			GfxFillRect(r.left + 7, r.top + 10, r.left + 7, r.bottom - 10, c1);
+			GfxFillRect(r.left + 8, r.top + 10, r.left + 8, r.bottom - 10, c2);
 
 			pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom);
 			DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : FR_NONE);
@@ -327,8 +327,9 @@
 		}
 		case WWT_SCROLL2BAR: {
 			Point pt;
-			int c1,c2;
+			int c1, c2;
 
+			assert(wi->data == 0);
 			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
 
 			/* draw up/down buttons */
@@ -340,18 +341,18 @@
 			DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color,  (clicked) ? FR_LOWERED : FR_NONE);
 			DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, TC_BLACK);
 
-			c1 = _colour_gradient[wi->color&0xF][3];
-			c2 = _colour_gradient[wi->color&0xF][7];
+			c1 = _colour_gradient[wi->color & 0xF][3];
+			c2 = _colour_gradient[wi->color & 0xF][7];
 
 			/* draw "shaded" background */
-			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2);
-			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
+			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c2);
+			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
 
 			/* draw shaded lines */
-			GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
-			GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2);
-			GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1);
-			GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2);
+			GfxFillRect(r.left + 2, r.top + 10, r.left + 2, r.bottom - 10, c1);
+			GfxFillRect(r.left + 3, r.top + 10, r.left + 3, r.bottom - 10, c2);
+			GfxFillRect(r.left + 7, r.top + 10, r.left + 7, r.bottom - 10, c1);
+			GfxFillRect(r.left + 8, r.top + 10, r.left + 8, r.bottom - 10, c2);
 
 			pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom);
 			DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : FR_NONE);
@@ -361,8 +362,9 @@
 		/* horizontal scrollbar */
 		case WWT_HSCROLLBAR: {
 			Point pt;
-			int c1,c2;
+			int c1, c2;
 
+			assert(wi->data == 0);
 			assert(r.bottom - r.top == 11); // XXX - to ensure the same sizes are used everywhere!
 
 			clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL));
@@ -370,21 +372,21 @@
 			DrawSprite(SPR_ARROW_LEFT, PAL_NONE, r.left + 1 + clicked, r.top + 1 + clicked);
 
 			clicked = ((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL));
-			DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+			DrawFrameRect(r.right - 9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 			DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, r.right - 8 + clicked, r.top + 1 + clicked);
 
-			c1 = _colour_gradient[wi->color&0xF][3];
-			c2 = _colour_gradient[wi->color&0xF][7];
+			c1 = _colour_gradient[wi->color & 0xF][3];
+			c2 = _colour_gradient[wi->color & 0xF][7];
 
 			/* draw "shaded" background */
-			GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2);
-			GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
+			GfxFillRect(r.left + 10, r.top, r.right - 10, r.bottom, c2);
+			GfxFillRect(r.left + 10, r.top, r.right - 10, r.bottom, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
 
 			/* draw shaded lines */
-			GfxFillRect(r.left+10, r.top+2, r.right-10, r.top+2, c1);
-			GfxFillRect(r.left+10, r.top+3, r.right-10, r.top+3, c2);
-			GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1);
-			GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2);
+			GfxFillRect(r.left + 10, r.top + 2, r.right - 10, r.top + 2, c1);
+			GfxFillRect(r.left + 10, r.top + 3, r.right - 10, r.top + 3, c2);
+			GfxFillRect(r.left + 10, r.top + 7, r.right - 10, r.top + 7, c1);
+			GfxFillRect(r.left + 10, r.top + 8, r.right - 10, r.top + 8, c2);
 
 			/* draw actual scrollbar */
 			pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right);
@@ -394,37 +396,39 @@
 		}
 
 		case WWT_FRAME: {
-			int c1,c2;
+			const StringID str = wi->data;
+			int c1, c2;
 			int x2 = r.left; // by default the left side is the left side of the widget
 
-			if (wi->data != 0) x2 = DrawString(r.left + 6, r.top, wi->data, TC_FROMSTRING);
+			if (str != STR_NULL) x2 = DrawString(r.left + 6, r.top, str, TC_FROMSTRING);
 
 			c1 = _colour_gradient[wi->color][3];
 			c2 = _colour_gradient[wi->color][7];
 
-			/*Line from upper left corner to start of text */
-			GfxFillRect(r.left, r.top+4, r.left+4,r.top+4, c1);
-			GfxFillRect(r.left+1, r.top+5, r.left+4,r.top+5, c2);
+			/* Line from upper left corner to start of text */
+			GfxFillRect(r.left, r.top + 4, r.left + 4, r.top + 4, c1);
+			GfxFillRect(r.left + 1, r.top + 5, r.left + 4, r.top + 5, c2);
 
 			/* Line from end of text to upper right corner */
-			GfxFillRect(x2, r.top+4, r.right-1,r.top+4,c1);
-			GfxFillRect(x2, r.top+5, r.right-2,r.top+5,c2);
+			GfxFillRect(x2, r.top + 4, r.right - 1, r.top + 4, c1);
+			GfxFillRect(x2, r.top + 5, r.right - 2, r.top + 5, c2);
 
 			/* Line from upper left corner to bottom left corner */
-			GfxFillRect(r.left, r.top+5, r.left, r.bottom-1, c1);
-			GfxFillRect(r.left+1, r.top+6, r.left+1, r.bottom-2, c2);
+			GfxFillRect(r.left, r.top + 5, r.left, r.bottom - 1, c1);
+			GfxFillRect(r.left + 1, r.top + 6, r.left + 1, r.bottom - 2, c2);
 
 			/*Line from upper right corner to bottom right corner */
-			GfxFillRect(r.right-1, r.top+5, r.right-1, r.bottom-2, c1);
-			GfxFillRect(r.right, r.top+4, r.right, r.bottom-1, c2);
+			GfxFillRect(r.right - 1, r.top + 5, r.right - 1, r.bottom - 2, c1);
+			GfxFillRect(r.right, r.top + 4, r.right, r.bottom - 1, c2);
 
-			GfxFillRect(r.left+1, r.bottom-1, r.right-1, r.bottom-1, c1);
+			GfxFillRect(r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1, c1);
 			GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2);
 
 			goto draw_default;
 		}
 
 		case WWT_STICKYBOX: {
+			assert(wi->data == 0);
 			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
 
 			clicked = !!(w->flags4 & WF_STICKY);
@@ -434,6 +438,7 @@
 		}
 
 		case WWT_RESIZEBOX: {
+			assert(wi->data == 0);
 			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
 
 			clicked = !!(w->flags4 & WF_SIZING);
@@ -443,26 +448,29 @@
 		}
 
 		case WWT_CLOSEBOX: {
+			const StringID str = wi->data;
+
+			assert(str == STR_00C5 || str == STR_00C6); // black or silver cross
 			assert(r.right - r.left == 10); // ensure the same sizes are used everywhere
 
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_NONE);
-			DrawString(r.left + 2, r.top + 2, STR_00C5, TC_FROMSTRING);
+			DrawString(r.left + 2, r.top + 2, str, TC_FROMSTRING);
 			break;
 		}
 
 		case WWT_CAPTION: {
 			assert(r.bottom - r.top == 13); // XXX - to ensure the same sizes are used everywhere!
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_BORDERONLY);
-			DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
+			DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, wi->color, (w->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
 
 			if (w->caption_color != 0xFF) {
-				GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _colour_gradient[_player_colors[w->caption_color]][4]);
+				GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_player_colors[w->caption_color]][4]);
 			}
 
-			DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top+2, wi->data, 0x84);
+			DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top + 2, wi->data, 0x84);
 draw_default:;
-			if (IsWindowWidgetDisabled(w, i)) {
-				GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _colour_gradient[wi->color&0xF][2] | (1 << PALETTE_MODIFIER_GREYOUT));
+			if (w->IsWidgetDisabled(i)) {
+				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[wi->color & 0xF][2] | (1 << PALETTE_MODIFIER_GREYOUT));
 			}
 		}
 		}
@@ -470,8 +478,7 @@
 
 
 	if (w->flags4 & WF_WHITE_BORDER_MASK) {
-		//DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10);
-		DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, FR_BORDERONLY);
+		DrawFrameRect(0, 0, w->width - 1, w->height - 1, 0xF, FR_BORDERONLY);
 	}
 
 }
@@ -496,12 +503,12 @@
 		return - 1;
 
 	item = y / 10;
-	if (item >= WP(w,dropdown_d).num_items || (HasBit(WP(w,dropdown_d).disabled_state, item) && !HasBit(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0)
+	if (item >= WP(w, dropdown_d).num_items || (HasBit(WP(w,dropdown_d).disabled_state, item) && !HasBit(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0)
 		return - 1;
 
 	/* Skip hidden items -- +1 for each hidden item before the clicked item. */
 	for (counter = 0; item >= counter; ++counter)
-		if (HasBit(WP(w,dropdown_d).hidden_state, counter)) item++;
+		if (HasBit(WP(w, dropdown_d).hidden_state, counter)) item++;
 
 	return item;
 }
@@ -520,19 +527,19 @@
 			x = 1;
 			y = 2 - w->vscroll.pos * 10;
 
-			sel    = WP(w,dropdown_d).selected_index;
+			sel    = WP(w, dropdown_d).selected_index;
 			width  = w->widget[0].right - 3;
 			height = w->widget[0].bottom - 3;
 
-			for (i = 0; WP(w,dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) {
-				if (HasBit(WP(w,dropdown_d).hidden_state, i)) continue;
+			for (i = 0; WP(w, dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) {
+				if (HasBit(WP(w, dropdown_d).hidden_state, i)) continue;
 
 				if (y >= 0 && y <= height) {
-					if (WP(w,dropdown_d).items[i] != STR_NULL) {
+					if (WP(w, dropdown_d).items[i] != STR_NULL) {
 						if (sel == 0) GfxFillRect(x + 1, y, x + width, y + 9, 0);
-						DrawStringTruncated(x + 2, y, WP(w,dropdown_d).items[i], sel == 0 ? TC_WHITE : TC_BLACK, x + width);
+						DrawStringTruncated(x + 2, y, WP(w, dropdown_d).items[i], sel == 0 ? TC_WHITE : TC_BLACK, x + width);
 
-						if (HasBit(WP(w,dropdown_d).disabled_state, i)) {
+						if (HasBit(WP(w, dropdown_d).disabled_state, i)) {
 							GfxFillRect(x, y, x + width, y + 9,
 								(1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[_dropdown_menu_widgets[0].color][5]
 							);
@@ -553,50 +560,50 @@
 			if (e->we.click.widget != 0) break;
 			item = GetDropdownItem(w);
 			if (item >= 0) {
-				WP(w,dropdown_d).click_delay = 4;
-				WP(w,dropdown_d).selected_index = item;
+				WP(w, dropdown_d).click_delay = 4;
+				WP(w, dropdown_d).selected_index = item;
 				SetWindowDirty(w);
 			}
 		} break;
 
 		case WE_MOUSELOOP: {
-			Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
+			Window *w2 = FindWindowById(WP(w, dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
 			if (w2 == NULL) {
 				DeleteWindow(w);
 				return;
 			}
 
-			if (WP(w,dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) {
+			if (WP(w, dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) {
 				WindowEvent e;
 				e.event = WE_DROPDOWN_SELECT;
-				e.we.dropdown.button = WP(w,dropdown_d).parent_button;
-				e.we.dropdown.index  = WP(w,dropdown_d).selected_index;
+				e.we.dropdown.button = WP(w, dropdown_d).parent_button;
+				e.we.dropdown.index  = WP(w, dropdown_d).selected_index;
 				w2->wndproc(w2, &e);
 				DeleteWindow(w);
 				return;
 			}
 
-			if (WP(w,dropdown_d).drag_mode) {
+			if (WP(w, dropdown_d).drag_mode) {
 				item = GetDropdownItem(w);
 
 				if (!_left_button_clicked) {
-					WP(w,dropdown_d).drag_mode = false;
+					WP(w, dropdown_d).drag_mode = false;
 					if (item < 0) return;
-					WP(w,dropdown_d).click_delay = 2;
+					WP(w, dropdown_d).click_delay = 2;
 				} else {
 					if (item < 0) return;
 				}
 
-				WP(w,dropdown_d).selected_index = item;
+				WP(w, dropdown_d).selected_index = item;
 				SetWindowDirty(w);
 			}
 		} break;
 
 		case WE_DESTROY: {
-			Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
+			Window *w2 = FindWindowById(WP(w, dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
 			if (w2 != NULL) {
-				RaiseWindowWidget(w2, WP(w,dropdown_d).parent_button);
-				InvalidateWidget(w2, WP(w,dropdown_d).parent_button);
+				w2->RaiseWidget(WP(w, dropdown_d).parent_button);
+				w2->InvalidateWidget(WP(w, dropdown_d).parent_button);
 			}
 		} break;
 	}
@@ -608,7 +615,7 @@
 	const Widget *wi;
 	Window *w2;
 	const Window *w3;
-	bool is_dropdown_menu_shown = IsWindowWidgetLowered(w, button);
+	bool is_dropdown_menu_shown = w->IsWidgetLowered(button);
 	int top, height;
 	int screen_top, screen_bottom;
 	bool scroll = false;
@@ -617,9 +624,9 @@
 
 	if (is_dropdown_menu_shown) return;
 
-	LowerWindowWidget(w, button);
+	w->LowerWidget(button);
 
-	InvalidateWidget(w, button);
+	w->InvalidateWidget(button);
 
 	for (i = 0; strings[i] != INVALID_STRING_ID; i++) {}
 	if (i == 0) return;
@@ -671,7 +678,7 @@
 	w2->widget[0].right = wi->right - wi[-1].left;
 	w2->widget[0].bottom = height - 1;
 
-	SetWindowWidgetHiddenState(w2, 1, !scroll);
+	w2->SetWidgetHiddenState(1, !scroll);
 
 	if (scroll) {
 		/* We're scrolling, so enable the scroll bar and shrink the list by
@@ -689,19 +696,19 @@
 	w2->desc_flags = WDF_DEF_WIDGET;
 	w2->flags4 &= ~WF_WHITE_BORDER_MASK;
 
-	WP(w2,dropdown_d).disabled_state = disabled_mask;
-	WP(w2,dropdown_d).hidden_state = hidden_mask;
+	WP(w2, dropdown_d).disabled_state = disabled_mask;
+	WP(w2, dropdown_d).hidden_state = hidden_mask;
 
-	WP(w2,dropdown_d).parent_wnd_class = w->window_class;
-	WP(w2,dropdown_d).parent_wnd_num = w->window_number;
-	WP(w2,dropdown_d).parent_button = button;
+	WP(w2, dropdown_d).parent_wnd_class = w->window_class;
+	WP(w2, dropdown_d).parent_wnd_num = w->window_number;
+	WP(w2, dropdown_d).parent_button = button;
 
-	WP(w2,dropdown_d).num_items = i;
-	WP(w2,dropdown_d).selected_index = selected;
-	WP(w2,dropdown_d).items = strings;
+	WP(w2, dropdown_d).num_items = i;
+	WP(w2, dropdown_d).selected_index = selected;
+	WP(w2, dropdown_d).items = strings;
 
-	WP(w2,dropdown_d).click_delay = 0;
-	WP(w2,dropdown_d).drag_mode = true;
+	WP(w2, dropdown_d).click_delay = 0;
+	WP(w2, dropdown_d).drag_mode = true;
 }
 
 
--- a/src/win32.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/win32.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,13 +5,9 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "macros.h"
-#include "helpers.hpp"
 #include "saveload.h"
-#include "string.h"
-#include "gfx.h"
-#include "window.h"
+#include "gfx_func.h"
+#include "textbuf_gui.h"
 #include "fileio.h"
 #include <windows.h>
 #include <winnt.h>
@@ -23,12 +19,16 @@
 #include "win32.h"
 #include "fios.h" // opendir/readdir/closedir
 #include "fileio.h"
+#include "core/alloc_func.hpp"
+#include "functions.h"
+#include "core/random_func.hpp"
+#include "core/bitmath_func.hpp"
+#include "string_func.h"
 #include <ctype.h>
 #include <tchar.h>
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <shlobj.h>
 #if defined(_MSC_VER) && !defined(WINCE)
 	#include <dbghelp.h>
 #endif
@@ -81,6 +81,17 @@
 
 #ifdef _MSC_VER
 static const char *_exception_string = NULL;
+void SetExceptionString(const char *s, ...)
+{
+	va_list va;
+	char buf[512];
+
+	va_start(va, s);
+	vsnprintf(buf, lengthof(buf), s, va);
+	va_end(va);
+
+	_exception_string = strdup(buf);
+}
 #endif
 
 void ShowOSErrorBox(const char *buf)
@@ -322,7 +333,7 @@
 	size = GetFileSize(h, NULL);
 	if (size > 500000) goto error1;
 
-	mem = malloc(size);
+	mem = MallocT<byte>(size);
 	if (mem == NULL) goto error1;
 
 	if (!ReadFile(h, mem, size, &read, NULL) || read != size) goto error2;
--- a/src/window.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/window.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -6,87 +6,97 @@
 #include <stdarg.h>
 #include "openttd.h"
 #include "debug.h"
-#include "functions.h"
-#include "map.h"
 #include "player.h"
-#include "window.h"
-#include "gfx.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"
-#include "helpers.hpp"
 #include "blitter/factory.hpp"
+#include "window_gui.h"
+#include "zoom_func.h"
+#include "core/alloc_func.hpp"
+#include "map_func.h"
+#include "vehicle_base.h"
 
 /* delta between mouse cursor and upper left corner of dragged window */
 static Point _drag_delta;
 
-static Window _windows[25];
+static Window _windows[MAX_NUMBER_OF_WINDOWS];
 Window *_z_windows[lengthof(_windows)];
 Window **_last_z_window; ///< always points to the next free space in the z-array
 
-void CDECL SetWindowWidgetsDisabledState(Window *w, bool disab_stat, int widgets, ...)
+void CDECL Window::SetWidgetsDisabledState(bool disab_stat, int widgets, ...)
 {
 	va_list wdg_list;
 
 	va_start(wdg_list, widgets);
 
 	while (widgets != WIDGET_LIST_END) {
-		SetWindowWidgetDisabledState(w, widgets, disab_stat);
+		SetWidgetDisabledState(widgets, disab_stat);
 		widgets = va_arg(wdg_list, int);
 	}
 
 	va_end(wdg_list);
 }
 
-void CDECL SetWindowWidgetsHiddenState(Window *w, bool hidden_stat, int widgets, ...)
-{
-	va_list wdg_list;
-
-	va_start(wdg_list, widgets);
-
-	while (widgets != WIDGET_LIST_END) {
-		SetWindowWidgetHiddenState(w, widgets, hidden_stat);
-		widgets = va_arg(wdg_list, int);
-	}
-
-	va_end(wdg_list);
-}
-
-void CDECL SetWindowWidgetsLoweredState(Window *w, bool lowered_stat, int widgets, ...)
+void CDECL Window::SetWidgetsHiddenState(bool hidden_stat, int widgets, ...)
 {
 	va_list wdg_list;
 
 	va_start(wdg_list, widgets);
 
 	while (widgets != WIDGET_LIST_END) {
-		SetWindowWidgetLoweredState(w, widgets, lowered_stat);
+		SetWidgetHiddenState(widgets, hidden_stat);
 		widgets = va_arg(wdg_list, int);
 	}
 
 	va_end(wdg_list);
 }
 
-void RaiseWindowButtons(Window *w)
+void CDECL Window::SetWidgetsLoweredState(bool lowered_stat, int widgets, ...)
+{
+	va_list wdg_list;
+
+	va_start(wdg_list, widgets);
+
+	while (widgets != WIDGET_LIST_END) {
+		SetWidgetLoweredState(widgets, lowered_stat);
+		widgets = va_arg(wdg_list, int);
+	}
+
+	va_end(wdg_list);
+}
+
+void Window::RaiseButtons()
 {
 	uint i;
 
-	for (i = 0; i < w->widget_count; i++) {
-		if (IsWindowWidgetLowered(w, i)) {
-			RaiseWindowWidget(w, i);
-			InvalidateWidget(w, i);
+	for (i = 0; i < this->widget_count; i++) {
+		if (this->IsWidgetLowered(i)) {
+			this->RaiseWidget(i);
+			this->InvalidateWidget(i);
 		}
 	}
 }
 
-void HandleButtonClick(Window *w, byte widget)
+void Window::InvalidateWidget(byte widget_index) const
 {
-	LowerWindowWidget(w, widget);
-	w->flags4 |= 5 << WF_TIMEOUT_SHL;
-	InvalidateWidget(w, widget);
+	const Widget *wi = &this->widget[widget_index];
+
+	/* Don't redraw the window if the widget is invisible or of no-type */
+	if (wi->type == WWT_EMPTY || IsWidgetHidden(widget_index)) return;
+
+	SetDirtyBlocks(this->left + wi->left, this->top + wi->top, this->left + wi->right + 1, this->top + wi->bottom + 1);
 }
 
+void Window::HandleButtonClick(byte widget)
+{
+	this->LowerWidget(widget);
+	this->flags4 |= 5 << WF_TIMEOUT_SHL;
+	this->InvalidateWidget(widget);
+}
 
 static void StartWindowDrag(Window *w);
 static void StartWindowSizing(Window *w);
@@ -105,7 +115,7 @@
 		if (e.we.click.widget < 0) return; // exit if clicked outside of widgets
 
 		/* don't allow any interaction if the button has been disabled */
-		if (IsWindowWidgetDisabled(w, e.we.click.widget)) return;
+		if (w->IsWidgetDisabled(e.we.click.widget)) return;
 
 		wi = &w->widget[e.we.click.widget];
 
@@ -115,7 +125,7 @@
 				case WWT_PANEL   | WWB_PUSHBUTTON: /* WWT_PUSHBTN */
 				case WWT_IMGBTN  | WWB_PUSHBUTTON: /* WWT_PUSHIMGBTN */
 				case WWT_TEXTBTN | WWB_PUSHBUTTON: /* WWT_PUSHTXTBTN */
-					HandleButtonClick(w, e.we.click.widget);
+					w->HandleButtonClick(e.we.click.widget);
 					break;
 			}
 		} else if (wi->type == WWT_SCROLLBAR || wi->type == WWT_SCROLL2BAR || wi->type == WWT_HSCROLLBAR) {
@@ -136,13 +146,13 @@
 
 		if (w->desc_flags & WDF_RESIZABLE && wi->type == WWT_RESIZEBOX) {
 			StartWindowSizing(w);
-			InvalidateWidget(w, e.we.click.widget);
+			w->InvalidateWidget(e.we.click.widget);
 			return;
 		}
 
 		if (w->desc_flags & WDF_STICKY_BUTTON && wi->type == WWT_STICKYBOX) {
 			w->flags4 ^= WF_STICKY;
-			InvalidateWidget(w, e.we.click.widget);
+			w->InvalidateWidget(e.we.click.widget);
 			return;
 		}
 	}
@@ -953,7 +963,7 @@
 
 	for (wz = _last_z_window; wz != _z_windows;) {
 		Window *w = *--wz;
-		if (IS_INSIDE_1D(x, w->left, w->width) && IS_INSIDE_1D(y, w->top, w->height)) {
+		if (IsInsideBS(x, w->left, w->width) && IsInsideBS(y, w->top, w->height)) {
 			return w;
 		}
 	}
@@ -1019,7 +1029,7 @@
 
 		if (w->flags4&WF_TIMEOUT_MASK && !(--w->flags4&WF_TIMEOUT_MASK)) {
 			CallWindowEventNP(w, WE_TIMEOUT);
-			if (w->desc_flags & WDF_UNCLICK_BUTTONS) RaiseWindowButtons(w);
+			if (w->desc_flags & WDF_UNCLICK_BUTTONS) w->RaiseButtons();
 		}
 	}
 }
@@ -1634,12 +1644,27 @@
 	e.we.keypress.keycode = GB(key, 16, 16);
 	e.we.keypress.cont = true;
 
+	/*
+	 * The Unicode standard defines an area called the private use area. Code points in this
+	 * area are reserved for private use and thus not portable between systems. For instance,
+	 * Apple defines code points for the arrow keys in this area, but these are only printable
+	 * on a system running OS X. We don't want these keys to show up in text fields and such,
+	 * and thus we have to clear the unicode character when we encounter such a key.
+	 */
+	if (e.we.keypress.key >= 0xE000 && e.we.keypress.key <= 0xF8FF) e.we.keypress.key = 0;
+
+	/*
+	 * If both key and keycode is zero, we don't bother to process the event.
+	 */
+	if (e.we.keypress.key == 0 && e.we.keypress.keycode == 0) return;
+
 	/* check if we have a query string window open before allowing hotkeys */
-	if (FindWindowById(WC_QUERY_STRING,       0) != NULL ||
-			FindWindowById(WC_SEND_NETWORK_MSG,   0) != NULL ||
-			FindWindowById(WC_GENERATE_LANDSCAPE, 0) != NULL ||
-			FindWindowById(WC_CONSOLE,            0) != NULL ||
-			FindWindowById(WC_SAVELOAD,           0) != NULL) {
+	if (FindWindowById(WC_QUERY_STRING,            0) != NULL ||
+			FindWindowById(WC_SEND_NETWORK_MSG,        0) != NULL ||
+			FindWindowById(WC_GENERATE_LANDSCAPE,      0) != NULL ||
+			FindWindowById(WC_CONSOLE,                 0) != NULL ||
+			FindWindowById(WC_SAVELOAD,                0) != NULL ||
+			FindWindowById(WC_COMPANY_PASSWORD_WINDOW, 0) != NULL) {
 		query_open = true;
 	}
 
@@ -1653,7 +1678,8 @@
 				w->window_class != WC_SEND_NETWORK_MSG &&
 				w->window_class != WC_GENERATE_LANDSCAPE &&
 				w->window_class != WC_CONSOLE &&
-				w->window_class != WC_SAVELOAD) {
+				w->window_class != WC_SAVELOAD &&
+				w->window_class != WC_COMPANY_PASSWORD_WINDOW) {
 			continue;
 		}
 		w->wndproc(w, &e);
@@ -1925,16 +1951,6 @@
 	}
 }
 
-void InvalidateWidget(const Window *w, byte widget_index)
-{
-	const Widget *wi = &w->widget[widget_index];
-
-	/* Don't redraw the window if the widget is invisible or of no-type */
-	if (wi->type == WWT_EMPTY || IsWindowWidgetHidden(w, widget_index)) return;
-
-	SetDirtyBlocks(w->left + wi->left, w->top + wi->top, w->left + wi->right + 1, w->top + wi->bottom + 1);
-}
-
 void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index)
 {
 	Window* const *wz;
@@ -1942,7 +1958,7 @@
 	FOR_ALL_WINDOWS(wz) {
 		const Window *w = *wz;
 		if (w->window_class == cls && w->window_number == number) {
-			InvalidateWidget(w, widget_index);
+			w->InvalidateWidget(widget_index);
 		}
 	}
 }
@@ -2131,8 +2147,11 @@
 			default:
 				left = w->left;
 				if (left + (w->width >> 1) >= neww) left = neww - w->width;
+				if (left < 0) left = 0;
+
 				top = w->top;
 				if (top + (w->height >> 1) >= newh) top = newh - w->height;
+				if (top < 0) top = 0;
 				break;
 		}
 
--- a/src/window.h	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,821 +0,0 @@
-/* $Id$ */
-
-/** @file window.h regroups declarations for all windowing system, as well as a few helper functions */
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include "macros.h"
-#include "string.h"
-#include "order.h"
-#include "rail.h"
-#include "road.h"
-#include "airport.h"
-#include "vehicle.h"
-#include "viewport.h"
-
-struct WindowEvent;
-
-typedef void WindowProc(Window *w, WindowEvent *e);
-
-/* How the resize system works:
-    First, you need to add a WWT_RESIZEBOX to the widgets, and you need
-     to add the flag WDF_RESIZABLE to the window. Now the window is ready
-     to resize itself.
-    As you may have noticed, all widgets have a RESIZE_XXX in their line.
-     This lines controls how the widgets behave on resize. RESIZE_NONE means
-     it doesn't do anything. Any other option let's one of the borders
-     move with the changed width/height. So if a widget has
-     RESIZE_RIGHT, and the window is made 5 pixels wider by the user,
-     the right of the window will also be made 5 pixels wider.
-    Now, what if you want to clamp a widget to the bottom? Give it the flag
-     RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets
-     5 pixels bigger, both the top and bottom gets 5 bigger, so the whole
-     widgets moves downwards without resizing, and appears to be clamped
-     to the bottom. Nice aint it?
-   You should know one more thing about this system. Most windows can't
-    handle an increase of 1 pixel. So there is a step function, which
-    let the windowsize only be changed by X pixels. You configure this
-    after making the window, like this:
-      w->resize.step_height = 10;
-    Now the window will only change in height in steps of 10.
-   You can also give a minimum width and height. The default value is
-    the default height/width of the window itself. You can change this
-    AFTER window-creation, with:
-     w->resize.width or w->resize.height.
-   That was all.. good luck, and enjoy :) -- TrueLight */
-
-enum ResizeFlag {
-	RESIZE_NONE   = 0,  ///< no resize required
-
-	RESIZE_LEFT   = 1,  ///< left resize flag
-	RESIZE_RIGHT  = 2,  ///< rigth resize flag
-	RESIZE_TOP    = 4,  ///< top resize flag
-	RESIZE_BOTTOM = 8,  ///< bottom resize flag
-
-	RESIZE_LR     = RESIZE_LEFT  | RESIZE_RIGHT,   ///<  combination of left and right resize flags
-	RESIZE_RB     = RESIZE_RIGHT | RESIZE_BOTTOM,  ///<  combination of right and bottom resize flags
-	RESIZE_TB     = RESIZE_TOP   | RESIZE_BOTTOM,  ///<  combination of top and bottom resize flags
-	RESIZE_LRB    = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags
-	RESIZE_LRTB   = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_TOP | RESIZE_BOTTOM,  ///<  combination of all resize flags
-	RESIZE_RTB    = RESIZE_RIGHT | RESIZE_TOP    | RESIZE_BOTTOM, ///<  combination of right, top and bottom resize flag
-
-	/* The following flags are used by the system to specify what is disabled, hidden, or clicked
-	 * They are used in the same place as the above RESIZE_x flags, Widget visual_flags.
-	 * These states are used in exceptions. If nothing is specified, they will indicate
-	 * Enabled, visible or unclicked widgets*/
-	WIDG_DISABLED = 4,  ///< widget is greyed out, not available
-	WIDG_HIDDEN   = 5,  ///< widget is made invisible
-	WIDG_LOWERED  = 6,  ///< widget is paint lowered, a pressed button in fact
-};
-
-enum {
-	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
-};
-
-struct Widget {
-	byte type;                        ///< Widget type, see WindowWidgetTypes
-	byte display_flags;               ///< Resize direction, alignment, etc. during resizing, see ResizeFlags
-	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
-	int16 left, right, top, bottom;   ///< The position offsets inside the window
-	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
-	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
-};
-
-enum FrameFlags {
-	FR_NONE         = 0x00,
-	FR_TRANSPARENT  = 0x01,  ///< Makes the background transparent if set
-	FR_BORDERONLY   = 0x10,  ///< Draw border only, no background
-	FR_LOWERED      = 0x20,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
-	FR_DARKENED     = 0x40,  ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes)
-};
-
-DECLARE_ENUM_AS_BIT_SET(FrameFlags);
-
-void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags);
-
-enum WindowEventCodes {
-	WE_CREATE,
-	WE_DESTROY,
-	WE_PAINT,
-	WE_KEYPRESS,
-	WE_CLICK,
-	WE_DOUBLE_CLICK,
-	WE_RCLICK,
-	WE_MOUSEOVER,
-	WE_MOUSELOOP,
-	WE_MOUSEWHEEL,
-	WE_TICK,
-	WE_4,
-	WE_TIMEOUT,
-	WE_PLACE_OBJ,
-	WE_ABORT_PLACE_OBJ,
-	WE_ON_EDIT_TEXT,
-	WE_ON_EDIT_TEXT_CANCEL,
-	WE_POPUPMENU_SELECT,
-	WE_POPUPMENU_OVER,
-	WE_DRAGDROP,
-	WE_PLACE_DRAG,
-	WE_PLACE_MOUSEUP,
-	WE_PLACE_PRESIZE,
-	WE_DROPDOWN_SELECT,
-	WE_RESIZE,
-	WE_MESSAGE,
-	WE_SCROLL,
-	WE_INVALIDATE_DATA,
-};
-
-struct WindowEvent {
-	byte event;
-	union {
-		struct {
-			void *data;
-		} create;
-
-		struct {
-			Point pt;
-			int widget;
-		} click;
-
-		struct {
-			Point pt;
-			TileIndex tile;
-			TileIndex starttile;
-			ViewportPlaceMethod select_method;
-			byte select_proc;
-		} place;
-
-		struct {
-			Point pt;
-			int widget;
-		} dragdrop;
-
-		struct {
-			Point size;
-			Point diff;
-		} sizing;
-
-		struct {
-			char *str;
-		} edittext;
-
-		struct {
-			Point pt;
-		} popupmenu;
-
-		struct {
-			int button;
-			int index;
-		} dropdown;
-
-		struct {
-			Point pt;
-			int widget;
-		} mouseover;
-
-		struct {
-			bool cont;      ///< continue the search? (default true)
-			uint16 key;     ///< 16-bit Unicode value of the key
-			uint16 keycode; ///< untranslated key (including shift-state)
-		} keypress;
-
-		struct {
-			int msg;      ///< message to be sent
-			int wparam;   ///< additional message-specific information
-			int lparam;   ///< additional message-specific information
-		} message;
-
-		struct {
-			Point delta;   ///< delta position against position of last call
-		} scroll;
-
-		struct {
-			int wheel;     ///< how much was 'wheel'd'
-		} wheel;
-	} we;
-};
-
-struct WindowDesc {
-	int16 left, top, minimum_width, minimum_height, default_width, default_height;
-	WindowClass cls;
-	WindowClass parent_cls;
-	uint32 flags;
-	const Widget *widgets;
-	WindowProc *proc;
-};
-
-enum WindowDefaultFlag {
-	WDF_STD_TOOLTIPS    =   1, ///< use standard routine when displaying tooltips
-	WDF_DEF_WIDGET      =   2, ///< default widget control for some widgets in the on click event
-	WDF_STD_BTN         =   4, ///< default handling for close and drag widgets (widget no 0 and 1)
-
-	WDF_UNCLICK_BUTTONS =  16, ///< Unclick buttons when the window event times out */
-	WDF_STICKY_BUTTON   =  32, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2)
-	WDF_RESIZABLE       =  64, ///< A window can be resized
-	WDF_MODAL           = 128, ///< The window is a modal child of some other window, meaning the parent is 'inactive'
-};
-
-/* can be used as x or y coordinates to cause a specific placement */
-enum WindowDefaultPosition {
-	WDP_AUTO      = -1, ///< Find a place automatically
-	WDP_CENTER    = -2, ///< Center the window (left/right or top/bottom)
-	WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
-	WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar
-};
-
-struct Textbuf {
-	char *buf;                  ///< buffer in which text is saved
-	uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes
-	uint16 length, width;       ///< the current size of the string. Width specifies screensize in pixels, length is in bytes
-	bool caret;                 ///< is the caret ("_") visible or not
-	uint16 caretpos;            ///< the current position of the caret in the buffer, in bytes
-	uint16 caretxoffs;          ///< the current position of the caret in pixels
-};
-
-#define WP(ptr,str) (*(str*)(ptr)->custom)
-/* You cannot 100% reliably calculate the biggest custom struct as
- * the number of pointers in it and alignment will have a huge impact.
- * 96 is the largest window-size for 64-bit machines currently */
-#define WINDOW_CUSTOM_SIZE 96
-
-struct Scrollbar {
-	uint16 count, cap, pos;
-};
-
-struct ResizeInfo {
-	uint width; ///< Minimum width and height
-	uint height;
-	uint step_width; ///< In how big steps the width and height go
-	uint step_height;
-};
-
-struct WindowMessage {
-	int msg;
-	int wparam;
-	int lparam;
-};
-
-struct Window {
-	uint16 flags4;
-	WindowClass window_class;
-	WindowNumber window_number;
-
-	int left, top;
-	int width, height;
-
-	Scrollbar hscroll, vscroll, vscroll2;
-	ResizeInfo resize;
-
-	byte caption_color;
-
-	WindowProc *wndproc;
-	ViewPort *viewport;
-	const Widget *original_widget;
-	Widget *widget;
-	uint widget_count;
-	uint32 desc_flags;
-
-	WindowMessage message;
-	Window *parent;
-	byte custom[WINDOW_CUSTOM_SIZE];
-};
-
-struct querystr_d {
-	StringID caption;
-	Textbuf text;
-	const char *orig;
-	CharSetFilter afilter;
-	bool handled;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
-
-struct chatquerystr_d : public querystr_d {
-	int dest;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d));
-
-struct menu_d {
-	byte item_count;      ///< follow_vehicle
-	byte sel_index;       ///< scrollpos_x
-	byte main_button;     ///< scrollpos_y
-	byte action_id;
-	StringID string_id;   ///< unk30
-	uint16 checked_items; ///< unk32
-	byte disabled_items;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d));
-
-struct def_d {
-	int16 data_1, data_2, data_3;
-	int16 data_4, data_5;
-	bool close;
-	byte byte_1;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d));
-
-struct void_d {
-	void *data;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d));
-
-struct tree_d {
-	uint16 base;
-	uint16 count;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d));
-
-struct tooltips_d {
-	StringID string_id;
-	byte paramcount;
-	uint64 params[5];
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
-
-struct buildvehicle_d {
-	VehicleType vehicle_type;
-	union {
-		RailTypeByte railtype;
-		AirportFTAClass::Flags flags;
-		RoadTypes roadtypes;
-	} filter;
-	byte sel_index;  ///< deprecated value, used for 'unified' ship and road
-	bool descending_sort_order;
-	byte sort_criteria;
-	bool regenerate_list;
-	EngineID sel_engine;
-	EngineID rename_engine;
-	EngineList eng_list;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d));
-
-struct replaceveh_d {
-	byte sel_index[2];
-	EngineID sel_engine[2];
-	uint16 count[2];
-	bool wagon_btnstate; ///< true means engine is selected
-	EngineList list[2];
-	bool update_left;
-	bool update_right;
-	bool init_lists;
-	GroupID sel_group;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
-
-struct depot_d {
-	VehicleID sel;
-	VehicleType type;
-	bool generate_list;
-	uint16 engine_list_length;
-	uint16 wagon_list_length;
-	uint16 engine_count;
-	uint16 wagon_count;
-	Vehicle **vehicle_list;
-	Vehicle **wagon_list;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d));
-
-struct order_d {
-	int sel;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
-
-struct vehicledetails_d {
-	byte tab;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehicledetails_d));
-
-struct smallmap_d {
-	int32 scroll_x;
-	int32 scroll_y;
-	int32 subscroll;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d));
-
-/* player face selection window */
-struct facesel_d {
-	PlayerFace face; // player face bits
-	bool advanced;   // advance player face selection window
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d));
-
-struct refit_d {
-	int sel;
-	struct RefitOption *cargo;
-	struct RefitList *list;
-	uint length;
-	VehicleOrderID order;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d));
-
-struct vp_d {
-	VehicleID follow_vehicle;
-	int32 scrollpos_x;
-	int32 scrollpos_y;
-	int32 dest_scrollpos_x;
-	int32 dest_scrollpos_y;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
-
-struct news_d {
-	uint16 follow_vehicle;
-	int32 scrollpos_x;
-	int32 scrollpos_y;
-	int32 dest_scrollpos_x;
-	int32 dest_scrollpos_y;
-	NewsItem *ni;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
-
-struct highscore_d {
-	uint32 background_img;
-	int8 rank;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d));
-
-struct scroller_d {
-	int height;
-	uint16 counter;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d));
-
-enum SortListFlags {
-	VL_NONE    = 0x00,  ///< no sort
-	VL_DESC    = 0x01,  ///< sort descending or ascending
-	VL_RESORT  = 0x02,  ///< instruct the code to resort the list in the next loop
-	VL_REBUILD = 0x04,  ///< create sort-listing to use for qsort and friends
-	VL_END     = 0x08
-};
-
-DECLARE_ENUM_AS_BIT_SET(SortListFlags);
-
-struct Listing {
-	bool order;    ///< Ascending/descending
-	byte criteria; ///< Sorting criteria
-};
-
-struct list_d {
-	uint16 list_length;  ///< length of the list being sorted
-	byte sort_type;      ///< what criteria to sort on
-	SortListFlags flags; ///< used to control sorting/resorting/etc.
-	uint16 resort_timer; ///< resort list after a given amount of ticks if set
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d));
-
-struct message_d {
-	int msg;
-	int wparam;
-	int lparam;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d));
-
-struct dropdown_d {
-	uint32 disabled_state;
-	uint32 hidden_state;
-	WindowClass parent_wnd_class;
-	WindowNumber parent_wnd_num;
-	byte parent_button;
-	byte num_items;
-	byte selected_index;
-	const StringID *items;
-	byte click_delay;
-	bool drag_mode;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
-
-struct vehiclelist_d {
-	const Vehicle** sort_list;  // List of vehicles (sorted)
-	Listing *_sorting;          // pointer to the appropiate subcategory of _sorting
-	uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for
-	VehicleType vehicle_type;   // The vehicle type that is sorted
-	list_d l;                   // General list struct
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
-
-struct grouplist_d {
-	const Group **sort_list;
-	list_d l;                   // General list struct
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(grouplist_d));
-
-struct groupveh_d : vehiclelist_d {
-	GroupID group_sel;
-	VehicleID vehicle_sel;
-
-	grouplist_d gl;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(groupveh_d));
-
-/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
-enum WindowWidgetBehaviours {
-	WWB_PUSHBUTTON  = 1 << 5,
-
-	WWB_MASK        = 0xE0,
-};
-
-
-enum WindowWidgetTypes {
-	WWT_EMPTY,
-
-	WWT_PANEL,      ///< simple depressed panel
-	WWT_INSET,      ///< pressed (inset) panel, most commonly used as combo box _text_ area
-	WWT_IMGBTN,     ///< button with image
-	WWT_IMGBTN_2,   ///< button with diff image when clicked
-
-	WWT_TEXTBTN,    ///< button with text
-	WWT_TEXTBTN_2,  ///< button with diff text when clicked
-	WWT_LABEL,      ///< centered label
-	WWT_TEXT,       ///< pure simple text
-	WWT_MATRIX,
-	WWT_SCROLLBAR,
-	WWT_FRAME,      ///< frame
-	WWT_CAPTION,
-
-	WWT_HSCROLLBAR,
-	WWT_STICKYBOX,
-	WWT_SCROLL2BAR, ///< 2nd vertical scrollbar
-	WWT_RESIZEBOX,
-	WWT_CLOSEBOX,
-	WWT_LAST,       ///< Last Item. use WIDGETS_END to fill up padding!!
-
-	WWT_MASK = 0x1F,
-
-	WWT_PUSHBTN     = WWT_PANEL   | WWB_PUSHBUTTON,
-	WWT_PUSHTXTBTN  = WWT_TEXTBTN | WWB_PUSHBUTTON,
-	WWT_PUSHIMGBTN  = WWT_IMGBTN  | WWB_PUSHBUTTON,
-};
-
-#define WIDGETS_END WWT_LAST,   RESIZE_NONE,     0,     0,     0,     0,     0, 0, STR_NULL
-
-enum WindowFlags {
-	WF_TIMEOUT_SHL       = 0,
-	WF_TIMEOUT_MASK      = 7,
-	WF_DRAGGING          = 1 <<  3,
-	WF_SCROLL_UP         = 1 <<  4,
-	WF_SCROLL_DOWN       = 1 <<  5,
-	WF_SCROLL_MIDDLE     = 1 <<  6,
-	WF_HSCROLL           = 1 <<  7,
-	WF_SIZING            = 1 <<  8,
-	WF_STICKY            = 1 <<  9,
-
-	WF_DISABLE_VP_SCROLL = 1 << 10,
-
-	WF_WHITE_BORDER_ONE  = 1 << 11,
-	WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE,
-	WF_SCROLL2           = 1 << 13,
-};
-
-/* window.cpp */
-void CallWindowEventNP(Window *w, int event);
-void CallWindowTickEvent();
-
-/**
- * Marks the window as dirty for repaint.
- *
- * @ingroup dirty
- */
-void SetWindowDirty(const Window *w);
-void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
-void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
-
-Window *FindWindowById(WindowClass cls, WindowNumber number);
-void DeleteWindow(Window *w);
-void DeletePlayerWindows(PlayerID pi);
-void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
-Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
-Window *FindWindowFromPt(int x, int y);
-
-bool IsWindowOfPrototype(const Window *w, const Widget *widget);
-void AssignWidgetToWindow(Window *w, const Widget *widget);
-Window *AllocateWindow(
-							int x,
-							int y,
-							int width,
-							int height,
-							WindowProc *proc,
-							WindowClass cls,
-							const Widget *widget,
-							void *data = NULL);
-
-Window *AllocateWindowDesc(const WindowDesc *desc, void *data = NULL);
-Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL);
-
-void DrawWindowViewport(const Window *w);
-void ResizeWindow(Window *w, int x, int y);
-
-/**
- * Sets the enabled/disabled status of a widget.
- * By default, widgets are enabled.
- * On certain conditions, they have to be disabled.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- * @param disab_stat : status to use ie: disabled = true, enabled = false
- */
-static inline void SetWindowWidgetDisabledState(Window *w, byte widget_index, bool disab_stat)
-{
-	assert(widget_index < w->widget_count);
-	SB(w->widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat);
-}
-
-/**
- * Sets a widget to disabled.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- */
-static inline void DisableWindowWidget(Window *w, byte widget_index)
-{
-	SetWindowWidgetDisabledState(w, widget_index, true);
-}
-
-/**
- * Sets a widget to Enabled.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- */
-static inline void EnableWindowWidget(Window *w, byte widget_index)
-{
-	SetWindowWidgetDisabledState(w, widget_index, false);
-}
-
-/**
- * Gets the enabled/disabled status of a widget.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- * @return status of the widget ie: disabled = true, enabled = false
- */
-static inline bool IsWindowWidgetDisabled(const Window *w, byte widget_index)
-{
-	assert(widget_index < w->widget_count);
-	return HasBit(w->widget[widget_index].display_flags, WIDG_DISABLED);
-}
-
-/**
- * Sets the hidden/shown status of a widget.
- * By default, widgets are visible.
- * On certain conditions, they have to be hidden.
- * @param w Window on which the widget is located
- * @param widget_index index of this widget in the window
- * @param hidden_stat status to use ie. hidden = true, visible = false
- */
-static inline void SetWindowWidgetHiddenState(Window *w, byte widget_index, bool hidden_stat)
-{
-	assert(widget_index < w->widget_count);
-	SB(w->widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat);
-}
-
-/**
- * Sets a widget hidden.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- */
-static inline void HideWindowWidget(Window *w, byte widget_index)
-{
-	SetWindowWidgetHiddenState(w, widget_index, true);
-}
-
-/**
- * Sets a widget visible.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- */
-static inline void ShowWindowWidget(Window *w, byte widget_index)
-{
-	SetWindowWidgetHiddenState(w, widget_index, false);
-}
-
-/**
- * Gets the visibility of a widget.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- * @return status of the widget ie: hidden = true, visible = false
- */
-static inline bool IsWindowWidgetHidden(const Window *w, byte widget_index)
-{
-	assert(widget_index < w->widget_count);
-	return HasBit(w->widget[widget_index].display_flags, WIDG_HIDDEN);
-}
-
-/**
- * Sets the lowered/raised status of a widget.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- * @param lowered_stat : status to use ie: lowered = true, raised = false
- */
-static inline void SetWindowWidgetLoweredState(Window *w, byte widget_index, bool lowered_stat)
-{
-	assert(widget_index < w->widget_count);
-	SB(w->widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat);
-}
-
-/**
- * Invert the lowered/raised  status of a widget.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- */
-static inline void ToggleWidgetLoweredState(Window *w, byte widget_index)
-{
-	assert(widget_index < w->widget_count);
-	ToggleBit(w->widget[widget_index].display_flags, WIDG_LOWERED);
-}
-
-/**
- * Marks a widget as lowered.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- */
-static inline void LowerWindowWidget(Window *w, byte widget_index)
-{
-	SetWindowWidgetLoweredState(w, widget_index, true);
-}
-
-/**
- * Marks a widget as raised.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- */
-static inline void RaiseWindowWidget(Window *w, byte widget_index)
-{
-	SetWindowWidgetLoweredState(w, widget_index, false);
-}
-
-/**
- * Gets the lowered state of a widget.
- * @param w : Window on which the widget is located
- * @param widget_index : index of this widget in the window
- * @return status of the widget ie: lowered = true, raised= false
- */
-static inline bool IsWindowWidgetLowered(const Window *w, byte widget_index)
-{
-	assert(widget_index < w->widget_count);
-	return HasBit(w->widget[widget_index].display_flags, WIDG_LOWERED);
-}
-
-void InitWindowSystem();
-void UnInitWindowSystem();
-void ResetWindowSystem();
-int GetMenuItemIndex(const Window *w, int x, int y);
-void InputLoop();
-void InvalidateWidget(const Window *w, byte widget_index);
-void InvalidateThisWindowData(Window *w);
-void InvalidateWindowData(WindowClass cls, WindowNumber number);
-void RaiseWindowButtons(Window *w);
-void RelocateAllWindows(int neww, int newh);
-int PositionMainToolbar(Window *w);
-void CDECL SetWindowWidgetsDisabledState(Window *w, bool disab_stat, int widgets, ...);
-void CDECL SetWindowWidgetsHiddenState(Window *w, bool hidden_stat, int widgets, ...);
-void CDECL SetWindowWidgetsLoweredState(Window *w, bool lowered_stat, int widgets, ...);
-
-/* misc_gui.cpp */
-void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]);
-static inline void GuiShowTooltips(StringID str)
-{
-	GuiShowTooltipsWithArgs(str, 0, NULL);
-}
-
-/* widget.cpp */
-int GetWidgetFromPos(const Window *w, int x, int y);
-void DrawWindowWidgets(const Window *w);
-void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask);
-
-void HandleButtonClick(Window *w, byte widget);
-
-Window *GetCallbackWnd();
-void DeleteNonVitalWindows();
-void DeleteAllNonVitalWindows();
-void HideVitalWindows();
-void ShowVitalWindows();
-Window **FindWindowZPosition(const Window *w);
-
-/* window.cpp */
-extern Window *_z_windows[];
-extern Window **_last_z_window;
-#define FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++)
-
-VARDEF Point _cursorpos_drag_start;
-
-VARDEF int _scrollbar_start_pos;
-VARDEF int _scrollbar_size;
-VARDEF byte _scroller_click_timeout;
-
-VARDEF bool _scrolling_scrollbar;
-VARDEF bool _scrolling_viewport;
-VARDEF bool _popup_menu_active;
-
-VARDEF byte _special_mouse_mode;
-enum SpecialMouseMode {
-	WSM_NONE     = 0,
-	WSM_DRAGDROP = 1,
-	WSM_SIZING   = 2,
-	WSM_PRESIZE  = 3,
-};
-
-void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y);
-
-/** Evenly distribute some widgets when resizing horizontally (often a button row)
- *  The widgets are presumed to be in a line and numberef from left to right (without gaps)
- * @param w widow to modify
- * @param left The leftmost widget to resize
- * @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT
- */
-void ResizeButtons(Window *w, byte left, byte right);
-
-#endif /* WINDOW_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/window_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,49 @@
+/* $Id$ */
+
+/** @file window.h Window functions not directly related to making/drawing windows. */
+
+#ifndef WINDOW_FUNC_H
+#define WINDOW_FUNC_H
+
+#include "window_type.h"
+
+/**
+ * Marks the window as dirty for repaint.
+ *
+ * @ingroup dirty
+ */
+void SetWindowDirty(const Window *w);
+void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
+void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
+
+Window *FindWindowById(WindowClass cls, WindowNumber number);
+void DeleteWindow(Window *w);
+void DeletePlayerWindows(PlayerID pi);
+void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
+
+void ResizeWindow(Window *w, int x, int y);
+int PositionMainToolbar(Window *w);
+
+void InitWindowSystem();
+void UnInitWindowSystem();
+void ResetWindowSystem();
+void SetupColorsAndInitialWindow();
+void InputLoop();
+void InvalidateThisWindowData(Window *w);
+void InvalidateWindowData(WindowClass cls, WindowNumber number);
+void RelocateAllWindows(int neww, int newh);
+
+void DeleteNonVitalWindows();
+void DeleteAllNonVitalWindows();
+void HideVitalWindows();
+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 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/window_gui.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,778 @@
+/* $Id$ */
+
+/** @file window_gui.h Functions, definitions and such used only by the GUI. */
+
+#ifndef WINDOW_GUI_H
+#define WINDOW_GUI_H
+
+#include "core/bitmath_func.hpp"
+#include "vehicle_type.h"
+#include "viewport_type.h"
+
+/**
+ * The maximum number of windows that can be opened.
+ */
+static const int MAX_NUMBER_OF_WINDOWS = 25;
+
+typedef void WindowProc(Window *w, WindowEvent *e);
+
+/* How the resize system works:
+    First, you need to add a WWT_RESIZEBOX to the widgets, and you need
+     to add the flag WDF_RESIZABLE to the window. Now the window is ready
+     to resize itself.
+    As you may have noticed, all widgets have a RESIZE_XXX in their line.
+     This lines controls how the widgets behave on resize. RESIZE_NONE means
+     it doesn't do anything. Any other option let's one of the borders
+     move with the changed width/height. So if a widget has
+     RESIZE_RIGHT, and the window is made 5 pixels wider by the user,
+     the right of the window will also be made 5 pixels wider.
+    Now, what if you want to clamp a widget to the bottom? Give it the flag
+     RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets
+     5 pixels bigger, both the top and bottom gets 5 bigger, so the whole
+     widgets moves downwards without resizing, and appears to be clamped
+     to the bottom. Nice aint it?
+   You should know one more thing about this system. Most windows can't
+    handle an increase of 1 pixel. So there is a step function, which
+    let the windowsize only be changed by X pixels. You configure this
+    after making the window, like this:
+      w->resize.step_height = 10;
+    Now the window will only change in height in steps of 10.
+   You can also give a minimum width and height. The default value is
+    the default height/width of the window itself. You can change this
+    AFTER window-creation, with:
+     w->resize.width or w->resize.height.
+   That was all.. good luck, and enjoy :) -- TrueLight */
+
+enum ResizeFlag {
+	RESIZE_NONE   = 0,  ///< no resize required
+
+	RESIZE_LEFT   = 1,  ///< left resize flag
+	RESIZE_RIGHT  = 2,  ///< rigth resize flag
+	RESIZE_TOP    = 4,  ///< top resize flag
+	RESIZE_BOTTOM = 8,  ///< bottom resize flag
+
+	RESIZE_LR     = RESIZE_LEFT  | RESIZE_RIGHT,   ///<  combination of left and right resize flags
+	RESIZE_RB     = RESIZE_RIGHT | RESIZE_BOTTOM,  ///<  combination of right and bottom resize flags
+	RESIZE_TB     = RESIZE_TOP   | RESIZE_BOTTOM,  ///<  combination of top and bottom resize flags
+	RESIZE_LRB    = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags
+	RESIZE_LRTB   = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_TOP | RESIZE_BOTTOM,  ///<  combination of all resize flags
+	RESIZE_RTB    = RESIZE_RIGHT | RESIZE_TOP    | RESIZE_BOTTOM, ///<  combination of right, top and bottom resize flag
+
+	/* The following flags are used by the system to specify what is disabled, hidden, or clicked
+	 * They are used in the same place as the above RESIZE_x flags, Widget visual_flags.
+	 * These states are used in exceptions. If nothing is specified, they will indicate
+	 * Enabled, visible or unclicked widgets*/
+	WIDG_DISABLED = 4,  ///< widget is greyed out, not available
+	WIDG_HIDDEN   = 5,  ///< widget is made invisible
+	WIDG_LOWERED  = 6,  ///< widget is paint lowered, a pressed button in fact
+};
+
+enum {
+	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
+};
+
+struct Widget {
+	byte type;                        ///< Widget type, see WindowWidgetTypes
+	byte display_flags;               ///< Resize direction, alignment, etc. during resizing, see ResizeFlags
+	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
+	int16 left, right, top, bottom;   ///< The position offsets inside the window
+	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
+	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
+};
+
+enum FrameFlags {
+	FR_NONE         =  0,
+	FR_TRANSPARENT  =  1 << 0,  ///< Makes the background transparent if set
+	FR_BORDERONLY   =  1 << 4,  ///< Draw border only, no background
+	FR_LOWERED      =  1 << 5,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
+	FR_DARKENED     =  1 << 6,  ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes)
+};
+
+DECLARE_ENUM_AS_BIT_SET(FrameFlags);
+
+void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags);
+
+enum WindowEventCodes {
+	WE_CREATE,
+	WE_DESTROY,
+	WE_PAINT,
+	WE_KEYPRESS,
+	WE_CLICK,
+	WE_DOUBLE_CLICK,
+	WE_RCLICK,
+	WE_MOUSEOVER,
+	WE_MOUSELOOP,
+	WE_MOUSEWHEEL,
+	WE_TICK,
+	WE_4,
+	WE_TIMEOUT,
+	WE_PLACE_OBJ,
+	WE_ABORT_PLACE_OBJ,
+	WE_ON_EDIT_TEXT,
+	WE_ON_EDIT_TEXT_CANCEL,
+	WE_POPUPMENU_SELECT,
+	WE_POPUPMENU_OVER,
+	WE_DRAGDROP,
+	WE_PLACE_DRAG,
+	WE_PLACE_MOUSEUP,
+	WE_PLACE_PRESIZE,
+	WE_DROPDOWN_SELECT,
+	WE_RESIZE,
+	WE_MESSAGE,
+	WE_SCROLL,
+	WE_INVALIDATE_DATA,
+};
+
+struct WindowEvent {
+	byte event;
+	union {
+		struct {
+			void *data;
+		} create;
+
+		struct {
+			Point pt;
+			int widget;
+		} click;
+
+		struct {
+			Point pt;
+			TileIndex tile;
+			TileIndex starttile;
+			ViewportPlaceMethod select_method;
+			byte select_proc;
+		} place;
+
+		struct {
+			Point pt;
+			int widget;
+		} dragdrop;
+
+		struct {
+			Point size;
+			Point diff;
+		} sizing;
+
+		struct {
+			char *str;
+		} edittext;
+
+		struct {
+			Point pt;
+		} popupmenu;
+
+		struct {
+			int button;
+			int index;
+		} dropdown;
+
+		struct {
+			Point pt;
+			int widget;
+		} mouseover;
+
+		struct {
+			bool cont;      ///< continue the search? (default true)
+			uint16 key;     ///< 16-bit Unicode value of the key
+			uint16 keycode; ///< untranslated key (including shift-state)
+		} keypress;
+
+		struct {
+			int msg;      ///< message to be sent
+			int wparam;   ///< additional message-specific information
+			int lparam;   ///< additional message-specific information
+		} message;
+
+		struct {
+			Point delta;   ///< delta position against position of last call
+		} scroll;
+
+		struct {
+			int wheel;     ///< how much was 'wheel'd'
+		} wheel;
+	} we;
+};
+
+struct WindowDesc {
+	int16 left, top, minimum_width, minimum_height, default_width, default_height;
+	WindowClass cls;
+	WindowClass parent_cls;
+	uint32 flags;
+	const Widget *widgets;
+	WindowProc *proc;
+};
+
+enum WindowDefaultFlag {
+	WDF_STD_TOOLTIPS    =   1 << 0, ///< use standard routine when displaying tooltips
+	WDF_DEF_WIDGET      =   1 << 1, ///< default widget control for some widgets in the on click event
+	WDF_STD_BTN         =   1 << 2, ///< default handling for close and drag widgets (widget no 0 and 1)
+
+	WDF_UNCLICK_BUTTONS =   1 << 4, ///< Unclick buttons when the window event times out */
+	WDF_STICKY_BUTTON   =   1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2)
+	WDF_RESIZABLE       =   1 << 6, ///< A window can be resized
+	WDF_MODAL           =   1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive'
+};
+
+/* can be used as x or y coordinates to cause a specific placement */
+enum WindowDefaultPosition {
+	WDP_AUTO      = -1, ///< Find a place automatically
+	WDP_CENTER    = -2, ///< Center the window (left/right or top/bottom)
+	WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
+	WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar
+};
+
+#define WP(ptr, str) (*(str*)(ptr)->custom)
+
+struct Scrollbar {
+	uint16 count, cap, pos;
+};
+
+struct ResizeInfo {
+	uint width; ///< Minimum width and height
+	uint height;
+	uint step_width; ///< In how big steps the width and height go
+	uint step_height;
+};
+
+struct WindowMessage {
+	int msg;
+	int wparam;
+	int lparam;
+};
+
+struct Window {
+	uint16 flags4;
+	WindowClass window_class;
+	WindowNumber window_number;
+
+	int left, top;
+	int width, height;
+
+	Scrollbar hscroll, vscroll, vscroll2;
+	ResizeInfo resize;
+
+	byte caption_color;
+
+	WindowProc *wndproc;
+	ViewPort *viewport;
+	const Widget *original_widget;
+	Widget *widget;
+	uint widget_count;
+	uint32 desc_flags;
+
+	WindowMessage message;
+	Window *parent;
+	byte custom[WINDOW_CUSTOM_SIZE];
+
+	void HandleButtonClick(byte widget);
+
+	void SetWidgetDisabledState(byte widget_index, bool disab_stat);
+	void DisableWidget(byte widget_index);
+	void EnableWidget(byte widget_index);
+	bool IsWidgetDisabled(byte widget_index) const;
+	void SetWidgetHiddenState(byte widget_index, bool hidden_stat);
+	void HideWidget(byte widget_index);
+	void ShowWidget(byte widget_index);
+	bool IsWidgetHidden(byte widget_index) const;
+	void SetWidgetLoweredState(byte widget_index, bool lowered_stat);
+	void ToggleWidgetLoweredState(byte widget_index);
+	void LowerWidget(byte widget_index);
+	void RaiseWidget(byte widget_index);
+	bool IsWidgetLowered(byte widget_index) const;
+
+	void RaiseButtons();
+	void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...);
+	void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...);
+	void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...);
+	void InvalidateWidget(byte widget_index) const;
+};
+
+struct menu_d {
+	byte item_count;      ///< follow_vehicle
+	byte sel_index;       ///< scrollpos_x
+	byte main_button;     ///< scrollpos_y
+	byte action_id;
+	StringID string_id;   ///< unk30
+	uint16 checked_items; ///< unk32
+	byte disabled_items;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d));
+
+struct def_d {
+	int16 data_1, data_2, data_3;
+	int16 data_4, data_5;
+	bool close;
+	byte byte_1;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d));
+
+struct void_d {
+	void *data;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d));
+
+struct tree_d {
+	uint16 base;
+	uint16 count;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d));
+
+struct tooltips_d {
+	StringID string_id;
+	byte paramcount;
+	uint64 params[5];
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
+
+struct replaceveh_d {
+	byte sel_index[2];
+	EngineID sel_engine[2];
+	uint16 count[2];
+	bool wagon_btnstate; ///< true means engine is selected
+	EngineList list[2];
+	bool update_left;
+	bool update_right;
+	bool init_lists;
+	GroupID sel_group;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
+
+struct depot_d {
+	VehicleID sel;
+	VehicleType type;
+	bool generate_list;
+	uint16 engine_list_length;
+	uint16 wagon_list_length;
+	uint16 engine_count;
+	uint16 wagon_count;
+	Vehicle **vehicle_list;
+	Vehicle **wagon_list;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d));
+
+struct order_d {
+	int sel;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
+
+struct vehicledetails_d {
+	byte tab;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehicledetails_d));
+
+struct smallmap_d {
+	int32 scroll_x;
+	int32 scroll_y;
+	int32 subscroll;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d));
+
+/* player face selection window */
+struct facesel_d {
+	PlayerFace face; // player face bits
+	bool advanced;   // advance player face selection window
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d));
+
+struct refit_d {
+	int sel;
+	struct RefitOption *cargo;
+	struct RefitList *list;
+	uint length;
+	VehicleOrderID order;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d));
+
+struct vp_d {
+	VehicleID follow_vehicle;
+	int32 scrollpos_x;
+	int32 scrollpos_y;
+	int32 dest_scrollpos_x;
+	int32 dest_scrollpos_y;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
+
+struct news_d {
+	uint16 follow_vehicle;
+	int32 scrollpos_x;
+	int32 scrollpos_y;
+	int32 dest_scrollpos_x;
+	int32 dest_scrollpos_y;
+	NewsItem *ni;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
+
+struct highscore_d {
+	uint32 background_img;
+	int8 rank;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d));
+
+struct scroller_d {
+	int height;
+	uint16 counter;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d));
+
+enum SortListFlags {
+	VL_NONE    = 0,      ///< no sort
+	VL_DESC    = 1 << 0, ///< sort descending or ascending
+	VL_RESORT  = 1 << 1, ///< instruct the code to resort the list in the next loop
+	VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends
+	VL_END     = 1 << 3,
+};
+
+DECLARE_ENUM_AS_BIT_SET(SortListFlags);
+
+struct Listing {
+	bool order;    ///< Ascending/descending
+	byte criteria; ///< Sorting criteria
+};
+
+struct list_d {
+	uint16 list_length;  ///< length of the list being sorted
+	byte sort_type;      ///< what criteria to sort on
+	SortListFlags flags; ///< used to control sorting/resorting/etc.
+	uint16 resort_timer; ///< resort list after a given amount of ticks if set
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d));
+
+struct message_d {
+	int msg;
+	int wparam;
+	int lparam;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d));
+
+struct dropdown_d {
+	uint32 disabled_state;
+	uint32 hidden_state;
+	WindowClass parent_wnd_class;
+	WindowNumber parent_wnd_num;
+	byte parent_button;
+	byte num_items;
+	byte selected_index;
+	const StringID *items;
+	byte click_delay;
+	bool drag_mode;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
+
+struct vehiclelist_d {
+	const Vehicle** sort_list;  // List of vehicles (sorted)
+	Listing *_sorting;          // pointer to the appropiate subcategory of _sorting
+	uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for
+	VehicleType vehicle_type;   // The vehicle type that is sorted
+	list_d l;                   // General list struct
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
+
+struct grouplist_d {
+	const Group **sort_list;
+	list_d l;                   // General list struct
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(grouplist_d));
+
+struct groupveh_d : vehiclelist_d {
+	GroupID group_sel;
+	VehicleID vehicle_sel;
+
+	grouplist_d gl;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(groupveh_d));
+
+/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
+enum WindowWidgetBehaviours {
+	WWB_PUSHBUTTON  = 1 << 5,
+
+	WWB_MASK        = 0xE0,
+};
+
+
+enum WindowWidgetTypes {
+	WWT_EMPTY,
+
+	WWT_PANEL,      ///< simple depressed panel
+	WWT_INSET,      ///< pressed (inset) panel, most commonly used as combo box _text_ area
+	WWT_IMGBTN,     ///< button with image
+	WWT_IMGBTN_2,   ///< button with diff image when clicked
+
+	WWT_TEXTBTN,    ///< button with text
+	WWT_TEXTBTN_2,  ///< button with diff text when clicked
+	WWT_LABEL,      ///< centered label
+	WWT_TEXT,       ///< pure simple text
+	WWT_MATRIX,
+	WWT_SCROLLBAR,
+	WWT_FRAME,      ///< frame
+	WWT_CAPTION,
+
+	WWT_HSCROLLBAR,
+	WWT_STICKYBOX,
+	WWT_SCROLL2BAR, ///< 2nd vertical scrollbar
+	WWT_RESIZEBOX,
+	WWT_CLOSEBOX,
+	WWT_LAST,       ///< Last Item. use WIDGETS_END to fill up padding!!
+
+	WWT_MASK = 0x1F,
+
+	WWT_PUSHBTN     = WWT_PANEL   | WWB_PUSHBUTTON,
+	WWT_PUSHTXTBTN  = WWT_TEXTBTN | WWB_PUSHBUTTON,
+	WWT_PUSHIMGBTN  = WWT_IMGBTN  | WWB_PUSHBUTTON,
+};
+
+#define WIDGETS_END WWT_LAST,   RESIZE_NONE,     0,     0,     0,     0,     0, 0, STR_NULL
+
+enum WindowFlags {
+	WF_TIMEOUT_SHL       = 0,
+	WF_TIMEOUT_MASK      = 7,
+	WF_DRAGGING          = 1 <<  3,
+	WF_SCROLL_UP         = 1 <<  4,
+	WF_SCROLL_DOWN       = 1 <<  5,
+	WF_SCROLL_MIDDLE     = 1 <<  6,
+	WF_HSCROLL           = 1 <<  7,
+	WF_SIZING            = 1 <<  8,
+	WF_STICKY            = 1 <<  9,
+
+	WF_DISABLE_VP_SCROLL = 1 << 10,
+
+	WF_WHITE_BORDER_ONE  = 1 << 11,
+	WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE,
+	WF_SCROLL2           = 1 << 13,
+};
+
+/* window.cpp */
+void CallWindowEventNP(Window *w, int event);
+void CallWindowTickEvent();
+
+/**
+ * Marks the window as dirty for repaint.
+ *
+ * @ingroup dirty
+ */
+void SetWindowDirty(const Window *w);
+void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
+void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
+
+Window *FindWindowById(WindowClass cls, WindowNumber number);
+void DeleteWindow(Window *w);
+void DeletePlayerWindows(PlayerID pi);
+void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
+Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
+Window *FindWindowFromPt(int x, int y);
+
+bool IsWindowOfPrototype(const Window *w, const Widget *widget);
+void AssignWidgetToWindow(Window *w, const Widget *widget);
+Window *AllocateWindow(
+							int x,
+							int y,
+							int width,
+							int height,
+							WindowProc *proc,
+							WindowClass cls,
+							const Widget *widget,
+							void *data = NULL);
+
+Window *AllocateWindowDesc(const WindowDesc *desc, void *data = NULL);
+Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL);
+
+void DrawWindowViewport(const Window *w);
+void ResizeWindow(Window *w, int x, int y);
+
+void InitWindowSystem();
+void UnInitWindowSystem();
+void ResetWindowSystem();
+int GetMenuItemIndex(const Window *w, int x, int y);
+void InputLoop();
+void InvalidateThisWindowData(Window *w);
+void InvalidateWindowData(WindowClass cls, WindowNumber number);
+void RelocateAllWindows(int neww, int newh);
+
+/* misc_gui.cpp */
+void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]);
+static inline void GuiShowTooltips(StringID str)
+{
+	GuiShowTooltipsWithArgs(str, 0, NULL);
+}
+
+/* widget.cpp */
+int GetWidgetFromPos(const Window *w, int x, int y);
+void DrawWindowWidgets(const Window *w);
+void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask);
+
+
+Window *GetCallbackWnd();
+void DeleteNonVitalWindows();
+void DeleteAllNonVitalWindows();
+void HideVitalWindows();
+void ShowVitalWindows();
+Window **FindWindowZPosition(const Window *w);
+
+/* window.cpp */
+extern Window *_z_windows[];
+extern Window **_last_z_window;
+#define FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++)
+
+VARDEF Point _cursorpos_drag_start;
+
+VARDEF int _scrollbar_start_pos;
+VARDEF int _scrollbar_size;
+VARDEF byte _scroller_click_timeout;
+
+VARDEF bool _scrolling_scrollbar;
+VARDEF bool _scrolling_viewport;
+VARDEF bool _popup_menu_active;
+
+VARDEF byte _special_mouse_mode;
+enum SpecialMouseMode {
+	WSM_NONE     = 0,
+	WSM_DRAGDROP = 1,
+	WSM_SIZING   = 2,
+	WSM_PRESIZE  = 3,
+};
+
+void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y);
+
+/** Evenly distribute some widgets when resizing horizontally (often a button row)
+ *  The widgets are presumed to be in a line and numberef from left to right (without gaps)
+ * @param w widow to modify
+ * @param left The leftmost widget to resize
+ * @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT
+ */
+void ResizeButtons(Window *w, byte left, byte right);
+
+
+/**
+ * Sets the enabled/disabled status of a widget.
+ * By default, widgets are enabled.
+ * On certain conditions, they have to be disabled.
+ * @param widget_index : index of this widget in the window
+ * @param disab_stat : status to use ie: disabled = true, enabled = false
+ */
+inline void Window::SetWidgetDisabledState(byte widget_index, bool disab_stat)
+{
+	assert(widget_index < this->widget_count);
+	SB(this->widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat);
+}
+
+/**
+ * Sets a widget to disabled.
+ * @param widget_index : index of this widget in the window
+ */
+inline void Window::DisableWidget(byte widget_index)
+{
+	SetWidgetDisabledState(widget_index, true);
+}
+
+/**
+ * Sets a widget to Enabled.
+ * @param widget_index : index of this widget in the window
+ */
+inline void Window::EnableWidget(byte widget_index)
+{
+	SetWidgetDisabledState(widget_index, false);
+}
+
+/**
+ * Gets the enabled/disabled status of a widget.
+ * @param widget_index : index of this widget in the window
+ * @return status of the widget ie: disabled = true, enabled = false
+ */
+inline bool Window::IsWidgetDisabled(byte widget_index) const
+{
+	assert(widget_index < this->widget_count);
+	return HasBit(this->widget[widget_index].display_flags, WIDG_DISABLED);
+}
+
+/**
+ * Sets the hidden/shown status of a widget.
+ * By default, widgets are visible.
+ * On certain conditions, they have to be hidden.
+ * @param widget_index index of this widget in the window
+ * @param hidden_stat status to use ie. hidden = true, visible = false
+ */
+inline void Window::SetWidgetHiddenState(byte widget_index, bool hidden_stat)
+{
+	assert(widget_index < this->widget_count);
+	SB(this->widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat);
+}
+
+/**
+ * Sets a widget hidden.
+ * @param widget_index : index of this widget in the window
+ */
+inline void Window::HideWidget(byte widget_index)
+{
+	SetWidgetHiddenState(widget_index, true);
+}
+
+/**
+ * Sets a widget visible.
+ * @param widget_index : index of this widget in the window
+ */
+inline void Window::ShowWidget(byte widget_index)
+{
+	SetWidgetHiddenState(widget_index, false);
+}
+
+/**
+ * Gets the visibility of a widget.
+ * @param widget_index : index of this widget in the window
+ * @return status of the widget ie: hidden = true, visible = false
+ */
+inline bool Window::IsWidgetHidden(byte widget_index) const
+{
+	assert(widget_index < this->widget_count);
+	return HasBit(this->widget[widget_index].display_flags, WIDG_HIDDEN);
+}
+
+/**
+ * Sets the lowered/raised status of a widget.
+ * @param widget_index : index of this widget in the window
+ * @param lowered_stat : status to use ie: lowered = true, raised = false
+ */
+inline void Window::SetWidgetLoweredState(byte widget_index, bool lowered_stat)
+{
+	assert(widget_index < this->widget_count);
+	SB(this->widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat);
+}
+
+/**
+ * Invert the lowered/raised  status of a widget.
+ * @param widget_index : index of this widget in the window
+ */
+inline void Window::ToggleWidgetLoweredState(byte widget_index)
+{
+	assert(widget_index < this->widget_count);
+	ToggleBit(this->widget[widget_index].display_flags, WIDG_LOWERED);
+}
+
+/**
+ * Marks a widget as lowered.
+ * @param widget_index : index of this widget in the window
+ */
+inline void Window::LowerWidget(byte widget_index)
+{
+	SetWidgetLoweredState(widget_index, true);
+}
+
+/**
+ * Marks a widget as raised.
+ * @param widget_index : index of this widget in the window
+ */
+inline void Window::RaiseWidget(byte widget_index)
+{
+	SetWidgetLoweredState(widget_index, false);
+}
+
+/**
+ * Gets the lowered state of a widget.
+ * @param widget_index : index of this widget in the window
+ * @return status of the widget ie: lowered = true, raised= false
+ */
+inline bool Window::IsWidgetLowered(byte widget_index) const
+{
+	assert(widget_index < this->widget_count);
+	return HasBit(this->widget[widget_index].display_flags, WIDG_LOWERED);
+}
+
+#endif /* WINDOW_GUI_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/window_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,106 @@
+/* $Id$ */
+
+/** @file window_type.h Types related to windows */
+
+#ifndef WINDOW_TYPE_H
+#define WINDOW_TYPE_H
+
+#include "core/enum_type.hpp"
+
+enum WindowClass {
+	WC_NONE,
+	WC_MAIN_WINDOW = WC_NONE,
+	WC_MAIN_TOOLBAR,
+	WC_STATUS_BAR,
+	WC_BUILD_TOOLBAR,
+	WC_NEWS_WINDOW,
+	WC_TOWN_DIRECTORY,
+	WC_STATION_LIST,
+	WC_TOWN_VIEW,
+	WC_SMALLMAP,
+	WC_TRAINS_LIST,
+	WC_ROADVEH_LIST,
+	WC_SHIPS_LIST,
+	WC_AIRCRAFT_LIST,
+	WC_VEHICLE_VIEW,
+	WC_VEHICLE_DETAILS,
+	WC_VEHICLE_REFIT,
+	WC_VEHICLE_ORDERS,
+	WC_STATION_VIEW,
+	WC_VEHICLE_DEPOT,
+	WC_BUILD_VEHICLE,
+	WC_BUILD_BRIDGE,
+	WC_ERRMSG,
+	WC_BUILD_STATION,
+	WC_BUS_STATION,
+	WC_TRUCK_STATION,
+	WC_BUILD_DEPOT,
+	WC_COMPANY,
+	WC_FINANCES,
+	WC_PLAYER_COLOR,
+	WC_QUERY_STRING,
+	WC_SAVELOAD,
+	WC_SELECT_GAME,
+	WC_TOOLBAR_MENU,
+	WC_INCOME_GRAPH,
+	WC_OPERATING_PROFIT,
+	WC_TOOLTIPS,
+	WC_INDUSTRY_VIEW,
+	WC_PLAYER_FACE,
+	WC_LAND_INFO,
+	WC_TOWN_AUTHORITY,
+	WC_SUBSIDIES_LIST,
+	WC_GRAPH_LEGEND,
+	WC_DELIVERED_CARGO,
+	WC_PERFORMANCE_HISTORY,
+	WC_COMPANY_VALUE,
+	WC_COMPANY_LEAGUE,
+	WC_BUY_COMPANY,
+	WC_PAYMENT_RATES,
+	WC_ENGINE_PREVIEW,
+	WC_MUSIC_WINDOW,
+	WC_MUSIC_TRACK_SELECTION,
+	WC_SCEN_LAND_GEN,
+	WC_SCEN_TOWN_GEN,
+	WC_SCEN_INDUSTRY,
+	WC_SCEN_BUILD_ROAD,
+	WC_BUILD_TREES,
+	WC_SEND_NETWORK_MSG,
+	WC_DROPDOWN_MENU,
+	WC_BUILD_INDUSTRY,
+	WC_GAME_OPTIONS,
+	WC_NETWORK_WINDOW,
+	WC_INDUSTRY_DIRECTORY,
+	WC_MESSAGE_HISTORY,
+	WC_CHEATS,
+	WC_PERFORMANCE_DETAIL,
+	WC_CONSOLE,
+	WC_EXTRA_VIEW_PORT,
+	WC_CLIENT_LIST,
+	WC_NETWORK_STATUS_WINDOW,
+	WC_CUSTOM_CURRENCY,
+	WC_REPLACE_VEHICLE,
+	WC_HIGHSCORE,
+	WC_ENDSCREEN,
+	WC_SIGN_LIST,
+	WC_GENERATE_LANDSCAPE,
+	WC_GENERATE_PROGRESS_WINDOW,
+	WC_CONFIRM_POPUP_QUERY,
+	WC_TRANSPARENCY_TOOLBAR,
+	WC_VEHICLE_TIMETABLE,
+	WC_BUILD_SIGNAL,
+	WC_COMPANY_PASSWORD_WINDOW,
+};
+
+struct Window;
+struct WindowEvent;
+typedef int32 WindowNumber;
+
+/**
+ * You cannot 100% reliably calculate the biggest custom struct as
+ * the number of pointers in it and alignment will have a huge impact.
+ * 96 is the largest window-size for 64-bit machines currently.
+ */
+#define WINDOW_CUSTOM_SIZE 96
+
+#endif /* WINDOW_TYPE_H */
--- a/src/yapf/follow_track.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/yapf/follow_track.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -78,7 +78,7 @@
 
 		// extra handling for tunnels in our direction
 		if (IsTunnelTile(m_old_tile)) {
-			DiagDirection tunnel_enterdir = GetTunnelDirection(m_old_tile);
+			DiagDirection tunnel_enterdir = GetTunnelBridgeDirection(m_old_tile);
 			if (tunnel_enterdir == m_exitdir) {
 				// we are entering the tunnel
 				FindLengthOfTunnelResult flotr = FindLengthOfTunnel(m_old_tile, m_exitdir);
@@ -92,7 +92,7 @@
 
 		// extra handling for bridge ramp in our direction
 		if (IsBridgeTile(m_old_tile)) {
-			DiagDirection bridge_enterdir = GetBridgeRampDirection(m_old_tile);
+			DiagDirection bridge_enterdir = GetTunnelBridgeDirection(m_old_tile);
 			if (bridge_enterdir == m_exitdir) {
 				// we are entering the bridge ramp
 				m_new_tile = GetOtherBridgeEnd(m_old_tile);
@@ -208,7 +208,7 @@
 		if (!IsWaterTT() && IsTileType(m_new_tile, MP_TUNNELBRIDGE)) {
 			if (IsTunnel(m_new_tile)) {
 				if (!m_is_tunnel) {
-					DiagDirection tunnel_enterdir = GetTunnelDirection(m_new_tile);
+					DiagDirection tunnel_enterdir = GetTunnelBridgeDirection(m_new_tile);
 					if (tunnel_enterdir != m_exitdir) {
 						m_err = EC_NO_WAY;
 						return false;
@@ -216,7 +216,7 @@
 				}
 			} else if (IsBridge(m_new_tile)) {
 				if (!m_is_bridge) {
-					DiagDirection ramp_enderdir = GetBridgeRampDirection(m_new_tile);
+					DiagDirection ramp_enderdir = GetTunnelBridgeDirection(m_new_tile);
 					if (ramp_enderdir != m_exitdir) {
 						m_err = EC_NO_WAY;
 						return false;
--- a/src/yapf/track_dir.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/yapf/track_dir.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -3,9 +3,6 @@
 #ifndef  TRACK_DIR_HPP
 #define  TRACK_DIR_HPP
 
-#include "../tile.h"
 #include "../openttd.h"
-#include "../map.h"
-#include "../rail.h"
 
 #endif /* TRACK_DIR_HPP */
--- a/src/yapf/yapf.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/yapf/yapf.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -7,23 +7,23 @@
 
 #include "track_dir.hpp"
 
-#include "../vehicle.h"
+#include "../vehicle_base.h"
 #include "../depot.h"
 #include "../road_map.h"
 #include "../tunnel_map.h"
 #include "../bridge_map.h"
+#include "../tunnelbridge_map.h"
 #include "../bridge.h"
 #include "../station.h"
 #include "../station_map.h"
-#include "../date.h"
-#include "../functions.h"
+#include "../tile_cmd.h"
 #include "../landscape.h"
 #include "yapf.h"
 #include "../pathfind.h"
 #include "../waypoint.h"
 #include "../debug.h"
+#include "../settings_type.h"
 
-extern Patches _patches_newgame;
 extern uint64 _rdtsc();
 
 #include <limits.h>
--- a/src/yapf/yapf_costbase.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/yapf/yapf_costbase.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -11,7 +11,7 @@
 		if (IsDiagonalTrackdir(td)) {
 			if (IsBridgeTile(tile)) {
 				// it is bridge ramp, check if we are entering the bridge
-				if (GetBridgeRampDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are living it, no penalty
+				if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are living it, no penalty
 				// we are entering the bridge
 				// if the tile slope is downwards, then bridge ramp has not upward slope
 				uint tile_slope = GetTileSlope(tile, NULL) & 0x0F;
--- a/src/yapf/yapf_costcache.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/yapf/yapf_costcache.hpp	Wed Jan 09 18:11:12 2008 +0000
@@ -5,6 +5,7 @@
 #ifndef  YAPF_COSTCACHE_HPP
 #define  YAPF_COSTCACHE_HPP
 
+#include "../date_func.h"
 
 /** CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements
  * PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData
--- a/src/yapf/yapf_rail.cpp	Fri Nov 23 16:59:30 2007 +0000
+++ b/src/yapf/yapf_rail.cpp	Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,7 @@
 #include "yapf_node_rail.hpp"
 #include "yapf_costrail.hpp"
 #include "yapf_destrail.hpp"
+#include "../vehicle_func.h"
 
 #define DEBUG_YAPF_CACHE 0
 
--- a/src/zoom.hpp	Fri Nov 23 16:59:30 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/* $Id$ */
-
-/** @file zoom.hpp */
-
-#ifndef ZOOM_HPP
-#define ZOOM_HPP
-
-enum ZoomLevel {
-	/* Our possible zoom-levels */
-	ZOOM_LVL_NORMAL = 0,
-	ZOOM_LVL_OUT_2X,
-	ZOOM_LVL_OUT_4X,
-	ZOOM_LVL_OUT_8X,
-	ZOOM_LVL_END,
-
-	/* Here we define in which zoom viewports are */
-	ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL,
-	ZOOM_LVL_NEWS     = ZOOM_LVL_NORMAL,
-	ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X,
-	ZOOM_LVL_TOWN     = ZOOM_LVL_OUT_2X,
-	ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL,
-	ZOOM_LVL_SHIP     = ZOOM_LVL_NORMAL,
-	ZOOM_LVL_TRAIN    = ZOOM_LVL_NORMAL,
-	ZOOM_LVL_ROADVEH  = ZOOM_LVL_NORMAL,
-	ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL,
-
-	ZOOM_LVL_DETAIL   = ZOOM_LVL_OUT_2X, ///< All zoomlevels below or equal to this, will result in details on the screen, like road-work, ...
-
-	ZOOM_LVL_MIN      = ZOOM_LVL_NORMAL,
-	ZOOM_LVL_MAX      = ZOOM_LVL_OUT_8X,
-};
-
-extern ZoomLevel _saved_scrollpos_zoom;
-
-/**
- * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
- * When shifting right, value is rounded up
- * @param value value to shift
- * @param zoom  zoom level to shift to
- * @return shifted value
- */
-static inline int ScaleByZoom(int value, ZoomLevel zoom)
-{
-	if (zoom == ZOOM_LVL_NORMAL) return value;
-	int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
-	return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom) - 1) >> -izoom;
-}
-
-/**
- * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
- * When shifting right, value is rounded up
- * @param value value to shift
- * @param zoom  zoom level to shift to
- * @return shifted value
- */
-static inline int UnScaleByZoom(int value, ZoomLevel zoom)
-{
-	if (zoom == ZOOM_LVL_NORMAL) return value;
-	int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
-	return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom;
-}
-
-/**
- * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
- * @param value value to shift
- * @param zoom  zoom level to shift to
- * @return shifted value
- */
-static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
-{
-	if (zoom == ZOOM_LVL_NORMAL) return value;
-	int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
-	return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom;
-}
-
-/**
- * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
- * @param value value to shift
- * @param zoom  zoom level to shift to
- * @return shifted value
- */
-static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
-{
-	if (zoom == ZOOM_LVL_NORMAL) return value;
-	int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
-	return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
-}
-
-#endif /* ZOOM_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/zoom_func.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,66 @@
+/* $Id$ */
+
+/** @file zoom.hpp */
+
+#ifndef ZOOM_FUNC_H
+#define ZOOM_FUNC_H
+
+#include "zoom_type.h"
+
+extern ZoomLevel _saved_scrollpos_zoom;
+
+/**
+ * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
+ * When shifting right, value is rounded up
+ * @param value value to shift
+ * @param zoom  zoom level to shift to
+ * @return shifted value
+ */
+static inline int ScaleByZoom(int value, ZoomLevel zoom)
+{
+	if (zoom == ZOOM_LVL_NORMAL) return value;
+	int izoom = zoom - ZOOM_LVL_NORMAL;
+	return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom) - 1) >> -izoom;
+}
+
+/**
+ * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
+ * When shifting right, value is rounded up
+ * @param value value to shift
+ * @param zoom  zoom level to shift to
+ * @return shifted value
+ */
+static inline int UnScaleByZoom(int value, ZoomLevel zoom)
+{
+	if (zoom == ZOOM_LVL_NORMAL) return value;
+	int izoom = zoom - ZOOM_LVL_NORMAL;
+	return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom;
+}
+
+/**
+ * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
+ * @param value value to shift
+ * @param zoom  zoom level to shift to
+ * @return shifted value
+ */
+static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
+{
+	if (zoom == ZOOM_LVL_NORMAL) return value;
+	int izoom = zoom - ZOOM_LVL_NORMAL;
+	return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom;
+}
+
+/**
+ * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
+ * @param value value to shift
+ * @param zoom  zoom level to shift to
+ * @return shifted value
+ */
+static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
+{
+	if (zoom == ZOOM_LVL_NORMAL) return value;
+	int izoom = zoom - ZOOM_LVL_NORMAL;
+	return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
+}
+
+#endif /* ZOOM_FUNC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/zoom_type.h	Wed Jan 09 18:11:12 2008 +0000
@@ -0,0 +1,37 @@
+/* $Id$ */
+
+/** @file zoom_type.h Types related to zooming in and out. */
+
+#ifndef ZOOM_TYPE_H
+#define ZOOM_TYPE_H
+
+#include "core/enum_type.hpp"
+
+enum ZoomLevel {
+	/* Our possible zoom-levels */
+	ZOOM_LVL_BEGIN  = 0,
+	ZOOM_LVL_NORMAL = 0,
+	ZOOM_LVL_OUT_2X,
+	ZOOM_LVL_OUT_4X,
+	ZOOM_LVL_OUT_8X,
+	ZOOM_LVL_END,
+
+	/* Here we define in which zoom viewports are */
+	ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_NEWS     = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X,
+	ZOOM_LVL_TOWN     = ZOOM_LVL_OUT_2X,
+	ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_SHIP     = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_TRAIN    = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_ROADVEH  = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL,
+
+	ZOOM_LVL_DETAIL   = ZOOM_LVL_OUT_2X, ///< All zoomlevels below or equal to this, will result in details on the screen, like road-work, ...
+
+	ZOOM_LVL_MIN      = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_MAX      = ZOOM_LVL_OUT_8X,
+};
+DECLARE_POSTFIX_INCREMENT(ZoomLevel)
+
+#endif /* ZOOM_TYPE_H */