From e31258e26cccefedcbfc7ec93b70bbf231a40282 Mon Sep 17 00:00:00 2001 From: AnnaSnoeijs Date: Wed, 25 Jun 2025 11:41:51 +0200 Subject: [PATCH] Fixed a little silly --- logic.c | 4 ++-- logic.h | 4 ++-- macros.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/logic.c b/logic.c index 9ff57de..aa36dff 100644 --- a/logic.c +++ b/logic.c @@ -72,7 +72,7 @@ void calcWins( // Now the rest of the wins // First connect 2 for( - columnsint_t i = top( column - 1, 0 ); + columnsint_t i = clipped_subtract( column, 1 ); i < bottom( column + 1, board.columns - 1 ); i++ ){ @@ -101,7 +101,7 @@ void calcWins( } // Then stitch the twos together and count for( - columnsint_t i = top( column - 3, 0 ); + columnsint_t i = clipped_subtract( column, 3 ); i < bottom( column + 1, board.columns - 3 ); i++ ){ diff --git a/logic.h b/logic.h index 4123f8a..488894c 100644 --- a/logic.h +++ b/logic.h @@ -6,11 +6,11 @@ extern void playMove( board_t *boardptr, - const int column + const columnsint_t column ); extern void calcWins( wins_t *wins, const board_t board, - const int column + const columnsint_t column ); diff --git a/macros.h b/macros.h index 0326c6c..20b6cf4 100644 --- a/macros.h +++ b/macros.h @@ -3,6 +3,7 @@ #define top( a, b ) ( a < b ? b : a ) #define bottom( a, b ) ( a < b ? a : b ) +#define clipped_subtract( a, b ) ( a < b ? 0 : a - b ) #define XSTR(s) STR(s) #define STR(s) #s