Bunch of fixes to null reference exceptions caused by removing characters mid-round

This commit is contained in:
Joonas Rikkonen
2017-06-21 16:56:35 +03:00
parent 4ac9aa09c6
commit 38f92acf8e
4 changed files with 28 additions and 8 deletions
@@ -1513,22 +1513,28 @@ namespace Barotrauma
public void Remove()
{
foreach (Limb l in Limbs)
if (Limbs != null)
{
l.Remove();
foreach (Limb l in Limbs)
{
l.Remove();
}
Limbs = null;
}
Limbs = null;
foreach (PhysicsBody b in collider)
{
b.Remove();
}
foreach (RevoluteJoint joint in LimbJoints)
if (LimbJoints != null)
{
GameMain.World.RemoveJoint(joint);
foreach (RevoluteJoint joint in LimbJoints)
{
GameMain.World.RemoveJoint(joint);
}
LimbJoints = null;
}
LimbJoints = null;
list.Remove(this);
}