diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index 3771f0a3d..2aedb48fc 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -46,6 +46,17 @@ namespace MWBase virtual void addTopic (const std::string& topic) = 0; + /* + Start of tes3mp addition + + Make it possible to check whether a topic is known by the player from elsewhere + in the code + */ + virtual bool isNewTopic(const std::string& topic) = 0; + /* + End of tes3mp addition + */ + virtual void askQuestion (const std::string& question,int choice) = 0; virtual void goodbye() = 0; diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 7578bd9d7..abb6ebd89 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -97,6 +97,20 @@ namespace MWDialogue mKnownTopics.insert( Misc::StringUtils::lowerCase(topic) ); } + /* + Start of tes3mp addition + + Make it possible to check whether a topic is known by the player from elsewhere + in the code + */ + bool DialogueManager::isNewTopic(const std::string& topic) + { + return (!mKnownTopics.count(topic)); + } + /* + End of tes3mp addition + */ + void DialogueManager::parseText (const std::string& text) { std::vector hypertext = HyperTextParser::parseHyperText(text); @@ -120,7 +134,7 @@ namespace MWDialogue Send an ID_PLAYER_TOPIC packet every time a new topic becomes known */ - if (mActorKnownTopics.count(topicId) && !mKnownTopics.count(topicId)) + if (mActorKnownTopics.count(topicId) && isNewTopic(topicId)) mwmp::Main::get().getLocalPlayer()->sendTopic(topicId); /* End of tes3mp addition diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index 40a24a1f8..00dbf5c05 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -68,6 +68,17 @@ namespace MWDialogue virtual void addTopic (const std::string& topic); + /* + Start of tes3mp addition + + Make it possible to check whether a topic is known by the player from elsewhere + in the code + */ + virtual bool isNewTopic(const std::string& topic); + /* + End of tes3mp addition + */ + virtual void askQuestion (const std::string& question,int choice); virtual void goodbye(); diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index faab1e9b9..85ef09e45 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -13,7 +13,16 @@ #include #include +/* + Start of tes3mp addition + + Include additional headers for multiplayer purposes +*/ #include "../mwmp/Main.hpp" +#include "../mwmp/LocalPlayer.hpp" +/* + End of tes3mp addition +*/ #include #include @@ -1026,6 +1035,17 @@ namespace MWInput void InputManager::toggleConsole() { + /* + Start of tes3mp addition + + If a player's console is disabled by the server, go no further + */ + if (!mwmp::Main::get().getLocalPlayer()->consoleAllowed) + return; + /* + End of tes3mp addition + */ + if (MyGUI::InputManager::getInstance ().isModalAny()) return; diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index d79236d8d..9f4678819 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -214,8 +214,6 @@ void mwmp::GUIController::update(float dt) Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->setPlayer(Main::get().getLocalPlayer()); Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(); } - - blockConsole(); } void mwmp::GUIController::WM_UpdateVisible(MWGui::GuiMode mode) @@ -383,13 +381,3 @@ void mwmp::GUIController::updateGlobalMapMarkerTooltips(MWGui::MapWindow *mapWin setGlobalMapMarkerTooltip(mapWindow, widget.second, x, y); } } - -void mwmp::GUIController::blockConsole() -{ - if (Main::get().getLocalPlayer()->consoleAllowed) - return; - - if (MWBase::Environment::get().getWindowManager()->isGuiMode()) - if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console) - MWBase::Environment::get().getWindowManager()->popGuiMode(); -} diff --git a/apps/openmw/mwmp/GUIController.hpp b/apps/openmw/mwmp/GUIController.hpp index 9cbf51ff6..8e6efba15 100644 --- a/apps/openmw/mwmp/GUIController.hpp +++ b/apps/openmw/mwmp/GUIController.hpp @@ -74,7 +74,6 @@ namespace mwmp GUIDialogList *mListBox; void onInputBoxDone(MWGui::WindowBase* parWindow); //MyGUI::Widget *oldFocusWidget, *currentFocusWidget; - void blockConsole(); }; } diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 06fcc18b1..1e72c1a9d 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -47,7 +47,7 @@ LocalPlayer::LocalPlayer() charGenStage.current = 0; charGenStage.end = 1; - consoleAllowed = true; + consoleAllowed = false; difficulty = 0; ignorePosPacket = false; diff --git a/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp b/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp index 738de5b26..a17d92f13 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp @@ -1,6 +1,9 @@ #ifndef OPENMW_PROCESSORGAMESETTINGS_HPP #define OPENMW_PROCESSORGAMESETTINGS_HPP +#include "apps/openmw/mwbase/environment.hpp" +#include "apps/openmw/mwgui/windowmanagerimp.hpp" + #include "../PlayerProcessor.hpp" namespace mwmp @@ -15,7 +18,16 @@ namespace mwmp virtual void Do(PlayerPacket &packet, BasePlayer *player) { - + if (isLocal()) + { + if (MWBase::Environment::get().getWindowManager()->isGuiMode()) + { + if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console && !player->consoleAllowed) + { + MWBase::Environment::get().getWindowManager()->popGuiMode(); + } + } + } } }; } diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 3380f6b7f..3295134e6 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -128,18 +128,19 @@ namespace MWScript std::string topic = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - MWBase::Environment::get().getDialogueManager()->addTopic(topic); - /* Start of tes3mp addition - Send an ID_PLAYER_TOPIC packet every time a topic is added + Send an ID_PLAYER_TOPIC packet every time a new topic is added through a script */ - mwmp::Main::get().getLocalPlayer()->sendTopic(topic); + if (MWBase::Environment::get().getDialogueManager()->isNewTopic(Misc::StringUtils::lowerCase(topic))) + mwmp::Main::get().getLocalPlayer()->sendTopic(Misc::StringUtils::lowerCase(topic)); /* End of tes3mp addition */ + + MWBase::Environment::get().getDialogueManager()->addTopic(topic); } }; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 296b6eee3..18f05b403 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -592,7 +592,7 @@ namespace MWScript */ if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen()) { - if (!ref.getRefData().isEnabled() && ref.getCell() != nullptr) + if (ref.isInCell() && !ref.getRefData().isEnabled()) { mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); worldEvent->reset(); @@ -620,7 +620,7 @@ namespace MWScript */ if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen()) { - if (ref.getRefData().isEnabled() && ref.getCell() != nullptr) + if (ref.isInCell() && ref.getRefData().isEnabled()) { mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); worldEvent->reset(); diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 9e10b1eeb..ca1ceb58b 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -60,10 +60,13 @@ namespace MWScript Send an ID_OBJECT_SCALE every time an object's scale is changed through a script */ - mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); - worldEvent->reset(); - worldEvent->addObjectScale(ptr, scale); - worldEvent->sendObjectScale(); + if (ptr.isInCell()) + { + mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); + worldEvent->reset(); + worldEvent->addObjectScale(ptr, scale); + worldEvent->sendObjectScale(); + } /* End of tes3mp addition */