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

📄 handler_fromgameserver.cpp

📁 奇迹世界data 服务器代码,研究游戏的朋友有帮助
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include "stdafx.h"
#include ".\Handler_FromGameServer.h"
#include <PacketStruct_DG.h>
#include <Macro.h>
#include "ServerSession.h"
#include "DBUser.h"
#include "DBUserManager.h"
#include "GameServerSession.h"
#include <SCSlot.h>
#include <SCSlotContainer.h>
#include "DBProxyServer.h"


Handler_FromGameServer_IMPL(DG_CHARINFO_CHAR_ITEM_CMD)
{
	MSG_DG_CHARINFO_CHAR_ITEM_CMD * pRecvMsg = (MSG_DG_CHARINFO_CHAR_ITEM_CMD *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	DBUser * pUser = g_DBUserManager.FindUser( UserKey );
	DEBUG_CODE( 
		if( !pUser )
		{
			SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_CHAR_ITEM_CMD)] [UserGUID:%u]", UserKey );
			return;
		}
	);

	BYTE slotIdx = pUser->GetSelectedCharSlotIndex();


	pUser->SerializeCharInfo( slotIdx, pRecvMsg->m_CharacterInfo, SERIALIZE_STORE );

	pUser->ClearEquipItemStream(slotIdx);
	pUser->ClearInventoryItemStream(slotIdx);
	pUser->ClearTempInventoryItemStream(slotIdx);

	ITEMSLOTEX * pSlot = pRecvMsg->m_ItemInfo.m_Slot;
	POSTYPE start = 0;
	POSTYPE total = pRecvMsg->m_ItemInfo.m_EquipCount;
	for(POSTYPE i=start;i<total;++i)
		pUser->SetEquipItem(slotIdx,pSlot[i].m_ItemPos, &pSlot[i].m_Stream);

	start = total;
	total += pRecvMsg->m_ItemInfo.m_InvenCount;
	for(POSTYPE i=start;i<total;++i)
		pUser->SetInventoryItem(slotIdx,pSlot[i].m_ItemPos, &pSlot[i].m_Stream);

	start = total;
	total += pRecvMsg->m_ItemInfo.m_TmpInvenCount;
	for(POSTYPE i=start;i<total;++i)
		pUser->SetTempInventoryItem(slotIdx,pSlot[i].m_ItemPos, &pSlot[i].m_Stream);
}

Handler_FromGameServer_IMPL(DG_CHARINFO_SKILL_CMD)
{
	MSG_DG_CHARINFO_SKILL_CMD * pRecvMsg = (MSG_DG_CHARINFO_SKILL_CMD *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	DBUser * pUser = g_DBUserManager.FindUser( UserKey );
	ASSERT( pUser );
	DEBUG_CODE( 
		if( !pUser ) 
		{
			SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_SKILL_CMD)] [UserGUID:%u]", UserKey );
			return; 
		}
	);

	pUser->m_packet |= eMSG_DG_CHARINFO_SKILL_CMD;

	BYTE slotIdx = pUser->GetSelectedCharSlotIndex();

	pUser->ClearSkillStream(slotIdx);

	SKILLSLOT * pSlot = pRecvMsg->m_SkillInfo.m_Slot;
	POSTYPE start = 0;
	POSTYPE total = pRecvMsg->m_SkillInfo.m_Count;
	for(POSTYPE i=start;i<total;++i)
	{
		pUser->SetSkill(slotIdx, pSlot[i].m_SkillPos, &pSlot[i].m_Stream);
	}
}


