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:
1431
Server/RylServerProject/RylDBAgentServer/Community/Guild/GuildDB.cpp
Normal file
1431
Server/RylServerProject/RylDBAgentServer/Community/Guild/GuildDB.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
|
||||
#ifndef _RYL_DBAGENT_GUILDDB_H_
|
||||
#define _RYL_DBAGENT_GUILDDB_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Network/Packet/PacketStruct/GuildPacket.h>
|
||||
#include <Community/Guild/Guild.h>
|
||||
|
||||
|
||||
// forward decl.
|
||||
class CDBComponent;
|
||||
class CSendStream;
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
class CGuildDB : public CGuild
|
||||
{
|
||||
private:
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ƿ<EFBFBD><C6BF> <20>̿<EFBFBD><CCBF>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> public)
|
||||
CGuildDB(CDBComponent& DBComponent);
|
||||
CGuildDB(CDBComponent& DBComponent, unsigned long dwGID, unsigned char cNation, char* szName);
|
||||
CGuildDB(CDBComponent& DBComponent, GuildInfoDB& guildInfo);
|
||||
|
||||
friend class CGuildDBMgr;
|
||||
|
||||
CDBComponent& m_DBComponent;
|
||||
|
||||
public:
|
||||
|
||||
~CGuildDB(void);
|
||||
|
||||
bool SetMark(char* szMark);
|
||||
bool SetLevel(unsigned char cLevel);
|
||||
// bool SetInclination(unsigned char cInclination);
|
||||
bool SetRight(GuildRight guildRight);
|
||||
bool SetTitle(unsigned long dwCID, unsigned char cTitle);
|
||||
bool SetRelation(unsigned long dwTargetGID, unsigned char cRelationType, unsigned char cActorType=Guild::BY_MINE, unsigned char cInsert = 1);
|
||||
void DeleteRelation();
|
||||
void CancelAlertAndCounterHostility();
|
||||
void CancelAlertHostility(unsigned long dwTargetGID);
|
||||
|
||||
unsigned long ReleaseGold(unsigned long dwGold);
|
||||
unsigned long SetNewMaster(void);
|
||||
|
||||
int GetLoginedTotalMemberNum() const;
|
||||
int GetLoginedCurrentMemberNum() const;
|
||||
|
||||
void AddAllMemberFame(unsigned char cType, int nFame, Guild::CGuildDB* lpEnemyGuild = 0); // <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ġ <20><>ȭ ( <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>밡<EFBFBD><EBB0A1> )
|
||||
void AddLoginedMemberFame(unsigned char cType, int nFame, Guild::CGuildDB* lpEnemyGuild = 0); // <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ġ <20><>ȭ ( <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>밡<EFBFBD><EBB0A1> )
|
||||
void AddMemberFame(unsigned char cType, unsigned long dwCID, int nFame); // <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ġ <20><>ȭ ( <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>밡<EFBFBD><EBB0A1> )
|
||||
void AddGoldToMaster(unsigned long dwGold); // <20><><EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD> <20>αƿ<D7BE><C6BF><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
|
||||
bool JoinMember(MemberInfo& memberInfo);
|
||||
bool LeaveMember(unsigned long dwCID);
|
||||
bool UpdateMemberInfo(unsigned long dwCID, MemberListInfo memberListInfo, MemberDetailInfo memberDetailInfo);
|
||||
void KickAllWaitMember() ;
|
||||
|
||||
void SendLoginOutMember(unsigned long dwCID, unsigned long dwServerID);
|
||||
void SendJoinMember(CSendStream* lpSendStream, unsigned long dwCID, unsigned char cTitle);
|
||||
|
||||
unsigned char GetTacticsMember(unsigned long dwCID);
|
||||
|
||||
void SetTacticsMember(unsigned long dwCID, unsigned char cTactics);
|
||||
|
||||
void SendJoinTacticsMember(CSendStream* lpSendStream, unsigned long dwCID, unsigned char cTitle, unsigned char CType);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,710 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <vector>
|
||||
#include <atltime.h>
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/PacketStruct/GuildPacket.h>
|
||||
#include <Network/SendPacket/SendGuild.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <DB/GuildDBComponent.h>
|
||||
|
||||
#include <DataStorage/SessionData.h>
|
||||
#include <DataStorage/SessionDataMgr.h>
|
||||
#include <DataStorage/CharacterData.h>
|
||||
#include <DataStorage/CharacterDataMgr.h>
|
||||
|
||||
#include <Creature/Siege/SiegeObjectDB.h>
|
||||
#include <Creature/Siege/SiegeObjectDBMgr.h>
|
||||
|
||||
#include <Castle/CastleDBMgr.h>
|
||||
#include <Community/Guild/GuildUtil.h>
|
||||
|
||||
#include "GuildDB.h"
|
||||
#include "GuildDBMgr.h"
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <DB/GameDBComponent.h>
|
||||
|
||||
#include <GameTime/GameTimeConstants.h>
|
||||
|
||||
using namespace Guild;
|
||||
|
||||
CGuildDBMgr& CGuildDBMgr::GetInstance()
|
||||
{
|
||||
static CGuildDBMgr guildDBMgr;
|
||||
return guildDBMgr;
|
||||
}
|
||||
|
||||
CGuildDBMgr::CGuildDBMgr(void)
|
||||
: CGuildMgr(), m_lpDBComponent(0)
|
||||
{
|
||||
}
|
||||
|
||||
CGuildDBMgr::~CGuildDBMgr(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool CGuildDBMgr::Initialize(CDBComponent& DBComponent)
|
||||
{
|
||||
m_lpDBComponent = &DBComponent;
|
||||
|
||||
if (false == ReadGuildInfoDB()) { return false; }
|
||||
if (false == ReadGuildMemberDB()) { return false; }
|
||||
if (false == ReadGuildRelationDB()) { return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CGuildDB* CGuildDBMgr::CreateGuild(unsigned long dwMasterID, unsigned char cNation, char* szGuildName, unsigned short* wError)
|
||||
{
|
||||
unsigned long dwGID = 0;
|
||||
|
||||
GuildRight guildRight;
|
||||
if (0 == m_lpDBComponent || !DBComponent::GuildDB::InsertGuildInfo(*m_lpDBComponent, szGuildName, cNation,
|
||||
reinterpret_cast<char *>(&guildRight), sizeof(GuildRight), &dwGID, wError))
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<EFBFBD> : CID:%10u DB<44><42><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.", dwMasterID);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (0 == dwGID)
|
||||
{
|
||||
ERRLOG0(g_Log, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>. <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CGuildDB* lpGuild = new CGuildDB(*m_lpDBComponent, dwGID, cNation, szGuildName);
|
||||
|
||||
if (!m_GuildMap.insert(GuildMap::value_type(dwGID, lpGuild)).second)
|
||||
{
|
||||
delete lpGuild;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return lpGuild;
|
||||
}
|
||||
|
||||
GuildMap::iterator CGuildDBMgr::DissolveGuild(unsigned long dwGID, unsigned short usDissolveReason)
|
||||
{
|
||||
GuildMap::iterator it = m_GuildMap.find(dwGID);
|
||||
if (it == m_GuildMap.end())
|
||||
{
|
||||
ERRLOG1(g_Log, "GID:%10u / <20><><EFBFBD><EFBFBD> <20><>ü <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʴ<EFBFBD> <20><><EFBFBD>带 <20><>ü<EFBFBD>Ϸ<EFBFBD><CFB7>մϴ<D5B4>.", dwGID);
|
||||
return it;
|
||||
}
|
||||
|
||||
CGuildDB* lpGuild = static_cast<CGuildDB*>(it->second);
|
||||
for (MemberList::iterator MemberIt = lpGuild->m_MemberList.begin(); MemberIt != lpGuild->m_MemberList.end(); ++MemberIt)
|
||||
{
|
||||
MemberInfo memberInfo = *MemberIt;
|
||||
|
||||
using namespace DBAgent::DataStorage;
|
||||
|
||||
CSessionData* lpSessionData =
|
||||
CSessionDataMgr::GetInstance().GetCharLoadedSession(memberInfo.m_dwCID);
|
||||
|
||||
CCharacterData* lpCharacterData = 0;
|
||||
|
||||
if (0 == lpSessionData || 0 == (lpCharacterData = lpSessionData->GetCharacterData()))
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ų<EFBFBD>, <20><><EFBFBD>ǿ<EFBFBD> ij<><C4B3><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20>αƿ<D7BE> <20>¿<EFBFBD><C2BF><EFBFBD> ã<>ƺ<EFBFBD><C6BA><EFBFBD>.
|
||||
lpCharacterData =
|
||||
static_cast<CCharacterData*>(CCharacterDataMgr::GetInstance().GetLogoutData(memberInfo.m_dwCID));
|
||||
}
|
||||
|
||||
if (0 != lpCharacterData)
|
||||
{
|
||||
lpCharacterData->SetGID(0);
|
||||
}
|
||||
|
||||
// WORK_LIST 2.3 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD> <20>ı<EFBFBD><C4B1><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ż<><C5BB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// lpGuild->AddMemberFame(Guild::TYPE_HALF, memberInfo.m_dwCID, 0);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>谡 <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
lpGuild->DeleteRelation();
|
||||
|
||||
PktCreateGuild pktCreateGuild;
|
||||
memset(&pktCreateGuild, 0, sizeof(PktCreateGuild));
|
||||
|
||||
pktCreateGuild.m_dwCID = 0;
|
||||
pktCreateGuild.m_dwGID = lpGuild->m_dwGID;
|
||||
pktCreateGuild.m_cInclination = lpGuild->m_cInclination;
|
||||
|
||||
strncpy(pktCreateGuild.m_szGuildName, lpGuild->GetName(), Guild::MAX_GUILD_NAME_LEN);
|
||||
|
||||
if(PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCreateGuild), sizeof(PktCreateGuild),
|
||||
CmdCreateGuild, usDissolveReason, PktCreateGuild::FAIL_DISSOLVE_GUILD))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCreateGuild), sizeof(PktCreateGuild), CmdCreateGuild));
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
DBComponent::GuildDB::DeleteGuildInfo(*m_lpDBComponent, lpGuild->GetGID());
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
DBComponent::GuildDB::DeleteGuildRelation(*m_lpDBComponent, lpGuild->GetGID());
|
||||
|
||||
delete it->second;
|
||||
it = m_GuildMap.erase(it);
|
||||
|
||||
// <20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ı<EFBFBD><C4B1>մϴ<D5B4>.
|
||||
CSiegeObjectDBMgr::GetInstance().DestroyCamp(dwGID);
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
bool CGuildDBMgr::SetRelation(unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelationType)
|
||||
{
|
||||
CGuildDB* lpGuild = static_cast<CGuildDB*>(GetGuild(dwGID));
|
||||
CGuildDB* lpTargetGuild = static_cast<CGuildDB*>(GetGuild(dwTargetGID));
|
||||
|
||||
if (!lpGuild || !lpTargetGuild) { return false ; }
|
||||
|
||||
if(Guild::TARGET_NEUTRALITY == cRelationType)
|
||||
{
|
||||
if (!lpGuild->SetRelation(dwTargetGID, cRelationType, Guild::BY_TARGET))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ߴµ<DFB4> <20>̹<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȭ<EFBFBD><C8AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>¸<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>¸<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><>Ų<EFBFBD><C5B2>.
|
||||
unsigned char tnRelation = lpTargetGuild->GetRelation(dwGID, Guild::BY_TARGET);
|
||||
|
||||
if( (Guild::HOSTILITY == cRelationType ||
|
||||
Guild::COUNTER_HOSTILITY == cRelationType ||
|
||||
Guild::ALERT_HOSTILITY == cRelationType) &&
|
||||
Guild::NEUTRALITY != tnRelation)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>¸<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD>Ѵ<EFBFBD>.
|
||||
if (!lpGuild->SetRelation(dwTargetGID, cRelationType, Guild::BY_MINE, 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20>ٽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̰<EFBFBD> <20>´<EFBFBD>.
|
||||
if (!lpTargetGuild->SetRelation(dwGID, cRelationType, Guild::BY_TARGET))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!lpGuild->SetRelation(dwTargetGID, cRelationType, Guild::BY_MINE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!lpTargetGuild->SetRelation(dwGID, cRelationType, Guild::BY_TARGET))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGuildDBMgr::CancelAlertAndCounterHostility()
|
||||
{
|
||||
for (GuildMap::iterator GuildIt = m_GuildMap.begin(); GuildIt != m_GuildMap.end(); ++GuildIt)
|
||||
{
|
||||
CGuildDB* lpGuild = static_cast<CGuildDB*>(GuildIt->second);
|
||||
|
||||
if (lpGuild->GetNumOfRelation(Guild::ALERT_HOSTILITY) > 0 ||
|
||||
lpGuild->GetNumOfRelation(Guild::COUNTER_HOSTILITY) > 0)
|
||||
{
|
||||
lpGuild->CancelAlertAndCounterHostility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGuildDBMgr::CancelAlertHostility(unsigned long dwTargetGID)
|
||||
{
|
||||
for (GuildMap::iterator GuildIt = m_GuildMap.begin(); GuildIt != m_GuildMap.end(); ++GuildIt)
|
||||
{
|
||||
CGuildDB* lpGuild = static_cast<CGuildDB*>(GuildIt->second);
|
||||
|
||||
if (lpGuild->GetRelationGID(Guild::ALERT_HOSTILITY) == dwTargetGID)
|
||||
{
|
||||
lpGuild->CancelAlertHostility(dwTargetGID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGuildDBMgr::ProcessGuild(void)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
CTime NowTime(sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
|
||||
CTimeSpan timeSpan(0);
|
||||
|
||||
for (GuildMap::iterator GuildIt = m_GuildMap.begin(); GuildIt != m_GuildMap.end(); )
|
||||
{
|
||||
CGuildDB* lpGuild = static_cast<CGuildDB*>(GuildIt->second);
|
||||
|
||||
/*
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ü
|
||||
if (0 != lpGuild->m_tmLastLogout.Year)
|
||||
{
|
||||
CTime GuildTime(lpGuild->m_tmLastLogout.Year, lpGuild->m_tmLastLogout.Month, lpGuild->m_tmLastLogout.Day,
|
||||
lpGuild->m_tmLastLogout.Hour, lpGuild->m_tmLastLogout.Minute, lpGuild->m_tmLastLogout.Second);
|
||||
timeSpan = NowTime - GuildTime;
|
||||
if (timeSpan.GetTotalMinutes() > DELETE_GUILD_LOGOUT_TIME)
|
||||
{
|
||||
DETLOG1(g_Log, "GID:%10u / <20><><EFBFBD>尡 <20><>ü<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD>ϴ<EFBFBD>. - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƹ<EFBFBD><C6B9><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
lpGuild->GetGID());
|
||||
GuildIt = DissolveGuild(lpGuild->GetGID(), PktCreateGuild::NONE_LOGIN);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ּ<EFBFBD> <20>ο<EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><>ü
|
||||
if (0 != lpGuild->m_tmCheckMember.Year && DELETE_GUILD_MEMBER_NUM > lpGuild->GetCurrentMemberNum())
|
||||
{
|
||||
CTime GuildTime(lpGuild->m_tmCheckMember.Year, lpGuild->m_tmCheckMember.Month, lpGuild->m_tmCheckMember.Day,
|
||||
lpGuild->m_tmCheckMember.Hour, lpGuild->m_tmCheckMember.Minute, lpGuild->m_tmCheckMember.Second);
|
||||
timeSpan = NowTime - GuildTime;
|
||||
if (timeSpan.GetTotalMinutes() > MEMBER_NUM_DELETE_TIME)
|
||||
{
|
||||
DETLOG1(g_Log, "GID:%10u / <20><><EFBFBD>尡 <20><>ü<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD>ϴ<EFBFBD>. - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ּ<EFBFBD> <20>ο<EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> ä <20><><EFBFBD><EFBFBD> <20>ð<EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
lpGuild->GetGID());
|
||||
GuildIt = DissolveGuild(lpGuild->GetGID(), PktCreateGuild::MIN_MEMBER_TIMEOUT);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>絵
|
||||
MemberInfo memberInfo = lpGuild->GetMaster();
|
||||
if (0 != lpGuild->m_tmGMLastLogout.Year && 0 == memberInfo.m_dwServerID)
|
||||
{
|
||||
CTime GuildTime(lpGuild->m_tmGMLastLogout.Year, lpGuild->m_tmGMLastLogout.Month, lpGuild->m_tmGMLastLogout.Day,
|
||||
lpGuild->m_tmGMLastLogout.Hour, lpGuild->m_tmGMLastLogout.Minute, lpGuild->m_tmGMLastLogout.Second);
|
||||
timeSpan = NowTime - GuildTime;
|
||||
if (timeSpan.GetTotalMinutes() > TRANFER_MASTER_TIME)
|
||||
{
|
||||
// <20><><EFBFBD>尡 <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD>츦 <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
GuildMap::iterator TempGuildIt = GuildIt;
|
||||
++TempGuildIt;
|
||||
|
||||
unsigned long dwNewMaster = lpGuild->SetNewMaster();
|
||||
if (0 == dwNewMaster)
|
||||
{
|
||||
DETLOG1(g_Log, "GID:%10u / <20><><EFBFBD>尡 <20><>ü<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD>ϴ<EFBFBD>. - <20><><EFBFBD><EFBFBD> <20>Ⱓ<EFBFBD><E2B0A3><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>帶<EFBFBD><E5B8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>絵", lpGuild->GetGID());
|
||||
CGuildDBMgr::GetInstance().DissolveGuild(lpGuild->GetGID(), PktCreateGuild::NONE_NEXT_GUILDMASTER_BY_NONE_LOGIN);
|
||||
GuildIt = TempGuildIt;
|
||||
continue;
|
||||
}
|
||||
|
||||
DBAgent::SendPacket::GuildCmd(NULL, lpGuild->GetGID(), dwNewMaster, MASTER,
|
||||
PktGuildCmd::GC_SETUP_TITLE, PktBase::NO_SERVER_ERR);
|
||||
|
||||
lpGuild->SetTitle(memberInfo.m_dwCID, COMMON);
|
||||
|
||||
DBAgent::SendPacket::GuildCmd(NULL, lpGuild->GetGID(), memberInfo.m_dwCID, COMMON,
|
||||
PktGuildCmd::GC_SETUP_TITLE, PktBase::NO_SERVER_ERR);
|
||||
|
||||
DETLOG3(g_Log, "GID:%10u / <20><><EFBFBD>帶<EFBFBD><E5B8B6><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>CID:%10u, <20><><EFBFBD><EFBFBD>CID:%10u)<29><> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD>ϴ<EFBFBD>. "
|
||||
"- <20><><EFBFBD><EFBFBD> <20>Ⱓ<EFBFBD><E2B0A3><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>帶<EFBFBD><E5B8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>絵",
|
||||
lpGuild->GetGID(), memberInfo.m_dwCID, dwNewMaster);
|
||||
}
|
||||
}
|
||||
*/
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ð<EFBFBD> üũ.
|
||||
if(lpGuild->GetGuildPointFlag())
|
||||
{
|
||||
// <20>ð<EFBFBD> <20>˻<EFBFBD> //
|
||||
TIME* pTime = lpGuild->GetGuildPointTime();
|
||||
|
||||
if(pTime)
|
||||
{
|
||||
CTime nowTime = CTime::GetCurrentTime();
|
||||
CTimeSpan timeSpan(0);
|
||||
|
||||
CTime GuildPointTime(pTime->Year, pTime->Month, pTime->Day, pTime->Hour, pTime->Minute, pTime->Second);
|
||||
|
||||
timeSpan = nowTime - GuildPointTime;
|
||||
|
||||
if(timeSpan.GetTotalMinutes() >= Guild::TIME_GUILD_POINT)
|
||||
{
|
||||
// <20><EFBFBD><DEBC><EFBFBD> <20><><EFBFBD><EFBFBD> //
|
||||
lpGuild->SetGuildPointFlag(0);
|
||||
|
||||
PktCampMessage pktCampMessage;
|
||||
memset(&pktCampMessage, 0, sizeof(PktCampMessage));
|
||||
pktCampMessage.m_cMsgCmd = PktCampMessage::MSGCMD_GUILD_TIME_COMPLETE;
|
||||
pktCampMessage.m_bNotify = false;
|
||||
pktCampMessage.m_dwGID = lpGuild->GetGID();
|
||||
|
||||
if (PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage, 0, 0))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktCampMessage), sizeof(PktCampMessage), CmdCampMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ż<><C5BB> <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD> <20><><EFBFBD><EFBFBD> Ż<><C5BB>
|
||||
std::list<unsigned long> deleteList;
|
||||
|
||||
for (MemberList::iterator MemberIt = lpGuild->m_MemberList.begin(); MemberIt != lpGuild->m_MemberList.end(); ++MemberIt)
|
||||
{
|
||||
MemberInfo memberInfo = *MemberIt;
|
||||
|
||||
if (Guild::LEAVE_WAIT != memberInfo.m_MemberListInfo.m_cTitle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (0 != memberInfo.m_LeaveGuildTime.Year)
|
||||
{
|
||||
CTime GuildTime(memberInfo.m_LeaveGuildTime.Year, memberInfo.m_LeaveGuildTime.Month, memberInfo.m_LeaveGuildTime.Day,
|
||||
memberInfo.m_LeaveGuildTime.Hour, memberInfo.m_LeaveGuildTime.Minute, memberInfo.m_LeaveGuildTime.Second);
|
||||
timeSpan = NowTime - GuildTime;
|
||||
|
||||
unsigned long dwLeaveWaitTime = LEAVE_WAIT_TIME;
|
||||
|
||||
if (timeSpan.GetTotalMinutes() > dwLeaveWaitTime)
|
||||
{
|
||||
deleteList.push_back(memberInfo.m_dwCID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (std::list<unsigned long>::iterator DeleteIt = deleteList.begin(); DeleteIt != deleteList.end(); ++DeleteIt)
|
||||
{
|
||||
using namespace DBAgent::DataStorage;
|
||||
|
||||
CSessionData* lpSessionData = CSessionDataMgr::GetInstance().GetCharLoadedSession(*DeleteIt);
|
||||
|
||||
if(lpSessionData)
|
||||
{
|
||||
CCharacterData* lpCharacterData = lpSessionData->GetCharacterData();
|
||||
|
||||
if(lpCharacterData)
|
||||
{
|
||||
unsigned short wError = PktBase::NO_SERVER_ERR;
|
||||
|
||||
lpCharacterData->SetGuildWarFlag(Creature::WAR_OFF);
|
||||
|
||||
PktWarOnOff pktWarOnOff;
|
||||
memset(&pktWarOnOff, 0, sizeof(PktWarOnOff));
|
||||
|
||||
pktWarOnOff.m_dwCID = *DeleteIt;
|
||||
pktWarOnOff.m_cType = GameTime::GUILD;
|
||||
pktWarOnOff.m_cFlag = Creature::WAR_OFF;
|
||||
|
||||
if(PacketWrap::WrapHeader(reinterpret_cast<char*>(&pktWarOnOff), sizeof(PktWarOnOff), CmdWarOnOff, 0, wError))
|
||||
{
|
||||
DBAgent::CGameDispatch::GetDispatchTable().Process(CSendPacketAllServer(
|
||||
reinterpret_cast<char*>(&pktWarOnOff), sizeof(PktWarOnOff), CmdWarOnOff));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DBComponent::GameDB::UpdateGuildWarFlag(CDBSingleObject::GetInstance(), *DeleteIt, Creature::WAR_OFF);
|
||||
}
|
||||
|
||||
lpGuild->LeaveMember(*DeleteIt);
|
||||
|
||||
DBAgent::SendPacket::GuildCmd(NULL, lpGuild->GetGID(),
|
||||
*DeleteIt, 0, PktGuildCmd::GC_KICK, NULL, NULL, PktBase::NO_SERVER_ERR);
|
||||
}
|
||||
|
||||
deleteList.clear();
|
||||
|
||||
++GuildIt;
|
||||
}
|
||||
}
|
||||
|
||||
bool CGuildDBMgr::ReadGuildInfoDB(void)
|
||||
{
|
||||
const int MAX_ROWS = 10240;
|
||||
int nGetRows = 0;
|
||||
|
||||
char szBuffer[CDBComponent::QUERY_BUFFER_LEN];
|
||||
_snprintf(szBuffer, CDBComponent::QUERY_BUFFER_LEN - 1,
|
||||
"SELECT nGuildID, strGuildName, tnGuildLevel, nGuildFame, nGuildGold, "
|
||||
"tLastLogout, tCheckMember, tGMLastLogout, bGuildMark, bRight, tnNationType, tChangeState "
|
||||
"FROM TblGuildInfo WHERE OldServerGroupID = %d", CServerSetup::GetInstance().GetAgentServerType());
|
||||
|
||||
szBuffer[CDBComponent::QUERY_BUFFER_LEN - 1] = 0;
|
||||
|
||||
if (0 == m_lpDBComponent ||
|
||||
!m_lpDBComponent->ExecuteQuery(szBuffer))
|
||||
{
|
||||
ERRLOG0(g_Log, "ReadGuildInfoDB <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD> DB <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
GuildInfoDB* guildInfo = new GuildInfoDB[MAX_ROWS];
|
||||
memset(guildInfo, 0, sizeof(GuildInfoDB) * MAX_ROWS);
|
||||
|
||||
int nTotalGuildNum = 0;
|
||||
|
||||
while (m_lpDBComponent->GetData((void**)guildInfo, sizeof(GuildInfoDB), MAX_ROWS, &nGetRows))
|
||||
{
|
||||
if (0 == nGetRows) { break; }
|
||||
|
||||
nTotalGuildNum += nGetRows;
|
||||
|
||||
for (GuildInfoDB* lpGuildInfo = guildInfo; nGetRows > 0; --nGetRows, ++lpGuildInfo)
|
||||
{
|
||||
CGuildDB* lpGuild = new CGuildDB(*m_lpDBComponent, *lpGuildInfo);
|
||||
if (false == m_GuildMap.insert(GuildMap::value_type(lpGuild->GetGID(), lpGuild)).second)
|
||||
{
|
||||
delete lpGuild;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
memset(guildInfo, 0, sizeof(GuildInfoDB) * MAX_ROWS);
|
||||
}
|
||||
|
||||
INFLOG1(g_Log, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> : %d <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE>Խ<EFBFBD><D4BD>ϴ<EFBFBD>", nTotalGuildNum);
|
||||
|
||||
delete [] guildInfo;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGuildDBMgr::ReadGuildMemberDB(void)
|
||||
{
|
||||
char szBuffer[CDBComponent::QUERY_BUFFER_LEN];
|
||||
_snprintf(szBuffer, CDBComponent::QUERY_BUFFER_LEN - 1,
|
||||
"SELECT TblGuildMember.nGuildID, TblGuildMember.nCID, "
|
||||
"TblGuildMember.nPositionInGuild, CharInfo.Name, "
|
||||
"TblGuildMember.nPosition, CharInfo.Level, CharInfo.Class, "
|
||||
"CharInfo.Fame, CharInfo.Gold, CharInfoEx.GuildWarFlag, TblGuildMember.tLeaveGuildTime, TblGuildMember.Tactics "
|
||||
"FROM TblGuildInfo, TblGuildMember, CharInfo, CharInfoEx WHERE "
|
||||
"TblGuildInfo.nGuildID = TblGuildMember.nGuildID AND "
|
||||
"TblGuildMember.nCID = CharInfo.CID AND "
|
||||
"TblGuildMember.nCID = CharInfoEx.CID AND "
|
||||
"TblGuildInfo.OldServerGroupID = %d", CServerSetup::GetInstance().GetAgentServerType());
|
||||
|
||||
szBuffer[CDBComponent::QUERY_BUFFER_LEN - 1] = 0;
|
||||
|
||||
if (0 == m_lpDBComponent || !m_lpDBComponent->ExecuteQuery(szBuffer))
|
||||
{
|
||||
ERRLOG0(g_Log, "ReadGuildMemberDB <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> DB <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef std::pair<GuildMemberDB*, int> GuildMemberDBRows;
|
||||
typedef std::vector<GuildMemberDBRows> VecGuildMemberDB;
|
||||
|
||||
VecGuildMemberDB vecGuildMemberDB;
|
||||
|
||||
const int MAX_ROWS = 4096;
|
||||
int nGetRows = 0;
|
||||
int nTotalGuildMemberNum = 0;
|
||||
|
||||
GuildMemberDB* guildMember = new GuildMemberDB[MAX_ROWS];
|
||||
memset(guildMember, 0, sizeof(GuildMemberDB) * MAX_ROWS);
|
||||
|
||||
while (m_lpDBComponent->GetData((void**)guildMember, sizeof(GuildMemberDB), MAX_ROWS, &nGetRows))
|
||||
{
|
||||
if (0 == nGetRows) { break; }
|
||||
|
||||
nTotalGuildMemberNum += nGetRows;
|
||||
|
||||
vecGuildMemberDB.push_back(GuildMemberDBRows(guildMember, nGetRows));
|
||||
|
||||
guildMember = new GuildMemberDB[MAX_ROWS];
|
||||
memset(guildMember, 0, sizeof(GuildMemberDB) * MAX_ROWS);
|
||||
}
|
||||
|
||||
if (0 != guildMember)
|
||||
{
|
||||
delete [] guildMember;
|
||||
guildMember = 0;
|
||||
}
|
||||
|
||||
VecGuildMemberDB::iterator pos = vecGuildMemberDB.begin();
|
||||
VecGuildMemberDB::iterator end = vecGuildMemberDB.end();
|
||||
|
||||
CGuild* lpGuild = 0;
|
||||
|
||||
for(; pos != end; ++pos)
|
||||
{
|
||||
GuildMemberDB* lpGuildPos = pos->first;
|
||||
GuildMemberDB* lpGuildEnd = lpGuildPos + pos->second;
|
||||
|
||||
for(; lpGuildPos != lpGuildEnd; ++lpGuildPos)
|
||||
{
|
||||
if (NULL == lpGuild || lpGuild->GetGID() != lpGuildPos->m_dwGID)
|
||||
{
|
||||
lpGuild = static_cast<CGuildDB*>(GetGuild(lpGuildPos->m_dwGID));
|
||||
if (NULL == lpGuild)
|
||||
{
|
||||
ERRLOG2(g_Log, "GID:%10u / CID:%10u / <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> DB<44>б<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʴ<EFBFBD> <20><><EFBFBD>忡 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>",
|
||||
lpGuildPos->m_dwGID, lpGuildPos->m_dwCID);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(!lpGuild->JoinMemberDB(*lpGuildPos))
|
||||
{
|
||||
ERRLOG3(g_Log, "GID:%10u / CID:%10u / Name:%s / DB<44><42><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Join<69>ϴ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>߾<EFBFBD><DFBE>ϴ<EFBFBD>",
|
||||
lpGuildPos->m_dwGID, lpGuildPos->m_dwCID, lpGuildPos->m_strName);
|
||||
}
|
||||
}
|
||||
|
||||
delete [] pos->first;
|
||||
*pos = GuildMemberDBRows((GuildMemberDB*)0, 0);
|
||||
}
|
||||
|
||||
INFLOG1(g_Log, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : %d <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE>Խ<EFBFBD><D4BD>ϴ<EFBFBD>", nTotalGuildMemberNum);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGuildDBMgr::ReadGuildRelationDB(void)
|
||||
{
|
||||
const int MAX_ROWS = 10240;
|
||||
int nGetRows = 0;
|
||||
|
||||
char szBuffer[CDBComponent::QUERY_BUFFER_LEN];
|
||||
_snprintf(szBuffer, CDBComponent::QUERY_BUFFER_LEN - 1,
|
||||
"SELECT TblGuildRelation.nGuildID, TblGuildRelation.nTargetGuildID, TblGuildRelation.tnRelation "
|
||||
"FROM TblGuildInfo, TblGuildRelation WHERE "
|
||||
"TblGuildInfo.nGuildID = TblGuildRelation.nGuildID AND TblGuildInfo.OldServerGroupID = %d",
|
||||
CServerSetup::GetInstance().GetAgentServerType());
|
||||
|
||||
szBuffer[CDBComponent::QUERY_BUFFER_LEN - 1] = 0;
|
||||
|
||||
if (0 == m_lpDBComponent || !m_lpDBComponent->ExecuteQuery(szBuffer))
|
||||
{
|
||||
ERRLOG0(g_Log, "ReadGuildRelationDB <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> DB <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
GuildRelationDB* guildRelation = new GuildRelationDB[MAX_ROWS];
|
||||
memset(guildRelation, 0, sizeof(GuildRelationDB) * MAX_ROWS);
|
||||
|
||||
int nTotalGuildRelationNum = 0;
|
||||
CGuildDB* lpGuild = NULL;
|
||||
CGuildDB* lpTargetGuild = NULL;
|
||||
|
||||
while (m_lpDBComponent->GetData((void**)guildRelation, sizeof(GuildRelationDB), MAX_ROWS, &nGetRows))
|
||||
{
|
||||
if (0 == nGetRows) { break; }
|
||||
|
||||
nTotalGuildRelationNum += nGetRows;
|
||||
|
||||
for (GuildRelationDB* lpGuildRelation = guildRelation; nGetRows > 0; --nGetRows, ++lpGuildRelation)
|
||||
{
|
||||
lpGuild = static_cast<CGuildDB*>(GetGuild(lpGuildRelation->m_dwGID));
|
||||
if (NULL == lpGuild)
|
||||
{
|
||||
ERRLOG2(g_Log, "GID:%10u / TargetGID:%10u / <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʴ<EFBFBD> <20><><EFBFBD>尡 <20><><EFBFBD>尣 <20><><EFBFBD>踦 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>մϴ<D5B4>. ",
|
||||
lpGuildRelation->m_dwGID, lpGuildRelation->m_dwTargetGID);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
lpTargetGuild = static_cast<CGuildDB*>(GetGuild(lpGuildRelation->m_dwTargetGID));
|
||||
if (NULL == lpTargetGuild)
|
||||
{
|
||||
ERRLOG2(g_Log, "GID:%10u / TargetGID:%10u / <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>尣 <20><><EFBFBD>踦 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>մϴ<D5B4>. ",
|
||||
lpGuildRelation->m_dwGID, lpGuildRelation->m_dwTargetGID);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
INFLOG3(g_Log, "GID:%10u / TargetGID:%10u / Relation:%d <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ε<EFBFBD>",
|
||||
lpGuildRelation->m_dwGID, lpGuildRelation->m_dwTargetGID, lpGuildRelation->m_cRelation);
|
||||
|
||||
// TARGET_NEUTRALITY Ÿ<><C5B8><EFBFBD≯<EFBFBD> TargetGuild<6C><64><EFBFBD><EFBFBD> <20><>ȭ<EFBFBD><C8AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ؾ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0>̱<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״<EFBFBD> <20>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD> <20>ʴ´<CAB4>.
|
||||
if(lpGuildRelation->m_cRelation != Guild::TARGET_NEUTRALITY)
|
||||
lpGuild->InsertRelation(lpGuildRelation->m_dwGID, lpGuildRelation->m_dwTargetGID, lpGuildRelation->m_cRelation);
|
||||
|
||||
lpTargetGuild->InsertRelation(lpGuildRelation->m_dwGID, lpGuildRelation->m_dwTargetGID, lpGuildRelation->m_cRelation);
|
||||
}
|
||||
|
||||
memset(guildRelation, 0, sizeof(GuildRelationDB) * MAX_ROWS);
|
||||
}
|
||||
|
||||
INFLOG1(g_Log, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : %d <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE>Խ<EFBFBD><D4BD>ϴ<EFBFBD>", nTotalGuildRelationNum);
|
||||
|
||||
delete [] guildRelation;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CGuildDBMgr::SendGuildDBList(CSendStream& SendStream)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> DB <20><>Ŷ + <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>ڽ<EFBFBD><DABD><EFBFBD> <20><><EFBFBD><EFBFBD>) + <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>ٸ<EFBFBD><D9B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>)
|
||||
const unsigned short MAX_GUILD_BUFFER_SIZE = sizeof(PktGuildDB) + sizeof(GuildInfoDB) +
|
||||
sizeof(GuildMemberDB) * MAX_MEMBER_NUM +
|
||||
sizeof(GuildRelationDB) * MAX_RELATION_NUM * 2;
|
||||
|
||||
char szBuffer[MAX_GUILD_BUFFER_SIZE];
|
||||
unsigned short wBufferSize = 0;
|
||||
|
||||
unsigned char cTotalMemberNum = 0;
|
||||
unsigned char cRelationByMineNum = 0;
|
||||
unsigned char cRelationByTargetNum = 0;
|
||||
|
||||
for (GuildMap::iterator it = m_GuildMap.begin(); it != m_GuildMap.end(); ++it)
|
||||
{
|
||||
CGuild* lpGuild = it->second;
|
||||
if (NULL == lpGuild)
|
||||
{
|
||||
ERRLOG0(g_Log, "NULL <20><><EFBFBD>尡 <20><><EFBFBD>ԵǾ<D4B5> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.");
|
||||
return;
|
||||
}
|
||||
|
||||
SerializeOut(lpGuild, szBuffer + sizeof(PktGuildDB),
|
||||
wBufferSize, cTotalMemberNum, cRelationByMineNum, cRelationByTargetNum);
|
||||
|
||||
PktGuildDB* lpGuildDB = reinterpret_cast<PktGuildDB*>(szBuffer);
|
||||
|
||||
lpGuildDB->m_bStartFlag = (it == m_GuildMap.begin()) ? true : false;
|
||||
|
||||
lpGuildDB->m_dwGID = lpGuild->GetGID();
|
||||
|
||||
lpGuildDB->m_cTotalMemberNum = cTotalMemberNum;
|
||||
lpGuildDB->m_cRelationByMineNum = cRelationByMineNum;
|
||||
lpGuildDB->m_cRelationByTargetNum = cRelationByTargetNum;
|
||||
|
||||
lpGuildDB->m_wSize = wBufferSize;
|
||||
|
||||
SendStream.WrapCompress(szBuffer, sizeof(PktGuildDB) + wBufferSize,
|
||||
CmdGuildDB, 0, PktBase::NO_SERVER_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
void CGuildDBMgr::KickAllWaitMember()
|
||||
{
|
||||
GuildMap::iterator itr = m_GuildMap.begin() ;
|
||||
GuildMap::iterator end = m_GuildMap.end() ;
|
||||
CGuildDB* lpGuild = NULL ;
|
||||
|
||||
while ( itr != end )
|
||||
{
|
||||
lpGuild = static_cast<CGuildDB*>( itr->second ) ;
|
||||
if ( lpGuild )
|
||||
{
|
||||
lpGuild->KickAllWaitMember() ;
|
||||
}
|
||||
|
||||
++itr ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
#ifndef _GUILDDB_MGR_H_
|
||||
#define _GUILDDB_MGR_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Community/Guild/GuildMgr.h>
|
||||
|
||||
|
||||
// forward decl.
|
||||
class CSendStream;
|
||||
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
class CGuildDB;
|
||||
|
||||
class CGuildDBMgr : public CGuildMgr
|
||||
{
|
||||
public:
|
||||
|
||||
static CGuildDBMgr& GetInstance();
|
||||
|
||||
CGuildDBMgr(void);
|
||||
~CGuildDBMgr(void);
|
||||
|
||||
bool Initialize(CDBComponent& DBComponent);
|
||||
|
||||
CGuildDB* CreateGuild(unsigned long dwMasterID, unsigned char cNation, char* szGuildName, unsigned short* wError);
|
||||
GuildMap::iterator DissolveGuild(unsigned long dwGID, unsigned short usDissolveReason);
|
||||
|
||||
bool SetRelation(unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelationType);
|
||||
void CancelAlertAndCounterHostility(); // <20>ڽ<EFBFBD><DABD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> / ī<><C4AB><EFBFBD><EFBFBD> <20><><EFBFBD>븦 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>踦 <20><><EFBFBD><EFBFBD>
|
||||
void CancelAlertHostility(unsigned long dwTargetGID); // dwTargetGID <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>踦 <20><><EFBFBD><EFBFBD>
|
||||
|
||||
void ProcessGuild(void);
|
||||
void SendGuildDBList(CSendStream& SendStream);
|
||||
|
||||
void KickAllWaitMember() ;
|
||||
|
||||
private:
|
||||
|
||||
bool ReadGuildInfoDB(void);
|
||||
bool ReadGuildMemberDB(void);
|
||||
bool ReadGuildRelationDB(void);
|
||||
|
||||
CDBComponent* m_lpDBComponent;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,336 @@
|
||||
#include "stdafx.h"
|
||||
#include "PartyDBInfo.h"
|
||||
|
||||
#include <DataStorage/CharacterData.h>
|
||||
#include <DataStorage/CharacterDataMgr.h>
|
||||
|
||||
#include <DataStorage/SessionData.h>
|
||||
#include <DataStorage/SessionDataMgr.h>
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
|
||||
|
||||
namespace DBAgent
|
||||
{
|
||||
|
||||
CPartyDBInfo::CPartyDBInfo(unsigned long PartyID_In)
|
||||
{
|
||||
memset(&m_Party, 0, sizeof(PARTY));
|
||||
m_Party.m_dwPartyID = PartyID_In;
|
||||
|
||||
std::fill_n(&m_Party.ServerID[0], int(PARTY::MAX_MEM), 0);
|
||||
std::fill_n(&m_bAutoRouting[0], int(PARTY::MAX_MEM), 1);
|
||||
|
||||
std::fill_n(&m_Party.m_cLevel[0], int(PARTY::MAX_MEM), 0);
|
||||
std::fill_n(&m_Party.m_wClass[0], int(PARTY::MAX_MEM), 0);
|
||||
std::fill_n(&m_Party.m_dwGID[0], int(PARTY::MAX_MEM), 0);
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::SerializeIn(PARTY_INFO& PartyInfo_In, PARTY_USER_INFO& PartyUserInfo_In)
|
||||
{
|
||||
int Count = 0;
|
||||
for (; Count < PARTY::MAX_MEM; ++Count)
|
||||
{
|
||||
if (0 == PartyInfo_In.MemberCID[Count])
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
strncpy((char *)m_Party.Name[Count], (char *)PartyInfo_In.Name[Count], CHAR_INFOST::MAX_NAME_LEN);
|
||||
m_Party.MemberCID[Count] = PartyInfo_In.MemberCID[Count];
|
||||
m_Party.ServerID[Count] = 0;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> //
|
||||
m_Party.m_cLevel[Count] = PartyUserInfo_In.m_cLevel[Count];
|
||||
m_Party.m_wClass[Count] = PartyUserInfo_In.m_wClass[Count];
|
||||
m_Party.m_dwGID[Count] = PartyUserInfo_In.m_dwGID[Count];
|
||||
}
|
||||
|
||||
m_Party.m_cMemberNum = Count;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::SerializeOut(PARTY_INFO& PartyInfo_Out, PARTY_USER_INFO& PartyUserInfo_Out)
|
||||
{
|
||||
if (m_Party.m_cMemberNum > PARTY::MAX_MEM)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int Count = 0; Count < m_Party.m_cMemberNum; ++Count)
|
||||
{
|
||||
PartyInfo_Out.MemberCID[Count] = m_Party.MemberCID[Count];
|
||||
strncpy((char *)PartyInfo_Out.Name[Count], (char *)m_Party.Name[Count], CHAR_INFOST::MAX_NAME_LEN);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> //
|
||||
PartyUserInfo_Out.m_cLevel[Count] = m_Party.m_cLevel[Count];
|
||||
PartyUserInfo_Out.m_wClass[Count] = m_Party.m_wClass[Count];
|
||||
PartyUserInfo_Out.m_dwGID[Count] = m_Party.m_dwGID[Count];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned long CPartyDBInfo::GetFirstMem(void)
|
||||
{
|
||||
for (int Count = 0; Count < m_Party.m_cMemberNum; ++Count)
|
||||
{
|
||||
if (0 != m_Party.ServerID[Count])
|
||||
{
|
||||
return m_Party.MemberCID[Count];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::IsMember(unsigned long CharID_In)
|
||||
{
|
||||
for (int Count = 0; Count < m_Party.m_cMemberNum; ++Count)
|
||||
{
|
||||
if (m_Party.MemberCID[Count] == CharID_In)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::PartyMemLogin(unsigned long dwCharID_In, unsigned long dwServerID_In)
|
||||
{
|
||||
for (int Count = 0; Count < m_Party.m_cMemberNum; ++Count)
|
||||
{
|
||||
if (m_Party.MemberCID[Count] == dwCharID_In)
|
||||
{
|
||||
m_Party.ServerID[Count] = dwServerID_In;
|
||||
if (0 == m_Party.m_dwLeaderID)
|
||||
{
|
||||
SetLeader(dwCharID_In);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::PartyMemLogout(unsigned long CharID_In)
|
||||
{
|
||||
for (int Count = 0; Count < m_Party.m_cMemberNum; ++Count)
|
||||
{
|
||||
if (m_Party.MemberCID[Count] == CharID_In)
|
||||
{
|
||||
m_Party.ServerID[Count] = 0;
|
||||
if (m_Party.m_dwLeaderID == CharID_In)
|
||||
{
|
||||
SetLeader(GetFirstMem());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPartyDBInfo::PartyMemAllLogout(void)
|
||||
{
|
||||
std::fill_n(&m_Party.ServerID[0], int(PARTY::MAX_MEM), 0);
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::IsLogined(unsigned long CharID_In)
|
||||
{
|
||||
for (int Count = 0; Count < m_Party.m_cMemberNum; ++Count)
|
||||
{
|
||||
if (m_Party.MemberCID[Count] == CharID_In)
|
||||
{
|
||||
if (m_Party.ServerID[Count] != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::TransferLeader(unsigned long OldLeaderID, unsigned long NewLeaderID)
|
||||
{
|
||||
if (OldLeaderID != GetLeader())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == IsLogined(OldLeaderID) || false == IsLogined(NewLeaderID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SetLeader(NewLeaderID);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::InsertPartyMem(unsigned long ServerID_In, unsigned long CharID_In, unsigned short Class_In, char Level_In, unsigned long GID_In, const char* CharName_In)
|
||||
{
|
||||
if (PARTY::MAX_MEM <= m_Party.m_cMemberNum) // <20><>Ƽ<EFBFBD>ο<EFBFBD><CEBF><EFBFBD> 10<31><30> <20>̻<EFBFBD>
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Party.ServerID[m_Party.m_cMemberNum] = ServerID_In;
|
||||
m_Party.MemberCID[m_Party.m_cMemberNum] = CharID_In;
|
||||
m_Party.m_cLevel[m_Party.m_cMemberNum] = Level_In;
|
||||
m_Party.m_wClass[m_Party.m_cMemberNum] = Class_In;
|
||||
m_Party.m_dwGID[m_Party.m_cMemberNum] = GID_In;
|
||||
|
||||
strncpy(m_Party.Name[m_Party.m_cMemberNum], CharName_In, CHAR_INFOST::MAX_NAME_LEN);
|
||||
|
||||
++m_Party.m_cMemberNum;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::DeletePartyMem(unsigned long CharID_In, unsigned long& ServerID_Out)
|
||||
{
|
||||
using namespace DBAgent::DataStorage;
|
||||
|
||||
int nCount = 0;
|
||||
|
||||
for (; nCount < m_Party.m_cMemberNum; ++nCount)
|
||||
{
|
||||
if (m_Party.MemberCID[nCount] == CharID_In)
|
||||
{
|
||||
CSessionData* lpSessionData = 0;
|
||||
CCharacterData* lpCharacterData = 0;
|
||||
|
||||
if(0 == m_Party.ServerID[nCount])
|
||||
{
|
||||
lpCharacterData = static_cast<CCharacterData*>(
|
||||
CCharacterDataMgr::GetInstance().GetLogoutData(CharID_In));
|
||||
}
|
||||
else
|
||||
{
|
||||
lpSessionData = CSessionDataMgr::GetInstance().GetCharLoadedSession(CharID_In);
|
||||
if(0 != lpSessionData)
|
||||
{
|
||||
lpCharacterData = lpSessionData->GetCharacterData();
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != lpCharacterData && m_Party.m_dwPartyID == lpCharacterData->GetPID())
|
||||
{
|
||||
RULLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : ij<><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PID<49><44> 0<><30><EFBFBD><EFBFBD> <20><>",
|
||||
m_Party.m_dwPartyID, CharID_In);
|
||||
|
||||
lpCharacterData->SetPID(0);
|
||||
}
|
||||
|
||||
ServerID_Out = m_Party.ServerID[nCount];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nCount == m_Party.m_cMemberNum)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (; nCount < m_Party.m_cMemberNum; ++nCount)
|
||||
{
|
||||
if ((nCount + 1) >= PARTY::MAX_MEM)
|
||||
{
|
||||
m_Party.ServerID[nCount] = 0;
|
||||
m_Party.MemberCID[nCount] = 0;
|
||||
m_Party.m_cLevel[nCount] = 0;
|
||||
m_Party.m_dwGID[nCount] = 0;
|
||||
m_Party.m_wClass[nCount] = 0;
|
||||
|
||||
std::fill_n(&m_Party.Name[nCount][0], int(CHAR_INFOST::MAX_NAME_LEN), 0);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
m_Party.ServerID[nCount] = m_Party.ServerID[nCount + 1];
|
||||
m_Party.MemberCID[nCount] = m_Party.MemberCID[nCount + 1];
|
||||
m_Party.m_cLevel[nCount] = m_Party.m_cLevel[nCount + 1];
|
||||
m_Party.m_dwGID[nCount] = m_Party.m_dwGID[nCount + 1];
|
||||
m_Party.m_wClass[nCount] = m_Party.m_wClass[nCount + 1];
|
||||
strncpy((char *)m_Party.Name[nCount], (char *)m_Party.Name[nCount + 1], CHAR_INFOST::MAX_NAME_LEN);
|
||||
}
|
||||
|
||||
if (m_Party.m_dwLeaderID == CharID_In)
|
||||
{
|
||||
SetLeader(GetFirstMem());
|
||||
}
|
||||
|
||||
--m_Party.m_cMemberNum;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::SetUserInfoLevel(unsigned long dwCID, char cLevel)
|
||||
{
|
||||
for(unsigned char cIndex = 0; cIndex < m_Party.m_cMemberNum; ++cIndex)
|
||||
{
|
||||
if(m_Party.MemberCID[cIndex]==dwCID)
|
||||
{
|
||||
m_Party.m_cLevel[cIndex] = cLevel;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::SetUserInfoClass(unsigned long dwCID, unsigned short wClass)
|
||||
{
|
||||
for(unsigned char cIndex = 0; cIndex < m_Party.m_cMemberNum; ++cIndex)
|
||||
{
|
||||
if(m_Party.MemberCID[cIndex]==dwCID)
|
||||
{
|
||||
m_Party.m_wClass[cIndex] = wClass;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::SetUserInfoGID(unsigned long dwCID, unsigned long dwGID)
|
||||
{
|
||||
for(unsigned char cIndex = 0; cIndex < m_Party.m_cMemberNum; ++cIndex)
|
||||
{
|
||||
if(m_Party.MemberCID[cIndex]==dwCID)
|
||||
{
|
||||
m_Party.m_dwGID[cIndex] = dwGID;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPartyDBInfo::AutoRouting(unsigned long CharID_In, bool bOn, bool bAll)
|
||||
{
|
||||
if (bAll == true)
|
||||
{
|
||||
int Count = 0;
|
||||
for (; Count < m_Party.m_cMemberNum; ++Count)
|
||||
{
|
||||
m_bAutoRouting[Count] = bOn;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int Count = 0;
|
||||
for (; Count < m_Party.m_cMemberNum; ++Count)
|
||||
{
|
||||
if (m_Party.MemberCID[Count] == CharID_In)
|
||||
{
|
||||
m_bAutoRouting[Count] = bOn;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#ifndef _RYL_DBAGENT_PARTY_DB_INFO_H_
|
||||
#define _RYL_DBAGENT_PARTY_DB_INFO_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <DB/DBdefine.h>
|
||||
|
||||
|
||||
namespace DBAgent
|
||||
{
|
||||
|
||||
class CPartyDBInfo
|
||||
{
|
||||
public:
|
||||
|
||||
CPartyDBInfo(unsigned long PartyID_In);
|
||||
|
||||
bool SerializeIn(PARTY_INFO& PartyInfo_In, PARTY_USER_INFO& PartyUserInfo_In);
|
||||
bool SerializeOut(PARTY_INFO& PartyInfo_Out, PARTY_USER_INFO& PartyUserInfo_Out);
|
||||
|
||||
unsigned long GetFirstMem();
|
||||
bool IsMember(unsigned long CharID_In);
|
||||
|
||||
bool PartyMemLogin(unsigned long dwCharID_In, unsigned long dwServer_In);
|
||||
bool PartyMemLogout(unsigned long dwCharID_In);
|
||||
void PartyMemAllLogout();
|
||||
|
||||
bool IsLogined(unsigned long CharID_In);
|
||||
bool IsLoginedByIndex(unsigned long Index) { return m_Party.ServerID[Index]; }
|
||||
|
||||
bool TransferLeader(unsigned long OldLeaderID, unsigned long NewLeaderID);
|
||||
bool InsertPartyMem(unsigned long ServerID_In, unsigned long CharID_In, unsigned short Class_In, char Level_In, unsigned long GID_In, const char* CharName_In);
|
||||
bool DeletePartyMem(unsigned long CharID_In, unsigned long& ServerID_Out);
|
||||
|
||||
bool AutoRouting(unsigned long CharID_In, bool bOn, bool bAll = false);
|
||||
|
||||
const PARTY& GetParty() const { return m_Party; }
|
||||
|
||||
unsigned long GetPID() { return m_Party.m_dwPartyID; }
|
||||
unsigned long GetLeader() { return m_Party.m_dwLeaderID; }
|
||||
unsigned long GetPartyMemNum() { return m_Party.m_cMemberNum; }
|
||||
|
||||
unsigned long SetPID(unsigned long PID_In) { return m_Party.m_dwPartyID = PID_In; }
|
||||
unsigned long SetLeader(unsigned long ID_In) { return m_Party.m_dwLeaderID = ID_In; }
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> //
|
||||
|
||||
const PARTY_USERINFO& GetPartyUserInfo() const { return m_PartyUserInfo; }
|
||||
|
||||
bool SetUserInfoLevel(unsigned long dwCID, char cLevel);
|
||||
bool SetUserInfoClass(unsigned long dwCID, unsigned short wClass);
|
||||
bool SetUserInfoGID(unsigned long dwCID, unsigned long dwGID);
|
||||
|
||||
private:
|
||||
|
||||
PARTY m_Party; // <20><>Ƽ<EFBFBD><C6BC> <20>⺻ <20><><EFBFBD><EFBFBD>.
|
||||
bool m_bAutoRouting[PARTY::MAX_MEM];
|
||||
|
||||
PARTY_USERINFO m_PartyUserInfo; // <20><>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,709 @@
|
||||
#include "stdafx.h"
|
||||
#include "PartyDBMgr.h"
|
||||
#include "PartyDBInfo.h"
|
||||
|
||||
#include <Network/SendPacket/SendParty.h>
|
||||
#include <Network/Dispatch/GameDispatch.h>
|
||||
|
||||
#include <DataStorage/CharacterData.h>
|
||||
#include <DataStorage/CharacterDataMgr.h>
|
||||
|
||||
#include <DataStorage/SessionData.h>
|
||||
#include <DataStorage/SessionDataMgr.h>
|
||||
|
||||
#include <DB/DBComponent.h>
|
||||
#include <DB/GameDBComponent.h>
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
|
||||
#include <Network/Packet/PacketStruct/PartyPacket.h>
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
namespace DBAgent
|
||||
{
|
||||
|
||||
CPartyDBMgr& CPartyDBMgr::GetInstance()
|
||||
{
|
||||
static CPartyDBMgr partyDBMgr;
|
||||
return partyDBMgr;
|
||||
}
|
||||
|
||||
CPartyDBMgr::CPartyDBMgr()
|
||||
: m_PartyDBPool(sizeof(CPartyDBInfo))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
CPartyDBInfo* CPartyDBMgr::CreatePartyDBInfo(unsigned long dwPID)
|
||||
{
|
||||
return new CPartyDBInfo(dwPID);
|
||||
|
||||
// return new (m_PartyDBPool.malloc()) CPartyDBInfo(dwPID);
|
||||
}
|
||||
|
||||
void CPartyDBMgr::DeletePartyDBInfo(CPartyDBInfo* lpPartyDBInfo)
|
||||
{
|
||||
delete lpPartyDBInfo;
|
||||
|
||||
// lpPartyDBInfo->~CPartyDBInfo();
|
||||
// m_PartyDBPool.free(lpPartyDBInfo);
|
||||
}
|
||||
|
||||
|
||||
CPartyDBMgr::~CPartyDBMgr()
|
||||
{
|
||||
PartyMap::iterator pos = m_PartyMap.begin();
|
||||
PartyMap::iterator end = m_PartyMap.end();
|
||||
|
||||
for(; pos != end; ++pos)
|
||||
{
|
||||
DeletePartyDBInfo(pos->second);
|
||||
}
|
||||
|
||||
m_PartyMap.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CPartyDBMgr::InsertPartyMap(unsigned long dwPartyID, CPartyDBInfo* lpParty)
|
||||
{
|
||||
m_PartyMap.insert(std::make_pair(dwPartyID, lpParty)).second;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPartyDBMgr::DeletePartyMap(unsigned long dwPartyID)
|
||||
{
|
||||
PartyMap::iterator itr = m_PartyMap.find(dwPartyID);
|
||||
if (itr == m_PartyMap.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
itr->second->~CPartyDBInfo();
|
||||
DeletePartyDBInfo(itr->second);
|
||||
|
||||
m_PartyMap.erase(dwPartyID);
|
||||
return true;
|
||||
}
|
||||
|
||||
CPartyDBInfo* CPartyDBMgr::FindPartyMap(unsigned long dwPartyID_In)
|
||||
{
|
||||
PartyMap::iterator itr = m_PartyMap.find(dwPartyID_In);
|
||||
if (itr == m_PartyMap.end())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CPartyDBInfo* CPartyDBMgr::OpenParty(CDBComponent& DBComponent, unsigned long dwPartyID)
|
||||
{
|
||||
CPartyDBInfo* lpParty = 0;
|
||||
|
||||
if (0 != dwPartyID)
|
||||
{
|
||||
lpParty = FindPartyMap(dwPartyID);
|
||||
|
||||
if (0 == lpParty)
|
||||
{
|
||||
// <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
PARTY_DB_INFO PartyDBInfo = {0,};
|
||||
|
||||
if (!DBComponent::GameDB::GetPartyInfo(DBComponent, dwPartyID, &PartyDBInfo))
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ<EFBFBD><C6BC> GetPartyInfo<66><6F> ȣ<><C8A3><EFBFBD>ϴµ<CFB4> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>.", dwPartyID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lpParty = CreatePartyDBInfo(dwPartyID);
|
||||
if (0 == lpParty)
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.", dwPartyID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lpParty->SerializeIn(PartyDBInfo.PartyInfo, PartyDBInfo.PartyUserInfo))
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> Serialize<7A><65> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.", dwPartyID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// <20><>Ƽ <20>ʿ<EFBFBD> <20>߰<EFBFBD>
|
||||
InsertPartyMap(dwPartyID, lpParty);
|
||||
}
|
||||
}
|
||||
|
||||
return lpParty;
|
||||
}
|
||||
|
||||
bool CPartyDBMgr::CloseParty(CDBComponent& DBComponent, unsigned long dwPartyID)
|
||||
{
|
||||
CPartyDBInfo* lpParty = OpenParty(DBComponent, dwPartyID);
|
||||
if (0 == lpParty)
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>", dwPartyID);
|
||||
return false;
|
||||
}
|
||||
|
||||
PARTY_DB_INFO PartyInfo = {0,};
|
||||
|
||||
if (!lpParty->SerializeOut(PartyInfo.PartyInfo, PartyInfo.PartyUserInfo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!DBComponent::GameDB::UpdatePartyInfo(DBComponent, dwPartyID, &PartyInfo))
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ<EFBFBD><C6BC> UpdatePartyInfo<66><6F> ȣ<><C8A3><EFBFBD>ϴµ<CFB4> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>.", dwPartyID);
|
||||
return false;
|
||||
}
|
||||
|
||||
RULLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20>ݱ<EFBFBD>.", dwPartyID);
|
||||
return DeletePartyMap(dwPartyID);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CPartyDBInfo* CPartyDBMgr::CreateParty(CDBComponent& DBComponent, unsigned long dwLeaderID, char cLeaderLevel, unsigned short wLeaderClass, unsigned long dwLeaderGID,
|
||||
unsigned long dwMemberID, char cMemberLevel, unsigned short wMemberClass, unsigned long dwMemberGID)
|
||||
{
|
||||
using namespace DataStorage;
|
||||
|
||||
CSessionData* lpLeaderSessionData =
|
||||
CSessionDataMgr::GetInstance().GetCharLoadedSession(dwLeaderID);
|
||||
|
||||
CSessionData* lpMemberSessionData =
|
||||
CSessionDataMgr::GetInstance().GetCharLoadedSession(dwMemberID);
|
||||
|
||||
CCharacterData* lpLeaderCharData = 0;
|
||||
CCharacterData* lpMemberCharData = 0;
|
||||
|
||||
CPartyDBInfo* lpParty = 0;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>Ἲ <20>˻<EFBFBD>.
|
||||
if (0 == lpLeaderSessionData || 0 == lpMemberSessionData)
|
||||
{
|
||||
ERRLOG4(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : LeaderCID:%10u(0x%p) / MemberCID:%10u(0x%p) / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.",
|
||||
dwLeaderID, lpLeaderSessionData, dwMemberID, lpMemberSessionData);
|
||||
}
|
||||
else if(CSessionData::SE_CHAR_ENABLED != lpLeaderSessionData->GetSessionState() ||
|
||||
CSessionData::SE_CHAR_ENABLED != lpMemberSessionData->GetSessionState())
|
||||
{
|
||||
ERRLOG4(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : LeaderCID:%10u(ST:%s) / MemberCID:%10u(ST:%s) / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD> <20><><EFBFBD>°<EFBFBD> Ȱ<><C8B0>ȭ<EFBFBD><C8AD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.",
|
||||
dwLeaderID, g_szSessionStateString[lpLeaderSessionData->GetSessionState()],
|
||||
dwMemberID, g_szSessionStateString[lpMemberSessionData->GetSessionState()]);
|
||||
}
|
||||
else if(0 == (lpLeaderCharData = lpLeaderSessionData->GetCharacterData()) ||
|
||||
0 == (lpMemberCharData = lpMemberSessionData->GetCharacterData()))
|
||||
{
|
||||
ERRLOG4(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : LeaderCID:%10u(CharData:0x%p) / MemberCID:%10u(CharData:0x%p) / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.",
|
||||
dwLeaderID, lpLeaderCharData, dwMemberID, lpMemberCharData);;
|
||||
}
|
||||
else
|
||||
{
|
||||
PARTY_DB_INFO PartyInfo = {0,};
|
||||
|
||||
PartyInfo.PartyInfo.MemberCID[0] = lpLeaderCharData->GetCID();
|
||||
PartyInfo.PartyUserInfo.m_cLevel[0] = cLeaderLevel;
|
||||
PartyInfo.PartyUserInfo.m_wClass[0] = wLeaderClass;
|
||||
PartyInfo.PartyUserInfo.m_dwGID[0] = dwLeaderGID;
|
||||
strncpy(PartyInfo.PartyInfo.Name[0], lpLeaderCharData->GetName(), CHAR_INFOST::MAX_NAME_LEN);
|
||||
|
||||
|
||||
PartyInfo.PartyInfo.MemberCID[1] = lpMemberCharData->GetCID();
|
||||
PartyInfo.PartyUserInfo.m_cLevel[1] = cMemberLevel;
|
||||
PartyInfo.PartyUserInfo.m_wClass[1] = wMemberClass;
|
||||
PartyInfo.PartyUserInfo.m_dwGID[1] = dwMemberGID;
|
||||
strncpy(PartyInfo.PartyInfo.Name[1], lpMemberCharData->GetName(), CHAR_INFOST::MAX_NAME_LEN);
|
||||
|
||||
// DB <20><>Ƽ <20><><EFBFBD><EFBFBD>
|
||||
unsigned long dwPartyID = 0;
|
||||
|
||||
if (!DBComponent::GameDB::InsertParty(DBComponent, &PartyInfo, &dwPartyID))
|
||||
{
|
||||
ERRLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / LeaderCID:%10u / MemberCID:%10u / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ<EFBFBD><C6BC> InsertParty<74><79> ȣ<><C8A3><EFBFBD>ϴµ<CFB4> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>.",
|
||||
dwPartyID, dwLeaderID, dwMemberID);
|
||||
}
|
||||
else if (0 == dwPartyID)
|
||||
{
|
||||
ERRLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / LeaderCID:%10u / MemberCID:%10u / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : DB<44><42><EFBFBD><EFBFBD> <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>.",
|
||||
dwPartyID, dwLeaderID, dwMemberID);
|
||||
}
|
||||
else if (0 == (lpParty = CreatePartyDBInfo(dwPartyID)))
|
||||
{
|
||||
ERRLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / LeaderCID:%10u / MemberCID:%10u / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : CPartyDBInfo<66><6F><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwLeaderID, dwMemberID);
|
||||
}
|
||||
else if (!lpParty->SerializeIn(PartyInfo.PartyInfo, PartyInfo.PartyUserInfo))
|
||||
{
|
||||
DeletePartyDBInfo(lpParty);
|
||||
lpParty = 0;
|
||||
|
||||
ERRLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / LeaderCID:%10u / MemberCID:%10u / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Serialize <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwLeaderID, dwMemberID);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpParty->PartyMemLogin(dwLeaderID, lpLeaderSessionData->GetServerID());
|
||||
lpParty->PartyMemLogin(dwMemberID, lpMemberSessionData->GetServerID());
|
||||
|
||||
InsertPartyMap(dwPartyID, lpParty);
|
||||
|
||||
RULLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / LeaderCID:%10u / MemberCID;%10u / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ", dwPartyID, dwLeaderID, dwMemberID);
|
||||
}
|
||||
}
|
||||
|
||||
return lpParty;
|
||||
}
|
||||
|
||||
bool CPartyDBMgr::DestoryParty(CDBComponent& DBComponent, unsigned long dwPartyID)
|
||||
{
|
||||
CPartyDBInfo* lpParty = FindPartyMap(dwPartyID);
|
||||
if (0 == lpParty)
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20>Ҹ<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>", dwPartyID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (MIN_MEMBER_NUM != lpParty->GetPartyMemNum())
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20>Ҹ<EFBFBD> <20><><EFBFBD><EFBFBD> : <20>ο<EFBFBD><CEBF><EFBFBD><EFBFBD><EFBFBD> <20>ּ<EFBFBD><D6BC>ο<EFBFBD><CEBF><EFBFBD> <20>ƴմϴ<D5B4>", dwPartyID);
|
||||
return false;
|
||||
}
|
||||
|
||||
PARTY_DB_INFO PartyInfo = {0,};
|
||||
if (!lpParty->SerializeOut(PartyInfo.PartyInfo, PartyInfo.PartyUserInfo))
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20>Ҹ<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>", dwPartyID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!DBComponent::GameDB::DeleteParty(DBComponent, &PartyInfo, dwPartyID))
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20>Ҹ<EFBFBD> <20><><EFBFBD><EFBFBD> : DBȣ<42><C8A3> DeleteParty<74><79> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>.", dwPartyID);
|
||||
return false;
|
||||
}
|
||||
|
||||
// ij<><C4B3> DB<44><42> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD> <20>ִ<EFBFBD> ij<><C4B3><EFBFBD>ʹ<EFBFBD> PID <20>缳<EFBFBD><E7BCB3> <20><><EFBFBD>־<EFBFBD><D6BE><EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
using namespace DataStorage;
|
||||
|
||||
CCharacterData* lpMember = 0;
|
||||
for (unsigned long nCount = 0; nCount < lpParty->GetPartyMemNum(); ++nCount)
|
||||
{
|
||||
if (0 == lpParty->IsLoginedByIndex(nCount))
|
||||
{
|
||||
lpMember = static_cast<CCharacterData*>(CCharacterDataMgr::GetInstance().GetLogoutData(PartyInfo.PartyInfo.MemberCID[nCount]));
|
||||
|
||||
if (0 != lpMember)
|
||||
{
|
||||
if (dwPartyID == lpMember->GetPID())
|
||||
{
|
||||
RULLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:10u / <20><>Ƽ <20>Ҹ<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20>Ҹ<EFBFBD><D2B8><EFBFBD>, ij<><C4B3> ij<><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PID<49><44><EFBFBD><EFBFBD>",
|
||||
dwPartyID, PartyInfo.PartyInfo.MemberCID[nCount]);
|
||||
|
||||
lpMember->SetPID(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendPacket::DeleteParty(lpParty);
|
||||
|
||||
RULLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / <20><>Ƽ <20>Ҹ<EFBFBD> <20><><EFBFBD><EFBFBD>", dwPartyID);
|
||||
return DeletePartyMap(dwPartyID);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool CPartyDBMgr::InsertPartyMember(CDBComponent& DBComponent, unsigned long dwPartyID, unsigned long dwCharID, unsigned long dwGID,
|
||||
unsigned short wClass, char cLevel)
|
||||
{
|
||||
using namespace DataStorage;
|
||||
|
||||
CSessionData* lpInsertMember = CSessionDataMgr::GetInstance().GetCharLoadedSession(dwCharID);
|
||||
CCharacterData* lpInsertMemberCharData = 0;
|
||||
CPartyDBInfo* lpParty = 0;
|
||||
|
||||
PARTY_DB_INFO PartyInfo = {0,};
|
||||
|
||||
if(0 == lpInsertMember)
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if(0 == (lpParty = OpenParty(DBComponent, dwPartyID)))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD> : ij<><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if(0 == (lpInsertMemberCharData = lpInsertMember->GetCharacterData()))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD>ǿ<EFBFBD> ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if(!lpParty->InsertPartyMem(lpInsertMember->GetServerID(), dwCharID, wClass, cLevel, dwGID, lpInsertMemberCharData->GetName()))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ<EFBFBD><C6BC> ij<><C4B3><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!lpParty->SerializeOut(PartyInfo.PartyInfo, PartyInfo.PartyUserInfo))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if(!DBComponent::GameDB::InsertPartyMember(DBComponent, dwPartyID, &PartyInfo, dwCharID))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD> : DB<44><42> InsertPartyMember ȣ<><C8A3> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if(!SendPacket::PartyCmd(PktDD::SCmdInsertPartyMem, lpParty->GetPID(), dwCharID, dwGID,
|
||||
wClass, lpInsertMember->GetServerID(), cLevel, lpInsertMemberCharData->GetName()))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD> <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DETLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD>", dwPartyID, dwCharID);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPartyDBMgr::DeletePartyMember(CDBComponent& DBComponent, unsigned long dwPartyID,
|
||||
unsigned long dwCharID, unsigned long dwReference)
|
||||
{
|
||||
CPartyDBInfo* lpParty = OpenParty(DBComponent, dwPartyID);
|
||||
if (0 == lpParty)
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (MIN_MEMBER_NUM == lpParty->GetPartyMemNum())
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
return DestoryParty(DBComponent, dwPartyID);
|
||||
}
|
||||
|
||||
unsigned long dwServerID = 0;
|
||||
unsigned long dwOldLeader = lpParty->GetLeader();
|
||||
if (!lpParty->DeletePartyMem(dwCharID, dwServerID))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DETLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>", dwPartyID, dwCharID);
|
||||
|
||||
PARTY_DB_INFO PartyInfo = {0,};
|
||||
if (!lpParty->SerializeOut(PartyInfo.PartyInfo, PartyInfo.PartyUserInfo))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if(!DBComponent::GameDB::DeletePartyMember(DBComponent, dwPartyID, &PartyInfo, dwCharID))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : DB<44><42> DeletePartyMember ȣ<><C8A3> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> üũ
|
||||
unsigned long dwLeader = lpParty->GetLeader();
|
||||
if (dwOldLeader != dwLeader)
|
||||
{
|
||||
// <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٲ<EFBFBD>
|
||||
dwReference = dwLeader;
|
||||
}
|
||||
|
||||
if(!SendPacket::PartyCmd(PktDD::SCmdDeletePartyMem, lpParty->GetPID(), dwCharID, dwReference, 0, 0, 0, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ٲ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
}
|
||||
|
||||
if (0 == dwLeader)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ƽ<EFBFBD><C6BC> <20>ݴ´<DDB4>.
|
||||
if(CloseParty(DBComponent, dwPartyID))
|
||||
{
|
||||
DETLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / Leader:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><>Ƽ<EFBFBD><C6BC> <20>ݽ<EFBFBD><DDBD>ϴ<EFBFBD>.",
|
||||
dwPartyID, dwCharID, dwLeader);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPartyDBMgr::AutoRoutingOn(CDBComponent& DBComponent, unsigned long dwPartyID, unsigned long dwCharID)
|
||||
{
|
||||
// CharID <20><> 0 <20≯<EFBFBD> ALL
|
||||
CPartyDBInfo* lpParty = OpenParty(DBComponent, dwPartyID);
|
||||
if (0 == lpParty)
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ON <20><><EFBFBD><EFBFBD> : <20><>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!lpParty->AutoRouting(dwCharID, true, (0 == dwCharID) ? true : false))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ON <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ѱ<EFBFBD> <20><><EFBFBD><EFBFBD> (CID<49><44> 0<≯<EFBFBD> <20><><EFBFBD><EFBFBD>)",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return SendPacket::PartyCmd(PktDD::SCmdAutoRoutingOn, lpParty->GetPID(), dwCharID, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
bool CPartyDBMgr::AutoRoutingOff(CDBComponent& DBComponent, unsigned long dwPartyID, unsigned long dwCharID)
|
||||
{
|
||||
// CharID <20><> 0 <20≯<EFBFBD> ALL
|
||||
CPartyDBInfo* lpParty = OpenParty(DBComponent, dwPartyID);
|
||||
if (0 == lpParty)
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> OFF <20><><EFBFBD><EFBFBD> : <20><>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == lpParty->AutoRouting(dwCharID, false, (0 == dwCharID) ? true : false))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> OFF <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ѱ<EFBFBD> <20><><EFBFBD><EFBFBD> (CID<49><44> 0<≯<EFBFBD> <20><><EFBFBD><EFBFBD>)",
|
||||
dwPartyID, dwCharID);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return SendPacket::PartyCmd(PktDD::SCmdAutoRoutingOff, lpParty->GetPID(), dwCharID, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void CPartyDBMgr::LoginPartyMember(CPartyDBInfo* lpParty, unsigned long dwUserID, unsigned long dwCharID, unsigned long dwGID,
|
||||
unsigned short wClass, unsigned long dwServerID, char cLevel)
|
||||
{
|
||||
if (0 == lpParty)
|
||||
{
|
||||
ERRLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : UID:%10u / CID:%10u / ServerID:0x%08X / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>", dwUserID, dwCharID, dwServerID);
|
||||
}
|
||||
else if (!lpParty->IsMember(dwCharID))
|
||||
{
|
||||
ERRLOG4(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / UID:%10u / CID:%10u / ServerID:0x%08X / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴմϴ<D5B4>",
|
||||
lpParty->GetPID(), dwUserID, dwCharID, dwServerID);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long dwPartyID = lpParty->GetPID();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> DB<44><42><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ȯ<><C8AE>
|
||||
|
||||
using namespace DataStorage;
|
||||
|
||||
CSessionData* lpSessionData = CSessionDataMgr::GetInstance().GetCharLoadedSession(dwCharID);
|
||||
CCharacterData* lpCharacterData = 0;
|
||||
|
||||
if (0 == dwPartyID || 0 == lpSessionData || 0 == (lpCharacterData = lpSessionData->GetCharacterData()))
|
||||
{
|
||||
ERRLOG6(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / UID:%10u / CID:%10u(Session:0x%p/Character:0x%p) / ServerID:0x%08X / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD> Ȥ<><C8A4> ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>",
|
||||
dwPartyID, dwUserID, dwCharID, lpSessionData, lpCharacterData, dwServerID);
|
||||
}
|
||||
else if (lpCharacterData->GetPID() != dwPartyID)
|
||||
{
|
||||
ERRLOG5(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CharacterDataPID:%10u / UID:%10u / CID:%10u / ServerID:0x%08X / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>û PID<49><44> ij<><C4B3><EFBFBD><EFBFBD> PID<49><44> <20>ٸ<EFBFBD><D9B8>ϴ<EFBFBD>",
|
||||
dwPartyID, lpCharacterData->GetPID(), dwUserID, dwCharID, dwServerID);
|
||||
}
|
||||
else if (!lpParty->PartyMemLogin(dwCharID, dwServerID))
|
||||
{
|
||||
GET_MULTI_DISPATCH(lpGameDispatch, dwServerID,
|
||||
DBAgent::CGameDispatch, DBAgent::CGameDispatch::GetDispatchTable());
|
||||
|
||||
if(0 != lpGameDispatch)
|
||||
{
|
||||
ERRLOG4(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / UID:%10u / CID:%10u / ServerID:0x%08X / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwUserID, dwCharID, dwServerID);
|
||||
|
||||
SendPacket::PartyCmd(lpGameDispatch->GetSendStream(), PktDD::SCmdLoginPartyMem,
|
||||
dwPartyID, dwCharID, dwGID, wClass, dwServerID, cLevel, lpCharacterData->GetName(), 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DETLOG4(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / UID:%10u / CID:%10u / ServerID:0x%08X / "
|
||||
"<EFBFBD><EFBFBD>Ƽ <20><><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD>", dwPartyID, dwUserID, dwCharID, dwServerID);
|
||||
|
||||
CPartyDBInfo* lpParty = CPartyDBMgr::GetInstance().OpenParty(CDBSingleObject::GetInstance(), dwPartyID);
|
||||
|
||||
if(lpParty)
|
||||
{
|
||||
// ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ //
|
||||
lpParty->SetUserInfoLevel(dwCharID, cLevel);
|
||||
lpParty->SetUserInfoClass(dwCharID, wClass);
|
||||
lpParty->SetUserInfoGID(dwCharID, dwGID);
|
||||
}
|
||||
|
||||
SendPacket::PartyCmd(PktDD::SCmdLoginPartyMem, lpParty->GetPID(),
|
||||
dwCharID, dwGID, wClass, dwServerID, cLevel, lpCharacterData->GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPartyDBMgr::LogoutPartyMember(CDBComponent& DBComponent, CPartyDBInfo* lpParty, unsigned long dwCharID)
|
||||
{
|
||||
if (0 == lpParty)
|
||||
{
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>αƿ<D7BE> <20><><EFBFBD><EFBFBD> : <20><>Ƽ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>", dwCharID);
|
||||
}
|
||||
else if (!lpParty->IsMember(dwCharID))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>αƿ<D7BE> <20><><EFBFBD><EFBFBD> : <20><>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD> <20>ƴմϴ<D5B4>",
|
||||
lpParty->GetPID(), dwCharID);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long dwPartyID = lpParty->GetPID();
|
||||
unsigned long dwOldLeader = lpParty->GetLeader();
|
||||
|
||||
if (!lpParty->PartyMemLogout(dwCharID))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>αƿ<D7BE> <20><><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD> <20>αƿ<D7BE> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long dwLeader = lpParty->GetLeader();
|
||||
unsigned long dwReference = 0;
|
||||
if (dwOldLeader != dwLeader)
|
||||
{
|
||||
dwReference = dwLeader;
|
||||
}
|
||||
|
||||
DETLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / NewLeader:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>αƿ<D7BE> <20><><EFBFBD><EFBFBD>",
|
||||
dwPartyID, dwCharID, dwReference);
|
||||
|
||||
SendPacket::PartyCmd(PktDD::SCmdLogoutPartyMem, lpParty->GetPID(), dwCharID, dwReference, 0, 0, 0, 0);
|
||||
|
||||
if (0 == dwLeader)
|
||||
{
|
||||
// <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
if(CloseParty(DBComponent, dwPartyID))
|
||||
{
|
||||
DETLOG3(g_Log, "<EFBFBD><EFBFBD>Ƽ <20>α<EFBFBD> : PID:%10u / CID:%10u / Leader:%10u / <20><>Ƽ <20><><EFBFBD><EFBFBD> <20>αƿ<D7BE> : <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><>Ƽ<EFBFBD><C6BC> <20>ݽ<EFBFBD><DDBD>ϴ<EFBFBD>.",
|
||||
dwPartyID, dwCharID, dwLeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPartyDBMgr::SendToGameServerPartyData(CSendStream& SendStream)
|
||||
{
|
||||
// <20><>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>. //]
|
||||
PartyMap::iterator start = m_PartyMap.begin();
|
||||
PartyMap::iterator end = m_PartyMap.end();
|
||||
|
||||
for(; start!=end; ++start)
|
||||
{
|
||||
// <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD> //
|
||||
CPartyDBInfo* lpPartyDBInfo = start->second;
|
||||
|
||||
if(lpPartyDBInfo)
|
||||
{
|
||||
// <20><>Ƽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //
|
||||
|
||||
PARTY sParty = lpPartyDBInfo->GetParty();
|
||||
|
||||
char* lpBuffer = SendStream.GetBuffer(sizeof(PktPIDAck));
|
||||
|
||||
PktPIDAck* lppktPIDAck = reinterpret_cast<PktPIDAck*>(lpBuffer);
|
||||
|
||||
memset(lppktPIDAck, 0, sizeof(PktPIDAck));
|
||||
|
||||
lppktPIDAck->m_wCmd = PktDD::SCmdGetPartyInfo;
|
||||
lppktPIDAck->m_Party = lpPartyDBInfo->GetParty();
|
||||
|
||||
SendStream.WrapHeader(sizeof(PktPIDAck), CmdAgentParty, 0, PktPMD::NO_SERVER_ERR);
|
||||
|
||||
// <20><>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //
|
||||
PARTY_USERINFO sPartyUserInfo = lpPartyDBInfo->GetPartyUserInfo();
|
||||
|
||||
for(unsigned char cIndex = 0; cIndex < PARTY::MAX_MEM; cIndex++)
|
||||
{
|
||||
// <20>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ӵǾ<D3B5><C7BE>ִ<EFBFBD> ij<><C4B3><EFBFBD><EFBFBD> //
|
||||
if(sParty.MemberCID[cIndex] && sParty.ServerID[cIndex])
|
||||
{
|
||||
char* lpBuffer = SendStream.GetBuffer(sizeof(PktPMD));
|
||||
|
||||
if(0 != lpBuffer)
|
||||
{
|
||||
PktPMD* lpPktPMD = reinterpret_cast<PktPMD*>(lpBuffer);
|
||||
|
||||
lpPktPMD->m_wCmd = PktDD::SCmdLoginPartyMem;
|
||||
lpPktPMD->m_dwPartyID = sParty.m_dwPartyID;
|
||||
lpPktPMD->m_dwSenderID = sParty.MemberCID[cIndex];
|
||||
lpPktPMD->m_dwGID = sPartyUserInfo.m_dwGID[cIndex];
|
||||
lpPktPMD->m_wClass = sParty.m_wClass[cIndex];
|
||||
lpPktPMD->m_dwServerID = sParty.ServerID[cIndex];
|
||||
lpPktPMD->m_cLevel = sParty.m_cLevel[cIndex];
|
||||
|
||||
if(sParty.Name[cIndex])
|
||||
{
|
||||
strncpy(lpPktPMD->m_strSenderName, sParty.Name[cIndex], CHAR_INFOST::MAX_NAME_LEN);
|
||||
lpPktPMD->m_strSenderName[CHAR_INFOST::MAX_NAME_LEN - 1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(lpPktPMD->m_strSenderName, 0, sizeof(char) * CHAR_INFOST::MAX_NAME_LEN);
|
||||
}
|
||||
|
||||
SendStream.WrapHeader(sizeof(PktPMD), CmdAgentParty, 0, PktPMD::NO_SERVER_ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#ifndef _RYL_DBAGENT_PARTY_DB_MGR_H_
|
||||
#define _RYL_DBAGENT_PARTY_DB_MGR_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <boost/pool/pool_alloc.hpp>
|
||||
#include <boost/pool/pool.hpp>
|
||||
|
||||
// forward decl.
|
||||
class CDBComponent;
|
||||
class CSendStream;
|
||||
|
||||
namespace DBAgent
|
||||
{
|
||||
|
||||
// forward delc.
|
||||
class CPartyDBInfo;
|
||||
|
||||
class CPartyDBMgr
|
||||
{
|
||||
public:
|
||||
|
||||
static CPartyDBMgr& GetInstance();
|
||||
|
||||
CPartyDBInfo* OpenParty(CDBComponent& DBComponent, unsigned long dwPartyID);
|
||||
bool CloseParty(CDBComponent& DBComponent, unsigned long dwPartyID);
|
||||
|
||||
CPartyDBInfo* CreateParty(CDBComponent& DBComponent, unsigned long dwLeaderID, char cLeaderLevel, unsigned short wLeaderClass, unsigned long dwLeaderGID,
|
||||
unsigned long dwMemberID, char cMemberLevel, unsigned short wMemberClass, unsigned long dwMemberGID);
|
||||
|
||||
bool DestoryParty(CDBComponent& DBComponent, unsigned long dwPartyID);
|
||||
|
||||
bool InsertPartyMember(CDBComponent& DBComponent, unsigned long dwPartyID, unsigned long dwCharID, unsigned long dwGID,
|
||||
unsigned short wClass, char cLevel);
|
||||
|
||||
bool DeletePartyMember(CDBComponent& DBComponent, unsigned long dwPartyID,
|
||||
unsigned long dwCharID, unsigned long dwReference);
|
||||
|
||||
bool AutoRoutingOn(CDBComponent& DBComponent, unsigned long dwPartyID, unsigned long dwCharID);
|
||||
bool AutoRoutingOff(CDBComponent& DBComponent, unsigned long dwPartyID, unsigned long dwCharID);
|
||||
|
||||
bool InsertPartyMap(unsigned long dwPartyID, CPartyDBInfo* lpParty);
|
||||
bool DeletePartyMap(unsigned long dwPartyID);
|
||||
CPartyDBInfo* FindPartyMap(unsigned long dwPartyID_In);
|
||||
|
||||
void LoginPartyMember(CPartyDBInfo* lpParty, unsigned long dwUserID, unsigned long dwCharID, unsigned long dwGID,
|
||||
unsigned short wClass, unsigned long dwServerID, char cLevel);
|
||||
|
||||
void LogoutPartyMember(CDBComponent& DBComponent, CPartyDBInfo* lpParty, unsigned long dwCharID);
|
||||
|
||||
void SendToGameServerPartyData(CSendStream& SendStream);
|
||||
|
||||
private:
|
||||
|
||||
CPartyDBMgr();
|
||||
~CPartyDBMgr();
|
||||
|
||||
CPartyDBInfo* CreatePartyDBInfo(unsigned long dwPID);
|
||||
void DeletePartyDBInfo(CPartyDBInfo* lpPartyDBInfo);
|
||||
|
||||
enum Const
|
||||
{
|
||||
MIN_MEMBER_NUM = 2
|
||||
};
|
||||
|
||||
typedef std::map<unsigned long, CPartyDBInfo*, std::less<unsigned long>,
|
||||
boost::fast_pool_allocator<std::pair<unsigned long, CPartyDBInfo*> > > PartyMap;
|
||||
|
||||
PartyMap m_PartyMap;
|
||||
boost::pool<> m_PartyDBPool;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user