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

From OniGalore
Jump to navigation Jump to search
mNo edit summary
(added plain-English lede; linked to save-gamed editors; noted that cheats are always unlocked these days; various wording)
Line 1: Line 1:
{{Retitle|persist.dat}}
{{Retitle|persist.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 player settings (besides [[Oni (folder)/key_config.txt|key bindings]]). It also records whether the cheats are enabled (i.e. whether you have beaten the game), and whether you killed Griffin in {{C|13}}.
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.
 
==Introduction==
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 [[AE:FERAL|Intel Mac build]]), and whether you killed Griffin in {{C|13}}.


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).
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).


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 [[AE:FERAL|native Intel build]], the files are now all in little-endian format, as in Windows.
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.


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 and are never written to. The savepoints of the original 14 levels follow. This leaves 25 unused levels at the end of the saved-game file.
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.


Only savepoint names 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.  
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.


==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 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).


==Header==
==Header data==
[[Image:Persist_header.gif]]
[[Image:Persist_header.gif]]


Line 69: Line 74:
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 savepoints (40 levels, 10 savepoints per level). The size of a savepoint is 516 bytes so the array size is 206,400 bytes.


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



Revision as of 21:57, 25 December 2015

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 OniLib for Mac, though a hex-based examination of this file is given below for the curious.

Introduction

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 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 Intel Mac build), and whether you killed Griffin in CHAPTER 13 . PHOENIX RISING.

The persist.dat file has nothing to do with Oni's 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).

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.

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.

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.

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 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 currently unlockable due to the 40-level savepoint limit in the persist.dat (probably reflecting an underlying engine restriction).

Header data

Persist header.gif

Offset Type Raw Hex Value Description
0x00 int32 0F 00 00 00 15 version
0x04 int32 0E 0B D0 D0 0xD0D00B0E signature
0x08 int32 5C 7F 0C 00 0x000C7F5C level unlock flags for levels 0-31; each level has a corresponding bit:
0x01 00 00 00 - level 0 (always unlocked, ignored)
0x02 00 00 00 - level 1 (always unlocked, ignored)
0x04 00 00 00 - level 2
...
0x00 00 08 00 - level 19
0x0C int32 00 00 00 00 level unlock flags for levels 32-63
0x10 int32 00 00 00 00 level unlock flags for levels 64-95
0x14 int32 00 00 00 00 level unlock flags for levels 96-127
0x18 int32 00 00 00 00 level unlock flags for levels 128-159
0x1C int32 00 00 00 00 level unlock flags for levels 160-191
0x20 int32 00 00 00 00 level unlock flags for levels 192-223
0x24 int32 00 00 00 00 level unlock flags for levels 224-255
0x28 int32 01 00 00 00 1 killed Griffin (0 = no, 1 = yes)
0x2C FE 1B 00 00 7166 unlocked weapons; one bit for each weapon; the number of corresponding bit is given by the skill index value in the primary firing mode block of each ONWC
0x30 1F 00 00 00 31 unlocked items; one bit for each item type (hypo, ammo etc.)
0x34 13 00 00 00 19 last read diary page (level)
0x38 01 00 00 00 1 last read diary page (page)
0x3C int32 04 00 00 00 4 level of graphical detail; the following options are possible:
0 - extra low
1 - low
2 - medium
3 - high
4 - extra high
0x40 float 00 00 80 3F 1.0 sound volume (0.0 = min, 1.0 = max)
0x44 int32 06 00 00 00 6 option flags; the following values are possible:
0x01 00 00 00 - show subtitles
0x02 00 00 00 - invert mouse
0x04 00 00 00 - game won (aka cheats enabled)
0x48 int32 02 00 00 00 2 difficulty; the following values are possible:
0 - easy
1 - medium
2 - hard
0x4C int16 20 03 800 resolution: width
0x4E int16 02 58 600 resolution: height
0x50 int16 20 00 32 color depth
0x52 00 00 padding
0x54 float 00 00 00 3F 0.5 gamma correction; from 0.0 to 1.0, 0.5 means no correction
0x58 int32 03 00 00 00 3 last saved level
0x5C int32 02 00 00 00 3 last saved savepoint


Killed Griffin
Used in Chapters 13 and 14; set with killed_griffen, read with did_kill_griffen.


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.

Savepoint data

Persist dat.gif


Offset Type Raw Hex Value Description
0x00 char[64] "Save Point 2" name of the save point in Load Game dialog
0x40 int32 01 00 00 00 1 valid (was saved previously), i.e. "Should we display this in Load Game?" (0 = no, 1 = yes)
0x44 int32 BE 00 00 00 190 current player health (HP)
0x48 int32 C8 00 00 00 200 max player health (HP)
0x4C float AE 20 FB 43 502.255310 x position of the player
0x50 float 03 32 4B 42 50.798839 y position of the player
0x54 float 55 12 25 C4 -660.286437 z position of the player
0x58 float 80 06 C1 3F 1.508010 player facing direction (radians)
0x5C int32 00 00 00 00 0 number of ballistic ammo clips
0x60 int32 01 00 00 00 1 number of energy cells
0x64 int32 00 00 00 00 0 shield (percent)
0x68 int32 00 00 00 00 0 invisibility (1/60 seconds)
0x6C int32 01 00 00 00 1 number of hypos
0x70 int32 00 00 00 00 0 door keys
0x74 int32 01 00 00 00 1 whether player has LSI (0 = no, 1 = yes)
0x78 char[128] "" weapon name (unused)
0xF8 int32 00 00 00 00 0 weapon ammo (unused)
0xFC char[128] "" weapon name (unused)
0x17C int32 00 00 00 00 0 weapon ammo (unused)
0x180 char[128] "w2_sap" weapon name
0x200 int32 1E 00 00 00 30 weapon ammo


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, dual-wielded guns and a holstered weapon....