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

📄 servercontrol.cpp

📁 网络游戏龙族服务器端管理工具 rmtool 源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:

		if(strcmp(str,"MAP"))		diff++;
		
		c_SelectList.GetItemText(i, 1, str, 128);
		wPort = (WORD)atoi(str);
		memcpy(packet + offset, &wPort, sizeof(WORD));
		offset += sizeof(WORD);
	}

	if(diff > 0)
		MessageBox("Only Map server Please!","MapServer Only!",MB_OK);
	else
	{
		g_pNet->Send(GetConnection(),(char*)&packet, offset);
		MessageBox("Reload GameServer Data. Check 'R'marks !");

#ifdef RM_LOG_MODE
	CServerView* pView = (CServerView*)GetParent();
	CString str;	str.Format("ServerControl :: Reload Gameserver Data(Applied: %d)",num);
	m_pApp->LogServer(pView->m_nCurServerSet, str);
#endif
		
	}


}

void CServerControl::OnProxyControlApply() 
{
	// TODO: Add your control notification handler code here
	if( !RIGHT(MASK_7) )	return;
	
	UpdateData(TRUE);

	PACKET_RM_PROXY_CONTROL packet((BYTE)m_UserAccept ,(BYTE)m_TryToConnect ,(WORD)m_MaxUser);
	g_pNet->Send(GetConnection(),(char*)&packet, packet.GetPacketSize());

#ifdef RM_LOG_MODE
	CServerView* pView = (CServerView*)GetParent();
	CString str;	str.Format("ServerControl :: Server Control! -> UserAccept:%d, TryToConnect:%d, MaxUser:%d",m_UserAccept ,m_TryToConnect ,m_MaxUser);
	m_pApp->LogServer(pView->m_nCurServerSet, str);
#endif
}

DWORD CServerControl::GetConnection()
{
	CServerView* pView = (CServerView*)GetParent();
	return m_pApp->m_nCI[ pView->m_nCurServerSet ];
}

void CServerControl::OnNoticeSend() 
{
	// TODO: Add your control notification handler code here
	if( !RIGHT(MASK_8) )	return;
	int num = c_SelectList.GetItemCount();

	if(num <= 0)
	{
		MessageBox("Select Broadcasting Map server!","Select Map Server",MB_OK);
		return;
	}
	
	UpdateData(TRUE);

	int line = c_NoticeMsg.GetLineCount();
	
	char packet[2048];
	char msg[2048];	
	for(int i=0; i<line; i++)
	{
		memset(msg,0,2048);
		c_NoticeMsg.GetLine(i,msg,2048);

		if(!strcmp(msg,""))
			continue;

		int diff = 0, offset;
		WORD wPort;
		WORD msgLen; msgLen = (WORD)strlen(msg);
		char str[ 128 ];

		packet[0] = PTCL_RM;
		packet[1] = MSG_RM_NOTICE;
		
		memcpy(packet + 2, &msgLen, sizeof(WORD));		//2~3 锅掳绰 辨捞 
		memcpy(packet + 4, msg, msgLen);				//皋技瘤 郴侩 	

		packet[4 + msgLen] = (char)num;
		offset = 5 + msgLen;

		for(int k=0; k<num; k++)
		{
			c_SelectList.GetItemText(k, 3, str, 128);		

			if(strcmp(str,"MAP"))		diff++;
			
			c_SelectList.GetItemText(k, 1, str, 128);
			wPort = (WORD)atoi(str);
			memcpy(packet + offset, &wPort, sizeof(WORD));
			offset += sizeof(WORD);
		}

		
		if(diff > 0)
		{
			MessageBox("Only Map server Please","MapServer Only!",MB_OK);
			return;
		}
		else
			g_pNet->Send(GetConnection(),(char*)&packet, offset);

		if(m_CheckNotice)	//檬寸 焊郴扁啊 眉农 登绢乐栏搁..
		{
			EnterCriticalSection(&m_criNotice);

			m_ContinueNoticePacketLength = offset;
			memcpy(m_ContinueNoticePacket, packet, offset);

			LeaveCriticalSection(&m_criNotice);
			SetTimer(1, m_NoticeSec*1000, NULL);
		}

		MessageBox("Broadcasting Completed.","Broadcast",MB_OK);
	}

	
#ifdef RM_LOG_MODE
	CServerView* pView = (CServerView*)GetParent();
	CString str;	str.Format("ServerControl :: Send Notice!(Applied: %d) -> Continue:%d, Sec:%d, Msg:%s",num, m_CheckNotice, m_NoticeSec, msg);
	m_pApp->LogServer(pView->m_nCurServerSet, str);
#endif
	
	//strcpy(msg, m_szNotice.GetBuffer( m_szNotice.GetLength() ));
}

