Skip to content

Commit

Permalink
Pull out more string consts into cata_string_consts.h (#37394)
Browse files Browse the repository at this point in the history
* Pull out string consts from tons of files

* Rollback large files

* Rollback

* Rollback

* Rollback

* FIx test/typo

* Astyle
  • Loading branch information
Ramza13 authored and ZhilkinSerg committed Jan 26, 2020
1 parent 95d54b2 commit 9e48800
Show file tree
Hide file tree
Showing 70 changed files with 1,420 additions and 1,330 deletions.
17 changes: 9 additions & 8 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ret_val.h"
#include "type_id.h"
#include "point.h"
#include "cata_string_consts.h"

class inventory;

Expand Down Expand Up @@ -577,8 +578,8 @@ int hotkey_for_action( action_id action, const bool restrict_to_printable )
bool can_butcher_at( const tripoint &p )
{
// TODO: unify this with game::butcher
const int factor = g->u.max_quality( quality_id( "BUTCHER" ) );
const int factorD = g->u.max_quality( quality_id( "CUT_FINE" ) );
const int factor = g->u.max_quality( qual_BUTCHER );
const int factorD = g->u.max_quality( qual_CUT_FINE );
auto items = g->m.i_at( p );
bool has_item = false;
bool has_corpse = false;
Expand All @@ -599,18 +600,18 @@ bool can_butcher_at( const tripoint &p )
bool can_move_vertical_at( const tripoint &p, int movez )
{
// TODO: unify this with game::move_vertical
if( g->m.has_flag( "SWIMMABLE", p ) && g->m.has_flag( TFLAG_DEEP_WATER, p ) ) {
if( g->m.has_flag( flag_SWIMMABLE, p ) && g->m.has_flag( TFLAG_DEEP_WATER, p ) ) {
if( movez == -1 ) {
return !g->u.is_underwater() && !g->u.worn_with_flag( "FLOTATION" );
return !g->u.is_underwater() && !g->u.worn_with_flag( flag_FLOTATION );
} else {
return g->u.swim_speed() < 500 || g->u.is_wearing( "swim_fins" );
}
}

if( movez == -1 ) {
return g->m.has_flag( "GOES_DOWN", p );
return g->m.has_flag( flag_GOES_DOWN, p );
} else {
return g->m.has_flag( "GOES_UP", p );
return g->m.has_flag( flag_GOES_UP, p );
}
}

Expand All @@ -619,7 +620,7 @@ bool can_examine_at( const tripoint &p )
if( g->m.veh_at( p ) ) {
return true;
}
if( g->m.has_flag( "CONSOLE", p ) ) {
if( g->m.has_flag( flag_CONSOLE, p ) ) {
return true;
}
if( g->m.has_items( p ) ) {
Expand Down Expand Up @@ -701,7 +702,7 @@ action_id handle_action_menu()
action_weightings[ACTION_CYCLE_MOVE] = 400;
}
// Only prioritize fire weapon options if we're wielding a ranged weapon.
if( g->u.weapon.is_gun() || g->u.weapon.has_flag( "REACH_ATTACK" ) ) {
if( g->u.weapon.is_gun() || g->u.weapon.has_flag( flag_REACH_ATTACK ) ) {
action_weightings[ACTION_FIRE] = 350;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ static void butchery_drops_harvest( item *corpse_item, const mtype &mt, player &
ruined_parts.set_mtype( &mt );
ruined_parts.set_item_temperature( 0.00001 * corpse_item->temperature );
ruined_parts.set_rot( corpse_item->get_rot() );
if( !p.backlog.empty() && p.backlog.front().id() == activity_id( "ACT_MULTIPLE_BUTCHER" ) ) {
if( !p.backlog.empty() && p.backlog.front().id() == ACT_MULTIPLE_BUTCHER ) {
ruined_parts.set_var( "activity_var", p.name );
}
g->m.add_item_or_charges( p.pos(), ruined_parts );
Expand Down Expand Up @@ -1846,7 +1846,7 @@ void activity_handlers::reload_finish( player_activity *act, player *p )
item &ammo = *act->targets[1];
const int qty = act->index;
const bool is_speedloader = ammo.has_flag( flag_SPEEDLOADER );
const bool is_bolt = ammo.ammo_type() == ammotype( "bolt" );
const bool is_bolt = ammo.ammo_type() == ammo_bolt;

if( !reloadable.reload( *p, std::move( act->targets[ 1 ] ), qty ) ) {
add_msg( m_info, _( "Can't reload the %s." ), reloadable.tname() );
Expand Down Expand Up @@ -2793,7 +2793,7 @@ void activity_handlers::travel_do_turn( player_activity *act, player *p )
const auto route_to = g->m.route( p->pos(), centre_sub, p->get_pathfinding_settings(),
p->get_path_avoid() );
if( !route_to.empty() ) {
const activity_id act_travel = activity_id( "ACT_TRAVELLING" );
const activity_id act_travel = ACT_TRAVELLING;
p->set_destination( route_to, player_activity( act_travel ) );
} else {
p->add_msg_if_player( _( "You cannot reach that destination" ) );
Expand Down Expand Up @@ -3008,7 +3008,7 @@ void activity_handlers::find_mount_do_turn( player_activity *act, player *p )
} else {
p->activity = player_activity();
mon->add_effect( effect_controlled, 40_turns );
p->set_destination( route, player_activity( activity_id( "ACT_FIND_MOUNT" ) ) );
p->set_destination( route, player_activity( ACT_FIND_MOUNT ) );
}
}
}
Expand Down Expand Up @@ -3129,7 +3129,7 @@ void activity_handlers::operation_do_turn( player_activity *act, player *p )
const bionic_id upbid( act->str_values[upgraded_cbm_id] );
const bool autodoc = act->str_values[is_autodoc] == "true";
const bool u_see = g->u.sees( p->pos() ) && ( !g->u.has_effect( effect_narcosis ) ||
g->u.has_bionic( bionic_id( "bio_painkiller" ) ) || g->u.has_trait( trait_id( "NOPAIN" ) ) );
g->u.has_bionic( bio_painkiller ) || g->u.has_trait( trait_NOPAIN ) );

const int difficulty = act->values.front();

Expand Down Expand Up @@ -3810,9 +3810,9 @@ void activity_handlers::dig_finish( player_activity *act, player *p )
if( grave ) {
if( one_in( 10 ) ) {
static const std::array<mtype_id, 5> monids = { {
mtype_id( "mon_zombie" ), mtype_id( "mon_zombie_fat" ),
mtype_id( "mon_zombie_rot" ), mtype_id( "mon_skeleton" ),
mtype_id( "mon_zombie_crawler" )
mon_zombie, mon_zombie_fat,
mon_zombie_rot, mon_skeleton,
mon_zombie_crawler
}
};

Expand Down Expand Up @@ -4236,7 +4236,7 @@ static hack_result hack_attempt( player &p )
}
const bool using_electrohack = p.has_charges( "electrohack", 25 ) &&
query_yn( _( "Use electrohack?" ) );
const bool using_fingerhack = !using_electrohack && p.has_bionic( bionic_id( "bio_fingerhack" ) ) &&
const bool using_fingerhack = !using_electrohack && p.has_bionic( bio_fingerhack ) &&
p.get_power_level() > 24_kJ && query_yn( _( "Use fingerhack?" ) );

if( !( using_electrohack || using_fingerhack ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/addiction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void addict_effect( Character &u, addiction &add )
}

case ADD_MUTAGEN:
if( u.has_trait( trait_id( "MUT_JUNKIE" ) ) ) {
if( u.has_trait( trait_MUT_JUNKIE ) ) {
if( one_in( 600 - 50 * in ) ) {
u.add_msg_if_player( m_warning, rng( 0,
6 ) < in ? _( "You so miss the exquisite rainbow of post-humanity." ) :
Expand Down
23 changes: 12 additions & 11 deletions src/advanced_inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "auto_pickup.h"
#include "avatar.h"
#include "cata_string_consts.h"
#include "cata_utility.h"
#include "catacharset.h"
#include "debug.h"
Expand Down Expand Up @@ -933,7 +934,7 @@ bool advanced_inventory::move_all_items( bool nested_call )
g->u.drop( dropped, g->u.pos() + darea.off );
} else {
if( dpane.get_area() == AIM_INVENTORY || dpane.get_area() == AIM_WORN ) {
g->u.assign_activity( activity_id( "ACT_PICKUP" ) );
g->u.assign_activity( ACT_PICKUP );
g->u.activity.coords.push_back( g->u.pos() );
} else {
// Vehicle and map destinations are handled the same.
Expand All @@ -943,7 +944,7 @@ bool advanced_inventory::move_all_items( bool nested_call )
return false;
}

g->u.assign_activity( activity_id( "ACT_MOVE_ITEMS" ) );
g->u.assign_activity( ACT_MOVE_ITEMS );
// store whether the destination is a vehicle
g->u.activity.values.push_back( dpane.in_vehicle() );
// Stash the destination
Expand Down Expand Up @@ -1244,7 +1245,7 @@ void advanced_inventory::display()
// make sure advanced inventory is reopened after activity completion.
do_return_entry();

g->u.assign_activity( activity_id( "ACT_WEAR" ) );
g->u.assign_activity( ACT_WEAR );

g->u.activity.targets.emplace_back( g->u, sitem->items.front() );
g->u.activity.values.push_back( amount_to_move );
Expand All @@ -1269,7 +1270,7 @@ void advanced_inventory::display()
} else {
// important if item is worn
if( g->u.can_unwield( g->u.i_at( idx ) ).success() ) {
g->u.assign_activity( activity_id( "ACT_DROP" ) );
g->u.assign_activity( ACT_DROP );
g->u.activity.placement = squares[destarea].off;

// incase there is vehicle cargo space at dest but the player wants to drop to ground
Expand All @@ -1290,13 +1291,13 @@ void advanced_inventory::display()
do_return_entry();

if( destarea == AIM_INVENTORY ) {
g->u.assign_activity( activity_id( "ACT_PICKUP" ) );
g->u.assign_activity( ACT_PICKUP );
g->u.activity.coords.push_back( g->u.pos() );
} else if( destarea == AIM_WORN ) {
g->u.assign_activity( activity_id( "ACT_WEAR" ) );
g->u.assign_activity( ACT_WEAR );
} else {
// Vehicle and map destinations are handled similarly.
g->u.assign_activity( activity_id( "ACT_MOVE_ITEMS" ) );
g->u.assign_activity( ACT_MOVE_ITEMS );
// store whether the destination is a vehicle
g->u.activity.values.push_back( to_vehicle );
// Stash the destination
Expand Down Expand Up @@ -1402,10 +1403,10 @@ void advanced_inventory::display()
// If examining the item did not create a new activity, we have to remove
// "return to AIM".
do_return_entry();
assert( g->u.has_activity( activity_id( "ACT_ADV_INVENTORY" ) ) );
assert( g->u.has_activity( ACT_ADV_INVENTORY ) );
ret = g->inventory_item_menu( loc, info_startx, info_width,
src == advanced_inventory::side::left ? game::LEFT_OF_INFO : game::RIGHT_OF_INFO );
if( !g->u.has_activity( activity_id( "ACT_ADV_INVENTORY" ) ) ) {
if( !g->u.has_activity( ACT_ADV_INVENTORY ) ) {
exit = true;
} else {
g->u.cancel_activity();
Expand Down Expand Up @@ -1682,7 +1683,7 @@ bool advanced_inventory::query_charges( aim_location destarea, const advanced_in
// Inventory has a weight capacity, map and vehicle don't have that
if( destarea == AIM_INVENTORY || destarea == AIM_WORN ) {
const units::mass unitweight = it.weight() / ( by_charges ? it.charges : 1 );
const units::mass max_weight = g->u.has_trait( trait_id( "DEBUG_STORAGE" ) ) ?
const units::mass max_weight = g->u.has_trait( trait_DEBUG_STORAGE ) ?
units::mass_max : g->u.weight_capacity() * 4 - g->u.weight_carried();
if( unitweight > 0_gram && unitweight * amount > max_weight ) {
const int weightmax = max_weight / unitweight;
Expand Down Expand Up @@ -1836,7 +1837,7 @@ void advanced_inventory::do_return_entry()
{
// only save pane settings
save_settings( true );
g->u.assign_activity( activity_id( "ACT_ADV_INVENTORY" ) );
g->u.assign_activity( ACT_ADV_INVENTORY );
g->u.activity.auto_resume = true;
uistate.adv_inv_exit_code = exit_re_entry;
}
Expand Down
4 changes: 3 additions & 1 deletion src/advanced_inv_pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include <iterator>
#include <utility>
#include <numeric>
#include "cata_string_consts.h"

#if defined(__ANDROID__)
# include <SDL_keyboard.h>
#endif
Expand All @@ -49,7 +51,7 @@ bool advanced_inventory_pane::is_filtered( const advanced_inv_listitem &it ) con

bool advanced_inventory_pane::is_filtered( const item &it ) const
{
if( it.has_flag( "HIDDEN_ITEM" ) ) {
if( it.has_flag( flag_HIDDEN_ITEM ) ) {
return true;
}
if( filter.empty() ) {
Expand Down
41 changes: 21 additions & 20 deletions src/armor_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "translations.h"
#include "debug.h"
#include "enums.h"
#include "cata_string_consts.h"

namespace
{
Expand Down Expand Up @@ -71,7 +72,7 @@ item_penalties get_item_penalties( std::list<item>::const_iterator worn_item_it,
}
const int num_items = std::count_if( c.worn.begin(), c.worn.end(),
[layer, bp]( const item & i ) {
return i.get_layer() == layer && i.covers( bp ) && !i.has_flag( "SEMITANGIBLE" );
return i.get_layer() == layer && i.covers( bp ) && !i.has_flag( flag_SEMITANGIBLE );
} );
if( num_items > 1 ) {
body_parts_with_stacking_penalty.push_back( bp );
Expand Down Expand Up @@ -247,17 +248,17 @@ std::string clothing_layer( const item &worn_item )
{
std::string layer;

if( worn_item.has_flag( "PERSONAL" ) ) {
if( worn_item.has_flag( flag_PERSONAL ) ) {
layer = _( "This is in your personal aura." );
} else if( worn_item.has_flag( "SKINTIGHT" ) ) {
} else if( worn_item.has_flag( flag_SKINTIGHT ) ) {
layer = _( "This is worn next to the skin." );
} else if( worn_item.has_flag( "WAIST" ) ) {
} else if( worn_item.has_flag( flag_WAIST ) ) {
layer = _( "This is worn on or around your waist." );
} else if( worn_item.has_flag( "OUTER" ) ) {
} else if( worn_item.has_flag( flag_OUTER ) ) {
layer = _( "This is worn over your other clothes." );
} else if( worn_item.has_flag( "BELTED" ) ) {
} else if( worn_item.has_flag( flag_BELTED ) ) {
layer = _( "This is strapped onto you." );
} else if( worn_item.has_flag( "AURA" ) ) {
} else if( worn_item.has_flag( flag_AURA ) ) {
layer = _( "This is an aura around you." );
}

Expand Down Expand Up @@ -308,40 +309,40 @@ std::vector<std::string> clothing_flags_description( const item &worn_item )
{
std::vector<std::string> description_stack;

if( worn_item.has_flag( "FIT" ) ) {
if( worn_item.has_flag( flag_FIT ) ) {
description_stack.push_back( _( "It fits you well." ) );
} else if( worn_item.has_flag( "VARSIZE" ) ) {
description_stack.push_back( _( "It could be refitted." ) );
}

if( worn_item.has_flag( "HOOD" ) ) {
if( worn_item.has_flag( flag_HOOD ) ) {
description_stack.push_back( _( "It has a hood." ) );
}
if( worn_item.has_flag( "POCKETS" ) ) {
if( worn_item.has_flag( flag_POCKETS ) ) {
description_stack.push_back( _( "It has pockets." ) );
}
if( worn_item.has_flag( "WATERPROOF" ) ) {
if( worn_item.has_flag( flag_WATERPROOF ) ) {
description_stack.push_back( _( "It is waterproof." ) );
}
if( worn_item.has_flag( "WATER_FRIENDLY" ) ) {
if( worn_item.has_flag( flag_WATER_FRIENDLY ) ) {
description_stack.push_back( _( "It is water friendly." ) );
}
if( worn_item.has_flag( "FANCY" ) ) {
if( worn_item.has_flag( flag_FANCY ) ) {
description_stack.push_back( _( "It looks fancy." ) );
}
if( worn_item.has_flag( "SUPER_FANCY" ) ) {
if( worn_item.has_flag( flag_SUPER_FANCY ) ) {
description_stack.push_back( _( "It looks really fancy." ) );
}
if( worn_item.has_flag( "FLOTATION" ) ) {
if( worn_item.has_flag( flag_FLOTATION ) ) {
description_stack.push_back( _( "You will not drown today." ) );
}
if( worn_item.has_flag( "OVERSIZE" ) ) {
if( worn_item.has_flag( flag_OVERSIZE ) ) {
description_stack.push_back( _( "It is very bulky." ) );
}
if( worn_item.has_flag( "SWIM_GOGGLES" ) ) {
if( worn_item.has_flag( flag_SWIM_GOGGLES ) ) {
description_stack.push_back( _( "It helps you to see clearly underwater." ) );
}
if( worn_item.has_flag( "SEMITANGIBLE" ) ) {
if( worn_item.has_flag( flag_SEMITANGIBLE ) ) {
description_stack.push_back( _( "It can occupy the same space as other things." ) );
}

Expand Down Expand Up @@ -491,7 +492,7 @@ void player::sort_armor()
ctxt.register_action( "HELP_KEYBINDINGS" );

auto do_return_entry = []() {
g->u.assign_activity( activity_id( "ACT_ARMOR_LAYERS" ), 0 );
g->u.assign_activity( ACT_ARMOR_LAYERS, 0 );
g->u.activity.auto_resume = true;
g->u.activity.moves_left = INT_MAX;
};
Expand Down Expand Up @@ -795,7 +796,7 @@ void player::sort_armor()
do_return_entry();
// remove the item, asking to drop it if necessary
takeoff( *tmp_worn[leftListIndex] );
if( !g->u.has_activity( activity_id( "ACT_ARMOR_LAYERS" ) ) ) {
if( !g->u.has_activity( ACT_ARMOR_LAYERS ) ) {
// An activity has been created to take off the item;
// we must surrender control until it is done.
return;
Expand Down
6 changes: 3 additions & 3 deletions src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ void avatar::do_read( item &book )
}

if( ( skill_level == reading->level || !skill_level.can_train() ) ||
( ( learner->has_trait( trait_id( "SCHIZOPHRENIC" ) ) ||
( ( learner->has_trait( trait_SCHIZOPHRENIC ) ||
learner->has_artifact_with( AEP_SCHIZO ) ) && one_in( 25 ) ) ) {
if( learner->is_player() ) {
add_msg( m_info, _( "You can no longer learn from %s." ), book.type_name() );
Expand Down Expand Up @@ -958,7 +958,7 @@ int avatar::calc_focus_equilibrium( bool ignore_pain ) const
{
int focus_equilibrium = 100;

if( activity.id() == activity_id( "ACT_READ" ) ) {
if( activity.id() == ACT_READ ) {
const item &book = *activity.targets[0].get_item();
if( book.is_book() && get_item_position( &book ) != INT_MIN ) {
auto &bt = *book.type->book;
Expand Down Expand Up @@ -1059,7 +1059,7 @@ void avatar::update_mental_focus()
focus_pool += calc_focus_change();

// Moved from calc_focus_equilibrium, because it is now const
if( activity.id() == activity_id( "ACT_READ" ) ) {
if( activity.id() == ACT_READ ) {
const item *book = activity.targets[0].get_item();
if( get_item_position( book ) == INT_MIN || !book->is_book() ) {
add_msg_if_player( m_bad, _( "You lost your book! You stop reading." ) );
Expand Down
Loading

0 comments on commit 9e48800

Please sign in to comment.