//
// cocos2d::CCMotionStreak::update from 0x18005d210 to 0x18005d885 (1653 bytes)
//
// 6 xrefs:
// > ??> @ 0x1800f9458
// > ??> @ 0x18013924c
// > ??> @ 0x1801392c0
// > ??> @ 0x1801392d0
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b3150
//
// 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 cocos2d::CCMotionStreak::update(cocos2d::CCMotionStreak *this, float a2, float a3)
{
struct cocos2d::CCPoint *v3; // rdx
float v5; // xmm6_4
int v6; // ebp
unsigned int v7; // esi
unsigned int m_uNuPoints; // eax
GLubyte **p_m_pColorPointer; // rbx
float *m_pPointState; // rax
float v11; // xmm1_4
__int64 v12; // r14
__int64 v13; // r9
__int64 v14; // r10
__int64 v15; // rax
__int64 v16; // r10
__int64 v17; // rdx
__int64 v18; // r9
unsigned int v19; // eax
float *v20; // rbx
float *v21; // rax
float *v22; // rax
float v23; // xmm0_4
float v24; // xmm1_4
unsigned int v25; // eax
bool v26; // r14
signed int v27; // ecx
float *v28; // rbx
float *v29; // rax
float *v30; // rax
float v31; // xmm0_4
float v32; // xmm2_4
unsigned int v33; // ebx
__int64 v34; // rsi
cocos2d::CCPoint *m_pPointVertexes; // rcx
GLubyte *m_pColorPointer; // rcx
__int64 v37; // r8
GLubyte *v38; // rcx
struct cocos2d::_ccVertex2F *v39; // r9
cocos2d *v40; // rcx
bool m_bRepeatMode; // r8
unsigned int v42; // r8d
__int64 v43; // rdx
int v44; // eax
__int64 v45; // rcx
float v46; // xmm0_4
cocos2d::ccTex2F *v47; // rax
GLfloat v48; // xmm0_4
cocos2d::ccTex2F *v49; // rax
unsigned int v50; // ecx
unsigned int v51; // r8d
float v52; // xmm1_4
__int64 v53; // rdx
int v54; // eax
__int64 v55; // rcx
float v56; // xmm0_4
cocos2d::ccTex2F *m_pTexCoords; // rax
GLfloat v58; // xmm0_4
cocos2d::ccTex2F *v59; // rax
unsigned int v60; // [rsp+28h] [rbp-70h]
int v61; // [rsp+A0h] [rbp+8h] BYREF
int v62; // [rsp+B0h] [rbp+18h] BYREF
float v63; // [rsp+B8h] [rbp+20h] BYREF
if ( !this->m_bStartingPositionInitialized )
return;
v5 = a2 * this->m_fFadeDelta;
v6 = 0;
v7 = 0;
m_uNuPoints = this->m_uNuPoints;
if ( m_uNuPoints )
{
p_m_pColorPointer = &this->m_pColorPointer;
do
{
this->m_pPointState[v7] = this->m_pPointState[v7] - v5;
m_pPointState = this->m_pPointState;
v11 = m_pPointState[v7];
if ( v11 > 0.0 )
{
v12 = v7 - v6;
if ( v6 )
{
m_pPointState[v12] = v11;
cocos2d::CCSize::operator=(&this->m_pPointVertexes[v12], &this->m_pPointVertexes[v7]);
v13 = 2 * v7;
v14 = (unsigned int)(2 * v12);
v15 = (unsigned int)(v14 + 1);
this->m_pVertices[v14] = this->m_pVertices[v13];
v16 = (unsigned int)(8 * v12);
v17 = (unsigned int)(v13 + 1);
v18 = 8 * v7;
this->m_pVertices[v15] = this->m_pVertices[v17];
v3 = (struct cocos2d::CCPoint *)*p_m_pColorPointer;
(*p_m_pColorPointer)[v16] = (*p_m_pColorPointer)[v18];
(*p_m_pColorPointer)[(unsigned int)(v16 + 1)] = (*p_m_pColorPointer)[(unsigned int)(v18 + 1)];
(*p_m_pColorPointer)[(unsigned int)(v16 + 2)] = (*p_m_pColorPointer)[(unsigned int)(v18 + 2)];
(*p_m_pColorPointer)[(unsigned int)(v16 + 4)] = (*p_m_pColorPointer)[(unsigned int)(v18 + 4)];
(*p_m_pColorPointer)[(unsigned int)(v16 + 5)] = (*p_m_pColorPointer)[(unsigned int)(v18 + 5)];
(*p_m_pColorPointer)[(unsigned int)(v16 + 6)] = (*p_m_pColorPointer)[(unsigned int)(v18 + 6)];
}
else
{
LODWORD(v16) = 8 * v12;
}
if ( this->m_bDontOpacityFade )
LOBYTE(v3) = -1;
else
v3 = (struct cocos2d::CCPoint *)(unsigned int)(int)(float)(this->m_pPointState[v12] * 255.0);
(*p_m_pColorPointer)[(unsigned int)(v16 + 3)] = (unsigned __int8)v3;
(*p_m_pColorPointer)[(unsigned int)(v16 + 7)] = (unsigned __int8)v3;
}
else
{
++v6;
p_m_pColorPointer = &this->m_pColorPointer;
}
m_uNuPoints = this->m_uNuPoints;
++v7;
}
while ( v7 < m_uNuPoints );
}
v19 = m_uNuPoints - v6;
this->m_uNuPoints = v19;
if ( v19 >= this->m_uMaxPoints || !this->m_bStroke )
{
v27 = v19;
goto LABEL_36;
}
if ( v19 )
{
v20 = (float *)cocos2d::cc_timeval::operator=(&v61, &this->m_tPositionR);
v21 = (float *)cocos2d::cc_timeval::operator=(&v62, &this->m_pPointVertexes[this->m_uNuPoints - 1]);
v22 = cocos2d::CCSize::operator-(v21, &v63, v20);
v23 = v22[1];
v24 = *v22;
v25 = this->m_uNuPoints;
v26 = this->m_fMinSeg > (float)((float)(v24 * v24) + (float)(v23 * v23));
if ( v25 == 1 )
{
LOBYTE(v3) = 0;
v27 = 1;
}
else
{
v28 = (float *)cocos2d::cc_timeval::operator=(&v61, &this->m_tPositionR);
v29 = (float *)cocos2d::cc_timeval::operator=(&v62, &this->m_pPointVertexes[this->m_uNuPoints - 2]);
v30 = cocos2d::CCSize::operator-(v29, &v63, v28);
v31 = v30[1];
v32 = *v30;
v25 = this->m_uNuPoints;
v27 = v25;
a3 = (float)(v32 * v32) + (float)(v31 * v31);
LOBYTE(v3) = (float)(this->m_fMinSeg + this->m_fMinSeg) > a3;
}
if ( v26 || (_BYTE)v3 )
goto LABEL_36;
if ( v25
&& this->m_fMaxSeg != 0.0
&& cocos2d::CCPoint::getDistance(&this->m_pPointVertexes[v25 - 1], &this->m_tPositionR) > this->m_fMaxSeg )
{
v33 = 0;
if ( this->m_uNuPoints )
{
v34 = 0;
do
{
cocos2d::CCSize::operator=(&this->m_pPointVertexes[v33], &this->m_tPositionR);
++v34;
++v33;
this->m_pPointState[v34 - 1] = 0.0;
}
while ( v33 < this->m_uNuPoints );
}
m_pPointVertexes = this->m_pPointVertexes;
this->m_uNuPoints = 1;
cocos2d::CCSize::operator=(m_pPointVertexes, &this->m_tPositionR);
*this->m_pPointState = 1.0;
}
}
cocos2d::CCSize::operator=(&this->m_pPointVertexes[this->m_uNuPoints], &this->m_tPositionR);
this->m_pPointState[this->m_uNuPoints] = 1.0;
m_pColorPointer = this->m_pColorPointer;
v37 = 8 * this->m_uNuPoints;
*(_WORD *)&m_pColorPointer[v37] = *(_WORD *)&this->_displayedColor.r;
m_pColorPointer[v37 + 2] = this->_displayedColor.b;
v38 = this->m_pColorPointer;
*(_WORD *)&v38[v37 + 4] = *(_WORD *)&this->_displayedColor.r;
v38[v37 + 6] = this->_displayedColor.b;
this->m_pColorPointer[(unsigned int)(v37 + 3)] = -1;
this->m_pColorPointer[(unsigned int)(v37 + 7)] = -1;
v39 = (struct cocos2d::_ccVertex2F *)this->m_uNuPoints;
if ( (_DWORD)v39 && this->m_bFastMode )
{
v40 = (cocos2d *)this->m_pPointVertexes;
if ( (unsigned int)v39 <= 1 )
cocos2d::ccVertexLineToPolygon(v40, v3, a3, nullptr, COERCE_FLOAT(2), v60);
else
cocos2d::ccVertexLineToPolygon(v40, v3, a3, v39, COERCE_FLOAT(1), v60);
}
v27 = this->m_uNuPoints + 1;
this->m_uNuPoints = v27;
LABEL_36:
if ( !this->m_bFastMode )
{
cocos2d::ccVertexLineToPolygon((cocos2d *)this->m_pPointVertexes, v3, a3, nullptr, *(float *)&v27, v60);
v27 = this->m_uNuPoints;
}
m_bRepeatMode = this->m_bRepeatMode;
if ( m_bRepeatMode && v6 )
this->m_fRepeatTime = (float)v6 + this->m_fRepeatTime;
this->m_idk = 0;
if ( v27 )
{
if ( this->m_uPreviousNuPoints == v27 )
{
if ( !m_bRepeatMode )
return;
}
else if ( !m_bRepeatMode )
{
v51 = 0;
v52 = 1.0 / (float)v27;
do
{
v53 = 2 * v51;
v54 = v51;
v55 = (unsigned int)(v53 + 1);
++v51;
v56 = (float)v54;
m_pTexCoords = this->m_pTexCoords;
m_pTexCoords[v53].u = 0.0;
v58 = v56 * v52;
m_pTexCoords[v53].v = v58;
v59 = this->m_pTexCoords;
v59[v55].u = 1.0;
v59[v55].v = v58;
v50 = this->m_uNuPoints;
}
while ( v51 < v50 );
goto LABEL_51;
}
v42 = 0;
do
{
v43 = 2 * v42;
v44 = v42;
v45 = (unsigned int)(v43 + 1);
++v42;
v46 = (float)v44;
v47 = this->m_pTexCoords;
v48 = (float)(v46 + this->m_fRepeatTime) * this->m_fRepeatSpeed;
v47[v43].u = 0.0;
v47[v43].v = v48;
v49 = this->m_pTexCoords;
v49[v45].u = 1.0;
v49[v45].v = v48;
v50 = this->m_uNuPoints;
}
while ( v42 < v50 );
LABEL_51:
this->m_uPreviousNuPoints = v50;
}
}