Fix build and refit cost estimation with artic/multihead vehicles.

Trailing vehicle part refit costs were not being added to the cost
estimate.
This commit is contained in:
Jonathan G Rennison
2015-10-12 20:06:59 +01:00
parent f170bc91e1
commit a1b60bcc85
3 changed files with 45 additions and 0 deletions

View File

@@ -159,6 +159,16 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
} else {
bool auto_refit_allowed = false;
value.AddCost(GetRefitCost(NULL, eid, cargo, 0, &auto_refit_allowed));
if (type == VEH_TRAIN || type == VEH_ROAD) {
std::vector<EngineID> engine_ids;
GetArticulatedPartsEngineIDs(eid, false, engine_ids);
for (size_t i = 0; i < engine_ids.size(); i++) {
value.AddCost(GetRefitCost(NULL, engine_ids[i], cargo, 0, &auto_refit_allowed));
}
}
if (type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_MULTIHEAD) {
value.AddCost(GetRefitCost(NULL, eid, cargo, 0, &auto_refit_allowed));
}
}
}
}