--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
319 lines
11 KiB
C++
319 lines
11 KiB
C++
#include "classes.h"
|
|
|
|
// 005ca5a0
|
|
bool KAGE_Filesys_FileManager::OpenRead(int param_2, int param_3)
|
|
{
|
|
uint8_t isHasFlags;
|
|
int iVar1;
|
|
int totalCharge;
|
|
|
|
if (-1 < param_3) {
|
|
iVar1 = (GHIDRA_CAST<Entity_Player *>((GHIDRA_CAST<Entity_Player *>(this))))->Entity_Player::GetActiveMaxCharge(param_3);
|
|
totalCharge = (GHIDRA_CAST<Entity_Player *>((GHIDRA_CAST<Entity_Player *>(this))))->Entity_Player::GetTotalActiveCharge(param_3);
|
|
if (totalCharge < iVar1) {
|
|
return false;
|
|
}
|
|
}
|
|
if (0x244 < param_2) {
|
|
switch(param_2) {
|
|
case 0x248:
|
|
if ((*GHIDRA_CAST<int **>((this + 0x7ec)) != GHIDRA_CAST<int *>(0x0)) && (**GHIDRA_CAST<int **>((this + 0x7ec)) == 3)) {
|
|
return false;
|
|
}
|
|
default:
|
|
return true;
|
|
case 0x26f:
|
|
return 0 < *GHIDRA_CAST<int *>((this + 0x674));
|
|
case 0x27b:
|
|
iVar1 = FUN_005c92f0();
|
|
if (iVar1 != 0) {
|
|
iVar1 = (GHIDRA_CAST<Room *>((g_game->_room)))->Room::GetGridCollisionAtPos(*GHIDRA_CAST<Vector *>((iVar1 + 0x33c)));
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(this[0x725])) + 0x1))) != '\0') {
|
|
return iVar1 != 4;
|
|
}
|
|
if (iVar1 == 0) {
|
|
return true;
|
|
}
|
|
if (iVar1 == 5) {
|
|
return true;
|
|
}
|
|
}
|
|
break;
|
|
case 0x282:
|
|
iVar1 = (GHIDRA_CAST<Entity_Player *>((GHIDRA_CAST<Entity_Player *>(this))))->Entity_Player::GetEffectiveMaxHearts();
|
|
return 0 < iVar1 + *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(this[0x66e])) + 0x2))));
|
|
case 0x2c5:
|
|
if ((*GHIDRA_CAST<int *>((this + 0xa64)) == 0) &&
|
|
(1.0 < *GHIDRA_CAST<float *>((this + 0x120)) * *GHIDRA_CAST<float *>((this + 0x120)) +
|
|
*GHIDRA_CAST<float *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(this[0x121])) + 0x1)))) * *GHIDRA_CAST<float *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(this[0x121])) + 0x1)))))) {
|
|
return true;
|
|
}
|
|
break;
|
|
case 0x2ca:
|
|
isHasFlags = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(this))))->Entity::HasEntityFlags(0x600000000000000);
|
|
if ((isHasFlags == 0) && (*GHIDRA_CAST<float *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(this[0x11a])) + 0x2)))) == 0.0)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
if (param_2 == 0x244) {
|
|
iVar1 = FUN_00827180(this + 0x114);
|
|
return iVar1 != -1;
|
|
}
|
|
if (0x127 < param_2) {
|
|
if (param_2 != 0x1e7) {
|
|
if (param_2 == 0x22b) {
|
|
return 4 < *GHIDRA_CAST<int *>((this + 0x678));
|
|
}
|
|
return true;
|
|
}
|
|
LAB_005ca662:
|
|
return 1 < *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(this[0x66a])) + 0x2))));
|
|
}
|
|
if (param_2 == 0x127) {
|
|
return 0 < *GHIDRA_CAST<int *>((this + 0x678));
|
|
}
|
|
if (param_2 != 0x82) {
|
|
if (param_2 == 0x85) goto LAB_005ca662;
|
|
if (param_2 != 0xb5) {
|
|
return true;
|
|
}
|
|
}
|
|
return 1.0 < *GHIDRA_CAST<float *>((this + 0x120)) * *GHIDRA_CAST<float *>((this + 0x120)) +
|
|
*GHIDRA_CAST<float *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(this[0x121])) + 0x1)))) * *GHIDRA_CAST<float *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(this[0x121])) + 0x1))));
|
|
}
|
|
|
|
// 00a159d0
|
|
uint32_t KAGE_Filesys_FileManager::GetPrimaryFilePathHash(uint8_t *filePath)
|
|
{
|
|
uint32_t hash;
|
|
uint32_t normalizedCh;
|
|
uint8_t lowerCh;
|
|
uint8_t ch;
|
|
|
|
if (filePath == GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
return 0;
|
|
}
|
|
hash = 0x1505;
|
|
ch = *filePath;
|
|
while (ch != 0) {
|
|
filePath = filePath + 1;
|
|
lowerCh = ch + 0x20;
|
|
if (0x19 < (uint8_t)(ch + 0xbf)) {
|
|
lowerCh = ch;
|
|
}
|
|
normalizedCh = GHIDRA_UINT(lowerCh);
|
|
if (lowerCh == 0x5c) {
|
|
normalizedCh = 0x2f;
|
|
}
|
|
hash = hash * 0x21 + normalizedCh;
|
|
ch = *filePath;
|
|
}
|
|
return hash;
|
|
}
|
|
|
|
// 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;
|
|
}
|