From 0ae7af6e1c6a4d30acddb4e2a0a4791aa02909d2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 6 Oct 2023 11:13:10 +0200 Subject: bbn --- src/path-search.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/path-search.cpp b/src/path-search.cpp index 365791de..f8d0a64f 100644 --- a/src/path-search.cpp +++ b/src/path-search.cpp @@ -130,14 +130,15 @@ auto path_search::always_continue() noexcept -> const pred& { return always_cont void path_search::ensure_allocated(chunk_coords a, chunk_coords b) { + constexpr auto max_chunks = 1uz << 26; auto new_size = (Math::abs(a - b) + Vector2i(3)); auto new_start = Vector2i(std::min(a.x, b.x), std::min(a.y, b.y)) - Vector2i(1); - auto size1 = new_size.product(); - fm_debug_assert(size1 > 0); + auto size1 = (size_t)new_size.product(); + fm_assert(size1 < max_chunks); cache.start = new_start; - if ((size_t)size1 > cache.array.size()) + if (size1 > cache.array.size()) { - cache.array = Array{ValueInit, (size_t)size1}; + cache.array = Array{ValueInit, size1}; cache.size = new_size; } else -- cgit v1.2.3