mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-09 04:15:40 -04:00
Merge branch 'corpsecollector' into 'master'
Ensure corpses of actors that have moved cells are cleaned up See merge request OpenMW/openmw!4793
This commit is contained in:
commit
82b1d1b78e
@ -1263,26 +1263,48 @@ namespace MWWorld
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CellRefList<ESM::Creature>::List::iterator it(get<ESM::Creature>().mList.begin());
|
// Actors need to respawn here even if they've been moved to another cell
|
||||||
it != get<ESM::Creature>().mList.end(); ++it)
|
for (LiveCellRefBase& base : get<ESM::Creature>().mList)
|
||||||
{
|
{
|
||||||
Ptr ptr = getCurrentPtr(&*it);
|
Ptr ptr = getCurrentPtr(&base);
|
||||||
clearCorpse(ptr, mStore);
|
clearCorpse(ptr, mStore);
|
||||||
ptr.getClass().respawn(ptr);
|
ptr.getClass().respawn(ptr);
|
||||||
}
|
}
|
||||||
for (CellRefList<ESM::NPC>::List::iterator it(get<ESM::NPC>().mList.begin());
|
for (LiveCellRefBase& base : get<ESM::NPC>().mList)
|
||||||
it != get<ESM::NPC>().mList.end(); ++it)
|
|
||||||
{
|
{
|
||||||
Ptr ptr = getCurrentPtr(&*it);
|
Ptr ptr = getCurrentPtr(&base);
|
||||||
clearCorpse(ptr, mStore);
|
clearCorpse(ptr, mStore);
|
||||||
ptr.getClass().respawn(ptr);
|
ptr.getClass().respawn(ptr);
|
||||||
}
|
}
|
||||||
forEachType<ESM::CreatureLevList>([](Ptr ptr) {
|
for (LiveCellRefBase& base : get<ESM::CreatureLevList>().mList)
|
||||||
// no need to clearCorpse, handled as part of get<ESM::Creature>()
|
{
|
||||||
|
Ptr ptr = getCurrentPtr(&base);
|
||||||
if (!ptr.mRef->isDeleted())
|
if (!ptr.mRef->isDeleted())
|
||||||
ptr.getClass().respawn(ptr);
|
ptr.getClass().respawn(ptr);
|
||||||
return true;
|
}
|
||||||
});
|
for (const auto& [base, _] : mMovedHere)
|
||||||
|
{
|
||||||
|
switch (base->getType())
|
||||||
|
{
|
||||||
|
case ESM::Creature::sRecordId:
|
||||||
|
case ESM::NPC::sRecordId:
|
||||||
|
case ESM::CreatureLevList::sRecordId:
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr(base, this);
|
||||||
|
if (ptr.mRef->isDeleted())
|
||||||
|
continue;
|
||||||
|
// Remove actors that have been dead a while, but don't belong here and didn't get hit by the
|
||||||
|
// logic above
|
||||||
|
if (ptr.getClass().isActor())
|
||||||
|
clearCorpse(ptr, mStore);
|
||||||
|
else // Respawn lists in their new position
|
||||||
|
ptr.getClass().respawn(ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user