mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
would be outside the map. Change behaviour so that a reasonable approximation is returned so that zooming (out) still works (GrimRC)
This commit is contained in:
parent
7977bd51a4
commit
a9fa6fd506
11
viewport.c
11
viewport.c
@ -297,6 +297,7 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
|
|||||||
{
|
{
|
||||||
Point pt;
|
Point pt;
|
||||||
int a,b;
|
int a,b;
|
||||||
|
uint z;
|
||||||
|
|
||||||
if ( (uint)(x -= vp->left) >= (uint)vp->width ||
|
if ( (uint)(x -= vp->left) >= (uint)vp->width ||
|
||||||
(uint)(y -= vp->top) >= (uint)vp->height) {
|
(uint)(y -= vp->top) >= (uint)vp->height) {
|
||||||
@ -315,8 +316,11 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
|
|||||||
b = x-y;
|
b = x-y;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((uint)a < MapMaxX() * TILE_SIZE && (uint)b < MapMaxY() * TILE_SIZE) {
|
/* we need to move variables in to the valid range, as the
|
||||||
uint z;
|
* GetTileZoomCenterWindow() function can call here with invalid x and/or y,
|
||||||
|
* when the user tries to zoom out along the sides of the map */
|
||||||
|
a = clamp(a, 0, (int)(MapMaxX() * TILE_SIZE) - 1);
|
||||||
|
b = clamp(b, 0, (int)(MapMaxY() * TILE_SIZE) - 1);
|
||||||
|
|
||||||
z = GetSlopeZ(a, b ) / 2;
|
z = GetSlopeZ(a, b ) / 2;
|
||||||
z = GetSlopeZ(a + z, b + z) / 2;
|
z = GetSlopeZ(a + z, b + z) / 2;
|
||||||
@ -326,9 +330,6 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
|
|||||||
|
|
||||||
pt.x = a + z;
|
pt.x = a + z;
|
||||||
pt.y = b + z;
|
pt.y = b + z;
|
||||||
} else {
|
|
||||||
pt.x = pt.y = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user