mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
This commit is contained in:
parent
7d502e2857
commit
8aeef665c7
@ -1334,8 +1334,7 @@ struct BuildVehicleWindow : Window {
|
||||
{
|
||||
std::vector<EngineID> variants;
|
||||
EngineID sel_id = INVALID_ENGINE;
|
||||
int num_engines = 0;
|
||||
int num_wagons = 0;
|
||||
size_t num_engines = 0;
|
||||
|
||||
list.clear();
|
||||
|
||||
@ -1356,12 +1355,7 @@ struct BuildVehicleWindow : Window {
|
||||
|
||||
list.emplace_back(eid, e->info.variant_id, e->display_flags, 0);
|
||||
|
||||
if (rvi->railveh_type != RAILVEH_WAGON) {
|
||||
num_engines++;
|
||||
} else {
|
||||
num_wagons++;
|
||||
}
|
||||
|
||||
if (rvi->railveh_type != RAILVEH_WAGON) num_engines++;
|
||||
if (e->info.variant_id != eid && e->info.variant_id != INVALID_ENGINE) variants.push_back(e->info.variant_id);
|
||||
if (eid == this->sel_engine) sel_id = eid;
|
||||
}
|
||||
@ -1371,6 +1365,7 @@ struct BuildVehicleWindow : Window {
|
||||
if (std::find(list.begin(), list.end(), variant) == list.end()) {
|
||||
const Engine *e = Engine::Get(variant);
|
||||
list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlags::Shaded, 0);
|
||||
if (e->u.rail.railveh_type != RAILVEH_WAGON) num_engines++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1388,7 +1383,7 @@ struct BuildVehicleWindow : Window {
|
||||
EngList_SortPartial(&list, _engine_sort_functions[0][this->sort_criteria], 0, num_engines);
|
||||
|
||||
/* and finally sort wagons */
|
||||
EngList_SortPartial(&list, _engine_sort_functions[0][this->sort_criteria], num_engines, num_wagons);
|
||||
EngList_SortPartial(&list, _engine_sort_functions[0][this->sort_criteria], num_engines, list.size() - num_engines);
|
||||
}
|
||||
|
||||
/* Figure out what road vehicle EngineIDs to put in the list */
|
||||
|
@ -337,7 +337,7 @@ void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
|
||||
* @param begin start of sorting
|
||||
* @param num_items count of items to be sorted
|
||||
*/
|
||||
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
|
||||
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, size_t begin, size_t num_items)
|
||||
{
|
||||
if (num_items < 2) return;
|
||||
assert(begin < el->size());
|
||||
|
@ -32,7 +32,7 @@ typedef GUIList<GUIEngineListItem, CargoID> GUIEngineList;
|
||||
|
||||
typedef bool EngList_SortTypeFunction(const GUIEngineListItem&, const GUIEngineListItem&); ///< argument type for #EngList_Sort.
|
||||
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare);
|
||||
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items);
|
||||
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, size_t begin, size_t num_items);
|
||||
|
||||
StringID GetEngineCategoryName(EngineID engine);
|
||||
StringID GetEngineInfoString(EngineID engine);
|
||||
|
Loading…
Reference in New Issue
Block a user