Changeset - r15880:31488f9ccdfa
[Not reviewed]
master
0 6 0
rubidium - 14 years ago 2010-08-19 20:42:00
rubidium@openttd.org
(svn r20572) -Codechange: free/reserve some bits in the wagon move command to increase the vehicle pool limit
6 files changed with 14 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_vehicle.cpp
Show inline comments
 
@@ -99,13 +99,13 @@
 
	const Train *w = NULL;
 
	if (dest_vehicle_id != -1) {
 
		w = ::Train::Get(dest_vehicle_id);
 
		while (dest_wagon-- > 0) w = w->GetNextUnit();
 
	}
 

	
 
	return AIObject::DoCommand(0, v->index | ((w == NULL ? ::INVALID_VEHICLE : w->index) << 16), move_attached_wagons ? 1 : 0, CMD_MOVE_RAIL_VEHICLE);
 
	return AIObject::DoCommand(0, v->index | (move_attached_wagons ? 1 : 0) << 20, w == NULL ? ::INVALID_VEHICLE : w->index, CMD_MOVE_RAIL_VEHICLE);
 
}
 

	
 
/* static */ bool AIVehicle::MoveWagon(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon)
 
{
 
	return _MoveWagonInternal(source_vehicle_id, source_wagon, false, dest_vehicle_id, dest_wagon);
 
}
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -306,13 +306,13 @@ static inline CommandCost StartStopVehic
 
 * @param flags the command flags to use
 
 * @param whole_chain move all vehicles following 'v' (true), or only 'v' (false)
 
 * @return success or error
 
 */
 
static inline CommandCost MoveVehicle(const Vehicle *v, const Vehicle *after, DoCommandFlag flags, bool whole_chain)
 
{
 
	return DoCommand(0, v->index | (after != NULL ? after->index : INVALID_VEHICLE) << 16, whole_chain ? 1 : 0, flags, CMD_MOVE_RAIL_VEHICLE);
 
	return DoCommand(0, v->index | (whole_chain ? 1 : 0) << 20, after != NULL ? after->index : INVALID_VEHICLE, flags, CMD_MOVE_RAIL_VEHICLE);
 
}
 

	
 
/**
 
 * Copy head specific things to the new vehicle chain after it was successfully constructed
 
 * @param old_head The old front vehicle (no wagons attached anymore)
 
 * @param new_head The new head of the completely replaced vehicle chain
src/depot_gui.cpp
Show inline comments
 
@@ -160,13 +160,13 @@ static void TrainDepotMoveVehicle(const 
 
		wagon = wagon->Previous();
 
		if (wagon == NULL) return;
 
	}
 

	
 
	if (wagon == v) return;
 

	
 
	DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
 
	DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == NULL ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
 
}
 

	
 
/**
 
 * Array containing the cell size in pixels of the #DEPOT_WIDGET_MATRIX widget for each vehicle type.
 
 * @note The train vehicle type uses the entire row for each train.
 
 */
src/group_cmd.cpp
Show inline comments
 
