//
// EmoteSprite::replaceTokens from 0x1004dcd5c to 0x1004dcf94 (568 bytes)
//
// 7 xrefs:
// > CommentCell::loadFromComment @ 0x10012ba0c
// > CCTextInputNode::updateLabel @ 0x1001fb4bc
// > sub_1002D11E0 @ 0x1002d123c
// > sub_1004D5758 @ 0x1004d5b30
// > InvitesPopup::buildRows @ 0x10050f86c
// > sub_100518264 @ 0x1005185e4
// > sub_10051FFE8 @ 0x1005204d0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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:06:35 +0000
//
std::string *__usercall EmoteSprite::replaceTokens@(
__int64 a1@,
__int64 *a2@,
__int64 a3@,
float a4@)
{
std::string::size_type v8; // x1
__int64 v9; // x8
unsigned __int64 v10; // x27
std::string::size_type v11; // x2
std::string *v12; // x0
__int64 *v13; // x8
__int64 v14; // x23
__int64 v15; // x24
__int64 v16; // x10
__int64 v17; // x22
unsigned __int8 v18; // w8
_DWORD *v19; // x25
__int64 v20; // x10
int v21; // w9
__int64 *v22; // x8
__int64 v23; // x26
void *v24; // x0
char *CString; // x0
__int64 v26; // x0
float v27; // s11
float v28; // s0
float v30; // s0
std::string::value_type v31; // w1
unsigned int *v33; // [xsp+18h] [xbp-78h] BYREF
*(_QWORD *)a3 = 0;
*(_QWORD *)(a3 + 8) = 0;
*(_QWORD *)(a3 + 16) = 0;
if ( *(char *)(a1 + 23) >= 0 )
v8 = *(unsigned __int8 *)(a1 + 23);
else
v8 = *(_QWORD *)(a1 + 8);
std::string::reserve((std::string *)a3, v8);
v9 = *a2;
if ( a2[1] == *a2 )
{
v11 = 0;
}
else
{
v10 = 0;
v11 = 0;
do
{
v12 = std::string::append((std::string *)a3, (const std::string *)a1, v11, *(_QWORD *)(v9 + 24 * v10) - v11);
v13 = (__int64 *)(*a2 + 24 * v10);
v14 = *v13;
v15 = v13[1];
if ( *(char *)(a3 + 23) >= 0 )
v16 = *(unsigned __int8 *)(a3 + 23);
else
v16 = *(_QWORD *)(a3 + 8);
*v13 = v16;
v13[1] = 1;
v17 = v13[2];
v18 = atomic_load((unsigned __int8 *)&byte_1009F81D0);
if ( (v18 & 1) == 0 )
sub_100755BD4(v12);
v19 = (_DWORD *)(v17 + 8);
v20 = qword_1009F81E0;
if ( !qword_1009F81E0 )
goto LABEL_18;
v21 = *v19;
v22 = &qword_1009F81E0;
do
{
if ( *(_DWORD *)(v20 + 28) >= v21 )
v22 = (__int64 *)v20;
v20 = *(_QWORD *)(v20 + 8LL * (*(_DWORD *)(v20 + 28) < v21));
}
while ( v20 );
if ( v22 != &qword_1009F81E0 && v21 >= *((_DWORD *)v22 + 7) )
{
v27 = *((float *)v22 + 8);
}
else
{
LABEL_18:
v23 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v24 = sub_1003065B0("particle_%02d_001.png", *v19);
CString = (char *)cocos2d::CCString::getCString((__int64)v24);
v26 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v23, CString);
v27 = 1.0;
if ( v26 )
{
v28 = *(float *)(v26 + 104);
if ( v28 > 0.0 )
v27 = *(float *)(v26 + 100) / v28;
}
v33 = (unsigned int *)(v17 + 8);
*((float *)sub_1001E71D0((__int64)&qword_1009F81D8, (int *)(v17 + 8), (__int64)&unk_10076FF6D, &v33) + 8) = v27;
}
if ( v27 <= a4 || a4 <= 0.0 )
v30 = v27;
else
v30 = a4;
if ( (float)(*(float *)(v17 + 12) * v30) <= 1.1 )
v31 = 127;
else
v31 = 30;
std::string::push_back((std::string *)a3, v31);
v11 = v15 + v14;
++v10;
v9 = *a2;
}
while ( v10 < 0xAAAAAAAAAAAAAAABLL * ((a2[1] - *a2) >> 3) );
}
return std::string::append((std::string *)a3, (const std::string *)a1, v11, 0xFFFFFFFFFFFFFFFFLL);
}