#include "classes.h" // 0090ac70 void * InputManager::GetDeviceByPlayerEntity(Entity_Player *player) { void *pvVar1; uint32_t uVar2; int *playerCursor; Entity_Player *mainTwin; int *piVar3; uint32_t uVar4; int extraout_ECX; Entity_Player *devicePlayer; uint32_t uVar5; uint32_t deviceIdx; int *deviceCursor; int deviceId; if (player == GHIDRA_CAST(0x0)) { KAGE_LogMessage(8,GHIDRA_CAST("[Frame %d] GetDeviceByPlayerEntity() given NULL player entity \n")); return (void *)0x0; } deviceCursor = *GHIDRA_CAST(this); deviceIdx = 0; uVar2 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - GHIDRA_INT(deviceCursor) >> 2; if (uVar2 != 0) { piVar3 = (g_game->_playerManager)._playerList._begin; uVar5 = GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT(piVar3) >> 2; do { pvVar1 = (void *)*deviceCursor; uVar4 = 0; deviceId = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)); if (uVar5 != 0) { playerCursor = piVar3; do { devicePlayer = GHIDRA_CAST(*playerCursor); if (devicePlayer->_controllerIndex == deviceId) goto LAB_0090ad07; uVar4 = uVar4 + 1; playerCursor = playerCursor + 1; } while (uVar4 < uVar5); } devicePlayer = GHIDRA_CAST(0x0); LAB_0090ad07: mainTwin = Entity_Player::GetMainTwin(player); if ((devicePlayer == mainTwin) || (deviceId == *GHIDRA_CAST((extraout_ECX + 0x1618)))) { return pvVar1; } deviceIdx = deviceIdx + 1; deviceCursor = deviceCursor + 1; } while (deviceIdx < uVar2); } KAGE_LogMessage(8,(uint8_t *) "[Frame %d] GetDeviceByPlayerEntity() cannot find device for the given player entity \n " ); KAGE_LogMessage(8,GHIDRA_CAST("----------------------------------------------------------- \n ")); KAGE_LogMessage(8,GHIDRA_CAST("playerEntity PlayerType: %d, Device ID: %d \n ")); KAGE_LogMessage(8,GHIDRA_CAST("Device List: \n ")); uVar2 = 0; if (*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - *GHIDRA_CAST(this) >> 2 == 0) { LAB_0090ae59: KAGE_LogMessage(8,GHIDRA_CAST("----------------------------------------------------------- \n")); return (void *)0x0; } LAB_0090ada1: KAGE_LogMessage(8,GHIDRA_CAST(" - UserID(%llu), DeviceID(%d), SourceDeviceID(%d) \n ")); uVar5 = 0; deviceId = *GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST(this) + uVar2 * 4)) + 0xc)); piVar3 = (g_game->_playerManager)._playerList._begin; uVar4 = GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT(piVar3) >> 2; if (uVar4 != 0) { do { if (*GHIDRA_CAST((piVar3[uVar5] + 0x1618)) == deviceId) { if (piVar3[uVar5] != 0) { uVar5 = 0; goto LAB_0090ae80; } break; } uVar5 = uVar5 + 1; } while (uVar5 < uVar4); } KAGE_LogMessage(8,GHIDRA_CAST(" - Device is not associated with a player entity!!! \n ")); goto LAB_0090ae42; while( true ) { uVar5 = uVar5 + 1; piVar3 = piVar3 + 1; if (uVar4 <= uVar5) break; LAB_0090ae80: if (*GHIDRA_CAST((*piVar3 + 0x1618)) == deviceId) break; } KAGE_LogMessage(8,GHIDRA_CAST(" - Device\'s Player Type: %d \n ")); LAB_0090ae42: uVar2 = uVar2 + 1; if (GHIDRA_UINT((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - *GHIDRA_CAST(this) >> 2)) <= uVar2) goto LAB_0090ae59; goto LAB_0090ada1; } // 0090aeb0 int InputManager::FirstLocalDeviceID() { char isLocal; int iVar1; uint32_t slotIndex; slotIndex = 0; iVar1 = *GHIDRA_CAST(this); if (*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - iVar1 >> 2 != 0) { do { iVar1 = *GHIDRA_CAST((iVar1 + slotIndex * 4)); isLocal = (**(code **)(*GHIDRA_CAST((iVar1 + 0x370)) + 0x14))(); if (isLocal != '\0') { iVar1 = *GHIDRA_CAST((iVar1 + 0x378)); if (iVar1 == 0) { return -1; } return *GHIDRA_CAST((iVar1 + 0xc)); } slotIndex = slotIndex + 1; iVar1 = *GHIDRA_CAST(this); } while (slotIndex < GHIDRA_UINT((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - iVar1 >> 2))); } KAGE_LogMessage(8,(uint8_t *) "[Frame %d] FirstLocalDeviceID() Could not find a device for the local user! \n " ); return -1; }