- Improve snapshot rate and data rate control
- Make server send packet fragments and queued packets when server is idle - Voip protocol detection is tied to com_protocol making past-end-of-message reading unncessary - Use Hunk_AllocateTempMemory() for buffering VOIP packets and fix buffering scheme that ryan hates so much - Disable packet scrambling for new protocol as it is useless now - Get rid of the old packet scrambling functions predating latest point release - Use Hunk_AllocateTempMemory() for netchan packet queue to fix memory leak when client gets disconnected with packets in the queue - Use Hunk_AllocateTempMemory() for download blocks to fix memory leak when client gets disconnected with download blocks in the queue - Fix SV_RateMsec to account for udp/udp6 packet lengths
This commit is contained in:
parent
a844c94af1
commit
ac30d86db0
15 changed files with 345 additions and 356 deletions
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "../qcommon/qcommon.h"
|
||||
#include "server.h"
|
||||
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
/*
|
||||
==============
|
||||
SV_Netchan_Encode
|
||||
|
@ -127,38 +128,63 @@ static void SV_Netchan_Decode( client_t *client, msg_t *msg ) {
|
|||
*(msg->data + i) = *(msg->data + i) ^ key;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
=================
|
||||
SV_Netchan_TransmitNextInQueue
|
||||
=================
|
||||
*/
|
||||
void SV_Netchan_TransmitNextInQueue(client_t *client)
|
||||
{
|
||||
netchan_buffer_t *netbuf;
|
||||
|
||||
Com_DPrintf("#462 Netchan_TransmitNextFragment: popping a queued message for transmit\n");
|
||||
netbuf = client->netchan_start_queue;
|
||||
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
if(client->compat)
|
||||
SV_Netchan_Encode(client, &netbuf->msg);
|
||||
#endif
|
||||
|
||||
Netchan_Transmit(&client->netchan, netbuf->msg.cursize, netbuf->msg.data);
|
||||
|
||||
// pop from queue
|
||||
client->netchan_start_queue = netbuf->next;
|
||||
if(!client->netchan_start_queue)
|
||||
{
|
||||
Com_DPrintf("#462 Netchan_TransmitNextFragment: emptied queue\n");
|
||||
client->netchan_end_queue = &client->netchan_start_queue;
|
||||
}
|
||||
else
|
||||
Com_DPrintf("#462 Netchan_TransmitNextFragment: remaining queued message\n");
|
||||
|
||||
Hunk_FreeTempMemory(netbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
SV_Netchan_TransmitNextFragment
|
||||
Transmit the next fragment and the next queued packet
|
||||
Return number of ms until next message can be sent based on throughput given by client rate,
|
||||
-1 if no packet was sent.
|
||||
=================
|
||||
*/
|
||||
void SV_Netchan_TransmitNextFragment( client_t *client ) {
|
||||
Netchan_TransmitNextFragment( &client->netchan );
|
||||
if (!client->netchan.unsentFragments)
|
||||
|
||||
int SV_Netchan_TransmitNextFragment(client_t *client)
|
||||
{
|
||||
if(client->netchan.unsentFragments)
|
||||
{
|
||||
// make sure the netchan queue has been properly initialized (you never know)
|
||||
if ((!client->netchan_end_queue) && (client->state >= CS_CONNECTED)) {
|
||||
Com_Error(ERR_DROP, "netchan queue is not properly initialized in SV_Netchan_TransmitNextFragment");
|
||||
}
|
||||
// the last fragment was transmitted, check wether we have queued messages
|
||||
if (client->netchan_start_queue) {
|
||||
netchan_buffer_t *netbuf;
|
||||
Com_DPrintf("#462 Netchan_TransmitNextFragment: popping a queued message for transmit\n");
|
||||
netbuf = client->netchan_start_queue;
|
||||
SV_Netchan_Encode( client, &netbuf->msg );
|
||||
Netchan_Transmit( &client->netchan, netbuf->msg.cursize, netbuf->msg.data );
|
||||
// pop from queue
|
||||
client->netchan_start_queue = netbuf->next;
|
||||
if (!client->netchan_start_queue) {
|
||||
Com_DPrintf("#462 Netchan_TransmitNextFragment: emptied queue\n");
|
||||
client->netchan_end_queue = &client->netchan_start_queue;
|
||||
}
|
||||
else
|
||||
Com_DPrintf("#462 Netchan_TransmitNextFragment: remaining queued message\n");
|
||||
Z_Free(netbuf);
|
||||
}
|
||||
}
|
||||
Netchan_TransmitNextFragment(&client->netchan);
|
||||
return SV_RateMsec(client);
|
||||
}
|
||||
else if(client->netchan_start_queue)
|
||||
{
|
||||
SV_Netchan_TransmitNextInQueue(client);
|
||||
return SV_RateMsec(client);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,22 +199,28 @@ then buffer them and make sure they get sent in correct order
|
|||
================
|
||||
*/
|
||||
|
||||
void SV_Netchan_Transmit( client_t *client, msg_t *msg) { //int length, const byte *data ) {
|
||||
void SV_Netchan_Transmit( client_t *client, msg_t *msg)
|
||||
{
|
||||
MSG_WriteByte( msg, svc_EOF );
|
||||
if (client->netchan.unsentFragments) {
|
||||
|
||||
if(client->netchan.unsentFragments || client->netchan_start_queue)
|
||||
{
|
||||
netchan_buffer_t *netbuf;
|
||||
Com_DPrintf("#462 SV_Netchan_Transmit: unsent fragments, stacked\n");
|
||||
netbuf = (netchan_buffer_t *)Z_Malloc(sizeof(netchan_buffer_t));
|
||||
netbuf = (netchan_buffer_t *) Hunk_AllocateTempMemory(sizeof(netchan_buffer_t));
|
||||
// store the msg, we can't store it encoded, as the encoding depends on stuff we still have to finish sending
|
||||
MSG_Copy(&netbuf->msg, netbuf->msgBuffer, sizeof( netbuf->msgBuffer ), msg);
|
||||
netbuf->next = NULL;
|
||||
// insert it in the queue, the message will be encoded and sent later
|
||||
*client->netchan_end_queue = netbuf;
|
||||
client->netchan_end_queue = &(*client->netchan_end_queue)->next;
|
||||
// emit the next fragment of the current message for now
|
||||
Netchan_TransmitNextFragment(&client->netchan);
|
||||
} else {
|
||||
SV_Netchan_Encode( client, msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
if(client->compat)
|
||||
SV_Netchan_Encode(client, msg);
|
||||
#endif
|
||||
Netchan_Transmit( &client->netchan, msg->cursize, msg->data );
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +235,12 @@ qboolean SV_Netchan_Process( client_t *client, msg_t *msg ) {
|
|||
ret = Netchan_Process( &client->netchan, msg );
|
||||
if (!ret)
|
||||
return qfalse;
|
||||
SV_Netchan_Decode( client, msg );
|
||||
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
if(client->compat)
|
||||
SV_Netchan_Decode(client, msg);
|
||||
#endif
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue