@@ -32,9 +32,7 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
3232 UPDATE_DIALOG_LABEL (" Building World" );
3333 #endif
3434 int buildRetryCount = 20 ;
35- EntranceShuffleError entranceErr = EntranceShuffleError::NONE;
3635 int fillAttemptCount = 0 ;
37- bool successfulFill = false ;
3836 while (buildRetryCount > 0 )
3937 {
4038 for (size_t i = 0 ; i < worlds.size (); i++)
@@ -98,12 +96,8 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
9896
9997 // If race mode is not enabled in any world, then the number of progression
10098 // locations is already fixed and we can check if we have enough locations now
101- if (!ANY_WORLD_HAS_RACE_MODE (worlds))
102- {
103- if (validateEnoughLocations (worlds) == FillError::NOT_ENOUGH_PROGRESSION_LOCATIONS)
104- {
105- return 1 ;
106- }
99+ if (!ANY_WORLD_HAS_RACE_MODE (worlds) && validateEnoughLocations (worlds) == FillError::NOT_ENOUGH_PROGRESSION_LOCATIONS) {
100+ return 1 ;
107101 }
108102
109103 // If the user(s) selected "Overworld" as the placement option for small/big keys
@@ -114,7 +108,7 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
114108 if (settings.progression_dungeons != ProgressionDungeons::Disabled)
115109 {
116110 size_t neededOverworldLocations = 0 ;
117- size_t numOverworldLocations = world.getNumOverworldProgressionLocations ();
111+ const size_t numOverworldLocations = world.getNumOverworldProgressionLocations ();
118112 if (settings.dungeon_small_keys == PlacementOption::Overworld)
119113 {
120114 neededOverworldLocations += filterFromPool (world.getItemPoolReference (), [](const Item& item){return Utility::Str::contains (item.getName (), " Small Key" );}).size ();
@@ -136,8 +130,7 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
136130
137131 // Randomize entrances before placing items
138132 LOG_TO_DEBUG (" Randomizing Entrances" );
139- entranceErr = randomizeEntrances (worlds);
140- if (entranceErr != EntranceShuffleError::NONE)
133+ if (const EntranceShuffleError entranceErr = randomizeEntrances (worlds); entranceErr != EntranceShuffleError::NONE)
141134 {
142135 LOG_TO_DEBUG (" Entrance randomization unsuccessful. Error Code: " + errorToName (entranceErr));
143136 // Return early for errors which can't be resolved by re-shuffling
@@ -148,7 +141,7 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
148141 }
149142
150143 buildRetryCount--;
151- if (buildRetryCount == 0 && entranceErr != EntranceShuffleError::NONE )
144+ if (buildRetryCount == 0 )
152145 {
153146 ErrorLog::getInstance ().log (" Build retry count exceeded. Error: " + errorToName (entranceErr));
154147 if (entranceErr == EntranceShuffleError::NOT_ENOUGH_SPHERE_ZERO_LOCATIONS)
@@ -176,7 +169,7 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
176169 int totalFillAttempts = 10 ;
177170 FillError fillError = FillError::NONE;
178171 #ifndef LOGIC_TESTS
179- std::string message = std::string (" Filling World" ) + (worlds.size () > 1 ? " s" : " " ) + (fillAttemptCount++ > 0 ? " (Attempt " + std::to_string (fillAttemptCount) + " )" : " " );
172+ const std::string message = std::string (" Filling World" ) + (worlds.size () > 1 ? " s" : " " ) + (fillAttemptCount++ > 0 ? " (Attempt " + std::to_string (fillAttemptCount) + " )" : " " );
180173 Utility::platformLog (message);
181174 UPDATE_DIALOG_VALUE (10 );
182175 UPDATE_DIALOG_LABEL (message.c_str ());
@@ -190,18 +183,6 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
190183 }
191184 LOG_TO_DEBUG (" Fill attempt failed completely. Error: " + errorToName (fillError) + " . Will retry " + std::to_string (totalFillAttempts) + " more times" );
192185 clearWorlds (worlds);
193- if (totalFillAttempts == 0 && buildRetryCount == 0 )
194- {
195- ErrorLog::getInstance ().log (" Ran out of retries on fill algorithm" );
196- }
197- }
198-
199- // If we don't have enough locations available, but one of the worlds has race mode enabled,
200- // then try rebuilding the world with different dungeons to increase the number of locations
201- if (fillError == FillError::NOT_ENOUGH_PROGRESSION_LOCATIONS && ANY_WORLD_HAS_RACE_MODE (worlds))
202- {
203- buildRetryCount--;
204- continue ;
205186 }
206187
207188 if (fillError != FillError::NONE)
@@ -215,20 +196,18 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
215196 world.dumpWorldGraph (" World" + std::to_string (world.getWorldId ()));
216197 }
217198 #endif
199+
218200 buildRetryCount--;
219201 if (buildRetryCount == 0 )
220202 {
203+ ErrorLog::getInstance ().log (" Ran out of retries on fill algorithm." );
221204 return 1 ;
222205 }
206+
223207 continue ;
224208 }
225- successfulFill = true ;
226- break ;
227- }
228209
229- if (!successfulFill)
230- {
231- return 1 ;
210+ break ;
232211 }
233212
234213 #ifndef LOGIC_TESTS
@@ -243,8 +222,7 @@ int generateWorlds(WorldPool& worlds, std::vector<Settings>& settingsVector)
243222 UPDATE_DIALOG_VALUE (20 );
244223 UPDATE_DIALOG_LABEL (" Generating Hints" );
245224 #endif
246- auto hintError = generateHints (worlds);
247- if (hintError != HintError::NONE)
225+ if (const HintError err = generateHints (worlds); err != HintError::NONE)
248226 {
249227 return 1 ;
250228 }
0 commit comments