Fixed items occasionally dropping instead of being moved to another inventory client-side. Closes #558
This commit is contained in:
@@ -487,13 +487,18 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (syncItemsCoroutine != null)
|
||||
{
|
||||
CoroutineManager.StopCoroutines(syncItemsCoroutine);
|
||||
syncItemsCoroutine = null;
|
||||
}
|
||||
ApplyReceivedState();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<object> SyncItemsAfterDelay()
|
||||
{
|
||||
while (syncItemsDelay > 0.0f && GameMain.Client != null && GameMain.Client.MidRoundSyncing)
|
||||
while (syncItemsDelay > 0.0f || (GameMain.Client != null && GameMain.Client.MidRoundSyncing))
|
||||
{
|
||||
syncItemsDelay -= CoroutineManager.DeltaTime;
|
||||
yield return CoroutineStatus.Running;
|
||||
@@ -511,19 +516,21 @@ namespace Barotrauma
|
||||
|
||||
private void ApplyReceivedState()
|
||||
{
|
||||
if (receivedItemIDs == null) return;
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (receivedItemIDs[i] == 0)
|
||||
if (receivedItemIDs[i] == 0 || (Entity.FindEntityByID(receivedItemIDs[i]) as Item != Items[i]))
|
||||
{
|
||||
if (Items[i] != null) Items[i].Drop();
|
||||
System.Diagnostics.Debug.Assert(Items[i] == null);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (receivedItemIDs[i] > 0)
|
||||
{
|
||||
var item = Entity.FindEntityByID(receivedItemIDs[i]) as Item;
|
||||
if (item == null) continue;
|
||||
|
||||
if (item == null || item == Items[i]) continue;
|
||||
TryPutItem(item, i, true, true, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,20 +202,22 @@ namespace Barotrauma
|
||||
{
|
||||
newItemIDs[i] = msg.ReadUInt16();
|
||||
}
|
||||
|
||||
if (c == null || c.Character == null || !c.Character.CanAccessInventory(this))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == null || c.Character == null || !c.Character.CanAccessInventory(this)) return;
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (newItemIDs[i] == 0)
|
||||
if (newItemIDs[i] == 0 || (Entity.FindEntityByID(newItemIDs[i]) as Item != Items[i]))
|
||||
{
|
||||
if (Items[i] != null) Items[i].Drop(c.Character);
|
||||
System.Diagnostics.Debug.Assert(Items[i]==null);
|
||||
if (Items[i] != null) Items[i].Drop();
|
||||
System.Diagnostics.Debug.Assert(Items[i] == null);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (newItemIDs[i] > 0)
|
||||
{
|
||||
var item = Entity.FindEntityByID(newItemIDs[i]) as Item;
|
||||
if (item == null || item == Items[i]) continue;
|
||||
|
||||
Reference in New Issue
Block a user