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

Function buildInitialRoad

src/OpenLoco/src/World/Town.cpp:1598–1631  ·  view source on GitHub ↗

0x00498101

Source from the content-addressed store, hash-verified

1596
1597 // 0x00498101
1598 static void buildInitialRoad(Town& town)
1599 {
1600 // 0x0049807D
1601 auto placeRoadAtTile = [&town](const World::Pos2& loc) {
1602 auto tile = World::TileManager::get(loc);
1603 auto* elSurface = tile.surface();
1604 auto height = elSurface->baseHeight();
1605 if (elSurface->slope())
1606 {
1607 height += 16;
1608 if (elSurface->isSlopeDoubleHeight())
1609 {
1610 height += 16;
1611 }
1612 }
1613
1614 auto roadObjId = getIdealTownRoadId(town);
1615 if (!roadObjId.has_value())
1616 {
1617 return true;
1618 }
1619
1620 GameCommands::RoadPlacementArgs args{};
1621 args.pos = World::Pos3{ loc, height };
1622 args.rotation = town.prng.randNext(3);
1623 args.roadId = 0;
1624 args.mods = 0;
1625 args.bridge = 0xFF;
1626 args.roadObjectId = roadObjId.value();
1627 args.unkFlags = 0;
1628 return GameCommands::doCommand(args, GameCommands::Flags::apply) == GameCommands::kFailure;
1629 };
1630 squareSearch({ town.x, town.y }, 9, placeRoadAtTile);
1631 }
1632
1633 /**
1634 * 0x00498116

Callers 1

growMethod · 0.85

Calls 10

getIdealTownRoadIdFunction · 0.85
squareSearchFunction · 0.85
surfaceMethod · 0.80
baseHeightMethod · 0.80
slopeMethod · 0.80
isSlopeDoubleHeightMethod · 0.80
valueMethod · 0.80
getFunction · 0.70
doCommandFunction · 0.50
randNextMethod · 0.45

Tested by

no test coverage detected