Changeset - r14639:3a2f2aaac095
[Not reviewed]
master
0 1 0
terkhen - 15 years ago 2010-02-24 21:47:06
terkhen@openttd.org
(svn r19228) -Codechange: Move an additional check from CmdBuildRoadStop to CheckFlatLandRoadStop.
1 file changed with 6 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -804,16 +804,20 @@ static CommandCost CheckFlatLandRailStat
 
 * @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 t
 
	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;
0 comments (0 inline, 0 general)