Browse Source

Merge pull request #463 from Hoikas/npcommon-cleanup

plString-ify the Vault
Michael Hansen 10 years ago
parent
commit
cd9057e840
  1. 4
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  2. 12
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp
  3. 8
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  4. 32
      Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp
  5. 15
      Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp
  6. 10
      Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.h
  7. 2
      Sources/Plasma/FeatureLib/pfPython/pyDniInfoSourceGlue.cpp
  8. 34
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  9. 51
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp
  10. 41
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.h
  11. 10
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp
  12. 59
      Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNode.cpp
  13. 11
      Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNode.h
  14. 8
      Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp
  15. 55
      Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNode.cpp
  16. 10
      Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNode.h
  17. 3
      Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNodeGlue.cpp
  18. 35
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp
  19. 5
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.h
  20. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNodeGlue.cpp
  21. 14
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp
  22. 10
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.h
  23. 2
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp
  24. 35
      Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp
  25. 1
      Sources/Plasma/FeatureLib/pfPython/pyVaultNode.h
  26. 68
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp
  27. 13
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h
  28. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp
  29. 32
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp
  30. 6
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.h
  31. 11
      Sources/Plasma/FeatureLib/pfPython/pyVaultSDLNode.cpp
  32. 90
      Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp
  33. 9
      Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.h
  34. 6
      Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNodeGlue.cpp
  35. 896
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp
  36. 510
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h
  37. 14
      Sources/Plasma/NucleusLib/pnUtils/pnUtMisc.h
  38. 2
      Sources/Plasma/PubUtilLib/plNetClient/plLinkEffectsMgr.cpp
  39. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp
  40. 12
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  41. 5
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  42. 40
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  43. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h
  44. 2
      Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp
  45. 4
      Sources/Plasma/PubUtilLib/plVault/Pch.h
  46. 389
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp
  47. 37
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h
  48. 263
      Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp
  49. 47
      Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h

4
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -6913,8 +6913,8 @@ PF_CONSOLE_GROUP(Vault)
PF_CONSOLE_CMD(Vault, Dump, "", "Prints the vault structure of current player and age to the nearest log file")
{
VaultDump(L"Player", NetCommGetPlayer()->playerInt);
VaultDump(L"Age", NetCommGetAge()->ageVaultId);
VaultDump("Player", NetCommGetPlayer()->playerInt);
VaultDump("Age", NetCommGetAge()->ageVaultId);
}
#endif

12
Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp

@ -1665,15 +1665,12 @@ bool cyAvatar::LoadClothingFromFile(plFileName filename)
void cyAvatar::ChangeAvatar(const char* genderName)
{
#ifndef PLASMA_EXTERNAL_RELEASE
plClothingMgr::ChangeAvatar((char*)genderName);
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, genderName, arrsize(wStr));
plClothingMgr::ChangeAvatar(genderName);
hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode();
if (rvnPlr) {
VaultPlayerNode plr(rvnPlr);
plr.SetAvatarShapeName(wStr);
plr.SetAvatarShapeName(genderName);
}
#endif
}
@ -1687,13 +1684,10 @@ void cyAvatar::ChangeAvatar(const char* genderName)
//
void cyAvatar::ChangePlayerName(const char* playerName)
{
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, playerName, arrsize(wStr));
hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode();
if (rvnPlr) {
VaultPlayerNode plr(rvnPlr);
plr.SetPlayerName(wStr);
plr.SetPlayerName(playerName);
}
}

8
Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp

@ -2469,11 +2469,9 @@ int cyMisc::GetKILevel()
{
int result = pfKIMsg::kNanoKI;
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, pfKIMsg::kChronicleKILevel, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wStr)) {
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(pfKIMsg::kChronicleKILevel)) {
VaultChronicleNode chron(rvn);
result = wcstol(chron.GetEntryValue(), nil, 0);
result = chron.GetEntryValue().ToInt();
}
return result;
@ -2934,7 +2932,7 @@ void cyMisc::ForceVaultNodeUpdate(unsigned nodeId)
void cyMisc::VaultDownload(unsigned nodeId)
{
VaultDownloadAndWait(
L"PyVaultDownload",
"PyVaultDownload",
nodeId,
nil,
nil

32
Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp

@ -203,10 +203,7 @@ void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, uint32
pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject );
cb->VaultOperationStarted( cbContext );
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultAgeAddDeviceAndWait(wStr))
if (hsRef<RelVaultNode> rvn = VaultAgeAddDeviceAndWait(deviceName))
cb->SetNode(rvn);
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail); // cbHolder deletes itself here.
@ -215,27 +212,18 @@ void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, uint32
// Remove a device.
void pyAgeVault::RemoveDevice( const char * deviceName )
{
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
VaultAgeRemoveDevice(wStr);
VaultAgeRemoveDevice(deviceName);
}
// True if device exists in age.
bool pyAgeVault::HasDevice( const char * deviceName )
{
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
return VaultAgeHasDevice(wStr);
return VaultAgeHasDevice(deviceName);
}
PyObject * pyAgeVault::GetDevice( const char * deviceName )
{
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultAgeGetDevice(wStr))
if (hsRef<RelVaultNode> rvn = VaultAgeGetDevice(deviceName))
return pyVaultTextNoteNode::New(rvn);
PYTHON_RETURN_NONE;
@ -247,12 +235,7 @@ void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName
pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject );
cb->VaultOperationStarted( cbContext );
wchar_t wDev[MAX_PATH];
StrToUnicode(wDev, deviceName, arrsize(wDev));
wchar_t wInb[MAX_PATH];
StrToUnicode(wInb, inboxName, arrsize(wInb));
if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(wDev, wInb))
if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(deviceName, inboxName))
cb->SetNode(rvn);
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here.
@ -260,10 +243,7 @@ void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName
PyObject * pyAgeVault::GetDeviceInbox( const char * deviceName )
{
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultAgeGetDeviceInbox(wStr))
if (hsRef<RelVaultNode> rvn = VaultAgeGetDeviceInbox(deviceName))
return pyVaultTextNoteNode::New(rvn);
PYTHON_RETURN_NONE;

15
Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp

@ -50,14 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plVault/plVault.h"
#include "pyDniCoordinates.h"
pyDniInfoSource::pyDniInfoSource()
: fAgeName(nil)
{}
pyDniInfoSource::~pyDniInfoSource() {
free(fAgeName);
}
PyObject* pyDniInfoSource::GetAgeCoords( void )
{
#if 0 // this may get retooled for another purpose someday...
@ -85,17 +77,14 @@ uint32_t pyDniInfoSource::GetAgeTime( void ) const
return result;
}
const char * pyDniInfoSource::GetAgeName( void ) const
plString pyDniInfoSource::GetAgeName() const
{
hsRef<RelVaultNode> node = VaultGetAgeInfoNode();
if (!node)
return "";
VaultAgeInfoNode ageInfo(node);
fAgeName = StrDupToAnsi(ageInfo.GetAgeInstanceName());
return fAgeName;
return ageInfo.GetAgeInstanceName();
}
plUUID pyDniInfoSource::GetAgeGuid( void ) const

10
Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.h

@ -46,18 +46,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h"
class pyDniCoordinates;
class plString;
class plUUID;
class pyDniInfoSource
{
private:
mutable char * fAgeName;
protected:
pyDniInfoSource();
pyDniInfoSource() { }
public:
~pyDniInfoSource();
~pyDniInfoSource() { }
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptDniInfoSource);
@ -72,7 +70,7 @@ public:
// current time in current age (tbd)
uint32_t GetAgeTime( void ) const;
// name of current age
const char * GetAgeName( void ) const;
plString GetAgeName() const;
// unique identifier for this age instance
plUUID GetAgeGuid(void) const;
};

2
Sources/Plasma/FeatureLib/pfPython/pyDniInfoSourceGlue.cpp

@ -69,7 +69,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptDniInfoSource, getAgeTime)
PYTHON_METHOD_DEFINITION_NOARGS(ptDniInfoSource, getAgeName)
{
return PyString_FromString(self->fThis->GetAgeName());
return PyString_FromPlString(self->fThis->GetAgeName());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptDniInfoSource, getAgeGuid)

34
Sources/Plasma/FeatureLib/pfPython/pyVault.cpp

@ -328,10 +328,7 @@ PyObject* pyVault::GetVisitAgeLink( const pyAgeInfoStruct & info)
// Chronicle
PyObject* pyVault::FindChronicleEntry( const char * entryName )
{
wchar_t wEntryName[kMaxVaultNodeStringLength];
StrToUnicode(wEntryName, entryName, arrsize(wEntryName));
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wEntryName))
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(entryName))
return pyVaultChronicleNode::New(rvn);
// just return a None object
@ -340,16 +337,10 @@ PyObject* pyVault::FindChronicleEntry( const char * entryName )
void pyVault::AddChronicleEntry( const char * name, uint32_t type, const char * value )
{
wchar_t * wEntryName = StrDupToUnicode(name);
wchar_t * wEntryValue = StrDupToUnicode(value);
// FIXME: We should ideally not block, but for now, the Python assumes that when
// we return, the chronicle exists and can be found with findChronicleEntry.
// Maybe we should insert a dummy into the tree? (currently hard)
VaultAddChronicleEntryAndWait(wEntryName, type, wEntryValue);
free(wEntryName);
free(wEntryValue);
VaultAddChronicleEntryAndWait(name, type, value);
}
@ -358,11 +349,8 @@ void pyVault::SendToDevice( pyVaultNode& node, const char * deviceName )
if (!node.GetNode())
return;
wchar_t wDevName[256];
StrToUnicode(wDevName, deviceName, arrsize(wDevName));
// Note: This actually blocks (~Hoikas)
VaultPublishNode(node.GetNode()->GetNodeId(), wDevName);
VaultPublishNode(node.GetNode()->GetNodeId(), deviceName);
}
@ -412,16 +400,12 @@ PyObject* pyVault::GetPsnlAgeSDL() const
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) {
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, kPersonalAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(kPersonalAgeFilename);
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->Clear();
templateNode->SetNodeType(plVault::kNodeType_SDL);
if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) {
@ -451,16 +435,12 @@ void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec )
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) {
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, kPersonalAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(kPersonalAgeFilename);
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->Clear();
templateNode->SetNodeType(plVault::kNodeType_SDL);
if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) {

51
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp

@ -177,48 +177,42 @@ PyObject * pyVaultAgeInfoNode::GetParentAgeLink () const
}
const char * pyVaultAgeInfoNode::GetAgeFilename() const
plString pyVaultAgeInfoNode::GetAgeFilename() const
{
if (fNode) {
char str[MAX_PATH];
VaultAgeInfoNode access(fNode);
StrToAnsi(str, access.GetAgeFilename(), arrsize(str));
fAgeFilename = str;
return access.GetAgeFilename();
}
return fAgeFilename.c_str();
return "";
}
void pyVaultAgeInfoNode::SetAgeFilename( const char * v )
void pyVaultAgeInfoNode::SetAgeFilename(const plString& v)
{
}
const char * pyVaultAgeInfoNode::GetAgeInstanceName() const
plString pyVaultAgeInfoNode::GetAgeInstanceName() const
{
if (fNode) {
char str[MAX_PATH];
VaultAgeInfoNode access(fNode);
StrToAnsi(str, access.GetAgeInstanceName(), arrsize(str));
fAgeInstName = str;
return access.GetAgeInstanceName();
}
return fAgeInstName.c_str();
return "";
}
void pyVaultAgeInfoNode::SetAgeInstanceName( const char * v )
void pyVaultAgeInfoNode::SetAgeInstanceName(const plString& v)
{
}
const char * pyVaultAgeInfoNode::GetAgeUserDefinedName() const
plString pyVaultAgeInfoNode::GetAgeUserDefinedName() const
{
if (fNode) {
char str[MAX_PATH];
VaultAgeInfoNode access(fNode);
StrToAnsi(str, access.GetAgeUserDefinedName(), arrsize(str));
fAgeUserName = str;
return access.GetAgeUserDefinedName();
}
return fAgeUserName.c_str();
return "";
}
void pyVaultAgeInfoNode::SetAgeUserDefinedName( const char * v )
void pyVaultAgeInfoNode::SetAgeUserDefinedName(const plString& v)
{
}
@ -236,19 +230,16 @@ void pyVaultAgeInfoNode::SetAgeInstanceGuid( const char * sguid )
{
}
const char * pyVaultAgeInfoNode::GetAgeDescription() const
plString pyVaultAgeInfoNode::GetAgeDescription() const
{
if (fNode) {
char str[MAX_PATH];
memset(str, 0, sizeof(str));
VaultAgeInfoNode access(fNode);
StrToAnsi(str, access.GetAgeDescription(), arrsize(str));
fAgeDescription = str;
return access.GetAgeDescription();
}
return fAgeDescription.c_str();
return "";
}
void pyVaultAgeInfoNode::SetAgeDescription( const char * v )
void pyVaultAgeInfoNode::SetAgeDescription(const plString& v)
{
}
@ -303,18 +294,16 @@ bool pyVaultAgeInfoNode::IsPublic() const
return false;
}
const char * pyVaultAgeInfoNode::GetDisplayName() const
plString pyVaultAgeInfoNode::GetDisplayName() const
{
if (fNode) {
char str[MAX_PATH];
VaultAgeInfoNode access(fNode);
if (access.GetAgeSequenceNumber() > 0)
StrPrintf(str, arrsize(str), "%S(%d) %S", access.GetAgeUserDefinedName(), access.GetAgeSequenceNumber(), access.GetAgeInstanceName());
return plFormat("{}({}) {}", access.GetAgeUserDefinedName(), access.GetAgeSequenceNumber(), access.GetAgeInstanceName());
else
StrPrintf(str, arrsize(str), "%S %S", access.GetAgeUserDefinedName(), access.GetAgeInstanceName());
fAgeDispName = str;
return plFormat("{} {}", access.GetAgeUserDefinedName(), access.GetAgeInstanceName());
}
return fAgeDispName.c_str();
return "";
}
PyObject * pyVaultAgeInfoNode::AsAgeInfoStruct() const

41
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.h

@ -61,13 +61,6 @@ class plUUID;
class pyVaultAgeInfoNode : public pyVaultNode
{
private:
mutable std::string fAgeFilename;
mutable std::string fAgeInstName;
mutable std::string fAgeUserName;
mutable std::string fAgeDispName;
mutable std::string fAgeDescription;
protected:
// should only be created from C++ side
pyVaultAgeInfoNode(RelVaultNode* vaultNode);
@ -96,35 +89,35 @@ public:
PyObject * GetParentAgeLink () const; // returns pyVaultAgeLinkNode, or None if not a child age.
const char * GetAgeFilename() const;
void SetAgeFilename( const char * v );
plString GetAgeFilename() const;
void SetAgeFilename(const plString& v);
const char * GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v );
plString GetAgeInstanceName() const;
void SetAgeInstanceName(const plString& v);
const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v );
plString GetAgeUserDefinedName() const;
void SetAgeUserDefinedName(const plString& v);
plUUID GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid );
const char * GetAgeDescription() const;
void SetAgeDescription( const char * v );
plString GetAgeDescription() const;
void SetAgeDescription(const plString& v);
int32_t GetSequenceNumber() const;
void SetSequenceNumber( int32_t v );
int32_t GetSequenceNumber() const;
void SetSequenceNumber( int32_t v );
int32_t GetAgeLanguage() const;
void SetAgeLanguage( int32_t v );
int32_t GetAgeLanguage() const;
void SetAgeLanguage( int32_t v );
uint32_t GetAgeID() const;
void SetAgeID( uint32_t v );
uint32_t GetAgeID() const;
void SetAgeID( uint32_t v );
uint32_t GetCzarID() const;
uint32_t GetCzarID() const;
bool IsPublic() const;
bool IsPublic() const;
const char * GetDisplayName() const;
plString GetDisplayName() const;
PyObject * AsAgeInfoStruct() const; // returns pyAgeInfoStruct
};

10
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp

@ -97,7 +97,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getParentAgeLink)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeFilename)
{
return PyString_FromString(self->fThis->GetAgeFilename());
return PyString_FromPlString(self->fThis->GetAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeFilename, args)
@ -114,7 +114,7 @@ PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeFilename, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeInstanceName)
{
return PyString_FromString(self->fThis->GetAgeInstanceName());
return PyString_FromPlString(self->fThis->GetAgeInstanceName());
}
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceName, args)
@ -131,7 +131,7 @@ PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeUserDefinedName)
{
return PyString_FromString(self->fThis->GetAgeUserDefinedName());
return PyString_FromPlString(self->fThis->GetAgeUserDefinedName());
}
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeUserDefinedName, args)
@ -165,7 +165,7 @@ PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceGuid, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeDescription)
{
return PyString_FromString(self->fThis->GetAgeDescription());
return PyString_FromPlString(self->fThis->GetAgeDescription());
}
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeDescription, args)
@ -243,7 +243,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, isPublic)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getDisplayName)
{
return PyString_FromString(self->fThis->GetDisplayName());
return PyString_FromPlString(self->fThis->GetDisplayName());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, asAgeInfoStruct)

59
Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNode.cpp

@ -56,25 +56,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// should only be created from C++ side
pyVaultChronicleNode::pyVaultChronicleNode(RelVaultNode* nfsNode)
: pyVaultNode(nfsNode)
, ansiName(nil)
, ansiValue(nil)
{
}
//create from the Python side
pyVaultChronicleNode::pyVaultChronicleNode(int n)
: pyVaultNode(new RelVaultNode)
, ansiName(nil)
, ansiValue(nil)
{
fNode->SetNodeType(plVault::kNodeType_Chronicle);
}
pyVaultChronicleNode::~pyVaultChronicleNode () {
free(ansiName);
free(ansiValue);
}
//==================================================================
// class RelVaultNode : public plVaultNode
@ -84,50 +75,34 @@ void pyVaultChronicleNode::Chronicle_SetName( const char * text )
if (!fNode)
return;
wchar_t * wStr = StrDupToUnicode(text);
VaultChronicleNode chron(fNode);
chron.SetEntryName(wStr);
free(wStr);
chron.SetEntryName(text);
}
const char * pyVaultChronicleNode::Chronicle_GetName( void )
plString pyVaultChronicleNode::Chronicle_GetName() const
{
if (!fNode)
return "";
free(ansiName);
VaultChronicleNode chron(fNode);
ansiName = StrDupToAnsi(chron.GetEntryName());
return ansiName;
if (fNode) {
VaultChronicleNode chron(fNode);
return chron.GetEntryName();
}
return "";
}
void pyVaultChronicleNode::Chronicle_SetValue( const char * text )
{
if (!fNode)
return;
wchar_t * wStr = StrDupToUnicode(text);
VaultChronicleNode chron(fNode);
chron.SetEntryValue(wStr);
free(wStr);
if (fNode) {
VaultChronicleNode chron(fNode);
chron.SetEntryValue(text);
}
}
const char * pyVaultChronicleNode::Chronicle_GetValue( void )
plString pyVaultChronicleNode::Chronicle_GetValue() const
{
if (!fNode)
return "";
free(ansiValue);
ansiValue = nil;
VaultChronicleNode chron(fNode);
if (!chron.GetEntryValue())
return "";
ansiValue = StrDupToAnsi(chron.GetEntryValue());
return ansiValue;
if (fNode) {
VaultChronicleNode chron(fNode);
return chron.GetEntryValue();
}
return "";
}
void pyVaultChronicleNode::Chronicle_SetType( uint32_t type )

11
Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNode.h

@ -52,14 +52,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h"
#include "pyVaultNode.h"
class plString;
struct RelVaultNode;
class pyVaultChronicleNode : public pyVaultNode
{
char * ansiName;
char * ansiValue;
protected:
// should only be created from C++ side
pyVaultChronicleNode(RelVaultNode* nfsNode);
@ -68,7 +65,7 @@ protected:
pyVaultChronicleNode(int n=0);
public:
~pyVaultChronicleNode ();
~pyVaultChronicleNode() { }
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVaultChronicleNode);
@ -83,9 +80,9 @@ public:
// class RelVaultNode : public plVaultNode
//
void Chronicle_SetName( const char * text );
const char * Chronicle_GetName( void );
plString Chronicle_GetName() const;
void Chronicle_SetValue( const char * text );
const char * Chronicle_GetValue( void );
plString Chronicle_GetValue() const;
void Chronicle_SetType( uint32_t type );
uint32_t Chronicle_GetType( void );
};

8
Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp

