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

📄 handler_dw.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
字号:
#include "stdafx.h"
#include "Handler_DW.h"
#include "GameDBProxySession.h"
#include <Protocol_DW.h>
#include <PacketStruct_DW.h>

// 模备 格废 贸府 困秦
#include <Protocol_CW.h>
#include <PacketStruct_CW.h>
#include "User.h"
#include "UserManager.h"

VOID Handler_DW::OnDW_CONNECTION_SERVER_INFO_CMD( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MessageOut(eCRITICAL_LOG, "OnDW_CONNECTION_SERVER_INFO_CMD");
}

// 模备 格废 荐脚
VOID Handler_DW::OnDW_FRIEND_GETLIST_ACK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_GETLIST_ACK*	pRecvMsg = (MSG_DW_FRIEND_GETLIST_ACK*)pMsg;

	MSG_CW_FRIEND_FRIENDLIST_ACK	sendFriend;
	MSG_CW_FRIEND_BLOCKLIST_ACK		sendBlock;
	User*						pUser = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuid );

	if( !pUser )
	{
		MessageOut( eFULL_LOG, "DW_FRIEND_GETLIST_ACK Error - User Already Logout[CharGuid:%u]", pRecvMsg->m_CharGuid );
		return;
	}

	User*	pFriend = NULL;

	sendFriend.byFriendStatNum = 0;
	sendBlock.byBlockStatNum = 0;

	STRUCT_FRIEND_INFO sFriendInfo;
	STRUCT_BLOCK_INFO sBlockInfo;
	int nFriendCnt=0, nBlockCnt=0;

	// 模备客 瞒窜栏肺 盒府茄促
	for(USHORT i=0; i<pRecvMsg->m_byFriendNum; i++)
	{
		// 模备
		if( pRecvMsg->m_sFriendInfo[i].Sts == STRUCT_FRIEND_DB_INFO::INFO_FRIEND )
		{
			sendFriend.byFriendStatNum++;
			pFriend = UserManager::Instance()->FindUser( pRecvMsg->m_sFriendInfo[nFriendCnt].ptszFriendName );
			// 模备甸 吝 柯扼牢牢 仇 乐唱 犬牢~!
			if( pFriend && !pFriend->FindBlock( pRecvMsg->m_CharGuid ) )	// 柯扼牢捞绊 瞒窜寸窍瘤 臼疽栏搁
			{
				sFriendInfo.sPacketInfo.bOnline = TRUE;
			}
			else
			{
				sFriendInfo.sPacketInfo.bOnline = FALSE;
			}
			_tcsncpy( sFriendInfo.sPacketInfo.ptszFriendName, 
					pRecvMsg->m_sFriendInfo[i].ptszFriendName, 
					MAX_CHARNAME_LENGTH - 1 );
			sFriendInfo.sPacketInfo.ptszFriendName[MAX_CHARNAME_LENGTH-1] = '\0';
			sFriendInfo.dwFriendGuid = pRecvMsg->m_sFriendInfo[i].dwFriendGuid;
			sFriendInfo.sPacketInfo.byClass = pRecvMsg->m_sFriendInfo[i].byClass;
			sFriendInfo.sPacketInfo.Level = pRecvMsg->m_sFriendInfo[i].Level;
			pUser->AddFriendInfo( &sFriendInfo );
			memcpy( &sendFriend.sFriendStat[nFriendCnt], &sFriendInfo, sizeof(STRUCT_FRIEND_INFO) );
			nFriendCnt++;
		}
		else if( pRecvMsg->m_sFriendInfo[i].Sts == STRUCT_FRIEND_DB_INFO::INFO_BLOCK )
		{
			sendBlock.byBlockStatNum++;
			_tcsncpy( sBlockInfo.ptszBlockName, 
					pRecvMsg->m_sFriendInfo[i].ptszFriendName, 
					MAX_CHARNAME_LENGTH - 1 );
			sBlockInfo.ptszBlockName[MAX_CHARNAME_LENGTH-1] = '\0';
			sBlockInfo.dwBlockGuid = pRecvMsg->m_sFriendInfo[i].dwFriendGuid;
			pUser->AddBlockInfo( &sBlockInfo );
			memcpy( &sendBlock.sBlockStat[nBlockCnt], &sBlockInfo, sizeof(STRUCT_BLOCK_INFO) );
			nBlockCnt++;
		}
		else
		{
			pUser->Send( (BYTE*)&sendFriend, sendFriend.GetSize() );
			pUser->Send( (BYTE*)&sendBlock, sendBlock.GetSize() );
			MessageOut( eCRITICAL_LOG, "[%s]DW_FRIEND_GETLIST Error - No Friend/Block Type[Sts:%u]", pUser->GetCharName().c_str(), pRecvMsg->m_sFriendInfo[i].Sts );
			return;
		}
	}

	UserManager::Instance()->AddFriend( pUser );	// 模备 格废 诀单捞飘

	// 模备 惑怕 傈何 犬牢 场车栏搁 焊辰促
	pUser->Send( (BYTE*)&sendFriend, sendFriend.GetSize() );
	pUser->Send( (BYTE*)&sendBlock, sendBlock.GetSize() );
	MessageOut( eFULL_LOG, "[%s][Guid:%u] Friend/Block List Send", pUser->GetCharName().c_str(), pUser->GetGUID() );
}

