X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=1f424e3ea2803c3a34051250ab9d012da86203fa;hb=76d2f540a0bc0a54bbb2aba5e29d5412e7f2191c;hp=a17d11dd03040a66c664f1d29d149f5373e27218;hpb=18c97517acda747ffe9d9177c61c9bf5b1195bb6;p=xboard.git diff --git a/backend.c b/backend.c index a17d11d..1f424e3 100644 --- a/backend.c +++ b/backend.c @@ -77,6 +77,7 @@ #if STDC_HEADERS # include # include +# include #else /* not STDC_HEADERS */ # if HAVE_STRING_H # include @@ -147,6 +148,7 @@ void read_from_player P((InputSourceRef isr, VOIDSTAR closure, char *buf, int count, int error)); void read_from_ics P((InputSourceRef isr, VOIDSTAR closure, char *buf, int count, int error)); +void ics_printf P((char *format, ...)); void SendToICS P((char *s)); void SendToICSDelayed P((char *s, long msdelay)); void SendMoveToICS P((ChessMove moveType, int fromX, int fromY, @@ -229,6 +231,7 @@ char *GetInfoFromComment( int, char * ); // [HGM] PV time: returns stripped comm void InitEngineUCI( const char * iniDir, ChessProgramState * cps ); // [HGM] moved here from winboard.c char *ProbeBook P((int moveNr, char *book)); // [HGM] book: returns a book move char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [HGM] book +void ics_update_width P((int new_width)); extern char installDir[MSG_SIZ]; extern int tinyLayout, smallLayout; @@ -1418,6 +1421,19 @@ KeepAlive() if(appData.keepAlive) ScheduleDelayedEvent(KeepAlive, appData.keepAlive*60*1000); } +/* added routine for printf style output to ics */ +void ics_printf(char *format, ...) +{ + char buffer[MSG_SIZ]; + va_list args; + + va_start(args, format); + vsnprintf(buffer, sizeof(buffer), format, args); + buffer[sizeof(buffer)-1] = '\0'; + SendToICS(buffer); + va_end(args); +} + void SendToICS(s) char *s; @@ -1536,6 +1552,10 @@ StringToVariant(e) while( *e++ != '_'); } + if(StrCaseStr(e, "misc/")) { // [HGM] on FICS, misc/shogi is not shogi + v = VariantNormal; + found = TRUE; + } else for (i=0; i= 5 && buf[buf_len-5]=='\n' && buf[buf_len-4]=='\\' && + if(!appData.noJoin && buf_len >= 5 && buf[buf_len-5]=='\n' && buf[buf_len-4]=='\\' && buf[buf_len-3]==' ' && buf[buf_len-2]==' ' && buf[buf_len-1]==' ') { buf_len -= 5; // [HGM] ICS: join continuation line of Lasker 2.2.3 server with previous if(buf_len == 0 || buf[buf_len-1] != ' ') @@ -2201,7 +2221,8 @@ read_from_ics(isr, closure, data, count, error) sprintf(str, "/set-quietly interface %s\n/set-quietly style 12\n", programVersion); - + if (!appData.noJoin) + strcat(str, "/set-quietly wrap 0\n"); } else if (ics_type == ICS_CHESSNET) { sprintf(str, "/style 12\n"); } else { @@ -2211,9 +2232,12 @@ read_from_ics(isr, closure, data, count, error) #ifdef WIN32 strcat(str, "$iset nohighlight 1\n"); #endif + if (!appData.noJoin) + strcat(str, "$iset nowrap 1\n"); strcat(str, "$iset lock 1\n$style 12\n"); } SendToICS(str); + NotifyFrontendLogin(); intfSet = TRUE; } @@ -3930,6 +3954,12 @@ AnalysisPeriodicEvent(force) programStats.ok_to_send = 0; } +void ics_update_width(new_width) + int new_width; +{ + ics_printf("set width %d\n", new_width); +} + void SendMoveToProgram(moveNum, cps) int moveNum; @@ -5871,16 +5901,16 @@ if(appData.debugMode) fprintf(debugFP, "nodes = %d, %lld\n", (int) programStats. } else moveCount = 6; } } -#if 1 - if (appData.debugMode) { int i; - fprintf(debugFP, "repeat test fmm=%d bmm=%d ep=%d, reps=%d\n", - forwardMostMove, backwardMostMove, epStatus[backwardMostMove], - appData.drawRepeats); - for( i=forwardMostMove; i>=backwardMostMove; i-- ) - fprintf(debugFP, "%d ep=%d\n", i, epStatus[i]); + + if (appData.debugMode) { int i; + fprintf(debugFP, "repeat test fmm=%d bmm=%d ep=%d, reps=%d\n", + forwardMostMove, backwardMostMove, epStatus[backwardMostMove], + appData.drawRepeats); + for( i=forwardMostMove; i>=backwardMostMove; i-- ) + fprintf(debugFP, "%d ep=%d\n", i, epStatus[i]); + + } - } -#endif /* Check for rep-draws */ count = 0; for(k = forwardMostMove-2; @@ -9569,7 +9599,7 @@ SaveGamePGN(f) fprintf(f, " "); linelen++; } - fprintf(f, numtext); + fprintf(f, "%s", numtext); linelen += numlen; /* Get move */ @@ -9587,7 +9617,7 @@ SaveGamePGN(f) fprintf(f, " "); linelen++; } - fprintf(f, move_buffer); + fprintf(f, "%s", move_buffer); linelen += movelen; /* [AS] Add PV info if present */ @@ -9595,7 +9625,6 @@ SaveGamePGN(f) /* [HGM] add time */ char buf[MSG_SIZ]; int seconds = 0; -#if 1 if(i >= backwardMostMove) { if(WhiteOnMove(i)) seconds = timeRemaining[0][i] - timeRemaining[0][i+1] @@ -9605,9 +9634,6 @@ SaveGamePGN(f) + GetTimeQuota(i/2) / (1000*WhitePlayer()->other->timeOdds); } seconds = (seconds+50)/100; // deci-seconds, rounded to nearest -#else - seconds = (pvInfoList[i].time + 5)/10; // [HGM] PVtime: use engine time -#endif if( seconds <= 0) buf[0] = 0; else if( seconds < 30 ) sprintf(buf, " %3.1f%c", seconds/10., 0); else { @@ -9635,7 +9661,7 @@ SaveGamePGN(f) fprintf(f, " "); linelen++; } - fprintf(f, move_buffer); + fprintf(f, "%s", move_buffer); linelen += movelen; } @@ -13476,6 +13502,14 @@ PositionToFEN(move, overrideCastling) } else { *p++ = '-'; } + } else if(move == backwardMostMove) { + // [HGM] perhaps we should always do it like this, and forget the above? + if(epStatus[move] >= 0) { + *p++ = epStatus[move] + AAA; + *p++ = whiteToPlay ? '6'+BOARD_HEIGHT-8 : '3'; + } else { + *p++ = '-'; + } } else { *p++ = '-'; }