//
// EditLevelLayer::onShare from 0x1000ea448 to 0x1000ea708 (704 bytes)
//
// 2 xrefs:
// > EditLevelLayer::FLAlert_Clicked @ 0x1000ec138
// > EditLevelLayer::init @ 0x1000e97e4
//
// 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::onShare(EditLevelLayer *a1, cocos2d::CCObject *a2)
{
GJAccountManager *v3; // x0
GJGameLevel *m_level; // x8
std::string *p_m_levelString; // x8
ShareLevelLayer *v6; // x19
void *v7; // x0
_BOOL4 v8; // w20
GJGameLevel *v9; // x8
std::string *p_m_levelName; // x8
_BOOL4 v11; // w20
GameManager *v12; // x0
GameManager *v13; // x0
void *v14[2]; // [xsp+0h] [xbp-A0h] BYREF
char v15; // [xsp+17h] [xbp-89h]
void *v16[2]; // [xsp+18h] [xbp-88h] BYREF
char v17; // [xsp+2Fh] [xbp-71h]
_QWORD v18[2]; // [xsp+30h] [xbp-70h] BYREF
char v19; // [xsp+47h] [xbp-59h]
void *__p[2]; // [xsp+48h] [xbp-58h] BYREF
char v21; // [xsp+5Fh] [xbp-41h]
__int128 __dst; // [xsp+60h] [xbp-40h] BYREF
char *longStorage; // [xsp+70h] [xbp-30h]
_QWORD v24[2]; // [xsp+78h] [xbp-28h] BYREF
char v25; // [xsp+8Fh] [xbp-11h]
v3 = GJAccountManager::sharedState();
if ( v3->m_accountID > v3->m_unkInt1 )
{
m_level = a1->m_level;
if ( m_level->m_levelString.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(
&__dst,
(void *)m_level->m_levelString.m_data.m_long.capacitym1,
m_level->m_levelString.m_data.m_long.size);
}
else
{
p_m_levelString = &m_level->m_levelString;
__dst = *(_OWORD *)&p_m_levelString->m_data.m_short.sizex2;
longStorage = p_m_levelString->m_data.m_long.longStorage;
}
sub_100009900(__p, "");
v8 = sub_1000045BC(&__dst, __p);
if ( v21 < 0 )
operator delete(__p[0]);
if ( SHIBYTE(longStorage) < 0 )
{
operator delete((void *)__dst);
if ( v8 )
{
LABEL_11:
sub_100009900(v18, "You cannot share an empty level.");
v6 = (ShareLevelLayer *)FLAlertLayer::create_1(0, "Empty", v18, "OK", 0, 380.0);
if ( v19 < 0 )
{
v7 = (void *)v18[0];
goto LABEL_23;
}
goto LABEL_24;
}
}
else if ( v8 )
{
goto LABEL_11;
}
v9 = a1->m_level;
if ( v9->m_levelName.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(&__dst, (void *)v9->m_levelName.m_data.m_long.capacitym1, v9->m_levelName.m_data.m_long.size);
}
else
{
p_m_levelName = &v9->m_levelName;
__dst = *(_OWORD *)&p_m_levelName->m_data.m_short.sizex2;
longStorage = p_m_levelName->m_data.m_long.longStorage;
}
sub_100009900(__p, "");
v11 = sub_1000045BC(&__dst, __p);
if ( v21 < 0 )
operator delete(__p[0]);
if ( SHIBYTE(longStorage) < 0 )
{
operator delete((void *)__dst);
if ( v11 )
{
LABEL_21:
sub_100009900(v16, "You must name your level before sharing it.");
v6 = (ShareLevelLayer *)FLAlertLayer::create_1(0, "No Name", v16, "OK", 0, 380.0);
if ( v17 < 0 )
{
v7 = v16[0];
goto LABEL_23;
}
goto LABEL_24;
}
}
else if ( v11 )
{
goto LABEL_21;
}
v12 = GameManager::sharedState();
if ( GameManager::getGameVariable(v12, "0157") )
{
EditLevelLayer::closeTextInputs(a1);
v6 = ShareLevelLayer::create(a1->m_level);
}
else
{
v13 = GameManager::sharedState();
GameManager::setGameVariable(v13, "0157", 1);
sub_100009900(
v14,
"Hateful, abusive, or otherwise inappropriate content, whether it is in the level, name, or description may lead "
"to deletion. The same applies to levels abusing cheats or exploits. Stealing assets from other levels is"
" discouraged and may stop a level from being rated depending on the context, severity, credit, and more."
" Levels verified with hacks cannot be rated.\n"
"These guidelines and their enforcement are entirely at RobTop's discretion.");
v6 = (ShareLevelLayer *)FLAlertLayer::create_1(
&a1->FLAlertLayerProtocol,
"Upload Guidelines",
v14,
"OK",
0,
380.0);
if ( v15 < 0 )
operator delete(v14[0]);
((void (__fastcall *)(ShareLevelLayer *, __int64))v6->setTag)(v6, 10);
}
goto LABEL_24;
}
sub_100009900(
v24,
"You need an account to share levels. You can create one for free from settings in the main menu.");
v6 = (ShareLevelLayer *)FLAlertLayer::create_1(0, "Account Needed", v24, "Close", 0, 300.0);
if ( v25 < 0 )
{
v7 = (void *)v24[0];
LABEL_23:
operator delete(v7);
}
LABEL_24:
((void (__fastcall *)(ShareLevelLayer *))v6->show)(v6);
}