mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::string over strecat to create the RV capacity string
parent
4fdde00e25
commit
b133328737
|
@ -41,7 +41,6 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||||
if (v->HasArticulatedPart()) {
|
if (v->HasArticulatedPart()) {
|
||||||
CargoArray max_cargo{};
|
CargoArray max_cargo{};
|
||||||
StringID subtype_text[NUM_CARGO];
|
StringID subtype_text[NUM_CARGO];
|
||||||
char capacity[512];
|
|
||||||
|
|
||||||
memset(subtype_text, 0, sizeof(subtype_text));
|
memset(subtype_text, 0, sizeof(subtype_text));
|
||||||
|
|
||||||
|
@ -53,23 +52,19 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetString(capacity, STR_VEHICLE_DETAILS_TRAIN_ARTICULATED_RV_CAPACITY, lastof(capacity));
|
std::string capacity = GetString(STR_VEHICLE_DETAILS_TRAIN_ARTICULATED_RV_CAPACITY);
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||||
if (max_cargo[i] > 0) {
|
if (max_cargo[i] > 0) {
|
||||||
char buffer[128];
|
if (!first) capacity += ", ";
|
||||||
|
|
||||||
SetDParam(0, i);
|
SetDParam(0, i);
|
||||||
SetDParam(1, max_cargo[i]);
|
SetDParam(1, max_cargo[i]);
|
||||||
GetString(buffer, STR_JUST_CARGO, lastof(buffer));
|
capacity += GetString(STR_JUST_CARGO);
|
||||||
|
|
||||||
if (!first) strecat(capacity, ", ", lastof(capacity));
|
|
||||||
strecat(capacity, buffer, lastof(capacity));
|
|
||||||
|
|
||||||
if (subtype_text[i] != 0) {
|
if (subtype_text[i] != 0) {
|
||||||
GetString(buffer, subtype_text[i], lastof(buffer));
|
capacity += GetString(subtype_text[i]);
|
||||||
strecat(capacity, buffer, lastof(capacity));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
|
|
Loading…
Reference in New Issue