diff --git a/src/landscape.cpp b/src/landscape.cpp index b94e315b95..00640f9486 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -723,11 +723,11 @@ void RunTileLoop() * shift register (LFSR). This allows a deterministic pseudorandom ordering, but * still with minimal state and fast iteration. */ - /* Maximal length LFSR feedback terms, from 12-bit (for 64x64 maps) to 26-bit (for 8kx8k maps). + /* Maximal length LFSR feedback terms, from 12-bit (for 64x64 maps) to 28-bit (for 16kx16k maps). * Extracted from http://www.ece.cmu.edu/~koopman/lfsr/ */ static const uint32 feedbacks[] = { 0xD8F, 0x1296, 0x2496, 0x4357, 0x8679, 0x1030E, 0x206CD, 0x403FE, 0x807B8, 0x1004B2, 0x2006A8, - 0x4004B2, 0x800B87, 0x10004F3, 0x200072D, + 0x4004B2, 0x800B87, 0x10004F3, 0x200072D, 0x40006AE, 0x80009E3, }; assert_compile(lengthof(feedbacks) == MAX_MAP_TILES_BITS - 2 * MIN_MAP_SIZE_BITS + 1); const uint32 feedback = feedbacks[MapLogX() + MapLogY() - 2 * MIN_MAP_SIZE_BITS]; diff --git a/src/map_type.h b/src/map_type.h index 7e50a03140..d2403fdb3d 100644 --- a/src/map_type.h +++ b/src/map_type.h @@ -63,10 +63,10 @@ struct TileIndexDiffC { /** Minimal and maximal map width and height */ static const uint MIN_MAP_SIZE_BITS = 6; ///< Minimal size of map is equal to 2 ^ MIN_MAP_SIZE_BITS static const uint MAX_MAP_SIZE_BITS = 20; ///< Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS -static const uint MAX_MAP_TILES_BITS = 26; ///< Maximal number of tiles in a map is equal to 2 ^ MAX_MAP_TILES_BITS. +static const uint MAX_MAP_TILES_BITS = 28; ///< Maximal number of tiles in a map is equal to 2 ^ MAX_MAP_TILES_BITS. static const uint MIN_MAP_SIZE = 1 << MIN_MAP_SIZE_BITS; ///< Minimal map size = 64 static const uint MAX_MAP_SIZE = 1 << MAX_MAP_SIZE_BITS; ///< Maximal map size = 1M -static const uint MAX_MAP_TILES = 1 << MAX_MAP_TILES_BITS;///< Maximal number of tiles in a map = 64M +static const uint MAX_MAP_TILES = 1 << MAX_MAP_TILES_BITS;///< Maximal number of tiles in a map = 256M (16k x 16k) /** * Approximation of the length of a straight track, relative to a diagonal diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 2ec678aea7..af9094c693 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -699,6 +699,7 @@ static WindowDesc _newgrf_inspect_desc( */ void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid) { + if (index >= (1 << 27)) return; if (!IsNewGRFInspectable(feature, index)) return; WindowNumber wno = GetInspectWindowNumber(feature, index); @@ -718,6 +719,7 @@ void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 gr void InvalidateNewGRFInspectWindow(GrfSpecFeature feature, uint index) { if (feature == GSF_INVALID) return; + if (index >= (1 << 27)) return; WindowNumber wno = GetInspectWindowNumber(feature, index); InvalidateWindowData(WC_NEWGRF_INSPECT, wno); @@ -734,6 +736,7 @@ void InvalidateNewGRFInspectWindow(GrfSpecFeature feature, uint index) void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index) { if (feature == GSF_INVALID) return; + if (index >= (1 << 27)) return; WindowNumber wno = GetInspectWindowNumber(feature, index); DeleteWindowById(WC_NEWGRF_INSPECT, wno); @@ -755,6 +758,7 @@ void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index) */ bool IsNewGRFInspectable(GrfSpecFeature feature, uint index) { + if (index >= (1 << 27)) return false; const NIFeature *nif = GetFeature(GetInspectWindowNumber(feature, index)); if (nif == NULL) return false; return nif->helper->IsInspectable(index);