From 274812c057510f3ecc97e1293212f78c2ef2040b Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sat, 15 Dec 2012 21:33:14 -0800 Subject: [PATCH] Remove all uses of GuidToString. --- .../FeatureLib/pfPython/Games/pyGameCli.cpp | 6 ++--- .../pfPython/Games/pyGameMgrMsg.cpp | 10 +++---- .../Plasma/FeatureLib/pfPython/pyAgeVault.h | 2 +- .../FeatureLib/pfPython/pyDniInfoSource.h | 2 +- .../pfPython/pyVaultAgeInfoNode.cpp | 3 ++- .../pfPython/pyVaultMarkerGameNode.cpp | 2 +- .../FeatureLib/pfPython/pyVaultNode.cpp | 2 +- .../pfPython/pyVaultPlayerInfoNode.cpp | 3 ++- .../pfPython/pyVaultPlayerInfoNode.h | 2 +- .../Plasma/NucleusLib/pnUUID/CMakeLists.txt | 6 +++-- Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp | 11 +++----- .../Plasma/NucleusLib/pnUUID/pnUUID_Unix.cpp | 8 ------ .../NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp | 2 +- .../NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp | 26 ------------------- .../Plasma/NucleusLib/pnUtils/pnUtUuid.cpp | 14 ---------- Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h | 4 --- .../plNetClientComm/plNetClientComm.cpp | 11 +++++--- .../PubUtilLib/plVault/plVaultNodeAccess.cpp | 4 +-- 18 files changed, 34 insertions(+), 84 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfPython/Games/pyGameCli.cpp b/Sources/Plasma/FeatureLib/pfPython/Games/pyGameCli.cpp index b810777f..3b5a811d 100644 --- a/Sources/Plasma/FeatureLib/pfPython/Games/pyGameCli.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/Games/pyGameCli.cpp @@ -103,8 +103,8 @@ std::wstring pyGameCli::GameTypeID() const { if (gameClient) { - wchar_t guidStr[256]; - GuidToString(gameClient->GetGameTypeId(), guidStr, arrsize(guidStr)); + wchar_t guidStr[64]; + wcsncpy(guidStr, plUUID(gameClient->GetGameTypeId()).AsString().ToWchar(), 64); return guidStr; } return L""; @@ -182,4 +182,4 @@ PyObject* pyGameCli::UpcastToVarSyncGame() if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_VarSync)) return pyVarSyncGame::New(gameClient); PYTHON_RETURN_NONE; -} \ No newline at end of file +} diff --git a/Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsg.cpp b/Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsg.cpp index 67d2fc81..b328a6a8 100644 --- a/Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsg.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsg.cpp @@ -108,8 +108,8 @@ std::wstring pyGameMgrInviteReceivedMsg::GameTypeID() const if (message) { const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg; - wchar_t buffer[256]; - GuidToString(gmMsg->gameTypeId, buffer, arrsize(buffer)); + wchar_t buffer[64]; + wcsncpy(buffer, plUUID(gmMsg->gameTypeId).AsString().ToWchar(), 64); return buffer; } return L""; @@ -149,8 +149,8 @@ std::wstring pyGameMgrInviteRevokedMsg::GameTypeID() const if (message) { const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg; - wchar_t buffer[256]; - GuidToString(gmMsg->gameTypeId, buffer, arrsize(buffer)); + wchar_t buffer[64]; + wcsncpy(buffer, plUUID(gmMsg->gameTypeId).AsString().ToWchar(), 64); return buffer; } return L""; @@ -164,4 +164,4 @@ unsigned long pyGameMgrInviteRevokedMsg::NewGameID() const return gmMsg->newGameId; } return 0; -} \ No newline at end of file +} diff --git a/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.h b/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.h index d3ad72a9..bce1cdc4 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.h @@ -82,7 +82,7 @@ public: static void AddPlasmaClasses(PyObject *m); - plUUID GetAgeGuid( void ); + plUUID GetAgeGuid(void); PyObject * GetAgeSDL() const; // returns pySDLStateDataRecord void UpdateAgeSDL( pySDLStateDataRecord & pyrec ); diff --git a/Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.h b/Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.h index 614e5605..e143bab0 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.h @@ -74,7 +74,7 @@ public: // name of current age const char * GetAgeName( void ) const; // unique identifier for this age instance - plUUID GetAgeGuid( void ) const; + plUUID GetAgeGuid(void) const; }; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp index 3878522b..f071ada3 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp @@ -234,7 +234,8 @@ const char * pyVaultAgeInfoNode::GetAgeInstanceGuid() const if (fNode) { VaultAgeInfoNode access(fNode); - GuidToString(access.ageInstUuid, fAgeInstGuid, arrsize(fAgeInstGuid)); + + strncpy(fAgeInstGuid, plUUID(access.ageInstUuid).AsString().c_str(), 64); } return fAgeInstGuid; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp index cfe152d0..fab28e10 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp @@ -94,7 +94,7 @@ const char * pyVaultMarkerGameNode::GetGameGuid () const if (fNode) { VaultMarkerGameNode access(fNode); - GuidToString(access.gameGuid, fGameGuid, arrsize(fGameGuid)); + strncpy(fGameGuid, plUUID(access.gameGuid).AsString().c_str(), 64); } return fGameGuid; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp index 20603fef..0a54d312 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp @@ -332,7 +332,7 @@ const char * pyVaultNode::GetCreateAgeGuid( void ) if (fNode) { fCreateAgeGuid = (char*)malloc(64); - GuidToString(fNode->createAgeUuid, fCreateAgeGuid, 64); + strncpy(fCreateAgeGuid, plUUID(fNode->createAgeUuid).AsString().c_str(), 64); } return fCreateAgeGuid; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp index 657eb588..f75dabcb 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp @@ -164,7 +164,8 @@ const char * pyVaultPlayerInfoNode::Player_GetAgeGuid( void ) return ""; VaultPlayerInfoNode playerInfo(fNode); - GuidToString(playerInfo.ageInstUuid, ansiAgeInstUuid, arrsize(ansiAgeInstUuid)); + + strncpy(ansiAgeInstUuid, plUUID(playerInfo.ageInstUuid).AsString().c_str(), 64); return ansiAgeInstUuid; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h index a7c0787c..2415c17f 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h @@ -55,7 +55,7 @@ class pyVaultPlayerInfoNode : public pyVaultNode { mutable char * ansiPlayerName; mutable char * ansiAgeInstName; - mutable char ansiAgeInstUuid[256]; + mutable char ansiAgeInstUuid[64]; protected: // should only be created from C++ side diff --git a/Sources/Plasma/NucleusLib/pnUUID/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnUUID/CMakeLists.txt index 2d9cb98b..9fad6e39 100644 --- a/Sources/Plasma/NucleusLib/pnUUID/CMakeLists.txt +++ b/Sources/Plasma/NucleusLib/pnUUID/CMakeLists.txt @@ -7,10 +7,12 @@ set(pnUUID_SOURCES if(WIN32) set(pnUUID_SOURCES ${pnUUID_SOURCES} pnUUID_Win32.cpp) -else(WIN32) - set(pnUUID_SOURCES ${pnUUID_SOURCES} pnUUID_Unix.cpp) endif(WIN32) +if(UNIX) + set(pnUUID_SOURCES ${pnUUID_SOURCES} pnUUID_Unix.cpp) +endif(UNIX) + set(pnUUID_HEADERS pnUUID.h ) diff --git a/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp b/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp index e9609ed4..ca27ff5a 100644 --- a/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp +++ b/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp @@ -47,12 +47,7 @@ plUUID::plUUID() Clear(); } -plUUID::plUUID(const plString & s) -{ - FromString(s); -} - -plUUID::plUUID(const char * s) +plUUID::plUUID(const plString& s) { FromString(s.c_str()); } @@ -67,13 +62,13 @@ plUUID::plUUID(const Uuid& uuid) memcpy(fData, uuid.data, sizeof(fData)); } -void plUUID::Read(hsStream * s) +void plUUID::Read(hsStream* s) { s->LogSubStreamPushDesc("plUUID"); s->Read(sizeof(fData), (void*)fData); } -void plUUID::Write(hsStream * s) +void plUUID::Write(hsStream* s) { s->Write(sizeof(fData), (const void*)fData); } diff --git a/Sources/Plasma/NucleusLib/pnUUID/pnUUID_Unix.cpp b/Sources/Plasma/NucleusLib/pnUUID/pnUUID_Unix.cpp index 867ca85c..7cc270e7 100644 --- a/Sources/Plasma/NucleusLib/pnUUID/pnUUID_Unix.cpp +++ b/Sources/Plasma/NucleusLib/pnUUID/pnUUID_Unix.cpp @@ -126,12 +126,4 @@ plUUID plUUID::Generate() return result; } -#else - -// dummy function to prevent a linker warning complaining about no public symbols if the -// contents of the file get compiled out via pre-processor -void _preventLNK4221WarningStub() -{ -} - #endif diff --git a/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp b/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp index 25601fe2..9e286384 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp @@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include -COMPILER_ASSERT(sizeof(Uuid) >= sizeof(uuid_t)); +static_assert(sizeof(Uuid) >= sizeof(uuid_t), "UUID size does not match uuid_t"); #else diff --git a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp index 841ab634..24ce023a 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp @@ -147,30 +147,4 @@ bool GuidIsNil (const Uuid & uuid) { return 1 == UuidIsNil((GUID *)&uuid, &s ); } -//============================================================================ -const wchar_t * GuidToString (const Uuid & uuid, wchar_t * dst, unsigned chars) { - wchar_t * src; - RPC_STATUS s; - s = UuidToStringW( (GUID *) &uuid, (unsigned short**)&src ); - if (RPC_S_OK == s) - StrCopy(dst, src, chars); - else - StrCopy(dst, L"", chars); - RpcStringFreeW( (unsigned short**)&src ); - return dst; -} - -//============================================================================ -const char * GuidToString (const Uuid & uuid, char * dst, unsigned chars) { - uint8_t * src; - RPC_STATUS s; - s = UuidToStringA( (GUID *) &uuid, &src ); - if (RPC_S_OK == s) - StrCopy(dst, (char *)src, chars); - else - StrCopy(dst, "", chars); - RpcStringFreeA(&src); - return dst; -} - #endif // HS_BUILD_FOR_WIN32 diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp index ff3da241..4745c3da 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp @@ -64,17 +64,3 @@ Uuid::Uuid (const wchar_t str[]) { GuidFromString(str, this); } - -//============================================================================ -Uuid::Uuid (const uint8_t buf[], unsigned length) { - - GuidFromHex(buf, length, this); -} - -//============================================================================ -bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid) { - - ASSERT(length == sizeof(uuid->data)); - memcpy(uuid->data, buf, sizeof(uuid->data)); - return true; -} diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h index 515d48cd..daae5008 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h @@ -80,9 +80,6 @@ bool GuidFromString (const char str[], Uuid * uuid); int GuidCompare (const Uuid & a, const Uuid & b); inline bool GuidsAreEqual (const Uuid & a, const Uuid & b) { return 0 == GuidCompare(a, b); } bool GuidIsNil (const Uuid & uuid); -const wchar_t * GuidToString (const Uuid & uuid, wchar_t * dst, unsigned chars); // returns dst -const char * GuidToString (const Uuid & uuid, char * dst, unsigned chars); // returns dst -bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid); /***************************************************************************** @@ -100,7 +97,6 @@ struct Uuid { Uuid () {} Uuid (const wchar_t str[]); - Uuid (const uint8_t buf[], unsigned length); operator bool () const { return !GuidIsNil(*this); } inline bool operator ! () const { return GuidIsNil(*this); } inline bool operator < (const Uuid & rhs) const { return GuidCompare(*this, rhs) < 0; } diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index af55ba28..99728029 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -596,14 +596,17 @@ static void INetCliAuthAgeRequestCallback ( if (!IS_NET_ERROR(result) || result == kNetErrVaultNodeNotFound) { s_age.ageInstId = ageInstId; s_age.ageVaultId = ageVaultId; - - wchar_t ageInstIdStr[64]; + + plString gameAddrStr = gameAddr.GetHostString(); + plString ageInstIdStr = plUUID(ageInstId).AsString(); + LogMsg( kLogPerf, L"Connecting to game server %s, ageInstId %s", - gameAddr.GetHostString().ToWchar().GetData(), - GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr)) + gameAddrStr.c_str(), + ageInstIdStr.c_str() ); + NetCliGameDisconnect(); NetCliGameStartConnect(gameAddr.GetHost()); NetCliGameJoinAgeRequest( diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp index 09988ec6..3596aa56 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp @@ -369,9 +369,9 @@ void VaultTextNoteNode::SetVisitInfo (const plAgeInfoStruct & info) { break; case kAgeInstGuid: { - Uuid guid = (Uuid)*info.GetAgeInstanceGuid(); + plUUID guid = (plUUID)*info.GetAgeInstanceGuid(); wchar_t src[64]; - GuidToString(guid, src, arrsize(src)); + wcsncpy(src, guid.AsString().ToWchar(), 64); unsigned len = StrLen(src); wchar_t * dst = buf.New(len); memcpy(dst, src, len * sizeof(src[0]));