diff --git a/Launcher/Launcher.csproj b/Launcher/OldLauncher.csproj similarity index 100% rename from Launcher/Launcher.csproj rename to Launcher/OldLauncher.csproj diff --git a/Launcher/Launcher.csproj.user b/Launcher/OldLauncher.csproj.user similarity index 100% rename from Launcher/Launcher.csproj.user rename to Launcher/OldLauncher.csproj.user diff --git a/Launcher/Properties/AssemblyInfo.cs b/Launcher/Properties/AssemblyInfo.cs index 3ccc23d8b..af2e579c4 100644 --- a/Launcher/Properties/AssemblyInfo.cs +++ b/Launcher/Properties/AssemblyInfo.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Launcher")] +[assembly: AssemblyTitle("OldLauncher")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] diff --git a/Launcher2/Launcher2.csproj b/Launcher2/Launcher.csproj similarity index 98% rename from Launcher2/Launcher2.csproj rename to Launcher2/Launcher.csproj index 89c7e279d..13ffdc7ed 100644 --- a/Launcher2/Launcher2.csproj +++ b/Launcher2/Launcher.csproj @@ -9,7 +9,7 @@ WinExe Properties Launcher2 - Launcher2 + Barotrauma Launcher 512 Windows diff --git a/Launcher2/Properties/AssemblyInfo.cs b/Launcher2/Properties/AssemblyInfo.cs index b63ffe7f1..a0f206311 100644 --- a/Launcher2/Properties/AssemblyInfo.cs +++ b/Launcher2/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Barotrauma Launcher")] -[assembly: AssemblyProduct("Launcher2")] +[assembly: AssemblyProduct("Barotrauma Launcher")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyCompany("")] diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 23696c51d..a298fc32a 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -512,6 +512,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Subsurface/Content/BackgroundSprites/BackgroundSpritePrefabs.xml b/Subsurface/Content/BackgroundSprites/BackgroundSpritePrefabs.xml index bd90adf5f..389ffef44 100644 --- a/Subsurface/Content/BackgroundSprites/BackgroundSpritePrefabs.xml +++ b/Subsurface/Content/BackgroundSprites/BackgroundSpritePrefabs.xml @@ -1,10 +1,24 @@  - + - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Subsurface/Content/BackgroundSprites/bgFish1.png b/Subsurface/Content/BackgroundSprites/bgFish1.png index 66e3d62f4..9d16661c2 100644 Binary files a/Subsurface/Content/BackgroundSprites/bgFish1.png and b/Subsurface/Content/BackgroundSprites/bgFish1.png differ diff --git a/Subsurface/Content/Map/dustparticles.png b/Subsurface/Content/Map/dustparticles.png new file mode 100644 index 000000000..a68587406 Binary files /dev/null and b/Subsurface/Content/Map/dustparticles.png differ diff --git a/Subsurface/Data/SavedSubs/Aegir Mark II.sub b/Subsurface/Data/SavedSubs/Aegir Mark II.sub index 5daf6ece2..f5600e33b 100644 Binary files a/Subsurface/Data/SavedSubs/Aegir Mark II.sub and b/Subsurface/Data/SavedSubs/Aegir Mark II.sub differ diff --git a/Subsurface/Data/SavedSubs/Vellamo.sub b/Subsurface/Data/SavedSubs/Vellamo.sub index d9345ee24..80d16c5d4 100644 Binary files a/Subsurface/Data/SavedSubs/Vellamo.sub and b/Subsurface/Data/SavedSubs/Vellamo.sub differ diff --git a/Subsurface/Properties/AssemblyInfo.cs b/Subsurface/Properties/AssemblyInfo.cs index 744e0f391..ea1db45ce 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.2.3.1")] -[assembly: AssemblyFileVersion("0.2.3.1")] +[assembly: AssemblyVersion("0.2.3.2")] +[assembly: AssemblyFileVersion("0.2.3.2")] diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 961b6d05b..276d52317 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -255,7 +255,7 @@ namespace Barotrauma static Character() { - DeathMsg[(int)CauseOfDeath.Damage] = "died"; + DeathMsg[(int)CauseOfDeath.Damage] = "succumbed to your injuries"; DeathMsg[(int)CauseOfDeath.Bloodloss] = "bled out"; DeathMsg[(int)CauseOfDeath.Drowning] = "drowned"; DeathMsg[(int)CauseOfDeath.Suffocation] = "suffocated"; @@ -841,7 +841,7 @@ namespace Barotrauma PressureProtection -= deltaTime*100.0f; } - Health = health - bleeding * deltaTime; + health = MathHelper.Clamp(health - bleeding * deltaTime, 0.0f, maxHealth); if (health <= 0.0f) Kill(CauseOfDeath.Bloodloss, false); } @@ -983,8 +983,7 @@ namespace Barotrauma { if (!isNetworkMessage) { - //if the game is run by a client, characters are only killed when the server says so - if (GameMain.Client != null && GameMain.Server == null) return; + if (GameMain.NetworkMember != null && controlled != this) return; } Vector2 centerOfMass = AnimController.GetCenterOfMass(); @@ -1065,12 +1064,29 @@ namespace Barotrauma yield return CoroutineStatus.Success; } - public void Kill(CauseOfDeath causeOfDeath, bool networkMessage = false) + public void Kill(CauseOfDeath causeOfDeath, bool isNetworkMessage = false) { if (isDead) return; - //if the game is run by a client, characters are only killed when the server says so - if (GameMain.Client != null && GameMain.Server==null && !networkMessage) return; + if (GameMain.NetworkMember != null) + { + //if the character is controlled by this client/server, let others know that the character has died + if (Character.controlled == this) + { + string chatMessage = "You have " + DeathMsg[(int)causeOfDeath] + "."; + if (GameMain.Client!=null) chatMessage += " Your chat messages will only be visible to other dead players."; + + GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead); + GameMain.LightManager.LosEnabled = false; + + new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath); + } + //otherwise don't kill the character unless received a message about the character dying + else if (!isNetworkMessage) + { + return; + } + } CoroutineManager.StartCoroutine(DeathAnim(GameMain.GameScreen.Cam)); @@ -1100,11 +1116,6 @@ namespace Barotrauma joint.MaxMotorTorque = 0.0f; } - if (GameMain.Server != null) - { - new NetworkEvent(NetworkEventType.KillCharacter, ID, false, causeOfDeath); - } - if (GameMain.GameSession != null) { GameMain.GameSession.KillCharacter(this); @@ -1248,6 +1259,13 @@ namespace Barotrauma } return; case NetworkEventType.KillCharacter: + if (GameMain.Server != null) + { + Client sender =GameMain.Server.connectedClients.Find(c => c.Connection == message.SenderConnection); + if (sender ==null || sender.character != this) + throw new Exception("Received a KillCharacter message from someone else than the client controlling the character!"); + } + CauseOfDeath causeOfDeath = CauseOfDeath.Damage; try { @@ -1267,12 +1285,6 @@ namespace Barotrauma { Kill(causeOfDeath, true); } - - if (GameMain.NetworkMember != null && controlled == this) - { - GameMain.NetworkMember.AddChatMessage("You have "+DeathMsg[(int)causeOfDeath]+". Your chat messages will only be visible to other dead players.", ChatMessageType.Dead); - GameMain.LightManager.LosEnabled = false; - } return; case NetworkEventType.InventoryUpdate: if (inventory == null) return; diff --git a/Subsurface/Source/GUI/GUIComponent.cs b/Subsurface/Source/GUI/GUIComponent.cs index b793b4d3b..299c1404c 100644 --- a/Subsurface/Source/GUI/GUIComponent.cs +++ b/Subsurface/Source/GUI/GUIComponent.cs @@ -359,6 +359,7 @@ namespace Barotrauma public virtual void RemoveChild(GUIComponent child) { + if (child == null) return; if (children.Contains(child)) children.Remove(child); } diff --git a/Subsurface/Source/GameSession/GameModes/TraitorMode.cs b/Subsurface/Source/GameSession/GameModes/TraitorMode.cs index f2551dac0..67f191fbe 100644 --- a/Subsurface/Source/GameSession/GameModes/TraitorMode.cs +++ b/Subsurface/Source/GameSession/GameModes/TraitorMode.cs @@ -6,9 +6,6 @@ namespace Barotrauma { class TraitorMode : GameMode { - Client traitor; - Client target; - private Character traitorCharacter, targetCharacter; public TraitorMode(GameModePreset preset) @@ -21,8 +18,8 @@ namespace Barotrauma { base.Start(); - traitor = null; - target = null; + traitorCharacter = null; + targetCharacter = null; } public override void Update(float deltaTime) @@ -32,42 +29,24 @@ namespace Barotrauma base.Update(deltaTime); if (!isRunning) return; - - if (traitor==null || target ==null) + + if (traitorCharacter == null || targetCharacter == null) { - int clientCount = GameMain.Server.connectedClients.Count(); - if (clientCount < 2) return; - - int traitorIndex = Rand.Int(clientCount, false); - traitor = GameMain.Server.connectedClients[traitorIndex]; - - int targetIndex = 0; - while (targetIndex == traitorIndex) - { - targetIndex = Rand.Int(clientCount, false); - } - target = GameMain.Server.connectedClients[targetIndex]; - - traitorCharacter = traitor.character; - targetCharacter = target.character; - - - GameMain.Server.NewTraitor(traitor, target); + GameMain.Server.NewTraitor(out traitorCharacter, out targetCharacter); } else { - if (target.character == null || target.character.IsDead) + if (targetCharacter == null || targetCharacter.IsDead) { string 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 (traitor.character == null || traitor.character.IsDead) + else if (traitorCharacter == null || traitorCharacter.IsDead) { string endMessage = traitorCharacter.Name + " was a traitor! "; - //TODO: remove references to traitor.character endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her"; endMessage += " task was to assassinate " + targetCharacter.Name + ", but "; endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "he" : "she"; @@ -88,5 +67,21 @@ namespace Barotrauma } } + + public void CharacterLeft(Character character) + { + if (character != traitorCharacter && character != targetCharacter) return; + + if (character == traitorCharacter) + { + string endMessage = "The traitor has disconnected from the server."; + End(endMessage); + } + else if (character == targetCharacter) + { + string endMessage = "The traitor's target has disconnected from the server."; + End(endMessage); + } + } } } diff --git a/Subsurface/Source/Items/FixRequirement.cs b/Subsurface/Source/Items/FixRequirement.cs index 4c734809a..f740473be 100644 --- a/Subsurface/Source/Items/FixRequirement.cs +++ b/Subsurface/Source/Items/FixRequirement.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using Barotrauma.Networking; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -138,11 +139,18 @@ namespace Barotrauma requirement.Fixed = true; + Item item = frame.UserData as Item; + if (item == null) return true; + + new NetworkEvent(NetworkEventType.ItemFixed, item.ID, true, (byte)item.FixRequirements.IndexOf(requirement) ); + return true; } private static void UpdateGUIFrame(Item item, Character character) { + if (frame == null) return; + bool unfixedFound = false; foreach (GUIComponent child in frame.children) { diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index cfb9842cd..037c7224e 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -1224,6 +1224,11 @@ namespace Barotrauma message.Write(body.SimPosition.Y); } break; + case NetworkEventType.ItemFixed: + byte requirementIndex = (byte)data; + + message.Write(requirementIndex); + break; case NetworkEventType.InventoryUpdate: var itemContainer = GetComponent(); if (itemContainer == null || itemContainer.inventory == null) return false; @@ -1290,6 +1295,13 @@ namespace Barotrauma SetTransform(newSimPos, body.Rotation); Drop(null, false); break; + case NetworkEventType.ItemFixed: + + byte requirementIndex = message.ReadByte(); + if (requirementIndex>=FixRequirements.Count) return; + + FixRequirements[requirementIndex].Fixed = true; + break; case NetworkEventType.InventoryUpdate: var itemContainer = GetComponent(); if (itemContainer == null || itemContainer.inventory == null) return; diff --git a/Subsurface/Source/Map/WaterRenderer.cs b/Subsurface/Source/Map/WaterRenderer.cs index 94b5ed0e7..4a7227776 100644 --- a/Subsurface/Source/Map/WaterRenderer.cs +++ b/Subsurface/Source/Map/WaterRenderer.cs @@ -45,7 +45,7 @@ namespace Barotrauma } } - public void RenderBack (SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0007f) + public void RenderBack (SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0f) { spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap); diff --git a/Subsurface/Source/Networking/BanList.cs b/Subsurface/Source/Networking/BanList.cs index e3d64ad26..30c2fd979 100644 --- a/Subsurface/Source/Networking/BanList.cs +++ b/Subsurface/Source/Networking/BanList.cs @@ -59,14 +59,21 @@ namespace Barotrauma.Networking return bannedPlayers.FirstOrDefault(bp => bp.IP == IP)!=null; } + public bool ToggleBanFrame(GUIButton button, object obj) + { + banFrame = CreateBanFrame(); + + return true; + } + private GUIFrame CreateBanFrame() { - banFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.3f); + banFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.5f); - GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,300,300), null, Alignment.Center, GUI.Style, banFrame); + GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400,300), null, Alignment.Center, GUI.Style, banFrame); - new GUITextBlock(new Rectangle(0, 0, 0, 30), "Banned IPs:", GUI.Style, Alignment.Left, Alignment.Left, innerFrame, false, GUI.LargeFont); - var banList = new GUIListBox(new Rectangle(0, 30, 200, 0), GUI.Style, innerFrame); + new GUITextBlock(new Rectangle(0, -10, 0, 30), "Banned IPs:", GUI.Style, Alignment.Left, Alignment.Left, innerFrame, false, GUI.LargeFont); + var banList = new GUIListBox(new Rectangle(0, 30, 0, 0), GUI.Style, innerFrame); foreach (BannedPlayer bannedPlayer in bannedPlayers) { @@ -78,12 +85,12 @@ namespace Barotrauma.Networking textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f); textBlock.UserData = banList; - var removeButton = new GUIButton(new Rectangle(0,0,100,20), "Remove", Alignment.Right, GUI.Style, textBlock); + var removeButton = new GUIButton(new Rectangle(0,00,100,20), "Remove", Alignment.Right | Alignment.CenterY, GUI.Style, textBlock); removeButton.UserData = bannedPlayer; removeButton.OnClicked = RemoveBan; } - var closeButton = new GUIButton(new Rectangle(0,0,100,20), "Close", Alignment.BottomRight, GUI.Style, innerFrame); + var closeButton = new GUIButton(new Rectangle(0,30,100,20), "Close", Alignment.BottomRight, GUI.Style, innerFrame); closeButton.OnClicked = CloseFrame; diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 29d693b85..2830a071d 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -484,8 +484,8 @@ namespace Barotrauma.Networking case (byte)PacketTypes.ResendRequest: reliableChannel.HandleResendRequest(inc); break; - case (byte)PacketTypes.Ack: - reliableChannel.HandleAckMessage(inc); + case (byte)PacketTypes.LatestMessageID: + reliableChannel.HandleLatestMessageID(inc); break; } } diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index b8c5da921..ef86135e9 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -54,6 +54,11 @@ namespace Barotrauma.Networking } public float AutoRestartTimer; + public BanList BanList + { + get { return banList; } + } + public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10) { var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD); @@ -86,7 +91,8 @@ namespace Barotrauma.Networking config.DisableMessageType(NetIncomingMessageType.DebugMessage | NetIncomingMessageType.WarningMessage | NetIncomingMessageType.Receipt | - NetIncomingMessageType.ErrorMessage | NetIncomingMessageType.Error); + NetIncomingMessageType.ErrorMessage | NetIncomingMessageType.Error | + NetIncomingMessageType.UnconnectedData); config.EnableMessageType(NetIncomingMessageType.ConnectionApproval); @@ -137,7 +143,7 @@ namespace Barotrauma.Networking RegisterToMasterServer(); } - updateInterval = new TimeSpan(0, 0, 0, 0, 60); + updateInterval = new TimeSpan(0, 0, 0, 0, 150); DebugConsole.NewMessage("Server started", Color.Green); @@ -504,8 +510,8 @@ namespace Barotrauma.Networking dataSender.ReliableChannel.HandleResendRequest(inc); break; - case (byte)PacketTypes.Ack: - dataSender.ReliableChannel.HandleAckMessage(inc); + case (byte)PacketTypes.LatestMessageID: + dataSender.ReliableChannel.HandleLatestMessageID(inc); break; } break; @@ -884,7 +890,19 @@ namespace Barotrauma.Networking { if (client == null) return; - if (gameStarted && client.character != null) client.character.ClearInputs(); + 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(); + } if (string.IsNullOrWhiteSpace(msg)) msg = client.name + " has left the server"; if (string.IsNullOrWhiteSpace(targetmsg)) targetmsg = "You have left the server"; @@ -956,23 +974,66 @@ namespace Barotrauma.Networking } } - public void NewTraitor(Client traitor, Client target) + public void NewTraitor(out Character traitor, out Character target) { - //new GUIMessageBox("New traitor", traitor.name + " is the traitor and the target is " + target.name+"."); + 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; + } + + Client traitorClient = null; + foreach (Client c in connectedClients) + { + if (c.character != traitor) continue; + traitorClient = c; + break; + } NetOutgoingMessage msg = server.CreateMessage(); msg.Write((byte)PacketTypes.Traitor); - msg.Write(target.name); + msg.Write(target.Info.Name); if (server.Connections.Count > 0) { - server.SendMessage(msg, traitor.Connection, NetDeliveryMethod.ReliableUnordered, 0); + server.SendMessage(msg, traitorClient.Connection, NetDeliveryMethod.ReliableUnordered, 0); } } public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) { base.Draw(spriteBatch); - + if (!ShowNetStats) return; int width = 200, height = 300; diff --git a/Subsurface/Source/Networking/NetConfig.cs b/Subsurface/Source/Networking/NetConfig.cs index 5777d8107..a0a59ea7d 100644 --- a/Subsurface/Source/Networking/NetConfig.cs +++ b/Subsurface/Source/Networking/NetConfig.cs @@ -25,7 +25,7 @@ namespace Barotrauma.Networking public const float DeleteDisconnectedTime = 10.0f; - public const float AckInterval = 0.2f; + public const float IdSendInterval = 0.2f; public const float RerequestInterval = 0.2f; public const int ResendAttempts = 8; diff --git a/Subsurface/Source/Networking/NetworkEvent.cs b/Subsurface/Source/Networking/NetworkEvent.cs index 11edf668c..d4c48c1e5 100644 --- a/Subsurface/Source/Networking/NetworkEvent.cs +++ b/Subsurface/Source/Networking/NetworkEvent.cs @@ -18,9 +18,10 @@ namespace Barotrauma.Networking PickItem = 6, DropItem = 7, InventoryUpdate = 8, + ItemFixed = 9, - UpdateProperty = 9, - WallDamage = 10, + UpdateProperty = 10, + WallDamage = 11, } @@ -34,7 +35,7 @@ namespace Barotrauma.Networking static NetworkEvent() { - isImportant = new bool[11]; + isImportant = new bool[Enum.GetNames(typeof(NetworkEventType)).Length]; isImportant[(int)NetworkEventType.ImportantEntityUpdate] = true; isImportant[(int)NetworkEventType.ImportantComponentUpdate] = true; isImportant[(int)NetworkEventType.KillCharacter] = true; @@ -44,12 +45,13 @@ namespace Barotrauma.Networking isImportant[(int)NetworkEventType.PickItem] = true; isImportant[(int)NetworkEventType.DropItem] = true; isImportant[(int)NetworkEventType.InventoryUpdate] = true; + isImportant[(int)NetworkEventType.ItemFixed] = true; isImportant[(int)NetworkEventType.UpdateProperty] = true; isImportant[(int)NetworkEventType.WallDamage] = true; - overridePrevious = new bool[11]; - for (int i = 0; i < 11; i++ ) + overridePrevious = new bool[isImportant.Length]; + for (int i = 0; i < overridePrevious.Length; i++ ) { overridePrevious[i] = true; } @@ -57,6 +59,7 @@ namespace Barotrauma.Networking overridePrevious[(int)NetworkEventType.PickItem] = false; overridePrevious[(int)NetworkEventType.DropItem] = false; + overridePrevious[(int)NetworkEventType.ItemFixed] = false; } private ushort id; diff --git a/Subsurface/Source/Networking/NetworkMember.cs b/Subsurface/Source/Networking/NetworkMember.cs index eb5eff609..b16864f04 100644 --- a/Subsurface/Source/Networking/NetworkMember.cs +++ b/Subsurface/Source/Networking/NetworkMember.cs @@ -32,7 +32,7 @@ namespace Barotrauma.Networking ResendRequest, ReliableMessage, - Ack + LatestMessageID } diff --git a/Subsurface/Source/Networking/ReliableSender.cs b/Subsurface/Source/Networking/ReliableSender.cs index 004b6f90e..2a9de7300 100644 --- a/Subsurface/Source/Networking/ReliableSender.cs +++ b/Subsurface/Source/Networking/ReliableSender.cs @@ -43,10 +43,10 @@ namespace Barotrauma.Networking.ReliableMessages sender.HandleResendRequest(inc); } - public void HandleAckMessage(NetIncomingMessage inc) + public void HandleLatestMessageID(NetIncomingMessage inc) { //make sure we've received what's been sent to us, if not, rerequest - receiver.HandleAckMessage(inc); + receiver.HandleLatestMessageID(inc); } public bool CheckMessage(NetIncomingMessage inc) @@ -73,9 +73,9 @@ namespace Barotrauma.Networking.ReliableMessages private NetConnection recipient; - private float ackTimer; + private float idSendTimer; - private float ackInterval; + private float idSendInterval; public ReliableSender(NetPeer sender) { @@ -134,8 +134,8 @@ namespace Barotrauma.Networking.ReliableMessages public void SendMessage(ReliableMessage message, NetConnection connection) { - ackInterval = 0.0f; - ackTimer = connection.AverageRoundtripTime; + idSendInterval = 0.0f; + idSendTimer = connection.AverageRoundtripTime; messageBuffer.Add(message.ID, message); @@ -168,7 +168,7 @@ namespace Barotrauma.Networking.ReliableMessages NetOutgoingMessage resendMessage = sender.CreateMessage(); message.RestoreInnerMessage(resendMessage); - ackTimer = connection.AverageRoundtripTime; + idSendTimer = connection.AverageRoundtripTime; sender.SendMessage(resendMessage, connection, NetDeliveryMethod.Unreliable); } @@ -177,20 +177,20 @@ namespace Barotrauma.Networking.ReliableMessages { if (recipient == null) return; - ackTimer -= deltaTime; + idSendTimer -= deltaTime; - if (ackTimer > 0.0f) return; + if (idSendTimer > 0.0f) return; //Debug.WriteLine("Sending ack message: "+messageCount); NetOutgoingMessage message = sender.CreateMessage(); - message.Write((byte)PacketTypes.Ack); + message.Write((byte)PacketTypes.LatestMessageID); message.Write(messageCount); sender.SendMessage(message, recipient, NetDeliveryMethod.Unreliable); - ackTimer = Math.Max(recipient.AverageRoundtripTime, NetConfig.AckInterval+ackInterval); - ackInterval += 0.1f; + idSendTimer = Math.Max(recipient.AverageRoundtripTime, NetConfig.IdSendInterval+idSendInterval); + idSendInterval += 0.1f; } } @@ -337,7 +337,7 @@ namespace Barotrauma.Networking.ReliableMessages missingMessages.Remove(id); } - public void HandleAckMessage(NetIncomingMessage inc) + public void HandleLatestMessageID(NetIncomingMessage inc) { ushort messageId = inc.ReadUInt16(); @@ -357,7 +357,7 @@ namespace Barotrauma.Networking.ReliableMessages return; } - Debug.WriteLine("Received ack message: " + messageId + ", need to rerequest messages (last id: "+lastMessageID+")"); + Debug.WriteLine("Received id update message: " + messageId + ", need to rerequest messages (last id: "+lastMessageID+")"); if (lastMessageID > ushort.MaxValue / 2 && messageId < short.MaxValue / 2) { diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 4704358f3..20a499de7 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -16,6 +16,9 @@ namespace Barotrauma readonly RenderTarget2D renderTargetAir; readonly Sprite background, backgroundTop; + readonly Texture2D dustParticles; + + Vector2 dustOffset; public BackgroundSpriteManager BackgroundSpriteManager; @@ -35,7 +38,8 @@ namespace Barotrauma background = new Sprite("Content/Map/background.png", Vector2.Zero); backgroundTop = new Sprite("Content/Map/background2.png", Vector2.Zero); - + dustParticles = Sprite.LoadTexture("Content/Map/dustparticles.png"); + BackgroundSpriteManager = new BackgroundSpriteManager("Content/BackgroundSprites/BackgroundSpritePrefabs.xml"); } @@ -78,6 +82,9 @@ namespace Barotrauma } #endif + + //dustOffset -= Vector2.UnitY * 100.0f * (float)deltaTime; + if (GameMain.GameSession!=null) GameMain.GameSession.Update((float)deltaTime); //EventManager.Update(gameTime); @@ -166,7 +173,7 @@ namespace Barotrauma graphics.SetRenderTarget(renderTarget); graphics.Clear(new Color(11, 18, 26, 255)); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap); Vector2 backgroundPos = cam.Position; if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; @@ -196,11 +203,26 @@ namespace Barotrauma spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, - null, null, null, null, + SamplerState.LinearWrap, null, null, null, cam.Transform); BackgroundSpriteManager.Draw(spriteBatch); + backgroundPos = new Vector2(cam.WorldView.X, cam.WorldView.Y); + if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; + + Rectangle viewRect = cam.WorldView; + viewRect.Y = -viewRect.Y; + + float multiplier = 0.8f; + for (int i = 1; i < 3; i++) + { + spriteBatch.Draw(dustParticles, viewRect, + new Rectangle((int)((backgroundPos.X * multiplier)), (int)((-backgroundPos.Y * multiplier)), cam.WorldView.Width, cam.WorldView.Height), + Color.LightGray * multiplier, 0.0f, Vector2.Zero, SpriteEffects.None, 1.0f-multiplier); + multiplier -= 0.15f; + } + spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, @@ -211,9 +233,12 @@ namespace Barotrauma Submarine.DrawBack(spriteBatch); foreach (Character c in Character.CharacterList) c.Draw(spriteBatch); - + spriteBatch.End(); + + GameMain.LightManager.DrawLightMap(spriteBatch, cam); + //---------------------------------------------------------------------------------------- //draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater @@ -272,7 +297,6 @@ namespace Barotrauma GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter); } - GameMain.LightManager.DrawLightMap(spriteBatch, cam); //---------------------------------------------------------------------------------------- //3. draw the sections of the map that are on top of the water //---------------------------------------------------------------------------------------- diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index 5afaf1bbc..203bc46d2 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -274,11 +274,17 @@ namespace Barotrauma infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton")); + playerList.Parent.RemoveChild(playerList.Parent.children.Find(c => c.UserData as string == "banListButton")); + if (IsServer && GameMain.Server != null) { GUIButton startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame); startButton.OnClicked = GameMain.Server.StartGameClicked; startButton.UserData = "startButton"; + + var banListButton = new GUIButton(new Rectangle(0, 30, 100, 20), "Banned IPs", Alignment.BottomRight, GUI.Style, playerList.Parent); + banListButton.OnClicked = GameMain.Server.BanList.ToggleBanFrame; + banListButton.UserData = "banListButton"; //mapList.OnSelected = new GUIListBox.OnSelectedHandler(Game1.server.UpdateNetLobby); modeList.OnSelected += GameMain.Server.UpdateNetLobby; @@ -544,6 +550,11 @@ namespace Barotrauma { autoRestartTimer = Math.Max(autoRestartTimer - (float)deltaTime, 0.0f); } + + if (GameMain.Server != null && GameMain.Server.BanList != null) + { + if (GameMain.Server.BanList.BanFrame != null) GameMain.Server.BanList.BanFrame.Update((float)deltaTime); + } //durationBar.BarScroll = Math.Max(durationBar.BarScroll, 1.0f / 60.0f); } @@ -564,6 +575,11 @@ namespace Barotrauma if (playerFrame != null) playerFrame.Draw(spriteBatch); + if (GameMain.Server!=null && GameMain.Server.BanList!=null) + { + if (GameMain.Server.BanList.BanFrame != null) GameMain.Server.BanList.BanFrame.Draw(spriteBatch); + } + GUI.Draw((float)deltaTime, spriteBatch, null); spriteBatch.End(); diff --git a/Subsurface/changelog.txt b/Subsurface/changelog.txt index d1bf2b2e4..191407d1e 100644 --- a/Subsurface/changelog.txt +++ b/Subsurface/changelog.txt @@ -1,3 +1,13 @@ +--------------------------------------------------------------------------------------------------------- +v0.2.3.2 +--------------------------------------------------------------------------------------------------------- + +- more reliable NPC position syncing +- more reliable method of handling players dying in multiplayer, there should now be less cases of +the server killing players who have equipped a diving suit or switched an oxygen tank just in time for example +- the "you have died" message in multiplayer now also tells your cause of death +- fixed incorrectly placed waypoints in Aegir + --------------------------------------------------------------------------------------------------------- v0.2.3.1 --------------------------------------------------------------------------------------------------------- diff --git a/Subsurface_Solution.sln b/Subsurface_Solution.sln index bacafb288..59a0706a8 100644 --- a/Subsurface_Solution.sln +++ b/Subsurface_Solution.sln @@ -11,11 +11,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Subsurface_content", "Subsu EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Farseer Physics MonoGame", "Farseer Physics Engine 3.5\Farseer Physics MonoGame.csproj", "{0AAD36E3-51A5-4A07-AB60-5C8A66BD38B7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher\Launcher.csproj", "{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OldLauncher", "Launcher\OldLauncher.csproj", "{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "Lidgren.Network\Lidgren.Network.csproj", "{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher2", "Launcher2\Launcher2.csproj", "{251AAFE1-F24B-4837-9128-9D04FCBFD528}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher2\Launcher.csproj", "{251AAFE1-F24B-4837-9128-9D04FCBFD528}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrashReporter", "CrashReporter\CrashReporter.csproj", "{6BE950CD-9A34-49C9-939A-786AC89C287E}" EndProject diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 4715cb1df..7d29b3848 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