diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -3,6 +3,7 @@ #include "stdafx.h" #include "openttd.h" #include "bridge_map.h" +#include "cmd_helper.h" #include "debug.h" #include "functions.h" #include "rail_map.h" @@ -540,7 +541,7 @@ int32 CmdRemoveRailroadTrack(TileIndex t /** Build a train depot * @param tile position of the train depot * @param p1 rail type - * @param p2 entrance direction (DiagDirection) + * @param p2 bit 0..1 entrance direction (DiagDirection) * * @todo When checking for the tile slope, * distingush between "Flat land required" and "land sloped in wrong direction" @@ -554,10 +555,12 @@ int32 CmdBuildTrainDepot(TileIndex tile, SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); /* check railtype and valid direction for depot (0 through 3), 4 in total */ - if (!ValParamRailtype(p1) || p2 > 3) return CMD_ERROR; + if (!ValParamRailtype(p1)) return CMD_ERROR; tileh = GetTileSlope(tile, NULL); + DiagDirection dir = Extract(p2); + /* Prohibit construction if * The tile is non-flat AND * 1) The AI is "old-school" @@ -570,7 +573,7 @@ int32 CmdBuildTrainDepot(TileIndex tile, _is_old_ai_player || !_patches.build_on_slopes || IsSteepSlope(tileh) || - !CanBuildDepotByTileh(p2, tileh) + !CanBuildDepotByTileh(dir, tileh) )) { return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); } @@ -585,7 +588,6 @@ int32 CmdBuildTrainDepot(TileIndex tile, if (d == NULL) return CMD_ERROR; if (flags & DC_EXEC) { - DiagDirection dir = (DiagDirection)p2; MakeRailDepot(tile, _current_player, dir, (RailType)p1); MarkTileDirtyByTile(tile);