Skip to content

Commit

Permalink
Fixed a bug where the save date could not be read;
Browse files Browse the repository at this point in the history
  • Loading branch information
LonelyWindG committed May 6, 2023
1 parent bd44d51 commit c18893a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions OctopathTraveler/BasicData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public BasicData()
{
gvas.AppendValue(address, false);
}
SaveDate = new DateTime((int)gvas.ReadNumber("SaveDate_Year"), (int)gvas.ReadNumber("SaveDate_Month"), (int)gvas.ReadNumber("SaveDate_Day"),
(int)gvas.ReadNumber("SaveDate_Hour"), (int)gvas.ReadNumber("SaveDate_Minute"), (int)gvas.ReadNumber("SaveDate_Second")).ToString();
SaveDate = new DateTime((int)gvas.ReadNumberOrDefault("SaveDate_Year"), (int)gvas.ReadNumberOrDefault("SaveDate_Month"),
(int)gvas.ReadNumberOrDefault("SaveDate_Day"), (int)gvas.ReadNumberOrDefault("SaveDate_Hour"),
(int)gvas.ReadNumberOrDefault("SaveDate_Minute"), (int)gvas.ReadNumberOrDefault("SaveDate_Second")).ToString();

gvas.AppendValue(Util.FindFirstAddress("PlayTime", soltDataAddress));
var playTime = new TimeSpan(gvas.ReadNumber("PlayTime") * TimeSpan.TicksPerSecond);
Expand Down
8 changes: 8 additions & 0 deletions OctopathTraveler/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ public static uint ReadNumber(this GVAS gvas, string key)
{
return ReadNumber(gvas.Key(key));
}

public static uint ReadNumberOrDefault(this GVAS gvas, string key, uint defaultValue = default)
{
if (!gvas.HasKey(key))
return defaultValue;

return ReadNumber(gvas.Key(key));
}
}
}

0 comments on commit c18893a

Please sign in to comment.