diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index dcdca6d13..e9ef7cbf2 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -879,3 +879,16 @@ void debugprintf(const char* f, ...) I_DebugPrint(out); } +int CalcSmoothRatio(const ClockTicks &totalclk, const ClockTicks &ototalclk, int realgameticspersec) +{ + const double TICRATE = 120.; + + double rfreq = (refreshfreq != -1 ? refreshfreq : 60); + rfreq = rfreq * TICRATE / timerGetClockRate(); + + double elapsedTime = (totalclk - ototalclk).toScale16F(); + double elapsedFrames = elapsedTime * rfreq * (1. / TICRATE); + double ratio = (elapsedFrames * realgameticspersec) / rfreq; + return clamp(xs_RoundToInt(ratio * 65536), 0, 65536); +} + diff --git a/source/common/gamecontrol.h b/source/common/gamecontrol.h index 7bec34c46..aeb25df8a 100644 --- a/source/common/gamecontrol.h +++ b/source/common/gamecontrol.h @@ -158,6 +158,7 @@ void S_SetSoundPaused(int state); void G_HandleMemErr(int32_t lineNum, const char* fileName, const char* funcName); void G_FatalEngineError(void); +int CalcSmoothRatio(const ClockTicks& totalclk, const ClockTicks& ototalclk, int realgameticspersec); struct FStartupInfo diff --git a/source/duke3d/src/demo.cpp b/source/duke3d/src/demo.cpp index 6e581acca..dfb18e9f2 100644 --- a/source/duke3d/src/demo.cpp +++ b/source/duke3d/src/demo.cpp @@ -796,7 +796,7 @@ nextdemo_nomenu: } else { - j = calc_smoothratio_demo(totalclock, ototalclock); + j = CalcSmoothRatio(totalclock, ototalclock, REALGAMETICSPERSEC); if (g_demo_paused && g_demo_rewind) j = 65536-j; diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 02afaf176..cab06df0f 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -325,17 +325,6 @@ static inline int32_t gameHandleEvents(void) return handleevents(); } -static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk) -{ - int32_t rfreq = tabledivide64((refreshfreq != -1 ? refreshfreq : 60) * TICRATE, timerGetClockRate()); - uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE); -#if 0 - //POGO: additional debug info for testing purposes - OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq)); -#endif - return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536); -} - static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) { if (!(((!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) || @@ -346,7 +335,7 @@ static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk return 65536; } - return calc_smoothratio_demo(totalclk, ototalclk); + return CalcSmoothRatio(totalclk, ototalclk, REALGAMETICSPERSEC); } // sector effector lotags diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 6c5057849..8cc77207a 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -1489,22 +1489,10 @@ void G_Polymer_UnInit(void) { } static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) { - // if (!((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) || - // (g_netServer || ud.multimode > 1) || - // ud.recstat == 2) || - // ud.pause_on) - // { - // return 65536; - // } if (bRecord || bPlayback || nFreeze != 0 || bCamera || bPause) return 65536; - int32_t rfreq = (refreshfreq != -1 ? refreshfreq : 60); - uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*120); -#if 0 - //POGO: additional debug info for testing purposes - OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*30, rfreq)); -#endif - return clamp(tabledivide64(65536*elapsedFrames*30, rfreq), 0, 65536); + + return CalcSmoothRatio(totalclk, ototalclk, 30); } #define COLOR_RED redcol diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 3b6a4e0a5..151698803 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -249,7 +249,7 @@ void PlayerInterruptKeys() } //if ((counter++) % 4 == 0) // what was this for??? - q16avel += fix16_from_int(turn); + q16avel += fix16_from_int(turn*2); } diff --git a/source/rr/src/game.h b/source/rr/src/game.h index b2c0a0a92..89c9672ea 100644 --- a/source/rr/src/game.h +++ b/source/rr/src/game.h @@ -324,17 +324,6 @@ static inline void G_HandleAsync(void) Net_GetPackets(); } -static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk) -{ - int32_t rfreq = (refreshfreq != -1 ? refreshfreq : 60); - uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE); -#if 0 - //POGO: additional debug info for testing purposes - OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq)); -#endif - return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536); -} - static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) { if (!(((!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) || @@ -345,7 +334,7 @@ static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk return 65536; } - return calc_smoothratio_demo(totalclk, ototalclk); + return CalcSmoothRatio(totalclk, ototalclk, REALGAMETICSPERSEC); } // sector effector lotags diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 0f3d7a2da..dac8c6140 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1994,19 +1994,6 @@ SWBOOL PicInView(short, SWBOOL); void DoPlayerDiveMeter(PLAYERp pp); void MoveScrollMode2D(PLAYERp pp); - -static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk) -{ - const int TICRATE = 120; - const int REALGAMETICSPERSEC = TICRATE / synctics; - - int32_t rfreq = (refreshfreq != -1 ? refreshfreq : 60); - double elapsedTime = (totalclk - ototalclk).toScale16F(); - double elapsedFrames = elapsedTime * rfreq * (1. / TICRATE); - double ratio = (elapsedFrames * REALGAMETICSPERSEC) / rfreq; - return clamp(xs_RoundToInt(ratio * 65536), 0, 65536); -} - void drawscreen(PLAYERp pp) { @@ -2076,7 +2063,7 @@ drawscreen(PLAYERp pp) PreUpdatePanel(); - smoothratio = calc_smoothratio_demo(totalclock, ototalclock); + smoothratio = CalcSmoothRatio(totalclock, ototalclock, 120 / synctics); if (!ScreenSavePic) {