diff options
author | tron <tron@openttd.org> | 2007-02-24 09:42:39 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2007-02-24 09:42:39 +0000 |
commit | d3b29bcacb4589922a3afc85cf648609b49679dc (patch) | |
tree | cfdc363aade39ceff0da3ef6b20dbd7e95b49c83 /src/rail_cmd.cpp | |
parent | 1d1121f85a975a6b9ed8305c154fc39f4f5db7fd (diff) | |
download | openttd-d3b29bcacb4589922a3afc85cf648609b49679dc.tar.xz |
(svn r8876) -Fix
Replace tests with magic numbers by a simple extraction template for command parameters
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r-- | src/rail_cmd.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index d74b30096..cb4d08c80 100644 --- 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 tile, uint32 flags, uint32 p1, uint32 p2) /** 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, uint32 flags, uint32 p1, uint32 p2) 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<DiagDirection, 0>(p2); + /* Prohibit construction if * The tile is non-flat AND * 1) The AI is "old-school" @@ -570,7 +573,7 @@ int32 CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) _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, uint32 flags, uint32 p1, uint32 p2) if (d == NULL) return CMD_ERROR; if (flags & DC_EXEC) { - DiagDirection dir = (DiagDirection)p2; MakeRailDepot(tile, _current_player, dir, (RailType)p1); MarkTileDirtyByTile(tile); |