mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
cleaned up object movement and fixed a bug regarding local scripts
This commit is contained in:
parent
cfceb45009
commit
c409f1184e
1 changed files with 32 additions and 32 deletions
|
@ -687,15 +687,15 @@ namespace MWWorld
|
|||
void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z)
|
||||
{
|
||||
ESM::Position &pos = ptr.getRefData().getPosition();
|
||||
pos.pos[0] = x, pos.pos[1] = y, pos.pos[2] = z;
|
||||
pos.pos[0] = x;
|
||||
pos.pos[1] = y;
|
||||
pos.pos[2] = z;
|
||||
Ogre::Vector3 vec(x, y, z);
|
||||
|
||||
CellStore *currCell = ptr.getCell();
|
||||
bool isPlayer = ptr == mPlayer->getPlayer();
|
||||
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
|
||||
|
||||
removeContainerScripts(ptr);
|
||||
|
||||
if (*currCell != newCell)
|
||||
{
|
||||
if (isPlayer)
|
||||
|
@ -707,7 +707,8 @@ namespace MWWorld
|
|||
int cellY = newCell.mCell->getGridY();
|
||||
mWorldScene->changeCell(cellX, cellY, pos, false);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (!mWorldScene->isCellActive(*currCell))
|
||||
copyObjectToCell(ptr, newCell, pos);
|
||||
else if (!mWorldScene->isCellActive(newCell))
|
||||
|
@ -715,6 +716,7 @@ namespace MWWorld
|
|||
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
||||
mWorldScene->removeObjectFromScene(ptr);
|
||||
mLocalScripts.remove(ptr);
|
||||
removeContainerScripts (ptr);
|
||||
haveToMove = false;
|
||||
}
|
||||
else
|
||||
|
@ -722,10 +724,18 @@ namespace MWWorld
|
|||
MWWorld::Ptr copy =
|
||||
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
||||
|
||||
addContainerScripts(copy, &newCell);
|
||||
|
||||
mRendering->moveObjectToCell(copy, vec, currCell);
|
||||
|
||||
std::string script =
|
||||
MWWorld::Class::get(ptr).getScript(ptr);
|
||||
if (!script.empty())
|
||||
{
|
||||
mLocalScripts.remove(ptr);
|
||||
removeContainerScripts (ptr);
|
||||
mLocalScripts.add(script, copy);
|
||||
addContainerScripts (copy, &newCell);
|
||||
}
|
||||
|
||||
if (MWWorld::Class::get(ptr).isActor())
|
||||
{
|
||||
MWBase::MechanicsManager *mechMgr =
|
||||
|
@ -734,16 +744,6 @@ namespace MWWorld
|
|||
mechMgr->removeActor(ptr);
|
||||
mechMgr->addActor(copy);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string script =
|
||||
MWWorld::Class::get(ptr).getScript(ptr);
|
||||
if (!script.empty())
|
||||
{
|
||||
mLocalScripts.remove(ptr);
|
||||
mLocalScripts.add(script, copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
ptr.getRefData().setCount(0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue