mirror of
https://github.com/blendogames/thirtyflightsofloving.git
synced 2024-11-14 16:40:57 +00:00
Prevent divide by zero errors with cl_particle_scale cvar.
This commit is contained in:
parent
7d294586f7
commit
d1c1e87940
5 changed files with 62 additions and 24 deletions
|
@ -383,7 +383,7 @@ void CL_Explosion_Sparks (vec3_t org, int size, int count)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < (count/cl_particle_scale->value); i++) // was 256
|
||||
for (i=0; i < (count/max(cl_particle_scale->value, 1.0f)); i++) // was 256
|
||||
{
|
||||
CL_SetupParticle (
|
||||
0, 0, 0,
|
||||
|
@ -1278,7 +1278,7 @@ void CL_BigTeleportParticles (vec3_t org)
|
|||
static int colortable1[4] = {150,150,50,10};
|
||||
static int colortable2[4] = {50,10,10,150};
|
||||
|
||||
for (i=0; i<(1024/cl_particle_scale->value); i++) // was 4096
|
||||
for (i=0; i<(1024/max(cl_particle_scale->value, 1.0f)); i++) // was 4096
|
||||
{
|
||||
|
||||
index = rand()&3;
|
||||
|
@ -1874,7 +1874,7 @@ void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old)
|
|||
VectorSubtract (end, start, vec);
|
||||
totallen = len = VectorNormalize (vec);
|
||||
|
||||
dec = 1*cl_particle_scale->value;
|
||||
dec = 1 * cl_particle_scale->value;
|
||||
VectorScale (vec, dec, vec);
|
||||
|
||||
while (len > 0)
|
||||
|
@ -1907,11 +1907,11 @@ void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old)
|
|||
VectorCopy (start, move);
|
||||
VectorSubtract (end, start, vec);
|
||||
totallen = len = VectorNormalize (vec);
|
||||
dec = 1.5*cl_particle_scale->value;
|
||||
dec = 1.5 * cl_particle_scale->value;
|
||||
VectorScale (vec, dec, vec);
|
||||
/* len = totallen;
|
||||
VectorCopy (start, move);
|
||||
dec = 1.5;//*cl_particle_scale->value;
|
||||
dec = 1.5;// * cl_particle_scale->value;
|
||||
VectorScale (vec, dec, vec);*/
|
||||
|
||||
while (len > 0)
|
||||
|
@ -1987,9 +1987,9 @@ void CL_RailSprial (vec3_t start, vec3_t end, qboolean isRed)
|
|||
len = min (len, cl_rail_length->value); // cap length
|
||||
MakeNormalVectors (vec, right, up);
|
||||
|
||||
VectorScale(vec, cl_rail_space->value*cl_particle_scale->value, vec);
|
||||
VectorScale(vec, cl_rail_space->value * cl_particle_scale->value, vec);
|
||||
|
||||
for (i=0; i<len; i += cl_rail_space->value*cl_particle_scale->value)
|
||||
for (i=0; i<len; i += cl_rail_space->value * cl_particle_scale->value)
|
||||
{
|
||||
d = i * 0.1;
|
||||
c = cos(d);
|
||||
|
@ -2232,7 +2232,7 @@ void CL_IonripperTrail (vec3_t start, vec3_t ent)
|
|||
|
||||
MakeNormalVectors (vec, leftdir, up);
|
||||
|
||||
dec = 3*cl_particle_scale->value;
|
||||
dec = 3 * cl_particle_scale->value;
|
||||
VectorScale (vec, dec, vec);
|
||||
|
||||
while (len > 0)
|
||||
|
@ -2874,7 +2874,7 @@ void CL_HeatbeamParticles (vec3_t start, vec3_t forward)
|
|||
VectorScale (vec, step, vec);
|
||||
|
||||
//Com_Printf ("%f\n", ltime);
|
||||
rstep = M_PI/10.0*min(cl_particle_scale->value, 2);
|
||||
rstep = M_PI/10.0 * min(cl_particle_scale->value, 2);
|
||||
for (i=start_pt; i<len; i+=step)
|
||||
{
|
||||
if (i>step*maxsteps) // don't bother after the nth ring
|
||||
|
@ -3042,8 +3042,8 @@ void CL_TrackerTrail (vec3_t start, vec3_t end)
|
|||
vectoangles2 (forward, angle_dir);
|
||||
AngleVectors (angle_dir, forward, right, up);
|
||||
|
||||
dec = 3*max(cl_particle_scale->value/2, 1);
|
||||
VectorScale (vec, 3*max(cl_particle_scale->value/2, 1), vec);
|
||||
dec = 3 * max(cl_particle_scale->value/2, 1);
|
||||
VectorScale (vec, 3 * max(cl_particle_scale->value/2, 1), vec);
|
||||
|
||||
// FIXME: this is a really silly way to have a loop
|
||||
while (len > 0)
|
||||
|
@ -3080,13 +3080,13 @@ void CL_TrackerTrail (vec3_t start, vec3_t end)
|
|||
CL_TrackerShell
|
||||
===============
|
||||
*/
|
||||
void CL_Tracker_Shell(vec3_t origin)
|
||||
void CL_Tracker_Shell (vec3_t origin)
|
||||
{
|
||||
vec3_t dir;
|
||||
int i;
|
||||
cparticle_t *p;
|
||||
|
||||
for(i=0; i < (300/cl_particle_scale->value); i++)
|
||||
for(i=0; i < (300/max(cl_particle_scale->value, 1.0f)); i++)
|
||||
{
|
||||
p = CL_SetupParticle (
|
||||
0, 0, 0,
|
||||
|
@ -3221,7 +3221,7 @@ void CL_Nukeblast (cl_sustain_t *self)
|
|||
ratio = 1.0 - (((float)self->endtime - (float)cl.time)/1000.0);
|
||||
size = ratio*ratio;
|
||||
|
||||
for(i=0; i<(700/cl_particle_scale->value); i++)
|
||||
for(i=0; i<(700/max(cl_particle_scale->value, 1.0f)); i++)
|
||||
{
|
||||
index = rand()&3;
|
||||
p = CL_SetupParticle (
|
||||
|
@ -3306,7 +3306,7 @@ void CL_Tracker_Explode (vec3_t origin)
|
|||
int i;
|
||||
cparticle_t *p;
|
||||
|
||||
for (i=0; i<(300/cl_particle_scale->value); i++)
|
||||
for (i=0; i<(300/max(cl_particle_scale->value, 1.0f)); i++)
|
||||
{
|
||||
p = CL_SetupParticle (
|
||||
0, 0, 0,
|
||||
|
|
|
@ -1122,13 +1122,21 @@ void CL_AddPacketEntities (frame_t *frame)
|
|||
entity_t ent;
|
||||
entity_state_t *s1;
|
||||
float autorotate;
|
||||
int i;
|
||||
int pnum;
|
||||
int i, pnum, autoanim;
|
||||
int max_models;
|
||||
centity_t *cent;
|
||||
int autoanim;
|
||||
clientinfo_t *ci;
|
||||
unsigned int effects, renderfx;
|
||||
|
||||
// Knightmare- hack for connected to server using old protocol
|
||||
// Changed config strings require different parsing
|
||||
if ( LegacyProtocol() )
|
||||
max_models = OLD_MAX_MODELS;
|
||||
else
|
||||
max_models = MAX_MODELS;
|
||||
|
||||
CL_FixParticleCvars (); // clamp critical effects vars to acceptable bounds
|
||||
|
||||
// bonus items rotate at a fixed rate
|
||||
autorotate = anglemod(cl.time/10);
|
||||
|
||||
|
@ -1237,9 +1245,11 @@ void CL_AddPacketEntities (frame_t *frame)
|
|||
else
|
||||
{
|
||||
// set skin
|
||||
if ( s1->modelindex == MAX_MODELS-1 //was 255
|
||||
/* if ( s1->modelindex == MAX_MODELS-1 //was 255
|
||||
//Knightmare- GROSS HACK for old demos, use modelindex 255
|
||||
|| ( LegacyProtocol() && s1->modelindex == OLD_MAX_MODELS-1 ) )
|
||||
|| ( LegacyProtocol() && s1->modelindex == OLD_MAX_MODELS-1 ) ) */
|
||||
if ( s1->modelindex == (max_models-1)) // was 255
|
||||
|
||||
{ // use custom player skin
|
||||
ent.skinnum = 0;
|
||||
ci = &cl.clientinfo[s1->skinnum & 0xff];
|
||||
|
@ -1391,8 +1401,9 @@ void CL_AddPacketEntities (frame_t *frame)
|
|||
V_AddLight (ent.origin, 225, -1.0, -1.0, -1.0); //PGM
|
||||
|
||||
// Knightmare- save off current player weapon model for player config menu
|
||||
if (s1->modelindex2 == MAX_MODELS-1
|
||||
|| ( LegacyProtocol() && s1->modelindex2 == OLD_MAX_MODELS-1 ) )
|
||||
/* if (s1->modelindex2 == MAX_MODELS-1
|
||||
|| ( LegacyProtocol() && s1->modelindex2 == OLD_MAX_MODELS-1 ) ) */
|
||||
if (s1->modelindex2 == max_models-1)
|
||||
{
|
||||
ci = &cl.clientinfo[s1->skinnum & 0xff];
|
||||
i = (s1->skinnum >> 8); // 0 is default weapon model
|
||||
|
@ -1510,9 +1521,10 @@ void CL_AddPacketEntities (frame_t *frame)
|
|||
// duplicate for linked models
|
||||
if (s1->modelindex2)
|
||||
{
|
||||
if (s1->modelindex2 == MAX_MODELS-1
|
||||
/* if (s1->modelindex2 == MAX_MODELS-1
|
||||
//Knightmare- GROSS HACK for old demos, use modelindex 255
|
||||
|| ( LegacyProtocol() && s1->modelindex2 == OLD_MAX_MODELS-1 ) )
|
||||
|| ( LegacyProtocol() && s1->modelindex2 == OLD_MAX_MODELS-1 ) ) */
|
||||
if (s1->modelindex2 == (max_models-1))
|
||||
{ // custom weapon
|
||||
ci = &cl.clientinfo[s1->skinnum & 0xff];
|
||||
i = (s1->skinnum >> 8); // 0 is default weapon model
|
||||
|
|
|
@ -553,6 +553,27 @@ void CL_DecalAlphaThink (cparticle_t *p, vec3_t org, vec3_t angle, float *alpha,
|
|||
|
||||
//===================================================================
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_FixParticleCvars
|
||||
===============
|
||||
*/
|
||||
void CL_FixParticleCvars (void)
|
||||
{
|
||||
// clamp to acceptable value (don't allow infinite particles)
|
||||
if (cl_particle_scale->value < 1.0f)
|
||||
Cvar_SetValue("cl_particle_scale", 1);
|
||||
|
||||
// clamp to acceptable minimum length
|
||||
if (cl_rail_length->value < MIN_RAIL_LENGTH)
|
||||
Cvar_SetValue("cl_rail_length", MIN_RAIL_LENGTH);
|
||||
|
||||
// clamp to acceptable minimum duration
|
||||
if (r_decal_life->value < MIN_DECAL_LIFE)
|
||||
Cvar_SetValue("r_decal_life", MIN_DECAL_LIFE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_AddParticles
|
||||
|
@ -571,6 +592,8 @@ void CL_AddParticles (void)
|
|||
tail = NULL;
|
||||
decals = 0;
|
||||
|
||||
CL_FixParticleCvars (); // clamp critical effects vars to acceptable bounds
|
||||
|
||||
for (p=active_particles; p; p=next)
|
||||
{
|
||||
next = p->next;
|
||||
|
|
|
@ -786,6 +786,8 @@ void CL_ParseTEnt (void)
|
|||
int ent;
|
||||
int magnitude;
|
||||
|
||||
CL_FixParticleCvars (); // clamp critical effects vars to acceptable bounds
|
||||
|
||||
type = MSG_ReadByte (&net_message);
|
||||
|
||||
switch (type)
|
||||
|
|
|
@ -985,6 +985,7 @@ extern cparticle_t *active_particles, *free_particles;
|
|||
extern cparticle_t particles[MAX_PARTICLES];
|
||||
extern int cl_numparticles;
|
||||
|
||||
void CL_FixParticleCvars (void);
|
||||
int CL_GetRandomBloodParticle (void);
|
||||
void CL_ClipDecal (cparticle_t *part, float radius, float orient, vec3_t origin, vec3_t dir);
|
||||
float CL_NewParticleTime (void);
|
||||
|
|
Loading…
Reference in a new issue