1
0
Fork 0

(svn r20573) -Codechange: free/reserve some bits in the sell vehicle command to increase the vehicle pool limit

release/1.1
rubidium 2010-08-19 20:45:29 +00:00
parent 646fbb628a
commit cc658392eb
5 changed files with 17 additions and 17 deletions

View File

@ -137,7 +137,7 @@
EnforcePrecondition(false, IsValidVehicle(vehicle_id)); EnforcePrecondition(false, IsValidVehicle(vehicle_id));
const Vehicle *v = ::Vehicle::Get(vehicle_id); const Vehicle *v = ::Vehicle::Get(vehicle_id);
return AIObject::DoCommand(0, vehicle_id | (v->type == VEH_TRAIN ? 1 : 0) << 16, 0, GetCmdSellVeh(v)); return AIObject::DoCommand(0, vehicle_id | (v->type == VEH_TRAIN ? 1 : 0) << 20, 0, GetCmdSellVeh(v));
} }
/* static */ bool AIVehicle::_SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons) /* static */ bool AIVehicle::_SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons)
@ -148,7 +148,7 @@
const Train *v = ::Train::Get(vehicle_id); const Train *v = ::Train::Get(vehicle_id);
while (wagon-- > 0) v = v->GetNextUnit(); while (wagon-- > 0) v = v->GetNextUnit();
return AIObject::DoCommand(0, v->index | (sell_attached_wagons ? 1 : 0) << 16, 0, CMD_SELL_VEHICLE); return AIObject::DoCommand(0, v->index | (sell_attached_wagons ? 1 : 0) << 20, 0, CMD_SELL_VEHICLE);
} }
/* static */ bool AIVehicle::SellWagon(VehicleID vehicle_id, int wagon) /* static */ bool AIVehicle::SellWagon(VehicleID vehicle_id, int wagon)

View File

@ -976,7 +976,7 @@ struct DepotWindow : Window {
this->SetDirty(); this->SetDirty();
int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0; int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
DoCommandP(v->tile, v->index | sell_cmd << 16 | MAKE_ORDER_BACKUP_FLAG, 0, GetCmdSellVeh(v->type)); DoCommandP(v->tile, v->index | sell_cmd << 20 | MAKE_ORDER_BACKUP_FLAG, 0, GetCmdSellVeh(v->type));
break; break;
} }

View File

@ -1383,7 +1383,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint3
/* If we deleted a window then open a new one for the 'new' train */ /* If we deleted a window then open a new one for the 'new' train */
if (IsLocalCompany() && w != NULL) ShowVehicleViewWindow(new_head); if (IsLocalCompany() && w != NULL) ShowVehicleViewWindow(new_head);
} else if (v->IsPrimaryVehicle() && data & (MAKE_ORDER_BACKUP_FLAG >> 16)) { } else if (v->IsPrimaryVehicle() && data & (MAKE_ORDER_BACKUP_FLAG >> 20)) {
OrderBackup::Backup(v, user); OrderBackup::Backup(v, user);
} }

View File

@ -43,7 +43,7 @@ void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p
if (found != NULL) { if (found != NULL) {
found = found->Last(); found = found->Last();
/* put the new wagon at the end of the loco. */ /* put the new wagon at the end of the loco. */
DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, CMD_MOVE_RAIL_VEHICLE); DoCommandP(0, _new_vehicle_id, found->index, CMD_MOVE_RAIL_VEHICLE);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0); InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
} }
} }

View File

