From 605b06c303b21afb632528614a39eb90062d0b4b Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 30 Oct 2017 11:06:09 +0200 Subject: [PATCH] [General] Find actor speech captions instead of sending them in packets --- apps/openmw/mwbase/dialoguemanager.hpp | 10 +++++++ apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 29 ++++++++++++++++++- apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 10 +++++++ apps/openmw/mwmp/Cell.cpp | 1 - apps/openmw/mwmp/DedicatedActor.cpp | 4 ++- components/openmw-mp/Base/BaseActor.hpp | 1 - .../Packets/Actor/PacketActorSpeech.cpp | 1 - 7 files changed, 51 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index 2aedb48fc..f489e4cb2 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -102,6 +102,16 @@ namespace MWBase /* End of tes3mp addition */ + + /* + Start of tes3mp addition + + Make it possible to get the caption of a voice dialogue + */ + virtual std::string getVoiceCaption(const std::string& sound) const = 0; + /* + End of tes3mp addition + */ }; } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index abb6ebd89..480415e38 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -711,7 +711,6 @@ namespace MWDialogue if (mwmp::Main::get().getCellController()->isLocalActor(actor)) { mwmp::LocalActor *localActor = mwmp::Main::get().getCellController()->getLocalActor(actor); - localActor->response = info->mResponse; localActor->sound = info->mSound; } /* @@ -816,4 +815,32 @@ namespace MWDialogue mLastTopic, actor.getClass().getName(actor)); } } + + /* + Start of tes3mp addition + + Make it possible to get the caption of a voice dialogue + */ + std::string DialogueManager::getVoiceCaption(const std::string& sound) const + { + const MWWorld::Store& dialogues = MWBase::Environment::get().getWorld()->getStore().get(); + + for (MWWorld::Store::iterator dialogueIter = dialogues.begin(); dialogueIter != dialogues.end(); ++dialogueIter) + { + if (dialogueIter->mType == ESM::Dialogue::Voice) + { + for (ESM::Dialogue::InfoContainer::const_iterator infoIter = dialogueIter->mInfo.begin(); + infoIter != dialogueIter->mInfo.end(); ++infoIter) + { + if (!infoIter->mSound.empty() && Misc::StringUtils::ciEqual(sound, infoIter->mSound)) + return infoIter->mResponse; + } + } + } + + return "???"; + } + /* + End of tes3mp addition + */ } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index 00dbf5c05..12fbff796 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -114,6 +114,16 @@ namespace MWDialogue /// Removes the last added topic response for the given actor from the journal virtual void clearInfoActor (const MWWorld::Ptr& actor) const; + + /* + Start of tes3mp addition + + Make it possible to get the caption of a voice dialogue + */ + virtual std::string getVoiceCaption(const std::string& sound) const; + /* + End of tes3mp addition + */ }; } diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index c8d610366..625c390ec 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -237,7 +237,6 @@ void Cell::readSpeech(ActorList& actorList) if (dedicatedActors.count(mapIndex) > 0) { DedicatedActor *actor = dedicatedActors[mapIndex]; - actor->response = baseActor.response; actor->sound = baseActor.sound; } } diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index 01ad37743..e0f18b816 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -4,6 +4,8 @@ #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwdialogue/dialoguemanagerimp.hpp" + #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/mechanicsmanagerimp.hpp" #include "../mwmechanics/movement.hpp" @@ -217,7 +219,7 @@ void DedicatedActor::playSound() MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); if (winMgr->getSubtitlesEnabled()) - winMgr->messageBox(response, MWGui::ShowInDialogueMode_Never); + winMgr->messageBox(MWBase::Environment::get().getDialogueManager()->getVoiceCaption(sound), MWGui::ShowInDialogueMode_Never); sound.clear(); } diff --git a/components/openmw-mp/Base/BaseActor.hpp b/components/openmw-mp/Base/BaseActor.hpp index c4b55b4e6..be8f50e28 100644 --- a/components/openmw-mp/Base/BaseActor.hpp +++ b/components/openmw-mp/Base/BaseActor.hpp @@ -32,7 +32,6 @@ namespace mwmp char drawState; bool isFlying; - std::string response; std::string sound; SimpleCreatureStats creatureStats; diff --git a/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp b/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp index 565097ccf..20fe76a47 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp @@ -11,6 +11,5 @@ PacketActorSpeech::PacketActorSpeech(RakNet::RakPeerInterface *peer) : ActorPack void PacketActorSpeech::Actor(BaseActor &actor, bool send) { - RW(actor.response, send); RW(actor.sound, send); }