summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-09-24 09:10:54 -0500
committerDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-09-24 09:10:54 -0500
commitd9cd88309313fabdb6437443b1319c1a813b8dcc (patch)
tree6a2903b207fda73f720088ea7843f3b123c39cc7
parent05fa6a72a07d319aedbf3993384e847bab921d9b (diff)
downloadcrawl-ref-d9cd88309313fabdb6437443b1319c1a813b8dcc.tar.gz
crawl-ref-d9cd88309313fabdb6437443b1319c1a813b8dcc.zip
Backport fix for [2865661] to 0.5.
-rw-r--r--crawl-ref/source/dungeon.cc3
-rw-r--r--crawl-ref/source/mon-util.cc39
2 files changed, 18 insertions, 24 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 93418cf7eb..a260e77785 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -4566,7 +4566,8 @@ static void _dgn_give_mon_spec_items(mons_spec &mspec,
if (item_made != NON_ITEM && item_made != -1)
{
item_def &item(mitm[item_made]);
- mon.pickup_item(item, 0, true);
+ if (!mon.pickup_item(item, 0, true))
+ destroy_item(item_made, true);
}
}
}
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index d2996b26e8..f7b617d780 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -3875,7 +3875,7 @@ item_def *monsters::weapon(int which_attack)
return NULL;
// Even/odd attacks use main/offhand weapon
- if ( which_attack > 1 )
+ if (which_attack > 1)
which_attack &= 1;
// This randomly picks one of the wielded weapons for monsters that can use
@@ -5115,17 +5115,6 @@ bool monsters::pickup_potion(item_def &item, int near)
if (!this->can_drink_potion(ptype))
return (false);
- switch (ptype)
- {
- case POT_SPEED:
- case POT_INVISIBILITY:
- // If there are any item using monsters that are permanently
- // invisible, this might have to be restricted.
- break;
- default:
- return (false);
- }
-
return (pickup(item, MSLOT_POTION, near));
}
@@ -8035,16 +8024,18 @@ bool monsters::can_drink_potion(potion_type ptype) const
if (mons_class_is_stationary(this->type))
return (false);
- if (mons_itemuse(this) >= MONUSE_STARTING_EQUIPMENT)
+ if (mons_itemuse(this) < MONUSE_STARTING_EQUIPMENT)
+ return (false);
+
+ // These monsters cannot drink.
+ if (mons_is_skeletal(type) || mons_is_insubstantial(type)
+ || mons_species() == MONS_LICH || mons_genus(type) == MONS_MUMMY)
{
- if (mons_is_skeletal(type) || mons_is_insubstantial(type)
- || mons_species() == MONS_LICH || mons_genus(type) == MONS_MUMMY)
- {
- return (false);
- }
+ return (false);
+ }
- switch (ptype)
- {
+ switch (ptype)
+ {
case POT_HEALING:
case POT_HEAL_WOUNDS:
return (holiness() != MH_NONLIVING
@@ -8052,11 +8043,13 @@ bool monsters::can_drink_potion(potion_type ptype) const
case POT_BLOOD:
case POT_BLOOD_COAGULATED:
return (mons_species() == MONS_VAMPIRE);
+ case POT_SPEED:
+ case POT_INVISIBILITY:
+ // If there are any item using monsters that are permanently
+ // invisible, this might have to be restricted.
+ return (true);
default:
break;
- }
-
- return (true);
}
return (false);