Exemplo n.º 1
0
//Aah, bets repeated info calls.
void Master_RequestHeartbeat(master_server_t * master) {

   unsigned int PlayerCount;
   char buffer[1400];
   unsigned int len;

   if(master == NULL) { return; }
   if(global_realtime - master->TimeOfRequest > MasterHeartbeatTimeout) { return; }

   SV_CountPlayers(&PlayerCount);

   //Let's write our packet.  If at any time we overflow, bail.  That's impossible for the current setup though.
   len = snprintf(buffer, sizeof(buffer),
                  "0\n\\"
                  "protocol\\%i\\"
                  "challenge\\%i\\"
                  "players\\%u\\"
                  "max\\%u\\"
                  "gamedir\\"
                  , 46, master->ChallengeRequest, PlayerCount, global_svs.allocated_client_slots);

   if(len > sizeof(buffer)) { return; }
   //For encapsulation reasons, there's no way to get a straight pointer to the
   //mod directory.  There's a function that'll write it into the packet though.
   len += COM_GetGameDirSize(buffer+len, sizeof(buffer)-len);


   len = snprintf(buffer+len, sizeof(buffer)-len,
                         "\\"
                         "map\\%s\\"
                         "password\\%i\\"
                         "os\\%c\\"
                         "secure\\%i\\"
                         "lan\\%i\\"
                         "dedicated\\%i\\"
                         "version\\%s\n"
                         , global_sv.name, ServerIsPassworded(), 'l'
                         , global_svs.paddingE8 != 0, Master_IsLanGame(), 'd', "7.1.1.2");

   NET_SendPacket(NS_SERVER, len, buffer, master->address);
}
Exemplo n.º 2
0
static LONG WINAPI Sys_ConsoleProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg) {
	case WM_ACTIVATE:
		if (LOWORD(wParam) != WA_INACTIVE) {
			SetFocus(sys_console.hWndInput);
			return 0;
		}
		break;

	case WM_CLOSE:
		if (SV_CountPlayers()) {
			const int ays = MessageBox(hWnd, "There are still players on the server! Really shut it down?", "WARNING!", MB_YESNO + MB_ICONEXCLAMATION);
			if (ays == IDNO)
				return TRUE;
		}
		Sys_Quit();
		break;

	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED) {
			if ((HWND)lParam == sys_console.hWndCopy) {
				SendMessage(sys_console.hWndOutput, EM_SETSEL, 0, -1);
				SendMessage(sys_console.hWndOutput, WM_COPY, 0, 0);
			} else if ((HWND)lParam == sys_console.hWndClear) {
				SendMessage(sys_console.hWndOutput, EM_SETSEL, 0, -1);
				SendMessage(sys_console.hWndOutput, WM_CLEAR, 0, 0);
			} else if ((HWND)lParam == sys_console.hWndQuit)
				Sys_Quit();
		} else if (HIWORD(wParam) == EN_VSCROLL)
			InvalidateRect(sys_console.hWndOutput, NULL, TRUE);
		break;

	case WM_CTLCOLOREDIT:
		if ((HWND)lParam == sys_console.hWndOutput) {
			SetBkMode((HDC)wParam, TRANSPARENT);
			SetBkColor((HDC)wParam, RGB(255, 255, 255));
			SetTextColor((HDC)wParam, RGB(0, 0, 0));
			return (LONG)sys_console.hBrushOutput;
		} else if ((HWND)lParam == sys_console.hWndInput) {
			SetBkMode((HDC)wParam, TRANSPARENT);
			SetBkColor((HDC)wParam, RGB(255, 255, 255));
			SetTextColor((HDC)wParam, RGB(0, 0, 0));
			return (LONG)sys_console.hBrushInput;
		}
		break;

	case WM_CTLCOLORSTATIC:
		if ((HWND)lParam == sys_console.hWndMsg) {
			SetBkMode((HDC)wParam, TRANSPARENT);
			SetBkColor((HDC)wParam, RGB(127, 127, 127));

			if (sys_console.flashColor)
				SetTextColor((HDC)wParam, RGB(255, 0, 0));
			else
				SetTextColor((HDC)wParam, RGB(0, 0, 0));

			return (LONG)sys_console.hBrushMsg;
		}
		break;

	case WM_TIMER:
		sys_console.flashColor = !sys_console.flashColor;
		InvalidateRect(sys_console.hWndMsg, NULL, TRUE);
		break;

	case WM_CREATE:
		SetTimer(sys_console.hWnd, 1, 500, NULL);
		break;
	}

	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}