Codechange: pass the randomizer directly to the town name generation

This commit is contained in:
Rubidium
2023-01-13 22:31:09 +01:00
committed by rubidium42
parent b3b8c3fd2d
commit 3373128233
6 changed files with 10 additions and 7 deletions

View File

@@ -112,11 +112,12 @@ bool VerifyTownName(uint32 r, const TownNameParams *par, TownNames *town_names)
/**
* Generates valid town name.
* @param randomizer the source of random data for generating the name
* @param townnameparts if a name is generated, it's stored there
* @param town_names if a name is generated, check its uniqueness with the set
* @return true iff a name was generated
*/
bool GenerateTownName(uint32 *townnameparts, TownNames *town_names)
bool GenerateTownName(Randomizer &randomizer, uint32 *townnameparts, TownNames *town_names)
{
TownNameParams par(_settings_game.game_creation.town_name);
@@ -130,7 +131,7 @@ bool GenerateTownName(uint32 *townnameparts, TownNames *town_names)
* the other towns may take considerable amount of time (10000 is
* too much). */
for (int i = 1000; i != 0; i--) {
uint32 r = _generating_world ? Random() : InteractiveRandom();
uint32 r = randomizer.Next();
if (!VerifyTownName(r, &par, town_names)) continue;
*townnameparts = r;