From e799353ccac14cec142e9fd93966c5260c93d842 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Mon, 18 Jul 2011 10:12:28 +0000 Subject: [PATCH] Fix a rare bug in the running code git-svn-id: http://svn.net-core.org/repos/t-engine4@3900 51575b47-30f0-44d4-a5cc-537603b46e54 --- .../default/engine/interface/PlayerRun.lua | 34 ++++++++++--------- game/modules/tome/class/Game.lua | 4 +-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/game/engines/default/engine/interface/PlayerRun.lua b/game/engines/default/engine/interface/PlayerRun.lua index f70e957615..05ca55de1d 100644 --- a/game/engines/default/engine/interface/PlayerRun.lua +++ b/game/engines/default/engine/interface/PlayerRun.lua @@ -364,25 +364,27 @@ function _M:runScan(fct) local x, y = self.x + dx, self.y + dy fct(x, y, "ahead") - -- Ahead left - local dx, dy = dir_to_coord[sides[self.running.dir].soft_left][1], dir_to_coord[sides[self.running.dir].soft_left][2] - local x, y = self.x + dx, self.y + dy - fct(x, y, "ahead left") + if sides[self.running.dir] then + -- Ahead left + local dx, dy = dir_to_coord[sides[self.running.dir].soft_left][1], dir_to_coord[sides[self.running.dir].soft_left][2] + local x, y = self.x + dx, self.y + dy + fct(x, y, "ahead left") - -- Ahead right - local dx, dy = dir_to_coord[sides[self.running.dir].soft_right][1], dir_to_coord[sides[self.running.dir].soft_right][2] - local x, y = self.x + dx, self.y + dy - fct(x, y, "ahead right") + -- Ahead right + local dx, dy = dir_to_coord[sides[self.running.dir].soft_right][1], dir_to_coord[sides[self.running.dir].soft_right][2] + local x, y = self.x + dx, self.y + dy + fct(x, y, "ahead right") - -- Left - local dx, dy = dir_to_coord[sides[self.running.dir].hard_left][1], dir_to_coord[sides[self.running.dir].hard_left][2] - local x, y = self.x + dx, self.y + dy - fct(x, y, "left") + -- Left + local dx, dy = dir_to_coord[sides[self.running.dir].hard_left][1], dir_to_coord[sides[self.running.dir].hard_left][2] + local x, y = self.x + dx, self.y + dy + fct(x, y, "left") - -- Right - local dx, dy = dir_to_coord[sides[self.running.dir].hard_right][1], dir_to_coord[sides[self.running.dir].hard_right][2] - local x, y = self.x + dx, self.y + dy - fct(x, y, "right") + -- Right + local dx, dy = dir_to_coord[sides[self.running.dir].hard_right][1], dir_to_coord[sides[self.running.dir].hard_right][2] + local x, y = self.x + dx, self.y + dy + fct(x, y, "right") + end elseif self.running.path[self.running.cnt] then -- Ahead diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 4dcba46b3b..5611545e22 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -912,13 +912,13 @@ function _M:display(nb_keyframes) _2DNoise:bind(1, false) self.fbo:toScreen(map.display_x, map.display_y, map.viewport.width, map.viewport.height, self.fbo_shader.shad) - self.target:display() + if self.target then self.target:display() end -- Basic display; no FBOs else if self.level.data.background then self.level.data.background(self.level, map.display_x, map.display_y, nb_keyframes) end map:display(nil, nil, nb_keyframes) - self.target:display() + if self.target then self.target:display() end if self.level.data.foreground then self.level.data.foreground(self.level, map.display_x, map.display_y, nb_keyframes) end if self.level.data.weather_particle then self.state:displayWeather(self.level, self.level.data.weather_particle, nb_keyframes) end end -- GitLab