From 2714d313e1d74605339b3a8b427fe6c563929c0b Mon Sep 17 00:00:00 2001 From: zelgadis Date: Wed, 3 Jun 2009 19:48:08 +0000 Subject: * Make messages about rotting corpses/skeletons in inventory more concise. * Use an alias to "you.inv[i]" instead of repeatedly using it directly. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9887 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/effects.cc | 106 ++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 49 deletions(-) (limited to 'crawl-ref/source/effects.cc') diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 670f4344eb..7fd6a699ba 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -2997,63 +2997,65 @@ static void _rot_inventory_food(long time_delta) for (int i = 0; i < ENDOFPACK; i++) { - if (you.inv[i].quantity < 1) + item_def &item(you.inv[i]); + + if (item.quantity < 1) continue; - if (!_food_item_needs_time_check(you.inv[i])) + if (!_food_item_needs_time_check(item)) continue; - if (you.inv[i].base_type == OBJ_POTIONS) + if (item.base_type == OBJ_POTIONS) { // Also handles messaging. - if (maybe_coagulate_blood_potions_inv(you.inv[i])) + if (maybe_coagulate_blood_potions_inv(item)) burden_changed_by_rot = true; continue; } - if (you.inv[i].base_type == OBJ_FOOD) + if (item.base_type == OBJ_FOOD) num_chunks++; - else if (you.inv[i].sub_type == CORPSE_SKELETON) + else if (item.sub_type == CORPSE_SKELETON) num_bones++; else num_corpses++; // Food item timed out -> make it disappear. - if ((time_delta / 20) >= you.inv[i].special) + if ((time_delta / 20) >= item.special) { - if (you.inv[i].base_type == OBJ_FOOD) + if (item.base_type == OBJ_FOOD) { if (you.equip[EQ_WEAPON] == i) unwield_item(); - // In case time_delta >= 210 - if (!you.inv[i].props.exists(ROTTING_WARNED_KEY)) + // In case time_delta >= 220 + if (!item.props.exists(ROTTING_WARNED_KEY)) num_chunks_gone++; - destroy_item(you.inv[i]); + destroy_item(item); burden_changed_by_rot = true; continue; } // The item is of type carrion. - if (you.inv[i].sub_type == CORPSE_SKELETON - || !mons_skeleton(you.inv[i].plus)) + if (item.sub_type == CORPSE_SKELETON + || !mons_skeleton(item.plus)) { if (you.equip[EQ_WEAPON] == i) unwield_item(); - if (you.inv[i].sub_type == CORPSE_SKELETON) + if (item.sub_type == CORPSE_SKELETON) num_bones_gone++; else num_corpses_gone++; - destroy_item(you.inv[i]); + destroy_item(item); burden_changed_by_rot = true; continue; } - turn_corpse_into_skeleton(you.inv[i]); + turn_corpse_into_skeleton(item); you.wield_change = true; burden_changed_by_rot = true; @@ -3062,19 +3064,19 @@ static void _rot_inventory_food(long time_delta) } // If it hasn't disappeared, reduce the rotting timer. - you.inv[i].special -= (time_delta / 20); + item.special -= (time_delta / 20); - if (food_is_rotten(you.inv[i]) - && (you.inv[i].special + (time_delta / 20) >= 100)) + if (food_is_rotten(item) + && (item.special + (time_delta / 20) >= 100)) { rotten_items.push_back(index_to_letter(i)); } - if (you.inv[i].base_type == OBJ_FOOD && you.inv[i].special <= 10 - && !you.inv[i].props.exists(ROTTING_WARNED_KEY)) + if (item.base_type == OBJ_FOOD && you.inv[i].special <= 10 + && !item.props.exists(ROTTING_WARNED_KEY)) { - // In case time_delta >= 210 - you.inv[i].props[ROTTING_WARNED_KEY] = true; + // In case time_delta >= 220 + item.props[ROTTING_WARNED_KEY] = true; num_chunks_rotting++; } @@ -3143,37 +3145,42 @@ static void _rot_inventory_food(long time_delta) if (burden_changed_by_rot) { - if ((num_chunks_gone + num_bones_gone + num_corpses_gone) > 0) + if ((num_chunks_gone + num_bones_gone + num_corpses_gone + + num_corpses_rotted) > 0) { + std::string msg; + if (num_chunks_gone == num_chunks + && num_bones_gone == num_bones + && (num_corpses_gone + num_corpses_rotted) == num_corpses) + { + msg = "All of the "; + } + else + msg = "Some of the "; + std::vector strs; if (num_chunks_gone > 0) - strs.push_back(make_stringf("%s of the chunks of flesh", - num_chunks_gone < num_chunks ? - "some" : "all")); + strs.push_back("chunks of flesh"); if (num_bones_gone > 0) - strs.push_back(make_stringf("%s of the skeletons", - num_bones_gone < num_bones ? - "some" : "all")); - - if (num_corpses_gone > 0) - strs.push_back(make_stringf("%s of the corpses", - num_corpses_gone < num_corpses ? - "some" : "all")); + strs.push_back("skeletons"); + if ((num_corpses_gone + num_corpses_rotted) > 0) + strs.push_back("corpses"); - strs[0] = upcase_first(strs[0]); + msg += comma_separated_line(strs.begin(), strs.end()); + msg += " in your inventory have "; - std::string line = comma_separated_line(strs.begin(), strs.end()); - line += " in your inventory have completely rotted away."; - mprf("%s", line.c_str()); - } - - num_corpses -= num_corpses_gone; - if (num_corpses_rotted > 0) - { - mprf("%s of the %scorpses in your invetory rotted away into " - "skeletons.", - num_corpses_rotted < num_corpses ? "Some" : "All", - num_corpses_gone > 0 ? "remaining " : ""); + if (num_corpses_rotted == 0) + msg += "completely "; + else if ((num_chunks_gone + num_bones_gone + + num_corpses_gone) == 0) + { + msg += "partially "; + } + else + msg += "completely or partially "; + + msg += "rotted away."; + mprf(MSGCH_ROTTEN_MEAT, "%s", msg.c_str()); } burden_change(); } @@ -3181,7 +3188,8 @@ static void _rot_inventory_food(long time_delta) num_chunks -= num_chunks_gone; if (num_chunks_rotting > 0) { - mprf("%s of the %schunks of flesh in your inventory are close to " + mprf(MSGCH_ROTTEN_MEAT, + "%s of the %schunks of flesh in your inventory are close to " "completely rotting away.", num_chunks_rotting < num_chunks ? "Some" : "All", num_chunks_gone > 0 ? "remaining " : ""); -- cgit v1.2.3-54-g00ecf