OpenClaw API Reference
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
| Namespace | Purpose |
|---|---|
oc::core | Application bootstrap, logging, math types |
oc::render | Sprites, tiles, palette, blitters |
oc::audio | Sample playback, mixer, streaming music |
oc::net | Lockstep networking, packet framing |
oc::game | Units, structures, AI, mission scripting |
oc::io | MIX archive reader, INI parser, file I/O |
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.
| Field | Size | Description |
|---|---|---|
| Magic | 2 | 0xCAFE |
| Version | 1 | Protocol version |
| Tick | 4 | Simulation tick number |
| PlayerId | 1 | Originating player |
| CommandCount | 1 | Number of commands in this packet |
| Commands | var. | 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
- Subclass
oc::game::Unitand overridetick(),onOrder(). - Register the type with
oc::game::UnitFactory::instance().registerType<MyUnit>("MY_UNIT"). - Add the matching stanza in
rules.ini.
Where to go next
- Browse the full doxygen docs on GitHub.
- Try the Advanced Tutorials for hands-on examples.
- Ask questions in the community.