Skip to content

Commit

Permalink
Improve accuracy of large export warning (#1142)
Browse files Browse the repository at this point in the history
* Improve accuracy of large export warning

The surrounding code checks for a limit of exactly 20,000 bytes and then
hardcodes the limit as being "20 kB" in the locale string. When
formatting, we were dividing by 1024 rather than 1000 and so when
breaching the limit we could end up showing values that were smaller
than 20 kB.

* We're also dividing stupidly elsewhere
  • Loading branch information
Meorawr authored Sep 7, 2024
1 parent 4b7f4ab commit 3db62be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions totalRP3/Core/Profiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,11 @@ local function onActionSelected(value, button)
local serial = Utils.serial.serialize({Globals.version, profileID, profile });
if serial:len() < 20000 then
TRP3_ProfileExport.content.scroll.text:SetText(serial);
TRP3_ProfileExport.content.title:SetText(loc.PR_EXPORT_NAME:format(profile.profileName, serial:len() / 1024));
TRP3_ProfileExport.content.title:SetText(loc.PR_EXPORT_NAME:format(profile.profileName, serial:len() / 1000));
TRP3_ProfileExport:Show();
TRP3_ProfileExport.content.scroll.text:SetFocus();
else
Utils.message.displayMessage(loc.PR_EXPORT_TOO_LARGE:format(serial:len() / 1024), 2);
Utils.message.displayMessage(loc.PR_EXPORT_TOO_LARGE:format(serial:len() / 1000), 2);
end
elseif value == PROFILEMANAGER_ACTIONS.IMPORT then
TRP3_ProfileImport.profileID = profileID;
Expand Down

0 comments on commit 3db62be

Please sign in to comment.