Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions Source/Net7ClientManager/Services/GamePilotSettingsCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public static IReadOnlyList<GamePilotSettingsFile> Load(
var archiveNames = clientManager.PilotArchive
.GetPilots()
.GroupBy(
pilot => BinaryPrimitives.ReverseEndianness(
pilot.CharacterId))
pilot => ToOptionsFileIdentity(
BinaryPrimitives.ReverseEndianness(
pilot.CharacterId)))
.ToDictionary(
group => group.Key,
group => group.First().Name);
Expand Down Expand Up @@ -99,7 +100,8 @@ public static IReadOnlySet<uint> ResolveOnlineIdentities(

if (snapshot.Shortcuts.ShortcutIdentity is > 0 and <= uint.MaxValue)
{
result.Add((uint)snapshot.Shortcuts.ShortcutIdentity.Value);
result.Add(ToOptionsFileIdentity(
snapshot.Shortcuts.ShortcutIdentity.Value));
continue;
}

Expand All @@ -109,7 +111,8 @@ public static IReadOnlySet<uint> ResolveOnlineIdentities(

if (objectId is not 0 and not uint.MaxValue)
{
result.Add(BinaryPrimitives.ReverseEndianness(objectId));
result.Add(ToOptionsFileIdentity(
BinaryPrimitives.ReverseEndianness(objectId)));
}
}

Expand All @@ -125,6 +128,7 @@ private static Dictionary<uint, string> ReadShortcutNames(string path)
return result;
}

// shortcut.ini's sections carry the full character id.
uint? currentIdentity = null;

try
Expand All @@ -135,13 +139,13 @@ private static Dictionary<uint, string> ReadShortcutNames(string path)
var section = ShortcutSectionRegex().Match(line);

if (section.Success &&
uint.TryParse(
ulong.TryParse(
section.Groups["identity"].Value,
NumberStyles.None,
CultureInfo.InvariantCulture,
out var identity))
out var characterId))
{
currentIdentity = identity;
currentIdentity = ToOptionsFileIdentity(characterId);
continue;
}

Expand Down Expand Up @@ -178,6 +182,16 @@ ArgumentException or
return result;
}

/// <summary>
/// The identity in a pilot's player&lt;identity&gt;_options.ini name. The
/// client names the file after its character id modulo 1,000,000,000,
/// while shortcut.ini and the session ticket hold the full id.
/// </summary>
private static uint ToOptionsFileIdentity(ulong characterId)
{
return (uint)(characterId % 1_000_000_000);
}

private static string ExtractPilotName(string sourceName)
{
var parts = sourceName.Split(
Expand Down
Loading