CFireSDK is a header-only C++ library for reading CrossFire's file formats. It is the same code the OpenCF asset viewer is built on, pulled out into a standalone SDK so you can open .rez archives and parse the assets inside them from your own program. Every reader was checked against the retail files.
#include <cfiresdk/cfiresdk.hpp>
using namespace cfiresdk;
Result<RezArchive> rez = RezArchive::open("crossfire.rez");
if (rez)
for (auto& entry : rez->entries())
process(entry.path(), rez->read(entry));
The format readers
Plain C++ with no dependencies beyond the standard library. Each reader was verified against the retail CrossFire archives:
| Reader | Reads | Checked against retail |
|---|---|---|
RezArchive | .rez container: directory tree, resource entries, type codes | Full directory walk of retail archives |
LtbModel | LithTech model files: meshes, LODs, skeleton, materials | Geometry and bone counts verified |
DtxTexture | Texture containers: codec, mip chains, dimensions | Mip levels and pixel formats confirmed |
WorldBsp | Map BSP: geometry, light maps, prop placement, collision | Vertex and poly counts matched |
SndEntry | Sound entries: codec, sample rate, channels, duration | Playback verified against client output |
StringTable | The 45,089-message string table: key lookup and iteration | Every key round-trips through hash lookup |
#include <cfiresdk/ltb.hpp>
using namespace cfiresdk;
Result<LtbModel> model = LtbModel::parse(bytes);
if (model)
for (auto& mesh : model->meshes())
draw(mesh.vertices(), mesh.indices());
Design
The library is header-only: add the include/ directory to your include path and you are done. Everything that can fail returns Result<T>; nothing throws. Archives are read through memory-mapped views by default, so only the pages you touch are loaded from disk.
The format knowledge behind each reader comes from CFEncyclopedia. The two are kept in sync: a correction in the book updates the SDK, and a finding in the SDK feeds back into the book.