Fix wrong session index + save file corruption

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2025-12-06 14:25:01 +01:00
parent a9ff0a6d07
commit e6966a628c
5 changed files with 26 additions and 3 deletions

View File

@@ -255,18 +255,23 @@ pub fn main() !void {
const session_index = std.fmt.parseInt(usize, session_index_str, 10) catch continue;
try saved_users.user_list.append(allocator, .{
.username = username,
.username = try allocator.dupe(u8, username),
.session_index = session_index,
.first_run = false,
.allocated_username = true,
});
}
}
// If no save file previously existed, fill it up with all usernames
// TODO: Add new username with existing save file
if (config.save and saved_users.user_list.items.len == 0) {
for (usernames.items) |user| {
try saved_users.user_list.append(allocator, .{
.username = user,
.session_index = 0,
.first_run = true,
.allocated_username = false,
});
}
}