Skip to content

Commit

Permalink
Fix view fails when using transparency, sync animation. Closes #189
Browse files Browse the repository at this point in the history
  • Loading branch information
Mignari committed May 6, 2017
1 parent faec29c commit f84b560
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions source/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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++) {
Expand Down Expand Up @@ -1499,6 +1499,7 @@ void Animator::reset()
is_complete = false;
direction = ANIMATION_FORWARD;
current_loop = 0;
async = false;
setFrame(-1);
}

Expand Down

0 comments on commit f84b560

Please sign in to comment.