Fix object town variables when no town is present

This commit is contained in:
Jonathan G Rennison
2023-06-02 22:19:54 +01:00
parent 3d4133cadb
commit fc80a93672

View File

@@ -334,10 +334,10 @@ static uint32 GetCountAndDistanceOfClosestInstance(uint32 local_id, uint32 grfid
case 0x44: return GetTileOwner(this->tile); case 0x44: return GetTileOwner(this->tile);
/* Get town zone and Manhattan distance of closest town */ /* 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); case 0x45: return (t == nullptr) ? 0 : (GetTownRadiusGroup(t, this->tile) << 16 | std::min(DistanceManhattan(this->tile, t->xy), 0xFFFFu));
/* Get square of Euclidian distance of closest town */ /* Get square of Euclidian distance of closest town */
case 0x46: return DistanceSquare(this->tile, t->xy); case 0x46: return (t == nullptr) ? 0 : DistanceSquare(this->tile, t->xy);
/* Object colour */ /* Object colour */
case 0x47: return this->obj->colour; case 0x47: return this->obj->colour;