From 57257d057f194f137726aad818054f8b7cd5a45e Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Sun, 31 Dec 2017 23:48:51 +0000 Subject: [PATCH 01/14] Remove unintended jump cooldown (Fixes #4250) --- apps/openmw/mwmechanics/character.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index d9e2cc292..fa261bbc3 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1797,7 +1797,7 @@ void CharacterController::update(float duration) vec.y() *= factor; vec.z() = 0.0f; } - else if(vec.z() > 0.0f && mJumpState == JumpState_None) + else if(vec.z() > 0.0f && mJumpState != JumpState_InAir) { // Started a jump. float z = cls.getJump(mPtr); From c920f95d1ec24806ed1547d85ce304bc4f7c876d Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Sun, 31 Dec 2017 23:49:43 +0000 Subject: [PATCH 02/14] Don't incorrectly discard root node transformation (Fixes #4272) --- components/nifosg/nifloader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index a3b81338e..6e04c6405 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -268,7 +268,7 @@ namespace NifOsg osg::ref_ptr skel = new SceneUtil::Skeleton; osg::Group* root = created->asGroup(); - if (root && root->getDataVariance() == osg::Object::STATIC) + if (root && root->getDataVariance() == osg::Object::STATIC && !root->asTransform()) { skel->setStateSet(root->getStateSet()); skel->setName(root->getName()); @@ -440,7 +440,7 @@ namespace NifOsg // The Root node can be created as a Group if no transformation is required. // This takes advantage of the fact root nodes can't have additional controllers // loaded from an external .kf file (original engine just throws "can't find node" errors if you try). - if (!nifNode->parent && nifNode->controller.empty()) + if (!nifNode->parent && nifNode->controller.empty() && nifNode->trafo.isIdentity()) { node = new osg::Group; dataVariance = osg::Object::STATIC; From 7a7b040216c212f1149ecbf770443b2f4fc4a132 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 1 Jan 2018 14:10:23 +0100 Subject: [PATCH 03/14] fix building on mips machines --- components/nif/data.cpp | 4 ++-- components/nif/data.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/nif/data.cpp b/components/nif/data.cpp index a6721fde1..b2ba63053 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -153,12 +153,12 @@ void NiPixelData::read(NIFStream *nif) // Unknown nif->skip(12); - mips = nif->getInt(); + number_of_mipmaps = nif->getInt(); // Bytes per pixel, should be bpp * 8 /* int bytes = */ nif->getInt(); - for(int i=0; i Date: Mon, 1 Jan 2018 16:32:20 +0100 Subject: [PATCH 04/14] camelCase --- components/nif/data.cpp | 4 ++-- components/nif/data.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/nif/data.cpp b/components/nif/data.cpp index b2ba63053..d19c8321e 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -153,12 +153,12 @@ void NiPixelData::read(NIFStream *nif) // Unknown nif->skip(12); - number_of_mipmaps = nif->getInt(); + numberOfMipmaps = nif->getInt(); // Bytes per pixel, should be bpp * 8 /* int bytes = */ nif->getInt(); - for(int i=0; i Date: Mon, 1 Jan 2018 19:47:36 +0100 Subject: [PATCH 05/14] update openmw.appdata.xml to fix https://lintian.debian.org/tags/appstream-metadata-legacy-format.html --- files/openmw.appdata.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/files/openmw.appdata.xml b/files/openmw.appdata.xml index 1c16cb9a4..932c82ad7 100644 --- a/files/openmw.appdata.xml +++ b/files/openmw.appdata.xml @@ -1,9 +1,12 @@ - - - openmw.desktop + + + org.openmw.desktop CC0-1.0 - GPL-3.0 and MIT and zlib + GPL-3.0 and MIT OpenMW Unofficial open source engine re-implementation of the game Morrowind @@ -32,8 +35,7 @@ Vivec seen from Ebonheart on OpenMW -nobrakal@gmail.com https://openmw.org https://bugs.openmw.org/ https://openmw.org/faq/ - + From bca9c550467282417b1d49c36078e311c02724b6 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 2 Jan 2018 07:47:27 +0200 Subject: [PATCH 06/14] [Client] Reinstate "Merge pull request #1529 from drummyfish/animfix" This reverts commit 2f4cd6b713fbb5abfd701110ba5dd247c3bb347a and adds back the changes made by 45993d3da21105879507772f53a9a25baaf54795 because the OpenMW issue at https://bugs.openmw.org/issues/4250 has been fixed by 57257d057f194f137726aad818054f8b7cd5a45e --- apps/openmw/mwmechanics/character.cpp | 38 ++++++++++++++++++--------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index fbcb7371a..6e6570b00 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -390,21 +390,29 @@ void CharacterController::refreshJumpAnims(const WeaponInfo* weap, JumpingState } } - if(mJumpState == JumpState_InAir) - { - mAnimation->disable(mCurrentJump); - mCurrentJump = jumpAnimName; - if (mAnimation->hasAnimation("jump")) - mAnimation->play(mCurrentJump, Priority_Jump, jumpmask, false, - 1.0f, (startAtLoop?"loop start":"start"), "stop", 0.0f, ~0ul); - } - else + if (!mCurrentJump.empty()) { mAnimation->disable(mCurrentJump); mCurrentJump.clear(); - if (mAnimation->hasAnimation("jump")) + } + + if(mJumpState == JumpState_InAir) + { + if (mAnimation->hasAnimation(jumpAnimName)) + { + mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, false, + 1.0f, (startAtLoop?"loop start":"start"), "stop", 0.0f, ~0ul); + mCurrentJump = jumpAnimName; + } + } + else if (mJumpState == JumpState_Landing) + { + if (mAnimation->hasAnimation(jumpAnimName)) + { mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, true, 1.0f, "loop stop", "stop", 0.0f, 0); + mCurrentJump = jumpAnimName; + } } } } @@ -1825,7 +1833,6 @@ void CharacterController::update(float duration) mHasMovedInXY = std::abs(vec.x())+std::abs(vec.y()) > 0.0f; isrunning = isrunning && mHasMovedInXY; - // advance athletics if(mHasMovedInXY && mPtr == getPlayer()) { @@ -1980,7 +1987,8 @@ void CharacterController::update(float duration) } else { - jumpstate = JumpState_None; + jumpstate = mAnimation->isPlaying(mCurrentJump) ? JumpState_Landing : JumpState_None; + vec.z() = 0.0f; inJump = false; @@ -2010,9 +2018,15 @@ void CharacterController::update(float duration) else if(rot.z() != 0.0f && !sneak && !(mPtr == getPlayer() && MWBase::Environment::get().getWorld()->isFirstPerson())) { if(rot.z() > 0.0f) + { movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight; + mAnimation->disable(mCurrentJump); + } else if(rot.z() < 0.0f) + { movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft; + mAnimation->disable(mCurrentJump); + } } } From c3c3fbc68e5aaed84eb40d1d0de705320dfd1a7a Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Tue, 2 Jan 2018 11:42:08 +0100 Subject: [PATCH 07/14] overriden -> overridden --- apps/openmw/mwphysics/physicssystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 36041a85e..174560e6b 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -705,7 +705,7 @@ namespace MWPhysics if (physFramerate > 0) { mPhysicsDt = 1.f / physFramerate; - std::cerr << "Warning: physics framerate was overriden (a new value is " << physFramerate << ")." << std::endl; + std::cerr << "Warning: physics framerate was overridden (a new value is " << physFramerate << ")." << std::endl; } } } From 1cf2f35a28f6f7e7162752ad1366d07cbaef47c0 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 2 Jan 2018 16:32:38 +0200 Subject: [PATCH 08/14] [Server] Add script functions to set & get plugin enforcement state --- apps/openmw-mp/Networking.cpp | 15 ++++++++++++- apps/openmw-mp/Networking.hpp | 3 +++ .../Script/Functions/Miscellaneous.cpp | 10 +++++++++ .../Script/Functions/Miscellaneous.hpp | 22 +++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 47091c0f4..7a0339c81 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -33,6 +33,7 @@ using namespace std; Networking *Networking::sThis = 0; static int currentMpNum = 0; +static bool pluginEnforcementState = true; Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr) { @@ -232,14 +233,16 @@ void Networking::update(RakNet::Packet *packet) packetPreInit.SetSendStream(&bs); // If the loop above was broken, then the client's plugins do not match the server's - if (plugin != plugins.end()) + if (pluginEnforcementState && plugin != plugins.end()) { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s was not allowed to connect due to incompatible plugins", packet->systemAddress.ToString()); packetPreInit.setChecksums(&samples); packetPreInit.Send(packet->systemAddress); peer->CloseConnection(packet->systemAddress, true); } else { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s was allowed to connect", packet->systemAddress.ToString()); PacketPreInit::PluginContainer tmp; packetPreInit.setChecksums(&tmp); packetPreInit.Send(packet->systemAddress); @@ -373,6 +376,16 @@ int Networking::incrementMpNum() return currentMpNum; } +bool Networking::getPluginEnforcementState() +{ + return pluginEnforcementState; +} + +void Networking::setPluginEnforcementState(bool state) +{ + pluginEnforcementState = state; +} + const Networking &Networking::get() { return *sThis; diff --git a/apps/openmw-mp/Networking.hpp b/apps/openmw-mp/Networking.hpp index 7deadd537..913377b0b 100644 --- a/apps/openmw-mp/Networking.hpp +++ b/apps/openmw-mp/Networking.hpp @@ -52,6 +52,9 @@ namespace mwmp void setCurrentMpNum(int value); int incrementMpNum(); + bool getPluginEnforcementState(); + void setPluginEnforcementState(bool state); + MasterClient *getMasterClient(); void InitQuery(std::string queryAddr, unsigned short queryPort); void setServerPassword(std::string passw) noexcept; diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp index 7270fe3e0..3127a14c9 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp @@ -43,6 +43,16 @@ void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept mwmp::Networking::getPtr()->setCurrentMpNum(mpNum); } +int MiscellaneousFunctions::GetPluginEnforcementState() noexcept +{ + return mwmp::Networking::getPtr()->getPluginEnforcementState(); +} + +void MiscellaneousFunctions::SetPluginEnforcementState(bool state) noexcept +{ + mwmp::Networking::getPtr()->setPluginEnforcementState(state); +} + void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept { LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message); diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp index 487b924ec..d5193fa24 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp @@ -11,6 +11,9 @@ {"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\ {"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\ \ + {"GetPluginEnforcementState", MiscellaneousFunctions::GetPluginEnforcementState},\ + {"SetPluginEnforcementState", MiscellaneousFunctions::SetPluginEnforcementState},\ + \ {"LogMessage", MiscellaneousFunctions::LogMessage},\ {"LogAppend", MiscellaneousFunctions::LogAppend} @@ -64,6 +67,25 @@ public: */ static void SetCurrentMpNum(int mpNum) noexcept; + /** + * \brief Get the plugin enforcement state of the server. + * + * If true, clients are required to use the same plugins as set for the server. + * + * \return The enforcement state. + */ + static int GetPluginEnforcementState() noexcept; + + /** + * \brief Set the plugin enforcement state of the server. + * + * If true, clients are required to use the same plugins as set for the server. + * + * \param state The new enforcement state. + * \return void + */ + static void SetPluginEnforcementState(bool state) noexcept; + /** * \brief Write a log message with its own timestamp. * From 502df7d9c1156ed81222bd1dd2cd8fba95240b4f Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 5 Jan 2018 00:03:05 +0200 Subject: [PATCH 09/14] [Client] Clean up GUIChat slightly --- apps/openmw/mwmp/GUI/GUIChat.cpp | 28 ++++++++++++++-------------- apps/openmw/mwmp/GUI/GUIChat.hpp | 4 ++-- apps/openmw/mwmp/GUIController.cpp | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwmp/GUI/GUIChat.cpp b/apps/openmw/mwmp/GUI/GUIChat.cpp index aae62e020..c02350883 100644 --- a/apps/openmw/mwmp/GUI/GUIChat.cpp +++ b/apps/openmw/mwmp/GUI/GUIChat.cpp @@ -52,7 +52,7 @@ namespace mwmp { // Give keyboard focus to the combo box whenever the console is // turned on - SetEditState(0); + setEditState(0); windowState = CHAT_ENABLED; } @@ -61,7 +61,7 @@ namespace mwmp // Apparently, hidden widgets can retain key focus // Remove for MyGUI 3.2.2 windowState = CHAT_DISABLED; - SetEditState(0); + setEditState(0); } bool GUIChat::exit() @@ -79,7 +79,7 @@ namespace mwmp if (cm.empty()) { mCommandLine->setCaption(""); - SetEditState(0); + setEditState(0); return; } @@ -96,7 +96,7 @@ namespace mwmp // It prevents the re-triggering of the acceptCommand() event for the same command // during the actual command execution mCommandLine->setCaption(""); - SetEditState(0); + setEditState(0); send (cm); } @@ -173,7 +173,7 @@ namespace mwmp { case CHAT_DISABLED: this->mMainWidget->setVisible(false); - SetEditState(0); + setEditState(0); break; case CHAT_ENABLED: this->mMainWidget->setVisible(true); @@ -184,7 +184,7 @@ namespace mwmp } } - void GUIChat::SetEditState(bool state) + void GUIChat::setEditState(bool state) { editState = state; mCommandLine->setVisible(editState); @@ -195,17 +195,17 @@ namespace mwmp { if (windowState == CHAT_DISABLED) return; - else if (windowState == CHAT_HIDDENMODE) + + if (!mCommandLine->getVisible()) + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Opening chat."); + + if (windowState == CHAT_HIDDENMODE) { setVisible(true); curTime = 0; - editState = true; } - else // CHAT_ENABLED - editState = true; - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Opening chat."); - SetEditState(editState); + setEditState(true); } void GUIChat::keyPress(MyGUI::Widget *_sender, MyGUI::KeyCode key, MyGUI::Char _char) @@ -241,14 +241,14 @@ namespace mwmp } - void GUIChat::Update(float dt) + void GUIChat::update(float dt) { if (windowState == CHAT_HIDDENMODE && !editState && isVisible()) { curTime += dt; if (curTime >= delay) { - SetEditState(false); + setEditState(false); this->mMainWidget->setVisible(false); } } diff --git a/apps/openmw/mwmp/GUI/GUIChat.hpp b/apps/openmw/mwmp/GUI/GUIChat.hpp index 059882561..cc2a1491d 100644 --- a/apps/openmw/mwmp/GUI/GUIChat.hpp +++ b/apps/openmw/mwmp/GUI/GUIChat.hpp @@ -41,7 +41,7 @@ namespace mwmp void pressedSay(); // switch chat focus (if chat mode != CHAT_DISABLED) void setDelay(float delay); - void Update(float dt); + void update(float dt); virtual void onOpen(); virtual void onClose(); @@ -78,7 +78,7 @@ namespace mwmp void acceptCommand(MyGUI::EditBox* _sender); - void SetEditState(bool state); + void setEditState(bool state); int windowState; bool editState; diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index cff86664a..c601221ec 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -198,7 +198,7 @@ bool mwmp::GUIController::hasFocusedElement() void mwmp::GUIController::update(float dt) { if (mChat != nullptr) - mChat->Update(dt); + mChat->update(dt); // Make sure we read the pressed button without resetting it, because it may also get // checked somewhere else From a639d3494a4befaa97a473b875a3d5ef4e8c20c4 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 5 Jan 2018 01:24:15 +0200 Subject: [PATCH 10/14] [Client] Fix use of DedicatedPlayers as targets for ConsoleCommand --- apps/openmw/mwmp/WorldEvent.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index 6e4e0b2eb..07e3f4534 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -470,13 +470,16 @@ void WorldEvent::runConsoleCommands(MWWorld::CellStore* cellStore) windowManager->setConsolePtr(static_cast(player)->getPlayerPtr()); windowManager->executeCommandInConsole(consoleCommand); } - else if (player != 0) + else { - player = PlayerList::getPlayer(guid); + player = PlayerList::getPlayer(worldObject.guid); - LOG_APPEND(Log::LOG_VERBOSE, "-- running on player %s", player->npc.mName.c_str()); - windowManager->setConsolePtr(static_cast(player)->getPtr()); - windowManager->executeCommandInConsole(consoleCommand); + if (player != 0) + { + LOG_APPEND(Log::LOG_VERBOSE, "-- running on player %s", player->npc.mName.c_str()); + windowManager->setConsolePtr(static_cast(player)->getPtr()); + windowManager->executeCommandInConsole(consoleCommand); + } } } else From 647661daf9e834e6f90fee052eeca771a312236c Mon Sep 17 00:00:00 2001 From: Koncord Date: Fri, 5 Jan 2018 08:36:13 +0800 Subject: [PATCH 11/14] [General] Minor fixes in Master packets --- .../openmw-mp/Master/PacketMasterAnnounce.cpp | 2 +- .../openmw-mp/Master/PacketMasterAnnounce.hpp | 8 ++++---- components/openmw-mp/Master/PacketMasterQuery.cpp | 10 ++++++++-- components/openmw-mp/Master/PacketMasterQuery.hpp | 4 ++-- components/openmw-mp/Master/PacketMasterUpdate.cpp | 2 +- components/openmw-mp/Master/PacketMasterUpdate.hpp | 4 ++-- components/openmw-mp/Master/ProxyMasterPacket.hpp | 13 +++++-------- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/components/openmw-mp/Master/PacketMasterAnnounce.cpp b/components/openmw-mp/Master/PacketMasterAnnounce.cpp index ac8b3cecb..ff22b6465 100644 --- a/components/openmw-mp/Master/PacketMasterAnnounce.cpp +++ b/components/openmw-mp/Master/PacketMasterAnnounce.cpp @@ -35,7 +35,7 @@ void PacketMasterAnnounce::SetServer(QueryData *_server) server = _server; } -void PacketMasterAnnounce::SetFunc(int _func) +void PacketMasterAnnounce::SetFunc(uint32_t _func) { func = _func; } diff --git a/components/openmw-mp/Master/PacketMasterAnnounce.hpp b/components/openmw-mp/Master/PacketMasterAnnounce.hpp index 4a3a81be0..5af7ad4e0 100644 --- a/components/openmw-mp/Master/PacketMasterAnnounce.hpp +++ b/components/openmw-mp/Master/PacketMasterAnnounce.hpp @@ -15,12 +15,12 @@ namespace mwmp { friend class ProxyMasterPacket; public: - PacketMasterAnnounce(RakNet::RakPeerInterface *peer); + explicit PacketMasterAnnounce(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, bool send); + void Packet(RakNet::BitStream *bs, bool send) override; void SetServer(QueryData *server); - void SetFunc(int keep); + void SetFunc(uint32_t keep); int GetFunc(); enum Func @@ -31,7 +31,7 @@ namespace mwmp }; private: QueryData *server; - int func; + uint32_t func; }; } diff --git a/components/openmw-mp/Master/PacketMasterQuery.cpp b/components/openmw-mp/Master/PacketMasterQuery.cpp index 1850de6c5..015b36d97 100644 --- a/components/openmw-mp/Master/PacketMasterQuery.cpp +++ b/components/openmw-mp/Master/PacketMasterQuery.cpp @@ -26,7 +26,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) if (send) bs->Write(packetID); - int serversCount = servers->size(); + int32_t serversCount = servers->size(); RW(serversCount, send); @@ -36,7 +36,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) QueryData server; string addr; - unsigned short port; + uint16_t port; while (serversCount--) { if (send) @@ -50,6 +50,12 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) ProxyMasterPacket::addServer(this, server, send); + if(addr.empty()) + { + cout << "Address empty. Aborting PacketMasterQuery::Packet" << endl; + return; + } + if (send) serverIt++; else diff --git a/components/openmw-mp/Master/PacketMasterQuery.hpp b/components/openmw-mp/Master/PacketMasterQuery.hpp index ada4b308d..43eeafee0 100644 --- a/components/openmw-mp/Master/PacketMasterQuery.hpp +++ b/components/openmw-mp/Master/PacketMasterQuery.hpp @@ -15,9 +15,9 @@ namespace mwmp { friend class ProxyMasterPacket; public: - PacketMasterQuery(RakNet::RakPeerInterface *peer); + explicit PacketMasterQuery(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, bool send); + void Packet(RakNet::BitStream *bs, bool send) override; void SetServers(std::map *serverMap); private: diff --git a/components/openmw-mp/Master/PacketMasterUpdate.cpp b/components/openmw-mp/Master/PacketMasterUpdate.cpp index 54f32e266..33ef10ec4 100644 --- a/components/openmw-mp/Master/PacketMasterUpdate.cpp +++ b/components/openmw-mp/Master/PacketMasterUpdate.cpp @@ -24,7 +24,7 @@ void PacketMasterUpdate::Packet(RakNet::BitStream *bs, bool send) bs->Write(packetID); string addr = server->first.ToString(false); - unsigned short port = server->first.GetPort(); + uint16_t port = server->first.GetPort(); RW(addr, send); RW(port, send); diff --git a/components/openmw-mp/Master/PacketMasterUpdate.hpp b/components/openmw-mp/Master/PacketMasterUpdate.hpp index 37adf2216..f3c254dbb 100644 --- a/components/openmw-mp/Master/PacketMasterUpdate.hpp +++ b/components/openmw-mp/Master/PacketMasterUpdate.hpp @@ -15,9 +15,9 @@ namespace mwmp { friend class ProxyMasterPacket; public: - PacketMasterUpdate(RakNet::RakPeerInterface *peer); + explicit PacketMasterUpdate(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, bool send); + void Packet(RakNet::BitStream *bs, bool send) override; void SetServer(std::pair *serverPair); private: diff --git a/components/openmw-mp/Master/ProxyMasterPacket.hpp b/components/openmw-mp/Master/ProxyMasterPacket.hpp index d5d4506b5..01bafa662 100644 --- a/components/openmw-mp/Master/ProxyMasterPacket.hpp +++ b/components/openmw-mp/Master/ProxyMasterPacket.hpp @@ -14,9 +14,8 @@ namespace mwmp class ProxyMasterPacket : public BasePacket { private: - ProxyMasterPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) + explicit ProxyMasterPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) { - } public: @@ -25,8 +24,7 @@ namespace mwmp { using namespace std; - int rulesSize = server.rules.size(); - + int32_t rulesSize = server.rules.size(); packet->RW(rulesSize, send); if (rulesSize > 2000) @@ -38,7 +36,7 @@ namespace mwmp while (rulesSize--) { - ServerRule *rule = 0; + ServerRule *rule = nullptr; string key; if (send) { @@ -71,9 +69,8 @@ namespace mwmp else server.players.clear(); - int playersCount = server.players.size(); + int32_t playersCount = server.players.size(); packet->RW(playersCount, send); - if (playersCount > 2000) playersCount = 0; @@ -91,7 +88,7 @@ namespace mwmp plIt++; } - int pluginsCount = server.plugins.size(); + int32_t pluginsCount = server.plugins.size(); packet->RW(pluginsCount, send); if (pluginsCount > 2000) From 5b8f4f3e92d662f36580b94184057b648be9f01d Mon Sep 17 00:00:00 2001 From: Koncord Date: Fri, 5 Jan 2018 08:38:29 +0800 Subject: [PATCH 12/14] [Browser] Stop PingHelper on refresh --- apps/browser/PingHelper.cpp | 6 ++++++ apps/browser/PingHelper.hpp | 1 + apps/browser/PingUpdater.cpp | 2 +- apps/browser/QueryHelper.cpp | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/browser/PingHelper.cpp b/apps/browser/PingHelper.cpp index 030f71610..b5f946b8a 100644 --- a/apps/browser/PingHelper.cpp +++ b/apps/browser/PingHelper.cpp @@ -14,6 +14,12 @@ void PingHelper::Add(int row, const AddrPair &addrPair) pingThread->start(); } +void PingHelper::Reset() +{ + //if (pingThread->isRunning()) + Stop(); +} + void PingHelper::Stop() { emit pingUpdater->stop(); diff --git a/apps/browser/PingHelper.hpp b/apps/browser/PingHelper.hpp index 7866d7bfc..808757482 100644 --- a/apps/browser/PingHelper.hpp +++ b/apps/browser/PingHelper.hpp @@ -17,6 +17,7 @@ class PingHelper : public QObject Q_OBJECT public: + void Reset(); void Add(int row, const AddrPair &addrPair); void Stop(); void SetModel(QAbstractTableModel *model); diff --git a/apps/browser/PingUpdater.cpp b/apps/browser/PingUpdater.cpp index 54122ffd8..befea9c3c 100644 --- a/apps/browser/PingUpdater.cpp +++ b/apps/browser/PingUpdater.cpp @@ -42,7 +42,7 @@ void PingUpdater::process() unsigned ping = PingRakNetServer(server.second.first.toLatin1(), server.second.second); qDebug() << "Pong from" << server.second.first + "|" + QString::number(server.second.second) - << ":" << ping << "ms"; + << ":" << ping << "ms" << "Sizeof servers: " << servers.size(); emit updateModel(server.first, ping); } diff --git a/apps/browser/QueryHelper.cpp b/apps/browser/QueryHelper.cpp index 2e1be8df2..8fee88db8 100644 --- a/apps/browser/QueryHelper.cpp +++ b/apps/browser/QueryHelper.cpp @@ -29,6 +29,7 @@ void QueryHelper::refresh() if (!queryThread->isRunning()) { _model->removeRows(0, _model->rowCount()); + PingHelper::Get().Stop(); queryThread->start(); emit started(); } From ef0384b2966439670a282bcf237181d5e5fd321d Mon Sep 17 00:00:00 2001 From: Koncord Date: Fri, 5 Jan 2018 09:06:10 +0800 Subject: [PATCH 13/14] [General] Simplify ProxyMasterPacket --- .../openmw-mp/Master/ProxyMasterPacket.hpp | 41 ++++++------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/components/openmw-mp/Master/ProxyMasterPacket.hpp b/components/openmw-mp/Master/ProxyMasterPacket.hpp index 01bafa662..25ca39c1f 100644 --- a/components/openmw-mp/Master/ProxyMasterPacket.hpp +++ b/components/openmw-mp/Master/ProxyMasterPacket.hpp @@ -64,29 +64,21 @@ namespace mwmp vector::iterator plIt; - if (send) - plIt = server.players.begin(); - else - server.players.clear(); - int32_t playersCount = server.players.size(); packet->RW(playersCount, send); + if (playersCount > 2000) playersCount = 0; - while (playersCount--) + if(!send) { - string player; - if (send) - player = *plIt; + server.players.clear(); + server.players.resize(playersCount); + } + for(auto &&player : server.players) packet->RW(player, send); - if (!send) - server.players.push_back(player); - else - plIt++; - } int32_t pluginsCount = server.plugins.size(); packet->RW(pluginsCount, send); @@ -94,25 +86,16 @@ namespace mwmp if (pluginsCount > 2000) pluginsCount = 0; - vector::iterator pluginIt; - - if (send) - pluginIt = server.plugins.begin(); - else - server.plugins.clear(); - - while (pluginsCount--) + if(!send) { - Plugin plugin; - if (send) - plugin = *pluginIt; + server.plugins.clear(); + server.plugins.resize(pluginsCount); + } + for(auto &&plugin : server.plugins) + { packet->RW(plugin.name, send); packet->RW(plugin.hash, send); - if (!send) - server.plugins.push_back(plugin); - else - pluginIt++; } } }; From 35922e48983e83a9b9b6d76860696ec8f6461512 Mon Sep 17 00:00:00 2001 From: Koncord Date: Fri, 5 Jan 2018 09:40:11 +0800 Subject: [PATCH 14/14] [General] Change "enum ACTOR_ACTION" to "enum class Action" --- apps/openmw-mp/Actors.cpp | 8 ++++---- apps/openmw/mwmp/ActorList.cpp | 2 +- .../mwmp/processors/actor/ProcessorActorList.hpp | 4 ++-- components/openmw-mp/Base/BaseActor.hpp | 12 ++++++------ components/openmw-mp/Base/BasePlayer.hpp | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/openmw-mp/Actors.cpp b/apps/openmw-mp/Actors.cpp index 1f7f379e4..ffe0090ae 100644 --- a/apps/openmw-mp/Actors.cpp +++ b/apps/openmw-mp/Actors.cpp @@ -239,7 +239,7 @@ void ActorController::sendList(std::shared_ptr player, std::vectorcell; actorList.guid = player->guid; - actorList.action = mwmp::BaseActorList::SET; + actorList.action = mwmp::BaseActorList::Action::Set; for (auto &actor : actors) { @@ -257,7 +257,7 @@ void ActorController::requestList(std::shared_ptr player, const ESM::Cel { actorList.cell = player->cell; actorList.guid = player->guid; - actorList.action = mwmp::BaseActorList::REQUEST; + actorList.action = mwmp::BaseActorList::Action::Request; auto packet = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST); packet->setActorList(&actorList); @@ -270,9 +270,9 @@ std::vector> ActorController::getActors(std::shared_ptr

> actorList; - for (auto actor : serverCell->getActorList()->baseActors) + for (const auto &actor : serverCell->getActorList()->baseActors) { - Actor *a = new Actor; + auto a = new Actor; a->actor = actor; actorList.emplace_back(a); } diff --git a/apps/openmw/mwmp/ActorList.cpp b/apps/openmw/mwmp/ActorList.cpp index 5c8f5a354..3c96ebb5f 100644 --- a/apps/openmw/mwmp/ActorList.cpp +++ b/apps/openmw/mwmp/ActorList.cpp @@ -172,7 +172,7 @@ void ActorList::sendActorsInCell(MWWorld::CellStore* cellStore) { reset(); cell = *cellStore->getCell(); - action = BaseActorList::SET; + action = BaseActorList::Action::Set; auto createActor = [](const MWWorld::Ptr &ptr){ BaseActor *actor = new BaseActor; diff --git a/apps/openmw/mwmp/processors/actor/ProcessorActorList.hpp b/apps/openmw/mwmp/processors/actor/ProcessorActorList.hpp index 41ab06c78..556c98bbc 100644 --- a/apps/openmw/mwmp/processors/actor/ProcessorActorList.hpp +++ b/apps/openmw/mwmp/processors/actor/ProcessorActorList.hpp @@ -23,10 +23,10 @@ namespace mwmp if (!ptrCellStore) return; LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str()); - LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", actorList.action); + LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", (int) actorList.action); // If we've received a request for information, comply with it - if (actorList.action == mwmp::BaseActorList::REQUEST) + if (actorList.action == mwmp::BaseActorList::Action::Request) { MechanicsHelper::spawnLeveledCreatures(ptrCellStore); actorList.sendActorsInCell(ptrCellStore); diff --git a/components/openmw-mp/Base/BaseActor.hpp b/components/openmw-mp/Base/BaseActor.hpp index 64f2fa460..f86ede32a 100644 --- a/components/openmw-mp/Base/BaseActor.hpp +++ b/components/openmw-mp/Base/BaseActor.hpp @@ -46,12 +46,12 @@ namespace mwmp cell.blank(); } - enum ACTOR_ACTION + enum class Action: uint8_t { - SET = 0, - ADD = 1, - REMOVE = 2, - REQUEST = 3 + Set = 0, + Add, + Remsove, + Request }; RakNet::RakNetGUID guid; @@ -60,7 +60,7 @@ namespace mwmp ESM::Cell cell; - unsigned char action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item, 3 - Request items + Action action; bool isValid; }; diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index 7e42f711a..38c7ca42c 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -21,7 +21,7 @@ namespace mwmp { struct Chat { - enum class Action : uint8_t { + enum class Action: uint8_t { print = 0, clear, addchannel, @@ -46,7 +46,7 @@ namespace mwmp { std::string quest; int index; - enum class Type + enum class Type: uint8_t { Entry = 0, Index = 1 @@ -85,7 +85,7 @@ namespace mwmp { std::string itemId; - enum class Type : uint8_t + enum class Type: uint8_t { Item = 0, Magic,