Save file format

From Arx Libertatis Wiki
Jump to navigation Jump to search

This page describes the save format used by Arx Fatalis and Arx Libertatis.

See Common file format types for a description of the type names used here.

Save files are stored in a generic container that maps names (arbitrary strings) to chunks of data. This page only describes the format of the files inside that container.

These structures are filled and parsed in src/scene/ChangeLevel.cpp and described in src/scene/SaveFormat.h in Arx Libertatis.

Savegame info (pld)

The savegame info file called "pld" consist of a single structure:

Type Description
f32 Savegame data version
char[256] Savegame name
s32 Current level
u32 Current time
1024 B (padding - always 0)

Savegame data version specifies the version number of this savegame info structure. Currently this value is always 1.005f.

The version is followed by the user-supplied name for the savegame. The special name "ARX_QUICK_ARX" is used for quicksaves. Arx Fatalis and older Arx Libertatis versions also used "ARX_QUICK_ARX1" for the second quicksave.

The current level specifies the number of the level in which the player resided when the savegame was last updated. This number can be padded to 3 digits with leading zeros and prepended with "lvl" to get the level file (1 becomes "lvl001")

The current time is the in-game time when the savegame was last updated. This is the total number of in-game milliseconds since the game start. Game-type may be paused or slowed down/sped up by spells.

Player state (player)

TODO

Global script state (globals)

TODO

Level state (lvl<number>)

To get the filename for the state of a level pad the level number to 3 digits with leading zeros and prepended that with "lvl". (1 becomes "lvl001")

Header

Type Description
f32 Level status version
u32 Game time
s32 Interactive object count
s32 Path count
s32 Light status count
s32 Ambiance data size
gmods Saved graphics modes
gmods Current graphics modes
gmods Desired graphics modes
8192 B (padding - always 0)

Level status version specifies the version number of this level status file. Currently this value is always 1.005f.

Game time is the in-game time in milliseconds when this level was last saved.

The gmods type contains:

Type Description
s32 Flags
rgb32f Depth color
f32 Clip distance
136 B (padding - always 0)

Flags is a bitwise combination of:

Flag Description
1<<0 Use depth color
1<<1 Use clip distance

Depth color is used as the fog / background color for the level.

Clip distance is used to adjust the camera far plane.

Current graphics modes are the active modes and desired graphics modes are modes that the game is fading to.

The header is followed by interactive object count object index entries, path count path status entries, ambiance data size bytes of ambiance data and light status count light status entries.

Object Index Entries

TODO

Path Status Entries

TODO

Ambiance Data

TODO

Light Status Entries

TODO

Entity state (<class>_<instance>)

TODO

Issues

Unsaved state

The following things are not included in save files:

  • Active spells (must be cast again in reload events)
  • Arrows shot by the player
  • Gibs (only live for a very short duration anyway)

Asset references

Script timers

Script timers reference byte positions in .asl script files. If the scripts are modified between saving and loading the byte position is not adjusted.

Linked entities

For linked entities the vertex indices of the linked action points are stored instead of the action point names. If the mesh files are edited between saving and loading the indices may not refer to the intended vertices.

String length

Most strings are stored in fixed-length arrays. This includes entity IDs.