⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 handler_cw.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
#include "stdafx.h"
#include "Handler_CW.h"
#include "User.h"
#include "WorldServer.h"
#include "UserManager.h"

//GM魄沥阑 困秦
#include "GMList.h"
#include <PacketStruct_CW.h>
#include <Protocol_CW.h>

// 盲泼 皋矫瘤 傈价阑 困秦
#include "ChannelManager.h"
#include "Channel.h"
#include "Zone.h"
#include "ViewPortManager.h"

// ArmorKit 橇肺配妮 副饭捞 困秦
#include "ServerSession.h"
#include "ServerSessionManager.h"
#include <PacketStruct_MW.h>

// 模备 包府 困秦
#include <PacketStruct_DW.h>
#include <Protocol_DW.h>

// 辨靛 包府 困秦
#include "WorldGuildManager.h"
#include "WorldGuild.h"
#include "WorldGuildMember.h"
#include <PacketStruct_WZ.h>

// GM 胶飘傅 疙飞 颇教 困秦
#include "GMCmdParser.h"
#include "GMCmdString.h"
#include "GMCmdManager.h"

GMCmdManager	Handler_CW::m_GMCmdManager;

VOID Handler_CW::OnCW_HEARTBEAT( User *pUser, MSG_BASE *pMsg, WORD wSize )
{
//	MessageOut( eCRITICAL_LOG, "[%s/%u] HeartBeat Recv", pUser->GetCharName().c_str(), pUser->GetGUID() );
}

