diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 1e45bbe921..35a7777691 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -98,6 +98,7 @@ IndustryLocationDistanceCache *IndustryLocationDistanceCache::instance = nullptr static uint32 GetClosestIndustry(TileIndex tile, IndustryType type, const Industry *current) { + if (type >= NUM_INDUSTRYTYPES) return UINT32_MAX; if (IndustryLocationDistanceCache::instance != nullptr) { IndustryLocationDistanceCache *cache = IndustryLocationDistanceCache::instance; if (!cache->initialised) {