Master Controller & Subsystems
Relevant source files
The following files were used as context for generating this wiki page:
The Master Controller (MC) manages the execution of timed tasks and global events within the simulation. It coordinates specialized Subsystems responsible for discrete game functions such as atmospheric simulation, lighting updates, and game logic checks.
The MC utilizes anti-lag heuristics to maintain performance during periods of high player population or server drift. It executes these tasks by iterating through registered subsystems, ensuring that critical world processes remain synchronized with the server's tick rate.
Sources: config/config.txt:462-465, code/datums/ai/learn_ai.md:65
Architecture and Execution Flow
The Master Controller functions as the primary scheduling engine. It triggers the process() method on various subsystems and controllers. In high-load scenarios, the MC adjusts the tick rate to prioritize stability.
Execution Cycle
The simulation timing depends on the TICKLAG value, which defines the deciseconds between BYOND ticks. The MC operates at a base rate relative to these ticks.
The diagram illustrates the flow of the Master Controller during a standard game tick.
Sources: config/config.txt:302-304, config/config.txt:462-480, config/config.txt:488-490
Configuration Options
The Master Controller behavior is modified through several configuration flags that determine how it handles player load and performance metrics.
| Option | Type | Default | Description |
|---|---|---|---|
BASE_MC_TICK_RATE | Integer | 1 | Processes every X BYOND ticks. 0 disables the MC. |
HIGH_POP_MC_TICK_RATE | Float | 1.1 | Tick rate multiplier during high population modes. |
HIGH_POP_MC_MODE_AMOUNT | Integer | 65 | Player threshold to engage High Pop Mode. |
DRIFT_DUMP_THRESHOLD | Deciseconds | 40 | Threshold before dumping profiles due to lag. |
TICKLAG | Float | 0.5 | Amount of time between game ticks in 1/10ths of a second. |
Sources: config/config.txt:302, config/config.txt:466-483, config/config.txt:488-493
AI Controller Subsystem
The AI Controller manages entity behaviors through a Blackboard-driven Behavior Tree system. It translates high-level logic into executable actions for NPCs and computer-controlled entities.
Blackboard Memory
The Blackboard acts as the controller's shared memory, using an associative list of keys and values. Nodes read these keys to make decisions and write to them to share state with subsequent nodes.
Node Logic Types
- Leaf (ai_behavior): Performs concrete actions like moving, attacking, or using abilities.
- Decorator: Gates execution behind conditions (e.g., checking if a target exists).
- Composites: Structural nodes (Selector, Sequence, Parallel) that control child execution flow.
The diagram shows a simplified AI behavior selection flow managed by a controller.
Sources: code/datums/ai/learn_ai.md:15-45, code/datums/ai/learn_ai.md:79-110
Rendering and Plane Masters
The rendering subsystem organizes objects into "slates" called Plane Masters. This per-client system groups atoms based on their plane variable and an appearance flag containing PLANE_MASTER.
Relays and Render Targets
Subsystems can relay one plane onto another using the render_target variable.
- If
render_targetstarts with an asterisk (*), the source is not drawn to the client view directly, only relayed. - Relays allow for complex effects like masking one plane with another or applying color matrices to groups of objects.
Sources: tgui/packages/tgui/interfaces/PlaneMasterDebug/PlaneMenus.tsx:128-155
Specialized System Controllers
MODsuit Subsystem
The MODsuit system handles the initialization and processing of modular power armor. It manages themes, skins, and active modules.
- Theme: Defines base stats like
armor_type,complexity_max, andcharge_drain. - Modules: Datums attached to the suit that are processed by the suit's controller. Types include Passive, Togglable, Usable, and Active.
Sources: code/modules/mod/adding_new_mod.md:10-40, code/modules/mod/adding_new_mod.md:144-155
Malfunction Subsystem
Used specifically for Malfunction AI antagonists, this subsystem manages speech recognition for Syndicate codewords and diagnostic reporting of "system integrity."
Sources: tgui/packages/tgui/interfaces/AntagInfoMalf.tsx:44-55, tgui/packages/tgui/interfaces/AntagInfoMalf.tsx:125-140
Database Schema Versioning
The project maintains a schema_revision_220 table to track the version of the SQL database subsystem. Changes to the schema must be recorded by incrementing DB_MAJOR_VERSION_220 and DB_MINOR_VERSION_220.
-- Example update for the schema revision table
INSERT INTO `schema_revision_220` (`major`, `minor`) VALUES (1, 3);
Sources: SQL/bandastation/database_changelog.md:1-10
Summary
The Master Controller and its associated Subsystems provide the fundamental framework for simulation timing, AI decision-making, and graphical rendering. By utilizing configurable tick rates and specialized controllers for features like MODsuits and AI, the system ensures modularity and performance scalability across various server loads.