mirror of
https://github.com/blendogames/thirtyflightsofloving.git
synced 2024-11-15 00:41:21 +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;
|
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 (
|
CL_SetupParticle (
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
|
@ -1278,7 +1278,7 @@ void CL_BigTeleportParticles (vec3_t org)
|
||||||
static int colortable1[4] = {150,150,50,10};
|
static int colortable1[4] = {150,150,50,10};
|
||||||
static int colortable2[4] = {50,10,10,150};
|
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;
|
index = rand()&3;
|
||||||
|
@ -1874,7 +1874,7 @@ void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old)
|
||||||
VectorSubtract (end, start, vec);
|
VectorSubtract (end, start, vec);
|
||||||
totallen = len = VectorNormalize (vec);
|
totallen = len = VectorNormalize (vec);
|
||||||
|
|
||||||
dec = 1*cl_particle_scale->value;
|
dec = 1 * cl_particle_scale->value;
|
||||||
VectorScale (vec, dec, vec);
|
VectorScale (vec, dec, vec);
|
||||||
|
|
||||||
while (len > 0)
|
while (len > 0)
|
||||||
|
@ -1907,11 +1907,11 @@ void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old)
|
||||||
VectorCopy (start, move);
|
VectorCopy (start, move);
|
||||||
VectorSubtract (end, start, vec);
|
VectorSubtract (end, start, vec);
|
||||||
totallen = len = VectorNormalize (vec);
|
totallen = len = VectorNormalize (vec);
|
||||||
dec = 1.5*cl_particle_scale->value;
|
dec = 1.5 * cl_particle_scale->value;
|
||||||
VectorScale (vec, dec, vec);
|
VectorScale (vec, dec, vec);
|
||||||
/* len = totallen;
|
/* len = totallen;
|
||||||
VectorCopy (start, move);
|
VectorCopy (start, move);
|
||||||
dec = 1.5;//*cl_particle_scale->value;
|
dec = 1.5;// * cl_particle_scale->value;
|
||||||
VectorScale (vec, dec, vec);*/
|
VectorScale (vec, dec, vec);*/
|
||||||
|
|
||||||
while (len > 0)
|
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
|
len = min (len, cl_rail_length->value); // cap length
|
||||||
MakeNormalVectors (vec, right, up);
|
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;
|
d = i * 0.1;
|
||||||
c = cos(d);
|
c = cos(d);
|
||||||
|
@ -2232,7 +2232,7 @@ void CL_IonripperTrail (vec3_t start, vec3_t ent)
|
||||||
|
|
||||||
MakeNormalVectors (vec, leftdir, up);
|
MakeNormalVectors (vec, leftdir, up);
|
||||||
|
|
||||||
dec = 3*cl_particle_scale->value;
|
dec = 3 * cl_particle_scale->value;
|
||||||
VectorScale (vec, dec, vec);
|
VectorScale (vec, dec, vec);
|
||||||
|
|
||||||
while (len > 0)
|
while (len > 0)
|
||||||
|
@ -2874,7 +2874,7 @@ void CL_HeatbeamParticles (vec3_t start, vec3_t forward)
|
||||||
VectorScale (vec, step, vec);
|
VectorScale (vec, step, vec);
|
||||||
|
|
||||||
//Com_Printf ("%f\n", ltime);
|
//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)
|
for (i=start_pt; i<len; i+=step)
|
||||||
{
|
{
|
||||||
if (i>step*maxsteps) // don't bother after the nth ring
|
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);
|
vectoangles2 (forward, angle_dir);
|
||||||
AngleVectors (angle_dir, forward, right, up);
|
AngleVectors (angle_dir, forward, right, up);
|
||||||
|
|
||||||
dec = 3*max(cl_particle_scale->value/2, 1);
|
dec = 3 * max(cl_particle_scale->value/2, 1);
|
||||||
VectorScale (vec, 3*max(cl_particle_scale->value/2, 1), vec);
|
VectorScale (vec, 3 * max(cl_particle_scale->value/2, 1), vec);
|
||||||
|
|
||||||
// FIXME: this is a really silly way to have a loop
|
// FIXME: this is a really silly way to have a loop
|
||||||
while (len > 0)
|
while (len > 0)
|
||||||
|
@ -3080,13 +3080,13 @@ void CL_TrackerTrail (vec3_t start, vec3_t end)
|
||||||
CL_TrackerShell
|
CL_TrackerShell
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void CL_Tracker_Shell(vec3_t origin)
|
void CL_Tracker_Shell (vec3_t origin)
|
||||||
{
|
{
|
||||||
vec3_t dir;
|
vec3_t dir;
|
||||||
int i;
|
int i;
|
||||||
cparticle_t *p;
|
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 (
|
p = CL_SetupParticle (
|
||||||
0, 0, 0,
|
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);
|
ratio = 1.0 - (((float)self->endtime - (float)cl.time)/1000.0);
|
||||||
size = ratio*ratio;
|
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;
|
index = rand()&3;
|
||||||
p = CL_SetupParticle (
|
p = CL_SetupParticle (
|
||||||
|
@ -3306,7 +3306,7 @@ void CL_Tracker_Explode (vec3_t origin)
|
||||||
int i;
|
int i;
|
||||||
cparticle_t *p;
|
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 (
|
p = CL_SetupParticle (
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
|
|
|
@ -1122,13 +1122,21 @@ void CL_AddPacketEntities (frame_t *frame)
|
||||||
entity_t ent;
|
entity_t ent;
|
||||||
entity_state_t *s1;
|
entity_state_t *s1;
|
||||||
float autorotate;
|
float autorotate;
|
||||||
int i;
|
int i, pnum, autoanim;
|
||||||
int pnum;
|
int max_models;
|
||||||
centity_t *cent;
|
centity_t *cent;
|
||||||
int autoanim;
|
|
||||||
clientinfo_t *ci;
|
clientinfo_t *ci;
|
||||||
unsigned int effects, renderfx;
|
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
|
// bonus items rotate at a fixed rate
|
||||||
autorotate = anglemod(cl.time/10);
|
autorotate = anglemod(cl.time/10);
|
||||||
|
|
||||||
|
@ -1237,9 +1245,11 @@ void CL_AddPacketEntities (frame_t *frame)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// set skin
|
// 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
|
//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
|
{ // use custom player skin
|
||||||
ent.skinnum = 0;
|
ent.skinnum = 0;
|
||||||
ci = &cl.clientinfo[s1->skinnum & 0xff];
|
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
|
V_AddLight (ent.origin, 225, -1.0, -1.0, -1.0); //PGM
|
||||||
|
|
||||||
// Knightmare- save off current player weapon model for player config menu
|
// Knightmare- save off current player weapon model for player config menu
|
||||||
if (s1->modelindex2 == MAX_MODELS-1
|
/* if (s1->modelindex2 == MAX_MODELS-1
|
||||||
|| ( LegacyProtocol() && s1->modelindex2 == OLD_MAX_MODELS-1 ) )
|
|| ( LegacyProtocol() && s1->modelindex2 == OLD_MAX_MODELS-1 ) ) */
|
||||||
|
if (s1->modelindex2 == max_models-1)
|
||||||
{
|
{
|
||||||
ci = &cl.clientinfo[s1->skinnum & 0xff];
|
ci = &cl.clientinfo[s1->skinnum & 0xff];
|
||||||
i = (s1->skinnum >> 8); // 0 is default weapon model
|
i = (s1->skinnum >> 8); // 0 is default weapon model
|
||||||
|
@ -1510,9 +1521,10 @@ void CL_AddPacketEntities (frame_t *frame)
|
||||||
// duplicate for linked models
|
// duplicate for linked models
|
||||||
if (s1->modelindex2)
|
if (s1->modelindex2)
|
||||||
{
|
{
|
||||||
if (s1->modelindex2 == MAX_MODELS-1
|
/* if (s1->modelindex2 == MAX_MODELS-1
|
||||||
//Knightmare- GROSS HACK for old demos, use modelindex 255
|
//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
|
{ // custom weapon
|
||||||
ci = &cl.clientinfo[s1->skinnum & 0xff];
|
ci = &cl.clientinfo[s1->skinnum & 0xff];
|
||||||
i = (s1->skinnum >> 8); // 0 is default weapon model
|
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
|
CL_AddParticles
|
||||||
|
@ -571,6 +592,8 @@ void CL_AddParticles (void)
|
||||||
tail = NULL;
|
tail = NULL;
|
||||||
decals = 0;
|
decals = 0;
|
||||||
|
|
||||||
|
CL_FixParticleCvars (); // clamp critical effects vars to acceptable bounds
|
||||||
|
|
||||||
for (p=active_particles; p; p=next)
|
for (p=active_particles; p; p=next)
|
||||||
{
|
{
|
||||||
next = p->next;
|
next = p->next;
|
||||||
|
|
|
@ -786,6 +786,8 @@ void CL_ParseTEnt (void)
|
||||||
int ent;
|
int ent;
|
||||||
int magnitude;
|
int magnitude;
|
||||||
|
|
||||||
|
CL_FixParticleCvars (); // clamp critical effects vars to acceptable bounds
|
||||||
|
|
||||||
type = MSG_ReadByte (&net_message);
|
type = MSG_ReadByte (&net_message);
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
|
@ -985,6 +985,7 @@ extern cparticle_t *active_particles, *free_particles;
|
||||||
extern cparticle_t particles[MAX_PARTICLES];
|
extern cparticle_t particles[MAX_PARTICLES];
|
||||||
extern int cl_numparticles;
|
extern int cl_numparticles;
|
||||||
|
|
||||||
|
void CL_FixParticleCvars (void);
|
||||||
int CL_GetRandomBloodParticle (void);
|
int CL_GetRandomBloodParticle (void);
|
||||||
void CL_ClipDecal (cparticle_t *part, float radius, float orient, vec3_t origin, vec3_t dir);
|
void CL_ClipDecal (cparticle_t *part, float radius, float orient, vec3_t origin, vec3_t dir);
|
||||||
float CL_NewParticleTime (void);
|
float CL_NewParticleTime (void);
|
||||||
|
|
Loading…
Reference in a new issue