aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-16 22:49:42 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-16 22:49:42 +0100
commitf6e5b57c70f73a2ecc6fba1a043ef3875ed08246 (patch)
tree022b0e3de7cfa12390416862b940626b69bdbebd /FICS
parentd260f8df2d41d85db330dba5b243442afb0518c6 (diff)
Reformatted getECO()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/eco.c82
1 files 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