//
// GJBaseGameLayer::updateCounters from 0x10014bb60 to 0x10014bf9a (1082 bytes)
//
// 5 xrefs:
// > GJBaseGameLayer::collectedObject @ 0x10014bb5a
// > GJBaseGameLayer::addPickupTrigger @ 0x10014c107
// > GJBaseGameLayer::activateItemEditTrigger @ 0x10014cb4a
// > GJBaseGameLayer::activatePersistentItemTrigger @ 0x10014d507
// > GJBaseGameLayer::activatePersistentItemTrigger @ 0x10014d5e7
//
// 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 GJBaseGameLayer::updateCounters(GJBaseGameLayer *a1, int a2, int a3)
{
double v3; // xmm0_8
unsigned __int64 value; // r10
unsigned __int64 v5; // r11
unsigned __int64 v6; // r8
std::__hash_node_base>, void *> *> *v7; // rax
std::__hash_node_base>, void *> *>::__next_pointer next; // r13
unsigned __int64 v9; // r10
std::__hash_node_base>, void *> *>::__next_pointer v10; // rax
unsigned __int64 v11; // rax
int v12; // esi
size_t v13; // rbx
size_t v14; // rdi
void *v15; // rax
void *v16; // r14
_BYTE *v17; // r15
void *v18; // r14
size_t v19; // rax
size_t v20; // rbx
char *v21; // r15
size_t v22; // r12
_QWORD *p_next; // rbx
_QWORD *v24; // r13
__int64 v25; // rdi
unsigned __int64 v26; // r14
__int64 v27; // r12
void *v28; // [rsp+8h] [rbp-288h]
__int128 v29; // [rsp+10h] [rbp-280h] BYREF
void *__p; // [rsp+20h] [rbp-270h]
__int128 __dst; // [rsp+30h] [rbp-260h] BYREF
void *v32; // [rsp+40h] [rbp-250h]
char v33; // [rsp+4Fh] [rbp-241h]
size_t __len; // [rsp+50h] [rbp-240h] BYREF
size_t v35; // [rsp+58h] [rbp-238h]
void *__src; // [rsp+60h] [rbp-230h]
_BYTE v37[504]; // [rsp+68h] [rbp-228h] BYREF
value = a1->m_labelObjects.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
if ( !value )
return;
v5 = (0x101010101010101LL
* ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v5 > 1 )
{
v6 = a2;
if ( value <= a2 )
{
if ( !((value | a2) >> 32) )
{
v6 = a2 % (unsigned int)value;
v7 = a1->m_labelObjects.__table_.__bucket_list_.__ptr_.__value_[v6];
if ( !v7 )
return;
goto LABEL_9;
}
v6 = a2 % value;
}
v7 = a1->m_labelObjects.__table_.__bucket_list_.__ptr_.__value_[v6];
if ( !v7 )
return;
goto LABEL_9;
}
v6 = a2 & (value - 1);
v7 = a1->m_labelObjects.__table_.__bucket_list_.__ptr_.__value_[v6];
if ( !v7 )
return;
LABEL_9:
next = v7->__next_;
if ( !v7->__next_ )
return;
if ( (unsigned int)v5 < 2 )
{
v9 = value - 1;
while ( 1 )
{
v10 = next[1].__next_;
if ( v10 == (std::__hash_node_base>, void *> *>::__next_pointer)a2 )
{
if ( LODWORD(next[2].__next_) == a2 )
goto LABEL_27;
}
else if ( (v9 & (unsigned __int64)v10) != v6 )
{
return;
}
next = next->__next_;
if ( !next )
return;
}
}
while ( 1 )
{
v11 = (unsigned __int64)next[1].__next_;
if ( v11 == a2 )
break;
if ( v11 < value )
goto LABEL_23;
if ( (value | v11) >> 32 )
{
v11 %= value;
LABEL_23:
if ( v11 != v6 )
return;
goto LABEL_18;
}
if ( (unsigned int)v11 % (unsigned int)value != v6 )
return;
LABEL_18:
next = next->__next_;
if ( !next )
return;
}
if ( LODWORD(next[2].__next_) != a2 )
goto LABEL_18;
LABEL_27:
v12 = 999999999;
if ( a3 < 999999999 )
v12 = a3;
__len = 0;
v35 = 500;
__src = v37;
sub_10003DD80((__int64)&__len, v12);
v13 = __len;
if ( v35 >= __len + 1 )
{
v16 = __src;
}
else
{
v14 = v35 + (v35 >> 1);
if ( v14 <= __len + 1 )
v14 = __len + 1;
v35 = v14;
v15 = operator new[](v14);
v16 = v15;
v17 = __src;
if ( v13 )
memmove(v15, __src, v13);
if ( v17 != v37 && v17 != nullptr )
operator delete[](v17);
__src = v16;
}
*((_BYTE *)v16 + v13) = 0;
v18 = __src;
v19 = strlen((const char *)__src);
if ( v19 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v3);
v20 = v19;
if ( v19 >= 0x17 )
{
v22 = 26;
if ( (v19 | 7) != 0x17 )
v22 = (v19 | 7) + 1;
v21 = (char *)operator new(v22);
v32 = v21;
*(_QWORD *)&__dst = v22 | 1;
*((_QWORD *)&__dst + 1) = v20;
goto LABEL_47;
}
LOBYTE(__dst) = 2 * v19;
v21 = (char *)&__dst + 1;
if ( v19 )
LABEL_47:
memmove(v21, v18, v20);
v21[v20] = 0;
p_next = &next[3].__next_->__next_;
v24 = &next[4].__next_->__next_;
if ( p_next == v24 )
{
if ( (__dst & 1) == 0 )
goto LABEL_56;
LABEL_55:
operator delete(v32);
goto LABEL_56;
}
v28 = v32;
v33 = __dst;
if ( (__dst & 1) != 0 )
{
v26 = *((_QWORD *)&__dst + 1);
do
{
v27 = *p_next;
sub_100006B70(&v29, v28, v26, v3);
LabelGameObject::queueUpdateLabel(v27, &v29);
if ( (v29 & 1) != 0 )
operator delete(__p);
++p_next;
}
while ( p_next != v24 );
goto LABEL_55;
}
do
{
v25 = *p_next;
__p = v32;
v29 = __dst;
LabelGameObject::queueUpdateLabel(v25, &v29);
if ( (v29 & 1) != 0 )
operator delete(__p);
++p_next;
}
while ( p_next != v24 );
LABEL_56:
if ( __src != v37 && __src != nullptr )
operator delete[](__src);
}