Skip to content

Commit

Permalink
Move string consts to file
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 committed Feb 17, 2020
1 parent 8ce5e61 commit 7b89cc2
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 72 deletions.
12 changes: 11 additions & 1 deletion src/cata_string_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ static const efftype_id effect_lack_sleep( "lack_sleep" );
static const efftype_id effect_laserlocked( "laserlocked" );
static const efftype_id effect_lightsnare( "lightsnare" );
static const efftype_id effect_lying_down( "lying_down" );
static const efftype_id effect_melatonin_supplements( "melatonin" );
static const efftype_id effect_masked_scent( "masked_scent" );
static const efftype_id effect_melatonin_supplements( "melatonin" );
static const efftype_id effect_mending( "mending" );
static const efftype_id effect_meth( "meth" );
static const efftype_id effect_milked( "milked" );
Expand Down Expand Up @@ -1173,7 +1173,9 @@ static const std::string flag_SHRUB( "SHRUB" );
static const std::string flag_SILENT( "SILENT" );
static const std::string flag_SKINNED( "SKINNED" );
static const std::string flag_SKINTIGHT( "SKINTIGHT" );
static const std::string flag_SLEEP_AID( "SLEEP_AID" );
static const std::string flag_SLOW_WIELD( "SLOW_WIELD" );
static const std::string flag_SLOWS_THIRST( "SLOWS_THIRST" );
static const std::string flag_SMOKABLE( "SMOKABLE" );
static const std::string flag_SMOKED( "SMOKED" );
static const std::string flag_SPEAR( "SPEAR" );
Expand Down Expand Up @@ -1385,6 +1387,14 @@ static const ammotype ammo_battery( "ammo_battery" );
static const ammotype ammo_reactor_slurry( "reactor_slurry" );
static const ammotype ammo_plutonium( "plutonium" );

static const std::string title_BIONICS = translate_marker( "BIONICS" );
static const std::string title_EFFECTS = translate_marker( "EFFECTS" );
static const std::string title_ENCUMB = translate_marker( "ENCUMBRANCE AND WARMTH" );
static const std::string title_SKILLS = translate_marker( "SKILLS" );
static const std::string title_SPEED = translate_marker( "SPEED" );
static const std::string title_STATS = translate_marker( "STATS" );
static const std::string title_TRAITS = translate_marker( "TRAITS" );

const vitamin_id vitamin_iron( "iron" );

static const std::string null_item_id( "null" );
Expand Down
18 changes: 5 additions & 13 deletions src/panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@
#include "magic.h"
#include "point.h"
#include "string_id.h"

static const trait_id trait_NOPAIN( "NOPAIN" );
static const trait_id trait_SELFAWARE( "SELFAWARE" );
static const trait_id trait_THRESH_FELINE( "THRESH_FELINE" );
static const trait_id trait_THRESH_BIRD( "THRESH_BIRD" );
static const trait_id trait_THRESH_URSINE( "THRESH_URSINE" );

static const efftype_id effect_got_checked( "got_checked" );
#include "cata_string_consts.h"

