//
// EditLevelLayer::verifyLevelName from 0x1000ebc94 to 0x1000ebefc (616 bytes)
//
// 4 xrefs:
// > EditLevelLayer::onEdit @ 0x1000ea29c
// > EditLevelLayer::onPlay @ 0x1000ea3e0
// > EditLevelLayer::onBack @ 0x1000eb43c
// > EditLevelLayer::onClone @ 0x1000ec390
//
// 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)
{
GJGameLevel *m_level; // x8
std::string *p_m_levelName; // x8
__int64 v4; // x20
GJGameLevel *v5; // x8
std::string *p_m_tempName; // x8
GJGameLevel *v7; // x20
__int64 v8; // x20
GJGameLevel *v9; // x20
std::string *p_str; // x8
GJGameLevel *v11; // x8
std::string *v12; // x8
bool v13; // w0
bool v14; // w20
LocalLevelManager *v15; // x20
GJGameLevel *v16; // x8
std::string *v17; // x8
__int64 AllLevelsWithName; // x20
__int64 v19; // x21
int v20; // w22
int v21; // w8
int v22; // w8
void *__p[2]; // [xsp+0h] [xbp-90h] BYREF
char *v24; // [xsp+10h] [xbp-80h]
std::string __str; // [xsp+18h] [xbp-78h] BYREF
std::string m_tempName; // [xsp+30h] [xbp-60h] BYREF
__int128 __dst; // [xsp+50h] [xbp-40h] BYREF
char *longStorage; // [xsp+60h] [xbp-30h]
m_level = a1->m_level;
if ( m_level->m_levelName.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(
&__dst,
(void *)m_level->m_levelName.m_data.m_long.capacitym1,
m_level->m_levelName.m_data.m_long.size);
}
else
{
p_m_levelName = &m_level->m_levelName;
__dst = *(_OWORD *)&p_m_levelName->m_data.m_short.sizex2;
longStorage = p_m_levelName->m_data.m_long.longStorage;
}
if ( SHIBYTE(longStorage) < 0 )
{
v4 = *((_QWORD *)&__dst + 1);
operator delete((void *)__dst);
if ( v4 )
goto LABEL_22;
}
else if ( HIBYTE(longStorage) )
{
goto LABEL_22;
}
v5 = a1->m_level;
if ( v5->m_tempName.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(&__dst, (void *)v5->m_tempName.m_data.m_long.capacitym1, v5->m_tempName.m_data.m_long.size);
}
else
{
p_m_tempName = &v5->m_tempName;
__dst = *(_OWORD *)&p_m_tempName->m_data.m_short.sizex2;
longStorage = p_m_tempName->m_data.m_long.longStorage;
}
if ( (SHIBYTE(longStorage) & 0x80000000) == 0 )
{
if ( HIBYTE(longStorage) )
goto LABEL_13;
LABEL_16:
v9 = a1->m_level;
sub_100009900(&__str, "Unknown");
std::string::operator=((std::string *)&v9->m_levelName, &__str);
if ( (SHIBYTE(__str.__r_.__value_.__r.__words[2]) & 0x80000000) == 0 )
goto LABEL_22;
p_str = &__str;
goto LABEL_21;
}
v8 = *((_QWORD *)&__dst + 1);
operator delete((void *)__dst);
if ( !v8 )
goto LABEL_16;
LABEL_13:
v7 = a1->m_level;
if ( v7->m_tempName.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(&m_tempName, (void *)v7->m_tempName.m_data.m_long.capacitym1, v7->m_tempName.m_data.m_long.size);
else
m_tempName = (std::string)v7->m_tempName;
std::string::operator=((std::string *)&v7->m_levelName, &m_tempName);
if ( SHIBYTE(m_tempName.__r_.__value_.__r.__words[2]) < 0 )
{
p_str = &m_tempName;
LABEL_21:
operator delete(p_str->__r_.__value_.__l.__data_);
}
LABEL_22:
v11 = a1->m_level;
if ( v11->m_levelName.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(&__dst, (void *)v11->m_levelName.m_data.m_long.capacitym1, v11->m_levelName.m_data.m_long.size);
}
else
{
v12 = &v11->m_levelName;
__dst = *(_OWORD *)&v12->m_data.m_short.sizex2;
longStorage = v12->m_data.m_long.longStorage;
}
v13 = sub_1000045BC(&__dst, &a1->m_levelName.m_data.m_long.capacitym1);
v14 = v13;
if ( SHIBYTE(longStorage) < 0 )
{
operator delete((void *)__dst);
if ( v14 )
return;
}
else if ( v13 )
{
return;
}
a1->m_level->m_levelRev = 0;
v15 = LocalLevelManager::sharedState();
v16 = a1->m_level;
if ( v16->m_levelName.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(__p, (void *)v16->m_levelName.m_data.m_long.capacitym1, v16->m_levelName.m_data.m_long.size);
}
else
{
v17 = &v16->m_levelName;
*(_OWORD *)__p = *(_OWORD *)&v17->m_data.m_short.sizex2;
v24 = v17->m_data.m_long.longStorage;
}
AllLevelsWithName = LocalLevelManager::getAllLevelsWithName(v15, __p);
if ( SHIBYTE(v24) < 0 )
operator delete(__p[0]);
if ( (unsigned int)sub_10024A36C(AllLevelsWithName) >= 2 )
{
if ( (unsigned int)sub_10024A36C(AllLevelsWithName) )
{
v19 = 0;
v20 = 0;
do
{
v21 = *(_DWORD *)(sub_10024A388(AllLevelsWithName, v19) + 604);
if ( v20 <= v21 )
v20 = v21;
v19 = (unsigned int)(v19 + 1);
}
while ( (unsigned int)v19 < (unsigned int)sub_10024A36C(AllLevelsWithName) );
v22 = v20 + 1;
}
else
{
v22 = 1;
}
a1->m_level->m_levelRev = v22;
}
}