Skip to content

Commit

Permalink
Merge pull request #208 from WhiteCloud0123/develop
Browse files Browse the repository at this point in the history
杂项
  • Loading branch information
WhiteCloud0123 authored Jul 15, 2023
2 parents 9e98975 + 97ed12a commit ea9cf88
Show file tree
Hide file tree
Showing 48 changed files with 86 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,7 @@ std::unique_ptr<activity_actor> ebooksave_activity_actor::deserialize( JsonValue
return actor.clone();
}

constexpr time_duration ebooksave_activity_actor::time_per_page;


void migration_cancel_activity_actor::do_turn( player_activity &act, Character &who )
{
Expand Down
4 changes: 2 additions & 2 deletions src/activity_actor_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,10 +712,10 @@ class consume_activity_actor : public activity_actor
type( type ) {}

explicit consume_activity_actor( const item_location &consume_location ) :
consume_location( consume_location ), consume_menu_selections( std::vector<int>() ) {}
consume_location(consume_location) {}

explicit consume_activity_actor( const item &consume_item ) :
consume_item( consume_item ), consume_menu_selections( std::vector<int>() ) {}
consume_item(consume_item) {}

activity_id get_type() const override {
return activity_id( "ACT_CONSUME" );
Expand Down
2 changes: 1 addition & 1 deletion src/bodypart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ sub_bodypart_id body_part_type::random_sub_part( bool secondary ) const
}
}
// should never get here
return ( sub_bodypart_id() );
return sub_bodypart_id();
}

const std::vector<body_part_type> &body_part_type::get_all()
Expand Down
6 changes: 5 additions & 1 deletion src/cata_small_literal_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define CATA_SRC_CATA_SMALL_LITERAL_VECTOR_H

