Reverse-engineered source for Cube World's client (Cube.exe) and dedicated server (Server.exe),
from the 2013 Alpha build with the paraglider fix. Both are 32-bit MSVC 2012 C++ binaries with RTTI
and no PDB. Function bodies come from Ghidra 12.1.2.
The goal is the game's real class and file layout with faithful function bodies. It does not compile yet, and it is not the original source: optimized MSVC output with whole-program optimization cannot be turned back into the exact code that was written.
cube/ is the client and server/ is the server. Both have:
world/ World, Zone, Region, Dungeon, House, Spawn, Field (client also has Chunk, WorldMap, ...)
entity/ Creature, Sprite, SpriteManager, Speech, QuestText
ai/ Behavior tree: Combat, Companion, RandomWalk, WalkPath, and others
db/ Database (SQLite glue)
game_misc/ game functions with no single owning class
_library/ statically linked SQLite, CRT/STL and FreeType, set aside
include/ cube_types.h: recovered structs plus verified game struct offsets
The client also has ui/, render/, audio/ and control/. The server also has net/.
Each binary folder has two index files:
attribution.tsv: every function's address, name, kind (game, gamemisc or lib) and class.GAP_ANALYSIS.md: a best-guess name, purpose and confidence for functions still namedFUN_<addr>.
- Every function starts with
/* <name> @ <addr> */, so you can jump to it in the binary. - Virtual methods are
Class::vfunc_Nand constructors areClass::ctor_N. - Member functions take a real
this. Field accesses read*(int *)(this + 0x140), which is the byte offset into the object. Offsets confirmed by other evidence are named ininclude/cube_types.h. - Skip
_library/unless you care about SQLite or the C runtime.
- RTTI vtables seed each
cube::class with its virtual methods and constructors. - Library code is detected by its strings and names, followed through the call graph, and moved
to
_library/. - An unnamed function called mostly by one class goes to that class.
- Remaining game-reachable code goes to
game_misc/.
Ghidra's first pass over the client made the same mistakes in thousands of functions. Each fix went into the Ghidra database and every function was decompiled again, so no body is patched by hand:
- Calling conventions: about 2,500 member functions were not marked
__thiscall, sothisshowed up as an uninitialized variable and callers dropped or shifted arguments. - Prototypes: a callee-cleanup function's parameter list is locked once it matches the function's
ret ninstruction, so callers stop inventing arguments from leftover stack values. - Return values: when callers read
EAX,EDX:EAX,ALorST0after a call, the callee now returns that value instead of it appearing asextraout_. - Register arguments: functions that read
EAXorEDXat entry take them as parameters. - Floats and math: single-precision code is typed
floatinstead ofdouble, and results of the SSE math imports (cos,powand so on) are no longer dropped.
Of the 1,683 client game functions, 92.5% now decompile with no leftover register artifacts
(in_, unaff_, extraout_), up from about 30%. The rest are mostly x87 float returns and
whole-program-optimized functions that pass values in ESI/EDI; they need manual work.
Names are the weak part. Most game functions are still FUN_<addr>, and only a few dozen struct
fields are verified. A function gets a name only once its behavior is confirmed.
| Cube.exe | Server.exe | |
|---|---|---|
| Functions | 12,983 | 6,152 |
| Decompiled | 12,983 | 6,151 |
| Game code (class plus game_misc) | 1,683 | 369 |
| Library | 11,300 | 5,783 |
cube:: classes |
55 | 25 |
23 classes are shared by both binaries: World, Zone, Region, Creature, Database, the Behavior AI tree and others.
The binary still contains its build path, C:\Users\funck\Projects\Cube\OptimizedXP\Cube.pdb, and
the string Wollay. Engine code lives in plasma:: (about 95 classes: Widget, Engine, Font,
D3D9Engine and more), whose object format is the .plx files. abstr:: is a small reflection
layer. SQLite 3.7.15.2 is linked in. zlib 1.2.3, FreeImage, XAudio2 and the MSVC 2012 runtime are
separate DLLs. The data*.db files are SQLite blob stores keyed by asset name.
Cube World and all of its code, assets, names and trademarks belong to Picroma and Wollay (Wolfram von Funck). This is an unofficial fan project for education and interoperability research. It ships no game binaries or data files, only source reconstructed by static analysis. It is not affiliated with or endorsed by Picroma or Wollay. If you hold rights to Cube World and want something changed or removed, open an issue.
You need a legitimate copy of Cube World to use anything here.