This document is an attempt to put what I have learn of the
various data structures used in the Command and Conquer file
'game.dat' so that other people can create editors for this
game as well.

The areas I focussed on when creating my editor (ccedit) were:
buildings, infantry and vehicles. I found out after I started
that there were 2 (at least) classes of vehicles: aircraft
and land vehicles. This means that there are at least 4 different
data structures used that I have some knowledge about (there
are undoubtably lots more used, but I don't know what they are).

I will use the terminology 'entry' to describe the fields in
the data structures, simply because I don't have a complete account
of the entire data structures used, so I will be using one entry
as a landmark to point to others.

PART 1: DETERMINING THE ENTRY SIZE
----------------------------------
One thing that makes editing these data structures difficult is that
they can be of different sizes within the file. There is a way to
work out the size of an entry however. It will only ever be either
a 1 byte value or a 4 byte value. The way to find out which it will
be is to look at the byte directly before it. If the value is 0x6A,
then the next entry will be a single byte. If the value is 0x68, then
the next entry will be 4 bytes long.

The values stored here are signed values.

The differences in entry size usually occur in entries dealing with
hit points, and occasionally cost. Most of the time when dealing with
vehicles, the hit points are stored as a 4 byte value, but for some of
them, they are stored as a single byte value (which is why I classified
things as being light and heavy in my editor).

I may be possible to change the size of the game.dat file to convert a
single byte value to a 4 byte value, but as this file is an executable
file, I don't know what effect this would have (it's probably not worth
the bother).

PART 2: REACHING THE END OF A STRUCTURE
---------------------------------------
You can tell when you reach the end of one complete structure when you
come across the value 0x81 then 0xC4. The value after these two reflects
what type of data structure it is:
 0xC0 = structure
 0xC4 = vehicle
 0x04 = Infantry
 0x94 = aircraft

PART 3: REACHING THE END OF A STRUCTURE TYPE
--------------------------------------------
When you bump on the values 0x81 0xC4 0x88, you reached the end of a
complete data structure type.

PART 4: AIRCRAFT STRUCTURE
--------------------------
There are 5 apparent aircraft. They are (in order of their appearance in
the game.dat file): A-10, Chinook, Apache (Attack helicopter), Orca, and
the transport plane.

To give you a hint, the speed for the A-10 is at offset 0x667C8 (in the
1.18p English version of Command and Conquer).