// 模备 格废 荐脚 角菩
VOID Handler_DW::OnDW_FRIEND_GETLIST_NAK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_GETLIST_NAK*	pRecvMsg = (MSG_DW_FRIEND_GETLIST_NAK*)pMsg;

	// 秦寸 蜡历啊 穿备衬?
	User	*pUser = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuid );

	if( !pUser )
	{
		MessageOut( eCRITICAL_LOG, "DW_FRIEND_GETLIST_NAK Error - Already Logout[CharGuid:%u]", pRecvMsg->m_CharGuid );
		return;
	}

	MSG_CW_FRIEND_NEWLIST_NAK	sendMsg;

	// 官肺 舅妨霖促!
	sendMsg.dwResult = pRecvMsg->m_byResult;

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

	MessageOut( eFULL_LOG, "[%s][Guid:%u] Can't Get Friend List(%u)", pUser->GetCharName().c_str(), pUser->GetGUID(), pRecvMsg->m_byResult );
}

// 模备 眠啊 己傍
VOID Handler_DW::OnDW_FRIEND_ADD_ACK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_ADD_ACK*	pRecvMsg = (MSG_DW_FRIEND_ADD_ACK*)pMsg;
	User* pUser = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuidFrom );

	if( !pUser )
	{
		MessageOut( eFULL_LOG, "[CharGuid:%u] Friend ADD - User Already Logout", pRecvMsg->m_CharGuidFrom );
		return;
	}

	STRUCT_FRIEND_INFO	sFriendInfo;

	memset( &sFriendInfo, 0, sizeof(STRUCT_FRIEND_INFO) );

	User* pFriend = UserManager::Instance()->FindUser( pRecvMsg->m_ToFriendInfo.ptszFriendName );

	if( pFriend )
	{
		sFriendInfo.sPacketInfo.bOnline = TRUE;
	}
	else
	{
		sFriendInfo.sPacketInfo.bOnline = FALSE;
	}
	_tcsncpy( sFriendInfo.sPacketInfo.ptszFriendName, pRecvMsg->m_ToFriendInfo.ptszFriendName, MAX_CHARNAME_LENGTH - 1 );
	sFriendInfo.sPacketInfo.ptszFriendName[MAX_CHARNAME_LENGTH-1] = '\0';
	sFriendInfo.sPacketInfo.byClass = pRecvMsg->m_ToFriendInfo.byClass;
	sFriendInfo.sPacketInfo.Level = pRecvMsg->m_ToFriendInfo.Level;
	sFriendInfo.dwFriendGuid = pRecvMsg->m_ToFriendInfo.dwFriendGuid;
	if( !pUser->AddFriendInfo( &sFriendInfo ) )
	{
		// 模备 沥焊 眠啊 角菩
		MessageOut( eCRITICAL_LOG, "[%s] Friend ADD Error - Can't Add FriendInfo", pUser->GetCharName().c_str() );
		return;
	}

	UserManager::Instance()->AddNewFriend( sFriendInfo.dwFriendGuid, pUser );
	// 模备 眠啊灯澜阑 舅妨霖促
	MSG_CW_FRIEND_ADD_ACK	sendMsg;
	sendMsg.sFriendStat = sFriendInfo;

	pUser->Send( (BYTE*)&sendMsg, sizeof(sendMsg) );
	MessageOut( eFULL_LOG, "[%s->%s] Friend ADD", pUser->GetCharName().c_str(), pRecvMsg->m_ToFriendInfo.ptszFriendName );
}

