summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-06-08 18:45:14 +0000
committertruelight <truelight@openttd.org>2007-06-08 18:45:14 +0000
commit98c3056aa66b82817ab2dc4045c718de4dbaaf1a (patch)
tree11fc57739dc8f723c5f23d04ca69ff4bf323b5e7
parentd3a7fb8d7361b346cb28f4497f4834dd7043687a (diff)
downloadopenttd-98c3056aa66b82817ab2dc4045c718de4dbaaf1a.tar.xz
(svn r10070) -Fix: fix the rounding problem of zoom-levels in zoom.hpp, so it is global for every call
-rw-r--r--src/gfx.cpp2
-rw-r--r--src/zoom.hpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index a0812baed..d529728de 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -856,7 +856,7 @@ static inline void GfxBlitTileZoom(BlitterParams *bp)
if (num <= 0) continue;
}
- num = UnScaleByZoom(num + ScaleByZoom(1, Tzoom) - 1, Tzoom);
+ num = UnScaleByZoom(num, Tzoom);
switch (Tmode) {
case BM_COLOUR_REMAP:
diff --git a/src/zoom.hpp b/src/zoom.hpp
index c80f094bf..500182d71 100644
--- a/src/zoom.hpp
+++ b/src/zoom.hpp
@@ -37,14 +37,14 @@ static inline int ScaleByZoom(int value, ZoomLevel zoom)
{
if (zoom == ZOOM_LVL_NORMAL) return value;
int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
- return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom;
+ return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom)) >> -izoom;
}
static inline int UnScaleByZoom(int value, ZoomLevel zoom)
{
if (zoom == ZOOM_LVL_NORMAL) return value;
int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
- return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
+ return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom;
}
#endif /* ZOOM_HPP */