Fix 11ab3c4ea2: Vehicles could not be refitted to cargo IDs higher than 32.

This commit is contained in:
2019-01-29 08:01:28 +00:00
committed by PeterN
parent 498ca6e4eb
commit 48fb575502
2 changed files with 9 additions and 9 deletions

View File

@@ -420,12 +420,12 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
* @param flags type of operation
* @param p1 vehicle ID to refit
* @param p2 various bitstuffed elements
* - p2 = (bit 0-4) - New cargo type to refit to.
* - p2 = (bit 6) - Automatic refitting.
* - p2 = (bit 7) - Refit only this vehicle. Used only for cloning vehicles.
* - p2 = (bit 0-7) - New cargo type to refit to.
* - p2 = (bit 8-15) - New cargo subtype to refit to. 0xFF means to try keeping the same subtype according to GetBestFittingSubType().
* - p2 = (bit 16-23) - Number of vehicles to refit (not counting articulated parts). Zero means all 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.
* @param text unused
* @return the cost of this operation or an error
*/
@@ -443,7 +443,7 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
CommandCost ret = CheckOwnership(front->owner);
if (ret.Failed()) return ret;
bool auto_refit = HasBit(p2, 6);
bool auto_refit = HasBit(p2, 24);
bool free_wagon = v->type == VEH_TRAIN && Train::From(front)->IsFreeWagon(); // used by autoreplace/renew
/* Don't allow shadows and such to be refitted. */
@@ -460,12 +460,12 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (front->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_VEHICLE_IS_DESTROYED);
/* Check cargo */
CargoID new_cid = GB(p2, 0, 5);
CargoID new_cid = GB(p2, 0, 8);
byte new_subtype = GB(p2, 8, 8);
if (new_cid >= NUM_CARGO) return CMD_ERROR;
/* For ships and aircraft there is always only one. */
bool only_this = HasBit(p2, 7) || front->type == VEH_SHIP || front->type == VEH_AIRCRAFT;
bool only_this = HasBit(p2, 25) || front->type == VEH_SHIP || front->type == VEH_AIRCRAFT;
uint8 num_vehicles = GB(p2, 16, 8);
CommandCost cost = RefitVehicle(v, only_this, num_vehicles, new_cid, new_subtype, flags, auto_refit);
@@ -899,7 +899,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
/* Find out what's the best sub type */
byte subtype = GetBestFittingSubType(v, w, v->cargo_type);
if (w->cargo_type != v->cargo_type || w->cargo_subtype != subtype) {
CommandCost cost = DoCommand(0, w->index, v->cargo_type | 1U << 7 | (subtype << 8), flags, GetCmdRefitVeh(v));
CommandCost cost = DoCommand(0, w->index, v->cargo_type | 1U << 25 | (subtype << 8), flags, GetCmdRefitVeh(v));
if (cost.Succeeded()) total_cost.AddCost(cost);
}