From 90629939ac4ba4ba84acf7b768c8673d4188c108 Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 28 Apr 2007 13:49:28 +0000 Subject: Some code review and cleanup. extern char info[] is almost gone. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1387 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/food.cc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'crawl-ref/source/food.cc') diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 4f81eb3ee5..49513143f8 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -529,23 +529,27 @@ static bool food_change(bool suppress_message) static void describe_food_change(int food_increment) { int magnitude = (food_increment > 0)?food_increment:(-food_increment); + std::string msg; if (magnitude == 0) return; - strcpy(info, (magnitude <= 100) ? "You feel slightly " : - (magnitude <= 350) ? "You feel somewhat " : - (magnitude <= 800) ? "You feel a quite a bit " - : "You feel a lot "); + if ( magnitude <= 100 ) + msg = "You feel slightly "; + else if (magnitude <= 350) + msg = "You feel somewhat "; + else if (magnitude <= 800) + msg = "You feel a quite a bit "; + else + msg = "You feel a lot "; if ((you.hunger_state > HS_SATIATED) ^ (food_increment < 0)) - strcat(info, "more "); + msg += "more "; else - strcat(info, "less "); + msg += "less "; - strcat(info, (you.hunger_state > HS_SATIATED) ? "full." - : "hungry."); - mpr(info); + msg += ((you.hunger_state > HS_SATIATED) ? "full." : "hungry."); + mpr(msg.c_str()); } // end describe_food_change() void eat_from_inventory(int which_inventory_slot) @@ -976,16 +980,12 @@ static void eating(unsigned char item_class, int item_type) mpr("That snozzcumber tasted truly putrid!"); break; case FOOD_ORANGE: - strcpy(info, "That orange was delicious!"); - if (one_chance_in(8)) - strcat(info, " Even the peel tasted good!"); - mpr(info); + mprf("That orange was delicious!%s", + one_chance_in(8) ? " Even the peel tasted good!" : ""); break; case FOOD_BANANA: - strcpy(info, "That banana was delicious!"); - if (one_chance_in(8)) - strcat(info, " Even the peel tasted good!"); - mpr(info); + mprf("That banana was delicious!%s", + one_chance_in(8) ? " Even the peel tasted good!" : ""); break; case FOOD_STRAWBERRY: mpr("That strawberry was delicious!"); -- cgit v1.2.3-54-g00ecf