Skip to content

Commit

Permalink
fix undefined behavior in linearsky calculation (#2157)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfomin authored Jan 26, 2025
1 parent a6b0c1e commit bdd5630
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,11 @@ static void R_InitTextureMapping(void)
;
xtoviewangle[x] = (i<<ANGLETOFINESHIFT)-ANG90;
// [FG] linear horizontal sky scrolling
linearskyangle[x] = (0.5 - x / (double)viewwidth) * linearskyfactor;
int angle = (0.5 - x / (double)viewwidth) * linearskyfactor;
if (angle >= 0)
linearskyangle[x] = angle;
else
linearskyangle[x] = ANG90 + angle;
}

// Take out the fencepost cases from viewangletox.
Expand Down

0 comments on commit bdd5630

Please sign in to comment.