mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-21 01:59:44 +00:00
Codechange: move calculating livery recolour offset to Livery
This commit is contained in:
+1
-2
@@ -192,8 +192,7 @@ struct Company : CompanyProperties, CompanyPool::PoolItem<&_company_pool> {
|
||||
*/
|
||||
inline uint8_t GetCompanyRecolourOffset(LiveryScheme livery_scheme, bool use_secondary = true) const
|
||||
{
|
||||
const Livery &l = this->livery[livery_scheme];
|
||||
return use_secondary ? l.colour1 + l.colour2 * 16 : l.colour1;
|
||||
return this->livery[livery_scheme].GetRecolourOffset(use_secondary);
|
||||
}
|
||||
|
||||
static void PostDestructor(size_t index);
|
||||
|
||||
@@ -87,6 +87,16 @@ struct Livery {
|
||||
Flags in_use{}; ///< Livery flags.
|
||||
Colours colour1 = COLOUR_BEGIN; ///< First colour, for all vehicles.
|
||||
Colours colour2 = COLOUR_BEGIN; ///< Second colour, for vehicles with 2CC support.
|
||||
|
||||
/**
|
||||
* Get offset for recolour palette.
|
||||
* @param use_secondary Specify whether to add secondary colour offset to the result.
|
||||
* @return The palette offset.
|
||||
*/
|
||||
inline uint8_t GetRecolourOffset(bool use_secondary = true) const
|
||||
{
|
||||
return use_secondary ? this->colour1 + this->colour2 * 16 : this->colour1;
|
||||
}
|
||||
};
|
||||
|
||||
void ResetCompanyLivery(Company *c);
|
||||
|
||||
@@ -506,7 +506,7 @@ void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8_t view)
|
||||
/* Get the colours of our company! */
|
||||
if (spec->flags.Test(ObjectFlag::Uses2CC)) {
|
||||
const Livery &l = Company::Get(_local_company)->livery[0];
|
||||
palette = SPR_2CCMAP_BASE + l.colour1 + l.colour2 * 16;
|
||||
palette = SPR_2CCMAP_BASE + l.GetRecolourOffset();
|
||||
} else {
|
||||
palette = GetCompanyPalette(_local_company);
|
||||
}
|
||||
|
||||
+1
-2
@@ -2148,8 +2148,7 @@ static PaletteID GetEngineColourMap(EngineID engine_type, CompanyID company, Eng
|
||||
|
||||
const Livery *livery = GetEngineLivery(engine_type, company, parent_engine_type, v, _settings_client.gui.liveries);
|
||||
|
||||
map += livery->colour1;
|
||||
if (twocc) map += livery->colour2 * 16;
|
||||
map += livery->GetRecolourOffset(twocc);
|
||||
|
||||
/* Update cache */
|
||||
if (v != nullptr) const_cast<Vehicle *>(v)->colourmap = map;
|
||||
|
||||
Reference in New Issue
Block a user