OpenClaw API Reference

Reference • Updated 2026

This page documents the major subsystems of the OpenClaw engine. It is a starting point for engine contributors and modders who need to understand the code that powers the game.

High-level architecture

+-------------------------------------+
|           Application               |
+-------------------------------------+
|  Renderer  |  Audio  |  Network     |
+-------------------------------------+
|        Game Logic / Simulation      |
+-------------------------------------+
|     INI Loader / MIX Archive        |
+-------------------------------------+

Core namespaces

NamespacePurpose
oc::coreApplication bootstrap, logging, math types
oc::renderSprites, tiles, palette, blitters
oc::audioSample playback, mixer, streaming music
oc::netLockstep networking, packet framing
oc::gameUnits, structures, AI, mission scripting
oc::ioMIX archive reader, INI parser, file I/O
Advertisement

INI Parser (oc::io::IniFile)

The INI parser is a fast, zero-copy reader that maps sections and keys to a backing std::string_view.

namespace oc::io {
class IniFile {
public:
    bool load(const std::filesystem::path& path);
    std::string_view get(std::string_view section,
                         std::string_view key,
                         std::string_view defaultValue = {}) const;
    bool contains(std::string_view section,
                  std::string_view key) const;
};
}

Example:

oc::io::IniFile rules;
rules.load("rules.ini");
auto strength = rules.get("ROBO_TANK", "Strength", "100");

Renderer

The renderer is built around a tile-based isometric viewport with sprite-on-tile overlays.

oc::render::Renderer

class Renderer {
public:
    void initialize(SDL_Window* window);
    void setViewport(int width, int height);
    void drawTile(int x, int y, TileId tile);
    void drawSprite(SpriteHandle sprite, Vec2 screenPos);
    void present(); // swaps the back buffer
};

Sprites

Sprites are loaded from .shp files. The engine supports indexed-color palettes with up to 256 colors.

Audio

oc::audio::Mixer mixes up to 16 simultaneous sound effects plus one streaming music track.

Networking

OpenClaw uses deterministic lockstep over UDP. Each game tick produces a 16-byte command packet; the server reconciles and rebroadcasts.

FieldSizeDescription
Magic20xCAFE
Version1Protocol version
Tick4Simulation tick number
PlayerId1Originating player
CommandCount1Number of commands in this packet
Commandsvar.Variable-length command stream

Game logic

The simulation is a fixed-tick, deterministic game loop driven by oc::game::World.

Adding a new unit type

  1. Subclass oc::game::Unit and override tick(), onOrder().
  2. Register the type with oc::game::UnitFactory::instance().registerType<MyUnit>("MY_UNIT").
  3. Add the matching stanza in rules.ini.

Where to go next