SZ_Clear(&sv.datagram);
}
-static void SV_WriteUnreliableMessages(client_t *client, sizebuf_t *msg, int maxsize)
+static void SV_WriteUnreliableMessages(client_t *client, sizebuf_t *msg, int maxsize, int maxsize2)
{
// scan the splitpoints to find out how many we can fit in
int numsegments, j, split;
// always accept the first one if it's within 1024 bytes, this ensures
// that very big datagrams which are over the rate limit still get
// through, just to keep it working
- j = msg->cursize + client->unreliablemsg_splitpoint[0];
- if (maxsize < 1024 && j > maxsize && j <= 1024)
- {
- numsegments = 1;
- maxsize = 1024;
- }
- else
- for (numsegments = 0;numsegments < client->unreliablemsg_splitpoints;numsegments++)
- if (msg->cursize + client->unreliablemsg_splitpoint[numsegments] > maxsize)
- break;
- if (numsegments > 0)
- {
- // some will fit, so add the ones that will fit
- split = client->unreliablemsg_splitpoint[numsegments-1];
- // note this discards ones that were accepted by the segments scan but
- // can not fit, such as a really huge first one that will never ever
- // fit in a packet...
- if (msg->cursize + split <= maxsize)
- SZ_Write(msg, client->unreliablemsg.data, split);
- // remove the part we sent, keeping any remaining data
- client->unreliablemsg.cursize -= split;
- if (client->unreliablemsg.cursize > 0)
- memmove(client->unreliablemsg.data, client->unreliablemsg.data + split, client->unreliablemsg.cursize);
- // adjust remaining splitpoints
- client->unreliablemsg_splitpoints -= numsegments;
- for (j = 0;j < client->unreliablemsg_splitpoints;j++)
- client->unreliablemsg_splitpoint[j] = client->unreliablemsg_splitpoint[numsegments + j] - split;
- }
+ for (numsegments = 1;numsegments < client->unreliablemsg_splitpoints;numsegments++)
+ if (msg->cursize + client->unreliablemsg_splitpoint[numsegments] > maxsize)
+ break;
+ // the first segment gets an exemption from the rate limiting, otherwise
+ // it could get dropped consistently due to a low rate limit
+ if (numsegments == 1)
+ maxsize = maxsize2;
+ // some will fit, so add the ones that will fit
+ split = client->unreliablemsg_splitpoint[numsegments-1];
+ // note this discards ones that were accepted by the segments scan but
+ // can not fit, such as a really huge first one that will never ever
+ // fit in a packet...
+ if (msg->cursize + split <= maxsize)
+ SZ_Write(msg, client->unreliablemsg.data, split);
+ // remove the part we sent, keeping any remaining data
+ client->unreliablemsg.cursize -= split;
+ if (client->unreliablemsg.cursize > 0)
+ memmove(client->unreliablemsg.data, client->unreliablemsg.data + split, client->unreliablemsg.cursize);
+ // adjust remaining splitpoints
+ client->unreliablemsg_splitpoints -= numsegments;
+ for (j = 0;j < client->unreliablemsg_splitpoints;j++)
+ client->unreliablemsg_splitpoint[j] = client->unreliablemsg_splitpoint[numsegments + j] - split;
}
/*
// add as many queued unreliable messages (effects) as we can fit
// limit effects to half of the remaining space
if (client->unreliablemsg.cursize)
- SV_WriteUnreliableMessages (client, &msg, (msg.cursize + maxsize) / 2);
+ SV_WriteUnreliableMessages (client, &msg, maxsize/2, maxsize2);
// now write as many entities as we can fit, and also sends stats
SV_WriteEntitiesToClient (client, client->edict, &msg, maxsize);