mirror of https://github.com/OpenTTD/OpenTTD
(svn r25698) -Fix [FS#5700]: Autoreplace/renew also refits free wagons.
parent
8f95bab001
commit
fbe6b92b1d
|
@ -418,7 +418,7 @@ int Train::GetCurrentMaxSpeed() const
|
||||||
/** Update acceleration of the train from the cached power and weight. */
|
/** Update acceleration of the train from the cached power and weight. */
|
||||||
void Train::UpdateAcceleration()
|
void Train::UpdateAcceleration()
|
||||||
{
|
{
|
||||||
assert(this->IsFrontEngine());
|
assert(this->IsFrontEngine() || this->IsFreeWagon());
|
||||||
|
|
||||||
uint power = this->gcache.cached_power;
|
uint power = this->gcache.cached_power;
|
||||||
uint weight = this->gcache.cached_weight;
|
uint weight = this->gcache.cached_weight;
|
||||||
|
|
|
@ -447,11 +447,12 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
bool auto_refit = HasBit(p2, 6);
|
bool auto_refit = HasBit(p2, 6);
|
||||||
|
bool free_wagon = v->type == VEH_TRAIN && Train::From(front)->IsFreeWagon(); // used by autoreplace/renew
|
||||||
|
|
||||||
/* Don't allow shadows and such to be refitted. */
|
/* Don't allow shadows and such to be refitted. */
|
||||||
if (v != front && (v->type == VEH_SHIP || v->type == VEH_AIRCRAFT)) return CMD_ERROR;
|
if (v != front && (v->type == VEH_SHIP || v->type == VEH_AIRCRAFT)) return CMD_ERROR;
|
||||||
/* Allow auto-refitting only during loading and normal refitting only in a depot. */
|
/* Allow auto-refitting only during loading and normal refitting only in a depot. */
|
||||||
if ((!auto_refit || !front->current_order.IsType(OT_LOADING)) && !front->IsStoppedInDepot()) return_cmd_error(STR_ERROR_TRAIN_MUST_BE_STOPPED_INSIDE_DEPOT + front->type);
|
if (!free_wagon && (!auto_refit || !front->current_order.IsType(OT_LOADING)) && !front->IsStoppedInDepot()) return_cmd_error(STR_ERROR_TRAIN_MUST_BE_STOPPED_INSIDE_DEPOT + front->type);
|
||||||
if (front->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_VEHICLE_IS_DESTROYED);
|
if (front->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_VEHICLE_IS_DESTROYED);
|
||||||
|
|
||||||
/* Check cargo */
|
/* Check cargo */
|
||||||
|
@ -490,9 +491,11 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
}
|
}
|
||||||
front->MarkDirty();
|
front->MarkDirty();
|
||||||
|
|
||||||
InvalidateWindowData(WC_VEHICLE_DETAILS, front->index);
|
if (!free_wagon) {
|
||||||
|
InvalidateWindowData(WC_VEHICLE_DETAILS, front->index);
|
||||||
|
InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
|
||||||
|
}
|
||||||
SetWindowDirty(WC_VEHICLE_DEPOT, front->tile);
|
SetWindowDirty(WC_VEHICLE_DEPOT, front->tile);
|
||||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
|
|
||||||
} else {
|
} else {
|
||||||
/* Always invalidate the cache; querycost might have filled it. */
|
/* Always invalidate the cache; querycost might have filled it. */
|
||||||
v->InvalidateNewGRFCacheOfChain();
|
v->InvalidateNewGRFCacheOfChain();
|
||||||
|
|
Loading…
Reference in New Issue