From e4085dd56ef6c70a48757470f990ab2476aec266 Mon Sep 17 00:00:00 2001 From: Tim Goll Date: Sun, 29 Sep 2024 18:13:17 +0200 Subject: [PATCH] Loadingscreen: Fixed Disabling (#1643) Fixes #1622 Fixes disabling of the loadingscreen breaking the game. Also I fixed the loading screen displaying one fewer rounds than are actually left because the game counts to 0 and it makes no real sense that in the last round are 0 rounds left. I also made sure that the prepare time is set to the correct value if the loading screen is disabled. --- CHANGELOG.md | 2 ++ .../terrortown/gamemode/client/vgui/cl_sb_main.lua | 2 +- lua/ttt2/libraries/loadingscreen.lua | 12 +++++++++--- lua/ttt2/libraries/tips.lua | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3fec9dd7..ec834e735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel - Fixed missing translation for None role error by removing it (by @mexikoedi) - Fixed sometimes entity use triggering the wrong or no entity (by @TimGoll) - Fixed translation of muting Terrorists and Spectators (by @mexikoedi) +- Fixed the loadingscreen disable causing an error (by @TimGoll) +- Fixed the rounds left always displaying one less than actually left (by @TimGoll) - Fixed rendering glitches in the loading screen (by @TimGoll) ### Changed diff --git a/gamemodes/terrortown/gamemode/client/vgui/cl_sb_main.lua b/gamemodes/terrortown/gamemode/client/vgui/cl_sb_main.lua index ef9bccf0c..c53557289 100644 --- a/gamemodes/terrortown/gamemode/client/vgui/cl_sb_main.lua +++ b/gamemodes/terrortown/gamemode/client/vgui/cl_sb_main.lua @@ -169,7 +169,7 @@ function PANEL:Init() if gameloop.HasLevelLimits() then local r, t = gameloop.UntilMapChange() - sf:SetText(GetPTranslation("sb_mapchange", { num = r, time = t })) + sf:SetText(GetPTranslation("sb_mapchange", { num = r + 1, time = t })) else sf:SetText(GetTranslation("sb_mapchange_disabled")) end diff --git a/lua/ttt2/libraries/loadingscreen.lua b/lua/ttt2/libraries/loadingscreen.lua index 19e63dd6a..c0aa286f8 100644 --- a/lua/ttt2/libraries/loadingscreen.lua +++ b/lua/ttt2/libraries/loadingscreen.lua @@ -70,7 +70,9 @@ function loadingscreen.End() end if SERVER then - local duration = loadingscreen.timeBegin - SysTime() + loadingscreen.GetDuration() + local duration = (loadingscreen.timeBegin or SysTime()) + - SysTime() + + loadingscreen.GetDuration() -- this timer makes sure the loading screen is displayed for at least the -- time that is set as the minimum time @@ -103,7 +105,11 @@ if SERVER then -- @return number The minimum time -- @realm server function loadingscreen.GetDuration() - return cvLoadingScreenMinDuration:GetFloat() + if cvLoadingScreenEnabled:GetBool() then + return cvLoadingScreenMinDuration:GetFloat() + else + return 0 + end end end @@ -229,7 +235,7 @@ if CLIENT then text = LANG.GetParamTranslation( "loadingscreen_round_restart_subtitle_limits", - { map = game.GetMap(), rounds = roundsLeft, time = timeLeft } + { map = game.GetMap(), rounds = roundsLeft + 1, time = timeLeft } ) else text = LANG.TryTranslation("loadingscreen_round_restart_subtitle") diff --git a/lua/ttt2/libraries/tips.lua b/lua/ttt2/libraries/tips.lua index 8158885bb..e639d5ba9 100644 --- a/lua/ttt2/libraries/tips.lua +++ b/lua/ttt2/libraries/tips.lua @@ -72,7 +72,7 @@ function tips.Initialize() tips.Register("tip31") tips.Register("tip32") tips.Register("tip33") - tips.Register("tip34", { helpkey = Key("+gm_showhelp", "F1") }) + tips.Register("tip34") tips.Register("tip35") tips.Register("tip36") tips.Register("tip37")