Revert implicit byte cast

similar to earlier pkNX/pkhex commit; this wasn't an intended c# feature
This commit is contained in:
Kurt
2021-05-26 22:45:45 -07:00
parent 6ce4f351d7
commit 3d1e3b6e8b
8 changed files with 10 additions and 11 deletions

View File

@@ -155,9 +155,9 @@ internal static NCSD SetNCSD(NCCH NCCH, bool Card2, RichTextBox TB_Progress = nu
}
NCSD.Header.flags = new byte[0x8];
NCSD.Header.flags[0] = 0; // 0-255 seconds of waiting for save writing.
NCSD.Header.flags[3] = NCSD.Card2 ? 2 : 1; // Media Card Device: 1 = NOR Flash, 2 = None, 3 = BT
NCSD.Header.flags[3] = NCSD.Card2 ? (byte)2 : (byte)1; // Media Card Device: 1 = NOR Flash, 2 = None, 3 = BT
NCSD.Header.flags[4] = 1; // Media Platform Index: 1 = CTR
NCSD.Header.flags[5] = NCSD.Card2 ? 2 : 1; // Media Type Index: 0 = Inner Device, 1 = Card1, 2 = Card2, 3 = Extended Device
NCSD.Header.flags[5] = NCSD.Card2 ? (byte)2 : (byte)1; // Media Type Index: 0 = Inner Device, 1 = Card1, 2 = Card2, 3 = Extended Device
NCSD.Header.flags[6] = 0; // Media Unit Size. Same as NCCH.
NCSD.Header.flags[7] = 0; // Old Media Card Device.
NCSD.Header.NCCHIdTable = new ulong[8];

View File

@@ -63,7 +63,7 @@ public override int HeldItem
public bool IsEgg
{
get => Data[0xA] == 1;
set => Data[0xA] = value ? 1 : 0;
set => Data[0xA] = value ? (byte)1 : (byte)0;
}
public int SpecialMove

View File

@@ -33,7 +33,7 @@ public TrainerData7(byte[] tr = null, byte[] tp = null)
public int Item4 { get => BitConverter.ToUInt16(trdata, 0x0A); set => BitConverter.GetBytes((ushort)value).CopyTo(trdata, 0x0A); }
public int AI { get => trdata[0x0C]; set => trdata[0x0C] = (byte)value; }
public bool Flag { get => trdata[0x0D] == 1; set => trdata[0x0D] = value ? 1 : 0; }
public bool Flag { get => trdata[0x0D] == 1; set => trdata[0x0D] = value ? (byte)1 : (byte)0; }
public int Money { get => trdata[0x11]; set => trdata[0x11] = (byte)value; }
public void Write(out byte[] tr, out byte[] pk)

View File

@@ -34,6 +34,6 @@ public override byte[] Write()
public int SpecialZ_Item { get => BitConverter.ToUInt16(Data, 0x4C); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4C); }
public int SpecialZ_BaseMove { get => BitConverter.ToUInt16(Data, 0x4E); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4E); }
public int SpecialZ_ZMove { get => BitConverter.ToUInt16(Data, 0x50); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x50); }
public bool LocalVariant { get => Data[0x52] == 1; set => Data[0x52] = value ? 1 : 0; }
public bool LocalVariant { get => Data[0x52] == 1; set => Data[0x52] = value ? (byte)1 : (byte)0; }
}
}

View File

@@ -132,7 +132,7 @@ private void SetEntry()
{
if (me.Method[i] > 1)
return; // Shouldn't hit this.
me.Method[i] = checkbox_spec[i].Checked ? 1 : 0;
me.Method[i] = checkbox_spec[i].Checked ? (byte)1 : (byte)0;
me.Argument[i] = (ushort)WinFormsUtil.GetIndex(item_spec[i]);
me.Form[i] = (ushort)forme_spec[i].SelectedIndex;
}

View File

@@ -139,11 +139,11 @@ private void InsertFile(string path)
{
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Overwrite image?"))
return;
byte[] data = File.ReadAllBytes(path);
byte[] bclim;
if (Path.GetExtension(path) == ".bclim") // bclim opened
{
byte[] data = File.ReadAllBytes(path);
var img = BCLIM.Analyze(data, path);
if (img.Width != PB_Image.Width || img.Height != PB_Image.Height)
{
@@ -155,8 +155,7 @@ private void InsertFile(string path)
}
else // image
{
using Stream BitmapStream = new MemoryStream(data);
Image img = Image.FromStream(BitmapStream);
Image img = Image.FromFile(path);
if (img.Width != PB_Image.Width || img.Height != PB_Image.Height)
{
WinFormsUtil.Alert("Image sizes do not match.",

View File

@@ -132,7 +132,7 @@ private void SetEntry()
{
if (me.Method[i] > 1)
return; // Shouldn't hit this.
me.Method[i] = checkbox_spec[i].Checked ? 1 : 0;
me.Method[i] = checkbox_spec[i].Checked ? (byte)1 : (byte)0;
me.Argument[i] = (ushort)WinFormsUtil.GetIndex(item_spec[i]);
me.Form[i] = (ushort)forme_spec[i].SelectedIndex;
}

View File

@@ -117,7 +117,7 @@ private void B_Save_Click(object sender, EventArgs e)
{
WriteCodePatch();
if (CHK_EverythingShiny.Enabled)
exefsData[alwaysIndex] = CHK_EverythingShiny.Checked ? 0xEA : 0x0A;
exefsData[alwaysIndex] = CHK_EverythingShiny.Checked ? (byte)0xEA : (byte)0x0A;
File.WriteAllBytes(codebin, exefsData);
Close();
}