VOID Handler_CW::OnCW_WHISPER_SYN( User *pUser, MSG_BASE *pMsg, WORD wSize )
{
	MSG_CW_WHISPER_SYN *pRecvMsg = (MSG_CW_WHISPER_SYN*)pMsg;

	char szTargetCharName[MAX_CHARNAME_LENGTH + 1];
	ZeroMemory( szTargetCharName, sizeof(szTargetCharName) );
	strncpy( szTargetCharName, pRecvMsg->szCharNameTo, MAX_CHARNAME_LENGTH );

	// 庇富 荤捞令啊 呈公 农搁 立加阑 谗绰促.
	if( pRecvMsg->byMsgLen > MAX_CHAT_LEN )
	{
		MessageOut(eCRITICAL_LOG,   "庇富 荤捞令(%d)啊 呈公 目辑 阂啊.", pRecvMsg->byMsgLen );
//		pUser->Disconnect();
		return;
	}

	User *pTargetUser = UserManager::Instance()->FindUser( szTargetCharName );

	// 庇富 措惑捞 绝栏搁 角菩 贸府
	if( !pTargetUser )
	{
		MessageOut(eCRITICAL_LOG,   "庇富 措惑阑 茫阑 荐 绝澜 (%s) to (%s)", pUser->GetCharName().c_str(), szTargetCharName );
		MSG_CW_WHISPER_NAK nakMsg;
		nakMsg.byReason = MSG_CW_WHISPER_NAK::USER_NOT_FOUND;
		pUser->Send( (BYTE*)&nakMsg, sizeof(MSG_CW_WHISPER_NAK) );
		return;
	}

	// 措惑捞 唱 磊脚牢 版快 公矫
	if( pUser == pTargetUser )
	{
		MessageOut( eFULL_LOG, "磊脚俊霸 庇加富 (%s)", pUser->GetCharName().c_str() );
		return;
	}

	// 措惑捞 庇富 荐脚阑 瞒窜沁栏搁 角菩
	if( !pTargetUser->CanWhisper() )
	{
		// 措惑 蜡历啊 GM牢瘤 八荤茄促
		GM_INFO		*pGMInfo;
		pGMInfo = GMList::Instance()->FindGM((const char*)szTargetCharName);

		//GM 蜡历 嘎栏搁 庇富篮 沥惑利栏肺 焊郴瘤父, 蜡历俊霸绰 庇富 焊郴瘤 给茄促绊 舅妨霖促
		if(pGMInfo != NULL)
		{
			MessageOut(eCRITICAL_LOG,   "庇富 瞒窜等 GM 蜡历俊霸 庇富 (%s) to (%s)", pUser->GetCharName().c_str(), szTargetCharName );

			// 庇富 瞒窜等 巴贸烦 舅妨 霖促
			MSG_CW_WHISPER_NAK nakMsg;
			nakMsg.byReason = MSG_CW_WHISPER_NAK::USER_WHISPER_OFF;
			pUser->Send( (BYTE*)&nakMsg, sizeof(MSG_CW_WHISPER_NAK) );

			if( pRecvMsg->byMsgLen >= MAX_CHAT_LEN )
			{
				MessageOut(eCRITICAL_LOG, "%s CW_CHAT_WHISPER_SYN 辨捞檬苞(%u)", pUser->GetCharName().c_str(), pRecvMsg->byMsgLen);
				return;
			}

			// 措惑俊霸 庇富 傈价
			MSG_CW_WHISPER_ACK resMsg;
			_tcsncpy( resMsg.szCharNameFrom, pUser->GetCharName().c_str(), MAX_CHARNAME_LENGTH - 1 );
			resMsg.szCharNameFrom[MAX_CHARNAME_LENGTH-1] = '\0';

			memset( resMsg.szWhisperMsg, 0, sizeof(char) * MAX_CHAT_LEN );
			_tcsncpy( resMsg.szWhisperMsg, pRecvMsg->szWhisperMsg, pRecvMsg->byMsgLen );
			resMsg.szWhisperMsg[pRecvMsg->byMsgLen] = '\0';
			resMsg.byMsgLen = pRecvMsg->byMsgLen;

			//pUser->Send( (BYTE*)&resMsg, resMsg.GetSize() );
			pTargetUser->Send( (BYTE*)&resMsg, resMsg.GetSize() );
		}
		else
		{
			MessageOut(eCRITICAL_LOG,  " 庇富 措惑捞 庇富 荐脚阑 瞒窜 (%s) to (%s)", pUser->GetCharName().c_str(), szTargetCharName );
			MSG_CW_WHISPER_NAK nakMsg;
			nakMsg.byReason = MSG_CW_WHISPER_NAK::USER_WHISPER_OFF;
			pUser->Send( (BYTE*)&nakMsg, sizeof(MSG_CW_WHISPER_NAK) );
		}
		return;
	}

	// 措惑俊霸 庇富 傈价
	MSG_CW_WHISPER_ACK resMsg;
	_tcsncpy( resMsg.szCharNameFrom, pUser->GetCharName().c_str(), MAX_CHARNAME_LENGTH - 1 );
	resMsg.szCharNameFrom[MAX_CHARNAME_LENGTH-1] = '\0';

	memset( resMsg.szWhisperMsg, 0, sizeof(char) * MAX_CHAT_LEN );
	_tcsncpy( resMsg.szWhisperMsg, pRecvMsg->szWhisperMsg, pRecvMsg->byMsgLen );
	resMsg.szWhisperMsg[pRecvMsg->byMsgLen] = '\0';

	resMsg.byMsgLen = pRecvMsg->byMsgLen;

	//pUser->Send( (BYTE*)&resMsg, resMsg.GetSize() );
	pTargetUser->Send( (BYTE*)&resMsg, resMsg.GetSize() );

	char szTemp[1024];
	ZeroMemory( szTemp, sizeof(szTemp) );
	strncpy( szTemp, pRecvMsg->szWhisperMsg, pRecvMsg->byMsgLen );
	TCHAR ptszCharName[MAX_CHARNAME_LENGTH]={0,}, ptszTargetName[MAX_CHARNAME_LENGTH]={0,};
	_tcsncpy( ptszCharName, pUser->GetCharName().c_str(), MAX_CHARNAME_LENGTH - 1 );
	_tcsncpy( ptszTargetName, pTargetUser->GetCharName().c_str(), MAX_CHARNAME_LENGTH - 1 );
	GAMELOG->WriteWhisperChat( NULL, ptszCharName, ptszTargetName, WorldServer::Instance()->GetServerKey(), resMsg.szWhisperMsg );
	MessageOut( eFULL_LOG,   "庇富 (%s) to (%s): %s", pUser->GetCharName().c_str(), szTargetCharName, szTemp );
}

