diff options
author | Adam Borowski <kilobyte@angband.pl> | 2009-12-17 12:48:02 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2009-12-17 12:48:02 +0100 |
commit | 1ab177757bec9eb28482785f75fd8a4fb8a1313c (patch) | |
tree | 4b1c8babcca442dc8b91a624b842bc5f30013747 /crawl-ref/source/items.cc | |
parent | c266f14414471d5252130c70bafa0c60f85a265c (diff) | |
download | crawl-ref-1ab177757bec9eb28482785f75fd8a4fb8a1313c.tar.gz crawl-ref-1ab177757bec9eb28482785f75fd8a4fb8a1313c.zip |
Replace static snprintf() with make_sprintf() where the result is immediately cast
to std::string.
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index a167165398..a3418761d4 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2010,7 +2010,6 @@ bool drop_item( int item_dropped, int quant_drop, bool try_offer ) static std::string _drop_menu_invstatus(const Menu *menu) { - char buf[100]; const int cap = carrying_capacity(BS_UNENCUMBERED); std::string s_newweight; @@ -2024,15 +2023,13 @@ static std::string _drop_menu_invstatus(const Menu *menu) newweight -= item_mass(*item) * se[i]->selected_qty; } - snprintf(buf, sizeof buf, ">%.0f", newweight * BURDEN_TO_AUM); - s_newweight = buf; + s_newweight = make_stringf(">%.0f", newweight * BURDEN_TO_AUM); } - snprintf(buf, sizeof buf, "(Inv: %.0f%s/%.0f aum)", + return (make_stringf("(Inv: %.0f%s/%.0f aum)", you.burden * BURDEN_TO_AUM, s_newweight.c_str(), - cap * BURDEN_TO_AUM); - return (buf); + cap * BURDEN_TO_AUM)); } static std::string _drop_menu_title(const Menu *menu, const std::string &oldt) @@ -2081,7 +2078,6 @@ mon_inv_type get_mon_equip_slot(const monsters* mon, const item_def &item) static std::string _drop_selitem_text( const std::vector<MenuEntry*> *s ) { - char buf[130]; bool extraturns = false; if (s->empty()) @@ -2098,11 +2094,10 @@ static std::string _drop_selitem_text( const std::vector<MenuEntry*> *s ) } } - snprintf( buf, sizeof buf, " (%lu%s turn%s)", + return (make_stringf( " (%lu%s turn%s)", (unsigned long) (s->size()), extraturns? "+" : "", - s->size() > 1? "s" : "" ); - return buf; + s->size() > 1? "s" : "" )); } std::vector<SelItem> items_for_multidrop; |