dynamically allocate tempents
parent
a1bd4a0862
commit
97ef220fb9
|
@ -49,6 +49,7 @@ cvar_t cl_maxpitch = {"cl_maxpitch", "90", CVAR_ARCHIVE}; //johnfitz -- variabl
|
|||
cvar_t cl_minpitch = {"cl_minpitch", "-90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping
|
||||
|
||||
cvar_t cl_maxdlights = {"cl_maxdlights", "128", CVAR_ARCHIVE};
|
||||
cvar_t cl_maxtempents = {"cl_maxtempents", "256", CVAR_ARCHIVE};
|
||||
|
||||
client_static_t cls;
|
||||
client_state_t cl;
|
||||
|
@ -85,7 +86,6 @@ void CL_ClearState(void)
|
|||
|
||||
// clear other arrays
|
||||
memset(cl_lightstyle, 0, sizeof(cl_lightstyle));
|
||||
memset(cl_temp_entities, 0, sizeof(cl_temp_entities));
|
||||
memset(cl_beams, 0, sizeof(cl_beams));
|
||||
|
||||
//johnfitz -- cl_entities is now dynamically allocated
|
||||
|
@ -95,6 +95,9 @@ void CL_ClearState(void)
|
|||
|
||||
cl_max_dlights = CLAMP(MIN_DLIGHTS, (int32_t)cl_maxdlights.value, MAX_DLIGHTS);
|
||||
cl_dlights = Hunk_AllocName(cl_max_dlights * sizeof(*cl_dlights), "cl_dlights");
|
||||
|
||||
max_temp_entities = CLAMP(0, (int32_t)cl_maxtempents.value, 32000);
|
||||
cl_temp_entities = Hunk_AllocName(max_temp_entities * sizeof(*cl_temp_entities), "cl_temp_entities");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -602,7 +605,6 @@ Read all incoming data from the server
|
|||
int32_t CL_ReadFromServer(void)
|
||||
{
|
||||
int32_t ret;
|
||||
extern int32_t num_temp_entities; //johnfitz
|
||||
int32_t num_beams = 0; //johnfitz
|
||||
int32_t num_dlights = 0; //johnfitz
|
||||
beam_t *b; //johnfitz
|
||||
|
@ -642,7 +644,7 @@ int32_t CL_ReadFromServer(void)
|
|||
|
||||
//temp entities
|
||||
if(num_temp_entities > 64 && dev_peakstats.tempents <= 64)
|
||||
Con_DWarning("%" PRIi32 " tempentities exceeds standard limit of 64 (max = %" PRIi32 ").\n", num_temp_entities, MAX_TEMP_ENTITIES);
|
||||
Con_DWarning("%" PRIi32 " tempentities exceeds standard limit of 64 (max = %" PRIi32 ").\n", num_temp_entities, max_temp_entities);
|
||||
dev_stats.tempents = num_temp_entities;
|
||||
dev_peakstats.tempents = q_max(num_temp_entities, dev_peakstats.tempents);
|
||||
|
||||
|
@ -814,6 +816,7 @@ void CL_Init(void)
|
|||
Cvar_RegisterVariable(&cl_minpitch); //johnfitz -- variable pitch clamping
|
||||
|
||||
Cvar_RegisterVariable(&cl_maxdlights);
|
||||
Cvar_RegisterVariable(&cl_maxtempents);
|
||||
|
||||
Cmd_AddCommand("entities", CL_PrintEntities_f);
|
||||
Cmd_AddCommand("disconnect", CL_Disconnect_f);
|
||||
|
|
|
@ -23,8 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
entity_t *cl_temp_entities;
|
||||
int32_t num_temp_entities;
|
||||
entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
|
||||
int32_t max_temp_entities;
|
||||
|
||||
beam_t cl_beams[MAX_BEAMS];
|
||||
|
||||
sfx_t *cl_sfx_wizhit;
|
||||
|
@ -271,7 +273,7 @@ entity_t *CL_NewTempEntity(void)
|
|||
|
||||
if(cl_numvisedicts == MAX_VISEDICTS)
|
||||
return NULL;
|
||||
if(num_temp_entities == MAX_TEMP_ENTITIES)
|
||||
if(num_temp_entities == max_temp_entities)
|
||||
return NULL;
|
||||
ent = &cl_temp_entities[num_temp_entities];
|
||||
memset(ent, 0, sizeof(*ent));
|
||||
|
|
|
@ -267,7 +267,6 @@ extern cvar_t m_forward;
|
|||
extern cvar_t m_side;
|
||||
|
||||
|
||||
#define MAX_TEMP_ENTITIES 256 //johnfitz -- was 64
|
||||
#define MAX_STATIC_ENTITIES 4096 //ericw -- was 512 //johnfitz -- was 128
|
||||
#define MAX_VISEDICTS 4096 // larger, now we support BSP2
|
||||
|
||||
|
@ -276,11 +275,14 @@ extern client_state_t cl;
|
|||
// FIXME, allocate dynamically
|
||||
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
||||
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||
extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
|
||||
extern beam_t cl_beams[MAX_BEAMS];
|
||||
extern entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
extern int32_t cl_numvisedicts;
|
||||
|
||||
extern entity_t *cl_temp_entities;
|
||||
extern int32_t num_temp_entities; //johnfitz
|
||||
extern int32_t max_temp_entities; //johnfitz
|
||||
|
||||
extern entity_t *cl_entities; //johnfitz -- was a static array, now on hunk
|
||||
extern int32_t cl_max_edicts; //johnfitz -- only changes when new map loads
|
||||
|
||||
|
|
Loading…
Reference in New Issue