Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove excessive usage of string_format #33430

Merged
merged 8 commits into from
Aug 22, 2019
11 changes: 5 additions & 6 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3248,12 +3248,11 @@ void activity_handlers::craft_do_turn( player_activity *act, player *p )
// item_location::get_item() will return nullptr if the item is lost
if( !craft ) {
p->add_msg_player_or_npc(
string_format( _( "You no longer have the in progress craft in your possession. "
"You stop crafting. "
"Reactivate the in progress craft to continue crafting." ) ),
string_format( _( "<npcname> no longer has the in progress craft in their possession. "
"<npcname> stops crafting." ) )
);
_( "You no longer have the in progress craft in your possession. "
"You stop crafting. "
"Reactivate the in progress craft to continue crafting." ),
_( "<npcname> no longer has the in progress craft in their possession. "
"<npcname> stops crafting." ) );
p->cancel_activity();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ void activity_on_turn_move_loot( player_activity &, player &p )
}

// If we got here without restarting the activity, it means we're done
add_msg( m_info, string_format( _( "%s sorted out every item possible." ), p.disp_name() ) );
add_msg( m_info, _( "%s sorted out every item possible." ), p.disp_name() );
if( p.is_npc() ) {
npc *guy = dynamic_cast<npc *>( &p );
guy->current_activity_id = activity_id::NULL_ID();
Expand Down
2 changes: 1 addition & 1 deletion src/advanced_inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void advanced_inventory::print_items( advanced_inventory_pane &pane, bool active
if( it.has_owner() ) {
const faction *item_fac = it.get_owner();
if( item_fac != g->faction_manager_ptr->get( faction_id( "your_followers" ) ) ) {
stolen_string = string_format( "<color_light_red>!</color>" );
stolen_string = "<color_light_red>!</color>";
stolen = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/basecamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void basecamp::query_new_name()
{
std::string camp_name;
string_input_popup popup;
popup.title( string_format( _( "Name this camp" ) ) )
popup.title( _( "Name this camp" ) )
.width( 40 )
.text( "" )
.max_length( 25 )
Expand Down
3 changes: 1 addition & 2 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,7 @@ bool player::deactivate_bionic( int b, bool eff_only )
if( weapon.typeId() == bionics[ bio.id ].fake_item ) {
add_msg_if_player( _( "You withdraw your %s." ), weapon.tname() );
if( g->u.sees( pos() ) ) {
add_msg_if_npc( m_info, string_format( _( "%s withdraws %s %s." ), disp_name(), disp_name( true ),
weapon.tname() ) );
add_msg_if_npc( m_info, _( "<npcname> withdraws %s %s." ), disp_name( true ), weapon.tname() );
}
bio.ammo_loaded = weapon.ammo_data() != nullptr ? weapon.ammo_data()->get_id() : "null";
bio.ammo_count = static_cast<unsigned int>( weapon.ammo_remaining() );
Expand Down
8 changes: 3 additions & 5 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2738,8 +2738,7 @@ hp_part Character::body_window( const std::string &menu_header,
if( bitten ) {
desc << colorize( string_format( "%s: ", get_effect( effect_bite,
e.bp ).get_speed_name() ), c_red );
desc << colorize( string_format( _( "It has a deep bite wound that needs cleaning." ) ),
c_red ) << "\n";
desc << colorize( _( "It has a deep bite wound that needs cleaning." ), c_red ) << "\n";
if( bite > 0 ) {
desc << colorize( string_format( _( "Chance to clean and disinfect: %d %%" ),
static_cast<int>( bite * 100 ) ), c_light_green ) << "\n";
Expand All @@ -2751,8 +2750,7 @@ hp_part Character::body_window( const std::string &menu_header,
if( infected ) {
desc << colorize( string_format( "%s: ", get_effect( effect_infected,
e.bp ).get_speed_name() ), c_red );
desc << colorize( string_format(
_( "It has a deep wound that looks infected. Antibiotics might be required." ) ),
desc << colorize( _( "It has a deep wound that looks infected. Antibiotics might be required." ),
c_red ) << "\n";
if( infect > 0 ) {
desc << colorize( string_format( _( "Chance to heal infection: %d %%" ),
Expand Down Expand Up @@ -2781,7 +2779,7 @@ hp_part Character::body_window( const std::string &menu_header,

if( ( !e.allowed && !limb_is_broken ) || ( show_all && current_hp == maximal_hp &&
!limb_is_broken && !bitten && !infected && !bleeding ) ) {
desc << colorize( string_format( _( "Healthy." ) ), c_green ) << "\n";
desc << colorize( _( "Healthy." ), c_green ) << "\n";
}
if( !e.allowed ) {
desc << colorize( _( "You don't expect any effect from using this." ), c_yellow );
Expand Down
72 changes: 29 additions & 43 deletions src/crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,39 +698,33 @@ static item_location set_item_map_or_vehicle( const player &p, const tripoint &l
if( const cata::optional<vehicle_stack::iterator> it = vp->vehicle().add_item( vp->part_index(),
newit ) ) {
p.add_msg_player_or_npc(
string_format( pgettext( "item, furniture", "You put the %s on the %s." ),
( *it )->tname(), vp->part().name() ),
string_format( pgettext( "item, furniture", "<npcname> puts the %s on the %s." ),
( *it )->tname(), vp->part().name() ) );
pgettext( "item, furniture", "You put the %s on the %s." ),
pgettext( "item, furniture", "<npcname> puts the %s on the %s." ),
( *it )->tname(), vp->part().name() );

return item_location( vehicle_cursor( vp->vehicle(), vp->part_index() ), & **it );
}

// Couldn't add the in progress craft to the target part, so drop it to the map.
p.add_msg_player_or_npc(
string_format( pgettext( "furniture, item",
"Not enough space on the %s. You drop the %s on the ground." ),
vp->part().name(), newit.tname() ),
string_format( pgettext( "furniture, item",
"Not enough space on the %s. <npcname> drops the %s on the ground." ),
vp->part().name(), newit.tname() ) );
pgettext( "furniture, item", "Not enough space on the %s. You drop the %s on the ground." ),
pgettext( "furniture, item", "Not enough space on the %s. <npcname> drops the %s on the ground." ),
vp->part().name(), newit.tname() );

return set_item_map( loc, newit );

} else {
if( g->m.has_furn( loc ) ) {
const furn_t &workbench = g->m.furn( loc ).obj();
p.add_msg_player_or_npc(
string_format( pgettext( "item, furniture", "You put the %s on the %s." ),
newit.tname(), workbench.name() ),
string_format( pgettext( "item, furniture", "<npcname> puts the %s on the %s." ),
newit.tname(), workbench.name() ) );
pgettext( "item, furniture", "You put the %s on the %s." ),
pgettext( "item, furniture", "<npcname> puts the %s on the %s." ),
newit.tname(), workbench.name() );
} else {
p.add_msg_player_or_npc(
string_format( pgettext( "item", "You put the %s on the ground." ),
newit.tname() ),
string_format( pgettext( "item", "<npcname> puts the %s on the ground." ),
newit.tname() ) );
pgettext( "item", "You put the %s on the ground." ),
pgettext( "item", "<npcname> puts the %s on the ground." ),
newit.tname() );
}
return set_item_map( loc, newit );
}
Expand Down Expand Up @@ -795,7 +789,7 @@ void player::start_craft( craft_command &command, const tripoint &loc )
amenu.text = string_format( pgettext( "in progress craft", "What to do with the %s?" ),
craft.display_name() );
amenu.addentry( WIELD_CRAFT, !weapon.has_flag( "NO_UNWIELD" ), '1',
string_format( _( "Dispose of your wielded %s and start working." ), weapon.tname() ) );
_( "Dispose of your wielded %s and start working." ), weapon.tname() );
amenu.addentry( DROP_CRAFT, true, '2', _( "Put it down and start working." ) );
const bool can_stash = can_pickVolume( craft ) &&
can_pickWeight( craft, !get_option<bool>( "DANGEROUS_PICKUPS" ) );
Expand Down Expand Up @@ -843,10 +837,9 @@ void player::start_craft( craft_command &command, const tripoint &loc )
activity.values.push_back( command.is_long() );

add_msg_player_or_npc(
string_format( pgettext( "in progress craft", "You start working on the %s." ),
craft.tname() ),
string_format( pgettext( "in progress craft", "<npcname> starts working on the %s." ),
craft.tname() ) );
pgettext( "in progress craft", "You start working on the %s." ),
pgettext( "in progress craft", "<npcname> starts working on the %s." ),
craft.tname() );
}

void player::craft_skill_gain( const item &craft, const int &multiplier )
Expand Down Expand Up @@ -1000,10 +993,8 @@ static void destroy_random_component( item &craft, const player &crafter )

item destroyed = random_entry_removed( craft.components );

crafter.add_msg_player_or_npc(
string_format( _( "You mess up and destroy the %s." ), destroyed.tname() ),
string_format( _( "<npcname> messes up and destroys the %s" ), destroyed.tname() )
);
crafter.add_msg_player_or_npc( _( "You mess up and destroy the %s." ),
_( "<npcname> messes up and destroys the %s" ), destroyed.tname() );
}

void item::handle_craft_failure( player &crafter )
Expand Down Expand Up @@ -1034,10 +1025,8 @@ void item::handle_craft_failure( player &crafter )
const double percent_progress_loss = rng_exponential( 0.25, 0.35 ) *
( 1.0 - std::min( success_roll, 1.0 ) );
const int progess_loss = item_counter * percent_progress_loss;
crafter.add_msg_player_or_npc(
string_format( _( "You mess up and lose %d%% progress." ), progess_loss / 100000 ),
string_format( _( "<npcname> messes up and loses %d%% progress." ), progess_loss / 100000 )
);
crafter.add_msg_player_or_npc( _( "You mess up and lose %d%% progress." ),
_( "<npcname> messes up and loses %d%% progress." ), progess_loss / 100000 );
item_counter = clamp( item_counter - progess_loss, 0, 10000000 );

set_next_failure_point( crafter );
Expand Down Expand Up @@ -1712,21 +1701,19 @@ bool player::craft_consume_tools( item &craft, int mulitplier, bool start_craft
case use_from_player:
if( !has_charges( type, count ) ) {
add_msg_player_or_npc(
string_format( _( "You have insufficient %s charges and can't continue crafting" ),
item::nname( type ) ),
string_format( _( "<npcname> has insufficient %s charges and can't continue crafting" ),
item::nname( type ) ) );
_( "You have insufficient %s charges and can't continue crafting" ),
_( "<npcname> has insufficient %s charges and can't continue crafting" ),
item::nname( type ) );
craft.set_tools_to_continue( false );
return false;
}
break;
case use_from_map:
if( !map_inv.has_charges( type, count ) ) {
add_msg_player_or_npc(
string_format( _( "You have insufficient %s charges and can't continue crafting" ),
item::nname( type ) ),
string_format( _( "<npcname> has insufficient %s charges and can't continue crafting" ),
item::nname( type ) ) );
_( "You have insufficient %s charges and can't continue crafting" ),
_( "<npcname> has insufficient %s charges and can't continue crafting" ),
item::nname( type ) );
craft.set_tools_to_continue( false );
return false;
}
Expand All @@ -1738,10 +1725,9 @@ bool player::craft_consume_tools( item &craft, int mulitplier, bool start_craft
}
} else if( !has_amount( type, 1 ) && !map_inv.has_tools( type, 1 ) ) {
add_msg_player_or_npc(
string_format( _( "You no longer have a %s and can't continue crafting" ),
item::nname( type ) ),
string_format( _( "<npcname> no longer has a %s and can't continue crafting" ),
item::nname( type ) ) );
_( "You no longer have a %s and can't continue crafting" ),
_( "<npcname> no longer has a %s and can't continue crafting" ),
item::nname( type ) );
craft.set_tools_to_continue( false );
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ void debug()

// Take a screenshot of the viewport.
if ( g->take_screenshot( current_file_path ) ) {
popup( string_format( _( "Successfully saved your screenshot to: %s" ), map_directory.str() ) );
popup( _( "Successfully saved your screenshot to: %s" ), map_directory.str() );
}
else {
popup( _( "An error occurred while trying to save the screenshot." ) );
Expand Down
4 changes: 2 additions & 2 deletions src/descriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ c to describe creatures, f to describe furniture, t to describe terrain, Esc/Ent

std::string signage = m.get_signage( p );
if( !signage.empty() ) {
desc += u.has_trait( trait_ILLITERATE ) ? string_format( _( "\nSign: ???" ) ) : string_format(
_( "\nSign: %s" ), signage );
desc += u.has_trait( trait_ILLITERATE ) ? _( "\nSign: ???" ) : string_format( _( "\nSign: %s" ),
signage );
}

werase( w_main );
Expand Down
6 changes: 3 additions & 3 deletions src/faction_camp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2344,13 +2344,13 @@ void basecamp::recruit_return( const std::string &task, int score )
int appeal = rng( -5, 3 ) + std::min( skill / 3, 3 );
int food_desire = rng( 0, 5 );
while( rec_m >= 0 ) {
std::string description = string_format( _( "NPC Overview:\n \n" ) );
std::string description = _( "NPC Overview:\n \n" );
description += string_format( _( "Name: %20s\n \n" ), recruit->name );
description += string_format( _( "Strength: %10d\n" ), recruit->str_max );
description += string_format( _( "Dexterity: %10d\n" ), recruit->dex_max );
description += string_format( _( "Intelligence: %10d\n" ), recruit->int_max );
description += string_format( _( "Perception: %10d\n \n" ), recruit->per_max );
description += string_format( _( "Top 3 Skills:\n" ) );
description += _( "Top 3 Skills:\n" );

const auto skillslist = Skill::get_skills_sorted_by( [&]( const Skill & a,
const Skill & b ) {
Expand All @@ -2366,7 +2366,7 @@ void basecamp::recruit_return( const std::string &task, int score )
description += string_format( "%12s: %4d\n \n", skillslist[2]->name(),
recruit->get_skill_level( skillslist[2]->ident() ) );

description += string_format( _( "Asking for:\n" ) );
description += _( "Asking for:\n" );
description += string_format( _( "> Food: %10d days\n \n" ), food_desire );
description += string_format( _( "Faction Food:%9d days\n \n" ),
camp_food_supply( 0, true ) );
Expand Down
20 changes: 9 additions & 11 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5451,9 +5451,9 @@ static std::string get_fire_fuel_string( const tripoint &examp )
field_entry *fire = g->m.get_field( examp, fd_fire );
if( fire ) {
std::stringstream ss;
ss << string_format( _( "There is a fire here." ) ) << " ";
ss << _( "There is a fire here." ) << " ";
if( fire->get_field_intensity() > 1 ) {
ss << string_format( _( "It's too big and unpredictable to evaluate how long it will last." ) );
ss << _( "It's too big and unpredictable to evaluate how long it will last." );
return ss.str();
}
time_duration fire_age = fire->get_field_age();
Expand All @@ -5462,7 +5462,7 @@ static std::string get_fire_fuel_string( const tripoint &examp )
mod = std::max( mod, 0 );
if( fire_age >= 0_turns ) {
if( mod >= 4 ) { // = survival level 0-1
ss << string_format( _( "It's going to go out soon without extra fuel." ) );
ss << _( "It's going to go out soon without extra fuel." );
return ss.str();
} else {
fire_age = 30_minutes - fire_age;
Expand All @@ -5483,15 +5483,13 @@ static std::string get_fire_fuel_string( const tripoint &examp )
fire_age = fire_age * -1 + 30_minutes;
if( mod >= 4 ) { // = survival level 0-1
if( fire_age <= 1_hours ) {
ss << string_format(
_( "It's quite decent and looks like it'll burn for a bit without extra fuel." ) );
ss << _( "It's quite decent and looks like it'll burn for a bit without extra fuel." );
return ss.str();
} else if( fire_age <= 3_hours ) {
ss << string_format( _( "It looks solid, and will burn for a few hours without extra fuel." ) );
ss << _( "It looks solid, and will burn for a few hours without extra fuel." );
return ss.str();
} else {
ss << string_format(
_( "It's very well supplied and even without extra fuel might burn for at least a part of a day." ) );
ss << _( "It's very well supplied and even without extra fuel might burn for at least a part of a day." );
return ss.str();
}
} else {
Expand Down Expand Up @@ -6699,10 +6697,10 @@ look_around_result game::look_around( catacurses::window w_info, tripoint &cente
werase( w_info );
draw_border( w_info );

static const char *title_prefix = "< ";
static const std::string title_prefix = "< ";
static const char *title = _( "Look Around" );
static const char *title_suffix = " >";
static const std::string full_title = string_format( "%s%s%s", title_prefix, title, title_suffix );
static const std::string title_suffix = " >";
static const std::string full_title = title_prefix + title + title_suffix;
const int start_pos = center_text_pos( full_title, 0, getmaxx( w_info ) - 1 );
mvwprintz( w_info, point( start_pos, 0 ), c_white, title_prefix );
wprintz( w_info, c_green, title );
Expand Down
Loading