Open main menu

UESPWiki β

Oblivion Mod:Mod File Format/Vs Morrowind

< Mod / Oblivion: Oblivion Mod: Modding: Mod File Format

While the Oblivion file format is closely related to the Morrowind file format, the two formats also differ substantially both in structural elements and in details for most (all) record types. The introduction of groups, data compression and outsize field data handling all vastly complicate reading and writing of the file, while the introduction of formids greatly complicates the logic of integrating and relating changes to files.

File Parsing PseudocodeEdit

OblivionEdit

Basic pseudocode for parsing Oblivion's ESM/ESP files. Successfully tested on Oblivion.esm. Note that Header refers to the 20 byte record/group and the 6 byte field headers.

Read Header   //Required TES4 record
Read Record

While Bytes Left in File
   Read Header
   Read Group
EndWhile

Read Group

   While Bytes Left in Group
      Read Header

      if Name = GRUP
         Read Group
      else
         Read Record
   EndWhile

End Group

Read Record
   Read Header

   if IsCompressed
      Read Compressed Record Data
   else
      Read Fields

End Record


Read Compressed Record Data
   Read Deflated Data Size (dword)
   Read Compressed Data (given by record size in header)
   Deflate Data (zLib)
   Read Fields (from the deflated data)
End Read Raw Data


Read Fields

   While Bytes Left in Record
      Read Field Header
      
      if Name = XXXX
         Read Field Data
         Field data is the size of the next field
         Read Next Field Header, ignoring size

     Read Field Data
      
   EndWhile

End Read Fields

MorrowindEdit

For comparison only, the pseudocode for parsing Morrowind's ESM/ESP/ESS files is trivial:

While Bytes Left in File
   Read Record Header

   While Bytes Left in Record
      Read Field Header
      Read Field Data
   EndWhile
EndWhile

Simple is good...