1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Merge branch 'fix_potential_crash' into 'master'

Fix potential crashes

See merge request OpenMW/openmw!2699
This commit is contained in:
psi29a 2023-02-08 20:06:09 +00:00
commit 92b42624b0
2 changed files with 6 additions and 3 deletions

View File

@ -822,7 +822,8 @@ namespace MWPhysics
// copy new ptr position in temporary vector. player is handled separately as its movement might change active
// cell.
mActorsPositions.clear();
mActorsPositions.reserve(mActors.size() - 1);
if (!mActors.empty())
mActorsPositions.reserve(mActors.size() - 1);
for (const auto& [ptr, physicActor] : mActors)
{
if (physicActor.get() == player)
@ -833,7 +834,8 @@ namespace MWPhysics
for (const auto& [ptr, pos] : mActorsPositions)
world->moveObject(ptr, pos, false, false);
world->moveObject(player->getPtr(), player->getSimulationPosition(), false, false);
if (player != nullptr)
world->moveObject(player->getPtr(), player->getSimulationPosition(), false, false);
}
void PhysicsSystem::updateAnimatedCollisionShape(const MWWorld::Ptr& object)

View File

@ -61,7 +61,8 @@ namespace Resource
{
// If ref count is greater than 1, the object has an external reference.
// If the timestamp is yet to be initialized, it needs to be updated too.
if (itr->second.first->referenceCount() > 1 || itr->second.second == 0.0)
if ((itr->second.first != nullptr && itr->second.first->referenceCount() > 1)
|| itr->second.second == 0.0)
itr->second.second = referenceTime;
}
}