@@ -14,29 +14,29 @@ ImportExportUtil.bitWidthSpecID = 16;
1414ImportExportUtil .bitWidthRanksPurchased = 6 ;
1515
1616local 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 ();
4040end
4141
4242function ImportExportUtil :GetLoadoutExportString (talentsTab , configIDOverride )
0 commit comments