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

Method GetImage

src/roadveh_cmd.cpp:120–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void RoadVehicle::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
121{
122 uint8_t spritenum = this->spritenum;
123
124 if (IsCustomVehicleSpriteNum(spritenum)) {
125 if (spritenum == CUSTOM_VEHICLE_SPRITENUM_REVERSED) direction = ReverseDir(direction);
126 GetCustomVehicleSprite(this, direction, image_type, result);
127 if (result->IsValid()) return;
128
129 spritenum = this->GetEngine()->original_image_index;
130 }
131
132 assert(IsValidImageIndex<VEH_ROAD>(spritenum));
133 SpriteID sprite = direction + _roadveh_images[spritenum];
134
135 if (this->cargo.StoredCount() >= this->cargo_cap / 2U) sprite += _roadveh_full_adder[spritenum];
136
137 result->Set(sprite);
138}
139
140/**
141 * Draw a road vehicle engine.

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected