Skip to content

Commit

Permalink
Cleanup: Remove unused (and mostly duplicated) function
Browse files Browse the repository at this point in the history
  • Loading branch information
LordAro authored and TrueBrain committed Jan 8, 2021
1 parent b953b7e commit 090e788
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions src/road.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,39 +295,3 @@ RoadTypes ExistingRoadTypes(CompanyID c)

return known_roadtypes;
}

/**
* Check whether we can build infrastructure for the given RoadType. This to disable building stations etc. when
* you are not allowed/able to have the RoadType yet.
* @param roadtype the roadtype to check this for
* @param company the company id to check this for
* @param any_date to check only existing vehicles or if it is possible to build them in the future
* @return true if there is any reason why you may build the infrastructure for the given roadtype
*/
bool CanBuildRoadTypeInfrastructure(RoadType roadtype, CompanyID company)
{
if (_game_mode != GM_EDITOR && !Company::IsValidID(company)) return false;
if (!_settings_client.gui.disable_unsuitable_building) return true;
if (!HasAnyRoadTypesAvail(company, GetRoadTramType(roadtype))) return false;

RoadTypes roadtypes = ExistingRoadTypes(company);

/* Check if the filtered roadtypes does have the roadtype we are checking for
* and if we can build new ones */
if (_settings_game.vehicle.max_roadveh > 0 && HasBit(roadtypes, roadtype)) {
/* Can we actually build the vehicle type? */
for (const Engine *e : Engine::IterateType(VEH_ROAD)) {
if (!HasBit(e->company_avail, company)) continue;
if (HasPowerOnRoad(e->u.road.roadtype, roadtype) || HasPowerOnRoad(roadtype, e->u.road.roadtype)) return true;
}
return false;
}

/* We should be able to build infrastructure when we have the actual vehicle type */
for (const Vehicle *v : Vehicle::Iterate()) {
if (v->type == VEH_ROAD && (company == OWNER_DEITY || v->owner == company) &&
HasBit(roadtypes, RoadVehicle::From(v)->roadtype) && HasPowerOnRoad(RoadVehicle::From(v)->roadtype, roadtype)) return true;
}

return false;
}

0 comments on commit 090e788

Please sign in to comment.