aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-19 23:02:12 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-19 23:02:12 +0100
commit2e1b9cdb88525641da448a2e116caddae6e72d02 (patch)
tree853afc3b13ff243c10ec66325fd8e88ddb5f268e /FICS
parentb0a140db85d87677795ba48071d32898a07d145a (diff)
Reformatted player_lastconnect() and changed its return type
Diffstat (limited to 'FICS')
-rw-r--r--FICS/playerdb.c57
-rw-r--r--FICS/playerdb.h2
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,
- &registered, 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,
+ &registered, 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 *);