Skip to content

Commit f100ed3

Browse files
committed
Minor code cleanup
1 parent 09a3612 commit f100ed3

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

ImportExportUtilV2.lua

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ ImportExportUtil.bitWidthSpecID = 16;
1414
ImportExportUtil.bitWidthRanksPurchased = 6;
1515

1616
local function fixLoadoutString(loadoutString, specID)
17-
local exportStream = ExportUtil.MakeExportDataStream();
18-
local importStream = ExportUtil.MakeImportDataStream(loadoutString);
19-
20-
if importStream:ExtractValue(ImportExportUtil.bitWidthHeaderVersion) ~= LOADOUT_SERIALIZATION_VERSION then
21-
return nil; -- only version 2 is supported
22-
end
23-
24-
local headerSpecID = importStream:ExtractValue(ImportExportUtil.bitWidthSpecID);
25-
if headerSpecID == specID then
26-
return loadoutString; -- no update needed
27-
end
28-
29-
exportStream:AddValue(ImportExportUtil.bitWidthHeaderVersion, LOADOUT_SERIALIZATION_VERSION);
30-
exportStream:AddValue(ImportExportUtil.bitWidthSpecID, specID);
31-
local remainingBits = importStream:GetNumberOfBits() - ImportExportUtil.bitWidthHeaderVersion - ImportExportUtil.bitWidthSpecID;
32-
-- copy the remaining bits in batches of 16
33-
while remainingBits > 0 do
34-
local bitsToCopy = math.min(remainingBits, 16);
35-
exportStream:AddValue(bitsToCopy, importStream:ExtractValue(bitsToCopy));
36-
remainingBits = remainingBits - bitsToCopy;
37-
end
38-
39-
return exportStream:GetExportString();
17+
local exportStream = ExportUtil.MakeExportDataStream();
18+
local importStream = ExportUtil.MakeImportDataStream(loadoutString);
19+
20+
if importStream:ExtractValue(ImportExportUtil.bitWidthHeaderVersion) ~= LOADOUT_SERIALIZATION_VERSION then
21+
return nil; -- only version 2 is supported
22+
end
23+
24+
local headerSpecID = importStream:ExtractValue(ImportExportUtil.bitWidthSpecID);
25+
if headerSpecID == specID then
26+
return loadoutString; -- no update needed
27+
end
28+
29+
exportStream:AddValue(ImportExportUtil.bitWidthHeaderVersion, LOADOUT_SERIALIZATION_VERSION);
30+
exportStream:AddValue(ImportExportUtil.bitWidthSpecID, specID);
31+
local remainingBits = importStream:GetNumberOfBits() - ImportExportUtil.bitWidthHeaderVersion - ImportExportUtil.bitWidthSpecID;
32+
-- copy the remaining bits in batches of 16
33+
while remainingBits > 0 do
34+
local bitsToCopy = math.min(remainingBits, 16);
35+
exportStream:AddValue(bitsToCopy, importStream:ExtractValue(bitsToCopy));
36+
remainingBits = remainingBits - bitsToCopy;
37+
end
38+
39+
return exportStream:GetExportString();
4040
end
4141

4242
function ImportExportUtil:GetLoadoutExportString(talentsTab, configIDOverride)

0 commit comments

Comments
 (0)