mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-17 17:17:56 +03:00
Fixed MAX_FRAGMENTS value for customizations (#114 now really fixed)
Fixed mistake in Netchan_CreateFileFragmentsFromBuffer (fixed customization downloading) Added sv_rehlds_force_dlmax cvar Corrected FRAGMENT_MAX_SIZE value
This commit is contained in:
parent
ac413a748e
commit
beaeb65138
@ -248,13 +248,26 @@ typedef struct flow_s
|
|||||||
float avgkbytespersec;
|
float avgkbytespersec;
|
||||||
} flow_t;
|
} flow_t;
|
||||||
|
|
||||||
// Size of fragmentation buffer internal buffers
|
#define FRAGMENT_C2S_MIN_SIZE 16
|
||||||
#define FRAGMENT_SIZE 1400
|
#define FRAGMENT_S2C_MIN_SIZE 256
|
||||||
|
#define FRAGMENT_S2C_MAX_SIZE 1024
|
||||||
|
#define CLIENT_FRAGMENT_SIZE_ONCONNECT 128
|
||||||
|
#define CUSTOMIZATION_MAX_SIZE 20480
|
||||||
|
|
||||||
#ifndef REHLDS_FIXES
|
#ifndef REHLDS_FIXES
|
||||||
|
// Size of fragmentation buffer internal buffers
|
||||||
|
#define FRAGMENT_MAX_SIZE 1400
|
||||||
|
|
||||||
#define MAX_FRAGMENTS 25000
|
#define MAX_FRAGMENTS 25000
|
||||||
#else
|
#else
|
||||||
#define MAX_FRAGMENTS (NET_MAX_PAYLOAD / FRAGMENT_SIZE) // should be enough for any send buf
|
#define FRAGMENT_MAX_SIZE 1024
|
||||||
|
|
||||||
|
// Client sends normal fragments only while connecting
|
||||||
|
#define MAX_NORMAL_FRAGMENTS (NET_MAX_PAYLOAD / CLIENT_FRAGMENT_SIZE_ONCONNECT)
|
||||||
|
|
||||||
|
// While client is connecting it sending fragments with minimal size, also it transfers sprays with minimal fragments...
|
||||||
|
// But with sv_delayed_spray_upload it sends with cl_dlmax fragment size
|
||||||
|
#define MAX_FILE_FRAGMENTS (CUSTOMIZATION_MAX_SIZE / FRAGMENT_C2S_MIN_SIZE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UDP_HEADER_SIZE 28
|
#define UDP_HEADER_SIZE 28
|
||||||
@ -278,7 +291,7 @@ typedef struct fragbuf_s
|
|||||||
// Message buffer where raw data is stored
|
// Message buffer where raw data is stored
|
||||||
sizebuf_t frag_message;
|
sizebuf_t frag_message;
|
||||||
// The actual data sits here
|
// The actual data sits here
|
||||||
byte frag_message_buf[FRAGMENT_SIZE];
|
byte frag_message_buf[FRAGMENT_MAX_SIZE];
|
||||||
// Is this a file buffer?
|
// Is this a file buffer?
|
||||||
qboolean isfile;
|
qboolean isfile;
|
||||||
// Is this file buffer from memory ( custom decal, etc. ).
|
// Is this file buffer from memory ( custom decal, etc. ).
|
||||||
|
@ -675,10 +675,15 @@ qboolean Netchan_Validate(netchan_t *chan, qboolean *frag_message, unsigned int
|
|||||||
}
|
}
|
||||||
#else // REHLDS_FIXES
|
#else // REHLDS_FIXES
|
||||||
// total fragments should be <= MAX_FRAGMENTS and current fragment can't be > total fragments
|
// total fragments should be <= MAX_FRAGMENTS and current fragment can't be > total fragments
|
||||||
if (FRAG_GETCOUNT(fragid[i]) > MAX_FRAGMENTS || FRAG_GETID(fragid[i]) > FRAG_GETCOUNT(fragid[i]))
|
if (i == FRAG_NORMAL_STREAM && FRAG_GETCOUNT(fragid[i]) > MAX_NORMAL_FRAGMENTS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (i == FRAG_FILE_STREAM && FRAG_GETCOUNT(fragid[i]) > MAX_FILE_FRAGMENTS)
|
||||||
if ((size_t)frag_length[i] > FRAGMENT_SIZE || (size_t)frag_offset[i] > NET_MAX_PAYLOAD - 1)
|
return FALSE;
|
||||||
|
if (FRAG_GETID(fragid[i]) > FRAG_GETCOUNT(fragid[i]))
|
||||||
|
return FALSE;
|
||||||
|
if (!frag_length[i])
|
||||||
|
return FALSE;
|
||||||
|
if ((size_t)frag_length[i] > FRAGMENT_MAX_SIZE || (size_t)frag_offset[i] > NET_MAX_PAYLOAD - 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
int frag_end = frag_offset[i] + frag_length[i];
|
int frag_end = frag_offset[i] + frag_length[i];
|
||||||
@ -1006,7 +1011,7 @@ fragbuf_t *Netchan_AllocFragbuf(void)
|
|||||||
buf->bufferid = 0;
|
buf->bufferid = 0;
|
||||||
buf->frag_message.cursize = 0;
|
buf->frag_message.cursize = 0;
|
||||||
buf->frag_message.data = buf->frag_message_buf;
|
buf->frag_message.data = buf->frag_message_buf;
|
||||||
buf->frag_message.maxsize = FRAGMENT_SIZE;
|
buf->frag_message.maxsize = sizeof(buf->frag_message_buf);
|
||||||
buf->frag_message.buffername = "Frag Buffer Alloc'd";
|
buf->frag_message.buffername = "Frag Buffer Alloc'd";
|
||||||
buf->next = 0;
|
buf->next = 0;
|
||||||
|
|
||||||
@ -1067,12 +1072,7 @@ void Netchan_CreateFragments_(qboolean server, netchan_t *chan, sizebuf_t *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef REHLDS_FIXES
|
|
||||||
chunksize = clamp(chan->pfnNetchan_Blocksize(chan->connection_status), 64, 1200);
|
|
||||||
#else
|
|
||||||
chunksize = chan->pfnNetchan_Blocksize(chan->connection_status);
|
chunksize = chan->pfnNetchan_Blocksize(chan->connection_status);
|
||||||
#endif // REHLDS_FIXES
|
|
||||||
|
|
||||||
|
|
||||||
wait = (fragbufwaiting_t *)Mem_ZeroMalloc(sizeof(fragbufwaiting_t));
|
wait = (fragbufwaiting_t *)Mem_ZeroMalloc(sizeof(fragbufwaiting_t));
|
||||||
|
|
||||||
@ -1144,7 +1144,7 @@ void Netchan_CreateFileFragmentsFromBuffer(qboolean server, netchan_t *chan, con
|
|||||||
unsigned int size;
|
unsigned int size;
|
||||||
fragbufwaiting_t *wait;
|
fragbufwaiting_t *wait;
|
||||||
|
|
||||||
if (!uncompressed_size == 0)
|
if (!uncompressed_size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bufferid = 1;
|
bufferid = 1;
|
||||||
|
@ -542,6 +542,7 @@ extern cvar_t sv_version;
|
|||||||
extern cvar_t sv_echo_unknown_cmd;
|
extern cvar_t sv_echo_unknown_cmd;
|
||||||
extern cvar_t sv_auto_precache_sounds_in_models;
|
extern cvar_t sv_auto_precache_sounds_in_models;
|
||||||
extern cvar_t sv_delayed_spray_upload;
|
extern cvar_t sv_delayed_spray_upload;
|
||||||
|
extern cvar_t sv_rehlds_force_dlmax;
|
||||||
#endif
|
#endif
|
||||||
extern int sv_playermodel;
|
extern int sv_playermodel;
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ cvar_t sv_version = { "sv_version", "", FCVAR_SERVER, 0.0f, NULL };
|
|||||||
cvar_t sv_echo_unknown_cmd = { "sv_echo_unknown_cmd", "0", 0, 0.0f, NULL };
|
cvar_t sv_echo_unknown_cmd = { "sv_echo_unknown_cmd", "0", 0, 0.0f, NULL };
|
||||||
cvar_t sv_auto_precache_sounds_in_models = { "sv_auto_precache_sounds_in_models", "0", 0, 0.0f, nullptr };
|
cvar_t sv_auto_precache_sounds_in_models = { "sv_auto_precache_sounds_in_models", "0", 0, 0.0f, nullptr };
|
||||||
cvar_t sv_delayed_spray_upload = { "sv_delayed_spray_upload", "0", 0, 0.0f, nullptr };
|
cvar_t sv_delayed_spray_upload = { "sv_delayed_spray_upload", "0", 0, 0.0f, nullptr };
|
||||||
|
cvar_t sv_rehlds_force_dlmax = { "sv_rehlds_force_dlmax", "0", 0, 0.0f, nullptr };
|
||||||
#else
|
#else
|
||||||
cvar_t sv_version = {"sv_version", "", 0, 0.0f, NULL};
|
cvar_t sv_version = {"sv_version", "", 0, 0.0f, NULL};
|
||||||
#endif
|
#endif
|
||||||
@ -1777,17 +1778,21 @@ void SV_RejectConnectionForPassword(netadr_t *adr)
|
|||||||
/* <a5bce> ../engine/sv_main.c:2230 */
|
/* <a5bce> ../engine/sv_main.c:2230 */
|
||||||
int SV_GetFragmentSize(void *state)
|
int SV_GetFragmentSize(void *state)
|
||||||
{
|
{
|
||||||
int size = 1024;
|
int size = FRAGMENT_S2C_MAX_SIZE;
|
||||||
client_t *cl = (client_t *)state;
|
client_t *cl = (client_t *)state;
|
||||||
|
|
||||||
|
#ifdef REHLDS_FIXES
|
||||||
|
if (cl->active && cl->spawned && cl->connected && cl->fully_connected && !sv_rehlds_force_dlmax.value)
|
||||||
|
#else // REHLDS_FIXES
|
||||||
if (cl->active && cl->spawned && cl->connected && cl->fully_connected)
|
if (cl->active && cl->spawned && cl->connected && cl->fully_connected)
|
||||||
|
#endif // REHLDS_FIXES
|
||||||
{
|
{
|
||||||
size = 256;
|
size = FRAGMENT_S2C_MIN_SIZE;
|
||||||
const char *val = Info_ValueForKey(cl->userinfo, "cl_dlmax");
|
const char *val = Info_ValueForKey(cl->userinfo, "cl_dlmax");
|
||||||
if (val[0] != 0)
|
if (val[0] != 0)
|
||||||
{
|
{
|
||||||
size = Q_atoi( val );
|
size = Q_atoi( val );
|
||||||
size = clamp(size, 256, 1024);
|
size = clamp(size, FRAGMENT_S2C_MIN_SIZE, FRAGMENT_S2C_MAX_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7758,6 +7763,7 @@ void SV_Init(void)
|
|||||||
Cvar_RegisterVariable(&sv_echo_unknown_cmd);
|
Cvar_RegisterVariable(&sv_echo_unknown_cmd);
|
||||||
Cvar_RegisterVariable(&sv_auto_precache_sounds_in_models);
|
Cvar_RegisterVariable(&sv_auto_precache_sounds_in_models);
|
||||||
Cvar_RegisterVariable(&sv_delayed_spray_upload);
|
Cvar_RegisterVariable(&sv_delayed_spray_upload);
|
||||||
|
Cvar_RegisterVariable(&sv_rehlds_force_dlmax);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < MAX_MODELS; i++)
|
for (int i = 0; i < MAX_MODELS; i++)
|
||||||
|
@ -1837,6 +1837,12 @@ void SV_SendEnts_f(void)
|
|||||||
// TODO: all this is already checked earlier
|
// TODO: all this is already checked earlier
|
||||||
if (res->ucFlags & RES_WASMISSING && res->type == t_decal && res->ucFlags & RES_CUSTOM)
|
if (res->ucFlags & RES_WASMISSING && res->type == t_decal && res->ucFlags & RES_CUSTOM)
|
||||||
{
|
{
|
||||||
|
if (sv_rehlds_force_dlmax.value)
|
||||||
|
{
|
||||||
|
MSG_WriteByte(&host_client->netchan.message, svc_stufftext);
|
||||||
|
MSG_WriteString(&host_client->netchan.message, va("cl_dlmax %i\n", FRAGMENT_MAX_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
MSG_WriteByte(&host_client->netchan.message, svc_stufftext);
|
MSG_WriteByte(&host_client->netchan.message, svc_stufftext);
|
||||||
MSG_WriteString(&host_client->netchan.message, va("upload !MD5%s\n", MD5_Print(res->rgucMD5_hash)));
|
MSG_WriteString(&host_client->netchan.message, va("upload !MD5%s\n", MD5_Print(res->rgucMD5_hash)));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user