#include "classes.h" // 0041c490 void EntityPartition::query_box(EntityList_EL *outList, Vector *position, Vector *extent) { float *pfVar1; int iVar2; float *pfVar3; void *isSeen; int resultSize; uint64_t *allocatedBytes; int iVar4; int iVar5; int iVar6; uint32_t uVar7; void *local_10; uint8_t *puStack_c; uint32_t uStack_8; float cellSize; int column; int entityIndex; float extentX; uint64_t oldAllocated; float posXCopy; uStack_8 = 0xffffffff; puStack_c = &LAB_00af1690; local_10 = ExceptionList; ExceptionList = &local_10; if (*GHIDRA_CAST((*GHIDRA_CAST(this) + 0xd4)) != 0) { isSeen = operator_new_tracked(*GHIDRA_CAST((*GHIDRA_CAST(this) + 0xd4))); memset(isSeen,0,*GHIDRA_CAST((*GHIDRA_CAST(this) + 0xd4))); extentX = extent->x; pfVar3 = &position->x; pfVar1 = &position->y; cellSize = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)); posXCopy = position->x; position = GHIDRA_CAST(GHIDRA_INT(((position->y - extent->y) / cellSize))); iVar5 = GHIDRA_INT(((extent->y + *pfVar1) / cellSize)); iVar6 = GHIDRA_INT(((*pfVar3 - extentX) / cellSize)); if (GHIDRA_INT(position) <= iVar5) { column = iVar6; do { for (; column <= GHIDRA_INT(((extentX + posXCopy) / cellSize)); column = column + 1) { iVar4 = column + *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) * GHIDRA_INT(position); if ((-1 < iVar4) && (iVar4 < (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x1c)) - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x18))) / 0xa4)) { uVar7 = 0; iVar4 = iVar4 * 0xa4 + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x18)); if (*GHIDRA_CAST((iVar4 + 0xa0)) != 0) { do { iVar2 = *GHIDRA_CAST((iVar4 + uVar7 * 4)); entityIndex = *GHIDRA_CAST((iVar2 + 0x24)); if (*GHIDRA_CAST((entityIndex + GHIDRA_INT(isSeen))) == '\0') { resultSize = outList->_size; if (GHIDRA_UINT(outList->_capacity) < resultSize + 1U) { KAGE_LogMessage(0x10,GHIDRA_CAST("EL: not enough space for push_back\n")); resultSize = outList->_size; } *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((outList)) + 0x4)))) + resultSize * 4)) = iVar2; outList->_size = outList->_size + 1; *GHIDRA_CAST((entityIndex + GHIDRA_INT(isSeen))) = 1; } uVar7 = uVar7 + 1; } while (uVar7 < *GHIDRA_CAST((iVar4 + 0xa0))); } } } position = GHIDRA_CAST((GHIDRA_INT(&position->x) + 1)); column = iVar6; } while (GHIDRA_INT(position) <= iVar5); } if (g_mainHeap == (void *)0x0) { allocatedBytes = &g_allocatedBytesNoHeap; } else { allocatedBytes = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if (isSeen != (void *)0x0) { uVar7 = *GHIDRA_CAST((GHIDRA_CAST(isSeen) + -4)); oldAllocated = *allocatedBytes; *GHIDRA_CAST(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar7; *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocated) < uVar7)); free((void *)(GHIDRA_INT(isSeen) + -4)); } } ExceptionList = local_10; return; }