(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
authorrubidium
Tue, 24 Jul 2007 21:48:50 +0000
changeset 7816 207d11ff7fda
parent 7815 04deaeb181ab
child 7817 f24498d934ac
(svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
src/station_cmd.cpp
src/station_map.h
--- a/src/station_cmd.cpp	Tue Jul 24 19:56:43 2007 +0000
+++ b/src/station_cmd.cpp	Tue Jul 24 21:48:50 2007 +0000
@@ -78,6 +78,26 @@
 DEFINE_OLD_POOL(RoadStop, RoadStop, RoadStopPoolNewBlock, NULL)
 
 
+/**
+ * Check whether the given tile is a hangar.
+ * @param t the tile to of whether it is a hangar.
+ * @pre IsTileType(t, MP_STATION)
+ * @return true if and only if the tile is a hangar.
+ */
+bool IsHangar(TileIndex t)
+{
+	assert(IsTileType(t, MP_STATION));
+
+	const Station *st = GetStationByTile(t);
+	const AirportFTAClass *apc = st->Airport();
+
+	for (uint i = 0; i < apc->nof_depots; i++) {
+		if (st->airport_tile + ToTileIndexDiff(apc->airport_depots[i]) == t) return true;
+	}
+
+	return false;
+}
+
 RoadStop* GetRoadStopByTile(TileIndex tile, RoadStop::Type type)
 {
 	const Station* st = GetStationByTile(tile);
--- a/src/station_map.h	Tue Jul 24 19:56:43 2007 +0000
+++ b/src/station_map.h	Tue Jul 24 21:48:50 2007 +0000
@@ -42,15 +42,6 @@
 	GFX_WINDSACK_INTERCON_LAST        = 143,
 };
 
-enum HangarTile {
-	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
-};
-
 static inline StationType GetStationType(TileIndex t)
 {
 	return (StationType)GB(_m[t].m6, 3, 3);
@@ -89,17 +80,7 @@
 	return GetStationType(t) == STATION_AIRPORT;
 }
 
-static inline bool IsHangar(TileIndex t)
-{
-	StationGfx gfx = GetStationGfx(t);
-	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);
-}
+bool IsHangar(TileIndex t);
 
 static inline bool IsTruckStop(TileIndex t)
 {