cleanups in Client.Common, mostly removing redundant parenthesis
This commit is contained in:
parent
2a77ad14f3
commit
db21af9e59
|
@ -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;
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <savestate_offset -
|
||||
length_of_extra_rom_info_in_bytes>.
|
||||
*/
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue