XML data layer: pugixml (external/pugixml, v1.15), a format-neutral DataNode API for every loader, DataFormat=auto|json|xml (default xml), KAGE's archive file system ported (index once, four unpackers, the original's mount order) so --resources can point at an install's resources/ with no import step, the original XML .anm2 loader beside Anm2Ed JSON, mods' own XML; 72 goldens identical from converted resources and from the install

This commit is contained in:
shweet committed 2026-11-24 05:57:54 -05:00
1 parent 74322af121
commit 6d8a43775d
52 files changed
+1513 -909

No files matched your search

+4 -2
View File
@@ -211,6 +211,10 @@ struct DamageEvent;
struct DamageHit;
struct DamageInfo;
struct Data;
struct DataAttr;
struct DataAttrs;
struct DataChildren;
struct DataNode;
struct DateTime;
struct DeathmatchManager;
struct DeathmatchTypeBase;
@@ -8447,7 +8451,6 @@ void FUN_009a8a40(); // 009a8a40
void _player_hud_set_heart_anim_state(int param_1); // 009a90b0
void move_directory_files(); // 009a90e0
uint8_t delete_directory_recursive(uint8_t *path); // 009a9250
void resources_mount_language(); // 009ab970
void FUN_009abd50(); // 009abd50
void FUN_009ad470(); // 009ad470
void FUN_009ad500(char *param_1, char *param_2); // 009ad500
@@ -12312,7 +12315,6 @@ bool FUN_00a68630(); // 00a68630
void FUN_00a68640(); // 00a68640
uint32_t FUN_00a68730(uint8_t *param_1); // 00a68730
uint32_t FUN_00a68790(uint8_t *param_1); // 00a68790
void FUN_00a68a50(int *param_1); // 00a68a50
void FUN_00a68b50(uint8_t param_1); // 00a68b50
uint32_t FUN_00a68c40(); // 00a68c40
void FUN_00a68c50(); // 00a68c50
-133
View File
@@ -312,92 +312,6 @@ LAB_00a16b36:
} while( true );
}
// 00a16c60
uint32_t FileSystem::find_mount(uint8_t *param_1, uint8_t *param_2)
{
int iVar1;
uint64_t qVar2;
uint8_t bVar3;
uint8_t *normalizedPath;
uint8_t *archivePath;
int *entry;
int in_ECX;
uint64_t *allocatedBytes;
int mountIndex;
uint8_t hashIter [8];
int hashNode;
int fileSystem;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
uint32_t blockSize;
local_8 = 0xffffffff;
puStack_c = &LAB_00b10fa0;
local_10 = ExceptionList;
ExceptionList = &local_10;
fileSystem = in_ECX;
normalizedPath = path_join(param_1,GHIDRA_CAST<uint8_t *>(0x0),0,0);
mountIndex = (*GHIDRA_CAST<int *>((in_ECX + 0xc)) - *GHIDRA_CAST<int *>((in_ECX + 8)) >> 2) + -1;
if (-1 < mountIndex) {
while( true ) {
if (DAT_00c37b14 != 0) {
archivePath = path_join(normalizedPath,
*GHIDRA_CAST<uint8_t **>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((in_ECX + 8)) + mountIndex * 4)) + 0xc)),0,
0);
bVar3 = open_archive_file(&PTR_vftable_00c37a10,archivePath,(void **)0x0);
param_1 = GHIDRA_CAST<uint8_t *>(CONCAT13(bVar3,(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(param_1)) + 0x0)))));
if (archivePath != GHIDRA_CAST<uint8_t *>(0x0)) {
operator_delete(archivePath,1);
bVar3 = (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(param_1)) + 0x3)));
}
if (bVar3 != 0) {
iVar1 = *GHIDRA_CAST<int *>((fileSystem + 8));
*param_2 = 1;
ExceptionList = local_10;
return *GHIDRA_CAST<uint32_t *>((iVar1 + mountIndex * 4));
}
in_ECX = fileSystem;
}
iVar1 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((in_ECX + 8)) + mountIndex * 4));
param_1 = GHIDRA_CAST<uint8_t *>(KAGE_Filesys_FileManager)::GetPrimaryFilePathHash(normalizedPath);
_Find_lower_bound<>(hashIter,&param_1);
if (((*GHIDRA_CAST<char *>((hashNode + 0xd)) == '\0') && (*GHIDRA_CAST<uint8_t **>((hashNode + 0x10)) <= param_1)) &&
(hashNode != *GHIDRA_CAST<int *>((iVar1 + 4)))) {
entry = map_find_value((void *)(iVar1 + 4),GHIDRA_UINT(&param_1));
if (*entry != 0) {
if (normalizedPath != GHIDRA_CAST<uint8_t *>(0x0)) {
local_8 = 0;
tracked_alloc(1,normalizedPath,0);
}
*param_2 = 0;
ExceptionList = local_10;
return *GHIDRA_CAST<uint32_t *>((*GHIDRA_CAST<int *>((fileSystem + 8)) + mountIndex * 4));
}
}
mountIndex = mountIndex + -1;
if (mountIndex < 0) break;
in_ECX = fileSystem;
}
}
if (normalizedPath != GHIDRA_CAST<uint8_t *>(0x0)) {
if (g_mainHeap == (void *)0x0) {
allocatedBytes = &g_allocatedBytesNoHeap;
}
else {
allocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
blockSize = *GHIDRA_CAST<uint32_t *>((normalizedPath + -4));
qVar2 = *allocatedBytes;
*GHIDRA_CAST<uint32_t *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - blockSize;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < blockSize));
free(normalizedPath + -4);
}
ExceptionList = local_10;
return 0;
}
// 00a17180
uint8_t * FileSystem::ResolvePath(uint8_t *path)
{
@@ -456,53 +370,6 @@ uint8_t * FileSystem::ResolvePath(uint8_t *path)
return pbVar1;
}
// 00a178d0
void * FileSystem::Open(uint8_t *path, int *outResolvedPath)
{
uint8_t *resolvedPath;
void *this_00;
void *local_10;
uint8_t *puStack_c;
int *local_8;
resolvedPath = path;
local_8 = GHIDRA_CAST<int *>(0xffffffff);
puStack_c = &LAB_00af0b60;
local_10 = ExceptionList;
if ((path == GHIDRA_CAST<uint8_t *>(0x0)) || (*path == 0)) {
return (void *)0x0;
}
path = GHIDRA_CAST<uint8_t *>(0x0);
ExceptionList = &local_10;
resolvedPath = ResolvePath(resolvedPath);
open_archive_file(this,resolvedPath,&path);
if (path == GHIDRA_CAST<uint8_t *>(0x0)) {
open_disk_file(this_00,resolvedPath,&path);
if (outResolvedPath == GHIDRA_CAST<int *>(0x0)) {
if (resolvedPath == GHIDRA_CAST<uint8_t *>(0x0)) {
ExceptionList = local_10;
return path;
}
local_8 = GHIDRA_CAST<int *>(0x1);
LAB_00a1795c:
tracked_alloc(1,resolvedPath,0);
ExceptionList = local_10;
return path;
}
}
else if (outResolvedPath == GHIDRA_CAST<int *>(0x0)) {
if (resolvedPath == GHIDRA_CAST<uint8_t *>(0x0)) {
ExceptionList = local_10;
return path;
}
local_8 = outResolvedPath;
goto LAB_00a1795c;
}
*outResolvedPath = GHIDRA_INT(resolvedPath);
ExceptionList = local_10;
return path;
}
// 00a17ea0
uint8_t FileSystem::open_disk_file(uint8_t *path, void **outFile)
{
-204
View File
@@ -58,207 +58,3 @@ uint32_t KAGE_Filesys_FileManager::GetSecondaryFilePathHash()
}
return uVar4;
}
// 00a179c0
void KAGE_Filesys_FileManager::LoadArchiveFile(uint8_t *param_1, uint32_t *param_2, uint16_t param_3)
{
uint8_t isExpectedChecksum;
uint32_t uVar1;
uint8_t *resolvedPath;
uint8_t *loadedPathChar;
uint32_t isExpectedChecksum;
uint32_t *fileEntry;
uint8_t *extraout_ECX;
uint8_t *resolvedPathChar;
int iVar3;
int *piVar4;
uint32_t uVar5;
int dwordCount;
bool isLess;
char *format;
uint32_t archiveIndex;
uint32_t fileCount;
uint8_t *archivePath;
int local_e58;
int *stream;
uint8_t archiveType;
uint32_t local_e4c;
int archivedFile [3];
int archivedFileRecord;
int chunkBuffer [128];
uint8_t headerMagic [7];
uint8_t local_15;
uint32_t local_14;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
uint8_t ch;
local_8 = 0xffffffff;
puStack_c = &LAB_00b11020;
local_10 = ExceptionList;
uVar1 = __security_cookie ^ GHIDRA_UINT((headerMagic + 0x18));
ExceptionList = &local_10;
archivePath = param_1;
local_14 = uVar1;
resolvedPath = FileSystem::ResolvePath(param_1);
if (resolvedPath == GHIDRA_CAST<uint8_t *>(0x0)) {
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("Failed to open archive file \'%s\'\n"));
}
else {
uVar5 = 0;
archiveIndex = 0;
resolvedPathChar = extraout_ECX;
if (DAT_00c37b14 != 0) {
do {
loadedPathChar = GHIDRA_CAST<uint8_t *>((&DAT_00c37a14)[uVar5 * 2]);
resolvedPathChar = resolvedPath;
do {
ch = *loadedPathChar;
isLess = ch < *resolvedPathChar;
if (ch != *resolvedPathChar) {
LAB_00a17a60:
isExpectedChecksum = -GHIDRA_UINT(isLess) | 1;
goto LAB_00a17a65;
}
if (ch == 0) break;
ch = loadedPathChar[1];
isLess = ch < resolvedPathChar[1];
if (ch != resolvedPathChar[1]) goto LAB_00a17a60;
loadedPathChar = loadedPathChar + 2;
resolvedPathChar = resolvedPathChar + 2;
} while (ch != 0);
isExpectedChecksum = 0;
LAB_00a17a65:
} while ((isExpectedChecksum != 0) && (uVar5 = uVar5 + 1, uVar5 < DAT_00c37b14));
archiveIndex = uVar5;
if (0x1f < uVar5) {
KAGE_LogMessage(8,(uint8_t *)
"Cannot load archive file \'%s\', maximum number of archive files exceeded\n"
);
local_8 = 0;
tracked_alloc(1,resolvedPath,0);
ExceptionList = local_10;
return;
}
}
(&DAT_00c37a14)[archiveIndex * 2] = resolvedPath;
stream = GHIDRA_CAST<int *>(0x0);
(GHIDRA_CAST<FileSystem *>((resolvedPathChar)))->FileSystem::open_disk_file(resolvedPath,&stream);
if ((stream == GHIDRA_CAST<int *>(0x0)) &&
(FileSystem::open_archive_file
(&PTR_vftable_00c37a10,GHIDRA_CAST<uint8_t *>((&DAT_00c37a14)[archiveIndex * 2]),&stream),
stream == GHIDRA_CAST<int *>(0x0))) {
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("Failed to open archive file \'%s\'\n"));
if ((void *)(&DAT_00c37a14)[archiveIndex * 2] == (void *)0x0) {
ExceptionList = local_10;
return;
}
local_8 = 1;
tracked_alloc(1,(void *)(&DAT_00c37a14)[archiveIndex * 2],0);
(&DAT_00c37a14)[archiveIndex * 2] = 0;
ExceptionList = local_10;
return;
}
piVar4 = stream;
(**(code **)(*stream + 0x14))(headerMagic,1,7,uVar1);
local_15 = 0;
archiveType = 0;
(**(code **)(*piVar4 + 0x14))(&archiveType,1,1);
(&DAT_00c37a18)[archiveIndex * 8] = archiveType;
local_e58 = 0;
(**(code **)(*piVar4 + 0x14))(&local_e58,4,1);
fileCount = 0;
(**(code **)(*piVar4 + 0x14))(&fileCount,2,1);
(**(code **)(*piVar4 + 0xc))(local_e58,0);
local_e58 = 0;
if ((uint16_t)fileCount != 0) {
do {
fileEntry = operator_new(0x1c);
piVar4 = stream;
local_e4c = 0;
*fileEntry = archiveIndex;
(**(code **)(*stream + 0x14))(&local_e4c,4,1);
fileEntry[1] = local_e4c;
local_e4c = 0;
(**(code **)(*piVar4 + 0x14))(&local_e4c,4,1);
fileEntry[2] = local_e4c;
local_e4c = 0;
(**(code **)(*piVar4 + 0x14))(&local_e4c,4,1);
fileEntry[3] = local_e4c;
local_e4c = 0;
(**(code **)(*piVar4 + 0x14))(&local_e4c,4,1);
fileEntry[4] = local_e4c;
local_e4c = 0;
(**(code **)(*piVar4 + 0x14))(&local_e4c,4,1);
fileEntry[5] = local_e4c;
if (((uint16_t)local_e58 < param_3) && (*param_2 == local_e4c)) {
isExpectedChecksum = 1;
}
else {
isExpectedChecksum = 0;
}
*GHIDRA_CAST<uint8_t *>((fileEntry + 6)) = isExpectedChecksum;
FUN_00a68a50(fileEntry);
local_8 = 2;
uVar1 = 0xababeb98;
memset(chunkBuffer,0,0x200);
local_e4c = *GHIDRA_CAST<uint32_t *>((archivedFileRecord + 0x10));
do {
uVar5 = local_e4c;
if (0x200 < GHIDRA_INT(local_e4c)) {
uVar5 = 0x200;
}
isExpectedChecksum = (**(code **)(archivedFile[0] + 0x14))(chunkBuffer,1,uVar5);
iVar3 = 0;
dwordCount = GHIDRA_INT(((GHIDRA_INT((isExpectedChecksum + 3)) >> 0x1f & 3U) + isExpectedChecksum + 3)) >> 2;
if (0 < dwordCount) {
do {
piVar4 = chunkBuffer + iVar3;
iVar3 = iVar3 + 1;
uVar1 = uVar1 * -0x80000000 + *piVar4 + (uVar1 >> 1);
} while (iVar3 < dwordCount);
}
local_e4c = local_e4c - uVar5;
} while ((0 < GHIDRA_INT(local_e4c)) && (isExpectedChecksum == uVar5));
if (uVar1 == *GHIDRA_CAST<uint32_t *>((archivedFileRecord + 0x14))) {
uVar5 = fileEntry[1] & 0x7fff;
iVar3 = *GHIDRA_CAST<int *>((&DAT_00c37b18 + uVar5 * 4));
uVar1 = 0;
if (iVar3 != 0) {
do {
if (((*GHIDRA_CAST<uint32_t *>((iVar3 + 4)) == fileEntry[1]) &&
(isExpectedChecksum = uVar1, *GHIDRA_CAST<uint32_t *>((iVar3 + 8)) == fileEntry[2])) ||
(isExpectedChecksum = uVar1 + 1, 0x7fff < uVar1)) break;
uVar5 = uVar5 + 1 & 0x7fff;
iVar3 = *GHIDRA_CAST<int *>((&DAT_00c37b18 + uVar5 * 4));
uVar1 = isExpectedChecksum;
} while (iVar3 != 0);
if (0x7fff < isExpectedChecksum) {
format = "Failed to load file %x%x from \'%s\', hash table is full\n";
goto LAB_00a17dad;
}
}
*GHIDRA_CAST<uint32_t **>((&DAT_00c37b18 + uVar5 * 4)) = fileEntry;
}
else {
format = "Failed to load file %x%x from \'%s\', checksum is invalid\n";
LAB_00a17dad:
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>(format));
operator_delete(fileEntry,0x1c);
}
local_8 = 0xffffffff;
(GHIDRA_CAST<KAGE::Filesys::ArchivedFile *>((archivedFile)))->KAGE::Filesys::ArchivedFile::~ArchivedFile();
param_2 = param_2 + 1;
local_e58 = local_e58 + 1;
} while ((uint16_t)local_e58 < (uint16_t)fileCount);
piVar4 = stream;
}
(**(code **)*piVar4)(1);
if (DAT_00c37b14 < archiveIndex + 1) {
DAT_00c37b14 = archiveIndex + 1;
}
}
ExceptionList = local_10;
return;
}
-5
View File
@@ -8284,9 +8284,7 @@ EntityList_Query::~EntityList_Query() { generated_stub("EntityList_Query::~Entit
void EntitySaveStateRef::Set(void *state) { generated_stub("EntitySaveStateRef::Set 006eee10"); }
void * FileSystem::GetMountPrefixes(void *outPrefixes) { generated_stub("FileSystem::GetMountPrefixes 00a16060"); }
void FileSystem::load_mount_points() { generated_stub("FileSystem::load_mount_points 00a167d0"); }
uint32_t FileSystem::find_mount(uint8_t *param_1, uint8_t *param_2) { generated_stub("FileSystem::find_mount 00a16c60"); }
uint8_t * FileSystem::ResolvePath(uint8_t *path) { generated_stub("FileSystem::ResolvePath 00a17180"); }
void * FileSystem::Open(uint8_t *path, int *outResolvedPath) { generated_stub("FileSystem::Open 00a178d0"); }
uint8_t FileSystem::open_disk_file(uint8_t *path, void **outFile) { generated_stub("FileSystem::open_disk_file 00a17ea0"); }
uint8_t FileSystem::open_archive_file(uint8_t *path, void **outFile) { generated_stub("FileSystem::open_archive_file 00a17f40"); }
void FrameQueue::setSize(int count) { generated_stub("FrameQueue::setSize 00aaa500"); }
@@ -9024,7 +9022,6 @@ void KAGE::Thread::vfunc_3() { generated_stub("KAGE::Thread::vfunc_3 00a5a700");
uint32_t KAGE::Util::String::CharacterIteratorUTF8::FUN_00a55aa0() { generated_stub("KAGE::Util::String::CharacterIteratorUTF8::FUN_00a55aa0 00a55aa0"); }
uint32_t KAGE_Filesys_FileManager::GetPrimaryFilePathHash(uint8_t *filePath) { generated_stub("KAGE_Filesys_FileManager::GetPrimaryFilePathHash 00a159d0"); }
uint32_t KAGE_Filesys_FileManager::GetSecondaryFilePathHash() { generated_stub("KAGE_Filesys_FileManager::GetSecondaryFilePathHash 00a15ab0"); }
void KAGE_Filesys_FileManager::LoadArchiveFile(uint8_t *param_1, uint32_t *param_2, uint16_t param_3) { generated_stub("KAGE_Filesys_FileManager::LoadArchiveFile 00a179c0"); }
void KColor::FromRGBA255(int red, int green, int blue, int alpha) { generated_stub("KColor::FromRGBA255 00682f50"); }
void KColor::SetFromARGB(uint32_t argb) { generated_stub("KColor::SetFromARGB 00a0f550"); }
KColor * KColor::set_from_argb_signed(uint32_t argb) { generated_stub("KColor::set_from_argb_signed 00a0f610"); }
@@ -12523,7 +12520,6 @@ void FUN_009a8a40() { generated_stub("FUN_009a8a40 009a8a40"); }
void _player_hud_set_heart_anim_state(int param_1) { generated_stub("_player_hud_set_heart_anim_state 009a90b0"); }
void move_directory_files() { generated_stub("move_directory_files 009a90e0"); }
uint8_t delete_directory_recursive(uint8_t *path) { generated_stub("delete_directory_recursive 009a9250"); }
void resources_mount_language() { generated_stub("resources_mount_language 009ab970"); }
void FUN_009abd50() { generated_stub("FUN_009abd50 009abd50"); }
void FUN_009ad470() { generated_stub("FUN_009ad470 009ad470"); }
void FUN_009ad500(char *param_1, char *param_2) { generated_stub("FUN_009ad500 009ad500"); }
@@ -16393,7 +16389,6 @@ bool FUN_00a68630() { generated_stub("FUN_00a68630 00a68630"); }
void FUN_00a68640() { generated_stub("FUN_00a68640 00a68640"); }
uint32_t FUN_00a68730(uint8_t *param_1) { generated_stub("FUN_00a68730 00a68730"); }
uint32_t FUN_00a68790(uint8_t *param_1) { generated_stub("FUN_00a68790 00a68790"); }
void FUN_00a68a50(int *param_1) { generated_stub("FUN_00a68a50 00a68a50"); }
void FUN_00a68b50(uint8_t param_1) { generated_stub("FUN_00a68b50 00a68b50"); }
uint32_t FUN_00a68c40() { generated_stub("FUN_00a68c40 00a68c40"); }
void FUN_00a68c50() { generated_stub("FUN_00a68c50 00a68c50"); }