|
|
|
@ -675,7 +675,7 @@ void StartupOneEngine(Engine *e, Date aging_date, uint32 seed)
|
|
|
|
|
* of engines in early starting games.
|
|
|
|
|
* Note: TTDP uses fixed 1922 */
|
|
|
|
|
e->intro_date = ei->base_intro <= ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro;
|
|
|
|
|
if (e->intro_date <= _date) {
|
|
|
|
|
if (e->intro_date <= TimerGameCalendar::date) {
|
|
|
|
|
e->age = (aging_date - e->intro_date) >> 5;
|
|
|
|
|
e->company_avail = MAX_UVALUE(CompanyMask);
|
|
|
|
|
e->flags |= ENGINE_AVAILABLE;
|
|
|
|
@ -721,7 +721,7 @@ void StartupOneEngine(Engine *e, Date aging_date, uint32 seed)
|
|
|
|
|
void StartupEngines()
|
|
|
|
|
{
|
|
|
|
|
/* Aging of vehicles stops, so account for that when starting late */
|
|
|
|
|
const Date aging_date = std::min(_date, ConvertYMDToDate(_year_engine_aging_stops, 0, 1));
|
|
|
|
|
const Date aging_date = std::min(TimerGameCalendar::date, ConvertYMDToDate(_year_engine_aging_stops, 0, 1));
|
|
|
|
|
uint32 seed = Random();
|
|
|
|
|
|
|
|
|
|
for (Engine *e : Engine::Iterate()) {
|
|
|
|
@ -883,11 +883,11 @@ static bool IsVehicleTypeDisabled(VehicleType type, bool ai)
|
|
|
|
|
static IntervalTimer<TimerGameCalendar> _engines_daily({TimerGameCalendar::DAY, TimerGameCalendar::Priority::ENGINE}, [](auto)
|
|
|
|
|
{
|
|
|
|
|
for (Company *c : Company::Iterate()) {
|
|
|
|
|
c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes, _date);
|
|
|
|
|
c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes, _date);
|
|
|
|
|
c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes, TimerGameCalendar::date);
|
|
|
|
|
c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes, TimerGameCalendar::date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_cur_year >= _year_engine_aging_stops) return;
|
|
|
|
|
if (TimerGameCalendar::year >= _year_engine_aging_stops) return;
|
|
|
|
|
|
|
|
|
|
for (Engine *e : Engine::Iterate()) {
|
|
|
|
|
EngineID i = e->index;
|
|
|
|
@ -1038,11 +1038,11 @@ static void NewVehicleAvailable(Engine *e)
|
|
|
|
|
if (e->type == VEH_TRAIN) {
|
|
|
|
|
/* maybe make another rail type available */
|
|
|
|
|
assert(e->u.rail.railtype < RAILTYPE_END);
|
|
|
|
|
for (Company *c : Company::Iterate()) c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes | GetRailTypeInfo(e->u.rail.railtype)->introduces_railtypes, _date);
|
|
|
|
|
for (Company *c : Company::Iterate()) c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes | GetRailTypeInfo(e->u.rail.railtype)->introduces_railtypes, TimerGameCalendar::date);
|
|
|
|
|
} else if (e->type == VEH_ROAD) {
|
|
|
|
|
/* maybe make another road type available */
|
|
|
|
|
assert(e->u.road.roadtype < ROADTYPE_END);
|
|
|
|
|
for (Company* c : Company::Iterate()) c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes | GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes, _date);
|
|
|
|
|
for (Company* c : Company::Iterate()) c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes | GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes, TimerGameCalendar::date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Only broadcast event if AIs are able to build this vehicle type. */
|
|
|
|
@ -1067,7 +1067,7 @@ static void NewVehicleAvailable(Engine *e)
|
|
|
|
|
/** Monthly update of the availability, reliability, and preview offers of the engines. */
|
|
|
|
|
void EnginesMonthlyLoop()
|
|
|
|
|
{
|
|
|
|
|
if (_cur_year < _year_engine_aging_stops) {
|
|
|
|
|
if (TimerGameCalendar::year < _year_engine_aging_stops) {
|
|
|
|
|
bool refresh = false;
|
|
|
|
|
for (Engine *e : Engine::Iterate()) {
|
|
|
|
|
/* Age the vehicle */
|
|
|
|
@ -1080,10 +1080,10 @@ void EnginesMonthlyLoop()
|
|
|
|
|
/* Do not introduce invalid engines */
|
|
|
|
|
if (!e->IsEnabled()) continue;
|
|
|
|
|
|
|
|
|
|
if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + DAYS_IN_YEAR)) {
|
|
|
|
|
if (!(e->flags & ENGINE_AVAILABLE) && TimerGameCalendar::date >= (e->intro_date + DAYS_IN_YEAR)) {
|
|
|
|
|
/* Introduce it to all companies */
|
|
|
|
|
NewVehicleAvailable(e);
|
|
|
|
|
} else if (!(e->flags & (ENGINE_AVAILABLE | ENGINE_EXCLUSIVE_PREVIEW)) && _date >= e->intro_date) {
|
|
|
|
|
} else if (!(e->flags & (ENGINE_AVAILABLE | ENGINE_EXCLUSIVE_PREVIEW)) && TimerGameCalendar::date >= e->intro_date) {
|
|
|
|
|
/* Introduction date has passed...
|
|
|
|
|
* Check if it is allowed to build this vehicle type at all
|
|
|
|
|
* based on the current game settings. If not, it does not
|
|
|
|
|