"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/frontend/cmd.cc" between
gnuchess-6.2.4.tar.gz and gnuchess-6.2.5.tar.gz

About: GNU Chess is a chess-playing program.

cmd.cc  (gnuchess-6.2.4):cmd.cc  (gnuchess-6.2.5)
skipping to change at line 249 skipping to change at line 249
if ( flags & USEHASH ) { if ( flags & USEHASH ) {
printf( _("Hashing is on.\n") ); printf( _("Hashing is on.\n") );
} else { } else {
printf( _("Hashing is off.\n") ); printf( _("Hashing is off.\n") );
} }
} }
/* Give a possible move for the player to play */ /* Give a possible move for the player to play */
void cmd_hint(void) void cmd_hint(void)
{ {
/* An answer is received only if book on - TODO change this in adapter */
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
/* TODO if no hint, inform on stdout */ /* TODO if no hint, inform on stdout */
} }
void cmd_ics(void) void cmd_ics(void)
{ {
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
} }
void cmd_level(void) void cmd_level(void)
skipping to change at line 330 skipping to change at line 331
data[i+9] = '\0'; data[i+9] = '\0';
SetDataToEngine( data ); SetDataToEngine( data );
SetAutoGo( true ); SetAutoGo( true );
} }
} }
} }
} }
void cmd_manual(void) void cmd_manual(void)
{ {
SetDataToEngine( "force" );
SET (flags, MANUAL); SET (flags, MANUAL);
ExpectAnswerFromEngine( false );
SetDataToEngine( "force" );
} }
void cmd_memory(void) void cmd_memory(void)
{ {
if (token[1][0] == 0) { if (token[1][0] == 0) {
SetDataToEngine( "memory" );
ExpectAnswerFromEngine( true ); ExpectAnswerFromEngine( true );
SetDataToEngine( "memory" );
} else { } else {
unsigned int memory; unsigned int memory;
if ( sscanf( token[1], "%d", &memory ) == 1 ) { if ( sscanf( token[1], "%d", &memory ) == 1 ) {
char data[MAXSTR]=""; char data[MAXSTR]="";
sprintf( data, "memory %d\nmemory", memory ); sprintf( data, "memory %d\nmemory", memory );
SetDataToEngine( data ); SetDataToEngine( data );
} }
/* TODO Handle error */
} }
} }
/* Move now, not applicable */ /* Move now, not applicable */
void cmd_movenow(void) void cmd_movenow(void)
{ {
SetDataToEngine( "?" ); SetDataToEngine( "?" );
} }
/* /*
skipping to change at line 404 skipping to change at line 407
CLEAR (flags, MANUAL); CLEAR (flags, MANUAL);
CLEAR (flags, THINK); CLEAR (flags, THINK);
myrating = opprating = 0; myrating = opprating = 0;
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
} }
void cmd_nopost(void) void cmd_nopost(void)
{ {
CLEAR (flags, POST); CLEAR (flags, POST);
postFlag = 0; postFlag = 0;
ExpectAnswerFromEngine( false );
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
} }
void cmd_null(void) void cmd_null(void)
{ {
if (tokeneq (token[1], "off")) { if (tokeneq (token[1], "off")) {
CLEAR (flags, USENULL); CLEAR (flags, USENULL);
SetDataToEngine( "nulloff" ); SetDataToEngine( "nulloff" );
} else if (tokeneq (token[1], "on")) { } else if (tokeneq (token[1], "on")) {
SET (flags, USENULL); SET (flags, USENULL);
skipping to change at line 502 skipping to change at line 506
UnmakeMove (board.side, &Game[GameCnt].move); UnmakeMove (board.side, &Game[GameCnt].move);
} }
} }
} }
cmd_first(); cmd_first();
} }
void cmd_next(void) void cmd_next(void)
{ {
if (!pgnloaded) if (!pgnloaded) {
printf(_("Error: PGN file not loaded!\n"));
return; return;
}
if ((GameCnt+1) <= pgncnt) { if ((GameCnt+1) <= pgncnt) {
ChangeColor( true ); ChangeColor( true );
SetAutoGo( true ); SetAutoGo( true );
MakeMove (board.side, &Game[GameCnt+1].move); MakeMove (board.side, &Game[GameCnt+1].move);
} else { } else {
printf(_("No more moves. Game reached the end.\n")); printf(_("No more moves. Game reached the end.\n"));
return; return;
} }
printf("%d. ",GameCnt/2+1); printf("%d. ",GameCnt/2+1);
printf("%s\n", Game[GameCnt].SANmv); printf("%s\n", Game[GameCnt].SANmv);
ShowBoard (); ShowBoard ();
} }
void cmd_previous(void) void cmd_previous(void)
{ {
if (!pgnloaded) if (!pgnloaded) {
printf(_("Error: PGN file not loaded!\n"));
return; return;
}
if (GameCnt >= 0) { if (GameCnt >= 0) {
ChangeColor( true ); ChangeColor( true );
SetAutoGo( true ); SetAutoGo( true );
UnmakeMove (board.side, &Game[GameCnt].move); UnmakeMove (board.side, &Game[GameCnt].move);
} }
else { else {
printf(_("Initial position reached. There are no earlier moves.\n")); printf(_("Initial position reached. There are no earlier moves.\n"));
return; return;
} }
printf("%d. ",GameCnt/2+1); printf("%d. ",GameCnt/2+1);
printf("%s\n", Game[GameCnt].SANmv); printf("%s\n", Game[GameCnt].SANmv);
ShowBoard (); ShowBoard ();
} }
void cmd_last(void) void cmd_last(void)
{ {
if (!pgnloaded) if (!pgnloaded) {
printf(_("Error: PGN file not loaded!\n"));
return; return;
}
while (GameCnt+1 <= pgncnt) { while (GameCnt+1 <= pgncnt) {
ChangeColor( true ); ChangeColor( true );
SetAutoGo( true ); SetAutoGo( true );
MakeMove (board.side, &Game[GameCnt+1].move); MakeMove (board.side, &Game[GameCnt+1].move);
} }
printf("%d. ",GameCnt/2+1); printf("%d. ",GameCnt/2+1);
printf("%s\n", Game[GameCnt].SANmv); printf("%s\n", Game[GameCnt].SANmv);
ShowBoard (); ShowBoard ();
} }
void cmd_first(void) void cmd_first(void)
{ {
if (!pgnloaded) if (!pgnloaded) {
printf(_("Error: PGN file not loaded!\n"));
return; return;
}
while (GameCnt >= 0) { while (GameCnt >= 0) {
if (GameCnt >= 0) { if (GameCnt >= 0) {
CLEAR (flags, ENDED); CLEAR (flags, ENDED);
CLEAR (flags, TIMEOUT); CLEAR (flags, TIMEOUT);
ChangeColor( true ); ChangeColor( true );
SetAutoGo( true ); SetAutoGo( true );
UnmakeMove (board.side, &Game[GameCnt].move); UnmakeMove (board.side, &Game[GameCnt].move);
if (GameCnt >= 0) { if (GameCnt >= 0) {
UnmakeMove (board.side, &Game[GameCnt].move); UnmakeMove (board.side, &Game[GameCnt].move);
skipping to change at line 603 skipping to change at line 615
} }
void cmd_nographic(void) void cmd_nographic(void)
{ {
graphicmodeoutput = 0; graphicmodeoutput = 0;
printf(_("Graphic mode is disabled.\n")); printf(_("Graphic mode is disabled.\n"));
} }
void cmd_ping(void) void cmd_ping(void)
{ {
/* TODO cf. 5.08 */
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
/* If ping is received when we are on move, we are supposed to /* If ping is received when we are on move, we are supposed to
reply only after moving. In this version of GNU Chess, we reply only after moving. In this version of GNU Chess, we
never read commands while we are on move, so we don't have to never read commands while we are on move, so we don't have to
worry about that here. */ worry about that here. */
printf("pong %s\n", token[1]); printf("pong %s\n", token[1]);
fflush(stdout); fflush(stdout);
} }
void cmd_post(void) void cmd_post(void)
{ {
/* TODO State makes no sense */
SET (flags, POST); SET (flags, POST);
postFlag = 1; postFlag = 1;
if ( hardFlag && postFlag ) if ( hardFlag && postFlag )
ExpectAnswerFromEngine( true ); ExpectAnswerFromEngine( true );
ExpectAnswerFromEngine( true ); if ( flags & XBOARD )
ExpectAnswerFromEngine( true );
else
ExpectAnswerFromEngine( false );
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
} }
void cmd_protover(void) void cmd_protover(void)
{ {
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
return; return;
if (flags & XBOARD) { if (flags & XBOARD) {
/* Note: change this if "draw" command is added, etc. */ /* Note: change this if "draw" command is added, etc. */
printf("feature setboard=1 analyze=1 ping=1 draw=0 sigint=0\ printf("feature setboard=1 analyze=1 ping=1 draw=0 sigint=0\
skipping to change at line 676 skipping to change at line 693
if (!(flags & XBOARD)) if (!(flags & XBOARD))
ShowBoard (); ShowBoard ();
} }
PGNSaveToFile ("game.log",""); PGNSaveToFile ("game.log","");
} else } else
printf (_("No moves to undo!\n")); printf (_("No moves to undo!\n"));
} }
void cmd_result(void) void cmd_result(void)
{ {
/* TODO Do not send to engine */
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
if (ofp != stdout) { if (ofp != stdout) {
fprintf(ofp, "result: %s\n",token[1]); fprintf(ofp, "result: %s\n",token[1]);
fclose(ofp); fclose(ofp);
ofp = stdout; ofp = stdout;
printf(_("Save to %s\n"),gamefile); printf(_("Save to %s\n"),gamefile);
PGNSaveToFile (gamefile, token[1]); PGNSaveToFile (gamefile, token[1]);
DBUpdatePlayer (name, token[1]); DBUpdatePlayer (name, token[1]);
} }
} }
skipping to change at line 706 skipping to change at line 724
{ {
/* setboard uses FEN, not EPD, but ParseEPD will accept FEN too */ /* setboard uses FEN, not EPD, but ParseEPD will accept FEN too */
char data[MAXSTR]=""; char data[MAXSTR]="";
ParseEPD (token[1]); ParseEPD (token[1]);
NewPosition(); NewPosition();
check_board(); check_board();
snprintf(data, sizeof(data), "setboard %s", token[1]); snprintf(data, sizeof(data), "setboard %s", token[1]);
SetDataToEngine(data); SetDataToEngine(data);
} }
void cmd_solve(void) { Solve (token[1]); } void cmd_solve(void)
{
Solve (token[1]);
}
/* Set total time for move to be N seconds is "st N" */ /* Set total time for move to be N seconds is "st N" */
void cmd_st(void) void cmd_st(void)
{ {
char data[MAXSTR]=""; char data[MAXSTR]="";
/* Approximately level 1 0 N */ /* Approximately level 1 0 N */
sscanf(token[1],"%d",&TCinc); sscanf(token[1],"%d",&TCinc);
/* Allow a little fussiness for failing low etc */ /* Allow a little fussiness for failing low etc */
SearchTime = TCinc * 0.90f ; SearchTime = TCinc * 0.90f ;
sprintf( data, "st %d", atoi( token[1] ) ); sprintf( data, "st %d", atoi( token[1] ) );
SetDataToEngine( data ); SetDataToEngine( data );
} }
void cmd_switch(void) void cmd_switch(void)
{ {
printf( _("Command 'switch' is currently not supported.\n") ); printf( _("Command 'switch' is currently not supported.\n") );
} }
void cmd_time(void) void cmd_time(void)
{ {
/* TODO send what? */
SetDataToEngine( token[0] ); SetDataToEngine( token[0] );
printf( _("Old TimeLimit = %g\n"), TimeLimit[1^board.side] );
TimeLimit[1^board.side] = atoi(token[1]) / 100.0f ; TimeLimit[1^board.side] = atoi(token[1]) / 100.0f ;
printf( _("New TimeLimit = %g\n"), TimeLimit[1^board.side] );
} }
void cmd_undo(void) void cmd_undo(void)
{ {
SetDataToEngine( "force\nundo" ); SetDataToEngine( "force\nundo" );
ChangeColor( true ); ChangeColor( true );
SetAutoGo( !(flags & MANUAL) ); SetAutoGo( !(flags & MANUAL) );
if (GameCnt >= 0) if (GameCnt >= 0)
UnmakeMove (board.side, &Game[GameCnt].move); UnmakeMove (board.side, &Game[GameCnt].move);
else else
skipping to change at line 805 skipping to change at line 825
environment variable GNUCHESS_PKGDATADIR.\n\ environment variable GNUCHESS_PKGDATADIR.\n\
\n"), stdout ); \n"), stdout );
fputs( _("\ fputs( _("\
Report bugs to <bug-gnu-chess@gnu.org>.\n\ Report bugs to <bug-gnu-chess@gnu.org>.\n\
\n"), stdout ); \n"), stdout );
} }
/* Play variant, we instruct interface in protover we play normal */ /* Play variant, we instruct interface in protover we play normal */
void cmd_variant(void) {} void cmd_variant(void) {}
/* TODO Not in 5.08 */
void cmd_usermove(void) void cmd_usermove(void)
{ {
/* TODO: Remove the first SetDataToEngine */ /* TODO: Remove the first SetDataToEngine */
/*SetDataToEngine( token[0] );*/ /*SetDataToEngine( token[0] );*/
leaf *ptr; leaf *ptr;
ptr = ValidateMove (token[1]); ptr = ValidateMove (token[1]);
if (ptr != NULL) { if (ptr != NULL) {
/* Since the user entered a move: /* Since the user entered a move:
* 1. The move must be sent to the engine. * 1. The move must be sent to the engine.
* 2. A reply is expected from the engine. * 2. A reply is expected from the engine.
skipping to change at line 856 skipping to change at line 877
} }
void cmd_version(void) void cmd_version(void)
{ {
if (!(flags & XBOARD)) if (!(flags & XBOARD))
printf ("%s %s\n", PROGRAM, VERSION); printf ("%s %s\n", PROGRAM, VERSION);
else else
printf ("Chess\n"); printf ("Chess\n");
} }
void cmd_coords(void) {
printf(_("Coordinate display enabled.\n"));
coords = 1;
}
void cmd_nocoords(void) {
printf(_("Coordinate display disabled.\n"));
coords = 0;
}
void cmd_white(void) void cmd_white(void)
{ {
/* /*
* No longer used by Xboard but requested as a feature * No longer used by Xboard but requested as a feature
*/ */
printf( _("Command 'white' is currently not supported.\n") ); printf( _("Command 'white' is currently not supported.\n") );
} }
void cmd_xboard(void) void cmd_xboard(void)
{ {
skipping to change at line 888 skipping to change at line 919
* tables here * tables here
*/ */
void cmd_show (void) void cmd_show (void)
/************************************************************************ /************************************************************************
* *
* The show command driver section. * The show command driver section.
* *
************************************************************************/ ************************************************************************/
{ {
/* TODO Remove gettext support */
if (tokeneq (token[1], "board")) if (tokeneq (token[1], "board"))
ShowBoard (); ShowBoard ();
else if (tokeneq (token[1], "rating")) else if (tokeneq (token[1], "rating"))
{ {
printf(_("My rating = %d\n"),myrating); printf(_("My rating = %d\n"),myrating);
printf(_("Opponent rating = %d\n"),opprating); printf(_("Opponent rating = %d\n"),opprating);
} }
else if (tokeneq (token[1], _("time"))) else if (tokeneq (token[1], _("time")))
ShowTime (); ShowTime ();
else if (tokeneq (token[1], _("moves"))) { else if (tokeneq (token[1], _("moves"))) {
skipping to change at line 1093 skipping to change at line 1125
gettext_noop(" movegenspeed - tests speed of move generator"), gettext_noop(" movegenspeed - tests speed of move generator"),
gettext_noop(" capturespeed - tests speed of capture move generator"), gettext_noop(" capturespeed - tests speed of capture move generator"),
gettext_noop(" eval - reads in an epd file and shows evaluation for its entri es"), gettext_noop(" eval - reads in an epd file and shows evaluation for its entri es"),
gettext_noop(" evalspeed - tests speed of the evaluator"), gettext_noop(" evalspeed - tests speed of the evaluator"),
"bk", "bk",
gettext_noop(" Shows moves from opening book."), gettext_noop(" Shows moves from opening book."),
"graphic", "graphic",
gettext_noop(" Enables display board in graphic mode."), gettext_noop(" Enables display board in graphic mode."),
"nographic", "nographic",
gettext_noop(" Disables graphic mode and display classical view."), gettext_noop(" Disables graphic mode and display classical view."),
"coords",
gettext_noop(" Displays the chessboard rank and file in both graphic and clas
sical views."),
"nocoords",
gettext_noop(" Does not display the chessboard rank nor file in either mode (
graphic nor classical)"),
NULL, NULL,
NULL NULL
}; };
void cmd_help (void) void cmd_help (void)
/************************************************************************** /**************************************************************************
* *
* Display all the help commands. * Display all the help commands.
* *
**************************************************************************/ **************************************************************************/
skipping to change at line 1215 skipping to change at line 1251
{ "switch", cmd_switch }, { "switch", cmd_switch },
{ "test", cmd_test }, { "test", cmd_test },
{ "time", cmd_time }, { "time", cmd_time },
{ "undo", cmd_undo }, { "undo", cmd_undo },
{ "usage", cmd_usage }, { "usage", cmd_usage },
{ "usermove", cmd_usermove }, { "usermove", cmd_usermove },
{ "variant", cmd_variant }, { "variant", cmd_variant },
{ "version", cmd_version }, { "version", cmd_version },
{ "white", cmd_white }, { "white", cmd_white },
{ "xboard", cmd_xboard }, { "xboard", cmd_xboard },
{ "coords", cmd_coords},
{ "nocoords", cmd_nocoords},
{ NULL, NULL } { NULL, NULL }
}; };
void parse_input(void) void parse_input(void)
/************************************************************************* /*************************************************************************
* *
* This is the main user command interface driver. * This is the main user command interface driver.
* *
*************************************************************************/ *************************************************************************/
{ {
 End of changes. 28 change blocks. 
10 lines changed or deleted 50 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)