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

📄 mssystem.cpp

📁 墨香最新私服
💻 CPP
📖 第 1 页 / 共 4 页
字号:
{
	MSGROOT* pMsg = (MSGROOT*)pmsg;
	ySWITCH(pMsg->Category)
	yCASE(MP_MORNITORMAPSERVER)		// from MapServer
	{
		ySWITCH(pMsg->Protocol)
		yCASE(MP_MORNITORMAPSERVER_QUERYUSERCOUNT_ACK)
		{
			MSGUSERCOUNT * pMsg = (MSGUSERCOUNT *)pmsg;
			MSERVERINFO * pInfo = MServerTable->GetServerInfoForConn(dwConnectionIndex);
			pMsg->Category = MP_MORNITORSERVER;
			pMsg->Protocol = MP_MORNITORSERVER_QUERYUSERCOUNT_ACK;
			pMsg->ServerPort = pInfo->wPortForServer;
			MNETWORK->SendToMAS(pmsg, sizeof(MSGUSERCOUNT));
		}
		yCASE(MP_MORNITORMAPSERVER_QUERY_CHANNELINFO_ACK)
		{			
			MSG_CHANNEL_INFO_MORNITOR Msg;
			Msg.ChannelInfo = *((MSG_CHANNEL_INFO*)pmsg);
			MSERVERINFO* pInfo = MServerTable->GetServerInfoForConn( dwConnectionIndex );
			strcpy( Msg.sServerIP, pInfo->szIPForServer );
			Msg.wServerPort = pInfo->wPortForServer;
			Msg.Category = MP_MORNITORSERVER;
			Msg.Protocol = MP_MORNITORSERVER_QUERY_CHANNELINFO_ACK;
			MNETWORK->SendToMAS( (char*)&Msg, sizeof(MSG_CHANNEL_INFO_MORNITOR) );
		}
		yCASE(MP_MORNITORMAPSERVER_BOOTUP_NOTIFY)
		{
			//send to mas
			MSG_PWRUP_BOOTUP * pmsg2 = (MSG_PWRUP_BOOTUP *)pmsg;
			MSMGR->AddServerRegiest(dwConnectionIndex, pmsg2->dwProcessID, &pmsg2->BootInfo);
			MSMGR->SendServerState(SERVERSTATE_ON, &pmsg2->BootInfo);
		}
		yCASE(MP_MORNITORMAPSERVER_PING_ACK)
		{
			MSERVERINFO * pInfo = MServerTable->GetServerInfoForConn(dwConnectionIndex);
			pInfo->dwExpiredTime = GetTickCount();
			if(pInfo->wServerState == SERVERSTATE_ABNORMAL )
			{
				MSMGR->SendServerState(SERVERSTATE_RECOVER, pInfo);
			}
			pInfo->wServerState = SERVERSTATE_ON;
		}
		yCASE(MP_MORNITORMAPSERVER_CHANGE_USERLEVEL_ACK)
		{
			MSG_MCDWORD* pMsg = (MSG_MCDWORD*)pmsg;
			pMsg->Category = MP_MORNITORSERVER;
			pMsg->Protocol = MP_MORNITORSERVER_CHANGE_USERLEVEL_ACK;
			MNETWORK->SendToMAS( (char*)pMsg, sizeof(MSG_MCDWORD) );
		}
		yCASE(MP_MORNITORMAPSERVER_DISCONNECT_ALLUSER_ACK)
		{
			MSERVERINFO* pInfo = MServerTable->GetServerInfoForConn(dwConnectionIndex);

			MSGSERVERSTATE msg;
			msg.Category = MP_MORNITORSERVER;
			msg.Protocol = MP_MORNITORSERVER_DISCONNECT_ALLUSER_ACK;
			strcpy(msg.serverState.ServerIP, pInfo->szIPForServer);
			msg.serverState.ServerPort		= pInfo->wPortForServer;
			msg.serverState.ServerType		= pInfo->wServerType;
			msg.serverState.ServerNum		= pInfo->wServerNum;
			MNETWORK->SendToMAS((char*)&msg, sizeof(msg));
		}
		yCASE(MP_MORNITORMAPSERVER_QUERY_VERSION_ACK)
		{
			MSGNOTICE* msg = (MSGNOTICE*)pmsg;
			msg->Category = MP_MORNITORSERVER;
			msg->Protocol = MP_MORNITORSERVER_QUERY_VERSION_ACK;
			MNETWORK->SendToMAS( (char*)msg, sizeof(MSGNOTICE) );
		}
		yCASE(MP_MORNITORMAPSERVER_CHANGE_VERSION_ACK)
		{
			MSGNOTICE* msg = (MSGNOTICE*)pmsg;
			msg->Category = MP_MORNITORSERVER;
			msg->Protocol = MP_MORNITORSERVER_CHANGE_VERSION_ACK;
			MNETWORK->SendToMAS( (char*)msg, sizeof(MSGNOTICE) );
		}
		yCASE(MP_MORNITORMAPSERVER_QUERY_MAXUSER_ACK)
		{
			MSG_MCDWORD* pMsg = (MSG_MCDWORD*)pmsg;
			pMsg->Category = MP_MORNITORSERVER;
			pMsg->Protocol = MP_MORNITORSERVER_QUERY_MAXUSER_ACK;
			MNETWORK->SendToMAS( (char*)pMsg, sizeof(MSG_MCDWORD) );
		}
		yCASE(MP_MORNITORMAPSERVER_CHANGE_MAXUSER_ACK)
		{
			MSG_MCDWORD* pMsg = (MSG_MCDWORD*)pmsg;
			pMsg->Category = MP_MORNITORSERVER;
			pMsg->Protocol = MP_MORNITORSERVER_CHANGE_MAXUSER_ACK;
			MNETWORK->SendToMAS( (char*)pMsg, sizeof(MSG_MCDWORD) );
		}
		yENDSWITCH
	}
	yCASE(MP_MORNITORSERVER)	// from MAS
	{
		ySWITCH(pMsg->Protocol)
		yCASE(MP_MORNITORSERVER_QUERYUSERCOUNT_SYN)
		{
			// send to mapserver all
			MSGMC * pMsg = (MSGMC *)pmsg;
			pMsg->Category = MP_MORNITORMAPSERVER;
			pMsg->Protocol = MP_MORNITORMAPSERVER_QUERYUSERCOUNT_SYN;
			MNETWORK->SendToMapServerAll((char*)pMsg, dwLength);
		}
		yCASE(MP_MORNITORSERVER_QUERY_CHANNELINFO_SYN)
		{
			MSGROOT Msg;
			Msg.Category = MP_MORNITORMAPSERVER;
			Msg.Protocol = MP_MORNITORMAPSERVER_QUERY_CHANNELINFO_SYN;
			MNETWORK->SendToMapServerAll( (char*)&Msg, sizeof(MSGROOT) );
		}
		yCASE(MP_MORNITORSERVER_BOOTLIST_NOTIFY)
		{
			//to mapserver
			MSG_PWRUP_BOOTLIST *pmsg2 = (MSG_PWRUP_BOOTLIST *)pmsg;
			pmsg2->Category = MP_POWERUP;
			pmsg2->Protocol = MP_POWERUP_BOOTLIST_ACK;
			MNETWORK->SendToMapServer(MServerTable->GetServerInfoForPort(pmsg2->MapServerPort)->dwConnectionIndex, pmsg, dwLength);
		}
		//to mapserver
		yCASE(MP_MORNITORSERVER_EXECUTE_MAPSERVER_SYN)
		{
			// ¼­¹ö ±¸µ¿!!!!
			MSGEXECUTESERVER * pmsg2 = (MSGEXECUTESERVER *)pmsg;
			MSMGR->ExecuteServer(pmsg2->ServerType, pmsg2->ServerNum);
		}
		yCASE(MP_MORNITORSERVER_SHUTDOWN_MAPSERVER_SYN)		// msg¸¦ ÅëÇØ
		{
			MSGSHUTDOWNSERVER * pmsg2 = (MSGSHUTDOWNSERVER *)pmsg;
			MSMGR->ServerOff(pmsg2->ServerPort);
		}
		yCASE(MP_MORNITORSERVER_KILL_SERVER_SYN)			// °­Á¦Á¾·á(abnormal)
		{
			MSGSHUTDOWNSERVER* pmsg2 = (MSGSHUTDOWNSERVER*)pmsg;
			MSMGR->KillServer(pmsg2->ServerPort);
		}
		yCASE(MP_MORNITORSERVER_NOTICESEND_SYN)
		{
			MSGNOTICE * pmsg2 = (MSGNOTICE *)pmsg;
			pmsg2->Category = MP_MORNITORMAPSERVER;
			pmsg2->Protocol = MP_MORNITORMAPSERVER_NOTICESEND_SYN;
			// ¿¡ÀÌÀüÆ®¿¡°Ô¸¸
			MSMGR->SendToNotice(pmsg2, dwLength);
		}
		yCASE(MP_MORNITORSERVER_EXECUTE_AUTOPATCH_SYN)	// AutoPatch
		{			
			MSMGR->ReadAutoPatchVersion();
			MSMGR->AutoPatch();
			bAutoPatch = TRUE;
		}
		yCASE(MP_MORNITORSERVER_CHANGE_USERLEVEL_SYN)	// UserLevel
		{
			MSG_MCDWORD* msg = (MSG_MCDWORD*)pmsg;
			msg->Category = MP_MORNITORMAPSERVER;
			msg->Protocol = MP_MORNITORMAPSERVER_CHANGE_USERLEVEL_SYN;

			// Distribute
			MSMGR->SendToDistribute( (char*)msg, dwLength );
		}
		yCASE(MP_MORNITORSERVER_ASSERTMSGBOX_SYN)
		{
			MSG_MCDWORD* pMsg = (MSG_MCDWORD *)pmsg;
			pMsg->Category = MP_MORNITORMAPSERVER;
			pMsg->Protocol = MP_MORNITORMAPSERVER_ASSERTMSGBOX_SYN;
			MNETWORK->SendToMapServerAll((char*)pMsg, dwLength);
		}
		yCASE(MP_MORNITORSERVER_DISCONNECT_ALLUSER_SYN)
		{
			MSG_MCDWORD msg;
			msg.Category = MP_MORNITORMAPSERVER;
			msg.Protocol = MP_MORNITORMAPSERVER_DISCONNECT_ALLUSER_SYN;
			MNETWORK->SendToMapServerAll((char*)&msg, sizeof(msg));
		}
		yCASE(MP_MORNITORSERVER_QUERY_VERSION_SYN)
		{
			MSGROOT* pmsg = (MSGROOT*)pMsg;
			pmsg->Category = MP_MORNITORMAPSERVER;
			pmsg->Protocol = MP_MORNITORMAPSERVER_QUERY_VERSION_SYN;
			MSMGR->SendToDistribute( (char*)pmsg, dwLength );
		}
		yCASE(MP_MORNITORSERVER_CHANGE_VERSION_SYN)
		{
			MSGNOTICE* pmsg = (MSGNOTICE*)pMsg;
			pmsg->Category = MP_MORNITORMAPSERVER;
			pmsg->Protocol = MP_MORNITORMAPSERVER_CHANGE_VERSION_SYN;
			MSMGR->SendToDistribute( (char*)pmsg, dwLength );
		}
		yCASE(MP_MORNITORSERVER_QUERY_MAXUSER_SYN)
		{
			MSGROOT* pmsg = (MSGROOT*)pMsg;
			pmsg->Category = MP_MORNITORMAPSERVER;
			pmsg->Protocol = MP_MORNITORMAPSERVER_QUERY_MAXUSER_SYN;
			MSMGR->SendToDistribute( (char*)pmsg, dwLength );
		}
		yCASE(MP_MORNITORSERVER_CHANGE_MAXUSER_SYN)
		{
			MSG_MCDWORD* pmsg = (MSG_MCDWORD*)pMsg;
			pmsg->Category = MP_MORNITORMAPSERVER;
			pmsg->Protocol = MP_MORNITORMAPSERVER_CHANGE_MAXUSER_SYN;
			MSMGR->SendToDistribute( (char*)pmsg, dwLength );
		}
		yCASE(MP_MORNITORSERVER_QUERY_AUTOPATCHVERSION_SYN)
		{
			MSGMSSTATE Msg;
			Msg.Category = MP_MORNITORSERVER;
			Msg.Protocol = MP_MORNITORSERVER_QUERY_AUTOPATCHVERSION_ACK;
			MSERVERINFO* pInfo = MServerTable->GetMSInfo();
			strcpy( Msg.MSState.sServerIP, pInfo->szIPForServer );
			Msg.MSState.wServerPort = pInfo->wPortForServer;
			Msg.MSState.wAutoPatchState = AUTOPATCHSTATE_END;
			MSMGR->ReadAutoPatchVersion();
			strcpy( Msg.MSState.sAutoPatchVersion, MSMGR->GetAutoPatchVersion() );
			MNETWORK->SendToMAS( (char*)&Msg, sizeof(Msg) );
		}
		yENDSWITCH
	}
	yENDSWITCH
}

