shithub: qk1

Download patch

ref: 61219b556ce4b630d41303634317867dd8bb1ed5
parent: 9c2610853f765d616e247bd7b4ae714028f45f05
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Oct 10 20:41:38 EDT 2023

raise a bunch of limits; get rid of packet overflow on loopback interface

--- a/cl_main.c
+++ b/cl_main.c
@@ -27,14 +27,13 @@
 client_static_t	cls;
 client_state_t	cl;
 // FIXME: put these on hunk?
-efrag_t			cl_efrags[MAX_EFRAGS];
-entity_t		cl_entities[MAX_EDICTS];
-entity_t		cl_static_entities[MAX_STATIC_ENTITIES];
+entity_t		**cl_visedicts;
+efrag_t			*cl_efrags;
+entity_t		*cl_entities;
+entity_t		*cl_static_entities;
 lightstyle_t	cl_lightstyle[Nlights];
 dlight_t		cl_dlights[MAX_DLIGHTS];
-
 int				cl_numvisedicts;
-entity_t		*cl_visedicts[MAX_VISEDICTS];
 
 /*
 =====================
@@ -674,6 +673,11 @@
 void CL_Init (void)
 {	
 	SZ_Alloc (&cls.message, 1024);
+
+	cl_visedicts = Hunk_Alloc(MAX_VISEDICTS * sizeof(*cl_visedicts));
+	cl_efrags = Hunk_Alloc(MAX_EFRAGS * sizeof(*cl_efrags));
+	cl_entities = Hunk_Alloc(MAX_EDICTS * sizeof(*cl_entities));
+	cl_static_entities = Hunk_Alloc(MAX_STATIC_ENTITIES * sizeof(*cl_static_entities));
 
 	CL_InitInput ();
 	CL_InitTEnts ();
--- a/cl_parse.c
+++ b/cl_parse.c
@@ -132,7 +132,7 @@
 	static float lastmsg;
 	int		ret;
 	sizebuf_t	old;
-	byte		olddata[8192];
+	static byte		olddata[NET_MAXMESSAGE];
 	
 	if (sv.active)
 		return;		// no need if server is local
--- a/client.h
+++ b/client.h
@@ -56,7 +56,7 @@
 } dlight_t;
 
 
-#define	MAX_BEAMS	24
+#define	MAX_BEAMS	128
 typedef struct
 {
 	int		entity;
@@ -65,7 +65,7 @@
 	vec3_t	start, end;
 } beam_t;
 
-#define	MAX_EFRAGS		4096
+#define	MAX_EFRAGS		65536
 
 #define	MAX_MAPSTRING	2048
 #define	MAX_DEMOS		8
@@ -233,15 +233,15 @@
 extern	cvar_t	m_side;
 
 
-#define	MAX_TEMP_ENTITIES	64			// lightning bolts, etc
-#define	MAX_STATIC_ENTITIES	128			// torches, etc
+#define	MAX_TEMP_ENTITIES	256			// lightning bolts, etc
+#define	MAX_STATIC_ENTITIES	8192			// torches, etc
 
 extern	client_state_t	cl;
 
 // FIXME, allocate dynamically
-extern	efrag_t			cl_efrags[MAX_EFRAGS];
-extern	entity_t		cl_entities[MAX_EDICTS];
-extern	entity_t		cl_static_entities[MAX_STATIC_ENTITIES];
+extern	efrag_t			*cl_efrags;
+extern	entity_t		*cl_entities;
+extern	entity_t		*cl_static_entities;
 extern	lightstyle_t	cl_lightstyle[Nlights];
 extern	dlight_t		cl_dlights[MAX_DLIGHTS];
 extern	entity_t		cl_temp_entities[MAX_TEMP_ENTITIES];
@@ -267,9 +267,9 @@
 void CL_Disconnect_f (void);
 void CL_NextDemo (void);
 
-#define			MAX_VISEDICTS	4096
+#define			MAX_VISEDICTS	65536
 extern	int				cl_numvisedicts;
-extern	entity_t		*cl_visedicts[MAX_VISEDICTS];
+extern	entity_t		**cl_visedicts;
 
 //
 // cl_input
--- a/dat.h
+++ b/dat.h
@@ -5,7 +5,6 @@
 enum{
 	Npath = 64,
 	Nfspath = 128,
-	Nmsg = 8000,
 	Nsav = 12,
 	Nsavcm = 40,
 	Nsavver = 5,
--- a/fs.c
+++ b/fs.c
@@ -757,7 +757,7 @@
 	VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
 	for(n=0, f=cl.mviewangles[0]; n<3; n++)
 		*f++ = getfl(demobf);
-	if(net_message.cursize > Nmsg)
+	if(net_message.cursize > NET_MAXMESSAGE)
 		fatal("readdm: invalid message size %d\n", net_message.cursize);
 	n = Bread(demobf, net_message.data, net_message.cursize);
 	demoofs = Bseek(demobf, 0, 1);
--- a/net.h
+++ b/net.h
@@ -11,7 +11,7 @@
 
 enum{
 	NET_NAMELEN = 64,
-	NET_MAXMESSAGE = 8192,
+	NET_MAXMESSAGE = 65000,
 	NET_HEADERSIZE = 4 + 4,
 	NET_DATAGRAMSIZE = MAX_DATAGRAM + NET_HEADERSIZE,
 
@@ -61,6 +61,7 @@
 	qboolean		disconnected;
 	qboolean		canSend;
 	qboolean		sendNext;
+	qboolean		local;
 	
 	int				driver;
 	int				landriver;
--- a/net_loop.c
+++ b/net_loop.c
@@ -44,6 +44,7 @@
 	loop_client->receiveMessageLength = 0;
 	loop_client->sendMessageLength = 0;
 	loop_client->canSend = true;
+	loop_client->local = true;
 
 	if (!loop_server)
 	{
@@ -57,10 +58,11 @@
 	loop_server->receiveMessageLength = 0;
 	loop_server->sendMessageLength = 0;
 	loop_server->canSend = true;
+	loop_server->local = true;
 
 	loop_client->driverdata = (void *)loop_server;
 	loop_server->driverdata = (void *)loop_client;
-	
+
 	return loop_client;	
 }
 
--- a/pr_exec.c
+++ b/pr_exec.c
@@ -10,11 +10,11 @@
 	dfunction_t		*f;
 } prstack_t;
 
-#define	MAX_STACK_DEPTH		32
+#define	MAX_STACK_DEPTH		2048
 prstack_t	pr_stack[MAX_STACK_DEPTH];
 int			pr_depth;
 
-#define	LOCALSTACK_SIZE		2048
+#define	LOCALSTACK_SIZE		32768
 int			localstack[LOCALSTACK_SIZE];
 int			localstack_used;
 
--- a/quakedef.h
+++ b/quakedef.h
@@ -26,12 +26,13 @@
 
 #define	ON_EPSILON		0.1			// point on plane side epsilon
 
-#define	MAX_DATAGRAM	1024		// max length of unreliable message
+#define	MAX_DATAGRAM	1400		// max length of unreliable message
+#define	MAX_DATAGRAM_LOCAL	65000	// on loopback we don't care
 
 //
 // per-level limits
 //
-#define	MAX_EDICTS		32000			// FIXME: ouch! ouch! ouch!
+#define	MAX_EDICTS		65536
 #define	Nlights	64
 #define	MAX_MODELS		4096			// these are sent over the net as bytes
 #define	MAX_SOUNDS		2048			// so they cannot be blindly increased
@@ -127,8 +128,6 @@
 
 #define	MAX_SCOREBOARD		16
 #define	MAX_SCOREBOARDNAME	32
-
-#define	SOUND_CHANNELS		8
 
 typedef unsigned char 		byte;
 typedef enum {false, true}	qboolean;
--- a/r_bsp.c
+++ b/r_bsp.c
@@ -488,7 +488,7 @@
 		mark = pleaf->firstmarksurface;
 		c = pleaf->nummarksurfaces;
 
-		if (c)
+		if (c && mark)
 		{
 			do
 			{
--- a/server.h
+++ b/server.h
@@ -44,7 +44,7 @@
 	byte		reliable_datagram_buf[MAX_DATAGRAM];
 
 	sizebuf_t	signon;
-	byte		signon_buf[8192];
+	byte		signon_buf[32768];
 } server_t;
 
 
@@ -67,7 +67,7 @@
 
 	sizebuf_t		message;			// can be added to at any time,
 										// copied and clear once per frame
-	byte			msgbuf[Nmsg];
+	byte			msgbuf[NET_MAXMESSAGE];
 	edict_t			*edict;				// EDICT_NUM(clientnum+1)
 	char			name[32];			// for printing to other people
 	int				colors;
--- a/sv_main.c
+++ b/sv_main.c
@@ -426,12 +426,12 @@
 			for (i=0 ; i < ent->num_leafs ; i++)
 				if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i]&7) ))
 					break;
-				
+
 			if (i == ent->num_leafs)
 				continue;		// not visible
 		}
 
-		if (msg->maxsize - msg->cursize < 16)
+		if (msg->cursize + 18 > msg->maxsize)
 		{
 			Con_Printf ("packet overflow\n");
 			return;
@@ -439,7 +439,7 @@
 
 // send an update
 		bits = 0;
-		
+
 		for (i=0 ; i<3 ; i++)
 		{
 			miss = ent->v.origin[i] - ent->baseline.origin[i];
@@ -682,11 +682,12 @@
 */
 qboolean SV_SendClientDatagram (client_t *client)
 {
-	byte		buf[MAX_DATAGRAM];
+	byte		buf[MAX_DATAGRAM_LOCAL];
 	sizebuf_t	msg;
-	
+
 	msg.data = buf;
-	msg.maxsize = sizeof buf;
+	// allow big messages locally, but otherwise (real world) we're forced to use 1400 at most
+	msg.maxsize = client->netconnection->local ? MAX_DATAGRAM_LOCAL : MAX_DATAGRAM;
 	msg.cursize = 0;
 
 	MSG_WriteByte (&msg, svc_time);