Home

Awesome

Age of Empires 2: The Conquerors — Savegame File Format Specification

Table of Contents

Structure Definitions

The structure definitions kind of follow the BinData Ruby Gem declarations. They should be as readable as pseudo code though. More information on BinData can be found here.

Synchronization

TagDescriptionValidated
SYNCH

Messaging

TagDescriptionValidated
0x000001F4GAMESTART
0xFFFFFFFFCHAT+

Gameplay Actions

TagDescriptionValidated
0x00ATTACK+
0x01STOP+
0x02AI_PRIMARY+
0x03MOVE+
0x0aAI_MOVE
0x0bRESIGN+
0x10WAYPOINT+
0x12STANCE+
0x13GUARD+
0x14FOLLOW+
0x15PATROL+
0x17FORMATION+
0x1bSAVE & EXIT
0x1fAI_COORD+
0x64AI_TRAIN+
0x65TECH+
0x66BUILD+
0x67MULTIPURPOSE
0x69WALL+
0x6aDELETE+
0x6bATTACKGROUND+
0x6cTRIBUTE+
0x6eREPAIR+
0x6fUNGARRISON+
0x72GATE+
0x73FLARE+
0x75GARRISON+
0x77TRAIN+
0x78RALLY+
0x7aSELL+
0x7bBUY+
0x7eRELIC+
0x7fTOWNBELL+
0x80BACKTOWORK+
0xFFGAMESTATSUP only

FAQ

  1. What actions are not saved but only calculated on replay simulation?

    • Only actions that are actively taken by players are stored
    • Any other actions are either simulated during replay (map reveal) or determined by the random number generator (Gaia movement)
    • Pause is not saved, that is why chat messages that were sent during the pause are displayed nearly at once when replayed.
  2. What actions are only saved for certain players, i.e., the owner of the recorded game?

    • Viewpoints (for lock view) are only saved for the owner of the recorded game, together with the sychronization info.
  3. How does AoE2 create an .mgx file?

    • Singleplayer games are recorded by getting actions from the input buffer and writing them into the .mgx file.
    • During multiplayer games, actions are distributed to all players (even messages). The input buffer is transferred over the network to the other players.
  4. Why are there so many zeros in the actions?

    • Most of the zeros are caused by memory alignment. Because networking and recording directly work on the input buffer, the data is aligned to 3the size of (menory) words (4 bytes). Example:
    struct example {
      uint8_t player_id;
      uint32_t unit_id;
    };
    

    Here the first variable player_id will take up 1 out of 4 bytes of the first word. The next variable, unit_id, doesn't fit into the first word anymore, so it will use a second word instead. The remaining 3 bytes in the first word remain uninitialized and therefore have zero values in them.

  5. Why are they doing this weird memory stuff? It sounds stupid

    • Because it is fast. Data can be put to use directly and does not have to be parsed.
  6. What are the various IDs used for?

    • Players have an ID and a number. This is necessary because of an undocumented cooperative mode in AoE2, where players can have the same player number.
    • Unit IDs reference a type of unit/building or object in the game files.
    • Object IDs reference a specific object during a game. Every building, unit or resource gets an ID. For new units, the IDs are incremented.