Fix ctf_stats migration crash on new servers

This commit is contained in:
rubenwardy 2017-11-07 00:32:20 +00:00
parent 9f6ccaf386
commit c835a117a7

View file

@ -23,21 +23,7 @@ function ctf_stats.load()
if player_stats.score > 800 then
player_stats.score = 800
end
end
ctf.needs_save = true
end
os.remove(minetest.get_worldpath() .. "/ctf_stats.txt")
else
for _, key in pairs(data_to_persist) do
ctf_stats[key] = minetest.parse_json(storage:get_string(key))
end
ctf_stats.matches.wins = ctf_stats.matches.wins or {
red = ctf_stats.matches.red_wins or 0,
blue = ctf_stats.matches.blue_wins or 0,
}
for name, player_stats in pairs(ctf_stats.players) do
player_stats.wins = player_stats.wins or {}
if player_stats.blue_wins then
player_stats.wins.blue = player_stats.blue_wins
@ -50,6 +36,19 @@ function ctf_stats.load()
player_stats.wins.blue = player_stats.wins.blue or 0
player_stats.wins.red = player_stats.wins.red or 0
end
ctf_stats.matches.wins = ctf_stats.matches.wins or {
red = ctf_stats.matches.red_wins or 0,
blue = ctf_stats.matches.blue_wins or 0,
}
ctf.needs_save = true
end
os.remove(minetest.get_worldpath() .. "/ctf_stats.txt")
else
for _, key in pairs(data_to_persist) do
ctf_stats[key] = minetest.parse_json(storage:get_string(key))
end
ctf.needs_save = true
end