Do not adjust the player position when loading a savegame (Fixes #2089)

openmw-39
scrawl 9 years ago
parent 92c2a10de4
commit 5bd8ef247d

@ -231,15 +231,15 @@ namespace MWBase
virtual float getTimeScaleFactor() const = 0; 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. ///< Move to interior cell.
///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes ///< @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. ///< Move to exterior cell.
///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes ///< @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 ///< @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; virtual const ESM::Cell *getExterior (const std::string& cellName) const = 0;

@ -49,7 +49,7 @@ namespace MWScript
world->getPlayer().setTeleported(true); world->getPlayer().setTeleported(true);
if (world->findExteriorPosition(cell, pos)) if (world->findExteriorPosition(cell, pos))
{ {
world->changeToExteriorCell(pos); world->changeToExteriorCell(pos, true);
world->fixPosition(world->getPlayerPtr()); world->fixPosition(world->getPlayerPtr());
} }
else else
@ -57,7 +57,7 @@ namespace MWScript
// Change to interior even if findInteriorPosition() // Change to interior even if findInteriorPosition()
// yields false. In this case position will be zero-point. // yields false. In this case position will be zero-point.
world->findInteriorPosition(cell, pos); 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; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
world->changeToExteriorCell (pos); world->changeToExteriorCell (pos, true);
world->fixPosition(world->getPlayerPtr()); world->fixPosition(world->getPlayerPtr());
} }
}; };

@ -495,7 +495,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
const ESM::CellId& cellId = ptr.getCell()->getCell()->getCellId(); const ESM::CellId& cellId = ptr.getCell()->getCell()->getCellId();
// Use detectWorldSpaceChange=false, otherwise some of the data we just loaded would be cleared again // 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, // 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. // but some mods may be using it as a reload detector.

@ -64,9 +64,9 @@ namespace MWWorld
{ {
world->getPlayer().setTeleported(true); world->getPlayer().setTeleported(true);
if (mCellName.empty()) if (mCellName.empty())
world->changeToExteriorCell (mPosition); world->changeToExteriorCell (mPosition, true);
else else
world->changeToInteriorCell (mCellName, mPosition); world->changeToInteriorCell (mCellName, mPosition, true);
} }
else else
{ {

@ -444,7 +444,8 @@ namespace MWWorld
float z = pos.rot[2]; float z = pos.rot[2];
world->rotateObject(player, x, y, z); world->rotateObject(player, x, y, z);
player.getClass().adjustPosition(player, true); if (adjustPlayerPos)
player.getClass().adjustPosition(player, true);
} }
MWBase::MechanicsManager *mechMgr = MWBase::MechanicsManager *mechMgr =
@ -493,7 +494,7 @@ namespace MWWorld
return mActiveCells; 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); CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName);
bool loadcell = (mCurrentCell == NULL); bool loadcell = (mCurrentCell == NULL);
@ -519,7 +520,8 @@ namespace MWWorld
float z = position.rot[2]; float z = position.rot[2];
world->rotateObject(world->getPlayerPtr(), x, y, z); 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); MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5);
return; return;
} }

@ -103,7 +103,7 @@ namespace MWWorld
bool hasCellChanged() const; bool hasCellChanged() const;
///< Has the set of active cells changed, since the last frame? ///< 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. ///< Move to interior cell.
/// @param changeEvent Set cellChanged flag? /// @param changeEvent Set cellChanged flag?

@ -251,13 +251,13 @@ namespace MWWorld
if (findExteriorPosition (mStartCell, pos)) if (findExteriorPosition (mStartCell, pos))
{ {
changeToExteriorCell (pos); changeToExteriorCell (pos, true);
fixPosition(getPlayerPtr()); fixPosition(getPlayerPtr());
} }
else else
{ {
findInteriorPosition (mStartCell, pos); findInteriorPosition (mStartCell, pos);
changeToInteriorCell (mStartCell, pos); changeToInteriorCell (mStartCell, pos, true);
} }
} }
else else
@ -962,7 +962,7 @@ namespace MWWorld
return mTimeScale->getFloat(); 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(); mPhysics->clearQueuedMovement();
@ -976,11 +976,11 @@ namespace MWWorld
} }
removeContainerScripts(getPlayerPtr()); removeContainerScripts(getPlayerPtr());
mWorldScene->changeToInteriorCell(cellName, position, changeEvent); mWorldScene->changeToInteriorCell(cellName, position, adjustPlayerPos, changeEvent);
addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell()); 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(); mPhysics->clearQueuedMovement();
@ -991,17 +991,17 @@ namespace MWWorld
mRendering->notifyWorldSpaceChanged(); mRendering->notifyWorldSpaceChanged();
} }
removeContainerScripts(getPlayerPtr()); removeContainerScripts(getPlayerPtr());
mWorldScene->changeToExteriorCell(position, true, changeEvent); mWorldScene->changeToExteriorCell(position, adjustPlayerPos, changeEvent);
addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell()); 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) if (!changeEvent)
mCurrentWorldSpace = cellId.mWorldspace; mCurrentWorldSpace = cellId.mWorldspace;
if (cellId.mPaged) if (cellId.mPaged)
changeToExteriorCell (position, changeEvent); changeToExteriorCell (position, adjustPlayerPos, changeEvent);
else else
changeToInteriorCell (cellId.mWorldspace, position, changeEvent); changeToInteriorCell (cellId.mWorldspace, position, changeEvent);
} }
@ -1137,7 +1137,7 @@ namespace MWWorld
if (isPlayer) if (isPlayer)
{ {
if (!newCell->isExterior()) if (!newCell->isExterior())
changeToInteriorCell(Misc::StringUtils::lowerCase(newCell->getCell()->mName), pos); changeToInteriorCell(Misc::StringUtils::lowerCase(newCell->getCell()->mName), pos, false);
else else
{ {
if (mWorldScene->isCellActive(*newCell)) if (mWorldScene->isCellActive(*newCell))

@ -324,15 +324,15 @@ namespace MWWorld
virtual float getTimeScaleFactor() const; 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. ///< Move to interior cell.
///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes ///< @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. ///< Move to exterior cell.
///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes ///< @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 ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes
virtual const ESM::Cell *getExterior (const std::string& cellName) const; virtual const ESM::Cell *getExterior (const std::string& cellName) const;

Loading…
Cancel
Save