summaryrefslogtreecommitdiff
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
parent498ca6e4eba6477633e4efa28ad32889504c17a6 (diff)
downloadopenttd-48fb57550240ea50497f1ab55dff91c583d71ebb.tar.xz
Fix 11ab3c4ea2f: Vehicles could not be refitted to cargo IDs higher than 32.
-rw-r--r--src/economy.cpp4
-rw-r--r--src/vehicle_cmd.cpp14
2 files changed, 9 insertions, 9 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index c7ffa96cc..6d3c2a8b2 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1484,7 +1484,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
if (st->goods[cid].cargo.HasCargoFor(next_station)) {
/* Try to find out if auto-refitting would succeed. In case the refit is allowed,
* the returned refit capacity will be greater than zero. */
- DoCommand(v_start->tile, v_start->index, cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_QUERY_COST, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
+ DoCommand(v_start->tile, v_start->index, cid | 1U << 24 | 0xFF << 8 | 1U << 16, DC_QUERY_COST, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
/* Try to balance different loadable cargoes between parts of the consist, so that
* all of them can be loaded. Avoid a situation where all vehicles suddenly switch
* to the first loadable cargo for which there is only one packet. If the capacities
@@ -1507,7 +1507,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
* "via any station" before reserving. We rather produce some more "any station" cargo than
* misrouting it. */
IterateVehicleParts(v_start, ReturnCargoAction(st, INVALID_STATION));
- CommandCost cost = DoCommand(v_start->tile, v_start->index, new_cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_EXEC, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
+ CommandCost cost = DoCommand(v_start->tile, v_start->index, new_cid | 1U << 24 | 0xFF << 8 | 1U << 16, DC_EXEC, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8;
}
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);
}