• Civ7 is already available! Happy playing :).

palace section of save game file format

MqsTout

Warlord
Joined
Mar 30, 2002
Messages
211
Location
Pittsburgh
I don't recall noticing any documents of the save game file format in the forums where I looked. Last night I went through and determined the Palace section for my own enjoyment (Yeah, I wanted to see a fully upgraded one for once...)

Code:
I took some time playing with Civilization 3 saved game files, to figure out the format for the palace section.
I had a saved game just before I was awarded an upgrade.  I made a few saves after choosing various upgrades and
got my start, from which I was able to feel the rest of the way to get this data.  I did crash the game a few times
with invalid data.  (Particularly, if you have the bitmask on for a piece and you don't have the data for that piece
set -- boom.)  Sometimes the palace button from the control strip in the bottom right corner of the screen would
disappear, but F9 would still bring up the palace.  I don't think that variable is contained within this section.
Those of you out there who have written or are working on save game editors, here's the information for the palaces.

Here's a clip from a save game I was playing, as the French:
+----------------------------------------------+
| 5041 4C56 9000 0000 0080 2010 | PALV...... . |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF FFFF FFFF | ............ |
| FFFF FFFF FFFF FFFF 0000 0000 | ............ |
| 0000 0000 0000 0000           | ........     |
+----------------------------------------------+
There are 32 152(0x98)-byte sections like this within the save game file.  The player's section starts at 0x0037F2D4.
The entire palace section starts at 0x0037F23C.  In the saved games I worked with anyway (from v1.17f).

The first 8 bytes seem to stay constant for each palace entry, as a header with the values:
 5041 4C56 9000 0000

The next 4 bytes are unidentified.  The only values I've seen while looking at the few saves I have are:
 0080 2010 (my side, unique)
 0000 0000 (default value)
 0000 0004 (frequent)
 0000 0014 (not uncommon)
 0010 0014 (rare)
 0000 0044 (common)
My guess is that these may have something to do with timing the upgrades.  Though, has anyone ever seen the computer
players have an upgraded palace?

32 x 4 bytes each.  PalaceView.txt says that the game can handle up to 32 upgrades per culture, even though it only
comes with graphics and information for 17.  These bytes set the culture for each piece:
 0000 0000 = AMERICAN
 0100 0000 = EUROPEAN
 0200 0000 = MEDITERRANEAN
 0300 0000 = MIDEAST
 0400 0000 = ASIAN
This makes me wonder, how many cultures could be added?  When I've tried values other than these, the game has crashed.
These values are in the order as they appear in PalaceView.txt

The next 8 bytes are unknown.  They never show any variance, though I don't recall any crashes happening when I changed
them to reasonable values.

The next (last) 4 bytes make a bitmask of which pieces have been added and which haven't.  Again, since the comments
in PalaceView.txt say there can be 32 pieces, 4 bytes times 8 bits per byte = 32 possible pieces.  However, when I put
any values into the last one, or greater than 03 in the second-to-last-one, the game would crash.  It only allowed me
to toggle on up to 18 bits:
  00000000000000000 = 0x0000 0000 = (no parts)
  11111111111111111 = 0xFFFF 0100= (all parts present)
 111111111111111111 = 0xFFFF 0300 = (highest value without crash)
  00000000000000001 = 0x0100 0000 = lawn
  00000000000000010 = 0x0200 0000 = right wing
  00000000000000011 = 0x0300 0000 = lawn and right wing
Note that the game will crash if you have the toggle for a piece on, but you do not have the culture selection
information set.  The masks are as they are in PalaceView.txt
  00000000000000001 = 0x0100 0000 = lawn
  00000000000000010 = 0x0200 0000 = wing right
  00000000000000100 = 0x0400 0000 = wing left
  00000000000001000 = 0x0800 0000 = steps
  00000000000010000 = 0x1000 0000 = wing tower right
  00000000000100000 = 0x2000 0000 = wing tower left
  00000000001000000 = 0x4000 0000 = hall right
  00000000010000000 = 0x8000 0000 = hall left
  00000000100000000 = 0x0001 0000 = hall tower right
  00000001000000000 = 0x0002 0000 = hall tower left
  00000010000000000 = 0x0004 0000 = center ground
  00000100000000000 = 0x0008 0000 = center 1st above ground
  00001000000000000 = 0x0010 0000 = arch and mini pillars
  00010000000000000 = 0x0020 0000 = tall pillars
  00100000000000000 = 0x0040 0000 = center 2nd above ground
  01000000000000000 = 0x0080 0000 = trees
  10000000000000000 = 0x0000 0100 = center 3rd above ground
 100000000000000000 = 0x0000 0200 = (no visible addition)
1000000000000000000 = 0x0000 0400 = (crash)
Yes, it is possible to have pieces added in to the save game that do not have their prerequisites, as set in the text
file met.  I did not, however, get a chance to test whether or not the game crashes on the next upgrade in the game if
you hurry it along and give yourself a floating center 3rd above ground.
 
You've never had a fully upgraded palace before? It's pretty easy if you keep your people happy enough. For me, a lot of upgrades come in a short period of a few turns when my guys are really insanely happy and then the rest are spread throughout the game.

I don't know how the game determines exactly when you get a palace upgrade.
 
Top Bottom