diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-17 18:26:26 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-17 18:26:26 +0100 |
commit | 3ae7f34539e42f96b9f2e3212a23d82e128544f9 (patch) | |
tree | 24d589c267405ce660e0f52b7099db0325cc923f /FICS | |
parent | c19e6d13c78ea441e19962fb1f7fbea1d3334980 (diff) |
Reformatted player_add_comment() and fixed the type of the var passed to strltime()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/playerdb.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c index 72177cc..5628d15 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -2336,23 +2336,26 @@ PUBLIC int player_num_comments(int p) return lines_file(fname); } -PUBLIC int player_add_comment(int p_by, int p_to, char *comment) +PUBLIC int +player_add_comment(int p_by, int p_to, char *comment) { - char fname[MAX_FILENAME_SIZE]; - FILE *fp; - int t = time(0); + FILE *fp; + char fname[MAX_FILENAME_SIZE]; + time_t t = time(NULL); - if (!parray[p_to].registered) - return -1; - sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, parray[p_to].login[0], - parray[p_to].login, "comments"); - fp = fopen(fname, "a"); - if (!fp) - return -1; - fprintf(fp, "%s at %s: %s\n", parray[p_by].name, strltime(&t), comment); - fclose(fp); - parray[p_to].num_comments = player_num_comments(p_to); - return 0; + if (!parray[p_to].registered) + return -1; + + sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, + parray[p_to].login[0], parray[p_to].login, "comments"); + + if ((fp = fopen(fname, "a")) == NULL) + return -1; + + fprintf(fp, "%s at %s: %s\n", parray[p_by].name, strltime(&t), comment); + fclose(fp); + parray[p_to].num_comments = player_num_comments(p_to); + return 0; } PUBLIC int player_show_comments(int p, int p1) |