Oblivion Mod:Mod File Format/Vs Morrowind
A UESPWiki – Sua fonte de The Elder Scrolls desde 1995
< Modding
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 subrecord 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 Pseudocode
Oblivion
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 subrecord 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 if IsCompressed Read Compressed Record Data else Read Subrecords End Record Read Compressed Record Data Read Deflated Data Size (dword) Read Compressed Data (given by record size in header) Deflate Data (zLib) Read Subrecords (from the deflated data) End Read Raw Data Read Subrecords While Bytes Left in Record Read Subrecord Header if Name = XXXX Read Subrecord Data Subrecord data is the size of the next subrecord else if Previous Name = XXXX Ignore subrecord size in header, take size from previous XXXX subrecord Read Subrecord Data else Read Subrecord Data EndWhile End Read Subrecords
Morrowind
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 Subrecord Header Read Subrecord Data EndWhile EndWhile
Simple is good...