MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / markInUseObjectsByTile

Function markInUseObjectsByTile

src/OpenLoco/src/Objects/ObjectIndex.cpp:866–993  ·  view source on GitHub ↗

0x00472DA1

Source from the content-addressed store, hash-verified

864
865 // 0x00472DA1
866 static void markInUseObjectsByTile(std::array<std::span<uint8_t>, kMaxObjectTypes>& loadedObjectFlags)
867 {
868 // Iterate the whole map looking for things
869 for (const auto pos : World::getWorldRange())
870 {
871 const auto tile = World::TileManager::get(pos);
872 for (const auto& el : tile)
873 {
874 const auto* elSurface = el.as<World::SurfaceElement>();
875 const auto* elTrack = el.as<World::TrackElement>();
876 const auto* elStation = el.as<World::StationElement>();
877 const auto* elSignal = el.as<World::SignalElement>();
878 const auto* elBuilding = el.as<World::BuildingElement>();
879 const auto* elTree = el.as<World::TreeElement>();
880 const auto* elWall = el.as<World::WallElement>();
881 const auto* elRoad = el.as<World::RoadElement>();
882 const auto* elIndustry = el.as<World::IndustryElement>();
883
884 if (elSurface != nullptr)
885 {
886 loadedObjectFlags[enumValue(ObjectType::land)][elSurface->terrain()] |= (1U << 0);
887 if (elSurface->snowCoverage())
888 {
889 loadedObjectFlags[enumValue(ObjectType::snow)][0] |= (1U << 0);
890 }
891 }
892 else if (elTrack != nullptr)
893 {
894 loadedObjectFlags[enumValue(ObjectType::track)][elTrack->trackObjectId()] |= (1U << 0);
895 if (elTrack->hasBridge())
896 {
897 loadedObjectFlags[enumValue(ObjectType::bridge)][elTrack->bridge()] |= (1U << 0);
898 }
899 for (auto i = 0U; i < 4; ++i)
900 {
901 if (elTrack->hasMod(i))
902 {
903 auto* trackObj = get<TrackObject>(elTrack->trackObjectId());
904 loadedObjectFlags[enumValue(ObjectType::trackExtra)][trackObj->mods[i]] |= (1U << 0);
905 }
906 }
907 }
908 else if (elStation != nullptr)
909 {
910 switch (elStation->stationType())
911 {
912 case StationType::trainStation:
913 loadedObjectFlags[enumValue(ObjectType::trainStation)][elStation->objectId()] |= (1U << 0);
914 break;
915 case StationType::roadStation:
916 loadedObjectFlags[enumValue(ObjectType::roadStation)][elStation->objectId()] |= (1U << 0);
917 break;
918 case StationType::airport:
919 loadedObjectFlags[enumValue(ObjectType::airport)][elStation->objectId()] |= (1U << 0);
920 break;
921 case StationType::docks:
922 loadedObjectFlags[enumValue(ObjectType::dock)][elStation->objectId()] |= (1U << 0);
923 break;

Callers 1

markInUseObjectsFunction · 0.85

Calls 15

getWorldRangeFunction · 0.85
enumValueFunction · 0.85
terrainMethod · 0.80
snowCoverageMethod · 0.80
trackObjectIdMethod · 0.80
stationTypeMethod · 0.80
signalObjectIdMethod · 0.80
treeObjectIdMethod · 0.80
wallObjectIdMethod · 0.80
roadObjectIdMethod · 0.80
levelCrossingObjectIdMethod · 0.80
streetLightStyleMethod · 0.80

Tested by

no test coverage detected