From: H.G. Muller Date: Sat, 14 May 2011 15:03:44 +0000 (+0200) Subject: Add secondry adapter command for UCCI or USI X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=36aefa2380480aa22c30c0a8c02a02fb961d600f;p=xboard.git Add secondry adapter command for UCCI or USI The option -uxiAdapter can define a second adapterCommand, which will be invoked on encountering the options -fUCCI, -sUCCI and -fUSI, sUCI. --- diff --git a/args.h b/args.h index 2a3fd18..bc82aa7 100644 --- a/args.h +++ b/args.h @@ -60,7 +60,7 @@ typedef enum { ArgString, ArgInt, ArgFloat, ArgBoolean, ArgTrue, ArgFalse, ArgNone, ArgColor, ArgAttribs, ArgFilename, ArgBoardSize, ArgFont, ArgCommSettings, - ArgSettingsFilename, + ArgSettingsFilename, ArgTwo, ArgX, ArgY, ArgZ // [HGM] placement: for window-placement options stored relative to main window } ArgType; @@ -537,6 +537,10 @@ ArgDescriptor argDescriptors[] = { { "firstUCI", ArgTrue, (void *) &appData.firstIsUCI, FALSE, INVALID }, { "secondIsUCI", ArgBoolean, (void *) &appData.secondIsUCI, FALSE, (ArgIniType) FALSE }, { "sUCI", ArgTrue, (void *) &appData.secondIsUCI, FALSE, INVALID }, + { "fUCCI", ArgTwo, (void *) &appData.firstIsUCI, FALSE, INVALID }, + { "sUCCI", ArgTwo, (void *) &appData.secondIsUCI, FALSE, INVALID }, + { "fUSI", ArgTwo, (void *) &appData.firstIsUCI, FALSE, INVALID }, + { "sUSI", ArgTwo, (void *) &appData.secondIsUCI, FALSE, INVALID }, { "secondUCI", ArgTrue, (void *) &appData.secondIsUCI, FALSE, INVALID }, { "firstHasOwnBookUCI", ArgBoolean, (void *) &appData.firstHasOwnBookUCI, FALSE, (ArgIniType) TRUE }, { "fNoOwnBookUCI", ArgFalse, (void *) &appData.firstHasOwnBookUCI, FALSE, INVALID }, @@ -545,6 +549,7 @@ ArgDescriptor argDescriptors[] = { { "sNoOwnBookUCI", ArgFalse, (void *) &appData.secondHasOwnBookUCI, FALSE, INVALID }, { "secondXBook", ArgFalse, (void *) &appData.secondHasOwnBookUCI, FALSE, INVALID }, { "adapterCommand", ArgFilename, (void *) &appData.adapterCommand, TRUE, (ArgIniType) "polyglot -noini -ec \"%fcp\" -ed \"%fd\"" }, + { "uxiAdapter", ArgFilename, (void *) &appData.ucciAdapter, TRUE, (ArgIniType) "" }, { "polyglotDir", ArgFilename, (void *) &appData.polyglotDir, TRUE, (ArgIniType) "" }, { "usePolyglotBook", ArgBoolean, (void *) &appData.usePolyglotBook, TRUE, (ArgIniType) FALSE }, { "polyglotBook", ArgFilename, (void *) &appData.polyglotBook, TRUE, (ArgIniType) "" }, @@ -854,6 +859,10 @@ ParseArgs(GetFunc get, void *cl) strncpy(argName, ad->argName,sizeof(argName)/sizeof(argName[0])); } + if (ad->argType == ArgTwo) { // [HGM] kludgey arg type, not suitable for saving + *(Boolean *) ad->argLoc = 2; + continue; + } if (ad->argType == ArgTrue) { *(Boolean *) ad->argLoc = TRUE; continue; diff --git a/backend.c b/backend.c index da18261..e56bbb1 100644 --- a/backend.c +++ b/backend.c @@ -915,7 +915,7 @@ Load(ChessProgramState *cps, int i) useNick ? "\"" : "", v1 ? " -firstProtocolVersion 1" : "", hasBook ? "" : " -fNoOwnBookUCI", - isUCI ? " -fUCI" : "", + isUCI ? (isUCI == TRUE ? " -fUCI" : gameInfo.variant == VariantShogi ? " -fUSI" : " -fUCCI") : "", storeVariant ? " -variant " : "", storeVariant ? VariantName(gameInfo.variant) : ""); firstChessProgramNames = malloc(len = strlen(q) + strlen(buf) + 1); diff --git a/common.h b/common.h index 94031ad..35c38fb 100644 --- a/common.h +++ b/common.h @@ -564,6 +564,7 @@ typedef struct { Boolean isUCI[ENGINES]; Boolean hasOwnBookUCI[ENGINES]; char * adapterCommand; + char * ucciAdapter; char * polyglotDir; Boolean usePolyglotBook; char * polyglotBook; diff --git a/uci.c b/uci.c index f78fb2c..1f39f6a 100644 --- a/uci.c +++ b/uci.c @@ -36,6 +36,7 @@ void InitEngineUCI( const char * iniDir, ChessProgramState * cps ) char *p, *q; char polyglotCommand[MSG_SIZ]; + if(cps->isUCI == 2) p = appData.ucciAdapter; else p = appData.adapterCommand; q = polyglotCommand; while(*p) { diff --git a/winboard/wsettings.c b/winboard/wsettings.c index 6c9ba72..0c92fbc 100644 --- a/winboard/wsettings.c +++ b/winboard/wsettings.c @@ -34,7 +34,7 @@ int breaks[MAX_OPTIONS]; int checks, combos, buttons, layout, groups; char title[MSG_SIZ]; char *engineName, *engineDir, *engineChoice, *engineLine, *nickName, *params; -Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick; +Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick, isUCCI; extern Option installOptions[], matchOptions[]; char *engineNr[] = { N_("First"), N_("Second"), NULL }; char *engineList[1000] = {" "}, *engineMnemonic[1000] = {""}; @@ -611,7 +611,8 @@ EngineOptionsPopup(HWND hwnd, ChessProgramState *cps) } void InstallOK() -{ +{ + if(isUCCI) isUCI = 2; if(engineChoice[0] == engineNr[0][0]) Load(&first, 0); else Load(&second, 1); } @@ -625,6 +626,7 @@ Option installOptions[] = { { 0, 0, 0, NULL, (void*) &engineDir, NULL, NULL, PathName, N_("directory:") }, { 95, 0, 0, NULL, NULL, NULL, NULL, Label, N_("(Directory will be derived from engine path when empty)") }, { 0, 0, 0, NULL, (void*) &isUCI, NULL, NULL, CheckBox, N_("UCI") }, + { 0, 0, 0, NULL, (void*) &isUCCI, NULL, NULL, CheckBox, N_("UCCI / USI (uses specified /uxiAdapter)") }, { 0, 0, 0, NULL, (void*) &v1, NULL, NULL, CheckBox, N_("WB protocol v1 (skip waiting for features)") }, { 0, 0, 0, NULL, (void*) &addToList, NULL, NULL, CheckBox, N_("Add this engine to the list") }, { 0, 0, 0, NULL, (void*) &hasBook, NULL, NULL, CheckBox, N_("Must not use GUI book") }, @@ -655,7 +657,7 @@ void LoadEnginePopUp(HWND hwnd) { int n=0; - isUCI = storeVariant = v1 = useNick = FALSE; addToList = hasBook = TRUE; // defaults + isUCI = isUCCI = storeVariant = v1 = useNick = FALSE; addToList = hasBook = TRUE; // defaults if(engineDir) free(engineDir); engineDir = strdup(""); if(params) free(params); params = strdup(""); if(nickName) free(nickName); nickName = strdup("");