📄 map.cpp
字号:
#include "stdafx.h"
#include "Map.h"
#include <macro.h>
#include "FieldInfo.h"
#include "Field.h"
#include "GameZone.h"
Map::Map()
{
m_FieldHashTable.Initialize( _MAX_FIELD_IN_MAP_NUM );
}
Map::~Map()
{
}
// 固记狼 版快俊绰 甘俊 加秦乐绰 葛电 鞘靛甫 固府 父甸绢 初瘤父, 清泼篮 秦寸 鞘靛 窍唱父 父甸搁 等促.
// iFieldIndex啊 -1牢 版快俊绰 肺厚, 固记栏肺 埃林窃
VOID Map::Init( MapInfo * pMapInfo, int iFieldIndex,
CMemoryPoolFactory<Field> * pFieldPool,
CMemoryPoolFactory<SectorGroup> * pSectorGroupPool,
CMemoryPoolFactory<Sector> * pSectorPool )
{
m_pMapInfo = pMapInfo;
typedef util::SolarHashTable<FieldInfo *> FIELDINFO_HASH;
FIELDINFO_HASH * pFieldInfoHash = m_pMapInfo->GetFieldInfoHashTable();
BYTE idx = 0;
for( FIELDINFO_HASH::iterator it = pFieldInfoHash->begin() ; it != pFieldInfoHash->end() ; ++it, ++idx )
{
FieldInfo * pFieldInfo = *it;
if( iFieldIndex != -1 && idx != iFieldIndex ) continue;
Field * pNewField = pFieldPool->Alloc();
pNewField->Init( this, pFieldInfo, pMapInfo->GetMapInfo()->FGCode[idx], pSectorGroupPool, pSectorPool );
addField( pNewField );
}
}
VOID Map::Release( CMemoryPoolFactory<Field> * pFieldPool,
CMemoryPoolFactory<SectorGroup> * pSectorGroupPool, CMemoryPoolFactory<Sector> * pSectorPool )
{
Field * pField = NULL;
m_FieldHashTable.SetFirst();
while( (pField = m_FieldHashTable.GetNext()) != NULL )
{
pField->Release( pSectorGroupPool, pSectorPool );
pFieldPool->Free(pField);
}
m_FieldHashTable.RemoveAll();
}
MapInfo * Map::GetMapInfo()
{
return m_pMapInfo;
}
CODETYPE Map::GetMapCode()
{
return m_pMapInfo->GetMapCode();
}
BOOL Map::CheckMapVersion(CODETYPE dwCodeType, DWORD dwCheckSum)
{
Field* pField = GetFieldx(dwCodeType);
if( NULL == pField )
{
return FALSE;
}
return pField->CheckMapVersion( dwCheckSum );
}
VOID Map::Update( DWORD dwDeltaTick )
{
Field * pField = NULL;
m_FieldHashTable.SetFirst();
while( (pField = m_FieldHashTable.GetNext()) != NULL )
{
pField->Update( dwDeltaTick );
}
}
VOID Map::addField( Field * pField )
{
m_FieldHashTable.Add( pField, pField->GetFieldCode() );
}
DWORD Map::GetTotalMonsterNum()
{
DWORD dwNum = 0;
Field * pField = NULL;
m_FieldHashTable.SetFirst();
while( (pField = m_FieldHashTable.GetNext()) != NULL )
{
dwNum += pField->GetNPCList()->size();
}
return dwNum;
}
eZONETYPE Map::GetZoneType()
{
return m_pGameZone->GetZoneType();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -