Merge branch 'master' into jgrpp-nrt
Merge NRT feature # Conflicts: # docs/landscape.html # docs/landscape_grid.html # src/bridge_map.h # src/build_vehicle_gui.cpp # src/company_base.h # src/company_cmd.cpp # src/misc_gui.cpp # src/newgrf.cpp # src/newgrf_engine.cpp # src/pathfinder/follow_track.hpp # src/pathfinder/npf/npf.cpp # src/road_cmd.cpp # src/road_func.h # src/road_gui.cpp # src/road_map.h # src/road_type.h # src/roadveh_cmd.cpp # src/saveload/afterload.cpp # src/saveload/company_sl.cpp # src/script/api/script_bridge.cpp # src/table/newgrf_debug_data.h # src/tile_cmd.h # src/town_cmd.cpp # src/tunnel_map.h # src/tunnelbridge_cmd.cpp
This commit is contained in:
@@ -1015,8 +1015,8 @@ void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selecte
|
||||
struct BuildVehicleWindow : Window {
|
||||
VehicleType vehicle_type; ///< Type of vehicles shown in the window.
|
||||
union {
|
||||
RailType railtype; ///< Rail type to show, or #RAILTYPE_END.
|
||||
RoadTypes roadtypes; ///< Road type to show, or #ROADTYPES_ALL.
|
||||
RailType railtype; ///< Rail type to show, or #INVALID_RAILTYPE.
|
||||
RoadType roadtype; ///< Road type to show, or #INVALID_ROADTYPE.
|
||||
} filter; ///< Filter to apply.
|
||||
bool descending_sort_order; ///< Sort direction, @see _engine_sort_direction
|
||||
byte sort_criteria; ///< Current sort criterium.
|
||||
@@ -1062,6 +1062,7 @@ struct BuildVehicleWindow : Window {
|
||||
this->virtual_train_out = virtual_train_out;
|
||||
this->virtual_train_mode = (virtual_train_out != nullptr);
|
||||
if (this->virtual_train_mode) this->window_number = 0;
|
||||
this->listview_mode = (tile == INVALID_TILE) && !virtual_train_mode;
|
||||
|
||||
this->sel_engine = INVALID_ENGINE;
|
||||
|
||||
@@ -1069,19 +1070,7 @@ struct BuildVehicleWindow : Window {
|
||||
this->descending_sort_order = _engine_sort_last_order[type];
|
||||
this->show_hidden_engines = _engine_sort_show_hidden_engines[type];
|
||||
|
||||
switch (type) {
|
||||
default: NOT_REACHED();
|
||||
case VEH_TRAIN:
|
||||
this->filter.railtype = (tile == INVALID_TILE) ? RAILTYPE_END : GetRailType(tile);
|
||||
break;
|
||||
case VEH_ROAD:
|
||||
this->filter.roadtypes = (tile == INVALID_TILE) ? ROADTYPES_ALL : GetRoadTypes(tile);
|
||||
case VEH_SHIP:
|
||||
case VEH_AIRCRAFT:
|
||||
break;
|
||||
}
|
||||
|
||||
this->listview_mode = !(this->virtual_train_mode) && (this->window_number <= VEH_END);
|
||||
this->UpdateFilterByTile();
|
||||
|
||||
this->CreateNestedTree();
|
||||
|
||||
@@ -1127,6 +1116,36 @@ struct BuildVehicleWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the filter type according to the depot type */
|
||||
void UpdateFilterByTile()
|
||||
{
|
||||
switch (this->vehicle_type) {
|
||||
default: NOT_REACHED();
|
||||
case VEH_TRAIN:
|
||||
if (this->listview_mode || this->virtual_train_mode) {
|
||||
this->filter.railtype = INVALID_RAILTYPE;
|
||||
} else {
|
||||
this->filter.railtype = GetRailType(this->window_number);
|
||||
}
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
if (this->listview_mode || this->virtual_train_mode) {
|
||||
this->filter.roadtype = INVALID_ROADTYPE;
|
||||
} else {
|
||||
this->filter.roadtype = GetRoadTypeRoad(this->window_number);
|
||||
if (this->filter.roadtype == INVALID_ROADTYPE) {
|
||||
this->filter.roadtype = GetRoadTypeTram(this->window_number);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VEH_SHIP:
|
||||
case VEH_AIRCRAFT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Populate the filter list and set the cargo filter criteria. */
|
||||
void SetCargoFilterArray()
|
||||
{
|
||||
@@ -1236,8 +1255,6 @@ struct BuildVehicleWindow : Window {
|
||||
int num_engines = 0;
|
||||
int num_wagons = 0;
|
||||
|
||||
this->filter.railtype = (this->listview_mode || this->virtual_train_mode) ? RAILTYPE_END : GetRailType(this->window_number);
|
||||
|
||||
this->eng_list.clear();
|
||||
|
||||
/* Make list of all available train engines and wagons.
|
||||
@@ -1250,7 +1267,7 @@ struct BuildVehicleWindow : Window {
|
||||
EngineID eid = e->index;
|
||||
const RailVehicleInfo *rvi = &e->u.rail;
|
||||
|
||||
if (this->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, this->filter.railtype)) continue;
|
||||
if (this->filter.railtype != INVALID_RAILTYPE && !HasPowerOnRail(rvi->railtype, this->filter.railtype)) continue;
|
||||
if (!IsEngineBuildable(eid, VEH_TRAIN, _local_company)) continue;
|
||||
|
||||
/* Filter now! So num_engines and num_wagons is valid */
|
||||
@@ -1293,7 +1310,8 @@ struct BuildVehicleWindow : Window {
|
||||
if (!this->show_hidden_engines && e->IsHidden(_local_company)) continue;
|
||||
EngineID eid = e->index;
|
||||
if (!IsEngineBuildable(eid, VEH_ROAD, _local_company)) continue;
|
||||
if (!HasBit(this->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
|
||||
if (this->filter.roadtype != INVALID_ROADTYPE && !HasPowerOnRoad(e->u.road.roadtype, this->filter.roadtype)) continue;
|
||||
|
||||
this->eng_list.push_back(eid);
|
||||
|
||||
if (eid == this->sel_engine) sel_id = eid;
|
||||
@@ -1351,6 +1369,10 @@ struct BuildVehicleWindow : Window {
|
||||
void GenerateBuildList()
|
||||
{
|
||||
if (!this->eng_list.NeedRebuild()) return;
|
||||
|
||||
/* Update filter type in case the road/railtype of the depot got converted */
|
||||
this->UpdateFilterByTile();
|
||||
|
||||
switch (this->vehicle_type) {
|
||||
default: NOT_REACHED();
|
||||
case VEH_TRAIN:
|
||||
@@ -1482,6 +1504,9 @@ struct BuildVehicleWindow : Window {
|
||||
if (this->vehicle_type == VEH_TRAIN && !this->listview_mode && !this->virtual_train_mode) {
|
||||
const RailtypeInfo *rti = GetRailTypeInfo(this->filter.railtype);
|
||||
SetDParam(0, rti->strings.build_caption);
|
||||
} else if (this->vehicle_type == VEH_ROAD && !this->listview_mode) {
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(this->filter.roadtype);
|
||||
SetDParam(0, rti->strings.build_caption);
|
||||
} else {
|
||||
SetDParam(0, (this->listview_mode ? STR_VEHICLE_LIST_AVAILABLE_TRAINS : STR_BUY_VEHICLE_TRAIN_ALL_CAPTION) + this->vehicle_type);
|
||||
}
|
||||
|
Reference in New Issue
Block a user