-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathwin_main.c
823 lines (669 loc) · 17.8 KB
/
win_main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// win_main.c
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
#ifndef DEDICATED
#include "../client/client.h"
#endif
#include "win_local.h"
#include "resource.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <direct.h>
#include <io.h>
#define MEM_THRESHOLD (96*1024*1024)
WinVars_t g_wv;
/*
==================
Sys_LowPhysicalMemory
==================
*/
qboolean Sys_LowPhysicalMemory( void ) {
#if _MSC_VER < 1600 // MSVC 2008 and lower, assume win9x compatibility builds
MEMORYSTATUS stat;
GlobalMemoryStatus( &stat );
return (stat.dwTotalPhys <= MEM_THRESHOLD) ? qtrue : qfalse;
#else
MEMORYSTATUSEX stat;
stat.dwLength = sizeof(stat);
if ( !GlobalMemoryStatusEx( &stat ) ) {
return qfalse;
}
return (stat.ullAvailPhys <= MEM_THRESHOLD) ? qtrue : qfalse;
#endif
}
/*
==================
Sys_BeginProfiling
==================
*/
void Sys_BeginProfiling( void ) {
// this is just used on the mac build
}
/*
=============
Sys_Error
Show the early console as an error dialog
=============
*/
void NORETURN FORMAT_PRINTF(1, 2) QDECL Sys_Error( const char *error, ... ) {
va_list argptr;
char text[4096];
MSG msg;
va_start( argptr, error );
Q_vsnprintf( text, sizeof( text ), error, argptr );
va_end( argptr );
#ifndef DEDICATED
CL_Shutdown( text, qtrue );
#endif
Conbuf_AppendText( text );
Conbuf_AppendText( "\n" );
Sys_SetErrorText( text );
Sys_ShowConsole( 1, qtrue );
timeEndPeriod( 1 );
// wait for the user to quit
while ( 1 ) {
if ( GetMessage( &msg, NULL, 0, 0 ) <= 0 ) {
Cmd_Clear();
Com_Quit_f();
}
TranslateMessage( &msg );
DispatchMessage( &msg );
}
Sys_DestroyConsole();
exit( 1 );
}
/*
==============
Sys_Quit
==============
*/
void NORETURN Sys_Quit( void ) {
timeEndPeriod( 1 );
Sys_DestroyConsole();
exit( 0 );
}
/*
==============
Sys_Print
==============
*/
void Sys_Print( const char *msg )
{
Conbuf_AppendText( msg );
}
/*
=============
Sys_Sleep
=============
*/
void Sys_Sleep( int msec ) {
if ( msec < 0 ) {
// special case: wait for event or network packet
DWORD dwResult;
msec = 300;
do {
dwResult = MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLEVENTS );
}
while ( dwResult == WAIT_TIMEOUT && NET_Sleep( 10 * 1000 ) );
//WaitMessage();
return;
}
// busy wait there because Sleep(0) will relinquish CPU - which is not what we want
//if ( msec == 0 )
// return;
Sleep( msec );
}
/*
==============
Sys_Mkdir
==============
*/
qboolean Sys_Mkdir( const char *path )
{
if ( _mkdir( path ) == 0 ) {
return qtrue;
} else {
if ( errno == EEXIST ) {
return qtrue;
} else {
return qfalse;
}
}
}
/*
==============
Sys_FOpen
==============
*/
FILE *Sys_FOpen( const char *ospath, const char *mode )
{
size_t length;
// Windows API ignores all trailing spaces and periods which can get around Quake 3 file system restrictions.
length = strlen( ospath );
if ( length == 0 || ospath[length-1] == ' ' || ospath[length-1] == '.' ) {
return NULL;
}
return fopen( ospath, mode );
}
/*
==============
Sys_ResetReadOnlyAttribute
==============
*/
qboolean Sys_ResetReadOnlyAttribute( const char *ospath ) {
DWORD dwAttr;
dwAttr = GetFileAttributesA( ospath );
if ( dwAttr & FILE_ATTRIBUTE_READONLY ) {
dwAttr &= ~FILE_ATTRIBUTE_READONLY;
if ( SetFileAttributesA( ospath, dwAttr ) ) {
return qtrue;
} else {
return qfalse;
}
} else {
return qfalse;
}
}
/*
==============
Sys_Pwd
==============
*/
const char *Sys_Pwd( void )
{
static char pwd[ MAX_OSPATH ];
TCHAR buffer[ MAX_OSPATH ];
char *s;
if ( pwd[0] )
return pwd;
GetModuleFileName( NULL, buffer, ARRAY_LEN( buffer ) );
buffer[ ARRAY_LEN( buffer ) - 1 ] = '\0';
Q_strncpyz( pwd, WtoA( buffer ), sizeof( pwd ) );
s = strrchr( pwd, PATH_SEP );
if ( s )
*s = '\0';
else // bogus case?
{
_getcwd( pwd, sizeof( pwd ) - 1 );
pwd[ sizeof( pwd ) - 1 ] = '\0';
}
return pwd;
}
/*
==============
Sys_DefaultBasePath
==============
*/
const char *Sys_DefaultBasePath( void )
{
return Sys_Pwd();
}
/*
==============================================================
DIRECTORY SCANNING
==============================================================
*/
/*
=============
Sys_ListExtFiles
=============
*/
static int Sys_ListExtFiles( const char *directory, const char *subdir, const char *extension, const char *filter, char **list, int maxfiles, int subdirs ) {
char search[MAX_OSPATH*2+MAX_QPATH+1];
char filename[MAX_OSPATH * 2];
int nfiles;
struct _finddata_t findinfo;
intptr_t findhandle;
int flag;
int extLen;
const char *x;
qboolean hasPatterns;
// passing a slash as extension will find directories
if ( extension[0] == '/' && extension[1] == '\0' ) {
extension = "";
flag = 0;
} else {
flag = _A_SUBDIR;
}
extLen = (int)strlen( extension );
hasPatterns = Com_HasPatterns( extension ); // contains either '?' or '*'
if ( hasPatterns && extension[0] == '.' && extension[1] != '\0' ) {
extension++;
}
nfiles = 0;
if ( *subdir != '\0' ) {
Com_sprintf( search, sizeof( search ), "%s\\%s\\*", directory, subdir );
} else {
Com_sprintf( search, sizeof( search ), "%s\\*", directory );
}
if ( subdirs > 0 ) {
// handle recursion
findhandle = _findfirst( search, &findinfo );
if ( findhandle != -1 ) {
do {
if ( findinfo.attrib & _A_SUBDIR ) {
if ( !Q_streq( findinfo.name, "." ) && !Q_streq( findinfo.name, ".." ) ) {
char subdir2[MAX_OSPATH * 2 + MAX_QPATH + 1];
if ( *subdir != '\0' ) {
Com_sprintf( subdir2, sizeof( subdir2 ), "%s\\%s", subdir, findinfo.name );
} else {
Q_strncpyz( subdir2, findinfo.name, sizeof( subdir2 ) );
}
if ( nfiles >= maxfiles ) {
break;
}
nfiles += Sys_ListExtFiles( directory, subdir2, extension, filter, list + nfiles, maxfiles - nfiles, subdirs - 1);
}
}
} while ( _findnext( findhandle, &findinfo ) == 0 );
}
_findclose( findhandle );
}
Q_strcat( search, sizeof( search ), extension );
findhandle = _findfirst( search, &findinfo );
if ( findhandle == -1 ) {
return nfiles;
}
do {
if ( flag ^ ( findinfo.attrib & _A_SUBDIR ) ) {
if ( *subdir != '\0' ) {
Com_sprintf( filename, sizeof( filename ), "%s\\%s", subdir, findinfo.name );
} else {
Q_strncpyz( filename, findinfo.name, sizeof( filename ) );
}
if ( filter != NULL && *filter != '\0' ) {
if ( !Com_FilterPath( filter, filename ) ) {
continue;
}
} else if ( *extension != '\0' ) {
if ( hasPatterns ) {
x = strrchr( findinfo.name, '.' );
if ( x == NULL || !Com_FilterExt( extension, x + 1 ) ) {
continue;
}
} else {
// check for exact extension
const int length = strlen( findinfo.name );
if ( length < extLen || Q_stricmp( findinfo.name + length - extLen, extension ) ) {
continue;
}
}
}
if ( nfiles >= maxfiles ) {
break;
}
list[ nfiles++ ] = FS_CopyString( filename );
}
} while ( _findnext( findhandle, &findinfo ) == 0 );
_findclose( findhandle );
return nfiles;
}
char** Sys_ListFiles( const char *directory, const char *extension, const char *filter, int *numfiles, int subdirs )
{
char** listCopy;
char* list[MAX_FOUND_FILES];
int i, nfiles;
if ( extension == NULL ) {
extension = "";
}
nfiles = Sys_ListExtFiles( directory, "", extension, filter, list, ARRAY_LEN( list ), subdirs );
// copy list from stack
listCopy = Z_Malloc( (nfiles + 1) * sizeof( listCopy[0] ) );
for ( i = 0; i < nfiles; i++ ) {
listCopy[i] = list[i];
}
listCopy[i] = NULL;
Com_SortFileList( listCopy, nfiles, *extension != '\0' );
*numfiles = nfiles;
return listCopy;
}
/*
=============
Sys_FreeFileList
=============
*/
void Sys_FreeFileList( char **list ) {
int i;
if ( !list ) {
return;
}
for ( i = 0 ; list[i] ; i++ ) {
Z_Free( list[i] );
}
Z_Free( list );
}
/*
=============
Sys_GetFileStats
=============
*/
qboolean Sys_GetFileStats( const char *filename, fileOffset_t *size, fileTime_t *mtime, fileTime_t *ctime ) {
struct _stat s;
if ( _stat( filename, &s ) == 0 ) {
*size = (fileOffset_t)s.st_size;
*mtime = (fileTime_t)s.st_mtime;
*ctime = (fileTime_t)s.st_ctime;
return qtrue;
} else {
*size = 0;
*mtime = *ctime = 0;
return qfalse;
}
}
//========================================================
/*
========================================================================
LOAD/UNLOAD DLL
========================================================================
*/
static int dll_err_count = 0;
/*
=================
Sys_LoadLibrary
=================
*/
void *Sys_LoadLibrary( const char *name )
{
const char *ext;
if ( !name || !*name )
return NULL;
if ( FS_AllowedExtension( name, qfalse, &ext ) )
{
Com_Error( ERR_FATAL, "Sys_LoadLibrary: Unable to load library with '%s' extension", ext );
}
return (void *)LoadLibrary( AtoW( name ) );
}
/*
=================
Sys_LoadFunction
=================
*/
void *Sys_LoadFunction( void *handle, const char *name )
{
void *symbol;
if ( handle == NULL || name == NULL || *name == '\0' )
{
dll_err_count++;
return NULL;
}
symbol = GetProcAddress( handle, name );
if ( !symbol )
dll_err_count++;
return symbol;
}
/*
=================
Sys_LoadFunctionErrors
=================
*/
int Sys_LoadFunctionErrors( void )
{
int result = dll_err_count;
dll_err_count = 0;
return result;
}
/*
=================
Sys_UnloadLibrary
=================
*/
void Sys_UnloadLibrary( void *handle )
{
if ( handle )
FreeLibrary( handle );
}
/*
=================
Sys_SendKeyEvents
Platform-dependent event handling
=================
*/
void Sys_SendKeyEvents( void )
{
#ifndef DEDICATED
if ( !com_dedicated->integer )
HandleEvents();
else
#endif
HandleConsoleEvents();
}
//================================================================
/*
==================
SetTimerResolution
Try to set lower timer period
==================
*/
static void SetTimerResolution( void )
{
typedef HRESULT (WINAPI *pfnNtQueryTimerResolution)( PULONG MinRes, PULONG MaxRes, PULONG CurRes );
typedef HRESULT (WINAPI *pfnNtSetTimerResolution)( ULONG NewRes, BOOLEAN SetRes, PULONG CurRes );
pfnNtQueryTimerResolution pNtQueryTimerResolution;
pfnNtSetTimerResolution pNtSetTimerResolution;
ULONG curr, minr, maxr;
HMODULE dll;
dll = LoadLibrary( T( "ntdll" ) );
if ( dll )
{
pNtQueryTimerResolution = (pfnNtQueryTimerResolution) GetProcAddress( dll, "NtQueryTimerResolution" );
pNtSetTimerResolution = (pfnNtSetTimerResolution) GetProcAddress( dll, "NtSetTimerResolution" );
if ( pNtQueryTimerResolution && pNtSetTimerResolution )
{
pNtQueryTimerResolution( &minr, &maxr, &curr );
if ( maxr < 5000 ) // well, we don't need less than 0.5ms periods for select()
maxr = 5000;
pNtSetTimerResolution( maxr, TRUE, &curr );
}
FreeLibrary( dll );
}
}
/*
================
Sys_Init
Called after the common systems (cvars, files, etc)
are initialized
================
*/
void Sys_Init( void ) {
// make sure the timer is high precision, otherwise
// NT gets 18ms resolution
timeBeginPeriod( 1 );
SetTimerResolution();
Cvar_Set( "arch", "winnt" );
}
//=======================================================================
/*
==================
SetDPIAwareness
==================
*/
#if 0
static void SetDPIAwareness( void )
{
typedef HANDLE (WINAPI *pfnSetThreadDpiAwarenessContext)( HANDLE dpiContext );
typedef HRESULT (WINAPI *pfnSetProcessDpiAwareness)( int value );
pfnSetThreadDpiAwarenessContext pSetThreadDpiAwarenessContext;
pfnSetProcessDpiAwareness pSetProcessDpiAwareness;
HMODULE dll;
dll = GetModuleHandle( T("user32") );
if ( dll )
{
pSetThreadDpiAwarenessContext = (pfnSetThreadDpiAwarenessContext) GetProcAddress( dll, "SetThreadDpiAwarenessContext" );
if ( pSetThreadDpiAwarenessContext )
{
pSetThreadDpiAwarenessContext( (HANDLE)(intptr_t)-2 ); // DPI_AWARENESS_CONTEXT_SYSTEM_AWARE
}
}
dll = LoadLibrary( T("shcore") );
if ( dll )
{
pSetProcessDpiAwareness = (pfnSetProcessDpiAwareness) GetProcAddress( dll, "SetProcessDpiAwareness" );
if ( pSetProcessDpiAwareness )
{
pSetProcessDpiAwareness( 2 ); // PROCESS_PER_MONITOR_DPI_AWARE
}
FreeLibrary( dll );
}
}
#endif
static const char *GetExceptionName( DWORD code )
{
static char buf[ 32 ];
switch ( code )
{
case EXCEPTION_ACCESS_VIOLATION: return "ACCESS_VIOLATION";
case EXCEPTION_DATATYPE_MISALIGNMENT: return "DATATYPE_MISALIGNMENT";
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: return "ARRAY_BOUNDS_EXCEEDED";
case EXCEPTION_PRIV_INSTRUCTION: return "PRIV_INSTRUCTION";
case EXCEPTION_IN_PAGE_ERROR: return "IN_PAGE_ERROR";
case EXCEPTION_ILLEGAL_INSTRUCTION: return "ILLEGAL_INSTRUCTION";
case EXCEPTION_NONCONTINUABLE_EXCEPTION: return "NONCONTINUABLE_EXCEPTION";
case EXCEPTION_STACK_OVERFLOW: return "STACK_OVERFLOW";
case EXCEPTION_INVALID_DISPOSITION: return "INVALID_DISPOSITION";
case EXCEPTION_GUARD_PAGE: return "GUARD_PAGE";
case EXCEPTION_INVALID_HANDLE: return "INVALID_HANDLE";
default: break;
}
sprintf( buf, "0x%08X", (unsigned int)code );
return buf;
}
/*
==================
ExceptionFilter
Restore gamma and hide fullscreen window in case of crash
==================
*/
static LONG WINAPI ExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo )
{
#ifndef DEDICATED
if ( com_dedicated->integer == 0 ) {
extern cvar_t *com_cl_running;
if ( com_cl_running && com_cl_running->integer ) {
// assume we can restart client module
} else {
GLW_RestoreGamma();
GLW_HideFullscreenWindow();
}
}
#endif
if ( ExceptionInfo->ExceptionRecord->ExceptionCode != EXCEPTION_BREAKPOINT )
{
char msg[128], name[MAX_OSPATH];
const char *basename;
HMODULE hModule, hKernel32;
byte *addr;
hModule = NULL;
name[0] = '\0';
basename = name;
addr = (byte*)ExceptionInfo->ExceptionRecord->ExceptionAddress;
hKernel32 = GetModuleHandleA( "kernel32" );
if ( hKernel32 != NULL ) {
typedef BOOL (WINAPI *PFN_GetModuleHandleExA)( DWORD dwFlags, LPCSTR lpModuleName, HMODULE *phModule );
PFN_GetModuleHandleExA pGetModuleHandleExA;
pGetModuleHandleExA = (PFN_GetModuleHandleExA) GetProcAddress( hKernel32, "GetModuleHandleExA" );
if ( pGetModuleHandleExA != NULL ) {
if ( pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)addr, &hModule ) ) {
if (GetModuleFileNameA( hModule, name, ARRAY_LEN(name) - 1) != 0 ) {
name[ARRAY_LEN(name) - 1] = '\0';
basename = strrchr( name, '\\' );
if ( basename ) {
basename = basename + 1;
}
else {
basename = strrchr( name, '/' );
if ( basename ) {
basename = basename + 1;
}
}
}
}
}
}
if ( basename && *basename ) {
Com_sprintf( msg, sizeof( msg ), "Exception Code: %s\nException Address: %s@%x",
GetExceptionName( ExceptionInfo->ExceptionRecord->ExceptionCode ),
basename, (uint32_t)(addr - (byte*)hModule) );
} else {
Com_sprintf( msg, sizeof( msg ), "Exception Code: %s\nException Address: %p",
GetExceptionName( ExceptionInfo->ExceptionRecord->ExceptionCode ),
addr );
}
Com_Error( ERR_DROP, "Unhandled exception caught\n%s", msg );
}
return EXCEPTION_EXECUTE_HANDLER;
}
/*
==================
WinMain
==================
*/
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
static char sys_cmdline[ MAX_STRING_CHARS ];
char con_title[ MAX_CVAR_VALUE_STRING ];
int xpos, ypos;
qboolean useXYpos;
HANDLE hProcess;
DWORD dwPriority;
// should never get a previous instance in Win32
if ( hPrevInstance ) {
return 0;
}
// slightly boost process priority if it set to default
hProcess = GetCurrentProcess();
dwPriority = GetPriorityClass( hProcess );
if ( dwPriority == NORMAL_PRIORITY_CLASS || dwPriority == ABOVE_NORMAL_PRIORITY_CLASS ) {
SetPriorityClass( hProcess, HIGH_PRIORITY_CLASS );
}
//SetDPIAwareness();
g_wv.hInstance = hInstance;
Q_strncpyz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) );
useXYpos = Com_EarlyParseCmdLine( sys_cmdline, con_title, sizeof( con_title ), &xpos, &ypos );
// done before Com/Sys_Init since we need this for error output
Sys_CreateConsole( con_title, xpos, ypos, useXYpos );
// no abort/retry/fail errors
SetErrorMode( SEM_FAILCRITICALERRORS );
SetUnhandledExceptionFilter( ExceptionFilter );
Com_Init( sys_cmdline );
// hide the early console since we've reached the point where we
// have a working graphics subsystems
if ( !com_dedicated->integer && !com_viewlog->integer ) {
Sys_ShowConsole( 0, qfalse );
}
// main game loop
while ( 1 ) {
// set low precision every frame, because some system calls
// reset it arbitrarily
// _controlfp( _PC_24, _MCW_PC );
// _controlfp( -1, _MCW_EM ); // no exceptions, even if some crappy syscall turns them back on!
#ifdef DEDICATED
// run the game
Com_Frame( qfalse );
#else
// make sure mouse and joystick are only called once a frame
IN_Frame();
// run the game
Com_Frame( CL_NoDelay() );
#endif
}
// never gets here
return 0;
}