From 751434ea638dbb476b188de408eae6f036a35363 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Thu, 25 Mar 2021 11:57:28 +0100 Subject: [PATCH] Fix: placing random trees in SE crashes the game (#8892) This used to work by accident: originally the code checked if GenerateWorld was threaded. If not, it would abort the function. This worked for placing trees, because it was also returning false when it was not active. With the recent changes, that check got removed, and this crash started to happen. So now check if we have a modal window, which is a very solid indication we are generating the world. --- src/genworld_gui.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index f26d43ac39..14abd4b758 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -1313,6 +1313,12 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1); assert(cls < GWP_CLASS_COUNT); + /* Check if we really are generating the world. + * For example, placing trees via the SE also calls this function, but + * shouldn't try to update the progress. + */ + if (!HasModalProgress()) return; + if (IsGeneratingWorldAborted()) { HandleGeneratingWorldAbortion(); return;