summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/food.cc32
1 files changed, 16 insertions, 16 deletions
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index a306a6ce41..4437026b37 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -613,6 +613,20 @@ static void describe_food_change(int food_increment)
mpr(msg.c_str());
} // end describe_food_change()
+static bool prompt_eat_chunk(const item_def &item, bool rotten)
+{
+ if (rotten && you.species != SP_GHOUL && you.species != SP_KOBOLD
+ && you.species != SP_TROLL && you.species != SP_OGRE
+ && you.species != SP_HILL_ORC
+ && !yesno("Are you sure you want to eat this rotten meat?",
+ false, 'n'))
+ {
+ canned_msg(MSG_OK);
+ return (false);
+ }
+ return (true);
+}
+
void eat_from_inventory(int which_inventory_slot)
{
if (you.inv[which_inventory_slot].base_type == OBJ_CORPSES
@@ -647,14 +661,8 @@ void eat_from_inventory(int which_inventory_slot)
const int chunk_type = mons_corpse_effect( mons_type );
const bool rotten = (you.inv[which_inventory_slot].special < 100);
- if (rotten && you.species != SP_GHOUL && you.species != SP_KOBOLD
- && you.species != SP_TROLL && you.species != SP_OGRE
- && you.species != SP_HILL_ORC
- && !yesno("Are you sure you want to eat this rotten meat?", false, 'n'))
- {
- canned_msg(MSG_OK);
+ if (!prompt_eat_chunk(you.inv[which_inventory_slot], rotten))
return;
- }
eat_chunk( determine_chunk_effect( chunk_type, rotten ) );
}
@@ -699,16 +707,8 @@ void eat_floor_item(int item_link)
{
const int chunk_type = mons_corpse_effect( mitm[item_link].plus );
const bool rotten = (mitm[item_link].special < 100);
-
-
- if (rotten && you.species != SP_GHOUL && you.species != SP_KOBOLD
- && you.species != SP_TROLL && you.species != SP_OGRE
- && you.species != SP_HILL_ORC
- && !yesno("Are you sure you want to eat this rotten meat?", false, 'n'))
- {
- canned_msg(MSG_OK);
+ if (!prompt_eat_chunk(mitm[item_link], rotten))
return;
- }
eat_chunk( determine_chunk_effect( chunk_type, rotten ) );
}
else