Index: src/build_vehicle_gui.cpp =================================================================== --- src/build_vehicle_gui.cpp (revision 27762) +++ src/build_vehicle_gui.cpp (working copy) @@ -416,6 +416,26 @@ return _engine_sort_direction ? -r : r; } +/** + * Determines order of aircraft by type. + * @param *a first engine to compare. + * @param *b second engine to compare. + * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal. + */ +static int CDECL AircraftTypeSorter(const EngineID *a, const EngineID *b) +{ + const Engine *e_a = Engine::Get(*a); + const Engine *e_b = Engine::Get(*b); + + int va = e_a->u.air.subtype; + int vb = e_b->u.air.subtype; + int r = va - vb; + + /* Use EngineID to sort instead since we want consistent sorting */ + if (r == 0) return EngineNumberSorter(a, b); + return _engine_sort_direction ? -r : r; +} + /** Sort functions for the vehicle sort criteria, for each vehicle type. */ EngList_SortTypeFunction * const _engine_sort_functions[][11] = {{ /* Trains */ @@ -464,6 +484,7 @@ &EngineReliabilitySorter, &AircraftEngineCargoSorter, &AircraftRangeSorter, + &AircraftTypeSorter, }}; /** Dropdown menu strings for the vehicle sort criteria. */ @@ -517,6 +538,7 @@ STR_SORT_BY_RELIABILITY, STR_SORT_BY_CARGO_CAPACITY, STR_SORT_BY_RANGE, + STR_SORT_BY_AIRCRAFT_TYPE, INVALID_STRING_ID }}; @@ -762,6 +784,11 @@ y += FONT_HEIGHT_NORMAL; } + /* Aircraft type */ + SetDParam(0, e->GetDisplayAircraftType()); + DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_TYPE); + y += FONT_HEIGHT_NORMAL; + return y; } Index: src/engine.cpp =================================================================== --- src/engine.cpp (revision 27762) +++ src/engine.cpp (working copy) @@ -464,6 +464,25 @@ } /** + * Get the aircraft type for display purposes. + * @return Aircraft type as a StringID. + */ +StringID Engine::GetDisplayAircraftType() const +{ + switch (this->type) { + case VEH_AIRCRAFT: + switch (this->u.air.subtype) { + case AIR_HELI: return STR_LIVERY_HELICOPTER; + case AIR_CTOL: return STR_LIVERY_SMALL_PLANE; + case AIR_CTOL | AIR_FAST: return STR_LIVERY_LARGE_PLANE; + default: NOT_REACHED(); + } + + default: NOT_REACHED(); + } +} + +/** * Initializes the EngineOverrideManager with the default engines. */ void EngineOverrideManager::ResetToDefaultMapping() Index: src/engine_base.h =================================================================== --- src/engine_base.h (revision 27762) +++ src/engine_base.h (working copy) @@ -111,6 +111,7 @@ uint GetDisplayMaxTractiveEffort() const; Date GetLifeLengthInDays() const; uint16 GetRange() const; + StringID GetDisplayAircraftType() const; /** * Check whether the engine is hidden in the GUI for the given company. Index: src/lang/english.txt =================================================================== --- src/lang/english.txt (revision 27762) +++ src/lang/english.txt (working copy) @@ -309,6 +309,7 @@ STR_SORT_BY_POWER_VS_RUNNING_COST :Power/Running cost STR_SORT_BY_CARGO_CAPACITY :Cargo capacity STR_SORT_BY_RANGE :Range +STR_SORT_BY_AIRCRAFT_TYPE :Aircraft Type STR_SORT_BY_POPULATION :Population STR_SORT_BY_RATING :Rating @@ -3398,6 +3399,7 @@ STR_PURCHASE_INFO_ALL_BUT :All but {CARGO_LIST} STR_PURCHASE_INFO_MAX_TE :{BLACK}Max. Tractive Effort: {GOLD}{FORCE} STR_PURCHASE_INFO_AIRCRAFT_RANGE :{BLACK}Range: {GOLD}{COMMA} tiles +STR_PURCHASE_INFO_AIRCRAFT_TYPE :{BLACK}Aircraft Type: {GOLD}{STRING} STR_BUY_VEHICLE_TRAIN_LIST_TOOLTIP :{BLACK}Train vehicle selection list. Click on vehicle for information. Ctrl+Click for toggling hiding of the vehicle type STR_BUY_VEHICLE_ROAD_VEHICLE_LIST_TOOLTIP :{BLACK}Road vehicle selection list. Click on vehicle for information. Ctrl+Click for toggling hiding of the vehicle type