respect slice keys frame number on ase file format (fix #4062)

This commit is contained in:
Nicolás Pinochet 2023-10-11 13:48:20 -03:00 committed by David Capello
parent f6db44b81d
commit 4fc36aaf02

View File

@ -1252,7 +1252,8 @@ static void ase_file_write_slice_chunk(FILE* f, dio::AsepriteFrameHeader* frame_
{
ChunkWriter chunk(f, frame_header, ASE_FILE_CHUNK_SLICE);
auto range = slice->range(fromFrame, toFrame);
frame_t firstFromFrame = slice->empty() ? fromFrame : slice->fromFrame();
auto range = slice->range(firstFromFrame, toFrame);
ASSERT(!range.empty());
int flags = 0;
@ -1268,10 +1269,10 @@ static void ase_file_write_slice_chunk(FILE* f, dio::AsepriteFrameHeader* frame_
fputl(0, f); // 4 bytes reserved
ase_file_write_string(f, slice->name()); // slice name
frame_t frame = fromFrame;
frame_t frame = firstFromFrame;
const SliceKey* oldKey = nullptr;
for (auto key : range) {
if (frame == fromFrame || key != oldKey) {
if (frame == firstFromFrame || key != oldKey) {
fputl(frame, f);
fputl((int32_t)(key ? key->bounds().x: 0), f);
fputl((int32_t)(key ? key->bounds().y: 0), f);