//
// GJSmartBlockPreview::addTemplateGuide_1 from 0x1004158e0 to 0x100415de6 (1286 bytes)
//
// 2 xrefs:
// > GJSmartBlockPreview::addTemplateGuide @ 0x1004156cd
// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1004e461e
//
// 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 12:30:11 +0000
//
__int64 __fastcall GJSmartBlockPreview::addTemplateGuide_1(std::string *a1, __int64 a2, float a3)
{
std::string::size_type v3; // rax
__int64 v4; // rax
double v5; // xmm0_8
void *v6; // r12
__int64 v7; // rbx
__int64 v8; // rax
__int64 v9; // rsi
const char *v10; // r15
size_t v11; // rax
std::string::size_type v12; // r14
char *v13; // r13
std::string::pointer data; // rdi
unsigned __int8 *v15; // r14
__int64 v16; // rcx
double v17; // xmm0_8
std::string::size_type v18; // r12
int v19; // ecx
std::string::size_type v20; // r13
int v21; // ebx
const std::string::value_type *v22; // rsi
int v23; // ecx
std::string::pointer v24; // rdi
unsigned __int8 *v25; // r14
unsigned int v26; // eax
int v27; // ecx
int v28; // ecx
bool v29; // zf
void (__fastcall *v30)(unsigned __int8 *, void *); // rax
unsigned int v31; // ebx
unsigned __int64 v33; // [rsp+Ch] [rbp-84h] BYREF
unsigned __int64 v34; // [rsp+14h] [rbp-7Ch] BYREF
unsigned int v35; // [rsp+1Ch] [rbp-74h]
std::string *v36; // [rsp+20h] [rbp-70h]
std::string *v37; // [rsp+28h] [rbp-68h]
__int64 v38; // [rsp+30h] [rbp-60h]
void *v39; // [rsp+38h] [rbp-58h]
std::string __dst; // [rsp+40h] [rbp-50h] BYREF
float v41; // [rsp+58h] [rbp-38h]
unsigned __int64 v42; // [rsp+5Ch] [rbp-34h] BYREF
__int16 v43; // [rsp+64h] [rbp-2Ch] BYREF
char v44; // [rsp+66h] [rbp-2Ah]
v41 = a3;
v38 = sub_1007FE900(a1);
*(float *)&v36 = *(float *)(*(__int64 (__fastcall **)(std::string *))(a1->__r_.__value_.__r.__words[0] + 328))(a1)
* 0.5;
v3 = a1->__r_.__value_.__r.__words[0];
v37 = a1;
v4 = (*(__int64 (__fastcall **)(std::string *))(v3 + 328))(a1);
*(_QWORD *)&v5 = (unsigned int)v36;
sub_100278250((float *)&v33, *(float *)&v36, 0.5 * *(float *)(v4 + 4));
v44 = -1;
v43 = -1;
if ( !*(_DWORD *)(a2 + 56) )
{
if ( *(_QWORD *)a2 )
{
v44 = 0;
v43 = -256;
}
else
{
v44 = 0;
v43 = 255;
}
}
v6 = operator new(0x140u);
cocos2d::CCNode::CCNode((__int64)v6);
*(_QWORD *)v6 = off_100B3ED58;
if ( cocos2d::CCNode::init() )
{
cocos2d::CCObject::autorelease(v6);
}
else
{
(*(void (__fastcall **)(void *))(*(_QWORD *)v6 + 16LL))(v6);
v6 = nullptr;
}
(*(void (__fastcall **)(std::string *, void *))(v37->__r_.__value_.__r.__words[0] + 456))(v37, v6);
v36 = (std::string *)(a2 + 8);
v7 = (unsigned int)*std::string::at((std::string *)(a2 + 8), 0);
v8 = ObjectToolbox::sharedState(v5);
v9 = 2895;
if ( (unsigned __int8)(v7 - 50) <= 0x1Au )
v9 = *(unsigned int *)&aP_2[4 * (unsigned __int8)(v7 - 50)];
v10 = (const char *)ObjectToolbox::intKeyToFrame(v8, v9);
v11 = strlen(v10);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v12 = v11;
if ( v11 >= 0x17 )
{
v39 = (void *)v7;
v7 = 26;
if ( (v11 | 7) != 0x17 )
v7 = (v11 | 7) + 1;
v13 = (char *)operator new(v7);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)v13;
__dst.__r_.__value_.__r.__words[0] = v7 + 1;
LODWORD(v7) = (_DWORD)v39;
__dst.__r_.__value_.__l.__size_ = v12;
LABEL_53:
memmove(v13, v10, v12);
data = __dst.__r_.__value_.__s.__data_;
v13[v12] = 0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_15;
goto LABEL_14;
}
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v11);
v13 = __dst.__r_.__value_.__s.__data_;
if ( v11 )
goto LABEL_53;
data = __dst.__r_.__value_.__s.__data_;
__dst.__r_.__value_.__s.__data_[0] = 0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
LABEL_14:
data = __dst.__r_.__value_.__l.__data_;
LABEL_15:
v15 = (unsigned __int8 *)cocos2d::CCSprite::createWithSpriteFrameName((__int64)data, v5);
GJSmartTemplate::applyTransformationsForType(v7, v15);
(*(void (__fastcall **)(unsigned __int8 *, __int16 *))(*(_QWORD *)v15 + 960LL))(v15, &v43);
GJSmartTemplate::offsetForType((float *)&v34, v7);
sub_100278350((double *)&v42, &v33, &v34);
(*(void (__fastcall **)(unsigned __int8 *, unsigned __int64 *))(*(_QWORD *)v15 + 184LL))(v15, &v42);
(*(void (__fastcall **)(void *, unsigned __int8 *, _QWORD))(*(_QWORD *)v6 + 464LL))(v6, v15, 0);
v16 = *(_QWORD *)v15;
v35 = (unsigned __int8)(int)(float)(255.0 * v41);
(*(void (__fastcall **)(unsigned __int8 *))(v16 + 912))(v15);
sub_1007FEBF0(v38, v15);
(*(void (__fastcall **)(unsigned __int8 *, _QWORD))(*(_QWORD *)v15 + 72LL))(v15, 0);
v39 = v6;
*(_QWORD *)&v17 = LODWORD(v41);
*(float *)&v17 = v41 * 150.0;
v37 = (std::string *)((char *)v37 + 320);
v18 = 0;
LODWORD(v41) = (unsigned __int8)(int)(float)(v41 * 150.0);
do
{
v20 = v18++;
v21 = (unsigned __int8)*std::string::at(v36, v18);
v22 = "smartBlock02b_001.png";
switch ( v21 )
{
case '2':
case '3':
case '4':
case '5':
break;
case '6':
case '8':
case 'A':
case 'C':
case 'E':
case 'G':
case 'I':
case 'K':
v22 = "smartBlock03b_001.png";
break;
case '7':
case 'B':
if ( (unsigned int)(v20 + 1) > 8 )
goto LABEL_27;
v19 = 326;
if ( !_bittest(&v19, v20 + 1) )
goto LABEL_27;
continue;
case '9':
case 'D':
if ( (unsigned int)(v20 + 1) > 7 )
goto LABEL_27;
v23 = 166;
if ( !_bittest(&v23, v20 + 1) )
goto LABEL_27;
continue;
case 'F':
case 'H':
if ( (((_DWORD)v20 - 2) & 0xFFFFFFFA) != 0 )
goto LABEL_27;
continue;
case 'J':
case 'L':
if ( (unsigned int)(v20 - 2) < 4 )
continue;
LABEL_27:
if ( (unsigned __int8)(v21 - 55) >= 0x16u )
goto LABEL_29;
v22 = (char *)dword_100A0A0CC + dword_100A0A0CC[(unsigned __int8)(v21 - 55)];
break;
default:
LABEL_29:
v22 = "smartBlock01b_001.png";
break;
}
std::string::assign(&__dst, v22);
v24 = __dst.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
v24 = __dst.__r_.__value_.__l.__data_;
v25 = (unsigned __int8 *)cocos2d::CCSprite::createWithSpriteFrameName((__int64)v24, v17);
GJSmartTemplate::applyTransformationsForType((char)v21, v25);
(*(void (__fastcall **)(void *, unsigned __int8 *, _QWORD))(*(_QWORD *)v39 + 464LL))(v39, v25, 0);
GJSmartTemplate::offsetForType((float *)&v42, (char)v21);
v26 = v20 + 1;
if ( (unsigned int)(v20 + 1) <= 6 )
{
v27 = 98;
if ( _bittest(&v27, v26) )
{
*(_QWORD *)&v17 = HIDWORD(v42);
*(float *)&v17 = *((float *)&v42 + 1) + 30.0;
*((float *)&v42 + 1) = *((float *)&v42 + 1) + 30.0;
}
}
if ( v26 <= 8 )
{
v28 = 388;
if ( _bittest(&v28, v26) )
{
*(_QWORD *)&v17 = HIDWORD(v42);
*(float *)&v17 = *((float *)&v42 + 1) + -30.0;
*((float *)&v42 + 1) = *((float *)&v42 + 1) + -30.0;
}
}
if ( (v26 & 0xB) == 3 || v20 == 4 )
{
*(_QWORD *)&v17 = (unsigned int)v42;
*(float *)&v17 = *(float *)&v42 + -30.0;
*(float *)&v42 = *(float *)&v42 + -30.0;
}
if ( (v26 & 0xD) == 4 || v20 == 7 )
{
*(_QWORD *)&v17 = (unsigned int)v42;
*(float *)&v17 = *(float *)&v42 + 30.0;
*(float *)&v42 = *(float *)&v42 + 30.0;
}
sub_100278350((double *)&v34, &v33, &v42);
(*(void (__fastcall **)(unsigned __int8 *, unsigned __int64 *))(*(_QWORD *)v25 + 184LL))(v25, &v34);
v29 = *std::string::at(v37, v18) == 48;
v30 = *(void (__fastcall **)(unsigned __int8 *, void *))(*(_QWORD *)v25 + 960LL);
if ( v29 )
{
v30(v25, &unk_100A09EA8);
v31 = 2;
(*(void (__fastcall **)(unsigned __int8 *, _QWORD))(*(_QWORD *)v25 + 912LL))(v25, LODWORD(v41));
}
else
{
v30(v25, &v43);
v31 = 1;
(*(void (__fastcall **)(unsigned __int8 *, _QWORD))(*(_QWORD *)v25 + 912LL))(v25, v35);
}
(*(void (__fastcall **)(unsigned __int8 *, _QWORD))(*(_QWORD *)v25 + 72LL))(v25, v31);
sub_1007FEBF0(v38, v25);
}
while ( v18 != 8 );
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
return v38;
}