0x004B1C48 Applies the vehicle object lengths to the bogies of the train with some specified starting distance. Bodies are not set as they are calculated later based on the positions of the bogies. returns the final distance
| 991 | // they are calculated later based on the positions of the bogies. |
| 992 | // returns the final distance |
| 993 | static int32_t applyVehicleObjectLengthToBogies(Vehicle& train, const int32_t startDistance) |
| 994 | { |
| 995 | auto distance = startDistance; |
| 996 | for (auto& car : train.cars) |
| 997 | { |
| 998 | const auto* vehicleObj = ObjectManager::get<VehicleObject>(car.front->objectId); |
| 999 | assert(std::distance(car.begin(), car.end()) == vehicleObj->numCarComponents); |
| 1000 | if (car.body->has38Flags(Flags38::isReversed)) |
| 1001 | { |
| 1002 | auto objCarIndex = vehicleObj->numCarComponents - 1; |
| 1003 | for (auto& component : car) |
| 1004 | { |
| 1005 | auto& objCar = vehicleObj->carComponents[objCarIndex]; |
| 1006 | const auto frontLength = objCar.backBogiePosition * -kObjDistToHighPrecisionDistance; |
| 1007 | component.front->remainingDistance = distance + frontLength; |
| 1008 | |
| 1009 | if (objCar.bodySpriteInd != 0xFFU) |
| 1010 | { |
| 1011 | const auto bodyLength = vehicleObj->bodySprites[objCar.bodySpriteInd & 0x7F].halfLength * -(kObjDistToHighPrecisionDistance * 2); |
| 1012 | distance += bodyLength; |
| 1013 | } |
| 1014 | const auto backLength = objCar.frontBogiePosition * kObjDistToHighPrecisionDistance; |
| 1015 | component.back->remainingDistance = distance + backLength; |
| 1016 | |
| 1017 | objCarIndex--; |
| 1018 | } |
| 1019 | } |
| 1020 | else |
| 1021 | { |
| 1022 | auto objCarIndex = 0; |
| 1023 | for (auto& component : car) |
| 1024 | { |
| 1025 | auto& objCar = vehicleObj->carComponents[objCarIndex]; |
| 1026 | const auto frontLength = objCar.frontBogiePosition * -kObjDistToHighPrecisionDistance; |
| 1027 | component.front->remainingDistance = distance + frontLength; |
| 1028 | |
| 1029 | if (objCar.bodySpriteInd != 0xFFU) |
| 1030 | { |
| 1031 | const auto bodyLength = vehicleObj->bodySprites[objCar.bodySpriteInd & 0x7F].halfLength * -(kObjDistToHighPrecisionDistance * 2); |
| 1032 | distance += bodyLength; |
| 1033 | } |
| 1034 | const auto backLength = objCar.backBogiePosition * kObjDistToHighPrecisionDistance; |
| 1035 | component.back->remainingDistance = distance + backLength; |
| 1036 | |
| 1037 | objCarIndex++; |
| 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | return distance; |
| 1042 | } |
| 1043 | |
| 1044 | // 0x004AE2AB |
| 1045 | // head: esi |
no test coverage detected