fixed an R_InitSky warning regarding transpix being uninitialized, added transpixunio...
[xonotic/darkplaces.git] / r_sky.c
diff --git a/r_sky.c b/r_sky.c
index 530fc19..2995a85 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -385,6 +385,12 @@ void R_InitSky (qbyte *src, int bytesperpixel)
        int i, j, p, r, g, b;
        qbyte skyupperlayerpixels[128*128*4], skylowerlayerpixels[128*128*4];
        unsigned trans[128*128], transpix, *rgba;
+       union
+       {
+               int i;
+               qbyte b[4];
+       }
+       transpixunion;
 
        skyavailable_quake = true;
 
@@ -396,6 +402,7 @@ void R_InitSky (qbyte *src, int bytesperpixel)
 
        if (bytesperpixel == 4)
        {
+               transpixunion.i = 0;
                for (i = 0;i < 128;i++)
                        for (j = 0;j < 128;j++)
                                trans[(i*128) + j] = ((unsigned *)src)[i*256+j+128];
@@ -418,11 +425,13 @@ void R_InitSky (qbyte *src, int bytesperpixel)
                        }
                }
 
-               ((qbyte *)&transpix)[0] = r/(128*128);
-               ((qbyte *)&transpix)[1] = g/(128*128);
-               ((qbyte *)&transpix)[2] = b/(128*128);
-               ((qbyte *)&transpix)[3] = 0;
+               transpixunion.i = 0;
+               transpixunion.b[0] = r/(128*128);
+               transpixunion.b[1] = g/(128*128);
+               transpixunion.b[2] = b/(128*128);
+               transpixunion.b[3] = 0;
        }
+       transpix = transpixunion.i;
 
        memcpy(skyupperlayerpixels, trans, 128*128*4);