dynamically allocate beams

master
an 2019-11-25 22:29:45 -05:00
parent 97ef220fb9
commit dce72d376b
3 changed files with 16 additions and 10 deletions

View File

@ -48,8 +48,9 @@ cvar_t m_side = {"m_side", "0.8", CVAR_ARCHIVE};
cvar_t cl_maxpitch = {"cl_maxpitch", "90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping
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_maxdlights = {"cl_maxdlights", "128", CVAR_ARCHIVE};
cvar_t cl_maxtempents = {"cl_maxtempents", "256", CVAR_ARCHIVE};
cvar_t cl_maxbeams = {"cl_maxbeams", "32", CVAR_ARCHIVE};
client_static_t cls;
client_state_t cl;
@ -86,7 +87,6 @@ void CL_ClearState(void)
// clear other arrays
memset(cl_lightstyle, 0, sizeof(cl_lightstyle));
memset(cl_beams, 0, sizeof(cl_beams));
//johnfitz -- cl_entities is now dynamically allocated
cl_max_edicts = CLAMP(MIN_EDICTS, (int32_t)max_edicts.value, MAX_EDICTS);
@ -98,6 +98,9 @@ void CL_ClearState(void)
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");
max_beams = CLAMP(0, (int32_t)cl_maxbeams.value, 32000);
cl_beams = Hunk_AllocName(max_beams * sizeof(*cl_beams), "cl_beams");
}
/*
@ -649,11 +652,11 @@ int32_t CL_ReadFromServer(void)
dev_peakstats.tempents = q_max(num_temp_entities, dev_peakstats.tempents);
//beams
for(i = 0, b = cl_beams ; i < MAX_BEAMS ; i++, b++)
for(i = 0, b = cl_beams ; i < max_beams ; i++, b++)
if(b->model && b->endtime >= cl.time)
num_beams++;
if(num_beams > 24 && dev_peakstats.beams <= 24)
Con_DWarning("%" PRIi32 " beams exceeded standard limit of 24 (max = %" PRIi32 ").\n", num_beams, MAX_BEAMS);
Con_DWarning("%" PRIi32 " beams exceeded standard limit of 24 (max = %" PRIi32 ").\n", num_beams, max_beams);
dev_stats.beams = num_beams;
dev_peakstats.beams = q_max(num_beams, dev_peakstats.beams);
@ -817,6 +820,7 @@ void CL_Init(void)
Cvar_RegisterVariable(&cl_maxdlights);
Cvar_RegisterVariable(&cl_maxtempents);
Cvar_RegisterVariable(&cl_maxbeams);
Cmd_AddCommand("entities", CL_PrintEntities_f);
Cmd_AddCommand("disconnect", CL_Disconnect_f);

View File

@ -27,7 +27,8 @@ entity_t *cl_temp_entities;
int32_t num_temp_entities;
int32_t max_temp_entities;
beam_t cl_beams[MAX_BEAMS];
beam_t *cl_beams;
int32_t max_beams;
sfx_t *cl_sfx_wizhit;
sfx_t *cl_sfx_knighthit;
@ -76,7 +77,7 @@ void CL_ParseBeam(qmodel_t *m)
end[2] = MSG_ReadCoord(cl.protocolflags);
// override any beam with the same entity
for(i = 0, b = cl_beams ; i < MAX_BEAMS ; i++, b++)
for(i = 0, b = cl_beams ; i < max_beams ; i++, b++)
if(b->entity == ent)
{
b->entity = ent;
@ -88,7 +89,7 @@ void CL_ParseBeam(qmodel_t *m)
}
// find a free beam
for(i = 0, b = cl_beams ; i < MAX_BEAMS ; i++, b++)
for(i = 0, b = cl_beams ; i < max_beams ; i++, b++)
{
if(!b->model || b->endtime < cl.time)
{
@ -306,7 +307,7 @@ void CL_UpdateTEnts(void)
srand((int32_t)(cl.time * 1000)); //johnfitz -- freeze beams when paused
// update lightning
for(i = 0, b = cl_beams ; i < MAX_BEAMS ; i++, b++)
for(i = 0, b = cl_beams ; i < max_beams ; i++, b++)
{
if(!b->model || b->endtime < cl.time)
continue;

View File

@ -77,7 +77,6 @@ typedef struct
} dlight_t;
#define MAX_BEAMS 32 // johnfitz -- was 24
typedef struct
{
int32_t entity;
@ -275,10 +274,12 @@ 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 beam_t cl_beams[MAX_BEAMS];
extern entity_t *cl_visedicts[MAX_VISEDICTS];
extern int32_t cl_numvisedicts;
extern beam_t *cl_beams;
extern int32_t max_beams;
extern entity_t *cl_temp_entities;
extern int32_t num_temp_entities; //johnfitz
extern int32_t max_temp_entities; //johnfitz