MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GenRandomRoadBits

Function GenRandomRoadBits

src/town_cmd.cpp:1883–1890  ·  view source on GitHub ↗

* Generate a random road block. * The probability of a straight road * is somewhat higher than a curved. * * @return A RoadBits value with 2 bits set */

Source from the content-addressed store, hash-verified

1881 * @return A RoadBits value with 2 bits set
1882 */
1883static RoadBits GenRandomRoadBits()
1884{
1885 uint32_t r = Random();
1886 uint a = GB(r, 0, 2);
1887 uint b = GB(r, 8, 2);
1888 if (a == b) b ^= 2;
1889 return (RoadBits)((ROAD_NW << a) + (ROAD_NW << b));
1890}
1891
1892/**
1893 * Grow the town.

Callers 1

GrowTownFunction · 0.85

Calls 2

GBFunction · 0.85
RandomFunction · 0.50

Tested by

no test coverage detected