VOID Handler_CW::OnCW_NOTICE_SYN( User *pUser, MSG_BASE *pMsg, WORD wSize )
{
	MSG_CW_NOTICE_SYN *pRecvMsg = (MSG_CW_NOTICE_SYN*)pMsg;

	// 辨捞啊 弥措蔼阑 逞扁搁 立加阑 谗绰促.
/*	if( pRecvMsg->byLen > MAX_NOTICE_LEN )
	{
		pUser->Disconnect();
		return;
	}

	// TODO: 傍瘤 鼻茄捞 绝栏搁 府畔茄促.

	char szNotice[MAX_NOTICE_LEN + 1];
	ZeroMemory( szNotice, sizeof(szNotice) );
	strncpy( szNotice, pRecvMsg->szMsg, pRecvMsg->byLen );

	WorldServer::Instance()->SendNoticeMsg( szNotice );*/
}

// 庇富 难绊 阐(瞒窜) 贸府
VOID Handler_CW::OnCW_WHISPER_SET_SYN( User *pUser, MSG_BASE *pMsg, WORD wSize )
{
	MSG_CW_WHISPER_SET_SYN *pRecvMsg = (MSG_CW_WHISPER_SET_SYN*)pMsg;

	if(!pUser)
	{
		MessageOut(eCRITICAL_LOG,  "庇富 荐脚 咯何 技泼 角菩(pUser == NULL)");
		return;
	}

	// 捞 蜡历狼 庇富 脑/阐 惑怕 技泼
	pUser->SetWhisper(pRecvMsg->bWhisper);

	// 己傍沁澜阑 舅赴促
	MSG_CW_WHISPER_SET_ACK	resMsg;

	resMsg.bWhisper = pRecvMsg->bWhisper;

	pUser->Send( (BYTE*)&resMsg, sizeof(MSG_CW_WHISPER_SET_ACK) );

	MessageOut(eCRITICAL_LOG,  "(%s) 庇富 技泼(%d)", pUser->GetCharName().c_str(), pRecvMsg->bWhisper);
}

