summaryrefslogtreecommitdiff
path: root/viewport.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-08-06 16:32:49 +0000
committertron <tron@openttd.org>2006-08-06 16:32:49 +0000
commit3254155930feb807f81031ebfdc9acedbe33745e (patch)
treef588dd076c3c98d0c2983a7f5c9e5f5dcbc4447b /viewport.c
parent7c9165827eb64c74efbad0198e97fe1a77fdb258 (diff)
downloadopenttd-3254155930feb807f81031ebfdc9acedbe33745e.tar.xz
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
Diffstat (limited to 'viewport.c')
-rw-r--r--viewport.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/viewport.c b/viewport.c
index eb0cbe51e..200098188 100644
--- a/viewport.c
+++ b/viewport.c
@@ -294,7 +294,6 @@ ViewPort *IsPtInWindowViewport(const Window *w, int x, int y)
static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
{
- int z;
Point pt;
int a,b;
@@ -314,16 +313,19 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
a = x+y;
b = x-y;
#endif
- z = GetSlopeZ(a, b) >> 1;
- z = GetSlopeZ(a+z, b+z) >> 1;
- z = GetSlopeZ(a+z, b+z) >> 1;
- z = GetSlopeZ(a+z, b+z) >> 1;
- z = GetSlopeZ(a+z, b+z) >> 1;
- pt.x = a+z;
- pt.y = b+z;
+ if ((uint)a < MapMaxX() * TILE_SIZE && (uint)b < MapMaxY() * TILE_SIZE) {
+ uint z;
- if ((uint)pt.x >= MapMaxX() * TILE_SIZE || (uint)pt.y >= MapMaxY() * TILE_SIZE) {
+ z = GetSlopeZ(a, b ) / 2;
+ z = GetSlopeZ(a + z, b + z) / 2;
+ z = GetSlopeZ(a + z, b + z) / 2;
+ z = GetSlopeZ(a + z, b + z) / 2;
+ z = GetSlopeZ(a + z, b + z) / 2;
+
+ pt.x = a + z;
+ pt.y = b + z;
+ } else {
pt.x = pt.y = -1;
}