1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 08:49:55 +00:00

Merge remote-tracking branch 'zini/master' into animation2

Conflicts:
	apps/openmw/mwworld/worldimp.cpp
This commit is contained in:
Chris Robinson 2013-02-05 03:26:46 -08:00
commit 4bd1e63ac1

View file

@ -303,26 +303,26 @@ namespace MWWorld
{ {
return mGlobalVariables->getGlobals(); return mGlobalVariables->getGlobals();
} }
std::string World::getCurrentCellName () const std::string World::getCurrentCellName () const
{ {
std::string name; std::string name;
Ptr::CellStore *cell = mWorldScene->getCurrentCell(); Ptr::CellStore *cell = mWorldScene->getCurrentCell();
if (cell->mCell->isExterior()) if (cell->mCell->isExterior())
{ {
if (cell->mCell->mName != "") if (cell->mCell->mName != "")
{ {
name = cell->mCell->mName; name = cell->mCell->mName;
} }
else else
{ {
const ESM::Region* region = const ESM::Region* region =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search(cell->mCell->mRegion); MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search(cell->mCell->mRegion);
if (region) if (region)
name = region->mName; name = region->mName;
else else
{ {
const ESM::GameSetting *setting = const ESM::GameSetting *setting =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search("sDefaultCellname"); MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search("sDefaultCellname");
@ -332,13 +332,13 @@ namespace MWWorld
name = "Wilderness"; name = "Wilderness";
} }
} }
} }
else else
{ {
name = cell->mCell->mName; name = cell->mCell->mName;
} }
return name; return name;
} }
@ -427,12 +427,12 @@ namespace MWWorld
if (!reference.getRefData().isEnabled()) if (!reference.getRefData().isEnabled())
{ {
reference.getRefData().enable(); reference.getRefData().enable();
if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end() && reference.getRefData().getCount()) if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end() && reference.getRefData().getCount())
mWorldScene->addObjectToScene (reference); mWorldScene->addObjectToScene (reference);
} }
} }
void World::removeContainerScripts(const Ptr& reference) void World::removeContainerScripts(const Ptr& reference)
{ {
if( reference.getTypeName()==typeid (ESM::Container).name() || if( reference.getTypeName()==typeid (ESM::Container).name() ||
@ -457,7 +457,7 @@ namespace MWWorld
if (reference.getRefData().isEnabled()) if (reference.getRefData().isEnabled())
{ {
reference.getRefData().disable(); reference.getRefData().disable();
if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end() && reference.getRefData().getCount()) if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end() && reference.getRefData().getCount())
mWorldScene->removeObjectFromScene (reference); mWorldScene->removeObjectFromScene (reference);
} }
@ -688,14 +688,14 @@ namespace MWWorld
void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z) void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z)
{ {
ESM::Position &pos = ptr.getRefData().getPosition(); 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); Ogre::Vector3 vec(x, y, z);
CellStore *currCell = ptr.getCell(); CellStore *currCell = ptr.getCell();
bool isPlayer = ptr == mPlayer->getPlayer(); bool isPlayer = ptr == mPlayer->getPlayer();
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer; bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
removeContainerScripts(ptr);
if (*currCell != newCell) if (*currCell != newCell)
{ {
@ -719,6 +719,7 @@ namespace MWWorld
MWWorld::Class::get(ptr).copyToCell(ptr, newCell); MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
mWorldScene->removeObjectFromScene(ptr); mWorldScene->removeObjectFromScene(ptr);
mLocalScripts.remove(ptr); mLocalScripts.remove(ptr);
removeContainerScripts (ptr);
haveToMove = false; haveToMove = false;
} }
else else
@ -726,17 +727,18 @@ namespace MWWorld
MWWorld::Ptr copy = MWWorld::Ptr copy =
MWWorld::Class::get(ptr).copyToCell(ptr, newCell); MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
addContainerScripts(copy, &newCell);
mRendering->moveObjectToCell(copy, vec, currCell); mRendering->moveObjectToCell(copy, vec, currCell);
MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager(); MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager();
mechMgr->updateCell(copy); mechMgr->updateCell(copy);
std::string script = MWWorld::Class::get(ptr).getScript(ptr); std::string script =
if(!script.empty()) MWWorld::Class::get(ptr).getScript(ptr);
if (!script.empty())
{ {
mLocalScripts.remove(ptr); mLocalScripts.remove(ptr);
removeContainerScripts (ptr);
mLocalScripts.add(script, copy); mLocalScripts.add(script, copy);
addContainerScripts (copy, &newCell);
} }
} }
ptr.getRefData().setCount(0); ptr.getRefData().setCount(0);