Beispiel #1
0
/*
 * Windows main function. Containts the
 * initialization code and the main loop
 */
int
main(int argc, char **argv)
{
	// Setup FPU if necessary.
	Sys_SetupFPU();

	// Force DPI awareness.
	Sys_SetHighDPIMode();

	// crappy argument parser can't parse.
	for (int i = 0; i < argc; i++)
	{
		// Are we portable?
		if (strcmp(argv[i], "-portable") == 0)
		{
			is_portable = true;
		}

		// Inject a custom data dir.
		if (strcmp(argv[i], "-datadir") == 0)
		{
			// Mkay, did the user give us an argument?
			if (i != (argc - 1))
			{
				DWORD attrib;
				WCHAR wpath[MAX_OSPATH];

				MultiByteToWideChar(CP_UTF8, 0, argv[i + 1], -1, wpath, MAX_OSPATH);
				attrib = GetFileAttributesW(wpath);

				if (attrib != INVALID_FILE_ATTRIBUTES)
				{
					if (!(attrib & FILE_ATTRIBUTE_DIRECTORY))
					{
						printf("-datadir %s is not a directory\n", argv[i + 1]);
						return 1;
					}

					Q_strlcpy(datadir, argv[i + 1], MAX_OSPATH);
				}
				else
				{
					printf("-datadir %s could not be found\n", argv[i + 1]);
					return 1;
				}
			}
			else
			{
				printf("-datadir needs an argument\n");
				return 1;
			}
		}
	}

	// Need to redirect stdout before anything happens.
#ifndef DEDICATED_ONLY
	Sys_RedirectStdout();
#endif

	// Call the initialization code.
	// Never returns.
	Qcommon_Init(argc, argv);

	return 0;
}
Beispiel #2
0
/*
 * Windows main function. Containts the
 * initialization code and the main loop
 */
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  MSG msg;
  long long oldtime, newtime;

  /* Previous instances do not exist in Win32 */
  if (hPrevInstance) {
    return 0;
  }

  /* Make the current instance global */
  global_hInstance = hInstance;

  /* Setup FPU if necessary */
  Sys_SetupFPU();

  /* Force DPI awareness */
  Sys_SetHighDPIMode();

  /* Parse the command line arguments */
  ParseCommandLine(lpCmdLine);

  /* Are we portable? */
  for (int i = 0; i < argc; i++) {
    if (strcmp(argv[i], "-portable") == 0) {
      is_portable = true;
    }
  }

/* Need to redirect stdout before anything happens. */
#ifndef DEDICATED_ONLY
  Sys_RedirectStdout();
#endif

  /* Seed PRNG */
  randk_seed();

  /* Call the initialization code */
  Qcommon_Init(argc, argv);

  /* Save our time */
  oldtime = Sys_Microseconds();

  /* The legendary main loop */
  while (1) {
    /* If at a full screen console, don't update unless needed */
    if (Minimized || (dedicated && dedicated->value)) {
      Sleep(1);
    }

    while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
      if (!GetMessage(&msg, NULL, 0, 0)) {
        Com_Quit();
      }

      sys_msg_time = msg.time;
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }

    // Throttle the game a little bit
    Sys_Nanosleep(5000);

    newtime = Sys_Microseconds();
    Qcommon_Frame(newtime - oldtime);
    oldtime = newtime;
  }

  /* never gets here */
  return TRUE;
}
Beispiel #3
0
/*
 * Windows main function. Containts the
 * initialization code and the main loop
 */
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
		LPSTR lpCmdLine, int nCmdShow)
{
	MSG msg;
	long long oldtime, newtime;

	/* Previous instances do not exist in Win32 */
	if (hPrevInstance)
	{
		return 0;
	}

	/* Make the current instance global */
	global_hInstance = hInstance;

	/* Setup FPU if necessary */
	Sys_SetupFPU();

	/* Force DPI awareness */
	Sys_SetHighDPIMode();

	/* Parse the command line arguments */
	ParseCommandLine(lpCmdLine);

	/* Are we portable? */
	for (int i = 0; i < argc; i++) {
		if (strcmp(argv[i], "-portable") == 0) {
			is_portable = true;
		}
	}

	/* Need to redirect stdout before anything happens. */
#ifndef DEDICATED_ONLY
	Sys_RedirectStdout();
#endif

	printf("Yamagi Quake II v%s\n", YQ2VERSION);
	printf("=====================\n\n");

#ifndef DEDICATED_ONLY
	printf("Client build options:\n");
#ifdef SDL2
	printf(" + SDL2\n");
#else
	printf(" - SDL2 (using 1.2)\n");
#endif
#ifdef CDA
	printf(" + CD audio\n");
#else
	printf(" - CD audio\n");
#endif
#ifdef OGG
	printf(" + OGG/Vorbis\n");
#else
	printf(" - OGG/Vorbis\n");
#endif
#ifdef USE_OPENAL
	printf(" + OpenAL audio\n");
#else
	printf(" - OpenAL audio\n");
#endif
#ifdef ZIP
	printf(" + Zip file support\n");
#else
	printf(" - Zip file support\n");
#endif
#endif

	printf("Platform: %s\n", YQ2OSTYPE);
	printf("Architecture: %s\n", YQ2ARCH);


	/* Seed PRNG */
	randk_seed();

	/* Call the initialization code */
	Qcommon_Init(argc, argv);

	/* Save our time */
	oldtime = Sys_Microseconds();

	/* The legendary main loop */
	while (1)
	{
		/* If at a full screen console, don't update unless needed */
		if (Minimized || (dedicated && dedicated->value))
		{
			Sleep(1);
		}

		while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if (!GetMessage(&msg, NULL, 0, 0))
			{
				Com_Quit();
			}

			sys_msg_time = msg.time;
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		// Throttle the game a little bit
		Sys_Nanosleep(5000);

		newtime = Sys_Microseconds();
		Qcommon_Frame(newtime - oldtime);
		oldtime = newtime;
	}

	/* never gets here */
	return TRUE;
}