From f2474955783a7b81e6ba460d4eda618a02ec7c7a Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 9 Dec 2023 11:35:40 +0900 Subject: [PATCH] Breaking change: Fix ShArray.ChangeSecretArray This breaks save file compatibility for Daiakuji and Kaeru nyo Kuni nyo Alice. Due to an incorrect encryption code in ShArray.ChangeSecretArray, save files were not interoperable with system3.9. (Even worse, this bug did not affect the checksum calculation and did not cause a "corrupt save file" error when a file saved with system3.9 was loaded with xsystem35 or vice versa.) Fixes #41. --- modules/ShArray/ShArray.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/ShArray/ShArray.c b/modules/ShArray/ShArray.c index 11c36b5..d91d4ce 100644 --- a/modules/ShArray/ShArray.c +++ b/modules/ShArray/ShArray.c @@ -1306,7 +1306,7 @@ static void ChangeSecretArray(void) { /* 53 */ (*vAry) ^= ax; ax = (key[i&3] ^ *vAry); j ^= ax; if (i & 2) { - ax = !ax ^ (i*3); + ax = ~ax ^ (i*3); } if (i & 4) { ax = (ax >> 4) | (ax << 12); @@ -1328,13 +1328,12 @@ static void ChangeSecretArray(void) { /* 53 */ *vAry ^= ax; ax = (key[i&3] ^ k); j ^= ax; if (i & 2) { - ax = !ax ^ (i*3); + ax = ~ax ^ (i*3); } if (i & 4) { ax = (ax >> 4) | (ax << 12); } vAry++; - } *vResult = j; }