mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Fix custom blocks with no fog in .cw files mistakenly still being loaded with fog density
The easiest way to reproduce this was to use noclip to move inside a solid custom block, and then notice the horizon has become black fog To solve this problem for both current and past client versions: - when the read FogDensity value is 0, the in-memory fog density value is set to 0 - when writing FogDensity values to disc, 0xFF instead of 0 is written to indicate 'no fog' (since older client versions convert FogDensity values of 0xFF to 0 in-memory)
This commit is contained in:
parent
b168adc7fe
commit
dd45c90b4c
@ -836,8 +836,8 @@ static void Cw_Callback_5(struct NbtTag* tag) {
|
|||||||
if (!arr) return;
|
if (!arr) return;
|
||||||
|
|
||||||
Blocks.FogDensity[id] = (arr[0] + 1) / 128.0f;
|
Blocks.FogDensity[id] = (arr[0] + 1) / 128.0f;
|
||||||
/* Fix for older ClassicalSharp versions which saved wrong fog density value */
|
/* Backwards compatibility with apps that use 0xFF to indicate no fog */
|
||||||
if (arr[0] == 0xFF) Blocks.FogDensity[id] = 0.0f;
|
if (arr[0] == 0 || arr[0] == 0xFF) Blocks.FogDensity[id] = 0.0f;
|
||||||
Blocks.FogCol[id] = PackedCol_Make(arr[1], arr[2], arr[3], 255);
|
Blocks.FogCol[id] = PackedCol_Make(arr[1], arr[2], arr[3], 255);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1548,7 +1548,7 @@ static cc_result Cw_WriteBockDef(struct Stream* stream, int b) {
|
|||||||
cur = Nbt_WriteArray(cur, "Fog", 4);
|
cur = Nbt_WriteArray(cur, "Fog", 4);
|
||||||
fog = (cc_uint8)(128 * Blocks.FogDensity[b] - 1);
|
fog = (cc_uint8)(128 * Blocks.FogDensity[b] - 1);
|
||||||
col = Blocks.FogCol[b];
|
col = Blocks.FogCol[b];
|
||||||
cur[0] = Blocks.FogDensity[b] ? fog : 0;
|
cur[0] = Blocks.FogDensity[b] ? fog : 0xFF; /* write 0xFF instead of 0 for backwards compatibility */
|
||||||
cur[1] = PackedCol_R(col); cur[2] = PackedCol_G(col); cur[3] = PackedCol_B(col);
|
cur[1] = PackedCol_R(col); cur[2] = PackedCol_G(col); cur[3] = PackedCol_B(col);
|
||||||
cur += 4;
|
cur += 4;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user