diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-04-17 02:47:56 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-04-17 02:47:56 +0200 |
commit | 011f1948c21cb01d229910d3261f5fd77c4e08da (patch) | |
tree | 6129863d976075361368534bd2fc827de2d004ef /FICS | |
parent | 66169ca47edda3d049a7c74ae47c6d915858e428 (diff) |
Revised com_jsave()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/obsproc.c | 134 |
1 files changed, 74 insertions, 60 deletions
diff --git a/FICS/obsproc.c b/FICS/obsproc.c index ac6a131..e0b1bd4 100644 --- a/FICS/obsproc.c +++ b/FICS/obsproc.c @@ -1534,75 +1534,89 @@ PUBLIC void jsave_history(int p,char save_spot,int p1,int from,char* to_file) } } -PUBLIC int com_jsave(int p, param_list param) +PUBLIC int +com_jsave(int p, param_list param) { - int p1, p1conn; - char* to = param[0].val.word; - char* from; - char fname[MAX_FILENAME_SIZE]; - - if (!parray[p].registered) { - pprintf (p,"Only registered players may keep a journal.\n"); - return COM_OK; - } - - if ((strlen(to) != 1) || (!(isalpha(to[0])))) { - pprintf (p,"Journal entries are referenced by single letters.\n"); - return COM_OK; - } - - if (((to[0] - 'a' - 1) > MAX_JOURNAL) && (parray[p].adminLevel < ADMIN_ADMIN) && (!titled_player(p,parray[p].login))) { - pprintf (p,"Your maximum journal entry is %c\n",toupper ((char)(MAX_JOURNAL + 'A' - 1))); - return COM_OK; - } - - if (!FindPlayer(p, param[1].val.word, &p1, &p1conn)) - return COM_OK; - - if (param[2].type == TYPE_INT) { + char *from; + char *to = param[0].val.word; + char fname[MAX_FILENAME_SIZE] = { '\0' }; + int p1, p1conn; + + if (!parray[p].registered) { + pprintf(p, "Only registered players may keep a journal.\n"); + return COM_OK; + } - /* grab from a history */ - sprintf (fname,"%s/player_data/%c/%s.%s",stats_dir,parray[p].login[0],parray[p].login, STATS_JOURNAL); - jsave_history(p, to[0], p1, param[2].val.integer,fname); + if (strlen(to) != 1 || !(isalpha(to[0]))) { + pprintf(p, "Journal entries are referenced by single " + "letters.\n"); + return COM_OK; + } - } else { + if ((to[0] - 'a' - 1) > MAX_JOURNAL && + parray[p].adminLevel < ADMIN_ADMIN && + !titled_player(p,parray[p].login)) { + pprintf(p, "Your maximum journal entry is %c\n", + toupper((char)(MAX_JOURNAL + 'A' - 1))); + return COM_OK; + } - from = param[2].val.word; + if (!FindPlayer(p, param[1].val.word, &p1, &p1conn)) + return COM_OK; - if ((strlen(from) != 1) || (!(isalpha(from[0])))) { - pprintf (p,"Journal entries are referenced by single letters.\n"); - if (!p1conn) - player_remove(p1); - return COM_OK; - } + if (param[2].type == TYPE_INT) { + // grab from a history + msnprintf(fname, sizeof fname, "%s/player_data/%c/%s.%s", + stats_dir, parray[p].login[0], parray[p].login, + STATS_JOURNAL); + jsave_history(p, to[0], p1, param[2].val.integer, fname); + } else { + from = param[2].val.word; + + if (strlen(from) != 1 || !(isalpha(from[0]))) { + pprintf(p, "Journal entries are referenced by single " + "letters.\n"); + if (!p1conn) + player_remove(p1); + return COM_OK; + } - if ((parray[p1].jprivate) && (parray[p].adminLevel < ADMIN_ADMIN) && (p != p1)) { - pprintf (p,"Sorry, the journal from which you are trying to fetch is private.\n"); + if (parray[p1].jprivate && + parray[p].adminLevel < ADMIN_ADMIN && + p != p1) { + pprintf(p, "Sorry, the journal from which you are " + "trying to fetch is private.\n"); + if (!p1conn) + player_remove(p1); + return COM_OK; + } - if (!p1conn) - player_remove(p1); - return COM_OK; - } + if ((to[0] - 'a' - 1) > MAX_JOURNAL && + parray[p1].adminLevel < ADMIN_ADMIN && + !titled_player(p, parray[p1].login)) { + pprintf(p, "%s's maximum journal entry is %c\n", + parray[p1].name, + toupper((char)(MAX_JOURNAL + 'A' - 1))); - if (((to[0] - 'a' - 1) > MAX_JOURNAL) && (parray[p1].adminLevel < ADMIN_ADMIN) && (!titled_player(p,parray[p1].login))) { - pprintf (p,"%s's maximum journal entry is %c\n",parray[p1].name,toupper((char)(MAX_JOURNAL + 'A' - 1))); - if (!p1conn) - player_remove(p1); - return COM_OK; - } - if (( p == p1) && (to[0] == from [0])) { - pprintf (p,"Source and destination entries are the same.\n"); - return COM_OK; - } + if (!p1conn) + player_remove(p1); + return COM_OK; + } - /* grab from a journal */ + if ((p == p1) && (to[0] == from[0])) { + pprintf(p, "Source and destination entries are the " + "same.\n"); + return COM_OK; + } - sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, parray[p].login[0], - parray[p].login, STATS_JOURNAL); - jsave_journalentry(p,to[0],p1, from[0], fname); + // grab from a journal + msnprintf(fname, sizeof fname, "%s/player_data/%c/%s.%s", + stats_dir, parray[p].login[0], parray[p].login, + STATS_JOURNAL); + jsave_journalentry(p, to[0], p1, from[0], fname); + } - } - if (!p1conn) - player_remove(p1); - return COM_OK; + if (!p1conn) + player_remove(p1); + return COM_OK; } |