From 2bf368d49b209038f868b42599e0981f8e7509fb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 31 Aug 2020 19:18:53 +0200 Subject: [PATCH] - redid the timer for the automap zoom Add more precision and uncouple from the game timer --- source/core/mainloop.cpp | 1 + source/games/duke/src/gameloop.cpp | 2 +- source/games/duke/src/input.cpp | 33 +++++++++++++++--------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 99904df63..d078c7165 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -242,6 +242,7 @@ void Display() case GS_LEVEL: if (gametic != 0) { + screen->FrameTime = I_msTimeFS(); screen->BeginFrame(); screen->SetSceneRenderTarget(gl_ssao != 0); twodpsp.Clear(); diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index 922e9b459..76358f50a 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -107,7 +107,6 @@ void GameInterface::Ticker() { exitlevel(); } - nonsharedkeys(); // this must go elsewhere later! } //--------------------------------------------------------------------------- @@ -164,6 +163,7 @@ void GameInterface::Startup() void GameInterface::Render() { + nonsharedkeys(); // automap zoom drawtime.Reset(); drawtime.Clock(); videoSetBrightness(thunder_brightness); diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 5f6e94d81..15a9bc63c 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -36,6 +36,7 @@ source as it is released. #include "ns.h" #include "global.h" #include "gamecontrol.h" +#include "v_video.h" BEGIN_DUKE_NS @@ -59,34 +60,35 @@ void GameInterface::ResetFollowPos(bool message) } //--------------------------------------------------------------------------- // -// handles UI side input not handled via CCMDs or CVARs. -// Most of what's in here needs to be offloaded to CCMDs +// // //--------------------------------------------------------------------------- void nonsharedkeys(void) { + int ms = screen->FrameTime; + int interval; + if (nonsharedtimer > 0 || ms < nonsharedtimer) + { + interval = ms - nonsharedtimer; + } + else + { + interval = 0; + } + nonsharedtimer = screen->FrameTime; + if (System_WantGuiCapture()) return; if (automapMode != am_off) { - int j; - if (nonsharedtimer > 0 || gameclock < nonsharedtimer) - { - j = gameclock - nonsharedtimer; - nonsharedtimer += j; - } - else - { - j = 0; - nonsharedtimer = gameclock; - } + double j = interval * (120./1000); if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) - ps[myconnectindex].zoom += mulscale6(j, max(ps[myconnectindex].zoom, 256)); + ps[myconnectindex].zoom += (int)fmulscale6(j, max(ps[myconnectindex].zoom, 256)); if (buttonMap.ButtonDown(gamefunc_Shrink_Screen)) - ps[myconnectindex].zoom -= mulscale6(j, max(ps[myconnectindex].zoom, 256)); + ps[myconnectindex].zoom -= (int)fmulscale6(j, max(ps[myconnectindex].zoom, 256)); ps[myconnectindex].zoom = clamp(ps[myconnectindex].zoom, 48, 2048); } @@ -1127,7 +1129,6 @@ void GameInterface::GetInput(InputPacket* packet) void GameInterface::clearlocalinputstate() { loc = {}; - nonsharedtimer = 0; turnheldtime = 0; lastcontroltime = 0; lastCheck = 0;