# ihhub/fheroes2 architecture

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

- Interactive diagram: https://gitdiagram.com/ihhub/fheroes2
- Repository: https://github.com/ihhub/fheroes2

## Overview

fheroes2 is a multiplatform recreation of Heroes of Might and Magic II. The player-facing workflow is to launch the game, enter a scenario or campaign, manage a kingdom and heroes on the adventure map, resolve battles and town activity, and continue toward victory. The repository also includes an Android asset-import and file-management front end, map editing with undo/redo, and shared rendering, audio, and serialization services. Major gameplay branches are represented from the tree and README; because most game runtime sources were not excerpted, their internal call relationships are left unasserted.

Main entry points: [`android/app/src/main/java/org/fheroes2/ToolsetActivity.java`](https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/ToolsetActivity.java) (Toolset activity), [`src/fheroes2/game/game.cpp`](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/game.cpp) (Game flow), [`src/fheroes2/maps/maps.cpp`](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/maps/maps.cpp) (Maps and world), [`src/fheroes2/game/fheroes2.cpp`](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/fheroes2.cpp) (Game entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android setup"]
  node_toolset["Toolset activity"]
  node_assetcheck["Asset validation"]
  node_installer["Installer extraction<br/>[InnoExtract.java]"]
  node_files["File operations"]
  node_mapfiles["Map management"]
  node_savefiles["Save management"]
  node_gameactivity["Game activity<br/>[GameActivity.java]"]
  node_iso["ISO filesystem"]
  node_isoentry["ISO entries"]
end

subgraph group_gameplay["Game flow"]
  node_gameentry["Game entry<br/>[fheroes2.cpp]"]
  node_gameflow["Game flow<br/>[game.cpp]"]
  node_campaign["Campaign flow<br/>[game_campaign.cpp]"]
end

subgraph group_world["Strategy and editing"]
  node_mapworld["Maps and world<br/>[maps.cpp]"]
  node_kingdomhero["Kingdom and heroes<br/>[kingdom.cpp]"]
  node_battle["Battle system<br/>[battle_main.cpp]"]
  node_ai["Computer opponents"]
  node_editor["Map editor"]
  node_history["Editor history"]
end

subgraph group_engine["Engine services"]
  node_render["Image rendering<br/>[image.cpp]"]
  node_serialization["Serialization<br/>[serialize.h]"]
end

subgraph group_media["Media and assets"]
  node_audio["Audio playback<br/>[audio_manager.cpp]"]
  node_assets["Game assets<br/>[game_assets.cpp]"]
end

node_player(("Player"))

node_player -.->|"opens"| node_toolset
node_toolset -->|"validates installer"| node_installer
node_toolset -->|"checks assets"| node_assetcheck
node_toolset -->|"launches"| node_gameactivity
node_toolset -->|"opens"| node_mapfiles
node_toolset -->|"opens"| node_savefiles
node_mapfiles -->|"uses"| node_files
node_savefiles -->|"uses"| node_files
node_gameactivity -.->|"starts"| node_gameentry
node_player -.->|"plays"| node_gameentry
node_gameentry -.->|"enters"| node_gameflow
node_gameflow -.->|"offers"| node_campaign
node_gameflow -.->|"uses"| node_mapworld
node_mapworld -.->|"supports"| node_kingdomhero
node_mapworld -.->|"supports"| node_battle
node_mapworld -.->|"includes"| node_ai
node_player -.->|"edits maps"| node_editor
node_editor -->|"records actions"| node_history
node_gameflow -.->|"renders"| node_render
node_gameflow -.->|"plays audio"| node_audio
node_gameflow -.->|"loads assets"| node_assets
node_history -->|"serializes maps"| node_serialization
node_assetcheck -->|"reads ISO"| node_iso
node_iso -->|"creates entries"| node_isoentry

click node_toolset "https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/ToolsetActivity.java"
click node_assetcheck "https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/HoMM2AssetManagement.java"
click node_installer "https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/InnoExtract.java"
click node_files "https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/FileManagement.java"
click node_mapfiles "https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/MapFileManagerActivity.java"
click node_savefiles "https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/SaveFileManagerActivity.java"
click node_gameactivity "https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/GameActivity.java"
click node_gameentry "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/fheroes2.cpp"
click node_gameflow "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/game.cpp"
click node_campaign "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/game_campaign.cpp"
click node_mapworld "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/maps/maps.cpp"
click node_kingdomhero "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/kingdom/kingdom.cpp"
click node_battle "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/battle/battle_main.cpp"
click node_ai "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/ai/ai_planner_hero.cpp"
click node_editor "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/editor/editor_interface.cpp"
click node_history "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/editor/history_manager.cpp"
click node_render "https://github.com/ihhub/fheroes2/blob/master/src/engine/image.cpp"
click node_serialization "https://github.com/ihhub/fheroes2/blob/master/src/engine/serialize.h"
click node_audio "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/audio/audio_manager.cpp"
click node_assets "https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/game_assets.cpp"
click node_iso "https://github.com/ihhub/fheroes2/blob/master/android/isotools/src/main/java/com/github/stephenc/javaisotools/loopfs/iso9660/Iso9660FileSystem.java"
click node_isoentry "https://github.com/ihhub/fheroes2/blob/master/android/isotools/src/main/java/com/github/stephenc/javaisotools/loopfs/iso9660/Iso9660FileEntry.java"

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_toolset,node_assetcheck,node_installer,node_files,node_mapfiles,node_savefiles,node_gameactivity,node_iso,node_isoentry toneBlue
class node_gameentry,node_gameflow,node_campaign toneAmber
class node_mapworld,node_kingdomhero,node_battle,node_ai,node_editor,node_history toneMint
class node_render,node_serialization toneRose
class node_audio,node_assets,node_player toneIndigo
```

## Components

### Android setup

- [Toolset activity](https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/ToolsetActivity.java): `android/app/src/main/java/org/fheroes2/ToolsetActivity.java`
- [Asset validation](https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/HoMM2AssetManagement.java): `android/app/src/main/java/org/fheroes2/HoMM2AssetManagement.java`
- [Installer extraction](https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/InnoExtract.java): `android/app/src/main/java/org/fheroes2/InnoExtract.java`
- [File operations](https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/FileManagement.java): `android/app/src/main/java/org/fheroes2/FileManagement.java`
- [Map management](https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/MapFileManagerActivity.java): `android/app/src/main/java/org/fheroes2/MapFileManagerActivity.java`
- [Save management](https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/SaveFileManagerActivity.java): `android/app/src/main/java/org/fheroes2/SaveFileManagerActivity.java`
- [Game activity](https://github.com/ihhub/fheroes2/blob/master/android/app/src/main/java/org/fheroes2/GameActivity.java): `android/app/src/main/java/org/fheroes2/GameActivity.java`
- [ISO filesystem](https://github.com/ihhub/fheroes2/blob/master/android/isotools/src/main/java/com/github/stephenc/javaisotools/loopfs/iso9660/Iso9660FileSystem.java): `android/isotools/src/main/java/com/github/stephenc/javaisotools/loopfs/iso9660/Iso9660FileSystem.java`
- [ISO entries](https://github.com/ihhub/fheroes2/blob/master/android/isotools/src/main/java/com/github/stephenc/javaisotools/loopfs/iso9660/Iso9660FileEntry.java): `android/isotools/src/main/java/com/github/stephenc/javaisotools/loopfs/iso9660/Iso9660FileEntry.java`

### Game flow

- [Game entry](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/fheroes2.cpp): `src/fheroes2/game/fheroes2.cpp`
- [Game flow](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/game.cpp): `src/fheroes2/game/game.cpp`
- [Campaign flow](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/game_campaign.cpp): `src/fheroes2/game/game_campaign.cpp`

### Strategy and editing

- [Maps and world](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/maps/maps.cpp): `src/fheroes2/maps/maps.cpp`
- [Kingdom and heroes](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/kingdom/kingdom.cpp): `src/fheroes2/kingdom/kingdom.cpp`
- [Battle system](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/battle/battle_main.cpp): `src/fheroes2/battle/battle_main.cpp`
- [Computer opponents](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/ai/ai_planner_hero.cpp): `src/fheroes2/ai/ai_planner_hero.cpp`
- [Map editor](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/editor/editor_interface.cpp): `src/fheroes2/editor/editor_interface.cpp`
- [Editor history](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/editor/history_manager.cpp): `src/fheroes2/editor/history_manager.cpp`

### Engine services

- [Image rendering](https://github.com/ihhub/fheroes2/blob/master/src/engine/image.cpp): `src/engine/image.cpp`
- [Serialization](https://github.com/ihhub/fheroes2/blob/master/src/engine/serialize.h): `src/engine/serialize.h`

### Media and assets

- [Audio playback](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/audio/audio_manager.cpp): `src/fheroes2/audio/audio_manager.cpp`
- [Game assets](https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/game/game_assets.cpp): `src/fheroes2/game/game_assets.cpp`

### Other components

- **Player**

## Connections

- Player → Toolset activity: opens
- Toolset activity → Installer extraction: validates installer (evidence: `android/app/src/main/java/org/fheroes2/ToolsetActivity.java`)
- Toolset activity → Asset validation: checks assets (evidence: `android/app/src/main/java/org/fheroes2/ToolsetActivity.java`)
- Toolset activity → Game activity: launches (evidence: `android/app/src/main/java/org/fheroes2/ToolsetActivity.java`)
- Toolset activity → Map management: opens (evidence: `android/app/src/main/java/org/fheroes2/ToolsetActivity.java`)
- Toolset activity → Save management: opens (evidence: `android/app/src/main/java/org/fheroes2/ToolsetActivity.java`)
- Map management → File operations: uses (evidence: `android/app/src/main/java/org/fheroes2/MapFileManagerActivity.java`)
- Save management → File operations: uses (evidence: `android/app/src/main/java/org/fheroes2/SaveFileManagerActivity.java`)
- Game activity → Game entry: starts
- Player → Game entry: plays (evidence: `README.md`)
- Game entry → Game flow: enters
- Game flow → Campaign flow: offers (evidence: `README.md`)
- Game flow → Maps and world: uses
- Maps and world → Kingdom and heroes: supports
- Maps and world → Battle system: supports
- Maps and world → Computer opponents: includes (evidence: `README.md`)
- Player → Map editor: edits maps
- Map editor → Editor history: records actions (evidence: `src/fheroes2/editor/history_manager.cpp`)
- Game flow → Image rendering: renders
- Game flow → Audio playback: plays audio
- Game flow → Game assets: loads assets
- Editor history → Serialization: serializes maps (evidence: `src/fheroes2/editor/history_manager.cpp`)
- Asset validation → ISO filesystem: reads ISO (evidence: `android/app/src/main/java/org/fheroes2/HoMM2AssetManagement.java`)
- ISO filesystem → ISO entries: creates entries (evidence: `android/isotools/src/main/java/com/github/stephenc/javaisotools/loopfs/iso9660/Iso9660VolumeDescriptorSet.java`)
