Compare commits
9 Commits
57120e257a
...
v1.3.0
Author | SHA1 | Date | |
---|---|---|---|
051b0adb4e | |||
beb19c81a3 | |||
00de269bb3 | |||
3c5234f7b2 | |||
d4bbf62945 | |||
36204b579f | |||
9d50705d9a | |||
935d119e4d | |||
172b9d3633 |
38
lb_store.lua
38
lb_store.lua
@ -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)
|
||||
|
||||
@ -353,17 +348,14 @@ COM_AddCommand("lb_write_checksums", function(player)
|
||||
end, COM_ADMIN)
|
||||
|
||||
COM_AddCommand("lb_known_maps", function(player, map)
|
||||
if not map then
|
||||
CONS_Printf(player, "Usage: <map>")
|
||||
CONS_Printf(player, "Print all known checksums under <map>")
|
||||
return
|
||||
end
|
||||
|
||||
local mapnum = mapnumFromExtended(map)
|
||||
local mapnum = gamemap
|
||||
if map then
|
||||
mapnum = mapnumFromExtended(map)
|
||||
if not mapnum then
|
||||
CONS_Printf(player, string.format("invalid map '%s'", map))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local known = {}
|
||||
|
||||
@ -380,10 +372,22 @@ COM_AddCommand("lb_known_maps", function(player, map)
|
||||
|
||||
CONS_Printf(player, "Map Chck Records")
|
||||
for checksum, count in pairs(known) do
|
||||
CONS_Printf(player, string.format("%s %s %d", map, checksum, count))
|
||||
CONS_Printf(player, string.format("%s %s %d", G_BuildMapName(mapnum), checksum, count))
|
||||
end
|
||||
end)
|
||||
|
||||
COM_AddCommand("lb_download_live_records", function(player, filename)
|
||||
if not filename then
|
||||
CONS_Printf(player, "Usage: lb_download_live_records <filename>")
|
||||
return
|
||||
end
|
||||
|
||||
if filename:sub(#filename-3) != ".txt" then
|
||||
filename = $..".txt"
|
||||
end
|
||||
dumpStoreToFile(filename, LiveStore)
|
||||
end, COM_LOCAL)
|
||||
|
||||
-- Load the livestore
|
||||
if isserver then
|
||||
LiveStore = loadStoreFile(LEADERBOARD_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
|
||||
)
|
||||
@ -686,7 +700,7 @@ local function moveRecords(player, from_map, from_checksum, to_map, to_checksum)
|
||||
|
||||
CONS_Printf(player, "Please repack coldstore and restart the server for changes to take effect.")
|
||||
end
|
||||
COM_AddCommand("lb_move_records", moveRecords)
|
||||
COM_AddCommand("lb_move_records", moveRecords, COM_ADMIN)
|
||||
|
||||
--DEBUGGING
|
||||
--local function printTable(tb)
|
||||
@ -1197,12 +1211,12 @@ local function saveTime(player)
|
||||
end
|
||||
|
||||
-- DEBUGGING
|
||||
local function saveLeaderboard(player, ...)
|
||||
TimeFinished = tonumber(... or player.realtime)
|
||||
splits = {1000, 2000, 3000}
|
||||
saveTime(player)
|
||||
end
|
||||
COM_AddCommand("save", saveLeaderboard)
|
||||
--local function saveLeaderboard(player, ...)
|
||||
-- TimeFinished = tonumber(... or player.realtime)
|
||||
-- splits = {1000, 2000, 3000}
|
||||
-- saveTime(player)
|
||||
--end
|
||||
--COM_AddCommand("save", saveLeaderboard)
|
||||
|
||||
local function regLap(player)
|
||||
if player.laps > prevLap and TimeFinished == 0 then
|
||||
|
@ -1,14 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from os import linesep
|
||||
from os import linesep, path
|
||||
|
||||
if len(sys.argv) != 4 or not sys.argv[1] or not sys.argv[2] or not sys.argv[3]:
|
||||
print("Usage: coldstore.py <leaderboard.txt> <coldstore.txt> <leaderboard_records.lua>")
|
||||
if len(sys.argv) != 3 or not sys.argv[1] or not sys.argv[2]:
|
||||
print("Usage: coldstore.py <game_directory> <leaderboard_records.lua>")
|
||||
print("\t<game_directory>\t\tthe game directory where wads and luafiles reside. Usually at '$HOME/.srb2kart'.")
|
||||
print("\t<leaderboard_records.lua>\tthe output name for the records packed lua file. It will be saved within <game_directory>.")
|
||||
quit()
|
||||
|
||||
leaderboard_txt = sys.argv[1]
|
||||
coldstore_txt = sys.argv[2]
|
||||
records_lua = sys.argv[3]
|
||||
if not sys.argv[2].endswith(".lua"):
|
||||
print("{} must end with .lua".format(sys.argv[2]))
|
||||
quit()
|
||||
|
||||
game_dir = sys.argv[1]
|
||||
leaderboard_txt = path.join(game_dir, "luafiles", "leaderboard.txt")
|
||||
coldstore_txt = path.join(game_dir, "luafiles", "leaderboard.coldstore.txt")
|
||||
records_lua = path.join(game_dir, sys.argv[2])
|
||||
|
||||
def ParseScore(score):
|
||||
# Map Name Skin Color Time Splits Flags Stat
|
||||
|
Reference in New Issue
Block a user