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,873 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <mmsystem.h>
|
||||
|
||||
#include <Utility/Math/Math.h>
|
||||
|
||||
#include <Creature/Character/Character.h>
|
||||
#include <Creature/Monster/PatternMonster.h>
|
||||
#include <Creature/Monster/VirtualMonsterMgr.h>
|
||||
|
||||
#include <Network/Dispatch/GameClient/SendCharBGServer.h>
|
||||
#include <Network/Dispatch/GameClient/GameClientDispatch.h>
|
||||
#include <Network/Dispatch/GameClient/SendCharEtc.h>
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Packet/PacketStruct/BGServerPacket.h>
|
||||
|
||||
#include "BGServerMap.h"
|
||||
|
||||
using namespace VirtualArea;
|
||||
|
||||
CBGServerMap::CBGServerMap(const VirtualArea::ProtoType* lpProtoType, unsigned short wMapNumber)
|
||||
: CVirtualArea(lpProtoType, VirtualArea::BGSERVERMAP | wMapNumber), m_MapInfo(lpProtoType->m_cMapType), m_cStatus(START_WAITING)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CBGServerMap::~CBGServerMap(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned short CBGServerMap::Enter(CCharacter* lpCharacter, unsigned char cMoveType)
|
||||
{
|
||||
if (false == IsPlaying())
|
||||
{
|
||||
return PktBase::SERVER_ERROR;
|
||||
}
|
||||
|
||||
switch (cMoveType)
|
||||
{
|
||||
case TYPE_PLAYER:
|
||||
{
|
||||
return AddCharacter(lpCharacter);
|
||||
}
|
||||
|
||||
case TYPE_SPECTATOR:
|
||||
{
|
||||
return AddSpectator(lpCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
return PktBase::SERVER_ERROR;
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMap::Leave(CCharacter* lpCharacter)
|
||||
{
|
||||
if (NULL == lpCharacter) return false;
|
||||
|
||||
char szNation[8];
|
||||
if (lpCharacter->GetRace() == CClass::HUMAN) strcpy(szNation, "HUMAN");
|
||||
else strcpy(szNation, "AKHAN");
|
||||
|
||||
CharacterList::iterator pos = std::find(m_CharacterList.begin(), m_CharacterList.end(), lpCharacter);
|
||||
if (pos != m_CharacterList.end())
|
||||
{
|
||||
--m_MapInfo.m_cCurrentCharNum[ lpCharacter->GetRace() ];
|
||||
m_CharacterList.erase(pos);
|
||||
|
||||
m_MapInfo.m_PersonalInfoMap.erase( lpCharacter->GetCID() );
|
||||
|
||||
// <20>α<EFBFBD>
|
||||
DETLOG5(g_Log, "Battle Server Log :: (Channel : %d, %s) - CID : 0x%08x ij<><C4B3><EFBFBD><EFBFBD>(%s, %s)<29><> <20><><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD><CCBD>ϴ<EFBFBD>.",
|
||||
(m_wMapIndex & ~VirtualArea::BGSERVERMAP), GetMapTypeName(),
|
||||
lpCharacter->GetCID(), lpCharacter->GetCharacterName(), szNation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pos = std::find(m_SpectatorList.begin(), m_SpectatorList.end(), lpCharacter);
|
||||
if (pos != m_SpectatorList.end())
|
||||
{
|
||||
m_SpectatorList.erase(pos);
|
||||
|
||||
// <20>α<EFBFBD>
|
||||
DETLOG5(g_Log, "Battle Server Log :: (Channel : %d, %s) - CID : 0x%08x ij<><C4B3><EFBFBD><EFBFBD>(%s, %s)<29><> <20><><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD><CCBD>ϴ<EFBFBD>.",
|
||||
(m_wMapIndex & ~VirtualArea::BGSERVERMAP), GetMapTypeName(),
|
||||
lpCharacter->GetCID(), lpCharacter->GetCharacterName(), szNation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
unsigned short CBGServerMap::AddCharacter(CCharacter* lpCharacter)
|
||||
{
|
||||
if (NULL == lpCharacter)
|
||||
{
|
||||
return PktBase::SERVER_ERROR;
|
||||
}
|
||||
|
||||
if (m_MapInfo.m_cMaxCharNumOfNation <= m_MapInfo.m_cCurrentCharNum[ lpCharacter->GetRace() ])
|
||||
{
|
||||
return PktBGServerMoveZone::FAIL_FULL_MAP;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>ο<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ɱ<EFBFBD>
|
||||
if (m_MapInfo.m_cCurrentCharNum[ lpCharacter->GetRace() ] >= 10)
|
||||
{
|
||||
if ( (lpCharacter->GetRace() == CClass::HUMAN && m_MapInfo.m_cCurrentCharNum[CClass::HUMAN] >= m_MapInfo.m_cCurrentCharNum[CClass::AKHAN] * 1.5) ||
|
||||
(lpCharacter->GetRace() == CClass::AKHAN && m_MapInfo.m_cCurrentCharNum[CClass::AKHAN] >= m_MapInfo.m_cCurrentCharNum[CClass::HUMAN] * 1.5) )
|
||||
{
|
||||
return PktBGServerMoveZone::FAIL_FIX_RATE;
|
||||
}
|
||||
}
|
||||
|
||||
++m_MapInfo.m_cCurrentCharNum[ lpCharacter->GetRace() ];
|
||||
m_CharacterList.push_back(lpCharacter);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><C3B0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>صд<D8B5>. (<28><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><C3B0><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ؼ<EFBFBD>...)
|
||||
MapInfo::PersonalInfo personalInfo(m_MapInfo.m_cRemainPlayMin);
|
||||
m_MapInfo.m_PersonalInfoMap.insert( make_pair(lpCharacter->GetCID(), personalInfo) );
|
||||
|
||||
// <20>α<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char szNation[8];
|
||||
if (lpCharacter->GetRace() == CClass::HUMAN)
|
||||
{
|
||||
strcpy(szNation, "HUMAN");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(szNation, "AKHAN");
|
||||
}
|
||||
|
||||
DETLOG5(g_Log, "Battle Server Log :: (Channel : %d, %s) - CID : 0x%08x ij<><C4B3><EFBFBD><EFBFBD>(%s, %s)<29><> Player <20><> <20><><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>ϴ<EFBFBD>.",
|
||||
(m_wMapIndex & ~VirtualArea::BGSERVERMAP), GetMapTypeName(),
|
||||
lpCharacter->GetCID(), lpCharacter->GetCharacterName(), szNation);
|
||||
|
||||
return PktBase::NO_SERVER_ERR;
|
||||
}
|
||||
|
||||
|
||||
unsigned short CBGServerMap::AddSpectator(CCharacter* lpSpectator)
|
||||
{
|
||||
if (NULL == lpSpectator)
|
||||
{
|
||||
return PktBase::SERVER_ERROR;
|
||||
}
|
||||
|
||||
m_SpectatorList.push_back(lpSpectator);
|
||||
|
||||
// <20>α<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char szNation[8];
|
||||
if (lpSpectator->GetRace() == CClass::HUMAN) strcpy(szNation, "HUMAN");
|
||||
else strcpy(szNation, "AKHAN");
|
||||
|
||||
DETLOG5(g_Log, "Battle Server Log :: (Channel : %d, %s) - CID : 0x%08x ij<><C4B3><EFBFBD><EFBFBD>(%s, %s)<29><> Spectator <20><> <20><><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>ϴ<EFBFBD>.",
|
||||
(m_wMapIndex & ~VirtualArea::BGSERVERMAP), GetMapTypeName(),
|
||||
lpSpectator->GetCID(), lpSpectator->GetCharacterName(), szNation);
|
||||
|
||||
return PktBase::NO_SERVER_ERR;
|
||||
}
|
||||
|
||||
bool CBGServerMap::IsPlayer(CCharacter* lpCharacter)
|
||||
{
|
||||
if (NULL == lpCharacter) return false;
|
||||
|
||||
CharacterList::iterator pos = std::find(m_CharacterList.begin(), m_CharacterList.end(), lpCharacter);
|
||||
if (pos != m_CharacterList.end()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBGServerMap::IsSpectator(CCharacter* lpCharacter)
|
||||
{
|
||||
if (NULL == lpCharacter) return false;
|
||||
|
||||
CharacterList::iterator pos = std::find(m_SpectatorList.begin(), m_SpectatorList.end(), lpCharacter);
|
||||
if (pos != m_SpectatorList.end()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20>̵<EFBFBD>
|
||||
bool CBGServerMap::AllRespawn()
|
||||
{
|
||||
if (0 == m_CharacterList.size() && 0 == m_SpectatorList.size()) return true;
|
||||
|
||||
bool bResult = true;
|
||||
CharacterList::iterator pos = m_CharacterList.begin();
|
||||
CharacterList::iterator end = m_CharacterList.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL == (*pos)) continue;
|
||||
|
||||
CGameClientDispatch* lpDispatch = (*pos)->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
if (false == GameClientSendPacket::SendCharBGServerMoveZone(lpDispatch->GetSendStream(), SERVER_ID::BATTLE_SERVER, VirtualArea::TYPE_PLAYER, PktBase::NO_SERVER_ERR))
|
||||
{
|
||||
ERRLOG2(g_Log, "CID:0x%08x ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.", (*pos)->GetCID(), (*pos)->GetMapIndex());
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
Position RespawnPos(VirtualArea::RespawnPos[ (*pos)->GetRace() ][ Math::Random::ComplexRandom(VirtualArea::MAX_LOBBY_RESPAWN_POS) ]);
|
||||
RespawnPos.m_fPointX += Math::Random::SimpleRandom(GetTickCount(), 20) - 10;
|
||||
RespawnPos.m_fPointZ += Math::Random::SimpleRandom(GetTickCount(), 20) - 10;
|
||||
|
||||
(*pos)->SetMapIndex(0);
|
||||
(*pos)->GetEnchantInfo().ResetFlag(Skill::SpellID::Hide);
|
||||
(*pos)->MoveTo(RespawnPos, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRLOG2(g_Log, "CID:0x%08x ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.", (*pos)->GetCID(), (*pos)->GetMapIndex());
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<><C3B3>
|
||||
pos = m_SpectatorList.begin();
|
||||
end = m_SpectatorList.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL == (*pos)) continue;
|
||||
|
||||
CGameClientDispatch* lpDispatch = (*pos)->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
if (false == GameClientSendPacket::SendCharBGServerMoveZone(lpDispatch->GetSendStream(), SERVER_ID::BATTLE_SERVER, VirtualArea::TYPE_PLAYER, PktBase::NO_SERVER_ERR))
|
||||
{
|
||||
ERRLOG2(g_Log, "CID:0x%08x ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.", (*pos)->GetCID(), (*pos)->GetMapIndex());
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
Position RespawnPos(VirtualArea::RespawnPos[ (*pos)->GetRace() ][ Math::Random::ComplexRandom(VirtualArea::MAX_LOBBY_RESPAWN_POS) ]);
|
||||
RespawnPos.m_fPointX += Math::Random::SimpleRandom(GetTickCount(), 20) - 10;
|
||||
RespawnPos.m_fPointZ += Math::Random::SimpleRandom(GetTickCount(), 20) - 10;
|
||||
|
||||
(*pos)->SetMapIndex(0);
|
||||
(*pos)->GetEnchantInfo().ResetFlag(Skill::SpellID::Hide);
|
||||
(*pos)->MoveTo(RespawnPos, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRLOG2(g_Log, "CID:0x%08x ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.", (*pos)->GetCID(), (*pos)->GetMapIndex());
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>Ʈ Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
m_CharacterList.clear();
|
||||
m_SpectatorList.clear();
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CBGServerMap::Process()
|
||||
{
|
||||
unsigned long dwCurrentTime = timeGetTime();
|
||||
int nMin = 0, nSec = 0;
|
||||
|
||||
if (m_dwRemainTime < dwCurrentTime) nMin = 0;
|
||||
else
|
||||
{
|
||||
nMin = (m_dwRemainTime - dwCurrentTime) / MILLISEC_PER_MINUTE;
|
||||
nSec = (m_dwRemainTime - dwCurrentTime) % MILLISEC_PER_MINUTE;
|
||||
if (nSec > 0) ++nMin;
|
||||
}
|
||||
|
||||
switch (m_cStatus)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> Start <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>¶<EFBFBD><C2B6><EFBFBD> <20>ƹ<EFBFBD><C6B9>͵<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʴ´<CAB4>.
|
||||
case START_WAITING: return;
|
||||
|
||||
case GAME_PLAYING:
|
||||
{
|
||||
// 1<>п<EFBFBD> <20>ѹ<EFBFBD><D1B9><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ð<EFBFBD><C3B0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
||||
if (nMin < m_MapInfo.m_cRemainPlayMin)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20>ð<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
m_MapInfo.m_cRemainPlayMin = static_cast<unsigned char>(nMin);
|
||||
|
||||
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
SendMapInfo();
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>ð<EFBFBD><C3B0><EFBFBD> <20><> <20>Ǿ<EFBFBD><C7BE>ٸ<EFBFBD>,
|
||||
if (0 == m_MapInfo.m_cRemainPlayMin)
|
||||
{
|
||||
// <20><><EFBFBD>и<EFBFBD> üũ <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
m_ResultInfo.m_cWinRace = RuleCheck(true);
|
||||
std::copy(&m_MapInfo.m_wScore[0], &m_MapInfo.m_wScore[CClass::MAX_RACE], &m_ResultInfo.m_wScore[0]);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// <20>̱<EFBFBD> <20><><EFBFBD><EFBFBD>, Ȥ<><C8A4> <20><><EFBFBD>º<EFBFBD> ij<><C4B3><EFBFBD>͵鿡<CDB5><E9BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ش<EFBFBD>.
|
||||
SendResultInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ResultInfo.m_cWinRace = RuleCheck();
|
||||
|
||||
// <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ǥ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><DEBC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if (CClass::MAX_RACE != m_ResultInfo.m_cWinRace)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
std::copy(&m_MapInfo.m_wScore[0], &m_MapInfo.m_wScore[CClass::MAX_RACE], &m_ResultInfo.m_wScore[0]);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// <20>̱<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD>͵鿡<CDB5><E9BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ش<EFBFBD>.
|
||||
SendResultInfo();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_RESTING:
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20>ð<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
m_MapInfo.m_cRemainRestMin = static_cast<unsigned char>(nMin);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>ð<EFBFBD><C3B0><EFBFBD> <20><> <20>Ǿ<EFBFBD><C7BE>ٸ<EFBFBD>,
|
||||
if (0 == m_MapInfo.m_cRemainRestMin)
|
||||
{
|
||||
GameStart();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MOVEZONE_WAITING:
|
||||
{
|
||||
// <20><><EFBFBD>̵<EFBFBD> <20><>ų <20>ð<EFBFBD><C3B0><EFBFBD> <20><> <20>Ǿ<EFBFBD><C7BE>ٸ<EFBFBD>,
|
||||
if (m_dwRemainTime <= timeGetTime())
|
||||
{
|
||||
SetStatus(GAME_RESTING);
|
||||
m_dwRemainTime = timeGetTime() + m_MapInfo.m_cRestMin * MILLISEC_PER_MINUTE;
|
||||
|
||||
// ij<><C4B3><EFBFBD>͵<EFBFBD><CDB5><EFBFBD> <20><> <20>̵<EFBFBD> <20><>Ų<EFBFBD><C5B2>. (<28>κ<EFBFBD><CEBA><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
AllRespawn();
|
||||
|
||||
// Item<65><6D> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
DeleteAllItem();
|
||||
|
||||
// <20><> <20><><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ
|
||||
m_MapInfo.Initialize();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMap::GameStart() // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
{
|
||||
m_dwRemainTime = timeGetTime() + m_MapInfo.m_cLimitMin * MILLISEC_PER_MINUTE;
|
||||
InitializeGameObject();
|
||||
|
||||
SetStatus(GAME_PLAYING);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMap::InitializeGameObject()
|
||||
{
|
||||
m_CharacterList.clear();
|
||||
m_SpectatorList.clear();
|
||||
|
||||
m_MapInfo.Initialize();
|
||||
m_ResultInfo.Initialize();
|
||||
|
||||
if (STATUE == m_MapInfo.m_cMapType && NULL != GetMonsterManager())
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>̰<EFBFBD>, <20>ƹ<EFBFBD><C6B9>͵<EFBFBD> <20><>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD> <20>ʴ´<CAB4>.
|
||||
CVirtualMonsterMgr::MonsterMap::iterator pos = m_pVirtualMonsterMgr->GetMonsterMap().begin();
|
||||
CVirtualMonsterMgr::MonsterMap::iterator end = m_pVirtualMonsterMgr->GetMonsterMap().end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
CMonster* lpMonster = pos->second;
|
||||
if (NULL == lpMonster) continue;
|
||||
|
||||
CStatue* lpStatue = lpMonster->DowncastToStatue();
|
||||
if (NULL != lpStatue)
|
||||
{
|
||||
lpStatue->Rest();
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
|
||||
// <20><EFBFBD>, <20>߸<EFBFBD>, <20><>ĭ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȯ<EFBFBD>Ѵ<EFBFBD>.
|
||||
enum { HUMAN_STATUE = 0, NUETRALITY_STATUE1 = 1, AKHAN_STATUE = 2, NUETRALITY_STATUE2 = 3, NUETRALITY_STATUE3 = 4, NONE = 100 };
|
||||
DWORD dwKind, dwOldKind = NONE;
|
||||
|
||||
pos = m_pVirtualMonsterMgr->GetMonsterMap().begin();
|
||||
end = m_pVirtualMonsterMgr->GetMonsterMap().end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
CMonster* lpMonster = pos->second;
|
||||
if (NULL == lpMonster) continue;
|
||||
|
||||
CStatue* lpStatue = lpMonster->DowncastToStatue();
|
||||
if (NULL != lpStatue)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ <20><>Ű<EFBFBD><C5B0>
|
||||
// !!<21><><EFBFBD><EFBFBD>!! <20><>ũ<EFBFBD><C5A9>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>. (HUMAN_STATUE = 0, NUETRALITY_STATUE1 = 1, AKHAN_STATUE = 2, NUETRALITY_STATUE2 = 3, NUETRALITY_STATUE3 = 4)
|
||||
dwKind = (lpStatue->GetCID() & ~(Creature::MONSTER_BIT | Creature::MONSTER_KIND_BIT)) >> 16;
|
||||
if (dwOldKind != dwKind)
|
||||
{
|
||||
switch (dwKind)
|
||||
{
|
||||
case HUMAN_STATUE:
|
||||
lpStatue = lpStatue->GetLinkStatue(MonsterInfo::BG_STATUE_HUMAN_COMPLETE1);
|
||||
lpStatue->InitMonster(lpStatue->GetOriginalPos());
|
||||
break;
|
||||
|
||||
case NUETRALITY_STATUE1:
|
||||
case NUETRALITY_STATUE2:
|
||||
case NUETRALITY_STATUE3:
|
||||
lpStatue = lpStatue->GetLinkStatue(MonsterInfo::BG_STATUE_NEUTRALITY1);
|
||||
lpStatue->InitMonster(lpStatue->GetOriginalPos());
|
||||
break;
|
||||
|
||||
case AKHAN_STATUE:
|
||||
lpStatue = lpStatue->GetLinkStatue(MonsterInfo::BG_STATUE_AKHAN_COMPLETE1);
|
||||
lpStatue->InitMonster(lpStatue->GetOriginalPos());
|
||||
break;
|
||||
}
|
||||
|
||||
dwOldKind = dwKind;
|
||||
}
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD> <20>ʱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
CalculateScore();
|
||||
|
||||
// <20>α<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
DETLOG4(g_Log, "Battle Server Log :: (Channel : %d, %s) - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ <20>մϴ<D5B4>. (<28><><EFBFBD><EFBFBD> Score - HM: %d AK: %d)",
|
||||
(m_wMapIndex & ~VirtualArea::BGSERVERMAP), GetMapTypeName(),
|
||||
m_MapInfo.m_wScore[CClass::HUMAN], m_MapInfo.m_wScore[CClass::AKHAN]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned char CBGServerMap::RuleCheck(bool bTimeout) // <20><><EFBFBD><EFBFBD> üũ<C3BC>ؼ<EFBFBD> <20>̱<EFBFBD><CCB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
{
|
||||
unsigned char cWinNation = CClass::MAX_RACE;
|
||||
|
||||
// <20>ð<EFBFBD><C3B0><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ٸ<EFBFBD>, Ȥ<><C8A4> <20><EFBFBD><EEBFB5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3><EFBFBD><EFBFBD>
|
||||
if (true == bTimeout)
|
||||
{
|
||||
if (m_MapInfo.m_wScore[CClass::HUMAN] > m_MapInfo.m_wScore[CClass::AKHAN])
|
||||
{
|
||||
cWinNation = CClass::HUMAN;
|
||||
}
|
||||
else if (m_MapInfo.m_wScore[CClass::HUMAN] < m_MapInfo.m_wScore[CClass::AKHAN])
|
||||
{
|
||||
cWinNation = CClass::AKHAN;
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20>̰<EFBFBD><CCB0><EFBFBD><EFBFBD><EFBFBD> CClass::MAX_RACE <20><> <20><><EFBFBD>º<EFBFBD><C2BA>̴<EFBFBD>.
|
||||
}
|
||||
|
||||
SetStatus(MOVEZONE_WAITING);
|
||||
m_dwRemainTime = timeGetTime() + MOVEZONE_WAIT_TIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20><>ǥ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ߴ°<DFB4> üũ
|
||||
if (m_MapInfo.m_wScore[CClass::HUMAN] >= m_MapInfo.m_wTargetScore)
|
||||
{
|
||||
cWinNation = CClass::HUMAN;
|
||||
|
||||
SetStatus(MOVEZONE_WAITING);
|
||||
m_dwRemainTime = timeGetTime() + MOVEZONE_WAIT_TIME;
|
||||
}
|
||||
else if (m_MapInfo.m_wScore[CClass::AKHAN] >= m_MapInfo.m_wTargetScore)
|
||||
{
|
||||
cWinNation = CClass::AKHAN;
|
||||
|
||||
SetStatus(MOVEZONE_WAITING);
|
||||
m_dwRemainTime = timeGetTime() + MOVEZONE_WAIT_TIME;
|
||||
}
|
||||
|
||||
// <20>̰<EFBFBD><CCB0><EFBFBD><EFBFBD><EFBFBD> CClass::MAX_RACE <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD>.
|
||||
}
|
||||
|
||||
return cWinNation;
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMap::AwardToWinner()
|
||||
{
|
||||
unsigned short wAwardBase, wRealPlayMin;
|
||||
unsigned short wPlayMin = m_MapInfo.m_cLimitMin - m_MapInfo.m_cRemainPlayMin;
|
||||
if (0 == wPlayMin) wPlayMin = 1;
|
||||
|
||||
CharacterList winnerList;
|
||||
CharacterList::iterator pos;
|
||||
CharacterList::iterator end;
|
||||
|
||||
if (CClass::MAX_RACE == m_ResultInfo.m_cWinRace)
|
||||
{
|
||||
wAwardBase = m_MapInfo.m_cLimitMin * MILEAGE_PER_MINUTE_FOR_DRAW;
|
||||
|
||||
pos = m_CharacterList.begin();
|
||||
end = m_CharacterList.end();
|
||||
}
|
||||
else
|
||||
{
|
||||
wAwardBase = m_MapInfo.m_cLimitMin * MILEAGE_PER_MINUTE_FOR_WIN;
|
||||
|
||||
FindWinner(winnerList);
|
||||
pos = winnerList.begin();
|
||||
end = winnerList.end();
|
||||
}
|
||||
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
MapInfo::PersonalInfoMap::iterator which = m_MapInfo.m_PersonalInfoMap.find( (*pos)->GetCID() );
|
||||
if (which != m_MapInfo.m_PersonalInfoMap.end())
|
||||
{
|
||||
wRealPlayMin = which->second.m_cEnteringMin - m_MapInfo.m_cRemainPlayMin;
|
||||
unsigned short wAward = wAwardBase * wRealPlayMin / wPlayMin;
|
||||
|
||||
(*pos)->SetMileage((*pos)->GetMileage() + wAward);
|
||||
|
||||
CGameClientDispatch* lpDispatch = (*pos)->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
GameClientSendPacket::SendCharFameInfo(lpDispatch->GetSendStream(), (*pos),
|
||||
"", "", 0, 0, PktFIAck::FAME_INFO, PktBase::NO_SERVER_ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMap::KillChar(unsigned long dwDeadCID, CCharacter* lpOffencer)
|
||||
{
|
||||
if (NULL == lpOffencer) return;
|
||||
|
||||
AddScore(lpOffencer->GetRace(), FRAG_SCORE);
|
||||
|
||||
// Kill <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
|
||||
UpdateKillInfo(dwDeadCID, lpOffencer->GetCID());
|
||||
|
||||
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
SendMapInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CBGServerMap::UpdateKillInfo(unsigned long dwDeadCID, unsigned long dwKillerCID)
|
||||
{
|
||||
MapInfo::PersonalInfoMap::iterator pos = m_MapInfo.m_PersonalInfoMap.find( dwDeadCID );
|
||||
if (pos != m_MapInfo.m_PersonalInfoMap.end()) ++pos->second.m_cKilled;
|
||||
|
||||
pos = m_MapInfo.m_PersonalInfoMap.find( dwKillerCID );
|
||||
if (pos != m_MapInfo.m_PersonalInfoMap.end()) ++pos->second.m_cKill;
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMap::AddScore(unsigned char cNation, short wScore)
|
||||
{
|
||||
if (cNation >= CClass::MAX_CLASS) return;
|
||||
m_MapInfo.m_wScore[cNation] += wScore;
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMap::CalculateScore() // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
{
|
||||
if (STATUE == m_MapInfo.m_cMapType && NULL != GetMonsterManager())
|
||||
{
|
||||
std::fill_n(m_MapInfo.m_wScore, int(CClass::MAX_RACE), 0);
|
||||
|
||||
CVirtualMonsterMgr::MonsterMap::iterator pos = m_pVirtualMonsterMgr->GetMonsterMap().begin();
|
||||
CVirtualMonsterMgr::MonsterMap::iterator end = m_pVirtualMonsterMgr->GetMonsterMap().end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
CMonster* lpMonster = pos->second;
|
||||
if (NULL != lpMonster && lpMonster->GetCurrentState() != STATE_ID_DIE)
|
||||
{
|
||||
switch (lpMonster->GetCID() & Creature::MONSTER_KIND_BIT)
|
||||
{
|
||||
case MonsterInfo::BG_STATUE_HUMAN_LOADING1:
|
||||
{
|
||||
AddScore(CClass::HUMAN, FRIENDLY_LOADING_STATUE_SCORE);
|
||||
break;
|
||||
}
|
||||
|
||||
case MonsterInfo::BG_STATUE_HUMAN_COMPLETE1:
|
||||
{
|
||||
AddScore(CClass::HUMAN, FRIENDLY_STATUE_SCORE);
|
||||
break;
|
||||
}
|
||||
|
||||
case MonsterInfo::BG_STATUE_AKHAN_LOADING1:
|
||||
{
|
||||
AddScore(CClass::AKHAN, FRIENDLY_LOADING_STATUE_SCORE);
|
||||
break;
|
||||
}
|
||||
|
||||
case MonsterInfo::BG_STATUE_AKHAN_COMPLETE1:
|
||||
{
|
||||
AddScore(CClass::AKHAN, FRIENDLY_STATUE_SCORE);
|
||||
break;
|
||||
}
|
||||
|
||||
case MonsterInfo::BG_STATUE_NEUTRALITY1:
|
||||
{
|
||||
AddScore(CClass::AKHAN, NEUTRALITY_STATUE_SCORE);
|
||||
AddScore(CClass::HUMAN, NEUTRALITY_STATUE_SCORE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// <20>ڱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> <20>Լ<EFBFBD>
|
||||
bool CBGServerMap::SendMapInfo()
|
||||
{
|
||||
if (0 == m_CharacterList.size() && 0 == m_SpectatorList.size()) return true;
|
||||
|
||||
const int MAX_BUFFER = sizeof(PktBGServerMapList) + sizeof(BGServerMapInfoNode);
|
||||
char szBuffer[MAX_BUFFER];
|
||||
|
||||
PktBGServerMapList* lpPktBGSMLAck = reinterpret_cast<PktBGServerMapList *>(szBuffer);
|
||||
BGServerMapInfoNode* lpMapInfoNode = reinterpret_cast<BGServerMapInfoNode *>(lpPktBGSMLAck + 1);
|
||||
|
||||
lpPktBGSMLAck->m_bAll = false;
|
||||
lpPktBGSMLAck->m_cMapInfoNodeNum = 1;
|
||||
|
||||
lpMapInfoNode->m_bPlaying = IsPlaying();
|
||||
lpMapInfoNode->m_cMapType = m_MapInfo.m_cMapType;
|
||||
lpMapInfoNode->m_cMaxCharNumOfNation = m_MapInfo.m_cMaxCharNumOfNation;
|
||||
lpMapInfoNode->m_wTargetScore = m_MapInfo.m_wTargetScore;
|
||||
//lpMapInfoNode->m_cRemainMin = (IsPlaying() == true) ? m_MapInfo.m_cRemainPlayMin : m_MapInfo.m_cRemainRestMin;
|
||||
lpMapInfoNode->m_cRemainMin = (IsPlaying() == true) ? m_MapInfo.m_cRemainPlayMin : 0;
|
||||
|
||||
lpMapInfoNode->m_cCurrentCharNum[CClass::HUMAN] = m_MapInfo.m_cCurrentCharNum[CClass::HUMAN];
|
||||
lpMapInfoNode->m_cCurrentCharNum[CClass::AKHAN] = m_MapInfo.m_cCurrentCharNum[CClass::AKHAN];
|
||||
lpMapInfoNode->m_wScore[CClass::HUMAN] = m_MapInfo.m_wScore[CClass::HUMAN];
|
||||
lpMapInfoNode->m_wScore[CClass::AKHAN] = m_MapInfo.m_wScore[CClass::AKHAN];
|
||||
|
||||
// ij<><C4B3><EFBFBD><EFBFBD> ó<><C3B3>
|
||||
CharacterList::iterator pos = m_CharacterList.begin();
|
||||
CharacterList::iterator end = m_CharacterList.end();
|
||||
CGameClientDispatch* lpDispatch = NULL;
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL == (*pos)) continue;
|
||||
lpDispatch = (*pos)->GetDispatcher();
|
||||
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
CSendStream& SendStream = lpDispatch->GetSendStream();
|
||||
SendStream.WrapCompress(szBuffer, sizeof(PktBGServerMapList) + sizeof(BGServerMapInfoNode), CmdBGServerMapList, 0, 0);
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<><C3B3>
|
||||
pos = m_SpectatorList.begin();
|
||||
end = m_SpectatorList.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL == (*pos)) continue;
|
||||
lpDispatch = (*pos)->GetDispatcher();
|
||||
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
CSendStream& SendStream = lpDispatch->GetSendStream();
|
||||
SendStream.WrapCompress(szBuffer, sizeof(PktBGServerMapList) + sizeof(BGServerMapInfoNode), CmdBGServerMapList, 0, 0);
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMap::SendResultInfo()
|
||||
{
|
||||
const int MAX_BUFFER = sizeof(PktBGServerResultList) + sizeof(BGServerResultInfoNode);
|
||||
char szBuffer[MAX_BUFFER];
|
||||
|
||||
PktBGServerResultList* lpPktBGSRLAck = reinterpret_cast<PktBGServerResultList *>(szBuffer);
|
||||
BGServerResultInfoNode* lpResultInfoNode = reinterpret_cast<BGServerResultInfoNode *>(lpPktBGSRLAck + 1);
|
||||
|
||||
lpPktBGSRLAck->m_bAll = false;
|
||||
lpPktBGSRLAck->m_cResultInfoNodeNum = 1;
|
||||
|
||||
lpResultInfoNode->m_cWinRace = m_ResultInfo.m_cWinRace;
|
||||
lpResultInfoNode->m_wScore[CClass::HUMAN] = m_ResultInfo.m_wScore[CClass::HUMAN];
|
||||
lpResultInfoNode->m_wScore[CClass::AKHAN] = m_ResultInfo.m_wScore[CClass::AKHAN];
|
||||
|
||||
// ij<><C4B3><EFBFBD><EFBFBD>(<28>÷<EFBFBD><C3B7>̾<EFBFBD>) ó<><C3B3>
|
||||
CharacterList::iterator pos = m_CharacterList.begin();
|
||||
CharacterList::iterator end = m_CharacterList.end();
|
||||
CGameClientDispatch* lpDispatch = NULL;
|
||||
|
||||
unsigned short wAwardBase;
|
||||
if (CClass::MAX_RACE == m_ResultInfo.m_cWinRace) wAwardBase = m_MapInfo.m_cLimitMin * MILEAGE_PER_MINUTE_FOR_DRAW;
|
||||
else wAwardBase = m_MapInfo.m_cLimitMin * MILEAGE_PER_MINUTE_FOR_WIN;
|
||||
|
||||
unsigned short wPlayMin = m_MapInfo.m_cLimitMin - m_MapInfo.m_cRemainPlayMin;
|
||||
if (0 == wPlayMin) wPlayMin = 1;
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL == (*pos)) continue;
|
||||
lpDispatch = (*pos)->GetDispatcher();
|
||||
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
MapInfo::PersonalInfoMap::iterator which = m_MapInfo.m_PersonalInfoMap.find( (*pos)->GetCID() );
|
||||
if (which != m_MapInfo.m_PersonalInfoMap.end())
|
||||
{
|
||||
lpResultInfoNode->m_cPlayMin = which->second.m_cEnteringMin - m_MapInfo.m_cRemainPlayMin;
|
||||
lpResultInfoNode->m_cKill = which->second.m_cKill;
|
||||
lpResultInfoNode->m_cKilled = which->second.m_cKilled;
|
||||
|
||||
RULLOG3(g_Log, "CID:0x%08x <20>̺<EFBFBD>Ʈ<EFBFBD>α<EFBFBD> - %s, Kill : %d, Die : %d",
|
||||
(*pos)->GetCharacterName(), which->second.m_cKill, which->second.m_cKilled);
|
||||
|
||||
// <20><><EFBFBD>ºγ<C2BA> <20>¸<EFBFBD><C2B8><EFBFBD><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
||||
if (CClass::MAX_RACE == m_ResultInfo.m_cWinRace || (*pos)->GetRace() == m_ResultInfo.m_cWinRace)
|
||||
{
|
||||
unsigned short wAward = wAwardBase * lpResultInfoNode->m_cPlayMin / wPlayMin;
|
||||
lpResultInfoNode->m_wAward = wAward;
|
||||
|
||||
(*pos)->SetMileage((*pos)->GetMileage() + wAward);
|
||||
CGameClientDispatch* lpDispatch = (*pos)->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
GameClientSendPacket::SendCharFameInfo(lpDispatch->GetSendStream(), (*pos),
|
||||
"", "", 0, 0, PktFIAck::FAME_INFO, PktBase::NO_SERVER_ERR);
|
||||
}
|
||||
}
|
||||
else lpResultInfoNode->m_wAward = 0;
|
||||
|
||||
CSendStream& SendStream = lpDispatch->GetSendStream();
|
||||
SendStream.WrapCompress(szBuffer, sizeof(PktBGServerResultList) + sizeof(BGServerResultInfoNode), CmdBGServerResultList, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<><C3B3>
|
||||
lpResultInfoNode->m_cPlayMin = 0;
|
||||
lpResultInfoNode->m_wAward = 0;
|
||||
lpResultInfoNode->m_cKill = 0;
|
||||
lpResultInfoNode->m_cKilled = 0;
|
||||
|
||||
pos = m_SpectatorList.begin();
|
||||
end = m_SpectatorList.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL == (*pos)) continue;
|
||||
lpDispatch = (*pos)->GetDispatcher();
|
||||
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
CSendStream& SendStream = lpDispatch->GetSendStream();
|
||||
SendStream.WrapCompress(szBuffer, sizeof(PktBGServerResultList) + sizeof(BGServerResultInfoNode), CmdBGServerResultList, 0, 0);
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CBGServerMap::FindWinner(CharacterList& winnerList)
|
||||
{
|
||||
CharacterList::iterator pos = m_CharacterList.begin();
|
||||
CharacterList::iterator end = m_CharacterList.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
if (m_ResultInfo.m_cWinRace == (*pos)->GetRace())
|
||||
{
|
||||
winnerList.push_back((*pos));
|
||||
}
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMap::DeleteAllItem()
|
||||
{
|
||||
if (NULL == m_CellData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CCell* lpCellPastEnd = m_CellData + GetWidth() * GetHeight();
|
||||
|
||||
for (CCell* lpCell = m_CellData; lpCell != lpCellPastEnd; ++lpCell)
|
||||
{
|
||||
lpCell->DeleteAllItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMap::ResetEnteringMin(unsigned char cMin)
|
||||
{
|
||||
if (m_MapInfo.m_PersonalInfoMap.empty()) return;
|
||||
|
||||
MapInfo::PersonalInfoMap::iterator pos = m_MapInfo.m_PersonalInfoMap.begin();
|
||||
MapInfo::PersonalInfoMap::iterator end = m_MapInfo.m_PersonalInfoMap.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
pos->second.m_cEnteringMin = cMin;
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#ifndef _BATTLEGROUND_SERVER_MAP_H_
|
||||
#define _BATTLEGROUND_SERVER_MAP_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Map/FieldMap/VirtualArea/VirtualAreaConstants.h>
|
||||
#include <Map/FieldMap/VirtualArea/VirtualAreaStructure.h>
|
||||
#include <Map/FieldMap/VirtualArea/VirtualArea.h>
|
||||
|
||||
class CCharacter;
|
||||
class CMonster;
|
||||
|
||||
namespace VirtualArea
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
struct ProtoType;
|
||||
|
||||
class CBGServerMap : public CVirtualArea
|
||||
{
|
||||
public:
|
||||
CBGServerMap(const VirtualArea::ProtoType* lpProtoType, unsigned short wMapNumber);
|
||||
~CBGServerMap(void);
|
||||
|
||||
void Process();
|
||||
unsigned short Enter(CCharacter* lpCharacter, unsigned char cMoveType);
|
||||
bool Leave(CCharacter* lpCharacter);
|
||||
|
||||
bool AllRespawn(); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20>̵<EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
|
||||
bool GameStart(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
unsigned char RuleCheck(bool bTimeout = false); // <20><><EFBFBD><EFBFBD> üũ<C3BC>ؼ<EFBFBD> <20>̱<EFBFBD><CCB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
void AwardToWinner();
|
||||
void KillChar(unsigned long dwDeadCID, CCharacter* lpOffencer);
|
||||
|
||||
void UpdateKillInfo(unsigned long dwDeadCID, unsigned long dwKillerCID);
|
||||
void AddScore(unsigned char cNation, short wScore);
|
||||
void CalculateScore(); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
void ResetEnteringMin(unsigned char cMin);
|
||||
|
||||
|
||||
// Get/Set <20>Լ<EFBFBD>
|
||||
unsigned char GetMapType() { return m_MapInfo.m_cMapType; }
|
||||
MapInfo& GetMapInfo() { return m_MapInfo; }
|
||||
ResultInfo& GetResultInfo() { return m_ResultInfo; }
|
||||
|
||||
unsigned char GetStatus() { return m_cStatus; }
|
||||
void SetStatus(unsigned char cStatus) { m_cStatus = cStatus; }
|
||||
|
||||
void SetRemainTime(unsigned long dwRemainTime) { m_dwRemainTime = dwRemainTime; }
|
||||
|
||||
bool IsPlaying() { return (GAME_PLAYING == m_cStatus); }
|
||||
bool IsResting() { return (GAME_RESTING == m_cStatus); }
|
||||
bool IsPlayer(CCharacter* lpCharacter);
|
||||
bool IsSpectator(CCharacter* lpCharacter);
|
||||
|
||||
|
||||
// <20>ڱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> <20>Լ<EFBFBD>
|
||||
bool SendMapInfo();
|
||||
bool SendResultInfo();
|
||||
|
||||
private:
|
||||
|
||||
bool InitializeGameObject();
|
||||
|
||||
void FindWinner(CharacterList& winnerList);
|
||||
|
||||
unsigned short AddCharacter(CCharacter* lpCharacter);
|
||||
unsigned short AddSpectator(CCharacter* lpSpectator);
|
||||
|
||||
// <20>ٴڿ<D9B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Item <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void DeleteAllItem();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
|
||||
MapInfo m_MapInfo;
|
||||
ResultInfo m_ResultInfo;
|
||||
|
||||
unsigned char m_cStatus;
|
||||
unsigned long m_dwRemainTime; // <20>ð<EFBFBD><C3B0><EFBFBD> <20><><EFBFBD>õ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>κп<CEBA><D0BF><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ð<EFBFBD><C3B0><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BATTLEGROUND_SERVER_MAP_H_
|
||||
@@ -0,0 +1,487 @@
|
||||
#include "stdafx.h"
|
||||
#include "BGServerMgr.h"
|
||||
|
||||
#include <Utility/Math/Math.h>
|
||||
#include <Creature/Character/Character.h>
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Packet/PacketStruct/BGServerPacket.h>
|
||||
|
||||
#include <Network/Dispatch/GameClient/SendCharBGServer.h>
|
||||
#include <Network/Dispatch/GameClient/GameClientDispatch.h>
|
||||
|
||||
#include <Map/FieldMap/CellManager.h>
|
||||
#include <Map/FieldMap/VirtualArea/BGServer/BGServerMap.h>
|
||||
#include <Map/FieldMap/VirtualArea/VirtualAreaMgr.h>
|
||||
|
||||
#include <Skill/SkillTable.h>
|
||||
#include <Skill/Spell/SpellTable.h>
|
||||
#include <Skill/Spell/SpellUtil.h>
|
||||
|
||||
|
||||
using namespace VirtualArea;
|
||||
|
||||
|
||||
|
||||
CBGServerMgr::CBGServerMgr()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CBGServerMgr::~CBGServerMgr()
|
||||
{
|
||||
DestroyBGServerMap();
|
||||
}
|
||||
|
||||
|
||||
CBGServerMgr& CBGServerMgr::GetInstance()
|
||||
{
|
||||
static CBGServerMgr ms_this;
|
||||
return ms_this;
|
||||
}
|
||||
|
||||
bool CBGServerMgr::CreateBGServerMap()
|
||||
{
|
||||
if (m_lstBGServerMap.size() != 0)
|
||||
{
|
||||
DestroyBGServerMap();
|
||||
}
|
||||
|
||||
// Game Room <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
|
||||
m_lstBGServerMap.push_back( new CBGServerMap( CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType("BG_FRAG"), 1 ) );
|
||||
m_lstBGServerMap.push_back( new CBGServerMap( CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType("BG_FRAG"), 2 ) );
|
||||
m_lstBGServerMap.push_back( new CBGServerMap( CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType("BG_FRAG"), 3 ) );
|
||||
m_lstBGServerMap.push_back( new CBGServerMap( CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType("BG_FRAG"), 4 ) );
|
||||
m_lstBGServerMap.push_back( new CBGServerMap( CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType("BG_FRAG"), 5 ) );
|
||||
m_lstBGServerMap.push_back( new CBGServerMap( CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType("BG_FRAG"), 6 ) );
|
||||
m_lstBGServerMap.push_back( new CBGServerMap( CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType("BG_FRAG"), 7 ) );
|
||||
m_lstBGServerMap.push_back( new CBGServerMap( CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType("BG_STATUE"), 8 ) );
|
||||
|
||||
LoginAllMonster();
|
||||
GameAllStart();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMgr::DestroyBGServerMap()
|
||||
{
|
||||
BGServerMapList::iterator pos = m_lstBGServerMap.begin();
|
||||
BGServerMapList::iterator end = m_lstBGServerMap.end();
|
||||
|
||||
for(; pos != end; ++pos)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
delete (*pos);
|
||||
(*pos) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
m_lstBGServerMap.clear();
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMgr::Enter(CCharacter* lpCharacter, unsigned short wMapIndex, unsigned char cMoveType)
|
||||
{
|
||||
if (NULL == lpCharacter) { return false; }
|
||||
|
||||
unsigned short wIndex = (wMapIndex & ~VirtualArea::BGSERVERMAP);
|
||||
if (0 == wIndex || wIndex > m_lstBGServerMap.size()) { return false; }
|
||||
|
||||
CBGServerMap* lpBGServerMap = m_lstBGServerMap[wIndex - 1];
|
||||
if (NULL == lpBGServerMap) { return false; }
|
||||
|
||||
unsigned short wError = lpBGServerMap->Enter(lpCharacter, cMoveType);
|
||||
if (PktBase::NO_SERVER_ERR == wError)
|
||||
{
|
||||
CGameClientDispatch* lpDispatch = lpCharacter->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
if (false == GameClientSendPacket::SendCharBGServerMoveZone(lpDispatch->GetSendStream(), lpBGServerMap->GetVirtualZone(), cMoveType, wError))
|
||||
{
|
||||
lpBGServerMap->Leave(lpCharacter);
|
||||
ERRLOG3(g_Log, "CID:0x%08x ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5>ϴµ<CFB4> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.",
|
||||
lpCharacter->GetCID(), lpCharacter->GetMapIndex(), wMapIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20><> <20>̵<EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD> MapIndex <20><> <20><>ǥ<EFBFBD><C7A5> <20>ٲ<EFBFBD> <20><><EFBFBD>̴<EFBFBD>.)
|
||||
lpCharacter->SetMapIndex(wMapIndex);
|
||||
lpCharacter->MoveTo(lpBGServerMap->GetStartPosition(lpCharacter->GetRace()), false);
|
||||
|
||||
// HIDE <20><><EFBFBD><EFBFBD> ó<><C3B3>
|
||||
if (VirtualArea::TYPE_SPECTATOR == cMoveType)
|
||||
{
|
||||
lpCharacter->GetEnchantInfo().SetFlag(Skill::SpellID::Hide);
|
||||
}
|
||||
|
||||
// <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
||||
// (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><C3B0>쿡<EFBFBD><ECBFA1> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ۿ<EFBFBD><DBBF>Ը<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ҽ<EFBFBD> <20>ִ<EFBFBD>.)
|
||||
lpBGServerMap->SendMapInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
lpBGServerMap->Leave(lpCharacter);
|
||||
ERRLOG3(g_Log, "CID:0x%08x ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5>ϴµ<CFB4> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.",
|
||||
lpCharacter->GetCID(), lpCharacter->GetMapIndex(), wMapIndex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PktBase::SERVER_ERROR == wError)
|
||||
{
|
||||
ERRLOG3(g_Log, "CID:0x%08x ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5>ϴµ<CFB4> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.",
|
||||
lpCharacter->GetCID(), lpCharacter->GetMapIndex(), wMapIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
CGameClientDispatch* lpDispatch = lpCharacter->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
return GameClientSendPacket::SendCharBGServerMoveZone(lpDispatch->GetSendStream(),
|
||||
lpBGServerMap->GetVirtualZone(), cMoveType, wError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMgr::Leave(CCharacter* lpCharacter)
|
||||
{
|
||||
if (NULL == lpCharacter) return false;
|
||||
|
||||
unsigned short wIndex = (lpCharacter->GetMapIndex() & ~VirtualArea::BGSERVERMAP);
|
||||
if (0 == wIndex || wIndex > m_lstBGServerMap.size()) return false;
|
||||
|
||||
CBGServerMap* lpBGServerMap = m_lstBGServerMap[wIndex - 1];
|
||||
if (NULL == lpBGServerMap) return false;
|
||||
|
||||
lpCharacter->SetMapIndex(0);
|
||||
Position RespawnPos(VirtualArea::RespawnPos[ lpCharacter->GetRace() ][ Math::Random::ComplexRandom(VirtualArea::MAX_LOBBY_RESPAWN_POS) ]);
|
||||
RespawnPos.m_fPointX += Math::Random::SimpleRandom(GetTickCount(), 20) - 10;
|
||||
RespawnPos.m_fPointZ += Math::Random::SimpleRandom(GetTickCount(), 20) - 10;
|
||||
lpCharacter->MoveTo(RespawnPos, false);
|
||||
lpCharacter->GetEnchantInfo().ResetFlag(Skill::SpellID::Hide);
|
||||
lpBGServerMap->Leave(lpCharacter);
|
||||
|
||||
CGameClientDispatch* lpDispatch = lpCharacter->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
if (false == GameClientSendPacket::SendCharBGServerMoveZone(lpDispatch->GetSendStream(), SERVER_ID::BATTLE_SERVER, VirtualArea::TYPE_PLAYER, PktBase::NO_SERVER_ERR))
|
||||
{
|
||||
ERRLOG2(g_Log, "CID:0x%08x ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>(MapIndex : %d)<29><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.", lpCharacter->GetCID(), lpCharacter->GetMapIndex());
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20>÷<EFBFBD><C3B7>̾ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
||||
if (lpBGServerMap->IsPlayer(lpCharacter))
|
||||
{
|
||||
lpBGServerMap->SendMapInfo();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMgr::Process()
|
||||
{
|
||||
BGServerMapList::iterator pos = m_lstBGServerMap.begin();
|
||||
BGServerMapList::iterator end = m_lstBGServerMap.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
(*pos)->Process();
|
||||
++pos;
|
||||
}
|
||||
|
||||
static unsigned long s_dwLastTime = 0;
|
||||
unsigned long dwCurrentTime = timeGetTime();
|
||||
if (dwCurrentTime - s_dwLastTime > VirtualArea::MILLISEC_PER_MINUTE)
|
||||
{
|
||||
s_dwLastTime = dwCurrentTime;
|
||||
SendMapListToAllCharacter();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CVirtualArea* CBGServerMgr::GetVirtualArea(unsigned short wMapIndex)
|
||||
{
|
||||
unsigned short wIndex = (wMapIndex & ~VirtualArea::BGSERVERMAP);
|
||||
|
||||
if (0 == wIndex || wIndex > m_lstBGServerMap.size())
|
||||
return NULL;
|
||||
|
||||
return reinterpret_cast<CVirtualArea*>(m_lstBGServerMap[wIndex - 1]);
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMgr::SendMapList(CCharacter* lpCharacter)
|
||||
{
|
||||
PERFORMANCE_CHECK(FunctionTimingCheck);
|
||||
|
||||
if (NULL == lpCharacter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const int MAX_BUFFER = sizeof(PktBGServerMapList) + PktBGServerMapList::MAX_MAP_NUM * sizeof(BGServerMapInfoNode);
|
||||
char szBuffer[MAX_BUFFER];
|
||||
|
||||
PktBGServerMapList* lpPktBGSMLAck = reinterpret_cast<PktBGServerMapList *>(szBuffer);
|
||||
BGServerMapInfoNode* lpMapInfoNode = reinterpret_cast<BGServerMapInfoNode *>(lpPktBGSMLAck + 1);
|
||||
|
||||
lpPktBGSMLAck->m_bAll = true;
|
||||
lpPktBGSMLAck->m_cMapInfoNodeNum = 0;
|
||||
|
||||
for (unsigned char cIndex = 0; cIndex < PktBGServerMapList::MAX_MAP_NUM && cIndex < m_lstBGServerMap.size();
|
||||
++cIndex, ++lpMapInfoNode, ++lpPktBGSMLAck->m_cMapInfoNodeNum)
|
||||
{
|
||||
CBGServerMap* lpBGServerMap = m_lstBGServerMap[cIndex];
|
||||
if (NULL != lpBGServerMap)
|
||||
{
|
||||
lpMapInfoNode->m_bPlaying = lpBGServerMap->IsPlaying();
|
||||
lpMapInfoNode->m_cMapType = lpBGServerMap->GetMapInfo().m_cMapType;
|
||||
lpMapInfoNode->m_cMaxCharNumOfNation = lpBGServerMap->GetMapInfo().m_cMaxCharNumOfNation;
|
||||
lpMapInfoNode->m_wTargetScore = lpBGServerMap->GetMapInfo().m_wTargetScore;
|
||||
lpMapInfoNode->m_cRemainMin = (lpBGServerMap->IsPlaying() == true) ? lpBGServerMap->GetMapInfo().m_cRemainPlayMin : lpBGServerMap->GetMapInfo().m_cRemainRestMin;
|
||||
|
||||
lpMapInfoNode->m_cCurrentCharNum[CClass::HUMAN] = lpBGServerMap->GetMapInfo().m_cCurrentCharNum[CClass::HUMAN];
|
||||
lpMapInfoNode->m_cCurrentCharNum[CClass::AKHAN] = lpBGServerMap->GetMapInfo().m_cCurrentCharNum[CClass::AKHAN];
|
||||
lpMapInfoNode->m_wScore[CClass::HUMAN] = lpBGServerMap->GetMapInfo().m_wScore[CClass::HUMAN];
|
||||
lpMapInfoNode->m_wScore[CClass::AKHAN] = lpBGServerMap->GetMapInfo().m_wScore[CClass::AKHAN];
|
||||
}
|
||||
}
|
||||
|
||||
CGameClientDispatch* lpDispatch = lpCharacter->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
return lpDispatch->GetSendStream().WrapCompress(szBuffer, sizeof(PktBGServerMapList) +
|
||||
lpPktBGSMLAck->m_cMapInfoNodeNum * sizeof(BGServerMapInfoNode), CmdBGServerMapList, 0, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMgr::SendResultList(CCharacter* lpCharacter)
|
||||
{
|
||||
PERFORMANCE_CHECK(FunctionTimingCheck);
|
||||
|
||||
if (NULL == lpCharacter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const int MAX_BUFFER = sizeof(PktBGServerResultList) + PktBGServerResultList::MAX_MAP_NUM * sizeof(BGServerResultInfoNode);
|
||||
char szBuffer[MAX_BUFFER];
|
||||
|
||||
PktBGServerResultList* lpPktBGSRLAck = reinterpret_cast<PktBGServerResultList *>(szBuffer);
|
||||
BGServerResultInfoNode* lpResultInfoNode = reinterpret_cast<BGServerResultInfoNode *>(lpPktBGSRLAck + 1);
|
||||
|
||||
lpPktBGSRLAck->m_bAll = true;
|
||||
lpPktBGSRLAck->m_cResultInfoNodeNum = 0;
|
||||
|
||||
for (unsigned char cIndex = 0; cIndex < PktBGServerResultList::MAX_MAP_NUM && cIndex < m_lstBGServerMap.size();
|
||||
++cIndex, ++lpResultInfoNode, ++lpPktBGSRLAck->m_cResultInfoNodeNum)
|
||||
{
|
||||
CBGServerMap* lpBGServerMap = m_lstBGServerMap[cIndex];
|
||||
if (NULL != lpBGServerMap)
|
||||
{
|
||||
lpResultInfoNode->m_cWinRace = lpBGServerMap->GetResultInfo().m_cWinRace;
|
||||
lpResultInfoNode->m_cPlayMin = 0;
|
||||
lpResultInfoNode->m_wAward = 0;
|
||||
lpResultInfoNode->m_wScore[CClass::HUMAN] = lpBGServerMap->GetResultInfo().m_wScore[CClass::HUMAN];
|
||||
lpResultInfoNode->m_wScore[CClass::AKHAN] = lpBGServerMap->GetResultInfo().m_wScore[CClass::AKHAN];
|
||||
}
|
||||
}
|
||||
|
||||
CGameClientDispatch* lpDispatch = lpCharacter->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
return lpDispatch->GetSendStream().WrapCompress(szBuffer, sizeof(PktBGServerResultList) +
|
||||
lpPktBGSRLAck->m_cResultInfoNodeNum * sizeof(BGServerResultInfoNode), CmdBGServerResultList, 0, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBGServerMgr::SendMapListToAllCharacter()
|
||||
{
|
||||
PERFORMANCE_CHECK(FunctionTimingCheck);
|
||||
|
||||
if (0 == CCreatureManager::GetInstance().GetCharacterNum()) return true;
|
||||
|
||||
const int MAX_BUFFER = sizeof(PktBGServerMapList) + PktBGServerMapList::MAX_MAP_NUM * sizeof(BGServerMapInfoNode);
|
||||
char szSrcBuffer[MAX_BUFFER], szDstBuffer[MAX_BUFFER];
|
||||
|
||||
PktBGServerMapList* lpPktBGSMLAck = reinterpret_cast<PktBGServerMapList *>(szSrcBuffer);
|
||||
BGServerMapInfoNode* lpMapInfoNode = reinterpret_cast<BGServerMapInfoNode *>(lpPktBGSMLAck + 1);
|
||||
|
||||
lpPktBGSMLAck->m_bAll = true;
|
||||
lpPktBGSMLAck->m_cMapInfoNodeNum = 0;
|
||||
|
||||
for (unsigned char cIndex = 0; cIndex < PktBGServerMapList::MAX_MAP_NUM && cIndex < m_lstBGServerMap.size();
|
||||
++cIndex, ++lpMapInfoNode, ++lpPktBGSMLAck->m_cMapInfoNodeNum)
|
||||
{
|
||||
CBGServerMap* lpBGServerMap = m_lstBGServerMap[cIndex];
|
||||
if (NULL != lpBGServerMap)
|
||||
{
|
||||
lpMapInfoNode->m_bPlaying = lpBGServerMap->IsPlaying();
|
||||
lpMapInfoNode->m_cMapType = lpBGServerMap->GetMapInfo().m_cMapType;
|
||||
lpMapInfoNode->m_cMaxCharNumOfNation = lpBGServerMap->GetMapInfo().m_cMaxCharNumOfNation;
|
||||
lpMapInfoNode->m_wTargetScore = lpBGServerMap->GetMapInfo().m_wTargetScore;
|
||||
lpMapInfoNode->m_cRemainMin = (lpBGServerMap->IsPlaying() == true) ? lpBGServerMap->GetMapInfo().m_cRemainPlayMin : lpBGServerMap->GetMapInfo().m_cRemainRestMin;
|
||||
|
||||
lpMapInfoNode->m_cCurrentCharNum[CClass::HUMAN] = lpBGServerMap->GetMapInfo().m_cCurrentCharNum[CClass::HUMAN];
|
||||
lpMapInfoNode->m_cCurrentCharNum[CClass::AKHAN] = lpBGServerMap->GetMapInfo().m_cCurrentCharNum[CClass::AKHAN];
|
||||
lpMapInfoNode->m_wScore[CClass::HUMAN] = lpBGServerMap->GetMapInfo().m_wScore[CClass::HUMAN];
|
||||
lpMapInfoNode->m_wScore[CClass::AKHAN] = lpBGServerMap->GetMapInfo().m_wScore[CClass::AKHAN];
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long dwDstLength = MAX_BUFFER;
|
||||
unsigned short wSrcLength = sizeof(PktBGServerMapList) + lpPktBGSMLAck->m_cMapInfoNodeNum * sizeof(BGServerMapInfoNode);
|
||||
|
||||
if (PacketWrap::WrapCompress(szDstBuffer, dwDstLength,
|
||||
szSrcBuffer, wSrcLength, CmdBGServerMapList, 0, 0))
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>鿡<EFBFBD>Ը<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
||||
CCreatureManager::GetInstance().SendAllCharacter(
|
||||
szDstBuffer, dwDstLength, CmdBGServerMapList, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CBGServerMgr::LoginAllMonster()
|
||||
{
|
||||
for (size_t nIndex=0; nIndex<m_lstBGServerMap.size(); ++nIndex)
|
||||
{
|
||||
if (m_lstBGServerMap[nIndex])
|
||||
{
|
||||
const VirtualArea::ProtoType* lpProtoType = VirtualArea::CVirtualAreaMgr::GetInstance().GetVirtualAreaProtoType( m_lstBGServerMap[nIndex]->GetVID() );
|
||||
if (lpProtoType && '\0' != lpProtoType->m_szArrangementFileName[0])
|
||||
{
|
||||
m_lstBGServerMap[nIndex]->CreateVirtualMonsterManager();
|
||||
unsigned short wMapIndex = static_cast<unsigned short>(VirtualArea::BGSERVERMAP | (nIndex + 1));
|
||||
CCellManager::GetInstance().LoginMonster(lpProtoType->m_szArrangementFileName, wMapIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBGServerMgr::GameAllStart()
|
||||
{
|
||||
std::for_each(m_lstBGServerMap.begin(), m_lstBGServerMap.end(), std::mem_fun<bool, CBGServerMap>(&CBGServerMap::GameStart));
|
||||
}
|
||||
|
||||
|
||||
void CBGServerMgr::ProcessAllMonster()
|
||||
{
|
||||
BGServerMapList::iterator pos = m_lstBGServerMap.begin();
|
||||
BGServerMapList::iterator end = m_lstBGServerMap.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
(*pos)->ProcessAllMonster();
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
void CBGServerMgr::ProcessMonsterRegenHPAndMP()
|
||||
{
|
||||
BGServerMapList::iterator pos = m_lstBGServerMap.begin();
|
||||
BGServerMapList::iterator end = m_lstBGServerMap.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
(*pos)->ProcessMonsterRegenHPAndMP();
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
void CBGServerMgr::ProcessSummonMonsterDead()
|
||||
{
|
||||
BGServerMapList::iterator pos = m_lstBGServerMap.begin();
|
||||
BGServerMapList::iterator end = m_lstBGServerMap.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
(*pos)->ProcessSummonMonsterDead();
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
void CBGServerMgr::ProcessDeleteItem()
|
||||
{
|
||||
BGServerMapList::iterator pos = m_lstBGServerMap.begin();
|
||||
BGServerMapList::iterator end = m_lstBGServerMap.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
(*pos)->ProcessDeleteItem();
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
bool CBGServerMgr::ProcessAllCellPrepareBroadCast()
|
||||
{
|
||||
BGServerMapList::iterator pos = m_lstBGServerMap.begin();
|
||||
BGServerMapList::iterator end = m_lstBGServerMap.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
(*pos)->ProcessAllCellPrepareBroadCast();
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBGServerMgr::ProcessAllCellBroadCast(unsigned long dwCurrentPulse)
|
||||
{
|
||||
BGServerMapList::iterator pos = m_lstBGServerMap.begin();
|
||||
BGServerMapList::iterator end = m_lstBGServerMap.end();
|
||||
|
||||
while (pos != end)
|
||||
{
|
||||
if (NULL != (*pos))
|
||||
{
|
||||
(*pos)->ProcessAllCellBroadCast(dwCurrentPulse);
|
||||
}
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef _BATTLEGROUND_SERVER_MANAGER_H_
|
||||
#define _BATTLEGROUND_SERVER_MANAGER_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
class CCharacter;
|
||||
|
||||
|
||||
namespace VirtualArea
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
class CVirtualArea;
|
||||
class CBGServerMap;
|
||||
|
||||
|
||||
class CBGServerMgr
|
||||
{
|
||||
public:
|
||||
|
||||
static CBGServerMgr& GetInstance();
|
||||
|
||||
bool CreateBGServerMap();
|
||||
|
||||
void Process();
|
||||
bool Enter(CCharacter* lpCharacter, unsigned short wMapIndex, unsigned char cMoveType);
|
||||
bool Leave(CCharacter* lpCharacter);
|
||||
|
||||
CVirtualArea* GetVirtualArea(unsigned short wMapIndex);
|
||||
|
||||
bool SendMapList(CCharacter* lpCharacter);
|
||||
bool SendResultList(CCharacter* lpCharacter);
|
||||
bool SendMapListToAllCharacter();
|
||||
|
||||
typedef std::vector<CBGServerMap* > BGServerMapList;
|
||||
|
||||
void ProcessAllMonster();
|
||||
void ProcessMonsterRegenHPAndMP();
|
||||
void ProcessSummonMonsterDead();
|
||||
void ProcessDeleteItem();
|
||||
|
||||
// Cell BroadCasting
|
||||
bool ProcessAllCellPrepareBroadCast();
|
||||
bool ProcessAllCellBroadCast(unsigned long dwCurrentPulse);
|
||||
|
||||
private:
|
||||
CBGServerMgr();
|
||||
~CBGServerMgr();
|
||||
|
||||
void DestroyBGServerMap();
|
||||
bool LoginAllMonster();
|
||||
void GameAllStart();
|
||||
|
||||
|
||||
BGServerMapList m_lstBGServerMap;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BATTLEGROUND_SERVER_MANAGER_H_
|
||||
Reference in New Issue
Block a user