From 09d8b4af80713c4a176c4d4be0ab31deed724371 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 12:00:21 +0100 Subject: [PATCH] - changed I_GetTimeFrac to return a double instead of a fixed_t. --- src/posix/cocoa/i_timer.cpp | 6 +++--- src/posix/i_system.h | 2 +- src/posix/sdl/i_timer.cpp | 5 ++--- src/r_utility.cpp | 6 +++--- src/win32/i_system.cpp | 7 +++---- src/win32/i_system.h | 2 +- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/posix/cocoa/i_timer.cpp b/src/posix/cocoa/i_timer.cpp index b08a43139..901657eb9 100644 --- a/src/posix/cocoa/i_timer.cpp +++ b/src/posix/cocoa/i_timer.cpp @@ -186,7 +186,7 @@ unsigned int I_FPSTime() } -fixed_t I_GetTimeFrac(uint32* ms) +double I_GetTimeFrac(uint32* ms) { const uint32_t now = I_MSTime(); @@ -196,8 +196,8 @@ fixed_t I_GetTimeFrac(uint32* ms) } return 0 == s_ticStart - ? FRACUNIT - : clamp( (now - s_ticStart) * FRACUNIT * TICRATE / 1000, 0, FRACUNIT); + ? 1. + : clamp( (now - s_ticStart) * TICRATE / 1000., 0, 1); } diff --git a/src/posix/i_system.h b/src/posix/i_system.h index 391503602..0515f2d85 100644 --- a/src/posix/i_system.h +++ b/src/posix/i_system.h @@ -62,7 +62,7 @@ extern int (*I_WaitForTic) (int); // tic will never arrive (unless it's the current one). extern void (*I_FreezeTime) (bool frozen); -fixed_t I_GetTimeFrac (uint32 *ms); +double I_GetTimeFrac (uint32 *ms); // Return a seed value for the RNG. unsigned int I_MakeRNGSeed(); diff --git a/src/posix/sdl/i_timer.cpp b/src/posix/sdl/i_timer.cpp index 6255c8a96..fa08659a1 100644 --- a/src/posix/sdl/i_timer.cpp +++ b/src/posix/sdl/i_timer.cpp @@ -178,7 +178,7 @@ void I_SelectTimer() } // Returns the fractional amount of a tic passed since the most recent tic -fixed_t I_GetTimeFrac (uint32 *ms) +double I_GetTimeFrac (uint32 *ms) { DWORD now = SDL_GetTicks (); if (ms) *ms = TicStart + (1000 / TICRATE); @@ -188,8 +188,7 @@ fixed_t I_GetTimeFrac (uint32 *ms) } else { - fixed_t frac = clamp ((now - TicStart)*FRACUNIT*TICRATE/1000, 0, FRACUNIT); - return frac; + return clamp((now - TicStart) * TICRATE / 1000., 0, 1); } } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index c3229c14c..224648770 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -1006,12 +1006,12 @@ void R_SetupFrame (AActor *actor) iview->otic = nowtic; } - r_TicFrac = I_GetTimeFrac (&r_FrameTime); + r_TicFracF = I_GetTimeFrac (&r_FrameTime); if (cl_capfps || r_NoInterpolate) { - r_TicFrac = FRACUNIT; + r_TicFracF = 1.; } - r_TicFracF = FIXED2DBL(r_TicFrac); + r_TicFrac = FLOAT2FIXED(r_TicFracF); R_InterpolateView (player, r_TicFrac, iview); diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 0db4dd15e..ebf90e476 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -468,7 +468,7 @@ static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw // //========================================================================== -fixed_t I_GetTimeFrac(uint32 *ms) +double I_GetTimeFrac(uint32 *ms) { DWORD now = timeGetTime(); if (ms != NULL) @@ -478,12 +478,11 @@ fixed_t I_GetTimeFrac(uint32 *ms) DWORD step = TicNext - TicStart; if (step == 0) { - return FRACUNIT; + return 1.; } else { - fixed_t frac = clamp ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT); - return frac; + return clamp(double(now - TicStart) / step, 0, 1); } } diff --git a/src/win32/i_system.h b/src/win32/i_system.h index 179af4804..8e75b22a3 100644 --- a/src/win32/i_system.h +++ b/src/win32/i_system.h @@ -90,7 +90,7 @@ extern int (*I_WaitForTic) (int); // tic will never arrive (unless it's the current one). extern void (*I_FreezeTime) (bool frozen); -fixed_t I_GetTimeFrac (uint32 *ms); +double I_GetTimeFrac (uint32 *ms); // Return a seed value for the RNG. unsigned int I_MakeRNGSeed();