// 模备 夸没 角菩
VOID Handler_DW::OnDW_FRIEND_ADD_NAK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_ADD_NAK*	pRecvMsg = (MSG_DW_FRIEND_ADD_NAK*)pMsg;
	User*	pUser = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuidFrom );

	if( !pUser )
	{
		// 捞固 夸没茄 某腐磐啊 唱啊滚啡促搁 喊档狼 盎脚 鞘夸 绝促
		MessageOut( eCRITICAL_LOG, "[CharGuid:%u] FRIEND_ADD_NAK Error - ADD Already Logout", pRecvMsg->m_CharGuidFrom );
		return;
	}

	MSG_CW_FRIEND_ADD_NAK	sendMsg;

	sendMsg.m_byResult = pRecvMsg->m_byResult;

	pUser->Send( (BYTE*)&sendMsg, sizeof(sendMsg) );
	MessageOut( eFULL_LOG, "[%s] FRIEND_ADD_NAK", pUser->GetCharName().c_str() );
}

// 模备 昏力 己傍
VOID Handler_DW::OnDW_FRIEND_DEL_ACK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_DEL_ACK*	pRecvMsg	= (MSG_DW_FRIEND_DEL_ACK*)pMsg;
	User*					pUser		= UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuidFrom );

	if( !pUser )
	{
		MessageOut( eFULL_LOG, "[CharGuid:%u] FRIEND_DEL_ACK - Already Logout", pRecvMsg->m_CharGuidFrom );
		return;
	}

	// 柯扼牢 府胶飘俊辑 瘤快绊
	STRUCT_FRIEND_INFO* pFriendInfo = pUser->FindFriend( pRecvMsg->m_CharGuidTo );
	if( !pFriendInfo )
	{
		// 捞繁 版快档 乐阑鳖? 酒付档 吝汗 孽府啊 朝酒啊绰 沥档狼 版快俊父 惯积且 巴捞促
		MessageOut( eCRITICAL_LOG, "[%s/%u->%s] FRIEND_DEL Error - Friend Already Deleted", pUser->GetCharName().c_str(), pRecvMsg->m_CharGuidTo, pFriendInfo->sPacketInfo.ptszFriendName );
		// 捞繁 惑炔捞扼绊 秦档 DB俊辑绰 犬角洒 瘤况柳 巴捞骨肺 ACK 拎具 茄促
		MSG_CW_FRIEND_DEL_ACK	sendMsg;

		memset( sendMsg.ptszDeletedName, 0, sizeof(sendMsg.ptszDeletedName) );

		pUser->Send( (BYTE*)&sendMsg, sizeof(sendMsg) );
		return;
	}

	UserManager::Instance()->RemoveNewFriend( pFriendInfo->dwFriendGuid, pUser );

	// 舅妨霖促
	MSG_CW_FRIEND_DEL_ACK	sendMsg;

	_tcsncpy( sendMsg.ptszDeletedName, pFriendInfo->sPacketInfo.ptszFriendName, MAX_CHARNAME_LENGTH - 1 );
	sendMsg.ptszDeletedName[MAX_CHARNAME_LENGTH-1] = '\0';

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

	MessageOut( eFULL_LOG, "[%s/%u->%s] FRIEND_DEL_ACK", pUser->GetCharName().c_str(), pRecvMsg->m_CharGuidFrom, pFriendInfo->sPacketInfo.ptszFriendName );
	pUser->RemoveFriend(pRecvMsg->m_CharGuidTo );
}

