From 870fd9a78bac3e690aa1205ecce37178398448fa Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 24 May 2017 13:28:34 +0300 Subject: [PATCH] [General] Remove ObjectUnlock packet, use ObjectLock with 0 lock instead --- apps/openmw-mp/CMakeLists.txt | 6 +-- apps/openmw-mp/ProcessorInitializer.cpp | 10 ++--- apps/openmw-mp/Script/Functions/World.cpp | 6 --- apps/openmw-mp/Script/Functions/World.hpp | 2 - apps/openmw-mp/Script/ScriptFunctions.hpp | 1 - .../world/ProcessorObjectUnlock.hpp | 31 ------------- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwmechanics/security.cpp | 6 +-- apps/openmw/mwmp/ProcessorInitializer.cpp | 10 ++--- apps/openmw/mwmp/WorldEvent.cpp | 44 ++---------------- apps/openmw/mwmp/WorldEvent.hpp | 3 -- .../world/ProcessorObjectUnlock.hpp | 30 ------------- apps/openmw/mwscript/miscextensions.cpp | 6 +-- components/CMakeLists.txt | 6 +-- .../Controllers/WorldPacketController.cpp | 2 - components/openmw-mp/NetworkMessages.hpp | 1 - .../Packets/World/PacketObjectUnlock.cpp | 45 ------------------- .../Packets/World/PacketObjectUnlock.hpp | 17 ------- 18 files changed, 25 insertions(+), 203 deletions(-) delete mode 100644 apps/openmw-mp/processors/world/ProcessorObjectUnlock.hpp delete mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectUnlock.hpp delete mode 100644 components/openmw-mp/Packets/World/PacketObjectUnlock.cpp delete mode 100644 components/openmw-mp/Packets/World/PacketObjectUnlock.hpp diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 463d99029..4304c3b09 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -134,9 +134,9 @@ set(PROCESSORS_WORLD processors/world/ProcessorObjectDelete.hpp processors/world/ProcessorObjectLock.hpp processors/world/ProcessorObjectMove.hpp processors/world/ProcessorObjectPlace.hpp processors/world/ProcessorObjectRotate.hpp processors/world/ProcessorObjectScale.hpp - processors/world/ProcessorObjectUnlock.hpp processors/world/ProcessorScriptGlobalShort.hpp - processors/world/ProcessorScriptLocalFloat.hpp processors/world/ProcessorScriptLocalShort.hpp - processors/world/ProcessorScriptMemberShort.hpp processors/world/ProcessorVideoPlay.hpp + processors/world/ProcessorScriptGlobalShort.hpp processors/world/ProcessorScriptLocalFloat.hpp + processors/world/ProcessorScriptLocalShort.hpp processors/world/ProcessorScriptMemberShort.hpp + processors/world/ProcessorVideoPlay.hpp ) source_group(tes3mp-server\\processors\\world FILES ${PROCESSORS_WORLD}) diff --git a/apps/openmw-mp/ProcessorInitializer.cpp b/apps/openmw-mp/ProcessorInitializer.cpp index d7c66fe87..f5ddfbdf7 100644 --- a/apps/openmw-mp/ProcessorInitializer.cpp +++ b/apps/openmw-mp/ProcessorInitializer.cpp @@ -52,11 +52,10 @@ #include "processors/world/ProcessorObjectMove.hpp" #include "processors/world/ProcessorObjectRotate.hpp" #include "processors/world/ProcessorObjectScale.hpp" -#include "processors/world/ProcessorObjectUnlock.hpp" -#include "processors/world/ProcessorScriptGlobalShort.hpp" -#include "processors/world/ProcessorScriptLocalFloat.hpp" #include "processors/world/ProcessorScriptLocalShort.hpp" +#include "processors/world/ProcessorScriptLocalFloat.hpp" #include "processors/world/ProcessorScriptMemberShort.hpp" +#include "processors/world/ProcessorScriptGlobalShort.hpp" #include "processors/world/ProcessorVideoPlay.hpp" @@ -108,10 +107,9 @@ void ProcessorInitializer() WorldProcessor::AddProcessor(new ProcessorObjectPlace()); WorldProcessor::AddProcessor(new ProcessorObjectRotate()); WorldProcessor::AddProcessor(new ProcessorObjectScale()); - WorldProcessor::AddProcessor(new ProcessorObjectUnlock()); - WorldProcessor::AddProcessor(new ProcessorScriptGlobalShort()); - WorldProcessor::AddProcessor(new ProcessorScriptLocalFloat()); WorldProcessor::AddProcessor(new ProcessorScriptLocalShort()); + WorldProcessor::AddProcessor(new ProcessorScriptLocalFloat()); WorldProcessor::AddProcessor(new ProcessorScriptMemberShort()); + WorldProcessor::AddProcessor(new ProcessorScriptGlobalShort()); WorldProcessor::AddProcessor(new ProcessorVideoPlay()); } diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/World.cpp index c6fb45680..e4813e0ea 100644 --- a/apps/openmw-mp/Script/Functions/World.cpp +++ b/apps/openmw-mp/Script/Functions/World.cpp @@ -275,12 +275,6 @@ void WorldFunctions::SendObjectLock() noexcept mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_LOCK)->Send(writeEvent.guid); } -void WorldFunctions::SendObjectUnlock() noexcept -{ - mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_UNLOCK)->setEvent(&writeEvent); - mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_UNLOCK)->Send(writeEvent.guid); -} - void WorldFunctions::SendDoorState() noexcept { mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_DOOR_STATE)->setEvent(&writeEvent); diff --git a/apps/openmw-mp/Script/Functions/World.hpp b/apps/openmw-mp/Script/Functions/World.hpp index 892eb2780..05adf1c8d 100644 --- a/apps/openmw-mp/Script/Functions/World.hpp +++ b/apps/openmw-mp/Script/Functions/World.hpp @@ -57,7 +57,6 @@ {"SendObjectPlace", WorldFunctions::SendObjectPlace},\ {"SendObjectScale", WorldFunctions::SendObjectScale},\ {"SendObjectLock", WorldFunctions::SendObjectLock},\ - {"SendObjectUnlock", WorldFunctions::SendObjectUnlock},\ {"SendDoorState", WorldFunctions::SendDoorState},\ {"SendContainer", WorldFunctions::SendContainer},\ \ @@ -124,7 +123,6 @@ public: static void SendObjectPlace() noexcept; static void SendObjectScale() noexcept; static void SendObjectLock() noexcept; - static void SendObjectUnlock() noexcept; static void SendDoorState() noexcept; static void SendContainer() noexcept; diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 2ce3dd210..1787aae7a 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -141,7 +141,6 @@ public: {"OnObjectDelete", Function()}, {"OnObjectScale", Function()}, {"OnObjectLock", Function()}, - {"OnObjectUnlock", Function()}, {"OnDoorState", Function()}, {"OnContainer", Function()}, {"OnPlayerSendMessage", Function()}, diff --git a/apps/openmw-mp/processors/world/ProcessorObjectUnlock.hpp b/apps/openmw-mp/processors/world/ProcessorObjectUnlock.hpp deleted file mode 100644 index db21385a0..000000000 --- a/apps/openmw-mp/processors/world/ProcessorObjectUnlock.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// -// Created by koncord on 03.04.17. -// - -#ifndef OPENMW_PROCESSOROBJECTUNLOCK_HPP -#define OPENMW_PROCESSOROBJECTUNLOCK_HPP - -#include "apps/openmw-mp/WorldProcessor.hpp" - -namespace mwmp -{ - class ProcessorObjectUnlock : public WorldProcessor - { - public: - ProcessorObjectUnlock() - { - BPP_INIT(ID_OBJECT_UNLOCK) - } - - void Do(WorldPacket &packet, Player &player, BaseEvent &event) override - { - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str()); - - packet.Send(true); - - Script::Call(player.getId(), event.cell.getDescription().c_str()); - } - }; -} - -#endif //OPENMW_PROCESSOROBJECTUNLOCK_HPP diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 12bb1c3b3..c346794c8 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -116,7 +116,7 @@ add_openmw_dir (mwmp\\processors\\player ProcessorChatMessage ProcessorGameConso add_openmw_dir (mwmp\\processors\\world BaseObjectProcessor ProcessorContainer ProcessorDoorState ProcessorMusicPlay ProcessorObjectAnimPlay ProcessorObjectDelete ProcessorObjectLock ProcessorObjectMove ProcessorObjectPlace - ProcessorObjectRotate ProcessorObjectScale ProcessorObjectUnlock ProcessorScriptGlobalShort ProcessorScriptLocalFloat + ProcessorObjectRotate ProcessorObjectScale ProcessorScriptGlobalShort ProcessorScriptLocalFloat ProcessorScriptLocalShort ProcessorScriptMemberShort ProcessorVideoPlay ) diff --git a/apps/openmw/mwmechanics/security.cpp b/apps/openmw/mwmechanics/security.cpp index 38ee26299..70a682846 100644 --- a/apps/openmw/mwmechanics/security.cpp +++ b/apps/openmw/mwmechanics/security.cpp @@ -69,12 +69,12 @@ namespace MWMechanics /* Start of tes3mp addition - Send an ID_OBJECT_UNLOCK packet every time an object is unlocked + Send an ID_OBJECT_LOCK packet every time an object is unlocked */ mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); worldEvent->reset(); - worldEvent->addObjectUnlock(lock); - worldEvent->sendObjectUnlock(); + worldEvent->addObjectLock(lock, 0); + worldEvent->sendObjectLock(); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/ProcessorInitializer.cpp b/apps/openmw/mwmp/ProcessorInitializer.cpp index 7fb014d89..481afceab 100644 --- a/apps/openmw/mwmp/ProcessorInitializer.cpp +++ b/apps/openmw/mwmp/ProcessorInitializer.cpp @@ -45,11 +45,10 @@ #include "processors/world/ProcessorObjectPlace.hpp" #include "processors/world/ProcessorObjectRotate.hpp" #include "processors/world/ProcessorObjectScale.hpp" -#include "processors/world/ProcessorObjectUnlock.hpp" -#include "processors/world/ProcessorScriptGlobalShort.hpp" -#include "processors/world/ProcessorScriptLocalFloat.hpp" #include "processors/world/ProcessorScriptLocalShort.hpp" +#include "processors/world/ProcessorScriptLocalFloat.hpp" #include "processors/world/ProcessorScriptMemberShort.hpp" +#include "processors/world/ProcessorScriptGlobalShort.hpp" #include "processors/world/ProcessorVideoPlay.hpp" #include "processors/actor/ProcessorActorAnimFlags.hpp" @@ -106,11 +105,10 @@ void ProcessorInitializer() WorldProcessor::AddProcessor(new ProcessorObjectPlace()); WorldProcessor::AddProcessor(new ProcessorObjectRotate()); WorldProcessor::AddProcessor(new ProcessorObjectScale()); - WorldProcessor::AddProcessor(new ProcessorObjectUnlock()); - WorldProcessor::AddProcessor(new ProcessorScriptGlobalShort()); - WorldProcessor::AddProcessor(new ProcessorScriptLocalFloat()); WorldProcessor::AddProcessor(new ProcessorScriptLocalShort()); + WorldProcessor::AddProcessor(new ProcessorScriptLocalFloat()); WorldProcessor::AddProcessor(new ProcessorScriptMemberShort()); + WorldProcessor::AddProcessor(new ProcessorScriptGlobalShort()); WorldProcessor::AddProcessor(new ProcessorVideoPlay()); ActorProcessor::AddProcessor(new ProcessorActorAnimFlags()); diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index 41cc110a4..fe8b0f75f 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -199,29 +199,10 @@ void WorldEvent::lockObjects(MWWorld::CellStore* cellStore) LOG_APPEND(Log::LOG_VERBOSE, "-- Found %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(), ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum()); - ptrFound.getClass().lock(ptrFound, worldObject.lockLevel); - } - } -} - -void WorldEvent::unlockObjects(MWWorld::CellStore* cellStore) -{ - WorldObject worldObject; - - for (unsigned int i = 0; i < worldObjectCount; i++) - { - worldObject = worldObjects.at(i); - - LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum); - - MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum); - - if (ptrFound) - { - LOG_APPEND(Log::LOG_VERBOSE, "-- Found %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(), - ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum()); - - ptrFound.getClass().unlock(ptrFound); + if (worldObject.lockLevel > 0) + ptrFound.getClass().lock(ptrFound, worldObject.lockLevel); + else + ptrFound.getClass().unlock(ptrFound); } } } @@ -509,17 +490,6 @@ void WorldEvent::addObjectLock(const MWWorld::Ptr& ptr, int lockLevel) addObject(worldObject); } -void WorldEvent::addObjectUnlock(const MWWorld::Ptr& ptr) -{ - cell = *ptr.getCell()->getCell(); - - mwmp::WorldObject worldObject; - worldObject.refId = ptr.getCellRef().getRefId(); - worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; - worldObject.mpNum = ptr.getCellRef().getMpNum(); - addObject(worldObject); -} - void WorldEvent::addObjectScale(const MWWorld::Ptr& ptr, float scale) { cell = *ptr.getCell()->getCell(); @@ -643,12 +613,6 @@ void WorldEvent::sendObjectLock() mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(); } -void WorldEvent::sendObjectUnlock() -{ - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->setEvent(this); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(); -} - void WorldEvent::sendObjectScale() { mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->setEvent(this); diff --git a/apps/openmw/mwmp/WorldEvent.hpp b/apps/openmw/mwmp/WorldEvent.hpp index 2deddf99b..1fe739940 100644 --- a/apps/openmw/mwmp/WorldEvent.hpp +++ b/apps/openmw/mwmp/WorldEvent.hpp @@ -23,7 +23,6 @@ namespace mwmp void placeObjects(MWWorld::CellStore* cellStore); void deleteObjects(MWWorld::CellStore* cellStore); void lockObjects(MWWorld::CellStore* cellStore); - void unlockObjects(MWWorld::CellStore* cellStore); void scaleObjects(MWWorld::CellStore* cellStore); void moveObjects(MWWorld::CellStore* cellStore); void rotateObjects(MWWorld::CellStore* cellStore); @@ -41,7 +40,6 @@ namespace mwmp void addObjectPlace(const MWWorld::Ptr& ptr); void addObjectDelete(const MWWorld::Ptr& ptr); void addObjectLock(const MWWorld::Ptr& ptr, int lockLevel); - void addObjectUnlock(const MWWorld::Ptr& ptr); void addObjectScale(const MWWorld::Ptr& ptr, float scale); void addObjectAnimPlay(const MWWorld::Ptr& ptr, std::string group, int mode); void addDoorState(const MWWorld::Ptr& ptr, int state); @@ -55,7 +53,6 @@ namespace mwmp void sendObjectPlace(); void sendObjectDelete(); void sendObjectLock(); - void sendObjectUnlock(); void sendObjectScale(); void sendObjectAnimPlay(); void sendDoorState(); diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectUnlock.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectUnlock.hpp deleted file mode 100644 index bf4bc086d..000000000 --- a/apps/openmw/mwmp/processors/world/ProcessorObjectUnlock.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Created by koncord on 18.04.17. -// - -#ifndef OPENMW_PROCESSOROBJECTUNLOCK_HPP -#define OPENMW_PROCESSOROBJECTUNLOCK_HPP - - -#include "BaseObjectProcessor.hpp" - -namespace mwmp -{ - class ProcessorObjectUnlock : public BaseObjectProcessor - { - public: - ProcessorObjectUnlock() - { - BPP_INIT(ID_OBJECT_UNLOCK) - } - - virtual void Do(WorldPacket &packet, WorldEvent &event) - { - BaseObjectProcessor::Do(packet, event); - - event.unlockObjects(ptrCellStore); - } - }; -} - -#endif //OPENMW_PROCESSOROBJECTUNLOCK_HPP diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 5301bcdaf..6622fb4cf 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -252,13 +252,13 @@ namespace MWScript /* Start of tes3mp addition - Send an ID_OBJECT_UNLOCK packet every time an object is unlocked + Send an ID_OBJECT_LOCK packet every time an object is unlocked through a script */ mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); worldEvent->reset(); - worldEvent->addObjectUnlock(ptr); - worldEvent->sendObjectUnlock(); + worldEvent->addObjectLock(ptr, 0); + worldEvent->sendObjectLock(); /* End of tes3mp addition */ diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index a003b6d1b..b26786d69 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -184,9 +184,9 @@ add_component_dir (openmw-mp\\Packets\\Player add_component_dir (openmw-mp\\Packets\\World WorldPacket - PacketObjectDelete PacketObjectPlace PacketObjectScale PacketObjectLock PacketObjectUnlock PacketObjectMove - PacketObjectRotate PacketObjectAnimPlay PacketContainer PacketDoorState PacketMusicPlay PacketVideoPlay - PacketScriptLocalShort PacketScriptLocalFloat PacketScriptMemberShort PacketScriptGlobalShort + PacketObjectDelete PacketObjectPlace PacketObjectScale PacketObjectLock PacketObjectMove PacketObjectRotate + PacketObjectAnimPlay PacketContainer PacketDoorState PacketMusicPlay PacketVideoPlay PacketScriptLocalShort + PacketScriptLocalFloat PacketScriptMemberShort PacketScriptGlobalShort ) add_component_dir (fallback diff --git a/components/openmw-mp/Controllers/WorldPacketController.cpp b/components/openmw-mp/Controllers/WorldPacketController.cpp index dece05a83..065fb19ed 100644 --- a/components/openmw-mp/Controllers/WorldPacketController.cpp +++ b/components/openmw-mp/Controllers/WorldPacketController.cpp @@ -6,7 +6,6 @@ #include "../Packets/World/PacketObjectPlace.hpp" #include "../Packets/World/PacketObjectScale.hpp" #include "../Packets/World/PacketObjectLock.hpp" -#include "../Packets/World/PacketObjectUnlock.hpp" #include "../Packets/World/PacketObjectMove.hpp" #include "../Packets/World/PacketObjectRotate.hpp" #include "../Packets/World/PacketObjectAnimPlay.hpp" @@ -37,7 +36,6 @@ mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *pee AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); - AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index a690e196c..914014e21 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -57,7 +57,6 @@ enum GameMessages ID_OBJECT_DELETE, ID_OBJECT_SCALE, ID_OBJECT_LOCK, - ID_OBJECT_UNLOCK, ID_OBJECT_MOVE, ID_OBJECT_ROTATE, ID_OBJECT_ANIM_PLAY, diff --git a/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp b/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp deleted file mode 100644 index d4d405538..000000000 --- a/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include "PacketObjectUnlock.hpp" - -using namespace mwmp; - -PacketObjectUnlock::PacketObjectUnlock(RakNet::RakPeerInterface *peer) : WorldPacket(peer) -{ - packetID = ID_OBJECT_UNLOCK; -} - -void PacketObjectUnlock::Packet(RakNet::BitStream *bs, bool send) -{ - WorldPacket::Packet(bs, send); - - if (!send) - event->worldObjects.clear(); - else - event->worldObjectCount = (unsigned int)(event->worldObjects.size()); - - RW(event->worldObjectCount, send); - - RW(event->cell.mData.mFlags, send); - RW(event->cell.mData.mX, send); - RW(event->cell.mData.mY, send); - RW(event->cell.mName, send); - - WorldObject worldObject; - - for (unsigned int i = 0; i < event->worldObjectCount; i++) - { - if (send) - { - worldObject = event->worldObjects.at(i); - } - - RW(worldObject.refId, send); - RW(worldObject.refNumIndex, send); - RW(worldObject.mpNum, send); - - if (!send) - { - event->worldObjects.push_back(worldObject); - } - } -} diff --git a/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp b/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp deleted file mode 100644 index ceed94301..000000000 --- a/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef OPENMW_PACKETOBJECTUNLOCK_HPP -#define OPENMW_PACKETOBJECTUNLOCK_HPP - -#include - -namespace mwmp -{ - class PacketObjectUnlock : public WorldPacket - { - public: - PacketObjectUnlock(RakNet::RakPeerInterface *peer); - - virtual void Packet(RakNet::BitStream *bs, bool send); - }; -} - -#endif //OPENMW_PACKETOBJECTUNLOCK_HPP