(652745ae0) Fix a crash due to invalid physics when scaling the Mudraptor. If the ragdoll still has invalid settings after trying to reset it, just freeze it to prevent crashing. Return boolean and make CheckValidity public so that we can check and react to the invalid ragdoll state elsewhere.

This commit is contained in:
Joonas Rikkonen
2019-03-26 17:08:53 +02:00
parent 56d1f5a054
commit 705d05a308
2 changed files with 54 additions and 15 deletions
@@ -118,6 +118,19 @@ namespace Barotrauma
instance = this;
}
private void Reset()
{
AnimParams.ForEach(a => a.Reset(true));
RagdollParams.Reset(true);
RagdollParams.ClearHistory();
CurrentAnimation.ClearHistory();
if (!character.Removed)
{
character.Remove();
}
character = null;
}
public override void Deselect()
{
base.Deselect();
@@ -128,15 +141,7 @@ namespace Barotrauma
isEndlessRunner = false;
if (character != null)
{
AnimParams.ForEach(a => a.Reset(true));
RagdollParams.Reset(true);
RagdollParams.ClearHistory();
CurrentAnimation.ClearHistory();
if (!character.Removed)
{
character.Remove();
}
character = null;
Reset();
}
GameMain.World.ProcessChanges();
}
@@ -393,6 +398,12 @@ namespace Barotrauma
}
if (!isFreezed)
{
if (character.AnimController.Invalid)
{
Reset();
SpawnCharacter(currentCharacterConfig);
}
Submarine.MainSub.SetPrevTransform(Submarine.MainSub.Position);
Submarine.MainSub.Update((float)deltaTime);