Help Reading 16+ character names

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Hi, I have a problem with understanding how it should be done because there are only 16 bytes at szPlayerName. Is it somehow coded into 2 chars per byte or is there any other way?
Code:
struct stRemotePlayer
{
	stRemotePlayerData	*pPlayerData; //0
	int					iIsNPC; //4
	void				*pVTBL_txtHandler; //8
	union //12
	{
		char			szPlayerName[16];
		char			*pszPlayerName;
	};
	int					iNameLen; //28
	int					iNameAllocated; //32
	int					iScore; //36
	int					iPing; //40
};
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Hmm I tried like this but all I got few weird characters
Code:
if(iNameLen > 15)
{
	for(int i=0;i<iNameLen;i++)
	{
		string += *(char*)(*(char*)(*pRP + 12) + i);
	}
}
else
{
	for(int i=0;i<iNameLen;i++)
	{
		string += *(char*)(*pRP + 12 + i);
	}
}

edit: changed (*(char*) into (*(DWORD*)... thanks
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
Umm, that looks ugly, why don't you use the structs instead of hard coded offsets?
It would be simpler..
Code:
char *name = (pRP->iNameLen <= 15 ? pRP->szPlayerName : pRP->pszPlayerName);
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
I tried but I didn't know how to initialize them properly and "left it for later"
 
Top