From 612ef8358cbaaf5d016627cf2ffde47376aad43f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 15 Dec 2022 17:59:46 +0100 Subject: [PATCH 1/2] Add separate `ed_limit_max_zoom_level` for editor To completely separate zoom settings between ingame and editor. --- src/game/editor/editor.cpp | 2 +- src/game/variables.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 483bcec1d..cca699f32 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -6154,7 +6154,7 @@ float CEditor::MinZoomLevel() const float CEditor::MaxZoomLevel() const { - return g_Config.m_ClLimitMaxZoomLevel ? 2000.0f : std::numeric_limits::max(); + return g_Config.m_EdLimitMaxZoomLevel ? 2000.0f : std::numeric_limits::max(); } float CEditor::ZoomProgress(float CurrentTime) const diff --git a/src/game/variables.h b/src/game/variables.h index 98ef5ea72..0513df5d8 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -91,6 +91,7 @@ MACRO_CONFIG_INT(ClDyncamSmoothness, cl_dyncam_smoothness, 0, 0, 100, CFGFLAG_CL MACRO_CONFIG_INT(ClDyncamStabilizing, cl_dyncam_stabilizing, 0, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Amount of camera slowdown during fast cursor movement. High value can cause delay in camera movement") MACRO_CONFIG_INT(EdSmoothZoomTime, ed_smooth_zoom_time, 250, 0, 5000, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Time of smooth zoom animation in the editor in ms (0 for off)") +MACRO_CONFIG_INT(EdLimitMaxZoomLevel, ed_limit_max_zoom_level, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Specifies, if zooming in the editor should be limited or not (0 = no limit)") MACRO_CONFIG_INT(EdZoomTarget, ed_zoom_target, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Zoom to the current mouse target") MACRO_CONFIG_INT(EdShowkeys, ed_showkeys, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "") @@ -114,7 +115,7 @@ MACRO_CONFIG_INT(ClAutoStatboardScreenshotMax, cl_auto_statboard_screenshot_max, MACRO_CONFIG_INT(ClDefaultZoom, cl_default_zoom, 10, 0, 20, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Default zoom level") MACRO_CONFIG_INT(ClSmoothZoomTime, cl_smooth_zoom_time, 250, 0, 5000, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Time of smooth zoom animation ingame in ms (0 for off)") -MACRO_CONFIG_INT(ClLimitMaxZoomLevel, cl_limit_max_zoom_level, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Specifies, if zooming should be limited or not (0 = no limit)") +MACRO_CONFIG_INT(ClLimitMaxZoomLevel, cl_limit_max_zoom_level, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Specifies, if zooming ingame should be limited or not (0 = no limit)") MACRO_CONFIG_INT(ClPlayerUseCustomColor, player_use_custom_color, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Toggles usage of custom colors") MACRO_CONFIG_COL(ClPlayerColorBody, player_color_body, 65408, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Player body color") From a0553f2d4019d647c7e07dd73a03283b233254a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 15 Dec 2022 18:18:06 +0100 Subject: [PATCH 2/2] Fix editor smooth zooming when joining/reloading game Using `IClient::LocalTime` for smooth zooming in the editor causes the zoom to behave incorrectly when joining a game, as the local time is reset when joining a game. This is fixed by adding a separate `IClient::GlobalTime` which is only set once when the client launches and never resets. --- src/engine/client.h | 2 ++ src/engine/client/client.cpp | 5 +++-- src/engine/client/client.h | 1 + src/game/editor/editor.cpp | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/client.h b/src/engine/client.h index fb0186a93..b883a50c7 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -84,6 +84,7 @@ protected: float m_aPredIntraTick[NUM_DUMMIES]; float m_LocalTime; + float m_GlobalTime; float m_RenderFrameTime; int m_GameTickSpeed; @@ -146,6 +147,7 @@ public: // other time access inline float RenderFrameTime() const { return m_RenderFrameTime; } inline float LocalTime() const { return m_LocalTime; } + inline float GlobalTime() const { return m_GlobalTime; } inline float FrameTimeAvg() const { return m_FrameTimeAvg; } // actions diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 1c54336a5..9ce7ccfd9 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -2964,7 +2964,7 @@ void CClient::InitInterfaces() void CClient::Run() { - m_LocalStartTime = time_get(); + m_LocalStartTime = m_GlobalStartTime = time_get(); #if defined(CONF_VIDEORECORDER) IVideo::SetLocalStartTime(m_LocalStartTime); #endif @@ -3383,8 +3383,9 @@ void CClient::Run() g_Config.m_DbgHitch = 0; } - // update local time + // update local and global time m_LocalTime = (time_get() - m_LocalStartTime) / (float)time_freq(); + m_GlobalTime = (time_get() - m_GlobalStartTime) / (float)time_freq(); } #if defined(CONF_FAMILY_UNIX) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 0f5159638..8143e5352 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -143,6 +143,7 @@ class CClient : public IClient, public CDemoPlayer::IListener uint64_t m_aSnapshotParts[NUM_DUMMIES]; int64_t m_LocalStartTime; + int64_t m_GlobalStartTime; IGraphics::CTextureHandle m_DebugFont; int m_DebugSoundIndex = 0; diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index cca699f32..92032ac41 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -6080,7 +6080,7 @@ void CEditor::SetZoom(float Target) { Target = clamp(Target, MinZoomLevel(), MaxZoomLevel()); - const float Now = Client()->LocalTime(); + const float Now = Client()->GlobalTime(); float Current = m_Zoom; float Derivative = 0.0f; if(m_Zooming) @@ -6128,7 +6128,7 @@ void CEditor::UpdateZoom() { if(m_Zooming) { - const float Time = Client()->LocalTime(); + const float Time = Client()->GlobalTime(); const float OldLevel = m_Zoom; if(Time >= m_ZoomSmoothingEnd) {