Skip to content

Commit

Permalink
FIX: Player ranking had wrong sort for oprational profit
Browse files Browse the repository at this point in the history
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11300 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed Jun 15, 2024
1 parent 6edbc56 commit 2f2bb83
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/simutrans/gui/player_ranking_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ static int compare_atv(uint8 player_nr_a, uint8 player_nr_b, uint8 atv_index)
comp = b_player->get_finance()->get_history_veh_year((transport_type)player_ranking_frame_t::transport_type_option, years_back - 1, atv_index) - a_player->get_finance()->get_history_veh_year((transport_type)player_ranking_frame_t::transport_type_option, years_back - 1, atv_index);
}
}
// if at least one if defined, it must go the the head of the list
else if(a_player) {
return true;
}
else if (b_player) {
return false;
}
if (comp == 0) {
comp = player_nr_b - player_nr_a;
}
Expand All @@ -111,6 +118,13 @@ static int compare_atc(uint8 player_nr_a, uint8 player_nr_b, uint8 atc_index)
comp = b_player->get_finance()->get_history_com_year(years_back - 1, atc_index) - a_player->get_finance()->get_history_com_year(years_back - 1, atc_index);
}
}
// if at least one if defined, it must go the the head of the list
else if (a_player) {
return true;
}
else if (b_player) {
return false;
}
if (comp == 0) {
comp = player_nr_b - player_nr_a;
}
Expand All @@ -121,7 +135,7 @@ static int compare_revenue(player_button_t* const& a, player_button_t* const& b)
return compare_atv(a->get_player_nr(), b->get_player_nr(), ATV_REVENUE);
}
static int compare_profit(player_button_t* const& a, player_button_t* const& b) {
return compare_atv(a->get_player_nr(), b->get_player_nr(), ATV_PROFIT);
return compare_atv(a->get_player_nr(), b->get_player_nr(), ATV_OPERATING_PROFIT);
}
static int compare_transport_pax(player_button_t* const& a, player_button_t* const& b) {
return compare_atv(a->get_player_nr(), b->get_player_nr(), ATV_TRANSPORTED_PASSENGER);
Expand Down Expand Up @@ -452,6 +466,9 @@ bool player_ranking_frame_t::action_triggered(gui_action_creator_t* comp, value_
transport_type_option = transport_types[v.i];
update_chart();
}
else {
transport_type_option = TT_ALL;
}
return true;
}

Expand Down

0 comments on commit 2f2bb83

Please sign in to comment.