From 2cf5df2a50e9f28ef4ba93a765bfcf79afcbb20c Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 2 May 2021 00:01:06 +0200 Subject: Fix: [NewGRF] industry variable 66 and object variable 46 clamped the squared-euclidian distance to 16 bit, when they should not. --- src/newgrf_industries.cpp | 4 ++-- src/newgrf_object.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 68f28148c..abae44604 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -286,11 +286,11 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout TileIndex tile = GetNearbyTile(parameter, this->tile, true); return GetTownRadiusGroup(this->industry->town, tile) << 16 | std::min(DistanceManhattan(tile, this->industry->town->xy), 0xFFFFu); } - /* Get square of Euclidian distance of closes town */ + /* Get square of Euclidian distance of closest town */ case 0x66: { if (this->tile == INVALID_TILE) break; TileIndex tile = GetNearbyTile(parameter, this->tile, true); - return GetTownRadiusGroup(this->industry->town, tile) << 16 | std::min(DistanceSquare(tile, this->industry->town->xy), 0xFFFFu); + return DistanceSquare(tile, this->industry->town->xy); } /* Count of industry, distance of closest instance diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp index 649a4b58a..3c069f4c9 100644 --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -303,8 +303,8 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid, /* Get town zone and Manhattan distance of closest town */ case 0x45: return GetTownRadiusGroup(t, this->tile) << 16 | std::min(DistanceManhattan(this->tile, t->xy), 0xFFFFu); - /* Get square of Euclidian distance of closes town */ - case 0x46: return GetTownRadiusGroup(t, this->tile) << 16 | std::min(DistanceSquare(this->tile, t->xy), 0xFFFFu); + /* Get square of Euclidian distance of closest town */ + case 0x46: return DistanceSquare(this->tile, t->xy); /* Object colour */ case 0x47: return this->obj->colour; -- cgit v1.2.3-70-g09d2