From 83a6fcffaf94ce1b9487303821bad4aa1565a244 Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 3 Apr 2017 20:49:12 +0300 Subject: [PATCH 1/6] Heavily nerfed oxygen and welding fuel tank explosions --- Subsurface/Content/Items/Diving/divinggear.xml | 2 +- Subsurface/Content/Items/Tools/tools.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml index cd1daebd3..2618d0122 100644 --- a/Subsurface/Content/Items/Diving/divinggear.xml +++ b/Subsurface/Content/Items/Diving/divinggear.xml @@ -17,7 +17,7 @@ - + diff --git a/Subsurface/Content/Items/Tools/tools.xml b/Subsurface/Content/Items/Tools/tools.xml index ff6953708..6df87404d 100644 --- a/Subsurface/Content/Items/Tools/tools.xml +++ b/Subsurface/Content/Items/Tools/tools.xml @@ -118,7 +118,7 @@ - + From b063cf3febd63731d46a79e08418cb62f44b9d72 Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 3 Apr 2017 20:59:02 +0300 Subject: [PATCH 2/6] Fire sound fix: the sounds were freed after each round without ever loading them again. The sound objects still existed and had some buffer ID assigned though, causing an incorrect clip to be played or OpenAL errors to be thrown on successive rounds. (Now freed sounds always have a buffer ID of -1) --- Subsurface/Source/Map/FireSource.cs | 17 ++++++----------- Subsurface/Source/Sounds/Sound.cs | 6 +++++- Subsurface/Source/Sounds/SoundManager.cs | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Subsurface/Source/Map/FireSource.cs b/Subsurface/Source/Map/FireSource.cs index 83c113986..d8d57e419 100644 --- a/Subsurface/Source/Map/FireSource.cs +++ b/Subsurface/Source/Map/FireSource.cs @@ -66,10 +66,10 @@ namespace Barotrauma hull = Hull.FindHull(worldPosition, spawningHull); if (hull == null || (!networkEvent && GameMain.Client!=null)) return; - if (fireSoundBasic==null) + if (fireSoundBasic == null) { - fireSoundBasic = Sound.Load("Content/Sounds/fire.ogg"); - fireSoundLarge = Sound.Load("Content/Sounds/firelarge.ogg"); + fireSoundBasic = Sound.Load("Content/Sounds/fire.ogg", false); + fireSoundLarge = Sound.Load("Content/Sounds/firelarge.ogg", false); } hull.AddFireSource(this, !networkEvent); @@ -78,13 +78,8 @@ namespace Barotrauma this.position = worldPosition - new Vector2(-5.0f, 5.0f) - Submarine.Position; - lightSource = new LightSource(this.position, 50.0f, new Color(1.0f, 0.9f, 0.7f), hull == null ? null : hull.Submarine); - - - - //this.position.Y = hull.Rect.Y - hull.Rect.Height; - + size = new Vector2(10.0f, 10.0f); } @@ -356,12 +351,12 @@ namespace Barotrauma lightSource.Remove(); - if (basicSoundIndex > -1) + if (basicSoundIndex > 0) { Sounds.SoundManager.Stop(basicSoundIndex); basicSoundIndex = -1; } - if (largeSoundIndex > -1) + if (largeSoundIndex > 0) { Sounds.SoundManager.Stop(largeSoundIndex); largeSoundIndex = -1; diff --git a/Subsurface/Source/Sounds/Sound.cs b/Subsurface/Source/Sounds/Sound.cs index 9ce6c8079..34714f97d 100644 --- a/Subsurface/Source/Sounds/Sound.cs +++ b/Subsurface/Source/Sounds/Sound.cs @@ -242,7 +242,11 @@ namespace Barotrauma SoundManager.ClearAlSource(AlBufferId); ALHelper.Check(); - if (oggSound != null) oggSound.Dispose(); + if (oggSound != null) + { + oggSound.Dispose(); + oggSound = null; + } } diff --git a/Subsurface/Source/Sounds/SoundManager.cs b/Subsurface/Source/Sounds/SoundManager.cs index e1184e983..4b1202da9 100644 --- a/Subsurface/Source/Sounds/SoundManager.cs +++ b/Subsurface/Source/Sounds/SoundManager.cs @@ -75,8 +75,8 @@ namespace Barotrauma.Sounds public static int Play(Sound sound, Vector2 position, float volume = 1.0f, float lowPassGain = 0.0f, bool loop=false) { - if (Disabled) return -1; - + if (Disabled || sound.AlBufferId == -1) return -1; + for (int i = 1; i < DefaultSourceCount; i++) { //find a source that's free to use (not playing or paused) From b3bbdbf589c36c9fc48b96dd5ca17212d12efaa6 Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 4 Apr 2017 19:54:28 +0300 Subject: [PATCH 3/6] Explosion damage is reduced if there are walls or other solid obstacles between an explosion and a character --- Subsurface/Source/Map/Explosion.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Subsurface/Source/Map/Explosion.cs b/Subsurface/Source/Map/Explosion.cs index ba3a750f3..1dc482b7e 100644 --- a/Subsurface/Source/Map/Explosion.cs +++ b/Subsurface/Source/Map/Explosion.cs @@ -3,6 +3,7 @@ using Barotrauma.Lights; using System; using System.Collections.Generic; using System.Xml.Linq; +using FarseerPhysics; namespace Barotrauma { @@ -116,6 +117,11 @@ namespace Barotrauma foreach (Character c in Character.CharacterList) { + Vector2 explosionPos = worldPosition; + if (c.Submarine != null) explosionPos -= c.Submarine.Position; + + explosionPos = ConvertUnits.ToSimUnits(explosionPos); + foreach (Limb limb in c.AnimController.Limbs) { float dist = Vector2.Distance(limb.WorldPosition, worldPosition); @@ -129,6 +135,9 @@ namespace Barotrauma float distFactor = 1.0f - dist / range; + //solid obstacles between the explosion and the limb reduce the effect of the explosion by 90% + if (Submarine.CheckVisibility(limb.SimPosition, explosionPos) != null) distFactor *= 0.1f; + c.AddDamage(limb.WorldPosition, DamageType.None, damage / c.AnimController.Limbs.Length * distFactor, 0.0f, stun * distFactor, false); From 7cb88e39e961b23aaf44ff7be343f7a546d4b55b Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 5 Apr 2017 21:36:31 +0300 Subject: [PATCH 4/6] Attempt to fix ThrowOrIgnoreBadComparer exception in LightSource.FindRaycastHits. Couldn't reproduce the crash, but I'm guessing it could be caused by CompareCCW not returning 0 if comparing a position to itself. (and if not, at least the exception is caught now) --- Subsurface/Source/Map/Lights/LightSource.cs | 14 +++++++++++++- Subsurface/Source/Utils/MathUtils.cs | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Subsurface/Source/Map/Lights/LightSource.cs b/Subsurface/Source/Map/Lights/LightSource.cs index bc2363e7c..0aeeada4e 100644 --- a/Subsurface/Source/Map/Lights/LightSource.cs +++ b/Subsurface/Source/Map/Lights/LightSource.cs @@ -352,7 +352,19 @@ namespace Barotrauma.Lights points.AddRange(boundaryCorners); var compareCCW = new CompareSegmentPointCW(drawPos); - points.Sort(compareCCW); + try + { + points.Sort(compareCCW); + } + catch (Exception e) + { + StringBuilder sb = new StringBuilder("Constructing light volumes failed! Light pos: "+drawPos+", Hull verts:\n"); + foreach (SegmentPoint sp in points) + { + sb.AppendLine(sp.Pos.ToString()); + } + DebugConsole.ThrowError(sb.ToString(), e); + } List output = new List(); diff --git a/Subsurface/Source/Utils/MathUtils.cs b/Subsurface/Source/Utils/MathUtils.cs index 62f11fab1..30d09ee5d 100644 --- a/Subsurface/Source/Utils/MathUtils.cs +++ b/Subsurface/Source/Utils/MathUtils.cs @@ -512,6 +512,7 @@ namespace Barotrauma public static int Compare(Vector2 a, Vector2 b, Vector2 center) { + if (a == b) return 0; if (a.X - center.X >= 0 && b.X - center.X < 0) return -1; if (a.X - center.X < 0 && b.X - center.X >= 0) return 1; if (a.X - center.X == 0 && b.X - center.X == 0) From 00b7193b6b24e16bcfb32991297681bfb0199b23 Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 6 Apr 2017 21:58:19 +0300 Subject: [PATCH 5/6] Minor optimizations: GUITextBlocks don't reposition and wrap the text when only the position of the text block changes (almost killed my laptop by spamming a bit too many messages to the debug console), less unnecessary floor raycasts --- .../Source/Characters/Animation/Ragdoll.cs | 18 ++++++++++++------ Subsurface/Source/GUI/GUITextBlock.cs | 8 +++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index 9a18e3aaf..3b4b2ea8a 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -853,13 +853,19 @@ namespace Barotrauma inWater = false; headInWater = false; - float waterSurface = ConvertUnits.ToSimUnits(currentHull.Surface); - - float floorY = GetFloorY(); - - if (currentHull.Volume > currentHull.FullVolume * 0.95f || - (waterSurface - floorY > HeadPosition * 0.95f && Collider.SimPosition.Y < waterSurface)) + inWater = false; + if (inWater = currentHull.Volume > currentHull.FullVolume * 0.95f) + { inWater = true; + } + else + { + float waterSurface = ConvertUnits.ToSimUnits(currentHull.Surface); + if (Collider.SimPosition.Y < waterSurface && waterSurface - GetFloorY() > HeadPosition * 0.95f) + { + inWater = true; + } + } } if (flowForce.LengthSquared() > 0.001f) diff --git a/Subsurface/Source/GUI/GUITextBlock.cs b/Subsurface/Source/GUI/GUITextBlock.cs index 3a51e6279..2e83251ed 100644 --- a/Subsurface/Source/GUI/GUITextBlock.cs +++ b/Subsurface/Source/GUI/GUITextBlock.cs @@ -43,6 +43,8 @@ namespace Barotrauma get { return text; } set { + if (Text == value) return; + text = value; wrappedText = value; SetTextPos(); @@ -68,8 +70,12 @@ namespace Barotrauma child.Rect = new Rectangle(child.Rect.X + value.X - rect.X, child.Rect.Y + value.Y - rect.Y, child.Rect.Width, child.Rect.Height); } + if (value.Width != rect.Width || value.Height != rect.Height) + { + SetTextPos(); + } + rect = value; - SetTextPos(); } } From a2e21a78f913ce87052087dc98ece50f2827bbb4 Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 6 Apr 2017 21:58:35 +0300 Subject: [PATCH 6/6] Nicer looking explosions --- .../Content/Particles/ParticlePrefabs.xml | 13 ++++---- Subsurface/Source/Map/Explosion.cs | 30 ++++++++++++++----- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Subsurface/Content/Particles/ParticlePrefabs.xml b/Subsurface/Content/Particles/ParticlePrefabs.xml index 36fbedd31..da68c848f 100644 --- a/Subsurface/Content/Particles/ParticlePrefabs.xml +++ b/Subsurface/Content/Particles/ParticlePrefabs.xml @@ -159,18 +159,21 @@ - + velocitychange="0.0, 1.0" + animduration="1.2" + loopanim="false"> + DimLight(LightSource light) { - float currBrightness= 1.0f; + float currBrightness = 1.0f; float startRange = light.Range; while (light.Color.A > 0.0f) @@ -101,13 +117,13 @@ namespace Barotrauma light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness); light.Range = startRange * currBrightness; - currBrightness -= CoroutineManager.DeltaTime*10.0f; + currBrightness -= CoroutineManager.DeltaTime * 20.0f; yield return CoroutineStatus.Running; } light.Remove(); - + yield return CoroutineStatus.Success; }