From e88529fe90a130b6d1860c9e238d47465ec029a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 5 Jul 2020 18:53:33 +0200 Subject: [PATCH] savestate: Take pokemon nickname padding into account MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- savestate/src/party.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/savestate/src/party.rs b/savestate/src/party.rs index 05941aa..93d01e4 100644 --- a/savestate/src/party.rs +++ b/savestate/src/party.rs @@ -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 = 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.