1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-15 16:32:41 +01:00

Codechange: Use std::string for most of the user-settable custom names.

This commit is contained in:
Michael Lutz
2020-05-17 23:31:59 +02:00
parent 9b6f5e3bb8
commit 63ccb36ef3
41 changed files with 160 additions and 177 deletions

View File

@@ -1270,8 +1270,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Company *c = Company::GetIfValid(args->GetInt32());
if (c == nullptr) break;
if (c->name != nullptr) {
int64 args_array[] = {(int64)(size_t)c->name};
if (!c->name.empty()) {
int64 args_array[] = {(int64)(size_t)c->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1305,8 +1305,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
}
const Depot *d = Depot::Get(args->GetInt32());
if (d->name != nullptr) {
int64 args_array[] = {(int64)(size_t)d->name};
if (!d->name.empty()) {
int64 args_array[] = {(int64)(size_t)d->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1321,8 +1321,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Engine *e = Engine::GetIfValid(args->GetInt32(SCC_ENGINE_NAME));
if (e == nullptr) break;
if (e->name != nullptr && e->IsEnabled()) {
int64 args_array[] = {(int64)(size_t)e->name};
if (!e->name.empty() && e->IsEnabled()) {
int64 args_array[] = {(int64)(size_t)e->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1336,8 +1336,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Group *g = Group::GetIfValid(args->GetInt32());
if (g == nullptr) break;
if (g->name != nullptr) {
int64 args_array[] = {(int64)(size_t)g->name};
if (!g->name.empty()) {
int64 args_array[] = {(int64)(size_t)g->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1373,8 +1373,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Company *c = Company::GetIfValid(args->GetInt32(SCC_PRESIDENT_NAME));
if (c == nullptr) break;
if (c->president_name != nullptr) {
int64 args_array[] = {(int64)(size_t)c->president_name};
if (!c->president_name.empty()) {
int64 args_array[] = {(int64)(size_t)c->president_name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1398,8 +1398,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
break;
}
if (st->name != nullptr) {
int64 args_array[] = {(int64)(size_t)st->name};
if (!st->name.empty()) {
int64 args_array[] = {(int64)(size_t)st->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1428,8 +1428,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Town *t = Town::GetIfValid(args->GetInt32(SCC_TOWN_NAME));
if (t == nullptr) break;
if (t->name != nullptr) {
int64 args_array[] = {(int64)(size_t)t->name};
if (!t->name.empty()) {
int64 args_array[] = {(int64)(size_t)t->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1442,8 +1442,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
Waypoint *wp = Waypoint::GetIfValid(args->GetInt32(SCC_WAYPOINT_NAME));
if (wp == nullptr) break;
if (wp->name != nullptr) {
int64 args_array[] = {(int64)(size_t)wp->name};
if (!wp->name.empty()) {
int64 args_array[] = {(int64)(size_t)wp->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1460,8 +1460,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Vehicle *v = Vehicle::GetIfValid(args->GetInt32(SCC_VEHICLE_NAME));
if (v == nullptr) break;
if (v->name != nullptr) {
int64 args_array[] = {(int64)(size_t)v->name};
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 {
@@ -1486,8 +1486,8 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Sign *si = Sign::GetIfValid(args->GetInt32());
if (si == nullptr) break;
if (si->name != nullptr) {
int64 args_array[] = {(int64)(size_t)si->name};
if (!si->name.empty()) {
int64 args_array[] = {(int64)(size_t)si->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {