From f84b5603420590166fd91df25c73ccef4d2f70b9 Mon Sep 17 00:00:00 2001 From: Nailson Date: Sat, 6 May 2017 12:31:26 -0300 Subject: [PATCH] Fix view fails when using transparency, sync animation. Closes #189 --- source/definitions.h | 1 + source/graphics.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/definitions.h b/source/definitions.h index d81f903b..eb3ac879 100644 --- a/source/definitions.h +++ b/source/definitions.h @@ -118,6 +118,7 @@ // The default size of sprites #define SPRITE_PIXELS 32 +#define SPRITE_PIXELS_SIZE SPRITE_PIXELS * SPRITE_PIXELS // The sea layer #define GROUND_LAYER 7 diff --git a/source/graphics.cpp b/source/graphics.cpp index 21d54f36..38c4423c 100644 --- a/source/graphics.cpp +++ b/source/graphics.cpp @@ -1167,7 +1167,7 @@ uint8_t* GameSprite::NormalImage::getRGBAData() } } - const int pixels_data_size = SPRITE_PIXELS * SPRITE_PIXELS * 4; + const int pixels_data_size = SPRITE_PIXELS_SIZE * 4; uint8_t* data = newd uint8_t[pixels_data_size]; bool use_alpha = g_gui.gfx.hasTransparency(); uint8_t bpp = use_alpha ? 4 : 3; @@ -1177,7 +1177,7 @@ uint8_t* GameSprite::NormalImage::getRGBAData() // decompress pixels while(read < size && write < pixels_data_size) { int transparent = dump[read] | dump[read + 1] << 8; - if(use_alpha && transparent >= size) // Corrupted sprite? + if(use_alpha && transparent >= SPRITE_PIXELS_SIZE) // Corrupted sprite? break; read += 2; for(int i = 0; i < transparent && write < pixels_data_size; i++) { @@ -1499,6 +1499,7 @@ void Animator::reset() is_complete = false; direction = ANIMATION_FORWARD; current_loop = 0; + async = false; setFrame(-1); }