Giter Club home page Giter Club logo

aoc-mgx-format's Introduction

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

Tag Description Validated
SYNCH

Messaging

Tag Description Validated
0x000001F4 GAMESTART
0xFFFFFFFF CHAT +

Gameplay Actions

Tag Description Validated
0x00 ATTACK +
0x01 STOP +
0x02 AI_PRIMARY +
0x03 MOVE +
0x0a AI_MOVE
0x0b RESIGN +
0x10 WAYPOINT +
0x12 STANCE +
0x13 GUARD +
0x14 FOLLOW +
0x15 PATROL +
0x17 FORMATION +
0x1b SAVE & EXIT
0x1f AI_COORD +
0x64 AI_TRAIN +
0x65 TECH +
0x66 BUILD +
0x67 MULTIPURPOSE
0x69 WALL +
0x6a DELETE +
0x6b ATTACKGROUND +
0x6c TRIBUTE +
0x6e REPAIR +
0x6f UNGARRISON +
0x72 GATE +
0x73 FLARE +
0x75 GARRISON +
0x77 TRAIN +
0x78 RALLY +
0x7a SELL +
0x7b BUY +
0x7e RELIC +
0x7f TOWNBELL +
0x80 BACKTOWORK +
0xFF GAMESTATS UP 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.

aoc-mgx-format's People

Contributors

dependabot[bot] avatar heinezen avatar stefan-kolb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aoc-mgx-format's Issues

Hints in network protocol

Hey, I'm doing a full analysis on the AoC network protocol over here and I might have some info for you.

  1. 0x00 is also used for boarding a transport ship.
  2. The value 0xff for selected_unit_count is meant to be a reference to previously selected units. Whenever this turns up, it translates to "Do that action with the units from the previous command". This construct saves a lot of bandwith.
  3. The action 0x67 is used for diplomacy (allied, neutral, enemy), but is also used for cheats and maybe other action like "resign". In the network protocol it looks like this

67 — command
00 — context (different values for cheat, diplomacy, etc.)
01 — player_id_1 (who sends the offer)
00 — zero
02 — player_id_2 (who receives the offer)
00 00 00 00 00 — zero
40 40 03 — relation
00 00 00 — attacker id

The values for relation can be 00 00 00 (allied), 80 3f 01 (neutral) and 40 40 03 (enemies). When using cheats, the player_id_2 field is used. Cheats start at value 0x65.

EDIT:

  1. Action 0x7e is dropping a relic.
  2. Action 0x1b is Save & Exit.

Unit actions

def Research
    int8 :command
    int24 :zero?
    int32 :object_id
    int16 :player_id
    int16 :technology_id
    int32 :constant?
end

Most actions (related to units?) always start with 4xint8 data, int32 object_id, ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.