Mercurial > hg > openttd
changeset 17163:5cdb72b33b97 draft
(svn r21901) -Codechange: Save some bits in p2 of CmdRefitVehicle.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 23 Jan 2011 13:25:26 +0000 |
parents | 18e173373bb0 |
children | bfc7b87f4672 |
files | src/vehicle_cmd.cpp src/vehicle_gui.cpp |
diffstat | 2 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -316,10 +316,10 @@ * @param flags type of operation * @param p1 vehicle ID to refit * @param p2 various bitstuffed elements - * - p2 = (bit 0-7) - New cargo type to refit to. + * - p2 = (bit 0-4) - New cargo type to refit to. + * - p2 = (bit 7) - Refit only this vehicle. Used only for cloning vehicles. * - p2 = (bit 8-15) - New cargo subtype to refit to. - * - p2 = (bit 16) - Refit only this vehicle. Used only for cloning vehicles. - * - p2 = (bit 17-24) - Number of vehicles to refit. Zero means all vehicles. Only used if "refit only this vehicle" is false. + * - p2 = (bit 16-23) - Number of vehicles to refit. Zero means all vehicles. Only used if "refit only this vehicle" is false. * @param text unused * @return the cost of this operation or an error */ @@ -343,13 +343,13 @@ if (front->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_VEHICLE_IS_DESTROYED); /* Check cargo */ - CargoID new_cid = GB(p2, 0, 8); + CargoID new_cid = GB(p2, 0, 5); byte new_subtype = GB(p2, 8, 8); if (new_cid >= NUM_CARGO) return CMD_ERROR; /* For ships and aircrafts there is always only one. */ - bool only_this = HasBit(p2, 16) || front->type == VEH_SHIP || front->type == VEH_AIRCRAFT; - uint8 num_vehicles = GB(p2, 17, 8); + bool only_this = HasBit(p2, 7) || 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); @@ -759,7 +759,7 @@ /* Find out what's the best sub type */ byte subtype = GetBestFittingSubType(v, w); if (w->cargo_type != v->cargo_type || w->cargo_subtype != subtype) { - CommandCost cost = DoCommand(0, w->index, v->cargo_type | (subtype << 8) | 1U << 16, flags, GetCmdRefitVeh(v)); + CommandCost cost = DoCommand(0, w->index, v->cargo_type | 1U << 7 | (subtype << 8), flags, GetCmdRefitVeh(v)); if (cost.Succeeded()) total_cost.AddCost(cost); }
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -587,7 +587,7 @@ { Vehicle *v = Vehicle::Get(this->window_number); CommandCost cost = DoCommand(v->tile, this->selected_vehicle, option->cargo | option->subtype << 8 | - this->num_vehicles << 17, DC_QUERY_COST, GetCmdRefitVeh(v->type)); + this->num_vehicles << 16, DC_QUERY_COST, GetCmdRefitVeh(v->type)); if (cost.Failed()) return INVALID_STRING_ID; @@ -810,7 +810,7 @@ if (this->order == INVALID_VEH_ORDER_ID) { bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX; - if (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 17, GetCmdRefitVeh(v)) && delete_window) delete this; + if (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window) delete this; } else { if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8 | this->order << 16, CMD_ORDER_REFIT)) delete this; }