- Apply parts of Ben Millwood's target bitfield patch (#3787)

- Fix Ryan's FIXME and have voip packet buffer on the server dynamically allocated via Z_Malloc and store pointers in a circular buffer
- Improve voip target parsing on top of Ben Millwood's patch
- Add new "spatial" target where speaker is spatialized in 3d space and can be heard by all clients in hearing range (s_alMaxDistance)
  (#4467)
- Decrease voip sound lengths from 240ms to 80ms per voip packet to mitigate udp packet loss and decrease latency
- Protocol version incremented to 71
This commit is contained in:
Thilo Schulz 2011-07-27 15:47:29 +00:00
parent 41ac8a232a
commit 2349148cf1
19 changed files with 403 additions and 241 deletions

View file

@ -521,6 +521,53 @@ static void SV_BuildClientSnapshot( client_t *client ) {
}
}
#ifdef USE_VOIP
/*
==================
SV_WriteVoipToClient
Check to see if there is any VoIP queued for a client, and send if there is.
==================
*/
static void SV_WriteVoipToClient(client_t *cl, msg_t *msg)
{
int totalbytes = 0;
int i;
voipServerPacket_t *packet;
if(cl->queuedVoipPackets)
{
// Write as many VoIP packets as we reasonably can...
for(i = 0; i < cl->queuedVoipPackets; i++)
{
packet = cl->voipPacket[(i + cl->queuedVoipIndex) % ARRAY_LEN(cl->voipPacket)];
if(!*cl->downloadName)
{
totalbytes += packet->len;
if (totalbytes > (msg->maxsize - msg->cursize) / 2)
break;
MSG_WriteByte(msg, svc_voip);
MSG_WriteShort(msg, packet->sender);
MSG_WriteByte(msg, (byte) packet->generation);
MSG_WriteLong(msg, packet->sequence);
MSG_WriteByte(msg, packet->frames);
MSG_WriteShort(msg, packet->len);
MSG_WriteBits(msg, packet->flags, VOIP_FLAGCNT);
MSG_WriteData(msg, packet->data, packet->len);
}
Z_Free(packet);
}
cl->queuedVoipPackets -= i;
cl->queuedVoipIndex += i;
cl->queuedVoipIndex %= ARRAY_LEN(cl->voipPacket);
}
}
#endif
/*
=======================
SV_SendMessageToClient
@ -610,11 +657,11 @@ void SV_SendClientMessages(void)
if(*c->downloadName)
continue; // Client is downloading, don't send snapshots
if(c->netchan.unsentFragments || c->netchan_start_queue)
{
c->rateDelayed = qtrue;
if(c->netchan.unsentFragments || c->netchan_start_queue)
{
c->rateDelayed = qtrue;
continue; // Drop this snapshot if the packet queue is still full or delta compression will break
}
}
if(!(c->netchan.remoteAddress.type == NA_LOOPBACK ||
(sv_lanForceRate->integer && Sys_IsLANAddress(c->netchan.remoteAddress))))