From: Laurent Mazet Date: Sun, 23 Jun 2024 08:14:51 +0000 (+0200) Subject: correct rotation (2) X-Git-Tag: v1.0~22 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=dbf7e8ba1873412ad7c300c5b99d4b2b35903d13;p=gameoflife.git correct rotation (2) --- diff --git a/function.c b/function.c index d343920..4cff58e 100644 --- a/function.c +++ b/function.c @@ -238,12 +238,8 @@ void rotateelement (board_t *element, int rot) rot = (rot > 0) ? rot % 4 : ((1 - rot / 4) * 4 + rot) % 4; - board_t *newelement = NULL; - if (rot % 2 == 0) { - newelement = initboard (element->xsize, element->ysize); - } else { - newelement = initboard (element->ysize, element->xsize); - } + int maxsize = (element->xsize > element->ysize) ? element->xsize : element->ysize; + board_t *newelement = initboard (maxsize, maxsize); switch (rot) { case 0: