From b1c4b0f07da9585026460d681786eff7d12df57b Mon Sep 17 00:00:00 2001 From: bjarni Date: Tue, 18 Jan 2005 23:27:06 +0000 Subject: (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 --- train_cmd.c | 57 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'train_cmd.c') 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); -- cgit v1.2.3-54-g00ecf