Merge branch 'master' into jgrpp

# Conflicts:
#	src/vehicle_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2019-01-31 02:04:02 +00:00
23 changed files with 256 additions and 160 deletions

View File

@@ -465,13 +465,13 @@ 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 5) - Is a virtual train (used by template replacement to allow refitting without stopped-in-depot checks)
* - 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.
* - 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
*/
@@ -486,8 +486,8 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
Vehicle *front = v->First();
bool auto_refit = HasBit(p2, 6);
bool is_virtual_train = HasBit(p2, 5);
bool auto_refit = HasBit(p2, 24);
bool is_virtual_train = HasBit(p2, 31);
bool free_wagon = v->type == VEH_TRAIN && Train::From(front)->IsFreeWagon(); // used by autoreplace/renew
if (is_virtual_train || (v->type == VEH_TRAIN && Train::From(front)->IsVirtual())) {
@@ -516,12 +516,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);
@@ -1468,7 +1468,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);
}