(svn r12211) [NoAI] -Sync: with trunk r12050:12209 noai
authorglx
Fri, 22 Feb 2008 00:25:54 +0000
branchnoai
changeset 9732 f8eb3e208514
parent 9731 9b1552d0fd9b
child 9733 49e424cd4edd
(svn r12211) [NoAI] -Sync: with trunk r12050:12209
Makefile.lang.in
changelog.txt
docs/landscape.html
docs/landscape_grid.html
known-bugs.txt
os/debian/changelog
os/win32/installer/install.nsi
projects/generate.vbs
projects/openttd_vs80.vcproj
projects/openttd_vs90.vcproj
projects/strgen_vs80.vcproj
projects/strgen_vs90.vcproj
readme.txt
source.list
src/ai/api/ai_airport.cpp
src/ai/api/ai_enginelist.cpp
src/ai/api/ai_station.cpp
src/ai/api/ai_tile.cpp
src/ai/api/ai_vehicle.cpp
src/aircraft_cmd.cpp
src/airport_gui.cpp
src/articulated_vehicles.cpp
src/articulated_vehicles.h
src/autoreplace_gui.cpp
src/bridge.h
src/bridge_gui.cpp
src/bridge_map.h
src/build_vehicle_gui.cpp
src/cargopacket.cpp
src/cargopacket.h
src/clear_cmd.cpp
src/command.cpp
src/command_type.h
src/console_cmds.cpp
src/core/alloc_func.cpp
src/core/alloc_func.hpp
src/core/math_func.hpp
src/core/random_func.hpp
src/depot.h
src/depot_gui.cpp
src/disaster_cmd.cpp
src/dock_gui.cpp
src/dummy_land.cpp
src/economy.cpp
src/economy_func.h
src/economy_type.h
src/elrail.cpp
src/engine.cpp
src/engine.h
src/engine_gui.cpp
src/gfx_func.h
src/group_gui.cpp
src/gui.h
src/industry_cmd.cpp
src/landscape.cpp
src/lang/afrikaans.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/lang/unfinished/greek.txt
src/lang/unfinished/latvian.txt
src/main_gui.cpp
src/misc_gui.cpp
src/newgrf.cpp
src/newgrf.h
src/newgrf_cargo.cpp
src/newgrf_commons.cpp
src/newgrf_commons.h
src/newgrf_config.cpp
src/newgrf_engine.cpp
src/newgrf_generic.cpp
src/newgrf_generic.h
src/newgrf_gui.cpp
src/newgrf_house.cpp
src/newgrf_industrytiles.cpp
src/newgrf_spritegroup.cpp
src/newgrf_spritegroup.h
src/newgrf_station.cpp
src/newgrf_town.cpp
src/npf.cpp
src/npf.h
src/oldloader.cpp
src/openttd.cpp
src/order_cmd.cpp
src/order_gui.cpp
src/pathfind.cpp
src/pathfind.h
src/player_base.h
src/player_gui.cpp
src/rail_cmd.cpp
src/rail_gui.cpp
src/rail_map.h
src/road_cmd.cpp
src/road_gui.cpp
src/road_map.cpp
src/road_map.h
src/roadveh.h
src/roadveh_cmd.cpp
src/saveload.cpp
src/settings.cpp
src/settings_gui.cpp
src/settings_type.h
src/ship_cmd.cpp
src/signal.cpp
src/sound.cpp
src/sprite.h
src/spritecache.cpp
src/station.h
src/station_cmd.cpp
src/table/bridge_land.h
src/table/engines.h
src/table/road_land.h
src/table/roadveh.h
src/table/roadveh_movement.h
src/table/sprites.h
src/table/station_land.h
src/table/track_land.h
src/table/unmovable_land.h
src/tile_cmd.h
src/town_cmd.cpp
src/town_gui.cpp
src/town_map.h
src/track_func.h
src/track_type.h
src/train.h
src/train_cmd.cpp
src/transparency.h
src/transparency_gui.cpp
src/tree_cmd.cpp
src/tunnelbridge_cmd.cpp
src/tunnelbridge_map.h
src/unmovable_cmd.cpp
src/vehicle.cpp
src/vehicle_base.h
src/vehicle_gui.cpp
src/vehicle_type.h
src/video/cocoa/event.mm
src/video/sdl_v.cpp
src/video/win32_v.cpp
src/viewport.cpp
src/water.h
src/water_cmd.cpp
src/water_map.h
src/waypoint.cpp
src/waypoint.h
src/widgets/dropdown.cpp
src/window.cpp
src/window_gui.h
src/yapf/follow_track.hpp
src/yapf/yapf_base.hpp
src/yapf/yapf_destrail.hpp
src/yapf/yapf_rail.cpp
src/yapf/yapf_road.cpp
src/yapf/yapf_ship.cpp
--- a/Makefile.lang.in	Thu Feb 21 22:34:54 2008 +0000
+++ b/Makefile.lang.in	Fri Feb 22 00:25:54 2008 +0000
@@ -44,13 +44,17 @@
 	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
 	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
 
+alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h
+	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
+	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
+
 lang/english.txt: $(LANG_DIR)/english.txt
 	$(Q)mkdir -p lang
 	$(Q)cp $(LANG_DIR)/english.txt lang/english.txt
 
-$(STRGEN): string.o strgen.o
+$(STRGEN): alloc_func.o string.o strgen.o
 	$(E) '$(STAGE) Compiling and Linking $@'
-	$(Q)$(CXX_BUILD) string.o strgen.o -o $@
+	$(Q)$(CXX_BUILD) $^ -o $@
 
 table/strings.h: lang/english.txt $(STRGEN)
 	$(E) '$(STAGE) Generating $@'
--- a/changelog.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/changelog.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1,3 +1,128 @@
+0.6.0-beta4 (2008-02-18)
+------------------------------------------------------------------------
+-Feature: Allow buttons to resize in NewGRF settings window (r12172)
+-Feature: Change colour of autorail and autoroad selection when Ctrl is pressed (r12167)
+-Feature: Separate catenary transparency settings from building transparency settings (r12103)
+-Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x' (r12102)
+-Feature: Add some missing VarAction2 variables (r12124)
+-Feature: Make snow appear on rail tiles dependant on track height, not on height of the lowest part of the tile (r12098)
+-Feature[newGRF]: Specify the purchase, rail and road description of a bridge (r12069)
+-Feature[newGRF]: Add support for var 12, Variational Action 2 (r12045)
+-Feature: Allow trees on shore (r12029)
+-Feature: Invisible trees are now separate from the building concept (r12022)
+-Feature: Add support for passenger engine designation for AI-use, NewGRF property 0x08 for trains (r12019)
+-Feature: Show all cargo sources (en-route from) in the station view cargo waiting list instead of just one (r11990)
+-Feature[newGRF]: Resizable industry view window on callback 3A (r11987)
+-Feature[newGRF]: Implement var 8F(random bits) during callback 28 [FS#1697] (r11985)
+-Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size (r11961)
+-Feature: Make use of new sprites added by Action5 type 0D (r11947)
+-Feature: Allow building bridge heads on more slopes (r11937)
+-Feature[newGRF]: Add support for Rivers. Rivers can currently only be placed with-in the scenario editor (r11926,r11938,r11949,r12071)
+-Feature: Generate.vbs script to allow project files generation for users unable to run generate bash script (r12123)
+-Feature: Sort the strings in languages dropdown (r11886)
+-Codechange: Drop MSVC 2003 support (r11979)
+-Fix: Test purchase list loading/loaded sprites instead of unconditionally returning a possibly non-existant sprite (r12180)
+-Fix: Return correct bridge price for AI when DC_QUERY_COST is set [FS#609] (r12171)
+-Fix: When drag&drop mode was cancelled by keyboard input, depot/group window wasn't updated [FS#337] (r12166)
+-Fix: Buffer overflow when drawing scrolling news [FS#1652, FS#1773] (r12165)
+-Fix: If a train is 'stopping' when entering a depot, do not let it leave again [FS#1705] (r12163)
+-Fix: Towns shouldn't build over houses owned by another town [FS#1757] (r12162)
+-Fix: Towns will no longer build houses > 1x1 there where should be road (with 2x2, 3x3 grid town layouts) (r12161)
+-Fix: Remove the arbitrary limit of 64 waypoints per town [FS#1744] (r12160)
+-Fix: Chance16I was now biased towards zero - round to nearest now (r12156)
+-Fix: Adjust aircraft slowing algorithm (r12144)
+-Fix: Callback 0x3D always gets a cargobit in var 0x18, independent of grf version [FS#1766] (r12142)
+-Fix: Do not allow adding tram to rail-road crossing when there is a vehicle on it (r12138)
+-Fix: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown [FS#1769] (r12137)
+-Fix: With mammoth trains disabled, maximum train length was limited to 9 (r12131)
+-Fix: Use tile index 0 for planes in the air, so it cannot have an invalid tile index [FS#1745] (r12109)
+-Fix: X/Y axis swap for station tiles in GetNearbyTile() was wrong way around [FS#1753]( r12108)
+-Fix: Loading older savegames fixes (r12096,r12097)
+-Fix: When a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road [FS#1703] (r12095)
+-Fix: Do not set station owner for buoys when merging company (r12093)
+-Fix: Keep production level within delimited boundaries, while using var result 0D/0E and than multiplying/dividing it [FS#1755] (r12092)
+-Fix: Assert when loading savegame with wrong tiletype at south map borders (r12088)
+-Fix: Check overrides only for industries when mapping newgrf entities to 'real' entities [FS#1747] (r12086)
+-Fix: Update waypoint signs when changing language (r12080)
+-Fix: Use search paths when opening console scripts (r12079)
+-Fix: When reusing a renamed deleted waypoint, keep the new name (r12076)
+-Fix: Make docks at sea flood neighboured tiles (r12072)
+-Fix: Possible deadlock when there are no houses available to build at given tile (r12062)
+-Fix: Houses with zero probability could be built (r12062)
+-Fix: Do not clear tiles when the town won't be able to build any buildings anyway (r12060)
+-Fix: Allow building 2x2 building on slopes if not explicitly forbidden (r12060)
+-Fix: It was possible to build 2x1 and 1x2 buildings on slopes even if it was not allowed (r12060)
+-Fix: Teach NPF where road vehicles and trams can reverse (r12058)
+-Fix: Ships can drive through opponents' ship depots (r12058)
+-Fix: Slowdown train when approaching 90deg turn when 90deg turns are forbidden (r12057)
+-Fix: Enable YAPF to start searching inside a wormhole [FS#1704] (r12056)
+-Fix: Another way to fix AI trying to build road through depots (r12055)
+-Fix: The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early [FS#1737] (r12052)
+-Fix: Random_func broke for desync debug (r12050)
+-Fix: Memset on multibyte array with wrong byte count (r12049)
+-Fix: Crash when centering on a vehicle (aircraft) that is outside of the map [FS#1741] (r12044)
+-Fix: Allow building transmitters and lighthouses on tree tiles [FS#1736] (r12043)
+-Fix: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
+      stored for buoys, docks, locks and depots. All these are now allowed on rivers and removal of them will revert to the
+      original water type [FS#1676] (r12042)
+-Fix: Change ownership of or remove statues when merging/bankrupting companies (r12038)
+-Fix: For station tiles, only get road types for road stops (r12036)
+-Fix: Teach YAPF where trams can reverse, and where not [FS#1702] (r12035)
+-Fix: Do not show train speed as zero after loading paused game (r12033)
+-Fix: When removing a statue, remove town statue flag for the statue owner, not current player (r12032)
+-Fix: Prevent towns from removing or claiming ownership of player owned tiles when growing [FS#1689,FS#1719] (r12031)
+-Fix: In one case trees could spread under bridges (r12024)
+-Fix: Put a better suited text in the quit-dialog [FS#1690] (r12023)
+-Fix: Restore initial intent on the invisible tree while transparent building patch setting [FS#1721] (r12018)
+-Fix: When you have more than 9 network interfaces you'll enter the wonderfull world of overflows (r12017)
+-Fix: Better work on strings in regard to gender [FS#1716] (r12015)
+-Fix: Lighthouses and transmitters were never supposed to be build on a slope (r12014)
+-Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases (r12013)
+-Fix: Enable TownRatingTestMode during cost estimation with 'shift'-key (r12012)
+-Fix: Do not consider one-corner-raised-shores to be watered tiles from all sides [FS#1701] (r12011)
+-Fix: Avoid loading sample.cat if it 'looks' incorrect, and avoid later null pointer dereferences by moving volume lookup deeper [FS#1707] (r12009)
+-Fix: Possible reading from an invalid pointer [FS#1717] (r12005)
+-Fix: When skipping Action 11 or 12, also skip belonging sprites (r12001)
+-Fix: Do entrance-slope-check for every tile of railstations (r11999)
+-Fix: Possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD [FS#1692] (r11998)
+-Fix: Update train statusbar when stopping from zero speed [FS#1706] (r11996)
+-Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long (r11993)
+-Fix: When building two rail stations close to each other (with control) so they looked like one long track trains would see them as one (r11992)
+-Fix: Resize autoreplace window to fit purchase information text if it is too large (r11989)
+-Fix: Build system ignored changes to table/control_codes.h which require strgen to be rebuilt (r11986)
+-Fix: Also draw corner shores under rail tracks (r11984)
+-Revert(r8738): Now we have shores in corners. No need to remove them from TTDP games (r11982)
+-Fix: Use unicode glyph mapping to fix up missing/shuffled sprites in original data files instead of shuffling or skipping sprites directly [FS#1698] (r11981)
+-Fix: Industries using results 0D/0E on callback cb29/35 were a bit too eager to close down (r11976)
+-Fix: Shore and sea tiles under bridges were converted to canals in old savegames [FS#1684] (r11974)
+-Fix: Use grass tiles for corner shores, if shores got replaced by ActionA [FS#1683] (r11973)
+-Fix: Old AI shouldn't build fast planes with a small airport in orders(r11972)
+-Fix: MP_ROAD can have railbits too - OPF searching over rail of diffen t owner behind crossing (r11967)
+-Fix: OPF was searching through depots and normal road stops [FS#1403, FS#1506] (r11966)
+-Fix: Tropic zone data was returned incorrectly [FS#1685] (r11964)
+-Fix: NewAI couldn't build any road vehicles when there were any tram grfs loaded (r11958)
+-Fix: Disallow building locks and docks on rapids [FS#1675] (r11956)
+-Fix: Do not allow modifying roadbits when other roadtypes would need different foundation (r11953)
+-Fix: Loading of very old savegames was broken (r11951)
+-Fix: Slope detection of bridge ramps.Helps YAPF and Trolly (r11946)
+-Fix: FileExists() failed for non latin paths (win32) (r11945)
+-Fix: Allow building drive-through road/tram stops at road/tram track that has no owner (r11944)
+-Fix: 'BRIDGE_TOO_LOW_FOR_TERRAIN'-check was wrong for steep slopes (r11936)
+-Fix[autoreplace]: Single to dualhead locomotive replacefailed when player had enough money to replace and refit one but not enough to refit the last one as well [FS#1624] (r11929)
+-Fix[autoreplace]: Autoreplace could refit train engines to the wrong cargo type if the old engine had no cargo capacity and the new one had (r11928)
+-Fix: Loading old, pre savegame version 2, savegames (r11925)
+-Fix: AI was reading wrong tile slope while building road bridge (r11917)
+-Fix: set correctly crossing state after train reversal, train leaving crossing, train crash (r11900)
+-Fix: Segmentation faults/wrong frees due uninitialized memory in the AI [FS#1658] (r11887)
+-Fix: Assert when trying to remove rail from a house or industry tile [FS#1663,FS#1665-6-7-8,FS#1680,FS#1686-7-8 FS#1715 FS#1742 FS#1771 FS#1776](r11883)
+-Fix: Crash in MP in vehicle group window if the currently selected group is deleted by another player (r11878)
+-Fix: Another way to crash competitors' train in a station (r11877)
+-Fix: Automatically sending aircraft to depot for autoreplace/renew is now triggered by the correct conditions (r11875)
+-Fix: EngineHasReplacementForPlayer() didn't look in ALL_GROUP (r11872)
+-Fix: Do not update signals after each tile when building/removing a large block of track/signals/station [FS#1074] (r11871)
+-Fix: Slow down train when approaching tile we can't enter in more cases (r11870)
+-Fix: Do not make crossing red when we can't enter it in any case (r11870)
+
 0.6.0-beta3 (2008-01-16)
 ------------------------------------------------------------------------
 -Feature: Replaced fixed size custom name array. Names are now attached to their object directly and there is no limit to the amount of names (r11822)
--- a/docs/landscape.html	Thu Feb 21 22:34:54 2008 +0000
+++ b/docs/landscape.html	Fri Feb 22 00:25:54 2008 +0000
@@ -280,6 +280,11 @@
         <td nowrap valign=top><tt>D</tt>&nbsp; </td>
         <td align=left>on grass with fence and shore or water on the free halftile</td>
        </tr>
+
+       <tr>
+        <td nowrap valign=top><tt>E</tt>&nbsp; </td>
+        <td align=left>higher part on foundation with snow, lower without snow</td>
+       </tr>
       </table>
      </li>
      <li>m5 bit 7 clear: railway track
@@ -908,7 +913,6 @@
     <ul>
      <li>m1: <a href="#OwnershipInfo">owner</a> (for sea, rivers, and coasts normally <tt>11</tt>)</li>
      <li>m3 bits 1..0 : Water class (sea, canal or river)
-     <li>m4: Owner of the water when ship depot</li>
      <li>m4: Random data for canal or river tiles</li>
      <li>m5: tile type:
       <table>
--- a/docs/landscape_grid.html	Thu Feb 21 22:34:54 2008 +0000
+++ b/docs/landscape_grid.html	Fri Feb 22 00:25:54 2008 +0000
@@ -284,7 +284,7 @@
       <td class="bits">-inherit-</td>
       <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
       <td class="bits"><span class="free">OOOO OO</span>XX</td>
-      <td class="bits">XXXX XXXX</td>
+      <td class="bits"><span class="free">OOOO OOOO</span></td>
       <td class="bits">-inherit-</td>
       <td class="bits">XX<span class="free">OO OO</span>XX</td>
       <td class="bits"><span class="free">OOOO OOOO</span></td>
--- a/known-bugs.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/known-bugs.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -15,7 +15,9 @@
 ------------------------------------------------------------------------
 URL: http://bugs.openttd.org
 
-- 1624	Autoreplace refit fails -> crash
+- 1762	Strange Autoreplace behaviour
+- 1711	Gravel and Clay have no worth
+- 1693	Removing road does not reset owner
 - 1549	Timetable + group ID are not backed up with orders
 - 1495	Long vehicles block multistop station
 - 1487	Ending_year is never written to
@@ -23,6 +25,5 @@
 - 1404	Spinner widget interprets one click as many
 - 1264	Autoreplace for multiple NewGRF DMU sets fails
 - 1140	[OSX] Not smooth moving map with touchpad
-- 1074	Large slowdown when building tracks
 - 1072	Text overflows in several windows
 -  119	Clipping problems with vehicles on slopes
--- a/os/debian/changelog	Thu Feb 21 22:34:54 2008 +0000
+++ b/os/debian/changelog	Fri Feb 22 00:25:54 2008 +0000
@@ -1,8 +1,8 @@
-openttd (0.6~svn) unstable; urgency=low
+openttd (0.6.0~beta4) unstable; urgency=low
 
-  * Unreleased SVN version. Versioned to allow normal upgrades to released versions.
+  * New upstream release.
 
- -- Matthijs Kooijman <m.kooijman@student.utwente.nl>  Mon, 26 Feb 2007 21:07:05 +0100
+ -- Matthijs Kooijman <m.kooijman@student.utwente.nl>  Mon, 18 Feb 2008 20:09:29 +0100
 
 openttd (0.6.0~beta3-1) unstable; urgency=low
 
--- a/os/win32/installer/install.nsi	Thu Feb 21 22:34:54 2008 +0000
+++ b/os/win32/installer/install.nsi	Fri Feb 22 00:25:54 2008 +0000
@@ -1,9 +1,9 @@
 !define APPNAME "OpenTTD"   ; Define application name
 !define APPVERSION "0.6.0"  ; Define application version
-!define INSTALLERVERSION 41 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
+!define INSTALLERVERSION 42 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
 
 !define APPURLLINK "http://www.openttd.org"
-!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}-beta3"
+!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}-beta4"
 !define APPVERSIONINTERNAL "${APPVERSION}.0" ; Needs to be of the format X.X.X.X
 
 !define MUI_ICON "..\..\..\media\openttd.ico"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/projects/generate.vbs	Fri Feb 22 00:25:54 2008 +0000
@@ -0,0 +1,182 @@
+Option Explicit
+
+Dim FSO
+Set FSO = CreateObject("Scripting.FileSystemObject")
+
+' openttd_vs90.sln    is for MSVC 2008
+' openttd_vs90.vcproj is for MSVC 2008
+' langs_vs90.vcproj   is for MSVC 2008
+' strgen_vs90.vcproj  is for MSVC 2008
+
+' openttd_vs80.sln    is for MSVC 2005
+' openttd_vs80.vcproj is for MSVC 2005
+' langs_vs80.vcproj   is for MSVC 2005
+' strgen_vs80.vcproj  is for MSVC 2005
+
+Sub safety_check(filename)
+	Dim file, line, regexp, list
+
+	' Define regexp
+	Set regexp = New RegExp
+	regexp.Pattern = "#|ottdres.rc|win32.cpp|win32_v.cpp"
+	regexp.Global = True
+
+	' We use a dictionary to check duplicates
+	Set list = CreateObject("Scripting.Dictionary")
+
+	Set file = FSO.OpenTextFile(filename, 1, 0, 0)
+	While Not file.AtEndOfStream
+		line = Replace(file.ReadLine, Chr(9), "") ' Remove tabs
+		If Len(line) > 0 And Not regexp.Test(line) Then
+			line = FSO.GetFileName(line)
+			if list.Exists(line) Then
+				WScript.Echo " !! ERROR !!" _
+				& vbCrLf & "" _
+				& vbCrLf & "The filename '" & line & "' is already used in this project." _
+				& vbCrLf & "Because MSVC uses one single directory for all object files, it" _
+				& vbCrLf & "cannot handle filenames with the same name inside the same project." _
+				& vbCrLf & "Please rename either one of the file and try generating again." _
+				& vbCrLf & "" _
+				& vbCrLf & " !! ERROR !!"
+				WScript.Quit(1)
+			End If
+			list.Add line, line
+		End If
+	Wend
+	file.Close
+End Sub
+
+Function load_main_data(filename)
+	Dim res, file, line, deep, skip, first_time
+	res = ""
+	' Read the source.list and process it
+	Set file = FSO.OpenTextFile(filename, 1, 0, 0)
+	While Not file.AtEndOfStream
+		line = Replace(file.ReadLine, Chr(9), "") ' Remove tabs
+		If Len(line) > 0 Then
+			Select Case Split(line, " ")(0)
+				Case "#end"
+					If deep = skip Then skip = skip - 1
+					deep = deep - 1
+				Case "#else"
+					If deep = skip Then
+						skip = skip - 1
+					ElseIf deep - 1 = skip Then
+						skip = skip + 1
+					End If
+				Case "#if"
+					line = Replace(line, "#if ", "")
+					If deep = skip And ( _
+						line = "SDL" Or _
+						line = "PNG" Or _
+						line = "WIN32" Or _
+						line = "MSVC" Or _
+						line = "DIRECTMUSIC" _
+					) Then skip = skip + 1
+					deep = deep + 1
+				Case "#"
+					if deep = skip Then
+						line = Replace(line, "# ", "")
+						if first_time <> 0 Then
+							res = res & "		</Filter>" & vbCrLf
+						Else
+							first_time = 1
+						End If
+						res = res & _
+						"		<Filter" & vbCrLf & _
+						"			Name=" & Chr(34) & line & Chr(34) & vbCrLf & _
+						"			>" & vbCrLf
+					End If
+				Case Else
+					If deep = skip Then
+						line = Replace(line, "/" ,"\")
+						res = res & _
+						"			<File" & vbCrLf & _
+						"				RelativePath=" & Chr(34) & ".\..\src\" & line & Chr(34) & vbCrLf & _
+						"				>" & vbCrLf & _
+						"			</File>" & vbCrLf
+					End If
+			End Select
+		End If
+	Wend
+	res = res & "		</Filter>"
+	file.Close()
+	load_main_data = res
+End Function
+
+Function load_lang_data(dir)
+	Dim res, folder, file
+	res = ""
+	Set folder = FSO.GetFolder(dir)
+	For Each file In folder.Files
+		file = FSO.GetFileName(file)
+		If FSO.GetExtensionName(file) = "txt" Then
+			file = Left(file, Len(file) - 4)
+			res = res _
+			& vbCrLf & "		<File" _
+			& vbCrLf & "			RelativePath=" & Chr(34) & "..\src\lang\" & file & ".txt" & Chr(34) _
+			& vbCrLf & "			>" _
+			& vbCrLf & "			<FileConfiguration" _
+			& vbCrLf & "				Name=" & Chr(34) & "Debug|Win32" & Chr(34) _
+			& vbCrLf & "				>" _
+			& vbCrLf & "				<Tool" _
+			& vbCrLf & "					Name=" & Chr(34) & "VCCustomBuildTool" & Chr(34) _
+			& vbCrLf & "					Description=" & Chr(34) & "Generating " & file & " language file" & Chr(34) _
+			& vbCrLf & "					CommandLine=" & Chr(34) & "..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;" & Chr(34) _
+			& vbCrLf & "					AdditionalDependencies=" & Chr(34) & Chr(34) _
+			& vbCrLf & "					Outputs=" & Chr(34) & "..\bin\lang\" & file & ".lng" & Chr(34) _
+			& vbCrLf & "				/>" _
+			& vbCrLf & "			</FileConfiguration>" _
+			& vbCrLf & "		</File>"
+		End If
+	Next
+	load_lang_data = res
+End Function
+
+Sub generate(data, dest)
+	Dim srcfile, destfile, line
+	WScript.Echo "Generating " & FSO.GetFileName(dest) & "..."
+	Set srcfile = FSO.OpenTextFile(dest & ".in", 1, 0, 0)
+	Set destfile = FSO.CreateTextFile(dest, -1, 0)
+
+	' Everything above the !!FILES!! marker
+	line = srcfile.ReadLine()
+	While line <> "!!FILES!!"
+		If len(line) > 0 Then destfile.WriteLine(line)
+		line = srcfile.ReadLine()
+	Wend
+
+	' Our generated content
+	destfile.WriteLine(data)
+
+	' Everything below the !!FILES!! marker
+	While Not srcfile.AtEndOfStream
+		line = srcfile.ReadLine()
+		If len(line) > 0 Then destfile.WriteLine(line)
+	Wend
+	srcfile.Close()
+	destfile.Close()
+End Sub
+
+Dim ROOT_DIR
+ROOT_DIR = FSO.GetFolder("..").Path
+If Not FSO.FileExists(ROOT_DIR & "/source.list") Then
+	ROOT_DIR = FSO.GetFolder(".").Path
+End If
+If Not FSO.FileExists(ROOT_DIR & "/source.list") Then
+	WScript.Echo "Can't find source.list, needed in order to make this run." _
+	& vbCrLf & "Please go to either the project dir, or the root dir of a clean SVN checkout."
+	WScript.Quit(1)
+End If
+
+safety_check ROOT_DIR & "/source.list"
+
+Dim openttd
+openttd = load_main_data(ROOT_DIR &"/source.list")
+generate openttd, ROOT_DIR & "/projects/openttd_vs80.vcproj"
+generate openttd, ROOT_DIR & "/projects/openttd_vs90.vcproj"
+
+Dim lang
+lang = load_lang_data(ROOT_DIR & "/src/lang")
+generate lang, ROOT_DIR & "/projects/langs_vs80.vcproj"
+generate lang, ROOT_DIR & "/projects/langs_vs90.vcproj"
--- a/projects/openttd_vs80.vcproj	Thu Feb 21 22:34:54 2008 +0000
+++ b/projects/openttd_vs80.vcproj	Fri Feb 22 00:25:54 2008 +0000
@@ -456,6 +456,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\alloc_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\articulated_vehicles.cpp"
 				>
 			</File>
@@ -468,6 +472,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\bmp.cpp"
 				>
 			</File>
@@ -496,14 +504,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\core\bitmath_func.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\core\random_func.cpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\currency.cpp"
 				>
 			</File>
@@ -528,6 +528,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\widgets\dropdown.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\economy.cpp"
 				>
 			</File>
@@ -668,6 +672,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\random_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\rev.cpp"
 				>
 			</File>
@@ -760,10 +768,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\widgets\dropdown.cpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\win32.cpp"
 				>
 			</File>
@@ -788,10 +792,30 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\alloc_func.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\articulated_vehicles.h"
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\autoreplace_base.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\autoreplace_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\autoreplace_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\autoreplace_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\autoslope.h"
 				>
 			</File>
@@ -800,10 +824,26 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\bmp.h"
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\bridge.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\callback_table.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\cargo_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\cargopacket.h"
 				>
 			</File>
@@ -812,7 +852,15 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\command.h"
+				RelativePath=".\..\src\cmd_helper.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\command_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\command_type.h"
 				>
 			</File>
 			<File
@@ -820,23 +868,15 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\core\bitmath_func.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\core\math_func.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\core\random_func.hpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\currency.h"
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\date.h"
+				RelativePath=".\..\src\date_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\date_type.h"
 				>
 			</File>
 			<File
@@ -852,7 +892,11 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\direction.h"
+				RelativePath=".\..\src\direction_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\direction_type.h"
 				>
 			</File>
 			<File
@@ -864,7 +908,23 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\economy.h"
+				RelativePath=".\..\src\widgets\dropdown_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\widgets\dropdown_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\economy_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\economy_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\core\endian_func.hpp"
 				>
 			</File>
 			<File
@@ -872,6 +932,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\enum_type.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\fileio.h"
 				>
 			</File>
@@ -892,7 +956,15 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\gfx.h"
+				RelativePath=".\..\src\core\geometry_type.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\gfx_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\gfx_type.h"
 				>
 			</File>
 			<File
@@ -904,6 +976,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\group_gui.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\gui.h"
 				>
 			</File>
@@ -916,6 +992,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\industry_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\landscape.h"
 				>
 			</File>
@@ -924,7 +1004,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\map.h"
+				RelativePath=".\..\src\core\math_func.hpp"
 				>
 			</File>
 			<File
@@ -960,6 +1040,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\network\network_internal.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\network\network_server.h"
 				>
 			</File>
@@ -996,6 +1080,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\newgrf_generic.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\newgrf_house.h"
 				>
 			</File>
@@ -1064,11 +1152,19 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\order.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\core\overflowsafe_type.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\pathfind.h"
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\player.h"
+				RelativePath=".\..\src\player_base.h"
 				>
 			</File>
 			<File
@@ -1076,6 +1172,18 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\player_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\player_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\player_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\queue.h"
 				>
 			</File>
@@ -1084,10 +1192,42 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\rail_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\rail_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\core\random_func.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\road_cmd.h"
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\road_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\road_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\road_internal.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\road_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\roadveh.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\saveload.h"
 				>
 			</File>
@@ -1120,7 +1260,23 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\settings.h"
+				RelativePath=".\..\src\settings_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\settings_internal.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\settings_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ship.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\signal_func.h"
 				>
 			</File>
 			<File
@@ -1128,15 +1284,19 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\signal_func.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\slope.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\sound.h"
+				RelativePath=".\..\src\slope_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\slope_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\sound_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\sound_type.h"
 				>
 			</File>
 			<File
@@ -1160,7 +1320,27 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\string.h"
+				RelativePath=".\..\src\string_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\string_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\strings_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\strings_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\terraform_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\textbuf_gui.h"
 				>
 			</File>
 			<File
@@ -1176,7 +1356,11 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\tile.h"
+				RelativePath=".\..\src\tile_cmd.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\tile_type.h"
 				>
 			</File>
 			<File
@@ -1188,6 +1372,18 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\town_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\track_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\track_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\train.h"
 				>
 			</File>
@@ -1204,11 +1400,19 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\unmovable.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\variables.h"
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\vehicle.h"
+				RelativePath=".\..\src\vehicle_base.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\vehicle_func.h"
 				>
 			</File>
 			<File
@@ -1216,7 +1420,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\viewport.h"
+				RelativePath=".\..\src\vehicle_type.h"
 				>
 			</File>
 			<File
@@ -1236,23 +1440,23 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\window.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\widgets\dropdown.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\widgets\dropdown_type.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\widgets\dropdown_func.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\zoom.hpp"
+				RelativePath=".\..\src\window_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\window_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\window_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\zoom_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\zoom_type.h"
 				>
 			</File>
 		</Filter>
@@ -1552,7 +1756,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\table\roadveh.h"
+				RelativePath=".\..\src\table\roadveh_movement.h"
 				>
 			</File>
 			<File
@@ -1687,370 +1891,6 @@
 				RelativePath=".\..\src\ai\ai.h"
 				>
 			</File>
-			<File
-				RelativePath=".\..\src\ai\ai_factory.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\ai_squirrel.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\ai_squirrel.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\ai_threads.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\ai_threads.h"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="AI C++"
-			>
-			<File
-				RelativePath=".\..\src\ai\NoAI\NoAI.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\NoAI\NoAI.hpp"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="AI API"
-			>
-			<File
-				RelativePath=".\..\src\ai\api\ai_abstractlist.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_accounting.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_airport.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_base.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_cargo.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_company.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_controller.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_engine.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_enginelist.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_enginelist_valuator.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_event.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_event_types.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_execmode.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_industry.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_industrylist.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_industrylist_valuator.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_list.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_list_valuator.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_map.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_marine.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_object.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_order.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_pathfinder.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_pathfinder_stupid.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_road.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_settings.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_sign.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_station.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_stationlist.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_stationlist_valuator.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_testmode.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_tile.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_tilelist.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_tilelist_valuator.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_town.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_townlist.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_townlist_valuator.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_transactionmode.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_vehicle.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_vehiclelist.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_vehiclelist_valuator.hpp"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="AI API Implementation"
-			>
-			<File
-				RelativePath=".\..\src\ai\api\ai_abstractlist.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_accounting.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_airport.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_base.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_cargo.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_company.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_controller.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_engine.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_enginelist.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_enginelist_valuator.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_event.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_event_types.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_execmode.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_industry.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_industrylist.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_industrylist_valuator.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_list.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_list_valuator.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_map.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_marine.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_object.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_order.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_pathfinder_stupid.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_road.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_settings.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_sign.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_station.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_stationlist.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_stationlist_valuator.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_testmode.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_tile.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_tilelist.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_tilelist_valuator.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_town.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_townlist.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_townlist_valuator.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_transactionmode.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_vehicle.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_vehiclelist.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\api\ai_vehiclelist_valuator.cpp"
-				>
-			</File>
 		</Filter>
 		<Filter
 			Name="Blitters"
@@ -2204,6 +2044,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\newgrf_generic.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\newgrf_house.cpp"
 				>
 			</File>
@@ -2280,6 +2124,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\tile_map.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\town_map.h"
 				>
 			</File>
--- a/projects/openttd_vs90.vcproj	Thu Feb 21 22:34:54 2008 +0000
+++ b/projects/openttd_vs90.vcproj	Fri Feb 22 00:25:54 2008 +0000
@@ -453,6 +453,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\alloc_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\articulated_vehicles.cpp"
 				>
 			</File>
@@ -465,6 +469,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\bmp.cpp"
 				>
 			</File>
@@ -493,14 +501,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\core\bitmath_func.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\core\random_func.cpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\currency.cpp"
 				>
 			</File>
@@ -525,6 +525,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\widgets\dropdown.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\economy.cpp"
 				>
 			</File>
@@ -665,6 +669,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\random_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\rev.cpp"
 				>
 			</File>
@@ -717,6 +725,14 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\squirrel.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\squirrel_std.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\texteff.cpp"
 				>
 			</File>
@@ -749,10 +765,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\widgets\dropdown.cpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\win32.cpp"
 				>
 			</File>
@@ -777,10 +789,30 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\alloc_func.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\articulated_vehicles.h"
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\autoreplace_base.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\autoreplace_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\autoreplace_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\autoreplace_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\autoslope.h"
 				>
 			</File>
@@ -789,10 +821,26 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\bitmath_func.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\bmp.h"
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\bridge.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\callback_table.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\cargo_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\cargopacket.h"
 				>
 			</File>
@@ -801,7 +849,15 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\command.h"
+				RelativePath=".\..\src\cmd_helper.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\command_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\command_type.h"
 				>
 			</File>
 			<File
@@ -809,23 +865,15 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\core\bitmath_func.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\core\math_func.hpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\core\random_func.hpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\currency.h"
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\date.h"
+				RelativePath=".\..\src\date_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\date_type.h"
 				>
 			</File>
 			<File
@@ -841,7 +889,11 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\direction.h"
+				RelativePath=".\..\src\direction_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\direction_type.h"
 				>
 			</File>
 			<File
@@ -853,7 +905,23 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\economy.h"
+				RelativePath=".\..\src\widgets\dropdown_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\widgets\dropdown_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\economy_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\economy_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\core\endian_func.hpp"
 				>
 			</File>
 			<File
@@ -861,6 +929,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\core\enum_type.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\fileio.h"
 				>
 			</File>
@@ -881,7 +953,15 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\gfx.h"
+				RelativePath=".\..\src\core\geometry_type.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\gfx_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\gfx_type.h"
 				>
 			</File>
 			<File
@@ -893,6 +973,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\group_gui.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\gui.h"
 				>
 			</File>
@@ -905,6 +989,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\industry_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\landscape.h"
 				>
 			</File>
@@ -913,7 +1001,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\map.h"
+				RelativePath=".\..\src\core\math_func.hpp"
 				>
 			</File>
 			<File
@@ -949,6 +1037,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\network\network_internal.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\network\network_server.h"
 				>
 			</File>
@@ -985,6 +1077,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\newgrf_generic.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\newgrf_house.h"
 				>
 			</File>
@@ -1053,11 +1149,19 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\order.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\core\overflowsafe_type.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\pathfind.h"
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\player.h"
+				RelativePath=".\..\src\player_base.h"
 				>
 			</File>
 			<File
@@ -1065,6 +1169,18 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\player_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\player_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\player_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\queue.h"
 				>
 			</File>
@@ -1073,10 +1189,42 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\rail_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\rail_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\core\random_func.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\road_cmd.h"
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\road_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\road_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\road_internal.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\road_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\roadveh.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\saveload.h"
 				>
 			</File>
@@ -1089,11 +1237,43 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\squirrel.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\squirrel_class.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\squirrel_helper.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\squirrel_std.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\video\sdl_v.h"
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\settings.h"
+				RelativePath=".\..\src\settings_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\settings_internal.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\settings_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ship.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\signal_func.h"
 				>
 			</File>
 			<File
@@ -1101,15 +1281,19 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\signal_func.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\slope.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\sound.h"
+				RelativePath=".\..\src\slope_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\slope_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\sound_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\sound_type.h"
 				>
 			</File>
 			<File
@@ -1133,7 +1317,27 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\string.h"
+				RelativePath=".\..\src\string_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\string_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\strings_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\strings_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\terraform_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\textbuf_gui.h"
 				>
 			</File>
 			<File
@@ -1149,7 +1353,11 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\tile.h"
+				RelativePath=".\..\src\tile_cmd.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\tile_type.h"
 				>
 			</File>
 			<File
@@ -1161,6 +1369,18 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\town_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\track_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\track_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\train.h"
 				>
 			</File>
@@ -1177,11 +1397,19 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\unmovable.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\variables.h"
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\vehicle.h"
+				RelativePath=".\..\src\vehicle_base.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\vehicle_func.h"
 				>
 			</File>
 			<File
@@ -1189,7 +1417,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\viewport.h"
+				RelativePath=".\..\src\vehicle_type.h"
 				>
 			</File>
 			<File
@@ -1209,23 +1437,23 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\window.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\widgets\dropdown.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\widgets\dropdown_type.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\widgets\dropdown_func.h"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\zoom.hpp"
+				RelativePath=".\..\src\window_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\window_gui.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\window_type.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\zoom_func.h"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\zoom_type.h"
 				>
 			</File>
 		</Filter>
@@ -1525,7 +1753,7 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\table\roadveh.h"
+				RelativePath=".\..\src\table\roadveh_movement.h"
 				>
 			</File>
 			<File
@@ -1566,30 +1794,98 @@
 			</File>
 		</Filter>
 		<Filter
-			Name="AI Files"
+			Name="Squirrel"
+			>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqapi.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqbaselib.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqclass.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqcompiler.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqdebug.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqfuncstate.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqlexer.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqmem.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqobject.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstate.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqtable.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqvm.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdaux.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdblob.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdio.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdmath.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdrex.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdstream.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdstring.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdsystem.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="AI Core"
 			>
 			<File
 				RelativePath=".\..\src\ai\ai.cpp"
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\ai\trolly\build.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\default\default.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\trolly\pathfinder.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\trolly\shared.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\..\src\ai\trolly\trolly.cpp"
+				RelativePath=".\..\src\ai\ai.h"
 				>
 			</File>
 		</Filter>
@@ -1745,6 +2041,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\newgrf_generic.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\newgrf_house.cpp"
 				>
 			</File>
@@ -1821,6 +2121,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\tile_map.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\town_map.h"
 				>
 			</File>
@@ -1877,6 +2181,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\misc\countedobj.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\misc\countedptr.hpp"
 				>
 			</File>
--- a/projects/strgen_vs80.vcproj	Thu Feb 21 22:34:54 2008 +0000
+++ b/projects/strgen_vs80.vcproj	Fri Feb 22 00:25:54 2008 +0000
@@ -113,6 +113,10 @@
 			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
 			>
 			<File
+				RelativePath="..\src\core\alloc_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\src\strgen\strgen.cpp"
 				>
 			</File>
@@ -122,7 +126,19 @@
 			</File>
 		</Filter>
 		<File
-			RelativePath="..\src\macros.h"
+			RelativePath="..\src\core\alloc_func.hpp"
+			>
+		</File>
+		<File
+			RelativePath="..\src\table\control_codes.h"
+			>
+		</File>
+		<File
+			RelativePath="..\src\debug.h"
+			>
+		</File>
+		<File
+			RelativePath="..\src\core\endian_func.hpp"
 			>
 		</File>
 		<File
--- a/projects/strgen_vs90.vcproj	Thu Feb 21 22:34:54 2008 +0000
+++ b/projects/strgen_vs90.vcproj	Fri Feb 22 00:25:54 2008 +0000
@@ -113,6 +113,10 @@
 			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
 			>
 			<File
+				RelativePath="..\src\core\alloc_func.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\src\strgen\strgen.cpp"
 				>
 			</File>
@@ -122,7 +126,19 @@
 			</File>
 		</Filter>
 		<File
-			RelativePath="..\src\macros.h"
+			RelativePath="..\src\core\alloc_func.hpp"
+			>
+		</File>
+		<File
+			RelativePath="..\src\table\control_codes.h"
+			>
+		</File>
+		<File
+			RelativePath="..\src\debug.h"
+			>
+		</File>
+		<File
+			RelativePath="..\src\core\endian_func.hpp"
 			>
 		</File>
 		<File
--- a/readme.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/readme.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1,6 +1,6 @@
 OpenTTD README
-Last updated:    2008-01-16
-Release version: 0.6.0-beta3
+Last updated:    2008-02-18
+Release version: 0.6.0-beta4
 ------------------------------------------------------------------------
 
 
@@ -285,6 +285,7 @@
   Bjarni Corfitzen (Bjarni)      - MacOSX port, coder and vehicles
   Matthijs Kooijman (blathijs)   - Pathfinder-guru, pool rework
   Loïc Guilloux (glx)            - General coding
+  Christoph Elsenhans (frosch)   - 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
--- a/source.list	Thu Feb 21 22:34:54 2008 +0000
+++ b/source.list	Fri Feb 22 00:25:54 2008 +0000
@@ -1,8 +1,10 @@
 # Source Files
 airport.cpp
+core/alloc_func.cpp
 articulated_vehicles.cpp
 autoreplace_cmd.cpp
 aystar.cpp
+core/bitmath_func.cpp
 bmp.cpp
 callback_table.cpp
 cargopacket.cpp
@@ -10,14 +12,13 @@
 command.cpp
 console.cpp
 console_cmds.cpp
-core/bitmath_func.cpp
-core/random_func.cpp
 currency.cpp
 date.cpp
 debug.cpp
 dedicated.cpp
 depot.cpp
 driver.cpp
+widgets/dropdown.cpp
 economy.cpp
 elrail.cpp
 engine.cpp
@@ -58,6 +59,7 @@
 players.cpp
 queue.cpp
 rail.cpp
+core/random_func.cpp
 rev.cpp
 road.cpp
 saveload.cpp
@@ -95,7 +97,6 @@
 viewport.cpp
 waypoint.cpp
 widget.cpp
-widgets/dropdown.cpp
 #if WIN32
 	win32.cpp
 #end
@@ -105,41 +106,60 @@
 aircraft.h
 airport.h
 airport_movement.h
+core/alloc_func.hpp
 articulated_vehicles.h
+autoreplace_base.h
+autoreplace_func.h
+autoreplace_gui.h
+autoreplace_type.h
 autoslope.h
 aystar.h
+core/bitmath_func.hpp
 bmp.h
+bridge.h
+callback_table.h
+cargo_type.h
 cargopacket.h
 cargotype.h
-command.h
+cmd_helper.h
+command_func.h
+command_type.h
 console.h
-core/bitmath_func.hpp
-core/math_func.hpp
-core/random_func.hpp
 currency.h
-date.h
+date_func.h
+date_type.h
 debug.h
 video/dedicated_v.h
 depot.h
-direction.h
+direction_func.h
+direction_type.h
 music/dmusic.h
 driver.h
-economy.h
+widgets/dropdown_func.h
+widgets/dropdown_type.h
+economy_func.h
+economy_type.h
+core/endian_func.hpp
 engine.h
+core/enum_type.hpp
 fileio.h
 fios.h
 fontcache.h
 functions.h
 genworld.h
-gfx.h
+core/geometry_type.hpp
+gfx_func.h
+gfx_type.h
 gfxinit.h
 group.h
+group_gui.h
 gui.h
 heightmap.h
 industry.h
+industry_type.h
 landscape.h
 livery.h
-map.h
+core/math_func.hpp
 md5.h
 mixer.h
 music.h
@@ -148,6 +168,7 @@
 network/network_data.h
 network/network_gamelist.h
 network/network_gui.h
+network/network_internal.h
 network/network_server.h
 network/network_udp.h
 newgrf.h
@@ -157,6 +178,7 @@
 newgrf_commons.h
 newgrf_config.h
 newgrf_engine.h
+newgrf_generic.h
 newgrf_house.h
 newgrf_industries.h
 newgrf_industrytiles.h
@@ -174,12 +196,25 @@
 video/null_v.h
 oldpool.h
 openttd.h
+order.h
+core/overflowsafe_type.hpp
 pathfind.h
-player.h
+player_base.h
 player_face.h
+player_func.h
+player_gui.h
+player_type.h
 queue.h
 rail.h
+rail_gui.h
+rail_type.h
+core/random_func.hpp
 road_cmd.h
+road_func.h
+road_gui.h
+road_internal.h
+road_type.h
+roadveh.h
 saveload.h
 screenshot.h
 sound/sdl_s.h
@@ -188,40 +223,56 @@
 squirrel_helper.hpp
 squirrel_std.hpp
 video/sdl_v.h
-settings.h
+settings_func.h
+settings_internal.h
+settings_type.h
+ship.h
+signal_func.h
 signs.h
-signal_func.h
-slope.h
-sound.h
+slope_func.h
+slope_type.h
+sound_func.h
+sound_type.h
 sprite.h
 spritecache.h
 station.h
 station_gui.h
 stdafx.h
-string.h
+string_func.h
+string_type.h
+strings_func.h
+strings_type.h
+terraform_gui.h
+textbuf_gui.h
 texteff.hpp
 tgp.h
 thread.h
-tile.h
+tile_cmd.h
+tile_type.h
 timetable.h
 town.h
+town_type.h
+track_func.h
+track_type.h
 train.h
 transparency.h
 transparency_gui.h
 tunnelbridge.h
+unmovable.h
 variables.h
-vehicle.h
+vehicle_base.h
+vehicle_func.h
 vehicle_gui.h
-viewport.h
+vehicle_type.h
 waypoint.h
 music/win32_m.h
 sound/win32_s.h
 video/win32_v.h
-window.h
-widgets/dropdown.h
-widgets/dropdown_type.h
-widgets/dropdown_func.h
-zoom.hpp
+window_func.h
+window_gui.h
+window_type.h
+zoom_func.h
+zoom_type.h
 
 # GUI Source Code
 aircraft_gui.cpp
@@ -299,7 +350,7 @@
 table/namegen.h
 table/palettes.h
 table/road_land.h
-table/roadveh.h
+table/roadveh_movement.h
 table/sprites.h
 table/station_land.h
 ../objs/langs/table/strings.h
@@ -475,6 +526,7 @@
 newgrf_commons.cpp
 newgrf_config.cpp
 newgrf_engine.cpp
+newgrf_generic.cpp
 newgrf_house.cpp
 newgrf_industries.cpp
 newgrf_industrytiles.cpp
@@ -495,6 +547,7 @@
 road_map.cpp
 road_map.h
 station_map.h
+tile_map.h
 town_map.h
 tree_map.h
 tunnel_map.cpp
--- a/src/ai/api/ai_airport.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/ai/api/ai_airport.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -44,7 +44,7 @@
 /* static */ int32 AIAirport::GetAirportCoverageRadius(AirportType type)
 {
 	if (type > AT_HELISTATION) return 0;
-	return _patches.modified_catchment ? GetAirport(type)->catchment : 4;
+	return _patches.modified_catchment ? GetAirport(type)->catchment : (uint)CA_UNMODIFIED;
 }
 
 bool AIAirport::BuildAirport(TileIndex tile, AirportType type)
--- a/src/ai/api/ai_enginelist.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/ai/api/ai_enginelist.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -4,7 +4,7 @@
 AIEngineList::AIEngineList(AIVehicle::VehicleType type)
 {
 	EngineID e;
-	FOR_ALL_ENGINEIDS_OF_TYPE(e, type) {
+	FOR_ALL_ENGINEIDS_OF_TYPE(e, (::VehicleType)type) {
 		this->AddItem(e);
 	}
 }
--- a/src/ai/api/ai_station.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/ai/api/ai_station.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -66,7 +66,7 @@
 		DEBUG(ai, 0, "GetCoverageRadius(): coverage radius of airports needs to be requested via AIAirport::GetAirportCoverageRadius(), as it requires AirportType");
 		return 0;
 	}
-	if (!_patches.modified_catchment) return 4;
+	if (!_patches.modified_catchment) return CA_UNMODIFIED;
 
 	switch (type) {
 		case STATION_TRAIN:      return CA_TRAIN;
--- a/src/ai/api/ai_tile.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/ai/api/ai_tile.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -56,7 +56,7 @@
 	if (tile >= ::MapSize()) return 0;
 
 	AcceptedCargo accepts;
-	GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? rad : 4);
+	GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? rad : (uint)CA_UNMODIFIED);
 	return accepts[cargo_type];
 }
 
@@ -66,7 +66,7 @@
 	if (tile >= ::MapSize()) return 0;
 
 	AcceptedCargo produced;
-	GetProductionAroundTiles(produced, tile, width, height, _patches.modified_catchment ? rad : 4);
+	GetProductionAroundTiles(produced, tile, width, height, _patches.modified_catchment ? rad : (uint)CA_UNMODIFIED);
 	return produced[cargo_type];
 }
 
--- a/src/ai/api/ai_vehicle.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/ai/api/ai_vehicle.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -189,14 +189,14 @@
 {
 	if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
 
-	return ::GetVehicle(vehicle_id)->profit_this_year;
+	return ::GetVehicle(vehicle_id)->GetDisplayProfitThisYear();
 }
 
 /* static */ int32 AIVehicle::GetProfitLastYear(VehicleID vehicle_id)
 {
 	if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
 
-	return ::GetVehicle(vehicle_id)->profit_last_year;
+	return ::GetVehicle(vehicle_id)->GetDisplayProfitLastYear();
 }
 
 /* static */ AIVehicle::VehicleType AIVehicle::GetVehicleType(VehicleID vehicle_id)
--- a/src/aircraft_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/aircraft_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -322,6 +322,8 @@
 		u->z_pos = GetSlopeZ(x, y);
 		v->z_pos = u->z_pos + 1;
 
+		v->running_ticks = 0;
+
 //		u->delta_x = u->delta_y = 0;
 
 		v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
@@ -736,11 +738,12 @@
 	AgeVehicle(this);
 	CheckIfAircraftNeedsService(this);
 
-	if (this->vehstatus & VS_STOPPED) return;
+	if (this->running_ticks == 0) return;
 
-	CommandCost cost = CommandCost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running / 364);
+	CommandCost cost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running * this->running_ticks / (364 * DAY_TICKS));
 
-	this->profit_this_year -= cost.GetCost() >> 8;
+	this->profit_this_year -= cost.GetCost();
+	this->running_ticks = 0;
 
 	SubtractMoneyFromPlayerFract(this->owner, cost);
 
@@ -931,7 +934,13 @@
 
 	v->subspeed = (t=v->subspeed) + (byte)spd;
 
-	if (!hard_limit && v->cur_speed > speed_limit) speed_limit = v->cur_speed - (v->cur_speed / 48);
+	/* Aircraft's current speed is used twice so that very fast planes are
+	 * forced to slow down rapidly in the short distance needed. The magic
+	 * value 16384 was determined to give similar results to the old speed/48
+	 * method at slower speeds. This also results in less reduction at slow
+	 * speeds to that aircraft do not get to taxi speed straight after
+	 * touchdown. */
+	if (!hard_limit && v->cur_speed > speed_limit) speed_limit = v->cur_speed - max(1, (v->cur_speed * v->cur_speed) / 16384);
 
 	spd = min(v->cur_speed + (spd >> 8) + (v->subspeed < t), speed_limit);
 
@@ -1195,7 +1204,7 @@
 
 		v->tile = gp.new_tile;
 		/* If vehicle is in the air, use tile coordinate 0. */
-		// if (amd->flag & (AMED_TAKEOFF | AMED_SLOWTURN | AMED_LAND)) v->tile = 0;
+		if (amd->flag & (AMED_TAKEOFF | AMED_SLOWTURN | AMED_LAND)) v->tile = 0;
 
 		/* Adjust Z for land or takeoff? */
 		uint z = v->z_pos;
@@ -2149,6 +2158,8 @@
 {
 	if (!IsNormalAircraft(this)) return;
 
+	if (!(this->vehstatus & VS_STOPPED)) this->running_ticks++;
+
 	if (this->subtype == AIR_HELICOPTER) HelicopterTickHandler(this);
 
 	AgeAircraftCargo(this);
--- a/src/airport_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/airport_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -179,7 +179,7 @@
 		airport = GetAirport(_selected_airport_type);
 		SetTileSelectSize(airport->size_x, airport->size_y);
 
-		int rad = _patches.modified_catchment ? airport->catchment : 4;
+		int rad = _patches.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
 
 		if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 
--- a/src/articulated_vehicles.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/articulated_vehicles.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -34,6 +34,42 @@
 	return i - 1;
 }
 
+
+uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
+{
+	static uint16 capacity[NUM_CARGO];
+	memset(capacity, 0, sizeof(capacity));
+
+	if (type == VEH_TRAIN) {
+		const RailVehicleInfo *rvi = RailVehInfo(engine);
+		capacity[rvi->cargo_type] = rvi->capacity;
+		if (rvi->railveh_type == RAILVEH_MULTIHEAD) capacity[rvi->cargo_type] += rvi->capacity;
+	} else if (type == VEH_ROAD) {
+		const RoadVehicleInfo *rvi = RoadVehInfo(engine);
+		capacity[rvi->cargo_type] = rvi->capacity;
+	}
+
+	if (!HasBit(EngInfo(engine)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return capacity;
+
+	for (uint i = 1; i < MAX_UVALUE(EngineID); i++) {
+		uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
+		if (callback == CALLBACK_FAILED || callback == 0xFF) break;
+
+		EngineID artic_engine = GetFirstEngineOfType(type) + GB(callback, 0, 7);
+
+		if (type == VEH_TRAIN) {
+			const RailVehicleInfo *rvi = RailVehInfo(artic_engine);
+			capacity[rvi->cargo_type] += GetEngineProperty(artic_engine, 0x14, rvi->capacity);
+		} else if (type == VEH_ROAD) {
+			const RoadVehicleInfo *rvi = RoadVehInfo(artic_engine);
+			capacity[rvi->cargo_type] += GetEngineProperty(artic_engine, 0x0F, rvi->capacity);
+		}
+	}
+
+	return capacity;
+}
+
+
 void AddArticulatedParts(Vehicle **vl, VehicleType type)
 {
 	const Vehicle *v = vl[0];
--- a/src/articulated_vehicles.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/articulated_vehicles.h	Fri Feb 22 00:25:54 2008 +0000
@@ -8,6 +8,7 @@
 #include "vehicle_type.h"
 
 uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
+uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type);
 void AddArticulatedParts(Vehicle **vl, VehicleType type);
 
 #endif /* ARTICULATED_VEHICLES_H */
--- a/src/autoreplace_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/autoreplace_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -80,7 +80,7 @@
 void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
 {
 	Player *p = GetPlayer(_local_player);
-	byte type = GetEngine(e)->type;
+	VehicleType type = GetEngine(e)->type;
 	uint num_engines = GetGroupNumEngines(_local_player, id_g, e);
 
 	if (num_engines == 0 || p->num_engines[e] == 0) {
@@ -175,7 +175,7 @@
 {
 	EngineID e;
 	EngineID selected_engine = INVALID_ENGINE;
-	byte type = w->window_number;
+	VehicleType type = (VehicleType)w->window_number;
 	byte i = draw_left ? 0 : 1;
 
 	EngineList *list = &WP(w, replaceveh_d).list[i];
--- a/src/bridge.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/bridge.h	Fri Feb 22 00:25:54 2008 +0000
@@ -13,30 +13,30 @@
 	MAX_BRIDGES = 13
 };
 
+typedef uint BridgeType;
+
 /** Struct containing information about a single bridge type
  */
-struct Bridge {
-	Year avail_year;     ///< the year where it becomes available
-	byte min_length;     ///< the minimum length (not counting start and end tile)
-	byte max_length;     ///< the maximum length (not counting start and end tile)
-	uint16 price;        ///< the price multiplier
-	uint16 speed;        ///< maximum travel speed
-	SpriteID sprite;     ///< the sprite which is used in the GUI
-	SpriteID pal;        ///< the palette which is used in the GUI
-	StringID material;   ///< the string that contains the bridge description
-	StringID name_rail;  ///< description of the bridge, when built for road
-	StringID name_road;  ///< description of the bridge, when built for road
-	PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge
-	byte flags;          ///< bit 0 set: disable drawing of far pillars.
+struct BridgeSpec {
+	Year avail_year;             ///< the year where it becomes available
+	byte min_length;             ///< the minimum length (not counting start and end tile)
+	byte max_length;             ///< the maximum length (not counting start and end tile)
+	uint16 price;                ///< the price multiplier
+	uint16 speed;                ///< maximum travel speed
+	SpriteID sprite;             ///< the sprite which is used in the GUI
+	SpriteID pal;                ///< the palette which is used in the GUI
+	StringID material;           ///< the string that contains the bridge description
+	StringID transport_name[2];  ///< description of the bridge, when built for road or rail
+	PalSpriteID **sprite_table;  ///< table of sprites for drawing the bridge
+	byte flags;                  ///< bit 0 set: disable drawing of far pillars.
 };
 
-extern const Bridge orig_bridge[MAX_BRIDGES];
-extern Bridge _bridge[MAX_BRIDGES];
+extern BridgeSpec _bridge[MAX_BRIDGES];
 
 Foundation GetBridgeFoundation(Slope tileh, Axis axis);
 bool HasBridgeFlatRamp(Slope tileh, Axis axis);
 
-static inline const Bridge *GetBridge(uint i)
+static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
 {
 	assert(i < lengthof(_bridge));
 	return &_bridge[i];
@@ -44,7 +44,9 @@
 
 void DrawBridgeMiddle(const TileInfo *ti);
 
-bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
+bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len);
 int CalcBridgeLenCostFactor(int x);
 
+void ResetBridges();
+
 #endif /* BRIDGE_H */
--- a/src/bridge_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/bridge_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -25,8 +25,8 @@
 	uint count;
 	TileIndex start_tile;
 	TileIndex end_tile;
-	uint8 type;
-	uint8 indexes[MAX_BRIDGES];
+	uint32 type; ///< Data type for the bridge. Bit 16,15 = transport type, 14..8 = road/rail pieces, 7..0 = type of bridge
+	BridgeType indexes[MAX_BRIDGES];
 	Money costs[MAX_BRIDGES];
 
 	BridgeData()
@@ -44,7 +44,7 @@
 {
 	DeleteWindow(w);
 	DoCommandP(_bridgedata.end_tile, _bridgedata.start_tile,
-		_bridgedata.indexes[i] | (_bridgedata.type << 8), CcBuildBridge,
+		_bridgedata.type | _bridgedata.indexes[i], CcBuildBridge,
 		CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
 }
 
@@ -79,7 +79,7 @@
 
 			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]];
+				const BridgeSpec *b = GetBridgeSpec(_bridgedata.indexes[i + w->vscroll.pos]);
 
 				SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]);
 				SetDParam(1, b->speed * 10 / 16);
@@ -143,38 +143,18 @@
 	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},            // 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_RESIZABLE,
-	_build_road_bridge_widgets,
-	BuildBridgeWndProc
-};
-
-
-void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
+void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type)
 {
 	DeleteWindowById(WC_BUILD_BRIDGE, 0);
 
-	_bridgedata.type = bridge_type;
+	_bridgedata.type = (transport_type << 15) | (bridge_type << 8); //prepare the parameter for use only once
 	_bridgedata.start_tile = start;
 	_bridgedata.end_tile = end;
 
 	/* 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);
+	CommandCost ret = DoCommand(end, start, _bridgedata.type, DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
 
 	uint8 j = 0;
 	if (CmdFailed(ret)) {
@@ -188,14 +168,14 @@
 		const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2);
 
 		/* loop for all bridgetypes */
-		for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) {
-			if (CheckBridge_Stuff(bridge_type, bridge_len)) {
+		for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
+			if (CheckBridge_Stuff(brd_type, bridge_len)) {
 				/* bridge is accepted, add to list */
-				const Bridge *b = &_bridge[bridge_type];
+				const BridgeSpec *b = GetBridgeSpec(brd_type);
 				/* 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;
+				_bridgedata.indexes[j] = brd_type;
 				j++;
 			}
 		}
@@ -204,7 +184,9 @@
 	}
 
 	if (j != 0) {
-		AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
+		Window *w = AllocateWindowDesc(&_build_bridge_desc);
+		/* Change the data, or the caption of the gui. Set it to road or rail, accordingly */
+		w->widget[BBSW_CAPTION].data = (transport_type == TRANSPORT_ROAD) ? STR_1803_SELECT_ROAD_BRIDGE : STR_100D_SELECT_RAIL_BRIDGE;
 	} else {
 		ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
 	}
--- a/src/bridge_map.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/bridge_map.h	Fri Feb 22 00:25:54 2008 +0000
@@ -8,6 +8,7 @@
 #include "direction_func.h"
 #include "rail_type.h"
 #include "road_map.h"
+#include "bridge.h"
 
 
 /**
@@ -67,7 +68,7 @@
  * @pre IsBridgeTile(t)
  * @return The bridge type
  */
-static inline uint GetBridgeType(TileIndex t)
+static inline BridgeType GetBridgeType(TileIndex t)
 {
 	assert(IsBridgeTile(t));
 	return GB(_m[t].m2, 4, 4);
@@ -163,7 +164,7 @@
  * @param rt         the road or rail type
  * @note this function should not be called directly.
  */
-static inline void MakeBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, TransportType tt, uint rt)
+static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt, uint rt)
 {
 	SetTileType(t, MP_TUNNELBRIDGE);
 	SetTileOwner(t, o);
@@ -181,7 +182,7 @@
  * @param d          the direction this ramp must be facing
  * @param r          the road type of the bridge
  */
-static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, RoadTypes r)
+static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RoadTypes r)
 {
 	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, r);
 }
@@ -194,7 +195,7 @@
  * @param d          the direction this ramp must be facing
  * @param r          the rail type of the bridge
  */
-static inline void MakeRailBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, RailType r)
+static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType r)
 {
 	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL, r);
 }
--- a/src/build_vehicle_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/build_vehicle_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -81,9 +81,11 @@
 };
 
 /* Setup widget strings to fit the different types of vehicles */
-static void SetupWindowStrings(Window *w, byte type)
+static void SetupWindowStrings(Window *w, VehicleType type)
 {
 	switch (type) {
+		default: NOT_REACHED();
+
 		case VEH_TRAIN:
 			w->widget[BUILD_VEHICLE_WIDGET_CAPTION].data    = STR_JUST_STRING;
 			w->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips   = STR_8843_TRAIN_VEHICLE_SELECTION;
@@ -92,6 +94,7 @@
 			w->widget[BUILD_VEHICLE_WIDGET_RENAME].data     = STR_8820_RENAME;
 			w->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_8845_RENAME_TRAIN_VEHICLE_TYPE;
 			break;
+
 		case VEH_ROAD:
 			w->widget[BUILD_VEHICLE_WIDGET_CAPTION].data    = STR_9006_NEW_ROAD_VEHICLES;
 			w->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips   = STR_9026_ROAD_VEHICLE_SELECTION;
@@ -100,6 +103,7 @@
 			w->widget[BUILD_VEHICLE_WIDGET_RENAME].data     = STR_9034_RENAME;
 			w->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_9035_RENAME_ROAD_VEHICLE_TYPE;
 			break;
+
 		case VEH_SHIP:
 			w->widget[BUILD_VEHICLE_WIDGET_CAPTION].data    = STR_9808_NEW_SHIPS;
 			w->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips   = STR_9825_SHIP_SELECTION_LIST_CLICK;
@@ -108,6 +112,7 @@
 			w->widget[BUILD_VEHICLE_WIDGET_RENAME].data     = STR_9836_RENAME;
 			w->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_9837_RENAME_SHIP_TYPE;
 			break;
+
 		case VEH_AIRCRAFT:
 			w->widget[BUILD_VEHICLE_WIDGET_CAPTION].data    = STR_A005_NEW_AIRCRAFT;
 			w->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips   = STR_A025_AIRCRAFT_SELECTION_LIST;
@@ -225,8 +230,8 @@
 	const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
 	const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
 
-	Money va = rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class] * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
-	Money vb = rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class] * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+	Money va = rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class) * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+	Money vb = rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class) * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
 	int r = ClampToI32(va - vb);
 
 	return _internal_sort_order ? -r : r;
@@ -243,8 +248,8 @@
 		* Because of this, the return value have to be reversed as well and we return b - a instead of a - b.
 		* Another thing is that both power and running costs should be doubled for multiheaded engines.
 		* Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */
-	Money va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max(1U, (uint)rvi_a->power);
-	Money vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max(1U, (uint)rvi_b->power);
+	Money va = (rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class)) / max(1U, (uint)rvi_a->power);
+	Money vb = (rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class)) / max(1U, (uint)rvi_b->power);
 	int r = ClampToI32(vb - va);
 
 	return _internal_sort_order ? -r : r;
@@ -307,9 +312,12 @@
 
 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;
+	const RoadVehicleInfo *rvi_a = RoadVehInfo(*(const EngineID*)a);
+	const RoadVehicleInfo *rvi_b = RoadVehInfo(*(const EngineID*)b);
+
+	Money va = rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class);
+	Money vb = rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class);
+	int r = ClampToI32(va - vb);
 
 	if (r == 0) {
 		/* Use EngineID to sort instead since we want consistent sorting */
@@ -525,6 +533,26 @@
 	INVALID_STRING_ID
 }};
 
+static int DrawCargoCapacityInfo(int x, int y, EngineID engine, VehicleType type, bool refittable)
+{
+	uint16 *cap = GetCapacityOfArticulatedParts(engine, type);
+
+	for (uint c = 0; c < NUM_CARGO; c++) {
+		if (cap[c] == 0) continue;
+
+		SetDParam(0, c);
+		SetDParam(1, cap[c]);
+		SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
+		DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING);
+		y += 10;
+
+		/* Only show as refittable once */
+		refittable = false;
+	}
+
+	return y;
+}
+
 /* Draw rail wagon specific details */
 static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
 {
@@ -549,6 +577,14 @@
 			y += 10;
 		}
 	}
+
+	/* Running cost */
+	if (rvi->running_cost_class != 0xFF) {
+		SetDParam(0, GetEngineProperty(engine_number, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8);
+		DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
+		y += 10;
+	}
+
 	return y;
 }
 
@@ -578,9 +614,11 @@
 	}
 
 	/* Running cost */
-	SetDParam(0, (GetEngineProperty(engine_number, 0x0D, rvi->running_cost_base) * _price.running_rail[rvi->running_cost_class] >> 8) << multihead);
-	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
-	y += 10;
+	if (rvi->running_cost_class != 0xFF) {
+		SetDParam(0, (GetEngineProperty(engine_number, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8) << multihead);
+		DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
+		y += 10;
+	}
 
 	/* Powered wagons power - Powered wagons extra weight */
 	if (rvi->pow_wag_power != 0) {
@@ -605,18 +643,12 @@
 	y += 10;
 
 	/* Running cost */
-	SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8);
+	SetDParam(0, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8);
 	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
 	y += 10;
 
 	/* Cargo type + capacity */
-	SetDParam(0, rvi->cargo_type);
-	SetDParam(1, GetEngineProperty(engine_number, 0x0F, rvi->capacity));
-	SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
-	DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING);
-	y += 10;
-
-	return y;
+	return DrawCargoCapacityInfo(x, y, engine_number, VEH_ROAD, refittable);
 }
 
 /* Draw ship specific details */
@@ -707,20 +739,18 @@
 			}
 
 			/* Cargo type + capacity, or N/A */
-			if (rvi->capacity == 0) {
+			int new_y = DrawCargoCapacityInfo(x, y, engine_number, VEH_TRAIN, refitable);
+
+			if (new_y == y) {
 				SetDParam(0, CT_INVALID);
 				SetDParam(2, STR_EMPTY);
+				DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING);
+				y += 10;
 			} else {
-				int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
-
-				SetDParam(0, rvi->cargo_type);
-				SetDParam(1, (capacity * (CountArticulatedParts(engine_number, true) + 1)) << multihead);
-				SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY);
+				y = new_y;
 			}
-			DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING);
-			y += 10;
+			break;
 		}
-			break;
 		case VEH_ROAD:
 			y = DrawRoadVehPurchaseInfo(x, y, engine_number, RoadVehInfo(engine_number));
 			refitable = true;
@@ -890,7 +920,7 @@
 	EngList_Sort(&bv->eng_list, _sorter[bv->vehicle_type][bv->sort_criteria]);
 }
 
-static void DrawVehicleEngine(byte type, int x, int y, EngineID engine, SpriteID pal)
+static void DrawVehicleEngine(VehicleType type, int x, int y, EngineID engine, SpriteID pal)
 {
 	switch (type) {
 		case VEH_TRAIN:    DrawTrainEngine(   x, y, engine, pal); break;
--- a/src/cargopacket.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/cargopacket.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -37,7 +37,7 @@
 	this->count = 0;
 }
 
-bool CargoPacket::SameSource(CargoPacket *cp)
+bool CargoPacket::SameSource(const CargoPacket *cp) const
 {
 	return this->source_xy == cp->source_xy && this->days_in_transit == cp->days_in_transit && this->paid_for == cp->paid_for;
 }
--- a/src/cargopacket.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/cargopacket.h	Fri Feb 22 00:25:54 2008 +0000
@@ -53,7 +53,7 @@
 	 * @param cp the cargo packet to compare to
 	 * @return true if and only if days_in_transit and source_xy are equal
 	 */
-	bool SameSource(CargoPacket *cp);
+	bool SameSource(const CargoPacket *cp) const;
 };
 
 /**
--- a/src/clear_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/clear_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -315,7 +315,7 @@
 	/* not used */
 }
 
-static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
 	return 0;
 }
--- a/src/command.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/command.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -209,160 +209,145 @@
  * as the value from the CMD_* enums.
  */
 static const Command _command_proc_table[] = {
-	{CmdBuildRailroadTrack,           CMD_AUTO}, /*   0, CMD_BUILD_RAILROAD_TRACK */
-	{CmdRemoveRailroadTrack,          CMD_AUTO}, /*   1, CMD_REMOVE_RAILROAD_TRACK */
-	{CmdBuildSingleRail,              CMD_AUTO}, /*   2, CMD_BUILD_SINGLE_RAIL */
-	{CmdRemoveSingleRail,             CMD_AUTO}, /*   3, CMD_REMOVE_SINGLE_RAIL */
-	{CmdLandscapeClear,                      0}, /*   4, CMD_LANDSCAPE_CLEAR */
-	{CmdBuildBridge,                  CMD_AUTO}, /*   5, CMD_BUILD_BRIDGE */
-	{CmdBuildRailroadStation,         CMD_AUTO}, /*   6, CMD_BUILD_RAILROAD_STATION */
-	{CmdBuildTrainDepot,              CMD_AUTO}, /*   7, CMD_BUILD_TRAIN_DEPOT */
-	{CmdBuildSingleSignal,            CMD_AUTO}, /*   8, CMD_BUILD_SIGNALS */
-	{CmdRemoveSingleSignal,           CMD_AUTO}, /*   9, CMD_REMOVE_SIGNALS */
-	{CmdTerraformLand,                CMD_AUTO}, /*  10, CMD_TERRAFORM_LAND */
-	{CmdPurchaseLandArea,             CMD_AUTO}, /*  11, CMD_PURCHASE_LAND_AREA */
-	{CmdSellLandArea,                        0}, /*  12, CMD_SELL_LAND_AREA */
-	{CmdBuildTunnel,                  CMD_AUTO}, /*  13, CMD_BUILD_TUNNEL */
-	{CmdRemoveFromRailroadStation,           0}, /*  14, CMD_REMOVE_FROM_RAILROAD_STATION */
-	{CmdConvertRail,                         0}, /*  15, CMD_CONVERT_RAILD */
-	{CmdBuildTrainWaypoint,                  0}, /*  16, CMD_BUILD_TRAIN_WAYPOINT */
-	{CmdRenameWaypoint,                      0}, /*  17, CMD_RENAME_WAYPOINT */
-	{CmdRemoveTrainWaypoint,                 0}, /*  18, CMD_REMOVE_TRAIN_WAYPOINT */
-	{NULL,                                   0}, /*  19, unused */
-	{NULL,                                   0}, /*  20, unused */
-	{CmdBuildRoadStop,                CMD_AUTO}, /*  21, CMD_BUILD_ROAD_STOP */
-	{CmdRemoveRoadStop,                      0}, /*  22, CMD_REMOVE_ROAD_STOP */
-	{CmdBuildLongRoad,                CMD_AUTO}, /*  23, CMD_BUILD_LONG_ROAD */
-	{CmdRemoveLongRoad,               CMD_AUTO}, /*  24, CMD_REMOVE_LONG_ROAD */
-	{CmdBuildRoad,                           0}, /*  25, CMD_BUILD_ROAD */
-	{CmdRemoveRoad,                          0}, /*  26, CMD_REMOVE_ROAD */
-	{CmdBuildRoadDepot,               CMD_AUTO}, /*  27, CMD_BUILD_ROAD_DEPOT */
-	{NULL,                                   0}, /*  28, unused */
-	{CmdBuildAirport,                 CMD_AUTO}, /*  29, CMD_BUILD_AIRPORT */
-	{CmdBuildDock,                    CMD_AUTO}, /*  30, CMD_BUILD_DOCK */
-	{CmdBuildShipDepot,               CMD_AUTO}, /*  31, CMD_BUILD_SHIP_DEPOT */
-	{CmdBuildBuoy,                    CMD_AUTO}, /*  32, CMD_BUILD_BUOY */
-	{CmdPlantTree,                    CMD_AUTO}, /*  33, CMD_PLANT_TREE */
-	{CmdBuildRailVehicle,                    0}, /*  34, CMD_BUILD_RAIL_VEHICLE */
-	{CmdMoveRailVehicle,                     0}, /*  35, CMD_MOVE_RAIL_VEHICLE */
-	{CmdStartStopTrain,                      0}, /*  36, CMD_START_STOP_TRAIN */
-	{NULL,                                   0}, /*  37, unused */
-	{CmdSellRailWagon,                       0}, /*  38, CMD_SELL_RAIL_WAGON */
-	{CmdSendTrainToDepot,                    0}, /*  39, CMD_SEND_TRAIN_TO_DEPOT */
-	{CmdForceTrainProceed,                   0}, /*  40, CMD_FORCE_TRAIN_PROCEED */
-	{CmdReverseTrainDirection,               0}, /*  41, CMD_REVERSE_TRAIN_DIRECTION */
-
-	{CmdModifyOrder,                         0}, /*  42, CMD_MODIFY_ORDER */
-	{CmdSkipToOrder,                         0}, /*  43, CMD_SKIP_TO_ORDER */
-	{CmdDeleteOrder,                         0}, /*  44, CMD_DELETE_ORDER */
-	{CmdInsertOrder,                         0}, /*  45, CMD_INSERT_ORDER */
-
-	{CmdChangeServiceInt,                    0}, /*  46, CMD_CHANGE_SERVICE_INT */
-
-	{CmdBuildIndustry,                       0}, /*  47, CMD_BUILD_INDUSTRY */
-	{CmdBuildCompanyHQ,               CMD_AUTO}, /*  48, CMD_BUILD_COMPANY_HQ */
-	{CmdSetPlayerFace,                       0}, /*  49, CMD_SET_PLAYER_FACE */
-	{CmdSetPlayerColor,                      0}, /*  50, CMD_SET_PLAYER_COLOR */
-
-	{CmdIncreaseLoan,                        0}, /*  51, CMD_INCREASE_LOAN */
-	{CmdDecreaseLoan,                        0}, /*  52, CMD_DECREASE_LOAN */
-
-	{CmdWantEnginePreview,                   0}, /*  53, CMD_WANT_ENGINE_PREVIEW */
-
-	{CmdNameVehicle,                         0}, /*  54, CMD_NAME_VEHICLE */
-	{CmdRenameEngine,                        0}, /*  55, CMD_RENAME_ENGINE */
-
-	{CmdChangeCompanyName,                   0}, /*  56, CMD_CHANGE_COMPANY_NAME */
-	{CmdChangePresidentName,                 0}, /*  57, CMD_CHANGE_PRESIDENT_NAME */
-
-	{CmdRenameStation,                       0}, /*  58, CMD_RENAME_STATION */
-
-	{CmdSellAircraft,                        0}, /*  59, CMD_SELL_AIRCRAFT */
-	{CmdStartStopAircraft,                   0}, /*  60, CMD_START_STOP_AIRCRAFT */
-
-	{CmdBuildAircraft,                       0}, /*  61, CMD_BUILD_AIRCRAFT */
-	{CmdSendAircraftToHangar,                0}, /*  62, CMD_SEND_AIRCRAFT_TO_HANGAR */
-	{NULL,                                   0}, /*  63, unused */
-	{CmdRefitAircraft,                       0}, /*  64, CMD_REFIT_AIRCRAFT */
+	{CmdBuildRailroadTrack,           CMD_AUTO}, /* CMD_BUILD_RAILROAD_TRACK */
+	{CmdRemoveRailroadTrack,          CMD_AUTO}, /* CMD_REMOVE_RAILROAD_TRACK */
+	{CmdBuildSingleRail,              CMD_AUTO}, /* CMD_BUILD_SINGLE_RAIL */
+	{CmdRemoveSingleRail,             CMD_AUTO}, /* CMD_REMOVE_SINGLE_RAIL */
+	{CmdLandscapeClear,                      0}, /* CMD_LANDSCAPE_CLEAR */
+	{CmdBuildBridge,                  CMD_AUTO}, /* CMD_BUILD_BRIDGE */
+	{CmdBuildRailroadStation,         CMD_AUTO}, /* CMD_BUILD_RAILROAD_STATION */
+	{CmdBuildTrainDepot,              CMD_AUTO}, /* CMD_BUILD_TRAIN_DEPOT */
+	{CmdBuildSingleSignal,            CMD_AUTO}, /* CMD_BUILD_SIGNALS */
+	{CmdRemoveSingleSignal,           CMD_AUTO}, /* CMD_REMOVE_SIGNALS */
+	{CmdTerraformLand,                CMD_AUTO}, /* CMD_TERRAFORM_LAND */
+	{CmdPurchaseLandArea,             CMD_AUTO}, /* CMD_PURCHASE_LAND_AREA */
+	{CmdSellLandArea,                        0}, /* CMD_SELL_LAND_AREA */
+	{CmdBuildTunnel,                  CMD_AUTO}, /* CMD_BUILD_TUNNEL */
+	{CmdRemoveFromRailroadStation,           0}, /* CMD_REMOVE_FROM_RAILROAD_STATION */
+	{CmdConvertRail,                         0}, /* CMD_CONVERT_RAILD */
+	{CmdBuildTrainWaypoint,                  0}, /* CMD_BUILD_TRAIN_WAYPOINT */
+	{CmdRenameWaypoint,                      0}, /* CMD_RENAME_WAYPOINT */
+	{CmdRemoveTrainWaypoint,                 0}, /* CMD_REMOVE_TRAIN_WAYPOINT */
 
-	{CmdPlaceSign,                           0}, /*  65, CMD_PLACE_SIGN */
-	{CmdRenameSign,                          0}, /*  66, CMD_RENAME_SIGN */
-
-	{CmdBuildRoadVeh,                        0}, /*  67, CMD_BUILD_ROAD_VEH */
-	{CmdStartStopRoadVeh,                    0}, /*  68, CMD_START_STOP_ROADVEH */
-	{CmdSellRoadVeh,                         0}, /*  69, CMD_SELL_ROAD_VEH */
-	{CmdSendRoadVehToDepot,                  0}, /*  70, CMD_SEND_ROADVEH_TO_DEPOT */
-	{CmdTurnRoadVeh,                         0}, /*  71, CMD_TURN_ROADVEH */
-	{CmdRefitRoadVeh,                        0}, /*  72, CMD_REFIT_ROAD_VEH */
-
-	{CmdPause,                      CMD_SERVER}, /*  73, CMD_PAUSE */
-
-	{CmdBuyShareInCompany,                   0}, /*  74, CMD_BUY_SHARE_IN_COMPANY */
-	{CmdSellShareInCompany,                  0}, /*  75, CMD_SELL_SHARE_IN_COMPANY */
-	{CmdBuyCompany,                          0}, /*  76, CMD_BUY_COMANY */
-
-	{CmdBuildTown,                 CMD_OFFLINE}, /*  77, CMD_BUILD_TOWN */
-	{NULL,                                   0}, /*  78, unused */
-	{NULL,                                   0}, /*  79, unused */
-	{CmdRenameTown,                 CMD_SERVER}, /*  80, CMD_RENAME_TOWN */
-	{CmdDoTownAction,                        0}, /*  81, CMD_DO_TOWN_ACTION */
-
-	{CmdSetRoadDriveSide,           CMD_SERVER}, /*  82, CMD_SET_ROAD_DRIVE_SIDE */
-	{NULL,                                   0}, /*  83, unused */
-	{NULL,                                   0}, /*  84, unused */
-	{CmdChangeDifficultyLevel,      CMD_SERVER}, /*  85, CMD_CHANGE_DIFFICULTY_LEVEL */
-
-	{CmdStartStopShip,                       0}, /*  86, CMD_START_STOP_SHIP */
-	{CmdSellShip,                            0}, /*  87, CMD_SELL_SHIP */
-	{CmdBuildShip,                           0}, /*  88, CMD_BUILD_SHIP */
-	{CmdSendShipToDepot,                     0}, /*  89, CMD_SEND_SHIP_TO_DEPOT */
-	{NULL,                                   0}, /*  90, unused */
-	{CmdRefitShip,                           0}, /*  91, CMD_REFIT_SHIP */
+	{CmdBuildRoadStop,                CMD_AUTO}, /* CMD_BUILD_ROAD_STOP */
+	{CmdRemoveRoadStop,                      0}, /* CMD_REMOVE_ROAD_STOP */
+	{CmdBuildLongRoad,                CMD_AUTO}, /* CMD_BUILD_LONG_ROAD */
+	{CmdRemoveLongRoad,               CMD_AUTO}, /* CMD_REMOVE_LONG_ROAD */
+	{CmdBuildRoad,                           0}, /* CMD_BUILD_ROAD */
+	{CmdRemoveRoad,                          0}, /* CMD_REMOVE_ROAD */
+	{CmdBuildRoadDepot,               CMD_AUTO}, /* CMD_BUILD_ROAD_DEPOT */
 
-	{NULL,                                   0}, /*  92, unused */
-	{NULL,                                   0}, /*  93, unused */
-	{NULL,                                   0}, /*  94, unused */
-	{NULL,                                   0}, /*  95, unused */
-	{NULL,                                   0}, /*  96, unused */
-	{NULL,                                   0}, /*  97, unused */
-
-	{CmdOrderRefit,                          0}, /*  98, CMD_ORDER_REFIT */
-	{CmdCloneOrder,                          0}, /*  99, CMD_CLONE_ORDER */
-
-	{CmdClearArea,                           0}, /* 100, CMD_CLEAR_AREA */
-	{NULL,                                   0}, /* 101, unused */
-
-	{CmdMoneyCheat,                CMD_OFFLINE}, /* 102, CMD_MONEY_CHEAT */
-	{CmdBuildCanal,                   CMD_AUTO}, /* 103, CMD_BUILD_CANAL */
-	{CmdPlayerCtrl,                          0}, /* 104, CMD_PLAYER_CTRL */
-
-	{CmdLevelLand,                    CMD_AUTO}, /* 105, CMD_LEVEL_LAND */
+	{CmdBuildAirport,                 CMD_AUTO}, /* CMD_BUILD_AIRPORT */
+	{CmdBuildDock,                    CMD_AUTO}, /* CMD_BUILD_DOCK */
+	{CmdBuildShipDepot,               CMD_AUTO}, /* CMD_BUILD_SHIP_DEPOT */
+	{CmdBuildBuoy,                    CMD_AUTO}, /* CMD_BUILD_BUOY */
+	{CmdPlantTree,                    CMD_AUTO}, /* CMD_PLANT_TREE */
+	{CmdBuildRailVehicle,                    0}, /* CMD_BUILD_RAIL_VEHICLE */
+	{CmdMoveRailVehicle,                     0}, /* CMD_MOVE_RAIL_VEHICLE */
+	{CmdStartStopTrain,                      0}, /* CMD_START_STOP_TRAIN */
 
-	{CmdRefitRailVehicle,                    0}, /* 106, CMD_REFIT_RAIL_VEHICLE */
-	{CmdRestoreOrderIndex,                   0}, /* 107, CMD_RESTORE_ORDER_INDEX */
-	{CmdBuildLock,                    CMD_AUTO}, /* 108, CMD_BUILD_LOCK */
-	{NULL,                                   0}, /* 109, unused */
-	{CmdBuildSignalTrack,             CMD_AUTO}, /* 110, CMD_BUILD_SIGNAL_TRACK */
-	{CmdRemoveSignalTrack,            CMD_AUTO}, /* 111, CMD_REMOVE_SIGNAL_TRACK */
-	{NULL,                                   0}, /* 112, unused */
-	{CmdGiveMoney,                           0}, /* 113, CMD_GIVE_MONEY */
-	{CmdChangePatchSetting,         CMD_SERVER}, /* 114, CMD_CHANGE_PATCH_SETTING */
-	{CmdSetAutoReplace,                      0}, /* 115, CMD_SET_AUTOREPLACE */
-	{CmdCloneVehicle,                        0}, /* 116, CMD_CLONE_VEHICLE */
-	{CmdMassStartStopVehicle,                0}, /* 117, CMD_MASS_START_STOP */
-	{CmdDepotSellAllVehicles,                0}, /* 118, CMD_DEPOT_SELL_ALL_VEHICLES */
-	{CmdDepotMassAutoReplace,                0}, /* 119, CMD_DEPOT_MASS_AUTOREPLACE */
-	{CmdCreateGroup,                         0}, /* 120, CMD_CREATE_GROUP */
-	{CmdDeleteGroup,                         0}, /* 121, CMD_DELETE_GROUP */
-	{CmdRenameGroup,                         0}, /* 122, CMD_RENAME_GROUP */
-	{CmdAddVehicleGroup,                     0}, /* 123, CMD_ADD_VEHICLE_GROUP */
-	{CmdAddSharedVehicleGroup,               0}, /* 124, CMD_ADD_SHARE_VEHICLE_GROUP */
-	{CmdRemoveAllVehiclesGroup,              0}, /* 125, CMD_REMOVE_ALL_VEHICLES_GROUP */
-	{CmdSetGroupReplaceProtection,           0}, /* 126, CMD_SET_GROUP_REPLACE_PROTECTION */
-	{CmdMoveOrder,                           0}, /* 127, CMD_MOVE_ORDER */
-	{CmdChangeTimetable,                     0}, /* 128, CMD_CHANGE_TIMETABLE */
-	{CmdSetVehicleOnTime,                    0}, /* 129, CMD_SET_VEHICLE_ON_TIME */
-	{CmdAutofillTimetable,                   0}, /* 130, CMD_AUTOFILL_TIMETABLE */
+	{CmdSellRailWagon,                       0}, /* CMD_SELL_RAIL_WAGON */
+	{CmdSendTrainToDepot,                    0}, /* CMD_SEND_TRAIN_TO_DEPOT */
+	{CmdForceTrainProceed,                   0}, /* CMD_FORCE_TRAIN_PROCEED */
+	{CmdReverseTrainDirection,               0}, /* CMD_REVERSE_TRAIN_DIRECTION */
+
+	{CmdModifyOrder,                         0}, /* CMD_MODIFY_ORDER */
+	{CmdSkipToOrder,                         0}, /* CMD_SKIP_TO_ORDER */
+	{CmdDeleteOrder,                         0}, /* CMD_DELETE_ORDER */
+	{CmdInsertOrder,                         0}, /* CMD_INSERT_ORDER */
+
+	{CmdChangeServiceInt,                    0}, /* CMD_CHANGE_SERVICE_INT */
+
+	{CmdBuildIndustry,                       0}, /* CMD_BUILD_INDUSTRY */
+	{CmdBuildCompanyHQ,               CMD_AUTO}, /* CMD_BUILD_COMPANY_HQ */
+	{CmdSetPlayerFace,                       0}, /* CMD_SET_PLAYER_FACE */
+	{CmdSetPlayerColor,                      0}, /* CMD_SET_PLAYER_COLOR */
+
+	{CmdIncreaseLoan,                        0}, /* CMD_INCREASE_LOAN */
+	{CmdDecreaseLoan,                        0}, /* CMD_DECREASE_LOAN */
+
+	{CmdWantEnginePreview,                   0}, /* CMD_WANT_ENGINE_PREVIEW */
+
+	{CmdNameVehicle,                         0}, /* CMD_NAME_VEHICLE */
+	{CmdRenameEngine,                        0}, /* CMD_RENAME_ENGINE */
+
+	{CmdChangeCompanyName,                   0}, /* CMD_CHANGE_COMPANY_NAME */
+	{CmdChangePresidentName,                 0}, /* CMD_CHANGE_PRESIDENT_NAME */
+
+	{CmdRenameStation,                       0}, /* CMD_RENAME_STATION */
+
+	{CmdSellAircraft,                        0}, /* CMD_SELL_AIRCRAFT */
+	{CmdStartStopAircraft,                   0}, /* CMD_START_STOP_AIRCRAFT */
+
+	{CmdBuildAircraft,                       0}, /* CMD_BUILD_AIRCRAFT */
+	{CmdSendAircraftToHangar,                0}, /* CMD_SEND_AIRCRAFT_TO_HANGAR */
+	{CmdRefitAircraft,                       0}, /* CMD_REFIT_AIRCRAFT */
+
+	{CmdPlaceSign,                           0}, /* CMD_PLACE_SIGN */
+	{CmdRenameSign,                          0}, /* CMD_RENAME_SIGN */
+
+	{CmdBuildRoadVeh,                        0}, /* CMD_BUILD_ROAD_VEH */
+	{CmdStartStopRoadVeh,                    0}, /* CMD_START_STOP_ROADVEH */
+	{CmdSellRoadVeh,                         0}, /* CMD_SELL_ROAD_VEH */
+	{CmdSendRoadVehToDepot,                  0}, /* CMD_SEND_ROADVEH_TO_DEPOT */
+	{CmdTurnRoadVeh,                         0}, /* CMD_TURN_ROADVEH */
+	{CmdRefitRoadVeh,                        0}, /* CMD_REFIT_ROAD_VEH */
+
+	{CmdPause,                      CMD_SERVER}, /* CMD_PAUSE */
+
+	{CmdBuyShareInCompany,                   0}, /* CMD_BUY_SHARE_IN_COMPANY */
+	{CmdSellShareInCompany,                  0}, /* CMD_SELL_SHARE_IN_COMPANY */
+	{CmdBuyCompany,                          0}, /* CMD_BUY_COMANY */
+
+	{CmdBuildTown,                 CMD_OFFLINE}, /* CMD_BUILD_TOWN */
+	{CmdRenameTown,                 CMD_SERVER}, /* CMD_RENAME_TOWN */
+	{CmdDoTownAction,                        0}, /* CMD_DO_TOWN_ACTION */
+
+	{CmdSetRoadDriveSide,           CMD_SERVER}, /* CMD_SET_ROAD_DRIVE_SIDE */
+	{CmdChangeDifficultyLevel,      CMD_SERVER}, /* CMD_CHANGE_DIFFICULTY_LEVEL */
+
+	{CmdStartStopShip,                       0}, /* CMD_START_STOP_SHIP */
+	{CmdSellShip,                            0}, /* CMD_SELL_SHIP */
+	{CmdBuildShip,                           0}, /* CMD_BUILD_SHIP */
+	{CmdSendShipToDepot,                     0}, /* CMD_SEND_SHIP_TO_DEPOT */
+	{CmdRefitShip,                           0}, /* CMD_REFIT_SHIP */
+
+	{CmdOrderRefit,                          0}, /* CMD_ORDER_REFIT */
+	{CmdCloneOrder,                          0}, /* CMD_CLONE_ORDER */
+
+	{CmdClearArea,                           0}, /* CMD_CLEAR_AREA */
+
+	{CmdMoneyCheat,                CMD_OFFLINE}, /* CMD_MONEY_CHEAT */
+	{CmdBuildCanal,                   CMD_AUTO}, /* CMD_BUILD_CANAL */
+	{CmdPlayerCtrl,                          0}, /* CMD_PLAYER_CTRL */
+
+	{CmdLevelLand,                    CMD_AUTO}, /* CMD_LEVEL_LAND */
+
+	{CmdRefitRailVehicle,                    0}, /* CMD_REFIT_RAIL_VEHICLE */
+	{CmdRestoreOrderIndex,                   0}, /* CMD_RESTORE_ORDER_INDEX */
+	{CmdBuildLock,                    CMD_AUTO}, /* CMD_BUILD_LOCK */
+
+	{CmdBuildSignalTrack,             CMD_AUTO}, /* CMD_BUILD_SIGNAL_TRACK */
+	{CmdRemoveSignalTrack,            CMD_AUTO}, /* CMD_REMOVE_SIGNAL_TRACK */
+
+	{CmdGiveMoney,                           0}, /* CMD_GIVE_MONEY */
+	{CmdChangePatchSetting,         CMD_SERVER}, /* CMD_CHANGE_PATCH_SETTING */
+	{CmdSetAutoReplace,                      0}, /* CMD_SET_AUTOREPLACE */
+	{CmdCloneVehicle,                        0}, /* CMD_CLONE_VEHICLE */
+	{CmdMassStartStopVehicle,                0}, /* CMD_MASS_START_STOP */
+	{CmdDepotSellAllVehicles,                0}, /* CMD_DEPOT_SELL_ALL_VEHICLES */
+	{CmdDepotMassAutoReplace,                0}, /* CMD_DEPOT_MASS_AUTOREPLACE */
+	{CmdCreateGroup,                         0}, /* CMD_CREATE_GROUP */
+	{CmdDeleteGroup,                         0}, /* CMD_DELETE_GROUP */
+	{CmdRenameGroup,                         0}, /* CMD_RENAME_GROUP */
+	{CmdAddVehicleGroup,                     0}, /* CMD_ADD_VEHICLE_GROUP */
+	{CmdAddSharedVehicleGroup,               0}, /* CMD_ADD_SHARE_VEHICLE_GROUP */
+	{CmdRemoveAllVehiclesGroup,              0}, /* CMD_REMOVE_ALL_VEHICLES_GROUP */
+	{CmdSetGroupReplaceProtection,           0}, /* CMD_SET_GROUP_REPLACE_PROTECTION */
+	{CmdMoveOrder,                           0}, /* CMD_MOVE_ORDER */
+	{CmdChangeTimetable,                     0}, /* CMD_CHANGE_TIMETABLE */
+	{CmdSetVehicleOnTime,                    0}, /* CMD_SET_VEHICLE_ON_TIME */
+	{CmdAutofillTimetable,                   0}, /* CMD_AUTOFILL_TIMETABLE */
 };
 
 /*!
@@ -426,7 +411,7 @@
 	_docommand_recursive++;
 
 	/* only execute the test call if it's toplevel, or we're not execing. */
-	if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
+	if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) {
 		SetTownRatingTestMode(true);
 		res = proc(tile, flags & ~DC_EXEC, p1, p2);
 		SetTownRatingTestMode(false);
@@ -437,6 +422,7 @@
 
 		if (_docommand_recursive == 1 &&
 				!(flags & DC_QUERY_COST) &&
+				!(flags & DC_BANKRUPT) &&
 				res.GetCost() != 0 &&
 				!CheckPlayerHasMoney(res)) {
 			goto error;
@@ -461,7 +447,7 @@
 	}
 
 	/* if toplevel, subtract the money. */
-	if (--_docommand_recursive == 0) {
+	if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) {
 		SubtractMoneyFromPlayer(res);
 		/* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player */
 		if (tile != 0 && IsValidPlayer(_current_player)) {
--- a/src/command_type.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/command_type.h	Fri Feb 22 00:25:54 2008 +0000
@@ -106,156 +106,156 @@
  * @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_BUILD_RAILROAD_TRACK,         ///< build a rail track
+	CMD_REMOVE_RAILROAD_TRACK,        ///< remove a rail track
+	CMD_BUILD_SINGLE_RAIL,            ///< build a single rail track
+	CMD_REMOVE_SINGLE_RAIL,           ///< remove a single rail track
+	CMD_LANDSCAPE_CLEAR,              ///< demolish a tile
+	CMD_BUILD_BRIDGE,                 ///< build a bridge
+	CMD_BUILD_RAILROAD_STATION,       ///< build a railroad station
+	CMD_BUILD_TRAIN_DEPOT,            ///< build a train depot
+	CMD_BUILD_SIGNALS,                ///< build a signal
+	CMD_REMOVE_SIGNALS,               ///< remove a signal
+	CMD_TERRAFORM_LAND,               ///< terraform a tile
+	CMD_PURCHASE_LAND_AREA,           ///< purchase a tile
+	CMD_SELL_LAND_AREA,               ///< sell a bought tile before
+	CMD_BUILD_TUNNEL,                 ///< build a tunnel
 
-	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_REMOVE_FROM_RAILROAD_STATION, ///< remove a tile station
+	CMD_CONVERT_RAIL,                 ///< convert a rail type
 
-	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_BUILD_TRAIN_WAYPOINT,         ///< build a waypoint
+	CMD_RENAME_WAYPOINT,              ///< rename a waypoint
+	CMD_REMOVE_TRAIN_WAYPOINT,        ///< remove a waypoint
 
-	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_BUILD_ROAD_STOP,              ///< build a road stop
+	CMD_REMOVE_ROAD_STOP,             ///< remove a road stop
+	CMD_BUILD_LONG_ROAD,              ///< build a complete road (not a "half" one)
+	CMD_REMOVE_LONG_ROAD,             ///< remove a complete road (not a "half" one)
+	CMD_BUILD_ROAD,                   ///< build a "half" road
+	CMD_REMOVE_ROAD,                  ///< remove a "half" road
+	CMD_BUILD_ROAD_DEPOT,             ///< build a road 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_BUILD_AIRPORT,                ///< build an airport
 
-	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
+	CMD_BUILD_DOCK,                   ///< build a dock
+
+	CMD_BUILD_SHIP_DEPOT,             ///< build a ship depot
+	CMD_BUILD_BUOY,                   ///< build a buoy
+
+	CMD_PLANT_TREE,                   ///< plant a tree
+
+	CMD_BUILD_RAIL_VEHICLE,           ///< build a rail vehicle
+	CMD_MOVE_RAIL_VEHICLE,            ///< move a rail vehicle (in the depot)
+
+	CMD_START_STOP_TRAIN,             ///< start or stop a train
+
+	CMD_SELL_RAIL_WAGON,              ///< sell a rail wagon
+
+	CMD_SEND_TRAIN_TO_DEPOT,          ///< send a train to a depot
+	CMD_FORCE_TRAIN_PROCEED,          ///< proceed a train to pass a red signal
+	CMD_REVERSE_TRAIN_DIRECTION,      ///< turn a train around
+
+	CMD_MODIFY_ORDER,                 ///< modify an order (like set full-load)
+	CMD_SKIP_TO_ORDER,                ///< skip an order to the next of specific one
+	CMD_DELETE_ORDER,                 ///< delete an order
+	CMD_INSERT_ORDER,                 ///< insert a new order
+
+	CMD_CHANGE_SERVICE_INT,           ///< change the server interval of a vehicle
+
+	CMD_BUILD_INDUSTRY,               ///< build a new industry
+
+	CMD_BUILD_COMPANY_HQ,             ///< build the company headquarter
+	CMD_SET_PLAYER_FACE,              ///< set the face of the player/company
+	CMD_SET_PLAYER_COLOR,             ///< set the color of the player/company
+
+	CMD_INCREASE_LOAN,                ///< increase the loan from the bank
+	CMD_DECREASE_LOAN,                ///< decrease the loan from the bank
+
+	CMD_WANT_ENGINE_PREVIEW,          ///< confirm the preview of an engine
+
+	CMD_NAME_VEHICLE,                 ///< rename a whole vehicle
+	CMD_RENAME_ENGINE,                ///< rename a engine (in the engine list)
+	CMD_CHANGE_COMPANY_NAME,          ///< change the company name
+	CMD_CHANGE_PRESIDENT_NAME,        ///< change the president name
+	CMD_RENAME_STATION,               ///< rename a station
+
+	CMD_SELL_AIRCRAFT,                ///< sell an aircraft
+	CMD_START_STOP_AIRCRAFT,          ///< start/stop an aircraft
+	CMD_BUILD_AIRCRAFT,               ///< build an aircraft
+	CMD_SEND_AIRCRAFT_TO_HANGAR,      ///< send an aircraft to a hanger
+	CMD_REFIT_AIRCRAFT,               ///< refit the cargo space of an aircraft
+
+	CMD_PLACE_SIGN,                   ///< place a sign
+	CMD_RENAME_SIGN,                  ///< rename a sign
+
+	CMD_BUILD_ROAD_VEH,               ///< build a road vehicle
+	CMD_START_STOP_ROADVEH,           ///< start/stop a road vehicle
+	CMD_SELL_ROAD_VEH,                ///< sell a road vehicle
+	CMD_SEND_ROADVEH_TO_DEPOT,        ///< send a road vehicle to the depot
+	CMD_TURN_ROADVEH,                 ///< turn a road vehicle around
+	CMD_REFIT_ROAD_VEH,               ///< refit the cargo space of a road vehicle
+
+	CMD_PAUSE,                        ///< pause the game
+
+	CMD_BUY_SHARE_IN_COMPANY,         ///< buy a share from a company
+	CMD_SELL_SHARE_IN_COMPANY,        ///< sell a share from a company
+	CMD_BUY_COMPANY,                  ///< buy a company which is bankrupt
+
+	CMD_BUILD_TOWN,                   ///< build a town
+
+	CMD_RENAME_TOWN,                  ///< rename a town
+	CMD_DO_TOWN_ACTION,               ///< do a action from the town detail window (like advertises or bribe)
+
+	CMD_SET_ROAD_DRIVE_SIDE,          ///< set the side where the road vehicles drive
+
+	CMD_CHANGE_DIFFICULTY_LEVEL,      ///< change the difficult of a game (each setting for it own)
+
+	CMD_START_STOP_SHIP,              ///< start/stop a ship
+	CMD_SELL_SHIP,                    ///< sell a ship
+	CMD_BUILD_SHIP,                   ///< build a new ship
+	CMD_SEND_SHIP_TO_DEPOT,           ///< send a ship to a depot
+	CMD_REFIT_SHIP,                   ///< refit the cargo space of a ship
+
+	CMD_ORDER_REFIT,                  ///< change the refit informaction of an order (for "goto depot" )
+	CMD_CLONE_ORDER,                  ///< clone (and share) an order
+	CMD_CLEAR_AREA,                   ///< clear an area
+
+	CMD_MONEY_CHEAT,                  ///< do the money cheat
+	CMD_BUILD_CANAL,                  ///< build a canal
+
+	CMD_PLAYER_CTRL,                  ///< used in multiplayer to create a new player etc.
+	CMD_LEVEL_LAND,                   ///< level land
+
+	CMD_REFIT_RAIL_VEHICLE,           ///< refit the cargo space of a train
+	CMD_RESTORE_ORDER_INDEX,          ///< restore vehicle order-index and service interval
+	CMD_BUILD_LOCK,                   ///< build a lock
+
+	CMD_BUILD_SIGNAL_TRACK,           ///< add signals along a track (by dragging)
+	CMD_REMOVE_SIGNAL_TRACK,          ///< remove signals along a track (by dragging)
+
+	CMD_GIVE_MONEY,                   ///< give money to an other player
+	CMD_CHANGE_PATCH_SETTING,         ///< change a patch setting
+
+	CMD_SET_AUTOREPLACE,              ///< set an autoreplace entry
+
+	CMD_CLONE_VEHICLE,                ///< clone a vehicle
+	CMD_MASS_START_STOP,              ///< start/stop all vehicles (in a depot)
+	CMD_DEPOT_SELL_ALL_VEHICLES,      ///< sell all vehicles which are in a given depot
+	CMD_DEPOT_MASS_AUTOREPLACE,       ///< force the autoreplace to take action in a given depot
+
+	CMD_CREATE_GROUP,                 ///< create a new group
+	CMD_DELETE_GROUP,                 ///< delete a group
+	CMD_RENAME_GROUP,                 ///< rename a group
+	CMD_ADD_VEHICLE_GROUP,            ///< add a vehicle to a group
+	CMD_ADD_SHARED_VEHICLE_GROUP,     ///< add all other shared vehicles to a group which are missing
+	CMD_REMOVE_ALL_VEHICLES_GROUP,    ///< remove all vehicles from a group
+	CMD_SET_GROUP_REPLACE_PROTECTION, ///< set the autoreplace-protection for a group
+
+	CMD_MOVE_ORDER,                   ///< move an order
+	CMD_CHANGE_TIMETABLE,             ///< change the timetable for a vehicle
+	CMD_SET_VEHICLE_ON_TIME,          ///< set the vehicle on time feature (timetable)
+	CMD_AUTOFILL_TIMETABLE,           ///< autofill the timetable
 };
 
 /**
@@ -271,7 +271,7 @@
 	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.
+	DC_BANKRUPT        = 0x80, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases
 };
 
 /**
--- a/src/console_cmds.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/console_cmds.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -810,7 +810,7 @@
 
 	if (argc < 2) return false;
 
-	_script_file = fopen(argv[1], "r");
+	_script_file = FioFOpenFile(argv[1], "r", BASE_DIR);
 
 	if (_script_file == NULL) {
 		if (argc == 2 || atoi(argv[2]) != 0) IConsoleError("script file not found");
@@ -834,7 +834,7 @@
 		IConsoleError("Encountered errror while trying to read from script file");
 
 	_script_running = false;
-	fclose(_script_file);
+	FioFCloseFile(_script_file);
 	return true;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/alloc_func.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -0,0 +1,24 @@
+/* $Id$ */
+
+/** @file alloc_func.cpp functions to 'handle' memory allocation errors */
+
+#include "../stdafx.h"
+#include "alloc_func.hpp"
+
+/**
+ * Function to exit with an error message after malloc() or calloc() have failed
+ * @param size number of bytes we tried to allocate
+ */
+void MallocError(size_t size)
+{
+	error("Out of memory. Cannot allocate %i bytes", size);
+}
+
+/**
+ * Function to exit with an error message after realloc() have failed
+ * @param size number of bytes we tried to allocate
+ */
+void ReallocError(size_t size)
+{
+	error("Out of memory. Cannot reallocate %i bytes", size);
+}
--- a/src/core/alloc_func.hpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/core/alloc_func.hpp	Fri Feb 22 00:25:54 2008 +0000
@@ -6,6 +6,15 @@
 #define ALLOC_FUNC_HPP
 
 /**
+ * Functions to exit badly with an error message.
+ * It has to be linked so the error messages are not
+ * duplicated in each object file making the final
+ * binary needlessly large.
+ */
+void MallocError(size_t size);
+void ReallocError(size_t size);
+
+/**
  * Simplified allocation function that allocates the specified number of
  * elements of the given type. It also explicitly casts it to the requested
  * type.
@@ -25,7 +34,7 @@
 	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));
+	if (t_ptr == NULL) MallocError(num_elements * sizeof(T));
 	return t_ptr;
 }
 
@@ -49,7 +58,7 @@
 	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));
+	if (t_ptr == NULL) MallocError(num_elements * sizeof(T));
 	return t_ptr;
 }
 
@@ -77,7 +86,7 @@
 	}
 
 	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));
+	if (t_ptr == NULL) ReallocError(num_elements * sizeof(T));
 	return t_ptr;
 }
 
--- a/src/core/math_func.hpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/core/math_func.hpp	Fri Feb 22 00:25:54 2008 +0000
@@ -169,6 +169,18 @@
 }
 
 /**
+ * Reduce an usigned 64-bit int to an unsigned 16-bit one
+ *
+ * @param a The 64-bit value to clamp
+ * @return The 64-bit value reduced to a 16-bit value
+ * @see ClampU(uint, uint, uint)
+ */
+static inline uint16 ClampToU16(const uint64 a)
+{
+	return min(a, 0xFFFF);
+}
+
+/**
  * Returns the (absolute) difference between two (scalar) variables
  *
  * @param a The first scalar
--- a/src/core/random_func.hpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/core/random_func.hpp	Fri Feb 22 00:25:54 2008 +0000
@@ -88,7 +88,7 @@
 static inline bool Chance16I(const uint a, const uint b, const uint32 r)
 {
 	assert(b != 0);
-	return (uint16)r < (uint16)((a << 16) / b);
+	return (uint16)r < (uint16)(((a << 16) + b / 2) / b);
 }
 
 /**
--- a/src/depot.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/depot.h	Fri Feb 22 00:25:54 2008 +0000
@@ -45,7 +45,7 @@
 			return IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile)  == RAIL_TILE_DEPOT;
 
 		case TRANSPORT_ROAD:
-			return IsTileType(tile, MP_ROAD)    && GetRoadTileType(tile)  == ROAD_TILE_DEPOT;
+			return IsRoadDepotTile(tile);
 
 		case TRANSPORT_WATER:
 			return IsTileType(tile, MP_WATER)   && GetWaterTileType(tile) == WATER_TILE_DEPOT;
@@ -64,7 +64,7 @@
 static inline bool IsDepotTile(TileIndex tile)
 {
 	switch (GetTileType(tile)) {
-		case MP_ROAD:    return GetRoadTileType(tile)  == ROAD_TILE_DEPOT;
+		case MP_ROAD:    return IsRoadDepot(tile);
 		case MP_WATER:   return GetWaterTileType(tile) == WATER_TILE_DEPOT;
 		case MP_RAILWAY: return GetRailTileType(tile)  == RAIL_TILE_DEPOT;
 		case MP_STATION: return IsHangar(tile);
--- a/src/depot_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/depot_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -519,9 +519,11 @@
  * Only use this if it's the same widget, that's used for more than one vehicle type and it needs different text/sprites
  * Vehicle specific text/sprites, that's in a widget, that's only shown for one vehicle type (like sell whole train) is set in the widget array
  */
-static void SetupStringsForDepotWindow(Window *w, byte type)
+static void SetupStringsForDepotWindow(Window *w, VehicleType type)
 {
 	switch (type) {
+		default: NOT_REACHED();
+
 		case VEH_TRAIN:
 			w->widget[DEPOT_WIDGET_CAPTION].data      = STR_8800_TRAIN_DEPOT;
 			w->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_TRAIN_TIP;
@@ -858,8 +860,13 @@
 		} break;
 
 		case WE_ABORT_PLACE_OBJ: {
+			/* abort clone */
 			w->RaiseWidget(DEPOT_WIDGET_CLONE);
 			w->InvalidateWidget(DEPOT_WIDGET_CLONE);
+
+			/* abort drag & drop */
+			WP(w, depot_d).sel = INVALID_VEHICLE;
+			w->InvalidateWidget(DEPOT_WIDGET_MATRIX);
 		} break;
 
 			/* check if a vehicle in a depot was clicked.. */
--- a/src/disaster_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/disaster_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -716,9 +716,8 @@
 
 	tile = v->tile + TileOffsByDiagDir(DirToDiagDir(v->direction));
 	if (IsValidTile(tile)) {
-		TrackdirBits r = (TrackdirBits)GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
-
-		if (TrackdirBitsToTrackBits(r) == TRACK_BIT_ALL && !Chance16(1, 90)) {
+		TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
+		if (trackbits == TRACK_BIT_ALL && !Chance16(1, 90)) {
 			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 			return;
--- a/src/dock_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/dock_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -243,7 +243,7 @@
 	case WE_CREATE: w->LowerWidget(_station_show_coverage + 3); break;
 
 	case WE_PAINT: {
-		int rad = (_patches.modified_catchment) ? CA_DOCK : 4;
+		int rad = (_patches.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
 
 		if (WP(w, def_d).close) return;
 		DrawWindowWidgets(w);
--- a/src/dummy_land.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/dummy_land.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -64,7 +64,7 @@
 	/* not used */
 }
 
-static uint32 GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
 	return 0;
 }
--- a/src/economy.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/economy.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -164,16 +164,16 @@
 				num++;
 				if (v->age > 730) {
 					/* Find the vehicle with the lowest amount of profit */
-					if (min_profit_first == true) {
+					if (min_profit_first || min_profit > v->profit_last_year) {
 						min_profit = v->profit_last_year;
 						min_profit_first = false;
-					} else if (min_profit > v->profit_last_year) {
-						min_profit = v->profit_last_year;
 					}
 				}
 			}
 		}
 
+		min_profit >>= 8; // remove the fract part
+
 		_score_part[owner][SCORE_VEHICLES] = num;
 		/* Don't allow negative min_profit to show */
 		if (min_profit > 0)
@@ -846,9 +846,9 @@
 	     55, ///< remove_dock
 	   1600, ///< remove_house
 	     40, ///< remove_road
-	   5600, ///< running_rail[0] railroad
-	   5200, ///< running_rail[1] monorail
-	   4800, ///< running_rail[2] maglev
+	   5600, ///< running_rail[0] steam
+	   5200, ///< running_rail[1] diesel
+	   4800, ///< running_rail[2] electric
 	   9600, ///< aircraft_running
 	   1600, ///< roadveh_running
 	   5600, ///< ship_running
@@ -914,6 +914,15 @@
 	_economy.fluct = GB(Random(), 0, 8) + 168;
 }
 
+
+Money GetPriceByIndex(uint8 index)
+{
+	if (index > NUM_PRICES) return 0;
+
+	return ((Money*)&_price)[index];
+}
+
+
 Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode)
 {
 	TileIndex tile;
@@ -1505,7 +1514,7 @@
 						cp->days_in_transit,
 						v->cargo_type);
 
-					front_v->profit_this_year += profit;
+					front_v->profit_this_year += profit << 8;
 					virtual_profit   += profit; // accumulate transfer profits for whole vehicle
 					cp->feeder_share += profit; // account for the (virtual) profit already made for the cargo packet
 					cp->paid_for      = true;   // record that the cargo has been paid for to eliminate double counting
@@ -1523,7 +1532,7 @@
 	}
 
 	if (route_profit != 0) {
-		front_v->profit_this_year += vehicle_profit;
+		front_v->profit_this_year += vehicle_profit << 8;
 		SubtractMoneyFromPlayer(CommandCost(front_v->GetExpenseType(true), -route_profit));
 
 		if (IsLocalPlayer() && !PlayVehicleSound(front_v, VSE_LOAD_UNLOAD)) {
--- a/src/economy_func.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/economy_func.h	Fri Feb 22 00:25:54 2008 +0000
@@ -41,4 +41,6 @@
 void VehiclePayment(Vehicle *front_v);
 void LoadUnloadStation(Station *st);
 
+Money GetPriceByIndex(uint8 index);
+
 #endif /* ECONOMY_FUNC_H */
--- a/src/economy_type.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/economy_type.h	Fri Feb 22 00:25:54 2008 +0000
@@ -112,18 +112,19 @@
 
 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,
+	EXPENSES_NEW_VEHICLES,
+	EXPENSES_TRAIN_RUN,
+	EXPENSES_ROADVEH_RUN,
+	EXPENSES_AIRCRAFT_RUN,
+	EXPENSES_SHIP_RUN,
+	EXPENSES_PROPERTY,
+	EXPENSES_TRAIN_INC,
+	EXPENSES_ROADVEH_INC,
+	EXPENSES_AIRCRAFT_INC,
+	EXPENSES_SHIP_INC,
+	EXPENSES_LOAN_INT,
+	EXPENSES_OTHER,
+	EXPENSES_END,
 	INVALID_EXPENSES      = 0xFF,
 };
 
--- a/src/elrail.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/elrail.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -103,7 +103,7 @@
 			return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
 
 		case MP_ROAD:
-			if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return TRACK_BIT_NONE;
+			if (!IsLevelCrossing(t)) return TRACK_BIT_NONE;
 			if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
 			return GetCrossingRailBits(t);
 
@@ -189,7 +189,7 @@
 		sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 		BB_data[2] - sss->x_offset, BB_data[3] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset + 1,
 		GetTileZ(ti->tile) + sss->z_offset,
-		IsTransparencySet(TO_BUILDINGS),
+		IsTransparencySet(TO_CATENARY),
 		BB_data[0] - sss->x_offset, BB_data[1] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset
 	);
 }
@@ -336,7 +336,7 @@
 
 					AddSortableSpriteToDraw(pylon_sprites[temp], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE,
 							GetPCPElevation(ti->tile, i),
-							IsTransparencySet(TO_BUILDINGS), -1, -1);
+							IsTransparencySet(TO_CATENARY), -1, -1);
 					break; /* We already have drawn a pylon, bail out */
 				}
 			}
@@ -344,7 +344,7 @@
 	}
 
 	/* Don't draw a wire under a low bridge */
-	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BUILDINGS)) {
+	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
 		uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
 
 		if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
@@ -371,7 +371,7 @@
 			 */
 			AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 				sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + sss->x_offset, ti->y + sss->y_offset) + sss->z_offset,
-				IsTransparencySet(TO_BUILDINGS));
+				IsTransparencySet(TO_CATENARY));
 		}
 	}
 }
@@ -404,7 +404,7 @@
 
 	AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 		sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset,
-		IsTransparencySet(TO_BUILDINGS)
+		IsTransparencySet(TO_CATENARY)
 	);
 
 	/* Finished with wires, draw pylons */
@@ -415,7 +415,7 @@
 		if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos);
 		uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos];
 		uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos];
-		AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_BUILDINGS), -1, -1);
+		AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1);
 	}
 
 	/* need a pylon on the southern end of the bridge */
@@ -425,7 +425,7 @@
 		if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos);
 		uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos];
 		uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos];
-		AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_BUILDINGS), -1, -1);
+		AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1);
 	}
 }
 
@@ -451,7 +451,7 @@
 					sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 					sss->x_size, sss->y_size, sss->z_size,
 					GetTileMaxZ(ti->tile) + sss->z_offset,
-					IsTransparencySet(TO_BUILDINGS)
+					IsTransparencySet(TO_CATENARY)
 				);
 				return;
 			}
--- a/src/engine.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/engine.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -91,8 +91,9 @@
 
 	/* Check for early retirement */
 	if (e->player_avail != 0 && !_patches.never_expire_vehicles) {
-		uint retire_early = EngInfo(e - _engines)->retire_early;
-		if (retire_early > 0 && age >= e->duration_phase_1 + e->duration_phase_2 - retire_early * 12) {
+		int retire_early = EngInfo(e - _engines)->retire_early;
+		uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12);
+		if (retire_early != 0 && age >= retire_early_max_age) {
 			/* Early retirement is enabled and we're past the date... */
 			e->player_avail = 0;
 			AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
@@ -190,13 +191,13 @@
 		SetBit(p->avail_roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
 	}
 
-	e->preview_player = INVALID_PLAYER;
+	e->preview_player_rank = 0xFF;
 	if (player == _local_player) {
 		AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
 	}
 }
 
-static PlayerID GetBestPlayer(PlayerID pp)
+static PlayerID GetBestPlayer(uint8 pp)
 {
 	const Player *p;
 	int32 best_hist;
@@ -217,7 +218,7 @@
 		if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR;
 
 		SetBit(mask, best_player);
-	} while (pp--, pp != 0);
+	} while (--p != 0);
 
 	return best_player;
 }
@@ -233,16 +234,16 @@
 
 		if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) {
 			if (e->flags & ENGINE_OFFER_WINDOW_OPEN) {
-				if (e->preview_player != 0xFF && !--e->preview_wait) {
+				if (e->preview_player_rank != 0xFF && !--e->preview_wait) {
 					e->flags &= ~ENGINE_OFFER_WINDOW_OPEN;
 					DeleteWindowById(WC_ENGINE_PREVIEW, i);
-					e->preview_player++;
+					e->preview_player_rank++;
 				}
-			} else if (e->preview_player != 0xFF) {
-				PlayerID best_player = GetBestPlayer(e->preview_player);
+			} else if (e->preview_player_rank != 0xFF) {
+				PlayerID best_player = GetBestPlayer(e->preview_player_rank);
 
 				if (best_player == PLAYER_SPECTATOR) {
-					e->preview_player = INVALID_PLAYER;
+					e->preview_player_rank = 0xFF;
 					continue;
 				}
 
@@ -272,7 +273,7 @@
 
 	if (!IsEngineIndex(p1)) return CMD_ERROR;
 	e = GetEngine(p1);
-	if (GetBestPlayer(e->preview_player) != _current_player) return CMD_ERROR;
+	if (GetBestPlayer(e->preview_player_rank) != _current_player) return CMD_ERROR;
 
 	if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_player);
 
@@ -360,7 +361,7 @@
 
 				/* Do not introduce new rail wagons */
 				if (!IsWagon(e - _engines))
-					e->preview_player = (PlayerID)1; // Give to the player with the highest rating.
+					e->preview_player_rank = 1; // Give to the player with the highest rating.
 			}
 		}
 	}
@@ -403,22 +404,19 @@
 }
 
 
-/*
- * returns true if an engine is valid, of the specified type, and buildable by
- * the given player, false otherwise
- *
- * engine = index of the engine to check
- * type   = the type the engine should be of (VEH_xxx)
- * player = index of the player
+/** Check if an engine is buildable.
+ * @param engine index of the engine to check.
+ * @param type   the type the engine should be.
+ * @param player index of the player.
+ * @return True if an engine is valid, of the specified type, and buildable by
+ *              the given player.
  */
-bool IsEngineBuildable(EngineID engine, byte type, PlayerID player)
+bool IsEngineBuildable(EngineID engine, VehicleType type, PlayerID player)
 {
-	const Engine *e;
-
 	/* check if it's an engine that is in the engine array */
 	if (!IsEngineIndex(engine)) return false;
 
-	e = GetEngine(engine);
+	const Engine *e = GetEngine(engine);
 
 	/* check if it's an engine of specified type */
 	if (e->type != type) return false;
@@ -615,7 +613,7 @@
 
 	    SLE_VAR(Engine, lifelength,          SLE_UINT8),
 	    SLE_VAR(Engine, flags,               SLE_UINT8),
-	    SLE_VAR(Engine, preview_player,      SLE_UINT8),
+	    SLE_VAR(Engine, preview_player_rank, SLE_UINT8),
 	    SLE_VAR(Engine, preview_wait,        SLE_UINT8),
 	SLE_CONDNULL(1, 0, 44),
 	    SLE_VAR(Engine, player_avail,        SLE_UINT8),
--- a/src/engine.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/engine.h	Fri Feb 22 00:25:54 2008 +0000
@@ -36,7 +36,7 @@
 	uint16 max_speed;
 	uint16 power;
 	uint16 weight;
-	byte running_cost_base;
+	byte running_cost;
 	byte running_cost_class;
 	EngineClass engclass;           ///< Class of engine for this vehicle
 	byte capacity;
@@ -90,6 +90,7 @@
 	byte image_index;
 	byte base_cost;
 	byte running_cost;
+	byte running_cost_class;
 	SoundFxByte sfx;
 	byte max_speed;
 	byte capacity;
@@ -110,7 +111,7 @@
 	byte refit_cost;
 	byte misc_flags;
 	byte callbackmask;
-	byte retire_early; ///< Number of years early to retire vehicle
+	int8 retire_early;  ///< Number of years early to retire vehicle
 	StringID string_id; ///< Default name of engine
 };
 
@@ -124,7 +125,7 @@
 	uint16 duration_phase_1, duration_phase_2, duration_phase_3;
 	byte lifelength;
 	byte flags;
-	PlayerByte preview_player;
+	uint8 preview_player_rank;
 	byte preview_wait;
 	byte player_avail;
 	VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
@@ -168,7 +169,7 @@
 void LoadCustomEngineNames();
 void DeleteCustomEngineNames();
 
-bool IsEngineBuildable(EngineID engine, byte type, PlayerID player);
+bool IsEngineBuildable(EngineID engine, VehicleType type, PlayerID player);
 CargoID GetEngineCargoType(EngineID engine);
 
 enum {
@@ -185,14 +186,14 @@
 	ROAD_ENGINES_INDEX      = NUM_TRAIN_ENGINES,
 };
 
-static inline EngineID GetFirstEngineOfType(byte type)
+static inline EngineID GetFirstEngineOfType(VehicleType type)
 {
 	const EngineID start[] = {0, ROAD_ENGINES_INDEX, SHIP_ENGINES_INDEX, AIRCRAFT_ENGINES_INDEX};
 
 	return start[type];
 }
 
-static inline EngineID GetLastEngineOfType(byte type)
+static inline EngineID GetLastEngineOfType(VehicleType type)
 {
 	const EngineID end[] = {
 		NUM_TRAIN_ENGINES,
--- a/src/engine_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/engine_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -126,7 +126,7 @@
 	SetDParam(3, rvi->power << multihead);
 	SetDParam(1, rvi->weight << multihead);
 
-	SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8 << multihead);
+	SetDParam(4, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8 << multihead);
 
 	if (rvi->capacity != 0) {
 		SetDParam(5, rvi->cargo_type);
@@ -155,7 +155,7 @@
 
 	SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5);
 	SetDParam(1, rvi->max_speed * 10 / 32);
-	SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8);
+	SetDParam(2, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8);
 	SetDParam(3, rvi->cargo_type);
 	SetDParam(4, rvi->capacity);
 
--- a/src/gfx_func.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/gfx_func.h	Fri Feb 22 00:25:54 2008 +0000
@@ -65,6 +65,7 @@
 extern Colour _cur_palette[256];
 
 void HandleKeypress(uint32 key);
+void HandleCtrlChanged();
 void HandleMouseEvents();
 void CSleep(int milliseconds);
 void UpdateWindows();
--- a/src/group_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/group_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -483,8 +483,8 @@
 
 				if (w->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG2) DrawSmallOrderList(v, x + 138, y2);
 
-				SetDParam(0, v->profit_this_year);
-				SetDParam(1, v->profit_last_year);
+				SetDParam(0, v->GetDisplayProfitThisYear());
+				SetDParam(1, v->GetDisplayProfitLastYear());
 				DrawString(x + 19, y2 + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
 
 				if (IsValidGroupID(v->group_id)) {
@@ -761,6 +761,13 @@
 				SetWindowDirty(w);
 			}
 			break;
+
+		case WE_ABORT_PLACE_OBJ: // called when new object to place is selected from keyboard
+			/* abort drag & drop */
+			gv->vehicle_sel = INVALID_VEHICLE;
+			w->InvalidateWidget(GRP_WIDGET_LIST_VEHICLE);
+			break;
+
 	}
 }
 
--- a/src/gui.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/gui.h	Fri Feb 22 00:25:54 2008 +0000
@@ -106,7 +106,7 @@
 extern const TextColour _fios_colors[];
 
 /* bridge_gui.cpp */
-void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte type);
+void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type);
 
 void ShowBuildIndustryWindow();
 void ShowMusicWindow();
--- a/src/industry_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/industry_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -815,7 +815,7 @@
 	ShowIndustryViewWindow(GetIndustryIndex(tile));
 }
 
-static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
 	return 0;
 }
@@ -1415,6 +1415,16 @@
 	return true;
 }
 
+/** Production level maximum, minimum and default values.
+ * It is not a value been really used in order to change, but rather an indicator
+ * of how the industry is behaving. */
+enum ProductionLevels {
+	PRODLEVEL_CLOSURE = 0x00,  ///< signal set to actually close the industry
+	PRODLEVEL_MINIMUM = 0x04,  ///< below this level, the industry is set to be closing
+	PRODLEVEL_DEFAULT = 0x10,  ///< default level set when the industry is created
+	PRODLEVEL_MAXIMUM = 0x80,  ///< the industry is running at full speed
+};
+
 static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, byte layout, const Town *t, Owner owner)
 {
 	const IndustrySpec *indspec = GetIndustrySpec(type);
@@ -1503,7 +1513,7 @@
 
 	if (!_generating_world) i->last_month_production[0] = i->last_month_production[1] = 0;
 
-	i->prod_level = 0x10;
+	i->prod_level = PRODLEVEL_DEFAULT;
 
 	do {
 		TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
@@ -2126,8 +2136,8 @@
 	}
 
 	/* Increase if needed */
-	while (mul-- != 0 && i->prod_level < 0x80) {
-		i->prod_level <<= 1;
+	while (mul-- != 0 && i->prod_level < PRODLEVEL_MAXIMUM) {
+		i->prod_level = min(i->prod_level * 2, PRODLEVEL_MAXIMUM);
 		i->production_rate[0] = min(i->production_rate[0] * 2, 0xFF);
 		i->production_rate[1] = min(i->production_rate[1] * 2, 0xFF);
 		if (str == STR_NULL) str = indspec->production_up_text;
@@ -2135,28 +2145,28 @@
 
 	/* Decrease if needed */
 	while (div-- != 0 && !closeit) {
-		if (i->prod_level == 4) {
+		if (i->prod_level == PRODLEVEL_MINIMUM) {
 			closeit = true;
 		} else {
-			i->prod_level >>= 1;
-			i->production_rate[0] = (i->production_rate[0] + 1) >> 1;
-			i->production_rate[1] = (i->production_rate[1] + 1) >> 1;
+			i->prod_level = max(i->prod_level / 2, (int)PRODLEVEL_MINIMUM); // typecast to int required to please MSVC
+			i->production_rate[0] = (i->production_rate[0] + 1) / 2;
+			i->production_rate[1] = (i->production_rate[1] + 1) / 2;
 			if (str == STR_NULL) str = indspec->production_down_text;
 		}
 	}
 
 	/* Increase or Decreasing the production level if needed */
 	if (increment != 0) {
-		if (increment < 0 && i->prod_level == 4) {
+		if (increment < 0 && i->prod_level == PRODLEVEL_MINIMUM) {
 			closeit = true;
 		} else {
-			i->prod_level = ClampU(i->prod_level + increment, 4, 0x80);
+			i->prod_level = ClampU(i->prod_level + increment, PRODLEVEL_MINIMUM, PRODLEVEL_MAXIMUM);
 		}
 	}
 
 	/* Close if needed and allowed */
 	if (closeit && !CheckIndustryCloseDownProtection(i->type)) {
-		i->prod_level = 0;
+		i->prod_level = PRODLEVEL_CLOSURE;
 		str = indspec->closure_text;
 	}
 
@@ -2200,7 +2210,7 @@
 
 	FOR_ALL_INDUSTRIES(i) {
 		UpdateIndustryStatistics(i);
-		if (i->prod_level == 0) {
+		if (i->prod_level == PRODLEVEL_CLOSURE) {
 			delete i;
 		} else {
 			ChangeIndustryProduction(i, true);
--- a/src/landscape.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/landscape.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -437,9 +437,18 @@
 	MarkTileDirtyByTile(tile);
 }
 
-uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode)
+/** Returns information about trackdirs and signal states.
+ * If there is any trackbit at 'side', return all trackdirbits.
+ * For TRANSPORT_ROAD, return no trackbits if there is no roadbit (of given subtype) at given side.
+ * @param tile tile to get info about
+ * @param mode transport type
+ * @param sub_mode for TRANSPORT_ROAD, roadtypes to check
+ * @param side side we are entering from, INVALID_DIAGDIR to return all trackbits
+ * @return trackdirbits and other info depending on 'mode'
+ */
+TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
-	return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode);
+	return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode, side);
 }
 
 void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player)
--- a/src/lang/afrikaans.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/afrikaans.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1043,7 +1043,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Laattoe die koop van eksklusief vervoer regte: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Laattoe die stuur van geld na ander maatskappye: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Ongelyk stasies: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nuwe wêreldwyd padvind (NPF, oorbrug NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Gewig vermenivoud vir vrag om swaar treine te simuleer: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Laattoe skyf-deur pad stop op dorp besit paaie: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Laattoe gebou van aangrensend stasies: {ORANGE}{STRING}
@@ -1197,9 +1196,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Verander stel waarde
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Sommige of almal van die verstek diens pouse(s) onder is onversoenbaar met die gekies stel! 5-90% en 30-800 dae is geldig
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Gebruik YAPF vir skepe: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Gebruik YAPF vir pad voertuie: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Gebruik YAPF vir treine: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Magtig landskap
 STR_SUB_ARCTIC_LANDSCAPE                                        :Onder-noordpool landskap
--- a/src/lang/brazilian_portuguese.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/brazilian_portuguese.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1051,7 +1051,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Permtir compra de direitos exclusivos de transporte: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Permitir o envio de dinheiro a outras companhias: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Estações não uniformes: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Novo busca de caminho global (NPF, sobrepõe NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Multiplicador de peso para trens simulando trens pesados: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Permitir estações drive-through em ruas locais: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Permitir construção de estações adjacentes: {ORANGE}{STRING}
@@ -1206,9 +1205,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Alterar valor
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Alguns ou todos os intervalo(s) de serviço predefinidos abaixo são incompatíveis com o valor escolhido! São válidos 5-90% e 30-800 dias
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Usar YAPF para embarcações: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Usar YAPF para automóveis: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Usar YAPF para trens: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :terreno temperado
 STR_SUB_ARCTIC_LANDSCAPE                                        :terreno subártico
--- a/src/lang/bulgarian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/bulgarian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1051,7 +1051,6 @@
 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}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Преминаване през спирки на градски пътища: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Позвалявай допрени гари: {ORANGE}{STRING}
@@ -1206,9 +1205,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Промяна стойноста на настройка
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Някои от стойностите за интервал(и) на сервиз са несъвместими с избраните настройки! 5-90% и 30-800 са валидни стойности
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}YAPF за кораби: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}YAPF за автомобили: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}YAPF за влакове: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :умерен климат
 STR_SUB_ARCTIC_LANDSCAPE                                        :Арктичен климат
--- a/src/lang/catalan.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/catalan.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1049,7 +1049,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Permet comprar els drets del transport en exclusiva: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Permet enviar diners a altres companyies: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Estacions no uniformes: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nova cerca de rutes global (NPF, anul·la NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Multiplicador de pes per contenidor per simular trens pesats: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Permet situar parades en carreteres que són propietat del poble: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Permet construir estacions annexes: {ORANGE}{STRING}
@@ -1204,9 +1203,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Canvia el valor de l'adjustament
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Alguns o tots els intervals de manteniment següents són incompatibles amb el valor triat! 5-90% i 30-800 dies són els vàlids
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Utilitza YAPF pels vaixells: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Utilitza YAPF pels automòvils: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Utilitza YAPF pels trens: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :paisatge temperat
 STR_SUB_ARCTIC_LANDSCAPE                                        :paisatge subàrtic
--- a/src/lang/croatian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/croatian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1049,7 +1049,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Dopusti kupovinu ekskluzivnih prijevoznih prava: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Dopusti slanje novca drugim tvrtkama: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Neujednačene stanice: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Novo globalno pronalaženje puteva (NPF, isključuje NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Težinski množitelj za teret za simulaciju teških vlakova: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Dopusti prolazne stanice na cestama u vlasti grada: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Dopusti izgradnju pridruženih stanica: {ORANGE}{STRING}
@@ -1204,9 +1203,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Promijeni vrijednost postavke
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Neki ili svi od zadanih servisnih intervala ispod nisu kompatibilni s odabranim postavkama! Valjane vrijednosti su 5-90% ili 30-800 dana.
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Koristi YAPF za brodove: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Koristi YAPF za cestovna vozila: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Koristi YAPF za vlakove: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Blagi krajolik
 STR_SUB_ARCTIC_LANDSCAPE                                        :Pod-arktički krajolik
--- a/src/lang/czech.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/czech.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1107,7 +1107,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Umožnit kupování výhradních přepravních práv: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Umožnit zasílání peněz ostatním společnostem: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Nejednolité stanice: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nový globální algoritmus hledání cesty (NPF, nahradí NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Pro simulaci těžkých vlaků vynásobit hmotnost nákladu: {ORANGE}{STRING}x
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Povolit průjezdné zastávky na silnicích vlastněných obcemi: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Povolit stavění přilehlých stanic: {ORANGE}{STRING}
@@ -1262,9 +1261,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Změnit hodnotu nastavení
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Některé nebo všechny základní intervaly servisů níže nesouhlasí s vybraným nastavením! 5-90 % nebo 30-800 dní jsou platné hodnoty
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Používat YAPF ("opět další pathfinder") pro lodě: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Používat YAPF pro silniční vozidla: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Používat YAPF pro vlaky: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :krajina mírného pásma
 STR_SUB_ARCTIC_LANDSCAPE                                        :subarktická krajina
--- a/src/lang/danish.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/danish.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1049,7 +1049,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Tillad køb af eksklusive transportrettigheder: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Tillad at sende penge til andre firmaer: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Ikke uniforme stationer: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Ny global ruteplanlægger (NPF, tilsidesætter NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Vægtfaktor for fragt for at simulere tunge tog: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Tillad gennemkørsels-stop på veje ejet af en by: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Tillad bygning af tilstødende stationer: {ORANGE}{STRING}
@@ -1204,9 +1203,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Skift indstillingsværdi
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Nogle eller alle standard service intervaller nedenunder er uforenelige med den valgte opsætning! 5-90% og 30-800 dage er gyldige
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Brug YAPF for skibe: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Brug YAPF for busser: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Brug YAPF for tog: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Tempereret klima
 STR_SUB_ARCTIC_LANDSCAPE                                        :Arktisk klima
--- a/src/lang/dutch.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/dutch.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1049,7 +1049,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Kopen van exclusieve transportrechten toestaan: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Geld geven aan andere bedrijven toestaan: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Vrij gevormde stations: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nieuwe globale routeplanner (NPF, voorkeur over NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Gewichtsverhouding voor vracht om zware treinen te simuleren: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Laat toe dat doorrij wegstops worden geplaatst op door stad beheerde wegen: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Bouwen van aangrenzende stations toestaan: {ORANGE}{STRING}
@@ -1204,9 +1203,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Verander waarde
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Sommige of alle van de standaard reparatie interval(len) hier onder zijn ongeldig met gekozen instelling! 5-90% en 30-800 dagen zijn geldig
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Gebruik YAPF voor schepen: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Gebruik YAPF voor wegvoertuigen: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Gebruik YAPF voor treinen: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :gematigd landschap
 STR_SUB_ARCTIC_LANDSCAPE                                        :subarctisch landschap
--- a/src/lang/english.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/english.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1049,7 +1049,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Allow buying exclusive transport rights: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Allow sending money to other companies: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Nonuniform stations: {ORANGE}{STRING1}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}New global pathfinding (NPF, overrides NTP): {ORANGE}{STRING1}
 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}
@@ -1204,9 +1203,19 @@
 
 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 the chosen setting! 5-90% and 30-800 days are valid
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Use YAPF for ships: {ORANGE}{STRING1}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Use YAPF for roadvehs: {ORANGE}{STRING1}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Use YAPF for trains: {ORANGE}{STRING1}
+
+STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS                        :{LTBLUE}Pathfinder for trains: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_NTP                    :NTP {RED}(Not recommended)
+STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_NPF                    :NPF
+STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_YAPF                   :YAPF {BLUE}(Recommended)
+STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH                       :{LTBLUE}Pathfinder for road vehicles: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_OPF                   :Original {RED}(Not recommended)
+STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_NPF                   :NPF
+STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_YAPF                  :YAPF {BLUE}(Recommended)
+STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS                         :{LTBLUE}Pathfinder for ships: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_OPF                     :Original {BLUE}(Recommended)
+STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_NPF                     :NPF
+STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_YAPF                    :YAPF {RED}(Not recommended)
 
 STR_TEMPERATE_LANDSCAPE                                         :Temperate landscape
 STR_SUB_ARCTIC_LANDSCAPE                                        :Sub-arctic landscape
@@ -3337,14 +3346,15 @@
 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_TRANSPARENT_SIGNS_DESC                                      :{BLACK}Toggle transparency for station signs. CTRL+click to lock.
+STR_TRANSPARENT_TREES_DESC                                      :{BLACK}Toggle transparency for trees. CTRL+click to lock.
+STR_TRANSPARENT_HOUSES_DESC                                     :{BLACK}Toggle transparency for houses. CTRL+click to lock.
+STR_TRANSPARENT_INDUSTRIES_DESC                                 :{BLACK}Toggle transparency for industries. CTRL+click to lock.
+STR_TRANSPARENT_BUILDINGS_DESC                                  :{BLACK}Toggle transparency for buildables like stations, depots and waypoints. CTRL+click to lock.
+STR_TRANSPARENT_BRIDGES_DESC                                    :{BLACK}Toggle transparency for bridges. CTRL+click to lock.
+STR_TRANSPARENT_STRUCTURES_DESC                                 :{BLACK}Toggle transparency for structures like lighthouses and antennas. CTRL+click to lock.
+STR_TRANSPARENT_CATENARY_DESC                                   :{BLACK}Toggle transparency for catenary. CTRL+click to lock.
+STR_TRANSPARENT_LOADING_DESC                                    :{BLACK}Toggle transparency for loading indicators. CTRL+click to lock.
 
 STR_PERCENT_UP_SMALL                                            :{TINYFONT}{WHITE}{NUM}%{UPARROW}
 STR_PERCENT_UP                                                  :{WHITE}{NUM}%{UPARROW}
--- a/src/lang/english_US.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/english_US.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1046,7 +1046,6 @@
 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}
@@ -1201,9 +1200,6 @@
 
 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
--- a/src/lang/esperanto.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/esperanto.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1036,7 +1036,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Ŝovu fenestron se la muso estas ĉe la rando: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Permesu subaĉeti la lokajn estrojn: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Nekonformaj stacioj: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nova ĝenerala vojtrovado (NPF, superas NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Pezpliigo pro ŝarĝo por imiti pezajn trajnojn: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Permesu trairaj bushaltejoj sur vojoj urboposedataj: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Permesu konstrui staciojn apude: {ORANGE}{STRING}
@@ -1163,9 +1162,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Ŝanĝu agord-valoron
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Iuj aŭ ĉiuj defaŭltaj prizorgintervaloj ne validas laŭ la agordoj! 5-90% kaj 30-800 tagoj validas
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Uzu YAPF por ŝipoj: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Uzu YAPF por vojveturiloj: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Uzu YAPF por trajnoj: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Modera landaspekto
 STR_SUB_ARCTIC_LANDSCAPE                                        :Arktikeca landaspekto
--- a/src/lang/estonian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/estonian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1149,7 +1149,6 @@
 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}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Luba suvalise kujuga jaamad: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Uus trassi otsimise algoritm(NPF asendab NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Raskete rongide simuleerimiseks kasutatav raskuse korrutaja: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Luba läbisõidupeatused linnateedel: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Luba jaamu lähestikku ehitada: {ORANGE}{STRING}
@@ -1304,9 +1303,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Muuda seadete väärtusi
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Mõni või kõik vaikimisi hooldusperioodid on kõlbmatud! Lubatud on 5-90% või 30-800 päeva
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Kasuta YAPF'i laevadel: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Kasuta YAPF'i autodel: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Kasuta YAPF'i rongidel: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Parasvöötme maastik
 STR_SUB_ARCTIC_LANDSCAPE                                        :Arktiline maastik
--- a/src/lang/finnish.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/finnish.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1039,7 +1039,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Vieritä ikkunaa, kun hiiri osuu reunaan: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Salli viranomaisten lahjominen: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Epäyhtenäiset asemat: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Uusi globaali tienhakualgor. (NPF, korvaa NTP:n): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Kerroin rahdin painolle raskaiden junien simuilointiin: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Läpiajettavat pysäkit kaupungin teille: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Vierekkäiset asemat: {ORANGE}{STRING}
@@ -1192,9 +1191,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Muuta asetusarvo
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Osa allaolevista oletushuoltoväleistä ei ole yhteensopivia valitun asetuksen kanssa! 5-90{NBSP}% ja 30-800 päivää ovat oikein.
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Käytä uutta reitinetsijää (YAPF) laivoille: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Käytä uutta reitinetsijää (YAPF) autoille: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Käytä uutta reitinetsijää (YAPF) junille: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :lauhkea maasto
 STR_SUB_ARCTIC_LANDSCAPE                                        :pohjoinen maasto
--- a/src/lang/french.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/french.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1050,7 +1050,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Autoriser l'achat des droits de transports exclusifs: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Autoriser l'envoi d'argent aux autres compagnies: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Gares non uniformes: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nouvelle recherche de chemin global (NPF, écrase NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Multiplier le poid pour les trains fret (simule des trains lourds): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Autoriser les arrêts de bus sur les routes des municipalités: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Autoriser la construction de stations adjacentes: {ORANGE}{STRING}
@@ -1205,9 +1204,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Changer valeur du paramètre
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Un ou plusieurs intervalles de service par défaut ci-dessous sont incompatibles avec le paramètre choisi! 5-90% et 30-800 jours sont valides
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Utiliser YAPF pour les navires: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Utiliser YAPF pour les véhicules routiers: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Utiliser YAPF pour les trains: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :environnement 'Tempéré'
 STR_SUB_ARCTIC_LANDSCAPE                                        :environnement 'Arctique'
--- a/src/lang/galician.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/galician.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1010,7 +1010,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Desplaza-la fiestra cando o ratón esté no borde: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Permiti-la chantaxe as autoridades locales: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Estacións non uniformes: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nova búsqueda de ruta global (NPF, invalida NTP): {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_SMALL_AIRPORTS                               :{LTBLUE}Permitir sempre aeroportos pequenos: {ORANGE}{STRING}
 
@@ -1102,9 +1101,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Cambia-lo valor
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}¡Algún ou tódolos intervalo(s) de servicio por defecto son incompatibles coa opción elixida! 5-90% e 30-800 días son válidos
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Usar YAPF para barcos: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Usar YAPF para vehículos de estrada: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Usar YAPF para os trens: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :escenario templado
 STR_SUB_ARCTIC_LANDSCAPE                                        :escenario sub-ártico
--- a/src/lang/german.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/german.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1049,7 +1049,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Erlaube den Erwerb exklusiver Transportrechte: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Erlaube es, anderen Firmen Geld zu schenken: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Ungleichmäßige Bahnhöfe: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Neue globale Wegfindung für alle Fahrzeuge: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Frachtgewicht erhöhen um schwere Züge zu simulieren: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Bushaltestellen an städtischen Straßen erlauben: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Bau angrenzender Stationen erlauben: {ORANGE}{STRING}
@@ -1204,9 +1203,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Einstellungswert ändern
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Einige oder alle dieser Standardwartungsintervalle sind inkompatibel mit den gewählten Einstellungen! 5-90% und 30-800 Tage sind gültig.
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}BenutzeYAPF für Schiffe: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Benutze YAPF für Fahrzeuge: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Benutze YAPF für Züge: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Gemäßigt
 STR_SUB_ARCTIC_LANDSCAPE                                        :Subarktisch
--- a/src/lang/hungarian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/hungarian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1114,7 +1114,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Lehessen exkluzív szállítási jogot venni: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Lehessen más vállalatoknak pénzt küldeni: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Különböző vágánytípusok engedélyezése egy állomáson: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Új útvonalkereső (NPF, felülbírálja az NTP-t): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Tömegszorzó tehervonatoknak (szimulációs célból): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Áthajtható állomások engedélyezése városi utakra: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Érintkező állomások építésének engedélyezése: {ORANGE}{STRING}
@@ -1269,9 +1268,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Válassz beállítási értéket
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}A lenti alap szervíz intervallum beállítások némelyike/mindegyike inkompatibilis a választott beállítással! Csak 5-90% és 30-800 napig elfogadható.
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}YAPF használata hajóknál: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}YAPF használata közutakon: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}YAPF használata vonatokhoz: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :mérsékelt táj
 STR_SUB_ARCTIC_LANDSCAPE                                        :sarkköri táj
--- a/src/lang/icelandic.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/icelandic.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1029,7 +1029,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Færa sjónarhorn þegar músin nálgast brún gluggans: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Leyfilegt að múta bæjaryfirvöldum: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Órétthyrndar lestarstöðvar leyfðar: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nýtt alhliða leiðsögukerfi (NPF, yfirtekur NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Margfalda þyngd farms til að líkja eftir þyngri lestum: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Leyfa strætóstöðvar á gangstéttum bæja: {ORANGE}{STRING}
 
@@ -1131,9 +1130,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Breyta gildi stillingar
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Einhver eða öll bil milli skoðana hér fyrir neðan eru ósamhæfanleg við valdar stillingar! 5-90% og 30-800 dagar er leyfilegt
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Nota YAPF fyrir skip: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Nota YAPF fyrir bifreiðar: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Nota YAPF fyrir lestir: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Temprað landslag
 STR_SUB_ARCTIC_LANDSCAPE                                        :Heimskautalandslag
--- a/src/lang/italian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/italian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1051,7 +1051,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Consenti l'acquisto dell'esclusiva sui trasporti: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Consenti l'invio di denaro ad altre compagnie: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Stazioni non uniformi: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nuovo pathfinding globale (NPF, sovrascrive NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Moltiplicatore di peso per simulare treni merci pesanti: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Consenti fermate passanti sulle strade delle città: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Consenti la costruzione di stazioni adiacenti: {ORANGE}{STRING}
@@ -1206,9 +1205,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Cambia impostazione
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Alcuni degli intervalli sottostanti sono incompatibili con l'impostazione scelta! Valori ammessi: 5-90% e 30-800 giorni
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Usa YAPF per le navi: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Usa YAPF per gli automezzi: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Usa YAPF per i treni: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Paesaggio 'temperato'
 STR_SUB_ARCTIC_LANDSCAPE                                        :Paesaggio 'sub-artico'
--- a/src/lang/japanese.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/japanese.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1049,7 +1049,6 @@
 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):{ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}重い列車のシミュレーションのための重量乗数の設定:{ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}町有道路上に通過点の建設を許容:{ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}隣接した駅の建設を許容:{ORANGE}{STRING}
@@ -1204,9 +1203,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}設定を変更します
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}以下のデフォルトの修理間隔は選択した設定に対応していません!5〜90%もしくは30〜800日が使用できます。
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}船舶にYAPFを使用:{ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}道路車両にYAPFを使用:{ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}列車にYAPFを使用:{ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :温帯国
 STR_SUB_ARCTIC_LANDSCAPE                                        :亜寒帯国
--- a/src/lang/korean.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/korean.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1049,7 +1049,6 @@
 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}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}마을이 소유중인 도로를 통과하는 버스 정류장 건설 허용: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}정거장 근처에 건물 짓기 허용: {ORANGE}{STRING}
@@ -1204,9 +1203,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}설정값 변경
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}아래 기본 점검간격의 일부 혹은 전체가 선택된 설정과 맞지 않습니다. 5-90%와 30-800일이 사용 가능합니다.
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}선박에 YAPF 사용 : {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}자동차에 YAPF 사용 : {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}열차에 YAPF 사용 : {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :온대 기후
 STR_SUB_ARCTIC_LANDSCAPE                                        :냉대 기후
--- a/src/lang/lithuanian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/lithuanian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1068,7 +1068,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Slinkti vaizdą pelei esant prie krašto: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Leisti papirkinėti miesto valdžią: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Nestandartines stoteles: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Globalus kelio radimo algoritmas (NPF, panaikina NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Krovinių svorio daugiklis skirtas imituoti prikrautus traukinius: {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_SMALL_AIRPORTS                               :{LTBLUE}Visada leisti statyti mazus oro uotus: {ORANGE}{STRING}
@@ -1173,9 +1172,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Keisti reiksmes
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Klaidingai nurodytas remonto intervalas. Intervalas dienomis: 30-800 d., procentais: 5-90%.
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Naudoti YAPF laivams: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Naudoti YAPF masinoms: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Naudoti YAPF traukiniams: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Normalus klimatas
 STR_SUB_ARCTIC_LANDSCAPE                                        :Sub-arktinis klimatas
--- a/src/lang/norwegian_bokmal.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/norwegian_bokmal.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1048,7 +1048,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Tillat kjøp av eksklusive transportrettigheter: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Tillat pengeoverføring til andre firmaer: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Uensartede stasjoner: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Ny global rutesøking (NGR, overstyrer NTK): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Vektmultiplikator for frakt til å simulere tunge tog: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Tillat gjennomkjøring av stoppesteder på veier som er eid av byene: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Tillat bygging av nærliggende stasjoner: {ORANGE}{STRING}
@@ -1203,9 +1202,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Endre innstillingsverdi
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Noen eller alle av standard vedlikeholdsintervall(ene) under er inkompatible med valgte instillinger! 5-90{NBSP}% og 30-800 dager er gyldige
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Skip skal bruke YAPF: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Kjøretøy skal bruke YAPF: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Tog skal bruke YAPF: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Temperert landskap
 STR_SUB_ARCTIC_LANDSCAPE                                        :subarktisk landskap
--- a/src/lang/norwegian_nynorsk.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/norwegian_nynorsk.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1047,7 +1047,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Gje høve til å kjøpe eksklusive transportretter: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Gje høve til å sende penger til andre firma: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Ikkje-einsarta stasjonar: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Ny global rutesøking (NGR, overstyrer NTK): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Vektmultiplikator for frakt til å simulere tunge tog: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Tillat å køyre gjennom stoppestadar på vegar som byane eig: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Tillat å byggje stasjonar inntil andre: {ORANGE}{STRING}
@@ -1202,9 +1201,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Endre innstillingsverdi
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Nokon eller alle standard-vedlikehaldsintervalla under er ikkje kompatible med valde innstillingar! 5-90 % og 30-800 dagar er gyldige
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Skip skal nytte YAPF: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Køyretøy skal nytte YAPF: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Tog skal nytte YAPF: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Temperert landskap
 STR_SUB_ARCTIC_LANDSCAPE                                        :subarktisk landskap
--- a/src/lang/piglatin.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/piglatin.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1039,7 +1039,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Anpay indowway enwhay ousemay isway atway ethay edgeway: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Allowway ibingbray ofway ethay ocallay authorityway: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Onuniformnay ationsstay: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Ewnay obalglay athfindingpay (NPFay, overridesway NTPay): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Eightway ultipliermay orfay eightfray otay imulatesay eavyhay ainstray: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Allowway ivedray-oughthray oadray opsstay onway owntay ownedway oadsray: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Allowway uildingbay adjacentway ationsstay: {ORANGE}{STRING}
@@ -1192,9 +1191,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Angechay ettingsay aluevay
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Omesay orway allway ofway ethay efaultday ervicesay intervalway(say) elowbay areway incompatibleway ithway ethay osenchay ettingsay! 5-90% andway 30-800 aysday areway alidvay
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Useway YAPFay orfay ipsshay: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Useway YAPFay orfay oadvehsray: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Useway YAPFay orfay ainstray: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Emperatetay andscapelay
 STR_SUB_ARCTIC_LANDSCAPE                                        :Ubsay-arcticway andscapelay
--- a/src/lang/polish.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/polish.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1133,7 +1133,6 @@
 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}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Pozwól na budowę przystanków typu ro-ro na drogach miejskich: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Pozwól na budowę stacji przyległych do stacji przeciwnika (z CTRL): {ORANGE}{STRING}
@@ -1288,9 +1287,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Zmiana wartości
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Niektóre lub wszystkie domyślne okresy między serwisowania są sprzeczne z wybranymi! 5-90% i 30-800 dni są poprawne
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Używaj YAPF dla statków: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Używaj YAPF dla samochodów: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Używaj YAPF dla pociągów: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Krajobraz umiarkowany
 STR_SUB_ARCTIC_LANDSCAPE                                        :Krajobraz arktyczny
--- a/src/lang/portuguese.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/portuguese.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1047,7 +1047,6 @@
 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}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Permitir estações de passagem em estradas das cidades: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Permitir construção de estações adjacentes: {ORANGE}{STRING}
@@ -1202,9 +1201,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Alterar valor
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Alguns ou todos os intervalo(s) de serviço predefinidos abaixo são incompatíveis com o valor escolhido! São válidos 5-90% e 30-800 dias
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Usar YAPF para navios: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Usar YAPF para veículos de estrada: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Usar YAPF para comboios: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Terreno temperado
 STR_SUB_ARCTIC_LANDSCAPE                                        :terreno subárctico
--- a/src/lang/romanian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/romanian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1047,7 +1047,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Permite cumpararea de drepturi exclusive de transport: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Permite transfer de bani catre alte companii: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Statii neuniforme: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nou pathfinding global(NPF, dezactiveaza NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Multiplicator greutate pt marfar pt simularea trenurilor grele: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Permite semafoare in intersectiile drumurilor din proprietatea orasului: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Permite construirea de statii adiacente: {ORANGE}{STRING}
@@ -1202,9 +1201,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Schimbã valoarea setãrii
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Unele sau toate din intervalurile de service alese sunt incompatibile cu setarea aleasa! Valorile valide sunt cuprinse intre 5-90% si 30-800 zile
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Foloseste YAPF pentru nave: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Foloseste YAPF pentru autoveh: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Foloseste YAPF pentru trenuri: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :peisajul temperat
 STR_SUB_ARCTIC_LANDSCAPE                                        :peisajul sub-arctic
--- a/src/lang/russian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/russian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1051,7 +1051,6 @@
 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 (замена оригинального): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Множитель увеличения веса груза для товарных поездов: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Позволять строить остановки на городских дорогах: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Разрешить строительство смежных станций: {ORANGE}{STRING}
@@ -1206,9 +1205,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Изменить значение
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Некоторые интервалы не совместимы с выбранной установкой. Допускаются значения 5-90% или 30-800 дней
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Алгоритм навигации YAPF для кораблей: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Алгоритм навигации YAPF для автотранспорта: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Алгоритм навигации YAPF для поездов: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Умеренный ландшафт
 STR_SUB_ARCTIC_LANDSCAPE                                        :Субарктический ландшафт
--- a/src/lang/simplified_chinese.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/simplified_chinese.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1035,7 +1035,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}当鼠标移动到屏幕边缘时移动屏幕:{ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{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}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}允许在城镇所有的道路上穿过禁行标志 {ORANGE}{STRING}
 
@@ -1153,9 +1152,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}改变设置值
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}下面一个或多个保养周期的值设置不对,应当在 0%-90% 或 30-800 天之内。
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}在船只上应用 YAPF:{ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}在汽车上应用 YAPF:{ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}在火车上应用 YAPE:{ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :温带景观
 STR_SUB_ARCTIC_LANDSCAPE                                        :寒带景观
--- a/src/lang/slovak.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/slovak.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1113,7 +1113,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Povolit zakúpenie exkluzívnych dopravných práv: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Umožnit posielanie penazí ostatným spolocnostiam: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Roznorode stanice: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Novy globalny algoritmus hladania cesty (NPF namiesto NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Váhový násobok pre nákladné vlaky: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Povolit prejazdné zastávky na mestských cestách: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Povolit stavbu oddelených staníc: {ORANGE}{STRING}
@@ -1268,9 +1267,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Zmenit hodnotu nastavenia
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Niektore alebo vsetky implicitne servisne intervaly su nekompatibilne s vybranym nastavenim. 5-90% a 30-800 dni su platne.
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Pouzit YAPF pre lode: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Pouzit YAPF pre vozidla: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Pouzit YAPF pre vlaky: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :krajina mierneho pasma
 STR_SUB_ARCTIC_LANDSCAPE                                        :subarkticka krajina
--- a/src/lang/slovenian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/slovenian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1090,7 +1090,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Dovoli nakup ekskluzivnih prevoznih dovoljenj: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Dovoli pošiljanje denarja drugim podjetjem: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Neenake postaje: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Novo skupno iskanje poti (NPF, prevlada NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Koeficient teže tovora za simulacijo težkih vlakov: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Dovoli prehodne postaje na cestah v lasti mest: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Dovoli gradnjo združljivih postaj: {ORANGE}{STRING}
@@ -1245,9 +1244,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Spremeni vrednost
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Nekatera ali vsa privzeta obdobja servisiranja spodaj niso združljiva z izborom! 5-90% in 30-800 dni je veljavno
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Uporabi YAPF za ladje: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Uporabi YAPF za cestna vozila: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Uporabi YAPF za vlake: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Zmerno podnebje
 STR_SUB_ARCTIC_LANDSCAPE                                        :Sub arktično podnebje
--- a/src/lang/spanish.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/spanish.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1050,7 +1050,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Permitir comprar derechos de transporte exclusivos: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Permitir enviar dinero a otras empresas: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Estaciones no uniformes: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Nuevo sistema de busq. de rutas global (NPF, anula a NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Carga el multiplicador de peso para simular trenes pesados: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Permite conducir en paradas sobre carreteras de ciudades: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Permitir construcción en estaciones contiguas : {ORANGE}{STRING}
@@ -1205,9 +1204,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Cambiar valor de la opción
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Alguno o todos los intervalos de servicio por defecto mostrados son incompatibles con la configuración elegida! 5-90% y 30-800 días son válidos
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Usar YAPF para barcos: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Usar YAPF para vehículos de carretera: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Usar YAPF para trenes: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Paisaje templado
 STR_SUB_ARCTIC_LANDSCAPE                                        :Paisaje sub-ártico
--- a/src/lang/swedish.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/swedish.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1048,7 +1048,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Tillåt köp av exklusiva transporträttigheter: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Tillåt skicka pengar till andra företag: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Icke-rektangulära stationer: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Ny globalt sätt att hitta rutt (NPF, åsidosätter NTP): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Godsfaktor för att simulera tunga tåg: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Tillåt genomfarts-stop på stadsägda vägar: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Tillåt byggande av närliggande stationer: {ORANGE}{STRING}
@@ -1203,9 +1202,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Ändra inställningsvärde
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Några eller alla av standard serviceintervalls-inställningarna är felaktiga! (5-90% och 30-800 dagar är giltiga inställningar)
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Använd YAPF för skepp: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Använd YAPF för fordon: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Använd YAPF för tåg: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Tempererat landskap
 STR_SUB_ARCTIC_LANDSCAPE                                        :Sub-arktiskt landskap
--- a/src/lang/traditional_chinese.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/traditional_chinese.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1043,7 +1043,6 @@
 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}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}可在鎮內興建路邊車站:{ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}容許興建相鄰車站: {ORANGE}{STRING}
@@ -1198,9 +1197,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}改變設定值
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}以下預設檢修期與揀選項目不相容! 合法設定為 5-90% 或 30-800 日
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}船隻使用新的尋路系統(YAPF):{ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}車輛使用新的尋路系統(YAPF):{ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}列車使用新的尋路系統:{ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :溫帶
 STR_SUB_ARCTIC_LANDSCAPE                                        :亞北極帶
--- a/src/lang/turkish.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/turkish.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1045,7 +1045,6 @@
 STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Şehrin ulaşım haklarını satın alma izinli: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Diğer şirketlere para gönderme izinli: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Özel istasyonlar: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Yeni evrensel yol bulma (NPF, NTP üzerinde): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Ağır yük trenleri için ağırlık çarpanı: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Şehiriçi yollara durak yapmak izinli: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Bitişik istasyonlar izinli: {ORANGE}{STRING}
@@ -1200,9 +1199,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Ayar değerini değiştir
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Bazi servis gecikmeleri aralık dışında: %5-%90 veya 30-800 gün arasında olmalı
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Gemiler için YAPF kullan: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Arabalar için YAPF kullan: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Trenler için YAPF kullan: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Ilıman iklim
 STR_SUB_ARCTIC_LANDSCAPE                                        :Soğuk iklim
--- a/src/lang/ukrainian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/ukrainian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1175,7 +1175,6 @@
 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}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Дозволити безпересадкові зупинки на муніципальних дорогах: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Дозволити будувати суміжні станції: {ORANGE}{STRING}
@@ -1330,9 +1329,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Змініть значення
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Одне чи декілька значень інтервалів несумісні за даних умов! Дозволено 5-90% та 30-800 днів
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Використовувати YAPF для кораблів: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Використовувати YAPF для авто: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Використовувати YAPF для поїздів: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Помірний ландшафт
 STR_SUB_ARCTIC_LANDSCAPE                                        :Субарктичний ландшафт
--- a/src/lang/unfinished/greek.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/unfinished/greek.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1030,7 +1030,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Μετακίνηση παραθύρου όταν είναι το ποντίκι στην άκρη: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{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}
 STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Επιτρέπεται η κίνηση μέσω των στάσεων σε δρόμους πόλεων : {ORANGE}{STRING}
 
@@ -1137,9 +1136,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Αλλαγή τιμής ρύθμισης
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Κάποια ή όλα τα προεπιλεγμένα διαστήματα επισκευών παρακάτω δεν είναι συμβατά με την επιλεγμένη ρύθμιση! 5-90% και 30-800 μέρες είναι τα αποδεκτά
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Χρησιμοποίηση YAPF για τα πλοία: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Χρησιμοποίηση YAPF για τα οχήματα: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Χρησιμοποίηση YAPF για τα τρένα: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Συγκρατημένο τοπίο
 STR_SUB_ARCTIC_LANDSCAPE                                        :Πολικό τοπίο
--- a/src/lang/unfinished/latvian.txt	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/lang/unfinished/latvian.txt	Fri Feb 22 00:25:54 2008 +0000
@@ -1024,7 +1024,6 @@
 STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Bi'di't logu kad pele ir ta' mala': {ORANGE}{STRING}
 STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Atl'aut viete'jo varas iesta'z'u piekukul'os'anu: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Ne-uniformas stacijas: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}Jauna' globa'la' cel'u kars'rutiza'cija (NPF, aizsta'j NTP): {ORANGE}{STRING}
 
 STR_CONFIG_PATCHES_SMALL_AIRPORTS                               :{LTBLUE}Vienme'r atl'aut mazas lidostas: {ORANGE}{STRING}
 
@@ -1114,9 +1113,6 @@
 
 STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Mainīt iestatījuma vērtību
 STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Daži vai visi apkalpošanas intervāli ir nesavietojami ar izvēlētajiem iestatījumiem! Der 5-90% un 30-800 dienas
-STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Izmantot YAPF kuģiem: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Izmantot YAPF autotransportam: {ORANGE}{STRING}
-STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Izmantot YAPF vilcieniem: {ORANGE}{STRING}
 
 STR_TEMPERATE_LANDSCAPE                                         :Mērenais klimats
 STR_SUB_ARCTIC_LANDSCAPE                                        :Subarktiskais klimats
--- a/src/main_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/main_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -977,8 +977,8 @@
 	if (HasBit(_display_opt, DO_WAYPOINTS))          SetBit(x,  9);
 	if (HasBit(_display_opt, DO_FULL_ANIMATION))     SetBit(x, 10);
 	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);
+	if (IsTransparencySet(TO_HOUSES))                SetBit(x, 12);
+	if (IsTransparencySet(TO_SIGNS))                 SetBit(x, 13);
 	WP(w, menu_d).checked_items = x;
 }
 
@@ -1668,7 +1668,7 @@
 {
 	char buf[512];
 	StringID str;
-	const char *s;
+	const char *s, *last;
 	char *d;
 	DrawPixelInfo tmp_dpi, *old_dpi;
 	int x;
@@ -1685,19 +1685,22 @@
 
 	s = buf;
 	d = buffer;
+	last = lastof(buffer);
 
 	for (;;) {
 		WChar c = Utf8Consume(&s);
 		if (c == 0) {
-			*d = '\0';
 			break;
-		} else if (*s == 0x0D) {
+		} else if (c == 0x0D) {
+			if (d + 4 >= last) break;
 			d[0] = d[1] = d[2] = d[3] = ' ';
 			d += 4;
 		} else if (IsPrintable(c)) {
+			if (d + Utf8CharLen(c) >= last) break;
 			d += Utf8Encode(d, c);
 		}
 	}
+	*d = '\0';
 
 	if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true;
 
@@ -1914,6 +1917,7 @@
 			case '6' | WKC_CTRL:
 			case '7' | WKC_CTRL:
 			case '8' | WKC_CTRL:
+			case '9' | WKC_CTRL:
 				/* Transparency toggle hot keys */
 				ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL)));
 				MarkWholeScreenDirty();
--- a/src/misc_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/misc_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -219,6 +219,7 @@
 	"  Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles",
 	"  Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework",
 	"  Loïc Guilloux (glx) - General coding",
+	"  Christoph Elsenhans (frosch) - 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",
--- a/src/newgrf.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -93,23 +93,6 @@
 static GrfDataType _grf_data_type;
 
 
-enum grfspec_feature {
-	GSF_TRAIN,
-	GSF_ROAD,
-	GSF_SHIP,
-	GSF_AIRCRAFT,
-	GSF_STATION,
-	GSF_CANAL,
-	GSF_BRIDGE,
-	GSF_TOWNHOUSE,
-	GSF_GLOBALVAR,
-	GSF_INDUSTRYTILES,
-	GSF_INDUSTRIES,
-	GSF_CARGOS,
-	GSF_SOUNDFX,
-};
-
-
 typedef void (*SpecialSpriteHandler)(byte *buf, int len);
 
 static const uint _vehcounts[4] = {
@@ -306,6 +289,26 @@
 	return colour;
 }
 
+/** Map the colour modifiers of TTDPatch to those that Open is using.
+ * @param grf_sprite pointer to the structure been modified
+ */
+static void MapSpriteMappingRecolour(PalSpriteID *grf_sprite)
+{
+	if (HasBit(grf_sprite->pal, 14)) {
+		ClrBit(grf_sprite->pal, 14);
+		SetBit(grf_sprite->sprite, SPRITE_MODIFIER_OPAQUE);
+	}
+
+	if (HasBit(grf_sprite->sprite, 14)) {
+		ClrBit(grf_sprite->sprite, 14);
+		SetBit(grf_sprite->sprite, PALETTE_MODIFIER_TRANSPARENT);
+	}
+
+	if (HasBit(grf_sprite->sprite, 15)) {
+		ClrBit(grf_sprite->sprite, 15);
+		SetBit(grf_sprite->sprite, PALETTE_MODIFIER_COLOR);
+	}
+}
 
 typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len);
 
@@ -374,20 +377,22 @@
 
 				if (rvi->railveh_type == RAILVEH_MULTIHEAD) runcostfact /= 2;
 
-				rvi->running_cost_base = runcostfact;
+				rvi->running_cost = runcostfact;
 			} break;
 
 			case 0x0E: { // Running cost base
 				uint32 base = grf_load_dword(&buf);
 
-				switch (base) {
-					case 0x4C30: rvi->running_cost_class = 0; break;
-					case 0x4C36: rvi->running_cost_class = 1; break;
-					case 0x4C3C: rvi->running_cost_class = 2; break;
-					case 0: break; // Used by wagons
-					default:
-						grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base);
-						break;
+				/* These magic numbers are used in GRFs to specify the base cost:
+				 * http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts
+				 */
+				if (base == 0) {
+					rvi->running_cost_class = 0xFF;
+				} else if (base < 0x4B34 || base > 0x4C54 || (base - 0x4B34) % 6 != 0) {
+					grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base);
+				} else {
+					/* Convert the magic number to an index into the price data */
+					rvi->running_cost_class = (base - 0x4B34) / 6;
 				}
 			} break;
 
@@ -408,14 +413,14 @@
 					if (rvi->railveh_type != RAILVEH_MULTIHEAD) {
 						// adjust power and running cost if needed
 						rvi->power /= 2;
-						rvi->running_cost_base /= 2;
+						rvi->running_cost /= 2;
 					}
 					rvi->railveh_type = RAILVEH_MULTIHEAD;
 				} else {
 					if (rvi->railveh_type == RAILVEH_MULTIHEAD) {
 						// adjust power and running cost if needed
 						rvi->power *= 2;
-						rvi->running_cost_base *= 2;
+						rvi->running_cost *= 2;
 					}
 					rvi->railveh_type = rvi->power == 0 ?
 						RAILVEH_WAGON : RAILVEH_SINGLEHEAD;
@@ -591,12 +596,23 @@
 				rvi->running_cost = grf_load_byte(&buf);
 				break;
 
-			case 0x0A: // Running cost base
-				/** @todo : I have no idea. --pasky
-				 * I THINK it is used for overriding the base cost of all road vehicle (_price.roadveh_base) --belugas */
-				grf_load_dword(&buf);
-				ret = true;
-				break;
+			case 0x0A: { // Running cost base
+				uint32 base= grf_load_dword(&buf);
+
+				/* These magic numbers are used in GRFs to specify the base cost:
+				 * http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts
+				 */
+				if (base == 0) {
+					rvi->running_cost_class = 0xFF;
+				} else if (base < 0x4B34 || base > 0x4C54 || (base - 0x4B34) % 6 != 0) {
+					grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base);
+				} else {
+					/* Convert the magic number to an index into the price data */
+					rvi->running_cost_class = (base - 0x4B34) / 6;
+				}
+
+				break;
+			}
 
 			case 0x0E: { // Sprite ID
 				uint8 spriteid = grf_load_byte(&buf);
@@ -946,25 +962,15 @@
 					uint seq_count = 0;
 
 					dts->seq = NULL;
-					dts->ground_sprite = grf_load_word(&buf);
-					dts->ground_pal = grf_load_word(&buf);
-					if (dts->ground_sprite == 0) continue;
-					if (HasBit(dts->ground_pal, 15)) {
-						ClrBit(dts->ground_pal, 15);
-						SetBit(dts->ground_sprite, SPRITE_MODIFIER_USE_OFFSET);
+					dts->ground.sprite = grf_load_word(&buf);
+					dts->ground.pal = grf_load_word(&buf);
+					if (dts->ground.sprite == 0) continue;
+					if (HasBit(dts->ground.pal, 15)) {
+						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);
-					}
+
+					MapSpriteMappingRecolour(&dts->ground);
 
 					while (buf < *bufp + len) {
 						DrawTileSeqStruct *dtss;
@@ -980,27 +986,16 @@
 						dtss->size_x = grf_load_byte(&buf);
 						dtss->size_y = grf_load_byte(&buf);
 						dtss->size_z = grf_load_byte(&buf);
-						dtss->image = grf_load_word(&buf);
-						dtss->pal = grf_load_word(&buf);
+						dtss->image.sprite = grf_load_word(&buf);
+						dtss->image.pal = grf_load_word(&buf);
 
 						/* Remap flags as ours collide */
-						if (HasBit(dtss->pal, 15)) {
-							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.pal, 15)) {
+							ClrBit(dtss->image.pal, 15);
+							SetBit(dtss->image.sprite, SPRITE_MODIFIER_USE_OFFSET);
 						}
 
-						if (HasBit(dtss->image, 15)) {
-							ClrBit(dtss->image, 15);
-							SetBit(dtss->image, PALETTE_MODIFIER_COLOR);
-						}
-						if (HasBit(dtss->image, 14)) {
-							ClrBit(dtss->image, 14);
-							SetBit(dtss->image, PALETTE_MODIFIER_TRANSPARENT);
-						}
+						MapSpriteMappingRecolour(&dtss->image);
 					}
 				}
 				break;
@@ -1177,7 +1172,7 @@
 	}
 
 	for (int i = 0; i < numinfo; i++) {
-		Bridge *bridge = &_bridge[brid + i];
+		BridgeSpec *bridge = &_bridge[brid + i];
 
 		switch (prop) {
 			case 0x08: // Year of availability
@@ -1224,15 +1219,10 @@
 						SpriteID image = grf_load_word(&buf);
 						SpriteID pal   = grf_load_word(&buf);
 
-						if (HasBit(pal, 15)) {
-							SetBit(image, PALETTE_MODIFIER_TRANSPARENT);
-						}
-
-						/* Clear old color modifer bit */
-						ClrBit(image, 15);
-
 						bridge->sprite_table[tableid][sprite].sprite = image;
 						bridge->sprite_table[tableid][sprite].pal    = pal;
+
+						MapSpriteMappingRecolour(&bridge->sprite_table[tableid][sprite]);
 					}
 				}
 			} break;
@@ -1245,6 +1235,17 @@
 				bridge->avail_year = Clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR);
 				break;
 
+			case 0x10: { // purchase string
+				StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf));
+				if (newone != STR_UNDEFINED) bridge->material = newone;
+				} break;
+
+			case 0x11: // description of bridge with rails or roads
+			case 0x12: {
+				StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf));
+				if (newone != STR_UNDEFINED) bridge->transport_name[prop - 0x11] = newone;
+				} break;
+
 			default:
 				ret = true;
 				break;
@@ -1488,21 +1489,11 @@
 				}
 			} break;
 
-			case 0x09: { // Cargo translation table
-				if (gvid != 0) {
-					if (i == 0) grfmsg(1, "InitChangeInfo: Cargo translation table must start at zero");
-					/* Skip data */
-					buf += 4;
-					break;
-				}
-				if (i == 0) {
-					free(_cur_grffile->cargo_list);
-					_cur_grffile->cargo_max = numinfo;
-					_cur_grffile->cargo_list = MallocT<CargoLabel>(numinfo);
-				}
-				CargoLabel cl = grf_load_dword(&buf);
-				_cur_grffile->cargo_list[i] = BSWAP32(cl);
-			} break;
+			case 0x09: // Cargo translation table
+				/* This is loaded during the reservation stage, so just skip it here. */
+				/* Each entry is 4 bytes. */
+				buf += 4;
+				break;
 
 			case 0x0A: { // Currency display names
 				uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
@@ -2127,7 +2118,7 @@
 				break;
 
 			case 0x24: // name for nearby station
-				indsp->station_name = GRFMappedStringID(grf_load_dword(&buf), _cur_grffile->grfid);
+				indsp->station_name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
 				break;
 
 			default:
@@ -2167,7 +2158,7 @@
 		/* GSF_CANAL */        CanalChangeInfo,
 		/* GSF_BRIDGE */       BridgeChangeInfo,
 		/* GSF_TOWNHOUSE */    TownHouseChangeInfo,
-		/* GSF_GLOBALVAR */    NULL, /* Global variables are handled during reservation */
+		/* GSF_GLOBALVAR */    GlobalVarChangeInfo,
 		/* GSF_INDUSTRYTILES */IndustrytilesChangeInfo,
 		/* GSF_INDUSTRIES */   IndustriesChangeInfo,
 		/* GSF_CARGOS */       NULL, /* Cargo is handled during reservation */
@@ -2287,7 +2278,7 @@
 {
 	byte *bufend = buf + len;
 
-	if (!check_length(len, 6, "InitChangeInfo")) return;
+	if (!check_length(len, 6, "ReserveChangeInfo")) return;
 	buf++;
 	uint8 feature  = grf_load_byte(&buf);
 
@@ -2307,7 +2298,23 @@
 				ignoring = CargoChangeInfo(index, numinfo, prop, &buf, bufend - buf);
 				break;
 			case GSF_GLOBALVAR:
-				ignoring = GlobalVarChangeInfo(index, numinfo, prop, &buf, bufend - buf);
+				switch (prop) {
+					case 0x09: // Cargo Translation Table
+						if (index != 0) {
+							grfmsg(1, "ReserveChangeInfo: Cargo translation table must start at zero");
+							return;
+						}
+
+						free(_cur_grffile->cargo_list);
+						_cur_grffile->cargo_max = numinfo;
+						_cur_grffile->cargo_list = MallocT<CargoLabel>(numinfo);
+
+						for (uint i = 0; i < numinfo; i++) {
+							CargoLabel cl = grf_load_dword(&buf);
+							_cur_grffile->cargo_list[i] = BSWAP32(cl);
+						}
+						break;
+				}
 				break;
 		}
 
@@ -2652,27 +2659,18 @@
 					group->g.layout.dts = CallocT<DrawTileSprites>(1);
 
 					/* Groundsprite */
-					group->g.layout.dts->ground_sprite = grf_load_word(&buf);
-					group->g.layout.dts->ground_pal    = grf_load_word(&buf);
+					group->g.layout.dts->ground.sprite = grf_load_word(&buf);
+					group->g.layout.dts->ground.pal    = grf_load_word(&buf);
+
 					/* Remap transparent/colour modifier bits */
-					if (HasBit(group->g.layout.dts->ground_sprite, 14)) {
-						ClrBit(group->g.layout.dts->ground_sprite, 14);
-						SetBit(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT);
-					}
-					if (HasBit(group->g.layout.dts->ground_sprite, 15)) {
-						ClrBit(group->g.layout.dts->ground_sprite, 15);
-						SetBit(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_COLOR);
-					}
-					if (HasBit(group->g.layout.dts->ground_pal, 14)) {
-						ClrBit(group->g.layout.dts->ground_pal, 14);
-						SetBit(group->g.layout.dts->ground_sprite, SPRITE_MODIFIER_OPAQUE);
-					}
-					if (HasBit(group->g.layout.dts->ground_pal, 15)) {
+					MapSpriteMappingRecolour(&group->g.layout.dts->ground);
+
+					if (HasBit(group->g.layout.dts->ground.pal, 15)) {
 						/* Bit 31 set means this is a custom sprite, so rewrite it to the
 						 * last spriteset defined. */
-						SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground_sprite, 0, 14) * sprites;
-						SB(group->g.layout.dts->ground_sprite, 0, SPRITE_WIDTH, sprite);
-						ClrBit(group->g.layout.dts->ground_pal, 15);
+						SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground.sprite, 0, 14) * sprites;
+						SB(group->g.layout.dts->ground.sprite, 0, SPRITE_WIDTH, sprite);
+						ClrBit(group->g.layout.dts->ground.pal, 15);
 					}
 
 					group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1);
@@ -2680,29 +2678,19 @@
 					for (i = 0; i < num_sprites; i++) {
 						DrawTileSeqStruct *seq = (DrawTileSeqStruct*)&group->g.layout.dts->seq[i];
 
-						seq->image = grf_load_word(&buf);
-						seq->pal   = grf_load_word(&buf);
+						seq->image.sprite = grf_load_word(&buf);
+						seq->image.pal   = grf_load_word(&buf);
 						seq->delta_x = grf_load_byte(&buf);
 						seq->delta_y = grf_load_byte(&buf);
 
-						if (HasBit(seq->image, 14)) {
-							ClrBit(seq->image, 14);
-							SetBit(seq->image, PALETTE_MODIFIER_TRANSPARENT);
-						}
-						if (HasBit(seq->image, 15)) {
-							ClrBit(seq->image, 15);
-							SetBit(seq->image, PALETTE_MODIFIER_COLOR);
-						}
-						if (HasBit(seq->pal, 14)) {
-							ClrBit(seq->pal, 14);
-							SetBit(seq->image, SPRITE_MODIFIER_OPAQUE);
-						}
-						if (HasBit(seq->pal, 15)) {
+						MapSpriteMappingRecolour(&seq->image);
+
+						if (HasBit(seq->image.pal, 15)) {
 							/* Bit 31 set means this is a custom sprite, so rewrite it to the
 							 * last spriteset defined. */
-							SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image, 0, 14) * sprites;
-							SB(seq->image, 0, SPRITE_WIDTH, sprite);
-							ClrBit(seq->pal, 15);
+							SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image.sprite, 0, 14) * sprites;
+							SB(seq->image.sprite, 0, SPRITE_WIDTH, sprite);
+							ClrBit(seq->image.pal, 15);
 						}
 
 						if (type > 0) {
@@ -3089,6 +3077,11 @@
 	 * W cid           cargo ID (sprite group ID) for this type of cargo
 	 * W def-cid       default cargo ID (sprite group ID) */
 
+	if (_cur_grffile->spritegroups == 0) {
+		grfmsg(1, "FeatureMapSpriteGroup: No sprite groups to work on! Skipping");
+		return;
+	}
+
 	if (!check_length(len, 6, "FeatureMapSpriteGroup")) return;
 
 	uint8 feature = buf[1];
@@ -3099,7 +3092,12 @@
 
 	/* If idcount is zero, this is a feature callback */
 	if (idcount == 0) {
-		grfmsg(2, "FeatureMapSpriteGroup: Feature callbacks not implemented yet");
+		byte *bp = &buf[4];
+		uint16 groupid = grf_load_word(&bp);
+
+		grfmsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature %d", feature);
+
+		AddGenericCallback(feature, _cur_grffile, _cur_grffile->spritegroups[groupid]);
 		return;
 	}
 
@@ -3109,11 +3107,6 @@
 	grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d",
 			feature, idcount, cidcount, wagover);
 
-	if (_cur_grffile->spritegroups == 0) {
-		grfmsg(1, "FeatureMapSpriteGroup: No sprite groups to work on! Skipping");
-		return;
-	}
-
 	switch (feature) {
 		case GSF_TRAIN:
 		case GSF_ROAD:
@@ -3435,15 +3428,131 @@
 	grfmsg(3, "SkipAct5: Skipping %d sprites", _skip_sprites);
 }
 
-static uint32 GetParamVal(byte param, uint32 *cond_val)
+/**
+ * Reads a variable common to VarAction2 and Action7/9/D.
+ *
+ * Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'.
+ * If a variable is not accessible from all four actions, it is handled in the action specific functions.
+ *
+ * @param param variable number (as for VarAction2, for Action7/9/D you have to subtract 0x80 first).
+ * @param value returns the value of the variable.
+ * @return true iff the variable is known and the value is returned in 'value'.
+ */
+bool GetGlobalVariable(byte param, uint32 *value)
 {
 	switch (param) {
-		case 0x81: // current year
-			return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
-
-		case 0x83: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland
-			return _opt.landscape;
-
+		case 0x00: // current date
+			*value = max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
+			return true;
+
+		case 0x01: // current year
+			*value = Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
+			return true;
+
+		case 0x02: // current month
+			*value = _cur_month;
+			return true;
+
+		case 0x03: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland
+			*value = _opt.landscape;
+			return true;
+
+		case 0x06: // road traffic side, bit 4 clear=left, set=right
+			*value = _opt.road_side << 4;
+			return true;
+
+		case 0x09: // date fraction
+			*value = _date_fract;
+			return true;
+
+		case 0x0A: // animation counter
+			*value = _tick_counter;
+			return true;
+
+		case 0x0B: { // TTDPatch version
+			uint major    = 2;
+			uint minor    = 6;
+			uint revision = 1; // special case: 2.0.1 is 2.0.10
+			uint build    = 1382;
+			*value = (major << 24) | (minor << 20) | (revision << 16) | build;
+			return true;
+		}
+
+		case 0x0D: // TTD Version, 00=DOS, 01=Windows
+			*value = !_use_dos_palette;
+			return true;
+
+		case 0x0E: // Y-offset for train sprites
+			*value = _traininfo_vehicle_pitch;
+			return true;
+
+		case 0x0F: // Rail track type cost factors
+			*value = 0;
+			SB(*value, 0, 8, _railtype_cost_multiplier[0]); // normal rail
+			if (_patches.disable_elrails) {
+				/* skip elrail multiplier - disabled */
+				SB(*value, 8, 8, _railtype_cost_multiplier[2]); // monorail
+			} else {
+				SB(*value, 8, 8, _railtype_cost_multiplier[1]); // electified railway
+				/* Skip monorail multiplier - no space in result */
+			}
+			SB(*value, 16, 8, _railtype_cost_multiplier[3]); // maglev
+			return true;
+
+		case 0x11: // current rail tool type
+			*value = 0;
+			return true;
+
+		case 0x12: // Game mode
+			*value = _game_mode;
+			return true;
+
+		/* case 0x13: // Tile refresh offset to left    not implemented */
+		/* case 0x14: // Tile refresh offset to right   not implemented */
+		/* case 0x15: // Tile refresh offset upwards    not implemented */
+		/* case 0x16: // Tile refresh offset downwards  not implemented */
+		/* case 0x17: // temperate snow line            not implemented */
+
+		case 0x1A: // Always -1
+			*value = UINT_MAX;
+			return true;
+
+		case 0x1B: // Display options
+			*value = GB(_display_opt, 0, 6);
+			return true;
+
+		case 0x1D: // TTD Platform, 00=TTDPatch, 01=OpenTTD
+			*value = 1;
+			return true;
+
+		case 0x1E: // Miscellaneous GRF features
+			*value = _misc_grf_features;
+			return true;
+
+		/* case 0x1F: // locale dependent settings not implemented */
+
+		case 0x20: // snow line height
+			*value = _opt.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF;
+			return true;
+
+		case 0x21: { // OpenTTD version
+			extern uint32 _openttd_newgrf_version;
+			*value = _openttd_newgrf_version;
+			return true;
+		}
+
+		default: return false;
+	}
+}
+
+static uint32 GetParamVal(byte param, uint32 *cond_val)
+{
+	/* First handle variable common with VarAction2 */
+	uint32 value;
+	if (GetGlobalVariable(param - 0x80, &value)) return value;
+
+	/* Non-common variable */
+	switch (param) {
 		case 0x84: { // GRF loading stage
 			uint32 res = 0;
 
@@ -3463,42 +3572,10 @@
 				return param_val;
 			}
 
-		case 0x86: // road traffic side, bit 4 clear=left, set=right
-			return _opt.road_side << 4;
-
 		case 0x88: // GRF ID check
 			return 0;
 
-		case 0x8B: { // TTDPatch version
-			uint major    = 2;
-			uint minor    = 6;
-			uint revision = 1; // special case: 2.0.1 is 2.0.10
-			uint build    = 1382;
-			return (major << 24) | (minor << 20) | (revision << 16) | build;
-		}
-
-		case 0x8D: // TTD Version, 00=DOS, 01=Windows
-			return !_use_dos_palette;
-
-		case 0x8E: // Y-offset for train sprites
-			return _traininfo_vehicle_pitch;
-
-		case 0x92: // Game mode
-			return _game_mode;
-
-		case 0x9A: // Always -1
-			return UINT_MAX;
-
-		case 0x9D: // TTD Platform, 00=TTDPatch, 01=OpenTTD
-			return 1;
-
-		case 0x9E: // Miscellaneous GRF features
-			return _misc_grf_features;
-
-		case 0xA1: { // OpenTTD version
-			extern uint32 _openttd_newgrf_version;
-			return _openttd_newgrf_version;
-		}
+		/* case 0x99: Global ID offest not implemented */
 
 		default:
 			/* GRF Parameter */
@@ -4352,6 +4429,10 @@
 			_traininfo_vehicle_width = HasGrfMiscBit(GMB_TRAIN_WIDTH_32_PIXELS) ? 32 : 29;
 			break;
 
+		case 0x9F: // locale-dependent settings
+			grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target);
+			break;
+
 		default:
 			if (target < 0x80) {
 				_cur_grffile->param[target] = res;
@@ -5085,15 +5166,8 @@
 	/* Copy/reset original engine info data */
 	SetupEngines();
 
-	/* Copy/reset original bridge info data
-	 * First, free sprite table data */
-	for (uint i = 0; i < MAX_BRIDGES; i++) {
-		if (_bridge[i].sprite_table != NULL) {
-			for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]);
-			free(_bridge[i].sprite_table);
-		}
-	}
-	memcpy(&_bridge, &orig_bridge, sizeof(_bridge));
+	/* Copy/reset original bridge info data */
+	ResetBridges();
 
 	/* Reset refit/cargo class data */
 	memset(&cargo_allowed, 0, sizeof(cargo_allowed));
@@ -5108,6 +5182,9 @@
 	UnloadCustomEngineSprites();
 	ResetEngineListOrder();
 
+	/* Reset generic feature callback lists */
+	ResetGenericCallbacks();
+
 	/* Reset price base data */
 	ResetPriceBaseMultipliers();
 
--- a/src/newgrf.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf.h	Fri Feb 22 00:25:54 2008 +0000
@@ -32,6 +32,23 @@
 	GMB_CATENARY_ON_3RD_TRACK  = 5, // Unsupported.
 };
 
+enum GrfSpecFeature {
+	GSF_TRAIN,
+	GSF_ROAD,
+	GSF_SHIP,
+	GSF_AIRCRAFT,
+	GSF_STATION,
+	GSF_CANAL,
+	GSF_BRIDGE,
+	GSF_TOWNHOUSE,
+	GSF_GLOBALVAR,
+	GSF_INDUSTRYTILES,
+	GSF_INDUSTRIES,
+	GSF_CARGOS,
+	GSF_SOUNDFX,
+	GSF_END,
+};
+
 struct GRFLabel {
 	byte label;
 	uint32 nfo_line;
@@ -109,5 +126,6 @@
 void CDECL grfmsg(int severity, const char *str, ...);
 
 bool HasGrfMiscBit(GrfMiscBit bit);
+bool GetGlobalVariable(byte param, uint32 *value);
 
 #endif /* NEWGRF_H */
--- a/src/newgrf_cargo.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_cargo.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -115,9 +115,7 @@
 
 uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile)
 {
-	/* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */
-	if (grffile->grf_version < 7) return cargo;
-
+	/* Note: All grf versions use CargoBit here. Pre-version 7 do NOT use the 'climate dependent' ID. */
 	const CargoSpec *cs = GetCargo(cargo);
 
 	/* If the GRF contains a translation table (and the cargo is in the table)
--- a/src/newgrf_commons.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_commons.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -91,11 +91,6 @@
 		}
 	}
 
-	/* No mapping found, try the overrides */
-	for (uint16 id = 0; id < max_offset; id++) {
-		if (entity_overrides[id] == grf_local_id && grfid_overrides[id] == grfid) return id;
-	}
-
 	return invalid_ID;
 }
 
@@ -169,6 +164,24 @@
 	}
 }
 
+/** Return the ID (if ever available) of a previously inserted entity.
+ * @param grf_local_id ID of this enity withing the grfID
+ * @param grfid ID of the grf file
+ * @return the ID of the candidate, of the Invalid flag item ID
+ */
+uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid)
+{
+	uint16 id = OverrideManagerBase::GetID(grf_local_id, grfid);
+	if (id != invalid_ID) return id;
+
+	/* No mapping found, try the overrides */
+	for (id = 0; id < max_offset; id++) {
+		if (entity_overrides[id] == grf_local_id && grfid_overrides[id] == grfid) return id;
+	}
+
+	return invalid_ID;
+}
+
 /** Method to find an entity ID and to mark it as reserved for the Industry to be included.
  * @param grf_local_id ID used by the grf file for pre-installation work (equivalent of TTDPatch's setid
  * @param grfid ID of the current grf file
@@ -281,7 +294,7 @@
 	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);
+	if (IsRailwayStationTile(tile) && GetRailStationAxis(tile) == AXIS_Y) Swap(x, y);
 
 	/* Make sure we never roam outside of the map */
 	return TILE_MASK(tile + TileDiffXY(x, y));
--- a/src/newgrf_commons.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_commons.h	Fri Feb 22 00:25:54 2008 +0000
@@ -49,7 +49,7 @@
 	virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id);
 
 	uint16 GetSubstituteID(byte entity_id);
-	uint16 GetID(uint8 grf_local_id, uint32 grfid);
+	virtual uint16 GetID(uint8 grf_local_id, uint32 grfid);
 
 	inline uint16 GetMaxMapping() { return max_new_entities; }
 	inline uint16 GetMaxOffset() { return max_offset; }
@@ -72,6 +72,7 @@
 			OverrideManagerBase(offset, maximum, invalid) {}
 
 	virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id);
+	virtual uint16 GetID(uint8 grf_local_id, uint32 grfid);
 	void SetEntitySpec(IndustrySpec *inds);
 };
 
--- a/src/newgrf_config.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_config.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -277,7 +277,7 @@
 			_all_grfs = c;
 		} else {
 			/* Insert file into list at a position determined by its
-				* name, so the list is sorted as we go along */
+			 * name, so the list is sorted as we go along */
 			GRFConfig **pd, *d;
 			bool stop = false;
 			for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) {
@@ -285,8 +285,11 @@
 				/* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name,
 				 *  before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of
 				 *  just after the first with the same name. Avoids doubles in the list. */
-				if (strcasecmp(c->name, d->name) <= 0) stop = true;
-				else if (stop) break;
+				if (strcasecmp(c->name, d->name) <= 0) {
+					stop = true;
+				} else if (stop) {
+					break;
+				}
 			}
 			if (added) {
 				c->next = d;
@@ -299,7 +302,7 @@
 
 	if (!added) {
 		/* File couldn't be opened, or is either not a NewGRF or is a
-			* 'system' NewGRF or it's already known, so forget about it. */
+		 * 'system' NewGRF or it's already known, so forget about it. */
 		free(c->filename);
 		free(c->name);
 		free(c->info);
--- a/src/newgrf_engine.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_engine.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -694,14 +694,14 @@
 		case 0x4F: return GB(v->reliability, 8, 8);
 		case 0x50: return v->reliability_spd_dec;
 		case 0x51: return GB(v->reliability_spd_dec, 8, 8);
-		case 0x52: return ClampToI32(v->profit_this_year);
-		case 0x53: return GB(ClampToI32(v->profit_this_year),  8, 24);
-		case 0x54: return GB(ClampToI32(v->profit_this_year), 16, 16);
-		case 0x55: return GB(ClampToI32(v->profit_this_year), 24,  8);
-		case 0x56: return ClampToI32(v->profit_last_year);
-		case 0x57: return GB(ClampToI32(v->profit_last_year),  8, 24);
-		case 0x58: return GB(ClampToI32(v->profit_last_year), 16, 16);
-		case 0x59: return GB(ClampToI32(v->profit_last_year), 24,  8);
+		case 0x52: return ClampToI32(v->GetDisplayProfitThisYear());
+		case 0x53: return GB(ClampToI32(v->GetDisplayProfitThisYear()),  8, 24);
+		case 0x54: return GB(ClampToI32(v->GetDisplayProfitThisYear()), 16, 16);
+		case 0x55: return GB(ClampToI32(v->GetDisplayProfitThisYear()), 24,  8);
+		case 0x56: return ClampToI32(v->GetDisplayProfitLastYear());
+		case 0x57: return GB(ClampToI32(v->GetDisplayProfitLastYear()),  8, 24);
+		case 0x58: return GB(ClampToI32(v->GetDisplayProfitLastYear()), 16, 16);
+		case 0x59: return GB(ClampToI32(v->GetDisplayProfitLastYear()), 24,  8);
 		case 0x5A: return v->Next() == NULL ? INVALID_VEHICLE : v->Next()->index;
 		case 0x5C: return ClampToI32(v->value);
 		case 0x5D: return GB(ClampToI32(v->value),  8, 24);
@@ -765,7 +765,11 @@
 	uint totalsets;
 	uint set;
 
-	if (v == NULL) return group->g.real.loading[0];
+	if (v == NULL) {
+		if (group->g.real.num_loading > 0) return group->g.real.loading[0];
+		if (group->g.real.num_loaded  > 0) return group->g.real.loaded[0];
+		return NULL;
+	}
 
 	bool in_motion = v->First()->current_order.type != OT_LOADING;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/newgrf_generic.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -0,0 +1,179 @@
+/* $Id$ */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "variables.h"
+#include "landscape.h"
+#include "debug.h"
+#include "newgrf.h"
+#include "newgrf_callbacks.h"
+#include "newgrf_commons.h"
+#include "newgrf_spritegroup.h"
+#include "newgrf_generic.h"
+#include "tile_map.h"
+#include <list>
+
+
+struct GenericCallback {
+	const GRFFile *file;
+	const SpriteGroup *group;
+
+	GenericCallback(const GRFFile *file, const SpriteGroup *group) :
+		file(file),
+		group(group)
+	{ }
+};
+
+typedef std::list<GenericCallback> GenericCallbackList;
+
+static GenericCallbackList _gcl[GSF_END];
+
+
+/**
+ * Reset all generic feature callback sprite groups.
+ */
+void ResetGenericCallbacks()
+{
+	for (uint8 feature = 0; feature < lengthof(_gcl); feature++) {
+		_gcl[feature].clear();
+	}
+}
+
+
+/**
+ * Add a generic feature callback sprite group to the appropriate feature list.
+ * @param feature
+ * @param file
+ * @param group
+ */
+void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *group)
+{
+	if (feature >= lengthof(_gcl)) {
+		grfmsg(5, "AddGenericCallback: Unsupported feature 0x%02X", feature);
+		return;
+	}
+
+	/* Generic feature callbacks are evaluated in reverse (i.e. the last group
+	 * to be added is evaluated first, etc) thus we push the group to the
+	 * beginning of the list so a standard iterator will do the right thing. */
+	_gcl[feature].push_front(GenericCallback(file, group));
+}
+
+
+static uint32 GenericCallbackGetRandomBits(const ResolverObject *object)
+{
+	return 0;
+}
+
+
+static uint32 GenericCallbackGetTriggers(const ResolverObject *object)
+{
+	return 0;
+}
+
+
+static void GenericCallbackSetTriggers(const ResolverObject *object, int triggers)
+{
+	return;
+}
+
+
+static uint32 GenericCallbackGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
+{
+	switch (variable) {
+		case 0x40: return object->u.generic.cargo_type;
+
+		case 0x80: return object->u.generic.cargo_type;
+		case 0x81: return object->u.generic.cargo_type;
+		case 0x82: return object->u.generic.default_selection;
+		case 0x83: return object->u.generic.src_industry;
+		case 0x84: return object->u.generic.dst_industry;
+		case 0x85: return object->u.generic.distance;
+		case 0x86: return object->u.generic.event;
+		case 0x87: return object->u.generic.count;
+		case 0x88: return object->u.generic.station_size;
+
+		default: break;
+	}
+
+	DEBUG(grf, 1, "Unhandled generic feature property 0x%02X", variable);
+
+	*available = false;
+	return 0;
+}
+
+
+static const SpriteGroup *GenericCallbackResolveReal(const ResolverObject *object, const SpriteGroup *group)
+{
+	if (group->g.real.num_loaded == 0) return NULL;
+
+	return group->g.real.loaded[0];
+}
+
+
+static inline void NewGenericResolver(ResolverObject *res)
+{
+	res->GetRandomBits = &GenericCallbackGetRandomBits;
+	res->GetTriggers   = &GenericCallbackGetTriggers;
+	res->SetTriggers   = &GenericCallbackSetTriggers;
+	res->GetVariable   = &GenericCallbackGetVariable;
+	res->ResolveReal   = &GenericCallbackResolveReal;
+
+	res->callback        = CBID_NO_CALLBACK;
+	res->callback_param1 = 0;
+	res->callback_param2 = 0;
+	res->last_value      = 0;
+	res->trigger         = 0;
+	res->reseed          = 0;
+}
+
+
+/** Follow a generic feature callback list and return the first successful
+ * answer
+ * @param feature GRF Feature of callback
+ * @param object  pre-populated resolver object
+ * @param file    address of GRFFile object if file reference is needed, NULL is valid
+ * @return callback value if successful or CALLBACK_FAILED
+ */
+static uint16 GetGenericCallbackResult(uint8 feature, ResolverObject *object, const GRFFile **file)
+{
+	assert(feature < lengthof(_gcl));
+
+	/* Test each feature callback sprite group. */
+	for (GenericCallbackList::const_iterator it = _gcl[feature].begin(); it != _gcl[feature].end(); ++it) {
+		const SpriteGroup *group = it->group;
+		group = Resolve(group, object);
+		if (group == NULL || group->type != SGT_CALLBACK) continue;
+
+		/* Return NewGRF file if necessary */
+		if (file != NULL) *file = it->file;
+
+		return group->g.callback.result;
+	}
+
+	/* No callback returned a valid result, so we've failed. */
+	return CALLBACK_FAILED;
+}
+
+
+/**
+ * 'Execute' an AI purchase selection callback
+ */
+uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const GRFFile **file)
+{
+	ResolverObject object;
+
+	NewGenericResolver(&object);
+
+	object.callback = CBID_GENERIC_AI_PURCHASE_SELECTION;
+	object.u.generic.cargo_type        = cargo_type;
+	object.u.generic.default_selection = default_selection;
+	object.u.generic.src_industry      = src_industry;
+	object.u.generic.dst_industry      = dst_industry;
+	object.u.generic.distance          = distance;
+	object.u.generic.event             = event;
+	object.u.generic.count             = count;
+	object.u.generic.station_size      = station_size;
+
+	return GetGenericCallbackResult(feature, &object, file);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/newgrf_generic.h	Fri Feb 22 00:25:54 2008 +0000
@@ -0,0 +1,35 @@
+/* $Id$ */
+
+#ifndef NEWGRF_GENERIC_H
+#define NEWGRF_GENERIC_H
+
+enum AIConstructionEvent {
+	AICE_TRAIN_CHECK_RAIL_ENGINE     = 0x00, ///< Check if we should build an engine
+	AICE_TRAIN_CHECK_ELRAIL_ENGINE   = 0x01,
+	AICE_TRAIN_CHECK_MONORAIL_ENGINE = 0x02,
+	AICE_TRAIN_CHECK_MAGLEV_ENGINE   = 0x03,
+	AICE_TRAIN_GET_RAIL_WAGON        = 0x08,
+	AICE_TRAIN_GET_ELRAIL_WAGON      = 0x09,
+	AICE_TRAIN_GET_MONORAIL_WAGON    = 0x0A,
+	AICE_TRAIN_GET_MAGLEV_WAGON      = 0x0B,
+	AICE_TRAIN_GET_RAILTYPE          = 0x0F,
+
+	AICE_ROAD_CHECK_ENGINE           = 0x00, ///< Check if we should build an engine
+	AICE_ROAD_GET_FIRST_ENGINE       = 0x01, ///< Unused, we check all
+	AICE_ROAD_GET_NUMBER_ENGINES     = 0x02, ///< Unused, we check all
+
+	AICE_SHIP_CHECK_ENGINE           = 0x00, ///< Check if we should build an engine
+	AICE_SHIP_GET_FIRST_ENGINE       = 0x01, ///< Unused, we check all
+	AICE_SHIP_GET_NUMBER_ENGINES     = 0x02, ///< Unused, we check all
+
+	AICE_AIRCRAFT_CHECK_ENGINE       = 0x00, ///< Check if we should build an engine
+
+	AICE_STATION_GET_STATION_ID      = 0x00, ///< Get a station ID to build
+};
+
+void ResetGenericCallbacks();
+void AddGenericCallback(uint8 feature, const struct GRFFile *file, const struct SpriteGroup *group);
+
+uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const struct GRFFile **file);
+
+#endif /* NEWGRF_GENERIC_H */
--- a/src/newgrf_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -281,7 +281,7 @@
 {
 	bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable;
 
-	w->SetWidgetDisabledState(3, !WP(w, newgrf_d).editable);
+	w->SetWidgetDisabledState(SNGRFS_ADD, !WP(w, newgrf_d).editable);
 	w->SetWidgetsDisabledState(disable_all,
 		SNGRFS_REMOVE,
 		SNGRFS_MOVE_UP,
@@ -530,6 +530,10 @@
 			break;
 
 		case WE_RESIZE:
+			if (e->we.sizing.diff.x != 0) {
+				ResizeButtons(w, SNGRFS_ADD, SNGRFS_MOVE_DOWN);
+				ResizeButtons(w, SNGRFS_SET_PARAMETERS, SNGRFS_APPLY_CHANGES);
+			}
 			w->vscroll.cap += e->we.sizing.diff.y / 14;
 			w->widget[SNGRFS_FILE_LIST].data = (w->vscroll.cap << 8) + 1;
 			SetupNewGRFWindow(w);
@@ -545,7 +549,7 @@
 { 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_PUSHTXTBTN, RESIZE_RIGHT,  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
--- a/src/newgrf_house.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_house.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -289,18 +289,18 @@
 	const DrawTileSprites *dts = group->g.layout.dts;
 	const DrawTileSeqStruct *dtss;
 
-	SpriteID image = dts->ground_sprite;
-	SpriteID pal   = dts->ground_pal;
+	SpriteID image = dts->ground.sprite;
+	SpriteID pal   = dts->ground.pal;
 
 	if (IS_CUSTOM_SPRITE(image)) image += stage;
 
 	if (GB(image, 0, SPRITE_WIDTH) != 0) DrawGroundSprite(image, pal);
 
 	foreach_draw_tile_seq(dtss, dts->seq) {
-		if (GB(dtss->image, 0, SPRITE_WIDTH) == 0) continue;
+		if (GB(dtss->image.sprite, 0, SPRITE_WIDTH) == 0) continue;
 
-		image = dtss->image;
-		pal   = dtss->pal;
+		image = dtss->image.sprite;
+		pal   = dtss->image.pal;
 
 		if (IS_CUSTOM_SPRITE(image)) image += stage;
 
--- a/src/newgrf_industrytiles.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_industrytiles.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -177,18 +177,18 @@
 	const DrawTileSprites *dts = group->g.layout.dts;
 	const DrawTileSeqStruct *dtss;
 
-	SpriteID image = dts->ground_sprite;
-	SpriteID pal   = dts->ground_pal;
+	SpriteID image = dts->ground.sprite;
+	SpriteID pal   = dts->ground.pal;
 
 	if (IS_CUSTOM_SPRITE(image)) image += stage;
 
 	if (GB(image, 0, SPRITE_WIDTH) != 0) DrawGroundSprite(image, pal);
 
 	foreach_draw_tile_seq(dtss, dts->seq) {
-		if (GB(dtss->image, 0, SPRITE_WIDTH) == 0) continue;
+		if (GB(dtss->image.sprite, 0, SPRITE_WIDTH) == 0) continue;
 
-		image = dtss->image;
-		pal   = dtss->pal;
+		image = dtss->image.sprite;
+		pal   = dtss->image.pal;
 
 		if (IS_CUSTOM_SPRITE(image)) image += stage;
 
--- a/src/newgrf_spritegroup.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_spritegroup.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -7,6 +7,7 @@
 #include "variables.h"
 #include "landscape.h"
 #include "oldpool.h"
+#include "newgrf.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_spritegroup.h"
 #include "sprite.h"
@@ -81,23 +82,16 @@
 
 static inline uint32 GetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 {
-	/* Return common variables */
+	/* First handle variables common with Action7/9/D */
+	uint32 value;
+	if (GetGlobalVariable(variable, &value)) return value;
+
+	/* Non-common variable */
 	switch (variable) {
-		case 0x00: return max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
-		case 0x01: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
-		case 0x02: return _cur_month;
-		case 0x03: return _opt.landscape;
-		case 0x09: return _date_fract;
-		case 0x0A: return _tick_counter;
 		case 0x0C: return object->callback;
 		case 0x10: return object->callback_param1;
-		case 0x11: return 0;
-		case 0x12: return _game_mode;
 		case 0x18: return object->callback_param2;
-		case 0x1A: return UINT_MAX;
-		case 0x1B: return GB(_display_opt, 0, 6);
 		case 0x1C: return object->last_value;
-		case 0x20: return _opt.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF;
 
 		case 0x7D: return _temp_store.Get(parameter);
 
--- a/src/newgrf_spritegroup.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_spritegroup.h	Fri Feb 22 00:25:54 2008 +0000
@@ -10,6 +10,7 @@
 #include "newgrf_storage.h"
 #include "core/bitmath_func.hpp"
 #include "gfx_type.h"
+#include "newgrf_generic.h"
 
 /**
  * Gets the value of a so-called newgrf "register".
@@ -236,6 +237,16 @@
 		struct {
 			const struct CargoSpec *cs;
 		} cargo;
+		struct {
+			CargoID cargo_type;
+			uint8 default_selection;
+			IndustryType src_industry;
+			IndustryType dst_industry;
+			uint8 distance;
+			AIConstructionEvent event;
+			uint8 count;
+			uint8 station_size;
+		} generic;
 	} u;
 
 	uint32 (*GetRandomBits)(const struct ResolverObject*);
--- a/src/newgrf_station.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_station.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -291,13 +291,13 @@
 	uint i;
 
 	for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) {
-		uint32 ts = GetTileTrackStatus(tile + TileOffsByDir(*dir), TRANSPORT_RAIL, 0);
-		if (ts != 0) {
+		TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile + TileOffsByDir(*dir), TRANSPORT_RAIL, 0));
+		if (trackbits != TRACK_BIT_NONE) {
 			/* If there is any track on the tile, set the bit in the second byte */
 			SetBit(res, i + 8);
 
 			/* If any track reaches our exit direction, set the bit in the lower byte */
-			if (ts & DiagdirReachesTracks(*diagdir)) SetBit(res, i);
+			if (trackbits & DiagdirReachesTracks(*diagdir)) SetBit(res, i);
 		}
 	}
 
@@ -772,7 +772,7 @@
 		sprites = &statspec->renderdata[(tile < statspec->tiles) ? tile + axis : (uint)axis];
 	}
 
-	image = sprites->ground_sprite;
+	image = sprites->ground.sprite;
 	if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
 		image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE);
 		image += rti->custom_ground_offset;
@@ -784,7 +784,7 @@
 
 	foreach_draw_tile_seq(seq, sprites->seq) {
 		Point pt;
-		image = seq->image;
+		image = seq->image.sprite;
 		if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
 			image += rti->total_offset;
 		} else {
--- a/src/newgrf_town.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/newgrf_town.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -7,6 +7,7 @@
 #include "settings_type.h"
 #include "debug.h"
 #include "core/bitmath_func.hpp"
+#include "core/math_func.hpp"
 #include "town.h"
 
 /** This function implements the town variables that newGRF defines.
@@ -30,8 +31,8 @@
 		/* Town properties */
 		case 0x80: return t->xy;
 		case 0x81: return GB(t->xy, 8, 8);
-		case 0x82: return t->population;
-		case 0x83: return GB(t->population, 8, 8);
+		case 0x82: return ClampToU16(t->population);
+		case 0x83: return GB(ClampToU16(t->population), 8, 8);
 		case 0x8A: return t->grow_counter;
 		case 0x92: return t->flags12;  // In original game, 0x92 and 0x93 are really one word. Since flags12 is a byte, this is to adjust
 		case 0x93: return 0;
@@ -57,22 +58,22 @@
 		case 0xB2: return t->statues;
 		case 0xB6: return t->num_houses;
 		case 0xB9: return t->growth_rate;
-		case 0xBA: return t->new_max_pass;
-		case 0xBB: return GB(t->new_max_pass, 8, 8);
-		case 0xBC: return t->new_max_mail;
-		case 0xBD: return GB(t->new_max_mail, 8, 8);
-		case 0xBE: return t->new_act_pass;
-		case 0xBF: return GB(t->new_act_pass, 8, 8);
-		case 0xC0: return t->new_act_mail;
-		case 0xC1: return GB(t->new_act_mail, 8, 8);
-		case 0xC2: return t->max_pass;
-		case 0xC3: return GB(t->max_pass, 8, 8);
-		case 0xC4: return t->max_mail;
-		case 0xC5: return GB(t->max_mail, 8, 8);
-		case 0xC6: return t->act_pass;
-		case 0xC7: return GB(t->act_pass, 8, 8);
-		case 0xC8: return t->act_mail;
-		case 0xC9: return GB(t->act_mail, 8, 8);
+		case 0xBA: return ClampToU16(t->new_max_pass);
+		case 0xBB: return GB(ClampToU16(t->new_max_pass), 8, 8);
+		case 0xBC: return ClampToU16(t->new_max_mail);
+		case 0xBD: return GB(ClampToU16(t->new_max_mail), 8, 8);
+		case 0xBE: return ClampToU16(t->new_act_pass);
+		case 0xBF: return GB(ClampToU16(t->new_act_pass), 8, 8);
+		case 0xC0: return ClampToU16(t->new_act_mail);
+		case 0xC1: return GB(ClampToU16(t->new_act_mail), 8, 8);
+		case 0xC2: return ClampToU16(t->max_pass);
+		case 0xC3: return GB(ClampToU16(t->max_pass), 8, 8);
+		case 0xC4: return ClampToU16(t->max_mail);
+		case 0xC5: return GB(ClampToU16(t->max_mail), 8, 8);
+		case 0xC6: return ClampToU16(t->act_pass);
+		case 0xC7: return GB(ClampToU16(t->act_pass), 8, 8);
+		case 0xC8: return ClampToU16(t->act_mail);
+		case 0xC9: return GB(ClampToU16(t->act_mail), 8, 8);
 		case 0xCA: return t->pct_pass_transported;
 		case 0xCB: return t->pct_mail_transported;
 		case 0xCC: return t->new_act_food;
--- a/src/npf.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/npf.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -457,18 +457,17 @@
  * Finds out if a given player's vehicles are allowed to enter a given tile.
  * @param owner    The owner of the vehicle.
  * @param tile     The tile that is about to be entered.
- * @param enterdir The direction from which the vehicle wants to enter the tile.
+ * @param enterdir The direction in which the vehicle wants to enter the tile.
  * @return         true if the vehicle can enter the tile.
  * @todo           This function should be used in other places than just NPF,
  *                 maybe moved to another file too.
  */
-static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enterdir)
+static bool CanEnterTileOwnerCheck(Owner owner, TileIndex tile, DiagDirection enterdir)
 {
 	if (IsTileType(tile, MP_RAILWAY) ||           /* Rail tile (also rail depot) */
 			IsRailwayStationTile(tile) ||               /* Rail station tile */
 			IsTileDepotType(tile, TRANSPORT_ROAD) ||  /* Road depot tile */
-			IsStandardRoadStopTile(tile) || /* Road station tile (but not drive-through stops) */
-			IsTileDepotType(tile, TRANSPORT_WATER)) { /* Water depot tile */
+			IsStandardRoadStopTile(tile)) { /* Road station tile (but not drive-through stops) */
 		return IsTileOwner(tile, owner); /* You need to own these tiles entirely to use them */
 	}
 
@@ -510,6 +509,137 @@
 	}
 }
 
+/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
+static DiagDirection GetSingleTramBit(TileIndex tile)
+{
+	if (IsNormalRoadTile(tile)) {
+		RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM);
+		switch (rb) {
+			case ROAD_NW: return DIAGDIR_NW;
+			case ROAD_SW: return DIAGDIR_SW;
+			case ROAD_SE: return DIAGDIR_SE;
+			case ROAD_NE: return DIAGDIR_NE;
+			default: break;
+		}
+	}
+	return INVALID_DIAGDIR;
+}
+
+/**
+ * Tests if a tile can be entered or left only from one side.
+ *
+ * Depots, non-drive-through roadstops, and tiles with single trambits are tested.
+ *
+ * @param tile The tile of interest.
+ * @param type The transporttype of the vehicle.
+ * @param subtype For TRANSPORT_ROAD the compatible RoadTypes of the vehicle.
+ * @return The single entry/exit-direction of the tile, or INVALID_DIAGDIR if there are more or less directions
+ */
+static DiagDirection GetTileSingleEntry(TileIndex tile, TransportType type, uint subtype)
+{
+	if (type != TRANSPORT_WATER && IsTileDepotType(tile, type)) return GetDepotDirection(tile, type);
+
+	if (type == TRANSPORT_ROAD) {
+		if (IsStandardRoadStopTile(tile)) return GetRoadStopDir(tile);
+		if (HasBit(subtype, ROADTYPE_TRAM)) return GetSingleTramBit(tile);
+	}
+
+	return INVALID_DIAGDIR;
+}
+
+/**
+ * Tests if a vehicle must reverse on a tile.
+ *
+ * @param tile The tile of interest.
+ * @param dir The direction in which the vehicle drives on a tile.
+ * @param type The transporttype of the vehicle.
+ * @param subtype For TRANSPORT_ROAD the compatible RoadTypes of the vehicle.
+ * @return true iff the vehicle must reverse on the tile.
+ */
+static inline bool ForceReverse(TileIndex tile, DiagDirection dir, TransportType type, uint subtype)
+{
+	DiagDirection single_entry = GetTileSingleEntry(tile, type, subtype);
+	return single_entry != INVALID_DIAGDIR && single_entry != dir;
+}
+
+/**
+ * Tests if a vehicle can enter a tile.
+ *
+ * @param tile The tile of interest.
+ * @param dir The direction in which the vehicle drives onto a tile.
+ * @param type The transporttype of the vehicle.
+ * @param subtype For TRANSPORT_ROAD the compatible RoadTypes of the vehicle.
+ * @param railtypes For TRANSPORT_RAIL the compatible RailTypes of the vehicle.
+ * @param owner The owner of the vehicle.
+ * @return true iff the vehicle can enter the tile.
+ */
+static bool CanEnterTile(TileIndex tile, DiagDirection dir, TransportType type, uint subtype, RailTypes railtypes, Owner owner)
+{
+	/* Check tunnel entries and bridge ramps */
+	if (IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(tile) != dir) return false;
+
+	/* Test ownership */
+	if (!CanEnterTileOwnerCheck(owner, tile, dir)) return false;
+
+	/* check correct rail type (mono, maglev, etc) */
+	if (type == TRANSPORT_RAIL) {
+		RailType rail_type = GetTileRailType(tile);
+		if (!HasBit(railtypes, rail_type)) return false;
+	}
+
+	/* Depots, standard roadstops and single tram bits can only be entered from one direction */
+	DiagDirection single_entry = GetTileSingleEntry(tile, type, subtype);
+	if (single_entry != INVALID_DIAGDIR && single_entry != ReverseDiagDir(dir)) return false;
+
+	return true;
+}
+
+/**
+ * Returns the driveable Trackdirs on a tile.
+ *
+ * One-way-roads are taken into account. Signals are not tested.
+ *
+ * @param dst_tile The tile of interest.
+ * @param src_trackdir The direction the vehicle is currently moving.
+ * @param type The transporttype of the vehicle.
+ * @param subtype For TRANSPORT_ROAD the compatible RoadTypes of the vehicle.
+ * @return The Trackdirs the vehicle can continue moving on.
+ */
+static TrackdirBits GetDriveableTrackdirBits(TileIndex dst_tile, Trackdir src_trackdir, TransportType type, uint subtype)
+{
+	TrackdirBits trackdirbits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, type, subtype));
+
+	if (trackdirbits == 0 && type == TRANSPORT_ROAD && HasBit(subtype, ROADTYPE_TRAM)) {
+		/* GetTileTrackStatus() returns 0 for single tram bits.
+		 * As we cannot change it there (easily) without breaking something, change it here */
+		switch (GetSingleTramBit(dst_tile)) {
+			case DIAGDIR_NE:
+			case DIAGDIR_SW:
+				trackdirbits = TRACKDIR_BIT_X_NE | TRACKDIR_BIT_X_SW;
+				break;
+
+			case DIAGDIR_NW:
+			case DIAGDIR_SE:
+				trackdirbits = TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_Y_SE;
+				break;
+
+			default: break;
+		}
+	}
+
+	DEBUG(npf, 4, "Next node: (%d, %d) [%d], possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), dst_tile, trackdirbits);
+
+	/* Select only trackdirs we can reach from our current trackdir */
+	trackdirbits &= TrackdirReachesTrackdirs(src_trackdir);
+
+	/* Filter out trackdirs that would make 90 deg turns for trains */
+	if (_patches.forbid_90_deg && (type == TRANSPORT_RAIL || type == TRANSPORT_WATER)) trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
+
+	DEBUG(npf, 6, "After filtering: (%d, %d), possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), trackdirbits);
+
+	return trackdirbits;
+}
+
 
 /* Will just follow the results of GetTileTrackStatus concerning where we can
  * go and where not. Uses AyStar.user_data[NPF_TYPE] as the transport type and
@@ -519,120 +649,71 @@
  * copy AyStarNode.user_data[NPF_NODE_FLAGS] from the parent */
 static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
 {
+	/* We leave src_tile on track src_trackdir in direction src_exitdir */
 	Trackdir src_trackdir = (Trackdir)current->path.node.direction;
 	TileIndex src_tile = current->path.node.tile;
 	DiagDirection src_exitdir = TrackdirToExitdir(src_trackdir);
-	TileIndex dst_tile = INVALID_TILE;
-	int i;
-	uint32 ts;
-	TrackdirBits trackdirbits;
+
+	/* Is src_tile valid, and can be used?
+	 * When choosing track on a junction src_tile is the tile neighboured to the junction wrt. exitdir.
+	 * But we must not check the validity of this move, as src_tile is totally unrelated to the move, if a roadvehicle reversed on a junction. */
+	bool ignore_src_tile = (current->path.parent == NULL && NPFGetFlag(&current->path.node, NPF_FLAG_IGNORE_START_TILE));
+
+	/* Information about the vehicle: TransportType (road/rail/water) and SubType (compatible rail/road types) */
 	TransportType type = (TransportType)aystar->user_data[NPF_TYPE];
 	uint subtype = aystar->user_data[NPF_SUB_TYPE];
-	bool override_dst_check = false;
+
 	/* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */
 	aystar->num_neighbours = 0;
 	DEBUG(npf, 4, "Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile);
 
+	/* We want to determine the tile we arrive, and which choices we have there */
+	TileIndex dst_tile;
+	TrackdirBits trackdirbits;
+
 	/* Find dest tile */
-	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 */
+	if (ignore_src_tile) {
+		/* Do not perform any checks that involve src_tile */
+		dst_tile = src_tile + TileOffsByDiagDir(src_exitdir);
+		trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);
+	} else if (IsTileType(src_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(src_tile) == src_exitdir) {
+		/* We drive through the wormhole and arrive on the other side */
 		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
-		 * those from one side only. Trackdirs don't support that (yet), so we'll
-		 * do this here. */
+		trackdirbits = TrackdirToTrackdirBits(src_trackdir);
+	} else if (ForceReverse(src_tile, src_exitdir, type, subtype)) {
+		/* We can only reverse on this tile */
+		dst_tile = src_tile;
+		src_trackdir = ReverseTrackdir(src_trackdir);
+		trackdirbits = TrackdirToTrackdirBits(src_trackdir);
+	} else {
+		/* We leave src_tile in src_exitdir and reach dst_tile */
+		dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDiagDir(src_exitdir));
 
-		DiagDirection exitdir;
-		/* Find out the exit direction first */
-		if (IsRoadStopTile(src_tile)) {
-			exitdir = GetRoadStopDir(src_tile);
-		} else { // Train or road depot
-			exitdir = GetDepotDirection(src_tile, type);
+		if (dst_tile != INVALID_TILE && !CanEnterTile(dst_tile, src_exitdir, type, subtype, (RailTypes)aystar->user_data[NPF_RAILTYPES], (Owner)aystar->user_data[NPF_OWNER])) dst_tile = INVALID_TILE;
+
+		if (dst_tile == INVALID_TILE) {
+			/* We cannot enter the next tile. Road vehicles can reverse, others reach dead end */
+			if (type != TRANSPORT_ROAD || HasBit(subtype, ROADTYPE_TRAM)) return;
+
+			dst_tile = src_tile;
+			src_trackdir = ReverseTrackdir(src_trackdir);
 		}
 
-		/* Let's see if were headed the right way into the depot */
-		if (src_trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(exitdir))) {
-			/* We are headed inwards. We cannot go through the back of the depot.
-			 * For rail, we can now reverse. Reversing for road vehicles is never
-			 * useful, since you cannot take paths you couldn't take before
-			 * reversing (as with rail). */
-			if (type == TRANSPORT_RAIL) {
-				/* We can only reverse here, so we'll not consider this direction, but
-				 * jump ahead to the reverse direction.  It would be nicer to return
-				 * one neighbour here (the reverse trackdir of the one we are
-				 * considering now) and then considering that one to return the tracks
-				 * outside of the depot. But, because the code layout is cleaner this
-				 * way, we will just pretend we are reversed already */
-				src_trackdir = ReverseTrackdir(src_trackdir);
-				dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDiagDir(exitdir));
-			} else {
-				dst_tile = INVALID_TILE; /* Road vehicle heading inwards: dead end */
-			}
-		} else {
-			dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDiagDir(exitdir));
+		trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);
+
+		if (trackdirbits == 0) {
+			/* We cannot enter the next tile. Road vehicles can reverse, others reach dead end */
+			if (type != TRANSPORT_ROAD || HasBit(subtype, ROADTYPE_TRAM)) return;
+
+			dst_tile = src_tile;
+			src_trackdir = ReverseTrackdir(src_trackdir);
+
+			trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);
 		}
-	} else {
-		/* This a normal tile, a bridge, a tunnel exit, etc. */
-		dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDiagDir(TrackdirToExitdir(src_trackdir)));
-	}
-	if (dst_tile == INVALID_TILE) {
-		/* We reached the border of the map */
-		/* TODO Nicer control flow for this */
-		return;
-	}
-
-	/* 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 && IsTileType(dst_tile, MP_TUNNELBRIDGE) &&
-			GetTunnelBridgeDirection(dst_tile) != src_exitdir) {
-		return;
 	}
 
-	/* check correct rail type (mono, maglev, etc) */
-	if (type == TRANSPORT_RAIL) {
-		RailType dst_type = GetTileRailType(dst_tile);
-		if (!HasBit(aystar->user_data[NPF_RAILTYPES], dst_type))
-			return;
-	}
-
-	/* Check the owner of the tile */
-	if (!VehicleMayEnterTile((Owner)aystar->user_data[NPF_OWNER], dst_tile, TrackdirToExitdir(src_trackdir))) {
-		return;
-	}
-
-	/* Determine available tracks */
-	if (type != TRANSPORT_WATER && (IsStandardRoadStopTile(dst_tile) || IsTileDepotType(dst_tile, type))){
-		/* Road stations and road and train depots return 0 on GTTS, so we have to do this by hand... */
-		DiagDirection exitdir;
-		if (IsRoadStopTile(dst_tile)) {
-			exitdir = GetRoadStopDir(dst_tile);
-		} else { // Road or train depot
-			exitdir = GetDepotDirection(dst_tile, type);
-		}
-		/* Find the trackdirs that are available for a depot or station with this
-		 * orientation. They are only "inwards", since we are reaching this tile
-		 * from some other tile. This prevents vehicles driving into depots from
-		 * the back */
-		ts = TrackdirToTrackdirBits(DiagdirToDiagTrackdir(ReverseDiagDir(exitdir)));
-	} else {
-		ts = GetTileTrackStatus(dst_tile, type, subtype);
-	}
-	trackdirbits = (TrackdirBits)(ts & TRACKDIR_BIT_MASK); /* Filter out signal status and the unused bits */
-
-	DEBUG(npf, 4, "Next node: (%d, %d) [%d], possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), dst_tile, trackdirbits);
-	/* Select only trackdirs we can reach from our current trackdir */
-	trackdirbits &= TrackdirReachesTrackdirs(src_trackdir);
-	if (_patches.forbid_90_deg && (type == TRANSPORT_RAIL || type == TRANSPORT_WATER)) /* Filter out trackdirs that would make 90 deg turns for trains */
-		trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
-
-	DEBUG(npf, 6, "After filtering: (%d, %d), possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), trackdirbits);
-
-	i = 0;
 	/* Enumerate possible track */
+	uint i = 0;
 	while (trackdirbits != 0) {
 		Trackdir dst_trackdir = RemoveFirstTrackdir(&trackdirbits);
 		DEBUG(npf, 5, "Expanded into trackdir: %d, remaining trackdirs: 0x%X", dst_trackdir, trackdirbits);
@@ -667,7 +748,7 @@
  * multiple targets that are spread around, we should perform a breadth first
  * search by specifiying CalcZero as our heuristic.
  */
-static NPFFoundTargetData NPFRouteInternal(AyStarNode* start1, AyStarNode* start2, NPFFindStationOrTileData* target, AyStar_EndNodeCheck target_proc, AyStar_CalculateH heuristic_proc, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty)
+static NPFFoundTargetData NPFRouteInternal(AyStarNode* start1, bool ignore_start_tile1, AyStarNode* start2, bool ignore_start_tile2, NPFFindStationOrTileData* target, AyStar_EndNodeCheck target_proc, AyStar_CalculateH heuristic_proc, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty)
 {
 	int r;
 	NPFFoundTargetData result;
@@ -687,10 +768,12 @@
 	/* Initialize Start Node(s) */
 	start1->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
 	start1->user_data[NPF_NODE_FLAGS] = 0;
+	NPFSetFlag(start1, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile1);
 	_npf_aystar.addstart(&_npf_aystar, start1, 0);
 	if (start2) {
 		start2->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
 		start2->user_data[NPF_NODE_FLAGS] = 0;
+		NPFSetFlag(start2, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile2);
 		NPFSetFlag(start2, NPF_FLAG_REVERSE, true);
 		_npf_aystar.addstart(&_npf_aystar, start2, reverse_penalty);
 	}
@@ -726,7 +809,7 @@
 	return result;
 }
 
-NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
+NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
 {
 	AyStarNode start1;
 	AyStarNode start2;
@@ -740,15 +823,15 @@
 	start2.direction = trackdir2;
 	start2.user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
 
-	return NPFRouteInternal(&start1, (IsValidTile(tile2) ? &start2 : NULL), target, NPFFindStationOrTile, NPFCalcStationOrTileHeuristic, type, sub_type, owner, railtypes, 0);
+	return NPFRouteInternal(&start1, ignore_start_tile1, (IsValidTile(tile2) ? &start2 : NULL), ignore_start_tile2, target, NPFFindStationOrTile, NPFCalcStationOrTileHeuristic, type, sub_type, owner, railtypes, 0);
 }
 
-NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
+NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
 {
-	return NPFRouteToStationOrTileTwoWay(tile, trackdir, INVALID_TILE, INVALID_TRACKDIR, target, type, sub_type, owner, railtypes);
+	return NPFRouteToStationOrTileTwoWay(tile, trackdir, ignore_start_tile, INVALID_TILE, INVALID_TRACKDIR, false, target, type, sub_type, owner, railtypes);
 }
 
-NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty)
+NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty)
 {
 	AyStarNode start1;
 	AyStarNode start2;
@@ -764,15 +847,15 @@
 
 	/* perform a breadth first search. Target is NULL,
 	 * since we are just looking for any depot...*/
-	return NPFRouteInternal(&start1, (IsValidTile(tile2) ? &start2 : NULL), NULL, NPFFindDepot, NPFCalcZero, type, sub_type, owner, railtypes, reverse_penalty);
+	return NPFRouteInternal(&start1, ignore_start_tile1, (IsValidTile(tile2) ? &start2 : NULL), ignore_start_tile2, NULL, NPFFindDepot, NPFCalcZero, type, sub_type, owner, railtypes, reverse_penalty);
 }
 
-NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
+NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
 {
-	return NPFRouteToDepotBreadthFirstTwoWay(tile, trackdir, INVALID_TILE, INVALID_TRACKDIR, type, sub_type, owner, railtypes, 0);
+	return NPFRouteToDepotBreadthFirstTwoWay(tile, trackdir, ignore_start_tile, INVALID_TILE, INVALID_TRACKDIR, false, type, sub_type, owner, railtypes, 0);
 }
 
-NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
+NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
 {
 	/* Okay, what we're gonna do. First, we look at all depots, calculate
 	 * the manhatten distance to get to each depot. We then sort them by
@@ -847,6 +930,7 @@
 		 * return a not found then */
 		start.user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
 		start.user_data[NPF_NODE_FLAGS] = 0;
+		NPFSetFlag(&start, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile);
 		_npf_aystar.addstart(&_npf_aystar, &start, 0);
 
 		/* Initialize result */
--- a/src/npf.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/npf.h	Fri Feb 22 00:25:54 2008 +0000
@@ -60,9 +60,10 @@
 
 /* Flags for AyStarNode.userdata[NPF_NODE_FLAGS]. Use NPFGetBit() and NPFGetBit() to use them. */
 enum NPFNodeFlag {
-	NPF_FLAG_SEEN_SIGNAL,     ///< Used to mark that a signal was seen on the way, for rail only
-	NPF_FLAG_REVERSE,         ///< Used to mark that this node was reached from the second start node, if applicable
-	NPF_FLAG_LAST_SIGNAL_RED, ///< Used to mark that the last signal on this path was red
+	NPF_FLAG_SEEN_SIGNAL,       ///< Used to mark that a signal was seen on the way, for rail only
+	NPF_FLAG_REVERSE,           ///< Used to mark that this node was reached from the second start node, if applicable
+	NPF_FLAG_LAST_SIGNAL_RED,   ///< Used to mark that the last signal on this path was red
+	NPF_FLAG_IGNORE_START_TILE, ///< Used to mark that the start tile is invalid, and searching should start from the second tile on
 };
 
 /* Meant to be stored in AyStar.userpath */
@@ -78,28 +79,28 @@
 /* Will search from the given tile and direction, for a route to the given
  * station for the given transport type. See the declaration of
  * NPFFoundTargetData above for the meaning of the result. */
-NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
+NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
 
 /* Will search as above, but with two start nodes, the second being the
  * reverse. Look at the NPF_FLAG_REVERSE flag in the result node to see which
  * direction was taken (NPFGetBit(result.node, NPF_FLAG_REVERSE)) */
-NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
+NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
 
 /* Will search a route to the closest depot. */
 
 /* Search using breadth first. Good for little track choice and inaccurate
  * heuristic, such as railway/road.*/
-NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
+NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
 /* Same as above but with two start nodes, the second being the reverse. Call
  * NPFGetBit(result.node, NPF_FLAG_REVERSE) to see from which node the path
  * orginated. All pathfs from the second node will have the given
  * reverse_penalty applied (NPF_TILE_LENGTH is the equivalent of one full
  * tile).
  */
-NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty);
+NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty);
 /* Search by trying each depot in order of Manhattan Distance. Good for lots
  * of choices and accurate heuristics, such as water. */
-NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
+NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
 
 void NPFFillWithOrderData(NPFFindStationOrTileData* fstd, Vehicle* v);
 
--- a/src/oldloader.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/oldloader.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -1142,7 +1142,7 @@
 
 	OCL_SVAR(  OC_UINT8, Engine, lifelength ),
 	OCL_SVAR(  OC_UINT8, Engine, flags ),
-	OCL_SVAR(  OC_UINT8, Engine, preview_player ),
+	OCL_SVAR(  OC_UINT8, Engine, preview_player_rank ),
 	OCL_SVAR(  OC_UINT8, Engine, preview_wait ),
 
 	OCL_NULL( 2 ), ///< Junk
--- a/src/openttd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/openttd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -826,9 +826,9 @@
 
 		case SL_REINIT:
 			switch (ogm) {
+				default:
 				case GM_MENU:   LoadIntroGame();      break;
 				case GM_EDITOR: MakeNewEditorWorld(); break;
-				default:        MakeNewGame(false);   break;
 			}
 			return false;
 
@@ -1452,8 +1452,11 @@
 	 * if a player does exist, rather then checking name_1 */
 	if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive();
 
-	/* the void tiles on the southern border used to belong to a wrong class (pre 4.3). */
-	if (CheckSavegameVersionOldStyle(4, 3)) UpdateVoidTiles();
+	/* The void tiles on the southern border used to belong to a wrong class (pre 4.3).
+	 * This problem appears in savegame version 21 too, see r3455. But after loading the
+	 * savegame and saving again, the buggy map array could be converted to new savegame
+	 * version. It didn't show up before r12070. */
+	if (CheckSavegameVersion(87)) UpdateVoidTiles();
 
 	/* If Load Scenario / New (Scenario) Game is used,
 	 *  a player does not exist yet. So create one here.
@@ -2343,9 +2346,16 @@
 				if (_m[t].m5 == 2) {
 					MakeRiver(t, Random());
 				} else {
-					Owner o = GetTileOwner(t);
-					if (IsWater(t) && o != OWNER_WATER) {
-						MakeCanal(t, o, Random());
+					if (IsWater(t)) {
+						Owner o = GetTileOwner(t);
+						if (o == OWNER_WATER) {
+							MakeWater(t);
+						} else {
+							MakeCanal(t, o, Random());
+						}
+					} else if (IsShipDepot(t)) {
+						Owner o = (Owner)_m[t].m4; // Original water owner
+						SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL);
 					}
 				}
 			}
@@ -2357,11 +2367,80 @@
 		for (TileIndex t = 0; t < map_size; t++) {
 			if (GetTileSlope(t, NULL) != SLOPE_FLAT) continue;
 
-			if (IsTileType(t, MP_WATER) && (GetWaterTileType(t) == WATER_TILE_LOCK || IsShipDepot(t))) SetWaterClassDependingOnSurroundings(t);
+			if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t);
 			if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t);
 		}
 	}
 
+	if (CheckSavegameVersion(87)) {
+		for (TileIndex t = 0; t < map_size; t++) {
+			/* skip oil rigs at borders! */
+			if ((IsTileType(t, MP_WATER) || IsBuoyTile(t)) &&
+					(TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1)) {
+				/* Some version 86 savegames have wrong water class at map borders (under buoy, or after removing buoy).
+				 * This conversion has to be done before buoys with invalid owner are removed. */
+				SetWaterClass(t, WATER_CLASS_SEA);
+			}
+
+			if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
+				Owner o = GetTileOwner(t);
+				if (IsValidPlayer(o) && !GetPlayer(o)->is_active) {
+					_current_player = o;
+					ChangeTileOwner(t, o, PLAYER_SPECTATOR);
+				}
+				if (IsBuoyTile(t)) {
+					/* reset buoy owner to OWNER_NONE in the station struct
+					 * (even if it is owned by active player) */
+					GetStationByTile(t)->owner = OWNER_NONE;
+				}
+			} else if (IsTileType(t, MP_ROAD)) {
+				/* works for all RoadTileType */
+				for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
+					/* update even non-existing road types to update tile owner too */
+					Owner o = GetRoadOwner(t, rt);
+					if (IsValidPlayer(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE);
+				}
+				if (IsLevelCrossing(t)) {
+					Owner o = GetTileOwner(t);
+					if (!GetPlayer(o)->is_active) {
+						/* remove leftover rail piece from crossing (from very old savegames) */
+						_current_player = o;
+						DoCommand(t, 0, GetCrossingRailTrack(t), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
+					}
+				}
+			}
+		}
+
+		/* Convert old PF settings to new */
+		if (_patches.yapf.rail_use_yapf) {
+			_patches.pathfinder_for_trains = VPF_YAPF;
+		} else {
+			_patches.pathfinder_for_trains = (_patches.new_pathfinding_all ? VPF_NPF : VPF_NTP);
+		}
+
+		if (_patches.yapf.road_use_yapf) {
+			_patches.pathfinder_for_roadvehs = VPF_YAPF;
+		} else {
+			_patches.pathfinder_for_roadvehs = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
+		}
+
+		if (_patches.yapf.ship_use_yapf) {
+			_patches.pathfinder_for_ships = VPF_YAPF;
+		} else {
+			_patches.pathfinder_for_ships = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
+		}
+	}
+
+	if (CheckSavegameVersion(88)) {
+		/* Profits are now with 8 bit fract */
+		Vehicle *v;
+		FOR_ALL_VEHICLES(v) {
+			v->profit_this_year <<= 8;
+			v->profit_last_year <<= 8;
+			v->running_ticks = 0;
+		}
+	}
+
 	return InitializeWindowsAndCaches();
 }
 
--- a/src/order_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/order_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -328,10 +328,8 @@
 
 	if (!HasOrderPoolFree(1)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
 
-	if (v->type == VEH_SHIP &&
-			IsHumanPlayer(v->owner) &&
-			!_patches.new_pathfinding_all) {
-		// Make sure the new destination is not too far away from the previous
+	if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _patches.pathfinder_for_ships != VPF_NPF) {
+		/* Make sure the new destination is not too far away from the previous */
 		const Order *prev = NULL;
 		uint n = 0;
 
--- a/src/order_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/order_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -281,7 +281,7 @@
 			break;
 
 		case MP_ROAD:
-			if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
+			if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
 				order.type = OT_GOTO_DEPOT;
 				order.flags = OFB_PART_OF_ORDERS;
 				order.dest = GetDepotByTile(tile)->index;
--- a/src/pathfind.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/pathfind.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -140,7 +140,6 @@
 
 static void TPFMode2(TrackPathFinder* tpf, TileIndex tile, DiagDirection direction)
 {
-	uint bits;
 	RememberData rd;
 
 	assert(tpf->tracktype == TRANSPORT_WATER);
@@ -153,43 +152,35 @@
 	if (++tpf->rd.cur_length > 50)
 		return;
 
-	bits = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type);
-	bits = (byte)((bits | (bits >> 8)) & _bits_mask[direction]);
-	if (bits == 0)
-		return;
+	TrackStatus ts = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type);
+	TrackBits bits = (TrackBits)(TrackStatusToTrackBits(ts) & _bits_mask[direction]);
+	if (bits == TRACK_BIT_NONE) return;
 
 	assert(TileX(tile) != MapMaxX() && TileY(tile) != MapMaxY());
 
-	uint i = 0;
-	/* only one direction */
-	if (KillFirstBit(bits) == 0) {
-		i = FindFirstBit(bits);
-		rd = tpf->rd;
-		goto continue_here;
-	}
-	/* several directions */
+	bool only_one_track = true;
 	do {
-		i = FindFirstBit(bits);
+		Track track = RemoveFirstTrack(&bits);
+		if (bits != TRACK_BIT_NONE) only_one_track = false;
 		rd = tpf->rd;
 
 		/* Change direction 4 times only */
-		if ((byte)i != tpf->rd.pft_var6) {
+		if (!only_one_track && track != tpf->rd.last_choosen_track) {
 			if (++tpf->rd.depth > 4) {
 				tpf->rd = rd;
 				return;
 			}
-			tpf->rd.pft_var6 = (byte)i;
+			tpf->rd.last_choosen_track = track;
 		}
 
-continue_here:
-		tpf->the_dir = (Trackdir)(i + (HasBit(_otherdir_mask[direction], i) ? 8 : 0));
+		tpf->the_dir = (Trackdir)(track + (HasBit(_otherdir_mask[direction], track) ? 8 : 0));
 
-		if (!tpf->enum_proc(tile, tpf->userdata, tpf->the_dir, tpf->rd.cur_length, NULL)) {
+		if (!tpf->enum_proc(tile, tpf->userdata, tpf->the_dir, tpf->rd.cur_length)) {
 			TPFMode2(tpf, tile, _tpf_new_direction[tpf->the_dir]);
 		}
 
 		tpf->rd = rd;
-	} while (ClrBit(bits, i) != 0);
+	} while (bits != TRACK_BIT_NONE);
 
 }
 
@@ -261,11 +252,11 @@
 		}
 	}
 
-	uint32 bits = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type);
+	uint32 bits = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type));
 
 	/* Check in case of rail if the owner is the same */
 	if (tpf->tracktype == TRANSPORT_RAIL) {
-		if (bits != 0 && GetTileTrackStatus(tile_org, TRANSPORT_RAIL, 0) != 0) {
+		if (bits != 0 && TrackStatusToTrackdirBits(GetTileTrackStatus(tile_org, TRANSPORT_RAIL, 0)) != TRACKDIR_BIT_NONE) {
 			if (GetTileOwner(tile_org) != GetTileOwner(tile)) return;
 		}
 	}
@@ -287,8 +278,9 @@
 				tpf->the_dir = (Trackdir)((_otherdir_mask[direction] & (byte)(1 << i)) ? (i + 8) : i);
 				RememberData rd = tpf->rd;
 
-				if (TPFSetTileBit(tpf, tile, tpf->the_dir) &&
-						!tpf->enum_proc(tile, tpf->userdata, tpf->the_dir, tpf->rd.cur_length, &tpf->rd.pft_var6) ) {
+				/* make sure we are not leaving from invalid side */
+				if (TPFSetTileBit(tpf, tile, tpf->the_dir) && CanAccessTileInDir(tile, TrackdirToExitdir(tpf->the_dir), tpf->tracktype) &&
+						!tpf->enum_proc(tile, tpf->userdata, tpf->the_dir, tpf->rd.cur_length) ) {
 					TPFMode1(tpf, tile, _tpf_new_direction[tpf->the_dir]);
 				}
 				tpf->rd = rd;
@@ -311,7 +303,7 @@
 
 	tpf.rd.cur_length = 0;
 	tpf.rd.depth = 0;
-	tpf.rd.pft_var6 = 0;
+	tpf.rd.last_choosen_track = INVALID_TRACK;
 
 	tpf.var2 = HasBit(flags, 15) ? 0x43 : 0xFF; // 0x8000
 
@@ -322,8 +314,7 @@
 	tpf.sub_type = sub_type;
 
 	if (HasBit(flags, 11)) {
-		tpf.rd.pft_var6 = 0xFF;
-		tpf.enum_proc(tile, data, INVALID_TRACKDIR, 0, 0);
+		tpf.enum_proc(tile, data, INVALID_TRACKDIR, 0);
 		TPFMode2(&tpf, tile, direction);
 	} else {
 		/* clear the hash_heads */
@@ -691,8 +682,8 @@
 			if (!IsTileType(tile, MP_RAILWAY) || !IsPlainRailTile(tile)) {
 				/* We found a tile which is not a normal railway tile.
 				 * Determine which tracks that exist on this tile. */
-				uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _tpfmode1_and[direction];
-				bits = TrackdirBitsToTrackBits((TrackdirBits)(ts & TRACKDIR_BIT_MASK));
+				TrackStatus ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _tpfmode1_and[direction];
+				bits = TrackStatusToTrackBits(ts);
 
 				/* Check that the tile contains exactly one track */
 				if (bits == 0 || KillFirstBit(bits) != 0) break;
--- a/src/pathfind.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/pathfind.h	Fri Feb 22 00:25:54 2008 +0000
@@ -16,7 +16,7 @@
 //supported on all archs)
 
 struct TrackPathFinder;
-typedef bool TPFEnumProc(TileIndex tile, void *data, Trackdir trackdir, uint length, byte *state);
+typedef bool TPFEnumProc(TileIndex tile, void *data, Trackdir trackdir, uint length);
 typedef void TPFAfterProc(TrackPathFinder *tpf);
 
 typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length);
@@ -40,7 +40,7 @@
 struct RememberData {
 	uint16 cur_length;
 	byte depth;
-	byte pft_var6;
+	Track last_choosen_track;
 };
 
 struct TrackPathFinder {
--- a/src/player_base.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/player_base.h	Fri Feb 22 00:25:54 2008 +0000
@@ -63,7 +63,7 @@
 	bool is_ai;
 	bool is_noai; ///< This is a NoAI player (for loading old savegames properly). Part of the NoAI 'hack' to retain savegame compatability with trunk
 
-	Money yearly_expenses[3][13];
+	Money yearly_expenses[3][EXPENSES_END];
 	PlayerEconomyEntry cur_economy;
 	PlayerEconomyEntry old_economy[24];
 	EngineRenewList engine_renew_list; ///< Defined later
--- a/src/player_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/player_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -46,7 +46,7 @@
 static void DrawPlayerEconomyStats(const Player *p, byte mode)
 {
 	int x, y, i, j, year;
-	const Money (*tbl)[13];
+	const Money (*tbl)[EXPENSES_END];
 	Money sum, cost;
 	StringID str;
 
--- a/src/rail_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/rail_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -45,6 +45,7 @@
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "table/railtypes.h"
+#include "table/track_land.h"
 
 const byte _track_sloped_sprites[14] = {
 	14, 15, 22, 13,
@@ -356,7 +357,7 @@
 
 			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
-			if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+			if (IsNormalRoad(tile)) {
 				if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
 
 				RoadTypes roadtypes = GetRoadTypes(tile);
@@ -455,7 +456,7 @@
 			if (!IsLevelCrossing(tile) ||
 					GetCrossingRailBits(tile) != trackbit ||
 					(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
-					!EnsureNoVehicleOnGround(tile)) {
+					(!(flags & DC_BANKRUPT) && !EnsureNoVehicleOnGround(tile))) {
 				return CMD_ERROR;
 			}
 
@@ -909,8 +910,7 @@
 	if (tile == INVALID_TILE) return false;
 
 	/* Check for track bits on the new tile */
-	uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0);
-	TrackdirBits trackdirbits = (TrackdirBits)(ts & TRACKDIR_BIT_MASK);
+	TrackdirBits trackdirbits = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0));
 
 	if (TracksOverlap(TrackdirBitsToTrackBits(trackdirbits))) return false;
 	trackdirbits &= TrackdirReachesTrackdirs(trackdir);
@@ -1311,7 +1311,7 @@
 
 				default: // MP_STATION, MP_ROAD
 					if (flags & DC_EXEC) {
-						Track track = (tt == MP_STATION) ? GetRailStationTrack(tile) : AxisToTrack(OtherAxis(GetCrossingRoadAxis(tile)));
+						Track track = ((tt == MP_STATION) ? GetRailStationTrack(tile) : GetCrossingRailTrack(tile));
 						YapfNotifyTrackLayoutChange(tile, track);
 					}
 
@@ -1397,8 +1397,6 @@
 	}
 }
 
-#include "table/track_land.h"
-
 /**
  * Get surface height in point (x,y)
  * On tiles with halftile foundations move (x,y) to a save point wrt. track
@@ -1432,27 +1430,20 @@
 		}
 	};
 
-	static const SpriteID SignalBase[2][2][4] = {
-		{    /* Signals on left side */
-			{  0x4FB, 0x1323, 0x1333, 0x1343}, /* light signals */
-			{ 0x1353, 0x1363, 0x1373, 0x1383}  /* semaphores    */
-		}, { /* Signals on right side */
-			{  0x4FB, 0x1323, 0x1333, 0x1343}, /* light signals */
-			{ 0x1446, 0x1456, 0x1466, 0x1476}  /* semaphores    */
-		/*         |       |       |       |     */
-		/*    normal,  entry,   exit,  combo     */
-		}
-	};
-
 	uint x = TileX(tile) * TILE_SIZE + SignalPositions[side][pos].x;
 	uint y = TileY(tile) * TILE_SIZE + SignalPositions[side][pos].y;
 
 	SpriteID sprite;
 
-	if (GetSignalType(tile, track) == SIGTYPE_NORMAL && GetSignalVariant(tile, track) == SIG_ELECTRIC) {
-		sprite = SignalBase[side][GetSignalVariant(tile, track)][GetSignalType(tile, track)] + image + condition;
+	SignalType type       = GetSignalType(tile, track);
+	SignalVariant variant = GetSignalVariant(tile, track);
+
+	if (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) {
+		/* Normal electric signals are picked from original sprites. */
+		sprite = SPR_ORIGINAL_SIGNALS_BASE + image + condition;
 	} else {
-		sprite = SPR_SIGNALS_BASE + (GetSignalType(tile, track) - 1) * 16 + GetSignalVariant(tile, track) * 64 + image + condition;
+		/* All other signals are picked from add on sprites. */
+		sprite = SPR_SIGNALS_BASE + (type - 1) * 16 + variant * 64 + image + condition;
 	}
 
 	AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track));
@@ -1697,7 +1688,8 @@
 		pal = PAL_NONE;
 		switch (rgt) {
 			case RAIL_GROUND_BARREN:     pal = PALETTE_TO_BARE_LAND; break;
-			case RAIL_GROUND_ICE_DESERT: image += rti->snow_offset;  break;
+			case RAIL_GROUND_ICE_DESERT:
+			case RAIL_GROUND_HALF_SNOW:  image += rti->snow_offset;  break; // higher part has snow in this case too
 			default: break;
 		}
 		DrawGroundSprite(image, pal, &(_halftile_sub_sprite[halftile_corner]));
@@ -1766,7 +1758,7 @@
 
 			relocation = rti->total_offset;
 
-			image = dts->ground_sprite;
+			image = dts->ground.sprite;
 			if (image != SPR_FLAT_GRASS_TILE) image += rti->total_offset;
 
 			/* adjust ground tile for desert
@@ -1802,7 +1794,7 @@
 				if (dts != NULL && dts->seq != NULL) {
 					relocation = GetCustomStationRelocation(statspec, st, ti->tile);
 
-					image = dts->ground_sprite;
+					image = dts->ground.sprite;
 					if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
 						image += GetCustomStationGroundRelocation(statspec, st, ti->tile);
 						image += rti->custom_ground_offset;
@@ -1817,7 +1809,7 @@
 				/* There is no custom layout, fall back to the default graphics */
 				dts = &_waypoint_gfx_table[GetWaypointAxis(ti->tile)];
 				relocation = 0;
-				image = dts->ground_sprite + rti->total_offset;
+				image = dts->ground.sprite + rti->total_offset;
 				if (IsSnowRailGround(ti->tile)) image += rti->snow_offset;
 			}
 		}
@@ -1827,7 +1819,7 @@
 		if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
 
 		foreach_draw_tile_seq(dtss, dts->seq) {
-			SpriteID image = dtss->image;
+			SpriteID image = dtss->image.sprite;
 			SpriteID pal;
 
 			/* Unlike stations, our default waypoint has no variation for
@@ -1842,7 +1834,7 @@
 			if (!(!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
 				pal = _drawtile_track_palette;
 			} else {
-				pal = dtss->pal;
+				pal = dtss->image.pal;
 			}
 
 			if ((byte)dtss->delta_z != 0x80) {
@@ -1867,9 +1859,9 @@
 	SpriteID palette = PLAYER_SPRITE_COLOR(_local_player);
 
 	DrawSprite(ground, PAL_NONE, x, y);
-	for (; dtss->image != 0; dtss++) {
+	for (; dtss->image.sprite != 0; dtss++) {
 		Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
-		SpriteID image = dtss->image + offset;
+		SpriteID image = dtss->image.sprite + offset;
 
 		DrawSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE, x + pt.x, y + pt.y);
 	}
@@ -1878,7 +1870,7 @@
 void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype)
 {
 	const DrawTileSprites* dts = &_depot_gfx_table[dir];
-	SpriteID image = dts->ground_sprite;
+	SpriteID image = dts->ground.sprite;
 	uint32 offset = GetRailTypeInfo(railtype)->total_offset;
 
 	if (image != SPR_FLAT_GRASS_TILE) image += offset;
@@ -1890,7 +1882,7 @@
 	uint32 offset = GetRailTypeInfo(railtype)->total_offset;
 	const DrawTileSprites* dts = &_waypoint_gfx_table[AXIS_X];
 
-	DrawTileSequence(x, y, dts->ground_sprite + offset, dts->seq, 0);
+	DrawTileSequence(x, y, dts->ground.sprite + offset, dts->seq, 0);
 }
 
 static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y)
@@ -1933,12 +1925,62 @@
 	}
 
 	switch (_opt.landscape) {
-		case LT_ARCTIC:
-			if (GetTileZ(tile) > GetSnowLine()) {
-				new_ground = RAIL_GROUND_ICE_DESERT;
+		case LT_ARCTIC: {
+			uint z;
+			Slope slope = GetTileSlope(tile, &z);
+			bool half = false;
+
+			/* for non-flat track, use lower part of track
+			 * in other cases, use the highest part with track */
+			if (IsPlainRailTile(tile)) {
+				TrackBits track = GetTrackBits(tile);
+				Foundation f = GetRailFoundation(slope, track);
+
+				switch (f) {
+					case FOUNDATION_NONE:
+						/* no foundation - is the track on the upper side of three corners raised tile? */
+						if (IsSlopeWithThreeCornersRaised(slope)) z += TILE_HEIGHT;
+						break;
+
+					case FOUNDATION_INCLINED_X:
+					case FOUNDATION_INCLINED_Y:
+						/* sloped track - is it on a steep slope? */
+						if (IsSteepSlope(slope)) z += TILE_HEIGHT;
+						break;
+
+					case FOUNDATION_STEEP_LOWER:
+						/* only lower part of steep slope */
+						z += TILE_HEIGHT;
+						break;
+
+					default:
+						/* if it is a steep slope, then there is a track on higher part */
+						if (IsSteepSlope(slope)) z += TILE_HEIGHT;
+						z += TILE_HEIGHT;
+						break;
+				}
+
+				half = IsInsideMM(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1);
+			} else {
+				/* is the depot on a non-flat tile? */
+				if (slope != SLOPE_FLAT) z += TILE_HEIGHT;
+			}
+
+			/* 'z' is now the lowest part of the highest track bit -
+			 * for sloped track, it is 'z' of lower part
+			 * for two track bits, it is 'z' of higher track bit
+			 * For non-continuous foundations (and STEEP_BOTH), 'half' is set */
+			if (z > GetSnowLine()) {
+				if (half && z - GetSnowLine() == TILE_HEIGHT) {
+					/* track on non-continuous foundation, lower part is not under snow */
+					new_ground = RAIL_GROUND_HALF_SNOW;
+				} else {
+					new_ground = RAIL_GROUND_ICE_DESERT;
+				}
 				goto set_ground;
 			}
 			break;
+			}
 
 		case LT_TROPIC:
 			if (GetTropicZone(tile) == TROPICZONE_DESERT) {
@@ -2039,20 +2081,21 @@
 }
 
 
-static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
 	if (mode != TRANSPORT_RAIL) return 0;
 
+	TrackBits trackbits = TRACK_BIT_NONE;
+	TrackdirBits red_signals = TRACKDIR_BIT_NONE;
+
 	switch (GetRailTileType(tile)) {
 		default: NOT_REACHED();
-		case RAIL_TILE_NORMAL: {
-			TrackBits rails = GetTrackBits(tile);
-			uint32 ret = rails * 0x101;
-			return (rails == TRACK_BIT_CROSS) ? ret | 0x40 : ret;
-		}
+		case RAIL_TILE_NORMAL:
+			trackbits = GetTrackBits(tile);
+			break;
 
 		case RAIL_TILE_SIGNALS: {
-			uint32 ret = GetTrackBits(tile) * 0x101;
+			trackbits = GetTrackBits(tile);
 			byte a = GetPresentSignals(tile);
 			uint b = GetSignalStates(tile);
 
@@ -2065,17 +2108,29 @@
 			if ((a & 0xC) == 0) b |= 0xC;
 			if ((a & 0x3) == 0) b |= 0x3;
 
-			if ((b & 0x8) == 0) ret |= 0x10070000;
-			if ((b & 0x4) == 0) ret |= 0x07100000;
-			if ((b & 0x2) == 0) ret |= 0x20080000;
-			if ((b & 0x1) == 0) ret |= 0x08200000;
+			if ((b & 0x8) == 0) red_signals |= (TRACKDIR_BIT_LEFT_N | TRACKDIR_BIT_X_NE | TRACKDIR_BIT_Y_SE | TRACKDIR_BIT_UPPER_E);
+			if ((b & 0x4) == 0) red_signals |= (TRACKDIR_BIT_LEFT_S | TRACKDIR_BIT_X_SW | TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_UPPER_W);
+			if ((b & 0x2) == 0) red_signals |= (TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_LOWER_E);
+			if ((b & 0x1) == 0) red_signals |= (TRACKDIR_BIT_RIGHT_S | TRACKDIR_BIT_LOWER_W);
 
-			return ret;
+			break;
 		}
 
-		case RAIL_TILE_DEPOT:    return AxisToTrackBits(DiagDirToAxis(GetRailDepotDirection(tile))) * 0x101;
-		case RAIL_TILE_WAYPOINT: return GetRailWaypointBits(tile) * 0x101;
+		case RAIL_TILE_DEPOT: {
+			DiagDirection dir = GetRailDepotDirection(tile);
+
+			if (side != INVALID_DIAGDIR && side != dir) break;
+
+			trackbits = AxisToTrackBits(DiagDirToAxis(dir));
+			break;
+		}
+
+		case RAIL_TILE_WAYPOINT:
+			trackbits = GetRailWaypointBits(tile);
+			break;
 	}
+
+	return CombineTrackStatus(TrackBitsToTrackdirBits(trackbits), red_signals);
 }
 
 static void ClickTile_Track(TileIndex tile)
@@ -2145,7 +2200,7 @@
 	if (new_player != PLAYER_SPECTATOR) {
 		SetTileOwner(tile, new_player);
 	} else {
-		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+		DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
 	}
 }
 
--- a/src/rail_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/rail_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -76,7 +76,7 @@
 static void GenericPlaceRail(TileIndex tile, int cmd)
 {
 	DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E,
-		(_remove_button_clicked || _ctrl_pressed) ?
+		_remove_button_clicked ?
 		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
 	);
@@ -150,7 +150,7 @@
 
 static void PlaceRail_Waypoint(TileIndex tile)
 {
-	if (_remove_button_clicked || _ctrl_pressed) {
+	if (_remove_button_clicked) {
 		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));
@@ -169,7 +169,8 @@
 static void PlaceRail_Station(TileIndex tile)
 {
 	if (_remove_button_clicked) {
-		VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_STATION);
+		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
+		VpSetPlaceSizingLimit(-1);
 	} else if (_railstation.dragdrop) {
 		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
 		VpSetPlaceSizingLimit(_patches.station_spread);
@@ -188,7 +189,7 @@
  */
 static void GenericPlaceSignals(TileIndex tile)
 {
-	TrackBits trackbits = (TrackBits)GB(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0), 0, 6);
+	TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0));
 
 	if (trackbits & TRACK_BIT_VERT) { // N-S direction
 		trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
@@ -277,6 +278,38 @@
 	RTW_CONVERT_RAIL,
 };
 
+
+/** Toogles state of the Remove button of Build rail toolbar
+ * @param w window the button belongs to
+ */
+static void ToggleRailButton_Remove(Window *w)
+{
+	w->ToggleWidgetLoweredState(RTW_REMOVE);
+	w->InvalidateWidget(RTW_REMOVE);
+	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
+	SetSelectionRed(_remove_button_clicked);
+}
+
+/** Updates the Remove button because of Ctrl state change
+ * @param w window the button belongs to
+ * @return true iff the remove buton was changed
+ */
+static bool RailToolbar_CtrlChanged(Window *w)
+{
+	if (w->IsWidgetDisabled(RTW_REMOVE)) return false;
+
+	/* allow ctrl to switch remove mode only for these widgets */
+	for (uint i = RTW_BUILD_NS; i <= RTW_BUILD_STATION; i++) {
+		if ((i <= RTW_AUTORAIL || i >= RTW_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
+			ToggleRailButton_Remove(w);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+
 static void BuildRailClick_N(Window *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, VHM_RECT, PlaceRail_N);
@@ -351,16 +384,29 @@
 static void BuildRailClick_Remove(Window *w)
 {
 	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
-	SetWindowDirty(w);
+	ToggleRailButton_Remove(w);
 	SndPlayFx(SND_15_BEEP);
 
-	w->ToggleWidgetLoweredState(RTW_REMOVE);
-	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
-	SetSelectionRed(_remove_button_clicked);
-
-	// handle station builder
-	if (_remove_button_clicked) {
-		SetTileSelectSize(1, 1);
+	/* handle station builder */
+	if (w->IsWidgetLowered(RTW_BUILD_STATION)) {
+		if (_remove_button_clicked) {
+			/* starting drag & drop remove */
+			if (!_railstation.dragdrop) {
+				SetTileSelectSize(1, 1);
+			} else {
+				VpSetPlaceSizingLimit(-1);
+			}
+		} else {
+			/* starting station build mode */
+			if (!_railstation.dragdrop) {
+				int x = _railstation.numtracks;
+				int y = _railstation.platlength;
+				if (_railstation.orientation == 0) Swap(x, y);
+				SetTileSelectSize(x, y);
+			} else {
+				VpSetPlaceSizingLimit(_patches.station_spread);
+			}
+		}
 	}
 }
 
@@ -373,7 +419,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 || _ctrl_pressed) ?
+		_remove_button_clicked ?
 		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)
 	);
@@ -514,6 +560,7 @@
 			_build_railroad_button_proc[e->we.click.widget - RTW_BUILD_NS](w);
 		}
 		UpdateRemoveWidgetStatus(w, e->we.click.widget);
+		if (_ctrl_pressed) RailToolbar_CtrlChanged(w);
 		break;
 
 	case WE_KEYPRESS:
@@ -523,6 +570,7 @@
 				_remove_button_clicked = false;
 				_build_railroad_button_proc[i](w);
 				UpdateRemoveWidgetStatus(w, i + RTW_BUILD_NS);
+				if (_ctrl_pressed) RailToolbar_CtrlChanged(w);
 				break;
 			}
 		}
@@ -549,7 +597,7 @@
 			switch (e->we.place.select_proc) {
 				case DDSP_BUILD_BRIDGE:
 					ResetObjectToPlace();
-					ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
+					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
 					break;
 
 				case DDSP_PLACE_AUTORAIL:
@@ -564,15 +612,16 @@
 					GUIPlaceProcDragXY(e);
 					break;
 
-				case DDSP_REMOVE_STATION:
-					DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
-					break;
-
 				case DDSP_CONVERT_RAIL:
 					DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
 					break;
 
+				case DDSP_REMOVE_STATION:
 				case DDSP_BUILD_STATION:
+					if (_remove_button_clicked) {
+						DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
+						break;
+					}
 					HandleStationPlacement(start_tile, end_tile);
 					break;
 
@@ -607,6 +656,11 @@
 	case WE_DESTROY:
 		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 		break;
+
+	case WE_CTRL_CHANGED:
+		/* do not toggle Remove button by Ctrl when placing station */
+		if (!w->IsWidgetLowered(RTW_BUILD_STATION) && RailToolbar_CtrlChanged(w)) e->we.ctrl.cont = false;
+		break;
 	}
 }
 
@@ -818,7 +872,7 @@
 				SetTileSelectSize(x, y);
 		}
 
-		int rad = (_patches.modified_catchment) ? CA_TRAIN : 4;
+		int rad = (_patches.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
 
 		if (_station_show_coverage)
 			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
@@ -1579,3 +1633,4 @@
 }
 
 
+
--- a/src/rail_map.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/rail_map.h	Fri Feb 22 00:25:54 2008 +0000
@@ -409,6 +409,7 @@
 	RAIL_GROUND_FENCE_HORIZ2 = 11, ///< Grass with a fence at the northern side
 	RAIL_GROUND_ICE_DESERT   = 12, ///< Icy or sandy
 	RAIL_GROUND_WATER        = 13, ///< Grass with a fence and shore or water on the free halftile
+	RAIL_GROUND_HALF_SNOW    = 14, ///< Snow only on higher part of slope (steep or one corner raised)
 };
 
 static inline void SetRailGroundType(TileIndex t, RailGroundType rgt)
--- a/src/road_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/road_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -225,7 +225,7 @@
 
 			/* Don't allow road to be removed from the crossing when there is tram;
 			 * we can't draw the crossing without trambits ;) */
-			if (rt == ROADTYPE_ROAD && HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) && (flags & DC_EXEC || crossing_check)) return CMD_ERROR;
+			if (rt == ROADTYPE_ROAD && HasTileRoadType(tile, ROADTYPE_TRAM) && (flags & DC_EXEC || crossing_check)) return CMD_ERROR;
 
 			if (rt == ROADTYPE_ROAD) {
 				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
@@ -426,10 +426,9 @@
 			switch (GetRoadTileType(tile)) {
 				case ROAD_TILE_NORMAL: {
 					if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
-					if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
 					all_bits = GetAllRoadBits(tile);
-					if (!HasBit(GetRoadTypes(tile), rt)) break;
+					if (!HasTileRoadType(tile, rt)) break;
 
 					existing = GetRoadBits(tile, rt);
 					RoadBits merged = existing | pieces;
@@ -443,6 +442,8 @@
 						if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && GetRoadOwner(tile, ROADTYPE_ROAD) == _current_player) {
 							if (crossing) return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
 
+							if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+
 							/* Ignore half built tiles */
 							if (flags & DC_EXEC && rt != ROADTYPE_TRAM && (existing == ROAD_X || existing == ROAD_Y)) {
 								SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd);
@@ -455,7 +456,7 @@
 				} break;
 
 				case ROAD_TILE_CROSSING:
-					if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
+					if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
 					all_bits = GetCrossingRoadBits(tile);
 					if (pieces & ComplementRoadBits(all_bits)) goto do_clear;
 					break;
@@ -507,14 +508,12 @@
 
 		case MP_STATION:
 			if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
-			if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
-			/* Don't allow adding roadtype to the roadstop when vehicles are already driving on it */
-			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+			if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
 			break;
 
 		case MP_TUNNELBRIDGE:
 			if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
-			if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
+			if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
 			/* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */
 			if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR;
 			break;
@@ -542,7 +541,7 @@
 		pieces &= ComplementRoadBits(existing);
 
 		/* Check if new road bits will have the same foundation as other existing road types */
-		if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+		if (IsNormalRoad(tile)) {
 			Slope slope = GetTileSlope(tile, NULL);
 			Foundation found_new = GetRoadFoundation(slope, pieces | existing);
 
@@ -559,6 +558,8 @@
 		}
 	}
 
+	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+
 	cost.AddCost(CountBits(pieces) * _price.build_road);
 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		/* Pay for *every* tile of the bridge or tunnel */
@@ -602,7 +603,7 @@
 				break;
 		}
 
-		if (rt != ROADTYPE_TRAM && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+		if (rt != ROADTYPE_TRAM && IsNormalRoadTile(tile)) {
 			existing |= pieces;
 			SetDisallowedRoadDirections(tile, (existing == ROAD_X || existing == ROAD_Y) ?
 					GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE);
@@ -633,6 +634,8 @@
 	bool had_success = false;
 	DisallowedRoadDirections drd = DRD_NORTHBOUND;
 
+	_error_message = INVALID_STRING_ID;
+
 	if (p1 >= MapSize()) return CMD_ERROR;
 
 	start_tile = p1;
@@ -670,7 +673,6 @@
 		ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD);
 		if (CmdFailed(ret)) {
 			if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR;
-			_error_message = INVALID_STRING_ID;
 		} else {
 			had_success = true;
 			/* Only pay for the upgrade on one side of the bridges and tunnels */
@@ -944,7 +946,7 @@
 void DrawTramCatenary(TileInfo *ti, RoadBits tram)
 {
 	/* Don't draw the catenary under a low bridge */
-	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BUILDINGS)) {
+	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
 		uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
 
 		if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
@@ -961,8 +963,8 @@
 		front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram];
 	}
 
-	AddSortableSpriteToDraw(back,  PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_BUILDINGS));
-	AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_BUILDINGS));
+	AddSortableSpriteToDraw(back,  PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY));
+	AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY));
 }
 
 /**
@@ -1052,6 +1054,16 @@
 	/* Return if full detail is disabled, or we are zoomed fully out. */
 	if (!HasBit(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZOOM_LVL_DETAIL) return;
 
+	/* Do not draw details (street lights, trees) under low bridge */
+	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && (roadside == ROADSIDE_TREES || roadside == ROADSIDE_STREET_LIGHTS)) {
+		uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
+		uint minz = GetTileMaxZ(ti->tile) + 2 * TILE_HEIGHT;
+
+		if (roadside == ROADSIDE_TREES) minz += TILE_HEIGHT;
+
+		if (height < minz) return;
+	}
+
 	/* Draw extra details. */
 	for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) {
 		DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10);
@@ -1088,7 +1100,7 @@
 			}
 
 			DrawGroundSprite(image, pal);
-			if (HasBit(GetRoadTypes(ti->tile), ROADTYPE_TRAM)) {
+			if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) {
 				DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal);
 				DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
 			}
@@ -1106,16 +1118,16 @@
 
 			palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
 
-			if (HasBit(GetRoadTypes(ti->tile), ROADTYPE_TRAM)) {
+			if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) {
 				dts =  &_tram_depot[GetRoadDepotDirection(ti->tile)];
 			} else {
 				dts =  &_road_depot[GetRoadDepotDirection(ti->tile)];
 			}
 
-			DrawGroundSprite(dts->ground_sprite, PAL_NONE);
+			DrawGroundSprite(dts->ground.sprite, PAL_NONE);
 
-			for (dtss = dts->seq; dtss->image != 0; dtss++) {
-				SpriteID image = dtss->image;
+			for (dtss = dts->seq; dtss->image.sprite != 0; dtss++) {
+				SpriteID image = dtss->image.sprite;
 				SpriteID pal;
 
 				if (!IsTransparencySet(TO_BUILDINGS) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
@@ -1147,11 +1159,11 @@
 	x += 33;
 	y += 17;
 
-	DrawSprite(dts->ground_sprite, PAL_NONE, x, y);
+	DrawSprite(dts->ground.sprite, PAL_NONE, x, y);
 
-	for (dtss = dts->seq; dtss->image != 0; dtss++) {
+	for (dtss = dts->seq; dtss->image.sprite != 0; dtss++) {
 		Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
-		SpriteID image = dtss->image;
+		SpriteID image = dtss->image.sprite;
 
 		DrawSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE, x + pt.x, y + pt.y);
 	}
@@ -1163,7 +1175,7 @@
 	Slope tileh = GetTileSlope(tile, &z);
 
 	if (tileh == SLOPE_FLAT) return z;
-	if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+	if (IsNormalRoad(tile)) {
 		Foundation f = GetRoadFoundation(tileh, GetAllRoadBits(tile));
 		z += ApplyFoundationToSlope(f, &tileh);
 		return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
@@ -1174,7 +1186,7 @@
 
 static Foundation GetFoundation_Road(TileIndex tile, Slope tileh)
 {
-	if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+	if (IsNormalRoad(tile)) {
 		return GetRoadFoundation(tileh, GetAllRoadBits(tile));
 	} else {
 		return FlatteningFoundation(tileh);
@@ -1227,7 +1239,7 @@
 			break;
 	}
 
-	if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) return;
+	if (IsRoadDepot(tile)) return;
 
 	const Town* t = ClosestTownFromTile(tile, (uint)-1);
 	if (!HasRoadWorks(tile)) {
@@ -1239,7 +1251,7 @@
 			/* Show an animation to indicate road work */
 			if (t->road_build_months != 0 &&
 					(DistanceManhattan(t->xy, tile) < 8 || grp != HZB_TOWN_EDGE) &&
-					GetRoadTileType(tile) == ROAD_TILE_NORMAL && CountBits(GetAllRoadBits(tile)) > 1 ) {
+					IsNormalRoad(tile) && CountBits(GetAllRoadBits(tile)) > 1 ) {
 				if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && Chance16(1, 40)) {
 					StartRoadWorks(tile);
 
@@ -1295,47 +1307,64 @@
 
 static void ClickTile_Road(TileIndex tile)
 {
-	if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) ShowDepotWindow(tile, VEH_ROAD);
+	if (IsRoadDepot(tile)) ShowDepotWindow(tile, VEH_ROAD);
 }
 
+/* Converts RoadBits to TrackBits */
 static const byte _road_trackbits[16] = {
 	0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F,
 };
 
-static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
-
+	TrackdirBits trackdirbits = TRACKDIR_BIT_NONE;
+	TrackdirBits red_signals = TRACKDIR_BIT_NONE; // crossing barred
 	switch (mode) {
 		case TRANSPORT_RAIL:
-			if (!IsLevelCrossing(tile)) return 0;
-			return GetCrossingRailBits(tile) * 0x101;
+			if (IsLevelCrossing(tile)) trackdirbits = TrackBitsToTrackdirBits(GetCrossingRailBits(tile));
+			break;
 
 		case TRANSPORT_ROAD:
-			if ((GetRoadTypes(tile) & sub_mode) == 0) return 0;
+			if ((GetRoadTypes(tile) & sub_mode) == 0) break;
 			switch (GetRoadTileType(tile)) {
 				case ROAD_TILE_NORMAL: {
-					RoadType rt = (RoadType)FindFirstBit(sub_mode);
 					const uint drd_to_multiplier[DRD_END] = { 0x101, 0x100, 0x1, 0x0 };
+					RoadType rt = (RoadType)FindFirstBit(sub_mode);
+					RoadBits bits = GetRoadBits(tile, rt);
+
+					/* no roadbit at this side of tile, return 0 */
+					if (side != INVALID_DIAGDIR && (DiagDirToRoadBits(side) & bits) == 0) break;
+
 					uint multiplier = drd_to_multiplier[rt == ROADTYPE_TRAM ? DRD_NONE : GetDisallowedRoadDirections(tile)];
-					return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile, rt)] * multiplier;
+					if (!HasRoadWorks(tile)) trackdirbits = (TrackdirBits)(_road_trackbits[bits] * multiplier);
+					break;
 				}
 
 				case ROAD_TILE_CROSSING: {
-					uint32 r = AxisToTrackBits(GetCrossingRoadAxis(tile)) * 0x101;
+					Axis axis = GetCrossingRoadAxis(tile);
 
-					if (IsCrossingBarred(tile)) r *= 0x10001;
-					return r;
+					if (side != INVALID_DIAGDIR && axis != DiagDirToAxis(side)) break;
+
+					trackdirbits = TrackBitsToTrackdirBits(AxisToTrackBits(axis));
+					if (IsCrossingBarred(tile)) red_signals = trackdirbits;
+					break;
 				}
 
 				default:
-				case ROAD_TILE_DEPOT:
-					return AxisToTrackBits(DiagDirToAxis(GetRoadDepotDirection(tile))) * 0x101;
+				case ROAD_TILE_DEPOT: {
+					DiagDirection dir = GetRoadDepotDirection(tile);
+
+					if (side != INVALID_DIAGDIR && side != dir) break;
+
+					trackdirbits = TrackBitsToTrackdirBits(AxisToTrackBits(DiagDirToAxis(dir)));
+					break;
+				}
 			}
 			break;
 
 		default: break;
 	}
-	return 0;
+	return CombineTrackStatus(trackdirbits, red_signals);
 }
 
 static const StringID _road_tile_strings[] = {
@@ -1400,10 +1429,10 @@
 
 static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
-	if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
+	if (IsRoadDepot(tile)) {
 		if (GetTileOwner(tile) == old_player) {
 			if (new_player == PLAYER_SPECTATOR) {
-				DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+				DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
 			} else {
 				SetTileOwner(tile, new_player);
 			}
@@ -1412,7 +1441,8 @@
 	}
 
 	for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
-		if (!HasBit(GetRoadTypes(tile), rt)) continue;
+		/* ROADTYPE_ROAD denotes the tile owner, so update it too */
+		if (rt != ROADTYPE_ROAD && !HasTileRoadType(tile, rt)) continue;
 
 		if (GetRoadOwner(tile, rt) == old_player) {
 			SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
@@ -1422,7 +1452,7 @@
 	if (IsLevelCrossing(tile)) {
 		if (GetTileOwner(tile) == old_player) {
 			if (new_player == PLAYER_SPECTATOR) {
-				MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY));
+				DoCommand(tile, 0, GetCrossingRailTrack(tile), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
 			} else {
 				SetTileOwner(tile, new_player);
 			}
--- a/src/road_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/road_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -177,7 +177,7 @@
 {
 	tile += TileOffsByDiagDir(direction);
 	// if there is a roadpiece just outside of the station entrance, build a connecting route
-	if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+	if (IsNormalRoadTile(tile)) {
 		if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
 			DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD);
 		}
@@ -255,6 +255,38 @@
 
 typedef void OnButtonClick(Window *w);
 
+
+/** Toogles state of the Remove button of Build road toolbar
+ * @param w window the button belongs to
+ */
+static void ToggleRoadButton_Remove(Window *w)
+{
+	w->ToggleWidgetLoweredState(RTW_REMOVE);
+	w->InvalidateWidget(RTW_REMOVE);
+	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
+	SetSelectionRed(_remove_button_clicked);
+}
+
+/** Updates the Remove button because of Ctrl state change
+ * @param w window the button belongs to
+ * @return true iff the remove buton was changed
+ */
+static bool RoadToolbar_CtrlChanged(Window *w)
+{
+	if (w->IsWidgetDisabled(RTW_REMOVE)) return false;
+
+	/* allow ctrl to switch remove mode only for these widgets */
+	for (uint i = RTW_ROAD_X; i <= RTW_AUTOROAD; i++) {
+		if (w->IsWidgetLowered(i)) {
+			ToggleRoadButton_Remove(w);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+
 /**
  * Function that handles the click on the
  *  X road placement button.
@@ -338,10 +370,8 @@
 static void BuildRoadClick_Remove(Window *w)
 {
 	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
-	SetWindowDirty(w);
+	ToggleRoadButton_Remove(w);
 	SndPlayFx(SND_15_BEEP);
-	w->ToggleWidgetLoweredState(RTW_REMOVE);
-	SetSelectionRed(w->IsWidgetLowered(RTW_REMOVE));
 }
 
 /** Array with the handlers of the button-clicks for the road-toolbar */
@@ -446,6 +476,7 @@
 			_build_road_button_proc[e->we.click.widget - RTW_ROAD_X](w);
 		}
 		UpdateOptionWidgetStatus(w, e->we.click.widget);
+		if (_ctrl_pressed) RoadToolbar_CtrlChanged(w);
 		break;
 
 	case WE_KEYPRESS:
@@ -456,6 +487,7 @@
 				_one_way_button_clicked = false;
 				_build_road_button_proc[i](w);
 				UpdateOptionWidgetStatus(w, i + RTW_ROAD_X);
+				if (_ctrl_pressed) RoadToolbar_CtrlChanged(w);
 				break;
 			}
 		}
@@ -532,7 +564,7 @@
 			switch (e->we.place.select_proc) {
 				case DDSP_BUILD_BRIDGE:
 					ResetObjectToPlace();
-					ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
+					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
 					break;
 
 				case DDSP_DEMOLISH_AREA:
@@ -568,6 +600,10 @@
 	case WE_DESTROY:
 		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 		break;
+
+	case WE_CTRL_CHANGED:
+		if (RoadToolbar_CtrlChanged(w)) e->we.ctrl.cont = false;
+		break;
 	}
 }
 
@@ -809,7 +845,7 @@
 		DrawWindowWidgets(w);
 
 		if (_station_show_coverage) {
-			int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4;
+			int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
 			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 		} else {
 			SetTileSelectSize(1, 1);
--- a/src/road_map.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/road_map.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -16,7 +16,7 @@
 
 RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt)
 {
-	if (!HasBit(GetRoadTypes(tile), rt)) return ROAD_NONE;
+	if (!HasTileRoadType(tile, rt)) return ROAD_NONE;
 
 	switch (GetTileType(tile)) {
 		case MP_ROAD:
@@ -43,14 +43,10 @@
 
 TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
 {
-	uint32 r;
-
 	/* Don't allow local authorities to build roads through road depots or road stops. */
-	if ((IsTileType(tile, MP_ROAD) && IsTileDepotType(tile, TRANSPORT_ROAD)) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasBit(GetRoadTypes(tile), rt)) {
+	if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) {
 		return TRACK_BIT_NONE;
 	}
 
-	r = GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt));
-
-	return (TrackBits)(byte)(r | (r >> 8));
+	return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)));
 }
--- a/src/road_map.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/road_map.h	Fri Feb 22 00:25:54 2008 +0000
@@ -19,11 +19,21 @@
 };
 
 static inline RoadTileType GetRoadTileType(TileIndex t)
-	{
+{
 	assert(IsTileType(t, MP_ROAD));
 	return (RoadTileType)GB(_m[t].m5, 6, 2);
 }
 
+static inline bool IsNormalRoad(TileIndex t)
+{
+	return GetRoadTileType(t) == ROAD_TILE_NORMAL;
+}
+
+static inline bool IsNormalRoadTile(TileIndex t)
+{
+	return IsTileType(t, MP_ROAD) && IsNormalRoad(t);
+}
+
 static inline bool IsLevelCrossing(TileIndex t)
 {
 	return GetRoadTileType(t) == ROAD_TILE_CROSSING;
@@ -34,9 +44,19 @@
 	return IsTileType(t, MP_ROAD) && IsLevelCrossing(t);
 }
 
+static inline bool IsRoadDepot(TileIndex t)
+{
+	return GetRoadTileType(t) == ROAD_TILE_DEPOT;
+}
+
+static inline bool IsRoadDepotTile(TileIndex t)
+{
+	return IsTileType(t, MP_ROAD) && IsRoadDepot(t);
+}
+
 static inline RoadBits GetRoadBits(TileIndex t, RoadType rt)
 {
-	assert(GetRoadTileType(t) == ROAD_TILE_NORMAL);
+	assert(IsNormalRoad(t));
 	switch (rt) {
 		default: NOT_REACHED();
 		case ROADTYPE_ROAD: return (RoadBits)GB(_m[t].m4, 0, 4);
@@ -52,7 +72,7 @@
 
 static inline void SetRoadBits(TileIndex t, RoadBits r, RoadType rt)
 {
-	assert(GetRoadTileType(t) == ROAD_TILE_NORMAL); // XXX incomplete
+	assert(IsNormalRoad(t)); // XXX incomplete
 	switch (rt) {
 		default: NOT_REACHED();
 		case ROADTYPE_ROAD: SB(_m[t].m4, 0, 4, r); break;
@@ -80,6 +100,11 @@
 	}
 }
 
+static inline bool HasTileRoadType(TileIndex t, RoadType rt)
+{
+	return HasBit(GetRoadTypes(t), rt);
+}
+
 static inline Owner GetRoadOwner(TileIndex t, RoadType rt)
 {
 	if (!IsTileType(t, MP_ROAD)) return GetTileOwner(t);
@@ -159,7 +184,7 @@
  */
 static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
 {
-	assert(GetRoadTileType(t) == ROAD_TILE_NORMAL);
+	assert(IsNormalRoad(t));
 	return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
 }
 
@@ -170,36 +195,47 @@
  */
 static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
 {
-	assert(GetRoadTileType(t) == ROAD_TILE_NORMAL);
+	assert(IsNormalRoad(t));
 	assert(drd < DRD_END);
 	SB(_m[t].m5, 4, 2, drd);
 }
 
 static inline Axis GetCrossingRoadAxis(TileIndex t)
 {
-	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
+	assert(IsLevelCrossing(t));
 	return (Axis)GB(_m[t].m4, 6, 1);
 }
 
+static inline Axis GetCrossingRailAxis(TileIndex t)
+{
+	assert(IsLevelCrossing(t));
+	return OtherAxis((Axis)GetCrossingRoadAxis(t));
+}
+
 static inline RoadBits GetCrossingRoadBits(TileIndex tile)
 {
 	return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y;
 }
 
+static inline Track GetCrossingRailTrack(TileIndex tile)
+{
+	return AxisToTrack(GetCrossingRailAxis(tile));
+}
+
 static inline TrackBits GetCrossingRailBits(TileIndex tile)
 {
-	return AxisToTrackBits(OtherAxis(GetCrossingRoadAxis(tile)));
+	return AxisToTrackBits(GetCrossingRailAxis(tile));
 }
 
 static inline bool IsCrossingBarred(TileIndex t)
 {
-	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
+	assert(IsLevelCrossing(t));
 	return HasBit(_m[t].m4, 5);
 }
 
 static inline void SetCrossingBarred(TileIndex t, bool barred)
 {
-	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
+	assert(IsLevelCrossing(t));
 	SB(_m[t].m4, 5, 1, barred);
 }
 
@@ -280,7 +316,7 @@
 
 static inline DiagDirection GetRoadDepotDirection(TileIndex t)
 {
-	assert(GetRoadTileType(t) == ROAD_TILE_DEPOT);
+	assert(IsRoadDepot(t));
 	return (DiagDirection)GB(_m[t].m5, 0, 2);
 }
 
--- a/src/roadveh.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/roadveh.h	Fri Feb 22 00:25:54 2008 +0000
@@ -72,7 +72,7 @@
 	int GetImage(Direction direction) const;
 	int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
 	int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
-	Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * _price.roadveh_running; }
+	Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * GetPriceByIndex(RoadVehInfo(this->engine_type)->running_cost_class); }
 	bool IsInDepot() const { return this->u.road.state == RVSB_IN_DEPOT; }
 	void Tick();
 	void OnNewDay();
--- a/src/roadveh_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/roadveh_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -183,7 +183,7 @@
 	if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR;
 	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
-	if (HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
+	if (HasTileRoadType(tile, ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
 
 	uint num_vehicles = 1 + CountArticulatedParts(p1, false);
 
@@ -220,6 +220,8 @@
 		v->y_pos = y;
 		v->z_pos = GetSlopeZ(x, y);
 
+		v->running_ticks = 0;
+
 		v->u.road.state = RVSB_IN_DEPOT;
 		v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
 
@@ -397,14 +399,13 @@
 	DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, INVALID_DIAGDIR, INVALID_DIAGDIR
 };
 
-static bool EnumRoadSignalFindDepot(TileIndex tile, void* data, Trackdir trackdir, uint length, byte* state)
+static bool EnumRoadSignalFindDepot(TileIndex tile, void* data, Trackdir trackdir, uint length)
 {
 	RoadFindDepotData* rfdd = (RoadFindDepotData*)data;
 
 	tile += TileOffsByDiagDir(_road_pf_directions[trackdir]);
 
-	if (IsTileType(tile, MP_ROAD) &&
-			GetRoadTileType(tile) == ROAD_TILE_DEPOT &&
+	if (IsRoadDepotTile(tile) &&
 			IsTileOwner(tile, rfdd->owner) &&
 			length < rfdd->best_length) {
 		rfdd->best_length = length;
@@ -415,38 +416,36 @@
 
 static const Depot* FindClosestRoadDepot(const Vehicle* v)
 {
-	TileIndex tile = v->tile;
-
-	if (_patches.yapf.road_use_yapf) {
-		Depot* ret = YapfFindNearestRoadDepot(v);
-		return ret;
-	} else if (_patches.new_pathfinding_all) {
-		NPFFoundTargetData ftd;
-		/* See where we are now */
-		Trackdir trackdir = GetVehicleTrackdir(v);
+	switch (_patches.pathfinder_for_roadvehs) {
+		case VPF_YAPF: /* YAPF */
+			return YapfFindNearestRoadDepot(v);
 
-		ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, v->tile, ReverseTrackdir(trackdir), TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES, 0);
-		if (ftd.best_bird_dist == 0) {
-			return GetDepotByTile(ftd.node.tile); /* Target found */
-		} else {
-			return NULL; /* Target not found */
-		}
-		/* We do not search in two directions here, why should we? We can't reverse right now can we? */
-	} else {
-		RoadFindDepotData rfdd;
+		case VPF_NPF: { /* NPF */
+			/* See where we are now */
+			Trackdir trackdir = GetVehicleTrackdir(v);
 
-		rfdd.owner = v->owner;
-		rfdd.best_length = (uint)-1;
+			NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, v->tile, ReverseTrackdir(trackdir), false, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES, 0);
 
-		/* search in all directions */
-		for (DiagDirection i = DIAGDIR_BEGIN; i != DIAGDIR_END; i++) {
-			FollowTrack(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, i, EnumRoadSignalFindDepot, NULL, &rfdd);
-		}
+			if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); /* Target found */
+		} break;
 
-		if (rfdd.best_length == (uint)-1) return NULL;
+		default:
+		case VPF_OPF: { /* OPF */
+			RoadFindDepotData rfdd;
 
-		return GetDepotByTile(rfdd.tile);
+			rfdd.owner = v->owner;
+			rfdd.best_length = UINT_MAX;
+
+			/* search in all directions */
+			for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) {
+				FollowTrack(v->tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, d, EnumRoadSignalFindDepot, NULL, &rfdd);
+			}
+
+			if (rfdd.best_length != UINT_MAX) return GetDepotByTile(rfdd.tile);
+		} break;
 	}
+
+	return NULL; /* Target not found */
 }
 
 /** Send a road vehicle to the depot.
@@ -551,7 +550,7 @@
 		return CMD_ERROR;
 	}
 
-	if (IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) return CMD_ERROR;
+	if (IsNormalRoadTile(v->tile) && GetDisallowedRoadDirections(v->tile) != DRD_NONE) return CMD_ERROR;
 
 	if (IsTileType(v->tile, MP_TUNNELBRIDGE) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR;
 
@@ -959,7 +958,7 @@
 	/* Clamp */
 	spd = min(spd, v->max_speed);
 	if (v->u.road.state == RVSB_WORMHOLE && !(v->vehstatus & VS_HIDDEN)) {
-		spd = min(spd, GetBridge(GetBridgeType(v->tile))->speed * 2);
+		spd = min(spd, GetBridgeSpec(GetBridgeType(v->tile))->speed * 2);
 	}
 
 	/* updates statusbar only if speed have changed to save CPU time */
@@ -1012,10 +1011,10 @@
 	const Vehicle* u;
 	const Vehicle* v;
 	TileIndex tile;
-	uint16 tilebits;
+	Trackdir trackdir;
 };
 
-static void* EnumFindVehToOvertake(Vehicle* v, void* data)
+static void* EnumFindVehBlockingOvertake(Vehicle* v, void* data)
 {
 	const OvertakeData* od = (OvertakeData*)data;
 
@@ -1024,22 +1023,29 @@
 			v : NULL;
 }
 
-static bool FindRoadVehToOvertake(OvertakeData *od)
+/**
+ * Check if overtaking is possible on a piece of track
+ *
+ * @param od Information about the tile and the involved vehicles
+ * @return true if we have to abort overtaking
+ */
+static bool CheckRoadBlockedForOvertaking(OvertakeData *od)
 {
-	uint32 bits;
+	TrackStatus ts = GetTileTrackStatus(od->tile, TRANSPORT_ROAD, od->v->u.road.compatible_roadtypes);
+	TrackdirBits trackdirbits = TrackStatusToTrackdirBits(ts);
+	TrackdirBits red_signals = TrackStatusToRedSignals(ts); // barred level crossing
+	TrackBits trackbits = TrackdirBitsToTrackBits(trackdirbits);
 
-	bits = GetTileTrackStatus(od->tile, TRANSPORT_ROAD, od->v->u.road.compatible_roadtypes);
-	bits |= bits >> 8;
+	/* Track does not continue along overtaking direction || track has junction || levelcrossing is barred */
+	if (!HasBit(trackdirbits, od->trackdir) || (trackbits & ~TRACK_BIT_CROSS) || (red_signals != TRACKDIR_BIT_NONE)) return true;
 
-	if (!(od->tilebits & bits) || (bits & 0x3C3C) || (bits & 0x3F3F0000))
-		return true;
-	return VehicleFromPos(od->tile, od, EnumFindVehToOvertake) != NULL;
+	/* Are there more vehicles on the tile except the two vehicles involved in overtaking */
+	return VehicleFromPos(od->tile, od, EnumFindVehBlockingOvertake) != NULL;
 }
 
 static void RoadVehCheckOvertake(Vehicle *v, Vehicle *u)
 {
 	OvertakeData od;
-	uint16 tt;
 
 	od.v = v;
 	od.u = u;
@@ -1059,32 +1065,31 @@
 	/* For now, articulated road vehicles can't overtake anything. */
 	if (RoadVehHasArticPart(v)) return;
 
+	/* Vehicles are not driving in same direction || direction is not a diagonal direction */
 	if (v->direction != u->direction || !(v->direction & 1)) return;
 
 	/* Check if vehicle is in a road stop, depot, tunnel or bridge or not on a straight road */
 	if (v->u.road.state >= RVSB_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->u.road.state & RVSB_TRACKDIR_MASK))) return;
 
-	tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
-	tt |= tt >> 8;
-	tt &= 0x3F;
+	od.trackdir = DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
 
-	if ((tt & 3) == 0) return;
-	if ((tt & 0x3C) != 0) return;
-
-	if (tt == 3) tt = (v->direction & 2) ? 2 : 1;
-	od.tilebits = tt;
-
+	/* Are the current and the next tile suitable for overtaking?
+	 *  - Does the track continue along od.trackdir
+	 *  - No junctions
+	 *  - No barred levelcrossing
+	 *  - No other vehicles in the way
+	 */
 	od.tile = v->tile;
-	if (FindRoadVehToOvertake(&od)) return;
+	if (CheckRoadBlockedForOvertaking(&od)) return;
 
 	od.tile = v->tile + TileOffsByDiagDir(DirToDiagDir(v->direction));
-	if (FindRoadVehToOvertake(&od)) return;
+	if (CheckRoadBlockedForOvertaking(&od)) return;
 
 	if (od.u->cur_speed == 0 || od.u->vehstatus& VS_STOPPED) {
 		v->u.road.overtaking_ctr = 0x11;
 		v->u.road.overtaking = 0x10;
 	} else {
-//		if (FindRoadVehToOvertake(&od)) return;
+//		if (CheckRoadBlockedForOvertaking(&od)) return;
 		v->u.road.overtaking_ctr = 0;
 		v->u.road.overtaking = 0x10;
 	}
@@ -1117,7 +1122,7 @@
 	uint mindist;
 };
 
-static bool EnumRoadTrackFindDist(TileIndex tile, void* data, Trackdir trackdir, uint length, byte* state)
+static bool EnumRoadTrackFindDist(TileIndex tile, void* data, Trackdir trackdir, uint length)
 {
 	FindRoadToChooseData* frd = (FindRoadToChooseData*)data;
 	uint dist = DistanceManhattan(tile, frd->dest);
@@ -1131,11 +1136,11 @@
 	return false;
 }
 
-static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
+static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
 {
 
 	void* perf = NpfBeginInterval();
-	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, sub_type, owner, railtypes);
+	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, ignore_start_tile, target, type, sub_type, owner, railtypes);
 	int t = NpfEndInterval(perf);
 	DEBUG(yapf, 4, "[NPFR] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
 	return ret;
@@ -1157,12 +1162,12 @@
 	FindRoadToChooseData frd;
 	Trackdir best_track;
 
-	uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
-	TrackdirBits signal    = (TrackdirBits)GB(r, 16, 16);
-	TrackdirBits trackdirs = (TrackdirBits)GB(r,  0, 16);
+	TrackStatus ts = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
+	TrackdirBits red_signals = TrackStatusToRedSignals(ts); // crossing
+	TrackdirBits trackdirs = TrackStatusToTrackdirBits(ts);
 
 	if (IsTileType(tile, MP_ROAD)) {
-		if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && (!IsTileOwner(tile, v->owner) || GetRoadDepotDirection(tile) == enterdir || (GetRoadTypes(tile) & v->u.road.compatible_roadtypes) == 0)) {
+		if (IsRoadDepot(tile) && (!IsTileOwner(tile, v->owner) || GetRoadDepotDirection(tile) == enterdir || (GetRoadTypes(tile) & v->u.road.compatible_roadtypes) == 0)) {
 			/* Road depot owned by another player or with the wrong orientation */
 			trackdirs = TRACKDIR_BIT_NONE;
 		}
@@ -1220,106 +1225,110 @@
 		return_track(FindFirstBit2x64(trackdirs));
 	}
 
-	if (_patches.yapf.road_use_yapf) {
-		Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir);
-		if (trackdir != INVALID_TRACKDIR) return_track(trackdir);
-		return_track(PickRandomBit(trackdirs));
-	} else if (_patches.new_pathfinding_all) {
-		NPFFindStationOrTileData fstd;
-		NPFFoundTargetData ftd;
-		Trackdir trackdir;
-
-		NPFFillWithOrderData(&fstd, v);
-		trackdir = DiagdirToDiagTrackdir(enterdir);
-		//debug("Finding path. Enterdir: %d, Trackdir: %d", enterdir, trackdir);
+	switch (_patches.pathfinder_for_roadvehs) {
+		case VPF_YAPF: { /* YAPF */
+			Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir);
+			if (trackdir != INVALID_TRACKDIR) return_track(trackdir);
+			return_track(PickRandomBit(trackdirs));
+		} break;
 
-		ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES);
-		if (ftd.best_trackdir == INVALID_TRACKDIR) {
-			/* We are already at our target. Just do something
-			 * @todo: maybe display error?
-			 * @todo: go straight ahead if possible? */
-			return_track(FindFirstBit2x64(trackdirs));
-		} else {
-			/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
-			the direction we need to take to get there, if ftd.best_bird_dist is not 0,
-			we did not find our target, but ftd.best_trackdir contains the direction leading
-			to the tile closest to our target. */
-			return_track(ftd.best_trackdir);
-		}
-	} else {
-		DiagDirection dir;
+		case VPF_NPF: { /* NPF */
+			NPFFindStationOrTileData fstd;
 
-		if (IsTileType(desttile, MP_ROAD)) {
-			if (GetRoadTileType(desttile) == ROAD_TILE_DEPOT) {
-				dir = GetRoadDepotDirection(desttile);
-				goto do_it;
+			NPFFillWithOrderData(&fstd, v);
+			Trackdir trackdir = DiagdirToDiagTrackdir(enterdir);
+			//debug("Finding path. Enterdir: %d, Trackdir: %d", enterdir, trackdir);
+
+			NPFFoundTargetData ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES);
+			if (ftd.best_trackdir == INVALID_TRACKDIR) {
+				/* We are already at our target. Just do something
+				 * @todo: maybe display error?
+				 * @todo: go straight ahead if possible? */
+				return_track(FindFirstBit2x64(trackdirs));
+			} else {
+				/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
+				 * the direction we need to take to get there, if ftd.best_bird_dist is not 0,
+				 * we did not find our target, but ftd.best_trackdir contains the direction leading
+				 * to the tile closest to our target. */
+				return_track(ftd.best_trackdir);
 			}
-		} else if (IsTileType(desttile, MP_STATION)) {
-			/* For drive-through stops we can head for the actual station tile */
-			if (IsStandardRoadStopTile(desttile)) {
-				dir = GetRoadStopDir(desttile);
+		} break;
+
+		default:
+		case VPF_OPF: { /* OPF */
+			DiagDirection dir;
+
+			if (IsTileType(desttile, MP_ROAD)) {
+				if (IsRoadDepot(desttile)) {
+					dir = GetRoadDepotDirection(desttile);
+					goto do_it;
+				}
+			} else if (IsTileType(desttile, MP_STATION)) {
+				/* For drive-through stops we can head for the actual station tile */
+				if (IsStandardRoadStopTile(desttile)) {
+					dir = GetRoadStopDir(desttile);
 do_it:;
-				/* When we are heading for a depot or station, we just
-				 * pretend we are heading for the tile in front, we'll
-				 * see from there */
-				desttile += TileOffsByDiagDir(dir);
-				if (desttile == tile && trackdirs & _road_exit_dir_to_incoming_trackdirs[dir]) {
-					/* If we are already in front of the
-					 * station/depot and we can get in from here,
-					 * we enter */
-					return_track(FindFirstBit2x64(trackdirs & _road_exit_dir_to_incoming_trackdirs[dir]));
+					/* When we are heading for a depot or station, we just
+					 * pretend we are heading for the tile in front, we'll
+					 * see from there */
+					desttile += TileOffsByDiagDir(dir);
+					if (desttile == tile && trackdirs & _road_exit_dir_to_incoming_trackdirs[dir]) {
+						/* If we are already in front of the
+						 * station/depot and we can get in from here,
+						 * we enter */
+						return_track(FindFirstBit2x64(trackdirs & _road_exit_dir_to_incoming_trackdirs[dir]));
+					}
 				}
 			}
-		}
-		/* Do some pathfinding */
-		frd.dest = desttile;
+			/* Do some pathfinding */
+			frd.dest = desttile;
 
-		best_track = INVALID_TRACKDIR;
-		uint best_dist = (uint)-1;
-		uint best_maxlen = (uint)-1;
-		uint bitmask = (uint)trackdirs;
-		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, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, _road_pf_directions[i], EnumRoadTrackFindDist, NULL, &frd);
+			best_track = INVALID_TRACKDIR;
+			uint best_dist = UINT_MAX;
+			uint best_maxlen = UINT_MAX;
+			uint bitmask = (uint)trackdirs;
+			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_MAX;
+				frd.mindist = UINT_MAX;
+				FollowTrack(tile, 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;
+				}
 			}
-		}
+		} break;
 	}
 
 found_best_track:;
 
-	if (HasBit(signal, best_track)) return INVALID_TRACKDIR;
+	if (HasBit(red_signals, best_track)) return INVALID_TRACKDIR;
 
 	return best_track;
 }
 
 static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
 {
-	uint dist;
-	if (_patches.yapf.road_use_yapf) {
+	if (_patches.pathfinder_for_roadvehs == VPF_YAPF) {
 		/* use YAPF */
-		dist = YapfRoadVehDistanceToTile(v, tile);
-	} else {
-		/* use NPF */
-		NPFFindStationOrTileData fstd;
-		Trackdir trackdir = GetVehicleTrackdir(v);
-		assert(trackdir != INVALID_TRACKDIR);
+		return YapfRoadVehDistanceToTile(v, tile);
+	}
 
-		fstd.dest_coords = tile;
-		fstd.station_index = INVALID_STATION; // indicates that the destination is a tile, not a station
+	/* use NPF */
+	Trackdir trackdir = GetVehicleTrackdir(v);
+	assert(trackdir != INVALID_TRACKDIR);
 
-		dist = NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES).best_path_dist;
-		/* change units from NPF_TILE_LENGTH to # of tiles */
-		if (dist != UINT_MAX)
-			dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH;
-	}
+	NPFFindStationOrTileData fstd;
+	fstd.dest_coords = tile;
+	fstd.station_index = INVALID_STATION; // indicates that the destination is a tile, not a station
+
+	uint dist = NPFRouteToStationOrTile(v->tile, trackdir, false, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES).best_path_dist;
+	/* change units from NPF_TILE_LENGTH to # of tiles */
+	if (dist != UINT_MAX) dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH;
+
 	return dist;
 }
 
@@ -1345,7 +1354,7 @@
 	byte x, y;
 };
 
-#include "table/roadveh.h"
+#include "table/roadveh_movement.h"
 
 static const byte _road_veh_data_1[] = {
 	20, 20, 16, 16, 0, 0, 0, 0,
@@ -1412,7 +1421,7 @@
 
 		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 			diag_dir = GetTunnelBridgeDirection(tile);
-		} else if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
+		} else if (IsRoadDepotTile(tile)) {
 			diag_dir = ReverseDiagDir(GetRoadDepotDirection(tile));
 		}
 
@@ -1581,8 +1590,7 @@
 					case TRACKDIR_RVREV_NW: needed = ROAD_SE; break;
 				}
 				if ((v->Previous() != NULL && v->Previous()->tile == tile) ||
-						(IsRoadVehFront(v) && IsTileType(tile, MP_ROAD) &&
-							GetRoadTileType(tile) == ROAD_TILE_NORMAL && !HasRoadWorks(tile) &&
+						(IsRoadVehFront(v) && IsNormalRoadTile(tile) && !HasRoadWorks(tile) &&
 							(needed & GetRoadBits(tile, ROADTYPE_TRAM)) != ROAD_NONE)) {
 					/*
 					 * Taking the 'big' corner for trams only happens when:
@@ -1613,7 +1621,7 @@
 					v->cur_speed = 0;
 					return false;
 				}
-			} else if (IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) {
+			} else if (IsNormalRoadTile(v->tile) && GetDisallowedRoadDirections(v->tile) != DRD_NONE) {
 				v->cur_speed = 0;
 				return false;
 			} else {
@@ -1756,9 +1764,7 @@
 	/* This vehicle is not in a wormhole and it hasn't entered a new tile. If
 	 * it's on a depot tile, check if it's time to activate the next vehicle in
 	 * the chain yet. */
-	if (v->Next() != NULL &&
-			IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_DEPOT) {
-
+	if (v->Next() != NULL && IsRoadDepotTile(v->tile)) {
 		if (v->u.road.frame == v->u.road.cached_veh_length + RVC_DEPOT_START_FRAME) {
 			RoadVehLeaveDepot(v->Next(), false);
 		}
@@ -1967,7 +1973,10 @@
 {
 	AgeRoadVehCargo(this);
 
-	if (IsRoadVehFront(this)) RoadVehController(this);
+	if (IsRoadVehFront(this)) {
+		if (!(this->vehstatus & VS_STOPPED)) this->running_ticks++;
+		RoadVehController(this);
+	}
 }
 
 static void CheckIfRoadVehNeedsService(Vehicle *v)
@@ -2009,8 +2018,6 @@
 
 void RoadVehicle::OnNewDay()
 {
-	CommandCost cost(EXPENSES_ROADVEH_RUN);
-
 	if (!IsRoadVehFront(this)) return;
 
 	if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
@@ -2028,10 +2035,8 @@
 		ClearSlot(this);
 	}
 
-	if (this->vehstatus & VS_STOPPED) return;
-
 	/* update destination */
-	if (this->current_order.type == OT_GOTO_STATION && this->u.road.slot == NULL && !(this->vehstatus & VS_CRASHED)) {
+	if (!(this->vehstatus & VS_STOPPED) && this->current_order.type == OT_GOTO_STATION && this->u.road.slot == NULL && !(this->vehstatus & VS_CRASHED)) {
 		Station *st = GetStation(this->current_order.dest);
 		RoadStop *rs = st->GetPrimaryRoadStop(this);
 		RoadStop *best = NULL;
@@ -2089,9 +2094,13 @@
 		}
 	}
 
-	cost = CommandCost(EXPENSES_ROADVEH_RUN, RoadVehInfo(this->engine_type)->running_cost * _price.roadveh_running / 364);
+	if (this->running_ticks == 0) return;
 
-	this->profit_this_year -= cost.GetCost() >> 8;
+	const RoadVehicleInfo *rvi = RoadVehInfo(this->engine_type);
+	CommandCost cost(EXPENSES_ROADVEH_RUN, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) * this->running_ticks / (364 * DAY_TICKS));
+
+	this->profit_this_year -= cost.GetCost();
+	this->running_ticks = 0;
 
 	SubtractMoneyFromPlayerFract(this->owner, cost);
 
--- a/src/saveload.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/saveload.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -34,7 +34,7 @@
 
 #include "table/strings.h"
 
-extern const uint16 SAVEGAME_VERSION = 86;
+extern const uint16 SAVEGAME_VERSION = 89;
 uint16 _sl_version;       ///< the major savegame version identifier
 byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 
@@ -1329,64 +1329,56 @@
 {
 	/* After version 4.3 REF_VEHICLE_OLD is saved as REF_VEHICLE,
 	 * and should be loaded like that */
-	if (rt == REF_VEHICLE_OLD && !CheckSavegameVersionOldStyle(4, 4))
+	if (rt == REF_VEHICLE_OLD && !CheckSavegameVersionOldStyle(4, 4)) {
 		rt = REF_VEHICLE;
+	}
 
 	/* No need to look up NULL pointers, just return immediately */
-	if (rt != REF_VEHICLE_OLD && index == 0)
+	if (rt != REF_VEHICLE_OLD && index == 0) {
 		return NULL;
+	}
 
 	index--; // correct for the NULL index
 
 	switch (rt) {
-		case REF_ORDER: {
-			if (!_Order_pool.AddBlockIfNeeded(index))
-				error("Orders: failed loading savegame: too many orders");
-			return GetOrder(index);
-		}
-		case REF_VEHICLE: {
-			if (!_Vehicle_pool.AddBlockIfNeeded(index))
-				error("Vehicles: failed loading savegame: too many vehicles");
-			return GetVehicle(index);
-		}
-		case REF_STATION: {
-			if (!_Station_pool.AddBlockIfNeeded(index))
-				error("Stations: failed loading savegame: too many stations");
-			return GetStation(index);
-		}
-		case REF_TOWN: {
-			if (!_Town_pool.AddBlockIfNeeded(index))
-				error("Towns: failed loading savegame: too many towns");
-			return GetTown(index);
-		}
-		case REF_ROADSTOPS: {
-			if (!_RoadStop_pool.AddBlockIfNeeded(index))
-				error("RoadStops: failed loading savegame: too many RoadStops");
-			return GetRoadStop(index);
-		}
-		case REF_ENGINE_RENEWS: {
-			if (!_EngineRenew_pool.AddBlockIfNeeded(index))
-				error("EngineRenews: failed loading savegame: too many EngineRenews");
-			return GetEngineRenew(index);
-		}
-		case REF_CARGO_PACKET: {
-			if (!_CargoPacket_pool.AddBlockIfNeeded(index))
-				error("CargoPackets: failed loading savegame: too many Cargo packets");
-			return GetCargoPacket(index);
-		}
+		case REF_ORDER:
+			if (_Order_pool.AddBlockIfNeeded(index)) return GetOrder(index);
+			error("Orders: failed loading savegame: too many orders");
 
-		case REF_VEHICLE_OLD: {
+		case REF_VEHICLE:
+			if (_Vehicle_pool.AddBlockIfNeeded(index)) return GetVehicle(index);
+			error("Vehicles: failed loading savegame: too many vehicles");
+
+		case REF_STATION:
+			if (_Station_pool.AddBlockIfNeeded(index)) return GetStation(index);
+			error("Stations: failed loading savegame: too many stations");
+
+		case REF_TOWN:
+			if (_Town_pool.AddBlockIfNeeded(index)) return GetTown(index);
+			error("Towns: failed loading savegame: too many towns");
+
+		case REF_ROADSTOPS:
+			if (_RoadStop_pool.AddBlockIfNeeded(index)) return GetRoadStop(index);
+			error("RoadStops: failed loading savegame: too many RoadStops");
+
+		case REF_ENGINE_RENEWS:
+			if (_EngineRenew_pool.AddBlockIfNeeded(index)) return GetEngineRenew(index);
+			error("EngineRenews: failed loading savegame: too many EngineRenews");
+
+		case REF_CARGO_PACKET:
+			if (_CargoPacket_pool.AddBlockIfNeeded(index)) return GetCargoPacket(index);
+			error("CargoPackets: failed loading savegame: too many Cargo packets");
+
+		case REF_VEHICLE_OLD:
 			/* Old vehicles were saved differently:
 			 * invalid vehicle was 0xFFFF,
 			 * and the index was not - 1.. correct for this */
 			index++;
-			if (index == INVALID_VEHICLE)
-				return NULL;
+			if (index == INVALID_VEHICLE) return NULL;
 
-			if (!_Vehicle_pool.AddBlockIfNeeded(index))
-				error("Vehicles: failed loading savegame: too many vehicles");
-			return GetVehicle(index);
-		}
+			if (_Vehicle_pool.AddBlockIfNeeded(index)) return GetVehicle(index);
+			error("Vehicles: failed loading savegame: too many vehicles");
+
 		default: NOT_REACHED();
 	}
 
--- a/src/settings.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/settings.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -1276,7 +1276,8 @@
 #endif
 	  SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size,     4, 1, 64, 0, STR_NULL, NULL),
 	  SDTG_VAR("player_face",    SLE_UINT32, S, 0, _player_face,      0,0,0xFFFFFFFF,0, STR_NULL, NULL),
-	  SDTG_VAR("transparency_options", SLE_UINT8, S, 0, _transparency_opt, 0, 0,0xFF,0, STR_NULL, NULL),
+	  SDTG_VAR("transparency_options", SLE_UINT, S, 0, _transparency_opt,  0,0,0x1FF,0, STR_NULL, NULL),
+	  SDTG_VAR("transparency_locks", SLE_UINT, S, 0, _transparency_lock,   0,0,0x1FF,0, STR_NULL, NULL),
 	  SDTG_END()
 };
 
@@ -1393,11 +1394,15 @@
 	SDT_BOOL(Patches, mammoth_trains,                0,NN,  true,                    STR_CONFIG_PATCHES_MAMMOTHTRAINS,        NULL),
 	SDT_BOOL(Patches, gotodepot,                     0, 0,  true,                    STR_CONFIG_PATCHES_GOTODEPOT,            NULL),
 	SDT_BOOL(Patches, roadveh_queue,                 0, 0,  true,                    STR_CONFIG_PATCHES_ROADVEH_QUEUE,        NULL),
-	SDT_BOOL(Patches, new_pathfinding_all,           0, 0, false,                    STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL,  NULL),
 
-	SDT_CONDBOOL(Patches, yapf.ship_use_yapf,      28, SL_MAX_VERSION, 0, 0, false,  STR_CONFIG_PATCHES_YAPF_SHIPS,      NULL),
-	SDT_CONDBOOL(Patches, yapf.road_use_yapf,      28, SL_MAX_VERSION, 0, 0,  true,  STR_CONFIG_PATCHES_YAPF_ROAD,       NULL),
-	SDT_CONDBOOL(Patches, yapf.rail_use_yapf,      28, SL_MAX_VERSION, 0, 0,  true,  STR_CONFIG_PATCHES_YAPF_RAIL,       NULL),
+	SDT_CONDBOOL(Patches, new_pathfinding_all, 0,86, 0, 0, false,                    STR_NULL,                                NULL),
+	SDT_CONDBOOL(Patches, yapf.ship_use_yapf, 28,86, 0, 0, false,                    STR_NULL,                                NULL),
+	SDT_CONDBOOL(Patches, yapf.road_use_yapf, 28,86, 0, 0,  true,                    STR_NULL,                                NULL),
+	SDT_CONDBOOL(Patches, yapf.rail_use_yapf, 28,86, 0, 0,  true,                    STR_NULL,                                NULL),
+
+	SDT_CONDVAR(Patches, pathfinder_for_trains,   SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS,  NULL),
+	SDT_CONDVAR(Patches, pathfinder_for_roadvehs, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH, NULL),
+	SDT_CONDVAR(Patches, pathfinder_for_ships,    SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS,   NULL),
 
 	SDT_BOOL(Patches, train_income_warn,             S, 0,  true,                    STR_CONFIG_PATCHES_WARN_INCOME_LESS,     NULL),
 	 SDT_VAR(Patches, order_review_system,SLE_UINT8, S,MS,     2,     0,       2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW,         NULL),
--- a/src/settings_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/settings_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -24,6 +24,7 @@
 #include "core/alloc_func.hpp"
 #include "string_func.h"
 #include "gfx_func.h"
+#include "waypoint.h"
 #include "widgets/dropdown_type.h"
 #include "widgets/dropdown_func.h"
 
@@ -301,6 +302,7 @@
 					ReadLanguagePack(e->we.dropdown.index);
 					CheckForMissingGlyphsInLoadedLanguagePack();
 					UpdateAllStationVirtCoord();
+					UpdateAllWaypointSigns();
 					MarkWholeScreenDirty();
 					break;
 
@@ -555,7 +557,7 @@
 				value = ((GDType*)&_opt_mod_temp.diff)[i];
 
 				DrawArrowButtons(5, y, 3,
-						(diffic_d->clicked_button == i) ? 1 << diffic_d->clicked_increase : 0,
+						(diffic_d->clicked_button == i) ? 1 + !!diffic_d->clicked_increase : 0,
 						!(HasBit(disabled, i) || gsd->min == value),
 						!(HasBit(disabled, i) || gsd->max == value));
 
@@ -792,10 +794,9 @@
 	"mammoth_trains",
 	"gotodepot",
 	"roadveh_queue",
-	"new_pathfinding_all",
-	"yapf.ship_use_yapf",
-	"yapf.road_use_yapf",
-	"yapf.rail_use_yapf",
+	"pathfinder_for_trains",
+	"pathfinder_for_roadvehs",
+	"pathfinder_for_ships",
 	"train_income_warn",
 	"order_review_system",
 	"never_expire_vehicles",
@@ -858,6 +859,7 @@
 static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
 {
 	static Patches *patches_ptr;
+	static int patches_max = 0;
 
 	switch (e->event) {
 		case WE_CREATE: {
@@ -871,6 +873,8 @@
 				for (page = &_patches_page[0]; page != endof(_patches_page); page++) {
 					uint i;
 
+					if (patches_max < page->num) patches_max = page->num;
+
 					page->entries = MallocT<PatchEntry>(page->num);
 					for (i = 0; i != page->num; i++) {
 						uint index;
@@ -883,6 +887,13 @@
 				}
 				first_time = false;
 			}
+
+			/* Resize the window to fit the largest patch tab */
+			ResizeWindowForWidget(w, PATCHSEL_OPTIONSPANEL, 0, patches_max * 11);
+
+			/* Recentre the window for the new size */
+			w->top = w->top - (patches_max * 11) / 2;
+
 			w->LowerWidget(4);
 		} break;
 
@@ -1069,7 +1080,7 @@
 {   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_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
-{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   380, 0x0,                             STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,    50, 0x0,                             STR_NULL},
 
 {    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_CONFIG_PATCHES_GUI,          STR_NULL},
 {    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL},
@@ -1081,7 +1092,7 @@
 };
 
 static const WindowDesc _patches_selection_desc = {
-	WDP_CENTER, WDP_CENTER, 370, 381, 370, 381,
+	WDP_CENTER, WDP_CENTER, 370, 51, 370, 51,
 	WC_GAME_OPTIONS, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 	_patches_selection_widgets,
--- a/src/settings_type.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/settings_type.h	Fri Feb 22 00:25:54 2008 +0000
@@ -126,6 +126,10 @@
 	uint16 servint_aircraft;            ///< service interval for aircraft
 	uint16 servint_ships;               ///< service interval for ships
 
+	uint8 pathfinder_for_trains;        ///< the pathfinder to use for trains
+	uint8 pathfinder_for_roadvehs;      ///< the pathfinder to use for roadvehicles
+	uint8 pathfinder_for_ships;         ///< the pathfinder to use for ships
+
 	bool autorenew;
 	int16 autorenew_months;
 	int32 autorenew_money;
--- a/src/ship_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/ship_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -50,10 +50,9 @@
 	TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT, // 0x2A, // DIAGDIR_NW
 };
 
-static TrackBits GetTileShipTrackStatus(TileIndex tile)
+static inline TrackBits GetTileShipTrackStatus(TileIndex tile)
 {
-	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
-	return TrackdirBitsToTrackBits((TrackdirBits)(TRACKDIR_BIT_MASK & (r | r >> 8)));
+	return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
 }
 
 void DrawShipEngine(int x, int y, EngineID engine, SpriteID pal)
@@ -113,34 +112,32 @@
 
 static const Depot* FindClosestShipDepot(const Vehicle* v)
 {
+	if (_patches.pathfinder_for_ships == VPF_NPF) { /* NPF is used */
+		Trackdir trackdir = GetVehicleTrackdir(v);
+		NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
+
+		if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); /* Found target */
+
+		return NULL; /* Did not find target */
+	}
+
+	/* OPF or YAPF - find the closest depot */
+
 	const Depot* depot;
 	const Depot* best_depot = NULL;
-	uint dist;
-	uint best_dist = (uint)-1;
-	TileIndex tile;
-	TileIndex tile2 = v->tile;
+	uint best_dist = UINT_MAX;
 
-	if (_patches.new_pathfinding_all) {
-		NPFFoundTargetData ftd;
-		Trackdir trackdir = GetVehicleTrackdir(v);
-		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
-		if (ftd.best_bird_dist == 0) {
-			best_depot = GetDepotByTile(ftd.node.tile); /* Found target */
-		} else {
-			best_depot = NULL; /* Did not find target */
-		}
-	} else {
-		FOR_ALL_DEPOTS(depot) {
-			tile = depot->xy;
-			if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) {
-				dist = DistanceManhattan(tile, tile2);
-				if (dist < best_dist) {
-					best_dist = dist;
-					best_depot = depot;
-				}
+	FOR_ALL_DEPOTS(depot) {
+		TileIndex tile = depot->xy;
+		if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) {
+			uint dist = DistanceManhattan(tile, v->tile);
+			if (dist < best_dist) {
+				best_dist = dist;
+				best_depot = depot;
 			}
 		}
 	}
+
 	return best_depot;
 }
 
@@ -172,8 +169,6 @@
 
 void Ship::OnNewDay()
 {
-	CommandCost cost(EXPENSES_SHIP_RUN);
-
 	if ((++this->day_counter & 7) == 0)
 		DecreaseVehicleValue(this);
 
@@ -183,10 +178,12 @@
 
 	CheckOrders(this);
 
-	if (this->vehstatus & VS_STOPPED) return;
+	if (this->running_ticks == 0) return;
 
-	cost.AddCost(GetVehicleProperty(this, 0x0F, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running / 364);
-	this->profit_this_year -= cost.GetCost() >> 8;
+	CommandCost cost(EXPENSES_SHIP_RUN, GetVehicleProperty(this, 0x0F, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running * this->running_ticks / (364 * DAY_TICKS));
+
+	this->profit_this_year -= cost.GetCost();
+	this->running_ticks = 0;
 
 	SubtractMoneyFromPlayerFract(this->owner, cost);
 
@@ -430,7 +427,7 @@
 	uint best_length;
 };
 
-static bool ShipTrackFollower(TileIndex tile, PathFindShip *pfs, int track, uint length, byte *state)
+static bool ShipTrackFollower(TileIndex tile, PathFindShip *pfs, int track, uint length)
 {
 	/* Found dest? */
 	if (tile == pfs->dest_coords) {
@@ -510,11 +507,11 @@
 	return best_bird_dist;
 }
 
-static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypes railtypes)
+static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypes railtypes)
 {
 
 	void* perf = NpfBeginInterval();
-	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, 0, owner, railtypes);
+	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, ignore_start_tile, target, type, 0, owner, railtypes);
 	int t = NpfEndInterval(perf);
 	DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
 	return ret;
@@ -525,53 +522,52 @@
  * direction in which we are entering the tile */
 static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 {
-	assert(enterdir >= 0 && enterdir <= 3);
+	assert(IsValidDiagDirection(enterdir));
 
-	if (_patches.yapf.ship_use_yapf) {
-		Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
-		return (trackdir != INVALID_TRACKDIR) ? TrackdirToTrack(trackdir) : INVALID_TRACK;
-	} else if (_patches.new_pathfinding_all) {
-		NPFFindStationOrTileData fstd;
-		NPFFoundTargetData ftd;
-		TileIndex src_tile = TILE_ADD(tile, TileOffsByDiagDir(ReverseDiagDir(enterdir)));
-		Trackdir trackdir = GetVehicleTrackdir(v);
-		assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
+	switch (_patches.pathfinder_for_ships) {
+		case VPF_YAPF: { /* YAPF */
+			Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
+			if (trackdir != INVALID_TRACKDIR) return TrackdirToTrack(trackdir);
+		} break;
 
-		NPFFillWithOrderData(&fstd, v);
+		case VPF_NPF: { /* NPF */
+			NPFFindStationOrTileData fstd;
+			Trackdir trackdir = GetVehicleTrackdir(v);
+			assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
 
-		ftd = PerfNPFRouteToStationOrTile(src_tile, trackdir, &fstd, TRANSPORT_WATER, v->owner, INVALID_RAILTYPES);
+			NPFFillWithOrderData(&fstd, v);
 
-		if (ftd.best_trackdir != 0xff) {
+			NPFFoundTargetData ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_WATER, v->owner, INVALID_RAILTYPES);
+
 			/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
-			the direction we need to take to get there, if ftd.best_bird_dist is not 0,
-			we did not find our target, but ftd.best_trackdir contains the direction leading
-			to the tile closest to our target. */
-			return TrackdirToTrack(ftd.best_trackdir); /* TODO: Wrapper function? */
-		} else {
-			return INVALID_TRACK; /* Already at target, reverse? */
-		}
-	} else {
-		uint tot_dist, dist;
-		Track track;
-		TileIndex tile2;
+			 * the direction we need to take to get there, if ftd.best_bird_dist is not 0,
+			 * we did not find our target, but ftd.best_trackdir contains the direction leading
+			 * to the tile closest to our target. */
+			if (ftd.best_trackdir != 0xff) return TrackdirToTrack(ftd.best_trackdir); /* TODO: Wrapper function? */
+		} break;
 
-		tile2 = TILE_ADD(tile, -TileOffsByDiagDir(enterdir));
-		tot_dist = (uint)-1;
+		default:
+		case VPF_OPF: { /* OPF */
+			TileIndex tile2 = TILE_ADD(tile, -TileOffsByDiagDir(enterdir));
+			Track track;
 
-		/* Let's find out how far it would be if we would reverse first */
-		TrackBits b = GetTileShipTrackStatus(tile2) & _ship_sometracks[ReverseDiagDir(enterdir)] & v->u.ship.state;
-		if (b != 0) {
-			dist = FindShipTrack(v, tile2, ReverseDiagDir(enterdir), b, tile, &track);
-			if (dist != (uint)-1)
-				tot_dist = dist + 1;
-		}
-		/* And if we would not reverse? */
-		dist = FindShipTrack(v, tile, enterdir, tracks, 0, &track);
-		if (dist > tot_dist)
-			/* We could better reverse */
-			return INVALID_TRACK;
-		return track;
+			/* Let's find out how far it would be if we would reverse first */
+			TrackBits b = GetTileShipTrackStatus(tile2) & _ship_sometracks[ReverseDiagDir(enterdir)] & v->u.ship.state;
+
+			uint distr = UINT_MAX; // distance if we reversed
+			if (b != 0) {
+				distr = FindShipTrack(v, tile2, ReverseDiagDir(enterdir), b, tile, &track);
+				if (distr != UINT_MAX) distr++; // penalty for reversing
+			}
+
+			/* And if we would not reverse? */
+			uint dist = FindShipTrack(v, tile, enterdir, tracks, 0, &track);
+
+			if (dist <= distr) return track;
+		} break;
 	}
+
+	return INVALID_TRACK; /* We could better reverse */
 }
 
 static const Direction _new_vehicle_direction_table[] = {
@@ -595,10 +591,9 @@
 	return _new_vehicle_direction_table[offs];
 }
 
-static TrackBits GetAvailShipTracks(TileIndex tile, int dir)
+static inline TrackBits GetAvailShipTracks(TileIndex tile, int dir)
 {
-	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
-	return (TrackBits)((r | r >> 8) & _ship_sometracks[dir]);
+	return GetTileShipTrackStatus(tile) & _ship_sometracks[dir];
 }
 
 static const byte _ship_subcoord[4][6][3] = {
@@ -784,6 +779,8 @@
 
 void Ship::Tick()
 {
+	if (!(this->vehstatus & VS_STOPPED)) this->running_ticks++;
+
 	AgeShipCargo(this);
 	ShipController(this);
 }
@@ -846,6 +843,8 @@
 		v->y_pos = y;
 		v->z_pos = GetSlopeZ(x, y);
 
+		v->running_ticks = 0;
+
 		v->UpdateDeltaXY(v->direction);
 		v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
 
--- a/src/signal.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/signal.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -506,7 +506,7 @@
 				/* FALLTHROUGH */
 			case MP_STATION:
 			case MP_ROAD:
-				if ((TrackBits)(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _enterdir_to_trackbits[dir]) != TRACK_BIT_NONE) {
+				if ((TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0)) & _enterdir_to_trackbits[dir]) != TRACK_BIT_NONE) {
  					/* only add to set when there is some 'interesting' track */
 					_tbdset.Add(tile, dir);
 					_tbdset.Add(tile + TileOffsByDiagDir(dir), ReverseDiagDir(dir));
@@ -517,7 +517,7 @@
 				/* jump to next tile */
 				tile = tile + TileOffsByDiagDir(dir);
 				dir = ReverseDiagDir(dir);
-				if ((TrackBits)(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _enterdir_to_trackbits[dir]) != TRACK_BIT_NONE) {
+				if ((TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0)) & _enterdir_to_trackbits[dir]) != TRACK_BIT_NONE) {
 					_tbdset.Add(tile, dir);
 					break;
 				}
--- a/src/sound.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/sound.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -209,7 +209,7 @@
 	}
 }
 
-static void SndPlayScreenCoordFx(SoundFx sound, int x, int y)
+static void SndPlayScreenCoordFx(SoundFx sound, int left, int right, int top, int bottom)
 {
 	Window* const *wz;
 
@@ -219,13 +219,15 @@
 		const ViewPort *vp = (*wz)->viewport;
 
 		if (vp != NULL &&
-				IsInsideBS(x, vp->virtual_left, vp->virtual_width) &&
-				IsInsideBS(y, vp->virtual_top, vp->virtual_height)) {
-			int left = (x - vp->virtual_left);
+				left < vp->virtual_left + vp->virtual_width && right > vp->virtual_left &&
+				top < vp->virtual_top + vp->virtual_height && bottom > vp->virtual_top) {
+			int screen_x = (left + right) / 2 - vp->virtual_left;
+			int width = (vp->virtual_width == 0 ? 1 : vp->virtual_width);
+			int panning = (screen_x * PANNING_LEVELS * 2) / width - PANNING_LEVELS;
 
 			StartSound(
 				sound,
-				left / max(1, vp->virtual_width / ((PANNING_LEVELS << 1) + 1)) - PANNING_LEVELS,
+				panning,
 				(msf.effect_vol * _vol_factor_by_zoom[vp->zoom - ZOOM_LVL_BEGIN]) / 256
 			);
 			return;
@@ -238,16 +240,19 @@
 {
 	/* emits sound from center of the tile */
 	int x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
-	int y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
-	Point pt = RemapCoords(x, y, GetSlopeZ(x, y));
-	SndPlayScreenCoordFx(sound, pt.x, pt.y);
+	int y = TileY(tile) * TILE_SIZE - TILE_SIZE / 2;
+	uint z = (y < 0 ? 0 : GetSlopeZ(x, y));
+	Point pt = RemapCoords(x, y, z);
+	y += 2 * TILE_SIZE;
+	Point pt2 = RemapCoords(x, y, GetSlopeZ(x, y));
+	SndPlayScreenCoordFx(sound, pt.x, pt2.x, pt.y, pt2.y);
 }
 
 void SndPlayVehicleFx(SoundFx sound, const Vehicle *v)
 {
 	SndPlayScreenCoordFx(sound,
-		(v->left_coord + v->right_coord) / 2,
-		(v->top_coord + v->bottom_coord) / 2
+		v->left_coord, v->right_coord,
+		v->top_coord, v->top_coord
 	);
 }
 
--- a/src/sprite.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/sprite.h	Fri Feb 22 00:25:54 2008 +0000
@@ -30,13 +30,11 @@
 	byte size_x;
 	byte size_y;
 	byte size_z;
-	SpriteID image;
-	SpriteID pal;
+	PalSpriteID image;
 };
 
 struct DrawTileSprites {
-	SpriteID ground_sprite;
-	SpriteID ground_pal;
+	PalSpriteID ground;
 	const DrawTileSeqStruct *seq;
 };
 
--- a/src/spritecache.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/spritecache.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -284,8 +284,9 @@
 	uint32 tot_size = 0;
 	MemBlock* s;
 
-	for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s))
+	for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s)) {
 		if (!(s->size & S_FREE_MASK)) tot_size += s->size;
+	}
 
 	return tot_size;
 }
@@ -454,6 +455,7 @@
 
 	/* Load the sprite, if it is not loaded, yet */
 	if (p == NULL) p = ReadSprite(sc, sprite, real_sprite);
+
 	return p;
 }
 
--- a/src/station.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/station.h	Fri Feb 22 00:25:54 2008 +0000
@@ -239,6 +239,8 @@
 	CA_TRAIN           =  4,
 	CA_DOCK            =  5,
 
+	CA_UNMODIFIED      =  4, ///< Used when _patches.modified_catchment is false
+
 	MAX_CATCHMENT      = 10, ///< Airports have a catchment up to this number.
 };
 
--- a/src/station_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/station_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -599,7 +599,7 @@
 			TileXY(rect.min_x, rect.min_y),
 			rect.max_x - rect.min_x + 1,
 			rect.max_y - rect.min_y + 1,
-			_patches.modified_catchment ? FindCatchmentRadius(st) : 4
+			_patches.modified_catchment ? FindCatchmentRadius(st) : (uint)CA_UNMODIFIED
 		);
 	} else {
 		memset(accepts, 0, sizeof(accepts));
@@ -1333,7 +1333,7 @@
 {
 	bool type = HasBit(p2, 0);
 	bool is_drive_through = HasBit(p2, 1);
-	bool build_over_road  = is_drive_through && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL;
+	bool build_over_road  = is_drive_through && IsNormalRoadTile(tile);
 	bool town_owned_road  = build_over_road && IsTileOwner(tile, OWNER_TOWN);
 	RoadTypes rts = (RoadTypes)GB(p2, 2, 3);
 
@@ -1356,7 +1356,6 @@
 	/* Not allowed to build over this road */
 	if (build_over_road) {
 		if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
-		if (GetRoadTileType(tile) != ROAD_TILE_NORMAL) return CMD_ERROR;
 
 		RoadTypes cur_rts = GetRoadTypes(tile);
 
@@ -1465,6 +1464,15 @@
 	return cost;
 }
 
+
+static void *ClearRoadStopStatusEnum(Vehicle *v, void *)
+{
+	if (v->type == VEH_ROAD) ClrBit(v->u.road.state, RVS_IN_DT_ROAD_STOP);
+
+	return NULL;
+}
+
+
 /** Remove a bus station
  * @param st Station to remove
  * @param flags operation to perform
@@ -1491,7 +1499,13 @@
 
 	assert(cur_stop != NULL);
 
-	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+	/* don't do the check for drive-through road stops when company bankrupts */
+	if (IsDriveThroughStopTile(tile) && (flags & DC_BANKRUPT)) {
+		/* remove the 'going through road stop' status from all vehicles on that tile */
+		if (flags & DC_EXEC) VehicleFromPos(tile, NULL, &ClearRoadStopStatusEnum);
+	} else {
+		if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+	}
 
 	if (flags & DC_EXEC) {
 		if (*primary_stop == cur_stop) {
@@ -1905,7 +1919,8 @@
 	TileIndex tile = st->dock_tile;
 
 	if (HasStationInUse(st->index, INVALID_PLAYER)) return_cmd_error(STR_BUOY_IS_IN_USE);
-	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+	/* remove the buoy if there is a ship on tile when company goes bankrupt... */
+	if (!(flags & DC_BANKRUPT) && !EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
 	if (flags & DC_EXEC) {
 		st->dock_tile = 0;
@@ -2140,18 +2155,31 @@
 
 	if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationType(ti->tile)][GetStationGfx(ti->tile)];
 
-	SpriteID image = t->ground_sprite;
-	if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
-		image += GetCustomStationGroundRelocation(statspec, st, ti->tile);
-		image += custom_ground_offset;
+
+	if (IsBuoy(ti->tile) || IsDock(ti->tile)) {
+		if (ti->tileh == SLOPE_FLAT) {
+			DrawWaterClassGround(ti);
+		} else {
+			assert(IsDock(ti->tile));
+			TileIndex water_tile = ti->tile + TileOffsByDiagDir(GetDockDirection(ti->tile));
+			WaterClass wc = GetWaterClass(water_tile);
+			if (wc == WATER_CLASS_SEA) {
+				DrawShoreTile(ti->tileh);
+			} else {
+				DrawClearLandTile(ti, 3);
+			}
+		}
 	} else {
-		image += total_offset;
+		SpriteID image = t->ground.sprite;
+		if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
+			image += GetCustomStationGroundRelocation(statspec, st, ti->tile);
+			image += custom_ground_offset;
+		} else {
+			image += total_offset;
+		}
+		DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE);
 	}
 
-	/* station_land array has been increased from 82 elements to 114
-	 * but this is something else. If AI builds station with 114 it looks all weird */
-	DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE);
-
 	if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
 
 	if (HasBit(roadtypes, ROADTYPE_TRAM)) {
@@ -2160,18 +2188,9 @@
 		DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
 	}
 
-	if (IsBuoy(ti->tile)) {
-		/* Draw appropriate water edges */
-		switch (GetWaterClass(ti->tile)) {
-			case WATER_CLASS_SEA: break;
-			case WATER_CLASS_CANAL: DrawCanalWater(ti->tile, false); break;
-			case WATER_CLASS_RIVER: DrawRiverWater(ti, false); break;
-		}
-	}
-
 	const DrawTileSeqStruct *dtss;
 	foreach_draw_tile_seq(dtss, t->seq) {
-		image = dtss->image;
+		SpriteID image = dtss->image.sprite;
 		if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
 			image += total_offset;
 		} else {
@@ -2182,7 +2201,7 @@
 		if (!(!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
 			pal = palette;
 		} else {
-			pal = dtss->pal;
+			pal = dtss->image.pal;
 		}
 
 		if ((byte)dtss->delta_z != 0x80) {
@@ -2210,17 +2229,17 @@
 		total_offset = rti->total_offset;
 	}
 
-	SpriteID img = t->ground_sprite;
+	SpriteID img = t->ground.sprite;
 	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);
+		DrawSprite(SPR_TRAMWAY_TRAM + (t->ground.sprite == SPR_ROAD_PAVED_STRAIGHT_X ? 1 : 0), PAL_NONE, x, y);
 	}
 
 	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 + total_offset, pal, x + pt.x, y + pt.y);
+		DrawSprite(dtss->image.sprite + total_offset, pal, x + pt.x, y + pt.y);
 	}
 }
 
@@ -2261,30 +2280,38 @@
 }
 
 
-static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Station(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
+	TrackBits trackbits = TRACK_BIT_NONE;
+
 	switch (mode) {
 		case TRANSPORT_RAIL:
 			if (IsRailwayStation(tile) && !IsStationTileBlocked(tile)) {
-				return TrackToTrackBits(GetRailStationTrack(tile)) * 0x101;
+				trackbits = TrackToTrackBits(GetRailStationTrack(tile));
 			}
 			break;
 
 		case TRANSPORT_WATER:
 			/* buoy is coded as a station, it is always on open water */
 			if (IsBuoy(tile)) {
-				TrackBits ts = TRACK_BIT_ALL;
+				trackbits = TRACK_BIT_ALL;
 				/* remove tracks that connect NE map edge */
-				if (TileX(tile) == 0) ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT);
+				if (TileX(tile) == 0) trackbits &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT);
 				/* remove tracks that connect NW map edge */
-				if (TileY(tile) == 0) ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER);
-				return uint32(ts) * 0x101;
+				if (TileY(tile) == 0) trackbits &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER);
 			}
 			break;
 
 		case TRANSPORT_ROAD:
-			if ((GetRoadTypes(tile) & sub_mode) != 0 && IsRoadStopTile(tile)) {
-				return AxisToTrackBits(DiagDirToAxis(GetRoadStopDir(tile))) * 0x101;
+			if ((GetRoadTypes(tile) & sub_mode) != 0 && IsRoadStop(tile)) {
+				DiagDirection dir = GetRoadStopDir(tile);
+				Axis axis = DiagDirToAxis(dir);
+
+				if (side != INVALID_DIAGDIR) {
+					if (axis != DiagDirToAxis(side) || (IsStandardRoadStopTile(tile) && dir != side)) break;
+				}
+
+				trackbits = AxisToTrackBits(axis);
 			}
 			break;
 
@@ -2292,7 +2319,7 @@
 			break;
 	}
 
-	return 0;
+	return CombineTrackStatus(TrackBitsToTrackdirBits(trackbits), TRACKDIR_BIT_NONE);
 }
 
 
@@ -2314,6 +2341,9 @@
 			}
 			break;
 
+		case STATION_DOCK:
+			if (GetTileSlope(tile, NULL) != SLOPE_FLAT) break; // only handle water part
+		/* FALL THROUGH */
 		case STATION_OILRIG: //(station part)
 		case STATION_BUOY:
 			TileLoop_Water(tile);
@@ -2690,7 +2720,7 @@
 		h_prod = 0;
 		w += 8;
 		h += 8;
-		max_rad = 4;
+		max_rad = CA_UNMODIFIED;
 	}
 
 	BEGIN_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad))
@@ -2880,15 +2910,22 @@
 		Station* st = GetStationByTile(tile);
 
 		SetTileOwner(tile, new_player);
-		st->owner = new_player;
+		if (!IsBuoy(tile)) st->owner = new_player; // do not set st->owner for buoys
 		RebuildStationLists();
 		InvalidateWindowClasses(WC_STATION_LIST);
 	} else {
-		if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) {
-			/* For a drive-through stop on a town-owned road remove the stop and replace the road */
-			DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC, CMD_REMOVE_ROAD_STOP);
+		if (IsDriveThroughStopTile(tile)) {
+			/* Remove the drive-through road stop */
+			DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
+			assert(IsTileType(tile, MP_ROAD));
+			/* Change owner of tile and all roadtypes */
+			ChangeTileOwner(tile, old_player, new_player);
 		} else {
-			DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+			DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
+			/* Set tile owner of water under (now removed) buoy and dock to OWNER_NONE.
+			 * Update owner of buoy if it was not removed (was in orders).
+			 * Do not update when owned by OWNER_WATER (sea and rivers). */
+			if ((IsTileType(tile, MP_WATER) || IsBuoyTile(tile)) && IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE);
 		}
 	}
 }
@@ -2916,8 +2953,8 @@
 		switch (GetStationType(tile)) {
 			case STATION_RAIL:    return_cmd_error(STR_300B_MUST_DEMOLISH_RAILROAD);
 			case STATION_AIRPORT: return_cmd_error(STR_300E_MUST_DEMOLISH_AIRPORT_FIRST);
-			case STATION_TRUCK:   return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_CARGO_TRAM_STATION : STR_3047_MUST_DEMOLISH_TRUCK_STATION);
-			case STATION_BUS:     return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_PASSENGER_TRAM_STATION : STR_3046_MUST_DEMOLISH_BUS_STATION);
+			case STATION_TRUCK:   return_cmd_error(HasTileRoadType(tile, ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_CARGO_TRAM_STATION : STR_3047_MUST_DEMOLISH_TRUCK_STATION);
+			case STATION_BUS:     return_cmd_error(HasTileRoadType(tile, ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_PASSENGER_TRAM_STATION : STR_3046_MUST_DEMOLISH_BUS_STATION);
 			case STATION_BUOY:    return_cmd_error(STR_306A_BUOY_IN_THE_WAY);
 			case STATION_DOCK:    return_cmd_error(STR_304D_MUST_DEMOLISH_DOCK_FIRST);
 			case STATION_OILRIG:
--- a/src/table/bridge_land.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/table/bridge_land.h	Fri Feb 22 00:25:54 2008 +0000
@@ -707,3 +707,72 @@
 	_bridge_sprite_table_11,
 	_bridge_sprite_table_12
 };
+
+/** Describes the data that defines each bridge in the game
+ * @param y   year of availablity
+ * @param mnl minimum length
+ * @param mxl maximum length
+ * @param p   price
+ * @param mxs maximum speed allowed
+ * @param spr sprite to use in purchase GUI
+ * @param plt palette for the sprite in purchase GUI
+ * @param dsc description of the bridge in purchase GUI
+ * @param nrl description of the rail bridge in query tool
+ * @param nrd description of the road bridge in query tool
+ */
+#define MB(y, mnl, mxl, p, mxs, spr, plt, dsc, nrl, nrd) \
+	{y, mnl, mxl, p, mxs, spr, plt, dsc, { nrl, nrd }, NULL, 0}
+
+const BridgeSpec _orig_bridge[] = {
+/*
+	       year of availablity
+	       |  minimum length
+	       |  |   maximum length
+	       |  |   |    price
+	       |  |   |    |    maximum speed
+	       |  |   |    |    |  sprite to use in GUI
+	       |  |   |    |    |  |      palette in GUI
+	   string with description        name on rail                             name on road
+	   |                              |                                        | */
+	MB(    0, 0, 16,  80,  32, 0xA24, PAL_NONE,
+	   STR_5012_WOODEN,               STR_501F_WOODEN_RAIL_BRIDGE,             STR_5025_WOODEN_ROAD_BRIDGE),
+
+	MB(    0, 0,  2, 112,  48, 0xA26, PALETTE_TO_STRUCT_RED,
+	   STR_5013_CONCRETE,             STR_5020_CONCRETE_RAIL_BRIDGE,           STR_5026_CONCRETE_ROAD_BRIDGE),
+
+	MB( 1930, 0,  5, 144,  64, 0xA25, PAL_NONE,
+	   STR_500F_GIRDER_STEEL,         STR_501C_STEEL_GIRDER_RAIL_BRIDGE,       STR_5022_STEEL_GIRDER_ROAD_BRIDGE),
+
+	MB(    0, 2, 10, 168,  80, 0xA22, PALETTE_TO_STRUCT_CONCRETE,
+	   STR_5011_SUSPENSION_CONCRETE,  STR_501E_REINFORCED_CONCRETE_SUSPENSION, STR_5024_REINFORCED_CONCRETE_SUSPENSION),
+
+	MB( 1930, 3, 16, 185,  96, 0xA22, PAL_NONE,
+	   STR_500E_SUSPENSION_STEEL,     STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE,   STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE),
+
+	MB( 1930, 3, 16, 192, 112, 0xA22, PALETTE_TO_STRUCT_YELLOW,
+	   STR_500E_SUSPENSION_STEEL,     STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE,   STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE),
+
+	MB( 1930, 3,  7, 224, 160, 0xA23, PAL_NONE,
+	   STR_5010_CANTILEVER_STEEL,     STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE,   STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
+
+	MB( 1930, 3,  8, 232, 208, 0xA23, PALETTE_TO_STRUCT_BROWN,
+	   STR_5010_CANTILEVER_STEEL,     STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE,   STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
+
+	MB( 1930, 3,  9, 248, 240, 0xA23, PALETTE_TO_STRUCT_RED,
+	   STR_5010_CANTILEVER_STEEL,     STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE,   STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
+
+	MB( 1930, 0,  2, 240, 256, 0xA27, PAL_NONE,
+	   STR_500F_GIRDER_STEEL,         STR_501C_STEEL_GIRDER_RAIL_BRIDGE,       STR_5022_STEEL_GIRDER_ROAD_BRIDGE),
+
+	MB( 1995, 2, 16, 255, 320, 0xA28, PAL_NONE,
+	   STR_5014_TUBULAR_STEEL,        STR_5027_TUBULAR_RAIL_BRIDGE,            STR_5028_TUBULAR_ROAD_BRIDGE),
+
+	MB( 2005, 2, 32, 380, 512, 0xA28, PALETTE_TO_STRUCT_YELLOW,
+	   STR_5014_TUBULAR_STEEL,        STR_5027_TUBULAR_RAIL_BRIDGE,            STR_5028_TUBULAR_ROAD_BRIDGE),
+
+	MB( 2010, 2, 32, 510, 608, 0xA28, PALETTE_TO_STRUCT_GREY,
+	   STR_BRIDGE_TUBULAR_SILICON,    STR_5027_TUBULAR_RAIL_BRIDGE,            STR_5028_TUBULAR_ROAD_BRIDGE)
+};
+
+#undef MB
+
--- a/src/table/engines.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/table/engines.h	Fri Feb 22 00:25:54 2008 +0000
@@ -7,6 +7,14 @@
  *  This file contains all the data for vehicles
  */
 
+enum {
+	RC_W = 0xFF, ///< Running cost price index (out of range) of wagons
+	RC_S = 0x2A, ///< Running cost price index of steam
+	RC_D = 0x2B, ///< Running cost price index of diesel
+	RC_E = 0x2C, ///< Running cost price index of electric
+	RC_R = 0x2E, ///< Running cost price index of road vehicles
+};
+
 /** Writes the properties of a train or road vehicle into the EngineInfo struct.
  * @see EngineInfo
  * @param a Introduction date
@@ -336,7 +344,7 @@
  * @param d max_speed (kph)
  * @param e power (hp)
  * @param f weight
- * @param g running_cost_base
+ * @param g running_cost
  * @param h running_cost_class
  * @param i capacity
  * @param j cargo_type
@@ -363,127 +371,127 @@
 #define L RAILTYPE_MAGLEV
 
 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             |  |
-	//   |  |    |    |        |    |      |  |   |  cargo_type        |  |  engclass
-	//   |  |    |    |        |    |      |  |   |  |                 |  |  |
-	RVI( 2, G,   7,  64,     300,  47,    50, S,  0, 0              ,  1, R, S), //   0
-	RVI(19, G,   8,  80,     600,  65,    65, D,  0, 0              ,  4, R, D), //   1
-	RVI( 2, G,  10,  72,     400,  85,    90, S,  0, 0              ,  7, R, S), //   2
-	RVI( 0, G,  15,  96,     900, 130,   130, S,  0, 0              , 19, R, S), //   3
-	RVI( 1, G,  19, 112,    1000, 140,   145, S,  0, 0              , 20, R, S), //   4
-	RVI(12, G,  16, 120,    1400,  95,   125, D,  0, 0              , 30, R, D), //   5
-	RVI(14, G,  20, 152,    2000, 120,   135, D,  0, 0              , 31, R, D), //   6
-	RVI( 3, G,  14,  88,    1100, 145,   130, S,  0, 0              , 19, R, S), //   7
-	RVI( 0, G,  13, 112,    1000, 131,   120, S,  0, 0              , 20, R, S), //   8
-	RVI( 1, G,  19, 128,    1200, 162,   140, S,  0, 0              , 21, R, S), //   9
-	RVI( 0, G,  22, 144,    1600, 170,   130, S,  0, 0              , 22, R, S), //  10
-	RVI( 8, M,  11, 112,   600/2,32/2,  85/2, D, 38, CT_PASSENGERS  , 10, R, D), //  11
-	RVI(10, M,  14, 120,   700/2,38/2,  70/2, D, 40, CT_PASSENGERS  , 11, R, D), //  12
-	RVI( 4, G,  15, 128,    1250,  72,    95, D,  0, 0              , 30, R, D), //  13
-	RVI( 5, G,  17, 144,    1750, 101,   120, D,  0, 0              , 31, R, D), //  14
-	RVI( 4, G,  18, 160,    2580, 112,   140, D,  0, 0              , 32, R, D), //  15
-	RVI(14, G,  23,  96,    4000, 150,   135, D,  0, 0              , 33, R, D), //  16
-	RVI(12, G,  16, 112,    2400, 120,   105, D,  0, 0              , 34, R, D), //  17
-	RVI(13, G,  30, 112,    6600, 207,   155, D,  0, 0              , 35, R, D), //  18
-	RVI(15, G,  18, 104,    1500, 110,   105, D,  0, 0              , 29, R, D), //  19
-	RVI(16, M,  35, 160,  3500/2,95/2, 205/2, D,  0, 0              , 45, R, D), //  20
-	RVI(18, G,  21, 104,    2200, 120,   145, D,  0, 0              , 32, R, D), //  21
-	RVI( 6, M,  20, 200,  4500/2,70/2, 190/2, D,  4, CT_MAIL        , 50, R, D), //  22
-	RVI(20, G,  26, 160,    3600,  84,   180, E,  0, 0              , 40, C, E), //  23
-	RVI(20, G,  30, 176,    5000,  82,   205, E,  0, 0              , 41, C, E), //  24
-	RVI(21, M,  40, 240,  7000/2,90/2, 240/2, E,  0, 0              , 51, C, E), //  25
-	RVI(23, M,  43, 264,  8000/2,95/2, 250/2, E,  0, 0              , 52, C, E), //  26
-	RVI(33, W, 247,   0,       0,  25,     0, 0, 40, CT_PASSENGERS  ,  0, R, A), //  27
-	RVI(35, W, 228,   0,       0,  21,     0, 0, 30, CT_MAIL        ,  0, R, A), //  28
-	RVI(34, W, 176,   0,       0,  18,     0, 0, 30, CT_COAL        ,  0, R, A), //  29
-	RVI(36, W, 200,   0,       0,  24,     0, 0, 30, CT_OIL         ,  0, R, A), //  30
-	RVI(37, W, 192,   0,       0,  20,     0, 0, 25, CT_LIVESTOCK   ,  0, R, A), //  31
-	RVI(38, W, 190,   0,       0,  21,     0, 0, 25, CT_GOODS       ,  0, R, A), //  32
-	RVI(39, W, 182,   0,       0,  19,     0, 0, 30, CT_GRAIN       ,  0, R, A), //  33
-	RVI(40, W, 181,   0,       0,  16,     0, 0, 30, CT_WOOD        ,  0, R, A), //  34
-	RVI(41, W, 179,   0,       0,  19,     0, 0, 30, CT_IRON_ORE    ,  0, R, A), //  35
-	RVI(42, W, 196,   0,       0,  18,     0, 0, 20, CT_STEEL       ,  0, R, A), //  36
-	RVI(43, W, 255,   0,       0,  30,     0, 0, 20, CT_VALUABLES   ,  0, R, A), //  37
-	RVI(44, W, 191,   0,       0,  22,     0, 0, 25, CT_FOOD        ,  0, R, A), //  38
-	RVI(45, W, 196,   0,       0,  18,     0, 0, 20, CT_PAPER       ,  0, R, A), //  39
-	RVI(46, W, 179,   0,       0,  19,     0, 0, 30, CT_COPPER_ORE  ,  0, R, A), //  40
-	RVI(47, W, 199,   0,       0,  25,     0, 0, 25, CT_WATER       ,  0, R, A), //  41
-	RVI(48, W, 182,   0,       0,  18,     0, 0, 25, CT_FRUIT       ,  0, R, A), //  42
-	RVI(49, W, 185,   0,       0,  19,     0, 0, 21, CT_RUBBER      ,  0, R, A), //  43
-	RVI(50, W, 176,   0,       0,  19,     0, 0, 30, CT_SUGAR       ,  0, R, A), //  44
-	RVI(51, W, 178,   0,       0,  20,     0, 0, 30, CT_COTTON_CANDY,  0, R, A), //  45
-	RVI(52, W, 192,   0,       0,  20,     0, 0, 30, CT_TOFFEE      ,  0, R, A), //  46
-	RVI(53, W, 190,   0,       0,  21,     0, 0, 20, CT_BUBBLES     ,  0, R, A), //  47
-	RVI(54, W, 182,   0,       0,  24,     0, 0, 25, CT_COLA        ,  0, R, A), //  48
-	RVI(55, W, 181,   0,       0,  21,     0, 0, 25, CT_CANDY       ,  0, R, A), //  49
-	RVI(56, W, 183,   0,       0,  21,     0, 0, 20, CT_TOYS        ,  0, R, A), //  50
-	RVI(57, W, 196,   0,       0,  18,     0, 0, 22, CT_BATTERIES   ,  0, R, A), //  51
-	RVI(58, W, 193,   0,       0,  18,     0, 0, 25, CT_FIZZY_DRINKS,  0, R, A), //  52
-	RVI(59, W, 191,   0,       0,  18,     0, 0, 30, CT_PLASTIC     ,  0, R, A), //  53
-	RVI(25, G,  52, 304,    9000,  95,   230, E,  0, 0              , 60, O, N), //  54
-	RVI(26, M,  60, 336, 10000/2,85/2, 240/2, E, 25, CT_PASSENGERS  , 62, O, N), //  55
-	RVI(26, G,  53, 320,    5000,  95,   230, E,  0, 0              , 63, O, N), //  56
-	RVI(60, W, 247,   0,       0,  25,     0, 0, 45, CT_PASSENGERS  ,  0, O, A), //  57
-	RVI(62, W, 228,   0,       0,  21,     0, 0, 35, CT_MAIL        ,  0, O, A), //  58
-	RVI(61, W, 176,   0,       0,  18,     0, 0, 35, CT_COAL        ,  0, O, A), //  59
-	RVI(63, W, 200,   0,       0,  24,     0, 0, 35, CT_OIL         ,  0, O, A), //  60
-	RVI(64, W, 192,   0,       0,  20,     0, 0, 30, CT_LIVESTOCK   ,  0, O, A), //  61
-	RVI(65, W, 190,   0,       0,  21,     0, 0, 30, CT_GOODS       ,  0, O, A), //  62
-	RVI(66, W, 182,   0,       0,  19,     0, 0, 35, CT_GRAIN       ,  0, O, A), //  63
-	RVI(67, W, 181,   0,       0,  16,     0, 0, 35, CT_WOOD        ,  0, O, A), //  64
-	RVI(68, W, 179,   0,       0,  19,     0, 0, 35, CT_IRON_ORE    ,  0, O, A), //  65
-	RVI(69, W, 196,   0,       0,  18,     0, 0, 25, CT_STEEL       ,  0, O, A), //  66
-	RVI(70, W, 255,   0,       0,  30,     0, 0, 25, CT_VALUABLES   ,  0, O, A), //  67
-	RVI(71, W, 191,   0,       0,  22,     0, 0, 30, CT_FOOD        ,  0, O, A), //  68
-	RVI(72, W, 196,   0,       0,  18,     0, 0, 25, CT_PAPER       ,  0, O, A), //  69
-	RVI(73, W, 179,   0,       0,  19,     0, 0, 35, CT_COPPER_ORE  ,  0, O, A), //  70
-	RVI(47, W, 199,   0,       0,  25,     0, 0, 30, CT_WATER       ,  0, O, A), //  71
-	RVI(48, W, 182,   0,       0,  18,     0, 0, 30, CT_FRUIT       ,  0, O, A), //  72
-	RVI(49, W, 185,   0,       0,  19,     0, 0, 26, CT_RUBBER      ,  0, O, A), //  73
-	RVI(50, W, 176,   0,       0,  19,     0, 0, 35, CT_SUGAR       ,  0, O, A), //  74
-	RVI(51, W, 178,   0,       0,  20,     0, 0, 35, CT_COTTON_CANDY,  0, O, A), //  75
-	RVI(52, W, 192,   0,       0,  20,     0, 0, 35, CT_TOFFEE      ,  0, O, A), //  76
-	RVI(53, W, 190,   0,       0,  21,     0, 0, 25, CT_BUBBLES     ,  0, O, A), //  77
-	RVI(54, W, 182,   0,       0,  24,     0, 0, 30, CT_COLA        ,  0, O, A), //  78
-	RVI(55, W, 181,   0,       0,  21,     0, 0, 30, CT_CANDY       ,  0, O, A), //  79
-	RVI(56, W, 183,   0,       0,  21,     0, 0, 25, CT_TOYS        ,  0, O, A), //  80
-	RVI(57, W, 196,   0,       0,  18,     0, 0, 27, CT_BATTERIES   ,  0, O, A), //  81
-	RVI(58, W, 193,   0,       0,  18,     0, 0, 30, CT_FIZZY_DRINKS,  0, O, A), //  82
-	RVI(59, W, 191,   0,       0,  18,     0, 0, 35, CT_PLASTIC     ,  0, O, A), //  83
-	RVI(28, G,  70, 400,   10000, 105,   250, E,  0, 0              , 70, L, V), //  84
-	RVI(29, G,  74, 448,   12000, 120,   253, E,  0, 0              , 71, L, V), //  85
-	RVI(30, G,  82, 480,   15000, 130,   254, E,  0, 0              , 72, L, V), //  86
-	RVI(31, M,  95, 640, 20000/2,150/2,255/2, E,  0, 0              , 73, L, V), //  87
-	RVI(28, G,  70, 480,   10000, 120,   250, E,  0, 0              , 74, L, V), //  88
-	RVI(60, W, 247,   0,       0,  25,     0, 0, 47, CT_PASSENGERS  ,  0, L, A), //  89
-	RVI(62, W, 228,   0,       0,  21,     0, 0, 37, CT_MAIL        ,  0, L, A), //  90
-	RVI(61, W, 176,   0,       0,  18,     0, 0, 37, CT_COAL        ,  0, L, A), //  91
-	RVI(63, W, 200,   0,       0,  24,     0, 0, 37, CT_OIL         ,  0, L, A), //  92
-	RVI(64, W, 192,   0,       0,  20,     0, 0, 32, CT_LIVESTOCK   ,  0, L, A), //  93
-	RVI(65, W, 190,   0,       0,  21,     0, 0, 32, CT_GOODS       ,  0, L, A), //  94
-	RVI(66, W, 182,   0,       0,  19,     0, 0, 37, CT_GRAIN       ,  0, L, A), //  95
-	RVI(67, W, 181,   0,       0,  16,     0, 0, 37, CT_WOOD        ,  0, L, A), //  96
-	RVI(68, W, 179,   0,       0,  19,     0, 0, 37, CT_IRON_ORE    ,  0, L, A), //  97
-	RVI(69, W, 196,   0,       0,  18,     0, 0, 27, CT_STEEL       ,  0, L, A), //  98
-	RVI(70, W, 255,   0,       0,  30,     0, 0, 27, CT_VALUABLES   ,  0, L, A), //  99
-	RVI(71, W, 191,   0,       0,  22,     0, 0, 32, CT_FOOD        ,  0, L, A), // 100
-	RVI(72, W, 196,   0,       0,  18,     0, 0, 27, CT_PAPER       ,  0, L, A), // 101
-	RVI(73, W, 179,   0,       0,  19,     0, 0, 37, CT_COPPER_ORE  ,  0, L, A), // 102
-	RVI(47, W, 199,   0,       0,  25,     0, 0, 32, CT_WATER       ,  0, L, A), // 103
-	RVI(48, W, 182,   0,       0,  18,     0, 0, 32, CT_FRUIT       ,  0, L, A), // 104
-	RVI(49, W, 185,   0,       0,  19,     0, 0, 28, CT_RUBBER      ,  0, L, A), // 105
-	RVI(50, W, 176,   0,       0,  19,     0, 0, 37, CT_SUGAR       ,  0, L, A), // 106
-	RVI(51, W, 178,   0,       0,  20,     0, 0, 37, CT_COTTON_CANDY,  0, L, A), // 107
-	RVI(52, W, 192,   0,       0,  20,     0, 0, 37, CT_TOFFEE      ,  0, L, A), // 108
-	RVI(53, W, 190,   0,       0,  21,     0, 0, 27, CT_BUBBLES     ,  0, L, A), // 109
-	RVI(54, W, 182,   0,       0,  24,     0, 0, 32, CT_COLA        ,  0, L, A), // 110
-	RVI(55, W, 181,   0,       0,  21,     0, 0, 32, CT_CANDY       ,  0, L, A), // 111
-	RVI(56, W, 183,   0,       0,  21,     0, 0, 27, CT_TOYS        ,  0, L, A), // 112
-	RVI(57, W, 196,   0,       0,  18,     0, 0, 29, CT_BATTERIES   ,  0, L, A), // 113
-	RVI(58, W, 193,   0,       0,  18,     0, 0, 32, CT_FIZZY_DRINKS,  0, L, A), // 114
-	RVI(59, W, 191,   0,       0,  18,     0, 0, 37, CT_PLASTIC     ,  0, L, A), // 115
+	//   image_index  max_speed (kph)      running_cost                   ai_rank
+	//   |  flags     |        power (hp)  |  running_cost_class          |  railtype
+	//   |  |    base_cost     |    weight |  |      capacity             |  |
+	//   |  |    |    |        |    |      |  |      |  cargo_type        |  |  engclass
+	//   |  |    |    |        |    |      |  |      |  |                 |  |  |
+	RVI( 2, G,   7,  64,     300,  47,    50, RC_S,  0, 0              ,  1, R, S), //   0
+	RVI(19, G,   8,  80,     600,  65,    65, RC_D,  0, 0              ,  4, R, D), //   1
+	RVI( 2, G,  10,  72,     400,  85,    90, RC_S,  0, 0              ,  7, R, S), //   2
+	RVI( 0, G,  15,  96,     900, 130,   130, RC_S,  0, 0              , 19, R, S), //   3
+	RVI( 1, G,  19, 112,    1000, 140,   145, RC_S,  0, 0              , 20, R, S), //   4
+	RVI(12, G,  16, 120,    1400,  95,   125, RC_D,  0, 0              , 30, R, D), //   5
+	RVI(14, G,  20, 152,    2000, 120,   135, RC_D,  0, 0              , 31, R, D), //   6
+	RVI( 3, G,  14,  88,    1100, 145,   130, RC_S,  0, 0              , 19, R, S), //   7
+	RVI( 0, G,  13, 112,    1000, 131,   120, RC_S,  0, 0              , 20, R, S), //   8
+	RVI( 1, G,  19, 128,    1200, 162,   140, RC_S,  0, 0              , 21, R, S), //   9
+	RVI( 0, G,  22, 144,    1600, 170,   130, RC_S,  0, 0              , 22, R, S), //  10
+	RVI( 8, M,  11, 112,   600/2,32/2,  85/2, RC_D, 38, CT_PASSENGERS  , 10, R, D), //  11
+	RVI(10, M,  14, 120,   700/2,38/2,  70/2, RC_D, 40, CT_PASSENGERS  , 11, R, D), //  12
+	RVI( 4, G,  15, 128,    1250,  72,    95, RC_D,  0, 0              , 30, R, D), //  13
+	RVI( 5, G,  17, 144,    1750, 101,   120, RC_D,  0, 0              , 31, R, D), //  14
+	RVI( 4, G,  18, 160,    2580, 112,   140, RC_D,  0, 0              , 32, R, D), //  15
+	RVI(14, G,  23,  96,    4000, 150,   135, RC_D,  0, 0              , 33, R, D), //  16
+	RVI(12, G,  16, 112,    2400, 120,   105, RC_D,  0, 0              , 34, R, D), //  17
+	RVI(13, G,  30, 112,    6600, 207,   155, RC_D,  0, 0              , 35, R, D), //  18
+	RVI(15, G,  18, 104,    1500, 110,   105, RC_D,  0, 0              , 29, R, D), //  19
+	RVI(16, M,  35, 160,  3500/2,95/2, 205/2, RC_D,  0, 0              , 45, R, D), //  20
+	RVI(18, G,  21, 104,    2200, 120,   145, RC_D,  0, 0              , 32, R, D), //  21
+	RVI( 6, M,  20, 200,  4500/2,70/2, 190/2, RC_D,  4, CT_MAIL        , 50, R, D), //  22
+	RVI(20, G,  26, 160,    3600,  84,   180, RC_E,  0, 0              , 40, C, E), //  23
+	RVI(20, G,  30, 176,    5000,  82,   205, RC_E,  0, 0              , 41, C, E), //  24
+	RVI(21, M,  40, 240,  7000/2,90/2, 240/2, RC_E,  0, 0              , 51, C, E), //  25
+	RVI(23, M,  43, 264,  8000/2,95/2, 250/2, RC_E,  0, 0              , 52, C, E), //  26
+	RVI(33, W, 247,   0,       0,  25,     0, RC_W, 40, CT_PASSENGERS  ,  0, R, A), //  27
+	RVI(35, W, 228,   0,       0,  21,     0, RC_W, 30, CT_MAIL        ,  0, R, A), //  28
+	RVI(34, W, 176,   0,       0,  18,     0, RC_W, 30, CT_COAL        ,  0, R, A), //  29
+	RVI(36, W, 200,   0,       0,  24,     0, RC_W, 30, CT_OIL         ,  0, R, A), //  30
+	RVI(37, W, 192,   0,       0,  20,     0, RC_W, 25, CT_LIVESTOCK   ,  0, R, A), //  31
+	RVI(38, W, 190,   0,       0,  21,     0, RC_W, 25, CT_GOODS       ,  0, R, A), //  32
+	RVI(39, W, 182,   0,       0,  19,     0, RC_W, 30, CT_GRAIN       ,  0, R, A), //  33
+	RVI(40, W, 181,   0,       0,  16,     0, RC_W, 30, CT_WOOD        ,  0, R, A), //  34
+	RVI(41, W, 179,   0,       0,  19,     0, RC_W, 30, CT_IRON_ORE    ,  0, R, A), //  35
+	RVI(42, W, 196,   0,       0,  18,     0, RC_W, 20, CT_STEEL       ,  0, R, A), //  36
+	RVI(43, W, 255,   0,       0,  30,     0, RC_W, 20, CT_VALUABLES   ,  0, R, A), //  37
+	RVI(44, W, 191,   0,       0,  22,     0, RC_W, 25, CT_FOOD        ,  0, R, A), //  38
+	RVI(45, W, 196,   0,       0,  18,     0, RC_W, 20, CT_PAPER       ,  0, R, A), //  39
+	RVI(46, W, 179,   0,       0,  19,     0, RC_W, 30, CT_COPPER_ORE  ,  0, R, A), //  40
+	RVI(47, W, 199,   0,       0,  25,     0, RC_W, 25, CT_WATER       ,  0, R, A), //  41
+	RVI(48, W, 182,   0,       0,  18,     0, RC_W, 25, CT_FRUIT       ,  0, R, A), //  42
+	RVI(49, W, 185,   0,       0,  19,     0, RC_W, 21, CT_RUBBER      ,  0, R, A), //  43
+	RVI(50, W, 176,   0,       0,  19,     0, RC_W, 30, CT_SUGAR       ,  0, R, A), //  44
+	RVI(51, W, 178,   0,       0,  20,     0, RC_W, 30, CT_COTTON_CANDY,  0, R, A), //  45
+	RVI(52, W, 192,   0,       0,  20,     0, RC_W, 30, CT_TOFFEE      ,  0, R, A), //  46
+	RVI(53, W, 190,   0,       0,  21,     0, RC_W, 20, CT_BUBBLES     ,  0, R, A), //  47
+	RVI(54, W, 182,   0,       0,  24,     0, RC_W, 25, CT_COLA        ,  0, R, A), //  48
+	RVI(55, W, 181,   0,       0,  21,     0, RC_W, 25, CT_CANDY       ,  0, R, A), //  49
+	RVI(56, W, 183,   0,       0,  21,     0, RC_W, 20, CT_TOYS        ,  0, R, A), //  50
+	RVI(57, W, 196,   0,       0,  18,     0, RC_W, 22, CT_BATTERIES   ,  0, R, A), //  51
+	RVI(58, W, 193,   0,       0,  18,     0, RC_W, 25, CT_FIZZY_DRINKS,  0, R, A), //  52
+	RVI(59, W, 191,   0,       0,  18,     0, RC_W, 30, CT_PLASTIC     ,  0, R, A), //  53
+	RVI(25, G,  52, 304,    9000,  95,   230, RC_E,  0, 0              , 60, O, N), //  54
+	RVI(26, M,  60, 336, 10000/2,85/2, 240/2, RC_E, 25, CT_PASSENGERS  , 62, O, N), //  55
+	RVI(26, G,  53, 320,    5000,  95,   230, RC_E,  0, 0              , 63, O, N), //  56
+	RVI(60, W, 247,   0,       0,  25,     0, RC_W, 45, CT_PASSENGERS  ,  0, O, A), //  57
+	RVI(62, W, 228,   0,       0,  21,     0, RC_W, 35, CT_MAIL        ,  0, O, A), //  58
+	RVI(61, W, 176,   0,       0,  18,     0, RC_W, 35, CT_COAL        ,  0, O, A), //  59
+	RVI(63, W, 200,   0,       0,  24,     0, RC_W, 35, CT_OIL         ,  0, O, A), //  60
+	RVI(64, W, 192,   0,       0,  20,     0, RC_W, 30, CT_LIVESTOCK   ,  0, O, A), //  61
+	RVI(65, W, 190,   0,       0,  21,     0, RC_W, 30, CT_GOODS       ,  0, O, A), //  62
+	RVI(66, W, 182,   0,       0,  19,     0, RC_W, 35, CT_GRAIN       ,  0, O, A), //  63
+	RVI(67, W, 181,   0,       0,  16,     0, RC_W, 35, CT_WOOD        ,  0, O, A), //  64
+	RVI(68, W, 179,   0,       0,  19,     0, RC_W, 35, CT_IRON_ORE    ,  0, O, A), //  65
+	RVI(69, W, 196,   0,       0,  18,     0, RC_W, 25, CT_STEEL       ,  0, O, A), //  66
+	RVI(70, W, 255,   0,       0,  30,     0, RC_W, 25, CT_VALUABLES   ,  0, O, A), //  67
+	RVI(71, W, 191,   0,       0,  22,     0, RC_W, 30, CT_FOOD        ,  0, O, A), //  68
+	RVI(72, W, 196,   0,       0,  18,     0, RC_W, 25, CT_PAPER       ,  0, O, A), //  69
+	RVI(73, W, 179,   0,       0,  19,     0, RC_W, 35, CT_COPPER_ORE  ,  0, O, A), //  70
+	RVI(47, W, 199,   0,       0,  25,     0, RC_W, 30, CT_WATER       ,  0, O, A), //  71
+	RVI(48, W, 182,   0,       0,  18,     0, RC_W, 30, CT_FRUIT       ,  0, O, A), //  72
+	RVI(49, W, 185,   0,       0,  19,     0, RC_W, 26, CT_RUBBER      ,  0, O, A), //  73
+	RVI(50, W, 176,   0,       0,  19,     0, RC_W, 35, CT_SUGAR       ,  0, O, A), //  74
+	RVI(51, W, 178,   0,       0,  20,     0, RC_W, 35, CT_COTTON_CANDY,  0, O, A), //  75
+	RVI(52, W, 192,   0,       0,  20,     0, RC_W, 35, CT_TOFFEE      ,  0, O, A), //  76
+	RVI(53, W, 190,   0,       0,  21,     0, RC_W, 25, CT_BUBBLES     ,  0, O, A), //  77
+	RVI(54, W, 182,   0,       0,  24,     0, RC_W, 30, CT_COLA        ,  0, O, A), //  78
+	RVI(55, W, 181,   0,       0,  21,     0, RC_W, 30, CT_CANDY       ,  0, O, A), //  79
+	RVI(56, W, 183,   0,       0,  21,     0, RC_W, 25, CT_TOYS        ,  0, O, A), //  80
+	RVI(57, W, 196,   0,       0,  18,     0, RC_W, 27, CT_BATTERIES   ,  0, O, A), //  81
+	RVI(58, W, 193,   0,       0,  18,     0, RC_W, 30, CT_FIZZY_DRINKS,  0, O, A), //  82
+	RVI(59, W, 191,   0,       0,  18,     0, RC_W, 35, CT_PLASTIC     ,  0, O, A), //  83
+	RVI(28, G,  70, 400,   10000, 105,   250, RC_E,  0, 0              , 70, L, V), //  84
+	RVI(29, G,  74, 448,   12000, 120,   253, RC_E,  0, 0              , 71, L, V), //  85
+	RVI(30, G,  82, 480,   15000, 130,   254, RC_E,  0, 0              , 72, L, V), //  86
+	RVI(31, M,  95, 640, 20000/2,150/2,255/2, RC_E,  0, 0              , 73, L, V), //  87
+	RVI(28, G,  70, 480,   10000, 120,   250, RC_E,  0, 0              , 74, L, V), //  88
+	RVI(60, W, 247,   0,       0,  25,     0, RC_W, 47, CT_PASSENGERS  ,  0, L, A), //  89
+	RVI(62, W, 228,   0,       0,  21,     0, RC_W, 37, CT_MAIL        ,  0, L, A), //  90
+	RVI(61, W, 176,   0,       0,  18,     0, RC_W, 37, CT_COAL        ,  0, L, A), //  91
+	RVI(63, W, 200,   0,       0,  24,     0, RC_W, 37, CT_OIL         ,  0, L, A), //  92
+	RVI(64, W, 192,   0,       0,  20,     0, RC_W, 32, CT_LIVESTOCK   ,  0, L, A), //  93
+	RVI(65, W, 190,   0,       0,  21,     0, RC_W, 32, CT_GOODS       ,  0, L, A), //  94
+	RVI(66, W, 182,   0,       0,  19,     0, RC_W, 37, CT_GRAIN       ,  0, L, A), //  95
+	RVI(67, W, 181,   0,       0,  16,     0, RC_W, 37, CT_WOOD        ,  0, L, A), //  96
+	RVI(68, W, 179,   0,       0,  19,     0, RC_W, 37, CT_IRON_ORE    ,  0, L, A), //  97
+	RVI(69, W, 196,   0,       0,  18,     0, RC_W, 27, CT_STEEL       ,  0, L, A), //  98
+	RVI(70, W, 255,   0,       0,  30,     0, RC_W, 27, CT_VALUABLES   ,  0, L, A), //  99
+	RVI(71, W, 191,   0,       0,  22,     0, RC_W, 32, CT_FOOD        ,  0, L, A), // 100
+	RVI(72, W, 196,   0,       0,  18,     0, RC_W, 27, CT_PAPER       ,  0, L, A), // 101
+	RVI(73, W, 179,   0,       0,  19,     0, RC_W, 37, CT_COPPER_ORE  ,  0, L, A), // 102
+	RVI(47, W, 199,   0,       0,  25,     0, RC_W, 32, CT_WATER       ,  0, L, A), // 103
+	RVI(48, W, 182,   0,       0,  18,     0, RC_W, 32, CT_FRUIT       ,  0, L, A), // 104
+	RVI(49, W, 185,   0,       0,  19,     0, RC_W, 28, CT_RUBBER      ,  0, L, A), // 105
+	RVI(50, W, 176,   0,       0,  19,     0, RC_W, 37, CT_SUGAR       ,  0, L, A), // 106
+	RVI(51, W, 178,   0,       0,  20,     0, RC_W, 37, CT_COTTON_CANDY,  0, L, A), // 107
+	RVI(52, W, 192,   0,       0,  20,     0, RC_W, 37, CT_TOFFEE      ,  0, L, A), // 108
+	RVI(53, W, 190,   0,       0,  21,     0, RC_W, 27, CT_BUBBLES     ,  0, L, A), // 109
+	RVI(54, W, 182,   0,       0,  24,     0, RC_W, 32, CT_COLA        ,  0, L, A), // 110
+	RVI(55, W, 181,   0,       0,  21,     0, RC_W, 32, CT_CANDY       ,  0, L, A), // 111
+	RVI(56, W, 183,   0,       0,  21,     0, RC_W, 27, CT_TOYS        ,  0, L, A), // 112
+	RVI(57, W, 196,   0,       0,  18,     0, RC_W, 29, CT_BATTERIES   ,  0, L, A), // 113
+	RVI(58, W, 193,   0,       0,  18,     0, RC_W, 32, CT_FIZZY_DRINKS,  0, L, A), // 114
+	RVI(59, W, 191,   0,       0,  18,     0, RC_W, 37, CT_PLASTIC     ,  0, L, A), // 115
 };
 #undef L
 #undef O
@@ -609,7 +617,7 @@
  * @param f capacity
  * @param g cargo_type
  */
-#define ROV(a, b, c, d, e, f, g) { a, b, c, {d}, e, f, g }
+#define ROV(a, b, c, d, e, f, g) { a, b, c, RC_R, {d}, e, f, g }
 const RoadVehicleInfo _orig_road_vehicle_info[NUM_ROAD_ENGINES] = {
 	//    image_index       sfx                                 max_speed
 	//    |    base_cost    |                                   |   capacity
--- a/src/table/road_land.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/table/road_land.h	Fri Feb 22 00:25:54 2008 +0000
@@ -1,7 +1,7 @@
 /* $Id$ */
 
-#define TILE_SEQ_LINE(img, pal, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 20, img, pal },
-#define TILE_SEQ_END() { 0, 0, 0, 0, 0, 0, 0, 0 }
+#define TILE_SEQ_LINE(img, pal, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 20, {img, pal} },
+#define TILE_SEQ_END() { 0, 0, 0, 0, 0, 0, {0, 0} }
 
 static const DrawTileSeqStruct _road_depot_NE[] = {
 	TILE_SEQ_LINE(0x584 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 15, 16, 1)
@@ -26,10 +26,10 @@
 };
 
 static const DrawTileSprites _road_depot[] = {
-	{ 0xA4A, PAL_NONE, _road_depot_NE },
-	{ 0xA4A, PAL_NONE, _road_depot_SE },
-	{ 0xA4A, PAL_NONE, _road_depot_SW },
-	{ 0xA4A, PAL_NONE, _road_depot_NW }
+	{ {0xA4A, PAL_NONE}, _road_depot_NE },
+	{ {0xA4A, PAL_NONE}, _road_depot_SE },
+	{ {0xA4A, PAL_NONE}, _road_depot_SW },
+	{ {0xA4A, PAL_NONE}, _road_depot_NW }
 };
 
 static const DrawTileSeqStruct _tram_depot_NE[] = {
@@ -55,13 +55,12 @@
 };
 
 static const DrawTileSprites _tram_depot[] = {
-	{ 0xA4A, PAL_NONE, _tram_depot_NE },
-	{ 0xA4A, PAL_NONE, _tram_depot_SE },
-	{ 0xA4A, PAL_NONE, _tram_depot_SW },
-	{ 0xA4A, PAL_NONE, _tram_depot_NW }
+	{ {0xA4A, PAL_NONE}, _tram_depot_NE },
+	{ {0xA4A, PAL_NONE}, _tram_depot_SE },
+	{ {0xA4A, PAL_NONE}, _tram_depot_SW },
+	{ {0xA4A, PAL_NONE}, _tram_depot_NW }
 };
 
-#undef TILE_SEQ_BEGIN
 #undef TILE_SEQ_LINE
 #undef TILE_SEQ_END
 
--- a/src/table/roadveh.h	Thu Feb 21 22:34:54 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1470 +0,0 @@
-/* $Id$ */
-
-/** @file table/roadveh.h Data about how a road vehicle must drive on a tile */
-
-static const RoadDriveEntry _roadveh_drive_data_0[] = {
-	{15, 5},
-	{14, 5},
-	{13, 5},
-	{12, 5},
-	{11, 5},
-	{10, 5},
-	{ 9, 5},
-	{ 8, 5},
-	{ 7, 5},
-	{ 6, 5},
-	{ 5, 5},
-	{ 4, 5},
-	{ 3, 5},
-	{ 2, 5},
-	{ 1, 5},
-	{ 0, 5},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_1[] = {
-	{5,  0},
-	{5,  1},
-	{5,  2},
-	{5,  3},
-	{5,  4},
-	{5,  5},
-	{5,  6},
-	{5,  7},
-	{5,  8},
-	{5,  9},
-	{5, 10},
-	{5, 11},
-	{5, 12},
-	{5, 13},
-	{5, 14},
-	{5, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_2[] = {
-	{5, 0},
-	{5, 1},
-	{5, 2},
-	{4, 3},
-	{3, 4},
-	{2, 5},
-	{1, 5},
-	{0, 5},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_3[] = {
-	{15,  5},
-	{14,  5},
-	{13,  5},
-	{12,  5},
-	{11,  5},
-	{10,  5},
-	{ 9,  6},
-	{ 8,  7},
-	{ 7,  8},
-	{ 6,  9},
-	{ 5, 10},
-	{ 5, 11},
-	{ 5, 12},
-	{ 5, 13},
-	{ 5, 14},
-	{ 5, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_4[] = {
-	{ 5, 0},
-	{ 5, 1},
-	{ 5, 2},
-	{ 5, 3},
-	{ 5, 4},
-	{ 5, 5},
-	{ 6, 6},
-	{ 7, 7},
-	{ 8, 8},
-	{ 9, 9},
-	{10, 9},
-	{11, 9},
-	{12, 9},
-	{13, 9},
-	{14, 9},
-	{15, 9},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_5[] = {
-	{0,  9},
-	{1,  9},
-	{2,  9},
-	{3, 10},
-	{4, 11},
-	{5, 12},
-	{5, 13},
-	{5, 14},
-	{5, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_6[] = {
-	{0, 6},
-	{0, 7},
-	{0, 8},
-	{0, 9},
-	{RDE_TURNED | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_7[] = {
-	{6, 15},
-	{7, 15},
-	{8, 15},
-	{9, 15},
-	{RDE_TURNED | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_8[] = {
-	{ 0, 9},
-	{ 1, 9},
-	{ 2, 9},
-	{ 3, 9},
-	{ 4, 9},
-	{ 5, 9},
-	{ 6, 9},
-	{ 7, 9},
-	{ 8, 9},
-	{ 9, 9},
-	{10, 9},
-	{11, 9},
-	{12, 9},
-	{13, 9},
-	{14, 9},
-	{15, 9},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_9[] = {
-	{9, 15},
-	{9, 14},
-	{9, 13},
-	{9, 12},
-	{9, 11},
-	{9, 10},
-	{9,  9},
-	{9,  8},
-	{9,  7},
-	{9,  6},
-	{9,  5},
-	{9,  4},
-	{9,  3},
-	{9,  2},
-	{9,  1},
-	{9,  0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_10[] = {
-	{0, 9},
-	{1, 9},
-	{2, 9},
-	{3, 9},
-	{4, 9},
-	{5, 9},
-	{6, 8},
-	{7, 7},
-	{8, 6},
-	{9, 5},
-	{9, 4},
-	{9, 3},
-	{9, 2},
-	{9, 1},
-	{9, 0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_11[] = {
-	{ 9, 15},
-	{ 9, 14},
-	{ 9, 13},
-	{10, 12},
-	{11, 11},
-	{12, 10},
-	{13,  9},
-	{14,  9},
-	{15,  9},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_12[] = {
-	{15, 5},
-	{14, 5},
-	{13, 5},
-	{12, 4},
-	{11, 3},
-	{10, 2},
-	{ 9, 1},
-	{ 9, 0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_13[] = {
-	{9, 15},
-	{9, 14},
-	{9, 13},
-	{9, 12},
-	{9, 11},
-	{9, 10},
-	{8,  9},
-	{7,  8},
-	{6,  7},
-	{5,  6},
-	{4,  5},
-	{3,  5},
-	{2,  5},
-	{1,  5},
-	{0,  5},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_14[] = {
-	{15, 8},
-	{15, 7},
-	{15, 6},
-	{15, 5},
-	{RDE_TURNED | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_15[] = {
-	{8, 0},
-	{7, 0},
-	{6, 0},
-	{5, 0},
-	{RDE_TURNED | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_16[] = {
-	{15, 9},
-	{14, 9},
-	{13, 9},
-	{12, 9},
-	{11, 9},
-	{10, 9},
-	{ 9, 9},
-	{ 8, 9},
-	{ 7, 9},
-	{ 6, 9},
-	{ 5, 9},
-	{ 4, 9},
-	{ 3, 9},
-	{ 2, 9},
-	{ 1, 9},
-	{ 0, 9},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_17[] = {
-	{9,  0},
-	{9,  1},
-	{9,  2},
-	{9,  3},
-	{9,  4},
-	{9,  5},
-	{9,  6},
-	{9,  7},
-	{9,  8},
-	{9,  9},
-	{9, 10},
-	{9, 11},
-	{9, 12},
-	{9, 13},
-	{9, 14},
-	{9, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_18[] = {
-	{9, 0},
-	{9, 1},
-	{9, 2},
-	{9, 3},
-	{9, 4},
-	{9, 5},
-	{8, 6},
-	{7, 7},
-	{6, 8},
-	{5, 9},
-	{4, 9},
-	{3, 9},
-	{2, 9},
-	{1, 9},
-	{0, 9},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_19[] = {
-	{15,  9},
-	{14,  9},
-	{13,  9},
-	{12, 10},
-	{11, 11},
-	{10, 12},
-	{ 9, 13},
-	{ 9, 14},
-	{ 9, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_20[] = {
-	{ 9, 0},
-	{ 9, 1},
-	{10, 2},
-	{11, 3},
-	{12, 4},
-	{13, 5},
-	{14, 5},
-	{15, 5},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_21[] = {
-	{0,  5},
-	{1,  5},
-	{2,  5},
-	{3,  5},
-	{4,  5},
-	{5,  6},
-	{6,  7},
-	{7,  8},
-	{8,  9},
-	{9, 10},
-	{9, 11},
-	{9, 12},
-	{9, 13},
-	{9, 14},
-	{9, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_22[] = {
-	{0, 8},
-	{0, 7},
-	{0, 6},
-	{0, 5},
-	{RDE_TURNED | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_23[] = {
-	{8, 15},
-	{7, 15},
-	{6, 15},
-	{5, 15},
-	{RDE_TURNED | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_24[] = {
-	{ 0, 5},
-	{ 1, 5},
-	{ 2, 5},
-	{ 3, 5},
-	{ 4, 5},
-	{ 5, 5},
-	{ 6, 5},
-	{ 7, 5},
-	{ 8, 5},
-	{ 9, 5},
-	{10, 5},
-	{11, 5},
-	{12, 5},
-	{13, 5},
-	{14, 5},
-	{15, 5},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_25[] = {
-	{5, 15},
-	{5, 14},
-	{5, 13},
-	{5, 12},
-	{5, 11},
-	{5, 10},
-	{5,  9},
-	{5,  8},
-	{5,  7},
-	{5,  6},
-	{5,  5},
-	{5,  4},
-	{5,  3},
-	{5,  2},
-	{5,  1},
-	{5,  0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_26[] = {
-	{0, 5},
-	{1, 5},
-	{2, 5},
-	{3, 4},
-	{4, 3},
-	{5, 2},
-	{5, 1},
-	{5, 0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_27[] = {
-	{ 5, 15},
-	{ 5, 14},
-	{ 5, 13},
-	{ 5, 12},
-	{ 5, 11},
-	{ 5, 10},
-	{ 6,  9},
-	{ 7,  8},
-	{ 8,  7},
-	{ 9,  6},
-	{10,  5},
-	{11,  5},
-	{12,  5},
-	{13,  5},
-	{14,  5},
-	{15,  5},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_28[] = {
-	{15, 9},
-	{14, 9},
-	{13, 9},
-	{12, 9},
-	{11, 9},
-	{10, 9},
-	{ 9, 9},
-	{ 8, 8},
-	{ 7, 7},
-	{ 6, 6},
-	{ 5, 5},
-	{ 5, 4},
-	{ 5, 3},
-	{ 5, 2},
-	{ 5, 1},
-	{ 5, 0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_29[] = {
-	{5, 15},
-	{5, 14},
-	{5, 13},
-	{5, 12},
-	{4, 11},
-	{3, 10},
-	{2,  9},
-	{1,  9},
-	{0,  9},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_30[] = {
-	{15, 6},
-	{15, 7},
-	{15, 8},
-	{15, 9},
-	{RDE_TURNED | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_31[] = {
-	{6, 0},
-	{7, 0},
-	{8, 0},
-	{9, 0},
-	{RDE_TURNED | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_32[] = {
-	{15,  5},
-	{14,  5},
-	{13,  6},
-	{13,  7},
-	{13,  8},
-	{13,  9},
-	{13, 10},
-	{13, 11},
-	{12, 12},
-	{11, 12},
-	{10, 12},
-	{ 9, 12},
-	{ 8, 12},
-	{ 7, 12},
-	{ 6, 12},
-	{ 5, 11},
-	{ 5, 10},
-	{ 5,  9},
-	{ 5,  8},
-	{ 5,  7},
-	{ 5,  6},
-	{ 5,  7},
-	{ 5,  8},
-	{ 5,  9},
-	{ 5, 10},
-	{ 5, 11},
-	{ 6, 12},
-	{ 7, 12},
-	{ 8, 12},
-	{ 9, 12},
-	{10, 12},
-	{11, 12},
-	{12, 12},
-	{13, 11},
-	{13, 10},
-	{14,  9},
-	{15,  9},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_33[] = {
-	{ 5,  0},
-	{ 5,  1},
-	{ 6,  2},
-	{ 7,  2},
-	{ 8,  2},
-	{ 9,  2},
-	{10,  2},
-	{11,  2},
-	{12,  3},
-	{12,  4},
-	{12,  5},
-	{12,  6},
-	{12,  7},
-	{12,  8},
-	{12,  9},
-	{11, 10},
-	{10, 10},
-	{ 9, 10},
-	{ 8, 10},
-	{ 7, 10},
-	{ 6, 10},
-	{ 7, 10},
-	{ 8, 10},
-	{ 9, 10},
-	{10, 10},
-	{11, 10},
-	{12,  9},
-	{12,  8},
-	{12,  7},
-	{12,  6},
-	{12,  5},
-	{12,  4},
-	{12,  3},
-	{11,  2},
-	{10,  2},
-	{ 9,  1},
-	{ 9,  0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_34[] = {
-	{15,  5},
-	{14,  5},
-	{13,  6},
-	{13,  7},
-	{13,  8},
-	{13,  9},
-	{13, 10},
-	{13, 11},
-	{12, 12},
-	{11, 12},
-	{10, 12},
-	{ 9, 11},
-	{ 9, 10},
-	{ 9,  9},
-	{ 9,  8},
-	{ 9,  7},
-	{ 9,  6},
-	{ 9,  7},
-	{ 9,  8},
-	{ 9,  9},
-	{ 9, 10},
-	{ 9, 11},
-	{10, 12},
-	{11, 12},
-	{12, 12},
-	{13, 11},
-	{13, 10},
-	{14,  9},
-	{15,  9},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_35[] = {
-	{ 5, 0},
-	{ 5, 1},
-	{ 6, 2},
-	{ 7, 2},
-	{ 8, 2},
-	{ 9, 2},
-	{10, 2},
-	{11, 2},
-	{12, 3},
-	{12, 4},
-	{12, 5},
-	{11, 6},
-	{10, 6},
-	{ 9, 6},
-	{ 8, 6},
-	{ 7, 6},
-	{ 6, 6},
-	{ 7, 6},
-	{ 8, 6},
-	{ 9, 6},
-	{10, 6},
-	{11, 6},
-	{12, 5},
-	{12, 4},
-	{12, 3},
-	{11, 2},
-	{10, 2},
-	{ 9, 1},
-	{ 9, 0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_40[] = {
-	{ 0, 9},
-	{ 1, 9},
-	{ 2, 8},
-	{ 2, 7},
-	{ 2, 6},
-	{ 2, 5},
-	{ 2, 4},
-	{ 3, 3},
-	{ 4, 3},
-	{ 5, 3},
-	{ 6, 3},
-	{ 7, 3},
-	{ 8, 3},
-	{ 9, 3},
-	{10, 4},
-	{10, 5},
-	{10, 6},
-	{10, 7},
-	{10, 8},
-	{10, 9},
-	{10, 8},
-	{10, 7},
-	{10, 6},
-	{10, 5},
-	{10, 4},
-	{ 9, 3},
-	{ 8, 3},
-	{ 7, 3},
-	{ 6, 3},
-	{ 5, 3},
-	{ 4, 3},
-	{ 3, 3},
-	{ 2, 4},
-	{ 1, 5},
-	{ 0, 5},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_41[] = {
-	{9, 15},
-	{9, 14},
-	{8, 13},
-	{7, 13},
-	{6, 13},
-	{5, 13},
-	{4, 13},
-	{3, 12},
-	{3, 11},
-	{3, 10},
-	{3,  9},
-	{3,  8},
-	{3,  7},
-	{3,  6},
-	{4,  5},
-	{5,  5},
-	{6,  5},
-	{7,  5},
-	{8,  5},
-	{9,  5},
-	{8,  5},
-	{7,  5},
-	{6,  5},
-	{5,  5},
-	{4,  5},
-	{3,  6},
-	{3,  7},
-	{3,  8},
-	{3,  9},
-	{3, 10},
-	{3, 11},
-	{3, 12},
-	{4, 13},
-	{5, 14},
-	{5, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_42[] = {
-	{0, 9},
-	{1, 9},
-	{2, 8},
-	{2, 7},
-	{2, 6},
-	{2, 5},
-	{2, 4},
-	{3, 3},
-	{4, 3},
-	{5, 3},
-	{6, 4},
-	{6, 5},
-	{6, 6},
-	{6, 7},
-	{6, 8},
-	{6, 9},
-	{6, 8},
-	{6, 7},
-	{6, 6},
-	{6, 5},
-	{6, 4},
-	{5, 3},
-	{4, 3},
-	{3, 3},
-	{2, 4},
-	{1, 5},
-	{0, 5},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_43[] = {
-	{9, 15},
-	{9, 14},
-	{8, 13},
-	{7, 13},
-	{6, 13},
-	{5, 13},
-	{4, 13},
-	{3, 12},
-	{3, 11},
-	{3, 10},
-	{4,  9},
-	{5,  9},
-	{6,  9},
-	{7,  9},
-	{8,  9},
-	{9,  9},
-	{8,  9},
-	{7,  9},
-	{6,  9},
-	{5,  9},
-	{4,  9},
-	{3, 10},
-	{3, 11},
-	{3, 12},
-	{4, 13},
-	{5, 14},
-	{5, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_48[] = {
-	{15,  9},
-	{14,  9},
-	{13, 10},
-	{13, 11},
-	{12, 12},
-	{11, 12},
-	{10, 12},
-	{ 9, 12},
-	{ 8, 12},
-	{ 7, 12},
-	{ 6, 12},
-	{ 5, 11},
-	{ 5, 10},
-	{ 5,  9},
-	{ 5,  8},
-	{ 5,  7},
-	{ 5,  6},
-	{ 5,  7},
-	{ 5,  8},
-	{ 5,  9},
-	{ 5, 10},
-	{ 5, 11},
-	{ 6, 12},
-	{ 7, 12},
-	{ 8, 12},
-	{ 9, 12},
-	{10, 12},
-	{11, 12},
-	{12, 12},
-	{13, 11},
-	{13, 10},
-	{13,  9},
-	{13,  8},
-	{13,  7},
-	{13,  6},
-	{14,  5},
-	{15,  5},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_49[] = {
-	{ 9,  0},
-	{ 9,  1},
-	{10,  2},
-	{11,  2},
-	{12,  3},
-	{12,  4},
-	{12,  5},
-	{12,  6},
-	{12,  7},
-	{12,  8},
-	{12,  9},
-	{11, 10},
-	{10, 10},
-	{ 9, 10},
-	{ 8, 10},
-	{ 7, 10},
-	{ 6, 10},
-	{ 7, 10},
-	{ 8, 10},
-	{ 9, 10},
-	{10, 10},
-	{11, 10},
-	{12,  9},
-	{12,  8},
-	{12,  7},
-	{12,  6},
-	{12,  5},
-	{12,  4},
-	{12,  3},
-	{11,  2},
-	{10,  2},
-	{ 9,  2},
-	{ 8,  2},
-	{ 7,  2},
-	{ 6,  2},
-	{ 5,  1},
-	{ 5,  0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_50[] = {
-	{15,  9},
-	{14,  9},
-	{13, 10},
-	{13, 11},
-	{12, 12},
-	{11, 12},
-	{10, 12},
-	{ 9, 11},
-	{ 9, 10},
-	{ 9,  9},
-	{ 9,  8},
-	{ 9,  7},
-	{ 9,  6},
-	{ 9,  7},
-	{ 9,  8},
-	{ 9,  9},
-	{ 9, 10},
-	{ 9, 11},
-	{10, 12},
-	{11, 12},
-	{12, 12},
-	{13, 11},
-	{13, 10},
-	{13,  9},
-	{13,  8},
-	{13,  7},
-	{13,  6},
-	{14,  5},
-	{15,  5},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_51[] = {
-	{ 9, 0},
-	{ 9, 1},
-	{10, 2},
-	{11, 2},
-	{12, 3},
-	{12, 4},
-	{12, 5},
-	{11, 6},
-	{10, 6},
-	{ 9, 6},
-	{ 8, 6},
-	{ 7, 6},
-	{ 6, 6},
-	{ 7, 6},
-	{ 8, 6},
-	{ 9, 6},
-	{10, 6},
-	{11, 6},
-	{12, 5},
-	{12, 4},
-	{12, 3},
-	{11, 2},
-	{10, 2},
-	{ 9, 2},
-	{ 8, 2},
-	{ 7, 2},
-	{ 6, 2},
-	{ 5, 1},
-	{ 5, 0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_56[] = {
-	{ 0, 5},
-	{ 1, 5},
-	{ 2, 4},
-	{ 3, 3},
-	{ 4, 3},
-	{ 5, 3},
-	{ 6, 3},
-	{ 7, 3},
-	{ 8, 3},
-	{ 9, 3},
-	{10, 4},
-	{10, 5},
-	{10, 6},
-	{10, 7},
-	{10, 8},
-	{10, 9},
-	{10, 8},
-	{10, 7},
-	{10, 6},
-	{10, 5},
-	{10, 4},
-	{ 9, 3},
-	{ 8, 3},
-	{ 7, 3},
-	{ 6, 3},
-	{ 5, 3},
-	{ 4, 3},
-	{ 3, 3},
-	{ 2, 4},
-	{ 2, 5},
-	{ 2, 6},
-	{ 2, 7},
-	{ 2, 8},
-	{ 1, 9},
-	{ 0, 9},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_57[] = {
-	{5, 15},
-	{5, 14},
-	{4, 13},
-	{3, 12},
-	{3, 11},
-	{3, 10},
-	{3,  9},
-	{3,  8},
-	{3,  7},
-	{3,  6},
-	{4,  5},
-	{5,  5},
-	{6,  5},
-	{7,  5},
-	{8,  5},
-	{9,  5},
-	{8,  5},
-	{7,  5},
-	{6,  5},
-	{5,  5},
-	{4,  5},
-	{3,  6},
-	{3,  7},
-	{3,  8},
-	{3,  9},
-	{3, 10},
-	{3, 11},
-	{3, 12},
-	{4, 13},
-	{5, 13},
-	{6, 13},
-	{7, 13},
-	{8, 13},
-	{9, 14},
-	{9, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_58[] = {
-	{0, 5},
-	{1, 5},
-	{2, 4},
-	{3, 3},
-	{4, 3},
-	{5, 3},
-	{6, 4},
-	{6, 5},
-	{6, 6},
-	{6, 7},
-	{6, 8},
-	{6, 9},
-	{6, 8},
-	{6, 7},
-	{6, 6},
-	{6, 5},
-	{6, 4},
-	{5, 3},
-	{4, 3},
-	{3, 3},
-	{2, 4},
-	{2, 5},
-	{2, 6},
-	{2, 7},
-	{2, 8},
-	{1, 9},
-	{0, 9},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_drive_data_59[] = {
-	{5, 15},
-	{5, 14},
-	{4, 13},
-	{3, 12},
-	{3, 11},
-	{3, 10},
-	{4,  9},
-	{5,  9},
-	{6,  9},
-	{7,  9},
-	{8,  9},
-	{9,  9},
-	{8,  9},
-	{7,  9},
-	{6,  9},
-	{5,  9},
-	{4,  9},
-	{3, 10},
-	{3, 11},
-	{3, 12},
-	{4, 13},
-	{5, 13},
-	{6, 13},
-	{7, 13},
-	{8, 13},
-	{9, 14},
-	{9, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-
-static const RoadDriveEntry * const _road_road_drive_data[] = {
-	_roadveh_drive_data_0,
-	_roadveh_drive_data_1,
-	_roadveh_drive_data_2,
-	_roadveh_drive_data_3,
-	_roadveh_drive_data_4,
-	_roadveh_drive_data_5,
-	_roadveh_drive_data_6,
-	_roadveh_drive_data_7,
-	_roadveh_drive_data_8,
-	_roadveh_drive_data_9,
-	_roadveh_drive_data_10,
-	_roadveh_drive_data_11,
-	_roadveh_drive_data_12,
-	_roadveh_drive_data_13,
-	_roadveh_drive_data_14,
-	_roadveh_drive_data_15,
-	_roadveh_drive_data_16,
-	_roadveh_drive_data_17,
-	_roadveh_drive_data_18,
-	_roadveh_drive_data_19,
-	_roadveh_drive_data_20,
-	_roadveh_drive_data_21,
-	_roadveh_drive_data_22,
-	_roadveh_drive_data_23,
-	_roadveh_drive_data_24,
-	_roadveh_drive_data_25,
-	_roadveh_drive_data_26,
-	_roadveh_drive_data_27,
-	_roadveh_drive_data_28,
-	_roadveh_drive_data_29,
-	_roadveh_drive_data_30,
-	_roadveh_drive_data_31,
-	_roadveh_drive_data_32,
-	_roadveh_drive_data_33,
-	_roadveh_drive_data_34,
-	_roadveh_drive_data_35,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	_roadveh_drive_data_40,
-	_roadveh_drive_data_41,
-	_roadveh_drive_data_42,
-	_roadveh_drive_data_43,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	_roadveh_drive_data_48,
-	_roadveh_drive_data_49,
-	_roadveh_drive_data_50,
-	_roadveh_drive_data_51,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	_roadveh_drive_data_56,
-	_roadveh_drive_data_57,
-	_roadveh_drive_data_58,
-	_roadveh_drive_data_59,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-};
-
-static const RoadDriveEntry _roadveh_tram_turn_ne_0[] = {
-	{15, 5},
-	{14, 5},
-	{13, 5},
-	{12, 5},
-	{11, 5},
-	{10, 5},
-	{ 9, 5},
-	{ 8, 5},
-	{ 7, 5},
-	{ 6, 5},
-	{ 5, 5},
-	{ 4, 5},
-	{ 3, 5},
-	{ 2, 5},
-	{ 1, 5},
-	{ 0, 5},
-	{ 0, 6},
-	{ 0, 7},
-	{ 0, 8},
-	{ 0, 9},
-	{RDE_TURNED | DIAGDIR_SW, 0},
-	{ 1, 9},
-	{ 2, 9},
-	{ 3, 9},
-	{ 4, 9},
-	{ 5, 9},
-	{ 6, 9},
-	{ 7, 9},
-	{ 8, 9},
-	{ 9, 9},
-	{10, 9},
-	{11, 9},
-	{12, 9},
-	{13, 9},
-	{14, 9},
-	{15, 9},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-
-static const RoadDriveEntry _roadveh_tram_turn_ne_1[] = {
-	{15, 9},
-	{14, 9},
-	{13, 9},
-	{12, 9},
-	{11, 9},
-	{10, 9},
-	{ 9, 9},
-	{ 8, 9},
-	{ 7, 9},
-	{ 6, 9},
-	{ 5, 9},
-	{ 4, 9},
-	{ 3, 9},
-	{ 2, 9},
-	{ 1, 9},
-	{ 0, 9},
-	{ 0, 8},
-	{ 0, 7},
-	{ 0, 6},
-	{ 0, 5},
-	{RDE_TURNED | DIAGDIR_SW, 0},
-	{ 1, 5},
-	{ 2, 5},
-	{ 3, 5},
-	{ 4, 5},
-	{ 5, 5},
-	{ 6, 5},
-	{ 7, 5},
-	{ 8, 5},
-	{ 9, 5},
-	{10, 5},
-	{11, 5},
-	{12, 5},
-	{13, 5},
-	{14, 5},
-	{15, 5},
-	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
-};
-
-static const RoadDriveEntry _roadveh_tram_turn_se_0[] = {
-	{5,  0},
-	{5,  1},
-	{5,  2},
-	{5,  3},
-	{5,  4},
-	{5,  5},
-	{5,  6},
-	{5,  7},
-	{5,  8},
-	{5,  9},
-	{5, 10},
-	{5, 11},
-	{5, 12},
-	{5, 13},
-	{5, 14},
-	{5, 15},
-	{6, 15},
-	{7, 15},
-	{8, 15},
-	{9, 15},
-	{RDE_TURNED | DIAGDIR_NW, 0},
-	{9, 14},
-	{9, 13},
-	{9, 12},
-	{9, 11},
-	{9, 10},
-	{9,  9},
-	{9,  8},
-	{9,  7},
-	{9,  6},
-	{9,  5},
-	{9,  4},
-	{9,  3},
-	{9,  2},
-	{9,  1},
-	{9,  0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-
-static const RoadDriveEntry _roadveh_tram_turn_se_1[] = {
-	{9,  0},
-	{9,  1},
-	{9,  2},
-	{9,  3},
-	{9,  4},
-	{9,  5},
-	{9,  6},
-	{9,  7},
-	{9,  8},
-	{9,  9},
-	{9, 10},
-	{9, 11},
-	{9, 12},
-	{9, 13},
-	{9, 14},
-	{9, 15},
-	{8, 15},
-	{7, 15},
-	{6, 15},
-	{5, 15},
-	{RDE_TURNED | DIAGDIR_NW, 0},
-	{5, 14},
-	{5, 13},
-	{5, 12},
-	{5, 11},
-	{5, 10},
-	{5,  9},
-	{5,  8},
-	{5,  7},
-	{5,  6},
-	{5,  5},
-	{5,  4},
-	{5,  3},
-	{5,  2},
-	{5,  1},
-	{5,  0},
-	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
-};
-
-static const RoadDriveEntry _roadveh_tram_turn_sw_0[] = {
-	{ 0, 9},
-	{ 1, 9},
-	{ 2, 9},
-	{ 3, 9},
-	{ 4, 9},
-	{ 5, 9},
-	{ 6, 9},
-	{ 7, 9},
-	{ 8, 9},
-	{ 9, 9},
-	{10, 9},
-	{11, 9},
-	{12, 9},
-	{13, 9},
-	{14, 9},
-	{15, 9},
-	{15, 8},
-	{15, 7},
-	{15, 6},
-	{15, 5},
-	{RDE_TURNED | DIAGDIR_SW, 0},
-	{14, 5},
-	{13, 5},
-	{12, 5},
-	{11, 5},
-	{10, 5},
-	{ 9, 5},
-	{ 8, 5},
-	{ 7, 5},
-	{ 6, 5},
-	{ 5, 5},
-	{ 4, 5},
-	{ 3, 5},
-	{ 2, 5},
-	{ 1, 5},
-	{ 0, 5},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-static const RoadDriveEntry _roadveh_tram_turn_sw_1[] = {
-	{ 0, 5},
-	{ 1, 5},
-	{ 2, 5},
-	{ 3, 5},
-	{ 4, 5},
-	{ 5, 5},
-	{ 6, 5},
-	{ 7, 5},
-	{ 8, 5},
-	{ 9, 5},
-	{10, 5},
-	{11, 5},
-	{12, 5},
-	{13, 5},
-	{14, 5},
-	{15, 5},
-	{15, 6},
-	{15, 7},
-	{15, 8},
-	{15, 9},
-	{RDE_TURNED | DIAGDIR_NE, 0},
-	{14, 9},
-	{13, 9},
-	{12, 9},
-	{11, 9},
-	{10, 9},
-	{ 9, 9},
-	{ 8, 9},
-	{ 7, 9},
-	{ 6, 9},
-	{ 5, 9},
-	{ 4, 9},
-	{ 3, 9},
-	{ 2, 9},
-	{ 1, 9},
-	{ 0, 9},
-	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
-};
-
-static const RoadDriveEntry _roadveh_tram_turn_nw_0[] = {
-	{9, 15},
-	{9, 14},
-	{9, 13},
-	{9, 12},
-	{9, 11},
-	{9, 10},
-	{9,  9},
-	{9,  8},
-	{9,  7},
-	{9,  6},
-	{9,  5},
-	{9,  4},
-	{9,  3},
-	{9,  2},
-	{9,  1},
-	{9,  0},
-	{8,  0},
-	{7,  0},
-	{6,  0},
-	{5,  0},
-	{RDE_TURNED | DIAGDIR_SE, 0},
-	{5,  1},
-	{5,  2},
-	{5,  3},
-	{5,  4},
-	{5,  5},
-	{5,  6},
-	{5,  7},
-	{5,  8},
-	{5,  9},
-	{5, 10},
-	{5, 11},
-	{5, 12},
-	{5, 13},
-	{5, 14},
-	{5, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-static const RoadDriveEntry _roadveh_tram_turn_nw_1[] = {
-	{5, 15},
-	{5, 14},
-	{5, 13},
-	{5, 12},
-	{5, 11},
-	{5, 10},
-	{5,  9},
-	{5,  8},
-	{5,  7},
-	{5,  6},
-	{5,  5},
-	{5,  4},
-	{5,  3},
-	{5,  2},
-	{5,  1},
-	{5,  0},
-	{6,  0},
-	{7,  0},
-	{8,  0},
-	{9,  0},
-	{RDE_TURNED | DIAGDIR_SE, 0},
-	{9,  1},
-	{9,  2},
-	{9,  3},
-	{9,  4},
-	{9,  5},
-	{9,  6},
-	{9,  7},
-	{9,  8},
-	{9,  9},
-	{9, 10},
-	{9, 11},
-	{9, 12},
-	{9, 13},
-	{9, 14},
-	{9, 15},
-	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
-};
-
-static const RoadDriveEntry * const _road_tram_drive_data[] = {
-	_roadveh_drive_data_0,
-	_roadveh_drive_data_1,
-	_roadveh_drive_data_2,
-	_roadveh_drive_data_3,
-	_roadveh_drive_data_4,
-	_roadveh_drive_data_5,
-	_roadveh_tram_turn_ne_0,
-	_roadveh_tram_turn_se_0,
-	_roadveh_drive_data_8,
-	_roadveh_drive_data_9,
-	_roadveh_drive_data_10,
-	_roadveh_drive_data_11,
-	_roadveh_drive_data_12,
-	_roadveh_drive_data_13,
-	_roadveh_tram_turn_sw_0,
-	_roadveh_tram_turn_nw_0,
-	_roadveh_drive_data_16,
-	_roadveh_drive_data_17,
-	_roadveh_drive_data_18,
-	_roadveh_drive_data_19,
-	_roadveh_drive_data_20,
-	_roadveh_drive_data_21,
-	_roadveh_tram_turn_ne_1,
-	_roadveh_tram_turn_se_1,
-	_roadveh_drive_data_24,
-	_roadveh_drive_data_25,
-	_roadveh_drive_data_26,
-	_roadveh_drive_data_27,
-	_roadveh_drive_data_28,
-	_roadveh_drive_data_29,
-	_roadveh_tram_turn_sw_1,
-	_roadveh_tram_turn_nw_1,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-};
-
-static const RoadDriveEntry * const * const _road_drive_data[2] = {
-	_road_road_drive_data,
-	_road_tram_drive_data,
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/table/roadveh_movement.h	Fri Feb 22 00:25:54 2008 +0000
@@ -0,0 +1,1470 @@
+/* $Id$ */
+
+/** @file table/roadveh_movement.h Data about how a road vehicle must drive on a tile */
+
+static const RoadDriveEntry _roadveh_drive_data_0[] = {
+	{15, 5},
+	{14, 5},
+	{13, 5},
+	{12, 5},
+	{11, 5},
+	{10, 5},
+	{ 9, 5},
+	{ 8, 5},
+	{ 7, 5},
+	{ 6, 5},
+	{ 5, 5},
+	{ 4, 5},
+	{ 3, 5},
+	{ 2, 5},
+	{ 1, 5},
+	{ 0, 5},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_1[] = {
+	{5,  0},
+	{5,  1},
+	{5,  2},
+	{5,  3},
+	{5,  4},
+	{5,  5},
+	{5,  6},
+	{5,  7},
+	{5,  8},
+	{5,  9},
+	{5, 10},
+	{5, 11},
+	{5, 12},
+	{5, 13},
+	{5, 14},
+	{5, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_2[] = {
+	{5, 0},
+	{5, 1},
+	{5, 2},
+	{4, 3},
+	{3, 4},
+	{2, 5},
+	{1, 5},
+	{0, 5},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_3[] = {
+	{15,  5},
+	{14,  5},
+	{13,  5},
+	{12,  5},
+	{11,  5},
+	{10,  5},
+	{ 9,  6},
+	{ 8,  7},
+	{ 7,  8},
+	{ 6,  9},
+	{ 5, 10},
+	{ 5, 11},
+	{ 5, 12},
+	{ 5, 13},
+	{ 5, 14},
+	{ 5, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_4[] = {
+	{ 5, 0},
+	{ 5, 1},
+	{ 5, 2},
+	{ 5, 3},
+	{ 5, 4},
+	{ 5, 5},
+	{ 6, 6},
+	{ 7, 7},
+	{ 8, 8},
+	{ 9, 9},
+	{10, 9},
+	{11, 9},
+	{12, 9},
+	{13, 9},
+	{14, 9},
+	{15, 9},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_5[] = {
+	{0,  9},
+	{1,  9},
+	{2,  9},
+	{3, 10},
+	{4, 11},
+	{5, 12},
+	{5, 13},
+	{5, 14},
+	{5, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_6[] = {
+	{0, 6},
+	{0, 7},
+	{0, 8},
+	{0, 9},
+	{RDE_TURNED | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_7[] = {
+	{6, 15},
+	{7, 15},
+	{8, 15},
+	{9, 15},
+	{RDE_TURNED | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_8[] = {
+	{ 0, 9},
+	{ 1, 9},
+	{ 2, 9},
+	{ 3, 9},
+	{ 4, 9},
+	{ 5, 9},
+	{ 6, 9},
+	{ 7, 9},
+	{ 8, 9},
+	{ 9, 9},
+	{10, 9},
+	{11, 9},
+	{12, 9},
+	{13, 9},
+	{14, 9},
+	{15, 9},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_9[] = {
+	{9, 15},
+	{9, 14},
+	{9, 13},
+	{9, 12},
+	{9, 11},
+	{9, 10},
+	{9,  9},
+	{9,  8},
+	{9,  7},
+	{9,  6},
+	{9,  5},
+	{9,  4},
+	{9,  3},
+	{9,  2},
+	{9,  1},
+	{9,  0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_10[] = {
+	{0, 9},
+	{1, 9},
+	{2, 9},
+	{3, 9},
+	{4, 9},
+	{5, 9},
+	{6, 8},
+	{7, 7},
+	{8, 6},
+	{9, 5},
+	{9, 4},
+	{9, 3},
+	{9, 2},
+	{9, 1},
+	{9, 0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_11[] = {
+	{ 9, 15},
+	{ 9, 14},
+	{ 9, 13},
+	{10, 12},
+	{11, 11},
+	{12, 10},
+	{13,  9},
+	{14,  9},
+	{15,  9},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_12[] = {
+	{15, 5},
+	{14, 5},
+	{13, 5},
+	{12, 4},
+	{11, 3},
+	{10, 2},
+	{ 9, 1},
+	{ 9, 0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_13[] = {
+	{9, 15},
+	{9, 14},
+	{9, 13},
+	{9, 12},
+	{9, 11},
+	{9, 10},
+	{8,  9},
+	{7,  8},
+	{6,  7},
+	{5,  6},
+	{4,  5},
+	{3,  5},
+	{2,  5},
+	{1,  5},
+	{0,  5},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_14[] = {
+	{15, 8},
+	{15, 7},
+	{15, 6},
+	{15, 5},
+	{RDE_TURNED | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_15[] = {
+	{8, 0},
+	{7, 0},
+	{6, 0},
+	{5, 0},
+	{RDE_TURNED | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_16[] = {
+	{15, 9},
+	{14, 9},
+	{13, 9},
+	{12, 9},
+	{11, 9},
+	{10, 9},
+	{ 9, 9},
+	{ 8, 9},
+	{ 7, 9},
+	{ 6, 9},
+	{ 5, 9},
+	{ 4, 9},
+	{ 3, 9},
+	{ 2, 9},
+	{ 1, 9},
+	{ 0, 9},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_17[] = {
+	{9,  0},
+	{9,  1},
+	{9,  2},
+	{9,  3},
+	{9,  4},
+	{9,  5},
+	{9,  6},
+	{9,  7},
+	{9,  8},
+	{9,  9},
+	{9, 10},
+	{9, 11},
+	{9, 12},
+	{9, 13},
+	{9, 14},
+	{9, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_18[] = {
+	{9, 0},
+	{9, 1},
+	{9, 2},
+	{9, 3},
+	{9, 4},
+	{9, 5},
+	{8, 6},
+	{7, 7},
+	{6, 8},
+	{5, 9},
+	{4, 9},
+	{3, 9},
+	{2, 9},
+	{1, 9},
+	{0, 9},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_19[] = {
+	{15,  9},
+	{14,  9},
+	{13,  9},
+	{12, 10},
+	{11, 11},
+	{10, 12},
+	{ 9, 13},
+	{ 9, 14},
+	{ 9, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_20[] = {
+	{ 9, 0},
+	{ 9, 1},
+	{10, 2},
+	{11, 3},
+	{12, 4},
+	{13, 5},
+	{14, 5},
+	{15, 5},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_21[] = {
+	{0,  5},
+	{1,  5},
+	{2,  5},
+	{3,  5},
+	{4,  5},
+	{5,  6},
+	{6,  7},
+	{7,  8},
+	{8,  9},
+	{9, 10},
+	{9, 11},
+	{9, 12},
+	{9, 13},
+	{9, 14},
+	{9, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_22[] = {
+	{0, 8},
+	{0, 7},
+	{0, 6},
+	{0, 5},
+	{RDE_TURNED | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_23[] = {
+	{8, 15},
+	{7, 15},
+	{6, 15},
+	{5, 15},
+	{RDE_TURNED | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_24[] = {
+	{ 0, 5},
+	{ 1, 5},
+	{ 2, 5},
+	{ 3, 5},
+	{ 4, 5},
+	{ 5, 5},
+	{ 6, 5},
+	{ 7, 5},
+	{ 8, 5},
+	{ 9, 5},
+	{10, 5},
+	{11, 5},
+	{12, 5},
+	{13, 5},
+	{14, 5},
+	{15, 5},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_25[] = {
+	{5, 15},
+	{5, 14},
+	{5, 13},
+	{5, 12},
+	{5, 11},
+	{5, 10},
+	{5,  9},
+	{5,  8},
+	{5,  7},
+	{5,  6},
+	{5,  5},
+	{5,  4},
+	{5,  3},
+	{5,  2},
+	{5,  1},
+	{5,  0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_26[] = {
+	{0, 5},
+	{1, 5},
+	{2, 5},
+	{3, 4},
+	{4, 3},
+	{5, 2},
+	{5, 1},
+	{5, 0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_27[] = {
+	{ 5, 15},
+	{ 5, 14},
+	{ 5, 13},
+	{ 5, 12},
+	{ 5, 11},
+	{ 5, 10},
+	{ 6,  9},
+	{ 7,  8},
+	{ 8,  7},
+	{ 9,  6},
+	{10,  5},
+	{11,  5},
+	{12,  5},
+	{13,  5},
+	{14,  5},
+	{15,  5},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_28[] = {
+	{15, 9},
+	{14, 9},
+	{13, 9},
+	{12, 9},
+	{11, 9},
+	{10, 9},
+	{ 9, 9},
+	{ 8, 8},
+	{ 7, 7},
+	{ 6, 6},
+	{ 5, 5},
+	{ 5, 4},
+	{ 5, 3},
+	{ 5, 2},
+	{ 5, 1},
+	{ 5, 0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_29[] = {
+	{5, 15},
+	{5, 14},
+	{5, 13},
+	{5, 12},
+	{4, 11},
+	{3, 10},
+	{2,  9},
+	{1,  9},
+	{0,  9},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_30[] = {
+	{15, 6},
+	{15, 7},
+	{15, 8},
+	{15, 9},
+	{RDE_TURNED | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_31[] = {
+	{6, 0},
+	{7, 0},
+	{8, 0},
+	{9, 0},
+	{RDE_TURNED | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_32[] = {
+	{15,  5},
+	{14,  5},
+	{13,  6},
+	{13,  7},
+	{13,  8},
+	{13,  9},
+	{13, 10},
+	{13, 11},
+	{12, 12},
+	{11, 12},
+	{10, 12},
+	{ 9, 12},
+	{ 8, 12},
+	{ 7, 12},
+	{ 6, 12},
+	{ 5, 11},
+	{ 5, 10},
+	{ 5,  9},
+	{ 5,  8},
+	{ 5,  7},
+	{ 5,  6},
+	{ 5,  7},
+	{ 5,  8},
+	{ 5,  9},
+	{ 5, 10},
+	{ 5, 11},
+	{ 6, 12},
+	{ 7, 12},
+	{ 8, 12},
+	{ 9, 12},
+	{10, 12},
+	{11, 12},
+	{12, 12},
+	{13, 11},
+	{13, 10},
+	{14,  9},
+	{15,  9},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_33[] = {
+	{ 5,  0},
+	{ 5,  1},
+	{ 6,  2},
+	{ 7,  2},
+	{ 8,  2},
+	{ 9,  2},
+	{10,  2},
+	{11,  2},
+	{12,  3},
+	{12,  4},
+	{12,  5},
+	{12,  6},
+	{12,  7},
+	{12,  8},
+	{12,  9},
+	{11, 10},
+	{10, 10},
+	{ 9, 10},
+	{ 8, 10},
+	{ 7, 10},
+	{ 6, 10},
+	{ 7, 10},
+	{ 8, 10},
+	{ 9, 10},
+	{10, 10},
+	{11, 10},
+	{12,  9},
+	{12,  8},
+	{12,  7},
+	{12,  6},
+	{12,  5},
+	{12,  4},
+	{12,  3},
+	{11,  2},
+	{10,  2},
+	{ 9,  1},
+	{ 9,  0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_34[] = {
+	{15,  5},
+	{14,  5},
+	{13,  6},
+	{13,  7},
+	{13,  8},
+	{13,  9},
+	{13, 10},
+	{13, 11},
+	{12, 12},
+	{11, 12},
+	{10, 12},
+	{ 9, 11},
+	{ 9, 10},
+	{ 9,  9},
+	{ 9,  8},
+	{ 9,  7},
+	{ 9,  6},
+	{ 9,  7},
+	{ 9,  8},
+	{ 9,  9},
+	{ 9, 10},
+	{ 9, 11},
+	{10, 12},
+	{11, 12},
+	{12, 12},
+	{13, 11},
+	{13, 10},
+	{14,  9},
+	{15,  9},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_35[] = {
+	{ 5, 0},
+	{ 5, 1},
+	{ 6, 2},
+	{ 7, 2},
+	{ 8, 2},
+	{ 9, 2},
+	{10, 2},
+	{11, 2},
+	{12, 3},
+	{12, 4},
+	{12, 5},
+	{11, 6},
+	{10, 6},
+	{ 9, 6},
+	{ 8, 6},
+	{ 7, 6},
+	{ 6, 6},
+	{ 7, 6},
+	{ 8, 6},
+	{ 9, 6},
+	{10, 6},
+	{11, 6},
+	{12, 5},
+	{12, 4},
+	{12, 3},
+	{11, 2},
+	{10, 2},
+	{ 9, 1},
+	{ 9, 0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_40[] = {
+	{ 0, 9},
+	{ 1, 9},
+	{ 2, 8},
+	{ 2, 7},
+	{ 2, 6},
+	{ 2, 5},
+	{ 2, 4},
+	{ 3, 3},
+	{ 4, 3},
+	{ 5, 3},
+	{ 6, 3},
+	{ 7, 3},
+	{ 8, 3},
+	{ 9, 3},
+	{10, 4},
+	{10, 5},
+	{10, 6},
+	{10, 7},
+	{10, 8},
+	{10, 9},
+	{10, 8},
+	{10, 7},
+	{10, 6},
+	{10, 5},
+	{10, 4},
+	{ 9, 3},
+	{ 8, 3},
+	{ 7, 3},
+	{ 6, 3},
+	{ 5, 3},
+	{ 4, 3},
+	{ 3, 3},
+	{ 2, 4},
+	{ 1, 5},
+	{ 0, 5},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_41[] = {
+	{9, 15},
+	{9, 14},
+	{8, 13},
+	{7, 13},
+	{6, 13},
+	{5, 13},
+	{4, 13},
+	{3, 12},
+	{3, 11},
+	{3, 10},
+	{3,  9},
+	{3,  8},
+	{3,  7},
+	{3,  6},
+	{4,  5},
+	{5,  5},
+	{6,  5},
+	{7,  5},
+	{8,  5},
+	{9,  5},
+	{8,  5},
+	{7,  5},
+	{6,  5},
+	{5,  5},
+	{4,  5},
+	{3,  6},
+	{3,  7},
+	{3,  8},
+	{3,  9},
+	{3, 10},
+	{3, 11},
+	{3, 12},
+	{4, 13},
+	{5, 14},
+	{5, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_42[] = {
+	{0, 9},
+	{1, 9},
+	{2, 8},
+	{2, 7},
+	{2, 6},
+	{2, 5},
+	{2, 4},
+	{3, 3},
+	{4, 3},
+	{5, 3},
+	{6, 4},
+	{6, 5},
+	{6, 6},
+	{6, 7},
+	{6, 8},
+	{6, 9},
+	{6, 8},
+	{6, 7},
+	{6, 6},
+	{6, 5},
+	{6, 4},
+	{5, 3},
+	{4, 3},
+	{3, 3},
+	{2, 4},
+	{1, 5},
+	{0, 5},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_43[] = {
+	{9, 15},
+	{9, 14},
+	{8, 13},
+	{7, 13},
+	{6, 13},
+	{5, 13},
+	{4, 13},
+	{3, 12},
+	{3, 11},
+	{3, 10},
+	{4,  9},
+	{5,  9},
+	{6,  9},
+	{7,  9},
+	{8,  9},
+	{9,  9},
+	{8,  9},
+	{7,  9},
+	{6,  9},
+	{5,  9},
+	{4,  9},
+	{3, 10},
+	{3, 11},
+	{3, 12},
+	{4, 13},
+	{5, 14},
+	{5, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_48[] = {
+	{15,  9},
+	{14,  9},
+	{13, 10},
+	{13, 11},
+	{12, 12},
+	{11, 12},
+	{10, 12},
+	{ 9, 12},
+	{ 8, 12},
+	{ 7, 12},
+	{ 6, 12},
+	{ 5, 11},
+	{ 5, 10},
+	{ 5,  9},
+	{ 5,  8},
+	{ 5,  7},
+	{ 5,  6},
+	{ 5,  7},
+	{ 5,  8},
+	{ 5,  9},
+	{ 5, 10},
+	{ 5, 11},
+	{ 6, 12},
+	{ 7, 12},
+	{ 8, 12},
+	{ 9, 12},
+	{10, 12},
+	{11, 12},
+	{12, 12},
+	{13, 11},
+	{13, 10},
+	{13,  9},
+	{13,  8},
+	{13,  7},
+	{13,  6},
+	{14,  5},
+	{15,  5},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_49[] = {
+	{ 9,  0},
+	{ 9,  1},
+	{10,  2},
+	{11,  2},
+	{12,  3},
+	{12,  4},
+	{12,  5},
+	{12,  6},
+	{12,  7},
+	{12,  8},
+	{12,  9},
+	{11, 10},
+	{10, 10},
+	{ 9, 10},
+	{ 8, 10},
+	{ 7, 10},
+	{ 6, 10},
+	{ 7, 10},
+	{ 8, 10},
+	{ 9, 10},
+	{10, 10},
+	{11, 10},
+	{12,  9},
+	{12,  8},
+	{12,  7},
+	{12,  6},
+	{12,  5},
+	{12,  4},
+	{12,  3},
+	{11,  2},
+	{10,  2},
+	{ 9,  2},
+	{ 8,  2},
+	{ 7,  2},
+	{ 6,  2},
+	{ 5,  1},
+	{ 5,  0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_50[] = {
+	{15,  9},
+	{14,  9},
+	{13, 10},
+	{13, 11},
+	{12, 12},
+	{11, 12},
+	{10, 12},
+	{ 9, 11},
+	{ 9, 10},
+	{ 9,  9},
+	{ 9,  8},
+	{ 9,  7},
+	{ 9,  6},
+	{ 9,  7},
+	{ 9,  8},
+	{ 9,  9},
+	{ 9, 10},
+	{ 9, 11},
+	{10, 12},
+	{11, 12},
+	{12, 12},
+	{13, 11},
+	{13, 10},
+	{13,  9},
+	{13,  8},
+	{13,  7},
+	{13,  6},
+	{14,  5},
+	{15,  5},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_51[] = {
+	{ 9, 0},
+	{ 9, 1},
+	{10, 2},
+	{11, 2},
+	{12, 3},
+	{12, 4},
+	{12, 5},
+	{11, 6},
+	{10, 6},
+	{ 9, 6},
+	{ 8, 6},
+	{ 7, 6},
+	{ 6, 6},
+	{ 7, 6},
+	{ 8, 6},
+	{ 9, 6},
+	{10, 6},
+	{11, 6},
+	{12, 5},
+	{12, 4},
+	{12, 3},
+	{11, 2},
+	{10, 2},
+	{ 9, 2},
+	{ 8, 2},
+	{ 7, 2},
+	{ 6, 2},
+	{ 5, 1},
+	{ 5, 0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_56[] = {
+	{ 0, 5},
+	{ 1, 5},
+	{ 2, 4},
+	{ 3, 3},
+	{ 4, 3},
+	{ 5, 3},
+	{ 6, 3},
+	{ 7, 3},
+	{ 8, 3},
+	{ 9, 3},
+	{10, 4},
+	{10, 5},
+	{10, 6},
+	{10, 7},
+	{10, 8},
+	{10, 9},
+	{10, 8},
+	{10, 7},
+	{10, 6},
+	{10, 5},
+	{10, 4},
+	{ 9, 3},
+	{ 8, 3},
+	{ 7, 3},
+	{ 6, 3},
+	{ 5, 3},
+	{ 4, 3},
+	{ 3, 3},
+	{ 2, 4},
+	{ 2, 5},
+	{ 2, 6},
+	{ 2, 7},
+	{ 2, 8},
+	{ 1, 9},
+	{ 0, 9},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_57[] = {
+	{5, 15},
+	{5, 14},
+	{4, 13},
+	{3, 12},
+	{3, 11},
+	{3, 10},
+	{3,  9},
+	{3,  8},
+	{3,  7},
+	{3,  6},
+	{4,  5},
+	{5,  5},
+	{6,  5},
+	{7,  5},
+	{8,  5},
+	{9,  5},
+	{8,  5},
+	{7,  5},
+	{6,  5},
+	{5,  5},
+	{4,  5},
+	{3,  6},
+	{3,  7},
+	{3,  8},
+	{3,  9},
+	{3, 10},
+	{3, 11},
+	{3, 12},
+	{4, 13},
+	{5, 13},
+	{6, 13},
+	{7, 13},
+	{8, 13},
+	{9, 14},
+	{9, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_58[] = {
+	{0, 5},
+	{1, 5},
+	{2, 4},
+	{3, 3},
+	{4, 3},
+	{5, 3},
+	{6, 4},
+	{6, 5},
+	{6, 6},
+	{6, 7},
+	{6, 8},
+	{6, 9},
+	{6, 8},
+	{6, 7},
+	{6, 6},
+	{6, 5},
+	{6, 4},
+	{5, 3},
+	{4, 3},
+	{3, 3},
+	{2, 4},
+	{2, 5},
+	{2, 6},
+	{2, 7},
+	{2, 8},
+	{1, 9},
+	{0, 9},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_drive_data_59[] = {
+	{5, 15},
+	{5, 14},
+	{4, 13},
+	{3, 12},
+	{3, 11},
+	{3, 10},
+	{4,  9},
+	{5,  9},
+	{6,  9},
+	{7,  9},
+	{8,  9},
+	{9,  9},
+	{8,  9},
+	{7,  9},
+	{6,  9},
+	{5,  9},
+	{4,  9},
+	{3, 10},
+	{3, 11},
+	{3, 12},
+	{4, 13},
+	{5, 13},
+	{6, 13},
+	{7, 13},
+	{8, 13},
+	{9, 14},
+	{9, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+
+static const RoadDriveEntry * const _road_road_drive_data[] = {
+	_roadveh_drive_data_0,
+	_roadveh_drive_data_1,
+	_roadveh_drive_data_2,
+	_roadveh_drive_data_3,
+	_roadveh_drive_data_4,
+	_roadveh_drive_data_5,
+	_roadveh_drive_data_6,
+	_roadveh_drive_data_7,
+	_roadveh_drive_data_8,
+	_roadveh_drive_data_9,
+	_roadveh_drive_data_10,
+	_roadveh_drive_data_11,
+	_roadveh_drive_data_12,
+	_roadveh_drive_data_13,
+	_roadveh_drive_data_14,
+	_roadveh_drive_data_15,
+	_roadveh_drive_data_16,
+	_roadveh_drive_data_17,
+	_roadveh_drive_data_18,
+	_roadveh_drive_data_19,
+	_roadveh_drive_data_20,
+	_roadveh_drive_data_21,
+	_roadveh_drive_data_22,
+	_roadveh_drive_data_23,
+	_roadveh_drive_data_24,
+	_roadveh_drive_data_25,
+	_roadveh_drive_data_26,
+	_roadveh_drive_data_27,
+	_roadveh_drive_data_28,
+	_roadveh_drive_data_29,
+	_roadveh_drive_data_30,
+	_roadveh_drive_data_31,
+	_roadveh_drive_data_32,
+	_roadveh_drive_data_33,
+	_roadveh_drive_data_34,
+	_roadveh_drive_data_35,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	_roadveh_drive_data_40,
+	_roadveh_drive_data_41,
+	_roadveh_drive_data_42,
+	_roadveh_drive_data_43,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	_roadveh_drive_data_48,
+	_roadveh_drive_data_49,
+	_roadveh_drive_data_50,
+	_roadveh_drive_data_51,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	_roadveh_drive_data_56,
+	_roadveh_drive_data_57,
+	_roadveh_drive_data_58,
+	_roadveh_drive_data_59,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_ne_0[] = {
+	{15, 5},
+	{14, 5},
+	{13, 5},
+	{12, 5},
+	{11, 5},
+	{10, 5},
+	{ 9, 5},
+	{ 8, 5},
+	{ 7, 5},
+	{ 6, 5},
+	{ 5, 5},
+	{ 4, 5},
+	{ 3, 5},
+	{ 2, 5},
+	{ 1, 5},
+	{ 0, 5},
+	{ 0, 6},
+	{ 0, 7},
+	{ 0, 8},
+	{ 0, 9},
+	{RDE_TURNED | DIAGDIR_SW, 0},
+	{ 1, 9},
+	{ 2, 9},
+	{ 3, 9},
+	{ 4, 9},
+	{ 5, 9},
+	{ 6, 9},
+	{ 7, 9},
+	{ 8, 9},
+	{ 9, 9},
+	{10, 9},
+	{11, 9},
+	{12, 9},
+	{13, 9},
+	{14, 9},
+	{15, 9},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_ne_1[] = {
+	{15, 9},
+	{14, 9},
+	{13, 9},
+	{12, 9},
+	{11, 9},
+	{10, 9},
+	{ 9, 9},
+	{ 8, 9},
+	{ 7, 9},
+	{ 6, 9},
+	{ 5, 9},
+	{ 4, 9},
+	{ 3, 9},
+	{ 2, 9},
+	{ 1, 9},
+	{ 0, 9},
+	{ 0, 8},
+	{ 0, 7},
+	{ 0, 6},
+	{ 0, 5},
+	{RDE_TURNED | DIAGDIR_SW, 0},
+	{ 1, 5},
+	{ 2, 5},
+	{ 3, 5},
+	{ 4, 5},
+	{ 5, 5},
+	{ 6, 5},
+	{ 7, 5},
+	{ 8, 5},
+	{ 9, 5},
+	{10, 5},
+	{11, 5},
+	{12, 5},
+	{13, 5},
+	{14, 5},
+	{15, 5},
+	{RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_se_0[] = {
+	{5,  0},
+	{5,  1},
+	{5,  2},
+	{5,  3},
+	{5,  4},
+	{5,  5},
+	{5,  6},
+	{5,  7},
+	{5,  8},
+	{5,  9},
+	{5, 10},
+	{5, 11},
+	{5, 12},
+	{5, 13},
+	{5, 14},
+	{5, 15},
+	{6, 15},
+	{7, 15},
+	{8, 15},
+	{9, 15},
+	{RDE_TURNED | DIAGDIR_NW, 0},
+	{9, 14},
+	{9, 13},
+	{9, 12},
+	{9, 11},
+	{9, 10},
+	{9,  9},
+	{9,  8},
+	{9,  7},
+	{9,  6},
+	{9,  5},
+	{9,  4},
+	{9,  3},
+	{9,  2},
+	{9,  1},
+	{9,  0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_se_1[] = {
+	{9,  0},
+	{9,  1},
+	{9,  2},
+	{9,  3},
+	{9,  4},
+	{9,  5},
+	{9,  6},
+	{9,  7},
+	{9,  8},
+	{9,  9},
+	{9, 10},
+	{9, 11},
+	{9, 12},
+	{9, 13},
+	{9, 14},
+	{9, 15},
+	{8, 15},
+	{7, 15},
+	{6, 15},
+	{5, 15},
+	{RDE_TURNED | DIAGDIR_NW, 0},
+	{5, 14},
+	{5, 13},
+	{5, 12},
+	{5, 11},
+	{5, 10},
+	{5,  9},
+	{5,  8},
+	{5,  7},
+	{5,  6},
+	{5,  5},
+	{5,  4},
+	{5,  3},
+	{5,  2},
+	{5,  1},
+	{5,  0},
+	{RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_sw_0[] = {
+	{ 0, 9},
+	{ 1, 9},
+	{ 2, 9},
+	{ 3, 9},
+	{ 4, 9},
+	{ 5, 9},
+	{ 6, 9},
+	{ 7, 9},
+	{ 8, 9},
+	{ 9, 9},
+	{10, 9},
+	{11, 9},
+	{12, 9},
+	{13, 9},
+	{14, 9},
+	{15, 9},
+	{15, 8},
+	{15, 7},
+	{15, 6},
+	{15, 5},
+	{RDE_TURNED | DIAGDIR_SW, 0},
+	{14, 5},
+	{13, 5},
+	{12, 5},
+	{11, 5},
+	{10, 5},
+	{ 9, 5},
+	{ 8, 5},
+	{ 7, 5},
+	{ 6, 5},
+	{ 5, 5},
+	{ 4, 5},
+	{ 3, 5},
+	{ 2, 5},
+	{ 1, 5},
+	{ 0, 5},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_tram_turn_sw_1[] = {
+	{ 0, 5},
+	{ 1, 5},
+	{ 2, 5},
+	{ 3, 5},
+	{ 4, 5},
+	{ 5, 5},
+	{ 6, 5},
+	{ 7, 5},
+	{ 8, 5},
+	{ 9, 5},
+	{10, 5},
+	{11, 5},
+	{12, 5},
+	{13, 5},
+	{14, 5},
+	{15, 5},
+	{15, 6},
+	{15, 7},
+	{15, 8},
+	{15, 9},
+	{RDE_TURNED | DIAGDIR_NE, 0},
+	{14, 9},
+	{13, 9},
+	{12, 9},
+	{11, 9},
+	{10, 9},
+	{ 9, 9},
+	{ 8, 9},
+	{ 7, 9},
+	{ 6, 9},
+	{ 5, 9},
+	{ 4, 9},
+	{ 3, 9},
+	{ 2, 9},
+	{ 1, 9},
+	{ 0, 9},
+	{RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_nw_0[] = {
+	{9, 15},
+	{9, 14},
+	{9, 13},
+	{9, 12},
+	{9, 11},
+	{9, 10},
+	{9,  9},
+	{9,  8},
+	{9,  7},
+	{9,  6},
+	{9,  5},
+	{9,  4},
+	{9,  3},
+	{9,  2},
+	{9,  1},
+	{9,  0},
+	{8,  0},
+	{7,  0},
+	{6,  0},
+	{5,  0},
+	{RDE_TURNED | DIAGDIR_SE, 0},
+	{5,  1},
+	{5,  2},
+	{5,  3},
+	{5,  4},
+	{5,  5},
+	{5,  6},
+	{5,  7},
+	{5,  8},
+	{5,  9},
+	{5, 10},
+	{5, 11},
+	{5, 12},
+	{5, 13},
+	{5, 14},
+	{5, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_tram_turn_nw_1[] = {
+	{5, 15},
+	{5, 14},
+	{5, 13},
+	{5, 12},
+	{5, 11},
+	{5, 10},
+	{5,  9},
+	{5,  8},
+	{5,  7},
+	{5,  6},
+	{5,  5},
+	{5,  4},
+	{5,  3},
+	{5,  2},
+	{5,  1},
+	{5,  0},
+	{6,  0},
+	{7,  0},
+	{8,  0},
+	{9,  0},
+	{RDE_TURNED | DIAGDIR_SE, 0},
+	{9,  1},
+	{9,  2},
+	{9,  3},
+	{9,  4},
+	{9,  5},
+	{9,  6},
+	{9,  7},
+	{9,  8},
+	{9,  9},
+	{9, 10},
+	{9, 11},
+	{9, 12},
+	{9, 13},
+	{9, 14},
+	{9, 15},
+	{RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+
+static const RoadDriveEntry * const _road_tram_drive_data[] = {
+	_roadveh_drive_data_0,
+	_roadveh_drive_data_1,
+	_roadveh_drive_data_2,
+	_roadveh_drive_data_3,
+	_roadveh_drive_data_4,
+	_roadveh_drive_data_5,
+	_roadveh_tram_turn_ne_0,
+	_roadveh_tram_turn_se_0,
+	_roadveh_drive_data_8,
+	_roadveh_drive_data_9,
+	_roadveh_drive_data_10,
+	_roadveh_drive_data_11,
+	_roadveh_drive_data_12,
+	_roadveh_drive_data_13,
+	_roadveh_tram_turn_sw_0,
+	_roadveh_tram_turn_nw_0,
+	_roadveh_drive_data_16,
+	_roadveh_drive_data_17,
+	_roadveh_drive_data_18,
+	_roadveh_drive_data_19,
+	_roadveh_drive_data_20,
+	_roadveh_drive_data_21,
+	_roadveh_tram_turn_ne_1,
+	_roadveh_tram_turn_se_1,
+	_roadveh_drive_data_24,
+	_roadveh_drive_data_25,
+	_roadveh_drive_data_26,
+	_roadveh_drive_data_27,
+	_roadveh_drive_data_28,
+	_roadveh_drive_data_29,
+	_roadveh_tram_turn_sw_1,
+	_roadveh_tram_turn_nw_1,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+};
+
+static const RoadDriveEntry * const * const _road_drive_data[2] = {
+	_road_road_drive_data,
+	_road_tram_drive_data,
+};
--- a/src/table/sprites.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/table/sprites.h	Fri Feb 22 00:25:54 2008 +0000
@@ -263,6 +263,8 @@
 	SPR_MONO_SNOW_OFFSET        = 26,
 	SPR_MGLV_SNOW_OFFSET        = 26,
 
+	SPR_ORIGINAL_SIGNALS_BASE   = 1275,
+
 	SPR_RAIL_SINGLE_Y           = 1005,
 	SPR_RAIL_SINGLE_X           = 1006,
 	SPR_RAIL_SINGLE_NORTH       = 1007,
--- a/src/table/station_land.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/table/station_land.h	Fri Feb 22 00:25:54 2008 +0000
@@ -1,426 +1,428 @@
 /* $Id$ */
 
-#define TILE_SEQ_END()	{ (byte)0x80, 0, 0, 0, 0, 0, 0, 0 }
+#define TILE_SEQ_LINE(dx, dy, dz, sx, sy, sz, img) { dx, dy, dz, sx, sy, sz, {img, PAL_NONE} },
+#define TILE_SEQ_LINE_PAL(dx, dy, dz, sx, sy, sz, img, pal) { dx, dy, dz, sx, sy, sz, {img, pal} },
+#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
 
 static const DrawTileSeqStruct _station_display_nothing[] = {
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_0[] = {
-	{  0,  0,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_REAR  | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 11,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_REAR  | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 11,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_FRONT | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_1[] = {
-	{  0,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_REAR  | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 11,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_REAR  | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(11,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_2[] = {
-	{  0,  0,  0, 16,  5,  2, SPR_RAIL_PLATFORM_BUILDING_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 11,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_FRONT    | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0, 16,  5,  2, SPR_RAIL_PLATFORM_BUILDING_X | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 11,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_FRONT    | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_3[] = {
-	{  0,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_BUILDING_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 11,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_FRONT    | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_BUILDING_Y | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(11,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_FRONT    | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_4[] = {
-	{  0,  0,  0, 16,  5,  7, SPR_RAIL_PLATFORM_PILLARS_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 11,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_FRONT        | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0, (byte)0x80, 0,  0,  0, SPR_RAIL_ROOF_GLASS_X_TILE_A     | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+	TILE_SEQ_LINE( 0,  0,  0, 16,  5,  7, SPR_RAIL_PLATFORM_PILLARS_X_REAR | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 11,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_FRONT        | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE_PAL( 0,  0, (byte)0x80, 0,  0,  0, SPR_RAIL_ROOF_GLASS_X_TILE_A     | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_5[] = {
-	{  0,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_PILLARS_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 11,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_FRONT        | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0, (byte)0x80, 0,  0,  0, SPR_RAIL_ROOF_GLASS_Y_TILE_A     | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+	TILE_SEQ_LINE( 0,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_PILLARS_Y_REAR | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(11,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_FRONT        | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE_PAL( 0,  0, (byte)0x80, 0,  0,  0, SPR_RAIL_ROOF_GLASS_Y_TILE_A     | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_6[] = {
-	{  0,  0,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_REAR          | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 11,  0, 16,  5,  2, SPR_RAIL_PLATFORM_PILLARS_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_B  | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0, (byte)0x80, 0,  0,  0, SPR_RAIL_ROOF_GLASS_X_TILE_B      | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+	TILE_SEQ_LINE( 0,  0,  0, 16,  5,  2, SPR_RAIL_PLATFORM_X_REAR          | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 11,  0, 16,  5,  2, SPR_RAIL_PLATFORM_PILLARS_X_FRONT | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_B  | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE_PAL( 0,  0, (byte)0x80, 0,  0,  0, SPR_RAIL_ROOF_GLASS_X_TILE_B      | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_7[] = {
-	{  0,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_REAR          | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 11,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_PILLARS_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_B  | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0, (byte)0x80, 0,  0,  0, SPR_RAIL_ROOF_GLASS_Y_TILE_B      | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+	TILE_SEQ_LINE( 0,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_Y_REAR          | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(11,  0,  0,  5, 16,  2, SPR_RAIL_PLATFORM_PILLARS_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_B  | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE_PAL( 0,  0, (byte)0x80, 0,  0,  0, SPR_RAIL_ROOF_GLASS_Y_TILE_B      | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_9[] = {
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences north
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences north
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_10[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_21[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_22[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_23[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_24[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_25[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_26[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_27[] = {
-	{  2,  0,  0, 11, 16, 40, SPR_AIRPORT_TERMINAL_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 2,  0,  0, 11, 16, 40, SPR_AIRPORT_TERMINAL_A | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_28[] = {
-	{  3,  3,  0, 10, 10, 60, SPR_AIRPORT_TOWER | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 3,  3,  0, 10, 10, 60, SPR_AIRPORT_TOWER | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_29[] = {
-	{  0,  1,  0, 14, 14, 30, SPR_AIRPORT_CONCOURSE | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  1,  0, 14, 14, 30, SPR_AIRPORT_CONCOURSE | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_30[] = {
-	{  3,  3,  0, 10, 11, 35, SPR_AIRPORT_TERMINAL_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 3,  3,  0, 10, 11, 35, SPR_AIRPORT_TERMINAL_B | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_31[] = {
-	{  0,  3,  0, 16, 11, 40, SPR_AIRPORT_TERMINAL_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  3,  0, 16, 11, 40, SPR_AIRPORT_TERMINAL_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_32[] = {
-	{ 14,  0,  0,  2, 16, 28, SPR_AIRPORT_HANGAR_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0,  2, 16, 28, SPR_AIRPORT_HANGAR_REAR, PAL_NONE },
+	TILE_SEQ_LINE(14,  0,  0,  2, 16, 28, SPR_AIRPORT_HANGAR_FRONT | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0,  2, 16, 28, SPR_AIRPORT_HANGAR_REAR)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_33[] = {
-	{  7, 11,  0,  3,  3, 14, SPR_AIRPORT_JETWAY_1, PAL_NONE },
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7, 11,  0,  3,  3, 14, SPR_AIRPORT_JETWAY_1)
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_34[] = {
-	{  2,  7,  0,  3,  3, 14, SPR_AIRPORT_JETWAY_2, PAL_NONE },
+	TILE_SEQ_LINE( 2,  7,  0,  3,  3, 14, SPR_AIRPORT_JETWAY_2)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_35[] = {
-	{  3,  2,  0,  3,  3, 14, SPR_AIRPORT_JETWAY_3, PAL_NONE },
+	TILE_SEQ_LINE( 3,  2,  0,  3,  3, 14, SPR_AIRPORT_JETWAY_3)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_36[] = {
-	{  0,  8,  0, 14,  3, 14, SPR_AIRPORT_PASSENGER_TUNNEL, PAL_NONE },
+	TILE_SEQ_LINE( 0,  8,  0, 14,  3, 14, SPR_AIRPORT_PASSENGER_TUNNEL)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_38[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_39[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_1, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_1)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_40[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_2, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_2)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_41[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_3, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_3)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_42[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_4, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_4)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_43[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_5, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_5)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_44[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_6, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_6)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_45[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_7, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_7)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_46[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_8, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_8)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_47[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_9, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_9)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_48[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_A, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_A)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_49[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_B, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_B)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_50[] = {
-	{  7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_C, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_C)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_51[] = {
-	{  7,  7,  0,  2,  2, 70, SPR_UNMOVABLE_TRANSMITTER, PAL_NONE },
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2, 70, SPR_UNMOVABLE_TRANSMITTER)
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_54[] = {
-	{  0,  0,  0, 15, 15, 30, SPR_AIRFIELD_TERM_C_BUILD | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0, 15, 15, 30, SPR_AIRFIELD_TERM_C_BUILD | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_55[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_58[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  4, 11,  0,  1,  1, 20, SPR_AIRFIELD_WIND_1 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 4, 11,  0,  1,  1, 20, SPR_AIRFIELD_WIND_1 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_59[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  4, 11,  0,  1,  1, 20, SPR_AIRFIELD_WIND_2 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 4, 11,  0,  1,  1, 20, SPR_AIRFIELD_WIND_2 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_60[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  4, 11,  0,  1,  1, 20, SPR_AIRFIELD_WIND_3 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 4, 11,  0,  1,  1, 20, SPR_AIRFIELD_WIND_3 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_61[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  4, 11,  0,  1,  1, 20, SPR_AIRFIELD_WIND_4 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 4, 11,  0,  1,  1, 20, SPR_AIRFIELD_WIND_4 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_62[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_63[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_64[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_65[] = {
-	{ 14,  0,  0,  2, 16, 28, SPR_AIRFIELD_HANGAR_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0,  2, 16, 28, SPR_AIRFIELD_HANGAR_REAR, PAL_NONE },
+	TILE_SEQ_LINE(14,  0,  0,  2, 16, 28, SPR_AIRFIELD_HANGAR_FRONT | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0,  2, 16, 28, SPR_AIRFIELD_HANGAR_REAR)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_66[] = {
-	{  0,  0,  0, 16, 16, 60, SPR_HELIPORT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0, 16, 16, 60, SPR_HELIPORT | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_67[] = {
-	{  0, 15,  0, 13,  1, 10, SPR_TRUCK_STOP_NE_BUILD_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 13,  0,  0,  3, 16, 10, SPR_TRUCK_STOP_NE_BUILD_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  2,  0,  0, 11,  1, 10, SPR_TRUCK_STOP_NE_BUILD_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0, 15,  0, 13,  1, 10, SPR_TRUCK_STOP_NE_BUILD_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(13,  0,  0,  3, 16, 10, SPR_TRUCK_STOP_NE_BUILD_B | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 2,  0,  0, 11,  1, 10, SPR_TRUCK_STOP_NE_BUILD_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_68[] = {
-	{ 15,  3,  0,  1, 13, 10, SPR_TRUCK_STOP_SE_BUILD_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0, 16,  3, 10, SPR_TRUCK_STOP_SE_BUILD_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  3,  0,  1, 11, 10, SPR_TRUCK_STOP_SE_BUILD_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(15,  3,  0,  1, 13, 10, SPR_TRUCK_STOP_SE_BUILD_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0, 16,  3, 10, SPR_TRUCK_STOP_SE_BUILD_B | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  3,  0,  1, 11, 10, SPR_TRUCK_STOP_SE_BUILD_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_69[] = {
-	{  3,  0,  0, 13,  1, 10, SPR_TRUCK_STOP_SW_BUILD_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0,  3, 16, 10, SPR_TRUCK_STOP_SW_BUILD_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  3, 15,  0, 11,  1, 10, SPR_TRUCK_STOP_SW_BUILD_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 3,  0,  0, 13,  1, 10, SPR_TRUCK_STOP_SW_BUILD_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0,  3, 16, 10, SPR_TRUCK_STOP_SW_BUILD_B | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 3, 15,  0, 11,  1, 10, SPR_TRUCK_STOP_SW_BUILD_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_70[] = {
-	{  0,  0,  0,  1, 13, 10, SPR_TRUCK_STOP_NW_BUILD_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 13,  0, 16,  3, 10, SPR_TRUCK_STOP_NW_BUILD_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 15,  2,  0,  1, 11, 10, SPR_TRUCK_STOP_NW_BUILD_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  1, 13, 10, SPR_TRUCK_STOP_NW_BUILD_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 13,  0, 16,  3, 10, SPR_TRUCK_STOP_NW_BUILD_B | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(15,  2,  0,  1, 11, 10, SPR_TRUCK_STOP_NW_BUILD_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_71[] = {
-	{  2,  0,  0, 11,  1, 10, SPR_BUS_STOP_NE_BUILD_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 13,  0,  0,  3, 16, 10, SPR_BUS_STOP_NE_BUILD_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 13,  0, 13,  3, 10, SPR_BUS_STOP_NE_BUILD_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 2,  0,  0, 11,  1, 10, SPR_BUS_STOP_NE_BUILD_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(13,  0,  0,  3, 16, 10, SPR_BUS_STOP_NE_BUILD_B | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 13,  0, 13,  3, 10, SPR_BUS_STOP_NE_BUILD_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_72[] = {
-	{  0,  3,  0,  1, 11, 10, SPR_BUS_STOP_SE_BUILD_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0, 16,  3, 10, SPR_BUS_STOP_SE_BUILD_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 13,  3,  0,  3, 13, 10, SPR_BUS_STOP_SE_BUILD_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  3,  0,  1, 11, 10, SPR_BUS_STOP_SE_BUILD_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0, 16,  3, 10, SPR_BUS_STOP_SE_BUILD_B | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(13,  3,  0,  3, 13, 10, SPR_BUS_STOP_SE_BUILD_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_73[] = {
-	{  3, 15,  0, 11,  1, 10, SPR_BUS_STOP_SW_BUILD_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0,  3, 16, 10, SPR_BUS_STOP_SW_BUILD_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  3,  0,  0, 13,  3, 10, SPR_BUS_STOP_SW_BUILD_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 3, 15,  0, 11,  1, 10, SPR_BUS_STOP_SW_BUILD_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0,  3, 16, 10, SPR_BUS_STOP_SW_BUILD_B | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 3,  0,  0, 13,  3, 10, SPR_BUS_STOP_SW_BUILD_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_74[] = {
-	{ 15,  2,  0,  1, 11, 10, SPR_BUS_STOP_NW_BUILD_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 13,  0, 16,  3, 10, SPR_BUS_STOP_NW_BUILD_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0,  3, 13, 10, SPR_BUS_STOP_NW_BUILD_C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(15,  2,  0,  1, 11, 10, SPR_BUS_STOP_NW_BUILD_A | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 13,  0, 16,  3, 10, SPR_BUS_STOP_NW_BUILD_B | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0,  3, 13, 10, SPR_BUS_STOP_NW_BUILD_C | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_76[] = {
-	{  0,  4,  0, 16,  8,  8, SPR_DOCK_SLOPE_NE, PAL_NONE },
+	TILE_SEQ_LINE( 0,  4,  0, 16,  8,  8, SPR_DOCK_SLOPE_NE)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_77[] = {
-	{  4,  0,  0,  8, 16,  8, SPR_DOCK_SLOPE_SE, PAL_NONE },
+	TILE_SEQ_LINE( 4,  0,  0,  8, 16,  8, SPR_DOCK_SLOPE_SE)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_78[] = {
-	{  0,  4,  0, 16,  8,  8, SPR_DOCK_SLOPE_SW, PAL_NONE },
+	TILE_SEQ_LINE( 0,  4,  0, 16,  8,  8, SPR_DOCK_SLOPE_SW)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_79[] = {
-	{  4,  0,  0,  8, 16,  8, SPR_DOCK_SLOPE_NW, PAL_NONE },
+	TILE_SEQ_LINE( 4,  0,  0,  8, 16,  8, SPR_DOCK_SLOPE_NW)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_80[] = {
-	{  0,  4,  0, 16,  8,  8, SPR_DOCK_FLAT_X, PAL_NONE },
+	TILE_SEQ_LINE( 0,  4,  0, 16,  8,  8, SPR_DOCK_FLAT_X)
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _station_display_datas_81[] = {
-	{  4,  0,  0,  8, 16,  8, SPR_DOCK_FLAT_Y, PAL_NONE },
+	TILE_SEQ_LINE( 4,  0,  0,  8, 16,  8, SPR_DOCK_FLAT_Y)
 	TILE_SEQ_END()
 };
 
 /* Buoy, which will _always_ drown under the ship */
 static const DrawTileSeqStruct _station_display_datas_82[] = {
-	{  4,  -1,  0,  0,  0,  0, SPR_IMG_BOUY, PAL_NONE },
+	TILE_SEQ_LINE( 4,  -1,  0,  0,  0,  0, SPR_IMG_BOUY)
 	TILE_SEQ_END()
 };
 
 // control tower with concrete underground and no fence
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_085[] = {
-	{  3,  3,  0, 10, 10, 60, SPR_AIRPORT_TOWER | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },  // control tower
+	TILE_SEQ_LINE( 3,  3,  0, 10, 10, 60, SPR_AIRPORT_TOWER | (1 << PALETTE_MODIFIER_COLOR))  // control tower
 	TILE_SEQ_END()
 };
 
 // new airportdepot, facing west
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_086[] = {
-	{ 14, 0,  0,  2, 16, 28, SPR_AIRFIELD_HANGAR_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 0,  0,  2, 16, 28, SPR_AIRFIELD_HANGAR_REAR, PAL_NONE },
+	TILE_SEQ_LINE(14, 0,  0,  2, 16, 28, SPR_AIRFIELD_HANGAR_FRONT | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 0,  0,  2, 16, 28, SPR_AIRFIELD_HANGAR_REAR)
 	TILE_SEQ_END()
 };
 
 // asphalt tile with fences in north
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_087[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // end of runway
 static const DrawTileSeqStruct _station_display_datas_088[] = {
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences
 	TILE_SEQ_END()
 };
 
 // runway tiles
 static const DrawTileSeqStruct _station_display_datas_089[] = {
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences
 	TILE_SEQ_END()
 };
 
@@ -428,85 +430,85 @@
 // concrete underground
 //BEGIN
 static const DrawTileSeqStruct _station_display_datas_090[] = {
-	{  7, 7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_1, PAL_NONE },   // turning radar
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },  //fences
+	TILE_SEQ_LINE( 7, 7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_1)   // turning radar
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))  //fences
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_091[] = {
-	{  7, 7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_2, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 7, 7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_2)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_092[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_3, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_3)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_093[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_4, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_4)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_094[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_5, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_5)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_095[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_6, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_6)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_096[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_7, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_7)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_097[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_8, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_8)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_098[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_9, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_9)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_099[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_A, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_A)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0100[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_B, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_B)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0101[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_C, PAL_NONE },
-	{ 15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_C)
+	TILE_SEQ_LINE(15, 0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 //END
@@ -515,85 +517,85 @@
 // concrete underground
 //BEGIN
 static const DrawTileSeqStruct _station_display_datas_0102[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_1, PAL_NONE },   // turning radar
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_1)   // turning radar
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0103[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_2, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_2)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0104[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_3, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_3)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0105[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_4, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_4)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0106[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_5, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_5)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0107[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_6, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_6)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0108[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_7, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_7)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0109[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_8, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_8)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0110[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_9, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_9)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0111[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_A, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_A)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0112[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_B, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_B)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0113[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_C, PAL_NONE },
-	{ 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_C)
+	TILE_SEQ_LINE(0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 //END
@@ -601,223 +603,223 @@
 // helipad for international airport
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0114[] = {
-	{ 10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences bottom
+	TILE_SEQ_LINE(10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences bottom
 	TILE_SEQ_END()
 };
 
 // helipad for commuter airport
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0115[] = {
-	{ 10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD, PAL_NONE },
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences left
+	TILE_SEQ_LINE(10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD)
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences left
 	TILE_SEQ_END()
 };
 
 // helipad for continental airport
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0116[] = {
-	{ 10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD, PAL_NONE },
+	TILE_SEQ_LINE(10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD)
 	TILE_SEQ_END()
 };
 
 // asphalt tile with fences in north and south
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0117[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // runway tiles with 2 corner fences
 static const DrawTileSeqStruct _station_display_datas_0118[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences north
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences north
 	TILE_SEQ_END()
 };
 
 // runway tiles with 2 corner fences
 static const DrawTileSeqStruct _station_display_datas_0119[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // runway tiles with 2 corner fences
 static const DrawTileSeqStruct _station_display_datas_0120[] = {
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences north
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences north
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
 	TILE_SEQ_END()
 };
 
 // runway tiles with 2 corner fences
 static const DrawTileSeqStruct _station_display_datas_0121[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // ======== new 2x2 helidepot ========
 // helipad tiles with 2 corner fences top+right
 static const DrawTileSeqStruct _station_display_datas_0122[] = {
-	{ 10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD, PAL_NONE },
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE(10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD)
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // tarmac tiles with 2 corner fences bottom+right
 static const DrawTileSeqStruct _station_display_datas_0123[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences north
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences north
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // helidepot office with concrete underground and no fence
 // concrete underground, fences top + left
 static const DrawTileSeqStruct _station_display_datas_0124[] = {
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences left
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
-	{  3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },  // helidepot office
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences left
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
+	TILE_SEQ_LINE( 3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR))  // helidepot office
 	TILE_SEQ_END()
 };
 
 // N/S runway plain
 static const DrawTileSeqStruct _station_display_datas_0125[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
 	TILE_SEQ_END()
 };
 
 // N/S runway end
 static const DrawTileSeqStruct _station_display_datas_0126[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
 	TILE_SEQ_END()
 };
 
 // N/S runway plain
 static const DrawTileSeqStruct _station_display_datas_0127[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences bottom
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences bottom
 	TILE_SEQ_END()
 };
 
 // N/S runway end
 static const DrawTileSeqStruct _station_display_datas_0128[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences bottom
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences bottom
 	TILE_SEQ_END()
 };
 
 // West facing hangar
 static const DrawTileSeqStruct _station_display_datas_0129[] = {
-	{ 14,  0,  0,  2, 16, 28, SPR_NEWHANGAR_W | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0,  2, 16, 28, SPR_NEWHANGAR_W_WALL, PAL_NONE },
+	TILE_SEQ_LINE(14,  0,  0,  2, 16, 28, SPR_NEWHANGAR_W | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0,  2, 16, 28, SPR_NEWHANGAR_W_WALL)
 	TILE_SEQ_END()
 };
 
 // North facing hangar
 static const DrawTileSeqStruct _station_display_datas_0130[] = {
-	{ 14,  0,  0,  2, 16, 28, SPR_NEWHANGAR_N | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(14,  0,  0,  2, 16, 28, SPR_NEWHANGAR_N | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // East facing hangar
 static const DrawTileSeqStruct _station_display_datas_0131[] = {
-	{ 14,  0,  0,  2, 16, 28, SPR_NEWHANGAR_E | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(14,  0,  0,  2, 16, 28, SPR_NEWHANGAR_E | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // helipad for district airport NS
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0132[] = {
-	{ 10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences bottom
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences right
+	TILE_SEQ_LINE(10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences bottom
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences right
 	TILE_SEQ_END()
 };
 
 // helipad for district airport NS
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0133[] = {
-	{ 10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE(10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // helidepot office with concrete underground and fence north
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0134[] = {
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences north
-	{  3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },  // helidepot office
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences north
+	TILE_SEQ_LINE( 3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR))  // helidepot office
 	TILE_SEQ_END()
 };
 
 // helidepot office with concrete underground and fence east
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0135[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
-	{  3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },  // helidepot office
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
+	TILE_SEQ_LINE( 3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR))  // helidepot office
 	TILE_SEQ_END()
 };
 
 // helidepot office with concrete underground and fence west
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0136[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
-	{  3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },  // helidepot office
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
+	TILE_SEQ_LINE( 3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR))  // helidepot office
 	TILE_SEQ_END()
 };
 
 // helidepot office with concrete underground and fence south
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0137[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
-	{  3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },  // helidepot office
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
+	TILE_SEQ_LINE( 3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR))  // helidepot office
 	TILE_SEQ_END()
 };
 
 // terminal with fence to east
 static const DrawTileSeqStruct _station_display_datas_0138[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
 	TILE_SEQ_END()
 };
 
 // terminal with fence to south
 static const DrawTileSeqStruct _station_display_datas_0139[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // terminal with fence to north
 static const DrawTileSeqStruct _station_display_datas_0140[] = {
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
 	TILE_SEQ_END()
 };
 
 // concrete with fence to east
 static const DrawTileSeqStruct _station_display_datas_0141[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
 	TILE_SEQ_END()
 };
 
 // concrete with fence to south
 static const DrawTileSeqStruct _station_display_datas_0142[] = {
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // helipad for district airport EW
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0143[] = {
-	{ 10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences north
+	TILE_SEQ_LINE(10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences north
 	TILE_SEQ_END()
 };
 
 // helipad for district airport EW
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0144[] = {
-	{ 10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
+	TILE_SEQ_LINE(10,  6,  0,  0,  0,  0, SPR_AIRPORT_HELIPAD)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
 	TILE_SEQ_END()
 };
 
@@ -825,85 +827,85 @@
 // concrete underground
 //BEGIN
 static const DrawTileSeqStruct _station_display_datas_0145[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_1, PAL_NONE },   // turning radar
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_1)   // turning radar
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0146[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_2, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_2)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0147[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_3, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_3)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0148[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_4, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_4)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0149[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_5, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_5)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0150[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_6, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_6)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0151[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_7, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_7)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0152[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_8, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_8)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0153[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_9, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_9)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0154[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_A, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_A)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0155[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_B, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_B)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0156[] = {
-	{ 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_C, PAL_NONE },
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 7,  7,  0,  2,  2,  8, SPR_AIRPORT_RADAR_C)
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 //END
@@ -911,275 +913,283 @@
 // helipad for helistation
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0157[] = {
-	{  0,  1,  2,  0,  0,  0, SPR_NEWHELIPAD, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 0,  1,  2,  0,  0,  0, SPR_NEWHELIPAD)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // helipad for helistation
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0158[] = {
-	{  0,  1,  2,  0,  0,  0, SPR_NEWHELIPAD, PAL_NONE },
-	{ 15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences west
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences north
+	TILE_SEQ_LINE( 0,  1,  2,  0,  0,  0, SPR_NEWHELIPAD)
+	TILE_SEQ_LINE(15,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences west
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences north
 	TILE_SEQ_END()
 };
 
 // helipad for helistation
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0159[] = {
-	{  0,  1,  2,  0,  0,  0, SPR_NEWHELIPAD, PAL_NONE },
-	{  0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences north
+	TILE_SEQ_LINE( 0,  1,  2,  0,  0,  0, SPR_NEWHELIPAD)
+	TILE_SEQ_LINE( 0,  0,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences north
 	TILE_SEQ_END()
 };
 
 // helidepot office with concrete underground - no fence
 static const DrawTileSeqStruct _station_display_datas_0160[] = {
-	{  3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },  // helidepot office
+	TILE_SEQ_LINE( 3,  3,  0, 10, 10, 60, SPR_AIRPORT_HELIDEPOT_OFFICE | (1 << PALETTE_MODIFIER_COLOR))  // helidepot office
 	TILE_SEQ_END()
 };
 
 // concrete underground
 static const DrawTileSeqStruct _station_display_datas_0161[] = {
-	{  0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences east
-	{  0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, // fences south
+	TILE_SEQ_LINE( 0,  0,  0,  1, 16,  6, SPR_AIRPORT_FENCE_Y | (1 << PALETTE_MODIFIER_COLOR)) // fences east
+	TILE_SEQ_LINE( 0, 15,  0, 16,  1,  6, SPR_AIRPORT_FENCE_X | (1 << PALETTE_MODIFIER_COLOR)) // fences south
 	TILE_SEQ_END()
 };
 
 // half grass half SPR_AIRPORT_APRON
 static const DrawTileSeqStruct _station_display_datas_0162[] = {
-	{ 0,  0,  0,  0,  0,  0, SPR_GRASS_LEFT, PAL_NONE },
+	TILE_SEQ_LINE(0,  0,  0,  0,  0,  0, SPR_GRASS_LEFT)
 	TILE_SEQ_END()
 };
 
 // half grass half SPR_AIRPORT_APRON
 static const DrawTileSeqStruct _station_display_datas_0163[] = {
-	{ 0,  0,  0,  0,  0,  0, SPR_GRASS_RIGHT, PAL_NONE },
+	TILE_SEQ_LINE(0,  0,  0,  0,  0,  0, SPR_GRASS_RIGHT)
 	TILE_SEQ_END()
 };
 
 // drive-through truck stop X
 static const DrawTileSeqStruct _station_display_datas_0168[] = {
-	{  0,  0,  0,  16,  3, 16, SPR_TRUCK_STOP_DT_X_W | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 13,  0,  16,  3, 16, SPR_TRUCK_STOP_DT_X_E | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  16,  3, 16, SPR_TRUCK_STOP_DT_X_W | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 13,  0,  16,  3, 16, SPR_TRUCK_STOP_DT_X_E | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // drive-through truck stop Y
 static const DrawTileSeqStruct _station_display_datas_0169[] = {
-	{ 13,  0,  0,  3, 16, 16, SPR_TRUCK_STOP_DT_Y_W | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0,  3, 16, 16, SPR_TRUCK_STOP_DT_Y_E | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(13,  0,  0,  3, 16, 16, SPR_TRUCK_STOP_DT_Y_W | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0,  3, 16, 16, SPR_TRUCK_STOP_DT_Y_E | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // drive-through bus stop X
 static const DrawTileSeqStruct _station_display_datas_0170[] = {
-	{  0,  0,  0,  16,  3, 16, SPR_BUS_STOP_DT_X_W | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0, 13,  0,  16,  3, 16, SPR_BUS_STOP_DT_X_E | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE( 0,  0,  0,  16,  3, 16, SPR_BUS_STOP_DT_X_W | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0, 13,  0,  16,  3, 16, SPR_BUS_STOP_DT_X_E | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 // drive-through bus stop Y
 static const DrawTileSeqStruct _station_display_datas_0171[] = {
-	{ 13,  0,  0,  3,  16, 16, SPR_BUS_STOP_DT_Y_W | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
-	{  0,  0,  0,  3,  16, 16, SPR_BUS_STOP_DT_Y_E | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(13,  0,  0,  3,  16, 16, SPR_BUS_STOP_DT_Y_W | (1 << PALETTE_MODIFIER_COLOR))
+	TILE_SEQ_LINE( 0,  0,  0,  3,  16, 16, SPR_BUS_STOP_DT_Y_E | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
+#undef TILE_SEQ_END
+#undef TILE_SEQ_LINE
+#undef TILE_SEQ_LINE_PAL
+
+#define TILE_SPRITE_LINE(img, dtss) { {img, PAL_NONE}, dtss },
+
 static const DrawTileSprites _station_display_datas_rail[] = {
-	{ SPR_RAIL_TRACK_X,               PAL_NONE, _station_display_datas_0 },
-	{ SPR_RAIL_TRACK_Y,               PAL_NONE, _station_display_datas_1 },
-	{ SPR_RAIL_TRACK_X,               PAL_NONE, _station_display_datas_2 },
-	{ SPR_RAIL_TRACK_Y,               PAL_NONE, _station_display_datas_3 },
-	{ SPR_RAIL_TRACK_X,               PAL_NONE, _station_display_datas_4 },
-	{ SPR_RAIL_TRACK_Y,               PAL_NONE, _station_display_datas_5 },
-	{ SPR_RAIL_TRACK_X,               PAL_NONE, _station_display_datas_6 },
-	{ SPR_RAIL_TRACK_Y,               PAL_NONE, _station_display_datas_7 },
+	TILE_SPRITE_LINE(SPR_RAIL_TRACK_X,               _station_display_datas_0)
+	TILE_SPRITE_LINE(SPR_RAIL_TRACK_Y,               _station_display_datas_1)
+	TILE_SPRITE_LINE(SPR_RAIL_TRACK_X,               _station_display_datas_2)
+	TILE_SPRITE_LINE(SPR_RAIL_TRACK_Y,               _station_display_datas_3)
+	TILE_SPRITE_LINE(SPR_RAIL_TRACK_X,               _station_display_datas_4)
+	TILE_SPRITE_LINE(SPR_RAIL_TRACK_Y,               _station_display_datas_5)
+	TILE_SPRITE_LINE(SPR_RAIL_TRACK_X,               _station_display_datas_6)
+	TILE_SPRITE_LINE(SPR_RAIL_TRACK_Y,               _station_display_datas_7)
 };
 
 static const DrawTileSprites _station_display_datas_airport[] = {
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_9 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_10 },
-	{ SPR_AIRPORT_AIRCRAFT_STAND,     PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_NS_WEST,    PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_EW_SOUTH,   PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_XING_SOUTH, PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_XING_WEST,  PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_NS_CTR,     PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_XING_EAST,  PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_NS_EAST,    PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_EW_NORTH,   PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_EW_CTR,     PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_TAXIWAY_EW_NORTH,   PAL_NONE, _station_display_datas_21 },
-	{ SPR_AIRPORT_RUNWAY_EXIT_A,      PAL_NONE, _station_display_datas_22 },
-	{ SPR_AIRPORT_RUNWAY_EXIT_B,      PAL_NONE, _station_display_datas_23 },
-	{ SPR_AIRPORT_RUNWAY_EXIT_C,      PAL_NONE, _station_display_datas_24 },
-	{ SPR_AIRPORT_RUNWAY_EXIT_D,      PAL_NONE, _station_display_datas_25 },
-	{ SPR_AIRPORT_RUNWAY_END,         PAL_NONE, _station_display_datas_26 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_27 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_28 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_29 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_30 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_31 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_32 },
-	{ SPR_AIRPORT_AIRCRAFT_STAND,     PAL_NONE, _station_display_datas_33 },
-	{ SPR_AIRPORT_AIRCRAFT_STAND,     PAL_NONE, _station_display_datas_34 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_35 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_36 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_nothing },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_38 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_39 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_40 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_41 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_42 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_43 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_44 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_45 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_46 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_47 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_48 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_49 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_50 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_51 },
-	{ SPR_AIRFIELD_TERM_A,            PAL_NONE, _station_display_nothing },
-	{ SPR_AIRFIELD_TERM_B,            PAL_NONE, _station_display_nothing },
-	{ SPR_AIRFIELD_TERM_C_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_54 },
-	{ SPR_AIRFIELD_APRON_A,           PAL_NONE, _station_display_datas_55 },
-	{ SPR_AIRFIELD_APRON_B,           PAL_NONE, _station_display_nothing },
-	{ SPR_AIRFIELD_APRON_C,           PAL_NONE, _station_display_nothing },
-	{ SPR_AIRFIELD_APRON_D,           PAL_NONE, _station_display_datas_58 },
-	{ SPR_AIRFIELD_APRON_D,           PAL_NONE, _station_display_datas_59 },
-	{ SPR_AIRFIELD_APRON_D,           PAL_NONE, _station_display_datas_60 },
-	{ SPR_AIRFIELD_APRON_D,           PAL_NONE, _station_display_datas_61 },
-	{ SPR_AIRFIELD_RUNWAY_NEAR_END,   PAL_NONE, _station_display_datas_62 },
-	{ SPR_AIRFIELD_RUNWAY_MIDDLE,     PAL_NONE, _station_display_datas_63 },
-	{ SPR_AIRFIELD_RUNWAY_FAR_END,    PAL_NONE, _station_display_datas_64 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_65 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_66 },
-	{ SPR_AIRPORT_RUNWAY_END,         PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_RUNWAY_EXIT_B,      PAL_NONE, _station_display_nothing },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_085 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_086 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_087 },
-	{ SPR_AIRPORT_RUNWAY_END,         PAL_NONE, _station_display_datas_088 },
-	{ SPR_AIRPORT_RUNWAY_EXIT_B,      PAL_NONE, _station_display_datas_089 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_090 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_091 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_092 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_093 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_094 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_095 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_096 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_097 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_098 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_099 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0100 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0101 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0102 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0103 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0104 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0105 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0106 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0107 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0108 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0109 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0110 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0111 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0112 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0113 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0114 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0115 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0116 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0117 },
-	{ SPR_AIRPORT_RUNWAY_END,         PAL_NONE, _station_display_datas_0118 },
-	{ SPR_AIRPORT_RUNWAY_END,         PAL_NONE, _station_display_datas_0119 },
-	{ SPR_AIRPORT_RUNWAY_END,         PAL_NONE, _station_display_datas_0120 },
-	{ SPR_AIRPORT_RUNWAY_END,         PAL_NONE, _station_display_datas_0121 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0122 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0123 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0124 },
-	{ SPR_NSRUNWAY1,                  PAL_NONE, _station_display_datas_0125 },
-	{ SPR_NSRUNWAY_END,               PAL_NONE, _station_display_datas_0126 },
-	{ SPR_NSRUNWAY1,                  PAL_NONE, _station_display_datas_0127 },
-	{ SPR_NSRUNWAY_END,               PAL_NONE, _station_display_datas_0128 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0129 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0130 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0131 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0132 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0133 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0134 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0135 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0136 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0137 },
-	{ SPR_AIRPORT_AIRCRAFT_STAND,     PAL_NONE, _station_display_datas_0138 },
-	{ SPR_AIRPORT_AIRCRAFT_STAND,     PAL_NONE, _station_display_datas_0139 },
-	{ SPR_AIRPORT_AIRCRAFT_STAND,     PAL_NONE, _station_display_datas_0140 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0141 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0142 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0143 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0144 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0145 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0146 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0147 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0148 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0149 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0150 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0151 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0152 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0153 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0154 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0155 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0156 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0157 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0158 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0159 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0160 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0161 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0162 },
-	{ SPR_AIRPORT_APRON,              PAL_NONE, _station_display_datas_0163 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_58 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_59 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_60 },
-	{ SPR_FLAT_GRASS_TILE,            PAL_NONE, _station_display_datas_61 },
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_9)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_10)
+	TILE_SPRITE_LINE(SPR_AIRPORT_AIRCRAFT_STAND,     _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_NS_WEST,    _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_EW_SOUTH,   _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_XING_SOUTH, _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_XING_WEST,  _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_NS_CTR,     _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_XING_EAST,  _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_NS_EAST,    _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_EW_NORTH,   _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_EW_CTR,     _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_TAXIWAY_EW_NORTH,   _station_display_datas_21)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_EXIT_A,      _station_display_datas_22)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_EXIT_B,      _station_display_datas_23)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_EXIT_C,      _station_display_datas_24)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_EXIT_D,      _station_display_datas_25)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_END,         _station_display_datas_26)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_27)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_28)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_29)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_30)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_31)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_32)
+	TILE_SPRITE_LINE(SPR_AIRPORT_AIRCRAFT_STAND,     _station_display_datas_33)
+	TILE_SPRITE_LINE(SPR_AIRPORT_AIRCRAFT_STAND,     _station_display_datas_34)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_35)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_36)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_38)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_39)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_40)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_41)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_42)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_43)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_44)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_45)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_46)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_47)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_48)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_49)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_50)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_51)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_TERM_A,            _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_TERM_B,            _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_TERM_C_GROUND | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_54)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_APRON_A,           _station_display_datas_55)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_APRON_B,           _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_APRON_C,           _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_APRON_D,           _station_display_datas_58)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_APRON_D,           _station_display_datas_59)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_APRON_D,           _station_display_datas_60)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_APRON_D,           _station_display_datas_61)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_RUNWAY_NEAR_END,   _station_display_datas_62)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_RUNWAY_MIDDLE,     _station_display_datas_63)
+	TILE_SPRITE_LINE(SPR_AIRFIELD_RUNWAY_FAR_END,    _station_display_datas_64)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_65)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_66)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_END,         _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_EXIT_B,      _station_display_nothing)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_085)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_086)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_087)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_END,         _station_display_datas_088)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_EXIT_B,      _station_display_datas_089)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_090)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_091)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_092)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_093)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_094)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_095)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_096)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_097)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_098)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_099)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0100)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0101)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0102)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0103)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0104)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0105)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0106)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0107)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0108)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0109)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0110)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0111)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0112)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0113)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0114)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0115)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0116)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0117)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_END,         _station_display_datas_0118)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_END,         _station_display_datas_0119)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_END,         _station_display_datas_0120)
+	TILE_SPRITE_LINE(SPR_AIRPORT_RUNWAY_END,         _station_display_datas_0121)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0122)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0123)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0124)
+	TILE_SPRITE_LINE(SPR_NSRUNWAY1,                  _station_display_datas_0125)
+	TILE_SPRITE_LINE(SPR_NSRUNWAY_END,               _station_display_datas_0126)
+	TILE_SPRITE_LINE(SPR_NSRUNWAY1,                  _station_display_datas_0127)
+	TILE_SPRITE_LINE(SPR_NSRUNWAY_END,               _station_display_datas_0128)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0129)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0130)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0131)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0132)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0133)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0134)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0135)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0136)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0137)
+	TILE_SPRITE_LINE(SPR_AIRPORT_AIRCRAFT_STAND,     _station_display_datas_0138)
+	TILE_SPRITE_LINE(SPR_AIRPORT_AIRCRAFT_STAND,     _station_display_datas_0139)
+	TILE_SPRITE_LINE(SPR_AIRPORT_AIRCRAFT_STAND,     _station_display_datas_0140)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0141)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0142)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0143)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0144)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0145)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0146)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0147)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0148)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0149)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0150)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0151)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0152)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0153)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0154)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0155)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0156)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0157)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0158)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0159)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0160)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0161)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0162)
+	TILE_SPRITE_LINE(SPR_AIRPORT_APRON,              _station_display_datas_0163)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_58)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_59)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_60)
+	TILE_SPRITE_LINE(SPR_FLAT_GRASS_TILE,            _station_display_datas_61)
 };
 
 static const DrawTileSprites _station_display_datas_truck[] = {
-	{ SPR_TRUCK_STOP_NE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_67 },
-	{ SPR_TRUCK_STOP_SE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_68 },
-	{ SPR_TRUCK_STOP_SW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_69 },
-	{ SPR_TRUCK_STOP_NW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_70 },
-	{ SPR_ROAD_PAVED_STRAIGHT_X,      PAL_NONE, _station_display_datas_0168 },
-	{ SPR_ROAD_PAVED_STRAIGHT_Y,      PAL_NONE, _station_display_datas_0169 },
+	TILE_SPRITE_LINE(SPR_TRUCK_STOP_NE_GROUND | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_67)
+	TILE_SPRITE_LINE(SPR_TRUCK_STOP_SE_GROUND | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_68)
+	TILE_SPRITE_LINE(SPR_TRUCK_STOP_SW_GROUND | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_69)
+	TILE_SPRITE_LINE(SPR_TRUCK_STOP_NW_GROUND | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_70)
+	TILE_SPRITE_LINE(SPR_ROAD_PAVED_STRAIGHT_X,      _station_display_datas_0168)
+	TILE_SPRITE_LINE(SPR_ROAD_PAVED_STRAIGHT_Y,      _station_display_datas_0169)
 };
 
 static const DrawTileSprites _station_display_datas_bus[] = {
-	{ SPR_BUS_STOP_NE_GROUND   | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_71 },
-	{ SPR_BUS_STOP_SE_GROUND   | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_72 },
-	{ SPR_BUS_STOP_SW_GROUND   | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_73 },
-	{ SPR_BUS_STOP_NW_GROUND   | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_74 },
-	{ SPR_ROAD_PAVED_STRAIGHT_X,      PAL_NONE, _station_display_datas_0170 },
-	{ SPR_ROAD_PAVED_STRAIGHT_Y,      PAL_NONE, _station_display_datas_0171 }
+	TILE_SPRITE_LINE(SPR_BUS_STOP_NE_GROUND   | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_71)
+	TILE_SPRITE_LINE(SPR_BUS_STOP_SE_GROUND   | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_72)
+	TILE_SPRITE_LINE(SPR_BUS_STOP_SW_GROUND   | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_73)
+	TILE_SPRITE_LINE(SPR_BUS_STOP_NW_GROUND   | (1 << PALETTE_MODIFIER_COLOR), _station_display_datas_74)
+	TILE_SPRITE_LINE(SPR_ROAD_PAVED_STRAIGHT_X,      _station_display_datas_0170)
+	TILE_SPRITE_LINE(SPR_ROAD_PAVED_STRAIGHT_Y,      _station_display_datas_0171)
 };
 
 static const DrawTileSprites _station_display_datas_oilrig[] = {
-	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_nothing },
+	TILE_SPRITE_LINE(SPR_FLAT_WATER_TILE,            _station_display_nothing)
 };
 
 static const DrawTileSprites _station_display_datas_dock[] = {
-	{ 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 },
+	TILE_SPRITE_LINE(SPR_SHORE_BASE + SLOPE_SW,      _station_display_datas_76)
+	TILE_SPRITE_LINE(SPR_SHORE_BASE + SLOPE_NW,      _station_display_datas_77)
+	TILE_SPRITE_LINE(SPR_SHORE_BASE + SLOPE_NE,      _station_display_datas_78)
+	TILE_SPRITE_LINE(SPR_SHORE_BASE + SLOPE_SE,      _station_display_datas_79)
+	TILE_SPRITE_LINE(SPR_FLAT_WATER_TILE,            _station_display_datas_80)
+	TILE_SPRITE_LINE(SPR_FLAT_WATER_TILE,            _station_display_datas_81)
 };
 
 static const DrawTileSprites _station_display_datas_buoy[] = {
-	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_82 },
+	TILE_SPRITE_LINE(SPR_FLAT_WATER_TILE,            _station_display_datas_82)
 };
 
+#undef TILE_SPRITE_LINE
+
 static const DrawTileSprites *_station_display_datas[] = {
 	_station_display_datas_rail,
 	_station_display_datas_airport,
--- a/src/table/track_land.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/table/track_land.h	Fri Feb 22 00:25:54 2008 +0000
@@ -1,7 +1,7 @@
 /* $Id$ */
 
-#define TILE_SEQ_LINE(img, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 23, img, PAL_NONE },
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, 0, 0 }
+#define TILE_SEQ_LINE(img, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 23, {img, PAL_NONE} },
+#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
 
 
 static const DrawTileSeqStruct _depot_gfx_NE[] = {
@@ -27,10 +27,10 @@
 };
 
 static const DrawTileSprites _depot_gfx_table[] = {
-	{ SPR_FLAT_GRASS_TILE, PAL_NONE, _depot_gfx_NE },
-	{ SPR_RAIL_TRACK_Y,    PAL_NONE, _depot_gfx_SE },
-	{ SPR_RAIL_TRACK_X,    PAL_NONE, _depot_gfx_SW },
-	{ SPR_FLAT_GRASS_TILE, PAL_NONE, _depot_gfx_NW }
+	{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NE },
+	{ {SPR_RAIL_TRACK_Y,    PAL_NONE}, _depot_gfx_SE },
+	{ {SPR_RAIL_TRACK_X,    PAL_NONE}, _depot_gfx_SW },
+	{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NW }
 };
 
 
@@ -47,6 +47,10 @@
 };
 
 static const DrawTileSprites _waypoint_gfx_table[] = {
-	{ SPR_RAIL_TRACK_X, PAL_NONE, _waypoint_gfx_X },
-	{ SPR_RAIL_TRACK_Y, PAL_NONE, _waypoint_gfx_Y }
+	{ {SPR_RAIL_TRACK_X, PAL_NONE}, _waypoint_gfx_X },
+	{ {SPR_RAIL_TRACK_Y, PAL_NONE}, _waypoint_gfx_Y }
 };
+
+#undef TILE_SEQ_LINE
+#undef TILE_SEQ_END
+
--- a/src/table/unmovable_land.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/table/unmovable_land.h	Fri Feb 22 00:25:54 2008 +0000
@@ -1,91 +1,89 @@
 /* $Id$ */
 
-struct DrawTileUnmovableStruct {
-	uint16 image;
-	byte subcoord_x;
-	byte subcoord_y;
-	byte width;
-	byte height;
-	byte z_size;
-	byte unused;
+
+static const DrawTileSeqStruct _draw_tile_transmitterlighthouse_data[] = {
+	{   7,  7,  0,  2,  2, 70, {SPR_UNMOVABLE_TRANSMITTER, PAL_NONE}},
+	{   4,  4,  0,  7,  7, 61, {SPR_UNMOVABLE_LIGHTHOUSE, PAL_NONE}},
 };
 
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, 0, 0 }
-
-static const DrawTileUnmovableStruct _draw_tile_unmovable_data[] = {
-	{0xA29, 7, 7, 2, 2, 70, 0},
-	{0xA2A, 4, 4, 7, 7, 61, 0},
-};
-
+#define TILE_SEQ_LINE(sz, img) { 0, 0, 0, 16, 16, sz, {img, PAL_NONE} },
+#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
 
 static const DrawTileSeqStruct _unmovable_display_nothing[] = {
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_8[] = {
-	{   0,  0,  0, 16, 16, 20, 0xA34 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(20, 0xA34 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_9[] = {
-	{   0,  0,  0, 16, 16, 20, 0xA36 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(20, 0xA36 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_10[] = {
-	{   0,  0,  0, 16, 16, 20, 0xA38 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(20, 0xA38 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_12[] = {
-	{   0,  0,  0, 16, 16, 50, 0xA3B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(50, 0xA3B | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_13[] = {
-	{   0,  0,  0, 16, 16, 50, 0xA3D | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(50, 0xA3D | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_14[] = {
-	{   0,  0,  0, 16, 16, 50, 0xA3F | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(50, 0xA3F | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_16[] = {
-	{   0,  0,  0, 16, 16, 60, 0xA42 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(60, 0xA42 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_17[] = {
-	{   0,  0,  0, 16, 16, 60, 0xA44 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(60, 0xA44 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
 static const DrawTileSeqStruct _unmovable_display_datas_18[] = {
-	{   0,  0,  0, 16, 16, 60, 0xA46 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
+	TILE_SEQ_LINE(60, 0xA46 | (1 << PALETTE_MODIFIER_COLOR))
 	TILE_SEQ_END()
 };
 
+#undef TILE_SEQ_LINE
+#undef TILE_SEQ_END
+
+#define TILE_SPRITE_LINE(img, dtss) { {img | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE}, dtss },
+
 static const DrawTileSprites _unmovable_display_datas[] = {
-	{ 0xA2B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA2C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA2D | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA2E | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA2F | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA30 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA31 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA32 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA33 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_8 },
-	{ 0xA35 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_9 },
-	{ 0xA37 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_10 },
-	{ 0xA39 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA3A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_12 },
-	{ 0xA3C | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_13 },
-	{ 0xA3E | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_14 },
-	{ 0xA40 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
-	{ 0xA41 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_16 },
-	{ 0xA43 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_17 },
-	{ 0xA45 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_datas_18 },
-	{ 0xA47 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _unmovable_display_nothing },
+	TILE_SPRITE_LINE(0xA2B, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA2C, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA2D, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA2E, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA2F, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA30, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA31, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA32, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA33, _unmovable_display_datas_8)
+	TILE_SPRITE_LINE(0xA35, _unmovable_display_datas_9)
+	TILE_SPRITE_LINE(0xA37, _unmovable_display_datas_10)
+	TILE_SPRITE_LINE(0xA39, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA3A, _unmovable_display_datas_12)
+	TILE_SPRITE_LINE(0xA3C, _unmovable_display_datas_13)
+	TILE_SPRITE_LINE(0xA3E, _unmovable_display_datas_14)
+	TILE_SPRITE_LINE(0xA40, _unmovable_display_nothing)
+	TILE_SPRITE_LINE(0xA41, _unmovable_display_datas_16)
+	TILE_SPRITE_LINE(0xA43, _unmovable_display_datas_17)
+	TILE_SPRITE_LINE(0xA45, _unmovable_display_datas_18)
+	TILE_SPRITE_LINE(0xA47, _unmovable_display_nothing)
 };
+
+#undef TILE_SPRITE_LINE
--- a/src/tile_cmd.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/tile_cmd.h	Fri Feb 22 00:25:54 2008 +0000
@@ -13,6 +13,8 @@
 #include "strings_type.h"
 #include "date_type.h"
 #include "player_type.h"
+#include "direction_type.h"
+#include "track_type.h"
 
 /** The returned bits of VehicleEnterTile. */
 enum VehicleEnterTileStatus {
@@ -59,29 +61,17 @@
 
 /**
  * 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).
+ * that can be taken on a given tile by a given transport.
+ * The return value contains the existing trackdirs and signal states.
  *
- * 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
+ * see track_func.h for usage of TrackStatus.
  *
- * 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
+ * @return the track status information
  */
-typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode);
+typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side);
 typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
 typedef void ClickTileProc(TileIndex tile);
 typedef void AnimateTileProc(TileIndex tile);
@@ -126,7 +116,7 @@
 
 extern const TileTypeProcs * const _tile_type_procs[16];
 
-uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode);
+TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
 void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
 void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player);
 void AnimateTile(TileIndex tile);
--- a/src/town_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/town_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -117,7 +117,6 @@
 };
 
 static bool BuildTownHouse(Town *t, TileIndex tile);
-static void DoBuildTownHouse(Town *t, TileIndex tile);
 
 static void TownDrawHouseLift(const TileInfo *ti)
 {
@@ -493,7 +492,7 @@
 		ClearTownHouse(t, tile);
 
 		/* Rebuild with another house? */
-		if (GB(r, 24, 8) >= 12) DoBuildTownHouse(t, tile);
+		if (GB(r, 24, 8) >= 12) BuildTownHouse(t, tile);
 	}
 
 	_current_player = OWNER_NONE;
@@ -593,7 +592,7 @@
 	td->owner = OWNER_TOWN;
 }
 
-static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Town(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
 	/* not used */
 	return 0;
@@ -1586,29 +1585,6 @@
 	return true;
 }
 
-static bool CheckBuildHouseMode(TileIndex tile, Slope tileh, int mode)
-{
-	int b;
-	Slope slope;
-
-	static const Slope _masks[8] = {
-		SLOPE_NE,  SLOPE_SW,  SLOPE_NW,  SLOPE_SE,
-		SLOPE_SW,  SLOPE_NE,  SLOPE_SE,  SLOPE_NW,
-	};
-
-	slope = GetTileSlope(tile, NULL);
-	if (IsSteepSlope(slope)) return false;
-
-	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
-
-	b = 0;
-	if ((slope != SLOPE_FLAT && ~slope & _masks[mode])) b = ~b;
-	if ((tileh != SLOPE_FLAT && ~tileh & _masks[mode + 4])) b = ~b;
-	if (b)
-		return false;
-
-	return CmdSucceeded(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
-}
 
 /** Returns the bit corresponding to the town zone of the specified tile
  * @param t Town on which radius is to be found
@@ -1631,155 +1607,347 @@
 	return smallest;
 }
 
-static bool CheckFree2x2Area(TileIndex tile)
+/**
+ * Clears tile and builds a house or house part.
+ * @param t tile index
+ * @param tid Town index
+ * @param counter of construction step
+ * @param stage of construction (used for drawing)
+ * @param type of house. Index into house specs array
+ * @param random_bits required for newgrf houses
+ * @pre house can be built here
+ */
+static inline void ClearMakeHouseTile(TileIndex tile, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
 {
-	int i;
-
-	static const TileIndexDiffC _tile_add[] = {
-		{0    , 0    },
-		{0 - 0, 1 - 0},
-		{1 - 0, 0 - 1},
-		{1 - 1, 1 - 0}
-	};
-
-	for (i = 0; i != 4; i++) {
-		tile += ToTileIndexDiff(_tile_add[i]);
-
-		if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return false;
-
-		if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
-
-		if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR)))
-			return false;
+	#if !defined(NDEBUG) || defined(WITH_ASSERT)
+		CommandCost cc =
+	#endif /* !defined(NDEBUG) || defined(WITH_ASSERT) */
+
+	DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR);
+
+	assert(CmdSucceeded(cc));
+
+	MakeHouseTile(tile, tid, counter, stage, type, random_bits);
+}
+
+
+/**
+ * Write house information into the map. For houses > 1 tile, all tiles are marked.
+ * @param t tile index
+ * @param tid Town index
+ * @param counter of construction step
+ * @param stage of construction (used for drawing)
+ * @param type of house. Index into house specs array
+ * @param random_bits required for newgrf houses
+ * @pre house can be built here
+ */
+static void MakeTownHouse(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
+{
+	BuildingFlags size = GetHouseSpecs(type)->building_flags;
+
+	ClearMakeHouseTile(t, tid, counter, stage, type, random_bits);
+	if (size & BUILDING_2_TILES_Y)   ClearMakeHouseTile(t + TileDiffXY(0, 1), tid, counter, stage, ++type, random_bits);
+	if (size & BUILDING_2_TILES_X)   ClearMakeHouseTile(t + TileDiffXY(1, 0), tid, counter, stage, ++type, random_bits);
+	if (size & BUILDING_HAS_4_TILES) ClearMakeHouseTile(t + TileDiffXY(1, 1), tid, counter, stage, ++type, random_bits);
+}
+
+
+/**
+ * Checks if a house can be built here. Important is slope, bridge above
+ * and ability to clear the land.
+ * @param tile tile to check
+ * @param town town that is checking
+ * @param noslope are slopes (foundations) allowed?
+ * @return true iff house can be built here
+ */
+static inline bool CanBuildHouseHere(TileIndex tile, TownID town, bool noslope)
+{
+	/* cannot build on these slopes... */
+	Slope slope = GetTileSlope(tile, NULL);
+	if ((noslope && slope != SLOPE_FLAT) || IsSteepSlope(slope)) return false;
+
+	/* building under a bridge? */
+	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
+
+	/* do not try to build over house owned by another town */
+	if (IsTileType(tile, MP_HOUSE) && GetTownIndex(tile) != town) return false;
+
+	/* can we clear the land? */
+	return CmdSucceeded(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
+}
+
+
+/**
+ * Checks if a house can be built at this tile, must have the same max z as parameter.
+ * @param tile tile to check
+ * @param town town that is checking
+ * @param z max z of this tile so more parts of a house are at the same height (with foundation)
+ * @param noslope are slopes (foundations) allowed?
+ * @return true iff house can be built here
+ * @see CanBuildHouseHere()
+ */
+static inline bool CheckBuildHouseSameZ(TileIndex tile, TownID town, uint z, bool noslope)
+{
+	if (!CanBuildHouseHere(tile, town, noslope)) return false;
+
+	/* if building on slopes is allowed, there will be flattening foundation (to tile max z) */
+	if (GetTileMaxZ(tile) != z) return false;
+
+	return true;
+}
+
+
+/**
+ * Checks if a house of size 2x2 can be built at this tile
+ * @param tile tile, N corner
+ * @param town town that is checking
+ * @param z maximum tile z so all tile have the same max z
+ * @param noslope are slopes (foundations) allowed?
+ * @return true iff house can be built
+ * @see CheckBuildHouseSameZ()
+ */
+static bool CheckFree2x2Area(TileIndex tile, TownID town, uint z, bool noslope)
+{
+	/* we need to check this tile too because we can be at different tile now */
+	if (!CheckBuildHouseSameZ(tile, town, z, noslope)) return false;
+
+	for (DiagDirection d = DIAGDIR_SE; d < DIAGDIR_END; d++) {
+		tile += TileOffsByDiagDir(d);
+		if (!CheckBuildHouseSameZ(tile, town, z, noslope)) return false;
 	}
 
 	return true;
 }
 
-static void DoBuildTownHouse(Town *t, TileIndex tile)
+
+/**
+ * Checks if current town layout allows building here
+ * @param t town
+ * @param tile tile to check
+ * @return true iff town layout allows building here
+ * @note see layouts
+ */
+static inline bool TownLayoutAllowsHouseHere(Town *t, TileIndex tile)
 {
-	int i;
-	uint bitmask;
-	HouseID house;
-	Slope slope;
+	TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile);
+
+	switch (_patches.town_layout) {
+		case TL_2X2_GRID:
+			if ((grid_pos.x % 3) == 0 || (grid_pos.y % 3) == 0) return false;
+			break;
+
+		case TL_3X3_GRID:
+			if ((grid_pos.x % 4) == 0 || (grid_pos.y % 4) == 0) return false;
+			break;
+
+		default:
+			break;
+	}
+
+	return true;
+}
+
+
+/**
+ * Checks if current town layout allows 2x2 building here
+ * @param t town
+ * @param tile tile to check
+ * @return true iff town layout allows 2x2 building here
+ * @note see layouts
+ */
+static inline bool TownLayoutAllows2x2HouseHere(Town *t, TileIndex tile)
+{
+	/* MapSize() is sure dividable by both MapSizeX() and MapSizeY(),
+	 * so to do only one memory access, use MapSize() */
+	uint dx = MapSize() + TileX(t->xy) - TileX(tile);
+	uint dy = MapSize() + TileY(t->xy) - TileY(tile);
+
+	switch (_patches.town_layout) {
+		case TL_2X2_GRID:
+			if ((dx % 3) != 0 || (dy % 3) != 0) return false;
+			break;
+
+		case TL_3X3_GRID:
+			if ((dx % 4) < 2 || (dy % 4) < 2) return false;
+			break;
+
+		default:
+			break;
+	}
+
+	return true;
+}
+
+
+/**
+ * Checks if 1x2 or 2x1 building is allowed here, also takes into account current town layout
+ * Also, tests both building positions that occupy this tile
+ * @param tile tile where the building should be built
+ * @param t town
+ * @param maxz all tiles should have the same height
+ * @param noslope are slopes forbidden?
+ * @param second diagdir from first tile to second tile
+ **/
+static bool CheckTownBuild2House(TileIndex *tile, Town *t, uint maxz, bool noslope, DiagDirection second)
+{
+	/* 'tile' is already checked in BuildTownHouse() - CanBuildHouseHere() and slope test */
+
+	TileIndex tile2 = *tile + TileOffsByDiagDir(second);
+	if (TownLayoutAllowsHouseHere(t, tile2) && CheckBuildHouseSameZ(tile2, t->index, maxz, noslope)) return true;
+
+	tile2 = *tile + TileOffsByDiagDir(ReverseDiagDir(second));
+	if (TownLayoutAllowsHouseHere(t, tile2) && CheckBuildHouseSameZ(tile2, t->index, maxz, noslope)) {
+		*tile = tile2;
+		return true;
+	}
+
+	return false;
+}
+
+
+/**
+ * Checks if 2x2 building is allowed here, also takes into account current town layout
+ * Also, tests all four building positions that occupy this tile
+ * @param tile tile where the building should be built
+ * @param t town
+ * @param maxz all tiles should have the same height
+ * @param noslope are slopes forbidden?
+ **/
+static bool CheckTownBuild2x2House(TileIndex *tile, Town *t, uint maxz, bool noslope)
+{
+	TileIndex tile2 = *tile;
+
+	for (DiagDirection d = DIAGDIR_SE;;d++) { // 'd' goes through DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_END
+		if (TownLayoutAllows2x2HouseHere(t, tile2) && CheckFree2x2Area(tile2, t->index, maxz, noslope)) {
+			*tile = tile2;
+			return true;
+		}
+		if (d == DIAGDIR_END) break;
+		tile2 += TileOffsByDiagDir(ReverseDiagDir(d)); // go clockwise
+	}
+
+	return false;
+}
+
+
+/**
+ * Tries to build a house at this tile
+ * @param t town the house will belong to
+ * @param tile where the house will be built
+ * @return false iff no house can be built at this tile
+ */
+static bool BuildTownHouse(Town *t, TileIndex tile)
+{
+	/* forbidden building here by town layout */
+	if (!TownLayoutAllowsHouseHere(t, tile)) return false;
+
+	/* no house allowed at all, bail out */
+	if (!CanBuildHouseHere(tile, t->index, false)) return false;
+
 	uint z;
-	uint oneof = 0;
-	HouseSpec *hs;
-
-	/* Above snow? */
-	slope = GetTileSlope(tile, &z);
+	Slope slope = GetTileSlope(tile, &z);
 
 	/* Get the town zone type of the current tile, as well as the climate.
 	 * This will allow to easily compare with the specs of the new house to build */
-	{
-		HouseZonesBits rad = GetTownRadiusGroup(t, tile);
-
-		int land = _opt.landscape;
-		if (land == LT_ARCTIC && z >= _opt.snow_line) land = -1;
-
-		bitmask = (1 << rad) + (1 << (land + 12));
-	}
+	HouseZonesBits rad = GetTownRadiusGroup(t, tile);
+
+	/* Above snow? */
+	int land = _opt.landscape;
+	if (land == LT_ARCTIC && z >= _opt.snow_line) land = -1;
+
+	uint bitmask = (1 << rad) + (1 << (land + 12));
 
 	/* bits 0-4 are used
 	 * bits 11-15 are used
 	 * bits 5-10 are not used. */
-	{
-		HouseID houses[HOUSE_MAX];
-		int num = 0;
-		uint cumulative_probs[HOUSE_MAX];
-		uint probability_max = 0;
-
-		/* Generate a list of all possible houses that can be built. */
-		for (i = 0; i < HOUSE_MAX; i++) {
-			hs = GetHouseSpecs(i);
-			/* Verify that the candidate house spec matches the current tile status */
-			if ((~hs->building_availability & bitmask) == 0 && hs->enabled) {
-				if (_loaded_newgrf_features.has_newhouses) {
-					probability_max += hs->probability;
-					cumulative_probs[num] = probability_max;
-				}
-				houses[num++] = (HouseID)i;
+	HouseID houses[HOUSE_MAX];
+	uint num = 0;
+	uint probs[HOUSE_MAX];
+	uint probability_max = 0;
+
+	/* Generate a list of all possible houses that can be built. */
+	for (uint i = 0; i < HOUSE_MAX; i++) {
+		HouseSpec *hs = GetHouseSpecs(i);
+		/* Verify that the candidate house spec matches the current tile status */
+		if ((~hs->building_availability & bitmask) == 0 && hs->enabled) {
+			/* Without NewHouses, all houses have probability '1' */
+			uint cur_prob = (_loaded_newgrf_features.has_newhouses ? hs->probability : 1);
+			probability_max += cur_prob;
+			probs[num] = cur_prob;
+			houses[num++] = (HouseID)i;
+		}
+	}
+
+	uint maxz = GetTileMaxZ(tile);
+
+	while (probability_max > 0) {
+		uint r = RandomRange(probability_max);
+		uint i;
+		for (i = 0; i < num; i++) {
+			if (probs[i] > r) break;
+			r -= probs[i];
+		}
+
+		HouseID house = houses[i];
+		probability_max -= probs[i];
+
+		/* remove tested house from the set */
+		num--;
+		houses[i] = houses[num];
+		probs[i] = probs[num];
+
+		HouseSpec *hs = GetHouseSpecs(house);
+
+		if (_loaded_newgrf_features.has_newhouses) {
+			if (hs->override != 0) {
+				house = hs->override;
+				hs = GetHouseSpecs(house);
+			}
+
+			if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue;
+
+			if (HasBit(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) {
+				uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house, t, tile);
+				if (callback_res != CALLBACK_FAILED && callback_res == 0) continue;
 			}
 		}
 
-		for (;;) {
-			if (_loaded_newgrf_features.has_newhouses) {
-				uint r = RandomRange(probability_max);
-				for (i = 0; i < num; i++) if (cumulative_probs[i] >= r) break;
-
-				house = houses[i];
-			} else {
-				house = houses[RandomRange(num)];
-			}
-
-			hs = GetHouseSpecs(house);
-
-			if (_loaded_newgrf_features.has_newhouses) {
-				if (hs->override != 0) {
-					house = hs->override;
-					hs = GetHouseSpecs(house);
-				}
-
-				if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue;
-
-				if (HasBit(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) {
-					uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house, t, tile);
-					if (callback_res != CALLBACK_FAILED && callback_res == 0) continue;
-				}
-			}
-
-			if (_cur_year < hs->min_date || _cur_year > hs->max_date) continue;
-
-			/* Special houses that there can be only one of. */
-			if (hs->building_flags & BUILDING_IS_CHURCH) {
-				SetBit(oneof, TOWN_HAS_CHURCH);
-			} else if (hs->building_flags & BUILDING_IS_STADIUM) {
-				SetBit(oneof, TOWN_HAS_STADIUM);
-			} else {
-				oneof = 0;
-			}
-
-			if (HASBITS(t->flags12 , oneof)) continue;
-
-			/* Make sure there is no slope? */
-			if (hs->building_flags & TILE_NOT_SLOPED && slope != SLOPE_FLAT) continue;
-
-			if (hs->building_flags & TILE_SIZE_2x2) {
-				if (CheckFree2x2Area(tile) ||
-						CheckFree2x2Area(tile += TileDiffXY(-1,  0)) ||
-						CheckFree2x2Area(tile += TileDiffXY( 0, -1)) ||
-						CheckFree2x2Area(tile += TileDiffXY( 1,  0))) {
-					break;
-				}
-				tile += TileDiffXY(0, 1);
-			} else if (hs->building_flags & TILE_SIZE_2x1) {
-				if (CheckBuildHouseMode(tile + TileDiffXY(1, 0), slope, 0)) break;
-
-				if (CheckBuildHouseMode(tile + TileDiffXY(-1, 0), slope, 1)) {
-					tile += TileDiffXY(-1, 0);
-					break;
-				}
-			} else if (hs->building_flags & TILE_SIZE_1x2) {
-				if (CheckBuildHouseMode(tile + TileDiffXY(0, 1), slope, 2)) break;
-
-				if (CheckBuildHouseMode(tile + TileDiffXY(0, -1), slope, 3)) {
-					tile += TileDiffXY(0, -1);
-					break;
-				}
-			} else {
-				break;
-			}
+		if (_cur_year < hs->min_date || _cur_year > hs->max_date) continue;
+
+		/* Special houses that there can be only one of. */
+		uint oneof = 0;
+
+		if (hs->building_flags & BUILDING_IS_CHURCH) {
+			SetBit(oneof, TOWN_HAS_CHURCH);
+		} else if (hs->building_flags & BUILDING_IS_STADIUM) {
+			SetBit(oneof, TOWN_HAS_STADIUM);
 		}
-	}
-
-	t->num_houses++;
-	IncreaseBuildingCount(t, house);
-
-	/* Special houses that there can be only one of. */
-	t->flags12 |= oneof;
-
-	{
-		byte construction_counter = 0, construction_stage = 0;
+
+		if (HASBITS(t->flags12 , oneof)) continue;
+
+		/* Make sure there is no slope? */
+		bool noslope = (hs->building_flags & TILE_NOT_SLOPED) != 0;
+		if (noslope && slope != SLOPE_FLAT) continue;
+
+		if (hs->building_flags & TILE_SIZE_2x2) {
+			if (!CheckTownBuild2x2House(&tile, t, maxz, noslope)) continue;
+		} else if (hs->building_flags & TILE_SIZE_2x1) {
+			if (!CheckTownBuild2House(&tile, t, maxz, noslope, DIAGDIR_SW)) continue;
+		} else if (hs->building_flags & TILE_SIZE_1x2) {
+			if (!CheckTownBuild2House(&tile, t, maxz, noslope, DIAGDIR_SE)) continue;
+		} else {
+			/* 1x1 house checks are already done */
+		}
+
+		/* build the house */
+		t->num_houses++;
+		IncreaseBuildingCount(t, house);
+
+		/* Special houses that there can be only one of. */
+		t->flags12 |= oneof;
+
+		byte construction_counter = 0;
+		byte construction_stage = 0;
 
 		if (_generating_world) {
 			uint32 r = Random();
@@ -1793,22 +1961,13 @@
 				construction_counter = GB(r, 2, 2);
 			}
 		}
+
 		MakeTownHouse(tile, t->index, construction_counter, construction_stage, house, Random());
+
+		return true;
 	}
-}
-
-static bool BuildTownHouse(Town *t, TileIndex tile)
-{
-	CommandCost r;
-
-	if (IsSteepSlope(GetTileSlope(tile, NULL))) return false;
-	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
-
-	r = DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR);
-	if (CmdFailed(r)) return false;
-
-	DoBuildTownHouse(t, tile);
-	return true;
+
+	return false;
 }
 
 
--- a/src/town_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/town_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -225,25 +225,24 @@
 	case WE_DOUBLE_CLICK:
 	case WE_CLICK:
 		switch (e->we.click.widget) {
-		case TWA_COMMAND_LIST: {
-			const Town *t = GetTown(w->window_number);
-			int y = (e->we.click.pt.y - 0x6B) / 10;
-
-			if (!IsInsideMM(y, 0, 5)) return;
+			case TWA_COMMAND_LIST: {
+				const Town *t = GetTown(w->window_number);
+				int y = (e->we.click.pt.y - 0x6B) / 10;
 
-			y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1);
-			if (y >= 0) {
-				WP(w, def_d).data_1 = y;
-				SetWindowDirty(w);
+				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;
+					SetWindowDirty(w);
+				}
+				/* Fall through to clicking in case we are double-clicked */
+				if (e->event != WE_DOUBLE_CLICK || y < 0) break;
 			}
-			/* Fall through to clicking in case we are double-clicked */
-			if (e->event != WE_DOUBLE_CLICK || y < 0) break;
-		}
 
-		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));
-			break;
-		}
+			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));
+				break;
 		}
 		break;
 
@@ -320,8 +319,7 @@
 			case 10: /* delete town */
 				delete t;
 				break;
-		}
-		break;
+		} break;
 
 	case WE_ON_EDIT_TEXT:
 		if (e->we.edittext.str[0] != '\0') {
@@ -394,6 +392,11 @@
 	}
 }
 
+enum TownDirectoryWidget {
+	TDW_SORTNAME = 3,
+	TDW_SORTPOPULATION,
+	TDW_CENTERTOWN,
+};
 static const Widget _town_directory_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    13,    11,   195,     0,    13, STR_2000_TOWNS,         STR_018C_WINDOW_TITLE_DRAG_THIS},
@@ -478,7 +481,7 @@
 		SetVScrollCount(w, _num_town_sort);
 
 		DrawWindowWidgets(w);
-		DrawSortButtonState(w, (_town_sort_order <= 1) ? 3 : 4, _town_sort_order & 1 ? SBS_DOWN : SBS_UP);
+		DrawSortButtonState(w, (_town_sort_order <= 1) ? TDW_SORTNAME : TDW_SORTPOPULATION, _town_sort_order & 1 ? SBS_DOWN : SBS_UP);
 
 		{
 			int n = 0;
@@ -505,34 +508,33 @@
 
 	case WE_CLICK:
 		switch (e->we.click.widget) {
-		case 3: { /* Sort by Name ascending/descending */
-			_town_sort_order = (_town_sort_order == 0) ? 1 : 0;
-			_town_sort_dirty = true;
-			SetWindowDirty(w);
-		} break;
-
-		case 4: { /* Sort by Population ascending/descending */
-			_town_sort_order = (_town_sort_order == 2) ? 3 : 2;
-			_town_sort_dirty = true;
-			SetWindowDirty(w);
-		} break;
+			case TDW_SORTNAME: { /* Sort by Name ascending/descending */
+				_town_sort_order = (_town_sort_order == 0) ? 1 : 0;
+				_town_sort_dirty = true;
+				SetWindowDirty(w);
+			} break;
 
-		case 5: { /* Click on Town Matrix */
-			const Town* t;
-
-			uint16 id_v = (e->we.click.pt.y - 28) / 10;
-
-			if (id_v >= w->vscroll.cap) return; // click out of bounds
+			case TDW_SORTPOPULATION: { /* Sort by Population ascending/descending */
+				_town_sort_order = (_town_sort_order == 2) ? 3 : 2;
+				_town_sort_dirty = true;
+				SetWindowDirty(w);
+			} break;
 
-			id_v += w->vscroll.pos;
-
-			if (id_v >= _num_town_sort) return; // click out of town bounds
+			case TDW_CENTERTOWN: { /* Click on Town Matrix */
+				const Town* t;
 
-			t = _town_sort[id_v];
-			assert(t->xy);
-			ScrollMainWindowToTile(t->xy);
-			break;
-		}
+				uint16 id_v = (e->we.click.pt.y - 28) / 10;
+
+				if (id_v >= w->vscroll.cap) return; // click out of bounds
+
+				id_v += w->vscroll.pos;
+
+				if (id_v >= _num_town_sort) return; // click out of town bounds
+
+				t = _town_sort[id_v];
+				assert(t->xy);
+				ScrollMainWindowToTile(t->xy);
+			} break;
 		}
 		break;
 
--- a/src/town_map.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/town_map.h	Fri Feb 22 00:25:54 2008 +0000
@@ -211,26 +211,6 @@
 }
 
 /**
- * Helper function for MakeHouseTile.
- * It is called  for each tile of a multi-tile house.
- * Parametes are the same.
- * @param t tile index
- * @param tid Town index
- * @param counter of construction step
- * @param stage of construction (used for drawing)
- * @param type of house.  Index into house specs array
- * @param random_bits required for newgrf houses
- */
-static inline void MakeTownHouse(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
-{
-	BuildingFlags size = GetHouseSpecs(type)->building_flags;
-	MakeHouseTile(t, tid, counter, stage, type, random_bits);
-	if (size & BUILDING_2_TILES_Y)   MakeHouseTile(t + TileDiffXY(0, 1), tid, counter, stage, ++type, random_bits);
-	if (size & BUILDING_2_TILES_X)   MakeHouseTile(t + TileDiffXY(1, 0), tid, counter, stage, ++type, random_bits);
-	if (size & BUILDING_HAS_4_TILES) MakeHouseTile(t + TileDiffXY(1, 1), tid, counter, stage, ++type, random_bits);
-}
-
-/**
  * House Construction Scheme.
  *  Construction counter, for buildings under construction. Incremented on every
  *  periodic tile processing.
--- a/src/track_func.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/track_func.h	Fri Feb 22 00:25:54 2008 +0000
@@ -274,6 +274,64 @@
 }
 
 /**
+ * Converts TrackBits to TrackdirBits while allowing both directions.
+ *
+ * @param bits The TrackBits
+ * @return The TrackDirBits containing of bits in both directions.
+ */
+static inline TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
+{
+	return (TrackdirBits)(bits * 0x101);
+}
+
+/**
+ * Returns the present-trackdir-information of a TrackStatus.
+ *
+ * @param ts The TrackStatus returned by GetTileTrackStatus()
+ * @return the present trackdirs
+ */
+static inline TrackdirBits TrackStatusToTrackdirBits(TrackStatus ts)
+{
+	return (TrackdirBits)(ts & TRACKDIR_BIT_MASK);
+}
+
+/**
+ * Returns the present-track-information of a TrackStatus.
+ *
+ * @param ts The TrackStatus returned by GetTileTrackStatus()
+ * @return the present tracks
+ */
+static inline TrackBits TrackStatusToTrackBits(TrackStatus ts)
+{
+	return TrackdirBitsToTrackBits(TrackStatusToTrackdirBits(ts));
+}
+
+/**
+ * Returns the red-signal-information of a TrackStatus.
+ *
+ * Note: The result may contain red signals for non-present tracks.
+ *
+ * @param ts The TrackStatus returned by GetTileTrackStatus()
+ * @return the The trackdirs that are blocked by red-signals
+ */
+static inline TrackdirBits TrackStatusToRedSignals(TrackStatus ts)
+{
+	return (TrackdirBits)((ts >> 16) & TRACKDIR_BIT_MASK);
+}
+
+/**
+ * Builds a TrackStatus
+ *
+ * @param trackdirbits present trackdirs
+ * @param red_signals red signals
+ * @return the TrackStatus representing the given information
+ */
+static inline TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
+{
+	return (TrackStatus)(trackdirbits | (red_signals << 16));
+}
+
+/**
  * Maps a trackdir to the trackdir that you will end up on if you go straight
  * ahead.
  *
--- a/src/track_type.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/track_type.h	Fri Feb 22 00:25:54 2008 +0000
@@ -124,4 +124,6 @@
 typedef TinyEnumT<TrackdirBits> TrackdirBitsShort;
 DECLARE_ENUM_AS_BIT_SET(TrackdirBits);
 
+typedef uint32 TrackStatus;
+
 #endif /* TRACK_TYPE_H */
--- a/src/train.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/train.h	Fri Feb 22 00:25:54 2008 +0000
@@ -17,12 +17,12 @@
  */
 
 enum TrainSubtype {
-	Train_Front             = 0, ///< Leading engine of a train
-	Train_Articulated_Part  = 1, ///< Articulated part of an engine
-	Train_Wagon             = 2, ///< Wagon
-	Train_Engine            = 3, ///< Engine, that can be front engines, but might be placed behind another engine
-	Train_Free_Wagon        = 4, ///< First in a wagon chain (in depot)
-	Train_Multiheaded       = 5, ///< Engine is a multiheaded
+	TS_FRONT             = 0, ///< Leading engine of a train
+	TS_ARTICULATED_PART  = 1, ///< Articulated part of an engine
+	TS_WAGON             = 2, ///< Wagon
+	TS_ENGINE            = 3, ///< Engine, that can be front engines, but might be placed behind another engine
+	TS_FREE_WAGON        = 4, ///< First in a wagon chain (in depot)
+	TS_MULTIHEADED       = 5, ///< Engine is a multiheaded
 };
 
 
@@ -33,7 +33,7 @@
 static inline bool IsFrontEngine(const Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	return HasBit(v->subtype, Train_Front);
+	return HasBit(v->subtype, TS_FRONT);
 }
 
 /** Set front engine state
@@ -42,7 +42,7 @@
 static inline void SetFrontEngine(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	SetBit(v->subtype, Train_Front);
+	SetBit(v->subtype, TS_FRONT);
 }
 
 /** Remove the front engine state
@@ -51,7 +51,7 @@
 static inline void ClearFrontEngine(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	ClrBit(v->subtype, Train_Front);
+	ClrBit(v->subtype, TS_FRONT);
 }
 
 /** Check if a vehicle is an articulated part of an engine
@@ -61,7 +61,7 @@
 static inline bool IsArticulatedPart(const Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	return HasBit(v->subtype, Train_Articulated_Part);
+	return HasBit(v->subtype, TS_ARTICULATED_PART);
 }
 
 /** Set a vehicle to be an articulated part
@@ -70,7 +70,7 @@
 static inline void SetArticulatedPart(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	SetBit(v->subtype, Train_Articulated_Part);
+	SetBit(v->subtype, TS_ARTICULATED_PART);
 }
 
 /** Clear a vehicle from being an articulated part
@@ -79,7 +79,7 @@
 static inline void ClearArticulatedPart(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	ClrBit(v->subtype, Train_Articulated_Part);
+	ClrBit(v->subtype, TS_ARTICULATED_PART);
 }
 
 /** Check if a vehicle is a wagon
@@ -89,7 +89,7 @@
 static inline bool IsTrainWagon(const Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	return HasBit(v->subtype, Train_Wagon);
+	return HasBit(v->subtype, TS_WAGON);
 }
 
 /** Set a vehicle to be a wagon
@@ -98,7 +98,7 @@
 static inline void SetTrainWagon(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	SetBit(v->subtype, Train_Wagon);
+	SetBit(v->subtype, TS_WAGON);
 }
 
 /** Clear wagon property
@@ -107,7 +107,7 @@
 static inline void ClearTrainWagon(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	ClrBit(v->subtype, Train_Wagon);
+	ClrBit(v->subtype, TS_WAGON);
 }
 
 /** Check if a vehicle is an engine (can be first in a train)
@@ -117,7 +117,7 @@
 static inline bool IsTrainEngine(const Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	return HasBit(v->subtype, Train_Engine);
+	return HasBit(v->subtype, TS_ENGINE);
 }
 
 /** Set engine status
@@ -126,7 +126,7 @@
 static inline void SetTrainEngine(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	SetBit(v->subtype, Train_Engine);
+	SetBit(v->subtype, TS_ENGINE);
 }
 
 /** Clear engine status
@@ -135,7 +135,7 @@
 static inline void ClearTrainEngine(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	ClrBit(v->subtype, Train_Engine);
+	ClrBit(v->subtype, TS_ENGINE);
 }
 
 /** Check if a vehicle is a free wagon (got no engine in front of it)
@@ -145,7 +145,7 @@
 static inline bool IsFreeWagon(const Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	return HasBit(v->subtype, Train_Free_Wagon);
+	return HasBit(v->subtype, TS_FREE_WAGON);
 }
 
 /** Set if a vehicle is a free wagon
@@ -154,7 +154,7 @@
 static inline void SetFreeWagon(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	SetBit(v->subtype, Train_Free_Wagon);
+	SetBit(v->subtype, TS_FREE_WAGON);
 }
 
 /** Clear a vehicle from being a free wagon
@@ -163,7 +163,7 @@
 static inline void ClearFreeWagon(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	ClrBit(v->subtype, Train_Free_Wagon);
+	ClrBit(v->subtype, TS_FREE_WAGON);
 }
 
 /** Check if a vehicle is a multiheaded engine
@@ -173,7 +173,7 @@
 static inline bool IsMultiheaded(const Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	return HasBit(v->subtype, Train_Multiheaded);
+	return HasBit(v->subtype, TS_MULTIHEADED);
 }
 
 /** Set if a vehicle is a multiheaded engine
@@ -182,7 +182,7 @@
 static inline void SetMultiheaded(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	SetBit(v->subtype, Train_Multiheaded);
+	SetBit(v->subtype, TS_MULTIHEADED);
 }
 
 /** Clear multiheaded engine property
@@ -191,7 +191,7 @@
 static inline void ClearMultiheaded(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	ClrBit(v->subtype, Train_Multiheaded);
+	ClrBit(v->subtype, TS_MULTIHEADED);
 }
 
 /** Check if an engine has an articulated part.
--- a/src/train_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/train_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -736,6 +736,7 @@
 			v->x_pos = x;
 			v->y_pos = y;
 			v->z_pos = GetSlopeZ(x, y);
+			v->running_ticks = 0;
 			v->u.rail.track = TRACK_BIT_DEPOT;
 			v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
 			v->spritenum = rvi->image_index;
@@ -994,7 +995,7 @@
 	if (HasBit(p2, 0) && src_head == dst_head) return CommandCost();
 
 	{
-		int max_len = _patches.mammoth_trains ? 100 : 9;
+		int max_len = _patches.mammoth_trains ? 100 : 10;
 
 		/* check if all vehicles in the source train are stopped inside a depot. */
 		int src_len = CheckTrainStoppedInDepot(src_head);
@@ -1445,7 +1446,7 @@
 				 * up on a new line to be added to the newly built loco. Replace it is.
 				 * Totally braindead cause building a new engine adds all loco-less
 				 * engines to its train anyways */
-				if (p2 == 2 && HasBit(ori_subtype, Train_Front)) {
+				if (p2 == 2 && HasBit(ori_subtype, TS_FRONT)) {
 					Vehicle *tmp;
 					for (v = first; v != NULL; v = tmp) {
 						tmp = GetNextVehicle(v);
@@ -1544,7 +1545,7 @@
 	EndVehicleMove(v);
 }
 
-static void SetLastSpeed(Vehicle* v, int spd)
+static inline void SetLastSpeed(Vehicle* v, int spd)
 {
 	int old = v->u.rail.last_speed;
 	if (spd != old) {
@@ -1667,7 +1668,7 @@
 {
 	assert(IsLevelCrossingTile(tile));
 
-	DiagDirection dir = AxisToDiagDir(OtherAxis(GetCrossingRoadAxis(tile)));
+	DiagDirection dir = AxisToDiagDir(GetCrossingRailAxis(tile));
 	TileIndex tile_from = tile + TileOffsByDiagDir(dir);
 
 	Vehicle *v = (Vehicle *)VehicleFromPos(tile_from, &tile, &TrainApproachingCrossingEnum);
@@ -2001,7 +2002,7 @@
 
 	TrainFindDepotData tfdd;
 	tfdd.owner = v->owner;
-	tfdd.best_length = (uint)-1;
+	tfdd.best_length = UINT_MAX;
 	tfdd.reverse = false;
 
 	TileIndex tile = v->tile;
@@ -2011,36 +2012,43 @@
 		return tfdd;
 	}
 
-	if (_patches.yapf.rail_use_yapf) {
-		bool found = YapfFindNearestRailDepotTwoWay(v, max_distance, NPF_INFINITE_PENALTY, &tfdd.tile, &tfdd.reverse);
-		tfdd.best_length = found ? max_distance / 2 : -1; // some fake distance or NOT_FOUND
-	} else if (_patches.new_pathfinding_all) {
-		Vehicle* last = GetLastVehicleInChain(v);
-		Trackdir trackdir = GetVehicleTrackdir(v);
-		Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last));
-
-		assert(trackdir != INVALID_TRACKDIR);
-		NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY);
-		if (ftd.best_bird_dist == 0) {
-			/* Found target */
-			tfdd.tile = ftd.node.tile;
-			/* Our caller expects a number of tiles, so we just approximate that
-			 * number by this. It might not be completely what we want, but it will
-			 * work for now :-) We can possibly change this when the old pathfinder
-			 * is removed. */
-			tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH;
-			if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true;
-		}
-	} else {
-		/* search in the forward direction first. */
-		DiagDirection i = TrainExitDir(v->direction, v->u.rail.track);
-		NewTrainPathfind(tile, 0, v->u.rail.compatible_railtypes, i, (NTPEnumProc*)NtpCallbFindDepot, &tfdd);
-		if (tfdd.best_length == (uint)-1){
-			tfdd.reverse = true;
-			/* search in backwards direction */
-			i = TrainExitDir(ReverseDir(v->direction), v->u.rail.track);
+	switch (_patches.pathfinder_for_trains) {
+		case VPF_YAPF: { /* YAPF */
+			bool found = YapfFindNearestRailDepotTwoWay(v, max_distance, NPF_INFINITE_PENALTY, &tfdd.tile, &tfdd.reverse);
+			tfdd.best_length = found ? max_distance / 2 : UINT_MAX; // some fake distance or NOT_FOUND
+		} break;
+
+		case VPF_NPF: { /* NPF */
+			Vehicle* last = GetLastVehicleInChain(v);
+			Trackdir trackdir = GetVehicleTrackdir(v);
+			Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last));
+
+			assert(trackdir != INVALID_TRACKDIR);
+			NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, last->tile, trackdir_rev, false, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY);
+			if (ftd.best_bird_dist == 0) {
+				/* Found target */
+				tfdd.tile = ftd.node.tile;
+				/* Our caller expects a number of tiles, so we just approximate that
+				* number by this. It might not be completely what we want, but it will
+				* work for now :-) We can possibly change this when the old pathfinder
+				* is removed. */
+				tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH;
+				if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true;
+			}
+		} break;
+
+		default:
+		case VPF_NTP: { /* NTP */
+			/* search in the forward direction first. */
+			DiagDirection i = TrainExitDir(v->direction, v->u.rail.track);
 			NewTrainPathfind(tile, 0, v->u.rail.compatible_railtypes, i, (NTPEnumProc*)NtpCallbFindDepot, &tfdd);
-		}
+			if (tfdd.best_length == UINT_MAX){
+				tfdd.reverse = true;
+				/* search in backwards direction */
+				i = TrainExitDir(ReverseDir(v->direction), v->u.rail.track);
+				NewTrainPathfind(tile, 0, v->u.rail.compatible_railtypes, i, (NTPEnumProc*)NtpCallbFindDepot, &tfdd);
+			}
+		} break;
 	}
 
 	return tfdd;
@@ -2203,7 +2211,7 @@
 	if (sound) PlayVehicleSound(u, VSE_TRAIN_EFFECT);
 }
 
-static void TrainPlayLeaveStationSound(const Vehicle* v)
+void Train::PlayLeaveStationSound() const
 {
 	static const SoundFx sfx[] = {
 		SND_04_TRAIN,
@@ -2213,15 +2221,10 @@
 		SND_41_MAGLEV
 	};
 
-	if (PlayVehicleSound(v, VSE_START)) return;
-
-	EngineID engtype = v->engine_type;
-	SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v);
-}
-
-void Train::PlayLeaveStationSound() const
-{
-	TrainPlayLeaveStationSound(this);
+	if (PlayVehicleSound(this, VSE_START)) return;
+
+	EngineID engtype = this->engine_type;
+	SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], this);
 }
 
 static bool CheckTrainStayInDepot(Vehicle *v)
@@ -2254,7 +2257,7 @@
 
 	VehicleServiceInDepot(v);
 	InvalidateWindowClasses(WC_TRAINS_LIST);
-	TrainPlayLeaveStationSound(v);
+	v->PlayLeaveStationSound();
 
 	v->u.rail.track = TRACK_BIT_X;
 	if (v->direction & 2) v->u.rail.track = TRACK_BIT_Y;
@@ -2364,68 +2367,76 @@
 	/* quick return in case only one possible track is available */
 	if (KillFirstBit(tracks) == TRACK_BIT_NONE) return FindFirstTrack(tracks);
 
-	if (_patches.yapf.rail_use_yapf) {
-		Trackdir trackdir = YapfChooseRailTrack(v, tile, enterdir, tracks, &path_not_found);
-		if (trackdir != INVALID_TRACKDIR) {
-			best_track = TrackdirToTrack(trackdir);
-		} else {
-			best_track = FindFirstTrack(tracks);
-		}
-	} else if (_patches.new_pathfinding_all) { /* Use a new pathfinding for everything */
-		void* perf = NpfBeginInterval();
-
-		NPFFindStationOrTileData fstd;
-		NPFFillWithOrderData(&fstd, v);
-		/* The enterdir for the new tile, is the exitdir for the old tile */
-		Trackdir trackdir = GetVehicleTrackdir(v);
-		assert(trackdir != 0xff);
-
-		NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes);
-
-		if (ftd.best_trackdir == 0xff) {
-			/* We are already at our target. Just do something
-			 * @todo maybe display error?
-			 * @todo: go straight ahead if possible? */
-			best_track = FindFirstTrack(tracks);
-		} else {
-			/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
-			the direction we need to take to get there, if ftd.best_bird_dist is not 0,
-			we did not find our target, but ftd.best_trackdir contains the direction leading
-			to the tile closest to our target. */
-			if (ftd.best_bird_dist != 0) path_not_found = true;
-			/* Discard enterdir information, making it a normal track */
-			best_track = TrackdirToTrack(ftd.best_trackdir);
-		}
-
-		int time = NpfEndInterval(perf);
-		DEBUG(yapf, 4, "[NPFT] %d us - %d rounds - %d open - %d closed -- ", time, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
-	} else {
-		void* perf = NpfBeginInterval();
-
-		TrainTrackFollowerData fd;
-		FillWithStationData(&fd, v);
-
-		/* New train pathfinding */
-		fd.best_bird_dist = (uint)-1;
-		fd.best_track_dist = (uint)-1;
-		fd.best_track = INVALID_TRACKDIR;
-
-		NewTrainPathfind(tile - TileOffsByDiagDir(enterdir), v->dest_tile,
-			v->u.rail.compatible_railtypes, enterdir, (NTPEnumProc*)NtpCallbFindStation, &fd);
-
-		/* check whether the path was found or only 'guessed' */
-		if (fd.best_bird_dist != 0) path_not_found = true;
-
-		if (fd.best_track == 0xff) {
-			/* blaha */
-			best_track = FindFirstTrack(tracks);
-		} else {
-			best_track = TrackdirToTrack(fd.best_track);
-		}
-
-		int time = NpfEndInterval(perf);
-		DEBUG(yapf, 4, "[NTPT] %d us - %d rounds - %d open - %d closed -- ", time, 0, 0, 0);
+	switch (_patches.pathfinder_for_trains) {
+		case VPF_YAPF: { /* YAPF */
+			Trackdir trackdir = YapfChooseRailTrack(v, tile, enterdir, tracks, &path_not_found);
+			if (trackdir != INVALID_TRACKDIR) {
+				best_track = TrackdirToTrack(trackdir);
+			} else {
+				best_track = FindFirstTrack(tracks);
+			}
+		} break;
+
+		case VPF_NPF: { /* NPF */
+			void *perf = NpfBeginInterval();
+
+			NPFFindStationOrTileData fstd;
+			NPFFillWithOrderData(&fstd, v);
+			/* The enterdir for the new tile, is the exitdir for the old tile */
+			Trackdir trackdir = GetVehicleTrackdir(v);
+			assert(trackdir != INVALID_TRACKDIR);
+
+			NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes);
+
+			if (ftd.best_trackdir == INVALID_TRACKDIR) {
+				/* We are already at our target. Just do something
+				 * @todo maybe display error?
+				 * @todo: go straight ahead if possible? */
+				best_track = FindFirstTrack(tracks);
+			} else {
+				/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
+				 * the direction we need to take to get there, if ftd.best_bird_dist is not 0,
+				 * we did not find our target, but ftd.best_trackdir contains the direction leading
+				 * to the tile closest to our target. */
+				if (ftd.best_bird_dist != 0) path_not_found = true;
+				/* Discard enterdir information, making it a normal track */
+				best_track = TrackdirToTrack(ftd.best_trackdir);
+			}
+
+			int time = NpfEndInterval(perf);
+			DEBUG(yapf, 4, "[NPFT] %d us - %d rounds - %d open - %d closed -- ", time, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
+		} break;
+
+		default:
+		case VPF_NTP: { /* NTP */
+			void *perf = NpfBeginInterval();
+
+			TrainTrackFollowerData fd;
+			FillWithStationData(&fd, v);
+
+			/* New train pathfinding */
+			fd.best_bird_dist = UINT_MAX;
+			fd.best_track_dist = UINT_MAX;
+			fd.best_track = INVALID_TRACKDIR;
+
+			NewTrainPathfind(tile - TileOffsByDiagDir(enterdir), v->dest_tile,
+				v->u.rail.compatible_railtypes, enterdir, (NTPEnumProc*)NtpCallbFindStation, &fd);
+
+			/* check whether the path was found or only 'guessed' */
+			if (fd.best_bird_dist != 0) path_not_found = true;
+
+			if (fd.best_track == INVALID_TRACKDIR) {
+				/* blaha */
+				best_track = FindFirstTrack(tracks);
+			} else {
+				best_track = TrackdirToTrack(fd.best_track);
+			}
+
+			int time = NpfEndInterval(perf);
+			DEBUG(yapf, 4, "[NTPT] %d us - %d rounds - %d open - %d closed -- ", time, 0, 0, 0);
+		} break;
 	}
+
 	/* handle "path not found" state */
 	if (path_not_found) {
 		/* PF didn't find the route */
@@ -2475,81 +2486,87 @@
 
 	int i = _search_directions[FIND_FIRST_BIT(v->u.rail.track)][DirToDiagDir(v->direction)];
 
-	if (_patches.yapf.rail_use_yapf) {
-		reverse_best = YapfCheckReverseTrain(v);
-	} else if (_patches.new_pathfinding_all) { /* Use a new pathfinding for everything */
-		NPFFindStationOrTileData fstd;
-		NPFFoundTargetData ftd;
-		Trackdir trackdir, trackdir_rev;
-		Vehicle* last = GetLastVehicleInChain(v);
-
-		NPFFillWithOrderData(&fstd, v);
-
-		trackdir = GetVehicleTrackdir(v);
-		trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last));
-		assert(trackdir != 0xff);
-		assert(trackdir_rev != 0xff);
-
-		ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes);
-		if (ftd.best_bird_dist != 0) {
-			/* We didn't find anything, just keep on going straight ahead */
-			reverse_best = false;
-		} else {
-			if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) {
-				reverse_best = true;
+	switch (_patches.pathfinder_for_trains) {
+		case VPF_YAPF: { /* YAPF */
+			reverse_best = YapfCheckReverseTrain(v);
+		} break;
+
+		case VPF_NPF: { /* NPF */
+			NPFFindStationOrTileData fstd;
+			NPFFoundTargetData ftd;
+			Vehicle* last = GetLastVehicleInChain(v);
+
+			NPFFillWithOrderData(&fstd, v);
+
+			Trackdir trackdir = GetVehicleTrackdir(v);
+			Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last));
+			assert(trackdir != INVALID_TRACKDIR);
+			assert(trackdir_rev != INVALID_TRACKDIR);
+
+			ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, false, last->tile, trackdir_rev, false, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes);
+			if (ftd.best_bird_dist != 0) {
+				/* We didn't find anything, just keep on going straight ahead */
+				reverse_best = false;
 			} else {
-				reverse_best = false;
+				if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) {
+					reverse_best = true;
+				} else {
+					reverse_best = false;
+				}
 			}
-		}
-	} else {
-		int best_track = -1;
-		uint reverse = 0;
-		uint best_bird_dist  = 0;
-		uint best_track_dist = 0;
-
-		for (;;) {
-			fd.best_bird_dist = (uint)-1;
-			fd.best_track_dist = (uint)-1;
-
-			NewTrainPathfind(v->tile, v->dest_tile, v->u.rail.compatible_railtypes, (DiagDirection)(reverse ^ i), (NTPEnumProc*)NtpCallbFindStation, &fd);
-
-			if (best_track != -1) {
-				if (best_bird_dist != 0) {
-					if (fd.best_bird_dist != 0) {
-						/* neither reached the destination, pick the one with the smallest bird dist */
-						if (fd.best_bird_dist > best_bird_dist) goto bad;
-						if (fd.best_bird_dist < best_bird_dist) goto good;
+		} break;
+
+		default:
+		case VPF_NTP: { /* NTP */
+			int best_track = -1;
+			uint reverse = 0;
+			uint best_bird_dist  = 0;
+			uint best_track_dist = 0;
+
+			for (;;) {
+				fd.best_bird_dist = UINT_MAX;
+				fd.best_track_dist = UINT_MAX;
+
+				NewTrainPathfind(v->tile, v->dest_tile, v->u.rail.compatible_railtypes, (DiagDirection)(reverse ^ i), (NTPEnumProc*)NtpCallbFindStation, &fd);
+
+				if (best_track != -1) {
+					if (best_bird_dist != 0) {
+						if (fd.best_bird_dist != 0) {
+							/* neither reached the destination, pick the one with the smallest bird dist */
+							if (fd.best_bird_dist > best_bird_dist) goto bad;
+							if (fd.best_bird_dist < best_bird_dist) goto good;
+						} else {
+							/* we found the destination for the first time */
+							goto good;
+						}
 					} else {
-						/* we found the destination for the first time */
-						goto good;
+						if (fd.best_bird_dist != 0) {
+							/* didn't find destination, but we've found the destination previously */
+							goto bad;
+						} else {
+							/* both old & new reached the destination, compare track length */
+							if (fd.best_track_dist > best_track_dist) goto bad;
+							if (fd.best_track_dist < best_track_dist) goto good;
+						}
 					}
-				} else {
-					if (fd.best_bird_dist != 0) {
-						/* didn't find destination, but we've found the destination previously */
-						goto bad;
-					} else {
-						/* both old & new reached the destination, compare track length */
-						if (fd.best_track_dist > best_track_dist) goto bad;
-						if (fd.best_track_dist < best_track_dist) goto good;
-					}
+
+					/* if we reach this position, there's two paths of equal value so far.
+					 * pick one randomly. */
+					int r = GB(Random(), 0, 8);
+					if (_pick_track_table[i] == (v->direction & 3)) r += 80;
+					if (_pick_track_table[best_track] == (v->direction & 3)) r -= 80;
+					if (r <= 127) goto bad;
 				}
-
-				/* if we reach this position, there's two paths of equal value so far.
-				 * pick one randomly. */
-				int r = GB(Random(), 0, 8);
-				if (_pick_track_table[i] == (v->direction & 3)) r += 80;
-				if (_pick_track_table[best_track] == (v->direction & 3)) r -= 80;
-				if (r <= 127) goto bad;
+good:;
+				best_track = i;
+				best_bird_dist = fd.best_bird_dist;
+				best_track_dist = fd.best_track_dist;
+				reverse_best = reverse;
+bad:;
+				if (reverse != 0) break;
+				reverse = 2;
 			}
-good:;
-			best_track = i;
-			best_bird_dist = fd.best_bird_dist;
-			best_track_dist = fd.best_track_dist;
-			reverse_best = reverse;
-bad:;
-			if (reverse != 0) break;
-			reverse = 2;
-		}
+		} break;
 	}
 
 	return reverse_best != 0;
@@ -2755,7 +2772,7 @@
 	DIR_E , DIR_SE, DIR_S
 };
 
-static Direction GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile)
+static inline Direction GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile)
 {
 	uint offs = (TileY(new_tile) - TileY(old_tile) + 1) * 4 +
 							TileX(new_tile) - TileX(old_tile) + 1;
@@ -2763,7 +2780,7 @@
 	return _new_vehicle_direction_table[offs];
 }
 
-static int GetDirectionToVehicle(const Vehicle *v, int x, int y)
+static inline int GetDirectionToVehicle(const Vehicle *v, int x, int y)
 {
 	byte offs;
 
@@ -2786,7 +2803,7 @@
 }
 
 /* Check if the vehicle is compatible with the specified tile */
-static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
+static inline bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
 {
 	return
 		IsTileOwner(tile, v->owner) && (
@@ -2810,7 +2827,7 @@
 };
 
 /** Modify the speed of the vehicle due to a turn */
-static void AffectSpeedByDirChange(Vehicle* v, Direction new_dir)
+static inline void AffectSpeedByDirChange(Vehicle* v, Direction new_dir)
 {
 	if (_patches.realistic_acceleration) return;
 
@@ -2822,7 +2839,7 @@
 }
 
 /** Modify the speed of the vehicle due to a change in altitude */
-static void AffectSpeedByZChange(Vehicle *v, byte old_z)
+static inline void AffectSpeedByZChange(Vehicle *v, byte old_z)
 {
 	if (old_z == v->z_pos || _patches.realistic_acceleration) return;
 
@@ -3025,14 +3042,12 @@
 
 				/* Get the status of the tracks in the new tile and mask
 				 * away the bits that aren't reachable. */
-				uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL, 0) & _reachable_tracks[enterdir];
-
-				/* Combine the from & to directions.
-				 * Now, the lower byte contains the track status, and the byte at bit 16 contains
-				 * the signal status. */
-				uint32 tracks = ts | (ts >> 8);
-				TrackBits bits = (TrackBits)(tracks & TRACK_BIT_MASK);
-				if ((_patches.new_pathfinding_all || _patches.yapf.rail_use_yapf) && _patches.forbid_90_deg && prev == NULL) {
+				TrackStatus ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL, 0, ReverseDiagDir(enterdir)) & _reachable_tracks[enterdir];
+				TrackdirBits trackdirbits = TrackStatusToTrackdirBits(ts);
+				TrackBits red_signals = TrackdirBitsToTrackBits(TrackStatusToRedSignals(ts));
+
+				TrackBits bits = TrackdirBitsToTrackBits(trackdirbits);
+				if (_patches.pathfinder_for_trains != VPF_NTP && _patches.forbid_90_deg && prev == NULL) {
 					/* We allow wagons to make 90 deg turns, because forbid_90_deg
 					 * can be switched on halfway a turn */
 					bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track));
@@ -3049,14 +3064,12 @@
 					/* Currently the locomotive is active. Determine which one of the
 					 * available tracks to choose */
 					chosen_track = TrackToTrackBits(ChooseTrainTrack(v, gp.new_tile, enterdir, bits));
-					assert(chosen_track & tracks);
+					assert(chosen_track & bits);
 
 					/* Check if it's a red signal and that force proceed is not clicked. */
-					if ((tracks >> 16) & chosen_track && v->u.rail.force_proceed == 0) {
-						/* In front of a red signal
-						 * find the first set bit in ts. need to do it in 2 steps, since
-						 * FIND_FIRST_BIT only handles 6 bits at a time. */
-						Trackdir i = FindFirstTrackdir((TrackdirBits)(uint16)ts);
+					if (red_signals & chosen_track && v->u.rail.force_proceed == 0) {
+						/* In front of a red signal */
+						Trackdir i = FindFirstTrackdir(trackdirbits);
 
 						if (!HasSignalOnTrackdir(gp.new_tile, ReverseTrackdir(i))) {
 							v->cur_speed = 0;
@@ -3134,7 +3147,7 @@
 			 * - 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);
+					min(v->cur_speed, GetBridgeSpec(GetBridgeType(v->tile))->speed);
 			}
 
 			if (!IsTileType(gp.new_tile, MP_TUNNELBRIDGE) || !HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
@@ -3422,9 +3435,9 @@
 	DiagDirection dir = TrainExitDir(v->direction, v->u.rail.track);
 	TileIndex tile = v->tile + TileOffsByDiagDir(dir);
 
-	/* not a crossing || wrong axis || wrong railtype || wrong owner */
+	/* not a crossing || wrong axis || unusable rail (wrong type or owner) */
 	if (!IsLevelCrossingTile(tile) || DiagDirToAxis(dir) == GetCrossingRoadAxis(tile) ||
-			!CheckCompatibleRail(v, tile) || GetTileOwner(tile) != v->owner) {
+			!CheckCompatibleRail(v, tile)) {
 		return INVALID_TILE;
 	}
 
@@ -3460,20 +3473,25 @@
 	TileIndex tile = v->tile + TileOffsByDiagDir(dir);
 
 	/* Determine the track status on the next tile */
-	uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _reachable_tracks[dir];
+	TrackStatus ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0, ReverseDiagDir(dir)) & _reachable_tracks[dir];
+	TrackdirBits trackdirbits = TrackStatusToTrackdirBits(ts);
+	TrackdirBits red_signals = TrackStatusToRedSignals(ts);
 
 	/* We are sure the train is not entering a depot, it is detected above */
 
-	/* no suitable trackbits at all || wrong railtype || not our track ||
-	 *   tunnel/bridge from opposite side || depot from opposite side */
-	if (GB(ts, 0, 16) == 0 || !CheckCompatibleRail(v, tile) || GetTileOwner(tile) != v->owner ||
-			(IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(tile) != dir) ||
-			(IsTileDepotType(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) == dir) ) {
+	/* mask unreachable track bits if we are forbidden to do 90deg turns */
+	TrackBits bits = TrackdirBitsToTrackBits(trackdirbits);
+	if (_patches.pathfinder_for_trains != VPF_NTP && _patches.forbid_90_deg) {
+		bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track));
+	}
+
+	/* no suitable trackbits at all || unusable rail (wrong type or owner) */
+	if (bits == TRACK_BIT_NONE || !CheckCompatibleRail(v, tile)) {
 		return TrainApproachingLineEnd(v, false);
 	}
 
 	/* approaching red signal */
-	if ((ts & (ts >> 16)) != 0) return TrainApproachingLineEnd(v, true);
+	if ((trackdirbits & red_signals) != 0) return TrainApproachingLineEnd(v, true);
 
 	/* approaching a rail/road crossing? then make it red */
 	if (IsLevelCrossingTile(tile)) MaybeBarCrossingWithSound(tile);
@@ -3558,10 +3576,10 @@
 	do {
 		const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
 
-		byte cost_factor = GetVehicleProperty(v, 0x0D, rvi->running_cost_base);
+		byte cost_factor = GetVehicleProperty(v, 0x0D, rvi->running_cost);
 		if (cost_factor == 0) continue;
 
-		cost += cost_factor * _price.running_rail[rvi->running_cost_class];
+		cost += cost_factor * GetPriceByIndex(rvi->running_cost_class);
 	} while ((v = GetNextVehicle(v)) != NULL);
 
 	return cost;
@@ -3575,6 +3593,7 @@
 	this->tick_counter++;
 
 	if (IsFrontEngine(this)) {
+		if (!(this->vehstatus & VS_STOPPED)) this->running_ticks++;
 		this->current_order_time++;
 
 		TrainLocoHandler(this, false);
@@ -3645,11 +3664,12 @@
 			if (tile != 0) this->dest_tile = tile;
 		}
 
-		if ((this->vehstatus & VS_STOPPED) == 0) {
+		if (this->running_ticks != 0) {
 			/* running costs */
-			CommandCost cost(EXPENSES_TRAIN_RUN, this->GetRunningCost() / 364);
-
-			this->profit_this_year -= cost.GetCost() >> 8;
+			CommandCost cost(EXPENSES_TRAIN_RUN, this->GetRunningCost() * this->running_ticks / (364 * DAY_TICKS));
+
+			this->profit_this_year -= cost.GetCost();
+			this->running_ticks = 0;
 
 			SubtractMoneyFromPlayerFract(this->owner, cost);
 
@@ -3669,8 +3689,8 @@
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
 			/* show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
-			if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->profit_this_year < 0) {
-				SetDParam(1, v->profit_this_year);
+			if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
+				SetDParam(1, v->GetDisplayProfitThisYear());
 				SetDParam(0, v->unitnumber);
 				AddNewsItem(
 					STR_TRAIN_IS_UNPROFITABLE,
--- a/src/transparency.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/transparency.h	Fri Feb 22 00:25:54 2008 +0000
@@ -11,8 +11,6 @@
  * 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.
  * If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp.
- * If you add an option and have more then 8, change the typedef TransparencyOptionBits and
- * the save stuff (e.g. SLE_UINT8 to SLE_UINT16) in settings.cpp .
  */
 enum TransparencyOption {
 	TO_SIGNS = 0,  ///< signs
@@ -22,12 +20,14 @@
 	TO_BUILDINGS,  ///< player buildings - depots, stations, HQ, ...
 	TO_BRIDGES,    ///< bridges
 	TO_STRUCTURES, ///< unmovable structures
+	TO_CATENARY,   ///< catenary
 	TO_LOADING,    ///< loading indicators
 	TO_END,
 };
 
-typedef byte TransparencyOptionBits; ///< transparency option bits
+typedef uint TransparencyOptionBits; ///< transparency option bits
 extern TransparencyOptionBits _transparency_opt;
+extern TransparencyOptionBits _transparency_lock;
 
 /**
  * Check if the transparency option bit is set
@@ -43,26 +43,33 @@
 /**
  * Toggle the transparency option bit
  *
- * @param to the structure which transparency option is toggle
+ * @param to the transparency option to be toggled
  */
 static inline void ToggleTransparency(TransparencyOption to)
 {
 	ToggleBit(_transparency_opt, to);
 }
 
-/** Toggle all transparency options (except signs) or restore the stored transparencies */
+/**
+ * Toggle the transparency lock bit
+ *
+ * @param to the transparency option to be locked or unlocked
+ */
+static inline void ToggleTransparencyLock(TransparencyOption to)
+{
+	ToggleBit(_transparency_lock, to);
+}
+
+/** Set or clear all non-locked transparency options */
 static inline void ResetRestoreAllTransparency()
 {
-	/* backup of the original transparencies or if all transparencies false toggle them to true */
-	static TransparencyOptionBits trans_opt = ~0;
-
-	if (_transparency_opt == 0) {
-		/* no structure is transparent, so restore the old transparency if present otherwise set all true */
-		_transparency_opt = trans_opt;
+	/* if none of the non-locked options are set */
+	if ((_transparency_opt & ~_transparency_lock) == 0) {
+		/* set all non-locked options */
+		_transparency_opt |= ~_transparency_lock;
 	} else {
-		/* any structure is transparent, so store current transparency settings and reset it */
-		trans_opt = _transparency_opt;
-		_transparency_opt = 0;
+		/* clear all non-locked options */
+		_transparency_opt &= _transparency_lock;
 	}
 
 	MarkWholeScreenDirty();
--- a/src/transparency_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/transparency_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -12,18 +12,17 @@
 #include "table/strings.h"
 
 TransparencyOptionBits _transparency_opt;
+TransparencyOptionBits _transparency_lock;
 
 enum TransparencyToolbarWidgets{
-	/* Widgets not toggled when pressing the X key */
 	TTW_WIDGET_SIGNS = 3,    ///< Make signs background transparent
-
-	/* Widgets toggled when pressing the X key */
 	TTW_WIDGET_TREES,        ///< Make trees transparent
 	TTW_WIDGET_HOUSES,       ///< Make houses transparent
 	TTW_WIDGET_INDUSTRIES,   ///< Make Industries transparent
 	TTW_WIDGET_BUILDINGS,    ///< Make player buildings and structures transparent
 	TTW_WIDGET_BRIDGES,      ///< Make bridges transparent
 	TTW_WIDGET_STRUCTURES,   ///< Make unmovable structures transparent
+	TTW_WIDGET_CATENARY,     ///< Make catenary transparent
 	TTW_WIDGET_LOADING,      ///< Make loading indicators transperent
 	TTW_WIDGET_END,          ///< End of toggle buttons
 };
@@ -39,14 +38,23 @@
 			}
 
 			DrawWindowWidgets(w);
+			for (uint i = TO_SIGNS; i < TO_END; i++) {
+				if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[TTW_WIDGET_SIGNS + i].left + 1, w->widget[TTW_WIDGET_SIGNS + i].top + 1);
+			}
 			break;
 
 		case WE_CLICK:
-			if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
-				/* toggle the bit of the transparencies variable when clicking on a widget, and play a sound */
-				ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
-				SndPlayFx(SND_15_BEEP);
-				MarkWholeScreenDirty();
+			if (e->we.click.widget >= TTW_WIDGET_SIGNS && e->we.click.widget < TTW_WIDGET_END) {
+				if (_ctrl_pressed) {
+					/* toggle the bit of the transparencies lock variable */
+					ToggleTransparencyLock((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
+					SetWindowDirty(w);
+				} else {
+					/* toggle the bit of the transparencies variable and play a sound */
+					ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
+					SndPlayFx(SND_15_BEEP);
+					MarkWholeScreenDirty();
+				}
 			}
 			break;
 	}
@@ -54,8 +62,8 @@
 
 static const Widget _transparency_widgets[] = {
 { WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
-{  WWT_CAPTION,   RESIZE_NONE,  7,  11, 184,   0,  13, STR_TRANSPARENCY_TOOLB,   STR_018C_WINDOW_TITLE_DRAG_THIS},
-{WWT_STICKYBOX,   RESIZE_NONE,  7, 185, 196,   0,  13, STR_NULL,                 STR_STICKY_BUTTON},
+{  WWT_CAPTION,   RESIZE_NONE,  7,  11, 206,   0,  13, STR_TRANSPARENCY_TOOLB,   STR_018C_WINDOW_TITLE_DRAG_THIS},
+{WWT_STICKYBOX,   RESIZE_NONE,  7, 207, 218,   0,  13, STR_NULL,                 STR_STICKY_BUTTON},
 
 /* transparency widgets:
  * transparent signs, trees, houses, industries, player's buildings, bridges, unmovable structures and loading indicators */
@@ -66,13 +74,14 @@
 {   WWT_IMGBTN,   RESIZE_NONE,  7,  88, 109,  14,  35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC},
 {   WWT_IMGBTN,   RESIZE_NONE,  7, 110, 152,  14,  35, SPR_IMG_BRIDGE,       STR_TRANSPARENT_BRIDGES_DESC},
 {   WWT_IMGBTN,   RESIZE_NONE,  7, 153, 174,  14,  35, SPR_IMG_TRANSMITTER,  STR_TRANSPARENT_STRUCTURES_DESC},
-{   WWT_IMGBTN,   RESIZE_NONE,  7, 175, 196,  14,  35, SPR_IMG_TRAINLIST,    STR_TRANSPARENT_LOADING_DESC},
+{   WWT_IMGBTN,   RESIZE_NONE,  7, 175, 196,  14,  35, SPR_BUILD_X_ELRAIL,   STR_TRANSPARENT_CATENARY_DESC},
+{   WWT_IMGBTN,   RESIZE_NONE,  7, 197, 218,  14,  35, SPR_IMG_TRAINLIST,    STR_TRANSPARENT_LOADING_DESC},
 
 {   WIDGETS_END},
 };
 
 static const WindowDesc _transparency_desc = {
-	WDP_ALIGN_TBR, 58+36, 197, 36, 197, 36,
+	WDP_ALIGN_TBR, 58+36, 219, 36, 219, 36,
 	WC_TRANSPARENCY_TOOLBAR, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
 	_transparency_widgets,
--- a/src/tree_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/tree_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -435,10 +435,6 @@
 
 static void DrawTile_Trees(TileInfo *ti)
 {
-	const PalSpriteID *s;
-	const TreePos* d;
-	byte z;
-
 	switch (GetTreeGround(ti->tile)) {
 		case TREE_GROUND_SHORE: DrawShoreTile(ti->tileh); break;
 		case TREE_GROUND_GRASS: DrawClearLandTile(ti, GetTreeDensity(ti->tile)); break;
@@ -448,77 +444,70 @@
 
 	DrawClearLandFence(ti);
 
-	z = ti->z;
-	if (ti->tileh != SLOPE_FLAT) {
-		z += 4;
-		if (IsSteepSlope(ti->tileh)) z += 4;
+	/* Do not draw trees when the invisible trees patch and transparency tree are set */
+	if (IsTransparencySet(TO_TREES) && _patches.invisible_trees) return;
+
+	uint16 tmp = ti->x;
+
+	tmp = ROR(tmp, 2);
+	tmp -= ti->y;
+	tmp = ROR(tmp, 3);
+	tmp -= ti->x;
+	tmp = ROR(tmp, 1);
+	tmp += ti->y;
+
+	uint index = GB(tmp, 6, 2) + (GetTreeType(ti->tile) << 2);
+
+	/* different tree styles above one of the grounds */
+	if (GetTreeGround(ti->tile) == TREE_GROUND_SNOW_DESERT &&
+			GetTreeDensity(ti->tile) >= 2 &&
+			IsInsideMM(index, TREE_SUB_ARCTIC << 2, TREE_RAINFOREST << 2)) {
+		index += 164 - (TREE_SUB_ARCTIC << 2);
 	}
 
-	{
-		uint16 tmp = ti->x;
-		uint index;
-
-		tmp = ROR(tmp, 2);
-		tmp -= ti->y;
-		tmp = ROR(tmp, 3);
-		tmp -= ti->x;
-		tmp = ROR(tmp, 1);
-		tmp += ti->y;
-
-		d = _tree_layout_xy[GB(tmp, 4, 2)];
+	assert(index < lengthof(_tree_layout_sprite));
 
-		index = GB(tmp, 6, 2) + (GetTreeType(ti->tile) << 2);
+	const PalSpriteID *s = _tree_layout_sprite[index];
+	const TreePos *d = _tree_layout_xy[GB(tmp, 4, 2)];
 
-		/* different tree styles above one of the grounds */
-		if (GetTreeGround(ti->tile) == TREE_GROUND_SNOW_DESERT &&
-				GetTreeDensity(ti->tile) >= 2 &&
-				IsInsideMM(index, TREE_SUB_ARCTIC << 2, TREE_RAINFOREST << 2)) {
-			index += 164 - (TREE_SUB_ARCTIC << 2);
-		}
-
-		assert(index < lengthof(_tree_layout_sprite));
-		s = _tree_layout_sprite[index];
-	}
-
+	/* combine trees into one sprite object */
 	StartSpriteCombine();
 
-	/* Do not draw trees when the invisible trees patch and transparency tree are set */
-	if (!(IsTransparencySet(TO_TREES) && _patches.invisible_trees)) {
-		TreeListEnt te[4];
-		uint i;
-
-		/* put the trees to draw in a list */
-		i = GetTreeCount(ti->tile) + 1;
-		do {
-			SpriteID image = s[0].sprite + (--i == 0 ? GetTreeGrowth(ti->tile) : 3);
-			SpriteID pal = s[0].pal;
+	TreeListEnt te[4];
 
-			te[i].image = image;
-			te[i].pal   = pal;
-			te[i].x = d->x;
-			te[i].y = d->y;
-			s++;
-			d++;
-		} while (i);
-
-		/* draw them in a sorted way */
-		for (;;) {
-			byte min = 0xFF;
-			TreeListEnt *tep = NULL;
+	/* put the trees to draw in a list */
+	uint trees = GetTreeCount(ti->tile) + 1;
 
-			i = GetTreeCount(ti->tile) + 1;
-			do {
-				if (te[--i].image != 0 && te[i].x + te[i].y < min) {
-					min = te[i].x + te[i].y;
-					tep = &te[i];
-				}
-			} while (i);
+	for (uint i = 0; i < trees; i++) {
+		SpriteID image = s[0].sprite + (i == trees - 1 ? GetTreeGrowth(ti->tile) : 3);
+		SpriteID pal = s[0].pal;
 
-			if (tep == NULL) break;
+		te[i].image = image;
+		te[i].pal   = pal;
+		te[i].x = d->x;
+		te[i].y = d->y;
+		s++;
+		d++;
+	}
 
-			AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 16 - tep->x, 16 - tep->y, 0x30, z, IsTransparencySet(TO_TREES), -tep->x, -tep->y);
-			tep->image = 0;
+	/* draw them in a sorted way */
+	byte z = ti->z + GetSlopeMaxZ(ti->tileh) / 2;
+
+	for (; trees > 0; trees--) {
+		uint min = te[0].x + te[0].y;
+		uint mi = 0;
+
+		for (uint i = 1; i < trees; i++) {
+			if ((uint)(te[i].x + te[i].y) < min) {
+				min = te[i].x + te[i].y;
+				mi = i;
+			}
 		}
+
+		AddSortableSpriteToDraw(te[mi].image, te[mi].pal, ti->x + te[mi].x, ti->y + te[mi].y, 16 - te[mi].x, 16 - te[mi].y, 0x30, z, IsTransparencySet(TO_TREES), -te[mi].x, -te[mi].y);
+
+		/* replace the removed one with the last one */
+		te[mi] = te[trees - 1];
 	}
 
 	EndSpriteCombine();
@@ -758,7 +747,7 @@
 	/* not used */
 }
 
-static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
 	return 0;
 }
--- a/src/tunnelbridge_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/tunnelbridge_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -33,82 +33,30 @@
 #include "sound_func.h"
 #include "signal_func.h"
 #include "tunnelbridge.h"
+#include "player_base.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
 #include "table/bridge_land.h"
 
-
-/** Describes the data that defines each bridge in the game
- * @param y   year of availablity
- * @param mnl minimum length
- * @param mxl maximum length
- * @param p   price
- * @param mxs maximum speed allowed
- * @param spr sprite to use in purchase GUI
- * @param plt palette for the sprite in purchase GUI
- * @param dsc description of the bridge in purchase GUI
- * @param nrl description of the rail bridge in query tool
- * @param nrd description of the road bridge in query tool
- */
-#define MB(y, mnl, mxl, p, mxs, spr, plt, dsc, nrl, nrd) \
-	{y, mnl, mxl, p, mxs, spr, plt, dsc, nrl, nrd, NULL, 0}
-
-const Bridge orig_bridge[] = {
-/*
-	       year of availablity
-	       |  minimum length
-	       |  |   maximum length
-	       |  |   |    price
-	       |  |   |    |    maximum speed
-	       |  |   |    |    |  sprite to use in GUI
-	       |  |   |    |    |  |      palette in GUI
-	   string with description        name on rail                             name on road
-	   |                              |                                        | */
-	MB(    0, 0, 16,  80,  32, 0xA24, PAL_NONE,
-	   STR_5012_WOODEN,               STR_501F_WOODEN_RAIL_BRIDGE,             STR_5025_WOODEN_ROAD_BRIDGE),
-
-	MB(    0, 0,  2, 112,  48, 0xA26, PALETTE_TO_STRUCT_RED,
-	   STR_5013_CONCRETE,             STR_5020_CONCRETE_RAIL_BRIDGE,           STR_5026_CONCRETE_ROAD_BRIDGE),
+BridgeSpec _bridge[MAX_BRIDGES];
 
-	MB( 1930, 0,  5, 144,  64, 0xA25, PAL_NONE,
-	   STR_500F_GIRDER_STEEL,         STR_501C_STEEL_GIRDER_RAIL_BRIDGE,       STR_5022_STEEL_GIRDER_ROAD_BRIDGE),
-
-	MB(    0, 2, 10, 168,  80, 0xA22, PALETTE_TO_STRUCT_CONCRETE,
-	   STR_5011_SUSPENSION_CONCRETE,  STR_501E_REINFORCED_CONCRETE_SUSPENSION, STR_5024_REINFORCED_CONCRETE_SUSPENSION),
-
-	MB( 1930, 3, 16, 185,  96, 0xA22, PAL_NONE,
-	   STR_500E_SUSPENSION_STEEL,     STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE,   STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE),
-
-	MB( 1930, 3, 16, 192, 112, 0xA22, PALETTE_TO_STRUCT_YELLOW,
-	   STR_500E_SUSPENSION_STEEL,     STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE,   STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE),
-
-	MB( 1930, 3,  7, 224, 160, 0xA23, PAL_NONE,
-	   STR_5010_CANTILEVER_STEEL,     STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE,   STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
-
-	MB( 1930, 3,  8, 232, 208, 0xA23, PALETTE_TO_STRUCT_BROWN,
-	   STR_5010_CANTILEVER_STEEL,     STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE,   STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
+/** Reset the data been eventually changed by the grf loaded. */
+void ResetBridges()
+{
+	/* First, free sprite table data */
+	for (BridgeType i = 0; i < MAX_BRIDGES; i++) {
+		if (_bridge[i].sprite_table != NULL) {
+			for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]);
+			free(_bridge[i].sprite_table);
+		}
+	}
 
-	MB( 1930, 3,  9, 248, 240, 0xA23, PALETTE_TO_STRUCT_RED,
-	   STR_5010_CANTILEVER_STEEL,     STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE,   STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
-
-	MB( 1930, 0,  2, 240, 256, 0xA27, PAL_NONE,
-	   STR_500F_GIRDER_STEEL,         STR_501C_STEEL_GIRDER_RAIL_BRIDGE,       STR_5022_STEEL_GIRDER_ROAD_BRIDGE),
-
-	MB( 1995, 2, 16, 255, 320, 0xA28, PAL_NONE,
-	   STR_5014_TUBULAR_STEEL,        STR_5027_TUBULAR_RAIL_BRIDGE,            STR_5028_TUBULAR_ROAD_BRIDGE),
-
-	MB( 2005, 2, 32, 380, 512, 0xA28, PALETTE_TO_STRUCT_YELLOW,
-	   STR_5014_TUBULAR_STEEL,        STR_5027_TUBULAR_RAIL_BRIDGE,            STR_5028_TUBULAR_ROAD_BRIDGE),
-
-	MB( 2010, 2, 32, 510, 608, 0xA28, PALETTE_TO_STRUCT_GREY,
-	   STR_BRIDGE_TUBULAR_SILICON,    STR_5027_TUBULAR_RAIL_BRIDGE,            STR_5028_TUBULAR_ROAD_BRIDGE)
-};
-
-#undef MB
-
-Bridge _bridge[MAX_BRIDGES];
-
+	/* Then, wipe out current bidges */
+	memset(&_bridge, 0, sizeof(_bridge));
+	/* And finally, reinstall default data */
+	memcpy(&_bridge, &_orig_bridge, sizeof(_orig_bridge));
+}
 
 /** calculate the price factor for building a long bridge.
  * basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6,  7,7,7,7,7,7,7,  8,8,8,8,8,8,8,8,
@@ -152,7 +100,7 @@
 
 static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table)
 {
-	const Bridge *bridge = &_bridge[index];
+	const BridgeSpec *bridge = GetBridgeSpec(index);
 	assert(table < 7);
 	if (bridge->sprite_table == NULL || bridge->sprite_table[table] == NULL) {
 		return _bridge_sprite_table[index][table];
@@ -161,8 +109,6 @@
 	}
 }
 
-static inline byte GetBridgeFlags(int index) { return _bridge[index].flags;}
-
 
 /**
  * Determines the foundation for the north bridge head, and tests if the resulting slope is valid.
@@ -206,9 +152,9 @@
 	return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 }
 
-bool CheckBridge_Stuff(byte bridge_type, uint bridge_len)
+bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len)
 {
-	const Bridge *b = &_bridge[bridge_type];
+	const BridgeSpec *b = GetBridgeSpec(bridge_type);
 	uint max; // max possible length of a bridge (with patch 100)
 
 	if (bridge_type >= MAX_BRIDGES) return false;
@@ -231,9 +177,9 @@
  */
 CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	uint bridge_type;
-	RailType railtype;
-	RoadTypes roadtypes;
+	BridgeType bridge_type;
+	RailType railtype = INVALID_RAILTYPE;
+	RoadTypes roadtypes = ROADTYPES_NONE;
 	uint x;
 	uint y;
 	uint sx;
@@ -251,22 +197,32 @@
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 	CommandCost ret;
 	bool replace_bridge = false;
-	uint replaced_bridge_type;
+	BridgeType replaced_bridge_type;
+	TransportType transport_type;
 
 	/* unpack parameters */
 	bridge_type = GB(p2, 0, 8);
 
 	if (p1 >= MapSize()) return CMD_ERROR;
 
+	transport_type = (TransportType)GB(p2, 15, 2);
+
 	/* type of bridge */
-	if (HasBit(p2, 15)) {
-		railtype = INVALID_RAILTYPE; // road bridge
-		roadtypes = (RoadTypes)GB(p2, 8, 3);
-		if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_player, roadtypes)) return CMD_ERROR;
-	} else {
-		if (!ValParamRailtype((RailType)GB(p2, 8, 8))) return CMD_ERROR;
-		railtype = (RailType)GB(p2, 8, 8);
-		roadtypes = ROADTYPES_NONE;
+	switch (transport_type) {
+		case TRANSPORT_ROAD:
+			roadtypes = (RoadTypes)GB(p2, 8, 3);
+			if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_player, roadtypes)) return CMD_ERROR;
+			break;
+
+		case TRANSPORT_RAIL:
+			railtype = (RailType)GB(p2, 8, 8);
+			if (!ValParamRailtype(railtype)) return CMD_ERROR;
+			break;
+
+		default:
+			/* For now, only TRANSPORT_RAIL and TRANSPORT_ROAD are allowed.
+			 * But let not this stops us for preparing the future */
+			return CMD_ERROR;
 	}
 
 	x = TileX(end_tile);
@@ -301,12 +257,10 @@
 	tileh_end = GetTileSlope(tile_end, &z_end);
 
 	CommandCost terraform_cost_north = CheckBridgeSlopeNorth(direction, &tileh_start, &z_start);
-	CommandCost terraform_cost_south = CheckBridgeSlopeSouth(direction, &tileh_end, &z_end);
+	CommandCost terraform_cost_south = CheckBridgeSlopeSouth(direction, &tileh_end,   &z_end);
 
 	if (z_start != z_end) return_cmd_error(STR_BRIDGEHEADS_NOT_SAME_HEIGHT);
 
-	TransportType transport_type = railtype == INVALID_RAILTYPE ? TRANSPORT_ROAD : TRANSPORT_RAIL;
-
 	if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) &&
 			GetOtherBridgeEnd(tile_start) == tile_end &&
 			GetTunnelBridgeTransportType(tile_start) == transport_type) {
@@ -319,7 +273,7 @@
 
 		/* Do not replace town bridges with lower speed bridges. */
 		if (!(flags & DC_QUERY_COST) && IsTileOwner(tile_start, OWNER_TOWN) &&
-				_bridge[bridge_type].speed < _bridge[GetBridgeType(tile_start)].speed) {
+				GetBridgeSpec(bridge_type)->speed < GetBridgeSpec(GetBridgeType(tile_start))->speed) {
 			Town *t = ClosestTownFromTile(tile_start, UINT_MAX);
 
 			if (t == NULL) {
@@ -395,12 +349,20 @@
 		DiagDirection dir = AxisToDiagDir(direction);
 		Owner owner = (replace_bridge && IsTileOwner(tile_start, OWNER_TOWN)) ? OWNER_TOWN : _current_player;
 
-		if (railtype != INVALID_RAILTYPE) {
-			MakeRailBridgeRamp(tile_start, owner, bridge_type, dir, railtype);
-			MakeRailBridgeRamp(tile_end,   owner, bridge_type, ReverseDiagDir(dir), railtype);
-		} else {
-			MakeRoadBridgeRamp(tile_start, owner, bridge_type, dir, roadtypes);
-			MakeRoadBridgeRamp(tile_end,   owner, bridge_type, ReverseDiagDir(dir), roadtypes);
+		switch (transport_type) {
+			case TRANSPORT_RAIL:
+				MakeRailBridgeRamp(tile_start, owner, bridge_type, dir,                 railtype);
+				MakeRailBridgeRamp(tile_end,   owner, bridge_type, ReverseDiagDir(dir), railtype);
+				break;
+
+			case TRANSPORT_ROAD:
+				MakeRoadBridgeRamp(tile_start, owner, bridge_type, dir,                 roadtypes);
+				MakeRoadBridgeRamp(tile_end,   owner, bridge_type, ReverseDiagDir(dir), roadtypes);
+				break;
+
+			default:
+				NOT_REACHED();
+				break;
 		}
 		MarkTileDirtyByTile(tile_start);
 		MarkTileDirtyByTile(tile_end);
@@ -426,7 +388,7 @@
 				break;
 
 			case MP_ROAD:
-				if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) goto not_valid_below;
+				if (IsRoadDepot(tile)) goto not_valid_below;
 				break;
 
 			case MP_TUNNELBRIDGE:
@@ -458,7 +420,7 @@
 		}
 	}
 
-	if (flags & DC_EXEC && railtype != INVALID_RAILTYPE) {
+	if (flags & DC_EXEC && transport_type == TRANSPORT_RAIL) {
 		Track track = AxisToTrack(direction);
 		AddSideToSignalBuffer(tile_start, INVALID_DIAGDIR, _current_player);
 		YapfNotifyTrackLayoutChange(tile_start, track);
@@ -468,15 +430,13 @@
 	 * It's unnecessary to execute this command every time for every bridge. So it is done only
 	 * and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated
 	 */
-	if (!(flags & DC_QUERY_COST)) {
-		const Bridge *b = &_bridge[bridge_type];
-
+	if (!(flags & DC_QUERY_COST) || (IsValidPlayer(_current_player) && GetPlayer(_current_player)->is_ai)) {
 		bridge_len += 2; // begin and end tiles/ramps
 
 		if (IsValidPlayer(_current_player))
 			bridge_len = CalcBridgeLenCostFactor(bridge_len);
 
-		cost.AddCost((int64)bridge_len * _price.build_bridge * b->price >> 8);
+		cost.AddCost((int64)bridge_len * _price.build_bridge * GetBridgeSpec(bridge_type)->price >> 8);
 	}
 
 	return cost;
@@ -496,13 +456,14 @@
 	DiagDirection direction;
 	Slope start_tileh;
 	Slope end_tileh;
+	TransportType transport_type = (TransportType)GB(p1, 9, 1);
 	uint start_z;
 	uint end_z;
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 	CommandCost ret;
 
 	_build_tunnel_endtile = 0;
-	if (!HasBit(p1, 9)) {
+	if (transport_type == TRANSPORT_RAIL) {
 		if (!ValParamRailtype((RailType)p1)) return CMD_ERROR;
 	} else {
 		const RoadTypes rts = (RoadTypes)GB(p1, 0, 3);
@@ -585,7 +546,7 @@
 	cost.AddCost(ret);
 
 	if (flags & DC_EXEC) {
-		if (GB(p1, 9, 1) == TRANSPORT_RAIL) {
+		if (transport_type == TRANSPORT_RAIL) {
 			MakeRailTunnel(start_tile, _current_player, direction,                 (RailType)GB(p1, 0, 4));
 			MakeRailTunnel(end_tile,   _current_player, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4));
 			AddSideToSignalBuffer(start_tile, INVALID_DIAGDIR, _current_player);
@@ -651,11 +612,11 @@
 			DoClearSquare(endtile);
 
 			/* cannot use INVALID_DIAGDIR for signal update because the tunnel doesn't exist anymore */
-			AddSideToSignalBuffer(tile, ReverseDiagDir(dir), owner);
-			AddSideToSignalBuffer(endtile, dir, owner);
+			AddSideToSignalBuffer(tile,    ReverseDiagDir(dir), owner);
+			AddSideToSignalBuffer(endtile, dir,                 owner);
 
 			Track track = AxisToTrack(DiagDirToAxis(dir));
-			YapfNotifyTrackLayoutChange(tile, track);
+			YapfNotifyTrackLayoutChange(tile,    track);
 			YapfNotifyTrackLayoutChange(endtile, track);
 		} else {
 			DoClearSquare(tile);
@@ -703,21 +664,27 @@
 		/* read this value before actual removal of bridge */
 		bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL;
 		Owner owner = GetTileOwner(tile);
+		uint height = GetBridgeHeight(tile);
 
 		DoClearSquare(tile);
 		DoClearSquare(endtile);
 		for (TileIndex c = tile + delta; c != endtile; c += delta) {
+			/* do not let trees appear from 'nowhere' after removing bridge */
+			if (IsNormalRoadTile(c) && GetRoadside(c) == ROADSIDE_TREES) {
+				uint minz = GetTileMaxZ(c) + 3 * TILE_HEIGHT;
+				if (height < minz) SetRoadside(c, ROADSIDE_PAVED);
+			}
 			ClearBridgeMiddle(c);
 			MarkTileDirtyByTile(c);
 		}
 
 		if (rail) {
 			/* cannot use INVALID_DIAGDIR for signal update because the bridge doesn't exist anymore */
-			AddSideToSignalBuffer(tile, ReverseDiagDir(direction), owner);
-			AddSideToSignalBuffer(endtile, direction, owner);
+			AddSideToSignalBuffer(tile,    ReverseDiagDir(direction), owner);
+			AddSideToSignalBuffer(endtile, direction,                 owner);
 
 			Track track = AxisToTrack(DiagDirToAxis(direction));
-			YapfNotifyTrackLayoutChange(tile, track);
+			YapfNotifyTrackLayoutChange(tile,    track);
 			YapfNotifyTrackLayoutChange(endtile, track);
 		}
 	}
@@ -749,11 +716,11 @@
  * @param y Sprite Y position of front pillar.
  * @param z_bridge Absolute height of bridge bottom.
  */
-static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, uint type, int x, int y, int z_bridge)
+static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, BridgeType type, int x, int y, int z_bridge)
 {
 	SpriteID image = psid->sprite;
 	if (image != 0) {
-		bool drawfarpillar = !HasBit(GetBridgeFlags(type), 0);
+		bool drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0);
 
 		/* "side" specifies the side the pillars stand on.
 		 * The length of the pillars is then set to the height of the bridge over the corners of this edge.
@@ -819,14 +786,14 @@
 	 * The bounding boxes here are the same as for bridge front/roof */
 	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BRIDGES));
 
-	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset],  PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BUILDINGS));
+	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset],  PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_CATENARY));
 
 	/* Start a new SpriteCombine for the front part */
 	EndSpriteCombine();
 	StartSpriteCombine();
 
 	/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
-	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, IsTransparencySet(TO_BUILDINGS), front_bb_offset_x[offset], front_bb_offset_y[offset]);
+	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, IsTransparencySet(TO_CATENARY), front_bb_offset_x[offset], front_bb_offset_y[offset]);
 }
 
 /**
@@ -845,6 +812,8 @@
 static void DrawTile_TunnelBridge(TileInfo *ti)
 {
 	SpriteID image;
+	TransportType transport_type = GetTunnelBridgeTransportType(ti->tile);
+	DiagDirection tunnelbridge_direction = GetTunnelBridgeDirection(ti->tile);
 
 	if (IsTunnel(ti->tile)) {
 		/* Front view of tunnel bounding boxes:
@@ -864,11 +833,11 @@
 			{  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[GetTunnelBridgeDirection(ti->tile)];
+		const int *BB_data = _tunnel_BB[tunnelbridge_direction];
 
 		bool catenary = false;
 
-		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
+		if (transport_type == TRANSPORT_RAIL) {
 			image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
 		} else {
 			image = SPR_TUNNEL_ENTRY_REAR_ROAD;
@@ -876,20 +845,19 @@
 
 		if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += 32;
 
-		image += GetTunnelBridgeDirection(ti->tile) * 2;
+		image += tunnelbridge_direction * 2;
 		DrawGroundSprite(image, PAL_NONE);
-		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
-			DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
+		if (transport_type == TRANSPORT_ROAD) {
 			RoadTypes rts = GetRoadTypes(ti->tile);
 
 			if (HasBit(rts, ROADTYPE_TRAM)) {
 				static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, {  5, 76, 77,  4 } };
 
-				DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][dir], PAL_NONE);
+				DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][tunnelbridge_direction], PAL_NONE);
 
 				catenary = true;
 				StartSpriteCombine();
-				AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + dir, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_BUILDINGS), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
+				AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
 			}
 		} else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) {
 			DrawCatenary(ti);
@@ -913,7 +881,7 @@
 		int base_offset;
 		bool ice = HasTunnelBridgeSnowOrDesert(ti->tile);
 
-		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
+		if (transport_type == TRANSPORT_RAIL) {
 			base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset;
 			assert(base_offset != 8); // This one is used for roads
 		} else {
@@ -923,10 +891,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(GetTunnelBridgeDirection(ti->tile))));
+		DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(tunnelbridge_direction)));
 
 		/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */
-		base_offset += (6 - GetTunnelBridgeDirection(ti->tile)) % 4;
+		base_offset += (6 - tunnelbridge_direction) % 4;
 
 		if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head
 
@@ -942,7 +910,7 @@
 		/* draw ramp */
 
 		/* Draw Trambits as SpriteCombine */
-		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) StartSpriteCombine();
+		if (transport_type == 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
@@ -951,11 +919,11 @@
 			psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, IsTransparencySet(TO_BRIDGES)
 		);
 
-		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
+		if (transport_type == TRANSPORT_ROAD) {
 			RoadTypes rts = GetRoadTypes(ti->tile);
 
 			if (HasBit(rts, ROADTYPE_TRAM)) {
-				uint offset = GetTunnelBridgeDirection(ti->tile);
+				uint offset = tunnelbridge_direction;
 				uint z = ti->z;
 				if (ti->tileh != SLOPE_FLAT) {
 					offset = (offset + 1) & 1;
@@ -1033,9 +1001,10 @@
 	uint base_offset;
 	TileIndex rampnorth;
 	TileIndex rampsouth;
+	TransportType transport_type;
 	Axis axis;
 	uint piece;
-	uint type;
+	BridgeType type;
 	int x;
 	int y;
 	uint z;
@@ -1044,6 +1013,7 @@
 
 	rampnorth = GetNorthernBridgeEnd(ti->tile);
 	rampsouth = GetSouthernBridgeEnd(ti->tile);
+	transport_type = GetTunnelBridgeTransportType(rampsouth);
 
 	axis = GetBridgeAxis(ti->tile);
 	piece = CalcBridgePiece(
@@ -1052,7 +1022,7 @@
 	);
 	type = GetBridgeType(rampsouth);
 
-	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_RAIL) {
+	if (transport_type == TRANSPORT_RAIL) {
 		base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset;
 	} else {
 		base_offset = 8;
@@ -1070,7 +1040,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 (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) StartSpriteCombine();
+	if (transport_type == TRANSPORT_ROAD) StartSpriteCombine();
 
 	/* Draw floor and far part of bridge*/
 	if (axis == AXIS_X) {
@@ -1081,7 +1051,7 @@
 
 	psid++;
 
-	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
+	if (transport_type == TRANSPORT_ROAD) {
 		RoadTypes rts = GetRoadTypes(rampsouth);
 
 		if (HasBit(rts, ROADTYPE_TRAM)) {
@@ -1105,7 +1075,7 @@
 	}
 
 	/* Draw TramFront as SpriteCombine */
-	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) EndSpriteCombine();
+	if (transport_type == TRANSPORT_ROAD) EndSpriteCombine();
 
 	psid++;
 	if (ti->z + 5 == z) {
@@ -1183,8 +1153,7 @@
 		td->str = (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) ?
 			STR_5017_RAILROAD_TUNNEL : STR_5018_ROAD_TUNNEL;
 	} else { //so it must be a bridge
-		int brtype = GetBridgeType(tile);
-		td->str = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL ? _bridge[brtype].name_rail : _bridge[brtype].name_road;
+		td->str = GetBridgeSpec(GetBridgeType(tile))->transport_name[GetTunnelBridgeTransportType(tile)];
 	}
 	td->owner = GetTileOwner(tile);
 }
@@ -1224,11 +1193,14 @@
 }
 
 
-static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
-	if (GetTunnelBridgeTransportType(tile) != mode) return 0;
-	if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
-	return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101;
+	TransportType transport_type = GetTunnelBridgeTransportType(tile);
+	if (transport_type != mode || (transport_type == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0)) return 0;
+
+	DiagDirection dir = GetTunnelBridgeDirection(tile);
+	if (side != INVALID_DIAGDIR && side != ReverseDiagDir(dir)) return 0;
+	return CombineTrackStatus(TrackBitsToTrackdirBits(AxisToTrackBits(DiagDirToAxis(dir))), TRACKDIR_BIT_NONE);
 }
 
 static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
@@ -1238,7 +1210,7 @@
 	if (new_player != PLAYER_SPECTATOR) {
 		SetTileOwner(tile, new_player);
 	} else {
-		if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
+		if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR))) {
 			/* When clearing the bridge/tunnel failed there are still vehicles on/in
 			 * the bridge/tunnel. As all *our* vehicles are already removed, they
 			 * must be of another owner. Therefor this must be a road bridge/tunnel.
@@ -1271,16 +1243,15 @@
 	int z = GetSlopeZ(x, y) - v->z_pos;
 
 	if (abs(z) > 2) return VETSB_CANNOT_ENTER;
+	const DiagDirection dir = GetTunnelBridgeDirection(tile);
 
 	if (IsTunnel(tile)) {
 		byte fc;
-		DiagDirection dir;
 		DiagDirection vdir;
 
 		if (v->type == VEH_TRAIN) {
 			fc = (x & 0xF) + (y << 4);
 
-			dir = GetTunnelBridgeDirection(tile);
 			vdir = DirToDiagDir(v->direction);
 
 			if (v->u.rail.track != TRACK_BIT_WORMHOLE && dir == vdir) {
@@ -1308,7 +1279,6 @@
 			}
 		} else if (v->type == VEH_ROAD) {
 			fc = (x & 0xF) + (y << 4);
-			dir = GetTunnelBridgeDirection(tile);
 			vdir = DirToDiagDir(v->direction);
 
 			/* Enter tunnel? */
@@ -1338,17 +1308,15 @@
 			}
 		}
 	} else { // IsBridge(tile)
-		DiagDirection dir;
 
 		if (v->IsPrimaryVehicle()) {
 			/* modify speed of vehicle */
-			uint16 spd = _bridge[GetBridgeType(tile)].speed;
+			uint16 spd = GetBridgeSpec(GetBridgeType(tile))->speed;
 
 			if (v->type == VEH_ROAD) spd *= 2;
 			if (v->cur_speed > spd) v->cur_speed = spd;
 		}
 
-		dir = GetTunnelBridgeDirection(tile);
 		if (DirToDiagDir(v->direction) == dir) {
 			switch (dir) {
 				default: NOT_REACHED();
--- a/src/tunnelbridge_map.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/tunnelbridge_map.h	Fri Feb 22 00:25:54 2008 +0000
@@ -13,7 +13,9 @@
 
 
 /**
- * Tunnel: Get the direction facing out of the tunnel
+ * Get the direction pointing to the other end.
+ *
+ * Tunnel: Get the direction facing into the tunnel
  * Bridge: Get the direction pointing onto the bridge
  * @param t The tile to analyze
  * @pre IsTileType(t, MP_TUNNELBRIDGE)
--- a/src/unmovable_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/unmovable_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -167,16 +167,14 @@
 	switch (GetUnmovableType(ti->tile)) {
 		case UNMOVABLE_TRANSMITTER:
 		case UNMOVABLE_LIGHTHOUSE: {
-			const DrawTileUnmovableStruct* dtus;
+			const DrawTileSeqStruct* dtu = &_draw_tile_transmitterlighthouse_data[GetUnmovableType(ti->tile)];
 
 			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
 			DrawClearLandTile(ti, 2);
 
-			dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)];
-
 			AddSortableSpriteToDraw(
-				dtus->image, PAL_NONE, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
-				dtus->width, dtus->height, dtus->z_size, ti->z,
+				dtu->image.sprite, PAL_NONE, ti->x | dtu->delta_x, ti->y | dtu->delta_y,
+				dtu->size_x, dtu->size_y, dtu->size_z, ti->z,
 				IsTransparencySet(TO_STRUCTURES)
 			);
 			break;
@@ -212,11 +210,11 @@
 			palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
 
 			t = &_unmovable_display_datas[GetCompanyHQSection(ti->tile)];
-			DrawGroundSprite(t->ground_sprite, palette);
+			DrawGroundSprite(t->ground.sprite, palette);
 
 			foreach_draw_tile_seq(dtss, t->seq) {
 				AddSortableSpriteToDraw(
-					dtss->image, palette,
+					dtss->image.sprite, palette,
 					ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 					dtss->size_x, dtss->size_y,
 					dtss->size_z, ti->z + dtss->delta_z,
@@ -350,7 +348,7 @@
 }
 
 
-static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
 	return 0;
 }
--- a/src/vehicle.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/vehicle.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -613,8 +613,10 @@
  */
 void VehicleEnteredDepotThisTick(Vehicle *v)
 {
-	/* we need to set v->leave_depot_instantly as we have no control of it's contents at this time */
-	if (HasBit(v->current_order.flags, OF_HALT_IN_DEPOT) && !HasBit(v->current_order.flags, OF_PART_OF_ORDERS) && v->current_order.type == OT_GOTO_DEPOT) {
+	/* We need to set v->leave_depot_instantly as we have no control of it's contents at this time.
+	 * Vehicle should stop in the depot if it was in 'stopping' state - train intered depot while slowing down. */
+	if ((HasBit(v->current_order.flags, OF_HALT_IN_DEPOT) && !HasBit(v->current_order.flags, OF_PART_OF_ORDERS) && v->current_order.type == OT_GOTO_DEPOT) ||
+			(v->vehstatus & VS_STOPPED)) {
 		/* we keep the vehicle in the depot since the user ordered it to stay */
 		v->leave_depot_instantly = false;
 	} else {
@@ -2797,6 +2799,7 @@
 
 	    SLE_VAR(Vehicle, day_counter,          SLE_UINT8),
 	    SLE_VAR(Vehicle, tick_counter,         SLE_UINT8),
+	SLE_CONDVAR(Vehicle, running_ticks,        SLE_UINT8,                   88, SL_MAX_VERSION),
 
 	    SLE_VAR(Vehicle, cur_order_index,      SLE_UINT8),
 	    SLE_VAR(Vehicle, num_orders,           SLE_UINT8),
@@ -2853,11 +2856,11 @@
 	 SLE_CONDVAR(Vehicle, value,                SLE_FILE_I32 | SLE_VAR_I64, 0, 64),
 	 SLE_CONDVAR(Vehicle, value,                SLE_INT64,                 65, SL_MAX_VERSION),
 
-	    SLE_VAR(Vehicle, random_bits,          SLE_UINT8),
-	    SLE_VAR(Vehicle, waiting_triggers,     SLE_UINT8),
-
-	    SLE_REF(Vehicle, next_shared,          REF_VEHICLE),
-	    SLE_REF(Vehicle, prev_shared,          REF_VEHICLE),
+	 SLE_CONDVAR(Vehicle, random_bits,          SLE_UINT8,                 2, SL_MAX_VERSION),
+	 SLE_CONDVAR(Vehicle, waiting_triggers,     SLE_UINT8,                 2, SL_MAX_VERSION),
+
+	 SLE_CONDREF(Vehicle, next_shared,        REF_VEHICLE,                 2, SL_MAX_VERSION),
+	 SLE_CONDREF(Vehicle, prev_shared,        REF_VEHICLE,                 2, SL_MAX_VERSION),
 
 	SLE_CONDVAR(Vehicle, group_id,             SLE_UINT16,                60, SL_MAX_VERSION),
 
--- a/src/vehicle_base.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/vehicle_base.h	Fri Feb 22 00:25:54 2008 +0000
@@ -249,8 +249,9 @@
 	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
+	byte day_counter;        ///< Increased by one for each day
+	byte tick_counter;       ///< Increased by one for each tick
+	byte running_ticks;      ///< Number of ticks this vehicle was not stopped this day
 
 	/* Begin Order-stuff */
 	Order current_order;     ///< The current order (+ status, like: loading)
@@ -291,8 +292,8 @@
 	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 profit_this_year;        ///< Profit this year << 8, low 8 bits are fract
+	Money profit_last_year;        ///< Profit last year << 8, low 8 bits are fract
 	Money value;
 
 	GroupID group_id;              ///< Index of group Pool array
@@ -437,6 +438,18 @@
 	Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
 
 	/**
+	 * Gets the profit vehicle had this year. It can be sent into SetDParam for string processing.
+	 * @return the vehicle's profit this year
+	 */
+	Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); }
+
+	/**
+	 * Gets the profit vehicle had last year. It can be sent into SetDParam for string processing.
+	 * @return the vehicle's profit last year
+	 */
+	Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); }
+
+	/**
 	 * Set the next vehicle of this vehicle.
 	 * @param next the next vehicle. NULL removes the next vehicle.
 	 */
--- a/src/vehicle_gui.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/vehicle_gui.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -171,9 +171,9 @@
 	/* draw profit-based colored icons */
 	if (v->age <= 365 * 2) {
 		pal = PALETTE_TO_GREY;
-	} else if (v->profit_last_year < 0) {
+	} else if (v->GetDisplayProfitLastYear() < 0) {
 		pal = PALETTE_TO_RED;
-	} else if (v->profit_last_year < 10000) {
+	} else if (v->GetDisplayProfitLastYear() < 10000) {
 		pal = PALETTE_TO_YELLOW;
 	} else {
 		pal = PALETTE_TO_GREEN;
@@ -587,7 +587,7 @@
 {
 	const Vehicle* va = *(const Vehicle**)a;
 	const Vehicle* vb = *(const Vehicle**)b;
-	int r = ClampToI32(va->profit_this_year - vb->profit_this_year);
+	int r = ClampToI32(va->GetDisplayProfitThisYear() - vb->GetDisplayProfitThisYear());
 
 	VEHICLEUNITNUMBERSORTER(r, va, vb);
 
@@ -598,7 +598,7 @@
 {
 	const Vehicle* va = *(const Vehicle**)a;
 	const Vehicle* vb = *(const Vehicle**)b;
-	int r = ClampToI32(va->profit_last_year - vb->profit_last_year);
+	int r = ClampToI32(va->GetDisplayProfitLastYear() - vb->GetDisplayProfitLastYear());
 
 	VEHICLEUNITNUMBERSORTER(r, va, vb);
 
@@ -644,22 +644,10 @@
 {
 	const Vehicle* va = *(const Vehicle**)a;
 	const Vehicle* vb = *(const Vehicle**)b;
-	int max_speed_a = 0xFFFF, max_speed_b = 0xFFFF;
 	int r;
-	const Vehicle *ua = va, *ub = vb;
 
 	if (va->type == VEH_TRAIN && vb->type == VEH_TRAIN) {
-		do {
-			if (RailVehInfo(ua->engine_type)->max_speed != 0)
-				max_speed_a = min(max_speed_a, RailVehInfo(ua->engine_type)->max_speed);
-		} while ((ua = ua->Next()) != NULL);
-
-		do {
-			if (RailVehInfo(ub->engine_type)->max_speed != 0)
-				max_speed_b = min(max_speed_b, RailVehInfo(ub->engine_type)->max_speed);
-		} while ((ub = ub->Next()) != NULL);
-
-		r = max_speed_a - max_speed_b;
+		r = va->u.rail.cached_max_speed - vb->u.rail.cached_max_speed;
 	} else {
 		r = va->max_speed - vb->max_speed;
 	}
@@ -995,8 +983,8 @@
 		const Vehicle *v = vl->sort_list[i];
 		StringID str;
 
-		SetDParam(0, v->profit_this_year);
-		SetDParam(1, v->profit_last_year);
+		SetDParam(0, v->GetDisplayProfitThisYear());
+		SetDParam(1, v->GetDisplayProfitLastYear());
 
 		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);
@@ -1512,8 +1500,8 @@
 	}
 
 	/* Draw profit */
-	SetDParam(0, v->profit_this_year);
-	SetDParam(1, v->profit_last_year);
+	SetDParam(0, v->GetDisplayProfitThisYear());
+	SetDParam(1, v->GetDisplayProfitLastYear());
 	DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING);
 
 	/* Draw breakdown & reliability */
--- a/src/vehicle_type.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/vehicle_type.h	Fri Feb 22 00:25:54 2008 +0000
@@ -52,4 +52,12 @@
 	EV_BUBBLE          = 9
 };
 
+/** Pathfinding option states */
+enum {
+	VPF_OPF  = 0, ///< The Original PathFinder
+	VPF_NTP  = 0, ///< New Train Pathfinder, replacing OPF for trains
+	VPF_NPF  = 1, ///< New PathFinder
+	VPF_YAPF = 2, ///< Yet Another PathFinder
+};
+
 #endif /* VEHICLE_TYPE_H */
--- a/src/video/cocoa/event.mm	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/video/cocoa/event.mm	Fri Feb 22 00:25:54 2008 +0000
@@ -668,9 +668,13 @@
 			last_cur_ticks = cur_ticks;
 			next_tick = cur_ticks + 30;
 
+			bool old_ctrl_pressed = _ctrl_pressed;
+
 			_ctrl_pressed = !!(_current_mods & ( _patches.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask));
 			_shift_pressed = !!(_current_mods & NSShiftKeyMask);
 
+			if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
+
 			GameLoop();
 
 			_screen.dst_ptr = _cocoa_subdriver->GetPixelBuffer();
--- a/src/video/sdl_v.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/video/sdl_v.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -490,6 +490,8 @@
 			last_cur_ticks = cur_ticks;
 			next_tick = cur_ticks + 30;
 
+			bool old_ctrl_pressed = _ctrl_pressed;
+
 			_ctrl_pressed  = !!(mod & KMOD_CTRL);
 			_shift_pressed = !!(mod & KMOD_SHIFT);
 
@@ -499,6 +501,9 @@
 				(keys[SDLK_UP]    ? 2 : 0) |
 				(keys[SDLK_RIGHT] ? 4 : 0) |
 				(keys[SDLK_DOWN]  ? 8 : 0);
+
+			if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
+
 			GameLoop();
 
 			_screen.dst_ptr = _sdl_screen->pixels;
--- a/src/video/win32_v.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/video/win32_v.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -856,6 +856,9 @@
 			_realtime_tick += cur_ticks - last_cur_ticks;
 			last_cur_ticks = cur_ticks;
 			next_tick = cur_ticks + 30;
+
+			bool old_ctrl_pressed = _ctrl_pressed;
+
 			_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0;
 			_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0;
 
@@ -870,6 +873,8 @@
 				_dirkeys = 0;
 			}
 
+			if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
+
 			GameLoop();
 			_cursor.delta.x = _cursor.delta.y = 0;
 
--- a/src/viewport.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/viewport.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -361,7 +361,7 @@
 	ViewPort *vp = w->viewport;
 
 	if (vp != NULL &&
-	    IsInsideMM(x, vp->left, vp->left + vp->width) &&
+			IsInsideMM(x, vp->left, vp->left + vp->width) &&
 			IsInsideMM(y, vp->top, vp->top + vp->height))
 		return vp;
 
@@ -689,6 +689,7 @@
 		top  = ps->top  = (pt.y += spr->y_offs);
 		bottom          = (pt.y +  spr->height);
 	}
+
 	if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) {
 		/* Compute maximal extents of sprite and it's bounding box */
 		left   = min(left  , RemapCoords(x + w          , y + bb_offset_y, z + bb_offset_z).x);
@@ -696,9 +697,10 @@
 		top    = min(top   , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz         ).y);
 		bottom = max(bottom, RemapCoords(x + w          , y + h          , z + bb_offset_z).y + 1);
 	}
+
 	/* Do not add the sprite to the viewport, if it is outside */
 	if (left   >= vd->dpi.left + vd->dpi.width ||
-	    right  <= vd->dpi.left ||
+	    right  <= vd->dpi.left                 ||
 	    top    >= vd->dpi.top + vd->dpi.height ||
 	    bottom <= vd->dpi.top) {
 		return;
@@ -1592,6 +1594,7 @@
 
 	ViewportSortParentSprites(parent_list);
 	ViewportDrawParentSprites(parent_list);
+
 	if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(parent_list);
 
 	if (vd.first_string != NULL) ViewportDrawStrings(&vd.dpi, vd.first_string);
@@ -1706,6 +1709,7 @@
 		}
 
 		ClampViewportToMap(vp, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y);
+
 		SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y);
 	}
 }
@@ -2843,9 +2847,8 @@
 {
 	Window *w;
 
-	/* undo clicking on button */
-	if (_thd.place_mode != VHM_NONE) {
-		_thd.place_mode = VHM_NONE;
+	/* undo clicking on button and drag & drop */
+	if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) {
 		w = FindWindowById(_thd.window_class, _thd.window_number);
 		if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ);
 	}
--- a/src/water.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/water.h	Fri Feb 22 00:25:54 2008 +0000
@@ -11,8 +11,7 @@
 void ConvertGroundTilesIntoWaterTiles();
 
 void DrawShipDepotSprite(int x, int y, int image);
-void DrawCanalWater(TileIndex tile, bool draw_base);
-void DrawRiverWater(const struct TileInfo *ti, bool draw_base);
+void DrawWaterClassGround(const struct TileInfo *ti);
 void DrawShoreTile(Slope tileh);
 
 void MakeWaterKeepingClass(TileIndex tile, Owner o);
--- a/src/water_cmd.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/water_cmd.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -96,6 +96,9 @@
 
 /**
  * Makes a tile canal or water depending on the surroundings.
+ *
+ * Must only be used for converting old savegames. Use WaterClass now.
+ *
  * 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.
@@ -108,6 +111,12 @@
 	/* Mark tile dirty in all cases */
 	MarkTileDirtyByTile(t);
 
+	if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1) {
+		/* tiles at map borders are always WATER_CLASS_SEA */
+		SetWaterClass(t, WATER_CLASS_SEA);
+		return;
+	}
+
 	bool has_water = false;
 	bool has_canal = false;
 	bool has_river = false;
@@ -116,9 +125,17 @@
 		TileIndex neighbour = TileAddByDiagDir(t, dir);
 		switch (GetTileType(neighbour)) {
 			case MP_WATER:
-				has_water |= IsSea(neighbour) || IsCoast(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) == OWNER_WATER);
-				has_canal |= IsCanal(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) != OWNER_WATER);
-				has_river |= IsRiver(neighbour);
+				/* clear water and shipdepots have already a WaterClass associated */
+				if (IsCoast(neighbour)) {
+					has_water = true;
+				} else if (!IsLock(neighbour)) {
+					switch (GetWaterClass(neighbour)) {
+						case WATER_CLASS_SEA:   has_water = true; break;
+						case WATER_CLASS_CANAL: has_canal = true; break;
+						case WATER_CLASS_RIVER: has_river = true; break;
+						default: NOT_REACHED();
+					}
+				}
 				break;
 
 			case MP_RAILWAY:
@@ -174,8 +191,6 @@
 
 	WaterClass wc1 = GetWaterClass(tile);
 	WaterClass wc2 = GetWaterClass(tile2);
-	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);
@@ -188,8 +203,8 @@
 	if (flags & DC_EXEC) {
 		depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
 
-		MakeShipDepot(tile,  _current_player, DEPOT_NORTH, axis, wc1, o1);
-		MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2, o2);
+		MakeShipDepot(tile,  _current_player, DEPOT_NORTH, axis, wc1);
+		MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2);
 		MarkTileDirtyByTile(tile);
 		MarkTileDirtyByTile(tile2);
 		d_auto_delete.Detach();
@@ -211,22 +226,22 @@
 
 static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
 {
-	TileIndex tile2;
-
 	if (!IsShipDepot(tile)) return CMD_ERROR;
 	if (!CheckTileOwnership(tile)) return CMD_ERROR;
-	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
-	tile2 = GetOtherShipDepotTile(tile);
+	TileIndex tile2 = GetOtherShipDepotTile(tile);
 
-	if (!EnsureNoVehicleOnGround(tile2)) return CMD_ERROR;
+	/* do not check for ship on tile when company goes bankrupt */
+	if (!(flags & DC_BANKRUPT)) {
+		if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile2)) return CMD_ERROR;
+	}
 
 	if (flags & DC_EXEC) {
 		/* Kill the depot, which is registered at the northernmost tile. Use that one */
 		delete GetDepotByTile(tile2 < tile ? tile2 : tile);
 
-		MakeWaterKeepingClass(tile,  GetShipDepotWaterOwner(tile));
-		MakeWaterKeepingClass(tile2, GetShipDepotWaterOwner(tile2));
+		MakeWaterKeepingClass(tile,  GetTileOwner(tile));
+		MakeWaterKeepingClass(tile2, GetTileOwner(tile2));
 		MarkTileDirtyByTile(tile);
 		MarkTileDirtyByTile(tile2);
 	}
@@ -533,15 +548,15 @@
 }
 
 /** Draw a plain sea water tile with no edges */
-void DrawSeaWater(TileIndex tile)
+static void DrawSeaWater(TileIndex tile)
 {
 	DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE);
 }
 
 /** draw a canal styled water tile with dikes around */
-void DrawCanalWater(TileIndex tile, bool draw_base)
+static void DrawCanalWater(TileIndex tile)
 {
-	if (draw_base) DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE);
+	DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE);
 
 	/* Test for custom graphics, else use the default */
 	SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile);
@@ -559,7 +574,7 @@
 #include "table/water_land.h"
 
 static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
-	SpriteID palette, uint base
+	SpriteID palette, uint base, bool draw_ground
 )
 {
 	SpriteID image;
@@ -577,7 +592,7 @@
 
 	image = wdts++->image;
 	if (image < 4) image += water_base;
-	DrawGroundSprite(image, PAL_NONE);
+	if (draw_ground) DrawGroundSprite(image, PAL_NONE);
 
 	for (; wdts->delta_x != 0x80; wdts++) {
 		AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette,
@@ -588,7 +603,7 @@
 	}
 }
 
-void DrawRiverWater(const TileInfo *ti, bool draw_base)
+static void DrawRiverWater(const TileInfo *ti)
 {
 	SpriteID image = SPR_FLAT_WATER_TILE;
 	SpriteID edges_base = GetCanalSprite(CF_RIVER_EDGE, ti->tile);
@@ -614,7 +629,7 @@
 		}
 	}
 
-	if (draw_base) DrawGroundSprite(image, PAL_NONE);
+	DrawGroundSprite(image, PAL_NONE);
 
 	/* Draw river edges if available. */
 	if (edges_base > 48) DrawWaterEdges(edges_base, ti->tile);
@@ -637,15 +652,19 @@
 	DrawGroundSprite(SPR_SHORE_BASE + tileh_to_shoresprite[tileh], PAL_NONE);
 }
 
+void DrawWaterClassGround(const TileInfo *ti) {
+	switch (GetWaterClass(ti->tile)) {
+		case WATER_CLASS_SEA:   DrawSeaWater(ti->tile); break;
+		case WATER_CLASS_CANAL: DrawCanalWater(ti->tile); break;
+		case WATER_CLASS_RIVER: DrawRiverWater(ti); break;
+	}
+}
+
 static void DrawTile_Water(TileInfo *ti)
 {
 	switch (GetWaterTileType(ti->tile)) {
 		case WATER_TILE_CLEAR:
-			switch (GetWaterClass(ti->tile)) {
-				case WATER_CLASS_SEA:   DrawSeaWater(ti->tile); break;
-				case WATER_CLASS_CANAL: DrawCanalWater(ti->tile, true); break;
-				case WATER_CLASS_RIVER: DrawRiverWater(ti, true); break;
-			}
+			DrawWaterClassGround(ti);
 			DrawBridgeMiddle(ti);
 			break;
 
@@ -656,11 +675,12 @@
 
 		case WATER_TILE_LOCK: {
 			const WaterDrawTileStruct *t = _shiplift_display_seq[GetSection(ti->tile)];
-			DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0);
+			DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0, true);
 		} break;
 
 		case WATER_TILE_DEPOT:
-			DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0);
+			DrawWaterClassGround(ti);
+			DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0, false);
 			break;
 	}
 }
@@ -850,9 +870,9 @@
  */
 static FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
 {
-	/* FLOOD_ACTIVE:  'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, rail with flooded halftile
+	/* FLOOD_ACTIVE:  'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, sea-docks (water part), rail with flooded halftile
 	 * FLOOD_DRYUP:   coast with more than one corner raised, coast with rail-track, coast with trees
-	 * FLOOD_PASSIVE: oilrig, dock, water-industries
+	 * FLOOD_PASSIVE: oilrig, water-industries
 	 * FLOOD_NONE:    canals, rivers, everything else
 	 */
 	switch (GetTileType(tile)) {
@@ -874,9 +894,10 @@
 			return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE);
 
 		case MP_STATION:
-			if (IsBuoy(tile) && GetWaterClass(tile) == WATER_CLASS_SEA) return FLOOD_ACTIVE;
-			if (IsOilRig(tile) || IsDock(tile)) return FLOOD_PASSIVE;
-			return FLOOD_NONE;
+			if (IsBuoy(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT)) {
+				return (GetWaterClass(tile) == WATER_CLASS_SEA ? FLOOD_ACTIVE : FLOOD_NONE);
+			}
+			return (IsOilRig(tile) ? FLOOD_PASSIVE : FLOOD_NONE);
 
 		case MP_INDUSTRY:
 			return ((GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0 ? FLOOD_PASSIVE : FLOOD_NONE);
@@ -1083,7 +1104,7 @@
 	}
 }
 
-static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode)
+static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 {
 	static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};
 
@@ -1106,7 +1127,7 @@
 		/* NW border: remove tracks that connects NW tile edge */
 		ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER);
 	}
-	return ts * 0x101;
+	return CombineTrackStatus(TrackBitsToTrackdirBits(ts), TRACKDIR_BIT_NONE);
 }
 
 static void ClickTile_Water(TileIndex tile)
@@ -1124,11 +1145,15 @@
 
 	if (new_player != PLAYER_SPECTATOR) {
 		SetTileOwner(tile, new_player);
-	} else if (IsShipDepot(tile)) {
-		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
-	} else {
-		SetTileOwner(tile, OWNER_NONE);
+		return;
 	}
+
+	/* Remove depot */
+	if (IsShipDepot(tile)) DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
+
+	/* Set owner of canals and locks ... and also canal under dock there was before.
+	 * Check if the new owner after removing depot isn't OWNER_WATER. */
+	if (IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE);
 }
 
 static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
--- a/src/water_map.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/water_map.h	Fri Feb 22 00:25:54 2008 +0000
@@ -106,9 +106,9 @@
 	return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1));
 }
 
-static inline Owner GetShipDepotWaterOwner(TileIndex t)
+static inline bool IsLock(TileIndex t)
 {
-	return (Owner)_m[t].m4;
+	return IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END);
 }
 
 static inline DiagDirection GetLockDirection(TileIndex t)
@@ -169,13 +169,13 @@
 	_m[t].m5 = 0;
 }
 
-static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, WaterClass original_water_class, Owner original_owner)
+static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, WaterClass original_water_class)
 {
 	SetTileType(t, MP_WATER);
 	SetTileOwner(t, o);
 	_m[t].m2 = 0;
 	_m[t].m3 = original_water_class;
-	_m[t].m4 = original_owner;
+	_m[t].m4 = 0;
 	_m[t].m5 = base + a * 2;
 }
 
--- a/src/waypoint.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/waypoint.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -34,10 +34,6 @@
 
 #include "table/strings.h"
 
-enum {
-	MAX_WAYPOINTS_PER_TOWN = 64,
-};
-
 DEFINE_OLD_POOL_GENERIC(Waypoint, Waypoint)
 
 
@@ -81,27 +77,57 @@
  */
 static void MakeDefaultWaypointName(Waypoint* wp)
 {
-	Waypoint *local_wp;
-	bool used_waypoint[MAX_WAYPOINTS_PER_TOWN];
-	int i;
+	uint32 used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base
+	uint32 next = 0; // first waypoint number in the bitmap
+	WaypointID idx = 0; // index where we will stop
 
 	wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index;
 
-	memset(used_waypoint, 0, sizeof(used_waypoint));
-
-	/* Find an unused waypoint number belonging to this town */
-	FOR_ALL_WAYPOINTS(local_wp) {
-		if (wp == local_wp) continue;
+	/* Find first unused waypoint number belonging to this town. This can never fail,
+	 * as long as there can be at most 65535 waypoints in total.
+	 *
+	 * This does 'n * m' search, but with 32bit 'used' bitmap, it needs at most 'n * (1 + ceil(m / 32))'
+	 * steps (n - number of waypoints in pool, m - number of waypoints near this town).
+	 * Usually, it needs only 'n' steps.
+	 *
+	 * If it wasn't using 'used' and 'idx', it would just search for increasing 'next',
+	 * but this way it is faster */
 
-		if (local_wp->xy && local_wp->name == NULL && local_wp->town_index == wp->town_index)
-			used_waypoint[local_wp->town_cn] = true;
-	}
+	WaypointID cid = 0; // current index, goes to GetWaypointPoolSize()-1, then wraps to 0
+	do {
+		Waypoint *lwp = GetWaypoint(cid);
 
-	/* Find an empty spot */
-	for (i = 0; used_waypoint[i] && i < MAX_WAYPOINTS_PER_TOWN; i++) {}
+		/* check only valid waypoints... */
+ 		if (lwp->IsValid() && wp != lwp) {
+			/* only waypoints with 'generic' name within the same city */
+			if (lwp->name == NULL && lwp->town_index == wp->town_index) {
+				/* if lwp->town_cn < next, uint will overflow to '+inf' */
+				uint i = (uint)lwp->town_cn - next;
 
-	wp->name = NULL;
-	wp->town_cn = i;
+				if (i < 32) {
+					SetBit(used, i); // update bitmap
+					if (i == 0) {
+						/* shift bitmap while the lowest bit is '1';
+						 * increase the base of the bitmap too */
+						do {
+							used >>= 1;
+							next++;
+						} while (HasBit(used, 0));
+						/* when we are at 'idx' again at end of the loop and
+						 * 'next' hasn't changed, then no waypoint had town_cn == next,
+						 * so we can safely use it */
+						idx = cid;
+					}
+				}
+			}
+		}
+
+		cid++;
+		if (cid == GetWaypointPoolSize()) cid = 0; // wrap to zero...
+	} while (cid != idx);
+
+	wp->town_cn = (uint16)next; // set index...
+	wp->name = NULL; // ... and use generic name
 }
 
 /**
@@ -197,7 +223,7 @@
 
 		wp_auto_delete = wp;
 
-		wp->town_index = 0;
+		wp->town_index = INVALID_TOWN;
 		wp->name = NULL;
 		wp->town_cn = 0;
 	} else if (flags & DC_EXEC) {
@@ -241,7 +267,7 @@
 		wp->deleted = 0;
 		wp->build_date = _date;
 
-		if (wp->town_index == 0) MakeDefaultWaypointName(wp);
+		if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp);
 
 		UpdateWaypointSign(wp);
 		RedrawWaypointSign(wp);
@@ -455,7 +481,8 @@
 	SLE_CONDVAR(Waypoint, xy,         SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 	SLE_CONDVAR(Waypoint, xy,         SLE_UINT32,                  6, SL_MAX_VERSION),
 	SLE_CONDVAR(Waypoint, town_index, SLE_UINT16,                 12, SL_MAX_VERSION),
-	SLE_CONDVAR(Waypoint, town_cn,    SLE_UINT8,                  12, SL_MAX_VERSION),
+	SLE_CONDVAR(Waypoint, town_cn,    SLE_FILE_U8 | SLE_VAR_U16,  12, 88),
+	SLE_CONDVAR(Waypoint, town_cn,    SLE_UINT16,                 89, SL_MAX_VERSION),
 	SLE_CONDVAR(Waypoint, string,     SLE_STRINGID,                0, 83),
 	SLE_CONDSTR(Waypoint, name,       SLE_STR, 0,                 84, SL_MAX_VERSION),
 	    SLE_VAR(Waypoint, deleted,    SLE_UINT8),
--- a/src/waypoint.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/waypoint.h	Fri Feb 22 00:25:54 2008 +0000
@@ -16,7 +16,7 @@
 	TileIndex xy;      ///< Tile of waypoint
 
 	TownID town_index; ///< Town associated with the waypoint
-	byte town_cn;      ///< The Nth waypoint for this town (consecutive number)
+	uint16 town_cn;    ///< The Nth waypoint for this town (consecutive number)
 	StringID string;   ///< C000-C03F have special meaning in old games
 	char *name;        ///< Custom name. If not set, town + town_cn is used for naming
 
--- a/src/widgets/dropdown.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/widgets/dropdown.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -49,7 +49,7 @@
 	WindowNumber parent_wnd_num;
 	byte parent_button;
 	DropDownList *list;
-	byte selected_index;
+	int selected_index;
 	byte click_delay;
 	bool drag_mode;
 	int scrolling;
--- a/src/window.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/window.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -1085,8 +1085,6 @@
 
 	w = GetCallbackWnd();
 
-	ResetObjectToPlace();
-
 	if (w != NULL) {
 		/* send an event in client coordinates. */
 		e.event = WE_DRAGDROP;
@@ -1095,6 +1093,9 @@
 		e.we.dragdrop.widget = GetWidgetFromPos(w, e.we.dragdrop.pt.x, e.we.dragdrop.pt.y);
 		w->wndproc(w, &e);
 	}
+
+	ResetObjectToPlace();
+
 	return false;
 }
 
@@ -1708,6 +1709,21 @@
 	}
 }
 
+void HandleCtrlChanged()
+{
+	WindowEvent e;
+
+	e.event = WE_CTRL_CHANGED;
+	e.we.ctrl.cont = true;
+
+	/* Call the event, start with the uppermost window. */
+	for (Window* const *wz = _last_z_window; wz != _z_windows;) {
+		Window *w = *--wz;
+		w->wndproc(w, &e);
+		if (!e.we.ctrl.cont) break;
+	}
+}
+
 extern void UpdateTileSelection();
 extern bool VpHandlePlaceSizingDrag();
 
--- a/src/window_gui.h	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/window_gui.h	Fri Feb 22 00:25:54 2008 +0000
@@ -123,6 +123,7 @@
 	WE_MESSAGE,
 	WE_SCROLL,
 	WE_INVALIDATE_DATA,
+	WE_CTRL_CHANGED,
 };
 
 struct WindowEvent {
@@ -192,6 +193,10 @@
 		struct {
 			int wheel;     ///< how much was 'wheel'd'
 		} wheel;
+
+		struct {
+			bool cont;     ///< continue the search? (default true)
+		} ctrl;
 	} we;
 };
 
--- a/src/yapf/follow_track.hpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/yapf/follow_track.hpp	Fri Feb 22 00:25:54 2008 +0000
@@ -44,7 +44,7 @@
 	/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
 	FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile)
 	{
-		if (IsTram() && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+		if (IsTram() && IsNormalRoadTile(tile)) {
 			RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM);
 			switch (rb) {
 				case ROAD_NW: return DIAGDIR_NW;
@@ -64,7 +64,7 @@
 		m_old_tile = old_tile;
 		m_old_td = old_td;
 		m_err = EC_NONE;
-		assert(((GetTileTrackStatus(m_old_tile, TT(), m_veh->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
+		assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), m_veh->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
 		       (GetSingleTramBit(m_old_tile) != INVALID_DIAGDIR)); // Disable the assertion for single tram bits
 		m_exitdir = TrackdirToExitdir(m_old_td);
 		if (ForcedReverse()) return true;
@@ -133,8 +133,7 @@
 		if (IsRailTT() && GetTileType(m_new_tile) == MP_RAILWAY && IsPlainRailTile(m_new_tile)) {
 			m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101);
 		} else {
-			uint32 ts = GetTileTrackStatus(m_new_tile, TT(), m_veh->u.road.compatible_roadtypes);
-			m_new_td_bits = (TrackdirBits)(ts & TRACKDIR_BIT_MASK);
+			m_new_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(m_new_tile, TT(), m_veh->u.road.compatible_roadtypes));
 
 			if (m_new_td_bits == 0) {
 				/* GetTileTrackStatus() returns 0 for single tram bits.
@@ -342,7 +341,7 @@
 
 		// for now we handle only on-bridge speed limit
 		if (!IsWaterTT() && IsBridgeTile(m_old_tile)) {
-			int spd = _bridge[GetBridgeType(m_old_tile)].speed;
+			int spd = GetBridgeSpec(GetBridgeType(m_old_tile))->speed;
 			if (IsRoadTT()) spd *= 2;
 			if (max_speed > spd) max_speed = spd;
 		}
--- a/src/yapf/yapf_base.hpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/yapf/yapf_base.hpp	Fri Feb 22 00:25:54 2008 +0000
@@ -138,21 +138,23 @@
 
 #ifndef NO_DEBUG_MESSAGES
 		perf.Stop();
-		if (_debug_yapf_level >= 3) {
+		if (_debug_yapf_level >= 2) {
 			int t = perf.Get(1000000);
 			_total_pf_time_us += t;
 
-			UnitID veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0;
-			char ttc = Yapf().TransportTypeChar();
-			float cache_hit_ratio = (m_stats_cache_hits == 0) ? 0.0f : ((float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f);
-			int cost = bDestFound ? m_pBestDestNode->m_cost : -1;
-			int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1;
+			if (_debug_yapf_level >= 3) {
+				UnitID veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0;
+				char ttc = Yapf().TransportTypeChar();
+				float cache_hit_ratio = (m_stats_cache_hits == 0) ? 0.0f : ((float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f);
+				int cost = bDestFound ? m_pBestDestNode->m_cost : -1;
+				int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1;
 
-			DEBUG(yapf, 3, "[YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ",
-			  ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(),
-			  cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000),
-			  m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000)
-			);
+				DEBUG(yapf, 3, "[YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ",
+				  ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(),
+				  cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000),
+				  m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000)
+				);
+			}
 		}
 #endif /* !NO_DEBUG_MESSAGES */
 		return bDestFound;
--- a/src/yapf/yapf_destrail.hpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/yapf/yapf_destrail.hpp	Fri Feb 22 00:25:54 2008 +0000
@@ -113,7 +113,7 @@
 			default:
 				m_destTile = v->dest_tile;
 				m_dest_station_id = INVALID_STATION;
-				m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL, 0) & TRACKDIR_BIT_MASK);
+				m_destTrackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL, 0));
 				break;
 		}
 		CYapfDestinationRailBase::SetDestination(v);
--- a/src/yapf/yapf_rail.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/yapf/yapf_rail.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -181,15 +181,15 @@
 		return next_trackdir;
 	}
 
-	static bool stCheckReverseTrain(Vehicle* v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2)
+	static bool stCheckReverseTrain(Vehicle* v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
 	{
 		Tpf pf1;
-		bool result1 = pf1.CheckReverseTrain(v, t1, td1, t2, td2);
+		bool result1 = pf1.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
 
 #if DEBUG_YAPF_CACHE
 		Tpf pf2;
 		pf2.DisableCache(true);
-		bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2);
+		bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
 		if (result1 != result2) {
 			DEBUG(yapf, 0, "CACHE ERROR: CheckReverseTrain() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
 		}
@@ -198,11 +198,11 @@
 		return result1;
 	}
 
-	FORCEINLINE bool CheckReverseTrain(Vehicle* v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2)
+	FORCEINLINE bool CheckReverseTrain(Vehicle* v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
 	{
 		// create pathfinder instance
 		// set origin and destination nodes
-		Yapf().SetOrigin(t1, td1, t2, td2, 1, false);
+		Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, false);
 		Yapf().SetDestination(v);
 
 		// find the best path
@@ -265,18 +265,49 @@
 
 bool YapfCheckReverseTrain(Vehicle* v)
 {
-	// tile where the engine is
-	TileIndex tile = v->tile;
-	// tile where we have last wagon
+	/* last wagon */
 	Vehicle* last_veh = GetLastVehicleInChain(v);
-	// if we are in tunnel then give up
-	if (v->u.rail.track == 0x40 || last_veh->u.rail.track == 0x40) return false;
+
 	// get trackdirs of both ends
 	Trackdir td = GetVehicleTrackdir(v);
 	Trackdir td_rev = ReverseTrackdir(GetVehicleTrackdir(last_veh));
 
+	/* tiles where front and back are */
+	TileIndex tile = v->tile;
+	TileIndex tile_rev = last_veh->tile;
 
-	typedef bool (*PfnCheckReverseTrain)(Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir);
+	int reverse_penalty = 0;
+
+	if (v->u.rail.track == TRACK_BIT_WORMHOLE) {
+		/* front in tunnel / on bridge */
+		DiagDirection dir_into_wormhole = GetTunnelBridgeDirection(tile);
+
+		if (TrackdirToExitdir(td) == dir_into_wormhole) tile = GetOtherTunnelBridgeEnd(tile);
+		/* Now 'tile' is the tunnel entry/bridge ramp the train will reach when driving forward */
+
+		/* Current position of the train in the wormhole */
+		TileIndex cur_tile = TileVirtXY(v->x_pos, v->y_pos);
+
+		/* Add distance to drive in the wormhole as penalty for the forward path, i.e. bonus for the reverse path
+		 * Note: Negative penalties are ok for the start tile. */
+		reverse_penalty -= DistanceManhattan(cur_tile, tile) * YAPF_TILE_LENGTH;
+	}
+
+	if (last_veh->u.rail.track == TRACK_BIT_WORMHOLE) {
+		/* back in tunnel / on bridge */
+		DiagDirection dir_into_wormhole = GetTunnelBridgeDirection(tile_rev);
+
+		if (TrackdirToExitdir(td_rev) == dir_into_wormhole) tile_rev = GetOtherTunnelBridgeEnd(tile_rev);
+		/* Now 'tile_rev' is the tunnel entry/bridge ramp the train will reach when reversing */
+
+		/* Current position of the last wagon in the wormhole */
+		TileIndex cur_tile = TileVirtXY(last_veh->x_pos, last_veh->y_pos);
+
+		/* Add distance to drive in the wormhole as penalty for the revere path. */
+		reverse_penalty += DistanceManhattan(cur_tile, tile_rev) * YAPF_TILE_LENGTH;
+	}
+
+	typedef bool (*PfnCheckReverseTrain)(Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int);
 	PfnCheckReverseTrain pfnCheckReverseTrain = CYapfRail1::stCheckReverseTrain;
 
 	// check if non-default YAPF type needed
@@ -284,7 +315,10 @@
 		pfnCheckReverseTrain = &CYapfRail2::stCheckReverseTrain; // Trackdir, forbid 90-deg
 	}
 
-	bool reverse = pfnCheckReverseTrain(v, tile, td, last_veh->tile, td_rev);
+	/* slightly hackish: If the pathfinders finds a path, the cost of the first node is tested to distinguish between forward- and reverse-path. */
+	if (reverse_penalty == 0) reverse_penalty = 1;
+
+	bool reverse = pfnCheckReverseTrain(v, tile, td, tile_rev, td_rev, reverse_penalty);
 
 	return reverse;
 }
--- a/src/yapf/yapf_road.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/yapf/yapf_road.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -268,15 +268,13 @@
 		// our source tile will be the next vehicle tile (should be the given one)
 		TileIndex src_tile = tile;
 		// get available trackdirs on the start tile
-		uint ts = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
-		TrackdirBits src_trackdirs = (TrackdirBits)(ts & TRACKDIR_BIT_MASK);
+		TrackdirBits src_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes));
 		// select reachable trackdirs only
 		src_trackdirs &= DiagdirReachesTrackdirs(enterdir);
 
 		// get available trackdirs on the destination tile
 		TileIndex dest_tile = v->dest_tile;
-		uint dest_ts = GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
-		TrackdirBits dest_trackdirs = (TrackdirBits)(dest_ts & TRACKDIR_BIT_MASK);
+		TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes));
 
 		// set origin and destination nodes
 		Yapf().SetOrigin(src_tile, src_trackdirs);
@@ -320,8 +318,7 @@
 
 		// set destination tile, trackdir
 		//   get available trackdirs on the destination tile
-		uint dest_ts = GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
-		TrackdirBits dst_td_bits = (TrackdirBits)(dest_ts & TRACKDIR_BIT_MASK);
+		TrackdirBits dst_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes));
 		Yapf().SetDestination(dst_tile, dst_td_bits);
 
 		// find the best path
@@ -345,7 +342,7 @@
 		// set origin (tile, trackdir)
 		TileIndex src_tile = v->tile;
 		Trackdir src_td = GetVehicleTrackdir(v);
-		if ((GetTileTrackStatus(src_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(src_td)) == 0) {
+		if ((TrackStatusToTrackdirBits(GetTileTrackStatus(src_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(src_td)) == 0) {
 			// sometimes the roadveh is not on the road (it resides on non-existing track)
 			// how should we handle that situation?
 			return false;
@@ -438,7 +435,7 @@
 {
 	TileIndex tile = v->tile;
 	Trackdir trackdir = GetVehicleTrackdir(v);
-	if ((GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(trackdir)) == 0)
+	if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0)
 		return NULL;
 
 	// handle the case when our vehicle is already in the depot tile
--- a/src/yapf/yapf_ship.cpp	Thu Feb 21 22:34:54 2008 +0000
+++ b/src/yapf/yapf_ship.cpp	Fri Feb 22 00:25:54 2008 +0000
@@ -53,7 +53,7 @@
 		// convert origin trackdir to TrackdirBits
 		TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir);
 		// get available trackdirs on the destination tile
-		TrackdirBits dest_trackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER, 0) & TRACKDIR_BIT_MASK);
+		TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER, 0));
 
 		// create pathfinder instance
 		Tpf pf;