From 86576c501dc0dc58804a905dc459a1c191637b0d Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 20 Aug 2023 21:08:29 +0200 Subject: [PATCH] Remove no longer used pnUtList (LISTDECL, LIST, LINK) --- .../Plasma/NucleusLib/pnUtils/CMakeLists.txt | 2 - .../NucleusLib/pnUtils/pnUtAllIncludes.h | 1 - .../Plasma/NucleusLib/pnUtils/pnUtList.cpp | 129 ---- Sources/Plasma/NucleusLib/pnUtils/pnUtList.h | 601 ------------------ 4 files changed, 733 deletions(-) delete mode 100644 Sources/Plasma/NucleusLib/pnUtils/pnUtList.cpp delete mode 100644 Sources/Plasma/NucleusLib/pnUtils/pnUtList.h diff --git a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt index 65c510611b..c0aac7a5a4 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt +++ b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt @@ -4,14 +4,12 @@ set(pnUtils_HEADERS pnUtCoreLib.h pnUtAllIncludes.h pnUtCrypt.h - pnUtList.h pnUtStr.h pnUtTime.h ) set(pnUtils_SOURCES pnUtCrypt.cpp - pnUtList.cpp pnUtStr.cpp pnUtTime.cpp ) diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h index 9fdffb9c68..80d972f07f 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h @@ -50,7 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnUtCoreLib.h" // must be first in list -#include "pnUtList.h" #include "pnUtTime.h" #include "pnUtStr.h" #include "pnUtCrypt.h" diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtList.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtList.cpp deleted file mode 100644 index aea37ed1ac..0000000000 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtList.cpp +++ /dev/null @@ -1,129 +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/pnUtList.cpp -* -***/ - -#include "Pch.h" -#include "pnUtList.h" - - -/**************************************************************************** -* -* CBaseList -* -***/ - -//=========================================================================== -void CBaseList::Link (CBaseList * list, uint8_t * afterNode, uint8_t * beforeNode, ELinkType linkType, uint8_t * existingNode) { - - // Verify that the two lists share a common link offset - ASSERT(m_linkOffset != LINK_OFFSET_UNINIT); - ASSERT(m_linkOffset == list->m_linkOffset); - - // Verify that the two lists are distinct - CBaseLink * sourceTerminator = &list->m_terminator; - ASSERT(sourceTerminator != &m_terminator); - - // Find the first and last nodes to move from the source list - CBaseLink * afterLink = afterNode ? GetLink(afterNode) : sourceTerminator; - CBaseLink * beforeLink = beforeNode ? GetLink(beforeNode) : sourceTerminator; - CBaseLink * firstLink = afterLink->NextLink(); - CBaseLink * lastLink = beforeLink->m_prevLink; - if (lastLink == afterLink) - return; - ASSERT(firstLink != beforeLink); - - // Store nodes for later use in linking - uint8_t * firstNode = afterLink->m_next; - uint8_t * lastNextNode = lastLink->m_next; - ASSERT(firstNode); - ASSERT(lastNextNode); - - // Find the previous and next nodes in the destination list which will - // bound all of the nodes of the source list - CBaseLink * existingLink = existingNode ? GetLink(existingNode) : &m_terminator; - CBaseLink * prevLink, * nextLink; - switch (linkType) { - - case kListLinkAfter: - prevLink = existingLink; - nextLink = existingLink->NextLink(); - break; - - case kListLinkBefore: - prevLink = existingLink->m_prevLink; - nextLink = existingLink; - break; - - DEFAULT_FATAL(linkType); - - } - - // Update the first and last nodes of the moved range to point to the - // previous and next nodes in the destination list - firstLink->m_prevLink = prevLink; - lastLink->m_next = prevLink->m_next; - - // Update the previous and next nodes in the destination list to point to - // the first and last nodes of the source range - nextLink->m_prevLink = lastLink; - prevLink->m_next = firstNode; - - // Update the before and after links from the source list to point to - // each other - afterLink->m_next = lastNextNode; - beforeLink->m_prevLink = afterLink; - -} - -//=========================================================================== -void CBaseList::UnlinkAll () { - for (CBaseLink * link = m_terminator.m_prevLink, * prev; link != &m_terminator; link = prev) { - prev = link->m_prevLink; - link->InitializeLinksWithOffset(m_linkOffset); - } - m_terminator.InitializeLinksWithOffset(m_linkOffset); -} - diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtList.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtList.h deleted file mode 100644 index 6193f1236c..0000000000 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtList.h +++ /dev/null @@ -1,601 +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/pnUtList.h -* -***/ - -#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTLIST_H -#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTLIST_H - -/**************************************************************************** -* -* Constants -* -***/ - -enum ELinkType { - kListUnlinked, - kListLinkAfter, - kListLinkBefore, - kListHead = kListLinkAfter, - kListTail = kListLinkBefore -}; - - -/**************************************************************************** -* -* Macros -* -***/ - -#define LINK(class) TLink< class > -#define LIST(class) TList< class > -#define LISTDECL(class,field) TListDecl< class, offsetof(class,field) > - - -/**************************************************************************** -* -* Forward declarations -* -***/ - -template -class TLink; - -template -class TList; - - -/**************************************************************************** -* -* CBaseLink -* -***/ - -class CBaseLink { - friend class CBaseList; - - inline static bool TermCheck (uint8_t * ptr); - inline static uint8_t * TermMark (uint8_t * ptr); - inline static uint8_t * TermUnmarkAlways (uint8_t * ptr); - -protected: - CBaseLink * volatile m_prevLink; - uint8_t * volatile m_next; - - inline int CalcLinkOffset () const; - inline void InitializeLinks (); - inline void InitializeLinksWithOffset (int linkOffset); - inline void InsertAfter (uint8_t * node, CBaseLink * prevLink, int linkOffset); - inline void InsertBefore (uint8_t * node, CBaseLink * nextLink); - inline uint8_t * Next () const; - inline uint8_t * NextIgnoreTerm () const; - inline uint8_t * NextUnchecked () const; - inline CBaseLink * NextLink () const; - inline CBaseLink * NextLink (int linkOffset) const; - inline uint8_t * Prev () const; - inline void UnlinkFromNeighbors (); - -public: - inline CBaseLink (); - inline CBaseLink (const CBaseLink & source) = delete; - inline ~CBaseLink (); - CBaseLink & operator= (const CBaseLink & source) = delete; - inline bool IsLinked () const; - inline void Unlink (); - -}; - -//=========================================================================== -CBaseLink::CBaseLink () { - InitializeLinks(); -} - -//=========================================================================== -CBaseLink::~CBaseLink () { - UnlinkFromNeighbors(); -} - -//=========================================================================== -int CBaseLink::CalcLinkOffset () const { - return (int)((uint8_t *)this - m_prevLink->NextIgnoreTerm()); -} - -//=========================================================================== -void CBaseLink::InitializeLinks () { - ASSERT(!((uintptr_t)this & 3)); - m_prevLink = this; - m_next = TermMark((uint8_t *)this); -} - -//=========================================================================== -void CBaseLink::InitializeLinksWithOffset (int linkOffset) { - m_prevLink = this; - m_next = TermMark((uint8_t *)this - linkOffset); -} - -//=========================================================================== -void CBaseLink::InsertAfter (uint8_t * node, CBaseLink * prevLink, int linkOffset) { - UnlinkFromNeighbors(); - m_prevLink = prevLink; - m_next = prevLink->m_next; - prevLink->NextLink(linkOffset)->m_prevLink = this; - prevLink->m_next = node; -} - -//=========================================================================== -void CBaseLink::InsertBefore (uint8_t * node, CBaseLink * nextLink) { - UnlinkFromNeighbors(); - m_prevLink = nextLink->m_prevLink; - m_next = m_prevLink->m_next; - nextLink->m_prevLink->m_next = node; - nextLink->m_prevLink = this; -} - -//=========================================================================== -bool CBaseLink::IsLinked () const { - return (m_prevLink != this); -} - -//=========================================================================== -uint8_t * CBaseLink::Next () const { - return TermCheck(m_next) ? nullptr : m_next; -} - -//=========================================================================== -uint8_t * CBaseLink::NextIgnoreTerm () const { - return TermUnmarkAlways(m_next); -} - -//=========================================================================== -uint8_t * CBaseLink::NextUnchecked () const { - return m_next; -} - -//=========================================================================== -CBaseLink * CBaseLink::NextLink () const { - return (CBaseLink *)(NextIgnoreTerm() + CalcLinkOffset()); -} - -//=========================================================================== -CBaseLink * CBaseLink::NextLink (int linkOffset) const { - ASSERT(linkOffset == CalcLinkOffset()); - return (CBaseLink *)(NextIgnoreTerm() + linkOffset); -} - -//=========================================================================== -uint8_t * CBaseLink::Prev () const { - return m_prevLink->m_prevLink->Next(); -} - -//=========================================================================== -bool CBaseLink::TermCheck (uint8_t * ptr) { - return (uintptr_t)ptr & 1; -} - -//=========================================================================== -uint8_t * CBaseLink::TermMark (uint8_t * ptr) { - // Converts an unmarked pointer to a marked pointer - ASSERT(!TermCheck(ptr)); - return (uint8_t *)((uintptr_t)ptr + 1); -} - -//=========================================================================== -uint8_t * CBaseLink::TermUnmarkAlways (uint8_t * ptr) { - // Returns an unmarked pointer regardless of whether the source pointer - // was marked on unmarked - return (uint8_t *)((uintptr_t)ptr & ~1); -} - -//=========================================================================== -void CBaseLink::Unlink () { - UnlinkFromNeighbors(); - InitializeLinks(); -} - -//=========================================================================== -void CBaseLink::UnlinkFromNeighbors () { - NextLink()->m_prevLink = m_prevLink; - m_prevLink->m_next = m_next; -} - - -/**************************************************************************** -* -* TLink -* -***/ - -template -class TLink : public CBaseLink { - -public: - inline T * Next (); - inline const T * Next () const; - inline T * NextUnchecked (); - inline const T * NextUnchecked () const; - inline T * Prev (); - inline const T * Prev () const; - -}; - -//=========================================================================== -template -T * TLink::Next () { - return (T *)CBaseLink::Next(); -} - -//=========================================================================== -template -const T * TLink::Next () const { - return (const T *)CBaseLink::Next(); -} - -//=========================================================================== -template -T * TLink::NextUnchecked () { - return (T *)CBaseLink::NextUnchecked(); -} - -//=========================================================================== -template -const T * TLink::NextUnchecked () const { - return (const T *)CBaseLink::NextUnchecked(); -} - -//=========================================================================== -template -T * TLink::Prev () { - return (T *)CBaseLink::Prev(); -} - -//=========================================================================== -template -const T * TLink::Prev () const { - return (const T *)CBaseLink::Prev(); -} - - -/**************************************************************************** -* -* CBaseList -* -***/ - -class CBaseList { - -private: - enum { LINK_OFFSET_UNINIT = 0xDDDDDDDD }; - - int m_linkOffset; - CBaseLink m_terminator; - -protected: - inline CBaseLink * GetLink (const uint8_t * node) const; - inline uint8_t * Head () const; - inline bool IsLinked (const uint8_t * node) const; - inline void Link (uint8_t * node, ELinkType linkType, uint8_t * existingNode); - void Link (CBaseList * list, uint8_t * afterNode, uint8_t * beforeNode, ELinkType linkType, uint8_t * existingNode); - inline uint8_t * Next (const uint8_t * node) const; - inline uint8_t * NextUnchecked (const uint8_t * node) const; - inline uint8_t * Prev (uint8_t * node) const; - inline uint8_t * Tail () const; - inline void Unlink (uint8_t * node); - -public: - inline CBaseList (); - inline CBaseList (const CBaseList & source); - inline ~CBaseList (); - inline CBaseList & operator= (const CBaseList & source); - inline void SetLinkOffset (int linkOffset); - void UnlinkAll (); - -}; - -//=========================================================================== -CBaseList::CBaseList () { - m_linkOffset = LINK_OFFSET_UNINIT; -} - -//=========================================================================== -CBaseList::CBaseList (const CBaseList & source) { - m_linkOffset = LINK_OFFSET_UNINIT; -} - -//=========================================================================== -CBaseList::~CBaseList () { - if (m_terminator.IsLinked()) - UnlinkAll(); -} - -//=========================================================================== -CBaseList & CBaseList::operator= (const CBaseList & source) { - return *this; -} - -//=========================================================================== -CBaseLink * CBaseList::GetLink (const uint8_t * node) const { - return (CBaseLink *)(node + m_linkOffset); -} - -//=========================================================================== -uint8_t * CBaseList::Head () const { - return m_terminator.Next(); -} - -//=========================================================================== -bool CBaseList::IsLinked (const uint8_t * node) const { - ASSERT(node); - return GetLink(node)->IsLinked(); -} - -//=========================================================================== -void CBaseList::Link (uint8_t * node, ELinkType linkType, uint8_t * existingNode) { - ASSERT(node != existingNode); - ASSERT(m_linkOffset != LINK_OFFSET_UNINIT); - ASSERT((linkType == kListLinkAfter) || (linkType == kListLinkBefore)); - if (linkType == kListLinkAfter) - GetLink(node)->InsertAfter(node, existingNode ? GetLink(existingNode) : &m_terminator, m_linkOffset); - else - GetLink(node)->InsertBefore(node, existingNode ? GetLink(existingNode) : &m_terminator); -} - -//=========================================================================== -uint8_t * CBaseList::Next (const uint8_t * node) const { - ASSERT(node); - return GetLink(node)->Next(); -} - -//=========================================================================== -uint8_t * CBaseList::NextUnchecked (const uint8_t * node) const { - ASSERT(node); - return GetLink(node)->NextUnchecked(); -} - -//=========================================================================== -uint8_t * CBaseList::Prev (uint8_t * node) const { - ASSERT(node); - return GetLink(node)->Prev(); -} - -//=========================================================================== -void CBaseList::SetLinkOffset (int linkOffset) { - ASSERT(!Head()); - - m_linkOffset = linkOffset; - m_terminator.InitializeLinksWithOffset(linkOffset); -} - -//=========================================================================== -uint8_t * CBaseList::Tail () const { - return m_terminator.Prev(); -} - -//=========================================================================== -void CBaseList::Unlink (uint8_t * node) { - ASSERT(node); - GetLink(node)->Unlink(); -} - - -/**************************************************************************** -* -* TList -* -***/ - -template -class TList : public CBaseList { - -private: - inline T * NewFlags (unsigned flags, ELinkType linkType, T * existingNode, const char file[], int line); - -public: - inline void Clear (); - inline void Delete (T * node); - inline T * Head (); - inline const T * Head () const; - inline bool IsLinked (const T * node) const; - inline void Link (T * node, ELinkType linkType = kListTail, T * existingNode = nullptr); - inline void Link (TList * list, ELinkType linkType = kListTail, T * existingNode = nullptr); - inline void Link (TList * list, T * afterNode, T * beforeNode, ELinkType linkType = kListTail, T * existingNode = nullptr); - inline T * New (ELinkType linkType = kListTail, T * existingNode = nullptr, const char file[] = nullptr, int line = 0); - inline T * NewZero (ELinkType linkType = kListTail, T * existingNode = nullptr, const char file[] = nullptr, int line = 0); - inline T * Next (const T * node); - inline const T * Next (const T * node) const; - inline T * NextUnchecked (const T * node); - inline const T * NextUnchecked (const T * node) const; - inline T * Prev (const T * node); - inline const T * Prev (const T * node) const; - inline T * Tail (); - inline const T * Tail () const; - inline void Unlink (T * node); - -}; - -//=========================================================================== -template -void TList::Clear () { - for (T * curr; (curr = Head()) != nullptr; Delete(curr)) - ; -} - -//=========================================================================== -template -void TList::Delete (T * node) { - delete node; -} - -//=========================================================================== -template -T * TList::Head () { - return (T *)CBaseList::Head(); -} - -//=========================================================================== -template -const T * TList::Head () const { - return (const T *)CBaseList::Head(); -} - -//=========================================================================== -template -bool TList::IsLinked (const T * node) const { - return CBaseList::IsLinked((const uint8_t *)node); -} - -//=========================================================================== -template -void TList::Link (T * node, ELinkType linkType, T * existingNode) { - CBaseList::Link((uint8_t *)node, linkType, (uint8_t *)existingNode); -} - -//=========================================================================== -template -void TList::Link (TList * list, ELinkType linkType, T * existingNode) { - CBaseList::Link(list, nullptr, nullptr, linkType, (uint8_t *)existingNode); -} - -//=========================================================================== -template -void TList::Link (TList * list, T * afterNode, T * beforeNode, ELinkType linkType, T * existingNode) { - CBaseList::Link(list, (uint8_t *)afterNode, (uint8_t *)beforeNode, linkType, (uint8_t *)existingNode); -} - -//=========================================================================== -template -inline T * TList::Next (const T * node) { - return (T *)CBaseList::Next((uint8_t *)node); -} - -//=========================================================================== -template -inline const T * TList::Next (const T * node) const { - return (const T *)CBaseList::Next((uint8_t *)node); -} - -//=========================================================================== -template -inline T * TList::NextUnchecked (const T * node) { - return (T *)CBaseList::NextUnchecked((uint8_t *)node); -} - -//=========================================================================== -template -inline const T * TList::NextUnchecked (const T * node) const { - return (const T *)CBaseList::NextUnchecked((uint8_t *)node); -} - -//=========================================================================== -template -inline T * TList::New (ELinkType linkType, T * existingNode, const char file[], int line) { - return NewFlags(0, linkType, existingNode, file, line); -} - -//=========================================================================== -template -inline T * TList::NewFlags (unsigned flags, ELinkType linkType, T * existingNode, const char file[], int line) { - T * node = new T(); - if (linkType != kListUnlinked) - Link(node, linkType, existingNode); - return node; -} - -//=========================================================================== -template -inline T * TList::NewZero (ELinkType linkType, T * existingNode, const char file[], int line) { - return NewFlags(0, linkType, existingNode, file, line); -} - -//=========================================================================== -template -inline T * TList::Prev (const T * node) { - return (T *)CBaseList::Prev((uint8_t *)node); -} - -//=========================================================================== -template -inline const T * TList::Prev (const T * node) const { - return (const T *)CBaseList::Prev((uint8_t *)node); -} - -//=========================================================================== -template -inline T * TList::Tail () { - return (T *)CBaseList::Tail(); -} - -//=========================================================================== -template -inline const T * TList::Tail () const { - return (const T *)CBaseList::Tail(); -} - -//=========================================================================== -template -inline void TList::Unlink (T * node) { - CBaseList::Unlink((uint8_t *)node); -} - - -/**************************************************************************** -* -* TListDecl -* -***/ - -template -class TListDecl : public TList { - -public: - inline TListDecl (); - -}; - -//=========================================================================== -template -TListDecl::TListDecl () { - this->SetLinkOffset(linkOffset); -} -#endif