Compare commits

..

No commits in common. "1d4eb423d627aab69e5ec485ecb2b5c252be2b72" and "2d4784f62e9c65838e8f0be4e41b70a64a90e26b" have entirely different histories.

View File

@ -272,62 +272,60 @@ local function stat_str(stat)
end end
-- Read the leaderboard -- Read the leaderboard
if isserver then local f = io.open(FILENAME, "r")
local f = io.open(FILENAME, "r") if f then
if f then for l in f:lines() do
for l in f:lines() do -- Leaderboard is stored in the following tab separated format
-- Leaderboard is stored in the following tab separated format -- mapnum, name, skin, color, time, splits, flags, stat
-- mapnum, name, skin, color, time, splits, flags, stat local t = {}
local t = {} for word in (l+"\t"):gmatch("(.-)\t") do
for word in (l+"\t"):gmatch("(.-)\t") do table.insert(t, word)
table.insert(t, word)
end
local flags = 0
if t[7] != nil then
flags = tonumber(t[7])
end
scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
local spl = {}
if t[6] != nil then
for str in t[6]:gmatch("([^ ]+)") do
table.insert(spl, tonumber(str))
end
end
local stats = nil
if t[8] != nil then
if #t[8] >= 2 then
local speed = tonumber(string.sub(t[8], 1, 1))
local weight = tonumber(string.sub(t[8], 2, 2))
stats = stat_t(speed, weight)
end
end
table.insert(
scoreTable,
score_t(
tonumber(t[1]),
t[2],
t[3],
t[4],
tonumber(t[5]),
spl,
flags,
stats
)
)
setScoreTable(tonumber(t[1]), flags, scoreTable)
end end
sortScores() local flags = 0
f:close() if t[7] != nil then
else flags = tonumber(t[7])
print("Failed to open file: ", FILENAME) end
scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
local spl = {}
if t[6] != nil then
for str in t[6]:gmatch("([^ ]+)") do
table.insert(spl, tonumber(str))
end
end
local stats = nil
if t[8] != nil then
if #t[8] >= 2 then
local speed = tonumber(string.sub(t[8], 1, 1))
local weight = tonumber(string.sub(t[8], 2, 2))
stats = stat_t(speed, weight)
end
end
table.insert(
scoreTable,
score_t(
tonumber(t[1]),
t[2],
t[3],
t[4],
tonumber(t[5]),
spl,
flags,
stats
)
)
setScoreTable(tonumber(t[1]), flags, scoreTable)
end end
sortScores()
f:close()
else
print("Failed to open file: ", FILENAME)
end end
function allowJoin(v) function allowJoin(v)
@ -1317,32 +1315,30 @@ local function saveTime(player)
StatTrack = true StatTrack = true
end end
if isserver then local f = assert(io.open(FILENAME, "w"))
local f = assert(io.open(FILENAME, "w")) if f == nil then
if f == nil then print("Failed to open file for writing: " + FILENAME)
print("Failed to open file for writing: " + FILENAME) return
return end
end
for _, tbl in pairs(lb) do for _, tbl in pairs(lb) do
for _, scoreTable in pairs(tbl) do for _, scoreTable in pairs(tbl) do
for _, score in ipairs(scoreTable) do for _, score in ipairs(scoreTable) do
f:write( f:write(
score["map"], "\t", score["map"], "\t",
score["name"], "\t", score["name"], "\t",
score["skin"], "\t", score["skin"], "\t",
score["color"], "\t", score["color"], "\t",
score["time"], "\t", score["time"], "\t",
table.concat(score["splits"], " "), "\t", table.concat(score["splits"], " "), "\t",
score["flags"], "\t", score["flags"], "\t",
stat_str(score["stat"]), "\n" stat_str(score["stat"]), "\n"
) )
end
end end
end end
f:close()
end end
f:close()
end end
-- DEBUGGING -- DEBUGGING