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

Method GetImage

src/train_cmd.cpp:494–514  ·  view source on GitHub ↗

* Get the sprite to display the train. * @param direction Direction of view/travel. * @param image_type Visualisation context. * @return Sprite to display. */

Source from the content-addressed store, hash-verified

492 * @return Sprite to display.
493 */
494void Train::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
495{
496 uint8_t spritenum = this->spritenum;
497
498 if (this->flags.Test(VehicleRailFlag::Flipped)) direction = ReverseDir(direction);
499
500 if (IsCustomVehicleSpriteNum(spritenum)) {
501 if (spritenum == CUSTOM_VEHICLE_SPRITENUM_REVERSED) direction = ReverseDir(direction);
502 GetCustomVehicleSprite(this, direction, image_type, result);
503 if (result->IsValid()) return;
504
505 spritenum = this->GetEngine()->original_image_index;
506 }
507
508 assert(IsValidImageIndex<VEH_TRAIN>(spritenum));
509 SpriteID sprite = GetDefaultTrainSprite(spritenum, direction);
510
511 if (this->cargo.StoredCount() >= this->cargo_cap / 2U) sprite += _wagon_full_adder[spritenum];
512
513 result->Set(sprite);
514}
515
516static void GetRailIcon(EngineID engine, bool rear_head, int &y, EngineImageType image_type, VehicleSpriteSeq *result)
517{

Callers

nothing calls this directly

Calls 9

ReverseDirFunction · 0.85
IsCustomVehicleSpriteNumFunction · 0.85
GetCustomVehicleSpriteFunction · 0.85
GetDefaultTrainSpriteFunction · 0.85
TestMethod · 0.80
StoredCountMethod · 0.80
IsValidMethod · 0.45
GetEngineMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected