crlib: reworked dictionary to hashmap.

linkage: another fix to dynamic linkage.
cpp: fixed msvc warning about placement new.
This commit is contained in:
dmitry 2020-06-15 22:36:11 +03:00 committed by jeefo
commit 43f6a7828a
12 changed files with 291 additions and 312 deletions

View file

@ -495,7 +495,7 @@ void BotConfig::loadLanguageConfig () {
}
if (!lang.second.empty () && !lang.first.empty ()) {
m_language.push (lang.first.trim (), lang.second.trim ());
m_language[lang.first.trim ()] = lang.second.trim ();
}
}
else if (line.startsWith ("[TRANSLATED]") && !temp.empty ()) {
@ -756,11 +756,9 @@ const char *BotConfig::translate (StringRef input) {
if (game.isDedicated ()) {
return input.chars ();
}
static String result;
result.clear ();
if (m_language.find (input, result)) {
return result.chars ();
if (m_language.has (input)) {
return m_language[input.chars ()].chars ();
}
return input.chars (); // nothing found
}