From 613c90e78f9847a86701019936473ce4ab5165d5 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 7 Aug 2022 00:11:52 +0100 Subject: [PATCH] Fix GetClosestIndustry with invalid industry type when using cache --- src/newgrf_industries.cpp | 1 + 1 file changed, 1 insertion(+) 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) {