via  1b65636845c45b6149175d3b97b7397efe83ffd6 (commit)
       via  36cea3e42b02b5ce8615a714e2ef784c5adbae0c (commit)
      from  a9e6ede60504aea9a5c19bd27275ace937e744ef (commit)

-----------------------------------------------------------------------
commit 1b65636845c45b6149175d3b97b7397efe83ffd6
Author: Johanna Ploog <j-p-...@users.sourceforge.net>
Date:   Thu Feb 17 20:28:22 2011 +0100

    Fix misinformation when clicking on rotten chunks as a non-saprovore.
    
    The returned message was "You're not hungry enough" which is completely
    misleading. Fixed by adding a can_ingest variant that gets the item
    itself rather than base and subtype, so we can check for rottenness.

commit 36cea3e42b02b5ce8615a714e2ef784c5adbae0c
Author: Johanna Ploog <j-p-...@users.sourceforge.net>
Date:   Thu Feb 17 19:47:25 2011 +0100

    Add a tutorial message when chunks in your inventory become rotten.
    
    I would have prefered giving a message when you try to eat them, but
    the eating code is stretched enough that I gave up trying the right
    hook. A tiles-only trigger would be easy, but I want it to work for
    console, too.

-----------------------------------------------------------------------

Summary of changes:
 .../source/dat/des/tutorial/tutorial_lesson2.des   |    2 +
 crawl-ref/source/describe.cc                       |    2 +-
 crawl-ref/source/food.cc                           |   95 ++++++++++----------
 crawl-ref/source/food.h                            |    5 +-
 crawl-ref/source/hints.cc                          |   19 +++--
 crawl-ref/source/item_use.cc                       |    2 +-
 crawl-ref/source/itemname.cc                       |    3 +-
 crawl-ref/source/l_food.cc                         |   12 +--
 crawl-ref/source/tutorial.cc                       |    3 +
 9 files changed, 76 insertions(+), 67 deletions(-)

diff --git a/crawl-ref/source/dat/des/tutorial/tutorial_lesson2.des 
b/crawl-ref/source/dat/des/tutorial/tutorial_lesson2.des
index c4290f5..c2561c7 100644
--- a/crawl-ref/source/dat/des/tutorial/tutorial_lesson2.des
+++ b/crawl-ref/source/dat/des/tutorial/tutorial_lesson2.des
@@ -11,6 +11,8 @@ function tutorial_msg2.start ()
     -- Make him hungry for the butchering tutorial.
     crawl.tutorial_hunger(2700)
     crawl.tutorial_hint("HINT_NEW_LEVEL")
+    -- TODO: Replace this with a hint on trying to _eat_ rotten food.
+    crawl.tutorial_hint("HINT_ROTTEN_FOOD")
 
     tutorial_intro("This lesson will teach you about monsters and how to kill 
them in melee and ranged combat.")
     crawl.mpr("First, you need a weapon! Go and grab the one lying in front of 
the door!", "tutorial")
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index d9ca21a..ea4f259 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -2563,7 +2563,7 @@ static bool _actions_prompt(item_def &item, bool 
allow_inscribe)
             actions.push_back(CMD_WEAR_ARMOUR);
         break;
     case OBJ_FOOD:
-        if (can_ingest(item.base_type, item.sub_type, true, true, false))
+        if (can_ingest(item, true, true, false))
             actions.push_back(CMD_EAT);
         break;
     case OBJ_SCROLLS:
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 8547a09..dfea264 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -717,29 +717,22 @@ bool prompt_eat_inventory_item(int slot)
         return (false);
     }
 
-    int which_inventory_slot;
+    int which_inventory_slot = slot;
 
-    if (you.species != SP_VAMPIRE)
-    {
-        which_inventory_slot = (slot != -1) ? slot :
-                prompt_invent_item("Eat which item?",
-                                   MT_INVLIST,
-                                   OBJ_FOOD,
-                                   true, true, true, 0, -1, NULL,
-                                   OPER_EAT);
-    }
-    else
+    if (slot == -1)
     {
-        which_inventory_slot = (slot != -1) ? slot :
-                prompt_invent_item("Drain what?",
+        which_inventory_slot =
+                prompt_invent_item(you.species == SP_VAMPIRE ? "Drain what?"
+                                                             : "Eat which 
item?",
                                    MT_INVLIST,
-                                   OSEL_VAMP_EAT,
+                                   you.species == SP_VAMPIRE ? OSEL_VAMP_EAT
+                                                             : OBJ_FOOD,
                                    true, true, true, 0, -1, NULL,
                                    OPER_EAT);
-    }
 
-    if (prompt_failed(which_inventory_slot))
-        return (false);
+        if (prompt_failed(which_inventory_slot))
+            return (false);
+    }
 
     // This conditional can later be merged into food::can_ingest() when
     // expanded to handle more than just OBJ_FOOD 16mar200 {dlb}
@@ -761,11 +754,8 @@ bool prompt_eat_inventory_item(int slot)
         }
     }
 
