Reconstruction layout: generated-src/ (generated) and src/ (curated), CMake, the first takeover: RNG
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>
This commit is contained in:
1 parent
2ff2d5d87f
commit
3ce74c6e2d
331 files changed
+485
-7835
No files matched your search
@@ -0,0 +1,245 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 00721a70
|
||||
void History::AddHistoryItem(void *historyItem)
|
||||
{
|
||||
int iVar1;
|
||||
int iVar2;
|
||||
int *item;
|
||||
int iVar3;
|
||||
int *itemsBegin;
|
||||
int *itemsEnd;
|
||||
void **itemsEndPtr;
|
||||
|
||||
if (this->_isLocked != 0) {
|
||||
return;
|
||||
}
|
||||
itemsBegin = (this->_historyItems)._begin;
|
||||
itemsEnd = (this->_historyItems)._end;
|
||||
item = itemsBegin;
|
||||
if (itemsBegin != itemsEnd) {
|
||||
do {
|
||||
item = item + 7;
|
||||
} while (item != itemsEnd);
|
||||
item = itemsBegin;
|
||||
if (*GHIDRA_CAST<int *>(historyItem) < itemsEnd[-7]) {
|
||||
do {
|
||||
if (*GHIDRA_CAST<int *>(historyItem) < *item) {
|
||||
FUN_00722250(&historyItem,item,historyItem);
|
||||
iVar3 = (GHIDRA_INT(item) - GHIDRA_INT(itemsBegin)) / 0x1c + (GHIDRA_INT(item) - GHIDRA_INT(itemsBegin) >> 0x1f);
|
||||
iVar2 = iVar3;
|
||||
goto LAB_00721b3f;
|
||||
}
|
||||
item = item + 7;
|
||||
} while (item != itemsEnd);
|
||||
goto LAB_00721b4c;
|
||||
}
|
||||
}
|
||||
if (itemsEnd == (this->_historyItems)._capacity) {
|
||||
std::vector<28byte>::_Emplace_reallocate(itemsEnd,historyItem);
|
||||
}
|
||||
else {
|
||||
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(historyItem) + 4));
|
||||
iVar3 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(historyItem) + 8));
|
||||
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(historyItem) + 0xc));
|
||||
*itemsEnd = *GHIDRA_CAST<int *>(historyItem);
|
||||
itemsEnd[1] = iVar2;
|
||||
itemsEnd[2] = iVar3;
|
||||
itemsEnd[3] = iVar1;
|
||||
*GHIDRA_CAST<undefined8 *>((itemsEnd + 4)) = *GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(historyItem) + 0x10));
|
||||
itemsEnd[6] = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(historyItem) + 0x18));
|
||||
itemsEndPtr = &(this->_historyItems)._end;
|
||||
*itemsEndPtr = (void *)(GHIDRA_INT(*itemsEndPtr) + 0x1c);
|
||||
}
|
||||
iVar2 = GHIDRA_INT((this->_historyItems)._end) - GHIDRA_INT((this->_historyItems)._begin);
|
||||
iVar3 = iVar2 / 0x1c + (iVar2 >> 0x1f);
|
||||
iVar2 = iVar3 + -1;
|
||||
LAB_00721b3f:
|
||||
FUN_00722020(iVar2 - (iVar3 >> 0x1f));
|
||||
LAB_00721b4c:
|
||||
HUD::mark_all_slots_dirty(&g_game->_hud,0,0);
|
||||
return;
|
||||
}
|
||||
|
||||
// 00721c00
|
||||
byte History::RemoveHistoryItemByIndex(int index)
|
||||
{
|
||||
void *historyBegin;
|
||||
int removedIndex;
|
||||
|
||||
removedIndex = index;
|
||||
if (this->_isLocked == 0) {
|
||||
historyBegin = (this->_historyItems)._begin;
|
||||
if (index < (GHIDRA_INT((this->_historyItems)._end) - GHIDRA_INT(historyBegin)) / 0x1c) {
|
||||
std::vector<HistoryItem>::erase(&index,(void *)(GHIDRA_INT(historyBegin) + index * 0x1c));
|
||||
remove_index_refs(this,removedIndex);
|
||||
HUD::mark_all_slots_dirty(&g_game->_hud,0,0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 00721c80
|
||||
void History::merge(void *other)
|
||||
{
|
||||
void **ppvVar1;
|
||||
int iVar2;
|
||||
int iVar3;
|
||||
int iVar4;
|
||||
uint size;
|
||||
int *oldItem;
|
||||
int *oldItem;
|
||||
undefined1 oldBegin [16];
|
||||
void *oldCapacity;
|
||||
History *history;
|
||||
int *oldEnd;
|
||||
int *otherEnd;
|
||||
undefined1 *puStack_20;
|
||||
void *local_1c;
|
||||
undefined1 *puStack_18;
|
||||
undefined4 local_14;
|
||||
|
||||
puStack_20 = oldBegin + 0x3c;
|
||||
puStack_18 = &LAB_00afcd4d;
|
||||
local_1c = ExceptionList;
|
||||
ExceptionList = &local_1c;
|
||||
if (this->_isLocked == 0) {
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0x0))) = GHIDRA_CAST<int *>(0x0);
|
||||
oldCapacity = (void *)0x0;
|
||||
local_14 = 0;
|
||||
oldEnd = GHIDRA_CAST<int *>(0x0);
|
||||
if (GHIDRA_CAST<History *>(oldBegin) != this) {
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0x0))) = (this->_historyItems)._begin;
|
||||
oldCapacity = (this->_historyItems)._capacity;
|
||||
(this->_historyItems)._begin = (void *)0x0;
|
||||
oldEnd = (this->_historyItems)._end;
|
||||
(this->_historyItems)._end = (void *)0x0;
|
||||
(this->_historyItems)._capacity = (void *)0x0;
|
||||
}
|
||||
oldItem = *GHIDRA_CAST<int **>(other);
|
||||
otherEnd = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(other) + 4));
|
||||
oldItem = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<int *>(oldBegin))) + 0x0)));
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0x4))) = oldEnd;
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0x8))) = oldCapacity;
|
||||
history = this;
|
||||
while( true ) {
|
||||
while (oldItem != oldEnd) {
|
||||
if ((oldItem != otherEnd) && (*oldItem < *oldItem)) goto LAB_00721d9e;
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) = (this->_historyItems)._end;
|
||||
if ((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((void *)oldBegin)) + 0xc))) == (this->_historyItems)._capacity) {
|
||||
std::vector<28byte>::_Emplace_reallocate((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))),oldItem);
|
||||
oldItem = oldItem + 7;
|
||||
this = history;
|
||||
}
|
||||
else {
|
||||
iVar2 = oldItem[1];
|
||||
iVar3 = oldItem[2];
|
||||
iVar4 = oldItem[3];
|
||||
*(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<int *>(oldBegin))) + 0xc))) = *oldItem;
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 4)) = iVar2;
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 8)) = iVar3;
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 0xc)) = iVar4;
|
||||
iVar2 = oldItem[5];
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 0x10)) = oldItem[4];
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 0x14)) = iVar2;
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 0x18)) = oldItem[6];
|
||||
ppvVar1 = &(this->_historyItems)._end;
|
||||
*ppvVar1 = (void *)(GHIDRA_INT(*ppvVar1) + 0x1c);
|
||||
oldItem = oldItem + 7;
|
||||
}
|
||||
}
|
||||
if (oldItem == otherEnd) break;
|
||||
LAB_00721d9e:
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) = (this->_historyItems)._end;
|
||||
if ((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((void *)oldBegin)) + 0xc))) == (this->_historyItems)._capacity) {
|
||||
std::vector<28byte>::_Emplace_reallocate((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))),oldItem);
|
||||
oldItem = oldItem + 7;
|
||||
this = history;
|
||||
}
|
||||
else {
|
||||
iVar2 = oldItem[1];
|
||||
iVar3 = oldItem[2];
|
||||
iVar4 = oldItem[3];
|
||||
*(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<int *>(oldBegin))) + 0xc))) = *oldItem;
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 4)) = iVar2;
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 8)) = iVar3;
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 0xc)) = iVar4;
|
||||
iVar2 = oldItem[5];
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 0x10)) = oldItem[4];
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 0x14)) = iVar2;
|
||||
*GHIDRA_CAST<int *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0xc))) + 0x18)) = oldItem[6];
|
||||
ppvVar1 = &(this->_historyItems)._end;
|
||||
*ppvVar1 = (void *)(GHIDRA_INT(*ppvVar1) + 0x1c);
|
||||
oldItem = oldItem + 7;
|
||||
}
|
||||
}
|
||||
HUD::mark_all_slots_dirty(&g_game->_hud,0,0);
|
||||
if ((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<int *>(oldBegin))) + 0x0))) != GHIDRA_CAST<int *>(0x0)) {
|
||||
size = ((GHIDRA_INT(oldCapacity) - (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0x0)))) / 0x1c) * 0x1c;
|
||||
oldItem = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<int *>(oldBegin))) + 0x0)));
|
||||
if (0xfff < size) {
|
||||
oldItem = *GHIDRA_CAST<int **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0x0))) + -4));
|
||||
size = size + 0x23;
|
||||
if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(oldBegin)) + 0x0))) + (-4 - GHIDRA_INT(oldItem))))) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(oldItem,size);
|
||||
}
|
||||
}
|
||||
ExceptionList = local_1c;
|
||||
return;
|
||||
}
|
||||
|
||||
// 007220a0
|
||||
void History::remove_index_refs(int index)
|
||||
{
|
||||
History *slot;
|
||||
History *compactSlot;
|
||||
int iVar1;
|
||||
int iVar2;
|
||||
int iVar3;
|
||||
int firstFreeSlot;
|
||||
void *storedIndex;
|
||||
|
||||
compactSlot = this + 1;
|
||||
slot = compactSlot;
|
||||
iVar3 = 0x10;
|
||||
do {
|
||||
iVar1 = iVar3;
|
||||
storedIndex = (slot->_historyItems)._begin;
|
||||
if (storedIndex == (void *)index) {
|
||||
(slot->_historyItems)._begin = (void *)0xffffffff;
|
||||
}
|
||||
else if (index < GHIDRA_INT(storedIndex)) {
|
||||
(slot->_historyItems)._begin = (void *)(GHIDRA_INT(storedIndex) + -1);
|
||||
}
|
||||
slot = GHIDRA_CAST<History *>(&(slot->_historyItems)._end);
|
||||
iVar3 = iVar1 + -1;
|
||||
} while (iVar3 != 0);
|
||||
firstFreeSlot = -1;
|
||||
iVar3 = 0;
|
||||
iVar1 = iVar1 + -5;
|
||||
do {
|
||||
storedIndex = (compactSlot->_historyItems)._begin;
|
||||
iVar2 = iVar1;
|
||||
if (GHIDRA_INT(storedIndex) < 0) {
|
||||
if (firstFreeSlot < 0) {
|
||||
iVar2 = (-0x14 - GHIDRA_INT(this)) + GHIDRA_INT(compactSlot);
|
||||
firstFreeSlot = iVar3;
|
||||
}
|
||||
}
|
||||
else if (-1 < firstFreeSlot) {
|
||||
firstFreeSlot = firstFreeSlot + 1;
|
||||
iVar2 = iVar1 + 4;
|
||||
(compactSlot->_historyItems)._begin = *(void **)(GHIDRA_INT(&this[1]._historyItems._begin) + iVar1);
|
||||
*(void **)(GHIDRA_INT(&this[1]._historyItems._begin) + iVar1) = storedIndex;
|
||||
}
|
||||
iVar3 = iVar3 + 1;
|
||||
compactSlot = GHIDRA_CAST<History *>(&(compactSlot->_historyItems)._end);
|
||||
iVar1 = iVar2;
|
||||
} while (iVar3 < 0x10);
|
||||
return;
|
||||
}
|
||||
Reference in new issue
Block a user