File diff r27883:ddbd33508a8a → r27884:803962be0328
src/road.cpp
Show inline comments
 
@@ -112,13 +112,13 @@ bool HasRoadTypeAvail(const CompanyID co
 
{
 
	if (company == OWNER_DEITY || company == OWNER_TOWN || _game_mode == GM_EDITOR || _generating_world) {
 
		const RoadTypeInfo *rti = GetRoadTypeInfo(roadtype);
 
		if (rti->label == 0) return false;
 

	
 
		/* Not yet introduced at this date. */
 
		if (IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(MAX_DATE)) && rti->introduction_date > TimerGameCalendar::date) return false;
 
		if (IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(CalendarTime::MAX_DATE)) && rti->introduction_date > TimerGameCalendar::date) return false;
 

	
 
		/*
 
		 * Do not allow building hidden road types, except when a town may build it.
 
		 * The GS under deity mode, as well as anybody in the editor builds roads that are
 
		 * owned by towns. So if a town may build it, it should be buildable by them too.
 
		 */
 
@@ -170,13 +170,13 @@ RoadTypes AddDateIntroducedRoadTypes(Roa
 
	for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
 
		const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
 
		/* Unused road type. */
 
		if (rti->label == 0) continue;
 

	
 
		/* Not date introduced. */
 
		if (!IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(MAX_DATE))) continue;
 
		if (!IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(CalendarTime::MAX_DATE))) continue;
 

	
 
		/* Not yet introduced at this date. */
 
		if (rti->introduction_date > date) continue;
 

	
 
		/* Have we introduced all required roadtypes? */
 
		RoadTypes required = rti->introduction_required_roadtypes;
 
@@ -201,13 +201,13 @@ RoadTypes GetCompanyRoadTypes(CompanyID 
 
	RoadTypes rts = ROADTYPES_NONE;
 

	
 
	for (const Engine *e : Engine::IterateType(VEH_ROAD)) {
 
		const EngineInfo *ei = &e->info;
 

	
 
		if (HasBit(ei->climates, _settings_game.game_creation.landscape) &&
 
				(HasBit(e->company_avail, company) || TimerGameCalendar::date >= e->intro_date + DAYS_IN_YEAR)) {
 
				(HasBit(e->company_avail, company) || TimerGameCalendar::date >= e->intro_date + CalendarTime::DAYS_IN_YEAR)) {
 
			const RoadVehicleInfo *rvi = &e->u.road;
 
			assert(rvi->roadtype < ROADTYPE_END);
 
			if (introduces) {
 
				rts |= GetRoadTypeInfo(rvi->roadtype)->introduces_roadtypes;
 
			} else {
 
				SetBit(rts, rvi->roadtype);
 
@@ -238,13 +238,13 @@ RoadTypes GetRoadTypes(bool introduces)
 
			rts |= GetRoadTypeInfo(rvi->roadtype)->introduces_roadtypes;
 
		} else {
 
			SetBit(rts, rvi->roadtype);
 
		}
 
	}
 

	
 
	if (introduces) return AddDateIntroducedRoadTypes(rts, MAX_DATE);
 
	if (introduces) return AddDateIntroducedRoadTypes(rts, CalendarTime::MAX_DATE);
 
	return rts;
 
}
 

	
 
/**
 
 * Get the road type for a given label.
 
 * @param label the roadtype label.
 
@@ -299,10 +299,10 @@ RoadTypes ExistingRoadTypes(CompanyID c)
 
		if (e->company_avail != MAX_UVALUE(CompanyMask)) continue;
 

	
 
		known_roadtypes |= GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes;
 
	}
 

	
 
	/* Get the date introduced roadtypes as well. */
 
	known_roadtypes = AddDateIntroducedRoadTypes(known_roadtypes, MAX_DATE);
 
	known_roadtypes = AddDateIntroducedRoadTypes(known_roadtypes, CalendarTime::MAX_DATE);
 

	
 
	return known_roadtypes;
 
}