diff options
author | frosch <frosch@openttd.org> | 2009-02-18 20:40:24 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-02-18 20:40:24 +0000 |
commit | 336fda62bec39eb9ad1ee966a23faa0886a75309 (patch) | |
tree | b2192b1e198e0ab4398f49ec84b8b3c5feb95f62 /src | |
parent | 3542b1dced698e6518c2f2bb6e397f316dc1e596 (diff) | |
download | openttd-336fda62bec39eb9ad1ee966a23faa0886a75309.tar.xz |
(svn r15517) -Fix [FS#2642](r6455): Wagonoverrides and articulated engine parts use the colour scheme of the engine, but not its recolour callback, nor its 2CC flag. Same applies to roadvehicles.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_engine.cpp | 4 | ||||
-rw-r--r-- | src/vehicle.cpp | 21 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index bda726d92..d05130ee9 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -432,7 +432,9 @@ static uint8 LiveryHelper(EngineID engine, const Vehicle *v) if (!IsValidCompanyID(_current_company)) return 0; l = GetEngineLivery(engine, _current_company, INVALID_ENGINE, NULL); } else if (v->type == VEH_TRAIN) { - l = GetEngineLivery((v->u.rail.first_engine != INVALID_ENGINE && (IsArticulatedPart(v) || UsesWagonOverride(v))) ? v->u.rail.first_engine : v->engine_type, v->owner, v->u.rail.first_engine, v); + l = GetEngineLivery(v->engine_type, v->owner, v->u.rail.first_engine, v); + } else if (v->type == VEH_ROAD) { + l = GetEngineLivery(v->engine_type, v->owner, v->u.road.first_engine, v); } else { l = GetEngineLivery(v->engine_type, v->owner, INVALID_ENGINE, v); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ba7fb4d01..5dc223b94 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1832,6 +1832,13 @@ const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID default: NOT_REACHED(); case VEH_TRAIN: { const RailVehicleInfo *rvi = RailVehInfo(engine_type); + if (v != NULL && parent_engine_type != INVALID_ENGINE && (UsesWagonOverride(v) || (IsArticulatedPart(v) && rvi->railveh_type != RAILVEH_WAGON))) { + /* Wagonoverrides use the coloir scheme of the front engine. + * Articulated parts use the colour scheme of the first part. (Not supported for articulated wagons) */ + engine_type = parent_engine_type; + rvi = RailVehInfo(engine_type); + /* Note: Luckily cargo_type is not needed for engines */ + } if (cargo_type == CT_INVALID) cargo_type = rvi->cargo_type; if (rvi->railveh_type == RAILVEH_WAGON) { @@ -1867,8 +1874,15 @@ const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID } case VEH_ROAD: { + /* Always use the livery of the front */ + if (v != NULL && parent_engine_type != INVALID_ENGINE) { + engine_type = parent_engine_type; + cargo_type = v->First()->cargo_type; + } const RoadVehicleInfo *rvi = RoadVehInfo(engine_type); if (cargo_type == CT_INVALID) cargo_type = rvi->cargo_type; + + /* Important: Use Tram Flag of front part. Luckily engine_type refers to the front part here. */ if (HasBit(EngInfo(engine_type)->misc_flags, EF_ROAD_TRAM)) { /* Tram */ scheme = IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_PASSENGER_TRAM : LS_FREIGHT_TRAM; @@ -1952,10 +1966,9 @@ SpriteID GetEnginePalette(EngineID engine_type, CompanyID company) SpriteID GetVehiclePalette(const Vehicle *v) { if (v->type == VEH_TRAIN) { - return GetEngineColourMap( - (v->u.rail.first_engine != INVALID_ENGINE && (UsesWagonOverride(v) || (IsArticulatedPart(v) && RailVehInfo(v->engine_type)->railveh_type != RAILVEH_WAGON))) ? - v->u.rail.first_engine : v->engine_type, - v->owner, v->u.rail.first_engine, v); + return GetEngineColourMap(v->engine_type, v->owner, v->u.rail.first_engine, v); + } else if (v->type == VEH_ROAD) { + return GetEngineColourMap(v->engine_type, v->owner, v->u.road.first_engine, v); } return GetEngineColourMap(v->engine_type, v->owner, INVALID_ENGINE, v); |