Changeset - r25072:d5140da20c44
[Not reviewed]
master
0 1 0
Patric Stout - 3 years ago 2021-03-25 10:57:28
truebrain@openttd.org
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.
1 file changed with 6 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/genworld_gui.cpp
Show inline comments
 
@@ -1313,6 +1313,12 @@ static void _SetGeneratingWorldProgress(
 
	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;
0 comments (0 inline, 0 general)