Binary save game layout

PC : Turn based WW2 goodness in the mold of Panzer General. This promises to be a true classic!

Moderators: Slitherine Core, Panzer Corps Moderators, Panzer Corps Design

PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Binary save game layout

Post by PanzerTum »

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.
sbpc1
Senior Corporal - Ju 87G
Senior Corporal - Ju 87G
Posts: 94
Joined: Tue May 03, 2022 1:10 pm

Re: Binary save game layout

Post by sbpc1 »

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
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

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..
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

Found the unit link and also the transport type link.
Now for the hero names & stats.
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

Question still is if the hero stats are cumulative in the save file or per awarded hero..
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

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.
sbpc1
Senior Corporal - Ju 87G
Senior Corporal - Ju 87G
Posts: 94
Joined: Tue May 03, 2022 1:10 pm

Re: Binary save game layout

Post by sbpc1 »

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
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

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
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

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
sbpc1
Senior Corporal - Ju 87G
Senior Corporal - Ju 87G
Posts: 94
Joined: Tue May 03, 2022 1:10 pm

Re: Binary save game layout

Post by sbpc1 »

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?
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

My first tests are with the python language, I think it has all the possibilities I need including creation of excel files.
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5957
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Binary save game layout

Post by terminator »

Some screenshots might be interesting ?
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

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:
Image

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:
Image
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.
Image

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.
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5957
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Binary save game layout

Post by terminator »

Very interesting, thank you :)
cw58
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 487
Joined: Thu Sep 24, 2015 9:44 pm

Re: Binary save game layout

Post by cw58 »

You might find this thread helpful:
https://www.slitherine.com/forum/viewto ... 1&t=102217
faos333
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1465
Joined: Sat Feb 16, 2019 9:04 pm

Re: Binary save game layout

Post by faos333 »

Indeed very interesting, thanks for sharing
Battlefield Europe get the most from Panzer Corps 8)
Download the new 2.4 Mod here http://www.slitherine.com/forum/viewtopic.php?f=147&t=47985
PanzerTum
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 111
Joined: Sat Sep 03, 2022 7:23 am

Re: Binary save game layout

Post by PanzerTum »

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.
McGuba
Colonel - Ju 88A
Colonel - Ju 88A
Posts: 1560
Joined: Thu Mar 15, 2012 7:34 pm

Re: Binary save game layout

Post by McGuba »

PanzerTum wrote: Wed Jan 04, 2023 10:31 pm So are there any other units whose values change with experience?
Where can I find that, in the rules file?
It is in the "exp.pzdat" file in the Data folder. Easy to edit simple text file, everything is explained in its header.

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 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.

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. :) So please keep it up, if you can. Editing the save game files may be useful for some.
ImageImage
slitherine.com/forum/viewtopic.php?f=147&t=47985
slitherine.com/forum/viewtopic.php?f=147&t=36969
sbpc1
Senior Corporal - Ju 87G
Senior Corporal - Ju 87G
Posts: 94
Joined: Tue May 03, 2022 1:10 pm

Re: Binary save game layout

Post by sbpc1 »

keep going very interested in this
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5957
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Binary save game layout

Post by terminator »

+1
Post Reply

Return to “Panzer Corps”