--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
390 lines
12 KiB
C++
390 lines
12 KiB
C++
#include "classes.h"
|
|
|
|
// 00426a50
|
|
void DailyChallenge::Init(uint32_t dailyDate)
|
|
{
|
|
code *pcVar1;
|
|
int iVar2;
|
|
tm *tmResult;
|
|
uint32_t uVar3;
|
|
uint32_t rolledPlayerType;
|
|
bool isGroundhogDay;
|
|
RNG rng;
|
|
uint8_t date [8];
|
|
__time64_t dateTime;
|
|
tm dateTm;
|
|
uint32_t local_c;
|
|
uint8_t auStack_8 [4];
|
|
|
|
local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4));
|
|
this->_id = 0;
|
|
this->_seed = 0;
|
|
this->_specialDailyId = 0;
|
|
this->_isPractice = 0;
|
|
(GHIDRA_CAST<ChallengeParam *>((&this->_params)))->ChallengeParam::Reset();
|
|
(this->_params)._isPathTypeSet = 1;
|
|
iVar2 = holiday_get_current(dailyDate);
|
|
this->_specialDailyId = iVar2;
|
|
this->_id = dailyDate;
|
|
DateTime::set_from_yyyymmdd(date,dailyDate);
|
|
isGroundhogDay = this->_specialDailyId == 2;
|
|
rng._seed = dailyDate;
|
|
if (isGroundhogDay) {
|
|
rng._seed = dailyDate - 1;
|
|
}
|
|
rng._shift3 = 0x15;
|
|
rng._shift1 = 10;
|
|
rng._shift2 = 9;
|
|
(this->_params)._playerType = 0x29;
|
|
uVar3 = dailyDate - 1;
|
|
if (!isGroundhogDay) {
|
|
uVar3 = dailyDate;
|
|
}
|
|
do {
|
|
if (uVar3 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> 10 ^ rng._seed;
|
|
rng._seed = rng._seed << 9 ^ rng._seed;
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> 0x15 ^ rng._seed;
|
|
rolledPlayerType = GHIDRA_UINT(rng._seed) % 0x14;
|
|
(this->_params)._playerType = rolledPlayerType;
|
|
uVar3 = rng._seed;
|
|
} while ((((rolledPlayerType == 0xc) || (rolledPlayerType == 0xb)) || (rolledPlayerType == 0x11))
|
|
|| (rolledPlayerType == 0x14));
|
|
if (rng._seed == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> 10 ^ rng._seed;
|
|
rng._seed = rng._seed << 9 ^ rng._seed;
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> 0x15 ^ rng._seed;
|
|
switch(rng._seed & 3) {
|
|
case 0:
|
|
(this->_params)._endStage = 6;
|
|
break;
|
|
case 1:
|
|
(this->_params)._endStage = 8;
|
|
break;
|
|
case 2:
|
|
(this->_params)._endStage = 10;
|
|
break;
|
|
case 3:
|
|
(this->_params)._endStage = 0xb;
|
|
}
|
|
if ((this->_params)._endStage < 10) {
|
|
LAB_00426bde:
|
|
iVar2 = 1;
|
|
}
|
|
else {
|
|
if (rng._seed == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> 10 ^ rng._seed;
|
|
rng._seed = rng._seed << 9 ^ rng._seed;
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> 0x15 ^ rng._seed;
|
|
if ((rng._seed & 1U) != 0) goto LAB_00426bde;
|
|
iVar2 = 0;
|
|
}
|
|
(this->_params)._pathType = iVar2;
|
|
(this->_params)._isMegaSatan = 0;
|
|
(this->_params)._difficulty = 0;
|
|
if ((date[0] & 2) != 0) {
|
|
dateTime = _mkgmtime64(&dateTm);
|
|
}
|
|
if ((date[0] & 3) != 0) {
|
|
tmResult = _gmtime64(&dateTime);
|
|
dateTm.tm_sec = tmResult->tm_sec;
|
|
dateTm.tm_min = tmResult->tm_min;
|
|
dateTm.tm_hour = tmResult->tm_hour;
|
|
dateTm.tm_mday = tmResult->tm_mday;
|
|
dateTm.tm_mon = tmResult->tm_mon;
|
|
dateTm.tm_year = tmResult->tm_year;
|
|
dateTm.tm_wday = tmResult->tm_wday;
|
|
dateTm.tm_yday = tmResult->tm_yday;
|
|
dateTm.tm_isdst = tmResult->tm_isdst;
|
|
}
|
|
date[0] = date[0] & 0xfc;
|
|
if ((char)dateTm.tm_wday == '\0') {
|
|
(this->_params)._endStage = 0xb;
|
|
(this->_params)._isMegaSatan = 1;
|
|
if (rng._seed == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift1 & 0x1f) ^ rng._seed;
|
|
rng._seed = rng._seed << ((uint8_t)rng._shift2 & 0x1f) ^ rng._seed;
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift3 & 0x1f) ^ rng._seed;
|
|
if (rng._seed != (GHIDRA_UINT(rng._seed) / 6) * 6) goto LAB_00427185;
|
|
LAB_0042717b:
|
|
(this->_params)._difficulty = 1;
|
|
goto LAB_00427185;
|
|
}
|
|
if ((char)dateTm.tm_wday == '\x01') {
|
|
(this->_params)._pathType = 2;
|
|
(this->_params)._endStage = 8;
|
|
goto LAB_00427185;
|
|
}
|
|
if ((char)dateTm.tm_wday == '\x02') {
|
|
switch((this->_params)._playerType) {
|
|
case 0:
|
|
(this->_params)._playerType = 0x15;
|
|
break;
|
|
case 1:
|
|
(this->_params)._playerType = 0x16;
|
|
break;
|
|
case 2:
|
|
(this->_params)._playerType = 0x17;
|
|
break;
|
|
case 3:
|
|
(this->_params)._playerType = 0x18;
|
|
break;
|
|
case 4:
|
|
(this->_params)._playerType = 0x19;
|
|
break;
|
|
case 5:
|
|
(this->_params)._playerType = 0x1a;
|
|
break;
|
|
case 6:
|
|
(this->_params)._playerType = 0x1b;
|
|
break;
|
|
case 7:
|
|
(this->_params)._playerType = 0x1c;
|
|
break;
|
|
case 8:
|
|
(this->_params)._playerType = 0x1d;
|
|
break;
|
|
case 9:
|
|
(this->_params)._playerType = 0x1e;
|
|
break;
|
|
case 10:
|
|
(this->_params)._playerType = 0x1f;
|
|
break;
|
|
default:
|
|
KAGE_LogMessage(8,(uint8_t *)
|
|
"GetTaintedId() could not find tainted counterpart to given ePlayerType (%d) \n"
|
|
);
|
|
break;
|
|
case 0xd:
|
|
(this->_params)._playerType = 0x20;
|
|
break;
|
|
case 0xe:
|
|
(this->_params)._playerType = 0x21;
|
|
break;
|
|
case 0xf:
|
|
(this->_params)._playerType = 0x22;
|
|
break;
|
|
case 0x10:
|
|
(this->_params)._playerType = 0x23;
|
|
break;
|
|
case 0x12:
|
|
(this->_params)._playerType = 0x24;
|
|
break;
|
|
case 0x13:
|
|
(this->_params)._playerType = 0x25;
|
|
}
|
|
if (rng._seed == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift1 & 0x1f) ^ rng._seed;
|
|
rng._seed = rng._seed << ((uint8_t)rng._shift2 & 0x1f) ^ rng._seed;
|
|
rng._seed = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift3 & 0x1f) ^ rng._seed;
|
|
uVar3 = GHIDRA_UINT(rng._seed) % 100;
|
|
if (uVar3 < 0x14) {
|
|
(this->_params)._endStage = 6;
|
|
goto LAB_00427185;
|
|
}
|
|
if (uVar3 < 0x28) {
|
|
(this->_params)._endStage = 8;
|
|
goto LAB_00427185;
|
|
}
|
|
if (0x31 < uVar3) {
|
|
if (0x40 < uVar3) {
|
|
if (0x4f < uVar3) {
|
|
(this->_params)._endStage = 0xb;
|
|
(this->_params)._pathType = GHIDRA_UINT((0x59 < uVar3));
|
|
goto LAB_00427185;
|
|
}
|
|
goto LAB_00426e6e;
|
|
}
|
|
goto LAB_00426e53;
|
|
}
|
|
}
|
|
else {
|
|
if ((char)dateTm.tm_wday == '\x03') {
|
|
(this->_params)._endStage = 0xc;
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
|
|
(this->_params)._pathType = GHIDRA_UINT((uVar3 == 0));
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(100);
|
|
if (GHIDRA_INT(uVar3) < 0x14) {
|
|
(this->_params)._endStage = 6;
|
|
goto LAB_00427185;
|
|
}
|
|
if (GHIDRA_INT(uVar3) < 0x28) {
|
|
(this->_params)._endStage = 8;
|
|
goto LAB_00427185;
|
|
}
|
|
}
|
|
else {
|
|
if ((char)dateTm.tm_wday == '\x04') {
|
|
(this->_params)._pathType = 3;
|
|
(this->_params)._endStage = 0xd;
|
|
goto LAB_00427185;
|
|
}
|
|
if ((char)dateTm.tm_wday != '\x05') {
|
|
if ((char)dateTm.tm_wday != '\x06') goto LAB_00427185;
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(100);
|
|
if (GHIDRA_INT(uVar3) < 0xf) {
|
|
(this->_params)._endStage = 6;
|
|
}
|
|
else if (GHIDRA_INT(uVar3) < 0x1e) {
|
|
(this->_params)._endStage = 8;
|
|
}
|
|
else if (GHIDRA_INT(uVar3) < 0x28) {
|
|
(this->_params)._endStage = 0xc;
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
|
|
(this->_params)._pathType = GHIDRA_UINT((uVar3 == 0));
|
|
}
|
|
else if (GHIDRA_INT(uVar3) < 0x32) {
|
|
(this->_params)._endStage = 10;
|
|
(this->_params)._pathType = 0;
|
|
}
|
|
else if (GHIDRA_INT(uVar3) < 0x3c) {
|
|
(this->_params)._endStage = 10;
|
|
(this->_params)._pathType = 1;
|
|
}
|
|
else if (GHIDRA_INT(uVar3) < 0x46) {
|
|
(this->_params)._endStage = 0xb;
|
|
(this->_params)._pathType = 0;
|
|
}
|
|
else if (GHIDRA_INT(uVar3) < 0x50) {
|
|
(this->_params)._endStage = 0xb;
|
|
(this->_params)._pathType = 1;
|
|
}
|
|
else if (GHIDRA_INT(uVar3) < 0x5a) {
|
|
(this->_params)._pathType = 3;
|
|
(this->_params)._endStage = 0xd;
|
|
}
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
|
|
if (uVar3 != 0) {
|
|
switch((this->_params)._playerType) {
|
|
case 0:
|
|
(this->_params)._playerType = 0x15;
|
|
break;
|
|
case 1:
|
|
(this->_params)._playerType = 0x16;
|
|
break;
|
|
case 2:
|
|
(this->_params)._playerType = 0x17;
|
|
break;
|
|
case 3:
|
|
(this->_params)._playerType = 0x18;
|
|
break;
|
|
case 4:
|
|
(this->_params)._playerType = 0x19;
|
|
break;
|
|
case 5:
|
|
(this->_params)._playerType = 0x1a;
|
|
break;
|
|
case 6:
|
|
(this->_params)._playerType = 0x1b;
|
|
break;
|
|
case 7:
|
|
(this->_params)._playerType = 0x1c;
|
|
break;
|
|
case 8:
|
|
(this->_params)._playerType = 0x1d;
|
|
break;
|
|
case 9:
|
|
(this->_params)._playerType = 0x1e;
|
|
break;
|
|
case 10:
|
|
(this->_params)._playerType = 0x1f;
|
|
break;
|
|
default:
|
|
KAGE_LogMessage(8,(uint8_t *)
|
|
"GetTaintedId() could not find tainted counterpart to given ePlayerType (%d) \n"
|
|
);
|
|
break;
|
|
case 0xd:
|
|
(this->_params)._playerType = 0x20;
|
|
break;
|
|
case 0xe:
|
|
(this->_params)._playerType = 0x21;
|
|
break;
|
|
case 0xf:
|
|
(this->_params)._playerType = 0x22;
|
|
break;
|
|
case 0x10:
|
|
(this->_params)._playerType = 0x23;
|
|
break;
|
|
case 0x12:
|
|
(this->_params)._playerType = 0x24;
|
|
break;
|
|
case 0x13:
|
|
(this->_params)._playerType = 0x25;
|
|
}
|
|
}
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
|
|
if (uVar3 == 0) goto LAB_00427185;
|
|
goto LAB_0042717b;
|
|
}
|
|
(this->_params)._difficulty = 1;
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(100);
|
|
if (GHIDRA_INT(uVar3) < 0x14) {
|
|
(this->_params)._endStage = 6;
|
|
goto LAB_00427185;
|
|
}
|
|
if (GHIDRA_INT(uVar3) < 0x28) {
|
|
(this->_params)._endStage = 8;
|
|
goto LAB_00427185;
|
|
}
|
|
}
|
|
if (0x31 < GHIDRA_INT(uVar3)) {
|
|
if (0x40 < GHIDRA_INT(uVar3)) {
|
|
if (0x4f < GHIDRA_INT(uVar3)) {
|
|
(this->_params)._endStage = 0xb;
|
|
(this->_params)._pathType = GHIDRA_UINT((0x59 < GHIDRA_INT(uVar3)));
|
|
goto LAB_00427185;
|
|
}
|
|
LAB_00426e6e:
|
|
(this->_params)._endStage = 10;
|
|
(this->_params)._pathType = 1;
|
|
goto LAB_00427185;
|
|
}
|
|
LAB_00426e53:
|
|
(this->_params)._endStage = 10;
|
|
(this->_params)._pathType = 0;
|
|
goto LAB_00427185;
|
|
}
|
|
}
|
|
(this->_params)._endStage = 0xc;
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
|
|
(this->_params)._pathType = GHIDRA_UINT((uVar3 == 0));
|
|
LAB_00427185:
|
|
if (rng._seed == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
uVar3 = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift1 & 0x1f) ^ rng._seed;
|
|
uVar3 = uVar3 << ((uint8_t)rng._shift2 & 0x1f) ^ uVar3;
|
|
this->_seed = uVar3 >> ((uint8_t)rng._shift3 & 0x1f) ^ uVar3;
|
|
FUN_00427290(this->_specialDailyId);
|
|
return;
|
|
}
|