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

📄 handler_fromguildserver.cpp

📁 奇迹世界data 服务器代码,研究游戏的朋友有帮助
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include "StdAfx.h"
#include ".\handler_fromguildserver.h"
#include ".\GuildServerQuery.h"
#include <PacketStruct_DZ.h>
#include "GuildServerQuery.h"
#include "ServerSession.h"


Handler_FromGuildServer_IMPL( DZ_GUILD_SELECT_SYN )
{
	MSG_DZ_GUILD_SELECT_SYN * pRecvMsg = (MSG_DZ_GUILD_SELECT_SYN *)pMsg;
	
	TCHAR szQueryBuff[64];
	_sntprintf( szQueryBuff, sizeof(szQueryBuff), "{?=call S_Guild_Select(%d)}" , pRecvMsg->m_GuildGuid );

	SelectGuildQuery * pQuery = SelectGuildQuery::ALLOC();
	pQuery->SetGuildGuid( pRecvMsg->m_GuildGuid );
	pQuery->SetUserKey( pRecvMsg->m_dwKey );
	pQuery->SetSessionIndex( pRecvMsg->m_dwSessionIndex );

	pQuery->SetQuery(szQueryBuff);
	pQuery->SetIndex( MAKEDWORD( (WORD)DZ_GUILD, (WORD)DZ_GUILD_SELECT_DBR ) );
	pQuery->SetVoidObject( pServerSession );
	pServerSession->DBQuery( pQuery );
}

Handler_FromGuildServer_IMPL( DZ_GUILD_SELECT_DBR )
{
	MSG_DBPROXY_RESULT * pResult	= (MSG_DBPROXY_RESULT *)pMsg;
	SelectGuildQuery * pQResult		= (SelectGuildQuery *)pResult->m_pData;

	if( !pQResult->ResultSuccess() )
	{
		MSG_DZ_GUILD_SELECT_NAK nmsg;
		nmsg.m_dwKey			= pQResult->GetUserKey();
		nmsg.m_dwSessionIndex	= pQResult->GetSessionIndex();
		nmsg.m_GuildGuid		= pQResult->GetGuildGuid();
		nmsg.m_byErrorCode		= 0;
		pServerSession->SendPacket( &nmsg, sizeof(nmsg) );
		SelectGuildQuery::FREE(pQResult); pQResult = NULL;
		return;
	}


	//------------------------------------------------------------------------------------------------------------------------
	// 辨靛 干滚 孽府!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	//------------------------------------------------------------------------------------------------------------------------
	TCHAR szQueryBuff[64];
	_sntprintf( szQueryBuff, sizeof(szQueryBuff), "{?=call S_Guild_SelectMember(%d)}", pQResult->GetGuildGuid() );

	SelectGuildMemberQuery * pQuery = SelectGuildMemberQuery::ALLOC();
	pQuery->SetGuildGuid( pQResult->GetGuildGuid() );
	pQuery->SetUserKey( pQResult->GetUserKey() );
	pQuery->SetSelectGuildQuery( pQResult );
	pQuery->SetSessionIndex( pQResult->GetSessionIndex() );

	pQuery->SetQuery(szQueryBuff);
	pQuery->SetIndex( MAKEDWORD( (WORD)DZ_GUILD, (WORD)DZ_GUILD_SELECT_MEMBER_DBR ) );
	pQuery->SetVoidObject( pServerSession );
	pServerSession->DBQuery( pQuery );

	//MSG_DZ_GUILD_SELECT_ACK msg;
	//msg.m_dwKey									= pQResult->GetUserKey();
	//msg.m_GuildInfo.m_GuildGuid					= pQResult->GetGuildGuid();
	//memcpy( msg.m_GuildInfo.m_tszGuildName, pQResult->pResult[0].m_tszGuildName, MAX_GUILDNAME_LENGTH*sizeof(TCHAR) );
	//msg.m_GuildInfo.m_GuildGrade				= pQResult->pResult[0].m_GuildGrade;
	//memcpy( msg.m_GuildInfo.m_MarkBinary, pQResult->pResult[0].m_MarkBinary, MAX_GUILDMARKSTREAM_SIZE );
	//msg.m_GuildInfo.m_MasterCharGuid			= pQResult->pResult[0].m_MasterCharGuid;
	//memcpy( msg.m_GuildInfo.m_tszMasterCharName, pQResult->pResult[0].m_tszMasterCharName, MAX_CHARNAME_LENGTH*sizeof(TCHAR) );
	//msg.m_GuildInfo.m_GuildPoint				= pQResult->pResult[0].m_GuildPoint;
	//msg.m_GuildInfo.m_RestrictedRight			= pQResult->pResult[0].m_RestrictedRight;
	//msg.m_GuildInfo.m_GuildMoney				= pQResult->pResult[0].m_GuildMoney;
	//pServerSession->SendPacket( &msg, sizeof(msg) );

	//SelectGuildQuery::FREE(pQResult); pQResult = NULL;
}

