Avoid unnecessary airport/town noise recalculations during map generation

This commit is contained in:
Jonathan G Rennison
2023-12-26 20:03:25 +00:00
parent ae1729fa50
commit 0a6639bd4b

View File

@@ -36,6 +36,7 @@
#include "tgp.h" #include "tgp.h"
#include "signal_func.h" #include "signal_func.h"
#include "newgrf_industrytiles.h" #include "newgrf_industrytiles.h"
#include "station_func.h"
#include "safeguards.h" #include "safeguards.h"
@@ -63,6 +64,8 @@ GenWorldInfo _gw;
/** Whether we are generating the map or not. */ /** Whether we are generating the map or not. */
bool _generating_world; bool _generating_world;
extern bool _town_noise_no_update;
class AbortGenerateWorldSignal { }; class AbortGenerateWorldSignal { };
/** /**
@@ -71,6 +74,7 @@ class AbortGenerateWorldSignal { };
static void CleanupGeneration() static void CleanupGeneration()
{ {
_generating_world = false; _generating_world = false;
_town_noise_no_update = false;
SetMouseCursorBusy(false); SetMouseCursorBusy(false);
/* Show all vital windows again, because we have hidden them */ /* Show all vital windows again, because we have hidden them */
@@ -94,6 +98,7 @@ static void _GenerateWorld()
try { try {
_generating_world = true; _generating_world = true;
_town_noise_no_update = true;
if (_network_dedicated) DEBUG(net, 3, "Generating map, please wait..."); if (_network_dedicated) DEBUG(net, 3, "Generating map, please wait...");
/* Set the Random() seed to generation_seed so we produce the same map with the same seed */ /* Set the Random() seed to generation_seed so we produce the same map with the same seed */
_random.SetSeed(_settings_game.game_creation.generation_seed); _random.SetSeed(_settings_game.game_creation.generation_seed);
@@ -156,6 +161,8 @@ static void _GenerateWorld()
IncreaseGeneratingWorldProgress(GWP_GAME_INIT); IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
StartupDisasters(); StartupDisasters();
_generating_world = false; _generating_world = false;
_town_noise_no_update = false;
UpdateAirportsNoise();
/* No need to run the tile loop in the scenario editor. */ /* No need to run the tile loop in the scenario editor. */
if (_gw.mode != GWM_EMPTY) { if (_gw.mode != GWM_EMPTY) {