// In case of MAS
// from ms
// MCÁ¤º¸¸¦ ¾Ë¾Æ¾ß ÇÑ´Ù.
void CMSSystem::ReceivedMsgFromMS(DWORD dwConnectionIndex,char* pmsg,DWORD dwLength)
{
	MSGROOT* pMsg = (MSGROOT*)pmsg;
	ySWITCH(pMsg->Category)
	yCASE(MP_MORNITORSERVER)
	{
		ySWITCH(pMsg->Protocol)
		yCASE(MP_MORNITORSERVER_QUERYUSERCOUNT_ACK)
		{
			MSGUSERCOUNT * pMsg = (MSGUSERCOUNT *)pmsg;
			SERVERSTATE * pState = MASMGR->GetServerState(pMsg->ServerPort);
			pState->UserCount = pMsg->dwUserCount;
			MASMGR->SendServerStateToMC(pMsg->dwConnectionIdxMC, pMsg->ServerPort);
		}
		yCASE(MP_MORNITORSERVER_QUERY_CHANNELINFO_ACK)
		{
			MSG_CHANNEL_INFO_MORNITOR* pMsg = (MSG_CHANNEL_INFO_MORNITOR*)pmsg;
			pMsg->Category = MP_MORNITORTOOL;
			pMsg->Protocol = MP_MORNITORTOOL_QUERY_CHANNELINFO_ACK;
			MASMGR->SendToAllMC( (char*)pMsg, sizeof(MSG_CHANNEL_INFO_MORNITOR) );			
		}
		yCASE(MP_MORNITORSERVER_MSINFO_NOTIFY)
		{
			MSGMSINFO * pmsg2 = (MSGMSINFO *)pMsg;
			pmsg2->MSInfo.dwConnectionIndex = dwConnectionIndex;
			//*MServerTable->GetMSInfo() = pmsg2->MSInfo;
			// ¿©·¯°³ÀÇ MS°¡ ºÙÀ½
			// MAPÀÌ ¾î´À MC¿¡ ºÙ¾î ÀÖ´ÂÁö ¾Ë¾Æ¾ß ÇÔ
			LogConsole("From MSINFO_NOTIFY : CON:%d, IP:%s, PORT:%d",pmsg2->MSInfo.dwConnectionIndex, pmsg2->MSInfo.szIPForServer, pmsg2->MSInfo.wPortForServer);
			MServerTable->AddServer(&pmsg2->MSInfo, pmsg2->MSInfo.wPortForServer);

			MASMGR->SendMSServerStateAllToMCAll();
		}
		yCASE(MP_MORNITORSERVER_EXECUTE_MAPSERVER_ACK)
		//send to mc
		{
			MSGEXECUTESERVER * pmsg2 = (MSGEXECUTESERVER *)pMsg;
			pmsg2->Category = MP_MORNITORTOOL;
			pmsg2->Protocol = MP_MORNITORTOOL_EXECUTE_MAPSERVER_ACK;
			MNETWORK->SendToMS(pmsg2->dwConnectionIdxMC, pmsg, dwLength);
		}
		yCASE(MP_MORNITORSERVER_MAPSERVERSTATE_ACK)
		{
			MSGSERVERSTATE * pmsg2 = (MSGSERVERSTATE *)pMsg;
			SERVERSTATE * pState = MASMGR->GetServerState(pmsg2->serverState.ServerPort);
			WORD OldState = pState->ServerState = pmsg2->serverState.ServerState;
						
			// 1. mapserver bootup		on
			// send conn list
			// 2. mapserver down		abnormal
			// 3. mapserver shutdown	off
			ySWITCH(pmsg2->serverState.ServerState)
				yCASE(SERVERSTATE_ON)
					MASMGR->SendServerStateBootListToMS(dwConnectionIndex, pState->ServerType, pState->ServerPort);
				
				yCASE(SERVERSTATE_OFF)
				yCASE(SERVERSTATE_ABNORMAL)
					if(OldState == SERVERSTATE_OFF)
					{
						ASSERTMSG(0,"OFFµÇ¾ú´Â µ¥ ´Ù½Ã ABNORMAL msg recv");
						pState->ServerState = SERVERSTATE_OFF;
					}
					
				yCASE(SERVERSTATE_RECOVER)
					pState->ServerState = SERVERSTATE_ON;
				
			yENDSWITCH

			MASMGR->SendServerStateToMCs(pmsg2->serverState.ServerPort);

		}
		yCASE(MP_MORNITORSERVER_SHUTDOWN_MAPSERVER_ACK)
		//send to mc
		{
			MSGSHUTDOWNSERVER * pmsg2 = (MSGSHUTDOWNSERVER *)pMsg;
			pmsg2->Category = MP_MORNITORTOOL;
			pmsg2->Protocol = MP_MORNITORTOOL_NOTICESEND_ACK;
			MNETWORK->SendToMS(pmsg2->dwConnectionIdxMC, pmsg, dwLength);
		}
		yCASE(MP_MORNITORSERVER_CHANGE_USERLEVEL_ACK)
		//send to mc
		{
			MSG_MCDWORD * pmsg = (MSG_MCDWORD*)pMsg;
			pmsg->Category = MP_MORNITORTOOL;
			pmsg->Protocol = MP_MORNITORTOOL_CHANGE_USERLEVEL_ACK;
			MASMGR->SendToAllMC( (char*)pmsg, dwLength );
		}
		yCASE(MP_MORNITORSERVER_DISCONNECT_ALLUSER_ACK)
		{
			MSGSERVERSTATE* pmsg = (MSGSERVERSTATE*)pMsg;
			pmsg->Category = MP_MORNITORTOOL;
			pmsg->Protocol = MP_MORNITORTOOL_DISCONNECT_ALLUSER_ACK;
			MASMGR->SendToAllMC( (char*)pmsg, dwLength );
		}
		yCASE(MP_MORNITORSERVER_QUERY_VERSION_ACK)
		{
			MSGNOTICE* msg = (MSGNOTICE*)pMsg;
			msg->Category = MP_MORNITORTOOL;
			msg->Protocol = MP_MORNITORTOOL_QUERY_VERSION_ACK;
			MASMGR->SendToAllMC( (char*)msg, sizeof(MSGNOTICE) );
		}
		yCASE(MP_MORNITORSERVER_CHANGE_VERSION_ACK)
		{
			MSGNOTICE* msg = (MSGNOTICE*)pMsg;
			msg->Category = MP_MORNITORTOOL;
			msg->Protocol = MP_MORNITORTOOL_CHANGE_VERSION_ACK;
			MASMGR->SendToAllMC( (char*)msg, sizeof(MSGNOTICE) );
		}
		yCASE(MP_MORNITORSERVER_QUERY_MAXUSER_ACK)
		{
			MSG_MCDWORD* msg = (MSG_MCDWORD*)pMsg;
			msg->Category = MP_MORNITORTOOL;
			msg->Protocol = MP_MORNITORTOOL_QUERY_MAXUSER_ACK;
			MASMGR->SendToAllMC( (char*)msg, sizeof(MSG_MCDWORD) );
		}
		yCASE(MP_MORNITORSERVER_CHANGE_MAXUSER_ACK)
		{
			MSG_MCDWORD* msg = (MSG_MCDWORD*)pMsg;
			msg->Category = MP_MORNITORTOOL;
			msg->Protocol = MP_MORNITORTOOL_CHANGE_MAXUSER_ACK;
			MASMGR->SendToAllMC( (char*)msg, sizeof(MSG_MCDWORD) );
		}
		// 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;

⌨️ 快捷键说明

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