# openttd-china-set/china-set-trains architecture

> Architecture diagram of the GitHub repository openttd-china-set/china-set-trains, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openttd-china-set/china-set-trains
- Repository: https://github.com/openttd-china-set/china-set-trains

## Overview

##### Main System Components

a) Asset Pipeline
- Model Processing System
- VOX files (in /gfx directories)
- Rendering System (gorender/renderobject)
- Texture/Palette Management (ttd_palette.json files)

b) Game Integration Layer
- PNML Source Files (/src directory)
- Vehicle Definitions
- Cargo Systems
- Rail Types
- Functions/Templates

c) Build System
- Make-based compilation
- Configuration Management
- Output Generation

##### Component Relationships

**[VOX Models] -> [Renderer] -> [Processed Graphics]**
- ↓
**[PNML Sources] -> [NML Compiler] -> [Final GRF]**
- ↑
**[Configuration Files]**

##### Detailed Breakdown

Create subsections for each major vehicle category:
- Electric Locomotives (25-electric)
- EMU Units (25-emu)
- Diesel Locomotives
- Steam Locomotives
- Coaches
- Wagons

Each should show:
- Model Assets
- Configuration
- Implementation Files
- Variant Management

##### Key Technical Elements

Highlight:
- Build Dependencies (nml, gcc, make, gorender)
- Asset Processing Pipeline
- Configuration Parameters System
- Livery Management System
- Cargo Handling System

##### Implementation Details

Specific flows for:
- Model Rendering Process
- Vehicle Configuration
- Livery System
- Cargo System
- Build Process

##### Notes

Include:
- GPL v2 License Notice
- Required Dependencies
- Build Instructions
- Parameter System
- Contributors Section

This system design should help developers understand both the high-level architecture and the detailed implementation specifics of the China Set: Trains project.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Asset Pipeline"
        VOX["VOX Models"]:::asset
        PAL["Palette Management"]:::asset
        REND["Renderer"]:::processor
        PROC["Processed Graphics"]:::output
    end

    subgraph "Game Integration Layer"
        MAIN["Main Game File"]:::source
        VDEF["Vehicle Definitions"]:::source
        FUNC["Core Functions"]:::source
        TEMP["Templates"]:::source
        CARGO["Cargo System"]:::source
        RAIL["Rail Types"]:::source
    end

    subgraph "Vehicle Categories"
        direction TB
        ELEC["Electric Locomotives"]:::vehicle
        EMU["EMU Units"]:::vehicle
        DIES["Diesel Locomotives"]:::vehicle
        STEAM["Steam Locomotives"]:::vehicle
        COACH["Coaches"]:::vehicle
        WAG["Wagons"]:::vehicle
    end

    subgraph "Build System"
        MAKE["Make System"]:::build
        CONF["Configuration"]:::build
        GHA["GitHub Actions"]:::build
        OUT["Final GRF"]:::output
    end

    subgraph "Documentation"
        DOC["Documentation"]:::doc
        LOG["Change Log"]:::doc
        LIC["License"]:::doc
        CONT["Contributors"]:::doc
    end

    %% Relationships
    VOX --> REND
    PAL --> REND
    REND --> PROC
    PROC --> OUT
    
    MAIN --> OUT
    VDEF --> MAIN
    FUNC --> MAIN
    TEMP --> MAIN
    CARGO --> MAIN
    RAIL --> MAIN
    
    ELEC --> VDEF
    EMU --> VDEF
    DIES --> VDEF
    STEAM --> VDEF
    COACH --> VDEF
    WAG --> VDEF
    
    CONF --> MAKE
    MAKE --> OUT
    GHA --> MAKE

    %% Styles
    classDef asset fill:#3498db,stroke:#2980b9,color:white
    classDef processor fill:#e74c3c,stroke:#c0392b,color:white
    classDef source fill:#2ecc71,stroke:#27ae60,color:white
    classDef vehicle fill:#9b59b6,stroke:#8e44ad,color:white
    classDef build fill:#f1c40f,stroke:#f39c12,color:black
    classDef output fill:#e67e22,stroke:#d35400,color:white
    classDef doc fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Click Events
    click MAIN "https://github.com/openttd-china-set/china-set-trains/blob/main/chinasettrains.pnml"
    click FUNC "https://github.com/openttd-china-set/china-set-trains/blob/main/src/functions.pnml"
    click TEMP "https://github.com/openttd-china-set/china-set-trains/blob/main/src/template.pnml"
    click CARGO "https://github.com/openttd-china-set/china-set-trains/blob/main/src/cargotable.pnml"
    click RAIL "https://github.com/openttd-china-set/china-set-trains/blob/main/src/railtypetable.pnml"
    click ELEC "https://github.com/openttd-china-set/china-set-trains/tree/main/src/25-electric"
    click EMU "https://github.com/openttd-china-set/china-set-trains/tree/main/src/25-emu"
    click DIES "https://github.com/openttd-china-set/china-set-trains/tree/main/src/diesel"
    click STEAM "https://github.com/openttd-china-set/china-set-trains/tree/main/src/steam"
    click COACH "https://github.com/openttd-china-set/china-set-trains/tree/main/src/coaches"
    click WAG "https://github.com/openttd-china-set/china-set-trains/tree/main/src/wagons"
    click MAKE "https://github.com/openttd-china-set/china-set-trains/tree/main/Makefile"
    click CONF "https://github.com/openttd-china-set/china-set-trains/blob/main/Makefile.config"
    click GHA "https://github.com/openttd-china-set/china-set-trains/blob/main/.github/workflows/build.yml"
    click DOC "https://github.com/openttd-china-set/china-set-trains/tree/main/docs"
    click LOG "https://github.com/openttd-china-set/china-set-trains/blob/main/changelog.md"
    click LIC "https://github.com/openttd-china-set/china-set-trains/tree/main/LICENSE"
    click CONT "https://github.com/openttd-china-set/china-set-trains/blob/main/docs/contributor.csv"
    click VOX "https://github.com/openttd-china-set/china-set-trains/tree/main/gfx"
    click PAL "https://github.com/openttd-china-set/china-set-trains/tree/main/gfx"
```
