Skip to content

Instantly share code, notes, and snippets.

@leoetlino
Last active October 31, 2020 21:53
Show Gist options
  • Save leoetlino/4184610deb018b37e38ba78f93aaf9f2 to your computer and use it in GitHub Desktop.
Save leoetlino/4184610deb018b37e38ba78f93aaf9f2 to your computer and use it in GitHub Desktop.
void __fastcall gdt::copyFlags_s32(GameDataMgr::FlagArray *dest, GameDataMgr::FlagArray *src, sead::ObjArray *records, int *indices, bool add_records, bool y, bool find_existing_record, bool is_array)
{
__int64 dest_size; // x27
int src_size; // w28
unsigned __int64 v14; // x19
signed __int64 v15; // x20
GameDataFlag *v16; // x0
unsigned __int8 *v17; // x0
GameDataFlag *v18; // x0
unsigned __int8 *v19; // x0
GameDataFlag *v20; // x8
GameDataFlag *v21; // x25
GameDataFlag *v22; // x0
bool (__fastcall *v23)(GameDataFlag *, _QWORD); // x24
unsigned int v24; // w0
__int16 v25; // w2
unsigned __int8 *v26; // x0
GameDataFlag *v27; // x0
__int64 v28; // x19
int v29; // w20
unsigned __int8 *v30; // x0
unsigned __int8 *v31; // x0
int v32; // w26
int v33; // w26
GameDataFlag *v34; // x26
bool (__fastcall *v35)(GameDataFlag *, _QWORD); // x24
unsigned int v36; // w0
__int16 v37; // w2
unsigned __int8 *v38; // x0
unsigned __int64 v39; // x19
signed __int64 v40; // x20
GameDataFlag *v41; // x0
unsigned __int8 *v42; // x0
GameDataFlag *v43; // x8
GameDataFlag *v44; // x25
bool (__fastcall *v45)(GameDataFlag *, _QWORD); // x24
unsigned int v46; // w0
__int16 v47; // w2
unsigned __int8 *v48; // x0
dest_size = (unsigned int)dest->size;
src_size = src->size;
if ( (_DWORD)dest_size == src->size )
{
if ( (signed int)dest_size >= 1 )
{
if ( y )
{
v14 = 0LL;
v15 = dest_size - 1;
while ( 1 )
{
if ( (unsigned int)dest_size <= v14 )
goto LABEL_26;
v16 = dest->ptrs[v14];
if ( !v16 )
goto LABEL_26;
v17 = (unsigned __int8 *)v16->vptr->getProperties(v16);
if ( !ksys::gdt::FlagProperties::isSave(v17) )
goto LABEL_26;
if ( add_records )
{
v18 = dest->ptrs[v14];
v19 = (unsigned __int8 *)v18->vptr->getProperties(v18);
if ( ksys::gdt::FlagProperties::isSave(v19) )
goto LABEL_26;
}
if ( (unsigned int)src->size <= v14 )
v20 = 0LL;
else
v20 = src->ptrs[v14];
if ( (unsigned int)dest->size <= v14 )
{
v21 = 0LL;
if ( !v20 )
{
LABEL_24:
v26 = (unsigned __int8 *)v21->vptr->getProperties(v21);
if ( !ksys::gdt::FlagProperties::isSave(v26) )
{
v27 = dest->ptrs[v14];
v27->vptr->resetToInitialValue(v27);
}
LABEL_26:
if ( v15 == v14 )
return;
goto LABEL_5;
}
}
else
{
v21 = dest->ptrs[v14];
if ( !v20 )
goto LABEL_24;
}
v22 = src->ptrs[v14];
v23 = v21->vptr->setValue;
v24 = v22->vptr->getValue(v22);
v23(v21, v24);
if ( !add_records )
goto LABEL_26;
if ( is_array )
v25 = v14;
else
v25 = 1;
ksys::gdt::`anonymous namespace'::addFlagCopyRecord<int>(records, v21, v25, find_existing_record);
if ( v15 == v14 )
return;
LABEL_5:
LODWORD(dest_size) = dest->size;
++v14;
}
}
v39 = 0LL;
v40 = dest_size - 1;
while ( 1 )
{
if ( (unsigned int)dest_size <= v39 )
goto LABEL_69;
v41 = dest->ptrs[v39];
if ( !v41 )
goto LABEL_69;
if ( add_records )
{
v42 = (unsigned __int8 *)((__int64 (*)(void))v41->vptr->getProperties)();
if ( ksys::gdt::FlagProperties::isSave(v42) )
goto LABEL_69;
}
if ( (unsigned int)src->size <= v39 )
v43 = 0LL;
else
v43 = src->ptrs[v39];
if ( (unsigned int)dest->size <= v39 )
{
v44 = 0LL;
if ( !v43 )
{
LABEL_67:
v48 = (unsigned __int8 *)v44->vptr->getProperties(v44);
if ( !ksys::gdt::FlagProperties::isSave(v48) )
((void (*)(void))dest->ptrs[v39]->vptr->resetToInitialValue)();
LABEL_69:
if ( v40 == v39 )
return;
goto LABEL_49;
}
}
else
{
v44 = dest->ptrs[v39];
if ( !v43 )
goto LABEL_67;
}
v45 = v44->vptr->setValue;
v46 = ((__int64 (*)(void))src->ptrs[v39]->vptr->getValue)();
v45(v44, v46);
if ( !add_records )
goto LABEL_69;
if ( is_array )
v47 = v39;
else
v47 = 1;
ksys::gdt::`anonymous namespace'::addFlagCopyRecord<int>(records, v44, v47, find_existing_record);
if ( v40 == v39 )
return;
LABEL_49:
LODWORD(dest_size) = dest->size;
++v39;
}
}
}
else if ( src_size < (signed int)dest_size && (signed int)dest_size >= 1 )
{
v28 = 0LL;
v29 = 0;
do
{
if ( !y
|| (v30 = (unsigned __int8 *)((__int64 (*)(void))dest->ptrs[v28]->vptr->getProperties)(),
ksys::gdt::FlagProperties::isSave(v30)) )
{
if ( !add_records
|| (v31 = (unsigned __int8 *)((__int64 (*)(void))dest->ptrs[v28]->vptr->getProperties)(),
!ksys::gdt::FlagProperties::isSave(v31)) )
{
if ( v29 >= src_size
|| (v32 = ((__int64 (*)(void))src->ptrs[v29]->vptr->getHash)(),
v32 != ((unsigned int (*)(void))dest->ptrs[v28]->vptr->getHash)()) )
{
v38 = (unsigned __int8 *)((__int64 (*)(void))dest->ptrs[v28]->vptr->getProperties)();
if ( !ksys::gdt::FlagProperties::isSave(v38) )
((void (*)(void))dest->ptrs[v28]->vptr->resetToInitialValue)();
}
else
{
v33 = ((__int64 (*)(void))src->ptrs[v29]->vptr->getHash)();
if ( v33 == ((unsigned int (*)(void))dest->ptrs[v28]->vptr->getHash)() )
{
v34 = dest->ptrs[v28];
v35 = v34->vptr->setValue;
v36 = ((__int64 (*)(void))src->ptrs[v29]->vptr->getValue)();
v35(v34, v36);
if ( add_records )
{
if ( is_array )
v37 = v28;
else
v37 = 1;
ksys::gdt::`anonymous namespace'::addFlagCopyRecord<int>(records, v34, v37, find_existing_record);
}
++v29;
}
}
}
}
++v28;
}
while ( dest_size != v28 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment