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
|
else
|
||||||
{
|
{
|
||||||
|
if (syncItemsCoroutine != null)
|
||||||
|
{
|
||||||
|
CoroutineManager.StopCoroutines(syncItemsCoroutine);
|
||||||
|
syncItemsCoroutine = null;
|
||||||
|
}
|
||||||
ApplyReceivedState();
|
ApplyReceivedState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<object> SyncItemsAfterDelay()
|
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;
|
syncItemsDelay -= CoroutineManager.DeltaTime;
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
@@ -511,19 +516,21 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private void ApplyReceivedState()
|
private void ApplyReceivedState()
|
||||||
{
|
{
|
||||||
if (receivedItemIDs == null) return;
|
for (int i = 0; i < capacity; i++)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < capacity; i++)
|
for (int i = 0; i < capacity; i++)
|
||||||
{
|
{
|
||||||
if (receivedItemIDs[i] == 0)
|
if (receivedItemIDs[i] > 0)
|
||||||
{
|
|
||||||
if (Items[i] != null) Items[i].Drop();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
var item = Entity.FindEntityByID(receivedItemIDs[i]) as Item;
|
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);
|
TryPutItem(item, i, true, true, null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,19 +203,21 @@ namespace Barotrauma
|
|||||||
newItemIDs[i] = msg.ReadUInt16();
|
newItemIDs[i] = msg.ReadUInt16();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == null || c.Character == null || !c.Character.CanAccessInventory(this))
|
if (c == null || c.Character == null || !c.Character.CanAccessInventory(this)) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < capacity; i++)
|
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);
|
if (Items[i] != null) Items[i].Drop();
|
||||||
System.Diagnostics.Debug.Assert(Items[i]==null);
|
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;
|
var item = Entity.FindEntityByID(newItemIDs[i]) as Item;
|
||||||
if (item == null || item == Items[i]) continue;
|
if (item == null || item == Items[i]) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user