diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index 517b363ff..647a690d8 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -127,7 +127,7 @@ qofs_t PR_ReadBytesString(char *str) double d = strtod(str, &str); if (d < 0) { -#if defined(_WIN64) && !defined(WINRT) +#if (defined(_WIN64) && !defined(WINRT)) || (defined(__linux__)&&defined(__LP64__)) return 0x80000000; //use of virtual address space rather than physical memory means we can just go crazy and use the max of 2gb. #elif defined(FTE_TARGET_WEB) return 8*1024*1024; diff --git a/engine/qclib/progslib.h b/engine/qclib/progslib.h index 1d78d5c60..885dbc0da 100644 --- a/engine/qclib/progslib.h +++ b/engine/qclib/progslib.h @@ -181,8 +181,8 @@ struct pubprogfuncs_s int callargc; //number of args of built-in call char *stringtable; //qc strings are all relative. add to a qc string. this is required for support of frikqcc progs that strip string immediates. - int stringtablesize; - int stringtablemaxsize; + unsigned int stringtablesize; + unsigned int stringtablemaxsize; int fieldadjust; //FrikQCC style arrays can cause problems due to field remapping. This causes us to leave gaps but offsets identical. except for system fields, qc-addressable variables use their old offsets, this is the bias so that the offset pokes the correct memory. unsigned int activefieldslots; //f+=fieldadjust; invalidfield = (f<0)||(f+fldsize>=activefieldslots); note that this does NOT apply to 'object' entities which are variable sized, use ed->fieldsize for those. diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 4ee1b57fd..8954ab26b 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -73,7 +73,7 @@ cvar_t pr_ssqc_memsize = CVARD("pr_ssqc_memsize", "-1", "The ammount of memory a cvar_t pr_imitatemvdsv = CVARFD("pr_imitatemvdsv", "0", CVAR_MAPLATCH, "Enables mvdsv-specific builtins, and fakes identifiers so that mods made for mvdsv can run properly and with the full feature set."); /*other stuff*/ -cvar_t pr_maxedicts = CVARAFD("pr_maxedicts", "32768", "max_edicts", CVAR_MAPLATCH, "Maximum number of entities spawnable on the map at once. Low values will crash the server on some maps/mods. High values will result in excessive memory useage (see pr_ssqc_memsize). Illegible server messages may occur with old/other clients above 32k. FTE's network protocols have a maximum at a little over 4 million. Please don't ever make a mod that actually uses that many..."); +cvar_t pr_maxedicts = CVARAFD("pr_maxedicts", "131072", "max_edicts", CVAR_MAPLATCH, "Maximum number of entities spawnable on the map at once. Low values will crash the server on some maps/mods. High values will result in excessive memory useage (see pr_ssqc_memsize). Illegible server messages may occur with old/other clients above 32k. FTE's network protocols have a maximum at a little over 4 million. Please don't ever make a mod that actually uses that many..."); #ifndef HAVE_LEGACY cvar_t pr_no_playerphysics = CVARFD("pr_no_playerphysics", "1", CVAR_MAPLATCH, "Prevents support of the 'SV_PlayerPhysics' QC function. This allows servers to prevent needless breakage of player prediction."); diff --git a/engine/server/sv_ccmds.c b/engine/server/sv_ccmds.c index 6578a87a7..383810119 100644 --- a/engine/server/sv_ccmds.c +++ b/engine/server/sv_ccmds.c @@ -2156,7 +2156,7 @@ static void SV_Status_f (void) continue; //free, and older than the zombie time count++; } - Con_TPrintf("entities : %i/%i/%i (mem: %.1f%%)\n", count, sv.world.num_edicts, sv.world.max_edicts, 100*(float)(sv.world.progs->stringtablesize/(double)sv.world.progs->stringtablemaxsize)); + Con_TPrintf("entities : %i/%i/%i (mem: %.1f%%)\n", count, sv.world.num_edicts, sv.world.max_edicts, 100.0*(sv.world.progs->stringtablesize/(double)sv.world.progs->stringtablemaxsize)); for (count = 1; count < MAX_PRECACHE_MODELS; count++) if (!sv.strings.model_precache[count]) break; diff --git a/engine/server/sv_ents.c b/engine/server/sv_ents.c index 300db8f5f..a0a797da9 100644 --- a/engine/server/sv_ents.c +++ b/engine/server/sv_ents.c @@ -3727,7 +3727,7 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, pvscamera_t #define DEPTHOPTIMISE #ifdef DEPTHOPTIMISE vec3_t org; - static float distances[32768]; + float *distances = NULL; float dist; #endif globalvars_t *pr_globals = PR_globals(svprogfuncs, PR_CURRENT); @@ -3736,6 +3736,22 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, pvscamera_t int c, maxc = cameras?cameras->numents:0; client_t *seat; + limit = sv.world.num_edicts; + if (client->max_net_ents < limit) + { + limit = client->max_net_ents; + if (!(client->plimitwarned & PLIMIT_ENTITIES)) + { + client->plimitwarned |= PLIMIT_ENTITIES; + SV_ClientPrintf(client, PRINT_HIGH, "WARNING: Your client's network protocol only supports %i entities. Please upgrade or enable extensions.\n", client->max_net_ents); + } + } + +#ifdef DEPTHOPTIMISE + if (clent && ISQWCLIENT(client) && client->max_net_ents<=512) //the vanilla QW client is shite and only supports 64 visible ents at a time... it can get cpu-heavy though, so don't waste time with other clients. + distances = alloca(sizeof(*distances)*limit); +#endif + //this entity is watching from outside themselves. The client is tricked into thinking that they themselves are in the view ent, and a new dummy ent (the old them) must be spawned. if (clent && ISQWCLIENT(client)) { @@ -3746,7 +3762,8 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, pvscamera_t continue; //FIXME: this hack needs cleaning up #ifdef DEPTHOPTIMISE - distances[pack->num_entities] = 0; + if (distances) + distances[pack->num_entities] = 0; #endif state = &pack->entities[pack->num_entities]; pack->num_entities++; @@ -3789,17 +3806,6 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, pvscamera_t else e = 1; - limit = sv.world.num_edicts; - if (client->max_net_ents < limit) - { - limit = client->max_net_ents; - if (!(client->plimitwarned & PLIMIT_ENTITIES)) - { - client->plimitwarned |= PLIMIT_ENTITIES; - SV_ClientPrintf(client, PRINT_HIGH, "WARNING: Your client's network protocol only supports %i entities. Please upgrade or enable extensions.\n", client->max_net_ents); - } - } - if (client->penalties & BAN_BLIND) { e = client->edict->entnum; @@ -3991,7 +3997,7 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, pvscamera_t if (ent->v->modelindex >= client->maxmodels) continue; #ifdef DEPTHOPTIMISE - if (clent) + if (distances) { //find distance based upon absolute mins/maxs so bsps are treated fairly. //org = clentorg + -0.5*(max+min)