# hyouka0904/mc2 architecture

> Architecture diagram of the GitHub repository hyouka0904/mc2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hyouka0904/mc2
- Repository: https://github.com/hyouka0904/mc2

## Overview

MechCommander 2 is a cross-platform real-time tactical game built on a reimplemented GameOS layer. The player enters through the game UI, selects or starts a mission, commands units through simulation and combat, and can continue a campaign with saved progress; the repository also documents logistics/mech-lab screens, movies, sound, and mod overlays. The map follows the README’s stated layers and capabilities. Source excerpts are limited, so edges describe documented relationships rather than presumed calls; network play is explicitly unimplemented.

Main entry points: [`code/mission.cpp`](https://github.com/hyouka0904/mc2/blob/master/code/mission.cpp) (Mission simulation), [`code/logmain.cpp`](https://github.com/hyouka0904/mc2/blob/master/code/logmain.cpp) (Game runtime), [`code/mainmenu.cpp`](https://github.com/hyouka0904/mc2/blob/master/code/mainmenu.cpp) (Menus and missions), [`code/logistics.cpp`](https://github.com/hyouka0904/mc2/blob/master/code/logistics.cpp) (Logistics and saves)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game flow"]
  node_runtime["Game runtime<br/>[logmain.cpp]"]
  node_menus["Menus and missions<br/>[mainmenu.cpp]"]
  node_mission["Mission simulation<br/>[mission.cpp]"]
  node_units["Mechs and warriors<br/>[mech.cpp]"]
  node_campaign["Logistics and saves<br/>[logistics.cpp]"]
  node_movies["Cutscenes<br/>[mc2movie.cpp]"]
end

subgraph group_engine["Game engine"]
  node_pathfinding["Pathfinding<br/>[move.cpp]"]
  node_terrain["Terrain and camera<br/>[camera.h]"]
  node_modelrender["Models and textures<br/>[mech3d.cpp]"]
  node_effects["Visual effects<br/>[effectlibrary.hpp]"]
  node_abl["ABL scripting<br/>[ablscan.cpp]"]
  node_datafiles[("Game data files<br/>[ffile.cpp]")]
end

subgraph group_ui["Game UI"]
  node_gui["GUI widgets<br/>[alistbox.cpp]"]
  node_pilot["Pilot review"]
end

subgraph group_platform["Platform services"]
  node_audio["Audio<br/>[gameos_sound.cpp]"]
  node_gameos["GameOS services<br/>[gameos.hpp]"]
  node_renderer["Rendering API<br/>[render_device.h]"]
  node_gpu["SDL GPU backend<br/>[gpu_device.cpp]"]
  node_opengl["OpenGL backend<br/>[gl_device.cpp]"]
end

subgraph group_mods["Mods"]
  node_modsystem["Mod overlays<br/>[mod_system.cpp]"]
  node_modtool["Mod authoring tool<br/>[main.cpp]"]
end

node_player(("Player"))

node_player -->|"starts"| node_runtime
node_runtime -.->|"runs"| node_menus
node_menus -->|"starts mission"| node_mission
node_mission -.->|"commands units"| node_units
node_mission -->|"uses navigation"| node_pathfinding
node_mission -->|"uses terrain"| node_terrain
node_mission -->|"runs mission scripts"| node_abl
node_menus -.->|"opens logistics"| node_campaign
node_campaign -.->|"loads game data"| node_datafiles
node_mission -->|"renders models"| node_modelrender
node_mission -->|"renders effects"| node_effects
node_menus -->|"uses widgets"| node_gui
node_campaign -.->|"shows pilot review"| node_pilot
node_runtime -->|"plays cutscenes"| node_movies
node_movies -->|"streams audio"| node_audio
node_runtime -->|"uses platform layer"| node_gameos
node_gameos -->|"draws through"| node_renderer
node_renderer -->|"uses by default"| node_gpu
node_renderer -.->|"falls back to"| node_opengl
node_runtime -->|"opens game files"| node_datafiles
node_datafiles -->|"applies overlays"| node_modsystem
node_modtool -->|"uses mod API"| node_modsystem

click node_runtime "https://github.com/hyouka0904/mc2/blob/master/code/logmain.cpp"
click node_menus "https://github.com/hyouka0904/mc2/blob/master/code/mainmenu.cpp"
click node_mission "https://github.com/hyouka0904/mc2/blob/master/code/mission.cpp"
click node_units "https://github.com/hyouka0904/mc2/blob/master/code/mech.cpp"
click node_campaign "https://github.com/hyouka0904/mc2/blob/master/code/logistics.cpp"
click node_movies "https://github.com/hyouka0904/mc2/blob/master/code/mc2movie.cpp"
click node_gui "https://github.com/hyouka0904/mc2/blob/master/gui/alistbox.cpp"
click node_pilot "https://github.com/hyouka0904/mc2/blob/master/code/pilotreviewarea.cpp"
click node_pathfinding "https://github.com/hyouka0904/mc2/blob/master/mclib/move.cpp"
click node_terrain "https://github.com/hyouka0904/mc2/blob/master/mclib/camera.h"
click node_modelrender "https://github.com/hyouka0904/mc2/blob/master/mclib/mech3d.cpp"
click node_effects "https://github.com/hyouka0904/mc2/blob/master/mclib/gosfx/effectlibrary.hpp"
click node_abl "https://github.com/hyouka0904/mc2/blob/master/mclib/ablscan.cpp"
click node_datafiles "https://github.com/hyouka0904/mc2/blob/master/mclib/ffile.cpp"
click node_audio "https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/gameos_sound.cpp"
click node_gameos "https://github.com/hyouka0904/mc2/blob/master/GameOS/include/gameos.hpp"
click node_renderer "https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/render/render_device.h"
click node_gpu "https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/render/gpu/gpu_device.cpp"
click node_opengl "https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/render/gl/gl_device.cpp"
click node_modsystem "https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/mods/mod_system.cpp"
click node_modtool "https://github.com/hyouka0904/mc2/blob/master/tools/mc2mod/main.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runtime,node_menus,node_mission,node_units,node_campaign,node_movies toneBlue
class node_pathfinding,node_terrain,node_modelrender,node_effects,node_abl,node_datafiles toneAmber
class node_gui,node_pilot toneMint
class node_audio,node_gameos,node_renderer,node_gpu,node_opengl toneRose
class node_modsystem,node_modtool,node_player toneIndigo
```

## Components

### Game flow

- [Game runtime](https://github.com/hyouka0904/mc2/blob/master/code/logmain.cpp): `code/logmain.cpp`
- [Menus and missions](https://github.com/hyouka0904/mc2/blob/master/code/mainmenu.cpp): `code/mainmenu.cpp`
- [Mission simulation](https://github.com/hyouka0904/mc2/blob/master/code/mission.cpp): `code/mission.cpp`
- [Mechs and warriors](https://github.com/hyouka0904/mc2/blob/master/code/mech.cpp): `code/mech.cpp`
- [Logistics and saves](https://github.com/hyouka0904/mc2/blob/master/code/logistics.cpp): `code/logistics.cpp`
- [Cutscenes](https://github.com/hyouka0904/mc2/blob/master/code/mc2movie.cpp): `code/mc2movie.cpp`

### Game engine

- [Pathfinding](https://github.com/hyouka0904/mc2/blob/master/mclib/move.cpp): `mclib/move.cpp`
- [Terrain and camera](https://github.com/hyouka0904/mc2/blob/master/mclib/camera.h): `mclib/camera.h`
- [Models and textures](https://github.com/hyouka0904/mc2/blob/master/mclib/mech3d.cpp): `mclib/mech3d.cpp`
- [Visual effects](https://github.com/hyouka0904/mc2/blob/master/mclib/gosfx/effectlibrary.hpp): `mclib/gosfx/effectlibrary.hpp`
- [ABL scripting](https://github.com/hyouka0904/mc2/blob/master/mclib/ablscan.cpp): `mclib/ablscan.cpp`
- [Game data files](https://github.com/hyouka0904/mc2/blob/master/mclib/ffile.cpp): `mclib/ffile.cpp`

### Game UI

- [GUI widgets](https://github.com/hyouka0904/mc2/blob/master/gui/alistbox.cpp): `gui/alistbox.cpp`
- [Pilot review](https://github.com/hyouka0904/mc2/blob/master/code/pilotreviewarea.cpp): `code/pilotreviewarea.cpp`

### Platform services

- [Audio](https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/gameos_sound.cpp): `GameOS/gameos/gameos_sound.cpp`
- [GameOS services](https://github.com/hyouka0904/mc2/blob/master/GameOS/include/gameos.hpp): `GameOS/include/gameos.hpp`
- [Rendering API](https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/render/render_device.h): `GameOS/gameos/render/render_device.h`
- [SDL GPU backend](https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/render/gpu/gpu_device.cpp): `GameOS/gameos/render/gpu/gpu_device.cpp`
- [OpenGL backend](https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/render/gl/gl_device.cpp): `GameOS/gameos/render/gl/gl_device.cpp`

### Mods

- [Mod overlays](https://github.com/hyouka0904/mc2/blob/master/GameOS/gameos/mods/mod_system.cpp): `GameOS/gameos/mods/mod_system.cpp`
- [Mod authoring tool](https://github.com/hyouka0904/mc2/blob/master/tools/mc2mod/main.cpp): `tools/mc2mod/main.cpp`

### Other components

- **Player**

## Connections

- Player → Game runtime: starts (evidence: `README.md`)
- Game runtime → Menus and missions: runs
- Menus and missions → Mission simulation: starts mission (evidence: `README.md`)
- Mission simulation → Mechs and warriors: commands units
- Mission simulation → Pathfinding: uses navigation (evidence: `README.md`)
- Mission simulation → Terrain and camera: uses terrain (evidence: `README.md`)
- Mission simulation → ABL scripting: runs mission scripts (evidence: `README.md`)
- Menus and missions → Logistics and saves: opens logistics
- Logistics and saves → Game data files: loads game data
- Mission simulation → Models and textures: renders models (evidence: `README.md`)
- Mission simulation → Visual effects: renders effects (evidence: `README.md`)
- Menus and missions → GUI widgets: uses widgets (evidence: `README.md`)
- Logistics and saves → Pilot review: shows pilot review
- Game runtime → Cutscenes: plays cutscenes (evidence: `README.md`)
- Cutscenes → Audio: streams audio (evidence: `README.md`)
- Game runtime → GameOS services: uses platform layer (evidence: `README.md`)
- GameOS services → Rendering API: draws through (evidence: `README.md`)
- Rendering API → SDL GPU backend: uses by default (evidence: `README.md`)
- Rendering API → OpenGL backend: falls back to (evidence: `README.md`)
- Game runtime → Game data files: opens game files (evidence: `README.md`)
- Game data files → Mod overlays: applies overlays (evidence: `README.md`)
- Mod authoring tool → Mod overlays: uses mod API (evidence: `README.md`)
