Advertisement
Fluffy93

TrinityCore (DetourNode.cpp)

Feb 26th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. dtNodePool::dtNodePool(int maxNodes, int hashSize) :
  2.     m_nodes(0),
  3.     m_first(0),
  4.     m_next(0),
  5.     m_maxNodes(maxNodes),
  6.     m_hashSize(hashSize),
  7.     m_nodeCount(0)
  8. {
  9.     dtAssert(dtNextPow2(m_hashSize) == (unsigned int)m_hashSize);
  10.     // pidx is special as 0 means "none" and 1 is the first node. For that reason
  11.     // we have 1 fewer nodes available than the number of values it can contain.
  12.     dtAssert(m_maxNodes > 0 && m_maxNodes <= DT_NULL_IDX && m_maxNodes <= (1 << DT_NODE_PARENT_BITS) - 1);
  13.  
  14.     m_nodes = (dtNode*)dtAlloc(sizeof(dtNode)*m_maxNodes, DT_ALLOC_PERM);
  15.     m_next = (dtNodeIndex*)dtAlloc(sizeof(dtNodeIndex)*m_maxNodes, DT_ALLOC_PERM);
  16.     m_first = (dtNodeIndex*)dtAlloc(sizeof(dtNodeIndex)*hashSize, DT_ALLOC_PERM);
  17.  
  18.     dtAssert(m_nodes); // <= V568 It's odd that 'sizeof()' operator evaluates the size of a pointer to a class, but not the size of the 'm_nodes' class object. detournode.cpp 68
  19.     dtAssert(m_next);
  20.     dtAssert(m_first);
  21.  
  22.     memset(m_first, 0xff, sizeof(dtNodeIndex)*m_hashSize);
  23.     memset(m_next, 0xff, sizeof(dtNodeIndex)*m_maxNodes);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement