Skip to content

Commit f492072

Browse files
committed
Fix modified collection exception error
1 parent 915b33f commit f492072

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/Atlasd/Battlenet/Protocols/Game/Messages/SID_GETADVLISTEX.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ public override bool Invoke(MessageContext context)
6060

6161
lock (Battlenet.Common.ActiveGameAds)
6262
{
63+
IList<GameAd> toDelete = new List<GameAd>();
6364
foreach (var gameAd in Battlenet.Common.ActiveGameAds)
6465
{
6566
if (gameAd.Clients.Count == 0)
6667
{
67-
Battlenet.Common.ActiveGameAds.Remove(gameAd);
68+
toDelete.Add(gameAd);
6869
continue;
6970
}
7071

@@ -79,6 +80,11 @@ public override bool Invoke(MessageContext context)
7980

8081
gameAds.Add(gameAd);
8182
}
83+
while (toDelete.Count > 0)
84+
{
85+
Battlenet.Common.ActiveGameAds.Remove(toDelete[0]);
86+
toDelete.RemoveAt(0);
87+
}
8288
}
8389

8490
return new SID_GETADVLISTEX().Invoke(new MessageContext(context.Client, MessageDirection.ServerToClient, new Dictionary<string, dynamic>(){

0 commit comments

Comments
 (0)