From 72a56a15d7df2a6faa5ced6a4707564b2c14a48f Mon Sep 17 00:00:00 2001 From: AnnaSnoeijs Date: Thu, 14 Aug 2025 20:21:06 +0200 Subject: [PATCH] Made maximum rows more limited to avoid bugs --- connect4.c | 4 ++-- types.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/connect4.c b/connect4.c index b054145..91710c8 100644 --- a/connect4.c +++ b/connect4.c @@ -114,7 +114,7 @@ int main( int argc, char *argv[] ){ "\n" " -o file --output file Ouput moves taken in game to file\n" "\n" -" --slow-calcwins Use the 32bit reference implementation of calcWins()\n" +" --slow-calcwins Use the reference implementation of calcWins()\n" " --random-moves Play random moves instead of asking for input\n" ); return 0; @@ -150,7 +150,7 @@ int main( int argc, char *argv[] ){ fprintf( stderr, "ERR: AMOUT OF ROWS MUST BE AT LEAST 1\n" ); return -1; } -#define ROWOVERFLOW (rowsint_t)( sizeof(column_t) * CHAR_BIT ) +#define ROWOVERFLOW (rowsint_t)( sizeof(column_t) * CHAR_BIT - 1 ) if( playboard.rows >= ROWOVERFLOW ){ fprintf( stderr, "ERR: AMOUT OF ROWS MUST BE LESS THAN %d\n", ROWOVERFLOW diff --git a/types.h b/types.h index 028565d..9590065 100644 --- a/types.h +++ b/types.h @@ -5,13 +5,13 @@ #include #include "config.h" -// Use fastest available ints unless it's 64 bits because that uses more memory +// Use fastest available ints unless it's 64 bits because that is doing silly #if INT_FAST16_MAX == INT_FAST64_MAX -typedef int rowsint_t; -typedef unsigned columnsint_t; +typedef int rowsint_t; +typedef unsigned columnsint_t; #define QUITCOLUMN UINT_MAX -typedef unsigned winint_t; -typedef uintmax_t column_t; +typedef unsigned winint_t; +typedef unsigned column_t; #else typedef int_fast8_t rowsint_t; typedef uint_fast8_t columnsint_t;