@ -78,7 +78,7 @@ PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, chronicleGetName)
{
return PyString_FromString(self->fThis->Chronicle_GetName());
return PyString_FromPlString(self->fThis->Chronicle_GetName());
}
PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetValue, args)
@ -95,7 +95,7 @@ PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetValue, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, chronicleGetValue)
{
return PyString_FromString(self->fThis->Chronicle_GetValue());
return PyString_FromPlString(self->fThis->Chronicle_GetValue());
}
PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetType, args)
@ -129,7 +129,7 @@ PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, getName)
{
return PyString_FromString(self->fThis->Chronicle_GetName());
return PyString_FromPlString(self->fThis->Chronicle_GetName());
}
PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setValue, args)
@ -146,7 +146,7 @@ PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setValue, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, getValue)
{
return PyString_FromString(self->fThis->Chronicle_GetValue());
return PyString_FromPlString(self->fThis->Chronicle_GetValue());
}
PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setEntryType, args)

55
Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNode.cpp

@ -87,50 +87,27 @@ int pyVaultFolderNode::Folder_GetType( void )
return folder.GetFolderType();
}
void pyVaultFolderNode::Folder_SetName( std::string name )
void pyVaultFolderNode::Folder_SetName(const char* name)
{
if (!fNode)
return;
wchar_t* wName = hsStringToWString(name.c_str());
VaultFolderNode folder(fNode);
folder.SetFolderName(wName);
delete [] wName;
}
void pyVaultFolderNode::Folder_SetNameW( std::wstring name )
{
if (!fNode)
return;
VaultFolderNode folder(fNode);
folder.SetFolderName(name.c_str());
if (fNode) {
VaultFolderNode folder(fNode);
folder.SetFolderName(name);
}
}
std::string pyVaultFolderNode::Folder_GetName( void )
void pyVaultFolderNode::Folder_SetNameW(const wchar_t* name)
{
if (!fNode)
return "";
VaultFolderNode folder(fNode);
if (!folder.GetFolderName())
return "";
std::string retVal;
char* sName = hsWStringToString(folder.GetFolderName());
retVal = sName;
delete [] sName;
return retVal;
if (fNode) {
VaultFolderNode folder(fNode);
folder.SetFolderName(plString::FromWchar(name));
}
}
std::wstring pyVaultFolderNode::Folder_GetNameW( void )
plString pyVaultFolderNode::Folder_GetName() const
{
if (!fNode)
return L"";
VaultFolderNode folder(fNode);
if (!folder.GetFolderName())
return L"";
return folder.GetFolderName();
if (fNode) {
VaultFolderNode folder(fNode);
return folder.GetFolderName();
}
return "";
}

10
Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNode.h

@ -50,12 +50,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "pyGlueHelpers.h"
#include <string>
#include "pyVaultNode.h"
class plString;
struct RelVaultNode;
class pyVaultFolderNode : public pyVaultNode
{
protected:
@ -80,10 +79,9 @@ public:
virtual void Folder_SetType( int type );
virtual int Folder_GetType( void );
void Folder_SetName( std::string name );
void Folder_SetNameW( std::wstring name );
std::string Folder_GetName( void );
std::wstring Folder_GetNameW( void );
void Folder_SetName(const char* name);
void Folder_SetNameW(const wchar_t* name);
plString Folder_GetName() const;

3
Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNodeGlue.cpp

@ -164,8 +164,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultFolderNode, getFolderName)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultFolderNode, getFolderNameW)
{
std::wstring name = self->fThis->Folder_GetNameW();
return PyUnicode_FromWideChar(name.c_str(), name.length());
return PyUnicode_FromStringEx(self->fThis->Folder_GetName());
}
PYTHON_START_METHODS_TABLE(ptVaultFolderNode)

35
Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp

@ -117,11 +117,8 @@ void pyVaultImageNode::Image_SetTitle( const char * text )
if (!fNode)
return;
wchar_t * wStr = hsStringToWString(text);
VaultImageNode image(fNode);
image.SetImageTitle(wStr);
delete [] wStr;
image.SetImageTitle(text);
}
void pyVaultImageNode::Image_SetTitleW( const wchar_t* text )
@ -130,34 +127,16 @@ void pyVaultImageNode::Image_SetTitleW( const wchar_t* text )
return;
VaultImageNode image(fNode);
image.SetImageTitle(text);
image.SetImageTitle(plString::FromWchar(text));
}
std::string pyVaultImageNode::Image_GetTitle( void )
plString pyVaultImageNode::Image_GetTitle() const
{
if (!fNode)
return "";
VaultImageNode image(fNode);
std::string retVal = "";
if (image.GetImageTitle())
{
char* temp = hsWStringToString(image.GetImageTitle());
retVal = temp;
delete [] temp;
if (fNode) {
VaultImageNode image(fNode);
return image.GetImageTitle();
}
return retVal;
}
std::wstring pyVaultImageNode::Image_GetTitleW( void )
{
if (!fNode)
return L"";
VaultImageNode image(fNode);
return image.GetImageTitle() ? image.GetImageTitle() : L"";
return "";
}
PyObject* pyVaultImageNode::Image_GetImage( void )

5
Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.h

@ -51,12 +51,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "pyGlueHelpers.h"
#include "pnKeyedObject/plKey.h"
#include <string>
#include "pyVaultNode.h"
struct RelVaultNode;
class plMipmap;
class plString;
class pyVaultImageNode : public pyVaultNode
{
@ -88,8 +88,7 @@ public:
//
void Image_SetTitle( const char * text );
void Image_SetTitleW( const wchar_t * text );
std::string Image_GetTitle( void );
std::wstring Image_GetTitleW( void );
plString Image_GetTitle() const;
PyObject* Image_GetImage( void ); // returns pyImage
void Image_SetImage(pyImage& image);

4
Sources/Plasma/FeatureLib/pfPython/pyVaultImageNodeGlue.cpp

@ -154,8 +154,8 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultImageNode, getTitle)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultImageNode, getTitleW)
{
std::wstring retVal = self->fThis->Image_GetTitleW();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
plStringBuffer<wchar_t> retVal = self->fThis->Image_GetTitle().ToWchar();
return PyUnicode_FromWideChar(retVal.GetData(), retVal.GetSize());
}
PYTHON_METHOD_DEFINITION(ptVaultImageNode, setImage, args)

14
Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp

@ -68,24 +68,20 @@ pyVaultMarkerGameNode::pyVaultMarkerGameNode(int n)
// class RelVaultNode : public plVaultNode
//
const char * pyVaultMarkerGameNode::GetGameName () const
plString pyVaultMarkerGameNode::GetGameName () const
{
fGameName[0] = 0;
if (fNode) {
VaultMarkerGameNode access(fNode);
StrToAnsi(fGameName, access.GetGameName(), arrsize(fGameName));
return access.GetGameName();
}
return fGameName;
return "";
}
void pyVaultMarkerGameNode::SetGameName (const char v[])
void pyVaultMarkerGameNode::SetGameName (const plString& name)
{
if (fNode) {
VaultMarkerGameNode access(fNode);
wchar_t unicode[kMaxVaultNodeStringLength];
StrToUnicode(unicode, v, arrsize(unicode));
access.SetGameName(unicode);
access.SetGameName(name);
}
}

10
Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.h

@ -53,16 +53,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h"
#include "pyVaultNode.h"
#include "pnNetBase/pnNetBase.h"
class plString;
struct RelVaultNode;
class plUUID;
class pyVaultMarkerGameNode : public pyVaultNode
{
private:
mutable char fGameName[kMaxVaultNodeStringLength];
protected:
// should only be created from C++ side
pyVaultMarkerGameNode(RelVaultNode* vaultNode);
@ -83,8 +79,8 @@ public:
//==================================================================
// class RelVaultNode : public plVaultNode
//
const char * GetGameName () const;
void SetGameName (const char v[]);
plString GetGameName () const;
void SetGameName (const plString& name);
plUUID GetGameGuid() const;
void SetGameGuid (const char v[]);

2
Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp

@ -67,7 +67,7 @@ PYTHON_INIT_DEFINITION(ptVaultMarkerGameNode, args, keywords)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultMarkerGameNode, getGameName)
{
return PyString_FromString(self->fThis->GetGameName());
return PyString_FromPlString(self->fThis->GetGameName());
}
PYTHON_METHOD_DEFINITION(ptVaultMarkerGameNode, setGameName, args)

35
Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp

@ -164,23 +164,17 @@ hsRef<RelVaultNode> pyVaultNode::pyVaultNodeOperationCallback::GetNode() const {
return fNode;
}
// only for python glue, do NOT call
pyVaultNode::pyVaultNode()
: fCreateAgeName(nil)
{
}
// should only be created from C++ side
pyVaultNode::pyVaultNode( RelVaultNode* nfsNode )
: fNode(nfsNode)
, fCreateAgeName(nil)
{
}
pyVaultNode::~pyVaultNode()
{
free(fCreateAgeName);
}
pyVaultNode::~pyVaultNode() {}
hsRef<RelVaultNode> pyVaultNode::GetNode() const
@ -291,22 +285,11 @@ uint32_t pyVaultNode::GetCreateAgeTime( void )
return GetCreateTime();
}
const char * pyVaultNode::GetCreateAgeName( void )
const char * pyVaultNode::GetCreateAgeName()
{
if (!fNode)
return "";
if (fCreateAgeName)
return fCreateAgeName;
if (fNode) {
if (fNode->GetCreateAgeName())
fCreateAgeName = StrDupToAnsi(fNode->GetCreateAgeName());
else
fCreateAgeName = StrDup("");
}
return fCreateAgeName;
if (fNode)
return fNode->GetCreateAgeName().c_str();
return "";
}
plUUID pyVaultNode::GetCreateAgeGuid(void) const
@ -359,13 +342,7 @@ void pyVaultNode::SetCreatorNodeID( uint32_t v )
void pyVaultNode::SetCreateAgeName( const char * v )
{
free(fCreateAgeName);
fCreateAgeName = nil;
ASSERT(fNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, v, arrsize(str));
fNode->SetCreateAgeName(str);
fNode->SetCreateAgeName(v);
}
void pyVaultNode::SetCreateAgeGuid( const char * v )

1
Sources/Plasma/FeatureLib/pfPython/pyVaultNode.h

@ -99,7 +99,6 @@ public:
};
hsRef<RelVaultNode> fNode;
mutable char * fCreateAgeName;
protected:
// only for python glue, do NOT call

68
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp

@ -57,24 +57,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// should only be created from C++ side
pyVaultPlayerInfoNode::pyVaultPlayerInfoNode(RelVaultNode* nfsNode)
: pyVaultNode(nfsNode)
, ansiPlayerName(nil)
, ansiAgeInstName(nil)
{
}
//create from the Python side
pyVaultPlayerInfoNode::pyVaultPlayerInfoNode()
: pyVaultNode(new RelVaultNode)
, ansiPlayerName(nil)
, ansiAgeInstName(nil)
{
fNode->SetNodeType(plVault::kNodeType_PlayerInfo);
}
pyVaultPlayerInfoNode::~pyVaultPlayerInfoNode () {
free(ansiPlayerName);
free(ansiAgeInstName);
}
//==================================================================
// class RelVaultNode : public plVaultNode
@ -97,55 +89,39 @@ uint32_t pyVaultPlayerInfoNode::Player_GetPlayerID( void )
return playerInfo.GetPlayerId();
}
void pyVaultPlayerInfoNode::Player_SetPlayerName( const char * name )
void pyVaultPlayerInfoNode::Player_SetPlayerName(const plString& name)
{
if (!fNode)
return;
wchar_t * wStr = StrDupToUnicode(name);
VaultPlayerInfoNode playerInfo(fNode);
playerInfo.SetPlayerName(wStr);
free(wStr);
if (fNode) {
VaultPlayerInfoNode playerInfo(fNode);
playerInfo.SetPlayerName(name);
}
}
const char * pyVaultPlayerInfoNode::Player_GetPlayerName( void )
plString pyVaultPlayerInfoNode::Player_GetPlayerName() const
{
if (!fNode)
return "";
VaultPlayerInfoNode playerInfo(fNode);
if (!playerInfo.GetPlayerName())
return "";
free(ansiPlayerName);
ansiPlayerName = StrDupToAnsi(playerInfo.GetPlayerName());
return ansiPlayerName;
if (fNode) {
VaultPlayerInfoNode playerInfo(fNode);
return playerInfo.GetPlayerName();
}
return "";
}
// age the player is currently in, if any.
void pyVaultPlayerInfoNode::Player_SetAgeInstanceName( const char * agename )
void pyVaultPlayerInfoNode::Player_SetAgeInstanceName(const plString& name)
{
if (!fNode)
return;
wchar_t * wStr = StrDupToUnicode(agename);
VaultPlayerInfoNode playerInfo(fNode);
playerInfo.SetAgeInstName(wStr);
free(wStr);
if (fNode) {
VaultPlayerInfoNode playerInfo(fNode);
playerInfo.SetAgeInstName(name);
}
}
const char * pyVaultPlayerInfoNode::Player_GetAgeInstanceName( void )
plString pyVaultPlayerInfoNode::Player_GetAgeInstanceName() const
{
if (!fNode)
return "";
VaultPlayerInfoNode playerInfo(fNode);
if (!playerInfo.GetAgeInstName())
return "";
free(ansiAgeInstName);
ansiAgeInstName = StrDupToAnsi(playerInfo.GetAgeInstName());
return ansiAgeInstName;
if (fNode) {
VaultPlayerInfoNode playerInfo(fNode);
return playerInfo.GetAgeInstName();
}
return "";
}
void pyVaultPlayerInfoNode::Player_SetAgeGuid( const char * guidtext)

13
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h

@ -55,9 +55,6 @@ class plUUID;
class pyVaultPlayerInfoNode : public pyVaultNode
{
mutable char * ansiPlayerName;
mutable char * ansiAgeInstName;
protected:
// should only be created from C++ side
pyVaultPlayerInfoNode(RelVaultNode * node);
@ -66,7 +63,7 @@ protected:
pyVaultPlayerInfoNode();
public:
~pyVaultPlayerInfoNode ();
~pyVaultPlayerInfoNode() { }
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVaultPlayerInfoNode);
@ -82,12 +79,12 @@ public:
//
void Player_SetPlayerID( uint32_t plyrid );
uint32_t Player_GetPlayerID( void );
void Player_SetPlayerName( const char * name );
const char * Player_GetPlayerName( void );
void Player_SetPlayerName(const plString& name);
plString Player_GetPlayerName() const;
// age the player is currently in, if any.
void Player_SetAgeInstanceName( const char * agename );
const char * Player_GetAgeInstanceName( void );
void Player_SetAgeInstanceName(const plString& name);
plString Player_GetAgeInstanceName() const;
void Player_SetAgeGuid( const char * guidtext);
plUUID Player_GetAgeGuid(void) const;
// online status

4
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp

@ -89,7 +89,7 @@ PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultPlayerInfoNode, playerGetName)
{
return PyString_FromString(self->fThis->Player_GetPlayerName());
return PyString_FromPlString(self->fThis->Player_GetPlayerName());
}
PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeInstanceName, args)
@ -106,7 +106,7 @@ PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeInstanceName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultPlayerInfoNode, playerGetAgeInstanceName)
{
return PyString_FromString(self->fThis->Player_GetAgeInstanceName());
return PyString_FromPlString(self->fThis->Player_GetAgeInstanceName());
}
PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeGuid, args)

32
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp

@ -231,9 +231,7 @@ void pyVaultPlayerNode::RemoveVisitAgeLink(const char *guidstr)
PyObject *pyVaultPlayerNode::FindChronicleEntry(const char *entryName)
{
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, entryName, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wStr))
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(entryName))
return pyVaultChronicleNode::New(rvn);
PYTHON_RETURN_NONE;
@ -244,15 +242,13 @@ void pyVaultPlayerNode::SetPlayerName(const char *value)
hsAssert(false, "python may not change a player's name this way");
}
std::string pyVaultPlayerNode::GetPlayerName()
plString pyVaultPlayerNode::GetPlayerName() const
{
if (!fNode)
return "";
VaultPlayerNode player(fNode);
char ansiStr[MAX_PATH];
StrToAnsi(ansiStr, player.GetPlayerName(), arrsize(ansiStr));
return ansiStr;
if (fNode) {
VaultPlayerNode player(fNode);
return player.GetPlayerName();
}
return "";
}
void pyVaultPlayerNode::SetAvatarShapeName(const char *value)
@ -260,15 +256,13 @@ void pyVaultPlayerNode::SetAvatarShapeName(const char *value)
hsAssert(false, "python may not change a player's avatar this way");
}
std::string pyVaultPlayerNode::GetAvatarShapeName()
plString pyVaultPlayerNode::GetAvatarShapeName() const
{
if (!fNode)
return "";
VaultPlayerNode player(fNode);
char ansiStr[MAX_PATH];
StrToAnsi(ansiStr, player.GetAvatarShapeName(), arrsize(ansiStr));
return ansiStr;
if (fNode) {
VaultPlayerNode player(fNode);
return player.GetAvatarShapeName();
}
return "";
}
void pyVaultPlayerNode::SetDisabled(bool value)

6
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.h

@ -49,10 +49,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//////////////////////////////////////////////////////////////////////
#include "HeadSpin.h"
#include "pyGlueHelpers.h"
#include <string>
#include "pyVaultNode.h"
class pyAgeInfoStruct;
class plString;
struct RelVaultNode;
class pyVaultPlayerNode : public pyVaultNode
@ -101,10 +101,10 @@ public:
PyObject *FindChronicleEntry(const char *entryName); // returns pyVaultChronicleNode
void SetPlayerName(const char *value);
std::string GetPlayerName();
plString GetPlayerName() const;
void SetAvatarShapeName(const char *value);
std::string GetAvatarShapeName();
plString GetAvatarShapeName() const;
void SetDisabled(bool value);
bool IsDisabled();

11
Sources/Plasma/FeatureLib/pfPython/pyVaultSDLNode.cpp

@ -105,13 +105,10 @@ PyObject * pyVaultSDLNode::GetStateDataRecord() const
void pyVaultSDLNode::InitStateDataRecord( const char* agename, int flags)
{
if (!fNode)
return;
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, agename, arrsize(wStr));
VaultSDLNode sdl(fNode);
sdl.InitStateDataRecord(wStr, flags);
if (fNode) {
VaultSDLNode sdl(fNode);
sdl.InitStateDataRecord(agename, flags);
}
}
void pyVaultSDLNode::SetStateDataRecord( const pySDLStateDataRecord & rec, int writeOptions/*=0 */)

90
Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp

@ -75,14 +75,10 @@ pyVaultTextNoteNode::pyVaultTextNoteNode()
//
void pyVaultTextNoteNode::Note_SetTitle( const char * text )
{
if (!fNode)
return;
wchar_t wStr[MAX_PATH] = L"";
if (text)
StrToUnicode(wStr, text, arrsize(wStr));
VaultTextNoteNode textNote(fNode);
textNote.SetNoteTitle(wStr);
if (fNode) {
VaultTextNoteNode textNote(fNode);
textNote.SetNoteTitle(text);
}
}
void pyVaultTextNoteNode::Note_SetTitleW( const wchar_t * text )
@ -91,48 +87,24 @@ void pyVaultTextNoteNode::Note_SetTitleW( const wchar_t * text )
return;
VaultTextNoteNode textNote(fNode);
textNote.SetNoteTitle(text);
textNote.SetNoteTitle(plString::FromWchar(text));
}
std::string pyVaultTextNoteNode::Note_GetTitle( void )
plString pyVaultTextNoteNode::Note_GetTitle() const
{
if (!fNode)
return "";
char * aStr = nil;
VaultTextNoteNode textNote(fNode);
if (textNote.GetNoteTitle()) {
std::string result;
aStr = StrDupToAnsi(textNote.GetNoteTitle());
result = aStr;
free(aStr);
return result;
if (fNode) {
VaultTextNoteNode note(fNode);
return note.GetNoteTitle();
}
return "";
}
std::wstring pyVaultTextNoteNode::Note_GetTitleW( void )
void pyVaultTextNoteNode::Note_SetText(const char * text)
{
if (!fNode)
return L"";
VaultTextNoteNode textNote(fNode);
if (textNote.GetNoteTitle())
return textNote.GetNoteTitle();
return L"";
}
void pyVaultTextNoteNode::Note_SetText( const char * text )
{
if (!fNode)
return;
wchar_t * wStr = nil;
if (text)
wStr = StrDupToUnicode(text);
VaultTextNoteNode textNote(fNode);
textNote.SetNoteText(wStr);
free(wStr);
if (fNode) {
VaultTextNoteNode textNote(fNode);
textNote.SetNoteText(text);
}
}
void pyVaultTextNoteNode::Note_SetTextW( const wchar_t * text )
@ -141,37 +113,18 @@ void pyVaultTextNoteNode::Note_SetTextW( const wchar_t * text )
return;
VaultTextNoteNode textNote(fNode);
textNote.SetNoteText(text);
textNote.SetNoteText(plString::FromWchar(text));
}
std::string pyVaultTextNoteNode::Note_GetText( void )
plString pyVaultTextNoteNode::Note_GetText() const
{
if (!fNode)
return "";
char * aStr = nil;
VaultTextNoteNode textNote(fNode);
if (textNote.GetNoteText()) {
std::string result;
aStr = StrDupToAnsi(textNote.GetNoteText());
result = aStr;
free(aStr);
return result;
if (fNode) {
VaultTextNoteNode note(fNode);
return note.GetNoteText();
}
return "";
}
std::wstring pyVaultTextNoteNode::Note_GetTextW( void )
{
if (!fNode)
return L"";
VaultTextNoteNode textNote(fNode);
if (textNote.GetNoteText())
return textNote.GetNoteText();
return L"";
}
void pyVaultTextNoteNode::Note_SetType( int32_t type )
{
if (!fNode)
@ -225,10 +178,7 @@ void pyVaultTextNoteNode::SetDeviceInbox( const char * devName, PyObject * cbObj
pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject );
cb->VaultOperationStarted( cbContext );
wchar_t wDev[MAX_PATH];
StrToUnicode(wDev, devName, arrsize(wDev));
if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(wDev, DEFAULT_DEVICE_INBOX))
if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(devName, DEFAULT_DEVICE_INBOX))
cb->SetNode(rvn);
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here.

