From 7a739a87de8a710f7138ced22a2e8feff540475e Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 17 Sep 2019 21:14:58 +0100 Subject: [PATCH] Improve formatting of CompanyInfrastructure::Dump --- src/company_cmd.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 5173aba43f..ec3d805331 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -1187,12 +1187,18 @@ uint32 CompanyInfrastructure::GetTramTotal() const char *CompanyInfrastructure::Dump(char *buffer, const char *last) const { + uint rail_total = 0; for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) { if (rail[rt]) buffer += seprintf(buffer, last, "Rail: %s: %u\n", GetStringPtr(GetRailTypeInfo(rt)->strings.name), rail[rt]); + rail_total += rail[rt]; } + buffer += seprintf(buffer, last, "Total Rail: %u\n", rail_total); buffer += seprintf(buffer, last, "Signal: %u\n", signal); - buffer += seprintf(buffer, last, "Road: %u\n", road[ROADTYPE_ROAD]); - buffer += seprintf(buffer, last, "Tram: %u\n", road[ROADTYPE_TRAM]); + for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) { + if (road[rt]) buffer += seprintf(buffer, last, "%s: %s: %u\n", RoadTypeIsTram(rt) ? "Tram" : "Road", GetStringPtr(GetRoadTypeInfo(rt)->strings.name), road[rt]); + } + buffer += seprintf(buffer, last, "Total Road: %u\n", this->GetRoadTotal()); + buffer += seprintf(buffer, last, "Total Tram: %u\n", this->GetTramTotal()); buffer += seprintf(buffer, last, "Water: %u\n", water); buffer += seprintf(buffer, last, "Station: %u\n", station); buffer += seprintf(buffer, last, "Airport: %u\n", airport);