diff options
author | Thilo Schulz <arny@ats.s.bawue.de> | 2011-07-27 15:47:29 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-10 22:36:32 +0000 |
commit | 34e5d1056d0cd83648db904549a368ef904e2be8 (patch) | |
tree | 94f69d7546b28b8b8854b06526b70934a65c0dc0 /src/server/sv_snapshot.c | |
parent | d28ee7e3da161ae9a9e9f339291001948672dae7 (diff) |
- 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
Diffstat (limited to 'src/server/sv_snapshot.c')
-rw-r--r-- | src/server/sv_snapshot.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/server/sv_snapshot.c b/src/server/sv_snapshot.c index ddd87cc6..a16b6b2c 100644 --- a/src/server/sv_snapshot.c +++ b/src/server/sv_snapshot.c @@ -522,6 +522,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 @@ -605,11 +652,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)))) |