Binary save game layout
Moderators: Slitherine Core, Panzer Corps Moderators, Panzer Corps Design
Binary save game layout
I know this has been asked in the past but I did not see a follow-up on this.
I wonder what the binary layout of the savefiles is.
I know it is utf-16 little endian and am able to find (and modify if I want) some of the unit attributes but there is still a long way to go.
Ideally I develop something where savefile in results in a excel or csv file out with all the units and stats. I do not really care about fancy ui's.
Even more ideally this tool is callable via the web.
I know the dossiertool has been developed in the past but I am not sure if that tool had savefiles as input. Anyway I cannot get the the tool to start anyway..
So all and all I would be very happy if a (partial) layout of the savefile is known.
I wonder what the binary layout of the savefiles is.
I know it is utf-16 little endian and am able to find (and modify if I want) some of the unit attributes but there is still a long way to go.
Ideally I develop something where savefile in results in a excel or csv file out with all the units and stats. I do not really care about fancy ui's.
Even more ideally this tool is callable via the web.
I know the dossiertool has been developed in the past but I am not sure if that tool had savefiles as input. Anyway I cannot get the the tool to start anyway..
So all and all I would be very happy if a (partial) layout of the savefile is known.
Re: Binary save game layout
it is a pure binary file AFAIK no encryption i have edited the hero values using a hex editor program but nothing more than that
Re: Binary save game layout
At the moment I know how to find Ammo, Fuel, Entrenchment, kills, losses, strength and experience.
Still looking for the link to the equipment.pzeqp file so I can load the basic unit stats.
Probably key based, all units have an ID in the equipment file, but sofar I have not been able to find this key in the save file.
Also the hero link I still have to investigate
indeed it is just binary, no encryption, just as in PG..
Still looking for the link to the equipment.pzeqp file so I can load the basic unit stats.
Probably key based, all units have an ID in the equipment file, but sofar I have not been able to find this key in the save file.
Also the hero link I still have to investigate
indeed it is just binary, no encryption, just as in PG..
Re: Binary save game layout
Found the unit link and also the transport type link.
Now for the hero names & stats.
Now for the hero names & stats.
Re: Binary save game layout
Question still is if the hero stats are cumulative in the save file or per awarded hero..
Re: Binary save game layout
Heroes are separately listed in the save file so you need to add all the characteristics together.
The unit database is also internal in the save file so no need to look up the equipment file.
This also means that changing the equipment file during a scenario has no effect.
The unit listing is still a bit vague, it seems to start twice, maybe once for lost units, not sure yet.
It should also contain the location on the map and whether or not it is deployed.
The unit database is also internal in the save file so no need to look up the equipment file.
This also means that changing the equipment file during a scenario has no effect.
The unit listing is still a bit vague, it seems to start twice, maybe once for lost units, not sure yet.
It should also contain the location on the map and whether or not it is deployed.
Re: Binary save game layout
seems like you are making progress. any chance of a screen capture?
if you are using excel i can maybe help if things get complicated or time consuming
if you are using excel i can maybe help if things get complicated or time consuming
Re: Binary save game layout
Well, I am still busy finding out the exact structure of the parts I want, mainly the units and consequently also the equipment db in the save file.
Equipment DB is relatively simple although it starts looking differently for unitkeys above 256 when the key switches from 1 to 2 bytes. Not an issue for the German units but for most of the units of the other countries.
The units themselves are variable length since they also contain heroes, battle history and some other stuff
A unit looks something like this:
Unit structure
• Unit
o Unit name
Unit type
Transport type
8byte FF
o Unit attributes
12 rows + 1 byte attributes (193 bytes
Battle history Array
• Name date
• 7 bytes (varying values
• Text
• 9 bytes (varying values
4 byte FF
o Hero list
Hero 1 name & image
• Name
• 7 bytes
• Image
• 3 bytes
8 byte FF
Hero attributes 34 bytes
Hero 2 name & image
8 byte FF
Hero 2 attributes 34 bytes
Hero 3 name & image
8 byte ff 34 bytes
13 bytes
List of scenarios?
8 byte FF
4 bytes
• New unit
The file is a combination of binary & utf-16
Sofar it is only analyzing, building will be another challenge
Equipment DB is relatively simple although it starts looking differently for unitkeys above 256 when the key switches from 1 to 2 bytes. Not an issue for the German units but for most of the units of the other countries.
The units themselves are variable length since they also contain heroes, battle history and some other stuff
A unit looks something like this:
Unit structure
• Unit
o Unit name
Unit type
Transport type
8byte FF
o Unit attributes
12 rows + 1 byte attributes (193 bytes
Battle history Array
• Name date
• 7 bytes (varying values
• Text
• 9 bytes (varying values
4 byte FF
o Hero list
Hero 1 name & image
• Name
• 7 bytes
• Image
• 3 bytes
8 byte FF
Hero attributes 34 bytes
Hero 2 name & image
8 byte FF
Hero 2 attributes 34 bytes
Hero 3 name & image
8 byte ff 34 bytes
13 bytes
List of scenarios?
8 byte FF
4 bytes
• New unit
The file is a combination of binary & utf-16
Sofar it is only analyzing, building will be another challenge
Re: Binary save game layout
Apparently the units are listed twice in the save, once with the values at the start of the scenario and once with the values at the current turn. The logic for this escapes me.
What's worse is that sofar I haven't been able to determine the logic for the starting point of the second listing. once I have that it is relatively straightforward :
16
b'2 Pio Dir I4M3D2'
b'I\x00'
unittype: 73
attr1: b'\x1e\x00' 30
attr2: b'\x05\x00' 5
attr4 - Strength: b'\x0c\x00' 12
attr5 - Max ammo???: b'\n\x00' 10
attr6 - Experience: b'\xfc\x01' 508
attr7 - Fuel: b'\x00\x00' 0
attr8 - Ammo: b'\x05\x00' 5
attr9 - Kills: b'\xf4\t' 2548
attr10 - Losses: b'\x83\x00' 131
Infantry kills: b'l\x00' 108
Tank kills: b'\x14\x00' 20
Recon kills: b'\x03\x00' 3
AT kills: b'\x17\x00' 23
Artillery kills: b'\x10\x00' 16
attr16 - Bunker kills: b'\x0e\x00' 14
What's worse is that sofar I haven't been able to determine the logic for the starting point of the second listing. once I have that it is relatively straightforward :
16
b'2 Pio Dir I4M3D2'
b'I\x00'
unittype: 73
attr1: b'\x1e\x00' 30
attr2: b'\x05\x00' 5
attr4 - Strength: b'\x0c\x00' 12
attr5 - Max ammo???: b'\n\x00' 10
attr6 - Experience: b'\xfc\x01' 508
attr7 - Fuel: b'\x00\x00' 0
attr8 - Ammo: b'\x05\x00' 5
attr9 - Kills: b'\xf4\t' 2548
attr10 - Losses: b'\x83\x00' 131
Infantry kills: b'l\x00' 108
Tank kills: b'\x14\x00' 20
Recon kills: b'\x03\x00' 3
AT kills: b'\x17\x00' 23
Artillery kills: b'\x10\x00' 16
attr16 - Bunker kills: b'\x0e\x00' 14
Re: Binary save game layout
very interesting. good luck with working it out. maybe there is some software that could help? maybe modders of some other similar games have "hacked" savegame files in a similar way?
Re: Binary save game layout
My first tests are with the python language, I think it has all the possibilities I need including creation of excel files.
-
- Field Marshal - Elefant
- Posts: 5957
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom
Re: Binary save game layout
Some screenshots might be interesting ?
Re: Binary save game layout
Well there really isn't that much to show yet. The savefile is giving up its secrets but a number of things are still unclear.
I do not have to know every byte but that still leaves a number of things to find out.
when you look at the internal equipment file you see this format:

Next there are 2 unit lists in the file. I just found out that the 2nd list is the list of units deployed in the scenario. The first list contains all your units with partially outdated attributes like kills and losses and such.
There are multiple variations of the unit list entry but the main one looks look this:

Oleh Dir does not use a transport so that is missing from this entry.
Sometimes the unit long name is also in the entry, especially when you renamed a captured unit. The layout is somewhat different then.
Inside the unit entry is also the list of heros. Each is mentioned separately with their specific attributes. If you want to know the cumulative values of a unit you have to add them all to the base values.

There is also a difference between the different campains so I have to find a better way of positioning inside the savefile.
All in all it takes quite a bit of time and concentration but it is nice to do.
I do not have to know every byte but that still leaves a number of things to find out.
when you look at the internal equipment file you see this format:

Next there are 2 unit lists in the file. I just found out that the 2nd list is the list of units deployed in the scenario. The first list contains all your units with partially outdated attributes like kills and losses and such.
There are multiple variations of the unit list entry but the main one looks look this:

Oleh Dir does not use a transport so that is missing from this entry.
Sometimes the unit long name is also in the entry, especially when you renamed a captured unit. The layout is somewhat different then.
Inside the unit entry is also the list of heros. Each is mentioned separately with their specific attributes. If you want to know the cumulative values of a unit you have to add them all to the base values.

There is also a difference between the different campains so I have to find a better way of positioning inside the savefile.
All in all it takes quite a bit of time and concentration but it is nice to do.
-
- Field Marshal - Elefant
- Posts: 5957
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom
Re: Binary save game layout
Very interesting, thank you 

Re: Binary save game layout
You might find this thread helpful:
https://www.slitherine.com/forum/viewto ... 1&t=102217
https://www.slitherine.com/forum/viewto ... 1&t=102217
Re: Binary save game layout
Indeed very interesting, thanks for sharing
Battlefield Europe get the most from Panzer Corps
Download the new 2.4 Mod here http://www.slitherine.com/forum/viewtopic.php?f=147&t=47985

Download the new 2.4 Mod here http://www.slitherine.com/forum/viewtopic.php?f=147&t=47985
Re: Binary save game layout
Finally a bit of progress after a while.
I've got the equipment table in an array now.
So when I list the units I can lookup all the values of the specific unit type.
Making headway with the deployed units as well.
I can programmatically list all the heros and their specific values.
So for a specific unit I can determine the base values and add the hero values.
Still have to find out what experience does with attack values.
For example AA units get +2 attack for each 100 of experience.
So are there any other units whose values change with experience?
Where can I find that, in the rules file?
The goal is still to be able to generate an excel file from a PC save file.
Not sure yet how I will handle the listings yet. There are two unit listings in the save file. A total Core as a snapshot at the start of the scenario and a deployed core with up to date values.
I've got the equipment table in an array now.
So when I list the units I can lookup all the values of the specific unit type.
Making headway with the deployed units as well.
I can programmatically list all the heros and their specific values.
So for a specific unit I can determine the base values and add the hero values.
Still have to find out what experience does with attack values.
For example AA units get +2 attack for each 100 of experience.
So are there any other units whose values change with experience?
Where can I find that, in the rules file?
The goal is still to be able to generate an excel file from a PC save file.
Not sure yet how I will handle the listings yet. There are two unit listings in the save file. A total Core as a snapshot at the start of the scenario and a deployed core with up to date values.
Re: Binary save game layout
It is in the "exp.pzdat" file in the Data folder. Easy to edit simple text file, everything is explained in its header.
I guess the first is used if the player presses "restart scenario" at some point. It should also contain the original names of the units, added by the scenario designer. These original unit names can be used in the editor to refer to certain units and thus make them "unique". Otherwise they would lose their "uniqeness" if the player renames them to something else.There are two unit listings in the save file. A total Core as a snapshot at the start of the scenario and a deployed core with up to date values.
Other than that, your findings are really interesting here. It makes me remember hex editing the PG.exe of Panzer General, back in the day.



slitherine.com/forum/viewtopic.php?f=147&t=47985
slitherine.com/forum/viewtopic.php?f=147&t=36969
Re: Binary save game layout
keep going very interested in this
-
- Field Marshal - Elefant
- Posts: 5957
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom