From beb19c81a3c5a3d367498d12f19f094b145926b3 Mon Sep 17 00:00:00 2001 From: Not Date: Fri, 25 Nov 2022 03:54:59 +0100 Subject: [PATCH] improve output and checking of lb_move_records command --- leaderboard.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/leaderboard.lua b/leaderboard.lua index e2a3968..e5a060f 100644 --- a/leaderboard.lua +++ b/leaderboard.lua @@ -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 )