Codechange: Iterate road/tram masks instead of checking each type. (#14716)

This commit is contained in:
Peter Nelson
2025-10-23 20:59:58 +01:00
committed by dP
parent e0f7fb74c4
commit 5b9dad4ac3
5 changed files with 27 additions and 41 deletions
+4 -16
View File
@@ -1291,26 +1291,14 @@ int CompanyServiceInterval(const Company *c, VehicleType type)
/**
* Get total sum of all owned road bits.
* @param rtt RoadTramType to get total for.
* @return Combined total road road bits.
*/
uint32_t CompanyInfrastructure::GetRoadTotal() const
uint32_t CompanyInfrastructure::GetRoadTramTotal(RoadTramType rtt) const
{
uint32_t total = 0;
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
if (RoadTypeIsRoad(rt)) total += this->road[rt];
}
return total;
}
/**
* Get total sum of all owned tram bits.
* @return Combined total of tram road bits.
*/
uint32_t CompanyInfrastructure::GetTramTotal() const
{
uint32_t total = 0;
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
if (RoadTypeIsTram(rt)) total += this->road[rt];
for (RoadType rt : GetMaskForRoadTramType(rtt)) {
total += this->road[rt];
}
return total;
}