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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user