From d79fe658783a1310772d52d95f0704ceb2ddd918 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 20 Jun 2013 21:56:04 -0500 Subject: [PATCH] Fix r_mergeLightmaps 0 crashing OpenGL2 renderer tr.fatLightmapStep was 0 and caused modulus division by 0. --- code/renderergl2/tr_bsp.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/code/renderergl2/tr_bsp.c b/code/renderergl2/tr_bsp.c index 01556cdd..05b933e8 100644 --- a/code/renderergl2/tr_bsp.c +++ b/code/renderergl2/tr_bsp.c @@ -524,11 +524,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); } @@ -544,11 +546,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); }