(rea, turn): Use a different buffer for message text. Just for
clarity.
This commit is contained in:
parent
ff27a2644f
commit
cb454a1f56
2 changed files with 11 additions and 9 deletions
|
@ -63,7 +63,8 @@ rea(void)
|
||||||
int teles;
|
int teles;
|
||||||
int size;
|
int size;
|
||||||
unsigned int nbytes;
|
unsigned int nbytes;
|
||||||
s_char buf[4096]; /* buf is message text */
|
char buf[1024];
|
||||||
|
char msgbuf[4096]; /* message text */
|
||||||
int lasttype;
|
int lasttype;
|
||||||
int lastcnum;
|
int lastcnum;
|
||||||
time_t lastdate;
|
time_t lastdate;
|
||||||
|
@ -163,12 +164,12 @@ rea(void)
|
||||||
skip:
|
skip:
|
||||||
while (tgm.tel_length > 0) {
|
while (tgm.tel_length > 0) {
|
||||||
nbytes = tgm.tel_length;
|
nbytes = tgm.tel_length;
|
||||||
if (nbytes > sizeof(buf) - 1)
|
if (nbytes > sizeof(msgbuf) - 1)
|
||||||
nbytes = sizeof(buf) - 1;
|
nbytes = sizeof(msgbuf) - 1;
|
||||||
(void)fread(buf, sizeof(s_char), nbytes, telfp);
|
(void)fread(msgbuf, sizeof(s_char), nbytes, telfp);
|
||||||
buf[nbytes] = 0;
|
msgbuf[nbytes] = 0;
|
||||||
if (readit)
|
if (readit)
|
||||||
uprnf(buf);
|
uprnf(msgbuf);
|
||||||
tgm.tel_length -= nbytes;
|
tgm.tel_length -= nbytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,8 @@ turn(void)
|
||||||
FILE *fptr;
|
FILE *fptr;
|
||||||
struct telstr tgm;
|
struct telstr tgm;
|
||||||
char *p;
|
char *p;
|
||||||
char buf[MAXTELSIZE + 1];
|
char buf[1024];
|
||||||
|
char msgbuf[MAXTELSIZE + 1]; /* message text */
|
||||||
char *msgfilepath;
|
char *msgfilepath;
|
||||||
|
|
||||||
p = getstarg(player->argp[1], "on, off or motd? ", buf);
|
p = getstarg(player->argp[1], "on, off or motd? ", buf);
|
||||||
|
@ -75,7 +76,7 @@ turn(void)
|
||||||
pr("Enter a new message of the day.\n");
|
pr("Enter a new message of the day.\n");
|
||||||
|
|
||||||
time(&tgm.tel_date);
|
time(&tgm.tel_date);
|
||||||
tgm.tel_length = getele("The World", buf);
|
tgm.tel_length = getele("The World", msgbuf);
|
||||||
|
|
||||||
if (tgm.tel_length < 0) {
|
if (tgm.tel_length < 0) {
|
||||||
pr("Ignored\n");
|
pr("Ignored\n");
|
||||||
|
@ -106,7 +107,7 @@ turn(void)
|
||||||
pr("Logins disabled.\n");
|
pr("Logins disabled.\n");
|
||||||
|
|
||||||
if ((fwrite(&tgm, sizeof(tgm), 1, fptr) != 1) ||
|
if ((fwrite(&tgm, sizeof(tgm), 1, fptr) != 1) ||
|
||||||
(fwrite(buf, tgm.tel_length, 1, fptr) != 1)) {
|
(fwrite(msgbuf, tgm.tel_length, 1, fptr) != 1)) {
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
pr("Something went wrong writing the message file.\n");
|
pr("Something went wrong writing the message file.\n");
|
||||||
logerror("Could not properly write message file (%s).\n",
|
logerror("Could not properly write message file (%s).\n",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue