bbodi/rustarok

Sprite loading with and without RLE encoding seem to be doing the same thing

drgomesp opened this issue · 0 comments

I'm trying to understand the code for sprite loading, and I've been struggling to understand the different implementations for loading indexed images with and without RLE encoding.

Both

SpriteFile::read_indexed_frames(&mut reader, indexed_frame_count)
and
SpriteFile::read_indexed_frames_rle(&mut reader, indexed_frame_count)
seem to be doing the same thing, with slightly different implementations:

 fn read_indexed_frames(buf: &mut BinaryReader, indexed_frame_count: usize) -> Vec<SprFrame> {
    (0..indexed_frame_count)
        .map(|_i| {
            let width = buf.next_u16();
            let height = buf.next_u16();
            let frame = SprFrame {
                typ: SpriteType::PAL,
                width: width as usize,
                height: height as usize,
                data_index: buf.tell(),
            };
            buf.skip(width as u32 * height as u32);
            //                buf.next(width as u32 * height as u32).to_vec();
            frame
        })
        .collect()
}
fn read_indexed_frames_rle(
    reader: &mut BinaryReader,
    indexed_frame_count: usize,
) -> Vec<SprFrame> {
    (0..indexed_frame_count)
        .map(|_i| {
            let width = reader.next_u16();
            let height = reader.next_u16();
            let data_index = reader.tell();
            let size = reader.next_u16();
            reader.skip(size as u32);
             SprFrame {
                typ: SpriteType::PAL,
                width: width as usize,
                height: height as usize,
                data_index,
            }
        })
        .collect()
}

Am I not seeing something, or maybe is this how they are actually supposed to be?