mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-21 21:49: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")
|
replay_file_list = love.filesystem.getDirectoryItems("replays")
|
||||||
for i=1,#replay_file_list do
|
for i=1,#replay_file_list do
|
||||||
local data = love.filesystem.read("replays/"..replay_file_list[i])
|
local data = love.filesystem.read("replays/"..replay_file_list[i])
|
||||||
local new_replay = binser.deserialize(data)[1]
|
local success, new_replay = pcall(
|
||||||
replays[#replays + 1] = new_replay
|
function() return binser.deserialize(data)[1] end
|
||||||
|
)
|
||||||
|
if success then
|
||||||
|
replays[#replays + 1] = new_replay
|
||||||
|
end
|
||||||
end
|
end
|
||||||
table.sort(replays, function(a, b)
|
table.sort(replays, function(a, b)
|
||||||
return a["timestamp"] > b["timestamp"]
|
return a["timestamp"] > b["timestamp"]
|
||||||
|
Loading…
Reference in New Issue
Block a user