mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r3219) -Codechange: removed the now obsolite code in the build train command to make half multiheaded engines
This commit is contained in:
parent
22a4679837
commit
e472fed85a
13
train_cmd.c
13
train_cmd.c
|
@ -658,8 +658,7 @@ void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building)
|
||||||
/** Build a railroad vehicle.
|
/** Build a railroad vehicle.
|
||||||
* @param x,y tile coordinates (depot) where rail-vehicle is built
|
* @param x,y tile coordinates (depot) where rail-vehicle is built
|
||||||
* @param p1 engine type id
|
* @param p1 engine type id
|
||||||
* @param p2 bit 0 build only one engine, even if it is a dualheaded engine.
|
* @param p2 bit 0 prevents any free cars from being added to the train
|
||||||
p2 bit 1 prevents any free cars from being added to the train
|
|
||||||
*/
|
*/
|
||||||
int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
|
@ -693,11 +692,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
value = EstimateTrainCost(rvi);
|
value = EstimateTrainCost(rvi);
|
||||||
|
|
||||||
//make sure we only pay for half a dualheaded engine if we only requested half of it
|
num_vehicles = (rvi->flags & RVI_MULTIHEAD) ? 2 : 1;
|
||||||
if (rvi->flags&RVI_MULTIHEAD && HASBIT(p2,0))
|
|
||||||
value /= 2;
|
|
||||||
|
|
||||||
num_vehicles = (rvi->flags & RVI_MULTIHEAD && !HASBIT(p2, 0)) ? 2 : 1;
|
|
||||||
num_vehicles += CountArticulatedParts(rvi, p1);
|
num_vehicles += CountArticulatedParts(rvi, p1);
|
||||||
|
|
||||||
if (!(flags & DC_QUERY_COST)) {
|
if (!(flags & DC_QUERY_COST)) {
|
||||||
|
@ -761,7 +756,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
VehiclePositionChanged(v);
|
VehiclePositionChanged(v);
|
||||||
|
|
||||||
if (rvi->flags & RVI_MULTIHEAD && !HASBIT(p2, 0)) {
|
if (rvi->flags & RVI_MULTIHEAD) {
|
||||||
SetMultiheaded(v);
|
SetMultiheaded(v);
|
||||||
AddRearEngineToMultiheadedTrain(vl[0], vl[1], true);
|
AddRearEngineToMultiheadedTrain(vl[0], vl[1], true);
|
||||||
/* Now we need to link the front and rear engines together
|
/* Now we need to link the front and rear engines together
|
||||||
|
@ -777,7 +772,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
TrainConsistChanged(v);
|
TrainConsistChanged(v);
|
||||||
UpdateTrainAcceleration(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);
|
NormalizeTrainVehInDepot(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1565,7 +1565,7 @@ int32 CmdCloneVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
continue;
|
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;
|
if (CmdFailed(cost)) return cost;
|
||||||
|
|
||||||
|
@ -1650,7 +1650,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
|
||||||
|
|
||||||
new_engine_type = p->engine_replacement[old_v->engine_type] == INVALID_ENGINE ? old_v->engine_type : p->engine_replacement[old_v->engine_type];
|
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 (CmdFailed(cost)) return cost;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
|
Loading…
Reference in New Issue