Loading

CanBuildVehicleInfrastruc

  1. bool CanBuildVehicleInfrastructure(RoadTypeIdentifier rtid, CompanyID company, bool any_date)
  2. {
  3.     if (_game_mode != GM_EDITOR && !Company::IsValidID(company)) return false;
  4.     /* TODO: In SE this could differ for the player who use the scenario, should I make it GM_NORMAL only? */
  5.     if (!_settings_client.gui.disable_unsuitable_building) return true;
  6.  
  7.     RoadSubTypes roadsubtypes = ExistingRoadSubTypesForRoadType(rtid.basetype, company, any_date);
  8.  
  9.     UnitID max = _settings_game.vehicle.max_roadveh;
  10.  
  11.     if (max > 0) {
  12.         /* Can we actually build the vehicle type? */
  13.         const Engine *e;
  14.         FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
  15.             if (HasBit(roadsubtypes, e->GetRoadType().subtype)) return true;
  16.         }
  17.         return false;
  18.     }
  19.  
  20.     /* We should be able to build infrastructure when we have the actual vehicle type */
  21.     const Vehicle *v;
  22.     FOR_ALL_VEHICLES(v) {
  23.         if (v->type == VEH_ROAD && HasBit(roadsubtypes, RoadVehicle::From(v)->rtid.subtype) && v->owner == company) return true;
  24.     }
  25.  
  26.     return false;
  27. }

Comments