diff options
author | Zack Middleton <zturtleman@gmail.com> | 2013-06-20 21:56:04 -0500 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-06-17 17:43:32 +0100 |
commit | dee702aaf3c7ff8dd5bcf63d1847ce5c4c79ac19 (patch) | |
tree | b5d8cc5475e7c989038c064a6e8b8af4ac51476f | |
parent | 0f76e330757dfab0f3e4cb5bb9dd4566a5397ba7 (diff) |
Fix r_mergeLightmaps 0 crashing OpenGL2 renderer
tr.fatLightmapStep was 0 and caused modulus division by 0.
-rw-r--r-- | src/renderergl2/tr_bsp.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/renderergl2/tr_bsp.c b/src/renderergl2/tr_bsp.c index f32c2365..456456fa 100644 --- a/src/renderergl2/tr_bsp.c +++ b/src/renderergl2/tr_bsp.c @@ -525,11 +525,13 @@ static float FatPackU(float input, int lightmapnum) if (tr.worldDeluxeMapping) lightmapnum >>= 1; - lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); - if(tr.fatLightmapSize > 0) { - int x = lightmapnum % tr.fatLightmapStep; + int x; + + lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); + + x = lightmapnum % tr.fatLightmapStep; return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)x); } @@ -545,11 +547,13 @@ static float FatPackV(float input, int lightmapnum) if (tr.worldDeluxeMapping) lightmapnum >>= 1; - lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); - if(tr.fatLightmapSize > 0) { - int y = lightmapnum / tr.fatLightmapStep; + int y; + + lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); + + y = lightmapnum / tr.fatLightmapStep; return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)y); } |