0x00490ABE
| 69 | |
| 70 | // 0x00490ABE |
| 71 | void RoadStationObject::load(const LoadedObjectHandle& handle, std::span<const std::byte> data, ObjectManager::DependentObjects*) |
| 72 | { |
| 73 | auto remainingData = data.subspan(sizeof(RoadStationObject)); |
| 74 | |
| 75 | auto strRes = ObjectManager::loadStringTable(remainingData, handle, 0); |
| 76 | name = strRes.str; |
| 77 | remainingData = remainingData.subspan(strRes.tableLength); |
| 78 | |
| 79 | std::fill(std::begin(mods), std::end(mods), 0xFF); |
| 80 | |
| 81 | // NOTE: These aren't dependent objects as this can load without the |
| 82 | // related object. |
| 83 | for (auto i = 0; i < numCompatible; ++i) |
| 84 | { |
| 85 | auto& mod = mods[i]; |
| 86 | mod = 0xFF; |
| 87 | |
| 88 | ObjectHeader modHeader = *reinterpret_cast<const ObjectHeader*>(remainingData.data()); |
| 89 | auto res = ObjectManager::findObjectHandle(modHeader); |
| 90 | if (res.has_value()) |
| 91 | { |
| 92 | mod = res->id; |
| 93 | } |
| 94 | remainingData = remainingData.subspan(sizeof(ObjectHeader)); |
| 95 | } |
| 96 | |
| 97 | if (hasFlags(RoadStationFlags::passenger | RoadStationFlags::freight)) |
| 98 | { |
| 99 | ObjectHeader cargoHeader = *reinterpret_cast<const ObjectHeader*>(remainingData.data()); |
| 100 | auto res = ObjectManager::findObjectHandle(cargoHeader); |
| 101 | if (res.has_value()) |
| 102 | { |
| 103 | cargoType = res->id; |
| 104 | } |
| 105 | remainingData = remainingData.subspan(sizeof(ObjectHeader)); |
| 106 | } |
| 107 | |
| 108 | for (size_t i = 0; i < 4; ++i) |
| 109 | { |
| 110 | for (size_t j = 0; j < 4; ++j) |
| 111 | { |
| 112 | cargoOffsetBytes[i][j] = static_cast<uint32_t>(remainingData.data() - data.data()); |
| 113 | |
| 114 | auto* bytes = reinterpret_cast<const int8_t*>(remainingData.data()); |
| 115 | bytes++; // z |
| 116 | auto length = 1; |
| 117 | while (*bytes != -1) |
| 118 | { |
| 119 | length += 4; // x, y, x, y |
| 120 | bytes += 4; |
| 121 | } |
| 122 | length += 4; |
| 123 | remainingData = remainingData.subspan(length); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | auto imgRes = ObjectManager::loadImageTable(remainingData); |
| 128 | image = imgRes.imageOffset; |
nothing calls this directly
no test coverage detected