Changeset - r25362:c9c529231562
[Not reviewed]
master
0 2 0
frosch - 3 years ago 2021-05-01 22:01:06
frosch@openttd.org
Fix: [NewGRF] industry variable 66 and object variable 46 clamped the squared-euclidian distance to 16 bit, when they should not.
2 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/newgrf_industries.cpp
Show inline comments
 
@@ -286,11 +286,11 @@ static uint32 GetCountAndDistanceOfClose
 
			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
src/newgrf_object.cpp
Show inline comments
 
@@ -303,8 +303,8 @@ static uint32 GetCountAndDistanceOfClose
 
		/* 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;
0 comments (0 inline, 0 general)