diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-26 16:46:27 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-26 16:46:27 +0100 |
commit | 204d5edeb8764198782f7b515e7a3e6fdaa1e3b4 (patch) | |
tree | 83b1d7db6e59634656d7639bd15aa572348bd72d | |
parent | 005dbdc2bead1b0f265e9421cc94ecb52d0109bf (diff) |
Reformatted ChooseClauses()
-rw-r--r-- | FICS/formula.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/FICS/formula.c b/FICS/formula.c index 516534b..26cbbce 100644 --- a/FICS/formula.c +++ b/FICS/formula.c @@ -439,28 +439,33 @@ int CheckFormula (game *g, int clause, int *i, int op_type, return (ERR_NONE); } /* end of function CheckFormula. */ -/* which clauses are relevant for a player's formula. */ -PRIVATE int ChooseClauses(player *who, char *formula) +/* + * Which clauses are relevant for a player's formula. + */ +PRIVATE int +ChooseClauses(player *who, char *formula) { - int i, which, ret=0; - - if (formula == NULL) - return ret; - for (i=0; formula[i] != '\0' && formula[i] != '#'; i++) { - if (formula[i] != 'f' || (i > 0 && isalnum(formula[i-1])) - || !isdigit(formula[i+1])) - continue; - sscanf(&formula[i], "f%d", &which); - ret |= (1 << (which - 1)); - } - /* now scan clauses found as part of the formula. */ - for (i = MAX_FORMULA - 1; i >= 0; i--) { - if (ret & (1 << i)) { - ret |= ChooseClauses(who, who->formulaLines[i]); - } - } - return ret; -} /* end of function ChooseClauses. */ + int i, which, ret = 0; + + if (formula == NULL) + return ret; + + for (i = 0; formula[i] != '\0' && formula[i] != '#'; i++) { + if (formula[i] != 'f' || (i > 0 && isalnum(formula[i - 1])) || + !isdigit(formula[i + 1])) + continue; + sscanf(&formula[i], "f%d", &which); + ret |= (1 << (which - 1)); + } + + /* Now scan clauses found as part of the formula. */ + for (i = MAX_FORMULA - 1; i >= 0; i--) { + if (ret & (1 << i)) + ret |= ChooseClauses(who, who->formulaLines[i]); + } + + return ret; +} void ExplainFormula(game *g, textlist **clauses) |