Check-in modifications made by HGM so far
[capablanca.git] / lasker-2.2.3 / src / matchproc.c
index 35f1937..020be38 100644 (file)
@@ -23,7 +23,7 @@
 #include "includes.h"
 
 const char *colorstr[] = {"", "[black] ", "[white] "};
-static const char *adjustr[] = {"", " (adjourned)"};
+const char *adjustr[] = {"", " (adjourned)"};
 
 static void prepare_match(int g,int wt,int bt,int winc,int binc,int wp, int bp,int rated)
 {
@@ -156,7 +156,8 @@ static void output_match_messages(int wp,int bp,int g, char* mess)
           player_globals.parray[bp].name,
           game_globals.garray[g].black_rating,
           rstr[game_globals.garray[g].rated],
-          bstr[game_globals.garray[g].type],
+          //bstr[game_globals.garray[g].type],
+          game_globals.garray[g].variant,
           game_globals.garray[g].wInitTime, 
           game_globals.garray[g].wIncrement);
   pprintf(wp, "%s", outStr);
@@ -168,7 +169,8 @@ static void output_match_messages(int wp,int bp,int g, char* mess)
           player_globals.parray[bp].name,
          mess,
           rstr[game_globals.garray[g].rated],
-          bstr[game_globals.garray[g].type]);
+          //bstr[game_globals.garray[g].type]);
+         game_globals.garray[g].variant);
   pprintf(wp, "%s", outStr);
   pprintf(bp, "%s", outStr);
 
@@ -265,6 +267,7 @@ int create_new_match(int g, int white_player, int black_player,
     decline_withdraw_offers(white_player, -1, PEND_SIMUL,
                             DO_WITHDRAW | DO_DECLINE);
   }
+  game_globals.garray[g].FENstartPos[0] = 0; // [HGM] new shuffle
   if (board_init(g,&game_globals.garray[g].game_state, category, board)) {
     pprintf(white_player, "PROBLEM LOADING BOARD. Game Aborted.\n");
     pprintf(black_player, "PROBLEM LOADING BOARD. Game Aborted.\n");
@@ -279,6 +282,15 @@ int create_new_match(int g, int white_player, int black_player,
   else
     game_globals.garray[g].type = game_isblitz(wt, winc, bt, binc, category, board);
 
+  if(category && category[0]) { // [HGM] set variant string from directory for games loaded from file
+    if(!strcmp(category, "wild") && board)
+       sprintf(game_globals.garray[g].variant, "%s/%s", category, board);
+    else
+       strcpy(game_globals.garray[g].variant, category);
+  }
+  else
+    strcpy(game_globals.garray[g].variant, bstr[game_globals.garray[g].type]);
+
   prepare_match(g,wt,bt,winc,binc,white_player,black_player,rated);
 
   output_match_messages(white_player,black_player,g, "Creating");
@@ -490,10 +502,47 @@ static int parse_match_string(int p, int* wt,int* bt,int* winc,int* binc,
       } else {
         strcpy(category,parsebuf);
         if (!strncmp("bughouse",category, strlen(category))
-            && strlen(category) >= 3) {
+            && strlen(category) >= 3 || !strcmp("bh", category)) {
           strcpy(category, "bughouse");
           bughouse = 1;
         }
+       // [HGM] allow some shortcuts for variant names
+       if(!strcmp("bh", category)) {
+         strcpy(category, "bughouse");
+       } else
+       if(!strcmp("zh", category)) {
+         strcpy(category, "crazyhouse");
+       } else
+       if(!strcmp("fr", category)) {
+         strcpy(category, "fischerandom");
+       } else
+       if(!strcmp("sj", category)) {
+         strcpy(category, "shatranj");
+       } else
+       if(!strcmp("gc", category)) {
+         strcpy(category, "gothic");
+       } else
+       if(!strcmp("ca", category)) {
+         strcpy(category, "capablanca");
+       } else
+       if(!strcmp("cr", category)) {
+         strcpy(category, "caparandom");
+       } else
+       if(!strcmp("su", category)) {
+         strcpy(category, "super");
+       } else
+       if(!strcmp("sg", category)) {
+         strcpy(category, "shogi");
+       } else
+       if(!strcmp("km", category)) {
+         strcpy(category, "knightmate");
+       } else
+       if(!strcmp("gr", category)) {
+         strcpy(category, "great");
+       } else
+       if(!strcmp("xq", category)) {
+         strcpy(category, "xiangqi");
+       }
       }
     } else
       confused = 1;
@@ -503,6 +552,8 @@ static int parse_match_string(int p, int* wt,int* bt,int* winc,int* binc,
     pprintf(p, "Can't interpret %s in match command.\n", parsebuf);
     return 0;
   }
+  if(category && (!board || !board[0]))
+       strcpy(board, "0"); // [HGM] variants: always provide default board
   return 1;
 }