1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Fixed travel window to use the rotation part of ESM::Position

This commit is contained in:
scrawl 2013-04-15 03:13:25 +02:00
parent 2693b78536
commit 7fcaffefb0

View File

@ -141,21 +141,22 @@ namespace MWGui
int x,y; int x,y;
bool interior = _sender->getUserString("interior") == "y"; bool interior = _sender->getUserString("interior") == "y";
MWBase::Environment::get().getWorld()->positionToIndex(pos.pos[0],pos.pos[1],x,y); MWBase::Environment::get().getWorld()->positionToIndex(pos.pos[0],pos.pos[1],x,y);
MWWorld::CellStore* cell; if(interior)
if(interior) cell = MWBase::Environment::get().getWorld()->getInterior(cellname); MWBase::Environment::get().getWorld()->changeToInteriorCell(cellname, pos);
else else
{ {
cell = MWBase::Environment::get().getWorld()->getExterior(x,y); ESM::Position playerPos = player.getRefData().getPosition();
ESM::Position PlayerPos = player.getRefData().getPosition(); float d = Ogre::Vector3(pos.pos[0], pos.pos[1], 0).distance(
float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); Ogre::Vector3(playerPos.pos[0], playerPos.pos[1], 0));
int time = int(d /MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTravelTimeMult")->getFloat()); int hours = static_cast<int>(d /MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTravelTimeMult")->getFloat());
for(int i = 0;i < time;i++) for(int i = 0;i < hours;i++)
{ {
MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats (); MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats ();
} }
MWBase::Environment::get().getWorld()->advanceTime(time); MWBase::Environment::get().getWorld()->advanceTime(hours);
MWBase::Environment::get().getWorld()->changeToExteriorCell(pos);
} }
MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]);
MWWorld::Class::get(player).adjustPosition(player); MWWorld::Class::get(player).adjustPosition(player);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel);