|
|
@ -291,18 +291,18 @@ struct PlayerCreateRequestTrans : NetAuthTrans { |
|
|
|
void * m_param; |
|
|
|
void * m_param; |
|
|
|
|
|
|
|
|
|
|
|
// send
|
|
|
|
// send
|
|
|
|
wchar_t m_playerName[kMaxPlayerNameLength]; |
|
|
|
plString m_playerName; |
|
|
|
wchar_t m_avatarShape[MAX_PATH]; |
|
|
|
plString m_avatarShape; |
|
|
|
wchar_t m_friendInvite[MAX_PATH]; |
|
|
|
plString m_friendInvite; |
|
|
|
|
|
|
|
|
|
|
|
// recv
|
|
|
|
// recv
|
|
|
|
NetCliAuthPlayerInfo m_playerInfo; |
|
|
|
NetCliAuthPlayerInfo m_playerInfo; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlayerCreateRequestTrans ( |
|
|
|
PlayerCreateRequestTrans ( |
|
|
|
const wchar_t playerName[], |
|
|
|
const plString& playerName, |
|
|
|
const wchar_t avatarShape[], |
|
|
|
const plString& avatarShape, |
|
|
|
const wchar_t friendInvite[], |
|
|
|
const plString& friendInvite, |
|
|
|
FNetCliAuthPlayerCreateRequestCallback callback, |
|
|
|
FNetCliAuthPlayerCreateRequestCallback callback, |
|
|
|
void * param |
|
|
|
void * param |
|
|
|
); |
|
|
|
); |
|
|
@ -1231,42 +1231,28 @@ static FNotifyNewBuildHandler s_notifyNewBuildHandler; |
|
|
|
***/ |
|
|
|
***/ |
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
static inline bool ICharIsSpace (unsigned ch) { |
|
|
|
static ENetError FixupPlayerName (plString& name) { |
|
|
|
return ch == ' '; |
|
|
|
ASSERT(!name.IsEmpty()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
// Trim leading and trailing whitespace
|
|
|
|
static ENetError FixupPlayerName (wchar_t * name) { |
|
|
|
name = name.Trim(" \t\n\r"); |
|
|
|
ASSERT(name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Trim leading and trailing whitespace and convert
|
|
|
|
|
|
|
|
// multiple internal spaces into only one space
|
|
|
|
|
|
|
|
unsigned nonSpaceChars = 0; |
|
|
|
|
|
|
|
wchar_t *dst = name; |
|
|
|
|
|
|
|
for (wchar_t *src = name; *src; ) { |
|
|
|
|
|
|
|
// Skip whitespace
|
|
|
|
|
|
|
|
while (*src && ICharIsSpace(*src)) |
|
|
|
|
|
|
|
src++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the block skipped was not at the beginning
|
|
|
|
|
|
|
|
// of the string then add one space character
|
|
|
|
|
|
|
|
if (*src && (dst != name)) |
|
|
|
|
|
|
|
*dst++ = ' '; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Copy characters until end-of-string or next whitespace
|
|
|
|
|
|
|
|
while (*src && !ICharIsSpace(*src)) { |
|
|
|
|
|
|
|
++nonSpaceChars; |
|
|
|
|
|
|
|
*dst++ = *src++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ensure destination string is terminated
|
|
|
|
// Convert remaining internal whitespace to a single space.
|
|
|
|
*dst = 0; |
|
|
|
// Kind of hacky, but meh.
|
|
|
|
|
|
|
|
std::vector<plString> things = name.Tokenize(" \t\n\r"); |
|
|
|
|
|
|
|
|
|
|
|
// Check for minimum name length
|
|
|
|
plStringStream ss; |
|
|
|
if (nonSpaceChars < 3) |
|
|
|
for (auto it = things.begin(); it != things.end(); ++it) { |
|
|
|
return kNetErrPlayerNameInvalid; |
|
|
|
ss << *it; |
|
|
|
|
|
|
|
if ((it + 1) != things.end()) |
|
|
|
|
|
|
|
ss << " "; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
name = ss.GetString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Now, check to see if we have the appropriate length
|
|
|
|
|
|
|
|
// We could count the characters, but lazy...
|
|
|
|
|
|
|
|
if (name.Replace(" ", "").GetSize() < 3) |
|
|
|
|
|
|
|
return kNetErrPlayerNameInvalid; |
|
|
|
return kNetSuccess; |
|
|
|
return kNetSuccess; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2938,21 +2924,18 @@ bool AccountCreateFromKeyRequestTrans::Recv ( |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
PlayerCreateRequestTrans::PlayerCreateRequestTrans ( |
|
|
|
PlayerCreateRequestTrans::PlayerCreateRequestTrans ( |
|
|
|
const wchar_t playerName[], |
|
|
|
const plString& playerName, |
|
|
|
const wchar_t avatarShape[], |
|
|
|
const plString& avatarShape, |
|
|
|
const wchar_t friendInvite[], |
|
|
|
const plString& friendInvite, |
|
|
|
FNetCliAuthPlayerCreateRequestCallback callback, |
|
|
|
FNetCliAuthPlayerCreateRequestCallback callback, |
|
|
|
void * param |
|
|
|
void * param |
|
|
|
) : NetAuthTrans(kPlayerCreateRequestTrans) |
|
|
|
) : NetAuthTrans(kPlayerCreateRequestTrans) |
|
|
|
|
|
|
|
, m_playerName(playerName) |
|
|
|
|
|
|
|
, m_avatarShape(avatarShape) |
|
|
|
|
|
|
|
, m_friendInvite(friendInvite) |
|
|
|
, m_callback(callback) |
|
|
|
, m_callback(callback) |
|
|
|
, m_param(param) |
|
|
|
, m_param(param) |
|
|
|
{ |
|
|
|
{ |
|
|
|
StrCopy(m_playerName, playerName, arrsize(m_playerName)); |
|
|
|
|
|
|
|
StrCopy(m_avatarShape, avatarShape, arrsize(m_avatarShape)); |
|
|
|
|
|
|
|
if (friendInvite) |
|
|
|
|
|
|
|
StrCopy(m_friendInvite, friendInvite, arrsize(m_friendInvite)); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
m_friendInvite[0] = 0; |
|
|
|
|
|
|
|
memset(&m_playerInfo, 0, sizeof(m_playerInfo)); |
|
|
|
memset(&m_playerInfo, 0, sizeof(m_playerInfo)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2961,12 +2944,16 @@ bool PlayerCreateRequestTrans::Send () { |
|
|
|
if (!AcquireConn()) |
|
|
|
if (!AcquireConn()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plStringBuffer<uint16_t> playerName = m_playerName.ToUtf16(); |
|
|
|
|
|
|
|
plStringBuffer<uint16_t> avatarShape = m_avatarShape.ToUtf16(); |
|
|
|
|
|
|
|
plStringBuffer<uint16_t> friendInvite = m_friendInvite.ToUtf16(); |
|
|
|
|
|
|
|
|
|
|
|
const uintptr_t msg[] = { |
|
|
|
const uintptr_t msg[] = { |
|
|
|
kCli2Auth_PlayerCreateRequest, |
|
|
|
kCli2Auth_PlayerCreateRequest, |
|
|
|
m_transId, |
|
|
|
m_transId, |
|
|
|
(uintptr_t) m_playerName, |
|
|
|
(uintptr_t) playerName.GetData(), |
|
|
|
(uintptr_t) m_avatarShape, |
|
|
|
(uintptr_t) avatarShape.GetData(), |
|
|
|
(uintptr_t) m_friendInvite, |
|
|
|
(uintptr_t) friendInvite.GetData(), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
m_conn->Send(msg, arrsize(msg)); |
|
|
|
m_conn->Send(msg, arrsize(msg)); |
|
|
@ -5322,14 +5309,13 @@ void NetCliAuthAccountCreateFromKeyRequest ( |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
void NetCliAuthPlayerCreateRequest ( |
|
|
|
void NetCliAuthPlayerCreateRequest ( |
|
|
|
const wchar_t playerName[], |
|
|
|
const plString& playerName, |
|
|
|
const wchar_t avatarShape[], |
|
|
|
const plString& avatarShape, |
|
|
|
const wchar_t friendInvite[], |
|
|
|
const plString& friendInvite, |
|
|
|
FNetCliAuthPlayerCreateRequestCallback callback, |
|
|
|
FNetCliAuthPlayerCreateRequestCallback callback, |
|
|
|
void * param |
|
|
|
void * param |
|
|
|
) { |
|
|
|
) { |
|
|
|
wchar_t name[kMaxPlayerNameLength]; |
|
|
|
plString name = playerName; |
|
|
|
StrCopy(name, playerName, arrsize(name)); |
|
|
|
|
|
|
|
ENetError error = FixupPlayerName(name); |
|
|
|
ENetError error = FixupPlayerName(name); |
|
|
|
if (IS_NET_ERROR(error)) { |
|
|
|
if (IS_NET_ERROR(error)) { |
|
|
|
NetCliAuthPlayerInfo playerInfo; |
|
|
|
NetCliAuthPlayerInfo playerInfo; |
|
|
|