* Add the road types that are to be introduced at the given date. * @param rt Roadtype * @param current The currently available roadtypes. * @param date The date for the introduction comparisons. * @return The road types that should be available when date * introduced road types are taken into account as well. */
| 175 | * introduced road types are taken into account as well. |
| 176 | */ |
| 177 | RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date) |
| 178 | { |
| 179 | RoadTypes rts = current; |
| 180 | |
| 181 | for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) { |
| 182 | const RoadTypeInfo *rti = GetRoadTypeInfo(rt); |
| 183 | /* Unused road type. */ |
| 184 | if (rti->label == 0) continue; |
| 185 | |
| 186 | /* Not date introduced. */ |
| 187 | if (!IsInsideMM(rti->introduction_date, 0, CalendarTime::MAX_DATE.base())) continue; |
| 188 | |
| 189 | /* Not yet introduced at this date. */ |
| 190 | if (rti->introduction_date > date) continue; |
| 191 | |
| 192 | /* Have we introduced all required roadtypes? */ |
| 193 | RoadTypes required = rti->introduction_required_roadtypes; |
| 194 | if (!rts.All(required)) continue; |
| 195 | |
| 196 | rts.Set(rti->introduces_roadtypes); |
| 197 | } |
| 198 | |
| 199 | /* When we added roadtypes we need to run this method again; the added |
| 200 | * roadtypes might enable more rail types to become introduced. */ |
| 201 | return rts == current ? rts : AddDateIntroducedRoadTypes(rts, date); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Get the road types the given company can build. |
no test coverage detected