TBTR: Fix various refit issues in refit as incoming vehicle mode
Allow refits to fail in refit as incoming vehicle mode Remove virtual train mode from CmdRefitVehicle Fix refit as incoming for non-head parts being free
This commit is contained in:
@@ -512,7 +512,6 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
|
||||
* Only used if "refit only this vehicle" is false.
|
||||
* - p2 = (bit 24) - Automatic refitting.
|
||||
* - p2 = (bit 25) - Refit only this vehicle. Used only for cloning vehicles.
|
||||
* - p2 = (bit 31) - Is a virtual train (used by template replacement to allow refitting without stopped-in-depot checks)
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
@@ -529,10 +528,9 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||
|
||||
bool auto_refit = HasBit(p2, 24);
|
||||
bool is_virtual_train = v->type == VEH_TRAIN && Train::From(front)->IsVirtual();
|
||||
bool virtual_train_mode = HasBit(p2, 31) || is_virtual_train;
|
||||
bool free_wagon = v->type == VEH_TRAIN && Train::From(front)->IsFreeWagon(); // used by autoreplace/renew
|
||||
|
||||
if (virtual_train_mode) {
|
||||
if (is_virtual_train) {
|
||||
CommandCost ret = CheckOwnership(front->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
} else {
|
||||
@@ -544,7 +542,7 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||
if (v != front && (v->type == VEH_AIRCRAFT)) return CMD_ERROR;
|
||||
|
||||
/* Allow auto-refitting only during loading and normal refitting only in a depot. */
|
||||
if (!virtual_train_mode) {
|
||||
if (!is_virtual_train) {
|
||||
if ((flags & DC_QUERY_COST) == 0 && // used by the refit GUI, including the order refit GUI.
|
||||
!free_wagon && // used by autoreplace/renew
|
||||
(!auto_refit || !front->current_order.IsType(OT_LOADING)) && // refit inside stations
|
||||
|
Reference in New Issue
Block a user