Fixed exceptions in ServerEntityEventManager if there are no clients on the server, clients who are in the lobby can't prevent outdated EntityEvents from being removed

This commit is contained in:
Regalis
2017-02-18 13:18:48 +02:00
parent 68b0f2132a
commit 0e66f2a69c
@@ -109,8 +109,11 @@ namespace Barotrauma.Networking
bufferedEvent.IsProcessed = true; bufferedEvent.IsProcessed = true;
} }
if (clients.Count > 0)
{
lastSentToAll = clients[0].lastRecvEntityEventID; lastSentToAll = clients[0].lastRecvEntityEventID;
clients.ForEach(c => { if (c.lastRecvEntityEventID < lastSentToAll) lastSentToAll = c.lastRecvEntityEventID; }); clients.ForEach(c => { if (c.inGame) lastSentToAll = Math.Min(lastSentToAll, c.lastRecvEntityEventID); });
}
bufferedEvents.RemoveAll(b => b.IsProcessed); bufferedEvents.RemoveAll(b => b.IsProcessed);
} }