Skip to content

Commit

Permalink
Move more string consts into single file (#38169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored Feb 20, 2020
1 parent 256c539 commit 07995cd
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 45 deletions.
14 changes: 14 additions & 0 deletions src/cata_string_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ static const std::string flag_ALLERGEN_MEAT( "ALLERGEN_MEAT" );
static const std::string flag_ALLERGEN_MILK( "ALLERGEN_MILK" );
static const std::string flag_ALLERGEN_VEGGY( "ALLERGEN_VEGGY" );
static const std::string flag_ALLERGEN_WHEAT( "ALLERGEN_WHEAT" );
static const std::string flag_ALLOW_OUTSIDE( "ALLOW_OUTSIDE" );
static const std::string flag_ALLOW_ROTTEN( "ALLOW_ROTTEN" );
static const std::string flag_ALLOWS_NATURAL_ATTACKS( "ALLOWS_NATURAL_ATTACKS" );
static const std::string flag_ALLOWS_REMOTE_USE( "ALLOWS_REMOTE_USE" );
Expand All @@ -954,6 +955,7 @@ static const std::string flag_BLIND_EASY( "BLIND_EASY" );
static const std::string flag_BLIND_HARD( "BLIND_HARD" );
static const std::string flag_BLOCK_WHILE_WORN( "BLOCK_WHILE_WORN" );
static const std::string flag_BLOCKSDOOR( "BLOCKSDOOR" );
static const std::string flag_BOARDED( "BOARDED" );
static const std::string flag_BOMB( "BOMB" );
static const std::string flag_BURROWABLE( "BURROWABLE" );
static const std::string flag_BUTCHER_EQ( "BUTCHER_EQ" );
Expand Down Expand Up @@ -988,6 +990,7 @@ static const std::string flag_DANGEROUS( "DANGEROUS" );
static const std::string flag_DEAF( "DEAF" );
static const std::string flag_DEEP_WATER( "DEEP_WATER" );
static const std::string flag_DESTROY_ITEM( "DESTROY_ITEM" );
static const std::string flag_DETERGENT( "DETERGENT" );
static const std::string flag_DIAMOND( "DIAMOND" );
static const std::string flag_DIFFICULT_Z( "DIFFICULT_Z" );
static const std::string flag_DIG_TOOL( "DIG_TOOL" );
Expand All @@ -999,6 +1002,8 @@ static const std::string flag_DONT_REMOVE_ROTTEN( "DONT_REMOVE_ROTTEN" );
static const std::string flag_DOOR( "DOOR" );
static const std::string flag_DROP_ACTION_ONLY_IF_LIQUID( "DROP_ACTION_ONLY_IF_LIQUID" );
static const std::string flag_DURABLE_MELEE( "DURABLE_MELEE" );
static const std::string flag_E_COLD_START( "E_COLD_START" );
static const std::string flag_E_STARTS_INSTANTLY( "E_STARTS_INSTANTLY" );
static const std::string flag_EASY_DECONSTRUCT( "EASY_DECONSTRUCT" );
static const std::string flag_EATEN_COLD( "EATEN_COLD" );
static const std::string flag_EATEN_HOT( "EATEN_HOT" );
Expand Down Expand Up @@ -1108,6 +1113,8 @@ static const std::string flag_MILLABLE( "MILLABLE" );
static const std::string flag_MINEABLE( "MINEABLE" );
static const std::string flag_MOUNTABLE( "MOUNTABLE" );
static const std::string flag_MOUNTED_GUN( "MOUNTED_GUN" );
static const std::string flag_MUSCLE_ARMS( "MUSCLE_ARMS" );
static const std::string flag_MUSCLE_LEGS( "MUSCLE_LEGS" );
static const std::string flag_MUSHY( "MUSHY" );
static const std::string flag_MYCUS_OK( "MYCUS_OK" );
static const std::string flag_NANOFAB_TEMPLATE( "NANOFAB_TEMPLATE" );
Expand Down Expand Up @@ -1140,6 +1147,7 @@ static const std::string flag_NPC_ACTIVATE( "NPC_ACTIVATE" );
static const std::string flag_NPC_SAFE( "NPC_SAFE" );
static const std::string flag_NUTRIENT_OVERRIDE( "NUTRIENT_OVERRIDE" );
static const std::string flag_ONLY_ONE( "ONLY_ONE" );
static const std::string flag_OPENABLE( "OPENABLE" );
static const std::string flag_OPENCLOSE_INSIDE( "OPENCLOSE_INSIDE" );
static const std::string flag_ORGANIC( "ORGANIC" );
static const std::string flag_OUTER( "OUTER" );
Expand All @@ -1151,6 +1159,7 @@ static const std::string flag_PLACE_ITEM( "PLACE_ITEM" );
static const std::string flag_PLACE_RANDOMLY( "PLACE_RANDOMLY" );
static const std::string flag_PLANT( "PLANT" );
static const std::string flag_PLANTABLE( "PLANTABLE" );
static const std::string flag_PLANTER( "PLANTER" );
static const std::string flag_PLOWABLE( "PLOWABLE" );
static const std::string flag_POCKETS( "POCKETS" );
static const std::string flag_POWERARMOR_COMPATIBLE( "POWERARMOR_COMPATIBLE" );
Expand Down Expand Up @@ -1202,11 +1211,14 @@ static const std::string flag_SAFE_FUEL_OFF( "SAFE_FUEL_OFF" );
static const std::string flag_SAFECRACK( "SAFECRACK" );
static const std::string flag_SALT_WATER( "SALT_WATER" );
static const std::string flag_SAPIOVORE( "SAPIOVORE" );
static const std::string flag_SCEN_ONLY( "SCEN_ONLY" );
static const std::string flag_SEALED( "SEALED" );
static const std::string flag_SEAT( "SEAT" );
static const std::string flag_SECRET( "SECRET" );
static const std::string flag_SEMITANGIBLE( "SEMITANGIBLE" );
static const std::string flag_SHARP( "SHARP" );
static const std::string flag_SHRUB( "SHRUB" );
static const std::string flag_SIGN( "SIGN" );
static const std::string flag_SILENT( "SILENT" );
static const std::string flag_SKINNED( "SKINNED" );
static const std::string flag_SKINTIGHT( "SKINTIGHT" );
Expand All @@ -1219,6 +1231,7 @@ static const std::string flag_SPEAR( "SPEAR" );
static const std::string flag_SPEEDLOADER( "SPEEDLOADER" );
static const std::string flag_SPLINT( "SPLINT" );
static const std::string flag_SPR_START( "SPR_START" );
static const std::string flag_STEERABLE( "STEERABLE" );
static const std::string flag_STR_DRAW( "STR_DRAW" );
static const std::string flag_STR_RELOAD( "STR_RELOAD" );
static const std::string flag_STURDY( "STURDY" );
Expand Down Expand Up @@ -1254,6 +1267,7 @@ static const std::string flag_URSINE_HONEY( "URSINE_HONEY" );
static const std::string flag_USABLE_FIRE( "USABLE_FIRE" );
static const std::string flag_USE_EAT_VERB( "USE_EAT_VERB" );
static const std::string flag_USE_PLAYER_ENERGY( "USE_PLAYER_ENERGY" );
static const std::string flag_USE_TANKS( "USE_TANKS" );
static const std::string flag_USE_UPS( "USE_UPS" );
static const std::string flag_USES_BIONIC_POWER( "USES_BIONIC_POWER" );
static const std::string flag_VARSIZE( "VARSIZE" );
Expand Down
6 changes: 3 additions & 3 deletions src/monattack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ bool mattack::none( monster * )
bool mattack::eat_crop( monster *z )
{
for( const auto &p : g->m.points_in_radius( z->pos(), 1 ) ) {
if( g->m.has_flag( "PLANT", p ) && one_in( 4 ) ) {
if( g->m.has_flag( flag_PLANT, p ) && one_in( 4 ) ) {
g->m.furn_set( p, furn_str_id( g->m.furn( p )->plant->base ) );
g->m.i_clear( p );
return true;
Expand All @@ -205,7 +205,7 @@ bool mattack::eat_food( monster *z )
{
for( const auto &p : g->m.points_in_radius( z->pos(), 1 ) ) {
//Protect crop seeds from carnivores, give omnivores eat_crop special also
if( g->m.has_flag( "PLANT", p ) ) {
if( g->m.has_flag( flag_PLANT, p ) ) {
continue;
}
auto items = g->m.i_at( p );
Expand Down Expand Up @@ -672,7 +672,7 @@ bool mattack::pull_metal_weapon( monster *z )
player *foe = dynamic_cast< player * >( target );
if( foe != nullptr ) {
// Wielded steel or iron items except for built-in things like bionic claws or monomolecular blade
if( !foe->weapon.has_flag( "NO_UNWIELD" ) &&
if( !foe->weapon.has_flag( flag_NO_UNWIELD ) &&
( foe->weapon.made_of( material_id( "iron" ) ) ||
foe->weapon.made_of( material_id( "hardsteel" ) ) ||
foe->weapon.made_of( material_id( "steel" ) ) ||
Expand Down
4 changes: 2 additions & 2 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3205,8 +3205,8 @@ std::string give_item_to( npc &p, bool allow_use )
}
item &given = *loc;

if( ( &given == &g->u.weapon && given.has_flag( "NO_UNWIELD" ) ) || ( g->u.is_worn( given ) &&
given.has_flag( "NO_TAKEOFF" ) ) ) {
if( ( &given == &g->u.weapon && given.has_flag( flag_NO_UNWIELD ) ) || ( g->u.is_worn( given ) &&
given.has_flag( flag_NO_TAKEOFF ) ) ) {
// Bionic weapon or shackles
return _( "How?" );
}
Expand Down
8 changes: 4 additions & 4 deletions src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ void vehicle_part::deserialize( JsonIn &jsin )
}

// with VEHICLE tag migrate fuel tanks only if amount field exists
if( base.has_flag( "VEHICLE" ) ) {
if( base.has_flag( flag_VEHICLE ) ) {
if( data.has_int( "amount" ) && ammo_capacity() > 0 && legacy_fuel != "battery" ) {
ammo_set( legacy_fuel, data.get_int( "amount" ) );
}
Expand Down Expand Up @@ -2700,21 +2700,21 @@ void vehicle::deserialize( JsonIn &jsin )

// Add vehicle mounts to cars that are missing them.
for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_LIGHT" ) ) {
if( vp.info().has_flag( "STEERABLE" ) ) {
if( vp.info().has_flag( flag_STEERABLE ) ) {
install_part( vp.mount(), vpart_id( "wheel_mount_light_steerable" ), false );
} else {
install_part( vp.mount(), vpart_id( "wheel_mount_light" ), false );
}
}
for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_MEDIUM" ) ) {
if( vp.info().has_flag( "STEERABLE" ) ) {
if( vp.info().has_flag( flag_STEERABLE ) ) {
install_part( vp.mount(), vpart_id( "wheel_mount_medium_steerable" ), false );
} else {
install_part( vp.mount(), vpart_id( "wheel_mount_medium" ), false );
}
}
for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_HEAVY" ) ) {
if( vp.info().has_flag( "STEERABLE" ) ) {
if( vp.info().has_flag( flag_STEERABLE ) ) {
install_part( vp.mount(), vpart_id( "wheel_mount_heavy_steerable" ), false );
} else {
install_part( vp.mount(), vpart_id( "wheel_mount_heavy" ), false );
Expand Down
5 changes: 3 additions & 2 deletions src/scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "profession.h"
#include "translations.h"
#include "rng.h"
#include "cata_string_consts.h"

namespace
{
Expand Down Expand Up @@ -300,11 +301,11 @@ std::vector<string_id<profession>> scenario::permitted_professions() const
const bool present = std::find( professions.begin(), professions.end(),
p.ident() ) != professions.end();
if( blacklist || professions.empty() ) {
if( !present && !p.has_flag( "SCEN_ONLY" ) ) {
if( !present && !p.has_flag( flag_SCEN_ONLY ) ) {
res.push_back( p.ident() );
}
} else if( extra_professions ) {
if( present || !p.has_flag( "SCEN_ONLY" ) ) {
if( present || !p.has_flag( flag_SCEN_ONLY ) ) {
res.push_back( p.ident() );
}
} else if( present ) {
Expand Down
3 changes: 2 additions & 1 deletion src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "json.h"
#include "optional.h"
#include "point.h"
#include "cata_string_consts.h"

#if defined(__linux__)
# include <cstdlib> // getenv()/setenv()
Expand Down Expand Up @@ -2609,7 +2610,7 @@ static void CheckMessages()
actions.insert( ACTION_CYCLE_MOVE );
}
// 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 ) ) {
actions.insert( ACTION_FIRE );
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/start_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "rng.h"
#include "translations.h"
#include "point.h"
#include "cata_string_consts.h"

class item;

Expand Down Expand Up @@ -185,7 +186,7 @@ static void board_up( map &m, const tripoint_range &range )
void start_location::prepare_map( tinymap &m ) const
{
const int z = m.get_abs_sub().z;
if( flags().count( "BOARDED" ) > 0 ) {
if( flags().count( flag_BOARDED ) > 0 ) {
m.build_outside_cache( z );
board_up( m, m.points_on_zlevel( z ) );
} else {
Expand Down Expand Up @@ -268,7 +269,7 @@ static int rate_location( map &m, const tripoint &p, const bool must_be_inside,
checked[cur.x][cur.y] = attempt;
if( cur.x == 0 || cur.x == MAPSIZE_X - 1 ||
cur.y == 0 || cur.y == MAPSIZE_Y - 1 ||
m.has_flag( "GOES_UP", cur ) ) {
m.has_flag( flag_GOES_UP, cur ) ) {
return INT_MAX;
}

Expand All @@ -295,7 +296,7 @@ void start_location::place_player( player &u ) const
u.setz( g->get_levz() );
m.invalidate_map_cache( m.get_abs_sub().z );
m.build_map_cache( m.get_abs_sub().z );
const bool must_be_inside = flags().count( "ALLOW_OUTSIDE" ) == 0;
const bool must_be_inside = flags().count( flag_ALLOW_OUTSIDE ) == 0;
///\EFFECT_STR allows player to start behind less-bashable furniture and terrain
// TODO: Allow using items here
const int bash = u.get_str();
Expand Down Expand Up @@ -364,7 +365,7 @@ void start_location::burn( const tripoint &omtstart,
m.has_flag_ter( "OPENCLOSE_INSIDE", p ) ||
m.is_outside( p ) ||
( p.x >= ux - rad && p.x <= ux + rad && p.y >= uy - rad && p.y <= uy + rad ) ) ) {
if( m.has_flag( "FLAMMABLE", p ) || m.has_flag( "FLAMMABLE_ASH", p ) ) {
if( m.has_flag( flag_FLAMMABLE, p ) || m.has_flag( flag_FLAMMABLE_ASH, p ) ) {
valid.push_back( p );
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/submap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "mapdata.h"
#include "trap.h"
#include "tileray.h"
#include "cata_string_consts.h"

template<int sx, int sy>
void maptile_soa<sx, sy>::swap_soa_tile( const point &p1, const point &p2 )
Expand Down Expand Up @@ -108,15 +109,15 @@ void submap::delete_graffiti( const point &p )
}
bool submap::has_signage( const point &p ) const
{
if( frn[p.x][p.y].obj().has_flag( "SIGN" ) ) {
if( frn[p.x][p.y].obj().has_flag( flag_SIGN ) ) {
return find_cosmetic( cosmetics, p, COSMETICS_SIGNAGE ).result;
}

return false;
}
std::string submap::get_signage( const point &p ) const
{
if( frn[p.x][p.y].obj().has_flag( "SIGN" ) ) {
if( frn[p.x][p.y].obj().has_flag( flag_SIGN ) ) {
const auto fresult = find_cosmetic( cosmetics, p, COSMETICS_SIGNAGE );
if( fresult.result ) {
return cosmetics[ fresult.ndx ].str;
Expand Down
4 changes: 2 additions & 2 deletions src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ void Character::suffer_in_sunlight()
}

if( has_trait( trait_SUNBURN ) && one_in( 10 ) ) {
if( !( weapon.has_flag( "RAIN_PROTECT" ) ) ) {
if( !( weapon.has_flag( flag_RAIN_PROTECT ) ) ) {
add_msg_if_player( m_bad, _( "The sunlight burns your skin!" ) );
if( has_effect( effect_sleep ) && !has_effect( effect_narcosis ) ) {
wake_up();
Expand Down Expand Up @@ -696,7 +696,7 @@ void Character::suffer_from_albinism()
}
}
// Umbrellas can keep the sun off the skin
if( weapon.has_flag( "RAIN_PROTECT" ) ) {
if( weapon.has_flag( flag_RAIN_PROTECT ) ) {
return;
}
//calculate total coverage of skin
Expand Down
22 changes: 11 additions & 11 deletions src/turret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ int turret_data::ammo_remaining() const
if( !veh || !part ) {
return 0;
}
if( part->info().has_flag( "USE_TANKS" ) ) {
if( part->info().has_flag( flag_USE_TANKS ) ) {
return veh->fuel_left( ammo_current() );
}
return part->base.ammo_remaining();
}

int turret_data::ammo_capacity() const
{
if( !veh || !part || part->info().has_flag( "USE_TANKS" ) ) {
if( !veh || !part || part->info().has_flag( flag_USE_TANKS ) ) {
return 0;
}
return part->base.ammo_capacity();
Expand All @@ -112,7 +112,7 @@ const itype *turret_data::ammo_data() const
if( !veh || !part ) {
return nullptr;
}
if( part->info().has_flag( "USE_TANKS" ) ) {
if( part->info().has_flag( flag_USE_TANKS ) ) {
return ammo_current() != "null" ? item::find_type( ammo_current() ) : nullptr;
}
return part->base.ammo_data();
Expand Down Expand Up @@ -141,7 +141,7 @@ std::set<itype_id> turret_data::ammo_options() const
return opts;
}

if( !part->info().has_flag( "USE_TANKS" ) ) {
if( !part->info().has_flag( flag_USE_TANKS ) ) {
if( part->base.ammo_current() != "null" ) {
opts.insert( part->base.ammo_current() );
}
Expand Down Expand Up @@ -176,7 +176,7 @@ std::set<std::string> turret_data::ammo_effects() const
return std::set<std::string>();
}
auto res = part->base.ammo_effects();
if( part->info().has_flag( "USE_TANKS" ) && ammo_data() ) {
if( part->info().has_flag( flag_USE_TANKS ) && ammo_data() ) {
res.insert( ammo_data()->ammo->ammo_effects.begin(), ammo_data()->ammo->ammo_effects.end() );
}
return res;
Expand All @@ -188,15 +188,15 @@ int turret_data::range() const
return 0;
}
int res = part->base.gun_range();
if( part->info().has_flag( "USE_TANKS" ) && ammo_data() ) {
if( part->info().has_flag( flag_USE_TANKS ) && ammo_data() ) {
res += ammo_data()->ammo->range;
}
return res;
}

bool turret_data::can_reload() const
{
if( !veh || !part || part->info().has_flag( "USE_TANKS" ) ) {
if( !veh || !part || part->info().has_flag( flag_USE_TANKS ) ) {
return false;
}
if( !part->base.magazine_integral() ) {
Expand All @@ -208,7 +208,7 @@ bool turret_data::can_reload() const

bool turret_data::can_unload() const
{
if( !veh || !part || part->info().has_flag( "USE_TANKS" ) ) {
if( !veh || !part || part->info().has_flag( flag_USE_TANKS ) ) {
return false;
}
return part->base.ammo_remaining() || part->base.magazine_current();
Expand All @@ -220,7 +220,7 @@ turret_data::status turret_data::query() const
return status::invalid;
}

if( part->info().has_flag( "USE_TANKS" ) ) {
if( part->info().has_flag( flag_USE_TANKS ) ) {
if( veh->fuel_left( ammo_current() ) < part->base.ammo_required() ) {
return status::no_ammo;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ void turret_data::prepare_fire( player &p )
p.recoil = 0;

// set fuel tank fluid as ammo, if appropriate
if( part->info().has_flag( "USE_TANKS" ) ) {
if( part->info().has_flag( flag_USE_TANKS ) ) {
auto mode = base()->gun_current_mode();
int qty = mode->ammo_required();
int fuel_left = veh->fuel_left( ammo_current() );
Expand All @@ -266,7 +266,7 @@ void turret_data::post_fire( player &p, int shots )
auto mode = base()->gun_current_mode();

// handle draining of vehicle tanks and UPS charges, if applicable
if( part->info().has_flag( "USE_TANKS" ) ) {
if( part->info().has_flag( flag_USE_TANKS ) ) {
veh->drain( ammo_current(), mode->ammo_required() * shots );
mode->ammo_unset();
}
Expand Down
2 changes: 1 addition & 1 deletion src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p,
return ret;
}
// we just ran into a fish, so move it out of the way
if( g->m.has_flag( "SWIMMABLE", critter->pos() ) ) {
if( g->m.has_flag( flag_SWIMMABLE, critter->pos() ) ) {
tripoint end_pos = critter->pos();
tripoint start_pos;
const int angle = move.dir() + 45 * ( parts[part].mount.x > pivot_point().x ? -1 : 1 );
Expand Down
Loading

0 comments on commit 07995cd

Please sign in to comment.