| 19 | namespace OpenLoco::GameCommands |
| 20 | { |
| 21 | static World::TrackElement* getElTrackAt(const TrackRemovalArgs& args, const uint8_t flags, const World::Pos3 pos, const uint8_t sequenceIndex) |
| 22 | { |
| 23 | auto tile = World::TileManager::get(pos); |
| 24 | for (auto& el : tile) |
| 25 | { |
| 26 | auto* elTrack = el.as<World::TrackElement>(); |
| 27 | if (elTrack == nullptr) |
| 28 | { |
| 29 | continue; |
| 30 | } |
| 31 | if (elTrack->rotation() != args.rotation) |
| 32 | { |
| 33 | continue; |
| 34 | } |
| 35 | if (elTrack->baseHeight() != pos.z) |
| 36 | { |
| 37 | continue; |
| 38 | } |
| 39 | if (elTrack->sequenceIndex() != sequenceIndex) |
| 40 | { |
| 41 | continue; |
| 42 | } |
| 43 | if (elTrack->trackObjectId() != args.trackObjectId) |
| 44 | { |
| 45 | continue; |
| 46 | } |
| 47 | if (elTrack->trackId() != args.trackId) |
| 48 | { |
| 49 | continue; |
| 50 | } |
| 51 | if (elTrack->isGhost() != ((flags & Flags::ghost) != 0)) |
| 52 | { |
| 53 | continue; |
| 54 | } |
| 55 | if (elTrack->isAiAllocated() != ((flags & Flags::aiAllocated) != 0)) |
| 56 | { |
| 57 | continue; |
| 58 | } |
| 59 | // Ghost only as this is checked elsewhere for non-ghost so that |
| 60 | // neutral company is always allowed |
| 61 | if (elTrack->owner() != getUpdatingCompanyId() && ((flags & Flags::ghost) != 0)) |
| 62 | { |
| 63 | continue; |
| 64 | } |
| 65 | return elTrack; |
| 66 | } |
| 67 | return nullptr; |
| 68 | }; |
| 69 | |
| 70 | // 0x0049CC23 |
| 71 | static currency32_t trackRemoveCost(const TrackRemovalArgs& args, const World::TrackData::PreviewTrack trackPiece0, const World::Pos3 trackStart, const uint8_t flags) |
no test coverage detected