summaryrefslogtreecommitdiff
path: root/src/blitter
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-09-10 00:03:47 +0000
committertruelight <truelight@openttd.org>2007-09-10 00:03:47 +0000
commitfc80e722cf64454515831ea9c645e6b25ed3d5b5 (patch)
tree23171771e8b4715d57971135197d172450cd3fa6 /src/blitter
parentab880fdf071a0f1490605bf8b7b16004ce65cc5d (diff)
downloadopenttd-fc80e722cf64454515831ea9c645e6b25ed3d5b5.tar.xz
(svn r11081) -Fix r11080: now solved the problem in a pretty way: don't do animation if we are not drawing to the screen-pointer
Diffstat (limited to 'src/blitter')
-rw-r--r--src/blitter/32bpp_anim.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index 0e2fe7969..290739e4e 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -10,9 +10,14 @@ static FBlitter_32bppAnim iFBlitter_32bppAnim;
void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
{
+ if (bp->dst < _screen.dst_ptr || bp->dst > (uint32 *)_screen.dst_ptr + _screen.width * _screen.height) {
+ /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
+ Blitter_32bppOptimized::Draw(bp, mode, zoom);
+ return;
+ }
const SpriteLoader::CommonPixel *src, *src_line;
uint32 *dst, *dst_line;
- uint8 *anim, *anim_line, *anim_end;
+ uint8 *anim, *anim_line;
if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
/* The size of the screen changed; we can assume we can wipe all data from our buffer */
@@ -21,7 +26,6 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
this->anim_buf_width = _screen.width;
this->anim_buf_height = _screen.height;
}
- anim_end = this->anim_buf + this->anim_buf_height * this->anim_buf_width - 1;
/* Find where to start reading in the source sprite */
src_line = (const SpriteLoader::CommonPixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
@@ -37,9 +41,6 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
anim = anim_line;
anim_line += this->anim_buf_width;
- /* Don't allow values of 'anim' greater than 'anim_end' to avoid buffer overflows.
- * This only happens when we are doing a big-screenshot, so it should be relative safe */
- if (anim >= anim_end || anim < this->anim_buf) anim = anim_end;
for (int x = 0; x < bp->width; x++) {
if (src->a == 0) {
@@ -48,10 +49,8 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
dst += skip;
/* Make sure the anim-buffer is cleared */
- if (anim < anim_end - skip) {
- memset(anim, 0, skip);
- anim += skip;
- }
+ memset(anim, 0, skip);
+ anim += skip;
x += skip - 1;
src += ScaleByZoom(1, zoom) * skip;
continue;
@@ -89,9 +88,7 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
break;
}
dst++;
- /* Don't increase the anim buffer anymore if we tend to run out of the buffer...
- * This only happens when we are doing a big-screenshot, so it should be relative safe */
- if (anim < anim_end) anim++;
+ anim++;
src += ScaleByZoom(1, zoom);
}
}