deserialize splits when needed
This commit is contained in:
parent
2d4784f62e
commit
0b2eb9e61d
@ -271,6 +271,18 @@ local function stat_str(stat)
|
|||||||
return "0"
|
return "0"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function splits_from_str(splitstr)
|
||||||
|
local spl = {}
|
||||||
|
for str in splitstr:gmatch("([^ ]+)") do
|
||||||
|
table.insert(spl, tonumber(str))
|
||||||
|
end
|
||||||
|
return spl
|
||||||
|
end
|
||||||
|
|
||||||
|
local function splits_to_str(splits)
|
||||||
|
return table.concat(splits, " ")
|
||||||
|
end
|
||||||
|
|
||||||
-- Read the leaderboard
|
-- Read the leaderboard
|
||||||
local f = io.open(FILENAME, "r")
|
local f = io.open(FILENAME, "r")
|
||||||
if f then
|
if f then
|
||||||
@ -289,12 +301,7 @@ if f then
|
|||||||
|
|
||||||
scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
|
scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
|
||||||
|
|
||||||
local spl = {}
|
local spl = t[6] or ""
|
||||||
if t[6] != nil then
|
|
||||||
for str in t[6]:gmatch("([^ ]+)") do
|
|
||||||
table.insert(spl, tonumber(str))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local stats = nil
|
local stats = nil
|
||||||
if t[8] != nil then
|
if t[8] != nil then
|
||||||
@ -1028,8 +1035,9 @@ local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, te
|
|||||||
)
|
)
|
||||||
|
|
||||||
-- Draw splits
|
-- Draw splits
|
||||||
if showSplit and score["splits"] and score["splits"][prevLap] != nil then
|
local splts = splits_from_str(score["splits"])
|
||||||
local split = splits[prevLap] - score["splits"][prevLap]
|
if showSplit and splts and splts[prevLap] != nil then
|
||||||
|
local split = splits[prevLap] - splts[prevLap]
|
||||||
v.drawString(
|
v.drawString(
|
||||||
x + px + FACERANK_DIM,
|
x + px + FACERANK_DIM,
|
||||||
y + 8,
|
y + 8,
|
||||||
@ -1268,7 +1276,7 @@ local function saveTime(player)
|
|||||||
player.mo.skin,
|
player.mo.skin,
|
||||||
player.skincolor,
|
player.skincolor,
|
||||||
timeFinished,
|
timeFinished,
|
||||||
splits,
|
splits_to_str(splits),
|
||||||
Flags,
|
Flags,
|
||||||
stat_t(player.HMRs or pskin.kartspeed, player.HMRw or pskin.kartweight)
|
stat_t(player.HMRs or pskin.kartspeed, player.HMRw or pskin.kartweight)
|
||||||
)
|
)
|
||||||
@ -1330,7 +1338,7 @@ local function saveTime(player)
|
|||||||
score["skin"], "\t",
|
score["skin"], "\t",
|
||||||
score["color"], "\t",
|
score["color"], "\t",
|
||||||
score["time"], "\t",
|
score["time"], "\t",
|
||||||
table.concat(score["splits"], " "), "\t",
|
score["splits"], "\t",
|
||||||
score["flags"], "\t",
|
score["flags"], "\t",
|
||||||
stat_str(score["stat"]), "\n"
|
stat_str(score["stat"]), "\n"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user