mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
Codechange: Use less locals for station free names bitmask.
This commit is contained in:
parent
aeaa552385
commit
122bfa2afd
@ -257,9 +257,9 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Town *t = st->town;
|
const Town *t = st->town;
|
||||||
uint32_t free_names = UINT32_MAX;
|
|
||||||
|
|
||||||
StationNameInformation sni{};
|
StationNameInformation sni{};
|
||||||
|
sni.free_names = UINT32_MAX;
|
||||||
|
|
||||||
for (const Station *s : Station::Iterate()) {
|
for (const Station *s : Station::Iterate()) {
|
||||||
if (s != st && s->town == t) {
|
if (s != st && s->town == t) {
|
||||||
@ -280,13 +280,12 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
if (str == M(STR_SV_STNAME_FOREST)) {
|
if (str == M(STR_SV_STNAME_FOREST)) {
|
||||||
str = M(STR_SV_STNAME_WOODS);
|
str = M(STR_SV_STNAME_WOODS);
|
||||||
}
|
}
|
||||||
ClrBit(free_names, str);
|
ClrBit(sni.free_names, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TileIndex indtile = tile;
|
TileIndex indtile = tile;
|
||||||
sni.free_names = free_names;
|
|
||||||
if (CircularTileSearch(&indtile, 7, FindNearIndustryName, &sni)) {
|
if (CircularTileSearch(&indtile, 7, FindNearIndustryName, &sni)) {
|
||||||
/* An industry has been found nearby */
|
/* An industry has been found nearby */
|
||||||
IndustryType indtype = GetIndustryType(indtile);
|
IndustryType indtype = GetIndustryType(indtile);
|
||||||
@ -299,14 +298,13 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Oil rigs/mines name could be marked not free by looking for a near by industry. */
|
/* Oil rigs/mines name could be marked not free by looking for a near by industry. */
|
||||||
free_names = sni.free_names;
|
|
||||||
|
|
||||||
/* check default names */
|
/* check default names */
|
||||||
uint32_t tmp = free_names & _gen_station_name_bits[name_class];
|
uint32_t tmp = sni.free_names & _gen_station_name_bits[name_class];
|
||||||
if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp);
|
if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp);
|
||||||
|
|
||||||
/* check mine? */
|
/* check mine? */
|
||||||
if (HasBit(free_names, M(STR_SV_STNAME_MINES))) {
|
if (HasBit(sni.free_names, M(STR_SV_STNAME_MINES))) {
|
||||||
if (CountMapSquareAround(tile, CMSAMine) >= 2) {
|
if (CountMapSquareAround(tile, CMSAMine) >= 2) {
|
||||||
return STR_SV_STNAME_MINES;
|
return STR_SV_STNAME_MINES;
|
||||||
}
|
}
|
||||||
@ -314,20 +312,20 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
|
|
||||||
/* check close enough to town to get central as name? */
|
/* check close enough to town to get central as name? */
|
||||||
if (DistanceMax(tile, t->xy) < 8) {
|
if (DistanceMax(tile, t->xy) < 8) {
|
||||||
if (HasBit(free_names, M(STR_SV_STNAME))) return STR_SV_STNAME;
|
if (HasBit(sni.free_names, M(STR_SV_STNAME))) return STR_SV_STNAME;
|
||||||
|
|
||||||
if (HasBit(free_names, M(STR_SV_STNAME_CENTRAL))) return STR_SV_STNAME_CENTRAL;
|
if (HasBit(sni.free_names, M(STR_SV_STNAME_CENTRAL))) return STR_SV_STNAME_CENTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check lakeside */
|
/* Check lakeside */
|
||||||
if (HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
|
if (HasBit(sni.free_names, M(STR_SV_STNAME_LAKESIDE)) &&
|
||||||
DistanceFromEdge(tile) < 20 &&
|
DistanceFromEdge(tile) < 20 &&
|
||||||
CountMapSquareAround(tile, CMSAWater) >= 5) {
|
CountMapSquareAround(tile, CMSAWater) >= 5) {
|
||||||
return STR_SV_STNAME_LAKESIDE;
|
return STR_SV_STNAME_LAKESIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check woods */
|
/* Check woods */
|
||||||
if (HasBit(free_names, M(STR_SV_STNAME_WOODS)) && (
|
if (HasBit(sni.free_names, M(STR_SV_STNAME_WOODS)) && (
|
||||||
CountMapSquareAround(tile, CMSATree) >= 8 ||
|
CountMapSquareAround(tile, CMSATree) >= 8 ||
|
||||||
CountMapSquareAround(tile, IsTileForestIndustry) >= 2)
|
CountMapSquareAround(tile, IsTileForestIndustry) >= 2)
|
||||||
) {
|
) {
|
||||||
@ -338,9 +336,9 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
int z = GetTileZ(tile);
|
int z = GetTileZ(tile);
|
||||||
int z2 = GetTileZ(t->xy);
|
int z2 = GetTileZ(t->xy);
|
||||||
if (z < z2) {
|
if (z < z2) {
|
||||||
if (HasBit(free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY;
|
if (HasBit(sni.free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY;
|
||||||
} else if (z > z2) {
|
} else if (z > z2) {
|
||||||
if (HasBit(free_names, M(STR_SV_STNAME_HEIGHTS))) return STR_SV_STNAME_HEIGHTS;
|
if (HasBit(sni.free_names, M(STR_SV_STNAME_HEIGHTS))) return STR_SV_STNAME_HEIGHTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check direction compared to town */
|
/* check direction compared to town */
|
||||||
@ -351,7 +349,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
|
~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
|
||||||
};
|
};
|
||||||
|
|
||||||
free_names &= _direction_and_table[
|
sni.free_names &= _direction_and_table[
|
||||||
(TileX(tile) < TileX(t->xy)) +
|
(TileX(tile) < TileX(t->xy)) +
|
||||||
(TileY(tile) < TileY(t->xy)) * 2];
|
(TileY(tile) < TileY(t->xy)) * 2];
|
||||||
|
|
||||||
@ -371,8 +369,8 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
(1U << M(STR_SV_STNAME_LOWER))
|
(1U << M(STR_SV_STNAME_LOWER))
|
||||||
);
|
);
|
||||||
|
|
||||||
tmp = free_names & fallback_names;
|
sni.free_names &= fallback_names;
|
||||||
return (tmp == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME + FindFirstBit(tmp));
|
return (sni.free_names == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME + FindFirstBit(sni.free_names));
|
||||||
}
|
}
|
||||||
#undef M
|
#undef M
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user