summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/food.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-18 19:32:13 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-18 19:32:13 +0000
commitf7400641cfa6ec4d8bc2d9220a270b2b90c43bc8 (patch)
tree6bf13c3480414ce35562eac0f29195b732947ea2 /crawl-ref/source/food.cc
parente00fd0d4e369ae44a7a2fb7af3cf801674aa43af (diff)
downloadcrawl-ref-f7400641cfa6ec4d8bc2d9220a270b2b90c43bc8.tar.gz
crawl-ref-f7400641cfa6ec4d8bc2d9220a270b2b90c43bc8.zip
Moved rotten meat prompt into its own function.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2018 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/food.cc')
-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