Skip to content

Commit

Permalink
Move string consts from several files (CleverRaven#38108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored Feb 18, 2020
1 parent c048de9 commit 036465f
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 133 deletions.
11 changes: 1 addition & 10 deletions src/timed_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@
#include "int_id.h"
#include "type_id.h"
#include "enums.h"

static const mtype_id mon_amigara_horror( "mon_amigara_horror" );
static const mtype_id mon_copbot( "mon_copbot" );
static const mtype_id mon_dark_wyrm( "mon_dark_wyrm" );
static const mtype_id mon_dermatik( "mon_dermatik" );
static const mtype_id mon_eyebot( "mon_eyebot" );
static const mtype_id mon_riotbot( "mon_riotbot" );
static const mtype_id mon_sewer_snake( "mon_sewer_snake" );
static const mtype_id mon_spider_widow_giant( "mon_spider_widow_giant" );
static const mtype_id mon_spider_cellar_giant( "mon_spider_cellar_giant" );
#include "cata_string_consts.h"

timed_event::timed_event( timed_event_type e_t, const time_point &w, int f_id, tripoint p )
: type( e_t )
Expand Down
9 changes: 3 additions & 6 deletions src/trap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "rng.h"
#include "creature.h"
#include "point.h"
#include "cata_string_consts.h"

namespace
{
Expand Down Expand Up @@ -79,10 +80,6 @@ bool string_id<trap>::is_valid() const

static std::vector<const trap *> funnel_traps;

static const skill_id skill_traps( "traps" );

static const efftype_id effect_lack_sleep( "lack_sleep" );

const std::vector<const trap *> &trap::get_funnels()
{
return funnel_traps;
Expand Down Expand Up @@ -207,8 +204,8 @@ bool trap::detect_trap( const tripoint &pos, const player &p ) const
// ...malus farther we are from trap...
rl_dist( p.pos(), pos ) +
// Police are trained to notice Something Wrong.
( p.has_trait( trait_id( "PROF_POLICE" ) ) ? 1 : 0 ) +
( p.has_trait( trait_id( "PROF_PD_DET" ) ) ? 2 : 0 ) >
( p.has_trait( trait_PROF_POLICE ) ? 1 : 0 ) +
( p.has_trait( trait_PROF_PD_DET ) ? 2 : 0 ) >
// ...must all be greater than the trap visibility.
visibility;
}
Expand Down
32 changes: 6 additions & 26 deletions src/trapfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,7 @@
#include "int_id.h"
#include "point.h"
#include "teleport.h"

static const mtype_id mon_blob( "mon_blob" );
static const mtype_id mon_shadow( "mon_shadow" );
static const mtype_id mon_shadow_snake( "mon_shadow_snake" );

static const species_id ROBOT( "ROBOT" );

static const skill_id skill_throw( "throw" );

static const efftype_id effect_beartrap( "beartrap" );
static const efftype_id effect_heavysnare( "heavysnare" );
static const efftype_id effect_in_pit( "in_pit" );
static const efftype_id effect_lightsnare( "lightsnare" );
static const efftype_id effect_slimed( "slimed" );
static const efftype_id effect_tetanus( "tetanus" );
static const efftype_id effect_ridden( "ridden" );

static const trait_id trait_INFIMMUNE( "INFIMMUNE" );
static const trait_id trait_INFRESIST( "INFRESIST" );
static const trait_id trait_WINGS_BIRD( "WINGS_BIRD" );
static const trait_id trait_WINGS_BUTTERFLY( "WINGS_BUTTERFLY" );
#include "cata_string_consts.h"

// A pit becomes less effective as it fills with corpses.
static float pit_effectiveness( const tripoint &p )
Expand Down Expand Up @@ -764,7 +744,7 @@ bool trapfunc::pit( const tripoint &p, Creature *c, item * )
if( ( n->has_trait( trait_WINGS_BIRD ) ) || ( ( one_in( 2 ) ) &&
( n->has_trait( trait_WINGS_BUTTERFLY ) ) ) ) {
n->add_msg_if_player( _( "You flap your wings and flutter down gracefully." ) );
} else if( n->has_active_bionic( bionic_id( "bio_shock_absorber" ) ) ) {
} else if( n->has_active_bionic( bio_shock_absorber ) ) {
n->add_msg_if_player( m_info,
_( "You hit the ground hard, but your shock absorbers handle the impact admirably!" ) );
} else {
Expand Down Expand Up @@ -813,7 +793,7 @@ bool trapfunc::pit_spikes( const tripoint &p, Creature *c, item * )
if( ( n->has_trait( trait_WINGS_BIRD ) ) || ( ( one_in( 2 ) ) &&
( n->has_trait( trait_WINGS_BUTTERFLY ) ) ) ) {
n->add_msg_if_player( _( "You flap your wings and flutter down gracefully." ) );
} else if( n->has_active_bionic( bionic_id( "bio_shock_absorber" ) ) ) {
} else if( n->has_active_bionic( bio_shock_absorber ) ) {
n->add_msg_if_player( m_info,
_( "You hit the ground hard, but your shock absorbers handle the impact admirably!" ) );
///\EFFECT_DODGE reduces chance of landing on spikes in spiked pit
Expand Down Expand Up @@ -896,7 +876,7 @@ bool trapfunc::pit_glass( const tripoint &p, Creature *c, item * )
if( ( n->has_trait( trait_WINGS_BIRD ) ) || ( ( one_in( 2 ) ) &&
( n->has_trait( trait_WINGS_BUTTERFLY ) ) ) ) {
n->add_msg_if_player( _( "You flap your wings and flutter down gracefully." ) );
} else if( n->has_active_bionic( bionic_id( "bio_shock_absorber" ) ) ) {
} else if( n->has_active_bionic( bio_shock_absorber ) ) {
n->add_msg_if_player( m_info,
_( "You hit the ground hard, but your shock absorbers handle the impact admirably!" ) );
///\EFFECT_DODGE reduces chance of landing on glass in glass pit
Expand Down Expand Up @@ -1126,7 +1106,7 @@ bool trapfunc::ledge( const tripoint &p, Creature *c, item * )
if( g->u.has_trait( trait_WINGS_BIRD ) || ( one_in( 2 ) &&
g->u.has_trait( trait_WINGS_BUTTERFLY ) ) ) {
add_msg( _( "You flap your wings and flutter down gracefully." ) );
} else if( g->u.has_active_bionic( bionic_id( "bio_shock_absorber" ) ) ) {
} else if( g->u.has_active_bionic( bio_shock_absorber ) ) {
add_msg( m_info,
_( "You hit the ground hard, but your shock absorbers handle the impact admirably!" ) );
} else {
Expand Down Expand Up @@ -1207,7 +1187,7 @@ bool trapfunc::ledge( const tripoint &p, Creature *c, item * )
pl->has_trait( trait_WINGS_BUTTERFLY ) ) ) {
pl->add_msg_player_or_npc( _( "You flap your wings and flutter down gracefully." ),
_( "<npcname> flaps their wings and flutters down gracefully." ) );
} else if( pl->has_active_bionic( bionic_id( "bio_shock_absorber" ) ) ) {
} else if( pl->has_active_bionic( bio_shock_absorber ) ) {
pl->add_msg_if_player( m_info,
_( "You hit the ground hard, but your shock absorbers handle the impact admirably!" ) );
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/turret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#include "optional.h"
#include "enums.h"
#include "vpart_range.h"

static const itype_id fuel_type_battery( "battery" );
static const efftype_id effect_on_roof( "on_roof" );
#include "cata_string_consts.h"

std::vector<vehicle_part *> vehicle::turrets()
{
Expand Down
27 changes: 10 additions & 17 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
#include "mapdata.h"
#include "point.h"
#include "material.h"

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

class player;

Expand All @@ -85,12 +84,6 @@ static auto can_refill = []( const vehicle_part &pt )
return pt.can_reload();
};

static const quality_id LIFT( "LIFT" );
static const quality_id JACK( "JACK" );
static const quality_id SELF_JACK( "SELF_JACK" );
static const skill_id skill_mechanics( "mechanics" );
static const itype_id fuel_type_battery( "battery" );

void act_vehicle_siphon( vehicle *veh );
void act_vehicle_unload_fuel( vehicle *veh );

Expand Down Expand Up @@ -122,7 +115,7 @@ player_activity veh_interact::serialize_activity()
if( g->u.has_trait( trait_DEBUG_HS ) ) {
time = 1;
}
player_activity res( activity_id( "ACT_VEHICLE" ), time, static_cast<int>( sel_cmd ) );
player_activity res( ACT_VEHICLE, time, static_cast<int>( sel_cmd ) );

// if we're working on an existing part, use that part as the reference point
// otherwise (e.g. installing a new frame), just use part 0
Expand Down Expand Up @@ -461,9 +454,9 @@ void veh_interact::cache_tool_availability()
if( g->u.is_mounted() ) {
mech_jack = g->u.mounted_creature->mech_str_addition() + 10;
}
max_jack = std::max( { g->u.max_quality( JACK ), mech_jack,
map_selector( g->u.pos(), PICKUP_RANGE ).max_quality( JACK ),
vehicle_selector( g->u.pos(), 2, true, *veh ).max_quality( JACK )
max_jack = std::max( { g->u.max_quality( qual_JACK ), mech_jack,
map_selector( g->u.pos(), PICKUP_RANGE ).max_quality( qual_JACK ),
vehicle_selector( g->u.pos(), 2, true, *veh ).max_quality( qual_JACK )
} );
}

Expand Down Expand Up @@ -637,7 +630,7 @@ bool veh_interact::can_self_jack()
int lvl = jack_quality( *veh );

for( const vpart_reference &vp : veh->get_avail_parts( "SELF_JACK" ) ) {
if( vp.part().base.has_quality( SELF_JACK, lvl ) ) {
if( vp.part().base.has_quality( qual_SELF_JACK, lvl ) ) {
return true;
}
}
Expand Down Expand Up @@ -746,13 +739,13 @@ bool veh_interact::can_install_part()
bool use_str = false;
item base( sel_vpart_info->item );
if( sel_vpart_info->has_flag( "NEEDS_JACKING" ) ) {
qual = JACK;
qual = qual_JACK;
lvl = jack_quality( *veh );
str = veh->lift_strength();
use_aid = ( max_jack >= lvl ) || can_self_jack();
use_str = g->u.can_lift( *veh );
} else {
qual = LIFT;
qual = qual_LIFT;
lvl = std::ceil( units::quantity<double, units::mass::unit_type>( base.weight() ) /
TOOL_LIFT_FACTOR );
str = base.lift_strength();
Expand Down Expand Up @@ -1668,13 +1661,13 @@ bool veh_interact::can_remove_part( int idx, const player &p )
bool use_str = false;
item base( sel_vpart_info->item );
if( sel_vpart_info->has_flag( "NEEDS_JACKING" ) ) {
qual = JACK;
qual = qual_JACK;
lvl = jack_quality( *veh );
str = veh->lift_strength();
use_aid = ( max_jack >= lvl ) || can_self_jack();
use_str = g->u.can_lift( *veh );
} else {
qual = LIFT;
qual = qual_LIFT;
lvl = ceil( units::quantity<double, units::mass::unit_type>( base.weight() ) / TOOL_LIFT_FACTOR );
str = base.lift_strength();
use_aid = max_lift >= lvl;
Expand Down
25 changes: 4 additions & 21 deletions src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,15 @@
#include "options.h"
#include "enums.h"
#include "monster.h"

#include "cata_string_consts.h"
/*
* Speed up all those if ( blarg == "structure" ) statements that are used everywhere;
* assemble "structure" once here instead of repeatedly later.
*/
static const itype_id fuel_type_battery( "battery" );
static const itype_id fuel_type_muscle( "muscle" );
static const itype_id fuel_type_wind( "wind" );
static const itype_id fuel_type_plutonium_cell( "plut_cell" );
static const itype_id fuel_type_animal( "animal" );
static const std::string part_location_structure( "structure" );
static const std::string part_location_center( "center" );
static const std::string part_location_onroof( "on_roof" );

static const fault_id fault_belt( "fault_engine_belt_drive" );
static const fault_id fault_immobiliser( "fault_engine_immobiliser" );
static const fault_id fault_filter_air( "fault_engine_filter_air" );
static const fault_id fault_filter_fuel( "fault_engine_filter_fuel" );

static bool is_sm_tile_outside( const tripoint &real_global_pos );
static bool is_sm_tile_over_water( const tripoint &real_global_pos );

static const efftype_id effect_harnessed( "harnessed" );
static const efftype_id effect_winded( "winded" );

// 1 kJ per battery charge
const int bat_energy_j = 1000;
//
Expand Down Expand Up @@ -118,7 +102,7 @@ class DefaultRemovePartHandler : public RemovePartHandler
void removed( vehicle &veh, const int part ) override {
// If the player is currently working on the removed part, stop them as it's futile now.
const player_activity &act = g->u.activity;
if( act.id() == activity_id( "ACT_VEHICLE" ) && act.moves_left > 0 && act.values.size() > 6 ) {
if( act.id() == ACT_VEHICLE && act.moves_left > 0 && act.values.size() > 6 ) {
if( veh_pointer_or_null( g->m.veh_at( tripoint( act.values[0], act.values[1],
g->u.posz() ) ) ) == &veh ) {
if( act.values[6] >= part ) {
Expand Down Expand Up @@ -4165,7 +4149,6 @@ float vehicle::k_traction( float wheel_traction_area ) const
return 1.0f;
}
const float mass_penalty = fraction_without_traction * to_kilogram( total_mass() );

float traction = std::min( 1.0f, wheel_traction_area / mass_penalty );
add_msg( m_debug, "%s has traction %.2f", name, traction );

Expand Down Expand Up @@ -4489,7 +4472,7 @@ void vehicle::consume_fuel( int load, const int t_seconds, bool skip_electric )
}
}
// decreased stamina burn scalable with load
if( g->u.has_active_bionic( bionic_id( "bio_jointservo" ) ) ) {
if( g->u.has_active_bionic( bio_jointservo ) ) {
g->u.mod_power_level( units::from_kilojoule( -std::max( eff_load / 20, 1 ) ) );
mod -= std::max( eff_load / 5, 5 );
}
Expand Down Expand Up @@ -4688,7 +4671,7 @@ void vehicle::power_parts()
const int gen_energy_bat = power_to_energy_bat( part_epower_w( elem ), 1_turns );
if( parts[ elem ].is_unavailable() ) {
continue;
} else if( parts[ elem ].info().has_flag( "PERPETUAL" ) ) {
} else if( parts[ elem ].info().has_flag( flag_PERPETUAL ) ) {
reactor_working = true;
delta_energy_bat += std::min( storage_deficit_bat, gen_energy_bat );
} else if( parts[elem].ammo_remaining() > 0 ) {
Expand Down
10 changes: 1 addition & 9 deletions src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,7 @@
#include "enums.h"
#include "int_id.h"
#include "monster.h"

static const std::string part_location_structure( "structure" );
static const itype_id fuel_type_muscle( "muscle" );
static const itype_id fuel_type_animal( "animal" );

static const efftype_id effect_pet( "pet" );
static const efftype_id effect_stunned( "stunned" );
static const efftype_id effect_harnessed( "harnessed" );
static const skill_id skill_driving( "driving" );
#include "cata_string_consts.h"

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

Expand Down
3 changes: 1 addition & 2 deletions src/vehicle_part.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
#include "color.h"
#include "enums.h"
#include "flat_set.h"
#include "cata_string_consts.h"

static const itype_id fuel_type_none( "null" );
static const itype_id fuel_type_battery( "battery" );
/*-----------------------------------------------------------------------------
* VEHICLE_PART
*-----------------------------------------------------------------------------*/
Expand Down
23 changes: 5 additions & 18 deletions src/vehicle_use.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,7 @@
#include "monster.h"
#include "mtype.h"
#include "weather.h"

static const itype_id fuel_type_none( "null" );
static const itype_id fuel_type_battery( "battery" );
static const itype_id fuel_type_muscle( "muscle" );
static const itype_id fuel_type_wind( "wind" );

static const fault_id fault_diesel( "fault_engine_pump_diesel" );
static const fault_id fault_glowplug( "fault_engine_glow_plug" );
static const fault_id fault_immobiliser( "fault_engine_immobiliser" );
static const fault_id fault_pump( "fault_engine_pump_fuel" );
static const fault_id fault_starter( "fault_engine_starter" );
static const efftype_id effect_harnessed( "harnessed" );
static const efftype_id effect_tied( "tied" );
static const skill_id skill_mechanics( "mechanics" );
#include "cata_string_consts.h"

enum change_types : int {
OPENCURTAINS = 0,
Expand Down Expand Up @@ -428,7 +415,7 @@ bool vehicle::interact_vehicle_locked()
const int hotwire_time = 6000 / ( ( mechanics_skill > 0 ) ? mechanics_skill : 1 );
const int moves = to_moves<int>( time_duration::from_turns( hotwire_time ) );
//assign long activity
g->u.assign_activity( activity_id( "ACT_HOTWIRE_CAR" ), moves, -1, INT_MIN, _( "Hotwire" ) );
g->u.assign_activity( ACT_HOTWIRE_CAR, moves, -1, INT_MIN, _( "Hotwire" ) );
// use part 0 as the reference point
point q = coord_translate( parts[0].mount );
const tripoint abs_veh_pos = g->m.getabs( global_pos3() );
Expand Down Expand Up @@ -1050,7 +1037,7 @@ void vehicle::start_engines( const bool take_control, const bool autodrive )
add_msg( _( "You take control of the %s." ), name );
}
if( !autodrive ) {
g->u.assign_activity( activity_id( "ACT_START_ENGINES" ), start_time );
g->u.assign_activity( ACT_START_ENGINES, start_time );
g->u.activity.placement = starting_engine_position - g->u.pos();
g->u.activity.values.push_back( take_control );
}
Expand Down Expand Up @@ -2061,7 +2048,7 @@ void vehicle::interact_with( const tripoint &pos, int interact_part )
if( veh_tool( "welder" ) ) {
// HACK: Evil hack incoming
auto &act = g->u.activity;
if( act.id() == activity_id( "ACT_REPAIR_ITEM" ) ) {
if( act.id() == ACT_REPAIR_ITEM ) {
// Magic: first tell activity the item doesn't really exist
act.index = INT_MIN;
// Then tell it to search it on `pos`
Expand Down Expand Up @@ -2106,7 +2093,7 @@ void vehicle::interact_with( const tripoint &pos, int interact_part )
case RELOAD_TURRET: {
item::reload_option opt = g->u.select_ammo( *turret.base(), true );
if( opt ) {
g->u.assign_activity( activity_id( "ACT_RELOAD" ), opt.moves(), opt.qty() );
g->u.assign_activity( ACT_RELOAD, opt.moves(), opt.qty() );
g->u.activity.targets.emplace_back( turret.base() );
g->u.activity.targets.push_back( std::move( opt.ammo ) );
}
Expand Down
Loading

0 comments on commit 036465f

Please sign in to comment.