mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-15 14:42:35 +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));
|
||||
}
|
||||
|
||||
ActorMap::iterator foundActor = mActors.find(old);
|
||||
if (foundActor != mActors.end())
|
||||
auto actorNode = mActors.extract(old);
|
||||
if (!actorNode.empty())
|
||||
{
|
||||
auto actor = foundActor->second;
|
||||
actor->updatePtr(updated);
|
||||
mActors.erase(foundActor);
|
||||
mActors.emplace(updated, std::move(actor));
|
||||
actorNode.key() = updated;
|
||||
actorNode.mapped()->updatePtr(updated);
|
||||
mActors.insert(std::move(actorNode));
|
||||
}
|
||||
|
||||
for (auto& [_, actor] : mActors)
|
||||
|
Loading…
x
Reference in New Issue
Block a user