diff --git a/BizHawk.Client.Common/BinarySaveStates.cs b/BizHawk.Client.Common/BinarySaveStates.cs index e583c532d3..edf95727c5 100644 --- a/BizHawk.Client.Common/BinarySaveStates.cs +++ b/BizHawk.Client.Common/BinarySaveStates.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using ICSharpCode.SharpZipLib.Zip; using System.IO; @@ -9,16 +6,16 @@ namespace BizHawk.Client.Common { public class BinaryStateFileNames { - public const string versiontag = "BizState 1.0"; - public const string corestate = "Core"; - public const string framebuffer = "Framebuffer"; - public const string input = "Input Log"; + public const string Versiontag = "BizState 1.0"; + public const string Corestate = "Core"; + public const string Framebuffer = "Framebuffer"; + public const string Input = "Input Log"; } public class BinaryStateLoader : IDisposable { - private bool isDisposed = false; + private bool isDisposed; public void Dispose() { Dispose(true); @@ -50,7 +47,7 @@ namespace BizHawk.Client.Common try { ret.zip = new ZipFile(Filename); - var e = ret.zip.GetEntry(BinaryStateFileNames.versiontag); + var e = ret.zip.GetEntry(BinaryStateFileNames.Versiontag); if (e == null) { ret.zip.Close(); @@ -87,23 +84,23 @@ namespace BizHawk.Client.Common public void GetCoreState(Action callback) { - GetFileByName(BinaryStateFileNames.corestate, true, callback); + GetFileByName(BinaryStateFileNames.Corestate, true, callback); } public bool GetFrameBuffer(Action callback) { - return GetFileByName(BinaryStateFileNames.framebuffer, false, callback); + return GetFileByName(BinaryStateFileNames.Framebuffer, false, callback); } public void GetInputLogRequired(Action callback) { - GetFileByName(BinaryStateFileNames.input, true, callback); + GetFileByName(BinaryStateFileNames.Input, true, callback); } } public class BinaryStateSaver : IDisposable { - ZipOutputStream zip; + private readonly ZipOutputStream zip; /// /// @@ -111,18 +108,19 @@ namespace BizHawk.Client.Common /// not closed when finished! public BinaryStateSaver(Stream s) { - zip = new ZipOutputStream(s); - zip.IsStreamOwner = false; + zip = new ZipOutputStream(s) + { + IsStreamOwner = false, + UseZip64 = UseZip64.Off + }; zip.SetLevel(0); - zip.UseZip64 = UseZip64.Off; - PutFileByName(BinaryStateFileNames.versiontag, (ss) => { }); + PutFileByName(BinaryStateFileNames.Versiontag, ss => { }); } void PutFileByName(string Name, Action callback) { - var e = new ZipEntry(Name); - e.CompressionMethod = CompressionMethod.Stored; + var e = new ZipEntry(Name) {CompressionMethod = CompressionMethod.Stored}; zip.PutNextEntry(e); callback(zip); zip.CloseEntry(); @@ -130,20 +128,20 @@ namespace BizHawk.Client.Common public void PutCoreState(Action callback) { - PutFileByName(BinaryStateFileNames.corestate, callback); + PutFileByName(BinaryStateFileNames.Corestate, callback); } public void PutFrameBuffer(Action callback) { - PutFileByName(BinaryStateFileNames.framebuffer, callback); + PutFileByName(BinaryStateFileNames.Framebuffer, callback); } public void PutInputLog(Action callback) { - PutFileByName(BinaryStateFileNames.input, callback); + PutFileByName(BinaryStateFileNames.Input, callback); } - private bool isDisposed = false; + private bool isDisposed; public void Dispose() { Dispose(true); diff --git a/BizHawk.Client.Common/ControllerBinding.cs b/BizHawk.Client.Common/ControllerBinding.cs index 8d4b24d5f5..575bf67d71 100644 --- a/BizHawk.Client.Common/ControllerBinding.cs +++ b/BizHawk.Client.Common/ControllerBinding.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.Common private readonly Dictionary FloatRanges = new WorkingDictionary(); - private readonly Dictionary FloatBinds = new Dictionary(); + private readonly Dictionary FloatBinds = new Dictionary(); public Controller(ControllerDefinition definition) { @@ -43,32 +43,13 @@ namespace BizHawk.Client.Common //look for bindings which are activated by the supplied physical button. public List SearchBindings(string button) { - var ret = new List(); - foreach (var kvp in bindings) - { - foreach (var bound_button in kvp.Value) - { - if (bound_button == button) - ret.Add(kvp.Key); - } - } - return ret; + return (from kvp in bindings from bound_button in kvp.Value where bound_button == button select kvp.Key).ToList(); } //Searches bindings for the controller and returns true if this binding is mapped somewhere in this controller public bool HasBinding(string button) { - foreach (var kvp in bindings) - { - foreach (var bound_button in kvp.Value) - { - if (bound_button == button) - { - return true; - } - } - } - return false; + return bindings.SelectMany(kvp => kvp.Value).Any(bound_button => bound_button == button); } /// @@ -153,7 +134,7 @@ namespace BizHawk.Client.Common bindings[button].Add(control.Trim()); } - public void BindFloat(string button, BizHawk.Client.Common.Config.AnalogBind bind) + public void BindFloat(string button, Config.AnalogBind bind) { FloatBinds[button] = bind; } @@ -164,17 +145,7 @@ namespace BizHawk.Client.Common /// public List> MappingList() { - List> list = new List>(); - - foreach (KeyValuePair> key in bindings) - { - foreach (string binding in key.Value) - { - list.Add(new KeyValuePair(binding, key.Key)); - } - } - - return list; + return (from key in bindings from binding in key.Value select new KeyValuePair(binding, key.Key)).ToList(); } public List PressedButtons @@ -188,9 +159,9 @@ namespace BizHawk.Client.Common public class AutofireController : IController { - private ControllerDefinition type; - private WorkingDictionary> bindings = new WorkingDictionary>(); - private WorkingDictionary buttons = new WorkingDictionary(); + private readonly ControllerDefinition type; + private readonly WorkingDictionary> bindings = new WorkingDictionary>(); + private readonly WorkingDictionary buttons = new WorkingDictionary(); public WorkingDictionary buttonStarts = new WorkingDictionary(); private bool autofire = true; @@ -229,16 +200,7 @@ namespace BizHawk.Client.Common //look for bindings which are activated by the supplied physical button. public List SearchBindings(string button) { - var ret = new List(); - foreach (var kvp in bindings) - { - foreach (var bound_button in kvp.Value) - { - if (bound_button == button) - ret.Add(kvp.Key); - } - } - return ret; + return (from kvp in bindings from bound_button in kvp.Value where bound_button == button select kvp.Key).ToList(); } /// diff --git a/BizHawk.Client.Common/CoreFileProvider.cs b/BizHawk.Client.Common/CoreFileProvider.cs index 3ed88ca61f..411833a910 100644 --- a/BizHawk.Client.Common/CoreFileProvider.cs +++ b/BizHawk.Client.Common/CoreFileProvider.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Collections.Generic; namespace BizHawk.Client.Common { @@ -22,7 +21,7 @@ namespace BizHawk.Client.Common public string PathSubfile(string fname) { - return Path.Combine(Path.GetDirectoryName(SubfileDirectory), fname); + return Path.Combine(Path.GetDirectoryName(SubfileDirectory) ?? String.Empty, fname); } } } \ No newline at end of file diff --git a/BizHawk.Client.Common/FirmwareManager.cs b/BizHawk.Client.Common/FirmwareManager.cs index 4a25256ef1..fbdc27d7df 100644 --- a/BizHawk.Client.Common/FirmwareManager.cs +++ b/BizHawk.Client.Common/FirmwareManager.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using System.IO; using System.Collections.Generic; @@ -27,7 +26,7 @@ namespace BizHawk.Client.Common public string Hash; } - Dictionary ResolutionDictionary = new Dictionary(); + readonly Dictionary ResolutionDictionary = new Dictionary(); public ResolutionInfo Resolve(string sysId, string firmwareId) @@ -41,7 +40,7 @@ namespace BizHawk.Client.Common RETRY: - ResolutionInfo resolved = null; + ResolutionInfo resolved; ResolutionDictionary.TryGetValue(record, out resolved); //couldnt find it! do a scan and resolve to try harder @@ -68,8 +67,7 @@ namespace BizHawk.Client.Common byte[] buffer = new byte[0]; public RealFirmwareFile Read(FileInfo fi) { - RealFirmwareFile rff = new RealFirmwareFile(); - rff.fi = fi; + RealFirmwareFile rff = new RealFirmwareFile {fi = fi}; long len = fi.Length; if (len > buffer.Length) buffer = new byte[len]; using (var fs = fi.OpenRead()) fs.Read(buffer, 0, (int)len); @@ -78,8 +76,8 @@ namespace BizHawk.Client.Common files.Add(rff); return rff; } - public Dictionary dict = new Dictionary(); - public List files = new List(); + public readonly Dictionary dict = new Dictionary(); + private readonly List files = new List(); } public void DoScanAndResolve() @@ -109,9 +107,10 @@ namespace BizHawk.Client.Common ResolutionDictionary.Remove(fr); //get all options for this firmware (in order) + FirmwareDatabase.FirmwareRecord fr1 = fr; var options = from fo in FirmwareDatabase.FirmwareOptions - where fo.systemId == fr.systemId && fo.firmwareId == fr.firmwareId + where fo.systemId == fr1.systemId && fo.firmwareId == fr1.firmwareId select fo; //try each option @@ -122,10 +121,12 @@ namespace BizHawk.Client.Common if (reader.dict.ContainsKey(hash)) { //rad! then we can use it - var ri = new ResolutionInfo(); - ri.FilePath = reader.dict[hash].fi.FullName; - ri.KnownFirmwareFile = FirmwareDatabase.FirmwareFilesByHash[hash]; - ri.Hash = hash; + var ri = new ResolutionInfo + { + FilePath = reader.dict[hash].fi.FullName, + KnownFirmwareFile = FirmwareDatabase.FirmwareFilesByHash[hash], + Hash = hash + }; ResolutionDictionary[fr] = ri; goto DONE_FIRMWARE; } @@ -138,13 +139,13 @@ namespace BizHawk.Client.Common //apply user overrides foreach (var fr in FirmwareDatabase.FirmwareRecords) { - string userSpec = null; + string userSpec; //do we have a user specification for this firmware record? if (Global.Config.FirmwareUserSpecifications.TryGetValue(fr.ConfigKey, out userSpec)) { //flag it as user specified - ResolutionInfo ri = null; + ResolutionInfo ri; if (!ResolutionDictionary.TryGetValue(fr, out ri)) { ri = new ResolutionInfo(); @@ -168,7 +169,7 @@ namespace BizHawk.Client.Common ri.Hash = rff.hash; //check whether it was a known file anyway, and go ahead and bind to the known file, as a perk (the firmwares config doesnt really use this information right now) - FirmwareDatabase.FirmwareFile ff = null; + FirmwareDatabase.FirmwareFile ff; if(FirmwareDatabase.FirmwareFilesByHash.TryGetValue(rff.hash,out ff)) { ri.KnownFirmwareFile = ff; diff --git a/BizHawk.Client.Common/HawkFile.cs b/BizHawk.Client.Common/HawkFile.cs index d5bd1bd373..67b4473d0b 100644 --- a/BizHawk.Client.Common/HawkFile.cs +++ b/BizHawk.Client.Common/HawkFile.cs @@ -84,7 +84,7 @@ namespace BizHawk.Client.Common /// public bool IsArchive { get { return extractor != null; } } - int? BoundIndex = null; + int? BoundIndex; public int? GetBoundIndex() { diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs index c2e6bcaf5a..4146558608 100644 --- a/BizHawk.Client.Common/PathManager.cs +++ b/BizHawk.Client.Common/PathManager.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.IO; -using System.Reflection; namespace BizHawk.Client.Common { @@ -196,12 +195,7 @@ namespace BizHawk.Client.Common return Environment.SpecialFolder.Recent.ToString(); } - PathEntry path = Global.Config.PathEntries[sysID, "ROM"]; - - if (path == null) - { - path = Global.Config.PathEntries[sysID, "Base"]; - } + PathEntry path = Global.Config.PathEntries[sysID, "ROM"] ?? Global.Config.PathEntries[sysID, "Base"]; return MakeAbsolutePath(path.Path, sysID); } @@ -231,24 +225,16 @@ namespace BizHawk.Client.Common name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename); } - PathEntry pathEntry = Global.Config.PathEntries[game.System, "Save RAM"]; - - if (pathEntry == null) - { - pathEntry = Global.Config.PathEntries[game.System, "Base"]; - } + PathEntry pathEntry = Global.Config.PathEntries[game.System, "Save RAM"] ?? + Global.Config.PathEntries[game.System, "Base"]; return Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name) + ".SaveRAM"; } public static string GetSaveStatePath(GameInfo game) { - PathEntry pathEntry = Global.Config.PathEntries[game.System, "Savestates"]; - - if (pathEntry == null) - { - pathEntry = Global.Config.PathEntries[game.System, "Base"]; - } + PathEntry pathEntry = Global.Config.PathEntries[game.System, "Savestates"] ?? + Global.Config.PathEntries[game.System, "Base"]; return MakeAbsolutePath(pathEntry.Path, game.System); } @@ -262,24 +248,16 @@ namespace BizHawk.Client.Common name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename); } - PathEntry pathEntry = Global.Config.PathEntries[game.System, "Savestates"]; - - if (pathEntry == null) - { - pathEntry = Global.Config.PathEntries[game.System, "Base"]; - } + PathEntry pathEntry = Global.Config.PathEntries[game.System, "Savestates"] ?? + Global.Config.PathEntries[game.System, "Base"]; return Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name); } public static string GetCheatsPath(GameInfo game) { - PathEntry pathEntry = Global.Config.PathEntries[game.System, "Cheats"]; - - if (pathEntry == null) - { - pathEntry = Global.Config.PathEntries[game.System, "Base"]; - } + PathEntry pathEntry = Global.Config.PathEntries[game.System, "Cheats"] ?? + Global.Config.PathEntries[game.System, "Base"]; return MakeAbsolutePath(pathEntry.Path, game.System); } @@ -288,12 +266,8 @@ namespace BizHawk.Client.Common { string name = FilesystemSafeName(game); - PathEntry pathEntry = Global.Config.PathEntries[game.System, "Screenshots"]; - - if (pathEntry == null) - { - pathEntry = Global.Config.PathEntries[game.System, "Base"]; - } + PathEntry pathEntry = Global.Config.PathEntries[game.System, "Screenshots"] ?? + Global.Config.PathEntries[game.System, "Base"]; return Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name); } diff --git a/BizHawk.Client.Common/XmlGame.cs b/BizHawk.Client.Common/XmlGame.cs index 8740535395..707b1e3b4e 100644 --- a/BizHawk.Client.Common/XmlGame.cs +++ b/BizHawk.Client.Common/XmlGame.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; using System.Xml; @@ -23,11 +21,16 @@ namespace BizHawk.Client.Common if (y == null) return null; - var ret = new XmlGame(); - ret.GI.System = y.Attributes["System"].Value; - ret.GI.Name = y.Attributes["Name"].Value; - ret.GI.Status = RomStatus.Unknown; - ret.Xml = x; + var ret = new XmlGame + { + GI = + { + System = y.Attributes["System"].Value, + Name = y.Attributes["Name"].Value, + Status = RomStatus.Unknown + }, + Xml = x + }; var n = y.SelectSingleNode("./LoadAssets"); if (n != null) @@ -61,7 +64,7 @@ namespace BizHawk.Client.Common else { // relative path - string fullpath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|')[0]); + string fullpath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|')[0]) ?? String.Empty; fullpath = Path.Combine(fullpath, filename); try { diff --git a/BizHawk.Client.Common/config/ConfigService.cs b/BizHawk.Client.Common/config/ConfigService.cs index d661838e35..65b7f100ee 100644 --- a/BizHawk.Client.Common/config/ConfigService.cs +++ b/BizHawk.Client.Common/config/ConfigService.cs @@ -22,8 +22,12 @@ namespace BizHawk.Client.Common config = (T)s.Deserialize(r, typeof(T)); } } - catch (Exception e) { /*TODO MessageBox.Show(e.ToString(), "Config Error"); */ } - if (config == null) return new T(); + catch (Exception ex) + { + throw new InvalidOperationException("Config Error", ex); + } + + //if (config == null) return new T(); //patch up arrays in the config with the minimum number of things foreach(var fi in typeof(T).GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public)) diff --git a/BizHawk.Client.Common/movie/InputAdapters.cs b/BizHawk.Client.Common/movie/InputAdapters.cs index 86fd7bf1e5..e1022473ed 100644 --- a/BizHawk.Client.Common/movie/InputAdapters.cs +++ b/BizHawk.Client.Common/movie/InputAdapters.cs @@ -1,5 +1,4 @@ using System; -using System.Text; using System.Collections.Generic; namespace BizHawk.Client.Common @@ -109,7 +108,7 @@ namespace BizHawk.Client.Common public IEnumerable> BoolButtons() { - foreach (var kvp in Buttons) yield return kvp; + return Buttons; } public virtual void LatchFrom(IController source) @@ -200,7 +199,7 @@ namespace BizHawk.Client.Common // if SetFloat() is called (typically virtual pads), then that float will entirely override the Source input // otherwise, the source is passed thru. - WorkingDictionary FloatSet = new WorkingDictionary(); + readonly WorkingDictionary FloatSet = new WorkingDictionary(); public void SetFloat(string name, float? value) { if (value.HasValue) diff --git a/BizHawk.Client.Common/movie/Movie.cs b/BizHawk.Client.Common/movie/Movie.cs index f8f42f01df..50d4ed63a8 100644 --- a/BizHawk.Client.Common/movie/Movie.cs +++ b/BizHawk.Client.Common/movie/Movie.cs @@ -370,7 +370,7 @@ namespace BizHawk.Client.Common string BackupName = Filename; BackupName = BackupName.Insert(Filename.LastIndexOf("."), String.Format(".{0:yyyy-MM-dd HH.mm.ss}", DateTime.Now)); - BackupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(BackupName)); + BackupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(BackupName) ?? String.Empty); var directory_info = new FileInfo(BackupName).Directory; if (directory_info != null) Directory.CreateDirectory(directory_info.FullName); diff --git a/BizHawk.Client.Common/movie/MovieMnemonics.cs b/BizHawk.Client.Common/movie/MovieMnemonics.cs index f75b642920..97154fb45b 100644 --- a/BizHawk.Client.Common/movie/MovieMnemonics.cs +++ b/BizHawk.Client.Common/movie/MovieMnemonics.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace BizHawk.Client.Common @@ -108,16 +107,16 @@ namespace BizHawk.Client.Common } }, { - "Nintento 64 Controller", new Dictionary() - { + "Nintento 64 Controller", new Dictionary + { {"DPad U", "U"}, {"DPad D", "D"}, {"DPad L", "L"}, {"DPad R", "R"}, {"B", "B"}, {"A", "A"}, {"Z", "Z"}, {"Start", "S"}, {"L", "L"}, {"R", "R"}, {"C Up", "u"}, {"C Down", "d"}, {"C Left", "l"}, {"C Right", "r"} } }, { - "Saturn Controller", new Dictionary() - { + "Saturn Controller", new Dictionary + { {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Start", "S"}, {"X", "X"}, {"Y", "Y"}, {"Z", "Z"}, {"A", "A"}, {"B", "B"}, {"C", "C"}, {"L", "l"}, {"R", "r"}, @@ -139,9 +138,9 @@ namespace BizHawk.Client.Common {"Genesis 3-Button Controller", new Dictionary {{"Reset", "r"}}}, {"NES Controller", new Dictionary {{"Reset", "r"}, {"Power", "P"}, {"FDS Eject", "E"}, {"FDS Insert 0", "0"}, {"FDS Insert 1", "1"}, {"VS Coin 1", "c"}, {"VS Coin 2", "C"}}}, {"SNES Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, - {"PC Engine Controller", new Dictionary {}}, + {"PC Engine Controller", new Dictionary()}, {"SMS Controller", new Dictionary {{"Pause", "p"}, {"Reset", "r"}}}, - {"TI83 Controller", new Dictionary {}}, + {"TI83 Controller", new Dictionary()}, {"Nintento 64 Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, {"Saturn Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, }; @@ -155,7 +154,7 @@ namespace BizHawk.Client.Common // just experimenting with different possibly more painful ways to handle mnemonics // |P|UDLRsSBA| - public static Tuple[] DGBMnemonic = new Tuple[] + public static Tuple[] DGBMnemonic = new[] { new Tuple(null, '|'), new Tuple("P1 Power", 'P'), @@ -406,7 +405,7 @@ namespace BizHawk.Client.Common { foreach (string name in MnemonicConstants.ANALOGS[ControlType].Keys) { - int val = 0; + int val; //Nasty hackery if (name == "Y Axis") diff --git a/BizHawk.Client.Common/movie/SubtitleList.cs b/BizHawk.Client.Common/movie/SubtitleList.cs index 0ed4061707..b83be5db0a 100644 --- a/BizHawk.Client.Common/movie/SubtitleList.cs +++ b/BizHawk.Client.Common/movie/SubtitleList.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Text; using System.Drawing; using System.IO; @@ -15,7 +14,7 @@ namespace BizHawk.Client.Common public SubtitleList() { } - public SubtitleList(SubtitleList subtitles) + public SubtitleList(IEnumerable subtitles) { foreach (var subtitle in subtitles) { diff --git a/BizHawk.Client.Common/tools/RamSearchEngine.cs b/BizHawk.Client.Common/tools/RamSearchEngine.cs index 3e92b5711b..9902eecd76 100644 --- a/BizHawk.Client.Common/tools/RamSearchEngine.cs +++ b/BizHawk.Client.Common/tools/RamSearchEngine.cs @@ -1,11 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; - using BizHawk.Common; namespace BizHawk.Client.Common @@ -52,14 +47,14 @@ namespace BizHawk.Client.Common public enum ComparisonOperator { Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DifferentBy }; public enum Compare { Previous, SpecificValue, SpecificAddress, Changes, Difference } - private int? _differentBy = null; + private int? _differentBy; private Compare _compareTo = Compare.Previous; - private long? _compareValue = null; + private long? _compareValue; private ComparisonOperator _operator = ComparisonOperator.Equal; private List _watchList = new List(); - private Settings _settings = new Settings(); - private UndoHistory _history = new UndoHistory(true); + private readonly Settings _settings = new Settings(); + private readonly UndoHistory _history = new UndoHistory(true); private bool _keepHistory = true; public RamSearchEngine(Settings settings) @@ -189,19 +184,19 @@ namespace BizHawk.Client.Common switch (_compareTo) { default: - case RamSearchEngine.Compare.Previous: + case Compare.Previous: _watchList = ComparePrevious(_watchList).ToList(); break; - case RamSearchEngine.Compare.SpecificValue: + case Compare.SpecificValue: _watchList = CompareSpecificValue(_watchList).ToList(); break; - case RamSearchEngine.Compare.SpecificAddress: + case Compare.SpecificAddress: _watchList = CompareSpecificAddress(_watchList).ToList(); break; - case RamSearchEngine.Compare.Changes: + case Compare.Changes: _watchList = CompareChanges(_watchList).ToList(); break; - case RamSearchEngine.Compare.Difference: + case Compare.Difference: _watchList = CompareDifference(_watchList).ToList(); break; } @@ -229,16 +224,16 @@ namespace BizHawk.Client.Common switch (_compareTo) { default: - case RamSearchEngine.Compare.Previous: - return ComparePrevious(listOfOne).Count() == 0; - case RamSearchEngine.Compare.SpecificValue: - return CompareSpecificValue(listOfOne).Count() == 0; - case RamSearchEngine.Compare.SpecificAddress: - return CompareSpecificAddress(listOfOne).Count() == 0; - case RamSearchEngine.Compare.Changes: - return CompareChanges(listOfOne).Count() == 0; - case RamSearchEngine.Compare.Difference: - return CompareDifference(listOfOne).Count() == 0; + case Compare.Previous: + return !ComparePrevious(listOfOne).Any(); + case Compare.SpecificValue: + return !CompareSpecificValue(listOfOne).Any(); + case Compare.SpecificAddress: + return !CompareSpecificAddress(listOfOne).Any(); + case Compare.Changes: + return !CompareChanges(listOfOne).Any(); + case Compare.Difference: + return !CompareDifference(listOfOne).Any(); } } @@ -745,7 +740,7 @@ namespace BizHawk.Client.Common } else { - return (uint)theDWord; + return theDWord; } } } @@ -758,7 +753,7 @@ namespace BizHawk.Client.Common case Settings.SearchMode.Detailed: return true; case Settings.SearchMode.Fast: - return !(compareType == Compare.Changes); + return compareType != Compare.Changes; } } @@ -851,7 +846,7 @@ namespace BizHawk.Client.Common { public int Address { get; private set; } private byte _previous; - int _changecount = 0; + int _changecount; public MiniByteWatchDetailed(MemoryDomain domain, int addr) { @@ -903,7 +898,7 @@ namespace BizHawk.Client.Common { public int Address { get; private set; } private ushort _previous; - int _changecount = 0; + int _changecount; public MiniWordWatchDetailed(MemoryDomain domain, int addr, bool bigEndian) { @@ -954,7 +949,7 @@ namespace BizHawk.Client.Common { public int Address { get; private set; } private uint _previous; - int _changecount = 0; + int _changecount; public MiniDWordWatchDetailed(MemoryDomain domain, int addr, bool bigEndian) {