|
VoltMod
C++23 framework for CS2 server plugins
|
Gamedata says where engine code and untyped fields live. The schema says where entity fields live. Both are resolved once and read from there.
| says where | source | checked | |
|---|---|---|---|
| gamedata/gamedata.jsonc | functions, globals, vtable slots, byte offsets | hand-maintained | by the host at startup, per entry |
| gamedata/schema/manifest.json | which entity fields get accessors | hand-maintained | offsets and sizes taken from the live schema at load |
The host reads addons/voltmod/gamedata/gamedata.jsonc and scans for every entry once, before any plugin loads. VoltMod::Bindings gives those locations C++ types:
Each plugin module calls Bindings::Bind before it builds the runtime, taking every member in one pass from a VoltMod::GameDataLookup over what the host already resolved. Services then hold const Bindings&, so no call path does a string lookup. No plugin reads the file or scans memory itself: a signature a game update broke costs one scan and one error line for the whole server.
Bindings::Failures lists key: reason for every member the last Bind left unbound.
Four sections, named for what they bind. A key is the engine's own name for the symbol, or Class::member, so it can be checked against upstream gamedata and against the binary. Each key belongs to exactly one section.
Wildcard bytes are ? or ??. A class name is the top-level RTTI name, with no namespace or template. An offset entry is either per-platform numbers or a class + base pair read from RTTI at load, never both.
A script entry has no platform columns. The host reads class's VScript description, searches its bindings and then its bases' for the name, and takes the function, or for a vtable entry the slot the binding dispatches through. A VScript binding can vanish in an update, so use one only where the binding calls the engine function itself.
A vtables entry with neither platform columns nor script binds a ClassTable: the class table alone. Use it where the SDK declares the virtual. HookTable takes the slot from that declaration, so a game update needs no index check for it.
gamedata.schema.json in the framework repository has additionalProperties: false everywhere, and the file's $schema loads it from GitHub, so an editor flags a typo before the server sees it. Only gamedata.jsonc ships; the schema is never copied to a server or into the package.
The file is read strictly: an unknown key, a wrong value type, or a section that is not an object rejects the whole file, and the host then has nothing to serve.
Otherwise every entry is resolved and each failure is logged once with its reason:
Each plugin's GameData load check then lists the failures touching its own members, and each feature reports its own through Available().
A pattern is validated by matching exactly once. A vtable index or a byte offset cannot be validated that way, so when build.server does not match the running server the load warns that those columns are unchecked on this build. The log records each vtable slot's code as key=module+offset, to match a crash dump against a binding.
When every entry resolves, the host writes addons/voltmod/gamedata/dumps/resolved.json: the server build, module-relative addresses for functions, globals and class tables, plus slot indices and offsets. It is written once per server build, and a failed write does not fail the load. Keep the record from a known-good build to diff against after an update.
Schema offsets need no gamedata. voltmod framework schemagen generates typed accessors, and each module (the host and every plugin) fills their offsets from the live schema once, when it loads:
schemagen reads gamedata/schema/manifest.json plus a dump and writes include/VoltMod/Schema/Generated/ and src/Schema/Generated/. The dump comes from the engine's network serializers, which exist only while a map runs, so the host writes addons/voltmod/gamedata/dumps/schema.json at map start and skips the write when the file on disk already carries the running game build.
The generated sources hold no offsets, so they are the same from a Windows or a Linux dump. --platform only picks which committed baseline, gamedata/schema/server.<platform>.json, the dump refreshes; gamedata check --fix reads it to name struct offsets. Re-rendering from a baseline needs no server:
Field access on a wrapper is what Entities and players describes.
src/Schema/Generated/Layout.cpp lists every field the accessors use, with the size the dump gave it. At load each module looks every field up by name in the live schema, takes its offset, and compares its size. A struct embedded by value has no size check, because its size differs per platform and its own fields are listed. A moved field passes. A field that is gone or resized fails the load, naming each one:
The host logs the same check for its own copy as Schema: every generated field found on game build <n>.
voltmod doctor --server <dir> says when the server is behind Steam, and when gamedata was checked on another build than the server runs. voltmod serve puts back the VoltMod line an update removes from gameinfo.gi.
A moved schema field needs nothing. Only when the load names a gone or resized field: let a map load so the host writes the dump, run voltmod framework schemagen, review the git diff of the generated code, fix what used the field, rebuild.
Gamedata is repaired separately, and offline:
check takes --game-dir (default CS2_SERVER_PATH) and --platform. The platform otherwise follows whichever binaries that directory holds.
What --fix will and will not do:
Common drift points:
| Entry | Section | Used by | Drift symptom |
|---|---|---|---|
| CPlayer_MovementServices::RunCommand | vtables | VoltMod::Movement | Crash on the first movement tick, unless the slot check catches it |
| CBaseEntity::Teleport | vtables | VoltMod::Teleport | Subscribing to Teleported is refused; Teleport::Available says why |
| CServerSideClient | vtables (table only) | VoltMod::ClientConVars, addon downloads | Missing: ClientConVars::Available fails and addons are not sent |
| CServerSideClient::INetworkMessageProcessingPreFilter | vtables (table only, base) | VoltMod::ScreenManager | Missing: presses never arrive |
| CUserCmd::CSGOUserCmdPB | offsets | VoltMod::Movement | Missing: Valid=false. Stale: garbage viewangles and buttons |
| CUserCmdBase::cmdNum | offsets | PlayerInput::CommandNumber | Missing: falls back to legacy_command_number, which live clients leave at 0 |
| CBaseEntity::SubclassVData | offsets | Entity::FindWeaponData | Missing: always empty. Stale: garbage weapon data, or a crash reading it; check that BaseName matches ClassName() for stock weapons |
| CNetworkGameServer::ReplyConnection | functions | VoltMod::MultiAddonManager | Add logs the reason in the host and requires nothing |
| CSource2Server::g_GameEventManager | globals | VoltMod::GameEvents | Events do not fire and center HTML does not display |
The host finds a class vtable by RTTI on Windows and by _ZTV symbol - falling back to the mapped module's Itanium RTTI - on Linux. A class name must therefore be the top-level RTTI name exactly; a nested or namespaced name resolves to nothing and the entry does not bind.