mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-29 16:24:16 +00:00
engine: netchan: fixed fragbufs very high memory usage
This commit is contained in:
parent
d72481e5ac
commit
840283d6e5
@ -414,6 +414,7 @@ void Netchan_ClearFragbufs( fragbuf_t **ppbuf )
|
|||||||
while( buf )
|
while( buf )
|
||||||
{
|
{
|
||||||
n = buf->next;
|
n = buf->next;
|
||||||
|
Mem_Free( buf->frag_message_buf );
|
||||||
Mem_Free( buf );
|
Mem_Free( buf );
|
||||||
buf = n;
|
buf = n;
|
||||||
}
|
}
|
||||||
@ -535,12 +536,13 @@ Netchan_AllocFragbuf
|
|||||||
|
|
||||||
==============================
|
==============================
|
||||||
*/
|
*/
|
||||||
fragbuf_t *Netchan_AllocFragbuf( void )
|
fragbuf_t *Netchan_AllocFragbuf( int fragment_size )
|
||||||
{
|
{
|
||||||
fragbuf_t *buf;
|
fragbuf_t *buf;
|
||||||
|
|
||||||
buf = (fragbuf_t *)Mem_Calloc( net_mempool, sizeof( fragbuf_t ));
|
buf = (fragbuf_t *)Mem_Calloc( net_mempool, sizeof( fragbuf_t ));
|
||||||
MSG_Init( &buf->frag_message, "Frag Message", buf->frag_message_buf, sizeof( buf->frag_message_buf ));
|
buf->frag_message_buf = (byte *)Mem_Calloc( net_mempool, fragment_size );
|
||||||
|
MSG_Init( &buf->frag_message, "Frag Message", buf->frag_message_buf, fragment_size );
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -736,7 +738,7 @@ static void Netchan_CreateFragments_( netchan_t *chan, sizebuf_t *msg )
|
|||||||
bytes = Q_min( remaining, chunksize );
|
bytes = Q_min( remaining, chunksize );
|
||||||
remaining -= bytes;
|
remaining -= bytes;
|
||||||
|
|
||||||
buf = Netchan_AllocFragbuf();
|
buf = Netchan_AllocFragbuf( bytes );
|
||||||
buf->bufferid = bufferid++;
|
buf->bufferid = bufferid++;
|
||||||
|
|
||||||
// Copy in data
|
// Copy in data
|
||||||
@ -803,7 +805,7 @@ fragbuf_t *Netchan_FindBufferById( fragbuf_t **pplist, int id, qboolean allocate
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// create new entry
|
// create new entry
|
||||||
pnewbuf = Netchan_AllocFragbuf();
|
pnewbuf = Netchan_AllocFragbuf( NET_MAX_FRAGMENT );
|
||||||
pnewbuf->bufferid = id;
|
pnewbuf->bufferid = id;
|
||||||
Netchan_AddBufferToList( pplist, pnewbuf );
|
Netchan_AddBufferToList( pplist, pnewbuf );
|
||||||
|
|
||||||
@ -894,7 +896,7 @@ void Netchan_CreateFileFragmentsFromBuffer( netchan_t *chan, const char *filenam
|
|||||||
{
|
{
|
||||||
send = Q_min( remaining, chunksize );
|
send = Q_min( remaining, chunksize );
|
||||||
|
|
||||||
buf = Netchan_AllocFragbuf();
|
buf = Netchan_AllocFragbuf( send );
|
||||||
buf->bufferid = bufferid++;
|
buf->bufferid = bufferid++;
|
||||||
|
|
||||||
// copy in data
|
// copy in data
|
||||||
@ -959,7 +961,7 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
|
|||||||
qboolean bCompressed = false;
|
qboolean bCompressed = false;
|
||||||
fragbufwaiting_t *wait, *p;
|
fragbufwaiting_t *wait, *p;
|
||||||
fragbuf_t *buf;
|
fragbuf_t *buf;
|
||||||
|
|
||||||
if(( filesize = FS_FileSize( filename, false )) <= 0 )
|
if(( filesize = FS_FileSize( filename, false )) <= 0 )
|
||||||
{
|
{
|
||||||
Con_Printf( S_WARN "Unable to open %s for transfer\n", filename );
|
Con_Printf( S_WARN "Unable to open %s for transfer\n", filename );
|
||||||
@ -1013,7 +1015,7 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
|
|||||||
{
|
{
|
||||||
send = Q_min( remaining, chunksize );
|
send = Q_min( remaining, chunksize );
|
||||||
|
|
||||||
buf = Netchan_AllocFragbuf();
|
buf = Netchan_AllocFragbuf( send );
|
||||||
buf->bufferid = bufferid++;
|
buf->bufferid = bufferid++;
|
||||||
|
|
||||||
// copy in data
|
// copy in data
|
||||||
|
@ -185,7 +185,7 @@ typedef struct fragbuf_s
|
|||||||
struct fragbuf_s *next; // next buffer in chain
|
struct fragbuf_s *next; // next buffer in chain
|
||||||
int bufferid; // id of this buffer
|
int bufferid; // id of this buffer
|
||||||
sizebuf_t frag_message; // message buffer where raw data is stored
|
sizebuf_t frag_message; // message buffer where raw data is stored
|
||||||
byte frag_message_buf[NET_MAX_FRAGMENT]; // the actual data sits here
|
byte *frag_message_buf; // the actual data sits here
|
||||||
qboolean isfile; // is this a file buffer?
|
qboolean isfile; // is this a file buffer?
|
||||||
qboolean isbuffer; // is this file buffer from memory ( custom decal, etc. ).
|
qboolean isbuffer; // is this file buffer from memory ( custom decal, etc. ).
|
||||||
qboolean iscompressed; // is compressed file, we should using filename.ztmp
|
qboolean iscompressed; // is compressed file, we should using filename.ztmp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user