From fdcfd891cc69c3f3d205d5a65014ae88c335bbfc Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Wed, 1 Nov 2017 07:29:23 +0100 Subject: [PATCH] Cosmetic: invert logic --- src/path.cxx | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/path.cxx b/src/path.cxx index 8b35317..9a762b7 100644 --- a/src/path.cxx +++ b/src/path.cxx @@ -170,27 +170,27 @@ CDecor::CheminFillTerrain (Sint32 rank) if (step < but) for (dir = 0; dir < 8; dir++) { - if (CheminTestDirection (rank, pos, dir, next, ampli, cout, action)) - { - last = pos + ampli * next; - if (last < 0 || last >= MAXCELX * MAXCELY) - continue; + if (!CheminTestDirection (rank, pos, dir, next, ampli, cout, action)) + continue; - if (m_cheminWork[last] == 0 || m_cheminWork[last] > step + cout) - { - // marque les cases sautées - for (Sint32 i = 1; i < ampli; i++) - m_cheminWork[pos + i * next] = step + cout - ampli + i; + last = pos + ampli * next; + if (last < 0 || last >= MAXCELX * MAXCELY) + continue; - m_cheminWork[last] = step + cout; + if (m_cheminWork[last] != 0 && m_cheminWork[last] <= step + cout) + continue; - dx = m_blupi[rank].goalCel.x - last % MAXCELX; - dy = m_blupi[rank].goalCel.y - last / MAXCELX; + // marque les cases sautées + for (Sint32 i = 1; i < ampli; i++) + m_cheminWork[pos + i * next] = step + cout - ampli + i; - dist = (Sint32) (dy * dy) + (Sint32) (dx * dx); - fifo.put (last, dist); - } - } + m_cheminWork[last] = step + cout; + + dx = m_blupi[rank].goalCel.x - last % MAXCELX; + dy = m_blupi[rank].goalCel.y - last / MAXCELX; + + dist = (Sint32) (dy * dy) + (Sint32) (dx * dx); + fifo.put (last, dist); } } }