Skip to content

Commit

Permalink
Fix high score decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanlangston committed Jan 4, 2024
1 parent 7730a14 commit 2402941
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Settings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2402941

Please sign in to comment.