mirror of https://github.com/OpenTTD/OpenTTD
Cleanup: Improve code style for OnTick_Trees
parent
d79ae73c14
commit
c24c075cb3
|
@ -834,10 +834,6 @@ void OnTick_Trees()
|
|||
/* Don't spread trees if that's not allowed */
|
||||
if (_settings_game.construction.extra_tree_placement == ETP_NO_SPREAD || _settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
|
||||
|
||||
uint32_t r;
|
||||
TileIndex tile;
|
||||
TreeType tree;
|
||||
|
||||
/* Skip some tree ticks for map sizes below 256 * 256. 64 * 64 is 16 times smaller, so
|
||||
* this is the maximum number of ticks that are skipped. Number of ticks to skip is
|
||||
* inversely proportional to map size, so that is handled to create a mask. */
|
||||
|
@ -847,23 +843,30 @@ void OnTick_Trees()
|
|||
/* place a tree at a random rainforest spot */
|
||||
if (_settings_game.game_creation.landscape == LT_TROPIC) {
|
||||
for (uint c = Map::ScaleBySize(1); c > 0; c--) {
|
||||
if ((r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
|
||||
CanPlantTreesOnTile(tile, false) &&
|
||||
(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
|
||||
uint32_t r = Random();
|
||||
TileIndex tile = RandomTileSeed(r);
|
||||
if (GetTropicZone(tile) != TROPICZONE_RAINFOREST) continue;
|
||||
if (!CanPlantTreesOnTile(tile, false)) continue;
|
||||
|
||||
TreeType tree = GetRandomTreeType(tile, GB(r, 24, 8));
|
||||
if (tree == TREE_INVALID) continue;
|
||||
|
||||
PlantTreesOnTile(tile, tree, 0, TreeGrowthStage::Growing1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!DecrementTreeCounter() || _settings_game.construction.extra_tree_placement == ETP_SPREAD_RAINFOREST) return;
|
||||
|
||||
/* place a tree at a random spot */
|
||||
r = Random();
|
||||
tile = RandomTileSeed(r);
|
||||
if (CanPlantTreesOnTile(tile, false) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
|
||||
uint32_t r = Random();
|
||||
TileIndex tile = RandomTileSeed(r);
|
||||
if (CanPlantTreesOnTile(tile, false)) {
|
||||
TreeType tree = GetRandomTreeType(tile, GB(r, 24, 8));
|
||||
if (tree != TREE_INVALID) {
|
||||
PlantTreesOnTile(tile, tree, 0, TreeGrowthStage::Growing1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static TrackStatus GetTileTrackStatus_Trees(TileIndex, TransportType, uint, DiagDirection)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue