Skip to content

Commit dce0ee1

Browse files
PMP DefaultSettings -> ulong
1 parent 24c3051 commit dce0ee1

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

xivModdingFramework/Mods/FileTypes/PMP.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,19 @@ private static void ValidateOption(PmpStandardOptionJson op)
350350
var selected = group.DefaultSettings;
351351

352352
// If the user selected custom settings, use those.
353-
if (group.SelectedSettings >= 0)
353+
if (group.SelectedSettings.HasValue)
354354
{
355-
selected = group.SelectedSettings;
355+
selected = group.SelectedSettings.Value;
356356
}
357357

358358
if (group.Type == "Single")
359359
{
360-
if (selected < 0 || selected >= group.Options.Count)
360+
var selectedIdx = (int)selected;
361+
if (selected < 0 || selectedIdx >= group.Options.Count)
361362
{
362363
selected = 0;
363364
}
364-
var groupRes = await ImportOption(group.Options[selected], unzippedPath, tx, progress, groupIdx, optionIdx);
365+
var groupRes = await ImportOption(group.Options[selectedIdx], unzippedPath, tx, progress, groupIdx, optionIdx);
365366
UnionDict(imported, groupRes.Imported);
366367
notImported.UnionWith(groupRes.NotImported);
367368
}
@@ -373,7 +374,7 @@ private static void ValidateOption(PmpStandardOptionJson op)
373374
foreach(var op in ordered)
374375
{
375376
var i = group.Options.IndexOf(op);
376-
var value = 1 << i;
377+
var value = 1UL << i;
377378
if ((selected & value) > 0)
378379
{
379380
var groupRes = await ImportOption(group.Options[i], unzippedPath, tx, progress, groupIdx, optionIdx);
@@ -393,7 +394,7 @@ private static void ValidateOption(PmpStandardOptionJson op)
393394
// Bitmask options.
394395
for (int i = 0; i < group.Options.Count; i++)
395396
{
396-
var value = 1 << i;
397+
var value = 1UL << i;
397398
if ((selected & value) > 0)
398399
{
399400
var disableOpt = group.Options[i] as PmpDisableImcOptionJson;
@@ -1334,10 +1335,10 @@ public class PMPGroupJson
13341335
public string Type = "";
13351336

13361337
// Only used internally when the user is selecting options during install/application.
1337-
[JsonIgnore] public int SelectedSettings = -1;
1338+
[JsonIgnore] public ulong? SelectedSettings = null;
13381339

13391340
// Either single Index or Bitflag.
1340-
public int DefaultSettings;
1341+
public ulong DefaultSettings;
13411342

13421343
public List<PMPOptionJson> Options = new List<PMPOptionJson>();
13431344
}

xivModdingFramework/Mods/WizardData.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public class WizardGroupEntry
569569
internal string FolderPath;
570570

571571
// Int or Bitflag depending on OptionType.
572-
public int Selection
572+
public ulong Selection
573573
{
574574
get
575575
{
@@ -580,18 +580,17 @@ public int Selection
580580
{
581581
return 0;
582582
}
583-
return Options.IndexOf(op);
583+
return (ulong)Options.IndexOf(op);
584584
}
585585
else
586586
{
587-
var total = 0;
587+
ulong total = 0;
588588
for (int i = 0; i < Options.Count; i++)
589589
{
590590
if (Options[i].Selected)
591591
{
592-
uint mask = 1;
593-
uint shifted = mask << i;
594-
total |= (int)shifted;
592+
var bit = 1UL << i;
593+
total |= bit;
595594
}
596595
}
597596
return total;
@@ -796,11 +795,11 @@ public static async Task<WizardGroupEntry> FromPMPGroup(PMPGroupJson pGroup, str
796795

797796
if (group.OptionType == EOptionType.Single)
798797
{
799-
wizOp.Selected = pGroup.DefaultSettings == idx;
798+
wizOp.Selected = pGroup.DefaultSettings == (ulong)idx;
800799
}
801800
else
802801
{
803-
var bit = 1 << idx;
802+
var bit = 1UL << idx;
804803
wizOp.Selected = (pGroup.DefaultSettings & bit) != 0;
805804
}
806805
group.Options.Add(wizOp);

0 commit comments

Comments
 (0)