From 4d062c5da169fb42bf634a4d55f8376d3f31bae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=84=E5=87=AF?= Date: Wed, 27 Jun 2018 02:28:14 +0800 Subject: [PATCH] fix the 1.0.1 crash --- .../Modeling/Tank/ConsumableScript.cs | 14 +++++++-- TankInspector/Modeling/Tank/DefaultScript.cs | 29 +++++++++++++++++++ TankInspector/Modeling/Tank/ReconScript.cs | 29 +++++++++++++++++++ TankInspector/Modeling/Tank/Shell.cs | 2 ++ TankInspector/Modeling/Tank/ShellType.cs | 8 ++++- 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 TankInspector/Modeling/Tank/DefaultScript.cs create mode 100644 TankInspector/Modeling/Tank/ReconScript.cs diff --git a/TankInspector/Modeling/Tank/ConsumableScript.cs b/TankInspector/Modeling/Tank/ConsumableScript.cs index cf07156..b5c6a84 100644 --- a/TankInspector/Modeling/Tank/ConsumableScript.cs +++ b/TankInspector/Modeling/Tank/ConsumableScript.cs @@ -26,12 +26,18 @@ public static ConsumableScript Resolve(XmlReader reader, Database database) case "RemovedRpmLimiter": script = new RemovedRpmLimiterScript(database); break; - case "Artillery": + case "RageArtillery": + case "ConsumableArtillery": script = new ArtilleryScript(database); break; - case "Bomber": + case "RageBomber": + case "ConsumableBomber": script = new BomberScript(database); break; + case "EpicRecon": + case "ConsumableRecon": + script = new ReconScript(database); + break; case "Afterburning": script = new AfterburningScript(database); break; @@ -60,7 +66,9 @@ public static ConsumableScript Resolve(XmlReader reader, Database database) script = new LastEffortBattleBoosterScript(database); break; default: - throw new NotSupportedException(); + script = new DefaultScript(database,type); + break; + //TODO throw new NotSupportedException(); } script.Deserialize(reader); diff --git a/TankInspector/Modeling/Tank/DefaultScript.cs b/TankInspector/Modeling/Tank/DefaultScript.cs new file mode 100644 index 0000000..719a433 --- /dev/null +++ b/TankInspector/Modeling/Tank/DefaultScript.cs @@ -0,0 +1,29 @@ +using System.Xml; + +namespace Smellyriver.TankInspector.Modeling +{ + internal class DefaultScript : ConsumableScript + { + public override string[] EffectiveDomains => new[] { "unknown" }; + + public DefaultScript(Database database,string type) + : base(database) + { + EffectiveDomains.SetValue(type, 0); + } + + public override bool DeserializeSection(string name, XmlReader reader) + { + switch (name) + { + default: + return base.DeserializeSection(name, reader); + } + } + + public override void Execute(ModificationContext context, object args) + { + + } + } +} diff --git a/TankInspector/Modeling/Tank/ReconScript.cs b/TankInspector/Modeling/Tank/ReconScript.cs new file mode 100644 index 0000000..350d21f --- /dev/null +++ b/TankInspector/Modeling/Tank/ReconScript.cs @@ -0,0 +1,29 @@ +using System.Xml; + +namespace Smellyriver.TankInspector.Modeling +{ + internal class ReconScript : ConsumableScript + { + public override string[] EffectiveDomains => new[] { "recon" }; + + public ReconScript(Database database) + : base(database) + { + + } + + public override bool DeserializeSection(string name, XmlReader reader) + { + switch (name) + { + default: + return base.DeserializeSection(name, reader); + } + } + + public override void Execute(ModificationContext context, object args) + { + + } + } +} diff --git a/TankInspector/Modeling/Tank/Shell.cs b/TankInspector/Modeling/Tank/Shell.cs index 6a8b072..3d2ddb8 100644 --- a/TankInspector/Modeling/Tank/Shell.cs +++ b/TankInspector/Modeling/Tank/Shell.cs @@ -120,6 +120,8 @@ private ShellType ParseShellType(string type) return ShellType.APHE; case "HIGH_EXPLOSIVE_PREMIUM": return ShellType.PremiumHE; + case "SMOKE": + return ShellType.SMOKE; default: throw new NotSupportedException(); } diff --git a/TankInspector/Modeling/Tank/ShellType.cs b/TankInspector/Modeling/Tank/ShellType.cs index 400b451..6afb93e 100644 --- a/TankInspector/Modeling/Tank/ShellType.cs +++ b/TankInspector/Modeling/Tank/ShellType.cs @@ -10,7 +10,8 @@ public enum ShellType HE, PremiumHE, HEAT, - APHE + APHE, + SMOKE } internal static class ShellTypeExtensions @@ -21,6 +22,7 @@ public static bool IsKineticShellType(this ShellType type) { case ShellType.HE: case ShellType.PremiumHE: + case ShellType.SMOKE: return false; case ShellType.AP: case ShellType.APCR: @@ -39,6 +41,7 @@ public static bool HasNormalizationEffect(this ShellType type) case ShellType.HE: case ShellType.PremiumHE: case ShellType.HEAT: + case ShellType.SMOKE: return false; case ShellType.AP: case ShellType.APCR: @@ -56,6 +59,7 @@ public static double BasicNormalization(this ShellType type) case ShellType.HE: case ShellType.PremiumHE: case ShellType.HEAT: + case ShellType.SMOKE: return 0.0; case ShellType.AP: case ShellType.APHE: @@ -71,6 +75,8 @@ public static double RicochetAngle(this ShellType type) { switch (type) { + case ShellType.SMOKE: + return 0.0; case ShellType.HE: case ShellType.PremiumHE: return 90.0;