summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-06-13 00:00:04 +0000
committersmatz <smatz@openttd.org>2008-06-13 00:00:04 +0000
commite40f835a7efae2cb00b626ab6b66951c16bc1337 (patch)
tree62c818d8ff408e5122104c87e9104ba67dc91edb /src
parent421a040e8919c95a431253b797a48c8f12b37343 (diff)
downloadopenttd-e40f835a7efae2cb00b626ab6b66951c16bc1337.tar.xz
(svn r13502) -Fix (r11212): drawing of zoomed out partial sprites could cause deadlocks or crashes
Diffstat (limited to 'src')
-rw-r--r--src/gfx.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index ac9e32fb6..676e68ffc 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -689,7 +689,7 @@ void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub)
}
}
-static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub)
+static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub)
{
const DrawPixelInfo *dpi = _cur_dpi;
Blitter::BlitterParams bp;
@@ -715,8 +715,8 @@ static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMod
bp.height = UnScaleByZoom(sprite->height - clip_top - clip_bottom, dpi->zoom);
bp.top = 0;
bp.left = 0;
- bp.skip_left = UnScaleByZoom(clip_left, dpi->zoom);
- bp.skip_top = UnScaleByZoom(clip_top, dpi->zoom);
+ bp.skip_left = UnScaleByZoomLower(clip_left, dpi->zoom);
+ bp.skip_top = UnScaleByZoomLower(clip_top, dpi->zoom);
x += ScaleByZoom(bp.skip_left, dpi->zoom);
y += ScaleByZoom(bp.skip_top, dpi->zoom);
@@ -767,6 +767,9 @@ static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMod
if (bp.width <= 0) return;
}
+ assert(bp.skip_left + bp.width <= UnScaleByZoom(sprite->width, dpi->zoom));
+ assert(bp.skip_top + bp.height <= UnScaleByZoom(sprite->height, dpi->zoom));
+
BlitterFactoryBase::GetCurrentBlitter()->Draw(&bp, mode, dpi->zoom);
}