changeset 7272:dc7fb38ec443 draft

(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
author rubidium <rubidium@openttd.org>
date Mon, 16 Jul 2007 23:55:22 +0000
parents e8d9809b864e
children 2370eca02bf1
files docs/landscape.html docs/landscape_grid.html projects/openttd.vcproj projects/openttd_vs80.vcproj source.list src/newgrf_station.cpp src/oldloader.cpp src/openttd.cpp src/rail_cmd.cpp src/rail_gui.cpp src/road_gui.cpp src/saveload.cpp src/station.h src/station_cmd.cpp src/station_map.cpp src/station_map.h src/table/station_land.h
diffstat 17 files changed, 226 insertions(+), 341 deletions(-) [+]
line wrap: on
line diff
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -744,7 +744,7 @@
      <li>m3 bits 7..4: persistent random data for newstations</li>
      <li>m3 bits 3..0: <a href="#TrackType">track type</a> for railway stations, must be 0 for all the other stations</li>
      <li>m4: custom station id; 0 means standard graphics</li>
-     <li>m5: tile type:
+     <li>m5: graphics index (range from 0..255 for each station type):
       <table>
        <tr>
         <td nowrap valign=top><tt>00</tt>..<tt>07</tt>&nbsp; </td>
@@ -770,121 +770,28 @@
        </tr>
 
        <tr>
-        <td nowrap valign=top><tt>08</tt>..<tt>33</tt>&nbsp; </td>
-        <td align=left>large airport
-         <table>
-          <tr>
-           <td nowrap valign=top><tt>0B</tt>&nbsp; </td>
-           <td align=left>pad 1</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>16</tt>..<tt>19</tt>&nbsp; </td>
-           <td align=left>runway middle</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>1A</tt>&nbsp; </td>
-           <td align=left>runway ending</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>1C</tt>&nbsp; </td>
-           <td align=left>control tower</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>20</tt>&nbsp; </td>
-           <td align=left>hangar</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>21</tt>&nbsp; </td>
-           <td align=left>pad 3</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>22</tt>&nbsp; </td>
-           <td align=left>pad 2</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>27</tt>..<tt>32</tt>&nbsp; </td>
-           <td align=left>radar (animated)</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>33</tt>&nbsp; </td>
-           <td align=left>transmitter</td>
-          </tr>
-          <tr>
-           <td colspan=2>The initial layout of a large airport is (rows in Y direction, columns in X direction):
-<pre>
-1F 1B 1E 33 26 1A
-09 24 0B 0C 0D 16
-21 1D 23 0E 0F 17
-09 22 0D 11 10 18
-09 08 14 13 12 19
-20 0A 15 1C 27 1A
-</pre>
-           </td>
-          </tr>
-         </table>
-        </td>
+        <td nowrap valign=top><tt>00</tt>..<tt>8F</tt></td>
+        <td align=left>all airports</td>
        </tr>
 
        <tr>
-        <td nowrap valign=top><tt>34</tt>..<tt>41</tt>&nbsp; </td>
-        <td align=left>small airport
+        <td nowrap valign=top><tt>00</tt>..<tt>03</tt>&nbsp; </td>
+        <td align=left>lorry loading area/truck station : exit towards:
          <table>
           <tr>
-           <td nowrap valign=top><tt>3A</tt>..<tt>3D</tt>&nbsp; </td>
-           <td align=left>field with the wind meter (animated)</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>3E</tt>&nbsp; </td>
-           <td align=left>runway south ending</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>3F</tt>&nbsp; </td>
-           <td align=left>runway middle</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>40</tt>&nbsp; </td>
-           <td align=left>runway north ending</td>
-          </tr>
-          <tr>
-           <td nowrap valign=top><tt>41</tt>&nbsp; </td>
-           <td align=left>hangar</td>
-          </tr>
-          <tr>
-           <td colspan=2>The initial layout of a small airport is (rows in Y direction, columns in X direction):
-<pre>
-36 3A 40
-35 39 3F
-34 38 3F
-41 37 3E
-</pre>
-           </td>
-          </tr>
-         </table>
-        </td>
-       </tr>
-
-       <tr>
-        <td nowrap valign=top><tt>42</tt> </td>
-        <td align=left>heliport</td>
-       </tr>
-       <tr>
-        <td nowrap valign=top><tt>43</tt>..<tt>46</tt>&nbsp; </td>
-        <td align=left>lorry loading area : exit towards:
-         <table>
-          <tr>
-           <td><tt>43</tt>&nbsp; </td>
+           <td><tt>00</tt>&nbsp; </td>
            <td align=left>NE</td>
           </tr>
           <tr>
-           <td><tt>44</tt>&nbsp; </td>
+           <td><tt>01</tt>&nbsp; </td>
            <td align=left>SE</td>
           </tr>
           <tr>
-           <td><tt>45</tt>&nbsp; </td>
+           <td><tt>02</tt>&nbsp; </td>
            <td align=left>SW</td>
           </tr>
           <tr>
-           <td><tt>46</tt>&nbsp; </td>
+           <td><tt>03</tt>&nbsp; </td>
            <td align=left>NW</td>
           </tr>
          </table>
@@ -892,76 +799,40 @@
        </tr>
 
        <tr>
-        <td nowrap valign=top><tt>47</tt>..<tt>4A</tt>&nbsp; </td>
-        <td align=left>bus station : exit towards:
-         <table>
-          <tr>
-           <td><tt>47</tt>&nbsp; </td>
-           <td align=left>NE</td>
-          </tr>
-          <tr>
-           <td><tt>48</tt>&nbsp; </td>
-           <td align=left>SE</td>
-          </tr>
-          <tr>
-           <td><tt>49</tt>&nbsp; </td>
-           <td align=left>SW</td>
-          </tr>
-          <tr>
-           <td><tt>4A</tt>&nbsp; </td>
-           <td align=left>NW</td>
-          </tr>
-         </table>
-        </td>
-       </tr>
-
-       <tr>
-        <td nowrap valign=top><tt>4B</tt> </td>
-        <td align=left>oilfield</td>
-       </tr>
-
-       <tr>
-        <td nowrap valign=top><tt>4C</tt>..<tt>51</tt>&nbsp; </td>
+        <td nowrap valign=top><tt>00</tt>..<tt>05</tt>&nbsp; </td>
         <td align=left>ship dock
          <table>
           <tr>
-           <td><tt>4C</tt>&nbsp; </td>
+           <td><tt>00</tt>&nbsp; </td>
            <td align=left>SW coast part</td>
           </tr>
           <tr>
-           <td><tt>4D</tt>&nbsp; </td>
+           <td><tt>01</tt>&nbsp; </td>
            <td align=left>NW coast part</td>
           </tr>
           <tr>
-           <td><tt>4E</tt>&nbsp; </td>
+           <td><tt>02</tt>&nbsp; </td>
            <td align=left>NE coast part</td>
           </tr>
           <tr>
-           <td><tt>4F</tt>&nbsp; </td>
+           <td><tt>03</tt>&nbsp; </td>
            <td align=left>SE coast part</td>
           </tr>
           <tr>
-           <td><tt>50</tt>&nbsp; </td>
+           <td><tt>04</tt>&nbsp; </td>
            <td align=left>X direction water part</td>
           </tr>
           <tr>
-           <td><tt>51</tt>&nbsp; </td>
+           <td><tt>05</tt>&nbsp; </td>
            <td align=left>Y direction water part</td>
           </tr>
          </table>
         </td>
        </tr>
-       <tr>
-        <td nowrap valign=top><tt>52</tt> </td>
-        <td align=left>buoy</td>
-       </tr>
-       <tr>
-        <td nowrap valign=top><tt>53</tt>..<tt>A7</tt>&nbsp; </td>
-        <td align=left>used by RichK's larger airports</td>
-       </tr>
       </table>
      </li>
-     <li>m6 bit 3: 1 when a drive through road stop is built over a town owned road, otherwise 0</li>
+     <li>m6 bits 3..5: the station type (rail, airport, truck, bus, oilrig, dock, buoy)</li>
+     <li>m6 bit 2: 1 when a drive through road stop is built over a town owned road, otherwise 0</li>
      <li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
     </ul>
    </td>
--- a/docs/landscape_grid.html
+++ b/docs/landscape_grid.html
@@ -184,7 +184,7 @@
       <td class="bits">XXXX XXXX</td>
       <td class="bits">XXXX XXXX</td>
       <td class="bits">XXXX XXXX</td>
-      <td class="bits"><span class="free">OOOO O</span>XXX</td>
+      <td class="bits"><span class="free">OO</span>XX XXXX</td>
       <td class="bits"><span class="free">OOOO OOOO</span></td>
     </tr>
     <tr>
--- a/projects/openttd.vcproj
+++ b/projects/openttd.vcproj
@@ -1140,9 +1140,6 @@
 				RelativePath=".\..\src\road_map.h">
 			</File>
 			<File
-				RelativePath=".\..\src\station_map.cpp">
-			</File>
-			<File
 				RelativePath=".\..\src\station_map.h">
 			</File>
 			<File
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1736,10 +1736,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\..\src\station_map.cpp"
-				>
-			</File>
-			<File
 				RelativePath=".\..\src\station_map.h"
 				>
 			</File>
--- a/source.list
+++ b/source.list
@@ -355,7 +355,6 @@
 rail_map.h
 road_map.cpp
 road_map.h
-station_map.cpp
 station_map.h
 town_map.h
 tree_map.h
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -757,7 +757,7 @@
 	}
 
 	if (statspec->renderdata == NULL) {
-		sprites = GetStationTileLayout(tile + axis);
+		sprites = GetStationTileLayout(STATION_RAIL, tile + axis);
 	} else {
 		sprites = &statspec->renderdata[(tile < statspec->tiles) ? tile + axis : (uint)axis];
 	}
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -1578,12 +1578,11 @@
 				_m[i].m4 = 0; // We do not understand this TTDP station mapping (yet)
 				switch (_m[i].m5) {
 					/* We have drive through stops at a totally different place */
-					case 0x53: case 0x54: _m[i].m5 += GFX_BUS_BASE_EXT   - 0x53; break;
-					case 0x57: case 0x58: _m[i].m5 += GFX_TRUCK_BASE_EXT - 0x57; break;
-					case 0x55: case 0x56: // Bus tram stop
-					case 0x59: case 0x5A: // Truck tram stop
-						DEBUG(oldloader, 0, "Loading failed - we don't support trams (yet)");
-						return false;
+					case 0x53: case 0x54: _m[i].m5 += 170 - 0x53; break; // Bus drive through
+					case 0x57: case 0x58: _m[i].m5 += 168 - 0x57; break; // Truck drive through
+					case 0x55: case 0x56: _m[i].m5 += 170 - 0x55; break; // Bus tram stop
+					case 0x59: case 0x5A: _m[i].m5 += 168 - 0x59; break; // Truck tram stop
+					default: break;
 				}
 				break;
 
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1358,6 +1358,59 @@
 	DoZoomInOutWindow(ZOOM_NONE, w); // update button status
 	MarkWholeScreenDirty();
 
