//
// GJGameLevel::encodeWithCoder from 0x708c84 to 0x709970 (3308 bytes)
//
// 2 xrefs:
// > ??> @ 0x93d80
// > ??> @ 0x115e3a0
//
// 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 GJGameLevel::encodeWithCoder(GJGameLevel *a1, DS_Dictionary *a2)
{
char *v4; // x0
int NormalPercent; // w0
int v6; // w2
int m_levelFolder; // w2
int m_bestTime; // w2
std::string *p_m_localBestPoints; // x2
int v10; // w22
char *v11; // x22
float x; // s0
int m_workingTime; // w2
int m_workingTime2; // w2
GJLevelType m_levelType; // w0
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x2
int v19; // w0
std::string v20; // [xsp+50h] [xbp+50h] BYREF
DS_Dictionary::setIntegerForKey(a2, "kCEK", 4);
DS_Dictionary::setIntegerForKey(a2, "k1", a1->m_levelID.random - a1->m_levelID.seed);
DS_Dictionary::setBoolForKey(a2, "k35", a1->m_levelNotDownloaded);
DS_Dictionary::setIntegerForKey(a2, "k18", a1->m_attempts.random - a1->m_attempts.seed);
DS_Dictionary::setIntegerForKey(a2, "k36", a1->m_jumps.random - a1->m_jumps.seed);
DS_Dictionary::setIntegerForKey(a2, "k85", a1->m_clicks.random - a1->m_clicks.seed);
DS_Dictionary::setIntegerForKey(a2, "k86", a1->m_attemptTime.random - a1->m_attemptTime.seed);
DS_Dictionary::setIntegerForKey(a2, "k87", a1->m_chk);
sub_D18D28(&v20, &a1->m_personalBests);
DS_Dictionary::setStringForKey(a2, "k88", &v20);
v4 = (char *)v20.m_data.m_data - 24;
if ( (__int64 *)v20.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v20.m_data.m_data - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v20.m_data.m_data - 2);
*((_DWORD *)v20.m_data.m_data - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v4);
}
DS_Dictionary::setBoolForKey(a2, "k89", a1->m_isChkValid);
DS_Dictionary::setIntegerForKey(a2, "k23", a1->m_levelLength);
NormalPercent = GJGameLevel::getNormalPercent(a1);
DS_Dictionary::setIntegerForKey(a2, "k19", NormalPercent);
DS_Dictionary::setIntegerForKey(a2, "k71", a1->m_orbCompletion.random - a1->m_orbCompletion.seed);
DS_Dictionary::setIntegerForKey(a2, "k90", a1->m_newNormalPercent2.random - a1->m_newNormalPercent2.seed);
DS_Dictionary::setIntegerForKey(a2, "k20", a1->m_practicePercent);
if ( a1->m_demon.random - a1->m_demon.seed == 1 )
{
DS_Dictionary::setBoolForKey(a2, "k25", 1);
DS_Dictionary::setIntegerForKey(a2, "k76", a1->m_demonDifficulty);
}
v6 = a1->m_stars.random - a1->m_stars.seed;
if ( v6 > 0 )
DS_Dictionary::setIntegerForKey(a2, "k26", v6);
if ( a1->m_isCompletionLegitimate )
DS_Dictionary::setBoolForKey(a2, "k68", 1);
DS_Dictionary::setIntegerForKey(a2, "k74", a1->m_dailyID.random - a1->m_dailyID.seed);
DS_Dictionary::setBoolForKey(a2, "k77", a1->m_gauntletLevel);
DS_Dictionary::setBoolForKey(a2, "k78", a1->m_gauntletLevel2);
if ( a1->m_levelFavorited )
DS_Dictionary::setBoolForKey(a2, "k82", 1);
m_levelFolder = a1->m_levelFolder;
if ( m_levelFolder > 0 )
DS_Dictionary::setIntegerForKey(a2, "k84", m_levelFolder);
m_bestTime = a1->m_bestTime;
if ( m_bestTime > 0 || a1->m_bestPoints )
{
DS_Dictionary::setIntegerForKey(a2, "k107", m_bestTime);
DS_Dictionary::setIntegerForKey(a2, "k115", a1->m_ticksTime);
DS_Dictionary::setIntegerForKey(a2, "k117", a1->m_clicksTime);
DS_Dictionary::setIntegerForKey(a2, "k121", a1->m_coinsTime);
if ( a1->m_savedTime )
DS_Dictionary::setStringForKey(a2, "k119", &a1->m_inputsTime);
DS_Dictionary::setIntegerForKey(a2, "k108", a1->m_bestPoints);
DS_Dictionary::setIntegerForKey(a2, "k116", a1->m_ticksPoints);
DS_Dictionary::setIntegerForKey(a2, "k118", a1->m_clicksPoints);
DS_Dictionary::setIntegerForKey(a2, "k122", a1->m_coinsPoints);
if ( a1->m_savedPoints )
DS_Dictionary::setStringForKey(a2, "k120", &a1->m_inputsPoints);
DS_Dictionary::setIntegerForKey(a2, "k111", a1->m_platformerSeed);
DS_Dictionary::setBoolForKey(a2, "k123", a1->m_savedTime);
DS_Dictionary::setBoolForKey(a2, "k124", a1->m_savedPoints);
}
if ( *((_QWORD *)a1->m_localBestTimes.m_data.m_data - 3) )
{
DS_Dictionary::setStringForKey(a2, "k109", &a1->m_localBestTimes);
p_m_localBestPoints = &a1->m_localBestPoints;
if ( !*((_QWORD *)a1->m_localBestPoints.m_data.m_data - 3) )
goto LABEL_20;
}
else
{
p_m_localBestPoints = &a1->m_localBestPoints;
if ( !*((_QWORD *)a1->m_localBestPoints.m_data.m_data - 3) )
goto LABEL_20;
}
DS_Dictionary::setStringForKey(a2, "k110", p_m_localBestPoints);
LABEL_20:
if ( a1->m_levelNotDownloaded )
return;
if ( *((_QWORD *)a1->m_levelName.m_data.m_data - 3) )
{
LABEL_24:
DS_Dictionary::setStringForKey(a2, "k2", &a1->m_levelName);
if ( a1->m_levelNotDownloaded )
goto LABEL_30;
goto LABEL_25;
}
if ( *((_QWORD *)a1->m_tempName.m_data.m_data - 3) )
{
sub_D18EA8(&a1->m_levelName, &a1->m_tempName);
goto LABEL_24;
}
sub_D1798C(&a1->m_levelName, "Unknown", 7);
DS_Dictionary::setStringForKey(a2, "k2", &a1->m_levelName);
if ( a1->m_levelNotDownloaded )
goto LABEL_30;
LABEL_25:
if ( a1->m_dontSave )
goto LABEL_30;
if ( a1->m_levelType != Main )
{
if ( a1->m_dailyID.random - a1->m_dailyID.seed > 0 || !GameManager::sharedState()->m_quickSave )
goto LABEL_28;
LABEL_30:
if ( a1->m_levelType == Editor )
goto LABEL_28;
}
if ( a1->m_dailyID.random - a1->m_dailyID.seed <= 0 || a1->m_dontSave )
{
sub_D153B8((int)&v20, &byte_F288A0);
DS_Dictionary::setStringForKey(a2, "k4", &v20);
v11 = (char *)v20.m_data.m_data - 24;
if ( (__int64 *)v20.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)((char *)v20.m_data.m_data - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *((_DWORD *)v20.m_data.m_data - 2);
*((_DWORD *)v20.m_data.m_data - 2) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v11);
}
v10 = 0;
goto LABEL_35;
}
LABEL_28:
v10 = 1;
DS_Dictionary::setStringForKey(a2, "k4", &a1->m_levelString);
DS_Dictionary::setStringForKey(a2, "k3", &a1->m_levelDesc);
LABEL_35:
DS_Dictionary::setStringForKey(a2, "k5", &a1->m_creatorName);
DS_Dictionary::setIntegerForKey(a2, "k95", a1->m_timestamp);
DS_Dictionary::setStringForKey(a2, "k91", &a1->m_lockedEditorLayers);
DS_Dictionary::setStringForKey(a2, "k101", &a1->m_savedCameraPositions);
DS_Dictionary::setIntegerForKey(a2, "k125", a1->m_cbsOverride);
x = a1->m_previewLock.x;
if ( x != 0.0 || a1->m_previewLock.y != 0.0 )
{
DS_Dictionary::setIntegerForKey(a2, "k102", (int)x);
DS_Dictionary::setIntegerForKey(a2, "k103", (int)a1->m_previewLock.y);
}
if ( v10 )
DS_Dictionary::setIntegerForKey(a2, "k6", a1->m_userID.random - a1->m_userID.seed);
DS_Dictionary::setIntegerForKey(a2, "k60", a1->m_accountID.random - a1->m_accountID.seed);
DS_Dictionary::setIntegerForKey(a2, "k7", a1->m_difficulty);
DS_Dictionary::setIntegerForKey(a2, "k8", a1->m_audioTrack);
DS_Dictionary::setIntegerForKey(a2, "k9", a1->m_ratings);
DS_Dictionary::setIntegerForKey(a2, "k10", a1->m_ratingsSum);
DS_Dictionary::setIntegerForKey(a2, "k11", a1->m_downloads);
DS_Dictionary::setBoolForKey(a2, "k13", a1->m_isEditable);
DS_Dictionary::setBoolForKey(a2, "k14", a1->m_isVerified.random - a1->m_isVerified.seed == 1);
DS_Dictionary::setBoolForKey(a2, "k15", a1->m_isUploaded);
DS_Dictionary::setIntegerForKey(a2, "k22", a1->m_likes);
DS_Dictionary::setIntegerForKey(a2, "k24", a1->m_dislikes);
DS_Dictionary::setIntegerForKey(a2, "k21", a1->m_levelType);
DS_Dictionary::setIntegerForKey(a2, "k16", a1->m_levelVersion);
if ( v10 )
DS_Dictionary::setIntegerForKey(a2, "k17", a1->m_gameVersion);
DS_Dictionary::setBoolForKey(a2, "k69", a1->m_highObjectsEnabled);
DS_Dictionary::setBoolForKey(a2, "k93", a1->m_unlimitedObjectsEnabled);
m_workingTime = a1->m_workingTime;
if ( m_workingTime > 0 )
DS_Dictionary::setIntegerForKey(a2, "k80", m_workingTime);
m_workingTime2 = a1->m_workingTime2;
if ( m_workingTime2 > 0 )
DS_Dictionary::setIntegerForKey(a2, "k81", m_workingTime2);
if ( v10 )
DS_Dictionary::setBoolForKey(a2, "k72", a1->m_lowDetailMode);
DS_Dictionary::setBoolForKey(a2, "k73", a1->m_lowDetailModeToggled);
DS_Dictionary::setBoolForKey(a2, "k112", a1->m_disableShakeToggled);
DS_Dictionary::setIntegerForKey(a2, "k83", a1->m_levelIndex);
DS_Dictionary::setIntegerForKey(a2, "k64", a1->m_coins);
DS_Dictionary::setBoolForKey(a2, "k65", a1->m_coinsVerified.random - a1->m_coinsVerified.seed == 1);
DS_Dictionary::setIntegerForKey(a2, "k27", a1->m_featured);
DS_Dictionary::setIntegerForKey(a2, "k75", a1->m_isEpic);
DS_Dictionary::setBoolForKey(a2, "k33", a1->m_autoLevel);
DS_Dictionary::setBoolForKey(a2, "k79", a1->m_unlisted);
DS_Dictionary::setBoolForKey(a2, "k94", a1->m_friendsOnly);
if ( v10 )
{
DS_Dictionary::setIntegerForKey(a2, "k41", a1->m_password.random - a1->m_password.seed);
DS_Dictionary::setIntegerForKey(a2, "k42", a1->m_originalLevel.random - a1->m_originalLevel.seed);
DS_Dictionary::setBoolForKey(a2, "k43", a1->m_twoPlayerMode);
DS_Dictionary::setIntegerForKey(a2, "k45", a1->m_songID);
DS_Dictionary::setIntegerForKey(a2, "k50", 48);
DS_Dictionary::setIntegerForKey(a2, "k46", a1->m_levelRev);
DS_Dictionary::setBoolForKey(a2, "k47", a1->m_hasBeenModified);
DS_Dictionary::setIntegerForKey(a2, "k48", a1->m_objectCount.random - a1->m_objectCount.seed);
DS_Dictionary::setStringForKey(a2, "k67", &a1->m_capacityString);
}
else
{
DS_Dictionary::setBoolForKey(a2, "k43", a1->m_twoPlayerMode);
DS_Dictionary::setIntegerForKey(a2, "k45", a1->m_songID);
DS_Dictionary::setIntegerForKey(a2, "k50", 48);
DS_Dictionary::setIntegerForKey(a2, "k46", a1->m_levelRev);
DS_Dictionary::setBoolForKey(a2, "k47", a1->m_hasBeenModified);
DS_Dictionary::setIntegerForKey(a2, "k48", a1->m_objectCount.random - a1->m_objectCount.seed);
}
DS_Dictionary::setStringForKey(a2, "k104", &a1->m_songIDs);
DS_Dictionary::setStringForKey(a2, "k105", &a1->m_sfxIDs);
DS_Dictionary::setIntegerForKey(a2, "k106", a1->m_songSize);
DS_Dictionary::setIntegerForKey(a2, "k66", a1->m_starsRequested);
m_levelType = a1->m_levelType;
if ( m_levelType == Main )
{
DS_Dictionary::setBoolForKey(a2, "k38", a1->m_isUnlocked);
DS_Dictionary::setIntegerForKey(a2, "k37", a1->m_requiredCoins);
m_levelType = a1->m_levelType;
}
if ( m_levelType == Editor )
{
DS_Dictionary::setFloatForKey(a2, "kI1", a1->m_lastCameraPos.x);
DS_Dictionary::setFloatForKey(a2, "kI2", a1->m_lastCameraPos.y);
DS_Dictionary::setFloatForKey(a2, "kI3", a1->m_lastEditorZoom);
DS_Dictionary::setIntegerForKey(a2, "kI4", a1->m_lastBuildPage);
DS_Dictionary::setIntegerForKey(a2, "kI5", a1->m_lastBuildTab);
DS_Dictionary::setIntegerForKey(a2, "kI7", a1->m_lastBuildGroupID);
DS_Dictionary::setDictForKey(a2, "kI6", a1->m_lastBuildSave);
DS_Dictionary::setBoolForKey(a2, "k61", a1->m_firstCoinVerified.random - a1->m_firstCoinVerified.seed == 1);
DS_Dictionary::setBoolForKey(a2, "k62", a1->m_secondCoinVerified.random - a1->m_secondCoinVerified.seed == 1);
DS_Dictionary::setBoolForKey(a2, "k63", a1->m_thirdCoinVerified.random - a1->m_thirdCoinVerified.seed == 1);
DS_Dictionary::setStringForKey(a2, "k34", &a1->m_recordString);
}
}