diff --git a/source/cl_main.c b/source/cl_main.c index 9a026e8..925e6d0 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -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); diff --git a/source/cl_tent.c b/source/cl_tent.c index bb59504..2f4d372 100644 --- a/source/cl_tent.c +++ b/source/cl_tent.c @@ -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; diff --git a/source/client.h b/source/client.h index a02b915..9acae4e 100644 --- a/source/client.h +++ b/source/client.h @@ -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