Skip to content

Commit

Permalink
Use culture-invariant case conversion for game collection parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku authored and Metadorius committed Jul 31, 2022
1 parent b2b7697 commit ccf3394
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ClientCore/CnCNet5/GameCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private List<CnCNetGame> GetCustomGames(List<CnCNetGame> existingGames)
if (!iniFile.SectionExists(kvp.Value))
continue;

string ID = iniFile.GetStringValue(kvp.Value, "InternalName", string.Empty).ToLower();
string ID = iniFile.GetStringValue(kvp.Value, "InternalName", string.Empty).ToLowerInvariant();

if (string.IsNullOrEmpty(ID))
throw new GameCollectionConfigurationException("InternalName for game " + kvp.Value + " is not defined or set to an empty value.");
Expand All @@ -180,18 +180,18 @@ private List<CnCNetGame> GetCustomGames(List<CnCNetGame> existingGames)
}

if (existingGames.Find(g => g.InternalName == ID) != null || customGameIDs.Contains(ID))
throw new GameCollectionConfigurationException("Game with InternalName " + ID.ToUpper() + " already exists in the game collection.");
throw new GameCollectionConfigurationException("Game with InternalName " + ID.ToUpperInvariant() + " already exists in the game collection.");

string iconFilename = iniFile.GetStringValue(kvp.Value, "IconFilename", ID + "icon.png");
customGames.Add(new CnCNetGame
{
InternalName = ID,
UIName = iniFile.GetStringValue(kvp.Value, "UIName", ID.ToUpper()),
UIName = iniFile.GetStringValue(kvp.Value, "UIName", ID.ToUpperInvariant()),
ChatChannel = GetIRCChannelNameFromIniFile(iniFile, kvp.Value, "ChatChannel"),
GameBroadcastChannel = GetIRCChannelNameFromIniFile(iniFile, kvp.Value, "GameBroadcastChannel"),
ClientExecutableName = iniFile.GetStringValue(kvp.Value, "ClientExecutableName", string.Empty),
RegistryInstallPath = iniFile.GetStringValue(kvp.Value, "RegistryInstallPath", "HKCU\\Software\\"
+ ID.ToUpper()),
+ ID.ToUpperInvariant()),
Texture = AssetLoader.AssetExists(iconFilename) ? AssetLoader.LoadTexture(iconFilename) :
AssetLoader.TextureFromImage(Resources.unknownicon)
});
Expand Down

0 comments on commit ccf3394

Please sign in to comment.