Last active
September 7, 2016 19:14
-
-
Save BenLubar/e4396da5cfa6597f4605433ba74642a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/game/client/cdll_client_int.cpp b/src/game/client/cdll_client_int.cpp | |
index 5dd7750..1a2c56b 100644 | |
--- a/src/game/client/cdll_client_int.cpp | |
+++ b/src/game/client/cdll_client_int.cpp | |
@@ -138,6 +138,7 @@ | |
#include "tier1/UtlDict.h" | |
#include "keybindinglistener.h" | |
+#include "game_timescale_shared.h" | |
// memdbgon must be the last include file in a .cpp file!!! | |
#include "tier0/memdbgon.h" | |
@@ -2364,7 +2365,16 @@ void OnRenderStart() | |
MDLCACHE_CRITICAL_SECTION(); | |
MDLCACHE_COARSE_LOCK(); | |
- | |
+ // BenLubar: rescale time in demos during slow motion | |
+ INetChannelInfo *nci = engine->GetNetChannelInfo(); | |
+ if ( nci && nci->IsPlayback() && GameTimescale()->GetCurrentTimescale() != 1 ) | |
+ { | |
+ float flServerTime = engine->GetLastTimeStamp(); | |
+ float flTimeSince = nci->GetTimeSinceLastReceived(); | |
+ float flTimeScale = GameTimescale()->GetCurrentTimescale(); | |
+ gpGlobals->curtime = flServerTime + flTimeSince * flTimeScale * flTimeScale; | |
+ gpGlobals->frametime *= flTimeScale; | |
+ } | |
partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, true ); | |
C_BaseEntity::SetAbsQueriesValid( false ); | |
diff --git a/src/game/shared/game_timescale_shared.cpp b/src/game/shared/game_timescale_shared.cpp | |
index 87e972e..ecfa0dd 100644 | |
--- a/src/game/shared/game_timescale_shared.cpp | |
+++ b/src/game/shared/game_timescale_shared.cpp | |
@@ -166,6 +166,13 @@ void CGameTimescale::UpdateTimescale( void ) | |
if ( m_flCurrentTimescale != engine->GetTimescale() ) | |
{ | |
+#ifdef CLIENT_DLL | |
+ // BenLubar: set the demo timescale to the inverse of the timescale we want so it's not applied twice | |
+ if ( engine->IsPlayingDemo() ) | |
+ { | |
+ engine->ClientCmd_Unrestricted( UTIL_VarArgs( "demo_timescale %f\n", 1.0f / m_flCurrentTimescale ) ); | |
+ } | |
+#endif | |
engine->SetTimescale( m_flCurrentTimescale ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment