From 3e5dc2d729717c07c8a6e0622646a0a44be80dfa Mon Sep 17 00:00:00 2001 From: AdAstra-LD Date: Sat, 24 Apr 2021 17:05:35 +0200 Subject: [PATCH] Changed == null to "is null" --- DS_Map/DSUtils.cs | 4 ++-- DS_Map/HeaderSearch.cs | 2 +- DS_Map/LibNDSFormats/EndianBinaryReader.cs | 4 ++-- DS_Map/LibNDSFormats/NSBMD/NSBMDGlRenderer.cs | 16 ++++++++-------- DS_Map/LibNDSFormats/NSBTX/Rom.cs | 2 +- DS_Map/LibNDSFormats/NSBTX/directory.cs | 2 +- DS_Map/LibNDSFormats/NSBTX/filesystem2.cs | 2 +- DS_Map/LibNDSFormats/NSBTX/imageindexer.cs | 8 ++++---- DS_Map/LibNDSFormats/NSBTX/imagetiler.cs | 10 +++++----- DS_Map/LibNDSFormats/NSBTX/nsbmetileset.cs | 6 +++--- DS_Map/LibNDSFormats/NSBTX/nsbtx.cs | 2 +- DS_Map/Main Window.cs | 16 ++++++++-------- DS_Map/ROMFiles/RomFile.cs | 2 +- DS_Map/ROMFiles/ScriptCommand.cs | 2 +- DS_Map/ROMFiles/ScriptFile.cs | 14 +++++++------- DS_Map/ROMToolboxDialog.cs | 2 +- DS_Map/RomInfo.cs | 2 +- DS_Map/SpawnEditor.cs | 2 +- 18 files changed, 49 insertions(+), 49 deletions(-) diff --git a/DS_Map/DSUtils.cs b/DS_Map/DSUtils.cs index 8355aa1..83c0e56 100644 --- a/DS_Map/DSUtils.cs +++ b/DS_Map/DSUtils.cs @@ -244,7 +244,7 @@ namespace DSPRE { if (!di.Exists || di.GetFiles().Length == 0) { Narc opened = Narc.Open(paths.packedPath); - if (opened == null) + if (opened is null) throw new NullReferenceException(); opened.ExtractToFolder(paths.unpackedPath); @@ -264,7 +264,7 @@ namespace DSPRE { if (gameDirs.TryGetValue(id, out (string packedPath, string unpackedPath) paths)) { Narc opened = Narc.Open(paths.packedPath); - if (opened == null) + if (opened is null) throw new NullReferenceException(); opened.ExtractToFolder(paths.unpackedPath); diff --git a/DS_Map/HeaderSearch.cs b/DS_Map/HeaderSearch.cs index 4acd7d6..fdba27f 100644 --- a/DS_Map/HeaderSearch.cs +++ b/DS_Map/HeaderSearch.cs @@ -186,7 +186,7 @@ namespace DSPRE { } string searchConfiguration = fieldToSearch1ComboBox.Text + " " + operator1ComboBox.Text.ToLower() + " " + '"' + valueTextBox.Text + '"'; - if (result == null || result.Count <= 0) { + if (result is null || result.Count <= 0) { string res = "No header suits the search criteria."; headerListBox.Items.Add(res); headerListBox.Enabled = false; diff --git a/DS_Map/LibNDSFormats/EndianBinaryReader.cs b/DS_Map/LibNDSFormats/EndianBinaryReader.cs index 703b9e5..2bb6f1d 100644 --- a/DS_Map/LibNDSFormats/EndianBinaryReader.cs +++ b/DS_Map/LibNDSFormats/EndianBinaryReader.cs @@ -32,7 +32,7 @@ namespace System.IO { : this(baseStream, Endianness.BigEndian) { } public EndianBinaryReader(Stream baseStream, Endianness endianness) { - if (baseStream == null) throw new ArgumentNullException("baseStream"); + if (baseStream is null) throw new ArgumentNullException("baseStream"); if (!baseStream.CanRead) throw new ArgumentException("baseStream"); BaseStream = baseStream; @@ -44,7 +44,7 @@ namespace System.IO { } private void FillBuffer(int bytes, int stride) { - if (buffer == null || buffer.Length < bytes) + if (buffer is null || buffer.Length < bytes) buffer = new byte[bytes]; BaseStream.Read(buffer, 0, bytes); diff --git a/DS_Map/LibNDSFormats/NSBMD/NSBMDGlRenderer.cs b/DS_Map/LibNDSFormats/NSBMD/NSBMDGlRenderer.cs index 39a38a7..9d8f1b0 100644 --- a/DS_Map/LibNDSFormats/NSBMD/NSBMDGlRenderer.cs +++ b/DS_Map/LibNDSFormats/NSBMD/NSBMDGlRenderer.cs @@ -148,7 +148,7 @@ namespace LibNDSFormats.NSBMD { S2z = new int[ca.JAC[selectedani].ObjInfo.Length]; lastselectedanim = selectedani; } - if (frame == null && p.Header.file_size != 0) { + if (frame is null && p.Header.file_size != 0) { frame = new int[p.MPT.names.Length]; frame_ = new int[p.MPT.names.Length]; nr = new int[p.MPT.names.Length]; @@ -327,7 +327,7 @@ namespace LibNDSFormats.NSBMD { goto end; scale: if (!mat.isEnvironmentMap) { - if (mat.mtx == null) { + if (mat.mtx is null) { Gl.glScalef(mat.scaleS / mat.width, mat.scaleT / mat.height, 1.0f); Gl.glRotatef(mat.rot, 0, 1, 0); Gl.glTranslatef(mat.transS, mat.transT, 0); @@ -1148,7 +1148,7 @@ namespace LibNDSFormats.NSBMD { continue; } var mat = mod.Materials[i]; - if (mat == null || (mat.paldata == null && mat.format != 7)) { + if (mat is null || (mat.paldata is null && mat.format != 7)) { matt.Add(new ImageBrush()); continue; } @@ -1192,7 +1192,7 @@ namespace LibNDSFormats.NSBMD { continue; int index = mat.texdata[matindex]; index = (index >> ((j % 2) << 2)) & 0x0f; - if (mat.paldata == null) + if (mat.paldata is null) continue; if (index < 0 || index >= mat.paldata.Length) continue; @@ -1344,7 +1344,7 @@ namespace LibNDSFormats.NSBMD { return; } var mat = m; - if (mat == null || (mat.paldata == null && mat.format != 7)) { + if (mat is null || (mat.paldata is null && mat.format != 7)) { //matt.Add(new System.Windows.Media.ImageBrush()); return; } @@ -1388,7 +1388,7 @@ namespace LibNDSFormats.NSBMD { continue; int index = mat.texdata[matindex]; index = (index >> ((j % 2) << 2)) & 0x0f; - if (mat.paldata == null) + if (mat.paldata is null) continue; if (index < 0 || index >= mat.paldata.Length) continue; @@ -1488,7 +1488,7 @@ namespace LibNDSFormats.NSBMD { private static extern bool DeleteObject(IntPtr hObject); public static System.Windows.Media.Imaging.BitmapSource CreateBitmapSourceFromBitmap(System.Drawing.Bitmap bitmap) { - if (bitmap == null) + if (bitmap is null) throw new ArgumentNullException("bitmap"); IntPtr hBitmap = bitmap.GetHbitmap(); @@ -1528,7 +1528,7 @@ namespace LibNDSFormats.NSBMD { IList nor = new List(); IList tex = new List(); int typ = -1; - if (polydata == null) + if (polydata is null) return; int commandptr = 0; int commandlimit = polydata.Length; diff --git a/DS_Map/LibNDSFormats/NSBTX/Rom.cs b/DS_Map/LibNDSFormats/NSBTX/Rom.cs index c2286b4..e9de8e1 100644 --- a/DS_Map/LibNDSFormats/NSBTX/Rom.cs +++ b/DS_Map/LibNDSFormats/NSBTX/Rom.cs @@ -95,7 +95,7 @@ namespace NSMBe4 //public static void close() //{ - // if (FS == null) return; + // if (FS is null) return; // FS.close(); //} diff --git a/DS_Map/LibNDSFormats/NSBTX/directory.cs b/DS_Map/LibNDSFormats/NSBTX/directory.cs index 9669ca2..51f9ee3 100644 --- a/DS_Map/LibNDSFormats/NSBTX/directory.cs +++ b/DS_Map/LibNDSFormats/NSBTX/directory.cs @@ -67,7 +67,7 @@ namespace NSMBe4.DSFileSystem public string getPath() { - if (parentDir == null) + if (parentDir is null) return "FS"; else return parentDir.getPath() + "/" + name; diff --git a/DS_Map/LibNDSFormats/NSBTX/filesystem2.cs b/DS_Map/LibNDSFormats/NSBTX/filesystem2.cs index 51149ad..16a4b56 100644 --- a/DS_Map/LibNDSFormats/NSBTX/filesystem2.cs +++ b/DS_Map/LibNDSFormats/NSBTX/filesystem2.cs @@ -73,7 +73,7 @@ namespace NSMBe4.DSFileSystem newDir = d; break; } - if (newDir == null) return null; + if (newDir is null) return null; dir = newDir; } diff --git a/DS_Map/LibNDSFormats/NSBTX/imageindexer.cs b/DS_Map/LibNDSFormats/NSBTX/imageindexer.cs index 5d3f9be..c41408d 100644 --- a/DS_Map/LibNDSFormats/NSBTX/imageindexer.cs +++ b/DS_Map/LibNDSFormats/NSBTX/imageindexer.cs @@ -100,7 +100,7 @@ namespace NSMBe4 { if (!c.deleteFlag) { int cnt = freqTable[c]; foreach (MultiColor c2 in freqTable.Keys) { - if (c2 == null) continue; + if (c2 is null) continue; if (c2.deleteFlag) continue; if (c2 == c) continue; @@ -130,7 +130,7 @@ namespace NSMBe4 { while (boxes.Count < (useAlpha ? paletteCount - 1 : paletteCount)) { Console.Out.WriteLine(boxes.Count); Box bo = getDominantBox(); - if (bo == null) + if (bo is null) break; split(bo); @@ -246,7 +246,7 @@ namespace NSMBe4 { int best = -1; float bestd = float.PositiveInfinity; for (int i = 0; i < multiPalette.Length; i++) { - if (multiPalette[i] == null) continue; + if (multiPalette[i] is null) continue; float d = mc.diff(multiPalette[i]); if (d < bestd || best == -1) { best = i; @@ -314,7 +314,7 @@ namespace NSMBe4 { foreach (Box b in boxes) { int dim = b.dominantDimension(freqTable); - if ((dim > bestDim || best == null) && b.canSplit(freqTable)) { + if ((dim > bestDim || best is null) && b.canSplit(freqTable)) { bestDim = dim; best = b; } diff --git a/DS_Map/LibNDSFormats/NSBTX/imagetiler.cs b/DS_Map/LibNDSFormats/NSBTX/imagetiler.cs index 451961c..ce15e96 100644 --- a/DS_Map/LibNDSFormats/NSBTX/imagetiler.cs +++ b/DS_Map/LibNDSFormats/NSBTX/imagetiler.cs @@ -74,11 +74,11 @@ namespace NSMBe4 for (int xt = 0; xt < (b.Height/8) * (b.Width/8); xt++) { //p.setValue(xt); - if (tiles[xt] == null) continue; + if (tiles[xt] is null) continue; for (int yt = 0; yt < xt; yt++) { - if (tiles[yt] == null) continue; + if (tiles[yt] is null) continue; float diff = tiles[xt].difference(tiles[yt]); if (diff < 0.5) mergeTiles(xt, yt); @@ -116,8 +116,8 @@ namespace NSMBe4 TileDiff td = en.Current; int t1 = td.t1; int t2 = td.t2; - if (tiles[t1] == null) continue; - if (tiles[t2] == null) continue; + if (tiles[t1] is null) continue; + if (tiles[t2] is null) continue; if (t1 == t2) throw new Exception("Should never happen"); mergeTiles(t1, t2); @@ -214,7 +214,7 @@ namespace NSMBe4 for (int t = 0; t < tileCount; t++) { if (t == tile) continue; - if (tiles[t] == null) continue; + if (tiles[t] is null) continue; float diff = tiles[tile].difference(tiles[t]); if (diff == 0) return t; diff --git a/DS_Map/LibNDSFormats/NSBTX/nsbmetileset.cs b/DS_Map/LibNDSFormats/NSBTX/nsbmetileset.cs index 1823873..e593a3c 100644 --- a/DS_Map/LibNDSFormats/NSBTX/nsbmetileset.cs +++ b/DS_Map/LibNDSFormats/NSBTX/nsbmetileset.cs @@ -815,7 +815,7 @@ namespace NSMBe4 for (int i = 0; i < Objects.Length; i++) { - if (Objects[i] == null) + if (Objects[i] is null) break; eObjIndexFile.writeUShort((ushort)eObjFile.getPos()); @@ -834,7 +834,7 @@ namespace NSMBe4 int[,] Dest = new int[Width, Height]; // Non-existent objects can just be made out of 0s - if (ObjNum >= Objects.Length || ObjNum < 0 || Objects[ObjNum] == null) + if (ObjNum >= Objects.Length || ObjNum < 0 || Objects[ObjNum] is null) return Dest; ObjectDef obj = Objects[ObjNum]; @@ -1067,7 +1067,7 @@ namespace NSMBe4 { if (objNum < 0) return false; if (objNum >= Objects.Length) return false; - if (Objects[objNum] == null) return false; + if (Objects[objNum] is null) return false; return true; } #endregion diff --git a/DS_Map/LibNDSFormats/NSBTX/nsbtx.cs b/DS_Map/LibNDSFormats/NSBTX/nsbtx.cs index 7e80d9d..c1a9c21 100644 --- a/DS_Map/LibNDSFormats/NSBTX/nsbtx.cs +++ b/DS_Map/LibNDSFormats/NSBTX/nsbtx.cs @@ -159,7 +159,7 @@ namespace NSMBe4.NSBMD for (int i = 0; i < textures.Length; i++) { - if (textures[i] == null) continue; + if (textures[i] is null) continue; textures[i].name = str.ReadString(16); //mgr.m.addImage(textures[i]); } diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index c7de4d7..2e0f3a3 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -915,7 +915,7 @@ namespace DSPRE { /* Set ROM gameVersion and language */ romInfo = new RomInfo(gameCode, workDir); - if (RomInfo.gameVersion == null) { + if (RomInfo.gameVersion is null) { statusLabel.Text = "Unsupported ROM"; Update(); return; @@ -1751,7 +1751,7 @@ namespace DSPRE { currentHeader.scriptFileID = (ushort)scriptFileUpDown.Value; } private void areaSettingsComboBox_SelectedIndexChanged(object sender, EventArgs e) { - if (disableHandlers || areaSettingsComboBox.SelectedItem == null) + if (disableHandlers || areaSettingsComboBox.SelectedItem is null) return; switch (RomInfo.gameFamily) { @@ -2129,7 +2129,7 @@ namespace DSPRE { } private void GenerateMatrixTables() { /* Generate table columns */ - if (currentMatrix == null) + if (currentMatrix is null) return; for (int i = 0; i < currentMatrix.width; i++) { @@ -2246,7 +2246,7 @@ namespace DSPRE { } } private void headersGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { - if (e.Value == null) + if (e.Value is null) return; disableHandlers = true; @@ -2354,7 +2354,7 @@ namespace DSPRE { disableHandlers = false; } private void heightsGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { - if (e.Value == null) + if (e.Value is null) return; disableHandlers = true; @@ -4077,7 +4077,7 @@ namespace DSPRE { disableHandlers = false; } private void centerEventViewOnSelectedEvent_Click(object sender, EventArgs e) { - if (selectedEvent == null) { + if (selectedEvent is null) { MessageBox.Show("You haven't selected any event.", "Nothing to do here", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { @@ -6294,7 +6294,7 @@ namespace DSPRE { disableHandlers = true; textEditorDataGridView.Rows.Clear(); - if (currentTextArchive == null || readAgain) { + if (currentTextArchive is null || readAgain) { currentTextArchive = new TextArchive(selectTextFileComboBox.SelectedIndex); } @@ -6468,7 +6468,7 @@ namespace DSPRE { currentTileset = new NSMBe4.NSBMD.NSBTX_File(new FileStream(tilesetPath, FileMode.Open)); string currentItemName = texturePacksListBox.Items[texturePacksListBox.SelectedIndex].ToString(); - if (currentTileset.TexInfo.names == null || currentTileset.PalInfo.names == null) { + if (currentTileset.TexInfo.names is null || currentTileset.PalInfo.names is null) { if (!currentItemName.StartsWith("Error!")) { texturePacksListBox.Items[texturePacksListBox.SelectedIndex] = "Error! - " + currentItemName; } diff --git a/DS_Map/ROMFiles/RomFile.cs b/DS_Map/ROMFiles/RomFile.cs index 3fa28d0..047b455 100644 --- a/DS_Map/ROMFiles/RomFile.cs +++ b/DS_Map/ROMFiles/RomFile.cs @@ -9,7 +9,7 @@ namespace DSPRE.ROMFiles { public void SaveToFile(string path, bool showSuccessMessage = true) { byte[] romFileToByteArray = ToByteArray(); - if (romFileToByteArray == null) { + if (romFileToByteArray is null) { Console.WriteLine(GetType().Name + " couldn't be saved!"); return; } diff --git a/DS_Map/ROMFiles/ScriptCommand.cs b/DS_Map/ROMFiles/ScriptCommand.cs index 2cb1ede..d21bf3b 100644 --- a/DS_Map/ROMFiles/ScriptCommand.cs +++ b/DS_Map/ROMFiles/ScriptCommand.cs @@ -38,7 +38,7 @@ namespace DSPRE.ROMFiles { #region Constructors (2) public ScriptCommand(ushort id, List commandParameters) { - if (commandParameters == null) { + if (commandParameters is null) { this.id = null; return; } diff --git a/DS_Map/ROMFiles/ScriptFile.cs b/DS_Map/ROMFiles/ScriptFile.cs index 404534b..e399912 100644 --- a/DS_Map/ROMFiles/ScriptFile.cs +++ b/DS_Map/ROMFiles/ScriptFile.cs @@ -72,7 +72,7 @@ namespace DSPRE.ROMFiles { bool endScript = new bool(); while (!endScript) { ScriptCommand cmd = ReadCommand(scrReader, ref functionOffsets, ref movementOffsets); - if (cmd.cmdParams == null) + if (cmd.cmdParams is null) return; cmdList.Add(cmd); @@ -97,7 +97,7 @@ namespace DSPRE.ROMFiles { bool endFunction = new bool(); while (!endFunction) { ScriptCommand command = ReadCommand(scrReader, ref functionOffsets, ref movementOffsets); - if (command.cmdParams == null) + if (command.cmdParams is null) return; cmdList.Add(command); @@ -155,15 +155,15 @@ namespace DSPRE.ROMFiles { || PokeDatabase.ScriptEditor.endCodes.Contains(id); allScripts = ReadCommandsFromLines(scriptLines, containerTypes.SCRIPT, scriptEndCondition); //Jump + whitespace - if (allScripts == null || allScripts.Count <= 0) + if (allScripts is null || allScripts.Count <= 0) return; allFunctions = ReadCommandsFromLines(functionLines, containerTypes.FUNCTION, functionEndCondition); //Jump + whitespace - if (allFunctions == null) + if (allFunctions is null) return; allActions = ReadActionsFromLines(actionLines); - if (allActions == null) + if (allActions is null) return; this.fileID = fileID; @@ -475,7 +475,7 @@ namespace DSPRE.ROMFiles { ScriptCommand lastRead; do { lastRead = new ScriptCommand(lineSource[i], i + 1); - if (lastRead.id == null) + if (lastRead.id is null) return null; cmdList.Add(lastRead); @@ -505,7 +505,7 @@ namespace DSPRE.ROMFiles { /* Read script commands */ do { ScriptAction toAdd = new ScriptAction(lineSource[i], i + 1); - if (toAdd.id == null) + if (toAdd.id is null) return null; cmdList.Add(toAdd); diff --git a/DS_Map/ROMToolboxDialog.cs b/DS_Map/ROMToolboxDialog.cs index c8559e4..492c808 100644 --- a/DS_Map/ROMToolboxDialog.cs +++ b/DS_Map/ROMToolboxDialog.cs @@ -697,7 +697,7 @@ namespace DSPRE { //09 22 02 4D A8 47 00 20 //03 21 FC BD F1 64 00 02 //00 80 3C 02 - if (hexString == null) + if (hexString is null) return null; hexString = hexString.Trim(); diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index 2c2fccb..8e1b43f 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -81,7 +81,7 @@ namespace DSPRE { romID = id; workDir = dir; LoadGameVersion(); - if (gameVersion == null) + if (gameVersion is null) return; LoadGameFamily(); diff --git a/DS_Map/SpawnEditor.cs b/DS_Map/SpawnEditor.cs index 50d3bd3..33e1618 100644 --- a/DS_Map/SpawnEditor.cs +++ b/DS_Map/SpawnEditor.cs @@ -11,7 +11,7 @@ namespace DSPRE { InitializeComponent(); this.names = allNames; - if (results == null || results.Count <= 1) { + if (results is null || results.Count <= 1) { SetupFields(allNames); spawnHeaderComboBox.SelectedIndex = headerNumber; } else {