From 35d1cc3623cac793d397d9228420237d66946543 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Tue, 2 Apr 2024 18:59:45 +0200 Subject: Reformatted GetRank() --- FICS/ratings.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'FICS/ratings.c') 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 -- cgit v1.2.3