Merge branch 'master' into jgrpp
# Conflicts: # cmake/CompileFlags.cmake # src/aircraft_cmd.cpp # src/blitter/32bpp_anim.cpp # src/cargopacket.cpp # src/cheat_gui.cpp # src/company_cmd.cpp # src/company_gui.cpp # src/core/pool_func.hpp # src/date.cpp # src/economy.cpp # src/error_gui.cpp # src/ground_vehicle.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/industry_cmd.cpp # src/lang/dutch.txt # src/lang/french.txt # src/lang/german.txt # src/linkgraph/linkgraph_gui.cpp # src/linkgraph/mcf.cpp # src/network/network_content.cpp # src/network/network_server.cpp # src/network/network_udp.cpp # src/newgrf_engine.cpp # src/newgrf_station.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/pathfinder/follow_track.hpp # src/pathfinder/yapf/yapf_common.hpp # src/saveload/saveload.cpp # src/settings_gui.cpp # src/station_cmd.cpp # src/station_kdtree.h # src/string_func.h # src/table/settings.ini # src/tgp.cpp # src/timetable_cmd.cpp # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/train_cmd.cpp # src/train_gui.cpp # src/tree_gui.cpp # src/tunnelbridge_cmd.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/video/sdl2_v.cpp # src/video/sdl_v.cpp # src/video/win32_v.cpp # src/viewport.cpp # src/viewport_sprite_sorter_sse4.cpp # src/window.cpp
This commit is contained in:
36
src/road.cpp
36
src/road.cpp
@@ -303,39 +303,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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user