Changed == null to "is null"

This commit is contained in:
AdAstra-LD
2021-04-24 17:05:35 +02:00
parent 383de86715
commit 3e5dc2d729
18 changed files with 49 additions and 49 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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<Vector3D> nor = new List<Vector3D>();
IList<Point> tex = new List<Point>();
int typ = -1;
if (polydata == null)
if (polydata is null)
return;
int commandptr = 0;
int commandlimit = polydata.Length;

View File

@@ -95,7 +95,7 @@ namespace NSMBe4
//public static void close()
//{
// if (FS == null) return;
// if (FS is null) return;
// FS.close();
//}

View File

@@ -67,7 +67,7 @@ namespace NSMBe4.DSFileSystem
public string getPath()
{
if (parentDir == null)
if (parentDir is null)
return "FS";
else
return parentDir.getPath() + "/" + name;

View File

@@ -73,7 +73,7 @@ namespace NSMBe4.DSFileSystem
newDir = d;
break;
}
if (newDir == null) return null;
if (newDir is null) return null;
dir = newDir;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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]);
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -38,7 +38,7 @@ namespace DSPRE.ROMFiles {
#region Constructors (2)
public ScriptCommand(ushort id, List<byte[]> commandParameters) {
if (commandParameters == null) {
if (commandParameters is null) {
this.id = null;
return;
}

View File

@@ -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);

View File

@@ -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();

View File

@@ -81,7 +81,7 @@ namespace DSPRE {
romID = id;
workDir = dir;
LoadGameVersion();
if (gameVersion == null)
if (gameVersion is null)
return;
LoadGameFamily();

View File

@@ -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 {