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

Function GetRailIcon

src/train_cmd.cpp:516–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516static void GetRailIcon(EngineID engine, bool rear_head, int &y, EngineImageType image_type, VehicleSpriteSeq *result)
517{
518 const Engine *e = Engine::Get(engine);
519 Direction dir = rear_head ? DIR_E : DIR_W;
520 uint8_t spritenum = e->VehInfo<RailVehicleInfo>().image_index;
521
522 if (IsCustomVehicleSpriteNum(spritenum)) {
523 GetCustomVehicleIcon(engine, dir, image_type, result);
524 if (result->IsValid()) {
525 if (e->GetGRF() != nullptr) {
526 y += ScaleSpriteTrad(e->GetGRF()->traininfo_vehicle_pitch);
527 }
528 return;
529 }
530
531 spritenum = Engine::Get(engine)->original_image_index;
532 }
533
534 if (rear_head) spritenum++;
535
536 result->Set(GetDefaultTrainSprite(spritenum, DIR_W));
537}
538
539void DrawTrainEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
540{

Callers 2

DrawTrainEngineFunction · 0.85
GetTrainSpriteSizeFunction · 0.85

Calls 7

IsCustomVehicleSpriteNumFunction · 0.85
GetCustomVehicleIconFunction · 0.85
ScaleSpriteTradFunction · 0.85
GetDefaultTrainSpriteFunction · 0.85
IsValidMethod · 0.45
GetGRFMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected