The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body. src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT, from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra). structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
656 lines
26 KiB
C++
656 lines
26 KiB
C++
#include "classes.h"
|
|
|
|
// 009015b0
|
|
NetInputDevice::NetInputDevice(void *userProfile)
|
|
{
|
|
void *historyMap = this;
|
|
void *pvVar1;
|
|
undefined4 *containerProxy;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
undefined4 *containerProxySlot;
|
|
undefined4 *historyMap;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00b082e1;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
FUN_00a1e050(__security_cookie ^ GHIDRA_INT(register0x00000010) - 4U);
|
|
*GHIDRA_CAST<undefined ***>(historyMap) = IsaacRepentancePlus::NetInputDevice::vftable;
|
|
*GHIDRA_CAST<undefined ***>((GHIDRA_CAST<char *>(historyMap) + 0x370)) = KAGE::System::UserProfileBase::vftable;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x374)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(userProfile) + 4));
|
|
*GHIDRA_CAST<undefined ***>((GHIDRA_CAST<char *>(historyMap) + 0x370)) = KAGE::System::UserProfile::vftable;
|
|
local_8 = 1;
|
|
KAGE::SmartPointer<InputDeviceBase>::SmartPointer(GHIDRA_INT(historyMap) + 0x378);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 2;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x394)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x390)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x39c)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x398)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3a0)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3a4)) = 0;
|
|
pvVar1 = operator_new(0x24);
|
|
*(void **)pvVar1 = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 4) = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 8) = pvVar1;
|
|
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(pvVar1) + 0xc)) = 0x101;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3a0)) = pvVar1;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3a8)) = 0xffff;
|
|
historyMap = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(historyMap) + 0x3ac));
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 3;
|
|
*historyMap = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3b0)) = 0;
|
|
pvVar1 = operator_new(0x24);
|
|
*(void **)pvVar1 = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 4) = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 8) = pvVar1;
|
|
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(pvVar1) + 0xc)) = 0x101;
|
|
*historyMap = pvVar1;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3b4)) = 0xffff;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 4;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3bc)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3c0)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3c8)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3cc)) = 0;
|
|
pvVar1 = operator_new(0x10);
|
|
*(void **)pvVar1 = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 4) = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(historyMap) + 0x3c8) = pvVar1;
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(historyMap) + 0x3d4)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3d8)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3dc)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3e0)) = 0;
|
|
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),6);
|
|
containerProxySlot = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(historyMap) + 0x3e4));
|
|
*containerProxySlot = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 1000)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3ec)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3f0)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3f4)) = 0;
|
|
containerProxy = operator_new(8);
|
|
containerProxy[1] = 0;
|
|
*containerProxySlot = containerProxy;
|
|
*containerProxy = containerProxySlot;
|
|
FUN_00901b70();
|
|
*GHIDRA_CAST<ushort *>((GHIDRA_CAST<char *>(historyMap) + 8)) = *GHIDRA_CAST<ushort *>((GHIDRA_CAST<char *>(historyMap) + 8)) | 1;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(historyMap) + 0x3b4)) = 0x3c;
|
|
if (0x3c < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(historyMap) + 0x3b0))) {
|
|
do {
|
|
pvVar1 = (GHIDRA_CAST<std::_Tree *>((historyMap)))->std::_Tree::_Extract(*(void **)*historyMap);
|
|
operator_delete(pvVar1,0x24);
|
|
} while (*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(historyMap) + 0x3b4)) < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(historyMap) + 0x3b0)));
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 00901cb0
|
|
undefined1 NetInputDevice::is_input_ready(undefined1 param_1, int *param_2)
|
|
{
|
|
int iVar1;
|
|
char cVar2;
|
|
int *piVar3;
|
|
Entity_Player *player;
|
|
int *node;
|
|
int iVar4;
|
|
int in_ECX;
|
|
uint uVar5;
|
|
Manager *pMVar6;
|
|
undefined1 isReady;
|
|
int iVar7;
|
|
undefined8 uVar8;
|
|
void *in_stack_ffffffb4;
|
|
void *deviceRefCount;
|
|
int frame;
|
|
undefined4 local_2c;
|
|
int *local_28;
|
|
undefined4 local_24;
|
|
undefined1 local_20 [4];
|
|
int *connectionRefCount;
|
|
undefined8 local_18;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
undefined4 *tail;
|
|
|
|
puStack_c = &LAB_00b083b5;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
local_8 = 0;
|
|
if ((*GHIDRA_CAST<byte *>((in_ECX + 8)) & 1) == 0) {
|
|
isReady = 1;
|
|
goto LAB_00901fc3;
|
|
}
|
|
cVar2 = (**(code **)(*GHIDRA_CAST<int *>((in_ECX + 0x370)) + 0x14))
|
|
(__security_cookie ^ GHIDRA_UINT((local_20 + 0x1c)));
|
|
if (cVar2 == '\0') {
|
|
piVar3 = GHIDRA_CAST<int *>(FUN_00a29fd0(local_20,in_ECX + 0x370));
|
|
iVar4 = *piVar3;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 1;
|
|
if (((connectionRefCount != GHIDRA_CAST<int *>(0x0)) &&
|
|
(cVar2 = (**(code **)(*connectionRefCount + 0xc))(), cVar2 != '\0')) &&
|
|
(g_connectionReleaseFn != (void *)0x0)) {
|
|
(*g_connectionReleaseFn)(local_20);
|
|
}
|
|
local_8 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_8))) + 0x1))) << 8;
|
|
if (iVar4 != 0) {
|
|
piVar3 = GHIDRA_CAST<int *>((in_ECX + 0x3c8));
|
|
local_18 = FUN_00a58670();
|
|
iVar4 = *piVar3;
|
|
if (*GHIDRA_CAST<int *>((in_ECX + 0x3cc)) == 0xfffffff) {
|
|
/* WARNING: Subroutine does not return */
|
|
std::_Xlength_error("list too long");
|
|
}
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 2;
|
|
local_24 = 0;
|
|
local_28 = piVar3;
|
|
node = operator_new(0x10);
|
|
*GHIDRA_CAST<undefined8 *>((node + 2)) = local_18;
|
|
local_8 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_8))) + 0x1))) << 8;
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x3cc)) = *GHIDRA_CAST<int *>((in_ECX + 0x3cc)) + 1;
|
|
tail = *GHIDRA_CAST<undefined4 **>((iVar4 + 4));
|
|
*node = iVar4;
|
|
node[1] = GHIDRA_INT(tail);
|
|
*GHIDRA_CAST<int **>((iVar4 + 4)) = node;
|
|
*tail = node;
|
|
uVar5 = *GHIDRA_CAST<uint *>((in_ECX + 0x3cc));
|
|
while (0x1e < uVar5) {
|
|
node = *GHIDRA_CAST<int **>(*piVar3);
|
|
iVar4 = *node;
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x3cc)) = *GHIDRA_CAST<int *>((in_ECX + 0x3cc)) + -1;
|
|
*GHIDRA_CAST<int *>(node[1]) = iVar4;
|
|
*GHIDRA_CAST<int *>((iVar4 + 4)) = node[1];
|
|
operator_delete(node,0x10);
|
|
uVar5 = *GHIDRA_CAST<uint *>((in_ECX + 0x3cc));
|
|
}
|
|
}
|
|
LAB_00901f19:
|
|
pMVar6 = g_manager;
|
|
}
|
|
else {
|
|
iVar4 = *GHIDRA_CAST<int *>((in_ECX + 0x3a4));
|
|
if (iVar4 == 0) {
|
|
uVar5 = g_manager[1]._state;
|
|
pMVar6 = g_manager;
|
|
}
|
|
else {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))) = *GHIDRA_CAST<undefined4 *>((in_ECX + 0x3a0));
|
|
uVar8 = FUN_009012b0();
|
|
uVar5 = *GHIDRA_CAST<int *>(uVar8) + 1;
|
|
pMVar6 = GHIDRA_CAST<Manager *>(((ulonglong)uVar8 >> 0x20));
|
|
}
|
|
local_18 = CONCAT44((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))),(undefined4)local_18);
|
|
if (uVar5 <= GHIDRA_UINT((pMVar6[1]._previousState + pMVar6[1]._state))) {
|
|
local_18 = CONCAT44((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))),(undefined4)local_18);
|
|
if (g_game != GHIDRA_CAST<Game *>(0x0)) {
|
|
iVar7 = *GHIDRA_CAST<int *>((in_ECX + 0x378));
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))) = 0x3c;
|
|
if (iVar7 != 0) {
|
|
iVar1 = *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(pMVar6[1]._gamestate)) + 0x92c))));
|
|
if (iVar1 == 0x3c) {
|
|
if ((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(pMVar6[1]._gamestate)) + 0x290)))) != 0) ||
|
|
(0 < *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(pMVar6[1]._gamestate)) + 0x2d8)))))) {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))) = 0x15;
|
|
}
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(pMVar6[1]._gamestate)) + 0x92c)))) = 0x3c;
|
|
iVar4 = *GHIDRA_CAST<int *>((in_ECX + 0x3a4));
|
|
iVar7 = *GHIDRA_CAST<int *>((in_ECX + 0x378));
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))) = iVar1;
|
|
}
|
|
}
|
|
if (iVar4 == 0) {
|
|
frame = pMVar6[1]._state;
|
|
}
|
|
else {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_18)) + 0x0))) = *GHIDRA_CAST<undefined4 *>((in_ECX + 0x3a0));
|
|
piVar3 = GHIDRA_CAST<int *>(FUN_009012b0());
|
|
frame = *piVar3 + 1;
|
|
}
|
|
local_2c = 0x7fff0000;
|
|
local_28 = GHIDRA_CAST<int *>(0x7fff7fff);
|
|
local_24 = GHIDRA_UINT(CONCAT12((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((char)local_18)) + 0x4))),0x7fff));
|
|
if (iVar7 != 0) {
|
|
deviceRefCount = (void *)0x901dfa;
|
|
player = GHIDRA_CAST<Entity_Player *>(FUN_004253d0());
|
|
FUN_00902d60(in_ECX + 0x378);
|
|
net_input_frame_capture(&frame,player,in_stack_ffffffb4,deviceRefCount);
|
|
}
|
|
iVar4 = frame;
|
|
FUN_00901070(&frame);
|
|
FUN_00901070(&frame);
|
|
broadcast_frame_input(iVar4);
|
|
goto LAB_00901f19;
|
|
}
|
|
}
|
|
}
|
|
FUN_00901030(pMVar6[1]._state);
|
|
FUN_00901030(g_manager[1]._state + -5);
|
|
if (*GHIDRA_CAST<char *>(&g_manager[1]._persistentGameData) == '\0') {
|
|
iVar4 = 0;
|
|
}
|
|
else {
|
|
iVar4 = g_manager[1]._previousState;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((in_ECX + 0x3a4)) == 0) {
|
|
uVar5 = g_manager[1]._state;
|
|
pMVar6 = g_manager;
|
|
}
|
|
else {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_18)) + 0x0))) = *GHIDRA_CAST<undefined4 *>((in_ECX + 0x3a0));
|
|
uVar8 = FUN_009012b0();
|
|
uVar5 = *GHIDRA_CAST<int *>(uVar8) + 1;
|
|
pMVar6 = GHIDRA_CAST<Manager *>(((ulonglong)uVar8 >> 0x20));
|
|
}
|
|
if (GHIDRA_UINT((pMVar6[1]._state + iVar4)) < uVar5) {
|
|
iVar4 = FUN_00901190(pMVar6[1]._state);
|
|
if (((iVar4 != 0) &&
|
|
(((*GHIDRA_CAST<ushort *>((iVar4 + 4)) & 0x4000) == 0 || (*GHIDRA_CAST<int *>((in_ECX + 0x3f4)) != 0)))) &&
|
|
(iVar4 != 0)) {
|
|
isReady = 1;
|
|
goto LAB_00901fc3;
|
|
}
|
|
}
|
|
isReady = 0;
|
|
LAB_00901fc3:
|
|
local_8 = 3;
|
|
if (param_2 != GHIDRA_CAST<int *>(0x0)) {
|
|
cVar2 = (**(code **)(*param_2 + 0xc))();
|
|
if ((cVar2 != '\0') && (g_connectionReleaseFn != (void *)0x0)) {
|
|
(*g_connectionReleaseFn)(¶m_1);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return isReady;
|
|
}
|
|
|
|
// 00902010
|
|
byte NetInputDevice::ProcessInputMessage(void *message, void *messageRefCount)
|
|
{
|
|
void *pvVar1;
|
|
char isLastRef;
|
|
uint uVar2;
|
|
void *pvVar3;
|
|
byte isAccepted;
|
|
int iVar4;
|
|
char *format;
|
|
undefined **stream;
|
|
int local_64;
|
|
int local_60;
|
|
void *streamBufBegin;
|
|
void *streamBufEnd;
|
|
int streamBufCapacity;
|
|
int payload;
|
|
undefined4 local_4c;
|
|
undefined4 local_48;
|
|
undefined4 local_44;
|
|
undefined **streamVtable;
|
|
int checksum;
|
|
byte local_38;
|
|
uint local_34;
|
|
int local_30;
|
|
uint inputFrame;
|
|
undefined4 local_28;
|
|
undefined4 local_24;
|
|
undefined4 local_20;
|
|
uint receivedChecksum;
|
|
uint readValue;
|
|
undefined1 readByte;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
|
|
puStack_c = &LAB_00b083f5;
|
|
local_10 = ExceptionList;
|
|
uVar2 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
local_8 = 0;
|
|
if (*GHIDRA_CAST<char *>((*GHIDRA_CAST<int *>((**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(message) + 8)) + 0x14)) + 5)) != '\x01') {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Specified message is not an input message"));
|
|
}
|
|
pvVar3 = message;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(message) + 0xc)) != 1) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("This function should only be called on consolidated messages"));
|
|
}
|
|
pvVar1 = message;
|
|
iVar4 = *GHIDRA_CAST<int *>((**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(pvVar3) + 8)) + 0x18)) + -8;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(message) + 0xc)) != 1) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("This function should only be called on consolidated messages"));
|
|
}
|
|
payload = *GHIDRA_CAST<int *>((**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(pvVar1) + 8)) + 0x14)) + 8;
|
|
streamBufBegin = (void *)0x0;
|
|
streamBufCapacity = 0;
|
|
local_44 = 0;
|
|
local_48 = 0;
|
|
local_4c = 0;
|
|
streamBufEnd = (void *)0x0;
|
|
stream = KAGE::Filesys::BufferedStream::vftable;
|
|
streamVtable = KAGE::Filesys::BufferedStream::vftable;
|
|
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1);
|
|
local_30 = 1;
|
|
checksum = 0;
|
|
local_38 = 0;
|
|
local_34 = 0xfedcba76;
|
|
receivedChecksum = 0;
|
|
local_64 = iVar4;
|
|
local_60 = iVar4;
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&receivedChecksum,4,1);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,4,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue,4,1,uVar2);
|
|
}
|
|
local_28 = readValue;
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,4,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
uVar2 = readValue;
|
|
local_24 = readValue;
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,4,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_20 = readValue;
|
|
if (uVar2 != 0) {
|
|
FUN_0090d4a0(&local_28);
|
|
}
|
|
(GHIDRA_CAST<Checksum *>((&checksum)))->Checksum::Update(GHIDRA_CAST<byte *>(&local_28),0xc);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,4,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
uVar2 = readValue;
|
|
inputFrame = readValue;
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_28 = CONCAT22((*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(&(local_28)) + 0x2))),(undefined2)readValue);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_28 = CONCAT22((undefined2)readValue,(undefined2)local_28);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_24 = CONCAT22((*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(&(local_24)) + 0x2))),(undefined2)readValue);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_24 = CONCAT22((undefined2)readValue,(undefined2)local_24);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_20 = CONCAT22((*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(&(local_20)) + 0x2))),(undefined2)readValue);
|
|
readByte = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readByte,1,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readByte);
|
|
}
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_20)) + 0x0))) = CONCAT12(readByte,(undefined2)local_20);
|
|
readByte = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readByte,1,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readByte);
|
|
}
|
|
local_20 = CONCAT13(readByte,(undefined3)local_20);
|
|
(GHIDRA_CAST<Checksum *>((&checksum)))->Checksum::Update(GHIDRA_CAST<byte *>(&inputFrame),0x10);
|
|
if (uVar2 < GHIDRA_UINT(g_manager[1]._state)) {
|
|
format =
|
|
"NetInputDevice::ProcessInputMessage - Dropping input packet outside of match scope. Received Frame: %d, Current Frame: %d\n"
|
|
;
|
|
LAB_0090244d:
|
|
KAGE_LogMessage(1,GHIDRA_CAST<byte *>(format));
|
|
}
|
|
else {
|
|
iVar4 = FUN_00901190(uVar2);
|
|
if (iVar4 == 0) {
|
|
if ((local_30 == 0) && (local_38 != 0)) {
|
|
if (local_38 < 4) {
|
|
memset((void *)(GHIDRA_INT(&checksum) + GHIDRA_UINT(local_38)),0,GHIDRA_UINT((byte)(4 - local_38)));
|
|
}
|
|
uVar2 = local_34 * -0x80000000 + (local_34 >> 1) + checksum;
|
|
}
|
|
else {
|
|
uVar2 = local_34;
|
|
}
|
|
if (uVar2 == receivedChecksum) {
|
|
FUN_00901070(&inputFrame);
|
|
FUN_00901070(&inputFrame);
|
|
isAccepted = 1;
|
|
goto LAB_00902459;
|
|
}
|
|
format =
|
|
"NetInputDevice::ProcessInputMessage - CHECKSUM MISMATCH! Expected: %08x, Received: %08x\n";
|
|
goto LAB_0090244d;
|
|
}
|
|
KAGE_LogMessage(1,(byte *)
|
|
"NetInputDevice::ProcessInputMessage - Dropping input packet for frame we already have. Frame: %d\n"
|
|
);
|
|
}
|
|
isAccepted = 0;
|
|
LAB_00902459:
|
|
local_8 = local_8 & 0xffffff00;
|
|
streamVtable = KAGE::Filesys::StreamBase::vftable;
|
|
stream = KAGE::Filesys::BufferedStreamBase::vftable;
|
|
local_64 = 0;
|
|
local_60 = 0;
|
|
streamBufEnd = streamBufBegin;
|
|
payload = 0;
|
|
local_4c = 0;
|
|
local_48 = 0;
|
|
local_44 = 0;
|
|
if (streamBufBegin != (void *)0x0) {
|
|
uVar2 = streamBufCapacity - GHIDRA_INT(streamBufBegin);
|
|
pvVar3 = streamBufBegin;
|
|
if (0xfff < uVar2) {
|
|
pvVar3 = *(void **)(GHIDRA_CAST<char *>(streamBufBegin) + -4);
|
|
uVar2 = uVar2 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(streamBufBegin) + (-4 - GHIDRA_INT(pvVar3))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pvVar3,uVar2);
|
|
streamBufEnd = (void *)0x0;
|
|
streamBufCapacity = 0;
|
|
}
|
|
local_8 = 2;
|
|
if (messageRefCount != (void *)0x0) {
|
|
streamBufBegin = streamBufEnd;
|
|
isLastRef = (**(code **)(*GHIDRA_CAST<int *>(messageRefCount) + 0xc))();
|
|
if ((isLastRef != '\0') && (g_multiplayerRelease != (void *)0x0)) {
|
|
(*g_multiplayerRelease)(&message);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return isAccepted;
|
|
}
|
|
|
|
// 00902950
|
|
void NetInputDevice::broadcast_frame_input(undefined4 param_1)
|
|
{
|
|
undefined8 uVar1;
|
|
byte *data;
|
|
char cVar2;
|
|
int in_ECX;
|
|
void *this;
|
|
int extraout_ECX;
|
|
uint *streamData;
|
|
uint checksum;
|
|
undefined4 checksumTail;
|
|
undefined4 checksumHigh;
|
|
void *messageRefCount;
|
|
undefined1 stream [4];
|
|
void *streamSize;
|
|
uint *local_74;
|
|
uint *local_68;
|
|
int local_58;
|
|
int checksumState;
|
|
byte local_50;
|
|
uint checksumAcc;
|
|
int local_48;
|
|
undefined8 frameChecksum;
|
|
undefined4 local_3c;
|
|
undefined1 inputMessage [4];
|
|
int *inputMessageRefCount;
|
|
byte *local_2c;
|
|
undefined4 tmpDword;
|
|
byte tmpByte;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
undefined8 *checksumEntry;
|
|
Manager *manager;
|
|
|
|
puStack_20 = inputMessage + 0x34;
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00b08455;
|
|
local_1c = ExceptionList;
|
|
ExceptionList = &local_1c;
|
|
cVar2 = (**(code **)(*GHIDRA_CAST<int *>((in_ECX + 0x370)) + 0x14))
|
|
(__security_cookie ^ GHIDRA_UINT((inputMessage + 0x28)));
|
|
if (cVar2 == '\0') {
|
|
KAGE_LogMessage(0x10,(byte *)
|
|
"NetInputDevice::broadcast_frame_input should only be called on the local player"
|
|
);
|
|
}
|
|
if (*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x20)))) != 0) {
|
|
local_2c = GHIDRA_CAST<byte *>((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x20)))) +
|
|
*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x1c))))));
|
|
if (g_manager[1]._state - 1U <=
|
|
**GHIDRA_CAST<uint **>((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x14)))) +
|
|
(*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x18)))) - 1U &
|
|
GHIDRA_UINT((local_2c + -1))) * 4))) {
|
|
checksumEntry =
|
|
*(undefined8 **)
|
|
(*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x14)))) +
|
|
(*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x18)))) - 1U & GHIDRA_UINT((local_2c + -1))) * 4)
|
|
;
|
|
uVar1 = *checksumEntry;
|
|
checksumTail = *GHIDRA_CAST<undefined4 *>((checksumEntry + 1));
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(frameChecksum)) + 0x4))) = (undefined4)((ulonglong)uVar1 >> 0x20);
|
|
checksumHigh = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(frameChecksum)) + 0x4)));
|
|
frameChecksum = uVar1;
|
|
goto LAB_00902a25;
|
|
}
|
|
}
|
|
checksumHigh = 0;
|
|
frameChecksum = 0;
|
|
checksumTail = 0;
|
|
LAB_00902a25:
|
|
local_3c = checksumTail;
|
|
local_2c = GHIDRA_CAST<byte *>(FUN_00901190(param_1));
|
|
if (local_2c != GHIDRA_CAST<byte *>(0x0)) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((stream)))->KAGE::Filesys::BufferedStream::BufferedStream(0);
|
|
local_14 = 0;
|
|
local_48 = 1;
|
|
checksumState = 0;
|
|
local_50 = 0;
|
|
checksumAcc = 0xfedcba76;
|
|
tmpDword = 0;
|
|
(**(code **)(local_58 + 0x1c))(&tmpDword,4,1);
|
|
tmpDword = (undefined4)frameChecksum;
|
|
(**(code **)(local_58 + 0x1c))(&tmpDword,4,1);
|
|
tmpDword = checksumHigh;
|
|
(**(code **)(local_58 + 0x1c))(&tmpDword,4,1);
|
|
tmpDword = checksumTail;
|
|
(**(code **)(local_58 + 0x1c))(&tmpDword,4,1);
|
|
data = local_2c;
|
|
local_2c = *GHIDRA_CAST<byte **>(local_2c);
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,4,1);
|
|
local_2c = GHIDRA_CAST<byte *>(GHIDRA_UINT(*GHIDRA_CAST<ushort *>((data + 4))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
local_2c = GHIDRA_CAST<byte *>(GHIDRA_UINT(*GHIDRA_CAST<ushort *>((data + 6))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
local_2c = GHIDRA_CAST<byte *>(GHIDRA_UINT(*GHIDRA_CAST<ushort *>((data + 8))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
local_2c = GHIDRA_CAST<byte *>(GHIDRA_UINT(*GHIDRA_CAST<ushort *>((data + 10))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
local_2c = GHIDRA_CAST<byte *>(GHIDRA_UINT(*GHIDRA_CAST<ushort *>((data + 0xc))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
tmpByte = data[0xe];
|
|
(**(code **)(local_58 + 0x1c))(&tmpByte,1,1);
|
|
tmpByte = data[0xf];
|
|
(**(code **)(local_58 + 0x1c))(&tmpByte,1,1);
|
|
(GHIDRA_CAST<Checksum *>((&checksumState)))->Checksum::Update(GHIDRA_CAST<byte *>(&frameChecksum),0xc);
|
|
this->Checksum::Update(data,0x10);
|
|
if ((local_48 == 0) && (local_50 != 0)) {
|
|
if (local_50 < 4) {
|
|
memset((void *)(extraout_ECX + GHIDRA_UINT(local_50)),0,GHIDRA_UINT((byte)(4 - local_50)));
|
|
}
|
|
checksum = checksumAcc * -0x80000000 + (checksumAcc >> 1) + checksumState;
|
|
}
|
|
else {
|
|
checksum = checksumAcc;
|
|
}
|
|
streamData = local_74;
|
|
if (local_68 != GHIDRA_CAST<uint *>(0x0)) {
|
|
streamData = local_68;
|
|
}
|
|
*streamData = checksum;
|
|
streamData = local_74;
|
|
if (local_68 != GHIDRA_CAST<uint *>(0x0)) {
|
|
streamData = local_68;
|
|
}
|
|
if (g_multiplayerService == (void *)0x0) {
|
|
KAGE_LogMessage(0x10,(byte *)
|
|
"Attempting to create a message when there is no multiplayer service\n");
|
|
}
|
|
messageRefCount = (void *)0x1;
|
|
NetConnection::send_message(g_multiplayerService,inputMessage,1,streamData,GHIDRA_UINT(streamSize),1);
|
|
manager = g_manager;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 1;
|
|
FUN_008ef1d0(inputMessage);
|
|
(GHIDRA_CAST<NetplayManager *>((&manager->_netplayManager)))->NetplayManager::send_message(8,streamSize,messageRefCount);
|
|
local_14 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))),2);
|
|
if (inputMessageRefCount != GHIDRA_CAST<int *>(0x0)) {
|
|
cVar2 = (**(code **)(*inputMessageRefCount + 0xc))();
|
|
if ((cVar2 != '\0') && (g_multiplayerRelease != (void *)0x0)) {
|
|
(*g_multiplayerRelease)(inputMessage);
|
|
}
|
|
}
|
|
FUN_00a58200();
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|