Loading

Revision differences

Old revision #p5hou9ktyNew revision #pzdjy2zkb
185             case MTHK_MUSIC: ShowMusicWindow(); break;  185             case MTHK_MUSIC: ShowMusicWindow(); break;  
186             case MTHK_AI_DEBUG: ShowAIDebugWindow(); break;  186             case MTHK_AI_DEBUG: ShowAIDebugWindow(); break;  
187diff --git a/src/vehicle.cpp b/src/vehicle.cpp  187diff --git a/src/vehicle.cpp b/src/vehicle.cpp  
188index 86e3dbc..9fc2711 100644  188index 86e3dbc..687bfc3 100644
189--- a/src/vehicle.cpp  189--- a/src/vehicle.cpp  
190+++ b/src/vehicle.cpp  190+++ b/src/vehicle.cpp  
191@@ -1714,12 +1714,12 @@ UnitID GetFreeUnitNumber(VehicleType type)  191@@ -1714,12 +1714,12 @@ UnitID GetFreeUnitNumber(VehicleType type)  
  
221         }  221         }  
222         return false;  222         return false;  
223     }  223     }  
224@@ -1748,14 +1746,45 @@ bool CanBuildVehicleInfrastructure(VehicleType type, uint subtype)  224@@ -1748,14 +1746,47 @@ bool CanBuildVehicleInfrastructure(VehicleType type, uint subtype)
225     /* We should be able to build infrastructure when we have the actual vehicle type */  225     /* We should be able to build infrastructure when we have the actual vehicle type */  
226     const Vehicle *v;  226     const Vehicle *v;  
227     FOR_ALL_VEHICLES(v) {  227     FOR_ALL_VEHICLES(v) {  
  
249+  249+  
250+    RoadSubTypes roadsubtypes = ExistingRoadSubTypesForRoadType(rtid.basetype, company, any_date);  250+    RoadSubTypes roadsubtypes = ExistingRoadSubTypesForRoadType(rtid.basetype, company, any_date);  
251+  251+  
252+    if (_settings_game.vehicle.max_roadveh > 0) {  252+    /* Check if the filtered subtypes does have the subtype we are checking for
   253+     * and if we can build new ones */
   254+    if (_settings_game.vehicle.max_roadveh > 0 && HasBit(roadsubtypes, rtid.subtype)) {
253+        /* Can we actually build the vehicle type? */  255+        /* Can we actually build the vehicle type? */  
254+        const Engine *e;  256+        const Engine *e;  
255+        FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {  257+        FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {  
256+            if (e->GetRoadType() == rtid && HasBit(roadsubtypes, e->GetRoadType().subtype)) return true;  256+            if (e->GetRoadType() == rtid) return true;
257+        }  259+        }  
258+        return false;  260+        return false;  
259+    }  261+    }  
  
261+    /* We should be able to build infrastructure when we have the actual vehicle type */  263+    /* We should be able to build infrastructure when we have the actual vehicle type */  
262+    const Vehicle *v;  264+    const Vehicle *v;  
263+    FOR_ALL_VEHICLES(v) {  265+    FOR_ALL_VEHICLES(v) {  
264+        if (v->type == VEH_ROAD && (company == OWNER_NONE || v->owner == company) &&  264+        if (v->type == VEH_ROAD && (company == OWNER_DEITY || v->owner == company) &&
265+                HasBit(roadsubtypes, RoadVehicle::From(v)->rtid.subtype) && RoadVehicle::From(v)->rtid == rtid) return true;  265+            HasBit(roadsubtypes, RoadVehicle::From(v)->rtid.subtype) && RoadVehicle::From(v)->rtid == rtid) return true;
266+    }  268+    }  
267+  269+  
268+    return false;  270+    return false;