Category:LoadContext
Load Context
The relationship is:
Global DB state
├── Zone registry
│ ├── patch_mp -> its own XZoneMemory
│ ├── common_mp -> its own XZoneMemory
│ ├── ui_mp -> its own XZoneMemory
│ ├── mp_boneyard_load -> its own XZoneMemory
│ └── mp_boneyard -> its own XZoneMemory
├── Current stream state
│ └── points at one zone's XZoneMemory while that zone is loading
└── Global XAsset registry
└── shared by assets from every loaded zone- XZoneMemory is per zone.
- Dependencies do not combine their blocks into one XZoneMemory.
- The global XAsset registry spans all loaded zones.
- Each XAssetEntry records its owning zoneIndex.
- Asset overrides and deduplication happen through the shared registry.
- Unloading a zone frees that zone’s XZoneMemory and removes or reveals its registry entries as appropriate.
Conceptually:
void DB_LoadZone(XZone *zone, DBFile *file)
{
DB_AllocXZoneMemory(file->blockSizes, &zone->memory);
DB_InitStreams(&zone->memory);
// The global stream state now points into this zone's seven blocks.
DB_LoadXFile(&zone->memory, file);
// Loaded assets are registered into the shared global XAsset registry.
DB_PostLoadXZone(zone);
}XZone
The encompassing live zone record appears shaped like:
typedef struct XZone
{
uint32_t zoneId; // 0x00
uint32_t unknown04; // 0x04
char name[64]; // 0x08
uint32_t unknown48; // 0x48
uint32_t zoneFlags; // 0x4C
uint32_t unknown50; // 0x50
XZoneMemory memory; // 0x54
} XZone;XZoneMemory
XZoneMemory is the memory-block allocation for one loaded zone/fastfile. It is only one component of the engine’s broader database loading state.
typedef enum XFileBlockType
{
XFILE_BLOCK_TEMP = 0,
XFILE_BLOCK_PHYSICAL = 1,
XFILE_BLOCK_RUNTIME = 2,
XFILE_BLOCK_VIRTUAL = 3,
XFILE_BLOCK_LARGE = 4,
XFILE_BLOCK_CALLBACK = 5,
XFILE_BLOCK_VERTEX = 6,
XFILE_BLOCK_COUNT = 7
} XFileBlockType;
typedef struct XZoneMemoryBlock
{
void* address; // Live address; null when size is zero
uint32_t size; // Declared allocation size
} XZoneMemoryBlock;
typedef struct XZoneMemory
{
XZoneMemoryBlock blocks[XFILE_BLOCK_COUNT];
} XZoneMemory;XAssetEntry
The engines load context keeps a record of semantic asset names to it's place in memory. The engine more or less does this:
typedef struct XAssetEntry
{
uint32_t assetType; // 0x00: XAssetType
uint32_t headerPointer; // 0x04: canonical asset-header pointer
uint8_t zoneIndex; // 0x08: owning zone-record index
uint8_t flags09; // 0x09: bit 0 is tested by registry logic
uint8_t state0A; // 0x0A: initialized to zero; meaning OPEN
uint8_t pad0B; // 0x0B: no semantics proven
uint16_t nextHashIndex; // 0x0C: next entry in the name-hash chain
uint16_t nextOverrideIndex; // 0x0E: override/replacement chain
} XAssetEntry;This category currently contains no pages or media.