* Decrement the tree tick counter. * The interval is scaled by map size to allow for the same density regardless of size. * Adjustment for map sizes below the standard 256 * 256 are handled earlier. * @return true if the counter was decremented past zero */
| 952 | * @return true if the counter was decremented past zero |
| 953 | */ |
| 954 | bool DecrementTreeCounter() |
| 955 | { |
| 956 | /* Ensure _trees_tick_ctr can be decremented past zero only once for the largest map size. */ |
| 957 | static_assert(2 * (MAX_MAP_SIZE_BITS - MIN_MAP_SIZE_BITS) - 4 <= std::numeric_limits<uint8_t>::digits); |
| 958 | |
| 959 | /* byte underflow */ |
| 960 | uint8_t old_trees_tick_ctr = _trees_tick_ctr; |
| 961 | _trees_tick_ctr -= Map::ScaleBySize(1); |
| 962 | return old_trees_tick_ctr <= _trees_tick_ctr; |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * Place a random tree on a random tile. |