Skip to content

Commit

Permalink
update dependencies, add warning if the game saves are outdated and c…
Browse files Browse the repository at this point in the history
…an potentially break analyzer
  • Loading branch information
AndrewSav committed Dec 3, 2024
1 parent b5ed80d commit bb4cf76
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Analyzer.LootGroups.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
using lib.remnant2.analyzer.Model;
using lib.remnant2.analyzer.Model;
using System.Text.RegularExpressions;
using Serilog;
using SerilogTimings.Extensions;
Expand Down
68 changes: 68 additions & 0 deletions Analyzer.Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,72 @@ public static string[] GetProfileStrings(string? folderPath = null)

return [.. result];
}

public static void CheckBuildNumber(string? folderPath = null)
{
ILogger logger = Log.Logger
.ForContext(Log.Category, "Analyze")
.ForContext("SourceContext", "Analyzer:Profile");

ILogger notifier = Log.Logger
.ForContext(Log.Category, "Analyze")
.ForContext("RemnantNotificationType", "Warning")
.ForContext("SourceContext", "Analyzer:Profile");

ILogger performance = Log.Logger
.ForContext(Log.Category, Log.Performance)
.ForContext("SourceContext", "Analyzer:Profile");

var qpOperation = performance.OperationAt(LogEventLevel.Debug).Begin($"Check build number {folderPath}");

string folder = folderPath ?? Utils.GetSteamSavePath();
string profilePath = Path.Combine(folder, "profile.sav");
List<string> result = [];

Operation operation = performance.OperationAt(LogEventLevel.Debug).Begin("Load Save file");
SaveFile profileSf = ReadWithRetry(profilePath);
operation.Complete();

if (profileSf.FileHeader.BuildNumber < BuildLevel)
{
notifier.Warning($"Profile save build number is {profileSf.FileHeader.BuildNumber}, supported build number is {BuildLevel}, Analyser might not work correctly, please update the game and touch the stone with each character");
}

ArrayProperty ap = (ArrayProperty)profileSf.SaveData.Objects[0].Properties!.Lookup
.Single(x => x.Key == "Characters").Value.Value!;

for (int index = 0; index < ap.Items.Count; index++)
{
object? item = ap.Items[index];
ObjectProperty ch = (ObjectProperty)item!;
if (ch.ClassName == null) continue;

operation = performance.BeginOperation($"Character {result.Count + 1} (save_{index}) save load");

string savePath = Path.Combine(folder, $"save_{index}.sav");

SaveFile sf;
try
{
sf = ReadWithRetry(savePath);
}
catch (IOException e)
{
logger.Information($"Could not load {savePath}, {e}");
continue;
}


if (sf.FileHeader.BuildNumber < BuildLevel)
{
notifier.Warning($"Character {result.Count + 1} (save_{index}) save build number is {sf.FileHeader.BuildNumber}, supported build number is {BuildLevel}, Analyser might not work correctly, please update the game and touch the stone with each character");
}

result.Add(sf.FileHeader.BuildNumber.ToString());
operation.Complete();
}

qpOperation.Complete();

}
}
2 changes: 2 additions & 0 deletions Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace lib.remnant2.analyzer;

public partial class Analyzer
{
private const int BuildLevel = 453438;

// We are not tracking consumables, concoctions and relic fragments
// perhaps we should
Expand Down Expand Up @@ -166,6 +167,7 @@ public static Dataset Analyze(string? folderPath = null, Dataset? oldDataset = n

operation = performance.BeginOperation($"Character {result.Characters.Count + 1} (save_{charSlotInternal}) has mats");
StructProperty characterData = (StructProperty)character.Properties!.Lookup["CharacterData"].Value!;

List<ObjectiveProgress> objectives =
GetObjectives((ArrayStructProperty)profileNavigator.GetProperty("ObjectiveProgressList", characterData)!.Value!,
result.Characters.Count, charSlotInternal);
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog


## v0.0.30 (3 Dec 2024)
- Update dependencies
- Add warning if the save files game build is less than expected
- Suppress bogus naked armor warning

## v0.0.29 (15 Nov 2024)
- Suppress warning about unknow relic charge item
- Fix engram names displayed instead of archetype names
Expand Down
7 changes: 5 additions & 2 deletions Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public partial class Utils
{
private static readonly Guid SavedGamesGuid = new("4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4");

[DllImport("shell32.dll")]
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable SYSLIB1054 // Use 'LibraryImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
[DllImport("shell32.dll")]
private static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags,
#pragma warning restore SYSLIB1054 // Use 'LibraryImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
IntPtr hToken,
out IntPtr pszPath);

Expand Down Expand Up @@ -83,7 +85,8 @@ public static bool IsKnownInventoryItem(string item)
"^Quest_Item_DLC_DreamLevel$",
"^SkillTrait_.*",
"^Weapon_Unarmed$",
"^Relic_Charge_Pickup$"
"^Relic_Charge_Pickup$",
"^Armor_.*_Default$"
];
Regex r = new(string.Join('|',patterns));
return r.IsMatch(item);
Expand Down
2 changes: 1 addition & 1 deletion db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@
"Material": "Material_CeramicFlask",
"DropType": "Event",
"DropReference": "Quest_SideD_TombRaid",
"Note": "Crafted from Ceramic Flask found in Proving Grounds location on Yaesha. After the forth and last checkpoint and finishing the final saw blades area, when you reach the lever, once you are ready turn left and jump through the whole in the floor"
"Note": "Crafted from Ceramic Flask found in Proving Grounds location on Yaesha. After the forth and last checkpoint and finishing the final saw blades area, when you reach the lever, once you are ready turn left and jump through the hole in the floor"
},
{
"Id": "Mod_Heatwave",
Expand Down
2 changes: 1 addition & 1 deletion lib.remnant2.analyzer-dev.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="SerilogTimings" Version="3.1.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions lib.remnant2.analyzer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="lib.remnant2.saves" Version="0.0.16" />
<PackageReference Include="lib.remnant2.saves" Version="0.0.17" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="SerilogTimings" Version="3.1.0" />
</ItemGroup>

Expand Down

0 comments on commit bb4cf76

Please sign in to comment.