diff --git a/Subsurface/Data/ContentPackages/Vanilla 0.3.xml b/Subsurface/Data/ContentPackages/Vanilla 0.3.xml index 226776875..9348a625f 100644 --- a/Subsurface/Data/ContentPackages/Vanilla 0.3.xml +++ b/Subsurface/Data/ContentPackages/Vanilla 0.3.xml @@ -1,40 +1,41 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/Subsurface/Properties/AssemblyInfo.cs b/Subsurface/Properties/AssemblyInfo.cs index f40f11617..63dd17eb2 100644 --- a/Subsurface/Properties/AssemblyInfo.cs +++ b/Subsurface/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.2.4")] -[assembly: AssemblyFileVersion("0.3.2.4")] +[assembly: AssemblyVersion("0.3.2.5")] +[assembly: AssemblyFileVersion("0.3.2.5")] diff --git a/Subsurface/Source/GUI/GUIMessageBox.cs b/Subsurface/Source/GUI/GUIMessageBox.cs index 545eb9409..5d25a0f2c 100644 --- a/Subsurface/Source/GUI/GUIMessageBox.cs +++ b/Subsurface/Source/GUI/GUIMessageBox.cs @@ -45,7 +45,11 @@ namespace Barotrauma var frame = new GUIFrame(new Rectangle(0,0,width,height), null, Alignment.Center, GUI.Style, this); new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, GUI.Style, frame, true); - new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text, Color.Transparent, Color.White, textAlignment, GUI.Style, frame, true); + if (!string.IsNullOrWhiteSpace(text)) + { + new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text, + Color.Transparent, Color.White, textAlignment, GUI.Style, frame, true); + } int x = 0; this.Buttons = new GUIButton[buttons.Length]; diff --git a/Subsurface/Source/GameSession/GameModes/Tutorials/BasicTutorial.cs b/Subsurface/Source/GameSession/GameModes/Tutorials/BasicTutorial.cs index 65fe392fb..e0883ab83 100644 --- a/Subsurface/Source/GameSession/GameModes/Tutorials/BasicTutorial.cs +++ b/Subsurface/Source/GameSession/GameModes/Tutorials/BasicTutorial.cs @@ -333,13 +333,21 @@ namespace Barotrauma.Tutorials //fix everything except the command windows foreach (Structure w in Structure.WallList) { - if (windows.Contains(w)) continue; + bool isWindow = windows.Contains(w); for (int i = 0; i < w.SectionCount; i++) { if (!w.SectionIsLeaking(i)) continue; - w.AddDamage(i, -100000.0f); + if (isWindow) + { + w.AddDamage(i, -w.SectionDamage(i) * 0.2f); + } + else + { + w.AddDamage(i, -100000.0f); + } + } } @@ -365,8 +373,19 @@ namespace Barotrauma.Tutorials infoBox = CreateInfoFrame("You should quickly find yourself a diving mask or a diving suit. " + "There are some in the room next to the airlock."); + bool divingMaskSelected = false; + while (!HasItem("Diving Mask") && !HasItem("Diving Suit")) { + if (!divingMaskSelected && + Character.Controlled.ClosestItem != null && Character.Controlled.ClosestItem.Name == "Diving Suit") + { + infoBox = CreateInfoFrame("The can only be one item in each inventory slot, so you need to take off " + +"the jumpsuit if you wish to wear a diving suit."); + + divingMaskSelected = true; + } + yield return CoroutineStatus.Running; } diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index 6ef73dd3c..a2fe024df 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -317,7 +317,8 @@ namespace Barotrauma.Items.Components GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X, (int)markerPos.Y, 5, 5), Color.LightGreen); spriteBatch.DrawString(GUI.SmallFont, label, new Vector2(markerPos.X + 10, markerPos.Y), Color.LightGreen); - spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen); + spriteBatch.DrawString(GUI.SmallFont, (int)(dist * Physics.DisplayToRealWorldRatio) + " m", + new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen); } public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message) diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs index 5781a17db..9bc6e3bc1 100644 --- a/Subsurface/Source/Items/Components/Machines/Steering.cs +++ b/Subsurface/Source/Items/Components/Machines/Steering.cs @@ -164,7 +164,22 @@ namespace Barotrauma.Items.Components Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40); //GUI.DrawRectangle(spriteBatch, velRect, Color.White, false); + + if (Submarine.Loaded != null && Level.Loaded != null) + { + Vector2 realWorldVelocity = ConvertUnits.ToDisplayUnits(Submarine.Loaded.Velocity * Physics.DisplayToRealWorldRatio) * 3.6f; + float realWorldDepth = (Submarine.Loaded.Position.Y - Level.Loaded.Size.Y) *Physics.DisplayToRealWorldRatio; + GUI.DrawString(spriteBatch, new Vector2(x + 20, y + height - 65), + "Velocity: " + (int)realWorldVelocity.X + " km/h", Color.LightGreen, null, 0, GUI.SmallFont); + GUI.DrawString(spriteBatch, new Vector2(x + 20, y + height - 50), + "Descent velocity: " + -(int)realWorldVelocity.Y + " km/h", Color.LightGreen, null, 0, GUI.SmallFont); + + GUI.DrawString(spriteBatch, new Vector2(x + 20, y + height - 30), + "Depth: " + (int)realWorldDepth + " m", Color.LightGreen, null, 0, GUI.SmallFont); + } + + GUI.DrawLine(spriteBatch, new Vector2(velRect.Center.X,velRect.Center.Y), new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y), diff --git a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs index b39f610a6..824ed435f 100644 --- a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Globalization; +using System.Linq; namespace Barotrauma.Items.Components { @@ -105,13 +106,19 @@ namespace Barotrauma.Items.Components ApplyStatusEffects(ActionType.OnActive, deltaTime, null); + List alreadyChecked = new List(); + List connections = item.Connections; if (connections == null) return; foreach (Connection c in connections) { if (!c.IsPower) continue; - foreach (Connection recipient in c.Recipients) + + + var recipients = c.Recipients; + + foreach (Connection recipient in recipients) { if (recipient == null || !c.IsPower) continue; @@ -123,6 +130,8 @@ namespace Barotrauma.Items.Components Powered powered = it.GetComponent(); if (powered == null) continue; + if (connectedList.Contains(powered)) continue; + PowerTransfer powerTransfer = powered as PowerTransfer; PowerContainer powerContainer = powered as PowerContainer; if (powerTransfer != null) @@ -140,6 +149,8 @@ namespace Barotrauma.Items.Components { fullPower += powerContainer.CurrPowerOutput; } + + alreadyChecked.Add(recipient); } else { diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index 5e675e31f..bc4cb8490 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -174,7 +174,7 @@ namespace Barotrauma.Items.Components var otherConnection = c.Wires[i].OtherConnection(c); Networking.GameServer.Log( item.Name+" ("+ c.Name + ") -> " + - otherConnection.Item.Name+" ("+(otherConnection == null ? "none" : otherConnection.Name)+")", Color.Orange); + (otherConnection == null ? "none" : otherConnection.Item.Name+" ("+(otherConnection.Name)+")"), Color.Orange); } c.UpdateRecipients(); } diff --git a/Subsurface/Source/Map/Explosion.cs b/Subsurface/Source/Map/Explosion.cs index 9e5d4d8cc..ed6ae9701 100644 --- a/Subsurface/Source/Map/Explosion.cs +++ b/Subsurface/Source/Map/Explosion.cs @@ -79,28 +79,8 @@ namespace Barotrauma if (force == 0.0f && attack.Stun == 0.0f && attack.GetDamage(1.0f) == 0.0f) return; - foreach (Character c in Character.CharacterList) - { + ApplyExplosionForces(worldPosition, attack.Range, force, attack.GetDamage(1.0f), attack.Stun); - - foreach (Limb limb in c.AnimController.Limbs) - { - float dist = Vector2.Distance(limb.WorldPosition, worldPosition); - - if (dist > attack.Range) continue; - - float distFactor = 1.0f - dist / attack.Range; - - if (limb.WorldPosition == worldPosition) continue; - - c.AddDamage(limb.SimPosition, DamageType.None, - attack.GetDamage(1.0f) / c.AnimController.Limbs.Length * distFactor, 0.0f, attack.Stun * distFactor, false); - if (force > 0.0f) - { - limb.body.ApplyLinearImpulse(Vector2.Normalize(limb.WorldPosition - worldPosition) * distFactor * force); - } - } - } } private IEnumerable DimLight() @@ -123,6 +103,32 @@ namespace Barotrauma yield return CoroutineStatus.Success; } + public static void ApplyExplosionForces(Vector2 worldPosition, float range, float force, float damage = 0.0f, float stun = 0.0f) + { + if (range <= 0.0f) return; + + foreach (Character c in Character.CharacterList) + { + foreach (Limb limb in c.AnimController.Limbs) + { + float dist = Vector2.Distance(limb.WorldPosition, worldPosition); + + if (dist > range) continue; + + float distFactor = 1.0f - dist / range; + + if (limb.WorldPosition == worldPosition) continue; + + c.AddDamage(limb.SimPosition, DamageType.None, + damage / c.AnimController.Limbs.Length * distFactor, 0.0f, stun * distFactor, false); + if (force > 0.0f) + { + limb.body.ApplyLinearImpulse(Vector2.Normalize(limb.WorldPosition - worldPosition) * distFactor * force); + } + } + } + } + public static void RangedStructureDamage(Vector2 worldPosition, float worldRange, float damage) { List structureList = new List(); diff --git a/Subsurface/Source/Map/Gap.cs b/Subsurface/Source/Map/Gap.cs index c082f435d..d483046d2 100644 --- a/Subsurface/Source/Map/Gap.cs +++ b/Subsurface/Source/Map/Gap.cs @@ -208,7 +208,11 @@ namespace Barotrauma { flowForce = Vector2.Zero; - if (open == 0.0f) return; + if (open == 0.0f) + { + lerpedFlowForce = Vector2.Zero; + return; + } UpdateOxygen(); diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index 66b18e72e..4811dc103 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -518,7 +518,11 @@ namespace Barotrauma bool hasHole = SectionHasHole(sectionIndex); - if (hadHole != hasHole) UpdateSections(); + if (hadHole != hasHole) + { + if (hasHole) Explosion.ApplyExplosionForces(sections[sectionIndex].gap.WorldPosition, 500.0f, 5.0f, 0.0f, 0.0f); + UpdateSections(); + } } diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index e523df138..3dfda2449 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -41,6 +41,9 @@ namespace Barotrauma.Networking endRoundButton.OnSelected = ToggleEndRoundVote; endRoundButton.Visible = false; + newName = newName.Replace(":", ""); + newName = newName.Replace(";", ""); + GameMain.DebugDraw = false; Hull.EditFire = false; Hull.EditWater = false; diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index cb15fecec..3719f4b10 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -39,6 +39,9 @@ namespace Barotrauma.Networking public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10) { + name = name.Replace(":", ""); + name = name.Replace(";", ""); + this.name = name; this.password = password; @@ -1121,12 +1124,11 @@ namespace Barotrauma.Networking int traitorIndex = Rand.Range(0, characters.Count); int targetIndex = Rand.Range(0, characters.Count); - while (targetIndex==traitorIndex) + while (targetIndex == traitorIndex) { targetIndex = Rand.Range(0, characters.Count); } - traitor = characters[traitorIndex]; target = characters[targetIndex]; diff --git a/Subsurface/Source/Networking/NetConfig.cs b/Subsurface/Source/Networking/NetConfig.cs index 9e1940093..871360a5d 100644 --- a/Subsurface/Source/Networking/NetConfig.cs +++ b/Subsurface/Source/Networking/NetConfig.cs @@ -12,6 +12,8 @@ namespace Barotrauma.Networking //UpdateEntity networkevents aren't sent to clients if they're further than this from the entity public const float UpdateEntityDistance = 2500.0f; + public const int MaxPlayers = 16; + public static string MasterServerUrl = GameMain.Config.MasterServerUrl; //if a Character is further than this from the sub, the server will ignore it diff --git a/Subsurface/Source/Physics/Physics.cs b/Subsurface/Source/Physics/Physics.cs index 2196f0d79..41dfe29b3 100644 --- a/Subsurface/Source/Physics/Physics.cs +++ b/Subsurface/Source/Physics/Physics.cs @@ -18,6 +18,8 @@ namespace Barotrauma public const Category CollisionProjectile = Category.Cat6; public const Category CollisionLevel = Category.Cat7; + public static float DisplayToRealWorldRatio = 1.0f / 80.0f; + public static double accumulator; public static double step = 1.0/60.0; diff --git a/Subsurface/Source/Program.cs b/Subsurface/Source/Program.cs index 33441588a..d330ef949 100644 --- a/Subsurface/Source/Program.cs +++ b/Subsurface/Source/Program.cs @@ -43,6 +43,15 @@ namespace Barotrauma } } + public static void CrashMessageBox(string message) + { +#if WINDOWS + MessageBox.Show(message, "Oops! Barotrauma just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error); +#endif + + Sounds.SoundManager.Dispose(); + } + static void CrashDump(GameMain game, string filePath, Exception exception) { StreamWriter sw = new StreamWriter(filePath); @@ -88,15 +97,8 @@ namespace Barotrauma sw.WriteLine(sb.ToString()); sw.Close(); - #if WINDOWS - MessageBox.Show( "A crash report (''crashreport.txt'') was saved in the root folder of the game."+ - " If you'd like to help fix this bug, please post the report on the Undertow Games forums.", - "Oops! Barotrauma just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error); - #endif - - Sounds.SoundManager.Dispose(); - - + CrashMessageBox( "A crash report (''crashreport.txt'') was saved in the root folder of the game."+ + " If you'd like to help fix this bug, please post the report on the Undertow Games forums."); } } #endif diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index c0beadcad..8c6b02cd8 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -288,10 +288,10 @@ namespace Barotrauma private bool ChangeMaxPlayers(GUIButton button, object obj) { - int currMaxPlayers = 10; + int currMaxPlayers = 8; int.TryParse(maxPlayersBox.Text, out currMaxPlayers); - currMaxPlayers = (int)MathHelper.Clamp(currMaxPlayers+(int)button.UserData, 1, 10); + currMaxPlayers = (int)MathHelper.Clamp(currMaxPlayers + (int)button.UserData, 1, NetConfig.MaxPlayers); maxPlayersBox.Text = currMaxPlayers.ToString(); diff --git a/Subsurface/Source/Sounds/SoundManager.cs b/Subsurface/Source/Sounds/SoundManager.cs index 93416efd6..11a18e4ea 100644 --- a/Subsurface/Source/Sounds/SoundManager.cs +++ b/Subsurface/Source/Sounds/SoundManager.cs @@ -33,7 +33,15 @@ namespace Barotrauma.Sounds public static void Init() { - AC = new AudioContext(); + try + { + AC = new AudioContext(); + } + catch (DllNotFoundException e) + { + Program.CrashMessageBox("OpenAL32.dll not found"); + throw e; + } for (int i = 0 ; i < DefaultSourceCount; i++) { diff --git a/Subsurface/changelog.txt b/Subsurface/changelog.txt index cb0a0da81..2f7e64523 100644 --- a/Subsurface/changelog.txt +++ b/Subsurface/changelog.txt @@ -1,3 +1,19 @@ +--------------------------------------------------------------------------------------------------------- +v0.3.2.5 +--------------------------------------------------------------------------------------------------------- + +- fixed null reference exception when starting a client + +--------------------------------------------------------------------------------------------------------- +v0.3.2.4 +--------------------------------------------------------------------------------------------------------- + +- fixed crashing when highlighting a dead husk +- fixed the unclickable checkboxes in server settings +- sending messages to specific players using ''d; [message]'' and ''name; [message]'' (messages can be +sent to players with spaces in their names now) +- more descriptive log messages when taking items from cabinets or other players + --------------------------------------------------------------------------------------------------------- v0.3.2.3 --------------------------------------------------------------------------------------------------------- diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index bca48bc5a..1da1054f4 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