diff --git a/Subsurface/Properties/AssemblyInfo.cs b/Subsurface/Properties/AssemblyInfo.cs index cfc80a621..f40f11617 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.3")] -[assembly: AssemblyFileVersion("0.3.2.3")] +[assembly: AssemblyVersion("0.3.2.4")] +[assembly: AssemblyFileVersion("0.3.2.4")] diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index a0625b26b..fe7364af3 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -653,6 +653,16 @@ namespace Barotrauma if (IsKeyDown(InputType.Use)) selectedConstruction.Use(deltaTime, this); if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.SecondaryUse(deltaTime, this); } + + if (selectedCharacter!=null) + { + if (Vector2.Distance(selectedCharacter.SimPosition, SimPosition) > 3.0f || + (!selectedCharacter.isDead && selectedCharacter.Stun <= 0.0f)) + { + DeselectCharacter(); + } + } + if (IsNetworkPlayer) { @@ -828,10 +838,9 @@ namespace Barotrauma if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen) { closestCharacter = FindClosestCharacter(mouseSimPos); - if (closestCharacter != null) + if (closestCharacter != null && closestCharacter.info==null) { - // if (closestCharacter != selectedCharacter) selectedCharacter = null; - if (!closestCharacter.IsHumanoid) closestCharacter = null; + closestCharacter = null; } closestItem = FindClosestItem(mouseSimPos); @@ -872,14 +881,6 @@ namespace Barotrauma } } } - else - { - if (Vector2.Distance(selectedCharacter.SimPosition, SimPosition) > 2.0f || - (!selectedCharacter.isDead && selectedCharacter.Stun <= 0.0f)) - { - DeselectCharacter(); - } - } if (IsKeyHit(InputType.Select)) { diff --git a/Subsurface/Source/GUI/GUITickBox.cs b/Subsurface/Source/GUI/GUITickBox.cs index 207b29999..d78c90f1a 100644 --- a/Subsurface/Source/GUI/GUITickBox.cs +++ b/Subsurface/Source/GUI/GUITickBox.cs @@ -50,7 +50,7 @@ namespace Barotrauma box.HoverColor = Color.Gray; box.SelectedColor = Color.DarkGray; - text = new GUITextBlock(new Rectangle(rect.X + 30, rect.Y+2, 200, rect.Height), label, Color.Transparent, Color.White, Alignment.TopLeft, null, this); + text = new GUITextBlock(new Rectangle(rect.X + 30, rect.Y+2, 20, rect.Height), label, Color.Transparent, Color.White, Alignment.TopLeft, null, this); this.rect = new Rectangle(box.Rect.X, box.Rect.Y, 240, rect.Height); diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs index e5e20815c..c1ab7820a 100644 --- a/Subsurface/Source/Items/CharacterInventory.cs +++ b/Subsurface/Source/Items/CharacterInventory.cs @@ -100,8 +100,6 @@ namespace Barotrauma /// public override bool TryPutItem(Item item, List allowedSlots, bool createNetworkEvent = true) { - bool alreadyInInventory = Array.Find(Items, i => i == item)!=null; - //try to place the item in LimBlot.Any slot if that's allowed if (allowedSlots.Contains(LimbSlot.Any)) { @@ -109,7 +107,6 @@ namespace Barotrauma { if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue; - GameServer.Log(character.Name + " picked up " + item.Name, Color.Orange); PutItem(item, i, createNetworkEvent); item.Unequip(character); return true; @@ -144,7 +141,6 @@ namespace Barotrauma if (placed) { - if (!alreadyInInventory) GameServer.Log(character.Name + " picked up " + item.Name, Color.Orange); return true; } } @@ -367,29 +363,66 @@ namespace Barotrauma return true; } - public override void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime) + public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime) { if (sendingTime < lastUpdate) return; character.ClearInput(InputType.Use); + List droppedItems = new List(); + List prevItems = new List(Items); + for (int i = 0; i c.Connection == message.SenderConnection); + if (sender != null && sender.Character != null) + { + foreach (Item item in droppedItems) + { + GameServer.Log(sender.Character == character ? + character.Name + " dropped " + item.Name : + sender.Character + " removed " + item.Name+" from "+character+"'s inventory", Color.Orange); + } + + foreach (Item item in Items) + { + if (item == null || prevItems.Contains(item)) continue; + GameServer.Log(sender.Character == character ? + character.Name + " picked up " + item.Name : + sender.Character + " placed " + item.Name + " in " + character + "'s inventory", Color.Orange); + } + } + + lastUpdate = sendingTime; } diff --git a/Subsurface/Source/Items/Components/Holdable/Holdable.cs b/Subsurface/Source/Items/Components/Holdable/Holdable.cs index d76b560b5..655c2a2d6 100644 --- a/Subsurface/Source/Items/Components/Holdable/Holdable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Holdable.cs @@ -316,7 +316,16 @@ namespace Barotrauma.Items.Components } item.SetTransform(newPos, 0.0f); - if (!attached) Use(1.0f); + if (!attached) + { + Use(1.0f); + + var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection); + if (sender != null && sender.Character != null) + { + Networking.GameServer.Log(sender.characterInfo.Name+" attached a "+item.Name+" on a wall", Color.Orange); + } + } } } } diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index b22bfa69c..5e675e31f 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -172,7 +172,9 @@ namespace Barotrauma.Items.Components wireComponent.Connect(c, false); var otherConnection = c.Wires[i].OtherConnection(c); - Networking.GameServer.Log(c.Name + " -> " + (otherConnection == null ? "none" : otherConnection.Name), Color.Orange); + Networking.GameServer.Log( + item.Name+" ("+ c.Name + ") -> " + + otherConnection.Item.Name+" ("+(otherConnection == null ? "none" : otherConnection.Name)+")", Color.Orange); } c.UpdateRecipients(); } diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index e3dd3010a..468140ac4 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -361,11 +361,13 @@ namespace Barotrauma return true; } - public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime) + public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime) { if (sendingTime < lastUpdate) return; List newItemIDs = new List(); + List droppedItems = new List(); + List prevItems = new List(Items); byte count = message.ReadByte(); for (int i = 0; i c.Connection == message.SenderConnection); + if (sender != null && sender.Character != null) + { + foreach (Item item in droppedItems) + { + GameServer.Log(sender.Character + " removed " + item.Name + " from " + Owner.ToString(), Color.Orange); + } + + foreach (Item item in Items) + { + if (item == null || prevItems.Contains(item)) continue; + GameServer.Log(sender.Character + " placed " + item.Name + " in " + Owner.ToString(), Color.Orange); + } + } + + lastUpdate = sendingTime; } } diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index e945e4a25..ac9d4ea0f 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -1125,7 +1125,7 @@ namespace Barotrauma // new NetworkEvent(NetworkEventType.DropItem, ID, true); - if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name, Color.Orange); + //if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name, Color.Orange); foreach (ItemComponent ic in components) ic.Drop(dropper); diff --git a/Subsurface/Source/Map/FireSource.cs b/Subsurface/Source/Map/FireSource.cs index 0e66c5f2f..4800ab0d5 100644 --- a/Subsurface/Source/Map/FireSource.cs +++ b/Subsurface/Source/Map/FireSource.cs @@ -145,13 +145,13 @@ namespace Barotrauma if (fireSoundBasic != null) { basicSoundIndex = fireSoundBasic.Loop(basicSoundIndex, - Math.Min(size.X / 100.0f, 1.0f), position + size / 2.0f, 2000.0f); + Math.Min(size.X / 100.0f, 1.0f), position + size / 2.0f, 1000.0f); } if (fireSoundLarge != null) { largeSoundIndex = fireSoundLarge.Loop(largeSoundIndex, - MathHelper.Clamp((size.X - 200.0f) / 100.0f, 0.0f, 1.0f), position + size / 2.0f, 2000.0f); + MathHelper.Clamp((size.X - 200.0f) / 100.0f, 0.0f, 1.0f), position + size / 2.0f, 1000.0f); } if (size.X>50.0f) diff --git a/Subsurface/Source/Map/Gap.cs b/Subsurface/Source/Map/Gap.cs index 210a25cb7..c082f435d 100644 --- a/Subsurface/Source/Map/Gap.cs +++ b/Subsurface/Source/Map/Gap.cs @@ -30,9 +30,6 @@ namespace Barotrauma float higherSurface; float lowerSurface; - private int soundIndex; - - float soundVolume; public float Open { @@ -42,10 +39,10 @@ namespace Barotrauma public Door ConnectedDoor; - public Vector2 FlowForce - { - get { return flowForce*soundVolume; } - } + //public Vector2 FlowForce + //{ + // get { return flowForce*soundVolume; } + //} public Vector2 LerpedFlowForce { @@ -144,8 +141,12 @@ namespace Barotrauma hulls[1] = temp; } - linkedTo.Add(hulls[0]); - if (hulls[1] != null) linkedTo.Add(hulls[1]); + for (int i = 0 ; i <2; i++) + { + if (hulls[i]==null) continue; + linkedTo.Add(hulls[i]); + if (!hulls[i].ConnectedGaps.Contains(this)) hulls[i].ConnectedGaps.Add(this); + } } public override void Draw(SpriteBatch sb, bool editing, bool back = true) @@ -205,14 +206,6 @@ namespace Barotrauma public override void Update(Camera cam, float deltaTime) { - soundVolume = soundVolume + ((flowForce.Length() < 100.0f) ? -deltaTime * 0.5f : deltaTime * 0.5f); - soundVolume = MathHelper.Clamp(soundVolume, 0.0f, 1.0f); - - int index = (int)Math.Floor(flowForce.Length() / 100.0f); - index = Math.Min(index,2); - - soundIndex = SoundPlayer.flowSounds[index].Loop(soundIndex, soundVolume, WorldPosition, 2000.0f); - flowForce = Vector2.Zero; if (open == 0.0f) return; @@ -548,7 +541,12 @@ namespace Barotrauma GapList.Remove(this); - if (soundIndex > -1) Sounds.SoundManager.Stop(soundIndex); + foreach (MapEntity entity in linkedTo) + { + var hull = entity as Hull; + if (hull.ConnectedGaps.Contains(this)) hull.ConnectedGaps.Remove(this); + } + } diff --git a/Subsurface/Source/Map/Hull.cs b/Subsurface/Source/Map/Hull.cs index 5947c7ab6..21fa54a95 100644 --- a/Subsurface/Source/Map/Hull.cs +++ b/Subsurface/Source/Map/Hull.cs @@ -48,6 +48,9 @@ namespace Barotrauma private bool update; + private int soundIndex; + private float soundVolume; + float[] waveY; //displacement from the surface of the water float[] waveVel; //velocity of the point @@ -56,6 +59,8 @@ namespace Barotrauma float lastSentVolume; + public List ConnectedGaps; + public override string Name { get @@ -173,12 +178,15 @@ namespace Barotrauma hullList.Add(this); + ConnectedGaps = new List(); + Item.UpdateHulls(); Gap.UpdateHulls(); Volume = 0.0f; + InsertToList(); } @@ -262,9 +270,11 @@ namespace Barotrauma fireSource.Remove(); } + if (soundIndex > -1) Sounds.SoundManager.Stop(soundIndex); + //renderer.Dispose(); - if (entityGrid!=null) entityGrid.RemoveEntity(this); + if (entityGrid != null) entityGrid.RemoveEntity(this); hullList.Remove(this); } @@ -311,6 +321,31 @@ namespace Barotrauma } FireSource.UpdateAll(fireSources, deltaTime); + + float strongestFlow = 0.0f; + foreach (Gap gap in ConnectedGaps) + { + float gapFlow = gap.LerpedFlowForce.Length(); + if (gapFlow > strongestFlow) + { + strongestFlow = gapFlow; + } + } + + if (strongestFlow>0.1f) + { + soundVolume = soundVolume + ((strongestFlow < 100.0f) ? -deltaTime * 0.5f : deltaTime * 0.5f); + soundVolume = MathHelper.Clamp(soundVolume, 0.0f, 1.0f); + + int index = (int)Math.Floor(strongestFlow / 100.0f); + index = Math.Min(index, 2); + + soundIndex = SoundPlayer.flowSounds[index].Loop(soundIndex, soundVolume, WorldPosition, 2000.0f); + } + else + { + if (soundIndex > -1) Sounds.SoundManager.Stop(soundIndex); + } //update client hulls if the amount of water has changed by >10% if (Math.Abs(lastSentVolume - volume) > FullVolume * 0.1f) @@ -588,19 +623,19 @@ namespace Barotrauma return null; } - public List FindGaps() - { - List gaps = new List(); + //public List FindGaps() + //{ + // List gaps = new List(); - foreach (Gap gap in Gap.GapList) - { - if (gap.Open < 0.01f) continue; + // foreach (Gap gap in Gap.GapList) + // { + // if (gap.Open < 0.01f) continue; - if (gap.linkedTo.Contains(this)) gaps.Add(gap); - } + // if (gap.linkedTo.Contains(this)) gaps.Add(gap); + // } - return gaps; - } + // return gaps; + //} public override XElement Save(XDocument doc) { diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs index 116675693..e08eae115 100644 --- a/Subsurface/Source/Map/SubmarineBody.cs +++ b/Subsurface/Source/Map/SubmarineBody.cs @@ -425,7 +425,7 @@ namespace Barotrauma if (newHull == null) return true; } - var gaps = newHull.FindGaps(); + var gaps = newHull.ConnectedGaps; targetPos = limb.character.WorldPosition; diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 36dba58e9..cb15fecec 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -883,7 +883,7 @@ namespace Barotrauma.Networking GameMain.GameScreen.Select(); - AddChatMessage("Press TAB to chat. Use ''/d'' to talk to dead players and spectators, and ''/playername'' to only send the message to a specific player.", ChatMessageType.Server); + AddChatMessage("Press TAB to chat. Use ''d;'' to talk to dead players and spectators, and ''player name;'' to only send the message to a specific player.", ChatMessageType.Server); yield return CoroutineStatus.Success; } @@ -1272,33 +1272,61 @@ namespace Barotrauma.Networking public override void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) { - string[] words = message.Split(' '); + List recipients = new List(); Client targetClient = null; - if (words.Length > 2 && words[1].FirstOrDefault()=='/' && type==ChatMessageType.Server) + if (type==ChatMessageType.Server) { - if (words[1] == "/dead" || words[1] == "/d") + string command = GetChatMessageCommand(message).ToLower(); + + if (command=="dead" || command=="d") { type = ChatMessageType.Dead; } - else + else if (command != "") { targetClient = ConnectedClients.Find(c => - words[1] == "/" + c.name.ToLower() || - c.Character != null && words[1] == "/" + c.Character.Name.ToLower()); + command == c.name.ToLower() || + c.Character != null && command == c.Character.Name.ToLower()); - if (targetClient==null) + if (targetClient == null) { - AddChatMessage("Player ''"+words[1].Replace("/", "")+"'' not found!", ChatMessageType.Admin); + AddChatMessage("Player ''" + command + "'' not found!", ChatMessageType.Admin); return; } } - - message = words[0] + " " + string.Join(" ", words, 2, words.Length - 2); } + //remove the ''name: '' part + //string[] words = message.Split(':'); + //string[] newMessage = ((string[])words.Skip(1)); + + + + //if (words.Length > 2 && words[1].FirstOrDefault()=='/' && type==ChatMessageType.Server) + //{ + // if (words[1] == "/dead" || words[1] == "/d") + // { + // type = ChatMessageType.Dead; + // } + // else + // { + // targetClient = ConnectedClients.Find(c => + // words[1] == "/" + c.name.ToLower() || + // c.Character != null && words[1] == "/" + c.Character.Name.ToLower()); + + // if (targetClient==null) + // { + // AddChatMessage("Player ''"+words[1].Replace("/", "")+"'' not found!", ChatMessageType.Admin); + // return; + // } + // } + + // message = words[0] + " " + string.Join(" ", words, 2, words.Length - 2); + //} + if (targetClient != null) { recipients.Add(targetClient); diff --git a/Subsurface/Source/Networking/NetworkMember.cs b/Subsurface/Source/Networking/NetworkMember.cs index cb1b2c633..911a0029a 100644 --- a/Subsurface/Source/Networking/NetworkMember.cs +++ b/Subsurface/Source/Networking/NetworkMember.cs @@ -214,6 +214,24 @@ namespace Barotrauma.Networking public virtual void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) { } + protected string GetChatMessageCommand(string message) + { + int separatorIndex = message.IndexOf(";"); + if (separatorIndex == -1) return ""; + + int colonIndex = message.IndexOf(":"); + + string command = ""; + try + { + command = message.Substring(colonIndex + 2, separatorIndex - colonIndex - 2); + } + + catch { } + + return command; + } + public virtual void Update(float deltaTime) { if (gameStarted && Screen.Selected == GameMain.GameScreen) diff --git a/Subsurface/Source/Particles/Particle.cs b/Subsurface/Source/Particles/Particle.cs index 79714501d..df76d43c8 100644 --- a/Subsurface/Source/Particles/Particle.cs +++ b/Subsurface/Source/Particles/Particle.cs @@ -115,7 +115,7 @@ namespace Barotrauma.Particles if (prefab.DeleteOnCollision || prefab.CollidesWithWalls) { - hullGaps = currentHull==null ? new List() : currentHull.FindGaps(); + hullGaps = currentHull == null ? new List() : currentHull.ConnectedGaps; //hullLimits = new List(); //hullLimits = FindLimits(position); } @@ -209,7 +209,7 @@ namespace Barotrauma.Particles else { currentHull = Hull.FindHull(position); - hullGaps = currentHull == null ? new List() : currentHull.FindGaps(); + hullGaps = currentHull == null ? new List() : currentHull.ConnectedGaps; if (OnChangeHull != null) OnChangeHull(edgePos, currentHull); diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index a5a712233..bca48bc5a 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