+	if (CheckSavegameVersion(72)) {
+		/* Locks/shiplifts in very old savegames had OWNER_WATER as owner */
+		for (TileIndex t = 0; t < MapSize(); t++) {
+			switch (GetTileType(t)) {
+				default: break;
+
+				case MP_WATER:
+					if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE);
+					break;
+
+				case MP_STATION: {
+					if (HASBIT(_m[t].m6, 3)) SETBIT(_m[t].m6, 2);
+					StationGfx gfx = GetStationGfx(t);
+					StationType st;
+					if (       IS_INT_INSIDE(gfx,   0,   8)) { // Railway station
+						st = STATION_RAIL;
+						SetStationGfx(t, gfx - 0);
+					} else if (IS_INT_INSIDE(gfx,   8,  67)) { // Airport
+						st = STATION_AIRPORT;
+						SetStationGfx(t, gfx - 8);
+					} else if (IS_INT_INSIDE(gfx,  67,  71)) { // Truck
+						st = STATION_TRUCK;
+						SetStationGfx(t, gfx - 67);
+					} else if (IS_INT_INSIDE(gfx,  71,  75)) { // Bus
+						st = STATION_BUS;
+						SetStationGfx(t, gfx - 71);
+					} else if (gfx == 75) {                    // Oil rig
+						st = STATION_OILRIG;
+						SetStationGfx(t, gfx - 75);
+					} else if (IS_INT_INSIDE(gfx,  76,  82)) { // Dock
+						st = STATION_DOCK;
+						SetStationGfx(t, gfx - 76);
+					} else if (gfx == 82) {                    // Buoy
+						st = STATION_BUOY;
+						SetStationGfx(t, gfx - 82);
+					} else if (IS_INT_INSIDE(gfx,  83, 168)) { // Extended airport
+						st = STATION_AIRPORT;
+						SetStationGfx(t, gfx - 83 + 67 - 8);
+					} else if (IS_INT_INSIDE(gfx, 168, 170)) { // Drive through truck
+						st = STATION_TRUCK;
+						SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
+					} else if (IS_INT_INSIDE(gfx, 170, 172)) { // Drive through bus
+						st = STATION_BUS;
+						SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
+					} else {
+						return false;
+					}
+					SB(_m[t].m6, 3, 3, st);
+				} break;
+			}
+		}
+	}
+
 	for (TileIndex t = 0; t < map_size; t++) {
 		switch (GetTileType(t)) {
 			case MP_STATION: {
@@ -2086,16 +2139,6 @@
 		FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE;
 	}
 
-	if (CheckSavegameVersion(72)) {
-		/* Locks/shiplifts in very old savegames had OWNER_WATER as owner */
-		for (TileIndex t = 0; t < MapSize(); t++) {
-			if (IsTileType(t, MP_WATER) && GetWaterTileType(t) == WATER_TILE_LOCK &&
-					GetTileOwner(t) == OWNER_WATER) {
-				SetTileOwner(t, OWNER_NONE);
-			}
-		}
-	}
-
 	/* Recalculate */
 	Group *g;
 	FOR_ALL_GROUPS(g) {
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1469,7 +1469,7 @@
 				}
 
 				if (statspec->renderdata == NULL) {
-					dts = GetStationTileLayout(gfx);
+					dts = GetStationTileLayout(STATION_RAIL, gfx);
 				} else {
 					dts = &statspec->renderdata[(gfx < statspec->tiles ? gfx : 0) + GetWaypointAxis(ti->tile)];
 				}
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -759,7 +759,7 @@
 			old_dpi = _cur_dpi;
 			_cur_dpi = &tmp_dpi;
 			if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
-				StationPickerDrawSprite(32, 16, _cur_railtype, INVALID_ROADTYPE, 2);
+				StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
 			}
 			_cur_dpi = old_dpi;
 		}
