robojumper / DarkestDungeonSaveEditor

Darkest Dungeon Save File (.json) Reader, Writer, Editor. Also, Spreadsheets.
MIT License
75 stars 8 forks source link

Padding zeroes of embedded DSON's `Meta2Entry`s contains non-zero bytes #51

Closed thanhnguyen2187 closed 2 years ago

thanhnguyen2187 commented 2 years ago

Hi.

I am dealing with a DSON file that contains embedded DSON files within itself. The embedded DSON files contain some Meta2Entrys that are padded by non-zero bytes. For example:

{
  "__revision_dont_touch": 1683488768,
  "base_root": {
    "version": 513,
    "nextGuid": 274,
    "dismissed_hero_count": 0,
    "heroes": {
      "56": {
        "hero_file_data": {
          "raw_data": {
            "__revision_dont_touch": 0,
            "base_root": {
              ...
              "actor": {
                "name": "Botin",
                "current_hp": 37,
                ...
              },
              "heroClass": "man_at_arms",
              ...
            }
          }
        }
      },
      ...
    },
    "last_party": {
      "last_party_guids": [
        -1,
        138,
        56,
        -1
      ]
    },
    "highest_resolve_xp": 24
  }
}

current_hp in this case has these 7 bytes [116, 95, 104, 0, 0, 20, 66] as its raw data. Following the rules on padding, the first 3 bytes get skipped. [0, 0, 20, 66] still gets read into 37. Do you have any idea what is the meaning of those skipped bytes? I attached the full file here.

Thanks!

robojumper commented 2 years ago

Personally I always assumed it was uninitialized memory that the serialization process skipped due to padding and never overwrote.

thanhnguyen2187 commented 2 years ago

Oh I see. That somehow... makes sense. [116, 95, 104] can be read as t_h, which is a part of current_hp, I think.