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

📄 gmcmdmanager.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include "stdAfx.h"
#include ".\gmcmdmanager.h"
#include "User.h"
#include "UserManager.h"
#include <GMList.h>
#include <PacketStruct_CW.h>
#include <ResultCode.h>

// 傍瘤 困秦
#include "Zone.h"
#include "Channel.h"
#include "ChannelManager.h"

GMCmdManager::GMCmdManager(void)
{
	m_vecCmd.reserve( 10 );
	m_GMString.Init();
}

GMCmdManager::~GMCmdManager(void)
{

}


bool GMCmdManager::ParseCommand( User* pUser, const char* szCmd )
{
	m_vecCmd.clear();

	if( !IsGMUser( pUser ) )
	{
		// 捞 版快绰 农贰欧捞唱 橇肺配妮 鸥涝 滚弊老 啊瓷己捞 乐促
		MessageOut(eCRITICAL_LOG, "GM 酒囱 蜡历啊 傍瘤 夸没!!!(%s)", pUser->GetCharName().c_str());
		return false;
	}

	if( !m_Parser.Parsing( szCmd, m_vecCmd ) )
		return false;

	if( !ProcessCommand( pUser, m_vecCmd ) )
		return false;

	return true;
}


bool GMCmdManager::ProcessCommand( User* pUser, vector<string>& vecCmd )
{
	int nSize = (int)vecCmd.size();
	bool bSuccess = false;

	if(nSize > 0)
	{
		string strHead = vecCmd[0];

		if( strHead.compare( m_GMString.GetWorldNotice() ) == 0 )					// 岿靛 傍瘤
		{
			bSuccess = ProcessWorldNotice( pUser, vecCmd );
		}
		else if( strHead.compare( m_GMString.GetChannelNotice() ) == 0 )					// 盲澄 傍瘤
		{
			bSuccess = ProcessChannelNotice( pUser, vecCmd );
		}
		else if( strHead.compare( m_GMString.GetZoneNotice() ) == 0 )					// 瘤开 傍瘤
		{
			bSuccess = ProcessZoneNotice( pUser, vecCmd );
		}
	}

	return bSuccess;
}


BOOL GMCmdManager::IsGMUser( User *pUser )
{
	GM_INFO* pGMInfo = GMList::Instance()->FindGM( pUser->GetCharName().c_str() );

	if( !pGMInfo )
	{
		MSG_CW_GM_STRING_CMD_NAK NakMsg;
		NakMsg.m_byErrorCode =  RC::RC_GM_ISNOT_GM;		// GM捞 酒聪促.
		pUser->Send( (BYTE*)&NakMsg, sizeof(NakMsg) );
		return FALSE;
	}

	return TRUE;
}


// 岿靛 傍瘤
bool GMCmdManager::ProcessWorldNotice( User* pUser, vector<string>& vecCmd )
{
	// vecCmd 俺荐父怒 佬绰促
	TCHAR	tszNoticeMsg[100]={0,};
	WORD	wCount=0;

	for(int i = 1; i<vecCmd.size(); i++)
	{
		// 傍瘤 皋矫瘤 炼赋
		if(wCount + vecCmd[i].size() > MAX_NOTICE_LEN )
		{
			// 傍瘤 辨捞 捞惑篮 肋赴促
			break;
		}
		_tcscat( tszNoticeMsg + wCount, vecCmd[i].c_str() );
		wCount += vecCmd[i].size();
		tszNoticeMsg[wCount++] = ' ';
	}
	tszNoticeMsg[wCount-1]='\0';

	MSG_CW_NOTICE_BRD noticeMsg;
	noticeMsg.m_byCategory	= CW_CHAT;
	noticeMsg.m_byProtocol	= CW_NOTICE_BRD;
	noticeMsg.wLen			= wCount;
	memset(noticeMsg.szMsg, 0, sizeof(noticeMsg.szMsg));
	memcpy( noticeMsg.szMsg, tszNoticeMsg, noticeMsg.wLen ); 

	// 爱绊 乐绰 葛电 蜡历甸俊霸 朝赴促
	UserManager::Instance()->SendToAll( (BYTE*)&noticeMsg, noticeMsg.GetSize() );

	char szNotice[MAX_NOTICE_LEN + 1];
	ZeroMemory( szNotice, sizeof(szNotice) );
	strncpy( szNotice, noticeMsg.szMsg, noticeMsg.wLen );
	MessageOut(eCRITICAL_LOG,  "-----------------------------<< 傈眉傍瘤 >>-----------------------------" );
	MessageOut(eCRITICAL_LOG,  "%s(%u)", noticeMsg.szMsg, noticeMsg.wLen );
	MessageOut(eCRITICAL_LOG,  "------------------------------------------------------------------------" );

	return true;
}

