MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / TrackDesignPlaceMaze

Function TrackDesignPlaceMaze

src/openrct2/ride/TrackDesign.cpp:1434–1559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1432}
1433
1434static GameActions::Result TrackDesignPlaceMaze(
1435 TrackDesignState& tds, const TrackDesign& td, const CoordsXYZ& origin, const Ride& ride)
1436{
1437 if (tds.placeOperation == TrackPlaceOperation::drawOutlines)
1438 {
1439 MapSelection::clearSelectedTiles();
1440 gMapSelectArrowPosition = CoordsXYZ{ origin, TileElementHeight(origin) };
1441 gMapSelectArrowDirection = _currentTrackPieceDirection;
1442 }
1443
1444 tds.placeZ = 0;
1445 money64 totalCost = 0;
1446
1447 auto& gameState = getGameState();
1448
1449 for (const auto& maze_element : td.mazeElements)
1450 {
1451 uint8_t rotation = _currentTrackPieceDirection & 3;
1452 CoordsXY mazeMapPos = maze_element.location.ToCoordsXY();
1453 auto mapCoord = mazeMapPos.Rotate(rotation);
1454 mapCoord += origin;
1455
1456 TrackDesignUpdatePreviewBounds(tds, { mapCoord, origin.z });
1457
1458 if (tds.placeOperation == TrackPlaceOperation::drawOutlines)
1459 {
1460 TrackDesignAddSelectedTile(mapCoord);
1461 }
1462
1463 if (tds.placeOperation == TrackPlaceOperation::placeQuery || tds.placeOperation == TrackPlaceOperation::place
1464 || tds.placeOperation == TrackPlaceOperation::placeGhost
1465 || tds.placeOperation == TrackPlaceOperation::placeTrackPreview)
1466 {
1467 CommandFlags flags;
1468 money64 cost = 0;
1469
1470 uint16_t mazeEntry = Numerics::rol16(maze_element.mazeEntry, rotation * 4);
1471
1472 if (tds.placeOperation == TrackPlaceOperation::placeTrackPreview)
1473 {
1474 flags = { CommandFlag::apply, CommandFlag::allowDuringPaused, CommandFlag::noSpend };
1475 }
1476 else if (tds.placeOperation == TrackPlaceOperation::placeGhost)
1477 {
1478 flags = { CommandFlag::apply, CommandFlag::allowDuringPaused, CommandFlag::noSpend, CommandFlag::ghost };
1479 }
1480 else if (tds.placeOperation == TrackPlaceOperation::placeQuery)
1481 {
1482 flags = {};
1483 }
1484 else
1485 {
1486 flags = { CommandFlag::apply };
1487 }
1488 if (tds.isReplay)
1489 {
1490 flags.set(CommandFlag::replay);
1491 }

Callers 1

TrackDesignPlaceVirtualFunction · 0.85

Calls 15

clearSelectedTilesFunction · 0.85
TileElementHeightFunction · 0.85
ExecuteNestedFunction · 0.85
QueryNestedFunction · 0.85
MapIsLocationValidFunction · 0.85
MapGetSurfaceElementAtFunction · 0.85
RideDemolishActionClass · 0.85
ToCoordsXYMethod · 0.80

Tested by

no test coverage detected