Merge branch 'master' into jgrpp

# Conflicts:
#	cmake/scripts/FindVersion.cmake
#	src/airport_gui.cpp
#	src/industry_gui.cpp
#	src/newgrf.cpp
#	src/newgrf_class_func.h
#	src/newgrf_object.h
#	src/newgrf_roadstop.cpp
#	src/newgrf_roadstop.h
#	src/object_gui.cpp
#	src/rail_gui.cpp
#	src/road_cmd.h
#	src/road_gui.cpp
#	src/station_cmd.h
#	src/strings.cpp
#	src/waypoint_cmd.h
This commit is contained in:
Jonathan G Rennison
2024-06-05 20:42:47 +01:00
22 changed files with 222 additions and 201 deletions

View File

@@ -2193,55 +2193,49 @@ static const char _initial_name_letters[] = {
'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W',
};
static void GenAndCoName(StringBuilder builder, uint32_t arg)
static std::span<const char * const> GetSurnameOptions()
{
const char * const *base;
uint num;
if (_settings_game.game_creation.landscape == LT_TOYLAND) return _silly_surname_list;
return _surname_list;
}
if (_settings_game.game_creation.landscape == LT_TOYLAND) {
base = _silly_surname_list;
num = lengthof(_silly_surname_list);
} else {
base = _surname_list;
num = lengthof(_surname_list);
}
/**
* Get the surname of the president with the given seed.
* @param seed The seed the surname was generated from.
* @return The surname.
*/
static const char *GetSurname(uint32_t seed)
{
auto surname_options = GetSurnameOptions();
return surname_options[surname_options.size() * GB(seed, 16, 8) >> 8];
}
builder += base[num * GB(arg, 16, 8) >> 8];
static void GenAndCoName(StringBuilder &builder, uint32_t seed)
{
builder += GetSurname(seed);
builder += " & Co.";
}
static void GenPresidentName(StringBuilder builder, uint32_t x)
static void GenPresidentName(StringBuilder builder, uint32_t seed)
{
char initial[] = "?. ";
const char * const *base;
uint num;
uint i;
builder += _initial_name_letters[std::size(_initial_name_letters) * GB(seed, 0, 8) >> 8];
builder += ". ";
initial[0] = _initial_name_letters[sizeof(_initial_name_letters) * GB(x, 0, 8) >> 8];
builder += initial;
i = (sizeof(_initial_name_letters) + 35) * GB(x, 8, 8) >> 8;
if (i < sizeof(_initial_name_letters)) {
initial[0] = _initial_name_letters[i];
builder += initial;
/* The second initial is optional. */
size_t index = (std::size(_initial_name_letters) + 35) * GB(seed, 8, 8) >> 8;
if (index < std::size(_initial_name_letters)) {
builder += _initial_name_letters[index];
builder += ". ";
}
if (_settings_game.game_creation.landscape == LT_TOYLAND) {
base = _silly_surname_list;
num = lengthof(_silly_surname_list);
} else {
base = _surname_list;
num = lengthof(_surname_list);
}
builder += base[num * GB(x, 16, 8) >> 8];
builder += GetSurname(seed);
}
static void GetSpecialNameString(StringBuilder builder, int ind, StringParameters &args)
{
switch (ind) {
case 1: // not used
builder += _silly_company_names[std::min<uint>(args.GetNextParameter<uint16_t>(), lengthof(_silly_company_names) - 1)];
builder += _silly_company_names[std::min<size_t>(args.GetNextParameter<uint16_t>(), std::size(_silly_company_names) - 1)];
return;
case 2: // used for Foobar & Co company names