@@ -769,7 +769,7 @@
 			old_dpi = _cur_dpi;
 			_cur_dpi = &tmp_dpi;
 			if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
-				StationPickerDrawSprite(32, 16, _cur_railtype, INVALID_ROADTYPE, 3);
+				StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
 			}
 			_cur_dpi = old_dpi;
 		}
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -554,8 +554,6 @@
 		break;
 
 	case WE_PAINT: {
-		int image;
-
 		if (WP(w, def_d).close) return;
 
 		DrawWindowWidgets(w);
@@ -567,17 +565,15 @@
 			SetTileSelectSize(1, 1);
 		}
 
-		image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE : GFX_TRUCK_BASE;
+		StationType st = (w->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
 
-		StationPickerDrawSprite(103, 35, RAILTYPE_BEGIN, ROADTYPE_ROAD, image);
-		StationPickerDrawSprite(103, 85, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 1);
-		StationPickerDrawSprite(35, 85, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 2);
-		StationPickerDrawSprite(35, 35, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 3);
+		StationPickerDrawSprite(103, 35, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 0);
+		StationPickerDrawSprite(103, 85, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 1);
+		StationPickerDrawSprite( 35, 85, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 2);
+		StationPickerDrawSprite( 35, 35, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 3);
 
-		image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT;
-
-		StationPickerDrawSprite(171, 35, RAILTYPE_BEGIN, _cur_roadtype, image);
-		StationPickerDrawSprite(171, 85, RAILTYPE_BEGIN, _cur_roadtype, image + 1);
+		StationPickerDrawSprite(171, 35, st, RAILTYPE_BEGIN, _cur_roadtype, 4);
+		StationPickerDrawSprite(171, 85, st, RAILTYPE_BEGIN, _cur_roadtype, 5);
 
 		DrawStationCoverageAreaText(2, 146,
 			(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -30,7 +30,7 @@
 #include <setjmp.h>
 #include <list>
 
-extern const uint16 SAVEGAME_VERSION = 71;
+extern const uint16 SAVEGAME_VERSION = 72;
 uint16 _sl_version;       ///< the major savegame version identifier
 byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 
--- a/src/station.h
+++ b/src/station.h
@@ -185,6 +185,16 @@
 	static Station *AllocateRaw();
 };
 
+enum StationType {
+	STATION_RAIL,
+	STATION_AIRPORT,
+	STATION_TRUCK,
+	STATION_BUS,
+	STATION_OILRIG,
+	STATION_DOCK,
+	STATION_BUOY
+};
+
 enum {
 	FACIL_TRAIN      = 0x01,
 	FACIL_TRUCK_STOP = 0x02,
@@ -263,8 +273,8 @@
 void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
 
 
-const DrawTileSprites *GetStationTileLayout(byte gfx);
-void StationPickerDrawSprite(int x, int y, RailType railtype, RoadType roadtype, int image);
+const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
+void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);
 
 RoadStop * GetRoadStopByTile(TileIndex tile, RoadStop::Type type);
 uint GetNumRoadStops(const Station* st, RoadStop::Type type);
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1658,7 +1658,8 @@
 			const byte *b = _airport_sections[p1];
 
 			BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
-				MakeAirport(tile_cur, st->owner, st->index, *b++);
+				MakeAirport(tile_cur, st->owner, st->index, *b - ((*b < 67) ? 8 : 24));
+				b++;
 			} END_TILE_LOOP(tile_cur, w, h, tile)
 		}
 
