diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-06 11:03:21 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-06 11:03:21 +0000 |
commit | 960323c5b08a5431ac60b72c7de65a40ef203183 (patch) | |
tree | 6571ec0d182fd5a597968a0415f80a15bbea3680 /crawl-ref/source/spells2.cc | |
parent | 6efc5c639a0ba48559c2fad77376a210b503256c (diff) | |
download | crawl-ref-960323c5b08a5431ac60b72c7de65a40ef203183.tar.gz crawl-ref-960323c5b08a5431ac60b72c7de65a40ef203183.zip |
Fix 1945389: Detect Creatures not clearing monsters detected on changed
terrain.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6419 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells2.cc')
-rw-r--r-- | crawl-ref/source/spells2.cc | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index a8ec9cab63..fa7bfee000 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -98,15 +98,21 @@ unsigned char detect_items( int pow ) pow = 50; unsigned char items_found = 0; - const int map_radius = 8 + random2(8) + pow; + const int map_radius = 8 + random2(8) + pow; for (int i = you.x_pos - map_radius; i < you.x_pos + map_radius; i++) - { for (int j = you.y_pos - map_radius; j < you.y_pos + map_radius; j++) { if (!in_bounds(i, j)) continue; + // Don't expose new dug out areas: + // Note: assumptions are being made here about how + // terrain can change (eg it used to be solid, and + // thus item free). + if (is_terrain_changed(i, j)) + continue; + if (igrd[i][j] != NON_ITEM && (!get_envmap_obj(i, j) || !is_envmap_item(i, j))) { @@ -121,7 +127,6 @@ unsigned char detect_items( int pow ) #endif } } - } return (items_found); } @@ -159,12 +164,25 @@ static bool _mark_detected_creature(int gridx, int gridy, const monsters *mon, const int fuzz_diam = 2 * fuzz_radius + 1; int gx, gy; + // Try five times to find a valid placement, else we attempt to place + // the monster where it really is (and may fail). for (int itry = 0; itry < 5; ++itry) { gx = gridx + random2(fuzz_diam) - fuzz_radius; gy = gridy + random2(fuzz_diam) - fuzz_radius; - if (map_bounds(gx, gy) + // If the player would be able to see a monster at this location + // don't place it there. + if (see_grid(gx, gy)) + continue; + + // Try not to overwrite another detected monster. + if (is_envmap_detected_mons(gx, gy)) + continue; + + // Don't print monsters on terrain they cannot pass through, + // not even if said terrain has since changed. + if (map_bounds(gx, gy) && !is_terrain_changed(gx, gy) && mon->can_pass_through_feat(grd[gx][gy])) { found_good = true; @@ -217,9 +235,6 @@ int detect_creatures( int pow, bool telepathic ) monsters *mon = &menv[ mgrd[i][j] ]; creatures_found++; - // This only returns whether a valid "fuzzy" place has been - // found for the monster. In any case, the monster gets - // printed on the screen. _mark_detected_creature(i, j, mon, fuzz_chance, fuzz_radius); // Assuming that highly intelligent spellcasters can |