summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monplace.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-18 17:28:03 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-18 18:17:47 +0530
commit4eae47b87412963d8047e52f6befc109cd9231b4 (patch)
tree099b4579699d6929b2081a96c2a492cde2818de8 /crawl-ref/source/monplace.cc
parent20499e4d29a0af3143ca2aaa163390d97c04c258 (diff)
downloadcrawl-ref-4eae47b87412963d8047e52f6befc109cd9231b4.tar.gz
crawl-ref-4eae47b87412963d8047e52f6befc109cd9231b4.zip
[2881182] Fix being unable to place flying monsters over lava in maps (due).
Diffstat (limited to 'crawl-ref/source/monplace.cc')
-rw-r--r--crawl-ref/source/monplace.cc40
1 files changed, 14 insertions, 26 deletions
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 01306bb13b..8479914609 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -689,34 +689,22 @@ static int _is_near_stairs(coord_def &p)
// is true, then we'll be less rigorous in our checks, in particular
// allowing land monsters to be placed in shallow water and water
// creatures in fountains.
-static bool _valid_monster_location(const mgen_data &mg,
- const coord_def &mg_pos)
+static bool _valid_monster_generation_location(
+ const mgen_data &mg,
+ const coord_def &mg_pos)
{
- const int montype = (mons_class_is_zombified(mg.cls) ? mg.base_type
- : mg.cls);
- const dungeon_feature_type feat_preferred =
- habitat2grid(mons_class_primary_habitat(montype));
- const dungeon_feature_type feat_nonpreferred =
- habitat2grid(mons_class_secondary_habitat(montype));
-
- if (!in_bounds(mg_pos))
+ if (!in_bounds(mg_pos) || actor_at(mg_pos))
return (false);
- // Occupied?
- if (actor_at(mg_pos))
- return (false);
-
- // Is the monster happy where we want to put it?
- if (!feat_compatible(feat_preferred, grd(mg_pos))
- && (feat_nonpreferred == feat_preferred
- || !feat_compatible(feat_nonpreferred, grd(mg_pos))))
+ const int montype = (mons_class_is_zombified(mg.cls) ? mg.base_type
+ : mg.cls);
+ if (!monster_habitable_grid(montype, grd(mg_pos),
+ mons_class_flies(montype), false)
+ || (mg.behaviour != BEH_FRIENDLY && is_sanctuary(mg_pos)))
{
return (false);
}
- if (mg.behaviour != BEH_FRIENDLY && is_sanctuary(mg_pos))
- return (false);
-
// Don't generate monsters on top of teleport traps.
// (How did they get there?)
const trap_def* ptrap = find_trap(mg_pos);
@@ -726,9 +714,9 @@ static bool _valid_monster_location(const mgen_data &mg,
return (true);
}
-static bool _valid_monster_location(mgen_data &mg)
+static bool _valid_monster_generation_location(mgen_data &mg)
{
- return _valid_monster_location(mg, mg.pos);
+ return _valid_monster_generation_location(mg, mg.pos);
}
int place_monster(mgen_data mg, bool force_pos)
@@ -829,7 +817,7 @@ int place_monster(mgen_data mg, bool force_pos)
if (mg.proximity != PROX_NEAR_STAIRS)
mg.pos = random_in_bounds();
- if (!_valid_monster_location(mg))
+ if (!_valid_monster_generation_location(mg))
continue;
// Is the grid verboten?
@@ -900,7 +888,7 @@ int place_monster(mgen_data mg, bool force_pos)
break;
} // end while... place first monster
}
- else if (!_valid_monster_location(mg))
+ else if (!_valid_monster_generation_location(mg))
{
// Sanity check that the specified position is valid.
return (-1);
@@ -1046,7 +1034,7 @@ static int _place_monster_aux(const mgen_data &mg,
fpos = mg.pos + coord_def( random_range(-3, 3),
random_range(-3, 3) );
- if (_valid_monster_location(mg, fpos))
+ if (_valid_monster_generation_location(mg, fpos))
break;
}