From 4eb72eecb14f2bc7b9747362ce7246b9d9f20c64 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 6 Jul 2018 18:39:14 +0300 Subject: [PATCH] [Client] Fix crash for invalid CellRefs in MechanicsHelper::getTarget() --- apps/openmw/mwmp/MechanicsHelper.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp index b1c9fd856..19a67dbb1 100644 --- a/apps/openmw/mwmp/MechanicsHelper.cpp +++ b/apps/openmw/mwmp/MechanicsHelper.cpp @@ -111,12 +111,17 @@ mwmp::Target MechanicsHelper::getTarget(const MWWorld::Ptr& ptr) else { MWWorld::CellRef *ptrRef = &ptr.getCellRef(); - - target.isPlayer = false; - target.refId = ptrRef->getRefId(); - target.refNumIndex = ptrRef->getRefNum().mIndex; - target.mpNum = ptrRef->getMpNum(); - target.name = ptr.getClass().getName(ptr); + + if (ptrRef) + { + target.isPlayer = false; + target.refId = ptrRef->getRefId(); + target.refNumIndex = ptrRef->getRefNum().mIndex; + target.mpNum = ptrRef->getMpNum(); + target.name = ptr.getClass().getName(ptr); + } + else + clearTarget(target); } return target;