mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 12:52:46 +00:00
make r_particles truely a flag and call R_MaxParticlesCheck when r_particles
changes
This commit is contained in:
parent
aa6472da2b
commit
d9fd8dc29f
2 changed files with 19 additions and 9 deletions
|
@ -141,8 +141,11 @@ r_particles_f (cvar_t *var)
|
||||||
{
|
{
|
||||||
if (!var->int_val)
|
if (!var->int_val)
|
||||||
R_ClearParticles ();
|
R_ClearParticles ();
|
||||||
|
r_maxparticles = 0;
|
||||||
|
if (var->int_val && cl_max_particles)
|
||||||
|
r_maxparticles = cl_max_particles->int_val;
|
||||||
if (cl_max_particles)
|
if (cl_max_particles)
|
||||||
r_maxparticles = var->int_val * cl_max_particles->int_val;
|
R_MaxParticlesCheck (cl_max_particles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -65,21 +65,28 @@ R_MaxParticlesCheck (cvar_t *var)
|
||||||
Prevents a segfault since if we grabbed the int_val of cl_max_particles
|
Prevents a segfault since if we grabbed the int_val of cl_max_particles
|
||||||
we'd sig11 right here at startup.
|
we'd sig11 right here at startup.
|
||||||
*/
|
*/
|
||||||
if (r_particles)
|
if (r_particles && r_particles->int_val)
|
||||||
r_maxparticles = max(var->int_val * r_particles->int_val, 0);
|
r_maxparticles = var->int_val;
|
||||||
else
|
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
|
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.
|
IMPORTANT and the compiler doesn't know when we do bad things with them.
|
||||||
*/
|
*/
|
||||||
free (particles);
|
if (particles)
|
||||||
free (freeparticles);
|
free (particles);
|
||||||
|
if (freeparticles)
|
||||||
|
free (freeparticles);
|
||||||
|
|
||||||
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
|
particles = 0;
|
||||||
freeparticles = (particle_t **) calloc (r_maxparticles,
|
freeparticles = 0;
|
||||||
sizeof (particle_t *));
|
|
||||||
|
if (r_maxparticles) {
|
||||||
|
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
|
||||||
|
freeparticles = (particle_t **) calloc (r_maxparticles,
|
||||||
|
sizeof (particle_t *));
|
||||||
|
}
|
||||||
|
|
||||||
R_ClearParticles();
|
R_ClearParticles();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue