From e929708a3b58099d32b7a5c24f3001b1968c2fb0 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 5 Apr 2014 19:20:04 -0700 Subject: [PATCH 1/4] Use std::atomic_int for hsSafeRefCnt, and move it to hsRefCnt.h/cpp --- Sources/Plasma/CoreLib/CMakeLists.txt | 2 - Sources/Plasma/CoreLib/hsRefCnt.cpp | 28 ++++++-- Sources/Plasma/CoreLib/hsRefCnt.h | 25 ++++++- Sources/Plasma/CoreLib/hsSafeRefCnt.cpp | 44 ------------- Sources/Plasma/CoreLib/hsSafeRefCnt.h | 65 ------------------- .../plNetMessage/plNetCommonMessage.h | 2 +- 6 files changed, 46 insertions(+), 120 deletions(-) delete mode 100644 Sources/Plasma/CoreLib/hsSafeRefCnt.cpp delete mode 100644 Sources/Plasma/CoreLib/hsSafeRefCnt.h diff --git a/Sources/Plasma/CoreLib/CMakeLists.txt b/Sources/Plasma/CoreLib/CMakeLists.txt index cea36c49..d2f65fb5 100644 --- a/Sources/Plasma/CoreLib/CMakeLists.txt +++ b/Sources/Plasma/CoreLib/CMakeLists.txt @@ -43,7 +43,6 @@ set(CoreLib_SOURCES hsMemory.cpp hsQuat.cpp hsRefCnt.cpp - hsSafeRefCnt.cpp hsSTLStream.cpp hsStream.cpp hsStringTokenizer.cpp @@ -88,7 +87,6 @@ set(CoreLib_HEADERS hsPoint2.h hsQuat.h hsRefCnt.h - hsSafeRefCnt.h hsSTLStream.h hsStream.h hsStringTokenizer.h diff --git a/Sources/Plasma/CoreLib/hsRefCnt.cpp b/Sources/Plasma/CoreLib/hsRefCnt.cpp index 7f9a0d86..e2226cb9 100644 --- a/Sources/Plasma/CoreLib/hsRefCnt.cpp +++ b/Sources/Plasma/CoreLib/hsRefCnt.cpp @@ -48,17 +48,35 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com hsRefCnt::~hsRefCnt() { - hsDebugCode(hsThrowIfFalse(fRefCnt == 1);) +#ifdef HS_DEBUGGING + hsThrowIfFalse(fRefCnt == 1); +#endif } -void hsRefCnt::Ref() +void hsRefCnt::UnRef() +{ +#ifdef HS_DEBUGGING + hsThrowIfFalse(fRefCnt >= 1); +#endif + + if (fRefCnt == 1) // don't decrement if we call delete + delete this; + else + --fRefCnt; +} + +hsSafeRefCnt::~hsSafeRefCnt() { - fRefCnt++; +#ifdef HS_DEBUGGING + hsThrowIfFalse(fRefCnt == 1); +#endif } -void hsRefCnt::UnRef() +void hsSafeRefCnt::UnRef() { - hsDebugCode(hsThrowIfFalse(fRefCnt >= 1);) +#ifdef HS_DEBUGGING + hsThrowIfFalse(fRefCnt >= 1); +#endif if (fRefCnt == 1) // don't decrement if we call delete delete this; diff --git a/Sources/Plasma/CoreLib/hsRefCnt.h b/Sources/Plasma/CoreLib/hsRefCnt.h index 822863b9..97bc5315 100644 --- a/Sources/Plasma/CoreLib/hsRefCnt.h +++ b/Sources/Plasma/CoreLib/hsRefCnt.h @@ -42,6 +42,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #ifndef hsRefCnt_Defiend #define hsRefCnt_Defiend +#include + class hsRefCnt { private: int fRefCnt; @@ -49,9 +51,9 @@ public: hsRefCnt() : fRefCnt(1) {} virtual ~hsRefCnt(); - virtual int RefCnt() const { return fRefCnt; } - virtual void UnRef(); - virtual void Ref(); + inline int RefCnt() const { return fRefCnt; } + void UnRef(); + inline void Ref() { ++fRefCnt; } }; #define hsRefCnt_SafeRef(obj) do { if (obj) (obj)->Ref(); } while (0) @@ -64,4 +66,21 @@ public: dst = src; \ } while (0) + +// Thread-safe version. TODO: Evaluate whether this is fast enough to +// merge with hsRefCnt above. +class hsSafeRefCnt +{ +private: + std::atomic fRefCnt; + +public: + hsSafeRefCnt() : fRefCnt(1) { } + virtual ~hsSafeRefCnt(); + + inline int RefCnt() const { return fRefCnt; } + void UnRef(); + inline void Ref() { ++fRefCnt; } +}; + #endif diff --git a/Sources/Plasma/CoreLib/hsSafeRefCnt.cpp b/Sources/Plasma/CoreLib/hsSafeRefCnt.cpp deleted file mode 100644 index c5395a0a..00000000 --- a/Sources/Plasma/CoreLib/hsSafeRefCnt.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Additional permissions under GNU GPL version 3 section 7 - -If you modify this Program, or any covered work, by linking or -combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, -NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent -JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK -(or a modified version of those libraries), -containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, -PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG -JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the -licensors of this Program grant you additional -permission to convey the resulting work. Corresponding Source for a -non-source form of such a combination shall include the source code for -the parts of OpenSSL and IJG JPEG Library used as well as that of the covered -work. - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -#include "hsSafeRefCnt.h" - -hsMutex hsSafeRefCnt::fMutex; diff --git a/Sources/Plasma/CoreLib/hsSafeRefCnt.h b/Sources/Plasma/CoreLib/hsSafeRefCnt.h deleted file mode 100644 index a772a70a..00000000 --- a/Sources/Plasma/CoreLib/hsSafeRefCnt.h +++ /dev/null @@ -1,65 +0,0 @@ -/*==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Additional permissions under GNU GPL version 3 section 7 - -If you modify this Program, or any covered work, by linking or -combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, -NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent -JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK -(or a modified version of those libraries), -containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, -PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG -JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the -licensors of this Program grant you additional -permission to convey the resulting work. Corresponding Source for a -non-source form of such a combination shall include the source code for -the parts of OpenSSL and IJG JPEG Library used as well as that of the covered -work. - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -#ifndef HS_SAFE_REF_CNT_H -#define HS_SAFE_REF_CNT_H - -#include "hsRefCnt.h" -#include "hsThread.h" - -// -// Thread Safe RefCounter -// - -class hsSafeRefCnt : public hsRefCnt -{ -private: - static hsMutex fMutex; -protected: - virtual void IRef() { } - virtual void IUnRef() { }; -public: - virtual int RefCnt() const { hsTempMutexLock temp(fMutex); return hsRefCnt::RefCnt(); } - void UnRef() { hsTempMutexLock temp(fMutex); IUnRef(); hsRefCnt::UnRef(); } - void Ref() { hsTempMutexLock temp(fMutex); IRef(); hsRefCnt::Ref(); } -}; - -#endif //HS_SAFE_REF_CNT_H diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h b/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h index 5b2b7b71..44b6798e 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h +++ b/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h @@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define plNetCommonMessage_inc #include "HeadSpin.h" -#include "hsSafeRefCnt.h" +#include "hsRefCnt.h" // // refcntable data From d713a13dbe4ddb806ce36e239024c7ccd84f71db Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sun, 6 Apr 2014 00:04:22 -0700 Subject: [PATCH 2/4] Merge pnUtRef with hsRefCnt, and remove the former --- Sources/Plasma/CoreLib/hsRefCnt.cpp | 31 +- Sources/Plasma/CoreLib/hsRefCnt.h | 13 +- .../Plasma/FeatureLib/pfPython/cyAvatar.cpp | 4 +- Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp | 4 +- .../FeatureLib/pfPython/plPythonFileMod.cpp | 2 +- .../Plasma/FeatureLib/pfPython/pyAgeVault.cpp | 32 +- .../FeatureLib/pfPython/pyDniInfoSource.cpp | 6 +- .../FeatureLib/pfPython/pyGameScore.cpp | 8 +- .../Plasma/FeatureLib/pfPython/pyVault.cpp | 70 +-- .../pfPython/pyVaultAgeInfoListNodeGlue.cpp | 4 +- .../pfPython/pyVaultAgeInfoNode.cpp | 8 +- .../pfPython/pyVaultAgeInfoNodeGlue.cpp | 4 +- .../pfPython/pyVaultAgeLinkNode.cpp | 2 +- .../pfPython/pyVaultAgeLinkNodeGlue.cpp | 4 +- .../pfPython/pyVaultChronicleNodeGlue.cpp | 4 +- .../pfPython/pyVaultFolderNodeGlue.cpp | 4 +- .../pfPython/pyVaultImageNodeGlue.cpp | 4 +- .../pfPython/pyVaultMarkerGameNodeGlue.cpp | 4 +- .../FeatureLib/pfPython/pyVaultNode.cpp | 42 +- .../FeatureLib/pfPython/pyVaultNodeGlue.cpp | 4 +- .../FeatureLib/pfPython/pyVaultNodeRef.cpp | 18 +- .../pfPython/pyVaultNodeRefGlue.cpp | 8 +- .../pfPython/pyVaultPlayerInfoListNode.cpp | 24 +- .../pyVaultPlayerInfoListNodeGlue.cpp | 4 +- .../pfPython/pyVaultPlayerInfoNodeGlue.cpp | 4 +- .../FeatureLib/pfPython/pyVaultPlayerNode.cpp | 10 +- .../pfPython/pyVaultPlayerNodeGlue.cpp | 4 +- .../pfPython/pyVaultSDLNodeGlue.cpp | 4 +- .../pfPython/pyVaultSystemNodeGlue.cpp | 4 +- .../pfPython/pyVaultTextNoteNode.cpp | 2 +- .../pfPython/pyVaultTextNoteNodeGlue.cpp | 4 +- .../NucleusLib/pnNetCli/pnNcChannel.cpp | 15 +- .../pnNetProtocol/Private/pnNpCommon.h | 3 +- .../Plasma/NucleusLib/pnUtils/CMakeLists.txt | 1 - .../NucleusLib/pnUtils/pnUtAllIncludes.h | 1 - Sources/Plasma/NucleusLib/pnUtils/pnUtRef.h | 180 -------- .../PubUtilLib/plAvatar/plAvatarClothing.cpp | 40 +- .../plInputCore/plSceneInputInterface.cpp | 2 +- .../plNetClient/plNetLinkingMgr.cpp | 20 +- .../plNetClientComm/plNetClientComm.cpp | 6 +- .../Plasma/PubUtilLib/plNetGameLib/Intern.h | 2 +- .../plNetGameLib/Private/plNglAuth.cpp | 54 +-- .../plNetGameLib/Private/plNglFile.cpp | 26 +- .../plNetGameLib/Private/plNglGame.cpp | 28 +- .../plNetGameLib/Private/plNglGateKeeper.cpp | 26 +- .../plNetGameLib/Private/plNglTrans.cpp | 10 +- .../plNetMessage/plNetCommonMessage.h | 2 +- .../PubUtilLib/plVault/plVaultClientApi.cpp | 420 +++++++++--------- .../PubUtilLib/plVault/plVaultNodeAccess.cpp | 4 +- 49 files changed, 515 insertions(+), 665 deletions(-) delete mode 100644 Sources/Plasma/NucleusLib/pnUtils/pnUtRef.h diff --git a/Sources/Plasma/CoreLib/hsRefCnt.cpp b/Sources/Plasma/CoreLib/hsRefCnt.cpp index e2226cb9..9d682075 100644 --- a/Sources/Plasma/CoreLib/hsRefCnt.cpp +++ b/Sources/Plasma/CoreLib/hsRefCnt.cpp @@ -65,21 +65,48 @@ void hsRefCnt::UnRef() --fRefCnt; } -hsSafeRefCnt::~hsSafeRefCnt() +hsAtomicRefCnt::~hsAtomicRefCnt() { #ifdef HS_DEBUGGING hsThrowIfFalse(fRefCnt == 1); #endif } -void hsSafeRefCnt::UnRef() +void hsAtomicRefCnt::UnRef(const char* tag) { #ifdef HS_DEBUGGING hsThrowIfFalse(fRefCnt >= 1); #endif +#ifdef REFCOUNT_DEBUGGING + if (tag) + DEBUG_MSG("Dec %p %s: %u", this, tag, prev - 1); + else + DEBUG_MSG("Dec %p: %u", this, prev - 1); +#endif + if (fRefCnt == 1) // don't decrement if we call delete delete this; else --fRefCnt; } + +void hsAtomicRefCnt::Ref(const char* tag) +{ +#ifdef REFCOUNT_DEBUGGING + if (tag) + DEBUG_MSG("Inc %p %s: %u", this, tag, prev + 1); + else + DEBUG_MSG("Inc %p: %u", this, prev + 1); +#endif + + ++fRefCnt; +} + +void hsAtomicRefCnt::TransferRef(const char* oldTag, const char* newTag) +{ +#ifdef REFCOUNT_DEBUGGING + DEBUG_MSG("Inc %p %s: (xfer)", this, newTag); + DEBUG_MSG("Dec %p %s: (xfer)", this, oldTag); +#endif +} diff --git a/Sources/Plasma/CoreLib/hsRefCnt.h b/Sources/Plasma/CoreLib/hsRefCnt.h index 97bc5315..e4c0721e 100644 --- a/Sources/Plasma/CoreLib/hsRefCnt.h +++ b/Sources/Plasma/CoreLib/hsRefCnt.h @@ -69,18 +69,21 @@ public: // Thread-safe version. TODO: Evaluate whether this is fast enough to // merge with hsRefCnt above. -class hsSafeRefCnt +class hsAtomicRefCnt { private: std::atomic fRefCnt; public: - hsSafeRefCnt() : fRefCnt(1) { } - virtual ~hsSafeRefCnt(); + hsAtomicRefCnt() : fRefCnt(1) { } + virtual ~hsAtomicRefCnt(); 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); }; #endif diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp index ff3e3b0f..95aac6c8 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp @@ -1695,7 +1695,7 @@ void cyAvatar::ChangeAvatar(const char* genderName) if (rvnPlr) { VaultPlayerNode plr(rvnPlr); plr.SetAvatarShapeName(wStr); - rvnPlr->DecRef(); + rvnPlr->UnRef(); } #endif } @@ -1716,7 +1716,7 @@ void cyAvatar::ChangePlayerName(const char* playerName) if (rvnPlr) { VaultPlayerNode plr(rvnPlr); plr.SetPlayerName(wStr); - rvnPlr->DecRef(); + rvnPlr->UnRef(); } } diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index fe00a35b..15c26c4d 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -2474,7 +2474,7 @@ int cyMisc::GetKILevel() if (RelVaultNode * rvn = VaultFindChronicleEntryIncRef(wStr)) { VaultChronicleNode chron(rvn); result = wcstol(chron.GetEntryValue(), nil, 0); - rvn->DecRef(); + rvn->UnRef(); } return result; @@ -2893,7 +2893,7 @@ void cyMisc::SendFriendInvite(const wchar_t email[], const wchar_t toName[]) } NetCommSendFriendInvite(email, toName, inviteUuid); - pNode->DecRef(); + pNode->UnRef(); } } diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp index feb52b3b..0c9ab7f0 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp @@ -2082,7 +2082,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg) Py_DECREF(ptuple); ptuple = PyTuple_New(1); PyTuple_SetItem(ptuple, 0, pyVaultAgeLinkNode::New(rvn)); - rvn->DecRef(); + rvn->UnRef(); } } break; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp b/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp index 40f8944f..883656b6 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp @@ -84,7 +84,7 @@ PyObject* pyAgeVault::GetAgeInfo() RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef(); if (rvn) { PyObject * result = pyVaultAgeInfoNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -97,7 +97,7 @@ PyObject* pyAgeVault::GetAgeDevicesFolder( void ) RelVaultNode * rvn = VaultGetAgeDevicesFolderIncRef(); if (rvn) { PyObject * result = pyVaultFolderNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -110,7 +110,7 @@ PyObject* pyAgeVault::GetSubAgesFolder( void ) RelVaultNode * rvn = VaultGetAgeSubAgesFolderIncRef(); if (rvn) { PyObject * result = pyVaultFolderNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -123,7 +123,7 @@ PyObject* pyAgeVault::GetChronicleFolder( void ) RelVaultNode * rvn = VaultGetAgeChronicleFolderIncRef(); if (rvn) { PyObject * result = pyVaultFolderNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -136,7 +136,7 @@ PyObject* pyAgeVault::GetBookshelfFolder ( void ) RelVaultNode * rvn = VaultAgeGetBookshelfFolderIncRef(); if (rvn) { PyObject * result = pyVaultFolderNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -149,7 +149,7 @@ PyObject* pyAgeVault::GetPeopleIKnowAboutFolder( void ) RelVaultNode * rvn = VaultGetAgePeopleIKnowAboutFolderIncRef(); if (rvn) { PyObject * result = pyVaultFolderNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -163,7 +163,7 @@ PyObject* pyAgeVault::GetPublicAgesFolder(void) RelVaultNode * rvn = VaultGetAgePublicAgesFolderIncRef(); if (rvn) { PyObject * result = pyVaultFolderNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -176,7 +176,7 @@ PyObject* pyAgeVault::GetSubAgeLink( const pyAgeInfoStruct & info ) RelVaultNode * rvn = VaultFindAgeSubAgeLinkIncRef(info.GetAgeInfo()); if (rvn) { PyObject * result = pyVaultAgeLinkNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -190,7 +190,7 @@ plUUID pyAgeVault::GetAgeGuid( void ) if (rvn) { VaultAgeInfoNode ageInfo(rvn); plUUID uuid = ageInfo.GetAgeInstanceGuid(); - rvn->DecRef(); + rvn->UnRef(); return uuid; } return kNilUuid; @@ -206,7 +206,7 @@ PyObject* pyAgeVault::FindChronicleEntry( const char * entryName ) if (RelVaultNode * rvn = VaultFindAgeChronicleEntryIncRef(wEntryName)) { PyObject * result = pyVaultChronicleNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -237,7 +237,7 @@ void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, uint32 if (RelVaultNode * rvn = VaultAgeAddDeviceAndWaitIncRef(wStr)) { cb->SetNode(rvn); - rvn->DecRef(); + rvn->UnRef(); } cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail); // cbHolder deletes itself here. @@ -268,7 +268,7 @@ PyObject * pyAgeVault::GetDevice( const char * deviceName ) if (RelVaultNode * rvn = VaultAgeGetDeviceIncRef(wStr)) { PyObject * result = pyVaultTextNoteNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -288,7 +288,7 @@ void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName if (RelVaultNode * rvn = VaultAgeSetDeviceInboxAndWaitIncRef(wDev, wInb)) { cb->SetNode(rvn); - rvn->DecRef(); + rvn->UnRef(); } cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here. @@ -301,7 +301,7 @@ PyObject * pyAgeVault::GetDeviceInbox( const char * deviceName ) if (RelVaultNode * rvn = VaultAgeGetDeviceInboxIncRef(wStr)) { PyObject * result = pyVaultTextNoteNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -333,10 +333,10 @@ PyObject* pyAgeVault::FindNode( pyVaultNode* templateNode ) const { if (RelVaultNode * rvn = VaultGetAgeNodeIncRef()) { RelVaultNode * find = rvn->GetChildNodeIncRef(templateNode->fNode, 1); - rvn->DecRef(); + rvn->UnRef(); if (find) { PyObject * result = pyVaultNode::New(find); - find->DecRef(); + find->UnRef(); return result; } } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp b/Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp index 0569c314..ebd15ebc 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp @@ -81,7 +81,7 @@ uint32_t pyDniInfoSource::GetAgeTime( void ) const result = (uint32_t)utime->GetSecs(); else result = 0; - node->DecRef(); + node->UnRef(); return result; } @@ -95,7 +95,7 @@ const char * pyDniInfoSource::GetAgeName( void ) const VaultAgeInfoNode ageInfo(node); fAgeName = StrDupToAnsi(ageInfo.GetAgeInstanceName()); - node->DecRef(); + node->UnRef(); return fAgeName; } @@ -106,7 +106,7 @@ plUUID pyDniInfoSource::GetAgeGuid( void ) const { VaultAgeInfoNode ageInfo(node); plUUID uuid = ageInfo.GetAgeInstanceGuid(); - node->DecRef(); + node->UnRef(); return uuid; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyGameScore.cpp b/Sources/Plasma/FeatureLib/pfPython/pyGameScore.cpp index af2fa346..01a92ee6 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyGameScore.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyGameScore.cpp @@ -129,7 +129,7 @@ void pyGameScore::CreateAgeScore(const plString& name, uint32_t type, int32_t po { uint32_t ownerId = ageInfo->GetNodeId(); pfGameScore::Create(ownerId, name, type, points, rcvr.getKey()); - ageInfo->DecRef(); + ageInfo->UnRef(); } else hsAssert(false, "Age has no vault... Need to rewrite score python script?"); } @@ -145,7 +145,7 @@ void pyGameScore::CreatePlayerScore(const plString& name, uint32_t type, int32_t { uint32_t ownerId = node->GetNodeId(); pfGameScore::Create(ownerId, name, type, points, rcvr.getKey()); - node->DecRef(); + node->UnRef(); } else hsAssert(false, "No PlayerInfo node... Need to rewrite python script?"); } @@ -161,7 +161,7 @@ void pyGameScore::FindAgeScores(const plString& name, pyKey& rcvr) { uint32_t ownerId = ageInfo->GetNodeId(); pfGameScore::Find(ownerId, name, rcvr.getKey()); - ageInfo->DecRef(); + ageInfo->UnRef(); } else hsAssert(false, "Age has no vault... Need to rewrite score python script?"); } @@ -177,7 +177,7 @@ void pyGameScore::FindPlayerScores(const plString& name, pyKey& rcvr) { uint32_t ownerId = node->GetNodeId(); pfGameScore::Find(ownerId, name, rcvr.getKey()); - node->DecRef(); + node->UnRef(); } else hsAssert(false, "No PlayerInfo node.. Need to rewrite python script?"); diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp index 0beff194..acc7d5ca 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp @@ -84,9 +84,9 @@ static PyObject * GetFolder (unsigned folderType) { if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) { if (RelVaultNode * rvnFldr = rvnPlr->GetChildFolderNodeIncRef(folderType, 1)) { result = pyVaultFolderNode::New(rvnFldr); - rvnFldr->DecRef(); + rvnFldr->UnRef(); } - rvnPlr->DecRef(); + rvnPlr->UnRef(); } return result; @@ -98,9 +98,9 @@ static PyObject * GetPlayerInfoList (unsigned folderType) { if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) { if (RelVaultNode * rvnFldr = rvnPlr->GetChildPlayerInfoListNodeIncRef(folderType, 1)) { result = pyVaultPlayerInfoListNode::New(rvnFldr); - rvnFldr->DecRef(); + rvnFldr->UnRef(); } - rvnPlr->DecRef(); + rvnPlr->UnRef(); } return result; @@ -112,9 +112,9 @@ static PyObject * GetAgeInfoList (unsigned folderType) { if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) { if (RelVaultNode * rvnFldr = rvnPlr->GetChildAgeInfoListNodeIncRef(folderType, 1)) { result = pyVaultAgeInfoListNode::New(rvnFldr); - rvnFldr->DecRef(); + rvnFldr->UnRef(); } - rvnPlr->DecRef(); + rvnPlr->UnRef(); } return result; @@ -127,9 +127,9 @@ PyObject* pyVault::GetPlayerInfo() if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) { if (RelVaultNode * rvnPlrInfo = rvnPlr->GetChildNodeIncRef(plVault::kNodeType_PlayerInfo, 1)) { result = pyVaultPlayerInfoNode::New(rvnPlrInfo); - rvnPlrInfo->DecRef(); + rvnPlrInfo->UnRef(); } - rvnPlr->DecRef(); + rvnPlr->UnRef(); } // just return an empty node @@ -231,13 +231,13 @@ PyObject* pyVault::GetKIUsage(void) ++notes; else if (rvn->GetNodeType() == plVault::kNodeType_MarkerGame) ++markerGames; - rvn->DecRef(); + rvn->UnRef(); } - rvnAgeJrnlz->DecRef(); + rvnAgeJrnlz->UnRef(); break; } - rvnPlr->DecRef(); + rvnPlr->UnRef(); break; } @@ -305,7 +305,7 @@ PyObject* pyVault::GetLinkToMyNeighborhood() const if (RelVaultNode * rvn = VaultGetOwnedAgeLinkIncRef(&info)) { PyObject * result = pyVaultAgeLinkNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -319,7 +319,7 @@ PyObject* pyVault::GetLinkToCity() const if (RelVaultNode * rvn = VaultGetOwnedAgeLinkIncRef(&info)) { PyObject * result = pyVaultAgeLinkNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -332,7 +332,7 @@ PyObject* pyVault::GetOwnedAgeLink( const pyAgeInfoStruct & info ) { if (RelVaultNode * rvnLink = VaultGetOwnedAgeLinkIncRef(info.GetAgeInfo())) { PyObject * result = pyVaultAgeLinkNode::New(rvnLink); - rvnLink->DecRef(); + rvnLink->UnRef(); return result; } @@ -345,7 +345,7 @@ PyObject* pyVault::GetVisitAgeLink( const pyAgeInfoStruct & info) { if (RelVaultNode * rvnLink = VaultGetVisitAgeLinkIncRef(info.GetAgeInfo())) { PyObject * result = pyVaultAgeLinkNode::New(rvnLink); - rvnLink->DecRef(); + rvnLink->UnRef(); return result; } @@ -363,7 +363,7 @@ PyObject* pyVault::FindChronicleEntry( const char * entryName ) if (RelVaultNode * rvn = VaultFindChronicleEntryIncRef(wEntryName)) { PyObject * result = pyVaultChronicleNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -442,7 +442,7 @@ PyObject* pyVault::GetPsnlAgeSDL() const { PyObject * result = nil; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); if (RelVaultNode * rvnFldr = VaultGetAgesIOwnFolderIncRef()) { @@ -465,14 +465,14 @@ PyObject* pyVault::GetPsnlAgeSDL() const result = pySDLStateDataRecord::New(rec); else delete rec; - rvnSdl->DecRef(); + rvnSdl->UnRef(); } - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - rvnFldr->DecRef(); + rvnFldr->UnRef(); } - templateNode->DecRef(); + templateNode->UnRef(); if (!result) PYTHON_RETURN_NONE; @@ -487,7 +487,7 @@ void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec ) return; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); if (RelVaultNode * rvnFldr = VaultGetAgesIOwnFolderIncRef()) { @@ -506,14 +506,14 @@ void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec ) if (RelVaultNode * rvnSdl = rvnInfo->GetChildNodeIncRef(templateNode, 1)) { VaultSDLNode sdl(rvnSdl); sdl.SetStateDataRecord(rec, plSDL::kDirtyOnly | plSDL::kTimeStampOnRead); - rvnSdl->DecRef(); + rvnSdl->UnRef(); } - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - rvnFldr->DecRef(); + rvnFldr->UnRef(); } - templateNode->DecRef(); + templateNode->UnRef(); } bool pyVault::InMyPersonalAge() const @@ -600,13 +600,13 @@ void _InvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode void pyVault::InvitePlayerToAge( const pyAgeLinkStruct & link, uint32_t playerID ) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); 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->DecRef(); + templateNode->UnRef(); } //============================================================================ @@ -626,20 +626,20 @@ void pyVault::UnInvitePlayerToAge( const char * str, uint32_t playerID ) if (RelVaultNode * rvnInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode ageInfo(rvnInfo); ageInfo.CopyTo(&info); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - rvnLink->DecRef(); + rvnLink->UnRef(); } NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_TextNote); VaultTextNoteNode visitAcc(templateNode); visitAcc.SetNoteType(plVault::kNoteType_UnVisit); visitAcc.SetVisitInfo(info); VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_UninvitePlayerToAge, nil, (void*)playerID); - templateNode->DecRef(); + templateNode->UnRef(); } //============================================================================ @@ -699,7 +699,7 @@ PyObject* pyVault::GetGlobalInbox() PyObject * result = nil; if (RelVaultNode * rvnGlobalInbox = VaultGetGlobalInboxIncRef()) { result = pyVaultFolderNode::New(rvnGlobalInbox); - rvnGlobalInbox->DecRef(); + rvnGlobalInbox->UnRef(); return result; } @@ -714,7 +714,7 @@ 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->DecRef(); + rvn->UnRef(); return result; } @@ -728,7 +728,7 @@ PyObject* pyVault::FindNode( pyVaultNode* templateNode ) const // 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->DecRef(); + rvn->UnRef(); return result; } } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoListNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoListNodeGlue.cpp index e3eba888..0cbce75e 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoListNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoListNodeGlue.cpp @@ -112,10 +112,10 @@ PyObject *pyVaultAgeInfoListNode::New(RelVaultNode* nfsNode) { ptVaultAgeInfoListNode *newObj = (ptVaultAgeInfoListNode*)ptVaultAgeInfoListNode_type.tp_new(&ptVaultAgeInfoListNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp index 0ba97e9e..e3b720b2 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp @@ -80,7 +80,7 @@ static PyObject * GetChildFolder (RelVaultNode * node, unsigned type) { PyObject * result = nil; if (RelVaultNode * rvn = node->GetChildFolderNodeIncRef(type, 1)) { result = pyVaultFolderNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); } return result; } @@ -91,7 +91,7 @@ static PyObject * GetChildPlayerInfoList (RelVaultNode * node, unsigned type) { PyObject * result = nil; if (RelVaultNode * rvn = node->GetChildPlayerInfoListNodeIncRef(type, 1)) { result = pyVaultPlayerInfoListNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); } return result; } @@ -101,7 +101,7 @@ static PyObject * GetChildAgeInfoList (RelVaultNode * node, unsigned type) { PyObject * result = nil; if (RelVaultNode * rvn = node->GetChildAgeInfoListNodeIncRef(type, 1)) { result = pyVaultAgeInfoListNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); } return result; } @@ -175,7 +175,7 @@ PyObject * pyVaultAgeInfoNode::GetParentAgeLink () const if (RelVaultNode * rvn = fNode->GetParentAgeLinkIncRef()) { PyObject * result = pyVaultAgeLinkNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp index bd8b0657..6bc593b5 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp @@ -288,10 +288,10 @@ PyObject *pyVaultAgeInfoNode::New(RelVaultNode* nfsNode) { ptVaultAgeInfoNode *newObj = (ptVaultAgeInfoNode*)ptVaultAgeInfoNode_type.tp_new(&ptVaultAgeInfoNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp index ab7f4013..2aa644aa 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp @@ -84,7 +84,7 @@ PyObject* pyVaultAgeLinkNode::GetAgeInfo() const PyObject * result = nil; if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { result = pyVaultAgeInfoNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); } if (result) diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNodeGlue.cpp index 51b1ded0..ded4fb41 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNodeGlue.cpp @@ -201,10 +201,10 @@ PyObject *pyVaultAgeLinkNode::New(RelVaultNode* nfsNode) { ptVaultAgeLinkNode *newObj = (ptVaultAgeLinkNode*)ptVaultAgeLinkNode_type.tp_new(&ptVaultAgeLinkNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp index 77de95dd..619a1e88 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp @@ -191,10 +191,10 @@ PyObject *pyVaultChronicleNode::New(RelVaultNode* nfsNode) { ptVaultChronicleNode *newObj = (ptVaultChronicleNode*)ptVaultChronicleNode_type.tp_new(&ptVaultChronicleNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNodeGlue.cpp index 8dabbdfd..928cc3a5 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNodeGlue.cpp @@ -192,10 +192,10 @@ PyObject *pyVaultFolderNode::New(RelVaultNode* nfsNode) { ptVaultFolderNode *newObj = (ptVaultFolderNode*)ptVaultFolderNode_type.tp_new(&ptVaultFolderNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNodeGlue.cpp index ca1e387b..9dba5ab2 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNodeGlue.cpp @@ -220,10 +220,10 @@ PyObject *pyVaultImageNode::New(RelVaultNode* nfsNode) { ptVaultImageNode *newObj = (ptVaultImageNode*)ptVaultImageNode_type.tp_new(&ptVaultImageNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp index 1edaa5f2..b3a4fec9 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp @@ -115,10 +115,10 @@ PyObject *pyVaultMarkerGameNode::New(RelVaultNode* nfsNode) { ptVaultMarkerGameNode *newObj = (ptVaultMarkerGameNode*)ptVaultMarkerGameNode_type.tp_new(&ptVaultMarkerGameNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp index 07312dfa..55da934d 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp @@ -159,10 +159,10 @@ void pyVaultNode::pyVaultNodeOperationCallback::VaultOperationComplete( uint32_t void pyVaultNode::pyVaultNodeOperationCallback::SetNode (RelVaultNode * rvn) { if (rvn) - rvn->IncRef(); + rvn->Ref(); SWAP(rvn, fNode); if (rvn) - rvn->DecRef(); + rvn->UnRef(); } RelVaultNode * pyVaultNode::pyVaultNodeOperationCallback::GetNode () { @@ -182,13 +182,13 @@ pyVaultNode::pyVaultNode( RelVaultNode* nfsNode ) , fCreateAgeName(nil) { if (fNode) - fNode->IncRef("pyVaultNode"); + fNode->Ref("pyVaultNode"); } pyVaultNode::~pyVaultNode() { if (fNode) - fNode->DecRef("pyVaultNode"); + fNode->UnRef("pyVaultNode"); free(fCreateAgeName); } @@ -271,16 +271,16 @@ PyObject* pyVaultNode::GetCreatorNode( void ) if (fNode) { RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode plrInfo(templateNode); plrInfo.SetPlayerId(fNode->GetCreatorId()); if (RelVaultNode * rvn = VaultGetNodeIncRef(templateNode)) { result = pyVaultPlayerInfoNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); } - templateNode->DecRef(); + templateNode->UnRef(); } if (result) @@ -423,8 +423,8 @@ PyObject* pyVaultNode::AddNode(pyVaultNode* pynode, PyObject* cbObject, uint32_t ); if (newNode) { - newNode->IncRef(); - pynode->fNode->DecRef(); + newNode->Ref(); + pynode->fNode->UnRef(); pynode->fNode = newNode; } else { @@ -471,7 +471,7 @@ void pyVaultNode::LinkToNode(int nodeID, PyObject* cbObject, uint32_t cbContext) if (RelVaultNode * rvn = VaultGetNodeIncRef(nodeID)) { cb->SetNode(rvn); cb->fPyNodeRef = pyVaultNodeRef::New(fNode, rvn); - rvn->DecRef(); + rvn->UnRef(); } VaultAddChildNode(fNode->GetNodeId(), @@ -536,7 +536,7 @@ void pyVaultNode::Save(PyObject* cbObject, uint32_t cbContext) if (!fNode->GetNodeId() && fNode->GetNodeType()) { ENetError result; if (RelVaultNode * node = VaultCreateNodeAndWaitIncRef(fNode, &result)) { - fNode->DecRef(); + fNode->UnRef(); fNode = node; } } @@ -560,7 +560,7 @@ void pyVaultNode::ForceSave() if (!fNode->GetNodeId() && fNode->GetNodeType()) { ENetError result; if (RelVaultNode * node = VaultCreateNodeAndWaitIncRef(fNode, &result)) { - fNode->DecRef(); + fNode->UnRef(); fNode = node; } } @@ -579,7 +579,7 @@ void pyVaultNode::SendTo(uint32_t destClientNodeID, PyObject* cbObject, uint32_t if (!fNode->GetNodeId() && fNode->GetNodeType()) { ENetError result; if (RelVaultNode * node = VaultCreateNodeAndWaitIncRef(fNode, &result)) { - fNode->DecRef(); + fNode->UnRef(); fNode = node; } } @@ -618,7 +618,7 @@ PyObject* pyVaultNode::GetChildNodeRefList() PyObject* elementObj = pyVaultNodeRef::New(fNode, nodes[i]); PyList_Append(pyEL, elementObj); Py_DECREF(elementObj); - nodes[i]->DecRef(); + nodes[i]->UnRef(); } } @@ -657,13 +657,13 @@ PyObject * pyVaultNode::GetNode2( uint32_t nodeID ) const if ( fNode ) { RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeId(nodeID); if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1)) { result = pyVaultNodeRef::New(fNode, rvn); - rvn->DecRef(); + rvn->UnRef(); } - templateNode->DecRef(); + templateNode->UnRef(); } if (result) @@ -679,7 +679,7 @@ PyObject* pyVaultNode::FindNode( pyVaultNode * templateNode ) { if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode->fNode, 1)) { result = pyVaultNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); } } @@ -695,14 +695,14 @@ PyObject * pyVaultNode::GetChildNode (unsigned nodeId) { PYTHON_RETURN_NONE; RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeId(nodeId); RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1); - templateNode->DecRef(); + templateNode->UnRef(); if (rvn) { PyObject * result = pyVaultNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeGlue.cpp index 0a417448..0d51b411 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeGlue.cpp @@ -542,10 +542,10 @@ PyObject *pyVaultNode::New(RelVaultNode* nfsNode) { ptVaultNode *newObj = (ptVaultNode*)ptVaultNode_type.tp_new(&ptVaultNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRef.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRef.cpp index a210d4c0..5af48f67 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRef.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRef.cpp @@ -65,8 +65,8 @@ pyVaultNodeRef::pyVaultNodeRef(RelVaultNode * parent, RelVaultNode * child) : fParent(parent) , fChild(child) { - fParent->IncRef(); - fChild->IncRef(); + fParent->Ref(); + fChild->Ref(); } pyVaultNodeRef::pyVaultNodeRef(int) @@ -78,9 +78,9 @@ pyVaultNodeRef::pyVaultNodeRef(int) pyVaultNodeRef::~pyVaultNodeRef() { if (fParent) - fParent->DecRef(); + fParent->UnRef(); if (fChild) - fChild->DecRef(); + fChild->UnRef(); } @@ -115,7 +115,7 @@ unsigned pyVaultNodeRef::GetSaverID () { unsigned saverId = 0; if (RelVaultNode * child = VaultGetNodeIncRef(fChild->GetNodeId())) { saverId = child->GetRefOwnerId(fParent->GetNodeId()); - child->DecRef(); + child->UnRef(); } return saverId; } @@ -129,7 +129,7 @@ PyObject * pyVaultNodeRef::GetSaver () { if (unsigned saverId = child->GetRefOwnerId(fParent->GetNodeId())) { // Find the player info node representing the saver NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode access(templateNode); access.SetPlayerId(saverId); @@ -144,15 +144,15 @@ PyObject * pyVaultNodeRef::GetSaver () { } } - templateNode->DecRef(); + templateNode->UnRef(); } - child->DecRef(); + child->UnRef(); } if (!saver) PYTHON_RETURN_NONE; PyObject * result = pyVaultPlayerInfoNode::New(saver); - saver->DecRef(); + saver->UnRef(); return result; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRefGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRefGlue.cpp index ad1350d4..235149a4 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRefGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultNodeRefGlue.cpp @@ -126,15 +126,15 @@ 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->DecRef(); + newObj->fThis->fParent->UnRef(); if (newObj->fThis->fChild) - newObj->fThis->fChild->DecRef(); + newObj->fThis->fChild->UnRef(); newObj->fThis->fParent = parent; newObj->fThis->fChild = child; if (newObj->fThis->fParent) - newObj->fThis->fParent->IncRef(); + newObj->fThis->fParent->Ref(); if (newObj->fThis->fChild) - newObj->fThis->fChild->IncRef(); + newObj->fThis->fChild->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp index 8dd6b500..378289da 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp @@ -80,16 +80,16 @@ bool pyVaultPlayerInfoListNode::HasPlayer( uint32_t playerID ) return false; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode access(templateNode); access.SetPlayerId(playerID); RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1); if (rvn) - rvn->DecRef(); + rvn->UnRef(); - templateNode->DecRef(); + templateNode->UnRef(); return (rvn != nil); } @@ -100,7 +100,7 @@ static void IAddPlayer_NodesFound(ENetError result, void* param, unsigned nodeId NetVaultNode* parent = static_cast(param); if (nodeIdCount) VaultAddChildNode(parent->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr); - parent->DecRef(); + parent->UnRef(); } void pyVaultPlayerInfoListNode::AddPlayer( uint32_t playerID ) @@ -109,7 +109,7 @@ void pyVaultPlayerInfoListNode::AddPlayer( uint32_t playerID ) return; NetVaultNode* templateNode = new NetVaultNode(); - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode access(templateNode); access.SetPlayerId(playerID); @@ -121,7 +121,7 @@ void pyVaultPlayerInfoListNode::AddPlayer( uint32_t playerID ) if (nodeIds.Count()) VaultAddChildNode(fNode->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr); else { - fNode->IncRef(); + fNode->Ref(); VaultFindNodes(templateNode, IAddPlayer_NodesFound, fNode); } } @@ -132,17 +132,17 @@ void pyVaultPlayerInfoListNode::RemovePlayer( uint32_t playerID ) return; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode access(templateNode); access.SetPlayerId(playerID); if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1)) { VaultRemoveChildNode(fNode->GetNodeId(), rvn->GetNodeId(), nil, nil); - rvn->DecRef(); + rvn->UnRef(); } - templateNode->DecRef(); + templateNode->UnRef(); } PyObject * pyVaultPlayerInfoListNode::GetPlayer( uint32_t playerID ) @@ -151,7 +151,7 @@ PyObject * pyVaultPlayerInfoListNode::GetPlayer( uint32_t playerID ) PYTHON_RETURN_NONE; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode access(templateNode); access.SetPlayerId(playerID); @@ -159,10 +159,10 @@ PyObject * pyVaultPlayerInfoListNode::GetPlayer( uint32_t playerID ) PyObject * result = nil; if (RelVaultNode * rvn = fNode->GetChildNodeIncRef(templateNode, 1)) { result = pyVaultPlayerInfoNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); } - templateNode->DecRef(); + templateNode->UnRef(); if (!result) PYTHON_RETURN_NONE; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNodeGlue.cpp index d693b7e8..906bcb01 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNodeGlue.cpp @@ -180,10 +180,10 @@ PyObject *pyVaultPlayerInfoListNode::New(RelVaultNode* nfsNode) { ptVaultPlayerInfoListNode *newObj = (ptVaultPlayerInfoListNode*)ptVaultPlayerInfoListNode_type.tp_new(&ptVaultPlayerInfoListNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp index 8238a18b..720a24f5 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp @@ -172,10 +172,10 @@ PyObject *pyVaultPlayerInfoNode::New(RelVaultNode* nfsNode) { ptVaultPlayerInfoNode *newObj = (ptVaultPlayerInfoNode*)ptVaultPlayerInfoNode_type.tp_new(&ptVaultPlayerInfoNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp index 7c277500..1c98bc9f 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp @@ -68,9 +68,9 @@ static PyObject * GetPlayerVaultFolder (unsigned folderType) { if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) { if (RelVaultNode * rvnFldr = rvnPlr->GetChildFolderNodeIncRef(folderType, 1)) { result = pyVaultFolderNode::New(rvnFldr); - rvnFldr->DecRef(); + rvnFldr->UnRef(); } - rvnPlr->DecRef(); + rvnPlr->UnRef(); } return result; @@ -174,7 +174,7 @@ PyObject *pyVaultPlayerNode::GetPlayerInfo() { if (RelVaultNode * rvn = VaultGetPlayerInfoNodeIncRef()) { PyObject * result = pyVaultPlayerInfoNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -223,7 +223,7 @@ PyObject *pyVaultPlayerNode::GetVisitAgeLink(const pyAgeInfoStruct *info) { if (RelVaultNode * rvn = VaultGetVisitAgeLinkIncRef(info->GetAgeInfo())) { PyObject * result = pyVaultAgeLinkNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } @@ -244,7 +244,7 @@ PyObject *pyVaultPlayerNode::FindChronicleEntry(const char *entryName) StrToUnicode(wStr, entryName, arrsize(wStr)); if (RelVaultNode * rvn = VaultFindChronicleEntryIncRef(wStr)) { PyObject * result = pyVaultChronicleNode::New(rvn); - rvn->DecRef(); + rvn->UnRef(); return result; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNodeGlue.cpp index a8b0df59..78698d94 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNodeGlue.cpp @@ -322,10 +322,10 @@ PyObject *pyVaultPlayerNode::New(RelVaultNode* nfsNode) { ptVaultPlayerNode *newObj = (ptVaultPlayerNode*)ptVaultPlayerNode_type.tp_new(&ptVaultPlayerNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultSDLNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultSDLNodeGlue.cpp index 56abdf1e..d049be2c 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultSDLNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultSDLNodeGlue.cpp @@ -130,10 +130,10 @@ PyObject *pyVaultSDLNode::New(RelVaultNode* nfsNode) { ptVaultSDLNode *newObj = (ptVaultSDLNode*)ptVaultSDLNode_type.tp_new(&ptVaultSDLNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultSystemNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultSystemNodeGlue.cpp index 9a1f8b4b..70dac4d9 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultSystemNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultSystemNodeGlue.cpp @@ -71,10 +71,10 @@ PyObject *pyVaultSystemNode::New(RelVaultNode* nfsNode) { ptVaultSystemNode *newObj = (ptVaultSystemNode*)ptVaultSystemNode_type.tp_new(&ptVaultSystemNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp index aa679a3a..e90af2da 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp @@ -230,7 +230,7 @@ void pyVaultTextNoteNode::SetDeviceInbox( const char * devName, PyObject * cbObj if (RelVaultNode * rvn = VaultAgeSetDeviceInboxAndWaitIncRef(wDev, DEFAULT_DEVICE_INBOX)) { cb->SetNode(rvn); - rvn->DecRef(); + rvn->UnRef(); } cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here. diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNodeGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNodeGlue.cpp index ca63bbac..2d89dc54 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNodeGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNodeGlue.cpp @@ -319,10 +319,10 @@ PyObject *pyVaultTextNoteNode::New(RelVaultNode* nfsNode) { ptVaultTextNoteNode *newObj = (ptVaultTextNoteNode*)ptVaultTextNoteNode_type.tp_new(&ptVaultTextNoteNode_type, NULL, NULL); if (newObj->fThis->fNode) - newObj->fThis->fNode->DecRef(); + newObj->fThis->fNode->UnRef(); newObj->fThis->fNode = nfsNode; if (newObj->fThis->fNode) - newObj->fThis->fNode->IncRef(); + newObj->fThis->fNode->Ref(); return (PyObject*)newObj; } diff --git a/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp b/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp index 37c468a7..058b3e53 100644 --- a/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp +++ b/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp @@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "Pch.h" #include "hsThread.h" #include +#include "hsRefCnt.h" #pragma hdrstop @@ -72,7 +73,7 @@ private: hsMutex m_critsect; }; -struct NetMsgChannel : AtomicRef { +struct NetMsgChannel : hsAtomicRefCnt { uint32_t m_protocol; bool m_server; @@ -109,7 +110,7 @@ ChannelCrit::~ChannelCrit () { while (s_channels->size()) { NetMsgChannel* const channel = s_channels->front(); s_channels->remove(channel); - channel->DecRef("ChannelLink"); + channel->UnRef("ChannelLink"); } delete s_channels; @@ -275,7 +276,7 @@ static NetMsgChannel* FindOrCreateChannel_CS (uint32_t protocol, bool server) { channel->m_largestRecv = 0; s_channels->push_back(channel); - channel->IncRef("ChannelLink"); + channel->Ref("ChannelLink"); } return channel; @@ -298,7 +299,7 @@ NetMsgChannel * NetMsgChannelLock ( s_channelCrit.Enter(); if (nil != (channel = FindChannel_CS(protocol, server))) { *largestRecv = channel->m_largestRecv; - channel->IncRef("ChannelLock"); + channel->Ref("ChannelLock"); } else { *largestRecv = 0; @@ -313,7 +314,7 @@ void NetMsgChannelUnlock ( ) { s_channelCrit.Enter(); { - channel->DecRef("ChannelLock"); + channel->UnRef("ChannelLock"); } s_channelCrit.Leave(); } @@ -392,7 +393,7 @@ void NetMsgProtocolRegister ( // make sure no connections have been established on this protocol, otherwise // we'll be modifying a live data structure; NetCli's don't lock their protocol // to operate on it once they have linked to it! - ASSERT(channel->GetRefCount() == 1); + ASSERT(channel->RefCnt() == 1); channel->m_dh_g = dh_g; channel->m_dh_xa = dh_xa; @@ -411,7 +412,7 @@ void NetMsgProtocolDestroy (uint32_t protocol, bool server) { s_channelCrit.EnterSafe(); if (NetMsgChannel* channel = FindChannel_CS(protocol, server)) { s_channels->remove(channel); - channel->DecRef("ChannelLink"); + channel->UnRef("ChannelLink"); } s_channelCrit.LeaveSafe(); } diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h index 870481b6..14d452a7 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h @@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETPROTOCOL_PRIVATE_PNNPCOMMON_H #include "pnUUID/pnUUID.h" +#include "hsRefCnt.h" /***************************************************************************** @@ -156,7 +157,7 @@ struct NetGameRank { // NetVaultNode //============================================================================ // Threaded apps: App is responsible for locking node->critsect before accessing *any* field in this struct -struct NetVaultNode : AtomicRef { +struct NetVaultNode : hsAtomicRefCnt { enum RwOptions { kRwDirtyOnly = 1<<0, // READ : No meaning // WRITE: Only write fields marked dirty diff --git a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt index 87603e88..c7ba9c57 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt +++ b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt @@ -14,7 +14,6 @@ set(pnUtils_HEADERS pnUtMisc.h pnUtPragma.h pnUtPriQ.h - pnUtRef.h pnUtSort.h pnUtStr.h pnUtTime.h diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h index b0e2fc9c..ebc16979 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h @@ -58,7 +58,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnUtPriQ.h" #include "pnUtTime.h" #include "pnUtStr.h" -#include "pnUtRef.h" #include "pnUtCmd.h" #include "pnUtMisc.h" #include "pnUtCrypt.h" diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtRef.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtRef.h deleted file mode 100644 index 5b1f50f3..00000000 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtRef.h +++ /dev/null @@ -1,180 +0,0 @@ -/*==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Additional permissions under GNU GPL version 3 section 7 - -If you modify this Program, or any covered work, by linking or -combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, -NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent -JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK -(or a modified version of those libraries), -containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, -PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG -JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the -licensors of this Program grant you additional -permission to convey the resulting work. Corresponding Source for a -non-source form of such a combination shall include the source code for -the parts of OpenSSL and IJG JPEG Library used as well as that of the covered -work. - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -/***************************************************************************** -* -* $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtRef.h -* -***/ - -#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTREF_H -#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTREF_H - - -/**************************************************************************** -* -* AtomicRef -* Thread safe reference count -* -***/ - -class AtomicRef { -#ifdef HS_DEBUGGING - bool zeroed; -#endif -public: - inline AtomicRef () - : m_ref(0) - #ifdef HS_DEBUGGING - , zeroed(false) - #endif - {} - - inline void AcknowledgeZeroRef () { - #ifdef HS_DEBUGGING - zeroed = false; - #endif - } - - inline long IncRef () { - #ifdef HS_DEBUGGING - ASSERT(!zeroed); - #endif - long prev = AtomicAdd(&m_ref, 1); - #ifdef REFCOUNT_DEBUGGING - DEBUG_MSG("Inc %p: %u", this, prev+1); - #endif - return prev+1; - } - inline long IncRef (const char tag[]) { - #ifdef HS_DEBUGGING - ASSERT(!zeroed); - #endif - long prev = AtomicAdd(&m_ref, 1); - #ifdef REFCOUNT_DEBUGGING - DEBUG_MSG("Inc %p %s: %u", this, tag, prev+1); - #endif - return prev+1; - } - inline long IncRef (unsigned n) { - #ifdef HS_DEBUGGING - ASSERT(!zeroed); - #endif - long prev = AtomicAdd(&m_ref, n); - #ifdef REFCOUNT_DEBUGGING - DEBUG_MSG("Inc %p: %u", this, prev+n); - #endif - return prev+n; - } - inline long IncRef (unsigned n, const char tag[]) { - #ifdef HS_DEBUGGING - ASSERT(!zeroed); - #endif - long prev = AtomicAdd(&m_ref, n); - #ifdef REFCOUNT_DEBUGGING - DEBUG_MSG("Inc %p %s: %u", this, tag, prev+n); - #endif - return prev+n; - } - - inline long DecRef () { - #ifdef HS_DEBUGGING - ASSERT(!zeroed); - #endif - long prev; - if ((prev = AtomicAdd(&m_ref, -1)) == 1) { - #ifdef HS_DEBUGGING - zeroed = true; - #endif - OnZeroRef(); - } - #ifdef REFCOUNT_DEBUGGING - DEBUG_MSG("Dec %p: %u", this, prev-1); - #endif - return prev-1; - } - inline long DecRef (const char tag[]) { - #ifdef HS_DEBUGGING - ASSERT(!zeroed); - #endif - long prev; - if ((prev = AtomicAdd(&m_ref, -1)) == 1) { - #ifdef HS_DEBUGGING - zeroed = true; - #endif - OnZeroRef(); - } - #ifdef REFCOUNT_DEBUGGING - DEBUG_MSG("Dec %p %s: %u", this, tag, prev-1); - #endif - return prev-1; - } - - inline void TransferRef ( - const char oldTag[], - const char newTag[] - ) { - #ifdef HS_DEBUGGING - ASSERT(!zeroed); - #endif - #ifdef REFCOUNT_DEBUGGING - DEBUG_MSG("Inc %p %s: (xfer)", this, newTag); - DEBUG_MSG("Dec %p %s: (xfer)", this, oldTag); - #endif - } - - inline unsigned GetRefCount () { - return m_ref; - } - - inline virtual void OnZeroRef () { - delete this; - } - -protected: - inline virtual ~AtomicRef () { - ASSERT(!m_ref); - } - -private: - long m_ref; -}; -#endif diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp index f55ab3e8..ca9c203b 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp @@ -831,13 +831,13 @@ bool plClothingOutfit::IReadFromVault() delete sdlDataRec; } } - nodes[i]->DecRef(); + nodes[i]->UnRef(); } fSynchClients = true; // set true if the next synch should be bcast ForceUpdate(true); - rvn->DecRef(); + rvn->UnRef(); return true; } @@ -874,7 +874,7 @@ void plClothingOutfit::WriteToVault() SDRs.Add(appearanceStateDesc->GetStateDataRecord(0)); WriteToVault(SDRs); - rvn->DecRef(); + rvn->UnRef(); } void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs) @@ -926,28 +926,28 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs) if (nodes.Count()) { node = nodes[0]; nodes.DeleteUnordered(0); - node->IncRef(); // REF: Work - node->DecRef(); // REF: Find + node->Ref(); // REF: Work + node->UnRef(); // REF: Find } else { RelVaultNode * templateNode = new RelVaultNode; templateNode->SetNodeType(plVault::kNodeType_SDL); templates.Add(templateNode); node = templateNode; - node->IncRef(); // REF: Create - node->IncRef(); // REF: Work + node->Ref(); // REF: Create + node->Ref(); // REF: Work } VaultSDLNode sdl(node); sdl.SetStateDataRecord((*arr)[i], 0); - node->DecRef(); // REF: Work + node->UnRef(); // REF: Work } } // Delete any leftover nodes for (unsigned i = 0; i < nodes.Count(); ++i) { VaultDeleteNode(nodes[i]->GetNodeId()); - nodes[i]->DecRef(); // REF: Array + nodes[i]->UnRef(); // REF: Array } // Create actual new nodes from their templates @@ -956,13 +956,13 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs) if (RelVaultNode * actual = VaultCreateNodeAndWaitIncRef(templates[i], &result)) { actuals.Add(actual); } - templates[i]->DecRef(); // REF: Create + templates[i]->UnRef(); // REF: Create } // Add new nodes to outfit folder for (unsigned i = 0; i < actuals.Count(); ++i) { VaultAddChildNodeAndWait(rvn->GetNodeId(), actuals[i]->GetNodeId(), NetCommGetPlayer()->playerInt); - actuals[i]->DecRef(); // REF: Create + actuals[i]->UnRef(); // REF: Create } // Cleanup morph SDRs @@ -970,7 +970,7 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs) delete morphs[i]; } - rvn->DecRef(); + rvn->UnRef(); } // XXX HACK. DON'T USE (this function exists for the temp console command Clothing.SwapClothTexHACK) @@ -1489,7 +1489,7 @@ bool plClothingOutfit::WriteToFile(const plFileName &filename) hsUNIXStream S; if (!S.Open(filename, "wb")) { - rvn->DecRef(); + rvn->UnRef(); return false; } @@ -1503,9 +1503,9 @@ bool plClothingOutfit::WriteToFile(const plFileName &filename) S.WriteLE32(sdl.GetSDLDataLength()); if (sdl.GetSDLDataLength()) S.Write(sdl.GetSDLDataLength(), sdl.GetSDLData()); - nodes[i]->DecRef(); + nodes[i]->UnRef(); } - rvn->DecRef(); + rvn->UnRef(); S.Close(); return true; @@ -1652,7 +1652,7 @@ void plClothingMgr::AddItemsToCloset(hsTArray &items) plClothingSDLModifier::PutSingleItemIntoSDR(&items[i], &rec); RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_SDL); VaultSDLNode sdl(templateNode); @@ -1669,12 +1669,12 @@ void plClothingMgr::AddItemsToCloset(hsTArray &items) actual->GetNodeId(), NetCommGetPlayer()->playerInt ); - actual->DecRef(); // REF: Create + actual->UnRef(); // REF: Create } - templates[i]->DecRef(); // REF: Create + templates[i]->UnRef(); // REF: Create } - rvn->DecRef(); + rvn->UnRef(); } void plClothingMgr::GetClosetItems(hsTArray &out) @@ -1702,7 +1702,7 @@ void plClothingMgr::GetClosetItems(hsTArray &out) } } - rvn->DecRef(); + rvn->UnRef(); } void plClothingMgr::GetAllWithSameMesh(plClothingItem *item, hsTArray &out) diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp index 37f4e8f9..563c3a66 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp @@ -865,7 +865,7 @@ void plSceneInputInterface::ILinkOffereeToAge() VaultRegisterOwnedAgeAndWait(&link); } } - linkNode->DecRef(); + linkNode->UnRef(); } if (!fSpawnPoint.IsEmpty()) { diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp index d454f454..ca70d4b2 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp @@ -535,14 +535,14 @@ bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg) { VaultAgeInfoNode accInfo(rvnInfo); accInfo.CopyTo(cur->GetAgeInfo()); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } IDoLink(fDeferredLink); fDeferredLink = nil; return true; - cVaultLink->DecRef(); + cVaultLink->UnRef(); } return false; @@ -786,7 +786,7 @@ void plNetLinkingMgr::IPostProcessLink( void ) accInfo.SetAgeInstName(ageInstName); accInfo.SetAgeInstUuid(ageInstGuid); accInfo.SetOnline(true); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } switch (link->GetLinkingRules()) { @@ -811,9 +811,9 @@ void plNetLinkingMgr::IPostProcessLink( void ) ); if (fldr) - fldr->DecRef(); + fldr->UnRef(); if (info) - info->DecRef(); + info->UnRef(); } } break; @@ -838,9 +838,9 @@ void plNetLinkingMgr::IPostProcessLink( void ) ); if (fldr) - fldr->DecRef(); + fldr->UnRef(); if (info) - info->DecRef(); + info->UnRef(); } } break; @@ -878,7 +878,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void) accInfo.SetAgeInstName(nil); accInfo.SetAgeInstUuid(kNilUuid); accInfo.SetOnline(false); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } #else // Update our online status @@ -890,7 +890,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void) accInfo.SetAgeInstName(ageInstName); accInfo.SetAgeInstUuid(ageInstGuid); accInfo.SetOnline(true); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } #endif @@ -1035,7 +1035,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void) break; } } - linkNode->DecRef(); + linkNode->UnRef(); } } diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index 58094b1e..f89e2e98 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -278,7 +278,7 @@ static void PlayerInitCallback ( if (RelVaultNode * rvn = VaultGetOwnedAgeLinkIncRef(&info)) { VaultAgeLinkNode acc(rvn); acc.AddSpawnPoint(plSpawnPointInfo(kCityFerryTerminalLinkTitle, kCityFerryTerminalLinkSpawnPtName)); - rvn->DecRef(); + rvn->UnRef(); } VaultProcessPlayerInbox(); @@ -1126,7 +1126,7 @@ void NetCommSetActivePlayer (//--> plNetCommActivePlayerMsg pInfo.SetOnline(false); NetCliAuthVaultNodeSave(rvn, nil, nil); - rvn->DecRef(); + rvn->UnRef(); } VaultCull(s_player->playerInt); @@ -1324,7 +1324,7 @@ void NetCommSetCCRLevel ( if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) { VaultPlayerInfoNode pInfo(rvnInfo); pInfo.SetCCRLevel(ccrLevel); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } NetCliAuthSetCCRLevel(ccrLevel); diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h b/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h index 828ed6c5..363347a3 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h @@ -287,7 +287,7 @@ enum ENetTransState { kTransStateComplete, }; -struct NetTrans : AtomicRef { +struct NetTrans : hsAtomicRefCnt { LINK(NetTrans) m_link; ENetTransState m_state; ENetError m_result; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index 986a1530..ae0109eb 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -57,7 +57,7 @@ namespace Ngl { namespace Auth { * ***/ -struct CliAuConn : AtomicRef { +struct CliAuConn : hsAtomicRefCnt { CliAuConn (); ~CliAuConn (); @@ -1280,7 +1280,7 @@ static unsigned GetNonZeroTimeMs () { //============================================================================ static CliAuConn * GetConnIncRef_CS (const char tag[]) { if (CliAuConn * conn = s_active) { - conn->IncRef(tag); + conn->Ref(tag); return conn; } return nil; @@ -1312,7 +1312,7 @@ static void UnlinkAndAbandonConn_CS (CliAuConn * conn) { AsyncSocketDisconnect(conn->sock, true); } else { - conn->DecRef("Lifetime"); + conn->UnRef("Lifetime"); } } @@ -1369,7 +1369,7 @@ static void CheckedReconnect (CliAuConn * conn, ENetError error) { // Cancel all transactions in progress on this connection. NetTransCancelByConnId(conn->seq, kNetErrTimeout); // conn is dead. - conn->DecRef("Lifetime"); + conn->UnRef("Lifetime"); ReportNetError(kNetProtocolCli2Auth, error); } else { @@ -1405,7 +1405,7 @@ static void NotifyConnSocketConnectFailed (CliAuConn * conn) { CheckedReconnect(conn, kNetErrConnectFailed); - conn->DecRef("Connecting"); + conn->UnRef("Connecting"); } //============================================================================ @@ -1426,7 +1426,7 @@ static void NotifyConnSocketDisconnect (CliAuConn * conn) { CheckedReconnect(conn, kNetErrDisconnected); - conn->DecRef("Connected"); + conn->UnRef("Connected"); } //============================================================================ @@ -1540,7 +1540,7 @@ static void Connect ( conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout strncpy(conn->name, name, arrsize(conn->name)); - conn->IncRef("Lifetime"); + conn->Ref("Lifetime"); conn->AutoReconnect(); } @@ -1571,7 +1571,7 @@ static void AsyncLookupCallback ( //=========================================================================== static unsigned CliAuConnTimerDestroyed (void * param) { CliAuConn * conn = (CliAuConn *) param; - conn->DecRef("TimerDestroyed"); + conn->UnRef("TimerDestroyed"); return kAsyncTimeInfinite; } @@ -1617,7 +1617,7 @@ void CliAuConn::TimerReconnect () { s_critsect.Leave(); } else { - IncRef("Connecting"); + Ref("Connecting"); // Remember the time we started the reconnect attempt, guarding against // TimeGetMs() returning zero (unlikely), as a value of zero indicates @@ -1656,7 +1656,7 @@ void CliAuConn::StartAutoReconnect () { void CliAuConn::AutoReconnect () { ASSERT(!reconnectTimer); - IncRef("ReconnectTimer"); + Ref("ReconnectTimer"); critsect.Enter(); { AsyncTimerCreate( @@ -1690,7 +1690,7 @@ bool CliAuConn::AutoReconnectEnabled () { //============================================================================ void CliAuConn::AutoPing () { ASSERT(!pingTimer); - IncRef("PingTimer"); + Ref("PingTimer"); critsect.Enter(); { AsyncTimerCreate( @@ -3941,7 +3941,7 @@ void VaultFetchNodeTrans::Post () { m_node ); if (m_node) - m_node->DecRef("Recv"); + m_node->UnRef("Recv"); } //============================================================================ @@ -3954,7 +3954,7 @@ bool VaultFetchNodeTrans::Recv ( if (IS_NET_SUCCESS(reply.result)) { m_node = new NetVaultNode; m_node->Read_LCS(reply.nodeBuffer, reply.nodeBytes, 0); - m_node->IncRef("Recv"); + m_node->Ref("Recv"); } m_result = reply.result; @@ -3980,12 +3980,12 @@ VaultFindNodeTrans::VaultFindNodeTrans ( , m_param(param) , m_node(templateNode) { - m_node->IncRef(); + m_node->Ref(); } //============================================================================ VaultFindNodeTrans::~VaultFindNodeTrans () { - m_node->DecRef(); + m_node->UnRef(); } //============================================================================ @@ -4056,7 +4056,7 @@ VaultCreateNodeTrans::VaultCreateNodeTrans ( , m_param(param) , m_nodeId(0) { - m_templateNode->IncRef(); + m_templateNode->Ref(); } //============================================================================ @@ -4086,7 +4086,7 @@ void VaultCreateNodeTrans::Post () { m_param, m_nodeId ); - m_templateNode->DecRef(); + m_templateNode->UnRef(); } //============================================================================ @@ -5024,7 +5024,7 @@ bool NetAuthTrans::AcquireConn () { //============================================================================ void NetAuthTrans::ReleaseConn () { if (m_conn) { - m_conn->DecRef("AcquireConn"); + m_conn->UnRef("AcquireConn"); m_conn = nil; } } @@ -5399,7 +5399,7 @@ void NetCliAuthSetCCRLevel ( }; conn->Send(msg, arrsize(msg)); - conn->DecRef("SetCCRLevel"); + conn->UnRef("SetCCRLevel"); } //============================================================================ @@ -5433,7 +5433,7 @@ void NetCliAuthSetAgePublic ( conn->Send(msg, arrsize(msg)); - conn->DecRef("SetAgePublic"); + conn->UnRef("SetAgePublic"); } //============================================================================ @@ -5733,7 +5733,7 @@ void NetCliAuthVaultSetSeen ( conn->Send(msg, arrsize(msg)); - conn->DecRef("SetSeen"); + conn->UnRef("SetSeen"); } //============================================================================ @@ -5753,7 +5753,7 @@ void NetCliAuthVaultSendNode ( conn->Send(msg, arrsize(msg)); - conn->DecRef("SendNode"); + conn->UnRef("SendNode"); } //============================================================================ @@ -5817,7 +5817,7 @@ void NetCliAuthPropagateBuffer ( conn->Send(msg, arrsize(msg)); - conn->DecRef("PropBuffer"); + conn->UnRef("PropBuffer"); } @@ -5834,7 +5834,7 @@ void NetCliAuthLogPythonTraceback (const wchar_t traceback[]) { conn->Send(msg, arrsize(msg)); - conn->DecRef("LogTraceback"); + conn->UnRef("LogTraceback"); } @@ -5851,7 +5851,7 @@ void NetCliAuthLogStackDump (const wchar_t stackdump[]) { conn->Send(msg, arrsize(msg)); - conn->DecRef("LogStackDump"); + conn->UnRef("LogStackDump"); } //============================================================================ @@ -5869,7 +5869,7 @@ void NetCliAuthLogClientDebuggerConnect () { conn->Send(msg, arrsize(msg)); - conn->DecRef(); + conn->UnRef(); } //============================================================================ @@ -5908,7 +5908,7 @@ void NetCliAuthKickPlayer ( }; conn->Send(msg, arrsize(msg)); - conn->DecRef("KickPlayer"); + conn->UnRef("KickPlayer"); } //============================================================================ diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index a3fdfb08..b873a95f 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -60,7 +60,7 @@ namespace Ngl { namespace File { * ***/ -struct CliFileConn : AtomicRef { +struct CliFileConn : hsAtomicRefCnt { LINK(CliFileConn) link; hsReaderWriterLock sockLock; // to protect the socket pointer so we don't nuke it while using it AsyncSocket sock; @@ -251,7 +251,7 @@ static unsigned GetNonZeroTimeMs () { //============================================================================ static CliFileConn * GetConnIncRef_CS (const char tag[]) { if (CliFileConn * conn = s_active) { - conn->IncRef(tag); + conn->Ref(tag); return conn; } return nil; @@ -291,7 +291,7 @@ static void UnlinkAndAbandonConn_CS (CliFileConn * conn) { conn->sockLock.UnlockForReading(); } if (needsDecref) { - conn->DecRef("Lifetime"); + conn->UnRef("Lifetime"); } } @@ -346,9 +346,9 @@ static void NotifyConnSocketConnectFailed (CliFileConn * conn) { if (s_running && conn->AutoReconnectEnabled()) conn->StartAutoReconnect(); else - conn->DecRef("Lifetime"); // if we are not reconnecting, this socket is done, so remove the lifetime ref + conn->UnRef("Lifetime"); // if we are not reconnecting, this socket is done, so remove the lifetime ref } - conn->DecRef("Connecting"); + conn->UnRef("Connecting"); } //============================================================================ @@ -424,10 +424,10 @@ static void NotifyConnSocketDisconnect (CliFileConn * conn) { if (conn->AutoReconnectEnabled()) conn->StartAutoReconnect(); else - conn->DecRef("Lifetime"); // if we are not reconnecting, this socket is done, so remove the lifetime ref + conn->UnRef("Lifetime"); // if we are not reconnecting, this socket is done, so remove the lifetime ref } - conn->DecRef("Connected"); + conn->UnRef("Connected"); } //============================================================================ @@ -552,7 +552,7 @@ static void Connect ( conn->seq = ConnNextSequence(); conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout - conn->IncRef("Lifetime"); + conn->Ref("Lifetime"); conn->AutoReconnect(); } @@ -609,7 +609,7 @@ void CliFileConn::TimerReconnect () { s_critsect.Leave(); } else { - IncRef("Connecting"); + Ref("Connecting"); // Remember the time we started the reconnect attempt, guarding against // TimeGetMs() returning zero (unlikely), as a value of zero indicates @@ -654,7 +654,7 @@ void CliFileConn::AutoReconnect () { timerCritsect.Enter(); { ASSERT(!reconnectTimer); - IncRef("ReconnectTimer"); + Ref("ReconnectTimer"); AsyncTimerCreate( &reconnectTimer, CliFileConnTimerReconnectProc, @@ -668,7 +668,7 @@ void CliFileConn::AutoReconnect () { //=========================================================================== static unsigned CliFileConnTimerDestroyed (void * param) { CliFileConn * sock = (CliFileConn *) param; - sock->DecRef("TimerDestroyed"); + sock->UnRef("TimerDestroyed"); return kAsyncTimeInfinite; } @@ -693,7 +693,7 @@ static unsigned CliFileConnPingTimerProc (void * param) { //============================================================================ void CliFileConn::AutoPing () { ASSERT(!pingTimer); - IncRef("PingTimer"); + Ref("PingTimer"); timerCritsect.Enter(); { sockLock.LockForReading(); @@ -1270,7 +1270,7 @@ bool NetFileTrans::AcquireConn () { //============================================================================ void NetFileTrans::ReleaseConn () { if (m_conn) { - m_conn->DecRef("AcquireConn"); + m_conn->UnRef("AcquireConn"); m_conn = nil; } } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp index eeb893bd..00d46023 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp @@ -55,7 +55,7 @@ namespace Ngl { namespace Game { * ***/ -struct CliGmConn : AtomicRef { +struct CliGmConn : hsAtomicRefCnt { LINK(CliGmConn) link; CCritSect critsect; @@ -176,7 +176,7 @@ static unsigned GetNonZeroTimeMs () { static CliGmConn * GetConnIncRef_CS (const char tag[]) { if (CliGmConn * conn = s_active) if (conn->cli) { - conn->IncRef(tag); + conn->Ref(tag); return conn; } return nil; @@ -205,7 +205,7 @@ static void UnlinkAndAbandonConn_CS (CliGmConn * conn) { AsyncSocketDisconnect(conn->sock, true); } else { - conn->DecRef("Lifetime"); + conn->UnRef("Lifetime"); } } @@ -260,8 +260,8 @@ static void NotifyConnSocketConnectFailed (CliGmConn * conn) { s_critsect.Leave(); NetTransCancelByConnId(conn->seq, kNetErrTimeout); - conn->DecRef("Connecting"); - conn->DecRef("Lifetime"); + conn->UnRef("Connecting"); + conn->UnRef("Lifetime"); if (notify) ReportNetError(kNetProtocolCli2Game, kNetErrConnectFailed); @@ -288,8 +288,8 @@ static void NotifyConnSocketDisconnect (CliGmConn * conn) { // Cancel all transactions in process on this connection. NetTransCancelByConnId(conn->seq, kNetErrTimeout); - conn->DecRef("Connected"); - conn->DecRef("Lifetime"); + conn->UnRef("Connected"); + conn->UnRef("Lifetime"); if (notify) ReportNetError(kNetProtocolCli2Game, kNetErrDisconnected); @@ -361,8 +361,8 @@ static void Connect ( conn->seq = ConnNextSequence(); conn->lastHeardTimeMs = GetNonZeroTimeMs(); - conn->IncRef("Lifetime"); - conn->IncRef("Connecting"); + conn->Ref("Lifetime"); + conn->Ref("Connecting"); s_critsect.Enter(); { @@ -403,7 +403,7 @@ static void Connect ( //=========================================================================== static unsigned CliGmConnTimerDestroyed (void * param) { CliGmConn * conn = (CliGmConn *) param; - conn->DecRef("TimerDestroyed"); + conn->UnRef("TimerDestroyed"); return kAsyncTimeInfinite; } @@ -431,7 +431,7 @@ CliGmConn::~CliGmConn () { //============================================================================ void CliGmConn::AutoPing () { ASSERT(!pingTimer); - IncRef("PingTimer"); + Ref("PingTimer"); critsect.Enter(); { AsyncTimerCreate( @@ -693,7 +693,7 @@ bool NetGameTrans::AcquireConn () { //============================================================================ void NetGameTrans::ReleaseConn () { if (m_conn) { - m_conn->DecRef("AcquireConn"); + m_conn->UnRef("AcquireConn"); m_conn = nil; } } @@ -860,7 +860,7 @@ void NetCliGamePropagateBuffer ( conn->Send(msg, arrsize(msg)); - conn->DecRef("PropBuffer"); + conn->UnRef("PropBuffer"); } //============================================================================ @@ -882,5 +882,5 @@ void NetCliGameSendGameMgrMsg (GameMsgHeader * msgHdr) { conn->Send(msg, arrsize(msg)); - conn->DecRef("GameMgrMsg"); + conn->UnRef("GameMgrMsg"); } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index 27623a12..cc5ccfde 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp @@ -56,7 +56,7 @@ namespace Ngl { namespace GateKeeper { * ***/ -struct CliGkConn : AtomicRef { +struct CliGkConn : hsAtomicRefCnt { CliGkConn (); ~CliGkConn (); @@ -208,7 +208,7 @@ static unsigned GetNonZeroTimeMs () { //============================================================================ static CliGkConn * GetConnIncRef_CS (const char tag[]) { if (CliGkConn * conn = s_active) { - conn->IncRef(tag); + conn->Ref(tag); return conn; } return nil; @@ -240,7 +240,7 @@ static void UnlinkAndAbandonConn_CS (CliGkConn * conn) { AsyncSocketDisconnect(conn->sock, true); } else { - conn->DecRef("Lifetime"); + conn->UnRef("Lifetime"); } } @@ -303,7 +303,7 @@ static void CheckedReconnect (CliGkConn * conn, ENetError error) { // Cancel all transactions in progress on this connection. NetTransCancelByConnId(conn->seq, kNetErrTimeout); // conn is dead. - conn->DecRef("Lifetime"); + conn->UnRef("Lifetime"); ReportNetError(kNetProtocolCli2GateKeeper, error); } else { @@ -339,7 +339,7 @@ static void NotifyConnSocketConnectFailed (CliGkConn * conn) { CheckedReconnect(conn, kNetErrConnectFailed); - conn->DecRef("Connecting"); + conn->UnRef("Connecting"); } //============================================================================ @@ -359,8 +359,8 @@ static void NotifyConnSocketDisconnect (CliGkConn * conn) { // Cancel all transactions in process on this connection. NetTransCancelByConnId(conn->seq, kNetErrTimeout); - conn->DecRef("Connected"); - conn->DecRef("Lifetime"); + conn->UnRef("Connected"); + conn->UnRef("Lifetime"); } //============================================================================ @@ -474,7 +474,7 @@ static void Connect ( conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout strncpy(conn->name, name, arrsize(conn->name)); - conn->IncRef("Lifetime"); + conn->Ref("Lifetime"); conn->AutoReconnect(); } @@ -507,7 +507,7 @@ static void AsyncLookupCallback ( //=========================================================================== static unsigned CliGkConnTimerDestroyed (void * param) { CliGkConn * conn = (CliGkConn *) param; - conn->DecRef("TimerDestroyed"); + conn->UnRef("TimerDestroyed"); return kAsyncTimeInfinite; } @@ -553,7 +553,7 @@ void CliGkConn::TimerReconnect () { s_critsect.Leave(); } else { - IncRef("Connecting"); + Ref("Connecting"); // Remember the time we started the reconnect attempt, guarding against // TimeGetMs() returning zero (unlikely), as a value of zero indicates @@ -592,7 +592,7 @@ void CliGkConn::StartAutoReconnect () { void CliGkConn::AutoReconnect () { ASSERT(!reconnectTimer); - IncRef("ReconnectTimer"); + Ref("ReconnectTimer"); critsect.Enter(); { AsyncTimerCreate( @@ -626,7 +626,7 @@ bool CliGkConn::AutoReconnectEnabled () { //============================================================================ void CliGkConn::AutoPing () { ASSERT(!pingTimer); - IncRef("PingTimer"); + Ref("PingTimer"); critsect.Enter(); { AsyncTimerCreate( @@ -970,7 +970,7 @@ bool NetGateKeeperTrans::AcquireConn () { //============================================================================ void NetGateKeeperTrans::ReleaseConn () { if (m_conn) { - m_conn->DecRef("AcquireConn"); + m_conn->UnRef("AcquireConn"); m_conn = nil; } } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp index da3a16d8..988236a1 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp @@ -81,7 +81,7 @@ static NetTrans * FindTransIncRef_CS (unsigned transId, const char tag[]) { // There shouldn't be more than a few transactions; just do a linear scan for (NetTrans * trans = s_transactions.Head(); trans; trans = s_transactions.Next(trans)) if (trans->m_transId == transId) { - trans->IncRef(tag); + trans->Ref(tag); return trans; } @@ -197,7 +197,7 @@ unsigned NetTransGetTimeoutMs () { //============================================================================ void NetTransSend (NetTrans * trans) { - trans->IncRef("Lifetime"); + trans->Ref("Lifetime"); s_critsect.Enter(); { static unsigned s_transId; @@ -225,7 +225,7 @@ bool NetTransRecv (unsigned transId, const uint8_t msg[], unsigned bytes) { if (!result) NetTransCancel(transId, kNetErrInternalError); - trans->DecRef("Recv"); + trans->UnRef("Recv"); return result; } @@ -345,13 +345,13 @@ void NetTransUpdate () { while (NetTrans * trans = completed.Head()) { completed.Unlink(trans); trans->Post(); - trans->DecRef("Lifetime"); + trans->UnRef("Lifetime"); } // Post completed parent transactions while (NetTrans * trans = parentCompleted.Head()) { parentCompleted.Unlink(trans); trans->Post(); - trans->DecRef("Lifetime"); + trans->UnRef("Lifetime"); } } diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h b/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h index 44b6798e..680245c1 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h +++ b/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 hsSafeRefCnt +class plNetCommonMessageData : public hsAtomicRefCnt { private: char *fData; // sent diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp index 5a52f112..3a16e831 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp @@ -99,10 +99,10 @@ struct RelVaultNodeLink : THashKeyVal { , ownerId(ownerId) , seen(seen) { - node->IncRef(); + node->Ref(); } ~RelVaultNodeLink () { - node->DecRef(); + node->UnRef(); } }; @@ -457,7 +457,7 @@ static void FetchRefOwners ( } QSORT(unsigned, ownerIds.Ptr(), ownerIds.Count(), elem1 < elem2); RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); { unsigned prevId = 0; for (unsigned i = 0; i < ownerIds.Count(); ++i) { @@ -466,7 +466,7 @@ static void FetchRefOwners ( VaultPlayerInfoNode access(templateNode); access.SetPlayerId(refs[i].ownerId); if (RelVaultNode * rvn = VaultGetNodeIncRef(templateNode)) { - rvn->DecRef(); + rvn->UnRef(); continue; } NetCliAuthVaultNodeFind( @@ -477,7 +477,7 @@ static void FetchRefOwners ( } } } - templateNode->DecRef(); + templateNode->UnRef(); } //============================================================================ @@ -632,7 +632,7 @@ static void VaultNodeAdded ( unsigned inboxId = 0; if (RelVaultNode * rvnInbox = VaultGetPlayerInboxFolderIncRef()) { inboxId = rvnInbox->GetNodeId(); - rvnInbox->DecRef(); + rvnInbox->UnRef(); } // Build the relationship locally @@ -762,7 +762,7 @@ static RelVaultNode * GetChildFolderNode ( RelVaultNode * rvn = parent->GetChildFolderNodeIncRef(folderType, maxDepth); if (rvn) - rvn->DecRef(); + rvn->UnRef(); return rvn; } @@ -778,7 +778,7 @@ static RelVaultNode * GetChildPlayerInfoListNode ( RelVaultNode * rvn = parent->GetChildPlayerInfoListNodeIncRef(folderType, maxDepth); if (rvn) - rvn->DecRef(); + rvn->UnRef(); return rvn; } @@ -1226,7 +1226,7 @@ RelVaultNode * RelVaultNode::GetParentNodeIncRef ( link = state->parents.Head(); for (; link; link = state->parents.Next(link)) { if (link->node->Matches(templateNode)) { - link->node->IncRef("Found"); + link->node->Ref("Found"); return link->node; } } @@ -1252,7 +1252,7 @@ RelVaultNode * RelVaultNode::GetChildNodeIncRef ( link = state->children.Head(); for (; link; link = state->children.Next(link)) { if (link->node->Matches(templateNode)) { - link->node->IncRef("Found"); + link->node->Ref("Found"); return link->node; } } @@ -1272,10 +1272,10 @@ RelVaultNode * RelVaultNode::GetChildNodeIncRef ( unsigned maxDepth ) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(nodeType); RelVaultNode * result = GetChildNodeIncRef(templateNode, maxDepth); - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -1285,12 +1285,12 @@ RelVaultNode * RelVaultNode::GetChildFolderNodeIncRef ( unsigned maxDepth ) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_Folder); VaultFolderNode folder(templateNode); folder.SetFolderType(folderType); RelVaultNode * result = GetChildNodeIncRef(templateNode, maxDepth); - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -1300,12 +1300,12 @@ RelVaultNode * RelVaultNode::GetChildPlayerInfoListNodeIncRef ( unsigned maxDepth ) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfoList); VaultPlayerInfoListNode access(templateNode); access.SetFolderType(folderType); RelVaultNode * result = GetChildNodeIncRef(templateNode, maxDepth); - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -1315,12 +1315,12 @@ RelVaultNode * RelVaultNode::GetChildAgeInfoListNodeIncRef ( unsigned maxDepth ) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfoList); VaultAgeInfoListNode access(templateNode); access.SetFolderType(folderType); RelVaultNode * result = GetChildNodeIncRef(templateNode, maxDepth); - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -1336,7 +1336,7 @@ void RelVaultNode::GetChildNodesIncRef ( link = state->children.Head(); for (; link; link = state->children.Next(link)) { nodes->Add(link->node); - link->node->IncRef(); + link->node->Ref(); link->node->GetChildNodesIncRef( maxDepth - 1, nodes @@ -1355,7 +1355,7 @@ void RelVaultNode::GetChildNodesIncRef ( for (; link; link = state->children.Next(link)) { if (link->node->Matches(templateNode)) { nodes->Add(link->node); - link->node->IncRef(); + link->node->Ref(); } link->node->GetChildNodesIncRef( templateNode, @@ -1372,14 +1372,14 @@ void RelVaultNode::GetChildNodesIncRef ( ARRAY(RelVaultNode*) * nodes ) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(nodeType); GetChildNodesIncRef( templateNode, maxDepth, nodes ); - templateNode->DecRef(); + templateNode->UnRef(); } //============================================================================ @@ -1389,7 +1389,7 @@ void RelVaultNode::GetChildFolderNodesIncRef ( ARRAY(RelVaultNode*) * nodes ) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_Folder); VaultFolderNode fldr(templateNode); fldr.SetFolderType(folderType); @@ -1398,7 +1398,7 @@ void RelVaultNode::GetChildFolderNodesIncRef ( maxDepth, nodes ); - templateNode->DecRef(); + templateNode->UnRef(); } //============================================================================ @@ -1590,7 +1590,7 @@ RelVaultNode * RelVaultNode::GetParentAgeLinkIncRef () { RelVaultNode * result = nil; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeLink); // Get our parent AgeLink node @@ -1599,7 +1599,7 @@ RelVaultNode * RelVaultNode::GetParentAgeLinkIncRef () { result = rvnLink->GetParentNodeIncRef(templateNode, 3); } - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -1702,7 +1702,7 @@ RelVaultNode * VaultGetNodeIncRef ( NetVaultNode * templateNode ) { if (RelVaultNode * node = GetNode(templateNode)) { - node->IncRef(); + node->Ref(); return node; } return nil; @@ -1713,7 +1713,7 @@ RelVaultNode * VaultGetNodeIncRef ( unsigned nodeId ) { if (RelVaultNode * node = GetNode(nodeId)) { - node->IncRef(); + node->Ref(); return node; } return nil; @@ -1725,7 +1725,7 @@ RelVaultNode * VaultGetNodeIncRef ( const char reftag[] ) { if (RelVaultNodeLink * link = s_nodes.Find(nodeId)) { - link->node->IncRef(reftag); + link->node->Ref(reftag); return link->node; } return nil; @@ -1971,7 +1971,7 @@ void VaultPublishNode ( } VaultAddChildNode(rvn->GetNodeId(), nodeId, VaultGetPlayerId(), nil, nil); - rvn->DecRef(); + rvn->UnRef(); } //============================================================================ @@ -1998,7 +1998,7 @@ void VaultCreateNode ( templateNode->SetCreateAgeName(access.GetAgeName()); if (!(templateNode->GetFieldFlags() & NetVaultNode::kCreateAgeUuid)) templateNode->SetCreateAgeUuid(access.GetAgeInstanceGuid()); - age->DecRef(); + age->UnRef(); } NetCliAuthVaultNodeCreate( @@ -2016,7 +2016,7 @@ void VaultCreateNode ( void * param ) { RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(nodeType); VaultCreateNode( @@ -2026,7 +2026,7 @@ void VaultCreateNode ( param ); - templateNode->DecRef(); + templateNode->UnRef(); } //============================================================================ @@ -2075,7 +2075,7 @@ RelVaultNode * VaultCreateNodeAndWaitIncRef ( *result = param.result; if (IS_NET_SUCCESS(param.result)) - param.node->IncRef(); + param.node->Ref(); return param.node; } @@ -2086,12 +2086,12 @@ RelVaultNode * VaultCreateNodeAndWaitIncRef ( ) { RelVaultNode * node; RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(nodeType); node = VaultCreateNodeAndWaitIncRef(templateNode, result); - templateNode->DecRef(); + templateNode->UnRef(); return node; } @@ -2297,12 +2297,12 @@ void VaultInitAge ( //============================================================================ static RelVaultNode * GetPlayerNode () { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_VNodeMgrPlayer); if (NetCommGetPlayer()) templateNode->SetNodeId(NetCommGetPlayer()->playerInt); RelVaultNode * result = GetNode(templateNode); - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -2316,7 +2316,7 @@ unsigned VaultGetPlayerId () { //============================================================================ RelVaultNode * VaultGetPlayerNodeIncRef () { if (RelVaultNode * rvnPlr = GetPlayerNode()) { - rvnPlr->IncRef(); + rvnPlr->Ref(); return rvnPlr; } return nil; @@ -2329,18 +2329,18 @@ RelVaultNode * VaultGetPlayerInfoNodeIncRef () { return nil; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode plrInfo(templateNode); plrInfo.SetPlayerId(rvnPlr->GetNodeId()); - rvnPlr->DecRef(); + rvnPlr->UnRef(); RelVaultNode * result = nil; if (RelVaultNode * rvnPlrInfo = rvnPlr->GetChildNodeIncRef(templateNode, 1)) result = rvnPlrInfo; - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -2394,7 +2394,7 @@ bool VaultGetLinkToMyNeighborhood (plAgeLinkStruct * link) { return false; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -2406,10 +2406,10 @@ bool VaultGetLinkToMyNeighborhood (plAgeLinkStruct * link) { if (nil != (node = rvnFldr->GetChildNodeIncRef(templateNode, 2))) { VaultAgeInfoNode info(node); info.CopyTo(link->GetAgeInfo()); - node->DecRef(); + node->UnRef(); } - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); return node != nil; } @@ -2421,7 +2421,7 @@ bool VaultGetLinkToMyPersonalAge (plAgeLinkStruct * link) { return false; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -2433,10 +2433,10 @@ bool VaultGetLinkToMyPersonalAge (plAgeLinkStruct * link) { if (nil != (node = rvnFldr->GetChildNodeIncRef(templateNode, 2))) { VaultAgeInfoNode info(node); info.CopyTo(link->GetAgeInfo()); - node->DecRef(); + node->UnRef(); } - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); return node != nil; } @@ -2448,7 +2448,7 @@ bool VaultGetLinkToCity (plAgeLinkStruct * link) { return false; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -2460,10 +2460,10 @@ bool VaultGetLinkToCity (plAgeLinkStruct * link) { if (nil != (node = rvnFldr->GetChildNodeIncRef(templateNode, 2))) { VaultAgeInfoNode info(node); info.CopyTo(link->GetAgeInfo()); - node->DecRef(); + node->UnRef(); } - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); return node != nil; } @@ -2476,7 +2476,7 @@ RelVaultNode * VaultGetOwnedAgeLinkIncRef (const plAgeInfoStruct * info) { if (RelVaultNode * rvnFldr = VaultGetAgesIOwnFolderIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -2493,11 +2493,11 @@ RelVaultNode * VaultGetOwnedAgeLinkIncRef (const plAgeInfoStruct * info) { templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_AgeLink); rvnLink = rvnInfo->GetParentNodeIncRef(templateNode, 1); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); } return rvnLink; @@ -2511,7 +2511,7 @@ RelVaultNode * VaultGetOwnedAgeInfoIncRef (const plAgeInfoStruct * info) { if (RelVaultNode * rvnFldr = VaultGetAgesIOwnFolderIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -2526,8 +2526,8 @@ RelVaultNode * VaultGetOwnedAgeInfoIncRef (const plAgeInfoStruct * info) { rvnInfo = rvnFldr->GetChildNodeIncRef(templateNode, 2); - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); } return rvnInfo; @@ -2540,11 +2540,11 @@ bool VaultGetOwnedAgeLink (const plAgeInfoStruct * info, plAgeLinkStruct * link) if (RelVaultNode * rvnInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode ageInfo(rvnInfo); ageInfo.CopyTo(link->GetAgeInfo()); - rvnInfo->DecRef(); + rvnInfo->UnRef(); result = true; } - rvnLink->DecRef(); + rvnLink->UnRef(); } return result; @@ -2576,7 +2576,7 @@ bool VaultAddOwnedAgeSpawnPoint (const plUUID& ageInstId, const plSpawnPointInfo fldr->GetChildNodeIds(&nodeIds, 1); NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode access(templateNode); access.SetAgeInstanceGuid(ageInstId); @@ -2588,21 +2588,21 @@ bool VaultAddOwnedAgeSpawnPoint (const plUUID& ageInstId, const plSpawnPointInfo if (RelVaultNode * info = link->GetChildNodeIncRef(templateNode, 1)) { VaultAgeLinkNode access(link); access.AddSpawnPoint(spawnPt); - info->DecRef(); - link->DecRef(); + info->UnRef(); + link->UnRef(); link = nil; break; } } - templateNode->DecRef(); + templateNode->UnRef(); break; } - if (fldr) - fldr->DecRef(); + if (fldr) + fldr->UnRef(); if (link) - link->DecRef(); + link->UnRef(); return true; } @@ -2626,9 +2626,9 @@ bool VaultSetOwnedAgePublicAndWait (const plAgeInfoStruct * info, bool publicOrN msg->GetArgs()->AddString(plNetCommon::VaultTaskArgs::kAgeFilename, ageName); msg->Send(); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - rvnLink->DecRef(); + rvnLink->UnRef(); } return true; } @@ -2640,7 +2640,7 @@ RelVaultNode * VaultGetVisitAgeLinkIncRef (const plAgeInfoStruct * info) { if (RelVaultNode * rvnFldr = VaultGetAgesICanVisitFolderIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -2657,11 +2657,11 @@ RelVaultNode * VaultGetVisitAgeLinkIncRef (const plAgeInfoStruct * info) { templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_AgeLink); rvnLink = rvnInfo->GetParentNodeIncRef(templateNode, 1); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); } return rvnLink; @@ -2676,7 +2676,7 @@ bool VaultGetVisitAgeLink (const plAgeInfoStruct * info, class plAgeLinkStruct * VaultAgeLinkNode ageLink(rvn); ageLink.CopyTo(link); - rvn->DecRef(); + rvn->UnRef(); return true; } @@ -2757,7 +2757,7 @@ bool VaultRegisterOwnedAgeAndWait (const plAgeLinkStruct * link) { for (;;) { if (RelVaultNode * rvn = VaultGetAgesIOwnFolderIncRef()) { agesIOwnId = rvn->GetNodeId(); - rvn->DecRef(); + rvn->UnRef(); } else { LogMsg(kLogError, L"RegisterOwnedAge: Failed to get player's AgesIOwnFolder"); @@ -2862,15 +2862,15 @@ bool VaultRegisterOwnedAgeAndWait (const plAgeLinkStruct * link) { if (RelVaultNode * rvnAgeInfo = VaultGetNodeIncRef(ageInfoId)) { if (RelVaultNode * rvnAgeOwners = rvnAgeInfo->GetChildPlayerInfoListNodeIncRef(plVault::kAgeOwnersFolder, 1)) { ageOwnersId = rvnAgeOwners->GetNodeId(); - rvnAgeOwners->DecRef(); + rvnAgeOwners->UnRef(); } - rvnAgeInfo->DecRef(); + rvnAgeInfo->UnRef(); } unsigned playerInfoId = 0; if (RelVaultNode * rvnPlayerInfo = VaultGetPlayerInfoNodeIncRef()) { playerInfoId = rvnPlayerInfo->GetNodeId(); - rvnPlayerInfo->DecRef(); + rvnPlayerInfo->UnRef(); } VaultAddChildNode( @@ -2921,7 +2921,7 @@ bool VaultRegisterOwnedAgeAndWait (const plAgeLinkStruct * link) { if (RelVaultNode * node = VaultGetNodeIncRef(ageLinkId)) { VaultAgeLinkNode access(node); access.AddSpawnPoint(link->SpawnPoint()); - node->DecRef(); + node->UnRef(); } result = true; @@ -2987,10 +2987,10 @@ namespace _VaultRegisterOwnedAge { if (RelVaultNode* rvnAgeInfo = VaultGetNodeIncRef((uint32_t)((uintptr_t)p->fAgeInfoId))) { if (RelVaultNode* rvnAgeOwners = rvnAgeInfo->GetChildPlayerInfoListNodeIncRef(plVault::kAgeOwnersFolder, 1)) { VaultAddChildNode(rvnAgeOwners->GetNodeId(), plyrInfo->GetNodeId(), 0, (FVaultAddChildNodeCallback)_AddPlayerInfoNode, nil); - rvnAgeOwners->DecRef(); + rvnAgeOwners->UnRef(); } - rvnAgeInfo->DecRef(); + rvnAgeInfo->UnRef(); } // Fire off vault callbacks @@ -3001,8 +3001,8 @@ namespace _VaultRegisterOwnedAge { msg->Send(); // Don't leak memory - agesIOwn->DecRef(); - plyrInfo->DecRef(); + agesIOwn->UnRef(); + plyrInfo->UnRef(); delete p; } @@ -3130,7 +3130,7 @@ bool VaultRegisterVisitAgeAndWait (const plAgeLinkStruct * link) { for (;;) { if (RelVaultNode * rvn = VaultGetAgesICanVisitFolderIncRef()) { agesICanVisitId = rvn->GetNodeId(); - rvn->DecRef(); + rvn->UnRef(); } else { LogMsg(kLogError, L"RegisterVisitAge: Failed to get player's AgesICanVisitFolder"); @@ -3235,15 +3235,15 @@ bool VaultRegisterVisitAgeAndWait (const plAgeLinkStruct * link) { if (RelVaultNode * rvnAgeInfo = VaultGetNodeIncRef(ageInfoId)) { if (RelVaultNode * rvnAgeVisitors = rvnAgeInfo->GetChildPlayerInfoListNodeIncRef(plVault::kCanVisitFolder, 1)) { ageVisitorsId = rvnAgeVisitors->GetNodeId(); - rvnAgeVisitors->DecRef(); + rvnAgeVisitors->UnRef(); } - rvnAgeInfo->DecRef(); + rvnAgeInfo->UnRef(); } unsigned playerInfoId = 0; if (RelVaultNode * rvnPlayerInfo = VaultGetPlayerInfoNodeIncRef()) { playerInfoId = rvnPlayerInfo->GetNodeId(); - rvnPlayerInfo->DecRef(); + rvnPlayerInfo->UnRef(); } VaultAddChildNode( @@ -3294,7 +3294,7 @@ bool VaultRegisterVisitAgeAndWait (const plAgeLinkStruct * link) { if (RelVaultNode * node = VaultGetNodeIncRef(ageLinkId)) { VaultAgeLinkNode access(node); access.AddSpawnPoint(link->SpawnPoint()); - node->DecRef(); + node->UnRef(); } result = true; @@ -3336,10 +3336,10 @@ namespace _VaultRegisterVisitAge { if (RelVaultNode * playerInfo = VaultGetPlayerInfoNodeIncRef()) { if (RelVaultNode* canVisit = ageInfo->GetChildPlayerInfoListNodeIncRef(plVault::kCanVisitFolder, 1)) { VaultAddChildNode(canVisit->GetNodeId(), playerInfo->GetNodeId(), 0, nil, nil); - canVisit->DecRef(); + canVisit->UnRef(); } - playerInfo->DecRef(); + playerInfo->UnRef(); } // Get our AgesICanVisit folder @@ -3433,7 +3433,7 @@ bool VaultUnregisterOwnedAgeAndWait (const plAgeInfoStruct * info) { if (RelVaultNode * rvn = VaultGetAgesIOwnFolderIncRef()) { agesIOwnId = rvn->GetNodeId(); - rvn->DecRef(); + rvn->UnRef(); } else { LogMsg(kLogError, L"UnregisterOwnedAge: Failed to get player's AgesIOwnFolder"); @@ -3446,18 +3446,18 @@ bool VaultUnregisterOwnedAgeAndWait (const plAgeInfoStruct * info) { if (RelVaultNode * rvnAgeInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { if (RelVaultNode * rvnAgeOwners = rvnAgeInfo->GetChildPlayerInfoListNodeIncRef(plVault::kAgeOwnersFolder, 1)) { ageOwnersId = rvnAgeOwners->GetNodeId(); - rvnAgeOwners->DecRef(); + rvnAgeOwners->UnRef(); } - rvnAgeInfo->DecRef(); + rvnAgeInfo->UnRef(); } unsigned playerInfoId = 0; if (RelVaultNode * rvnPlayerInfo = VaultGetPlayerInfoNodeIncRef()) { playerInfoId = rvnPlayerInfo->GetNodeId(); - rvnPlayerInfo->DecRef(); + rvnPlayerInfo->UnRef(); } - rvnLink->DecRef(); + rvnLink->UnRef(); // remove our playerInfo from the ageOwners folder VaultRemoveChildNode(ageOwnersId, playerInfoId, nil, nil); @@ -3497,7 +3497,7 @@ bool VaultUnregisterVisitAgeAndWait (const plAgeInfoStruct * info) { if (RelVaultNode * rvn = VaultGetAgesICanVisitFolderIncRef()) { agesICanVisitId = rvn->GetNodeId(); - rvn->DecRef(); + rvn->UnRef(); } else { LogMsg(kLogError, L"UnregisterOwnedAge: Failed to get player's AgesICanVisitFolder"); @@ -3510,18 +3510,18 @@ bool VaultUnregisterVisitAgeAndWait (const plAgeInfoStruct * info) { if (RelVaultNode * rvnAgeInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { if (RelVaultNode * rvnAgeVisitors = rvnAgeInfo->GetChildPlayerInfoListNodeIncRef(plVault::kCanVisitFolder, 1)) { ageVisitorsId = rvnAgeVisitors->GetNodeId(); - rvnAgeVisitors->DecRef(); + rvnAgeVisitors->UnRef(); } - rvnAgeInfo->DecRef(); + rvnAgeInfo->UnRef(); } unsigned playerInfoId = 0; if (RelVaultNode * rvnPlayerInfo = VaultGetPlayerInfoNodeIncRef()) { playerInfoId = rvnPlayerInfo->GetNodeId(); - rvnPlayerInfo->DecRef(); + rvnPlayerInfo->UnRef(); } - rvnLink->DecRef(); + rvnLink->UnRef(); // remove our playerInfo from the ageVisitors folder VaultRemoveChildNode(ageVisitorsId, playerInfoId, nil, nil); @@ -3551,7 +3551,7 @@ RelVaultNode * VaultFindChronicleEntryIncRef (const wchar_t entryName[], int ent RelVaultNode * result = nil; if (RelVaultNode * rvnFldr = GetChildFolderNode(GetPlayerNode(), plVault::kChronicleFolder, 1)) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_Chronicle); VaultChronicleNode chrn(templateNode); chrn.SetEntryName(entryName); @@ -3559,7 +3559,7 @@ RelVaultNode * VaultFindChronicleEntryIncRef (const wchar_t entryName[], int ent chrn.SetEntryType(entryType); if (RelVaultNode * rvnChrn = rvnFldr->GetChildNodeIncRef(templateNode, 255)) result = rvnChrn; - templateNode->DecRef(); + templateNode->UnRef(); } return result; } @@ -3567,7 +3567,7 @@ RelVaultNode * VaultFindChronicleEntryIncRef (const wchar_t entryName[], int ent //============================================================================ bool VaultHasChronicleEntry (const wchar_t entryName[], int entryType) { if (RelVaultNode * rvn = VaultFindChronicleEntryIncRef(entryName, entryType)) { - rvn->DecRef(); + rvn->UnRef(); return true; } return false; @@ -3585,7 +3585,7 @@ void VaultAddChronicleEntryAndWait ( } else if (RelVaultNode * rvnFldr = GetChildFolderNode(GetPlayerNode(), plVault::kChronicleFolder, 1)) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_Chronicle); VaultChronicleNode chrnNode(templateNode); chrnNode.SetEntryName(entryName); @@ -3594,9 +3594,9 @@ void VaultAddChronicleEntryAndWait ( ENetError result; if (RelVaultNode * rvnChrn = VaultCreateNodeAndWaitIncRef(templateNode, &result)) { VaultAddChildNode(rvnFldr->GetNodeId(), rvnChrn->GetNodeId(), 0, nil, nil); - rvnChrn->DecRef(); + rvnChrn->UnRef(); } - templateNode->DecRef(); + templateNode->UnRef(); } } @@ -3604,21 +3604,21 @@ void VaultAddChronicleEntryAndWait ( bool VaultAmIgnoringPlayer (unsigned playerId) { bool retval = false; if (RelVaultNode * rvnFldr = GetChildPlayerInfoListNode(GetPlayerNode(), plVault::kIgnoreListFolder, 1)) { - rvnFldr->IncRef(); + rvnFldr->Ref(); NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode pinfoNode(templateNode); pinfoNode.SetPlayerId(playerId); if (RelVaultNode * rvnPlayerInfo = rvnFldr->GetChildNodeIncRef(templateNode, 1)) { retval = true; - rvnPlayerInfo->DecRef(); + rvnPlayerInfo->UnRef(); } - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); } return retval; @@ -3637,7 +3637,7 @@ bool VaultGetCCRStatus () { VaultSystemNode sysNode(rvnSystem); retval = (sysNode.GetCCRStatus() != 0); - rvnSystem->DecRef(); + rvnSystem->UnRef(); } return retval; @@ -3650,7 +3650,7 @@ bool VaultSetCCRStatus (bool online) { VaultSystemNode sysNode(rvnSystem); sysNode.SetCCRStatus(online ? 1 : 0); - rvnSystem->DecRef(); + rvnSystem->UnRef(); retval = true; } @@ -3689,13 +3689,13 @@ bool VaultAmInMyPersonalAge () { if (ageInfo.GetAgeInstanceGuid() == curAgeInfo.GetAgeInstanceGuid()) result = true; - currentAgeInfoNode->DecRef(); + currentAgeInfoNode->UnRef(); } - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - rvnLink->DecRef(); + rvnLink->UnRef(); } return result; @@ -3718,13 +3718,13 @@ bool VaultAmInMyNeighborhoodAge () { if (ageInfo.GetAgeInstanceGuid() == curAgeInfo.GetAgeInstanceGuid()) result = true; - currentAgeInfoNode->DecRef(); + currentAgeInfoNode->UnRef(); } - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - rvnLink->DecRef(); + rvnLink->UnRef(); } return result; @@ -3752,13 +3752,13 @@ bool VaultAmOwnerOfCurrentAge () { if (ageInfo.GetAgeInstanceGuid() == curAgeInfo.GetAgeInstanceGuid()) result = true; - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - rvnLink->DecRef(); + rvnLink->UnRef(); } - currentAgeInfoNode->DecRef(); + currentAgeInfoNode->UnRef(); } return result; @@ -3795,7 +3795,7 @@ bool VaultRegisterMTStationAndWait ( StrToAnsi(spawnPt, linkBackSpawnPtObjName, arrsize(spawnPt)); VaultAgeLinkNode link(rvn); link.AddSpawnPoint(plSpawnPointInfo(title, spawnPt)); - rvn->DecRef(); + rvn->UnRef(); return true; } return false; @@ -3804,7 +3804,7 @@ bool VaultRegisterMTStationAndWait ( //============================================================================ void VaultProcessVisitNote(RelVaultNode * rvnVisit) { if (RelVaultNode * rvnInbox = VaultGetPlayerInboxFolderIncRef()) { - rvnVisit->IncRef(); + rvnVisit->Ref(); VaultTextNoteNode visitAcc(rvnVisit); plAgeLinkStruct link; @@ -3814,16 +3814,16 @@ void VaultProcessVisitNote(RelVaultNode * rvnVisit) { } // remove it from the inbox VaultRemoveChildNode(rvnInbox->GetNodeId(), rvnVisit->GetNodeId(), nil, nil); - rvnVisit->DecRef(); + rvnVisit->UnRef(); - rvnInbox->DecRef(); + rvnInbox->UnRef(); } } //============================================================================ void VaultProcessUnvisitNote(RelVaultNode * rvnUnVisit) { if (RelVaultNode * rvnInbox = VaultGetPlayerInboxFolderIncRef()) { - rvnUnVisit->IncRef(); + rvnUnVisit->Ref(); VaultTextNoteNode unvisitAcc(rvnUnVisit); plAgeInfoStruct info; if (unvisitAcc.GetVisitInfo(&info)) { @@ -3832,9 +3832,9 @@ void VaultProcessUnvisitNote(RelVaultNode * rvnUnVisit) { } // remove it from the inbox VaultRemoveChildNode(rvnInbox->GetNodeId(), rvnUnVisit->GetNodeId(), nil, nil); - rvnUnVisit->DecRef(); + rvnUnVisit->UnRef(); - rvnInbox->DecRef(); + rvnInbox->UnRef(); } } @@ -3844,12 +3844,12 @@ void VaultProcessPlayerInbox () { { // Process new visit requests ARRAY(RelVaultNode*) visits; RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_TextNote); VaultTextNoteNode tmpAcc(templateNode); tmpAcc.SetNoteType(plVault::kNoteType_Visit); rvnInbox->GetChildNodesIncRef(templateNode, 1, &visits); - templateNode->DecRef(); + templateNode->UnRef(); for (unsigned i = 0; i < visits.Count(); ++i) { RelVaultNode * rvnVisit = visits[i]; @@ -3861,18 +3861,18 @@ void VaultProcessPlayerInbox () { } // remove it from the inbox VaultRemoveChildNode(rvnInbox->GetNodeId(), rvnVisit->GetNodeId(), nil, nil); - rvnVisit->DecRef(); + rvnVisit->UnRef(); } } { // Process new unvisit requests ARRAY(RelVaultNode*) unvisits; RelVaultNode * templateNode = new RelVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_TextNote); VaultTextNoteNode tmpAcc(templateNode); tmpAcc.SetNoteType(plVault::kNoteType_UnVisit); rvnInbox->GetChildNodesIncRef(templateNode, 1, &unvisits); - templateNode->DecRef(); + templateNode->UnRef(); for (unsigned i = 0; i < unvisits.Count(); ++i) { RelVaultNode * rvnUnVisit = unvisits[i]; @@ -3884,11 +3884,11 @@ void VaultProcessPlayerInbox () { } // remove it from the inbox VaultRemoveChildNode(rvnInbox->GetNodeId(), rvnUnVisit->GetNodeId(), nil, nil); - rvnUnVisit->DecRef(); + rvnUnVisit->UnRef(); } } - rvnInbox->DecRef(); + rvnInbox->UnRef(); } } @@ -3902,12 +3902,12 @@ void VaultProcessPlayerInbox () { //============================================================================ static RelVaultNode * GetAgeNode () { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_VNodeMgrAge); if (NetCommGetAge()) templateNode->SetNodeId(NetCommGetAge()->ageVaultId); RelVaultNode * result = GetNode(templateNode); - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -3915,13 +3915,13 @@ static RelVaultNode * GetAgeNode () { RelVaultNode * VaultGetAgeNodeIncRef () { RelVaultNode * result = nil; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_VNodeMgrAge); if (NetCommGetAge()) templateNode->SetNodeId(NetCommGetAge()->ageVaultId); if (RelVaultNode * rvnAge = VaultGetNodeIncRef(templateNode)) result = rvnAge; - templateNode->DecRef(); + templateNode->UnRef(); return result; } @@ -3933,18 +3933,18 @@ static RelVaultNode * GetAgeInfoNode () { RelVaultNode * result = nil; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); templateNode->SetCreatorId(rvnAge->GetNodeId()); if (RelVaultNode * rvnAgeInfo = rvnAge->GetChildNodeIncRef(templateNode, 1)) { - rvnAgeInfo->DecRef(); + rvnAgeInfo->UnRef(); result = rvnAgeInfo; } - templateNode->DecRef(); - rvnAge->DecRef(); + templateNode->UnRef(); + rvnAge->UnRef(); return result; } @@ -3957,15 +3957,15 @@ RelVaultNode * VaultGetAgeInfoNodeIncRef () { RelVaultNode * result = nil; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); templateNode->SetCreatorId(rvnAge->GetNodeId()); if (RelVaultNode * rvnAgeInfo = rvnAge->GetChildNodeIncRef(templateNode, 1)) result = rvnAgeInfo; - templateNode->DecRef(); - rvnAge->DecRef(); + templateNode->UnRef(); + rvnAge->UnRef(); return result; } @@ -4032,7 +4032,7 @@ RelVaultNode * VaultFindAgeSubAgeLinkIncRef (const plAgeInfoStruct * info) { if (RelVaultNode * rvnFldr = VaultGetAgeSubAgesFolderIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -4044,11 +4044,11 @@ RelVaultNode * VaultFindAgeSubAgeLinkIncRef (const plAgeInfoStruct * info) { templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_AgeLink); rvnLink = rvnInfo->GetParentNodeIncRef(templateNode, 1); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); } return rvnLink; @@ -4096,7 +4096,7 @@ RelVaultNode * VaultAgeAddDeviceAndWaitIncRef (const wchar_t deviceName[]) { } if (folder) - folder->DecRef(); + folder->UnRef(); return device; } @@ -4105,19 +4105,19 @@ RelVaultNode * VaultAgeAddDeviceAndWaitIncRef (const wchar_t deviceName[]) { void VaultAgeRemoveDevice (const wchar_t deviceName[]) { if (RelVaultNode * folder = VaultGetAgeDevicesFolderIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_TextNote); VaultTextNoteNode access(templateNode); access.SetNoteTitle(deviceName); if (RelVaultNode * device = folder->GetChildNodeIncRef(templateNode, 1)) { VaultRemoveChildNode(folder->GetNodeId(), device->GetNodeId(), nil, nil); - device->DecRef(); + device->UnRef(); if (DeviceInbox * deviceInbox = s_ageDeviceInboxes.Find(CHashKeyStr(deviceName))) delete device; } - templateNode->DecRef(); - folder->DecRef(); + templateNode->UnRef(); + folder->UnRef(); } } @@ -4126,16 +4126,16 @@ bool VaultAgeHasDevice (const wchar_t deviceName[]) { bool found = false; if (RelVaultNode * folder = VaultGetAgeDevicesFolderIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_TextNote); VaultTextNoteNode access(templateNode); access.SetNoteTitle(deviceName); if (RelVaultNode * device = folder->GetChildNodeIncRef(templateNode, 1)) { found = true; - device->DecRef(); + device->UnRef(); } - templateNode->DecRef(); - folder->DecRef(); + templateNode->UnRef(); + folder->UnRef(); } return found; } @@ -4145,14 +4145,14 @@ RelVaultNode * VaultAgeGetDeviceIncRef (const wchar_t deviceName[]) { RelVaultNode * result = nil; if (RelVaultNode * folder = VaultGetAgeDevicesFolderIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_TextNote); VaultTextNoteNode access(templateNode); access.SetNoteTitle(deviceName); if (RelVaultNode * device = folder->GetChildNodeIncRef(templateNode, 1)) result = device; - templateNode->DecRef(); - folder->DecRef(); + templateNode->UnRef(); + folder->UnRef(); } return result; } @@ -4217,14 +4217,14 @@ RelVaultNode * VaultAgeGetDeviceInboxIncRef (const wchar_t deviceName[]) { if (parentNode) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_Folder); VaultFolderNode access(templateNode); access.SetFolderType(plVault::kDeviceInboxFolder); access.SetFolderName(devInbox->inboxName); result = parentNode->GetChildNodeIncRef(templateNode, 1); - templateNode->DecRef(); - parentNode->DecRef(); + templateNode->UnRef(); + parentNode->UnRef(); } } return result; @@ -4248,9 +4248,9 @@ bool VaultAgeGetAgeSDL (plStateDataRecord * out) { sdl.InitStateDataRecord(sdl.GetSDLName()); result = sdl.GetStateDataRecord(out, plSDL::kKeepDirty); } - rvnSdl->DecRef(); + rvnSdl->UnRef(); } - rvn->DecRef(); + rvn->UnRef(); } return result; } @@ -4261,9 +4261,9 @@ void VaultAgeUpdateAgeSDL (const plStateDataRecord * rec) { if (RelVaultNode * rvnSdl = rvn->GetChildNodeIncRef(plVault::kNodeType_SDL, 1)) { VaultSDLNode sdl(rvnSdl); sdl.SetStateDataRecord(rec, plSDL::kDirtyOnly | plSDL::kTimeStampOnRead); - rvnSdl->DecRef(); + rvnSdl->UnRef(); } - rvn->DecRef(); + rvn->UnRef(); } } @@ -4281,7 +4281,7 @@ RelVaultNode * VaultGetSubAgeLinkIncRef (const plAgeInfoStruct * info) { if (RelVaultNode * rvnFldr = VaultGetAgeSubAgesFolderIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -4293,11 +4293,11 @@ RelVaultNode * VaultGetSubAgeLinkIncRef (const plAgeInfoStruct * info) { templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_AgeLink); rvnLink = rvnInfo->GetParentNodeIncRef(templateNode, 1); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - templateNode->DecRef(); - rvnFldr->DecRef(); + templateNode->UnRef(); + rvnFldr->UnRef(); } return rvnLink; @@ -4310,11 +4310,11 @@ bool VaultAgeGetSubAgeLink (const plAgeInfoStruct * info, plAgeLinkStruct * link if (RelVaultNode * rvnInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode ageInfo(rvnInfo); ageInfo.CopyTo(link->GetAgeInfo()); - rvnInfo->DecRef(); + rvnInfo->UnRef(); result = true; } - rvnLink->DecRef(); + rvnLink->UnRef(); } return result; @@ -4396,8 +4396,8 @@ bool VaultAgeFindOrCreateSubAgeLinkAndWait ( if (RelVaultNode * rvnInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode infoAcc(rvnInfo); infoAcc.CopyTo(link->GetAgeInfo()); - rvnInfo->DecRef(); - rvnLink->DecRef(); + rvnInfo->UnRef(); + rvnLink->UnRef(); return true; } } @@ -4410,7 +4410,7 @@ bool VaultAgeFindOrCreateSubAgeLinkAndWait ( if (RelVaultNode * rvnSubAges = VaultGetAgeSubAgesFolderIncRef()) { subAgesId = rvnSubAges->GetNodeId(); - rvnSubAges->DecRef(); + rvnSubAges->UnRef(); } else { LogMsg(kLogError, L"CreateSubAge: Failed to get ages's SubAges folder"); @@ -4536,13 +4536,13 @@ bool VaultAgeFindOrCreateSubAgeLinkAndWait ( if (RelVaultNode * rvnLink = VaultGetNodeIncRef(ageLinkId)) { VaultAgeLinkNode linkAcc(rvnLink); linkAcc.CopyTo(link); - rvnLink->DecRef(); + rvnLink->UnRef(); } if (RelVaultNode * rvnInfo = VaultGetNodeIncRef(ageInfoId)) { VaultAgeInfoNode infoAcc(rvnInfo); infoAcc.CopyTo(link->GetAgeInfo()); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } return true; @@ -4560,7 +4560,7 @@ namespace _VaultCreateSubAge { VaultAddChildNode(node->GetNodeId(), (uint32_t)((uintptr_t)param), 0, nil, nil); if (RelVaultNode* saFldr = VaultGetAgeSubAgesFolderIncRef()) { VaultAddChildNode(saFldr->GetNodeId(), node->GetNodeId(), 0, nil, nil); - saFldr->DecRef(); + saFldr->UnRef(); } else LogMsg(kLogError, "CreateSubAge: Couldn't find SubAges folder (async)"); @@ -4614,10 +4614,10 @@ bool VaultAgeFindOrCreateSubAgeLink(const plAgeInfoStruct* info, plAgeLinkStruct if (RelVaultNode* rvnInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode accInfo(rvnInfo); accInfo.CopyTo(link->GetAgeInfo()); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - rvnLink->DecRef(); + rvnLink->UnRef(); return true; } @@ -4716,7 +4716,7 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait ( pinfo.SetAgeFilename(ansi); if (RelVaultNode * rvnAgeLink = VaultGetOwnedAgeLinkIncRef(&pinfo)) { rvnAgeInfo = rvnAgeLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1); - rvnAgeLink->DecRef(); + rvnAgeLink->UnRef(); } } else { @@ -4733,16 +4733,16 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait ( childAgesId = rvnChildAges->GetNodeId(); } else { - rvnAgeInfo->DecRef(); + rvnAgeInfo->UnRef(); LogMsg(kLogError, L"CreateChildAge: Failed to get ages's ChildAges folder"); return false; } - rvnAgeInfo->DecRef(); + rvnAgeInfo->UnRef(); // Check for existing child age in folder RelVaultNode * rvnLink = nil; NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); @@ -4754,16 +4754,16 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait ( templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_AgeLink); rvnLink = rvnInfo->GetParentNodeIncRef(templateNode, 1); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } - templateNode->DecRef(); - rvnChildAges->DecRef(); + templateNode->UnRef(); + rvnChildAges->UnRef(); if (rvnLink) { VaultAgeLinkNode access(rvnLink); access.CopyTo(link); - rvnLink->DecRef(); + rvnLink->UnRef(); return true; } } @@ -4776,7 +4776,7 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait ( if (RelVaultNode * rvnAge = VaultGetAgeNodeIncRef()) { VaultAgeNode access(rvnAge); parentAgeInstId = access.GetAgeInstanceGuid(); - rvnAge->DecRef(); + rvnAge->UnRef(); } VaultInitAge( @@ -4894,13 +4894,13 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait ( if (RelVaultNode * rvnLink = VaultGetNodeIncRef(ageLinkId)) { VaultAgeLinkNode linkAcc(rvnLink); linkAcc.CopyTo(link); - rvnLink->DecRef(); + rvnLink->UnRef(); } if (RelVaultNode * rvnInfo = VaultGetNodeIncRef(ageInfoId)) { VaultAgeInfoNode infoAcc(rvnInfo); infoAcc.CopyTo(link->GetAgeInfo()); - rvnInfo->DecRef(); + rvnInfo->UnRef(); } return true; @@ -4988,7 +4988,7 @@ uint8_t VaultAgeFindOrCreateChildAgeLink( RelVaultNode* rvnParentInfo = nil; if (RelVaultNode* rvnParentLink = VaultGetOwnedAgeLinkIncRef(&search)) { rvnParentInfo = rvnParentLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1); - rvnParentLink->DecRef(); + rvnParentLink->UnRef(); } else // Fallback to current age rvnParentInfo = VaultGetAgeInfoNodeIncRef(); @@ -5018,8 +5018,8 @@ uint8_t VaultAgeFindOrCreateChildAgeLink( VaultAgeInfoNode accAgeInfo(rvnAgeInfo); accAgeInfo.CopyTo(link->GetAgeInfo()); - rvnAgeLink->DecRef(); - rvnAgeInfo->DecRef(); + rvnAgeLink->UnRef(); + rvnAgeInfo->UnRef(); retval = true; } else { @@ -5036,11 +5036,11 @@ uint8_t VaultAgeFindOrCreateChildAgeLink( retval = false; } - temp->DecRef(); - rvnChildAges->DecRef(); + temp->UnRef(); + rvnChildAges->UnRef(); } - rvnParentInfo->DecRef(); + rvnParentInfo->UnRef(); return retval; } @@ -5166,12 +5166,12 @@ RelVaultNode * VaultGetSystemNodeIncRef () { RelVaultNode * result = nil; if (RelVaultNode * player = VaultGetPlayerNodeIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_System); if (RelVaultNode * systemNode = player->GetChildNodeIncRef(templateNode, 1)) result = systemNode; - templateNode->DecRef(); - player->DecRef(); + templateNode->UnRef(); + player->UnRef(); } return result; } @@ -5181,14 +5181,14 @@ RelVaultNode * VaultGetGlobalInboxIncRef () { RelVaultNode * result = nil; if (RelVaultNode * system = VaultGetSystemNodeIncRef()) { NetVaultNode * templateNode = new NetVaultNode; - templateNode->IncRef(); + templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_Folder); VaultFolderNode folder(templateNode); folder.SetFolderType(plVault::kGlobalInboxFolder); if (RelVaultNode * inbox = system->GetChildNodeIncRef(templateNode, 1)) result = inbox; - templateNode->DecRef(); - system->DecRef(); + templateNode->UnRef(); + system->UnRef(); } return result; } diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp index f9529765..1dbf2312 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp @@ -439,10 +439,10 @@ bool VaultAgeLinkNode::CopyTo (plAgeLinkStruct * link) { if (RelVaultNode * info = me->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode access(info); access.CopyTo(link->GetAgeInfo()); - me->DecRef(); + me->UnRef(); return true; } - me->DecRef(); + me->UnRef(); } link->Clear(); return false; From 23a071860e9eb3695380148e3855fb61b2598a87 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 8 Apr 2014 20:41:50 -0700 Subject: [PATCH 3/4] pnUtRef started at zero refs instead of one, and this is simpler than finding and removing all the extra Ref() calls. --- Sources/Plasma/CoreLib/hsRefCnt.h | 5 +++-- .../Private/Win32/pnAceW32Thread.cpp | 14 ++++++++------ Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp | 2 ++ .../pnNetProtocol/Private/pnNpCommon.cpp | 2 +- .../PubUtilLib/plNetGameLib/Private/plNglAuth.cpp | 2 +- .../PubUtilLib/plNetGameLib/Private/plNglFile.cpp | 3 ++- .../PubUtilLib/plNetGameLib/Private/plNglGame.cpp | 3 ++- .../plNetGameLib/Private/plNglGateKeeper.cpp | 2 +- .../PubUtilLib/plNetGameLib/Private/plNglTrans.cpp | 3 ++- 9 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsRefCnt.h b/Sources/Plasma/CoreLib/hsRefCnt.h index e4c0721e..5a945fda 100644 --- a/Sources/Plasma/CoreLib/hsRefCnt.h +++ b/Sources/Plasma/CoreLib/hsRefCnt.h @@ -47,8 +47,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com class hsRefCnt { private: int fRefCnt; + public: - hsRefCnt() : fRefCnt(1) {} + hsRefCnt(int initRefs = 1) : fRefCnt(initRefs) {} virtual ~hsRefCnt(); inline int RefCnt() const { return fRefCnt; } @@ -75,7 +76,7 @@ private: std::atomic fRefCnt; public: - hsAtomicRefCnt() : fRefCnt(1) { } + hsAtomicRefCnt(int initRefs = 1) : fRefCnt(initRefs) { } virtual ~hsAtomicRefCnt(); inline int RefCnt() const { return fRefCnt; } diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp index 40eb11d6..df50c909 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp @@ -48,6 +48,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../../Pch.h" #pragma hdrstop +#include "hsRefCnt.h" + /***************************************************************************** * @@ -55,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com * ***/ -struct AsyncThreadTaskList : AtomicRef { +struct AsyncThreadTaskList : hsAtomicRefCnt { ENetError error; AsyncThreadTaskList (); ~AsyncThreadTaskList (); @@ -79,7 +81,7 @@ static HANDLE s_taskPort; //=========================================================================== AsyncThreadTaskList::AsyncThreadTaskList () -: error(kNetSuccess) +: hsAtomicRefCnt(0), error(kNetSuccess) { PerfAddCounter(kAsyncPerfThreadTaskListCount, 1); } @@ -139,7 +141,7 @@ static unsigned THREADCALL ThreadTaskProc (AsyncThread * thread) { if (task) { task->callback(task->param, task->taskList->error); - task->taskList->DecRef("task"); + task->taskList->Ref("task"); delete task; } } @@ -227,7 +229,7 @@ void AsyncThreadTaskSetThreadCount (unsigned threads) { AsyncThreadTaskList * AsyncThreadTaskListCreate () { ASSERT(s_taskPort); AsyncThreadTaskList * taskList = new AsyncThreadTaskList; - taskList->IncRef("TaskList"); + taskList->Ref("TaskList"); return taskList; } @@ -241,7 +243,7 @@ void AsyncThreadTaskListDestroy ( ASSERT(!taskList->error); taskList->error = error; - taskList->DecRef(); // REF:TaskList + taskList->UnRef(); // REF:TaskList } //=========================================================================== @@ -263,7 +265,7 @@ void AsyncThreadTaskAdd ( task->callback = callback; task->param = param; StrCopy(task->debugStr, debugStr, arrsize(task->debugStr)); // this will be sent with the deadlock checker email if this thread exceeds time set in plServer.ini - taskList->IncRef("Task"); + taskList->Ref("Task"); PostQueuedCompletionStatus(s_taskPort, 0, (DWORD) task, NULL); } diff --git a/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp b/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp index 058b3e53..467d880c 100644 --- a/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp +++ b/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp @@ -74,6 +74,8 @@ private: }; struct NetMsgChannel : hsAtomicRefCnt { + NetMsgChannel() : hsAtomicRefCnt(0) { } + uint32_t m_protocol; bool m_server; diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp index cf6c209e..a7762282 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp @@ -315,7 +315,7 @@ void NetVaultNode::DeallocNodeFields () { //============================================================================ NetVaultNode::NetVaultNode () - : fieldFlags(0), dirtyFlags(0) + : hsAtomicRefCnt(0), fieldFlags(0), dirtyFlags(0) , nodeId(0), createTime(0), modifyTime(0) , createAgeName(nil), creatorId(0) , nodeType(0) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index ae0109eb..ec7a0f80 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -1589,7 +1589,7 @@ static unsigned CliAuConnPingTimerProc (void * param) { //============================================================================ CliAuConn::CliAuConn () - : reconnectTimer(nil), reconnectStartMs(0) + : hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0) , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) , sock(nil), cli(nil), seq(0), serverChallenge(0) , cancelId(nil), abandoned(false) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index b873a95f..19c142a8 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -581,7 +581,8 @@ static void AsyncLookupCallback ( //============================================================================ CliFileConn::CliFileConn () - : sock(nil), seq(0), cancelId(nil), abandoned(false), buildId(0), serverType(0) + : hsAtomicRefCnt(0), sock(nil), seq(0), cancelId(nil), abandoned(false) + , buildId(0), serverType(0) , reconnectTimer(nil), reconnectStartMs(0), connectStartMs(0) , numImmediateDisconnects(0), numFailedConnects(0) , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp index 00d46023..1ac3fb15 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp @@ -415,7 +415,8 @@ static unsigned CliGmConnPingTimerProc (void * param) { //============================================================================ CliGmConn::CliGmConn () - : sock(nil), cancelId(nil), cli(nil), seq(0), abandoned(false) + : hsAtomicRefCnt(0), sock(nil), cancelId(nil), cli(nil) + , seq(0), abandoned(false) , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) { AtomicAdd(&s_perf[kPerfConnCount], 1); diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index cc5ccfde..70b260e5 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp @@ -525,7 +525,7 @@ static unsigned CliGkConnPingTimerProc (void * param) { //============================================================================ CliGkConn::CliGkConn () - : reconnectTimer(nil), reconnectStartMs(0) + : hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0) , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) , sock(nil), cli(nil), seq(0), serverChallenge(0) , cancelId(nil), abandoned(false) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp index 988236a1..b6a164a4 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp @@ -117,7 +117,8 @@ static void CancelTrans_CS (NetTrans * trans, ENetError error) { //============================================================================ NetTrans::NetTrans (ENetProtocol protocol, ETransType transType) -: m_state(kTransStateWaitServerConnect) +: hsAtomicRefCnt(0) +, m_state(kTransStateWaitServerConnect) , m_result(kNetPending) , m_transId(0) , m_connId(0) From 34b2eb183606b2f243dc834a64670d5e41dca58d Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 8 Apr 2014 21:38:46 -0700 Subject: [PATCH 4/4] More std::atomic and friends --- Sources/Plasma/CoreLib/HeadSpin.h | 15 --------- .../Plasma/FeatureLib/pfGameMgr/pfGameMgr.cpp | 10 ++---- .../pnAsyncCoreExe/Private/Nt/pnAceNt.cpp | 18 ++--------- .../pnAsyncCoreExe/Private/Nt/pnAceNtInt.h | 8 ++--- .../Private/Nt/pnAceNtSocket.cpp | 15 +++++---- .../NucleusLib/pnAsyncCoreExe/pnAceCore.cpp | 9 +++--- .../plNetClientComm/plNetClientComm.cpp | 6 ++-- .../Plasma/PubUtilLib/plNetGameLib/Intern.h | 2 +- .../plNetGameLib/Private/plNglAuth.cpp | 6 ++-- .../plNetGameLib/Private/plNglCore.cpp | 6 ++-- .../plNetGameLib/Private/plNglFile.cpp | 6 ++-- .../plNetGameLib/Private/plNglGame.cpp | 6 ++-- .../plNetGameLib/Private/plNglGateKeeper.cpp | 6 ++-- .../plNetGameLib/Private/plNglTrans.cpp | 10 +++--- .../PubUtilLib/plVault/plVaultClientApi.cpp | 32 +++++++++---------- 15 files changed, 61 insertions(+), 94 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index 5fd53a70..4b5648c5 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -489,19 +489,4 @@ void DebugMsg(const char* fmt, ...); #define DEFAULT_FATAL(var) default: FATAL("No valid case for switch variable '" #var "'"); break; #endif -/***************************************************************************** -* -* Atomic Operations -* FIXME: Replace with std::atomic when VS2012 supports WinXP -* -***/ - -#ifdef _MSC_VER -# define AtomicAdd(value, increment) InterlockedExchangeAdd(value, increment) -# define AtomicSet(value, set) InterlockedExchange(value, set) -#elif __GNUC__ -# define AtomicAdd(value, increment) __sync_fetch_and_add(value, increment) -# define AtomicSet(value, set) __sync_lock_test_and_set(value, set) -#endif - #endif diff --git a/Sources/Plasma/FeatureLib/pfGameMgr/pfGameMgr.cpp b/Sources/Plasma/FeatureLib/pfGameMgr/pfGameMgr.cpp index 61b88b88..39f4043f 100644 --- a/Sources/Plasma/FeatureLib/pfGameMgr/pfGameMgr.cpp +++ b/Sources/Plasma/FeatureLib/pfGameMgr/pfGameMgr.cpp @@ -133,8 +133,8 @@ static HASHTABLEDECL(TransState, THashKeyVal, link) s_trans; static HASHTABLEDECL(IGameCli, THashKeyVal, link) s_games; static std::map s_factories; -static long s_transId; -static ARRAYOBJ(plKey) s_receivers; +static std::atomic s_transId; +static ARRAYOBJ(plKey) s_receivers; /***************************************************************************** @@ -163,11 +163,7 @@ AUTO_INIT_FUNC (SetGameMgrMsgHandler) { //============================================================================ static inline unsigned INextTransId () { - - unsigned transId = AtomicAdd(&s_transId, 1); - while (!transId) - transId = AtomicAdd(&s_transId, 1); - return transId; + return ++s_transId; } diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.cpp index 1475ede2..277a5eea 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.cpp @@ -80,7 +80,6 @@ static unsigned s_pageSizeMask; //=========================================================================== CNtWaitHandle::CNtWaitHandle () { - m_refCount = 1; m_event = CreateEvent( (LPSECURITY_ATTRIBUTES) nil, true, // manual reset @@ -94,17 +93,6 @@ CNtWaitHandle::~CNtWaitHandle () { CloseHandle(m_event); } -//=========================================================================== -void CNtWaitHandle::IncRef () { - InterlockedIncrement(&m_refCount); -} - -//=========================================================================== -void CNtWaitHandle::DecRef () { - if (!InterlockedDecrement(&m_refCount)) - delete this; -} - //=========================================================================== bool CNtWaitHandle::WaitForObject (unsigned timeMs) const { return WAIT_TIMEOUT != WaitForSingleObject(m_event, timeMs); @@ -189,7 +177,7 @@ static void INtOpDispatch ( // set event *after* operation is complete if (signalComplete) { signalComplete->SignalObject(); - signalComplete->DecRef(); + signalComplete->UnRef(); } // if we just deleted the last operation then stop dispatching @@ -203,7 +191,7 @@ static void INtOpDispatch ( if (op->pending) break; - InterlockedDecrement(&ntObj->ioCount); + --ntObj->ioCount; } ntObj->critsect.Leave(); @@ -300,7 +288,7 @@ bool INtConnInitialize (NtObject * ntObj) { //=========================================================================== void INtConnCompleteOperation (NtObject * ntObj) { // are we completing the last operation for this object? - if (InterlockedDecrement(&ntObj->ioCount)) + if (--ntObj->ioCount) return; DWORD err = GetLastError(); diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h index f142836e..24effcaa 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h @@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #endif #define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_NT_PNACENTINT_H +#include "hsRefCnt.h" namespace Nt { @@ -87,15 +88,12 @@ public: BOOL TryEnter () { return TryEnterCriticalSection(&m_handle); } }; -class CNtWaitHandle { - long m_refCount; +class CNtWaitHandle : public hsAtomicRefCnt { HANDLE m_event; public: CNtWaitHandle (); ~CNtWaitHandle (); - void IncRef (); - void DecRef (); bool WaitForObject (unsigned timeMs) const; void SignalObject () const; }; @@ -131,7 +129,7 @@ struct NtObject { LISTDECL(Operation, link) opList; long nextCompleteSequence; long nextStartSequence; - long ioCount; + std::atomic ioCount; bool closed; NtObject() diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp index 0437681f..ab4cd404 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp @@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #pragma hdrstop #include "pnAceNtInt.h" +#include namespace Nt { @@ -222,7 +223,7 @@ static void SocketStartAsyncRead (NtSock * sock) { bool readResult; sock->critsect.Enter(); if (sock->handle != INVALID_HANDLE_VALUE) { - InterlockedIncrement(&sock->ioCount); + ++sock->ioCount; readResult = ReadFile( sock->handle, sock->buffer + sock->bytesLeft, @@ -238,7 +239,7 @@ static void SocketStartAsyncRead (NtSock * sock) { DWORD err = GetLastError(); if (!readResult && (err != ERROR_IO_PENDING)) - InterlockedDecrement(&sock->ioCount); + --sock->ioCount; } //=========================================================================== @@ -378,7 +379,7 @@ static NtOpSocketWrite * SocketQueueAsyncWrite ( op->write.bytesProcessed = bytes; memcpy(op->write.buffer, data, bytes); - InterlockedIncrement(&sock->ioCount); + ++sock->ioCount; PerfAddCounter(kAsyncPerfSocketBytesWaitQueued, bytes); return op; @@ -1022,8 +1023,8 @@ void INtSocketOpCompleteSocketRead ( || ((sock->opRead.read.bytesProcessed + sock->bytesLeft) > sizeof(sock->buffer)) ) { #ifdef HS_DEBUGGING - static long s_once; - if (!AtomicAdd(&s_once, 1)) { + static std::once_flag s_once; + std::call_once(s_once, [sock]() { DumpInvalidData( "NtSockErr.log", sizeof(sock->buffer), @@ -1034,7 +1035,7 @@ void INtSocketOpCompleteSocketRead ( sock->opRead.read.bytes, sock->opRead.read.bytesProcessed ); - } + }); #endif // ifdef HS_DEBUGGING LogMsg( @@ -1419,7 +1420,7 @@ bool NtSocketWrite ( op->write.bytesProcessed = bytes; PerfAddCounter(kAsyncPerfSocketBytesWaitQueued, bytes); - InterlockedIncrement(&sock->ioCount); + ++sock->ioCount; if (op == sock->opList.Head()) result = INtSocketOpCompleteQueuedSocketWrite((NtSock *) sock, op); diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceCore.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceCore.cpp index 8d109840..98322fe4 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceCore.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceCore.cpp @@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "Pch.h" #pragma hdrstop +#include /***************************************************************************** * @@ -55,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com * ***/ -static long s_perf[kNumAsyncPerfCounters]; +static std::atomic s_perf[kNumAsyncPerfCounters]; /**************************************************************************** @@ -124,19 +125,19 @@ static void IAsyncInitForServer () { //============================================================================ long PerfAddCounter (unsigned id, unsigned n) { ASSERT(id < kNumAsyncPerfCounters); - return AtomicAdd(&s_perf[id], n); + return s_perf[id].fetch_add(n); } //============================================================================ long PerfSubCounter (unsigned id, unsigned n) { ASSERT(id < kNumAsyncPerfCounters); - return AtomicAdd(&s_perf[id], -(signed)n); + return s_perf[id].fetch_sub(n); } //============================================================================ long PerfSetCounter (unsigned id, unsigned n) { ASSERT(id < kNumAsyncPerfCounters); - return AtomicSet(&s_perf[id], n); + return s_perf[id].exchange(n); } diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index f89e2e98..4ee6e878 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -815,10 +815,10 @@ void NetCommActivatePostInitErrorHandler () { //============================================================================ void NetCommUpdate () { // plClient likes to recursively call us on occasion; debounce that crap. - static long s_updating; - if (0 == AtomicSet(&s_updating, 1)) { + static std::atomic_flag s_updating = ATOMIC_FLAG_INIT; + if (!s_updating.test_and_set()) { NetClientUpdate(); - AtomicSet(&s_updating, 0); + s_updating.clear(); } } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h b/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h index 363347a3..8aff7722 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h @@ -273,7 +273,7 @@ static const char * s_transTypes[] = { }; static_assert(arrsize(s_transTypes) == kNumTransTypes, "Ngl Trans array and enum differ in size"); -static long s_perfTransCount[kNumTransTypes]; +static std::atomic s_perfTransCount[kNumTransTypes]; namespace Auth { struct CliAuConn; } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index ec7a0f80..b93b55d5 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -1208,7 +1208,7 @@ static ShaDigest s_accountNamePassHash; static wchar_t s_authToken[kMaxPublisherAuthKeyLength]; static wchar_t s_os[kMaxGTOSIdLength]; -static long s_perf[kNumPerf]; +static std::atomic s_perf[kNumPerf]; static uint32_t s_encryptionKey[4]; @@ -1596,14 +1596,14 @@ CliAuConn::CliAuConn () { memset(name, 0, sizeof(name)); - AtomicAdd(&s_perf[kPerfConnCount], 1); + ++s_perf[kPerfConnCount]; } //============================================================================ CliAuConn::~CliAuConn () { if (cli) NetCliDelete(cli, true); - AtomicAdd(&s_perf[kPerfConnCount], -1); + --s_perf[kPerfConnCount]; } //=========================================================================== diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.cpp index 8890b699..843aaacd 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.cpp @@ -77,7 +77,7 @@ struct ReportNetErrorTrans : NetNotifyTrans { ***/ static FNetClientErrorProc s_errorProc; -static long s_initCount; +static std::atomic s_initCount; /***************************************************************************** @@ -143,7 +143,7 @@ void ReportNetError (ENetProtocol protocol, ENetError error) { //============================================================================ void NetClientInitialize () { - if (0 == AtomicAdd(&s_initCount, 1)) { + if (0 == s_initCount.fetch_add(1)) { NetTransInitialize(); AuthInitialize(); GameInitialize(); @@ -160,7 +160,7 @@ void NetClientCancelAllTrans () { //============================================================================ void NetClientDestroy (bool wait) { - if (1 == AtomicAdd(&s_initCount, -1)) { + if (1 == s_initCount.fetch_sub(1)) { s_errorProc = nil; GateKeeperDestroy(false); diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index 19c142a8..a808f4ac 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -225,7 +225,7 @@ static bool s_running; static CCritSect s_critsect; static LISTDECL(CliFileConn, link) s_conns; static CliFileConn * s_active; -static long s_perf[kNumPerf]; +static std::atomic s_perf[kNumPerf]; static unsigned s_connectBuildId; static unsigned s_serverType; @@ -588,7 +588,7 @@ CliFileConn::CliFileConn () , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) { memset(name, 0, sizeof(name)); - AtomicAdd(&s_perf[kPerfConnCount], 1); + ++s_perf[kPerfConnCount]; } //============================================================================ @@ -596,7 +596,7 @@ CliFileConn::~CliFileConn () { ASSERT(!cancelId); ASSERT(!reconnectTimer); Destroy(); - AtomicAdd(&s_perf[kPerfConnCount], -1); + --s_perf[kPerfConnCount]; } //=========================================================================== diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp index 1ac3fb15..49e5d79a 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp @@ -156,7 +156,7 @@ static LISTDECL(CliGmConn, link) s_conns; static CliGmConn * s_active; static FNetCliGameRecvBufferHandler s_bufHandler; static FNetCliGameRecvGameMgrMsgHandler s_gameMgrMsgHandler; -static long s_perf[kNumPerf]; +static std::atomic s_perf[kNumPerf]; /***************************************************************************** @@ -419,14 +419,14 @@ CliGmConn::CliGmConn () , seq(0), abandoned(false) , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) { - AtomicAdd(&s_perf[kPerfConnCount], 1); + ++s_perf[kPerfConnCount]; } //============================================================================ CliGmConn::~CliGmConn () { if (cli) NetCliDelete(cli, true); - AtomicAdd(&s_perf[kPerfConnCount], -1); + --s_perf[kPerfConnCount]; } //============================================================================ diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index 70b260e5..91fc7a0c 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp @@ -188,7 +188,7 @@ static CCritSect s_critsect; static LISTDECL(CliGkConn, link) s_conns; static CliGkConn * s_active; -static long s_perf[kNumPerf]; +static std::atomic s_perf[kNumPerf]; @@ -532,14 +532,14 @@ CliGkConn::CliGkConn () { memset(name, 0, sizeof(name)); - AtomicAdd(&s_perf[kPerfConnCount], 1); + ++s_perf[kPerfConnCount]; } //============================================================================ CliGkConn::~CliGkConn () { if (cli) NetCliDelete(cli, true); - AtomicAdd(&s_perf[kPerfConnCount], -1); + --s_perf[kPerfConnCount]; } //=========================================================================== diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp index b6a164a4..aa611a1d 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp @@ -66,7 +66,7 @@ static const unsigned kDefaultTimeoutMs = 5 * 60 * 1000; static bool s_running; static CCritSect s_critsect; static LISTDECL(NetTrans, m_link) s_transactions; -static long s_perf[kNumPerf]; +static std::atomic s_perf[kNumPerf]; static unsigned s_timeoutMs = kDefaultTimeoutMs; @@ -127,16 +127,16 @@ NetTrans::NetTrans (ENetProtocol protocol, ETransType transType) , m_timeoutAtMs(0) , m_transType(transType) { - AtomicAdd(&s_perf[kPerfCurrTransactions], 1); - AtomicAdd(&s_perfTransCount[m_transType], 1); + ++s_perf[kPerfCurrTransactions]; + ++s_perfTransCount[m_transType]; // DebugMsg("%s@%p created", s_transTypes[m_transType], this); } //============================================================================ NetTrans::~NetTrans () { ASSERT(!m_link.IsLinked()); - AtomicAdd(&s_perfTransCount[m_transType], -1); - AtomicAdd(&s_perf[kPerfCurrTransactions], -1); + --s_perfTransCount[m_transType]; + --s_perf[kPerfCurrTransactions]; // DebugMsg("%s@%p destroyed", s_transTypes[m_transType], this); } diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp index 3a16e831..8b671160 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp @@ -250,7 +250,7 @@ struct AddChildNodeFetchTrans { FVaultAddChildNodeCallback callback; void * cbParam; ENetError result; - long opCount; + std::atomic opCount; AddChildNodeFetchTrans() : callback(nil), cbParam(nil), result(kNetSuccess), opCount(0) { } @@ -1019,12 +1019,11 @@ void AddChildNodeFetchTrans::VaultNodeRefsFetched ( param, &incFetchCount ); - AtomicAdd(&trans->opCount, incFetchCount); + trans->opCount += incFetchCount; } // Make the callback now if there are no nodes to fetch, or if error - AtomicAdd(&trans->opCount, -1); - if (!trans->opCount) { + if (!(--trans->opCount)) { if (trans->callback) trans->callback( trans->result, @@ -1046,9 +1045,8 @@ void AddChildNodeFetchTrans::VaultNodeFetched ( if (IS_NET_ERROR(result)) trans->result = result; - - AtomicAdd(&trans->opCount, -1); - if (!trans->opCount) { + + if (!(--trans->opCount)) { if (trans->callback) trans->callback( trans->result, @@ -1793,13 +1791,13 @@ void VaultAddChildNode ( // One or more nodes need to be fetched before the callback is made AddChildNodeFetchTrans * trans = new AddChildNodeFetchTrans(callback, param); if (!childLink->node->GetNodeType()) { - AtomicAdd(&trans->opCount, 1); + ++trans->opCount; NetCliAuthVaultNodeFetch( childId, AddChildNodeFetchTrans::VaultNodeFetched, trans ); - AtomicAdd(&trans->opCount, 1); + ++trans->opCount; NetCliAuthVaultFetchNodeRefs( childId, AddChildNodeFetchTrans::VaultNodeRefsFetched, @@ -1807,13 +1805,13 @@ void VaultAddChildNode ( ); } if (!parentLink->node->GetNodeType()) { - AtomicAdd(&trans->opCount, 1); + ++trans->opCount; NetCliAuthVaultNodeFetch( parentId, AddChildNodeFetchTrans::VaultNodeFetched, trans ); - AtomicAdd(&trans->opCount, 1); + ++trans->opCount; NetCliAuthVaultFetchNodeRefs( parentId, AddChildNodeFetchTrans::VaultNodeRefsFetched, @@ -2218,8 +2216,7 @@ namespace _VaultFetchNodesAndWait { ) { ::VaultNodeFetched(result, nil, node); - long * nodeCount = (long *)param; - AtomicAdd(nodeCount, -1); + --(*reinterpret_cast*>(param)); } } // namespace _VaultFetchNodesAndWait @@ -2231,20 +2228,21 @@ void VaultFetchNodesAndWait ( ) { using namespace _VaultFetchNodesAndWait; - long nodeCount = (long)count; + std::atomic nodeCount(count); for (unsigned i = 0; i < count; ++i) { if (!force) { // See if we already have this node if (RelVaultNodeLink * link = s_nodes.Find(nodeIds[i])) { - AtomicAdd(&nodeCount, -1); + --nodeCount; continue; } } - // Start fetching the node - NetCliAuthVaultNodeFetch(nodeIds[i], _VaultNodeFetched, (void *)&nodeCount); + // Start fetching the node + NetCliAuthVaultNodeFetch(nodeIds[i], _VaultNodeFetched, + reinterpret_cast(&nodeCount)); } while (nodeCount) {