@@ -1966,9 +1967,9 @@
 
 #include "table/station_land.h"
 
-const DrawTileSprites *GetStationTileLayout(byte gfx)
+const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx)
 {
-	return &_station_display_datas[gfx];
+	return &_station_display_datas[st][gfx];
 }
 
 /* For drawing canal edges on buoys */
@@ -2028,7 +2029,7 @@
 		}
 	}
 
-	if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)];
+	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)) {
@@ -2084,11 +2085,11 @@
 	}
 }
 
-void StationPickerDrawSprite(int x, int y, RailType railtype, RoadType roadtype, int image)
+void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
 {
 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
 	SpriteID pal = PLAYER_SPRITE_COLOR(_local_player);
-	const DrawTileSprites *t = &_station_display_datas[image];
+	const DrawTileSprites *t = &_station_display_datas[st][image];
 
 	SpriteID img = t->ground_sprite;
 	DrawSprite(img + rti->total_offset, HASBIT(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y);
@@ -2180,18 +2181,22 @@
 {
 	// FIXME -- GetTileTrackStatus_Station -> animated stationtiles
 	// hardcoded.....not good
-	switch (GetStationGfx(tile)) {
-		case GFX_RADAR_LARGE_FIRST:
-		case GFX_WINDSACK_FIRST : // for small airport
-		case GFX_RADAR_INTERNATIONAL_FIRST:
-		case GFX_RADAR_METROPOLITAN_FIRST:
-		case GFX_RADAR_DISTRICTWE_FIRST: // radar district W-E airport
-		case GFX_WINDSACK_INTERCON_FIRST : // for intercontinental airport
-			AddAnimatedTile(tile);
+	switch (GetStationType(tile)) {
+		case STATION_AIRPORT:
+			switch (GetStationGfx(tile)) {
+				case GFX_RADAR_LARGE_FIRST:
+				case GFX_WINDSACK_FIRST : // for small airport
+				case GFX_RADAR_INTERNATIONAL_FIRST:
+				case GFX_RADAR_METROPOLITAN_FIRST:
+				case GFX_RADAR_DISTRICTWE_FIRST: // radar district W-E airport
+				case GFX_WINDSACK_INTERCON_FIRST : // for intercontinental airport
+					AddAnimatedTile(tile);
+					break;
+			}
 			break;
 
-		case GFX_OILRIG_BASE: //(station part)
-		case GFX_BUOY_BASE:
+		case STATION_OILRIG: //(station part)
+		case STATION_BUOY:
 			TileLoop_Water(tile);
 			break;
 
deleted file mode 100644
--- a/src/station_map.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/* $Id$ */
-
-/** @file station_map.cpp */
-
-#include "stdafx.h"
-#include "openttd.h"
-#include "station_map.h"
-
-/**
- * Get the station type (rail, airport, truck etc) for the given tile.
- * @param t the tile to get the station type of.
- * @pre IsTileType(t, MP_STATION)
- * @return the station type of the given tile.
- */
-StationType GetStationType(TileIndex t)
-{
-	assert(IsTileType(t, MP_STATION));
-	if (IsRailwayStation(t)) return STATION_RAIL;
-	if (IsAirport(t)) return STATION_AIRPORT;
-	if (IsTruckStop(t)) return STATION_TRUCK;
-	if (IsBusStop(t)) return STATION_BUS;
-	if (IsOilRig(t)) return STATION_OILRIG;
-	if (IsDock(t)) return STATION_DOCK;
-	assert(IsBuoy(t));
-	return STATION_BUOY;
-}
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -24,63 +24,37 @@
 
 
 enum {
-	GFX_RAILWAY_BASE              =   0,
-	GFX_AIRPORT_BASE              =   8,
-	GFX_RADAR_LARGE_FIRST         =  39,
-	GFX_RADAR_LARGE_LAST          =  50,
-	GFX_WINDSACK_FIRST            =  58,
-	GFX_WINDSACK_LAST             =  61,
-	GFX_TRUCK_BASE                =  67,
-	GFX_BUS_BASE                  =  71,
-	GFX_OILRIG_BASE               =  75,
-	GFX_DOCK_BASE                 =  76,
-	GFX_DOCK_BASE_WATER_PART      =  80,
-	GFX_BUOY_BASE                 =  82,
-	GFX_AIRPORT_BASE_EXTENDED     =  83,
-	GFX_RADAR_INTERNATIONAL_FIRST =  90,
-	GFX_RADAR_INTERNATIONAL_LAST  = 101,
-	GFX_RADAR_METROPOLITAN_FIRST  = 102,
-	GFX_RADAR_METROPOLITAN_LAST   = 113,
-	GFX_RADAR_DISTRICTWE_FIRST    = 145,
-	GFX_RADAR_DISTRICTWE_LAST     = 156,
-	GFX_WINDSACK_INTERCON_FIRST   = 164,
-	GFX_WINDSACK_INTERCON_LAST    = 167,
-	GFX_TRUCK_BASE_EXT            = 168,
-	GFX_BUS_BASE_EXT              = 170,
-	GFX_BASE_END                  = 172
-};
+	GFX_RADAR_LARGE_FIRST             =  31,
+	GFX_RADAR_LARGE_LAST              =  42,
+	GFX_WINDSACK_FIRST                =  50,
+	GFX_WINDSACK_LAST                 =  53,
+
+	GFX_DOCK_BASE_WATER_PART          =  4,
+	GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET =  4,
 
-enum {
-	RAILWAY_SIZE = GFX_AIRPORT_BASE - GFX_RAILWAY_BASE,
-	AIRPORT_SIZE = GFX_TRUCK_BASE - GFX_AIRPORT_BASE,
-	TRUCK_SIZE = GFX_BUS_BASE - GFX_TRUCK_BASE,
-	BUS_SIZE = GFX_OILRIG_BASE - GFX_BUS_BASE,
-	DOCK_SIZE_TOTAL = GFX_BUOY_BASE - GFX_DOCK_BASE,
-	AIRPORT_SIZE_EXTENDED = GFX_TRUCK_BASE_EXT - GFX_AIRPORT_BASE_EXTENDED,
-	TRUCK_SIZE_EXT = GFX_BUS_BASE_EXT - GFX_TRUCK_BASE_EXT,
-	BUS_SIZE_EXT = GFX_BASE_END - GFX_BUS_BASE_EXT,
+	GFX_RADAR_INTERNATIONAL_FIRST     =  66,
+	GFX_RADAR_INTERNATIONAL_LAST      =  77,
+	GFX_RADAR_METROPOLITAN_FIRST      =  78,
+	GFX_RADAR_METROPOLITAN_LAST       =  89,
+	GFX_RADAR_DISTRICTWE_FIRST        = 121,
+	GFX_RADAR_DISTRICTWE_LAST         = 132,
+	GFX_WINDSACK_INTERCON_FIRST       = 140,
+	GFX_WINDSACK_INTERCON_LAST        = 143,
 };
 
 enum HangarTile {
-	HANGAR_TILE_0 = 32,
-	HANGAR_TILE_1 = 65,
-	HANGAR_TILE_2 = 86,
-	HANGAR_TILE_3 = 129, // added for west facing hangar
-	HANGAR_TILE_4 = 130, // added for north facing hangar
-	HANGAR_TILE_5 = 131 // added for east facing hangar
+	HANGAR_TILE_0 = 24,
+	HANGAR_TILE_1 = 57,
+	HANGAR_TILE_2 = 62,
+	HANGAR_TILE_3 = 105, // added for west facing hangar
+	HANGAR_TILE_4 = 106, // added for north facing hangar
+	HANGAR_TILE_5 = 107  // added for east facing hangar
 };
 
-enum StationType {
-	STATION_RAIL,
-	STATION_AIRPORT,
-	STATION_TRUCK,
-	STATION_BUS,
-	STATION_OILRIG,
-	STATION_DOCK,
-	STATION_BUOY
-};
-
-StationType GetStationType(TileIndex);
+static inline StationType GetStationType(TileIndex t)
+{
+	return (StationType)GB(_m[t].m6, 3, 3);
+}
 
 static inline RoadStop::Type GetRoadStopType(TileIndex t)
 {
@@ -102,7 +76,7 @@
 
 static inline bool IsRailwayStation(TileIndex t)
 {
-	return GetStationGfx(t) < GFX_RAILWAY_BASE + RAILWAY_SIZE;
+	return GetStationType(t) == STATION_RAIL;
 }
 
 static inline bool IsRailwayStationTile(TileIndex t)
@@ -110,40 +84,36 @@
 	return IsTileType(t, MP_STATION) && IsRailwayStation(t);
 }
 
+static inline bool IsAirport(TileIndex t)
+{
+	return GetStationType(t) == STATION_AIRPORT;
+}
+
 static inline bool IsHangar(TileIndex t)
 {
 	StationGfx gfx = GetStationGfx(t);
-	return
+	return IsAirport(t) && (
 		gfx == HANGAR_TILE_0 ||
 		gfx == HANGAR_TILE_1 ||
 		gfx == HANGAR_TILE_2 ||
 		gfx == HANGAR_TILE_3 ||
 		gfx == HANGAR_TILE_4 ||
-		gfx == HANGAR_TILE_5;
-}
-
-static inline bool IsAirport(TileIndex t)
-{
-	StationGfx gfx = GetStationGfx(t);
-	return
-		(IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE, GFX_AIRPORT_BASE + AIRPORT_SIZE)) ||
-		(IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE_EXTENDED, GFX_AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED));
+		gfx == HANGAR_TILE_5);
 }
 
 static inline bool IsTruckStop(TileIndex t)
 {
-	return (IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE)) ||
-		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE_EXT, GFX_TRUCK_BASE_EXT + TRUCK_SIZE_EXT));
+	return GetStationType(t) == STATION_TRUCK;
 }
 
 static inline bool IsBusStop(TileIndex t)
 {
-	return (IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE)) ||
-		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE_EXT, GFX_BUS_BASE_EXT + BUS_SIZE_EXT));
+	return GetStationType(t) == STATION_BUS;
 }
 
 static inline bool IsRoadStop(TileIndex t)
 {
+	assert(IsTileType(t, MP_STATION));
 	return IsTruckStop(t) || IsBusStop(t);
 }
 
