fix object moving

This commit is contained in:
greye 2012-08-06 18:20:48 +04:00
parent ee97a204f2
commit d32a61b928
2 changed files with 27 additions and 22 deletions

View file

@ -167,67 +167,71 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& ce
else else
return Ptr(); return Ptr();
} }
MWWorld::Ptr ptr;
if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.activators.find (name)) if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.activators.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.potions.find (name)) if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.potions.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = cell.appas.find (name)) if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = cell.appas.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Armor> *ref = cell.armors.find (name)) if (MWWorld::LiveCellRef<ESM::Armor> *ref = cell.armors.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Book> *ref = cell.books.find (name)) if (MWWorld::LiveCellRef<ESM::Book> *ref = cell.books.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Clothing> *ref = cell.clothes.find (name)) if (MWWorld::LiveCellRef<ESM::Clothing> *ref = cell.clothes.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Container> *ref = cell.containers.find (name)) if (MWWorld::LiveCellRef<ESM::Container> *ref = cell.containers.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Creature> *ref = cell.creatures.find (name)) if (MWWorld::LiveCellRef<ESM::Creature> *ref = cell.creatures.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Door> *ref = cell.doors.find (name)) if (MWWorld::LiveCellRef<ESM::Door> *ref = cell.doors.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = cell.ingreds.find (name)) if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = cell.ingreds.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = cell.creatureLists.find (name)) if (MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = cell.creatureLists.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::ItemLevList> *ref = cell.itemLists.find (name)) if (MWWorld::LiveCellRef<ESM::ItemLevList> *ref = cell.itemLists.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Light> *ref = cell.lights.find (name)) if (MWWorld::LiveCellRef<ESM::Light> *ref = cell.lights.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Tool> *ref = cell.lockpicks.find (name)) if (MWWorld::LiveCellRef<ESM::Tool> *ref = cell.lockpicks.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = cell.miscItems.find (name)) if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = cell.miscItems.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::NPC> *ref = cell.npcs.find (name)) if (MWWorld::LiveCellRef<ESM::NPC> *ref = cell.npcs.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Probe> *ref = cell.probes.find (name)) if (MWWorld::LiveCellRef<ESM::Probe> *ref = cell.probes.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Repair> *ref = cell.repairs.find (name)) if (MWWorld::LiveCellRef<ESM::Repair> *ref = cell.repairs.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Static> *ref = cell.statics.find (name)) if (MWWorld::LiveCellRef<ESM::Static> *ref = cell.statics.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Weapon> *ref = cell.weapons.find (name)) if (MWWorld::LiveCellRef<ESM::Weapon> *ref = cell.weapons.find (name))
return Ptr (ref, &cell); ptr = Ptr (ref, &cell);
if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) {
return ptr;
}
return Ptr(); return Ptr();
} }

View file

@ -545,7 +545,7 @@ namespace MWWorld
bool World::moveObjectImp (const Ptr& ptr, float x, float y, float z) 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(); 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;
@ -558,6 +558,7 @@ namespace MWWorld
} else { } else {
currCell = ptr.getCell(); currCell = ptr.getCell();
} }
bool haveToMove = mWorldScene->isCellActive(*currCell);
if (currCell) { if (currCell) {
if (!(currCell->cell->data.flags & ESM::Cell::Interior)) { if (!(currCell->cell->data.flags & ESM::Cell::Interior)) {
@ -575,7 +576,7 @@ namespace MWWorld
MWBase::Environment::get().getWorld()->getExterior(cellX, cellY); MWBase::Environment::get().getWorld()->getExterior(cellX, cellY);
// placeObject() handles both target cell states // placeObject() handles both target cell states
// with active current cell // with inactive current cell
if (!mWorldScene->isCellActive(*currCell)) { if (!mWorldScene->isCellActive(*currCell)) {
placeObject(ptr, *newCell, pos); placeObject(ptr, *newCell, pos);
haveToMove = false; haveToMove = false;