Skip to content

Commit 6f8cf15

Browse files
committed
Hack around WW lighting key value typos
1 parent 69dd8a3 commit 6f8cf15

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/TSMapEditor/Initialization/Initializer.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ private void InitBuildingType(INIDefineable obj, IniFile rulesIni, IniSection se
158158

159159
buildingType.RadialColor = section.KeyExists(nameof(buildingType.RadialColor)) ?
160160
Helpers.ColorFromString(section.GetStringValue(nameof(buildingType.RadialColor), null)) : buildingType.RadialColor;
161+
162+
// WW often made dumb typos where instead of a dot '.', they used a comma ',' in the values of lighting keys
163+
buildingType.LightRedTint = FloatTypoFix(buildingType, section, "LightRedTint", buildingType.LightRedTint);
164+
buildingType.LightGreenTint = FloatTypoFix(buildingType, section, "LightGreenTint", buildingType.LightGreenTint);
165+
buildingType.LightBlueTint = FloatTypoFix(buildingType, section, "LightBlueTint", buildingType.LightBlueTint);
166+
}
167+
168+
private double FloatTypoFix(BuildingType buildingType, IniSection section, string keyName, double current)
169+
{
170+
string value = section.GetStringValue(keyName, string.Empty);
171+
if (string.IsNullOrWhiteSpace(value))
172+
return current;
173+
174+
if (value.Contains(','))
175+
return Conversions.DoubleFromString(value.Replace(',', '.'), current);
176+
177+
return current;
161178
}
162179

163180
private void InitInfantryType(INIDefineable obj, IniFile rulesIni, IniSection section)

0 commit comments

Comments
 (0)