@@ -154,22 +124,18 @@
 
 static inline bool IsStandardRoadStopTile(TileIndex t)
 {
-	return IsTileType(t, MP_STATION) &&
-		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE) ||
-		IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE));
+	return IsRoadStopTile(t) && GetStationGfx(t) < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
 }
 
 static inline bool IsDriveThroughStopTile(TileIndex t)
 {
-	return IsTileType(t, MP_STATION) &&
-		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE_EXT, GFX_TRUCK_BASE_EXT + TRUCK_SIZE_EXT) ||
-		IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE_EXT, GFX_BUS_BASE_EXT + BUS_SIZE_EXT));
+	return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
 }
 
 static inline bool GetStopBuiltOnTownRoad(TileIndex t)
 {
 	assert(IsDriveThroughStopTile(t));
-	return HASBIT(_m[t].m6, 3);
+	return HASBIT(_m[t].m6, 2);
 }
 
 
@@ -180,26 +146,26 @@
 {
 	StationGfx gfx = GetStationGfx(t);
 	assert(IsRoadStopTile(t));
-	if (gfx < GFX_TRUCK_BASE_EXT) {
-		return (DiagDirection)((gfx - GFX_TRUCK_BASE) & 3);
+	if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
+		return (DiagDirection)(gfx);
 	} else {
-		return (DiagDirection)((gfx - GFX_TRUCK_BASE_EXT) & 1);
+		return (DiagDirection)(gfx - GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
 	}
 }
 
 static inline bool IsOilRig(TileIndex t)
 {
-	return GetStationGfx(t) == GFX_OILRIG_BASE;
+	return GetStationType(t) == STATION_OILRIG;
 }
 
 static inline bool IsDock(TileIndex t)
 {
-	return IS_BYTE_INSIDE(GetStationGfx(t), GFX_DOCK_BASE, GFX_DOCK_BASE + DOCK_SIZE_TOTAL);
+	return GetStationType(t) == STATION_DOCK;
 }
 
 static inline bool IsBuoy(TileIndex t)
 {
-	return GetStationGfx(t) == GFX_BUOY_BASE;
+	return GetStationType(t) == STATION_BUOY;
 }
 
 static inline bool IsBuoyTile(TileIndex t)
@@ -240,8 +206,8 @@
 static inline DiagDirection GetDockDirection(TileIndex t)
 {
 	StationGfx gfx = GetStationGfx(t);
-	assert(gfx < GFX_DOCK_BASE_WATER_PART);
-	return (DiagDirection)(gfx - GFX_DOCK_BASE);
+	assert(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART);
+	return (DiagDirection)(gfx);
 }
 
 static inline TileIndexDiffC GetDockOffset(TileIndex t)
@@ -294,38 +260,39 @@
 	return GB(_m[t].m3, 4, 4);
 }
 
