From: gnohmon@ssiny.UUCP (Ralph Betza)
Newsgroups: comp.sys.ibm.pc.games
Subject: CIV save files new info
Keywords: CIV save files
Date: 16 Nov 92 17:56:50 GMT
Distribution: world

Here is my contribution to CIV save-file decoding.
I have added several important fields;
city.TradeRoutes is tested; so are unit.CityNumber and the unit
veteran status bit.


        /* char  = 1 byte */
        /* short = 2 bytes */
        /* int   = 4 bytes */

1508-2307 (128 x 28 = City Info)
** The index into this array is a one-byte CityNumber.
** CityNumber 0xff is invalid, == NONE

                struct {
0                        unsigned short possessions; /* yes */
2                        char unknown1;
3                        char unknown2;
4                        char latitude;
5                        char longitude;
6                        char unknown3;
7                        char population;
8                        char unknown4;
9                        char current_project;
a                        char trade;
    ** needed for other city to calculate trade route value quickly
b                        char ownerNumber;
c                        short storedFood;
e                        short current_shields_saved_up;
10                       char CitySquares[3];
    ??? bitmap of squares the city has under production???
13                       char unknown5[3];
16                       char CityNameIndex;
    ** Rome 0x10, Paris 0x90
17                       char TradeRoutes[5];
    ** CityNumber index to city with which trade route exists
    ** possibly TradeRoutes[3], unknown7[2];
    ** Most cheats are so powerful they spoil the game.
    **     Magic trade routes are more subtle...
                }

2308-26bf Unit definitions
                struct {
                        char name[12];
0                        short  ObsolescenceLevel;
    tech level at which it becomes obsolete and is no longer offered
    on the city production menu
2                        short  travel_mode; /* 0 - land, 2 - sea, 1 - air */
4                        short  movement_per_turn;
6                        short  turns_of_movement_for_air_travel;
8                        short  offense;
a                        short  defense;
c                        short  cost; /* x10 shields to produce */
e                        short  unknown; /* vision distance NOT */
    ** Cruiser Battleship Submarine Carrier == 0300
    ** Fighter Bomber == 0200
    ** all others == 0000
    ** It is surprising  that diplomat caravan nuclear are == 00
10                        short  transport_amount;
12                        short  Purpose; /* 0 expansion
                                          1 ground offensive
                                          2 ground defensive
                                          3 sea offensive
                                          4 air defensive
                                          5 sea transportation
                                          6 other
      the computer's AI uses this...      */
14                        short  tech_level_available_at;
                }

26c0-2cbf Red #0 Unit information (12 x 128 = 1536 bytes)
                struct {
0                        char flags1;
    0x20 veteran
1                        char latitude;
2                        char longitude;
    It's sensible to make new units in your first city.
    Random locations might be good for exploring.
3                        char unit_type; ff == no unit
4                        char movement_remaining; /* times three */
5                        char flags2;
    0x01 only value seen; for a settler
6                        char unknown1;
    ( 6 and 7 == destination. Used mostly for computer pieces. )
7                        char unknown2;
8                        char flags3;
    ** possibly this is the number of turns remaining for a settler
    ** operation.
9                        char flags4;
    0x02 == sentry
    0x08 == cannot move; on sentry, or settler finished operation
    02, 10, 80, 40, 08, 00 observed; 00 is normal
a                        char unknown; /* pointer to next unit ??? */
    ** Seems to be meaningless for *your* units
b                        char CityNumber;  0xff == NONE
    index into "1508-2307 (128 x 28 = City Info)"
    This is the city it belongs to.
    Making all your units belong to NONE under democracy is quite
    unfair. :-)
                }

6. TECHNOLOGY MASK  (10 bytes/Civilization - Start at 0x4e8)

Tech level is a shift count

0100-0000-0000-0000-0000    Masonry ? Code of Laws ? ( level 0 )
0200-0000-0000-0000-0000    Alphabet ( level 1 )
0400-0000-0000-0000-0000    Currency ? ( level 2 )
8000-0000-0000-0000-0000    Mapmaking ( level 7 )
0001-0000-0000-0000-0000    Navigation ( level 8 )
0002-0000-0000-0000-0000    Mathematics ( level 9 )
0040-0000-0000-0000-0000    ? ( level e ) Frigate
0000-0100-0000-0000-0000    Masonry ? Code of Laws ? ( level 10 )
0000-0200-0000-0000-0000    Bronze Working ( level 11 )
0000-0400-0000-0000-0000    Iron Working ( level 12 )
0000-4000-0000-0000-0000    Writing ( level 16 )
0000-8000-0000-0000-0000    ? ( level 17 ) Ironclad
0000-0001-0000-0000-0000    Trade ( level 18 )
0000-0002-0000-0000-0000    Ceremonial Burial ( level 19 )
0000-0080-0000-0000-0000    Horseback Riding *A* ( tech level 1f )
0000-0000-0100-0000-0000    Gunpowder ( level 20 )
0000-0000-0200-0000-0000    The Wheel ( level 21 )
0000-0000-0800-0000-0000    ? ( level 23 ) Transport
0000-0000-2000-0000-0000    ? ( level 25 ) Cruiser
0000-0000-4000-0000-0000    Flight ( level 26 )
0000-0000-8000-0000-0000    Advanced Flight ( level 27 )
0000-0000-0002-0000-0000    ? ( level 29 ) Submarine
0000-0000-0004-0000-0000    Pottery ( level 2a )
0000-0000-0040-0000-0000    ? ( level 2e ) Nuclear
0000-0000-0000-0100-0000    Metallurgy ( level 30 )
0000-0000-0000-1000-0000    ? ( level 34 ) Battleship
0000-0000-0000-0004-0000    Automobile ( level 3a )
0000-0000-0000-0040-0000    Chivalry ( level 3e )
0000-0000-0000-0080-0000    Robotics ( level 3f )
0000-0000-0000-0000-0100    Conscription ( level 40 )
0000-0000-0000-0000-0200    ? ( level 40 ) Mech. Infantry

*A* level 1f is not 0000-8000-0 because of Intel byte order

0190-01c7 White (player 1) Unit Count (2/unit * 28 unit types)
** this is used by the military advisor, you don't have to update it
** if you give self extra units.

04d8-04d9 Red (player 0) Technology Count (????)
** this is used for scoring, and to determine how much the next
** advance costs.

000a-000b Difficulty Level (1-4)
** Difficulty level 1024 is impossible!!!, but it works...

5. UNIT/production TYPES
d8  - Women's Suffrage


----Ralph Betza (FM),
    uunet!ssiny!gnohmon

"The question of whether a computer can swim is more interesting
 than the question of whether a submarine can think" - Lenny Dykstra
Newsgroups: comp.sys.ibm.pc.games,misc.forsale