Browse Source

Don't throw errors when including pnUtils stuff.

Darryl Pogue 13 years ago
parent
commit
65b75f0667
  1. 2
      Sources/Plasma/NucleusLib/pnUUID/pnUUID.h
  2. 1
      Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
  3. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtAddr.h
  4. 7
      Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h
  5. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtBase64.h
  6. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtBigNum.h
  7. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtCmd.h
  8. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.h
  9. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h
  10. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtList.h
  11. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtMath.h
  12. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtMisc.h
  13. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h
  14. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtPriQ.h
  15. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtRand.h
  16. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtRef.h
  17. 477
      Sources/Plasma/NucleusLib/pnUtils/pnUtSkipList.h
  18. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h
  19. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtSpareList.h
  20. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h
  21. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h
  22. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtTime.h
  23. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtTls.h
  24. 57
      Sources/Plasma/NucleusLib/pnUtils/pnUtTypes.h
  25. 6
      Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h

2
Sources/Plasma/NucleusLib/pnUUID/pnUUID.h

@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsStlUtils.h"
#ifdef HS_BUILD_FOR_WIN32
#include "pnUtils/pnUtils.h"
#include "pnUtils/pnUtUuid.h"
#endif
class hsStream;

1
Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt

@ -21,7 +21,6 @@ set(pnUtils_HEADERS
pnUtPriQ.h
pnUtRand.h
pnUtRef.h
pnUtSkipList.h
pnUtSort.h
pnUtSpareList.h
pnUtStr.h

5
Sources/Plasma/NucleusLib/pnUtils/pnUtAddr.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTADDR_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtAddr.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTADDR_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTADDR_H
#include "Pch.h"
@ -169,3 +167,4 @@ unsigned NetAddressGetLocal (
unsigned count,
NetAddressNode addresses[]
);
#endif

7
Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h

@ -52,16 +52,22 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnUtCoreLib.h" // must be first in list
#include "pnUtPragma.h"
#include "pnUtAddr.h"
#if HS_BUILD_FOR_WIN32
#include "pnUtUuid.h"
#endif
#include "pnUtMath.h"
#include "pnUtSort.h"
#include "pnUtArray.h"
#include "pnUtList.h"
#include "pnUtHash.h"
#include "pnUtPriQ.h"
#if HS_BUILD_FOR_WIN32
#include "pnUtSync.h"
#endif
#include "pnUtTime.h"
#if HS_BUILD_FOR_WIN32
#include "pnUtTls.h"
#endif
#include "pnUtStr.h"
#include "pnUtRef.h"
#include "pnUtPath.h"
@ -72,6 +78,5 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnUtSpareList.h"
#include "pnUtRand.h"
#include "pnUtBase64.h"
#include "pnUtSkipList.h"
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTALLINCLUDES_H

5
Sources/Plasma/NucleusLib/pnUtils/pnUtBase64.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTBASE64_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTBASE64_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTBASE64_H
#include "Pch.h"
@ -84,3 +82,4 @@ unsigned Base64Decode (
unsigned dstChars,
uint8_t * dstData
);
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtBigNum.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTBIGNUM_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBigNum.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTBIGNUM_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTBIGNUM_H
#include "Pch.h"
@ -228,3 +226,4 @@ public:
BN_sub(&m_number, &a.m_number, &b.m_number);
}
};
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtCmd.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTCMD_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCmd.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTCMD_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTCMD_H
#include "Pch.h"
@ -145,3 +143,4 @@ public:
);
};
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTCRYPT_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCrypt.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTCRYPT_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTCRYPT_H
#include "Pch.h"
@ -182,3 +180,4 @@ void CryptDecrypt (
unsigned bytes,
void * data
);
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTHASH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtHash.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTHASH_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTHASH_H
#include "Pch.h"
@ -746,3 +744,4 @@ typedef THashKeyStr< wchar_t, THashKeyStrCmp<wchar_t> > CHashKeyStr;
typedef THashKeyStr< wchar_t, THashKeyStrCmpI<wchar_t> > CHashKeyStrI;
typedef THashKeyStr< char, THashKeyStrCmp<char> > CHashKeyStrChar;
typedef THashKeyStr< char, THashKeyStrCmpI<char> > CHashKeyStrCharI;
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtList.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTLIST_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtList.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTLIST_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTLIST_H
#include "Pch.h"
@ -641,3 +639,4 @@ template<class T>
void TListDyn<T>::Initialize (int linkOffset) {
this->SetLinkOffset(linkOffset);
}
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtMath.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTMATH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtMath.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTMATH_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTMATH_H
#include "Pch.h"
@ -115,3 +113,4 @@ inline unsigned MathNextMultiplePow2 (unsigned val, unsigned multiple) {
inline uint32_t MathNextPow2 (uint32_t val) {
return MathIsPow2(val) ? val : 1 << (MathHighBitPos(val) + 1);
}
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtMisc.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTMISC_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtMisc.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTMISC_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTMISC_H
#include "Pch.h"
@ -166,3 +164,4 @@ const unsigned kCpuCapTsc = 1<<9; // time stamp counter
#define CPU_SIGNATURE_FAMILY(sig) ((sig >> 8) & 0xf)
#define CPU_SIGNATURE_MODEL(sig) ((sig >> 4) & 0xf)
#define CPU_SIGNATURE_STEPPING(sig) (sig & 0xf)
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTPATH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtPath.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTPATH_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTPATH_H
#include "Pch.h"
@ -325,3 +323,4 @@ void PathSplitEmail (
unsigned subDomainChars, // arrsize(subs[0]) --> 256
unsigned subDomainCount // arrsize(subs) --> 16
);
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtPriQ.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTPRIQ_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtPriQ.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTPRIQ_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTPRIQ_H
#include "Pch.h"
@ -486,3 +484,4 @@ public:
private:
unsigned m_time;
};
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtRand.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTRAND_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtRand.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTRAND_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTRAND_H
#include "Pch.h"
@ -66,3 +64,4 @@ float RandFloat ();
float RandFloat (float minVal, float maxVal);
unsigned RandUnsigned ();
unsigned RandUnsigned (unsigned minVal, unsigned maxVal);
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtRef.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTREF_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtRef.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTREF_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTREF_H
@ -179,3 +177,4 @@ protected:
private:
long m_ref;
};
#endif

