// Include #include "gamesrv.h" #include "PvPPlayerListPool.h" cPvPPlayerListPool* cPvPPlayerListPool::mpPvPPlayerListPool = NULL; int WINAPI PvPPlayerCmpIndex(void* arg1, void* arg2) { return ((PerPvPPlayer*)arg1)->mPlayerIdx - ((PerPvPPlayer*)arg2)->mPlayerIdx; } int WINAPI PvPPlayerCmpValue(void* arg1, void* arg2) { return ((PerPvPPlayer*)arg1)->mPlayerIdx - (*(long*)arg2); } cPvPPlayerListPool::cPvPPlayerListPool( ) { // Global Variable mpPvPPlayerListPool = this; // Pool Usage Pointer mNonPagedPoolUsage = NULL; } cPvPPlayerListPool::~cPvPPlayerListPool(void) { // cItemCountPool¸¦ ÇØÁ¦. Shutdown(); // Global Variable mpPvPPlayerListPool = NULL; } void cPvPPlayerListPool::Shutdown() { PerPvPPlayer* temp; // Pool Usage Shutdown - NonPagedPoolUsage while ( mNonPagedPoolUsage != NULL ) { temp = mNonPagedPoolUsage; mNonPagedPoolUsage = (PerPvPPlayer*)mNonPagedPoolUsage->next; MEMORY_POOL->FreeNode( (void**)&temp ); } } PerPvPPlayer* cPvPPlayerListPool::AddPlayer( PvPPlayerRoot* pPvPPlayerRoot, short channel, unsigned long playerIdx, unsigned char level, unsigned char forceType, bool selection ) { PerPvPPlayer* perPvPPlayer = (PerPvPPlayer*)MEMORY_POOL->GetPool( (PerNode**)&mNonPagedPoolUsage, sizeof(PerPvPPlayer) ); if ( perPvPPlayer ) { perPvPPlayer->mPlayerIdx = playerIdx; // Index - Key // BST-¿¬°á½Ãµµ. if ( MEMORY_POOL->AttachBst( &pPvPPlayerRoot->root, (PerNode*)perPvPPlayer, &PvPPlayerCmpIndex ) ) { MEMORY_POOL->AttachPool( &pPvPPlayerRoot->pool, perPvPPlayer ); perPvPPlayer->mCharacterChannel = channel; perPvPPlayer->mLevel = level; perPvPPlayer->mForceType = forceType; perPvPPlayer->mSelection = selection; pPvPPlayerRoot->count++; return perPvPPlayer; // ¿¬°á¼º°ø. } else { MEMORY_POOL->AttachPool( (PerNode**)&mNonPagedPoolUsage, perPvPPlayer ); assert(0); return NULL; // ¿¬°á½ÇÆÐ. } } return perPvPPlayer; } PerPvPPlayer* cPvPPlayerListPool::GetPlayer(PvPPlayerRoot* root, long index) { return (PerPvPPlayer*)MEMORY_POOL->SearchNode( root, &index, &PvPPlayerCmpValue ); } void cPvPPlayerListPool::ReleasePlayer( PvPPlayerRoot* root, PerPvPPlayer* perPlayer ) { perPlayer->mCharacterChannel = 0; perPlayer->mPlayerIdx = 0; perPlayer->mLevel = 0; perPlayer->mForceType = 0; perPlayer->mSelection = 0; // BST - ¿¬°áÁ¾·á. MEMORY_POOL->DetachBst( (PerNode**)&root->root, (PerNode*)perPlayer ); // ÆäÀÌÁö µÈ Ç® »ç¿ë·®À» Â÷°¨. MEMORY_POOL->DetachPool( (PerNode**)&root->pool, (PerNode*)perPlayer ); // ÆäÀÌÁö ¾ÈµÈ Ç® »ç¿ë·®À» Áõ°¨. MEMORY_POOL->ReleasePool( (PerNode**)&mNonPagedPoolUsage, (PerNode*)perPlayer ); --root->count; }