diff --git a/Subsurface/Barotrauma.csproj.user b/Subsurface/Barotrauma.csproj.user index 1782abafa..df35fcf91 100644 --- a/Subsurface/Barotrauma.csproj.user +++ b/Subsurface/Barotrauma.csproj.user @@ -9,7 +9,7 @@ en-US false - ShowAllFiles + ProjectFiles diff --git a/Subsurface/Content/Characters/TigerThresher/tigerthresher.xml b/Subsurface/Content/Characters/TigerThresher/tigerthresher.xml index ad1761c38..c401e5d51 100644 --- a/Subsurface/Content/Characters/TigerThresher/tigerthresher.xml +++ b/Subsurface/Content/Characters/TigerThresher/tigerthresher.xml @@ -30,7 +30,7 @@ - + diff --git a/Subsurface/Content/Items/Button/button.xml b/Subsurface/Content/Items/Button/button.xml index 47510268a..e89794e0d 100644 --- a/Subsurface/Content/Items/Button/button.xml +++ b/Subsurface/Content/Items/Button/button.xml @@ -15,12 +15,12 @@ - + - diff --git a/Subsurface/Content/Items/Door/doors.xml b/Subsurface/Content/Items/Door/doors.xml index 7e1d1e859..298acf04d 100644 --- a/Subsurface/Content/Items/Door/doors.xml +++ b/Subsurface/Content/Items/Door/doors.xml @@ -19,7 +19,7 @@ - + @@ -48,7 +48,7 @@ - + diff --git a/Subsurface/Content/Items/Electricity/lights.xml b/Subsurface/Content/Items/Electricity/lights.xml index 34d48a133..85da571ab 100644 --- a/Subsurface/Content/Items/Electricity/lights.xml +++ b/Subsurface/Content/Items/Electricity/lights.xml @@ -11,7 +11,7 @@ - + diff --git a/Subsurface/Content/Items/Electricity/poweritems.xml b/Subsurface/Content/Items/Electricity/poweritems.xml index 7f58f6b74..52f63dcc0 100644 --- a/Subsurface/Content/Items/Electricity/poweritems.xml +++ b/Subsurface/Content/Items/Electricity/poweritems.xml @@ -17,7 +17,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -69,7 +69,7 @@ - + diff --git a/Subsurface/Content/Items/Electricity/signalitems.xml b/Subsurface/Content/Items/Electricity/signalitems.xml index 6f4f3ea07..9e138f855 100644 --- a/Subsurface/Content/Items/Electricity/signalitems.xml +++ b/Subsurface/Content/Items/Electricity/signalitems.xml @@ -80,13 +80,13 @@ - - + @@ -108,12 +108,12 @@ - - + @@ -135,12 +135,12 @@ - - + @@ -163,11 +163,11 @@ - + - + @@ -188,12 +188,12 @@ - - + @@ -212,12 +212,12 @@ - - + @@ -239,12 +239,12 @@ - - + @@ -264,12 +264,12 @@ - - + diff --git a/Subsurface/Content/Items/Engine/engine.xml b/Subsurface/Content/Items/Engine/engine.xml index c1daaaa47..a14c67887 100644 --- a/Subsurface/Content/Items/Engine/engine.xml +++ b/Subsurface/Content/Items/Engine/engine.xml @@ -13,7 +13,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -46,4 +46,23 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Subsurface/Content/Items/MiniMap/item.xml b/Subsurface/Content/Items/MiniMap/item.xml index b898d70f4..463c391d3 100644 --- a/Subsurface/Content/Items/MiniMap/item.xml +++ b/Subsurface/Content/Items/MiniMap/item.xml @@ -10,7 +10,7 @@ - + diff --git a/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml b/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml index 96501ab14..1fc53de08 100644 --- a/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml +++ b/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml @@ -17,7 +17,7 @@ - + diff --git a/Subsurface/Content/Items/Pump/pump.xml b/Subsurface/Content/Items/Pump/pump.xml index 782671806..8ce2ecfdb 100644 --- a/Subsurface/Content/Items/Pump/pump.xml +++ b/Subsurface/Content/Items/Pump/pump.xml @@ -10,7 +10,7 @@ - + diff --git a/Subsurface/Content/Items/Reactor/reactor.xml b/Subsurface/Content/Items/Reactor/reactor.xml index c23c90635..7ace14c21 100644 --- a/Subsurface/Content/Items/Reactor/reactor.xml +++ b/Subsurface/Content/Items/Reactor/reactor.xml @@ -31,7 +31,7 @@ - + diff --git a/Subsurface/Content/Items/Weapons/explosives.xml b/Subsurface/Content/Items/Weapons/explosives.xml index f23a12245..b5f5c269a 100644 --- a/Subsurface/Content/Items/Weapons/explosives.xml +++ b/Subsurface/Content/Items/Weapons/explosives.xml @@ -12,7 +12,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/Subsurface/Properties/AssemblyInfo.cs b/Subsurface/Properties/AssemblyInfo.cs index 61b22b369..caaef8883 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.0.0.1")] -[assembly: AssemblyFileVersion("0.0.0.1")] +[assembly: AssemblyVersion("0.2.3.0")] +[assembly: AssemblyFileVersion("0.2.3.0")] diff --git a/Subsurface/Source/Characters/AICharacter.cs b/Subsurface/Source/Characters/AICharacter.cs index 442662e78..6ea38dab6 100644 --- a/Subsurface/Source/Characters/AICharacter.cs +++ b/Subsurface/Source/Characters/AICharacter.cs @@ -165,8 +165,8 @@ namespace Barotrauma try { targetDir = message.ReadBoolean(); - targetMovement.X = message.ReadRangedSingle(-10.0f, 10.0f, 8); - targetMovement.Y = message.ReadRangedSingle(-10.0f, 10.0f, 8); + targetMovement.X = message.ReadRangedSingle(-10.0f, 10.0f, 16); + targetMovement.Y = message.ReadRangedSingle(-10.0f, 10.0f, 16); } catch @@ -236,7 +236,7 @@ namespace Barotrauma catch { return; } - + //error AnimController.RefLimb.body.TargetPosition = pos; AnimController.RefLimb.body.TargetVelocity = vel; diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index d310dfcab..d8e9835a5 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -626,8 +626,7 @@ namespace Barotrauma selectedCharacter = null; - if (createNetworkEvent) - new NetworkEvent(NetworkEventType.SelectCharacter, ID, true, 0); + if (createNetworkEvent) new NetworkEvent(NetworkEventType.SelectCharacter, ID, true, (ushort)0); } /// @@ -723,9 +722,10 @@ namespace Barotrauma if (closestItem != null) { closestItem.IsHighlighted = true; - if (GetInputState(InputType.Select) && closestItem.Pick(this, false)) + if (closestItem.Pick(this)) { - new NetworkEvent(NetworkEventType.PickItem, ID, true, closestItem.ID); + new NetworkEvent(NetworkEventType.PickItem, ID, true, + new int[] { closestItem.ID, GetInputState(InputType.Select) ? 1 : 0, GetInputState(InputType.ActionHit) ? 1 : 0 }); } } } @@ -801,7 +801,7 @@ namespace Barotrauma if (!(this is AICharacter)) Control(deltaTime, cam); UpdateSightRange(); - aiTarget.SoundRange = 0.0f; + if (aiTarget != null) aiTarget.SoundRange = 0.0f; lowPassMultiplier = MathHelper.Lerp(lowPassMultiplier, 1.0f, 0.1f); @@ -830,6 +830,8 @@ namespace Barotrauma private void UpdateSightRange() { + if (aiTarget == null) return; + aiTarget.SightRange = 0.0f; //distance is approximated based on the mass of the character @@ -1088,10 +1090,17 @@ namespace Barotrauma { if (type == NetworkEventType.PickItem) { - message.Write((ushort)data); + int[] pickData = (int[])data; + if (pickData.Length != 3) return false; + + message.Write((ushort)pickData[0]); + message.Write((int)pickData[1] == 1); + message.Write((int)pickData[2] == 1); + message.WritePadBits(); + return true; } - else if (type== NetworkEventType.SelectCharacter) + else if (type == NetworkEventType.SelectCharacter) { message.Write((ushort)data); return true; @@ -1193,12 +1202,15 @@ namespace Barotrauma itemId = message.ReadUInt16(); + bool pickHit = message.ReadBoolean(); + bool actionHit = message.ReadBoolean(); + System.Diagnostics.Debug.WriteLine("item id: "+itemId); Item item = FindEntityByID(itemId) as Item; if (item != null) { - item.Pick(this); + item.Pick(this, false, pickHit, actionHit); } return; @@ -1249,9 +1261,9 @@ namespace Barotrauma bool hasInputs = message.ReadBoolean(); sendingTime = message.ReadFloat(); - if (!hasInputs && sendingTime > LastNetworkUpdate) + if (!hasInputs) { - ClearInputs(); + if (sendingTime > LastNetworkUpdate) ClearInputs(); return; } @@ -1266,7 +1278,7 @@ namespace Barotrauma runState = message.ReadBoolean(); } - catch + catch (Exception e) { return; } @@ -1310,7 +1322,7 @@ namespace Barotrauma } if (secondaryKeyState) { - cursorPosition = cursorPos; + cursorPosition = MathUtils.IsValid(cursorPos) ? cursorPos : Vector2.Zero; } else { diff --git a/Subsurface/Source/Characters/Ragdoll.cs b/Subsurface/Source/Characters/Ragdoll.cs index d36eb7595..b2cd94834 100644 --- a/Subsurface/Source/Characters/Ragdoll.cs +++ b/Subsurface/Source/Characters/Ragdoll.cs @@ -531,7 +531,15 @@ namespace Barotrauma { if (limb.ignoreCollisions) continue; - limb.body.CollidesWith = collisionCategory; + try + { + limb.body.CollidesWith = collisionCategory; + } + catch (Exception e) + { + DebugConsole.ThrowError("Failed to update ragdoll limb collisioncategories", e); + } + } } diff --git a/Subsurface/Source/Events/Quests/Quest.cs b/Subsurface/Source/Events/Quests/Quest.cs index ed5475533..3e21fab28 100644 --- a/Subsurface/Source/Events/Quests/Quest.cs +++ b/Subsurface/Source/Events/Quests/Quest.cs @@ -159,15 +159,15 @@ namespace Barotrauma public void GiveReward() { + if (!string.IsNullOrWhiteSpace(successMessage)) + { + new GUIMessageBox("Quest completed successfully", successMessage); + } + var mode = GameMain.GameSession.gameMode as SinglePlayerMode; if (mode == null) return; mode.Money += reward; - - if (!string.IsNullOrWhiteSpace(successMessage)) - { - new GUIMessageBox("Quest completed", successMessage); - } } } } diff --git a/Subsurface/Source/GUI/GUIComponent.cs b/Subsurface/Source/GUI/GUIComponent.cs index 0e749962f..b793b4d3b 100644 --- a/Subsurface/Source/GUI/GUIComponent.cs +++ b/Subsurface/Source/GUI/GUIComponent.cs @@ -185,10 +185,10 @@ namespace Barotrauma public bool IsParentOf(GUIComponent component) { - foreach (GUIComponent child in children) + for(int i = children.Count - 1; i >= 0; i--) { - if (child == component) return true; - if (child.IsParentOf(component)) return true; + if (children[i] == component) return true; + if (children[i].IsParentOf(component)) return true; } return false; diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index 95655eae0..77faa8aa2 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -305,7 +305,8 @@ namespace Barotrauma if (titleScreenOpen) { TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime); - if (TitleScreen.LoadState>=100.0f && (PlayerInput.GetKeyboardState.GetPressedKeys().Length>0 || PlayerInput.LeftButtonClicked())) + if (TitleScreen.LoadState>=100.0f && + (!waitForKeyHit || PlayerInput.GetKeyboardState.GetPressedKeys().Length>0 || PlayerInput.LeftButtonClicked())) { titleScreenOpen = false; } @@ -325,8 +326,10 @@ namespace Barotrauma Stopwatch sw; - public static void ShowLoading(IEnumerable loader) + static bool waitForKeyHit = true; + public static void ShowLoading(IEnumerable loader, bool waitKeyHit = true) { + waitForKeyHit = waitKeyHit; titleScreenOpen = true; CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader)); diff --git a/Subsurface/Source/GameSession/GameModes/TutorialMode.cs b/Subsurface/Source/GameSession/GameModes/TutorialMode.cs index 6b49c7be9..d8b926c31 100644 --- a/Subsurface/Source/GameSession/GameModes/TutorialMode.cs +++ b/Subsurface/Source/GameSession/GameModes/TutorialMode.cs @@ -213,7 +213,7 @@ namespace Barotrauma yield return new WaitForSeconds(5.0f); infoBox = CreateInfoFrame("You need a screwdriver to check the wiring of the terminal." - + " Equip a screwdriver by pulling it to either of the slots with a hand symbol, and then select the terminal again by pressing E."); + + " Equip a screwdriver by pulling it to either of the slots with a hand symbol, and then use it on the terminal by left clicking."); while (Character.Controlled.SelectedConstruction != steering.Item || Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.Name == "Screwdriver") == null) diff --git a/Subsurface/Source/Items/Components/Holdable/Holdable.cs b/Subsurface/Source/Items/Components/Holdable/Holdable.cs index 99d1c7886..4d4b10d5b 100644 --- a/Subsurface/Source/Items/Components/Holdable/Holdable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Holdable.cs @@ -215,7 +215,7 @@ namespace Barotrauma.Items.Components attached = true; - item.NewComponentEvent(this, true, true); + if (character != null) item.NewComponentEvent(this, true, true); return true; } diff --git a/Subsurface/Source/Items/Components/Holdable/Pickable.cs b/Subsurface/Source/Items/Components/Holdable/Pickable.cs index 6f3e2c3fc..260887a64 100644 --- a/Subsurface/Source/Items/Components/Holdable/Pickable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Pickable.cs @@ -37,7 +37,7 @@ namespace Barotrauma.Items.Components if (picker == null) return false; if (picker.Inventory == null) return false; - if (picker.Inventory.TryPutItem(item, allowedSlots)) + if (picker.Inventory.TryPutItem(item, allowedSlots, picker==Character.Controlled)) { if (!picker.HasSelectedItem(item) && item.body!=null) item.body.Enabled = false; this.picker = picker; diff --git a/Subsurface/Source/Items/Components/ItemComponent.cs b/Subsurface/Source/Items/Components/ItemComponent.cs index 6fab1cba3..3a7cb8744 100644 --- a/Subsurface/Source/Items/Components/ItemComponent.cs +++ b/Subsurface/Source/Items/Components/ItemComponent.cs @@ -108,6 +108,18 @@ namespace Barotrauma.Items.Components set { canBeSelected = value; } } + public InputType PickKey + { + get; + private set; + } + + public InputType SelectKey + { + get; + private set; + } + [HasDefaultValue(false, false)] public bool DeleteOnUse { @@ -166,24 +178,26 @@ namespace Barotrauma.Items.Components statusEffects = new List(); - //var initableProperties = ObjectProperty.GetProperties(this); - //foreach (ObjectProperty initableProperty in initableProperties) - //{ - // object value = ToolBox.GetAttributeObject(element, initableProperty.Name.ToLower()); - // if (value==null) - // { - // foreach (var ini in initableProperty.Attributes.OfType()) - // { - // value = ini.defaultValue; - // break; - // } - // } + SelectKey = InputType.Select; - // initableProperty.TrySetValue(value); - //} - if (item.Name=="Welding Tool") + try { - int a = 1; + SelectKey = (InputType)Enum.Parse(typeof(InputType), ToolBox.GetAttributeString(element, "selectkey", "Select"), true); + } + catch (Exception e) + { + DebugConsole.ThrowError("Invalid select key in " + element + "!", e); + } + + PickKey = InputType.Select; + + try + { + PickKey = (InputType)Enum.Parse(typeof(InputType), ToolBox.GetAttributeString(element, "selectkey", "Select"), true); + } + catch (Exception e) + { + DebugConsole.ThrowError("Invalid pick key in " + element + "!", e); } properties = ObjectProperty.InitProperties(this, element); diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index 0df23e5c4..7940096da 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -77,7 +77,7 @@ namespace Barotrauma.Items.Components if (voltage < minVoltage) return; - if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 200, 30), "Activate Radar")) + if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 200, 30), "Activate Sonar")) { IsActive = !IsActive; item.NewComponentEvent(this, true, false); diff --git a/Subsurface/Source/Items/Components/Projectile.cs b/Subsurface/Source/Items/Components/Projectile.cs index 738b74ee6..d9fadefd2 100644 --- a/Subsurface/Source/Items/Components/Projectile.cs +++ b/Subsurface/Source/Items/Components/Projectile.cs @@ -119,11 +119,31 @@ namespace Barotrauma.Items.Components { if (stickTarget!=null) { - item.body.FarseerBody.RestoreCollisionWith(stickTarget); + try + { + item.body.FarseerBody.RestoreCollisionWith(stickTarget); + } + catch (Exception e) + { +#if DEBUG + DebugConsole.ThrowError("Failed to restore collision with stickTarget", e); +#endif + } + stickTarget = null; } - GameMain.World.RemoveJoint(stickJoint); + try + { + GameMain.World.RemoveJoint(stickJoint); + } + catch (Exception e) + { +#if DEBUG + DebugConsole.ThrowError("Failed to remove stickJoint", e); +#endif + } + stickJoint = null; IsActive = false; diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs index e705e6c0a..ca42763e1 100644 --- a/Subsurface/Source/Items/Components/Signal/Wire.cs +++ b/Subsurface/Source/Items/Components/Signal/Wire.cs @@ -420,11 +420,17 @@ namespace Barotrauma.Items.Components public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message) { Nodes.Clear(); + + List newNodes = new List(); int nodeCount = message.ReadByte(); for (int i = 0; i ushort.MaxValue / 2 && messageId < short.MaxValue / 2) { for (ushort i = (ushort)Math.Min((int)lastMessageID + 1, ushort.MaxValue); i <= ushort.MaxValue; i++) { if (i == ushort.MaxValue && lastMessageID == ushort.MaxValue) break; - if (!missingMessages.ContainsKey(i)) missingMessages.Add(i, new MissingMessage(i)); + QueueMissingMessage(i); if (i == ushort.MaxValue) break; } for (ushort i = 1; i < messageId; i++) { - if (!missingMessages.ContainsKey(i)) missingMessages.Add(i, new MissingMessage(i)); + QueueMissingMessage(i); } } else { + //we already wrapped around but message hasn't, so it's an old message + if (lastMessageID < ushort.MaxValue / 2 && messageId > ushort.MaxValue / 2) + { + Debug.WriteLine("old already received message, ignore"); + return; + } + for (ushort i = (ushort)Math.Min((int)lastMessageID+1, ushort.MaxValue); i <= messageId; i++) { - if (!missingMessages.ContainsKey(i)) missingMessages.Add(i, new MissingMessage(i)); + QueueMissingMessage(i); if (i == ushort.MaxValue) break; } } diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index 3a9bed0be..0716c35b4 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -391,7 +391,7 @@ namespace Barotrauma GUI.Draw((float)deltaTime, spriteBatch, null); - spriteBatch.DrawString(GUI.Font, "Barotrauma chat lag test build", new Vector2(10, GameMain.GraphicsHeight-20), Color.White); + spriteBatch.DrawString(GUI.Font, "Barotrauma v"+GameMain.Version, new Vector2(10, GameMain.GraphicsHeight-20), Color.White); spriteBatch.End(); } diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 4cd6ea86e..162aad873 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