diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-05-02 22:37:46 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-05-02 22:37:46 +0200 |
commit | 57114336670264eae04a595013403188e63ba58e (patch) | |
tree | eec4ffa07a11139299f840ae7b1f179e87cb55b8 /FICS | |
parent | 0ac49149a76aa0edd46ca7a3012dd3bf76a5224e (diff) |
Revised OldestHistGame()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/gamedb.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c index 555bf8e..4fc6d0e 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -1256,28 +1256,31 @@ PUBLIC int game_save(int g) return 0; } -PRIVATE long OldestHistGame(char *login) +PRIVATE long int +OldestHistGame(char *login) { - FILE *fp; - char pFile[MAX_FILENAME_SIZE]; - long when; - - sprintf(pFile, "%s/player_data/%c/%s.%s", stats_dir, - login[0], login, STATS_GAMES); - fp = fopen(pFile, "r"); + FILE *fp; + char pFile[MAX_FILENAME_SIZE] = { '\0' }; + long int when; - if (fp == NULL) { - sprintf(pFile, "%s/player_data/%c/.rem.%s.%s", stats_dir, + msnprintf(pFile, sizeof pFile, "%s/player_data/%c/%s.%s", stats_dir, login[0], login, STATS_GAMES); - fp = fopen(pFile, "r"); - } - if (fp != NULL) { - fscanf(fp, "%*d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d %*s %*s %ld", - &when); - fclose(fp); - return when; - } else - return 0L; + + fp = fopen(pFile, "r"); + + if (fp == NULL) { + msnprintf(pFile, sizeof pFile, "%s/player_data/%c/.rem.%s.%s", + stats_dir, login[0], login, STATS_GAMES); + fp = fopen(pFile, "r"); + } + + if (fp != NULL) { + fscanf(fp, "%*d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d %*s " + "%*s %ld", &when); + fclose(fp); + return when; + } else + return 0L; } PRIVATE void |