* * rct2: 0x006C494B */
| 246 | * rct2: 0x006C494B |
| 247 | */ |
| 248 | ResultWithMessage TrackRemoveStationElement(const CoordsXYZD& loc, RideId rideIndex, CommandFlags flags) |
| 249 | { |
| 250 | auto ride = GetRide(rideIndex); |
| 251 | if (ride == nullptr) |
| 252 | return { false }; |
| 253 | |
| 254 | CoordsXYZD removeLoc = loc; |
| 255 | CoordsXYZD stationBackLoc = loc; |
| 256 | CoordsXYZD stationFrontLoc = loc; |
| 257 | int32_t stationLength = 0; |
| 258 | int32_t ByteF441D1 = -1; |
| 259 | |
| 260 | if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasSinglePieceStation)) |
| 261 | { |
| 262 | TileElement* tileElement = MapGetTrackElementAtWithDirectionFromRide(loc, rideIndex); |
| 263 | if (tileElement != nullptr) |
| 264 | { |
| 265 | if (flags.has(CommandFlag::apply)) |
| 266 | { |
| 267 | ride_remove_station(*ride, loc); |
| 268 | } |
| 269 | } |
| 270 | return { true }; |
| 271 | } |
| 272 | |
| 273 | TileElement* stationElement; |
| 274 | |
| 275 | // Search backwards for more station |
| 276 | CoordsXYZD currentLoc = stationBackLoc; |
| 277 | while ((stationElement = find_station_element(currentLoc, rideIndex)) != nullptr) |
| 278 | { |
| 279 | if (stationElement->asTrack()->GetTrackType() == TrackElemType::endStation) |
| 280 | { |
| 281 | if (flags.has(CommandFlag::apply)) |
| 282 | { |
| 283 | ride_remove_station(*ride, currentLoc); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | stationBackLoc = currentLoc; |
| 288 | ByteF441D1++; |
| 289 | |
| 290 | currentLoc -= CoordsDirectionDelta[currentLoc.direction]; |
| 291 | } |
| 292 | |
| 293 | // Search forwards for more station |
| 294 | currentLoc = stationFrontLoc; |
| 295 | do |
| 296 | { |
| 297 | currentLoc += CoordsDirectionDelta[currentLoc.direction]; |
| 298 | |
| 299 | stationElement = find_station_element(currentLoc, rideIndex); |
| 300 | if (stationElement != nullptr) |
| 301 | { |
| 302 | if (stationElement->asTrack()->GetTrackType() == TrackElemType::endStation) |
| 303 | { |
| 304 | if (flags.has(CommandFlag::apply)) |
| 305 | { |
no test coverage detected