@@ -202,13 +202,13 @@ CommandCost CmdRenameGroup(TileIndex til
 
 * Add a vehicle to a group
 
 * @param tile unused
 
 * @param flags type of operation
 
 * @param p1   index of array group
 
 *   - p1 bit 0-15 : GroupID
 
 * @param p2   vehicle to add to a group
 
 *   - p2 bit 0-15 : VehicleID
 
 *   - p2 bit 0-19 : VehicleID
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Vehicle *v = Vehicle::GetIfValid(p2);
src/train_cmd.cpp
Show inline comments
 
@@ -580,13 +580,13 @@ void DrawTrainEngine(int left, int right
 
 * @param tile     tile of the depot where rail-vehicle is built.
 
 * @param flags    type of operation.
 
 * @param e        the engine to build.
 
 * @param ret[out] the vehicle that has been built.
 
 * @return the cost of this operation or an error.
 
 */
 
CommandCost CmdBuildRailWagon(TileIndex tile, DoCommandFlag flags, const Engine *e, Vehicle **ret)
 
static CommandCost CmdBuildRailWagon(TileIndex tile, DoCommandFlag flags, const Engine *e, Vehicle **ret)
 
{
 
	const RailVehicleInfo *rvi = &e->u.rail;
 

	
 
	/* Check that the wagon can drive on the track in question */
 
	if (!IsCompatibleRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
 

	
 
@@ -644,13 +644,13 @@ CommandCost CmdBuildRailWagon(TileIndex 
 
		FOR_ALL_TRAINS(w) {
 
			if (w->tile == tile &&              ///< Same depot
 
					w->IsFreeWagon() &&             ///< A free wagon chain
 
					w->engine_type == e->index &&   ///< Same type
 
					w->First() != v &&              ///< Don't connect to ourself
 
					!(w->vehstatus & VS_CRASHED)) { ///< Not crashed/flooded
 
				DoCommand(0, v->index | (w->Last()->index << 16), 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
 
				DoCommand(0, v->index | 1 << 20, w->Last()->index, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	return CommandCost();
 
@@ -660,13 +660,13 @@ CommandCost CmdBuildRailWagon(TileIndex 
 
static void NormalizeTrainVehInDepot(const Train *u)
 
{
 
	const Train *v;
 
	FOR_ALL_TRAINS(v) {
 
		if (v->IsFreeWagon() && v->tile == u->tile &&
 
				v->track == TRACK_BIT_DEPOT) {
 
			if (DoCommand(0, v->index | (u->index << 16), 1, DC_EXEC,
 
			if (DoCommand(0, v->index | 1 << 20, u->index, DC_EXEC,
 
					CMD_MOVE_RAIL_VEHICLE).Failed())
 
				break;
 
		}
 
	}
 
}
 

	
 
@@ -1140,23 +1140,23 @@ static void NormaliseTrainHead(Train *he
 
/**
 
 * Move a rail vehicle around inside the depot.
 
 * @param tile unused
 
 * @param flags type of operation
 
 *              Note: DC_AUTOREPLACE is set when autoreplace tries to undo its modifications or moves vehicles to temporary locations inside the depot.
 
 * @param p1 various bitstuffed elements
 
 * - p1 (bit  0 - 15) source vehicle index
 
 * - p1 (bit 16 - 31) what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
 
 * @param p2 (bit 0) move all vehicles following the source vehicle
 
 * - p1 (bit  0 - 19) source vehicle index
 
 * - p1 (bit      20) move all vehicles following the source vehicle
 
 * @param p2 what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	VehicleID s = GB(p1, 0, 16);
 
	VehicleID d = GB(p1, 16, 16);
 
	bool move_chain = HasBit(p2, 0);
 
	VehicleID s = GB(p1, 0, 20);
 
	VehicleID d = GB(p2, 0, 20);
 
	bool move_chain = HasBit(p1, 20);
 

	
 
	Train *src = Train::GetIfValid(s);
 
	if (src == NULL) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(src->owner);
 
	if (ret.Failed()) return ret;
src/vehicle_cmd.cpp
Show inline comments
 
@@ -697,13 +697,13 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
				SetBit(Train::From(w)->flags, VRF_REVERSE_DIRECTION);
 
			}
 

	
 
			if (v->type == VEH_TRAIN && !Train::From(v)->IsFrontEngine()) {
 
				/* this s a train car
 
				 * add this unit to the end of the train */
 
				CommandCost result = DoCommand(0, (w_rear->index << 16) | w->index, 1, flags, CMD_MOVE_RAIL_VEHICLE);
 
				CommandCost result = DoCommand(0, w->index | 1 << 20, w_rear->index, flags, CMD_MOVE_RAIL_VEHICLE);
 
				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 << 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
0 comments (0 inline, 0 general)