From 36b33cc1a5a4a5f1ea81369c35d58bac8bd344cb Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 8 Feb 2023 02:28:59 +0100 Subject: [PATCH] Support absence of player and other actors in physics system --- apps/openmw/mwphysics/physicssystem.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 8bf0e39240..8db390a6ea 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -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)