diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-03-13 04:34:08 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-03-13 10:43:28 +0100 |
commit | 1495978437e71a2461e7d35e00e16c8edc131d13 (patch) | |
tree | 2d6c1e283f1ea5337dfa8a8c279f55ef850bc888 /crawl-ref/source/colour.cc | |
parent | b10dbcdf6daad946e426cdb08687ad89c004af5c (diff) | |
download | crawl-ref-1495978437e71a2461e7d35e00e16c8edc131d13.tar.gz crawl-ref-1495978437e71a2461e7d35e00e16c8edc131d13.zip |
Declare an explicit type for colours.
An imperial buttload of places assumes these to be 8 bits, which makes it
impossible to add support for 256 (or more!) colours. This commit tries
to allow expanding it in the future; sadly, it is badly incomplete. At
least, new code can use the new type.
Also, beware of "branded" colours which use bits above 8 for inverse,
underline, etc.
Diffstat (limited to 'crawl-ref/source/colour.cc')
-rw-r--r-- | crawl-ref/source/colour.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/crawl-ref/source/colour.cc b/crawl-ref/source/colour.cc index 77af9628d0..4f70936d59 100644 --- a/crawl-ref/source/colour.cc +++ b/crawl-ref/source/colour.cc @@ -65,14 +65,14 @@ int random_element_colour_calc::get(const coord_def& loc, bool non_random) return (*real_calc)(rand(non_random), loc, rand_vals); } -uint8_t random_colour(void) +colour_t random_colour(void) { return (1 + random2(15)); } -uint8_t random_uncommon_colour() +colour_t random_uncommon_colour() { - uint8_t result; + colour_t result; do result = random_colour(); @@ -81,17 +81,17 @@ uint8_t random_uncommon_colour() return (result); } -bool is_low_colour(uint8_t colour) +bool is_low_colour(colour_t colour) { return (colour <= 7); } -bool is_high_colour(uint8_t colour) +bool is_high_colour(colour_t colour) { return (colour >= 8 && colour <= 15); } -uint8_t make_low_colour(uint8_t colour) +colour_t make_low_colour(colour_t colour) { if (is_high_colour(colour)) return (colour - 8); @@ -99,7 +99,7 @@ uint8_t make_low_colour(uint8_t colour) return (colour); } -uint8_t make_high_colour(uint8_t colour) +colour_t make_high_colour(colour_t colour) { if (is_low_colour(colour)) return (colour + 8); @@ -661,14 +661,14 @@ unsigned int str_to_tile_colour(std::string colour) } #endif -const std::string cols[16] = +static const std::string cols[16] = { "black", "blue", "green", "cyan", "red", "magenta", "brown", "lightgrey", "darkgrey", "lightblue", "lightgreen", "lightcyan", "lightred", "lightmagenta", "yellow", "white" }; -const std::string colour_to_str(uint8_t colour) +const std::string colour_to_str(colour_t colour) { if (colour >= 16) return "lightgrey"; @@ -784,7 +784,7 @@ static unsigned short _dos_hilite_brand(unsigned short colour, } unsigned short dos_brand(unsigned short colour, - unsigned brand) + unsigned brand) { if ((brand & CHATTR_ATTRMASK) == CHATTR_NORMAL) return (colour); |