Codechange: Move Ticks into their own class

This commit is contained in:
Tyler Trahan
2023-08-16 09:01:24 -04:00
parent 30172fc037
commit fca2b37726
34 changed files with 132 additions and 116 deletions

View File

@@ -3353,12 +3353,12 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
v->cur_speed = 0;
v->subspeed = 0;
v->progress = 255; // make sure that every bit of acceleration will hit the signal again, so speed stays 0.
if (!_settings_game.pf.reverse_at_signals || ++v->wait_counter < _settings_game.pf.wait_oneway_signal * DAY_TICKS * 2) return false;
if (!_settings_game.pf.reverse_at_signals || ++v->wait_counter < _settings_game.pf.wait_oneway_signal * Ticks::DAY_TICKS * 2) return false;
} else if (HasSignalOnTrackdir(gp.new_tile, i)) {
v->cur_speed = 0;
v->subspeed = 0;
v->progress = 255; // make sure that every bit of acceleration will hit the signal again, so speed stays 0.
if (!_settings_game.pf.reverse_at_signals || ++v->wait_counter < _settings_game.pf.wait_twoway_signal * DAY_TICKS * 2) {
if (!_settings_game.pf.reverse_at_signals || ++v->wait_counter < _settings_game.pf.wait_twoway_signal * Ticks::DAY_TICKS * 2) {
DiagDirection exitdir = TrackdirToExitdir(i);
TileIndex o_tile = TileAddByDiagDir(gp.new_tile, exitdir);
@@ -3978,14 +3978,14 @@ static bool TrainLocoHandler(Train *v, bool mode)
++v->wait_counter;
/* Should we try reversing this tick if still stuck? */
bool turn_around = v->wait_counter % (_settings_game.pf.wait_for_pbs_path * DAY_TICKS) == 0 && _settings_game.pf.reverse_at_signals;
bool turn_around = v->wait_counter % (_settings_game.pf.wait_for_pbs_path * Ticks::DAY_TICKS) == 0 && _settings_game.pf.reverse_at_signals;
if (!turn_around && v->wait_counter % _settings_game.pf.path_backoff_interval != 0 && v->force_proceed == TFP_NONE) return true;
if (!TryPathReserve(v)) {
/* Still stuck. */
if (turn_around) ReverseTrainDirection(v);
if (HasBit(v->flags, VRF_TRAIN_STUCK) && v->wait_counter > 2 * _settings_game.pf.wait_for_pbs_path * DAY_TICKS) {
if (HasBit(v->flags, VRF_TRAIN_STUCK) && v->wait_counter > 2 * _settings_game.pf.wait_for_pbs_path * Ticks::DAY_TICKS) {
/* Show message to player. */
if (_settings_client.gui.lost_vehicle_warn && v->owner == _local_company) {
SetDParam(0, v->index);
@@ -4179,7 +4179,7 @@ void Train::OnNewDay()
if (this->running_ticks != 0) {
/* running costs */
CommandCost cost(EXPENSES_TRAIN_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
CommandCost cost(EXPENSES_TRAIN_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * Ticks::DAY_TICKS));
this->profit_this_year -= cost.GetCost();
this->running_ticks = 0;