mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
r_dlight_max can now safely be 0
This commit is contained in:
parent
fda073acb6
commit
a65d98a35c
1 changed files with 14 additions and 9 deletions
|
@ -57,15 +57,13 @@ unsigned int r_maxdlights;
|
||||||
void
|
void
|
||||||
R_MaxDlightsCheck (cvar_t *var)
|
R_MaxDlightsCheck (cvar_t *var)
|
||||||
{
|
{
|
||||||
// FIXME: 1 minimum should be 0, if it doesn't require excess testing in
|
r_maxdlights = max(var->int_val, 0);
|
||||||
// *_rsurf.c
|
|
||||||
if (r_dynamic)
|
|
||||||
r_maxdlights = max(var->int_val * r_dynamic->int_val, 1);
|
|
||||||
else
|
|
||||||
r_maxdlights = max(var->int_val, 1);
|
|
||||||
|
|
||||||
|
if (r_dlights)
|
||||||
free (r_dlights);
|
free (r_dlights);
|
||||||
|
r_dlights=0;
|
||||||
|
|
||||||
|
if (r_maxdlights)
|
||||||
r_dlights = (dlight_t *) calloc (r_maxdlights, sizeof (dlight_t));
|
r_dlights = (dlight_t *) calloc (r_maxdlights, sizeof (dlight_t));
|
||||||
|
|
||||||
R_ClearDlights();
|
R_ClearDlights();
|
||||||
|
@ -433,6 +431,12 @@ R_AllocDlight (int key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
dlight_t *dl;
|
dlight_t *dl;
|
||||||
|
static dlight_t dummy;
|
||||||
|
|
||||||
|
if (!r_maxdlights) {
|
||||||
|
memset (&dummy, 0, sizeof (dummy));
|
||||||
|
return &dummy;
|
||||||
|
}
|
||||||
|
|
||||||
// first look for an exact key match
|
// first look for an exact key match
|
||||||
if (key) {
|
if (key) {
|
||||||
|
@ -483,5 +487,6 @@ R_DecayLights (double frametime)
|
||||||
void
|
void
|
||||||
R_ClearDlights (void)
|
R_ClearDlights (void)
|
||||||
{
|
{
|
||||||
memset (r_dlights, 0, sizeof (r_dlights));
|
if (r_maxdlights)
|
||||||
|
memset (r_dlights, 0, r_maxdlights * sizeof (dlight_t));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue