Fixed memory management for achievements (#4381)

Fixes #4380
This commit is contained in:
Lemongrass3110
2019-10-02 09:17:53 +02:00
committed by GitHub
parent f290bc97be
commit 0e793e0c12

View File

@@ -891,9 +891,28 @@ static bool achievement_update_objectives(struct map_session_data *sd, std::shar
break;
}
if (isNew) {
if (!(entry = achievement_add(sd, ad->achievement_id)))
return false; // Failed to add achievement
if( isNew ){
// Always add the achievement if it was completed
bool hasCounter = complete;
// If it was not completed
if( !hasCounter ){
// Check if it has a counter
for( int counter : current_count ){
if( counter != 0 ){
hasCounter = true;
break;
}
}
}
if( hasCounter ){
if( !( entry = achievement_add( sd, ad->achievement_id ) ) ){
return false; // Failed to add achievement
}
}else{
changed = false;
}
}
if (changed) {