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

📄 handler_aw.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include "StdAfx.h"
#include ".\handler_AW.h"
#include "WorldServer.h"
#include "AgentServerSession.h"
#include "UserFactory.h"
#include "UserManager.h"
#include "WaitingUserList.h"
#include "Channel.h"
#include "ChannelManager.h"
#include "ServerSessionManager.h"
#include <PacketStruct_AW.h>
#include <Protocol_AW.h>
#include <PacketStruct_MW.h>
#include <Protocol_ServerCommon.h>
#include <PacketStruct_ServerCommon.h>

//付胶磐 辑滚 烹脚 锭巩
#include "WorldServerInfoParser.h"

VOID Handler_AW::OnAW_AGENTSERVER_INFO_SYN( AgentServerSession *pAgentServer, MSG_BASE *pMsg, WORD wSize )
{
	MSG_AW_AGENTSERVER_INFO_SYN *pRecvMsg = (MSG_AW_AGENTSERVER_INFO_SYN*)pMsg;

	pAgentServer->SetChannelID( pRecvMsg->dwChannelID );

#ifdef _DEBUG
	assert( pRecvMsg->dwChannelID > 0 && pRecvMsg->dwChannelID < 10 );
#else
	if( pRecvMsg->dwChannelID <= 0 || pRecvMsg->dwChannelID >= 10 )
	{
		MessageOut( eCRITICAL_LOG, "AGENTSERVER_INFO_SYN Error - 盲澄 牢郸胶 坷幅![%u]", pRecvMsg->dwChannelID );
		pAgentServer->Disconnect();
		return;
	}
#endif

	if( ChannelManager::Instance()->GetChannel( pRecvMsg->dwChannelID ) != NULL )
	{
		MessageOut(eCRITICAL_LOG,  "盲澄(%d)捞 捞固 粮犁窍骨肺 楷搬阑 谗嚼聪促.", pRecvMsg->dwChannelID );
		pAgentServer->Disconnect();
		return;
	}

	ChannelManager::Instance()->AddChannel( pRecvMsg->dwChannelID );
/*
	// 趣矫 郴啊 磷菌菌带 芭具?
	MSG_AW_USER_RESTORE_SYN	sendMsg;

	sendMsg.m_byCategory = AW_USER_STATUS;
	sendMsg.m_byProtocol = AW_USER_RESTORE_SYN;
	sendMsg.m_dwKey = WorldServer::Instance()->GetServerKey();

	// 弊烦 汗备 粱 秦拎官官...
	pAgentServer->Send( (BYTE*)&sendMsg, sizeof(sendMsg) );
*/
}

VOID Handler_AW::OnAW_PREPARE_NEW_USER_SYN( AgentServerSession *pAgentServer, MSG_BASE *pMsg, WORD wSize )
{
	MSG_AW_PREPARE_NEW_USER_SYN *pRecvMsg = (MSG_AW_PREPARE_NEW_USER_SYN*)pMsg;

	User *pUser;

	if( pAgentServer->GetChannelID() == 0 )
	{
		MessageOut(eCRITICAL_LOG,  "酒流 盲澄 ID啊 技泼登瘤 臼疽栏骨肺 俊捞傈飘 辑滚肺 AW_PREPARE_NEW_USER_NAK甫 焊晨" );
		MSG_AW_PREPARE_NEW_USER_NAK nakMsg;
		nakMsg.m_dwKey = pRecvMsg->m_dwKey;
		pAgentServer->Send( (BYTE*)&nakMsg, sizeof(nakMsg) );
		return;
	}

	// 秦寸 蜡廉啊 捞固 乐绰 版快 立加阑 谗绰促.
	if( pUser = UserManager::Instance()->FindUser( pRecvMsg->dwUserGuid ) )
	{
		MessageOut(eCRITICAL_LOG, "吝汗 guid 惯积! 乐带 蜡廉 立加 辆丰(%s:%u)", pUser->GetCharName().c_str(), pUser->GetGUID() );
		pUser->Logout();
		return;
	}

	// 咀萍宏 蜡廉 且寸
	pUser = UserFactory::Instance()->Alloc( ACTIVE_USER );

	// 蜡廉 沥焊 悸泼
	pUser->SetGUID( pRecvMsg->dwUserGuid );
	pUser->SetChannelID( pAgentServer->GetChannelID() );
//	pUser->SetStatus( (eZONETYPE)pRecvMsg->byUserStatus );

	// 牢刘等 IP 悸泼
	pUser->SetAuthIP( pRecvMsg->szClientIP );
	pUser->SetAuthID( pRecvMsg->dwAuthUserID );

/*
	// 某腐磐 捞抚 技泼.. 绝栏搁 后巩磊凯 技泼
	if( strcmp( pRecvMsg->szCharName, "" ) != 0 )
	{
		pUser->SetCharName( pRecvMsg->szCharName );
	}
	else
	{
*/
		pUser->SetCharName( "" );
//	}

	// 措扁 府胶飘俊 眠啊
	WaitingUserList::Instance()->AddUser( pRecvMsg->dwAuthUserID, pUser );

	//MessageOut(eCRITICAL_LOG,  "蜡廉 立加 措扁.. 盲澄(%d) Guid(%d) IP(%s)", 
	//	pUser->GetChannelID(), pUser->GetGUID(), pUser->GetAuthIP() );

	// AgentServer俊 览翠
	MSG_AW_PREPARE_NEW_USER_ACK ackMsg;
	ackMsg.m_byCategory		= AW_CONNECTION;
	ackMsg.m_byProtocol		= AW_PREPARE_NEW_USER_ACK;
	ackMsg.m_dwKey			= pRecvMsg->m_dwKey;
	pAgentServer->Send( (BYTE*)&ackMsg, sizeof(ackMsg) );

	MessageOut( eFULL_LOG, "PREPARE_NEW_USER_SYN[Channel:%u][Guid:%u]", pUser->GetChannelID(), pUser->GetGUID() );
}

VOID Handler_AW::OnAW_USER_SET_CHARNAME_SYN( AgentServerSession *pAgentServer, MSG_BASE *pMsg, WORD wSize )
{
	MSG_AW_USER_SET_CHARNAME_SYN *pRecvMsg = (MSG_AW_USER_SET_CHARNAME_SYN*)pMsg;
	
	UserManager::Instance()->SetUserCharGuid( pRecvMsg->m_dwKey, pRecvMsg->dwCharGuid );
	if( !UserManager::Instance()->SetUserCharName( pRecvMsg->m_dwKey, pRecvMsg->szCharName ) )
	{
		// 蜡廉 概聪廉俊 绝阑 版快 措扁 府胶飘俊辑档 茫酒夯促.
        User *pUser = WaitingUserList::Instance()->FindUserWithGuid( pRecvMsg->m_dwKey );
		if( pUser )
		{
			pUser->SetCharGuid( pRecvMsg->dwCharGuid );
			pUser->SetCharName( pRecvMsg->szCharName );
		}
	}
}

VOID Handler_AW::OnAW_USER_UNSET_CHARNAME_SYN( AgentServerSession *pAgentServer, MSG_BASE *pMsg, WORD wSize )
{
	MSG_AW_USER_UNSET_CHARNAME_SYN *pRecvMsg = (MSG_AW_USER_UNSET_CHARNAME_SYN*)pMsg;

	if( !UserManager::Instance()->UnSetCharGuid( pRecvMsg->m_dwKey ) )
	{
		User *pUser = WaitingUserList::Instance()->FindUserWithGuid( pRecvMsg->m_dwKey );
		if( pUser )
		{
			pUser->SetCharGuid( 0 );
		}
	}
	if( !UserManager::Instance()->UnsetUserCharName( pRecvMsg->m_dwKey ) )
	{
		User *pUser = WaitingUserList::Instance()->FindUserWithGuid( pRecvMsg->m_dwKey );
		if( pUser )
		{
			pUser->SetCharName( "" );
		}
	}
}

