- converting NetworkEvent sending time to local time before doing any comparisons

- using mersenne twister for random number generation due to differences in Mono and .NET implementations of the Random library
- password prompt for password-protected private servers
- fixed deconstructor, fabricator and railgun connection panels closing immediately after opening
- fixed editor saving newly created subs to the root folder instead of the Submarines folder
- keeping items in the same inventory slots between clients instead of just syncing which items are in the inventory
- fixed crashing when swapping items between different limbslots
This commit is contained in:
Regalis
2016-03-03 21:11:54 +02:00
parent 35c36d283a
commit 40714c1102
21 changed files with 225 additions and 59 deletions
+10 -7
View File
@@ -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))
{