# daynz/gtavicecity architecture

> Architecture diagram of the GitHub repository daynz/gtavicecity, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/daynz/gtavicecity
- Repository: https://github.com/daynz/gtavicecity

## Overview

##### Project type and purpose
- This is a reverse-engineered reimplementation of the GTA III/VC game engine (“re3”).
- It’s a full game engine: it loads original GTA assets (models, textures, scripts), runs game logic, physics, AI, rendering and audio, and produces a playable executable on multiple platforms (Windows, Linux, macOS, FreeBSD, consoles).

##### File structure
- Top-level: build tooling (CMakeLists.txt, premake5.lua, conanfile.py), configuration (.clang-format, CODING_STYLE.md), scripts, .github CI workflows.
- src/: all engine code, organized into subsystems (core, renderer, audio, collision, control/AI, animation, math, entities, modelinfo, objects, peds, vehicles, weapons, save, text, skel/platform, extras).
- gamefiles/: read-only data (textures, models, scripts) that the engine loads at runtime.
- res/: logos and splash images.
- utils/: helper tools (e.g., GXT text packer).
- vendor/, codewarrior/, autoconf/, cmake/: build system/integration files for various toolchains and platforms.

##### README for additional insights
- Two rendering backends: original RenderWare D3D8 or homebrew librw (D3D9, OpenGL, OpenGL ES).
- Audio backends: Microsoft MSS (via original DLLs) or OpenAL.
- Cross-platform skeleton layer (“skel”) abstracts windowing, input and platform specifics.
- Uses premake or CMake+Conan for building on multiple platforms/architectures.

##### Elements
- Blue = core subsystems (Collision, Animation, AI),
- Green = I/O (Resource Manager, Save/Load, Scripting),
- Orange = rendering/audio backends,
- Gray = platform abstraction.

