fix(hs): roll back team reservation if TryEnterAsync throws
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user