// 盲泼 夸没
VOID Handler_CW::OnCW_CHAT_VILLAGE_SYN( User *pUser, MSG_BASE *pMsg, WORD wSize )
{
	MSG_CW_CHAT_VILLAGE_SYN	*pRecvMsg = (MSG_CW_CHAT_VILLAGE_SYN*)pMsg;

	if(!pUser)
	{
		MessageOut(eCRITICAL_LOG,  "CW_CHAT_VILLAGE_SYN 角菩(pUser == NULL)");
		return;
	}
/*
	// 焊辰 蜡历 捞抚捞 橇肺配妮 救俊 汲沥等 蔼苞 老摹窍绰瘤 犬牢
	string strCharName = pUser->GetCharName();
	if(_strnicmp(strCharName.c_str(), pRecvMsg->m_szCharNameTo, MAX_CHARNAME_LENGTH))
	{
		//撇府搁 坷幅!
		MessageOut(eCRITICAL_LOG, "CW_CHAT_VILLAGE_SYN 角菩(某腐磐 捞抚 阂老摹)");
		return;
	}
*/
	// 呈 绢蠢 悼匙 家加捞衬?
	Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
	if(!pChannel)
	{
		// 家加等 盲澄 绝绢档 坷幅
		MessageOut(eCRITICAL_LOG, "%s CW_CHAT_VILLAGE_SYN 角菩(Channel %u)", pUser->GetCharName().c_str(), pUser->GetChannelID());
		return;
	}

	Zone *pZone = pChannel->FindVillage(pUser->GetZoneKey());
	if(!pZone)
	{
		// 家加等 付阑 绝绢档 坷幅
		MessageOut( eCRITICAL_LOG, "%s CW_CHAT_VILLAGE_SYN 角菩[ZT:%u][ZK:%u]", pUser->GetCharName().c_str(), 
																				pUser->GetStatus(), 
																				pUser->GetZoneKey() );
		return;
	}

	// 盲泼 皋矫瘤 菩哦 炼赋
	MSG_CW_CHAT_VILLAGE_BRD	resMsg;

	resMsg.m_byCategory = CW_CHAT;
	resMsg.m_byProtocol = CW_CHAT_VILLAGE_BRD;
	memset(resMsg.m_szCharNameTo, 0, MAX_CHARNAME_LENGTH);
	_tcsncpy(resMsg.m_szCharNameTo, pRecvMsg->m_szCharNameTo, MAX_CHARNAME_LENGTH - 1 );	// 鞍篮 皋矫瘤捞骨肺 弊措肺 汗荤
	resMsg.m_szCharNameTo[MAX_CHARNAME_LENGTH-1] = '\0';
	if(pRecvMsg->m_byMsgLength >= MSG_CW_CHAT_VILLAGE_SYN::_MAX_CHATMSG_SIZE)
	{
		MessageOut(eCRITICAL_LOG, "%s CW_CHAT_VILLAGE_SYN 辨捞檬苞(%u)", pUser->GetCharName().c_str(), pRecvMsg->m_byMsgLength);
		return;
	}
	memset( resMsg.m_pszChatMsg, 0, sizeof(char) * MSG_CW_CHAT_VILLAGE_BRD::_MAX_CHATMSG_SIZE );
	_tcsncpy( resMsg.m_pszChatMsg, pRecvMsg->m_pszChatMsg, pRecvMsg->m_byMsgLength );
	resMsg.m_pszChatMsg[pRecvMsg->m_byMsgLength] = '\0';

	resMsg.m_byMsgLength = pRecvMsg->m_byMsgLength;
//	memset(resMsg.m_pszChatMsg, 0, MSG_CW_CHAT_VILLAGE_SYN::_MAX_CHATMSG_SIZE);
//	memcpy(resMsg.m_pszChatMsg, pRecvMsg->m_pszChatMsg, resMsg.m_byMsgLength);

	// 付阑捞搁 轰器飘 锚 - 菊俊辑 FindVillage肺 茫栏骨肺 咯扁 吧副 老篮 绝促
//	if(pZone->GetZoneType() == (eZONETYPE)eZONETYPE_VILLAGE)
//	{
		// 轰器飘 茫酒 焊辰促
//		if( !ViewPortManager::Instance()->SendViewPort( pUser, (BYTE*)&resMsg, resMsg.GetSize() ) )
		if( !pChannel->SendToViewPort( pUser, (BYTE*)&resMsg, resMsg.GetSize() ) )
		{
			// SendViewPort俊辑 肺弊 巢变促
//			MessageOut( eCRITICAL_LOG, "%s SendViewPort Error(%u)", pUser->GetCharName().c_str(), pUser->GetFieldCode() );
			return;
		}
		TCHAR ptszCharName[MAX_CHARNAME_LENGTH]={0,};
		_stprintf( ptszCharName, "%s", pUser->GetCharName().c_str() );
		GAMELOG->WriteVillageChat( NULL, ptszCharName, WorldServer::Instance()->GetServerKey(), pUser->GetFieldCode(), resMsg.m_pszChatMsg );
		MessageOut( eFULL_LOG, "CW_CHAT_VILLAGE_SYN[%s][Guid:%u][C:%u][F:%u]: %s", pUser->GetCharName().c_str(), 
																								pUser->GetGUID(), 
																								pUser->GetChannelID(), 
																								pUser->GetFieldCode(),
																								resMsg.m_pszChatMsg );
/*
	}
	else
	{
		// 瘤开俊 乐绰 葛电 蜡历甸俊霸 朝妨霖促!! - 捞 版快绰 沥惑篮 酒聪促
		pZone->SendToAll( (BYTE*)&resMsg, resMsg.GetSize() );

		TCHAR ptszCharName[MAX_CHARNAME_LENGTH]={0,};
		_stprintf( ptszCharName, "%s", pUser->GetCharName().c_str() );
		GAMELOG->WriteBattleZoneChat( NULL, ptszCharName, pZone->GetKey(), WorldServer::Instance()->GetServerKey(), pUser->GetFieldCode(), resMsg.m_pszChatMsg );
		MessageOut( eCRITICAL_LOG, "CW_CHAT_VILLAGE_SYN 贸府[%s][C:%u][ZT:%u][ZK:%u]", pUser->GetCharName().c_str(), 
																					pUser->GetChannelID(), 
																					pUser->GetStatus(), 
																					pUser->GetZoneKey() );
	}
*/
}