##### Detail
- Break out major subsystems rather than lumping them; show Renderer split into “geometry submission”, “shader postfx (extras)”, “screen buffer”.
- Audio split into “collision sounds”, “music”, “radio”, “voice”.
- That Build System targets multiple platforms with different toolchains but same source tree.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Platform Abstraction
    subgraph "Platform Abstraction"
        Skel["Platform Abstraction (Skel)"]:::platform
    end
    click Skel "https://github.com/daynz/gtavicecity/tree/master/src/skel/"

    %% Resource Manager / File Loader
    subgraph "Resource Manager / File Loader"
        FL["FileLoader.cpp / .h"]:::io
        FM["FileMgr.cpp / .h"]:::io
        ST["Streaming.cpp / .h"]:::io
        CD["CdStream.cpp / .h"]:::io
    end
    click FL "https://github.com/daynz/gtavicecity/blob/master/src/core/FileLoader.cpp"
    click FM "https://github.com/daynz/gtavicecity/blob/master/src/core/FileMgr.cpp"
    click ST "https://github.com/daynz/gtavicecity/blob/master/src/core/Streaming.cpp"
    click CD "https://github.com/daynz/gtavicecity/blob/master/src/core/CdStream.cpp"

    %% Core Game Loop
    subgraph "Core Game Loop"
        Main["main.cpp"]:::core
        Game["Game.cpp / .h"]:::core
        Re3["re3.cpp"]:::core
    end
    click Main "https://github.com/daynz/gtavicecity/blob/master/src/core/main.cpp"
    click Game "https://github.com/daynz/gtavicecity/blob/master/src/core/Game.cpp"
    click Re3 "https://github.com/daynz/gtavicecity/blob/master/src/core/re3.cpp"

    %% Core Subsystems
    subgraph "Core Subsystems"
        Collision["Collision & Physics"]:::subsys
        Animation["Animation"]:::subsys
        AI["AI & Control"]:::subsys
        Entities["Entities & Object Management"]:::subsys
        Vehicles["Vehicles"]:::subsys
        Peds["Peds"]:::subsys
        Weapons["Weapons"]:::subsys
    end
    click Collision "https://github.com/daynz/gtavicecity/tree/master/src/collision/"
    click Animation "https://github.com/daynz/gtavicecity/tree/master/src/animation/"
    click AI "https://github.com/daynz/gtavicecity/tree/master/src/control/"
    click Entities "https://github.com/daynz/gtavicecity/tree/master/src/entities/"
    click Vehicles "https://github.com/daynz/gtavicecity/tree/master/src/vehicles/"
    click Peds "https://github.com/daynz/gtavicecity/tree/master/src/peds/"
    click Weapons "https://github.com/daynz/gtavicecity/tree/master/src/weapons/"

    %% Rendering Backends
    subgraph "Rendering"
        Renderer["Renderer"]:::backend
        Librw["librw (D3D9/OpenGL)"]:::backend
        Fakerw["RenderWare D3D8"]:::backend
    end
    click Renderer "https://github.com/daynz/gtavicecity/tree/master/src/renderer/"
    click Librw "https://github.com/daynz/gtavicecity/tree/master/src/rw/"
    click Fakerw "https://github.com/daynz/gtavicecity/tree/master/src/fakerw/"

    %% Audio
    Audio["Audio"]:::backend
    click Audio "https://github.com/daynz/gtavicecity/tree/master/src/audio/"

    %% Scripting Engine
    Scripting["Scripting Engine"]:::io
    click Scripting "https://github.com/daynz/gtavicecity/blob/master/src/control/Script.cpp"

    %% Save/Load
    SaveLoad["Save/Load"]:::io
    click SaveLoad "https://github.com/daynz/gtavicecity/tree/master/src/save/"

    %% UI/HUD/Menu
    subgraph "UI / HUD / Menu"
        Frontend["Frontend/UI"]:::io
        MenuScreens["Menu Screens"]:::io
        HUD["HUD"]:::backend
    end
    click Frontend "https://github.com/daynz/gtavicecity/blob/master/src/core/Frontend.cpp"
    click MenuScreens "https://github.com/daynz/gtavicecity/blob/master/src/core/MenuScreens.cpp"
    click HUD "https://github.com/daynz/gtavicecity/blob/master/src/renderer/Hud.cpp"

    %% Gamefiles Data Store
    Gamefiles["Gamefiles (DFF, TXD, SCM, GXT)"]:::db

    %% Build System
    subgraph "Build System"
        CMake["CMakeLists.txt"]:::build
        CMakeDir["cmake/"]:::build
        Premake["premake5.lua"]:::build
        Conan["conanfile.py"]:::build
        Autoconf["autoconf/"]:::build
        CW["codewarrior/"]:::build
    end
    click CMake "https://github.com/daynz/gtavicecity/blob/master/CMakeLists.txt"
    click CMakeDir "https://github.com/daynz/gtavicecity/tree/master/cmake/"
    click Premake "https://github.com/daynz/gtavicecity/blob/master/premake5.lua"
    click Conan "https://github.com/daynz/gtavicecity/blob/master/conanfile.py"
    click Autoconf "https://github.com/daynz/gtavicecity/tree/master/autoconf/"
    click CW "https://github.com/daynz/gtavicecity/tree/master/codewarrior/"

    %% Relationships
    Skel --> Main
    Main --> FL
    Main --> Collision
    Main --> Animation
    Main --> AI
    Main --> Entities
    Main --> Vehicles
    Main --> Peds
    Main --> Weapons
    Main --> Renderer
    Main --> Audio
    Main --> Scripting
    Main --> SaveLoad
    Main --> Frontend
    Main --> MenuScreens
    Main --> HUD

    FL --> Collision
    FL --> Animation
    FL --> AI
    FL --> Entities
    FL --> Renderer
    FL --> Scripting

    Gamefiles --> FL
    Gamefiles --> Renderer
    Gamefiles --> Scripting

    Collision --> Animation
    Animation --> AI
    AI --> Entities
    Entities --> Vehicles
    Entities --> Peds
    Entities --> Weapons
    AI --> Audio
    AI --> SaveLoad
    AI --> Scripting

    Renderer --> Librw
    Renderer --> Fakerw

    %% Build System integration
    CMake --> Main
    Premake --> Main
    Conan --> Main
    Autoconf --> Main
    CW --> Main

    %% Styles
    classDef platform fill:#dddddd,stroke:#333,stroke-width:1px
    classDef io fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef core fill:#add8e6,stroke:#333,stroke-width:1px
    classDef subsys fill:#add8e6,stroke:#333,stroke-width:1px
    classDef backend fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef db fill:#ddccff,stroke:#333,stroke-width:1px
    classDef build fill:#eeeeee,stroke:#333,stroke-width:1px
```
