fix(hs): roll back team reservation if TryEnterAsync throws

This commit is contained in:
Acentech Dev
2026-07-20 23:48:36 +03:00
parent cd55e726f1
commit 372929a8d1

View File

@@ -160,19 +160,26 @@ public class HeykelSavasiContext : MiniGameContext
return false;
}
var enterResult = await this.TryEnterAsync(player).ConfigureAwait(false);
if (enterResult != EnterResult.Success)
var success = false;
try
{
lock (this._teamLock)
var enterResult = await this.TryEnterAsync(player).ConfigureAwait(false);
success = enterResult == EnterResult.Success;
}
finally
{
if (!success)
{
// Roll back the reservation; the player never actually entered the mini game.
this.RemoveTeam(player);
lock (this._teamLock)
{
// Roll back the reservation; the player never actually entered the mini game
// (or TryEnterAsync threw, e.g. due to a disconnect/disposal race).
this.RemoveTeam(player);
}
}
return false;
}
return true;
return success;
}
/// <summary>