Fix cxd strategymemo/shadowinfo export

Closes #1347
Closes #1296
This commit is contained in:
Kurt 2017-08-06 17:20:04 -07:00
parent 07690e2919
commit ebecb21b2e
2 changed files with 5 additions and 3 deletions

View File

@ -20,7 +20,7 @@ public ShadowInfoTableXD(byte[] data)
Array.Copy(data, i*eSize, d, 0, eSize);
var entry = new ShadowInfoEntryXD(d);
if (entry.Species != 0)
//if (entry.Species != 0)
Entries.Add(entry);
}
}

View File

@ -10,6 +10,7 @@ public class StrategyMemo
private const int SIZE_ENTRY = 12;
private readonly List<StrategyMemoEntry> Entries = new List<StrategyMemoEntry>();
private StrategyMemoEntry this[int Species] => Entries.FirstOrDefault(e => e.Species == Species);
private readonly byte[] _unk;
public StrategyMemo(byte[] input, int offset, bool xd)
{
@ -17,6 +18,7 @@ public StrategyMemo(byte[] input, int offset, bool xd)
int count = BigEndian.ToInt16(input, offset);
if (count > 500)
count = 500;
_unk = input.Skip(offset + 2).Take(2).ToArray();
for (int i = 0; i < count; i++)
{
byte[] data = new byte[SIZE_ENTRY];
@ -24,8 +26,8 @@ public StrategyMemo(byte[] input, int offset, bool xd)
Entries.Add(new StrategyMemoEntry(XD, data));
}
}
public byte[] FinalData => BigEndian.GetBytes(Entries.Count) // count followed by populated entries
.Concat(Entries.Where(entry => entry.Species != 0).SelectMany(entry => entry.Data)).ToArray();
public byte[] FinalData => BigEndian.GetBytes((short)Entries.Count).Concat(_unk) // count followed by populated entries
.Concat(Entries.SelectMany(entry => entry.Data)).ToArray();
public StrategyMemoEntry GetEntry(int Species)
{