diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp index 11cc95e0..ac7a72b1 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp @@ -810,7 +810,7 @@ PF_CONSOLE_CMD( Net_Vault, plAgeLinkStruct link; link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeInstanceName( params[0] ); - plUUID guid(GuidGenerate()); + plUUID guid = plUUID::Generate(); link.GetAgeInfo()->SetAgeInstanceGuid( &guid); link.SetSpawnPoint( kDefaultSpawnPoint ); bool success = VaultRegisterOwnedAgeAndWait(&link); @@ -838,7 +838,7 @@ PF_CONSOLE_CMD( Net_Vault, plAgeLinkStruct link; link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeInstanceName( params[0] ); - plUUID guid(GuidGenerate()); + plUUID guid = plUUID::Generate(); link.GetAgeInfo()->SetAgeInstanceGuid( &guid); link.SetSpawnPoint( kDefaultSpawnPoint ); bool success = VaultRegisterOwnedAgeAndWait(&link); diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index 1179dfb4..c7eb6341 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -2828,12 +2828,12 @@ void cyMisc::SendFriendInvite(const wchar_t email[], const wchar_t toName[]) if (RelVaultNode* pNode = VaultGetPlayerNodeIncRef()) { VaultPlayerNode player(pNode); - Uuid inviteUuid = player.inviteUuid; + plUUID inviteUuid(player.inviteUuid); // If we don't have an invite UUID set then make a new one - if (GuidIsNil(inviteUuid)) + if (inviteUuid.IsNull()) { - inviteUuid = GuidGenerate(); + inviteUuid = plUUID::Generate(); player.SetInviteUuid(inviteUuid); } @@ -2844,11 +2844,9 @@ void cyMisc::SendFriendInvite(const wchar_t email[], const wchar_t toName[]) PyObject* cyMisc::PyGuidGenerate() { - char guidStr[64]; - Uuid newGuid = GuidGenerate(); - GuidToString(newGuid, guidStr, arrsize(guidStr)); + plUUID newGuid = plUUID::Generate(); - return PyString_FromString(guidStr); + return PyString_FromString(newGuid.AsString().c_str()); } PyObject* cyMisc::GetAIAvatarsByModelName(const char* name) diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp index 82284a3c..73a38b6d 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp @@ -671,7 +671,7 @@ void pyVault::CreateNeighborhood() desc = plString::Format( "%s's %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() ); } - plUUID guid(GuidGenerate()); + plUUID guid = plUUID::Generate(); link.GetAgeInfo()->SetAgeInstanceGuid(&guid); link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() ); link.GetAgeInfo()->SetAgeDescription( desc.c_str() ); diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp index b82ee37d..a48aa22f 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp @@ -976,9 +976,9 @@ void NetVaultNodeFieldArray::GetFieldValueString_LCS ( case NetVaultNode::kUuid_2: case NetVaultNode::kUuid_3: case NetVaultNode::kUuid_4: { - wchar_t tmp[64]; - GuidToHex(*(Uuid *)fieldAddr, tmp, arrsize(tmp)); - StrPrintf(dst, dstChars, L"hextoraw('%s')", tmp); + plString tmp = plUUID(fieldAddr).AsString(); + + StrPrintf(dst, dstChars, L"hextoraw('%s')", tmp.c_str()); } break; diff --git a/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp b/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp index 32beab3f..e9609ed4 100644 --- a/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp +++ b/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp @@ -47,44 +47,46 @@ plUUID::plUUID() Clear(); } -plUUID::plUUID( const plString & s ) +plUUID::plUUID(const plString & s) { - FromString( s ); + FromString(s); } -plUUID::plUUID( const char * s ) +plUUID::plUUID(const char * s) { - FromString( s ); + FromString(s.c_str()); } -plUUID::plUUID( const plUUID & other ) +plUUID::plUUID(const plUUID& other) { - CopyFrom( &other ); + CopyFrom(&other); } -plUUID::plUUID( const Uuid & uuid ) +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 ); + s->Read(sizeof(fData), (void*)fData); } -void plUUID::Write( hsStream * s) +void plUUID::Write(hsStream * s) { - s->Write( sizeof( fData ), (const void*)fData ); + s->Write(sizeof(fData), (const void*)fData); } -plString plUUID::AsString() const { +plString plUUID::AsString() const +{ plString str; ToString(str); return str; } -plUUID::operator Uuid () const { +plUUID::operator Uuid () const +{ Uuid uuid; memcpy(uuid.data, fData, sizeof(uuid.data)); return uuid; diff --git a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp index acd519d8..841ab634 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp @@ -120,17 +120,7 @@ Uuid Uuid::Generate() static_assert(sizeof(Uuid) >= sizeof(GUID), "pnUtils Uuid and Win32 GUID types differ in size"); -//============================================================================ -Uuid GuidGenerate () { - Uuid result; - UuidCreate( (GUID *)&result ); - return result; -} -//============================================================================ -void GuidClear (Uuid * uuid) { - UuidCreateNil((GUID *)uuid); -} //============================================================================ bool GuidFromString (const wchar_t str[], Uuid * uuid) { diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp index c5f31c32..ff3da241 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp @@ -71,32 +71,6 @@ Uuid::Uuid (const uint8_t buf[], unsigned length) { GuidFromHex(buf, length, this); } -//============================================================================ -unsigned GuidHash (const Uuid & uuid) { - - CHashValue hash(&uuid.data, sizeof(uuid.data)); - return hash.GetHash(); -} - -//============================================================================ -static const wchar_t s_hexChars[] = L"0123456789ABCDEF"; -const wchar_t * GuidToHex (const Uuid & uuid, wchar_t * dst, unsigned chars) { - - wchar_t * str = (wchar_t*)malloc((sizeof(uuid.data) * 2 + 1) * sizeof(wchar_t)); - wchar_t * cur = str; - - for (unsigned i = 0; i < sizeof(uuid.data); ++i) { - *cur++ = s_hexChars[(uuid.data[i] >> 4) & 0x0f]; - *cur++ = s_hexChars[uuid.data[i] & 0x0f]; - } - *cur = 0; - - StrCopy(dst, str, chars); - - free(str); - return dst; -} - //============================================================================ bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid) { diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h index 875adcf9..515d48cd 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h @@ -75,17 +75,13 @@ extern const Uuid kNilGuid; // Using 'Guid' here instead of 'Uuid' to avoid name clash with windows API =( -Uuid GuidGenerate (); -void GuidClear (Uuid * uuid); bool GuidFromString (const wchar_t str[], Uuid * uuid); 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); -unsigned GuidHash (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 -const wchar_t * GuidToHex (const Uuid & uuid, wchar_t * dst, unsigned chars); // returns dst bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid); diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp index cb4787f6..eb928ccf 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp @@ -833,7 +833,7 @@ void plSceneInputInterface::ILinkOffereeToAge() else if (!VaultGetOwnedAgeLink(&info, &link)) { // We must have an owned copy of the age before we can offer it, so make one now - plUUID guid(GuidGenerate()); + plUUID guid = plUUID::Generate(); info.SetAgeInstanceGuid(&guid); plString title, desc; @@ -861,7 +861,7 @@ void plSceneInputInterface::ILinkOffereeToAge() VaultAgeLinkNode linkAcc(linkNode); if (linkAcc.volat) { if (VaultUnregisterOwnedAgeAndWait(link.GetAgeInfo())) { - plUUID guid(GuidGenerate()); + plUUID guid = plUUID::Generate(); link.GetAgeInfo()->SetAgeInstanceGuid(&guid); VaultRegisterOwnedAgeAndWait(&link); } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp index cfaa2077..3948eae6 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp @@ -920,7 +920,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void) // BASIC LINK. Link to a unique instance of the age, if no instance specified. case plNetCommon::LinkingRules::kBasicLink: if (!info->HasAgeInstanceGuid()) { - plUUID newuuid(GuidGenerate()); + plUUID newuuid = plUUID::Generate(); info->SetAgeInstanceGuid(&newuuid); } break; @@ -961,7 +961,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void) info->SetAgeDescription(desc.c_str()); } if (!info->HasAgeInstanceGuid()) { - plUUID newuuid(GuidGenerate()); + plUUID newuuid = plUUID::Generate(); info->SetAgeInstanceGuid(&newuuid); } @@ -1002,7 +1002,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void) } if (!info->HasAgeInstanceGuid()) { - plUUID newuuid(GuidGenerate()); + plUUID newuuid = plUUID::Generate(); info->SetAgeInstanceGuid(&newuuid); } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index 4a28fddb..a6fa421e 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -5624,7 +5624,7 @@ unsigned NetCliAuthVaultNodeSave ( node->dirtyFlags |= NetVaultNode::kNodeType; // We're definitely saving this node, so assign a revisionId - node->revisionId = GuidGenerate(); + node->revisionId = (Uuid)plUUID::Generate(); ARRAY(uint8_t) buffer; unsigned bytes = node->Write_LCS(&buffer, NetVaultNode::kRwDirtyOnly | NetVaultNode::kRwUpdateDirty);