summaryrefslogtreecommitdiff
path: root/src/vehicle_cmd.cpp
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2019-01-29 08:01:28 +0000
committerPeterN <peter@fuzzle.org>2019-01-29 17:57:28 +0000
commit48fb57550240ea50497f1ab55dff91c583d71ebb (patch)
tree2665202a29170c7e63ce370e46dd77bef3ae9775 /src/vehicle_cmd.cpp
parent498ca6e4eba6477633e4efa28ad32889504c17a6 (diff)
downloadopenttd-48fb57550240ea50497f1ab55dff91c583d71ebb.tar.xz
Fix 11ab3c4ea2f: Vehicles could not be refitted to cargo IDs higher than 32.
Diffstat (limited to 'src/vehicle_cmd.cpp')
-rw-r--r--src/vehicle_cmd.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 9231ad689..9f8e03887 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -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);
}