7 Commits

3 changed files with 41 additions and 25 deletions

View File

@ -241,7 +241,7 @@ function parseScore(str)
splits,
flags,
stats,
checksum
checksum:lower()
)
end
rawset(_G, "lb_parse_score", parseScore)
@ -275,8 +275,6 @@ local function moveRecords(from, to, modeSep)
return 0
end
local moveCount = #store[from.id][from.checksum]
store[to.id] = $ or {}
store[to.id][to.checksum] = $ or {}
for i, score in ipairs(store[from.id][from.checksum]) do
@ -287,24 +285,21 @@ local function moveRecords(from, to, modeSep)
-- Destroy the original table
store[from.id][from.checksum] = nil
return moveCount
end
-- move livestore records and write to disk
local moveCount = moveRecordsInStore(LiveStore)
moveRecordsInStore(LiveStore)
if isserver then
dumpStoreToFile(LEADERBOARD_FILE, LiveStore)
-- move coldstore records
if isserver then
local ok, coldstore = pcall(loadStoreFile, COLDSTORE_FILE)
if ok and coldstore then
moveRecordsInStore(coldstore)
dumpStoreToFile(COLDSTORE_FILE, coldstore)
end
end
return moveCount
end
rawset(_G, "lb_move_records", moveRecords)

View File

@ -661,7 +661,7 @@ local function moveRecords(player, from_map, from_checksum, to_map, to_checksum)
local from = {
["id"] = mapnumFromExtended(from_map),
["checksum"] = from_checksum
["checksum"] = from_checksum:lower()
}
local to = {
@ -670,15 +670,29 @@ local function moveRecords(player, from_map, from_checksum, to_map, to_checksum)
to.checksum = to_checksum or mapChecksum(to.id)
if not to.checksum then
CONS_Printf(player, string.format("error: '%s' is missing; provide to_checksum to continue", to.id))
CONS_Printf(player, string.format("error: %s is not loaded; provide to_checksum to continue", to_map:upper()))
return
end
if #to.checksum != 4 or to.checksum:match("[^a-f0-9]") then
CONS_Printf(player, string.format("error: %s is an invalid checksum; checksums are of length 4 and can contain only 0-9a-f", to.checksum))
return
end
to.checksum = $:lower()
local mapRecords = GetMapRecords(from.id, from.checksum, F_SPBATK | F_SPBBIG | F_SPBEXP)
local recordCount = 0
for mode, records in pairs(mapRecords) do
recordCount = $ + #records
end
MoveRecords(from, to, ST_SEP)
CONS_Printf(
player,
string.format(
"%d records have been moved from %s %s to %s %s",
MoveRecords(from, to, ST_SEP),
"%d records have been moved from\x82 %s %s\x80 to\x88 %s %s",
recordCount,
from_map, from.checksum,
to_map, to.checksum
)
@ -1032,7 +1046,7 @@ local function drawScoreboard(v, player)
cachePatches(v)
local gui = cv_gui.value
local gui = cv_gui.value or drawState == DS_BROWSER
-- Force enable gui at start and end of the race
if leveltime < START_TIME or player.exiting or player.lives == 0 then
@ -1041,7 +1055,6 @@ local function drawScoreboard(v, player)
if gui then
stateFunctions[drawState](v, player, ScoreTable, gui)
end
local pos = 0
-- Draw current active modes bottom left
@ -1049,6 +1062,7 @@ local function drawScoreboard(v, player)
pos = drawMode(v, pos, F_SPBBIG)
pos = drawMode(v, pos, F_SPBEXP)
end
end
hud.add(drawScoreboard, "game")
function cachePatches(v)

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import sys
from os import linesep, path
from os import path
linesep = "\n"
if len(sys.argv) != 3 or not sys.argv[1] or not sys.argv[2]:
print("Usage: coldstore.py <game_directory> <leaderboard_records.lua>")
@ -47,9 +48,15 @@ def SameScore(a, b):
def LoadRecordsFromFile(path):
records = []
try:
with open(path, "r") as f:
for line in f.readlines():
records.append(ParseScore(line.strip()))
line = line.strip()
if line != "":
records.append(ParseScore(line))
except FileNotFoundError:
pass
return records
def AddScore(records, score):