Codechange: turn a constant variable into a real constant.

This commit is contained in:
frosch
2021-01-12 22:11:12 +01:00
committed by frosch
parent d17226910d
commit 4ce941bbc2
3 changed files with 15 additions and 18 deletions

View File

@@ -15,11 +15,14 @@
#include "newgrf_townname.h"
#include "town_type.h"
#include "string_type.h"
#include <set>
#include <string>
typedef std::set<std::string> TownNames;
static constexpr uint BUILTIN_TOWNNAME_GENERATOR_COUNT = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; ///< Number of built-in town name generators.
/**
* Struct holding parameters used to generate town name.
* Speeds things up a bit because these values are computed only once per name generation.
@@ -34,10 +37,9 @@ struct TownNameParams {
*/
TownNameParams(byte town_name)
{
extern int _nb_orig_names;
bool grf = town_name >= _nb_orig_names;
this->grfid = grf ? GetGRFTownNameId(town_name - _nb_orig_names) : 0;
this->type = grf ? GetGRFTownNameType(town_name - _nb_orig_names) : SPECSTR_TOWNNAME_START + town_name;
bool grf = town_name >= BUILTIN_TOWNNAME_GENERATOR_COUNT;
this->grfid = grf ? GetGRFTownNameId(town_name - BUILTIN_TOWNNAME_GENERATOR_COUNT) : 0;
this->type = grf ? GetGRFTownNameType(town_name - BUILTIN_TOWNNAME_GENERATOR_COUNT) : SPECSTR_TOWNNAME_START + town_name;
}
TownNameParams(const Town *t);