Skip to content

Commit

Permalink
Clamp tod_color values in the [-510, 510] range instead of [-255, 255]
Browse files Browse the repository at this point in the history
[color_adjust] needs to be able to use absolute values as large as
2*255 in certain edge cases to set the screen a single solid colour when
interacting with time of day colour shifts.

Fixes #3144.
  • Loading branch information
irydacea committed May 21, 2018
1 parent 9c1da12 commit 711e9a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Expand Up @@ -25,6 +25,8 @@
* Experimental AI: fixed recruiting evaluations sometimes not being updated
* Replaced deprecated Lua code and all remaining uses of FOREACH and MESSAGE
macros
* Fixed [color_adjust] interacting poorly with time of day color shifts and
values outside the [-255, 255] range (issue #3144).

## Version 1.14.1
### Campaigns
Expand Down
6 changes: 3 additions & 3 deletions src/time_of_day.hpp
Expand Up @@ -27,9 +27,9 @@ class config;
// This is a color delta, so do not replace with color_t!
struct tod_color {
explicit tod_color(int red = 0, int green = 0, int blue = 0)
: r(utils::clamp(red, -255, 255))
, g(utils::clamp(green, -255, 255))
, b(utils::clamp(blue, -255, 255))
: r(utils::clamp(red, -510, 510))
, g(utils::clamp(green, -510, 510))
, b(utils::clamp(blue, -510, 510))
{}
bool operator==(const tod_color& o) const {
return r == o.r && g == o.g && b == o.b;
Expand Down

0 comments on commit 711e9a2

Please sign in to comment.