From a699b4128aaaa54a72f43875b451b273c59788d5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 9 Dec 2015 00:48:51 +0100 Subject: [PATCH] Add isInCell checks to PlaceAt and PlaceItem (Fixes #2873) Avoids the game crashing when a script calls these functions before the player has been moved to the starting location. --- apps/openmw/mwscript/transformationextensions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 592168687..474f2a392 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -458,6 +458,10 @@ namespace MWScript runtime.pop(); MWWorld::Ptr player = MWMechanics::getPlayer(); + + if (!player.isInCell()) + throw std::runtime_error("player not in a cell"); + MWWorld::CellStore* store = NULL; if (player.getCell()->isExterior()) { @@ -505,6 +509,9 @@ namespace MWScript if (count<0) throw std::runtime_error ("count must be non-negative"); + if (!actor.isInCell()) + throw std::runtime_error ("actor is not in a cell"); + for (int i=0; i