// constructor
window_panel::window_panel( std::function<void( avatar &, const catacurses::window & )>
Expand Down Expand Up @@ -430,8 +423,8 @@ static void decorate_panel( const std::string &name, const catacurses::window &w
static std::string get_temp( const avatar &u )
{
std::string temp;
if( u.has_item_with_flag( "THERMOMETER" ) ||
u.has_bionic( bionic_id( "bio_meteorologist" ) ) ) {
if( u.has_item_with_flag( flag_THERMOMETER ) ||
u.has_bionic( bio_meteorologist ) ) {
temp = print_temperature( g->weather.get_temperature( u.pos() ) );
}
if( temp.empty() ) {
Expand Down Expand Up @@ -875,7 +868,6 @@ static void draw_limb_health( avatar &u, const catacurses::window &w, int limb_i

const auto bp = avatar::hp_to_bp( static_cast<hp_part>( limb_index ) );
if( u.worn_with_flag( "SPLINT", bp ) ) {
static const efftype_id effect_mending( "mending" );
const auto &eff = u.get_effect( effect_mending, bp );
const int mend_perc = eff.is_null() ? 0.0 : 100 * eff.get_duration() / eff.get_max_duration();

Expand Down Expand Up @@ -1521,7 +1513,7 @@ static void draw_env_compact( avatar &u, const catacurses::window &w )
mvwprintz( w, point( 8, 5 ), get_wind_color( windpower ),
get_wind_desc( windpower ) + " " + get_wind_arrow( g->weather.winddirection ) );

if( u.has_item_with_flag( "THERMOMETER" ) || u.has_bionic( bionic_id( "bio_meteorologist" ) ) ) {
if( u.has_item_with_flag( flag_THERMOMETER ) || u.has_bionic( bio_meteorologist ) ) {
std::string temp = print_temperature( g->weather.get_temperature( u.pos() ) );
mvwprintz( w, point( 31 - utf8_width( temp ), 5 ), c_light_gray, temp );
}
Expand Down Expand Up @@ -1912,7 +1904,7 @@ static void draw_time_classic( const avatar &u, const catacurses::window &w )
mvwprintz( w, point( 15, 0 ), c_light_gray, _( "Time: ???" ) );
}

if( u.has_item_with_flag( "THERMOMETER" ) || u.has_bionic( bionic_id( "bio_meteorologist" ) ) ) {
if( u.has_item_with_flag( flag_THERMOMETER ) || u.has_bionic( bio_meteorologist ) ) {
std::string temp = print_temperature( g->weather.get_temperature( u.pos() ) );
mvwprintz( w, point( 31, 0 ), c_light_gray, _( "Temp : " ) + temp );
}
Expand Down
5 changes: 3 additions & 2 deletions src/pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "pimpl.h"
#include "point.h"
#include "popup.h"
#include "cata_string_consts.h"

using ItemCount = std::pair<item, int>;
using PickupMap = std::map<std::string, ItemCount>;
Expand Down Expand Up @@ -501,7 +502,7 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from )

// Not many items, just grab them
if( static_cast<int>( here.size() ) <= min && min != -1 ) {
g->u.assign_activity( activity_id( "ACT_PICKUP" ) );
g->u.assign_activity( ACT_PICKUP );
if( from_vehicle ) {
g->u.activity.targets.emplace_back( vehicle_cursor( *veh, cargo_part ), &*here.front() );
} else {
Expand Down Expand Up @@ -987,7 +988,7 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from )
}

// At this point we've selected our items, register an activity to pick them up.
g->u.assign_activity( activity_id( "ACT_PICKUP" ) );
g->u.assign_activity( ACT_PICKUP );
g->u.activity.coords.push_back( g->u.pos() );
if( min == -1 ) {
// Auto pickup will need to auto resume since there can be several of them on the stack.
Expand Down
39 changes: 20 additions & 19 deletions src/player_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "avatar.h"
#include "itype.h"
#include "skill.h"
#include "cata_string_consts.h"

player_activity::player_activity() : type( activity_id::NULL_ID() ) { }

Expand Down Expand Up @@ -67,16 +68,16 @@ std::string player_activity::get_str_value( size_t index, const std::string &def

cata::optional<std::string> player_activity::get_progress_message( const avatar &u ) const
{
if( type == activity_id( "ACT_NULL" ) || get_verb().empty() ) {
if( type == ACT_NULL || get_verb().empty() ) {
return cata::optional<std::string>();
}

std::string extra_info;
if( type == activity_id( "ACT_CRAFT" ) ) {
if( type == ACT_CRAFT ) {
if( const item *craft = targets.front().get_item() ) {
extra_info = craft->tname();
}
} else if( type == activity_id( "ACT_READ" ) ) {
} else if( type == ACT_READ ) {
if( const item *book = targets.front().get_item() ) {
if( const auto &reading = book->type->book ) {
const skill_id &skill = reading->skill;
Expand All @@ -93,24 +94,24 @@ cata::optional<std::string> player_activity::get_progress_message( const avatar
}
}
} else if( moves_total > 0 ) {
if( type == activity_id( "ACT_BURROW" ) ||
type == activity_id( "ACT_HACKSAW" ) ||
type == activity_id( "ACT_JACKHAMMER" ) ||
type == activity_id( "ACT_PICKAXE" ) ||
type == activity_id( "ACT_DISASSEMBLE" ) ||
type == activity_id( "ACT_FILL_PIT" ) ||
type == activity_id( "ACT_DIG" ) ||
type == activity_id( "ACT_DIG_CHANNEL" ) ||
type == activity_id( "ACT_CHOP_TREE" ) ||
type == activity_id( "ACT_CHOP_LOGS" ) ||
type == activity_id( "ACT_CHOP_PLANKS" )
if( type == ACT_BURROW ||
type == ACT_HACKSAW ||
type == ACT_JACKHAMMER ||
type == ACT_PICKAXE ||
type == ACT_DISASSEMBLE ||
type == ACT_FILL_PIT ||
type == ACT_DIG ||
type == ACT_DIG_CHANNEL ||
type == ACT_CHOP_TREE ||
type == ACT_CHOP_LOGS ||
type == ACT_CHOP_PLANKS
) {
const int percentage = ( ( moves_total - moves_left ) * 100 ) / moves_total;

extra_info = string_format( "%d%%", percentage );
}

if( type == activity_id( "ACT_BUILD" ) ) {
if( type == ACT_BUILD ) {
partial_con *pc = g->m.partial_con_at( g->m.getlocal( u.activity.placement ) );
if( pc ) {
int counter = std::min( pc->counter, 10000000 );
Expand Down Expand Up @@ -167,7 +168,7 @@ void player_activity::do_turn( player &p )
p.add_msg_if_player( _( "You pause for a moment to catch your breath." ) );
}
auto_resume = true;
player_activity new_act( activity_id( "ACT_WAIT_STAMINA" ), to_moves<int>( 1_minutes ) );
player_activity new_act( ACT_WAIT_STAMINA, to_moves<int>( 1_minutes ) );
new_act.values.push_back( 200 + p.get_stamina_max() / 3 );
p.assign_activity( new_act );
return;
Expand Down Expand Up @@ -218,11 +219,11 @@ bool player_activity::can_resume_with( const player_activity &other, const Chara
return false;
}

if( id() == activity_id( "ACT_CLEAR_RUBBLE" ) ) {
if( id() == ACT_CLEAR_RUBBLE ) {
if( other.coords.empty() || other.coords[0] != coords[0] ) {
return false;
}
} else if( id() == activity_id( "ACT_READ" ) ) {
} else if( id() == ACT_READ ) {
// Return false if any NPCs joined or left the study session
// the vector {1, 2} != {2, 1}, so we'll have to check manually
if( values.size() != other.values.size() ) {
Expand All @@ -236,7 +237,7 @@ bool player_activity::can_resume_with( const player_activity &other, const Chara
if( targets.empty() || other.targets.empty() || targets[0] != other.targets[0] ) {
return false;
}
} else if( id() == activity_id( "ACT_DIG" ) || id() == activity_id( "ACT_DIG_CHANNEL" ) ) {
} else if( id() == ACT_DIG || id() == ACT_DIG_CHANNEL ) {
// We must be digging in the same location.
if( placement != other.placement ) {
return false;
Expand Down
33 changes: 12 additions & 21 deletions src/player_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@
#include "translations.h"
#include "string_id.h"
#include "enums.h"

static const skill_id skill_swimming( "swimming" );

static const std::string title_STATS = translate_marker( "STATS" );
static const std::string title_ENCUMB = translate_marker( "ENCUMBRANCE AND WARMTH" );
static const std::string title_EFFECTS = translate_marker( "EFFECTS" );
static const std::string title_SPEED = translate_marker( "SPEED" );
static const std::string title_SKILLS = translate_marker( "SKILLS" );
static const std::string title_BIONICS = translate_marker( "BIONICS" );
static const std::string title_TRAITS = translate_marker( "TRAITS" );
#include "cata_string_consts.h"

// use this instead of having to type out 26 spaces like before
static const std::string header_spaces( 26, ' ' );
Expand Down Expand Up @@ -692,7 +683,7 @@ static const Skill *draw_skills_list( const catacurses::window &w_skills,
int exercise = level.exercise();
int level_num = level.level();
bool locked = false;
if( you.has_active_bionic( bionic_id( "bio_cqb" ) ) && is_cqb_skill( aSkill->ident() ) ) {
if( you.has_active_bionic( bio_cqb ) && is_cqb_skill( aSkill->ident() ) ) {
level_num = 5;
exercise = 0;
locked = true;
Expand Down Expand Up @@ -724,7 +715,7 @@ static const Skill *draw_skills_list( const catacurses::window &w_skills,
mvwprintz( w_skills, point( 1, y_pos ), c_light_gray, std::string( col_width, ' ' ) );
}
mvwprintz( w_skills, point( 1, y_pos ), cstatus, "%s:", aSkill->name() );
if( aSkill->ident() == skill_id( "dodge" ) ) {
if( aSkill->ident() == skill_dodge ) {
mvwprintz( w_skills, point( 14, y_pos ), cstatus, "%4.1f/%-2d(%2d%%)",
you.get_dodge(), level_num, exercise < 0 ? 0 : exercise );
} else {
Expand Down Expand Up @@ -1030,7 +1021,7 @@ static void draw_initial_windows( const catacurses::window &w_stats,
left_justify( inanition, 20 ), pen );
line++;
}
if( you.has_trait( trait_id( "SUNLIGHT_DEPENDENT" ) ) && !g->is_in_sunlight( you.pos() ) ) {
if( you.has_trait( trait_SUNLIGHT_DEPENDENT ) && !g->is_in_sunlight( you.pos() ) ) {
pen = ( g->light_level( you.posz() ) >= 12 ? 5 : 10 );
mvwprintz( w_speed, point( 1, line ), c_red,
pgettext( "speed penalty", "Out of Sunlight -%2d%%" ), pen );
Expand All @@ -1042,7 +1033,7 @@ static void draw_initial_windows( const catacurses::window &w_stats,
nc_color pen_color;
std::string pen_sign;
const auto player_local_temp = g->weather.get_temperature( you.pos() );
if( you.has_trait( trait_id( "COLDBLOOD4" ) ) && player_local_temp > 65 ) {
if( you.has_trait( trait_COLDBLOOD4 ) && player_local_temp > 65 ) {
pen_color = c_green;
pen_sign = "+";
} else if( player_local_temp < 65 ) {
Expand All @@ -1060,16 +1051,16 @@ static void draw_initial_windows( const catacurses::window &w_stats,

int quick_bonus = static_cast<int>( newmoves - ( newmoves / 1.1 ) );
int bio_speed_bonus = quick_bonus;
if( you.has_trait( trait_id( "QUICK" ) ) && you.has_bionic( bionic_id( "bio_speed" ) ) ) {
if( you.has_trait( trait_QUICK ) && you.has_bionic( bio_speed ) ) {
bio_speed_bonus = static_cast<int>( newmoves / 1.1 - ( newmoves / 1.1 / 1.1 ) );
std::swap( quick_bonus, bio_speed_bonus );
}
if( you.has_trait( trait_id( "QUICK" ) ) ) {
if( you.has_trait( trait_QUICK ) ) {
mvwprintz( w_speed, point( 1, line ), c_green,
pgettext( "speed bonus", "Quick +%2d%%" ), quick_bonus );
line++;
}
if( you.has_bionic( bionic_id( "bio_speed" ) ) ) {
if( you.has_bionic( bio_speed ) ) {
mvwprintz( w_speed, point( 1, line ), c_green,
pgettext( "speed bonus", "Bionic Speed +%2d%%" ), bio_speed_bonus );
}
Expand Down Expand Up @@ -1142,20 +1133,20 @@ void player::disp_info()
effect_name_and_text.push_back( { starvation_name, starvation_text } );
}

if( ( has_trait( trait_id( "TROGLO" ) ) && g->is_in_sunlight( pos() ) &&
if( ( has_trait( trait_TROGLO ) && g->is_in_sunlight( pos() ) &&
g->weather.weather == WEATHER_SUNNY ) ||
( has_trait( trait_id( "TROGLO2" ) ) && g->is_in_sunlight( pos() ) &&
( has_trait( trait_TROGLO2 ) && g->is_in_sunlight( pos() ) &&
g->weather.weather != WEATHER_SUNNY ) ) {
effect_name_and_text.push_back( { _( "In Sunlight" ),
_( "The sunlight irritates you.\n"
"Strength - 1; Dexterity - 1; Intelligence - 1; Perception - 1" )
} );
} else if( has_trait( trait_id( "TROGLO2" ) ) && g->is_in_sunlight( pos() ) ) {
} else if( has_trait( trait_TROGLO2 ) && g->is_in_sunlight( pos() ) ) {
effect_name_and_text.push_back( { _( "In Sunlight" ),
_( "The sunlight irritates you badly.\n"
"Strength - 2; Dexterity - 2; Intelligence - 2; Perception - 2" )
} );
} else if( has_trait( trait_id( "TROGLO3" ) ) && g->is_in_sunlight( pos() ) ) {
} else if( has_trait( trait_TROGLO3 ) && g->is_in_sunlight( pos() ) ) {
effect_name_and_text.push_back( { _( "In Sunlight" ),
_( "The sunlight irritates you terribly.\n"
"Strength - 4; Dexterity - 4; Intelligence - 4; Perception - 4" )
Expand Down
3 changes: 1 addition & 2 deletions src/requirements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
#include "item.h"
#include "visitable.h"
#include "point.h"

static const trait_id trait_DEBUG_HS( "DEBUG_HS" );
#include "cata_string_consts.h"

static std::map<requirement_id, requirement_data> requirements_all;

Expand Down
17 changes: 3 additions & 14 deletions src/sounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "point.h"
#include "string_id.h"
#include "safemode_ui.h"
#include "cata_string_consts.h"

#if defined(SDL_SOUND)
# if defined(_MSC_VER) && defined(USE_VCPKG)
Expand Down Expand Up @@ -71,18 +72,6 @@ auto sfx_time = end_sfx_timestamp - start_sfx_timestamp;
activity_id act;
std::pair<std::string, std::string> engine_external_id_and_variant;

static const efftype_id effect_alarm_clock( "alarm_clock" );
static const efftype_id effect_deaf( "deaf" );
static const efftype_id effect_narcosis( "narcosis" );
static const efftype_id effect_sleep( "sleep" );
static const efftype_id effect_slept_through_alarm( "slept_through_alarm" );

static const trait_id trait_HEAVYSLEEPER2( "HEAVYSLEEPER2" );
static const trait_id trait_HEAVYSLEEPER( "HEAVYSLEEPER" );
static const itype_id fuel_type_muscle( "muscle" );
static const itype_id fuel_type_wind( "wind" );
static const itype_id fuel_type_battery( "battery" );

struct sound_event {
int volume;
sounds::sound_t category;
Expand Down Expand Up @@ -372,7 +361,7 @@ void sounds::process_sound_markers( player *p )
if( is_sound_deafening && !p->is_immune_effect( effect_deaf ) ) {
p->add_effect( effect_deaf, std::min( 4_minutes,
time_duration::from_turns( felt_volume - 130 ) / 8 ) );
if( !p->has_trait( trait_id( "NOPAIN" ) ) ) {
if( !p->has_trait( trait_NOPAIN ) ) {
p->add_msg_if_player( m_bad, _( "Your eardrums suddenly ache!" ) );
if( p->get_pain() < 10 ) {
p->mod_pain( rng( 0, 2 ) );
Expand Down Expand Up @@ -457,7 +446,7 @@ void sounds::process_sound_markers( player *p )
}

if( !p->has_effect( effect_sleep ) && p->has_effect( effect_alarm_clock ) &&
!p->has_bionic( bionic_id( "bio_watch" ) ) ) {
!p->has_bionic( bio_watch ) ) {
// if we don't have effect_sleep but we're in_sleep_state, either
// we were trying to fall asleep for so long our alarm is now going
// off or something disturbed us while trying to sleep
Expand Down

0 comments on commit 7b89cc2

Please sign in to comment.