Merge branch 'racer_recursion_limited' into 'master'

Check if a leveled creature is in an unloaded cell before deciding it doesn't exist

Closes #4376

See merge request OpenMW/openmw!1420

(cherry picked from commit 782371cb2e7f6653d72305090033557b53bbcf3a)

6d945da7 Check if a leveled creature is in an unloaded cell before deciding it doesn't exist
switch-to-ppa
psi29a 2 years ago
parent 6c7dc2d72f
commit c844e5d045

@ -12,6 +12,7 @@
Bug #3855: AI sometimes spams defensive spells
Bug #3905: Great House Dagoth issues
Bug #4203: Resurrecting an actor should close the loot GUI
Bug #4376: Moved actors don't respawn in their original cells
Bug #4389: NPC's lips do not move if his head model has the NiBSAnimationNode root node
Bug #4602: Robert's Bodies: crash inside createInstance()
Bug #4700: Editor: Incorrect command implementation

@ -64,7 +64,13 @@ namespace MWClass
if (customData.mSpawn)
return;
MWWorld::Ptr creature = (customData.mSpawnActorId == -1) ? MWWorld::Ptr() : MWBase::Environment::get().getWorld()->searchPtrViaActorId(customData.mSpawnActorId);
MWWorld::Ptr creature;
if(customData.mSpawnActorId != -1)
{
creature = MWBase::Environment::get().getWorld()->searchPtrViaActorId(customData.mSpawnActorId);
if(creature.isEmpty())
creature = ptr.getCell()->getMovedActor(customData.mSpawnActorId);
}
if (!creature.isEmpty())
{
const MWMechanics::CreatureStats& creatureStats = creature.getClass().getCreatureStats(creature);

@ -1195,4 +1195,18 @@ namespace MWWorld
|| enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
mRechargingItems.emplace_back(ptr.getBase(), static_cast<float>(enchantment->mData.mCharge));
}
Ptr MWWorld::CellStore::getMovedActor(int actorId) const
{
for(const auto& [cellRef, cell] : mMovedToAnotherCell)
{
if(cellRef->mClass->isActor() && cellRef->mData.getCustomData())
{
Ptr actor(cellRef, cell);
if(actor.getClass().getCreatureStats(actor).getActorId() == actorId)
return actor;
}
}
return {};
}
}

@ -397,6 +397,8 @@ namespace MWWorld
void respawn ();
///< Check mLastRespawn and respawn references if necessary. This is a no-op if the cell is not loaded.
Ptr getMovedActor(int actorId) const;
private:
/// Run through references and store IDs

Loading…
Cancel
Save