From: H.G. Muller Date: Sun, 30 Sep 2012 08:07:58 +0000 (+0200) Subject: Resolve conflict between -mps and -inc options X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=03825b0fcf49f649d77f6b8313557ad3efbe8368;p=xboard.git Resolve conflict between -mps and -inc options The age-old problem that a persistent valid -inc value will cause -mps to be ignored is solved by the kludge of storing these two as a single option (-mps) in the settings file, and declaring the other (-inc) volatile. The range of negative numbers (invalid as -mps value) was available for that, and now is used to store the negated value of -inc in msec. For backward compatibility, specification of -inc causes interpretation of -mps in the old way. The forcing of -inc to -1 in the master settings file could be safely removed because of this change, so that the time increment now is a persistent option. --- diff --git a/args.h b/args.h index 6e3c3ac..cb817c3 100644 --- a/args.h +++ b/args.h @@ -230,7 +230,7 @@ ArgDescriptor argDescriptors[] = { { "td", ArgFloat, (void *) &appData.timeDelay, FALSE, INVALID }, { "timeControl", ArgString, (void *) &appData.timeControl, TRUE, (ArgIniType) TIME_CONTROL }, { "tc", ArgString, (void *) &appData.timeControl, FALSE, INVALID }, - { "timeIncrement", ArgFloat, (void *) &appData.timeIncrement, TRUE, INVALID }, + { "timeIncrement", ArgFloat, (void *) &appData.timeIncrement, FALSE, INVALID }, { "inc", ArgFloat, (void *) &appData.timeIncrement, FALSE, INVALID }, { "internetChessServerMode", ArgBoolean, (void *) &appData.icsActive, FALSE, INVALID }, { "ics", ArgTrue, (void *) &appData.icsActive, FALSE, (ArgIniType) FALSE }, @@ -1274,7 +1274,7 @@ InitAppData(char *lpCmdLine) // float: casting to int is not harmless, so default cannot be contained in table appData.timeDelay = TIME_DELAY; - appData.timeIncrement = TIME_INCREMENT; + appData.timeIncrement = -314159; // some complex, platform-dependent stuff that could not be handled from table SetDefaultTextAttribs(); @@ -1342,6 +1342,12 @@ InitAppData(char *lpCmdLine) if (appData.icsActive || appData.noChessProgram) { chessProgram = FALSE; /* not local chess program mode */ } + if(appData.timeIncrement == -314159) { // new storage mechanism of (mps,inc) in use and no -inc on command line + if(appData.movesPerSession <= 0) { // new encoding of incremental mode + appData.timeIncrement = -appData.movesPerSession/1000.; + } else appData.timeIncrement = -1; + } + if(appData.movesPerSession <= 0) appData.movesPerSession = MOVES_PER_SESSION; // mps <= 0 is invalid in any case /* Open startup dialog if needed */ if ((!appData.noChessProgram && !chessProgram && !appData.icsActive) || @@ -1387,6 +1393,7 @@ SaveSettings(char* name) FILE *f; ArgDescriptor *ad; char dir[MSG_SIZ], buf[MSG_SIZ]; + int mps = appData.movesPerSession; if (!MainWindowUp()) return; @@ -1425,6 +1432,8 @@ SaveSettings(char* name) // [HGM] in WB we have to copy sound names to appData first ExportSounds(); + if(appData.timeIncrement >= 0) appData.movesPerSession = -1000*appData.timeIncrement; // kludge to store mps & inc as one + for (ad = argDescriptors; ad->argName != NULL; ad++) { if (!ad->save) continue; switch (ad->argType) { @@ -1506,6 +1515,7 @@ SaveSettings(char* name) } } fclose(f); + appData.movesPerSession = mps; } Boolean diff --git a/xboard.conf.in b/xboard.conf.in index b17b2c4..412eb24 100644 --- a/xboard.conf.in +++ b/xboard.conf.in @@ -125,8 +125,4 @@ Message (name);message $name $input; -saveSettingsOnExit true -saveSettingsFile "~/.xboardrc" -settingsFile "~/.xboardrc" -; -; Turn -inc into a volatile option, to prevent a persistent increment >= 0 dominating a command-line -mps -; --inc -1