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

Method GetCursorImageOffset

src/train_cmd.cpp:440–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438}
439
440int Train::GetCursorImageOffset() const
441{
442 if (this->gcache.cached_veh_length != 8 && this->flags.Test(VehicleRailFlag::Flipped) && !EngInfo(this->engine_type)->misc_flags.Test(EngineMiscFlag::RailFlips)) {
443 int reference_width = TRAININFO_DEFAULT_VEHICLE_WIDTH;
444
445 const Engine *e = this->GetEngine();
446 if (e->GetGRF() != nullptr && IsCustomVehicleSpriteNum(e->VehInfo<RailVehicleInfo>().image_index)) {
447 reference_width = e->GetGRF()->traininfo_vehicle_width;
448 }
449
450 return ScaleSpriteTrad((this->gcache.cached_veh_length - (int)VEHICLE_LENGTH) * reference_width / (int)VEHICLE_LENGTH);
451 }
452 return 0;
453}
454
455/**
456 * Get the width of a train vehicle image in the GUI.

Callers 1

SetMouseCursorVehicleFunction · 0.80

Calls 6

EngInfoFunction · 0.85
IsCustomVehicleSpriteNumFunction · 0.85
ScaleSpriteTradFunction · 0.85
TestMethod · 0.80
GetEngineMethod · 0.45
GetGRFMethod · 0.45

Tested by

no test coverage detected