| 255 | }; |
| 256 | |
| 257 | static DrawItems getDrawItemsForVehicle(const VehicleObject& vehObject, const uint8_t yaw, const uint8_t roll, const ColourScheme colourScheme) |
| 258 | { |
| 259 | DrawItems drawItems{}; |
| 260 | const auto unk11360E8 = kUnk500264[roll & 0x7]; |
| 261 | for (auto i = 0; i < vehObject.numCarComponents; ++i) |
| 262 | { |
| 263 | if (vehObject.hasFlags(VehicleObjectFlags::jacobsBogieFront) && i == 0) |
| 264 | { |
| 265 | continue; |
| 266 | } |
| 267 | if (vehObject.hasFlags(VehicleObjectFlags::jacobsBogieRear) && i + 1 == vehObject.numCarComponents) |
| 268 | { |
| 269 | continue; |
| 270 | } |
| 271 | |
| 272 | auto& componentObject = vehObject.carComponents[i]; |
| 273 | // 0x01136172 |
| 274 | auto unkDist = componentObject.frontBogiePosition; |
| 275 | |
| 276 | if (componentObject.frontBogieSpriteInd != SpriteIndex::null && (vehObject.mode == TransportMode::rail || vehObject.mode == TransportMode::road)) |
| 277 | { |
| 278 | auto unk = yaw; |
| 279 | if (componentObject.bodySpriteInd & SpriteIndex::isReversed) |
| 280 | { |
| 281 | unk ^= 1U << 5; |
| 282 | } |
| 283 | unk /= 2; |
| 284 | |
| 285 | auto& bogieSprites = vehObject.bogieSprites[componentObject.frontBogieSpriteInd]; |
| 286 | if (bogieSprites.hasFlags(BogieSpriteFlags::rotationalSymmetry)) |
| 287 | { |
| 288 | unk &= 0xFU; |
| 289 | } |
| 290 | |
| 291 | const auto rollIndex = (bogieSprites.numFramesPerRotation - 1) & roll; |
| 292 | auto spriteIndex = bogieSprites.numFramesPerRotation * unk + rollIndex + bogieSprites.flatImageIds; |
| 293 | drawItems.items.push_back(DrawItem{ ImageId(spriteIndex, colourScheme), drawItems.totalDistance + unkDist, false }); |
| 294 | } |
| 295 | |
| 296 | auto carComponentLength = 0; |
| 297 | auto backBogieDist = drawItems.totalDistance; |
| 298 | if (componentObject.bodySpriteInd != SpriteIndex::null) |
| 299 | { |
| 300 | auto& bodySprites = vehObject.bodySprites[componentObject.bodySpriteInd & ~(1U << 7)]; |
| 301 | carComponentLength = bodySprites.halfLength * 2; |
| 302 | backBogieDist += carComponentLength; |
| 303 | } |
| 304 | auto unk1136174 = componentObject.backBogiePosition; |
| 305 | backBogieDist -= componentObject.backBogiePosition; |
| 306 | |
| 307 | if (componentObject.backBogieSpriteInd != SpriteIndex::null && (vehObject.mode == TransportMode::rail || vehObject.mode == TransportMode::road)) |
| 308 | { |
| 309 | auto unk = yaw; |
| 310 | if (!(componentObject.bodySpriteInd & SpriteIndex::isReversed)) |
| 311 | { |
| 312 | unk ^= 1U << 5; |
| 313 | } |
| 314 | unk /= 2; |
no test coverage detected