From f7400641cfa6ec4d8bc2d9220a270b2b90c43bc8 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sat, 18 Aug 2007 19:32:13 +0000 Subject: 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 --- crawl-ref/source/food.cc | 32 ++++++++++++++++---------------- 1 file 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 -- cgit v1.2.3-54-g00ecf