Fix player sky race.

Fixes a bug that would leave the player's sky permanently white after
two lightning strikes occur in rapid succession.
This commit is contained in:
brittm3 2016-11-21 13:18:21 -06:00 committed by Auke Kok
parent 846079370f
commit 1d9dfaa785

View File

@ -34,8 +34,9 @@ local revertsky = function()
return
end
for i = 1, table.getn(ps) do
ps[i].p:set_sky(ps[i].sky.bgcolor, ps[i].sky.type, ps[i].sky.textures)
for key, entry in pairs(ps) do
local sky = entry.sky
entry.p:set_sky(sky.bgcolor, sky.type, sky.textures)
end
ps = {}
@ -130,11 +131,18 @@ lightning.strike = function(pos)
local playerlist = minetest.get_connected_players()
for i = 1, #playerlist do
local player = playerlist[i]
local sky = {}
sky.bgcolor, sky.type, sky.textures = playerlist[i]:get_sky()
table.insert(ps, { p = playerlist[i], sky = sky})
playerlist[i]:set_sky(0xffffff, "plain", {})
sky.bgcolor, sky.type, sky.textures = player:get_sky()
local name = player:get_player_name()
if ps[name] == nil then
ps[name] = {p = player, sky = sky}
player:set_sky(0xffffff, "plain", {})
end
end
-- trigger revert of skybox
ttl = 5