Vehicles age at calendar speed in wallclock mode
This commit is contained in:
@@ -480,7 +480,7 @@ void Aircraft::OnNewDay()
|
|||||||
|
|
||||||
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
||||||
|
|
||||||
AgeVehicle(this);
|
if (!EconTime::UsingWallclockUnits()) AgeVehicle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aircraft::OnPeriodic()
|
void Aircraft::OnPeriodic()
|
||||||
|
@@ -2302,7 +2302,7 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v)
|
|||||||
|
|
||||||
void RoadVehicle::OnNewDay()
|
void RoadVehicle::OnNewDay()
|
||||||
{
|
{
|
||||||
AgeVehicle(this);
|
if (!EconTime::UsingWallclockUnits()) AgeVehicle(this);
|
||||||
|
|
||||||
if (!this->IsFrontEngine()) return;
|
if (!this->IsFrontEngine()) return;
|
||||||
|
|
||||||
|
@@ -290,7 +290,7 @@ void Ship::OnNewDay()
|
|||||||
if ((++this->day_counter & 7) == 0) {
|
if ((++this->day_counter & 7) == 0) {
|
||||||
DecreaseVehicleValue(this);
|
DecreaseVehicleValue(this);
|
||||||
}
|
}
|
||||||
AgeVehicle(this);
|
if (!EconTime::UsingWallclockUnits()) AgeVehicle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ship::OnPeriodic()
|
void Ship::OnPeriodic()
|
||||||
|
@@ -6889,7 +6889,7 @@ static void CheckIfTrainNeedsService(Train *v)
|
|||||||
/** Update day counters of the train vehicle. */
|
/** Update day counters of the train vehicle. */
|
||||||
void Train::OnNewDay()
|
void Train::OnNewDay()
|
||||||
{
|
{
|
||||||
AgeVehicle(this);
|
if (!EconTime::UsingWallclockUnits()) AgeVehicle(this);
|
||||||
|
|
||||||
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
||||||
}
|
}
|
||||||
|
@@ -1369,6 +1369,41 @@ static void RunVehicleDayProc()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increases the day counter for all vehicles and calls 1-day and 32-day handlers.
|
||||||
|
* Each tick, it processes vehicles with "index % DAY_TICKS == _date_fract",
|
||||||
|
* so each day, all vehicles are processes in DAY_TICKS steps.
|
||||||
|
*/
|
||||||
|
static void RunVehicleCalendarDayProc()
|
||||||
|
{
|
||||||
|
if (_game_mode != GM_NORMAL) return;
|
||||||
|
|
||||||
|
Vehicle *v = nullptr;
|
||||||
|
SCOPE_INFO_FMT([&v], "RunVehicleCalendarDayProc: %s", scope_dumper().VehicleInfo(v));
|
||||||
|
for (size_t i = CalTime::CurDateFract(); i < Vehicle::GetPoolSize(); i += DAY_TICKS) {
|
||||||
|
v = Vehicle::Get(i);
|
||||||
|
if (v == nullptr) continue;
|
||||||
|
|
||||||
|
/* This is called once per day for each vehicle, but not in the first tick of the day */
|
||||||
|
switch (v->type) {
|
||||||
|
case VEH_TRAIN:
|
||||||
|
AgeVehicle(v);
|
||||||
|
break;
|
||||||
|
case VEH_ROAD:
|
||||||
|
if (v->IsFrontEngine()) AgeVehicle(v);
|
||||||
|
break;
|
||||||
|
case VEH_SHIP:
|
||||||
|
if (static_cast<Ship *>(v)->IsPrimaryVehicle()) AgeVehicle(v);
|
||||||
|
break;
|
||||||
|
case VEH_AIRCRAFT:
|
||||||
|
if (static_cast<Aircraft *>(v)->IsNormalAircraft()) AgeVehicle(v);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ShowAutoReplaceAdviceMessage(const CommandCost &res, const Vehicle *v)
|
static void ShowAutoReplaceAdviceMessage(const CommandCost &res, const Vehicle *v)
|
||||||
{
|
{
|
||||||
StringID error_message = res.GetErrorMessage();
|
StringID error_message = res.GetErrorMessage();
|
||||||
@@ -1530,6 +1565,10 @@ void CallVehicleTicks()
|
|||||||
|
|
||||||
if (TickSkipCounter() == 0) RunVehicleDayProc();
|
if (TickSkipCounter() == 0) RunVehicleDayProc();
|
||||||
|
|
||||||
|
if (EconTime::UsingWallclockUnits() && _settings_game.economy.minutes_per_calendar_year != CalTime::FROZEN_MINUTES_PER_YEAR && CalTime::Detail::now.sub_date_fract == 0) {
|
||||||
|
RunVehicleCalendarDayProc();
|
||||||
|
}
|
||||||
|
|
||||||
if (DayLengthFactor() >= 8 && _game_mode == GM_NORMAL) {
|
if (DayLengthFactor() >= 8 && _game_mode == GM_NORMAL) {
|
||||||
/*
|
/*
|
||||||
* Vehicle::OnPeriodic is decoupled from Vehicle::OnNewDay at day lengths >= 8
|
* Vehicle::OnPeriodic is decoupled from Vehicle::OnNewDay at day lengths >= 8
|
||||||
|
Reference in New Issue
Block a user