Fix #8316: Make sort industries by production and transported with a cargo filter...
[openttd-github.git] / src / townname_type.h
blob2dc23567f0dabd47cd86748f11be26360c8b50d5
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /**
9 * @file townname_type.h
10 * Definition of structures used for generating town names.
13 #ifndef TOWNNAME_TYPE_H
14 #define TOWNNAME_TYPE_H
16 #include "newgrf_townname.h"
17 #include "town_type.h"
18 #include "string_type.h"
19 #include <set>
20 #include <string>
22 typedef std::set<std::string> TownNames;
24 static constexpr uint BUILTIN_TOWNNAME_GENERATOR_COUNT = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; ///< Number of built-in town name generators.
26 /**
27 * Struct holding parameters used to generate town name.
28 * Speeds things up a bit because these values are computed only once per name generation.
30 struct TownNameParams {
31 uint32 grfid; ///< newgrf ID (0 if not used)
32 uint16 type; ///< town name style
34 /**
35 * Initializes this struct from language ID
36 * @param town_name town name 'language' ID
38 TownNameParams(byte town_name)
40 bool grf = town_name >= BUILTIN_TOWNNAME_GENERATOR_COUNT;
41 this->grfid = grf ? GetGRFTownNameId(town_name - BUILTIN_TOWNNAME_GENERATOR_COUNT) : 0;
42 this->type = grf ? GetGRFTownNameType(town_name - BUILTIN_TOWNNAME_GENERATOR_COUNT) : SPECSTR_TOWNNAME_START + town_name;
45 TownNameParams(const Town *t);
48 #endif /* TOWNNAME_TYPE_H */