Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Save Game Conversion Utility

WinFan3672 edited this page Oct 25, 2022 · 1 revision

What The Utility Does

The Save Game Conversion Utility [also known as the SGCU] can convert save game files from older versions to newer ones, by adding placeholder or default data in, allowing for old save files to be used in newer versions, meaning you never have to worry about updates breaking older save files, and you never have to write any such utilities yourself, since the SGCU handles it for you.

Preface- Why Not Object Serialisation?

I know that a lot of people will be pissed off that I don't use object serialisation, like with the pickle module built into Python. The short answer- I have no idea how pickle works. The long one? It's complicated.

What is pickle?

pickle is a Python module that allows you to perform what is known as object serialisation. It is basically a system that allows you to dump the contents of a Python object, such as a variable, and save its contents in a format that allows for:

  • Sharing the pickle data on a network
  • Loading it later, essentially acting as a save game

What is "OLL2"?

OLL2 is the save game format used by OpenLife since Alpha 12. It is compiled at save time and is essentially a long string which is Base64 encoded. when loading the game, it is decoded and turned into an array using split(). OpenLife then uses the data from the array it retrieved from the OLL2 save file to get data to load variables and jumps into adult().

In short, OLL2 refers to the save game system used by OpenLife that I bodged together.

Why I don't use Pickle

There are a few reasons why I chose to make OLL2 and not use Pickle or something similar.

Complexity

I cannot be arsed to work out how pickle works. I don't care. My method works OK.

Portability

You can download a save file and share it easily, since it has a proper save format. It can be shared and sent over a network easier, since you can share a 2KB file instead of worrying about network protocols or whatever, since everything is in one file.

You can also name the file whatever you want instead of seeing the character's name and have as many people with the same name as possible and have little to no confusion.

Version Control

You can "lock" OLL2 for different versions, without multiple save file formats being used. The first part of an OLL2 save file is a version identifier. It allows for identifying if a file is compatible with OpenLife.

Flexibility

Since it has proper version control, I can re-organise the way OLL2 works by changing the order of things. I can also bodge it together by adding more to OLL2 with no reprecussions.

How the utility works

There are multiple phases of conversion SGCU uses.

Detection Phase

The game detects that the save file uses an older version of OpenLfie and needs to be converted. This is done by checking the first 2 elements of the decoded save file and seeing that:

  • The version of OpenLife used by the save file is older than the OpenLife version
  • The SGCU can convert the save file, since it understands the save file format for the detected version

Save Conversion Phase

This is incredibly simple. The save file gets fed into the SGCU, where it is:

  • Decoded from base64 into a string
  • Converted into a list
  • Converts the outdated version identifier [the first 2 items in the list] to the correct one
  • Converts the list into a string

The SGCU then:

  • Adds custom data to the end of the save file
  • Saves the save file to itself.

After that, the SGCU may feed the save file to itself again, in order to convert it again. This is because the SGCU can only convert one version at a time [I.E Alpha 12 --> Alpha 13 --> Alpha 14] and may need to convert the save file multiple times in order to load the save file in the target version.

That's it, really.

Clone this wiki locally