SVE data reference table
The table below is a high-level list of the SVE data structure.
You can click on the data elements to jump to their detailed description, located in the further posts.
The offset values are provided for both English and French versions of Civ DOS; there is a known difference with FR versions, namely a 56-byte offset starting at Unit Types.
Game turn counter (back to table)
Data range/length: [0:1] / 2 bytes - (hex: [0x0:0x1]/0x2)
- Game turn counter:
- starts at 0 for first turn (4000 BC)
- increases by +1 at every turn
- turns match to years as follows:
- Turns 0 to 250 (4000 BC to 1000 AD): 1 turn = 20 years
- Turns 250 to 300 (1000 AD to 1500 AD): 1 turn = 10 years
- Turns 300 to 350 (1500 AD to 1750 AD): 1 turn = 5 years
- Turns 350 to 400 (1750 BC to 1850 AD): 1 turn = 2 years
- Turns 400 onwards (after 1850 AD): 1 turn = 1 year
- if this value is 0 (4000 BC) and value of game.year is -4000, loading this savegame will prompt the user to the Civ selection screen
Human player Civ (back to table)
Data range/length: [2:3] / 2 bytes - (hex:
[0x2:0x3]/0x2)
- Player Civ ID:
- valid values are 0 to 7:
- 0 - Barbarians
- 1 - Russians/Romans (white)
- 2 - Zulu/Babylonians (green)
- 3 - German/French (blue)
- 4 - Egyptians/Aztecs (yellow)
- 5 - Americans/Chinese (cyan)
- 6 - English/Greek (magenta)
- 7 - Mongol/Indians (gray)
- this value determines what Civilization the human player is controlling
Human player Civ bitflag (back to table)
Data range/length: [4:5] / 2 bytes - (hex:
[0x4:0x5]/0x2)
- Player civ flag
- the low-order byte is used as a 'bit flag' to indicate the human player Civ; example below for a human playing a Zulu or Babylonian:
Code:
bit: 8 7 6 5 4 3 2 1
val: 0 0 0 0 0 1 0 0
dec: 4
hex: 0x04
- this value does NOT determine what Civ the human player is controlling, so changing it does not seem to affect the game
- its exact usage is still unclear
Random map seed (back to table)
Data range/length: [6:7] / 2 bytes - (hex:
[0x6:0x7]/0x2)
- Random seed:
- this value was determine to control the pattern of special resources and tribal huts on the world map
Current year (back to table)
Data range/length: [8:9] / 2 bytes - (hex:
[0x8:0x9]/0x2)
- Year of the current turn:
- value range matches that of signed short integer, i.e. -32768 to 32767
- if this value is -4000 (4000 BC) and value of game.game_turn is 0, loading this savegame will prompt the user to the Civ selection screen
Game difficulty level (back to table)
Data range/length: [10:11] / 2 bytes - (hex:
[0xA:0xB]/0x2)
- Game difficulty level:
- valid values range from 0 to 4:
- 0 = Chieftain (easiest)
- 1 = Warlord
- 2 = Prince
- 3 = King
- 4 = Emperor (hardest)
- Civ's behaviour is unknown if the value is outside the valid range…
Active Civilizations (back to table)
Data range/length: [12:13] / 2 bytes - (hex:
[0xC:0xD]/0x2)
- Active Flag for Civs:
- this value is a bitflag whose bits determine which Civs are active (i.e. not annihilated); example below show active bit flag where Babylonian (2), Americans (5) and English (6) are still active; Barbarians (0) are always active:
Code:
bit: 8 7 6 5 4 3 2 1
val: 0 0 1 1 0 1 0 1
dec: 101
hex: 0x65
Current researched Civ Advance (back to table)
Data range/length: [14:15] / 2 bytes - (hex:
[0xE:0xF]/0x2)
- ID of the Civ Advance that the current human player is researching; refer to Civ Advances table for the list of valid IDs
Leader names (back to table)
Data range/length: [16:127] / 112 bytes - (hex:
[0x10:0x7F]/0x70)
- Name of Civilization leader:
- represents the name of a Civ's leader
- it is a 0-terminated String, of maximum length 14
- occurs 8 times, once for each Civ
Civ names (back to table)
Data range/length: [128:223] / 96 bytes - (hex:
[0x80:0xDF]/0x60)
- Name of Civilization:
- represents the name of a Civilization
- occurs 8 times, once for each Civ
Citizens name (back to table)
Data range/length: [224:311] / 88 bytes - (hex:
[0xE0:0x137]/0x58)
- Name of Civ's citizens:
- represents the ajdective used to determine all things related to a Civ: citizens, units, spaceship, etc.
- occurs 8 times, once for each Civ
Treasury gold (back to table)
Data range/length: [312:327] / 16 bytes - (hex:
[0x138:0x147]/0x10)
- Treasury gold:
- amount of gold in a Civ's treasury
- ranges from 0 to 32767 (signed short maximum positive value, 0x7F)
- occurs 8 times, once for each Civ
Research progress (back to table)
Data range/length: [328:343] / 16 bytes - (hex:
[0x148:0x157]/0x10)
- Research progress:
- amount of 'research' accumulated for the advance currently research by a Civ
- ranges from 0 to 32767 (signed short maximum positive value, 0x7F)
- occurs 8 times, once for each Civ
Units active (back to table)
Data range/length: [344:791] / 448 bytes - (hex:
[0x158:0x317]/0x1C0)
- Units active
- The data below is a block of 8 sets of 28 short integers (totally 8*28*2 = 448 bytes)
- There is 1 set for each Civ
- each of the 28 integers defines the number of active units that a particular Civ currently possesses, for the 28 possible unit types
Units in production (back to table)
Data range/length: [792:1239] / 448 bytes - (hex:
[0x318:0x4D7]/0x1C0)
- Units in production
- The data below is a block of 8 sets of 28 short integers (totally 8*28*2 = 448 bytes)
- There is 1 set for each Civ
- each of the 28 integers defines the number of units that a particular Civ is currently building, for the 28 possible unit types
Discovered Advances Count (back to table)
Data range/length: [1240:1255] / 16 bytes - (hex:
[0x4D8:0x4E7]/0x10)
- Advances count
- This data block is an array of 8 short integers (8*2 = 16 bytes)
- Each integer s the count of how many Advances a Civ has already discovered
Discovered Civ Advances (back to table)
Data range/length: [1256:1335] / 80 bytes - (hex:
[0x4E8:0x537]/0x50)
- Advances already discovered by a Civ:
- a series of 10 bytes, 5 short bitflags, where each indicates whether an Advance was discovered or not
- refer to Civ Advances table for the list of valid IDs
- the discovered Advance bits are orderes in the same order as in the Civ Advances table (see this thread by Gowron, section 6. 'Tech Tree');
- the flag bits must be read as follows:
Code:
flag_tech0 bit: 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
advance ID: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
flag_tech1 bit: 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
advance ID: 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
flag_tech2 bit: 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
advance ID: 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32
flag_tech3 bit: 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
advance ID: 63 62 61 60 59 58 57 56 55 54 53 52 51 49 48 47
flag_tech4 bit: 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
advance ID: 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64
- this 10-byte series occurs 8 times, once for each Civ
Civ Govnernment (back to table)
Data range/length: [1336:1351] / 16 bytes - (hex:
[0x538:0x547]/0x10)
- Government type for a Civ:
- valid values range from 0 to 5:
- 0 = Anarchy (revolution)
- 1 = Despotism
- 2 = Monarchy
- 3 = Communism
- 4 = Republic
- 5 = Democracy
- unknown behaviour if value is outside range
Per-continent Civ AI strategy (back to table)
Data range/length: [1352:1607] / 256 bytes - (hex:
[0x548:0x647]/0x100)
- Per-continent Civ strategy:
- a series of 8 data blocks (1 for each Civ)
- each data block contains 16 short integers, 1 for each continent (16*2 = 32 bytes)
- total size is 8*32 = 256 bytes
- each short integer is a value that describes the Civ's AI strategy for this continent (values below suggested by Gowron):
- 0 = to settle
- 1 = to attack
- 2 = to defend
- 5 = to transport units to
Diplomacy (back to table)
Data range/length: [1608:1735] / 128 bytes - (hex:
[0x648:0x6C7]/0x80)
- Diplomatic status of a Civ:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short describe the status between the Civ and one of the 8 other Civs (seems to include Barbarians…)
- each short value is a bitflag whose bits describe a particular diplomatic status
- currently known bits are as follows:
Code:
bit | meaning of bit value = 1
0 | at war
1 | at peace
2 | alliance
3 | vendetta
4 | ?
5 | ?
6 | embassy established
7 | ?
8 | ?
9 | ?
10 | ?
11 | ?
12 | ?
13 | ?
14 | ?
15 | ?
- this series of 16 bytes is repeated 8 times, once for each Civ (totally 8*16 = 128 bytes)
City counts (back to table)
Data range/length: [1736:1751] / 16 bytes - (hex:
[0x6C8:0x6D7]/0x10)
- City counts:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short describe total number of citiesthat a Civ owns
Unit counts (back to table)
Data range/length: [1752:1767] / 16 bytes - (hex:
[0x6D8:0x6E7]/0x10)
- Unit counts:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short describe total number of units that a Civ owns
Land counts (back to table)
Data range/length: [1768:1783] / 16 bytes - (hex:
[0x6E8:0x6F7]/0x10)
- Land counts:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short describe total land area that a Civ owns
- this value may be related to .MAP layer 8, that represents the total area belonging to Civs… (to be confirmed)
Settler counts (back to table)
Data range/length: [1784:1799] / 16 bytes - (hex:
[0x6F8:0x707]/0x10)
- Settler counts:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short describe total number of Settlers that a Civ owns, +1 (reason for the +1 is unknown, but is empirically observed…)
Total Civ size (back to table)
Data range/length: [1800:1815] / 16 bytes - (hex:
[0x708:0x717]/0x10)
- Total Civ size:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short describe total sum of city sizes for all of aCiv's cities
Military power (back to table)
Data range/length: [1816:1831] / 16 bytes - (hex:
[0x718:0x727]/0x10)
- Military Power:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short is the sum of nominal attack and defense strengths of all units under a Civ's control
Civ Rankings (back to table)
Data range/length: [1832:1847] / 16 bytes - (hex:
[0x728:0x737]/0x10)
- Civ Rankings:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short is a ranking value representing the Civ's relative power in the world; the highest rank is 7, the lowest is 0 (Barbarians)
Tax rate (back to table)
Data range/length: [1848:1863] / 16 bytes - (hex:
[0x738:0x747]/0x10)
- Tax rate of a Civ:
- valid values range from 0 to 10; 0 represents 0% tax rate, 10 represents 100% tax rate, N represents N*10% tax rate
- combined with Science Rate (see REF) the determine the rate of 'Luxury'
- occurs 8 times, once for each Civ
Civ score (back to table)
Data range/length: [1864:1879] / 16 bytes - (hex:
[0x748:0x757]/0x10)
- Civ scores:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 short describes the score of a Civ, as shown in the F9 screen in-game
Human contact turn counter (back to table)
Data range/length: [1880:1895] / 16 bytes - (hex:
[0x758:0x767]/0x10)
- Contact turn counter:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 shorts seems to describe the number of turns when a Civ is willing to contact the human player again
Starting position X coordinate (back to table)
Data range/length: [1896:1911] / 16 bytes - (hex:
[0x768:0x777]/0x10)
- Starting position X:
- this is a series of 8 shorts (8*2 = 16 bytes)
- each of the 8 shorts represents the Horizontal (X) coordinate of a Civ's starting position
Civ identity / Leader graphics (back to table)
Data range/length: [1912:1927] / 16 bytes - (hex:
[0x778:0x787]/0x10)
- Civ 'ID':
- for each of the 7 (8 ?) civ 'flavor', this value determines which one is the 'actual' Civ, out of the 2 possible for that flavor
- for example, for flavor 'white', the Civ can be Romans or Russians; if the Civ is Romans, the value of 'who' will be '1'; if it is the Russians, this value will be '9' (1+8)
- this value controls what graphics will be used to display an AI leader in diplomatic screens:
Code:
1 = Romans = Caesar = KING10.PIC
2 = Babylonians = Hammurabi = KING07.PIC
3 = German = Frederick = KING12.PIC
4 = Egyptians = Ramesses = KING01.PIC
5 = Americans = Abe Lincoln = KING04.PIC
6 = Greek = Alexander = KING13.PIC
7 = Indians = Gandhi = KING02.PIC
9 = Russians = Staline = KING08.PIC
10 = Zulu = Shaka = KING03.PIC
11 = French = Napoleon = KING11.PIC
12 = Aztecs = Moctezuma = KING09.PIC
13 = Chinese = Mao Zedong = KING06.PIC
14 = English = Elizabeth = KING00.PIC
15 = Mongols = Gengis Khan = KING05.PIC
- it is possible (tested) to set any value for any Civ, so that any leader can have any other leader graphics
- Barbarians have value 0xFFFF
Per-continent Civ defense (back to table)
Data range/length: [1928:2183] / 256 bytes - (hex:
[0x788:0x887]/0x100)
- Per-continent Civ defense:
- a series of 8 data blocks (1 for each Civ)
- each data block contains 16 short integers, 1 for each continent (16*2 = 32 bytes)
- total size is 8*32 = 256 bytes
- each short integer is the sum of a Civ's units' defense strengths, limited to units located on that continent
Per-continent Civ attack (back to table)
Data range/length: [2184:2439] / 256 bytes - (hex:
[0x888:0x987]/0x100)
- Per-continent Civ attack:
- a series of 8 data blocks (1 for each Civ)
- each data block contains 16 short integers, 1 for each continent (16*2 = 32 bytes)
- total size is 8*32 = 256 bytes
- each short integer is the sum of a Civ's units' attack strengths, limited to units located on that continent
Per-continent Civ city count (back to table)
Data range/length: [2440:2695] / 256 bytes - (hex:
[0x988:0xA87]/0x100)
- Per-continent Civ city count:
- a series of 8 data blocks (1 for each Civ)
- each data block contains 16 short integers, 1 for each continent (16*2 = 32 bytes)
- total size is 8*32 = 256 bytes
- each short integer is the count of a Civ's cities located on that continent
Continent sizes (back to table)
Data range/length: [2696:2823] / 128 bytes - (hex:
[0xA88:0xB07]/0x80)
- Continent sizes:
- the first 32 bytes are a series 16 short integers (2*16=32)
- each integer is the total size of the corresponding continent
- note how continents are indexed by size (was remarked by Dack before)
- if there are more than 15 continents, all continents above and including '15' are labelled as '15'
Oceans sizes (back to table)
Data range/length: [2824:2951] / 128 bytes - (hex:
[0xB08:0xB87]/0x80)
- Oceans/seas sizes:
- the first 32 bytes are a series 16 short integers (2*16=32)
- each integer is the total size of the corresponding ocean/sea
- note how oceans and seas are indexed by size (was remarked by Dack before)
- if there are more than 15 seas/oceans, all seas above and including '15' are labelled as '15'
Continent building site counts (back to table)
Data range/length: [2952:2983] / 32 bytes - (hex:
[0xB88:0xBA7]/0x20)
- Continent building sites:
- the first 32 bytes are a series 16 short integers (2*16=32)
- each integer is the number of initial building sites on the corresponding continent
- a 'building site' is a map square whose 'land value' is not 0
- the 'land value' of a map square is a score (whose formula is unknown yet) that CIV computes for each map square to represent the appeal of asquare for building a city on it (it has been observed that computer Civs use this value to build cities)
- land value are stored in the .MAP file, alongside geography and terrain improvements...
- note: for some reason, CIV doesn't seem to update land values when the player modifies terrain with settlers...
Score chart (a.k.a Civ POWERGraph) (back to table)
Data range/length: [2984:4183] / 1200 bytes - (hex:
[0xBA8:0x1057]/0x4B0)
- Score chart data:
- Score chart is stored as a sequence of 8-bytes blocks
- The chart covers totally 1200 bytes (approx.), equivalent to 150 8-byte blocks
- each 8-byte block contains the scores of all 7 Civs for one of the chart's X plot
- Each X plot of the score chart seem to cover 4 in-game turns
- 150 times 4 turns can cover up to turn 600, which correspond to Civ year 2050 AD
- Each 8-bye block contains 1 byte per Civ; each byte is an unsigned 1-byte integer, represneting that Civ's score for the block; the score value ranges from 0 to 255 (0xFF)
Peace chart data (unused?) (back to table)
Data range/length: [4184:5383] / 1200 bytes - (hex:
[0x1058:0x1507]/0x4B0)
- Peace chart data:
- This data is stored as a sequence of 8-bytes blocks
- It covers totally 1200 bytes, equivalent to 150 8-byte blocks
- each 8-byte block contains the Peace status of all 7 Civs with all other Civs
- each 8-byte block seems to cover 4 in-game turns
- 150 times 4 turns can cover up to turn 600, which correspond to Civ year 2050 AD
- Each 8-byte block contains 1 byte per Civ; each byte is a 8-bit flag, where each bit represents the Peace status between the byte's Civ and the bit's Civ: 1 if they are at Peace, 0 if they are not
- Current investigations could not determine that this data is actually used anywhere in CIV (except being computed and stored in the SVE file)
Cities (back to table)
Data range/length: [5384:8967] / 3584 bytes - (hex:
[0x1508:0x2307]/0xE00)
- Cities
- there are totally 128 data blocks representing the 128 possible cities supported by CIV
- each City data is a 28-byte data block, as described below:
Building flags- a series of 4 byte bitflag, where each bit indicates whether a given City improvement is built in the city
- the building bits are ordered in the same order as in the City Improvements table (see ref);
- the flag bits must be read as follows:
Code:
buildings_flag0 bit: 8 7 6 5 4 3 2 1
building ID: 7 6 5 4 3 2 1 0
buildings_flag1 bit: 8 7 6 5 4 3 2 1
building ID: 15 14 13 12 11 10 9 8
buildings_flag2 bit: 8 7 6 5 4 3 2 1
building ID: 23 22 21 20 19 18 17 16
buildings_flag3 bit: 8 7 6 5 4 3 2 1
building ID: . . . . . . . .
- the last byte is actually unused, at least not for city buildings
Map coordinates- Two bytes represneting the X and Y coordinates of the city on the world map;
- Values range from 0 to 79 (for X) and from 0 to 49 (for Y)
City status flag- a single byte used as bitflag representing the city status:
- currently known bits are as follows:
Code:
bit | meaning of bit value = 1
0 | Civil disorder
1 | Costal city (used by AI to build ships)
2 | something related to city celebration/rapture
3 | Hydro-powered: city benefits from hydro-electrical power bonus
4 | Auto-build: city is in auto-build mode
5 | Stolen tech: unclear, related to diplomats stealing techs from cities
6 | Something else related to celebration/rapture
7 | A city improvement was sold during this turn (cannot sell another one)
- if the city does not exist (not built yet or destroyed) all flags are set to 1 and this byte's value is 0xFF
Actual size- City 'true' size, as opposed to visible size below
Visible size- City size as visible by the human player; if the city belongs to the human player, this value is ignored
Current production- ID of the current city production; refer to CITY PROD table (TODO)
Base tradeOwning Civ- ID of the Civ who owns the city
Food storage- Current amount of food available in storage
Shields storage- Current amount of shields accumulated for production
City squares / specialists- A series of 6 bytes used to store information for city square usage and city specialists (see this post by darkpanda)
City name ID- ID of the name used for the city; this is an index to another data block, which is the list of city names
Trading cities- ID of up to 3 other cities with which this city is trading; value 0xFF means that no trade route is established
unknown- Bytes whose usage is still unknown yet
Unit types (back to table)
Data range/length: [8968:9919] / 952 bytes - (hex:
[0x2308:0x26BF]/0x3B8)
- Unit types
- The Unit Type data is a 34-byte sequence repeated 28 times (totally 952 bytes), representing all of the 28 unit types available in Civ (TODO: unit type ref table)
- The following 34 bytes represent a Unit Type
Unit type name- Name of unit, up to 12 chars (in French version of Civ, this data is extended to 14 chars)
Cancelling tech- Civ Advance ID whose discover cancels this unit type; Civs can no longer build it after the discovery is made; see table of Civ Advance for list of IDs
Terrain category- Terrain category: specifies that movement behaviour for this unit type:
- 0 = Land: can only move on land squares; can embark on transport ships
- 1 = Air: can move on land and sea squares; can embark on carriers
- 2 = Sea: can only move on sea squares and (coastal) cities; cannot fortify
- Other values are untested
Total moves- Total moves per turn:
- this value is the base to compute movement turns for a unit
- it is the number of possible movements for a Land unit on plains/grasslands/river/desert without road or railroad
- it is also the number of movement per turn for any air unit
- it is also the number of movement per trun for sea units, not taking into account Wonder bonuses (Magellan, Lighthouse)
Turns outdoors- Number of turns that the unit can stay outdoors, meaning outside a city, a transport or a carrier:
- if value is 0, there is no limitation
- if value is 1 or more, the unit will be destroyed after it finished its Nth turn outside a city (if value is 1, then the unit can NEVER end its turn outdoors)
<ul><li><a name="d8988i20"><a href="#d8968"><font size="3" color="black"><b>Attack</b></font></a></a><ul><li>Attack value for this unit; this value is used in the battle algorithm as explained in this thread by <a href="http://forums.civfanatics.com/showthread.php?t=492843" target="_blank">Gowron</a></li>
Defence
- Defence value for this unit; this value is used in the battle algorithm as explained in this thread by Gowron
Cost- Unit cost:
- the actual shield cost (amount of shileds needed to produce the unit) is tenfolds this value:
- if the cost is 45, then a city needs 450 shields to produce the unit
Sight range- The range of sight of the unit, i.e. how 'black' squares are revealed when the unit moves towards them:
- 0 means that the unit will only reveal its own square and the 8 squares surrounding it; this is the default value, for most unit types; if the unit's terrain category is Land (0),
- 2 means that the unit will reveal two 'rings' of squares surrounding it: the first 'ring' corresponds to the same 8 squares as for value 0; the second 'ring' is compomsed of the 16 additional squares surrounding the 8 squares of the first ring; this is the value for jetfighters and bombers
- 3 is the same as 2, but is assigned to ships (cruiser, battleship, submarine); other difference not identified yet
- other values are untested
Transport capacity- Amount of units it can transport:
- if this amount is not null, and the unit moves from a location where there are sleeping units, then it will bring as much sleeping units as this amount allows, keeping them asleep
- this works on any unit category or terrain category
Unit role- Category indicating the nature of a unit:
- this primarily controls what the unit can do
- values range from 0 to 6:
- 0 = settler: can improve terrain and build cities
- 1 = land attack: can attack ground units (catapult, bomber, ...)
- 2 = defence: primarily used for defence
- 3 = sea attack: can attack units at sea
- 4 = air attack: can attack units in the air
- 5 = transport: can transport units on the sea
- 6 = civilian: can move through enemy lines (caravan and diplomats)
Unlocking tech- ID of the Civ Advance that makes this unit available for production (see this thread by Gowron, section 6. 'Tech Tree')
Units (back to table)
Data range/length: [9920:22207] / 12288 bytes - (hex:
[0x26C0:0x56BF]/0x3000)
- Units
- the following 12 bytes represent a Unit
- this 12-byte sequence is repeated 128 times for each Unit of a Civ
- the 12*128 bytes block is then repeated 8 times, once for each Civ (totally 12*128*8 = 12288 bytes), representing all of the units available in Civ (TODO: unit type ref table)
- this also means that Civ only supports 128 active units per civ at any single time
Unit status- Unit status flag:
- a single byte used as bitflag representing the unit status:
- bits are as follows:
Code:
bit | meaning of bit value = 1
0 | Sentry/sleeping
1 | Improving terrain; see below
2 | Fortifying (non-settler unit marked with an 'F', fortified this turn)
3 | Fortified (non-settler unit surrounded with 'walls', fortified before this turn)
4 | ? (unknown, thought to be related to sea transport, somehow)
5 | Veteran
6 | Improving terrain; see below
7 | Improving terrain; see below
- Flags 1, 6 and 7 are combined as below to determine the current terrain improving task of a settler:
Code:
bit1 | bit6 | bit7 | Task
1 | 0 | 0 | Road/rail
0 | 1 | 0 | Irrigation
0 | 0 | 1 | Mining/forest
0 | 1 | 1 | Building fortress
1 | 0 | 1 | Cleaning pollution
Map coordinates- Two bytes representing the X and Y coordinates of the unit on the world map;
- values range from 0 to 79 (for X) and from 0 to 49 (for Y)
Unit type- Unit Type: this value is actually the ID of the Unit Type from the types table (TODO: Unit Type ref table)
Remaining moves- Moves remaining for the unit:
- this value is actual expresses in *thirds* of moves:
- if a unit has totally 1 move available, and has not moved yet, this value is *3*, that is 3 thirds of movement
- moving alongside a road decreases this value by 1 (i.e. moving on road consumes 1 third of movement)
Special moves- Special counter:
- for aerial units that have a 'turns_outdoor' value different from 0, this value counts that number of turns that the unit spent outside *already*
- for colonizing units (settlers), this value counts the number of turns already spent doing the current task (typically terrain improvement)
Goto coordinates- The X and Y coordinates of the GoTo destination of the unit:
- values range from 0 to 79 (for X) and from 0 to 49 (for Y)
- if GoToX value is 0xFF (-1 or 255), then those coordinates are ignored
- if GoToX value is different from 0xFF, then the unit is in 'GoTo' mode
unknownVisibility- Visibility flag indicating what Civ can see this unit on the world map; each bit of the byte acts as a flag for on the 7 Civs + Barbarians
Next unit in stack- ID of the next unit in this unit's stack:
- when several units are located on the same map cell, Civ records them as a 'stack', which is actually a linked list;
- this value is the link to the next unit in the stack;
- the full linked list is closed loop, i.e. the last unit of the stack has a pointer to the first one
- the stack/list is used to decide in which order units are activated;
- for some operations where the maximum number of units is 10 (battle, nukes), this list is also controls which of the 10 units will be affected (first 10 units of the stack)
Home City- ID of the city where this unit was built (home city); if this value is 0xFF (-1 or 255), then the unit has no home city (marked as NONE ingame)
Map visibility (back to table)
Data range/length: [22208:26207] / 4000 bytes - (hex:
[0x56C0:0x665F]/0xFA0)
- Map visibility
- Map visibility for all Civs:
- this data block contains 1 byte per map cell (80*50 = 4000)
- each byte contains 8 bits, each bit acts as a 'flag' to determine whether the map cell is revealed (i.e. not black) for a particular Civ
- bit 0 determines whether Barbarians can see a cell: it has a particular role, to also indicate whether a tribe hut was visited or not (see Random Seed regarding Tribe Huts)
- bits 1 to 7 indicate whether Civ 1 to 7 can see the map cell
Strategic locations status (back to table)
Data range/length: [26208:26335] / 128 bytes - (hex:
[0x6660:0x66DF]/0x80)
Strategic locations policy (back to table)
Data range/length: [26336:26463] / 128 bytes - (hex:
[0x66E0:0x675F]/0x80)
Strategic locations X (back to table)
Data range/length: [26464:26591] / 128 bytes - (hex:
[0x6760:0x67DF]/0x80)
Strategic locations Y (back to table)
Data range/length: [26592:26719] / 128 bytes - (hex:
[0x67E0:0x685F]/0x80)
Tech first inventors (back to table)
Data range/length: [26720:26863] / 144 bytes - (hex:
[0x6860:0x68EF]/0x90)
- Techs first inventors
- A series of 72 values (2-byte words), totally 72*2 = 144 bytes
- Each value is initialized to 0
- Each value represents the ID of the Civ who first discovered the corresponding Tech
- for more details, see this post: http://forums.civfanatics.com/showth...6&post12733796
Civ-to-Civ destroyed unit counts (back to table)
Data range/length: [26864:26991] / 128 bytes - (hex:
[0x68F0:0x696F]/0x80)
- Civ-to-Civ destroyed unit counts
- Data block containing the total number of Units of 1 Civ destroyed by another Civ
- For each attacking Civ A, a block of 16 bytes, so totally 16*8 = 128 bytes
- Each 16-byte block is an arrays of 8 values (2-byte words); each value is the total number of Units belonging to Civ B (whose ID is the offset of the value within the 16-byte block) that Civ A has destroyed
- for more details, see this post: http://forums.civfanatics.com/showth...6&post12733796
City names (back to table)
Data range/length: [26992:30319] / 3328 bytes - (hex:
[0x6970:0x766F]/0xD00)
- City names
- the next data block is a list of 16 times 16 city names, each being 13-byte long (totally 3328 bytes)
- the first 14 sets of city names are specific to the 14 playable Civs
- the last 2 sets of city names are common names used whenever a Civ exhausted its specific names
Replay (back to table)
Data range/length: [30320:34417] / 4098 bytes - (hex:
[0x7670:0x8671]/0x1002)
- Replay data: this block stores data used to generate the replay at the end of a Civ game; (see this post by darkpanda)
Wonders (back to table)
Data range/length: [34418:34461] / 44 bytes - (hex:
[0x8672:0x869D]/0x2C)
- Wonders
- this data element is a short integer (2 bytes) that occurs 21 times, once for each Wonder
- it is the ID of the City where the Wonder with the current offset ID (TODO: ref table of Wonders) is built
- if the wonder is not built yet, this value is 0xFFFF (-1)
- if this city ID is *not* 0xFFFF and the city corresponding to this ID has size '0' (city destroyed), then the Wonder is marked as Destroyed by CIV
Units lost (back to table)
Data range/length: [34462:34909] / 448 bytes - (hex:
[0x869E:0x885D]/0x1C0)
- Units lost
- The data below is a block of 8 sets of 28 short integers (totally 8*28*2 = 448 bytes)
- There is 1 set for each Civ
- each of the 28 integers defines the number of units that a particular Civ has already lost in battle, for the 28 possible unit types
Source Civs for Technologies (back to table)
Data range/length: [34910:35485] / 576 bytes - (hex:
[0x885E:0x8A9D]/0x240)
- Source Civs for technologies:
- For each civ and each technology, the game stores where the technology came from
- This only applies to technologies what were acquired via espionage, conquest or diplomatic exchange
- If a tech is not acquired yet, the value is 0xFF (-1)
- If a tech was self-discovered, or discovered in a hut, the value is 0
- It has been observed that for AI Civs, their own Civ ID is stored instead of '0' when they make the discovery themselves
- 1 byte per technology, 72 technologies per civ, 8 civs ==> total size: 576 bytes
Polluted square count (back to table)
Data range/length: [35486:35487] / 2 bytes - (hex:
[0x8A9E:0x8A9F]/0x2)
- Polluted square count:
- a short integer whose value is the total count of all map squares currently polluted
Pollution effect level (back to table)
Data range/length: [35488:35489] / 2 bytes - (hex:
[0x8AA0:0x8AA1]/0x2)
- World pollution accumulated level (see post by Dack)
- this is a single byte controlling the level of global warming / world pollution:
Code:
values | sun color
0 | none
1,2,3 | dark red
4,5,6,7 | red
8,9,A,B | yellow
C,D,E,F,10 | white
Global warming count (back to table)
Data range/length: [35490:35491] / 2 bytes - (hex:
[0x8AA2:0x8AA3]/0x2)
- Global warming count:
- a short integer counting the number of times that global warming occurred
Game settings (back to table)
Data range/length: [35492:35493] / 2 bytes - (hex:
[0x8AA4:0x8AA5]/0x2)
- In-game CIV Settings:
- this is a byte bitflag controlling the enabled/disabled status of CIV settings:
Code:
bit | meaning of bit value = 1
0 | Instant advice
1 | Auto-save
2 | End of turn
3 | Animations
4 | Sound
5 | Enemy moves
6 | Civilopedia text
7 | Palace
- the high-order byte is unused
Land pathfinding (back to table)
Data range/length: [35494:35753] / 260 bytes - (hex:
[0x8AA6:0x8BA9]/0x104)
- Land pathfinding helper data:
- This data is described in full details in this series of posts: http://forums.civfanatics.com/showth...3&post12554133
- It is basically a highlevel 'connexity' map between land map 'tiles' (tiles are 4x4-squares areas of the map, there are 20x13 = 260 tiles covering the whole 80x50 map)
- Investigation revealed that this data is actually wrongly generated by CIV (a patch to fix this is proposed at the link above)
- Eact usage of this map is still unclear
Max tech count (back to table)
Data range/length: [35754:35755] / 2 bytes - (hex:
[0x8BAA:0x8BAB]/0x2)
- Max tech count:
- The maximum value (2-byte word) of Civ tech count among all Civs
Player future tech. (back to table)
Data range/length: [35756:35757] / 2 bytes - (hex:
[0x8BAC:0x8BAD]/0x2)
- Player's current level of Future Tech research (see post by Dack)
Debug switches (back to table)
Data range/length: [35758:35759] / 2 bytes - (hex:
[0x8BAE:0x8BAF]/0x2)
- Debug switches:
- A 2-byte word value whose first 4 bits only are used as function switches, controlling whether certain game features are enabled/disabled:
- bit 0: controls an AI/player diplomacy function, which is not yet fully understood; seems to be related to assessment of diplomatic relationships with others Civs...
- bit 1: may be related to possibility of civil disorder/unhappy citizens, and also the possibility of improving terrains, but still unclear...
- bit 2: controls the possibility of building City improvements
- bit 3: seems to control scientific research function; if 0, no research progress occurs at all
Science rates (back to table)
Data range/length: [35760:35775] / 16 bytes - (hex:
[0x8BB0:0x8BBF]/0x10)
- Science rate:
- determines the level of science for a Civ; 0 means 0% while 10 means 100%
- combined with Tax rate (see above), this also determines the Luxury rate for a Civ
- To be noted that it is possible to set both 10 for Science and Tax, in which case Luxury rate becomes... -100% !!
- This value ocurs 8 times, once for each Civ
Next anthology turn (back to table)
Data range/length: [35776:35777] / 2 bytes - (hex:
[0x8BC0:0x8BC1]/0x2)
- Next anthology turn:
- A 2-byte short value representing the next turn when a 'historian' or philosopher will publish a 'world anthology' with the rankings of all Civs
- At the start of the game, it is a random value between 0 and 50 (exc.)
- Whenever the turn is reached, the next turn is computed as: current turn + 20 + a random value between 0 and 40 (exc.)
Cumulative Epic rankings (back to table)
Data range/length: [35778:35793] / 16 bytes - (hex:
[0x8BC2:0x8BD1]/0x10)
- Cumulative Epic rankings
- A series of 8 values (2-byte words), 1 for each Civ
- The first value (=Barbarians) is the number of times a scribe/writer/philosophist/anthologist has published an Epic - i.e. the number of times a gobal Civ rankings occured
- The other values for each non-Barbarian Civ is the addition of all Epic ranking scores so far
- The ranking score for each Epic is 7 for the first one, 6 for the second one, etc.
Space ships (back to table)
Data range/length: [35794:37255] / 1462 bytes - (hex:
[0x8BD2:0x9187]/0x5B6)
- Spaceships
- The following data blocks define how much the Spaceship is built for each Civ
- Those data blocks give a great insight in how *unfinished* this feature was meant to be, compared to what was finally implemented in CIV:
- the total spaceship data can be considered as 8 blocks (one for each Civ), of 15 x 12 bytes (totally 180 bytes per Civ)
- those 15 x 12 presumably represented the total spaceship 'grid area' where spaceship components could be placed, the grid being 15 columns wide and 12 rows high
- when analyzing the *actual* data in a SVE file, one realizes that the grid was trimmed down to a 12 x 12 area, removing the 3 first columns
- the data size was not reduced accordingly, and the space reserved for those columns is now unused
- Each spaceship grid *cell* is represented by a single *byte*; the value of the byte determines what component is located on this cell (for components that span multiple cells, this placement cell matches the top-left cell of the component):
- 0 = horizontal structure
- 1 = vertical structure
- 2 = intersection structure
- 3 = propulsion
- 4 = fuel
- 5 = cockpit
- 6 = habitation
- 7 = life support
- 8 = solar panel
- In addition, the scale-down of spaceship feature limits the cells that *can* actually host a spaceship part, to only the cells that are populated by default; that said, it is still possible to place a solar panel on cell here a structural part would be...
Offset/start | | Size | |
dec | hex | | |
0 | 0 | 36 | unknown (unused first 3 columns of cells) |
12 | C | 144 | Spaceship grid cells (12 x 12) (see description above for details about its contents) |
- The remaining 24 bytes are used as follows, for storing what Civs have a spaceship, and the ETA (estimated time of arrival) for all Civ's spaceships:
Spaceship launched flag- Spaceship launched byte bitflag: each bit indicates whether a Civ has launched their spaceship already (1 if true, 0 if not)
Spaceship under construction flag- Space-enabled Civs byte bitflag: each bit of this byte indicates whether a Civ has started to build a spaceship (1 if true, 0 if not)
Human spaceship success rate- A 2-short integer coding for the chance of the human player's spaceship to reach its destination
unknown- A 2-short integer coding for the chance of the AI player's spaceship to reach its destination (share by all AI Civs; to be confirmed)
ETA year- Estimated Year of Arrival for spaceship:
- this value is actually a *year*, rather than a turn number;
- this design is known to create bugs when the ETA year does not match a valid CIV turn number (e.g. very early spaceship sent, before 0 AD), in which case the Spaceship is lost and never arrives
- this value occurs 8 times, once for each Civ
Palace (back to table)
Data range/length: [37256:37303] / 48 bytes - (hex:
[0x9188:0x91B7]/0x30)
- Palace
- the next data section contains all information related to the human player's Palace
- it basically contains information about the *level of construction* and the *style* of each Palace's parts, intertweened with some apparently padding bytes with an unknown usage
- the Palace has 10 parts:
- 7 buiding parts: leftmost(0) left(1) centerleft(2) center(3) centerright(4) right(5) rightmost(6)
- 3 garden parts: left hedge(A) central alley(B) right hedge(C)
- the *level* valid values are:
- 0xFFFF: cannot be built (initialy value for parts (0) and (6), when adjacent part have not been built yet)
- 0x0: empy but can be built (for centerpiece, this is the starting 'hut' castle)
- 0x1: level 1
- 0x2: level 2
- 0x3: level 3 (highest possible level for garden parts)
- 0x4: level 4 (highest possible level for castle parts)
- the *style* valid values are:
- 0x0: Medieval Europe (gray-brick style castle)
- 0x1: Ancient Rome (greek-style colonade)
- 0x2: Arabian (arabesques)
Offset/start | | Size | |
dec | hex | | |
0 | 0 | 2 | Leftmost(0) level |
2 | 2 | 2 | Left(1) level |
4 | 4 | 2 | Centerleft(2) level |
6 | 6 | 2 | Center(3) level |
8 | 8 | 2 | Centerright(4) level |
10 | A | 2 | Right(5) level |
12 | C | 2 | Rightmost(6) level |
14 | E | 2 | unknown |
16 | 10 | 2 | Left hedge(A) level |
18 | 12 | 2 | Central alley(B) level |
20 | 14 | 2 | Right hedge(C) level |
22 | 16 | 2 | unknown |
24 | 18 | 2 | Leftmost(0) style |
26 | 1A | 2 | Left(1) style |
28 | 1C | 2 | Centerleft(2) style |
30 | 1E | 2 | Center(3) style |
32 | 20 | 2 | Centerright(4) style |
34 | 22 | 2 | Right(5) style |
36 | 24 | 2 | Rightmost(6) style |
38 | 26 | 8 | unknown |
Cities X coordinates (back to table)
Data range/length: [37304:37559] / 256 bytes - (hex:
[0x91B8:0x92B7]/0x100)
- Cities X coordinate
- List of X coordinates for all cities, ordered by City Name ID (256 possible cities), 1 byte per value
- If value is 0xFF, this means the city does not exist
Cities Y coordinates (back to table)
Data range/length: [37560:37815] / 256 bytes - (hex:
[0x92B8:0x93B7]/0x100)
- Cities Y coordinate
- List of Y coordinates for all cities, ordered by City Name ID (256 possible cities), 1 byte per value
Palace level (back to table)
Data range/length: [37816:37817] / 2 bytes - (hex:
[0x93B8:0x93B9]/0x2)
- Palace level
- Number of total palace upgrades for the player; Gowron suggests it helps CIV to determine whether the player's Palace is maxed out or not
Peace turn count (back to table)
Data range/length: [37818:37819] / 2 bytes - (hex:
[0x93BA:0x93BB]/0x2)
- Peace turn count
- Number of consecutive turns without any battle (incl. between AI players); CIV ignores this before 0 AD
AI opponents (back to table)
Data range/length: [37820:37821] / 2 bytes - (hex:
[0x93BC:0x93BD]/0x2)
- AI opponents
- Total number of Civs in this game, minus 1; possibly used by Civ to determine whether a Civ should be ressucitated when its counterpart is destroyed
Spaceship population (back to table)
Data range/length: [37822:37837] / 16 bytes - (hex:
[0x93BE:0x93CD]/0x10)
- Spaceship population
- Population aboard the spaceship (x10,000)
- Occurs 8 times, once for each Civ
Spaceship launch year (back to table)
Data range/length: [37838:37853] / 16 bytes - (hex:
[0x93CE:0x93DD]/0x10)
- Spaceship launch year
- Actual year at which the Spaceship is launched
- Occurs 8 times, once for each Civ
Civ identify flag (back to table)
Data range/length: [37854:37855] / 2 bytes - (hex:
[0x93DE:0x93DF]/0x2)
- Civs identifiy flag
- Similar to 'Civ identity/leader graphics' but represented as a bitflag
- The position of each bit determines which Civ 'flavour' it codes for: bit 0 is for Barbarians, bit 1 is for Romans/Russians, bit 2 is for Babylonians/Zulu, etc.
- The value of each bit determines which of the 2 Civ is active: bit1=0 -> Romans, bit1=1 -> Russians, etc.