I'm not sure if this is the appropriate forum to post this in, but I figure it is the most appropriate.
I haven't seen any concise documentation on the save format in Civilization III. I've done a briefish investigation myself, and I post the results of what I've found. I hope that others will also post anything they know below too. The information is as at Play the World 1.14f
---
The autosaves are uncompressed, but normal saves are compressed by default. You have to decompress saves to get them in the correct format. I'm not sure how they're compressed though. It's probably something standard like ZLib.
Numbers in the file are generally stored as 4-byte integers, with the lowest value byte coming first. UINT_MAX (i.e. 0xFFFFFFFF) is generally used to represent 'null' values.
The save file is a database which contains a series of records. There are different types of records. Each record begins with the name of its record type. This is followed by a 4-byte integer which is the length of the record's data (does not include the name or this integer itself).
The records generally either describe the rules the game is played under - the improvements that can be built, units that can be built, how much they cost etc etc: everything that can be set in the editor - I call these 'rules records', and actual game state data - the map, where units are located on the map, where cities are, etc etc. I call these 'game data records'.
Since almost everything in the rules can be edited in the editor, the game data records are what I'm most interested in.
The following are the known records in the game:
BLDGN - rules - the state of buildings
CNSL
CONT
CTZN
CULT - rules - culture
DIFF - rules - difficulty settings
ERAS
EXPR
FAXXT
GAME
GOOD
GOVT - rules - government types
HIST - histogram (?)
ICBM
LEAD - gamedata - general information about a civilization
PALV
PEER
RACE - rules - the races available to play
RPLS
RPLT
RULE
TECHR - rules - the technologies available
TERR - rules - terrain
TFRM
TILE - gamedata - a single tile on the map
UNIT - gamedata - a single unit
WRLD
WSIZ - world size (?)
I have found a little about the formats of some of the more interesting records, as follows:
LEAD section:
This section documents information about each civilization. The first LEAD section in the file is for barbarians, and the second one is for the player's civilization. Further ones after that are for each AI civilization.
I guess that "LEAD" stands for "leader", but I'm not sure. The known format is as follows:
bytes 0-3: id of the civilization. i.e. if '0' this means the civilization uses the first RACE record, if '1' it uses the second RACE record and so forth.
bytes 12-15: the capital city. UINT_MAX means none. It seems however that a palace may also need to be in the city for it to count as the capital.
bytes 36-43: two integers which seem to be encrypted values determining how much gold the civilization has. It seems that changing these numbers so that they sum to the same amount will not affect one's gold balance.
bytes 216-219: beakers put into researching the current technology
bytes 220-223: technology being researched. (UINT_MAX means none). I'm guessing the index into TECHR of what is currently being researched.
bytes 388-391: luxury rate (0-10)
bytes 392-395: science rate (0-10)
bytes 3740-?: a series of 4 byte values, each of which can assume only the values 0 or 1. Each one corresponds to another civilization, and determines if contact has been established yet. Note though that whether the 'D' for diplomacy button is available is determined elsewhere, so changing this when one has contact with no-one will still not allow entry into diplomacy.
CITY section: this section stories information about a city. The records seem to be in a varying format depending on how long they are. In particular, a 148 byte city field seems to also store the city name and be in a slightly different format to what's listed here, although I'm not sure why the city name isn't already stored. The following is known:
0-3: the co-ordinates of the city, as two short integers (two bytes each). Changing these is not sufficient to change the location of the city.
4-7: the LEAD-index of the owner of the city (changing this alone will not be sufficient to change ownership of the city however).
12-15: whether the city name should be displayed with dropshadows.
28-31: food stored
32-35: shields stored
40-47: ID of what is currently being built. First integer is the id of the item being built, second integer is the type: 1 - building, 2 - unit
56-59: The cultural influence of the city, but changing doesn't seem to influence anything.
UNIT section:
0-3: The unit ID. It appears that each unit gets a unique id across the entire game.
4-7: x-co-ordinate
8-11: y-co-ordinate. Note that co-ordinates are in half tiles. To move a unit to the right one space, add 2 to its x-co. To move it to the up-right one space, add 1 to its x-co and 1 to its y-co. Otherwise it'll end up (!!) between tiles.
12-15: x-co-ordinate that the unit was on last turn. (why this needs to be recorded is unknown)
16-19: y-co-ordinate that the unit was on last turn.
20-23: the id of the civilization that the unit belongs to. This is the index into LEAD of the owner
24-27: the nationality of the unit. This is the civilization id - so an index into RACE, not an index into LEAD.
28-31: unknown
32-35: the type of unit. I.e. whether a worker, warrior, archer etc.
36-39: the rank of the unit. 0 = conscript, 1 = regular, etc.
40-43: unknown
44-47: the number of hits of damage the unit has taken. i.e. 0 = undamaged.
48-51: the number of thirds of point of movement the unit has moved this turn
52-55: unknown
56-59: (for workers) the type of action the worker is performing. UINT_MAX = none. 0 = mine. 1 = irrigate. 2 = build fort
60-63: unknown
64-67: unknown
68-71: whether the unit is fortified. (or in other states perhaps?)
TILE section: I'm still investigating this section. The records seem to be highly variant in size, and are really confusing me....
If anyone else wants to post what they know about the save format, please go ahead!
-Sirp.
I haven't seen any concise documentation on the save format in Civilization III. I've done a briefish investigation myself, and I post the results of what I've found. I hope that others will also post anything they know below too. The information is as at Play the World 1.14f
---
The autosaves are uncompressed, but normal saves are compressed by default. You have to decompress saves to get them in the correct format. I'm not sure how they're compressed though. It's probably something standard like ZLib.
Numbers in the file are generally stored as 4-byte integers, with the lowest value byte coming first. UINT_MAX (i.e. 0xFFFFFFFF) is generally used to represent 'null' values.
The save file is a database which contains a series of records. There are different types of records. Each record begins with the name of its record type. This is followed by a 4-byte integer which is the length of the record's data (does not include the name or this integer itself).
The records generally either describe the rules the game is played under - the improvements that can be built, units that can be built, how much they cost etc etc: everything that can be set in the editor - I call these 'rules records', and actual game state data - the map, where units are located on the map, where cities are, etc etc. I call these 'game data records'.
Since almost everything in the rules can be edited in the editor, the game data records are what I'm most interested in.
The following are the known records in the game:
BLDGN - rules - the state of buildings
CNSL
CONT
CTZN
CULT - rules - culture
DIFF - rules - difficulty settings
ERAS
EXPR
FAXXT
GAME
GOOD
GOVT - rules - government types
HIST - histogram (?)
ICBM
LEAD - gamedata - general information about a civilization
PALV
PEER
RACE - rules - the races available to play
RPLS
RPLT
RULE
TECHR - rules - the technologies available
TERR - rules - terrain
TFRM
TILE - gamedata - a single tile on the map
UNIT - gamedata - a single unit
WRLD
WSIZ - world size (?)
I have found a little about the formats of some of the more interesting records, as follows:
LEAD section:
This section documents information about each civilization. The first LEAD section in the file is for barbarians, and the second one is for the player's civilization. Further ones after that are for each AI civilization.
I guess that "LEAD" stands for "leader", but I'm not sure. The known format is as follows:
bytes 0-3: id of the civilization. i.e. if '0' this means the civilization uses the first RACE record, if '1' it uses the second RACE record and so forth.
bytes 12-15: the capital city. UINT_MAX means none. It seems however that a palace may also need to be in the city for it to count as the capital.
bytes 36-43: two integers which seem to be encrypted values determining how much gold the civilization has. It seems that changing these numbers so that they sum to the same amount will not affect one's gold balance.
bytes 216-219: beakers put into researching the current technology
bytes 220-223: technology being researched. (UINT_MAX means none). I'm guessing the index into TECHR of what is currently being researched.
bytes 388-391: luxury rate (0-10)
bytes 392-395: science rate (0-10)
bytes 3740-?: a series of 4 byte values, each of which can assume only the values 0 or 1. Each one corresponds to another civilization, and determines if contact has been established yet. Note though that whether the 'D' for diplomacy button is available is determined elsewhere, so changing this when one has contact with no-one will still not allow entry into diplomacy.
CITY section: this section stories information about a city. The records seem to be in a varying format depending on how long they are. In particular, a 148 byte city field seems to also store the city name and be in a slightly different format to what's listed here, although I'm not sure why the city name isn't already stored. The following is known:
0-3: the co-ordinates of the city, as two short integers (two bytes each). Changing these is not sufficient to change the location of the city.
4-7: the LEAD-index of the owner of the city (changing this alone will not be sufficient to change ownership of the city however).
12-15: whether the city name should be displayed with dropshadows.
28-31: food stored
32-35: shields stored
40-47: ID of what is currently being built. First integer is the id of the item being built, second integer is the type: 1 - building, 2 - unit
56-59: The cultural influence of the city, but changing doesn't seem to influence anything.
UNIT section:
0-3: The unit ID. It appears that each unit gets a unique id across the entire game.
4-7: x-co-ordinate
8-11: y-co-ordinate. Note that co-ordinates are in half tiles. To move a unit to the right one space, add 2 to its x-co. To move it to the up-right one space, add 1 to its x-co and 1 to its y-co. Otherwise it'll end up (!!) between tiles.
12-15: x-co-ordinate that the unit was on last turn. (why this needs to be recorded is unknown)
16-19: y-co-ordinate that the unit was on last turn.
20-23: the id of the civilization that the unit belongs to. This is the index into LEAD of the owner
24-27: the nationality of the unit. This is the civilization id - so an index into RACE, not an index into LEAD.
28-31: unknown
32-35: the type of unit. I.e. whether a worker, warrior, archer etc.
36-39: the rank of the unit. 0 = conscript, 1 = regular, etc.
40-43: unknown
44-47: the number of hits of damage the unit has taken. i.e. 0 = undamaged.
48-51: the number of thirds of point of movement the unit has moved this turn
52-55: unknown
56-59: (for workers) the type of action the worker is performing. UINT_MAX = none. 0 = mine. 1 = irrigate. 2 = build fort
60-63: unknown
64-67: unknown
68-71: whether the unit is fortified. (or in other states perhaps?)
TILE section: I'm still investigating this section. The records seem to be highly variant in size, and are really confusing me....
If anyone else wants to post what they know about the save format, please go ahead!
-Sirp.