#include "classes.h" // 00829670 RoomConfig::~RoomConfig() { uint uVar1; uint stageIndex; RoomConfig *this_00; void *local_10; undefined1 *puStack_c; undefined4 uStack_8; uStack_8 = 0xffffffff; puStack_c = &LAB_00b01ae0; local_10 = ExceptionList; uVar1 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U; ExceptionList = &local_10; stageIndex = 0; this_00 = this; do { (GHIDRA_CAST((GHIDRA_CAST(this_00))))->RoomConfig_Stage::unload(); stageIndex = stageIndex + 1; this_00 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this_00)) + 0xc4)))); } while (stageIndex < 0x25); FUN_0082e050(uVar1); _eh_vector_destructor_iterator_(this + 1,0x1c,0x10,FUN_0069d1f0); std::vector<28byte_string>::_Tidy(); _eh_vector_destructor_iterator_(this,0xc4,0x25,RoomConfig_Stage::game_destructor); ExceptionList = local_10; return; } // 00829710 void RoomConfig::LoadRoomFromXmlFile() { uint uVar1; int *file; int iVar2; byte *text; void *pvVar3; byte *in_EDX; byte *pbVar4; undefined1 xmlDoc [48]; undefined1 auStack_100ec [65560]; RoomConfig_Room parsedRoom; undefined1 local_74 [20]; void *local_60; undefined4 local_50; uint local_4c; int local_3c; undefined4 local_38; void *local_34; short local_30; undefined4 local_28; undefined4 local_24; undefined4 local_20; uint local_14; void *local_10; undefined1 *puStack_c; undefined4 local_8; puStack_c = &LAB_00b01b18; local_10 = ExceptionList; uVar1 = __security_cookie ^ GHIDRA_UINT((local_74 + 0x70)); ExceptionList = &local_10; local_50 = 0; local_4c = 0xf; local_60 = (void *)0x0; local_3c = 0; local_38 = 0; local_34 = (void *)0x0; local_30 = 0; local_20 = 0; local_24 = 0; local_8 = 0; (*GHIDRA_CAST((GHIDRA_CAST(&(local_74)) + 0x0))) = 0; local_28 = 0; if (0xf < *GHIDRA_CAST((in_EDX + 0x14))) { in_EDX = *GHIDRA_CAST(in_EDX); } local_14 = uVar1; file = (GHIDRA_CAST((&PTR_vftable_00c37a10)))->FileSystem::Open(in_EDX,GHIDRA_CAST(0x0)); if (file == GHIDRA_CAST(0x0)) { KAGE_LogMessage(1,GHIDRA_CAST("[error] Could not open %s\n")); FUN_00829920(local_74); if (local_4c < 0x10) { ExceptionList = local_10; return; } uVar1 = local_4c + 1; pvVar3 = local_60; if (uVar1 < 0x1000) goto LAB_00829805; pvVar3 = *(void **)(GHIDRA_CAST(local_60) + -4); iVar2 = GHIDRA_INT(local_60) - GHIDRA_INT(pvVar3); } else { iVar2 = (**(code **)(*file + 4))(uVar1); text = operator_new_tracked(iVar2 + 1); (**(code **)(*file + 0x14))(text,1,iVar2); text[iVar2] = 0; (**(code **)*file)(1); FUN_00413b90(); (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 1; iVar2 = 0x829878; pbVar4 = text; (GHIDRA_CAST((xmlDoc)))->rapidxml::xml_document::parse(text); pvVar3 = (GHIDRA_CAST((xmlDoc)))->xml_node::first_node(&DAT_00b1c17c,iVar2,(byte)pbVar4); RoomConfigRoom::ParseXml(&parsedRoom,pvVar3,GHIDRA_CAST(local_74)); (GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(&(parsedRoom)) + 0x14))))))->std::string::_Tidy_deallocate(); (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 2; (GHIDRA_CAST((auStack_100ec)))->xml_memory_pool::clear(); local_8 = CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),3); tracked_alloc(1,text,0); FUN_00829920(local_74); if (local_4c < 0x10) { ExceptionList = local_10; return; } uVar1 = local_4c + 1; pvVar3 = local_60; if (uVar1 < 0x1000) goto LAB_00829805; pvVar3 = *(void **)(GHIDRA_CAST(local_60) + -4); iVar2 = GHIDRA_INT(local_60) - GHIDRA_INT(pvVar3); } uVar1 = local_4c + 0x24; if (0x1f < iVar2 - 4U) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } LAB_00829805: operator_delete(pvVar3,uVar1); ExceptionList = local_10; return; } // 00829a10 int RoomConfig::get_door_from_position(short posX, int shape) { int doorSlot; undefined2 in_register_00000006; int doorSlot; int in_EDX; doorSlot = CONCAT22(in_register_00000006,posX); doorSlot = -1; if ((doorSlot == -1) || (doorSlot == 0xc)) { if (in_EDX == 3) { return 0; } if (((doorSlot == -1) || (doorSlot == 0xc)) && (in_EDX == 10)) { return 4; } } if (doorSlot == 6) { if (in_EDX != -1) { if (in_EDX != 0xe) { if (in_EDX != 6) { if (in_EDX == 7) { return 3; } return -1; } if (shape == 9) { return 1; } return -1; } if (shape != 0xb) { return 3; } } return 1; } if (doorSlot != 0x13) { if ((doorSlot == 0xd) || (doorSlot == 0x1a)) { if (in_EDX == 3) { return 2; } if (((doorSlot == 0xd) || (doorSlot == 0x1a)) && (in_EDX == 10)) { doorSlot = 6; } } return doorSlot; } if (in_EDX != -1) { if (in_EDX != 0xe) { if (in_EDX != 6) { if (in_EDX == 7) { return 7; } return -1; } if (shape == 10) { return 5; } return -1; } if (shape != 0xc) { return 7; } } return 5; } // 0082a9c0 void RoomConfig::ResetStageWeights(uint stageId, int mode) { int roomOffset; uint roomIndex; int stageModeOffset; if (mode == -1) { if ((g_game == GHIDRA_CAST(0x0)) || ((g_game->_difficulty != 2 && (g_game->_difficulty != 3)))) { mode = 0; } else { mode = 1; } } stageModeOffset = mode * 0x2c + stageId * 0xc4 + 100; if ((&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8c))))[stageModeOffset + -100] == '\0') { LoadStageBinary(this,stageId,mode); return; } roomIndex = 0; if (*GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x80))) + stageModeOffset + -100)) != 0) { roomOffset = 0; do { roomOffset = roomOffset + 0x5c; roomIndex = roomIndex + 1; *GHIDRA_CAST((*GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x7c))) + stageModeOffset + -100)) + -0x28 + roomOffset)) = *(undefined4 *) (*GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x7c))) + stageModeOffset + -100)) + -0x2c + roomOffset); } while (roomIndex < *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x80))) + stageModeOffset + -100))); } return; } // 0082aa40 void RoomConfig::LoadStageBinary(uint Stage, uint Mode) { int iVar1; RoomSet RVar2; undefined4 *puVar3; byte *extraout_EAX; byte *path; int *fileHandle; RoomSet length; void *pvVar4; uint uVar5; uint allocSize; RoomConfig_Stage *local_EDI_80; uint *puVar6; int magic; int *file; uint local_7c; uint local_78; uint *puStack_74; undefined1 isLoaded; void *redirectedPath [4]; uint uStack_5c; uint uStack_58; void *tmpString; char acStack_50 [4]; char acStack_4c [4]; char acStack_48 [8]; uint uStack_40; void *basePath [4]; undefined4 uStack_2c; uint uStack_28; uint local_24; undefined1 *puStack_20; void *local_1c; undefined1 *puStack_18; void *local_14; int roomVariant; RoomSet temp_208e6a6609; puStack_20 = GHIDRA_CAST((basePath + 0xe)); local_14 = (void *)0xffffffff; puStack_18 = &LAB_00b01c02; local_1c = ExceptionList; local_24 = __security_cookie ^ GHIDRA_UINT((basePath + 0xb)); local_7c = Stage; local_78 = Mode; local_EDI_80 = GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x0))) + Stage * 0xc4)); if (Mode == 0xffffffff) { if ((g_game == GHIDRA_CAST(0x0)) || ((g_game->_difficulty != 2 && (g_game->_difficulty != 3)))) { local_78 = 0; } else { local_78 = 1; } } temp_208e6a6609 = (RoomSet)(local_EDI_80 + local_78 * 0xb + 0x19); if (local_EDI_80[local_78 * 0xb + 0x1d] == (RoomConfig_Stage)0x0) { return; } ExceptionList = &local_1c; (GHIDRA_CAST((local_EDI_80)))->RoomConfigStage::GetDisplayName(GHIDRA_CAST(&tmpString),0x14); local_14 = (void *)0x0; KAGE_LogMessage(1,GHIDRA_CAST("[RoomConfig] load stage %d: %s (mode %d)\n")); local_14 = (void *)0xffffffff; if (0xf < uStack_40) { uVar5 = uStack_40 + 1; pvVar4 = tmpString; if (0xfff < uVar5) { pvVar4 = *(void **)(GHIDRA_CAST(tmpString) + -4); uVar5 = uStack_40 + 0x24; if (0x1f < GHIDRA_UINT((GHIDRA_INT(tmpString) + (-4 - GHIDRA_INT(pvVar4))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(pvVar4,uVar5); } RVar2 = *GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x10)); uStack_2c = 0; uStack_28 = 0xf; basePath[0] = (void *)0x0; length = (RoomSet)(GHIDRA_INT(RVar2) - 3U); if (GHIDRA_UINT(RVar2) < GHIDRA_INT(RVar2) - 3U) { length = RVar2; } RVar2 = temp_208e6a6609; if (0xf < GHIDRA_UINT(*GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x14)))) { RVar2 = *GHIDRA_CAST(temp_208e6a6609); } (GHIDRA_CAST((GHIDRA_CAST(basePath))))->std::string::assign(GHIDRA_CAST(RVar2),GHIDRA_UINT(length)); local_14 = (void *)0x1; puVar3 = (GHIDRA_CAST((GHIDRA_CAST(basePath))))->std::string::append(&UNK_00b6cb40,3); tmpString = (void *)*puVar3; acStack_50 = (char [4])puVar3[1]; acStack_4c = (char [4])puVar3[2]; (*GHIDRA_CAST((GHIDRA_CAST(&(acStack_48)) + 0x0))) = puVar3[3]; unique0x0000a400 = *GHIDRA_CAST((puVar3 + 4)); puVar3[4] = 0; puVar3[5] = 0xf; *GHIDRA_CAST(puVar3) = 0; (*GHIDRA_CAST((GHIDRA_CAST(&(local_14)) + 0x0))) = 3; if (0xf < uStack_28) { uVar5 = uStack_28 + 1; pvVar4 = basePath[0]; if (0xfff < uVar5) { pvVar4 = *(void **)(GHIDRA_INT(basePath[0]) + -4); uVar5 = uStack_28 + 0x24; if (0x1f < GHIDRA_UINT((GHIDRA_INT(basePath[0]) + (-4 - GHIDRA_INT(pvVar4))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(pvVar4,uVar5); } uStack_2c = 0; uStack_28 = 0xf; basePath[0] = (void *)(GHIDRA_UINT(basePath[0]) & 0xffffff00); ModManager::TryRedirectPath (&g_manager->_modManager,GHIDRA_CAST(redirectedPath),GHIDRA_CAST(&tmpString)); (*GHIDRA_CAST((GHIDRA_CAST(&(local_14)) + 0x0))) = 4; path = extraout_EAX; if (0xf < *GHIDRA_CAST((extraout_EAX + 0x14))) { path = *GHIDRA_CAST(extraout_EAX); } fileHandle = (GHIDRA_CAST((&PTR_vftable_00c37a10)))->FileSystem::Open(path,GHIDRA_CAST(0x0)); (*GHIDRA_CAST((GHIDRA_CAST(&(local_14)) + 0x0))) = 3; file = fileHandle; if (0xf < uStack_58) { uVar5 = uStack_58 + 1; pvVar4 = redirectedPath[0]; if (0xfff < uVar5) { pvVar4 = *(void **)(GHIDRA_INT(redirectedPath[0]) + -4); uVar5 = uStack_58 + 0x24; if (0x1f < GHIDRA_UINT((GHIDRA_INT(redirectedPath[0]) + (-4 - GHIDRA_INT(pvVar4))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(pvVar4,uVar5); } uStack_5c = 0; uStack_58 = 0xf; redirectedPath[0] = (void *)(GHIDRA_UINT(redirectedPath[0]) & 0xffffff00); if (fileHandle != GHIDRA_CAST(0x0)) { (GHIDRA_CAST(((void *)temp_208e6a6609)))->RoomConfigMode::Clear(); (**(code **)(*fileHandle + 0x14))(&magic,1,4); if (magic == 0x31425453) { (**(code **)(*fileHandle + 0x14))(GHIDRA_INT(temp_208e6a6609) + 0x1c,4,1); if (*GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x1c)) != 0) { KAGE_LogMessage(1,GHIDRA_CAST("allocate %d rooms.\n")); uVar5 = *GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x1c)); puStack_74 = GHIDRA_CAST(0x0); allocSize = -GHIDRA_UINT((GHIDRA_INT(((ulonglong)uVar5 * 0x5c >> 0x20)) != 0)) | GHIDRA_UINT(((ulonglong)uVar5 * 0x5c)); puStack_74 = operator_new_tracked(-GHIDRA_UINT((0xfffffffb < allocSize)) | allocSize + 4); (*GHIDRA_CAST((GHIDRA_CAST(&(local_14)) + 0x0))) = 5; if (puStack_74 == GHIDRA_CAST(0x0)) { puVar6 = GHIDRA_CAST(0x0); } else { *puStack_74 = uVar5; puVar6 = puStack_74 + 1; _eh_vector_constructor_iterator_ (puVar6,0x5c,uVar5,GHIDRA_CAST<_func_void_void_ptr *>(&UNK_00828b20),RoomConfigRoom::dtor); } (*GHIDRA_CAST((GHIDRA_CAST(&(local_14)) + 0x0))) = 3; *GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x18)) = puVar6; uVar5 = 0; if (*GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x1c)) != 0) { puStack_74 = GHIDRA_CAST(0x0); do { ReadRoom((void *)temp_208e6a6609,uVar5,local_7c,file); *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x18)) + 4 + GHIDRA_INT(puStack_74))) = local_78; RoomSet::GetVariantSet (GHIDRA_CAST(temp_208e6a6609), *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x18)) + 8 + GHIDRA_INT(puStack_74)))); VariantRanges::Insert (*(undefined4 *) (*GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x18)) + 0xc + GHIDRA_INT(puStack_74))); iVar1 = *GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x18)); switch(local_7c) { case 1: case 2: case 3: roomVariant = *GHIDRA_CAST((GHIDRA_CAST(puStack_74) + iVar1 + 0xc)); if ((roomVariant == 0x25b) || (roomVariant == 0x2cc)) { puVar6 = GHIDRA_CAST((GHIDRA_INT(puStack_74) + iVar1 + 0x4c)); *puVar6 = *puVar6 | 4; } break; case 0x1d: case 0x1e: if ((*GHIDRA_CAST((GHIDRA_CAST(puStack_74) + iVar1 + 8)) == 1) && (*GHIDRA_CAST((GHIDRA_CAST(puStack_74) + iVar1 + 0x10)) == 0x1f)) { puVar6 = GHIDRA_CAST((GHIDRA_INT(puStack_74) + iVar1 + 0x4c)); *puVar6 = *puVar6 | 2; } } puStack_74 = puStack_74 + 0x17; uVar5 = uVar5 + 1; } while (uVar5 < *GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x1c))); } fileHandle = file; } (**(code **)*fileHandle)(1); (GHIDRA_CAST((&g_manager->_modManager)))->ModManager::LoadModRooms(local_7c,local_78); *GHIDRA_CAST((GHIDRA_CAST(temp_208e6a6609) + 0x28)) = 1; isLoaded = 1; goto LAB_0082ae11; } } isLoaded = 0; LAB_0082ae11: if (0xf < uStack_40) { uVar5 = uStack_40 + 1; pvVar4 = tmpString; if (0xfff < uVar5) { pvVar4 = *(void **)(GHIDRA_CAST(tmpString) + -4); uVar5 = uStack_40 + 0x24; if (0x1f < GHIDRA_UINT((GHIDRA_INT(tmpString) + (-4 - GHIDRA_INT(pvVar4))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(pvVar4,uVar5); } ExceptionList = local_1c; return; } // 0082aea0 void RoomConfig::ReadRoom(void *stage, int roomIndex, int stageId, void *file) { ushort spawnCount; uint uVar1; int *roomName; uint doorSlot; void *pvVar2; undefined4 *spawnInit; int *nameBuf; byte *entryCountPtr; char entryCountCopy; int entryType; int *fileLocal; int *room; int iVar3; int roomSubtype; int roomType; uint spawnIndex; float entryWeight; int roomWeight; int roomVariant; undefined2 entrySubtype [2]; undefined2 entryVariant [2]; ushort entryTypeRaw [2]; undefined2 spawnY [2]; undefined2 spawnX [2]; int local_24; int local_20; ushort nameLength [3]; byte roomShape; undefined1 roomHeight; undefined1 roomWidth; byte roomDifficulty; byte local_11; void *local_10; undefined1 *puStack_c; undefined4 local_8; byte entryCount; fileLocal = file; local_8 = 0xffffffff; puStack_c = &LAB_00b01c56; local_10 = ExceptionList; uVar1 = __security_cookie ^ GHIDRA_UINT((nameLength + 0xc)); ExceptionList = &local_10; room = GHIDRA_CAST((roomIndex * 0x5c + *GHIDRA_CAST((GHIDRA_CAST(stage) + 0x18)))); *room = stageId; (**(code **)(*GHIDRA_CAST(file) + 0x14))(&roomType,4,1,uVar1); (**(code **)(*fileLocal + 0x14))(&roomVariant,4,1); (**(code **)(*fileLocal + 0x14))(&roomSubtype,4,1); (**(code **)(*fileLocal + 0x14))(&roomDifficulty,1,1); (**(code **)(*fileLocal + 0x14))(nameLength,2,1); roomName = room + 5; if (nameLength[0] == 0) { if (0xf < GHIDRA_UINT(room[10])) { roomName = GHIDRA_CAST(*roomName); } room[9] = 0; *GHIDRA_CAST(roomName) = '\0'; } else { uVar1 = GHIDRA_UINT(nameLength[0]); if (GHIDRA_UINT(room[9]) < uVar1) { (GHIDRA_CAST((GHIDRA_CAST(roomName))))->std::string::append_n(uVar1 - room[9],0); } else { nameBuf = roomName; if (0xf < GHIDRA_UINT(room[10])) { nameBuf = GHIDRA_CAST(*roomName); } room[9] = uVar1; *GHIDRA_CAST((GHIDRA_CAST(nameBuf) + uVar1)) = '\0'; } if (0xf < GHIDRA_UINT(room[10])) { roomName = GHIDRA_CAST(*roomName); } (**(code **)(*fileLocal + 0x14))(roomName,1,nameLength[0]); } (**(code **)(*fileLocal + 0x14))(&roomWeight,4,1); (**(code **)(*fileLocal + 0x14))(&roomWidth,1,1); (**(code **)(*fileLocal + 0x14))(&roomHeight,1,1); (**(code **)(*fileLocal + 0x14))(&roomShape,1,1); room[2] = roomType; room[0x16] = roomVariant; room[3] = roomVariant; room[4] = roomSubtype; room[0xb] = GHIDRA_UINT(roomDifficulty); room[0xd] = roomWeight; room[0xc] = roomWeight; *GHIDRA_CAST((GHIDRA_CAST(room) + 0x46)) = roomWidth; *GHIDRA_CAST((GHIDRA_CAST(room) + 0x47)) = roomHeight; room[0x12] = GHIDRA_UINT(roomShape); room[0x13] = 0; (**(code **)(*fileLocal + 0x14))(GHIDRA_INT(&stageId) + 3,1,1); (**(code **)(*fileLocal + 0x14))(room + 0x11,2,1); spawnCount = *GHIDRA_CAST((room + 0x11)); uVar1 = 0; if ((*GHIDRA_CAST((GHIDRA_CAST(&(stageId)) + 0x3))) != '\0') { do { (**(code **)(*fileLocal + 0x14))(&local_24,2,1); (**(code **)(*fileLocal + 0x14))(&local_20,2,1); (**(code **)(*fileLocal + 0x14))(&local_11,1,1); if (local_11 != 0) { doorSlot = get_door_from_position((short)local_24,room[0x12]); if (-1 < GHIDRA_INT(doorSlot)) { if (7 < doorSlot) { LAB_0082b2de: /* WARNING: Subroutine does not return */ std::bitset::_Xran(); } room[(doorSlot >> 5) + 0xe] = room[(doorSlot >> 5) + 0xe] | 1 << ((byte)doorSlot & 0x1f); } } uVar1 = uVar1 + 1; } while (uVar1 < GHIDRA_UINT(stageId) >> 0x18); spawnCount = *GHIDRA_CAST((room + 0x11)); } if (spawnCount != 0) { uVar1 = GHIDRA_UINT(spawnCount); pvVar2 = operator_new_tracked(uVar1 * 0x10); if (pvVar2 == (void *)0x0) { pvVar2 = (void *)0x0; } else if (uVar1 != 0) { spawnInit = GHIDRA_CAST((GHIDRA_INT(pvVar2) + 4)); do { spawnInit[-1] = 0; *spawnInit = 0; *GHIDRA_CAST((spawnInit + 1)) = 0; spawnInit[2] = 0; uVar1 = uVar1 - 1; spawnInit = spawnInit + 4; } while (uVar1 != 0); } local_8 = 0xffffffff; room[0x10] = GHIDRA_INT(pvVar2); spawnIndex = 0; if ((short)room[0x11] != 0) { local_20 = 0; do { iVar3 = local_20; local_24 = room[0x10]; (**(code **)(*fileLocal + 0x14))(spawnX,2,1); (**(code **)(*fileLocal + 0x14))(spawnY,2,1); entryCountPtr = GHIDRA_CAST((local_24 + 8 + iVar3)); (**(code **)(*fileLocal + 0x14))(entryCountPtr,1,1); *GHIDRA_CAST((iVar3 + local_24)) = spawnX[0]; *GHIDRA_CAST((iVar3 + 2 + local_24)) = spawnY[0]; entryCount = *GHIDRA_CAST((local_24 + 8 + iVar3)); entryCountCopy = '\0'; if (entryCount != 0) { pvVar2 = operator_new_tracked(GHIDRA_UINT(entryCount) * 0xc); entryCountCopy = *GHIDRA_CAST((iVar3 + 8 + local_24)); *(void **)(iVar3 + 4 + local_24) = pvVar2; } uVar1 = 0; local_11 = 0; if (entryCountCopy != '\0') { do { iVar3 = *GHIDRA_CAST((local_20 + 4 + local_24)); (**(code **)(*GHIDRA_CAST(file) + 0x14))(entryTypeRaw,2,1); (**(code **)(*GHIDRA_CAST(file) + 0x14))(entryVariant,2,1); (**(code **)(*GHIDRA_CAST(file) + 0x14))(entrySubtype,2,1); (**(code **)(*GHIDRA_CAST(file) + 0x14))(&entryWeight,4,1); *GHIDRA_CAST((iVar3 + uVar1 * 0xc)) = GHIDRA_UINT(entryTypeRaw[0]); *GHIDRA_CAST((iVar3 + 4 + uVar1 * 0xc)) = entryVariant[0]; *GHIDRA_CAST((iVar3 + 6 + uVar1 * 0xc)) = entrySubtype[0]; *GHIDRA_CAST((iVar3 + 8 + uVar1 * 0xc)) = entryWeight; *GHIDRA_CAST((local_20 + 0xc + local_24)) = entryWeight + *GHIDRA_CAST((local_20 + 0xc + local_24)); entryType = *GHIDRA_CAST((iVar3 + uVar1 * 0xc)); if (entryType == 0x3ca) { if ((*GHIDRA_CAST((iVar3 + 4 + uVar1 * 0xc)) == 2) && (doorSlot = get_door_from_position(*GHIDRA_CAST((local_20 + local_24)),room[0x12]), -1 < GHIDRA_INT(doorSlot))) { if (doorSlot < 8) { room[(doorSlot >> 5) + 0xf] = room[(doorSlot >> 5) + 0xf] | 1 << ((byte)doorSlot & 0x1f); entryType = *GHIDRA_CAST((iVar3 + uVar1 * 0xc)); goto LAB_0082b280; } goto LAB_0082b2de; } } else { LAB_0082b280: if ((entryType == 0x1194) && (*GHIDRA_CAST((iVar3 + 4 + uVar1 * 0xc)) == 0)) { room[0x13] = room[0x13] | 0x80; } } local_11 = local_11 + 1; uVar1 = GHIDRA_UINT(local_11); } while (local_11 < *entryCountPtr); fileLocal = file; iVar3 = local_20; } local_20 = iVar3 + 0x10; spawnIndex = spawnIndex + 1; } while (spawnIndex < *GHIDRA_CAST((room + 0x11))); } } ExceptionList = local_10; return; } // 0082b2f0 byte RoomConfig::LoadStagesXml(byte *path) { RoomConfig *destString = this; byte bVar1; uint uVar2; int *file; int fileSize; byte *text; void *node; void *pvVar3; std_string *rootBuffer; byte *strCursor; byte *literalCursor; char *keyLiteral; byte *attrText; std_string *destString; qword *allocCounter; undefined4 *attr; bool isLess; int stageId; std_string stageName; std_string playerSpotPath; std_string bossSpotPath; std_string stageSuffix; std_string normalMode; std_string greedMode; undefined1 xmlDoc [48]; undefined1 xmlMemoryPool [65564]; std_string roomsRoot; std_string greedRoot; std_string concatResult; std_string bossGfxRoot; void *savedExceptionList; undefined1 *puStack_18; undefined4 ehState; qword oldAllocBytes; ehState = 0xffffffff; puStack_18 = &LAB_00b01cdf; savedExceptionList = ExceptionList; uVar2 = __security_cookie ^ GHIDRA_UINT((xmlMemoryPool + 0x10090)); ExceptionList = &savedExceptionList; file = (GHIDRA_CAST((&PTR_vftable_00c37a10)))->FileSystem::Open(path,GHIDRA_CAST(0x0)); if (file == GHIDRA_CAST(0x0)) { bVar1 = 0; } else { fileSize = (**(code **)(*file + 4))(uVar2); text = operator_new_tracked(fileSize + 1); (**(code **)(*file + 0x14))(text,1,fileSize); text[fileSize] = 0; (**(code **)*file)(1); FUN_00413b90(); ehState = 0; uVar2 = 0x82b3bf; attrText = text; (GHIDRA_CAST((xmlDoc)))->rapidxml::xml_document::parse(text); bVar1 = (byte)attrText; node = (GHIDRA_CAST((xmlDoc)))->xml_node::first_node(GHIDRA_CAST("stages"),uVar2,bVar1); pvVar3 = (GHIDRA_CAST((node)))->xml_node::first_attribute(&DAT_00b66f40,uVar2,bVar1); if (pvVar3 == (void *)0x0) { attrText = &DAT_00b6cbb4; } else { attrText = &g_xmlNullStr; if (*GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 4)) != GHIDRA_CAST(0x0)) { attrText = *GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 4)); } } roomsRoot._size = 0; roomsRoot._capacity = 0xf; roomsRoot._buf[0] = '\0'; roomsRoot._buf[1] = '\0'; roomsRoot._buf[2] = '\0'; roomsRoot._buf[3] = '\0'; strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); uVar2 = GHIDRA_INT(strCursor) - GHIDRA_INT((attrText + 1)); (GHIDRA_CAST((roomsRoot._buf)))->std::string::assign(attrText,uVar2); (*GHIDRA_CAST((GHIDRA_CAST(&(ehState)) + 0x0))) = 1; pvVar3 = (GHIDRA_CAST((node)))->xml_node::first_attribute(GHIDRA_CAST("greedroot"),GHIDRA_UINT(attrText),(byte)uVar2); if (pvVar3 == (void *)0x0) { attrText = GHIDRA_CAST("rooms/greed/"); } else { attrText = &g_xmlNullStr; if (*GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 4)) != GHIDRA_CAST(0x0)) { attrText = *GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 4)); } } greedRoot._size = 0; greedRoot._capacity = 0xf; greedRoot._buf[0] = '\0'; greedRoot._buf[1] = '\0'; greedRoot._buf[2] = '\0'; greedRoot._buf[3] = '\0'; strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); uVar2 = GHIDRA_INT(strCursor) - GHIDRA_INT((attrText + 1)); (GHIDRA_CAST((greedRoot._buf)))->std::string::assign(attrText,uVar2); (*GHIDRA_CAST((GHIDRA_CAST(&(ehState)) + 0x0))) = 2; pvVar3 = (GHIDRA_CAST((node)))->xml_node::first_attribute(GHIDRA_CAST("bossgfxroot"),GHIDRA_UINT(attrText),(byte)uVar2); bossGfxRoot._size = 0; bossGfxRoot._capacity = 0xf; bossGfxRoot._buf[0] = '\0'; bossGfxRoot._buf[1] = '\0'; bossGfxRoot._buf[2] = '\0'; bossGfxRoot._buf[3] = '\0'; attrText = &g_xmlNullStr; if (*GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 4)) != GHIDRA_CAST(0x0)) { attrText = *GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 4)); } strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); uVar2 = GHIDRA_INT(strCursor) - GHIDRA_INT((attrText + 1)); (GHIDRA_CAST((bossGfxRoot._buf)))->std::string::assign(attrText,uVar2); for (node = (GHIDRA_CAST((node)))->xml_node::first_node(GHIDRA_CAST("stage"),GHIDRA_INT(attrText),(byte)uVar2); node != (void *)0x0; node = *(void **)(GHIDRA_CAST(node) + 0x2c)) { stageName._size = 0; stageName._capacity = 0xf; stageName._buf[0] = '\0'; stageName._buf[1] = '\0'; stageName._buf[2] = '\0'; stageName._buf[3] = '\0'; playerSpotPath._capacity = 0xf; playerSpotPath._buf[0] = '\0'; playerSpotPath._buf[1] = '\0'; playerSpotPath._buf[2] = '\0'; playerSpotPath._buf[3] = '\0'; bossSpotPath._capacity = 0xf; bossSpotPath._buf[0] = '\0'; bossSpotPath._buf[1] = '\0'; bossSpotPath._buf[2] = '\0'; bossSpotPath._buf[3] = '\0'; stageSuffix._size = 0; stageSuffix._capacity = 0xf; stageSuffix._buf[0] = '\0'; stageSuffix._buf[1] = '\0'; stageSuffix._buf[2] = '\0'; stageSuffix._buf[3] = '\0'; (*GHIDRA_CAST((GHIDRA_CAST(&(ehState)) + 0x0))) = 7; _eh_vector_constructor_iterator_(&normalMode,0x2c,2,RoomConfigMode::ctor,RoomConfigMode::dtor) ; (*GHIDRA_CAST((GHIDRA_CAST(&(ehState)) + 0x0))) = 8; attr = *GHIDRA_CAST((GHIDRA_CAST(node) + 0x20)); if (attr != GHIDRA_CAST(0x0)) { do { attrText = GHIDRA_CAST(*attr); literalCursor = s_id; strCursor = &g_xmlNullStr; if (attrText != GHIDRA_CAST(0x0)) { strCursor = attrText; } do { bVar1 = *strCursor; isLess = bVar1 < *literalCursor; if (bVar1 != *literalCursor) { LAB_0082b611: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_0082b616; } if (bVar1 == 0) break; bVar1 = strCursor[1]; isLess = bVar1 < literalCursor[1]; if (bVar1 != literalCursor[1]) goto LAB_0082b611; strCursor = strCursor + 2; literalCursor = literalCursor + 2; } while (bVar1 != 0); uVar2 = 0; LAB_0082b616: if (uVar2 == 0) { attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } stageId = atoi(GHIDRA_CAST(attrText)); } else { literalCursor = s_name; strCursor = &g_xmlNullStr; if (attrText != GHIDRA_CAST(0x0)) { strCursor = attrText; } do { bVar1 = *strCursor; isLess = bVar1 < *literalCursor; if (bVar1 != *literalCursor) { LAB_0082b670: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_0082b675; } if (bVar1 == 0) break; bVar1 = strCursor[1]; isLess = bVar1 < literalCursor[1]; if (bVar1 != literalCursor[1]) goto LAB_0082b670; literalCursor = literalCursor + 2; strCursor = strCursor + 2; } while (bVar1 != 0); uVar2 = 0; LAB_0082b675: if (uVar2 == 0) { attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); uVar2 = GHIDRA_INT(strCursor) - GHIDRA_INT((attrText + 1)); destString = &stageName; LAB_0082bab2: (GHIDRA_CAST((destString->_buf)))->std::string::assign(attrText,uVar2); } else { literalCursor = &DAT_00b66e0c; strCursor = &g_xmlNullStr; if (attrText != GHIDRA_CAST(0x0)) { strCursor = attrText; } do { bVar1 = *strCursor; isLess = bVar1 < *literalCursor; if (bVar1 != *literalCursor) { LAB_0082b6d4: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_0082b6d9; } if (bVar1 == 0) break; bVar1 = strCursor[1]; isLess = bVar1 < literalCursor[1]; if (bVar1 != literalCursor[1]) goto LAB_0082b6d4; strCursor = strCursor + 2; literalCursor = literalCursor + 2; } while (bVar1 != 0); uVar2 = 0; LAB_0082b6d9: if (uVar2 == 0) { attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); destString = GHIDRA_CAST((strCursor + -GHIDRA_INT((attrText + 1)))); if (GHIDRA_CAST((0x7fffffff - roomsRoot._size)) < destString) { LAB_0082bd57: /* WARNING: Subroutine does not return */ std::string::_Xlen(); } rootBuffer = &roomsRoot; if (0xf < roomsRoot._capacity) { rootBuffer = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(roomsRoot._buf))) + 0x0))); } (GHIDRA_CAST((concatResult._buf)))->std::string::concat(GHIDRA_INT(destString),destString,GHIDRA_CAST(rootBuffer), roomsRoot._size,attrText,GHIDRA_UINT(destString)); (GHIDRA_CAST((normalMode._buf)))->std::string::_Tidy_deallocate(); normalMode._buf[0] = concatResult._buf[0]; normalMode._buf[1] = concatResult._buf[1]; normalMode._buf[2] = concatResult._buf[2]; normalMode._buf[3] = concatResult._buf[3]; normalMode._buf[4] = concatResult._buf[4]; normalMode._buf[5] = concatResult._buf[5]; normalMode._buf[6] = concatResult._buf[6]; normalMode._buf[7] = concatResult._buf[7]; normalMode._buf[8] = concatResult._buf[8]; normalMode._buf[9] = concatResult._buf[9]; normalMode._buf[10] = concatResult._buf[10]; normalMode._buf[0xb] = concatResult._buf[0xb]; normalMode._buf[0xc] = concatResult._buf[0xc]; normalMode._buf[0xd] = concatResult._buf[0xd]; normalMode._buf[0xe] = concatResult._buf[0xe]; normalMode._buf[0xf] = concatResult._buf[0xf]; attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); destString = GHIDRA_CAST((strCursor + -GHIDRA_INT((attrText + 1)))); if (GHIDRA_CAST((0x7fffffff - greedRoot._size)) < destString) goto LAB_0082bd57; rootBuffer = &greedRoot; if (0xf < greedRoot._capacity) { rootBuffer = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(greedRoot._buf))) + 0x0))); } (GHIDRA_CAST((concatResult._buf)))->std::string::concat(GHIDRA_INT(destString),destString,GHIDRA_CAST(rootBuffer), greedRoot._size,attrText,GHIDRA_UINT(destString)); (GHIDRA_CAST((greedMode._buf)))->std::string::_Tidy_deallocate(); greedMode._buf[0] = concatResult._buf[0]; greedMode._buf[1] = concatResult._buf[1]; greedMode._buf[2] = concatResult._buf[2]; greedMode._buf[3] = concatResult._buf[3]; greedMode._buf[4] = concatResult._buf[4]; greedMode._buf[5] = concatResult._buf[5]; greedMode._buf[6] = concatResult._buf[6]; greedMode._buf[7] = concatResult._buf[7]; greedMode._buf[8] = concatResult._buf[8]; greedMode._buf[9] = concatResult._buf[9]; greedMode._buf[10] = concatResult._buf[10]; greedMode._buf[0xb] = concatResult._buf[0xb]; greedMode._buf[0xc] = concatResult._buf[0xc]; greedMode._buf[0xd] = concatResult._buf[0xd]; greedMode._buf[0xe] = concatResult._buf[0xe]; greedMode._buf[0xf] = concatResult._buf[0xf]; greedMode._size = concatResult._size; greedMode._capacity = concatResult._capacity; } else { keyLiteral = "playerspot"; strCursor = &g_xmlNullStr; if (attrText != GHIDRA_CAST(0x0)) { strCursor = attrText; } do { bVar1 = *strCursor; isLess = bVar1 < (byte)*keyLiteral; if (bVar1 != *keyLiteral) { LAB_0082b800: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_0082b805; } if (bVar1 == 0) break; bVar1 = strCursor[1]; isLess = bVar1 < (byte)keyLiteral[1]; if (bVar1 != keyLiteral[1]) goto LAB_0082b800; strCursor = strCursor + 2; keyLiteral = keyLiteral + 2; } while (bVar1 != 0); uVar2 = 0; LAB_0082b805: if (uVar2 == 0) { attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); destString = GHIDRA_CAST((strCursor + -GHIDRA_INT((attrText + 1)))); if (GHIDRA_CAST((0x7fffffff - bossGfxRoot._size)) < destString) goto LAB_0082bd57; rootBuffer = &bossGfxRoot; if (0xf < bossGfxRoot._capacity) { rootBuffer = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(bossGfxRoot._buf))) + 0x0))); } (GHIDRA_CAST((concatResult._buf)))->std::string::concat(GHIDRA_INT(destString),destString,GHIDRA_CAST(rootBuffer), bossGfxRoot._size,attrText,GHIDRA_UINT(destString)); if (0xf < playerSpotPath._capacity) { uVar2 = playerSpotPath._capacity + 1; pvVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)playerSpotPath._buf)) + 0x0))); if (0xfff < uVar2) { pvVar3 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(playerSpotPath._buf)) + 0x0))) + -4); uVar2 = playerSpotPath._capacity + 0x24; if (0x1f < ((*GHIDRA_CAST((GHIDRA_CAST(&(playerSpotPath._buf)) + 0x0))) - GHIDRA_INT(pvVar3)) - 4U) goto LAB_0082bce0; } operator_delete(pvVar3,uVar2); } playerSpotPath._buf[0] = concatResult._buf[0]; playerSpotPath._buf[1] = concatResult._buf[1]; playerSpotPath._buf[2] = concatResult._buf[2]; playerSpotPath._buf[3] = concatResult._buf[3]; playerSpotPath._capacity = concatResult._capacity; } else { keyLiteral = "bossspot"; strCursor = &g_xmlNullStr; if (attrText != GHIDRA_CAST(0x0)) { strCursor = attrText; } do { bVar1 = *strCursor; isLess = bVar1 < (byte)*keyLiteral; if (bVar1 != *keyLiteral) { LAB_0082b8e6: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_0082b8eb; } if (bVar1 == 0) break; bVar1 = strCursor[1]; isLess = bVar1 < (byte)keyLiteral[1]; if (bVar1 != keyLiteral[1]) goto LAB_0082b8e6; strCursor = strCursor + 2; keyLiteral = keyLiteral + 2; } while (bVar1 != 0); uVar2 = 0; LAB_0082b8eb: if (uVar2 == 0) { attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); destString = GHIDRA_CAST((strCursor + -GHIDRA_INT((attrText + 1)))); if (GHIDRA_CAST((0x7fffffff - bossGfxRoot._size)) < destString) goto LAB_0082bd57; rootBuffer = &bossGfxRoot; if (0xf < bossGfxRoot._capacity) { rootBuffer = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(bossGfxRoot._buf))) + 0x0))); } (GHIDRA_CAST((concatResult._buf)))->std::string::concat(GHIDRA_INT(destString),destString,GHIDRA_CAST(rootBuffer), bossGfxRoot._size,attrText,GHIDRA_UINT(destString)); if (0xf < bossSpotPath._capacity) { uVar2 = bossSpotPath._capacity + 1; pvVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)bossSpotPath._buf)) + 0x0))); if (0xfff < uVar2) { pvVar3 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(bossSpotPath._buf)) + 0x0))) + -4); uVar2 = bossSpotPath._capacity + 0x24; if (0x1f < ((*GHIDRA_CAST((GHIDRA_CAST(&(bossSpotPath._buf)) + 0x0))) - GHIDRA_INT(pvVar3)) - 4U) goto LAB_0082bce0; } operator_delete(pvVar3,uVar2); } bossSpotPath._buf[0] = concatResult._buf[0]; bossSpotPath._buf[1] = concatResult._buf[1]; bossSpotPath._buf[2] = concatResult._buf[2]; bossSpotPath._buf[3] = concatResult._buf[3]; bossSpotPath._capacity = concatResult._capacity; } else { keyLiteral = "music"; strCursor = &g_xmlNullStr; if (attrText != GHIDRA_CAST(0x0)) { strCursor = attrText; } do { bVar1 = *strCursor; isLess = bVar1 < (byte)*keyLiteral; if (bVar1 != *keyLiteral) { LAB_0082b9d0: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_0082b9d5; } if (bVar1 == 0) break; bVar1 = strCursor[1]; isLess = bVar1 < (byte)keyLiteral[1]; if (bVar1 != keyLiteral[1]) goto LAB_0082b9d0; keyLiteral = keyLiteral + 2; strCursor = strCursor + 2; } while (bVar1 != 0); uVar2 = 0; LAB_0082b9d5: if (uVar2 == 0) { attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } atoi(GHIDRA_CAST(attrText)); } else { keyLiteral = "backdrop"; strCursor = &g_xmlNullStr; if (attrText != GHIDRA_CAST(0x0)) { strCursor = attrText; } do { bVar1 = *strCursor; isLess = bVar1 < (byte)*keyLiteral; if (bVar1 != *keyLiteral) { LAB_0082ba30: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_0082ba35; } if (bVar1 == 0) break; bVar1 = strCursor[1]; isLess = bVar1 < (byte)keyLiteral[1]; if (bVar1 != keyLiteral[1]) goto LAB_0082ba30; keyLiteral = keyLiteral + 2; strCursor = strCursor + 2; } while (bVar1 != 0); uVar2 = 0; LAB_0082ba35: if (uVar2 == 0) { attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } atoi(GHIDRA_CAST(attrText)); } else { keyLiteral = "suffix"; strCursor = &g_xmlNullStr; if (attrText != GHIDRA_CAST(0x0)) { strCursor = attrText; } do { bVar1 = *strCursor; isLess = bVar1 < (byte)*keyLiteral; if (bVar1 != *keyLiteral) { LAB_0082ba87: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_0082ba8c; } if (bVar1 == 0) break; bVar1 = strCursor[1]; isLess = bVar1 < (byte)keyLiteral[1]; if (bVar1 != keyLiteral[1]) goto LAB_0082ba87; strCursor = strCursor + 2; keyLiteral = keyLiteral + 2; } while (bVar1 != 0); uVar2 = 0; LAB_0082ba8c: if (uVar2 == 0) { attrText = &g_xmlNullStr; if (GHIDRA_CAST(attr[1]) != GHIDRA_CAST(0x0)) { attrText = GHIDRA_CAST(attr[1]); } strCursor = attrText; do { bVar1 = *strCursor; strCursor = strCursor + 1; } while (bVar1 != 0); uVar2 = GHIDRA_INT(strCursor) - GHIDRA_INT((attrText + 1)); destString = &stageSuffix; goto LAB_0082bab2; } } } } } } } } } while ((attr[4] != 0) && (attr = GHIDRA_CAST(attr[6]), attr != GHIDRA_CAST(0x0))); } RoomConfigStage::operator_assign(&stageId); (*GHIDRA_CAST((GHIDRA_CAST(&(ehState)) + 0x0))) = 9; _eh_vector_destructor_iterator_(&normalMode,0x2c,2,RoomConfigMode::dtor); if (0xf < stageSuffix._capacity) { uVar2 = stageSuffix._capacity + 1; pvVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)stageSuffix._buf)) + 0x0))); if (0xfff < uVar2) { pvVar3 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(stageSuffix._buf)) + 0x0))) + -4); uVar2 = stageSuffix._capacity + 0x24; if (0x1f < ((*GHIDRA_CAST((GHIDRA_CAST(&(stageSuffix._buf)) + 0x0))) - GHIDRA_INT(pvVar3)) - 4U) goto LAB_0082bce0; } operator_delete(pvVar3,uVar2); } stageSuffix._size = 0; stageSuffix._capacity = 0xf; (*GHIDRA_CAST((GHIDRA_CAST(&(stageSuffix._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(stageSuffix._buf)) + 0x0))) & 0xffffff00; if (0xf < bossSpotPath._capacity) { uVar2 = bossSpotPath._capacity + 1; pvVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)bossSpotPath._buf)) + 0x0))); if (0xfff < uVar2) { pvVar3 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(bossSpotPath._buf)) + 0x0))) + -4); uVar2 = bossSpotPath._capacity + 0x24; if (0x1f < ((*GHIDRA_CAST((GHIDRA_CAST(&(bossSpotPath._buf)) + 0x0))) - GHIDRA_INT(pvVar3)) - 4U) goto LAB_0082bce0; } operator_delete(pvVar3,uVar2); } if (0xf < playerSpotPath._capacity) { uVar2 = playerSpotPath._capacity + 1; pvVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)playerSpotPath._buf)) + 0x0))); if (0xfff < uVar2) { pvVar3 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(playerSpotPath._buf)) + 0x0))) + -4); uVar2 = playerSpotPath._capacity + 0x24; if (0x1f < ((*GHIDRA_CAST((GHIDRA_CAST(&(playerSpotPath._buf)) + 0x0))) - GHIDRA_INT(pvVar3)) - 4U) goto LAB_0082bce0; } operator_delete(pvVar3,uVar2); } if (0xf < stageName._capacity) { uVar2 = stageName._capacity + 1; pvVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)stageName._buf)) + 0x0))); if (0xfff < uVar2) { pvVar3 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(stageName._buf)) + 0x0))) + -4); uVar2 = stageName._capacity + 0x24; if (0x1f < ((*GHIDRA_CAST((GHIDRA_CAST(&(stageName._buf)) + 0x0))) - GHIDRA_INT(pvVar3)) - 4U) goto LAB_0082bce0; } operator_delete(pvVar3,uVar2); } } (*GHIDRA_CAST((GHIDRA_CAST(&(ehState)) + 0x0))) = 2; if (0xf < bossGfxRoot._capacity) { uVar2 = bossGfxRoot._capacity + 1; node = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)bossGfxRoot._buf)) + 0x0))); if (0xfff < uVar2) { node = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(bossGfxRoot._buf)) + 0x0))) + -4); uVar2 = bossGfxRoot._capacity + 0x24; if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(bossGfxRoot._buf)) + 0x0))) + (-4 - GHIDRA_INT(node))))) goto LAB_0082bce0; } operator_delete(node,uVar2); } (*GHIDRA_CAST((GHIDRA_CAST(&(ehState)) + 0x0))) = 1; if (0xf < greedRoot._capacity) { uVar2 = greedRoot._capacity + 1; node = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)greedRoot._buf)) + 0x0))); if (0xfff < uVar2) { node = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(greedRoot._buf)) + 0x0))) + -4); uVar2 = greedRoot._capacity + 0x24; if (0x1f < ((*GHIDRA_CAST((GHIDRA_CAST(&(greedRoot._buf)) + 0x0))) - GHIDRA_INT(node)) - 4U) goto LAB_0082bce0; } operator_delete(node,uVar2); } (*GHIDRA_CAST((GHIDRA_CAST(&(ehState)) + 0x0))) = 0; if (0xf < roomsRoot._capacity) { uVar2 = roomsRoot._capacity + 1; node = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)roomsRoot._buf)) + 0x0))); if (0xfff < uVar2) { node = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(roomsRoot._buf)) + 0x0))) + -4); uVar2 = roomsRoot._capacity + 0x24; if (0x1f < ((*GHIDRA_CAST((GHIDRA_CAST(&(roomsRoot._buf)) + 0x0))) - GHIDRA_INT(node)) - 4U) { LAB_0082bce0: /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(node,uVar2); } ehState = 10; (GHIDRA_CAST((xmlMemoryPool)))->xml_memory_pool::clear(); if (g_mainHeap == (void *)0x0) { allocCounter = &g_allocatedBytesNoHeap; } else { allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if (text != GHIDRA_CAST(0x0)) { uVar2 = *GHIDRA_CAST((text + -4)); oldAllocBytes = *allocCounter; *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar2; *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocBytes) < uVar2)); free(text + -4); } bVar1 = 1; } ExceptionList = savedExceptionList; return bVar1; } // 0082bf00 byte RoomConfig::LoadCursesXml(byte *path, byte isAppend) { std_vector *psVar1; void **ppvVar2; qword qVar3; byte bVar4; uint curseCount; byte *pbVar6; int *piVar7; int iVar8; void *node; byte ****text; byte *expectedAttrChar; byte ****ppppbVar9; qword *allocCounter; byte *pbVar10; bool isCharLess; byte *pbStack_1007c; int curseId; byte ****curseName [4]; uint uStack_10064; uint uStack_10060; undefined1 xmlDoc [48]; undefined1 xmlPool [65564]; void *local_10; undefined1 *puStack_c; undefined4 local_8; undefined4 *attribute; uint curseCount; void *cursesBegin; local_8 = 0xffffffff; puStack_c = &LAB_00b01d2b; local_10 = ExceptionList; curseCount = __security_cookie ^ GHIDRA_UINT((xmlPool + 0x10028)); ExceptionList = &local_10; if (isAppend != 0) goto LAB_0082c007; pbVar6 = (this->_curses)._end; psVar1 = &this->_curses; pbVar10 = psVar1->_begin; if (pbVar10 != pbVar6) { do { (GHIDRA_CAST((GHIDRA_CAST((pbVar10 + 4)))))->std::string::_Tidy_deallocate(); pbVar10 = pbVar10 + 0x1c; } while (pbVar10 != pbVar6); pbVar10 = psVar1->_begin; } (this->_curses)._end = pbVar10; curseCount = (GHIDRA_INT(pbVar10) - GHIDRA_INT(psVar1->_begin)) / 0x1c; if (curseCount < 10) { if (8 < curseCount) goto LAB_0082c007; iVar8 = GHIDRA_INT((this->_curses)._capacity) - GHIDRA_INT(psVar1->_begin); if (GHIDRA_UINT((iVar8 / 0x1c)) < 9) { FUN_0082e650(iVar8,&pbStack_1007c); goto LAB_0082c007; } pbVar6 = GHIDRA_CAST(FUN_0082e340(pbVar10,9 - curseCount,pbStack_1007c)); } else { pbVar6 = GHIDRA_CAST((GHIDRA_INT(psVar1->_begin) + 0xfc)); pbStack_1007c = pbVar6; if (pbVar6 != pbVar10) { do { (GHIDRA_CAST((GHIDRA_CAST((pbVar6 + 4)))))->std::string::_Tidy_deallocate(); pbVar6 = pbVar6 + 0x1c; } while (pbVar6 != pbVar10); pbVar6 = pbStack_1007c; } } (this->_curses)._end = pbVar6; LAB_0082c007: piVar7 = (GHIDRA_CAST((&PTR_vftable_00c37a10)))->FileSystem::Open(path,GHIDRA_CAST(0x0)); if (piVar7 == GHIDRA_CAST(0x0)) { bVar4 = 0; } else { iVar8 = (**(code **)(*piVar7 + 4))(curseCount); pbVar6 = operator_new_tracked(iVar8 + 1); pbStack_1007c = pbVar6; (**(code **)(*piVar7 + 0x14))(pbVar6,1,iVar8); pbVar6[iVar8] = 0; (**(code **)*piVar7)(1); FUN_00413b90(); local_8 = 0; iVar8 = 0x82c073; (GHIDRA_CAST((xmlDoc)))->rapidxml::xml_document::parse(pbVar6); bVar4 = (byte)pbVar6; node = (GHIDRA_CAST((xmlDoc)))->xml_node::first_node(GHIDRA_CAST("curses"),iVar8,bVar4); for (node = (GHIDRA_CAST((node)))->xml_node::first_node(GHIDRA_CAST("curse"),iVar8,bVar4); node != (void *)0x0; node = *(void **)(GHIDRA_CAST(node) + 0x2c)) { uStack_10064 = 0; uStack_10060 = 0xf; curseName[0] = GHIDRA_CAST(0x0); curseCount = local_8 >> 8; local_8 = CONCAT31((int3)curseCount,1); for (attribute = *GHIDRA_CAST((GHIDRA_CAST(node) + 0x20)); attribute != GHIDRA_CAST(0x0); attribute = GHIDRA_CAST(attribute[6])) { pbVar6 = GHIDRA_CAST(*attribute); expectedAttrChar = s_id; pbVar10 = &g_xmlNullStr; if (pbVar6 != GHIDRA_CAST(0x0)) { pbVar10 = pbVar6; } do { bVar4 = *pbVar10; isCharLess = bVar4 < *expectedAttrChar; if (bVar4 != *expectedAttrChar) { LAB_0082c105: curseCount = -GHIDRA_UINT(isCharLess) | 1; goto LAB_0082c10a; } if (bVar4 == 0) break; bVar4 = pbVar10[1]; isCharLess = bVar4 < expectedAttrChar[1]; if (bVar4 != expectedAttrChar[1]) goto LAB_0082c105; pbVar10 = pbVar10 + 2; expectedAttrChar = expectedAttrChar + 2; } while (bVar4 != 0); curseCount = 0; LAB_0082c10a: if (curseCount == 0) { pbVar6 = &g_xmlNullStr; if (GHIDRA_CAST(attribute[1]) != GHIDRA_CAST(0x0)) { pbVar6 = GHIDRA_CAST(attribute[1]); } curseId = atoi(GHIDRA_CAST(pbVar6)); } else { expectedAttrChar = s_name; pbVar10 = &g_xmlNullStr; if (pbVar6 != GHIDRA_CAST(0x0)) { pbVar10 = pbVar6; } do { bVar4 = *pbVar10; isCharLess = bVar4 < *expectedAttrChar; if (bVar4 != *expectedAttrChar) { LAB_0082c160: curseCount = -GHIDRA_UINT(isCharLess) | 1; goto LAB_0082c165; } if (bVar4 == 0) break; bVar4 = pbVar10[1]; isCharLess = bVar4 < expectedAttrChar[1]; if (bVar4 != expectedAttrChar[1]) goto LAB_0082c160; pbVar10 = pbVar10 + 2; expectedAttrChar = expectedAttrChar + 2; } while (bVar4 != 0); curseCount = 0; LAB_0082c165: if (curseCount == 0) { pbVar6 = &g_xmlNullStr; if (GHIDRA_CAST(attribute[1]) != GHIDRA_CAST(0x0)) { pbVar6 = GHIDRA_CAST(attribute[1]); } pbVar10 = pbVar6; do { bVar4 = *pbVar10; pbVar10 = pbVar10 + 1; } while (bVar4 != 0); (GHIDRA_CAST((GHIDRA_CAST(curseName))))->std::string::assign(pbVar6,GHIDRA_INT(pbVar10) - GHIDRA_INT((pbVar6 + 1))); } } if (attribute[4] == 0) break; } if (isAppend == 0) { cursesBegin = (this->_curses)._begin; *GHIDRA_CAST((GHIDRA_CAST(cursesBegin) + curseId * 0x1c)) = curseId; ppppbVar9 = GHIDRA_CAST((GHIDRA_INT(cursesBegin) + curseId * 0x1c + 4)); if (GHIDRA_CAST(ppppbVar9) != curseName) { text = GHIDRA_CAST(curseName); if (0xf < uStack_10060) { text = curseName[0]; } (GHIDRA_CAST((GHIDRA_CAST(ppppbVar9))))->std::string::assign(GHIDRA_CAST(text),uStack_10064); } } else { piVar7 = (this->_curses)._end; curseId = (GHIDRA_INT(piVar7) - GHIDRA_INT((this->_curses)._begin)) / 0x1c; if (piVar7 == (this->_curses)._capacity) { FUN_0082e0e0(piVar7,&curseId); } else { *piVar7 = curseId; (GHIDRA_CAST((GHIDRA_CAST((piVar7 + 1)))))->std::string::string(curseName); ppvVar2 = &(this->_curses)._end; *ppvVar2 = (void *)(GHIDRA_INT(*ppvVar2) + 0x1c); } } local_8 = local_8 & 0xffffff00; if (0xf < uStack_10060) { curseCount = uStack_10060 + 1; ppppbVar9 = curseName[0]; if (0xfff < curseCount) { ppppbVar9 = GHIDRA_CAST(curseName[0][-1]); curseCount = uStack_10060 + 0x24; if (GHIDRA_CAST(0x1f) < GHIDRA_CAST((GHIDRA_INT(curseName[0]) + (-4 - GHIDRA_INT(ppppbVar9))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(ppppbVar9,curseCount); } } local_8 = 2; (GHIDRA_CAST((xmlPool)))->xml_memory_pool::clear(); if (g_mainHeap == (void *)0x0) { allocCounter = &g_allocatedBytesNoHeap; } else { allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if (pbStack_1007c != GHIDRA_CAST(0x0)) { curseCount = *GHIDRA_CAST((pbStack_1007c + -4)); qVar3 = *allocCounter; *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - curseCount; *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar3) < curseCount)); free(pbStack_1007c + -4); } bVar4 = 1; } ExceptionList = local_10; return bVar4; } // 0082d000 std_string * RoomConfig::GetStageDisplayName(std_string *outName, int stageId, int language) { RoomConfigStage::GetDisplayName (GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x0))) + stageId * 0xc4)),outName,language); return outName; } // 0082d030 uint RoomConfig::GetStageID(uint levelStage, uint stageType, int mode) { uint uVar1; if (mode == -1) { if ((g_game != GHIDRA_CAST(0x0)) && ((g_game->_difficulty == 2 || (g_game->_difficulty == 3)))) { LAB_0082d065: if (levelStage == 7) { return 0x19; } if (levelStage == 6) { return 0x18; } if (levelStage == 5) { return 0xe; } if (stageType == 4) { return levelStage * 2 + 0x19; } if (stageType == 5) { return levelStage * 2 + 0x1a; } return stageType + levelStage * 3 + -2; } } else if (mode == 1) goto LAB_0082d065; if (levelStage == 0xd) { return 0x23; } if (8 < GHIDRA_INT(levelStage)) { if (levelStage == 9) { uVar1 = 0xd; if (stageType == 4) { uVar1 = 0x24; } return uVar1; } if (levelStage == 0xc) { return 0x1a; } return stageType + (levelStage - 3) * 2; } if (stageType == 4) { return (levelStage - 1 & 0xfffffffe) + 0x1b; } uVar1 = levelStage - 1 >> 1; if (stageType == 5) { return uVar1 * 2 + 0x1c; } return stageType + 1 + uVar1 * 3; } // 0082d100 int RoomConfig::GetStageIdByName(std_string *name) { byte bVar1; byte *nameEnd; uint *foundNode; byte *nameEnd; int compareResult; void *ptr; undefined1 *puVar4; uint stageIdx; undefined1 *nameMapHead; int nameMapSize; void *stageName [3]; undefined1 local_20 [4]; undefined4 local_1c; undefined1 *local_18; uint local_14; void *local_10; undefined1 *puStack_c; undefined4 local_8; undefined1 *foundNode; local_8 = 0xffffffff; puStack_c = &LAB_00b01e65; local_10 = ExceptionList; local_14 = __security_cookie ^ GHIDRA_UINT((local_20 + 0x1c)); ExceptionList = &local_10; nameMapHead = GHIDRA_CAST(0x0); nameMapSize = 0; nameMapHead = operator_new(0x2c); *GHIDRA_CAST(nameMapHead) = nameMapHead; *GHIDRA_CAST((nameMapHead + 4)) = nameMapHead; *GHIDRA_CAST((nameMapHead + 8)) = nameMapHead; *GHIDRA_CAST((nameMapHead + 0xc)) = 0x101; local_8 = 0; if (nameMapSize == 0) { stageIdx = 1; do { nameEnd = (&PTR_DAT_00b1fd50)[stageIdx]; local_1c = 0; local_18 = &DAT_0000000f; stageName[0] = (void *)0x0; nameEnd = nameEnd; do { bVar1 = *nameEnd; nameEnd = nameEnd + 1; } while (bVar1 != 0); (GHIDRA_CAST((GHIDRA_CAST(stageName))))->std::string::assign(nameEnd,GHIDRA_INT(nameEnd) - GHIDRA_INT((nameEnd + 1))); (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 1; foundNode = GHIDRA_CAST(FUN_0069d630(stageName)); local_8 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_UINT(local_8))) + 0x1))) << 8; *foundNode = stageIdx; if (&DAT_0000000f < local_18) { puVar4 = local_18 + 1; ptr = stageName[0]; if (GHIDRA_CAST(0xfff) < puVar4) { ptr = *(void **)(GHIDRA_INT(stageName[0]) + -4); puVar4 = local_18 + 0x24; if (0x1f < GHIDRA_UINT((GHIDRA_INT(stageName[0]) + (-4 - GHIDRA_INT(ptr))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(ptr,GHIDRA_UINT(puVar4)); } stageIdx = stageIdx + 1; } while (stageIdx < 0x1e); } puVar4 = nameMapHead; std::map::_Find_lower_bound(local_20,name); foundNode = local_18; if (local_18[0xd] == '\0') { nameEnd = local_18 + 0x10; if (0xf < *GHIDRA_CAST((local_18 + 0x24))) { nameEnd = *GHIDRA_CAST(nameEnd); } foundNode = &name->_size; if (0xf < name->_capacity) { name = *GHIDRA_CAST(name->_buf); } compareResult = string_compare(GHIDRA_CAST(name),*foundNode,nameEnd,*GHIDRA_CAST((local_18 + 0x20))); if ((-1 < compareResult) && (foundNode != puVar4)) { compareResult = *GHIDRA_CAST((foundNode + 0x28)); goto LAB_0082d24b; } } compareResult = 0; LAB_0082d24b: FUN_004235c0(&nameMapHead,*GHIDRA_CAST((puVar4 + 4))); operator_delete(nameMapHead,0x2c); ExceptionList = local_10; return compareResult; } // 0082d320 void RoomConfig::ClearGeneratedRooms() { undefined4 *ptr; int *roomListHead; void *heap; qword *allocatedBytes; int entryOffset; int *roomNode; int entry; uint entryIndex; void *local_10; undefined1 *puStack_c; undefined4 uStack_8; uint *allocBlock; uint allocSize; undefined4 *nextNode; qword prevAllocatedBytes; uStack_8 = 0xffffffff; puStack_c = &LAB_00b01e90; local_10 = ExceptionList; ExceptionList = &local_10; KAGE_LogMessage(1,GHIDRA_CAST("delete %d generated rooms.\n")); roomListHead = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c0)))); roomNode = GHIDRA_CAST(*roomListHead); if (roomNode != roomListHead) { heap = g_mainHeap; do { if ((short)roomNode[0x13] != 0) { entryIndex = 0; entryOffset = 0; do { entry = roomNode[0x12] + entryOffset; if (*GHIDRA_CAST((entry + 8)) != '\0') { allocatedBytes = GHIDRA_CAST((GHIDRA_INT(heap) + 0x30)); if (heap == (void *)0x0) { allocatedBytes = &g_allocatedBytesNoHeap; } if (*GHIDRA_CAST((entry + 4)) != 0) { allocBlock = GHIDRA_CAST((*GHIDRA_CAST((entry + 4)) + -4)); allocSize = *allocBlock; prevAllocatedBytes = *allocatedBytes; *GHIDRA_CAST(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - allocSize; *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(prevAllocatedBytes) < allocSize)) ; free(allocBlock); heap = g_mainHeap; } } *GHIDRA_CAST((entry + 4)) = 0; entryOffset = entryOffset + 0x10; *GHIDRA_CAST((entry + 8)) = 0; entryIndex = entryIndex + 1; } while (entryIndex < *GHIDRA_CAST((roomNode + 0x13))); allocatedBytes = GHIDRA_CAST((GHIDRA_INT(heap) + 0x30)); if (heap == (void *)0x0) { allocatedBytes = &g_allocatedBytesNoHeap; } if (roomNode[0x12] != 0) { allocBlock = GHIDRA_CAST((roomNode[0x12] + -4)); allocSize = *allocBlock; prevAllocatedBytes = *allocatedBytes; *GHIDRA_CAST(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - allocSize; *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(prevAllocatedBytes) < allocSize)); free(allocBlock); heap = g_mainHeap; } } roomNode[0x12] = 0; *GHIDRA_CAST((roomNode + 0x13)) = 0; roomNode = GHIDRA_CAST(*roomNode); roomListHead = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c0)))); } while (roomNode != roomListHead); } *GHIDRA_CAST(roomListHead[1]) = 0; ptr = GHIDRA_CAST(*roomListHead); while (ptr != GHIDRA_CAST(0x0)) { nextNode = GHIDRA_CAST(*ptr); (GHIDRA_CAST((GHIDRA_CAST((ptr + 7)))))->std::string::_Tidy_deallocate(); operator_delete(ptr,100); ptr = nextNode; } *GHIDRA_CAST(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c0))))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c0)))); *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c0)))) + 4)) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c0)))); *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c4)))) = 0; ExceptionList = local_10; return; } // 0082dac0 RoomConfig_Room * RoomConfig::make_generated_room(RoomConfig_Room *source) { uint doorWord; void *pvVar1; undefined4 *dstSpawn; uint uVar2; uint doorBit; short *srcSpawn; uint doorBits; int srcEntries; int srcSpawnOffset; uint entryIndex; uint spawnIndex; uint doorRemap [8]; uint local_14; void *local_10; undefined1 *puStack_c; uint local_8; int dstEntries; int newNode; char shapeFlag; int srcEntries; local_8 = 0xffffffff; puStack_c = &LAB_00b01f26; local_10 = ExceptionList; local_14 = __security_cookie ^ GHIDRA_UINT((doorRemap + 0xc)); ExceptionList = &local_10; std::list<92byte>::resize(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c4)))) + 1); srcEntries = source->Shape; doorRemap[0] = 2; newNode = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1c0)))) + 4)); doorRemap[2] = 0; doorRemap[4] = 6; *GHIDRA_CAST((newNode + 0x34)) = source->Difficulty; *GHIDRA_CAST((newNode + 0x40)) = 0; shapeFlag = (&DAT_00b1f8cc)[srcEntries * 8]; doorRemap[6] = 4; doorRemap[1] = GHIDRA_UINT((shapeFlag != '\0')) * 4 + 1; doorRemap[3] = GHIDRA_UINT((shapeFlag != '\0')) * 4 + 3; doorRemap[5] = GHIDRA_UINT((shapeFlag == '\0')) * 4 + 1; uVar2 = 0; doorRemap[7] = GHIDRA_UINT((shapeFlag == '\0')) * 4 + 3; do { doorWord = uVar2 >> 5; doorBit = 1 << ((byte)uVar2 & 0x1f); doorBits = *GHIDRA_CAST((newNode + 0x40 + doorWord * 4)); if (((&source->Doors)[doorRemap[uVar2] >> 5] & 1 << ((byte)doorRemap[uVar2] & 0x1f)) == 0) { doorBits = doorBits & ~doorBit; } else { doorBits = doorBits | doorBit; } uVar2 = uVar2 + 1; *GHIDRA_CAST((newNode + 0x40 + doorWord * 4)) = doorBits; } while (uVar2 < 8); *GHIDRA_CAST((newNode + 0x4e)) = source->Width; *GHIDRA_CAST((newNode + 0x4f)) = source->Height; *GHIDRA_CAST((newNode + 0x3c)) = 0x3f800000; *GHIDRA_CAST((newNode + 0x38)) = 0x3f800000; (GHIDRA_CAST((GHIDRA_CAST((newNode + 0x1c)))))->std::string::assign(GHIDRA_CAST("generated"),9); *GHIDRA_CAST((newNode + 0x50)) = *GHIDRA_CAST((&DAT_00b1f8c8 + srcEntries * 8)); (GHIDRA_CAST((newNode + 8)))->StageId = source->StageId; *GHIDRA_CAST((newNode + 0x10)) = source->Type; *GHIDRA_CAST((newNode + 0x14)) = source->Variant; *GHIDRA_CAST((newNode + 0x18)) = source->Subtype; *GHIDRA_CAST((newNode + 0x54)) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((source)) + 0x4c)))) | 0x20; uVar2 = GHIDRA_UINT((ushort)source->SpawnCount); *GHIDRA_CAST((newNode + 0x4c)) = source->SpawnCount; pvVar1 = operator_new_tracked(uVar2 * 0x10); if (pvVar1 == (void *)0x0) { pvVar1 = (void *)0x0; } else if (uVar2 != 0) { dstSpawn = GHIDRA_CAST((GHIDRA_INT(pvVar1) + 4)); do { dstSpawn[-1] = 0; *dstSpawn = 0; *GHIDRA_CAST((dstSpawn + 1)) = 0; dstSpawn[2] = 0; uVar2 = uVar2 - 1; dstSpawn = dstSpawn + 4; } while (uVar2 != 0); } local_8 = 0xffffffff; *(void **)(newNode + 0x48) = pvVar1; spawnIndex = 0; if (source->SpawnCount != 0) { dstSpawn = GHIDRA_CAST((GHIDRA_INT(pvVar1) + 0xc)); srcSpawnOffset = 0; do { srcSpawn = GHIDRA_CAST((GHIDRA_INT(source->Spawns) + srcSpawnOffset)); *GHIDRA_CAST((dstSpawn + -3)) = ((ushort)*GHIDRA_CAST((newNode + 0x4e)) - *srcSpawn) + -1; *GHIDRA_CAST((GHIDRA_CAST(dstSpawn) + -10)) = srcSpawn[1]; *dstSpawn = *GHIDRA_CAST((srcSpawn + 6)); *GHIDRA_CAST((dstSpawn + -1)) = (char)srcSpawn[4]; if (*GHIDRA_CAST((srcSpawn + 4)) != 0) { pvVar1 = operator_new_tracked(GHIDRA_UINT(*GHIDRA_CAST((srcSpawn + 4))) * 0xc); dstSpawn[-2] = pvVar1; entryIndex = 0; if ((char)srcSpawn[4] != '\0') { srcEntries = 0; do { srcEntries = *GHIDRA_CAST((srcSpawn + 2)); dstEntries = dstSpawn[-2]; *GHIDRA_CAST((dstEntries + srcEntries)) = *GHIDRA_CAST((srcEntries + srcEntries)); *GHIDRA_CAST((GHIDRA_CAST((dstEntries + srcEntries)) + 1)) = *GHIDRA_CAST((srcEntries + 8 + srcEntries)); FUN_0082dd80(); srcEntries = srcEntries + 0xc; entryIndex = entryIndex + 1; } while (entryIndex < *GHIDRA_CAST((srcSpawn + 4))); } } dstSpawn = dstSpawn + 4; srcSpawnOffset = srcSpawnOffset + 0x10; spawnIndex = spawnIndex + 1; } while (spawnIndex < (ushort)source->SpawnCount); } ExceptionList = local_10; return GHIDRA_CAST((newNode + 8)); }