[Client] Rework MechanicsHelper::getTarget() to avoid crashes

0.6.3
David Cernat 7 years ago
parent 7f0549fc4f
commit 509882b5f6

@ -97,7 +97,10 @@ MWWorld::Ptr MechanicsHelper::getPlayerPtr(const Target& target)
mwmp::Target MechanicsHelper::getTarget(const MWWorld::Ptr& ptr)
{
mwmp::Target target;
clearTarget(target);
if (ptr != nullptr)
{
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{
target.isPlayer = true;
@ -120,8 +123,7 @@ mwmp::Target MechanicsHelper::getTarget(const MWWorld::Ptr& ptr)
target.mpNum = ptrRef->getMpNum();
target.name = ptr.getClass().getName(ptr);
}
else
clearTarget(target);
}
}
return target;

Loading…
Cancel
Save