Skip to content

Commit

Permalink
Loadingscreen: Fixed Disabling (#1643)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TimGoll authored Sep 29, 2024
1 parent 9d1fd6d commit e4085dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gamemodes/terrortown/gamemode/client/vgui/cl_sb_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions lua/ttt2/libraries/loadingscreen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion lua/ttt2/libraries/tips.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e4085dd

Please sign in to comment.