From aee2f7f7ca8438ac6ae78ad42596675371bb8f87 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sun, 1 Jun 2014 13:29:19 -0700 Subject: [PATCH] Make hsRefCnt atomic, and merge with hsAtomicRefCnt --- Sources/Plasma/CoreLib/hsRefCnt.cpp | 43 ++++----------- Sources/Plasma/CoreLib/hsRefCnt.h | 55 ++++++------------- .../pfPython/pyAgeInfoStructGlue.cpp | 2 +- .../pfPython/pyAgeLinkStructGlue.cpp | 2 +- .../pfPython/pyNetServerSessionInfo.h | 2 +- .../pfPython/pyNetServerSessionInfoGlue.cpp | 4 +- .../pfPython/pyVaultPlayerInfoListNode.cpp | 2 +- .../pnAsyncCoreExe/Private/Nt/pnAceNtInt.h | 2 +- .../Private/Win32/pnAceW32Thread.cpp | 4 +- .../NucleusLib/pnNetCli/pnNcChannel.cpp | 4 +- .../pnNetProtocol/Private/pnNpCommon.cpp | 2 +- .../pnNetProtocol/Private/pnNpCommon.h | 2 +- .../plNetCommon/plNetServerSessionInfo.cpp | 21 ++++++- .../plNetCommon/plNetServerSessionInfo.h | 2 +- .../Plasma/PubUtilLib/plNetGameLib/Intern.h | 2 +- .../plNetGameLib/Private/plNglAuth.cpp | 4 +- .../plNetGameLib/Private/plNglFile.cpp | 4 +- .../plNetGameLib/Private/plNglGame.cpp | 4 +- .../plNetGameLib/Private/plNglGateKeeper.cpp | 4 +- .../plNetGameLib/Private/plNglTrans.cpp | 2 +- .../plNetMessage/plNetCommonMessage.h | 2 +- .../plPipeline/plFogEnvironment.cpp | 10 ++++ .../PubUtilLib/plPipeline/plFogEnvironment.h | 3 + 23 files changed, 87 insertions(+), 95 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsRefCnt.cpp b/Sources/Plasma/CoreLib/hsRefCnt.cpp index 3cf968f0..fc397258 100644 --- a/Sources/Plasma/CoreLib/hsRefCnt.cpp +++ b/Sources/Plasma/CoreLib/hsRefCnt.cpp @@ -67,7 +67,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com struct _RefCountLeakCheck { - std::unordered_set<_hsRefCnt_Base *> m_refs; + std::unordered_set m_refs; unsigned m_added, m_removed; std::mutex m_mutex; @@ -81,7 +81,7 @@ struct _RefCountLeakCheck return; _LeakDebug(plFormat(" {} objects leaked...\n", m_refs.size()).c_str()); - for (_hsRefCnt_Base *ref : m_refs) { + for (hsRefCnt *ref : m_refs) { _LeakDebug(plFormat(" 0x{_08x} {}: {} refs remain\n", (uintptr_t)ref, typeid(*ref).name(), ref->RefCnt()).c_str()); } @@ -93,7 +93,7 @@ struct _RefCountLeakCheck return &s_instance; } - static void add(_hsRefCnt_Base *ref) + static void add(hsRefCnt *ref) { _RefCountLeakCheck *this_p = _instance(); std::lock_guard lock(this_p->m_mutex); @@ -101,7 +101,7 @@ struct _RefCountLeakCheck this_p->m_refs.insert(ref); } - static void del(_hsRefCnt_Base *ref) + static void del(hsRefCnt *ref) { _RefCountLeakCheck *this_p = _instance(); std::lock_guard lock(this_p->m_mutex); @@ -111,47 +111,26 @@ struct _RefCountLeakCheck }; #endif -_hsRefCnt_Base::_hsRefCnt_Base(int) +hsRefCnt::hsRefCnt(int initRefs) + : fRefCnt(initRefs) { #if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_LEAKS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL) _RefCountLeakCheck::add(this); #endif } -_hsRefCnt_Base::~_hsRefCnt_Base() -{ -#if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_LEAKS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL) - _RefCountLeakCheck::del(this); -#endif -} - hsRefCnt::~hsRefCnt() { #ifdef HS_DEBUGGING hsThrowIfFalse(fRefCnt == 1); #endif -} - -void hsRefCnt::UnRef() -{ -#ifdef HS_DEBUGGING - hsThrowIfFalse(fRefCnt >= 1); -#endif - if (fRefCnt == 1) // don't decrement if we call delete - delete this; - else - --fRefCnt; -} - -hsAtomicRefCnt::~hsAtomicRefCnt() -{ -#ifdef HS_DEBUGGING - hsThrowIfFalse(fRefCnt == 1); +#if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_LEAKS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL) + _RefCountLeakCheck::del(this); #endif } -void hsAtomicRefCnt::UnRef(const char* tag) +void hsRefCnt::UnRef(const char* tag) { #ifdef HS_DEBUGGING hsThrowIfFalse(fRefCnt >= 1); @@ -170,7 +149,7 @@ void hsAtomicRefCnt::UnRef(const char* tag) --fRefCnt; } -void hsAtomicRefCnt::Ref(const char* tag) +void hsRefCnt::Ref(const char* tag) { #if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_REFS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL) if (tag) @@ -182,7 +161,7 @@ void hsAtomicRefCnt::Ref(const char* tag) ++fRefCnt; } -void hsAtomicRefCnt::TransferRef(const char* oldTag, const char* newTag) +void hsRefCnt::TransferRef(const char* oldTag, const char* newTag) { #if (REFCOUNT_DEBUGGING == REFCOUNT_DBG_REFS) || (REFCOUNT_DEBUGGING == REFCOUNT_DBG_ALL) DEBUG_MSG("Inc %p %s: (xfer)", this, newTag); diff --git a/Sources/Plasma/CoreLib/hsRefCnt.h b/Sources/Plasma/CoreLib/hsRefCnt.h index 24fee505..78ac15f0 100644 --- a/Sources/Plasma/CoreLib/hsRefCnt.h +++ b/Sources/Plasma/CoreLib/hsRefCnt.h @@ -44,59 +44,40 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include -// For easier debugging -class _hsRefCnt_Base -{ -public: - _hsRefCnt_Base(int initRefs = 1); - virtual ~_hsRefCnt_Base(); - - virtual int RefCnt() const = 0; -}; - -class hsRefCnt : public _hsRefCnt_Base { +class hsRefCnt { private: - int fRefCnt; + std::atomic fRefCnt; public: - hsRefCnt(int initRefs = 1) : fRefCnt(initRefs) { } + hsRefCnt(int initRefs = 1); virtual ~hsRefCnt(); inline int RefCnt() const { return fRefCnt; } - void UnRef(); - inline void Ref() { ++fRefCnt; } + void UnRef(const char* tag = nullptr); + void Ref(const char* tag = nullptr); + + // Useless, but left here for debugging compatibility with AtomicRef + void TransferRef(const char* oldTag, const char* newTag); + + + // The stored reference count of an hsRefCnt-derived object should never + // be copied! Therefore, if you want a copyable hsRefCnt-based class, you + // should implement your own copy constructor / assignment operator. + hsRefCnt(const hsRefCnt &) = delete; + hsRefCnt &operator=(const hsRefCnt &) = delete; }; -#define hsRefCnt_SafeRef(obj) do { if (obj) (obj)->Ref(); } while (0) +#define hsRefCnt_SafeRef(obj) do { if (obj) (obj)->Ref(); } while (0) #define hsRefCnt_SafeUnRef(obj) do { if (obj) (obj)->UnRef(); } while (0) -#define hsRefCnt_SafeAssign(dst, src) \ +#define hsRefCnt_SafeAssign(dst, src) \ do { \ hsRefCnt_SafeRef(src); \ - hsRefCnt_SafeUnRef(dst); \ + hsRefCnt_SafeUnRef(dst); \ dst = src; \ } while (0) -// Thread-safe version. TODO: Evaluate whether this is fast enough to -// merge with hsRefCnt above. -class hsAtomicRefCnt : public _hsRefCnt_Base -{ -private: - std::atomic fRefCnt; - -public: - hsAtomicRefCnt(int initRefs = 1) : fRefCnt(initRefs) { } - virtual ~hsAtomicRefCnt(); - - inline int RefCnt() const { return 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); -}; - template class hsRef { diff --git a/Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp index 75855e1c..f1c6da8e 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp @@ -435,7 +435,7 @@ PLASMA_DEFAULT_TYPE(ptAgeInfoStructRef, "Class to hold AgeInfo struct data"); PyObject *pyAgeInfoStructRef::New(plAgeInfoStruct &info) { ptAgeInfoStructRef *newObj = (ptAgeInfoStructRef*)ptAgeInfoStructRef_type.tp_new(&ptAgeInfoStructRef_type, NULL, NULL); - newObj->fThis->fAgeInfo = info; + newObj->fThis->fAgeInfo.CopyFrom(&info); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyAgeLinkStructGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyAgeLinkStructGlue.cpp index 5337e463..4433ebda 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyAgeLinkStructGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyAgeLinkStructGlue.cpp @@ -366,7 +366,7 @@ PLASMA_DEFAULT_TYPE(ptAgeLinkStructRef, "Class to hold the data of the AgeLink s PyObject *pyAgeLinkStructRef::New(plAgeLinkStruct &link) { ptAgeLinkStructRef *newObj = (ptAgeLinkStructRef*)ptAgeLinkStructRef_type.tp_new(&ptAgeLinkStructRef_type, NULL, NULL); - newObj->fThis->fAgeLink = link; + newObj->fThis->fAgeLink.CopyFrom(&link); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h b/Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h index 32688019..f5867c6f 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h @@ -62,7 +62,7 @@ private: protected: pyNetServerSessionInfo() {} - pyNetServerSessionInfo( const plNetServerSessionInfo & info ): fInfo( info ) {} + pyNetServerSessionInfo(const plNetServerSessionInfo & info) { fInfo.CopyFrom(&info); } public: // required functions for PyObject interoperability diff --git a/Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfoGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfoGlue.cpp index b212fecf..5c74d040 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfoGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfoGlue.cpp @@ -193,7 +193,7 @@ PYTHON_CLASS_NEW_IMPL(ptNetServerSessionInfo, pyNetServerSessionInfo) PyObject *pyNetServerSessionInfo::New(const plNetServerSessionInfo &info) { ptNetServerSessionInfo *newObj = (ptNetServerSessionInfo*)ptNetServerSessionInfo_type.tp_new(&ptNetServerSessionInfo_type, NULL, NULL); - newObj->fThis->fInfo = info; + newObj->fThis->fInfo.CopyFrom(&info); return (PyObject*)newObj; } @@ -354,7 +354,7 @@ PLASMA_DEFAULT_TYPE(ptNetServerSessionInfoRef, "Basic server session info class" PyObject *pyNetServerSessionInfoRef::New(plNetServerSessionInfo &info) { ptNetServerSessionInfoRef *newObj = (ptNetServerSessionInfoRef*)ptNetServerSessionInfoRef_type.tp_new(&ptNetServerSessionInfoRef_type, NULL, NULL); - newObj->fThis->fInfo = info; + newObj->fThis->fInfo.CopyFrom(&info); return (PyObject*)newObj; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp index 7a4901b4..ab67d470 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp @@ -115,7 +115,7 @@ void pyVaultPlayerInfoListNode::AddPlayer( uint32_t playerID ) if (nodeIds.Count()) VaultAddChildNode(fNode->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr); else - VaultFindNodes(templateNode, IAddPlayer_NodesFound, fNode); + VaultFindNodes(templateNode, IAddPlayer_NodesFound, (NetVaultNode *)fNode); } void pyVaultPlayerInfoListNode::RemovePlayer( uint32_t playerID ) diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h index 24effcaa..f08d18e8 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h @@ -88,7 +88,7 @@ public: BOOL TryEnter () { return TryEnterCriticalSection(&m_handle); } }; -class CNtWaitHandle : public hsAtomicRefCnt { +class CNtWaitHandle : public hsRefCnt { HANDLE m_event; public: diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp index df50c909..dd8a1e02 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp @@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com * ***/ -struct AsyncThreadTaskList : hsAtomicRefCnt { +struct AsyncThreadTaskList : hsRefCnt { ENetError error; AsyncThreadTaskList (); ~AsyncThreadTaskList (); @@ -81,7 +81,7 @@ static HANDLE s_taskPort; //=========================================================================== AsyncThreadTaskList::AsyncThreadTaskList () -: hsAtomicRefCnt(0), error(kNetSuccess) +: hsRefCnt(0), error(kNetSuccess) { PerfAddCounter(kAsyncPerfThreadTaskListCount, 1); } diff --git a/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp b/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp index 467d880c..027310f7 100644 --- a/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp +++ b/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp @@ -73,8 +73,8 @@ private: hsMutex m_critsect; }; -struct NetMsgChannel : hsAtomicRefCnt { - NetMsgChannel() : hsAtomicRefCnt(0) { } +struct NetMsgChannel : hsRefCnt { + NetMsgChannel() : hsRefCnt(0) { } uint32_t m_protocol; bool m_server; diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp index a7762282..5638fcee 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 () - : hsAtomicRefCnt(0), fieldFlags(0), dirtyFlags(0) + : hsRefCnt(0), fieldFlags(0), dirtyFlags(0) , nodeId(0), createTime(0), modifyTime(0) , createAgeName(nil), creatorId(0) , nodeType(0) diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h index 14d452a7..3c838a49 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h @@ -157,7 +157,7 @@ struct NetGameRank { // NetVaultNode //============================================================================ // Threaded apps: App is responsible for locking node->critsect before accessing *any* field in this struct -struct NetVaultNode : hsAtomicRefCnt { +struct NetVaultNode : hsRefCnt { enum RwOptions { kRwDirtyOnly = 1<<0, // READ : No meaning // WRITE: Only write fields marked dirty diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp b/Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp index 6c89a5cf..3da7f1e6 100644 --- a/Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp @@ -132,6 +132,20 @@ bool plAgeInfoStruct::IsEqualTo( const plAgeInfoStruct * other ) const return match; } +void plAgeInfoStruct::CopyFrom(const plAgeInfoStruct * other) +{ + hsAssert(other, "CopyFrom called with null struct"); + + fFlags = other->fFlags; + fAgeFilename = other->fAgeFilename; + fAgeInstanceName = other->fAgeInstanceName; + fAgeInstanceGuid = other->fAgeInstanceGuid; + fAgeUserDefinedName = other->fAgeUserDefinedName; + fAgeDescription = other->fAgeDescription; + fAgeSequenceNumber = other->fAgeSequenceNumber; + fAgeLanguage = other->fAgeLanguage; +} + void plAgeInfoStruct::CopyFrom( const plVaultAgeInfoNode * node ) { hsAssert(false, "eric, port me"); @@ -441,7 +455,12 @@ void plAgeLinkStruct::CopyFrom( const plAgeLinkStruct * other ) { if ( other ) { - *this=*other; + fFlags = other->fFlags; + fAgeInfo.CopyFrom(&other->fAgeInfo); + fLinkingRules = other->fLinkingRules; + fSpawnPoint = other->fSpawnPoint; + fAmCCR = other->fAmCCR; + fParentAgeFilename = other->fParentAgeFilename; } else { diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.h b/Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.h index 9e751312..e1f4aed5 100644 --- a/Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.h +++ b/Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.h @@ -112,7 +112,7 @@ public: void Clear(); void UpdateFlags() const; - void CopyFrom( const plAgeInfoStruct * other ) { *this=*other; } + void CopyFrom( const plAgeInfoStruct * other ); void CopyFrom( const plVaultAgeInfoNode * node ); void CopyFrom(const struct NetAgeInfo & info); bool IsEqualTo( const plAgeInfoStruct * other ) const; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h b/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h index 8aff7722..41fadc8a 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h @@ -287,7 +287,7 @@ enum ENetTransState { kTransStateComplete, }; -struct NetTrans : hsAtomicRefCnt { +struct NetTrans : hsRefCnt { LINK(NetTrans) m_link; ENetTransState m_state; ENetError m_result; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index 8496c05d..57a5e366 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 : hsAtomicRefCnt { +struct CliAuConn : hsRefCnt { CliAuConn (); ~CliAuConn (); @@ -1588,7 +1588,7 @@ static unsigned CliAuConnPingTimerProc (void * param) { //============================================================================ CliAuConn::CliAuConn () - : hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0) + : hsRefCnt(0), reconnectTimer(nil), reconnectStartMs(0) , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) , sock(nil), cli(nil), seq(0), serverChallenge(0) , cancelId(nil), abandoned(false) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index a808f4ac..0223205e 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 : hsAtomicRefCnt { +struct CliFileConn : hsRefCnt { LINK(CliFileConn) link; hsReaderWriterLock sockLock; // to protect the socket pointer so we don't nuke it while using it AsyncSocket sock; @@ -581,7 +581,7 @@ static void AsyncLookupCallback ( //============================================================================ CliFileConn::CliFileConn () - : hsAtomicRefCnt(0), sock(nil), seq(0), cancelId(nil), abandoned(false) + : hsRefCnt(0), sock(nil), seq(0), cancelId(nil), abandoned(false) , buildId(0), serverType(0) , reconnectTimer(nil), reconnectStartMs(0), connectStartMs(0) , numImmediateDisconnects(0), numFailedConnects(0) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp index 49e5d79a..1458ad76 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 : hsAtomicRefCnt { +struct CliGmConn : hsRefCnt { LINK(CliGmConn) link; CCritSect critsect; @@ -415,7 +415,7 @@ static unsigned CliGmConnPingTimerProc (void * param) { //============================================================================ CliGmConn::CliGmConn () - : hsAtomicRefCnt(0), sock(nil), cancelId(nil), cli(nil) + : hsRefCnt(0), sock(nil), cancelId(nil), cli(nil) , seq(0), abandoned(false) , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) { diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index 91fc7a0c..71d10412 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 : hsAtomicRefCnt { +struct CliGkConn : hsRefCnt { CliGkConn (); ~CliGkConn (); @@ -525,7 +525,7 @@ static unsigned CliGkConnPingTimerProc (void * param) { //============================================================================ CliGkConn::CliGkConn () - : hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0) + : hsRefCnt(0), reconnectTimer(nil), reconnectStartMs(0) , pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0) , sock(nil), cli(nil), seq(0), serverChallenge(0) , cancelId(nil), abandoned(false) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp index aa611a1d..b76e6d87 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp @@ -117,7 +117,7 @@ static void CancelTrans_CS (NetTrans * trans, ENetError error) { //============================================================================ NetTrans::NetTrans (ENetProtocol protocol, ETransType transType) -: hsAtomicRefCnt(0) +: hsRefCnt(0) , m_state(kTransStateWaitServerConnect) , m_result(kNetPending) , m_transId(0) diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h b/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h index 680245c1..d4ba36ab 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 hsAtomicRefCnt +class plNetCommonMessageData : public hsRefCnt { private: char *fData; // sent diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.cpp index 39d7c987..1c607411 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.cpp @@ -71,6 +71,16 @@ plFogEnvironment::~plFogEnvironment() { } +plFogEnvironment &plFogEnvironment::operator=(const plFogEnvironment ©) +{ + fType = copy.fType; + fStart = copy.fStart; + fEnd = copy.fEnd; + fDensity = copy.fDensity; + fColor = copy.fColor; + return *this; +} + //// Set ///////////////////////////////////////////////////////////////////// void plFogEnvironment::Set( float start, float end, float density, const hsColorRGBA *color ) diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.h b/Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.h index 11c5429f..13ed06e9 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/plFogEnvironment.h @@ -85,6 +85,9 @@ class plFogEnvironment : public hsKeyedObject plFogEnvironment( FogType type, float end, float density, hsColorRGBA &color ); ~plFogEnvironment(); + plFogEnvironment(const plFogEnvironment ©) { operator=(copy); } + plFogEnvironment &operator=(const plFogEnvironment ©); + // Sets the parameters for linear fog void Set( float start, float end, float density, const hsColorRGBA *color = nil );