public Dictionary <int, ItemInfo> GetItemInfoCache(WowVersionEnum _WowVersion, bool _WaitForLoad = true) { if (_WowVersion == WowVersionEnum.Vanilla) { if (m_ItemInfoCacheVanilla == null && _WaitForLoad == true) { if (_WaitForLoad == true) { Monitor.Enter(m_ItemInfoLock); } else { if (Monitor.TryEnter(m_ItemInfoLock) == false) { return(m_ItemInfoCacheVanilla); } } try { if (m_ItemInfoCacheVanilla == null) { if (System.IO.File.Exists(Constants.RPPDbDir + "VF_ItemInfoCache.dat")) { Dictionary <int, ItemInfo> itemInfoCache = new Dictionary <int, ItemInfo>(); if (VF_RealmPlayersDatabase.Utility.LoadSerialize(Constants.RPPDbDir + "VF_ItemInfoCache.dat", out itemInfoCache)) { m_ItemInfoCacheVanilla = itemInfoCache; } } if (m_ItemDropDatabase == null) { m_ItemDropDatabase = new ItemDropDatabase(Constants.RPPDbDir + "Database\\"); } } if (m_ItemInfoCacheVanilla == null) { m_ItemInfoCacheVanilla = new Dictionary <int, ItemInfo>(); } } catch (Exception ex) { Logger.LogException(ex); } Monitor.Exit(m_ItemInfoLock); return(m_ItemInfoCacheVanilla); } else { return(m_ItemInfoCacheVanilla); } } else if (_WowVersion == WowVersionEnum.TBC) { if (m_ItemInfoCacheTBC == null && _WaitForLoad == true) { if (_WaitForLoad == true) { Monitor.Enter(m_ItemInfoLock); } else { if (Monitor.TryEnter(m_ItemInfoLock) == false) { return(m_ItemInfoCacheTBC); } } try { if (m_ItemInfoCacheTBC == null) { if (System.IO.File.Exists(Constants.RPPDbDir + "VF_ItemInfoCacheTBC.dat")) { Dictionary <int, ItemInfo> itemInfoCache = new Dictionary <int, ItemInfo>(); if (VF_RealmPlayersDatabase.Utility.LoadSerialize(Constants.RPPDbDir + "VF_ItemInfoCacheTBC.dat", out itemInfoCache)) { m_ItemInfoCacheTBC = itemInfoCache; } } if (m_ItemDropDatabase == null) { m_ItemDropDatabase = new ItemDropDatabase(Constants.RPPDbDir + "Database\\"); } } if (m_ItemInfoCacheTBC == null) { m_ItemInfoCacheTBC = new Dictionary <int, ItemInfo>(); } } catch (Exception ex) { Logger.LogException(ex); } Monitor.Exit(m_ItemInfoLock); return(m_ItemInfoCacheTBC); } else { return(m_ItemInfoCacheTBC); } } return(null); }
static void FixDatabase(string _Name, string _DatabaseFile, ItemDropDatabase _ItemDropDatabase, DateTime _BetweenDate_MIN, DateTime _BetweenDate_HonorMAX, DateTime _BetweenDate_ItemMax) { Dictionary <string, PlayerData.PlayerHistory> historyData = null; VF_RealmPlayersDatabase.Utility.LoadSerialize(_DatabaseFile, out historyData); List <string> gearFixed = new List <string>(); List <string> honorFixed = new List <string>(); List <string> triedHonorFix = new List <string>(); foreach (var playerHistory in historyData) { var honorHistorys = playerHistory.Value.HonorHistory; var gearHistorys = playerHistory.Value.GearHistory; bool fixedHonor = false; bool triedFixedHonor = false; bool fixedGear = false; if (honorHistorys.Count > 0) { if (honorHistorys.Last().Uploader.GetTime() > _BetweenDate_MIN) { int realLifeTimeHighestRank = 0; float realRankProgress = 0; int realRank = 0; if (honorHistorys.Last().Uploader.GetTime() > _BetweenDate_HonorMAX) { for (int i = honorHistorys.Count - 1; i >= 0; --i) { if (honorHistorys[i].Uploader.GetTime() < _BetweenDate_HonorMAX) { if (honorHistorys[i].Uploader.GetTime() > _BetweenDate_MIN) { if (honorHistorys[i].Data.LifetimeHighestRank > realLifeTimeHighestRank) { honorHistorys[i].Data.CurrentRank = realRank; honorHistorys[i].Data.CurrentRankProgress = realRankProgress; honorHistorys[i].Data.LifetimeHighestRank = realLifeTimeHighestRank; fixedHonor = true; } } } else { realLifeTimeHighestRank = honorHistorys[i].Data.LifetimeHighestRank; realRankProgress = honorHistorys[i].Data.CurrentRankProgress; realRank = honorHistorys[i].Data.CurrentRank; } } } else { for (int i = 0; i < honorHistorys.Count; ++i) { if (honorHistorys[i].Uploader.GetTime() > _BetweenDate_MIN) { if (honorHistorys[i].Data.LifetimeHighestRank != realLifeTimeHighestRank || honorHistorys[i].Data.CurrentRank != realRank) { if (realRank != 0) { honorHistorys[i].Data.CurrentRank = realRank; honorHistorys[i].Data.CurrentRankProgress = realRankProgress; honorHistorys[i].Data.LifetimeHighestRank = realLifeTimeHighestRank; fixedHonor = true; } else { triedFixedHonor = true; } } } else { realLifeTimeHighestRank = honorHistorys[i].Data.LifetimeHighestRank; realRankProgress = honorHistorys[i].Data.CurrentRankProgress; realRank = honorHistorys[i].Data.CurrentRank; } } } } } if (fixedHonor == true) { honorFixed.Add(playerHistory.Key); } if (triedFixedHonor == true) { triedHonorFix.Add(playerHistory.Key); } if (gearHistorys.Count > 0) { List <int> haveItem = new List <int>(); if (gearHistorys.Last().Uploader.GetTime() > _BetweenDate_MIN) { for (int i = gearHistorys.Count - 1; i >= 0; --i) { if (gearHistorys[i].Uploader.GetTime() > _BetweenDate_MIN && gearHistorys[i].Uploader.GetTime() < _BetweenDate_ItemMax) { var removeItemsSlots = new List <ItemSlot>(); foreach (var item in gearHistorys[i].Data.Items) { if (haveItem.Contains(item.Value.ItemID) == false) { try { var dropInfos = _ItemDropDatabase.GetDatabase()[item.Value.ItemID]; foreach (var dropInfo in dropInfos) { int currBoss = (int)dropInfo.m_Boss; if ((currBoss >= (int)VF_RealmPlayersDatabase.WowBoss.PVPSetFirst && currBoss <= (int)VF_RealmPlayersDatabase.WowBoss.PVPSetLast) /* || (currBoss >= (int)VF_RealmPlayersDatabase.WowBoss.PVPOffsetFirst && currBoss <= (int)VF_RealmPlayersDatabase.WowBoss.PVPOffsetLast)*/) { removeItemsSlots.Add(item.Key); fixedGear = true; } } } catch (Exception ex) { } } } foreach (var removeSlot in removeItemsSlots) { gearHistorys[i].Data.Items.Remove(removeSlot); } } else { foreach (var item in gearHistorys[i].Data.Items) { if (haveItem.Contains(item.Value.ItemID) == false) { haveItem.Add(item.Value.ItemID); } } } } } } if (fixedGear == true) { gearFixed.Add(playerHistory.Key); } } System.IO.File.WriteAllLines("Fix_" + _Name + "_FixedGear.txt", gearFixed.ToArray()); System.IO.File.WriteAllLines("Fix_" + _Name + "_FixedHonor.txt", honorFixed.ToArray()); System.IO.File.WriteAllLines("Fix_" + _Name + "_TriedFixHonor.txt", triedHonorFix.ToArray()); VF_RealmPlayersDatabase.Utility.SaveSerialize(_DatabaseFile, historyData); }