src/station_map.h
branchcpp_gui
changeset 6254 abc6ad7c035c
parent 6204 c237d8081b58
child 6268 4b5241e5dd10
equal deleted inserted replaced
6253:23983700e3d7 6254:abc6ad7c035c
    40 	GFX_RADAR_METROPOLITAN_LAST   = 113,
    40 	GFX_RADAR_METROPOLITAN_LAST   = 113,
    41 	GFX_RADAR_DISTRICTWE_FIRST    = 145,
    41 	GFX_RADAR_DISTRICTWE_FIRST    = 145,
    42 	GFX_RADAR_DISTRICTWE_LAST     = 156,
    42 	GFX_RADAR_DISTRICTWE_LAST     = 156,
    43 	GFX_WINDSACK_INTERCON_FIRST   = 164,
    43 	GFX_WINDSACK_INTERCON_FIRST   = 164,
    44 	GFX_WINDSACK_INTERCON_LAST    = 167,
    44 	GFX_WINDSACK_INTERCON_LAST    = 167,
    45 	GFX_BASE_END                  = 168
    45 	GFX_TRUCK_BASE_EXT            = 168,
       
    46 	GFX_BUS_BASE_EXT              = 170,
       
    47 	GFX_BASE_END                  = 172
    46 };
    48 };
    47 
    49 
    48 enum {
    50 enum {
    49 	RAILWAY_SIZE = GFX_AIRPORT_BASE - GFX_RAILWAY_BASE,
    51 	RAILWAY_SIZE = GFX_AIRPORT_BASE - GFX_RAILWAY_BASE,
    50 	AIRPORT_SIZE = GFX_TRUCK_BASE - GFX_AIRPORT_BASE,
    52 	AIRPORT_SIZE = GFX_TRUCK_BASE - GFX_AIRPORT_BASE,
    51 	TRUCK_SIZE = GFX_BUS_BASE - GFX_TRUCK_BASE,
    53 	TRUCK_SIZE = GFX_BUS_BASE - GFX_TRUCK_BASE,
    52 	BUS_SIZE = GFX_OILRIG_BASE - GFX_BUS_BASE,
    54 	BUS_SIZE = GFX_OILRIG_BASE - GFX_BUS_BASE,
    53 	DOCK_SIZE_TOTAL = GFX_BUOY_BASE - GFX_DOCK_BASE,
    55 	DOCK_SIZE_TOTAL = GFX_BUOY_BASE - GFX_DOCK_BASE,
    54 	AIRPORT_SIZE_EXTENDED = GFX_BASE_END - GFX_AIRPORT_BASE_EXTENDED
    56 	AIRPORT_SIZE_EXTENDED = GFX_TRUCK_BASE_EXT - GFX_AIRPORT_BASE_EXTENDED,
       
    57 	TRUCK_SIZE_EXT = GFX_BUS_BASE_EXT - GFX_TRUCK_BASE_EXT,
       
    58 	BUS_SIZE_EXT = GFX_BASE_END - GFX_BUS_BASE_EXT,
    55 };
    59 };
    56 
    60 
    57 typedef enum HangarTiles {
    61 typedef enum HangarTiles {
    58 	HANGAR_TILE_0 = 32,
    62 	HANGAR_TILE_0 = 32,
    59 	HANGAR_TILE_1 = 65,
    63 	HANGAR_TILE_1 = 65,
   123 		(IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE_EXTENDED, GFX_AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED));
   127 		(IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE_EXTENDED, GFX_AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED));
   124 }
   128 }
   125 
   129 
   126 static inline bool IsTruckStop(TileIndex t)
   130 static inline bool IsTruckStop(TileIndex t)
   127 {
   131 {
   128 	return IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE);
   132 	return (IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE)) ||
       
   133 		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE_EXT, GFX_TRUCK_BASE_EXT + TRUCK_SIZE_EXT));
   129 }
   134 }
   130 
   135 
   131 static inline bool IsBusStop(TileIndex t)
   136 static inline bool IsBusStop(TileIndex t)
   132 {
   137 {
   133 	return IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE);
   138 	return (IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE)) ||
       
   139 		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE_EXT, GFX_BUS_BASE_EXT + BUS_SIZE_EXT));
   134 }
   140 }
   135 
   141 
   136 static inline bool IsRoadStop(TileIndex t)
   142 static inline bool IsRoadStop(TileIndex t)
   137 {
   143 {
   138 	return IsTruckStop(t) || IsBusStop(t);
   144 	return IsTruckStop(t) || IsBusStop(t);
   139 }
   145 }
   140 
   146 
   141 static inline bool IsRoadStopTile(TileIndex t)
   147 static inline bool IsRoadStopTile(TileIndex t)
   142 {
   148 {
   143 	return IsTileType(t, MP_STATION) && IsRoadStop(t);
   149 	return IsTileType(t, MP_STATION) && IsRoadStop(t);
       
   150 }
       
   151 
       
   152 static inline bool IsStandardRoadStopTile(TileIndex t)
       
   153 {
       
   154 	return IsTileType(t, MP_STATION) &&
       
   155 		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE) ||
       
   156 		IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE));
       
   157 }
       
   158 
       
   159 static inline bool IsDriveThroughStopTile(TileIndex t)
       
   160 {
       
   161 	return IsTileType(t, MP_STATION) &&
       
   162 		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE_EXT, GFX_TRUCK_BASE_EXT + TRUCK_SIZE_EXT) ||
       
   163 		IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE_EXT, GFX_BUS_BASE_EXT + BUS_SIZE_EXT));
       
   164 }
       
   165 
       
   166 static inline bool GetStopBuiltOnTownRoad(TileIndex t)
       
   167 {
       
   168 	assert(IsDriveThroughStopTile(t));
       
   169 	return HASBIT(_m[t].m6, 3);
       
   170 }
       
   171 
       
   172 static inline void SetStopBuiltOnTownRoad(TileIndex t)
       
   173 {
       
   174 	assert(IsDriveThroughStopTile(t));
       
   175 	SETBIT(_m[t].m6, 3);
   144 }
   176 }
   145 
   177 
   146 /**
   178 /**
   147  * Gets the direction the road stop entrance points towards.
   179  * Gets the direction the road stop entrance points towards.
   148  */
   180  */
   149 static inline DiagDirection GetRoadStopDir(TileIndex t)
   181 static inline DiagDirection GetRoadStopDir(TileIndex t)
   150 {
   182 {
       
   183 	StationGfx gfx = GetStationGfx(t);
   151 	assert(IsRoadStopTile(t));
   184 	assert(IsRoadStopTile(t));
   152 	return (DiagDirection)((GetStationGfx(t) - GFX_TRUCK_BASE) & 3);
   185 	if (gfx < GFX_TRUCK_BASE_EXT) {
       
   186 		return (DiagDirection)((gfx - GFX_TRUCK_BASE) & 3);
       
   187 	} else {
       
   188 		return (DiagDirection)((gfx - GFX_TRUCK_BASE_EXT) & 1);
       
   189 	}
   153 }
   190 }
   154 
   191 
   155 static inline bool IsOilRig(TileIndex t)
   192 static inline bool IsOilRig(TileIndex t)
   156 {
   193 {
   157 	return GetStationGfx(t) == GFX_OILRIG_BASE;
   194 	return GetStationGfx(t) == GFX_OILRIG_BASE;
   273 {
   310 {
   274 	MakeStation(t, o, sid, section + a);
   311 	MakeStation(t, o, sid, section + a);
   275 	SetRailType(t, rt);
   312 	SetRailType(t, rt);
   276 }
   313 }
   277 
   314 
   278 static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, DiagDirection d)
   315 static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, bool is_drive_through, DiagDirection d)
   279 {
   316 {
   280 	MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d);
   317 	if (is_drive_through) {
       
   318 		MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT) + d);
       
   319 	} else {
       
   320 		MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d);
       
   321 	}
   281 }
   322 }
   282 
   323 
   283 static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
   324 static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
   284 {
   325 {
   285 	MakeStation(t, o, sid, section);
   326 	MakeStation(t, o, sid, section);