//
// cocos2d::CCTMXMapInfo::textHandler from 0x1004ccc80 to 0x1004ccef1 (625 bytes)
//
// 2 xrefs:
// > sub_1004CCF30 @ 0x1004ccf39
// > ??> @ 0x100b5c778
//
// This function is hookable on this platform (idp: pc, 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 12:31:11 +0000
//
void __fastcall cocos2d::CCTMXMapInfo::textHandler(__int64 a1, __int64 a2, const char *a3, int a4)
{
size_t v4; // r14
size_t v6; // rax
std::string::size_type v7; // r15
char *data; // r13
size_t v9; // rbx
unsigned __int128 v10; // kr00_16
std::string::value_type *v11; // r13
const char *v12; // r14
size_t v13; // rbx
size_t v14; // rax
std::string::size_type v15; // r15
char *v16; // r12
unsigned int v17; // edx
const std::string::value_type *v18; // rsi
std::string::size_type v19; // rdx
size_t v20; // rbx
const std::string::value_type *v21; // rsi
std::string::value_type __s[8]; // [rsp+18h] [rbp-58h] BYREF
size_t v23; // [rsp+20h] [rbp-50h]
void *v24; // [rsp+28h] [rbp-48h]
std::string __dst[2]; // [rsp+30h] [rbp-40h] BYREF
LODWORD(v4) = a4;
v6 = strlen(a3);
if ( v6 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v7 = v6;
if ( v6 >= 0x17 )
{
v9 = 26;
if ( (v6 | 7) != 0x17 )
v9 = (v6 | 7) + 1;
data = (char *)operator new(v9);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v9 + 1;
__dst[0].__r_.__value_.__l.__size_ = v7;
goto LABEL_8;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v6);
data = __dst[0].__r_.__value_.__s.__data_;
if ( v6 )
LABEL_8:
memcpy(data, a3, v7);
data[v7] = 0;
v4 = (int)v4;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v10 = *(_OWORD *)&__dst[0].__r_.__value_.__r.__words[1];
else
v10 = __PAIR128__(
(std::string *)((char *)&__dst[0].__r_.__value_.__l.0 + 1),
*(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1);
if ( (unsigned __int64)v10 < (int)v4 )
v4 = v10;
if ( v4 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( v4 >= 0x17 )
{
v13 = 26;
if ( (v4 | 7) != 0x17 )
v13 = (v4 | 7) + 1;
v11 = (std::string::value_type *)operator new(v13);
v24 = v11;
*(_QWORD *)__s = v13 | 1;
v23 = v4;
}
else
{
__s[0] = 2 * v4;
v11 = &__s[1];
if ( !v4 )
{
__s[1] = 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_19;
goto LABEL_18;
}
}
memmove(v11, *((const void **)&v10 + 1), v4);
v11[v4] = 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
LABEL_18:
operator delete(__dst[0].__r_.__value_.__l.__data_);
LABEL_19:
if ( *(_BYTE *)(a1 + 124) != 1 )
goto LABEL_43;
if ( (*(_BYTE *)(a1 + 184) & 1) != 0 )
v12 = *(const char **)(a1 + 200);
else
v12 = (const char *)(a1 + 185);
v14 = strlen(v12);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v15 = v14;
if ( v14 >= 0x17 )
{
v20 = 26;
if ( (v14 | 7) != 0x17 )
v20 = (v14 | 7) + 1;
v16 = (char *)operator new(v20);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v16;
__dst[0].__r_.__value_.__r.__words[0] = v20 | 1;
__dst[0].__r_.__value_.__l.__size_ = v15;
LABEL_36:
memmove(v16, v12, v15);
v16[v15] = 0;
v17 = (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 * v14);
v16 = __dst[0].__r_.__value_.__s.__data_;
if ( v14 )
goto LABEL_36;
__dst[0].__r_.__value_.__s.__data_[0] = 0;
v17 = (unsigned __int8)__s[0];
if ( (__s[0] & 1) != 0 )
{
LABEL_32:
v18 = (const std::string::value_type *)v24;
v19 = v23;
goto LABEL_38;
}
LABEL_37:
v19 = v17 >> 1;
v18 = &__s[1];
LABEL_38:
std::string::append(__dst, v18, v19);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v21 = __dst[0].__r_.__value_.__l.__data_;
else
v21 = __dst[0].__r_.__value_.__s.__data_;
std::string::assign((std::string *)(a1 + 184), v21);
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(v24);
}