Move `&&`/`||` to start of next line in main solution

This commit is contained in:
James Groom 2024-03-27 16:35:31 +00:00 committed by GitHub
parent b0ba7a1246
commit 8967f58df8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 41 additions and 65 deletions

View File

@ -279,10 +279,9 @@ namespace BizHawk.BizInvoke
private static void VerifyParameter(Type type) private static void VerifyParameter(Type type)
{ {
if (type == typeof(float) || type == typeof(double) || if (type.IsPrimitive || type.IsEnum || type.IsPointer || type.IsByRef || type.IsClass
type == typeof(void) || type.IsPrimitive || type.IsEnum || || type == typeof(float) || type == typeof(double) || type == typeof(void) //TODO aren't these covered by IsPrimitive? --yoshi
type.IsPointer || typeof(Delegate).IsAssignableFrom(type) || || typeof(Delegate).IsAssignableFrom(type))
type.IsByRef || type.IsClass)
{ {
return; return;
} }

View File

@ -88,8 +88,7 @@ namespace BizHawk.Bizware.Audio
try try
{ {
var status = (BufferStatus)_deviceBuffer.Status; var status = (BufferStatus)_deviceBuffer.Status;
return (status & BufferStatus.BufferLost) == 0 && return (status & (BufferStatus.BufferLost | BufferStatus.Playing)) is BufferStatus.Playing;
(status & BufferStatus.Playing) == BufferStatus.Playing;
} }
catch (SharpDXException) catch (SharpDXException)
{ {
@ -290,8 +289,7 @@ namespace BizHawk.Bizware.Audio
} }
var status = (BufferStatus)_wavDeviceBuffer.Status; var status = (BufferStatus)_wavDeviceBuffer.Status;
return (status & BufferStatus.BufferLost) == 0 && return (status & (BufferStatus.BufferLost | BufferStatus.Playing)) is BufferStatus.Playing;
(status & BufferStatus.Playing) == BufferStatus.Playing;
} }
} }

View File

@ -32,11 +32,11 @@ namespace BizHawk.Bizware.Graphics
// set some sensible defaults // set some sensible defaults
SDL_GL_ResetAttributes(); SDL_GL_ResetAttributes();
if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8) != 0 || if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8) is not 0
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8) != 0 || || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8) is not 0
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8) != 0 || || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8) is not 0
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 0) != 0 || || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 0) is not 0
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1) != 0) || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1) is not 0)
{ {
throw new($"Could not set GL attributes! SDL Error: {SDL_GetError()}"); throw new($"Could not set GL attributes! SDL Error: {SDL_GetError()}");
} }

View File

