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

📄 mssystem.cpp

📁 墨香最新私服
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		// AutoPatch
		yCASE(MP_MORNITORSERVER_CHECK_AUTOPATCH_ACK)
		{
			MSGMSSTATE* pmsg = (MSGMSSTATE*)pMsg;
			pmsg->Category = MP_MORNITORTOOL;
			pmsg->Protocol = MP_MORNITORTOOL_CHECK_AUTOPATCH_ACK;
			MASMGR->SendToAllMC( (char*)pmsg, sizeof(MSGMSSTATE) );
		}
		yCASE(MP_MORNITORSERVER_QUERY_AUTOPATCHVERSION_ACK)
		{
			MSGMSSTATE* pmsg = (MSGMSSTATE*)pMsg;
			pmsg->Category = MP_MORNITORTOOL;
			pmsg->Protocol = MP_MORNITORTOOL_QUERY_AUTOPATCHVERSION_ACK;
			MASMGR->SendToAllMC( (char*)pmsg, sizeof(MSGMSSTATE) );
		}
		yENDSWITCH
	}
	yENDSWITCH
}

void CMSSystem::ReceivedMsgFromServer(DWORD dwConnectionIndex,char* pMsg,DWORD dwLength)
{
	MSGROOT* pTempMsg = (MSGROOT*)pMsg;
	ySWITCH(g_pMSSystem->m_wServerType)
	yCASE(TYPE_MS)
		ReceivedMsgFrom2Server(dwConnectionIndex, pMsg, dwLength);
	yCASE(TYPE_MAS)
		ReceivedMsgFromMS(dwConnectionIndex,pMsg, dwLength);
	yENDSWITCH
}

//FROM MC肺 何磐 坷绰 巴
void CMSSystem::ReceivedMsgFromUser(DWORD dwConnectionIndex,char* pMsg,DWORD dwLength)
{
	MSGROOT* pTempMsg = (MSGROOT*)pMsg;
	if( pTempMsg->Category == MP_RMTOOL_CONNECT )
	{
		ConnentMsgParse(dwConnectionIndex, pMsg, dwLength);
		return;
	}

	if( !IPCHECKMGR->CheckIP( dwConnectionIndex ) )
		return;

	ySWITCH(pTempMsg->Category)
	yCASE(MP_MORNITORTOOL)
	{
		ySWITCH(pTempMsg->Protocol)
		yCASE(MP_MORNITORTOOL_QUERYUSERCOUNT_SYN)
		{
			// send to ms all
			MSGMC msg;
			msg.Category = MP_MORNITORSERVER;
			msg.Protocol = MP_MORNITORSERVER_QUERYUSERCOUNT_SYN;
			msg.dwConnectionIdxMC = dwConnectionIndex;
			MNETWORK->SendToMSAll((char*)&msg, sizeof(msg));
		}
		yCASE(MP_MORNITORTOOL_QUERY_CHANNELINFO_SYN)
		{
			MSGROOT Msg;
			Msg.Category = MP_MORNITORSERVER;
			Msg.Protocol = MP_MORNITORSERVER_QUERY_CHANNELINFO_SYN;
			MNETWORK->SendToMSAll( (char*)&Msg, sizeof(MSGROOT) );
		}
		yCASE(MP_MORNITORTOOL_EXECUTE_MAPSERVER_SYN)
		{
			MSGEXECUTESERVER * pmsg = (MSGEXECUTESERVER *)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_EXECUTE_MAPSERVER_SYN;
			pmsg->dwConnectionIdxMC = dwConnectionIndex;
			// map辑滚 器飘肺 map捞 家加等 ms甫 茫酒辑 ms肺 焊辰促.
			
			MSERVERINFO * pInfo = MServerTable->GetMSServerInfoForIP(pmsg->ServerIP);
			if(pInfo)
			{

				MNETWORK->SendToMS(pInfo->dwConnectionIndex, pMsg, dwLength);
				LogConsole("sendEXEMsg To MS(CON:%d, IP:%s, PORT:%d)", pInfo->dwConnectionIndex, pInfo->szIPForServer, pInfo->wPortForServer);
			}			
		}
		yCASE(MP_MORNITORTOOL_SHUTDOWN_MAPSERVER_SYN)	// Msg肺 辑滚 阐.
		{
			MSGSHUTDOWNSERVER * pmsg = (MSGSHUTDOWNSERVER *)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_SHUTDOWN_MAPSERVER_SYN;
			pmsg->dwConnectionIdxMC = dwConnectionIndex;
			// map辑滚 器飘肺 map捞 家加等 ms甫 茫酒辑 ms肺 焊辰促.
			MSERVERINFO * pInfo = MServerTable->GetMSServerInfoForIP(pmsg->ServerIP);
			if(pInfo)
			MNETWORK->SendToMS(pInfo->dwConnectionIndex, pMsg, dwLength);
		}
		yCASE(MP_MORNITORTOOL_KILL_SERVER_SYN)			// 碍力 辆丰(abnormal)
		{
			MSGSHUTDOWNSERVER* pmsg = (MSGSHUTDOWNSERVER*)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_KILL_SERVER_SYN;
			pmsg->dwConnectionIdxMC = dwConnectionIndex;
			// map辑滚 器飘肺 map捞 家加等 ms甫 茫酒辑 ms肺 焊辰促.
			MSERVERINFO * pInfo = MServerTable->GetMSServerInfoForIP(pmsg->ServerIP);
			if(pInfo)
				MNETWORK->SendToMS(pInfo->dwConnectionIndex, pMsg, dwLength);
		}
		yCASE(MP_MORNITORTOOL_NOTICESEND_SYN)
		{
			MSGNOTICE * pmsg = (MSGNOTICE *)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_NOTICESEND_SYN;
			pmsg->dwConnectionIdxMC = dwConnectionIndex;
			MNETWORK->SendToMSAll(pMsg, dwLength);
		}
		yCASE(MP_MORNITORTOOL_MAPSERVERSTATE_SYN)
		{
			// Request
			//辑滚 惑怕 ACK
			MASMGR->SendServerStateAllToMC(dwConnectionIndex);
		}
		yCASE(MP_MORNITORTOOL_EXECUTE_AUTOPATCH_SYN)	// AutoPatch
		{
			MSGROOT msg;
			msg.Category = MP_MORNITORSERVER;
			msg.Protocol = MP_MORNITORSERVER_EXECUTE_AUTOPATCH_SYN;
			MNETWORK->SendToMSAll( (char*)&msg, sizeof(msg));
		}
		yCASE(MP_MORNITORTOOL_CHANGE_USERLEVEL_SYN)		// UserLevel
		{
			MSGROOT* msg = (MSGROOT*)pMsg;
			msg->Category = MP_MORNITORSERVER;
			msg->Protocol = MP_MORNITORSERVER_CHANGE_USERLEVEL_SYN;
			MNETWORK->SendToMSAll( (char*)msg, dwLength );			
		}
		yCASE(MP_MORNITORTOOL_ASSERTMSGBOX_SYN)
		{
			MSG_MCDWORD* msg = (MSG_MCDWORD*)pMsg;
			msg->Category = MP_MORNITORSERVER;
			msg->Protocol = MP_MORNITORSERVER_ASSERTMSGBOX_SYN;
			MNETWORK->SendToMSAll( (char*)msg, dwLength );
		}
		yCASE(MP_MORNITORTOOL_DISCONNECT_ALLUSER_SYN)
		{
			MSGEXECUTESERVER* pmsg = (MSGSHUTDOWNSERVER *)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_DISCONNECT_ALLUSER_SYN;
			pmsg->dwConnectionIdxMC = dwConnectionIndex;
			// map辑滚 器飘肺 map捞 家加等 ms甫 茫酒辑 ms肺 焊辰促.
			MSERVERINFO * pInfo = MServerTable->GetMSServerInfoForIP(pmsg->ServerIP);
			if(pInfo)
				MNETWORK->SendToMS(pInfo->dwConnectionIndex, pMsg, dwLength);
			
//			MNETWORK->SendToMSAll( (char*)pmsg, dwLength );
		}		
		yCASE(MP_MORNITORTOOL_QUERY_VERSION_SYN)
		{
			MSGROOT* pmsg = (MSGROOT*)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_QUERY_VERSION_SYN;
			MNETWORK->SendToMSAll( (char*)pmsg, dwLength );
		}
		yCASE(MP_MORNITORTOOL_CHANGE_VERSION_SYN)
		{
			MSGNOTICE* pmsg = (MSGNOTICE*)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_CHANGE_VERSION_SYN;
			MNETWORK->SendToMSAll( (char*)pmsg, dwLength );
		}
		yCASE(MP_MORNITORTOOL_QUERY_MAXUSER_SYN)
		{
			MSGROOT* pmsg = (MSGROOT*)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_QUERY_MAXUSER_SYN;
			MNETWORK->SendToMSAll( (char*)pmsg, dwLength );	
		}
		yCASE(MP_MORNITORTOOL_CHANGE_MAXUSER_SYN)
		{
			MSG_MCDWORD* pmsg = (MSG_MCDWORD*)pMsg;
			pmsg->Category = MP_MORNITORSERVER;
			pmsg->Protocol = MP_MORNITORSERVER_CHANGE_MAXUSER_SYN;
			MNETWORK->SendToMSAll( (char*)pmsg, dwLength );			
		}
		yCASE(MP_MORNITORTOOL_MSSTATEALL_SYN)
		{
			MSERVERINFO* info = NULL;
			MSGMSSTATEALL Msg;
			MServerTable->SetPositionHeadInfo();			
			while( info = (MSERVERINFO*)MServerTable->GetDataInfo() )
			{
				MSSTATE state;
				strcpy( state.sServerIP, info->szIPForServer );
				state.wServerPort = info->wPortForServer;

				Msg.AddMSServerState( &state );
			}

			Msg.Category = MP_MORNITORTOOL;
			Msg.Protocol = MP_MORNITORTOOL_MSSTATEALL_ACK;

			MNETWORK->SendToMC( dwConnectionIndex, (char*)&Msg, Msg.GetSize() );
		}
		yCASE(MP_MORNITORTOOL_QUERY_AUTOPATCHVERSION_SYN)
		{
			MSGROOT Msg;
			Msg.Category = MP_MORNITORSERVER;
			Msg.Protocol = MP_MORNITORSERVER_QUERY_AUTOPATCHVERSION_SYN;
			MNETWORK->SendToMSAll( (char*)&Msg, sizeof(MSGROOT) );
		}
		yENDSWITCH
	}
/*	yCASE(MP_RMTOOL_CONNECT)
	{
		ConnentMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_USER)
	{
		UserMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_MUNPA)
	{
		MunpaMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_GAMELOG)
	{
		GameLogMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_OPERLOG)
	{
		OperLogMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_STATISTICS)
	{
		StatisticsMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_ADMIN)
	{
		AdminMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_CHARACTER)
	{
		CharacterMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE( MP_RMTOOL_ITEM )
	{
		ItemMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	*/
	yENDSWITCH
}

