Fix setting wc with no wcID number

Closes #745
This commit is contained in:
Kurt
2017-01-25 20:49:53 -08:00
parent f1c2a74aed
commit ae8f929f97
2 changed files with 7 additions and 7 deletions

View File

@@ -635,7 +635,7 @@ public override void setDaycareHasEgg(int loc, bool hasEgg)
Data[ofs + 0x1E0] = (byte)(hasEgg ? 1 : 0);
}
public byte[] Puffs { get { return Data.Skip(Puff).Take(100).ToArray(); } set { value.CopyTo(Data, Puff); } }
public byte[] Puffs { get { return getData(Puff, 100); } set { value.CopyTo(Data, Puff); } }
public int PuffCount { get { return BitConverter.ToInt32(Data, Puff + 100); } set { BitConverter.GetBytes(value).CopyTo(Data, Puff + 100); } }
public int[] SelectItems
@@ -676,7 +676,7 @@ public int[] RecentItems
}
public override string JPEGTitle => JPEG < 0 ? null : Util.TrimFromZero(Encoding.Unicode.GetString(Data, JPEG, 0x1A));
public override byte[] JPEGData => JPEG < 0 || Data[JPEG + 0x54] != 0xFF ? null : Data.Skip(JPEG + 0x54).Take(0xE004).ToArray();
public override byte[] JPEGData => JPEG < 0 || Data[JPEG + 0x54] != 0xFF ? null : getData(JPEG + 0x54, 0xE004);
// Inventory
public override InventoryPouch[] Inventory
@@ -911,7 +911,7 @@ public byte[] LinkBlock
{
if (LinkInfo < 0)
return null;
return Data.Skip(LinkInfo).Take(0xC48).ToArray();
return getData(LinkInfo, 0xC48);
}
set
{
@@ -930,7 +930,7 @@ private MysteryGift getWC6(int index)
if (index < 0 || index > GiftCountMax)
return null;
return new WC6(Data.Skip(WondercardData + index * WC6.Size).Take(WC6.Size).ToArray());
return new WC6(getData(WondercardData + index * WC6.Size, WC6.Size));
}
private void setWC6(MysteryGift wc6, int index)
{
@@ -942,7 +942,7 @@ private void setWC6(MysteryGift wc6, int index)
wc6.Data.CopyTo(Data, WondercardData + index * WC6.Size);
for (int i = 0; i < GiftCountMax; i++)
if (BitConverter.ToUInt16(Data, WondercardData + i * WC6.Size) == 0)
if (getData(WondercardData + i * WC6.Size, WC6.Size).All(b => b == 0)) // empty
for (int j = i + 1; j < GiftCountMax - i; j++) // Shift everything down
Array.Copy(Data, WondercardData + j * WC6.Size, Data, WondercardData + (j - 1) * WC6.Size, WC6.Size);

View File

@@ -1123,7 +1123,7 @@ private WC7 getWC7(int index)
if (index < 0 || index > GiftCountMax)
return null;
return new WC7(Data.Skip(WondercardData + index * WC7.Size).Take(WC7.Size).ToArray());
return new WC7(getData(WondercardData + index * WC7.Size, WC7.Size));
}
private void setWC7(MysteryGift wc7, int index)
{
@@ -1135,7 +1135,7 @@ private void setWC7(MysteryGift wc7, int index)
wc7.Data.CopyTo(Data, WondercardData + index * WC7.Size);
for (int i = 0; i < GiftCountMax; i++)
if (BitConverter.ToUInt16(Data, WondercardData + i * WC7.Size) == 0)
if (getData(WondercardData + i * WC7.Size, WC7.Size).All(b => b == 0)) // empty
for (int j = i + 1; j < GiftCountMax - i; j++) // Shift everything down
Array.Copy(Data, WondercardData + j * WC7.Size, Data, WondercardData + (j - 1) * WC7.Size, WC7.Size);