fix: notetracksoundmap initialized with empty string instead of nullptr in t6

This commit is contained in:
Jan 2024-02-04 21:14:50 +01:00
parent 27cd703cbd
commit ce31472f7f
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C

View File

@ -83,14 +83,13 @@ namespace T6
std::vector<std::pair<std::string, std::string>> pairs; std::vector<std::pair<std::string, std::string>> pairs;
if (!ParseAsPairs(value, pairs)) if (!ParseAsPairs(value, pairs))
{ {
std::cout << "Failed to parse notetracksoundmap as pairs" << std::endl; std::cout << "Failed to parse notetracksoundmap as pairs\n";
return false; return false;
} }
if (pairs.size() > std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>) if (pairs.size() > std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>)
{ {
std::cout << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)> << " notetracksoundmap entries!" std::cout << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)> << " notetracksoundmap entries!\n";
<< std::endl;
return false; return false;
} }
@ -100,21 +99,27 @@ namespace T6
if (pairs.size() < std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>) if (pairs.size() < std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>)
{ {
m_used_script_string_list.emplace(m_zone_script_strings.AddOrGetScriptString("")); m_used_script_string_list.emplace(m_zone_script_strings.AddOrGetScriptString(nullptr));
} }
for (; currentEntryNum < pairs.size(); currentEntryNum++) for (; currentEntryNum < pairs.size(); currentEntryNum++)
{ {
keys[currentEntryNum] = m_zone_script_strings.AddOrGetScriptString(pairs[currentEntryNum].first); const auto& currentValue = pairs[currentEntryNum];
m_used_script_string_list.emplace(keys[currentEntryNum]); const auto keyScriptString = !currentValue.first.empty() ? m_zone_script_strings.AddOrGetScriptString(currentValue.first)
: m_zone_script_strings.AddOrGetScriptString(nullptr);
const auto valueScriptString = !currentValue.second.empty() ? m_zone_script_strings.AddOrGetScriptString(currentValue.second)
: m_zone_script_strings.AddOrGetScriptString(nullptr);
values[currentEntryNum] = m_zone_script_strings.AddOrGetScriptString(pairs[currentEntryNum].second); keys[currentEntryNum] = keyScriptString;
m_used_script_string_list.emplace(values[currentEntryNum]); m_used_script_string_list.emplace(keyScriptString);
values[currentEntryNum] = valueScriptString;
m_used_script_string_list.emplace(valueScriptString);
} }
for (; currentEntryNum < std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>; currentEntryNum++) for (; currentEntryNum < std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>; currentEntryNum++)
{ {
const auto emptyScr = m_zone_script_strings.GetScriptString(""); const auto emptyScr = m_zone_script_strings.GetScriptString(nullptr);
keys[currentEntryNum] = emptyScr; keys[currentEntryNum] = emptyScr;
values[currentEntryNum] = emptyScr; values[currentEntryNum] = emptyScr;
} }