From db21af9e5934b617dababeb02bdddb5e8da08b0c Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 1 Mar 2020 14:52:16 -0600 Subject: [PATCH] cleanups in Client.Common, mostly removing redundant parenthesis --- BizHawk.Client.Common/FrameworkFastZipWriter.cs | 12 ++++++------ .../movie/conversions/MovieConversionExtensions.cs | 2 +- BizHawk.Client.Common/movie/import/MmvImport.cs | 2 +- BizHawk.Client.Common/movie/import/SmvImport.cs | 4 ++-- .../movie/import/bkm/BkmControllerAdapter.cs | 8 ++++---- .../movie/tasproj/StateManagerDecay.cs | 4 ++-- .../movie/tasproj/TasMovie.Editing.cs | 4 ++-- BizHawk.Client.Common/tools/Cheat.cs | 10 +++++----- BizHawk.Client.Common/tools/CheatList.cs | 4 ++-- BizHawk.Client.Common/tools/RamSearchEngine.cs | 8 ++++---- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/BizHawk.Client.Common/FrameworkFastZipWriter.cs b/BizHawk.Client.Common/FrameworkFastZipWriter.cs index 878c2a0da2..316fcceff3 100644 --- a/BizHawk.Client.Common/FrameworkFastZipWriter.cs +++ b/BizHawk.Client.Common/FrameworkFastZipWriter.cs @@ -197,24 +197,24 @@ namespace BizHawk.Client.Common _localHeader[26] = (byte)nameb.Length; _localHeader[27] = (byte)(nameb.Length >> 8); - var localHeaderOffset = (int)(_output.Position); + var localHeaderOffset = (int)_output.Position; _output.Write(_localHeader, 0, _localHeader.Length); _output.Write(nameb, 0, nameb.Length); - var fileStart = (int)(_output.Position); + var fileStart = (int)_output.Position; var s2 = new DeflateStream(_output, _level, true); var s3 = new CRC32Stream(s2); callback(s3); s2.Flush(); - var fileEnd = (int)(_output.Position); + var fileEnd = (int)_output.Position; var crc = s3.Crc; var compressedSize = fileEnd - fileStart; var uncompressedSize = s3.Size; - var descriptor = new byte[] + var descriptor = new[] { (byte)crc, (byte)(crc >> 8), @@ -248,12 +248,12 @@ namespace BizHawk.Client.Common private void WriteFooter() { - var centralHeaderOffset = (int)(_output.Position); + var centralHeaderOffset = (int)_output.Position; foreach (var blob in _endBlobs) _output.Write(blob, 0, blob.Length); - var centralHeaderEnd = (int)(_output.Position); + var centralHeaderEnd = (int)_output.Position; var centralHeaderSize = centralHeaderEnd - centralHeaderOffset; diff --git a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs index 1454004384..068b86adcf 100644 --- a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs +++ b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs @@ -366,7 +366,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions movie.HeaderEntries.Add("Is32X", "1"); } - if ((Global.Emulator is SubNESHawk) || (Global.Emulator is SubGBHawk)) + if (Global.Emulator is SubNESHawk || Global.Emulator is SubGBHawk) { movie.HeaderEntries.Add(HeaderKeys.VBLANKCOUNT, "0"); } diff --git a/BizHawk.Client.Common/movie/import/MmvImport.cs b/BizHawk.Client.Common/movie/import/MmvImport.cs index f90cd41135..3becbc503c 100644 --- a/BizHawk.Client.Common/movie/import/MmvImport.cs +++ b/BizHawk.Client.Common/movie/import/MmvImport.cs @@ -135,7 +135,7 @@ namespace BizHawk.Client.Common.movie.import if (player == 1) { controllers["Pause"] = - (((controllerState >> 6) & 0x1) != 0 && (!isGameGear)) + (((controllerState >> 6) & 0x1) != 0 && !isGameGear) || (((controllerState >> 7) & 0x1) != 0 && isGameGear); } } diff --git a/BizHawk.Client.Common/movie/import/SmvImport.cs b/BizHawk.Client.Common/movie/import/SmvImport.cs index 3a41dd1313..bf2eb1de48 100644 --- a/BizHawk.Client.Common/movie/import/SmvImport.cs +++ b/BizHawk.Client.Common/movie/import/SmvImport.cs @@ -154,7 +154,7 @@ namespace BizHawk.Client.Common.movie.import Extra ROM info is always positioned right before the savestate. Its size is 30 bytes if MOVIE_SYNC_HASROMINFO is used (and MOVIE_SYNC_DATA_EXISTS is set), 0 bytes otherwise. */ - int extraRomInfo = (((syncFlags >> 6) & 0x1) != 0 && (syncFlags & 0x1) != 0) ? 30 : 0; + int extraRomInfo = ((syncFlags >> 6) & 0x1) != 0 && (syncFlags & 0x1) != 0 ? 30 : 0; // 018 4-byte little-endian unsigned int: offset to the savestate inside file uint savestateOffset = r.ReadUInt32(); @@ -190,7 +190,7 @@ namespace BizHawk.Client.Common.movie.import from position 32 (0x20 (0x40 for 1.51 and up)) and ends at . */ - byte[] metadata = r.ReadBytes((int)(savestateOffset - extraRomInfo - ((version != "1.43") ? 0x40 : 0x20))); + byte[] metadata = r.ReadBytes((int)(savestateOffset - extraRomInfo - (version != "1.43" ? 0x40 : 0x20))); string author = NullTerminated(Encoding.Unicode.GetString(metadata).Trim()); if (!string.IsNullOrWhiteSpace(author)) { diff --git a/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs b/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs index c729276ca5..ee9050aa9f 100644 --- a/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs +++ b/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs @@ -437,9 +437,9 @@ namespace BizHawk.Client.Common for (int player = 1; player <= BkmMnemonicConstants.Players[ControlType]; player++) { - int srcindex = (player - 1) * (BkmMnemonicConstants.Buttons[ControlType].Count + (BkmMnemonicConstants.Analogs[ControlType].Count * 4) + 1 + 1); + int srcIndex = (player - 1) * (BkmMnemonicConstants.Buttons[ControlType].Count + (BkmMnemonicConstants.Analogs[ControlType].Count * 4) + 1 + 1); - if (mnemonic.Length < srcindex + 3 + BkmMnemonicConstants.Buttons[ControlType].Count - 1) + if (mnemonic.Length < srcIndex + 3 + BkmMnemonicConstants.Buttons[ControlType].Count - 1) { return; } @@ -447,12 +447,12 @@ namespace BizHawk.Client.Common int start = 3; foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) { - Force($"P{player} {button}", c[srcindex + start++]); + Force($"P{player} {button}", c[srcIndex + start++]); } foreach (string name in BkmMnemonicConstants.Analogs[ControlType].Keys) { - Force($"P{player} {name}", int.Parse(mnemonic.Substring(srcindex + start, 4))); + Force($"P{player} {name}", int.Parse(mnemonic.Substring(srcIndex + start, 4))); start += 5; } } diff --git a/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs b/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs index 28fa07e735..48a3ad6077 100644 --- a/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs +++ b/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs @@ -131,7 +131,7 @@ namespace BizHawk.Client.Common continue; } - if ((currentFrame % _step > 0) && (currentFrame + 1 != _movie.LastEditedFrame)) + if (currentFrame % _step > 0 && currentFrame + 1 != _movie.LastEditedFrame) { // ignore the pattern if the state doesn't belong already, drop it blindly and skip everything if (_tsm.Remove(currentFrame)) @@ -154,7 +154,7 @@ namespace BizHawk.Client.Common if (_align) { - priority -= ((_base * ((1 << zeroCount) * 2 - 1)) >> zeroCount); + priority -= (_base * ((1 << zeroCount) * 2 - 1)) >> zeroCount; } if (priority > backwardPriority) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs index f16fa296cd..ccf640deb4 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs @@ -461,7 +461,7 @@ namespace BizHawk.Client.Common ExtendMovieForEdit(frame + count - Log.Count); } - ChangeLog.AddGeneralUndo(frame, frame + count - 1, $"Set {buttonName}({(val ? "On" : "Off")}): {frame}-{(frame + count - 1)}"); + ChangeLog.AddGeneralUndo(frame, frame + count - 1, $"Set {buttonName}({(val ? "On" : "Off")}): {frame}-{frame + count - 1}"); int changed = -1; for (int i = 0; i < count; i++) @@ -519,7 +519,7 @@ namespace BizHawk.Client.Common ExtendMovieForEdit(frame - Log.Count + 1); } - ChangeLog.AddGeneralUndo(frame, frame + count - 1, $"Set {buttonName}({val}): {frame}-{(frame + count - 1)}"); + ChangeLog.AddGeneralUndo(frame, frame + count - 1, $"Set {buttonName}({val}): {frame}-{frame + count - 1}"); int changed = -1; for (int i = 0; i < count; i++) diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs index 7bd9c2117b..9eec69594a 100644 --- a/BizHawk.Client.Common/tools/Cheat.cs +++ b/BizHawk.Client.Common/tools/Cheat.cs @@ -262,10 +262,10 @@ namespace BizHawk.Client.Common case WatchSize.Byte: return _watch.Address == addr; case WatchSize.Word: - return (addr == _watch.Address) || (addr == _watch.Address + 1); + return addr == _watch.Address || addr == _watch.Address + 1; case WatchSize.DWord: - return (addr == _watch.Address) || (addr == _watch.Address + 1) || - (addr == _watch.Address + 2) || (addr == _watch.Address + 3); + return addr == _watch.Address || addr == _watch.Address + 1 || + addr == _watch.Address + 2 || addr == _watch.Address + 3; } } @@ -416,7 +416,7 @@ namespace BizHawk.Client.Common public static bool operator ==(Cheat a, Cheat b) { // If one is null, but not both, return false. - if (((object)a == null) || ((object)b == null)) + if ((object)a == null || (object)b == null) { return false; } @@ -432,7 +432,7 @@ namespace BizHawk.Client.Common public static bool operator ==(Cheat a, Watch b) { // If one is null, but not both, return false. - if (((object)a == null) || ((object)b == null)) + if ((object)a == null || (object)b == null) { return false; } diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index bdfced2a42..8700accafd 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -627,7 +627,7 @@ namespace BizHawk.Client.Common if (reverse) { _cheatList = _cheatList - .OrderByDescending(c => ((int)c.Size)) + .OrderByDescending(c => (int)c.Size) .ThenBy(c => c.Name) .ThenBy(c => c.Address ?? 0) .ToList(); @@ -635,7 +635,7 @@ namespace BizHawk.Client.Common else { _cheatList = _cheatList - .OrderBy(c => ((int)c.Size)) + .OrderBy(c => (int)c.Size) .ThenBy(c => c.Name) .ThenBy(c => c.Address ?? 0) .ToList(); diff --git a/BizHawk.Client.Common/tools/RamSearchEngine.cs b/BizHawk.Client.Common/tools/RamSearchEngine.cs index 742edf25ae..19e50c930e 100644 --- a/BizHawk.Client.Common/tools/RamSearchEngine.cs +++ b/BizHawk.Client.Common/tools/RamSearchEngine.cs @@ -440,7 +440,7 @@ namespace BizHawk.Client.Common break; case WatchList.DIFF: _watchList = reverse - ? _watchList.OrderByDescending(w => (GetValue(w.Address) - w.Previous)).ToList() + ? _watchList.OrderByDescending(w => GetValue(w.Address) - w.Previous).ToList() : _watchList.OrderBy(w => GetValue(w.Address) - w.Previous).ToList(); break; @@ -1111,9 +1111,9 @@ namespace BizHawk.Client.Common BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big; Size = (WatchSize)memoryDomains.MainMemory.WordSize; Type = DisplayType.Unsigned; - Mode = memoryDomains.MainMemory.Size > (1024 * 1024) ? - SearchMode.Fast : - SearchMode.Detailed; + Mode = memoryDomains.MainMemory.Size > 1024 * 1024 + ? SearchMode.Fast + : SearchMode.Detailed; Domain = memoryDomains.MainMemory; CheckMisAligned = false;