From 4e3856498daad97f417e7141e6e38afee6d8254b Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 7 Aug 2010 16:53:50 +0200 Subject: [PATCH] Add -colorNickNames option This option allows non-standard designation of side to move in FENs. (Useful for Xiangqi, where white is indicated often as r(ed), and Shogi, where white is s(ente) or b(lack), and black is g(ote) or w(hite).) Can also be used for FENs in a local language. A match of theinput character with the nick name translates it to the standard; this means the standard will continue to be recognized, unless it was defined as a nick name. --- args.h | 1 + backend.c | 9 +++++++-- common.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/args.h b/args.h index e897749..d59f26c 100644 --- a/args.h +++ b/args.h @@ -555,6 +555,7 @@ ArgDescriptor argDescriptors[] = { { "matchPause", ArgInt, (void *) &appData.matchPause, TRUE, (ArgIniType) 10000 }, { "pieceToCharTable", ArgString, (void *) &appData.pieceToCharTable, FALSE, INVALID }, { "pieceNickNames", ArgString, (void *) &appData.pieceNickNames, FALSE, INVALID }, + { "colorNickNames", ArgString, (void *) &appData.colorNickNames, FALSE, INVALID }, { "flipBlack", ArgBoolean, (void *) &appData.upsideDown, TRUE, (ArgIniType) FALSE }, { "allWhite", ArgBoolean, (void *) &appData.allWhite, TRUE, (ArgIniType) FALSE }, { "alphaRank", ArgBoolean, (void *) &appData.alphaRank, FALSE, (ArgIniType) FALSE }, diff --git a/backend.c b/backend.c index d4549bf..d05c721 100644 --- a/backend.c +++ b/backend.c @@ -14762,7 +14762,7 @@ ParseFEN(board, blackPlaysFirst, fen) char *fen; { int i, j; - char *p; + char *p, c; int emptycount; ChessSquare piece; @@ -14855,7 +14855,12 @@ ParseFEN(board, blackPlaysFirst, fen) while(*p == ' ') p++; /* Active color */ - switch (*p++) { + c = *p++; + if(appData.colorNickNames) { + if( c == appData.colorNickNames[0] ) c = 'w'; else + if( c == appData.colorNickNames[1] ) c = 'b'; + } + switch (c) { case 'w': *blackPlaysFirst = FALSE; break; diff --git a/common.h b/common.h index d5e23ee..996badf 100644 --- a/common.h +++ b/common.h @@ -583,6 +583,7 @@ typedef struct { int matchPause; char * pieceToCharTable; char * pieceNickNames; + char * colorNickNames; Boolean allWhite; Boolean upsideDown; Boolean alphaRank; -- 1.7.0.4