Skip to content

Commit

Permalink
- Fix crash with fog and software light modes.
Browse files Browse the repository at this point in the history
  • Loading branch information
drfrag666 authored and madame-rachelle committed Mar 29, 2021
1 parent 4e503a1 commit 25ab8e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rendering/hwrenderer/scene/hw_setcolor.cpp
Expand Up @@ -106,7 +106,7 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
fogdensity = 70;
fogcolor = 0x808080;
}
else if (cmap != NULL && !fullbright)
else if (cmap != nullptr && !fullbright)
{
fogcolor = cmap->FadeColor;
fogdensity = GetFogDensity(lightlevel, fogcolor, cmap->FogDensity, cmap->BlendFactor);
Expand All @@ -130,7 +130,7 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
}
else
{
if ((lightmode == ELightMode::Doom || (isSoftwareLighting() && cmap->BlendFactor > 0)) && fogcolor == 0)
if ((lightmode == ELightMode::Doom || (isSoftwareLighting() && cmap && cmap->BlendFactor > 0)) && fogcolor == 0)
{
float light = (float)CalcLightLevel(lightlevel, rellight, false, cmap->BlendFactor);
SetShaderLight(state, light, lightlevel);
Expand All @@ -155,7 +155,7 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
state.SetFog(fogcolor, fogdensity);

// Korshun: fullbright fog like in software renderer.
if (isSoftwareLighting() && cmap->BlendFactor == 0 && Level->brightfog && fogdensity != 0 && fogcolor != 0)
if (isSoftwareLighting() && cmap && cmap->BlendFactor == 0 && Level->brightfog && fogdensity != 0 && fogcolor != 0)
{
state.SetSoftLightLevel(255);
}
Expand Down

0 comments on commit 25ab8e2

Please sign in to comment.