diff --git a/OctopathTraveler/BasicData.cs b/OctopathTraveler/BasicData.cs index 08d1149..022bbad 100644 --- a/OctopathTraveler/BasicData.cs +++ b/OctopathTraveler/BasicData.cs @@ -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); diff --git a/OctopathTraveler/Util.cs b/OctopathTraveler/Util.cs index b87a550..df800b0 100644 --- a/OctopathTraveler/Util.cs +++ b/OctopathTraveler/Util.cs @@ -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)); + } } }