Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.
qad3nPublic archive

About

A highly accurate decompiled source code for Cube World Alpha.

Topics

Resources

Stars

12 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Cube World Reconstructed Source

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.

Layout

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 named FUN_<addr>.

Reading it

  • Every function starts with /* <name> @ <addr> */, so you can jump to it in the binary.
  • Virtual methods are Class::vfunc_N and constructors are Class::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 in include/cube_types.h.
  • Skip _library/ unless you care about SQLite or the C runtime.

How functions were sorted

  1. RTTI vtables seed each cube:: class with its virtual methods and constructors.
  2. Library code is detected by its strings and names, followed through the call graph, and moved to _library/.
  3. An unnamed function called mostly by one class goes to that class.
  4. Remaining game-reachable code goes to game_misc/.

Accuracy

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, so this showed 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 n instruction, so callers stop inventing arguments from leftover stack values.
  • Return values: when callers read EAX, EDX:EAX, AL or ST0 after a call, the callee now returns that value instead of it appearing as extraout_.
  • Register arguments: functions that read EAX or EDX at entry take them as parameters.
  • Floats and math: single-precision code is typed float instead of double, and results of the SSE math imports (cos, pow and 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.

Numbers

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.

Provenance

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.

Legal

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.

About

A highly accurate decompiled source code for Cube World Alpha.

Topics

Resources

Stars

12 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages