0x004B841B
| 337 | |
| 338 | // 0x004B841B |
| 339 | void VehicleObject::load(const LoadedObjectHandle& handle, [[maybe_unused]] std::span<const std::byte> data, ObjectManager::DependentObjects* dependencies) |
| 340 | { |
| 341 | auto remainingData = data.subspan(sizeof(VehicleObject)); |
| 342 | |
| 343 | auto strRes = ObjectManager::loadStringTable(remainingData, handle, 0); |
| 344 | name = strRes.str; |
| 345 | remainingData = remainingData.subspan(strRes.tableLength); |
| 346 | |
| 347 | trackType = 0xFF; |
| 348 | if (!hasFlags(VehicleObjectFlags::anyRoadType) && (mode == TransportMode::rail || mode == TransportMode::road)) |
| 349 | { |
| 350 | ObjectHeader trackHeader = *reinterpret_cast<const ObjectHeader*>(remainingData.data()); |
| 351 | if (dependencies != nullptr) |
| 352 | { |
| 353 | dependencies->required.push_back(trackHeader); |
| 354 | } |
| 355 | auto res = ObjectManager::findObjectHandle(trackHeader); |
| 356 | if (res.has_value()) |
| 357 | { |
| 358 | trackType = res->id; |
| 359 | } |
| 360 | remainingData = remainingData.subspan(sizeof(ObjectHeader)); |
| 361 | } |
| 362 | |
| 363 | // Load Extra |
| 364 | for (auto i = 0U, index = 0U; i < numTrackExtras; ++i) |
| 365 | { |
| 366 | ObjectHeader modHeader = *reinterpret_cast<const ObjectHeader*>(remainingData.data()); |
| 367 | if (dependencies != nullptr) |
| 368 | { |
| 369 | dependencies->required.push_back(modHeader); |
| 370 | } |
| 371 | auto res = ObjectManager::findObjectHandle(modHeader); |
| 372 | if (res.has_value()) |
| 373 | { |
| 374 | requiredTrackExtras[index++] = res->id; |
| 375 | } |
| 376 | remainingData = remainingData.subspan(sizeof(ObjectHeader)); |
| 377 | } |
| 378 | |
| 379 | std::fill(std::begin(cargoTypeSpriteOffsets), std::end(cargoTypeSpriteOffsets), 0); |
| 380 | std::fill(std::begin(compatibleCargoCategories), std::end(compatibleCargoCategories), 0); |
| 381 | numSimultaneousCargoTypes = 0; |
| 382 | |
| 383 | for (auto i = 0U; i < std::size(compatibleCargoCategories); ++i) |
| 384 | { |
| 385 | const auto index = numSimultaneousCargoTypes; |
| 386 | maxCargo[index] = *reinterpret_cast<const uint8_t*>(remainingData.data()); |
| 387 | remainingData = remainingData.subspan(sizeof(uint8_t)); |
| 388 | if (maxCargo[index] == 0) |
| 389 | { |
| 390 | continue; |
| 391 | } |
| 392 | while (*reinterpret_cast<const CargoCategory*>(remainingData.data()) != CargoCategory::null) |
| 393 | { |
| 394 | const auto cargoCategory = *reinterpret_cast<const CargoCategory*>(remainingData.data()); |
| 395 | remainingData = remainingData.subspan(sizeof(CargoCategory)); |
| 396 | const auto cargoTypeSpriteOffset = *reinterpret_cast<const uint8_t*>(remainingData.data()); |
nothing calls this directly
no test coverage detected