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,161 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 0095f4f0
|
||||
void Cutscene::ANM2Part::vfunc_3()
|
||||
{
|
||||
void *musicManager = this;
|
||||
longlong lVar1;
|
||||
longlong lVar2;
|
||||
byte isAnimSet;
|
||||
byte *anim;
|
||||
uint uVar3;
|
||||
uint uVar4;
|
||||
uint uVar5;
|
||||
MusicManager *musicManager;
|
||||
int musicid;
|
||||
ulonglong timeNs;
|
||||
float musicVolume;
|
||||
Manager *manager;
|
||||
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(musicManager) + 0x24)) != 0) {
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(musicManager) + 0x2c)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(musicManager) + 0x28)) = 0;
|
||||
}
|
||||
anim = GHIDRA_CAST<byte *>((GHIDRA_INT(musicManager) + 0x58));
|
||||
if (0xf < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(musicManager) + 0x6c))) {
|
||||
anim = *GHIDRA_CAST<byte **>(anim);
|
||||
}
|
||||
isAnimSet = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((GHIDRA_INT(musicManager) + 0x80)))))->ANM2::SetAnimation(anim,1);
|
||||
if (isAnimSet != 0) {
|
||||
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((GHIDRA_INT(musicManager) + 0xb0)))))->AnimationState::Rewind();
|
||||
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(musicManager) + 0xc4)) = 1;
|
||||
}
|
||||
manager = g_manager;
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(musicManager) + 0x74)) == 0) {
|
||||
musicVolume = 0.0;
|
||||
if ((g_manager->_musicManager)._isEnabled != 0) {
|
||||
musicVolume = (g_manager->_optionsConfig)._musicVolume;
|
||||
}
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(musicManager) + 0x70)) == 0x3c) {
|
||||
if (((g_manager->_persistentGameData)._achievements[0x27d] == 0) &&
|
||||
(((g_manager->_state != 2 || (g_game == GHIDRA_CAST<Game *>(0x0))) ||
|
||||
(((g_game->_dailyChallenge)._id == 0 && (g_game->_isDebug == 0)))))) {
|
||||
if (((g_manager->_persistentGameData)._achievements[0x20] == 0) &&
|
||||
(((g_manager->_state != 2 || (g_game == GHIDRA_CAST<Game *>(0x0))) ||
|
||||
(((g_game->_dailyChallenge)._id == 0 && (g_game->_isDebug == 0)))))) {
|
||||
musicid = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(musicManager) + 0x70));
|
||||
if (musicid < 0) goto LAB_0095f67a;
|
||||
}
|
||||
else {
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(musicManager) + 0x70)) = 0x46;
|
||||
musicid = 0x46;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(musicManager) + 0x70)) = 0x47;
|
||||
musicid = 0x47;
|
||||
}
|
||||
musicManager = &manager->_musicManager;
|
||||
if (musicid < (GHIDRA_INT((manager->_musicManager)._entries._end) -
|
||||
GHIDRA_INT((manager->_musicManager)._entries._begin)) / 0x60) {
|
||||
(GHIDRA_CAST<Music *>((GHIDRA_CAST<Music *>(musicManager))))->Music::Play(musicid,0.0);
|
||||
musicManager->_channels[musicManager->_currentChannel]._volume = 0.0;
|
||||
musicManager->_channels[musicManager->_currentChannel]._targetVolume = musicVolume;
|
||||
musicManager->_channels[musicManager->_currentChannel]._fadeRate = 0.08;
|
||||
}
|
||||
}
|
||||
else {
|
||||
(GHIDRA_CAST<Music *>((GHIDRA_CAST<Music *>(&g_manager->_musicManager))))->Music::Play(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(musicManager) + 0x70)),
|
||||
musicVolume + musicVolume);
|
||||
}
|
||||
}
|
||||
LAB_0095f67a:
|
||||
timeNs = GetTimeNs();
|
||||
uVar4 = GHIDRA_UINT((timeNs >> 0x20));
|
||||
lVar1 = (timeNs & 0xffffffff) * 0x431bde82;
|
||||
lVar2 = (ulonglong)uVar4 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
||||
uVar5 = GHIDRA_UINT(((ulonglong)lVar2 >> 0x20));
|
||||
uVar3 = GHIDRA_INT(((ulonglong)lVar1 >> 0x20)) + GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar1),GHIDRA_UINT(lVar2)));
|
||||
lVar1 = (ulonglong)uVar4 * 0x431bde82 + (ulonglong)CONCAT14(CARRY4(uVar5,uVar3),uVar5 + uVar3);
|
||||
uVar3 = GHIDRA_UINT(((ulonglong)lVar1 >> 0x20));
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(musicManager) + 0x38)) = GHIDRA_UINT(lVar1) >> 0x12 | uVar3 * 0x4000;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(musicManager) + 0x3c)) = uVar3 >> 0x12;
|
||||
return;
|
||||
}
|
||||
|
||||
// 0095f6f0
|
||||
void Cutscene::ANM2Part::vfunc_4()
|
||||
{
|
||||
longlong lVar1;
|
||||
longlong lVar2;
|
||||
uint diffSign;
|
||||
uint uVar3;
|
||||
int currentFrame;
|
||||
float volume;
|
||||
ulonglong timeNs;
|
||||
double dVar4;
|
||||
int animFrameCount;
|
||||
int musicStartFrame;
|
||||
|
||||
if ((g_manager->_framecount & 1) != 0) {
|
||||
return;
|
||||
}
|
||||
timeNs = GetTimeNs();
|
||||
uVar3 = GHIDRA_UINT((timeNs >> 0x20));
|
||||
lVar1 = (timeNs & 0xffffffff) * 0x431bde82;
|
||||
lVar2 = (ulonglong)uVar3 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
||||
lVar1 = (ulonglong)uVar3 * 0x431bde82 +
|
||||
(ulonglong)
|
||||
CONCAT14(CARRY4(GHIDRA_UINT(((ulonglong)lVar2 >> 0x20)),
|
||||
GHIDRA_INT(((ulonglong)lVar1 >> 0x20)) + GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar1),GHIDRA_UINT(lVar2)))),
|
||||
GHIDRA_INT(((ulonglong)(lVar2 + lVar1) >> 0x20)));
|
||||
uVar3 = ((((GHIDRA_UINT(lVar1) >> 0x12 | GHIDRA_INT(((ulonglong)lVar1 >> 0x20)) * 0x4000) -
|
||||
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x198))) - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x38))) * 0x1e) / 1000;
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xb4)) == 0) {
|
||||
animFrameCount = 0;
|
||||
currentFrame = -1;
|
||||
}
|
||||
else {
|
||||
animFrameCount = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xb4)) + 0x30));
|
||||
dVar4 = floor((double)*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0xc0)));
|
||||
currentFrame = GHIDRA_INT(dVar4);
|
||||
}
|
||||
diffSign = GHIDRA_INT((currentFrame - uVar3)) >> 0x1f;
|
||||
if ((GHIDRA_INT(((currentFrame - uVar3 ^ diffSign) - diffSign)) < 3) || (animFrameCount <= GHIDRA_INT(uVar3))) {
|
||||
if (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(this) + 0x189)) != '\0') {
|
||||
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((GHIDRA_INT(this) + 0xb0)))))->AnimationState::Update();
|
||||
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((GHIDRA_INT(this) + 0xd0)))))->AnimationState::Update();
|
||||
}
|
||||
}
|
||||
else {
|
||||
(GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((GHIDRA_INT(this) + 0x80)))))->ANM2::GetFrame();
|
||||
KAGE_LogMessage(1,GHIDRA_CAST<byte *>("Cutscene: correct anm2 timing: f%d -> f%d\n"));
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xb4)) == 0) goto LAB_0095f882;
|
||||
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((GHIDRA_INT(this) + 0xb0)))))->AnimationState::SetFrameFloat((float)uVar3);
|
||||
}
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xb4)) != 0) {
|
||||
floor((double)*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0xc0)));
|
||||
}
|
||||
LAB_0095f882:
|
||||
FUN_0095f1a0();
|
||||
musicStartFrame = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x74));
|
||||
if (currentFrame < musicStartFrame) {
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xb4)) == 0) {
|
||||
currentFrame = -1;
|
||||
}
|
||||
else {
|
||||
dVar4 = floor((double)*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0xc0)));
|
||||
currentFrame = GHIDRA_INT(dVar4);
|
||||
}
|
||||
if (musicStartFrame <= currentFrame) {
|
||||
if ((g_manager->_musicManager)._isEnabled == 0) {
|
||||
volume = 0.0;
|
||||
}
|
||||
else {
|
||||
volume = (g_manager->_optionsConfig)._musicVolume;
|
||||
}
|
||||
(GHIDRA_CAST<Music *>((GHIDRA_CAST<Music *>(&g_manager->_musicManager))))->Music::Play(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x70)),volume);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 0095fd70
|
||||
void Cutscene::TemporaryPart::vfunc_1()
|
||||
{
|
||||
byte *extraout_EAX;
|
||||
byte *extraout_EAX_00;
|
||||
byte *fontPath;
|
||||
void *ptr;
|
||||
char *pcVar1;
|
||||
uint uVar2;
|
||||
char *terminusPath [4];
|
||||
uint terminusPathSize;
|
||||
uint terminusPathCapacity;
|
||||
void *redirectedPath [4];
|
||||
uint redirectedPathSize;
|
||||
uint redirectedPathCapacity;
|
||||
char *pathText [4];
|
||||
uint pathTextSize;
|
||||
uint pathTextCapacity;
|
||||
uint local_14;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
char *local_8;
|
||||
Manager *manager;
|
||||
|
||||
manager = g_manager;
|
||||
local_8 = GHIDRA_CAST<char *>(0xffffffff);
|
||||
puStack_c = &LAB_00b0c7f5;
|
||||
local_10 = ExceptionList;
|
||||
local_14 = __security_cookie ^ GHIDRA_UINT((pathText + 10));
|
||||
ExceptionList = &local_10;
|
||||
pathText[0] = std::_Allocate(0x20);
|
||||
pathTextSize = 0x1b;
|
||||
pathTextCapacity = 0x1f;
|
||||
builtin_strncpy(pathText[0],"font/TeamMeatFont20Bold.fnt",0x1c);
|
||||
local_8 = GHIDRA_CAST<char *>(0x0);
|
||||
ModManager::TryRedirectPath
|
||||
(&manager->_modManager,GHIDRA_CAST<std_string *>(redirectedPath),GHIDRA_CAST<std_string *>(pathText));
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 1;
|
||||
fontPath = extraout_EAX;
|
||||
if (0xf < *GHIDRA_CAST<uint *>((extraout_EAX + 0x14))) {
|
||||
fontPath = *GHIDRA_CAST<byte **>(extraout_EAX);
|
||||
}
|
||||
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((GHIDRA_INT(this) + 0x40)))))->Font::Load(fontPath,0);
|
||||
local_8 = GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_8))) + 0x1))) << 8));
|
||||
if (0xf < redirectedPathCapacity) {
|
||||
uVar2 = redirectedPathCapacity + 1;
|
||||
ptr = redirectedPath[0];
|
||||
if (0xfff < uVar2) {
|
||||
ptr = *(void **)(GHIDRA_INT(redirectedPath[0]) + -4);
|
||||
uVar2 = redirectedPathCapacity + 0x24;
|
||||
if (0x1f < GHIDRA_UINT((GHIDRA_INT(redirectedPath[0]) + (-4 - GHIDRA_INT(ptr))))) goto LAB_0095fe96;
|
||||
}
|
||||
operator_delete(ptr,uVar2);
|
||||
}
|
||||
local_8 = GHIDRA_CAST<char *>(0xffffffff);
|
||||
redirectedPathSize = 0;
|
||||
redirectedPathCapacity = 0xf;
|
||||
redirectedPath[0] = (void *)(GHIDRA_UINT(redirectedPath[0]) & 0xffffff00);
|
||||
if (0xf < pathTextCapacity) {
|
||||
uVar2 = pathTextCapacity + 1;
|
||||
pcVar1 = pathText[0];
|
||||
if (0xfff < uVar2) {
|
||||
pcVar1 = *GHIDRA_CAST<char **>((pathText[0] + -4));
|
||||
uVar2 = pathTextCapacity + 0x24;
|
||||
if (GHIDRA_CAST<char *>(0x1f) < pathText[0] + (-4 - GHIDRA_INT(pcVar1))) {
|
||||
LAB_0095fe96:
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(pcVar1,uVar2);
|
||||
}
|
||||
manager = g_manager;
|
||||
terminusPath[0] = std::_Allocate(0x20);
|
||||
terminusPathSize = 0x11;
|
||||
terminusPathCapacity = 0x1f;
|
||||
builtin_strncpy(terminusPath[0],"font/terminus.fnt",0x12);
|
||||
local_8 = GHIDRA_CAST<char *>(0x2);
|
||||
ModManager::TryRedirectPath
|
||||
(&manager->_modManager,GHIDRA_CAST<std_string *>(pathText),GHIDRA_CAST<std_string *>(terminusPath));
|
||||
local_8 = GHIDRA_CAST<char *>(CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),3));
|
||||
fontPath = extraout_EAX_00;
|
||||
if (0xf < *GHIDRA_CAST<uint *>((extraout_EAX_00 + 0x14))) {
|
||||
fontPath = *GHIDRA_CAST<byte **>(extraout_EAX_00);
|
||||
}
|
||||
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((GHIDRA_INT(this) + 0x8c)))))->Font::Load(fontPath,0);
|
||||
if (0xf < pathTextCapacity) {
|
||||
uVar2 = pathTextCapacity + 1;
|
||||
pcVar1 = pathText[0];
|
||||
if (0xfff < uVar2) {
|
||||
pcVar1 = *GHIDRA_CAST<char **>((pathText[0] + -4));
|
||||
uVar2 = pathTextCapacity + 0x24;
|
||||
if (GHIDRA_CAST<char *>(0x1f) < pathText[0] + (-4 - GHIDRA_INT(pcVar1))) goto LAB_0095ff7d;
|
||||
}
|
||||
operator_delete(pcVar1,uVar2);
|
||||
}
|
||||
pathTextSize = 0;
|
||||
pathTextCapacity = 0xf;
|
||||
pathText[0] = GHIDRA_CAST<char *>((GHIDRA_UINT(pathText[0]) & 0xffffff00));
|
||||
if (0xf < terminusPathCapacity) {
|
||||
uVar2 = terminusPathCapacity + 1;
|
||||
pcVar1 = terminusPath[0];
|
||||
if (0xfff < uVar2) {
|
||||
pcVar1 = *GHIDRA_CAST<char **>((terminusPath[0] + -4));
|
||||
uVar2 = terminusPathCapacity + 0x24;
|
||||
if (GHIDRA_CAST<char *>(0x1f) < terminusPath[0] + (-4 - GHIDRA_INT(pcVar1))) {
|
||||
LAB_0095ff7d:
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(pcVar1,uVar2);
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
Reference in new issue
Block a user