X-Git-Url: http://winboard.nl/cgi-bin?p=capablanca.git;a=blobdiff_plain;f=lasker-2.2.3%2Fsrc%2Fsetup.c;h=eb37655846ae485659d057325fbbb239e33a7833;hp=4138c638f37292d612f88bd249b97986e6914b59;hb=fc8a38817986f2ad7a034db0d413762e509a7cac;hpb=76f1e81b3426b94e1d80c9daa309f78045e5335b diff --git a/lasker-2.2.3/src/setup.c b/lasker-2.2.3/src/setup.c index 4138c63..eb37655 100644 --- a/lasker-2.2.3/src/setup.c +++ b/lasker-2.2.3/src/setup.c @@ -45,8 +45,8 @@ static int validate_position (int p,struct game_state_t *b) int white_k = 0; int black_k = 0; - for (f = 0; (f < 8); f++) { - for (r = 0; (r < 8); r++) { + for (f = 0; (f < b->files); f++) { + for (r = 0; (r < b->ranks); r++) { if (b->board[f][r] == W_KING) { white_k += 1; if (white_k == 2) { @@ -62,7 +62,7 @@ static int validate_position (int p,struct game_state_t *b) } } if (((b->board[f][r] == W_PAWN) || (b->board[f][r] == B_PAWN)) && - ((r == 0) || (r == 7))) { + ((r == 0) || (r == b->ranks-1))) { pprintf (p,"Pawns cannot be placed on the first or eighth rank.\n"); return 0; } @@ -151,17 +151,23 @@ int com_setup (int p,param_list param) pprintf(p,"The position is not valid - staying in setup mode.\n"); return COM_OK; } else { /* try to load a category of board */ - if (param[1].type != TYPE_NULL) { - if (!board_init (pp->game,&(game_globals.garray[pp->game].game_state),param[0].val.word,param[1].val.word)) { + char *board = param[1].val.word; + if (param[1].type == TYPE_NULL) board = "0"; + game_globals.garray[pp->game].FENstartPos[0] = 0; // [HGM] new shuffle + if (!board_init (pp->game,&(game_globals.garray[pp->game].game_state),param[0].val.word,board)) { game_globals.garray[pp->game].game_state.gameNum = gamenum; + if(!strcmp(board,"0")) + sprintf(game_globals.garray[pp->game].variant, "%s",param[0].val.word); + else + sprintf(game_globals.garray[pp->game].variant, "%s/%s",param[0].val.word,board); send_board_to(pp->game, p); - pprintf (p,"Board set up as %s %s.\n",param[0].val.word,param[1].val.word); + pprintf (p,"Board set up as %s %s.\n",param[0].val.word,board); } else { - pprintf (p,"Board %s %s is unavailable.\n",param[0].val.word,param[1].val.word); + pprintf (p,"Board %s %s is unavailable.\n",param[0].val.word,board); game_globals.garray[pp->game].game_state.gameNum = gamenum; } return COM_OK; - } + } } pprintf (p, "You have supplied an incorrect parameter to setup.\n"); @@ -302,7 +308,7 @@ int attempt_drop(int p,int g,char* dropstr) /*check wp@e3 */ } else if (dropstr[0] == 'w') { - piece = CharToPiece(dropstr[1]) & 0x07; + piece = CharToPiece(dropstr[1], game_globals.garray[g].game_state.variant) & 0x7F; color = WHITE; getsquare(dropstr+3,&f,&r); @@ -310,7 +316,7 @@ int attempt_drop(int p,int g,char* dropstr) } else if (len == 5) { /* check length to avoid b@e2 and bb@e2 being confused */ if (dropstr[0] == 'b') { - piece = CharToPiece(dropstr[1]) | BLACK; + piece = CharToPiece(dropstr[1], game_globals.garray[g].game_state.variant) | BLACK; getsquare(dropstr+3,&f,&r); } @@ -320,7 +326,7 @@ int attempt_drop(int p,int g,char* dropstr) if (!((dropstr[1] == '@') || (dropstr[1] == '*'))) return 0; else { - piece = CharToPiece(dropstr[0]); + piece = CharToPiece(dropstr[0], game_globals.garray[g].game_state.variant); getsquare(dropstr+2,&f,&r); } }