From e52a998e845c18a76194c100373ed9b99709577a Mon Sep 17 00:00:00 2001 From: LerPetitCarcajou Date: Thu, 1 Feb 2024 10:08:25 -0500 Subject: [PATCH] =?UTF-8?q?pattern=20apparait.=20Toujours=20un=20probl?= =?UTF-8?q?=C3=A8me=20de=20gestion=20de=20m=C3=A9moire=20qui=20fait=20plan?= =?UTF-8?q?ter.=20Surement=20un=20delete[]=C3=A0=20faire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GPA675Lab1GOL/GOLTeamH.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/GPA675Lab1GOL/GOLTeamH.cpp b/GPA675Lab1GOL/GOLTeamH.cpp index 489f9cc..da535a8 100644 --- a/GPA675Lab1GOL/GOLTeamH.cpp +++ b/GPA675Lab1GOL/GOLTeamH.cpp @@ -354,7 +354,6 @@ bool GOLTeamH::setFromPattern(std::string const& pattern) int centerY = (mData.height() - sq.value().height)/2; fillDataFromPattern(pattern, sq.value(),centerX+1, centerY+1); - mIteration = 0; countLifeStatusCells(); @@ -564,14 +563,9 @@ void GOLTeamH::fillDataFromPattern(std::string const& pattern, sizeQueried& sq, // Coordonnées dans la grille de destination int destX = centerX + x; int destY = centerY + y; - /*if (centerX - sq.width / 2 + x <0 - || centerX - sq.width / 2 + x > mData.width() - || centerY - sq.height / 2 + x <0 - || centerY - sq.height / 2 + x > mData.height()) { - continue; - }*/ + // Vérifier si les coordonnées sont dans la grille - if (destX >= 0 || destX < mData.width()-1 || destY >= 0 || destY < mData.height()-1) { + if (destX >= 0 || destX < mData.width() || destY >= 0 || destY < mData.height()) { // On remplit la grille avec les valeurs du pattern State cellState = (sq.pos[(y * sq.width) + x] == '0') ? State::dead : State::alive; mData.setAt(destX, destY, cellState); @@ -582,6 +576,7 @@ void GOLTeamH::fillDataFromPattern(std::string const& pattern, sizeQueried& sq, } } + } void GOLTeamH::countLifeStatusCells()