savestate: Take pokemon nickname padding into account

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2020-07-05 18:53:33 +02:00
parent 4593b45e2e
commit e88529fe90
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -70,15 +70,16 @@ impl TryFrom<&[u8]> for PokemonList {
}
// Pokemon names x6
// Data seems to consist of 10 chars padded with 0x50 plus one 0x50 per pokémon.
let mut pk_nicks: Vec<PKString> = vec![];
let mut start = PARTY_PK_NAMES_OFFSET;
for _ in 0..count {
for i in 1..=count {
let mut end = start + 1;
while data[end] != 0x50 {
end += 1;
}
pk_nicks.push(PKString::try_from(&data[start..end])?);
start = end + 1;
start = PARTY_PK_NAMES_OFFSET + 11 * i;
}
// Now pokemon data.