mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-16 08:42:23 +00:00
Use extract/insert instead of erase/emplace
When we call moveObject(), we might trigger a change of cell for the actor, which in turn triggers updatePtr(). The erase/emplace construct invalidate references, whereas extract/insert do not. The reason is was working before !1075 is because we were always "refreshing" the reference by a call to getActor().
This commit is contained in:
parent
547bc4a252
commit
bc738c5640
@ -519,13 +519,12 @@ namespace MWPhysics
|
|||||||
mObjects.emplace(updated, std::move(obj));
|
mObjects.emplace(updated, std::move(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorMap::iterator foundActor = mActors.find(old);
|
auto actorNode = mActors.extract(old);
|
||||||
if (foundActor != mActors.end())
|
if (!actorNode.empty())
|
||||||
{
|
{
|
||||||
auto actor = foundActor->second;
|
actorNode.key() = updated;
|
||||||
actor->updatePtr(updated);
|
actorNode.mapped()->updatePtr(updated);
|
||||||
mActors.erase(foundActor);
|
mActors.insert(std::move(actorNode));
|
||||||
mActors.emplace(updated, std::move(actor));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& [_, actor] : mActors)
|
for (auto& [_, actor] : mActors)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user