A little cleanup.
This commit is contained in:
parent
97f656b730
commit
37d69a8bbb
4 changed files with 10 additions and 8 deletions
|
@ -1952,7 +1952,7 @@ void turn_info::recall()
|
|||
|
||||
//sort the available units into order by value
|
||||
//so that the most valuable units are shown first
|
||||
std::sort(recall_list.begin(),recall_list.end(),compare_unit_values());
|
||||
sort_units(recall_list);
|
||||
|
||||
gui_.draw(); //clear the old menu
|
||||
|
||||
|
|
|
@ -716,7 +716,7 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
|
|||
if (!game_config::ignore_replay_errors) throw replay::error();
|
||||
}
|
||||
|
||||
std::sort(player->available_units.begin(),player->available_units.end(),compare_unit_values());
|
||||
sort_units(player->available_units);
|
||||
|
||||
const std::string& recall_num = (*child)["value"];
|
||||
const int val = atoi(recall_num.c_str());
|
||||
|
@ -742,7 +742,7 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
|
|||
if (!game_config::ignore_replay_errors) throw replay::error();
|
||||
}
|
||||
|
||||
std::sort(player->available_units.begin(),player->available_units.end(),compare_unit_values());
|
||||
sort_units(player->available_units);
|
||||
const std::string& unit_num = (*child)["value"];
|
||||
const int val = atoi(unit_num.c_str());
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace {
|
|||
sizeof(*ModificationTypes);
|
||||
}
|
||||
|
||||
bool compare_unit_values::operator()(const unit& a, const unit& b) const
|
||||
static bool compare_unit_values(unit const &a, unit const &b)
|
||||
{
|
||||
const int lvla = a.type().level();
|
||||
const int lvlb = b.type().level();
|
||||
|
@ -58,6 +58,11 @@ bool compare_unit_values::operator()(const unit& a, const unit& b) const
|
|||
lvla == lvlb && namea == nameb && xpa < xpb;
|
||||
}
|
||||
|
||||
void sort_units(std::vector< unit > &units)
|
||||
{
|
||||
std::sort(units.begin(), units.end(), compare_unit_values);
|
||||
}
|
||||
|
||||
//constructor for reading a unit
|
||||
unit::unit(const game_data& data, const config& cfg) :
|
||||
state_(STATE_NORMAL),
|
||||
|
|
|
@ -255,10 +255,7 @@ private:
|
|||
int moves_;
|
||||
};
|
||||
|
||||
struct compare_unit_values
|
||||
{
|
||||
bool operator()(const unit& a, const unit& b) const;
|
||||
};
|
||||
void sort_units(std::vector< unit > &);
|
||||
|
||||
int team_units(const unit_map& units, int team_num);
|
||||
int team_upkeep(const unit_map& units, int team_num);
|
||||
|
|
Loading…
Add table
Reference in a new issue