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;
|
std::vector<EngineID> variants;
|
||||||
EngineID sel_id = INVALID_ENGINE;
|
EngineID sel_id = INVALID_ENGINE;
|
||||||
int num_engines = 0;
|
size_t num_engines = 0;
|
||||||
int num_wagons = 0;
|
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|
||||||
@ -1356,12 +1355,7 @@ struct BuildVehicleWindow : Window {
|
|||||||
|
|
||||||
list.emplace_back(eid, e->info.variant_id, e->display_flags, 0);
|
list.emplace_back(eid, e->info.variant_id, e->display_flags, 0);
|
||||||
|
|
||||||
if (rvi->railveh_type != RAILVEH_WAGON) {
|
if (rvi->railveh_type != RAILVEH_WAGON) num_engines++;
|
||||||
num_engines++;
|
|
||||||
} else {
|
|
||||||
num_wagons++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e->info.variant_id != eid && e->info.variant_id != INVALID_ENGINE) variants.push_back(e->info.variant_id);
|
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;
|
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()) {
|
if (std::find(list.begin(), list.end(), variant) == list.end()) {
|
||||||
const Engine *e = Engine::Get(variant);
|
const Engine *e = Engine::Get(variant);
|
||||||
list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlags::Shaded, 0);
|
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);
|
EngList_SortPartial(&list, _engine_sort_functions[0][this->sort_criteria], 0, num_engines);
|
||||||
|
|
||||||
/* and finally sort wagons */
|
/* 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 */
|
/* 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 begin start of sorting
|
||||||
* @param num_items count of items to be sorted
|
* @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;
|
if (num_items < 2) return;
|
||||||
assert(begin < el->size());
|
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.
|
typedef bool EngList_SortTypeFunction(const GUIEngineListItem&, const GUIEngineListItem&); ///< argument type for #EngList_Sort.
|
||||||
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare);
|
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 GetEngineCategoryName(EngineID engine);
|
||||||
StringID GetEngineInfoString(EngineID engine);
|
StringID GetEngineInfoString(EngineID engine);
|
||||||
|
Loading…
Reference in New Issue
Block a user