diff --git a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
index 2774f622..ddcc21ab 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
+++ b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
@@ -8,21 +8,17 @@ set(pnUtils_HEADERS
pnUtAddr.h
pnUtAllIncludes.h
pnUtArray.h
- pnUtBase64.h
pnUtBigNum.h
pnUtCmd.h
pnUtCrypt.h
pnUtHash.h
pnUtList.h
- pnUtMath.h
pnUtMisc.h
pnUtPath.h
pnUtPragma.h
pnUtPriQ.h
- pnUtRand.h
pnUtRef.h
pnUtSort.h
- pnUtSpareList.h
pnUtStr.h
pnUtSync.h
pnUtTime.h
@@ -33,16 +29,12 @@ set(pnUtils_HEADERS
set(pnUtils_SOURCES
pnUtAddr.cpp
pnUtArray.cpp
- pnUtBase64.cpp
pnUtBigNum.cpp
pnUtCmd.cpp
pnUtHash.cpp
pnUtList.cpp
- pnUtMath.cpp
pnUtMisc.cpp
pnUtPath.cpp
- pnUtRand.cpp
- pnUtSpareList.cpp
pnUtStr.cpp
pnUtTime.cpp
pnUtUuid.cpp
diff --git a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Dll.cpp b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Dll.cpp
deleted file mode 100644
index 9c32e117..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Dll.cpp
+++ /dev/null
@@ -1,56 +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/Win32/pnUtW32Dll.cpp
-*
-***/
-
-#include "../pnUtils.h"
-
-
-/*****************************************************************************
-*
-* Private
-*
-***/
-
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtBase64.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtBase64.cpp
deleted file mode 100644
index 09f10687..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtBase64.cpp
+++ /dev/null
@@ -1,182 +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/pnUtBase64.cpp
-*
-***/
-
-#include "pnUtBase64.h"
-
-
-/*****************************************************************************
-*
-* Private
-*
-***/
-
-static const char kEncode64[] = {
-// 0000000000111111111122222222223333333333444444444455555555556666
-// 0123456789012345678901234567890123456789012345678901234567890123
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
-};
-
-// Note that the decode table contains one special entry:
-// The '-' character (0x2d) maps to 63 just like '/' (0x2f)
-// so that URLs will work with Base64Decode when we implement them.
-#define kTerminator 127
-#define xx kTerminator
-static const char kDecode64[] = {
-// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,62,xx,63,xx,63,
- 52,53,54,55,56,57,58,59,60,61,xx,xx,xx,xx,xx,xx,
- xx, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
- 15,16,17,18,19,20,21,22,23,24,25,xx,xx,xx,xx,xx,
- xx,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
- 41,42,43,44,45,46,47,48,49,50,51,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
- xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,
-};
-#undef xx
-
-static const char kFillchar = '=';
-
-
-/*****************************************************************************
-*
-* Exports
-*
-***/
-
-//============================================================================
-unsigned Base64Encode (
- unsigned srcChars,
- const uint8_t srcData[],
- unsigned dstChars,
- char * dstData
-) {
- ASSERT(srcData);
- ASSERT(dstChars >= Base64EncodeSize(srcChars));
- ASSERT(dstData);
-
- const char * dstBase = dstData;
- const uint8_t * srcTerm = srcData + srcChars;
- for (;;) switch (srcTerm - srcData) {
- case 0:
- *dstData++ = 0;
- return dstData - dstBase;
-
- case 1:
- *dstData++ = kEncode64[ ((srcData[0] >> 2) & 0x3f) ];
- *dstData++ = kEncode64[ ((srcData[0] << 4) & 0x30) ];
- *dstData++ = kFillchar;
- *dstData++ = kFillchar;
- *dstData++ = 0;
- return dstData - dstBase;
-
- case 2:
- *dstData++ = kEncode64[ ((srcData[0] >> 2) & 0x3f) ];
- *dstData++ = kEncode64[ ((srcData[0] << 4) & 0x30) + ((srcData[1] >> 4) & 0x0f) ];
- *dstData++ = kEncode64[ ((srcData[1] << 2) & 0x3c) ];
- *dstData++ = kFillchar;
- *dstData++ = 0;
- return dstData - dstBase;
-
- default:
- *dstData++ = kEncode64[ ((srcData[0] >> 2) & 0x3f) ];
- *dstData++ = kEncode64[ ((srcData[0] << 4) & 0x30) + ((srcData[1] >> 4) & 0x0f) ];
- *dstData++ = kEncode64[ ((srcData[1] << 2) & 0x3c) + ((srcData[2] >> 6) & 0x03) ];
- *dstData++ = kEncode64[ (srcData[2] & 0x3f) ];
- srcData += 3;
- break;
- }
-}
-
-//============================================================================
-unsigned Base64Decode (
- unsigned srcChars,
- const char srcData[],
- unsigned dstChars,
- uint8_t * dstData
-) {
- ASSERT(srcData);
- ASSERT(dstChars >= Base64DecodeSize(srcChars, srcData));
- ASSERT(dstData);
-
- const uint8_t * dstBase = dstData;
- const char * srcTerm = srcData + srcChars;
- while (srcTerm - srcData >= 4) {
-
- *dstData++ = (uint8_t) (
- (kDecode64[srcData[0]] << 2 & 0xfc)
- +(kDecode64[srcData[1]] >> 4 & 0x03)
- );
-
- if (kDecode64[srcData[2]] == kTerminator)
- break;
-
- *dstData++ = (uint8_t) (
- (kDecode64[srcData[1]] << 4 & 0xf0)
- +(kDecode64[srcData[2]] >> 2 & 0x0f)
- );
-
- if (kDecode64[srcData[3]] == kTerminator)
- break;
-
- *dstData++ = (uint8_t) (
- (kDecode64[srcData[2]] << 6 & 0xc0)
- +(kDecode64[srcData[3]])
- );
-
- srcData += 4;
- }
-
- return dstData - dstBase;
-}
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtBase64.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtBase64.h
deleted file mode 100644
index f6635ebe..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtBase64.h
+++ /dev/null
@@ -1,85 +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/pnUtBase64.h
-*
-***/
-
-#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTBASE64_H
-#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTBASE64_H
-
-#include "Pch.h"
-
-
-/*****************************************************************************
-*
-* Base64 Codec API
-*
-***/
-
-const unsigned kBase64EncodeBlock = 4;
-const unsigned kBase64EncodeMultiple = 3;
-
-inline unsigned Base64EncodeSize (unsigned srcChars) {
- return (srcChars + kBase64EncodeMultiple - 1) / kBase64EncodeMultiple
- * kBase64EncodeBlock;
-}
-unsigned Base64Encode (
- unsigned srcChars,
- const uint8_t srcData[],
- unsigned dstChars,
- char * dstData
-);
-
-inline unsigned Base64DecodeSize (unsigned srcChars, const char srcData[]) {
- return srcChars * kBase64EncodeMultiple / kBase64EncodeBlock
- - ((srcChars >= 1 && srcData[srcChars - 1] == '=') ? 1 : 0)
- - ((srcChars >= 2 && srcData[srcChars - 2] == '=') ? 1 : 0);
-}
-unsigned Base64Decode (
- unsigned srcChars,
- const char srcData[],
- unsigned dstChars,
- uint8_t * dstData
-);
-#endif
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h
index 6e6f12b2..638a0bb1 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h
+++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h
@@ -437,8 +437,14 @@ void TBaseHashTable::SetLinkOffset (int linkOffset, unsigned maxSize) {
m_linkOffset = linkOffset;
m_fullList.SetLinkOffset(m_linkOffset + offsetof(THashLink, m_linkToFull));
- if (!m_slotMask)
- SetSlotCount(max(kSlotMinCount, MathNextPow2(maxSize)));
+ if (!m_slotMask) {
+ // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
+ uint32_t v = maxSize - 1;
+ v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16;
+ v++;
+
+ SetSlotCount(max(kSlotMinCount, v));
+ }
}
//===========================================================================
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtMath.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtMath.cpp
deleted file mode 100644
index 431ea740..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtMath.cpp
+++ /dev/null
@@ -1,63 +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/pnUtMath.cpp
-*
-***/
-
-#include "pnUtMath.h"
-
-
-/*****************************************************************************
-*
-* Exported bit manipulation functions
-*
-***/
-
-//===========================================================================
-
-unsigned MathHighBitPos (uint32_t val) {
- ASSERT(val);
- double f = (double)val;
- return (*((uint32_t *)&f + 1) >> 20) - 1023;
-}
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtMath.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtMath.h
deleted file mode 100644
index 7080bb83..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtMath.h
+++ /dev/null
@@ -1,102 +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/pnUtMath.h
-*
-***/
-
-#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTMATH_H
-#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTMATH_H
-
-#include "Pch.h"
-
-/*****************************************************************************
-*
-* Bit manipulation functions
-*
-***/
-
-unsigned MathHighBitPos (uint32_t val);
-
-//===========================================================================
-inline unsigned MathBitCount (uint32_t val) {
- val = val - ((val >> 1) & 033333333333) - ((val >> 2) & 011111111111);
- val = ((val + (val >> 3)) & 030707070707);
- val = val + (val >> 6);
- val = (val + (val >> 12) + (val >> 24)) & 077;
- return val;
-}
-
-//===========================================================================
-inline unsigned MathBitMaskCreate (unsigned count) {
- ASSERT(count <= 8 * sizeof(unsigned));
- return count ? ((2 << (count - 1)) - 1) : 0;
-}
-
-//===========================================================================
-inline uint32_t MathHighBitValue (uint32_t val) {
- return val ? 1 << MathHighBitPos(val) : 0;
-}
-
-//===========================================================================
-inline bool MathIsPow2 (unsigned val) {
- return !(val & (val - 1));
-}
-
-//===========================================================================
-inline unsigned MathLowBitValue (unsigned val) {
- return val & ~(val - 1);
-}
-
-//===========================================================================
-inline unsigned MathNextMultiplePow2 (unsigned val, unsigned multiple) {
- ASSERT(multiple);
- ASSERT(MathIsPow2(multiple));
- return (val + (multiple - 1)) & ~(multiple - 1);
-}
-
-//===========================================================================
-inline uint32_t MathNextPow2 (uint32_t val) {
- return MathIsPow2(val) ? val : 1 << (MathHighBitPos(val) + 1);
-}
-#endif
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtRand.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtRand.cpp
deleted file mode 100644
index 4d30e7fe..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtRand.cpp
+++ /dev/null
@@ -1,184 +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/pnUtRand.cpp
-*
-***/
-
-#include "pnUtRand.h"
-
-
-/*****************************************************************************
-*
-* Private
-*
-***/
-
-class RandomContext {
- uint32_t m_seed;
- uint32_t m_value;
-
- void UpdateValue ();
-
-public:
- RandomContext ();
-
- void Reset ();
- void SetSeed (unsigned seed);
- float GetFloat ();
- float GetFloat (float minVal, float maxVal);
- unsigned GetUnsigned ();
- unsigned GetUnsigned (unsigned minVal, unsigned maxVal);
-};
-
-
-/*****************************************************************************
-*
-* Private data
-*
-***/
-
-static const uint32_t kDefaultRandomSeed = 0x075bd924;
-
-static RandomContext s_random;
-
-
-/*****************************************************************************
-*
-* RandomContext
-*
-***/
-
-//============================================================================
-RandomContext::RandomContext ()
-: m_seed(kDefaultRandomSeed)
-{
- Reset();
-}
-
-//============================================================================
-void RandomContext::UpdateValue () {
- const uint32_t A = 0xbc8f;
- const uint32_t Q = 0xadc8;
- const uint32_t R = 0x0d47;
-
- uint32_t div = m_value / Q;
- m_value = A * (m_value - Q * div) - R * div;
- if (m_value > kRandomMax)
- m_value -= kRandomMax + 1;
- if (!m_value)
- m_value = kDefaultRandomSeed;
-}
-
-//============================================================================
-void RandomContext::Reset () {
- m_value = m_seed;
-}
-
-//============================================================================
-void RandomContext::SetSeed (unsigned seed) {
- // Never allow a seed of zero
- m_seed = seed ? seed : kDefaultRandomSeed;
- Reset();
-}
-
-//============================================================================
-float RandomContext::GetFloat () {
- UpdateValue();
- return m_value * (1.0f / kRandomMax);
-}
-
-//============================================================================
-float RandomContext::GetFloat (float minVal, float maxVal) {
- float value = GetFloat();
- return minVal + value * (maxVal - minVal);
-}
-
-//============================================================================
-unsigned RandomContext::GetUnsigned () {
- UpdateValue();
- return (unsigned)m_value;
-}
-
-//============================================================================
-unsigned RandomContext::GetUnsigned (unsigned minVal, unsigned maxVal) {
- unsigned value = GetUnsigned();
- return minVal + value % (maxVal - minVal + 1);
-}
-
-
-/*****************************************************************************
-*
-* Exports
-*
-***/
-
-//============================================================================
-void RandReset () {
- s_random.Reset();
-}
-
-//============================================================================
-void RandSetSeed (unsigned seed) {
- s_random.SetSeed(seed);
-}
-
-//============================================================================
-float RandFloat () {
- return s_random.GetFloat();
-}
-
-//============================================================================
-float RandFloat (float minVal, float maxVal) {
- return s_random.GetFloat(minVal, maxVal);
-}
-
-//============================================================================
-unsigned RandUnsigned () {
- return s_random.GetUnsigned();
-}
-
-//============================================================================
-unsigned RandUnsigned (unsigned minVal, unsigned maxVal) {
- return s_random.GetUnsigned(minVal, maxVal);
-}
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtRand.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtRand.h
deleted file mode 100644
index 5383d49d..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtRand.h
+++ /dev/null
@@ -1,67 +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/pnUtRand.h
-*
-***/
-
-#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTRAND_H
-#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTRAND_H
-
-#include "Pch.h"
-
-/*****************************************************************************
-*
-* Psuedo-random number generator
-*
-***/
-
-const uint32_t kRandomMax = 0x7fffffff;
-
-void RandReset ();
-void RandSetSeed (unsigned seed);
-float RandFloat ();
-float RandFloat (float minVal, float maxVal);
-unsigned RandUnsigned ();
-unsigned RandUnsigned (unsigned minVal, unsigned maxVal);
-#endif
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtSpareList.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtSpareList.cpp
deleted file mode 100644
index 8bc75878..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtSpareList.cpp
+++ /dev/null
@@ -1,163 +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/pnUtSpareList.cpp
-*
-***/
-
-#include "pnUtSpareList.h"
-
-
-/****************************************************************************
-*
-* Exported functions
-*
-***/
-
-//===========================================================================
-CBaseSpareList::CBaseSpareList ()
-: m_allocHead(nil),
- m_spareHead(nil),
- m_chunkSize(0)
-{
- #ifdef SPARELIST_TRACK_MEMORY
- m_unfreedObjects = 0;
- #endif
-}
-
-//===========================================================================
-void * CBaseSpareList::Alloc (unsigned objectSize, const char typeName[]) {
- // if there aren't any spare nodes available then make more
- if (!m_spareHead)
- GrowSpareList(objectSize, typeName);
-
- // dequeue the head of the spare list
- void * const object = m_spareHead;
- m_spareHead = m_spareHead->spareNext;
- #ifdef SPARELIST_TRACK_MEMORY
- m_unfreedObjects++;
- #endif
-
- // initialize memory to a freaky value in debug mode
- #ifdef HS_DEBUGGING
- memset(object, (uint8_t) ((unsigned) object >> 4), objectSize);
- #endif
-
- return object;
-}
-
-//===========================================================================
-void CBaseSpareList::Free (void * object, unsigned objectSize) {
- // initialize memory to a freaky value in debug mode
- #ifdef HS_DEBUGGING
- memset(object, (uint8_t) ((unsigned) object >> 4), objectSize);
- #endif
-
- // link memory block onto head of spare list
- ((SpareNode *) object)->spareNext = m_spareHead;
- m_spareHead = (SpareNode *) object;
- #ifdef SPARELIST_TRACK_MEMORY
- m_unfreedObjects--;
- #endif
-}
-
-//===========================================================================
-void CBaseSpareList::GrowSpareList (unsigned objectSize, const char typeName[]) {
- // Grow the allocation by a substantial amount each time
- // to reduce the time spent in memory managament
- m_chunkSize *= 2;
- const unsigned MIN_ALLOC = max(1, 256/objectSize);
- const unsigned MAX_ALLOC = max(512, 32*1024/objectSize);
- if (m_chunkSize < MIN_ALLOC)
- m_chunkSize = MIN_ALLOC;
- else if (m_chunkSize > MAX_ALLOC)
- m_chunkSize = MAX_ALLOC;
-
- // allocate a block of memory to hold a bunch
- // of T-objects, but allocate them as "raw" memory
- AllocNode * allocNode = (AllocNode *) malloc(
- sizeof(AllocNode) + objectSize * m_chunkSize
- );
-
- // link allocation onto head of allocation list
- allocNode->allocNext = m_allocHead;
- m_allocHead = allocNode;
-
- // chain newly created raw memory units together onto the spare list
- SpareNode * spareCurr = (SpareNode *) (allocNode + 1);
- SpareNode * spareEnd = (SpareNode *) ((uint8_t *) spareCurr + objectSize * m_chunkSize);
- do {
- spareCurr->spareNext = m_spareHead;
- m_spareHead = spareCurr;
- spareCurr = (SpareNode *) ((uint8_t *) spareCurr + objectSize);
- } while (spareCurr < spareEnd);
-}
-
-//===========================================================================
-void CBaseSpareList::CleanUp (const char typeName[]) {
- // warn of resource leaks
- #ifdef SPARELIST_TRACK_MEMORY
- if (m_unfreedObjects) {
- #ifdef CLIENT
- {
- char buffer[256];
- snprintf(buffer, arrsize(buffer), "Memory leak: %s", typeName);
- FATAL(buffer);
- }
- #else
- {
- DEBUG_MSG("Memory leak: %s", typeName);
- }
- #endif
- }
- #endif
-
- // walk chain of AllocNodes and free each of them
- while (m_allocHead) {
- AllocNode * allocNext = m_allocHead->allocNext;
- free(m_allocHead);
- m_allocHead = allocNext;
- }
-
- m_spareHead = nil;
-}
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtSpareList.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtSpareList.h
deleted file mode 100644
index ba660284..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtSpareList.h
+++ /dev/null
@@ -1,148 +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/pnUtSpareList.h
-*
-***/
-
-#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSPARELIST_H
-#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSPARELIST_H
-
-#include "Pch.h"
-#include
-
-
-#ifdef HS_DEBUGGING
-#define SPARELIST_TRACK_MEMORY
-#endif
-
-
-/****************************************************************************
-*
-* CBaseSpareList
-*
-***/
-
-class CBaseSpareList {
-public:
- CBaseSpareList ();
-
-protected:
- struct SpareNode {
- SpareNode * spareNext;
- };
- SpareNode * m_spareHead;
-
- void * Alloc (unsigned objectSize, const char typeName[]);
- void CleanUp (const char typeName[]);
- void Free (void * object, unsigned objectSize);
-
-private:
- union AllocNode {
- AllocNode * allocNext;
- uint64_t align;
- };
- AllocNode * m_allocHead;
- unsigned m_chunkSize;
-
- #ifdef SPARELIST_TRACK_MEMORY
- unsigned m_unfreedObjects;
- #endif
-
- void GrowSpareList (unsigned objectSize, const char typeName[]);
-};
-
-
-/****************************************************************************
-*
-* TSpareList
-*
-***/
-
-template
-class TSpareList : public CBaseSpareList {
-private:
- enum { OBJECT_SIZE = MAX(sizeof(T), sizeof(SpareNode)) };
-
-public:
- ~TSpareList () { CleanUp(); }
-
- void * Alloc ();
- void CleanUp ();
- void Delete (T * node);
- void Free (T * node);
- T * New ();
-};
-
-
-//===========================================================================
-template
-void * TSpareList::Alloc () {
- return CBaseSpareList::Alloc(OBJECT_SIZE, typeid(T).name());
-}
-
-//===========================================================================
-template
-void TSpareList::CleanUp () {
- CBaseSpareList::CleanUp(typeid(T).name());
-}
-
-//===========================================================================
-template
-void TSpareList::Delete (T * node) {
- node->~T();
- CBaseSpareList::Free(node, OBJECT_SIZE);
-}
-
-//===========================================================================
-template
-void TSpareList::Free (T * node) {
- CBaseSpareList::Free(node, OBJECT_SIZE);
-}
-
-//===========================================================================
-template
-T * TSpareList::New () {
- return new(CBaseSpareList::Alloc(OBJECT_SIZE, typeid(T).name())) T;
-}
-#endif