Skip to content

Commit

Permalink
Prevent Commander list scrambling on save-load
Browse files Browse the repository at this point in the history
Prevents the list of commanders in the command tab from being jumbled up when loading a save by sorting the list by droid ID.
  • Loading branch information
DARwins1 authored and KJeff01 committed Oct 18, 2023
1 parent b8e9ee3 commit 9423ce1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/hci/commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ void CommanderController::updateCommandersList()
}
}

std::reverse(commanders.begin(), commanders.end());
// Sort the list of commanders from lowest to highest id (using a lambda function defined within the sort call)
std::sort(commanders.begin(), commanders.end(), [](DROID *droid1, DROID *droid2) {
return droid1->id < droid2->id;
});
}

STRUCTURE_STATS *CommanderController::getObjectStatsAt(size_t objectIndex) const
Expand Down

0 comments on commit 9423ce1

Please sign in to comment.