//
// ChallengesPage::updateTimers from 0x908898 to 0x908b44 (684 bytes)
//
// 8 xrefs:
// > ChallengesPage::challengeStatusFinished @ 0x908b74
// > ChallengesPage::challengeStatusFinished @ 0x908bf8
// > ChallengesPage::claimItem @ 0x908d4c
// > ??> @ 0x78a38
// > ChallengesPage::init @ 0x90825c
// > ChallengesPage::challengeStatusFinished @ 0x908bfc
// > ChallengesPage::challengeStatusFinished @ 0x908c0c
// > ??> @ 0x122c088
//
// 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 ChallengesPage::updateTimers(ChallengesPage *a1, float a2)
{
GameStatsManager *v3; // x0
double v4; // d8
int v5; // w24
cocos2d::CCLabelBMFont *m_countdownLabel; // x19
void (__fastcall *setString)(cocos2d::CCLabelBMFont *__hidden, const unsigned __int8 *); // x26
cocos2d::CCString *v8; // x0
const char *CString; // x0
cocos2d::CCDictionary *m_challengeNodes; // x0
cocos2d::CCDictElement *m_pElements; // x2
cocos2d::CCDictElement *i; // x19
__int64 m_pObject; // x28
std::_Rb_tree_node_base::_Base_ptr *p_M_right; // x0
unsigned int *p_m_pathBugFixed; // x1
int v16; // w2
char *v17; // x19
unsigned int *v18; // x1
int v19; // w0
GameStatsManager *v20; // x0
char *v21; // [xsp+80h] [xbp+80h] BYREF
GameStatsManager *v22[2]; // [xsp+88h] [xbp+88h] BYREF
v3 = GameStatsManager::sharedState();
if ( GameStatsManager::areChallengesLoaded(v3) )
{
clock_gettime(0, (struct timespec *)v22);
v4 = (double)(__int64)v22[0] + (double)(__int64)v22[1] / 1000000000.0;
v5 = (int)(GameStatsManager::sharedState()->m_challengeTime - v4);
if ( v5 < 0 )
v5 = 0;
GameToolbox::getTimeString((GameToolbox *)(unsigned int)v5, nullptr, (__int64)&v21);
m_countdownLabel = a1->m_countdownLabel;
setString = m_countdownLabel->setString;
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"New quests in: %s", v21);
CString = cocos2d::CCString::getCString(v8);
setString(m_countdownLabel, (const unsigned __int8 *)CString);
m_challengeNodes = a1->m_challengeNodes;
if ( m_challengeNodes )
{
m_pElements = m_challengeNodes->m_pElements;
if ( m_pElements )
{
for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )
{
m_pObject = (__int64)m_pElements->m_pObject;
sub_D18D28(v22);
ChallengeNode::updateTimeLabel(m_pObject, v22);
p_M_right = &v22[0][-1].m_wraithIcons._M_t._M_impl._M_header._M_right;
if ( (__int64 *)&v22[0][-1].m_wraithIcons._M_t._M_impl._M_header._M_right == &qword_124B6B0 )
goto LABEL_9;
if ( &pthread_create )
{
p_m_pathBugFixed = (unsigned int *)&v22[0][-1].m_pathBugFixed;
do
v16 = __ldaxr(p_m_pathBugFixed);
while ( __stlxr(v16 - 1, p_m_pathBugFixed) );
}
else
{
v16 = *(_DWORD *)&v22[0][-1].m_pathBugFixed;
*(_DWORD *)&v22[0][-1].m_pathBugFixed = v16 - 1;
}
if ( v16 > 0 )
{
LABEL_9:
if ( !i )
break;
}
else
{
operator delete(p_M_right);
if ( !i )
break;
}
m_pElements = i;
}
}
}
if ( !v5 && !a1->m_unkBool )
{
a1->m_circle->setVisible(a1->m_circle, 1);
a1->m_countdownLabel->setVisible(a1->m_countdownLabel, 0);
a1->m_triedToLoad = 0;
a1->m_unkBool = (unsigned __int8)&dword_0 + 1;
v20 = GameStatsManager::sharedState();
GameStatsManager::resetChallengeTimer(v20);
ChallengesPage::tryGetChallenges(a1);
}
v17 = v21 - 24;
if ( v21 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v21 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *((_DWORD *)v21 - 2);
*((_DWORD *)v21 - 2) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v17);
}
}
}