mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r22389) -Fix [FS#4600]: try to make sure there is an early house available in the current climate for every townzone, not just a single available house for all climates/townzones
This commit is contained in:
parent
0e1ac234d8
commit
abc2352537
|
@ -7602,6 +7602,33 @@ static bool IsHouseSpecValid(HouseSpec *hs, const HouseSpec *next1, const HouseS
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure there is at least one house available in the year 0 for the given
|
||||||
|
* climate / housezone combination.
|
||||||
|
* @param bitmask The climate and housezone to check for. Exactly one climate
|
||||||
|
* bit and one housezone bit should be set.
|
||||||
|
*/
|
||||||
|
static void EnsureEarlyHouse(HouseZones bitmask)
|
||||||
|
{
|
||||||
|
Year min_year = MAX_YEAR;
|
||||||
|
|
||||||
|
for (int i = 0; i < HOUSE_MAX; i++) {
|
||||||
|
HouseSpec *hs = HouseSpec::Get(i);
|
||||||
|
if (hs == NULL || !hs->enabled) continue;
|
||||||
|
if ((hs->building_availability & bitmask) != bitmask) continue;
|
||||||
|
if (hs->min_year < min_year) min_year = hs->min_year;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (min_year == 0) return;
|
||||||
|
|
||||||
|
for (int i = 0; i < HOUSE_MAX; i++) {
|
||||||
|
HouseSpec *hs = HouseSpec::Get(i);
|
||||||
|
if (hs == NULL || !hs->enabled) continue;
|
||||||
|
if ((hs->building_availability & bitmask) != bitmask) continue;
|
||||||
|
if (hs->min_year == min_year) hs->min_year = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all new houses to the house array. House properties can be set at any
|
* Add all new houses to the house array. House properties can be set at any
|
||||||
* time in the GRF file, so we can only add a house spec to the house array
|
* time in the GRF file, so we can only add a house spec to the house array
|
||||||
|
@ -7639,8 +7666,6 @@ static void FinaliseHouseArray()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Year min_year = MAX_YEAR;
|
|
||||||
|
|
||||||
for (int i = 0; i < HOUSE_MAX; i++) {
|
for (int i = 0; i < HOUSE_MAX; i++) {
|
||||||
HouseSpec *hs = HouseSpec::Get(i);
|
HouseSpec *hs = HouseSpec::Get(i);
|
||||||
const HouseSpec *next1 = (i + 1 < HOUSE_MAX ? HouseSpec::Get(i + 1) : NULL);
|
const HouseSpec *next1 = (i + 1 < HOUSE_MAX ? HouseSpec::Get(i + 1) : NULL);
|
||||||
|
@ -7658,17 +7683,22 @@ static void FinaliseHouseArray()
|
||||||
* building_flags to zero here to make sure any house following
|
* building_flags to zero here to make sure any house following
|
||||||
* this one in the pool is properly handled as 1x1 house. */
|
* this one in the pool is properly handled as 1x1 house. */
|
||||||
hs->building_flags = TILE_NO_FLAG;
|
hs->building_flags = TILE_NO_FLAG;
|
||||||
} else {
|
|
||||||
if (hs->min_year < min_year) min_year = hs->min_year;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min_year != 0) {
|
HouseZones climate_mask = (HouseZones)(1 << (_settings_game.game_creation.landscape + 12));
|
||||||
for (int i = 0; i < HOUSE_MAX; i++) {
|
EnsureEarlyHouse(HZ_ZON1 | climate_mask);
|
||||||
HouseSpec *hs = HouseSpec::Get(i);
|
EnsureEarlyHouse(HZ_ZON2 | climate_mask);
|
||||||
|
EnsureEarlyHouse(HZ_ZON3 | climate_mask);
|
||||||
|
EnsureEarlyHouse(HZ_ZON4 | climate_mask);
|
||||||
|
EnsureEarlyHouse(HZ_ZON5 | climate_mask);
|
||||||
|
|
||||||
if (hs->enabled && hs->min_year == min_year) hs->min_year = 0;
|
if (_settings_game.game_creation.landscape == LT_ARCTIC) {
|
||||||
}
|
EnsureEarlyHouse(HZ_ZON1 | HZ_SUBARTC_ABOVE);
|
||||||
|
EnsureEarlyHouse(HZ_ZON2 | HZ_SUBARTC_ABOVE);
|
||||||
|
EnsureEarlyHouse(HZ_ZON3 | HZ_SUBARTC_ABOVE);
|
||||||
|
EnsureEarlyHouse(HZ_ZON4 | HZ_SUBARTC_ABOVE);
|
||||||
|
EnsureEarlyHouse(HZ_ZON5 | HZ_SUBARTC_ABOVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue