1. Architecture
Four TCP servers, all started from build/. They read gamedata/ and their *.cfg from the working directory.
| Server | Port | Owns |
|---|---|---|
login_srv | 10900 | Nickname login (no passwords, the client runs with local auth), reconnect offer for a suspended game, redirect to the hub. |
hub_srv | 11900 | The bridge (lobby map), accounts, gear and nodes, weapons, guilds, mail, achievements, parties, rooms and the pick phase. |
mm_srv | 13900 | Parties, queues, matching, bot fill, room confirm, game creation. Hub and game connect to it on loopback. |
game_srv | 12900 | The match: simulation, combat, AI and bots, PhysX, replication. |
Player flow
- The client logs in on login. If the account has a suspended game, login offers it (
SN_SuspendedToCity, thenCQ_ReturnToGameleads toSN_DoConnectGameServer); otherwiseSN_DoConnectChannelServersends it to the hub. - The hub loads the bridge. Queuing sends
HQ_PartyCreate/HQ_PartyEnqueueto the matchmaker. - The matchmaker answers
MN_MatchingPartyFound; the hub shows the accept window (SQ_MatchingPartyFound). After confirms,MN_RoomCreatedstarts the pick phase, thenMQ_CreateGamegoes to the game server, which answersGR_GameCreated; the hub receivesMN_MatchCreated. - The hub sends
SN_DoConnectGameServerwith an instant key (hash of account and sortie ids); the client joins the game server. - At the end, the game sends
SQ_PrepareHandoverToChannel, thenSN_DoConnectChannelServerback to the hub;GN_GameEnded/MN_GameEndedclose the match on the matchmaker and hub.
Inter-server messages
src/common/inner_protocol.h, namespace In. Prefixes: HQ_/HN_ hub to matchmaker, GQ_/GR_/GN_ game to matchmaker, MR_/MN_/MQ_ matchmaker to hub or game (Q query, R response, N notification). These are not client packets.
Accounts
Flat files in build/accounts/, one set per nickname (progress, items, gear, weapons, stages, missions, achievements, PvP, summary, friends, settings), plus shared guild and mail files. Writes go through a temporary file and a commit (src/mxm/safe_file.cpp); the hub backs the folder up at start. Suspended games for reconnect are small records next to them. Never publish this folder.
2. Repository layout
GameServer
gamedata
Two kinds of data: gamedata/client/ holds copies of the EU client tables, the rest is server-side data derived from captures, the client or testers. Many files carry a source= attribute.
build/ runtime
Tools repository
Everything that is not server code lives here: labs, probes, capture tools, reverse engineering, notes. New scripts and notes never go into GameServer.
ClientMod and release
ClientMod is its own repository of client data overrides (Data/Design, Graphic, L10N, NavMesh, Sound, Ui) installed into the client folder: ported masters, skins, sounds, interface fixes. Code fixes to the packed client executable go through the xinput1_3.dll proxy in Tools/clientpatch (ship both DLLs).
Release: Tools/release/make_full.py <version> builds one zip from the local client and the built server, with the launch scripts and README of MxM_Server: start_servers.bat, stop_servers.bat, set_host_ip.bat, open_firewall.bat.
3. Rules and data-driven design
- No comments in the code (AGENTS.md). Check diffs for
//before committing. - Every gameplay value comes from data: client tables, skill tooltips, official captures, client reverse engineering. No invented constants; an unavoidable assumption is named as one and kept minimal.
- Works or crashes: assert internal invariants, a server never half-works. Hostile client input is dropped.
- Hot paths: resolve strings to enums or indexes at load time; no per-tick string compares or linear status scans. Per-master exceptions live in one table (
world_master_rules.h), not in branches. - Avoid STL strings (EASTL fixed strings are used). Packet structs keep the client's real names.
Constant prefixes
| Prefix | Meaning |
|---|---|
MEASURED_ | Measured on official match captures (for example a timing, an angle, a rate). |
TESTER_ | From a veteran tester when data and captures are silent; data and captures win if they disagree. |
HYP_ | A hypothesis: the best guess until evidence arrives. Grep for it to find what still needs proof. |
CLIENT_ | Mirrors client behaviour found by reverse engineering. |
Data files use the same idea with source= attributes (measured, tester, hypothesis); estimated monster data lives in separate *Estimated.xml files.
Layers and commits
- Layer 1: engine and the 40 EU masters. Layer 2: masters ported from the Chinese client. Layer 3: test bench code (
world_showcase.*,Dev*options), kept out of upstream PRs. - Commit messages in English: one line describing the behaviour against official, with the evidence.
- Upstream PRs go to the community GameServer repository through a fork, built without lab code (
Tools/pr/strip_lab_code.py). The private branch is backed up separately. Never commit raw captures.
4. Packet handling
| Prefix | Direction | Meaning |
|---|---|---|
CQ_ | client → server | request |
CN_ | client → server | notification |
CA_ | client → server | answer to a server request |
SA_ | server → client | answer to a CQ_ |
SN_ | server → client | notification |
SQ_ | server → client | server request (accept window, handover, teleport) |
ST_ | both | embedded sub-structure |
Header: NetHeader { u16 size; u16 netID; }. Client ids are in the 600xx range (CQ_FirstHello = 60002), server ids in 62xxx (SA_FirstHello = 62002). Traffic is LEA-encrypted (see PacketEncryption.md).
Every handler follows the same three steps (AGENTS.md): ValidatePacket<T> before parsing (exact size by default, specialisations walk variable parts), then one NT_LOG with PacketSerialize<T> (every logged type needs a specialisation, the default template fails to compile), then use the values. Header-only packets skip validation but are still logged.
#define CASE(PACKET) case Cl::PACKET::NET_ID: { HandlePacket_##PACKET(...); } break
CASE(CQ_ExecuteSkill);Example: src/servers/game/channel.cpp dispatches CQ_ExecuteSkill; the handler validates, warns and returns on a bad packet, logs it, then calls game->OnPlayerExecuteSkill. The hub uses the same pattern with HANDLE_CASE. Logging: LOG / WARN go to <server>.log, NT_LOG / NT_WARN to <server>_nt.log.
5. Build and run
game_srv.cmd /c '"<VS BuildTools>\VC\Auxiliary\Build\vcvars64.bat" >nul && cd /d <GameServer> && cmake --build build\release'
cmake --build build\release --target sync_gamedata # data only
cmake -S <GameServer> -B <GameServer>\build\release -G Ninja -DCMAKE_BUILD_TYPE=Release # configureStart order: mm_srv, then hub_srv and game_srv, then login_srv (start_servers.bat or Tools/human/restart_all.ps1). The client is launched with local auth and encryption options, for example /AuthMethod:local /AutoLoginID:<name>.
Dev config flags
| File | Key | Effect |
|---|---|---|
| game.cfg | DevMode | Enables the chat commands below. Release value 0. |
| game.cfg | DevForcedMap | Forces the map of every game. Keep it at 0: a deathmatch map id there forces it even in Titan Ruins. |
| game.cfg | DevObserver | The client spectates the bots. |
| game.cfg | DevScenario, DevTruth, DevTelemetry | Scripted scenarios and truth/telemetry dumps for the probe. |
| game.cfg | DevGodPlayers, DevStartLevel, DevGameTimeSec | Lab conveniences. |
| game.cfg | HostIP | Address announced for the return to the hub (set by set_host_ip.bat). |
| hub.cfg | DevMode, LobbyMap | Hub chat commands; bridge map (Christmas bridge in releases). |
| hub.cfg | DevAutoQueue*, DevStageSweep, DevShowcase*, DevMirror* | Automatic queue, PvE sweep and bench modes for labs. |
| matchmaker.cfg | DevNoBots | No bot fill (lane labs). Restore it after a test. |
| matchmaker.cfg | TeamSize, MatchingWaitSec, SoloRooms | Matching parameters. |
| matchmaker.cfg / login.cfg | public address keys | Written by set_host_ip.bat; never publish their values. |
Dev chat commands (DevMode)
Game server: !tp x y [z], !god, !level n, !titan, !item idx, !killtag n, !killnear r, !ult, !vision, !loadout, !ai, !removeai, !dummyhome, !dummymortal, !clear, !portal, !wave, !enemysummon, !mongroggy. Hub: !give, !gold, !change, !rozark.
6. Tests and labs
- Main launcher:
Tools/human/clientbot_run.ps1rewrites the cfg files, starts the four servers and the client, records the game, then restores the configs.-QueueStage 200101000= Titan Ruins,200020100= 3v3,200000100= training room; without it, a PvE sweep. Switches:-Observer,-Probe,-Pilot,-Scenario,-Masters. - Training room first: targeted skill, animation and damage tests run in the training room (
train_lab.ps1, generated scenarios); Titan Ruins games are the final check. Bot tests run in observer mode. - Reviews:
Tools/probe/full_review.py <recording>runs the detectors (continuity, dashes, structures, towers, effects, hit shapes, damage against official, statuses, minion fights);review_diff.pycompares with the previous recording and flags regressions. - Mirror tests: a human client and a bot play the same masters;
mirror-*git tags mark each passed campaign. - References, in order of trust: official captures, client data, official videos, reverse engineering.
Official captures
Packet captures of official matches stay outside the repositories and are never committed. Tools/pcap/mxmcap.py lists and caches games by mode; payloads are decrypted in order per direction with the LEA key derived from SA_FirstHello. The gen_*.py scripts turn the measurements into the Measured*.xml, monster and skill ratio files.
Wiki and release
Tools/wiki/build_skill_ratios.py reads gamedata, protocol definitions, client strings and interface art and writes the skill wiki; make_standalone.py inlines it into one file. Tools/session/cleanup.py removes old lab captures.
7. Glossary
- Master
- A playable character; each has a class number (1 = Taejin...).
- Tag
- Swapping between your two masters during a match.
- Remote
- A server-spawned hit entity: hitbox, projectile or area, defined in the REMOTE tables.
- Creator
- A remote that spawns child remotes.
- Status
- A buff or debuff from the STATUS tables (statuses and passives).
- skilltt
- The skill tooltip table: per-rank values shown in game, also used as data.
- Stance
- A timed or shot-limited skill mode (for example a cannon mode).
- Shirk
- The dodge / survival skill slot.
- Sortie
- One game instance, identified by a sortie id.
- Stage
- A playable mode or level id from STAGELIST (200101000 = Titan Ruins).
- Doc id
- The id of a row in a data table (a creature, an item...).
- Bridge / hub
- The lobby ship between matches, run by the hub server.
- In-match level
- Level 1 to 18 gained during a Titan Ruins match.
- Titan Shard / piece
- Dropped by titans, monoliths and towers; carried back to base to unlock Titan Incarnate.
- Titan's Sight
- A capturable vision point in Titan Ruins.
- Altar
- Top and bottom lane objective that calls a Fallen Hero.
- Node
- Gear item equipped in node pages per master.
- Augment
- Weapon upgrade bought with materials.
- MEASURED / TESTER / HYP
- Where a value comes from: captures, a veteran tester, or a hypothesis.
