]> git.sesse.net Git - remoteglot-book/blobdiff - binmerger.cpp
Parse timestamps from the binary format. Needs some rework, though.
[remoteglot-book] / binmerger.cpp
index 612a19b123dd9100056468776eb42436ca18a071..620ef0afe5a25d1a55967de95c484f0e35925565 100644 (file)
@@ -25,10 +25,16 @@ void merge_count(void* userdata,
        c->white = c0->white + c1->white;
        c->draw = c0->draw + c1->draw;
        c->black = c0->black + c1->black;
-       c->opening_num = c0->opening_num;  // Arbitrary choice.
        c->sum_white_elo = c0->sum_white_elo + c1->sum_white_elo;
        c->sum_black_elo = c0->sum_black_elo + c1->sum_black_elo;
        c->num_elo = c0->num_elo + c1->num_elo;
+       if (c0->first_timestamp <= c1->first_timestamp) {
+               c->opening_num = c0->opening_num;
+               c->first_timestamp = c0->first_timestamp;
+       } else {
+               c->opening_num = c1->opening_num;
+               c->first_timestamp = c1->first_timestamp;
+       }
 
        *merged_val = reinterpret_cast<uint8_t *>(c.release());
        *len_merged_val = sizeof(Count);