-static inline void MakeStation(TileIndex t, Owner o, StationID sid, byte m5)
+static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section)
 {
 	SetTileType(t, MP_STATION);
 	SetTileOwner(t, o);
 	_m[t].m2 = sid;
 	_m[t].m3 = 0;
 	_m[t].m4 = 0;
-	_m[t].m5 = m5;
+	_m[t].m5 = section;
+	SB(_m[t].m6, 3, 3, st);
 }
 
 static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
 {
-	MakeStation(t, o, sid, section + a);
+	MakeStation(t, o, sid, STATION_RAIL, section + a);
 	SetRailType(t, rt);
 }
 
 static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, DiagDirection d)
 {
-	MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d);
+	MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), d);
 	SetRoadTypes(t, rt);
 }
 
 static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, Axis a, bool on_town_road)
 {
-	MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT) + a);
-	SB(_m[t].m6, 3, 1, on_town_road);
+	MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
+	SB(_m[t].m6, 2, 1, on_town_road);
 	SetRoadTypes(t, rt);
 }
 
 static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
 {
-	MakeStation(t, o, sid, section);
+	MakeStation(t, o, sid, STATION_AIRPORT, section);
 }
 
 static inline void MakeBuoy(TileIndex t, StationID sid)
@@ -333,18 +300,18 @@
 	/* Make the owner of the buoy tile the same as the current owner of the
 	 * water tile. In this way, we can reset the owner of the water to its
 	 * original state when the buoy gets removed. */
