Sub editor doesn't allow creating structures with zero width/height, fixed null exceptions when trying to remove a structure without wall sections
This commit is contained in:
@@ -469,14 +469,18 @@ namespace Barotrauma
|
|||||||
GameMain.World.RemoveBody(b);
|
GameMain.World.RemoveBody(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (WallSection s in sections)
|
if (sections != null)
|
||||||
{
|
{
|
||||||
if (s.gap != null)
|
foreach (WallSection s in sections)
|
||||||
{
|
{
|
||||||
s.gap.Remove();
|
if (s.gap != null)
|
||||||
s.gap = null;
|
{
|
||||||
|
s.gap.Remove();
|
||||||
|
s.gap = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
|
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,11 +152,8 @@ namespace Barotrauma
|
|||||||
public override void UpdatePlacing(Camera cam)
|
public override void UpdatePlacing(Camera cam)
|
||||||
{
|
{
|
||||||
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||||
//Vector2 placeSize = size;
|
|
||||||
|
|
||||||
Rectangle newRect = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
|
Rectangle newRect = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
|
||||||
|
|
||||||
|
|
||||||
if (placePosition == Vector2.Zero)
|
if (placePosition == Vector2.Zero)
|
||||||
{
|
{
|
||||||
if (PlayerInput.LeftButtonHeld())
|
if (PlayerInput.LeftButtonHeld())
|
||||||
@@ -164,8 +161,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
newRect.X = (int)position.X;
|
newRect.X = (int)position.X;
|
||||||
newRect.Y = (int)position.Y;
|
newRect.Y = (int)position.Y;
|
||||||
|
|
||||||
//sprite.Draw(spriteBatch, new Vector2(position.X, -position.Y), placeSize, Color.White);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -177,10 +172,14 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (PlayerInput.LeftButtonReleased())
|
if (PlayerInput.LeftButtonReleased())
|
||||||
{
|
{
|
||||||
newRect.Location -= Submarine.MainSub.Position.ToPoint();
|
//don't allow resizing width/height to zero
|
||||||
|
if ((!resizeHorizontal || placeSize.X != 0.0f) && (!resizeVertical || placeSize.Y != 0.0f))
|
||||||
|
{
|
||||||
|
newRect.Location -= Submarine.MainSub.Position.ToPoint();
|
||||||
|
|
||||||
var structure = new Structure(newRect, this, Submarine.MainSub);
|
var structure = new Structure(newRect, this, Submarine.MainSub);
|
||||||
structure.Submarine = Submarine.MainSub;
|
structure.Submarine = Submarine.MainSub;
|
||||||
|
}
|
||||||
|
|
||||||
selected = null;
|
selected = null;
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user