diff --git a/Barotrauma/BarotraumaClient/Source/Map/Levels/CaveGenerator.cs b/Barotrauma/BarotraumaClient/Source/Map/Levels/CaveGenerator.cs index 6bc67482c..942925c27 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Levels/CaveGenerator.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Levels/CaveGenerator.cs @@ -27,7 +27,7 @@ namespace Barotrauma return verticeList; } - public static VertexPositionTexture[] GenerateWallShapes(List cells) + public static VertexPositionTexture[] GenerateWallShapes(List cells, Level level) { float inwardThickness = 500.0f, outWardThickness = 30.0f; @@ -80,6 +80,10 @@ namespace Barotrauma #if DEBUG DebugConsole.ThrowError("Invalid left normal"); #endif + GameAnalyticsManager.AddErrorEventOnce("CaveGenerator.GenerateWallShapes:InvalidLeftNormal:" + level.Seed, + GameAnalyticsSDK.Net.EGAErrorSeverity.Warning, + "Invalid left normal (leftedge: " + leftEdge + ", rightedge: " + rightEdge + ", normal: " + leftNormal + ", seed: " + level.Seed + ")"); + if (cell.body != null) { GameMain.World.RemoveBody(cell.body); @@ -106,6 +110,10 @@ namespace Barotrauma #if DEBUG DebugConsole.ThrowError("Invalid right normal"); #endif + GameAnalyticsManager.AddErrorEventOnce("CaveGenerator.GenerateWallShapes:InvalidRightNormal:" + level.Seed, + GameAnalyticsSDK.Net.EGAErrorSeverity.Warning, + "Invalid right normal (leftedge: " + leftEdge + ", rightedge: " + rightEdge + ", normal: " + rightNormal + ", seed: " + level.Seed + ")"); + if (cell.body != null) { GameMain.World.RemoveBody(cell.body); diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/GameSession.cs b/Barotrauma/BarotraumaShared/Source/GameSession/GameSession.cs index 61394b4c6..91ded070f 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/GameSession.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/GameSession.cs @@ -236,6 +236,7 @@ namespace Barotrauma } GameAnalyticsManager.AddDesignEvent("Submarine:" + submarine.Name); + GameAnalyticsManager.AddDesignEvent("Level", ToolBox.StringToInt(level.Seed)); GameAnalyticsManager.AddProgressionEvent(GameAnalyticsSDK.Net.EGAProgressionStatus.Start, GameMode.Name, (Mission == null ? "None" : Mission.GetType().ToString())); diff --git a/Barotrauma/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs b/Barotrauma/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs index 9cccfc97f..1e08742a2 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs @@ -349,7 +349,7 @@ namespace Barotrauma return pathCells; } - public static List GeneratePolygons(List cells, out List renderTriangles, bool setSolid = true) + public static List GeneratePolygons(List cells, Level level, out List renderTriangles, bool setSolid = true) { renderTriangles = new List(); var bodies = new List(); @@ -428,6 +428,15 @@ namespace Barotrauma Vertices bodyVertices = new Vertices(triangles[i]); var newFixture = FixtureFactory.AttachPolygon(bodyVertices, 5.0f, cellBody); newFixture.UserData = cell; + + if (newFixture.Shape.MassData.Area < FarseerPhysics.Settings.Epsilon) + { + DebugConsole.ThrowError("Invalid triangle created by CaveGenerator (" + triangles[i][0] + ", " + triangles[i][1] + ", " + triangles[i][2] + ")"); + GameAnalyticsManager.AddErrorEventOnce( + "CaveGenerator.GeneratePolygons:InvalidTriangle", + GameAnalyticsSDK.Net.EGAErrorSeverity.Warning, + "Invalid triangle created by CaveGenerator (" + triangles[i][0] + ", " + triangles[i][1] + ", " + triangles[i][2] + "). Seed: " + level.Seed); + } } cell.body = cellBody; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs index 1ab021186..7d7ce68e1 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs @@ -449,11 +449,11 @@ namespace Barotrauma List cellsWithBody = new List(cells); List triangles; - bodies = CaveGenerator.GeneratePolygons(cellsWithBody, out triangles); + bodies = CaveGenerator.GeneratePolygons(cellsWithBody, this, out triangles); #if CLIENT renderer.SetBodyVertices(CaveGenerator.GenerateRenderVerticeList(triangles).ToArray(), generationParams.WallColor); - renderer.SetWallVertices(CaveGenerator.GenerateWallShapes(cells), generationParams.WallColor); + renderer.SetWallVertices(CaveGenerator.GenerateWallShapes(cells, this), generationParams.WallColor); #endif TopBarrier = BodyFactory.CreateEdge(GameMain.World, @@ -700,7 +700,7 @@ namespace Barotrauma SeaFloorTopPos = bottomPositions.Max(p => p.Y); - extraWalls = new LevelWall[] { new LevelWall(bottomPositions, new Vector2(0.0f, -2000.0f), backgroundColor) }; + extraWalls = new LevelWall[] { new LevelWall(bottomPositions, new Vector2(0.0f, -2000.0f), backgroundColor, this) }; BottomBarrier = BodyFactory.CreateEdge(GameMain.World, ConvertUnits.ToSimUnits(new Vector2(borders.X, 0)), diff --git a/Barotrauma/BarotraumaShared/Source/Map/Levels/LevelWall.cs b/Barotrauma/BarotraumaShared/Source/Map/Levels/LevelWall.cs index a0445de16..b79ba05fc 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Levels/LevelWall.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Levels/LevelWall.cs @@ -18,7 +18,7 @@ namespace Barotrauma private List bodies; - public LevelWall(List edgePositions, Vector2 extendAmount, Color color) + public LevelWall(List edgePositions, Vector2 extendAmount, Color color, Level level) { cells = new List(); for (int i = 0; i < edgePositions.Count - 1; i++) @@ -46,13 +46,13 @@ namespace Barotrauma cells.Add(wallCell); } - bodies = CaveGenerator.GeneratePolygons(cells, out List triangles, false); + bodies = CaveGenerator.GeneratePolygons(cells, level, out List triangles, false); #if CLIENT List bodyVertices = CaveGenerator.GenerateRenderVerticeList(triangles); SetBodyVertices(bodyVertices.ToArray(), color); - SetWallVertices(CaveGenerator.GenerateWallShapes(cells), color); + SetWallVertices(CaveGenerator.GenerateWallShapes(cells, level), color); #endif }