-	MakeStation(t, GetTileOwner(t), sid, GFX_BUOY_BASE);
+	MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0);
 }
 
 static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d)
 {
-	MakeStation(t, o, sid, GFX_DOCK_BASE + d);
-	MakeStation(t + TileOffsByDiagDir(d), o, sid, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
+	MakeStation(t, o, sid, STATION_DOCK, d);
+	MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
 }
 
 static inline void MakeOilrig(TileIndex t, StationID sid)
 {
-	MakeStation(t, OWNER_NONE, sid, GFX_OILRIG_BASE);
+	MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0);
 }
 
 #endif /* STATION_MAP_H */
--- a/src/table/station_land.h
+++ b/src/table/station_land.h
@@ -987,7 +987,7 @@
 	TILE_SEQ_END()
 };
 
-static const DrawTileSprites _station_display_datas[] = {
+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 },
@@ -996,6 +996,9 @@
 	{ 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 },
+};
+
+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 },
@@ -1055,22 +1058,6 @@
 	{ 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_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_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_FLAT_WATER_TILE,            PAL_NONE, _station_display_nothing },
-	{ SPR_SHORE_TILEH_3,              PAL_NONE, _station_display_datas_76 },
-	{ SPR_SHORE_TILEH_9,              PAL_NONE, _station_display_datas_77 },
-	{ SPR_SHORE_TILEH_12,             PAL_NONE, _station_display_datas_78 },
-	{ SPR_SHORE_TILEH_6,              PAL_NONE, _station_display_datas_79 },
-	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_80 },
-	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_81 },
-	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_82 },
 	{ 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 },
@@ -1156,8 +1143,49 @@
 	{ 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 },
+};
+
+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 },
+};
+
+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 }
 };
+
+static const DrawTileSprites _station_display_datas_oilrig[] = {
+	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_nothing },
+};
+
+static const DrawTileSprites _station_display_datas_dock[] = {
+	{ SPR_SHORE_TILEH_3,              PAL_NONE, _station_display_datas_76 },
+	{ SPR_SHORE_TILEH_9,              PAL_NONE, _station_display_datas_77 },
+	{ SPR_SHORE_TILEH_12,             PAL_NONE, _station_display_datas_78 },
+	{ SPR_SHORE_TILEH_6,              PAL_NONE, _station_display_datas_79 },
+	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_80 },
+	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_81 },
+};
+
+static const DrawTileSprites _station_display_datas_buoy[] = {
+	{ SPR_FLAT_WATER_TILE,            PAL_NONE, _station_display_datas_82 },
+};
+
+static const DrawTileSprites *_station_display_datas[] = {
+	_station_display_datas_rail,
+	_station_display_datas_airport,
+	_station_display_datas_truck,
+	_station_display_datas_bus,
+	_station_display_datas_oilrig,
+	_station_display_datas_dock,
+	_station_display_datas_buoy,
+};