//
// EditLevelLayer::verifyLevelName from 0x1001fdbc0 to 0x1001fdef4 (820 bytes)
//
// 4 xrefs:
// > EditLevelLayer::onEdit @ 0x1001fbd78
// > EditLevelLayer::onPlay @ 0x1001fbf11
// > EditLevelLayer::onBack @ 0x1001fd104
// > EditLevelLayer::onClone @ 0x1001fe42c
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall EditLevelLayer::verifyLevelName(EditLevelLayer *a1)
{
__int128 v1; // xmm0
GJGameLevel *m_level; // rax
std::string *p_m_levelName; // rax
char v5; // al
__int64 v6; // r14
GJGameLevel *v7; // rax
std::string *p_m_tempName; // rax
char v9; // al
__int64 v10; // r14
void **p_data; // r15
std::string *v12; // rdi
GJGameLevel *v13; // r14
GJGameLevel *v14; // rax
std::string *v15; // rax
unsigned int sizex2; // eax
char v17; // r15
void *v18; // r14
size_t v19; // rdx
char *v20; // rdi
std::size_t size; // rax
std::array *p_shortStorage; // rsi
bool v23; // zf
char v24; // r12
LocalLevelManager *v25; // r14
GJGameLevel *v26; // rax
std::string *v27; // rax
__int64 AllLevelsWithName; // r14
unsigned int v29; // r15d
int v30; // r12d
int v31; // r13d
int v32; // r12d
std::string v33; // [rsp+0h] [rbp-90h] BYREF
std::string __str; // [rsp+18h] [rbp-78h] BYREF
__int128 v35; // [rsp+30h] [rbp-60h] BYREF
void *longStorage; // [rsp+40h] [rbp-50h]
__int128 __s1; // [rsp+50h] [rbp-40h] BYREF
void *__p; // [rsp+60h] [rbp-30h]
m_level = a1->m_level;
if ( (m_level->m_levelName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&__s1,
m_level->m_levelName.m_data.m_long.longStorage,
m_level->m_levelName.m_data.m_long.size,
*(double *)&v1);
v5 = __s1;
if ( (__s1 & 1) != 0 )
{
LABEL_3:
v6 = *((_QWORD *)&__s1 + 1);
operator delete(__p);
if ( v6 )
goto LABEL_19;
goto LABEL_7;
}
}
else
{
p_m_levelName = &m_level->m_levelName;
__p = p_m_levelName->m_data.m_long.longStorage;
v1 = *(_OWORD *)&p_m_levelName->m_data.m_short.sizex2;
__s1 = *(_OWORD *)&p_m_levelName->m_data.m_short.sizex2;
v5 = __s1;
if ( (__s1 & 1) != 0 )
goto LABEL_3;
}
if ( v5 )
goto LABEL_19;
LABEL_7:
v7 = a1->m_level;
if ( (v7->m_tempName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(&__s1, v7->m_tempName.m_data.m_long.longStorage, v7->m_tempName.m_data.m_long.size, *(double *)&v1);
v9 = __s1;
if ( (__s1 & 1) != 0 )
{
LABEL_9:
v10 = *((_QWORD *)&__s1 + 1);
operator delete(__p);
if ( !v10 )
goto LABEL_10;
goto LABEL_14;
}
}
else
{
p_m_tempName = &v7->m_tempName;
__p = p_m_tempName->m_data.m_long.longStorage;
v1 = *(_OWORD *)&p_m_tempName->m_data.m_short.sizex2;
__s1 = *(_OWORD *)&p_m_tempName->m_data.m_short.sizex2;
v9 = __s1;
if ( (__s1 & 1) != 0 )
goto LABEL_9;
}
if ( !v9 )
{
LABEL_10:
p_data = (void **)&__str.__r_.__value_.__l.__data_;
v12 = (std::string *)&a1->m_level->m_levelName;
__str.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)14;
strcpy(__str.__r_.__value_.__s.__data_, "Unknown");
std::string::operator=(v12, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_19;
LABEL_18:
operator delete(*p_data);
goto LABEL_19;
}
LABEL_14:
p_data = (void **)&v33.__r_.__value_.__l.__data_;
v13 = a1->m_level;
if ( (v13->m_tempName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(&v33, v13->m_tempName.m_data.m_long.longStorage, v13->m_tempName.m_data.m_long.size, *(double *)&v1);
}
else
{
v33.__r_.__value_.__r.__words[2] = (std::string::size_type)v13->m_tempName.m_data.m_long.longStorage;
v1 = *(_OWORD *)&v13->m_tempName.m_data.m_short.sizex2;
*(_OWORD *)&v33.__r_.__value_.__l.0 = v1;
}
std::string::operator=((std::string *)&v13->m_levelName, &v33);
if ( (*(_BYTE *)&v33.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_18;
LABEL_19:
v14 = a1->m_level;
if ( (v14->m_levelName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&__s1,
v14->m_levelName.m_data.m_long.longStorage,
v14->m_levelName.m_data.m_long.size,
*(double *)&v1);
}
else
{
v15 = &v14->m_levelName;
__p = v15->m_data.m_long.longStorage;
v1 = *(_OWORD *)&v15->m_data.m_short.sizex2;
__s1 = *(_OWORD *)&v15->m_data.m_short.sizex2;
}
sizex2 = a1->m_levelName.m_data.m_short.sizex2;
v17 = __s1;
v18 = __p;
if ( (__s1 & 1) != 0 )
{
v19 = *((_QWORD *)&__s1 + 1);
v20 = (char *)__p;
if ( (sizex2 & 1) == 0 )
{
LABEL_24:
size = sizex2 >> 1;
p_shortStorage = &a1->m_levelName.m_data.m_short.shortStorage;
goto LABEL_27;
}
}
else
{
v19 = (unsigned __int8)__s1 >> 1;
v20 = (char *)&__s1 + 1;
if ( (sizex2 & 1) == 0 )
goto LABEL_24;
}
size = a1->m_levelName.m_data.m_long.size;
p_shortStorage = (std::array *)a1->m_levelName.m_data.m_long.longStorage;
LABEL_27:
v23 = size == v19;
if ( size < v19 )
v19 = size;
v24 = v23 & (memcmp(v20, p_shortStorage, v19) == 0);
if ( (v17 & 1) != 0 )
operator delete(v18);
if ( !v24 )
{
a1->m_level->m_levelRev = 0;
v25 = LocalLevelManager::sharedState();
v26 = a1->m_level;
if ( (v26->m_levelName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v35,
v26->m_levelName.m_data.m_long.longStorage,
v26->m_levelName.m_data.m_long.size,
*(double *)&v1);
}
else
{
v27 = &v26->m_levelName;
longStorage = v27->m_data.m_long.longStorage;
v35 = *(_OWORD *)&v27->m_data.m_short.sizex2;
}
AllLevelsWithName = LocalLevelManager::getAllLevelsWithName(v25, &v35);
if ( (v35 & 1) != 0 )
operator delete(longStorage);
if ( (unsigned int)sub_100720070(AllLevelsWithName) >= 2 )
{
if ( (unsigned int)sub_100720070(AllLevelsWithName) )
{
v29 = 0;
v30 = 0;
do
{
v31 = v30;
v30 = *(_DWORD *)(sub_1007200C0(AllLevelsWithName, v29) + 604);
if ( v31 > v30 )
v30 = v31;
++v29;
}
while ( v29 < (unsigned int)sub_100720070(AllLevelsWithName) );
v32 = v30 + 1;
}
else
{
v32 = 1;
}
a1->m_level->m_levelRev = v32;
}
}
}