From: havoc Date: Sun, 27 Jul 2003 05:13:27 +0000 (+0000) Subject: added MAX_PACKETFRAGMENT to limit size of reliable packets, and also try to keep... X-Git-Tag: xonotic-v0.1.0preview~6474 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7fee05b0d2478692853c585d1f6d0bf3fbc1afd2;p=xonotic%2Fdarkplaces.git added MAX_PACKETFRAGMENT to limit size of reliable packets, and also try to keep effects from pushing it over the limit either, this means the only possible way to push it over the limit is entity updates, and if exceeding the limit the packets might be lost, possibly dropping the player... but at least everything else should work now. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3338 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/netconn.c b/netconn.c index 363fbb9e..c7dc5336 100755 --- a/netconn.c +++ b/netconn.c @@ -143,14 +143,14 @@ int NetConn_SendReliableMessage(netconn_t *conn, sizebuf_t *data) memcpy(conn->sendMessage, data->data, data->cursize); conn->sendMessageLength = data->cursize; - if (conn->sendMessageLength <= MAX_DATAGRAM) + if (conn->sendMessageLength <= MAX_PACKETFRAGMENT) { dataLen = conn->sendMessageLength; eom = NETFLAG_EOM; } else { - dataLen = MAX_DATAGRAM; + dataLen = MAX_PACKETFRAGMENT; eom = 0; } @@ -182,14 +182,14 @@ static void NetConn_SendMessageNext(netconn_t *conn) if (conn->sendMessageLength && !conn->canSend && conn->sendNext) { - if (conn->sendMessageLength <= MAX_DATAGRAM) + if (conn->sendMessageLength <= MAX_PACKETFRAGMENT) { dataLen = conn->sendMessageLength; eom = NETFLAG_EOM; } else { - dataLen = MAX_DATAGRAM; + dataLen = MAX_PACKETFRAGMENT; eom = 0; } @@ -220,14 +220,14 @@ static void NetConn_ReSendMessage(netconn_t *conn) if (conn->sendMessageLength && !conn->canSend && (realtime - conn->lastSendTime) > 1.0) { - if (conn->sendMessageLength <= MAX_DATAGRAM) + if (conn->sendMessageLength <= MAX_PACKETFRAGMENT) { dataLen = conn->sendMessageLength; eom = NETFLAG_EOM; } else { - dataLen = MAX_DATAGRAM; + dataLen = MAX_PACKETFRAGMENT; eom = 0; } @@ -479,10 +479,10 @@ int NetConn_ReceivedMessage(netconn_t *conn, qbyte *data, int length) Con_DPrintf("ack sequencing error\n"); conn->lastMessageTime = realtime; conn->timeout = realtime + net_messagetimeout.value; - conn->sendMessageLength -= MAX_DATAGRAM; + conn->sendMessageLength -= MAX_PACKETFRAGMENT; if (conn->sendMessageLength > 0) { - memcpy(conn->sendMessage, conn->sendMessage+MAX_DATAGRAM, conn->sendMessageLength); + memcpy(conn->sendMessage, conn->sendMessage+MAX_PACKETFRAGMENT, conn->sendMessageLength); conn->sendNext = true; NetConn_SendMessageNext(conn); } diff --git a/quakedef.h b/quakedef.h index bd9ca3c1..4ab90481 100644 --- a/quakedef.h +++ b/quakedef.h @@ -45,6 +45,7 @@ extern char *buildstring; #define ON_EPSILON 0.1 // point on plane side epsilon +#define MAX_PACKETFRAGMENT 1024 // max length of packet fragment // LordHavoc: this was 1024, now 65536 #define MAX_DATAGRAM 65536 // max length of unreliable #define MAX_NETRELIABLE 65536 // max length of reliable message (fragments into unreliable packets) diff --git a/sv_main.c b/sv_main.c index d9fb0507..d7db4ef9 100644 --- a/sv_main.c +++ b/sv_main.c @@ -94,7 +94,7 @@ void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count) { int i, v; - if (sv.datagram.cursize > MAX_DATAGRAM-16) + if (sv.datagram.cursize > MAX_PACKETFRAGMENT-18) return; MSG_WriteByte (&sv.datagram, svc_particle); MSG_WriteDPCoord (&sv.datagram, org[0]); @@ -122,10 +122,10 @@ Make sure the event gets sent to all clients */ void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate) { - if (sv.datagram.cursize > MAX_DATAGRAM-18) - return; if (modelindex >= 256 || startframe >= 256) { + if (sv.datagram.cursize > MAX_PACKETFRAGMENT-19) + return; MSG_WriteByte (&sv.datagram, svc_effect2); MSG_WriteDPCoord (&sv.datagram, org[0]); MSG_WriteDPCoord (&sv.datagram, org[1]); @@ -137,6 +137,8 @@ void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, } else { + if (sv.datagram.cursize > MAX_PACKETFRAGMENT-17) + return; MSG_WriteByte (&sv.datagram, svc_effect); MSG_WriteDPCoord (&sv.datagram, org[0]); MSG_WriteDPCoord (&sv.datagram, org[1]); @@ -176,7 +178,7 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, floa if (channel < 0 || channel > 7) Host_Error ("SV_StartSound: channel = %i", channel); - if (sv.datagram.cursize > MAX_DATAGRAM-16) + if (sv.datagram.cursize > MAX_PACKETFRAGMENT-21) return; // find precache number for sound