- 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
+14 -26
View File
@@ -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<ushort> newItemIDs = new List<ushort>();
List<Item> droppedItems = new List<Item>();
List<Item> prevItems = new List<Item>(Items);
byte count = message.ReadByte();
for (int i = 0; i<count; i++)
{
newItemIDs.Add(message.ReadUInt16());
}
for (int i = 0; i < capacity; i++)
{
if (Items[i] == null) continue;
if (!newItemIDs.Contains(Items[i].ID))
ushort itemId = message.ReadUInt16();
if (itemId==0)
{
droppedItems.Add(Items[i]);
Items[i].Drop(null, false);
continue;
if (Items[i] != null) Items[i].Drop();
}
}
foreach (ushort itemId in newItemIDs)
{
Item item = Entity.FindEntityByID(itemId) as Item;
if (item == null) continue;
else
{
var item = Entity.FindEntityByID(itemId) as Item;
if (item == null) continue;
TryPutItem(item, item.AllowedSlots, false);
if (droppedItems.Contains(item)) droppedItems.Remove(item);
TryPutItem(item, i, true, false);
}
}
lastUpdate = sendingTime;