mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-02-22 19:31:58 +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;
|
packet_entities_t entities;
|
||||||
} client_frame_t;
|
} client_frame_t;
|
||||||
|
|
||||||
#define MAX_BACK_BUFFERS 4
|
#define MAX_BACK_BUFFERS 4
|
||||||
|
#define MAX_STUFFTEXT 256
|
||||||
|
|
||||||
typedef struct client_s
|
typedef struct client_s
|
||||||
{
|
{
|
||||||
|
@ -175,6 +176,8 @@ typedef struct client_s
|
||||||
int backbuf_size[MAX_BACK_BUFFERS];
|
int backbuf_size[MAX_BACK_BUFFERS];
|
||||||
byte backbuf_data[MAX_BACK_BUFFERS][MAX_MSGLEN];
|
byte backbuf_data[MAX_BACK_BUFFERS][MAX_MSGLEN];
|
||||||
|
|
||||||
|
byte stufftext_buf[MAX_STUFFTEXT];
|
||||||
|
|
||||||
double connection_started; // or time of disconnect for zombies
|
double connection_started; // or time of disconnect for zombies
|
||||||
qboolean send_message; // set on frames a datagram arived on
|
qboolean send_message; // set on frames a datagram arived on
|
||||||
|
|
||||||
|
|
|
@ -708,6 +708,8 @@ void PF_stuffcmd (void)
|
||||||
int entnum;
|
int entnum;
|
||||||
char *str;
|
char *str;
|
||||||
client_t *cl;
|
client_t *cl;
|
||||||
|
char *buf;
|
||||||
|
int i;
|
||||||
|
|
||||||
entnum = G_EDICTNUM(OFS_PARM0);
|
entnum = G_EDICTNUM(OFS_PARM0);
|
||||||
if (entnum < 1 || entnum > MAX_CLIENTS)
|
if (entnum < 1 || entnum > MAX_CLIENTS)
|
||||||
|
@ -716,14 +718,27 @@ void PF_stuffcmd (void)
|
||||||
|
|
||||||
cl = &svs.clients[entnum-1];
|
cl = &svs.clients[entnum-1];
|
||||||
|
|
||||||
if (strcmp(str, "disconnect\n") == 0) {
|
buf = cl->stufftext_buf;
|
||||||
// so long and thanks for all the fish
|
if (strlen(buf) + strlen(str) >= MAX_STUFFTEXT)
|
||||||
cl->drop = true;
|
PR_RunError ("stufftext buffer overflow");
|
||||||
return;
|
strcat (buf, str);
|
||||||
}
|
|
||||||
|
|
||||||
ClientReliableWrite_Begin (cl, svc_stufftext, 2+strlen(str));
|
for (i = strlen(buf); i >= 0; i--)
|
||||||
ClientReliableWrite_String (cl, str);
|
{
|
||||||
|
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