From 82fd798480e81c7f00741935cf2d69702daee880 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Thu, 8 Oct 2009 07:18:30 -0500 Subject: Simplify further. --- crawl-ref/source/mon-util.cc | 32 +++++++++++++++++++++++--------- crawl-ref/source/mon-util.h | 4 ++-- crawl-ref/source/tilepick.cc | 44 +++++++++++++++----------------------------- 3 files changed, 40 insertions(+), 40 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 091b3d5089..da6a84acde 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -2005,30 +2005,44 @@ void define_monster(monsters &mons) mons.ench_countdown = 0; } -static std::string _ugly_thing_colour_name(const monsters *mon) +static const char *ugly_colour_names[] = { + "green", "cyan", "red", "purple", "brown", "white" +}; + +int ugly_thing_colour_offset(const monsters *mon) { if (mon->type != MONS_UGLY_THING && mon->type != MONS_VERY_UGLY_THING) - return ("buggy"); + return (-1); switch (make_low_colour(mon->colour)) { case GREEN: - return ("green"); + return (0); case CYAN: - return ("cyan"); + return (1); case RED: - return ("red"); + return (2); case MAGENTA: - return ("purple"); + return (3); case BROWN: - return ("brown"); + return (4); case LIGHTGREY: - return ("white"); + return (5); default: - return ("buggy"); + return (-1); } } +static std::string _ugly_thing_colour_name(const monsters *mon) +{ + const int colour_offset = ugly_thing_colour_offset(mon); + + if (colour_offset == -1) + return ("buggy"); + + return (ugly_colour_names[colour_offset]); +} + static const char *drac_colour_names[] = { "black", "mottled", "yellow", "green", "purple", "red", "white", "pale" }; diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index 21f859d755..9f8d86147e 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -848,8 +848,8 @@ bool mons_cannot_move(const monsters *m); bool monster_senior(const monsters *first, const monsters *second, bool fleeing = false); -monster_type draco_subspecies( const monsters *mon ); -std::string draconian_colour_name(monster_type mtype); +monster_type draco_subspecies(const monsters *mon); +int ugly_thing_colour_offset(const monsters *mon); monster_type draconian_colour_by_name(const std::string &colour); monster_type random_monster_at_grid(const coord_def& p); diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index ccb6bf102c..591a6459fe 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -101,7 +101,7 @@ static int _bow_offset(const monsters *mon) { int mon_wep = mon->inv[MSLOT_WEAPON]; if (mon_wep == NON_ITEM) - return 1; + return (1); switch (mitm[mon_wep].sub_type) { @@ -109,33 +109,9 @@ static int _bow_offset(const monsters *mon) case WPN_LONGBOW: case WPN_CROSSBOW: case WPN_HAND_CROSSBOW: - return 0; - default: - return 1; - } -} - -static int _ugly_thing_colour_offset(const monsters *mon) -{ - if (mon->type != MONS_UGLY_THING && mon->type != MONS_VERY_UGLY_THING) return (0); - - switch (make_low_colour(mon->colour)) - { - case GREEN: - return (0); - case CYAN: - return (1); - case RED: - return (2); - case MAGENTA: - return (3); - case BROWN: - return (4); - case LIGHTGREY: - return (5); - default: - return (0); + default: + return (1); } } @@ -376,9 +352,19 @@ int tileidx_monster_base(const monsters *mon, bool detected) // ugly things ('u') case MONS_UGLY_THING: - return TILEP_MONS_UGLY_THING + _ugly_thing_colour_offset(mon); + { + const int colour_offset = ugly_thing_colour_offset(mon); + if (colour_offset == -1) + colour_offset = 0; + return TILEP_MONS_UGLY_THING + colour_offset; + } case MONS_VERY_UGLY_THING: - return TILEP_MONS_VERY_UGLY_THING + _ugly_thing_colour_offset(mon); + { + const int colour_offset = ugly_thing_colour_offset(mon); + if (colour_offset == -1) + colour_offset = 0; + return TILEP_MONS_VERY_UGLY_THING + colour_offset; + } // vortices ('v') case MONS_FIRE_VORTEX: -- cgit v1.2.3-54-g00ecf