Departure boards: Change long vehicle names to traditional if group also shown
This commit is contained in:
@@ -1932,18 +1932,26 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||
}
|
||||
|
||||
case SCC_VEHICLE_NAME: { // {VEHICLE}
|
||||
const Vehicle *v = Vehicle::GetIfValid(args->GetInt32(SCC_VEHICLE_NAME));
|
||||
uint32 id = (uint32)args->GetInt64(SCC_VEHICLE_NAME);
|
||||
uint8 vehicle_names = _settings_client.gui.vehicle_names;
|
||||
if (id & VEHICLE_NAME_NO_GROUP) {
|
||||
id &= ~VEHICLE_NAME_NO_GROUP;
|
||||
/* Change format from long to traditional */
|
||||
if (vehicle_names == 2) vehicle_names = 0;
|
||||
}
|
||||
|
||||
const Vehicle *v = Vehicle::GetIfValid(id);
|
||||
if (v == nullptr) break;
|
||||
|
||||
if (!v->name.empty()) {
|
||||
int64 args_array[] = {(int64)(size_t)v->name.c_str()};
|
||||
StringParameters tmp_params(args_array);
|
||||
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
|
||||
} else if (v->group_id != DEFAULT_GROUP && _settings_client.gui.vehicle_names != 0 && v->type < VEH_COMPANY_END) {
|
||||
} else if (v->group_id != DEFAULT_GROUP && vehicle_names != 0 && v->type < VEH_COMPANY_END) {
|
||||
/* The vehicle has no name, but is member of a group, so print group name */
|
||||
uint32 group_name = v->group_id;
|
||||
if (_settings_client.gui.show_vehicle_group_hierarchy_name) group_name |= GROUP_NAME_HIERARCHY;
|
||||
if (_settings_client.gui.vehicle_names == 1) {
|
||||
if (vehicle_names == 1) {
|
||||
int64 args_array[] = {group_name, v->unitnumber};
|
||||
StringParameters tmp_params(args_array);
|
||||
buff = GetStringWithArgs(buff, STR_FORMAT_GROUP_VEHICLE_NAME, &tmp_params, last);
|
||||
@@ -1958,7 +1966,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||
|
||||
StringID string_id;
|
||||
if (v->type < VEH_COMPANY_END) {
|
||||
string_id = ((_settings_client.gui.vehicle_names == 1) ? STR_SV_TRAIN_NAME : STR_TRADITIONAL_TRAIN_NAME) + v->type;
|
||||
string_id = ((vehicle_names == 1) ? STR_SV_TRAIN_NAME : STR_TRADITIONAL_TRAIN_NAME) + v->type;
|
||||
} else {
|
||||
string_id = STR_INVALID_VEHICLE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user