diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index da43743a1..41c90f961 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -242,6 +242,10 @@ void DedicatedPlayer::UpdatePtr(MWWorld::Ptr newPtr) ptr.mCell = newPtr.mCell; ptr.mRef = newPtr.mRef; ptr.mContainerStore = newPtr.mContainerStore; + + // Disallow this player's reference from moving across cells until + // the correct packet is sent by the player + ptr.getBase()->canChangeCell = false; } @@ -400,5 +404,9 @@ void DedicatedPlayer::updateCell() cellStore = world->getExterior(cell.mCellId.mIndex.mX, cell.mCellId.mIndex.mY); else cellStore = world->getInterior(cell.mName); + + // Allow this player's reference to move across a cell now that + // a manual cell update has been called + ptr.getBase()->canChangeCell = true; UpdatePtr(world->moveObject(ptr, cellStore, pos.pos[0], pos.pos[1], pos.pos[2])); } diff --git a/apps/openmw/mwworld/livecellref.cpp b/apps/openmw/mwworld/livecellref.cpp index 32830b5fb..6d138d7e1 100644 --- a/apps/openmw/mwworld/livecellref.cpp +++ b/apps/openmw/mwworld/livecellref.cpp @@ -14,6 +14,7 @@ MWWorld::LiveCellRefBase::LiveCellRefBase(const std::string& type, const ESM::CellRef &cref) : mClass(&Class::get(type)), mRef(cref), mData(cref) { + canChangeCell = true; } void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state) diff --git a/apps/openmw/mwworld/livecellref.hpp b/apps/openmw/mwworld/livecellref.hpp index 2631f513f..f42e1611a 100644 --- a/apps/openmw/mwworld/livecellref.hpp +++ b/apps/openmw/mwworld/livecellref.hpp @@ -27,6 +27,11 @@ namespace MWWorld * and individual type-dependent data. */ MWWorld::CellRef mRef; + + /* Added by TES3MP to prevent dedicated players' references from automatically + * and unpredictably moving across exterior cell boundaries on clients + */ + bool canChangeCell; /** runtime-data */ RefData mData; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index b178e6e52..3ab9aa665 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1141,7 +1141,7 @@ namespace MWWorld bool haveToMove = isPlayer || (currCell && mWorldScene->isCellActive(*currCell)); MWWorld::Ptr newPtr = ptr; - if (currCell != newCell) + if (currCell != newCell && ptr.getBase()->canChangeCell) { removeContainerScripts(ptr);