# sidreshot/openmerc architecture

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

- Interactive diagram: https://gitdiagram.com/sidreshot/openmerc
- Repository: https://github.com/sidreshot/openmerc

## Overview

openMERC is a Soldier of Fortune engine and mode-B game implementation. The user launches the platform executable, which enters the engine; the engine loads original game data and provides client, server, rendering, menus, and sound capabilities. Gameplay is split across game and player modules, with AI, damage, modes, scripting, navigation, and Ghoul model support. The README documents these product capabilities, but sampled source does not expose all module-loading and runtime call paths, so those links are omitted rather than inferred.

Main entry points: [`game/src/g_main.cpp`](https://github.com/sidreshot/openmerc/blob/main/game/src/g_main.cpp) (Game module), [`engine/src/client/cl_main.c`](https://github.com/sidreshot/openmerc/blob/main/engine/src/client/cl_main.c) (Game client), [`engine/src/server/sv_main.c`](https://github.com/sidreshot/openmerc/blob/main/engine/src/server/sv_main.c) (Game server), [`engine/src/backends/unix/main.c`](https://github.com/sidreshot/openmerc/blob/main/engine/src/backends/unix/main.c) (Platform entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_engine["Engine runtime"]
  node_platform["Platform entry<br/>[main.c]"]
  node_engine_core["Engine core<br/>[sof_engine.c]"]
  node_filesystem["Game data and files<br/>[filesystem.c]"]
  node_server["Game server<br/>[sv_main.c]"]
  node_network["Network transport<br/>[netchan.c]"]
  node_ghoul["Ghoul models<br/>[ghoul_system.cpp]"]
  node_save["Save and load<br/>[sv_save.c]"]
end

subgraph group_presentation["Client presentation"]
  node_client["Game client<br/>[cl_main.c]"]
  node_menus["Widescreen menus<br/>[menu.c]"]
  node_renderer["GL3 renderer<br/>[gl3_main.c]"]
  node_effects["Client effects<br/>[cl_effects.c]"]
end

subgraph group_gameplay["Game simulation"]
  node_player_lifecycle["Player lifecycle<br/>[p_client.cpp]"]
  node_combat["Damage and combat<br/>[g3_damage.cpp]"]
  node_ai["Character AI<br/>[ai_manager.cpp]"]
  node_modes["Game modes<br/>[gm_clients.cpp]"]
  node_script["Game scripting<br/>[script_vm.cpp]"]
  node_navigation["Navigation<br/>[nav_runtime.cpp]"]
end

subgraph group_modules["Game modules"]
  node_sound["OpenAL sound<br/>[snd_engine.c]"]
  node_game_module["Game module<br/>[g_main.cpp]"]
  node_player_module["Player module<br/>[pm_main.cpp]"]
end

node_player(("Player"))
node_original_data[("Original game data")]

node_player -->|"launches"| node_platform
node_platform -->|"initializes"| node_engine_core
node_engine_core -.->|"uses"| node_filesystem
node_filesystem -->|"reads pak files"| node_original_data
node_client -->|"renders with"| node_renderer
node_client -->|"presents"| node_menus
node_client -->|"draws effects"| node_effects
node_client -->|"uses"| node_sound
node_client -.->|"exchanges packets"| node_network
node_server -.->|"exchanges packets"| node_network
node_server -->|"runs gameplay"| node_game_module
node_game_module -->|"handles players"| node_player_lifecycle
node_player_lifecycle -->|"uses player logic"| node_player_module
node_game_module -.->|"supports combat"| node_combat
node_game_module -.->|"supports AI"| node_ai
node_game_module -->|"implements modes"| node_modes
node_game_module -.->|"supports scripting"| node_script
node_game_module -.->|"supports navigation"| node_navigation
node_client -->|"displays models"| node_ghoul
node_server -->|"saves levels"| node_save

click node_platform "https://github.com/sidreshot/openmerc/blob/main/engine/src/backends/unix/main.c"
click node_engine_core "https://github.com/sidreshot/openmerc/blob/main/engine/src/common/sof_engine.c"
click node_filesystem "https://github.com/sidreshot/openmerc/blob/main/engine/src/common/filesystem.c"
click node_client "https://github.com/sidreshot/openmerc/blob/main/engine/src/client/cl_main.c"
click node_server "https://github.com/sidreshot/openmerc/blob/main/engine/src/server/sv_main.c"
click node_network "https://github.com/sidreshot/openmerc/blob/main/engine/src/common/netchan.c"
click node_menus "https://github.com/sidreshot/openmerc/blob/main/engine/src/client/menu/menu.c"
click node_renderer "https://github.com/sidreshot/openmerc/blob/main/engine/src/client/refresh/gl3/gl3_main.c"
click node_effects "https://github.com/sidreshot/openmerc/blob/main/engine/src/client/cl_effects.c"
click node_sound "https://github.com/sidreshot/openmerc/blob/main/modules/sound/src/snd_engine.c"
click node_ghoul "https://github.com/sidreshot/openmerc/blob/main/engine/src/ghoul/ghoul_system.cpp"
click node_game_module "https://github.com/sidreshot/openmerc/blob/main/game/src/g_main.cpp"
click node_player_module "https://github.com/sidreshot/openmerc/blob/main/player/src/pm_main.cpp"
click node_player_lifecycle "https://github.com/sidreshot/openmerc/blob/main/game/src/p_client.cpp"
click node_combat "https://github.com/sidreshot/openmerc/blob/main/game/src/damage/g3_damage.cpp"
click node_ai "https://github.com/sidreshot/openmerc/blob/main/game/src/ai/ai_manager.cpp"
click node_modes "https://github.com/sidreshot/openmerc/blob/main/game/src/modes/gm_clients.cpp"
click node_script "https://github.com/sidreshot/openmerc/blob/main/game/src/script/script_vm.cpp"
click node_navigation "https://github.com/sidreshot/openmerc/blob/main/game/src/nav/nav_runtime.cpp"
click node_save "https://github.com/sidreshot/openmerc/blob/main/engine/src/server/sv_save.c"

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_platform,node_engine_core,node_filesystem,node_server,node_network,node_ghoul,node_save toneBlue
class node_client,node_menus,node_renderer,node_effects,node_original_data toneAmber
class node_player_lifecycle,node_combat,node_ai,node_modes,node_script,node_navigation toneMint
class node_sound,node_game_module,node_player_module toneRose
class node_player toneIndigo
```

## Components

### Engine runtime

- [Platform entry](https://github.com/sidreshot/openmerc/blob/main/engine/src/backends/unix/main.c): `engine/src/backends/unix/main.c`
- [Engine core](https://github.com/sidreshot/openmerc/blob/main/engine/src/common/sof_engine.c): `engine/src/common/sof_engine.c`
- [Game data and files](https://github.com/sidreshot/openmerc/blob/main/engine/src/common/filesystem.c): `engine/src/common/filesystem.c`
- [Game server](https://github.com/sidreshot/openmerc/blob/main/engine/src/server/sv_main.c): `engine/src/server/sv_main.c`
- [Network transport](https://github.com/sidreshot/openmerc/blob/main/engine/src/common/netchan.c): `engine/src/common/netchan.c`
- [Ghoul models](https://github.com/sidreshot/openmerc/blob/main/engine/src/ghoul/ghoul_system.cpp): `engine/src/ghoul/ghoul_system.cpp`
- [Save and load](https://github.com/sidreshot/openmerc/blob/main/engine/src/server/sv_save.c): `engine/src/server/sv_save.c`

### Client presentation

- [Game client](https://github.com/sidreshot/openmerc/blob/main/engine/src/client/cl_main.c): `engine/src/client/cl_main.c`
- [Widescreen menus](https://github.com/sidreshot/openmerc/blob/main/engine/src/client/menu/menu.c): `engine/src/client/menu/menu.c`
- [GL3 renderer](https://github.com/sidreshot/openmerc/blob/main/engine/src/client/refresh/gl3/gl3_main.c): `engine/src/client/refresh/gl3/gl3_main.c`
- [Client effects](https://github.com/sidreshot/openmerc/blob/main/engine/src/client/cl_effects.c): `engine/src/client/cl_effects.c`

### Game simulation

- [Player lifecycle](https://github.com/sidreshot/openmerc/blob/main/game/src/p_client.cpp): `game/src/p_client.cpp`
- [Damage and combat](https://github.com/sidreshot/openmerc/blob/main/game/src/damage/g3_damage.cpp): `game/src/damage/g3_damage.cpp`
- [Character AI](https://github.com/sidreshot/openmerc/blob/main/game/src/ai/ai_manager.cpp): `game/src/ai/ai_manager.cpp`
- [Game modes](https://github.com/sidreshot/openmerc/blob/main/game/src/modes/gm_clients.cpp): `game/src/modes/gm_clients.cpp`
- [Game scripting](https://github.com/sidreshot/openmerc/blob/main/game/src/script/script_vm.cpp): `game/src/script/script_vm.cpp`
- [Navigation](https://github.com/sidreshot/openmerc/blob/main/game/src/nav/nav_runtime.cpp): `game/src/nav/nav_runtime.cpp`

### Game modules

- [OpenAL sound](https://github.com/sidreshot/openmerc/blob/main/modules/sound/src/snd_engine.c): `modules/sound/src/snd_engine.c`
- [Game module](https://github.com/sidreshot/openmerc/blob/main/game/src/g_main.cpp): `game/src/g_main.cpp`
- [Player module](https://github.com/sidreshot/openmerc/blob/main/player/src/pm_main.cpp): `player/src/pm_main.cpp`

### Other components

- **Player**
- **Original game data**

## Connections

- Player → Platform entry: launches (evidence: `engine/src/backends/unix/main.c`)
- Platform entry → Engine core: initializes (evidence: `engine/src/backends/unix/main.c`)
- Engine core → Game data and files: uses
- Game data and files → Original game data: reads pak files (evidence: `README.md`)
- Game client → GL3 renderer: renders with (evidence: `README.md`)
- Game client → Widescreen menus: presents (evidence: `README.md`)
- Game client → Client effects: draws effects (evidence: `README.md`)
- Game client → OpenAL sound: uses (evidence: `README.md`)
- Game client → Network transport: exchanges packets
- Game server → Network transport: exchanges packets
- Game server → Game module: runs gameplay (evidence: `README.md`)
- Game module → Player lifecycle: handles players (evidence: `game/src/p_client.cpp`)
- Player lifecycle → Player module: uses player logic (evidence: `game/src/p_client.cpp`)
- Game module → Damage and combat: supports combat
- Game module → Character AI: supports AI
- Game module → Game modes: implements modes (evidence: `game/src/modes/gm_clients.cpp`)
- Game module → Game scripting: supports scripting
- Game module → Navigation: supports navigation
- Game client → Ghoul models: displays models (evidence: `README.md`)
- Game server → Save and load: saves levels (evidence: `README.md`)
