diff options
author | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-10-31 18:19:04 -0500 |
---|---|---|
committer | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-10-31 18:19:04 -0500 |
commit | 432fd3111694130fc627da8ee6c27ddbcb79905f (patch) | |
tree | 9029c16d4a2291a6d53d1a646ca37dcb1fe8fab8 /crawl-ref/source/mon-util.cc | |
parent | e2270069f7b23cac4b1249919f980813935d2fd4 (diff) | |
download | crawl-ref-432fd3111694130fc627da8ee6c27ddbcb79905f.tar.gz crawl-ref-432fd3111694130fc627da8ee6c27ddbcb79905f.zip |
Simplify (very) ugly thing color-related functions.
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r-- | crawl-ref/source/mon-util.cc | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 8d37d99192..14ec525994 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1735,42 +1735,31 @@ void define_monster(monsters &mons) mons.ench_countdown = 0; } -unsigned char ugly_thing_random_colour() -{ - const unsigned char colours[] = - { - RED, BROWN, GREEN, CYAN, MAGENTA, LIGHTGREY - }; - - return (RANDOM_ELEMENT(colours)); -} +static const unsigned char ugly_colour_values[] = { + RED, BROWN, GREEN, CYAN, MAGENTA, LIGHTGREY +}; static const char *ugly_colour_names[] = { "red", "brown", "green", "cyan", "purple", "white" }; +unsigned char ugly_thing_random_colour() +{ + return (RANDOM_ELEMENT(ugly_colour_values)); +} + int ugly_thing_colour_offset(const monsters *mon) { if (mon->type != MONS_UGLY_THING && mon->type != MONS_VERY_UGLY_THING) return (-1); - switch (make_low_colour(mon->colour)) + for (unsigned i = 0; i < ARRAYSZ(ugly_colour_values); ++i) { - case RED: - return (0); - case BROWN: - return (1); - case GREEN: - return (2); - case CYAN: - return (3); - case MAGENTA: - return (4); - case LIGHTGREY: - return (5); - default: - return (-1); + if (make_low_colour(mon->colour) == ugly_colour_values[i]) + return (i); } + + return (-1); } static std::string _ugly_thing_colour_name(const monsters *mon) |