diff --git a/connect4.c b/connect4.c index 818ee72..38c3269 100644 --- a/connect4.c +++ b/connect4.c @@ -20,9 +20,7 @@ #include #include #include -#ifndef NO_OPTIONS #include -#endif /* ! NO_OPTIONS */ #include #include "macros.h" #include "config.h" @@ -41,14 +39,12 @@ #define VERSIONSTRING \ "AnnaConnect version "XSTR(FULLVERSION)", Copyright (C) Anna Snoeijs\n" -#ifndef NO_OPTIONS // The LISENCE file // Not null-terminated so need pointers for both start and end extern char _binary_LICENSE_start[]; extern char _binary_LICENSE_end[]; -#endif /* ! NO_OPTIONS */ -int main( [[maybe_unused]] int argc, [[maybe_unused]] char *argv[] ){ +int main( int argc, char *argv[] ){ // Initialise variables board_t playboard = { .player = 0, @@ -57,10 +53,9 @@ int main( [[maybe_unused]] int argc, [[maybe_unused]] char *argv[] ){ .count0 = {0}, .count1 = {0}, }; - wins_t *wins = malloc( sizeof(wins_t) ); -#ifndef NO_OPTIONS FILE *outputfile = NULL; char *filename = NULL; + wins_t *wins = malloc( sizeof(wins_t) ); bool randomMoves = 0; // Parse options for(;;){ @@ -163,18 +158,12 @@ int main( [[maybe_unused]] int argc, [[maybe_unused]] char *argv[] ){ return -1; } #undef ROWOVERFLOW -#endif /* ! NO_OPTIONS */ // Start the actual program printf( VERSIONSTRING "AnnaConnect comes with ABSOLUTELY NO WARRANTY\n" "This is free software, and you are welcome to redistribute it\n" - "under certain condtions." -#ifndef NO_OPTIONS - " See `%s --license`\n", argv[0] -#else /* NO_OPTIONS */ - "\n" -#endif /* NO_OPTIONS */ + "under certain condtions. See `%s --license`\n", argv[0] ); // board, innit? // Allocate the board @@ -196,10 +185,11 @@ int main( [[maybe_unused]] int argc, [[maybe_unused]] char *argv[] ){ wins->same.horizontal4 = calloc( playboard.columns, sizeof(column_t) ); wins->same.diagonalUp4 = calloc( playboard.columns, sizeof(column_t) ); wins->same.diagonalDown4 = calloc( playboard.columns, sizeof(column_t) ); + goto init_ui; } + init_ui: initBoard( playboard ); // Begin loopin -#ifndef NO_OPTIONS if( outputfile != NULL ){ fprintf( outputfile, @@ -213,29 +203,21 @@ int main( [[maybe_unused]] int argc, [[maybe_unused]] char *argv[] ){ playboard.columns ); } -#endif /* ! NO_OPTIONS */ for(;; playboard.player = !playboard.player ){ columnsint_t column; -#ifndef NO_OPTIONS if( randomMoves ){ column = randomColumn( playboard ); }else{ column = askColumn( playboard ); }; -#else /* NO_OPTIONS */ - column = askColumn( playboard ); -#endif /* NO_OPTIONS */ if( column == QUITCOLUMN ) break; playMove( &playboard, column ); calcWins( wins, &playboard, column ); updateBoard( playboard, column ); -#ifndef NO_OPTIONS if( outputfile != NULL ){ fprintf( outputfile, "%d\n", column ); } -#endif /* ! NO_OPTIONS */ } -#ifndef NO_OPTIONS if( outputfile != NULL ){ fprintf( outputfile, "# Wins\n" @@ -255,6 +237,5 @@ int main( [[maybe_unused]] int argc, [[maybe_unused]] char *argv[] ){ fclose( outputfile ); printf( "Output is written to %s\n", filename ); } -#endif /* ! NO_OPTIONS */ exit_ui(); } diff --git a/makefile b/makefile index dd57147..e0366af 100644 --- a/makefile +++ b/makefile @@ -28,11 +28,6 @@ FLAGS += -flto #FLAGS += -Wno-sign-conversion #FLAGS += -Wformat-truncation=0 -ifneq (, $(EXTRA_FLAGS)) - FLAGS += $(EXTRA_FLAGS) -endif - - # Compile flag for defining GITHASH to put at the end of the version string GITFLAG = -D'GITHASH=$(shell git rev-parse --short=1 HEAD)'