Project Structure
The OpenRCT2 source code is organized into the following main components:Core Engine (openrct2/)
The core engine contains the main game logic and is organized into the following modules:
Actions
Location:src/openrct2/actions/
Handles all player actions in the game using a command pattern. Actions are used for:
- Ride construction and modification
- Park management operations
- Guest and staff interactions
- Terrain modification
Audio
Location:src/openrct2/audio/
Manages sound effects and music playback:
- Audio mixer and channels
- Music track management
- Sound effect triggering
- Audio device abstraction
Command Line
Location:src/openrct2/command_line/
Provides command-line interface functionality for:
- Headless server operation
- Asset conversion utilities
- Screenshot generation
- Benchmarking tools
Configuration
Location:src/openrct2/config/
Handles game configuration and settings:
- User preferences
- Graphics settings
- Audio settings
- Keyboard shortcuts
Core
Location:src/openrct2/core/
Provides fundamental utilities and data structures:
- String manipulation
- File I/O operations
- Memory management
- Data structures (collections, containers)
- Cryptographic functions
The core module includes utilities like
String.hpp for UTF-8 string handling and file system abstractions for cross-platform compatibility.Drawing
Location:src/openrct2/drawing/
Handles 2D rendering and drawing operations:
- Sprite rendering
- Text rendering
- Image manipulation
- Drawing surfaces and contexts
Entity
Location:src/openrct2/entity/
Manages dynamic game entities:
- Guests (peeps)
- Staff members
- Vehicles
- Ducks and other effects
Interface
Location:src/openrct2/interface/
Provides the game’s windowing system and UI framework:
- Window management
- Widget system
- Input handling
- Viewport management
Localisation
Location:src/openrct2/localisation/
Handles translation and localization:
- String table management
- Language loading
- String ID definitions (
StringIds.h) - Date and currency formatting
Network
Location:src/openrct2/network/
Implements multiplayer functionality:
- Client-server architecture
- Network synchronization
- Player management
- Chat system
Object
Location:src/openrct2/object/
Manages game objects (rides, scenery, etc.):
- Object loading and parsing
- Object repositories
- Custom object support
- DAT file parsing
Paint
Location:src/openrct2/paint/
Handles 3D rendering and painting:
- Isometric rendering
- Ride rendering
- Scenery rendering
- Paint session management
The paint system is one of the most complex parts of OpenRCT2, responsible for converting 3D game world data into 2D isometric sprites.
Park
Location:src/openrct2/park/
Manages park-level data and operations:
- Park rating and awards
- Entrance management
- Park statistics
- Research and development
Peep
Location:src/openrct2/peep/
Implements guest and staff AI:
- Guest behavior and pathfinding
- Staff AI and tasks
- Thought generation
- Peep spawning
Platform
Location:src/openrct2/platform/
Provides platform-specific abstractions:
- File system operations
- Window management
- Clipboard access
- Platform detection
RCT1/RCT2 Compatibility
Locations:src/openrct2/rct1/src/openrct2/rct2/src/openrct2/rct12/
- Save game loading (SV4/SV6)
- Scenario import
- Data conversion
- Track design import
Ride
Location:src/openrct2/ride/
Manages ride logic and mechanics:
- Ride types and definitions
- Station management
- Vehicle physics
- Track construction
- Ride ratings calculation
Scenario
Location:src/openrct2/scenario/
Handles scenario and park management:
- Scenario objectives
- Park initialization
- Scenario editor
Scripting
Location:src/openrct2/scripting/
Provides plugin scripting API:
- JavaScript plugin support (Duktape)
- Script engine management
- Hook system for game events
- API bindings for game functions
UI
Location:src/openrct2/ui/
Provides UI abstraction layer:
- UI context management
- Window system interface
- Input management
Utility
Location:src/openrct2/util/
Provides various utility functions:
- Math utilities
- Compression utilities
- Encoding/decoding
UI Layer (openrct2-ui/)
The UI layer is built on SDL and provides the window system for the game. It includes:
- Windows: All game windows (ride windows, guest windows, park management, etc.)
- Cursor handling: Custom cursor rendering and repository
- Text input: Text composition and input handling
- Platform integration: Platform-specific UI code (Linux, Windows, Android)
The UI layer is separated from the core engine to allow for potential alternative UI implementations in the future.
Third-Party Libraries
Location:src/thirdparty/
OpenRCT2 includes several third-party libraries:
Duktape
JavaScript engine for plugin scripting
dukglue
C++ binding library for Duktape
SFL
Small Fast Library - container implementations
linenoise
Command-line editing library
Data Flow
The typical data flow in OpenRCT2 follows this pattern:Game Loop
- Input Processing: User input is captured by the UI layer
- Action Execution: Input is converted to actions and validated
- State Update: Game state is updated based on actions
- AI Processing: Guest and staff AI logic executes
- Rendering: Paint system renders the updated state
- Audio: Sound effects and music are played
Key Design Patterns
Command Pattern
All game-modifying operations use the command/action pattern for:- Network synchronization in multiplayer
- Undo/redo functionality (future)
- Validation and error handling
Entity-Component System
Entities (guests, staff, vehicles) use a component-based approach for flexible behavior composition.Paint Sessions
Rendering uses paint sessions to collect and sort draw calls before rendering, allowing for proper depth sorting in isometric view.Building Blocks
Tile Elements
The game world is composed of tiles, each containing multiple tile elements:- Surface elements (terrain)
- Path elements
- Track elements
- Scenery elements
- Entrance elements
- Walls
- Banners
Further Reading
Contributing Guide
Learn how to contribute code to OpenRCT2
Save Format
Understanding the save file format
Plugin API
Scripting API documentation
Coding Style
Code style guidelines

