mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-02-22 03:11:20 +00:00
Solution for stufftext problem
This commit is contained in:
parent
02e48af08f
commit
6024c0ce7f
2 changed files with 26 additions and 8 deletions
|
@ -133,7 +133,8 @@ typedef struct
|
|||
packet_entities_t entities;
|
||||
} client_frame_t;
|
||||
|
||||
#define MAX_BACK_BUFFERS 4
|
||||
#define MAX_BACK_BUFFERS 4
|
||||
#define MAX_STUFFTEXT 256
|
||||
|
||||
typedef struct client_s
|
||||
{
|
||||
|
@ -175,6 +176,8 @@ typedef struct client_s
|
|||
int backbuf_size[MAX_BACK_BUFFERS];
|
||||
byte backbuf_data[MAX_BACK_BUFFERS][MAX_MSGLEN];
|
||||
|
||||
byte stufftext_buf[MAX_STUFFTEXT];
|
||||
|
||||
double connection_started; // or time of disconnect for zombies
|
||||
qboolean send_message; // set on frames a datagram arived on
|
||||
|
||||
|
|
|
@ -708,6 +708,8 @@ void PF_stuffcmd (void)
|
|||
int entnum;
|
||||
char *str;
|
||||
client_t *cl;
|
||||
char *buf;
|
||||
int i;
|
||||
|
||||
entnum = G_EDICTNUM(OFS_PARM0);
|
||||
if (entnum < 1 || entnum > MAX_CLIENTS)
|
||||
|
@ -716,14 +718,27 @@ void PF_stuffcmd (void)
|
|||
|
||||
cl = &svs.clients[entnum-1];
|
||||
|
||||
if (strcmp(str, "disconnect\n") == 0) {
|
||||
// so long and thanks for all the fish
|
||||
cl->drop = true;
|
||||
return;
|
||||
}
|
||||
buf = cl->stufftext_buf;
|
||||
if (strlen(buf) + strlen(str) >= MAX_STUFFTEXT)
|
||||
PR_RunError ("stufftext buffer overflow");
|
||||
strcat (buf, str);
|
||||
|
||||
ClientReliableWrite_Begin (cl, svc_stufftext, 2+strlen(str));
|
||||
ClientReliableWrite_String (cl, str);
|
||||
for (i = strlen(buf); i >= 0; i--)
|
||||
{
|
||||
if (buf[i] == '\n')
|
||||
{
|
||||
if (!strcmp(buf, "disconnect\n"))
|
||||
{
|
||||
// so long and thanks for all the fish
|
||||
cl->drop = true;
|
||||
buf[0] = 0;
|
||||
return;
|
||||
}
|
||||
ClientReliableWrite_Begin (cl, svc_stufftext, 2+strlen(buf));
|
||||
ClientReliableWrite_String (cl, buf);
|
||||
buf[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue