//
// LevelEditorLayer::doAutoBackup from 0x472bec to 0x472f98 (940 bytes)
//
// 1 xrefs:
// > LevelEditorLayer::checkAutoSave @ 0x4730ca
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:49:06 +0000
//
int __fastcall LevelEditorLayer::doAutoBackup(LevelEditorLayer *this)
{
int result; // r0
int v3; // r8
int v4; // r0
_BOOL4 v5; // r7
EditorSFXManager *v6; // r0
EditorSFXManager *v7; // r0
int v8; // r11
const char *v9; // r1
size_t v10; // r0
struct tm *v11; // r0
unsigned __int8 *v12; // r3
int v13; // r1
char *v14; // r1
int v15; // r2
int v16; // t1
char *v17; // r1
char *v18; // r2
cocos2d::CCString *v19; // r0
char *CString; // r0
unsigned int *v21; // r0
LocalLevelManager *BackupCap; // r11
int v23; // r0
std::__thread_struct *v24; // r11
int v25; // r0
std::__thread_struct *v26; // r1
std::__thread_struct *v27; // r2
int v28; // r0
std::__thread_struct *v29; // r1
std::__thread_struct *v30; // r2
std::__thread_struct *v31; // r0
std::__thread_struct *v32; // r1
std::__thread_struct *v33; // r2
std::__thread_struct **v34; // r8
std::__thread_struct *v35; // r1
std::__thread_struct *v36; // r2
std::__thread_struct *v37; // r1
std::__thread_struct *v38; // r2
std::__thread_struct *v39; // r0
std::__thread_struct *v40; // r1
std::__thread_struct *v41; // r2
std::__thread_struct *v42; // r1
std::__thread_struct *v43; // r2
int v44; // r0
const char *v45; // [sp+Ch] [bp-D8h]
time_t v46; // [sp+10h] [bp-D4h] BYREF
pthread_t newthread; // [sp+14h] [bp-D0h] BYREF
unsigned __int8 v48[12]; // [sp+18h] [bp-CCh] BYREF
char v49[4]; // [sp+24h] [bp-C0h] BYREF
int v50; // [sp+28h] [bp-BCh]
unsigned __int8 v51[12]; // [sp+30h] [bp-B4h] BYREF
std::__thread_struct *v52; // [sp+3Ch] [bp-A8h] BYREF
std::__thread_struct *v53; // [sp+40h] [bp-A4h]
std::__thread_struct *v54; // [sp+44h] [bp-A0h]
int v55[2]; // [sp+48h] [bp-9Ch] BYREF
unsigned __int8 *v56; // [sp+50h] [bp-94h]
char v57; // [sp+54h] [bp-90h] BYREF
char v58; // [sp+55h] [bp-8Fh] BYREF
char *v59; // [sp+5Ch] [bp-88h]
unsigned int v60; // [sp+60h] [bp-84h] BYREF
std::__thread_struct *v61; // [sp+64h] [bp-80h]
std::__thread_struct *v62; // [sp+68h] [bp-7Ch]
unsigned int v63; // [sp+6Ch] [bp-78h] BYREF
std::__thread_struct *v64; // [sp+70h] [bp-74h]
std::__thread_struct *v65; // [sp+74h] [bp-70h]
std::__thread_struct *v66; // [sp+78h] [bp-6Ch] BYREF
std::__thread_struct *v67; // [sp+7Ch] [bp-68h]
std::__thread_struct *v68; // [sp+80h] [bp-64h]
int v69; // [sp+84h] [bp-60h] BYREF
std::__thread_struct *v70; // [sp+88h] [bp-5Ch]
std::__thread_struct *v71; // [sp+8Ch] [bp-58h]
int v72; // [sp+90h] [bp-54h] BYREF
std::__thread_struct *v73; // [sp+94h] [bp-50h]
std::__thread_struct *v74; // [sp+98h] [bp-4Ch]
LocalLevelManager *v75; // [sp+9Ch] [bp-48h]
std::__thread_struct *v76; // [sp+A0h] [bp-44h] BYREF
std::__thread_struct *v77; // [sp+A4h] [bp-40h]
std::__thread_struct *v78; // [sp+A8h] [bp-3Ch]
int v79; // [sp+ACh] [bp-38h] BYREF
std::__thread_struct *v80; // [sp+B0h] [bp-34h]
std::__thread_struct *v81; // [sp+B4h] [bp-30h]
LocalLevelManager *v82; // [sp+B8h] [bp-2Ch]
char v83[32]; // [sp+BCh] [bp-28h] BYREF
result = LevelEditorLayer::canAutoSave(this);
if ( result )
{
v3 = *((_DWORD *)this + 352);
LevelEditorLayer::updateCustomSFXMappings((char **)this);
LevelEditorLayer::getLevelString((LevelEditorLayer *)v48, (int)this);
if ( !sub_45F9A6((unsigned __int8 *)this + 12360, v48) )
{
std::string::operator=((unsigned __int8 *)this + 12360, v48);
AutoSaveSettingsLayer::getCustomBackupDirectory((AutoSaveSettingsLayer *)v49);
if ( (v49[0] & 1) != 0 )
v4 = v50;
else
v4 = (int)(unsigned __int8)v49[0] >> 1;
if ( v4 )
v5 = !GameToolbox::directoryExists((int)v49);
else
v5 = 0;
v6 = (EditorSFXManager *)AutoBackupPopup::backupDirectory((AutoBackupPopup *)v51);
v7 = (EditorSFXManager *)EditorSFXManager::sharedState(v6);
EditorSFXManager::playAction(v7, 226);
v8 = *((_DWORD *)this + 2964);
if ( v8 )
{
if ( v5 )
v9 = "Auto-Backup. Folder missing, using default.";
else
v9 = "Auto-Backup.";
v45 = v9;
v76 = nullptr;
v77 = nullptr;
v78 = nullptr;
v10 = strlen(v9);
std::string::__init((int *)&v76, v45, v10);
EditorUI::showTextAlert(v8, (int)&v76, 0, 1, 0);
std::string::~string((int)&v76);
}
LevelEditorLayer::prepareSaveData((GJGameLevel *)&v52, (int)this, (char *)v48);
v46 = time(nullptr);
v11 = localtime(&v46);
strftime(v83, 0x20u, "%Y-%m-%d_%H-%M-%S", v11);
std::string::basic_string(v55, v3 + 280);
if ( (v55[0] & 1) != 0 )
{
v12 = v56;
v13 = v55[1];
}
else
{
v13 = (int)LOBYTE(v55[0]) >> 1;
v12 = (unsigned __int8 *)v55 + 1;
}
v14 = (char *)&v12[v13];
while ( v12 != (unsigned __int8 *)v14 )
{
v16 = *v12++;
v15 = v16;
if ( v16 == 47
|| v15 == 92
|| v15 == 58
|| (v15 & 0xF7) == 0x22
|| (v15 & 0xBF) == 0x3C
|| (unsigned int)(v15 - 62) <= 1 )
{
*(v12 - 1) = 95;
}
}
GJGameLevel::generateAutoSaveUID((GJGameLevel *)&v57);
if ( (v57 & 1) != 0 )
v17 = v59;
else
v17 = &v58;
if ( (v55[0] & 1) != 0 )
v18 = (char *)v56;
else
v18 = (char *)v55 + 1;
v19 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s_%s_%s.gdlvl",
v17,
v18,
v83);
CString = (char *)cocos2d::CCString::getCString(v19);
v21 = std::operator+(&v60, v51, CString);
BackupCap = (LocalLevelManager *)AutoSaveSettingsLayer::getBackupCap((AutoSaveSettingsLayer *)v21);
v23 = LocalLevelManager::sharedState(BackupCap);
__dmb(0xFu);
*(_BYTE *)(v23 + 377) = 1;
__dmb(0xFu);
std::string::basic_string(&v69, (int)v51);
std::string::basic_string(&v72, (int)&v57);
v75 = BackupCap;
v24 = (std::__thread_struct *)operator new(4u);
std::__thread_struct::__thread_struct(v24);
v25 = v69;
v26 = v70;
v27 = v71;
v69 = 0;
v70 = nullptr;
v71 = nullptr;
v76 = (std::__thread_struct *)v25;
v77 = v26;
v78 = v27;
v28 = v72;
v29 = v73;
v30 = v74;
v72 = 0;
v73 = nullptr;
v74 = nullptr;
v79 = v28;
v80 = v29;
v81 = v30;
v82 = v75;
v31 = v52;
v32 = v53;
v33 = v54;
v52 = nullptr;
v53 = nullptr;
v54 = nullptr;
v66 = v31;
v67 = v32;
v68 = v33;
v63 = v60;
v64 = v61;
v65 = v62;
v60 = 0;
v61 = nullptr;
v62 = nullptr;
v34 = (std::__thread_struct **)operator new(0x38u);
*v34 = v24;
v35 = v77;
v36 = v78;
v34[1] = v76;
v34[2] = v35;
v34[3] = v36;
v76 = nullptr;
v77 = nullptr;
v78 = nullptr;
v37 = v80;
v38 = v81;
v34[4] = (std::__thread_struct *)v79;
v34[5] = v37;
v34[6] = v38;
v39 = v66;
v40 = v67;
v41 = v68;
v79 = 0;
v80 = nullptr;
v81 = nullptr;
v34[7] = v82;
v66 = nullptr;
v34[8] = v39;
v34[9] = v40;
v34[10] = v41;
v67 = nullptr;
v42 = v64;
v43 = v65;
v68 = nullptr;
v34[11] = (std::__thread_struct *)v63;
v34[12] = v42;
v34[13] = v43;
v63 = 0;
v64 = nullptr;
v65 = nullptr;
std::string::~string((int)&v63);
std::string::~string((int)&v66);
std::string::~string((int)&v79);
std::string::~string((int)&v76);
v44 = pthread_create(&newthread, nullptr, (void *(*)(void *))sub_46BB18, v34);
if ( v44 )
std::__throw_system_error(v44, "thread constructor failed");
std::thread::detach((std::thread *)&newthread);
std::thread::~thread((std::thread *)&newthread);
std::string::~string((int)&v72);
std::string::~string((int)&v69);
std::string::~string((int)&v60);
std::string::~string((int)&v57);
std::string::~string((int)v55);
std::string::~string((int)&v52);
std::string::~string((int)v51);
std::string::~string((int)v49);
}
return std::string::~string((int)v48);
}
return result;
}