]> git.sesse.net Git - pgn-extract/commitdiff
Store opening choices for each move.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 10 Dec 2014 23:19:43 +0000 (00:19 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 12 Dec 2014 21:56:56 +0000 (22:56 +0100)
apply.c
output.c
typedef.h

diff --git a/apply.c b/apply.c
index bd7b4721e2467974ad26db29c97a05f2e0d31d9b..c58e16dc6af8ca3ac8216998ffbff523fcf999f9 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -903,6 +903,7 @@ play_moves(Game *game_details, Board *board, Move *moves, unsigned max_depth,
                               eco_match = entry;
                           }
                       }
+                      next_move->eco = eco_match;
                   }
                   next_move = next_move->next;
                }
index 6e47275ca8842e32106a35d3b0117d95230c6975..297cf8b37b3e107e6922cf1256b296c51e390893 100644 (file)
--- a/output.c
+++ b/output.c
@@ -34,6 +34,7 @@
 #include "apply.h"
 #include "output.h"
 #include "mymalloc.h"
+#include "eco.h"
 
 
             /* Functions for outputting games in the required format. */
@@ -1205,7 +1206,7 @@ output_sesse_bin_game(Game current_game,FILE *outputfile,
     int black_elo = atoi(black_elo_tag);
 
     for (move = current_game.moves; move != NULL; move = move->next) {
-        unsigned int opening = 0;  // TODO
+        unsigned int opening = move->eco ? move->eco->cumulative_hash_value : 0;
 
         // key
         putc(move->bpfen_len + strlen((char *)move->move), outputfile);
index f405a63f2c04d9736004f2ebcd583af85b3bf499..df0d81dfd18ad60314e54995b403dcff0f8b17e2 100644 (file)
--- a/typedef.h
+++ b/typedef.h
@@ -70,6 +70,9 @@ typedef struct variation{
  */
 #define MAX_MOVE_LEN 15
 
+struct EcoLog;
+typedef struct EcoLog EcoLog;
+
         /* Retain the text of a move and any associated 
          * NAGs and comments.
          */
@@ -106,6 +109,7 @@ typedef struct move{
     /* terminating_result hold the result of the current list of moves. */
     char *terminating_result;
     Variation *Variants;
+    EcoLog *eco;
     /* Pointers to the previous and next move.
      * The extraction program does not need the prev field, but my
      * intention is to build other interfaces that might need it.