Fix freezing of dedicated server window on Windows

The code was donated by motorsep, thanks!
This commit is contained in:
Daniel Gibson 2012-09-01 23:18:03 +02:00
parent 105fdb0624
commit 5936422d9d
2 changed files with 23 additions and 0 deletions

View file

@ -636,6 +636,10 @@ WinMain
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
const HCURSOR hcurSave = ::SetCursor( LoadCursor( 0, IDC_WAIT ) ); const HCURSOR hcurSave = ::SetCursor( LoadCursor( 0, IDC_WAIT ) );
#ifdef ID_DEDICATED
MSG msg;
#endif
Sys_SetPhysicalWorkMemory( 192 << 20, 1024 << 20 ); Sys_SetPhysicalWorkMemory( 192 << 20, 1024 << 20 );
win32.hInstance = GetModuleHandle(NULL); win32.hInstance = GetModuleHandle(NULL);
@ -681,6 +685,17 @@ int main(int argc, char *argv[]) {
// main game loop // main game loop
while( 1 ) { while( 1 ) {
#if ID_DEDICATED
// Since this is a Dedicated Server, process all Windowing Messages
// Now.
while(PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Give the OS a little time to recuperate.
Sleep(10);
#endif
Win_Frame(); Win_Frame();

View file

@ -108,7 +108,11 @@ static LRESULT CALLBACK ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
} }
break; break;
case WM_CLOSE: case WM_CLOSE:
#ifdef ID_DEDICATED
if ( cvarSystem->IsInitialized() ) {
#else
if ( cvarSystem->IsInitialized() && com_skipRenderer.GetBool() ) { if ( cvarSystem->IsInitialized() && com_skipRenderer.GetBool() ) {
#endif
cmdSystem->BufferCommandText(CMD_EXEC_APPEND, "quit\n"); cmdSystem->BufferCommandText(CMD_EXEC_APPEND, "quit\n");
} else if ( s_wcd.quitOnClose ) { } else if ( s_wcd.quitOnClose ) {
PostQuitMessage( 0 ); PostQuitMessage( 0 );
@ -143,11 +147,15 @@ static LRESULT CALLBACK ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 ); SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
SendMessage( s_wcd.hwndBuffer, WM_COPY, 0, 0 ); SendMessage( s_wcd.hwndBuffer, WM_COPY, 0, 0 );
} else if ( wParam == QUIT_ID ) { } else if ( wParam == QUIT_ID ) {
#ifdef ID_DEDICATED
cmdSystem->BufferCommandText(CMD_EXEC_APPEND, "quit\n");
#else
if ( s_wcd.quitOnClose ) { if ( s_wcd.quitOnClose ) {
PostQuitMessage( 0 ); PostQuitMessage( 0 );
} else { } else {
cmdSystem->BufferCommandText(CMD_EXEC_APPEND, "quit\n"); cmdSystem->BufferCommandText(CMD_EXEC_APPEND, "quit\n");
} }
#endif
} else if ( wParam == CLEAR_ID ) { } else if ( wParam == CLEAR_ID ) {
SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 ); SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, FALSE, ( LPARAM ) "" ); SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, FALSE, ( LPARAM ) "" );