Handler_FromGameServer_IMPL(DG_CHARINFO_QUICK_CMD)
{
	MSG_DG_CHARINFO_QUICK_CMD * pRecvMsg = (MSG_DG_CHARINFO_QUICK_CMD *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	DBUser * pUser = g_DBUserManager.FindUser( UserKey );
	ASSERT( pUser );
	DEBUG_CODE( 
		if( !pUser ) 
		{
			SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_QUICK_CMD)] [UserGUID:%u]", UserKey );
			return; 
		}
		);

	pUser->m_packet |= eMSG_DG_CHARINFO_QUICK_CMD;

	BYTE slotIdx = pUser->GetSelectedCharSlotIndex();

	pUser->ClearQuickStream(slotIdx);

	QUICKSLOT * pSlot = pRecvMsg->m_QuickInfo.m_Slot;
	POSTYPE start = 0;
	POSTYPE total = pRecvMsg->m_QuickInfo.m_Count;
	for(POSTYPE i=start;i<total;++i)
	{
		pUser->SetQuick(slotIdx, pSlot[i].m_QuickPos, &pSlot[i].m_Stream);
	}
}
Handler_FromGameServer_IMPL(DG_CHARINFO_STYLE_CMD)
{
	MSG_DG_CHARINFO_STYLE_CMD * pRecvMsg = (MSG_DG_CHARINFO_STYLE_CMD *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	DBUser * pUser = g_DBUserManager.FindUser( UserKey );
	ASSERT( pUser );
	DEBUG_CODE( 
		if( !pUser ) 
		{
			SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_STYLE_CMD)] [UserGUID:%u]", UserKey );
			return; 
		}
		);

	pUser->m_packet |= eMSG_DG_CHARINFO_STYLE_CMD;

	BYTE slotIdx = pUser->GetSelectedCharSlotIndex();

	pUser->ClearStyleStream(slotIdx);

	STYLESLOT * pSlot = pRecvMsg->m_StyleInfo.m_Slot;
	POSTYPE start = 0;
	POSTYPE total = pRecvMsg->m_StyleInfo.m_Count;
	for(POSTYPE i=start;i<total;++i)
	{
		pUser->SetStyle(slotIdx, pSlot[i].m_StylePos, &pSlot[i].m_Stream);
	}
}
Handler_FromGameServer_IMPL(DG_CHARINFO_QUEST_CMD)
{
	MSG_DG_CHARINFO_QUEST_CMD * pRecvMsg = (MSG_DG_CHARINFO_QUEST_CMD *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	DBUser * pUser = g_DBUserManager.FindUser( UserKey );
	ASSERT( pUser );
	DEBUG_CODE( 
		if( !pUser ) 
		{
			SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_QUEST_CMD)] [UserGUID:%u]", UserKey );
			return; 
		}
	);


	pUser->m_packet |= eMSG_DG_CHARINFO_QUEST_CMD;

	BYTE slotIdx = pUser->GetSelectedCharSlotIndex();

	pUser->SerializeQuestStream( slotIdx, pRecvMsg->m_pQuestStream, MAX_QUESTSTREAM_SIZE, SERIALIZE_STORE );
	pUser->SerializeMissionStream( slotIdx, pRecvMsg->m_pMissionStream, MAX_MISSIONSTREAM_SIZE, SERIALIZE_STORE );
}

Handler_FromGameServer_IMPL(DG_CHARINFO_WAREHOUSE_CMD)
{
	MSG_DG_CHARINFO_WAREHOUSE_CMD * pRecvMsg = (MSG_DG_CHARINFO_WAREHOUSE_CMD *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	DBUser * pUser = g_DBUserManager.FindUser( UserKey );
	ASSERT( pUser );
	DEBUG_CODE( 
		if( !pUser ) 
		{
			SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_WAREHOUSE_CMD)] [UserGUID:%u]", UserKey );
			return; 
		}
		);

	pUser->m_packet |= eMSG_DG_CHARINFO_WAREHOUSE_CMD;

	pUser->ClearWarehouseStream();

	ITEMSLOTEX * pSlot = pRecvMsg->m_ItemInfo.m_Slot;
	POSTYPE start = 0;
	POSTYPE total = pRecvMsg->m_ItemInfo.m_Count;
	for(POSTYPE i=start;i<total;++i)
		pUser->SetWarehouseItem(pSlot[i].m_ItemPos, &pSlot[i].m_Stream);

	pUser->SetWarehouseMoney(pRecvMsg->m_WarehouseMoney);

	pUser->SetNeedWarehouseToSave( TRUE );
}

Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_CMD)
{
	MSG_DG_CHARINFO_UDPATE_CMD * pRecvMsg = (MSG_DG_CHARINFO_UDPATE_CMD *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	DBUser * pUser = g_DBUserManager.FindUser( UserKey );
	DEBUG_CODE( 
		if( !pUser ) 
		{
			SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_CMD)][UserGUID:%u]", UserKey );
			return; 
		}
	);

	if( !pUser->IsValidSlot( pUser->GetSelectedCharSlotIndex() ) )
	{
		// 急琶等 某腐磐啊 乐瘤父, 单捞磐甫 罐瘤 给沁促.
		g_DBUserManager.DestroyUser(UserKey);
		SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_CMD)] 单捞磐甫 罐瘤 给茄 某腐磐啊 乐促. 昏力");
		return;
	}

	pUser->SetDBSaveState( eDB_SAVE_BEFORE );
	g_DBUserManager.MoveUserToCacheList( UserKey );

	// 芒绊 沥焊
	g_DBProxyServer.ExecutUpdateWarehouseQuery( pUser );

	UpdateCharacterQuery * pQuery = QUERYALLOC(UpdateCharacterQuery);
	pUser->MakeUpdateCharacterQuery(pQuery);
	pQuery->SetIndex( MAKEDWORD( (WORD)DG_CHARINFO, (WORD)DG_CHARINFO_UDPATE_CMD_DBR ) );
	pQuery->SetVoidObject( pServerSession );
	pServerSession->DBQuery( pQuery );
}

Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_CMD_DBR)
{
	MSG_DBPROXY_RESULT * pResult	= (MSG_DBPROXY_RESULT *)pMsg;
	UpdateCharacterQuery * pQResult	= (UpdateCharacterQuery *)pResult->m_pData;

	DWORD UserKey = pQResult->GetUserKey();
	DBUser * pUser = g_DBUserManager.FindUserFromCacheList( UserKey );
	if( !pUser ) 
	{
		// 绝阑 府 绝促.
		SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_CMD_DBR)] 某矫府胶飘俊蜡历啊绝促");
	}
	else
	{
		pUser->SetDBSaveState( eDB_SAVE_AFTER );
	}
	
	if( UpdateCharacterQuery::QUERY_RESULT_SUCCEEDED != pQResult->pCharacterParam[0].m_Result )
	{
		// 历厘 角菩!
		SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_CMD_DBR)] 某腐磐 历厘角菩(%s)", pQResult->GetQuery() );
	}
	QUERYFREE( UpdateCharacterQuery, pQResult ); pQResult = NULL;
}


