23 #include "../qcommon/qcommon.h"
33 #include "../win32/conproc.h"
35 #define MINIMUM_WIN_MEMORY 0x0a00000
36 #define MAXIMUM_WIN_MEMORY 0x1000000
54 #define MAX_NUM_ARGVS 128
76 va_start (argptr,
error);
77 vsnprintf (text, 1024,
error, argptr);
80 MessageBox(
NULL, text,
"Error", 0 );
100 #ifdef WIN_DEBUG_CONSOLE
117 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
120 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
127 MessageBox(
NULL, lpMsgBuf,
"GetLastError", MB_OK|MB_ICONINFORMATION );
130 LocalFree( lpMsgBuf );
155 SetErrorMode (SEM_FAILCRITICALERRORS);
165 for (drive[0] =
'c' ; drive[0] <=
'z' ; drive[0]++)
168 sprintf (cddir,
"%sinstall\\data", drive);
169 sprintf (test,
"%sinstall\\data\\quake2.exe", drive);
170 f = fopen(test,
"r");
174 if (GetDriveType (drive) == DRIVE_CDROM)
214 HMODULE hShcore = LoadLibraryA(
"Shcore.dll");
215 HMODULE hUser32 = LoadLibraryA(
"user32.dll");
219 if (setProcDPIAwareness)
221 else if (setProcDPIAware)
225 FreeLibrary(hShcore);
227 FreeLibrary(hUser32);
242 timeBeginPeriod( 1 );
244 vinfo.dwOSVersionInfoSize =
sizeof(vinfo);
246 if (!GetVersionEx (&vinfo))
249 if (vinfo.dwMajorVersion < 4)
250 Sys_Error (
"Quake2 requires windows version 4 or greater");
251 if (vinfo.dwPlatformId == VER_PLATFORM_WIN32s)
252 Sys_Error (
"Quake2 doesn't run on Win32s");
253 else if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
258 if (!AllocConsole ())
259 Sys_Error (
"Couldn't create dedicated server console");
260 hinput = GetStdHandle (STD_INPUT_HANDLE);
261 houtput = GetStdHandle (STD_OUTPUT_HANDLE);
266 #ifdef WIN_DEBUG_CONSOLE
270 SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), 0x07);
271 DeleteMenu(GetSystemMenu(GetConsoleWindow(),
false), SC_CLOSE, MF_BYCOMMAND);
272 freopen(
"CONOUT$",
"w", stderr);
291 INPUT_RECORD recs[1024];
293 int ch, numread, numevents;
301 if (!GetNumberOfConsoleInputEvents (
hinput, &numevents))
302 Sys_Error (
"Error getting # of console events");
307 if (!ReadConsoleInput(
hinput, recs, 1, &numread))
308 Sys_Error (
"Error reading console input");
311 Sys_Error (
"Couldn't read console input");
313 if (recs[0].EventType == KEY_EVENT)
315 if (!recs[0].Event.KeyEvent.bKeyDown)
317 ch = recs[0].Event.KeyEvent.uChar.AsciiChar;
376 #ifdef WIN_DEBUG_CONSOLE
377 fputs(
string, stderr);
378 OutputDebugString(
string);
410 while (PeekMessage (&
msg,
NULL, 0, 0, PM_NOREMOVE))
412 if (!GetMessage (&
msg,
NULL, 0, 0))
415 TranslateMessage (&
msg);
416 DispatchMessage (&
msg);
436 if ( OpenClipboard(
NULL ) != 0 )
438 HANDLE hClipboardData;
440 if ( ( hClipboardData = GetClipboardData( CF_TEXT ) ) != 0 )
442 if ( ( cliptext = GlobalLock( hClipboardData ) ) != 0 )
444 data = malloc( GlobalSize( hClipboardData ) + 1 );
445 strcpy( data, cliptext );
446 GlobalUnlock( hClipboardData );
469 ShowWindow (
cl_hwnd, SW_RESTORE);
470 SetForegroundWindow (
cl_hwnd );
504 void *(*GetGameAPI) (
void *);
509 const char *gamename =
"gamex86.dll";
512 const char *debugdir =
"release";
514 const char *debugdir =
"debug";
518 const char *gamename =
"gamex64.dll";
521 const char *debugdir =
"releasex64";
523 const char *debugdir =
"debugx64";
526 #elif defined _M_ALPHA
527 const char *gamename =
"gameaxp.dll";
530 const char *debugdir =
"releaseaxp";
532 const char *debugdir =
"debugaxp";
541 _getcwd (cwd,
sizeof(cwd));
605 while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
613 while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
635 int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
638 int time, oldtime, newtime;
657 if (!strcmp(
argv[
i],
"cddir"))
679 while (PeekMessage (&
msg,
NULL, 0, 0, PM_NOREMOVE))
681 if (!GetMessage (&
msg,
NULL, 0, 0))
684 TranslateMessage (&
msg);
685 DispatchMessage (&
msg);
691 time = newtime - oldtime;
698 _controlfp( _PC_24, _MCW_PC );