lighting: add BUGFIX for MakeLightTable

The i/j/k/l variables obfuscate the fact that the distance
formula used for generating data in lightblock is using the x
offset with the y component of the tile coordinate and vice-versa.

Mixing x and y this way causes light to move horizontally within
a tile when the light source is moving vertically and vice-versa.
This commit is contained in:
staphen
2025-03-07 12:36:11 -05:00
committed by Anders Jenbo
parent e30328b316
commit 14a9620921

View File

@@ -1003,6 +1003,9 @@ void MakeLightTable()
fs = (BYTE)sqrt((8 * l - j) * (8 * l - j) + (8 * k - i) * (8 * k - i));
fs += fs < 0 ? -0.5 : 0.5;
// BUGFIX: This error causes a "jittery" effect when a light source moves.
// Swap the addition and multiplication operators to fix the lookup table.
// lightblock[j + 8 * i][k][l] = fs;
lightblock[j * 8 + i][k][l] = fs;
}
}