diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj
index 611aea7c1..562d70328 100644
--- a/Subsurface/Barotrauma.csproj
+++ b/Subsurface/Barotrauma.csproj
@@ -142,6 +142,7 @@
+
diff --git a/Subsurface/Content/Items/Fabricators/fabricators.xml b/Subsurface/Content/Items/Fabricators/fabricators.xml
index c585eec6d..ad101c1ec 100644
--- a/Subsurface/Content/Items/Fabricators/fabricators.xml
+++ b/Subsurface/Content/Items/Fabricators/fabricators.xml
@@ -49,7 +49,7 @@
-
+
@@ -73,7 +73,7 @@
-
+
diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml
index ad75a5009..b90e28e1f 100644
--- a/Subsurface/Content/Items/Weapons/railgun.xml
+++ b/Subsurface/Content/Items/Weapons/railgun.xml
@@ -17,7 +17,7 @@
-
+
@@ -40,7 +40,7 @@
-
+
diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveCombat.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveCombat.cs
index 5dd2f96c4..ec5711587 100644
--- a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveCombat.cs
+++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveCombat.cs
@@ -47,7 +47,7 @@ namespace Barotrauma
{
if (!character.SelectedItems.Contains(weapon))
{
- character.Inventory.TryPutItem(weapon, 3, false);
+ character.Inventory.TryPutItem(weapon, 3, true, false);
weapon.Equip(character);
}
character.CursorPosition = enemy.Position;
diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs
index c7db395eb..d31622b6c 100644
--- a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs
+++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs
@@ -88,7 +88,7 @@ namespace Barotrauma
if (targetSlot>-1 && character.Inventory.IsInLimbSlot(targetItem, LimbSlot.Any))
{
- character.Inventory.TryPutItem(targetItem, targetSlot, false);
+ character.Inventory.TryPutItem(targetItem, targetSlot, true, false);
}
}
diff --git a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
index e4f3ef309..5e6578213 100644
--- a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
+++ b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
@@ -875,15 +875,17 @@ namespace Barotrauma
Vector2 itemPos = aim ? aimPos : holdPos;
+ bool usingController = character.SelectedConstruction != null && character.SelectedConstruction.GetComponent() != null;
+
+
float itemAngle;
- if (Anim != Animation.Climbing && stunTimer <= 0.0f && aim && itemPos != Vector2.Zero)
+ if (Anim != Animation.Climbing && !usingController && stunTimer <= 0.0f && aim && itemPos != Vector2.Zero)
{
Vector2 mousePos = ConvertUnits.ToSimUnits(character.CursorPosition);
Vector2 diff = (mousePos - torso.SimPosition) * Dir;
holdAngle = MathUtils.VectorToAngle(new Vector2(diff.X, diff.Y * Dir)) - torso.body.Rotation * Dir;
- //holdAngle = MathHelper.Clamp(MathUtils.WrapAnglePi(holdAngle), -1.3f, 1.0f);
itemAngle = (torso.body.Rotation + holdAngle * Dir);
@@ -909,7 +911,7 @@ namespace Barotrauma
Vector2 shoulderPos = limbJoints[2].WorldAnchorA;
Vector2 transformedHoldPos = shoulderPos;
- if (itemPos == Vector2.Zero || Anim == Animation.Climbing || (leftHand.Disabled && rightHand.Disabled))
+ if (itemPos == Vector2.Zero || Anim == Animation.Climbing || usingController)
{
if (character.SelectedItems[1] == item)
{
diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs
index d43e7c342..4f4629125 100644
--- a/Subsurface/Source/Characters/Character.cs
+++ b/Subsurface/Source/Characters/Character.cs
@@ -487,7 +487,7 @@ namespace Barotrauma
if (item == null) continue;
item.Pick(this, true, true, true);
- inventory.TryPutItem(item, i, false);
+ inventory.TryPutItem(item, i, false, false);
}
}
}
diff --git a/Subsurface/Source/Characters/CharacterHUD.cs b/Subsurface/Source/Characters/CharacterHUD.cs
index 2fc846110..669d19dc7 100644
--- a/Subsurface/Source/Characters/CharacterHUD.cs
+++ b/Subsurface/Source/Characters/CharacterHUD.cs
@@ -96,6 +96,8 @@ namespace Barotrauma
}
}
+ if (Screen.Selected == GameMain.EditMapScreen) return;
+
if (character.Oxygen < 50.0f && !character.IsDead)
{
Vector2 offset = Rand.Vector(noiseOverlay.size.X);
diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs
index 3fd75bb56..6e0318434 100644
--- a/Subsurface/Source/Items/CharacterInventory.cs
+++ b/Subsurface/Source/Items/CharacterInventory.cs
@@ -149,7 +149,7 @@ namespace Barotrauma
return placed;
}
- public override bool TryPutItem(Item item, int index, bool createNetworkEvent)
+ public override bool TryPutItem(Item item, int index, bool allowSwapping, bool createNetworkEvent)
{
//there's already an item in the slot
if (Items[index] != null)
@@ -173,7 +173,7 @@ namespace Barotrauma
combined = true;
}
//if moving the item between slots in the same inventory
- else if (item.ParentInventory == this)
+ else if (item.ParentInventory == this && allowSwapping)
{
int currentIndex = Array.IndexOf(Items, item);
@@ -182,16 +182,19 @@ namespace Barotrauma
Items[currentIndex] = null;
Items[index] = null;
//if the item in the slot can be moved to the slot of the moved item
- if (TryPutItem(existingItem, currentIndex, false) &&
- TryPutItem(item, index, false))
+ if (TryPutItem(existingItem, currentIndex, false, false) &&
+ TryPutItem(item, index, false, false))
{
new Networking.NetworkEvent(Networking.NetworkEventType.InventoryUpdate, Owner.ID, true, true);
}
else
{
+ Items[currentIndex] = null;
+ Items[index] = null;
+
//swapping the items failed -> move them back to where they were
- TryPutItem(item, currentIndex, false);
- TryPutItem(existingItem, index, false);
+ TryPutItem(item, currentIndex, false, false);
+ TryPutItem(existingItem, index, false, false);
}
}
@@ -416,7 +419,7 @@ namespace Barotrauma
if (Items[i] != item && Items[i] != null) Items[i].Drop(character, false);
- if (TryPutItem(item, i, false))
+ if (TryPutItem(item, i, false, false))
{
if (droppedItems.Contains(item))
{
diff --git a/Subsurface/Source/Items/Components/ItemContainer.cs b/Subsurface/Source/Items/Components/ItemContainer.cs
index 0f529c2d9..fd9d3fdf9 100644
--- a/Subsurface/Source/Items/Components/ItemContainer.cs
+++ b/Subsurface/Source/Items/Components/ItemContainer.cs
@@ -241,7 +241,7 @@ namespace Barotrauma.Items.Components
Item item = MapEntity.FindEntityByID(itemIds[i]) as Item;
if (item == null) continue;
- Inventory.TryPutItem(item, i, false);
+ Inventory.TryPutItem(item, i, false, false);
}
itemIds = null;
diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs
index 65778372f..ba090f4d4 100644
--- a/Subsurface/Source/Items/Inventory.cs
+++ b/Subsurface/Source/Items/Inventory.cs
@@ -104,7 +104,7 @@ namespace Barotrauma
return true;
}
- public virtual bool TryPutItem(Item item, int i, bool createNetworkEvent = true)
+ public virtual bool TryPutItem(Item item, int i, bool allowSwapping, bool createNetworkEvent)
{
if (Owner == null) return false;
if (CanBePut(item,i))
@@ -274,7 +274,7 @@ namespace Barotrauma
}
//selectedSlot = slotIndex;
- TryPutItem(draggingItem, slotIndex);
+ TryPutItem(draggingItem, slotIndex, true, true);
draggingItem = null;
}
@@ -351,11 +351,9 @@ namespace Barotrauma
public virtual bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
{
- var foundItems = Array.FindAll(Items, i => i != null);
- message.Write((byte)foundItems.Count());
- foreach (Item item in foundItems)
+ for (int i = 0; i < capacity; i++)
{
- message.Write((ushort)item.ID);
+ message.Write((ushort)(Items[i]==null ? 0 : Items[i].ID));
}
return true;
@@ -368,31 +366,21 @@ namespace Barotrauma
List newItemIDs = new List();
List- droppedItems = new List
- ();
List
- prevItems = new List
- (Items);
-
- byte count = message.ReadByte();
- for (int i = 0; i c.name.ToLower() == name.ToLower() && c.ID!=userID) != null)
+ else if (ConnectedClients.Find(c => c.name.ToLower() == name.ToLower() && c.ID != userID) != null)
{
inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name.");
DebugConsole.NewMessage(name + " couldn't join the server (name already in use)", Color.Red);
diff --git a/Subsurface/Source/Networking/NetworkEvent.cs b/Subsurface/Source/Networking/NetworkEvent.cs
index 563b7ffd8..03511e2ab 100644
--- a/Subsurface/Source/Networking/NetworkEvent.cs
+++ b/Subsurface/Source/Networking/NetworkEvent.cs
@@ -160,6 +160,8 @@ namespace Barotrauma.Networking
{
float sendingTime = message.ReadFloat();
+ sendingTime = (float)message.SenderConnection.GetLocalTime(sendingTime);
+
byte msgCount = message.ReadByte();
long currPos = message.PositionInBytes;
diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs
index 22f711a76..d8f987b4d 100644
--- a/Subsurface/Source/Screens/EditMapScreen.cs
+++ b/Subsurface/Source/Screens/EditMapScreen.cs
@@ -298,6 +298,10 @@ namespace Barotrauma
{
savePath = Path.Combine(Path.GetDirectoryName(Submarine.Loaded.FilePath), savePath);
}
+ else
+ {
+ savePath = Path.Combine(Submarine.SavePath, savePath);
+ }
Submarine.SaveCurrent(savePath);
Submarine.Loaded.CheckForErrors();
diff --git a/Subsurface/Source/Screens/ServerListScreen.cs b/Subsurface/Source/Screens/ServerListScreen.cs
index 26a57b4c6..5b2cfb8b5 100644
--- a/Subsurface/Source/Screens/ServerListScreen.cs
+++ b/Subsurface/Source/Screens/ServerListScreen.cs
@@ -293,17 +293,22 @@ namespace Barotrauma
return false;
}
- CoroutineManager.StartCoroutine(JoinServer(ip));
+ CoroutineManager.StartCoroutine(ConnectToServer(ip, serverList.Selected != null && (serverList.Selected.GetChild("password") as GUITickBox).Selected));
return true;
}
- private IEnumerable