COMMON: Check GUIO constants for duplicates

This commit is contained in:
Eugene Sandulenko 2023-02-23 13:50:18 +01:00
parent c7d0594834
commit c138d170a5
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -115,6 +115,25 @@ const struct GameOpt {
};
bool checkGameGUIOption(const String &option, const String &str) {
#ifndef RELEASE_BUILD
static bool firstRun = true;
// Check GUIO constants for duplicates
if (firstRun) {
HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> allOptions;
for (int i = 0; g_gameOptions[i].desc; i++) {
if (allOptions.contains(g_gameOptions[i].option)) {
error("Duplicate GUIO constant, id: \\x%02x, renumerate them", g_gameOptions[i].option[0]);
}
allOptions[g_gameOptions[i].option] = true;
}
firstRun = false;
}
#endif
for (int i = 0; g_gameOptions[i].desc; i++) {
if (option.contains(g_gameOptions[i].option)) {
if (str.contains(g_gameOptions[i].desc))
@ -147,7 +166,7 @@ const String getGameGUIOptionsDescription(const String &options) {
String res;
for (int i = 0; g_gameOptions[i].desc; i++)
if (options.contains(g_gameOptions[i].option[0]))
if (options.contains(g_gameOptions[i].option[0]))
res += String(g_gameOptions[i].desc) + " ";
res.trim();