1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Convert plUUID and its cascade of dependencies to plString

This commit is contained in:
2012-01-25 21:17:35 -08:00
parent acd47d9f91
commit a1852ad385
16 changed files with 135 additions and 111 deletions

View File

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "plClientGuid.h"
#include "hsStream.h"
#include <sstream>
#include "plNetCommon.h"
#include "pnMessage/plMessage.h"
#include "plSockets/plNet.h"
@ -105,10 +104,10 @@ void plClientGuid::SetTempPlayerID(UInt32 id)
}
}
void plClientGuid::SetPlayerName( const char * v )
void plClientGuid::SetPlayerName( const plString & v )
{
fPlayerName = v?v:"";
if ( fPlayerName.size() )
fPlayerName = v;
if ( !fPlayerName.IsEmpty() )
fFlags|=kPlayerName;
else
fFlags&=~kPlayerName;
@ -155,10 +154,10 @@ void plClientGuid::SetReserved(bool b)
fFlags |= kReserved;
}
void plClientGuid::SetClientKey(const std::string& key)
void plClientGuid::SetClientKey(const plString& key)
{
fClientKey = key;
if ( fClientKey.size() )
if ( !fClientKey.IsEmpty() )
fFlags|=kClientKey;
else
fFlags&=~kClientKey;
@ -171,13 +170,13 @@ const char * plClientGuid::GetSrcAddrStr() const
return foo;
}
std::string plClientGuid::AsStdString() const
plString plClientGuid::AsString() const
{
#define kComma ","
#define kEmpty ""
const char * spacer = kEmpty;
std::stringstream ss;
plStringStream ss;
ss << "[";
@ -222,7 +221,7 @@ std::string plClientGuid::AsStdString() const
}
if (IsFlagSet(kAccountUUID))
{
ss << spacer << "plUUID:" << fAccountUUID.AsStdString();
ss << spacer << "plUUID:" << fAccountUUID.AsString();
spacer = kComma;
}
if ( IsFlagSet(kReserved))
@ -237,19 +236,19 @@ std::string plClientGuid::AsStdString() const
}
ss << "]";
return ss.str().c_str();
return ss.GetString();
}
std::string plClientGuid::AsLogString() const
plString plClientGuid::AsLogString() const
{
#define kSemicolon ";"
const char* spacer = kSemicolon;
std::stringstream ss;
plStringStream ss;
if (IsFlagSet(kAccountUUID))
{
ss << "AcctUUID=" << fAccountUUID.AsStdString();
ss << "AcctUUID=" << fAccountUUID.AsString();
ss << spacer;
}
if (IsFlagSet(kPlayerID))
@ -298,7 +297,7 @@ std::string plClientGuid::AsLogString() const
ss << spacer;
}
return ss.str().c_str();
return ss.GetString();
}
void plClientGuid::Read(hsStream * s, hsResMgr* mgr)

View File

@ -55,11 +55,11 @@ class plClientGuid : public plCreatable
UInt8 fCCRLevel;
bool fProtectedLogin;
UInt8 fBuildType; // see plNetCommon.h
std::string fPlayerName;
plString fPlayerName;
UInt32 fSrcAddr;
UInt16 fSrcPort;
bool fReserved;
std::string fClientKey;
plString fClientKey;
public:
enum Flags // 16 bits.
@ -80,8 +80,8 @@ public:
CLASSNAME_REGISTER( plClientGuid );
GETINTERFACE_ANY( plClientGuid, plCreatable );
std::string AsStdString() const;
std::string AsLogString() const;
plString AsString() const;
plString AsLogString() const;
void Clear();
void CopyFrom(const plClientGuid * other);
void UpdateFrom(const plClientGuid * other);
@ -94,7 +94,7 @@ public:
bool HasAccountUUID() const { return (fFlags&kAccountUUID&&!fAccountUUID.IsNull())?true:false;}
bool HasPlayerID() const { return (fFlags&kPlayerID&&fPlayerID>0)?true:false;}
bool HasPlayerName() const { return (fFlags&kPlayerName&&fPlayerName.size())?true:false; }
bool HasPlayerName() const { return (fFlags&kPlayerName&&!fPlayerName.IsEmpty())?true:false; }
bool HasCCRLevel() const { return (fFlags&kCCRLevel)?true:false;}
bool HasProtectedLogin() const { return (fFlags&kProtectedLogin)?true:false;}
bool HasBuildType() const { return (fFlags&kBuildType)?true:false;}
@ -105,7 +105,7 @@ public:
const plUUID * GetAccountUUID() const { return &fAccountUUID;}
UInt32 GetPlayerID() const { return fPlayerID;}
const char * GetPlayerName() const { return fPlayerName.c_str(); }
const plString & GetPlayerName() const { return fPlayerName; }
UInt8 GetCCRLevel() const { return fCCRLevel; }
bool GetProtectedLogin() const { return ( fProtectedLogin!=0 ); }
UInt8 GetFlags() const { return (UInt8)fFlags;}
@ -114,12 +114,12 @@ public:
const char * GetSrcAddrStr() const;
UInt16 GetSrcPort() const { return fSrcPort; }
bool IsReserved() const { return fReserved!=0; }
const std::string& GetClientKey() const { return fClientKey; }
const plString& GetClientKey() const { return fClientKey; }
void SetAccountUUID(const plUUID * v);
void SetAccountUUID(const plUUID & v);
void SetPlayerID(UInt32 v);
void SetPlayerName( const char * v );
void SetPlayerName( const plString & v );
void SetCCRLevel(UInt8 v);
void SetProtectedLogin(bool v);
void SetBuildType(UInt8 v);
@ -127,7 +127,7 @@ public:
void SetSrcAddrFromStr( const char * s );
void SetSrcPort( UInt16 v );
void SetReserved( bool v );
void SetClientKey( const std::string& key );
void SetClientKey( const plString& key );
// When a client hasn't selected a player yet,
// we need to uniquely identify them in the lobby server.
// We do this by stuffing a temp value into the fPlayerID

