From 24029419278de43d36f22c20ba00bf06f03f87b9 Mon Sep 17 00:00:00 2001 From: Dylan Langston Date: Wed, 3 Jan 2024 19:17:47 -0500 Subject: [PATCH] Fix high score decryption --- src/Settings.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Settings.zig b/src/Settings.zig index 609f70a..6709f86 100644 --- a/src/Settings.zig +++ b/src/Settings.zig @@ -59,7 +59,14 @@ pub const Settings = struct { defer settings.deinit(); var highScoreDecryptedOut: [32]u8 = undefined; - Shared.Crypto.Decrypt(settings.value.object.get("HighScore").?.string[0..], highScoreDecryptedOut[0..]); + if (settings.value.object.contains("HighScore")) { + const highScore = settings.value.object.get("HighScore").?.array; + var scoreBuffer: [48]u8 = undefined; + for (0..highScore.items.len) |i| { + scoreBuffer[i] = @intCast(highScore.items[i].integer); + } + Shared.Crypto.Decrypt(&scoreBuffer, highScoreDecryptedOut[0..]); + } var trimValue: [1]u8 = undefined; const highScore = if (settings.value.object.contains("HighScore")) (std.fmt.parseInt(u64, std.mem.trimRight(u8, &highScoreDecryptedOut, &trimValue), 10) catch default_settings.HighScore) else default_settings.HighScore;