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,150 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <Utility/Math/Math.h>
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
#include <Utility/DelimitedFile.h>
|
||||
|
||||
#include <Creature/CreatureManager.h>
|
||||
#include <Creature/Monster/Monster.h>
|
||||
|
||||
#include "DuelCellManager.h"
|
||||
|
||||
|
||||
CDuelCellManager CDuelCellManager::ms_this;
|
||||
|
||||
CCell* CDuelCellManager::CreateCell(unsigned long dwCID)
|
||||
{
|
||||
CCell* lpCell = new CCell();
|
||||
if(NULL == lpCell)
|
||||
return NULL;
|
||||
|
||||
lpCell->Initialize(0, 0);
|
||||
|
||||
m_CellData.insert(std::make_pair(dwCID, lpCell)).second;
|
||||
return lpCell;
|
||||
}
|
||||
|
||||
bool CDuelCellManager::DestroyCell(unsigned long dwCID)
|
||||
{
|
||||
DuelCellMap::iterator itr = m_CellData.find(dwCID);
|
||||
if(itr == m_CellData.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
delete itr->second;
|
||||
m_CellData.erase(dwCID);
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// <20>α<CEB1> <20>Լ<EFBFBD><D4BC><EFBFBD>
|
||||
|
||||
struct CheckInfo
|
||||
{
|
||||
unsigned long m_dwCellID;
|
||||
CheckInfo(unsigned long CellID) : m_dwCellID(CellID) { }
|
||||
};
|
||||
|
||||
typedef std::map<unsigned long, CheckInfo> CIDInCell;
|
||||
typedef std::multimap<unsigned long, CheckInfo> DUPCID;
|
||||
|
||||
class CheckMap
|
||||
{
|
||||
public:
|
||||
CheckMap(CIDInCell& Map) : m_Map(Map) { }
|
||||
bool operator() (CAggresiveCreature* lpCreature) { m_Map.erase(lpCreature->GetCID()); return true; }
|
||||
protected:
|
||||
CIDInCell& m_Map;
|
||||
};
|
||||
|
||||
|
||||
bool CDuelCellManager::CheckCellAggresiveCreatures()
|
||||
{
|
||||
CIDInCell AggresiveCreatureMap;
|
||||
DUPCID DuplicateCID;
|
||||
|
||||
unsigned long dwCID = 0;
|
||||
|
||||
for(DuelCellMap::iterator itr = m_CellData.begin(); itr != m_CellData.end(); ++itr)
|
||||
{
|
||||
CCell* lpCell = itr->second;
|
||||
unsigned long CellID = itr->first;
|
||||
|
||||
CCharacter* lpCharacter = lpCell->GetFirstCharacter();
|
||||
while(NULL != lpCharacter)
|
||||
{
|
||||
dwCID = lpCharacter->GetCID();
|
||||
if(!AggresiveCreatureMap.insert(CIDInCell::value_type(dwCID, CheckInfo(CellID))).second)
|
||||
{
|
||||
DuplicateCID.insert(DUPCID::value_type(dwCID, CheckInfo(CellID)));
|
||||
}
|
||||
|
||||
lpCharacter = lpCell->GetNextCharacter();
|
||||
}
|
||||
}
|
||||
|
||||
CheckMap check(AggresiveCreatureMap);
|
||||
CCreatureManager::GetInstance().ProcessAllCharacter(check);
|
||||
CCreatureManager::GetInstance().ProcessAllMonster(check);
|
||||
|
||||
FILE* fFile = fopen("CellLog.txt", "wt");
|
||||
if(NULL == fFile) { return false; }
|
||||
|
||||
if(DuplicateCID.empty())
|
||||
{
|
||||
fprintf(fFile, "<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ߺ<EFBFBD><DFBA>Ǵ<EFBFBD> CID<49><44> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for(DUPCID::iterator itr = DuplicateCID.begin(); itr != DuplicateCID.end(); ++itr)
|
||||
{
|
||||
fprintf(fFile, "<EFBFBD><EFBFBD> <20>ȿ<EFBFBD><C8BF><EFBFBD> <20>ߺ<EFBFBD><DFBA>Ǵ<EFBFBD> CID:0x%08x - CellID:%d", itr->first,
|
||||
itr->second.m_dwCellID);
|
||||
}
|
||||
}
|
||||
|
||||
if(AggresiveCreatureMap.empty())
|
||||
{
|
||||
fprintf(fFile, "ũ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʿ<EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD>̵<EFBFBD> <20><><EFBFBD>Դϴ<D4B4>.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for(CIDInCell::iterator itr = AggresiveCreatureMap.begin(); itr != AggresiveCreatureMap.end(); ++itr)
|
||||
{
|
||||
fprintf(fFile, "ũ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʿ<EFBFBD> <20><><EFBFBD><EFBFBD> CID:0x%08x - CellID:%d", itr->first,
|
||||
itr->second.m_dwCellID);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CDuelCellManager::CheckCellStatus(void)
|
||||
{
|
||||
// <20><> <20><><EFBFBD>¸<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>κ<EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>.
|
||||
FILE* fFile = fopen("CellStat.txt", "wt");
|
||||
if(NULL == fFile)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf(fFile, "X,Z,<2C>ο<EFBFBD><CEBF><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>\r\n");
|
||||
|
||||
for(DuelCellMap::iterator itr = m_CellData.begin(); itr != m_CellData.end(); ++itr)
|
||||
{
|
||||
CCell* lpCell = itr->second;
|
||||
unsigned long CellID = itr->first;
|
||||
|
||||
fprintf(fFile, "%4d\t%4d\t%4d\r\n",
|
||||
CellID, lpCell->GetCharacterNum(), lpCell->GetItemNum());
|
||||
}
|
||||
|
||||
fclose(fFile);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
#ifndef _DUELCELL_MANAGER_H_
|
||||
#define _DUELCELL_MANAGER_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../FieldMap/Cell.h"
|
||||
#include <Pattern/Singleton.h>
|
||||
|
||||
class CDuelCellManager : public CSingleton<CDuelCellManager>
|
||||
{
|
||||
public:
|
||||
|
||||
~CDuelCellManager() { }
|
||||
|
||||
CCell* CreateCell(unsigned long dwCID);
|
||||
bool DestroyCell(unsigned long dwCID);
|
||||
|
||||
CCell* GetCell(unsigned long dwCellID); // <20><> <20><>ȣ<EFBFBD><C8A3> <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
|
||||
inline void LowerResolution(int nHighX, int nHighZ, int *nLowX, int *nLowZ);
|
||||
inline void HigherResolution(int nLowX, int nLowZ, int *nHighX, int *nHighZ);
|
||||
|
||||
template<typename FnRefCell>
|
||||
inline bool ProcessAllCell(FnRefCell fnRefCell)
|
||||
{
|
||||
if (0 == m_CellData.size()) return false;
|
||||
|
||||
for(DuelCellMap::iterator itr = m_CellData.begin(); itr != m_CellData.end(); ++itr)
|
||||
{
|
||||
fnRefCell(*itr->second);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename FnRefCell, typename Arg1>
|
||||
inline bool ProcessAllCell(FnRefCell fnRefCell, Arg1 arg1)
|
||||
{
|
||||
if (0 == m_CellData.size()) return false;
|
||||
|
||||
for(DuelCellMap::iterator itr = m_CellData.begin(); itr != m_CellData.end(); ++itr)
|
||||
{
|
||||
fnRefCell(*itr->second, arg1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD><D4BC><EFBFBD>
|
||||
|
||||
bool CheckCellAggresiveCreatures(void); // <20><> <20><><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> CID<49><44> <20>ִ<EFBFBD><D6B4><EFBFBD> <20>˻<EFBFBD>.
|
||||
bool CheckCellStatus(void); // <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CDuelCellManager() { }
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// member variable
|
||||
typedef std::map<unsigned long, CCell*> DuelCellMap;
|
||||
|
||||
DuelCellMap m_CellData;
|
||||
|
||||
static CDuelCellManager ms_this;
|
||||
};
|
||||
|
||||
inline CCell* CDuelCellManager::GetCell(unsigned long dwCellID)
|
||||
{
|
||||
DuelCellMap::iterator it = m_CellData.find(dwCellID);
|
||||
return (it != m_CellData.end()) ? it->second : NULL;
|
||||
}
|
||||
|
||||
inline void CDuelCellManager::LowerResolution(int nHighX, int nHighZ, int *nLowX, int *nLowZ)
|
||||
{
|
||||
*nLowX = nHighX >> CCell::CELL_RESOLUTION;
|
||||
*nLowZ = nHighZ >> CCell::CELL_RESOLUTION;
|
||||
}
|
||||
|
||||
|
||||
inline void CDuelCellManager::HigherResolution(int nLowX, int nLowZ, int *nHighX, int *nHighZ) {
|
||||
*nHighX = nLowX << CCell::CELL_RESOLUTION;
|
||||
*nHighZ = nLowZ << CCell::CELL_RESOLUTION;
|
||||
}
|
||||
|
||||
#endif+
|
||||
Reference in New Issue
Block a user