From dba0d47973a51db53f57dff6e12384e0ee561e56 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 23 Apr 2017 22:25:16 +0300 Subject: [PATCH] [Client] Revert position changes on invalid cell changes to fix glitches --- apps/openmw/mwworld/worldimp.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 7c427981c..dffd9da09 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1167,6 +1167,17 @@ namespace MWWorld MWWorld::Ptr World::moveObject(const Ptr &ptr, CellStore* newCell, float x, float y, float z, bool movePhysics) { + /* + Start of tes3mp addition + + If we choose to deny this move because it's part of an unapproved cell change, we should also revert the Ptr back to its + original coordinates, so keep track of them + */ + ESM::Position originalPos = ptr.getRefData().getPosition(); + /* + End of tes3mp addition + */ + ESM::Position pos = ptr.getRefData().getPosition(); pos.pos[0] = x; @@ -1187,15 +1198,21 @@ namespace MWWorld /* Start of tes3mp addition - Check if a DedicatedPlayer or DedicatedActor's new Ptr cell is the same as their packet cell, and deny the Ptr's cell change - if it is not + Check if a DedicatedPlayer or DedicatedActor's new Ptr cell is the same as their packet cell, and deny the Ptr's movement and + cell change if it is not */ if (mwmp::PlayerList::isDedicatedPlayer(ptr) && !mwmp::Main::get().getCellController()->isSameCell(mwmp::PlayerList::getPlayer(ptr)->cell, *newCell->getCell())) + { + ptr.getRefData().setPosition(originalPos); return ptr; + } else if (mwmp::Main::get().getCellController()->isDedicatedActor(ptr) && !mwmp::Main::get().getCellController()->isSameCell(mwmp::Main::get().getCellController()->getDedicatedActor(ptr)->cell, *newCell->getCell())) + { + ptr.getRefData().setPosition(originalPos); return ptr; + } /* End of tes3mp addition */