View File

@ -47,8 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetCommon.h"
#include "plVault/plVault.h"
#include <sstream>
#define SAFE(s) ((s)?(s):"(nil)")
#define kComma ","
#define kEmpty ""
@ -177,11 +175,11 @@ void plAgeInfoStruct::CopyFrom(const NetAgeInfo & info) {
}
//============================================================================
std::string plAgeInfoStruct::AsStdString() const
plString plAgeInfoStruct::AsString() const
{
const char * spacer = kEmpty;
std::stringstream ss;
plStringStream ss;
ss << "[";
@ -236,7 +234,7 @@ std::string plAgeInfoStruct::AsStdString() const
}
ss << "]";
return ss.str().c_str();
return ss.GetString();
}
@ -495,11 +493,11 @@ void plAgeLinkStruct::Clear()
fAmCCR = false;
}
std::string plAgeLinkStruct::AsStdString() const
plString plAgeLinkStruct::AsString() const
{
const char * spacer = kEmpty;
std::stringstream ss;
plStringStream ss;
ss << "[";
@ -507,7 +505,7 @@ std::string plAgeLinkStruct::AsStdString() const
{
ss << spacer
<< "Nfo:"
<< fAgeInfo.AsStdString();
<< fAgeInfo.AsString();
spacer = kComma;
}
if (HasLinkingRules())
@ -533,7 +531,7 @@ std::string plAgeLinkStruct::AsStdString() const
}
ss << "]";
return ss.str().c_str();
return ss.GetString();
}
@ -615,11 +613,11 @@ void plNetServerSessionInfo::CopyFrom(const plNetServerSessionInfo * other)
}
}
std::string plNetServerSessionInfo::AsStdString() const
plString plNetServerSessionInfo::AsString() const
{
const char * spacer = kEmpty;
std::stringstream ss;
plStringStream ss;
ss << "[";
@ -656,19 +654,19 @@ std::string plNetServerSessionInfo::AsStdString() const
}
ss << "]";
return ss.str().c_str();
return ss.GetString();
}
std::string plNetServerSessionInfo::AsLogString() const
plString plNetServerSessionInfo::AsLogString() const
{
const char* spacer = kSemicolon;
std::stringstream ss;
std::string typeName = "";
plStringStream ss;
plString typeName = _TEMP_CONVERT_FROM_LITERAL("");
if (HasServerType())
{
typeName = plNetServerConstants::GetServerTypeStr(fServerType);
typeName = _TEMP_CONVERT_FROM_LITERAL(plNetServerConstants::GetServerTypeStr(fServerType));
}
if (HasServerName())
@ -699,7 +697,7 @@ std::string plNetServerSessionInfo::AsLogString() const
ss << spacer;
}
return ss.str().c_str();
return ss.GetString();
}
bool plNetServerSessionInfo::IsEqualTo(const plNetServerSessionInfo * other) const

View File

@ -147,7 +147,7 @@ public:
const char * GetDisplayName() const;
std::string AsStdString() const;
plString AsString() const;
};
////////////////////////////////////////////////////////////////////
@ -220,7 +220,7 @@ public:
void Read( hsStream * s, hsResMgr* );
void Write( hsStream * s, hsResMgr* );
std::string AsStdString() const;
plString AsString() const;
};
@ -291,8 +291,8 @@ public:
void Clear();
void CopyFrom(const plNetServerSessionInfo * other);
bool IsEqualTo(const plNetServerSessionInfo * other) const;
virtual std::string AsStdString() const;
virtual std::string AsLogString() const;
virtual plString AsString() const;
virtual plString AsLogString() const;
void Read(hsStream* s, hsResMgr* mgr=nil);
void Write(hsStream* s, hsResMgr* mgr=nil);