Skip to content

Fixed an assertion failure that sometimes happened when giving the player a medal in debug builds.

Adam Kaminski requested to merge topic/default/medal-assert-fix into branch/default

In MEDAL_GiveMedal, the line queue.push_back( medal ); invalidates any iterators that were connected to the vector (i.e. auto iterator = std::find( queue.begin( ), queue.end( ), medal );, but the invalid iterator can still be used later in the code: if ( iterator == queue.begin( )).

It's best to ensure that the iterator is never invalid by always setting it to the last element in the vector via iterator = queue.end( ) - 1;, when inserting a new medal into the queue.

Merge request reports