-    if (!can_ingest(you.inv[which_inventory_slot].base_type,
-                     you.inv[which_inventory_slot].sub_type, false))
-    {
+    if (!can_ingest(you.inv[which_inventory_slot], false))
         return (false);
-    }
 
     eat_inventory_item(which_inventory_slot);
 
@@ -775,8 +765,7 @@ bool prompt_eat_inventory_item(int slot)
     return (true);
 }
 
-// [ds] Returns true if something was eaten.
-bool eat_food(int slot)
+static bool _eat_check(bool check_hunger = true)
 {
     if (you.is_undead == US_UNDEAD)
     {
@@ -785,13 +774,21 @@ bool eat_food(int slot)
         return (false);
     }
 
-    if (you.hunger >= 11000)
+    if (check_hunger && you.hunger >= 11000)
     {
         mprf("You're too full to %s anything.",
              you.species == SP_VAMPIRE ? "drain" : "eat");
         crawl_state.zero_turns_taken();
         return (false);
     }
+    return (true);
+}
+
+// [ds] Returns true if something was eaten.
+bool eat_food(int slot)
+{
+    if (!_eat_check())
+        return (false);
 
     int result;
     // Skip the prompts if we already know what we're eating.
@@ -829,7 +826,7 @@ static bool _player_has_enough_food()
         if (!item.defined())
             continue;
 
-        if (!can_ingest(item.base_type, item.sub_type, true, true, false))
+        if (!can_ingest(item, true, true, false))
             continue;
 
         if (food_is_rotten(item) && !player_mutation_level(MUT_SAPROVOROUS))
@@ -1173,6 +1170,9 @@ public:
 // Returns -1 for cancel, 1 for eaten, 0 for not eaten.
 int eat_from_floor(bool skip_chunks)
 {
+    if (!_eat_check())
+        return (false);
+
     if (you.flight_mode() == FL_LEVITATE)
         return (0);
 
@@ -1219,7 +1219,7 @@ int eat_from_floor(bool skip_chunks)
             unusable_corpse++;
             continue;
         }
-        else if (!can_ingest(si->base_type, si->sub_type, true))
+        else if (!can_ingest(*si, true))
         {
             if (!inedible_food)
             {
@@ -1269,7 +1269,7 @@ int eat_from_floor(bool skip_chunks)
                 if (!check_warning_inscriptions(*item, OPER_EAT))
                     break;
 
-                if (can_ingest(item->base_type, item->sub_type, false))
+                if (can_ingest(*item, false))
                 {
                     int ilink = item_on_floor(*item, you.pos());
 
@@ -1313,7 +1313,7 @@ int eat_from_floor(bool skip_chunks)
             {
                 ASSERT(wonteat.defined());
                 // Use the normal cannot ingest message.
-                if (can_ingest(wonteat.base_type, wonteat.sub_type, false))
+                if (can_ingest(wonteat, false))
                 {
                     mprf(MSGCH_DIAGNOSTICS, "Error: Can eat %s after all?",
                          wonteat.name(DESC_PLAIN).c_str());
@@ -1333,6 +1333,9 @@ int eat_from_floor(bool skip_chunks)
 
 bool eat_from_inventory()
 {
+    if (!_eat_check())
+        return (false);
+
     // Corpses should have been handled before.
     if (you.species == SP_VAMPIRE)
         return 0;
@@ -1375,7 +1378,7 @@ bool eat_from_inventory()
             unusable_corpse++;
             continue;
         }
-        else if (!can_ingest(item->base_type, item->sub_type, true))
+        else if (!can_ingest(*item, true))
         {
             if (!inedible_food)
             {
@@ -1421,7 +1424,7 @@ bool eat_from_inventory()
                 return (false);
             case 'e':
             case 'y':
-                if (can_ingest(item->base_type, item->sub_type, false))
+                if (can_ingest(*item, false))
                 {
                     eat_inventory_item(item->link);
                     return (true);
@@ -1453,7 +1456,7 @@ bool eat_from_inventory()
             {
                 ASSERT(wonteat->defined());
                 // Use the normal cannot ingest message.
-                if (can_ingest(wonteat->base_type, wonteat->sub_type, false))
+                if (can_ingest(*wonteat, false))
                 {
                     mprf(MSGCH_DIAGNOSTICS, "Error: Can eat %s after all?",
                          wonteat->name(DESC_PLAIN).c_str());
@@ -1595,7 +1598,7 @@ int prompt_eat_chunks()
                 return (-2);
             case 'e':
             case 'y':
-                if (can_ingest(item->base_type, item->sub_type, false))
+                if (can_ingest(*item, false))
                 {
                     if (autoeat)
                     {
@@ -2439,7 +2442,7 @@ bool is_inedible(const item_def &item)
     }
 
     if (item.base_type == OBJ_FOOD
-        && !can_ingest(item.base_type, item.sub_type, true, true, false))
+        && !can_ingest(item, true, true, false))
     {
         return (true);
     }
@@ -2545,25 +2548,21 @@ bool check_amu_the_gourmand(bool reqid)
     return (false);
 }
 
+bool can_ingest(const item_def &food, bool suppress_msg, bool reqid,
+                bool check_hunger)
+{
+    return can_ingest(food.base_type, food.sub_type, suppress_msg, reqid,
+                      check_hunger, food_is_rotten(food));
+}
+
 bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
-                bool reqid, bool check_hunger)
+                bool reqid, bool check_hunger, bool rotten)
 {
     bool survey_says = false;
 
     // [ds] These redundant checks are now necessary - Lua might be calling us.
-    if (you.is_undead == US_UNDEAD)
-    {
-        if (!suppress_msg)
-            mpr("You can't eat.");
+    if (!_eat_check(check_hunger))
         return (false);
-    }
-
-    if (check_hunger && you.hunger >= 11000)
-    {
-        if (!suppress_msg)
-            mpr("You're too full to eat anything.");
-        return (false);
-    }
 
     if (you.species == SP_VAMPIRE)
     {
@@ -2625,6 +2624,9 @@ bool can_ingest(int what_isit, int kindof_thing, bool 
suppress_msg,
             }
             else if (kindof_thing == FOOD_CHUNK)
             {
+                if (rotten && !_player_can_eat_rotten_meat(true))
+                    return (false);
+
                 if (ur_chunkslover)
                     return (true);
 
@@ -2633,6 +2635,7 @@ bool can_ingest(int what_isit, int kindof_thing, bool 
suppress_msg,
 
                 if (!suppress_msg)
                     mpr("You aren't quite hungry enough to eat that!");
+
                 return (false);
             }
         }
diff --git a/crawl-ref/source/food.h b/crawl-ref/source/food.h
index 8cdef5e..d101f45 100644
--- a/crawl-ref/source/food.h
+++ b/crawl-ref/source/food.h
@@ -60,8 +60,11 @@ bool is_preferred_food(const item_def &food);
 bool is_forbidden_food(const item_def &food);
 bool check_amu_the_gourmand(bool reqid);
 
-bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
+bool can_ingest(const item_def &food, bool suppress_msg, 
                 bool reqid = false, bool check_hunger = true);
+bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
+                bool reqid = false, bool check_hunger = true, 
+                bool rotten = false);
 
 bool chunk_is_poisonous(int chunktype);
 void eat_floor_item(int item_link);
diff --git a/crawl-ref/source/hints.cc b/crawl-ref/source/hints.cc
index 6738b88..eccf7f6 100644
--- a/crawl-ref/source/hints.cc
+++ b/crawl-ref/source/hints.cc
@@ -1383,7 +1383,6 @@ static bool _tutorial_interesting(hints_event_type event)
     case HINT_HEALING_POTIONS:
     case HINT_GAINED_SPELLCASTING:
     case HINT_FUMBLING_SHALLOW_WATER:
-    case HINT_EATING_ROTTEN_FOOD:
     case HINT_SPELL_MISCAST:
     case HINT_CLOUD_WARNING:
         return (true);
@@ -2431,12 +2430,20 @@ void learned_something_new(hints_event_type seen_what, 
coord_def gc)
         break;
 
     case HINT_ROTTEN_FOOD:
+        if (!crawl_state.game_is_hints())
+        {
+            text << "One or more of the chunks or corpses you carry has "
+                    "started to rot. While some species can eat rotten "
+                    "meat, you can't.";
+            break;
+        }
         text << "One or more of the chunks or corpses you carry has started "
-                "to rot. Few species can digest these safely, so you might "
-                "just as well <w>%</w>rop them now. When selecting items from "
-                "a menu, there's a shortcut (<w>&</w>) to select all corpses, "
-                "skeletons, and rotten chunks in your inventory at once.";
-         cmd.push_back(CMD_DROP);
+                "to rot. Few species can digest these, so you might just as "
+                "well <w>%</w>rop them now."
+                "When selecting items from a menu, there's a shortcut "
+                "(<w>&</w>) to select all items in your inventory at once "
+                "that are useless to you.";
+        cmd.push_back(CMD_DROP);
         break;
 
     case HINT_MAKE_CHUNKS:
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index cd6c48d..95ddef0 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -5272,7 +5272,7 @@ void tile_item_eat_floor(int idx)
         || mitm[idx].base_type == OBJ_FOOD
             && you.is_undead != US_UNDEAD && you.species != SP_VAMPIRE)
     {
-        if (can_ingest(mitm[idx].base_type, mitm[idx].sub_type, false)
+        if (can_ingest(mitm[idx], false)
             && _prompt_eat_bad_food(mitm[idx]))
         {
             eat_floor_item(idx);
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 1b1a53e..5b77f9e 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -2957,8 +2957,7 @@ bool is_useless_item(const item_def &item, bool temp)
         case POT_WATER:
         case POT_BLOOD:
         case POT_BLOOD_COAGULATED:
-            return (!can_ingest(item.base_type, item.sub_type, true, true,
-                                                               false));
+            return (!can_ingest(item, true, true, false));
         case POT_POISON:
         case POT_STRONG_POISON:
             // If you're poison resistant, poison is only useless.
diff --git a/crawl-ref/source/l_food.cc b/crawl-ref/source/l_food.cc
index 8707eb5..089390b 100644
--- a/crawl-ref/source/l_food.cc
+++ b/crawl-ref/source/l_food.cc
@@ -70,11 +70,7 @@ static int food_can_eat(lua_State *ls)
     if (lua_isboolean(ls, 2))
         hungercheck = lua_toboolean(ls, 2);
 
-    bool edible = item && can_ingest(item->base_type,
-                                     item->sub_type,
-                                     true,
-                                     true,
-                                     hungercheck);
+    bool edible = item && can_ingest(*item, true, true, hungercheck);
     lua_pushboolean(ls, edible);
     return (1);
 }
@@ -108,11 +104,7 @@ static int food_eat(lua_State *ls)
     {
         // When we get down to eating, we don't care if the eating is courtesy
         // an un-ided amulet of the gourmand.
-        bool edible = item && can_ingest(item->base_type,
-                                         item->sub_type,
-                                         false,
-                                         false);
-        if (edible)
+        if (item && can_ingest(*item, false, false))
             eaten = eat_item(*item);
     }
     lua_pushboolean(ls, eaten);
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index ed894c0..a8972d0 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -78,6 +78,9 @@ void tutorial_init_hint(const char* hintstr)
         hint = HINT_REMOVED_CURSE;
     else if (strcmp(hintstr, "HINT_MULTI_PICKUP") == 0)
         hint = HINT_MULTI_PICKUP;
+    else if (strcmp(hintstr, "HINT_ROTTEN_FOOD") == 0)
+        hint = HINT_ROTTEN_FOOD;
+
 
     if (hint != HINT_EVENTS_NUM)
         Hints.hints_events[hint] = true;


-- 
Dungeon Crawl Stone Soup

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Crawl-ref-discuss mailing list
Crawl-ref-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crawl-ref-discuss

Reply via email to