summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2019-04-06 07:46:15 +0100
committerMichael Lutz <michi@icosahedron.de>2019-05-01 21:36:27 +0200
commitc02ef3e4564b7b54d49f0827d2d7625cbc38f335 (patch)
tree1c0ee62b6ce55124b247daaafa42300bfaa932e7 /src/vehicle.cpp
parent21edf67f89c60351d5a0d84625455aa296b6b950 (diff)
downloadopenttd-c02ef3e4564b7b54d49f0827d2d7625cbc38f335.tar.xz
Feature: Add NotRoadTypes (NRT)
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r--src/vehicle.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 031b6f95e..6e26c7bfe 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1757,7 +1757,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));
@@ -1770,7 +1770,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();
@@ -1781,6 +1784,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;
@@ -1789,6 +1793,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;
}