make r_particles truely a flag and call R_MaxParticlesCheck when r_particles

changes
This commit is contained in:
Bill Currie 2001-10-27 08:31:45 +00:00
parent aa6472da2b
commit d9fd8dc29f
2 changed files with 19 additions and 9 deletions

View file

@ -141,8 +141,11 @@ r_particles_f (cvar_t *var)
{
if (!var->int_val)
R_ClearParticles ();
r_maxparticles = 0;
if (var->int_val && cl_max_particles)
r_maxparticles = cl_max_particles->int_val;
if (cl_max_particles)
r_maxparticles = var->int_val * cl_max_particles->int_val;
R_MaxParticlesCheck (cl_max_particles);
}
void

View file

@ -65,21 +65,28 @@ R_MaxParticlesCheck (cvar_t *var)
Prevents a segfault since if we grabbed the int_val of cl_max_particles
we'd sig11 right here at startup.
*/
if (r_particles)
r_maxparticles = max(var->int_val * r_particles->int_val, 0);
if (r_particles && r_particles->int_val)
r_maxparticles = var->int_val;
else
r_maxparticles = max(var->int_val, 0);
r_maxparticles = 0;
/*
Be very careful the next time we do something like this. calloc/free are
IMPORTANT and the compiler doesn't know when we do bad things with them.
*/
free (particles);
free (freeparticles);
if (particles)
free (particles);
if (freeparticles)
free (freeparticles);
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
freeparticles = (particle_t **) calloc (r_maxparticles,
sizeof (particle_t *));
particles = 0;
freeparticles = 0;
if (r_maxparticles) {
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
freeparticles = (particle_t **) calloc (r_maxparticles,
sizeof (particle_t *));
}
R_ClearParticles();
}