0x004AEA9E
| 212 | |
| 213 | // 0x004AEA9E |
| 214 | static VehicleBody* createBody(const EntityId head, const uint16_t vehicleTypeId, const VehicleObject& vehObject, const uint8_t bodyNumber, VehicleBase* const lastVeh, const ColourScheme colourScheme) |
| 215 | { |
| 216 | auto newBody = createVehicleBaseEntity<VehicleBody>(); |
| 217 | // TODO: move this into the create function somehow |
| 218 | newBody->setSubType(bodyNumber == 0 ? VehicleEntityType::body_start : VehicleEntityType::body_continued); |
| 219 | newBody->owner = getUpdatingCompanyId(); |
| 220 | newBody->head = head; |
| 221 | newBody->bodyIndex = bodyNumber; |
| 222 | newBody->trackType = lastVeh->getTrackType(); |
| 223 | newBody->mode = lastVeh->getTransportMode(); |
| 224 | newBody->tileX = -1; |
| 225 | newBody->tileY = 0; |
| 226 | newBody->tileBaseZ = 0; |
| 227 | newBody->subPosition = 0; |
| 228 | newBody->trackAndDirection = TrackAndDirection(0, 0); |
| 229 | newBody->routingHandle = lastVeh->getRoutingHandle(); |
| 230 | newBody->var_38 = Flags38::unk_0; // different to create bogie |
| 231 | newBody->objectId = vehicleTypeId; |
| 232 | |
| 233 | auto& prng = gPrng1(); |
| 234 | newBody->var_44 = prng.randNext(); |
| 235 | newBody->creationDay = getCurrentDay(); |
| 236 | newBody->animationFrame = 0; |
| 237 | newBody->cargoFrame = 0; |
| 238 | newBody->primaryCargo.acceptedTypes = 0; |
| 239 | newBody->primaryCargo.type = 0xFF; |
| 240 | newBody->primaryCargo.qty = 0; |
| 241 | newBody->chuffSoundIndex = 0; // different to create bogie |
| 242 | newBody->wheelSlipping = 0; |
| 243 | newBody->breakdownFlags = BreakdownFlags::none; |
| 244 | |
| 245 | // different to create bogie |
| 246 | if (bodyNumber == 0) |
| 247 | { |
| 248 | // If the car carries any type of cargo then it will have a primary |
| 249 | // cargo in the first body of the first car component of the car. |
| 250 | // Locomotives do not carry any cargo. |
| 251 | if (vehObject.numSimultaneousCargoTypes != 0) |
| 252 | { |
| 253 | newBody->primaryCargo.maxQty = vehObject.maxCargo[0]; |
| 254 | newBody->primaryCargo.acceptedTypes = vehObject.compatibleCargoCategories[0]; |
| 255 | auto cargoType = Numerics::bitScanForward(newBody->primaryCargo.acceptedTypes); |
| 256 | if (cargoType != -1) |
| 257 | { |
| 258 | newBody->primaryCargo.type = cargoType; |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | newBody->spriteWidth = 1; |
| 264 | newBody->spriteHeightNegative = 1; |
| 265 | newBody->spriteHeightPositive = 1; |
| 266 | |
| 267 | // different onwards to create bogie |
| 268 | auto spriteType = vehObject.carComponents[bodyNumber].bodySpriteInd; |
| 269 | if (spriteType != SpriteIndex::null) |
| 270 | { |
| 271 | if (spriteType & SpriteIndex::isReversed) |
no test coverage detected