dynamically allocate tempents

master
an 2019-11-25 22:23:25 -05:00
parent a1bd4a0862
commit 97ef220fb9
5 changed files with 44 additions and 37 deletions

View File

@ -48,7 +48,8 @@ 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};
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);

View File

@ -879,7 +879,7 @@ CL_ParseStatic
void CL_ParseStatic(int32_t version) //johnfitz -- added a parameter
{
entity_t *ent;
int32_t i;
int32_t i;
i = cl.num_statics;
if(i >= MAX_STATIC_ENTITIES)

View File

@ -23,17 +23,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.h"
int32_t num_temp_entities;
entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
beam_t cl_beams[MAX_BEAMS];
entity_t *cl_temp_entities;
int32_t num_temp_entities;
int32_t max_temp_entities;
sfx_t *cl_sfx_wizhit;
sfx_t *cl_sfx_knighthit;
sfx_t *cl_sfx_tink1;
sfx_t *cl_sfx_ric1;
sfx_t *cl_sfx_ric2;
sfx_t *cl_sfx_ric3;
sfx_t *cl_sfx_r_exp3;
beam_t cl_beams[MAX_BEAMS];
sfx_t *cl_sfx_wizhit;
sfx_t *cl_sfx_knighthit;
sfx_t *cl_sfx_tink1;
sfx_t *cl_sfx_ric1;
sfx_t *cl_sfx_ric2;
sfx_t *cl_sfx_ric3;
sfx_t *cl_sfx_r_exp3;
/*
=================
@ -42,13 +44,13 @@ CL_ParseTEnt
*/
void CL_InitTEnts(void)
{
cl_sfx_wizhit = S_PrecacheSound("wizard/hit.wav");
cl_sfx_wizhit = S_PrecacheSound("wizard/hit.wav");
cl_sfx_knighthit = S_PrecacheSound("hknight/hit.wav");
cl_sfx_tink1 = S_PrecacheSound("weapons/tink1.wav");
cl_sfx_ric1 = S_PrecacheSound("weapons/ric1.wav");
cl_sfx_ric2 = S_PrecacheSound("weapons/ric2.wav");
cl_sfx_ric3 = S_PrecacheSound("weapons/ric3.wav");
cl_sfx_r_exp3 = S_PrecacheSound("weapons/r_exp3.wav");
cl_sfx_tink1 = S_PrecacheSound("weapons/tink1.wav");
cl_sfx_ric1 = S_PrecacheSound("weapons/ric1.wav");
cl_sfx_ric2 = S_PrecacheSound("weapons/ric2.wav");
cl_sfx_ric3 = S_PrecacheSound("weapons/ric3.wav");
cl_sfx_r_exp3 = S_PrecacheSound("weapons/r_exp3.wav");
}
/*
@ -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));

View File

@ -267,20 +267,22 @@ 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
#define MAX_STATIC_ENTITIES 4096 //ericw -- was 512 //johnfitz -- was 128
#define MAX_VISEDICTS 4096 // larger, now we support BSP2
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

View File

@ -239,19 +239,19 @@ extern bool noclip_anglehack;
//
// host
//
extern quakeparms_t *host_parms;
extern quakeparms_t *host_parms;
extern cvar_t sys_ticrate;
extern cvar_t sys_throttle;
extern cvar_t sys_nostdout;
extern cvar_t developer;
extern cvar_t max_edicts; //johnfitz
extern cvar_t sys_ticrate;
extern cvar_t sys_throttle;
extern cvar_t sys_nostdout;
extern cvar_t developer;
extern cvar_t max_edicts; //johnfitz
extern bool host_initialized; // true if into command execution
extern double host_frametime;
extern byte *host_colormap;
extern int32_t host_framecount; // incremented every frame, never reset
extern double realtime; // not bounded in any way, changed at
extern bool host_initialized; // true if into command execution
extern double host_frametime;
extern byte *host_colormap;
extern int32_t host_framecount; // incremented every frame, never reset
extern double realtime; // not bounded in any way, changed at
// start of every frame, never reset
typedef struct filelist_item_s