Пример #1
0
void TryRunTics (void)
{
	int runtics;
	int entertime = I_GetTime();

	// Wait for tics to run
	while (1)
	{
#ifdef HAVE_NET
    NetUpdate();
#else
    D_BuildNewTiccmds();
#endif

    runtics = (server ? remotetic : maketic) - gametic;
	
    if (!runtics)
	{
		if (server)
			I_WaitForPacket(ms_to_next_tick);
		else
			I_uSleep(ms_to_next_tick*1000);

		if (I_GetTime() - entertime > 10)
		{
			remotesend--;
			
			if (server)
			{
				char buf[sizeof(packet_header_t) + 1];
				
				packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic);
				buf[sizeof(buf) - 1] = consoleplayer;
				I_SendPacket((packet_header_t *)buf, sizeof buf);
			}
			
			M_Ticker();
			return;
		}
		} else break;
	}

	while (runtics--)
	{
#ifdef HAVE_NET
		if (server) CheckQueuedPackets();
#endif
		if (advancedemo) D_DoAdvanceDemo ();
	
		M_Ticker ();
		G_Ticker ();
	
		gametic++;
	
#ifdef HAVE_NET
		NetUpdate(); // Keep sending our tics to avoid stalling remote nodes
#endif
	}
}
Пример #2
0
void TryRunTics (void)
{
  int runtics;
  int entertime = I_GetTime();

  // Wait for tics to run
  while (1) {
    NetUpdate();
    runtics = (server ? remotetic : maketic) - gametic;
    if (!runtics) {
      if (!movement_smooth) {
        if (server)
          I_WaitForPacket(ms_to_next_tick);
        else
          I_uSleep(ms_to_next_tick*1000);
      }
      if (I_GetTime() - entertime > 10) {
        if (server) {
          char buf[sizeof(packet_header_t)+1];
          remotesend--;
          packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic);
          buf[sizeof(buf)-1] = consoleplayer;
          I_SendPacket((packet_header_t *)buf, sizeof buf);
        }
        M_Ticker(); return;
      }
      {
        WasRenderedInTryRunTics = TRUE;
        if (movement_smooth && gamestate==wipegamestate)
        {
          isExtraDDisplay = TRUE;
          D_Display();
          isExtraDDisplay = FALSE;
        }
      }
    } else break;
  }

  while (runtics--) {
    if (server) CheckQueuedPackets();
    if (advancedemo)
      D_DoAdvanceDemo ();
    M_Ticker ();
    I_GetTime_SaveMS();
    G_Ticker ();
    P_Checksum(gametic);
    gametic++;
    NetUpdate(); // Keep sending our tics to avoid stalling remote nodes
  }
}
Пример #3
0
void D_QuitNetGame (void)
{
  uint8_t buf[1 + sizeof(packet_header_t)];
  packet_header_t *packet = (void*)buf;
  int i;

  if (!server) return;
  buf[sizeof(packet_header_t)] = consoleplayer;
  packet_set(packet, PKT_QUIT, gametic);

  for (i=0; i<4; i++) {
    I_SendPacket(packet, 1 + sizeof(packet_header_t));
    I_uSleep(10000);
  }
}
Пример #4
0
void D_CheckNetGame(void)
{
  packet_header_t *packet = Z_Malloc(sizeof(packet_header_t)+1, PU_STATIC, NULL);

  if (server) {
    lprintf(LO_INFO, "D_CheckNetGame: waiting for server to signal game start\n");
    do {
      while (!I_GetPacket(packet, sizeof(packet_header_t)+1)) {
        packet_set(packet, PKT_GO, 0);
	*(uint8_t*)(packet+1) = consoleplayer;
	I_SendPacket(packet, sizeof(packet_header_t)+1);
	I_uSleep(100000);
      }
    } while (packet->type != PKT_GO);
  }
  Z_Free(packet);
}
Пример #5
0
void D_CheckNetGame(void)
{
  packet_header_t *packet = Z_Malloc(sizeof(packet_header_t)+1, PU_STATIC, NULL);

  if (server) {
    lprintf(LO_INFO, "D_CheckNetGame: waiting for server to signal game start\n");
#ifdef USE_ANDROID
    jni_info_msg("Waiting for server to signal game start!", TT_LONG_DELAY | TT_COLOR_RED);
#endif
    do {
      while (!I_GetPacket(packet, sizeof(packet_header_t)+1)) {
        packet_set(packet, PKT_GO, 0);
	*(byte*)(packet+1) = consoleplayer;
	I_SendPacket(packet, sizeof(packet_header_t)+1);
	I_uSleep(100000);
      }
    } while (packet->type != PKT_GO);
  }
  Z_Free(packet);
}
Пример #6
0
static void tryruntics(void)
{

    int runtics;
    int entertime = I_GetTime();

    while (1)
    {

        D_BuildNewTiccmds();

        runtics = maketic - gametic;

        if (runtics)
            break;

        I_uSleep(ms_to_next_tick * 1000);

        if (I_GetTime() - entertime > 10)
        {

            M_Ticker();
                
            return;

        }

    }

    while (runtics--)
    {

        M_Ticker();
        G_Ticker();

        gametic++;

    }

}
Пример #7
0
static void D_Wipe(void)
{
  boolean done;
  int wipestart = I_GetTime () - 1;

  do
    {
      int nowtime, tics;
      do
        {
          I_uSleep(5000); // CPhipps - don't thrash cpu in this loop
          nowtime = I_GetTime();
          tics = nowtime - wipestart;
        }
      while (!tics);
      wipestart = nowtime;
      done = wipe_ScreenWipe(tics);
      I_UpdateNoBlit();
      M_Drawer();                   // menu is drawn even on top of wipes
      I_FinishUpdate();             // page flip or blit buffer
    }
  while (!done);
}
Пример #8
0
int I_MessageBox(const char* text, unsigned int type)
{
  int result = PRB_IDCANCEL;

#ifdef _WIN32
  {
    HWND current_hwnd = GetForegroundWindow();
    result = MessageBox(GetDesktopWindow(), text, PACKAGE_NAME, type|MB_TASKMODAL|MB_TOPMOST);
    I_SwitchToWindow(current_hwnd);
    return result;
  }
#endif

#if 0
  {
    typedef struct mb_hotkeys_s
    {
      int type;
      char *hotkeys_str;
    } mb_hotkeys_t;

    mb_hotkeys_t mb_hotkeys[] = {
      {PRB_MB_OK               , "(press <enter> to continue)"},
      {PRB_MB_OKCANCEL         , "(press <enter> to continue or <esc> to cancel)"},
      {PRB_MB_ABORTRETRYIGNORE , "(a - abort, r - retry, i - ignore)"},
      {PRB_MB_YESNOCANCEL      , "(y - yes, n - no, esc - cancel"},
      {PRB_MB_YESNO            , "(y - yes, n - no)"},
      {PRB_MB_RETRYCANCEL      , "(r - retry, <esc> - cancel)"},
      {0, NULL}
    };

    int i, c;
    char* hotkeys_str = NULL;
    
    type &= 0x000000ff;

    i = 0;
    while (mb_hotkeys[i].hotkeys_str)
    {
      if (mb_hotkeys[i].type == type)
      {
        hotkeys_str = mb_hotkeys[i].hotkeys_str;
        break;
      }
      i++;
    }

    if (hotkeys_str)
    {
      lprintf(LO_CONFIRM, "%s\n%s\n", text, hotkeys_str);

      result = -1;
      do
      {
        I_uSleep(1000);

        c = tolower(getchar());

        if (c == 'y') result = PRB_IDYES;
        else if (c == 'n') result = PRB_IDNO;
        else if (c == 'a') result = PRB_IDABORT;
        else if (c == 'r') result = PRB_IDRETRY;
        else if (c == 'i') result = PRB_IDIGNORE;
        else if (c == 'o' || c == 13) result = PRB_IDOK;
        else if (c == 'c' || c == 27) result = PRB_IDCANCEL;
      }
      while (result == EOF);

      return result;
    }

    return result;
  }
#else
  return PRB_IDCANCEL;
#endif
}
Пример #9
0
boolean D_NetGetWad(const char* name)
{
#if defined(HAVE_WAIT_H)
  size_t psize = sizeof(packet_header_t) + strlen(name) + 500;
  packet_header_t *packet;
  boolean done = FALSE;

  if (!server || strchr(name, '/')) return FALSE; // If it contains path info, reject

  do {
    // Send WAD request to remote
    packet = Z_Malloc(psize, PU_STATIC, NULL);
    packet_set(packet, PKT_WAD, 0);
    *(uint8_t*)(packet+1) = consoleplayer;
    strcpy(1+(uint8_t*)(packet+1), name);
    I_SendPacket(packet, sizeof(packet_header_t) + strlen(name) + 2);

    I_uSleep(10000);
  } while (!I_GetPacket(packet, psize) || (packet->type != PKT_WAD));
  Z_Free(packet);

  if (!strcasecmp((void*)(packet+1), name)) {
    pid_t pid;
    int   rv;
    uint8_t *p = (uint8_t*)(packet+1) + strlen(name) + 1;

    /* Automatic wad file retrieval using wget (supports http and ftp, using URLs)
     * Unix systems have all these commands handy, this kind of thing is easy
     * Any windo$e port will have some awkward work replacing these.
     */
    /* cph - caution here. This is data from an untrusted source.
     * Don't pass it via a shell. */
    if ((pid = fork()) == -1)
      perror("fork");
    else if (!pid) {
      /* Child chains to wget, does the download */
      execlp("wget", "wget", p, NULL);
    }
    /* This is the parent, i.e. main LxDoom process */
    wait(&rv);
    if (!(done = !access(name, R_OK))) {
      if (!strcmp(p+strlen(p)-4, ".zip")) {
  p = strrchr(p, '/')+1;
  if ((pid = fork()) == -1)
    perror("fork");
  else if (!pid) {
    /* Child executes decompressor */
    execlp("unzip", "unzip", p, name, NULL);
  }
  /* Parent waits for the file */
  wait(&rv);
  done = !!access(name, R_OK);
      }
      /* Add more decompression protocols here as desired */
    }
    Z_Free(buffer);
  }
  return done;
#else /* HAVE_WAIT_H */
  return FALSE;
#endif
}
Пример #10
0
void D_Display (void)
{
  static boolean inhelpscreensstate   = false;
  static boolean isborderstate        = false;
  static boolean borderwillneedredraw = false;
  static gamestate_t oldgamestate = -1;
  boolean wipe;
  boolean viewactive = false, isborder = false;

  if (nodrawers)                    // for comparative timing / profiling
    return;

  if (!I_StartDisplay())
    return;

  // save the current screen if about to wipe
  if ((wipe = gamestate != wipegamestate) && (V_GetMode() != VID_MODEGL))
    wipe_StartScreen();

  if (gamestate != GS_LEVEL) { // Not a level
    switch (oldgamestate) {
    case -1:
    case GS_LEVEL:
      V_SetPalette(0); // cph - use default (basic) palette
    default:
      break;
    }

    switch (gamestate) {
    case GS_INTERMISSION:
      WI_Drawer();
      break;
    case GS_FINALE:
      F_Drawer();
      break;
    case GS_DEMOSCREEN:
      D_PageDrawer();
      break;
    default:
      break;
    }
  } else if (gametic != basetic) { // In a level
    boolean redrawborderstuff;

    HU_Erase();

    if (setsizeneeded) {               // change the view size if needed
      R_ExecuteSetViewSize();
      oldgamestate = -1;            // force background redraw
    }

    // Work out if the player view is visible, and if there is a border
    viewactive = (!(automapmode & am_active) || (automapmode & am_overlay)) && !inhelpscreens;
    isborder = viewactive ? (viewheight != SCREENHEIGHT) : (!inhelpscreens && (automapmode & am_active));

    if (oldgamestate != GS_LEVEL) {
      R_FillBackScreen ();    // draw the pattern into the back screen
      redrawborderstuff = isborder;
    } else {
      // CPhipps -
      // If there is a border, and either there was no border last time,
      // or the border might need refreshing, then redraw it.
      redrawborderstuff = isborder && (!isborderstate || borderwillneedredraw);
      // The border may need redrawing next time if the border surrounds the screen,
      // and there is a menu being displayed
      borderwillneedredraw = menuactive && isborder && viewactive && (viewwidth != SCREENWIDTH);
    }
    if (redrawborderstuff || (V_GetMode() == VID_MODEGL))
      R_DrawViewBorder();

    // Now do the drawing
    if (viewactive)
      R_RenderPlayerView (&players[displayplayer]);
    if (automapmode & am_active)
      AM_Drawer();
    ST_Drawer((viewheight != SCREENHEIGHT) || ((automapmode & am_active) && !(automapmode & am_overlay)), redrawborderstuff);
    if (V_GetMode() != VID_MODEGL)
      R_DrawViewBorder();
    HU_Drawer();
  }

  inhelpscreensstate = inhelpscreens;
  isborderstate      = isborder;
  oldgamestate = wipegamestate = gamestate;

  // draw pause pic
  if (paused) {
    // Simplified the "logic" here and no need for x-coord caching - POPE
    V_DrawNamePatch((320 - V_NamePatchWidth("M_PAUSE"))/2, 4,
                    0, "M_PAUSE", CR_DEFAULT, VPT_STRETCH);
  }

  // menus go directly to the screen
  M_Drawer();          // menu is drawn even on top of everything
#ifdef HAVE_NET
  NetUpdate();         // send out any new accumulation
#else
  D_BuildNewTiccmds();
#endif

  // normal update
  if (!wipe || (V_GetMode() == VID_MODEGL))
    I_FinishUpdate ();              // page flip or blit buffer
  else {
    // wipe update
    wipe_EndScreen();
    D_Wipe();
  }

  I_EndDisplay();

  //e6y: don't thrash cpu during pausing
  if (paused) {
    I_uSleep(1000);
  }
}
Пример #11
0
void TryRunTics ()
{
  int runtics;
  int entertime = I_GetTime();

  // Wait for tics to run
  while (1) {
#ifdef HAVE_NET
    NetUpdate();
#else

    D_BuildNewTiccmds();

#endif
    runtics = (server ? remotetic : maketic) - gametic;

    if (!runtics) {
      if (!movement_smooth) {
#ifdef HAVE_NET
        if (server)
          I_WaitForPacket(ms_to_next_tick);
        else
#endif
          I_uSleep(ms_to_next_tick*1000);
      }

      if (I_GetTime() - entertime > 10) {
#ifdef HAVE_NET
        if (server) {
          char buf[sizeof(packet_header_t)+1];
          remotesend--;
          packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic);
          buf[sizeof(buf)-1] = consoleplayer;
          I_SendPacket((packet_header_t *)buf, sizeof buf);
        }
#endif

        M_Ticker(); return;
      }
      //if ((displaytime) < (tic_vars.next-SDL_GetTicks()))
      {
        WasRenderedInTryRunTics = true;
        if (V_GetMode() == VID_MODEGL ? 
            movement_smooth : 
            movement_smooth && gamestate==wipegamestate)
        {
          isExtraDDisplay = true;
          D_Display(0);
          D_Display(1);
          isExtraDDisplay = false;
        }
      }
    } else break;
  }

  while (runtics--) {
#ifdef HAVE_NET
    if (server) CheckQueuedPackets();
#endif


    if (advancedemo)
      D_DoAdvanceDemo ();


    M_Ticker ();
    I_GetTime_SaveMS();
    G_Ticker ();
    P_Checksum(gametic);
    gametic++;
#ifdef HAVE_NET
    NetUpdate(); // Keep sending our tics to avoid stalling remote nodes
#endif
  }
}