aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-04-02 18:59:45 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-04-02 18:59:45 +0200
commit35d1cc3623cac793d397d9228420237d66946543 (patch)
tree6e2bb7c0b10e62c78cf1eab34c4950a0fd8188e0
parent935a6ae3c1d2bb70bfa5e0749188acee0988642a (diff)
Reformatted GetRank()
-rw-r--r--FICS/ratings.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/FICS/ratings.c b/FICS/ratings.c
index 2b8f459..c3daa62 100644
--- a/FICS/ratings.c
+++ b/FICS/ratings.c
@@ -1063,21 +1063,25 @@ PRIVATE int CountRankLine(int countComp, char *loginName,
return (countComp || !is_computer) && (is_active(num));
}
-PRIVATE int GetRank(FILE * fp, char *target, int countComp)
+PRIVATE int
+GetRank(FILE *fp, char *target, int countComp)
{
- int count = 0;
- int nGames, is_computer;
- int playerFound = 0;
- char line[MAX_RANK_LINE];
- char login[MAX_LOGIN_NAME];
+ char line[MAX_RANK_LINE] = { '\0' };
+ char login[MAX_LOGIN_NAME] = { '\0' };
+ int count = 0;
+ int nGames, is_computer;
+ int playerFound = 0;
- while (fgets(line, MAX_RANK_LINE - 1, fp) && !playerFound) {
- sscanf(line, "%s %*d %d %d", login, &nGames, &is_computer);
- if ((playerFound = !strcasecmp(login, target))
- || CountRankLine(countComp, login, nGames, is_computer))
- count++;
- }
- return (playerFound ? count : -1);
+ while (fgets(line, MAX_RANK_LINE - 1, fp) &&
+ !playerFound) {
+ sscanf(line, "%s %*d %d %d", login, &nGames, &is_computer);
+
+ if ((playerFound = !strcasecmp(login, target)) ||
+ CountRankLine(countComp, login, nGames, is_computer))
+ count++;
+ }
+
+ return (playerFound ? count : -1);
}
PRIVATE void