Codechange: Don't store tree counter in the map array
(cherry picked from commit 6c3f351d5a4b0d19a1a265f04f44c70c24c19cd2) See: https://github.com/OpenTTD/OpenTTD/pull/10018
This commit is contained in:
@@ -840,8 +840,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
<li>m2 bits 5..4: ground density</li>
|
<li>m2 bits 5..4: ground density</li>
|
||||||
<li>m2 bits 3..0: update counter, incremented on every periodic processing.<br>
|
|
||||||
on wraparound the growth status is updated (or, if it's <tt>3</tt>, a random action is taken)</li>
|
|
||||||
<li>m3 bits 7..0: type of trees:
|
<li>m3 bits 7..0: type of trees:
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -248,9 +248,6 @@ static void PlaceTree(TileIndex tile, uint32 r)
|
|||||||
if (ground != TREE_GROUND_SNOW_DESERT && ground != TREE_GROUND_ROUGH_SNOW && ground != TREE_GROUND_SHORE) {
|
if (ground != TREE_GROUND_SNOW_DESERT && ground != TREE_GROUND_ROUGH_SNOW && ground != TREE_GROUND_SHORE) {
|
||||||
SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 3);
|
SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the counter to a random start value */
|
|
||||||
SetTreeCounter(tile, (TreeGround)GB(r, 24, 4));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -914,10 +911,13 @@ static void TileLoop_Trees(TileIndex tile)
|
|||||||
|
|
||||||
AmbientSoundEffect(tile);
|
AmbientSoundEffect(tile);
|
||||||
|
|
||||||
uint treeCounter = GetTreeCounter(tile);
|
/* _tick_counter is incremented by 256 between each call, so ignore lower 8 bits.
|
||||||
|
* Also, we add tile % 31 to spread the updates evenly over the map,
|
||||||
|
* where 31 is just some prime number that looks ok. */
|
||||||
|
uint32 cycle = (uint32)tile % 31 + (_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. */
|
/* 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);
|
uint density = GetTreeDensity(tile);
|
||||||
if (density < 3) {
|
if (density < 3) {
|
||||||
SetTreeGroundDensity(tile, TREE_GROUND_GRASS, density + 1);
|
SetTreeGroundDensity(tile, TREE_GROUND_GRASS, density + 1);
|
||||||
@@ -925,11 +925,7 @@ static void TileLoop_Trees(TileIndex tile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetTreeCounter(tile) < 15) {
|
if ((cycle & 15) < 15) return;
|
||||||
AddTreeCounter(tile, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SetTreeCounter(tile, 0);
|
|
||||||
|
|
||||||
if (_settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
|
if (_settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
|
||||||
|
|
||||||
|
@@ -215,50 +215,6 @@ static inline void SetTreeGrowth(TileIndex t, uint g)
|
|||||||
SB(_m[t].m5, 0, 3, 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_tile(IsTileType(t, MP_TREES), t);
|
|
||||||
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_tile(IsTileType(t, MP_TREES), t); // 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_tile(IsTileType(t, MP_TREES), t); // XXX incomplete
|
|
||||||
SB(_m[t].m2, 0, 4, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a tree-tile.
|
* Make a tree-tile.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user