Add -colorNickNames option
authorH.G. Muller <h.g.muller@hccnet.nl>
Sat, 7 Aug 2010 14:53:50 +0000 (16:53 +0200)
committerArun Persaud <arun@nubati.net>
Sat, 14 Aug 2010 17:14:52 +0000 (10:14 -0700)
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
backend.c
common.h

diff --git a/args.h b/args.h
index e897749..d59f26c 100644 (file)
--- 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 },
index d4549bf..d05c721 100644 (file)
--- 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;
index d5e23ee..996badf 100644 (file)
--- 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;