diff --git a/docs/landscape.html b/docs/landscape.html
index 0f9a18bbf5..99243101e6 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -807,8 +807,6 @@
m2 bits 5..4: ground density
- m2 bits 3..0: update counter, incremented on every periodic processing.
- on wraparound the growth status is updated (or, if it's 3, a random action is taken)
m3 bits 7..0: type of trees:
diff --git a/regression/regression/result.txt b/regression/regression/result.txt
index 13a770a8aa..9942857cfb 100644
--- a/regression/regression/result.txt
+++ b/regression/regression/result.txt
@@ -588,7 +588,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
SetName(): false
GetLastErrorString(): ERR_NAME_IS_NOT_UNIQUE
GetName(): Regression
- GetPresidentName(): E. McAlpine
+ GetPresidentName(): J. Green
SetPresidentName(): true
GetPresidentName(): Regression AI
GetBankBalance(): 100000
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 854bb5b56f..4c3e942255 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2334,8 +2334,7 @@ bool AfterLoadGame()
if (IsTileType(t, MP_TREES)) {
uint density = GB(_m[t].m2, 6, 2);
uint ground = GB(_m[t].m2, 4, 2);
- uint counter = GB(_m[t].m2, 0, 4);
- _m[t].m2 = ground << 6 | density << 4 | counter;
+ _m[t].m2 = ground << 6 | density << 4;
}
}
}
@@ -3190,6 +3189,15 @@ bool AfterLoadGame()
}
}
+ if (IsSavegameVersionBeforeOrAt(SLV_MULTITRACK_LEVEL_CROSSINGS)) {
+ /* Reset unused tree counters to reduce the savegame size. */
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (IsTileType(t, MP_TREES)) {
+ SB(_m[t].m2, 0, 4, 0);
+ }
+ }
+ }
+
/* Refresh all level crossings to bar adjacent crossing tiles, if needed. */
for (TileIndex tile = 0; tile < Map::Size(); tile++) {
if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile, false);
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 7ed2f163c6..c42a7ff003 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -174,9 +174,6 @@ static void PlaceTree(TileIndex tile, uint32 r)
if (ground != TREE_GROUND_SNOW_DESERT && ground != TREE_GROUND_ROUGH_SNOW && ground != TREE_GROUND_SHORE) {
SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 3);
}
-
- /* Set the counter to a random start value */
- SetTreeCounter(tile, (TreeGround)GB(r, 24, 4));
}
}
@@ -710,10 +707,14 @@ static void TileLoop_Trees(TileIndex tile)
AmbientSoundEffect(tile);
- uint treeCounter = GetTreeCounter(tile);
+ /* _tick_counter is incremented by 256 between each call, so ignore lower 8 bits.
+ * Also, we use a simple hash to spread the updates evenly over the map.
+ * 11 and 9 are just some co-prime numbers for better spread.
+ */
+ uint32 cycle = 11 * TileX(tile) + 9 * TileY(tile) + (_tick_counter >> 8);
/* Handle growth of grass (under trees/on MP_TREES tiles) at every 8th processings, like it's done for grass on MP_CLEAR tiles. */
- if ((treeCounter & 7) == 7 && GetTreeGround(tile) == TREE_GROUND_GRASS) {
+ if ((cycle & 7) == 7 && GetTreeGround(tile) == TREE_GROUND_GRASS) {
uint density = GetTreeDensity(tile);
if (density < 3) {
SetTreeGroundDensity(tile, TREE_GROUND_GRASS, density + 1);
@@ -723,11 +724,7 @@ static void TileLoop_Trees(TileIndex tile)
if (_settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
- if (GetTreeCounter(tile) < 15) {
- AddTreeCounter(tile, 1);
- return;
- }
- SetTreeCounter(tile, 0);
+ if ((cycle & 15) != 15) return;
switch (GetTreeGrowth(tile)) {
case 3: // regular sized tree
diff --git a/src/tree_map.h b/src/tree_map.h
index e8f68d825d..a01968f08f 100644
--- a/src/tree_map.h
+++ b/src/tree_map.h
@@ -215,50 +215,6 @@ static inline void SetTreeGrowth(TileIndex t, uint g)
SB(_m[t].m5, 0, 3, g);
}
-/**
- * Get the tick counter of a tree tile.
- *
- * Returns the saved tick counter of a given tile.
- *
- * @param t The tile to get the counter value from
- * @pre Tile must be of type MP_TREES
- */
-static inline uint GetTreeCounter(TileIndex t)
-{
- assert(IsTileType(t, MP_TREES));
- return GB(_m[t].m2, 0, 4);
-}
-
-/**
- * Add a value on the tick counter of a tree-tile
- *
- * This function adds a value on the tick counter of a tree-tile.
- *
- * @param t The tile to add the value on
- * @param a The value to add on the tick counter
- * @pre Tile must be of type MP_TREES
- */
-static inline void AddTreeCounter(TileIndex t, int a)
-{
- assert(IsTileType(t, MP_TREES)); // XXX incomplete
- _m[t].m2 += a;
-}
-
-/**
- * Set the tick counter for a tree-tile
- *
- * This function sets directly the tick counter for a tree-tile.
- *
- * @param t The tile to set the tick counter
- * @param c The new tick counter value
- * @pre Tile must be of type MP_TREES
- */
-static inline void SetTreeCounter(TileIndex t, uint c)
-{
- assert(IsTileType(t, MP_TREES)); // XXX incomplete
- SB(_m[t].m2, 0, 4, c);
-}
-
/**
* Make a tree-tile.
*