char vabuf2[1024];
cvar_t *cvar;
int structtype = 0;
+ int max_safe_edicts;
if (prog->loaded)
prog->error_cmd("%s: there is already a %s program loaded!", __func__, prog->name);
PRVM_FindOffsets(prog);
+ // Do not allow more than 2^31 total entityfields. Achieve this by limiting maximum edict count.
+ max_safe_edicts = ((1 << 31) - prog->numglobals) / prog->entityfields;
+ if (prog->limit_edicts > max_safe_edicts)
+ {
+ Con_Printf("%s: reducing maximum entity count to %d to avoid address overflow in %s\n", __func__, max_safe_edicts, prog->name);
+ prog->limit_edicts = max_safe_edicts;
+ }
+
prog->init_cmd(prog);
// init mempools
// first reset them all
host_client->download_deflate = false;
-
+
for(i = 2; i < argc; ++i)
{
if(!strcmp(Cmd_Argv(cmd, i), "deflate"))
}
is_csqc = (sv.csqc_progname[0] && strcmp(Cmd_Argv(cmd, 1), sv.csqc_progname) == 0);
-
+
if (!sv_allowdownloads.integer && !is_csqc)
{
SV_ClientPrintf("Downloads are disabled on this server\n");
{
char extensions[MAX_QPATH]; // make sure this can hold all extensions
extensions[0] = '\0';
-
+
if(host_client->download_deflate)
dp_strlcat(extensions, " deflate", sizeof(extensions));
-
+
Con_DPrintf("Downloading %s to %s\n", host_client->download_name, host_client->name);
if(host_client->download_deflate && svs.csqc_progdata_deflated)
host_client->download_file = FS_FileFromData(svs.csqc_progdata_deflated, svs.csqc_progsize_deflated, true);
else
host_client->download_file = FS_FileFromData(svs.csqc_progdata, sv.csqc_progsize, true);
-
+
// no, no space is needed between %s and %s :P
SV_ClientCommands("\ncl_downloadbegin %i %s%s\n", (int)FS_FileSize(host_client->download_file), host_client->download_name, extensions);
{
char extensions[MAX_QPATH]; // make sure this can hold all extensions
extensions[0] = '\0';
-
+
if(host_client->download_deflate)
strlcat(extensions, " deflate", sizeof(extensions));
svs.csqc_progdata = NULL;
svs.csqc_progdata_deflated = NULL;
-
+
sv.csqc_progname[0] = 0;
svs.csqc_progdata = FS_LoadFile(csqc_progname.string, sv_mempool, false, &progsize);
++sv.perf_acc_offset_samples;
sv.perf_acc_offset += offset;
sv.perf_acc_offset_squared += offset * offset;
-
+
if(sv.perf_acc_offset_max < offset)
sv.perf_acc_offset_max = offset;
}