public async Task Write(CroFile dllField, CroFile dllPoke3Select) { byte[] fieldCode = await dllField.GetCodeSection(); byte[] pokeSelectData = await dllPoke3Select.GetDataSection(); this.SynchronizeSpecies(); fieldCode.WithWriter(bw => this.startersField.WriteData(bw)); pokeSelectData.WithWriter(bw => this.startersPokeSelect.WriteData(bw)); await dllField.WriteCodeSection(fieldCode); await dllPoke3Select.WriteDataSection(pokeSelectData); }
public async Task Read(CroFile dllField, CroFile dllPoke3Select) { byte[] fieldCode = await dllField.GetCodeSection(); byte[] pokeSelectData = await dllPoke3Select.GetDataSection(); fieldCode.WithReader(br => this.startersField.ReadData(br)); pokeSelectData.WithReader(br => this.startersPokeSelect.ReadData(br)); for (int gen = 1; gen <= 6; gen++) { for (int entry = 0; entry < 3; entry++) { ushort speciesField = this.startersField.StarterSpecies[gen - 1][entry]; ushort speciesPokeSelect = this.startersPokeSelect.StarterSpecies[gen - 1][entry]; if (speciesField != speciesPokeSelect) { throw new InvalidDataException($"Species ID for Gen {gen}, Starter {entry + 1} did not match in the two CRO files. " + $"DllField was {speciesField} but DllPoke3Select was {speciesPokeSelect}"); } } } }