From 0d25f49537f68e4764c94eaf92d235e205ff5b45 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 20 Dec 2014 00:16:27 +0100 Subject: [PATCH] Push through a computer/human flag to the binary output. --- argsfile.c | 4 ++++ main.c | 1 + output.c | 3 +++ typedef.h | 3 +++ 4 files changed, 11 insertions(+) diff --git a/argsfile.c b/argsfile.c index 62146f6..067a479 100644 --- a/argsfile.c +++ b/argsfile.c @@ -1090,6 +1090,10 @@ process_long_form_argument(const char *argument, const char *associated_value) GlobalState.start_file_number = atoi(associated_value); return 2; } + else if(stringcompare(argument, "computerflag") == 0) { + GlobalState.computer_flag = atoi(associated_value); + return 2; + } else if(stringcompare(argument, "version") == 0) { fprintf(GlobalState.logfile, "pgn-extract %s\n", CURRENT_VERSION); exit(0); diff --git a/main.c b/main.c index eb25da5..0a83cbc 100644 --- a/main.c +++ b/main.c @@ -111,6 +111,7 @@ StateInfo GlobalState = { 0, /* start_file_number */ 0, /* start_position */ LONG_MAX, /* end_position */ + 0, /* computer_flag */ DEFAULT_ECO_FILE, /* eco_file (-e) */ (FILE *)NULL, /* outputfile (-o, -a). Default is stdout */ (char *)NULL, /* output_filename (-o, -a) */ diff --git a/output.c b/output.c index 7a1b325..a403488 100644 --- a/output.c +++ b/output.c @@ -1216,6 +1216,7 @@ output_sesse_bin_game(Game current_game,FILE *outputfile, } int file_num = current_game.file_number; long start_position = current_game.start_position; + int computer_flag = GlobalState.computer_flag; // Parse date and time, if it exists. Set invalid dates to year 3000. const char *date_tag = current_game.tags[DATE_TAG]; @@ -1258,6 +1259,7 @@ output_sesse_bin_game(Game current_game,FILE *outputfile, fwrite(×tamp, sizeof(timestamp), 1, outputfile); fwrite(&file_num, sizeof(file_num), 1, outputfile); fwrite(&start_position, sizeof(start_position), 1, outputfile); + putc(computer_flag, outputfile); putc(strlen((char *)move->move), outputfile); fwrite(move->move, strlen((char *)move->move), 1, outputfile); @@ -1282,6 +1284,7 @@ output_sesse_bin_game(Game current_game,FILE *outputfile, fwrite(×tamp, sizeof(timestamp), 1, outputfile); fwrite(&file_num, sizeof(file_num), 1, outputfile); fwrite(&start_position, sizeof(start_position), 1, outputfile); + putc(computer_flag, outputfile); putc(0, outputfile); // No move. free(bpfen); diff --git a/typedef.h b/typedef.h index ed7a82d..93978bd 100644 --- a/typedef.h +++ b/typedef.h @@ -290,6 +290,9 @@ typedef struct { */ long start_position; long end_position; + /* Whether the games are assumed played by computers. + * Passed through verbatim to the binary format. */ + int computer_flag; /* File of ECO lines. */ const char *eco_file; /* Where to write the extracted games. */ -- 2.39.2