//
// SetupRandAdvTriggerPopup::onAddChance from 0x14043ea60 to 0x14043ed17 (695 bytes)
//
// 2 xrefs:
// > SetupRandAdvTriggerPopup::init @ 0x14043db31
// > ??> @ 0x1406da1f0
//
// 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 SetupRandAdvTriggerPopup::onAddChance(SetupRandAdvTriggerPopup *a1, cocos2d::CCObject *a2)
{
cocos2d::CCLabelProtocol *v3; // rcx
_BYTE *v4; // rax
size_t v5; // rdi
size_t v6; // r8
const char *v7; // rcx
int v8; // ebx
char *v9; // rcx
cocos2d::CCLabelProtocol *v10; // rcx
const char *v11; // rax
const char *v12; // rcx
int v13; // esi
char *v14; // rcx
EffectGameObject *m_gameObject; // rcx
EffectGameObject *v16; // rcx
int *v17; // rax
int *v18; // rdx
unsigned int v19; // edi
unsigned int *p_m_uID; // rcx
int *v21; // rax
int *v22; // rdx
int v23; // [rsp+20h] [rbp-40h] BYREF
int v24; // [rsp+28h] [rbp-38h] BYREF
char *String[2]; // [rsp+30h] [rbp-30h] BYREF
__int128 v26; // [rsp+40h] [rbp-20h]
v3 = &a1->m_groupIDInput->m_textField->cocos2d::CCLabelProtocol;
v4 = (_BYTE *)((__int64 (__fastcall *)(cocos2d::CCLabelProtocol *, cocos2d::CCObject *))v3->getString)(v3, a2);
v5 = -1;
*(_OWORD *)String = 0;
v6 = -1;
v26 = 0;
do
++v6;
while ( v4[v6] );
sub_14003A930(String, v4, v6);
v7 = (const char *)String;
if ( *((_QWORD *)&v26 + 1) > 0xFu )
v7 = String[0];
v8 = atoi(v7);
if ( *((_QWORD *)&v26 + 1) > 0xFu )
{
v9 = String[0];
if ( (unsigned __int64)(*((_QWORD *)&v26 + 1) + 1LL) >= 0x1000 )
{
v9 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v9 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v9);
}
v10 = &a1->m_chanceInput->m_textField->cocos2d::CCLabelProtocol;
v11 = v10->getString(v10);
*(_OWORD *)String = 0;
v26 = 0;
do
++v5;
while ( v11[v5] );
sub_14003A930(String, v11, v5);
v12 = (const char *)String;
if ( *((_QWORD *)&v26 + 1) > 0xFu )
v12 = String[0];
v13 = atoi(v12);
if ( *((_QWORD *)&v26 + 1) > 0xFu )
{
v14 = String[0];
if ( (unsigned __int64)(*((_QWORD *)&v26 + 1) + 1LL) >= 0x1000 )
{
v14 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
if ( v8 > 0 && v13 > 0 )
{
m_gameObject = a1->m_gameObject;
a1->m_performedAction = 1;
if ( m_gameObject )
{
v16 = m_gameObject + 1;
v24 = v13;
v23 = v8;
v17 = (int *)v16->EnhancedGameObject::GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v18 = *(int **)&v16->m_uID;
if ( (int *)v16->EnhancedGameObject::GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable == v18 )
{
LABEL_25:
if ( v18 == *(int **)&v16->m_nTag )
{
((void (__fastcall *)(EffectGameObject *, int *, int *, int *))sub_14043F020)(v16, v18, &v23, &v24);
}
else
{
*v18 = v8;
v18[1] = v8;
v18[2] = v13;
v18[3] = 0;
*(_QWORD *)&v16->m_uID += 16LL;
}
}
else
{
while ( *v17 != v8 )
{
v17 += 4;
if ( v17 == v18 )
goto LABEL_25;
}
v17[2] += v13;
}
}
else
{
v19 = 0;
if ( cocos2d::CCArray::count(a1->m_gameObjects) )
{
v23 = v13;
v24 = v8;
do
{
p_m_uID = &cocos2d::CCArray::objectAtIndex(a1->m_gameObjects, v19)[33].m_uID;
v21 = *(int **)p_m_uID;
v22 = *((int **)p_m_uID + 1);
if ( *(int **)p_m_uID == v22 )
{
LABEL_34:
if ( v22 == *((int **)p_m_uID + 2) )
{
((void (__fastcall *)(unsigned int *, int *, int *, int *))sub_14043F020)(p_m_uID, v22, &v24, &v23);
}
else
{
*v22 = v8;
v22[1] = v8;
v22[2] = v13;
v22[3] = 0;
*((_QWORD *)p_m_uID + 1) += 16LL;
}
}
else
{
while ( *v21 != v8 )
{
v21 += 4;
if ( v21 == v22 )
goto LABEL_34;
}
v21[2] += v13;
}
++v19;
}
while ( v19 < cocos2d::CCArray::count(a1->m_gameObjects) );
}
}
SetupRandAdvTriggerPopup::updateGroupIDButtons(a1);
SetupRandAdvTriggerPopup::updateGroupIDButtons(a1);
}
}