// 模备 昏力 角菩
VOID Handler_DW::OnDW_FRIEND_DEL_NAK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_DEL_NAK*	pRecvMsg	= (MSG_DW_FRIEND_DEL_NAK*)pMsg;
	User*					pUser		=  UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuidFrom );

	if( !pUser )
	{
		MessageOut( eFULL_LOG, "[CharGuid:%u] FRIEND_DEL_NAK - Already Logout", pRecvMsg->m_CharGuidFrom );
		return;
	}

	// 舅妨霖促
	MSG_CW_FRIEND_DEL_NAK	sendMsg;

	sendMsg.m_byResult = pRecvMsg->m_byResult;

	pUser->Send( (BYTE*)&sendMsg, sizeof(MSG_CW_FRIEND_DEL_NAK) );

	MessageOut( eFULL_LOG, "[%s][CharGuid:%u] FRIEND_DEL_NAK", pUser->GetCharName().c_str(), pRecvMsg->m_CharGuidFrom );
}

// 瞒窜 己傍
VOID Handler_DW::OnDW_FRIEND_BLOCK_ACK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_BLOCK_ACK*	pRecvMsg = (MSG_DW_FRIEND_BLOCK_ACK*)pMsg;
	User* pBlock = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuidFrom );

	if( !pBlock )
	{
		MessageOut( eFULL_LOG, "[CharGuid:%u] Block[%s] ADD User Already Logout", pRecvMsg->m_CharGuidFrom, pRecvMsg->m_BlockInfo.ptszBlockName );
		return;
	}

	// 柯扼牢捞搁 荤侩磊俊 瞒窜 眠啊
	STRUCT_BLOCK_INFO	sBlockInfo;

	memset( &sBlockInfo, 0, sizeof(STRUCT_BLOCK_INFO) );

	sBlockInfo.dwBlockGuid = pRecvMsg->m_BlockInfo.dwBlockGuid;
	_tcsncpy( sBlockInfo.ptszBlockName, pRecvMsg->m_BlockInfo.ptszBlockName, MAX_CHARNAME_LENGTH - 1 );
	sBlockInfo.ptszBlockName[MAX_CHARNAME_LENGTH-1] = '\0';

	if( !pBlock->AddBlockInfo( &sBlockInfo ) )
	{
		// 瞒窜 眠啊 角菩
		MessageOut( eCRITICAL_LOG, "[%s] Block ADD Error - Can't Add BlockInfo", pBlock->GetCharName().c_str() );
		return;
	}

	// 喉废等 仇捞 趣矫唱 柯扼牢俊 乐栏搁 郴 沥焊甫 见变促!
	User *pBlocked = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_BlockInfo.dwBlockGuid );

	if( pBlocked )
	{
		pBlock->RemoveOnlineFriend( pBlocked );
	}

	// 喉废 己傍沁澜阑 舅妨霖促
	MSG_CW_FRIEND_BLOCK_ACK	sendMsg;
	_tcsncpy( sendMsg.ptszBlockedName, pRecvMsg->m_BlockInfo.ptszBlockName, MAX_CHARNAME_LENGTH - 1 );
	sendMsg.ptszBlockedName[MAX_CHARNAME_LENGTH-1] = '\0';

	pBlock->Send( (BYTE*)&sendMsg, sizeof(MSG_CW_FRIEND_BLOCK_ACK) );
	MessageOut( eFULL_LOG, "[%s->%s] Block ADD", pBlock->GetCharName().c_str(), pRecvMsg->m_BlockInfo.ptszBlockName );
}

