From ba3e6a6301920d112fde459b61a5a5206565dcbd Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Wed, 15 Oct 2014 21:50:44 +0200 Subject: [PATCH] Implement displaying of variant tag in Game List The variant tag was displayed as an empty string in game-header lines. Processing it during PGN load was not able to handle engine-defined variants anyway; they were recognized as 'normal'. A new field in the GameInfo struct now holds variantName in text form, and this is the primary place from which it is displayed in the Game List. --- common.h | 1 + gamelist.c | 6 ++++++ pgntags.c | 2 +- 3 files changed, 8 insertions(+), 1 deletions(-) diff --git a/common.h b/common.h index cb1278f..9f54f47 100644 --- a/common.h +++ b/common.h @@ -838,6 +838,7 @@ typedef struct { int whiteRating; /* -1 if unknown */ int blackRating; /* -1 if unknown */ VariantClass variant; + char *variantName; char *outOfBook; /* [AS] Move and score when engine went out of book */ int boardWidth; /* [HGM] adjustable board size */ int boardHeight; diff --git a/gamelist.c b/gamelist.c index 2055e96..a6c688c 100644 --- a/gamelist.c +++ b/gamelist.c @@ -180,6 +180,7 @@ GameListInitGameInfo (GameInfo *gameInfo) gameInfo->whiteRating = -1; /* unknown */ gameInfo->blackRating = -1; /* unknown */ gameInfo->variant = VariantNormal; + gameInfo->variantName = NULL; gameInfo->outOfBook = NULL; gameInfo->resultDetails = NULL; } @@ -437,6 +438,9 @@ ClearGameInfo (GameInfo *gameInfo) if (gameInfo->extraTags != NULL) { free(gameInfo->extraTags); } + if (gameInfo->variantName != NULL) { + free(gameInfo->variantName); + } if (gameInfo->outOfBook != NULL) { free(gameInfo->outOfBook); } @@ -513,6 +517,8 @@ GameListLine (int number, GameInfo * gameInfo) strncpy( buf, gameInfo->timeControl ? gameInfo->timeControl : "?", MAX_FIELD_LEN ); break; case GLT_VARIANT: + strncpy( buf, gameInfo->variantName ? gameInfo->variantName : VariantName(gameInfo->variant), MAX_FIELD_LEN ); +// strncpy( buf, VariantName(gameInfo->variant), MAX_FIELD_LEN ); break; case GLT_OUT_OF_BOOK: strncpy( buf, gameInfo->outOfBook ? gameInfo->outOfBook : "?", MAX_FIELD_LEN ); diff --git a/pgntags.c b/pgntags.c index 2d9cfb8..f13eb96 100644 --- a/pgntags.c +++ b/pgntags.c @@ -114,8 +114,8 @@ ParsePGNTag (char *tag, GameInfo *gameInfo) success = TRUE; } else if (StrCaseCmp(name, "Variant") == 0) { /* xboard-defined extension */ + success = StrSavePtr(value, &gameInfo->variantName) != NULL; gameInfo->variant = StringToVariant(value); - success = TRUE; } else if (StrCaseCmp(name, "VariantMen") == 0) { /* for now ignore this tag, as we have no method yet */ /* for assigning the pieces to XBoard pictograms */ -- 1.7.0.4