Initial gamelib integration AAS2 with some animation and physics and another integration pass on idLib.

This commit is contained in:
Justin Marshall
2026-08-09 03:52:45 -07:00
parent cdf7d52214
commit 6d92a71d19
111 changed files with 15204 additions and 2275 deletions
+67
View File
@@ -0,0 +1,67 @@
#include "framework/resource.h"
#include "framework/resourcelist.h"
#include "idlib/lib_print.h"
#include "idlib/text/str.h"
idResource::idResource()
: trackedMemory(0), name("unnamed"), nextOnHashChain(nullptr),
resourceListPtr(nullptr), resourceError(nullptr), networkID(-1),
staleCount(0), resourceFlags(0), pad{} {
}
idResource::~idResource() {
if ((resourceFlags & 0x40u) != 0) {
idLibPrint::FatalError("Resource deleted with staticResource set: %s",
name.c_str());
}
if (resourceListPtr != nullptr) {
resourceListPtr->Remove(this);
}
idResourceList::UnRegisterNetworkResource(this);
}
void idResource::LoadResource() {
const idResourceList* const list = GetResourceList();
idLibPrint::FatalError("idResource::Load() for %s not implemented.\n",
list != nullptr ? list->GetResourceTypeName() : "resource");
}
bool idResource::ReloadIfStale() {
return false;
}
void idResource::WriteResourceFile() {
const idResourceList* const list = GetResourceList();
idLibPrint::FatalError(
"resource type '%s' has not implemented WriteResourceFile()",
list != nullptr ? list->GetResourceTypeName() : "resource");
}
idResourceList* idResource::GetResourceList() {
return resourceListPtr;
}
void idResource::Print() {
const idResourceList* const list = GetResourceList();
const char* const typeName =
list != nullptr ? list->GetResourceTypeName() : "resource";
if (resourceError != nullptr) {
idLibPrint::Printf("%s:%s:%s\n", typeName, name.c_str(),
resourceError);
} else {
idLibPrint::Printf("%s:%s\n", typeName, name.c_str());
}
}
void idResource::List() {
Print();
}
void idResource::SetName(const char* const newName) {
idStr canonicalName(newName);
canonicalName.MakeNameCanonical();
if (idStr::Cmp(canonicalName.c_str(), name.c_str()) != 0) {
name.Set(canonicalName.c_str());
}
}
+50 -146
View File
@@ -1,155 +1,59 @@
#pragma once
// Reconstructed C++ declarations from IDA Local Types and PDB/DIA metadata.
// Original PDB header: w:\tech5\engine\framework\resource.h
// Recovered logical types: 12
// Signatures retain Xbox 360 ABI evidence and may still require manual review.
#include "idlib/text/atomicstring.h"
#include <cstdint>
// IDA Local Type ordinal 2777; PDB kind: enum.
enum idResource::referenceType_t : __int32
{
REF_UNKNOWN = 0x0,
REF_FREED = 0x1,
REF_WEAK = 0x2,
REF_STRONG = 0x3,
};
class idResourceList;
// IDA Local Type ordinal 2778; PDB kind: enum.
enum idResource::resourceError_t : __int32
{
RESOURCE_ERROR_NONE = 0x0,
RESOURCE_ERROR_FILE_NOT_FOUND = 0x1,
RESOURCE_ERROR_WRONG_TYPE = 0x2,
RESOURCE_ERROR_INVALID_NAME = 0x3,
RESOURCE_ERROR_HEADER_VERSION_MISMATCH = 0x4,
RESOURCE_ERROR_RESOURCE_VERSION_MISMATCH = 0x5,
RESOURCE_ERROR_FATAL = 0x6,
RESOURCE_ERROR_TRUNCATED = 0x7,
RESOURCE_ERROR_MAX = 0x8,
};
// IDA Local Type ordinal 2779; PDB kind: enum.
enum idResource::resourceHeader_t::resourcePlatform_t : __int32
{
RESOURCEPLATFORM_WINDOWS = 0x0,
RESOURCEPLATFORM_360 = 0x1,
RESOURCEPLATFORM_PS3 = 0x2,
RESOURCEPLATFORM_MAC = 0x3,
RESOURCEPLATFORM_MAX = 0x4,
};
// IDA Local Type ordinal 13299; PDB kind: class.
class __declspec(align(4)) idResource
{
class alignas(4) idResource {
public:
// Recovered virtual interface; IDA vtable ordinal 13302.
virtual ~idResource();
virtual void LoadResource();
virtual bool ReloadIfStale();
virtual void WriteResourceFile();
virtual idResourceList *GetResourceList();
virtual void Print();
virtual void List();
// Recovered from idResource's PDB type information. The executable
// stores the printable error text in resourceError, while this enum is
// the stable result vocabulary used by binary-resource loaders.
enum resourceError_t : int {
RESOURCE_ERROR_NONE = 0,
RESOURCE_ERROR_FILE_NOT_FOUND = 1,
RESOURCE_ERROR_WRONG_TYPE = 2,
RESOURCE_ERROR_INVALID_NAME = 3,
RESOURCE_ERROR_HEADER_VERSION_MISMATCH = 4,
RESOURCE_ERROR_RESOURCE_VERSION_MISMATCH = 5,
RESOURCE_ERROR_FATAL = 6,
RESOURCE_ERROR_TRUNCATED = 7,
RESOURCE_ERROR_MAX = 8
};
int trackedMemory;
idAtomicString name;
idResource *nextOnHashChain;
idResourceList *resourceListPtr;
const char *resourceError;
int networkID;
int staleCount;
unsigned __int8 : 3;
__int8 loadDeferred : 1;
__int8 forceLoad : 1;
__int8 insideRecursiveLoad : 1;
__int8 staticResource : 1;
__int8 loadedResource : 1;
enum referenceType_t : int {
REF_UNKNOWN = 0,
REF_FREED = 1,
REF_WEAK = 2,
REF_STRONG = 3
};
idResource();
virtual ~idResource();
virtual void LoadResource();
virtual bool ReloadIfStale();
virtual void WriteResourceFile();
virtual idResourceList* GetResourceList();
virtual void Print();
virtual void List();
void SetName(const char* newName);
const char* GetName() const { return name.c_str(); }
int trackedMemory;
idAtomicString name;
idResource* nextOnHashChain;
idResourceList* resourceListPtr;
const char* resourceError;
int networkID;
int staleCount;
std::uint8_t resourceFlags;
std::uint8_t pad[3];
};
// IDA Local Type ordinal 13653; PDB kind: class.
class idCodeResource<idDeclRenderParm> : public idBaseCodeResource
{
public:
};
// IDA Local Type ordinal 17567; PDB kind: class.
class idCodeResource<idFont> : public idBaseCodeResource
{
public:
};
// IDA Local Type ordinal 19095; PDB kind: class.
class idAtlasResource : public idResource
{
public:
// Recovered virtual interface; IDA vtable ordinal 19096.
virtual ~idAtlasResource();
virtual void LoadResource();
virtual bool ReloadIfStale();
virtual void WriteResourceFile();
virtual idResourceList *GetResourceList();
virtual void Print();
virtual void List();
unsigned int binaryTimestamp;
idVec4 scaleBias;
int img_tiles_wide;
int img_tiles_high;
int img_x;
int img_y;
int img_w;
int img_h;
};
// IDA Local Type ordinal 21416; PDB kind: class.
class idCodeResource<idMaterial> : public idBaseCodeResource
{
public:
};
// IDA Local Type ordinal 22063; PDB kind: struct.
struct idResource::resourceHeader_t
{
unsigned __int16 headerVersionHi;
unsigned __int16 headerVersionLo;
unsigned int resourceId;
unsigned __int16 versionHi;
unsigned __int16 versionLo;
unsigned int sourceTimestamp;
unsigned __int16 sourceFileNameLen;
unsigned __int16 uniqueIdNameLen;
unsigned __int8 platform;
unsigned __int8 pad[3];
unsigned __int64 uniqueId;
unsigned __int64 hash;
unsigned __int64 dataOffset;
unsigned __int64 totalSize;
};
// IDA Local Type ordinal 22703; PDB kind: class.
class idCodeResource<idSoundShader> : public idBaseCodeResource
{
public:
};
// IDA Local Type ordinal 22770; PDB kind: class.
class idCodeResource<idDeclRenderProg> : public idBaseCodeResource
{
public:
};
// IDA Local Type ordinal 23337; PDB kind: class.
class idJointResource : public idResource
{
public:
// Recovered virtual interface; IDA vtable ordinal 23338.
virtual ~idJointResource();
virtual void LoadResource();
virtual bool ReloadIfStale();
virtual void WriteResourceFile();
virtual idResourceList *GetResourceList();
virtual void Print();
virtual void List();
};
#if INTPTR_MAX == INT32_MAX
static_assert(sizeof(idResource) == 36, "Recovered idResource ABI changed");
#endif
+147
View File
@@ -0,0 +1,147 @@
#include "framework/resourcelist.h"
#include "framework/resource.h"
#include "idlib/lib_print.h"
#include <cstring>
#include <mutex>
namespace {
std::mutex resourceListMutex;
unsigned int ResourceHash(const char* text) {
unsigned int hash = 0;
if (text != nullptr) {
for (const unsigned char* cursor =
reinterpret_cast<const unsigned char*>(text);
*cursor != 0; ++cursor) {
hash = 31u * hash + *cursor;
}
}
return hash & 255u;
}
} // namespace
idResourceList::idResourceList(const char* const typeName)
: resourceTypeName(typeName), nextResourceList(nullptr), num(0),
staticID(-1), hashTable{} {
}
idResourceList::~idResourceList() = default;
idResource* idResourceList::Alloc(const char*) {
return nullptr;
}
int idResourceList::AllocSize() {
return 0;
}
const char* idResourceList::GetResourceTypeName() const {
if (resourceTypeName == nullptr) {
idLibPrint::FatalError(
"idResourceList::GetResourceTypeName: not set");
}
return resourceTypeName;
}
idResource* idResourceList::Load(const char* const name,
const bool makeDefault, const bool skipStaleCheck) {
if (name == nullptr || *name == '\0') return nullptr;
if (idResource* const existing = FindExisting(name, skipStaleCheck)) {
return existing;
}
idResource* const resource = Alloc(name);
if (resource == nullptr) return nullptr;
resource->LoadResource();
if (resource->resourceError != nullptr && !makeDefault) {
Remove(resource);
delete resource;
return nullptr;
}
return resource;
}
void idResourceList::Add(idResource* const resource) {
if (resource == nullptr || resource->GetName() == nullptr
|| *resource->GetName() == '\0') {
idLibPrint::FatalError(
"idResourceList::Add called with unnamed resource");
}
std::lock_guard<std::mutex> lock(resourceListMutex);
idResource*& head = hashTable[ResourceHash(resource->GetName())];
for (idResource* current = head; current != nullptr;
current = current->nextOnHashChain) {
if (current == resource) {
return;
}
}
resource->nextOnHashChain = head;
resource->resourceListPtr = this;
head = resource;
++num;
}
idResource* idResourceList::FindExisting(const char* const name,
const bool skipStaleCheck) {
if (name == nullptr || *name == '\0') {
return nullptr;
}
idResource* result = nullptr;
{
std::lock_guard<std::mutex> lock(resourceListMutex);
for (idResource* current = hashTable[ResourceHash(name)];
current != nullptr; current = current->nextOnHashChain) {
if (_stricmp(current->GetName(), name) == 0) {
result = current;
break;
}
}
}
if (result != nullptr && !skipStaleCheck) {
result->ReloadIfStale();
}
return result;
}
idResource* idResourceList::Index(const int index) const {
if (index < 0 || index >= num) {
return nullptr;
}
int currentIndex = 0;
for (int bucket = 0; bucket < 256; ++bucket) {
for (idResource* current = hashTable[bucket]; current != nullptr;
current = current->nextOnHashChain) {
if (currentIndex++ == index) {
return current;
}
}
}
return nullptr;
}
void idResourceList::Remove(idResource* const resource) {
std::lock_guard<std::mutex> lock(resourceListMutex);
idResource** link = &hashTable[ResourceHash(resource->name.c_str())];
while (*link != nullptr && *link != resource) {
link = &(*link)->nextOnHashChain;
}
if (*link == nullptr) {
idLibPrint::FatalError("idResourceList::Remove( %s ) not found",
resource->name.c_str());
}
*link = resource->nextOnHashChain;
resource->nextOnHashChain = nullptr;
resource->resourceListPtr = nullptr;
--num;
}
void idResourceList::UnRegisterNetworkResource(idResource* const resource) {
// The recovered operation is a no-op for the normal unregistered state;
// the network resource array itself belongs to the later framework port.
if (resource->networkID != -1) {
resource->networkID = -1;
}
}
+38 -342
View File
@@ -1,353 +1,49 @@
#pragma once
// Reconstructed C++ declarations from IDA Local Types and PDB/DIA metadata.
// Original PDB header: w:\tech5\engine\framework\resourcelist.h
// Recovered logical types: 31
// Signatures retain Xbox 360 ABI evidence and may still require manual review.
#include "framework/resource.h"
// IDA Local Type ordinal 13300; PDB kind: class.
class idResourceList
{
class idResourceList {
public:
// Recovered virtual interface; IDA vtable ordinal 13301.
virtual ~idResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
explicit idResourceList(const char* typeName = nullptr);
virtual ~idResourceList();
virtual idResource* Alloc(const char* name);
virtual int AllocSize();
const char *resourceTypeName;
idResourceList *nextResourceList;
int num;
int staticID;
idResource *hashTable[256];
const char* GetResourceTypeName() const;
idResource* Load(const char* name, bool makeDefault,
bool skipStaleCheck = false);
void Add(idResource* resource);
idResource* FindExisting(const char* name,
bool skipStaleCheck = false);
idResource* Index(int index) const;
void Remove(idResource* resource);
static void UnRegisterNetworkResource(idResource* resource);
const char* resourceTypeName;
idResourceList* nextResourceList;
int num;
int staticID;
idResource* hashTable[256];
};
// IDA Local Type ordinal 18047; PDB kind: class.
class idTypedResourceList<idVoiceTrack> : public idResourceList
{
template<class resourceType>
class idTypedResourceList final : public idResourceList {
public:
// Recovered virtual interface; IDA vtable ordinal 18048.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
explicit idTypedResourceList(const char* const typeName)
: idResourceList(typeName) {
}
idResource* Alloc(const char* const name) override {
resourceType* const resource = new resourceType();
resource->SetName(name);
Add(resource);
return resource;
}
int AllocSize() override { return sizeof(resourceType); }
};
// IDA Local Type ordinal 18119; PDB kind: class.
class idTypedResourceList<idNavigationMesh> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 18120.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 18306; PDB kind: class.
class idTypedResourceList<idCoverPoints> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 18307.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 18732; PDB kind: class.
class idTypedResourceList<idInGameVideoFile> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 18733.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 18735; PDB kind: class.
class idTypedResourceList<idMD6Anim> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 18736.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 18739; PDB kind: class.
class idTypedResourceList<idIESfile> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 18740.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 19089; PDB kind: class.
class idTypedResourceList<idImage> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 19090.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 19097; PDB kind: class.
class idTypedResourceList<idAtlasResource> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 19098.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 20001; PDB kind: class.
class idTypedResourceList<idCollisionModelLocal> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 20002.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 20076; PDB kind: class.
class idTypedResourceList<idFont> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 20077.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 21602; PDB kind: class.
class idTypedResourceList<idStaticModel> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 21603.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 21604; PDB kind: class.
class idTypedResourceList<idSoundSample> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 21605.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 21607; PDB kind: class.
class idTypedResourceList<idStaticParticleModelData> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 21608.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 21627; PDB kind: class.
class idTypedResourceList<idMD6Skel> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 21628.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 21701; PDB kind: class.
class idTypedResourceList<idMD6Model> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 21702.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 21755; PDB kind: class.
class idTypedResourceList<idDiscreteAnimationModelData> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 21756.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 21903; PDB kind: class.
class idTypedResourceList<idMD6SkeletonConfig> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 21904.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 21984; PDB kind: class.
class idTypedResourceList<idAAS2File> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 21985.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 22175; PDB kind: class.
class idTypedResourceList<idRenderModelCuttableResource> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 22176.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 22333; PDB kind: class.
class idTypedResourceList<idMorphVertices> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 22334.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 22456; PDB kind: class.
class idTypedResourceList<idFileResource> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 22457.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 22869; PDB kind: class.
class idTypedResourceList<idFoliageModel> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 22870.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 22873; PDB kind: class.
class idTypedResourceList<idDetailModel> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 22874.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 23020; PDB kind: class.
class idTypedResourceList<idImageCPU> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 23021.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 23026; PDB kind: class.
class idTypedResourceList<idImageCubeCPU> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 23027.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 23308; PDB kind: class.
class idTypedResourceList<idJointConversion> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 23309.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 23335; PDB kind: class.
class idTypedResourceList<idJointResource> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 23336.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 23364; PDB kind: class.
class idTypedResourceList<idDetailModelData> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 23365.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 23512; PDB kind: class.
class idTypedResourceList<idAAS2DebugAreaModel> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 23513.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
// IDA Local Type ordinal 23769; PDB kind: class.
class idTypedResourceList<idCollisionGridLocal> : public idResourceList
{
public:
// Recovered virtual interface; IDA vtable ordinal 23770.
virtual ~idTypedResourceList();
virtual idResource *Alloc(const char *);
virtual int AllocSize();
};
#if INTPTR_MAX == INT32_MAX
static_assert(sizeof(idResourceList) == 1044,
"Recovered idResourceList ABI changed");
#endif