mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-24 09:09:03 -06:00
Added error handling in the case of a corrupt replay
This commit is contained in:
parent
7199aa7ef6
commit
c693871621
@ -14,9 +14,13 @@ function ReplaySelectScene:new()
|
||||
replay_file_list = love.filesystem.getDirectoryItems("replays")
|
||||
for i=1,#replay_file_list do
|
||||
local data = love.filesystem.read("replays/"..replay_file_list[i])
|
||||
local new_replay = binser.deserialize(data)[1]
|
||||
local success, new_replay = pcall(
|
||||
function() return binser.deserialize(data)[1] end
|
||||
)
|
||||
if success then
|
||||
replays[#replays + 1] = new_replay
|
||||
end
|
||||
end
|
||||
table.sort(replays, function(a, b)
|
||||
return a["timestamp"] > b["timestamp"]
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user