//
// EditLevelLayer::onShare from 0x1001fbf70 to 0x1001fc373 (1027 bytes)
//
// 2 xrefs:
// > EditLevelLayer::FLAlert_Clicked @ 0x1001fe206
// > EditLevelLayer::init @ 0x1001fb2ca
//
// 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)
{
__int128 v2; // xmm0
GJAccountManager *v3; // rax
GJGameLevel *m_level; // rax
std::string *p_m_levelString; // rax
ShareLevelLayer *v6; // rbx
GJGameLevel *v7; // rax
std::string *p_m_levelName; // rax
__int64 v9; // r14
GameManager *v10; // rax
unsigned int v11; // r14d
__int64 v12; // rax
__int64 v13; // r14
GameManager *v14; // rax
_QWORD v15[2]; // [rsp+0h] [rbp-90h] BYREF
void *__p; // [rsp+10h] [rbp-80h]
_QWORD v17[2]; // [rsp+18h] [rbp-78h] BYREF
void *v18; // [rsp+28h] [rbp-68h]
_QWORD v19[2]; // [rsp+30h] [rbp-60h] BYREF
void *v20; // [rsp+40h] [rbp-50h]
_QWORD v21[2]; // [rsp+48h] [rbp-48h] BYREF
void *v22; // [rsp+58h] [rbp-38h]
__int128 v23; // [rsp+60h] [rbp-30h] BYREF
void *longStorage; // [rsp+70h] [rbp-20h]
v3 = GJAccountManager::sharedState();
if ( v3->m_accountID <= v3->m_unkInt1 )
{
__p = operator new(0x78u);
v15[0] = 121;
v15[1] = 112;
strcpy(
(char *)__p,
"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", v15, "Close", 0, 300.0);
if ( (v15[0] & 1) != 0 )
operator delete(__p);
goto LABEL_28;
}
m_level = a1->m_level;
if ( (m_level->m_levelString.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v23,
m_level->m_levelString.m_data.m_long.longStorage,
m_level->m_levelString.m_data.m_long.size,
*(double *)&v2);
}
else
{
p_m_levelString = &m_level->m_levelString;
longStorage = p_m_levelString->m_data.m_long.longStorage;
v2 = *(_OWORD *)&p_m_levelString->m_data.m_short.sizex2;
v23 = *(_OWORD *)&p_m_levelString->m_data.m_short.sizex2;
}
if ( (v23 & 1) != 0 )
{
v9 = *((_QWORD *)&v23 + 1);
operator delete(longStorage);
if ( v9 )
goto LABEL_9;
LABEL_12:
v18 = operator new(0x28u);
v17[0] = 41;
v17[1] = 32;
strcpy((char *)v18, "You cannot share an empty level.");
v6 = (ShareLevelLayer *)FLAlertLayer::create_1(0, "Empty", v17, "OK", 0, 380.0);
if ( (v17[0] & 1) != 0 )
operator delete(v18);
goto LABEL_28;
}
if ( !((unsigned __int8)v23 >> 1) )
goto LABEL_12;
LABEL_9:
v7 = a1->m_level;
if ( (v7->m_levelName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(&v23, v7->m_levelName.m_data.m_long.longStorage, v7->m_levelName.m_data.m_long.size, *(double *)&v2);
}
else
{
p_m_levelName = &v7->m_levelName;
longStorage = p_m_levelName->m_data.m_long.longStorage;
v23 = *(_OWORD *)&p_m_levelName->m_data.m_short.sizex2;
}
if ( (v23 & 1) != 0 )
{
v13 = *((_QWORD *)&v23 + 1);
operator delete(longStorage);
if ( v13 )
{
LABEL_17:
v10 = GameManager::sharedState();
if ( GameManager::getGameVariable(v10, "0157") )
{
if ( (unsigned int)sub_100720070(a1->m_textInputs) )
{
v11 = 0;
do
{
v12 = sub_1007200C0(a1->m_textInputs, v11);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v12 + 1144LL))(v12, 0);
++v11;
}
while ( v11 < (unsigned int)sub_100720070(a1->m_textInputs) );
}
v6 = ShareLevelLayer::create(a1->m_level);
}
else
{
v14 = GameManager::sharedState();
GameManager::setGameVariable(v14, "0157", 1);
v22 = operator new(0x1D8u);
v21[0] = 473;
v21[1] = 464;
strcpy(
(char *)v22,
"Hateful, abusive, or otherwise inappropriate content, whether it is in the level, name, or description may lea"
"d to deletion. The same applies to levels abusing cheats or exploits. Stealing assets from other level"
"s 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",
v21,
"OK",
0,
380.0);
if ( (v21[0] & 1) != 0 )
operator delete(v22);
((void (__fastcall *)(ShareLevelLayer *, __int64))v6->setTag)(v6, 10);
}
goto LABEL_28;
}
}
else if ( (unsigned __int8)v23 >> 1 )
{
goto LABEL_17;
}
v20 = operator new(0x30u);
v19[0] = 49;
v19[1] = 43;
strcpy((char *)v20, "You must name your level before sharing it.");
v6 = (ShareLevelLayer *)FLAlertLayer::create_1(0, "No Name", v19, "OK", 0, 380.0);
if ( (v19[0] & 1) != 0 )
operator delete(v20);
LABEL_28:
((void (__fastcall *)(ShareLevelLayer *))v6->show)(v6);
}