@ -56,9 +56,7 @@ namespace BizHawk.Bizware.Input
lock (_lockObj) lock (_lockObj)
{ {
if (_keyboard == null || if (_keyboard is null || _keyboard.Acquire().Failure || _keyboard.Poll().Failure)
_keyboard.Acquire().Failure ||
_keyboard.Poll().Failure)
{ {
return Enumerable.Empty<KeyEvent>(); return Enumerable.Empty<KeyEvent>();
} }

View File

@ -85,8 +85,8 @@ namespace BizHawk.Bizware.Input
return DefWindowProcW(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
} }
if (input->header.dwType == RAWINPUTHEADER.RIM_TYPE.KEYBOARD && if (input->header.dwType is RAWINPUTHEADER.RIM_TYPE.KEYBOARD
(input->data.keyboard.Flags & ~(RAWKEYBOARD.RI_KEY.E0 | RAWKEYBOARD.RI_KEY.BREAK)) == 0) && (input->data.keyboard.Flags & ~(RAWKEYBOARD.RI_KEY.E0 | RAWKEYBOARD.RI_KEY.BREAK)) is 0)
{ {
var handle = GCHandle.FromIntPtr(ud); var handle = GCHandle.FromIntPtr(ud);
var rawKeyInput = (RawKeyInput)handle.Target; var rawKeyInput = (RawKeyInput)handle.Target;

View File

@ -238,8 +238,8 @@ namespace BizHawk.Client.Common.FilterManager
{ {
newTarget = true; newTarget = true;
} }
else if (currState.SurfaceDisposition == SurfaceDisposition.Texture && else if (currState.SurfaceDisposition is SurfaceDisposition.Texture
iosi.SurfaceDisposition == SurfaceDisposition.RenderTarget) && iosi.SurfaceDisposition is SurfaceDisposition.RenderTarget)
{ {
newTarget = true; newTarget = true;
} }

View File

@ -105,8 +105,7 @@ namespace BizHawk.Client.Common
{ {
RomData = FileData; RomData = FileData;
} }
else if (file.Extension == ".dsk" || file.Extension == ".tap" || file.Extension == ".tzx" || else if (file.Extension is ".cdt" or ".csw" or ".dsk" or ".pzx" or ".tap" or ".tzx" or ".wav")
file.Extension == ".pzx" || file.Extension == ".csw" || file.Extension == ".wav" || file.Extension == ".cdt")
{ {
// these are not roms. unfortunately if treated as such there are certain edge-cases // these are not roms. unfortunately if treated as such there are certain edge-cases
// where a header offset is detected. This should mitigate this issue until a cleaner solution is found // where a header offset is detected. This should mitigate this issue until a cleaner solution is found

View File

@ -239,8 +239,8 @@ namespace BizHawk.Client.Common
UpdateHistory(_baseSamplesPerFrame, count, BaseSampleRateMaxHistoryLength); UpdateHistory(_baseSamplesPerFrame, count, BaseSampleRateMaxHistoryLength);
if (_baseSamplesPerFrame.Count >= BaseSampleRateUsableHistoryLength && if (_baseSamplesPerFrame.Count >= BaseSampleRateUsableHistoryLength
!_baseEmptyFrameCorrectionHistory.Any(n => n)) && !_baseEmptyFrameCorrectionHistory.Contains(true))
{ {
double baseAverageSamplesPerFrame = _baseSamplesPerFrame.Average(); double baseAverageSamplesPerFrame = _baseSamplesPerFrame.Average();
if (baseAverageSamplesPerFrame != 0.0) if (baseAverageSamplesPerFrame != 0.0)

View File

@ -115,8 +115,9 @@ namespace BizHawk.Client.Common
{ {
try try
{ {
if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable() && if (DebuggableCore is not null
DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable) && DebuggableCore.MemoryCallbacksAvailable()
&& DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable)
{ {
if (!HasScope(scope)) if (!HasScope(scope))
{ {

View File

@ -160,12 +160,14 @@ namespace BizHawk.Client.Common
{ {
long targetSize = settings.BufferSize * 1024 * 1024; long targetSize = settings.BufferSize * 1024 * 1024;
long size = 1L << (int)Math.Floor(Math.Log(targetSize, 2)); long size = 1L << (int)Math.Floor(Math.Log(targetSize, 2));
return Size == size && return Size == size
_useCompression == settings.UseCompression && && _useCompression == settings.UseCompression
_fixedRewindInterval == settings.UseFixedRewindInterval && && _fixedRewindInterval == settings.UseFixedRewindInterval
(_fixedRewindInterval ? _targetRewindInterval == settings.TargetRewindInterval : _targetFrameLength == settings.TargetFrameLength) && && (_fixedRewindInterval
_allowOutOfOrderStates == settings.AllowOutOfOrderStates && ? _targetRewindInterval == settings.TargetRewindInterval
_backingStoreType == settings.BackingStore; : _targetFrameLength == settings.TargetFrameLength)
&& _allowOutOfOrderStates == settings.AllowOutOfOrderStates
&& _backingStoreType == settings.BackingStore;
} }
private bool ShouldCaptureForFrameDiff(int frameDiff) private bool ShouldCaptureForFrameDiff(int frameDiff)

View File

@ -224,8 +224,7 @@ namespace BizHawk.Client.Common
case WatchSize.Word: case WatchSize.Word:
return addr == _watch.Address || addr == _watch.Address + 1; return addr == _watch.Address || addr == _watch.Address + 1;
case WatchSize.DWord: case WatchSize.DWord:
return addr == _watch.Address || addr == _watch.Address + 1 || return addr >= _watch.Address && addr <= _watch.Address + 3;
addr == _watch.Address + 2 || addr == _watch.Address + 3;
} }
} }

View File

@ -324,16 +324,8 @@ namespace BizHawk.Client.Common
/// <param name="other">The <see cref="Watch"/> to compare</param> /// <param name="other">The <see cref="Watch"/> to compare</param>
/// <returns>True if both object are equals; otherwise, false</returns> /// <returns>True if both object are equals; otherwise, false</returns>
public bool Equals(Watch other) public bool Equals(Watch other)
{ => other is not null
if (other is null) && _domain == other._domain && Address == other.Address && Size == other.Size;
{
return false;
}
return _domain == other._domain &&
Address == other.Address &&
Size == other.Size;
}
/// <summary> /// <summary>
/// Determines if this <see cref="Watch"/> is equals to an instance of <see cref="Cheat"/> /// Determines if this <see cref="Watch"/> is equals to an instance of <see cref="Cheat"/>

View File

@ -89,13 +89,7 @@ namespace BizHawk.Common.CollectionExtensions
return midItem; return midItem;
} }
} }
if (min == max && keySelector(list[min]).CompareTo(key) is 0) return list[min];
if (min == max &&
keySelector(list[min]).CompareTo(key) == 0)
{
return list[min];
}
throw new InvalidOperationException("Item not found"); throw new InvalidOperationException("Item not found");
} }

View File

@ -207,9 +207,9 @@ namespace BizHawk.Emulation.Common
} }
} }
if (trk.Sectors[0].SectorData[7] == 3 && if (trk.Sectors[0].SectorData[7] is 3
trk.Sectors[0].SectorData[9] == 23 && && trk.Sectors[0].SectorData[9] is 23
trk.Sectors[0].SectorData[2] == 40) && trk.Sectors[0].SectorData[2] is 40)
{ {
IdentifiedSystem = VSystemID.Raw.ZXSpectrum; IdentifiedSystem = VSystemID.Raw.ZXSpectrum;
return; return;

View File

@ -481,8 +481,8 @@ namespace BizHawk.Emulation.DiscSystem
var (dir, fileNoExt, _) = aFile.MDSPath.SplitPathToDirFileAndExt(); var (dir, fileNoExt, _) = aFile.MDSPath.SplitPathToDirFileAndExt();
if (f.FilenameOffset == 0 || if (f.FilenameOffset is 0
string.Equals(fileName, "*.mdf", StringComparison.OrdinalIgnoreCase)) || string.Equals(fileName, "*.mdf", StringComparison.OrdinalIgnoreCase))
{ {
fileName = $@"{dir}\{fileNoExt}.mdf"; fileName = $@"{dir}\{fileNoExt}.mdf";
} }

View File

@ -415,9 +415,7 @@ namespace BizHawk.Emulation.DiscSystem
var v2 = chunkID == "DAOX"; var v2 = chunkID == "DAOX";
var ntracks = ret.LastTrack - ret.FirstTrack + 1; var ntracks = ret.LastTrack - ret.FirstTrack + 1;
if (ntracks <= 0 || if (ntracks <= 0 || ret.FirstTrack is < 0 or > 99 || ret.LastTrack is < 0 or > 99)
ret.FirstTrack is < 0 or > 99 ||
ret.LastTrack is < 0 or > 99)
{ {
throw new NRGParseException("Malformed NRG format: Corrupt track numbers in DAO chunk!"); throw new NRGParseException("Malformed NRG format: Corrupt track numbers in DAO chunk!");
} }
@ -443,9 +441,7 @@ namespace BizHawk.Emulation.DiscSystem
track.TrackStartFileOffset = BinaryPrimitives.ReadInt64BigEndian(chunkData.Slice(i + 26, sizeof(long))); track.TrackStartFileOffset = BinaryPrimitives.ReadInt64BigEndian(chunkData.Slice(i + 26, sizeof(long)));
track.TrackEndFileOffset = BinaryPrimitives.ReadInt64BigEndian(chunkData.Slice(i + 34, sizeof(long))); track.TrackEndFileOffset = BinaryPrimitives.ReadInt64BigEndian(chunkData.Slice(i + 34, sizeof(long)));
if (track.PregapFileOffset < 0 || if (track.PregapFileOffset < 0 || track.TrackStartFileOffset < 0 || track.TrackEndFileOffset < 0)
track.TrackStartFileOffset < 0 ||
track.TrackEndFileOffset < 0)
{ {
throw new NRGParseException("Malformed NRG format: Negative file offsets in DAOX chunk!"); throw new NRGParseException("Malformed NRG format: Negative file offsets in DAOX chunk!");
} }
@ -849,9 +845,7 @@ namespace BizHawk.Emulation.DiscSystem
if (nrgf.DAOTrackInfos.Count > 0) if (nrgf.DAOTrackInfos.Count > 0)
{ {
if (nrgf.TAOTrackInfos.Count > 0 || if (nrgf.TAOTrackInfos.Count is not 0 || nrgf.RELOs.Count is not 0 || nrgf.TOCTs.Count is not 0)
nrgf.RELOs.Count > 0 ||
nrgf.TOCTs.Count > 0)
{ {
throw new NRGParseException("Malformed NRG format: DAO and TAO chunks both present on file!"); throw new NRGParseException("Malformed NRG format: DAO and TAO chunks both present on file!");
} }