108 lines
2.0 KiB
C++
108 lines
2.0 KiB
C++
#include "stdafx.h"
|
|
#include "GameZone.h"
|
|
//
|
|
#include "GameField.h"
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//
|
|
BOOL GameZone::SetCurrentField(FIELDCODE mcFIELDCODE)
|
|
{
|
|
GAME_FIELD_LIST_IT itFIND;
|
|
BOOL bFail = !_GetRefGameField(mcFIELDCODE, itFIND);
|
|
|
|
if(bFail)
|
|
{
|
|
m_pCurrentField = NULL;
|
|
return FALSE;
|
|
}
|
|
|
|
sPAIR& rPAIR = *itFIND;
|
|
GameField* pFIELD = rPAIR.pGAMEFIELD;
|
|
|
|
m_pCurrentField = pFIELD;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
DWORD GameZone::GetMapVersion(FIELDCODE mcFIELDCODE)
|
|
{
|
|
if(m_GameFieldList.size() == 0)
|
|
return 0;
|
|
|
|
GAME_FIELD_LIST_IT it;
|
|
|
|
if(!mcFIELDCODE)
|
|
it = m_GameFieldList.begin();
|
|
else
|
|
{
|
|
if(!_GetRefGameField(mcFIELDCODE, it))
|
|
return 0;
|
|
}
|
|
|
|
sPAIR& rPAIR = *it;
|
|
GameField* pFIELD = rPAIR.pGAMEFIELD;
|
|
C3D_WORLD_BASE interfaceOfEngine = pFIELD->FIELD_INFO().INTERFACEofENGINE();
|
|
|
|
return interfaceOfEngine.GetCheckSum();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//
|
|
void GameZone::Init(MAPCODE mcCODE)
|
|
{
|
|
_Clear();
|
|
|
|
m_MapCode = mcCODE;
|
|
}
|
|
|
|
void GameZone::Release()
|
|
{
|
|
ObjectPoolRouter* pROUTER = ObjectPoolRouter::Instance();
|
|
|
|
GAME_FIELD_LIST_IT it(m_GameFieldList.begin()), itend(m_GameFieldList.end());
|
|
for(; it != itend ; ++it)
|
|
{
|
|
sPAIR& rPAIR = *it;
|
|
GameField* pFIELD = rPAIR.pGAMEFIELD;
|
|
pFIELD->Release();
|
|
pROUTER->Free(OBJTYPE_GAMEFIELD, pFIELD);
|
|
}
|
|
|
|
_Clear();
|
|
}
|
|
|
|
void GameZone::_Clear()
|
|
{
|
|
m_MapCode = 0;
|
|
m_pCurrentField = NULL;
|
|
m_GameFieldList.clear();
|
|
}
|
|
|
|
void GameZone::_AddGameField(GameField* pGameField)
|
|
{
|
|
FIELDCODE fcFCODE = pGameField->GetFieldCode();
|
|
sPAIR rPAIR;
|
|
rPAIR.mcFIELDCODE = fcFCODE;
|
|
rPAIR.pGAMEFIELD = pGameField;
|
|
m_GameFieldList.push_back(rPAIR);
|
|
}
|
|
|
|
BOOL GameZone::_GetRefGameField(FIELDCODE mcFIELDCODE, GAME_FIELD_LIST_IT& rFIND_IT)
|
|
{
|
|
GAME_FIELD_LIST_IT it(m_GameFieldList.begin()), itend(m_GameFieldList.end());
|
|
for(; it != itend ; ++it)
|
|
{
|
|
sPAIR& rPAIR = *it;
|
|
if(mcFIELDCODE == rPAIR.mcFIELDCODE)
|
|
{
|
|
rFIND_IT = it;
|
|
return TRUE;
|
|
}
|
|
}
|
|
|
|
rFIND_IT = itend;
|
|
|
|
return FALSE;
|
|
}
|
|
|