WIP Make networking code thread-safe and refactor update ID

Replaces direct increments of LastClientListUpdateID with a thread-safe IncrementLastClientListUpdateID method and uses Interlocked for atomic operations. Refactors EntitySpawner to lock access to the spawn/remove queue for thread safety. Updates INetSerializableStruct to use concurrent collections for cached variables and type behaviors, improving thread safety in networking code.
This commit is contained in:
Eero
2025-12-28 13:10:17 +08:00
parent 31812d524d
commit c5fa49405f
8 changed files with 111 additions and 51 deletions
@@ -174,7 +174,7 @@ namespace Barotrauma.Networking
StartTime = DateTime.Now;
OnStarted(transfer);
GameMain.Server.LastClientListUpdateID++;
GameMain.Server.IncrementLastClientListUpdateID();
return transfer;
}
@@ -204,7 +204,7 @@ namespace Barotrauma.Networking
if (numRemoved > 0 || endedTransfers.Count > 0)
{
GameMain.Server.LastClientListUpdateID++;
GameMain.Server.IncrementLastClientListUpdateID();
}
}