(svn r23074) -Codechange: Add Vehicle::GetEngine() to simplify code.

This commit is contained in:
frosch
2011-11-01 00:21:08 +00:00
parent c366e0d45f
commit 72cd855978
13 changed files with 45 additions and 33 deletions

View File

@@ -273,7 +273,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
for (; v != NULL; v = (only_this ? NULL : v->Next())) {
if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index) && !only_this) continue;
const Engine *e = Engine::Get(v->engine_type);
const Engine *e = v->GetEngine();
if (!e->CanCarryCargo()) continue;
/* If the vehicle is not refittable, count its capacity nevertheless if the cargo matches */
@@ -789,7 +789,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
break;
}
} else {
const Engine *e = Engine::Get(v->engine_type);
const Engine *e = v->GetEngine();
CargoID initial_cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
if (v->cargo_type != initial_cargo && initial_cargo != CT_INVALID) {