MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / LiveryHelper

Function LiveryHelper

src/newgrf_engine.cpp:373–387  ·  view source on GitHub ↗

* Determines the livery of an engine. * * This always uses dual company colours independent of GUI settings. So it is desync-safe. * * @param engine Engine type * @param v Vehicle, nullptr in purchase list. * @return Livery to use */

Source from the content-addressed store, hash-verified

371 * @return Livery to use
372 */
373static const Livery *LiveryHelper(EngineID engine, const Vehicle *v)
374{
375 const Livery *l;
376
377 if (v == nullptr) {
378 if (!Company::IsValidID(_current_company)) return nullptr;
379 l = GetEngineLivery(engine, _current_company, EngineID::Invalid(), nullptr, LIT_ALL);
380 } else if (v->IsGroundVehicle()) {
381 l = GetEngineLivery(v->engine_type, v->owner, v->GetGroundVehicleCache()->first_engine, v, LIT_ALL);
382 } else {
383 l = GetEngineLivery(v->engine_type, v->owner, EngineID::Invalid(), v, LIT_ALL);
384 }
385
386 return l;
387}
388
389/**
390 * Helper to get the position of a vehicle within a chain of vehicles.

Callers 2

VehicleGetVariableFunction · 0.85
GetVariableMethod · 0.85

Calls 4

GetEngineLiveryFunction · 0.85
InvalidFunction · 0.85
GetGroundVehicleCacheMethod · 0.80
IsGroundVehicleMethod · 0.45

Tested by

no test coverage detected