void CServerControl::OnCheckNotice() 
{
	// TODO: Add your control notification handler code here
	UpdateData();

	if(m_CheckNotice == FALSE)
	{
		KillTimer(1);	//楷加 傍瘤 掺绊 
	}
}

void CServerControl::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	switch(nIDEvent)
	{
	case 1:
		{
			EnterCriticalSection(&m_criNotice);
			g_pNet->Send(GetConnection(),(char*)&m_ContinueNoticePacket, m_ContinueNoticePacketLength);
			LeaveCriticalSection(&m_criNotice);
		}
		break;
	}
	CDialog::OnTimer(nIDEvent);
}

void CServerControl::OnWeatherApply() 
{
	// TODO: Add your control notification handler code here
	if( !RIGHT(MASK_10) )	return;

	int num = c_SelectList.GetItemCount();

	if(num <= 0)
	{
		MessageBox("Select Broadcasting Map server!","Select Map Server",MB_OK);
		return;
	}
	
	UpdateData(TRUE);

	char packet[2048];
	char str[128];
	int diff = 0, offset = 9;
	WORD wPort;
	
	packet[0] = PTCL_RM;
	packet[1] = MSG_RM_CHANGE_WEATHER;
	packet[2] = (char)m_RadioWeather;
	memcpy(packet + 3, &m_WeatherAmount, sizeof(DWORD));		//amount
	packet[7] = (char)m_CheckStopWeather;
	packet[8] = (char)num;

	for(int i=0; i<num; i++)
	{
		c_SelectList.GetItemText(i, 3, str, 128);		

		if(strcmp(str,"MAP"))		diff++;
		
		c_SelectList.GetItemText(i, 1, str, 128);
		wPort = (WORD)atoi(str);
		memcpy(packet + offset, &wPort, sizeof(WORD));
		offset += sizeof(WORD);
	}

	if(diff > 0)
		MessageBox("Only Map server Please!","MapServer Only!",MB_OK);
	else
	{
		g_pNet->Send(GetConnection(),(char*)&packet, offset);
		MessageBox("Weather Changed.");

#ifdef RM_LOG_MODE
	CServerView* pView = (CServerView*)GetParent();
	CString str;	str.Format("ServerControl :: Change Weather!(Applied: %d) -> Weather:%d, StopWeatherSystem:%d",num, m_RadioWeather, m_CheckStopWeather);
	m_pApp->LogServer(pView->m_nCurServerSet, str);
#endif

	}
	
}

//厚 急琶 
void CServerControl::OnRadioWeather2() 
{
	// TODO: Add your control notification handler code here
	c_WeatherAmount.EnableWindow();
}