477
Sources/Plasma/NucleusLib/pnUtils/pnUtSkipList.h

@ -1,477 +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 <http://www.gnu.org/licenses/>.
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/pnUtSkipList.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSKIPLIST_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSkipList.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSKIPLIST_H
/*****************************************************************************
*
* Macros
*
***/
#define SKIPLIST(type, keyType, keyField, cmp) TSkipList< type, keyType, offsetof(type, keyField), cmp >
#define SKIPLIST_NUMERIC(type, keyType, keyField) SKIPLIST(type, keyType, keyField, TSkipListNumericCmp<keyType>)
#define SKIPLIST_STRING(type, keyType, keyField) SKIPLIST(type, keyType, keyField, TSkipListStringCmp<keyType>)
#define SKIPLIST_STRINGI(type, keyType, keyField) SKIPLIST(type, keyType, keyField, TSkipListStringCmpI<keyType>)
/*****************************************************************************
*
* Typedefs
*
***/
typedef void * SkipListTag;
/*****************************************************************************
*
* Comparers
*
***/
template<class K>
class TSkipListNumericCmp {
public:
static bool Eq (const K & a, const K & b) { return a == b; }
static bool Lt (const K & a, const K & b) { return a < b; }
};
template<class K>
class TSkipListStringCmp {
public:
static bool Eq (const K & a, const K & b) { return StrCmp(a, b, (unsigned)-1) == 0; }
static bool Lt (const K & a, const K & b) { return StrCmp(a, b, (unsigned)-1) < 0; }
};
template<class K>
class TSkipListStringCmpI {
public:
static bool Eq (const K & a, const K & b) { return StrCmpI(a, b, (unsigned)-1) == 0; }
static bool Lt (const K & a, const K & b) { return StrCmpI(a, b, (unsigned)-1) < 0; }
};
/*****************************************************************************
*
* TSkipList
*
***/
template<class T, class K, unsigned keyOffset, class Cmp>
class TSkipList {
private:
enum { kMaxLevels = 32 };
template<class T2, class K2>
struct TNode {
const K2 * key;
T2 * object;
unsigned level;
TNode<T2, K2> * prev;
TNode<T2, K2> * next[1]; // variable size array
};
typedef TNode<T,K> Node;
unsigned m_level;
Node * m_head;
Node * m_stop;
unsigned m_randomBits;
unsigned m_randomsLeft;
Node * AllocNode (unsigned levels);
void FreeNode (Node * node);
unsigned RandomLevel ();
public:
inline TSkipList ();
inline ~TSkipList ();
inline void Clear ();
inline void Delete (T * object);
inline T * Find (const K & key, SkipListTag * tag = nil) const;
inline T * FindNext (SkipListTag * tag) const;
inline T * Head (SkipListTag * tag) const;
inline T * Next (SkipListTag * tag) const;
inline T * Prev (SkipListTag * tag) const;
inline T * Tail (SkipListTag * tag) const;
inline void Link (T * object);
inline void Unlink (T * object);
inline void Unlink (SkipListTag * tag);
inline void UnlinkAll ();
#ifdef HS_DEBUGGING
inline void Print () const;
#endif
};
/*****************************************************************************
*
* TSkipList private member functions
*
***/
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
typename TSkipList<T,K,keyOffset,Cmp>::Node* TSkipList<T,K,keyOffset,Cmp>::AllocNode (unsigned level) {
unsigned size = offsetof(Node, next) + (level + 1) * sizeof(Node);
Node * node = (Node *)malloc(size);
node->level = level;
return node;
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
void TSkipList<T,K,keyOffset,Cmp>::FreeNode (TNode<T,K> * node) {
free(node);
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
unsigned TSkipList<T,K,keyOffset,Cmp>::RandomLevel () {
unsigned level = 0;
unsigned bits = 0;
while (!bits) {
bits = m_randomBits % 4;
if (!bits)
++level;
m_randomBits >>= 2;
m_randomsLeft -= 2;
if (!m_randomsLeft) {
m_randomBits = RandUnsigned();
m_randomsLeft = 30;
}
}
return level;
}
/*****************************************************************************
*
* TSkipList public member functions
*
***/
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
TSkipList<T,K,keyOffset,Cmp>::TSkipList () {
m_level = 0;
m_head = AllocNode(kMaxLevels);
m_stop = AllocNode(0);
m_randomBits = RandUnsigned();
m_randomsLeft = 30;
// Initialize header and stop skip node pointers
m_stop->prev = m_head;
m_stop->object = nil;
m_stop->next[0] = nil;
m_head->object = nil;
for (unsigned index = 0; index < kMaxLevels; ++index)
m_head->next[index] = m_stop;
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
TSkipList<T,K,keyOffset,Cmp>::~TSkipList () {
UnlinkAll();
ASSERT(m_stop->prev == m_head);
FreeNode(m_head);
FreeNode(m_stop);
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
void TSkipList<T,K,keyOffset,Cmp>::Clear () {
Node * ptr = m_head->next[0];
while (ptr != m_stop) {
Node * next = ptr->next[0];
delete ptr->object;
FreeNode(ptr);
ptr = next;
}
m_stop->prev = m_head;
for (unsigned index = 0; index < kMaxLevels; ++index)
m_head->next[index] = m_stop;
m_level = 0;
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
void TSkipList<T,K,keyOffset,Cmp>::Delete (T * object) {
Unlink(object);
delete object;
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
T * TSkipList<T,K,keyOffset,Cmp>::Find (const K & key, SkipListTag * tag) const {
Node * node = m_head;
m_stop->key = &key;
for (int level = (int)m_level; level >= 0; --level)
while (Cmp::Lt(*node->next[level]->key, key))
node = node->next[level];
node = node->next[0];
if (node != m_stop && Cmp::Eq(*node->key, *m_stop->key)) {
if (tag)
*tag = node;
return node->object;
}
else {
if (tag)
*tag = nil;
return nil;
}
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
T * TSkipList<T,K,keyOffset,Cmp>::FindNext (SkipListTag * tag) const {
Node * node = (Node *)*tag;
m_stop->key = node->key;
for (int level = (int)node->level; level >= 0; --level)
while (Cmp::Lt(*node->next[level]->key, *m_stop->key))
node = node->next[level];
node = node->next[0];
if (node != m_stop && Cmp::Eq(*node->key, *m_stop->key)) {
*tag = node;
return node->object;
}
else {
*tag = nil;
return nil;
}
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
T * TSkipList<T,K,keyOffset,Cmp>::Head (SkipListTag * tag) const {
ASSERT(tag);
Node * first = m_head->next[0];
if (first == m_stop) {
*tag = nil;
return nil;
}
*tag = first;
return first->object;
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
T * TSkipList<T,K,keyOffset,Cmp>::Next (SkipListTag * tag) const {
ASSERT(tag);
Node * node = (Node *)*tag;
ASSERT(node);
if (node->next[0] == m_stop) {
*tag = nil;
return nil;
}
*tag = node->next[0];
return node->next[0]->object;
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
T * TSkipList<T,K,keyOffset,Cmp>::Prev (SkipListTag * tag) const {
ASSERT(tag);
Node * node = (Node *)*tag;
ASSERT(node);
if (node->prev == m_head) {
*tag = nil;
return nil;
}
*tag = node->prev;
return node->prev->object;
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
T * TSkipList<T,K,keyOffset,Cmp>::Tail (SkipListTag * tag) const {
ASSERT(tag);
Node * last = m_stop->prev;
if (last == m_head) {
*tag = nil;
return nil;
}
*tag = last;
return last->object;
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
void TSkipList<T,K,keyOffset,Cmp>::Link (T * object) {
const K * key = (const K *)((const uint8_t *)object + keyOffset);
// Find the node's insertion point
m_stop->key = key;
Node * update[kMaxLevels];
Node * node = m_head;
for (int level = (int)m_level; level >= 0; --level) {
while (Cmp::Lt(*node->next[level]->key, *key))
node = node->next[level];
update[level] = node;
}
node = node->next[0];
{
// Select a level for the skip node
unsigned newLevel = RandomLevel();
if (newLevel > m_level) {
if (m_level < kMaxLevels - 1) {
newLevel = ++m_level;
update[newLevel] = m_head;
}
else
newLevel = m_level;
}
// Create the node and insert it into the skip list
Node * node = AllocNode(newLevel);
node->key = key;
node->object = object;
for (unsigned level = newLevel; level >= 1; --level) {
node->next[level] = update[level]->next[level];
update[level]->next[level] = node;
}
node->prev = update[0];
node->next[0] = update[0]->next[0];
update[0]->next[0]->prev = node;
update[0]->next[0] = node;
}
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
void TSkipList<T,K,keyOffset,Cmp>::Unlink (T * object) {
const K * key = (const K *)((const uint8_t *)object + keyOffset);
Node * node = m_head;
Node * update[kMaxLevels];
int level = m_level;
for (;;) {
// Find the node being unlinked
m_stop->key = key;
for (; level >= 0; --level) {
while (Cmp::Lt(*node->next[level]->key, *key))
node = node->next[level];
update[level] = node;
}
node = node->next[0];
// Node wasn't found so do nothing
if (*node->key != *key || node == m_stop)
return;
if (node->object == object)
break;
}
// Update all links
for (level = m_level; level >= 1; --level) {
if (update[level]->next[level] != node)
continue;
update[level]->next[level] = node->next[level];
}
ASSERT(update[0]->next[0] == node);
node->next[0]->prev = update[0];
update[0]->next[0] = node->next[0];
// Update header
while (m_level && m_head->next[m_level] == m_stop)
--m_level;
FreeNode(node);
}
//============================================================================
template<class T, class K, unsigned keyOffset, class Cmp>
void TSkipList<T,K,keyOffset,Cmp>::UnlinkAll () {
Node * ptr = m_head->next[0];
while (ptr != m_stop) {
Node * next = ptr->next[0];
FreeNode(ptr);
ptr = next;
}
m_stop->prev = m_head;
for (unsigned index = 0; index < kMaxLevels; ++index)
m_head->next[index] = m_stop;
m_level = 0;
}

5
Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSORT_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSort.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSORT_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSORT_H
@ -239,3 +237,4 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*(addrOfIndex) = high - (ptr); \
\
}
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtSpareList.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSPARELIST_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSpareList.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSPARELIST_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSPARELIST_H
#include "Pch.h"
@ -147,3 +145,4 @@ template<class T>
T * TSpareList<T>::New () {
return new(CBaseSpareList::Alloc(OBJECT_SIZE, typeid(T).name())) T;
}
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSTR_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtStr.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSTR_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSTR_H
#include "Pch.h"
@ -156,3 +154,4 @@ bool StrTokenize (const char * source[], char * dest, unsigned chars, const char
bool StrTokenize (const wchar_t * source[], wchar_t * dest, unsigned chars, const wchar_t whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
bool StrTokenize (const char * source[], ARRAY(char) * destArray, const char whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
bool StrTokenize (const wchar_t * source[], ARRAY(wchar_t) * destArray, const wchar_t whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSYNC_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSync.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSYNC_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSYNC_H
#include "Pch.h"
@ -133,3 +131,4 @@ public:
const EventHandle & Handle () const { return m_handle; }
};
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtTime.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTTIME_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtTime.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTTIME_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTTIME_H
#include "Pch.h"
@ -128,3 +126,4 @@ uint32_t TimeGetSecondsSince1970Utc ();
static const uint64_t kTime1601To1970 = 11644473600 * kTimeIntervalsPerSecond;
static const uint64_t kTime1601To2001 = 12622780800 * kTimeIntervalsPerSecond;
#endif

5
Sources/Plasma/NucleusLib/pnUtils/pnUtTls.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTTLS_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtTls.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTTLS_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTTLS_H
#include "Pch.h"
@ -71,3 +69,4 @@ void ThreadLocalSetValue (unsigned id, void * value);
void ThreadAllowBlock ();
void ThreadDenyBlock ();
void ThreadAssertCanBlock (const char file[], int line);
#endif

57
Sources/Plasma/NucleusLib/pnUtils/pnUtTypes.h

@ -1,57 +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 <http://www.gnu.org/licenses/>.
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/pnUtTypes.h
*
*
* By Eric Anderson (10/10/2005)
* Copyright 2005 Cyan Worlds, Inc.
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTTYPES_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtTypes.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTTYPES_H

6
Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h

@ -45,9 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTUUID_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtUuid.h included more than once"
#endif
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTUUID_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTUUID_H
#include "Pch.h"
@ -117,4 +115,4 @@ struct Uuid {
};
#include <poppack.h>
#endif

Loading…
Cancel
Save