//
//Handler_FromGuildServer_IMPL( DZ_GUILD_SELECT_GUILD_MEMBER_SYN )
//{
//	MSG_DZ_GUILD_SELECT_GUILD_MEMBER_SYN * pRecvMsg = (MSG_DZ_GUILD_SELECT_GUILD_MEMBER_SYN *)pMsg;
//
//	TCHAR szQueryBuff[64];
//	_sntprintf( szQueryBuff, sizeof(szQueryBuff), "{ ? = call S_SelectGuildMember ( %d ) }", pRecvMsg->m_GuildGuid );
//
//	SelectGuildMemberQuery * pQuery = SelectGuildMemberQuery::ALLOC();
//	pQuery->SetGuildGuid( pRecvMsg->m_GuildGuid );
//	pQuery->SetUserKey( pRecvMsg->m_dwKey );
//
//	pQuery->SetQuery(szQueryBuff);
//	pQuery->SetIndex( MAKEDWORD( (WORD)DZ_GUILD, (WORD)DZ_GUILD_SELECT_GUILD_MEMBER_DBR ) );
//	pQuery->SetVoidObject( pServerSession );
//	pServerSession->DBQuery( pQuery );
//}

Handler_FromGuildServer_IMPL( DZ_GUILD_SELECT_MEMBER_DBR )
{
	MSG_DBPROXY_RESULT * pResult		= (MSG_DBPROXY_RESULT *)pMsg;
	SelectGuildMemberQuery * pQResult	= (SelectGuildMemberQuery *)pResult->m_pData;

	if( !pQResult->ResultSuccess() )
	{
		MSG_DZ_GUILD_SELECT_NAK nmsg;
		nmsg.m_dwKey			= pQResult->GetUserKey();
		nmsg.m_dwSessionIndex	= pQResult->GetSessionIndex();
		nmsg.m_GuildGuid		= pQResult->GetGuildGuid();
		nmsg.m_byErrorCode		= 0;
		pServerSession->SendPacket( &nmsg, sizeof(nmsg) );

		SelectGuildQuery::FREE(pQResult->GetSelectGuildQuery());
		SelectGuildMemberQuery::FREE(pQResult); pQResult = NULL;
		return;
	}

	ASSERT( pQResult->GetResultRowNum() <= MSG_DZ_GUILD_SELECT_ACK::_MAX_GUILD_MEMBER_INFO_NUM ); 
	
	SelectGuildQuery * pSelectQResult			= pQResult->GetSelectGuildQuery();
	MSG_DZ_GUILD_SELECT_ACK msg;
	msg.m_dwKey	= pQResult->GetUserKey();
	msg.m_dwSessionIndex = pQResult->GetSessionIndex();

	msg.m_GuildInfo.m_GuildGuid					= pQResult->GetGuildGuid();
	memcpy( msg.m_GuildInfo.m_tszGuildName, pSelectQResult->pResult[0].m_tszGuildName, MAX_GUILDNAME_LENGTH*sizeof(TCHAR) );
	msg.m_GuildInfo.m_GuildGrade				= pSelectQResult->pResult[0].m_GuildGrade;
	memcpy( msg.m_GuildInfo.m_MarkBinary, pSelectQResult->pResult[0].m_MarkBinary, MAX_GUILDMARKSTREAM_SIZE );
	msg.m_GuildInfo.m_MasterCharGuid			= pSelectQResult->pResult[0].m_MasterCharGuid;
	memcpy( msg.m_GuildInfo.m_tszMasterCharName, pSelectQResult->pResult[0].m_tszMasterCharName, MAX_CHARNAME_LENGTH*sizeof(TCHAR) );
	memcpy( msg.m_GuildInfo.m_tszGuildNotice, pSelectQResult->pResult[0].m_tszGuildNotice, MAX_GUILDNOTICE_LENGTH*sizeof(TCHAR) );
	msg.m_GuildInfo.m_UserPoint					= pSelectQResult->pResult[0].m_GuildUserPoint;
	msg.m_GuildInfo.m_GuildPoint				= pSelectQResult->pResult[0].m_GuildPoint;
	msg.m_GuildInfo.m_RestrictedRight			= pSelectQResult->pResult[0].m_RestrictedRight;
	msg.m_GuildInfo.m_GuildMoney				= pSelectQResult->pResult[0].m_GuildMoney;
	msg.m_Count = (BYTE)pQResult->GetResultRowNum();
	if( msg.m_Count > MSG_DZ_GUILD_SELECT_ACK::_MAX_GUILD_MEMBER_INFO_NUM )
		msg.m_Count = MSG_DZ_GUILD_SELECT_ACK::_MAX_GUILD_MEMBER_INFO_NUM;

	for( BYTE i = 0 ; i < msg.m_Count ; ++i )
	{
		msg.m_MemberInfo[i].m_CharGuid		= pQResult->pResult[i].m_CharGUID;
		memcpy( msg.m_MemberInfo[i].m_tszCharName, pQResult->pResult[i].m_tszCharName, MAX_CHARNAME_LENGTH*sizeof(TCHAR) );
		msg.m_MemberInfo[i].m_byClass		= pQResult->pResult[i].m_byClass;
		msg.m_MemberInfo[i].m_LV			=pQResult->pResult[i].m_LV;
		msg.m_MemberInfo[i].m_byPosition	= pQResult->pResult[i].m_byPosition;
	}
	
	pServerSession->SendPacket( &msg, msg.GetSize() );

	SelectGuildQuery::FREE(pQResult->GetSelectGuildQuery());
	SelectGuildMemberQuery::FREE(pQResult); pQResult = NULL;
}

Handler_FromGuildServer_IMPL( DZ_GUILD_CREATE_SYN )
{
	MSG_DZ_GUILD_CREATE_SYN * pRecvMsg = (MSG_DZ_GUILD_CREATE_SYN *)pMsg;
	
	TCHAR szQueryBuff[100];

	TCHAR tszTmpGuildName[MAX_GUILDNAME_LENGTH+1];
	TCHAR tszTmpMasterCharName[MAX_CHARNAME_LENGTH+1];
	memcpy( tszTmpGuildName, pRecvMsg->m_tszGuildName, MAX_GUILDNAME_LENGTH*sizeof(TCHAR) );
	memcpy( tszTmpMasterCharName, pRecvMsg->m_szMasterCharName, MAX_CHARNAME_LENGTH*sizeof(TCHAR) );
	tszTmpGuildName[MAX_GUILDNAME_LENGTH] = '\0';
	tszTmpMasterCharName[MAX_CHARNAME_LENGTH] = '\0';

	_sntprintf( szQueryBuff, sizeof(szQueryBuff), 
		"{?=call S_Guild_Create('%s',%d,'%s')}", 
		tszTmpGuildName, pRecvMsg->m_MasterCharGuid, tszTmpMasterCharName );

	CreateGuildQuery * pQuery = CreateGuildQuery::ALLOC();
	pQuery->SetUserKey( pRecvMsg->m_dwKey );
	pQuery->SetCharGuid( pRecvMsg->m_MasterCharGuid );
	pQuery->SetSessionIndex( pRecvMsg->m_dwSessionIndex );

	pQuery->SetQuery(szQueryBuff);
	pQuery->SetIndex( MAKEDWORD( (WORD)DZ_GUILD, (WORD)DZ_GUILD_CREATE_DBR ) );
	pQuery->SetVoidObject( pServerSession );
	pServerSession->DBQuery( pQuery );
}

Handler_FromGuildServer_IMPL( DZ_GUILD_CREATE_DBR )
{
	MSG_DBPROXY_RESULT * pResult	= (MSG_DBPROXY_RESULT *)pMsg;
	CreateGuildQuery * pQResult		= (CreateGuildQuery *)pResult->m_pData;

	if( pQResult->ResultCode() != CreateGuildQuery::RETURNCODE_SUCCESS )
	{
		MSG_DZ_GUILD_CREATE_NAK nmsg;
		nmsg.m_dwKey			= pQResult->GetUserKey();
		nmsg.m_dwSessionIndex	= pQResult->GetSessionIndex();
		nmsg.m_byErrorCode		= pQResult->ResultCode();
		nmsg.m_MasterCharGuid	= pQResult->GetCharGuid();
		pServerSession->SendPacket( &nmsg, sizeof(nmsg) );
		CreateGuildQuery::FREE(pQResult); pQResult = NULL;
		return;
	}

	MSG_DZ_GUILD_CREATE_ACK msg;
	msg.m_dwKey				= pQResult->GetUserKey();
	msg.m_dwSessionIndex	= pQResult->GetSessionIndex();
	msg.m_GuildGuid			= pQResult->pResult[0].m_GuildGuid;
	msg.m_MasterCharGuid	= pQResult->GetCharGuid();
	pServerSession->SendPacket( &msg, sizeof(msg) );

⌨️ 快捷键说明

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