summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-18 00:03:08 +0000
committerrubidium <rubidium@openttd.org>2010-08-18 00:03:08 +0000
commit9b8d7048da4c078a0b8d58daf38db04b5cfce114 (patch)
tree3965959589f2b742ff5627c0090f5328c68e5e4e /src
parent4780cc50b200400bb1d05f22532041cd6edd3dc9 (diff)
downloadopenttd-9b8d7048da4c078a0b8d58daf38db04b5cfce114.tar.xz
(svn r20533) -Codechange: shuffle a bit with the bits in the sell command
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_vehicle.cpp4
-rw-r--r--src/depot_gui.cpp2
-rw-r--r--src/vehicle_cmd.cpp16
3 files changed, 12 insertions, 10 deletions
diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp
index f7af218f9..73cb04ac6 100644
--- a/src/ai/api/ai_vehicle.cpp
+++ b/src/ai/api/ai_vehicle.cpp
@@ -137,7 +137,7 @@
EnforcePrecondition(false, IsValidVehicle(vehicle_id));
const Vehicle *v = ::Vehicle::Get(vehicle_id);
- return AIObject::DoCommand(0, vehicle_id, v->type == VEH_TRAIN ? 1 : 0, GetCmdSellVeh(v));
+ return AIObject::DoCommand(0, vehicle_id | (v->type == VEH_TRAIN ? 1 : 0) << 16, 0, GetCmdSellVeh(v));
}
/* static */ bool AIVehicle::_SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons)
@@ -148,7 +148,7 @@
const Train *v = ::Train::Get(vehicle_id);
while (wagon-- > 0) v = v->GetNextUnit();
- return AIObject::DoCommand(0, v->index, sell_attached_wagons ? 1 : 0, CMD_SELL_VEHICLE);
+ return AIObject::DoCommand(0, v->index | (sell_attached_wagons ? 1 : 0) << 16, 0, CMD_SELL_VEHICLE);
}
/* static */ bool AIVehicle::SellWagon(VehicleID vehicle_id, int wagon)
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 3ebc8dfca..159e6adc3 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -983,7 +983,7 @@ struct DepotWindow : Window {
BackupVehicleOrders(v);
}
- if (!DoCommandP(v->tile, v->index, sell_cmd, GetCmdSellVeh(v->type)) && is_engine) _backup_orders_tile = 0;
+ if (!DoCommandP(v->tile, v->index | sell_cmd << 16, 0, GetCmdSellVeh(v->type)) && is_engine) _backup_orders_tile = 0;
break;
}
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 88a0467e8..ad6fb7010 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -155,7 +155,9 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *v, uint16 data);
* Sell a vehicle.
* @param tile unused.
* @param flags for command.
- * @param p1 vehicle ID to be sold.
+ * @param p1 various bitstuffed data.
+ * bits 0-15: vehicle ID being sold.
+ * bits 16-31: vehicle type specific bits passed on to the vehicle build functions.
* @param p2 unused.
* @param text unused.
* @return the cost of this operation or an error.
@@ -175,7 +177,7 @@ CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (!front->IsStoppedInDepot()) return_cmd_error(STR_TRAIN_MUST_BE_STOPPED + front->type);
if (v->type == VEH_TRAIN) {
- ret = CmdSellRailWagon(flags, v, GB(p2, 0, 16));
+ ret = CmdSellRailWagon(flags, v, GB(p1, 16, 16));
} else {
ret = CommandCost(EXPENSES_NEW_VEHICLES, -front->value);
@@ -326,7 +328,7 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32
CommandCost last_error = CMD_ERROR;
bool had_success = false;
for (uint i = 0; i < list.Length(); i++) {
- CommandCost ret = DoCommand(tile, list[i]->index, 1, flags, sell_command);
+ CommandCost ret = DoCommand(tile, list[i]->index | (1 << 16), 0, flags, sell_command);
if (ret.Succeeded()) {
cost.AddCost(ret);
had_success = true;
@@ -597,7 +599,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (cost.Failed()) {
/* Can't build a part, then sell the stuff we already made; clear up the mess */
- if (w_front != NULL) DoCommand(w_front->tile, w_front->index, 1, flags, GetCmdSellVeh(w_front));
+ if (w_front != NULL) DoCommand(w_front->tile, w_front->index | (1 << 16), 0, flags, GetCmdSellVeh(w_front));
return cost;
}
@@ -617,8 +619,8 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (result.Failed()) {
/* The train can't be joined to make the same consist as the original.
* Sell what we already made (clean up) and return an error. */
- DoCommand(w_front->tile, w_front->index, 1, flags, GetCmdSellVeh(w_front));
- DoCommand(w_front->tile, w->index, 1, flags, GetCmdSellVeh(w));
+ DoCommand(w_front->tile, w_front->index | 1 << 16, 0, flags, GetCmdSellVeh(w_front));
+ DoCommand(w_front->tile, w->index | 1 << 16, 0, flags, GetCmdSellVeh(w));
return result; // return error and the message returned from CMD_MOVE_RAIL_VEHICLE
}
} else {
@@ -708,7 +710,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (!CheckCompanyHasMoney(total_cost)) {
if (flags & DC_EXEC) {
/* The vehicle has already been bought, so now it must be sold again. */
- DoCommand(w_front->tile, w_front->index, 1, flags, GetCmdSellVeh(w_front));
+ DoCommand(w_front->tile, w_front->index | 1 << 16, 0, flags, GetCmdSellVeh(w_front));
}
return total_cost;
}