diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseTorpedo.cs b/ElectronicObserver/Data/Battle/Phase/PhaseTorpedo.cs index a6f3e8f92..f034ba5ae 100644 --- a/ElectronicObserver/Data/Battle/Phase/PhaseTorpedo.cs +++ b/ElectronicObserver/Data/Battle/Phase/PhaseTorpedo.cs @@ -111,27 +111,38 @@ public override void EmulateBattle(int[] hps, int[] damages) - private T[] GetConcatArray(string friendName, string enemyName, T defaultValue) + private T[] GetConcatArray(string friendName, string enemyName, T defaultValue) where T : struct { - var friend = (T[])TorpedoData[friendName]; - var enemy = (T[])TorpedoData[enemyName]; + var friend = ConvertToArray(TorpedoData[friendName], 12, defaultValue); + var enemy = ConvertToArray(TorpedoData[enemyName], 12, defaultValue); var ret = new T[24]; for (int i = 0; i < 12; i++) { - if (i < friend.Length) - ret[i] = friend[i]; - else - ret[i] = defaultValue; - - if (i < enemy.Length) - ret[i + 12] = enemy[i]; - else - ret[i + 12] = defaultValue; + ret[i] = friend[i]; + ret[i + 12] = enemy[i]; } return ret; } + + /// + /// 基本的には `(T[])json` と等価ですが、特定の状況下におけるデータエラーを回避するための実装が含まれています + /// https://github.com/andanteyk/ElectronicObserver/issues/294 + /// + private static T[] ConvertToArray(dynamic json, int maxLength, T defaultValue) where T : struct + { + var ret = Enumerable.Repeat(defaultValue, maxLength).ToArray(); + int i = 0; + foreach (var member in json) + { + ret[i++ % maxLength] = + member is KeyValuePair pair ? (T)pair.Value : + member != null ? (T)member : + default(T); + } + return ret; + } } } diff --git a/ElectronicObserver/Utility/SoftwareInformation.cs b/ElectronicObserver/Utility/SoftwareInformation.cs index a8090dbdb..7f244cb5a 100644 --- a/ElectronicObserver/Utility/SoftwareInformation.cs +++ b/ElectronicObserver/Utility/SoftwareInformation.cs @@ -29,20 +29,20 @@ public static class SoftwareInformation /// /// バージョン(日本語, ソフトウェア名を含みます) /// - public static string VersionJapanese => SoftwareNameJapanese + "四七型"; + public static string VersionJapanese => SoftwareNameJapanese + "四七型改"; /// /// バージョン(英語) /// - public static string VersionEnglish => "4.7.0"; + public static string VersionEnglish => "4.7.1"; /// /// 更新日時 /// - public static DateTime UpdateTime => DateTimeHelper.CSVStringToTime("2021/09/19 18:30:00"); + public static DateTime UpdateTime => DateTimeHelper.CSVStringToTime("2021/11/23 18:30:00");