//传 急琶 
void CServerControl::OnRadioWeather3() 
{
	// TODO: Add your control notification handler code here
	c_WeatherAmount.EnableWindow();
}
//讣澜, 肛勉 
void CServerControl::OnRadioWeather() 
{
	// TODO: Add your control notification handler code here
	c_WeatherAmount.EnableWindow(FALSE);
}
//extern int bbb;
void CServerControl::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	CServerView *pView = (CServerView*)GetParent();

	if(!pView)	return;

	CWnd *pWnd = GetTopWindow();
	CRect wndRect,baseRect;

	int TotalListBottom=0;			//Tab Order 1锅 牧飘费狼 Top蔼 
	int TotalListTop=0;	//IDC_ALL_SERVER_LIST 狼 Top蔼 
	
	float x,y;
	float hx, hy; hx=0.0; hy=0.0;
	while(pWnd)
	{
		//int vCx = cx - pView->m_BaseRect.Width();
		//int vCy = cy - pView->m_BaseRect.Height();
		
		//base : 1 = cx : x
		//cx = base * x
		//x = cx / base

		//prev : 1 = cx : x
		//cx = prev * x
		//x = cx / prev


		//x = cx * 1.0 / pView->m_BaseRect.Width();
		//y = cy * 1.0 / pView->m_BaseRect.Height();

		x = (float)(cx * 1.0 / m_nPrevWidth);
		y = (float)(cy * 1.0 / m_nPrevHeight);

		pWnd->GetWindowRect(&wndRect);
		ScreenToClient(&wndRect);

		baseRect = wndRect;
		
		int id = pWnd->GetDlgCtrlID() ;

		switch(id)
		{
		case IDC_LEFT_ALL:
		case IDC_LEFT:
		case IDC_RIGHT:
		case IDC_RIGHT_ALL:
			{
			//	y = ((TotalListBottom - TotalListTop) + (int)(wndRect.top * y + 0.5)) * 1.0 / pView->m_nPrevHeight;
			//	wndRect.top = (int)(wndRect.top * y + 0.5);
			//	wndRect.bottom = (int)(wndRect.bottom * y + 0.5);
				
				wndRect.left = (int)(wndRect.left * x + 0.5);
				wndRect.right = (int)(wndRect.right * x + 0.5);
			}
			break;

		case IDC_SELECT_SERVER_LIST:
		case IDC_ALL_SERVER_LIST:
			{
				//wndRect.top = (int)(wndRect.top * y + 0.5);
				//wndRect.bottom = (int)(wndRect.bottom * y + 0.5);
				wndRect.top = TotalListTop;
				wndRect.bottom = TotalListBottom;	//Taborder 1锅 牧飘费狼 臭捞俊辑 30 猾巴..
				wndRect.left = (int)(wndRect.left * x + 0.5);
				wndRect.right = (int)(wndRect.right * x + 0.5);
			}
			break;

		case IDC_STATIC_ALL_SERVER:
		case IDC_STATIC_SELECT_SERVER:
		case IDC_STATIC_TOTAL:
		case IDC_STATIC_SELECT:
			{
				wndRect.left = (int)(wndRect.left * x + 0.5);
				wndRect.right = (int)(wndRect.right * x + 0.5);

				if(id == IDC_STATIC_ALL_SERVER)
					TotalListTop = wndRect.bottom + 2;
			}
			break;

		default:
			{
				wndRect.left = (int)(wndRect.left * x + 0.5);
				wndRect.right = (int)(wndRect.right * x + 0.5);

				int h = cy - m_nPrevHeight;
				wndRect.top += h; 
				wndRect.bottom += h;

				if(id == IDC_STATIC_TOP)
					TotalListBottom = wndRect.top - 30;
			}
			break;
		}
		
		pWnd->MoveWindow(&wndRect);
		pWnd = pWnd->GetNextWindow();
	}
	
	Invalidate();

	m_nPrevWidth = cx;
	m_nPrevHeight = cy;
}

BOOL CServerControl::RefreshSomeItem(WORD port, BOOL connect)
{
	//立加惑怕肺 盎脚 
	char str[10];
	DWORD dwPort = 0;
	LVITEM item;

	//<! BBD 040105		怕惫,富饭捞 辑滚惑怕 瘤盔侩
	((CMainFrame *)m_pApp->m_pMainWnd)->RefreshRMServerStatus();
	//> BBD 040105		怕惫,富饭捞 辑滚惑怕 瘤盔侩

	//AllList 八祸 
	int count = c_AllList.GetItemCount();	
	for(int i=0 ; i<count ; i++)
	{
		c_AllList.GetItemText(i,1,str,10);
		dwPort = atoi(str);
		
		if(dwPort == port)
		{
			item.mask = LVIF_TEXT;
			item.iItem = i;					//青锅龋 
			item.iSubItem = 2;
			
			switch(connect)
			{
			case 14:	//Reload Complete
			case 1:
				item.pszText = "O";
				c_AllList.SetItem(&item);
				break;

			case 0:
				item.pszText = "X";
				c_AllList.SetItem(&item);
				break;

			case 13:	//Reloading
				item.pszText = "R";
				c_AllList.SetItem(&item);
				break;
			}
			
			c_AllList.Update(i);
			CountConnectServer();
			return TRUE;
		}
	}

	count = c_SelectList.GetItemCount();	
	for(i=0 ; i<count ; i++)
	{
		c_SelectList.GetItemText(i,1,str,10);
		dwPort = atoi(str);
		
		if(dwPort == port)
		{
			item.mask = LVIF_TEXT;
			item.iItem = i;					//青锅龋 
			item.iSubItem = 2;
			switch(connect)
			{
			case 14:	//Reload Complete
			case 1:
				item.pszText = "O";
				c_SelectList.SetItem(&item);
				break;

			case 0:
				item.pszText = "X";
				c_SelectList.SetItem(&item);
				break;

			case 13:	//Reloading
				item.pszText = "R";
				c_SelectList.SetItem(&item);
				break;
			}
			c_SelectList.Update(i);
			CountConnectServer();
			return TRUE;
		}
	}

	return FALSE;
}



