fix bug which could cause multiple players to have the same ID (closes #154)

This commit is contained in:
Lion Kortlepel
2022-11-13 14:00:31 +01:00
parent 2f85c708c5
commit 8551e68184
2 changed files with 5 additions and 0 deletions

View File

@@ -577,6 +577,10 @@ void TNetwork::OnDisconnect(const std::weak_ptr<TClient>& ClientPtr) {
}
int TNetwork::OpenID() {
// This lock ensures that each call to OpenID is exclusive.
// If we didn't have this, two concurrent calls to this function may result
// in the same ID.
std::unique_lock Lock(mOpenIDMutex);
int ID = 0;
bool found;
do {