From 40739d9176303ff2fc8b4cf2169d5b7d1a347911 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 26 Aug 2020 07:45:14 +1000 Subject: [PATCH] - SW: Add `ogameclock` and use in places where `ototalclock` was used. * Duke used `ototalclock` only to keep track of when the game ticked. SW uses it in the rendering code for differentials between tics so we should preserve that to prevent issues down the track. --- source/sw/src/game.cpp | 3 ++- source/sw/src/game.h | 2 +- source/sw/src/jsector.cpp | 6 +++--- source/sw/src/network.cpp | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 6fedad406..800a181df 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -786,6 +786,7 @@ void GameTicker(void) while (ready2send && currentTic - lastTic >= 1) { lastTic = currentTic; + ogameclock = gameclock; UpdateInputs(); MoveTicker(); } @@ -825,7 +826,7 @@ void GameInterface::RunGameFrame() case GS_STARTUP: I_ResetTime(); lastTic = -1; - gameclock = 0; + ogameclock = gameclock = 0; if (userConfig.CommandMap.IsNotEmpty()) { diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 239b48516..9c2f423e1 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2188,7 +2188,7 @@ extern USER puser[MAX_SW_PLAYERS_REG]; /////////////////////////// extern int gotlastpacketclock; -extern int gameclock; +extern int ogameclock, gameclock; extern int lastTic; extern SWBOOL ready2send; extern double smoothratio; diff --git a/source/sw/src/jsector.cpp b/source/sw/src/jsector.cpp index e5683e195..472561d0f 100644 --- a/source/sw/src/jsector.cpp +++ b/source/sw/src/jsector.cpp @@ -300,7 +300,7 @@ void JS_InitMirrors(void) // Scan wall tags for mirrors mirrorcnt = 0; tileDelete(MIRROR); - oscilationclock = gameclock; + oscilationclock = ogameclock; for (i = 0; i < MAXMIRRORS; i++) { @@ -532,7 +532,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz) SWBOOL bIsWallMirror = FALSE; - camloopcnt += gameclock - gameclock; + camloopcnt += gameclock - ogameclock; if (camloopcnt > (60 * 5)) // 5 seconds per player view { camloopcnt = 0; @@ -545,7 +545,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz) longptr = (int*)&gotpic[MIRRORLABEL >> 3]; if (longptr && (longptr[0] || longptr[1])) { - uint32_t oscilation_delta = gameclock - oscilationclock; + uint32_t oscilation_delta = ogameclock - oscilationclock; oscilation_delta -= oscilation_delta % 4; oscilationclock += oscilation_delta; oscilation_delta *= 2; diff --git a/source/sw/src/network.cpp b/source/sw/src/network.cpp index 7ce1226ec..369784d2a 100644 --- a/source/sw/src/network.cpp +++ b/source/sw/src/network.cpp @@ -95,7 +95,7 @@ uint8_t syncstat[MAXSYNCBYTES]; int syncvaltail, syncvaltottail; void GetSyncInfoFromPacket(uint8_t *packbuf, int packbufleng, int *j, int otherconnectindex); -int gameclock; +int ogameclock, gameclock; int lastTic; double smoothratio; @@ -167,7 +167,7 @@ InitTimingVars(void) totalsynctics = 0; I_ResetTime(); lastTic = -1; - gameclock = 0; + ogameclock = gameclock = 0; randomseed = 17L; MoveSkip8 = 2;