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:
@@ -2457,7 +2457,7 @@ UnitID GetFreeUnitNumber(VehicleType type)
|
||||
* @return true if there is any reason why you may build
|
||||
* the infrastructure for the given vehicle type
|
||||
*/
|
||||
bool CanBuildVehicleInfrastructure(VehicleType type)
|
||||
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
|
||||
{
|
||||
assert(IsCompanyBuildableVehicleType(type));
|
||||
|
||||
@@ -2470,7 +2470,10 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
|
||||
if (!HasAnyRailtypesAvail(_local_company)) return false;
|
||||
max = _settings_game.vehicle.max_trains;
|
||||
break;
|
||||
case VEH_ROAD: max = _settings_game.vehicle.max_roadveh; break;
|
||||
case VEH_ROAD:
|
||||
if (!HasAnyRoadTypesAvail(_local_company, (RoadTramType)subtype)) return false;
|
||||
max = _settings_game.vehicle.max_roadveh;
|
||||
break;
|
||||
case VEH_SHIP: max = _settings_game.vehicle.max_ships; break;
|
||||
case VEH_AIRCRAFT: max = _settings_game.vehicle.max_aircraft; break;
|
||||
default: NOT_REACHED();
|
||||
@@ -2481,6 +2484,7 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
|
||||
/* Can we actually build the vehicle type? */
|
||||
const Engine *e;
|
||||
FOR_ALL_ENGINES_OF_TYPE(e, type) {
|
||||
if (type == VEH_ROAD && GetRoadTramType(e->u.road.roadtype) != (RoadTramType)subtype) continue;
|
||||
if (HasBit(e->company_avail, _local_company)) return true;
|
||||
}
|
||||
return false;
|
||||
@@ -2489,6 +2493,7 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
|
||||
/* We should be able to build infrastructure when we have the actual vehicle type */
|
||||
const Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (type == VEH_ROAD && GetRoadTramType(RoadVehicle::From(v)->roadtype) != (RoadTramType)subtype) continue;
|
||||
if (v->owner == _local_company && v->type == type) return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user