VOID Handler_AW::OnAW_USER_ENTER_ZONE_SYN( AgentServerSession *pAgentServer, MSG_BASE *pMsg, WORD wSize )
{
	MSG_AW_USER_ENTER_ZONE_SYN *pRecvMsg = (MSG_AW_USER_ENTER_ZONE_SYN*)pMsg;

	// 秦寸 蜡廉 器牢磐 茫扁
	User *pUser = UserManager::Instance()->FindUser( pRecvMsg->m_dwKey );
	if( pUser )
	{
		Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
		if( !pChannel )
		{
			MessageOut( eCRITICAL_LOG, "USER_ENTER_ZONE Error - [Guid:%u][ZT:%u][ZK:%u] Channel Not Exist!", pRecvMsg->m_dwKey, pRecvMsg->byZoneType, pRecvMsg->dwZoneKey );
			// 呈 酪绢滚啡促! 促矫 嘿绢扼!
//			pUser->Logout();
			return;
		}

		switch( pRecvMsg->byZoneType )
		{
		case eZONETYPE_LOBBY:
			pChannel->UserEnterLobby( pUser, pRecvMsg->dwZoneKey );
			break;
		case eZONETYPE_CHARSELECT:
			pChannel->UserEnterCharScene( pUser );
			break;
		case eZONETYPE_VILLAGE:
			pChannel->UserEnterVillage( pUser, pRecvMsg->dwZoneKey );
			break;
		case eZONETYPE_MISSION:
			pChannel->UserEnterMissionZone( pUser, pRecvMsg->dwZoneKey );
			break;
		case eZONETYPE_HUNTING:
			pChannel->UserEnterHuntingZone( pUser, pRecvMsg->dwZoneKey );
			break;
		case eZONETYPE_QUEST:
			pChannel->UserEnterQuestZone( pUser, pRecvMsg->dwZoneKey );
			break;
		case eZONETYPE_PVP:
			pChannel->UserEnterPVPZone( pUser, pRecvMsg->dwZoneKey );
			break;
		case eZONETYPE_EVENT:
			pChannel->UserEnterEventZone( pUser, pRecvMsg->dwZoneKey );
			break;
		case eZONETYPE_GUILD:
			pChannel->UserEnterGuildZone( pUser, pRecvMsg->dwZoneKey );
			break;
		case eZONETYPE_SIEGE:
			pChannel->UserEnterSiegeZone( pUser, pRecvMsg->dwZoneKey );
			break;
//		default:	// 老窜 某腐磐 急琶/付阑捞 酒聪搁 傈何 硅撇粮栏肺 秒鞭(己泅芒)
//			pChannel->UserEnterBattleZone( pUser, pRecvMsg->dwZoneKey );
//			break;
		default:
#ifdef _DEBUG
			assert( !"invalid user status" );
#else
			MessageOut( eCRITICAL_LOG, "USER_ENTER_ZONE Error - No User Status[Guid:%u][Stat:%u]", pRecvMsg->m_dwKey, pRecvMsg->byZoneType );
			// 呈 酪绢滚啡促! 促矫 嘿绢扼!!!
//			pUser->Logout();
			break;
#endif
		}
	}
	else
	{
		// 捞 版快绰 悼扁拳 坷幅 - 贸澜 甸绢棵 锭绰 馆靛矫 惯积窍哥, 贸府秦 临 鞘夸啊 绝促
/*
		MessageOut( eFULL_LOG, "USER_ENTER_ZONE Error - User[%u] 立加 救 沁澜(悼扁拳 坷幅)", pRecvMsg->m_dwKey );

		pUser = WaitingUserList::Instance()->FindUserWithGuid( pRecvMsg->m_dwKey );
		if( pUser )
		{
#ifdef _DEBUG
			ASSERT( !pUser->GetZoneKey() && "LeaveZone 绝捞 EnterZone!!!");	// sectorIndex啊 0 酒聪搁 LeaveZone捞 力措肺 救 灯促绰 娟扁
#else
			if( pUser->GetZoneKey() )
			{
				MessageOut( eCRITICAL_LOG, "USER_ENTER_ZONE Error - LeaveZone 绝捞 EnterZone[Guid:%u][UserZT:%u][ZT:%u][ZK:%u]", 
											pRecvMsg->m_dwKey, pUser->GetStatus(), pRecvMsg->byZoneType, pRecvMsg->dwZoneKey );
				return;
			}
#endif
//			pUser->SetStatus( (eZONETYPE)pRecvMsg->byZoneType );
//			pUser->SetZoneKey( pRecvMsg->dwZoneKey );

			Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
			if( !pChannel )
			{
				MessageOut( eCRITICAL_LOG, "USER_ENTER_ZONE_SYN Error - No User Channel %u(%u)", pUser->GetChannelID(), 
																								pUser->GetGUID() );
				return;
			}
		}
		else
		{
			MessageOut( eCRITICAL_LOG, "USER_ENTER_ZONE Error - No User[%u]", pRecvMsg->m_dwKey );
		}
*/
	}

}

VOID Handler_AW::OnAW_USER_LEAVE_ZONE_SYN( AgentServerSession *pAgentServer, MSG_BASE *pMsg, WORD wSize )
{
	MSG_AW_USER_LEAVE_ZONE_SYN *pRecvMsg = (MSG_AW_USER_LEAVE_ZONE_SYN*)pMsg;
	
	// 秦寸 蜡廉 器牢磐 茫扁
	User *pUser = UserManager::Instance()->FindUser( pRecvMsg->m_dwKey );
	if( pUser )
	{

⌨️ 快捷键说明

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