X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=410488b921bcd3ec0789e6862bf867a096197130;hb=c29f3526dee9ab2774d7a6e9958ce145c2cd1187;hp=361fb86cfe693750d17656a67d1dd2e65cb7306f;hpb=d2a7786025d6bdb8cbd7e3b38a068185d2f93222;p=xboard.git diff --git a/backend.c b/backend.c index 361fb86..410488b 100644 --- a/backend.c +++ b/backend.c @@ -448,9 +448,6 @@ long lastNodeCount=0; int shiftKey; // [HGM] set by mouse handler int have_sent_ICS_logon = 0; -int sending_ICS_login = 0; -int sending_ICS_password = 0; - int movesPerSession; int suddenDeath, whiteStartMove, blackStartMove; /* [HGM] for implementation of 'any per time' sessions, as in first part of byoyomi TC */ long whiteTimeRemaining, blackTimeRemaining, timeControl, timeIncrement, lastWhite, lastBlack; @@ -1089,16 +1086,16 @@ ParseTimeControl(tc, ti, mps) if(mps) snprintf(buf, MSG_SIZ, ":%d/%s+%g", mps, mytc, ti); - else + else snprintf(buf, MSG_SIZ, ":%s+%g", mytc, ti); } else { if(mps) snprintf(buf, MSG_SIZ, ":%d/%s", mps, mytc); - else + else snprintf(buf, MSG_SIZ, ":%s", mytc); } fullTimeControlString = StrSave(buf); // this should now be in PGN format - + if( NextTimeControlFromString( &tc, &tc1 ) != 0 ) { return FALSE; } @@ -3116,23 +3113,8 @@ read_from_ics(isr, closure, data, count, error) if (!have_sent_ICS_logon && looking_at(buf, &i, "login:")) { ICSInitScript(); have_sent_ICS_logon = 1; - /* if we don't send the login/password via icsLogon, use special readline - code for it */ - if (strlen(appData.icsLogon)==0) - { - sending_ICS_password = 0; // in case we come back to login - sending_ICS_login = 1; - }; continue; } - /* need to shadow the password */ - if (!sending_ICS_password && looking_at(buf, &i, "password:")) { - /* if we don't send the login/password via icsLogon, use special readline - code for it */ - if (strlen(appData.icsLogon)==0) - sending_ICS_password = 1; - continue; - } if (ics_getting_history != H_GETTING_MOVES /*smpos kludge*/ && (looking_at(buf, &i, "\n<12> ") || @@ -6082,15 +6064,15 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) pup = boards[currentMove][toY][toX]; /* [HGM] If move started in holdings, it means a drop. Convert to standard form */ - if( fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) { + if( fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) { if( pup != EmptySquare ) return; moveType = WhiteOnMove(currentMove) ? WhiteDrop : BlackDrop; - if(appData.debugMode) fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n", + if(appData.debugMode) fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n", moveType, currentMove, fromX, fromY, boards[currentMove][fromY][fromX]); // holdings might not be sent yet in ICS play; we have to figure out which piece belongs here if(fromX == 0) fromY = BOARD_HEIGHT-1 - fromY; // black holdings upside-down fromX = fromX ? WhitePawn : BlackPawn; // first piece type in selected holdings - while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) fromX++; + while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) fromX++; fromY = DROP_RANK; } @@ -8358,6 +8340,7 @@ ParseGameHistory(game) if (q != NULL) *q = NULLCHAR; p++; } + while(q = strchr(p, '\n')) *q = ' '; // [HGM] crush linefeeds in result message gameInfo.resultDetails = StrSave(p); continue; } @@ -8685,8 +8668,8 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board) } else if(!appData.testLegality && promoChar != NULLCHAR && promoChar != '=') { // without legality testing, unconditionally believe promoChar board[toY][toX] = CharToPiece(piece < BlackPawn ? ToUpper(promoChar) : ToLower(promoChar)); } - if((gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) - && promoChar != NULLCHAR && gameInfo.holdingsSize) { + if((gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) + && promoChar != NULLCHAR && gameInfo.holdingsSize) { // [HGM] superchess: take promotion piece out of holdings int k = PieceToNumber(CharToPiece(ToUpper(promoChar))); if((int)piece < (int)BlackPawn) { // determine stm from piece color @@ -9624,7 +9607,7 @@ AutoPlayGameLoop() return; if (matchMode || appData.timeDelay == 0) continue; - if (appData.timeDelay < 0 || gameMode == AnalyzeFile) + if (appData.timeDelay < 0) return; StartLoadGameTimer((long)(1000.0 * appData.timeDelay)); break; @@ -9641,10 +9624,18 @@ AutoPlayOneMove() fprintf(debugFP, "AutoPlayOneMove(): current %d\n", currentMove); } - if (gameMode != PlayFromGameFile) + if (gameMode != PlayFromGameFile && gameMode != AnalyzeFile) return FALSE; + if (gameMode == AnalyzeFile && currentMove > backwardMostMove) { + pvInfoList[currentMove].depth = programStats.depth; + pvInfoList[currentMove].score = programStats.score; + pvInfoList[currentMove].time = 0; + if(currentMove < forwardMostMove) AppendComment(currentMove+1, lastPV[0], 2); + } + if (currentMove >= forwardMostMove) { + if(gameMode == AnalyzeFile) { ExitAnalyzeMode(); SendToProgram("force\n", &first); } gameMode = EditGame; ModeHighlight(); @@ -9777,6 +9768,7 @@ LoadGameOneMove(readAhead) if (q != NULL) *q = NULLCHAR; p++; } + while(q = strchr(p, '\n')) *q = ' '; // [HGM] crush linefeeds in result message GameEnds(moveType, p, GE_FILE); done = TRUE; if (cmailMsgLoaded) { @@ -11649,7 +11641,7 @@ void EditTagsEvent() { char *tags = PGNTags(&gameInfo); - EditTagsPopUp(tags); + EditTagsPopUp(tags, NULL); free(tags); } @@ -13305,7 +13297,13 @@ ReplaceComment(index, text) char *text; { int len; + char *p; + float score; + if(index && sscanf(text, "%f/%d", &score, &len) == 2 && + pvInfoList[index-1].depth == len && + fabs(pvInfoList[index-1].score - score*100.) < 0.5 && + (p = strchr(text, '\n'))) text = p; // [HGM] strip off first line with PV info, if any while (*text == '\n') text++; len = strlen(text); while (len > 0 && text[len - 1] == '\n') len--; @@ -13379,24 +13377,24 @@ if(appData.debugMode) fprintf(debugFP, "Append: in='%s' %d\n", text, addBraces); safeStrCpy(commentList[index], old, oldlen + len + 6); free(old); // [HGM] braces: join "{A\n}\n" + "{\nB}" as "{A\nB\n}" - if(commentList[index][oldlen-1] == '}' && (text[0] == '{' || addBraces)) { - if(addBraces) addBraces = FALSE; else { text++; len--; } + if(commentList[index][oldlen-1] == '}' && (text[0] == '{' || addBraces == TRUE)) { + if(addBraces == TRUE) addBraces = FALSE; else { text++; len--; } while (*text == '\n') { text++; len--; } commentList[index][--oldlen] = NULLCHAR; } - if(addBraces) strcat(commentList[index], "\n{\n"); + if(addBraces) strcat(commentList[index], addBraces == 2 ? "\n(" : "\n{\n"); else strcat(commentList[index], "\n"); strcat(commentList[index], text); - if(addBraces) strcat(commentList[index], "\n}\n"); + if(addBraces) strcat(commentList[index], addBraces == 2 ? ")\n" : "\n}\n"); else strcat(commentList[index], "\n"); } else { commentList[index] = (char *) malloc(len + 6); // perhaps wastes 4... if(addBraces) - safeStrCpy(commentList[index], "{\n", 3); + safeStrCpy(commentList[index], addBraces == 2 ? "(" : "{\n", 3); else commentList[index][0] = NULLCHAR; strcat(commentList[index], text); - strcat(commentList[index], "\n"); - if(addBraces) strcat(commentList[index], "}\n"); + strcat(commentList[index], addBraces == 2 ? ")\n" : "\n"); + if(addBraces == TRUE) strcat(commentList[index], "}\n"); } } @@ -13415,7 +13413,7 @@ static char * FindStr( char * text, char * sub_text ) /* [HGM] PV time: and then remove it, to prevent it appearing twice */ char *GetInfoFromComment( int index, char * text ) { - char * sep = text; + char * sep = text, *p; if( text != NULL && index > 0 ) { int score = 0; @@ -13453,11 +13451,20 @@ char *GetInfoFromComment( int index, char * text ) return text; } + p = text; + if(p[1] == '(') { // comment starts with PV + p = strchr(p, ')'); // locate end of PV + if(p == NULL || sep < p+5) return text; + // at this point we have something like "{(.*) +0.23/6 ..." + p = text; while(*++p != ')') p[-1] = *p; p[-1] = ')'; + *p = '\n'; while(*p == ' ' || *p == '\n') p++; *--p = '{'; + // we now moved the brace to behind the PV: "(.*) {+0.23/6 ..." + } time = -1; sec = -1; deci = -1; - if( sscanf( text+1, "%d.%d/%d %d:%d", &score, &score_lo, &depth, &time, &sec ) != 5 && - sscanf( text+1, "%d.%d/%d %d.%d", &score, &score_lo, &depth, &time, &deci ) != 5 && - sscanf( text+1, "%d.%d/%d %d", &score, &score_lo, &depth, &time ) != 4 && - sscanf( text+1, "%d.%d/%d", &score, &score_lo, &depth ) != 3 ) { + if( sscanf( p+1, "%d.%d/%d %d:%d", &score, &score_lo, &depth, &time, &sec ) != 5 && + sscanf( p+1, "%d.%d/%d %d.%d", &score, &score_lo, &depth, &time, &deci ) != 5 && + sscanf( p+1, "%d.%d/%d %d", &score, &score_lo, &depth, &time ) != 4 && + sscanf( p+1, "%d.%d/%d", &score, &score_lo, &depth ) != 3 ) { return text; } @@ -13473,7 +13480,7 @@ char *GetInfoFromComment( int index, char * text ) /* [HGM] PV time: now locate end of PV info */ while( *++sep >= '0' && *sep <= '9'); // strip depth if(time >= 0) - while( *++sep >= '0' && *sep <= '9'); // strip time + while( *++sep >= '0' && *sep <= '9' || *sep == '\n'); // strip time if(sec >= 0) while( *++sep >= '0' && *sep <= '9'); // strip seconds if(deci >= 0) @@ -13493,6 +13500,7 @@ char *GetInfoFromComment( int index, char * text ) pvInfoList[index-1].score = score; pvInfoList[index-1].time = 10*time; // centi-sec if(*sep == '}') *sep = 0; else *--sep = '{'; + if(p != text) { while(*p++ = *sep++); sep = text; } // squeeze out space between PV and comment, and return both } return sep; }