//
// cocos2d::CCTextFieldTTF::setString from 0x1001cb9d0 to 0x1001cbb6c (412 bytes)
//
// 2 xrefs:
// > sub_1001CBB9C @ 0x1001cbba0
// > ??> @ 0x1007ba060
//
// 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::CCTextFieldTTF::setString(cocos2d::CCTextFieldTTF *a1, const char *a2)
{
std::string *m_pInputText; // x21
std::string *v5; // x21
std::string *v6; // x8
std::size_t size; // x21
std::string *v8; // x0
std::string *v9; // x9
const char *m_pPlaceHolder; // x1
std::string *capacitym1; // x9
std::uint8_t sizex2; // w10
int v13; // w8
std::array *p_shortStorage; // x9
int v15; // t1
cocos2d::CCTextFieldDelegate *m_pDelegate; // x0
std::string v17; // [xsp+8h] [xbp-38h] BYREF
memset(&v17, 0, sizeof(v17));
m_pInputText = a1->m_pInputText;
if ( m_pInputText )
{
if ( m_pInputText->m_data.m_short.shortStorage.__elems_[22] < 0 )
operator delete((void *)m_pInputText->m_data.m_long.capacitym1);
operator delete(m_pInputText);
a1->m_pInputText = nullptr;
}
if ( !a2 )
{
v8 = (std::string *)operator new(0x18u);
v8->m_data.m_long.capacitym1 = 0;
v8->m_data.m_long.size = 0;
v8->m_data.m_long.longStorage = nullptr;
a1->m_pInputText = v8;
goto LABEL_13;
}
v5 = (std::string *)operator new(0x18u);
sub_100009900(v5, (char *)a2);
a1->m_pInputText = v5;
std::string::operator=(&v17, (const std::string *)v5);
if ( !a1->m_bSecureTextEntry )
goto LABEL_13;
std::string::assign(&v17, "");
v6 = a1->m_pInputText;
size = v6->m_data.m_short.shortStorage.__elems_[22];
if ( (size & 0x8000000000000000LL) != 0 )
{
size = v6->m_data.m_long.size;
if ( !(_DWORD)size )
goto LABEL_13;
}
else if ( !v6->m_data.m_short.shortStorage.__elems_[22] )
{
goto LABEL_13;
}
do
{
std::string::append(&v17, byte_10084BFF8);
LODWORD(size) = size - 1;
}
while ( (_DWORD)size );
LABEL_13:
v9 = a1->m_pInputText;
if ( (v9->m_data.m_short.shortStorage.__elems_[22] & 0x8000000000000000LL) != 0 )
{
if ( v9->m_data.m_long.size )
{
LABEL_15:
if ( (v17.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
m_pPlaceHolder = (const char *)&v17;
else
m_pPlaceHolder = (const char *)v17.__r_.__value_.__r.__words[0];
goto LABEL_21;
}
}
else if ( v9->m_data.m_short.shortStorage.__elems_[22] )
{
goto LABEL_15;
}
m_pPlaceHolder = (const char *)a1->m_pPlaceHolder;
if ( m_pPlaceHolder[23] < 0 )
m_pPlaceHolder = *(const char **)m_pPlaceHolder;
LABEL_21:
cocos2d::CCLabelTTF::setString(a1, m_pPlaceHolder);
capacitym1 = a1->m_pInputText;
if ( capacitym1->m_data.m_short.shortStorage.__elems_[22] < 0 )
capacitym1 = (std::string *)capacitym1->m_data.m_long.capacitym1;
sizex2 = capacitym1->m_data.m_short.sizex2;
if ( capacitym1->m_data.m_short.sizex2 )
{
v13 = 0;
p_shortStorage = &capacitym1->m_data.m_short.shortStorage;
do
{
if ( (sizex2 & 0xC0) != 0x80 )
++v13;
v15 = (unsigned __int8)p_shortStorage->__elems_[0];
p_shortStorage = (std::array *)((char *)p_shortStorage + 1);
sizex2 = v15;
}
while ( v15 );
}
else
{
v13 = 0;
}
a1->m_nCharCount = v13;
m_pDelegate = a1->m_pDelegate;
if ( m_pDelegate )
((void (__fastcall *)(cocos2d::CCTextFieldDelegate *))m_pDelegate->textChanged)(m_pDelegate);
if ( SHIBYTE(v17.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v17.__r_.__value_.__l.__data_);
}