Skip to content

Commit

Permalink
fix(UI): displayed disassemble time (#5953)
Browse files Browse the repository at this point in the history
* implementation

* count multiplication
  • Loading branch information
Goredell authored Jan 20, 2025
1 parent b231e95 commit 4121e37
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8524,18 +8524,33 @@ void game::butcher()
kmenu.addentry( MULTIBUTCHER, true, 'b', _( "Butcher everything" ) );
}
if( disassembles.size() > 1 ) {
int time_to_disassemble = 0;
int time_to_disassemble_all = 0;
int time_to_disassemble_rec = 0;
std::vector<std::pair<itype_id, int>> disassembly_stacks_res;

for( const auto &stack : disassembly_stacks ) {
const int time = recipe_dictionary::get_uncraft( stack.first->typeId() ).time;
time_to_disassemble += time;
time_to_disassemble_all += time * stack.second;
disassembly_stacks_res.emplace_back( stack.first->typeId(), stack.second );
}

for( int i = 0; i < disassembly_stacks_res.size(); i++ ) {

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / GCC 12, Ubuntu, Tiles, Sound, Lua, CMake, Languages

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<string_id<itype>, int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / GCC 12, Ubuntu, Tiles, Sound, Lua

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<string_id<itype>, int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / GCC 12, Ubuntu, Curses

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<string_id<itype>, int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / osx-curses-x64

comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / linux-curses-x64

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<string_id<itype>, int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / Linux Tiles x64

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<string_id<itype>, int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / osx-curses-arm

comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / Windows Tiles x32

comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<string_id<itype>, int> >::size_type' {aka 'unsigned int'} [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / Windows Tiles x64

comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<string_id<itype>, int> >::size_type' {aka 'long long unsigned int'} [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / osx-tiles-arm

comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]

Check warning on line 8537 in src/game.cpp

View workflow job for this annotation

GitHub Actions / osx-tiles-x64

comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
const auto dis = recipe_dictionary::get_uncraft( disassembly_stacks_res[i].first );
time_to_disassemble_rec += dis.time * disassembly_stacks_res[i].second;
//uses default craft materials to estimate recursive disassembly time
const auto components = dis.disassembly_requirements().get_components();
for( const auto &subcomps : components ) {
if( subcomps.size() > 0 ) {
disassembly_stacks_res.emplace_back( subcomps.front().type,
subcomps.front().count * disassembly_stacks_res[i].second );
}
}
}

kmenu.addentry_col( MULTIDISASSEMBLE_ONE, true, 'D', _( "Disassemble everything once" ),
to_string_clipped( time_duration::from_turns( time_to_disassemble / 100 ) ) );
kmenu.addentry_col( MULTIDISASSEMBLE_ALL, true, 'd', _( "Disassemble everything recursively" ),
kmenu.addentry_col( MULTIDISASSEMBLE_ONE, true, 'D', _( "Disassemble everything" ),
to_string_clipped( time_duration::from_turns( time_to_disassemble_all / 100 ) ) );
kmenu.addentry_col( MULTIDISASSEMBLE_ALL, true, 'd', _( "Disassemble everything recursively" ),
to_string_clipped( time_duration::from_turns( time_to_disassemble_rec / 100 ) ) );
}
if( salvage_iuse && salvageables.size() > 1 ) {
int time_to_salvage = 0;
Expand Down

0 comments on commit 4121e37

Please sign in to comment.