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

Function OnTick_Trees

src/tree_cmd.cpp:983–1005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

981}
982
983void OnTick_Trees()
984{
985 /* Don't spread trees if that's not allowed */
986 if (_settings_game.construction.extra_tree_placement == ETP_NO_SPREAD || _settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
987
988 /* Skip some tree ticks for map sizes below 256 * 256. 64 * 64 is 16 times smaller, so
989 * this is the maximum number of ticks that are skipped. Number of ticks to skip is
990 * inversely proportional to map size, so that is handled to create a mask. */
991 int skip = Map::ScaleBySize(16);
992 if (skip < 16 && (TimerGameTick::counter & (16 / skip - 1)) != 0) return;
993
994 /* place a tree at a random rainforest spot */
995 if (_settings_game.game_creation.landscape == LandscapeType::Tropic) {
996 for (uint c = Map::ScaleBySize(1); c > 0; c--) {
997 PlantRandomTree(true);
998 }
999 }
1000
1001 if (!DecrementTreeCounter() || _settings_game.construction.extra_tree_placement == ETP_SPREAD_RAINFOREST) return;
1002
1003 /* place a tree at a random spot */
1004 PlantRandomTree(false);
1005}
1006
1007static TrackStatus GetTileTrackStatus_Trees(TileIndex, TransportType, uint, DiagDirection)
1008{

Callers 1

CallLandscapeTickFunction · 0.85

Calls 2

PlantRandomTreeFunction · 0.85
DecrementTreeCounterFunction · 0.85

Tested by

no test coverage detected