diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index de5f15d64..e9a76c565 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -231,15 +231,15 @@ namespace MWBase virtual float getTimeScaleFactor() const = 0; - virtual void changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool changeEvent=true) = 0; + virtual void changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent=true) = 0; ///< Move to interior cell. ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes - virtual void changeToExteriorCell (const ESM::Position& position, bool changeEvent=true) = 0; + virtual void changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos, bool changeEvent=true) = 0; ///< Move to exterior cell. ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes - virtual void changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool changeEvent=true) = 0; + virtual void changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent=true) = 0; ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes virtual const ESM::Cell *getExterior (const std::string& cellName) const = 0; diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 513c1cc42..43e8318b2 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -49,7 +49,7 @@ namespace MWScript world->getPlayer().setTeleported(true); if (world->findExteriorPosition(cell, pos)) { - world->changeToExteriorCell(pos); + world->changeToExteriorCell(pos, true); world->fixPosition(world->getPlayerPtr()); } else @@ -57,7 +57,7 @@ namespace MWScript // Change to interior even if findInteriorPosition() // yields false. In this case position will be zero-point. world->findInteriorPosition(cell, pos); - world->changeToInteriorCell(cell, pos); + world->changeToInteriorCell(cell, pos, true); } } }; @@ -82,7 +82,7 @@ namespace MWScript pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - world->changeToExteriorCell (pos); + world->changeToExteriorCell (pos, true); world->fixPosition(world->getPlayerPtr()); } }; diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index 6cd8ec43b..e4b26f8b7 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -495,7 +495,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str const ESM::CellId& cellId = ptr.getCell()->getCell()->getCellId(); // Use detectWorldSpaceChange=false, otherwise some of the data we just loaded would be cleared again - MWBase::Environment::get().getWorld()->changeToCell (cellId, ptr.getRefData().getPosition(), false); + MWBase::Environment::get().getWorld()->changeToCell (cellId, ptr.getRefData().getPosition(), false, false); // Vanilla MW will restart startup scripts when a save game is loaded. This is unintuitive, // but some mods may be using it as a reload detector. diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 031f07258..c9315283d 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -64,9 +64,9 @@ namespace MWWorld { world->getPlayer().setTeleported(true); if (mCellName.empty()) - world->changeToExteriorCell (mPosition); + world->changeToExteriorCell (mPosition, true); else - world->changeToInteriorCell (mCellName, mPosition); + world->changeToInteriorCell (mCellName, mPosition, true); } else { diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index ba2829469..c7ac757b2 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -444,7 +444,8 @@ namespace MWWorld float z = pos.rot[2]; world->rotateObject(player, x, y, z); - player.getClass().adjustPosition(player, true); + if (adjustPlayerPos) + player.getClass().adjustPosition(player, true); } MWBase::MechanicsManager *mechMgr = @@ -493,7 +494,7 @@ namespace MWWorld return mActiveCells; } - void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool changeEvent) + void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) { CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); bool loadcell = (mCurrentCell == NULL); @@ -519,7 +520,8 @@ namespace MWWorld float z = position.rot[2]; world->rotateObject(world->getPlayerPtr(), x, y, z); - world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true); + if (adjustPlayerPos) + world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true); MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5); return; } diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 6cba9c3be..33886eed4 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -103,7 +103,7 @@ namespace MWWorld bool hasCellChanged() const; ///< Has the set of active cells changed, since the last frame? - void changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool changeEvent=true); + void changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent=true); ///< Move to interior cell. /// @param changeEvent Set cellChanged flag? diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 948612623..8f3fcbd41 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -251,13 +251,13 @@ namespace MWWorld if (findExteriorPosition (mStartCell, pos)) { - changeToExteriorCell (pos); + changeToExteriorCell (pos, true); fixPosition(getPlayerPtr()); } else { findInteriorPosition (mStartCell, pos); - changeToInteriorCell (mStartCell, pos); + changeToInteriorCell (mStartCell, pos, true); } } else @@ -962,7 +962,7 @@ namespace MWWorld return mTimeScale->getFloat(); } - void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool changeEvent) + void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) { mPhysics->clearQueuedMovement(); @@ -976,11 +976,11 @@ namespace MWWorld } removeContainerScripts(getPlayerPtr()); - mWorldScene->changeToInteriorCell(cellName, position, changeEvent); + mWorldScene->changeToInteriorCell(cellName, position, adjustPlayerPos, changeEvent); addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell()); } - void World::changeToExteriorCell (const ESM::Position& position, bool changeEvent) + void World::changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) { mPhysics->clearQueuedMovement(); @@ -991,17 +991,17 @@ namespace MWWorld mRendering->notifyWorldSpaceChanged(); } removeContainerScripts(getPlayerPtr()); - mWorldScene->changeToExteriorCell(position, true, changeEvent); + mWorldScene->changeToExteriorCell(position, adjustPlayerPos, changeEvent); addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell()); } - void World::changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool changeEvent) + void World::changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) { if (!changeEvent) mCurrentWorldSpace = cellId.mWorldspace; if (cellId.mPaged) - changeToExteriorCell (position, changeEvent); + changeToExteriorCell (position, adjustPlayerPos, changeEvent); else changeToInteriorCell (cellId.mWorldspace, position, changeEvent); } @@ -1137,7 +1137,7 @@ namespace MWWorld if (isPlayer) { if (!newCell->isExterior()) - changeToInteriorCell(Misc::StringUtils::lowerCase(newCell->getCell()->mName), pos); + changeToInteriorCell(Misc::StringUtils::lowerCase(newCell->getCell()->mName), pos, false); else { if (mWorldScene->isCellActive(*newCell)) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index d1298a39b..c9a1d415d 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -324,15 +324,15 @@ namespace MWWorld virtual float getTimeScaleFactor() const; - virtual void changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool changeEvent = true); + virtual void changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true); ///< Move to interior cell. ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes - virtual void changeToExteriorCell (const ESM::Position& position, bool changeEvent = true); + virtual void changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true); ///< Move to exterior cell. ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes - virtual void changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool changeEvent=true); + virtual void changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent=true); ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes virtual const ESM::Cell *getExterior (const std::string& cellName) const;