mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-29 07:04:35 +01:00
Codechange: Iterate road/tram masks instead of checking each type. (#14716)
This commit is contained in:
@@ -965,14 +965,9 @@ RoadType GetTownRoadType()
|
||||
const RoadTypeInfo *best = nullptr;
|
||||
const uint16_t assume_max_speed = 50;
|
||||
|
||||
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
|
||||
if (RoadTypeIsTram(rt)) continue;
|
||||
|
||||
for (RoadType rt : GetMaskForRoadTramType(RTT_ROAD)) {
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
||||
|
||||
/* Unused road type. */
|
||||
if (rti->label == 0) continue;
|
||||
|
||||
/* Can town build this road. */
|
||||
if (!rti->flags.Test(RoadTypeFlag::TownBuild)) continue;
|
||||
|
||||
@@ -997,10 +992,9 @@ RoadType GetTownRoadType()
|
||||
static TimerGameCalendar::Date GetTownRoadTypeFirstIntroductionDate()
|
||||
{
|
||||
const RoadTypeInfo *best = nullptr;
|
||||
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
|
||||
if (RoadTypeIsTram(rt)) continue;
|
||||
for (RoadType rt : GetMaskForRoadTramType(RTT_ROAD)) {
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
||||
if (rti->label == 0) continue; // Unused road type.
|
||||
|
||||
if (!rti->flags.Test(RoadTypeFlag::TownBuild)) continue; // Town can't build this road type.
|
||||
|
||||
if (best != nullptr && rti->introduction_date >= best->introduction_date) continue;
|
||||
|
||||
Reference in New Issue
Block a user