diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml index 875804ca1..d537af6c2 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 @@ - + 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"> + 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) @@ -1069,15 +1076,7 @@ namespace Barotrauma float tfloorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction; float targetY = tfloorY + Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor; - - 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 = true; - + if (Math.Abs(Collider.SimPosition.Y - targetY) > 0.01f && Collider.SimPosition.Y DimLight(LightSource light) { - float currBrightness= 1.0f; + float currBrightness = 1.0f; float startRange = light.Range; while (light.Color.A > 0.0f) @@ -99,13 +116,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; } @@ -115,6 +132,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); @@ -128,6 +150,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); diff --git a/Subsurface/Source/Map/FireSource.cs b/Subsurface/Source/Map/FireSource.cs index 93a583c4d..518f61f2b 100644 --- a/Subsurface/Source/Map/FireSource.cs +++ b/Subsurface/Source/Map/FireSource.cs @@ -68,10 +68,10 @@ namespace Barotrauma if (!isNetworkMessage && 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); @@ -80,13 +80,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); } @@ -358,12 +353,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/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/Networking/FileTransfer/FileReceiver.cs b/Subsurface/Source/Networking/FileTransfer/FileReceiver.cs index 0afc107a3..d84c24702 100644 --- a/Subsurface/Source/Networking/FileTransfer/FileReceiver.cs +++ b/Subsurface/Source/Networking/FileTransfer/FileReceiver.cs @@ -207,6 +207,19 @@ namespace Barotrauma.Networking DebugConsole.Log(" Sequence channel: " + inc.SequenceChannel); } + if (!Directory.Exists(downloadFolder)) + { + try + { + Directory.CreateDirectory(downloadFolder); + } + catch (Exception e) + { + DebugConsole.ThrowError("Could not start a file transfer: failed to create the folder \""+downloadFolder+"\".", e); + return; + } + } + var newTransfer = new FileTransferIn(inc.SenderConnection, Path.Combine(downloadFolder, fileName), (FileTransferType)fileType); newTransfer.SequenceChannel = inc.SequenceChannel; newTransfer.Status = FileTransferStatus.Receiving; diff --git a/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs b/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs index c4a9d7a2b..de0dd1538 100644 --- a/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs +++ b/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs @@ -97,19 +97,30 @@ namespace Barotrauma.Networking msg.Write((byte)ClientNetObject.ENTITY_STATE); Write(msg, eventsToSync); } - + + private UInt16? firstNewID; + /// /// Read the events from the message, ignoring ones we've already received /// public void Read(ServerNetObject type, NetIncomingMessage msg, float sendingTime) { UInt16 unreceivedEntityEventCount = 0; - UInt16 firstNewID = 0; if (type == ServerNetObject.ENTITY_EVENT_INITIAL) { unreceivedEntityEventCount = msg.ReadUInt16(); firstNewID = msg.ReadUInt16(); + + DebugConsole.NewMessage("received midround syncing msg, unreceived: "+unreceivedEntityEventCount+", first new ID: "+firstNewID, Microsoft.Xna.Framework.Color.Yellow); + + } + else if (firstNewID != null) + { + DebugConsole.NewMessage("midround syncing complete, switching to ID "+ (UInt16)(firstNewID - 1), Microsoft.Xna.Framework.Color.Yellow); + + lastReceivedID = (UInt16)(firstNewID - 1); + firstNewID = null; } UInt16 firstEventID = msg.ReadUInt16(); @@ -165,15 +176,6 @@ namespace Barotrauma.Networking } msg.ReadPadBits(); } - - if (type == ServerNetObject.ENTITY_EVENT_INITIAL) - { - if (lastReceivedID == unreceivedEntityEventCount - 1 || - unreceivedEntityEventCount == 0) - { - lastReceivedID = (UInt16)(firstNewID - 1); - } - } } protected override void WriteEvent(NetBuffer buffer, NetEntityEvent entityEvent, Client recipient = null) @@ -195,6 +197,8 @@ namespace Barotrauma.Networking lastReceivedID = 0; + firstNewID = null; + events.Clear(); eventLastSent.Clear(); } 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) 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)