[Client] Fix crash for invalid CellRefs in MechanicsHelper::getTarget()

0.6.3
David Cernat 7 years ago
parent 4b30a44816
commit 4eb72eecb1

@ -112,12 +112,17 @@ mwmp::Target MechanicsHelper::getTarget(const MWWorld::Ptr& ptr)
{ {
MWWorld::CellRef *ptrRef = &ptr.getCellRef(); MWWorld::CellRef *ptrRef = &ptr.getCellRef();
if (ptrRef)
{
target.isPlayer = false; target.isPlayer = false;
target.refId = ptrRef->getRefId(); target.refId = ptrRef->getRefId();
target.refNumIndex = ptrRef->getRefNum().mIndex; target.refNumIndex = ptrRef->getRefNum().mIndex;
target.mpNum = ptrRef->getMpNum(); target.mpNum = ptrRef->getMpNum();
target.name = ptr.getClass().getName(ptr); target.name = ptr.getClass().getName(ptr);
} }
else
clearTarget(target);
}
return target; return target;
} }

Loading…
Cancel
Save