Mmove local cv_teamchange to the top scope

No need to constantly look up the cvar when it can be saved
This commit is contained in:
Lonsfor 2022-04-30 20:52:42 +02:00
parent 5cecda05f1
commit de63c4b2be

View File

@ -12,6 +12,7 @@ local splits = {}
local PATCH = nil local PATCH = nil
local help = true local help = true
local EncoreInitial = nil local EncoreInitial = nil
local cv_teamchange
-- Tracks if stats have been written or not -- Tracks if stats have been written or not
local StatTrack = false local StatTrack = false
@ -1239,7 +1240,10 @@ local function think()
end end
end end
local cv_teamchange = CV_FindVar("allowteamchange") if not cv_teamchange then
cv_teamchange = CV_FindVar("allowteamchange")
end
if p then if p then
-- Scroll controller -- Scroll controller
-- Spectators can't input buttons so let the gamer do it -- Spectators can't input buttons so let the gamer do it
@ -1290,7 +1294,12 @@ local function interThink()
COM_BufInsertText(server, "map " + nextMap) COM_BufInsertText(server, "map " + nextMap)
nextMap = nil nextMap = nil
end end
if not CV_FindVar("allowteamchange").value then
if not cv_teamchange then
cv_teamchange = CV_FindVar("allowteamchange")
end
if not cv_teamchange.value then
allowJoin(true) allowJoin(true)
end end
end end