Compare commits
No commits in common. "beb19c81a3c5a3d367498d12f19f094b145926b3" and "d4bbf6294528b8a536d352de1ce1e4184a6ef90d" have entirely different histories.
beb19c81a3
...
d4bbf62945
15
lb_store.lua
15
lb_store.lua
@ -241,7 +241,7 @@ function parseScore(str)
|
|||||||
splits,
|
splits,
|
||||||
flags,
|
flags,
|
||||||
stats,
|
stats,
|
||||||
checksum:lower()
|
checksum
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
rawset(_G, "lb_parse_score", parseScore)
|
rawset(_G, "lb_parse_score", parseScore)
|
||||||
@ -275,6 +275,8 @@ local function moveRecords(from, to, modeSep)
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local moveCount = #store[from.id][from.checksum]
|
||||||
|
|
||||||
store[to.id] = $ or {}
|
store[to.id] = $ or {}
|
||||||
store[to.id][to.checksum] = $ or {}
|
store[to.id][to.checksum] = $ or {}
|
||||||
for i, score in ipairs(store[from.id][from.checksum]) do
|
for i, score in ipairs(store[from.id][from.checksum]) do
|
||||||
@ -285,21 +287,24 @@ local function moveRecords(from, to, modeSep)
|
|||||||
|
|
||||||
-- Destroy the original table
|
-- Destroy the original table
|
||||||
store[from.id][from.checksum] = nil
|
store[from.id][from.checksum] = nil
|
||||||
|
|
||||||
|
return moveCount
|
||||||
end
|
end
|
||||||
|
|
||||||
-- move livestore records and write to disk
|
-- move livestore records and write to disk
|
||||||
moveRecordsInStore(LiveStore)
|
local moveCount = moveRecordsInStore(LiveStore)
|
||||||
|
dumpStoreToFile(LEADERBOARD_FILE, LiveStore)
|
||||||
|
|
||||||
|
-- move coldstore records
|
||||||
if isserver then
|
if isserver then
|
||||||
dumpStoreToFile(LEADERBOARD_FILE, LiveStore)
|
|
||||||
|
|
||||||
-- move coldstore records
|
|
||||||
local ok, coldstore = pcall(loadStoreFile, COLDSTORE_FILE)
|
local ok, coldstore = pcall(loadStoreFile, COLDSTORE_FILE)
|
||||||
if ok and coldstore then
|
if ok and coldstore then
|
||||||
moveRecordsInStore(coldstore)
|
moveRecordsInStore(coldstore)
|
||||||
dumpStoreToFile(COLDSTORE_FILE, coldstore)
|
dumpStoreToFile(COLDSTORE_FILE, coldstore)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return moveCount
|
||||||
end
|
end
|
||||||
rawset(_G, "lb_move_records", moveRecords)
|
rawset(_G, "lb_move_records", moveRecords)
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ local function moveRecords(player, from_map, from_checksum, to_map, to_checksum)
|
|||||||
|
|
||||||
local from = {
|
local from = {
|
||||||
["id"] = mapnumFromExtended(from_map),
|
["id"] = mapnumFromExtended(from_map),
|
||||||
["checksum"] = from_checksum:lower()
|
["checksum"] = from_checksum
|
||||||
}
|
}
|
||||||
|
|
||||||
local to = {
|
local to = {
|
||||||
@ -670,29 +670,15 @@ local function moveRecords(player, from_map, from_checksum, to_map, to_checksum)
|
|||||||
to.checksum = to_checksum or mapChecksum(to.id)
|
to.checksum = to_checksum or mapChecksum(to.id)
|
||||||
|
|
||||||
if not to.checksum then
|
if not to.checksum then
|
||||||
CONS_Printf(player, string.format("error: %s is not loaded; provide to_checksum to continue", to_map:upper()))
|
CONS_Printf(player, string.format("error: '%s' is missing; provide to_checksum to continue", to.id))
|
||||||
return
|
return
|
||||||
end
|
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(
|
CONS_Printf(
|
||||||
player,
|
player,
|
||||||
string.format(
|
string.format(
|
||||||
"%d records have been moved from\x82 %s %s\x80 to\x88 %s %s",
|
"%d records have been moved from %s %s to %s %s",
|
||||||
recordCount,
|
MoveRecords(from, to, ST_SEP),
|
||||||
from_map, from.checksum,
|
from_map, from.checksum,
|
||||||
to_map, to.checksum
|
to_map, to.checksum
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user