Skip to content

MPF image loading doesn't match disassembly #10

@im-apbecker

Description

@im-apbecker

Hi.

I've been reading through the client disassembly and making my own library for working with DA file types, network protocols, etc. I found this repo and looked to see if it could fill in any gaps I have in my own code. I noticed that your MPF file loading doesn't match up with the client disassembly method (exists at: 0x50f490):

Image

Your code does a direct compare of the flag value with 4, but should only be checking if bit 2 is on (n & 4) != 0, as well as seeking a fixed amount forward to skip over the as-of-yet unknown data instead of sizing that dynamically as the client does. Reference code that matches the client:

impl MpfImage {
  pub fn read_from(buf: &[u8]) -> Self {
    let mut cursor = Cursor::new(buf);

    let magic = u32::read_le(&mut cursor).unwrap();

    if magic != 0xffffffff {
      cursor.seek(io::SeekFrom::Current(-4)).unwrap();
    } else {
      let some_flags = u32::read_le(&mut cursor).unwrap();

      if (some_flags & 4) != 0 {
        let some_count = u32::read_le(&mut cursor).unwrap() as usize;
        let some_count_or_4 = some_count.min(4);
        let mut unknown_16_words = [[0; 4]; 4];

        for n in 0..some_count {
          let mut buf = [0; 4];

          cursor.read_exact(&mut buf).unwrap();

          if n < some_count_or_4 {
            unknown_16_words[n][3] = buf[0];
            unknown_16_words[n][0] = buf[1];
            unknown_16_words[n][1] = buf[2];
            unknown_16_words[n][2] = 0; // should be buf[3]?
          }
        }
      }
    }

    MpfImage::read(&mut cursor).unwrap()
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions