Skip to content

Commit 2f25eac

Browse files
committed
v5.0.2
1 parent 3c79b91 commit 2f25eac

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.11)
22
project (raylib_aseprite
3-
VERSION 5.0.1
3+
VERSION 5.0.2
44
DESCRIPTION "raylib_aseprite: Use Aseprite files in raylib"
55
HOMEPAGE_URL "https://github.com/robloach/raylib-aseprite"
66
LANGUAGES C)

include/cute_aseprite.h

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
SUMMARY
1414
15-
cute_asesprite.h is a single-file header that implements some functions to
15+
cute_aseprite.h is a single-file header that implements some functions to
1616
parse .ase/.aseprite files. The entire file is parsed all at once and some
1717
structs are filled out then handed back to you.
1818
@@ -65,7 +65,7 @@
6565
6666
for (int i = 0; i < ase->frame_count; ++i) {
6767
ase_frame_t* frame = ase->frames + i;
68-
anim.add_frame(frame->duration, frame->pixels);
68+
anim.add_frame(frame->duration_milliseconds, frame->pixels);
6969
}
7070
7171
@@ -123,7 +123,6 @@ typedef struct ase_udata_t ase_udata_t;
123123
typedef struct ase_cel_extra_chunk_t ase_cel_extra_chunk_t;
124124
typedef struct ase_color_profile_t ase_color_profile_t;
125125
typedef struct ase_fixed_t ase_fixed_t;
126-
typedef struct ase_cel_extra_chunk_t ase_cel_extra_chunk_t;
127126

128127
struct ase_color_t
129128
{
@@ -838,10 +837,9 @@ static char* s_fopen(const char* path, int* size, void* mem_ctx)
838837
CUTE_ASEPRITE_FILE* fp = CUTE_ASEPRITE_FOPEN(path, "rb");
839838
int sz = 0;
840839

841-
if (fp)
842-
{
840+
if (fp) {
843841
CUTE_ASEPRITE_FSEEK(fp, 0, CUTE_ASEPRITE_SEEK_END);
844-
sz = CUTE_ASEPRITE_FTELL(fp);
842+
sz = (int)CUTE_ASEPRITE_FTELL(fp);
845843
CUTE_ASEPRITE_FSEEK(fp, 0, CUTE_ASEPRITE_SEEK_SET);
846844
data = (char*)CUTE_ASEPRITE_ALLOC(sz + 1, mem_ctx);
847845
CUTE_ASEPRITE_FREAD(data, sz, 1, fp);
@@ -930,7 +928,7 @@ ase_t* cute_aseprite_load_from_memory(const void* memory, int size, void* mem_ct
930928
ase_t* ase = (ase_t*)CUTE_ASEPRITE_ALLOC(sizeof(ase_t), mem_ctx);
931929
CUTE_ASEPRITE_MEMSET(ase, 0, sizeof(*ase));
932930

933-
ase_state_t state = { 0 };
931+
ase_state_t state = { 0, 0, 0 };
934932
ase_state_t* s = &state;
935933
s->in = (uint8_t*)memory;
936934
s->end = s->in + size;
@@ -996,22 +994,22 @@ ase_t* cute_aseprite_load_from_memory(const void* memory, int size, void* mem_ct
996994
switch (chunk_type) {
997995
case 0x0004: // Old Palette chunk (used when there are no colors with alpha in the palette)
998996
{
999-
int nbPackets = (int)s_read_uint16(s);
1000-
for (int k = 0; k < nbPackets ; k++ ) {
1001-
uint16_t maxColor=0;
1002-
uint8_t skip = s_read_uint8(s);
1003-
uint16_t nbColors = s_read_uint8(s);
997+
uint16_t nbPackets = s_read_uint16(s);
998+
for (uint16_t k = 0; k < nbPackets; k++) {
999+
uint16_t maxColor = 0;
1000+
uint16_t skip = (uint16_t)s_read_uint8(s);
1001+
uint16_t nbColors = (uint16_t)s_read_uint8(s);
10041002
if (nbColors == 0) nbColors = 256;
10051003

1006-
for (int l = 0; l < nbColors; l++) {
1004+
for (uint16_t l = 0; l < nbColors; l++) {
10071005
ase_palette_entry_t entry;
10081006
entry.color.r = s_read_uint8(s);
10091007
entry.color.g = s_read_uint8(s);
10101008
entry.color.b = s_read_uint8(s);
10111009
entry.color.a = 255;
10121010
entry.color_name = NULL;
1013-
ase->palette.entries[skip+l] = entry;
1014-
if (skip+l > maxColor) maxColor = skip+l;
1011+
ase->palette.entries[skip + l] = entry;
1012+
if (skip + l > maxColor) maxColor = skip + l;
10151013
}
10161014

10171015
ase->palette.entry_count = maxColor+1;
@@ -1122,18 +1120,16 @@ ase_t* cute_aseprite_load_from_memory(const void* memory, int size, void* mem_ct
11221120
s_skip(s, 8); // For future (set to zero).
11231121
CUTE_ASEPRITE_ASSERT(ase->tag_count < CUTE_ASEPRITE_MAX_TAGS);
11241122
for (int k = 0; k < ase->tag_count; ++k) {
1125-
ase_tag_t tag;
1126-
tag.from_frame = (int)s_read_uint16(s);
1127-
tag.to_frame = (int)s_read_uint16(s);
1128-
tag.loop_animation_direction = (ase_animation_direction_t)s_read_uint8(s);
1129-
tag.repeat = s_read_uint16(s);
1123+
ase->tags[k].from_frame = (int)s_read_uint16(s);
1124+
ase->tags[k].to_frame = (int)s_read_uint16(s);
1125+
ase->tags[k].loop_animation_direction = (ase_animation_direction_t)s_read_uint8(s);
1126+
ase->tags[k].repeat = s_read_uint16(s);
11301127
s_skip(s, 6); // For future (set to zero).
1131-
tag.r = s_read_uint8(s);
1132-
tag.g = s_read_uint8(s);
1133-
tag.b = s_read_uint8(s);
1128+
ase->tags[k].r = s_read_uint8(s);
1129+
ase->tags[k].g = s_read_uint8(s);
1130+
ase->tags[k].b = s_read_uint8(s);
11341131
s_skip(s, 1); // Extra byte (zero).
1135-
tag.name = s_read_string(s);
1136-
ase->tags[k] = tag;
1132+
ase->tags[k].name = s_read_string(s);
11371133
}
11381134
was_on_tags = 1;
11391135
} break;
@@ -1190,7 +1186,8 @@ ase_t* cute_aseprite_load_from_memory(const void* memory, int size, void* mem_ct
11901186
s_skip(s, sizeof(uint32_t)); // Reserved.
11911187
const char* name = s_read_string(s);
11921188
for (int k = 0; k < (int)slice_count; ++k) {
1193-
ase_slice_t slice = { 0 };
1189+
ase_slice_t slice;
1190+
CUTE_ASEPRITE_MEMSET(&slice, 0, sizeof(slice));
11941191
slice.name = name;
11951192
slice.frame_number = (int)s_read_uint32(s);
11961193
slice.origin_x = (int)s_read_int32(s);

0 commit comments

Comments
 (0)