(65e2b5073) Fixed crashing when an item that requires aim to use is used by something else than a character. Not sure if there are any vanilla items that can cause this error, but can be reproduced for example by creating a projectile that RequiresAimToUse and triggers the Use method when it hits something. Closes #1602

This commit is contained in:
Joonas Rikkonen
2019-06-12 16:44:18 +03:00
parent e3ca616fff
commit b598459179
2 changed files with 1 additions and 53 deletions

View File

@@ -632,58 +632,6 @@ namespace Barotrauma
}
}
if ((PlayerInput.KeyDown(Keys.LeftControl) || PlayerInput.KeyDown(Keys.RightControl)))
{
if (PlayerInput.KeyHit(Keys.N))
{
float minX = selectedList[0].WorldRect.X, maxX = selectedList[0].WorldRect.Right;
for (int i = 0; i < selectedList.Count; i++)
{
minX = Math.Min(minX, selectedList[i].WorldRect.X);
maxX = Math.Max(maxX, selectedList[i].WorldRect.Right);
}
float centerX = (minX + maxX) / 2.0f;
foreach (MapEntity me in selectedList)
{
me.FlipX(false);
me.Move(new Vector2((centerX - me.WorldPosition.X) * 2.0f, 0.0f));
}
}
else if (PlayerInput.KeyHit(Keys.M))
{
float minY = selectedList[0].WorldRect.Y - selectedList[0].WorldRect.Height, maxY = selectedList[0].WorldRect.Y;
for (int i = 0; i < selectedList.Count; i++)
{
minY = Math.Min(minY, selectedList[i].WorldRect.Y - selectedList[i].WorldRect.Height);
maxY = Math.Max(maxY, selectedList[i].WorldRect.Y);
}
float centerY = (minY + maxY) / 2.0f;
foreach (MapEntity me in selectedList)
{
me.FlipY(false);
me.Move(new Vector2(0.0f, (centerY - me.WorldPosition.Y) * 2.0f));
}
}
}
FilteredSelectedList.Clear();
if (selectedList.Count == 0) return;
foreach (var e in selectedList)
{
if (e is Gap) { continue; }
FilteredSelectedList.Add(e);
}
var first = FilteredSelectedList.FirstOrDefault();
if (first != null)
{
first.UpdateEditing(cam);
if (first.ResizeHorizontal || first.ResizeVertical)
{
first.UpdateResizing(cam);
}
}
if ((PlayerInput.KeyDown(Keys.LeftControl) || PlayerInput.KeyDown(Keys.RightControl)))
{
if (PlayerInput.KeyHit(Keys.N))

View File

@@ -1553,7 +1553,7 @@ namespace Barotrauma
public void Use(float deltaTime, Character character = null, Limb targetLimb = null)
{
if (RequireAimToUse && !character.IsKeyDown(InputType.Aim))
if (RequireAimToUse && (character == null || !character.IsKeyDown(InputType.Aim)))
{
return;
}