Add fast paths for clear/tree snow line checks in tile loop
This commit is contained in:
@@ -203,7 +203,13 @@ static void UpdateFences(TileIndex tile)
|
|||||||
/** Convert to or from snowy tiles. */
|
/** Convert to or from snowy tiles. */
|
||||||
static void TileLoopClearAlps(TileIndex tile)
|
static void TileLoopClearAlps(TileIndex tile)
|
||||||
{
|
{
|
||||||
int k = GetTileZ(tile) - GetSnowLine() + 1;
|
int k;
|
||||||
|
if ((int)TileHeight(tile) < GetSnowLine() - 1) {
|
||||||
|
/* Fast path to avoid needing to check all 4 corners */
|
||||||
|
k = -1;
|
||||||
|
} else {
|
||||||
|
k = GetTileZ(tile) - GetSnowLine() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
/* Below the snow line, do nothing if no snow. */
|
/* Below the snow line, do nothing if no snow. */
|
||||||
|
@@ -745,7 +745,13 @@ static void TileLoopTreesDesert(TileIndex tile)
|
|||||||
|
|
||||||
static void TileLoopTreesAlps(TileIndex tile)
|
static void TileLoopTreesAlps(TileIndex tile)
|
||||||
{
|
{
|
||||||
int k = GetTileZ(tile) - GetSnowLine() + 1;
|
int k;
|
||||||
|
if ((int)TileHeight(tile) < GetSnowLine() - 1) {
|
||||||
|
/* Fast path to avoid needing to check all 4 corners */
|
||||||
|
k = -1;
|
||||||
|
} else {
|
||||||
|
k = GetTileZ(tile) - GetSnowLine() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
switch (GetTreeGround(tile)) {
|
switch (GetTreeGround(tile)) {
|
||||||
|
Reference in New Issue
Block a user