Changeset - r8563:f734b85d629c
[Not reviewed]
master
0 16 0
frosch - 17 years ago 2008-02-14 15:59:16
frosch@openttd.org
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
16 files changed with 79 insertions and 61 deletions:
0 comments (0 inline, 0 general)
src/ai/default/default.cpp
Show inline comments
 
@@ -2639,8 +2639,7 @@ static CommandCost AiDoBuildDefaultRoadB
 
		_cleared_town = NULL;
 

	
 
		if (p->mode == 2) {
 
			if (IsTileType(c, MP_ROAD) &&
 
					GetRoadTileType(c) == ROAD_TILE_NORMAL &&
 
			if (IsNormalRoadTile(c) &&
 
					(GetRoadBits(c, ROADTYPE_ROAD) & p->attr) != 0) {
 
				roadflag |= 2;
 

	
 
@@ -2682,7 +2681,7 @@ clear_town_stuff:;
 

	
 
			if (GetTileSlope(c, NULL) != SLOPE_FLAT) return CMD_ERROR;
 

	
 
			if (!IsTileType(c, MP_ROAD) || GetRoadTileType(c) != ROAD_TILE_NORMAL) {
 
			if (!IsNormalRoadTile(c)) {
 
				ret = DoCommand(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
 
				if (CmdFailed(ret)) return CMD_ERROR;
 
			}
 
@@ -2857,7 +2856,7 @@ static bool AiEnumFollowRoad(TileIndex t
 
	if (dist <= a->best_dist) {
 
		TileIndex tile2 = TILE_MASK(tile + TileOffsByDiagDir(_dir_by_track[track]));
 

	
 
		if (IsTileType(tile2, MP_ROAD) && GetRoadTileType(tile2) == ROAD_TILE_NORMAL) {
 
		if (IsNormalRoadTile(tile2)) {
 
			a->best_dist = dist;
 
			a->best_tile = tile;
 
			a->best_track = track;
 
@@ -3740,7 +3739,7 @@ pos_3:
 

	
 
		if (IsLevelCrossing(tile)) goto is_rail_crossing;
 

	
 
		if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
 
		if (IsRoadDepot(tile)) {
 
			DiagDirection dir;
 
			TileIndex t;
 

	
src/ai/trolly/trolly.cpp
Show inline comments
 
@@ -801,8 +801,7 @@ static void AiNew_State_FindDepot(Player
 
		for (j = DIAGDIR_BEGIN; j < DIAGDIR_END; j++) {
 
			TileIndex t = tile + TileOffsByDiagDir(j);
 

	
 
			if (IsTileType(t, MP_ROAD) &&
 
					GetRoadTileType(t) == ROAD_TILE_DEPOT &&
 
			if (IsRoadDepotTile(t) &&
 
					IsTileOwner(t, _current_player) &&
 
					GetRoadDepotDirection(t) == ReverseDiagDir(j)) {
 
				_players_ainew[p->index].depot_tile = t;
 
@@ -1102,7 +1101,7 @@ static void AiNew_State_BuildDepot(Playe
 
	CommandCost res;
 
	assert(_players_ainew[p->index].state == AI_STATE_BUILD_DEPOT);
 

	
 
	if (IsTileType(_players_ainew[p->index].depot_tile, MP_ROAD) && GetRoadTileType(_players_ainew[p->index].depot_tile) == ROAD_TILE_DEPOT) {
 
	if (IsRoadDepotTile(_players_ainew[p->index].depot_tile)) {
 
		if (IsTileOwner(_players_ainew[p->index].depot_tile, _current_player)) {
 
			// The depot is already built
 
			_players_ainew[p->index].state = AI_STATE_BUILD_VEHICLE;
src/depot.h
Show inline comments
 
@@ -45,7 +45,7 @@ static inline bool IsTileDepotType(TileI
 
			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 IsTileDepotType(TileI
 
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);
src/elrail.cpp
Show inline comments
 
@@ -103,7 +103,7 @@ static TrackBits GetRailTrackBitsUnivers
 
			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);
 

	
src/npf.cpp
Show inline comments
 
@@ -512,7 +512,7 @@ static DiagDirection GetDepotDirection(T
 
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
 
static DiagDirection GetSingleTramBit(TileIndex tile)
 
{
 
	if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
 
	if (IsNormalRoadTile(tile)) {
 
		RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM);
 
		switch (rb) {
 
			case ROAD_NW: return DIAGDIR_NW;
src/openttd.cpp
Show inline comments
 
@@ -2388,7 +2388,7 @@ bool AfterLoadGame()
 
					Owner o = GetRoadOwner(t, rt);
 
					if (IsValidPlayer(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE);
 
				}
 
				if (GetRoadTileType(t) == ROAD_TILE_CROSSING) {
 
				if (IsLevelCrossing(t)) {
 
					Owner o = GetTileOwner(t);
 
					if (!GetPlayer(o)->is_active) {
 
						/* remove leftover rail piece from crossing (from very old savegames) */
src/order_gui.cpp
Show inline comments
 
@@ -281,7 +281,7 @@ static Order GetOrderCmdFromTile(const V
 
			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;
src/rail_cmd.cpp
Show inline comments
 
@@ -356,7 +356,7 @@ CommandCost CmdBuildSingleRail(TileIndex
 

	
 
			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);
src/road_cmd.cpp
Show inline comments
 
@@ -225,7 +225,7 @@ static CommandCost RemoveRoad(TileIndex 
 

	
 
			/* 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);
 
@@ -429,7 +429,7 @@ CommandCost CmdBuildRoad(TileIndex tile,
 
					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;
 
@@ -455,7 +455,7 @@ CommandCost CmdBuildRoad(TileIndex tile,
 
				} 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;
 
					if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
@@ -508,14 +508,14 @@ CommandCost CmdBuildRoad(TileIndex tile,
 

	
 
		case MP_STATION:
 
			if (!IsDriveThroughStopTile(tile)) 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 roadstop when vehicles are already driving on it */
 
			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
			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;
 
@@ -543,7 +543,7 @@ do_clear:;
 
		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);
 

	
 
@@ -603,7 +603,7 @@ do_clear:;
 
				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);
 
@@ -1090,7 +1090,7 @@ static void DrawTile_Road(TileInfo *ti)
 
			}
 

	
 
			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));
 
			}
 
@@ -1108,7 +1108,7 @@ static void DrawTile_Road(TileInfo *ti)
 

	
 
			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)];
 
@@ -1165,7 +1165,7 @@ static uint GetSlopeZ_Road(TileIndex til
 
	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);
 
@@ -1176,7 +1176,7 @@ static uint GetSlopeZ_Road(TileIndex til
 

	
 
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);
 
@@ -1229,7 +1229,7 @@ static void TileLoop_Road(TileIndex tile
 
			break;
 
	}
 

	
 
	if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) return;
 
	if (IsRoadDepot(tile)) return;
 

	
 
	const Town* t = ClosestTownFromTile(tile, (uint)-1);
 
	if (!HasRoadWorks(tile)) {
 
@@ -1241,7 +1241,7 @@ static void TileLoop_Road(TileIndex tile
 
			/* 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);
 

	
 
@@ -1297,7 +1297,7 @@ static void TileLoop_Road(TileIndex tile
 

	
 
static void ClickTile_Road(TileIndex tile)
 
{
 
	if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) ShowDepotWindow(tile, VEH_ROAD);
 
	if (IsRoadDepot(tile)) ShowDepotWindow(tile, VEH_ROAD);
 
}
 

	
 
static const byte _road_trackbits[16] = {
 
@@ -1402,7 +1402,7 @@ static VehicleEnterTileStatus VehicleEnt
 

	
 
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 | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
 
@@ -1415,7 +1415,7 @@ static void ChangeTileOwner_Road(TileInd
 

	
 
	for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
 
		/* ROADTYPE_ROAD denotes the tile owner, so update it too */
 
		if (rt != ROADTYPE_ROAD && !HasBit(GetRoadTypes(tile), rt)) continue;
 
		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);
src/road_gui.cpp
Show inline comments
 
@@ -177,7 +177,7 @@ static void BuildRoadOutsideStation(Tile
 
{
 
	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);
 
		}
src/road_map.cpp
Show inline comments
 
@@ -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:
 
@@ -46,7 +46,7 @@ TrackBits GetAnyRoadTrackBits(TileIndex 
 
	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;
 
	}
 

	
src/road_map.h
Show inline comments
 
@@ -24,6 +24,16 @@ static inline RoadTileType GetRoadTileTy
 
	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 @@ static inline bool IsLevelCrossingTile(T
 
	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 RoadBits GetAllRoadBits(Ti
 

	
 
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 void SetRoadTypes(TileInde
 
	}
 
}
 

	
 
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 @@ DECLARE_ENUM_AS_BIT_SET(DisallowedRoadDi
 
 */
 
static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
 
{
 
	assert(GetRoadTileType(t) == ROAD_TILE_NORMAL);
 
	assert(IsNormalRoad(t));
 
	return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
 
}
 

	
 
@@ -170,14 +195,14 @@ static inline DisallowedRoadDirections G
 
 */
 
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);
 
}
 

	
 
@@ -193,13 +218,13 @@ static inline TrackBits GetCrossingRailB
 

	
 
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 +305,7 @@ static inline void TerminateRoadWorks(Ti
 

	
 
static inline DiagDirection GetRoadDepotDirection(TileIndex t)
 
{
 
	assert(GetRoadTileType(t) == ROAD_TILE_DEPOT);
 
	assert(IsRoadDepot(t));
 
	return (DiagDirection)GB(_m[t].m5, 0, 2);
 
}
 

	
src/roadveh_cmd.cpp
Show inline comments
 
@@ -182,7 +182,7 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 
	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);
 

	
 
@@ -404,8 +404,7 @@ static bool EnumRoadSignalFindDepot(Tile
 

	
 
	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;
 
@@ -550,7 +549,7 @@ CommandCost CmdTurnRoadVeh(TileIndex til
 
		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;
 

	
 
@@ -1159,7 +1158,7 @@ static Trackdir RoadFindPathToDest(Vehic
 
	TrackdirBits trackdirs = (TrackdirBits)GB(r,  0, 16);
 

	
 
	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;
 
		}
 
@@ -1251,7 +1250,7 @@ static Trackdir RoadFindPathToDest(Vehic
 
			DiagDirection dir;
 

	
 
			if (IsTileType(desttile, MP_ROAD)) {
 
				if (GetRoadTileType(desttile) == ROAD_TILE_DEPOT) {
 
				if (IsRoadDepot(desttile)) {
 
					dir = GetRoadDepotDirection(desttile);
 
					goto do_it;
 
				}
 
@@ -1413,7 +1412,7 @@ static Trackdir FollowPreviousRoadVehicl
 

	
 
		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));
 
		}
 

	
 
@@ -1582,8 +1581,7 @@ again:
 
					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:
 
@@ -1614,7 +1612,7 @@ again:
 
					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 {
 
@@ -1757,9 +1755,7 @@ again:
 
	/* 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);
 
		}
src/station_cmd.cpp
Show inline comments
 
@@ -1333,7 +1333,7 @@ CommandCost CmdBuildRoadStop(TileIndex t
 
{
 
	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 @@ CommandCost CmdBuildRoadStop(TileIndex t
 
	/* 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);
 

	
 
@@ -2946,8 +2945,8 @@ static CommandCost ClearTile_Station(Til
 
		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:
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -387,7 +387,7 @@ CommandCost CmdBuildBridge(TileIndex end
 
				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:
src/yapf/follow_track.hpp
Show inline comments
 
@@ -44,7 +44,7 @@ struct CFollowTrackT : public FollowTrac
 
	/** 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;
0 comments (0 inline, 0 general)