Here is a small tool, which can load savegames of Europa Universalis 3.
Why
I use it to remove not so important things to reduce loading times.. But maybe it is useful for other tasks too
The code
Previously I had some code here, but better look at the github page.. There is the newest version with smaller bugfixes.
Format
The format is quite simple: you have key-value pairs which are represented by >key="value"\< or >key=value\< (without the \</>) When there are no quotations it's either a number, a date or a string keyword Also there exist to other value-types: Object and List. Objects again contain key-value pairs and are surrounded by { and } Lists contain only values separated by a space and surrounded by { and } Example
test=123 test=456 REB= { sthg={0 1 2 3 4} }
Parsing
I started to do the parsing line-based thats why i ended up with some strange code. To decide whether it is a list or an object, I look always 2 lines ahead with the lookahead2 function which wraps around a fixer-method, which returns text which is line-parsable.. To make it line-parseable objects are required to have their { start on a new line and } and on a new line while the lists on the other hand are required to have { and } on the same line as the =
Internal Format
Since keywords can happen multiple times and maybe they have some order The base-format is a list containing dictionaries with {'key':keyFromLine,'val':valueFromLine} where valueFromLine is either again a list or a string
Example for Save-game size reduction
I added an example how to reduce the size of the save-game which will remove all battles from it. Those battles often amount to multiple thousands of lines.. Another good idea would be to remove the history-entries.
Errors may happen
The parsing just supports my test-savegame files.. Maybe there exist other formats too where my parser might fail.. So if you use this on your only savegame of your 300 years empire and something goes wrong you have been warned.. Just do a backup and nothing bad should happen.
The code
Since this blog-code might become outdated here is my github repo: here
Commentaires: