diff options
-rw-r--r-- | FICS/playerdb.c | 57 | ||||
-rw-r--r-- | FICS/playerdb.h | 2 |
2 files changed, 33 insertions, 26 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c index d407df1..c29f410 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -1211,33 +1211,40 @@ PUBLIC void player_write_logout(int p) write_p_inout(P_LOGOUT, p, fname, 0); } -PUBLIC int player_lastconnect(int p) +PUBLIC time_t +player_lastconnect(int p) { - char fname[MAX_FILENAME_SIZE]; - FILE *fp; - int inout, thetime, registered; - int last = 0; - char loginName[MAX_LOGIN_NAME]; - char ipstr[20]; + FILE *fp; + char fname[MAX_FILENAME_SIZE]; + char ipstr[20]; + char loginName[MAX_LOGIN_NAME]; + int inout, registered; + long int lval; + time_t last = 0; - sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, - parray[p].login[0], parray[p].login, STATS_LOGONS); - fp = fopen(fname, "r"); - if (!fp) - return 0; - inout = 1; - while (!feof(fp)) { - if (inout == P_LOGIN) - last = thetime; - if (fscanf(fp, "%d %s %d %d %s\n", &inout, loginName, &thetime, - ®istered, ipstr) != 5) { - fprintf(stderr, "FICS: Error in login info format. %s\n", fname); - fclose(fp); - return 0; - } - } - fclose(fp); - return last; + sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, parray[p].login[0], + parray[p].login, STATS_LOGONS); + + if ((fp = fopen(fname, "r")) == NULL) + return 0; + + inout = 1; + + while (!feof(fp)) { + if (inout == P_LOGIN) + last = lval; + + if (fscanf(fp, "%d %s %ld %d %s\n", &inout, loginName, &lval, + ®istered, ipstr) != 5) { + fprintf(stderr, "FICS: Error in login info format. %s" + "\n", fname); + fclose(fp); + return 0; + } + } + + fclose(fp); + return last; } PUBLIC time_t diff --git a/FICS/playerdb.h b/FICS/playerdb.h index 8cb73ef..c6fa9e9 100644 --- a/FICS/playerdb.h +++ b/FICS/playerdb.h @@ -225,7 +225,7 @@ extern int player_clear(int); extern void player_write_login(int); extern void player_write_logout(int); -extern int player_lastconnect(int); +extern time_t player_lastconnect(int); extern time_t player_lastdisconnect(int); extern void player_pend_print(int, pending *); |