summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-09-29 10:17:05 -0500
committerDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-09-29 10:17:05 -0500
commit7f72c37783571cc8a398b0c9d56a2727191c08c4 (patch)
tree4699b222006d112b81f3c2c43d09cd4908167d8a /crawl-ref
parent75f92afc22ec70a6753551d71ecc731712e9e53c (diff)
downloadcrawl-ref-7f72c37783571cc8a398b0c9d56a2727191c08c4.tar.gz
crawl-ref-7f72c37783571cc8a398b0c9d56a2727191c08c4.zip
Simplify several random array selections by using RANDOM_ELEMENT().
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/fight.cc7
-rw-r--r--crawl-ref/source/ghost.cc4
-rw-r--r--crawl-ref/source/mstuff2.cc4
3 files changed, 6 insertions, 9 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 12ab335741..6497ac8fe5 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -4282,12 +4282,9 @@ static const char *klown_attack[] =
std::string melee_attack::mons_attack_verb(const mon_attack_def &attk)
{
if (attacker->id() == MONS_KILLER_KLOWN && attk.type == AT_HIT)
- {
- const int num_attacks = sizeof(klown_attack) / sizeof(*klown_attack);
- return (klown_attack[random2(num_attacks)]);
- }
+ return (RANDOM_ELEMENT(klown_attack));
- if (attacker->id() == MONS_KRAKEN_TENTACLE)
+ if (attacker->id() == MONS_KRAKEN_TENTACLE && attk.type == AT_TENTACLE_SLAP)
return ("slap");
static const char *attack_types[] =
diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc
index 411d9a8dc1..bbd464e0a4 100644
--- a/crawl-ref/source/ghost.cc
+++ b/crawl-ref/source/ghost.cc
@@ -410,7 +410,7 @@ static unsigned char _ugly_thing_random_colour(unsigned char not_colour)
unsigned char colour;
do
- colour = (colours[random2(sizeof(colours) / sizeof(*colours))]);
+ colour = RANDOM_ELEMENT(colours);
while (colour == not_colour);
return (colour);
@@ -518,7 +518,7 @@ void ghost_demon::init_ugly_thing(bool very_ugly, bool only_mutate)
AT_TENTACLE_SLAP, AT_TAIL_SLAP, AT_GORE
};
- att_type = att_types[random2(sizeof(att_types) / sizeof(*att_types))];
+ att_type = RANDOM_ELEMENT(att_types);
// An ugly thing always gets a low-intensity colour. If we're
// mutating it, it always gets a different colour from what it had
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 408a3e79e8..609aa86a6c 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -72,7 +72,7 @@ static monster_type _pick_random_wraith()
MONS_SPECTRAL_WARRIOR
};
- return wraiths[random2(sizeof(wraiths) / sizeof(*wraiths))];
+ return (RANDOM_ELEMENT(wraiths));
}
static monster_type _pick_horrible_thing()
@@ -93,7 +93,7 @@ static monster_type _pick_undead_summon()
MONS_SIMULACRUM_LARGE, MONS_SHADOW
};
- return undead[random2(sizeof(undead) / sizeof(*undead))];
+ return (RANDOM_ELEMENT(undead));
}
static void _do_high_level_summon(monsters *monster, bool monsterNearby,