mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
This commit is contained in:
parent
9515328962
commit
0b888ccc00
|
@ -2228,7 +2228,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
|
|||
return false;
|
||||
_players_ai[p->index].cur_tile_a = TILE_MASK(_build_tunnel_endtile - TileOffsByDiagDir(_players_ai[p->index].cur_dir_a));
|
||||
return true;
|
||||
} else {
|
||||
} else { // IsBridge(tile)
|
||||
// Check if the bridge points in the right direction.
|
||||
// This is not really needed the first place AiRemoveTileAndGoForward is called.
|
||||
if (DiagDirToAxis(GetTunnelBridgeDirection(tile)) != (_players_ai[p->index].cur_dir_a & 1)) return false;
|
||||
|
|
|
@ -1667,8 +1667,8 @@ bool AfterLoadGame()
|
|||
|
||||
case MP_TUNNELBRIDGE:
|
||||
/* Middle part of "old" bridges */
|
||||
if (old_bridge && IsBridgeTile(t) && HasBit(_m[t].m5, 6)) break;
|
||||
if ((IsTunnel(t) ? GetTunnelBridgeTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t))) == TRANSPORT_ROAD) {
|
||||
if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
|
||||
if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
|
||||
SetRoadTypes(t, ROADTYPES_ROAD);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -313,7 +313,7 @@ static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection directi
|
|||
* entrance :-) */
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
} else { // IsBridge(tile)
|
||||
TileIndex tile_end;
|
||||
if (GetTunnelBridgeDirection(tile) != direction ||
|
||||
GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
|
||||
|
@ -733,7 +733,7 @@ start_at:
|
|||
tile = flotr.tile;
|
||||
/* tile now points to the exit tile of the tunnel */
|
||||
}
|
||||
} else {
|
||||
} else { // IsBridge(tile)
|
||||
TileIndex tile_end;
|
||||
if (GetTunnelBridgeDirection(tile) != ReverseDiagDir(direction)) {
|
||||
/* We are not just leaving the bridge */
|
||||
|
|
|
@ -132,10 +132,9 @@ CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
break;
|
||||
|
||||
case MP_TUNNELBRIDGE:
|
||||
{
|
||||
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
|
||||
if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR;
|
||||
} break;
|
||||
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
|
||||
if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR;
|
||||
break;
|
||||
|
||||
default:
|
||||
return CMD_ERROR;
|
||||
|
@ -498,18 +497,16 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
case MP_STATION:
|
||||
if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
|
||||
if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
|
||||
/* Don't allow "upgrading" the roadstop when vehicles are already driving on it */
|
||||
/* 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);
|
||||
|
||||
/* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */
|
||||
if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR;
|
||||
} break;
|
||||
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
|
||||
if (HasBit(GetRoadTypes(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;
|
||||
|
||||
default:
|
||||
do_clear:;
|
||||
|
@ -672,7 +669,7 @@ CommandCost CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32
|
|||
cost.AddCost(ret);
|
||||
}
|
||||
had_bridge = true;
|
||||
} else {
|
||||
} else { // IsTunnel(tile)
|
||||
if ((!had_tunnel || GetTunnelBridgeDirection(tile) == DIAGDIR_SE || GetTunnelBridgeDirection(tile) == DIAGDIR_SW)) {
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
|
|
|
@ -1520,7 +1520,7 @@ static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev)
|
|||
}
|
||||
}
|
||||
|
||||
if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) && HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
|
||||
if (IsTileType(gp.new_tile, MP_TUNNELBRIDGE) && HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
|
||||
/* Vehicle has just entered a bridge or tunnel */
|
||||
v->cur_image = v->GetImage(v->direction);
|
||||
v->UpdateDeltaXY(v->direction);
|
||||
|
|
|
@ -3135,7 +3135,7 @@ static void TrainController(Vehicle *v, bool update_image)
|
|||
min(v->cur_speed, GetBridge(GetBridgeType(v->tile))->speed);
|
||||
}
|
||||
|
||||
if (!(IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) || !HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
|
||||
if (!IsTileType(gp.new_tile, MP_TUNNELBRIDGE) || !HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
|
||||
v->x_pos = gp.x;
|
||||
v->y_pos = gp.y;
|
||||
VehiclePositionChanged(v);
|
||||
|
|
|
@ -701,7 +701,7 @@ static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags)
|
|||
if (IsTunnel(tile)) {
|
||||
if (flags & DC_AUTO) return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST);
|
||||
return DoClearTunnel(tile, flags);
|
||||
} else if (IsBridge(tile)) { // XXX Is this necessary?
|
||||
} else { // IsBridge(tile)
|
||||
if (flags & DC_AUTO) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
return DoClearBridge(tile, flags);
|
||||
}
|
||||
|
@ -879,7 +879,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
|||
AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, ti->x + BB_data[4], ti->y + BB_data[5], BB_data[6], BB_data[7], TILE_HEIGHT, ti->z);
|
||||
|
||||
DrawBridgeMiddle(ti);
|
||||
} else if (IsBridge(ti->tile)) { // XXX is this necessary?
|
||||
} else { // IsBridge(ti->tile)
|
||||
const PalSpriteID *psid;
|
||||
int base_offset;
|
||||
bool ice = HasTunnelBridgeSnowOrDesert(ti->tile);
|
||||
|
@ -943,8 +943,6 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
|||
}
|
||||
|
||||
DrawBridgeMiddle(ti);
|
||||
} else {
|
||||
NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1113,7 +1111,7 @@ static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y)
|
|||
|
||||
/* In the tunnel entrance? */
|
||||
if (5 <= pos && pos <= 10) return z;
|
||||
} else {
|
||||
} else { // IsBridge(tile)
|
||||
DiagDirection dir = GetTunnelBridgeDirection(tile);
|
||||
uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x);
|
||||
|
||||
|
@ -1187,7 +1185,7 @@ static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td)
|
|||
if (IsTunnel(tile)) {
|
||||
td->str = (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) ?
|
||||
STR_5017_RAILROAD_TUNNEL : STR_5018_ROAD_TUNNEL;
|
||||
} else {
|
||||
} else { // IsBridge(tile)
|
||||
td->str = _bridge_tile_str[GetTunnelBridgeTransportType(tile) << 4 | GetBridgeType(tile)];
|
||||
}
|
||||
td->owner = GetTileOwner(tile);
|
||||
|
@ -1341,7 +1339,7 @@ static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex ti
|
|||
return VETSB_ENTERED_WORMHOLE;
|
||||
}
|
||||
}
|
||||
} else if (IsBridge(tile)) { // XXX is this necessary?
|
||||
} else { // IsBridge(tile)
|
||||
DiagDirection dir;
|
||||
|
||||
if (v->IsPrimaryVehicle()) {
|
||||
|
|
|
@ -214,7 +214,7 @@ protected:
|
|||
return false;
|
||||
}
|
||||
}
|
||||
} else if (IsBridge(m_new_tile)) {
|
||||
} else { // IsBridge(m_new_tile)
|
||||
if (!m_is_bridge) {
|
||||
DiagDirection ramp_enderdir = GetTunnelBridgeDirection(m_new_tile);
|
||||
if (ramp_enderdir != m_exitdir) {
|
||||
|
|
Loading…
Reference in New Issue