Skip to content
Snippets Groups Projects
Commit 08f7300e authored by DarkGod's avatar DarkGod
Browse files

Merge branch 'redisplay_fix' into 'master'

Redisplay fix

Calling redisplay() multiple times per turn is notorious for causing lag. The worst offender is probably Smoke Bomb, and it just got stripped from Creeping Dark.
This commit introduces a new scheduleRedisplay method, which uses little-known feature of game:onTickEnd to ensure that a redisplay would only get called once per this tick, not causing any frame drops.
parents 57987f3e cfb4e835
No related branches found
No related tags found
No related merge requests found
......@@ -388,6 +388,11 @@ function _M:redisplay()
end end
end
-- Schedules a redisplay, use this in places where multiple redisplays might happen on the same tick
function _M:scheduleRedisplay()
game:onTickEnd(function() self:redisplay() end, "map_redisplay")
end
--- Closes things in the object to allow it to be garbage collected
-- Map objects are NOT automatically garbage collected because they contain FOV C structure, which themselves have a reference
-- to the map. Cyclic references! BAD BAD BAD !<br/>
......
......@@ -1078,12 +1078,12 @@ newTalent{
game.level.map(self.x, self.y, engine.Map.TERRAIN, self.old_feat)
game.nicer_tiles:updateAround(game.level, self.x, self.y)
game.level:removeEntity(self)
-- game.level.map:redisplay()
game.level.map:scheduleRedisplay()
end
end,
dig = function(src, x, y, old)
game.level:removeEntity(old)
-- game.level.map:redisplay()
game.level.map:scheduleRedisplay()
return nil, old.old_feat
end,
summoner_gain_exp = true,
......
......@@ -236,7 +236,7 @@ newTalent{
game.level.map:remove(self.x, self.y, Map.TERRAIN+3)
game.level:removeEntity(self, true)
self.creepingDark = nil
--game.level.map:redisplay()
game.level.map:scheduleRedisplay()
else
self.duration = self.duration - 1
......
......@@ -179,12 +179,12 @@ newTalent{
game.level.map(self.x, self.y, engine.Map.TERRAIN, self.old_feat)
game.nicer_tiles:updateAround(game.level, self.x, self.y)
game.level:removeEntity(self)
-- game.level.map:redisplay()
game.level.map:scheduleRedisplay()
end
end,
dig = function(src, x, y, old)
game.level:removeEntity(old)
-- game.level.map:redisplay()
game.level.map:scheduleRedisplay()
return nil, old.old_feat
end,
summoner_gain_exp = true,
......
......@@ -82,7 +82,7 @@ newTalent{
if self.temporary <= 0 then
game.level.map:remove(self.x, self.y, engine.Map.TERRAIN+2)
game.level:removeEntity(self)
game.level.map:redisplay()
game.level.map:scheduleRedisplay()
end
end,
summoner_gain_exp = true,
......@@ -100,6 +100,7 @@ newTalent{
end)
end
game:playSoundNear(self, "talents/breath")
game.level.map:redisplay()
return true
end,
info = function(self, t)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment