Changeset - r2677:3b5b37166afc
[Not reviewed]
master
0 2 0
bjarni - 19 years ago 2005-11-19 00:10:20
bjarni@openttd.org
(svn r3219) -Codechange: removed the now obsolite code in the build train command to make half multiheaded engines
2 files changed with 6 insertions and 11 deletions:
0 comments (0 inline, 0 general)
train_cmd.c
Show inline comments
 
@@ -655,14 +655,13 @@ void AddRearEngineToMultiheadedTrain(Veh
 
	VehiclePositionChanged(u);
 
}
 

	
 
/** Build a railroad vehicle.
 
 * @param x,y tile coordinates (depot) where rail-vehicle is built
 
 * @param p1 engine type id
 
 * @param p2 bit 0 build only one engine, even if it is a dualheaded engine.
 
          p2 bit 1 prevents any free cars from being added to the train
 
 * @param p2 bit 0 prevents any free cars from being added to the train
 
 */
 
int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	const RailVehicleInfo *rvi;
 
	int value;
 
	Vehicle *v;
 
@@ -690,17 +689,13 @@ int32 CmdBuildRailVehicle(int x, int y, 
 
	if (!IsCompatibleRail(e->railtype, GetRailType(tile))) return CMD_ERROR;
 

	
 
	if (rvi->flags & RVI_WAGON) return CmdBuildRailWagon(p1, tile, flags);
 

	
 
	value = EstimateTrainCost(rvi);
 

	
 
	//make sure we only pay for half a dualheaded engine if we only requested half of it
 
	if (rvi->flags&RVI_MULTIHEAD && HASBIT(p2,0))
 
		value /= 2;
 

	
 
	num_vehicles = (rvi->flags & RVI_MULTIHEAD && !HASBIT(p2, 0)) ? 2 : 1;
 
	num_vehicles = (rvi->flags & RVI_MULTIHEAD) ? 2 : 1;
 
	num_vehicles += CountArticulatedParts(rvi, p1);
 

	
 
	if (!(flags & DC_QUERY_COST)) {
 
		Vehicle *vl[12]; // Allow for upto 10 artic parts and dual-heads
 
		if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull())
 
			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 
@@ -758,13 +753,13 @@ int32 CmdBuildRailVehicle(int x, int y, 
 

	
 
			v->u.rail.shortest_platform[0] = 255;
 
			v->u.rail.shortest_platform[1] = 0;
 

	
 
			VehiclePositionChanged(v);
 

	
 
			if (rvi->flags & RVI_MULTIHEAD && !HASBIT(p2, 0)) {
 
			if (rvi->flags & RVI_MULTIHEAD) {
 
				SetMultiheaded(v);
 
				AddRearEngineToMultiheadedTrain(vl[0], vl[1], true);
 
				/* Now we need to link the front and rear engines together
 
				 * other_multiheaded_part is the pointer that links to the other half of the engine
 
				 * vl[0] is the front and vl[1] is the rear
 
				 */
 
@@ -774,13 +769,13 @@ int32 CmdBuildRailVehicle(int x, int y, 
 
				AddArticulatedParts(rvi, vl);
 
			}
 

	
 
			TrainConsistChanged(v);
 
			UpdateTrainAcceleration(v);
 

	
 
			if (!HASBIT(p2, 1)) {	// check if the cars should be added to the new vehicle
 
			if (!HASBIT(p2, 0)) {	// check if the cars should be added to the new vehicle
 
				NormalizeTrainVehInDepot(v);
 
			}
 

	
 
			InvalidateWindow(WC_VEHICLE_DEPOT, tile);
 
			RebuildVehicleLists();
 
			InvalidateWindow(WC_COMPANY, v->owner);
vehicle.c
Show inline comments
 
@@ -1562,13 +1562,13 @@ int32 CmdCloneVehicle(int x, int y, uint
 

	
 
		if (IsMultiheaded(v) && !IsTrainEngine(v)) {
 
			/* we build the rear ends of multiheaded trains with the front ones */
 
			continue;
 
		}
 

	
 
		cost = DoCommand(x, y, v->engine_type, 2, flags, CMD_BUILD_VEH(v->type));
 
		cost = DoCommand(x, y, v->engine_type, 1, flags, CMD_BUILD_VEH(v->type));
 

	
 
		if (CmdFailed(cost)) return cost;
 

	
 
		total_cost += cost;
 

	
 
		if (flags & DC_EXEC) {
 
@@ -1647,13 +1647,13 @@ static int32 ReplaceVehicle(Vehicle **w,
 
	const UnitID cached_unitnumber = old_v->unitnumber;
 
	bool new_front = false;
 
	Vehicle *new_v = NULL;
 

	
 
	new_engine_type = p->engine_replacement[old_v->engine_type] == INVALID_ENGINE ? old_v->engine_type : p->engine_replacement[old_v->engine_type];
 

	
 
	cost = DoCommand(old_v->x_pos, old_v->y_pos, new_engine_type, 2, flags, CMD_BUILD_VEH(old_v->type));
 
	cost = DoCommand(old_v->x_pos, old_v->y_pos, new_engine_type, 1, flags, CMD_BUILD_VEH(old_v->type));
 
	if (CmdFailed(cost)) return cost;
 

	
 
	if (flags & DC_EXEC) {
 
		new_v = GetVehicle(_new_vehicle_id);
 
		*w = new_v;	//we changed the vehicle, so MaybeReplaceVehicle needs to work on the new one. Now we tell it what the new one is
 

	
0 comments (0 inline, 0 general)