void CMSSystem::OnAcceptUser(DWORD dwConnectionIndex)
{
	// mc立加秦 咳
	LogConsole("Mc立加");
	MCINFO Info;
	Info.dwConnectionIndex = dwConnectionIndex;
	MUserTable->AddUser(&Info, dwConnectionIndex);
	// sendserverstate all
//	MASMGR->SendServerStateAllToMC(dwConnectionIndex);
	
}
void CMSSystem::OnDisconnectUser(DWORD dwConnectionIndex)
{
	// nothing
	LogConsole("Mc谗绢咙");
	MUserTable->RemoveUser(dwConnectionIndex);
}

/////////////////////////////////////////////////////////////////////////////////////
// MR_TOOL only
void CMSSystem::ReceivedMsgFromRMTool( DWORD dwConnectionIndex,char* pMsg,DWORD dwLength )
{
	MSGROOT* pTempMsg = (MSGROOT*)pMsg;

	if( pTempMsg->Category == MP_RMTOOL_CONNECT )
	{
		ConnentMsgParse(dwConnectionIndex, pMsg, dwLength);
		return;
	}

	if( !IPCHECKMGR->CheckIP( dwConnectionIndex ) )
		return;

	ySWITCH(pTempMsg->Category)
//	yCASE(MP_RMTOOL_CONNECT)
//	{
//		ConnentMsgParse(dwConnectionIndex, pMsg, dwLength);
//	}
	yCASE(MP_RMTOOL_USER)
	{
		UserMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_MUNPA)
	{
		MunpaMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_GAMELOG)
	{
		GameLogMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_OPERLOG)
	{
		OperLogMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_STATISTICS)
	{
		StatisticsMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_ADMIN)
	{
		AdminMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE(MP_RMTOOL_CHARACTER)
	{
		CharacterMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yCASE( MP_RMTOOL_ITEM )
	{
		ItemMsgParse(dwConnectionIndex, pMsg, dwLength);
	}
	yENDSWITCH	
}

void CMSSystem::ConnentMsgParse(DWORD dwConnectionIndex,char* pMsg,DWORD dwLength)
{
	MSGROOT* pTempMsg = (MSGROOT*)pMsg;
	ySWITCH(pTempMsg->Protocol)
	{
		yCASE(MP_RMTOOL_CONNECT_SYN)
		{
			TMSG_OPERATOR_LOGIN* msg = (TMSG_OPERATOR_LOGIN*)pMsg;
			// Id/Pwd 八荤  Ip checking 殿殿..
			char strIP[20] = {0,};
			WORD wPort;
			MNETWORK->GetUserAddress(dwConnectionIndex, strIP, &wPort);
/*
			if( strcmp(msg->sIP.strIP, strIP) != 0 )
			{
				TMSG_WORD msg;
				msg.Category = MP_RMTOOL_CONNECT;
				msg.Protocol = MP_RMTOOL_CONNECT_NACK;
				msg.dwTemplateIdx = 0;
				msg.wData = 1;
				
				MNETWORK->SendToMC(dwConnectionIndex, (char*)&msg, sizeof(msg));
				return;
			}
*/
			// version check
			if( strcmp(msg->sOper.strRegDate,"mastertjdeoekt!") == 0 )
			{
				OperatorLoginCheck(dwConnectionIndex, msg->sOper.strOperID, msg->sOper.strOperPWD, strIP);
			}
			else
			{
				TMSG_WORD Msg;
				Msg.Category = MP_RMTOOL_CONNECT;
				Msg.Protocol = MP_RMTOOL_CONNECT_NACK;
				Msg.dwTemplateIdx = 0;
				Msg.wData = 4;
				if( g_pMSSystem->m_wServerType == TYPE_MAS )
				{
					if( strcmp(msg->sOper.strRegDate, SERVERTOOLVERSION) != 0 )
					{
						MNETWORK->SendToMC(dwConnectionIndex, (char*)&Msg, sizeof(Msg));
						return;
					}
				}
				else if( g_pMSSystem->m_wServerType == TYPE_RMS )
				{
					if( strcmp(msg->sOper.strRegDate, RMTOOLVERSION) != 0 )
					{

⌨️ 快捷键说明

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