@ -79,7 +79,7 @@ CommandCost CmdBuildAircraft (TileIndex tile, DoCommandFlag flags, const Engin
* @param p1 various bitstuffed data * @param p1 various bitstuffed data
* bits 0-15: vehicle type being built. * bits 0-15: vehicle type being built.
* bits 16-31: vehicle type specific bits passed on to the vehicle build functions. * bits 16-31: vehicle type specific bits passed on to the vehicle build functions.
* @param p2 unused * @param p2 User
* @param text unused * @param text unused
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
@ -159,16 +159,16 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *v, uint16 data, uint3
* @param tile unused. * @param tile unused.
* @param flags for command. * @param flags for command.
* @param p1 various bitstuffed data. * @param p1 various bitstuffed data.
* bits 0-15: vehicle ID being sold. * bits 0-19: vehicle ID being sold.
* bits 16-30: vehicle type specific bits passed on to the vehicle build functions. * bits 20-30: vehicle type specific bits passed on to the vehicle build functions.
* bit 31: make a backup of the vehicle's order (if an engine). * bit 31: make a backup of the vehicle's order (if an engine).
* @param p2 unused. * @param p2 User.
* @param text unused. * @param text unused.
* @return the cost of this operation or an error. * @return the cost of this operation or an error.
*/ */
CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 16)); Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
Vehicle *front = v->First(); Vehicle *front = v->First();
@ -191,7 +191,7 @@ CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
} }
if (v->type == VEH_TRAIN) { if (v->type == VEH_TRAIN) {
ret = CmdSellRailWagon(flags, v, GB(p1, 16, 16), p2); ret = CmdSellRailWagon(flags, v, GB(p1, 20, 12), p2);
} else { } else {
ret = CommandCost(EXPENSES_NEW_VEHICLES, -front->value); ret = CommandCost(EXPENSES_NEW_VEHICLES, -front->value);
@ -301,7 +301,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, CargoID new_cid, byt
* Refits a vehicle to the specified cargo type. * Refits a vehicle to the specified cargo type.
* @param tile unused * @param tile unused
* @param flags type of operation * @param flags type of operation
* @param p1 vehicle ID of the train to refit * @param p1 vehicle ID to refit
* @param p2 various bitstuffed elements * @param p2 various bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to * - p2 = (bit 0-7) - the new cargo type to refit to
* - p2 = (bit 8-15) - the new cargo subtype to refit to * - p2 = (bit 8-15) - the new cargo subtype to refit to
@ -506,7 +506,7 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32
CommandCost last_error = CMD_ERROR; CommandCost last_error = CMD_ERROR;
bool had_success = false; bool had_success = false;
for (uint i = 0; i < list.Length(); i++) { for (uint i = 0; i < list.Length(); i++) {
CommandCost ret = DoCommand(tile, list[i]->index | (1 << 16), 0, flags, sell_command); CommandCost ret = DoCommand(tile, list[i]->index | (1 << 20), 0, flags, sell_command);
if (ret.Succeeded()) { if (ret.Succeeded()) {
cost.AddCost(ret); cost.AddCost(ret);
had_success = true; had_success = true;
@ -684,7 +684,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (cost.Failed()) { if (cost.Failed()) {
/* Can't build a part, then sell the stuff we already made; clear up the mess */ /* 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 << 16), 0, flags, GetCmdSellVeh(w_front)); if (w_front != NULL) DoCommand(w_front->tile, w_front->index | (1 << 20), 0, flags, GetCmdSellVeh(w_front));
return cost; return cost;
} }
@ -704,8 +704,8 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (result.Failed()) { if (result.Failed()) {
/* The train can't be joined to make the same consist as the original. /* 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. */ * Sell what we already made (clean up) and return an error. */
DoCommand(w_front->tile, w_front->index | 1 << 16, 0, flags, GetCmdSellVeh(w_front)); DoCommand(w_front->tile, w_front->index | 1 << 20, 0, flags, GetCmdSellVeh(w_front));
DoCommand(w_front->tile, w->index | 1 << 16, 0, flags, GetCmdSellVeh(w)); DoCommand(w_front->tile, w->index | 1 << 20, 0, flags, GetCmdSellVeh(w));
return result; // return error and the message returned from CMD_MOVE_RAIL_VEHICLE return result; // return error and the message returned from CMD_MOVE_RAIL_VEHICLE
} }
} else { } else {
@ -795,7 +795,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (!CheckCompanyHasMoney(total_cost)) { if (!CheckCompanyHasMoney(total_cost)) {
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
/* The vehicle has already been bought, so now it must be sold again. */ /* The vehicle has already been bought, so now it must be sold again. */
DoCommand(w_front->tile, w_front->index | 1 << 16, 0, flags, GetCmdSellVeh(w_front)); DoCommand(w_front->tile, w_front->index | 1 << 20, 0, flags, GetCmdSellVeh(w_front));
} }
return total_cost; return total_cost;
} }