#include <cstdlib>
#include <limits>
#include <memory>
#include <stdexcept>
#include <type_traits>
Expand All @@ -20,7 +21,10 @@ template<typename T, size_t kInlineCount = 4, typename SizeT = uint8_t>
struct alignas( T * ) small_literal_vector {
// To avoid having to invoke constructors and destructors when copying Elements
// around or inserting new ones, we enforce it is a literal type.
static_assert( std::is_literal_type<T>::value, "T must be literal." );
static_assert(std::is_trivially_destructible_v<T>, "T must be trivially destructible.");
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable.");
static_assert(std::is_trivially_default_constructible_v<T>,
"T must be trivially default constuctible.");

small_literal_vector() : heap_( nullptr ), capacity_( kInlineCount ), len_( 0 ) {}
small_literal_vector( const small_literal_vector &other ) : capacity_( kInlineCount ), len_( 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ
if( display_tile.animated ) {
// idle animations run during the user's turn, and the animation speed
// needs to be defined by the tileset to look good, so we use system clock:
auto now = std::chrono::system_clock::now();
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
auto now_ms = std::chrono::time_point_cast<std::chrono::milliseconds>( now );
auto value = now_ms.time_since_epoch();
// aiming roughly at the standard 60 frames per second:
Expand Down
8 changes: 4 additions & 4 deletions src/crafting_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ static recipe_subset filter_recipes( const recipe_subset &available_recipes,
// Find next ','
qry_end = qry.find_first_of( ',', qry_begin );

auto qry_filter_str = trim( qry.substr( qry_begin, qry_end - qry_begin ) );
std::string qry_filter_str = trim(qry.substr(qry_begin, qry_end - qry_begin));
// Process filter
if( qry_filter_str.size() > 2 && qry_filter_str[1] == ':' ) {
switch( qry_filter_str[0] ) {
Expand Down Expand Up @@ -1404,12 +1404,12 @@ const recipe *select_crafting_recipe( int &batch_size_out, const recipe_id &goto
indent.assign( current.size(), 0 );
} else {
static_popup popup;
auto last_update = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point last_update = std::chrono::steady_clock::now();
static constexpr std::chrono::milliseconds update_interval( 500 );

std::function<void( size_t, size_t )> progress_callback =
[&]( size_t at, size_t out_of ) {
auto now = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
if( now - last_update < update_interval ) {
return;
}
Expand All @@ -1423,7 +1423,7 @@ const recipe *select_crafting_recipe( int &batch_size_out, const recipe_id &goto

std::vector<const recipe *> picking;
if( !filterstring.empty() ) {
auto qry = trim( filterstring );
std::string qry = trim(filterstring);
recipe_subset filtered_recipes =
filter_recipes( available_recipes, qry, player_character, progress_callback );
picking.insert( picking.end(), filtered_recipes.begin(), filtered_recipes.end() );
Expand Down
2 changes: 1 addition & 1 deletion src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ struct time_info {
using char_t = typename Stream::char_type;
using base = std::basic_ostream<char_t>;

static_assert( std::is_base_of<base, Stream>::value, "" );
static_assert(std::is_base_of<base, Stream>::value);

out << std::setfill( '0' );
out << std::setw( 2 ) << t.hours << ':' << std::setw( 2 ) << t.minutes << ':' <<
Expand Down
7 changes: 4 additions & 3 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,8 @@ static void character_edit_menu()
uilist ssmenu;
std::vector<std::pair<std::string, mutation_category_id>> mutation_categories_list;
mutation_categories_list.reserve( mutations_category.size() );
for( const std::pair<mutation_category_id, std::vector<trait_id> > mut_cat : mutations_category ) {
for (const std::pair<const mutation_category_id, std::vector<trait_id> >& mut_cat :
mutations_category) {
mutation_categories_list.emplace_back( mut_cat.first.c_str(), mut_cat.first );
}
ssmenu.text = _( "Choose mutation category:" );
Expand Down Expand Up @@ -2324,8 +2325,8 @@ void mission_debug::edit_mission( mission &m )
static void draw_benchmark( const int max_difference )
{
// call the draw procedure as many times as possible in max_difference milliseconds
auto start_tick = std::chrono::steady_clock::now();
auto end_tick = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point start_tick = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point end_tick = std::chrono::steady_clock::now();
int64_t difference = 0;
int draw_counter = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ std::string effect::disp_desc( bool reduced ) const
std::string ret;

std::string timestr;
time_duration effect_dur_elapsed = ( calendar::turn - start_time );
time_duration effect_dur_elapsed = calendar::turn - start_time;
if( to_turns<int>( effect_dur_elapsed ) == 0 ) {
timestr = _( "just now" );
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,7 @@ std::pair<tripoint, tripoint> game::mouse_edge_scrolling( input_context &ctxt, c
( void ) speed;
( void ) iso;
#if (defined TILES || defined _WIN32 || defined WINDOWS)
auto now = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
if( now < last_mouse_edge_scroll + std::chrono::milliseconds( rate ) ) {
return ret;
} else {
Expand Down Expand Up @@ -6109,7 +6109,7 @@ void game::print_all_tile_info( const tripoint &lp, const catacurses::window &w_
}
const int max_width = getmaxx( w_look ) - column - 1;

auto this_sound = sounds::sound_at( lp );
std::string this_sound = sounds::sound_at(lp);
if( !this_sound.empty() ) {
const int lines = fold_and_print( w_look, point( 1, ++line ), max_width, c_light_gray,
_( "From here you heard %s" ),
Expand Down
4 changes: 2 additions & 2 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ class comestible_inventory_preset : public inventory_selector_preset

static std::string get_consume_needs_hint( Character &you )
{
auto hint = std::string();
std::string hint = std::string();
auto desc = display::hunger_text_color( you );
hint.append( string_format( "%s %s", _( "Food:" ), colorize( desc.first, desc.second ) ) );
hint.append( string_format( " %s ", LINE_XOXO_S ) );
Expand Down Expand Up @@ -1836,7 +1836,7 @@ class repair_inventory_preset: public inventory_selector_preset
static std::string get_repair_hint( const Character &you, const repair_item_actor *actor,
const item *main_tool )
{
auto hint = std::string();
std::string hint = std::string();
hint.append( string_format( _( "Tool: <color_cyan>%s</color>" ), main_tool->display_name() ) );
hint.append( string_format( " | " ) );
hint.append( string_format( _( "Skill used: <color_cyan>%s (%d)</color>" ),
Expand Down
2 changes: 1 addition & 1 deletion src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class user_turn
if (turn_duration <= 0.005) {
return 0;
}
auto now = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
std::chrono::milliseconds elapsed_ms =
std::chrono::duration_cast<std::chrono::milliseconds>(now - user_turn_start);
return elapsed_ms.count() / (10.0 * turn_duration);
Expand Down
15 changes: 9 additions & 6 deletions src/harvest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,23 @@ bool string_id<harvest_drop_type>::is_valid() const

translation harvest_drop_type::field_dress_msg( bool succeeded ) const
{
return SNIPPET.random_from_category( succeeded ? msg_fielddress_success :
msg_fielddress_fail ).value_or( translation() );
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
return SNIPPET.random_from_category(
succeeded ? msg_fielddress_success : msg_fielddress_fail).value_or(translation());
}

translation harvest_drop_type::butcher_msg( bool succeeded ) const
{
return SNIPPET.random_from_category( succeeded ? msg_butcher_success : msg_butcher_fail ).value_or(
translation() );
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
return SNIPPET.random_from_category(
succeeded ? msg_butcher_success : msg_butcher_fail).value_or(translation());
}

translation harvest_drop_type::dissect_msg( bool succeeded ) const
{
return SNIPPET.random_from_category( succeeded ? msg_dissect_success : msg_dissect_fail ).value_or(
translation() );
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
return SNIPPET.random_from_category(
succeeded ? msg_dissect_success : msg_dissect_fail).value_or(translation());
}

/** @relates string_id */
Expand Down
2 changes: 1 addition & 1 deletion src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4519,7 +4519,7 @@ cata::optional<tripoint> iexamine::getNearFilledGasTank( const tripoint &center,
map &here = get_map();
for( const tripoint &tmp : here.points_in_radius( center, SEEX * 2 ) ) {

auto check_for_fuel_tank = here.furn( tmp );
furn_id check_for_fuel_tank = here.furn(tmp);

if( ( fuel_type == FUEL_TYPE_GASOLINE && check_for_fuel_tank != furn_f_gas_tank ) ||
( fuel_type == FUEL_TYPE_DIESEL && check_for_fuel_tank != furn_f_diesel_tank ) ) {
Expand Down
9 changes: 6 additions & 3 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static const std::string flag_SILENT( "SILENT" );
// item pricing
static const int PRICE_FILTHY_MALUS = 100; // cents

constexpr units::volume armor_portion_data::volume_per_encumbrance;


class npc_class;

Expand Down Expand Up @@ -10483,13 +10483,16 @@ int item::get_chapters() const
}

int item::get_remaining_chapters( const Character &u ) const
{
{
// NOLINTNEXTLINE(cata-translate-string-literal)
const std::string var = string_format( "remaining-chapters-%d", u.getID().get_value() );
return get_var( var, get_chapters() );
}

void item::mark_chapter_as_read( const Character &u )
{
{

// NOLINTNEXTLINE(cata-translate-string-literal)
const std::string var = string_format( "remaining-chapters-%d", u.getID().get_value() );
if( type->book && type->book->chapters == 0 ) {
// books without chapters will always have remaining chapters == 0, so we don't need to store them
Expand Down
2 changes: 1 addition & 1 deletion src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4763,7 +4763,7 @@ void Item_factory::emplace_usage( std::map<std::string, use_function> &container

std::pair<std::string, use_function> Item_factory::usage_from_object( const JsonObject &obj )
{
auto type = obj.get_string( "type" );
std::string type = obj.get_string("type");

if( type == "repair_item" ) {
type = obj.get_string( "item_action_type" );
Expand Down
2 changes: 1 addition & 1 deletion src/item_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ void item_location::serialize( JsonOut &js ) const

void item_location::deserialize( const JsonObject &obj )
{
auto type = obj.get_string( "type" );
std::string type = obj.get_string("type");

int idx = -1;
tripoint pos = tripoint_min;
Expand Down
3 changes: 1 addition & 2 deletions src/item_pocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ std::string enum_to_string<item_pocket::pocket_type>( item_pocket::pocket_type d
// *INDENT-ON*
} // namespace io

constexpr units::volume pocket_data::max_volume_for_container;
constexpr units::mass pocket_data::max_weight_for_container;


std::string pocket_data::check_definition() const
{
Expand Down
6 changes: 3 additions & 3 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4728,7 +4728,7 @@ cata::optional<int> iuse::blood_draw( Character *p, item *it, bool, const tripoi
drew_blood = true;
blood_temp = map_it.temperature;

auto bloodtype( map_it.get_mtype()->bloodType() );
field_type_id bloodtype(map_it.get_mtype()->bloodType());
if( bloodtype.obj().has_acid ) {
acid_blood = true;
} else {
Expand Down Expand Up @@ -5979,7 +5979,7 @@ static bool einkpc_download_memory_card( Character &p, item &eink, item &mc )
something_downloaded = true;
p.add_msg_if_player( m_good, _( "You have updated your monster collection." ) );

auto photos = eink.get_var( "EINK_MONSTER_PHOTOS" );
std::string photos = eink.get_var("EINK_MONSTER_PHOTOS");
if( photos.empty() ) {
eink.set_var( "EINK_MONSTER_PHOTOS", monster_photos );
} else {
Expand Down Expand Up @@ -8649,7 +8649,7 @@ cata::optional<int> iuse::cable_attach( Character *p, item *it, bool, const trip
}
const tripoint posp = *posp_;
const optional_vpart_position vp = here.veh_at( posp );
auto ter = here.ter( posp );
ter_id ter = here.ter(posp);
if( !vp && ter != t_chainfence ) {
p->add_msg_if_player( _( "There's no vehicle there." ) );
return cata::nullopt;
Expand Down
2 changes: 1 addition & 1 deletion src/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void TextJsonObject::report_unvisited() const
{
#ifndef CATA_IN_TOOL
if( report_unvisited_members && !reported_unvisited_members &&
!std::uncaught_exception() ) {
!std::uncaught_exceptions()) {
reported_unvisited_members = true;
for( const std::pair<const std::string, int> &p : positions ) {
const std::string &name = p.first;
Expand Down
3 changes: 2 additions & 1 deletion src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ void enchant_cache::serialize( JsonOut &jsout ) const
jsout.start_object();
jsout.member( "effects" );
jsout.start_array();
for( const std::pair<time_duration, std::vector<fake_spell>> pair : intermittent_activation ) {
for (const std::pair<const time_duration, std::vector<fake_spell>>& pair :
intermittent_activation) {
jsout.start_object();
jsout.member( "frequency", to_string_writable( pair.first ) );
jsout.member( "spell_effects", pair.second );
Expand Down
2 changes: 1 addition & 1 deletion src/magic_teleporter_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void teleporter_list::serialize( JsonOut &json ) const

json.member( "known_teleporters" );
json.start_array();
for( std::pair<tripoint_abs_omt, std::string> pair : known_teleporters ) {
for (const std::pair<const tripoint_abs_omt, std::string>& pair : known_teleporters) {
json.start_object();
json.member( "position", pair.first );
json.member( "name", pair.second );
Expand Down
2 changes: 1 addition & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9377,7 +9377,7 @@ void map::scent_blockers( std::array<std::array<bool, MAPSIZE_X>, MAPSIZE_Y> &bl

// Now vehicles

auto vehs = get_vehicles();
VehicleList vehs = get_vehicles();
for( wrapped_vehicle &wrapped_veh : vehs ) {
vehicle &veh = *( wrapped_veh.v );
for( const vpart_reference &vp : veh.get_all_parts_with_fakes() ) {
Expand Down
4 changes: 2 additions & 2 deletions src/mapbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ void mapbuffer::save( bool delete_after_save )
std::set<tripoint_abs_omt> saved_submaps;
std::list<tripoint_abs_sm> submaps_to_delete;
static constexpr std::chrono::milliseconds update_interval( 500 );
auto last_update = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point last_update = std::chrono::steady_clock::now();

for( auto &elem : submaps ) {
auto now = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
if( last_update + update_interval < now ) {
popup.message( _( "Please wait as the map saves [%d/%d]" ),
num_saved_submaps, num_total_submaps );
Expand Down
2 changes: 1 addition & 1 deletion src/medical_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ static medical_column draw_stats_summary( const int column_count, avatar *player
}

for( const std::pair<const std::string, int> &speed_effect : speed_effects ) {
nc_color col = ( speed_effect.second > 0 ? c_green : c_red );
nc_color col = speed_effect.second > 0 ? c_green : c_red;
speed_detail_str += colorize( string_format( _( "%s %s%d%%\n" ), speed_effect.first,
( speed_effect.second > 0 ? "+" : "-" ),
std::abs( speed_effect.second ) ), col );
Expand Down
2 changes: 1 addition & 1 deletion src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ bool Character::handle_melee_wear( item_location shield, float wear_multiplier )
return false;
}

auto str = shield->tname(); // save name before we apply damage
std::string str = shield->tname(); // save name before we apply damage

if( !shield->inc_damage() ) {
add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the force of the blow!" ),
Expand Down
2 changes: 1 addition & 1 deletion src/mission_companion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ bool talk_function::display_and_choose_opts(
size_t list_line = 2;
for( size_t current = name_index; list_line < info_height + 2 &&
current < cur_key_list.size(); current++ ) {
nc_color col = ( current == sel ? h_white : c_white );
nc_color col = current == sel ? h_white : c_white;
//highlight important missions
for( const mission_entry &k : mission_key.entries[0] ) {
if( is_equal( cur_key_list[current].id, k.id ) ) {
Expand Down
1 change: 1 addition & 0 deletions src/mod_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ bool mod_manager::copy_mod_contents( const t_mod_list &mods_to_copy,
}

// create needed directories
// NOLINTNEXTLINE(cata-translate-string-literal)
const cata_path cur_mod_dir = output_base_path / string_format( "mod_%05d", i + 1 );

std::queue<cata_path> dir_to_make;
Expand Down
2 changes: 1 addition & 1 deletion src/mod_manager_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ std::string mod_ui::get_information( const MOD_INFORMATION *mod )

if( !mod->dependencies.empty() ) {
const auto &deps = mod->dependencies;
auto str = enumerate_as_string( deps.begin(), deps.end(), [&]( const mod_id & e ) {
std::string str = enumerate_as_string(deps.begin(), deps.end(), [&](const mod_id& e) {
if( e.is_valid() ) {
return string_format( "[%s]", e->name() );
} else {
Expand Down
Loading

0 comments on commit ea9cf88

Please sign in to comment.