[Client] Rely on untranslated topics in ObjectDialogueChoice packets

Previously, when using the Russian edition, all dialogue topics were translated into English before being sent to the server in an ObjectDialogueChoice packet and were then translated back into Russian when received again by the client. However, there were situations where different topics in English corresponded to the same Russian word, e.g. "chores" and "duties" were both translated as "задания", which led to the incorrect topic being used on the client in the end.

This commit makes it so that users of the Russian edition send ObjectDialogueChoice packets where the topicId variable contains both the untranslated topic and the translated one, delimited by a | character, with the client simply using the former when receiving the packet again.

This is a hotfix instead of the proper fix, as the proper fix would use different variables for the two versions of the topic and thus require the structure of the ObjectDialogueChoice packet to change.
pull/600/head
David Cernat 3 years ago
parent 571f3e8ee7
commit abdaedd752

@ -465,10 +465,6 @@ namespace MWGui
{
if (dialogueChoiceType == mwmp::DialogueChoiceType::TOPIC)
{
// If we're using a translated version of Morrowind, translate this topic from English into our language
if (MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().hasTranslation())
topic = MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().getLocalizedTopicId(topic);
onTopicActivated(topic);
}
else if (dialogueChoiceType == mwmp::DialogueChoiceType::PERSUASION)

@ -1036,7 +1036,33 @@ void ObjectList::makeDialogueChoices(MWWorld::CellStore* cellStore)
LOG_APPEND(TimedLog::LOG_VERBOSE, "-- topic was %s", baseObject.topicId.c_str());
}
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->activateDialogueChoice(baseObject.dialogueChoiceType, baseObject.topicId);
std::string topic = baseObject.topicId;
if (MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().hasTranslation())
{
char delimiter = '|';
// If we're using a translated version of Morrowind, we may have received a string that had the original
// topic delimited from its possible English translation by a | character, in which case we need to use
// the original topic here
if (topic.find(delimiter) != std::string::npos)
{
topic = topic.substr(0, topic.find(delimiter));
}
// Alternatively, we may have received a topic that needs to be translated into the current language's
// version of it
else
{
std::string translatedTopic = MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().getLocalizedTopicId(topic);
if (!translatedTopic.empty())
{
topic = translatedTopic;
}
}
}
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->activateDialogueChoice(baseObject.dialogueChoiceType, topic);
}
else
{
@ -1329,7 +1355,7 @@ void ObjectList::addObjectDialogueChoice(const MWWorld::Ptr& ptr, std::string di
// For translated versions of the game, make sure we translate the topic back into English first
if (MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().hasTranslation())
baseObject.topicId = MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().topicID(dialogueChoice);
baseObject.topicId = dialogueChoice + "|" + MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().topicID(dialogueChoice);
else
baseObject.topicId = dialogueChoice;
}

Loading…
Cancel
Save