mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-21 15:39:02 -06:00
Added error handling in the case of a corrupt replay
This commit is contained in:
parent
7199aa7ef6
commit
c693871621
@ -14,8 +14,12 @@ 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]
|
||||
replays[#replays + 1] = new_replay
|
||||
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"]
|
||||
|
Loading…
Reference in New Issue
Block a user