diff options
author | frosch <frosch@openttd.org> | 2021-01-12 22:11:12 +0100 |
---|---|---|
committer | frosch <github@elsenhans.name> | 2021-02-14 23:14:07 +0100 |
commit | 4ce941bbc2ac7f2d40d46909af4a3f75fe24ecef (patch) | |
tree | aa11f2f738ee1b7ff3be8b91d01c691e87798290 /src/townname_type.h | |
parent | d17226910d319cb552edc5f43c4c4315109dbe04 (diff) | |
download | openttd-4ce941bbc2ac7f2d40d46909af4a3f75fe24ecef.tar.xz |
Codechange: turn a constant variable into a real constant.
Diffstat (limited to 'src/townname_type.h')
-rw-r--r-- | src/townname_type.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/townname_type.h b/src/townname_type.h index dd95f8f70..2dc23567f 100644 --- a/src/townname_type.h +++ b/src/townname_type.h @@ -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); |