]> git.sesse.net Git - pgn-extract/commitdiff
Push through a computer/human flag to the binary output. master
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 19 Dec 2014 23:16:27 +0000 (00:16 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 19 Dec 2014 23:16:27 +0000 (00:16 +0100)
argsfile.c
main.c
output.c
typedef.h

index 62146f69707006fbf1f2c5b5ad9914d94d5cf23c..067a479eae7077c1ebef97a7a8f019294c16679e 100644 (file)
@@ -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 eb25da5abcc7d48eda11d48125c676d025ee78cb..0a83cbcf5f083beddd0bc4d971930fa941b550d4 100644 (file)
--- 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) */
index 7a1b325adfdb7c0b85f61e0537252751262e667b..a403488375b878a2035259267c2df9dd1dbfd41e 100644 (file)
--- 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(&timestamp, 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(&timestamp, 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);
index ed7a82d47302524ba8cec3bb375d53be5de20cf3..93978bdb5bd11dab4e3b1698dab334ab41dac9de 100644 (file)
--- 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. */