diff --git a/Subsurface/Content/Map/TutorialSub.sub b/Subsurface/Content/Map/TutorialSub.sub index a525518a9..41d0fe8d8 100644 Binary files a/Subsurface/Content/Map/TutorialSub.sub and b/Subsurface/Content/Map/TutorialSub.sub differ diff --git a/Subsurface/Properties/AssemblyInfo.cs b/Subsurface/Properties/AssemblyInfo.cs index 17cfa604d..2a9a1c81f 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.6")] -[assembly: AssemblyFileVersion("0.3.2.6")] +[assembly: AssemblyVersion("0.3.3.0")] +[assembly: AssemblyFileVersion("0.3.3.0")] diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 586a78a4b..98a107d01 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -913,6 +913,13 @@ namespace Barotrauma } } } + else + { + if (selectedCharacter != null) DeselectCharacter(); + selectedConstruction = null; + closestItem = null; + closestCharacter = null; + } DisableControls = false; } @@ -1393,7 +1400,7 @@ namespace Barotrauma else { message.Write((byte)0); - message.WriteRangedInteger((int)lastAttackCauseOfDeath, 0, Enum.GetValues(typeof(CauseOfDeath)).Length); + message.WriteRangedInteger(0, Enum.GetValues(typeof(CauseOfDeath)).Length, (int)lastAttackCauseOfDeath); } if (AnimController.StunTimer<=0.0f && bleeding<=0.0f && oxygen>99.0f) diff --git a/Subsurface/Source/Characters/CharacterInfo.cs b/Subsurface/Source/Characters/CharacterInfo.cs index 0b49799f5..dbde15c26 100644 --- a/Subsurface/Source/Characters/CharacterInfo.cs +++ b/Subsurface/Source/Characters/CharacterInfo.cs @@ -328,7 +328,11 @@ namespace Barotrauma public void Remove() { - if (headSprite != null) headSprite.Remove(); + //if (headSprite != null) + //{ + // headSprite.Remove(); + // headSprite = null; + //} } } } diff --git a/Subsurface/Source/GUI/GUITextBox.cs b/Subsurface/Source/GUI/GUITextBox.cs index e957ce5c9..d043de721 100644 --- a/Subsurface/Source/GUI/GUITextBox.cs +++ b/Subsurface/Source/GUI/GUITextBox.cs @@ -265,11 +265,12 @@ namespace Barotrauma } public void ReceiveCommandInput(char command) { + if (Text == null) Text = ""; + switch (command) { case '\b': //backspace - if (Text.Length > 0) - Text = Text.Substring(0, Text.Length - 1); + if (Text.Length > 0) Text = Text.Substring(0, Text.Length - 1); break; //case '\r': //return // if (OnEnterPressed != null) diff --git a/Subsurface/Source/GameSession/GameModes/TraitorMode.cs b/Subsurface/Source/GameSession/GameModes/TraitorMode.cs index 22f3f0fbf..d2b60febc 100644 --- a/Subsurface/Source/GameSession/GameModes/TraitorMode.cs +++ b/Subsurface/Source/GameSession/GameModes/TraitorMode.cs @@ -1,6 +1,8 @@ using System; using System.Linq; using Barotrauma.Networking; +using System.Collections.Generic; +using Microsoft.Xna.Framework; namespace Barotrauma { @@ -10,46 +12,98 @@ namespace Barotrauma public TraitorManager(GameServer server) { - server.NewTraitor(out traitorCharacter, out targetCharacter); + Start(server); + } + + private void Start(GameServer server) + { + if (server == null) return; + + List characters = new List(); + foreach (Client client in server.ConnectedClients) + { + if (!client.inGame || client.Character==null) continue; + characters.Add(client.Character); + } + + if (server.Character!= null) characters.Add(server.Character); + + if (characters.Count < 2) + { + traitorCharacter = null; + targetCharacter = null; + return; + } + + int traitorIndex = Rand.Range(0, characters.Count); + + int targetIndex = Rand.Range(0, characters.Count); + while (targetIndex == traitorIndex) + { + targetIndex = Rand.Range(0, characters.Count); + } + + traitorCharacter = characters[traitorIndex]; + targetCharacter = characters[targetIndex]; + + if (server.Character == null) + { + new GUIMessageBox("New traitor", traitorCharacter.Name + " is the traitor and the target is " + targetCharacter.Name+"."); + } + else if (server.Character == traitorCharacter) + { + CreateStartPopUp(traitorCharacter.Name); + return; + } + + server.NewTraitor(traitorCharacter, targetCharacter); + } + + public static void CreateStartPopUp(string targetName) + { + new GUIMessageBox("You are the Traitor!", + "Your secret task is to assassinate " + targetName + "! Discretion is an utmost concern; sinking the submarine and killing the entire crew " + + "will arouse suspicion amongst the Fleet. If possible, make the death look like an accident.", 400, 350); } public string GetEndMessage() { if (GameMain.Server == null || traitorCharacter == null || targetCharacter == null) return ""; - if (targetCharacter.IsDead) + string endMessage = ""; + + if (targetCharacter.IsDead && !traitorCharacter.IsDead) { - string endMessage = traitorCharacter.Name + " was a traitor! "; + endMessage = traitorCharacter.Name + " was a traitor! "; endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her"; endMessage += " task was to assassinate " + targetCharacter.Name + ". The task was successful."; - //End(endMessage); + } + else if (targetCharacter.IsDead && traitorCharacter.IsDead) + { + endMessage = traitorCharacter.Name + " was a traitor! "; + endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her"; + endMessage += " task was to assassinate " + targetCharacter.Name + ". The task was successful, but luckily the bastard didn't make it out alive either."; } else if (traitorCharacter.IsDead) { - string endMessage = traitorCharacter.Name + " was a traitor! "; + endMessage = traitorCharacter.Name + " was a traitor! "; endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her"; endMessage += " task was to assassinate " + targetCharacter.Name + ", but "; endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "he" : "she"; endMessage += " got " + ((traitorCharacter.Info.Gender == Gender.Male) ? "himself" : "herself"); endMessage += " killed before completing it."; - - return endMessage; } else { - string endMessage = traitorCharacter.Name + " was a traitor! "; + endMessage = traitorCharacter.Name + " was a traitor! "; endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her"; endMessage += " task was to assassinate " + targetCharacter.Name + ". "; endMessage += (Submarine.Loaded.AtEndPosition) ? "The task was unsuccessful - the has submarine reached its destination." : "The task was unsuccessful."; - - return endMessage; } - return ""; - - + return endMessage; } //public void CharacterLeft(Character character) diff --git a/Subsurface/Source/Items/Components/Machines/Pump.cs b/Subsurface/Source/Items/Components/Machines/Pump.cs index 4d14e3acb..95bbff2dd 100644 --- a/Subsurface/Source/Items/Components/Machines/Pump.cs +++ b/Subsurface/Source/Items/Components/Machines/Pump.cs @@ -198,7 +198,7 @@ namespace Barotrauma.Items.Components public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message) { - message.WriteRangedInteger(-10,10,(int)(flowPercentage/10.0f)); + message.WriteRangedInteger(-10, 10, (int)(flowPercentage / 10.0f)); message.Write(IsActive); message.WritePadBits(); diff --git a/Subsurface/Source/Items/Components/Signal/Connection.cs b/Subsurface/Source/Items/Components/Signal/Connection.cs index 21b19efa6..516746d3e 100644 --- a/Subsurface/Source/Items/Components/Signal/Connection.cs +++ b/Subsurface/Source/Items/Components/Signal/Connection.cs @@ -64,7 +64,8 @@ namespace Barotrauma.Items.Components { panelTexture = Sprite.LoadTexture("Content/Items/connectionpanel.png"); - connector = new Sprite(panelTexture, new Rectangle(448, 80, 64, 64), new Vector2(-32.0f, -32.0f), 0.0f); + connector = new Sprite(panelTexture, new Rectangle(448, 80, 64, 64), Vector2.Zero, 0.0f); + connector.Origin = new Vector2(32.0f, 32.0f); wireCorner = new Sprite(panelTexture, new Rectangle(448, 0, 64, 64), new Vector2(-32.0f, -32.0f), 0.0f); wireVertical = new Sprite(panelTexture, new Rectangle(480, 64, 16, 16), new Vector2(-8.0f, -8.0f), 0.0f); wireHorizontal = new Sprite(panelTexture, new Rectangle(496, 64, 16, 16), new Vector2(-8.0f, -8.0f), 0.0f); diff --git a/Subsurface/Source/Map/Hull.cs b/Subsurface/Source/Map/Hull.cs index 1348ab1b2..37bce6d95 100644 --- a/Subsurface/Source/Map/Hull.cs +++ b/Subsurface/Source/Map/Hull.cs @@ -57,7 +57,8 @@ namespace Barotrauma float[] leftDelta; float[] rightDelta; - float lastSentVolume; + private float lastSentVolume; + private float lastNetworkUpdate; public List ConnectedGaps; @@ -705,7 +706,7 @@ namespace Barotrauma message.WriteRangedSingle(MathHelper.Clamp(volume/FullVolume, 0.0f, 1.5f), 0.0f, 1.5f, 6); message.Write((byte)fireSources.Count, 4); - for (int i = 0; i < Math.Min(fireSources.Count, 16) ;i++ ) + for (int i = 0; i < Math.Min(fireSources.Count, 16); i++) { var fireSource = fireSources[i]; @@ -725,6 +726,8 @@ namespace Barotrauma { data = null; + if (sendingTime < lastNetworkUpdate) return; + float newVolume = this.volume; try @@ -785,6 +788,8 @@ namespace Barotrauma toBeRemoved[i].Remove(true); } fireSources = newFireSources; + + lastNetworkUpdate = sendingTime; } diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index 7bfac6888..23d5ae734 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -711,6 +711,8 @@ namespace Barotrauma } Vector2 center = (topLeft + bottomRight) / 2.0f; + center.X -= center.X % GridSize.X; + center.Y -= center.Y % GridSize.Y; foreach (Item item in Item.ItemList) { diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 3dfda2449..37da2044d 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -527,7 +527,7 @@ namespace Barotrauma.Networking case (byte)PacketTypes.Traitor: string targetName = inc.ReadString(); - new GUIMessageBox("You are the Traitor!", "Your secret task is to assassinate " + targetName + "!"); + TraitorManager.CreateStartPopUp(targetName); break; case (byte)PacketTypes.ResendRequest: diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index d3e55f794..cab9f5e7f 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -873,7 +873,7 @@ namespace Barotrauma.Networking UpdateCrewFrame(); - if (TraitorsEnabled == YesNoMaybe.Yes || (TraitorsEnabled == YesNoMaybe.Maybe && Rand.Range(0.0f, 1.0f)<0.5f)) + if (TraitorsEnabled == YesNoMaybe.Yes || (TraitorsEnabled == YesNoMaybe.Maybe && Rand.Range(0.0f, 1.0f) < 0.5f)) { TraitorManager = new TraitorManager(this); } @@ -1022,15 +1022,6 @@ namespace Barotrauma.Networking if (gameStarted && client.Character != null) { - if (GameMain.GameSession!=null && GameMain.GameSession.gameMode!=null) - { - //TraitorMode traitorMode = GameMain.GameSession.gameMode as TraitorMode; - //if (traitorMode!=null) - //{ - // traitorMode.CharacterLeft(client.Character); - //} - } - client.Character.ClearInputs(); } @@ -1106,45 +1097,9 @@ namespace Barotrauma.Networking } } - public void NewTraitor(out Character traitor, out Character target) + public void NewTraitor(Character traitor, Character target) { - List characters = new List(); - foreach (Client client in ConnectedClients) - { - if (!client.inGame || client.Character==null) continue; - characters.Add(client.Character); - } - if (myCharacter!= null) characters.Add(myCharacter); - - if (characters.Count < 2) - { - traitor = null; - target = null; - return; - } - - int traitorIndex = Rand.Range(0, characters.Count); - - int targetIndex = Rand.Range(0, characters.Count); - while (targetIndex == traitorIndex) - { - targetIndex = Rand.Range(0, characters.Count); - } - - traitor = characters[traitorIndex]; - target = characters[targetIndex]; - - if (myCharacter==null) - { - new GUIMessageBox("New traitor", traitor.Info.Name + " is the traitor and the target is " + target.Info.Name+"."); - } - else if (myCharacter == traitor) - { - new GUIMessageBox("You are the traitor!", "Your task is to assassinate " + target.Info.Name+"."); - return; - } - - Log(traitor.Info.Name + " is the traitor and the target is " + target.Info.Name, Color.Cyan); + Log(traitor.Name + " is the traitor and the target is " + target.Name, Color.Cyan); Client traitorClient = null; foreach (Client c in ConnectedClients) diff --git a/Subsurface/Source/Networking/NetworkEvent.cs b/Subsurface/Source/Networking/NetworkEvent.cs index c2cea2427..ac7a7438f 100644 --- a/Subsurface/Source/Networking/NetworkEvent.cs +++ b/Subsurface/Source/Networking/NetworkEvent.cs @@ -144,10 +144,10 @@ namespace Barotrauma.Networking if (!e.FillNetworkData(eventType, message, data)) return false; } - catch + catch (Exception exception) { #if DEBUG - DebugConsole.ThrowError("Failed to write network message for entity "+e.ToString()); + DebugConsole.ThrowError("Failed to write network message for entity "+e.ToString(), exception); #endif return false; diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index ee8d0db1e..f50db9418 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -103,17 +103,17 @@ namespace Barotrauma } if (Submarine.SavedSubmarines.Count > 0) mapList.Select(Submarine.SavedSubmarines[0]); - new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 30), 0, 100, 20), + new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 0, 100, 20), "Save name: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tab.NewGame]); - saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 30, 180, 20), + saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 30), 30, 180, 20), Alignment.TopLeft, GUI.Style, menuTabs[(int)Tab.NewGame]); saveNameBox.Text = SaveUtil.CreateSavePath(); - new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 30), 60, 100, 20), + new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 60, 100, 20), "Map Seed: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tab.NewGame]); - seedBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 90, 180, 20), + seedBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 30), 90, 180, 20), Alignment.TopLeft, GUI.Style, menuTabs[(int)Tab.NewGame]); seedBox.Text = ToolBox.RandomSeed(8); diff --git a/Subsurface/Submarines/Aegir Mark II.sub b/Subsurface/Submarines/Aegir Mark II.sub index f9ef740a2..1ecc326cb 100644 Binary files a/Subsurface/Submarines/Aegir Mark II.sub and b/Subsurface/Submarines/Aegir Mark II.sub differ diff --git a/Subsurface/Submarines/Nehalennia.sub b/Subsurface/Submarines/Nehalennia.sub index d7c296ea6..1298ea34e 100644 Binary files a/Subsurface/Submarines/Nehalennia.sub and b/Subsurface/Submarines/Nehalennia.sub differ diff --git a/Subsurface/Submarines/Vellamo.sub b/Subsurface/Submarines/Vellamo.sub index dae0e8d9e..3542a9781 100644 Binary files a/Subsurface/Submarines/Vellamo.sub and b/Subsurface/Submarines/Vellamo.sub differ diff --git a/Subsurface/changelog.txt b/Subsurface/changelog.txt index 3ebd04cdc..d3622f864 100644 --- a/Subsurface/changelog.txt +++ b/Subsurface/changelog.txt @@ -12,6 +12,8 @@ far away from the coordinates (0,0) - character/inventory syncing bugfixes - fixed spectators not seeing their own chat messages - scrollable list of clients in the network statistics view +- small changes to the vanilla subs +- fixed the water brightness in Linux version --------------------------------------------------------------------------------------------------------- v0.3.2.6 diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index b53e89c63..ad135a719 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