summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-01-25 15:47:58 +0000
committerfrosch <frosch@openttd.org>2008-01-25 15:47:58 +0000
commit6f6708e8448f891bc03c87c630a0c8f9cf47d332 (patch)
treef904e7af79be7c749721bcae930333e27ad88830 /src/station_cmd.cpp
parentd11aeb118c7a0b5f6c1900dfcdcfd97ea2333097 (diff)
downloadopenttd-6f6708e8448f891bc03c87c630a0c8f9cf47d332.tar.xz
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 8b30d98de..a31a3d053 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1945,14 +1945,9 @@ CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
CommandCost cost;
- DiagDirection direction;
- switch (GetTileSlope(tile, NULL)) {
- case SLOPE_SW: direction = DIAGDIR_NE; break;
- case SLOPE_SE: direction = DIAGDIR_NW; break;
- case SLOPE_NW: direction = DIAGDIR_SE; break;
- case SLOPE_NE: direction = DIAGDIR_SW; break;
- default: return_cmd_error(STR_304B_SITE_UNSUITABLE);
- }
+ DiagDirection direction = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
+ if (direction == INVALID_DIAGDIR) return_cmd_error(STR_304B_SITE_UNSUITABLE);
+ direction = ReverseDiagDir(direction);
/* Docks cannot be placed on rapids */
if (IsRiverTile(tile)) return_cmd_error(STR_304B_SITE_UNSUITABLE);