SupSuper’s open-source reimplementation of the original XCOM game engine, OpenXcom, is nearly complete! Check out the code at https://github.com/SupSuper/OpenXcom. Some notes for reading:
- There’s a simple build process with few external dependencies (just SDL and YAML).
- Several “make”-like systems are implemented in parallel. You can compare and contrast how CMake/autotools/XCode/MSVC look for the same code.
- The engine is somewhat modularized:
- “Basescape” for the base management GUI
- “Geoscape” for the world map
- “Battlescape” for tactical combat
- However, the headers aren’t organized clearly and there are some cross-includes between the different modules.
- Game data like item/tech states are parsed from YAML and accessed by a “Ruleset” library.
- The “Savegame” system is misleadingly named; it’s actually the container for all persistent player state.
- There are beautifully concise (1-page) implementations of A* and Dijkstra’s algorithm in Pathfinding.cpp
- Cringe at memory-management horrors like:
Craft::~Craft() { for (std::vector<CraftWeapon*>::iterator i = _weapons.begin(); i != _weapons.end(); ++i) { delete *i; } delete _items; for (std::vector<Vehicle*>::iterator i = _vehicles.begin(); i != _vehicles.end(); ++i) { delete *i; } }
(which translates to zero lines of code in modern RAAI C++)