* Add the rail types that are to be introduced at the given date. * @param current The currently available railtypes. * @param date The date for the introduction comparisons. * @return The rail types that should be available when date * introduced rail types are taken into account as well. */
| 100 | * introduced rail types are taken into account as well. |
| 101 | */ |
| 102 | RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date) |
| 103 | { |
| 104 | RailTypes rts = current; |
| 105 | |
| 106 | for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) { |
| 107 | const RailTypeInfo *rti = GetRailTypeInfo(rt); |
| 108 | /* Unused rail type. */ |
| 109 | if (rti->label == 0) continue; |
| 110 | |
| 111 | /* Not date introduced. */ |
| 112 | if (!IsInsideMM(rti->introduction_date, 0, CalendarTime::MAX_DATE.base())) continue; |
| 113 | |
| 114 | /* Not yet introduced at this date. */ |
| 115 | if (rti->introduction_date > date) continue; |
| 116 | |
| 117 | /* Have we introduced all required railtypes? */ |
| 118 | RailTypes required = rti->introduction_required_railtypes; |
| 119 | if (!rts.All(required)) continue; |
| 120 | |
| 121 | rts.Set(rti->introduces_railtypes); |
| 122 | } |
| 123 | |
| 124 | /* When we added railtypes we need to run this method again; the added |
| 125 | * railtypes might enable more rail types to become introduced. */ |
| 126 | return rts == current ? rts : AddDateIntroducedRailTypes(rts, date); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Get the rail types the given company can build. |
no test coverage detected