diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index cffaf70ea..822aa78d6 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -167,67 +167,71 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& ce else return Ptr(); } + MWWorld::Ptr ptr; if (MWWorld::LiveCellRef *ref = cell.activators.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.potions.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.appas.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.armors.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.books.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.clothes.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.containers.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.creatures.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.doors.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.ingreds.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.creatureLists.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.itemLists.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.lights.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.lockpicks.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.miscItems.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.npcs.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.probes.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.repairs.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.statics.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef *ref = cell.weapons.find (name)) - return Ptr (ref, &cell); + ptr = Ptr (ref, &cell); + if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) { + return ptr; + } return Ptr(); } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 215fbb30e..dc7f25751 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -545,7 +545,7 @@ namespace MWWorld bool World::moveObjectImp (const Ptr& ptr, float x, float y, float z) { - bool cellChanged = false, haveToMove = true; + bool cellChanged = false; ESM::Position &pos = ptr.getRefData().getPosition(); pos.pos[0] = x, pos.pos[1] = y, pos.pos[2] = z; @@ -558,6 +558,7 @@ namespace MWWorld } else { currCell = ptr.getCell(); } + bool haveToMove = mWorldScene->isCellActive(*currCell); if (currCell) { if (!(currCell->cell->data.flags & ESM::Cell::Interior)) { @@ -575,7 +576,7 @@ namespace MWWorld MWBase::Environment::get().getWorld()->getExterior(cellX, cellY); // placeObject() handles both target cell states - // with active current cell + // with inactive current cell if (!mWorldScene->isCellActive(*currCell)) { placeObject(ptr, *newCell, pos); haveToMove = false;