summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-01-02 11:05:42 +0000
committerrubidium <rubidium@openttd.org>2014-01-02 11:05:42 +0000
commit9bf21279f839d2452b99b4eb3324617439c18a4c (patch)
tree4e0513604d22bf47fe2d7e2994832e019c065699
parentfb4db0b022489fe70b99f5bdef92c46721f3cfbb (diff)
downloadopenttd-9bf21279f839d2452b99b4eb3324617439c18a4c.tar.xz
(svn r26202) -Cleanup: since ZOOM_LEVEL_NORMAL 0 and there aren't any negative zoom levels, there is no reason to account for negative zoom levels in the zoom functions (based on patch by MJP)
-rw-r--r--src/zoom_func.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/zoom_func.h b/src/zoom_func.h
index aa4bf3d69..5f1bf830d 100644
--- a/src/zoom_func.h
+++ b/src/zoom_func.h
@@ -23,9 +23,8 @@
*/
static inline int ScaleByZoom(int value, ZoomLevel zoom)
{
- if (zoom == ZOOM_LVL_NORMAL) return value;
- int izoom = zoom - ZOOM_LVL_NORMAL;
- return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom) - 1) >> -izoom;
+ assert(zoom >= 0);
+ return value << zoom;
}
/**
@@ -37,9 +36,8 @@ static inline int ScaleByZoom(int value, ZoomLevel zoom)
*/
static inline int UnScaleByZoom(int value, ZoomLevel zoom)
{
- if (zoom == ZOOM_LVL_NORMAL) return value;
- int izoom = zoom - ZOOM_LVL_NORMAL;
- return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom;
+ assert(zoom >= 0);
+ return (value + (1 << zoom) - 1) >> zoom;
}
/**
@@ -50,9 +48,8 @@ static inline int UnScaleByZoom(int value, ZoomLevel zoom)
*/
static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
{
- if (zoom == ZOOM_LVL_NORMAL) return value;
- int izoom = zoom - ZOOM_LVL_NORMAL;
- return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom;
+ assert(zoom >= 0);
+ return value << zoom;
}
/**
@@ -63,9 +60,8 @@ static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
*/
static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
{
- if (zoom == ZOOM_LVL_NORMAL) return value;
- int izoom = zoom - ZOOM_LVL_NORMAL;
- return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
+ assert(zoom >= 0);
+ return value >> zoom;
}
#endif /* ZOOM_FUNC_H */