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

Move more string consts into file for them #37302

Merged
merged 6 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
434 changes: 208 additions & 226 deletions src/activity_handlers.cpp

Large diffs are not rendered by default.

283 changes: 137 additions & 146 deletions src/activity_item_handling.cpp

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/addiction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
#include "translations.h"
#include "calendar.h"
#include "enums.h"

static const efftype_id effect_hallu( "hallu" );
static const efftype_id effect_shakes( "shakes" );
#include "cata_string_consts.h"

namespace io
{
Expand Down
41 changes: 4 additions & 37 deletions src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,11 @@
#include "string_id.h"
#include "translations.h"
#include "units.h"
#include "cata_string_consts.h"

class JsonIn;
class JsonOut;

static const efftype_id effect_contacts( "contacts" );
static const efftype_id effect_depressants( "depressants" );
static const efftype_id effect_happy( "happy" );
static const efftype_id effect_irradiated( "irradiated" );
static const efftype_id effect_pkill( "pkill" );
static const efftype_id effect_sad( "sad" );
static const efftype_id effect_sleep( "sleep" );
static const efftype_id effect_sleep_deprived( "sleep_deprived" );
static const efftype_id effect_slept_through_alarm( "slept_through_alarm" );
static const efftype_id effect_stim( "stim" );
static const efftype_id effect_stim_overdose( "stim_overdose" );

static const bionic_id bio_eye_optic( "bio_eye_optic" );
static const bionic_id bio_memory( "bio_memory" );
static const bionic_id bio_watch( "bio_watch" );

static const trait_id trait_ARACHNID_ARMS( "ARACHNID_ARMS" );
static const trait_id trait_ARACHNID_ARMS_OK( "ARACHNID_ARMS_OK" );
static const trait_id trait_CENOBITE( "CENOBITE" );
static const trait_id trait_CHITIN2( "CHITIN2" );
static const trait_id trait_CHITIN3( "CHITIN3" );
static const trait_id trait_CHITIN_FUR3( "CHITIN_FUR3" );
static const trait_id trait_COMPOUND_EYES( "COMPOUND_EYES" );
static const trait_id trait_HYPEROPIC( "HYPEROPIC" );
static const trait_id trait_INSECT_ARMS( "INSECT_ARMS" );
static const trait_id trait_INSECT_ARMS_OK( "INSECT_ARMS_OK" );
static const trait_id trait_ILLITERATE( "ILLITERATE" );
static const trait_id trait_PROF_DICEMASTER( "PROF_DICEMASTER" );
static const trait_id trait_STIMBOOST( "STIMBOOST" );
static const trait_id trait_THICK_SCALES( "THICK_SCALES" );
static const trait_id trait_WEBBED( "WEBBED" );
static const trait_id trait_WHISKERS( "WHISKERS" );
static const trait_id trait_WHISKERS_RAT( "WHISKERS_RAT" );

avatar::avatar()
{
show_map_memory = true;
Expand Down Expand Up @@ -278,7 +245,7 @@ const player *avatar::get_book_reader( const item &book, std::vector<std::string
// Check for conditions that disqualify us only if no NPCs can read to us
if( type->intel > 0 && has_trait( trait_ILLITERATE ) ) {
reasons.emplace_back( _( "You're illiterate!" ) );
} else if( has_trait( trait_HYPEROPIC ) && !worn_with_flag( "FIX_FARSIGHT" ) &&
} else if( has_trait( trait_HYPEROPIC ) && !worn_with_flag( flag_FIX_FARSIGHT ) &&
!has_effect( effect_contacts ) && !has_bionic( bio_eye_optic ) ) {
reasons.emplace_back( _( "Your eyes won't focus without reading glasses." ) );
} else if( fine_detail_vision_mod() > 4 ) {
Expand Down Expand Up @@ -308,7 +275,7 @@ const player *avatar::get_book_reader( const item &book, std::vector<std::string
has_identified( book.typeId() ) ) {
reasons.push_back( string_format( _( "%s %d needed to understand. %s has %d" ),
skill.obj().name(), type->req, elem->disp_name(), elem->get_skill_level( skill ) ) );
} else if( elem->has_trait( trait_HYPEROPIC ) && !elem->worn_with_flag( "FIX_FARSIGHT" ) &&
} else if( elem->has_trait( trait_HYPEROPIC ) && !elem->worn_with_flag( flag_FIX_FARSIGHT ) &&
!elem->has_effect( effect_contacts ) ) {
reasons.push_back( string_format( _( "%s needs reading glasses!" ),
elem->disp_name() ) );
Expand Down Expand Up @@ -392,7 +359,7 @@ bool avatar::read( item &it, const bool continuous )
const int time_taken = time_to_read( it, *reader );

add_msg( m_debug, "avatar::read: time_taken = %d", time_taken );
player_activity act( activity_id( "ACT_READ" ), time_taken, continuous ? activity.index : 0,
player_activity act( ACT_READ, time_taken, continuous ? activity.index : 0,
reader->getID().get_value() );
act.targets.emplace_back( item_location( *this, &it ) );

Expand Down
42 changes: 14 additions & 28 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,10 @@
#include "player_activity.h"
#include "ret_val.h"
#include "rng.h"
#include "cata_string_consts.h"

#define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": "

static const trait_id trait_BURROW( "BURROW" );
static const trait_id trait_SHELL2( "SHELL2" );

static const efftype_id effect_amigara( "amigara" );
static const efftype_id effect_glowing( "glowing" );
static const efftype_id effect_onfire( "onfire" );
static const efftype_id effect_pet( "pet" );
static const efftype_id effect_relax_gas( "relax_gas" );
static const efftype_id effect_stunned( "stunned" );
static const efftype_id effect_ridden( "ridden" );
static const efftype_id effect_harnessed( "harnessed" );

static const trait_id trait_GRAZER( "GRAZER" );
static const trait_id trait_RUMINANT( "RUMINANT" );

bool avatar_action::move( avatar &you, map &m, int dx, int dy, int dz )
{
if( ( !g->check_safe_mode_allowed() ) || you.has_active_mutation( trait_SHELL2 ) ) {
Expand Down Expand Up @@ -451,7 +437,7 @@ bool avatar_action::ramp_move( avatar &you, map &m, const tripoint &dest_loc )
// Basically, finish walking on the stairs instead of pulling self up by hand
bool aligned_ramps = false;
for( const tripoint &pt : m.points_in_radius( you.pos(), 1 ) ) {
if( rl_dist( pt, dest_loc ) < 2 && m.has_flag( "RAMP_END", pt ) ) {
if( rl_dist( pt, dest_loc ) < 2 && m.has_flag( flag_RAMP_END, pt ) ) {
aligned_ramps = true;
break;
}
Expand All @@ -476,7 +462,7 @@ bool avatar_action::ramp_move( avatar &you, map &m, const tripoint &dest_loc )

void avatar_action::swim( map &m, avatar &you, const tripoint &p )
{
if( !m.has_flag( "SWIMMABLE", p ) ) {
if( !m.has_flag( flag_SWIMMABLE, p ) ) {
dbg( D_ERROR ) << "game:plswim: Tried to swim in "
<< m.tername( p ) << "!";
debugmsg( "Tried to swim in %s!", m.tername( p ) );
Expand All @@ -497,7 +483,7 @@ void avatar_action::swim( map &m, avatar &you, const tripoint &p )
you.remove_effect( effect_glowing );
}
int movecost = you.swim_speed();
you.practice( skill_id( "swimming" ), you.is_underwater() ? 2 : 1 );
you.practice( skill_swimming, you.is_underwater() ? 2 : 1 );
if( movecost >= 500 ) {
if( !you.is_underwater() && !( you.shoe_type_count( "swim_fins" ) == 2 ||
( you.shoe_type_count( "swim_fins" ) == 1 && one_in( 2 ) ) ) ) {
Expand Down Expand Up @@ -638,22 +624,22 @@ bool avatar_action::fire_check( avatar &you, const map &m, const targeting_data

const optional_vpart_position vp = m.veh_at( you.pos() );
if( vp && vp->vehicle().player_in_control( you ) && ( mode_map.second->is_two_handed( you ) ||
mode_map.second->has_flag( "FIRE_TWOHAND" ) ) ) {
mode_map.second->has_flag( flag_FIRE_TWOHAND ) ) ) {
messages.push_back( string_format( _( "You can't use your %s while driving!" ),
mode_map.second->tname() ) );
fireable = false;
}

if( mode_map.second->has_flag( "FIRE_TWOHAND" ) && ( !you.has_two_arms() ||
you.worn_with_flag( "RESTRICT_HANDS" ) ) ) {
if( mode_map.second->has_flag( flag_FIRE_TWOHAND ) && ( !you.has_two_arms() ||
you.worn_with_flag( flag_RESTRICT_HANDS ) ) ) {
messages.push_back( string_format( _( "You need two free hands to fire your %s." ),
mode_map.second->tname() ) );
fireable = false;
}

// Skip certain checks if we are directly firing a vehicle turret
if( args.mode != TARGET_MODE_TURRET_MANUAL ) {
if( !mode_map.second->ammo_sufficient() && !mode_map.second->has_flag( "RELOAD_AND_SHOOT" ) ) {
if( !mode_map.second->ammo_sufficient() && !mode_map.second->has_flag( flag_RELOAD_AND_SHOOT ) ) {
if( !mode_map.second->ammo_remaining() ) {
messages.push_back( string_format( _( "Your %s is empty!" ), mode_map.second->tname() ) );
} else {
Expand Down Expand Up @@ -692,7 +678,7 @@ bool avatar_action::fire_check( avatar &you, const map &m, const targeting_data
}
}

if( mode_map.second->has_flag( "MOUNTED_GUN" ) ) {
if( mode_map.second->has_flag( flag_MOUNTED_GUN ) ) {
const bool v_mountable = static_cast<bool>( m.veh_at( you.pos() ).part_with_feature( "MOUNTABLE",
true ) );
bool t_mountable = m.has_flag_ter_or_furn( "MOUNTABLE", you.pos() );
Expand Down Expand Up @@ -739,7 +725,7 @@ bool avatar_action::fire( avatar &you, map &m )
MODERATE_EXERCISE );

// TODO: move handling "RELOAD_AND_SHOOT" flagged guns to a separate function.
if( gun->has_flag( "RELOAD_AND_SHOOT" ) ) {
if( gun->has_flag( flag_RELOAD_AND_SHOOT ) ) {
if( !gun->ammo_remaining() ) {
const auto ammo_location_is_valid = [&]() -> bool {
if( !you.ammo_location )
Expand Down Expand Up @@ -792,8 +778,8 @@ bool avatar_action::fire( avatar &you, map &m )
gun = args.relevant->gun_current_mode();

if( trajectory.empty() ) {
bool not_aiming = you.activity.id() != activity_id( "ACT_AIM" );
if( not_aiming && gun->has_flag( "RELOAD_AND_SHOOT" ) ) {
bool not_aiming = you.activity.id() != ACT_AIM;
if( not_aiming && gun->has_flag( flag_RELOAD_AND_SHOOT ) ) {
const auto previous_moves = you.moves;
g->unload( *gun );
// Give back time for unloading as essentially nothing has been done.
Expand Down Expand Up @@ -990,7 +976,7 @@ void avatar_action::plthrow( avatar &you, item_location loc,
return;
}

if( you.is_wielding( *orig ) && orig->has_flag( "NO_UNWIELD" ) ) {
if( you.is_wielding( *orig ) && orig->has_flag( flag_NO_UNWIELD ) ) {
// pos == -1 is the weapon, NO_UNWIELD is used for bio_claws_weapon
add_msg( m_info, _( "That's part of your body, you can't throw that!" ) );
return;
Expand Down Expand Up @@ -1102,7 +1088,7 @@ void avatar_action::use_item( avatar &you, item_location &loc )
return;
}

if( loc->has_flag( "ALLOWS_REMOTE_USE" ) ) {
if( loc->has_flag( flag_ALLOWS_REMOTE_USE ) ) {
use_in_place = true;
} else {
const int obtain_cost = loc.obtain_cost( you );
Expand Down
Loading