diff options
author | Johanna Ploog <j-p-e-g@users.sourceforge.net> | 2010-01-11 21:23:29 +0100 |
---|---|---|
committer | Johanna Ploog <j-p-e-g@users.sourceforge.net> | 2010-01-11 21:33:48 +0100 |
commit | 8faad6519eda40981bbe03c36243a2067a924c8d (patch) | |
tree | 4343f82228d8125fad43dc1b613aaa5235ebe416 /crawl-ref/source/tilepick.cc | |
parent | c9a153bf0e040197b9e5ffe5d7e815dd2bff6844 (diff) | |
download | crawl-ref-8faad6519eda40981bbe03c36243a2067a924c8d.tar.gz crawl-ref-8faad6519eda40981bbe03c36243a2067a924c8d.zip |
Also apply _pick_random_dngn_tile() to animated feature tiles.
Diffstat (limited to 'crawl-ref/source/tilepick.cc')
-rw-r--r-- | crawl-ref/source/tilepick.cc | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index 999a8d38ca..e1697dde23 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -3228,6 +3228,26 @@ int _get_door_offset (int base_tile, bool opened = false, return offset + gateway_type; } +static int _pick_random_dngn_tile(unsigned int idx, int value = -1) +{ + ASSERT(idx >= 0 && idx < TILE_DNGN_MAX); + const int count = tile_dngn_count(idx); + if (count == 1) + return (idx); + + const int total = tile_dngn_probs(idx + count - 1); + const int rand = (value == -1 ? random2(total) : value % total); + + for (int i = 0; i < count; ++i) + { + int curr = idx + i; + if (rand < tile_dngn_probs(curr)) + return (curr); + } + + return (idx); +} + // Modify wall tile index depending on floor/wall flavour. static inline void _finalise_tile(unsigned int *tile, unsigned int wall_flv, @@ -3272,7 +3292,7 @@ static inline void _finalise_tile(unsigned int *tile, if (orig >= TILE_DNGN_LAVA && orig < TILE_BLOOD && you.see_cell(gc)) env.tile_flv(gc).special = random2(256); - (*tile) = orig + (special_flv % tile_dngn_count(orig)); + (*tile) = _pick_random_dngn_tile(orig, special_flv); } (*tile) |= flag; @@ -4510,26 +4530,6 @@ void tile_init_flavour() tile_init_flavour(*ri); } -static int _pick_random_dngn_tile(unsigned int idx) -{ - ASSERT(idx >= 0 && idx < TILE_DNGN_MAX); - const int count = tile_dngn_count(idx); - if (count == 1) - return (idx); - - const int total = tile_dngn_probs(idx + count - 1); - const int rand = random2(total); - - for (int i = 0; i < count; ++i) - { - int curr = idx + i; - if (rand < tile_dngn_probs(curr)) - return (curr); - } - - return (idx); -} - void tile_init_flavour(const coord_def &gc) { if (!map_bounds(gc)) |