// 盲澄 傍瘤
bool GMCmdManager::ProcessChannelNotice( User* pUser, vector<string>& vecCmd )
{
	// vecCmd 俺荐父怒 佬绰促
	TCHAR	tszNoticeMsg[100]={0,};
	WORD	wCount=0;

	for(int i = 1; i<vecCmd.size(); i++)
	{
		// 傍瘤 皋矫瘤 炼赋
		if(wCount + vecCmd[i].size() > MAX_NOTICE_LEN )
		{
			// 傍瘤 辨捞 捞惑篮 肋赴促
			break;
		}
		_tcscat( tszNoticeMsg + wCount, vecCmd[i].c_str() );
		wCount += vecCmd[i].size();
		tszNoticeMsg[wCount++] = ' ';
	}
	tszNoticeMsg[wCount-1]='\0';

	MSG_CW_NOTICE_BRD noticeMsg;
	noticeMsg.m_byCategory	= CW_CHAT;
	noticeMsg.m_byProtocol	= CW_NOTICE_BRD;
	noticeMsg.wLen			= wCount;
	memset(noticeMsg.szMsg, 0, sizeof(noticeMsg.szMsg));
	memcpy( noticeMsg.szMsg, tszNoticeMsg, noticeMsg.wLen ); 

	// 秦寸 蜡历啊 立加茄 盲澄俊父 朝妨霖促
	Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
	if(!pChannel)
	{
		// 荤侩磊狼 盲澄 ID啊 撇啡促. 摹疙利牢 滚弊
		MessageOut( eCRITICAL_LOG, "荤侩磊 %s狼 盲澄 %u啊 粮犁窍瘤 臼澜!! 傍瘤 角菩!!", pUser->GetCharName().c_str(), pUser->GetChannelID() );
		return false;
	}
	// 付阑, 硅撇粮 葛滴 傍瘤
	pChannel->SendToAll( (BYTE*)&noticeMsg, noticeMsg.GetSize() );

	char szNotice[MAX_NOTICE_LEN + 1];
	ZeroMemory( szNotice, sizeof(szNotice) );
	strncpy( szNotice, noticeMsg.szMsg, noticeMsg.wLen );
	MessageOut(eCRITICAL_LOG,  "----------------------------<< %d盲澄 傍瘤 >>----------------------------", pUser->GetChannelID() );
	MessageOut(eCRITICAL_LOG,  "%s(%u)", noticeMsg.szMsg, noticeMsg.wLen );
	MessageOut(eCRITICAL_LOG,  "------------------------------------------------------------------------" );

	return true;
}

// 瘤开 傍瘤
bool GMCmdManager::ProcessZoneNotice( User* pUser, vector<string>& vecCmd )
{
	// vecCmd 俺荐父怒 佬绰促
	TCHAR	tszNoticeMsg[100]={0,};
	WORD	wCount=0;

	for(int i = 1; i<vecCmd.size(); i++)
	{
		// 傍瘤 皋矫瘤 炼赋
		if(wCount + vecCmd[i].size() > MAX_NOTICE_LEN )
		{
			// 傍瘤 辨捞 捞惑篮 肋赴促
			break;
		}
		_tcscat( tszNoticeMsg + wCount, vecCmd[i].c_str() );
		wCount += vecCmd[i].size();
		tszNoticeMsg[wCount++] = ' ';
	}
	tszNoticeMsg[wCount-1]='\0';

	MSG_CW_NOTICE_BRD noticeMsg;
	noticeMsg.m_byCategory	= CW_CHAT;
	noticeMsg.m_byProtocol	= CW_NOTICE_BRD;
	noticeMsg.wLen			= wCount;
	memset(noticeMsg.szMsg, 0, sizeof(noticeMsg.szMsg));
	memcpy( noticeMsg.szMsg, tszNoticeMsg, noticeMsg.wLen ); 

	Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
	if(!pChannel)
	{
		// 荤侩磊狼 盲澄 ID啊 撇啡促. 摹疙利牢 滚弊
		MessageOut( eCRITICAL_LOG, "荤侩磊 %s狼 盲澄 %u啊 粮犁窍瘤 臼澜!! 瘤开傍瘤 角菩!!", pUser->GetCharName().c_str(), pUser->GetChannelID() );
		return false;
	}
	Zone *pZone = NULL;
	switch(pUser->GetStatus())
	{
		case eZONETYPE_CHARSELECT:

⌨️ 快捷键说明

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