// 辑滚埃 捞悼矫 (单捞磐 历厘茄促!)
// 某腐磐 急琶芒栏肺 捞悼
Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_SYN)
{
	MSG_DG_CHARINFO_UDPATE_SYN * pRecvMsg = (MSG_DG_CHARINFO_UDPATE_SYN *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	DBUser * pUser = g_DBUserManager.FindUser( UserKey );
	if( !pUser) 
	{
		SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_SYN)] 蜡历啊老馆府胶飘俊绝促" );
		ASSERT( ! "[DG_CHARINFO_UDPATE_SYN] 蜡历啊 绝阑府 绝促" );
		return;
	}

	pUser->SetDBSaveState( eDB_SAVE_BEFORE );
	g_DBUserManager.MoveUserToCacheList( UserKey );

	// 芒绊 沥焊
	g_DBProxyServer.ExecutUpdateWarehouseQuery( pUser );

	UpdateCharacterQuery * pQuery = QUERYALLOC(UpdateCharacterQuery);
	pUser->MakeUpdateCharacterQuery(pQuery);
	pQuery->SetIndex( MAKEDWORD( (WORD)DG_CHARINFO, (WORD)DG_CHARINFO_UDPATE_DBR ) );
	pQuery->SetVoidObject( pServerSession );
	//pQuery->SetType( pRecvMsg->m_byType );
	pServerSession->DBQuery( pQuery );
}

Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_DBR)
{
	MSG_DBPROXY_RESULT * pResult	= (MSG_DBPROXY_RESULT *)pMsg;
	UpdateCharacterQuery * pQResult		= (UpdateCharacterQuery *)pResult->m_pData;

	DWORD UserKey		= pQResult->GetUserKey();
	//BYTE Type			= pQResult->GetType();

	DBUser * pUser = g_DBUserManager.FindUserFromCacheList( UserKey );
	if( !pUser ) 
	{
		// 绝阑 府 绝促.
		SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_DBR)] 某矫府胶飘俊蜡历啊绝促");
		ASSERT( ! "[DG_CHARINFO_UDPATE_DBR] 某矫府胶飘俊 蜡历啊 绝阑府 绝促" );
	}
	else
	{
		pUser->SetDBSaveState( eDB_SAVE_AFTER );
	}

	if( UpdateCharacterQuery::QUERY_RESULT_SUCCEEDED != pQResult->pCharacterParam[0].m_Result )
	{
		// 历厘 角菩!
		SUNLOG(eFULL_LOG,  "[Handler_FromGameServer_IMPL(DG_CHARINFO_UDPATE_DBR)] 某腐磐 历厘角菩(%s)", pQResult->GetQuery() );
	}
	QUERYFREE( UpdateCharacterQuery, pQResult ); pQResult = NULL;

	
	MSG_DG_CHARINFO_UDPATE_ACK msg;
	msg.m_dwKey = UserKey;
	//msg.m_byType = Type;
	pServerSession->Send( (BYTE *)&msg, sizeof(msg) );
}

VOID Handler_FromGameServer::ExecuteCharacterQuery( ServerSession * pServerSession, DWORD DBIndex, DWORD CharGUID, DWORD UserKey, BYTE Type )
{
	TCHAR szQueryBuff[32];
	_sntprintf( szQueryBuff, sizeof(szQueryBuff), "S_SelectCharTest %u", CharGUID );
	SelectCharQuery * pQuery = SelectCharQuery::ALLOC();
	pQuery->SetIndex( DBIndex );
	pQuery->SetVoidObject( pServerSession );
	pQuery->SetQuery( szQueryBuff );
	pQuery->SetUserKey( UserKey );
	pQuery->SetType( Type );
	pServerSession->DBQuery( pQuery );

	//SUNLOG(eFULL_LOG,  "[ID:%d]:%s", UserKey, szQueryBuff );
}


Handler_FromGameServer_IMPL(DG_CHARINFO_ALL_REQ_SYN)
{
	MSG_DG_CHARINFO_ALL_REQ_SYN * pRecvMsg = (MSG_DG_CHARINFO_ALL_REQ_SYN *)pMsg;
	DWORD UserKey = pRecvMsg->m_dwKey;

	BOOL bCache = FALSE;
	// 某浆 府胶飘俊辑 啊廉柯促.
	DBUser * pUser = g_DBUserManager.FindUserFromCacheList(UserKey);
	if( pUser ) bCache = TRUE;

	if( !pUser )
	{
		// 某腐磐 积己
		pUser = g_DBUserManager.CreateUser_AddList(UserKey);
		ASSERT(pUser);
		if( !pUser ) 
		{

⌨️ 快捷键说明

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