//
// cocos2d::CCTMXMapInfo::textHandler from 0x1004d1110 to 0x1004d1381 (625 bytes)
//
// 2 xrefs:
// > sub_1004D13C0 @ 0x1004d13c9
// > ??> @ 0x100951510
//
// 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::CCTMXMapInfo::textHandler(cocos2d::CCTMXMapInfo *a1, void *a2, const char *a3, int a4)
{
double v4; // xmm0_8
size_t v5; // r14
size_t v7; // rax
std::string::size_type v8; // r15
char *data; // r13
size_t v10; // rbx
unsigned __int128 v11; // kr00_16
std::string::value_type *v12; // r13
const char *v13; // r14
size_t v14; // rbx
size_t v15; // rax
std::string::size_type v16; // r15
char *v17; // r12
unsigned int v18; // edx
const std::string::value_type *v19; // rsi
std::string::size_type v20; // rdx
size_t v21; // rbx
const std::string::value_type *v22; // rsi
std::string::value_type __s[8]; // [rsp+18h] [rbp-58h] BYREF
size_t v24; // [rsp+20h] [rbp-50h]
void *v25; // [rsp+28h] [rbp-48h]
std::string __dst[2]; // [rsp+30h] [rbp-40h] BYREF
LODWORD(v5) = a4;
v7 = strlen(a3);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v4);
v8 = v7;
if ( v7 >= 0x17 )
{
v10 = 26;
if ( (v7 | 7) != 0x17 )
v10 = (v7 | 7) + 1;
data = (char *)operator new(v10);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v10 + 1;
__dst[0].__r_.__value_.__l.__size_ = v8;
goto LABEL_8;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v7);
data = __dst[0].__r_.__value_.__s.__data_;
if ( v7 )
LABEL_8:
memcpy(data, a3, v8);
data[v8] = 0;
v5 = (int)v5;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v11 = *(_OWORD *)&__dst[0].__r_.__value_.__r.__words[1];
else
v11 = __PAIR128__(
(std::string *)((char *)&__dst[0].__r_.__value_.__l.0 + 1),
*(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1);
if ( (unsigned __int64)v11 < (int)v5 )
v5 = v11;
if ( v5 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v4);
if ( v5 >= 0x17 )
{
v14 = 26;
if ( (v5 | 7) != 0x17 )
v14 = (v5 | 7) + 1;
v12 = (std::string::value_type *)operator new(v14);
v25 = v12;
*(_QWORD *)__s = v14 | 1;
v24 = v5;
}
else
{
__s[0] = 2 * v5;
v12 = &__s[1];
if ( !v5 )
{
__s[1] = 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_19;
goto LABEL_18;
}
}
memmove(v12, *((const void **)&v11 + 1), v5);
v12[v5] = 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
LABEL_18:
operator delete(__dst[0].__r_.__value_.__l.__data_);
LABEL_19:
if ( BYTE4(a1[1].cocos2d::CCSAXDelegator::__vftable) != 1 )
goto LABEL_43;
if ( ((__int64)a1[2].cocos2d::CCSAXDelegator::__vftable & 1) != 0 )
v13 = *(const char **)&a1[3].m_uID;
else
v13 = (char *)&a1[2].cocos2d::CCSAXDelegator::__vftable + 1;
v15 = strlen(v13);
if ( v15 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v4);
v16 = v15;
if ( v15 >= 0x17 )
{
v21 = 26;
if ( (v15 | 7) != 0x17 )
v21 = (v15 | 7) + 1;
v17 = (char *)operator new(v21);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v17;
__dst[0].__r_.__value_.__r.__words[0] = v21 | 1;
__dst[0].__r_.__value_.__l.__size_ = v16;
LABEL_36:
memmove(v17, v13, v16);
v17[v16] = 0;
v18 = (unsigned __int8)__s[0];
if ( (__s[0] & 1) != 0 )
goto LABEL_32;
goto LABEL_37;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v15);
v17 = __dst[0].__r_.__value_.__s.__data_;
if ( v15 )
goto LABEL_36;
__dst[0].__r_.__value_.__s.__data_[0] = 0;
v18 = (unsigned __int8)__s[0];
if ( (__s[0] & 1) != 0 )
{
LABEL_32:
v19 = (const std::string::value_type *)v25;
v20 = v24;
goto LABEL_38;
}
LABEL_37:
v20 = v18 >> 1;
v19 = &__s[1];
LABEL_38:
std::string::append(__dst, v19, v20);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v22 = __dst[0].__r_.__value_.__l.__data_;
else
v22 = __dst[0].__r_.__value_.__s.__data_;
std::string::assign((std::string *)&a1[2].cocos2d::CCSAXDelegator, v22);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
LABEL_43:
if ( (__s[0] & 1) != 0 )
operator delete(v25);
}