void CServerControl::OnCustomDrawAll(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMTVCUSTOMDRAW * pcd = (NMTVCUSTOMDRAW*) pNMHDR;

	switch(pcd->nmcd.dwDrawStage) 
	{
    case  CDDS_PREPAINT:
        *pResult = CDRF_NOTIFYITEMDRAW;
        break;
    case CDDS_ITEMPREPAINT:
    	{
			char str[16];	
			c_AllList.GetItemText(pcd->nmcd.dwItemSpec,2,str,16);

			if(!strcmp(str,"O"))
			{
				pcd->clrText = (COLORREF)RGB(0,0,0);
			}
			else if(!strcmp(str,"X"))
			{
				pcd->clrText = (COLORREF)RGB(255,0,0);
				pcd->clrTextBk = (COLORREF)RGB(255,255,0);
			}
			else
			{
				pcd->clrText = (COLORREF)RGB(0,0,255);
			}

			*pResult = CDRF_DODEFAULT;   
		}
		break;
		/*
		COLORREF rgb = (COLORREF)c_AllList.GetItemData(pcd->nmcd.dwItemSpec);

		if(rgb == RGB(255,0,0))
		{
			pcd->clrText = (COLORREF)rgb;
			pcd->clrTextBk = (COLORREF)RGB(255,255,0);
		}
		else if(rgb == RGB(0,0,255))
		{
			pcd->clrText = (COLORREF)rgb;
		}
		
        *pResult = CDRF_DODEFAULT;
        break;
		*/
    }
}


void CServerControl::OnCustomDrawSelect(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMTVCUSTOMDRAW * pcd = (NMTVCUSTOMDRAW*) pNMHDR;

	switch(pcd->nmcd.dwDrawStage) 
	{
    case  CDDS_PREPAINT:
        *pResult = CDRF_NOTIFYITEMDRAW;
        break;
    case CDDS_ITEMPREPAINT:
		{
			char str[16];	
			c_SelectList.GetItemText(pcd->nmcd.dwItemSpec,2,str,16);

			if(!strcmp(str,"O"))
			{
				pcd->clrText = (COLORREF)RGB(0,0,0);
			}
			else if(!strcmp(str,"X"))
			{
				pcd->clrText = (COLORREF)RGB(255,0,0);
				pcd->clrTextBk = (COLORREF)RGB(255,255,0);
			}
			else
			{
				pcd->clrText = (COLORREF)RGB(0,0,255);
			}

			*pResult = CDRF_DODEFAULT;   
		}
		break;
    /*
		COLORREF rgb = (COLORREF)c_SelectList.GetItemData(pcd->nmcd.dwItemSpec);

		if(rgb == RGB(255,0,0))
		{
			pcd->clrText = (COLORREF)rgb;
			pcd->clrTextBk = (COLORREF)RGB(255,255,0);
		}
		else if(rgb == RGB(0,0,255))
		{
			pcd->clrText = (COLORREF)rgb;
		}
		
        *pResult = CDRF_DODEFAULT;
        break;
		*/
    }
}

⌨️ 快捷键说明

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