9
Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.h

@ -50,13 +50,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "pyGlueHelpers.h"
#include <string>
#include "pyVaultNode.h"
class plString;
struct RelVaultNode;
class pyVaultAgeLinkNode;
class pyVaultTextNoteNode : public pyVaultNode
{
protected:
@ -82,12 +81,10 @@ public:
//
void Note_SetTitle( const char * text );
void Note_SetTitleW( const wchar_t * text );
std::string Note_GetTitle( void );
std::wstring Note_GetTitleW( void );
plString Note_GetTitle() const;
void Note_SetText( const char * text );
void Note_SetTextW( const wchar_t * text );
std::string Note_GetText( void );
std::wstring Note_GetTextW( void );
plString Note_GetText() const;
void Note_SetType( int32_t type );
int32_t Note_GetType( void );

6
Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNodeGlue.cpp

@ -173,8 +173,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getTitle)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getTitleW)
{
std::wstring retVal = self->fThis->Note_GetTitleW();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
return PyUnicode_FromStringEx(self->fThis->Note_GetTitle());
}
PYTHON_METHOD_DEFINITION(ptVaultTextNoteNode, setText, args)
@ -225,8 +224,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getText)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getTextW)
{
std::wstring retVal = self->fThis->Note_GetTextW();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
return PyUnicode_FromStringEx(self->fThis->Note_GetText());
}
PYTHON_METHOD_DEFINITION(ptVaultTextNoteNode, setType, args)

896
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp

