From 6443a1654977e58ecdebff2dc4f86593a12b250d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Leclaire-Fournier?= Date: Thu, 25 Jan 2024 19:07:44 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20bogue=20de=20couleur=20blanche=20apr?= =?UTF-8?q?=C3=A8s=20des=20=C3=A9change=20d'engins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GPA675Lab1GOL/GOLTeamH.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/GPA675Lab1GOL/GOLTeamH.cpp b/GPA675Lab1GOL/GOLTeamH.cpp index 290940d..3fd0c3b 100644 --- a/GPA675Lab1GOL/GOLTeamH.cpp +++ b/GPA675Lab1GOL/GOLTeamH.cpp @@ -460,9 +460,14 @@ void GOLTeamH::setSolidColor(State state, Color const& color) else mDeadColor = color; + mColorEncoded &= 0; // Clear mColorEncoded |= ((static_cast(mAliveColor.red) << 16) << 32 * static_cast(state)); mColorEncoded |= ((static_cast(mAliveColor.green) << 8) << 32 * static_cast(state)); mColorEncoded |= (static_cast(mAliveColor.blue) << 32 * static_cast(state)); + + mColorEncoded |= ((static_cast(mDeadColor.red) << 16) * static_cast(state)); + mColorEncoded |= ((static_cast(mDeadColor.green) << 8) * static_cast(state)); + mColorEncoded |= (static_cast(mDeadColor.blue) * static_cast(state)); } @@ -489,7 +494,7 @@ void GOLTeamH::processOneStep() auto const widthNoBorder{ mData.width() - 2 }, heightNoBorder{ mData.height() - 2 }; auto const offset{ mData.width() }; - size_t neighboursAliveCount{}, aliveCount{}; + size_t neighborsAliveCount{}, aliveCount{}; // On commence à la première case qui n'est pas dans le border // Pointeur du tableau intermédiaire. @@ -501,29 +506,29 @@ void GOLTeamH::processOneStep() for (size_t j{ 1 }; j < heightNoBorder + 1; ++j) { for (size_t i{ 1 }; i < widthNoBorder + 1; ++i) { - neighboursAliveCount = 0; + neighborsAliveCount = 0; // Top - neighboursAliveCount += *ptrGrid; + neighborsAliveCount += *ptrGrid; ptrGrid++; - neighboursAliveCount += *ptrGrid; + neighborsAliveCount += *ptrGrid; ptrGrid++; - neighboursAliveCount += *ptrGrid; + neighborsAliveCount += *ptrGrid; // Milieu ptrGrid += offset - 2; - neighboursAliveCount += *ptrGrid; + neighborsAliveCount += *ptrGrid; ptrGrid += 2; - neighboursAliveCount += *ptrGrid; + neighborsAliveCount += *ptrGrid; // Dessous ptrGrid += offset - 2; - neighboursAliveCount += *ptrGrid; + neighborsAliveCount += *ptrGrid; ptrGrid++; - neighboursAliveCount += *ptrGrid; + neighborsAliveCount += *ptrGrid; ptrGrid++; - neighboursAliveCount += *ptrGrid; + neighborsAliveCount += *ptrGrid; // On retourne à une place plus loin qu'à l'origine. ptrGrid -= (2 * offset) + 1; @@ -534,8 +539,7 @@ void GOLTeamH::processOneStep() // On accède à la bonne partie des bits et on compare si le bit de survie/réanimation est // présent. Voir GOLTeamH.cpp pour plus de détails. *(ptrGridInt - 1) = static_cast( - (mParsedRule >> static_cast(*(ptrGrid + offset)) * 16) & (1u << neighboursAliveCount) - ); + (mParsedRule >> *(ptrGrid + offset) * 16) & (1u << neighborsAliveCount)); if (*(ptrGridInt - 1)) aliveCount++;