Browse Source

Merge pull request #437 from zrax/hsRef

Clean up ref-counting
Adam Johnson 11 years ago
parent
commit
d27f102166
  1. 102
      Sources/Plasma/CoreLib/hsRefCnt.cpp
  2. 82
      Sources/Plasma/CoreLib/hsRefCnt.h
  3. 6
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp
  4. 6
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  5. 3
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  6. 2
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp
  7. 2
      Sources/Plasma/FeatureLib/pfPython/pyAgeLinkStructGlue.cpp
  8. 119
      Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp
  9. 13
      Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp
  10. 12
      Sources/Plasma/FeatureLib/pfPython/pyGameScore.cpp
  11. 2
      Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h
  12. 4
      Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfoGlue.cpp
  13. 144
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  14. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoListNodeGlue.cpp
  15. 15
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp
  16. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp
  17. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp
  18. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNodeGlue.cpp
  19. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp
  20. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNodeGlue.cpp
  21. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNodeGlue.cpp
  22. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp
  23. 92
      Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp
  24. 9
      Sources/Plasma/FeatureLib/pfPython/pyVaultNode.h
  25. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultNodeGlue.cpp
  26. 38
      Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRef.cpp
  27. 11
      Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRef.h
  28. 8
      Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRefGlue.cpp
  29. 38
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp
  30. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNodeGlue.cpp
  31. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp
  32. 28
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp
  33. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNodeGlue.cpp
  34. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultSDLNodeGlue.cpp
  35. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultSystemNodeGlue.cpp
  36. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp
  37. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNodeGlue.cpp
  38. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h
  39. 4
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp
  40. 4
      Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp
  41. 2
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp
  42. 2
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h
  43. 121
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  44. 3
      Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp
  45. 39
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  46. 10
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  47. 21
      Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp
  48. 2
      Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.h
  49. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h
  50. 22
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  51. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  52. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp
  53. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp
  54. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp
  55. 2
      Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h
  56. 10
      Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.cpp
  57. 3
      Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.h
  58. 1037
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp
  59. 111
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h
  60. 6
      Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp

102
Sources/Plasma/CoreLib/hsRefCnt.cpp

@ -46,43 +46,101 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsExceptions.h"
#include "hsRefCnt.h"
hsRefCnt::~hsRefCnt()
{
#ifdef HS_DEBUGGING
hsThrowIfFalse(fRefCnt == 1);
#define REFCOUNT_DBG_NONE 0
#define REFCOUNT_DBG_REFS 1
#define REFCOUNT_DBG_LEAKS 2
#define REFCOUNT_DBG_ALL 3
#define REFCOUNT_DEBUGGING REFCOUNT_DBG_NONE
#if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_LEAKS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL)
#include <unordered_set>
#include <mutex>
#include "plFormat.h"
// hsDebugMessage can get overridden to dump to a file :(
#ifdef _MSC_VER
# include "hsWindows.h"
# define _LeakDebug(message) OutputDebugString(message)
#else
# define _LeakDebug(message) fputs(message, stderr)
#endif
struct _RefCountLeakCheck
{
std::unordered_set<hsRefCnt *> m_refs;
unsigned m_added, m_removed;
std::mutex m_mutex;
~_RefCountLeakCheck()
{
std::lock_guard<std::mutex> lock(m_mutex);
_LeakDebug(plFormat("Refs tracked: {} created, {} destroyed\n",
m_added, m_removed).c_str());
if (m_refs.empty())
return;
_LeakDebug(plFormat(" {} objects leaked...\n", m_refs.size()).c_str());
for (hsRefCnt *ref : m_refs) {
_LeakDebug(plFormat(" 0x{_08x} {}: {} refs remain\n",
(uintptr_t)ref, typeid(*ref).name(), ref->RefCnt()).c_str());
}
}
void hsRefCnt::UnRef()
static _RefCountLeakCheck *_instance()
{
#ifdef HS_DEBUGGING
hsThrowIfFalse(fRefCnt >= 1);
static _RefCountLeakCheck s_instance;
return &s_instance;
}
static void add(hsRefCnt *ref)
{
_RefCountLeakCheck *this_p = _instance();
std::lock_guard<std::mutex> lock(this_p->m_mutex);
++this_p->m_added;
this_p->m_refs.insert(ref);
}
static void del(hsRefCnt *ref)
{
_RefCountLeakCheck *this_p = _instance();
std::lock_guard<std::mutex> lock(this_p->m_mutex);
++this_p->m_removed;
this_p->m_refs.erase(ref);
}
};
#endif
if (fRefCnt == 1) // don't decrement if we call delete
delete this;
else
--fRefCnt;
hsRefCnt::hsRefCnt(int initRefs)
: fRefCnt(initRefs)
{
#if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_LEAKS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL)
_RefCountLeakCheck::add(this);
#endif
}
hsAtomicRefCnt::~hsAtomicRefCnt()
hsRefCnt::~hsRefCnt()
{
#ifdef HS_DEBUGGING
hsThrowIfFalse(fRefCnt == 1);
#endif
#if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_LEAKS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL)
_RefCountLeakCheck::del(this);
#endif
}
void hsAtomicRefCnt::UnRef(const char* tag)
void hsRefCnt::UnRef(const char* tag)
{
#ifdef HS_DEBUGGING
hsThrowIfFalse(fRefCnt >= 1);
#endif
#ifdef REFCOUNT_DEBUGGING
#if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_REFS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL)
if (tag)
DEBUG_MSG("Dec %p %s: %u", this, tag, prev - 1);
DEBUG_MSG("Dec %p %s: %u", this, tag, fRefCnt - 1);
else
DEBUG_MSG("Dec %p: %u", this, prev - 1);
DEBUG_MSG("Dec %p: %u", this, fRefCnt - 1);
#endif
if (fRefCnt == 1) // don't decrement if we call delete
@ -91,21 +149,21 @@ void hsAtomicRefCnt::UnRef(const char* tag)
--fRefCnt;
}
void hsAtomicRefCnt::Ref(const char* tag)
void hsRefCnt::Ref(const char* tag)
{
#ifdef REFCOUNT_DEBUGGING
#if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_REFS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL)
if (tag)
DEBUG_MSG("Inc %p %s: %u", this, tag, prev + 1);
DEBUG_MSG("Inc %p %s: %u", this, tag, fRefCnt + 1);
else
DEBUG_MSG("Inc %p: %u", this, prev + 1);
DEBUG_MSG("Inc %p: %u", this, fRefCnt + 1);
#endif
++fRefCnt;
}
void hsAtomicRefCnt::TransferRef(const char* oldTag, const char* newTag)
void hsRefCnt::TransferRef(const char* oldTag, const char* newTag)
{
#ifdef REFCOUNT_DEBUGGING
#if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_REFS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL)
DEBUG_MSG("Inc %p %s: (xfer)", this, newTag);
DEBUG_MSG("Dec %p %s: (xfer)", this, oldTag);
#endif

82
Sources/Plasma/CoreLib/hsRefCnt.h

@ -46,15 +46,25 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class hsRefCnt {
private:
int fRefCnt;
std::atomic<int> fRefCnt;
public:
hsRefCnt(int initRefs = 1) : fRefCnt(initRefs) {}
hsRefCnt(int initRefs = 1);
virtual ~hsRefCnt();
inline int RefCnt() const { return fRefCnt; }
void UnRef();
inline void Ref() { ++fRefCnt; }
void UnRef(const char* tag = nullptr);
void Ref(const char* tag = nullptr);
// Useless, but left here for debugging compatibility with AtomicRef
void TransferRef(const char* oldTag, const char* newTag);
// The stored reference count of an hsRefCnt-derived object should never
// be copied! Therefore, if you want a copyable hsRefCnt-based class, you
// should implement your own copy constructor / assignment operator.
hsRefCnt(const hsRefCnt &) = delete;
hsRefCnt &operator=(const hsRefCnt &) = delete;
};
#define hsRefCnt_SafeRef(obj) do { if (obj) (obj)->Ref(); } while (0)
@ -68,23 +78,61 @@ public:
} while (0)
// Thread-safe version. TODO: Evaluate whether this is fast enough to
// merge with hsRefCnt above.
class hsAtomicRefCnt
template <class _Ref>
class hsRef
{
private:
std::atomic<int> fRefCnt;
public:
hsAtomicRefCnt(int initRefs = 1) : fRefCnt(initRefs) { }
virtual ~hsAtomicRefCnt();
hsRef() : fObj(nullptr) { }
hsRef(nullptr_t) : fObj(nullptr) { }
hsRef(_Ref *obj) : fObj(obj) { if (fObj) fObj->Ref(); }
hsRef(const hsRef<_Ref> &copy) : fObj(copy.fObj) { if (fObj) fObj->Ref(); }
hsRef(hsRef<_Ref> &&move) : fObj(move.fObj) { move.fObj = nullptr; }
inline int RefCnt() const { return fRefCnt; }
void UnRef(const char* tag = nullptr);
void Ref(const char* tag = nullptr);
~hsRef() { if (fObj) fObj->UnRef(); }
// Useless, but left here for debugging compatibility with AtomicRef
void TransferRef(const char* oldTag, const char* newTag);
hsRef<_Ref> &operator=(_Ref *obj)
{
if (obj)
obj->Ref();
if (fObj)
fObj->UnRef();
fObj = obj;
return *this;
}
hsRef<_Ref> &operator=(const hsRef<_Ref> &copy) { return operator=(copy.fObj); }
hsRef<_Ref> &operator=(hsRef<_Ref> &&move)
{
if (fObj)
fObj->UnRef();
fObj = move.fObj;
move.fObj = nullptr;
return *this;
}
hsRef<_Ref> &operator=(nullptr_t)
{
if (fObj)
fObj->UnRef();
fObj = nullptr;
return *this;
}
bool operator==(const hsRef<_Ref> &other) const { return fObj == other.fObj; }
bool operator!=(const hsRef<_Ref> &other) const { return fObj != other.fObj; }
bool operator> (const hsRef<_Ref> &other) const { return fObj > other.fObj; }
bool operator< (const hsRef<_Ref> &other) const { return fObj < other.fObj; }
bool operator>=(const hsRef<_Ref> &other) const { return fObj >= other.fObj; }
bool operator<=(const hsRef<_Ref> &other) const { return fObj <= other.fObj; }
bool operator==(_Ref *other) const { return fObj == other; }
bool operator!=(_Ref *other) const { return fObj != other; }
_Ref &operator*() const { return *fObj; }
_Ref *const operator->() const { return fObj; }
operator _Ref *const() const { return fObj; }
private:
_Ref *fObj;
};
#endif

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

@ -1670,11 +1670,10 @@ void cyAvatar::ChangeAvatar(const char* genderName)
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, genderName, arrsize(wStr));
RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef();
hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode();
if (rvnPlr) {
VaultPlayerNode plr(rvnPlr);
plr.SetAvatarShapeName(wStr);
rvnPlr->UnRef();
}
#endif
}
@ -1691,11 +1690,10 @@ void cyAvatar::ChangePlayerName(const char* playerName)
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, playerName, arrsize(wStr));
RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef();
hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode();
if (rvnPlr) {
VaultPlayerNode plr(rvnPlr);
plr.SetPlayerName(wStr);
rvnPlr->UnRef();
}
}

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

@ -2471,10 +2471,9 @@ int cyMisc::GetKILevel()
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, pfKIMsg::kChronicleKILevel, arrsize(wStr));
if (RelVaultNode * rvn = VaultFindChronicleEntryIncRef(wStr)) {
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wStr)) {
VaultChronicleNode chron(rvn);
result = wcstol(chron.GetEntryValue(), nil, 0);
rvn->UnRef();
}
return result;
@ -2880,7 +2879,7 @@ void cyMisc::SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp)
void cyMisc::SendFriendInvite(const wchar_t email[], const wchar_t toName[])
{
if (RelVaultNode* pNode = VaultGetPlayerNodeIncRef())
if (hsRef<RelVaultNode> pNode = VaultGetPlayerNode())
{
VaultPlayerNode player(pNode);
plUUID inviteUuid = player.GetInviteUuid();
@ -2893,7 +2892,6 @@ void cyMisc::SendFriendInvite(const wchar_t email[], const wchar_t toName[])
}
NetCommSendFriendInvite(email, toName, inviteUuid);
pNode->UnRef();
}
}

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

@ -2079,11 +2079,10 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
case plVaultNotifyMsg::kRegisteredVisitAge:
case plVaultNotifyMsg::kUnRegisteredOwnedAge:
case plVaultNotifyMsg::kUnRegisteredVisitAge: {
if (RelVaultNode * rvn = VaultGetNodeIncRef(vaultNotifyMsg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode))) {
if (hsRef<RelVaultNode> rvn = VaultGetNode(vaultNotifyMsg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode))) {
Py_DECREF(ptuple);
ptuple = PyTuple_New(1);
PyTuple_SetItem(ptuple, 0, pyVaultAgeLinkNode::New(rvn));
rvn->UnRef();
}
}
break;

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

@ -435,7 +435,7 @@ PLASMA_DEFAULT_TYPE(ptAgeInfoStructRef, "Class to hold AgeInfo struct data");
PyObject *pyAgeInfoStructRef::New(plAgeInfoStruct &info)
{
ptAgeInfoStructRef *newObj = (ptAgeInfoStructRef*)ptAgeInfoStructRef_type.tp_new(&ptAgeInfoStructRef_type, NULL, NULL);
newObj->fThis->fAgeInfo = info;
newObj->fThis->fAgeInfo.CopyFrom(&info);
return (PyObject*)newObj;
}

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

@ -366,7 +366,7 @@ PLASMA_DEFAULT_TYPE(ptAgeLinkStructRef, "Class to hold the data of the AgeLink s
PyObject *pyAgeLinkStructRef::New(plAgeLinkStruct &link)
{
ptAgeLinkStructRef *newObj = (ptAgeLinkStructRef*)ptAgeLinkStructRef_type.tp_new(&ptAgeLinkStructRef_type, NULL, NULL);
newObj->fThis->fAgeLink = link;
newObj->fThis->fAgeLink.CopyFrom(&link);
return (PyObject*)newObj;
}

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

@ -81,12 +81,9 @@ pyAgeVault::~pyAgeVault() {
PyObject* pyAgeVault::GetAgeInfo()
{
RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef();
if (rvn) {
PyObject * result = pyVaultAgeInfoNode::New(rvn);
rvn->UnRef();
return result;
}
hsRef<RelVaultNode> rvn = VaultGetAgeInfoNode();
if (rvn)
return pyVaultAgeInfoNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -94,12 +91,9 @@ PyObject* pyAgeVault::GetAgeInfo()
PyObject* pyAgeVault::GetAgeDevicesFolder( void )
{
RelVaultNode * rvn = VaultGetAgeDevicesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->UnRef();
return result;
}
hsRef<RelVaultNode> rvn = VaultGetAgeDevicesFolder();
if (rvn)
return pyVaultFolderNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -107,12 +101,9 @@ PyObject* pyAgeVault::GetAgeDevicesFolder( void )
PyObject* pyAgeVault::GetSubAgesFolder( void )
{
RelVaultNode * rvn = VaultGetAgeSubAgesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->UnRef();
return result;
}
hsRef<RelVaultNode> rvn = VaultGetAgeSubAgesFolder();
if (rvn)
return pyVaultFolderNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -120,12 +111,9 @@ PyObject* pyAgeVault::GetSubAgesFolder( void )
PyObject* pyAgeVault::GetChronicleFolder( void )
{
RelVaultNode * rvn = VaultGetAgeChronicleFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->UnRef();
return result;
}
hsRef<RelVaultNode> rvn = VaultGetAgeChronicleFolder();
if (rvn)
return pyVaultFolderNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -133,12 +121,9 @@ PyObject* pyAgeVault::GetChronicleFolder( void )
PyObject* pyAgeVault::GetBookshelfFolder ( void )
{
RelVaultNode * rvn = VaultAgeGetBookshelfFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->UnRef();
return result;
}
hsRef<RelVaultNode> rvn = VaultAgeGetBookshelfFolder();
if (rvn)
return pyVaultFolderNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -146,12 +131,9 @@ PyObject* pyAgeVault::GetBookshelfFolder ( void )
PyObject* pyAgeVault::GetPeopleIKnowAboutFolder( void )
{
RelVaultNode * rvn = VaultGetAgePeopleIKnowAboutFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->UnRef();
return result;
}
hsRef<RelVaultNode> rvn = VaultGetAgePeopleIKnowAboutFolder();
if (rvn)
return pyVaultFolderNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -160,12 +142,9 @@ PyObject* pyAgeVault::GetPeopleIKnowAboutFolder( void )
PyObject* pyAgeVault::GetPublicAgesFolder(void)
{
RelVaultNode * rvn = VaultGetAgePublicAgesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->UnRef();
return result;
}
hsRef<RelVaultNode> rvn = VaultGetAgePublicAgesFolder();
if (rvn)
return pyVaultFolderNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -173,12 +152,9 @@ PyObject* pyAgeVault::GetPublicAgesFolder(void)
PyObject* pyAgeVault::GetSubAgeLink( const pyAgeInfoStruct & info )
{
RelVaultNode * rvn = VaultFindAgeSubAgeLinkIncRef(info.GetAgeInfo());
if (rvn) {
PyObject * result = pyVaultAgeLinkNode::New(rvn);
rvn->UnRef();
return result;
}
hsRef<RelVaultNode> rvn = VaultFindAgeSubAgeLink(info.GetAgeInfo());
if (rvn)
return pyVaultAgeLinkNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -186,12 +162,10 @@ PyObject* pyAgeVault::GetSubAgeLink( const pyAgeInfoStruct & info )
plUUID pyAgeVault::GetAgeGuid( void )
{
RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef();
hsRef<RelVaultNode> rvn = VaultGetAgeInfoNode();
if (rvn) {
VaultAgeInfoNode ageInfo(rvn);
plUUID uuid = ageInfo.GetAgeInstanceGuid();
rvn->UnRef();
return uuid;
return ageInfo.GetAgeInstanceGuid();
}
return kNilUuid;
}
@ -204,11 +178,8 @@ PyObject* pyAgeVault::FindChronicleEntry( const char * entryName )
wchar_t wEntryName[kMaxVaultNodeStringLength];
StrToUnicode(wEntryName, entryName, arrsize(wEntryName));
if (RelVaultNode * rvn = VaultFindAgeChronicleEntryIncRef(wEntryName)) {
PyObject * result = pyVaultChronicleNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultFindAgeChronicleEntry(wEntryName))
return pyVaultChronicleNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -235,10 +206,8 @@ void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, uint32
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeAddDeviceAndWaitIncRef(wStr)) {
if (hsRef<RelVaultNode> rvn = VaultAgeAddDeviceAndWait(wStr))
cb->SetNode(rvn);
rvn->UnRef();
}
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail); // cbHolder deletes itself here.
}
@ -266,11 +235,8 @@ PyObject * pyAgeVault::GetDevice( const char * deviceName )
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeGetDeviceIncRef(wStr)) {
PyObject * result = pyVaultTextNoteNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultAgeGetDevice(wStr))
return pyVaultTextNoteNode::New(rvn);
PYTHON_RETURN_NONE;
}
@ -286,10 +252,8 @@ void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName
wchar_t wInb[MAX_PATH];
StrToUnicode(wInb, inboxName, arrsize(wInb));
if (RelVaultNode * rvn = VaultAgeSetDeviceInboxAndWaitIncRef(wDev, wInb)) {
if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(wDev, wInb))
cb->SetNode(rvn);
rvn->UnRef();
}
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here.
}
@ -299,11 +263,8 @@ PyObject * pyAgeVault::GetDeviceInbox( const char * deviceName )
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeGetDeviceInboxIncRef(wStr)) {
PyObject * result = pyVaultTextNoteNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultAgeGetDeviceInbox(wStr))
return pyVaultTextNoteNode::New(rvn);
PYTHON_RETURN_NONE;
}
@ -331,14 +292,10 @@ void pyAgeVault::UpdateAgeSDL( pySDLStateDataRecord & pyrec )
PyObject* pyAgeVault::FindNode( pyVaultNode* templateNode ) const
{
if (RelVaultNode * rvn = VaultGetAgeNodeIncRef()) {
RelVaultNode * find = rvn->GetChildNodeIncRef(templateNode->fNode, 1);
rvn->UnRef();
if (find) {
PyObject * result = pyVaultNode::New(find);
find->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultGetAgeNode()) {
hsRef<RelVaultNode> find = rvn->GetChildNode(templateNode->fNode, 1);
if (find)
return pyVaultNode::New(find);
}
PYTHON_RETURN_NONE;

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

@ -71,7 +71,7 @@ PyObject* pyDniInfoSource::GetAgeCoords( void )
uint32_t pyDniInfoSource::GetAgeTime( void ) const
{
RelVaultNode * node = VaultGetAgeInfoNodeIncRef();
hsRef<RelVaultNode> node = VaultGetAgeInfoNode();
if (!node)
return 0;
@ -81,34 +81,29 @@ uint32_t pyDniInfoSource::GetAgeTime( void ) const
result = (uint32_t)utime->GetSecs();
else
result = 0;
node->UnRef();
return result;
}
const char * pyDniInfoSource::GetAgeName( void ) const
{
RelVaultNode * node = VaultGetAgeInfoNodeIncRef();
hsRef<RelVaultNode> node = VaultGetAgeInfoNode();
if (!node)
return "";
VaultAgeInfoNode ageInfo(node);
fAgeName = StrDupToAnsi(ageInfo.GetAgeInstanceName());
node->UnRef();
return fAgeName;
}
plUUID pyDniInfoSource::GetAgeGuid( void ) const
{
if (RelVaultNode * node = VaultGetAgeInfoNodeIncRef())
if (hsRef<RelVaultNode> node = VaultGetAgeInfoNode())
{
VaultAgeInfoNode ageInfo(node);
plUUID uuid = ageInfo.GetAgeInstanceGuid();
node->UnRef();
return uuid;
return ageInfo.GetAgeInstanceGuid();
}
return kNilUuid;

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

@ -125,11 +125,10 @@ void pyGameScore::SetPoints(int32_t numPoints, pyKey& rcvr)
void pyGameScore::CreateAgeScore(const plString& name, uint32_t type, int32_t points, pyKey& rcvr)
{
if (RelVaultNode* ageInfo = VaultGetAgeInfoNodeIncRef())
if (hsRef<RelVaultNode> ageInfo = VaultGetAgeInfoNode())
{
uint32_t ownerId = ageInfo->GetNodeId();
pfGameScore::Create(ownerId, name, type, points, rcvr.getKey());
ageInfo->UnRef();
} else
hsAssert(false, "Age has no vault... Need to rewrite score python script?");
}
@ -141,11 +140,10 @@ void pyGameScore::CreateGlobalScore(const plString& name, uint32_t type, int32_t
void pyGameScore::CreatePlayerScore(const plString& name, uint32_t type, int32_t points, pyKey& rcvr)
{
if (RelVaultNode* node = VaultGetPlayerInfoNodeIncRef())
if (hsRef<RelVaultNode> node = VaultGetPlayerInfoNode())
{
uint32_t ownerId = node->GetNodeId();
pfGameScore::Create(ownerId, name, type, points, rcvr.getKey());
node->UnRef();
} else
hsAssert(false, "No PlayerInfo node... Need to rewrite python script?");
}
@ -157,11 +155,10 @@ void pyGameScore::CreateScore(uint32_t ownerId, const plString& name, uint32_t t
void pyGameScore::FindAgeScores(const plString& name, pyKey& rcvr)
{
if (RelVaultNode* ageInfo = VaultGetAgeInfoNodeIncRef())
if (hsRef<RelVaultNode> ageInfo = VaultGetAgeInfoNode())
{
uint32_t ownerId = ageInfo->GetNodeId();
pfGameScore::Find(ownerId, name, rcvr.getKey());
ageInfo->UnRef();
} else
hsAssert(false, "Age has no vault... Need to rewrite score python script?");
}
@ -173,11 +170,10 @@ void pyGameScore::FindGlobalScores(const plString& name, pyKey& rcvr)
void pyGameScore::FindPlayerScores(const plString& name, pyKey& rcvr)
{
if (RelVaultNode* node = VaultGetPlayerInfoNodeIncRef())
if (hsRef<RelVaultNode> node = VaultGetPlayerInfoNode())
{
uint32_t ownerId = node->GetNodeId();
pfGameScore::Find(ownerId, name, rcvr.getKey());
node->UnRef();
}
else
hsAssert(false, "No PlayerInfo node.. Need to rewrite python script?");

2
Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h

@ -62,7 +62,7 @@ private:
protected:
pyNetServerSessionInfo() {}
pyNetServerSessionInfo( const plNetServerSessionInfo & info ): fInfo( info ) {}
pyNetServerSessionInfo(const plNetServerSessionInfo & info) { fInfo.CopyFrom(&info); }
public:
// required functions for PyObject interoperability

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

@ -193,7 +193,7 @@ PYTHON_CLASS_NEW_IMPL(ptNetServerSessionInfo, pyNetServerSessionInfo)
PyObject *pyNetServerSessionInfo::New(const plNetServerSessionInfo &info)
{
ptNetServerSessionInfo *newObj = (ptNetServerSessionInfo*)ptNetServerSessionInfo_type.tp_new(&ptNetServerSessionInfo_type, NULL, NULL);
newObj->fThis->fInfo = info;
newObj->fThis->fInfo.CopyFrom(&info);
return (PyObject*)newObj;
}
@ -354,7 +354,7 @@ PLASMA_DEFAULT_TYPE(ptNetServerSessionInfoRef, "Basic server session info class"
PyObject *pyNetServerSessionInfoRef::New(plNetServerSessionInfo &info)
{
ptNetServerSessionInfoRef *newObj = (ptNetServerSessionInfoRef*)ptNetServerSessionInfoRef_type.tp_new(&ptNetServerSessionInfoRef_type, NULL, NULL);
newObj->fThis->fInfo = info;
newObj->fThis->fInfo.CopyFrom(&info);
return (PyObject*)newObj;
}

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

@ -81,12 +81,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//============================================================================
static PyObject * GetFolder (unsigned folderType) {
PyObject * result = nil;
if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) {
if (RelVaultNode * rvnFldr = rvnPlr->GetChildFolderNodeIncRef(folderType, 1)) {
if (hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode()) {
if (hsRef<RelVaultNode> rvnFldr = rvnPlr->GetChildFolderNode(folderType, 1))
result = pyVaultFolderNode::New(rvnFldr);
rvnFldr->UnRef();
}
rvnPlr->UnRef();
}
return result;
@ -95,12 +92,9 @@ static PyObject * GetFolder (unsigned folderType) {
//============================================================================
static PyObject * GetPlayerInfoList (unsigned folderType) {
PyObject * result = nil;
if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) {
if (RelVaultNode * rvnFldr = rvnPlr->GetChildPlayerInfoListNodeIncRef(folderType, 1)) {
if (hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode()) {
if (hsRef<RelVaultNode> rvnFldr = rvnPlr->GetChildPlayerInfoListNode(folderType, 1))
result = pyVaultPlayerInfoListNode::New(rvnFldr);
rvnFldr->UnRef();
}
rvnPlr->UnRef();
}
return result;
@ -109,12 +103,9 @@ static PyObject * GetPlayerInfoList (unsigned folderType) {
//============================================================================
static PyObject * GetAgeInfoList (unsigned folderType) {
PyObject * result = nil;
if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) {
if (RelVaultNode * rvnFldr = rvnPlr->GetChildAgeInfoListNodeIncRef(folderType, 1)) {
if (hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode()) {
if (hsRef<RelVaultNode> rvnFldr = rvnPlr->GetChildAgeInfoListNode(folderType, 1))
result = pyVaultAgeInfoListNode::New(rvnFldr);
rvnFldr->UnRef();
}
rvnPlr->UnRef();
}
return result;
@ -124,12 +115,9 @@ static PyObject * GetAgeInfoList (unsigned folderType) {
PyObject* pyVault::GetPlayerInfo()
{
PyObject * result = nil;
if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) {
if (RelVaultNode * rvnPlrInfo = rvnPlr->GetChildNodeIncRef(plVault::kNodeType_PlayerInfo, 1)) {
if (hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode()) {
if (hsRef<RelVaultNode> rvnPlrInfo = rvnPlr->GetChildNode(plVault::kNodeType_PlayerInfo, 1))
result = pyVaultPlayerInfoNode::New(rvnPlrInfo);
rvnPlrInfo->UnRef();
}
rvnPlr->UnRef();
}
// just return an empty node
@ -208,36 +196,30 @@ PyObject* pyVault::GetKIUsage(void)
uint32_t markerGames = 0;
for (;;) {
RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef();
hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode();
if (!rvnPlr)
break;
for (;;) {
RelVaultNode * rvnAgeJrnlz = rvnPlr->GetChildFolderNodeIncRef(plVault::kAgeJournalsFolder, 1);
hsRef<RelVaultNode> rvnAgeJrnlz = rvnPlr->GetChildFolderNode(plVault::kAgeJournalsFolder, 1);
if (!rvnAgeJrnlz)
break;
// Get child nodes up to two levels deep
ARRAY(RelVaultNode*) nodeArr;
rvnAgeJrnlz->GetChildNodesIncRef(2, &nodeArr);
RelVaultNode::RefList nodeArr;
rvnAgeJrnlz->GetChildNodes(2, &nodeArr);
RelVaultNode ** cur = nodeArr.Ptr();
RelVaultNode ** end = nodeArr.Term();
for (; cur != end; ++cur) {
RelVaultNode * rvn = *cur;
for (const hsRef<RelVaultNode> &rvn : nodeArr) {
if (rvn->GetNodeType() == plVault::kNodeType_Image)
++pictures;
else if (rvn->GetNodeType() == plVault::kNodeType_TextNote)
++notes;
else if (rvn->GetNodeType() == plVault::kNodeType_MarkerGame)
++markerGames;
rvn->UnRef();
}
rvnAgeJrnlz->UnRef();
break;
}
rvnPlr->UnRef();
break;
}
@ -303,11 +285,8 @@ PyObject* pyVault::GetLinkToMyNeighborhood() const
plAgeInfoStruct info;
info.SetAgeFilename(kNeighborhoodAgeFilename);
if (RelVaultNode * rvn = VaultGetOwnedAgeLinkIncRef(&info)) {
PyObject * result = pyVaultAgeLinkNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultGetOwnedAgeLink(&info))
return pyVaultAgeLinkNode::New(rvn);
PYTHON_RETURN_NONE;
}
@ -317,11 +296,8 @@ PyObject* pyVault::GetLinkToCity() const
plAgeInfoStruct info;
info.SetAgeFilename(kCityAgeFilename);
if (RelVaultNode * rvn = VaultGetOwnedAgeLinkIncRef(&info)) {
PyObject * result = pyVaultAgeLinkNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultGetOwnedAgeLink(&info))
return pyVaultAgeLinkNode::New(rvn);
PYTHON_RETURN_NONE;
}
@ -330,11 +306,8 @@ PyObject* pyVault::GetLinkToCity() const
// Owned ages
PyObject* pyVault::GetOwnedAgeLink( const pyAgeInfoStruct & info )
{
if (RelVaultNode * rvnLink = VaultGetOwnedAgeLinkIncRef(info.GetAgeInfo())) {
PyObject * result = pyVaultAgeLinkNode::New(rvnLink);
rvnLink->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvnLink = VaultGetOwnedAgeLink(info.GetAgeInfo()))
return pyVaultAgeLinkNode::New(rvnLink);
// just return a None object
PYTHON_RETURN_NONE;
@ -343,11 +316,8 @@ PyObject* pyVault::GetOwnedAgeLink( const pyAgeInfoStruct & info )
// Visit ages
PyObject* pyVault::GetVisitAgeLink( const pyAgeInfoStruct & info)
{
if (RelVaultNode * rvnLink = VaultGetVisitAgeLinkIncRef(info.GetAgeInfo())) {
PyObject * result = pyVaultAgeLinkNode::New(rvnLink);
rvnLink->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvnLink = VaultGetVisitAgeLink(info.GetAgeInfo()))
return pyVaultAgeLinkNode::New(rvnLink);
// just return a None object
PYTHON_RETURN_NONE;
@ -361,11 +331,8 @@ PyObject* pyVault::FindChronicleEntry( const char * entryName )
wchar_t wEntryName[kMaxVaultNodeStringLength];
StrToUnicode(wEntryName, entryName, arrsize(wEntryName));
if (RelVaultNode * rvn = VaultFindChronicleEntryIncRef(wEntryName)) {
PyObject * result = pyVaultChronicleNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wEntryName))
return pyVaultChronicleNode::New(rvn);
// just return a None object
PYTHON_RETURN_NONE;
@ -441,10 +408,9 @@ PyObject* pyVault::GetInviteFolder()
PyObject* pyVault::GetPsnlAgeSDL() const
{
PyObject * result = nil;
NetVaultNode * templateNode = new NetVaultNode;
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode;
if (RelVaultNode * rvnFldr = VaultGetAgesIOwnFolderIncRef()) {
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) {
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
@ -453,27 +419,22 @@ PyObject* pyVault::GetPsnlAgeSDL() const
StrToUnicode(str, kPersonalAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
if (RelVaultNode * rvnInfo = rvnFldr->GetChildNodeIncRef(templateNode, 2)) {
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_SDL);
if (RelVaultNode * rvnSdl = rvnInfo->GetChildNodeIncRef(templateNode, 1)) {
if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) {
VaultSDLNode sdl(rvnSdl);
plStateDataRecord * rec = new plStateDataRecord;
if (sdl.GetStateDataRecord(rec, plSDL::kKeepDirty))
result = pySDLStateDataRecord::New(rec);
else
delete rec;
rvnSdl->UnRef();
}
rvnInfo->UnRef();
}
rvnFldr->UnRef();
}
templateNode->UnRef();
if (!result)
PYTHON_RETURN_NONE;
@ -486,10 +447,9 @@ void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec )
if ( !rec )
return;
NetVaultNode * templateNode = new NetVaultNode;
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode;
if (RelVaultNode * rvnFldr = VaultGetAgesIOwnFolderIncRef()) {
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) {
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
@ -498,22 +458,17 @@ void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec )
StrToUnicode(str, kPersonalAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
if (RelVaultNode * rvnInfo = rvnFldr->GetChildNodeIncRef(templateNode, 2)) {
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_SDL);
if (RelVaultNode * rvnSdl = rvnInfo->GetChildNodeIncRef(templateNode, 1)) {
if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) {
VaultSDLNode sdl(rvnSdl);
sdl.SetStateDataRecord(rec, plSDL::kDirtyOnly | plSDL::kTimeStampOnRead);
rvnSdl->UnRef();
}
rvnInfo->UnRef();
}
rvnFldr->UnRef();
}
templateNode->UnRef();
}
bool pyVault::InMyPersonalAge() const
@ -599,14 +554,12 @@ void _InvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode
void pyVault::InvitePlayerToAge( const pyAgeLinkStruct & link, uint32_t playerID )
{
NetVaultNode * templateNode = new NetVaultNode;
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode;
templateNode->SetNodeType(plVault::kNodeType_TextNote);
VaultTextNoteNode visitAcc(templateNode);
visitAcc.SetNoteType(plVault::kNoteType_Visit);
visitAcc.SetVisitInfo(*link.GetAgeLink()->GetAgeInfo());
VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_InvitePlayerToAge, nil, (void*)playerID);
templateNode->UnRef();
}
//============================================================================
@ -622,24 +575,19 @@ void pyVault::UnInvitePlayerToAge( const char * str, uint32_t playerID )
plUUID guid(str);
info.SetAgeInstanceGuid(&guid);
if (RelVaultNode * rvnLink = VaultGetOwnedAgeLinkIncRef(&info)) {
if (RelVaultNode * rvnInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) {
if (hsRef<RelVaultNode> rvnLink = VaultGetOwnedAgeLink(&info)) {
if (hsRef<RelVaultNode> rvnInfo = rvnLink->GetChildNode(plVault::kNodeType_AgeInfo, 1)) {
VaultAgeInfoNode ageInfo(rvnInfo);
ageInfo.CopyTo(&info);
rvnInfo->UnRef();
}
rvnLink->UnRef();
}
NetVaultNode * templateNode = new NetVaultNode;
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode;
templateNode->SetNodeType(plVault::kNodeType_TextNote);
VaultTextNoteNode visitAcc(templateNode);
visitAcc.SetNoteType(plVault::kNoteType_UnVisit);
visitAcc.SetVisitInfo(info);
VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_UninvitePlayerToAge, nil, (void*)playerID);
templateNode->UnRef();
}
//============================================================================
@ -696,12 +644,8 @@ bool pyVault::SetAgePublic( const pyAgeInfoStruct * ageInfo, bool makePublic )
PyObject* pyVault::GetGlobalInbox()
{
PyObject * result = nil;
if (RelVaultNode * rvnGlobalInbox = VaultGetGlobalInboxIncRef()) {
result = pyVaultFolderNode::New(rvnGlobalInbox);
rvnGlobalInbox->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvnGlobalInbox = VaultGetGlobalInbox())
return pyVaultFolderNode::New(rvnGlobalInbox);
PYTHON_RETURN_NONE;
}
@ -712,11 +656,8 @@ PyObject* pyVault::GetGlobalInbox()
PyObject* pyVault::FindNode( pyVaultNode* templateNode ) const
{
// See if we already have a matching node locally
if (RelVaultNode * rvn = VaultGetNodeIncRef(templateNode->GetNode())) {
PyObject * result = pyVaultNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultGetNode(templateNode->GetNode()))
return pyVaultNode::New(rvn);
// See if a matching node exists on the server
ARRAY(unsigned) nodeIds;
@ -726,11 +667,8 @@ PyObject* pyVault::FindNode( pyVaultNode* templateNode ) const
// Only fetch the first matching node since this function returns a single node
VaultFetchNodesAndWait(&nodeIds[0], 1);
// If we fetched it successfully then it'll be in our local node cache now
if (RelVaultNode * rvn = VaultGetNodeIncRef(nodeIds[0])) {
PyObject * result = pyVaultNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultGetNode(nodeIds[0]))
return pyVaultNode::New(rvn);
}
PYTHON_RETURN_NONE;

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

@ -111,11 +111,7 @@ PLASMA_DEFAULT_TYPE_WBASE(ptVaultAgeInfoListNode, pyVaultFolderNode, "Params: n=
PyObject *pyVaultAgeInfoListNode::New(RelVaultNode* nfsNode)
{
ptVaultAgeInfoListNode *newObj = (ptVaultAgeInfoListNode*)ptVaultAgeInfoListNode_type.tp_new(&ptVaultAgeInfoListNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -89,20 +89,16 @@ static PyObject * GetChildFolder (RelVaultNode * node, unsigned type) {
//============================================================================
static PyObject * GetChildPlayerInfoList (RelVaultNode * node, unsigned type) {
PyObject * result = nil;
if (RelVaultNode * rvn = node->GetChildPlayerInfoListNodeIncRef(type, 1)) {
if (hsRef<RelVaultNode> rvn = node->GetChildPlayerInfoListNode(type, 1))
result = pyVaultPlayerInfoListNode::New(rvn);
rvn->UnRef();
}
return result;
}
//============================================================================
static PyObject * GetChildAgeInfoList (RelVaultNode * node, unsigned type) {
PyObject * result = nil;
if (RelVaultNode * rvn = node->GetChildAgeInfoListNodeIncRef(type, 1)) {
if (hsRef<RelVaultNode> rvn = node->GetChildAgeInfoListNode(type, 1))
result = pyVaultAgeInfoListNode::New(rvn);
rvn->UnRef();
}
return result;
}
@ -173,11 +169,8 @@ PyObject * pyVaultAgeInfoNode::GetParentAgeLink () const
if (!fNode)
PYTHON_RETURN_NONE;
if (RelVaultNode * rvn = fNode->GetParentAgeLinkIncRef()) {
PyObject * result = pyVaultAgeLinkNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = fNode->GetParentAgeLink())
return pyVaultAgeLinkNode::New(rvn);
// just return a None object.
PYTHON_RETURN_NONE

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

@ -287,11 +287,7 @@ PLASMA_DEFAULT_TYPE_WBASE(ptVaultAgeInfoNode, pyVaultNode, "Params: n=0\nPlasma
PyObject *pyVaultAgeInfoNode::New(RelVaultNode* nfsNode)
{
ptVaultAgeInfoNode *newObj = (ptVaultAgeInfoNode*)ptVaultAgeInfoNode_type.tp_new(&ptVaultAgeInfoNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -82,10 +82,8 @@ PyObject* pyVaultAgeLinkNode::GetAgeInfo() const
PYTHON_RETURN_NONE;
PyObject * result = nil;
if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) {
if (hsRef<RelVaultNode> rvn = fNode->GetChildNode(plVault::kNodeType_AgeInfo, 1))
result = pyVaultAgeInfoNode::New(rvn);
rvn->UnRef();
}
if (result)
return result;

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

@ -200,11 +200,7 @@ PLASMA_DEFAULT_TYPE_WBASE(ptVaultAgeLinkNode, pyVaultNode, "Params: n=0\nPlasma
PyObject *pyVaultAgeLinkNode::New(RelVaultNode* nfsNode)
{
ptVaultAgeLinkNode *newObj = (ptVaultAgeLinkNode*)ptVaultAgeLinkNode_type.tp_new(&ptVaultAgeLinkNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -190,11 +190,7 @@ PLASMA_DEFAULT_TYPE_WBASE(ptVaultChronicleNode, pyVaultNode, "Params: n=0\nPlasm
PyObject *pyVaultChronicleNode::New(RelVaultNode* nfsNode)
{
ptVaultChronicleNode *newObj = (ptVaultChronicleNode*)ptVaultChronicleNode_type.tp_new(&ptVaultChronicleNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -191,11 +191,7 @@ PYTHON_EXPOSE_TYPE_DEFINITION(ptVaultFolderNode, pyVaultFolderNode);
PyObject *pyVaultFolderNode::New(RelVaultNode* nfsNode)
{
ptVaultFolderNode *newObj = (ptVaultFolderNode*)ptVaultFolderNode_type.tp_new(&ptVaultFolderNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -219,11 +219,7 @@ PLASMA_DEFAULT_TYPE_WBASE(ptVaultImageNode, pyVaultNode, "Params: n=0\nPlasma va
PyObject *pyVaultImageNode::New(RelVaultNode* nfsNode)
{
ptVaultImageNode *newObj = (ptVaultImageNode*)ptVaultImageNode_type.tp_new(&ptVaultImageNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -114,11 +114,7 @@ PLASMA_DEFAULT_TYPE_WBASE(ptVaultMarkerGameNode, pyVaultNode, "Params: n=0\nPlas
PyObject *pyVaultMarkerGameNode::New(RelVaultNode* nfsNode)
{
ptVaultMarkerGameNode *newObj = (ptVaultMarkerGameNode*)ptVaultMarkerGameNode_type.tp_new(&ptVaultMarkerGameNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -94,7 +94,6 @@ static void CDECL LogDumpProc (
pyVaultNode::pyVaultNodeOperationCallback::pyVaultNodeOperationCallback(PyObject * cbObject)
: fCbObject( cbObject )
, fNode(nil)
, fPyNodeRef(nil)
, fContext(0)
{
@ -158,21 +157,16 @@ void pyVaultNode::pyVaultNodeOperationCallback::VaultOperationComplete( uint32_t
}
void pyVaultNode::pyVaultNodeOperationCallback::SetNode (RelVaultNode * rvn) {
if (rvn)
rvn->Ref();
SWAP(rvn, fNode);
if (rvn)
rvn->UnRef();
fNode = rvn;
}
RelVaultNode * pyVaultNode::pyVaultNodeOperationCallback::GetNode () {
hsRef<RelVaultNode> pyVaultNode::pyVaultNodeOperationCallback::GetNode() const {
return fNode;
}
// only for python glue, do NOT call
pyVaultNode::pyVaultNode()
: fNode(nil)
, fCreateAgeName(nil)
: fCreateAgeName(nil)
{
}
@ -181,19 +175,15 @@ pyVaultNode::pyVaultNode( RelVaultNode* nfsNode )
: fNode(nfsNode)
, fCreateAgeName(nil)
{
if (fNode)
fNode->Ref("pyVaultNode");
}
pyVaultNode::~pyVaultNode()
{
if (fNode)
fNode->UnRef("pyVaultNode");
free(fCreateAgeName);
}
RelVaultNode* pyVaultNode::GetNode() const
hsRef<RelVaultNode> pyVaultNode::GetNode() const
{
return fNode;
}
@ -202,8 +192,8 @@ RelVaultNode* pyVaultNode::GetNode() const
// override the equals to operator
bool pyVaultNode::operator==(const pyVaultNode &vaultNode) const
{
RelVaultNode* ours = GetNode();
RelVaultNode* theirs = vaultNode.GetNode();
hsRef<RelVaultNode> ours = GetNode();
hsRef<RelVaultNode> theirs = vaultNode.GetNode();
if (ours == nil && theirs == nil)
return true;
if (ours == nil || theirs == nil)
@ -270,17 +260,13 @@ PyObject* pyVaultNode::GetCreatorNode( void )
PyObject * result = nil;
if (fNode)
{
RelVaultNode * templateNode = new RelVaultNode;
templateNode->Ref();
hsRef<RelVaultNode> templateNode = new RelVaultNode;
templateNode->SetNodeType(plVault::kNodeType_PlayerInfo);
VaultPlayerInfoNode plrInfo(templateNode);
plrInfo.SetPlayerId(fNode->GetCreatorId());
if (RelVaultNode * rvn = VaultGetNodeIncRef(templateNode)) {
if (hsRef<RelVaultNode> rvn = VaultGetNode(templateNode))
result = pyVaultPlayerInfoNode::New(rvn);
rvn->UnRef();
}
templateNode->UnRef();
}
if (result)
@ -417,20 +403,16 @@ PyObject* pyVaultNode::AddNode(pyVaultNode* pynode, PyObject* cbObject, uint32_t
// Block here until node is created and fetched =(
ASSERT(pynode->GetNode()->GetNodeType());
ENetError result;
RelVaultNode * newNode = VaultCreateNodeAndWaitIncRef(
hsRef<RelVaultNode> newNode = VaultCreateNodeAndWait(
pynode->GetNode(),
&result
);
if (newNode) {
newNode->Ref();
pynode->fNode->UnRef();
if (newNode)
pynode->fNode = newNode;
}
else {
else
hsResult = hsFail;
}
}
PyObject* nodeRef = cb->fPyNodeRef = pyVaultNodeRef::New(fNode, pynode->fNode);
Py_INCREF(nodeRef); // The callback steals the ref, according to Eric...
@ -468,10 +450,9 @@ void pyVaultNode::LinkToNode(int nodeID, PyObject* cbObject, uint32_t cbContext)
// Hack the callbacks until vault notification is in place
cb->VaultOperationStarted( cbContext );
if (RelVaultNode * rvn = VaultGetNodeIncRef(nodeID)) {
if (hsRef<RelVaultNode> rvn = VaultGetNode(nodeID)) {
cb->SetNode(rvn);
cb->fPyNodeRef = pyVaultNodeRef::New(fNode, rvn);
rvn->UnRef();
}
VaultAddChildNode(fNode->GetNodeId(),
@ -535,11 +516,9 @@ void pyVaultNode::Save(PyObject* cbObject, uint32_t cbContext)
// otherwise just ignore the save request since vault nodes are now auto-saved.
if (!fNode->GetNodeId() && fNode->GetNodeType()) {
ENetError result;
if (RelVaultNode * node = VaultCreateNodeAndWaitIncRef(fNode, &result)) {
fNode->UnRef();
if (hsRef<RelVaultNode> node = VaultCreateNodeAndWait(fNode, &result))
fNode = node;
}
}
pyVaultNodeOperationCallback * cb = new pyVaultNodeOperationCallback( cbObject );
cb->SetNode(fNode);
cb->VaultOperationStarted( cbContext );
@ -559,11 +538,9 @@ void pyVaultNode::ForceSave()
{
if (!fNode->GetNodeId() && fNode->GetNodeType()) {
ENetError result;
if (RelVaultNode * node = VaultCreateNodeAndWaitIncRef(fNode, &result)) {
fNode->UnRef();
if (hsRef<RelVaultNode> node = VaultCreateNodeAndWait(fNode, &result))
fNode = node;
}
}
else
VaultForceSaveNodeAndWait(fNode);
}
@ -578,11 +555,9 @@ void pyVaultNode::SendTo(uint32_t destClientNodeID, PyObject* cbObject, uint32_t
// If the node doesn't have an id, then use it as a template to create the node in the vault,
if (!fNode->GetNodeId() && fNode->GetNodeType()) {
ENetError result;
if (RelVaultNode * node = VaultCreateNodeAndWaitIncRef(fNode, &result)) {
fNode->UnRef();
if (hsRef<RelVaultNode> node = VaultCreateNodeAndWait(fNode, &result))
fNode = node;
}
}
// Hack the callbacks until vault notification is in place
cb->VaultOperationStarted( cbContext );
@ -608,17 +583,13 @@ PyObject* pyVaultNode::GetChildNodeRefList()
// fill in the elements list of this folder
if (fNode)
{
ARRAY(RelVaultNode*) nodes;
fNode->GetChildNodesIncRef(
1,
&nodes
);
RelVaultNode::RefList nodes;
fNode->GetChildNodes(1, &nodes);
for (unsigned i = 0; i < nodes.Count(); ++i) {
PyObject* elementObj = pyVaultNodeRef::New(fNode, nodes[i]);
for (const hsRef<RelVaultNode> &node : nodes) {
PyObject* elementObj = pyVaultNodeRef::New(fNode, node);
PyList_Append(pyEL, elementObj);
Py_DECREF(elementObj);
nodes[i]->UnRef();
}
}
@ -656,14 +627,10 @@ PyObject * pyVaultNode::GetNode2( uint32_t nodeID ) const
PyObject * result = nil;
if ( fNode )
{
RelVaultNode * templateNode = new RelVaultNode;
templateNode->Ref();
hsRef<RelVaultNode> templateNode = new RelVaultNode;
templateNode->SetNodeId(nodeID);
if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1)) {
if (hsRef<RelVaultNode> rvn = fNode->GetChildNode(templateNode, 1))
result = pyVaultNodeRef::New(fNode, rvn);
rvn->UnRef();
}
templateNode->UnRef();
}
if (result)
@ -677,10 +644,8 @@ PyObject* pyVaultNode::FindNode( pyVaultNode * templateNode )
PyObject * result = nil;
if ( fNode && templateNode->fNode )
{
if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode->fNode, 1)) {
if (hsRef<RelVaultNode> rvn = fNode->GetChildNode(templateNode->fNode, 1))
result = pyVaultNode::New(rvn);
rvn->UnRef();
}
}
if (result)
@ -694,17 +659,12 @@ PyObject * pyVaultNode::GetChildNode (unsigned nodeId) {
if (!fNode)
PYTHON_RETURN_NONE;
RelVaultNode * templateNode = new RelVaultNode;
templateNode->Ref();
hsRef<RelVaultNode> templateNode = new RelVaultNode;
templateNode->SetNodeId(nodeId);
RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1);
templateNode->UnRef();
hsRef<RelVaultNode> rvn = fNode->GetChildNode(templateNode, 1);
if (rvn) {
PyObject * result = pyVaultNode::New(rvn);
rvn->UnRef();
return result;
}
if (rvn)
return pyVaultNode::New(rvn);
PYTHON_RETURN_NONE;
}

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

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "pyGlueHelpers.h"
#include "hsRefCnt.h"
struct RelVaultNode;
class plMipmap;
@ -82,7 +83,7 @@ public:
struct pyVaultNodeOperationCallback
{
PyObject * fCbObject;
RelVaultNode * fNode;
hsRef<RelVaultNode> fNode;
PyObject * fPyNodeRef;
uint32_t fContext;
@ -94,10 +95,10 @@ public:
void VaultOperationComplete(int resultCode) { VaultOperationComplete(fContext, resultCode); }
void SetNode (RelVaultNode * rvn);
RelVaultNode * GetNode ();
hsRef<RelVaultNode> GetNode() const;
};
RelVaultNode * fNode;
hsRef<RelVaultNode> fNode;
mutable char * fCreateAgeName;
protected:
@ -118,7 +119,7 @@ public:
static void AddPlasmaClasses(PyObject *m);
RelVaultNode * GetNode() const;
hsRef<RelVaultNode> GetNode() const;
// override the equals to operator
bool operator==(const pyVaultNode &vaultNode) const;

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

@ -541,11 +541,7 @@ PYTHON_EXPOSE_TYPE_DEFINITION(ptVaultNode, pyVaultNode);
PyObject *pyVaultNode::New(RelVaultNode* nfsNode)
{
ptVaultNode *newObj = (ptVaultNode*)ptVaultNode_type.tp_new(&ptVaultNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

38
Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRef.cpp

@ -65,22 +65,20 @@ pyVaultNodeRef::pyVaultNodeRef(RelVaultNode * parent, RelVaultNode * child)
: fParent(parent)
, fChild(child)
{
fParent->Ref();
fChild->Ref();
}
pyVaultNodeRef::pyVaultNodeRef(int)
: fParent(nil)
, fChild(nil)
{
}
pyVaultNodeRef::~pyVaultNodeRef()
hsRef<RelVaultNode> pyVaultNodeRef::GetParentNode() const
{
if (fParent)
fParent->UnRef();
if (fChild)
fChild->UnRef();
return fParent;
}
hsRef<RelVaultNode> pyVaultNodeRef::GetChildNode() const
{
return fChild;
}
@ -113,10 +111,8 @@ unsigned pyVaultNodeRef::GetSaverID () {
return 0;
unsigned saverId = 0;
if (RelVaultNode * child = VaultGetNodeIncRef(fChild->GetNodeId())) {
if (hsRef<RelVaultNode> child = VaultGetNode(fChild->GetNodeId()))
saverId = child->GetRefOwnerId(fParent->GetNodeId());
child->UnRef();
}
return saverId;
}
@ -124,36 +120,30 @@ PyObject * pyVaultNodeRef::GetSaver () {
if (!fParent || !fChild)
return 0;
RelVaultNode * saver = nil;
if (RelVaultNode * child = VaultGetNodeIncRef(fChild->GetNodeId())) {
hsRef<RelVaultNode> saver;
if (hsRef<RelVaultNode> child = VaultGetNode(fChild->GetNodeId())) {
if (unsigned saverId = child->GetRefOwnerId(fParent->GetNodeId())) {
// Find the player info node representing the saver
NetVaultNode * templateNode = new NetVaultNode;
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode;
templateNode->SetNodeType(plVault::kNodeType_PlayerInfo);
VaultPlayerInfoNode access(templateNode);
access.SetPlayerId(saverId);
saver = VaultGetNodeIncRef(templateNode);
saver = VaultGetNode(templateNode);
if (!saver) {
ARRAY(unsigned) nodeIds;
VaultFindNodesAndWait(templateNode, &nodeIds);
if (nodeIds.Count() > 0) {
VaultFetchNodesAndWait(nodeIds.Ptr(), nodeIds.Count());
saver = VaultGetNodeIncRef(nodeIds[0]);
saver = VaultGetNode(nodeIds[0]);
}
}
templateNode->UnRef();
}
child->UnRef();
}
if (!saver)
PYTHON_RETURN_NONE;
PyObject * result = pyVaultPlayerInfoNode::New(saver);
saver->UnRef();
return result;
return pyVaultPlayerInfoNode::New(saver);
}
bool pyVaultNodeRef::BeenSeen () {

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

@ -50,13 +50,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "pyGlueHelpers.h"
#include "hsRefCnt.h"
struct RelVaultNode;
class pyVaultNodeRef
{
RelVaultNode * fParent;
RelVaultNode * fChild;
hsRef<RelVaultNode> fParent;
hsRef<RelVaultNode> fChild;
protected:
// should only be created from C++ side
@ -64,10 +65,8 @@ protected:
pyVaultNodeRef(int =0 );
public:
~pyVaultNodeRef();
RelVaultNode * GetParentNode () const { return fParent; }
RelVaultNode * GetChildNode () const { return fChild; }
hsRef<RelVaultNode> GetParentNode() const;
hsRef<RelVaultNode> GetChildNode() const;
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass

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

@ -125,16 +125,8 @@ PYTHON_EXPOSE_TYPE_DEFINITION(ptVaultNodeRef, pyVaultNodeRef);
PyObject *pyVaultNodeRef::New(RelVaultNode * parent, RelVaultNode * child)
{
ptVaultNodeRef *newObj = (ptVaultNodeRef*)ptVaultNodeRef_type.tp_new(&ptVaultNodeRef_type, NULL, NULL);
if (newObj->fThis->fParent)
newObj->fThis->fParent->UnRef();
if (newObj->fThis->fChild)
newObj->fThis->fChild->UnRef();
newObj->fThis->fParent = parent;
newObj->fThis->fChild = child;
if (newObj->fThis->fParent)
newObj->fThis->fParent->Ref();
if (newObj->fThis->fChild)
newObj->fThis->fChild->Ref();
return (PyObject*)newObj;
}

38
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp

@ -79,17 +79,13 @@ bool pyVaultPlayerInfoListNode::HasPlayer( uint32_t playerID )
if (!fNode)
return false;
NetVaultNode * templateNode = new NetVaultNode;
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode;
templateNode->SetNodeType(plVault::kNodeType_PlayerInfo);
VaultPlayerInfoNode access(templateNode);
access.SetPlayerId(playerID);
RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1);
if (rvn)
rvn->UnRef();
hsRef<RelVaultNode> rvn = fNode->GetChildNode(templateNode, 1);
templateNode->UnRef();
return (rvn != nil);
}
@ -97,10 +93,9 @@ bool pyVaultPlayerInfoListNode::HasPlayer( uint32_t playerID )
static void IAddPlayer_NodesFound(ENetError result, void* param, unsigned nodeIdCount, const unsigned nodeIds[])
{
NetVaultNode* parent = static_cast<NetVaultNode*>(param);
hsRef<NetVaultNode> parent = static_cast<NetVaultNode*>(param);
if (nodeIdCount)
VaultAddChildNode(parent->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr);
parent->UnRef();
}
void pyVaultPlayerInfoListNode::AddPlayer( uint32_t playerID )
@ -108,8 +103,7 @@ void pyVaultPlayerInfoListNode::AddPlayer( uint32_t playerID )
if (HasPlayer(playerID) || !fNode)
return;
NetVaultNode* templateNode = new NetVaultNode();
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode();
templateNode->SetNodeType(plVault::kNodeType_PlayerInfo);
VaultPlayerInfoNode access(templateNode);
access.SetPlayerId(playerID);
@ -120,10 +114,8 @@ void pyVaultPlayerInfoListNode::AddPlayer( uint32_t playerID )
// So, if we know about this node, we can take it easy. If not, we lazy load it.
if (nodeIds.Count())
VaultAddChildNode(fNode->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr);
else {
fNode->Ref();
VaultFindNodes(templateNode, IAddPlayer_NodesFound, fNode);
}
else
VaultFindNodes(templateNode, IAddPlayer_NodesFound, (NetVaultNode *)fNode);
}
void pyVaultPlayerInfoListNode::RemovePlayer( uint32_t playerID )
@ -131,18 +123,13 @@ void pyVaultPlayerInfoListNode::RemovePlayer( uint32_t playerID )
if (!fNode)
return;
NetVaultNode * templateNode = new NetVaultNode;
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode;
templateNode->SetNodeType(plVault::kNodeType_PlayerInfo);
VaultPlayerInfoNode access(templateNode);
access.SetPlayerId(playerID);
if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1)) {
if (hsRef<RelVaultNode> rvn = fNode->GetChildNode(templateNode, 1))
VaultRemoveChildNode(fNode->GetNodeId(), rvn->GetNodeId(), nil, nil);
rvn->UnRef();
}
templateNode->UnRef();
}
PyObject * pyVaultPlayerInfoListNode::GetPlayer( uint32_t playerID )
@ -150,19 +137,14 @@ PyObject * pyVaultPlayerInfoListNode::GetPlayer( uint32_t playerID )
if (!fNode)
PYTHON_RETURN_NONE;
NetVaultNode * templateNode = new NetVaultNode;
templateNode->Ref();
hsRef<NetVaultNode> templateNode = new NetVaultNode;
templateNode->SetNodeType(plVault::kNodeType_PlayerInfo);
VaultPlayerInfoNode access(templateNode);
access.SetPlayerId(playerID);
PyObject * result = nil;
if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1)) {
if (hsRef<RelVaultNode> rvn = fNode->GetChildNode(templateNode, 1))
result = pyVaultPlayerInfoNode::New(rvn);
rvn->UnRef();
}
templateNode->UnRef();
if (!result)
PYTHON_RETURN_NONE;

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

@ -179,11 +179,7 @@ PLASMA_DEFAULT_TYPE_WBASE(ptVaultPlayerInfoListNode, pyVaultFolderNode, "Params:
PyObject *pyVaultPlayerInfoListNode::New(RelVaultNode* nfsNode)
{
ptVaultPlayerInfoListNode *newObj = (ptVaultPlayerInfoListNode*)ptVaultPlayerInfoListNode_type.tp_new(&ptVaultPlayerInfoListNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -171,11 +171,7 @@ PYTHON_CLASS_NEW_IMPL(ptVaultPlayerInfoNode, pyVaultPlayerInfoNode)
PyObject *pyVaultPlayerInfoNode::New(RelVaultNode* nfsNode)
{
ptVaultPlayerInfoNode *newObj = (ptVaultPlayerInfoNode*)ptVaultPlayerInfoNode_type.tp_new(&ptVaultPlayerInfoNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -65,12 +65,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//============================================================================
static PyObject * GetPlayerVaultFolder (unsigned folderType) {
PyObject * result = nil;
if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) {
if (RelVaultNode * rvnFldr = rvnPlr->GetChildFolderNodeIncRef(folderType, 1)) {
if (hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode()) {
if (hsRef<RelVaultNode> rvnFldr = rvnPlr->GetChildFolderNode(folderType, 1))
result = pyVaultFolderNode::New(rvnFldr);
rvnFldr->UnRef();
}
rvnPlr->UnRef();
}
return result;
@ -172,11 +169,8 @@ PyObject *pyVaultPlayerNode::GetAgesIOwnFolder()
PyObject *pyVaultPlayerNode::GetPlayerInfo()
{
if (RelVaultNode * rvn = VaultGetPlayerInfoNodeIncRef()) {
PyObject * result = pyVaultPlayerInfoNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultGetPlayerInfoNode())
return pyVaultPlayerInfoNode::New(rvn);
PYTHON_RETURN_NONE;
}
@ -221,11 +215,8 @@ void pyVaultPlayerNode::RemoveOwnedAgeLink(const char* ageFilename)
PyObject *pyVaultPlayerNode::GetVisitAgeLink(const pyAgeInfoStruct *info)
{
if (RelVaultNode * rvn = VaultGetVisitAgeLinkIncRef(info->GetAgeInfo())) {
PyObject * result = pyVaultAgeLinkNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultGetVisitAgeLink(info->GetAgeInfo()))
return pyVaultAgeLinkNode::New(rvn);
PYTHON_RETURN_NONE;
}
@ -242,11 +233,8 @@ PyObject *pyVaultPlayerNode::FindChronicleEntry(const char *entryName)
{
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, entryName, arrsize(wStr));
if (RelVaultNode * rvn = VaultFindChronicleEntryIncRef(wStr)) {
PyObject * result = pyVaultChronicleNode::New(rvn);
rvn->UnRef();
return result;
}
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wStr))
return pyVaultChronicleNode::New(rvn);
PYTHON_RETURN_NONE;
}

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

@ -321,11 +321,7 @@ PYTHON_CLASS_NEW_IMPL(ptVaultPlayerNode, pyVaultPlayerNode)
PyObject *pyVaultPlayerNode::New(RelVaultNode* nfsNode)
{
ptVaultPlayerNode *newObj = (ptVaultPlayerNode*)ptVaultPlayerNode_type.tp_new(&ptVaultPlayerNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -129,11 +129,7 @@ PYTHON_CLASS_NEW_IMPL(ptVaultSDLNode, pyVaultSDLNode)
PyObject *pyVaultSDLNode::New(RelVaultNode* nfsNode)
{
ptVaultSDLNode *newObj = (ptVaultSDLNode*)ptVaultSDLNode_type.tp_new(&ptVaultSDLNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -70,11 +70,7 @@ PYTHON_CLASS_NEW_IMPL(ptVaultSystemNode, pyVaultSystemNode)
PyObject *pyVaultSystemNode::New(RelVaultNode* nfsNode)
{
ptVaultSystemNode *newObj = (ptVaultSystemNode*)ptVaultSystemNode_type.tp_new(&ptVaultSystemNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

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

@ -228,10 +228,8 @@ void pyVaultTextNoteNode::SetDeviceInbox( const char * devName, PyObject * cbObj
wchar_t wDev[MAX_PATH];
StrToUnicode(wDev, devName, arrsize(wDev));
if (RelVaultNode * rvn = VaultAgeSetDeviceInboxAndWaitIncRef(wDev, DEFAULT_DEVICE_INBOX)) {
if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(wDev, DEFAULT_DEVICE_INBOX))
cb->SetNode(rvn);
rvn->UnRef();
}
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here.
}

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

@ -318,11 +318,7 @@ PYTHON_CLASS_NEW_IMPL(ptVaultTextNoteNode, pyVaultTextNoteNode)
PyObject *pyVaultTextNoteNode::New(RelVaultNode* nfsNode)
{
ptVaultTextNoteNode *newObj = (ptVaultTextNoteNode*)ptVaultTextNoteNode_type.tp_new(&ptVaultTextNoteNode_type, NULL, NULL);
if (newObj->fThis->fNode)
newObj->fThis->fNode->UnRef();
newObj->fThis->fNode = nfsNode;
if (newObj->fThis->fNode)
newObj->fThis->fNode->Ref();
return (PyObject*)newObj;
}

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h

@ -88,7 +88,7 @@ public:
BOOL TryEnter () { return TryEnterCriticalSection(&m_handle); }
};
class CNtWaitHandle : public hsAtomicRefCnt {
class CNtWaitHandle : public hsRefCnt {
HANDLE m_event;
public:

4
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp

@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
struct AsyncThreadTaskList : hsAtomicRefCnt {
struct AsyncThreadTaskList : hsRefCnt {
ENetError error;
AsyncThreadTaskList ();
~AsyncThreadTaskList ();
@ -81,7 +81,7 @@ static HANDLE s_taskPort;
//===========================================================================
AsyncThreadTaskList::AsyncThreadTaskList ()
: hsAtomicRefCnt(0), error(kNetSuccess)
: hsRefCnt(0), error(kNetSuccess)
{
PerfAddCounter(kAsyncPerfThreadTaskListCount, 1);
}

4
Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp

@ -73,8 +73,8 @@ private:
hsMutex m_critsect;
};
struct NetMsgChannel : hsAtomicRefCnt {
NetMsgChannel() : hsAtomicRefCnt(0) { }
struct NetMsgChannel : hsRefCnt {
NetMsgChannel() : hsRefCnt(0) { }
uint32_t m_protocol;
bool m_server;

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

@ -315,7 +315,7 @@ void NetVaultNode::DeallocNodeFields () {
//============================================================================
NetVaultNode::NetVaultNode ()
: hsAtomicRefCnt(0), fieldFlags(0), dirtyFlags(0)
: hsRefCnt(0), fieldFlags(0), dirtyFlags(0)
, nodeId(0), createTime(0), modifyTime(0)
, createAgeName(nil), creatorId(0)
, nodeType(0)

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

@ -157,7 +157,7 @@ struct NetGameRank {
// NetVaultNode
//============================================================================
// Threaded apps: App is responsible for locking node->critsect before accessing *any* field in this struct
struct NetVaultNode : hsAtomicRefCnt {
struct NetVaultNode : hsRefCnt {
enum RwOptions {
kRwDirtyOnly = 1<<0, // READ : No meaning
// WRITE: Only write fields marked dirty

121
Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp

@ -802,15 +802,15 @@ bool plClothingOutfit::IReadFromVault()
WearDefaultClothing();
RelVaultNode * rvn = VaultGetAvatarOutfitFolderIncRef();
hsRef<RelVaultNode> rvn = VaultGetAvatarOutfitFolder();
if (!rvn)
return false;
ARRAY(RelVaultNode*) nodes;
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
RelVaultNode::RefList nodes;
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
for (unsigned i = 0; i < nodes.Count(); ++i) {
VaultSDLNode sdl(nodes[i]);
for (const hsRef<RelVaultNode> &node : nodes) {
VaultSDLNode sdl(node);
if (sdl.GetSDLDataLength()) {
hsRAMStream ram;
ram.Write(sdl.GetSDLDataLength(), sdl.GetSDLData());
@ -831,13 +831,11 @@ bool plClothingOutfit::IReadFromVault()
delete sdlDataRec;
}
}
nodes[i]->UnRef();
}
fSynchClients = true; // set true if the next synch should be bcast
ForceUpdate(true);
rvn->UnRef();
return true;
}
@ -857,8 +855,8 @@ void plClothingOutfit::WriteToVault()
if (!fVaultSaveEnabled)
return;
RelVaultNode * rvn;
if (nil == (rvn = VaultGetAvatarOutfitFolderIncRef()))
hsRef<RelVaultNode> rvn = VaultGetAvatarOutfitFolder();
if (!rvn)
return;
ARRAY(plStateDataRecord*) SDRs;
@ -874,7 +872,6 @@ void plClothingOutfit::WriteToVault()
SDRs.Add(appearanceStateDesc->GetStateDataRecord(0));
WriteToVault(SDRs);
rvn->UnRef();
}
void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
@ -883,8 +880,8 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
if (fAvatar->GetTarget(0) != plNetClientApp::GetInstance()->GetLocalPlayer())
return;
RelVaultNode * rvn;
if (nil == (rvn = VaultGetAvatarOutfitFolderIncRef()))
hsRef<RelVaultNode> rvn = VaultGetAvatarOutfitFolder();
if (!rvn)
return;
ARRAY(plStateDataRecord*) morphs;
@ -906,12 +903,12 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
}
}
ARRAY(RelVaultNode*) templates;
ARRAY(RelVaultNode*) actuals;
ARRAY(RelVaultNode*) nodes;
RelVaultNode::RefList templates;
RelVaultNode::RefList actuals;
RelVaultNode::RefList nodes;
// Get all existing clothing SDRs
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes); // REF: Find
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes); // REF: Find
const ARRAY(plStateDataRecord*) * arrs[] = {
&SDRs,
@ -922,55 +919,41 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
// Write all SDL to to the outfit folder, reusing existing nodes and creating new ones as necessary
for (unsigned i = 0; i < arr->Count(); ++i) {
RelVaultNode * node;
if (nodes.Count()) {
node = nodes[0];
nodes.DeleteUnordered(0);
node->Ref(); // REF: Work
node->UnRef(); // REF: Find
hsRef<RelVaultNode> node;
if (!nodes.empty()) {
node = nodes.front();
nodes.pop_front();
}
else {
RelVaultNode * templateNode = new RelVaultNode;
templateNode->SetNodeType(plVault::kNodeType_SDL);
templates.Add(templateNode);
node = templateNode;
node->Ref(); // REF: Create
node->Ref(); // REF: Work
node = new RelVaultNode;
node->SetNodeType(plVault::kNodeType_SDL);
templates.push_back(node);
}
VaultSDLNode sdl(node);
sdl.SetStateDataRecord((*arr)[i], 0);
node->UnRef(); // REF: Work
}
}
// Delete any leftover nodes
for (unsigned i = 0; i < nodes.Count(); ++i) {
VaultDeleteNode(nodes[i]->GetNodeId());
nodes[i]->UnRef(); // REF: Array
}
for (const hsRef<RelVaultNode> &node : nodes)
VaultDeleteNode(node->GetNodeId());
// Create actual new nodes from their templates
for (unsigned i = 0; i < templates.Count(); ++i) {
for (const hsRef<RelVaultNode> &temp : templates) {
ENetError result;
if (RelVaultNode * actual = VaultCreateNodeAndWaitIncRef(templates[i], &result)) {
actuals.Add(actual);
}
templates[i]->UnRef(); // REF: Create
if (hsRef<RelVaultNode> actual = VaultCreateNodeAndWait(temp, &result))
actuals.push_back(actual);
}
// Add new nodes to outfit folder
for (unsigned i = 0; i < actuals.Count(); ++i) {
VaultAddChildNodeAndWait(rvn->GetNodeId(), actuals[i]->GetNodeId(), NetCommGetPlayer()->playerInt);
actuals[i]->UnRef(); // REF: Create
}
for (const hsRef<RelVaultNode> &act : actuals)
VaultAddChildNodeAndWait(rvn->GetNodeId(), act->GetNodeId(), NetCommGetPlayer()->playerInt);
// Cleanup morph SDRs
for (unsigned i = 0; i < morphs.Count(); ++i) {
delete morphs[i];
}
rvn->UnRef();
}
// XXX HACK. DON'T USE (this function exists for the temp console command Clothing.SwapClothTexHACK)
@ -1483,29 +1466,25 @@ bool plClothingOutfit::WriteToFile(const plFileName &filename)
if (!filename.IsValid())
return false;
RelVaultNode* rvn = VaultGetAvatarOutfitFolderIncRef();
hsRef<RelVaultNode> rvn = VaultGetAvatarOutfitFolder();
if (!rvn)
return false;
hsUNIXStream S;
if (!S.Open(filename, "wb")) {
rvn->UnRef();
if (!S.Open(filename, "wb"))
return false;
}
S.WriteByte(fGroup);
ARRAY(RelVaultNode*) nodes;
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
S.WriteLE32(nodes.Count());
for (size_t i = 0; i < nodes.Count(); i++) {
VaultSDLNode sdl(nodes[i]);
RelVaultNode::RefList nodes;
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
S.WriteLE32(nodes.size());
for (const hsRef<RelVaultNode> &node : nodes) {
VaultSDLNode sdl(node);
S.WriteLE32(sdl.GetSDLDataLength());
if (sdl.GetSDLDataLength())
S.Write(sdl.GetSDLDataLength(), sdl.GetSDLData());
nodes[i]->UnRef();
}
rvn->UnRef();
S.Close();
return true;
@ -1626,14 +1605,14 @@ plClothingElement *plClothingMgr::FindElementByName(const plString &name) const
void plClothingMgr::AddItemsToCloset(hsTArray<plClosetItem> &items)
{
RelVaultNode * rvn = VaultGetAvatarClosetFolderIncRef();
hsRef<RelVaultNode> rvn = VaultGetAvatarClosetFolder();
if (!rvn)
return;
hsTArray<plClosetItem> closet;
GetClosetItems(closet);
ARRAY(RelVaultNode*) templates;
RelVaultNode::RefList templates;
for (unsigned i = 0; i < items.GetCount(); ++i) {
bool match = false;
@ -1651,44 +1630,40 @@ void plClothingMgr::AddItemsToCloset(hsTArray<plClosetItem> &items)
plStateDataRecord rec(plClothingSDLModifier::GetClothingItemSDRName());
plClothingSDLModifier::PutSingleItemIntoSDR(&items[i], &rec);
RelVaultNode * templateNode = new RelVaultNode;
templateNode->Ref();
hsRef<RelVaultNode> templateNode = new RelVaultNode;
templateNode->SetNodeType(plVault::kNodeType_SDL);
VaultSDLNode sdl(templateNode);
sdl.SetStateDataRecord(&rec);
templates.Add(templateNode);
templates.push_back(templateNode);
}
for (unsigned i = 0; i < templates.Count(); ++i) {
for (const hsRef<RelVaultNode> &temp : templates) {
ENetError result;
if (RelVaultNode * actual = VaultCreateNodeAndWaitIncRef(templates[i], &result)) {
if (hsRef<RelVaultNode> actual = VaultCreateNodeAndWait(temp, &result)) {
VaultAddChildNodeAndWait(
rvn->GetNodeId(),
actual->GetNodeId(),
NetCommGetPlayer()->playerInt
);
actual->UnRef(); // REF: Create
}
templates[i]->UnRef(); // REF: Create
}
rvn->UnRef();
}
void plClothingMgr::GetClosetItems(hsTArray<plClosetItem> &out)
{
RelVaultNode * rvn = VaultGetAvatarClosetFolderIncRef();
hsRef<RelVaultNode> rvn = VaultGetAvatarClosetFolder();
if (!rvn)
return;
ARRAY(RelVaultNode*) nodes;
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
out.SetCount(nodes.Count());
RelVaultNode::RefList nodes;
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
out.SetCount(nodes.size());
for (unsigned i = 0; i < nodes.Count(); ++i) {
VaultSDLNode sdl(nodes[i]);
auto iter = nodes.begin();
for (unsigned i = 0; i < nodes.size(); ++i, ++iter) {
VaultSDLNode sdl(*iter);
plStateDataRecord * rec = new plStateDataRecord;
if (sdl.GetStateDataRecord(rec, 0))
plClothingSDLModifier::HandleSingleSDR(rec, nil, &out[i]);
@ -1701,8 +1676,6 @@ void plClothingMgr::GetClosetItems(hsTArray<plClosetItem> &out)
out.Remove(i);
}
}
rvn->UnRef();
}
void plClothingMgr::GetAllWithSameMesh(plClothingItem *item, hsTArray<plClothingItem*> &out)

3
Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp

@ -858,7 +858,7 @@ void plSceneInputInterface::ILinkOffereeToAge()
return;
}
}
else if (RelVaultNode * linkNode = VaultGetOwnedAgeLinkIncRef(&info)) {
else if (hsRef<RelVaultNode> linkNode = VaultGetOwnedAgeLink(&info)) {
// We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one.
VaultAgeLinkNode linkAcc(linkNode);
if (linkAcc.GetVolatile()) {
@ -868,7 +868,6 @@ void plSceneInputInterface::ILinkOffereeToAge()
VaultRegisterOwnedAgeAndWait(&link);
}
}
linkNode->UnRef();
}
if (!fSpawnPoint.IsEmpty()) {

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

@ -513,13 +513,13 @@ bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg)
return false;
plAgeLinkStruct* cur = GetAgeLink();
RelVaultNode* cVaultLink = nil;
hsRef<RelVaultNode> cVaultLink;
switch (msg->GetType())
{
case plVaultNotifyMsg::kRegisteredChildAgeLink:
case plVaultNotifyMsg::kRegisteredOwnedAge:
case plVaultNotifyMsg::kRegisteredSubAgeLink:
cVaultLink = VaultGetNodeIncRef(msg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode));
cVaultLink = VaultGetNode(msg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode));
break;
default:
return false;
@ -531,18 +531,15 @@ bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg)
// It's very useful though...
VaultAgeLinkNode accLink(cVaultLink);
accLink.CopyTo(cur);
if (RelVaultNode* rvnInfo = cVaultLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1))
if (hsRef<RelVaultNode> rvnInfo = cVaultLink->GetChildNode(plVault::kNodeType_AgeInfo, 1))
{
VaultAgeInfoNode accInfo(rvnInfo);
accInfo.CopyTo(cur->GetAgeInfo());
rvnInfo->UnRef();
}
IDoLink(fDeferredLink);
fDeferredLink = nil;
return true;
cVaultLink->UnRef();
}
return false;
@ -778,7 +775,7 @@ void plNetLinkingMgr::IPostProcessLink( void )
bool psnl = (info->GetAgeFilename().CompareI(kPersonalAgeFilename) == 0);
// Update our online status
if (RelVaultNode* rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode accInfo(rvnInfo);
wchar_t ageInstName[MAX_PATH];
plUUID ageInstGuid = *info->GetAgeInstanceGuid();
@ -786,7 +783,6 @@ void plNetLinkingMgr::IPostProcessLink( void )
accInfo.SetAgeInstName(ageInstName);
accInfo.SetAgeInstUuid(ageInstGuid);
accInfo.SetOnline(true);
rvnInfo->UnRef();
}
switch (link->GetLinkingRules()) {
@ -797,8 +793,8 @@ void plNetLinkingMgr::IPostProcessLink( void )
break;
{ // Ensure we're in the AgeOwners folder
RelVaultNode* fldr = VaultGetAgeAgeOwnersFolderIncRef();
RelVaultNode* info = VaultGetPlayerInfoNodeIncRef();
hsRef<RelVaultNode> fldr = VaultGetAgeAgeOwnersFolder();
hsRef<RelVaultNode> info = VaultGetPlayerInfoNode();
if (fldr && info)
if (!fldr->IsParentOf(info->GetNodeId(), 1))
@ -809,11 +805,6 @@ void plNetLinkingMgr::IPostProcessLink( void )
nil,
nil
);
if (fldr)
fldr->UnRef();
if (info)
info->UnRef();
}
}
break;
@ -824,8 +815,8 @@ void plNetLinkingMgr::IPostProcessLink( void )
break;
{ // Ensure we're in the CanVisit folder
RelVaultNode* fldr = VaultGetAgeCanVisitFolderIncRef();
RelVaultNode* info = VaultGetPlayerInfoNodeIncRef();
hsRef<RelVaultNode> fldr = VaultGetAgeCanVisitFolder();
hsRef<RelVaultNode> info = VaultGetPlayerInfoNode();
if (fldr && info)
if (!fldr->IsParentOf(info->GetNodeId(), 1))
@ -836,11 +827,6 @@ void plNetLinkingMgr::IPostProcessLink( void )
nil,
nil
);
if (fldr)
fldr->UnRef();
if (info)
info->UnRef();
}
}
break;
@ -873,16 +859,15 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
#if 0
// Appear offline until we're done linking
if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode accInfo(rvnInfo);
accInfo.SetAgeInstName(nil);
accInfo.SetAgeInstUuid(kNilUuid);
accInfo.SetOnline(false);
rvnInfo->UnRef();
}
#else
// Update our online status
if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode accInfo(rvnInfo);
wchar_t ageInstName[MAX_PATH];
plUUID ageInstGuid = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid();
@ -890,7 +875,6 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
accInfo.SetAgeInstName(ageInstName);
accInfo.SetAgeInstUuid(ageInstGuid);
accInfo.SetOnline(true);
rvnInfo->UnRef();
}
#endif
@ -984,7 +968,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
success = kLinkDeferred;
break;
}
else if (RelVaultNode* linkNode = VaultGetOwnedAgeLinkIncRef(&ageInfo)) {
else if (hsRef<RelVaultNode> linkNode = VaultGetOwnedAgeLink(&ageInfo)) {
// We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one.
VaultAgeLinkNode linkAcc(linkNode);
if (linkAcc.GetVolatile()) {
@ -1035,7 +1019,6 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
break;
}
}
linkNode->UnRef();
}
}

10
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -275,10 +275,9 @@ static void PlayerInitCallback (
// Ensure the city link has the required spawn points
plAgeInfoStruct info;
info.SetAgeFilename(kCityAgeFilename);
if (RelVaultNode * rvn = VaultGetOwnedAgeLinkIncRef(&info)) {
if (hsRef<RelVaultNode> rvn = VaultGetOwnedAgeLink(&info)) {
VaultAgeLinkNode acc(rvn);
acc.AddSpawnPoint(plSpawnPointInfo(kCityFerryTerminalLinkTitle, kCityFerryTerminalLinkSpawnPtName));
rvn->UnRef();
}
VaultProcessPlayerInbox();
@ -1119,14 +1118,12 @@ void NetCommSetActivePlayer (//--> plNetCommActivePlayerMsg
unsigned playerInt = 0;
if (s_player) {
if (RelVaultNode* rvn = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvn = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode pInfo(rvn);
pInfo.SetAgeInstName(nil);
pInfo.SetAgeInstUuid(kNilUuid);
pInfo.SetOnline(false);
NetCliAuthVaultNodeSave(rvn, nil, nil);
rvn->UnRef();
}
VaultCull(s_player->playerInt);
@ -1321,10 +1318,9 @@ void NetCommUpgradeVisitorToExplorer (
void NetCommSetCCRLevel (
unsigned ccrLevel
) {
if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode pInfo(rvnInfo);
pInfo.SetCCRLevel(ccrLevel);
rvnInfo->UnRef();
}
NetCliAuthSetCCRLevel(ccrLevel);

21
Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp

@ -132,6 +132,20 @@ bool plAgeInfoStruct::IsEqualTo( const plAgeInfoStruct * other ) const
return match;
}
void plAgeInfoStruct::CopyFrom(const plAgeInfoStruct * other)
{
hsAssert(other, "CopyFrom called with null struct");
fFlags = other->fFlags;
fAgeFilename = other->fAgeFilename;
fAgeInstanceName = other->fAgeInstanceName;
fAgeInstanceGuid = other->fAgeInstanceGuid;
fAgeUserDefinedName = other->fAgeUserDefinedName;
fAgeDescription = other->fAgeDescription;
fAgeSequenceNumber = other->fAgeSequenceNumber;
fAgeLanguage = other->fAgeLanguage;
}
void plAgeInfoStruct::CopyFrom( const plVaultAgeInfoNode * node )
{
hsAssert(false, "eric, port me");
@ -441,7 +455,12 @@ void plAgeLinkStruct::CopyFrom( const plAgeLinkStruct * other )
{
if ( other )
{
*this=*other;
fFlags = other->fFlags;
fAgeInfo.CopyFrom(&other->fAgeInfo);
fLinkingRules = other->fLinkingRules;
fSpawnPoint = other->fSpawnPoint;
fAmCCR = other->fAmCCR;
fParentAgeFilename = other->fParentAgeFilename;
}
else
{

2
Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.h

@ -112,7 +112,7 @@ public:
void Clear();
void UpdateFlags() const;
void CopyFrom( const plAgeInfoStruct * other ) { *this=*other; }
void CopyFrom( const plAgeInfoStruct * other );
void CopyFrom( const plVaultAgeInfoNode * node );
void CopyFrom(const struct NetAgeInfo & info);
bool IsEqualTo( const plAgeInfoStruct * other ) const;

2
Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h

@ -287,7 +287,7 @@ enum ENetTransState {
kTransStateComplete,
};
struct NetTrans : hsAtomicRefCnt {
struct NetTrans : hsRefCnt {
LINK(NetTrans) m_link;
ENetTransState m_state;
ENetError m_result;

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

@ -57,7 +57,7 @@ namespace Ngl { namespace Auth {
*
***/
struct CliAuConn : hsAtomicRefCnt {
struct CliAuConn : hsRefCnt {
CliAuConn ();
~CliAuConn ();
@ -726,7 +726,7 @@ struct VaultFetchNodeTrans : NetAuthTrans {
FNetCliAuthVaultNodeFetched m_callback;
void * m_param;
NetVaultNode * m_node;
hsRef<NetVaultNode> m_node;
VaultFetchNodeTrans (
unsigned nodeId,
@ -751,14 +751,13 @@ struct VaultFindNodeTrans : NetAuthTrans {
FNetCliAuthVaultNodeFind m_callback;
void * m_param;
NetVaultNode * m_node;
hsRef<NetVaultNode> m_node;
VaultFindNodeTrans (
NetVaultNode * templateNode,
FNetCliAuthVaultNodeFind callback,
void * param
);
~VaultFindNodeTrans ();
bool Send ();
@ -774,7 +773,7 @@ struct VaultFindNodeTrans : NetAuthTrans {
//============================================================================
struct VaultCreateNodeTrans : NetAuthTrans {
NetVaultNode * m_templateNode;
hsRef<NetVaultNode> m_templateNode;
FNetCliAuthVaultNodeCreated m_callback;
void * m_param;
@ -1589,7 +1588,7 @@ static unsigned CliAuConnPingTimerProc (void * param) {
//============================================================================
CliAuConn::CliAuConn ()
: hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
: hsRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
, sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false)
@ -3940,8 +3939,6 @@ void VaultFetchNodeTrans::Post () {
m_param,
m_node
);
if (m_node)
m_node->UnRef("Recv");
}
//============================================================================
@ -3954,7 +3951,6 @@ bool VaultFetchNodeTrans::Recv (
if (IS_NET_SUCCESS(reply.result)) {
m_node = new NetVaultNode;
m_node->Read_LCS(reply.nodeBuffer, reply.nodeBytes, 0);
m_node->Ref("Recv");
}
m_result = reply.result;
@ -3980,12 +3976,6 @@ VaultFindNodeTrans::VaultFindNodeTrans (
, m_param(param)
, m_node(templateNode)
{
m_node->Ref();
}
//============================================================================
VaultFindNodeTrans::~VaultFindNodeTrans () {
m_node->UnRef();
}
//============================================================================
@ -4056,7 +4046,6 @@ VaultCreateNodeTrans::VaultCreateNodeTrans (
, m_param(param)
, m_nodeId(0)
{
m_templateNode->Ref();
}
//============================================================================
@ -4086,7 +4075,6 @@ void VaultCreateNodeTrans::Post () {
m_param,
m_nodeId
);
m_templateNode->UnRef();
}
//============================================================================

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp

@ -60,7 +60,7 @@ namespace Ngl { namespace File {
*
***/
struct CliFileConn : hsAtomicRefCnt {
struct CliFileConn : hsRefCnt {
LINK(CliFileConn) link;
hsReaderWriterLock sockLock; // to protect the socket pointer so we don't nuke it while using it
AsyncSocket sock;
@ -581,7 +581,7 @@ static void AsyncLookupCallback (
//============================================================================
CliFileConn::CliFileConn ()
: hsAtomicRefCnt(0), sock(nil), seq(0), cancelId(nil), abandoned(false)
: hsRefCnt(0), sock(nil), seq(0), cancelId(nil), abandoned(false)
, buildId(0), serverType(0)
, reconnectTimer(nil), reconnectStartMs(0), connectStartMs(0)
, numImmediateDisconnects(0), numFailedConnects(0)

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp

@ -55,7 +55,7 @@ namespace Ngl { namespace Game {
*
***/
struct CliGmConn : hsAtomicRefCnt {
struct CliGmConn : hsRefCnt {
LINK(CliGmConn) link;
CCritSect critsect;
@ -415,7 +415,7 @@ static unsigned CliGmConnPingTimerProc (void * param) {
//============================================================================
CliGmConn::CliGmConn ()
: hsAtomicRefCnt(0), sock(nil), cancelId(nil), cli(nil)
: hsRefCnt(0), sock(nil), cancelId(nil), cli(nil)
, seq(0), abandoned(false)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
{

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp

@ -56,7 +56,7 @@ namespace Ngl { namespace GateKeeper {
*
***/
struct CliGkConn : hsAtomicRefCnt {
struct CliGkConn : hsRefCnt {
CliGkConn ();
~CliGkConn ();
@ -525,7 +525,7 @@ static unsigned CliGkConnPingTimerProc (void * param) {
//============================================================================
CliGkConn::CliGkConn ()
: hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
: hsRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
, sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false)

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp

@ -117,7 +117,7 @@ static void CancelTrans_CS (NetTrans * trans, ENetError error) {
//============================================================================
NetTrans::NetTrans (ENetProtocol protocol, ETransType transType)
: hsAtomicRefCnt(0)
: hsRefCnt(0)
, m_state(kTransStateWaitServerConnect)
, m_result(kNetPending)
, m_transId(0)

2
Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h

@ -48,7 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//
// refcntable data
//
class plNetCommonMessageData : public hsAtomicRefCnt
class plNetCommonMessageData : public hsRefCnt
{
private:
char *fData; // sent

10
Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.cpp

@ -71,6 +71,16 @@ plFogEnvironment::~plFogEnvironment()
{
}
plFogEnvironment &plFogEnvironment::operator=(const plFogEnvironment &copy)
{
fType = copy.fType;
fStart = copy.fStart;
fEnd = copy.fEnd;
fDensity = copy.fDensity;
fColor = copy.fColor;
return *this;
}
//// Set /////////////////////////////////////////////////////////////////////
void plFogEnvironment::Set( float start, float end, float density, const hsColorRGBA *color )

3
Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.h

@ -85,6 +85,9 @@ class plFogEnvironment : public hsKeyedObject
plFogEnvironment( FogType type, float end, float density, hsColorRGBA &color );
~plFogEnvironment();
plFogEnvironment(const plFogEnvironment &copy) { operator=(copy); }
plFogEnvironment &operator=(const plFogEnvironment &copy);
// Sets the parameters for linear fog
void Set( float start, float end, float density, const hsColorRGBA *color = nil );

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

File diff suppressed because it is too large Load Diff

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

@ -94,6 +94,8 @@ void VaultUnregisterCallback (VaultCallback * cb);
*
***/
struct RelVaultNode : NetVaultNode {
typedef std::list<hsRef<RelVaultNode>> RefList;
struct IRelVaultNode * state;
RelVaultNode ();
@ -127,50 +129,50 @@ struct RelVaultNode : NetVaultNode {
);
// returns first matching node found
RelVaultNode * GetParentNodeIncRef (
hsRef<RelVaultNode> GetParentNode (
NetVaultNode * templateNode,
unsigned maxDepth
);
RelVaultNode * GetChildNodeIncRef (
hsRef<RelVaultNode> GetChildNode (
NetVaultNode * templateNode,
unsigned maxDepth
);
RelVaultNode * GetChildNodeIncRef (
hsRef<RelVaultNode> GetChildNode (
unsigned nodeType,
unsigned maxDepth
);
RelVaultNode * GetChildFolderNodeIncRef (
hsRef<RelVaultNode> GetChildFolderNode (
unsigned folderType,
unsigned maxDepth
);
RelVaultNode * GetChildPlayerInfoListNodeIncRef (
hsRef<RelVaultNode> GetChildPlayerInfoListNode (
unsigned folderType,
unsigned maxDepth
);
RelVaultNode * GetChildAgeInfoListNodeIncRef (
hsRef<RelVaultNode> GetChildAgeInfoListNode (
unsigned folderType,
unsigned maxDepth
);
// returns all matching nodes found
void GetChildNodesIncRef (
void GetChildNodes (
unsigned maxDepth,
ARRAY(RelVaultNode*) * nodes
RefList * nodes
);
void GetChildNodesIncRef (
void GetChildNodes (
NetVaultNode * templateNode,
unsigned maxDepth,
ARRAY(RelVaultNode*) * nodes
RefList * nodes
);
void GetChildNodesIncRef (
void GetChildNodes (
unsigned nodeType,
unsigned maxDepth,
ARRAY(RelVaultNode*) * nodes
RefList * nodes
);
void GetChildFolderNodesIncRef (
void GetChildFolderNodes (
unsigned folderType,
unsigned maxDepth,
ARRAY(RelVaultNode*) * nodes
RefList * nodes
);
unsigned GetRefOwnerId (unsigned parentId);
@ -183,7 +185,7 @@ struct RelVaultNode : NetVaultNode {
void PrintTree (FStateDump dumpProc, unsigned level);
// AgeInfoNode-specific (and it checks!)
RelVaultNode * GetParentAgeLinkIncRef ();
hsRef<RelVaultNode> GetParentAgeLink ();
};
@ -204,12 +206,9 @@ void VaultUpdate ();
*
***/
RelVaultNode * VaultGetNodeIncRef (
unsigned nodeId
);
RelVaultNode * VaultGetNodeIncRef (
NetVaultNode * templateNode
);
hsRef<RelVaultNode> VaultGetNode(unsigned nodeId);
hsRef<RelVaultNode> VaultGetNode(NetVaultNode * templateNode);
// VaultAddChildNode will download the child node if necessary
// the parent exists locally before making the callback.
typedef void (*FVaultAddChildNodeCallback)(
@ -272,11 +271,11 @@ void VaultCreateNode ( // non-blocking
void * state,
void * param
);
RelVaultNode * VaultCreateNodeAndWaitIncRef ( // block until completion. returns node. nil --> failure
hsRef<RelVaultNode> VaultCreateNodeAndWait ( // block until completion. returns node. nil --> failure
plVault::NodeTypes nodeType,
ENetError * result
);
RelVaultNode * VaultCreateNodeAndWaitIncRef ( // block until completion. returns node. nil --> failure
hsRef<RelVaultNode> VaultCreateNodeAndWait ( // block until completion. returns node. nil --> failure
NetVaultNode * templateNode,
ENetError * result
);
@ -303,7 +302,7 @@ void VaultLocalFindNodes (
NetVaultNode * templateNode,
ARRAY(unsigned) * nodeIds
);
void VaultFetchNodesAndWait ( // Use VaultGetNodeIncRef to access the fetched nodes
void VaultFetchNodesAndWait ( // Use VaultGetNode to access the fetched nodes
const unsigned nodeIds[],
unsigned count,
bool force = false
@ -331,22 +330,22 @@ void VaultInitAge (
***/
unsigned VaultGetPlayerId();
RelVaultNode * VaultGetPlayerNodeIncRef ();
RelVaultNode * VaultGetPlayerInfoNodeIncRef ();
RelVaultNode * VaultGetAvatarOutfitFolderIncRef ();
RelVaultNode * VaultGetAvatarClosetFolderIncRef ();
hsRef<RelVaultNode> VaultGetPlayerNode();
hsRef<RelVaultNode> VaultGetPlayerInfoNode();
hsRef<RelVaultNode> VaultGetAvatarOutfitFolder();
hsRef<RelVaultNode> VaultGetAvatarClosetFolder();
bool VaultGetLinkToMyNeighborhood(plAgeLinkStruct * link);
bool VaultGetLinkToMyPersonalAge(plAgeLinkStruct * link);
bool VaultGetLinkToCity(plAgeLinkStruct * link);
RelVaultNode * VaultGetAgesIOwnFolderIncRef ();
RelVaultNode * VaultGetAgesICanVisitFolderIncRef ();
RelVaultNode * VaultGetPlayerInboxFolderIncRef ();
RelVaultNode * VaultGetOwnedAgeLinkIncRef (const plAgeInfoStruct * info);
RelVaultNode * VaultGetOwnedAgeInfoIncRef (const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultGetAgesIOwnFolder();
hsRef<RelVaultNode> VaultGetAgesICanVisitFolder();
hsRef<RelVaultNode> VaultGetPlayerInboxFolder();
hsRef<RelVaultNode> VaultGetOwnedAgeLink(const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultGetOwnedAgeInfo(const plAgeInfoStruct * info);
bool VaultGetOwnedAgeLink(const plAgeInfoStruct * info, plAgeLinkStruct * link);
bool VaultAddOwnedAgeSpawnPoint(const plUUID& ageInstId, const plSpawnPointInfo & spawnPt);
bool VaultSetOwnedAgePublicAndWait(const plAgeInfoStruct * info, bool publicOrNot);
RelVaultNode * VaultGetVisitAgeLinkIncRef (const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultGetVisitAgeLink(const plAgeInfoStruct * info);
bool VaultGetVisitAgeLink(const plAgeInfoStruct * info, class plAgeLinkStruct * link);
bool VaultRegisterOwnedAgeAndWait(const plAgeLinkStruct * link);
void VaultRegisterOwnedAge(const plAgeLinkStruct* link);
@ -354,7 +353,7 @@ bool VaultRegisterVisitAgeAndWait (const plAgeLinkStruct * link);
void VaultRegisterVisitAge(const plAgeLinkStruct* link);
bool VaultUnregisterOwnedAgeAndWait(const plAgeInfoStruct * info);
bool VaultUnregisterVisitAgeAndWait(const plAgeInfoStruct * info);
RelVaultNode * VaultFindChronicleEntryIncRef (const wchar_t entryName[], int entryType = -1);
hsRef<RelVaultNode> VaultFindChronicleEntry(const wchar_t entryName[], int entryType = -1);
bool VaultHasChronicleEntry(const wchar_t entryName[], int entryType = -1);
// if entry of same name and type already exists, value is updated
void VaultAddChronicleEntryAndWait (
@ -390,32 +389,32 @@ void VaultProcessPlayerInbox ();
#define DEFAULT_DEVICE_INBOX L"DevInbox"
RelVaultNode * VaultGetAgeNodeIncRef ();
RelVaultNode * VaultGetAgeInfoNodeIncRef ();
RelVaultNode * VaultGetAgeChronicleFolderIncRef ();
RelVaultNode * VaultGetAgeDevicesFolderIncRef ();
RelVaultNode * VaultGetAgeSubAgesFolderIncRef ();
RelVaultNode * VaultGetAgeChildAgesFolderIncRef ();
RelVaultNode * VaultGetAgeAgeOwnersFolderIncRef ();
RelVaultNode * VaultGetAgeCanVisitFolderIncRef ();
RelVaultNode * VaultGetAgePeopleIKnowAboutFolderIncRef ();
RelVaultNode * VaultGetAgePublicAgesFolderIncRef ();
RelVaultNode * VaultAgeGetBookshelfFolderIncRef ();
RelVaultNode * VaultFindAgeSubAgeLinkIncRef (const plAgeInfoStruct * info);
RelVaultNode * VaultFindAgeChildAgeLinkIncRef (const plAgeInfoStruct * info);
RelVaultNode * VaultFindAgeChronicleEntryIncRef (const wchar_t entryName[], int entryType = -1);
hsRef<RelVaultNode> VaultGetAgeNode();
hsRef<RelVaultNode> VaultGetAgeInfoNode();
hsRef<RelVaultNode> VaultGetAgeChronicleFolder();
hsRef<RelVaultNode> VaultGetAgeDevicesFolder();
hsRef<RelVaultNode> VaultGetAgeSubAgesFolder();
hsRef<RelVaultNode> VaultGetAgeChildAgesFolder();
hsRef<RelVaultNode> VaultGetAgeAgeOwnersFolder();
hsRef<RelVaultNode> VaultGetAgeCanVisitFolder();
hsRef<RelVaultNode> VaultGetAgePeopleIKnowAboutFolder();
hsRef<RelVaultNode> VaultGetAgePublicAgesFolder();
hsRef<RelVaultNode> VaultAgeGetBookshelfFolder();
hsRef<RelVaultNode> VaultFindAgeSubAgeLink(const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultFindAgeChildAgeLink(const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultFindAgeChronicleEntry(const wchar_t entryName[], int entryType = -1);
// if entry of same name and type already exists, value is updated
void VaultAddAgeChronicleEntry (
const wchar_t entryName[],
int entryType,
const wchar_t entryValue[]
);
RelVaultNode * VaultAgeAddDeviceAndWaitIncRef (const wchar_t deviceName[]); // blocks until completion
hsRef<RelVaultNode> VaultAgeAddDeviceAndWait(const wchar_t deviceName[]); // blocks until completion
void VaultAgeRemoveDevice (const wchar_t deviceName[]);
bool VaultAgeHasDevice (const wchar_t deviceName[]);
RelVaultNode * VaultAgeGetDeviceIncRef (const wchar_t deviceName[]);
RelVaultNode * VaultAgeSetDeviceInboxAndWaitIncRef (const wchar_t deviceName[], const wchar_t inboxName[]); // blocks until completion
RelVaultNode * VaultAgeGetDeviceInboxIncRef (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[]);
void VaultClearDeviceInboxMap ();
bool VaultAgeGetAgeSDL (class plStateDataRecord * out);
@ -423,7 +422,7 @@ void VaultAgeUpdateAgeSDL (const class plStateDataRecord * rec);
unsigned VaultAgeGetAgeTime ();
RelVaultNode * VaultGetSubAgeLinkIncRef (const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultGetSubAgeLink(const plAgeInfoStruct * info);
bool VaultAgeGetSubAgeLink (
const plAgeInfoStruct * info,
plAgeLinkStruct * link
@ -494,7 +493,7 @@ void VaultCull (
*
***/
RelVaultNode * VaultGetSystemNodeIncRef ();
RelVaultNode * VaultGetGlobalInboxIncRef ();
hsRef<RelVaultNode> VaultGetSystemNode();
hsRef<RelVaultNode> VaultGetGlobalInbox();
#endif // def CLIENT

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

@ -435,14 +435,12 @@ struct MatchesSpawnPointName
//============================================================================
#ifdef CLIENT
bool VaultAgeLinkNode::CopyTo (plAgeLinkStruct * link) {
if (RelVaultNode * me = VaultGetNodeIncRef(base->GetNodeId())) {
if (RelVaultNode * info = me->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) {
if (hsRef<RelVaultNode> me = VaultGetNode(base->GetNodeId())) {
if (hsRef<RelVaultNode> info = me->GetChildNode(plVault::kNodeType_AgeInfo, 1)) {
VaultAgeInfoNode access(info);
access.CopyTo(link->GetAgeInfo());
me->UnRef();
return true;
}
me->UnRef();
}
link->Clear();
return false;

Loading…
Cancel
Save