Reuse localization structures.

This commit is contained in:
momo5502 2016-02-06 19:22:40 +01:00
parent 4a1ca56a3b
commit 374bef35dc

View File

@ -8,6 +8,17 @@ namespace Components
void Localization::Set(const char* key, const char* value)
{
if (Localization::LocalizeMap.find(key) != Localization::LocalizeMap.end())
{
Game::LocalizedEntry* entry = Localization::LocalizeMap[key];
char* newStaticValue = Utils::Memory::DuplicateString(value);
if (!newStaticValue) return;
if (entry->value) Utils::Memory::Free(entry->value);
entry->value = newStaticValue;
return;
}
Game::LocalizedEntry* entry = Utils::Memory::AllocateArray<Game::LocalizedEntry>(1);
if (!entry) return;