fix(hs): roll back team reservation if TryEnterAsync throws
This commit is contained in:
@@ -160,19 +160,26 @@ public class HeykelSavasiContext : MiniGameContext
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var enterResult = await this.TryEnterAsync(player).ConfigureAwait(false);
|
var success = false;
|
||||||
if (enterResult != EnterResult.Success)
|
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.
|
lock (this._teamLock)
|
||||||
this.RemoveTeam(player);
|
{
|
||||||
|
// 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>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user