summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-05-09 19:45:02 +0000
committeryexo <yexo@openttd.org>2009-05-09 19:45:02 +0000
commit8d22e4bec3d21f2f99c2d6094d14aaa88865bcb8 (patch)
tree71b5bba15fbb76b3f3365df13007f0c2087b20eb /src
parentf8944cc9b3fb846ddd8d22bc5601bfeec26c5d6b (diff)
downloadopenttd-8d22e4bec3d21f2f99c2d6094d14aaa88865bcb8.tar.xz
(svn r16262) -Fix [NoAI]: Check slopes passed to the API better for validity
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_tile.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/ai/api/ai_tile.cpp b/src/ai/api/ai_tile.cpp
index f5bf96f1a..70bb1fb83 100644
--- a/src/ai/api/ai_tile.cpp
+++ b/src/ai/api/ai_tile.cpp
@@ -73,14 +73,14 @@
/* static */ bool AITile::IsSteepSlope(Slope slope)
{
- if (slope == SLOPE_INVALID) return false;
+ if ((slope & ~(SLOPE_ELEVATED | SLOPE_STEEP | SLOPE_HALFTILE_MASK)) != 0) return false;
return ::IsSteepSlope((::Slope)slope);
}
/* static */ bool AITile::IsHalftileSlope(Slope slope)
{
- if (slope == SLOPE_INVALID) return false;
+ if ((slope & ~(SLOPE_ELEVATED | SLOPE_STEEP | SLOPE_HALFTILE_MASK)) != 0) return false;
return ::IsHalftileSlope((::Slope)slope);
}
@@ -124,9 +124,7 @@
/* static */ AITile::Slope AITile::GetComplementSlope(Slope slope)
{
- if (slope == SLOPE_INVALID) return SLOPE_INVALID;
- if (IsSteepSlope(slope)) return SLOPE_INVALID;
- if (IsHalftileSlope(slope)) return SLOPE_INVALID;
+ if ((slope & ~SLOPE_ELEVATED) != 0) return SLOPE_INVALID;
return (Slope)::ComplementSlope((::Slope)slope);
}