From 23a8373230f3fb8d543dd5f1ae0af99294eeff08 Mon Sep 17 00:00:00 2001 From: Lonsfor Date: Sat, 30 Apr 2022 23:11:52 +0200 Subject: [PATCH] only look for scoreTable once --- leaderboard.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/leaderboard.lua b/leaderboard.lua index 4a9321e..8a66357 100644 --- a/leaderboard.lua +++ b/leaderboard.lua @@ -13,6 +13,7 @@ local PATCH = nil local help = true local EncoreInitial = nil local cv_teamchange +local scoreTable -- Tracks if stats have been written or not local StatTrack = false @@ -240,7 +241,7 @@ if f then flags = tonumber(t[7]) end - local scoreTable = getScoreTable(tonumber(t[1]), flags) or {} + scoreTable = getScoreTable(tonumber(t[1]), flags) or {} local spl = {} if t[6] != nil then @@ -961,8 +962,6 @@ local function drawScoreboard(v, player) if player != displayplayers[0] then return end cachePatches(v) - - local scoreTable = getScoreTable(gamemap, Flags) local gui = cv_gui.value if leveltime < START_TIME or player.exiting or player.lives == 0 then @@ -1010,7 +1009,7 @@ end -- Find location of player and scroll to it function scroll_to(player) - local m = getScoreTable(gamemap, Flags) or {} + local m = scoreTable or {} scrollToPos = 2 for pos, score in ipairs(m) do @@ -1039,7 +1038,8 @@ local function writeStats() end local function saveTime(player) - local scoreTable = getScoreTable(gamemap, Flags) or {} + + scoreTable = $ or {} local pskin = skins[player.mo.skin] local newscore = score_t( @@ -1242,6 +1242,8 @@ local function think() end end + scoreTable = getScoreTable(gamemap, Flags) + if not cv_teamchange then cv_teamchange = CV_FindVar("allowteamchange") end