22 #include "../qcommon/qcommon.h"
32 #include "../win32/conproc.h"
34 #define MINIMUM_WIN_MEMORY 0x0a00000
35 #define MAXIMUM_WIN_MEMORY 0x1000000
53 #define MAX_NUM_ARGVS 128
75 va_start (argptr, error);
76 vsprintf (text, error, argptr);
79 MessageBox(
NULL, text,
"Error", 0 );
112 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
115 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
122 MessageBox(
NULL, lpMsgBuf,
"GetLastError", MB_OK|MB_ICONINFORMATION );
125 LocalFree( lpMsgBuf );
150 SetErrorMode (SEM_FAILCRITICALERRORS);
160 for (drive[0] =
'c' ; drive[0] <=
'z' ; drive[0]++)
163 sprintf (cddir,
"%sinstall\\data", drive);
164 sprintf (test,
"%sinstall\\data\\quake2.exe", drive);
165 f = fopen(test,
"r");
169 if (GetDriveType (drive) == DRIVE_CDROM)
220 Sys_Error (
"QWCL is already running on this system");
230 timeBeginPeriod( 1 );
232 vinfo.dwOSVersionInfoSize =
sizeof(vinfo);
234 if (!GetVersionEx (&vinfo))
237 if (vinfo.dwMajorVersion < 4)
238 Sys_Error (
"Quake2 requires windows version 4 or greater");
239 if (vinfo.dwPlatformId == VER_PLATFORM_WIN32s)
240 Sys_Error (
"Quake2 doesn't run on Win32s");
241 else if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
246 if (!AllocConsole ())
247 Sys_Error (
"Couldn't create dedicated server console");
248 hinput = GetStdHandle (STD_INPUT_HANDLE);
249 houtput = GetStdHandle (STD_OUTPUT_HANDLE);
267 INPUT_RECORD recs[1024];
269 int ch, numread, numevents;
277 if (!GetNumberOfConsoleInputEvents (
hinput, &numevents))
278 Sys_Error (
"Error getting # of console events");
283 if (!ReadConsoleInput(
hinput, recs, 1, &numread))
284 Sys_Error (
"Error reading console input");
287 Sys_Error (
"Couldn't read console input");
289 if (recs[0].EventType == KEY_EVENT)
291 if (!recs[0].Event.KeyEvent.bKeyDown)
293 ch = recs[0].Event.KeyEvent.uChar.AsciiChar;
362 WriteFile(
houtput,
string, strlen(
string), &dummy,
NULL);
380 while (PeekMessage (&
msg,
NULL, 0, 0, PM_NOREMOVE))
382 if (!GetMessage (&
msg,
NULL, 0, 0))
385 TranslateMessage (&
msg);
386 DispatchMessage (&
msg);
406 if ( OpenClipboard(
NULL ) != 0 )
408 HANDLE hClipboardData;
410 if ( ( hClipboardData = GetClipboardData( CF_TEXT ) ) != 0 )
412 if ( ( cliptext = GlobalLock( hClipboardData ) ) != 0 )
414 data = malloc( GlobalSize( hClipboardData ) + 1 );
415 strcpy( data, cliptext );
416 GlobalUnlock( hClipboardData );
439 ShowWindow (
cl_hwnd, SW_RESTORE);
440 SetForegroundWindow (
cl_hwnd );
474 void *(*GetGameAPI) (
void *);
479 const char *gamename =
"gamex86.dll";
482 const char *debugdir =
"release";
484 const char *debugdir =
"debug";
487 #elif defined _M_ALPHA
488 const char *gamename =
"gameaxp.dll";
491 const char *debugdir =
"releaseaxp";
493 const char *debugdir =
"debugaxp";
502 _getcwd (cwd,
sizeof(cwd));
566 while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
574 while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
596 int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
599 int time, oldtime, newtime;
618 if (!strcmp(
argv[
i],
"cddir"))
640 while (PeekMessage (&
msg,
NULL, 0, 0, PM_NOREMOVE))
642 if (!GetMessage (&
msg,
NULL, 0, 0))
645 TranslateMessage (&
msg);
646 DispatchMessage (&
msg);
652 time = newtime - oldtime;
657 _controlfp( _PC_24, _MCW_PC );