summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-18 23:27:06 +0000
committerbjarni <bjarni@openttd.org>2005-01-18 23:27:06 +0000
commitb1c4b0f07da9585026460d681786eff7d12df57b (patch)
tree1f738e2f92db00ec961c934644d0f5c4badf9f66 /train_cmd.c
parent31d6f87d80bb42c1fbb8841071937e6d86fe9e86 (diff)
downloadopenttd-b1c4b0f07da9585026460d681786eff7d12df57b.tar.xz
(svn r1561) Fix: autoreplacing a singleheaded engine into a dualheaded engine now adds the the rear engine
autoreplacing a dualheaded engine into a singleheaded engine now sells the rear engine as a sideeffect of this, the price for replacing both engines are now added and displayed once from the depot(instead of two identical numbers written on top of each other, looking like one) fix: cost for autorenew dualheaded engines were doubled and their value where doubled too
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 73fd22399..0f0fd6c5a 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -365,6 +365,35 @@ int32 EstimateTrainCost(const RailVehicleInfo *rvi)
return (rvi->base_cost * (_price.build_railvehicle >> 3)) >> 5;
}
+void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building)
+{
+ u->direction = v->direction;
+ u->owner = v->owner;
+ u->tile = v->tile;
+ u->x_pos = v->x_pos;
+ u->y_pos = v->y_pos;
+ u->z_pos = v->z_pos;
+ u->z_height = 6;
+ u->u.rail.track = 0x80;
+ v->u.rail.first_engine = 0xffff;
+ u->vehstatus = v->vehstatus & ~VS_STOPPED;
+ u->subtype = 2;
+ u->spritenum = v->spritenum + 1;
+ u->cargo_type = v->cargo_type;
+ u->cargo_cap = v->cargo_cap;
+ u->u.rail.railtype = v->u.rail.railtype;
+ if (building) v->next = u;
+ u->engine_type = v->engine_type;
+ u->build_year = v->build_year;
+ if (building)
+ v->value = u->value = v->value >> 1;
+ else
+ u->value = v->value;
+ u->type = VEH_Train;
+ u->cur_image = 0xAC2;
+ VehiclePositionChanged(u);
+}
+
/* Build a railroad vehicle
* p1 = vehicle type id
*/
@@ -442,32 +471,8 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
VehiclePositionChanged(v);
- if (rvi->flags&RVI_MULTIHEAD && (u=AllocateVehicle()) != NULL) {
- u->direction = v->direction;
- u->owner = v->owner;
- u->tile = v->tile;
- u->x_pos = v->x_pos;
- u->y_pos = v->y_pos;
- u->z_pos = v->z_pos;
- u->z_height = 6;
- u->u.rail.track = 0x80;
- v->u.rail.first_engine = 0xffff;
- u->vehstatus = VS_HIDDEN | VS_DEFPAL;
- u->subtype = 2;
- u->spritenum = v->spritenum + 1;
- u->cargo_type = v->cargo_type;
- u->cargo_cap = v->cargo_cap;
- u->u.rail.railtype = v->u.rail.railtype;
-// u->next_in_chain = 0xffff;
- v->next = u;
- u->engine_type = v->engine_type;
- u->build_year = v->build_year;
- v->value = u->value = v->value >> 1;
-// u->day_counter = 0;
- u->type = VEH_Train;
- u->cur_image = 0xAC2;
- VehiclePositionChanged(u);
- }
+ if (rvi->flags&RVI_MULTIHEAD && (u = AllocateVehicle()) != NULL)
+ AddRearEngineToMultiheadedTrain(v, u, true);
UpdateTrainAcceleration(v);
NormalizeTrainVehInDepot(v);