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,853 @@
|
||||
#include "stdafx.h"
|
||||
#include "CampDB.h"
|
||||
#include "SiegeObjectDBMgr.h"
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Community/Guild/GuildDB.h>
|
||||
#include <Community/Guild/GuildDBMgr.h>
|
||||
|
||||
#include <Castle/Castle.h>
|
||||
#include <Castle/CastleMgr.h>
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include <atltime.h>
|
||||
|
||||
|
||||
CCampDB::CCampDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo)
|
||||
: CSiegeObjectDB(DBComponent, CampInfo), m_wChangeType(0),
|
||||
m_dwOldTotalMinutes(Siege::CAMP_ENCAMPING_TIME)
|
||||
{
|
||||
::memcpy(&m_CampRight, CampInfo.m_szRight, sizeof(CampRight));
|
||||
}
|
||||
|
||||
CCampDB::CCampDB(CDBComponent& DBComponent, unsigned long dwCampID, unsigned long dwGID,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos)
|
||||
: CSiegeObjectDB(DBComponent, dwCampID, dwGID, cZone, cChannel, Pos),
|
||||
m_wChangeType(0), m_dwOldTotalMinutes(Siege::CAMP_ENCAMPING_TIME)
|
||||
{
|
||||
}
|
||||
|
||||
CCampDB::~CCampDB()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool CCampDB::CancelBuild()
|
||||
{
|
||||
if (m_cState == Siege::DEVELOPING)
|
||||
{
|
||||
m_cState = Siege::CANCELING;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCampDB::Cancel()
|
||||
{
|
||||
m_cState = Siege::DESTROYED;
|
||||
m_dwHP = 0;
|
||||
m_cUpgradeStep = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCampDB::Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold, unsigned char cUpgradeType)
|
||||
{
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
if (Siege::MAX_UPGRADE_NUM == m_cUpgradeStep) return false;
|
||||
|
||||
m_cState = Siege::UPGRADING;
|
||||
m_cUpgradeTime = cUpgradeTime;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCampDB::Repair(unsigned long dwRepairHP, unsigned long dwRepairGold)
|
||||
{
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
m_cState = Siege::REPARING;
|
||||
m_dwRepairHP = dwRepairHP;
|
||||
m_cRepairTime = Siege::CAMP_REPAIR_TIME;
|
||||
|
||||
// 수리 비용 길드 창고에서 빼기
|
||||
if (dwRepairGold > 0)
|
||||
{
|
||||
Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
|
||||
if (lpGuild)
|
||||
{
|
||||
lpGuild->DeductGold(dwRepairGold);
|
||||
}
|
||||
}
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCampDB::Destroy(unsigned long dwEnemyNation, bool bDeductFame)
|
||||
{
|
||||
m_cState = Siege::DESTROYED;
|
||||
m_dwHP = 0;
|
||||
m_cUpgradeStep = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCampDB::ChangeType(unsigned short wType)
|
||||
{
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
m_cState = Siege::CHANGING;
|
||||
m_cChangeTime = Siege::CAMP_CHANGING_TIME;
|
||||
m_wChangeType = wType;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCampDB::UpdateLastUseTime(bool bInit)
|
||||
{
|
||||
CSiegeObjectDB::UpdateLastUseTime(bInit);
|
||||
|
||||
if (!bInit)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_LAST_USE_TIME, sysTime);
|
||||
}
|
||||
}
|
||||
|
||||
void CCampDB::UpdateHP(unsigned long dwNowHP)
|
||||
{
|
||||
CSiegeObjectDB::UpdateHP(dwNowHP);
|
||||
|
||||
DBComponent::CastleDB::UpdateCampHP(m_DBComponent, GetCampID(), m_dwHP);
|
||||
}
|
||||
|
||||
bool CCampDB::ToStartKit()
|
||||
{
|
||||
m_cState = Siege::DESTROYING;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCampDB::SetRight(CampRight campRight)
|
||||
{
|
||||
m_CampRight = campRight;
|
||||
DBComponent::CastleDB::UpdateCampRight(m_DBComponent, GetCampID(), reinterpret_cast<char*>(&m_CampRight), sizeof(CampRight));
|
||||
}
|
||||
|
||||
void CCampDB::SetMaterialNum(unsigned char cMaterial)
|
||||
{
|
||||
CSiegeObjectDB::SetMaterialNum(cMaterial);
|
||||
DBComponent::CastleDB::UpdateCampMaterial(m_DBComponent, GetCampID(), m_cMaterial);
|
||||
}
|
||||
|
||||
void CCampDB::UpdateRewardFame(int Fame)
|
||||
{
|
||||
// 명성 보상.
|
||||
Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
|
||||
if (lpGuild)
|
||||
{
|
||||
lpGuild->AddLoginedMemberFame( Guild::TYPE_VALUE, Fame );
|
||||
}
|
||||
}
|
||||
|
||||
Siege::eReturn CCampDB::Process()
|
||||
{
|
||||
CTime nowTime = CTime::GetCurrentTime();
|
||||
CTimeSpan timeSpan(0);
|
||||
|
||||
/* // 오랬동안 사용하지 않은 길드 요새 폭파 기능 주석 처리
|
||||
if (0 != m_LastUseTime.Year && Siege::DEVELOPING != m_cState)
|
||||
{
|
||||
CTime lastUseTime(m_LastUseTime.Year, m_LastUseTime.Month, m_LastUseTime.Day,
|
||||
m_LastUseTime.Hour, m_LastUseTime.Minute, m_LastUseTime.Second);
|
||||
|
||||
timeSpan = nowTime - lastUseTime;
|
||||
if (timeSpan.GetDays() > Siege::CAMP_LEAST_USE_TIME)
|
||||
{
|
||||
DestroyCamp();
|
||||
SendCampCmd(PktCampCmd::CAMP_DESTROY);
|
||||
|
||||
// 명성 처리
|
||||
Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
|
||||
if (lpGuild)
|
||||
{
|
||||
lpGuild->AddAllMemberFame( Siege::FAME_FOR_DESTROYED_CAMP );
|
||||
}
|
||||
|
||||
// 길드 요새 객체 삭제
|
||||
return Siege::RET_DESTROY_CAMP;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
switch (m_cState)
|
||||
{
|
||||
case Siege::COMPLETE: // 구축 완료 상태
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::DEVELOPING: // 구축중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime developTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - developTime;
|
||||
if (timeSpan.GetTotalMinutes() >= Siege::CAMP_ENCAMPING_TIME)
|
||||
{
|
||||
Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
Guild::CGuildDBMgr::GetInstance().GetGuild( m_dwGID ));
|
||||
|
||||
// 길드 요새 구축 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
UpdateLastUseTime();
|
||||
|
||||
// DB에 상태 업데이트
|
||||
SYSTEMTIME sysTime;
|
||||
::memset(&sysTime, 0, sizeof(SYSTEMTIME));
|
||||
::memset(&m_TimeValue, 0, sizeof(TIME));
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
if (IsWorldWeapon())
|
||||
{
|
||||
// 월드 웨폰 구축 완료
|
||||
// 메세지 종류, 존 번호, 국가 번호, 공지
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_WEAPON_ENCAMP_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = true;
|
||||
|
||||
if (NULL != lpGuild)
|
||||
{
|
||||
pktCampMessage.m_cNation = lpGuild->GetNation();
|
||||
}
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 길드 요새 구축 완료
|
||||
// 메세지 종류, 존 번호, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_ENCAMP_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
// 길드 요새 구축 완료
|
||||
// 메세지 종류, 존 번호, 길드 이름, 공지
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_ENCAMP_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = true;
|
||||
|
||||
if (NULL != lpGuild)
|
||||
{
|
||||
strcpy(pktCampMessage.m_szGuildName, lpGuild->GetName());
|
||||
}
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCampCmd(PktCampCmd::CAMP_BUILD_COMPLETE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 구축중 일때 10분 단위로 메세지를 보내준다.
|
||||
if (0 < timeSpan.GetTotalMinutes() && m_dwOldTotalMinutes != timeSpan.GetTotalMinutes() &&
|
||||
0 == (timeSpan.GetTotalMinutes() % Siege::CAMP_ENCAMPING_INTERVAL))
|
||||
{
|
||||
m_dwOldTotalMinutes = static_cast<unsigned long>( timeSpan.GetTotalMinutes() );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
if (IsWorldWeapon())
|
||||
{
|
||||
// 월드 웨폰 구축 중
|
||||
// 메세지 종류, 존 번호, 구축 완료까지 남은 시간, 공지
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_WEAPON_ENCAMPING;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_cRemainTime = static_cast<unsigned char>(Siege::CAMP_ENCAMPING_TIME - timeSpan.GetTotalMinutes());
|
||||
pktCampMessage.m_bNotify = true;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 길드 요새 구축 중
|
||||
// 메세지 종류, 존 번호, 구축 완료까지 남은 시간, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_ENCAMPING;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_cRemainTime = static_cast<unsigned char>(Siege::CAMP_ENCAMPING_TIME - timeSpan.GetTotalMinutes());
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::CANCELING: // 구축 해제중 (스타트킷으로 돌리기)
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime cancelTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - cancelTime;
|
||||
if (timeSpan.GetTotalMinutes() >= Siege::CAMP_CANCELING_TIME)
|
||||
{
|
||||
// 길드 요새 구축 해제 완료
|
||||
Cancel();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
if (IsWorldWeapon())
|
||||
{
|
||||
// 월드 웨폰 구축 취소 완료
|
||||
// 메세지 종류, 존 번호, 공지
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_WEAPON_CANCEL_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = true;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 길드 요새 구축 취소 완료
|
||||
// 메세지 종류, 존 번호, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_CANCEL_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCampCmd(PktCampCmd::CAMP_CANCEL_COMPLETE);
|
||||
|
||||
// 돈으로 돌려주는 처리
|
||||
Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
|
||||
if (lpGuild)
|
||||
{
|
||||
lpGuild->AddGoldToMaster( Siege::GOLD_FOR_CANCEL_CAMP );
|
||||
}
|
||||
|
||||
// 길드 요새 객체 삭제
|
||||
return Siege::RET_DESTROY_CAMP;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::UPGRADING: // 업그레이드중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime upgradeTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - upgradeTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cUpgradeTime)
|
||||
{
|
||||
// 길드 요새 업그레이드 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
++m_cUpgradeStep;
|
||||
|
||||
// DB에 상태 업데이트
|
||||
SYSTEMTIME sysTime;
|
||||
::memset(&sysTime, 0, sizeof(SYSTEMTIME));
|
||||
::memset(&m_TimeValue, 0, sizeof(TIME));
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampUpgrade(m_DBComponent, GetCampID(), m_cUpgradeStep);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
if (IsWorldWeapon())
|
||||
{
|
||||
// 월드 웨폰 업그레이드 완료
|
||||
// 메세지 종류, 존 번호, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_WEAPON_UPGRADE_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 길드 요새 업그레이드 완료
|
||||
// 메세지 종류, 존 번호, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_UPGRADE_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCampCmd(PktCampCmd::CAMP_UPGRADE_COMPLETE, m_cUpgradeStep);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::REPARING: // 수리중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime repairTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - repairTime;
|
||||
if (timeSpan.GetTotalSeconds() >= m_cRepairTime)
|
||||
{
|
||||
// 길드 요새 수리 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
|
||||
// DB에 상태 업데이트
|
||||
SYSTEMTIME sysTime;
|
||||
::memset(&sysTime, 0, sizeof(SYSTEMTIME));
|
||||
::memset(&m_TimeValue, 0, sizeof(TIME));
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
if (IsWorldWeapon())
|
||||
{
|
||||
// 월드 웨폰 수리 완료
|
||||
// 메세지 종류, 존 번호, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_WEAPON_REPAIR_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 길드 요새 수리 완료
|
||||
// 메세지 종류, 존 번호, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_REPAIR_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCampCmd(PktCampCmd::CAMP_REPAIR_COMPLETE, m_dwRepairHP);
|
||||
m_dwRepairHP = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::DESTROYING: // 스타트킷으로 돌리기 중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime destroyTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - destroyTime;
|
||||
if (timeSpan.GetTotalMinutes() >= Siege::CAMP_TO_STARTKIT_TIME)
|
||||
{
|
||||
// 길드 요새 파괴 완료
|
||||
Destroy();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
|
||||
short sFameForSelfDestroyCamp = Siege::FAME_FOR_SELF_DESTROY_CAMP;
|
||||
|
||||
if (IsWorldWeapon())
|
||||
{
|
||||
// 월드 웨폰 스스로 파괴 완료 공지
|
||||
// 메세지 종류, 존 번호, 길드 이름, 국가, 공지
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_WEAPON_SELF_DESTROY_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = true;
|
||||
|
||||
if (NULL != lpGuild)
|
||||
{
|
||||
strcpy(pktCampMessage.m_szGuildName, lpGuild->GetName()); // 길드 이름
|
||||
pktCampMessage.m_cNation = lpGuild->GetNation();
|
||||
}
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 길드 요새 스스로 파괴 완료
|
||||
// 메세지 종류, 존 번호, 명성, 돌려주는 골드, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_SELF_DESTROY_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_nValue1 = -(sFameForSelfDestroyCamp);
|
||||
pktCampMessage.m_nValue2 = Siege::GOLD_FOR_SELF_DESTROY_CAMP;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
// 길드 요새 스스로 파괴 완료 공지
|
||||
// 메세지 종류, 존 번호, 길드 이름, 공지
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_SELF_DESTROY_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = true;
|
||||
|
||||
if (NULL != lpGuild)
|
||||
{
|
||||
strcpy(pktCampMessage.m_szGuildName, lpGuild->GetName()); // 길드 이름
|
||||
}
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCampCmd(PktCampCmd::CAMP_TO_STARTKIT_COMPLETE);
|
||||
|
||||
// 명성 처리, 돈으로 돌려주는 처리
|
||||
if (lpGuild)
|
||||
{
|
||||
lpGuild->AddAllMemberFame( Guild::TYPE_VALUE, sFameForSelfDestroyCamp );
|
||||
lpGuild->AddGoldToMaster( Siege::GOLD_FOR_SELF_DESTROY_CAMP );
|
||||
}
|
||||
|
||||
// 길드 요새 객체 삭제
|
||||
return Siege::RET_DESTROY_CAMP;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Siege::CHANGING: // 길드요새 타입 변형중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime changeTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - changeTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cChangeTime)
|
||||
{
|
||||
// 길드 요새 타입 변형 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
|
||||
// 채굴기였다면, 현재 광물 및 임시 광물을 모두 날린다.
|
||||
if (Siege::MINING_CAMP == m_wObjectType)
|
||||
{
|
||||
DBComponent::CastleDB::DeleteMiningCampMineralInfo(m_DBComponent, GetCampID(), Siege::ACCUMULATED_MINERAL);
|
||||
DBComponent::CastleDB::DeleteMiningCampMineralInfo(m_DBComponent, GetCampID(), Siege::TEMPORARY_MINERAL);
|
||||
}
|
||||
|
||||
// 상점에서 다른 타입이 되는 경우 DB 삭제
|
||||
if (Siege::CAMP_SHOP == m_wObjectType)
|
||||
{
|
||||
DBComponent::CastleDB::DeleteCampShopInfo(m_DBComponent, GetCampID());
|
||||
}
|
||||
|
||||
// 상점으로 바뀌는 경우 DB 생성
|
||||
if (Siege::CAMP_SHOP == m_wChangeType)
|
||||
{
|
||||
DBComponent::CastleDB::InsertCampShopInfo(m_DBComponent, GetCampID());
|
||||
}
|
||||
|
||||
// 상태 업데이트
|
||||
SYSTEMTIME sysTime;
|
||||
::memset(&sysTime, 0, sizeof(SYSTEMTIME));
|
||||
::memset(&m_TimeValue, 0, sizeof(TIME));
|
||||
|
||||
DBComponent::CastleDB::UpdateCampState(m_DBComponent, GetCampID(), m_cState);
|
||||
DBComponent::CastleDB::UpdateCampType(m_DBComponent, GetCampID(), m_wChangeType);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
// 길드 요새 타입 변형 완료
|
||||
// 메세지 종류, 존 번호, 변형된 타입, 공지 아님
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_CHANGE_TYPE_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_nValue1 = m_wChangeType;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCampCmd(PktCampCmd::CAMP_CHANGE_COMPLETE, m_wChangeType);
|
||||
|
||||
return Siege::RET_CHANGE_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Siege::RET_OK;
|
||||
}
|
||||
|
||||
|
||||
bool CCampDB::SerializeOut(char* szBuffer_Out, unsigned short& usBufferSize_Out, unsigned long& dwCID_Out)
|
||||
{
|
||||
if (!szBuffer_Out)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
usBufferSize_Out = 0;
|
||||
dwCID_Out = m_dwCID;
|
||||
|
||||
// 요새 정보
|
||||
CampInfoDB* lpCampInfoDB = reinterpret_cast<CampInfoDB*>(szBuffer_Out);
|
||||
|
||||
lpCampInfoDB->m_dwCampID = GetCampID();
|
||||
lpCampInfoDB->m_dwGID = m_dwGID;
|
||||
lpCampInfoDB->m_dwHP = m_dwHP;
|
||||
lpCampInfoDB->m_cZone = m_cZone;
|
||||
lpCampInfoDB->m_cChannel = 0;
|
||||
lpCampInfoDB->m_wObjectType = m_wObjectType;
|
||||
lpCampInfoDB->m_cState = m_cState;
|
||||
lpCampInfoDB->m_cSubState = m_cSubState;
|
||||
lpCampInfoDB->m_cUpgradeStep = m_cUpgradeStep;
|
||||
lpCampInfoDB->m_TimeValue = m_TimeValue;
|
||||
lpCampInfoDB->m_LastUseTime = m_LastUseTime;
|
||||
::memcpy(lpCampInfoDB->m_szRight, m_CampRight.m_aryCampRight, CampRight::MAX_RIGHT_NUM);
|
||||
lpCampInfoDB->m_Pos.fPointX = m_Pos.m_fPointX;
|
||||
lpCampInfoDB->m_Pos.fPointY = m_Pos.m_fPointY;
|
||||
lpCampInfoDB->m_Pos.fPointZ = m_Pos.m_fPointZ;
|
||||
lpCampInfoDB->m_cMaterial = m_cMaterial;
|
||||
lpCampInfoDB->m_cSiegeCount = m_cSiegeCount;
|
||||
|
||||
usBufferSize_Out += sizeof(CampInfoDB);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef _RYL_DBAGENT_CAMP_DB_H_
|
||||
#define _RYL_DBAGENT_CAMP_DB_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SiegeObjectDB.h"
|
||||
|
||||
using namespace Siege;
|
||||
|
||||
class CCampDB : public CSiegeObjectDB
|
||||
{
|
||||
public:
|
||||
virtual ~CCampDB();
|
||||
|
||||
// Process 함수
|
||||
virtual Siege::eReturn Process();
|
||||
|
||||
// Cmd 처리 가상 함수
|
||||
virtual bool CancelBuild(); // 구축 취소
|
||||
virtual bool Cancel(); // 구축 취소 완료
|
||||
virtual bool Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold = 0, unsigned char cUpgradeType = Siege::NO_JEWEL);
|
||||
virtual bool Repair(unsigned long dwRepairHP, unsigned long dwRepairGold = 0);
|
||||
virtual bool Destroy(unsigned long dwEnemyNation = 0, bool bDeductFame = false); // 파괴 완료 (스스로 파괴, 적에게 파괴)
|
||||
virtual bool ChangeType(unsigned short wType);
|
||||
|
||||
void UpdateRewardFame(int Fame);
|
||||
|
||||
void UpdateLastUseTime(bool bInit=false);
|
||||
void UpdateHP(unsigned long dwNowHP);
|
||||
bool ToStartKit();
|
||||
|
||||
unsigned short GetChangeType() const { return m_wChangeType; }
|
||||
|
||||
const CampRight& GetRight() const { return m_CampRight; }
|
||||
void SetRight(CampRight campRight); // 관리 권한 변경
|
||||
|
||||
void SetMaterialNum(unsigned char cMaterial);
|
||||
|
||||
virtual bool SerializeOut(char* szBuffer_Out, unsigned short& usBufferSize_Out, unsigned long& dwCID_Out);
|
||||
|
||||
protected:
|
||||
|
||||
CCampDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo);
|
||||
CCampDB(CDBComponent& DBComponent, unsigned long dwCampID, unsigned long dwGID,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos);
|
||||
|
||||
CampRight m_CampRight; // 길드 요새 관리 권한
|
||||
unsigned short m_wChangeType;
|
||||
|
||||
unsigned long m_dwOldTotalMinutes;
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif _RYL_DBAGENT_CAMP_DB_H_
|
||||
@@ -0,0 +1,110 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Community/Guild/GuildDBMgr.h>
|
||||
#include <Community/Guild/Guild.h>
|
||||
|
||||
#include "CampShopDB.h"
|
||||
|
||||
CCampShopDB::CCampShopDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo)
|
||||
: CCampDB(DBComponent, CampInfo), m_dwItemContainerSize(0), m_cItemNum(0), m_dwTempSafe(0), m_cTax(0)
|
||||
{
|
||||
std::fill_n(m_aryItemContainer, int(CampShopInfoDB::MAX_CONTAINER_SIZE), 0);
|
||||
}
|
||||
|
||||
CCampShopDB::~CCampShopDB()
|
||||
{
|
||||
}
|
||||
|
||||
Siege::eReturn CCampShopDB::Process()
|
||||
{
|
||||
if (m_cSiegeCount >= Siege::CAMP_SHOP_TRANSFER_COUNT)
|
||||
{
|
||||
Guild::CGuild* lpGuild = Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID);
|
||||
if (NULL != lpGuild)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
::memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
// 길드 요새 상점 세금 수익금 획득
|
||||
// 메세지 종류, 존 번호, 공지 아님, 수익금
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_SHOP_GAIN_TAX;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = GetGID();
|
||||
pktCampMessage.m_cZone = GetZone();
|
||||
pktCampMessage.m_bNotify = false;
|
||||
pktCampMessage.m_nValue1 = m_dwTempSafe;
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage),
|
||||
CmdCampMessage, 0, PktBase::NO_SERVER_ERR))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SendCampCmd(PktCampCmd::CAMP_SHOP_GAIN_TAX, m_dwTempSafe);
|
||||
|
||||
DETLOG3(g_Log, "GID:%10u / CurrentGuildGold:%u / TempSafeGold:%u / 길드 요새 상점 : 그동안 모인 수익금을 길드 요새에 입금합니다",
|
||||
lpGuild->GetGID(), lpGuild->GetGold(), m_dwTempSafe);
|
||||
|
||||
lpGuild->AddGold(m_dwTempSafe);
|
||||
m_dwTempSafe = 0;
|
||||
|
||||
SetSiegeCount(0);
|
||||
DBComponent::CastleDB::UpdateCampSiegeCount(m_DBComponent, GetCampID(), GetSiegeCount());
|
||||
}
|
||||
}
|
||||
|
||||
return CCampDB::Process();
|
||||
}
|
||||
|
||||
bool CCampShopDB::UpdateCampInfo(const char* aryItemBuffer, unsigned long dwItemBufferSize, unsigned char cItemNum,
|
||||
unsigned long dwTempSafe, unsigned char cTax)
|
||||
{
|
||||
return DBComponent::CastleDB::UpdateCampShopInfo(m_DBComponent, GetCampID(),
|
||||
aryItemBuffer, dwItemBufferSize, cItemNum, dwTempSafe, cTax);
|
||||
}
|
||||
|
||||
bool CCampShopDB::SerializeOut(char* szBuffer_Out, unsigned short& usBufferSize_Out, unsigned long& dwCID_Out)
|
||||
{
|
||||
if (true == CCampDB::SerializeOut(szBuffer_Out, usBufferSize_Out, dwCID_Out))
|
||||
{
|
||||
char* lpBuffer = szBuffer_Out + usBufferSize_Out;
|
||||
if (NULL == lpBuffer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 길드 요새 상점 정보
|
||||
CampShopInfo* lpCampShopInfo = reinterpret_cast<CampShopInfo*>(lpBuffer);
|
||||
|
||||
lpCampShopInfo->m_dwTempSafe = m_dwTempSafe;
|
||||
lpCampShopInfo->m_cTax = m_cTax;
|
||||
lpCampShopInfo->m_dwBufferSize = m_dwItemContainerSize;
|
||||
lpCampShopInfo->m_cItemNum = m_cItemNum;
|
||||
|
||||
unsigned short wSize = static_cast<unsigned short>(m_dwItemContainerSize + sizeof(unsigned long) * m_cItemNum);
|
||||
|
||||
// 아이템 버퍼
|
||||
char* lpItemBuffer = reinterpret_cast<char*>(lpCampShopInfo + 1);
|
||||
std::copy(m_aryItemContainer, m_aryItemContainer + wSize, lpItemBuffer);
|
||||
|
||||
usBufferSize_Out += sizeof(CampShopInfo) + wSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#ifndef _RYL_DBAGENT_CAMP_SHOP_H_
|
||||
#define _RYL_DBAGENT_CAMP_SHOP_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CampDB.h"
|
||||
|
||||
using namespace Siege;
|
||||
|
||||
class CCampShopDB : public CCampDB
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~CCampShopDB();
|
||||
|
||||
// Process 함수
|
||||
virtual Siege::eReturn Process();
|
||||
|
||||
void SetItemContainer(const char* aryContainer, unsigned long dwContainerSize, unsigned char cItemNum)
|
||||
{
|
||||
std::copy(aryContainer, aryContainer + dwContainerSize + sizeof(unsigned long) * cItemNum, m_aryItemContainer);
|
||||
m_dwItemContainerSize = dwContainerSize;
|
||||
m_cItemNum = cItemNum;
|
||||
}
|
||||
|
||||
void SetTempSafe(unsigned long dwTempSafe) { m_dwTempSafe = dwTempSafe; }
|
||||
void SetTax(unsigned char cTax) { m_cTax = cTax; }
|
||||
|
||||
bool UpdateCampInfo(const char* aryItemBuffer, unsigned long dwItemBufferSize, unsigned char cItemNum,
|
||||
unsigned long dwTempSafe, unsigned char cTax);
|
||||
|
||||
bool SerializeOut(char* szBuffer_Out, unsigned short& usBufferSize_Out, unsigned long& dwCID_Out);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CCampShopDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo);
|
||||
|
||||
unsigned char m_aryItemContainer[CampShopInfoDB::MAX_CONTAINER_SIZE]; // 판매중인 아이템 목록
|
||||
unsigned long m_dwItemContainerSize; // 아이템 목록 사이즈
|
||||
unsigned char m_cItemNum; // 아이템 갯수
|
||||
|
||||
unsigned long m_dwTempSafe; // 임시 금고
|
||||
unsigned char m_cTax; // 세율
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,283 @@
|
||||
#include "stdafx.h"
|
||||
#include "CastleArmsDB.h"
|
||||
#include "SiegeObjectDBMgr.h"
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Community/Guild/GuildDB.h>
|
||||
#include <Community/Guild/GuildDBMgr.h>
|
||||
|
||||
#include <Castle/Castle.h>
|
||||
#include <Castle/CastleMgr.h>
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include <atltime.h>
|
||||
|
||||
|
||||
CCastleArmsDB::CCastleArmsDB(CDBComponent& DBComponent, const CastleObjectInfoDB& CastleObject)
|
||||
: CSiegeObjectDB(DBComponent, CastleObject)
|
||||
{
|
||||
}
|
||||
|
||||
CCastleArmsDB::~CCastleArmsDB()
|
||||
{
|
||||
}
|
||||
|
||||
bool CCastleArmsDB::Build(unsigned short wType, unsigned char cDevelopTime, unsigned long dwDevelopGold, unsigned long dwOwnerID)
|
||||
{
|
||||
if (Siege::CASTLE_ARMS_NPC != m_wObjectType) return false;
|
||||
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
m_wObjectType = wType;
|
||||
m_cState = Siege::DEVELOPING;
|
||||
m_cUpgradeStep = 0;
|
||||
m_cDevelopTime = cDevelopTime;
|
||||
m_dwOwnerID = dwOwnerID;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectType(m_DBComponent, m_dwCID, wType, m_dwOwnerID);
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectTime(m_DBComponent, m_dwCID, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCastleArmsDB::Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold, unsigned char cUpgradeType)
|
||||
{
|
||||
if ( !IsCastleArms() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
m_cState = Siege::UPGRADING;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
m_cUpgradeTime = cUpgradeTime;
|
||||
|
||||
// CASTLE_TODO : 개인 금고에서 돈을 빼야한다.
|
||||
|
||||
// // 업글 비용 길드 창고에서 빼기
|
||||
// Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
// Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
//
|
||||
// if (lpGuild)
|
||||
// {
|
||||
// lpGuild->DeductGold(dwUpgradeGold);
|
||||
// }
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectTime(m_DBComponent, m_dwCID, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCastleArmsDB::Repair(unsigned long dwRepairHP, unsigned long dwRepairGold)
|
||||
{
|
||||
if ( !IsCastleArms() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
m_cState = Siege::REPARING;
|
||||
m_dwRepairHP = dwRepairHP;
|
||||
m_cRepairTime = Siege::CASTLE_ARMS_REPAIR_TIME;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectTime(m_DBComponent, m_dwCID, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCastleArmsDB::Destroy(unsigned long dwEnemyNation, bool bDeductFame)
|
||||
{
|
||||
if ( !IsCastleArms() || Siege::CASTLE_ARMS_NPC == m_wObjectType )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_wObjectType = Siege::CASTLE_ARMS_NPC;
|
||||
m_cState = Siege::COMPLETE;
|
||||
m_cUpgradeStep = 0;
|
||||
m_dwHP = 0;
|
||||
m_dwOwnerID = 0;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectType(m_DBComponent, m_dwCID, m_wObjectType, m_dwOwnerID);
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectUpgrade(m_DBComponent, m_dwCID, m_cUpgradeStep, m_cUpgradeType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCastleArmsDB::UpdateLastUseTime(bool bInit)
|
||||
{
|
||||
CSiegeObjectDB::UpdateLastUseTime(bInit);
|
||||
|
||||
if (!bInit)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectLastUseTime(m_DBComponent, m_dwCID, sysTime);
|
||||
}
|
||||
}
|
||||
|
||||
void CCastleArmsDB::UpdateHP(unsigned long dwNowHP)
|
||||
{
|
||||
CSiegeObjectDB::UpdateHP(dwNowHP);
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectHP(m_DBComponent, m_dwCID, m_dwHP);
|
||||
}
|
||||
|
||||
Siege::eReturn CCastleArmsDB::Process()
|
||||
{
|
||||
CTime nowTime = CTime::GetCurrentTime();
|
||||
CTimeSpan timeSpan(0);
|
||||
|
||||
switch (m_cState)
|
||||
{
|
||||
case Siege::COMPLETE: // 병기 개발 완료된 정상 상태일때
|
||||
{
|
||||
if (0 != m_LastUseTime.Year && Siege::CASTLE_ARMS_NPC != m_wObjectType)
|
||||
{
|
||||
CTime lastUseTime(m_LastUseTime.Year, m_LastUseTime.Month, m_LastUseTime.Day,
|
||||
m_LastUseTime.Hour, m_LastUseTime.Minute, m_LastUseTime.Second);
|
||||
|
||||
timeSpan = nowTime - lastUseTime;
|
||||
if (timeSpan.GetTotalMinutes() >= Siege::CASTLE_ARMS_LEAST_USE_TIME)
|
||||
{
|
||||
// 병기 파괴
|
||||
Destroy();
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(0, PktCastleCmd::CASTLE_DESTROY_ARMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::DEVELOPING: // 병기 개발중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime developTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - developTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cDevelopTime)
|
||||
{
|
||||
// 병기 개발 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
|
||||
UpdateLastUseTime();
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(m_wObjectType, PktCastleCmd::CASTLE_CREATE_ARMS_COMPLETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::UPGRADING: // 업그레이드중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime upgradeTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - upgradeTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cUpgradeTime)
|
||||
{
|
||||
// 수리 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
++m_cUpgradeStep;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectUpgrade(m_DBComponent, m_dwCID, m_cUpgradeStep, m_cUpgradeType);
|
||||
|
||||
UpdateLastUseTime();
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(m_cUpgradeStep, PktCastleCmd::CASTLE_UPGRADE_ARMS_COMPLETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::REPARING: // 수리중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime repairTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - repairTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cRepairTime)
|
||||
{
|
||||
// 수리 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
|
||||
UpdateLastUseTime();
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(m_dwRepairHP, PktCastleCmd::CASTLE_REPAIR_ARMS_COMPLETE);
|
||||
m_dwRepairHP = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Siege::RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef _RYL_DBAGENT_CASTLE_ARMS_DB_H_
|
||||
#define _RYL_DBAGENT_CASTLE_ARMS_DB_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SiegeObjectDB.h"
|
||||
|
||||
using namespace Siege;
|
||||
|
||||
class CCastleArmsDB : public CSiegeObjectDB
|
||||
{
|
||||
public:
|
||||
virtual ~CCastleArmsDB();
|
||||
|
||||
// Process ÇÔ¼ö
|
||||
Siege::eReturn Process();
|
||||
|
||||
// Cmd ó¸® °¡»ó ÇÔ¼ö
|
||||
bool Build(unsigned short wType, unsigned char cDevelopTime, unsigned long dwDevelopGold = 0, unsigned long dwOwnerID = 0);
|
||||
bool Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold = 0, unsigned char cUpgradeType = Siege::NO_JEWEL);
|
||||
bool Repair(unsigned long dwRepairHP, unsigned long dwRepairGold = 0);
|
||||
bool Destroy(unsigned long dwEnemyNation = 0, bool bDeductFame = false);
|
||||
|
||||
void UpdateLastUseTime(bool bInit=false);
|
||||
void UpdateHP(unsigned long dwNowHP);
|
||||
|
||||
private:
|
||||
|
||||
CCastleArmsDB(CDBComponent& DBComponent, const CastleObjectInfoDB& CastleObject);
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif _RYL_DBAGENT_CASTLE_ARMS_DB_H_
|
||||
@@ -0,0 +1,232 @@
|
||||
#include "stdafx.h"
|
||||
#include "CastleEmblemDB.h"
|
||||
#include "SiegeObjectDBMgr.h"
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Community/Guild/GuildDB.h>
|
||||
#include <Community/Guild/GuildDBMgr.h>
|
||||
|
||||
#include <Castle/CastleDB.h>
|
||||
#include <Castle/CastleDBMgr.h>
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include <atltime.h>
|
||||
|
||||
#include <GameTime/GameTimeDBMgr.h>
|
||||
|
||||
|
||||
|
||||
CCastleEmblemDB::CCastleEmblemDB(CDBComponent& DBComponent, const CastleObjectInfoDB& CastleObject)
|
||||
: CSiegeObjectDB(DBComponent, CastleObject), m_cEnemyNation(0)
|
||||
{
|
||||
m_cSubState = Siege::MINE;
|
||||
}
|
||||
|
||||
CCastleEmblemDB::~CCastleEmblemDB()
|
||||
{
|
||||
}
|
||||
|
||||
bool CCastleEmblemDB::Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold, unsigned char cUpgradeType)
|
||||
{
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
if (Siege::MAX_EMBLEM_UPGRADE == m_cUpgradeStep) return false;
|
||||
|
||||
m_cState = Siege::UPGRADING;
|
||||
if (0 == m_cUpgradeStep) m_cUpgradeType = cUpgradeType;
|
||||
m_cUpgradeTime = cUpgradeTime;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectTime(m_DBComponent, m_dwCID, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCastleEmblemDB::Destroy(unsigned long dwEnemyNation, bool bDeductFame)
|
||||
{
|
||||
m_cState = Siege::DEVELOPING;
|
||||
m_cUpgradeStep = 0;
|
||||
m_cUpgradeType = Siege::NO_JEWEL;
|
||||
|
||||
if (m_cSubState == Siege::ENEMY)
|
||||
{
|
||||
m_cSubState = Siege::MINE;
|
||||
m_cEnemyNation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cSubState = Siege::ENEMY;
|
||||
m_cEnemyNation = (unsigned char)dwEnemyNation;
|
||||
}
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, Siege::MINE);
|
||||
DBComponent::CastleDB::UpdateCastleObjectUpgrade(m_DBComponent, m_dwCID, m_cUpgradeStep, m_cUpgradeType);
|
||||
DBComponent::CastleDB::UpdateCastleObjectTime(m_DBComponent, m_dwCID, sysTime);
|
||||
|
||||
// 상징물이 부셔지면 성문도 부서지도록 만든다.
|
||||
Castle::CCastleDB* lpCastle = Castle::CCastleDBMgr::GetInstance().GetCastle(m_dwCampOrCastleID);
|
||||
if (0 != lpCastle)
|
||||
{
|
||||
CSiegeObjectDB* lpGate = lpCastle->GetCastleGate();
|
||||
if (0 != lpGate && Siege::DESTROYED != lpGate->GetState())
|
||||
{
|
||||
lpGate->Destroy();
|
||||
lpGate->SendCastleCmd(0, PktCastleCmd::CASTLE_DESTROY_GATE);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCastleEmblemDB::UpdateHP(unsigned long dwNowHP)
|
||||
{
|
||||
CSiegeObjectDB::UpdateHP(dwNowHP);
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectHP(m_DBComponent, m_dwCID, m_dwHP);
|
||||
}
|
||||
|
||||
|
||||
Siege::eReturn CCastleEmblemDB::Process()
|
||||
{
|
||||
CTime nowTime = CTime::GetCurrentTime();
|
||||
CTimeSpan timeSpan(0);
|
||||
|
||||
switch (m_cState)
|
||||
{
|
||||
case Siege::COMPLETE: // 소환 완료 상태
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::DEVELOPING: // 소환중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime summonTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - summonTime;
|
||||
if (timeSpan.GetTotalMinutes() >= Siege::EMBLEM_SUMMON_TIME)
|
||||
{
|
||||
// 성 상징물 소환 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, Siege::MINE);
|
||||
|
||||
if (m_cSubState == Siege::MINE)
|
||||
{
|
||||
// 아군이 소환 완료
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
// [Out] dwValue1 : SubState (아군이 소환했는지, 적이 소환했는지 정보)
|
||||
SendCastleCmd(m_cSubState, PktCastleCmd::CASTLE_SUMMON_EMBLEM_COMPLETE);
|
||||
|
||||
Castle::CCastleDB* lpCastle = Castle::CCastleDBMgr::GetInstance().GetCastle( GetCastleID() );
|
||||
|
||||
if(lpCastle)
|
||||
{
|
||||
lpCastle->ChangeCastleMaster(static_cast<unsigned char>(lpCastle->GetNation()));
|
||||
|
||||
SendCastleCmd(lpCastle->GetNation(), PktCastleCmd::CASTLE_CHANGE_MASTER);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 적군이 소환 완료.. 성주 변경
|
||||
Castle::CCastleDB* lpCastle = Castle::CCastleDBMgr::GetInstance().GetCastle( GetCastleID() );
|
||||
|
||||
if (lpCastle)
|
||||
{
|
||||
if(CGameTimeDBMgr::GetInstance().IsSiegeWarTime())
|
||||
{
|
||||
// CASTLE_TODO : 공성전은 길드와 무관하다.
|
||||
// CSiegeObjectDBMgr::GetInstance().DestroyCamp(m_dwGID);
|
||||
lpCastle->ChangeCastleMaster(m_cEnemyNation);
|
||||
m_cSubState = Siege::MINE;
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
// [Out] dwValue1 : 새로운 성의 국가
|
||||
SendCastleCmd(m_cEnemyNation, PktCastleCmd::CASTLE_CHANGE_MASTER);
|
||||
}
|
||||
else // 공성시간이 이후 소환이 완료 되었을 경우 성에 주인을 바꾸지 않는다.
|
||||
{
|
||||
unsigned char cNation = Creature::STATELESS;
|
||||
|
||||
if(m_cEnemyNation!=Creature::STATELESS)
|
||||
{
|
||||
cNation = (m_cEnemyNation==Creature::KARTERANT) ? Creature::MERKADIA : Creature::KARTERANT;
|
||||
}
|
||||
|
||||
lpCastle->ChangeCastleMaster(cNation);
|
||||
m_cSubState = Siege::MINE;
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
// [Out] dwValue1 : 새로운 성의 국가
|
||||
SendCastleCmd(cNation, PktCastleCmd::CASTLE_CHANGE_MASTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::UPGRADING: // 업그레이드중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime upgradeTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - upgradeTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cUpgradeTime)
|
||||
{
|
||||
// 길드 요새 업그레이드 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
++m_cUpgradeStep;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectUpgrade(m_DBComponent, m_dwCID, m_cUpgradeStep, m_cUpgradeType);
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
// [In/Out] dwValue1 : 업그레이드 단계
|
||||
SendCastleCmd(m_cUpgradeStep, PktCastleCmd::CASTLE_UPGRADE_EMBLEM_COMPLETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Siege::RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef _RYL_DBAGENT_CASTLE_EMBLEM_DB_H_
|
||||
#define _RYL_DBAGENT_CASTLE_EMBLEM_DB_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SiegeObjectDB.h"
|
||||
|
||||
using namespace Siege;
|
||||
|
||||
class CCastleEmblemDB : public CSiegeObjectDB
|
||||
{
|
||||
public:
|
||||
virtual ~CCastleEmblemDB();
|
||||
|
||||
// Process 함수
|
||||
Siege::eReturn Process();
|
||||
|
||||
// Cmd 처리 가상 함수
|
||||
bool Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold = 0, unsigned char cUpgradeType = Siege::NO_JEWEL);
|
||||
bool Destroy(unsigned long dwEnemyNation = 0, bool bDeductFame = false);
|
||||
|
||||
void UpdateHP(unsigned long dwNowHP);
|
||||
|
||||
private:
|
||||
|
||||
CCastleEmblemDB(CDBComponent& DBComponent, const CastleObjectInfoDB& CastleObject);
|
||||
|
||||
unsigned char m_cEnemyNation; // Nation : 성 상징물을 공격해서 부순 적의 국가 ID
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif _RYL_DBAGENT_CASTLE_EMBLEM_DB_H_
|
||||
@@ -0,0 +1,279 @@
|
||||
#include "stdafx.h"
|
||||
#include "CastleGateDB.h"
|
||||
#include "SiegeObjectDBMgr.h"
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Community/Guild/GuildDB.h>
|
||||
#include <Community/Guild/GuildDBMgr.h>
|
||||
|
||||
#include <Castle/Castle.h>
|
||||
#include <Castle/CastleMgr.h>
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include <atltime.h>
|
||||
|
||||
|
||||
CCastleGateDB::CCastleGateDB(CDBComponent& DBComponent, const CastleObjectInfoDB& CastleObject)
|
||||
: CSiegeObjectDB(DBComponent, CastleObject)
|
||||
{
|
||||
}
|
||||
|
||||
CCastleGateDB::~CCastleGateDB()
|
||||
{
|
||||
}
|
||||
|
||||
bool CCastleGateDB::Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold, unsigned char cUpgradeType)
|
||||
{
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
if (Siege::MAX_UPGRADE_NUM == m_cUpgradeStep) return false;
|
||||
|
||||
m_cState = Siege::UPGRADING;
|
||||
m_cUpgradeTime = cUpgradeTime;
|
||||
|
||||
// CASTLE_TODO : 개인 금고에서 빼내야한다.
|
||||
|
||||
// // 업글 비용 길드 창고에서 빼기
|
||||
// Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
// Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
//
|
||||
// if (lpGuild)
|
||||
// {
|
||||
// lpGuild->DeductGold(dwUpgradeGold);
|
||||
// }
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectTime(m_DBComponent, m_dwCID, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCastleGateDB::Repair(unsigned long dwRepairHP, unsigned long dwRepairGold)
|
||||
{
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
m_cState = Siege::REPARING;
|
||||
m_dwRepairHP = dwRepairHP;
|
||||
m_cRepairTime = static_cast<unsigned char>(dwRepairHP * Siege::GATE_REPAIR_MIN_PER_HP);
|
||||
|
||||
// CASTLE_TODO : 개인 금고에서 빼내야한다.
|
||||
|
||||
// // 수리 비용 길드 창고에서 빼기
|
||||
// Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
// Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
//
|
||||
// if (lpGuild)
|
||||
// {
|
||||
// lpGuild->DeductGold(dwRepairGold);
|
||||
// }
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectTime(m_DBComponent, m_dwCID, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCastleGateDB::Restore(unsigned char cRestoreTime, unsigned long dwRestoreGold)
|
||||
{
|
||||
if (Siege::DESTROYED == m_cState)
|
||||
{
|
||||
m_cState = Siege::RESTORING;
|
||||
m_cDevelopTime = cRestoreTime;
|
||||
|
||||
// CASTLE_TODO : 개인 금고에서 빼내야한다.
|
||||
|
||||
// 복구 비용을 길드 창고에서 빼기
|
||||
// Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB*>(
|
||||
// Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
//
|
||||
// if (lpGuild)
|
||||
// {
|
||||
// lpGuild->DeductGold(dwRestoreGold);
|
||||
// }
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectTime(m_DBComponent, m_dwCID, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCastleGateDB::Destroy(unsigned long dwEnemyNation, bool bDeductFame)
|
||||
{
|
||||
m_cState = Siege::DESTROYED;
|
||||
m_cSubState = Siege::OPENED;
|
||||
m_cUpgradeStep = 0;
|
||||
m_dwHP = 0;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectUpgrade(m_DBComponent, m_dwCID, m_cUpgradeStep, m_cUpgradeType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCastleGateDB::UpdateHP(unsigned long dwNowHP)
|
||||
{
|
||||
CSiegeObjectDB::UpdateHP(dwNowHP);
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectHP(m_DBComponent, m_dwCID, m_dwHP);
|
||||
}
|
||||
|
||||
void CCastleGateDB::ForceOpen()
|
||||
{
|
||||
if (Siege::COMPLETE == m_cState && Siege::OPENED == m_cSubState)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
m_cState = Siege::COMPLETE;
|
||||
m_cSubState = Siege::OPENED;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(0, PktCastleCmd::CASTLE_GATE_FORCE_OPEN);
|
||||
}
|
||||
|
||||
void CCastleGateDB::ForceClose()
|
||||
{
|
||||
if (Siege::COMPLETE == m_cSubState && Siege::CLOSED == m_cSubState)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
m_cState = Siege::COMPLETE;
|
||||
m_cSubState = Siege::CLOSED;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(0, PktCastleCmd::CASTLE_GATE_FORCE_CLOSE);
|
||||
}
|
||||
|
||||
Siege::eReturn CCastleGateDB::Process()
|
||||
{
|
||||
CTime nowTime = CTime::GetCurrentTime();
|
||||
CTimeSpan timeSpan(0);
|
||||
|
||||
switch (m_cState)
|
||||
{
|
||||
case Siege::UPGRADING: // 업그레이드중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime upgradeTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - upgradeTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cUpgradeTime)
|
||||
{
|
||||
// 성문 업그레이드 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
++m_cUpgradeStep;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCastleObjectUpgrade(m_DBComponent, m_dwCID, m_cUpgradeStep, m_cUpgradeType);
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(m_cUpgradeStep, PktCastleCmd::CASTLE_UPGRADE_GATE_COMPLETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::REPARING: // 수리중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime repairTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - repairTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cRepairTime)
|
||||
{
|
||||
// 수리 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(m_dwRepairHP, PktCastleCmd::CASTLE_REPAIR_GATE_COMPLETE);
|
||||
m_dwRepairHP = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::RESTORING: // 복구중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime restoreTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - restoreTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cDevelopTime)
|
||||
{
|
||||
// 복구 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
m_cUpgradeStep = 0;
|
||||
m_dwHP = 0;
|
||||
|
||||
DBComponent::CastleDB::UpdateCastleObjectState(m_DBComponent, m_dwCID, m_cState, m_cSubState);
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCastleCmd(m_dwHP, PktCastleCmd::CASTLE_RESTORE_GATE_COMPLETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Siege::RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef _RYL_DBAGENT_CASTLE_GATE_DB_H_
|
||||
#define _RYL_DBAGENT_CASTLE_GATE_DB_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SiegeObjectDB.h"
|
||||
|
||||
using namespace Siege;
|
||||
|
||||
class CCastleGateDB : public CSiegeObjectDB
|
||||
{
|
||||
public:
|
||||
virtual ~CCastleGateDB();
|
||||
|
||||
// Process 함수
|
||||
Siege::eReturn Process();
|
||||
|
||||
// Cmd 처리 가상 함수
|
||||
bool Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold = 0, unsigned char cUpgradeType = Siege::NO_JEWEL);
|
||||
bool Repair(unsigned long dwRepairHP, unsigned long dwRepairGold = 0);
|
||||
bool Restore(unsigned char cRestoreTime, unsigned long dwRestoreGold = 0);
|
||||
bool Destroy(unsigned long dwEnemyNation = 0, bool bDeductFame = false);
|
||||
|
||||
void UpdateHP(unsigned long dwNowHP);
|
||||
|
||||
// 중계 서버에서 강제로 Open / Close 상태로 만드는 기능 (상태는 Complete로 된다.)
|
||||
void ForceOpen();
|
||||
void ForceClose();
|
||||
|
||||
private:
|
||||
|
||||
CCastleGateDB(CDBComponent& DBComponent, const CastleObjectInfoDB& CastleObject);
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif _RYL_DBAGENT_CASTLE_GATE_DB_H_
|
||||
@@ -0,0 +1,198 @@
|
||||
#include "stdafx.h"
|
||||
#include "MiningCampDB.h"
|
||||
#include "SiegeObjectDBMgr.h"
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
|
||||
CMiningCampDB::CMiningCampDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo)
|
||||
: CCampDB(DBComponent, CampInfo)
|
||||
{
|
||||
}
|
||||
|
||||
CMiningCampDB::~CMiningCampDB()
|
||||
{
|
||||
}
|
||||
|
||||
bool CMiningCampDB::OnOff(unsigned long dwSubState)
|
||||
{
|
||||
if ( Siege::MINING_ON == dwSubState && Siege::MINING_ON != m_cSubState )
|
||||
{
|
||||
m_cSiegeCount = 0;
|
||||
m_cSubState = Siege::MINING_ON;
|
||||
DBComponent::CastleDB::UpdateCampSubState(m_DBComponent, GetCampID(), m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCampSiegeCount(m_DBComponent, GetCampID(), m_cSiegeCount);
|
||||
}
|
||||
else if ( Siege::MINING_OFF == dwSubState && Siege::MINING_OFF != m_cSubState )
|
||||
{
|
||||
m_cSiegeCount = 0;
|
||||
m_cSubState = Siege::MINING_OFF;
|
||||
DBComponent::CastleDB::UpdateCampSubState(m_DBComponent, GetCampID(), m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCampSiegeCount(m_DBComponent, GetCampID(), m_cSiegeCount);
|
||||
|
||||
// 임시 보관된 광물 날리기
|
||||
DBComponent::CastleDB::DeleteMiningCampMineralInfo(m_DBComponent, GetCampID(), Siege::TEMPORARY_MINERAL);
|
||||
m_TemporaryMineralMap.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMiningCampDB::GainMineral(unsigned short wMineralID, unsigned short wAmount)
|
||||
{
|
||||
MineralInfoMap::iterator itr = m_AccumulatedMineralMap.find(wMineralID);
|
||||
|
||||
if (itr != m_AccumulatedMineralMap.end())
|
||||
{
|
||||
if (itr->second < wAmount)
|
||||
{
|
||||
ERRLOG4(g_Log, "획득할려는 아이템 수보다 현재 누적된 아이템 수가 더 적습니다.( CampID : 0x%08x, MineralID : %d, CurrentAmount : %d, GainAmount : %d )",
|
||||
GetCampID(), wMineralID, itr->second, wAmount);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itr->second == wAmount)
|
||||
{
|
||||
DBComponent::CastleDB::DeleteMiningCampMineralInfo(m_DBComponent, GetCampID(), Siege::ACCUMULATED_MINERAL, wMineralID);
|
||||
m_AccumulatedMineralMap.erase(itr);
|
||||
}
|
||||
else
|
||||
{
|
||||
itr->second -= wAmount;
|
||||
DBComponent::CastleDB::UpdateMiningCampMineralInfo(m_DBComponent, GetCampID(), Siege::ACCUMULATED_MINERAL, wMineralID, itr->second);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMiningCampDB::AddMineral(unsigned char cFlag, const CampMineralInfo& campMineralInfo)
|
||||
{
|
||||
if (campMineralInfo.m_wAmount > 0)
|
||||
{
|
||||
switch (cFlag)
|
||||
{
|
||||
case Siege::ACCUMULATED_MINERAL :
|
||||
{
|
||||
m_AccumulatedMineralMap.insert( std::make_pair(campMineralInfo.m_wMineralID, campMineralInfo.m_wAmount) ).second;
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::TEMPORARY_MINERAL :
|
||||
{
|
||||
m_TemporaryMineralMap.insert( std::make_pair(campMineralInfo.m_wMineralID, campMineralInfo.m_wAmount) ).second;
|
||||
}
|
||||
break;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMiningCampDB::UpdateMineralInfo(unsigned char cFlag, unsigned char cNum, CampMineralInfo* lpMineralInfo)
|
||||
{
|
||||
switch (cFlag)
|
||||
{
|
||||
case Siege::TEMPORARY_MINERAL :
|
||||
{
|
||||
DBComponent::CastleDB::DeleteMiningCampMineralInfo(m_DBComponent, GetCampID(), cFlag);
|
||||
m_TemporaryMineralMap.clear();
|
||||
|
||||
for (int i=0; i<cNum; ++i)
|
||||
{
|
||||
DBComponent::CastleDB::InsertMiningCampMineralInfo(m_DBComponent, GetCampID(), cFlag,
|
||||
lpMineralInfo->m_wMineralID, lpMineralInfo->m_wAmount);
|
||||
|
||||
AddMineral(cFlag, *lpMineralInfo);
|
||||
++lpMineralInfo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::ACCUMULATED_MINERAL :
|
||||
{
|
||||
DBComponent::CastleDB::DeleteMiningCampMineralInfo(m_DBComponent, GetCampID(), cFlag);
|
||||
m_AccumulatedMineralMap.clear();
|
||||
|
||||
for (int i=0; i<cNum; ++i)
|
||||
{
|
||||
DBComponent::CastleDB::InsertMiningCampMineralInfo(m_DBComponent, GetCampID(), cFlag,
|
||||
lpMineralInfo->m_wMineralID, lpMineralInfo->m_wAmount);
|
||||
|
||||
AddMineral(cFlag, *lpMineralInfo);
|
||||
++lpMineralInfo;
|
||||
}
|
||||
|
||||
m_cSiegeCount = 0;
|
||||
DBComponent::CastleDB::UpdateCampSiegeCount(m_DBComponent, GetCampID(), m_cSiegeCount);
|
||||
}
|
||||
break;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CMiningCampDB::SerializeOut(char* szBuffer_Out, unsigned short& usBufferSize_Out, unsigned long& dwCID_Out)
|
||||
{
|
||||
if (CCampDB::SerializeOut(szBuffer_Out, usBufferSize_Out, dwCID_Out))
|
||||
{
|
||||
char* lpBuffer = szBuffer_Out + usBufferSize_Out;
|
||||
|
||||
if (!lpBuffer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 채굴기 정보
|
||||
unsigned short wSize = 0;
|
||||
MiningCampInfo* lpMiningCampInfo = reinterpret_cast<MiningCampInfo*>(lpBuffer);
|
||||
|
||||
lpMiningCampInfo->m_cAccumulatedNum = static_cast<unsigned char>(m_AccumulatedMineralMap.size());
|
||||
lpMiningCampInfo->m_cTemporaryNum = static_cast<unsigned char>(m_TemporaryMineralMap.size());
|
||||
|
||||
wSize += sizeof(MiningCampInfo);
|
||||
|
||||
// 누적 광물 정보
|
||||
CampMineralInfo* lpCampMineralInfo = reinterpret_cast<CampMineralInfo*>(lpMiningCampInfo + 1);
|
||||
for (MineralInfoMap::iterator itr = m_AccumulatedMineralMap.begin();
|
||||
itr != m_AccumulatedMineralMap.end(); ++itr, ++lpCampMineralInfo)
|
||||
{
|
||||
lpCampMineralInfo->m_wMineralID = itr->first;
|
||||
lpCampMineralInfo->m_wAmount = itr->second;
|
||||
|
||||
wSize += sizeof(CampMineralInfo);
|
||||
}
|
||||
|
||||
// 임시 광물 정보
|
||||
for (MineralInfoMap::iterator itr = m_TemporaryMineralMap.begin();
|
||||
itr != m_TemporaryMineralMap.end(); ++itr, ++lpCampMineralInfo)
|
||||
{
|
||||
lpCampMineralInfo->m_wMineralID = itr->first;
|
||||
lpCampMineralInfo->m_wAmount = itr->second;
|
||||
|
||||
wSize += sizeof(CampMineralInfo);
|
||||
}
|
||||
|
||||
lpMiningCampInfo->m_wSize = wSize;
|
||||
usBufferSize_Out += wSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef _RYL_DBAGENT_MINING_CAMP_H_
|
||||
#define _RYL_DBAGENT_MINING_CAMP_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CampDB.h"
|
||||
#include <map>
|
||||
#include <Network/Packet/PacketStruct/CastlePacket.h>
|
||||
|
||||
using namespace Siege;
|
||||
|
||||
|
||||
class CMiningCampDB : public CCampDB
|
||||
{
|
||||
public:
|
||||
virtual ~CMiningCampDB();
|
||||
|
||||
typedef std::map<unsigned short, unsigned short> MineralInfoMap; // <wMineralID, wAmount>
|
||||
|
||||
bool OnOff(unsigned long dwSubState);
|
||||
bool GainMineral(unsigned short wMineralID, unsigned short wAmount); // 누적 광물 획득
|
||||
|
||||
// 주의 AddMineral 함수는 insert만 담당함!! (이미 있는 녀석의 Add 는 하지 않음)
|
||||
bool AddMineral(unsigned char cFlag, const CampMineralInfo& campMineralInfo);
|
||||
bool UpdateMineralInfo(unsigned char cFlag, unsigned char cNum, CampMineralInfo* lpMineralInfo);
|
||||
|
||||
bool SerializeOut(char* szBuffer_Out, unsigned short& usBufferSize_Out, unsigned long& dwCID_Out);
|
||||
|
||||
private:
|
||||
CMiningCampDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo);
|
||||
|
||||
MineralInfoMap m_AccumulatedMineralMap;
|
||||
MineralInfoMap m_TemporaryMineralMap;
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif // _RYL_DBAGENT_MINING_CAMP_H_
|
||||
@@ -0,0 +1,182 @@
|
||||
#include "stdafx.h"
|
||||
#include "SiegeArmsDB.h"
|
||||
#include "SiegeObjectDBMgr.h"
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Community/Guild/GuildDB.h>
|
||||
#include <Community/Guild/GuildDBMgr.h>
|
||||
|
||||
#include <Castle/Castle.h>
|
||||
#include <Castle/CastleMgr.h>
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include <atltime.h>
|
||||
|
||||
|
||||
CSiegeArmsDB::CSiegeArmsDB(CDBComponent& DBComponent, unsigned long dwOwnerID,
|
||||
unsigned char cNation, unsigned short wObjectType, unsigned char cUpgradeStep,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos)
|
||||
: CSiegeObjectDB(DBComponent, dwOwnerID, cNation, wObjectType, cUpgradeStep, cZone, cChannel, Pos)
|
||||
{
|
||||
}
|
||||
|
||||
CSiegeArmsDB::~CSiegeArmsDB()
|
||||
{
|
||||
}
|
||||
|
||||
bool CSiegeArmsDB::Repair(unsigned long dwRepairHP, unsigned long dwRepairGold)
|
||||
{
|
||||
if (Siege::COMPLETE == m_cState)
|
||||
{
|
||||
m_cState = Siege::REPARING;
|
||||
m_dwRepairHP = dwRepairHP;
|
||||
m_cRepairTime = Siege::SIEGE_ARMS_REPAIR_TIME;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSiegeArmsDB::Destroy(unsigned long dwEnemyNation, bool bDeductFame)
|
||||
{
|
||||
m_cState = Siege::DESTROYED;
|
||||
m_dwHP = 0;
|
||||
m_cUpgradeStep = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSiegeArmsDB::ToStartKit()
|
||||
{
|
||||
m_cState = Siege::DESTROYING;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Siege::eReturn CSiegeArmsDB::Process()
|
||||
{
|
||||
CTime nowTime = CTime::GetCurrentTime();
|
||||
CTimeSpan timeSpan(0);
|
||||
|
||||
switch (m_cState)
|
||||
{
|
||||
case Siege::COMPLETE: // 완료 상태
|
||||
{
|
||||
if (0 != m_LastUseTime.Year)
|
||||
{
|
||||
CTime lastUseTime(m_LastUseTime.Year, m_LastUseTime.Month, m_LastUseTime.Day,
|
||||
m_LastUseTime.Hour, m_LastUseTime.Minute, m_LastUseTime.Second);
|
||||
|
||||
timeSpan = nowTime - lastUseTime;
|
||||
if (timeSpan.GetTotalMinutes() > Siege::SIEGE_ARMS_LEAST_USE_TIME)
|
||||
{
|
||||
Destroy();
|
||||
SendSiegeArmsCmd(0, PktSiegeArmsCmd::SIEGE_DESTROY_ARMS);
|
||||
|
||||
// 공성 병기 객체 삭제
|
||||
return Siege::RET_DESTROY_SIEGE_ARMS;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::DEVELOPING: // 개발중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime developTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - developTime;
|
||||
if (timeSpan.GetTotalMinutes() >= Siege::SIEGE_ARMS_BUILDING_TIME)
|
||||
{
|
||||
// 공성 병기 개발 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
UpdateLastUseTime();
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendSiegeArmsCmd(m_cUpgradeStep, PktSiegeArmsCmd::SIEGE_CREATE_ARMS_COMPLETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::REPARING: // 수리중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime repairTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - repairTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cRepairTime)
|
||||
{
|
||||
// 공성 병기 수리 완료
|
||||
m_cState = Siege::COMPLETE;
|
||||
UpdateLastUseTime();
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendSiegeArmsCmd(m_dwRepairHP, PktSiegeArmsCmd::SIEGE_REPAIR_ARMS_COMPLETE);
|
||||
m_dwRepairHP = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Siege::DESTROYING: // 스타트킷으로 돌리기 중
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime destroyTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - destroyTime;
|
||||
if (timeSpan.GetTotalMinutes() >= Siege::SIEGE_ARMS_TO_STARTKIT_TIME)
|
||||
{
|
||||
// 공성 병기 파괴
|
||||
Destroy();
|
||||
UpdateLastUseTime();
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendSiegeArmsCmd(1, PktSiegeArmsCmd::SIEGE_TO_STARTKIT_COMPLETE);
|
||||
|
||||
// 공성 병기 객체 삭제
|
||||
return Siege::RET_DESTROY_SIEGE_ARMS;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Siege::RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef _RYL_DBAGENT_SIEGE_ARMS_DB_H_
|
||||
#define _RYL_DBAGENT_SIEGE_ARMS_DB_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SiegeObjectDB.h"
|
||||
|
||||
using namespace Siege;
|
||||
|
||||
class CSiegeArmsDB : public CSiegeObjectDB
|
||||
{
|
||||
public:
|
||||
virtual ~CSiegeArmsDB();
|
||||
|
||||
// Process ÇÔ¼ö
|
||||
Siege::eReturn Process();
|
||||
|
||||
// Cmd ó¸® °¡»ó ÇÔ¼ö
|
||||
bool Repair(unsigned long dwRepairHP, unsigned long dwRepairGold = 0);
|
||||
bool Destroy(unsigned long dwEnemyNation = 0, bool bDeductFame = false);
|
||||
|
||||
bool ToStartKit();
|
||||
|
||||
private:
|
||||
|
||||
CSiegeArmsDB(CDBComponent& DBComponent, unsigned long dwOwnerID,
|
||||
unsigned char cNation, unsigned short wObjectType, unsigned char cUpgradeStep,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos);
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif _RYL_DBAGENT_SIEGE_ARMS_DB_H_
|
||||
@@ -0,0 +1,425 @@
|
||||
#include "stdafx.h"
|
||||
#include "SiegeObjectDB.h"
|
||||
#include "SiegeObjectDBMgr.h"
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Community/Guild/GuildDB.h>
|
||||
#include <Community/Guild/GuildDBMgr.h>
|
||||
|
||||
#include <Castle/Castle.h>
|
||||
#include <Castle/CastleMgr.h>
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include <atltime.h>
|
||||
|
||||
|
||||
CSiegeObjectDB::CSiegeObjectDB(CDBComponent& DBComponent, const CastleObjectInfoDB& CastleObject)
|
||||
: m_dwCID(Creature::SIEGE_OBJECT_BIT | CastleObject.m_dwCID),
|
||||
m_dwCampOrCastleID(CastleObject.m_dwCastleID),
|
||||
m_dwOwnerID(CastleObject.m_dwOwnerID),
|
||||
m_dwGID(0),
|
||||
m_cNation(0),
|
||||
m_dwHP(CastleObject.m_dwHP),
|
||||
m_wObjectType(CastleObject.m_wObjectType),
|
||||
m_cState(CastleObject.m_cState),
|
||||
m_cSubState(CastleObject.m_cSubState),
|
||||
m_cUpgradeStep(CastleObject.m_cUpgradeStep),
|
||||
m_cUpgradeType(CastleObject.m_cUpgradeType),
|
||||
m_cZone(0),
|
||||
m_cChannel(0),
|
||||
m_TimeValue(CastleObject.m_RemainUpTime),
|
||||
m_LastUseTime(CastleObject.m_LastUseTime),
|
||||
m_Pos(CastleObject.m_Pos),
|
||||
m_cMaterial(0),
|
||||
m_cSiegeCount(0),
|
||||
m_dwRepairHP(0),
|
||||
m_fDefaultDir(CastleObject.m_fDefaultDir),
|
||||
m_cDevelopTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_cUpgradeTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_cRepairTime(Siege::DEFAULT_REPAIR_TIME),
|
||||
m_cChangeTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_DBComponent(DBComponent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CSiegeObjectDB::CSiegeObjectDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo)
|
||||
: m_dwCID(0),
|
||||
m_dwCampOrCastleID(Castle::CAMP_BIT | CampInfo.m_dwCampID),
|
||||
m_dwOwnerID(0),
|
||||
m_dwGID(CampInfo.m_dwGID),
|
||||
m_cNation(0),
|
||||
m_dwHP(CampInfo.m_dwHP),
|
||||
m_wObjectType(CampInfo.m_wObjectType),
|
||||
m_cState(CampInfo.m_cState),
|
||||
m_cSubState(CampInfo.m_cSubState),
|
||||
m_cUpgradeStep(CampInfo.m_cUpgradeStep),
|
||||
m_cUpgradeType(0),
|
||||
m_cZone(CampInfo.m_cZone),
|
||||
m_cChannel(CampInfo.m_cChannel),
|
||||
m_TimeValue(CampInfo.m_TimeValue),
|
||||
m_LastUseTime(CampInfo.m_LastUseTime),
|
||||
m_Pos(CampInfo.m_Pos),
|
||||
m_cMaterial(CampInfo.m_cMaterial),
|
||||
m_cSiegeCount(CampInfo.m_cSiegeCount),
|
||||
m_dwRepairHP(0),
|
||||
m_fDefaultDir(0),
|
||||
m_cDevelopTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_cUpgradeTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_cRepairTime(Siege::DEFAULT_REPAIR_TIME),
|
||||
m_cChangeTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_DBComponent(DBComponent)
|
||||
{
|
||||
}
|
||||
|
||||
CSiegeObjectDB::CSiegeObjectDB(CDBComponent& DBComponent, unsigned long dwCampID,
|
||||
unsigned long dwGID, unsigned char cZone,
|
||||
unsigned char cChannel, Position Pos)
|
||||
: m_dwCID(0),
|
||||
m_dwCampOrCastleID(dwCampID),
|
||||
m_dwOwnerID(0),
|
||||
m_dwGID(dwGID),
|
||||
m_cNation(0),
|
||||
m_dwHP(0),
|
||||
m_wObjectType(Siege::CAMP),
|
||||
m_cSubState(0),
|
||||
m_cState(DEVELOPING),
|
||||
m_cUpgradeStep(0),
|
||||
m_cUpgradeType(0),
|
||||
m_cZone(cZone),
|
||||
m_cChannel(cChannel),
|
||||
m_Pos(Pos),
|
||||
m_cMaterial(0),
|
||||
m_cSiegeCount(0),
|
||||
m_dwRepairHP(0),
|
||||
m_fDefaultDir(0),
|
||||
m_cDevelopTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_cUpgradeTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_cRepairTime(Siege::DEFAULT_REPAIR_TIME),
|
||||
m_cChangeTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_DBComponent(DBComponent)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
m_LastUseTime = m_TimeValue;
|
||||
}
|
||||
|
||||
CSiegeObjectDB::CSiegeObjectDB(CDBComponent& DBComponent, unsigned long dwOwnerID,
|
||||
unsigned char cNation, unsigned short wObjectType,
|
||||
unsigned char cUpgradeStep, unsigned char cZone, unsigned char cChannel,
|
||||
Position Pos)
|
||||
: m_dwCID(0),
|
||||
m_dwCampOrCastleID(0),
|
||||
m_dwOwnerID(dwOwnerID),
|
||||
m_dwGID(0),
|
||||
m_cNation(cNation),
|
||||
m_dwHP(0),
|
||||
m_wObjectType(wObjectType),
|
||||
m_cSubState(0),
|
||||
m_cState(DEVELOPING),
|
||||
m_cUpgradeStep(cUpgradeStep),
|
||||
m_cUpgradeType(0),
|
||||
m_cZone(cZone),
|
||||
m_cChannel(cChannel),
|
||||
m_Pos(Pos),
|
||||
m_cMaterial(0),
|
||||
m_cSiegeCount(0),
|
||||
m_dwRepairHP(0),
|
||||
m_fDefaultDir(0),
|
||||
m_cDevelopTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_cUpgradeTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_cRepairTime(Siege::DEFAULT_REPAIR_TIME),
|
||||
m_cChangeTime(Siege::DEFAULT_TIME_VALUE),
|
||||
m_DBComponent(DBComponent)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
m_LastUseTime = m_TimeValue;
|
||||
}
|
||||
|
||||
CSiegeObjectDB::~CSiegeObjectDB()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CSiegeObjectDB::SendCampCmd(unsigned char cSubCmd, unsigned long dwValue1, unsigned long dwValue2)
|
||||
{
|
||||
if ( IsCamp() )
|
||||
{
|
||||
SERVER_ID serverID;
|
||||
serverID.sID.Type = CServerSetup::GameServer;
|
||||
serverID.sID.Group = CServerSetup::GetInstance().GetServerGroup();
|
||||
serverID.sID.Channel = m_cChannel;
|
||||
serverID.sID.ID = m_cZone;
|
||||
|
||||
GET_MULTI_DISPATCH(lpGameDispatch, serverID.dwID,
|
||||
DBAgent::CGameDispatch, DBAgent::CGameDispatch::GetDispatchTable());
|
||||
|
||||
if(0 != lpGameDispatch)
|
||||
{
|
||||
CSendStream& SendStream = lpGameDispatch->GetSendStream();
|
||||
|
||||
char* lpBuffer = SendStream.GetBuffer(sizeof(PktCampCmd));
|
||||
if(0 != lpBuffer)
|
||||
{
|
||||
PktCampCmd* lpPktCampCmd = reinterpret_cast<PktCampCmd*>(lpBuffer);
|
||||
|
||||
lpPktCampCmd->m_dwCID = m_dwCID;
|
||||
lpPktCampCmd->m_dwCampID = GetCampID();
|
||||
lpPktCampCmd->m_cState = m_cState;
|
||||
lpPktCampCmd->m_dwValue1 = dwValue1;
|
||||
lpPktCampCmd->m_dwValue2 = dwValue2;
|
||||
lpPktCampCmd->m_cSubCmd = cSubCmd;
|
||||
|
||||
SendStream.WrapHeader(sizeof(PktCampCmd), CmdCampCmd, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSiegeObjectDB::SendCastleCmd(unsigned long dwValue, unsigned char cSubCmd)
|
||||
{
|
||||
if ( IsCastleObject() )
|
||||
{
|
||||
SERVER_ID serverID;
|
||||
serverID.sID.Type = CServerSetup::GameServer;
|
||||
serverID.sID.Group = CServerSetup::GetInstance().GetServerGroup();
|
||||
serverID.sID.Channel = m_cChannel;
|
||||
serverID.sID.ID = m_cZone;
|
||||
|
||||
GET_MULTI_DISPATCH(lpGameDispatch, serverID.dwID,
|
||||
DBAgent::CGameDispatch, DBAgent::CGameDispatch::GetDispatchTable());
|
||||
|
||||
if (0 != lpGameDispatch)
|
||||
{
|
||||
CSendStream& SendStream = lpGameDispatch->GetSendStream();
|
||||
|
||||
char* lpBuffer = SendStream.GetBuffer(sizeof(PktCampCmd));
|
||||
if (0 != lpBuffer)
|
||||
{
|
||||
PktCastleCmd* lpPktCastleCmd = reinterpret_cast<PktCastleCmd*>(lpBuffer);
|
||||
|
||||
lpPktCastleCmd->m_dwCastleID = GetCastleID();
|
||||
lpPktCastleCmd->m_dwCastleObjectID = m_dwCID;
|
||||
lpPktCastleCmd->m_cState = m_cState;
|
||||
lpPktCastleCmd->m_dwValue1 = dwValue;
|
||||
lpPktCastleCmd->m_dwValue2 = 0;
|
||||
lpPktCastleCmd->m_cSubCmd = cSubCmd;
|
||||
|
||||
SendStream.WrapHeader(sizeof(PktCastleCmd), CmdCastleCmd, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSiegeObjectDB::SendSiegeArmsCmd(unsigned long dwValue, unsigned char cSubCmd)
|
||||
{
|
||||
if ( IsSiegeArms() )
|
||||
{
|
||||
SERVER_ID serverID;
|
||||
|
||||
serverID.sID.Type = CServerSetup::GameServer;
|
||||
serverID.sID.Group = CServerSetup::GetInstance().GetServerGroup();
|
||||
serverID.sID.Channel = m_cChannel;
|
||||
serverID.sID.ID = m_cZone;
|
||||
|
||||
GET_MULTI_DISPATCH(lpGameDispatch, serverID.dwID,
|
||||
DBAgent::CGameDispatch, DBAgent::CGameDispatch::GetDispatchTable());
|
||||
|
||||
if(0 != lpGameDispatch)
|
||||
{
|
||||
CSendStream& SendStream = lpGameDispatch->GetSendStream();
|
||||
|
||||
char* lpBuffer = SendStream.GetBuffer(sizeof(PktSiegeArmsCmd));
|
||||
if(0 != lpBuffer)
|
||||
{
|
||||
PktSiegeArmsCmd* lpPktSiegeArmsCmd = reinterpret_cast<PktSiegeArmsCmd*>(lpBuffer);
|
||||
|
||||
lpPktSiegeArmsCmd->m_dwCID = m_dwOwnerID;
|
||||
lpPktSiegeArmsCmd->m_dwArmsID = m_dwCID;
|
||||
lpPktSiegeArmsCmd->m_cState = m_cState;
|
||||
lpPktSiegeArmsCmd->m_dwValue = dwValue;
|
||||
lpPktSiegeArmsCmd->m_cSubCmd = cSubCmd;
|
||||
|
||||
SendStream.WrapHeader(sizeof(PktSiegeArmsCmd), CmdSiegeArmsCmd, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSiegeObjectDB::UpdateLastUseTime(bool bInit)
|
||||
{
|
||||
if (bInit)
|
||||
{
|
||||
m_LastUseTime.Year = 0;
|
||||
m_LastUseTime.Month = 0;
|
||||
m_LastUseTime.Day = 0;
|
||||
m_LastUseTime.Hour = 0;
|
||||
m_LastUseTime.Minute = 0;
|
||||
m_LastUseTime.Second = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_LastUseTime.Year = sysTime.wYear;
|
||||
m_LastUseTime.Month = sysTime.wMonth;
|
||||
m_LastUseTime.Day = sysTime.wDay;
|
||||
m_LastUseTime.Hour = sysTime.wHour;
|
||||
m_LastUseTime.Minute = sysTime.wMinute;
|
||||
m_LastUseTime.Second = sysTime.wSecond;
|
||||
}
|
||||
}
|
||||
|
||||
bool CSiegeObjectDB::IsCamp() const
|
||||
{
|
||||
switch ( m_wObjectType )
|
||||
{
|
||||
case Siege::CAMP:
|
||||
case Siege::CAMP_SHOP:
|
||||
case Siege::MINING_CAMP:
|
||||
case Siege::KARTERANT_WEAPON:
|
||||
case Siege::MERKADIA_WEAPON:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSiegeObjectDB::IsCastleObject() const
|
||||
{
|
||||
switch ( m_wObjectType )
|
||||
{
|
||||
case Siege::EMBLEM :
|
||||
case Siege::GATE :
|
||||
case Siege::BACKDOOR :
|
||||
case Siege::CASTLE_ARMS_NPC :
|
||||
case Siege::GUARD :
|
||||
case Siege::SHORT_RANGE_CASTLE_ARMS :
|
||||
case Siege::LONG_RANGE_CASTLE_ARMS :
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSiegeObjectDB::IsCastleArms() const
|
||||
{
|
||||
switch ( m_wObjectType )
|
||||
{
|
||||
case Siege::GUARD :
|
||||
case Siege::SHORT_RANGE_CASTLE_ARMS :
|
||||
case Siege::LONG_RANGE_CASTLE_ARMS :
|
||||
case Siege::CASTLE_ARMS_NPC :
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSiegeObjectDB::IsSiegeArms() const
|
||||
{
|
||||
switch ( m_wObjectType )
|
||||
{
|
||||
case Siege::SHORT_RANGE_SIEGE_ARMS :
|
||||
case Siege::LONG_RANGE_SIEGE_ARMS :
|
||||
case Siege::AIRSHIP :
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSiegeObjectDB::IsRidable() const
|
||||
{
|
||||
switch ( m_wObjectType )
|
||||
{
|
||||
case Siege::SHORT_RANGE_CASTLE_ARMS :
|
||||
case Siege::LONG_RANGE_CASTLE_ARMS :
|
||||
case Siege::SHORT_RANGE_SIEGE_ARMS :
|
||||
case Siege::LONG_RANGE_SIEGE_ARMS :
|
||||
case Siege::AIRSHIP :
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSiegeObjectDB::IsWorldWeapon() const
|
||||
{
|
||||
if (Siege::KARTERANT_WEAPON == m_wObjectType || Siege::MERKADIA_WEAPON == m_wObjectType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSiegeObjectDB::SetGID(unsigned long dwGID)
|
||||
{
|
||||
m_dwGID = dwGID;
|
||||
|
||||
// if (IsEmblem() && 0 == dwGID)
|
||||
// {
|
||||
// m_cState = Siege::COMPLETE;
|
||||
// m_cSubState = Siege::NONE;
|
||||
// }
|
||||
}
|
||||
|
||||
void CSiegeObjectDB::SetNation(unsigned char cNation)
|
||||
{
|
||||
m_cNation = cNation ;
|
||||
|
||||
if (IsEmblem() && Creature::STATELESS == cNation)
|
||||
{
|
||||
m_cState = Siege::COMPLETE;
|
||||
m_cSubState = Siege::NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void CSiegeObjectDB::SetZoneChannel(unsigned char cZone, unsigned char cChannel)
|
||||
{
|
||||
m_cZone = cZone;
|
||||
m_cChannel = cChannel;
|
||||
}
|
||||
|
||||
void CSiegeObjectDB::SetMaterialNum(unsigned char cMaterial)
|
||||
{
|
||||
m_cMaterial = cMaterial;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
#ifndef _RYL_DBAGENT_SIEGE_OBJECT_DB_H_
|
||||
#define _RYL_DBAGENT_SIEGE_OBJECT_DB_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Network/Packet/PacketStruct/CastlePacket.h>
|
||||
#include <Creature/CreatureStructure.h>
|
||||
|
||||
using namespace Siege;
|
||||
|
||||
// forward decl.
|
||||
class CDBComponent;
|
||||
|
||||
class CSiegeObjectDB
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~CSiegeObjectDB();
|
||||
|
||||
// Process 함수
|
||||
virtual Siege::eReturn Process() { return Siege::RET_OK; }
|
||||
|
||||
// Cmd 처리 가상 함수
|
||||
virtual bool CancelBuild() { return false; }
|
||||
virtual bool Cancel() { return false; }
|
||||
virtual bool Build(unsigned short wType, unsigned char cDevelopTime, unsigned long dwDevelopGold = 0, unsigned long dwOwnerID = 0) { return false; }
|
||||
virtual bool Upgrade(unsigned char cUpgradeTime, unsigned long dwUpgradeGold = 0, unsigned char cUpgradeType = Siege::NO_JEWEL) { return false; }
|
||||
virtual bool Repair(unsigned long dwRepairHP, unsigned long dwRepairGold = 0) { return false; }
|
||||
virtual bool Restore(unsigned char cRestoreTime, unsigned long dwRestoreGold = 0) { return false; }
|
||||
virtual bool Destroy(unsigned long dwEnemyNation = 0, bool bDeductFame = false) { return false; }
|
||||
virtual bool ChangeType(unsigned short wType) { return false; }
|
||||
|
||||
virtual void UpdateRewardFame() { }
|
||||
|
||||
virtual void UpdateLastUseTime(bool bInit=false);
|
||||
virtual void UpdateHP(unsigned long dwNowHP) { m_dwHP = dwNowHP; }
|
||||
virtual bool ToStartKit() { return false; }
|
||||
|
||||
// To GameServer
|
||||
void SendCampCmd(unsigned char cSubCmd, unsigned long dwValue1=0, unsigned long dwValue2=0);
|
||||
void SendCastleCmd(unsigned long dwValue, unsigned char cSubCmd);
|
||||
void SendSiegeArmsCmd(unsigned long dwValue, unsigned char cSubCmd);
|
||||
|
||||
// Get / Set 함수
|
||||
bool IsEmblem() const { return (Siege::EMBLEM == m_wObjectType); }
|
||||
bool IsCamp() const;
|
||||
bool IsGate() const { return (Siege::GATE == m_wObjectType); }
|
||||
bool IsGuard() const { return (Siege::GUARD == m_wObjectType); }
|
||||
bool IsCastleObject() const;
|
||||
bool IsCastleArms() const;
|
||||
bool IsSiegeArms() const;
|
||||
bool IsRidable() const;
|
||||
bool IsWorldWeapon() const;
|
||||
|
||||
unsigned long GetCID() const { return m_dwCID; }
|
||||
unsigned long GetGID() const { return m_dwGID; } // 주의!! 요새 및 월드웨폰만 가능
|
||||
unsigned long GetNation() const { return m_cNation; } // 주의!! 공성 및 수성 관련 오브젝트들만 가능
|
||||
unsigned long GetNowHP() const { return m_dwHP; }
|
||||
unsigned char GetState() const { return m_cState; }
|
||||
unsigned char GetSubState() const { return m_cSubState; }
|
||||
unsigned char GetUpgradeStep() const { return m_cUpgradeStep; }
|
||||
unsigned char GetZone() const { return m_cZone; }
|
||||
unsigned char GetChannel() const { return m_cChannel; }
|
||||
const Position& GetPosition() const { return m_Pos; }
|
||||
unsigned char GetMaterialNum() const { return m_cMaterial; }
|
||||
unsigned char GetSiegeCount() const { return m_cSiegeCount; }
|
||||
unsigned short GetObjectType() const { return m_wObjectType; }
|
||||
unsigned char GetDevelopTime() const { return m_cDevelopTime; }
|
||||
unsigned char GetUpgradeTime() const { return m_cUpgradeTime; }
|
||||
unsigned char GetRepairTime() const { return m_cRepairTime; }
|
||||
unsigned char GetChangeTime() const { return m_cChangeTime; }
|
||||
|
||||
const TIME& GetTimeValue() const { return m_TimeValue; }
|
||||
const TIME& GetLastUseTime() const { return m_LastUseTime; }
|
||||
|
||||
unsigned long GetCastleID() const { return m_dwCampOrCastleID; } // 성 상징물, 성문/뒷문, 수성 병기
|
||||
unsigned long GetCampID() const { return m_dwCampOrCastleID; } // 길드 요새
|
||||
unsigned long GetOwnerID() const { return m_dwOwnerID; } // 근거리/원거리 수성병기, 근거리/원거리 공성 병기, 비공정
|
||||
|
||||
void SetGID(unsigned long dwGID); // 주의!! 요새 및 월드웨폰만 가능
|
||||
void SetNation(unsigned char cNation); // 주의!! 공성 및 수성관련 오브젝트들만 가능
|
||||
void SetZoneChannel(unsigned char cZone, unsigned char cChannel);
|
||||
virtual void SetMaterialNum(unsigned char cMaterial);
|
||||
void SetSiegeCount(unsigned char cSiegeCount) { m_cSiegeCount = cSiegeCount; }
|
||||
|
||||
protected:
|
||||
|
||||
CSiegeObjectDB(CDBComponent& DBComponent, const CastleObjectInfoDB& CastleObject);
|
||||
CSiegeObjectDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo);
|
||||
|
||||
CSiegeObjectDB(CDBComponent& DBComponent, unsigned long dwCampID,
|
||||
unsigned long dwGID, unsigned char cZone, unsigned char cChannel, Position Pos);
|
||||
|
||||
CSiegeObjectDB(CDBComponent& DBComponent, unsigned long dwOwnerID,
|
||||
unsigned char cNation, unsigned short wObjectType, unsigned char cUpgradeStep,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos);
|
||||
|
||||
void SetCID(unsigned long dwCID) { m_dwCID = dwCID; }
|
||||
|
||||
unsigned long m_dwCID; // CID : SIEGE_OBJECT_BIT 이 설정된 CreatureID
|
||||
unsigned long m_dwCampOrCastleID; // CampID : 진지의 길드 요새 및 월드 웨폰
|
||||
// CastleID : 성 상징물, 성문, 뒷문, 가드, 근거리/원거리 수성병기의 성ID
|
||||
unsigned long m_dwOwnerID; // CID : 근거리/원거리 공성병기, 비공정의 주인, 근거리/원거리 수성병기
|
||||
|
||||
unsigned long m_dwGID; // GID : 길드 요새 소유 길드의 길드ID (요새 및 월드웨폰만 사용함)
|
||||
unsigned char m_cNation; // 성 상징물, 성문, 뒷문, 가드, 근거리/원거리 수성병기의 국가 (공성전 오브젝트들만 사용)
|
||||
unsigned long m_dwHP; // HP
|
||||
|
||||
unsigned short m_wObjectType; // 공성 관련 오브젝트 타입
|
||||
unsigned char m_cState; // 현재 오브젝트의 상태
|
||||
unsigned char m_cSubState; // 현재 오브젝트의 서브 상태 (Use EMBLEM & GATE)
|
||||
unsigned char m_cUpgradeStep; // 현재 오브젝트의 업그레이드 단계
|
||||
unsigned char m_cUpgradeType; // 성 상징물의 업그레이드 타입 (Only EMBLEM)
|
||||
|
||||
unsigned char m_cDevelopTime; // 개발(복구)에 걸리는 시간 (분)
|
||||
unsigned char m_cUpgradeTime; // 업그레이드에 걸리는 시간 (분)
|
||||
unsigned char m_cRepairTime; // 수리에 걸리는 시간 (초)
|
||||
unsigned char m_cChangeTime; // 타입 변형에 걸리는 시간 (분)
|
||||
|
||||
unsigned char m_cZone; // 존 (Only CAMP)
|
||||
unsigned char m_cChannel; // 채널 (Only CAMP)
|
||||
TIME m_TimeValue; // 각종 시간 저장 변수
|
||||
TIME m_LastUseTime; // 진지의 마지막 사용 시간 (Use CAMP & SIEGE_ARMS & CASTLE_ARMS)
|
||||
Position m_Pos; // 위치
|
||||
unsigned char m_cMaterial; // 공성용 자재 갯수
|
||||
unsigned char m_cSiegeCount; // 공성 지난 횟수
|
||||
|
||||
unsigned long m_dwRepairHP; // 수리 완료시 회복할 HP 양
|
||||
float m_fDefaultDir; // 수성 병기의 기본 방향
|
||||
|
||||
CDBComponent& m_DBComponent; // DB
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif // _RYL_DBAGENT_SIEGE_OBJECT_DB_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,126 @@
|
||||
#ifndef _SIEGE_OBJECT_MANAGER_H_
|
||||
#define _SIEGE_OBJECT_MANAGER_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <boost/pool/pool.hpp>
|
||||
#include <boost/pool/pool_alloc.hpp>
|
||||
#include <Creature/Siege/SiegeConstants.h>
|
||||
#include <Network/Packet/PacketStruct/CastlePacket.h>
|
||||
|
||||
// 전방 참조
|
||||
class CSendStream;
|
||||
class CDBComponent;
|
||||
class CSiegeObjectDB;
|
||||
class CCampDB;
|
||||
|
||||
class CSiegeObjectDBMgr
|
||||
{
|
||||
public:
|
||||
|
||||
static CSiegeObjectDBMgr& GetInstance();
|
||||
|
||||
// 타입 정의
|
||||
typedef std::map<unsigned long, CSiegeObjectDB*> SiegeObjectMap; // < CID, CSiegeObjectDB* >
|
||||
typedef std::map<unsigned long, CCampDB*> CampMap; // < CampID, CCampDB* >
|
||||
|
||||
bool Initialize(CDBComponent& DBComponent);
|
||||
void Process();
|
||||
void UpdateSiegeCount(); // 공성 시간 지난 횟수 증가 및 업데이트
|
||||
|
||||
void UpdateRewardFame(); // 명성을 보상한다.
|
||||
|
||||
// 월드 웨폰 파괴정보의 공성 시간 지난 횟수 증가
|
||||
void DecreaseWeaponRemainSiegeTime(); // 공성 시간이 끝나는 시점에 호출된다.
|
||||
|
||||
// DB 에서 읽어들인 값으로 생성하는 함수
|
||||
CSiegeObjectDB* CreateCastleObject(CastleObjectInfoDB& CastleObject);
|
||||
CSiegeObjectDB* CreateCamp(CampInfoDB& CampInfo, unsigned long dwCID=0);
|
||||
CSiegeObjectDB* CreateMiningCamp(CampInfoDB& CampInfo, unsigned long dwCID=0);
|
||||
CSiegeObjectDB* CreateCampShop(CampInfoDB& CampInfo, unsigned long dwCID=0);
|
||||
CSiegeObjectDB* CreateWorldWeapon(CampInfoDB& CampInfo, unsigned long dwCID=0);
|
||||
|
||||
// 게임서버의 요청으로 생성해서 DB 에 추가하는 함수
|
||||
CSiegeObjectDB* CreateCamp(unsigned long dwGID, unsigned char cZone, unsigned char cChannel, POS Pos);
|
||||
CSiegeObjectDB* CreateWorldWeapon(unsigned long dwGID, unsigned short wObjectType, unsigned char cZone, unsigned char cChannel, POS Pos);
|
||||
CSiegeObjectDB* CreateSiegeArms(unsigned long dwOwnerID, unsigned char cNation, unsigned char cZone, unsigned char cChannel,
|
||||
unsigned short wObjectType, unsigned char cUpgradeStep, POS Pos);
|
||||
|
||||
// Get 함수
|
||||
CCampDB* GetCamp(unsigned long dwCampID);
|
||||
CSiegeObjectDB* GetSiegeObject(unsigned long dwObjectID);
|
||||
unsigned char GetWorldWeaponNation(unsigned char cZone, unsigned char cChannel) const; // 월드 웨폰 소유 국가 얻기
|
||||
void DeleteWorldWeaponNation(unsigned char cZone, unsigned char cChannel); // 월드 웨폰 소유 국가 초기화
|
||||
void UpdateWorldWeaponInfo(unsigned char cZone, unsigned char cChannel, unsigned char cOwenrNation,
|
||||
unsigned char cDestroyedWeaponNation, unsigned char cRemainSiegeTime);
|
||||
bool HasCampByGID(unsigned long dwGID, unsigned long dwExceptCampID=0);
|
||||
|
||||
// 객체 삭제 함수
|
||||
bool DeleteSiegeObject(unsigned long dwCID);
|
||||
bool DeleteSiegeObject(CSiegeObjectDB* lpObject);
|
||||
CampMap::iterator DeleteCamp(unsigned long dwCampID);
|
||||
|
||||
int DestroyCamp(unsigned long dwGID); // 해당 길드의 진지를 모두 파괴, 파괴한 진지수를 리턴
|
||||
void DestroySiegeArms(unsigned long dwOnwerCID); // 길드 탈퇴시 해당 캐릭터의 공성병기를 아이템으로 돌려주기
|
||||
void DestoryAllSiegeArms(); // 공성 시간이 끝났을때 아이템으로 돌려주기
|
||||
|
||||
// 요새 객체 변형 함수
|
||||
bool ChangeCampType(unsigned long dwCampID, unsigned short wChangeType);
|
||||
|
||||
// GameServer 로의 Send 함수
|
||||
void SendWorldWeaponInfo(CSendStream& SendStream, unsigned char cZone, unsigned char cChannel);
|
||||
void SendCampInfo(CSendStream& SendStream, unsigned char cZone, unsigned char cChannel);
|
||||
void SendSiegeArmsInfo(CSendStream& SendStream, unsigned char cZone, unsigned char cChannel);
|
||||
void SendProcessMining(unsigned long dwProcessType);
|
||||
|
||||
bool SerializeOutCastleObject(CSiegeObjectDB* lpObject_In, char* lpBuffer_Out, unsigned short& wBufferSize_Out);
|
||||
|
||||
private:
|
||||
|
||||
CSiegeObjectDBMgr();
|
||||
~CSiegeObjectDBMgr();
|
||||
|
||||
// CSiegeObjectDBMgr 내에서만 사용하는 타입 정의
|
||||
typedef struct _WorldWeaponInfo
|
||||
{
|
||||
unsigned char m_cWorldWeaponNation; // 현재 있는 월드 웨폰의 소유 국가
|
||||
unsigned char m_cKarRemainSiegeTime; // 카르테란트 월드 웨폰이 부서지고난 후 지나야할 공성시간
|
||||
unsigned char m_cMerRemainSiegeTime; // 메르카디아 월드 웨폰이 부서지고난 후 지나야할 공성시간
|
||||
} WorldWeaponInfo;
|
||||
|
||||
typedef std::map<unsigned long, WorldWeaponInfo> WorldWeaponInfoMap; // < dwZoneChannel, WorldWeaponInfo >
|
||||
// dwZoneChannel : Zone(16bit) | Channel(16bit)
|
||||
bool ReadCastleObjectInfoDB();
|
||||
bool ReadWorldWeaponInfoDB();
|
||||
bool ReadCampInfoDB();
|
||||
|
||||
unsigned long GetBlankIndex();
|
||||
|
||||
void CreateDummyCamp();
|
||||
|
||||
// 실제로 객체를 생성하는 함수
|
||||
CSiegeObjectDB* CreateCastleObjectDB(const CastleObjectInfoDB& CastleObject);
|
||||
CSiegeObjectDB* CreateCampDB(const CampInfoDB& CampInfo);
|
||||
CSiegeObjectDB* CreateMiningCampDB(const CampInfoDB& CampInfo);
|
||||
CSiegeObjectDB* CreateCampShopDB(const CampInfoDB& CampInfo);
|
||||
CSiegeObjectDB* CreateWorldWeaponDB(const CampInfoDB& CampInfo);
|
||||
|
||||
CSiegeObjectDB* CreateCampDB(unsigned long dwCampID, unsigned long dwGID,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos);
|
||||
CSiegeObjectDB* CreateWorldWeaponDB(unsigned long dwCampID, unsigned long dwGID, unsigned short wObjectType,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos);
|
||||
CSiegeObjectDB* CreateSiegeArmsDB(unsigned long dwOwnerID,
|
||||
unsigned char cNation, unsigned short wObjectType, unsigned char cUpgradeStep,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos);
|
||||
|
||||
void DeleteSiegeObjectDB(CSiegeObjectDB* lpSiegeObjectDB);
|
||||
|
||||
SiegeObjectMap m_SiegeObjectMap;
|
||||
CampMap m_CampMap;
|
||||
WorldWeaponInfoMap m_WorldWeaponInfoMap;
|
||||
CDBComponent* m_lpDBComponent;
|
||||
};
|
||||
|
||||
#endif // _SIEGE_OBJECT_MANAGER_H_
|
||||
@@ -0,0 +1,183 @@
|
||||
#include "stdafx.h"
|
||||
#include "WorldWeaponDB.h"
|
||||
#include "SiegeObjectDBMgr.h"
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Castle/CastleDBComponent.h>
|
||||
|
||||
#include <Community/Guild/GuildDB.h>
|
||||
#include <Community/Guild/GuildDBMgr.h>
|
||||
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
|
||||
CWorldWeaponDB::CWorldWeaponDB(CDBComponent& DBComponent, unsigned long dwCampID, unsigned long dwGID, unsigned short wObjectType,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos)
|
||||
: CCampDB(DBComponent, dwCampID, dwGID, cZone, cChannel, Pos), m_iFireX(0), m_iFireZ(0)
|
||||
{
|
||||
m_wObjectType = wObjectType;
|
||||
}
|
||||
|
||||
CWorldWeaponDB::CWorldWeaponDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo)
|
||||
: CCampDB(DBComponent, CampInfo), m_iFireX(0), m_iFireZ(0)
|
||||
{
|
||||
}
|
||||
|
||||
CWorldWeaponDB::~CWorldWeaponDB()
|
||||
{
|
||||
}
|
||||
|
||||
bool CWorldWeaponDB::UpdateWeaponState(unsigned char cWeaponState, unsigned long dwValue1, unsigned long dwValue2)
|
||||
{
|
||||
if (Siege::WEAPON_CHARGE != cWeaponState && Siege::WEAPON_FIRE != cWeaponState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (cWeaponState)
|
||||
{
|
||||
case Siege::WEAPON_CHARGE: m_cChargeTime = static_cast<unsigned char>(dwValue1); break;
|
||||
case Siege::WEAPON_FIRE: m_iFireX = static_cast<int>(dwValue1); m_iFireZ = static_cast<int>(dwValue2); break;
|
||||
}
|
||||
|
||||
m_cSubState = cWeaponState;
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
m_TimeValue.Year = sysTime.wYear;
|
||||
m_TimeValue.Month = sysTime.wMonth;
|
||||
m_TimeValue.Day = sysTime.wDay;
|
||||
m_TimeValue.Hour = sysTime.wHour;
|
||||
m_TimeValue.Minute = sysTime.wMinute;
|
||||
m_TimeValue.Second = sysTime.wSecond;
|
||||
|
||||
DBComponent::CastleDB::UpdateCampSubState(m_DBComponent, GetCampID(), m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWorldWeaponDB::Fire()
|
||||
{
|
||||
// 월드 웨폰 파괴 정보 DB 에 추가한다.
|
||||
if (Siege::KARTERANT_WEAPON == m_wObjectType)
|
||||
{
|
||||
DBComponent::CastleDB::InsertWorldWeaponInfo(m_DBComponent, GetZone(), GetChannel(), Creature::KARTERANT);
|
||||
|
||||
// 월드 웨폰 정보 갱신
|
||||
CSiegeObjectDBMgr::GetInstance().UpdateWorldWeaponInfo(GetZone(), GetChannel(), Creature::STATELESS,
|
||||
Creature::KARTERANT, Siege::WEAPON_REBUILD_SIEGE_TIME_COUNT);
|
||||
}
|
||||
else if (Siege::MERKADIA_WEAPON == m_wObjectType)
|
||||
{
|
||||
DBComponent::CastleDB::InsertWorldWeaponInfo(m_DBComponent, GetZone(), GetChannel(), Creature::MERKADIA);
|
||||
|
||||
// 월드 웨폰 정보 갱신
|
||||
CSiegeObjectDBMgr::GetInstance().UpdateWorldWeaponInfo(GetZone(), GetChannel(), Creature::STATELESS,
|
||||
Creature::MERKADIA, Siege::WEAPON_REBUILD_SIEGE_TIME_COUNT);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Siege::eReturn CWorldWeaponDB::Process()
|
||||
{
|
||||
CTime nowTime = CTime::GetCurrentTime();
|
||||
CTimeSpan timeSpan(0);
|
||||
|
||||
// 구축 완료 상태에서 (장전)
|
||||
if (Siege::COMPLETE == m_cState && Siege::WEAPON_CHARGE == m_cSubState)
|
||||
{
|
||||
if (0 != m_TimeValue.Year)
|
||||
{
|
||||
CTime chargeTime(m_TimeValue.Year, m_TimeValue.Month, m_TimeValue.Day,
|
||||
m_TimeValue.Hour, m_TimeValue.Minute, m_TimeValue.Second);
|
||||
|
||||
timeSpan = nowTime - chargeTime;
|
||||
if (timeSpan.GetTotalMinutes() >= m_cChargeTime)
|
||||
{
|
||||
// 월드 웨폰 장전 완료
|
||||
m_cSubState = Siege::WEAPON_READY;
|
||||
|
||||
// DB에 상태 업데이트
|
||||
SYSTEMTIME sysTime;
|
||||
::memset(&sysTime, 0, sizeof(SYSTEMTIME));
|
||||
::memset(&m_TimeValue, 0, sizeof(TIME));
|
||||
|
||||
DBComponent::CastleDB::UpdateCampSubState(m_DBComponent, GetCampID(), m_cSubState);
|
||||
DBComponent::CastleDB::UpdateCampTime(m_DBComponent, GetCampID(), Siege::TYPE_REMAIN_TIME, sysTime);
|
||||
|
||||
// 게임 서버에게 결과 전송..
|
||||
SendCampCmd(PktCampCmd::WORLDWEAPON_CHARGE_COMPLETE);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 메세지 전송
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
|
||||
// 월드 웨폰 무기 장전 완료
|
||||
// 메세지 종류, 존 번호, 월드 웨폰 국가, 공지
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_WEAPON_CHARGE_END;
|
||||
pktCampMessage.m_dwCampID = GetCampID();
|
||||
pktCampMessage.m_dwGID = m_dwGID;
|
||||
pktCampMessage.m_cZone = m_cZone;
|
||||
pktCampMessage.m_bNotify = true;
|
||||
|
||||
Guild::CGuildDB* lpGuild = static_cast<Guild::CGuildDB *>(
|
||||
Guild::CGuildDBMgr::GetInstance().GetGuild(m_dwGID));
|
||||
|
||||
if (lpGuild)
|
||||
{
|
||||
pktCampMessage.m_cNation = lpGuild->GetNation();
|
||||
}
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CCampDB::Process();
|
||||
}
|
||||
|
||||
bool CWorldWeaponDB::Cancel()
|
||||
{
|
||||
// 월드 웨폰이 없어졌으므로, 월드 웨폰 소유국가 정보 갱신
|
||||
CSiegeObjectDBMgr::GetInstance().DeleteWorldWeaponNation(GetZone(), GetChannel());
|
||||
|
||||
return CCampDB::Cancel();
|
||||
}
|
||||
|
||||
bool CWorldWeaponDB::Destroy(unsigned long dwEnemyGID, bool bDeductFame)
|
||||
{
|
||||
// 월드 웨폰 파괴 정보 DB 에 추가한다.
|
||||
if (Siege::KARTERANT_WEAPON == m_wObjectType)
|
||||
{
|
||||
DBComponent::CastleDB::InsertWorldWeaponInfo(m_DBComponent, GetZone(), GetChannel(), Creature::KARTERANT);
|
||||
|
||||
// 월드 웨폰 정보 갱신
|
||||
CSiegeObjectDBMgr::GetInstance().UpdateWorldWeaponInfo(GetZone(), GetChannel(), Creature::STATELESS,
|
||||
Creature::KARTERANT, Siege::WEAPON_REBUILD_SIEGE_TIME_COUNT);
|
||||
}
|
||||
else if (Siege::MERKADIA_WEAPON == m_wObjectType)
|
||||
{
|
||||
DBComponent::CastleDB::InsertWorldWeaponInfo(m_DBComponent, GetZone(), GetChannel(), Creature::MERKADIA);
|
||||
|
||||
// 월드 웨폰 정보 갱신
|
||||
CSiegeObjectDBMgr::GetInstance().UpdateWorldWeaponInfo(GetZone(), GetChannel(), Creature::STATELESS,
|
||||
Creature::MERKADIA, Siege::WEAPON_REBUILD_SIEGE_TIME_COUNT);
|
||||
}
|
||||
|
||||
return CCampDB::Destroy(dwEnemyGID, bDeductFame);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// File Name: WorldWeaponDB.h
|
||||
//
|
||||
// Programmer: Zergra( Park Jongtae ) in GamaSoft corp.
|
||||
//
|
||||
// File Desciption: 월드 웨폰 DB
|
||||
//
|
||||
// Date: 2004. 12. 14. (화)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#ifndef _RYL_DBAGENT_WORLD_WEAPON_DB_H_
|
||||
#define _RYL_DBAGENT_WORLD_WEAPON_DB_H_
|
||||
|
||||
#pragma once
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#include "CampDB.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Classes
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// class CWorldWeaponDB
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class CWorldWeaponDB : public CCampDB
|
||||
{
|
||||
public:
|
||||
virtual ~CWorldWeaponDB();
|
||||
|
||||
// Process 함수
|
||||
Siege::eReturn Process();
|
||||
|
||||
// Cmd 처리 가상 함수
|
||||
bool Cancel(); // 구축 취소 완료
|
||||
bool Destroy(unsigned long dwEnemyGID = 0, bool bDeductFame = false);
|
||||
|
||||
bool UpdateWeaponState(unsigned char cWeaponState, unsigned long dwValue1, unsigned long dwValue2);
|
||||
bool Fire();
|
||||
|
||||
protected:
|
||||
|
||||
// Client 의 요청으로 새로운 월드 웨폰 생성
|
||||
CWorldWeaponDB(CDBComponent& DBComponent, unsigned long dwCampID, unsigned long dwGID, unsigned short wObjectType,
|
||||
unsigned char cZone, unsigned char cChannel, Position Pos);
|
||||
|
||||
// DB 에서 읽어온 값으로 월드 웨폰 객체 생성
|
||||
CWorldWeaponDB(CDBComponent& DBComponent, const CampInfoDB& CampInfo);
|
||||
|
||||
unsigned char m_cChargeTime;
|
||||
int m_iFireX, m_iFireZ;
|
||||
|
||||
friend class CSiegeObjectDBMgr;
|
||||
};
|
||||
|
||||
#endif //_RYL_DBAGENT_WORLD_WEAPON_DB_H_
|
||||
@@ -0,0 +1,265 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "StatueDBMgr.h"
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <Log/ServerLog.h>
|
||||
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketStruct/CastlePacket.h>
|
||||
#include <Network/Stream/SendStream.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <Creature/Monster/MonsterStructure.h>
|
||||
|
||||
CStatueDBMgr& CStatueDBMgr::GetInstance()
|
||||
{
|
||||
static CStatueDBMgr ms_this;
|
||||
return ms_this;
|
||||
}
|
||||
|
||||
CStatueDBMgr::CStatueDBMgr()
|
||||
: m_lpDBComponent(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CStatueDBMgr::~CStatueDBMgr()
|
||||
{
|
||||
ClearStatueMap();
|
||||
}
|
||||
|
||||
bool CStatueDBMgr::Initialize(CDBComponent& DBComponent)
|
||||
{
|
||||
ClearStatueMap();
|
||||
m_lpDBComponent = &DBComponent;
|
||||
|
||||
// 컨텐츠 : 다크 카나번 국가 전쟁 or 신규존
|
||||
if (true == CServerSetup::GetInstance().UseContents(GameRYL::STONE_BATTLE))
|
||||
// || true == CServerSetup::GetInstance().UseContents(GameRYL::NEWZONE_ZONE9))
|
||||
{
|
||||
const int MAX_ROWS = 1000;
|
||||
int nGetRows = 0;
|
||||
|
||||
char szBuffer[CDBComponent::QUERY_BUFFER_LEN];
|
||||
_snprintf(szBuffer, CDBComponent::QUERY_BUFFER_LEN - 1,
|
||||
"SELECT "
|
||||
"TblStatueInfo.nIndex, "
|
||||
"TblStatueInfo.tnChannel, "
|
||||
"TblStatueInfo.snKID, "
|
||||
"TblStatueInfo.nLostHP FROM TblStatueInfo ");
|
||||
|
||||
szBuffer[CDBComponent::QUERY_BUFFER_LEN - 1] = 0;
|
||||
if (0 == m_lpDBComponent || !m_lpDBComponent->ExecuteQuery(szBuffer))
|
||||
{
|
||||
ERRLOG0(g_Log, "Statue DB 얻어오기 실패");
|
||||
return false;
|
||||
}
|
||||
|
||||
StatueInfoDB* statueInfo = new StatueInfoDB[MAX_ROWS];
|
||||
memset(statueInfo, 0, sizeof(StatueInfoDB) * MAX_ROWS);
|
||||
|
||||
while (m_lpDBComponent->GetData((void**)statueInfo, sizeof(StatueInfoDB), MAX_ROWS, &nGetRows))
|
||||
{
|
||||
if (0 == nGetRows) { break; }
|
||||
|
||||
for (StatueInfoDB* lpStatueInfo = statueInfo; nGetRows > 0; --nGetRows, ++lpStatueInfo)
|
||||
{
|
||||
StatueInfoDB* lpStatue = CreateStatue(*lpStatueInfo);
|
||||
if (NULL != lpStatue)
|
||||
{
|
||||
unsigned long dwKey = CalcKeyValue(lpStatue->m_dwIndex, lpStatue->m_cChannel);
|
||||
if (!m_StatueMap.insert(std::make_pair(dwKey, lpStatue)).second)
|
||||
{
|
||||
ERRLOG2(g_Log, "Statue DB에 중복된 키값의 석상이 존재합니다. Index: %d / Channel: %d",
|
||||
lpStatue->m_dwIndex, lpStatue->m_cChannel);
|
||||
|
||||
memset(statueInfo, 0, sizeof(StatueInfoDB) * MAX_ROWS);
|
||||
delete [] statueInfo;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRLOG2(g_Log, "Statue DB 값으로 석상정보를 생성하는데 실패했습니다. Index: %d / Channel: %d",
|
||||
lpStatueInfo->m_dwIndex, lpStatueInfo->m_cChannel);
|
||||
|
||||
memset(statueInfo, 0, sizeof(StatueInfoDB) * MAX_ROWS);
|
||||
delete [] statueInfo;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
memset(statueInfo, 0, sizeof(StatueInfoDB) * MAX_ROWS);
|
||||
}
|
||||
|
||||
delete [] statueInfo;
|
||||
|
||||
SERLOG0(g_Log, "석상 정보 Initalize 성공.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned long CStatueDBMgr::CalcKeyValue(unsigned long dwIndex, unsigned char cChannel) const
|
||||
{
|
||||
return static_cast<unsigned long>( (dwIndex << 16) | (cChannel) );
|
||||
}
|
||||
|
||||
bool CStatueDBMgr::UpdateKID(unsigned long dwIndex, unsigned char cChannel, unsigned short wNewKID)
|
||||
{
|
||||
unsigned long dwKey = CalcKeyValue(dwIndex, cChannel);
|
||||
StatueMap::iterator itr = m_StatueMap.find(dwKey);
|
||||
if (itr == m_StatueMap.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
char szBuffer[CDBComponent::QUERY_BUFFER_LEN];
|
||||
_snprintf(szBuffer, CDBComponent::QUERY_BUFFER_LEN - 1,
|
||||
"UPDATE TblStatueInfo SET snKID=%d WHERE nIndex=%d and tnChannel=%d",
|
||||
wNewKID, dwIndex, cChannel);
|
||||
szBuffer[CDBComponent::QUERY_BUFFER_LEN - 1] = 0;
|
||||
|
||||
if (0 == m_lpDBComponent || !m_lpDBComponent->ExecuteQuery(szBuffer))
|
||||
{
|
||||
ERRLOG0(g_Log, "Statue KID DB Update 실패");
|
||||
return false;
|
||||
}
|
||||
|
||||
StatueInfoDB* lpStatue = itr->second;
|
||||
if (0 != lpStatue)
|
||||
{
|
||||
lpStatue->m_wKID = wNewKID;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRLOG0(g_Log, "Statue KID Update 실패");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStatueDBMgr::UpdateLostHP(unsigned long dwIndex, unsigned char cChannel, unsigned long dwLostHP)
|
||||
{
|
||||
unsigned long dwKey = CalcKeyValue(dwIndex, cChannel);
|
||||
StatueMap::iterator itr = m_StatueMap.find(dwKey);
|
||||
if (itr == m_StatueMap.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
char szBuffer[CDBComponent::QUERY_BUFFER_LEN];
|
||||
_snprintf(szBuffer, CDBComponent::QUERY_BUFFER_LEN - 1,
|
||||
"UPDATE TblStatueInfo SET nLostHP=%d WHERE nIndex=%d and tnChannel=%d",
|
||||
dwLostHP, dwIndex, cChannel);
|
||||
szBuffer[CDBComponent::QUERY_BUFFER_LEN - 1] = 0;
|
||||
|
||||
if (0 == m_lpDBComponent || !m_lpDBComponent->ExecuteQuery(szBuffer))
|
||||
{
|
||||
ERRLOG0(g_Log, "Statue LostHP DB Update 실패");
|
||||
return false;
|
||||
}
|
||||
|
||||
StatueInfoDB* lpStatue = itr->second;
|
||||
if (0 != lpStatue)
|
||||
{
|
||||
lpStatue->m_dwLostHP = dwLostHP;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRLOG0(g_Log, "Statue LostHP DB Update 실패");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CStatueDBMgr::SendStatueInfo(CSendStream& SendStream, unsigned char cChannel)
|
||||
{
|
||||
const unsigned int MAX_STATUE_INFO = sizeof(PktStatueCmd) + sizeof(StatueInfo) * 100;
|
||||
char szBuffer[MAX_STATUE_INFO];
|
||||
PktStatueCmd* lpPktStatueCmd = reinterpret_cast<PktStatueCmd*>(szBuffer);
|
||||
StatueInfo* lpStatueInfo = reinterpret_cast<StatueInfo*>(lpPktStatueCmd + 1);
|
||||
|
||||
unsigned short wSize = 0;
|
||||
unsigned short wStatueNum = 0;
|
||||
|
||||
StatueMap::const_iterator itr = m_StatueMap.begin();
|
||||
StatueMap::const_iterator end = m_StatueMap.end();
|
||||
|
||||
while (itr != end)
|
||||
{
|
||||
const StatueInfoDB* lpStatue = itr->second;
|
||||
if (0 != lpStatue)
|
||||
{
|
||||
if (lpStatue->m_cChannel == cChannel)
|
||||
{
|
||||
lpStatueInfo->m_dwIndex = lpStatue->m_dwIndex;
|
||||
lpStatueInfo->m_wKID = lpStatue->m_wKID;
|
||||
lpStatueInfo->m_dwLostHP = lpStatue->m_dwLostHP;
|
||||
|
||||
++lpStatueInfo;
|
||||
++wStatueNum;
|
||||
wSize += sizeof(StatueInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRLOG0( g_Log, "Null StatueInfo 포인터가 포함되어 있습니다." ) ;
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
|
||||
if (wStatueNum > 0)
|
||||
{
|
||||
lpPktStatueCmd->m_wSubCmd = PktStatueCmd::CMD_INFO;
|
||||
lpPktStatueCmd->m_dwValue = wStatueNum;
|
||||
lpPktStatueCmd->m_wSize = wSize;
|
||||
|
||||
SendStream.WrapCompress(szBuffer,
|
||||
static_cast<unsigned short>(sizeof(PktStatueCmd) + wSize), CmdStatueCmd, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
StatueInfoDB* CStatueDBMgr::CreateStatue( const StatueInfoDB& statueInfo )
|
||||
{
|
||||
StatueInfoDB* lpStatue = new StatueInfoDB;
|
||||
if (0 != lpStatue)
|
||||
{
|
||||
lpStatue->m_dwIndex = statueInfo.m_dwIndex;
|
||||
lpStatue->m_cChannel = statueInfo.m_cChannel;
|
||||
lpStatue->m_wKID = statueInfo.m_wKID;
|
||||
lpStatue->m_dwLostHP = statueInfo.m_dwLostHP;
|
||||
}
|
||||
|
||||
return lpStatue;
|
||||
}
|
||||
|
||||
void CStatueDBMgr::ClearStatueMap()
|
||||
{
|
||||
if (!m_StatueMap.empty())
|
||||
{
|
||||
StatueMap::iterator itr = m_StatueMap.begin();
|
||||
StatueMap::iterator end = m_StatueMap.end();
|
||||
|
||||
while (itr != end)
|
||||
{
|
||||
if (itr->second)
|
||||
{
|
||||
delete itr->second;
|
||||
itr->second = NULL;
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
|
||||
m_StatueMap.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef _RYL_DBAGENT_STATUE_DB_MANAGER_H_
|
||||
#define _RYL_DBAGENT_STATUE_DB_MANAGER_H_
|
||||
|
||||
// 국가전 석상 DB 정보를 가지고 있는 객체
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <Network/Packet/PacketStruct/CastlePacket.h>
|
||||
|
||||
// 전방 참조
|
||||
class CDBComponent;
|
||||
class CSendStream;
|
||||
|
||||
class CStatueDBMgr
|
||||
{
|
||||
public:
|
||||
static CStatueDBMgr& GetInstance();
|
||||
|
||||
// <Key, StatueInfo*> : Key = (Index << 16) | (Channel)
|
||||
typedef std::map<unsigned long, StatueInfoDB*> StatueMap;
|
||||
|
||||
|
||||
bool Initialize(CDBComponent& DBComponent);
|
||||
|
||||
unsigned long CalcKeyValue(unsigned long dwIndex, unsigned char cChannel) const;
|
||||
|
||||
bool UpdateKID(unsigned long dwIndex, unsigned char cChannel, unsigned short wNewKID);
|
||||
bool UpdateLostHP(unsigned long dwIndex, unsigned char cChannel, unsigned long dwLostHP);
|
||||
|
||||
// Send to gameserver
|
||||
void SendStatueInfo(CSendStream& SendStream, unsigned char cChannel);
|
||||
|
||||
private:
|
||||
|
||||
CStatueDBMgr();
|
||||
~CStatueDBMgr();
|
||||
|
||||
StatueInfoDB* CreateStatue( const StatueInfoDB& statueInfo ) ;
|
||||
void ClearStatueMap() ;
|
||||
|
||||
CDBComponent* m_lpDBComponent;
|
||||
StatueMap m_StatueMap;
|
||||
};
|
||||
|
||||
#endif // _RYL_DBAGENT_STATUE_DB_MANAGER_H_
|
||||
Reference in New Issue
Block a user