//
// SecretLayer2::onDoor from 0x14057a3e0 to 0x14057acf8 (2328 bytes)
//
// 2 xrefs:
// > SecretLayer2::init @ 0x140578d86
// > ??> @ 0x14092c870
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:34:24 +0000
//
// Hidden C++ exception states: #wind=4
void __fastcall SecretLayer2::onDoor(_DWORD *a1)
{
__int64 v2; // rcx
__int64 v3; // rdx
__int64 v4; // rcx
__int64 v5; // r8
__int64 v6; // r9
struct cocos2d::CCScene *v7; // rdi
__int64 v8; // rcx
__int128 *v9; // rbx
struct cocos2d::CCScene *v10; // rbx
__int64 v11; // rcx
cocos2d::CCDirector *v12; // rax
unsigned __int64 v13; // r14
int v14; // eax
int v15; // eax
int v16; // eax
__int64 v17; // rcx
__int64 v18; // rdi
char *v19; // rax
char *v20; // rax
char *v21; // rax
char *v22; // rax
char *v23; // rax
char *v24; // rax
char *v25; // rax
char *v26; // rax
char *v27; // rax
char *v28; // rax
char *v29; // rax
void **v30; // rbx
void **v31; // rax
cocos2d::CCLayerColor *DialogLayer; // rsi
__int64 v33; // rcx
__int64 v34; // rax
__int64 v35; // rdi
__int64 v36; // rbx
__int64 v37; // rax
void *v38; // rcx
__int16 v39; // [rsp+30h] [rbp-59h] BYREF
char v40; // [rsp+32h] [rbp-57h]
__int128 *v41; // [rsp+40h] [rbp-49h] BYREF
__int128 v42; // [rsp+48h] [rbp-41h] BYREF
unsigned __int64 v43; // [rsp+58h] [rbp-31h]
__int64 v44; // [rsp+60h] [rbp-29h]
_WORD v45[8]; // [rsp+68h] [rbp-21h] BYREF
__int64 v46; // [rsp+78h] [rbp-11h]
__int64 v47; // [rsp+80h] [rbp-9h]
_BYTE v48[8]; // [rsp+88h] [rbp-1h] BYREF
void *Src[2]; // [rsp+90h] [rbp+7h] BYREF
unsigned __int64 v50; // [rsp+A0h] [rbp+17h]
__int64 v51; // [rsp+A8h] [rbp+1Fh]
v2 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v41 = (__int128 *)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v41);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v2 = qword_14090BFD0;
}
if ( GameManager::getUGV(v2, &word_14070D04C) )
{
v7 = (struct cocos2d::CCScene *)cocos2d::CCScene::create(v4, v3, v5, v6);
*(_QWORD *)(cocos2d::CCApplication::sharedApplication(v8) + 232) = v7;
v9 = (__int128 *)operator new(0x1D0u);
v41 = v9;
cocos2d::CCLayer::CCLayer((cocos2d::CCLayer *)v9);
*(_QWORD *)v9 = &SecretLayer3::`vftable';
*((_QWORD *)v9 + 40) = &SecretLayer3::`vftable';
*((_QWORD *)v9 + 41) = &SecretLayer3::`vftable';
*((_QWORD *)v9 + 42) = &SecretLayer3::`vftable';
*((_QWORD *)v9 + 43) = &SecretLayer3::`vftable';
*((_QWORD *)v9 + 44) = &SecretLayer3::`vftable';
*((_QWORD *)v9 + 51) = &SecretLayer3::`vftable';
*((_BYTE *)v9 + 424) = 0;
*((_QWORD *)v9 + 54) = 0;
*((_QWORD *)v9 + 55) = 0;
*((_QWORD *)v9 + 56) = 0;
*((_QWORD *)v9 + 57) = 0;
if ( (unsigned __int8)SecretLayer3::init(v9) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v9);
}
else
{
(*(void (__fastcall **)(__int128 *, __int64))(*(_QWORD *)v9 + 8LL))(v9, 1);
v9 = nullptr;
}
(*(void (__fastcall **)(struct cocos2d::CCScene *, __int128 *))(*(_QWORD *)v7 + 464LL))(v7, v9);
v10 = cocos2d::CCTransitionFade::create(0.5, v7);
v12 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v11);
cocos2d::CCDirector::replaceScene(v12, v10);
}
else
{
v50 = 11;
v13 = 15;
v51 = 15;
Src[0] = (void *)0x6F6C6C6120746F4ELL;
Src[1] = (void *)6579575;
v14 = a1[123];
if ( v14 >= 0 )
{
v16 = v14 + 1;
}
else
{
v15 = rand();
v16 = (int)roundf((float)((float)v15 / 32767.0) * 10.0);
}
v17 = (unsigned int)v16;
a1[123] = v16;
v18 = 0x7FFFFFFFFFFFFFFFLL;
if ( v16 <= 10 )
{
if ( (unsigned int)v16 <= 0xA )
{
switch ( v16 )
{
case 0:
goto LABEL_15;
case 1:
v13 = 47;
v20 = (char *)sub_14003D460(0x30u);
v50 = 34;
strcpy(v20, "Its too dangerous, just stay here.");
v17 = 11877;
Src[0] = v20;
goto LABEL_26;
case 2:
v13 = 31;
v21 = (char *)sub_14003D460(0x20u);
v50 = 19;
strcpy(v21, "Leave that alone...");
v17 = 46;
Src[0] = v21;
goto LABEL_26;
case 3:
v13 = 31;
v22 = (char *)sub_14003D460(0x20u);
v50 = 24;
strcpy(v22, "That area is off limits.");
Src[0] = v22;
goto LABEL_26;
case 4:
v23 = (char *)sub_14003D460(0x30u);
v50 = 47;
v13 = 47;
v51 = 47;
strcpy(v23, "I keep that door locked.\nRubRub's orders.");
Src[0] = v23;
break;
case 5:
v13 = 63;
v24 = (char *)sub_14003D460(0x40u);
v50 = 56;
strcpy(v24, "I've only been down there once. Its pretty creepy.");
Src[0] = v24;
goto LABEL_26;
case 6:
v13 = 31;
v25 = (char *)sub_14003D460(0x20u);
v50 = 21;
strcpy(v25, "Just forget about it.");
v17 = 46;
Src[0] = v25;
goto LABEL_26;
case 7:
v13 = 47;
v26 = (char *)sub_14003D460(0x30u);
v50 = 32;
strcpy(v26, "Some things are best left alone.");
Src[0] = v26;
goto LABEL_26;
case 8:
v13 = 47;
v27 = (char *)sub_14003D460(0x30u);
v50 = 34;
strcpy(v27, "Even I dont want to go down there.");
v17 = 11877;
Src[0] = v27;
goto LABEL_26;
case 9:
v13 = 31;
v28 = (char *)sub_14003D460(0x20u);
v50 = 19;
strcpy(v28, "Off. Limits.");
v17 = 46;
Src[0] = v28;
goto LABEL_26;
case 10:
v13 = 47;
v29 = (char *)sub_14003D460(0x30u);
v50 = 41;
strcpy(v29, "Does the word locked mean nothing to you?");
Src[0] = v29;
goto LABEL_26;
}
}
}
else
{
a1[123] = 0;
LABEL_15:
v13 = 47;
v19 = (char *)sub_14003D460(0x30u);
v50 = 32;
strcpy(v19, "Sorry, I can't let you in.");
Src[0] = v19;
LABEL_26:
v51 = v13;
}
v41 = &v42;
v39 = -1;
v40 = -1;
v42 = 0;
v43 = 0;
v44 = 0;
v30 = Src;
if ( v13 > 0xF )
v30 = (void **)Src[0];
if ( v50 > 0x7FFFFFFFFFFFFFFFLL )
sub_140009D90(v17);
if ( v50 > 0xF )
{
if ( (v50 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v18 = v50 | 0xF;
if ( (v50 | 0xF) < 0x16 )
v18 = 22;
}
*(_QWORD *)&v42 = sub_14003D460(v18 + 1);
v43 = v50;
v44 = v18;
memcpy((void *)v42, v30, v50 + 1);
}
else
{
v43 = v50;
v44 = 15;
v42 = *(_OWORD *)v30;
}
v45[7] = 0;
v46 = 13;
v47 = 15;
strcpy((char *)v45, "The Keymaster");
v31 = DialogObject::create((__int64)v45, (__int64)&v42, 2, 1.0, 0, (__int64)&v39);
DialogLayer = DialogLayer::createDialogLayer((__int64)v31, 0, 2u);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCLayerColor *, __int64))(*(_QWORD *)a1 + 456LL))(a1, DialogLayer, 100);
v34 = cocos2d::CCDirector::sharedDirector(v33);
cocos2d::CCDirector::getWinSize(v34, &v41);
v35 = **((_QWORD **)DialogLayer + 70);
v36 = *((_QWORD *)DialogLayer + 70);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v48, *(float *)&v41 * 0.5, *((float *)&v41 + 1) * 0.5);
(*(void (__fastcall **)(__int64, __int64))(v35 + 184))(v36, v37);
DialogLayer::animateInRandomSide(DialogLayer);
if ( v13 > 0xF )
{
v38 = Src[0];
if ( v13 + 1 >= 0x1000 )
{
v38 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v38 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v38);
}
}
}