// 硅撇粮 盲泼 夸没
VOID Handler_CW::OnCW_CHAT_BATTLE_SYN( User *pUser, MSG_BASE *pMsg, WORD wSize )
{
	MSG_CW_CHAT_BATTLE_SYN*	pRecvMsg = (MSG_CW_CHAT_BATTLE_SYN*)pMsg;
	MSG_CW_CHAT_BATTLE_BRD	sendMsg;

	// 固府 sendMsg绰 炼赋秦 敌促
	TCHAR ptszCharName[MAX_CHARNAME_LENGTH]={0,};
	_stprintf( ptszCharName, "%s", pUser->GetCharName().c_str() );
	_tcsncpy( sendMsg.m_pszCharName, ptszCharName, MAX_CHARNAME_LENGTH - 1 );
	sendMsg.m_pszCharName[MAX_CHARNAME_LENGTH-1] = '\0';
	if( pRecvMsg->m_byMsgLength >= MSG_CW_CHAT_BATTLE_SYN::_MAX_CHATMSG_SIZE )
	{
		MessageOut(eCRITICAL_LOG, "%s CW_CHAT_BATTLE_SYN 辨捞檬苞(%u)", pUser->GetCharName().c_str(), pRecvMsg->m_byMsgLength);
		return;
	}
	memset( sendMsg.m_pszChatMsg, 0, sizeof(char) * MSG_CW_CHAT_BATTLE_BRD::_MAX_CHATMSG_SIZE );
	_tcsncpy( sendMsg.m_pszChatMsg, pRecvMsg->m_pszChatMsg, pRecvMsg->m_byMsgLength );
	sendMsg.m_pszChatMsg[pRecvMsg->m_byMsgLength] = '\0';

	sendMsg.m_byMsgLength = pRecvMsg->m_byMsgLength;

//	memset( sendMsg.m_pszChatMsg, 0, sizeof(sendMsg.m_pszChatMsg) );
//	strncpy( sendMsg.m_pszChatMsg, pRecvMsg->m_pszChatMsg, pRecvMsg->m_byMsgLength );
//	sendMsg.m_byMsgLength = pRecvMsg->m_byMsgLength;

	// 秦寸 硅撇粮 茫绰促
	Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
	Zone	*pZone = NULL;

	if( !pChannel )
	{
		MessageOut( eCRITICAL_LOG, "[%s]CW_CHAT_BATTLE_SYN  Error - No Channel %u", pUser->GetCharName().c_str(), 
																					pUser->GetChannelID() );
		return;
	}

	switch( pUser->GetStatus() )
	{
		case eZONETYPE_LOBBY:
		{
			pZone = pChannel->FindLobby( pUser->GetZoneKey() );
			break;
		}
		case eZONETYPE_MISSION:
		{
			pZone = pChannel->FindMissionZone( pUser->GetZoneKey() );
			break;
		}
		case eZONETYPE_HUNTING:
		{
			pZone = pChannel->FindHuntingZone( pUser->GetZoneKey() );
			break;
		}
		case eZONETYPE_QUEST:
		{
			pZone = pChannel->FindQuestZone( pUser->GetZoneKey() );
			break;
		}
		case eZONETYPE_PVP:
		{
			pZone = pChannel->FindPVPZone( pUser->GetZoneKey() );
			break;
		}
		case eZONETYPE_EVENT:
		{
			pZone = pChannel->FindEventZone( pUser->GetZoneKey() );
			break;
		}
		case eZONETYPE_GUILD:
		{
			pZone = pChannel->FindGuildZone( pUser->GetZoneKey() );
			break;
		}
		case eZONETYPE_SIEGE:
		{
			pZone = pChannel->FindSiegeZone( pUser->GetZoneKey() );
			break;
		}
		case eZONETYPE_VILLAGE:
		{
			// 付阑 盲泼阑 咯扁辑 趣矫 焊辰促绊 秦档 老窜 侩辑秦 霖促
			pZone = pChannel->FindVillage( pUser->GetZoneKey() );
			MessageOut( eCRITICAL_LOG, "BattleZoneChat阑 Village俊辑 焊晨[Guid:%u][CharGuid:%u][ZK:%u]][Field:%u]", pUser->GetGUID(), 
																											pUser->GetCharGuid(), 
																											pUser->GetStatus(), 
																											pUser->GetZoneKey(), 
																											pUser->GetFieldCode() );

			// 烙矫肺 付阑 盲泼 内靛 嘿烙
			// 盲泼 皋矫瘤 菩哦 炼赋
			MSG_CW_CHAT_VILLAGE_BRD	resMsg;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -