From 6ea3d4628fbdd57225eb89c1654f814eac18e748 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 16 Feb 2012 14:41:43 +0100 Subject: [PATCH] Move change of debug file to before game load Loading a game from -lgf is done before TwoMachinesEvent is called, but logically belongs to the game. So the code to switch to the new debug file for the game is moved to NextMatchGame now. --- backend.c | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/backend.c b/backend.c index d08aea0..eee690b 100644 --- a/backend.c +++ b/backend.c @@ -10072,6 +10072,18 @@ NextMatchGame () { // performs game initialization that does not invoke engines, and then tries to start the game int res, firstWhite, swapColors = 0; if(!NextTourneyGame(nextGame, &swapColors)) return; // this sets matchGame, -fcp / -scp and other options for next game, if needed + if(matchMode && appData.debugMode) { // [HGM] debug split: game is part of a match; we might have to create a debug file just for this game + char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, appData.nameOfDebugFile, nextGame+1); // expand name of debug file with %d in it + if(strcmp(buf, currentDebugFile)) { // name has changed + FILE *f = fopen(buf, "w"); + if(f) { // if opening the new file failed, just keep using the old one + ASSIGN(currentDebugFile, buf); + fclose(debugFP); + debugFP = f; + } + } + } firstWhite = appData.firstPlaysBlack ^ (matchGame & 1 | appData.sameColorGames > 1); // non-incremental default firstWhite ^= swapColors; // reverses if NextTourneyGame says we are in an odd round first.twoMachinesColor = firstWhite ? "white\n" : "black\n"; // perform actual color assignement @@ -13385,17 +13397,6 @@ TwoMachinesEvent P((void)) break; } - if(matchMode && appData.debugMode) { // [HGM] debug split: game is part of a match; we might have to create a debug file just for this game - snprintf(buf, MSG_SIZ, appData.nameOfDebugFile, nextGame+1); // expand name of debug file with %d in it - if(strcmp(buf, currentDebugFile)) { // name has changed - FILE *f = fopen(buf, "w"); - if(f) { // if opening the new file failed, just keep using the old one - ASSIGN(currentDebugFile, buf); - fclose(debugFP); - debugFP = f; - } - } - } // forwardMostMove = currentMove; TruncateGame(); // [HGM] vari: MachineWhite and MachineBlack do this... -- 1.7.0.4