diff --git a/MagazinePatcher.csproj b/MagazinePatcher.csproj index 2180adf..eeae914 100644 --- a/MagazinePatcher.csproj +++ b/MagazinePatcher.csproj @@ -19,7 +19,7 @@ true full false - bin\Debug\ + bin\Release\ DEBUG;TRACE prompt 4 diff --git a/Scripts/CompatibleMagazineCache.cs b/Scripts/CompatibleMagazineCache.cs index f963060..44fa3c0 100644 --- a/Scripts/CompatibleMagazineCache.cs +++ b/Scripts/CompatibleMagazineCache.cs @@ -43,10 +43,6 @@ public CompatibleMagazineCache() BlacklistEntries = new Dictionary(); } - public void PrintBlacklist() - { - if(BlacklistEntries.coun) - } public void AddMagazineData(FVRFireArmMagazine mag) { @@ -148,8 +144,11 @@ public class MagazineBlacklistEntry { public string FirearmID; public List MagazineBlacklist = new List(); + public List MagazineWhitelist = new List(); public List ClipBlacklist = new List(); + public List ClipWhitelist = new List(); public List RoundBlacklist = new List(); + public List RoundWhitelist = new List(); public MagazineBlacklistEntry() { @@ -159,5 +158,32 @@ public bool IsItemBlacklisted(string itemID) { return MagazineBlacklist.Contains(itemID) || ClipBlacklist.Contains(itemID) || RoundBlacklist.Contains(itemID); } + + public bool IsMagazineAllowed(string itemID) + { + if(MagazineWhitelist.Count > 0 && (!MagazineWhitelist.Contains(itemID))) return false; + + if (MagazineBlacklist.Contains(itemID)) return false; + + return true; + } + + public bool IsClipAllowed(string itemID) + { + if (ClipWhitelist.Count > 0 && (!ClipWhitelist.Contains(itemID))) return false; + + if (ClipBlacklist.Contains(itemID)) return false; + + return true; + } + + public bool IsRoundAllowed(string itemID) + { + if (RoundWhitelist.Count > 0 && (!RoundWhitelist.Contains(itemID))) return false; + + if (RoundWhitelist.Contains(itemID)) return false; + + return true; + } } } diff --git a/Scripts/MagazinePatcher.cs b/Scripts/MagazinePatcher.cs index 8b8f49f..7bf042a 100644 --- a/Scripts/MagazinePatcher.cs +++ b/Scripts/MagazinePatcher.cs @@ -420,25 +420,10 @@ private static void ApplyMagazineCache(CompatibleMagazineCache magazineCache, Di foreach (string mag in entry.CompatibleMagazines) { - - //true && (!true || !true) - if (IM.OD.ContainsKey(mag) && ((!blacklist.ContainsKey(firearm.ItemID)) || (!blacklist[firearm.ItemID].MagazineBlacklist.Contains(mag)))) + if (IM.OD.ContainsKey(mag) && (!firearm.CompatibleMagazines.Any(o => o.ItemID == mag)) && ((!blacklist.ContainsKey(firearm.ItemID)) || blacklist[firearm.ItemID].IsMagazineAllowed(mag))) { FVRObject magazineObject = IM.OD[mag]; - if (entry.FirearmID == "SKSClassic") - { - PatchLogger.Log("Caching (" + entry.FirearmID + ") with mag (" + mag + ")", PatchLogger.LogType.General); - PatchLogger.Log($"Is item in blacklist : {blacklist.ContainsKey(firearm.ItemID)}", PatchLogger.LogType.General); - - if (blacklist.ContainsKey(firearm.ItemID)) - { - PatchLogger.Log($"Is mag in blacklist : {blacklist[firearm.ItemID].MagazineBlacklist.Contains(mag)}", PatchLogger.LogType.General); - } - - } - - firearm.CompatibleMagazines.Add(magazineObject); if (magazineCache.AmmoObjects.ContainsKey(mag)) magazineObject.MagazineCapacity = magazineCache.AmmoObjects[mag].Capacity; @@ -449,7 +434,7 @@ private static void ApplyMagazineCache(CompatibleMagazineCache magazineCache, Di } foreach (string clip in entry.CompatibleClips) { - if (IM.OD.ContainsKey(clip) && (!blacklist.ContainsKey(firearm.ItemID) || !blacklist[firearm.ItemID].ClipBlacklist.Contains(clip))) + if (IM.OD.ContainsKey(clip) && (!firearm.CompatibleClips.Any(o => o.ItemID == clip)) && ((!blacklist.ContainsKey(firearm.ItemID)) || blacklist[firearm.ItemID].IsClipAllowed(clip))) { FVRObject clipObject = IM.OD[clip]; @@ -463,7 +448,7 @@ private static void ApplyMagazineCache(CompatibleMagazineCache magazineCache, Di } foreach (string bullet in entry.CompatibleBullets) { - if (IM.OD.ContainsKey(bullet) && (!blacklist.ContainsKey(firearm.ItemID) || !blacklist[firearm.ItemID].RoundBlacklist.Contains(bullet))) + if (IM.OD.ContainsKey(bullet) && (!firearm.CompatibleSingleRounds.Any(o => o.ItemID == bullet)) && ((!blacklist.ContainsKey(firearm.ItemID)) || blacklist[firearm.ItemID].IsRoundAllowed(bullet))) { firearm.CompatibleSingleRounds.Add(IM.OD[bullet]); }