//
// GameLevelManager::uploadLevel from 0x14014c7c0 to 0x14014d2a0 (2784 bytes)
//
// 2 xrefs:
// > UploadPopup::init @ 0x140490b03
// > ??> @ 0x1406ca7a0
//
// 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
//
// Hidden C++ exception states: #wind=19
void GameLevelManager::uploadLevel(GameLevelManager *a1, GJGameLevel *a2)
{
bool v2; // r9
GameManager *v5; // rcx
cocos2d::CCString *v6; // rax
const char *CString; // rax
const char *v8; // r12
size_t v9; // r15
size_t v10; // r8
__int64 v11; // rbx
void *v12; // rcx
size_t v13; // r8
__int64 v14; // rax
void *v15; // rcx
__int64 v16; // rdx
__int64 v17; // rdx
__int64 v18; // rax
__int64 v19; // rcx
__int64 v20; // rax
__int64 v21; // rcx
__int64 v22; // rax
__int64 v23; // rcx
__int64 v24; // rcx
const char *v25; // r14
const char *v26; // r9
const char *v27; // rdx
cocos2d::CCString *v28; // rax
char *v29; // rax
size_t v30; // r8
void **v31; // rdx
size_t v32; // r8
std::string *p_m_songIDs; // rdx
size_t v34; // r8
std::string *p_m_sfxIDs; // rdx
size_t v36; // r8
std::string *p_m_levelString; // rbx
void **v38; // rcx
bool v39; // r14
void **v40; // rsi
__int64 v41; // rax
void **v42; // rdx
__int64 v43; // rbx
__int64 v44; // rdi
__int64 v45; // r12
void **v46; // rdx
cocos2d::CCString *v47; // rax
char *v48; // rax
size_t v49; // r8
__int128 *p_Src; // rcx
__int128 *v51; // rax
__int64 v52; // rdx
size_t v53; // r8
void *v54; // rcx
const char *v55; // r8
const char *v56; // rdx
cocos2d::CCString *v57; // rax
char *v58; // rax
size_t v59; // r8
void **v60; // rdx
size_t v61; // r8
void **v62; // rdx
size_t v63; // r8
cocos2d::CCString *v64; // rax
char *v65; // rax
size_t v66; // r8
size_t v67; // r8
_QWORD *v68; // rdx
__int64 v69; // [rsp+20h] [rbp-110h]
__int64 v70; // [rsp+20h] [rbp-110h]
__int64 v71; // [rsp+28h] [rbp-108h]
__int64 v72; // [rsp+28h] [rbp-108h]
void *v73; // [rsp+B0h] [rbp-80h]
void *v74; // [rsp+B0h] [rbp-80h]
int m_audioTrack; // [rsp+B0h] [rbp-80h]
void *v76; // [rsp+B8h] [rbp-78h]
const char *v77; // [rsp+B8h] [rbp-78h]
int v78; // [rsp+C0h] [rbp-70h]
void *Block[2]; // [rsp+D0h] [rbp-60h] BYREF
__int64 v81; // [rsp+E0h] [rbp-50h]
unsigned __int64 v82; // [rsp+E8h] [rbp-48h]
void *v83[2]; // [rsp+F0h] [rbp-40h] BYREF
__int64 v84; // [rsp+100h] [rbp-30h]
unsigned __int64 v85; // [rsp+108h] [rbp-28h]
_QWORD v86[4]; // [rsp+110h] [rbp-20h] BYREF
__int128 Src; // [rsp+130h] [rbp+0h] BYREF
__int64 v88; // [rsp+140h] [rbp+10h]
unsigned __int64 v89; // [rsp+148h] [rbp+18h]
void *v90[3]; // [rsp+150h] [rbp+20h] BYREF
unsigned __int64 v91; // [rsp+168h] [rbp+38h]
void *v92[4]; // [rsp+170h] [rbp+40h] BYREF
_QWORD v93[4]; // [rsp+190h] [rbp+60h] BYREF
_QWORD v94[4]; // [rsp+1B0h] [rbp+80h] BYREF
_QWORD v95[4]; // [rsp+1D0h] [rbp+A0h] BYREF
_QWORD v96[4]; // [rsp+1F0h] [rbp+C0h] BYREF
_QWORD v97[4]; // [rsp+210h] [rbp+E0h] BYREF
_BYTE v98[32]; // [rsp+230h] [rbp+100h] BYREF
__int128 v99; // [rsp+250h] [rbp+120h] BYREF
__int64 v100; // [rsp+260h] [rbp+130h]
__int64 v101; // [rsp+268h] [rbp+138h]
_BYTE v102[48]; // [rsp+270h] [rbp+140h] BYREF
v5 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v76 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v76);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v5 = (GameManager *)qword_1406C2ED8;
}
GameManager::reportAchievementWithID(v5, "geometry.ach.submit", 100, v2);
v6 = cocos2d::CCString::createWithFormat("%i", a2->m_M_ID);
CString = cocos2d::CCString::getCString(v6);
v8 = CString;
v77 = CString;
*(_OWORD *)Block = 0;
v81 = 0;
v82 = 0;
v9 = -1;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003A930(Block, CString, v10);
v11 = cocos2d::CCDictionary::objectForKey(a1->m_friendReqAndUserBlocks, Block);
if ( v82 > 0xF )
{
v12 = Block[0];
if ( v82 + 1 >= 0x1000 )
{
v12 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v12 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v12);
}
if ( !v11 )
{
*(_OWORD *)Block = 0;
v81 = 0;
v82 = 0;
v13 = -1;
do
++v13;
while ( v8[v13] );
sub_14003A930(Block, v8, v13);
v14 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(a1->m_friendReqAndUserBlocks, v14, Block);
if ( v82 > 0xF )
{
v15 = Block[0];
if ( v82 + 1 >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v15);
}
v81 = 0;
v82 = 15;
LOBYTE(Block[0]) = 0;
v16 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v73 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v73);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v16 = qword_1406C2ED8;
}
sub_14003BDB0((__int64)v95, v16 + 616);
v17 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v74 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v74);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v17 = qword_1406C2ED8;
}
sub_14003BDB0((__int64)v98, v17 + 584);
sub_14003BDB0((__int64)v94, (__int64)&a2->m_levelName);
sub_14003BDB0((__int64)v93, (__int64)&a2->m_levelDesc);
v18 = sub_14003BDB0((__int64)v83, (__int64)v95);
GameLevelManager::removeDelimiterChars(v19, v18, 0);
v20 = sub_14003BDB0((__int64)v83, (__int64)v94);
GameLevelManager::removeDelimiterChars(v21, v20, 0);
v22 = sub_14003BDB0((__int64)v83, (__int64)v93);
GameLevelManager::removeDelimiterChars(v23, v22, 0);
GameLevelManager::getBasePostString(v24, v86);
v78 = 0;
if ( a2->m_unlisted )
v78 = 2 - a2->m_friendsOnly;
if ( a2->m_songID <= 0 )
m_audioTrack = a2->m_audioTrack;
else
m_audioTrack = 0;
v25 = (const char *)v93;
if ( v93[3] > 0xFu )
v25 = (const char *)v93[0];
v26 = (const char *)v94;
if ( v94[3] > 0xFu )
v26 = (const char *)v94[0];
v27 = (const char *)v95;
if ( v95[3] > 0xFu )
v27 = (const char *)v95[0];
v28 = cocos2d::CCString::createWithFormat(
"&userName=%s&levelID=%i&levelName=%s&levelDesc=%s&levelVersion=%i&levelLength=%i&audioTrack=%i&auto=%i&passw"
"ord=%i&original=%i&twoPlayer=%i&songID=%i&objects=%i&coins=%i&requestedStars=%i&unlisted=%i&wt=%i&wt2=%i&ldm=%i&ts=%i",
v27,
a2->m_levelID.random - a2->m_levelID.seed,
v26,
v25,
a2->m_levelVersion,
a2->m_levelLength,
m_audioTrack,
a2->m_autoLevel,
a2->m_password.random - a2->m_password.seed,
a2->m_originalLevel.random - a2->m_originalLevel.seed,
a2->m_twoPlayerMode,
a2->m_songID,
a2->m_objectCount.random - a2->m_objectCount.seed,
a2->m_coins,
a2->m_starsRequested,
v78,
a2->m_workingTime,
a2->m_workingTime2,
a2->m_lowDetailMode,
a2->m_timestamp);
v29 = (char *)cocos2d::CCString::getCString(v28);
v30 = -1;
do
++v30;
while ( v29[v30] );
sub_140041270(v86, v29, v30);
sub_14003BDB0((__int64)v92, (__int64)&a2->m_capacityString);
if ( v92[2] )
{
sub_140041270(v86, "&extraString=", 0xDu);
v31 = v92;
if ( v92[3] > (void *)0xF )
v31 = (void **)v92[0];
v32 = -1;
do
++v32;
while ( *((_BYTE *)v31 + v32) );
sub_140041270(v86, v31, v32);
}
if ( a2->m_songIDs.m_data.m_size )
{
sub_140041270(v86, "&songIDs=", 9u);
p_m_songIDs = &a2->m_songIDs;
if ( a2->m_songIDs.m_data.m_capacity > 0xF )
p_m_songIDs = (std::string *)p_m_songIDs->m_data.m_bigStorage;
v34 = -1;
do
++v34;
while ( p_m_songIDs->m_data.m_smallStorage._Elems[v34] );
sub_140041270(v86, p_m_songIDs, v34);
}
if ( a2->m_sfxIDs.m_data.m_size )
{
sub_140041270(v86, "&sfxIDs=", 8u);
p_m_sfxIDs = &a2->m_sfxIDs;
if ( a2->m_sfxIDs.m_data.m_capacity > 0xF )
p_m_sfxIDs = (std::string *)p_m_sfxIDs->m_data.m_bigStorage;
v36 = -1;
do
++v36;
while ( p_m_sfxIDs->m_data.m_smallStorage._Elems[v36] );
sub_140041270(v86, p_m_sfxIDs, v36);
}
p_m_levelString = &a2->m_levelString;
sub_14003BDB0((__int64)v90, (__int64)&a2->m_levelString);
Src = 0;
v88 = 0;
v89 = 15;
LOBYTE(Src) = 0;
v38 = v90;
v39 = v91 > 0xF;
v40 = (void **)v90[0];
if ( v91 > 0xF )
v38 = (void **)v90[0];
v41 = -1;
do
++v41;
while ( *((_BYTE *)v38 + v41) );
if ( (int)v41 >= 50 )
{
v43 = 0;
v44 = 50;
v45 = (int)(float)((float)(int)v41 / 50.0);
do
{
v46 = v90;
if ( v39 )
v46 = v40;
sub_14003B190((void **)&Src, *((_BYTE *)v46 + v43));
v43 += v45;
--v44;
}
while ( v44 );
v8 = v77;
p_m_levelString = &a2->m_levelString;
}
else
{
v42 = v90;
if ( v91 > 0xF )
v42 = (void **)v90[0];
sub_14003CCE0((void **)&Src, v42, (size_t)v90[2]);
}
LODWORD(v71) = 67;
LODWORD(v69) = 112;
v47 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 120, "I25", "fpAa", v69, v71, "Qg");
v48 = (char *)cocos2d::CCString::getCString(v47);
v49 = -1;
do
++v49;
while ( v48[v49] );
sub_140041270(&Src, v48, v49);
p_Src = &Src;
if ( v89 <= 0xF )
{
v51 = &Src;
}
else
{
p_Src = (__int128 *)Src;
v51 = (__int128 *)Src;
}
v52 = -1;
do
++v52;
while ( *((_BYTE *)v51 + v52) );
sub_140070860((__int64)p_Src, v52, &v99);
sub_140070B30((unsigned __int8 *)&v99, v102);
*(_OWORD *)Block = 0;
v81 = 0;
v82 = 0;
v53 = -1;
do
++v53;
while ( v102[v53] );
sub_14003A930(Block, v102, v53);
v99 = 0;
v100 = 5;
v101 = 15;
strcpy((char *)&v99, "41274");
cocos2d::ZipUtils::base64EncodeEnc(v97, Block, &v99);
if ( v82 > 0xF )
{
v54 = Block[0];
if ( v82 + 1 >= 0x1000 )
{
v54 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v54 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v54);
}
v81 = 0;
v82 = 15;
LOBYTE(Block[0]) = 0;
sub_140142B90(v96, 0xAu);
v55 = (const char *)v97;
if ( v97[3] > 0xFu )
v55 = (const char *)v97[0];
v56 = (const char *)v96;
if ( v96[3] > 0xFu )
v56 = (const char *)v96[0];
v57 = cocos2d::CCString::createWithFormat("&seed=%s&seed2=%s", v56, v55);
v58 = (char *)cocos2d::CCString::getCString(v57);
v59 = -1;
do
++v59;
while ( v58[v59] );
sub_140041270(v86, v58, v59);
sub_140041270(v86, "&levelString=", 0xDu);
sub_14003BDB0((__int64)v83, (__int64)p_m_levelString);
v60 = v83;
if ( v85 > 0xF )
v60 = (void **)v83[0];
v61 = -1;
do
++v61;
while ( *((_BYTE *)v60 + v61) );
sub_140041270(v86, v60, v61);
sub_14003A830((__int64)v83);
sub_140041270(v86, "&lrs=", 5u);
sub_14003BDB0((__int64)v83, (__int64)&a2->m_recordString);
v62 = v83;
if ( v85 > 0xF )
v62 = (void **)v83[0];
v63 = -1;
do
++v63;
while ( *((_BYTE *)v62 + v63) );
sub_140041270(v86, v62, v63);
sub_14003A830((__int64)v83);
sub_140041270(v86, "&secret=", 8u);
LODWORD(v72) = 98;
LODWORD(v70) = 103;
v64 = cocos2d::CCString::createWithFormat(
"%c%s%s%c%c%s",
87,
"mfd",
"2893",
v70,
v72,
(const char *)&word_140531E88);
v65 = (char *)cocos2d::CCString::getCString(v64);
v66 = -1;
do
++v66;
while ( v65[v66] );
sub_140041270(v86, v65, v66);
v99 = 0;
v100 = 0;
v101 = 0;
v67 = -1;
do
++v67;
while ( v8[v67] );
sub_14003A930(&v99, v8, v67);
v68 = v86;
if ( v86[3] > 0xFu )
v68 = (_QWORD *)v86[0];
*(_OWORD *)v83 = 0;
v84 = 0;
v85 = 0;
do
++v9;
while ( *((_BYTE *)v68 + v9) );
sub_14003A930(v83, v68, v9);
*(_OWORD *)Block = 0;
v81 = 0;
v82 = 15;
Block[0] = sub_14003AA10(0x40u);
v81 = 54;
v82 = 63;
strcpy((char *)Block[0], "https://www.boomlings.com/database/uploadGJLevel21.php");
GameLevelManager::ProcessHttpRequest(a1, (__int64)Block, (const char *)v83, (const char *)&v99, 1);
sub_14003A830((__int64)v96);
sub_14003A830((__int64)v97);
sub_14003A830((__int64)&Src);
sub_14003A830((__int64)v90);
sub_14003A830((__int64)v92);
sub_14003A830((__int64)v86);
sub_14003A830((__int64)v93);
sub_14003A830((__int64)v94);
sub_14003A830((__int64)v98);
sub_14003A830((__int64)v95);
}
}