Skip to content

Commit

Permalink
Merge pull request #75141 from PatrikLundell/armor
Browse files Browse the repository at this point in the history
fix armor wear crash
  • Loading branch information
Maleclypse authored Jul 22, 2024
2 parents 9e39260 + 153fa1e commit 54ec149
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/armor_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ void outfit::sort_armor( Character &guy )
// wear the item
std::optional<std::list<item>::iterator> new_equip_it =
guy.wear( obtained );
if( new_equip_it ) {
if( new_equip_it && !tmp_worn.empty() ) {
// save iterator to cursor's position
std::list<item>::iterator cursor_it = tmp_worn[leftListIndex];
item &item_to_check = *cursor_it;
Expand All @@ -1116,7 +1116,7 @@ void outfit::sort_armor( Character &guy )
// reorder `worn` vector to place new item at cursor
worn.splice( cursor_it, worn, *new_equip_it );
}
} else if( guy.is_npc() ) {
} else if( guy.is_npc() && !tmp_worn.empty() ) {
// TODO: Pass the reason here
popup( _( "Can't put this on!" ) );
}
Expand Down

0 comments on commit 54ec149

Please sign in to comment.