From f6e5b57c70f73a2ecc6fba1a043ef3875ed08246 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 16 Dec 2023 22:49:42 +0100 Subject: Reformatted getECO() --- FICS/eco.c | 82 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/FICS/eco.c b/FICS/eco.c index 13187ab..ffd4b7f 100644 --- a/FICS/eco.c +++ b/FICS/eco.c @@ -313,53 +313,59 @@ BookInit() LONG_init(); } -char *getECO(int g) +char * +getECO(int g) { - static char ECO[4]; + static char ECO[4]; #ifndef IGNORE_ECO + int i, flag, l, r, x; - int i, flag, l = 0, r = ECO_entries - 1, x; - - - if ((parray[garray[g].white].private) || (parray[garray[g].black].private)) { - strcpy(ECO, "---"); - return ECO; - } else { - if (garray[g].type == TYPE_WILD) { - strcpy(ECO, "---"); - return ECO; - } else if (garray[g].moveList == NULL) { - strcpy(ECO, "***"); - return ECO; - } else { - strcpy(ECO, "A00"); - } - } + if (parray[garray[g].white].private || + parray[garray[g].black].private) { + strcpy(ECO, "---"); + return ECO; + } else { + if (garray[g].type == TYPE_WILD) { + strcpy(ECO, "---"); + return ECO; + } else if (garray[g].moveList == NULL) { + strcpy(ECO, "***"); + return ECO; + } else { + strcpy(ECO, "A00"); + } + } - for (flag=0,i=garray[g].numHalfMoves; (i>0 && !flag); i--) { - l = 0; - r = ECO_entries - 1; - while ((r >= l) && !flag) { - x = (l+r)/2; - if ((strcmp(garray[g].moveList[i].FENpos, ECO_book[x]->FENpos)) < 0) - r = x - 1; - else - l = x + 1; - if (!strcmp(garray[g].moveList[i].FENpos, ECO_book[x]->FENpos)) { - strcpy(ECO, ECO_book[x]->ECO); - flag=1; - } - } - } -#else + flag = 0; + i = garray[g].numHalfMoves; - strcpy(ECO, "---"); + while (i > 0 && !flag) { + l = 0; + r = (ECO_entries - 1); -#endif + while ((r >= l) && !flag) { + x = ((l + r) / 2); + if (strcmp(garray[g].moveList[i].FENpos, + ECO_book[x]->FENpos) < 0) + r = (x - 1); + else + l = (x + 1); + + if (!strcmp(garray[g].moveList[i].FENpos, + ECO_book[x]->FENpos)) { + strcpy(ECO, ECO_book[x]->ECO); + flag = 1; + } + } - return ECO; + i--; + } /* while */ +#else + strcpy(ECO, "---"); +#endif + return ECO; } PUBLIC int -- cgit v1.2.3