From 9e49c24eb8684c13fd61316b149abb57a5a5b352 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 21 Sep 2019 12:12:30 -0400 Subject: [PATCH] Core/AuctionHouse: Fixes collection was modified errror. Also fixes mail not having the right subject. --- Source/Game/AuctionHouse/AuctionManager.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Source/Game/AuctionHouse/AuctionManager.cs b/Source/Game/AuctionHouse/AuctionManager.cs index 088bb01bd..d1796ef98 100644 --- a/Source/Game/AuctionHouse/AuctionManager.cs +++ b/Source/Game/AuctionHouse/AuctionManager.cs @@ -24,6 +24,7 @@ using Game.Mails; using Game.Network.Packets; using System; using System.Collections.Generic; +using System.Collections.Concurrent; namespace Game { @@ -426,14 +427,9 @@ namespace Game public bool RemoveAuction(AuctionEntry auction) { - bool wasInMap = AuctionsMap.Remove(auction.Id) ? true : false; - Global.ScriptMgr.OnAuctionRemove(this, auction); - // we need to delete the entry, it is not referenced any more - auction = null; - - return wasInMap; + return AuctionsMap.TryRemove(auction.Id, out AuctionEntry removedItem); } public void Update() @@ -570,7 +566,7 @@ namespace Game return AuctionsMap.LookupByKey(id); } - Dictionary AuctionsMap = new Dictionary(); + ConcurrentDictionary AuctionsMap = new ConcurrentDictionary(); } public class AuctionEntry @@ -761,12 +757,12 @@ namespace Game public string BuildAuctionMailSubject(MailAuctionAnswers response) { - return $"{itemEntry}:0:{response}:{Id}:{itemCount}"; + return $"{itemEntry}:0:{(uint)response}:{Id}:{itemCount}"; } public static string BuildAuctionMailBody(ulong lowGuid, ulong bid, ulong buyout, ulong deposit, ulong cut) { - return string.Format($"{lowGuid}:{bid}:{buyout}:{deposit}:{cut}"); + return $"{lowGuid}:{bid}:{buyout}:{deposit}:{cut}"; } // helpers