From 02ce8915f03453980a3ff58dbf8413a2c95154ae Mon Sep 17 00:00:00 2001 From: Trevan Richins Date: Sat, 31 Oct 2020 11:48:28 -0600 Subject: [PATCH 1/2] Only skip giveUnitControl if the value is false or true --- .../games/strategy/engine/data/gameparser/GameParser.java | 6 +++--- .../engine/data/gameparser/LegacyPropertyMapper.java | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/game-core/src/main/java/games/strategy/engine/data/gameparser/GameParser.java b/game-core/src/main/java/games/strategy/engine/data/gameparser/GameParser.java index d6a881ee9e0..bf47efe1010 100644 --- a/game-core/src/main/java/games/strategy/engine/data/gameparser/GameParser.java +++ b/game-core/src/main/java/games/strategy/engine/data/gameparser/GameParser.java @@ -895,9 +895,6 @@ private List> setOptions( } // decapitalize the property name for backwards compatibility final String name = LegacyPropertyMapper.mapLegacyOptionName(decapitalize(option.getName())); - if (LegacyPropertyMapper.ignoreOptionName(name)) { - continue; - } if (name.isEmpty()) { throw new GameParseException( @@ -905,6 +902,9 @@ private List> setOptions( } final String value = option.getValue(); final String count = option.getCount(); + if (LegacyPropertyMapper.ignoreOptionName(name, value)) { + continue; + } final String countAndValue = (count != null && !count.isEmpty() ? count + ":" : "") + value; if (containsEmptyForeachVariable(countAndValue, foreach)) { continue; // Skip adding option if contains empty foreach variable diff --git a/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java b/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java index 117c718b2fa..d61a3ed0436 100644 --- a/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java +++ b/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java @@ -55,7 +55,9 @@ public String mapPropertyName(final String propertyName) { return propertyName; } - static boolean ignoreOptionName(final String name) { - return name.equalsIgnoreCase("takeUnitControl") || name.equalsIgnoreCase("giveUnitControl"); + static boolean ignoreOptionName(final String name, final String value) { + return name.equalsIgnoreCase("takeUnitControl") + || (name.equalsIgnoreCase("giveUnitControl") + && (value.equals("false") || value.equals("true"))); } } From 5ca0fbfc85874a93cfa1fc8dd73df934fae1a41f Mon Sep 17 00:00:00 2001 From: Trevan Richins Date: Sat, 31 Oct 2020 20:01:26 -0600 Subject: [PATCH 2/2] Ignore giveUnitControl if its value is null --- .../strategy/engine/data/gameparser/LegacyPropertyMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java b/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java index d61a3ed0436..0fd3089de63 100644 --- a/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java +++ b/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java @@ -58,6 +58,6 @@ public String mapPropertyName(final String propertyName) { static boolean ignoreOptionName(final String name, final String value) { return name.equalsIgnoreCase("takeUnitControl") || (name.equalsIgnoreCase("giveUnitControl") - && (value.equals("false") || value.equals("true"))); + && (value == null || value.equals("false") || value.equals("true"))); } }