The aircraft data stucture is:
entry        use
----------------
00           ?
01           turning speed
02           speed
03           armour
04           secondary weapon
05           primary weapon
06           owner
07           ?
08           ?
09           First build level
0A           cost
0B           visual radius
0C           hit points
0D           number of shots
0E           ?
0F           Can be built
10           ?
11           ?
12           invulnerability
13           ?
14           Can be attacked by the enemy (set to OFF by default for Nod
             cargo plane, so you can't shoot it)
15           Can be selected
16           ?
17           ?
18           ?
19           ?
1A           gives it a set of rotor blades
1B           airplane: - Airplanes will keep on going forward while turning.
                       - Airplanes can't land / lift off
                       - Airplanes will keep shooting while turning around
                         for another strike. (for A-10)
1C           transport ability (stuffs up graphics for apaches)
1D           ?
1E           ?
1F           what structures you need to have to be able build this unit
20           tech level (for multiplayer settings)
21           name offset
22           ?
23           Aircraft ID number (identification for the computer)
24           ?

PART 5: BUILDING STRUCTURE
--------------------------
There are a number of structures in the file, but I never bothered with the
ones you cannot build. The others would undoubtably have the same format
(roughly) as these.

To give you a hint, the power required for the Temple of Nod is at offset
0x6DEFA (in the 1.18p English version of Command and Conquer).

The building data structure is:
entry        use
----------------
00           ?
01           ?
02           ? (has something to do with the exit of the building if it
                produces units/infantry)
03           building width
04           power required
05           power produced
06           tiberium capacity
07           ?
08           armor
09           secondary weapon
0A           primary weapon
0B           owner
0C           ?
0D           ?
0E           first build level
0F           cost
10           visual radius
11           hit points
12           ?
13           what this structure can build (8 = buildings; 6 =helicopters;
             4 = vehicles; 2 = infantry) [inf+veh: see entry 02]
14           ?
15           ?
16           can be built
17           can be repaired
18           fires weapons twice
19           has a moving turret (like the Gun turret)
1A           graphics for that building are not shown (not cloaked, just
             not drawn)
1B           invulnerability
1C           ?
1D           ?
1E           can be selected
1F           ?
20           ?
21           ?
22           capturable
23           ?
24           wall Y/N
25           calls the building "CIVILIAN BUILDING". Also used for special
             buildings to show name to an enemy player.
26           Attached concrete bib Y/N
27           ?
28           ?
29           what other structures you need to have to be able build this one
2A           tech level (for multiplayer settings)
2B           ?
2C           name offset
2D           ?
2E           structure ID number (building identification for the computer.
             Also used for making missions)
2F           ?

PART 6: VEHICLE STRUCTURE
-------------------------
The order of the vehicles in this section of the file is: visceroid,
flame tank, stealth tank, light tank, medium tank, mammoth tank, hovercraft,
mobile HQ, SSM (flame launcher), artillery, harvester, MCV, humm-vee,
Nod buggy, recon bike, rocket launcher, APC, gunboat, triceratops, t-rex,
velociraptor, and stegosaurus.

To give you a hint, the armour for the visceroid is at offset 0xDE22E (in
the 1.18p English version of Command and Conquer).

The vehicles structure is:
entry        use
----------------
00           ?
01           ?
02           turning speed
03           speed
04           unit width
05           armor
06           secondary weapon
07           primary weapon
08           owner
09           ?
0A           ?
0B           first build level
0C           cost
0D           visual radius
0E           hit points
0F           ?
10           cycles through all that units graphics (used for the visceroid)
11           stealth
12           can not turn
13           ?
14           ?
15           ?
16           ?
17           auto-rotating turret: Used for MHQ radar animation
18           Crewed: infantry unit appears when destroyed
19           can be built
1A           ?
1B           fires its weapons twice
1C           can fire in all directions
1D           invulnerability
1E           ?
1F           ?
20           ?
21           ?
22           can harvest tiberium (only Harvester can actually unload though)
23           Can crush infantry(/units: see 37)
24           Can be crushed by harvesters/tracked vehicles (see 36)
           -> Remark: only computer players can crush enemy vehicles :(
25           transport (but can't carry infantry if set by itself)
26           Name displayed to enemy
27           Dinosaur (Has walking animations, heals when uses one of the two
             bite weapons, graphics not displayed unless C&C is started with
             command line parameter 'funpark'.
28           ?
29           ?
2A           what structures you need to have to be able build this unit
2B           tech level (for multiplayer settings)
2C           ?
2D           Name offset
2E           ?
2F           Unit ID number (identification for the computer)
30           ?

PART 7: INFANTRY STRUCTURE
--------------------------
This section is definitely the hardest. I have almost no knowledge about
what this data structure is. It was just luck that I found this in the
first place.

To give you a hint, the weapon for the minigunner is at offset 0x96FAC (in
the 1.18p English version of Command and Conquer).

entry        use
----------------
00           ?
01           secondary weapon
02           primary weapon
03           owner
04           ?
05           ?
06           ?
07           cost
08           visual radius
0A           hit points
0B           ?
...          ???
73           ?
74           infiltrate
             -For Commando (if ON): can place C4-bombs.
             -For any other unit (if ON): can capture a building.
               \-> Obviously used for Engineer
           -> Remark: If put ON: Can capture a transport helicopter.
              (also for Commando's!)
75           ?
76           call this infantry unit "CIVILIAN"
             (also works with enemy soldiers)
           -> Remark: also used for special units to show name to enemy.
               \-> Delphi, Nikoomba (C10), Moebius.
                   (NOT with dr. Chan: he is always called "civilian")
77           civilian Y/N
               \-> units with this option talk like civilians and fly off
                   the edge of the map when they enter a chinook.
78           ?
79           ?
7A           ?
7B           what structures you need to have to be able build this inf. unit
7C           tech level (for multiplayer settings)
7D           Name offset
7E           ?
7F           Infantry ID number (identification for the computer)
80           ?

There are many more entries in between, but I have no idea what
they do.

I tried looking for things like invulnerability, but couldn't find it.


Andrew Griffin

Completed and corrected by
Maarten Meuris
http://www.planetcnc.com/cnc2sw/
