summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-02-24 21:47:06 +0000
committerterkhen <terkhen@openttd.org>2010-02-24 21:47:06 +0000
commitf7f08c586fb797e9a62f3f818f2fec929e016abe (patch)
treed0bcbf348b0e8a1b856579f36d71ba8788047e7e
parent524a10b3754e4e393293d6e1fa17cfb42eac1590 (diff)
downloadopenttd-f7f08c586fb797e9a62f3f818f2fec929e016abe.tar.xz
(svn r19228) -Codechange: Move an additional check from CmdBuildRoadStop to CheckFlatLandRoadStop.
-rw-r--r--src/station_cmd.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 383336b4e..913f0cbc2 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -804,16 +804,20 @@ static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag fl
* @param flags Operation to perform.
* @param invalid_dirs Prohibited directions (set of DiagDirections).
* @param build_over_road True if trying to build a drive through station over a normal road tile.
+ * @param axis Axis of a drive-through road stop.
* @param rts Road types to build. Bits already built at the tile will be removed.
* @return The cost in case of success, or an error code if it failed.
*/
-static CommandCost CheckFlatLandRoadStop(TileIndex tile, DoCommandFlag flags, uint invalid_dirs, bool build_over_road, RoadTypes &rts)
+static CommandCost CheckFlatLandRoadStop(TileIndex tile, DoCommandFlag flags, uint invalid_dirs, bool build_over_road, Axis axis, RoadTypes &rts)
{
int allowed_z = -1;
CommandCost cost = CheckBuildableTile(tile, invalid_dirs, allowed_z);
if (cost.Failed()) return cost;
+ /* Road bits in the wrong direction. */
+ if (build_over_road && (GetAllRoadBits(tile) & (axis == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_ERROR_DRIVE_THROUGH_DIRECTION);
+
RoadTypes cur_rts = IsNormalRoadTile(tile) ? GetRoadTypes(tile) : ROADTYPES_NONE;
uint num_roadbits = 0;
if (build_over_road) {
@@ -1625,12 +1629,10 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (!IsValidDiagDirection(ddir)) return CMD_ERROR;
/* If it is a drive-through stop, check for valid axis. */
if (is_drive_through && !IsValidAxis((Axis)ddir)) return CMD_ERROR;
- /* Road bits in the wrong direction */
- if (build_over_road && (GetAllRoadBits(tile) & (DiagDirToAxis(ddir) == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_ERROR_DRIVE_THROUGH_DIRECTION);
if (!CheckIfAuthorityAllowsNewStation(tile, flags)) return CMD_ERROR;
- CommandCost cost = CheckFlatLandRoadStop(tile, flags, is_drive_through ? 5 << ddir : 1 << ddir, build_over_road, rts);
+ CommandCost cost = CheckFlatLandRoadStop(tile, flags, is_drive_through ? 5 << ddir : 1 << ddir, build_over_road, DiagDirToAxis(ddir), rts);
if (cost.Failed()) return cost;
Station *st = NULL;