mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
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.
This commit is contained in:
parent
612ef8358c
commit
a0553f2d40
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue