diff --git a/src/c_console.cpp b/src/c_console.cpp index 4dabdb9e11..e7c7dc30bf 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -641,12 +641,14 @@ void C_NewModeAdjust () C_AdjustBottom (); } +int consoletic = 0; void C_Ticker () { static int lasttic = 0; + consoletic++; if (lasttic == 0) - lasttic = gametic - 1; + lasttic = consoletic - 1; if (con_buffersize > 0) { @@ -657,7 +659,7 @@ void C_Ticker () { if (ConsoleState == c_falling) { - ConBottom += (gametic - lasttic) * (SCREENHEIGHT*2/25); + ConBottom += (consoletic - lasttic) * (SCREENHEIGHT * 2 / 25); if (ConBottom >= SCREENHEIGHT / 2) { ConBottom = SCREENHEIGHT / 2; @@ -666,7 +668,7 @@ void C_Ticker () } else if (ConsoleState == c_rising) { - ConBottom -= (gametic - lasttic) * (SCREENHEIGHT*2/25); + ConBottom -= (consoletic - lasttic) * (SCREENHEIGHT * 2 / 25); if (ConBottom <= 0) { ConsoleState = c_up; @@ -681,7 +683,7 @@ void C_Ticker () CursorTicker = C_BLINKRATE; } - lasttic = gametic; + lasttic = consoletic; if (NotifyTopGoal > NotifyTop) { diff --git a/src/d_net.cpp b/src/d_net.cpp index 2cf13173fc..0daf010c64 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -1275,6 +1275,55 @@ void NetUpdate (void) // listen for other packets GetPackets (); + + if (!demoplayback) + { + // ideally nettics[0] should be 1 - 3 tics above lowtic + // if we are consistantly slower, speed up time + + // [RH] I had erroneously assumed frameskip[] had 4 entries + // because there were 4 players, but that's not the case at + // all. The game is comparing the lag behind the master for + // four runs of TryRunTics. If our tic count is ahead of the + // master all 4 times, the next run of NetUpdate will not + // process any new input. If we have less input than the + // master, the next run of NetUpdate will process extra tics + // (because gametime gets decremented here). + + // the key player does not adapt + if (consoleplayer != Net_Arbitrator) + { + // I'm not sure about this when using a packet server, because + // if left unmodified from the P2P version, it can make the game + // very jerky. The way I have it written right now basically means + // that it won't adapt. Fortunately, player prediction helps + // alleviate the lag somewhat. + + if (NetMode != NET_PacketServer) + { + mastertics = nettics[nodeforplayer[Net_Arbitrator]]; + } + if (nettics[0] <= mastertics) + { + gametime--; + if (debugfile) fprintf(debugfile, "-"); + } + if (NetMode != NET_PacketServer) + { + frameskip[(maketic / ticdup) & 3] = (oldnettics > mastertics); + } + else + { + frameskip[(maketic / ticdup) & 3] = (oldnettics - mastertics) > 3; + } + if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) + { + skiptics = 1; + if (debugfile) fprintf(debugfile, "+"); + } + oldnettics = nettics[0]; + } + }// !demoplayback } @@ -1751,72 +1800,27 @@ void TryRunTics (void) else counts = availabletics; + // Uncapped framerate needs seprate checks if (counts == 0 && !doWait) { // Check possible stall conditions Net_CheckLastRecieved(counts); + if (realtics >= 1) + { + C_Ticker(); + M_Ticker(); + } return; } if (counts < 1) counts = 1; - frameon++; - if (debugfile) fprintf (debugfile, "=======real: %i avail: %i game: %i\n", realtics, availabletics, counts); - if (!demoplayback) - { - // ideally nettics[0] should be 1 - 3 tics above lowtic - // if we are consistantly slower, speed up time - - // [RH] I had erroneously assumed frameskip[] had 4 entries - // because there were 4 players, but that's not the case at - // all. The game is comparing the lag behind the master for - // four runs of TryRunTics. If our tic count is ahead of the - // master all 4 times, the next run of NetUpdate will not - // process any new input. If we have less input than the - // master, the next run of NetUpdate will process extra tics - // (because gametime gets decremented here). - - // the key player does not adapt - if (consoleplayer != Net_Arbitrator) - { - // I'm not sure about this when using a packet server, because - // if left unmodified from the P2P version, it can make the game - // very jerky. The way I have it written right now basically means - // that it won't adapt. Fortunately, player prediction helps - // alleviate the lag somewhat. - - if (NetMode != NET_PacketServer) - { - mastertics = nettics[nodeforplayer[Net_Arbitrator]]; - } - if (nettics[0] <= mastertics) - { - gametime--; - if (debugfile) fprintf (debugfile, "-"); - } - if (NetMode != NET_PacketServer) - { - frameskip[frameon&3] = (oldnettics > mastertics); - } - else - { - frameskip[frameon&3] = (oldnettics - mastertics) > 3; - } - if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) - { - skiptics = 1; - if (debugfile) fprintf (debugfile, "+"); - } - oldnettics = nettics[0]; - } - }// !demoplayback - // wait for new tics if needed while (lowtic < gametic + counts) { @@ -1836,7 +1840,7 @@ void TryRunTics (void) Net_CheckLastRecieved (counts); // don't stay in here forever -- give the menu a chance to work - if (I_GetTime (false) - entertic >= TICRATE/3) + if (I_GetTime (false) - entertic >= 1) { C_Ticker (); M_Ticker ();