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) {
}
}
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;
}
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");
/*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);
} 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);
}
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);
}
}