(svn r18812) -Codechange: make some functions in train.h functions of Train.

This commit is contained in:
rubidium 2010-01-15 18:23:52 +00:00
parent 55d1db5b28
commit aaf0b4b46c
10 changed files with 84 additions and 80 deletions

View File

@ -125,7 +125,7 @@ static void TransferCargo(Vehicle *old_veh, Vehicle *new_head, bool part_of_chai
} }
/* Update train weight etc., the old vehicle will be sold anyway */ /* Update train weight etc., the old vehicle will be sold anyway */
if (part_of_chain && new_head->type == VEH_TRAIN) TrainConsistChanged(Train::From(new_head), true); if (part_of_chain && new_head->type == VEH_TRAIN) Train::From(new_head)->ConsistChanged(true);
} }
/** /**

View File

@ -573,8 +573,8 @@ bool SettingsDisableElrail(int32 p1)
FOR_ALL_TRAINS(t) { FOR_ALL_TRAINS(t) {
/* power and acceleration is cached only for front engines */ /* power and acceleration is cached only for front engines */
if (t->IsFrontEngine()) { if (t->IsFrontEngine()) {
TrainPowerChanged(t); t->PowerChanged();
UpdateTrainAcceleration(t); t->UpdateAcceleration();
} }
} }

View File

@ -1140,7 +1140,7 @@ void StateGameLoop()
length = 0; length = 0;
for (Train *u = t; u != NULL; u = u->Next()) wagons[length++] = u->tcache; for (Train *u = t; u != NULL; u = u->Next()) wagons[length++] = u->tcache;
TrainConsistChanged(t, true); t->ConsistChanged(true);
length = 0; length = 0;
for (Train *u = t; u != NULL; u = u->Next()) { for (Train *u = t; u != NULL; u = u->Next()) {

View File

@ -1285,7 +1285,7 @@ static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
if (t->IsArticulatedPart()) return NULL; if (t->IsArticulatedPart()) return NULL;
const RailVehicleInfo *rvi = RailVehInfo(t->engine_type); const RailVehicleInfo *rvi = RailVehInfo(t->engine_type);
if (GetVehicleProperty(t, PROP_TRAIN_POWER, rvi->power) != 0) TrainPowerChanged(t->First()); if (GetVehicleProperty(t, PROP_TRAIN_POWER, rvi->power) != 0) t->First()->PowerChanged();
return NULL; return NULL;
} }

View File

@ -1042,7 +1042,7 @@ bool AfterLoadGame()
} }
FOR_ALL_TRAINS(v) { FOR_ALL_TRAINS(v) {
if (v->IsFrontEngine() || v->IsFreeWagon()) TrainConsistChanged(v, true); if (v->IsFrontEngine() || v->IsFreeWagon()) v->ConsistChanged(true);
} }
} }

View File

@ -318,7 +318,7 @@ void AfterLoadVehicles(bool part_of_load)
Train *t = Train::From(v); Train *t = Train::From(v);
if (t->IsFrontEngine() || t->IsFreeWagon()) { if (t->IsFrontEngine() || t->IsFreeWagon()) {
t->tcache.last_speed = t->cur_speed; // update displayed train speed t->tcache.last_speed = t->cur_speed; // update displayed train speed
TrainConsistChanged(t, false); t->ConsistChanged(false);
} }
} else if (v->type == VEH_ROAD) { } else if (v->type == VEH_ROAD) {
RoadVehicle *rv = RoadVehicle::From(v); RoadVehicle *rv = RoadVehicle::From(v);

View File

@ -700,7 +700,7 @@ static bool UpdateConsists(int32 p1)
Train *t; Train *t;
FOR_ALL_TRAINS(t) { FOR_ALL_TRAINS(t) {
/* Update the consist of all trains so the maximum speed is set correctly. */ /* Update the consist of all trains so the maximum speed is set correctly. */
if (t->IsFrontEngine() || t->IsFreeWagon()) TrainConsistChanged(t, true); if (t->IsFrontEngine() || t->IsFreeWagon()) t->ConsistChanged(true);
} }
return true; return true;
} }
@ -737,8 +737,8 @@ static bool TrainAccelerationModelChanged(int32 p1)
Train *t; Train *t;
FOR_ALL_TRAINS(t) { FOR_ALL_TRAINS(t) {
if (t->IsFrontEngine()) { if (t->IsFrontEngine()) {
t->tcache.cached_max_curve_speed = GetTrainCurveSpeedLimit(t); t->tcache.cached_max_curve_speed = t->GetCurveSpeedLimit();
UpdateTrainAcceleration(t); t->UpdateAcceleration();
} }
} }

