Browse Source

Get rid of GuidGenerate calls.

Darryl Pogue 12 years ago
parent
commit
fd8541e18d
  1. 4
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  2. 12
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  3. 2
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  4. 6
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp
  5. 28
      Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp
  6. 10
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp
  7. 26
      Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp
  8. 4
      Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h
  9. 4
      Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp
  10. 6
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  11. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

4
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);

12
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)

2
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() );

6
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;

28
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;

10
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) {

26
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) {

4
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);

4
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);
}

6
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);
}

2
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);

Loading…
Cancel
Save