0x004A6A5F
| 58 | |
| 59 | // 0x004A6A5F |
| 60 | void TrackObject::load(const LoadedObjectHandle& handle, std::span<const std::byte> data, ObjectManager::DependentObjects* dependencies) |
| 61 | { |
| 62 | auto remainingData = data.subspan(sizeof(TrackObject)); |
| 63 | |
| 64 | auto strRes = ObjectManager::loadStringTable(remainingData, handle, 0); |
| 65 | name = strRes.str; |
| 66 | remainingData = remainingData.subspan(strRes.tableLength); |
| 67 | |
| 68 | // NOTE: These aren't dependent (objects unless otherwise stated) as this object can load without the |
| 69 | // related object. |
| 70 | // Load compatible roads/tracks |
| 71 | compatibleTracks = 0; |
| 72 | compatibleRoads = 0; |
| 73 | for (auto i = 0; i < numCompatible; ++i) |
| 74 | { |
| 75 | ObjectHeader modHeader = *reinterpret_cast<const ObjectHeader*>(remainingData.data()); |
| 76 | auto res = ObjectManager::findObjectHandleFuzzy(modHeader); |
| 77 | if (res.has_value()) |
| 78 | { |
| 79 | if (res->type == ObjectType::track) |
| 80 | { |
| 81 | compatibleTracks |= 1U << res->id; |
| 82 | } |
| 83 | else if (res->type == ObjectType::road) |
| 84 | { |
| 85 | compatibleRoads |= 1U << res->id; |
| 86 | } |
| 87 | } |
| 88 | remainingData = remainingData.subspan(sizeof(ObjectHeader)); |
| 89 | } |
| 90 | |
| 91 | // Load Extra |
| 92 | std::fill(std::begin(mods), std::end(mods), 0xFF); |
| 93 | for (auto i = 0U, index = 0U; i < numMods; ++i) |
| 94 | { |
| 95 | ObjectHeader modHeader = *reinterpret_cast<const ObjectHeader*>(remainingData.data()); |
| 96 | auto res = ObjectManager::findObjectHandle(modHeader); |
| 97 | if (res.has_value() && res->type == ObjectType::trackExtra) |
| 98 | { |
| 99 | mods[index++] = res->id; |
| 100 | } |
| 101 | remainingData = remainingData.subspan(sizeof(ObjectHeader)); |
| 102 | } |
| 103 | |
| 104 | // Load Signals |
| 105 | signals = 0; |
| 106 | for (auto i = 0; i < numSignals; ++i) |
| 107 | { |
| 108 | ObjectHeader modHeader = *reinterpret_cast<const ObjectHeader*>(remainingData.data()); |
| 109 | auto res = ObjectManager::findObjectHandle(modHeader); |
| 110 | if (res.has_value() && res->type == ObjectType::trackSignal) |
| 111 | { |
| 112 | signals |= 1U << res->id; |
| 113 | } |
| 114 | remainingData = remainingData.subspan(sizeof(ObjectHeader)); |
| 115 | } |
| 116 | |
| 117 | // Load Tunnel (DEPENDENT OBJECT) |
nothing calls this directly
no test coverage detected