// 瞒窜 角菩
VOID Handler_DW::OnDW_FRIEND_BLOCK_NAK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_BLOCK_NAK*	pRecvMsg = (MSG_DW_FRIEND_BLOCK_NAK*)pMsg;
	User*	pUser = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuidFrom );

	if( !pUser )
	{
		// 捞固 夸没茄 某腐磐啊 唱啊滚啡促搁 喊档狼 盎脚 鞘夸 绝促
		MessageOut( eCRITICAL_LOG, "[CharGuid:%u] FRIEND_ADD_NAK Error - ADD Already Logout", pRecvMsg->m_CharGuidFrom );
		return;
	}

	MSG_CW_FRIEND_BLOCK_NAK	sendMsg;

	sendMsg.m_byResult = pRecvMsg->m_byResult;

	pUser->Send( (BYTE*)&sendMsg, sizeof(MSG_CW_FRIEND_BLOCK_NAK) );
	MessageOut( eFULL_LOG, "[%s] FRIEND_ADD_NAK", pUser->GetCharName().c_str() );
}

// 瞒窜 秦力 己傍
VOID Handler_DW::OnDW_FRIEND_BLOCK_FREE_ACK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_BLOCK_FREE_ACK*	pRecvMsg = (MSG_DW_FRIEND_BLOCK_FREE_ACK*)pMsg;
	User*	pUser = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuidFrom );

	if( !pUser )
	{
		// 捞固 夸没茄 某腐磐啊 唱啊滚啡促搁 喊档狼 盎脚 鞘夸 绝促
		MessageOut( eCRITICAL_LOG, "[CharGuid:%u] MSG_DW_FRIEND_BLOCK_FREE_ACK Error - Already Logout", pRecvMsg->m_CharGuidFrom );
		return;
	}

	MSG_CW_FRIEND_BLOCK_FREE_ACK	sendMsg;

	_tcsncpy( sendMsg.ptszBlockedName, pRecvMsg->m_ptszCharNameTo, MAX_CHARNAME_LENGTH - 1 );
	sendMsg.ptszBlockedName[MAX_CHARNAME_LENGTH-1] = '\0';

	// 趣矫 捞仇捞 柯扼牢捞绊 唱甫 模备肺 眠啊沁菌促搁 肺弊牢 惑怕肺 官层霖促
	User* pBlocked = UserManager::Instance()->FindUser( pRecvMsg->m_ptszCharNameTo );

	if( pBlocked && pBlocked->FindFriend( pUser->GetCharGuid() ) )
	{
		// 肺弊牢 惑怕肺 函脚!!
		pUser->AddOnlineFriend( pBlocked );
	}

	pUser->Send( (BYTE*)&sendMsg, sizeof(MSG_CW_FRIEND_BLOCK_FREE_ACK) );
	MessageOut( eFULL_LOG, "[%s->%s] FRIEND_BLOCK_FREE_ACK", pUser->GetCharName().c_str(), pRecvMsg->m_ptszCharNameTo );
	pUser->RemoveBlock( pRecvMsg->m_ptszCharNameTo );
}

// 瞒窜 秦力 角菩
VOID Handler_DW::OnDW_FRIEND_BLOCK_FREE_NAK( GameDBProxySession *pGameDBProxy, MSG_BASE *pMsg, WORD wSize)
{
	MSG_DW_FRIEND_BLOCK_FREE_NAK*	pRecvMsg = (MSG_DW_FRIEND_BLOCK_FREE_NAK*)pMsg;
	User*	pUser = UserManager::Instance()->FindUserByCharGuid( pRecvMsg->m_CharGuidFrom );

	if( !pUser )
	{
		// 捞固 夸没茄 某腐磐啊 唱啊滚啡促搁 喊档狼 盎脚 鞘夸 绝促
		MessageOut( eCRITICAL_LOG, "[CharGuid:%u] MSG_DW_FRIEND_BLOCK_FREE_NAK Error - Already Logout", pRecvMsg->m_CharGuidFrom );
		return;
	}

	MSG_CW_FRIEND_BLOCK_FREE_NAK	sendMsg;

	sendMsg.m_byResult = pRecvMsg->m_byResult;

	pUser->Send( (BYTE*)&sendMsg, sizeof(MSG_CW_FRIEND_BLOCK_FREE_NAK) );
	MessageOut( eFULL_LOG, "[%s] MSG_DW_FRIEND_BLOCK_FREE_NAK", pUser->GetCharName().c_str() );
}

⌨️ 快捷键说明

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