Пример #1
0
/*
 * Returns a pointer to the structure
 * with all entry points and global
 * variables
 */
game_export_t *
GetGameAPI(game_import_t *import)
{
	gi = *import;

	globals.apiversion = GAME_API_VERSION;
	globals.Init = InitGame;
	globals.Shutdown = ShutdownGame;
	globals.SpawnEntities = SpawnEntities;

	globals.WriteGame = WriteGame;
	globals.ReadGame = ReadGame;
	globals.WriteLevel = WriteLevel;
	globals.ReadLevel = ReadLevel;

	globals.ClientThink = ClientThink;
	globals.ClientConnect = ClientConnect;
	globals.ClientUserinfoChanged = ClientUserinfoChanged;
	globals.ClientDisconnect = ClientDisconnect;
	globals.ClientBegin = ClientBegin;
	globals.ClientCommand = ClientCommand;

	globals.RunFrame = G_RunFrame;

	globals.ServerCommand = ServerCommand;

	globals.edict_size = sizeof(edict_t);

	/* Initalize the PRNG */
	randk_seed();

	return &globals;
}
Пример #2
0
int main(int argc, char **argv)
{
	int i, j;
	int seed;

	randk_reset();
	if(argc < 2 || !(seed = atoi(argv[1])))
	{
		//seed = time(NULL);
		randk_seed();
	}
	else
	{
		printf("SEED: %u\n", seed);
		//srand(seed);
		randk_seed_manual(seed);
	}
	
	printf(";;k = 5;;;;k = log2(n);;;;k = sqrt(n);;;;k = n/2;\n");
	printf("i;n;Stupid;Heap;Median;Quick;");
	printf("Stupid;Heap;Median;Quick;");
	printf("Stupid;Heap;Median;Quick;");
	printf("Stupid;Heap;Median;Quick;\n");
	
	for (i = 1; i <= 15; i++)
	{
		int n = 1000 * (1 << i);
		instance_a(vet, n);
		printf("%d;%d;", i, n);
		test_battery(n);
	}
	
	printf("j;p;\n");
	
	for (j = 1; j <= 15; j++)
	{
		int p = 1 << j;
		instance_b(vet, INPUT_MAX, p);
		printf("%d;%d;", j, p);
		test_battery(INPUT_MAX);
	}
	
	return 0;
}
Пример #3
0
int
main(int argc, char **argv)
{
  Game game;
  uint64_t perftVal;
  int depth;

  SetUnbufferedOutput();

  if(argc == 2 && strcmp(argv[1], "--version") == 0) {
      printf("Weak %s.\n", version);
      return EXIT_SUCCESS;
  }

  if(argc < 3) {
    fprintf(stderr, "Usage: %s [fen] [depth]\n", argv[0]);
    return EXIT_FAILURE;
  }

  if((depth = atoi(argv[2])) < 1) {
    fprintf(stderr, "Invalid depth '%s'.\n", argv[2]);
    return EXIT_FAILURE;
  }

  // Initialise prng.
  randk_seed();
  randk_warmup(KISS_WARMUP_ROUNDS);

  InitEngine();

  game = ParseFen(argv[1]);

  perftVal = QuickPerft(&game, depth);

  printf("%lu\n", perftVal);

  return EXIT_SUCCESS;
}
Пример #4
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;
}
Пример #5
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;
}