1
\$\begingroup\$

my question is about save-games format.

Look at this screenshot:

enter image description here

On the left I made a "simple" fake savegame (Ini format) and on the right there is a "complex" TR2 save game.

I'm wondering how does the complex one work, and why.

I thought that it was made this way to prevent from cheating-editing values, and the format was just a "simple" save encrypted with a key (like aes does).

I'm sceptic though, I don't think every game has implemented an encryption algorithm to save some data. Maybe I miss something, or maybe it's done this way.

Do you have some informations about this ? Have you ever asked yourselves how does this works ? Thanks, have a good day !

\$\endgroup\$
1
  • \$\begingroup\$ btw, you may (or may not) find libraries that support saving object data into a Json format possibly. This format is very human readable and could help with debugging. \$\endgroup\$
    – AturSams
    Commented Jan 27, 2015 at 10:58

1 Answer 1

1
\$\begingroup\$

It is not so complex. A lot of times, the saved data is in binary format. In many oop (and not oop) programming languages, data objects can be serialized and dumped into a file. It is that simple (no encryption, just plain old binary data). When you want to load the saved state, you simply "read the objects" from the serialized data.

You need to think of memory and all objects residing inside it, as a big array of bytes. In fact everything in your computer's memory is binary data (1's and 0's) and the easiest way to store a state in a game, is often to simply dump that state composed of 1's and 0's into a file.

What you did with that text file is parse the binary data into ascii which is readable to humans and great for debugging but probably requires more work when and if you need to save more data. Dumping a bunch of objects that represent the state in the game, could be easier to maintain and extend. Using a protocol, that parses everything into a text file is possibly easier for others to interface with as the contents of the file serve also as documentation, since they are also human readable content.

\$\endgroup\$
5
  • \$\begingroup\$ I kinda see what you mean, but i don't see how it can be made. The object in question is a string ? Let's say i want to save more than one integer.. \$\endgroup\$
    – Riptide
    Commented Jan 25, 2015 at 20:01
  • \$\begingroup\$ @Riptide A 32bit integer is 4 byte which are written to the savegame file as they are. Most APIs for file I/O support reading and writing files both in ASCII and in binary mode. \$\endgroup\$
    – Philipp
    Commented Jan 25, 2015 at 20:07
  • \$\begingroup\$ @Riptide By the way, I see some integers in the file you posted. NUL, NUL, NUL, strange character is usually a 32bit integer with a low (<256) value. \$\endgroup\$
    – Philipp
    Commented Jan 25, 2015 at 20:38
  • \$\begingroup\$ I see now how it's done, I will look at serialization, thanks a lot. \$\endgroup\$
    – Riptide
    Commented Jan 25, 2015 at 21:52
  • \$\begingroup\$ @Riptide An object is a bunch of data clamped up together. It can be health (hp), position, stats, level, inventory contents etc.. \$\endgroup\$
    – AturSams
    Commented Jan 26, 2015 at 8:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .