]> git.sesse.net Git - pgn-extract/blobdiff - output.c
Push through a computer/human flag to the binary output.
[pgn-extract] / output.c
index 9c57e3195f1678ddf9db3e5f3421cd19b26c6597..a403488375b878a2035259267c2df9dd1dbfd41e 100644 (file)
--- a/output.c
+++ b/output.c
@@ -1180,6 +1180,10 @@ output_sesse_bin_game(Game current_game,FILE *outputfile,
 
     // Find the result. Skip games with no result.
     for (move = current_game.moves; move != NULL; move = move->next) {
+        if (move->class == NULL_MOVE) {
+            // Skip games with null moves.
+            return;
+        }
         if (move->terminating_result) {
             result = move->terminating_result;
         }
@@ -1212,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];
@@ -1254,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);
 
@@ -1278,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);