fortuni on 22/8/2023 at 10:26
Curious as to what info sav files contain?
Typically they are around 3000KB which is tiny (a typical screenshot is around 40-50KB and a medium sized FM can be in the region of 250MB), so what info do sav files record in order to guarantee players return to exactly the same position in the map and all previous actions (KO'ing or killing guards, opening doors, arrows used, loot collected, secrets discovered, objectives completed etc).
Or do they not record such player information if so what?
ValmontPhl on 22/8/2023 at 20:49
Pretty sure they are hex. Given how old the engine is (even ND at this point) any hex viewer/editor should yield some insight for those who are adept in them
baeuchlein on 23/8/2023 at 01:57
ValmontPhl, "hex" is just the number format used to display something. Whether this is useful for anything depends on whether the numbers mean anything. For example, a Thief savegame contains ASCII text strings, such as the name of the save, but these are more recognizable as an ASCII text than as a group of hex numbers. I also do not think that the age of any piece of software influences whether something is better displayed in hex numbers, as an ASCII text, or maybe a colour.
fortuni, after running some experiments, I think that the .sav files of Thief contain some kind of information about anything that has been changed compared to the .mis and possibly the .gam file of the mission. Neither DromEd2 nor Thief 2 load savegames correctly if I delete the corresponding .mis files from the FM folder. However, if I load a savegame in DromEd, change the position of an object, and then write the changed level/state back as a savegame, the changes are there. I would guess that the game first loads the .mis file, and then applies all changes that are recorded in the .sav file. This does also explain why old savegames do not always work with newer versions of a mission. However, since loading of a savegame from a former version of Thief 2 may result in problems, like incorrect lighting, some of the changes made between different T2 versions are apparently not saved in the .sav files.
I also remember that I frequently saw torches lit for a second after loading a savegame, then going out. These are torches I had extinguished in a mission before saving. Thus, the engine appears to first load the state of the torch as set in the .mis file, but then applies the changes stored in the .sav file.
The engine also applies some physics to objects after the save has been loaded. I just changed the position of a lantern in a quicksave so that the lantern floated in the air instead of resting on a table. I wrote that state back as a (new) quicksave, loaded the quicksave in Thief 2, and could see the hovering lantern gain speed and hitting the floor after a second. Thus, the effect of gravity is also applied to objects after loading the savegame. Maybe gravity strength is stored in the .sav, but it is only applied later.
Since the player, as well as AI's, are (special) objects in DromEd, one can assume that changes of these objects' states or coordinates on the map are also part of the data stored in .sav files. Data on whether the player has visited some rooms (important for automap function!) also has to be present in the .sav files. Textures, however, are apparently never ever changed in a game (if you exclude cases where an object first uses texture A, but then is changed to use texture B after a certain event changing the look of said object). Thus, the game most likely saves whicht texture is applied to which face (side) of an object, but most likely the texture graphics are not saved in the .sav. These are in the appropriate folders of the mission (fam, obj\txt, etc.). That's why saving a game without the Enhancement Pack (EP, EP2), and then loading it after the EP has been installed/activated, does use the newly added EP textures instead of the standard ones that were present while the save was made.
I never saw a compressed name of a savegame in any .sav, so I assume that at least parts of the save files are not compressed in any way.
So much for my guesswork. -shrug-
lordhern on 23/8/2023 at 03:54
The position and velocity data granularity is highest for garret - all other positions (and path of AI) is stored in a bit lower resolution grid. None of the info is "packed" - it's basicly a flat database with variable length data values. The inventory appears to use only the lower seven bits of a byte field datatabse and the inventory stack info is fully expanded reference the inventory and the count value is an un-signed double-wide (32bit) integer. All the remaining counters for damage, knockouts, bodies found, detections etc are saved as an unsigned 16bit integer.
The same setup/layout is also used in systemshock2 savegame files.
fortuni on 23/8/2023 at 06:08
All of the above makes sense, sav files must in some way record the x,y,z position of all objects that have changed from the original mis file positions but in instances where you have caused utter chaos, such as a major fight with bodies piled on top of each other, to my non-digital eye a loaded save seems to show exactly the same carnage scene with all moved objects being in exactly the same position.
sav files would accurately know the new x, y, z position of each body, but AI’s also have legs and arms that are flexible and when a body is slumped on a pile of other bodies their limbs fall in different directions and sav files seem to also record such minor changes but I don’t see how that could be possible if sav files only record the new position of an AI, it can’t possibly also record the directional fall of the AIs limbs.
I know I’m being a bit silly considering such minor nuances in the game, but I was playing a mission recently and a fallen AI had an arm sticking up in the air at a rather strange angle, and it was still in that position when I reloaded which made me think how the hell was that possible.
zappenduster on 23/8/2023 at 07:58
Quote Posted by fortuni
sav files would accurately know the new x, y, z position of each body, but AI's also have legs and arms that are flexible and when a body is slumped on a pile of other bodies their limbs fall in different directions and sav files seem to also record such minor changes but I don't see how that could be possible if sav files only record the new position of an AI, it can't possibly also record the directional fall of the AIs limbs.
Try this: Just beat an AI with your BJ and make an immediate QSave. If you reload, the AI will fall again, so the SAV even seem to save the info that the motion hasn't been completed. :cheeky:
nicked on 23/8/2023 at 08:05
Yes, but it doesn't store how far through the motion it is, hence why enemies will pop back up and collapse again if you load a quick save while an enemy is mid-collapse.
fortuni on 23/8/2023 at 09:30
Quote Posted by nicked
Yes, but it doesn't store how far through the motion it is, hence why enemies will pop back up and collapse again if you load a quick save while an enemy is mid-collapse.
Of course. I've seen that many times and sometimes it's highly amusing.
baeuchlein on 23/8/2023 at 11:54
I do not think that the AIs' limbs are really as flexible as they appear to be. While the limbs can be moved by the AI while the AI walks or does other things, closer examinations show that the limbs' physical properties are not always correct. For example, if I tidy up the usual mess after creating lots of carnage (or at least unconscious bodies) by stacking the AI's on top of each other, or on tables, ledges or other surfaces that are above the environment, things get weird. Every now and then I end up with an unconscious AI which is "resting" in the air, except for a very small part of the AI's body. The AI's foot may rest on solid ground, then, but the rest of my victim's body is suspended above ground, sometimes floating/hovering over a very deep abyss.
AI stacks may also change when I save a game and then reload it. Some of the AI may notably change position, e.g., they may suddenly remember that there's gravity there when I reload the appropriate savegame, and fall down, or slide down and sideways. In rare cases, I may also return to a site where I knocked out an AI earlier on, and the AI now floats at waist height. This later example of AIs not behaving properly may, however, have nothing to do with saving & reloading, but rather with the player moving rather far away from the fallen AI and re-approaching him/her/it.
And don't get me started on zombies and some other undead. I remember meeting large undead creatures in a mission sometimes (could have been "Eclipsed", or another FM using the large black undead who are "bent" at the waist), which would engage in weird behaviour if the player kills/incapacitates that AI, and saved & reloaded, or left the area and returned again. Every now and then, I found undead AI in a horizontal position, making movements as if they were having sex with the walls - sometimes while floating at waist height...:weird:
fortuni on 23/8/2023 at 12:38
Quote Posted by baeuchlein
suddenly remember that there's gravity
Wish I had remembered that yesterday when I got out of bed....shoulders still hurting. :mad:
It makes sense that sav files ought to only record object positions and orientation, but I have a feeling that sometimes they also record or remember other stuff on a deeper level, like clouds of smoke from an explosion, IIRC when you reload a save the explosion does not re-occur (so long as you don't save at the same time as the explosion of course) but the cloud of smoke is there often in the same shape as before, but a sav file couldn't possible record every particle of smoke in that cloud.