make backbuf max size tunable (for the big packets)

This commit is contained in:
Bill Currie 2007-05-07 12:09:10 +00:00 committed by Jeff Teunissen
parent 32733ef3d9
commit c2894dcfce
4 changed files with 15 additions and 3 deletions

View file

@ -32,6 +32,8 @@
#ifndef __qw_msg_backbuf_h
#define __qw_msg_backbuf_h
#include "netchan.h"
#define MAX_BACK_BUFFERS 8
typedef struct backbuf_s {
@ -40,6 +42,7 @@ typedef struct backbuf_s {
int head_backbuf;
int backbuf_size[MAX_BACK_BUFFERS];
byte backbuf_data[MAX_BACK_BUFFERS][MAX_MSGLEN];
size_t max_msglen;
struct netchan_s *netchan;
const char *name;
} backbuf_t;

View file

@ -53,9 +53,11 @@ PushBackbuf (backbuf_t *rel)
Con_DPrintf ("backbuffering %d %s\n", rel->num_backbuf, rel->name);
tail_backbuf = (rel->head_backbuf + rel->num_backbuf) % MAX_BACK_BUFFERS;
memset (&rel->backbuf, 0, sizeof (rel->backbuf));
if (rel->max_msglen > sizeof (rel->backbuf_data[tail_backbuf]))
rel->max_msglen = sizeof (rel->backbuf_data[tail_backbuf]);
rel->backbuf.allowoverflow = true;
rel->backbuf.data = rel->backbuf_data[tail_backbuf];
rel->backbuf.maxsize = sizeof (rel->backbuf_data[tail_backbuf]);
rel->backbuf.maxsize = rel->max_msglen;
rel->backbuf_size[tail_backbuf] = 0;
rel->num_backbuf++;
}

View file

@ -1148,6 +1148,7 @@ client_connect (connection_t *con, void *object)
cl->name = Info_ValueForKey (userinfo, "name");
cl->backbuf.name = cl->name;
cl->backbuf.netchan = &cl->netchan;
cl->backbuf.max_msglen = MAX_MSGLEN;
cl->con = con;
con->object = cl;
con->handler = client_handler;

View file

@ -768,6 +768,7 @@ SVC_DirectConnect (void)
const char *s;
client_t *cl, *newcl;
int challenge, qport, version, i, qtv = 0;
int large_ent, large_dg;
netadr_t adr;
qboolean spectator;
client_frame_t *frames;
@ -908,19 +909,24 @@ SVC_DirectConnect (void)
Netchan_OutOfBandPrint (adr, "%c", S2C_CONNECTION);
large_ent = strchr(Info_ValueForKey (userinfo, "*cap"), 'e') != 0;
large_dg = strchr(Info_ValueForKey (userinfo, "*cap"), 'u') != 0;
Netchan_Setup (&newcl->netchan, adr, qport, NC_READ_QPORT);
newcl->backbuf.netchan = &newcl->netchan;
newcl->backbuf.name = newcl->name;
newcl->backbuf.max_msglen = large_dg ? MAX_MSGLEN : MAX_OLD_MSGLEN;
newcl->state = cs_connected;
newcl->prespawned = false;
newcl->spawned = false;
newcl->max_packet_ents = (strchr(Info_ValueForKey (userinfo, "*cap"), 'e') != 0) ? MAX_EXT_PACKET_ENTITIES : MAX_PACKET_ENTITIES;
newcl->max_packet_ents = large_ent ? MAX_EXT_PACKET_ENTITIES
: MAX_PACKET_ENTITIES;
newcl->datagram.allowoverflow = true;
newcl->datagram.data = newcl->datagram_buf;
newcl->datagram.maxsize = (strchr(Info_ValueForKey (userinfo, "*cap"), 'u') != 0) ? MAX_DATAGRAM : MAX_OLD_DATAGRAM;
newcl->datagram.maxsize = large_dg ? MAX_DATAGRAM : MAX_OLD_DATAGRAM;
// spectator mode can ONLY be set at join time
newcl->spectator = spectator;