Workaround to null reference exceptions in Character.WriteStatus: it seems AnimController can be null when reading the message, which suggests that the character has been removed (e.g. turned to a husk, eaten by something).
This commit is contained in:
@@ -21,11 +21,18 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return enabled;
|
return enabled && !Removed;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == enabled) return;
|
if (value == enabled) return;
|
||||||
|
|
||||||
|
if (Removed)
|
||||||
|
{
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
enabled = value;
|
enabled = value;
|
||||||
|
|
||||||
foreach (Limb limb in AnimController.Limbs)
|
foreach (Limb limb in AnimController.Limbs)
|
||||||
@@ -980,7 +987,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public bool CanInteractWith(Character c, float maxDist = 200.0f)
|
public bool CanInteractWith(Character c, float maxDist = 200.0f)
|
||||||
{
|
{
|
||||||
if (c == this || !c.enabled || c.info == null || !c.IsHumanoid || !c.CanBeSelected) return false;
|
if (c == this || !c.Enabled || c.info == null || !c.IsHumanoid || !c.CanBeSelected) return false;
|
||||||
|
|
||||||
maxDist = ConvertUnits.ToSimUnits(maxDist);
|
maxDist = ConvertUnits.ToSimUnits(maxDist);
|
||||||
if (Vector2.DistanceSquared(SimPosition, c.SimPosition) > maxDist * maxDist) return false;
|
if (Vector2.DistanceSquared(SimPosition, c.SimPosition) > maxDist * maxDist) return false;
|
||||||
|
|||||||
@@ -474,18 +474,27 @@ namespace Barotrauma
|
|||||||
if (isDead)
|
if (isDead)
|
||||||
{
|
{
|
||||||
msg.Write((byte)causeOfDeath);
|
msg.Write((byte)causeOfDeath);
|
||||||
List<int> severedJointIndices = new List<int>();
|
|
||||||
for (int i = 0; i < AnimController.LimbJoints.Length; i++)
|
if (AnimController?.LimbJoints == null)
|
||||||
{
|
{
|
||||||
if (AnimController.LimbJoints[i] != null && AnimController.LimbJoints[i].IsSevered)
|
//0 limbs severed
|
||||||
{
|
msg.Write((byte)0);
|
||||||
severedJointIndices.Add(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
msg.Write((byte)severedJointIndices.Count);
|
else
|
||||||
foreach (int jointIndex in severedJointIndices)
|
|
||||||
{
|
{
|
||||||
msg.Write((byte)jointIndex);
|
List<int> severedJointIndices = new List<int>();
|
||||||
|
for (int i = 0; i < AnimController.LimbJoints.Length; i++)
|
||||||
|
{
|
||||||
|
if (AnimController.LimbJoints[i] != null && AnimController.LimbJoints[i].IsSevered)
|
||||||
|
{
|
||||||
|
severedJointIndices.Add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg.Write((byte)severedJointIndices.Count);
|
||||||
|
foreach (int jointIndex in severedJointIndices)
|
||||||
|
{
|
||||||
|
msg.Write((byte)jointIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user