diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-08-27 02:05:07 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-08-27 02:05:07 +0200 |
commit | 088cf57e3cc6b52504b46d74b02a6ec1f5101db3 (patch) | |
tree | 2240109357f9ea3d2f097b4bbf74689500e6c5b4 /crawl-ref/source/zotdef.cc | |
parent | c086f60cd87777a410498bf9690d71cd56b670ac (diff) | |
download | crawl-ref-088cf57e3cc6b52504b46d74b02a6ec1f5101db3.tar.gz crawl-ref-088cf57e3cc6b52504b46d74b02a6ec1f5101db3.zip |
Avoid a pointless loop in ZotDef monster selection.
Diffstat (limited to 'crawl-ref/source/zotdef.cc')
-rw-r--r-- | crawl-ref/source/zotdef.cc | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/crawl-ref/source/zotdef.cc b/crawl-ref/source/zotdef.cc index 96659e896d..5435503796 100644 --- a/crawl-ref/source/zotdef.cc +++ b/crawl-ref/source/zotdef.cc @@ -553,20 +553,19 @@ static monster_type _get_zotdef_monster(level_id &place, int power) monster_type mon_type; for (int i = 0; i <= 10000; ++i) { - int count = 0; int rarity; - do + if (place.branch == NUM_BRANCHES) { - mon_type = static_cast<monster_type>(random2(NUM_MONSTERS)); - count++; - rarity = (place.branch == NUM_BRANCHES) ? 30 - : mons_rarity(mon_type, place.branch); + mon_type = static_cast<monster_type>(random2(NUM_MONSTERS - 1) + 1); + rarity = 30; + } + else + { + mon_type = pick_monster_no_rarity(place.branch); + rarity = mons_rarity(mon_type, place.branch); + ASSERT(rarity > 0); } - while (rarity == 0 && count < 2000); - - if (rarity == 0) - return MONS_PROGRAM_BUG; // Calculate strength monsterentry *mentry = get_monster_data(mon_type); |