diff --git a/src/Builder.c b/src/Builder.c index 25e0ff53a..ca365f69c 100644 --- a/src/Builder.c +++ b/src/Builder.c @@ -771,6 +771,10 @@ enum ADV_MASK { xP1_yM1_zP1, xP1_yCC_zP1, xP1_yP1_zP1, }; +/* Bit-or the Adv_Lit flags with these to set the appropriate light values */ +#define LIT_M1 (1 << 0) +#define LIT_CC (1 << 1) +#define LIT_P1 (1 << 2) /* Returns a 3 bit value where */ /* - bit 0 set: Y-1 is in light */ /* - bit 1 set: Y is in light */ @@ -778,11 +782,11 @@ enum ADV_MASK { static int Adv_Lit(int x, int y, int z, int cIndex) { int flags, offset, lightFlags; BlockID block; - if (y < 0 || y >= World.Height) return 7; /* all faces lit */ + if (y < 0 || y >= World.Height) return LIT_M1 | LIT_CC | LIT_P1; /* all faces lit */ /* TODO: check sides height (if sides > edges), check if edge block casts a shadow */ if (!World_ContainsXZ(x, z)) { - return y >= Builder_EdgeLevel ? 7 : y == (Builder_EdgeLevel - 1) ? 6 : 0; + return y >= Builder_EdgeLevel ? LIT_M1 | LIT_CC | LIT_P1 : y == (Builder_EdgeLevel - 1) ? LIT_CC | LIT_P1 : 0; } flags = 0; @@ -791,19 +795,19 @@ static int Adv_Lit(int x, int y, int z, int cIndex) { /* Use fact Light(Y.YMin) == Light((Y-1).YMax) */ offset = (lightFlags >> FACE_YMIN) & 1; - flags |= Lighting_IsLit_Fast(x, y - offset, z) ? 1 : 0; + flags |= Lighting_IsLit_Fast(x, y - offset, z) ? LIT_M1 : 0; /* Light is same for all the horizontal faces */ - flags |= Lighting_IsLit_Fast(x, y, z) ? 1 << 1 : 0; + flags |= Lighting_IsLit_Fast(x, y, z) ? LIT_CC : 0; /* Use fact Light((Y+1).YMin) == Light(Y.YMax) */ offset = (lightFlags >> FACE_YMAX) & 1; - flags |= Lighting_IsLit_Fast(x, (y + 1) - offset, z) ? 1 << 2 : 0; + flags |= Lighting_IsLit_Fast(x, (y + 1) - offset, z) ? LIT_P1 : 0; /* If a block is fullbright, it should also look as if that spot is lit */ - if (Blocks.FullBright[Builder_Chunk[cIndex - 324]]) flags |= 1; - if (Blocks.FullBright[block]) flags |= 1 << 1; - if (Blocks.FullBright[Builder_Chunk[cIndex + 324]]) flags |= 1 << 2; + if (Blocks.FullBright[Builder_Chunk[cIndex - 324]]) flags |= LIT_M1; + if (Blocks.FullBright[block]) flags |= LIT_CC; + if (Blocks.FullBright[Builder_Chunk[cIndex + 324]]) flags |= LIT_P1; return flags; }