* Get the sprite to display the train. * @param direction Direction of view/travel. * @param image_type Visualisation context. * @return Sprite to display. */
| 492 | * @return Sprite to display. |
| 493 | */ |
| 494 | void 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 | |
| 516 | static void GetRailIcon(EngineID engine, bool rear_head, int &y, EngineImageType image_type, VehicleSpriteSeq *result) |
| 517 | { |
nothing calls this directly
no test coverage detected