@ -53,9 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
namespace pnNpCommon {
// Verify our uint64_t constants were properly inited as such.
static_assert(NetVaultNode::kBlob_2, "NetVaultNode constants failed to init");
/*****************************************************************************
@ -297,605 +294,344 @@ void NetGameRank::CopyFrom(const NetGameRank & fromRank) {
***/
//============================================================================
void NetVaultNode::DeallocNodeFields () {
free(createAgeName);
free(string64_1);
free(string64_2);
free(string64_3);
free(string64_4);
free(string64_5);
free(string64_6);
free(istring64_1);
free(istring64_2);
free(text_1);
free(text_2);
free(blob_1);
free(blob_2);
void NetVaultNode::Blob::operator=(const Blob& rhs)
{
if (size != rhs.size) {
delete[] buffer;
buffer = new uint8_t[rhs.size];
size = rhs.size;
}
memcpy(buffer, rhs.buffer, rhs.size);
}
//============================================================================
NetVaultNode::NetVaultNode ()
: hsRefCnt(0), fieldFlags(0), dirtyFlags(0)
, nodeId(0), createTime(0), modifyTime(0)
, createAgeName(nil), creatorId(0)
, nodeType(0)
, int32_1(0), int32_2(0), int32_3(0), int32_4(0)
, uint32_1(0), uint32_2(0), uint32_3(0), uint32_4(0)
, string64_1(nil), string64_2(nil), string64_3(nil), string64_4(nil)
, string64_5(nil), string64_6(nil)
, istring64_1(nil), istring64_2(nil)
, text_1(nil), text_2(nil)
, blob_1(nil), blob_1Length(0), blob_2(nil), blob_2Length(0) { }
//============================================================================
NetVaultNode::~NetVaultNode () {
DeallocNodeFields();
void NetVaultNode::Blob::operator=(Blob&& rhs)
{
delete[] buffer;
size = rhs.size;
buffer = rhs.buffer;
rhs.size = 0;
rhs.buffer = nullptr;
}
//============================================================================
uint32_t NetVaultNode::Read_LCS (const uint8_t inbuffer[], uint32_t bufsz, unsigned rwOpts) {
DeallocNodeFields();
uint8_t * buffer = const_cast<uint8_t *>(inbuffer);
uint8_t * start = buffer;
IReadValue(&fieldFlags, &buffer, &bufsz);
#define READ(flag, func, varptr) if (flag & fieldFlags) func(varptr, &buffer, &bufsz);
#define READARR(flag, func, varptr, lenptr) if (flag & fieldFlags) func(varptr, lenptr, &buffer, &bufsz);
READ(kNodeId, IReadValue, &nodeId);
READ(kCreateTime, IReadValue, &createTime);
READ(kModifyTime, IReadValue, &modifyTime);
READ(kCreateAgeName,IReadString, &createAgeName);
READ(kCreateAgeUuid,IReadValue, &createAgeUuid);
READ(kCreatorAcct, IReadValue, &creatorAcct);
READ(kCreatorId, IReadValue, &creatorId);
READ(kNodeType, IReadValue, &nodeType);
READ(kInt32_1, IReadValue, &int32_1);
READ(kInt32_2, IReadValue, &int32_2);
READ(kInt32_3, IReadValue, &int32_3);
READ(kInt32_4, IReadValue, &int32_4);
READ(kUInt32_1, IReadValue, &uint32_1);
READ(kUInt32_2, IReadValue, &uint32_2);
READ(kUInt32_3, IReadValue, &uint32_3);
READ(kUInt32_4, IReadValue, &uint32_4);
READ(kUuid_1, IReadValue, &uuid_1);
READ(kUuid_2, IReadValue, &uuid_2);
READ(kUuid_3, IReadValue, &uuid_3);
READ(kUuid_4, IReadValue, &uuid_4);
READ(kString64_1, IReadString, &string64_1);
READ(kString64_2, IReadString, &string64_2);
READ(kString64_3, IReadString, &string64_3);
READ(kString64_4, IReadString, &string64_4);
READ(kString64_5, IReadString, &string64_5);
READ(kString64_6, IReadString, &string64_6);
READ(kIString64_1, IReadString, &istring64_1);
READ(kIString64_2, IReadString, &istring64_2);
READ(kText_1, IReadString, &text_1);
READ(kText_2, IReadString, &text_2);
READARR(kBlob_1, IReadArray, &blob_1, &blob_1Length);
READARR(kBlob_2, IReadArray, &blob_2, &blob_2Length);
#undef READARR
#undef READ
if (fieldFlags & ~kAllValidFields)
FATAL("Invalid field flag(s) encountered");
if (rwOpts & kRwUpdateDirty)
dirtyFlags = fieldFlags;
else
dirtyFlags = 0;
return buffer - start;
}
//============================================================================
uint32_t NetVaultNode::Write_LCS (ARRAY(uint8_t) * buffer, unsigned rwOpts) {
unsigned pos = buffer->Count();
uint64_t flags = fieldFlags;
if (rwOpts & kRwDirtyOnly)
flags &= dirtyFlags;
if (!flags)
return 0;
IWriteValue(flags, buffer);
#define WRITE(flag, func, var) if (flag & flags) func(var, buffer);
#define WRITEARR(flag, func, var, len) if (flag & flags) func(var, len, buffer);
WRITE(kNodeId, IWriteValue, nodeId );
WRITE(kCreateTime, IWriteValue, createTime );
WRITE(kModifyTime, IWriteValue, modifyTime );
WRITE(kCreateAgeName, IWriteString, createAgeName ? createAgeName : L"" );
WRITE(kCreateAgeUuid, IWriteValue, createAgeUuid );
WRITE(kCreatorAcct, IWriteValue, creatorAcct );
WRITE(kCreatorId, IWriteValue, creatorId );
WRITE(kNodeType, IWriteValue, nodeType );
WRITE(kInt32_1, IWriteValue, int32_1 );
WRITE(kInt32_2, IWriteValue, int32_2 );
WRITE(kInt32_3, IWriteValue, int32_3 );
WRITE(kInt32_4, IWriteValue, int32_4 );
WRITE(kUInt32_1, IWriteValue, uint32_1 );
WRITE(kUInt32_2, IWriteValue, uint32_2 );
WRITE(kUInt32_3, IWriteValue, uint32_3 );
WRITE(kUInt32_4, IWriteValue, uint32_4 );
WRITE(kUuid_1, IWriteValue, uuid_1 );
WRITE(kUuid_2, IWriteValue, uuid_2 );
WRITE(kUuid_3, IWriteValue, uuid_3 );
WRITE(kUuid_4, IWriteValue, uuid_4 );
WRITE(kString64_1, IWriteString, string64_1 ? string64_1 : L"" );
WRITE(kString64_2, IWriteString, string64_2 ? string64_2 : L"" );
WRITE(kString64_3, IWriteString, string64_3 ? string64_3 : L"" );
WRITE(kString64_4, IWriteString, string64_4 ? string64_4 : L"" );
WRITE(kString64_5, IWriteString, string64_5 ? string64_5 : L"" );
WRITE(kString64_6, IWriteString, string64_6 ? string64_6 : L"" );
WRITE(kIString64_1, IWriteString, istring64_1 ? istring64_1 : L"" );
WRITE(kIString64_2, IWriteString, istring64_2 ? istring64_2 : L"" );
WRITE(kText_1, IWriteString, text_1 ? text_1 : L"" );
WRITE(kText_2, IWriteString, text_2 ? text_2 : L"" );
WRITEARR(kBlob_1, IWriteArray, blob_1, blob_1Length);
WRITEARR(kBlob_2, IWriteArray, blob_2, blob_2Length);
#undef WRITEARR
#undef WRITE
if (flags & ~kAllValidFields)
FATAL("Invalid field flag(s) encountered");
if (rwOpts & kRwUpdateDirty)
dirtyFlags = 0;
// else, preserve existing dirtyFlags value
return buffer->Count() - pos;
bool NetVaultNode::Blob::operator==(const Blob& rhs) const
{
if (size == rhs.size)
return memcmp(buffer, rhs.buffer, size) == 0;
return false;
}
//============================================================================
bool NetVaultNode::Matches (const NetVaultNode * other) {
void NetVaultNode::Clear()
{
// Sneaky -- we're just going to set the fields to empty.
// If a field is neither used nor dirty, it doesn't matter what value it actually has.
fUsedFields = 0;
fDirtyFields = 0;
fRevision = kNilUuid;
}
//============================================================================
template<typename T>
static void IZero(T& dest)
{
dest = 0;
}
template<>
static void IZero<plString>(plString& dest)
{
dest = "";
}
template<>
static void IZero<plUUID>(plUUID& dest)
{
dest = kNilUuid;
}
template<>
static void IZero<NetVaultNode::Blob>(NetVaultNode::Blob& blob)
{
delete[] blob.buffer;
blob.buffer = nullptr;
blob.size = 0;
}
void NetVaultNode::CopyFrom(const NetVaultNode* node)
{
fUsedFields = node->fUsedFields;
fDirtyFields = node->fDirtyFields;
fRevision = node->fRevision;
#define COPYORZERO(field) \
if (fUsedFields & k##field) \
f##field = node->f##field; \
else \
IZero(f##field);
COPYORZERO(NodeId);
COPYORZERO(CreateTime);
COPYORZERO(ModifyTime);
COPYORZERO(CreateAgeName);
COPYORZERO(CreateAgeUuid);
COPYORZERO(CreatorAcct);
COPYORZERO(CreatorId);
COPYORZERO(NodeType);
COPYORZERO(Int32_1);
COPYORZERO(Int32_2);
COPYORZERO(Int32_3);
COPYORZERO(Int32_4);
COPYORZERO(UInt32_1);
COPYORZERO(UInt32_2);
COPYORZERO(UInt32_3);
COPYORZERO(UInt32_4);
COPYORZERO(Uuid_1);
COPYORZERO(Uuid_2);
COPYORZERO(Uuid_3);
COPYORZERO(Uuid_4);
COPYORZERO(String64_1);
COPYORZERO(String64_2);
COPYORZERO(String64_3);
COPYORZERO(String64_4);
COPYORZERO(String64_5);
COPYORZERO(String64_6);
COPYORZERO(IString64_1);
COPYORZERO(IString64_2);
COPYORZERO(Text_1);
COPYORZERO(Text_2);
COPYORZERO(Blob_1);
COPYORZERO(Blob_2);
#undef COPYORZERO
}
//============================================================================
bool NetVaultNode::Matches(const NetVaultNode* rhs) const
{
for (uint64_t bit = 1; bit; bit <<= 1) {
// if bit has gone past all set fields on the other node without failing, return true
if (bit > other->fieldFlags)
// If we have tested all fields on the other node, we obviously match.
if (bit > rhs->fUsedFields)
return true;
// if the other node does not have the field, then continue to next field
if (!(bit & other->fieldFlags))
// If the other node does not have the field, then continue to next field
if (!(bit & rhs->fUsedFields))
continue;
// if we don't have the field (but the other node does), then return false
if (!(bit & fieldFlags))
// If we don't have this field, but the other node does, we are obviously not the same.
if (!(bit & fUsedFields))
return false;
#define COMPARE(flag, func, var) case flag: if (!func(var, other->var)) return false; break
switch (bit) {
COMPARE(kNodeId, ICompareValue, nodeId);
COMPARE(kCreateTime, ICompareValue, createTime);
COMPARE(kModifyTime, ICompareValue, modifyTime);
COMPARE(kCreateAgeName, ICompareStringI, createAgeName);
COMPARE(kCreateAgeUuid, ICompareValue, createAgeUuid);
COMPARE(kCreatorAcct, ICompareValue, creatorAcct);
COMPARE(kCreatorId, ICompareValue, creatorId);
COMPARE(kNodeType, ICompareValue, nodeType);
COMPARE(kInt32_1, ICompareValue, int32_1);
COMPARE(kInt32_2, ICompareValue, int32_2);
COMPARE(kInt32_3, ICompareValue, int32_3);
COMPARE(kInt32_4, ICompareValue, int32_4);
COMPARE(kUInt32_1, ICompareValue, uint32_1);
COMPARE(kUInt32_2, ICompareValue, uint32_2);
COMPARE(kUInt32_3, ICompareValue, uint32_3);
COMPARE(kUInt32_4, ICompareValue, uint32_4);
COMPARE(kUuid_1, ICompareValue, uuid_1);
COMPARE(kUuid_2, ICompareValue, uuid_2);
COMPARE(kUuid_3, ICompareValue, uuid_3);
COMPARE(kUuid_4, ICompareValue, uuid_4);
COMPARE(kString64_1, ICompareString, string64_1);
COMPARE(kString64_2, ICompareString, string64_2);
COMPARE(kString64_3, ICompareString, string64_3);
COMPARE(kString64_4, ICompareString, string64_4);
COMPARE(kString64_5, ICompareString, string64_5);
COMPARE(kString64_6, ICompareString, string64_6);
COMPARE(kIString64_1, ICompareStringI, istring64_1);
COMPARE(kIString64_2, ICompareStringI, istring64_2);
COMPARE(kText_1, ICompareString, text_1);
COMPARE(kText_2, ICompareString, text_2);
COMPARE(kBlob_1, ICompareArray, blob_1);
COMPARE(kBlob_2, ICompareArray, blob_2);
DEFAULT_FATAL(bit);
}
#undef COMPARE
#define COMPARE(field) if (k##field == bit && f##field != rhs->f##field) return false;
#define COMPARE_ISTRING(field) if (k##field == bit && f##field.CompareI(rhs->f##field) != 0) return false;
COMPARE(NodeId);
COMPARE(CreateTime);
COMPARE(ModifyTime);
COMPARE_ISTRING(CreateAgeName);
COMPARE(CreateAgeUuid);
COMPARE(CreatorAcct);
COMPARE(CreatorId);
COMPARE(NodeType);
COMPARE(Int32_1);
COMPARE(Int32_2);
COMPARE(Int32_3);
COMPARE(Int32_4);
COMPARE(UInt32_1);
COMPARE(UInt32_2);
COMPARE(UInt32_3);
COMPARE(UInt32_4);
COMPARE(Uuid_1);
COMPARE(Uuid_2);
COMPARE(Uuid_3);
COMPARE(Uuid_4);
COMPARE(String64_1);
COMPARE(String64_2);
COMPARE(String64_3);
COMPARE(String64_4);
COMPARE(String64_5);
COMPARE(String64_6);
COMPARE_ISTRING(IString64_1);
COMPARE_ISTRING(IString64_2);
COMPARE(Text_1);
COMPARE(Text_2);
COMPARE(Blob_1);
COMPARE(Blob_2);
#undef COMPARE
#undef COMPARE_ISTRING
}
return true;
}
//============================================================================
void NetVaultNode::CopyFrom (const NetVaultNode * other, unsigned copyOpts) {
if (this == other)
return;
uint64_t origDirtyFlags = dirtyFlags;
for (uint64_t bit = 1; bit; bit <<= 1) {
// we already have a value for this field...
if (bit & fieldFlags) {
if (!(copyOpts & kCopyOverwrite))
continue; // don't overwrite our field value
}
// other does not have a value for this field...
if (!(bit & other->fieldFlags)) {
// clear our field?
if (!(copyOpts & kCopyClear))
continue;
// clear our field.
if (bit & fieldFlags) {
#define _ZERO(flag, func, var, z) case flag: func(bit, &var, z); break
#define _ZEROSTRING(flag, func, var, z) case flag: func(bit, &var, z, kMaxVaultNodeStringLength); break
#define _ZEROCLOB(flag, func, var, z) case flag: func(bit, &var, z, (unsigned)-1); break
#define _ZEROARR(flag, func, var, varlen) case flag: func(bit, &var, &varlen, nil, 0); break
switch (bit) {
_ZERO(kNodeId, IVaultNodeSetValue, nodeId, (unsigned)0);
_ZERO(kCreateTime, IVaultNodeSetValue, createTime, (unsigned)0);
_ZERO(kModifyTime, IVaultNodeSetValue, modifyTime, (unsigned)0);
_ZEROSTRING(kCreateAgeName, IVaultNodeSetString, createAgeName, L"");
_ZERO(kCreateAgeUuid, IVaultNodeSetValue, createAgeUuid, kNilUuid);
_ZERO(kCreatorAcct, IVaultNodeSetValue, creatorAcct, kNilUuid);
_ZERO(kCreatorId, IVaultNodeSetValue, creatorId, (unsigned)0);
_ZERO(kNodeType, IVaultNodeSetValue, nodeType, (unsigned)0);
_ZERO(kInt32_1, IVaultNodeSetValue, int32_1, (signed)0);
_ZERO(kInt32_2, IVaultNodeSetValue, int32_2, (signed)0);
_ZERO(kInt32_3, IVaultNodeSetValue, int32_3, (signed)0);
_ZERO(kInt32_4, IVaultNodeSetValue, int32_4, (signed)0);
_ZERO(kUInt32_1, IVaultNodeSetValue, uint32_1, (unsigned)0);
_ZERO(kUInt32_2, IVaultNodeSetValue, uint32_2, (unsigned)0);
_ZERO(kUInt32_3, IVaultNodeSetValue, uint32_3, (unsigned)0);
_ZERO(kUInt32_4, IVaultNodeSetValue, uint32_4, (unsigned)0);
_ZERO(kUuid_1, IVaultNodeSetValue, uuid_1, kNilUuid);
_ZERO(kUuid_2, IVaultNodeSetValue, uuid_2, kNilUuid);
_ZERO(kUuid_3, IVaultNodeSetValue, uuid_3, kNilUuid);
_ZERO(kUuid_4, IVaultNodeSetValue, uuid_4, kNilUuid);
_ZEROSTRING(kString64_1, IVaultNodeSetString, string64_1, L"");
_ZEROSTRING(kString64_2, IVaultNodeSetString, string64_2, L"");
_ZEROSTRING(kString64_3, IVaultNodeSetString, string64_3, L"");
_ZEROSTRING(kString64_4, IVaultNodeSetString, string64_4, L"");
_ZEROSTRING(kString64_5, IVaultNodeSetString, string64_5, L"");
_ZEROSTRING(kString64_6, IVaultNodeSetString, string64_6, L"");
_ZEROSTRING(kIString64_1, IVaultNodeSetString, istring64_1, L"");
_ZEROSTRING(kIString64_2, IVaultNodeSetString, istring64_2, L"");
_ZEROCLOB(kText_1, IVaultNodeSetString, text_1, L"");
_ZEROCLOB(kText_2, IVaultNodeSetString, text_2, L"");
_ZEROARR(kBlob_1, IVaultNodeSetBlob, blob_1, blob_1Length);
_ZEROARR(kBlob_2, IVaultNodeSetBlob, blob_2, blob_2Length);
DEFAULT_FATAL(bit);
}
#undef _ZEROARR
#undef _ZEROCLOB
#undef _ZEROSTRING
#undef _ZERO
}
}
#define COPY(flag, func, var) case flag: func(bit, &var, other->var); break
#define COPYSTRING(flag, func, var) case flag: func(bit, &var, other->var, kMaxVaultNodeStringLength); break
#define COPYCLOB(flag, func, var) case flag: func(bit, &var, other->var, (unsigned)-1); break
#define COPYARR(flag, func, var, varlen) case flag: func(bit, &var, &varlen, other->var, other->varlen); break
switch (bit) {
COPY(kNodeId, IVaultNodeSetValue, nodeId );
COPY(kCreateTime, IVaultNodeSetValue, createTime );
COPY(kModifyTime, IVaultNodeSetValue, modifyTime );
COPYSTRING(kCreateAgeName, IVaultNodeSetString, createAgeName );
COPY(kCreateAgeUuid, IVaultNodeSetValue, createAgeUuid );
COPY(kCreatorAcct, IVaultNodeSetValue, creatorAcct );
COPY(kCreatorId, IVaultNodeSetValue, creatorId );
COPY(kNodeType, IVaultNodeSetValue, nodeType );
COPY(kInt32_1, IVaultNodeSetValue, int32_1 );
COPY(kInt32_2, IVaultNodeSetValue, int32_2 );
COPY(kInt32_3, IVaultNodeSetValue, int32_3 );
COPY(kInt32_4, IVaultNodeSetValue, int32_4 );
COPY(kUInt32_1, IVaultNodeSetValue, uint32_1 );
COPY(kUInt32_2, IVaultNodeSetValue, uint32_2 );
COPY(kUInt32_3, IVaultNodeSetValue, uint32_3 );
COPY(kUInt32_4, IVaultNodeSetValue, uint32_4 );
COPY(kUuid_1, IVaultNodeSetValue, uuid_1 );
COPY(kUuid_2, IVaultNodeSetValue, uuid_2 );
COPY(kUuid_3, IVaultNodeSetValue, uuid_3 );
COPY(kUuid_4, IVaultNodeSetValue, uuid_4 );
COPYSTRING(kString64_1, IVaultNodeSetString, string64_1 );
COPYSTRING(kString64_2, IVaultNodeSetString, string64_2 );
COPYSTRING(kString64_3, IVaultNodeSetString, string64_3 );
COPYSTRING(kString64_4, IVaultNodeSetString, string64_4 );
COPYSTRING(kString64_5, IVaultNodeSetString, string64_5 );
COPYSTRING(kString64_6, IVaultNodeSetString, string64_6 );
COPYSTRING(kIString64_1, IVaultNodeSetString, istring64_1 );
COPYSTRING(kIString64_2, IVaultNodeSetString, istring64_2 );
COPYCLOB(kText_1, IVaultNodeSetString, text_1 );
COPYCLOB(kText_2, IVaultNodeSetString, text_2 );
COPYARR(kBlob_1, IVaultNodeSetBlob, blob_1, blob_1Length);
COPYARR(kBlob_2, IVaultNodeSetBlob, blob_2, blob_2Length);
DEFAULT_FATAL(bit);
}
#undef COPYARR
#undef COPYCLOB
#undef COPYSTRING
#undef COPY
}
if (!(copyOpts & kCopySetDirty))
dirtyFlags = origDirtyFlags;
}
//============================================================================
void NetVaultNode::SetNodeId (unsigned v) {
IVaultNodeSetValue(kNodeId, &nodeId, v);
}
//============================================================================
void NetVaultNode::SetCreateTime (unsigned v) {
IVaultNodeSetValue(kCreateTime, &createTime, v);
}
//============================================================================
void NetVaultNode::SetModifyTime (unsigned v) {
IVaultNodeSetValue(kModifyTime, &modifyTime, v);
}
//============================================================================
void NetVaultNode::SetCreateAgeName (const wchar_t v[]) {
IVaultNodeSetString(kCreateAgeName, &createAgeName, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetCreateAgeUuid (const plUUID& v) {
IVaultNodeSetValue(kCreateAgeUuid, &createAgeUuid, v);
}
//============================================================================
void NetVaultNode::SetCreatorAcct (const plUUID& v) {
IVaultNodeSetValue(kCreatorAcct, &creatorAcct, v);
}
//============================================================================
void NetVaultNode::SetCreatorId (unsigned v) {
IVaultNodeSetValue(kCreatorId, &creatorId, v);
}
//============================================================================
void NetVaultNode::SetNodeType (unsigned v) {
IVaultNodeSetValue(kNodeType, &nodeType, v);
}
//============================================================================
void NetVaultNode::SetInt32_1 (int v) {
IVaultNodeSetValue(kInt32_1, &int32_1, v);
}
//============================================================================
void NetVaultNode::SetInt32_2 (int v) {
IVaultNodeSetValue(kInt32_2, &int32_2, v);
}
//============================================================================
void NetVaultNode::SetInt32_3 (int v) {
IVaultNodeSetValue(kInt32_3, &int32_3, v);
}
//============================================================================
void NetVaultNode::SetInt32_4 (int v) {
IVaultNodeSetValue(kInt32_4, &int32_4, v);
}
//============================================================================
void NetVaultNode::SetUInt32_1 (unsigned v) {
IVaultNodeSetValue(kUInt32_1, &uint32_1, v);
}
//============================================================================
void NetVaultNode::SetUInt32_2 (unsigned v) {
IVaultNodeSetValue(kUInt32_2, &uint32_2, v);
}
//============================================================================
void NetVaultNode::SetUInt32_3 (unsigned v) {
IVaultNodeSetValue(kUInt32_3, &uint32_3, v);
}
//============================================================================
void NetVaultNode::SetUInt32_4 (unsigned v) {
IVaultNodeSetValue(kUInt32_4, &uint32_4, v);
}
//============================================================================
void NetVaultNode::SetUuid_1 (const plUUID& v) {
IVaultNodeSetValue(kUuid_1, &uuid_1, v);
}
//============================================================================
void NetVaultNode::SetUuid_2 (const plUUID& v) {
IVaultNodeSetValue(kUuid_2, &uuid_2, v);
}
//============================================================================
void NetVaultNode::SetUuid_3 (const plUUID& v) {
IVaultNodeSetValue(kUuid_3, &uuid_3, v);
}
//============================================================================
void NetVaultNode::SetUuid_4 (const plUUID& v) {
IVaultNodeSetValue(kUuid_4, &uuid_4, v);
}
//============================================================================
void NetVaultNode::SetString64_1 (const wchar_t v[]) {
IVaultNodeSetString(kString64_1, &string64_1, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetString64_2 (const wchar_t v[]) {
IVaultNodeSetString(kString64_2, &string64_2, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetString64_3 (const wchar_t v[]) {
IVaultNodeSetString(kString64_3, &string64_3, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetString64_4 (const wchar_t v[]) {
IVaultNodeSetString(kString64_4, &string64_4, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetString64_5 (const wchar_t v[]) {
IVaultNodeSetString(kString64_5, &string64_5, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetString64_6 (const wchar_t v[]) {
IVaultNodeSetString(kString64_6, &string64_6, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetIString64_1 (const wchar_t v[]) {
IVaultNodeSetString(kIString64_1, &istring64_1, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetIString64_2 (const wchar_t v[]) {
IVaultNodeSetString(kIString64_2, &istring64_2, v, kMaxVaultNodeStringLength);
}
//============================================================================
void NetVaultNode::SetText_1 (const wchar_t v[]) {
IVaultNodeSetString(kText_1, &text_1, v, (unsigned)-1);
}
//============================================================================
void NetVaultNode::SetText_2 (const wchar_t v[]) {
IVaultNodeSetString(kText_2, &text_2, v, (unsigned)-1);
}
//============================================================================
void NetVaultNode::SetBlob_1 (const uint8_t v[], uint32_t len) {
IVaultNodeSetBlob(kBlob_1, &blob_1, &blob_1Length, v, len);
}
//============================================================================
void NetVaultNode::SetBlob_2 (const uint8_t v[], uint32_t len) {
IVaultNodeSetBlob(kBlob_2, &blob_2, &blob_2Length, v, len);
}
/*****************************************************************************
*
* CSrvPackBuffer
*
***/
//============================================================================
CSrvPackBuffer::CSrvPackBuffer (unsigned bytes) {
m_data = (uint8_t *)malloc(bytes);
m_pos = m_data;
m_end = m_pos + bytes;
}
//============================================================================
void * CSrvPackBuffer::Alloc (unsigned bytes) {
ASSERT((signed) bytes >= 0);
ASSERT(m_pos + bytes <= m_end);
uint8_t * pos = m_pos;
m_pos += bytes;
return pos;
}
//============================================================================
void CSrvPackBuffer::AddData (const void * ptr, unsigned bytes) {
memcpy(Alloc(bytes), ptr, bytes);
}
//============================================================================
void CSrvPackBuffer::AddString (const wchar_t str[]) {
AddData(str, StrBytes(str));
}
//============================================================================
void CSrvPackBuffer::AddDWordArray (const uint32_t * arr, unsigned count) {
// Don't let large counts cause pointer wrap
count &= 0x00ffffff;
AddData(arr, count * sizeof(arr[0]));
}
//============================================================================
unsigned CSrvPackBuffer::Size () {
return m_pos - m_data;
}
/*****************************************************************************
*
* CSrvUnpackBuffer
*
***/
//============================================================================
CSrvUnpackBuffer::CSrvUnpackBuffer (const void * buffer, unsigned count) {
m_pos = (const uint8_t *) buffer;
m_end = m_pos + count;
// We should never get here, but this silences a warning.
return true;
}
//============================================================================
const void * CSrvUnpackBuffer::GetData (unsigned bytes) {
for (;;) {
const uint8_t * result = m_pos;
m_pos += bytes;
if (m_pos < result)
break;
if (m_pos > m_end)
break;
return result;
template<typename T>
static void IRead(const uint8_t*& buf, T& dest)
{
const T* ptr = reinterpret_cast<const T*>(buf);
dest = *ptr;
buf += sizeof(T);
}
template<>
static void IRead<plString>(const uint8_t*& buf, plString& dest)
{
uint32_t size = *(reinterpret_cast<const uint32_t*>(buf));
uint32_t arraySize = size / 2;
buf += sizeof(uint32_t);
plStringBuffer<uint16_t> str;
uint16_t* theStrBuffer = str.CreateWritableBuffer(arraySize - 1);
memcpy(theStrBuffer, buf, size);
theStrBuffer[arraySize - 1] = 0;
dest = plString::FromUtf16(str);
buf += size;
}
template<>
static void IRead<NetVaultNode::Blob>(const uint8_t*& buf, NetVaultNode::Blob& blob)
{
blob.size = *(reinterpret_cast<const uint32_t*>(buf));
buf += sizeof(uint32_t);
delete[] blob.buffer;
blob.buffer = new uint8_t[blob.size];
memcpy(blob.buffer, buf, blob.size);
buf += blob.size;
}
void NetVaultNode::Read(const uint8_t* buf, size_t size)
{
fUsedFields= *(reinterpret_cast<const uint64_t*>(buf));
buf += sizeof(uint64_t);
#define READ(field) if (fUsedFields & k##field) IRead(buf, f##field);
READ(NodeId);
READ(CreateTime);
READ(ModifyTime);
READ(CreateAgeName);
READ(CreateAgeUuid);
READ(CreatorAcct);
READ(CreatorId);
READ(NodeType);
READ(Int32_1);
READ(Int32_2);
READ(Int32_3);
READ(Int32_4);
READ(UInt32_1);
READ(UInt32_2);
READ(UInt32_3);
READ(UInt32_4);
READ(Uuid_1);
READ(Uuid_2);
READ(Uuid_3);
READ(Uuid_4);
READ(String64_1);
READ(String64_2);
READ(String64_3);
READ(String64_4);
READ(String64_5);
READ(String64_6);
READ(IString64_1);
READ(IString64_2);
READ(Text_1);
READ(Text_2);
READ(Blob_1);
READ(Blob_2);
#undef READ
fDirtyFields = 0;
}
//============================================================================
template<typename T>
static void IWrite(ARRAY(uint8_t)* buffer, T value)
{
uint8_t* ptr = buffer->New(sizeof(T));
memcpy(ptr, &value, sizeof(T));
}
template<>
static void IWrite<plString>(ARRAY(uint8_t)* buffer, plString value)
{
plStringBuffer<uint16_t> utf16 = value.ToUtf16();
uint32_t strsz = (utf16.GetSize() + 1) * 2;
IWrite(buffer, strsz);
uint8_t* ptr = buffer->New(strsz);
memcpy(ptr, utf16.GetData(), strsz);
}
template<>
static void IWrite<const NetVaultNode::Blob&>(ARRAY(uint8_t)* buffer, const NetVaultNode::Blob& blob)
{
IWrite(buffer, static_cast<uint32_t>(blob.size));
if (blob.size > 0) {
uint8_t* ptr = buffer->New(blob.size);
memcpy(ptr, blob.buffer, blob.size);
}
m_end = nil;
return nil;
}
//============================================================================
const wchar_t * CSrvUnpackBuffer::GetString () {
if (m_end) {
const wchar_t * end = (const wchar_t *) (m_end - sizeof(wchar_t) + 1);
for (const wchar_t * cur = (const wchar_t *) m_pos; cur < end; ) {
if (*cur++)
continue;
const wchar_t * pos = (const wchar_t *) m_pos;
m_pos = (const uint8_t *) cur;
return pos;
}
}
m_end = NULL;
return NULL;
}
//============================================================================
const uint32_t * CSrvUnpackBuffer::GetDWordArray (unsigned count) {
// Don't let large counts cause pointer wrap
if (count & 0x00ffffff)
return (const uint32_t *)GetData(count * sizeof(uint32_t));
m_end = nil;
return nil;
}
//============================================================================
unsigned CSrvUnpackBuffer::BytesLeft () {
return m_end ? m_end - m_pos : 0;
}
//============================================================================
bool CSrvUnpackBuffer::ParseError () {
return !m_end;
void NetVaultNode::Write(ARRAY(uint8_t)* buf, uint32_t ioFlags)
{
uint64_t flags = fUsedFields;
if (ioFlags & kDirtyNodeType)
fDirtyFields |= kNodeType;
if (ioFlags & kDirtyString64_1)
fDirtyFields |= kString64_1;
if (ioFlags & kDirtyOnly)
flags &= fDirtyFields;
IWrite(buf, flags);
#define WRITE(field) if (flags & k##field) IWrite(buf, f##field);
WRITE(NodeId);
WRITE(CreateTime);
WRITE(ModifyTime);
WRITE(CreateAgeName);
WRITE(CreateAgeUuid);
WRITE(CreatorAcct);
WRITE(CreatorId);
WRITE(NodeType);
WRITE(Int32_1);
WRITE(Int32_2);
WRITE(Int32_3);
WRITE(Int32_4);
WRITE(UInt32_1);
WRITE(UInt32_2);
WRITE(UInt32_3);
WRITE(UInt32_4);
WRITE(Uuid_1);
WRITE(Uuid_2);
WRITE(Uuid_3);
WRITE(Uuid_4);
WRITE(String64_1);
WRITE(String64_2);
WRITE(String64_3);
WRITE(String64_4);
WRITE(String64_5);
WRITE(String64_6);
WRITE(IString64_1);
WRITE(IString64_2);
WRITE(Text_1);
WRITE(Text_2);
WRITE(Blob_1);
WRITE(Blob_2);
#undef WRITE
if (ioFlags & kClearDirty)
fDirtyFields = 0;
}
//============================================================================
void NetVaultNode::ISetVaultBlob(uint64_t bits, NetVaultNode::Blob& blob, const uint8_t* buf, size_t size)
{
delete[] blob.buffer;
blob.buffer = new uint8_t[size];
blob.size = size;
memcpy(blob.buffer, buf, size);
fUsedFields |= bits;
fDirtyFields |= bits;
}

510
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h

@ -153,315 +153,253 @@ struct NetGameRank {
*
***/
//============================================================================
// NetVaultNode
//============================================================================
// Threaded apps: App is responsible for locking node->critsect before accessing *any* field in this struct
struct NetVaultNode : hsRefCnt {
enum RwOptions {
kRwDirtyOnly = 1<<0, // READ : No meaning
// WRITE: Only write fields marked dirty
kRwUpdateDirty = 1<<1, // READ : Set dirty flag on fields read from stream
// WRITE: Clear dirty flag on fields written to stream
class NetVaultNode : public hsRefCnt
{
protected:
enum NodeFields
{
kNodeId = (1 << 0),
kCreateTime = (1 << 1),
kModifyTime = (1 << 2),
kCreateAgeName = (1 << 3),
kCreateAgeUuid = (1 << 4),
kCreatorAcct = (1 << 5),
kCreatorId = (1 << 6),
kNodeType = (1 << 7),
kInt32_1 = (1 << 8),
kInt32_2 = (1 << 9),
kInt32_3 = (1 << 10),
kInt32_4 = (1 << 11),
kUInt32_1 = (1 << 12),
kUInt32_2 = (1 << 13),
kUInt32_3 = (1 << 14),
kUInt32_4 = (1 << 15),
kUuid_1 = (1 << 16),
kUuid_2 = (1 << 17),
kUuid_3 = (1 << 18),
kUuid_4 = (1 << 19),
kString64_1 = (1 << 20),
kString64_2 = (1 << 21),
kString64_3 = (1 << 22),
kString64_4 = (1 << 23),
kString64_5 = (1 << 24),
kString64_6 = (1 << 25),
kIString64_1 = (1 << 26),
kIString64_2 = (1 << 27),
kText_1 = (1 << 28),
kText_2 = (1 << 29),
kBlob_1 = (1 << 30),
kBlob_2 = (1 << 31),
kValidFields = (kNodeId | kCreateTime | kModifyTime | kCreateAgeName | kCreateAgeUuid |
kCreatorAcct | kCreatorId | kNodeType | kInt32_1 | kInt32_2 | kInt32_3 |
kInt32_4 | kUInt32_1 | kUInt32_2 | kUInt32_3 | kUInt32_3 | kUInt32_4 |
kUuid_1 | kUuid_2 | kUuid_3 | kUuid_4 | kString64_1 | kString64_2 |
kString64_3 | kString64_4 | kString64_5 | kString64_6 | kIString64_1 |
kIString64_2 | kText_1 | kText_2 | kBlob_1 | kBlob_2)
};
enum CopyOptions {
kCopySetDirty = 1<<0, // set dirty flag on changed dst fields
kCopyOverwrite = 1<<1, // overwrite fields for which dst node already has values
kCopyClear = 1<<2, // clear dst fields for which src node does not have values
public:
/**
* This is public only so that it may be referenced by anonymous functions.
* Should not be used outside NetVaultNode.
*/
struct Blob
{
size_t size;
uint8_t* buffer;
Blob() : size(0), buffer(nullptr) { }
~Blob() { delete[] buffer; }
void operator =(const Blob& rhs);
void operator =(Blob&& rhs);
bool operator ==(const Blob& rhs) const;
bool operator !=(const Blob& rhs) const { return !operator==(rhs); }
};
// These flag values must not change unless all servers are
// simultaneously replaced, so basically forget it.
static const uint64_t kNodeId = (uint64_t)1<< 0;
static const uint64_t kCreateTime = (uint64_t)1<< 1;
static const uint64_t kModifyTime = (uint64_t)1<< 2;
static const uint64_t kCreateAgeName = (uint64_t)1<< 3;
static const uint64_t kCreateAgeUuid = (uint64_t)1<< 4;
static const uint64_t kCreatorAcct = (uint64_t)1<< 5;
static const uint64_t kCreatorId = (uint64_t)1<< 6;
static const uint64_t kNodeType = (uint64_t)1<< 7;
static const uint64_t kInt32_1 = (uint64_t)1<< 8;
static const uint64_t kInt32_2 = (uint64_t)1<< 9;
static const uint64_t kInt32_3 = (uint64_t)1<<10;
static const uint64_t kInt32_4 = (uint64_t)1<<11;
static const uint64_t kUInt32_1 = (uint64_t)1<<12;
static const uint64_t kUInt32_2 = (uint64_t)1<<13;
static const uint64_t kUInt32_3 = (uint64_t)1<<14;
static const uint64_t kUInt32_4 = (uint64_t)1<<15;
static const uint64_t kUuid_1 = (uint64_t)1<<16;
static const uint64_t kUuid_2 = (uint64_t)1<<17;
static const uint64_t kUuid_3 = (uint64_t)1<<18;
static const uint64_t kUuid_4 = (uint64_t)1<<19;
static const uint64_t kString64_1 = (uint64_t)1<<20;
static const uint64_t kString64_2 = (uint64_t)1<<21;
static const uint64_t kString64_3 = (uint64_t)1<<22;
static const uint64_t kString64_4 = (uint64_t)1<<23;
static const uint64_t kString64_5 = (uint64_t)1<<24;
static const uint64_t kString64_6 = (uint64_t)1<<25;
static const uint64_t kIString64_1 = (uint64_t)1<<26;
static const uint64_t kIString64_2 = (uint64_t)1<<27;
// blobs always come last
static const uint64_t kText_1 = (uint64_t)1<<28;
static const uint64_t kText_2 = (uint64_t)1<<29;
static const uint64_t kBlob_1 = (uint64_t)1<<30;
static const uint64_t kBlob_2 = (uint64_t)1<<31;
static const uint64_t kAllValidFields = 0x00000000FFFFFFFFULL;
CCritSect critsect;
plUUID revisionId;
private:
uint64_t fieldFlags;
uint64_t dirtyFlags;
// Treat these as read-only or node flag fields will become invalid
// Threaded apps: Must be accessed with node->critsect locked
uint32_t nodeId;
uint32_t createTime;
uint32_t modifyTime;
wchar_t * createAgeName;
plUUID createAgeUuid;
plUUID creatorAcct; // accountId of node creator
uint32_t creatorId; // playerId of node creator
uint32_t nodeType;
int32_t int32_1;
int32_t int32_2;
int32_t int32_3;
int32_t int32_4;
uint32_t uint32_1;
uint32_t uint32_2;
uint32_t uint32_3;
uint32_t uint32_4;
plUUID uuid_1;
plUUID uuid_2;
plUUID uuid_3;
plUUID uuid_4;
wchar_t * string64_1;
wchar_t * string64_2;
wchar_t * string64_3;
wchar_t * string64_4;
wchar_t * string64_5;
wchar_t * string64_6;
wchar_t * istring64_1;
wchar_t * istring64_2;
wchar_t * text_1;
wchar_t * text_2;
uint8_t * blob_1; uint32_t blob_1Length;
uint8_t * blob_2; uint32_t blob_2Length;
void IVaultNodeSetString (
uint64_t bit,
char ** pdst,
const char src[],
unsigned chars
) {
free(*pdst);
if (src && src[0])
*pdst = StrDupLen(src, chars);
else
*pdst = StrDupLen("", chars);
fieldFlags |= bit;
dirtyFlags |= bit;
}
void IVaultNodeSetString (
uint64_t bit,
wchar_t ** pdst,
const wchar_t src[],
unsigned chars
) {
free(*pdst);
if (src && src[0])
*pdst = StrDupLen(src, chars);
else
*pdst = StrDupLen(L"", chars);
fieldFlags |= bit;
dirtyFlags |= bit;
uint64_t fUsedFields;
uint64_t fDirtyFields;
plUUID fRevision;
uint32_t fNodeId;
uint32_t fCreateTime;
uint32_t fModifyTime;
plString fCreateAgeName;
plUUID fCreateAgeUuid;
plUUID fCreatorAcct;
uint32_t fCreatorId;
uint32_t fNodeType;
int32_t fInt32_1;
int32_t fInt32_2;
int32_t fInt32_3;
int32_t fInt32_4;
uint32_t fUInt32_1;
uint32_t fUInt32_2;
uint32_t fUInt32_3;
uint32_t fUInt32_4;
plUUID fUuid_1;
plUUID fUuid_2;
plUUID fUuid_3;
plUUID fUuid_4;
plString fString64_1;
plString fString64_2;
plString fString64_3;
plString fString64_4;
plString fString64_5;
plString fString64_6;
plString fIString64_1;
plString fIString64_2;
plString fText_1;
plString fText_2;
Blob fBlob_1;
Blob fBlob_2;
template<typename T>
inline void ISetVaultField(uint64_t bits, T& field, T value)
{
field = value;
fUsedFields |= bits;
fDirtyFields |= bits;
}
template <typename T>
inline void IVaultNodeSetValue (
uint64_t bit,
T * pdst,
const T & src
) {
*pdst = src;
fieldFlags |= bit;
dirtyFlags |= bit;
template<typename T>
inline void ISetVaultField_NoDirty(uint64_t bits, T& field, T value)
{
field = value;
fUsedFields |= bits;
}
void IVaultNodeSetBlob (
uint64_t bit,
uint8_t ** pdst,
unsigned * pdstLen,
const uint8_t src[],
unsigned srcLen
) {
free(*pdst);
if (src) {
*pdst = (uint8_t*)malloc(srcLen);
memcpy(*pdst, src, srcLen);
*pdstLen = srcLen;
}
else {
*pdst = nil;
*pdstLen = 0;
}
fieldFlags |= bit;
dirtyFlags |= bit;
}
void DeallocNodeFields();
void ISetVaultBlob(uint64_t bits, Blob& blob, const uint8_t* buf, size_t size);
public:
NetVaultNode ();
~NetVaultNode ();
// Threaded apps: Must be called with node->critsect locked
uint32_t Read_LCS (const uint8_t buffer[], uint32_t bufsz, uint32_t rwOpts); // returns number of bytes read
uint32_t Write_LCS (ARRAY(uint8_t) * buffer, uint32_t rwOpts); // returns number of bytes written
bool Matches (const NetVaultNode * other);
void CopyFrom (const NetVaultNode * other, uint32_t copyOpts);
uint64_t GetFieldFlags () const { return fieldFlags; }
void ClearFieldFlags () { fieldFlags = 0; }
uint64_t GetDirtyFlags () const { return dirtyFlags; }
void SetDirtyFlags (uint64_t flags) { dirtyFlags |= flags; }
void ClearDirtyFlags (uint64_t flags) { dirtyFlags &= ~flags; }
// Threaded apps: Must be called with node->critsect locked
void SetNodeId (uint32_t v);
void SetNodeId_NoDirty (uint32_t v) { nodeId = v; }
void SetCreateTime (uint32_t v);
void SetModifyTime (uint32_t v);
void SetCreateAgeName (const wchar_t v[]);
void SetCreateAgeUuid (const plUUID & v);
void SetCreatorAcct (const plUUID & v);
void SetCreatorId (uint32_t v);
void SetNodeType (uint32_t v);
void SetInt32_1 (int32_t v);
void SetInt32_2 (int32_t v);
void SetInt32_3 (int32_t v);
void SetInt32_4 (int32_t v);
void SetUInt32_1 (uint32_t v);
void SetUInt32_2 (uint32_t v);
void SetUInt32_3 (uint32_t v);
void SetUInt32_4 (uint32_t v);
void SetUuid_1 (const plUUID & v);
void SetUuid_2 (const plUUID & v);
void SetUuid_3 (const plUUID & v);
void SetUuid_4 (const plUUID & v);
void SetString64_1 (const wchar_t v[]);
void SetString64_2 (const wchar_t v[]);
void SetString64_3 (const wchar_t v[]);
void SetString64_4 (const wchar_t v[]);
void SetString64_5 (const wchar_t v[]);
void SetString64_6 (const wchar_t v[]);
void SetIString64_1 (const wchar_t v[]);
void SetIString64_2 (const wchar_t v[]);
void SetText_1 (const wchar_t v[]);
void SetText_2 (const wchar_t v[]);
void SetBlob_1 (const uint8_t v[], uint32_t len);
void SetBlob_2 (const uint8_t v[], uint32_t len);
uint32_t GetNodeId () const { return nodeId; }
uint32_t GetCreateTime () const { return createTime; }
uint32_t GetModifyTime () const { return modifyTime; }
const wchar_t * GetCreateAgeName () const { return createAgeName; }
plUUID GetCreateAgeUuid () const { return createAgeUuid; }
plUUID GetCreatorAcct () const { return creatorAcct; }
uint32_t GetCreatorId () const { return creatorId; }
uint32_t GetNodeType () const { return nodeType; }
int32_t GetInt32_1 () const { return int32_1; }
int32_t GetInt32_2 () const { return int32_2; }
int32_t GetInt32_3 () const { return int32_3; }
int32_t GetInt32_4 () const { return int32_4; }
uint32_t GetUInt32_1 () const { return uint32_1; }
uint32_t GetUInt32_2 () const { return uint32_2; }
uint32_t GetUInt32_3 () const { return uint32_3; }
uint32_t GetUInt32_4 () const { return uint32_4; }
plUUID GetUuid_1 () const { return uuid_1; }
plUUID GetUuid_2 () const { return uuid_2; }
plUUID GetUuid_3 () const { return uuid_3; }
plUUID GetUuid_4 () const { return uuid_4; }
const wchar_t * GetString64_1 () const { return string64_1; }
const wchar_t * GetString64_2 () const { return string64_2; }
const wchar_t * GetString64_3 () const { return string64_3; }
const wchar_t * GetString64_4 () const { return string64_4; }
const wchar_t * GetString64_5 () const { return string64_5; }
const wchar_t * GetString64_6 () const { return string64_6; }
const wchar_t * GetIString64_1 () const { return istring64_1; }
const wchar_t * GetIString64_2 () const { return istring64_2; }
const wchar_t * GetText_1 () const { return text_1; }
const wchar_t * GetText_2 () const { return text_2; }
const uint8_t * GetBlob_1 () const { return blob_1; }
size_t GetBlob_1Length () const { return blob_1Length; }
const uint8_t * GetBlob_2 () const { return blob_2; }
size_t GetBlob_2Length () const { return blob_2Length; }
};
enum IOFlags
{
/** Only write fields marked dirty */
kDirtyOnly = (1 << 0),
/** Clears the dirty flag on fields written to the stream */
kClearDirty = (1 << 1),
//============================================================================
// NetVaultNodeRef (packed because is sent over wire directly)
//============================================================================
#pragma pack(push,1)
struct NetVaultNodeRef {
unsigned parentId;
unsigned childId;
unsigned ownerId;
bool seen;
};
#pragma pack(pop)
/** Indicates that we should mark the NodeType fields as dirty before writing */
kDirtyNodeType = (1 << 2),
//============================================================================
// SrvPackBuffer
//============================================================================
/** Indicates that we should mark the String64_1 field as dirty before writing */
kDirtyString64_1 = (1 << 3),
};
// Allocate a CSrvPackBuffer on the heap with one extra uint32_t to allow for padding
#define SRV_ALLOC_BUFFER(bytes) \
new(malloc(sizeof(CSrvPackBuffer) + (bytes) + sizeof(uint32_t))) \
CSrvPackBuffer(bytes + sizeof(uint32_t))
public:
NetVaultNode()
: fNodeId(0), fCreateTime(0), fModifyTime(0), fCreatorId(0), fNodeType(0), fInt32_1(0),
fInt32_2(0), fInt32_3(0), fInt32_4(0), fUInt32_1(0), fUInt32_2(0), fUInt32_3(0),
fUInt32_4(0), fUsedFields(0), fDirtyFields(0)
{ }
// Allocate a CSrvPackBuffer on the stack with one extra uint32_t to allow for padding
#define SRV_ALLOCA_BUFFER(bytes) \
new(_alloca(sizeof(CSrvPackBuffer) + (bytes) + sizeof(uint32_t))) \
CSrvPackBuffer(bytes + sizeof(uint32_t))
/** Clears this NetVaultNode for subsequent usage */
void Clear();
class CSrvPackBuffer {
public:
CSrvPackBuffer (unsigned bytes);
/** Copies data from \a node to this NetVaultNode */
void CopyFrom(const NetVaultNode* node);
void * Alloc (unsigned bytes);
void AddData (const void * ptr, unsigned bytes);
void AddString (const wchar_t str[]);
void AddDWordArray (const uint32_t * arr, unsigned count);
// add new "Add..." methods here as needed
bool Matches(const NetVaultNode* rhs) const;
unsigned Size ();
void Read(const uint8_t* buf, size_t size);
void Write(ARRAY(uint8_t)* buf, uint32_t ioFlags=0);
private:
uint8_t * m_pos;
uint8_t * m_end;
uint8_t * m_data;
};
protected:
uint64_t GetFieldFlags() const { return fUsedFields; }
class CSrvUnpackBuffer {
public:
CSrvUnpackBuffer (const void * buffer, unsigned count);
const void * GetData (unsigned bytes);
const wchar_t * GetString ();
const uint32_t * GetDWordArray (unsigned count);
bool IsDirty() const { return fDirtyFields != 0; }
plUUID GetRevision() const { return fRevision; }
void GenerateRevision() { fRevision = plUUID::Generate(); }
uint32_t GetNodeId() const { return fNodeId; }
uint32_t GetCreateTime() const { return fCreateTime; }
uint32_t GetModifyTime() const { return fModifyTime; }
plString GetCreateAgeName() const { return fCreateAgeName; }
plUUID GetCreateAgeUuid() const { return fCreateAgeUuid; }
plUUID GetCreatorAcct() const { return fCreatorAcct; }
uint32_t GetCreatorId() const { return fCreatorId; }
uint32_t GetNodeType() const { return fNodeType; }
int32_t GetInt32_1() const { return fInt32_1; }
int32_t GetInt32_2() const { return fInt32_2; }
int32_t GetInt32_3() const { return fInt32_3; }
int32_t GetInt32_4() const { return fInt32_4; }
uint32_t GetUInt32_1() const { return fUInt32_1; }
uint32_t GetUInt32_2() const { return fUInt32_2; }
uint32_t GetUInt32_3() const { return fUInt32_3; }
uint32_t GetUInt32_4() const { return fUInt32_4; }
plUUID GetUuid_1() const { return fUuid_1; }
plUUID GetUuid_2() const { return fUuid_2; }
plUUID GetUuid_3() const { return fUuid_3; }
plUUID GetUuid_4() const { return fUuid_4; }
plString GetString64_1() const { return fString64_1; }
plString GetString64_2() const { return fString64_2; }
plString GetString64_3() const { return fString64_3; }
plString GetString64_4() const { return fString64_4; }
plString GetString64_5() const { return fString64_5; }
plString GetString64_6() const { return fString64_6; }
plString GetIString64_1() const { return fIString64_1; }
plString GetIString64_2() const { return fIString64_2; }
plString GetText_1() const { return fText_1; }
plString GetText_2() const { return fText_2; }
const uint8_t* GetBlob_1() const { return fBlob_1.buffer; }
size_t GetBlob_1Length() const { return fBlob_1.size; }
const uint8_t* GetBlob_2() const { return fBlob_2.buffer; }
size_t GetBlob_2Length() const { return fBlob_2.size; }
unsigned BytesLeft ();
bool ParseError ();
public:
void SetNodeId(uint32_t value) { ISetVaultField(kNodeId, fNodeId, value); }
void SetNodeId_NoDirty(uint32_t value) { ISetVaultField_NoDirty(kNodeId, fNodeId, value); }
void SetCreateTime(uint32_t value) { ISetVaultField(kCreateTime, fCreateTime, value); }
void SetModifyTime(uint32_t value) { ISetVaultField(kModifyTime, fModifyTime, value); }
void SetCreateAgeName(plString value) { ISetVaultField(kCreateAgeName, fCreateAgeName, value); }
void SetCreateAgeUuid(plUUID value) { ISetVaultField(kCreateAgeUuid, fCreateAgeUuid, value); }
void SetCreatorAcct(plUUID value) { ISetVaultField(kCreatorAcct, fCreatorAcct, value); }
void SetCreatorId(uint32_t value) { ISetVaultField(kCreatorId, fCreatorId, value); }
void SetNodeType(uint32_t value) { ISetVaultField(kNodeType, fNodeType, value); }
void SetInt32_1(int32_t value) { ISetVaultField(kInt32_1, fInt32_1, value); }
void SetInt32_2(int32_t value) { ISetVaultField(kInt32_2, fInt32_2, value); }
void SetInt32_3(int32_t value) { ISetVaultField(kInt32_3, fInt32_3, value); }
void SetInt32_4(int32_t value) { ISetVaultField(kInt32_4, fInt32_4, value); }
void SetUInt32_1(uint32_t value) { ISetVaultField(kUInt32_1, fUInt32_1, value); }
void SetUInt32_2(uint32_t value) { ISetVaultField(kUInt32_2, fUInt32_2, value); }
void SetUInt32_3(uint32_t value) { ISetVaultField(kUInt32_3, fUInt32_3, value); }
void SetUInt32_4(uint32_t value) { ISetVaultField(kUInt32_4, fUInt32_4, value); }
void SetUuid_1(const plUUID& value) { ISetVaultField(kUuid_1, fUuid_1, value); }
void SetUuid_2(const plUUID& value) { ISetVaultField(kUuid_2, fUuid_2, value); }
void SetUuid_3(const plUUID& value) { ISetVaultField(kUuid_3, fUuid_3, value); }
void SetUuid_4(const plUUID& value) { ISetVaultField(kUuid_4, fUuid_4, value); }
void SetString64_1(const plString& value) { ISetVaultField(kString64_1, fString64_1, value); }
void SetString64_2(const plString& value) { ISetVaultField(kString64_2, fString64_2, value); }
void SetString64_3(const plString& value) { ISetVaultField(kString64_3, fString64_3, value); }
void SetString64_4(const plString& value) { ISetVaultField(kString64_4, fString64_4, value); }
void SetString64_5(const plString& value) { ISetVaultField(kString64_5, fString64_5, value); }
void SetString64_6(const plString& value) { ISetVaultField(kString64_6, fString64_6, value); }
void SetIString64_1(const plString& value) { ISetVaultField(kIString64_1, fIString64_1, value); }
void SetIString64_2(const plString& value) { ISetVaultField(kIString64_2, fIString64_2, value); }
void SetText_1(const plString& value) { ISetVaultField(kText_1, fText_1, value); }
void SetText_2(const plString& value) { ISetVaultField(kText_2, fText_2, value); }
void SetBlob_1(const uint8_t* buf, size_t size) { ISetVaultBlob(kBlob_1, fBlob_1, buf, size); }
void SetBlob_2(const uint8_t* buf, size_t size) { ISetVaultBlob(kBlob_2, fBlob_2, buf, size); }
};
private:
const uint8_t * m_pos;
const uint8_t * m_end;
//============================================================================
// NetVaultNodeRef (packed because is sent over wire directly)
//============================================================================
#pragma pack(push,1)
struct NetVaultNodeRef {
unsigned parentId;
unsigned childId;
unsigned ownerId;
bool seen;
};
#pragma pack(pop)

14
Sources/Plasma/NucleusLib/pnUtils/pnUtMisc.h

@ -69,18 +69,4 @@ void * ModuleGetInstance ();
const wchar_t * AppGetCommandLine ();
/*****************************************************************************
*
* Misc types
*
***/
// used to dump the internal state of a module
typedef void (CDECL * FStateDump)(
void * param,
const wchar_t fmt[],
...
);
#endif

2
Sources/Plasma/PubUtilLib/plNetClient/plLinkEffectsMgr.cpp

@ -64,7 +64,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plFixedKey.h"
// chronicle var
#define kCleftSolved L"CleftSolved"
#define kCleftSolved "CleftSolved"
#include "plAvatar/plArmatureMod.h"
#include "plAvatar/plAvatarTasks.h"

2
Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp

@ -408,7 +408,7 @@ bool plNCAgeJoiner::MsgReceive (plMessage * msg) {
else if (unsigned ageVaultId = NetCommGetAge()->ageVaultId) {
// Download the age vault
VaultDownload(
L"AgeJoin",
"AgeJoin",
ageVaultId,
AgeVaultDownloadCallback,
this,

12
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -777,10 +777,8 @@ void plNetLinkingMgr::IPostProcessLink( void )
// Update our online status
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode accInfo(rvnInfo);
wchar_t ageInstName[MAX_PATH];
plUUID ageInstGuid = *info->GetAgeInstanceGuid();
StrToUnicode(ageInstName, info->GetAgeInstanceName(), arrsize(ageInstName));
accInfo.SetAgeInstName(ageInstName);
accInfo.SetAgeInstName(info->GetAgeInstanceName());
accInfo.SetAgeInstUuid(ageInstGuid);
accInfo.SetOnline(true);
}
@ -869,11 +867,9 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
// Update our online status
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode accInfo(rvnInfo);
wchar_t ageInstName[MAX_PATH];
plUUID ageInstGuid = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid();
StrToUnicode(ageInstName, info->GetAgeInstanceName(), arrsize(ageInstName));
accInfo.SetAgeInstName(ageInstName);
accInfo.SetAgeInstUuid(ageInstGuid);
const plUUID* ageInstGuid = info->GetAgeInstanceGuid();
accInfo.SetAgeInstName(info->GetAgeInstanceName());
accInfo.SetAgeInstUuid(*ageInstGuid);
accInfo.SetOnline(true);
}
#endif

5
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -311,7 +311,7 @@ static void INetCliAuthSetPlayerRequestCallback (
s_needAvatarLoad = true;
VaultDownload(
L"SetActivePlayer",
"SetActivePlayer",
s_player->playerInt,
PlayerInitCallback,
param,
@ -367,7 +367,7 @@ static void INetCliAuthLoginSetPlayerRequestCallback (
}
else {
VaultDownload(
L"SetActivePlayer",
"SetActivePlayer",
s_player->playerInt,
LoginPlayerInitCallback,
param,
@ -1120,7 +1120,6 @@ void NetCommSetActivePlayer (//--> plNetCommActivePlayerMsg
if (s_player) {
if (hsRef<RelVaultNode> rvn = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode pInfo(rvn);
pInfo.SetAgeInstName(nil);
pInfo.SetAgeInstUuid(kNilUuid);
pInfo.SetOnline(false);
NetCliAuthVaultNodeSave(rvn, nil, nil);

40
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#pragma hdrstop
#include "pnEncryption/plChallengeHash.h"
#include "plVault/plVaultConstants.h"
namespace Ngl { namespace Auth {
/*****************************************************************************
@ -3950,7 +3951,7 @@ bool VaultFetchNodeTrans::Recv (
if (IS_NET_SUCCESS(reply.result)) {
m_node = new NetVaultNode;
m_node->Read_LCS(reply.nodeBuffer, reply.nodeBytes, 0);
m_node->Read(reply.nodeBuffer, reply.nodeBytes);
}
m_result = reply.result;
@ -3984,9 +3985,7 @@ bool VaultFindNodeTrans::Send () {
return false;
ARRAY(uint8_t) buffer;
m_node->critsect.Enter();
m_node->Write_LCS(&buffer, 0);
m_node->critsect.Leave();
m_node->Write(&buffer);
const uintptr_t msg[] = {
kCli2Auth_VaultNodeFind,
@ -4054,7 +4053,7 @@ bool VaultCreateNodeTrans::Send () {
return false;
ARRAY(uint8_t) buffer;
m_templateNode->Write_LCS(&buffer, 0);
m_templateNode->Write(&buffer, 0);
const uintptr_t msg[] = {
kCli2Auth_VaultNodeCreate,
@ -5608,43 +5607,34 @@ unsigned NetCliAuthVaultNodeSave (
FNetCliAuthVaultNodeSaveCallback callback,
void * param
) {
ASSERTMSG(!(node->GetDirtyFlags() & NetVaultNode::kNodeType), "Node type may not be changed");
// Clear dirty bits of read-only fields before we write the node to the msg buffer
node->ClearDirtyFlags(
NetVaultNode::kNodeId |
NetVaultNode::kNodeType |
NetVaultNode::kCreatorAcct |
NetVaultNode::kCreatorId |
NetVaultNode::kCreateTime
);
if (!node->GetDirtyFlags())
if (!node->IsDirty())
return 0;
if (!node->GetNodeId())
return 0;
// force sending of the nodeType value, since the auth needs it.
// auth will clear the field before sending it on to the vault.
node->SetDirtyFlags(NetVaultNode::kNodeType);
// We're definitely saving this node, so assign a revisionId
node->revisionId = plUUID::Generate();
node->GenerateRevision();
// Lots of hacks for MOULa :(
uint32_t ioFlags = NetVaultNode::kDirtyOnly | NetVaultNode::kClearDirty;
if (node->GetNodeType() == plVault::kNodeType_SDL)
ioFlags |= NetVaultNode::kDirtyString64_1;
ioFlags |= NetVaultNode::kDirtyNodeType;
ARRAY(uint8_t) buffer;
unsigned bytes = node->Write_LCS(&buffer, NetVaultNode::kRwDirtyOnly | NetVaultNode::kRwUpdateDirty);
node->Write(&buffer, ioFlags);
VaultSaveNodeTrans * trans = new VaultSaveNodeTrans(
node->GetNodeId(),
node->revisionId,
node->GetRevision(),
buffer.Count(),
buffer.Ptr(),
callback,
param
);
NetTransSend(trans);
return bytes;
return buffer.Count();
}
//============================================================================

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h

@ -383,7 +383,7 @@ void NetCliAuthFileRequest (
//============================================================================
// Vault Operations
//============================================================================
struct NetVaultNode;
class NetVaultNode;
struct NetVaultNodeRef;
// VaultNodeChanged

2
Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp

@ -382,7 +382,7 @@ bool plAutoProfileImp::MsgReceive(plMessage* msg)
if (ageBeginLoadingMsg)
{
plgDispatch::Dispatch()->UnRegisterForExactType(plAgeBeginLoadingMsg::Index(), GetKey());
VaultAddChronicleEntryAndWait(L"InitialAvCursomizationsDone", 0, L"1");
VaultAddChronicleEntryAndWait("InitialAvCursomizationsDone", 0, "1");
return true;
}

4
Sources/Plasma/PubUtilLib/plVault/Pch.h

@ -62,7 +62,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// 'Old' system is full of compiler warnings at /W4, so just hide them
#pragma warning(push, 0)
#include <algorithm>
#include <memory>
#include <sstream>
#include <unordered_map>
#include "hsStringTokenizer.h"
#include "hsGeometry3.h"
#include "plSDL/plSDL.h"
@ -77,6 +80,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plGImage/plJPEG.h"
#include "plMessage/plVaultNotifyMsg.h"
#include "plNetClientComm/plNetClientComm.h"
#include "plStatusLog/plStatusLog.h"
#define KI_CONSTANTS_ONLY
#include "pfMessage/pfKIMsg.h" // for KI level constants =(

389
Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp

@ -74,17 +74,6 @@ struct INotifyAfterDownload : THashKeyVal<unsigned> {
{}
};
struct DeviceInbox : CHashKeyStr {
HASHLINK(DeviceInbox) link;
wchar_t inboxName[kMaxVaultNodeStringLength];
DeviceInbox (const wchar_t device[], const wchar_t inbox[])
: CHashKeyStr(device)
{
StrCopy(inboxName, inbox, arrsize(inboxName));
}
};
// A RelVaultNodeLink may be either stored in the global table,
// or stored in an IRelVaultNode's parents or children table.
struct RelVaultNodeLink : THashKeyVal<unsigned> {
@ -184,7 +173,7 @@ struct VaultDownloadTrans {
FVaultProgressCallback progressCallback;
void * cbProgressParam;
wchar_t tag[MAX_PATH];
plString tag;
unsigned nodeCount;
unsigned nodesLeft;
unsigned vaultId;
@ -194,18 +183,15 @@ struct VaultDownloadTrans {
: callback(nil), cbParam(nil), progressCallback(nil), cbProgressParam(nil),
nodeCount(0), nodesLeft(0), vaultId(0), result(kNetSuccess)
{
memset(tag, 0, sizeof(tag));
}
VaultDownloadTrans (const wchar_t * _tag, FVaultDownloadCallback _callback,
VaultDownloadTrans (const plString& _tag, FVaultDownloadCallback _callback,
void * _cbParam, FVaultProgressCallback _progressCallback,
void * _cbProgressParam, unsigned _vaultId)
: callback(_callback), cbParam(_cbParam), progressCallback(_progressCallback),
cbProgressParam(_cbProgressParam), nodeCount(0), nodesLeft(0),
vaultId(_vaultId), result(kNetSuccess)
vaultId(_vaultId), result(kNetSuccess), tag(_tag)
{
wcsncpy(tag, _tag, arrsize(tag));
tag[arrsize(tag)-1] = 0;
}
@ -293,11 +279,7 @@ static HASHTABLEDECL(
link
) s_notifyAfterDownload;
static HASHTABLEDECL(
DeviceInbox,
CHashKeyStr,
link
) s_ageDeviceInboxes;
static std::unordered_map<plString, plString, plString::hash> s_ageDeviceInboxes;
static bool s_processPlayerInbox = false;
@ -553,14 +535,14 @@ static void VaultNodeFetched (
// Add to global node table
RelVaultNodeLink * link = s_nodes.Find(node->GetNodeId());
if (!link) {
link = new RelVaultNodeLink(false, 0, node->GetNodeId(), new RelVaultNode);
link = new RelVaultNodeLink(false, 0, node->GetNodeId(), new RelVaultNode());
link->node->SetNodeId_NoDirty(node->GetNodeId());
s_nodes.Add(link);
}
link->node->CopyFrom(node, NetVaultNode::kCopyOverwrite);
link->node->CopyFrom(node);
InitFetchedNode(link->node);
link->node->Print(L"Fetched", LogDumpProc, 0);
link->node->Print("Fetched", 0);
}
//============================================================================
@ -602,7 +584,7 @@ static void VaultNodeChanged (
// We are the party responsible for the change, so we already have the
// latest version of the node; no need to fetch it.
if (link->node->revisionId == revisionId)
if (link->node->GetRevision() == revisionId)
return;
// We have the node and we weren't the one that changed it, so fetch it.
@ -651,7 +633,7 @@ static void VaultNodeAdded (
continue;
prevId = link->node->GetNodeId();
VaultDownload(
L"NodeAdded",
"NodeAdded",
nodeIds[i],
VaultNodeAddedDownloadCallback,
(void*)nodeIds[i],
@ -726,15 +708,10 @@ static void SaveDirtyNodes () {
for (RelVaultNodeLink * link = s_nodes.Head(); link; link = s_nodes.Next(link)) {
if (bytesWritten >= kMaxBytesPerSaveUpdate)
break;
if (link->node->GetDirtyFlags()) {
// Auth server needs the name of the sdl record
if (link->node->GetNodeType() == plVault::kNodeType_SDL)
link->node->SetDirtyFlags(VaultSDLNode::kSDLName);
if (link->node->IsDirty()) {
if (unsigned bytes = NetCliAuthVaultNodeSave(link->node, nil, nil)) {
bytesWritten += bytes;
link->node->Print(L"Saving", LogDumpProc, 0);
link->node->Print("Saving", 0);
}
}
}
@ -882,7 +859,7 @@ void VaultDownloadTrans::VaultNodeFetched (
}
if (!trans->nodesLeft) {
VaultDump(trans->tag, trans->vaultId, LogDumpProc);
VaultDump(trans->tag, trans->vaultId);
if (trans->callback)
trans->callback(
@ -1389,93 +1366,12 @@ void RelVaultNode::SetSeen (unsigned parentId, bool seen) {
}
//============================================================================
template <typename T>
static bool IStrSqlEscape (const T src[], T * dst, unsigned dstChars) {
// count the number of ' chars
unsigned ticks = 0;
{
const T * cur = src;
while (*cur) {
if (*cur == L'\'')
++ticks;
cur++;
}
}
unsigned reqChars = StrLen(src) + ticks + 1;
if (dstChars < reqChars)
// failure!
return false;
T * cur = dst;
// copy src to dst, escaping ' chars
while (*src) {
if (*src == L'\'') {
*cur++ = L'\'';
*cur++ = *src++;
continue;
}
*cur++ = *src++;
}
// null-terminate dst string
*cur = 0;
// success!
return true;
}
static void IGetStringFieldValue (
const wchar_t * value,
wchar_t * dst,
size_t dstChars
) {
wchar_t * tmp = (wchar_t*)malloc(sizeof(wchar_t) * dstChars);
IStrSqlEscape(value, tmp, dstChars);
swprintf(dst, dstChars, L"'%s'", tmp);
free(tmp);
}
static void IGetUuidFieldValue (
const plUUID & value,
wchar_t * dst,
size_t dstChars
) {
swprintf(dst, dstChars, L"hextoraw('%S')", value.AsString().c_str());
}
static void IGetUintFieldValue (
uint32_t value,
wchar_t * dst,
size_t dstChars
) {
swprintf(dst, dstChars, L"%u", value);
}
static void IGetIntFieldValue (
int32_t value,
wchar_t * dst,
size_t dstChars
) {
swprintf(dst, dstChars, L"%d", value);
}
void RelVaultNode::Print (const wchar_t tag[], FStateDump dumpProc, unsigned level) {
wchar_t str[1024];
StrPrintf(
str,
arrsize(str),
L"%s%*s%*s%u, %S",
tag ? tag : L"",
tag ? 1 : 0,
" ",
level * 2,
" ",
GetNodeId(),
plVault::NodeTypeStr(GetNodeType(), false)
);
void RelVaultNode::Print (const plString& tag, unsigned level) {
plStringStream ss;
ss << tag;
ss << plString::Fill(level * 2, ' ');
ss << " " << GetNodeId();
ss << " " << plVault::NodeTypeStr(GetNodeType());
for (uint64_t bit = 1; bit; bit <<= 1) {
if (!(GetFieldFlags() & bit))
@ -1483,60 +1379,66 @@ void RelVaultNode::Print (const wchar_t tag[], FStateDump dumpProc, unsigned lev
if (bit > GetFieldFlags())
break;
#define STPRINT(flag, func) case k##flag: { \
wcsncat(str, L", " L ## #flag L"=", arrsize(str)); \
const size_t chars = wcslen(str); \
func(Get##flag(), str + chars, arrsize(str) - chars * sizeof(str[0])); \
}; break
#define STNAME(flag) case k##flag: { \
wcsncat(str, L", " L ## #flag, arrsize(str)); \
}; break
#define STPRINT(flag) \
case k##flag: \
ss << ", " #flag "=\"" << Get##flag() << "\""; \
break;
#define STPRINT_ESCAPE(flag) \
case k##flag: \
ss << ", " #flag "=\"" << Get##flag().Replace("\"", "\\\"") << "\""; \
break;
#define STNAME(flag) \
case k##flag: \
ss << ", " << #flag; \
break;
switch (bit) {
STPRINT(NodeId, IGetUintFieldValue);
STPRINT(CreateTime, IGetUintFieldValue);
STPRINT(ModifyTime, IGetUintFieldValue);
STPRINT(CreateAgeName, IGetStringFieldValue);
STPRINT(CreateAgeUuid, IGetUuidFieldValue);
STPRINT(CreatorAcct, IGetUuidFieldValue);
STPRINT(CreatorId, IGetUintFieldValue);
STPRINT(NodeType, IGetUintFieldValue);
STPRINT(Int32_1, IGetIntFieldValue);
STPRINT(Int32_2, IGetIntFieldValue);
STPRINT(Int32_3, IGetIntFieldValue);
STPRINT(Int32_4, IGetIntFieldValue);
STPRINT(UInt32_1, IGetUintFieldValue);
STPRINT(UInt32_2, IGetUintFieldValue);
STPRINT(UInt32_3, IGetUintFieldValue);
STPRINT(UInt32_4, IGetUintFieldValue);
STPRINT(Uuid_1, IGetUuidFieldValue);
STPRINT(Uuid_2, IGetUuidFieldValue);
STPRINT(Uuid_3, IGetUuidFieldValue);
STPRINT(Uuid_4, IGetUuidFieldValue);
STPRINT(String64_1, IGetStringFieldValue);
STPRINT(String64_2, IGetStringFieldValue);
STPRINT(String64_3, IGetStringFieldValue);
STPRINT(String64_4, IGetStringFieldValue);
STPRINT(String64_5, IGetStringFieldValue);
STPRINT(String64_6, IGetStringFieldValue);
STPRINT(IString64_1, IGetStringFieldValue);
STPRINT(IString64_2, IGetStringFieldValue);
STPRINT(NodeId);
STPRINT(CreateTime);
STPRINT(ModifyTime);
STPRINT(CreateAgeName);
STPRINT(CreateAgeUuid);
STPRINT(CreatorAcct);
STPRINT(CreatorId);
STPRINT(NodeType);
STPRINT(Int32_1);
STPRINT(Int32_2);
STPRINT(Int32_3);
STPRINT(Int32_4);
STPRINT(UInt32_1);
STPRINT(UInt32_2);
STPRINT(UInt32_3);
STPRINT(UInt32_4);
STPRINT(Uuid_1);
STPRINT(Uuid_2);
STPRINT(Uuid_3);
STPRINT(Uuid_4);
STPRINT_ESCAPE(String64_1);
STPRINT_ESCAPE(String64_2);
STPRINT_ESCAPE(String64_3);
STPRINT_ESCAPE(String64_4);
STPRINT_ESCAPE(String64_5);
STPRINT_ESCAPE(String64_6);
STPRINT_ESCAPE(IString64_1);
STPRINT_ESCAPE(IString64_2);
STNAME(Text_1);
STNAME(Text_2);
STNAME(Blob_1);
STNAME(Blob_2);
DEFAULT_FATAL(bit);
}
#undef STPRINT
#undef STPRINT
#undef STNAME
}
dumpProc(nil, str);
plStatusLog::AddLineS("VaultClient.log", ss.GetString().c_str());
}
//============================================================================
void RelVaultNode::PrintTree (FStateDump dumpProc, unsigned level) {
Print(L"", dumpProc, level);
void RelVaultNode::PrintTree (unsigned level) {
Print("", level);
for (RelVaultNodeLink * link = state->children.Head(); link; link = state->children.Next(link))
link->node->PrintTree(dumpProc, level + 1);
link->node->PrintTree(level + 1);
}
//============================================================================
@ -1875,18 +1777,18 @@ void VaultDeleteNode (
//============================================================================
void VaultPublishNode (
unsigned nodeId,
const wchar_t deviceName[]
const plString& deviceName
) {
hsRef<RelVaultNode> rvn;
rvn = VaultAgeGetDeviceInbox(deviceName);
if (!rvn) {
LogMsg(kLogDebug, L"Failed to find inbox for device %s, adding it on-the-fly", deviceName);
LogMsg(kLogDebug, L"Failed to find inbox for device %S, adding it on-the-fly", deviceName.c_str());
VaultAgeSetDeviceInboxAndWait(deviceName, DEFAULT_DEVICE_INBOX);
rvn = VaultAgeGetDeviceInbox(deviceName);
if (!rvn) {
LogMsg(kLogDebug, L"Failed to add inbox to device %s on-the-fly", deviceName);
LogMsg(kLogDebug, L"Failed to add inbox to device %S on-the-fly", deviceName.c_str());
return;
}
}
@ -1914,10 +1816,8 @@ void VaultCreateNode (
if (hsRef<RelVaultNode> age = VaultGetAgeNode()) {
VaultAgeNode access(age);
if (!(templateNode->GetFieldFlags() & NetVaultNode::kCreateAgeName))
templateNode->SetCreateAgeName(access.GetAgeName());
if (!(templateNode->GetFieldFlags() & NetVaultNode::kCreateAgeUuid))
templateNode->SetCreateAgeUuid(access.GetAgeInstanceGuid());
templateNode->SetCreateAgeName(access.GetAgeName());
templateNode->SetCreateAgeUuid(access.GetAgeInstanceGuid());
}
NetCliAuthVaultNodeCreate(
@ -2297,9 +2197,7 @@ bool VaultGetLinkToMyNeighborhood (plAgeLinkStruct * link) {
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, kNeighborhoodAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(kNeighborhoodAgeFilename);
hsRef<RelVaultNode> node;
if (node = rvnFldr->GetChildNode(templateNode, 2)) {
@ -2320,9 +2218,7 @@ bool VaultGetLinkToMyPersonalAge (plAgeLinkStruct * link) {
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, kPersonalAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(kPersonalAgeFilename);
hsRef<RelVaultNode> node;
if (node = rvnFldr->GetChildNode(templateNode, 2)) {
@ -2343,9 +2239,7 @@ bool VaultGetLinkToCity (plAgeLinkStruct * link) {
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, kCityAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(kCityAgeFilename);
hsRef<RelVaultNode> node;
if (node = rvnFldr->GetChildNode(templateNode, 2)) {
@ -2368,16 +2262,14 @@ hsRef<RelVaultNode> VaultGetOwnedAgeLink (const plAgeInfoStruct * info) {
VaultAgeInfoNode ageInfo(templateNode);
if (info->HasAgeFilename()) {
wchar_t str[MAX_PATH];
StrToUnicode(str, info->GetAgeFilename(), arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(info->GetAgeFilename());
}
if (info->HasAgeInstanceGuid()) {
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid());
}
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->Clear();
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
rvnLink = rvnInfo->GetParentNode(templateNode, 1);
}
@ -2390,7 +2282,6 @@ hsRef<RelVaultNode> VaultGetOwnedAgeLink (const plAgeInfoStruct * info) {
hsRef<RelVaultNode> VaultGetOwnedAgeInfo (const plAgeInfoStruct * info) {
hsRef<RelVaultNode> rvnInfo;
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) {
hsRef<NetVaultNode> templateNode = new NetVaultNode;
@ -2398,9 +2289,7 @@ hsRef<RelVaultNode> VaultGetOwnedAgeInfo (const plAgeInfoStruct * info) {
VaultAgeInfoNode ageInfo(templateNode);
if (info->HasAgeFilename()) {
wchar_t str[MAX_PATH];
StrToUnicode(str, info->GetAgeFilename(), arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(info->GetAgeFilename());
}
if (info->HasAgeInstanceGuid()) {
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid());
@ -2408,7 +2297,6 @@ hsRef<RelVaultNode> VaultGetOwnedAgeInfo (const plAgeInfoStruct * info) {
rvnInfo = rvnFldr->GetChildNode(templateNode, 2);
}
return rvnInfo;
}
@ -2488,8 +2376,6 @@ bool VaultSetAgePublicAndWait (NetVaultNode * ageInfoNode, bool publicOrNot) {
NetCliAuthSetAgePublic(ageInfoNode->GetNodeId(), publicOrNot);
VaultAgeInfoNode access(ageInfoNode);
char ageName[MAX_PATH];
StrToAnsi(ageName, access.GetAgeFilename(), arrsize(ageName));
plVaultNotifyMsg * msg = new plVaultNotifyMsg;
if (publicOrNot)
@ -2497,7 +2383,7 @@ bool VaultSetAgePublicAndWait (NetVaultNode * ageInfoNode, bool publicOrNot) {
else
msg->SetType(plVaultNotifyMsg::kPublicAgeRemoved);
msg->SetResultCode(true);
msg->GetArgs()->AddString(plNetCommon::VaultTaskArgs::kAgeFilename, ageName);
msg->GetArgs()->AddString(plNetCommon::VaultTaskArgs::kAgeFilename, access.GetAgeFilename().c_str());
msg->Send();
return true;
}
@ -2513,16 +2399,14 @@ hsRef<RelVaultNode> VaultGetVisitAgeLink (const plAgeInfoStruct * info) {
VaultAgeInfoNode ageInfo(templateNode);
if (info->HasAgeFilename()) {
wchar_t str[MAX_PATH];
StrToUnicode(str, info->GetAgeFilename(), arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(info->GetAgeFilename());
}
if (info->HasAgeInstanceGuid()) {
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid());
}
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->Clear();
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
rvnLink = rvnInfo->GetParentNode(templateNode, 1);
}
@ -2539,7 +2423,6 @@ bool VaultGetVisitAgeLink (const plAgeInfoStruct * info, class plAgeLinkStruct *
VaultAgeLinkNode ageLink(rvn);
ageLink.CopyTo(link);
return true;
}
@ -2688,7 +2571,7 @@ bool VaultRegisterOwnedAgeAndWait (const plAgeLinkStruct * link) {
memset(&param, 0, sizeof(param));
VaultDownload(
L"RegisterOwnedAge",
"RegisterOwnedAge",
ageInfoId,
_FetchVaultCallback,
&param,
@ -2870,7 +2753,7 @@ namespace _VaultRegisterOwnedAge {
p->fSpawn = (plSpawnPointInfo*)param;
VaultDownload(
L"RegisterOwnedAge",
"RegisterOwnedAge",
ageInfoVaultId,
(FVaultDownloadCallback)_DownloadCallback,
p,
@ -3048,7 +2931,7 @@ bool VaultRegisterVisitAgeAndWait (const plAgeLinkStruct * link) {
memset(&param, 0, sizeof(param));
VaultDownload(
L"RegisterVisitAge",
"RegisterVisitAge",
ageInfoId,
_FetchVaultCallback,
&param,
@ -3222,7 +3105,7 @@ namespace _VaultRegisterVisitAge {
_Params* p = (_Params*)param;
p->fAgeInfoId = (void*)ageInfoId;
VaultDownload(L"RegisterVisitAge",
VaultDownload("RegisterVisitAge",
ageInfoId,
(FVaultDownloadCallback)_DownloadCallback,
param,
@ -3365,7 +3248,7 @@ bool VaultUnregisterVisitAgeAndWait (const plAgeInfoStruct * info) {
}
//============================================================================
hsRef<RelVaultNode> VaultFindChronicleEntry (const wchar_t entryName[], int entryType) {
hsRef<RelVaultNode> VaultFindChronicleEntry (const plString& entryName, int entryType) {
hsRef<RelVaultNode> result;
if (hsRef<RelVaultNode> rvnFldr = GetChildFolderNode(GetPlayerNode(), plVault::kChronicleFolder, 1)) {
@ -3382,7 +3265,7 @@ hsRef<RelVaultNode> VaultFindChronicleEntry (const wchar_t entryName[], int entr
}
//============================================================================
bool VaultHasChronicleEntry (const wchar_t entryName[], int entryType) {
bool VaultHasChronicleEntry (const plString& entryName, int entryType) {
if (VaultFindChronicleEntry(entryName, entryType))
return true;
return false;
@ -3390,9 +3273,9 @@ bool VaultHasChronicleEntry (const wchar_t entryName[], int entryType) {
//============================================================================
void VaultAddChronicleEntryAndWait (
const wchar_t entryName[],
int entryType,
const wchar_t entryValue[]
const plString& entryName,
int entryType,
const plString& entryValue
) {
if (hsRef<RelVaultNode> rvnChrn = VaultFindChronicleEntry(entryName, entryType)) {
VaultChronicleNode chrnNode(rvnChrn);
@ -3458,18 +3341,13 @@ bool VaultSetCCRStatus (bool online) {
}
//============================================================================
void VaultDump (const wchar_t tag[], unsigned vaultId, FStateDump dumpProc) {
LogMsg(kLogDebug, L"<---- ID:%u, Begin Vault%*s%s ---->", vaultId, tag ? 1 : 0, L" ", tag);
void VaultDump (const plString& tag, unsigned vaultId) {
plStatusLog::AddLineS("VaultClient.log", plFormat("<---- ID:{}, Begin Vault {} ---->", vaultId, tag).c_str());
if (hsRef<RelVaultNode> rvn = VaultGetNode(vaultId))
rvn->PrintTree(dumpProc, 0);
LogMsg(kLogDebug, L"<---- ID:%u, End Vault%*s%s ---->", vaultId, tag ? 1 : 0, L" ", tag);
}
rvn->PrintTree(0);
//============================================================================
void VaultDump (const wchar_t tag[], unsigned vaultId) {
VaultDump (tag, vaultId, LogDumpProc);
plStatusLog::AddLineS("VaultClient.log", plFormat("<---- ID:{}, End Vault {} ---->", vaultId, tag).c_str());
}
//============================================================================
@ -3526,7 +3404,7 @@ bool VaultAmOwnerOfCurrentAge () {
VaultAgeInfoNode curAgeInfo(currentAgeInfoNode);
plAgeInfoStruct info;
info.SetAgeFilename(plString::FromWchar(curAgeInfo.GetAgeFilename()));
info.SetAgeFilename(curAgeInfo.GetAgeFilename());
if (hsRef<RelVaultNode> rvnLink = VaultGetOwnedAgeLink(&info)) {
@ -3778,12 +3656,10 @@ hsRef<RelVaultNode> VaultFindAgeSubAgeLink (const plAgeInfoStruct * info) {
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, info->GetAgeFilename(), arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(info->GetAgeFilename());
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->Clear();
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
rvnLink = rvnInfo->GetParentNode(templateNode, 1);
}
@ -3808,7 +3684,7 @@ void VaultAddAgeChronicleEntry (
}
//============================================================================
hsRef<RelVaultNode> VaultAgeAddDeviceAndWait (const wchar_t deviceName[]) {
hsRef<RelVaultNode> VaultAgeAddDeviceAndWait (const plString& deviceName) {
if (hsRef<RelVaultNode> existing = VaultAgeGetDevice(deviceName))
return existing;
@ -3836,7 +3712,7 @@ hsRef<RelVaultNode> VaultAgeAddDeviceAndWait (const wchar_t deviceName[]) {
}
//============================================================================
void VaultAgeRemoveDevice (const wchar_t deviceName[]) {
void VaultAgeRemoveDevice (const plString& deviceName) {
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) {
hsRef<NetVaultNode> templateNode = new NetVaultNode;
templateNode->SetNodeType(plVault::kNodeType_TextNote);
@ -3845,14 +3721,15 @@ void VaultAgeRemoveDevice (const wchar_t deviceName[]) {
if (hsRef<RelVaultNode> device = folder->GetChildNode(templateNode, 1)) {
VaultRemoveChildNode(folder->GetNodeId(), device->GetNodeId(), nil, nil);
if (DeviceInbox * deviceInbox = s_ageDeviceInboxes.Find(CHashKeyStr(deviceName)))
delete device;
auto it = s_ageDeviceInboxes.find(deviceName);
if (it != s_ageDeviceInboxes.end())
s_ageDeviceInboxes.erase(it);
}
}
}
//============================================================================
bool VaultAgeHasDevice (const wchar_t deviceName[]) {
bool VaultAgeHasDevice (const plString& deviceName) {
bool found = false;
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) {
hsRef<NetVaultNode> templateNode = new NetVaultNode;
@ -3866,7 +3743,7 @@ bool VaultAgeHasDevice (const wchar_t deviceName[]) {
}
//============================================================================
hsRef<RelVaultNode> VaultAgeGetDevice (const wchar_t deviceName[]) {
hsRef<RelVaultNode> VaultAgeGetDevice (const plString& deviceName) {
hsRef<RelVaultNode> result;
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) {
hsRef<NetVaultNode> templateNode = new NetVaultNode;
@ -3880,20 +3757,13 @@ hsRef<RelVaultNode> VaultAgeGetDevice (const wchar_t deviceName[]) {
}
//============================================================================
hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait (const wchar_t deviceName[], const wchar_t inboxName[]) {
DeviceInbox * devInbox = s_ageDeviceInboxes.Find(CHashKeyStr(deviceName));
if (devInbox) {
StrCopy(devInbox->inboxName, inboxName, arrsize(devInbox->inboxName));
}
else {
devInbox = new DeviceInbox(deviceName, inboxName);
s_ageDeviceInboxes.Add(devInbox);
}
hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait (const plString& deviceName, const plString& inboxName) {
s_ageDeviceInboxes[deviceName] = inboxName;
// if we found the inbox or its a global inbox then return here, otherwise if its the default inbox and
// it wasn't found then continue on and create the inbox
hsRef<RelVaultNode> existing = VaultAgeGetDeviceInbox(deviceName);
if (existing || StrCmp(inboxName, DEFAULT_DEVICE_INBOX) != 0)
if (existing || inboxName == DEFAULT_DEVICE_INBOX)
return existing;
hsRef<RelVaultNode> device, inbox;
@ -3920,28 +3790,26 @@ hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait (const wchar_t deviceName[], c
}
//============================================================================
hsRef<RelVaultNode> VaultAgeGetDeviceInbox (const wchar_t deviceName[]) {
hsRef<RelVaultNode> VaultAgeGetDeviceInbox (const plString& deviceName) {
hsRef<RelVaultNode> result;
DeviceInbox * devInbox = s_ageDeviceInboxes.Find(CHashKeyStr(deviceName));
auto it = s_ageDeviceInboxes.find(deviceName);
if (devInbox)
{
if (it != s_ageDeviceInboxes.end()) {
hsRef<RelVaultNode> parentNode;
const wchar_t * inboxName = nil;
if (StrCmp(devInbox->inboxName, DEFAULT_DEVICE_INBOX) == 0) {
//if (StrCmp(devInbox->inboxName, DEFAULT_DEVICE_INBOX) == 0) {
if (it->second == DEFAULT_DEVICE_INBOX)
parentNode = VaultAgeGetDevice(deviceName);
}
else {
else
parentNode = VaultGetGlobalInbox();
}
if (parentNode) {
hsRef<NetVaultNode> templateNode = new NetVaultNode;
templateNode->SetNodeType(plVault::kNodeType_Folder);
VaultFolderNode access(templateNode);
access.SetFolderType(plVault::kDeviceInboxFolder);
access.SetFolderName(devInbox->inboxName);
access.SetFolderName(it->second);
result = parentNode->GetChildNode(templateNode, 1);
}
}
@ -3950,9 +3818,7 @@ hsRef<RelVaultNode> VaultAgeGetDeviceInbox (const wchar_t deviceName[]) {
//============================================================================
void VaultClearDeviceInboxMap () {
while (DeviceInbox * inbox = s_ageDeviceInboxes.Head()) {
delete inbox;
}
s_ageDeviceInboxes.clear();
}
//============================================================================
@ -3998,12 +3864,10 @@ hsRef<RelVaultNode> VaultGetSubAgeLink (const plAgeInfoStruct * info) {
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, info->GetAgeFilename(), arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(info->GetAgeFilename());
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->Clear();
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
rvnLink = rvnInfo->GetParentNode(templateNode, 1);
}
@ -4175,7 +4039,7 @@ bool VaultAgeFindOrCreateSubAgeLinkAndWait (
memset(&param, 0, sizeof(param));
VaultDownload(
L"CreateSubAge",
"CreateSubAge",
ageInfoId,
_FetchVaultCallback,
&param,
@ -4292,7 +4156,7 @@ namespace _VaultCreateSubAge {
}
// Download age vault
VaultDownload(L"CreateSubAge",
VaultDownload("CreateSubAge",
ageInfoId,
(FVaultDownloadCallback)_DownloadCallback,
(void*)ageInfoId,
@ -4438,12 +4302,10 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait (
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, info->GetAgeFilename(), arrsize(str));
ageInfo.SetAgeFilename(str);
ageInfo.SetAgeFilename(info->GetAgeFilename());
if (hsRef<RelVaultNode> rvnInfo = rvnChildAges->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->Clear();
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
rvnLink = rvnInfo->GetParentNode(templateNode, 1);
}
@ -4517,7 +4379,7 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait (
memset(&param, 0, sizeof(param));
VaultDownload(
L"CreateChildAge",
"CreateChildAge",
ageInfoId,
_FetchVaultCallback,
&param,
@ -4646,7 +4508,7 @@ namespace _VaultCreateChildAge {
p->fAgeInfoId = (void*)ageInfoId;
// Download age vault
VaultDownload(L"CreateChildAge",
VaultDownload("CreateChildAge",
ageInfoId,
(FVaultDownloadCallback)_DownloadCallback,
param,
@ -4684,14 +4546,11 @@ uint8_t VaultAgeFindOrCreateChildAgeLink(
// Still here? Try to find the Child Ages folder
uint8_t retval = hsFail;
if (hsRef<RelVaultNode> rvnChildAges = rvnParentInfo->GetChildAgeInfoListNode(plVault::kChildAgesFolder, 1)) {
wchar_t hack[MAX_PATH];
StrToUnicode(hack, info->GetAgeFilename(), arrsize(hack));
// Search for our age
hsRef<NetVaultNode> temp = new NetVaultNode;
temp->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode theAge(temp);
theAge.SetAgeFilename(hack);
theAge.SetAgeFilename(info->GetAgeFilename());
if (hsRef<RelVaultNode> rvnAgeInfo = rvnChildAges->GetChildNode(temp, 2)) {
hsRef<RelVaultNode> rvnAgeLink = rvnAgeInfo->GetParentAgeLink();
@ -4741,7 +4600,7 @@ void VaultCCRDumpPlayers() {
//============================================================================
void VaultDownload (
const wchar_t tag[],
const plString& tag,
unsigned vaultId,
FVaultDownloadCallback callback,
void * cbParam,
@ -4773,7 +4632,7 @@ static void _DownloadVaultCallback (
}
void VaultDownloadAndWait (
const wchar_t tag[],
const plString& tag,
unsigned vaultId,
FVaultProgressCallback progressCallback,
void * cbProgressParam

37
Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h

@ -181,8 +181,8 @@ struct RelVaultNode : NetVaultNode {
void SetSeen (unsigned parentId, bool seen);
// logging
void Print (const wchar_t tag[], FStateDump dumpProc, unsigned level);
void PrintTree (FStateDump dumpProc, unsigned level);
void Print (const plString& tag, unsigned level);
void PrintTree (unsigned level);
// AgeInfoNode-specific (and it checks!)
hsRef<RelVaultNode> GetParentAgeLink ();
@ -246,7 +246,7 @@ void VaultDeleteNode (
);
void VaultPublishNode (
unsigned nodeId,
const wchar_t deviceName[]
const plString& deviceName
);
void VaultSendNode (
RelVaultNode* srcNode,
@ -354,20 +354,19 @@ bool VaultRegisterVisitAgeAndWait(const plAgeLinkStruct * link);
void VaultRegisterVisitAge(const plAgeLinkStruct* link);
bool VaultUnregisterOwnedAgeAndWait(const plAgeInfoStruct * info);
bool VaultUnregisterVisitAgeAndWait(const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultFindChronicleEntry(const wchar_t entryName[], int entryType = -1);
bool VaultHasChronicleEntry(const wchar_t entryName[], int entryType = -1);
hsRef<RelVaultNode> VaultFindChronicleEntry(const plString& entryName, int entryType = -1);
bool VaultHasChronicleEntry(const plString& entryName, int entryType = -1);
// if entry of same name and type already exists, value is updated
void VaultAddChronicleEntryAndWait (
const wchar_t entryName[],
int entryType,
const wchar_t entryValue[]
const plString& entryName,
int entryType,
const plString& entryValue
);
bool VaultAmIgnoringPlayer (unsigned playerId);
unsigned VaultGetKILevel ();
bool VaultGetCCRStatus (); // true=online, false=away
bool VaultSetCCRStatus (bool online); // true=online, false=away
void VaultDump (const wchar_t tag[], unsigned vaultId, FStateDump dumpProc);
void VaultDump (const wchar_t tag[], unsigned vaultId);
void VaultDump (const plString& tag, unsigned vaultId);
bool VaultAmInMyPersonalAge ();
bool VaultAmInMyNeighborhoodAge ();
@ -388,7 +387,7 @@ void VaultProcessPlayerInbox ();
*
***/
#define DEFAULT_DEVICE_INBOX L"DevInbox"
#define DEFAULT_DEVICE_INBOX "DevInbox"
hsRef<RelVaultNode> VaultGetAgeNode();
hsRef<RelVaultNode> VaultGetAgeInfoNode();
@ -410,12 +409,12 @@ void VaultAddAgeChronicleEntry (
int entryType,
const wchar_t entryValue[]
);
hsRef<RelVaultNode> VaultAgeAddDeviceAndWait(const wchar_t deviceName[]); // blocks until completion
void VaultAgeRemoveDevice (const wchar_t deviceName[]);
bool VaultAgeHasDevice (const wchar_t deviceName[]);
hsRef<RelVaultNode> VaultAgeGetDevice(const wchar_t deviceName[]);
hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait(const wchar_t deviceName[], const wchar_t inboxName[]); // blocks until completion
hsRef<RelVaultNode> VaultAgeGetDeviceInbox(const wchar_t deviceName[]);
hsRef<RelVaultNode> VaultAgeAddDeviceAndWait(const plString& deviceName); // blocks until completion
void VaultAgeRemoveDevice (const plString& deviceName);
bool VaultAgeHasDevice (const plString& deviceName);
hsRef<RelVaultNode> VaultAgeGetDevice(const plString& deviceName);
hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait(const plString& deviceName, const plString& inboxName); // blocks until completion
hsRef<RelVaultNode> VaultAgeGetDeviceInbox(const plString& deviceName);
void VaultClearDeviceInboxMap ();
bool VaultAgeGetAgeSDL (class plStateDataRecord * out);
@ -470,7 +469,7 @@ typedef void (*FVaultProgressCallback)(
);
void VaultDownload (
const wchar_t tag[],
const plString& tag,
unsigned vaultId,
FVaultDownloadCallback callback,
void * cbParam,
@ -478,7 +477,7 @@ void VaultDownload (
void * cbProgressParam
);
void VaultDownloadAndWait (
const wchar_t tag[],
const plString& tag,
unsigned vaultId,
FVaultProgressCallback progressCallback,
void * cbProgressParam

263
Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp

@ -48,37 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "Pch.h"
#pragma hdrstop
//============================================================================
// Volatile Vault Node Fields - be very careful when adding to this
//============================================================================
struct NodeTypeToVolatileField {
unsigned nodeType;
uint64_t volatileFields;
};
NodeTypeToVolatileField volatileFieldList[] = {
{plVault::kNodeType_PlayerInfo, VaultPlayerInfoNode::kOnline | VaultPlayerInfoNode::kAgeInstName | VaultPlayerInfoNode::kAgeInstUuid},
{0, 0}
};
//============================================================================
uint64_t GetNodeVolatileFields(NetVaultNode* node) {
uint64_t volatileFields = 0;
unsigned index = 0;
while (volatileFieldList[index].nodeType != 0) {
if (node->GetNodeType() == volatileFieldList[index].nodeType) {
volatileFields |= volatileFieldList[index].volatileFields;
break;
}
++index;
}
return volatileFields;
}
/*****************************************************************************
*
* VaultTextNoteNode
@ -99,170 +68,66 @@ enum EAgeInfoFields {
#ifdef CLIENT
void VaultTextNoteNode::SetVisitInfo (const plAgeInfoStruct & info) {
ARRAY(wchar_t) buf;
plStringStream str;
for (unsigned i = 0; i < kNumAgeInfoFields; ++i) {
switch (i) {
case kAgeFilename: {
wchar_t src[128];
StrToUnicode(src, info.GetAgeFilename(), arrsize(src));
unsigned len = StrLen(src);
wchar_t * dst = buf.New(len);
memcpy(dst, src, len * sizeof(src[0]));
}
case kAgeFilename:
str << info.GetAgeFilename();
break;
case kAgeInstName: {
wchar_t src[128];
StrToUnicode(src, info.GetAgeInstanceName(), arrsize(src));
unsigned len = StrLen(src);
wchar_t * dst = buf.New(len);
memcpy(dst, src, len * sizeof(src[0]));
}
case kAgeInstName:
str << info.GetAgeInstanceName();
break;
case kAgeUserName: {
wchar_t src[128];
StrToUnicode(src, info.GetAgeUserDefinedName(), arrsize(src));
unsigned len = StrLen(src);
wchar_t * dst = buf.New(len);
memcpy(dst, src, len * sizeof(src[0]));
}
case kAgeUserName:
str << info.GetAgeUserDefinedName();
break;
case kAgeDesc: {
wchar_t src[128];
StrToUnicode(src, info.GetAgeDescription(), arrsize(src));
unsigned len = StrLen(src);
wchar_t * dst = buf.New(len);
memcpy(dst, src, len * sizeof(src[0]));
}
case kAgeDesc:
str << info.GetAgeDescription();
break;
case kAgeInstGuid: {
plUUID guid = *info.GetAgeInstanceGuid();
wchar_t src[64];
wcsncpy(src, guid.AsString().ToWchar(), 64);
unsigned len = StrLen(src);
wchar_t * dst = buf.New(len);
memcpy(dst, src, len * sizeof(src[0]));
}
case kAgeInstGuid:
str << info.GetAgeInstanceGuid()->AsString();
break;
case kAgeLanguage: {
wchar_t src[32];
StrPrintf(src, arrsize(src), L"%u", info.GetAgeLanguage());
unsigned len = StrLen(src);
wchar_t * dst = buf.New(len);
memcpy(dst, src, len * sizeof(src[0]));
}
case kAgeLanguage:
str << info.GetAgeLanguage();
break;
case kAgeSequence: {
wchar_t src[32];
StrPrintf(src, arrsize(src), L"%u", info.GetAgeSequenceNumber());
unsigned len = StrLen(src);
wchar_t * dst = buf.New(len);
memcpy(dst, src, len * sizeof(src[0]));
}
case kAgeSequence:
str << info.GetAgeSequenceNumber();
break;
DEFAULT_FATAL(i);
DEFAULT_FATAL(i);
}
wchar_t * sep = buf.New(1);
*sep = L'|';
str << "|";
}
wchar_t * term = buf.New(1);
*term = 0;
SetNoteText(buf.Ptr());
SetNoteText(str.GetString());
}
#endif
//============================================================================
#ifdef CLIENT
bool VaultTextNoteNode::GetVisitInfo (plAgeInfoStruct * info) {
std::vector<plString> toks = GetNoteText().Split("|");
hsAssert(toks.size() == kNumAgeInfoFields, "visit text note malformed--discarding");
if (toks.size() != kNumAgeInfoFields)
return false;
wchar_t * mem;
const wchar_t * str = mem = wcsdup(GetNoteText());
for (unsigned i = 0; i < kNumAgeInfoFields; ++i) {
wchar_t token[1024];
switch (i) {
case kAgeFilename: {
StrTokenize(&str, token, arrsize(token), L"|", 1);
if (StrLen(token) > 0) {
char ansi[1024];
StrToAnsi(ansi, token, arrsize(ansi));
info->SetAgeFilename(ansi);
}
}
break;
case kAgeInstName: {
StrTokenize(&str, token, arrsize(token), L"|", 1);
if (StrLen(token) > 0) {
char ansi[1024];
StrToAnsi(ansi, token, arrsize(ansi));
info->SetAgeInstanceName(ansi);
}
}
break;
case kAgeUserName: {
StrTokenize(&str, token, arrsize(token), L"|", 1);
if (StrLen(token) > 0) {
char ansi[1024];
StrToAnsi(ansi, token, arrsize(ansi));
info->SetAgeUserDefinedName(ansi);
}
}
break;
case kAgeDesc: {
StrTokenize(&str, token, arrsize(token), L"|", 1);
if (StrLen(token) > 0) {
char ansi[1024];
StrToAnsi(ansi, token, arrsize(ansi));
info->SetAgeDescription(ansi);
}
}
break;
case kAgeInstGuid: {
StrTokenize(&str, token, arrsize(token), L"|", 1);
if (StrLen(token) > 0) {
plUUID uuid(plString::FromWchar(token));
info->SetAgeInstanceGuid(&uuid);
}
}
break;
case kAgeLanguage: {
StrTokenize(&str, token, arrsize(token), L"|", 1);
if (StrLen(token) > 0) {
info->SetAgeLanguage(StrToUnsigned(token, nil, 10));
}
}
break;
case kAgeSequence: {
StrTokenize(&str, token, arrsize(token), L"|", 1);
if (StrLen(token) > 0) {
info->SetAgeSequenceNumber(StrToUnsigned(token, nil, 10));
}
}
break;
DEFAULT_FATAL(i);
}
if (!toks[kAgeFilename].IsEmpty())
info->SetAgeFilename(toks[kAgeFilename]);
if (!toks[kAgeInstName].IsEmpty())
info->SetAgeInstanceName(toks[kAgeInstName]);
if (!toks[kAgeUserName].IsEmpty())
info->SetAgeUserDefinedName(toks[kAgeUserName]);
if (!toks[kAgeDesc].IsEmpty())
info->SetAgeDescription(toks[kAgeDesc]);
if (!toks[kAgeInstGuid].IsEmpty()) {
std::unique_ptr<plUUID> guid = std::make_unique<plUUID>(toks[kAgeInstGuid]);
info->SetAgeInstanceGuid(guid.get());
}
free(mem);
if (!toks[kAgeLanguage].IsEmpty())
info->SetAgeLanguage(toks[kAgeLanguage].ToUInt());
if (!toks[kAgeSequence].IsEmpty())
info->SetAgeSequenceNumber(toks[kAgeSequence].ToUInt());
return true;
}
#endif
@ -327,7 +192,7 @@ void VaultSDLNode::SetStateDataRecord (const plStateDataRecord * rec, unsigned w
//============================================================================
#ifdef CLIENT
void VaultSDLNode::InitStateDataRecord (const wchar_t sdlRecName[], unsigned writeOptions) {
void VaultSDLNode::InitStateDataRecord (const plString& sdlRecName, unsigned writeOptions) {
{
plStateDataRecord * rec = new plStateDataRecord;
bool exists = GetStateDataRecord(rec, 0);
@ -336,9 +201,7 @@ void VaultSDLNode::InitStateDataRecord (const wchar_t sdlRecName[], unsigned wri
return;
}
char aStr[MAX_PATH];
StrToAnsi(aStr, sdlRecName, arrsize(aStr));
if (plStateDescriptor * des = plSDLMgr::GetInstance()->FindDescriptor(aStr, plSDL::kLatestVersion)) {
if (plStateDescriptor * des = plSDLMgr::GetInstance()->FindDescriptor(sdlRecName, plSDL::kLatestVersion)) {
plStateDataRecord rec(des);
rec.SetFromDefaults(false);
SetStateDataRecord(&rec, writeOptions|plSDL::kDontWriteDirtyFlag);
@ -555,44 +418,17 @@ const class plUnifiedTime * VaultAgeInfoNode::GetAgeTime () const {
//============================================================================
#ifdef CLIENT
void VaultAgeInfoNode::CopyFrom (const plAgeInfoStruct * info) {
wchar_t str[MAX_PATH];
// age filename
if (info->HasAgeFilename()) {
StrToUnicode(str, info->GetAgeFilename(), arrsize(str));
SetAgeFilename(str);
}
else {
SetAgeFilename(nil);
}
SetAgeFilename(info->HasAgeFilename() ? info->GetAgeFilename() : "");
// age instance name
if (info->HasAgeInstanceName()) {
StrToUnicode(str, info->GetAgeInstanceName(), arrsize(str));
SetAgeInstanceName(str);
}
else {
SetAgeInstanceName(nil);
}
SetAgeInstanceName(info->HasAgeInstanceName() ? info->GetAgeInstanceName() : "");
// age user-defined name
if (info->HasAgeUserDefinedName()) {
StrToUnicode(str, info->GetAgeUserDefinedName(), arrsize(str));
SetAgeUserDefinedName(str);
}
else {
SetAgeUserDefinedName(nil);
}
SetAgeUserDefinedName(info->HasAgeUserDefinedName() ? info->GetAgeUserDefinedName() : "");
// age description
// TODO
if (info->HasAgeDescription()) {
// StrToUnicode(str, info->GetAgeDescription(), arrsize(str));
// SetAgeDescription(str);
}
else {
// SetAgeDescription(nil);
}
SetAgeDescription(info->HasAgeDescription() ? info->GetAgeDescription() : "");
// age sequence number
SetAgeSequenceNumber(info->GetAgeSequenceNumber());
@ -608,22 +444,17 @@ void VaultAgeInfoNode::CopyFrom (const plAgeInfoStruct * info) {
//============================================================================
#ifdef CLIENT
void VaultAgeInfoNode::CopyTo (plAgeInfoStruct * info) const {
char str[MAX_PATH];
// age filename
StrToAnsi(str, GetAgeFilename(), arrsize(str));
info->SetAgeFilename(str);
info->SetAgeFilename(GetAgeFilename());
// age instance name
StrToAnsi(str, GetAgeInstanceName(), arrsize(str));
info->SetAgeInstanceName(str);
info->SetAgeInstanceName(GetAgeInstanceName());
// age user-defined name
StrToAnsi(str, GetAgeUserDefinedName(), arrsize(str));
info->SetAgeUserDefinedName(str);
info->SetAgeUserDefinedName(GetAgeUserDefinedName());
// age description
// TODO
info->SetAgeDescription(GetAgeDescription());
// age sequence number
info->SetAgeSequenceNumber(GetAgeSequenceNumber());

47
Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h

@ -64,11 +64,6 @@ struct plSpawnPointInfo;
typedef std::vector<plSpawnPointInfo> plSpawnPointVec;
#endif
//============================================================================
// Volatile Vault Node Fields
//============================================================================
uint64_t GetNodeVolatileFields(NetVaultNode* node);
//============================================================================
// NetVaultNodeAccess
//============================================================================
@ -83,22 +78,24 @@ private:
};
#define VNODE_ACCESSOR(type, name, basename) \
static const uint64_t k##name = NetVaultNode::k##basename; \
type Get##name () const { return base->Get##basename(); } \
void Set##name (type v) { base->Set##basename(v); }
#define VNODE_BLOB(name, basename) \
static const uint64_t k##name = NetVaultNode::k##basename; \
const uint8_t * Get##name () const { return base->Get##basename(); } \
size_t Get##name##Length () const { return base->Get##basename##Length(); } \
void Set##name (const uint8_t data[], size_t length) { base->Set##basename(data, length); }
#define VNODE_STRING(name, basename) \
plString Get##name () const { return base->Get##basename(); } \
void Set##name (const plString& v) { base->Set##basename(v); }
//============================================================================
// VaultPlayerNode
//============================================================================
struct VaultPlayerNode : NetVaultNodeAccess {
VNODE_ACCESSOR(const wchar_t *, PlayerName, IString64_1);
VNODE_ACCESSOR(const wchar_t *, AvatarShapeName, String64_1);
VNODE_STRING ( PlayerName, IString64_1);
VNODE_STRING ( AvatarShapeName, String64_1);
VNODE_ACCESSOR(int32_t, Disabled, Int32_1);
VNODE_ACCESSOR(int32_t, Explorer, Int32_2); // explorer = 1, visitor = 0
VNODE_ACCESSOR(uint32_t, OnlineTime, UInt32_1);
@ -114,8 +111,8 @@ struct VaultPlayerNode : NetVaultNodeAccess {
//============================================================================
struct VaultPlayerInfoNode : NetVaultNodeAccess {
VNODE_ACCESSOR(uint32_t, PlayerId, UInt32_1);
VNODE_ACCESSOR(const wchar_t *, PlayerName, IString64_1);
VNODE_ACCESSOR(const wchar_t *, AgeInstName, String64_1); // name of age player is currently in
VNODE_STRING ( PlayerName, IString64_1);
VNODE_STRING ( AgeInstName, String64_1); // name of age player is currently in
VNODE_ACCESSOR(plUUID, AgeInstUuid, Uuid_1); // guid of age player is currently in
VNODE_ACCESSOR(int32_t, Online, Int32_1); // whether or not player is online
VNODE_ACCESSOR(int32_t, CCRLevel, Int32_2);
@ -129,7 +126,7 @@ struct VaultPlayerInfoNode : NetVaultNodeAccess {
//============================================================================
struct VaultFolderNode : NetVaultNodeAccess {
VNODE_ACCESSOR(int32_t, FolderType, Int32_1);
VNODE_ACCESSOR(const wchar_t *, FolderName, String64_1);
VNODE_STRING ( FolderName, String64_1);
VaultFolderNode (NetVaultNode * node) : NetVaultNodeAccess(node) { }
};
@ -154,8 +151,8 @@ struct VaultAgeInfoListNode : VaultFolderNode {
//============================================================================
struct VaultChronicleNode : NetVaultNodeAccess {
VNODE_ACCESSOR(int32_t, EntryType, Int32_1);
VNODE_ACCESSOR(const wchar_t *, EntryName, String64_1);
VNODE_ACCESSOR(const wchar_t *, EntryValue, Text_1);
VNODE_STRING ( EntryName, String64_1);
VNODE_STRING ( EntryValue, Text_1);
VaultChronicleNode (NetVaultNode * node) : NetVaultNodeAccess(node) { }
};
@ -165,7 +162,7 @@ struct VaultChronicleNode : NetVaultNodeAccess {
// VaultSDLNode
//============================================================================
struct VaultSDLNode : NetVaultNodeAccess {
VNODE_ACCESSOR(const wchar_t *, SDLName, String64_1);
VNODE_STRING ( SDLName, String64_1);
VNODE_ACCESSOR(int32_t, SDLIdent, Int32_1);
VNODE_BLOB ( SDLData, Blob_1);
@ -174,7 +171,7 @@ struct VaultSDLNode : NetVaultNodeAccess {
#ifdef CLIENT
bool GetStateDataRecord (class plStateDataRecord * out, unsigned readOptions = 0);
void SetStateDataRecord (const class plStateDataRecord * rec, unsigned writeOptions = 0);
void InitStateDataRecord (const wchar_t sdlRecName[], unsigned writeOptions = 0);
void InitStateDataRecord (const plString& sdlRecName, unsigned writeOptions = 0);
#endif // def CLIENT
};
@ -206,7 +203,7 @@ struct VaultImageNode : NetVaultNodeAccess {
enum ImageTypes { kNone=0, kJPEG=1, kPNG=2 };
VNODE_ACCESSOR(int32_t, ImageType, Int32_1);
VNODE_ACCESSOR(const wchar_t *, ImageTitle, String64_1);
VNODE_STRING ( ImageTitle, String64_1);
VNODE_BLOB ( ImageData, Blob_1);
VaultImageNode (NetVaultNode * node) : NetVaultNodeAccess(node) { }
@ -234,8 +231,8 @@ struct VaultCliImageNode : VaultImageNode {
struct VaultTextNoteNode : NetVaultNodeAccess {
VNODE_ACCESSOR(int32_t, NoteType, Int32_1);
VNODE_ACCESSOR(int32_t, NoteSubType, Int32_2);
VNODE_ACCESSOR(const wchar_t *, NoteTitle, String64_1);
VNODE_ACCESSOR(const wchar_t *, NoteText, Text_1);
VNODE_STRING ( NoteTitle, String64_1);
VNODE_STRING ( NoteText, Text_1);
VaultTextNoteNode (NetVaultNode * node) : NetVaultNodeAccess(node) { }
@ -252,7 +249,7 @@ struct VaultTextNoteNode : NetVaultNodeAccess {
struct VaultAgeNode : NetVaultNodeAccess {
VNODE_ACCESSOR(plUUID, AgeInstanceGuid, Uuid_1);
VNODE_ACCESSOR(plUUID, ParentAgeInstanceGuid, Uuid_2);
VNODE_ACCESSOR(const wchar_t *, AgeName, String64_1);
VNODE_STRING ( AgeName, String64_1);
VaultAgeNode (NetVaultNode * node) : NetVaultNodeAccess(node) { }
};
@ -261,12 +258,12 @@ struct VaultAgeNode : NetVaultNodeAccess {
// VaultAgeInfoNode
//============================================================================
struct VaultAgeInfoNode : NetVaultNodeAccess {
VNODE_ACCESSOR(const wchar_t *, AgeFilename, String64_2); // "Garden"
VNODE_ACCESSOR(const wchar_t *, AgeInstanceName, String64_3); // "Eder Kemo"
VNODE_ACCESSOR(const wchar_t *, AgeUserDefinedName, String64_4); // "Joe's"
VNODE_STRING ( AgeFilename, String64_2); // "Garden"
VNODE_STRING ( AgeInstanceName, String64_3); // "Eder Kemo"
VNODE_STRING ( AgeUserDefinedName, String64_4); // "Joe's"
VNODE_ACCESSOR(plUUID, AgeInstanceGuid, Uuid_1); // 6278b081-342a-4229-ac1b-a0b8a2658390
VNODE_ACCESSOR(plUUID, ParentAgeInstanceGuid, Uuid_2); // 9192be7f-89ef-41bc-83db-79afe451e399
VNODE_ACCESSOR(const wchar_t *, AgeDescription, Text_1); // "Stay out!"
VNODE_STRING ( AgeDescription, Text_1); // "Stay out!"
VNODE_ACCESSOR(int32_t, AgeSequenceNumber, Int32_1);
VNODE_ACCESSOR(int32_t, AgeLanguage, Int32_3); // The language of the client that made this age
VNODE_ACCESSOR(uint32_t, AgeId, UInt32_1);
@ -299,7 +296,7 @@ struct VaultSystemNode : NetVaultNodeAccess {
// VaultMarkerGameNode
//============================================================================
struct VaultMarkerGameNode : NetVaultNodeAccess {
VNODE_ACCESSOR(const wchar_t *, GameName, Text_1);
VNODE_STRING ( GameName, Text_1);
VNODE_ACCESSOR(plUUID, GameGuid, Uuid_1);
VaultMarkerGameNode (NetVaultNode * node) : NetVaultNodeAccess(node) { }

Loading…
Cancel
Save