Skip to content

Commit

Permalink
A couple small C++20 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
moxian committed Jan 12, 2025
1 parent dbf4dca commit c723d11
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ moon_phase get_moon_phase( const time_point &p )
const int num_middays = to_days<int>( p - calendar::turn_zero + 1_days / 2 );
const time_duration nearest_midnight = num_middays * 1_days;
const double phase_change = nearest_midnight / moon_phase_duration;
const int current_phase = static_cast<int>( std::round( phase_change * MOON_PHASE_MAX ) ) %
const int current_phase = static_cast<int>( std::round( phase_change * static_cast<int>
( MOON_PHASE_MAX ) ) ) %
static_cast<int>( MOON_PHASE_MAX );
return static_cast<moon_phase>( current_phase );
}
Expand Down
1 change: 1 addition & 0 deletions src/cata_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define CATA_SRC_CATA_PATH_H

#include <iosfwd>
#include <string>

#include <ghc/fs_std_fwd.hpp>

Expand Down
2 changes: 1 addition & 1 deletion src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3951,7 +3951,7 @@ void mm_submap::serialize( JsonOut &jsout ) const
const auto write_seq = [&]() {
jsout.start_array();
jsout.write( num_same );
jsout.write( last.symbol );
jsout.write( static_cast<int>( last.symbol ) );
jsout.write( last.ter_id );
jsout.write( static_cast<int>( last.ter_subtile ) );
jsout.write( static_cast<int>( last.ter_rotation ) );
Expand Down
10 changes: 6 additions & 4 deletions src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7881,17 +7881,19 @@ time_duration vehicle::folding_time() const
{
const vehicle_part_range vpr = get_all_parts();
return std::accumulate( vpr.begin(), vpr.end(), time_duration(),
[]( time_duration & acc, const vpart_reference & part ) {
return acc + ( part.part().removed ? time_duration() : part.info().get_folding_time() );
[]( time_duration acc, const vpart_reference & part ) {
return acc + ( part.part().removed ? time_duration() :
part.info().get_folding_time() );
} );
}

time_duration vehicle::unfolding_time() const
{
const vehicle_part_range vpr = get_all_parts();
return std::accumulate( vpr.begin(), vpr.end(), time_duration(),
[]( time_duration & acc, const vpart_reference & part ) {
return acc + ( part.part().removed ? time_duration() : part.info().get_unfolding_time() );
[]( time_duration acc, const vpart_reference & part ) {
return acc + ( part.part().removed ? time_duration() :
part.info().get_unfolding_time() );
} );
}

Expand Down

0 comments on commit c723d11

Please sign in to comment.