View File

@ -44,7 +44,6 @@ enum VehicleRailFlags {
byte FreightWagonMult(CargoID cargo); byte FreightWagonMult(CargoID cargo);
void UpdateTrainAcceleration(Train *v);
void CheckTrainsLengths(); void CheckTrainsLengths();
void FreeTrainTrackReservation(const Train *v, TileIndex origin = INVALID_TILE, Trackdir orig_td = INVALID_TRACKDIR); void FreeTrainTrackReservation(const Train *v, TileIndex origin = INVALID_TILE, Trackdir orig_td = INVALID_TRACKDIR);
@ -52,11 +51,6 @@ bool TryPathReserve(Train *v, bool mark_as_stuck = false, bool first_tile_okay =
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length); int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length);
void TrainConsistChanged(Train *v, bool same_length);
void TrainPowerChanged(Train *v);
int GetTrainCurveSpeedLimit(Train *v);
Money GetTrainRunningCost(const Train *v);
/** Variables that are cached to improve performance and such */ /** Variables that are cached to improve performance and such */
struct TrainCache { struct TrainCache {
/* Cached wagon override spritegroup */ /* Cached wagon override spritegroup */
@ -139,6 +133,14 @@ struct Train : public SpecializedVehicle<Train, VEH_TRAIN> {
void ReserveTrackUnderConsist() const; void ReserveTrackUnderConsist() const;
int GetCurveSpeedLimit() const;
void ConsistChanged(bool same_length);
void CargoChanged();
void PowerChanged();
void UpdateAcceleration();
/** /**
* enum to handle train subtypes * enum to handle train subtypes
* Do not access it directly unless you have to. Use the access functions below * Do not access it directly unless you have to. Use the access functions below

View File

@ -91,14 +91,15 @@ byte FreightWagonMult(CargoID cargo)
/** /**
* Recalculates the cached total power of a train. Should be called when the consist is changed * Recalculates the cached total power of a train. Should be called when the consist is changed
* @param v First vehicle of the consist.
*/ */
void TrainPowerChanged(Train *v) void Train::PowerChanged()
{ {
assert(this->First() == this);
uint32 total_power = 0; uint32 total_power = 0;
uint32 max_te = 0; uint32 max_te = 0;
for (const Train *u = v; u != NULL; u = u->Next()) { for (const Train *u = this; u != NULL; u = u->Next()) {
RailType railtype = GetRailType(u->tile); RailType railtype = GetRailType(u->tile);
/* Power is not added for articulated parts */ /* Power is not added for articulated parts */
@ -120,19 +121,19 @@ void TrainPowerChanged(Train *v)
} }
} }
if (HasBit(u->flags, VRF_POWEREDWAGON) && HasPowerOnRail(v->railtype, railtype)) { if (HasBit(u->flags, VRF_POWEREDWAGON) && HasPowerOnRail(this->railtype, railtype)) {
total_power += RailVehInfo(u->tcache.first_engine)->pow_wag_power; total_power += RailVehInfo(u->tcache.first_engine)->pow_wag_power;
} }
} }
if (v->tcache.cached_power != total_power || v->tcache.cached_max_te != max_te) { if (this->tcache.cached_power != total_power || this->tcache.cached_max_te != max_te) {
/* If it has no power (no catenary), stop the train */ /* If it has no power (no catenary), stop the train */
if (total_power == 0) v->vehstatus |= VS_STOPPED; if (total_power == 0) this->vehstatus |= VS_STOPPED;
v->tcache.cached_power = total_power; this->tcache.cached_power = total_power;
v->tcache.cached_max_te = max_te; this->tcache.cached_max_te = max_te;
SetWindowDirty(WC_VEHICLE_DETAILS, v->index); SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
} }
} }
@ -142,11 +143,12 @@ void TrainPowerChanged(Train *v)
* the consist changes. * the consist changes.
* @param v First vehicle of the consist. * @param v First vehicle of the consist.
*/ */
static void TrainCargoChanged(Train *v) void Train::CargoChanged()
{ {
assert(this->First() == this);
uint32 weight = 0; uint32 weight = 0;
for (Train *u = v; u != NULL; u = u->Next()) { for (Train *u = this; u != NULL; u = u->Next()) {
uint32 vweight = CargoSpec::Get(u->cargo_type)->weight * u->cargo.Count() * FreightWagonMult(u->cargo_type) / 16; uint32 vweight = CargoSpec::Get(u->cargo_type)->weight * u->cargo.Count() * FreightWagonMult(u->cargo_type) / 16;
/* Vehicle weight is not added for articulated parts. */ /* Vehicle weight is not added for articulated parts. */
@ -168,10 +170,10 @@ static void TrainCargoChanged(Train *v)
} }
/* store consist weight in cache */ /* store consist weight in cache */
v->tcache.cached_weight = weight; this->tcache.cached_weight = weight;
/* Now update train power (tractive effort is dependent on weight) */ /* Now update train power (tractive effort is dependent on weight) */
TrainPowerChanged(v); this->PowerChanged();
} }
@ -218,48 +220,47 @@ void CheckTrainsLengths()
* Recalculates the cached stuff of a train. Should be called each time a vehicle is added * Recalculates the cached stuff of a train. Should be called each time a vehicle is added
* to/removed from the chain, and when the game is loaded. * to/removed from the chain, and when the game is loaded.
* Note: this needs to be called too for 'wagon chains' (in the depot, without an engine) * Note: this needs to be called too for 'wagon chains' (in the depot, without an engine)
* @param v First vehicle of the chain.
* @param same_length should length of vehicles stay the same? * @param same_length should length of vehicles stay the same?
*/ */
void TrainConsistChanged(Train *v, bool same_length) void Train::ConsistChanged(bool same_length)
{ {
uint16 max_speed = UINT16_MAX; uint16 max_speed = UINT16_MAX;
assert(v->IsFrontEngine() || v->IsFreeWagon()); assert(this->IsFrontEngine() || this->IsFreeWagon());
const RailVehicleInfo *rvi_v = RailVehInfo(v->engine_type); const RailVehicleInfo *rvi_v = RailVehInfo(this->engine_type);
EngineID first_engine = v->IsFrontEngine() ? v->engine_type : INVALID_ENGINE; EngineID first_engine = this->IsFrontEngine() ? this->engine_type : INVALID_ENGINE;
v->tcache.cached_total_length = 0; this->tcache.cached_total_length = 0;
v->compatible_railtypes = RAILTYPES_NONE; this->compatible_railtypes = RAILTYPES_NONE;
bool train_can_tilt = true; bool train_can_tilt = true;
for (Train *u = v; u != NULL; u = u->Next()) { for (Train *u = this; u != NULL; u = u->Next()) {
const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type); const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
/* Check the v->first cache. */ /* Check the this->first cache. */
assert(u->First() == v); assert(u->First() == this);
/* update the 'first engine' */ /* update the 'first engine' */
u->tcache.first_engine = v == u ? INVALID_ENGINE : first_engine; u->tcache.first_engine = this == u ? INVALID_ENGINE : first_engine;
u->railtype = rvi_u->railtype; u->railtype = rvi_u->railtype;
if (u->IsEngine()) first_engine = u->engine_type; if (u->IsEngine()) first_engine = u->engine_type;
/* Set user defined data to its default value */ /* Set user defined data to its default value */
u->tcache.user_def_data = rvi_u->user_def_data; u->tcache.user_def_data = rvi_u->user_def_data;
v->InvalidateNewGRFCache(); this->InvalidateNewGRFCache();
u->InvalidateNewGRFCache(); u->InvalidateNewGRFCache();
} }
for (Train *u = v; u != NULL; u = u->Next()) { for (Train *u = this; u != NULL; u = u->Next()) {
/* Update user defined data (must be done before other properties) */ /* Update user defined data (must be done before other properties) */
u->tcache.user_def_data = GetVehicleProperty(u, PROP_TRAIN_USER_DATA, u->tcache.user_def_data); u->tcache.user_def_data = GetVehicleProperty(u, PROP_TRAIN_USER_DATA, u->tcache.user_def_data);
v->InvalidateNewGRFCache(); this->InvalidateNewGRFCache();
u->InvalidateNewGRFCache(); u->InvalidateNewGRFCache();
} }
for (Train *u = v; u != NULL; u = u->Next()) { for (Train *u = this; u != NULL; u = u->Next()) {
const Engine *e_u = Engine::Get(u->engine_type); const Engine *e_u = Engine::Get(u->engine_type);
const RailVehicleInfo *rvi_u = &e_u->u.rail; const RailVehicleInfo *rvi_u = &e_u->u.rail;
@ -305,7 +306,7 @@ void TrainConsistChanged(Train *v, bool same_length)
/* Do not count powered wagons for the compatible railtypes, as wagons always /* Do not count powered wagons for the compatible railtypes, as wagons always
have railtype normal */ have railtype normal */
if (rvi_u->power > 0) { if (rvi_u->power > 0) {
v->compatible_railtypes |= GetRailTypeInfo(u->railtype)->powered_railtypes; this->compatible_railtypes |= GetRailTypeInfo(u->railtype)->powered_railtypes;
} }
/* Some electric engines can be allowed to run on normal rail. It happens to all /* Some electric engines can be allowed to run on normal rail. It happens to all
@ -338,22 +339,22 @@ void TrainConsistChanged(Train *v, bool same_length)
/* update vehicle length? */ /* update vehicle length? */
if (!same_length) u->tcache.cached_veh_length = veh_len; if (!same_length) u->tcache.cached_veh_length = veh_len;
v->tcache.cached_total_length += u->tcache.cached_veh_length; this->tcache.cached_total_length += u->tcache.cached_veh_length;
v->InvalidateNewGRFCache(); this->InvalidateNewGRFCache();
u->InvalidateNewGRFCache(); u->InvalidateNewGRFCache();
} }
/* store consist weight/max speed in cache */ /* store consist weight/max speed in cache */
v->tcache.cached_max_speed = max_speed; this->tcache.cached_max_speed = max_speed;
v->tcache.cached_tilt = train_can_tilt; this->tcache.cached_tilt = train_can_tilt;
v->tcache.cached_max_curve_speed = GetTrainCurveSpeedLimit(v); this->tcache.cached_max_curve_speed = this->GetCurveSpeedLimit();
/* recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added) */ /* recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added) */
TrainCargoChanged(v); this->CargoChanged();
if (v->IsFrontEngine()) { if (this->IsFrontEngine()) {
UpdateTrainAcceleration(v); this->UpdateAcceleration();
SetWindowDirty(WC_VEHICLE_DETAILS, v->index); SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
} }
} }
@ -414,11 +415,12 @@ int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, i
/** /**
* Computes train speed limit caused by curves * Computes train speed limit caused by curves
* @param v first vehicle of consist
* @return imposed speed limit * @return imposed speed limit
*/ */
int GetTrainCurveSpeedLimit(Train *v) int Train::GetCurveSpeedLimit() const
{ {
assert(this->First() == this);
static const int absolute_max_speed = UINT16_MAX; static const int absolute_max_speed = UINT16_MAX;
int max_speed = absolute_max_speed; int max_speed = absolute_max_speed;
@ -431,7 +433,7 @@ int GetTrainCurveSpeedLimit(Train *v)
int sum = 0; int sum = 0;
int pos = 0; int pos = 0;
int lastpos = -1; int lastpos = -1;
for (const Vehicle *u = v; u->Next() != NULL; u = u->Next(), pos++) { for (const Vehicle *u = this; u->Next() != NULL; u = u->Next(), pos++) {
Direction this_dir = u->direction; Direction this_dir = u->direction;
Direction next_dir = u->Next()->direction; Direction next_dir = u->Next()->direction;
@ -468,10 +470,10 @@ int GetTrainCurveSpeedLimit(Train *v)
if (max_speed != absolute_max_speed) { if (max_speed != absolute_max_speed) {
/* Apply the engine's rail type curve speed advantage, if it slowed by curves */ /* Apply the engine's rail type curve speed advantage, if it slowed by curves */
const RailtypeInfo *rti = GetRailTypeInfo(v->railtype); const RailtypeInfo *rti = GetRailTypeInfo(this->railtype);
max_speed += (max_speed / 2) * rti->curve_speed; max_speed += (max_speed / 2) * rti->curve_speed;
if (v->tcache.cached_tilt) { if (this->tcache.cached_tilt) {
/* Apply max_speed bonus of 20% for a tilting train */ /* Apply max_speed bonus of 20% for a tilting train */
max_speed += max_speed / 5; max_speed += max_speed / 5;
} }
@ -484,7 +486,7 @@ int GetTrainCurveSpeedLimit(Train *v)
static int GetTrainAcceleration(Train *v, bool mode) static int GetTrainAcceleration(Train *v, bool mode)
{ {
int max_speed = v->tcache.cached_max_curve_speed; int max_speed = v->tcache.cached_max_curve_speed;
assert(max_speed == GetTrainCurveSpeedLimit(v)); // safety check, will be removed later assert(max_speed == v->GetCurveSpeedLimit());
int speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h int speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h
if (IsRailStationTile(v->tile) && v->IsFrontEngine()) { if (IsRailStationTile(v->tile) && v->IsFrontEngine()) {
@ -574,16 +576,16 @@ static int GetTrainAcceleration(Train *v, bool mode)
} }
} }
void UpdateTrainAcceleration(Train *v) void Train::UpdateAcceleration()
{ {
assert(v->IsFrontEngine()); assert(this->IsFrontEngine());
v->max_speed = v->tcache.cached_max_speed; this->max_speed = this->tcache.cached_max_speed;
uint power = v->tcache.cached_power; uint power = this->tcache.cached_power;
uint weight = v->tcache.cached_weight; uint weight = this->tcache.cached_weight;
assert(weight != 0); assert(weight != 0);
v->acceleration = Clamp(power / weight * 4, 1, 255); this->acceleration = Clamp(power / weight * 4, 1, 255);
} }
/** /**
@ -749,7 +751,7 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandF
_new_vehicle_id = v->index; _new_vehicle_id = v->index;
VehicleMove(v, false); VehicleMove(v, false);
TrainConsistChanged(v->First(), false); v->First()->ConsistChanged(false);
UpdateTrainGroupID(v->First()); UpdateTrainGroupID(v->First());
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
@ -930,7 +932,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
AddArticulatedParts(v); AddArticulatedParts(v);
} }
TrainConsistChanged(v, false); v->ConsistChanged(false);
UpdateTrainGroupID(v); UpdateTrainGroupID(v);
if (!HasBit(p2, 1) && !(flags & DC_AUTOREPLACE)) { // check if the cars should be added to the new vehicle if (!HasBit(p2, 1) && !(flags & DC_AUTOREPLACE)) { // check if the cars should be added to the new vehicle
@ -1288,7 +1290,7 @@ static void NormaliseTrainHead(Train *head)
if (head == NULL) return; if (head == NULL) return;
/* Tell the 'world' the train changed. */ /* Tell the 'world' the train changed. */
TrainConsistChanged(head, false); head->ConsistChanged(false);
UpdateTrainGroupID(head); UpdateTrainGroupID(head);
/* Not a front engine, i.e. a free wagon chain. No need to do more. */ /* Not a front engine, i.e. a free wagon chain. No need to do more. */
@ -1692,7 +1694,7 @@ static void ReverseTrainSwapVeh(Train *v, int l, int r)
} }
/* Update train's power incase tiles were different rail type */ /* Update train's power incase tiles were different rail type */
TrainPowerChanged(v); v->PowerChanged();
} }
@ -1909,7 +1911,7 @@ static void ReverseTrainDirection(Train *v)
ClrBit(v->flags, VRF_REVERSING); ClrBit(v->flags, VRF_REVERSING);
/* recalculate cached data */ /* recalculate cached data */
TrainConsistChanged(v, true); v->ConsistChanged(true);
/* update all images */ /* update all images */
for (Vehicle *u = v; u != NULL; u = u->Next()) u->UpdateViewport(false, false); for (Vehicle *u = v; u != NULL; u = u->Next()) u->UpdateViewport(false, false);
@ -2080,7 +2082,7 @@ CommandCost CmdRefitRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
/* Update the train's cached variables */ /* Update the train's cached variables */
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Train *front = v->First(); Train *front = v->First();
TrainConsistChanged(front, false); front->ConsistChanged(false);
SetWindowDirty(WC_VEHICLE_DETAILS, front->index); SetWindowDirty(WC_VEHICLE_DETAILS, front->index);
SetWindowDirty(WC_VEHICLE_DEPOT, front->tile); SetWindowDirty(WC_VEHICLE_DEPOT, front->tile);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0); InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
@ -2350,7 +2352,7 @@ static bool CheckTrainStayInDepot(Train *v)
v->cur_image = v->GetImage(v->direction); v->cur_image = v->GetImage(v->direction);
VehicleMove(v, false); VehicleMove(v, false);
UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner); UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
UpdateTrainAcceleration(v); v->UpdateAcceleration();
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
return false; return false;
@ -2943,8 +2945,8 @@ void Train::MarkDirty()
} while ((v = v->Next()) != NULL); } while ((v = v->Next()) != NULL);
/* need to update acceleration and cached values since the goods on the train changed. */ /* need to update acceleration and cached values since the goods on the train changed. */
TrainCargoChanged(this); this->CargoChanged();
UpdateTrainAcceleration(this); this->UpdateAcceleration();
} }
/** /**
@ -3463,7 +3465,7 @@ static void TrainController(Train *v, Vehicle *nomove)
v->tile = gp.new_tile; v->tile = gp.new_tile;
if (GetTileRailType(gp.new_tile) != GetTileRailType(gp.old_tile)) { if (GetTileRailType(gp.new_tile) != GetTileRailType(gp.old_tile)) {
TrainPowerChanged(v->First()); v->First()->PowerChanged();
} }
v->track = chosen_track; v->track = chosen_track;
@ -3568,7 +3570,7 @@ static void TrainController(Train *v, Vehicle *nomove)
if (v->IsFrontEngine() && v->tick_counter % _settings_game.pf.path_backoff_interval == 0) CheckNextTrainTile(v); if (v->IsFrontEngine() && v->tick_counter % _settings_game.pf.path_backoff_interval == 0) CheckNextTrainTile(v);
} }
if (direction_changed) first->tcache.cached_max_curve_speed = GetTrainCurveSpeedLimit(first); if (direction_changed) first->tcache.cached_max_curve_speed = first->GetCurveSpeedLimit();
return; return;
@ -3624,7 +3626,7 @@ static void DeleteLastWagon(Train *v)
if (first != v) { if (first != v) {
/* Recalculate cached train properties */ /* Recalculate cached train properties */
TrainConsistChanged(first, false); first->ConsistChanged(false);
/* Update the depot window if the first vehicle is in depot - /* Update the depot window if the first vehicle is in depot -
* if v == first, then it is updated in PreDestructor() */ * if v == first, then it is updated in PreDestructor() */
if (first->track == TRACK_BIT_DEPOT) { if (first->track == TRACK_BIT_DEPOT) {

View File

@ -1002,7 +1002,7 @@ void VehicleEnterDepot(Vehicle *v)
UpdateSignalsOnSegment(t->tile, INVALID_DIAGDIR, t->owner); UpdateSignalsOnSegment(t->tile, INVALID_DIAGDIR, t->owner);
t->wait_counter = 0; t->wait_counter = 0;
ClrBit(t->flags, VRF_TOGGLE_REVERSE); ClrBit(t->flags, VRF_TOGGLE_REVERSE);
TrainConsistChanged(t, true); t->ConsistChanged(true);
break; break;
} }