summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-10-08 07:18:30 -0500
committerDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-10-08 07:18:30 -0500
commit82fd798480e81c7f00741935cf2d69702daee880 (patch)
tree1a9e8e708b65b51d9f13eb431cbd49bbaab5af51 /crawl-ref
parenteb35aeaf1c639f7b575f75f15dfff72b02fbee34 (diff)
downloadcrawl-ref-82fd798480e81c7f00741935cf2d69702daee880.tar.gz
crawl-ref-82fd798480e81c7f00741935cf2d69702daee880.zip
Simplify further.
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/mon-util.cc32
-rw-r--r--crawl-ref/source/mon-util.h4
-rw-r--r--crawl-ref/source/tilepick.cc44
3 files changed, 40 insertions, 40 deletions
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: