Skip to content

Commit da2ca5b

Browse files
mqrausemqrause
andauthored
fix weighted_int_list iteration (#82859)
Co-authored-by: mqrause <[email protected]>
1 parent 9b0efb8 commit da2ca5b

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/character.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8402,15 +8402,14 @@ void Character::apply_random_wound( bodypart_id bp, const damage_instance &d )
84028402
}
84038403

84048404
weighted_int_list<wound_type_id> possible_wounds;
8405-
for( const weighted_object<int, bp_wounds> &wd : bp->potential_wounds ) {
8405+
for( const std::pair<bp_wounds, int> &wd : bp->potential_wounds ) {
84068406
for( const damage_unit &du : d.damage_units ) {
8407-
const bool damage_within_limits =
8408-
du.amount >= wd.obj.damage_required.first &&
8409-
du.amount <= wd.obj.damage_required.second;
8410-
const bool damage_type_matches = std::find( wd.obj.damage_type.begin(), wd.obj.damage_type.end(),
8411-
du.type ) != wd.obj.damage_type.end();
8407+
const bool damage_within_limits = du.amount >= wd.first.damage_required.first &&
8408+
du.amount <= wd.first.damage_required.second;
8409+
const bool damage_type_matches = std::find( wd.first.damage_type.begin(),
8410+
wd.first.damage_type.end(), du.type ) != wd.first.damage_type.end();
84128411
if( damage_within_limits && damage_type_matches ) {
8413-
possible_wounds.add( wd.obj.id, wd.weight );
8412+
possible_wounds.add( wd.first.id, wd.second );
84148413
}
84158414
}
84168415
}

src/medical_ui.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,19 +520,19 @@ static medical_column draw_health_summary( const int column_count, Character &yo
520520

521521
if( debug_mode ) {
522522
detail_str += "All potential wounds:\n";
523-
for( const weighted_object<int, bp_wounds> &wd : bp->get_id()->potential_wounds ) {
523+
for( const std::pair<bp_wounds, int> &wd : bp->get_id()->potential_wounds ) {
524524
std::string damage_types;
525525

526-
for( const damage_type_id dt : wd.obj.damage_type ) {
526+
for( const damage_type_id dt : wd.first.damage_type ) {
527527
damage_types += dt.c_str();
528528
damage_types += ", ";
529529
}
530530
damage_types.pop_back();
531531
damage_types.pop_back();
532532
detail_str +=
533533
string_format( "%s:\nweight: %s\ndamage types required: %s\ndamage required: [ %s - %s ]\n",
534-
colorize( wd.obj.id.c_str(), c_yellow ), wd.weight, damage_types, wd.obj.damage_required.first,
535-
wd.obj.damage_required.second );
534+
colorize( wd.first.id.c_str(), c_yellow ), wd.second, damage_types, wd.first.damage_required.first,
535+
wd.first.damage_required.second );
536536
}
537537
}
538538

0 commit comments

Comments
 (0)