From dd5eb69875a5db7e64403b089b84862b1e3966f6 Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 14 Nov 2016 20:09:37 +0200 Subject: [PATCH 1/4] Fixed respawned characters getting a different team ID than the rest of the characters (causing them to be displayed as a separate team in the crew menu) --- Subsurface/Source/Networking/RespawnManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Subsurface/Source/Networking/RespawnManager.cs b/Subsurface/Source/Networking/RespawnManager.cs index 987cd1068..dfc8872f8 100644 --- a/Subsurface/Source/Networking/RespawnManager.cs +++ b/Subsurface/Source/Networking/RespawnManager.cs @@ -416,6 +416,7 @@ namespace Barotrauma.Networking bool myCharacter = i >= clients.Count; var character = Character.Create(characterInfos[i], shuttleSpawnPoints[i].WorldPosition, !myCharacter, false); + character.TeamID = 1; if (myCharacter) { From f7a9a7772195621c88f602e3af92ab6bb998f0da Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 15 Nov 2016 19:53:25 +0200 Subject: [PATCH 2/4] Some debug assertions to help figure out the cause for the body.FixtureList==null & GetHullsInRange crash reports --- Subsurface/Source/Items/Item.cs | 2 ++ Subsurface/Source/Map/Lights/ConvexHull.cs | 15 ++++++++++++-- Subsurface/Source/Map/Lights/LightSource.cs | 22 ++++++++------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 1cbe1e4ee..d1ca4175b 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -770,6 +770,8 @@ namespace Barotrauma if (body == null || !body.Enabled) return; + System.Diagnostics.Debug.Assert(body.FarseerBody.FixtureList != null); + if (Math.Abs(body.LinearVelocity.X) > 0.01f || Math.Abs(body.LinearVelocity.Y) > 0.01f) { Submarine prevSub = Submarine; diff --git a/Subsurface/Source/Map/Lights/ConvexHull.cs b/Subsurface/Source/Map/Lights/ConvexHull.cs index 7ab0bc15d..c48285988 100644 --- a/Subsurface/Source/Map/Lights/ConvexHull.cs +++ b/Subsurface/Source/Map/Lights/ConvexHull.cs @@ -44,13 +44,24 @@ namespace Barotrauma.Lights class ConvexHullList { + private List list; + public readonly Submarine Submarine; - public List List; + public List List + { + get { return list; } + set + { + Debug.Assert(value != null); + Debug.Assert(!list.Contains(null)); + list = value; + } + } public ConvexHullList(Submarine submarine) { Submarine = submarine; - List = new List(); + list = new List(); } } diff --git a/Subsurface/Source/Map/Lights/LightSource.cs b/Subsurface/Source/Map/Lights/LightSource.cs index 931c9455f..36f7dbd3b 100644 --- a/Subsurface/Source/Map/Lights/LightSource.cs +++ b/Subsurface/Source/Map/Lights/LightSource.cs @@ -164,15 +164,15 @@ namespace Barotrauma.Lights private List GetHullsInRange(Submarine sub) { + //find the current list of hulls in range var chList = hullsInRange.Find(x => x.Submarine == sub); + //not found -> create one if (chList == null) { chList = new ConvexHullList(sub); hullsInRange.Add(chList); } - List list = chList.List; - Vector2 lightPos = position; if (ParentSub == null) @@ -183,15 +183,12 @@ namespace Barotrauma.Lights if (NeedsHullUpdate) { var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub); - - list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); - chList.List = list; + chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); } } //light is outside, convexhull inside a sub else { - //todo: check lightPos -= sub.Position; Rectangle subBorders = sub.Borders; @@ -201,7 +198,7 @@ namespace Barotrauma.Lights if (!MathUtils.CircleIntersectsRectangle(lightPos, range, subBorders)) return null; var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub); - list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); + chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); } } else @@ -215,15 +212,13 @@ namespace Barotrauma.Lights if (NeedsHullUpdate) { var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub); - - list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); - chList.List = list; + chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); } } //light and convexhull are inside different subs else { - if (sub.DockedTo.Contains(ParentSub) && !NeedsHullUpdate) return list; + if (sub.DockedTo.Contains(ParentSub) && !NeedsHullUpdate) return chList.List; lightPos -= (sub.Position - ParentSub.Position); @@ -234,12 +229,11 @@ namespace Barotrauma.Lights if (!MathUtils.CircleIntersectsRectangle(lightPos, range, subBorders)) return null; var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub); - list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); - chList.List = list; + chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); } } - return list; + return chList.List; } public static List GetHullsInRange(Vector2 position, float range, Submarine ParentSub) From 642a1bdd5461e81ff9ab4452a09549046b42bb98 Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 15 Nov 2016 19:56:00 +0200 Subject: [PATCH 3/4] Disabled the "infinite walls" at the edges of the level (don't work correctly with multiple subs), the barrier at the top of the level can't be passed through when outside the borders of the level --- Subsurface/Source/Map/Levels/Level.cs | 22 +++++++++++-------- Subsurface/Source/Map/Levels/LevelRenderer.cs | 7 +++--- Subsurface/Source/Map/SubmarineBody.cs | 15 +++++++++++++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 0f2ff1a6c..e81bf75e3 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -54,7 +54,7 @@ namespace Barotrauma public const int GridCellSize = 2000; private List[,] cellGrid; - private WrappingWall[,] wrappingWalls; + //private WrappingWall[,] wrappingWalls; //private float shaftHeight; @@ -97,10 +97,10 @@ namespace Barotrauma get { return ruins; } } - public WrappingWall[,] WrappingWalls - { - get { return wrappingWalls; } - } + //public WrappingWall[,] WrappingWalls + //{ + // get { return wrappingWalls; } + //} public string Seed { @@ -440,6 +440,7 @@ namespace Barotrauma renderer.PlaceSprites(generationParams.BackgroundSpriteAmount); + /* wrappingWalls = new WrappingWall[2, 2]; Rectangle ignoredArea = new Rectangle((int)startPosition.X, 0, (int)(endPosition.X - startPosition.X), borders.Height); @@ -465,7 +466,7 @@ namespace Barotrauma { cells.AddRange(wrappingWalls[side, i].Cells); } - } + }*/ ShaftBody = BodyFactory.CreateEdge(GameMain.World, ConvertUnits.ToSimUnits(new Vector2(borders.X, 0)), @@ -809,10 +810,11 @@ namespace Barotrauma public void Update(float deltaTime) { + /* if (Submarine.MainSub != null) { WrappingWall.UpdateWallShift(Submarine.MainSub.WorldPosition, wrappingWalls); - } + }*/ if (Hull.renderer != null) { @@ -884,6 +886,7 @@ namespace Barotrauma } } + /* if (wrappingWalls == null) return cells; for (int side = 0; side < 2; side++) @@ -899,7 +902,7 @@ namespace Barotrauma cells.Add(cell); } } - } + }*/ return cells; } @@ -918,6 +921,7 @@ namespace Barotrauma ruins = null; } + /* if (wrappingWalls!=null) { for (int side = 0; side < 2; side++) @@ -929,7 +933,7 @@ namespace Barotrauma } wrappingWalls = null; - } + }*/ cells = null; diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs index f1e5148c1..0910925c2 100644 --- a/Subsurface/Source/Map/Levels/LevelRenderer.cs +++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs @@ -219,6 +219,7 @@ namespace Barotrauma graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(bodyVertices.VertexCount / 3.0f)); + /* for (int side = 0; side < 2; side++) { for (int i = 0; i < 2; i++) @@ -234,7 +235,7 @@ namespace Barotrauma PrimitiveType.TriangleList, 0, (int)Math.Floor(level.WrappingWalls[side, i].BodyVertices.VertexCount / 3.0f)); } - } + }*/ graphicsDevice.SetVertexBuffer(wallVertices); @@ -243,7 +244,7 @@ namespace Barotrauma basicEffect.CurrentTechnique = basicEffect.Techniques["BasicEffect_Texture"]; basicEffect.CurrentTechnique.Passes[0].Apply(); graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wallVertices.VertexCount / 3.0f)); - + /* for (int side = 0; side < 2; side++) { for (int i = 0; i < 2; i++) @@ -260,7 +261,7 @@ namespace Barotrauma (int)Math.Floor(level.WrappingWalls[side, i].WallVertices.VertexCount / 3.0f)); } - } + }*/ } diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs index c17d6c302..c9c904ef9 100644 --- a/Subsurface/Source/Map/SubmarineBody.cs +++ b/Subsurface/Source/Map/SubmarineBody.cs @@ -243,6 +243,21 @@ namespace Barotrauma return; } + //if outside left or right edge of the level + if (Position.X < 0 || Position.X > Level.Loaded.Size.X) + { + Rectangle worldBorders = Borders; + worldBorders.Location += Position.ToPoint(); + + //push the sub back below the upper "barrier" of the level + if (worldBorders.Y > Level.Loaded.Size.Y) + { + Body.LinearVelocity = new Vector2( + Body.LinearVelocity.X, + Math.Min(Body.LinearVelocity.Y, ConvertUnits.ToSimUnits(Level.Loaded.Size.Y - worldBorders.Y))); + } + } + //------------------------- Vector2 totalForce = CalculateBuoyancy(); From 184c6858cdbcd94f0118f7e840dfd23b7ecbe565 Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 15 Nov 2016 20:48:52 +0200 Subject: [PATCH 4/4] Removing orphans in PathFinder.GenerateNodes, fixed autopilot steering the wrong way if clicking an already selected destination tickbox --- Subsurface/Source/Characters/AI/PathFinder.cs | 8 ++------ Subsurface/Source/Items/Components/Machines/Steering.cs | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Subsurface/Source/Characters/AI/PathFinder.cs b/Subsurface/Source/Characters/AI/PathFinder.cs index 7ddef2f11..78846b22c 100644 --- a/Subsurface/Source/Characters/AI/PathFinder.cs +++ b/Subsurface/Source/Characters/AI/PathFinder.cs @@ -61,6 +61,7 @@ namespace Barotrauma } var nodeList = nodes.Values.ToList(); + nodeList.RemoveAll(n => n.connections.Count == 0); foreach (PathNode node in nodeList) { node.distances = new List(); @@ -69,6 +70,7 @@ namespace Barotrauma node.distances.Add(Vector2.Distance(node.position, node.connections[i].position)); } } + return nodeList; } } @@ -198,12 +200,6 @@ namespace Barotrauma { Vector2 nodePos = node.Position; - //if node waypoint is one of submarine waypoints outside the sub, transform position - //if (node.Waypoint!=null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull==null) - //{ - // nodePos -= node.Waypoint.Submarine.Position; - //} - float dist = Vector2.Distance(end, nodePos); if (dist < closestDist || endNode == null) { diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs index c10a905fa..c9250a5cc 100644 --- a/Subsurface/Source/Items/Components/Machines/Steering.cs +++ b/Subsurface/Source/Items/Components/Machines/Steering.cs @@ -424,10 +424,10 @@ namespace Barotrauma.Items.Components maintainPosTickBox.Selected = false; posToMaintain = null; + tickBox.Selected = true; UpdatePath(); - tickBox.Selected = true; return true; }