From 12b149c598c0c4b8dcb6fac64697481a6bb3cb51 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 30 Apr 2022 21:30:11 +0300 Subject: [PATCH] [VR Client] Use ObjectActivate when activating objects in VR --- apps/openmw/mwvr/vrinputmanager.cpp | 20 +++++++++++++++++++- apps/openmw/mwworld/player.cpp | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwvr/vrinputmanager.cpp b/apps/openmw/mwvr/vrinputmanager.cpp index 29caf1046..7cf467b32 100644 --- a/apps/openmw/mwvr/vrinputmanager.cpp +++ b/apps/openmw/mwvr/vrinputmanager.cpp @@ -186,7 +186,25 @@ namespace MWVR { if (wm->getMode() != MWGui::GM_Container && wm->getMode() != MWGui::GM_Inventory) return; - wm->getInventoryWindow()->pickUpObject(ptr); + /* + Start of tes3mp change (major) + + Disable unilateral picking up of objects on this client + + Instead, send an ID_OBJECT_ACTIVATE packet every time an attempt is made to pick up + an item here and expect the server's reply to our packet to cause the actual + picking up of items + */ + //wm->getInventoryWindow()->pickUpObject(ptr); + + mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList(); + objectList->reset(); + objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY; + objectList->addObjectActivate(ptr, MWMechanics::getPlayer()); + objectList->sendObjectActivate(); + /* + End of tes3mp change (major) + */ } else { diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 779842d83..e67ed94a2 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -237,7 +237,25 @@ namespace MWWorld void Player::activate(MWWorld::Ptr obj) { - MWBase::Environment::get().getWorld()->activate(obj, getPlayer()); + /* + Start of tes3mp change (major) + + Disable unilateral activating of objects on this client + + Instead, send an ID_OBJECT_ACTIVATE packet every time an attempt to activate + an object is made here and expect the server's reply to our packet to cause + the actual activation of objects + */ + //MWBase::Environment::get().getWorld()->activate(obj, getPlayer()); + + mwmp::ObjectList* objectList = mwmp::Main::get().getNetworking()->getObjectList(); + objectList->reset(); + objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY; + objectList->addObjectActivate(obj, MWMechanics::getPlayer()); + objectList->sendObjectActivate(); + /* + End of tes3mp change (major) + */ } void Player::activate()