aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
Diffstat (limited to 'FICS')
-rw-r--r--FICS/gamedb.c41
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