From 631d9079d03d88e95cd945497a223f697fdc8670 Mon Sep 17 00:00:00 2001 From: LerPetitCarcajou Date: Wed, 31 Jan 2024 18:20:10 -0500 Subject: [PATCH] verification border pattern --- GPA675Lab1GOL/GOLTeamH.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/GPA675Lab1GOL/GOLTeamH.cpp b/GPA675Lab1GOL/GOLTeamH.cpp index a9dcfc5..203960e 100644 --- a/GPA675Lab1GOL/GOLTeamH.cpp +++ b/GPA675Lab1GOL/GOLTeamH.cpp @@ -545,6 +545,13 @@ void GOLTeamH::fillDataFromPattern(std::string const& pattern, sizeQueried& sq, for (size_t y = 0; y < sq.height; ++y) { for (size_t x = 0; x < sq.width; ++x) { // TODO: Check si in bounds et vérifie que ça répare le problème de quand on ferme, erreur. + 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; + } + State cellState = (sq.pos[(y * sq.width) + x] == '0') ? State::dead : State::alive; mData.setAt(centerX + x, centerY + y, cellState); }