TeamVanilla Workshop

CFireSDK

CFireSDK is a header-only C++ library for reading CrossFire's file formats: .rez archives, LithTech models, textures, maps, sounds and the string table.

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:

ReaderReadsChecked against retail
RezArchive.rez container: directory tree, resource entries, type codesFull directory walk of retail archives
LtbModelLithTech model files: meshes, LODs, skeleton, materialsGeometry and bone counts verified
DtxTextureTexture containers: codec, mip chains, dimensionsMip levels and pixel formats confirmed
WorldBspMap BSP: geometry, light maps, prop placement, collisionVertex and poly counts matched
SndEntrySound entries: codec, sample rate, channels, durationPlayback verified against client output
StringTableThe 45,089-message string table: key lookup and iterationEvery 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.