Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,273 @@
|
||||
#ifndef __CHARACTER_SPHERE_TREE_H__
|
||||
#define __CHARACTER_SPHERE_TREE_H__
|
||||
|
||||
#include "Sphere.h"
|
||||
#include "CharSphereTreeConstants.h"
|
||||
using namespace SphereConst;
|
||||
|
||||
#include <map>
|
||||
|
||||
#ifndef SAFE_DELETE
|
||||
#define SAFE_DELETE(p) { if ((p)) { delete (p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_DELETE_ARRAY
|
||||
#define SAFE_DELETE_ARRAY(p) { if ((p)) { delete [] (p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
//======================================================================================
|
||||
struct Position;
|
||||
class CCharacter;
|
||||
class CSphere;
|
||||
class CCharSphereNode;
|
||||
class CCharSphereTree;
|
||||
class CCharSphereNodeFifo;
|
||||
class ICharSphereTreeCallBack;
|
||||
|
||||
//======================================================================================
|
||||
class ICharSphereTreeCallBack
|
||||
{
|
||||
public:
|
||||
virtual void RangeTestCallBack( const Position& centerPos, float fDistance, CCharSphereNode* pNode )
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
//======================================================================================
|
||||
class CCharSphereNode : public CSphere
|
||||
{
|
||||
public:
|
||||
CCharSphereNode();
|
||||
CCharSphereNode( CCharSphereTree* pTree, const Position& Pos, float fRadius, void* pLink );
|
||||
|
||||
void Init( CCharSphereTree* pTree, const Position& Pos, float fRadius, void* pLink );
|
||||
|
||||
// ===================================================================
|
||||
// Flag <20>Լ<EFBFBD>
|
||||
void SetSphereNodeFlag( eSphereNodeFlag flag ) { m_dwFlag |= flag; }
|
||||
void ClearShpereNodeFlag( eSphereNodeFlag flag ) { m_dwFlag &= ~flag; }
|
||||
bool HasSphereNodeFlag( eSphereNodeFlag flag ) const
|
||||
{
|
||||
if ( m_dwFlag & flag ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
void SetCID( unsigned long dwCID ) { m_dwCID = dwCID; }
|
||||
unsigned long GetCID() const { return m_dwCID; }
|
||||
void SetCharacter(CCharacter* pCharacter) { m_pCharacter = pCharacter; }
|
||||
CCharacter* GetCharacter() const { return m_pCharacter; }
|
||||
|
||||
// ===================================================================
|
||||
// <20>θ<EFBFBD> & <20>ڽ<EFBFBD> <20>Լ<EFBFBD>
|
||||
void SetParent( CCharSphereNode* pParent ) { m_pParent = pParent; }
|
||||
CCharSphereNode* GetParent() const { return m_pParent; }
|
||||
|
||||
void AddChild( CCharSphereNode* pChild );
|
||||
void DeleteChild( CCharSphereNode* pChild );
|
||||
CCharSphereNode* GetChildren() const { return m_pChildren; }
|
||||
int GetChildCount() const { return m_iChildCount; }
|
||||
|
||||
// ===================================================================
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
void SetPrevSibling( CCharSphereNode* pNode ) { m_pPrevSibling = pNode; }
|
||||
void SetNextSibling( CCharSphereNode* pNode ) { m_pNextSibling = pNode; }
|
||||
CCharSphereNode* GetPrevSibling() const { return m_pPrevSibling; }
|
||||
CCharSphereNode* GetNextSibling() const { return m_pNextSibling; }
|
||||
|
||||
// ===================================================================
|
||||
// Fifo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
void SetRecomputeFifo( CCharSphereNode** ppFifo ) { m_ppRecomuteFifo = ppFifo; }
|
||||
void SetIntegrateFifo( CCharSphereNode** ppFifo ) { m_ppIntegrateFifo = ppFifo; }
|
||||
|
||||
// ===================================================================
|
||||
// <20>θ<EFBFBD><CEB8><EFBFBD> <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD> <20>θ<EFBFBD><CEB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>´<EFBFBD>.)
|
||||
void Unlink();
|
||||
|
||||
// ===================================================================
|
||||
// Root tree node <20><> Link ( Leaf tree <20><> Root <20><> <20>ƴ<EFBFBD> SuperSphere node <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> )
|
||||
void SetLink( void* pLink ) { m_pLink = pLink; }
|
||||
void* GetLink() const { return m_pLink; }
|
||||
|
||||
// ===================================================================
|
||||
// <20><>ǥ <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
void NewPos( const Position& Pos );
|
||||
void NewPos( float fX, float fY, float fZ );
|
||||
void NewPosRadius( const Position& Pos, float fRadius );
|
||||
void NewPosRadius( float fX, float fY, float fZ, float fRadius );
|
||||
|
||||
// ===================================================================
|
||||
// <20>Ÿ<EFBFBD> <20><> <20><><EFBFBD>ε<EFBFBD><CEB5>Ÿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
float Distance2( const CCharSphereNode* pNode );
|
||||
void ComputeBindingDistance( const CCharSphereNode* pParent );
|
||||
|
||||
// ===================================================================
|
||||
// ũ<><C5A9> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Լ<EFBFBD> ( true <20><><EFBFBD>Ͻÿ<CFBD><C3BF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD> )
|
||||
bool Recompute( float fGravy );
|
||||
|
||||
// ===================================================================
|
||||
// <20><><EFBFBD><EFBFBD> <20><EFBFBD>Ʈ<EFBFBD><C6AE> <20>Լ<EFBFBD>
|
||||
void RangeTest( const Position& centerPos, float fDistance, ICharSphereTreeCallBack* pCallBack );
|
||||
void SendToRange( const Position& centerPos, float fDistance, const char* szPacket,
|
||||
unsigned long dwPacketSize, unsigned char cCMD_In );
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
unsigned long m_dwCID;
|
||||
CCharacter* m_pCharacter;
|
||||
|
||||
CCharSphereNode* m_pParent;
|
||||
CCharSphereNode* m_pChildren;
|
||||
|
||||
CCharSphereNode* m_pPrevSibling;
|
||||
CCharSphereNode* m_pNextSibling;
|
||||
|
||||
CCharSphereNode** m_ppRecomuteFifo; // Recompute Fifo <20><><EFBFBD><EFBFBD> <20><>ġ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CCharSphereNode** m_ppIntegrateFifo; // Integrate Fifo <20><><EFBFBD><EFBFBD> <20><>ġ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
int m_iChildCount;
|
||||
unsigned long m_dwFlag;
|
||||
float m_fBindingDistance2;
|
||||
|
||||
void* m_pLink;
|
||||
CCharSphereTree* m_pTree;
|
||||
};
|
||||
|
||||
|
||||
//======================================================================================
|
||||
class CCharSphereTree
|
||||
{
|
||||
public:
|
||||
CCharSphereTree( int iMaxSphereNode, float fRootSize, float fLeafSize, float fGravy );
|
||||
virtual ~CCharSphereTree();
|
||||
|
||||
typedef std::map< unsigned long, CCharSphereNode* > CharSphereMap;
|
||||
|
||||
static CCharSphereTree& GetInstance();
|
||||
|
||||
// ===================================================================
|
||||
// Tree <20><> Node <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20>籸<EFBFBD><E7B1B8><EFBFBD>ϴ<EFBFBD> ó<><C3B3> <20>Լ<EFBFBD>
|
||||
void Process();
|
||||
|
||||
// ===================================================================
|
||||
// ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
bool AddCharacter( unsigned long dwCID, CCharacter* pCharacter, const Position& Pos ) ;
|
||||
bool DeleteCharacter( unsigned long dwCID );
|
||||
void MoveTo( unsigned long dwCID, const Position& NewPos );
|
||||
|
||||
// ===================================================================
|
||||
// CCharSphereNode <20><> <20><><EFBFBD><EFBFBD>(ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>)<29>ؼ<EFBFBD> <20>籸<EFBFBD><E7B1B8><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
|
||||
CCharSphereNode* AddSphere( const Position& Pos, float fRadius, void* pLink, unsigned long dwFlag = SNF_LEAF_TREE );
|
||||
void DeleteSphere( CCharSphereNode* pNode );
|
||||
|
||||
// ===================================================================
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>籸<EFBFBD><E7B1B8> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> Node <20>߰<EFBFBD> <20>Լ<EFBFBD>
|
||||
void AddRecompute( CCharSphereNode* pNode );
|
||||
void AddIntegrate( CCharSphereNode* pNode );
|
||||
|
||||
// ===================================================================
|
||||
// Tree <20><> <20>籸<EFBFBD><E7B1B8><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
|
||||
void Integrate( CCharSphereNode* pNode, CCharSphereNode* pSuperSphere, float fNodeSize );
|
||||
|
||||
// ===================================================================
|
||||
// <20><><EFBFBD><EFBFBD> <20><EFBFBD>Ʈ<EFBFBD><C6AE> <20>Լ<EFBFBD>
|
||||
void RangeTest( const Position& centerPos, float fDistance, ICharSphereTreeCallBack* pCallBack );
|
||||
void SendToRange( const Position& centerPos, float fDistance, const char* szPacket,
|
||||
unsigned long dwPacketSize, unsigned char cCMD_In );
|
||||
|
||||
protected:
|
||||
// ===================================================================
|
||||
// <20><><EFBFBD><EFBFBD> <20>ڽ<EFBFBD> Node <20><> <20><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
|
||||
void DeleteAllChildSphere( CCharSphereNode* pRootNode );
|
||||
|
||||
private:
|
||||
CCharSphereNode* m_pRoot;
|
||||
CCharSphereNode* m_pLeaf;
|
||||
|
||||
CCharSphereNodeFifo* m_Recompute;
|
||||
CCharSphereNodeFifo* m_Integrate;
|
||||
|
||||
float m_fMaxRootSize;
|
||||
float m_fMaxLeafSize;
|
||||
float m_fSuperSphereGravy;
|
||||
|
||||
CharSphereMap m_CharSphereMap;
|
||||
};
|
||||
|
||||
|
||||
//======================================================================================
|
||||
class CCharSphereNodeFifo
|
||||
{
|
||||
public:
|
||||
CCharSphereNodeFifo( int iSize )
|
||||
{
|
||||
m_iCount = 0;
|
||||
m_iStackPointer = 0;
|
||||
m_iBottom = 0;
|
||||
m_iSize = iSize;
|
||||
m_ppFifo = new CCharSphereNode *[ m_iSize ];
|
||||
};
|
||||
|
||||
~CCharSphereNodeFifo()
|
||||
{
|
||||
SAFE_DELETE_ARRAY( m_ppFifo );
|
||||
};
|
||||
|
||||
CCharSphereNode** Push( CCharSphereNode* pNode )
|
||||
{
|
||||
m_iCount++;
|
||||
CCharSphereNode** ret = &m_ppFifo[ m_iStackPointer ];
|
||||
m_ppFifo[ m_iStackPointer ] = pNode;
|
||||
++m_iStackPointer;
|
||||
if ( m_iStackPointer == m_iSize ) m_iStackPointer = 0;
|
||||
return ret;
|
||||
};
|
||||
|
||||
CCharSphereNode* Pop()
|
||||
{
|
||||
while ( m_iStackPointer != m_iBottom )
|
||||
{
|
||||
--m_iCount;
|
||||
CCharSphereNode* ret = m_ppFifo[ m_iBottom ];
|
||||
++m_iBottom;
|
||||
if ( m_iBottom == m_iSize ) m_iBottom = 0;
|
||||
if ( ret ) return ret;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool Flush( CCharSphereNode* pNode )
|
||||
{
|
||||
if ( m_iStackPointer == m_iBottom ) return false;
|
||||
int i = m_iBottom;
|
||||
while ( i != m_iStackPointer )
|
||||
{
|
||||
if ( m_ppFifo[i] == pNode )
|
||||
{
|
||||
m_ppFifo[i] = NULL;
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
if ( i == m_iSize ) i = 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
int GetCount(void) const { return m_iCount; }
|
||||
|
||||
private:
|
||||
|
||||
int m_iCount;
|
||||
int m_iStackPointer;
|
||||
int m_iBottom;
|
||||
int m_iSize;
|
||||
CCharSphereNode** m_ppFifo;
|
||||
};
|
||||
|
||||
|
||||
#endif __CHARACTER_SPHERE_TREE_H__
|
||||
Reference in New Issue
Block a user