Oni (folder)/persist.dat: Difference between revisions

lots of wording improvements and some corrections; structured the opening paragraphs better, with more subheaders
m (link fix)
(lots of wording improvements and some corrections; structured the opening paragraphs better, with more subheaders)
Line 1: Line 1:
{{Retitle|persist.dat}}
{{Retitle|persist.dat}}
Persist.dat is the save-game and preference file for Oni. It can be edited most easily with GUI tools such as [[OSGE]] for Windows and [http://mods.oni2.net/node/155 OniLib] for Mac, though a hex-based examination of this file is given below for the curious.
The persist.dat file is the save-game and preference file for Oni. It can be edited most easily with GUI tools such as [[OSGE]] for Windows and [http://mods.oni2.net/node/155 OniLib] for Mac, though [[OBD]]-style hex-based documentation of this file is given below.


==Introduction==
The persist.dat file has nothing to do with Oni's [[Dat|.dat level files]] despite the ".dat" extension (it looks like Bungie West simply used .dat for every kind of file Oni read and wrote – saved_film####.dat, lvl_#_###_corpse.dat, etc. – until they later added .raw and then .sep as unique suffixes when they needed to break out some resource data from the levelX_Final.dat).
As players of Oni are well aware, the game does not allow arbitrary saving ("save anywhere"), but relies on the use of fixed savepoints activated through level scripting by reaching certain places in each level. This means that by setting a maximum number of levels and savepoints for Oni, the developer could store the total state of the player's progress in a single, fixed-size file -- a 206,496 byte file, to be exact.


In addition to savepoint data, persist.dat has a header which stores Oni's preferences as chosen on the Options screen (note that this does not include [[Oni (folder)/key_config.txt|key bindings]]). It also records whether the cheats are enabled, i.e. whether you have beaten the game (however, cheats are unlocked at all times when playing with the [[Daodan DLL]] installed or when using a [[FERAL|Intel Mac build]]), and whether you killed Griffin in {{C|13}}.
==Progress saving==
As players of Oni are well aware, the game does not allow arbitrary saving ("save anywhere"), but relies on the use of fixed save points activated by reaching certain places in each level, at which point the level scripting uses the [[BSL]] function <tt>save_game</tt> to mark your progress. This means that by deciding on a maximum number of levels and save points, Bungie West could store the total state of the player's progress in a fixed-size file – 206,496 bytes, to be exact.


The persist.dat file has nothing to do with Oni's [[Dat|instance files]] despite the ".dat" extension (it looks like Bungie West simply used .dat for every kind of file Oni read and wrote -- saved_film####.dat, lvl_#_###_corpse.dat, etc., then later on added .raw and then .sep as unique suffixes when they needed to break out the level data .dats).
As you will see below, many aspects of the game world are ''not'' saved in persist.dat; essentially, anything not pertaining to Konoko herself, such as the position of AIs and the presence of power-ups on the ground. What <u>is</u> stored is Konoko's position, health and inventory. Everything else is essentially hardcoded by the level scripting and will always be put in the same place when that save point is loaded.


The original Mac game application and the Omni Group build were for PPC Macs, thus numbers were written big-endian (e.g., the 0x08 field in the header would be 00 0C 7F 5C). This meant that the saved-game files were not interchangeable between PC and Mac versions of Oni. However, with modern Macs running a native Intel build, the files are now saved in little-endian format, as in Windows.
==Game preferences==
In addition to save point data, persist.dat has a header section which stores Oni's preferences as chosen on the Options screen (note that this omits key bindings since they're stored in [[key_config.txt]]). It also records whether the [[cheats]] are enabled, i.e. whether you have beaten the game (however, cheats are unlocked at all times when playing with the [[Anniversary Edition]] or [[Daodan DLL]] installed or when using the [[FERAL|Intel Mac build]]), as well as whether you killed Griffin in {{C|13}}.


The header of the file is 0x60=96 bytes long. It is followed by an array of 400 savepoints, 0x204=516 bytes each, grouped implicitly into 40 levels, 10 savepoints per level. The first 10 savepoints belong to level 0, which contains global game data rather than a specific level, thus they are never written to. The savepoints of the original 14 levels follow. This leaves 25 unused level slots at the end of the saved-game file.
==Endianness==
The Windows version of persist.dat stores its numbers in little-endian format. Bungie's original Mac game application and The Omni Group's Mac OS X port were built for PowerPC Macs, thus numbers were written big-endian (e.g., the 0x08 field in the header would be 00 0C 7F 5C). This meant that the save-game files were not compatible between Windows and Mac versions of Oni. However, with modern Macs running a native Intel build, the files are now saved in little-endian format and are thus interchangeable between Windows and Mac Oni.


Only the names of savepoints, not levels, are stored in this file (and they are all named uniformly as "Save Point ''x''" even though they could say anything). The actual level names are taken from the [[ONLD]] files of level 0, except for Chapters 0 and 1: "TCTF Training" and "Syndicate Warehouse" are hard-coded into the engine for some reason.
==Overview==
The header of the file is 0x60=96 bytes long. It is followed by an array of 400 save points, 0x204=516 bytes each, grouped implicitly into 40 levels with 10 save points per level for a total of 206,400 bytes. The first 10 save points belong to level 0, which contains global game data rather than a specific level, thus they are never written to. The save points of the game's 14 levels follow. This leaves 25 unused level slots at the end of the save-game file.
 
Only the names of save points, not levels, are stored in this file (and they are all named uniformly as "Save Point ''n''" even though they could say anything). The actual level names are taken from the ONLD resources in level0_Final, except for Chapter 1's name, "Syndicate Warehouse", which was hard-coded into the engine for a reason explained on the [[ONLD]] page.


==Unlocking more levels==
==Unlocking more levels==
To unlock all possible levels, fill the range 0x08 to 0x28 with "FF". So far this has caused no problems, and allows you to add more levels to the game. Levels will not be visible unless there is a corresponding level''x''_Final.dat in the GameDataFolder, and an ONLD which matches this level number is found in level0_Final.dat. Levels above 39 are not currently unlockable due to the 40-level savepoint limit in the persist.dat (probably reflecting an underlying engine restriction).
To unlock all possible levels, fill the range 0x08 to 0x28 with "FF". So far this has caused no problems, and allows you to add more levels to the game. Levels will not be visible unless there is a corresponding levelX_Final.dat in the GameDataFolder and an ONLD which matches this level number is found in level0_Final.dat. Levels above 39 are not unlockable due to the 40-level save point limit in the persist.dat.


==Header data==
==Header data==
Line 64: Line 69:
{{OBDtr| 0x54 | float |C87C64| 00 00 00 3F | 0.5 | gamma correction; from 0.0 to 1.0, 0.5 means no correction }}
{{OBDtr| 0x54 | float |C87C64| 00 00 00 3F | 0.5 | gamma correction; from 0.0 to 1.0, 0.5 means no correction }}
{{OBDtr| 0x58 | int32 |B0C3D4| 03 00 00 00 | 3  | last saved level }}
{{OBDtr| 0x58 | int32 |B0C3D4| 03 00 00 00 | 3  | last saved level }}
{{OBDtr| 0x5C | int32 |E7CEA5| 02 00 00 00 | 3  | last saved savepoint }}
{{OBDtr| 0x5C | int32 |E7CEA5| 02 00 00 00 | 3  | last saved save point }}
|}
|}


Line 72: Line 77:




After this header is an array of 400 savepoints (40 levels, 10 savepoints per level). The size of a savepoint is 516 bytes so the array size is 206,400 bytes.
After this header is an array of 400 save points (40 levels, 10 save points per level). The size of a save point is 516 bytes so the array size is 206,400 bytes.


==Savepoint data==
==Save point data==
[[Image:Persist dat.gif]]
[[Image:Persist dat.gif]]


Line 103: Line 108:
|}
|}


;Player health
:Storing both the player's current HP and max HP allows the game to scale your health appropriately if the difficulty level is changed between saving the game and restoring from it.


;Weapon slots
;Weapon slots
:Yes, Virginia, Oni does seem to support saved data for three weapons, even though the player can only carry one in the final game. Perhaps the three weapon slots were planned to allow for, say, [[Fully Armed Konoko|dual-wielded guns and a holstered weapon]]....
:Yes, Virginia, Oni does seem to support saved data for three weapons, even though the player can only carry one in the final game. Perhaps the three weapon slots were planned to allow for, say, [[Fully Armed Konoko|dual-wielded guns and a holstered weapon]]....


[[Category:Oni binary data docs]]
{{OBD}}