mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-01-22 16:01:25 +00:00
rework PF_stuffcmd so it can't lose chars
This commit is contained in:
parent
8723fde566
commit
73d26a4e32
1 changed files with 18 additions and 14 deletions
|
@ -668,7 +668,7 @@ PF_stuffcmd (progs_t *pr)
|
||||||
char *str;
|
char *str;
|
||||||
client_t *cl;
|
client_t *cl;
|
||||||
char *buf;
|
char *buf;
|
||||||
int i;
|
char *p;
|
||||||
|
|
||||||
entnum = G_EDICTNUM (pr, OFS_PARM0);
|
entnum = G_EDICTNUM (pr, OFS_PARM0);
|
||||||
if (entnum < 1 || entnum > MAX_CLIENTS)
|
if (entnum < 1 || entnum > MAX_CLIENTS)
|
||||||
|
@ -680,20 +680,24 @@ PF_stuffcmd (progs_t *pr)
|
||||||
buf = cl->stufftext_buf;
|
buf = cl->stufftext_buf;
|
||||||
if (strlen (buf) + strlen (str) >= MAX_STUFFTEXT)
|
if (strlen (buf) + strlen (str) >= MAX_STUFFTEXT)
|
||||||
PR_RunError (pr, "stufftext buffer overflow");
|
PR_RunError (pr, "stufftext buffer overflow");
|
||||||
strncat (buf, str, MAX_STUFFTEXT - strlen (buf));
|
strcat (buf, str);
|
||||||
|
|
||||||
for (i = strlen (buf); i >= 0; i--) {
|
if (!strcmp (buf, "disconnect\n")) {
|
||||||
if (buf[i] == '\n') {
|
// so long and thanks for all the fish
|
||||||
if (!strcmp (buf, "disconnect\n")) {
|
cl->drop = true;
|
||||||
// so long and thanks for all the fish
|
buf[0] = 0;
|
||||||
cl->drop = true;
|
return;
|
||||||
buf[0] = 0;
|
}
|
||||||
return;
|
|
||||||
}
|
p = strrchr (buf, '\n');
|
||||||
ClientReliableWrite_Begin (cl, svc_stufftext, 2 + strlen (buf));
|
if (p) {
|
||||||
ClientReliableWrite_String (cl, buf);
|
char t = p[1];
|
||||||
buf[0] = 0;
|
p[1] = 0;
|
||||||
}
|
ClientReliableWrite_Begin (cl, svc_stufftext, 2 + p - buf);
|
||||||
|
ClientReliableWrite_String (cl, buf);
|
||||||
|
p[1] = t;
|
||||||
|
strcpy (buf, p + 1); // safe because this is a downward, in
|
||||||
|
// buffer move
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue