📄 handler_mw.cpp
字号:
#include "StdAfx.h"
#include ".\handler_MW.h"
#include "WorldServer.h"
#include "MasterServerSession.h"
#include "UserManager.h"
#include "ChannelManager.h"
#include "Channel.h"
#include <PacketStruct_MW.h>
#include <Protocol_MW.h>
#include <Protocol_ServerCommon.h>
#include <PacketStruct_ServerCommon.h>
#include <PacketStruct_CW.h>
#include <GMList.h>
VOID Handler_MW::OnMW_NOTICE_CMD( MasterServerSession *pMasterServer, MSG_BASE *pMsg, WORD wSize )
{
MSG_MW_NOTICE_CMD *pRecvMsg = (MSG_MW_NOTICE_CMD*)pMsg;
if( pRecvMsg->dwNoticeLength > MAX_NOTICE_LEN )
{
MessageOut(eCRITICAL_LOG, "傍瘤 辨捞 檬苞(%d)", pRecvMsg->dwNoticeLength );
return;
}
SERVER_KEY serverKey = pRecvMsg->dwServerUID;
BYTE byChannelID = serverKey.GetChannelID();
BYTE byServerType = serverKey.GetServerType();
//BYTE byServerID = serverKey.GetServerID();
MSG_CW_NOTICE_BRD noticeMsg;
noticeMsg.m_byCategory = CW_CHAT;
noticeMsg.m_byProtocol = CW_NOTICE_BRD;
noticeMsg.wLen = (WORD)pRecvMsg->dwNoticeLength;
strncpy( noticeMsg.szMsg, pRecvMsg->szNotice, noticeMsg.wLen );
if( byChannelID == 0 )
{
// 盲澄锅龋啊 0牢 版快 岿靛郴 葛电 盲澄 措惑
if( byServerType == 0 )
{
UserManager::Instance()->SendToAll( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
char szNotice[MAX_NOTICE_LEN + 1];
ZeroMemory( szNotice, sizeof(szNotice) );
strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
MessageOut(eCRITICAL_LOG, "-----------------------------<< 傈眉傍瘤 >>-----------------------------" );
MessageOut(eCRITICAL_LOG, "%s", szNotice );
MessageOut(eCRITICAL_LOG, "------------------------------------------------------------------------" );
}
else
{
// 辑滚 鸥涝捞 0捞 酒囱 版快 葛电 盲澄狼 漂沥 粮俊父 傍瘤
switch( byServerType )
{
case FIELD_SERVER:
{
ChannelManager::Instance()->SendToVillages( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
char szNotice[MAX_NOTICE_LEN + 1];
ZeroMemory( szNotice, sizeof(szNotice) );
strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
MessageOut(eCRITICAL_LOG, "------------------------<< 葛电盲澄 付阑傍瘤 >>-------------------------" );
MessageOut(eCRITICAL_LOG, "%s", szNotice );
MessageOut(eCRITICAL_LOG, "------------------------------------------------------------------------" );
}
break;
case BATTLE_SERVER:
{
// ChannelManager::Instance()->SendToBattleZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToLobby( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToMissionZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToHuntingZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToQuestZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToPVPZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToEventZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToGuildZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToSiegeZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
char szNotice[MAX_NOTICE_LEN + 1];
ZeroMemory( szNotice, sizeof(szNotice) );
strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
MessageOut(eCRITICAL_LOG, "------------------------<< 葛电盲澄 傈捧规傍瘤 >>-----------------------" );
MessageOut(eCRITICAL_LOG, "%s", szNotice );
MessageOut(eCRITICAL_LOG, "------------------------------------------------------------------------" );
}
break;
}
}
}
else
{
// 盲澄锅龋啊 0捞 酒聪骨肺 漂沥 盲澄 措惑
Channel *pChannel = ChannelManager::Instance()->GetChannel( byChannelID );
if( byServerType == 0 )
{
// 付阑, 硅撇粮 葛滴 傍瘤
pChannel->SendToAll( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
char szNotice[MAX_NOTICE_LEN + 1];
ZeroMemory( szNotice, sizeof(szNotice) );
strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
MessageOut(eCRITICAL_LOG, "----------------------------<< %d盲澄 傍瘤 >>----------------------------", byChannelID );
MessageOut(eCRITICAL_LOG, "%s", szNotice );
MessageOut(eCRITICAL_LOG, "------------------------------------------------------------------------" );
}
else
{
// 辑滚 鸥涝捞 0捞 酒囱 版快 漂沥 盲澄狼 漂沥 粮俊父 傍瘤
switch( byServerType )
{
case FIELD_SERVER:
{
// 辑滚 酒捞叼啊 0捞搁 秦寸 付阑 傈眉俊 傍瘤
pChannel->SendToVillages( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
char szNotice[MAX_NOTICE_LEN + 1];
ZeroMemory( szNotice, sizeof(szNotice) );
strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
MessageOut(eCRITICAL_LOG, "---------------------------<< %d盲澄 付阑傍瘤 >>-------------------------", byChannelID );
MessageOut(eCRITICAL_LOG, "%s", szNotice );
MessageOut(eCRITICAL_LOG, "------------------------------------------------------------------------" );
}
break;
case BATTLE_SERVER:
{
// pChannel->SendToBattleZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToLobby( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToMissionZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToHuntingZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToQuestZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToPVPZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToEventZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToGuildZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
ChannelManager::Instance()->SendToSiegeZones( (BYTE*)¬iceMsg, noticeMsg.GetSize() );
char szNotice[MAX_NOTICE_LEN + 1];
ZeroMemory( szNotice, sizeof(szNotice) );
strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
MessageOut(eCRITICAL_LOG, "--------------------------<< %d盲澄 傈捧规傍瘤 >>------------------------", byChannelID );
MessageOut(eCRITICAL_LOG, "%s", szNotice );
MessageOut(eCRITICAL_LOG, "------------------------------------------------------------------------" );
}
break;
}
}
}
}
// 付胶磐俊 立加 己傍窍搁 捞菩哦阑 郴妨罐绰促.
VOID Handler_MW::OnMW_SERVER_INFO_CMD( MasterServerSession *pMasterServer, MSG_BASE *pMsg, WORD wSize )
{
MSG_MW_SERVER_INFO_CMD *pRecvMsg = (MSG_MW_SERVER_INFO_CMD*)pMsg;
// 罐篮 辑滚虐 悸泼
WorldServer::Instance()->SetServerKey( pRecvMsg->ServerKey );
MessageOut(eCRITICAL_LOG, "付胶磐肺何磐 罐篮 辑滚虐 悸泼(%d) (%d, %d, %d, %d)", pRecvMsg->ServerKey,
pRecvMsg->ServerKey.GetWorldID(), pRecvMsg->ServerKey.GetChannelID(), pRecvMsg->ServerKey.GetServerType(), pRecvMsg->ServerKey.GetServerID() );
WorldServer::Instance()->UpdateServerTitle();
WorldServer::Instance()->SetGameDBProxyServerAddr( pRecvMsg->m_szGameDBProxyServerIP, pRecvMsg->m_wGameDBProxyServerPort );
// DBProxy辑滚 立加
WorldServer::Instance()->ConnectToGameDBProxyServer();
// 府郊 矫累
WorldServer::Instance()->StartListen( pRecvMsg->m_szWorldServerIP, pRecvMsg->m_wWorldServerPort,
pRecvMsg->m_szWorldServerInnerIP, pRecvMsg->m_wWorldServerInnerPort );
}
// 付胶磐 辑滚肺何磐 GM 府胶飘甫 罐阑 锭
VOID Handler_MW::OnMW_GM_LIST_CMD( MasterServerSession *pMasterServer, MSG_BASE *pMsg, WORD wSize )
{
MSG_MW_GM_LIST_CMD *pRecvMsg = (MSG_MW_GM_LIST_CMD*)pMsg;
for( int i = 0; i < pRecvMsg->byCount; ++i )
{
GMList::Instance()->AddGM( &pRecvMsg->GMInfo[i] );
}
}
// 付胶磐 辑滚啊 硅撇粮 沥焊 夸没
VOID Handler_MW::OnMW_BATTLEZONEINFO_REQ( MasterServerSession *pMasterServer, MSG_BASE *pMsg, WORD wSize )
{
MSG_MW_BATTLEZONEINFO_ANS sendMsg;
CHANNEL_MAP& mapChannel = ChannelManager::Instance()->GetChannelMap();
if( mapChannel.empty() )
{
// 盲澄捞 窍唱档 绝栏搁 价脚 阂啊
sendMsg.byCount = 0;
pMasterServer->Send( (BYTE*)&sendMsg, sendMsg.GetSize() );
}
sendMsg.byCount = (BYTE)mapChannel.size();
CHANNEL_MAP::iterator iter;
int nChannelNum = 0;
Channel *pChannel;
for( iter = mapChannel.begin(); iter != mapChannel.end(); iter++ )
{
pChannel = (*iter).second;
sendMsg.ChannelInfo[nChannelNum].byChannelID = (BYTE)pChannel->GetChannelID();
sendMsg.ChannelInfo[nChannelNum].dwVillageUserCount = pChannel->GetVillageUserNum();
sendMsg.ChannelInfo[nChannelNum].dwLobbyZoneCount = pChannel->GetLobbyZoneCount();
sendMsg.ChannelInfo[nChannelNum].dwLobbyUserCount = pChannel->GetLobbyUserNum();
sendMsg.ChannelInfo[nChannelNum].dwHuntingZoneCount = pChannel->GetHuntingZoneCount();
sendMsg.ChannelInfo[nChannelNum].dwHuntingUserCount = pChannel->GetHuntingUserNum();
sendMsg.ChannelInfo[nChannelNum].dwMissionZoneCount = pChannel->GetMissionZoneCount();
sendMsg.ChannelInfo[nChannelNum].dwMissionUserCount = pChannel->GetMissionUserNum();
sendMsg.ChannelInfo[nChannelNum].dwQuestZoneCount = pChannel->GetQuestZoneCount();
sendMsg.ChannelInfo[nChannelNum].dwQuestUserCount = pChannel->GetQuestUserNum();
sendMsg.ChannelInfo[nChannelNum].dwPVPZoneCount = pChannel->GetPVPZoneCount();
sendMsg.ChannelInfo[nChannelNum].dwPVPUserCount = pChannel->GetPVPUserNum();
sendMsg.ChannelInfo[nChannelNum].dwEventZoneCount = pChannel->GetEventZoneCount();
sendMsg.ChannelInfo[nChannelNum].dwEventUserCount = pChannel->GetEventUserNum();
sendMsg.ChannelInfo[nChannelNum].dwGuildZoneCount = pChannel->GetGuildZoneCount();
sendMsg.ChannelInfo[nChannelNum].dwGuildUserCount = pChannel->GetGuildUserNum();
sendMsg.ChannelInfo[nChannelNum].dwSiegeZoneCount = pChannel->GetSiegeZoneCount();
sendMsg.ChannelInfo[nChannelNum].dwSiegeUserCount = pChannel->GetSiegeUserNum();
nChannelNum++;
}
pMasterServer->Send( (BYTE*)&sendMsg, sendMsg.GetSize() );
}
VOID Handler_MW::OnSERVERCOMMON_SERVERSHUTDOWN_REQ( MasterServerSession *pMasterServer, MSG_BASE *pMsg, WORD wSize )
{
// 沥惑辆丰 甸绢埃促!
WorldServer::Instance()->Shutdown();
// 辆丰茄促绊 舅妨拎~
MSG_SERVERCOMMON_SERVERSHUTDOWN_ANS sendMsg;
sendMsg.m_byCategory = 0;
sendMsg.m_byProtocol = SERVERCOMMON_SERVERSHUTDOWN_ANS;
pMasterServer->Send( (BYTE*)&sendMsg, sizeof(MSG_SERVERCOMMON_SERVERSHUTDOWN_ANS) );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -