Increase church/stadium count field size, fix save/load

Fix too many error message
pull/182/head
Jonathan G Rennison 4 years ago
parent 4a21fafd5c
commit 1fd9c929ef

@ -5295,6 +5295,7 @@ STR_ERROR_TOO_MANY_HOUSE_TYPES :{WHITE}... too
STR_ERROR_BUILDING_IS_TOO_OLD :{WHITE}... building is too old.
STR_ERROR_BUILDING_IS_TOO_MODERN :{WHITE}... building is too modern.
STR_ERROR_ONLY_ONE_BUILDING_ALLOWED_PER_TOWN :{WHITE}... only one building of this type is allowed in a town.
STR_ERROR_NO_MORE_BUILDINGS_ALLOWED_PER_TOWN :{WHITE}... too many buildings of this type in the town.
STR_ERROR_BUILDING_NOT_ALLOWED :{WHITE}... the building is not allowed.
# Industry related errors

@ -130,7 +130,8 @@ static const SaveLoad _town_desc[] = {
SLE_CONDSTR(Town, name, SLE_STR | SLF_ALLOW_CONTROL, 0, SLV_84, SL_MAX_VERSION),
SLE_VAR(Town, flags, SLE_UINT8),
SLE_CONDVAR_X(Town, church_count, SLE_UINT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_SPRINGPP)),
SLE_CONDVAR_X(Town, church_count, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TOWN_MULTI_BUILDING)),
SLE_CONDVAR_X(Town, stadium_count, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TOWN_MULTI_BUILDING)),
SLE_CONDVAR(Town, statues, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_104),
SLE_CONDVAR(Town, statues, SLE_UINT16, SLV_104, SL_MAX_VERSION),

@ -65,8 +65,8 @@ struct Town : TownPool::PoolItem<&_town_pool> {
mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the town, if not using a custom town name
byte flags; ///< See #TownFlags.
byte church_count; ///< Number of church buildings in the town.
byte stadium_count; ///< Number of stadium buildings in the town.
uint16 church_count; ///< Number of church buildings in the town.
uint16 stadium_count; ///< Number of stadium buildings in the town.
uint16 noise_reached; ///< level of noise that all the airports are generating

@ -2621,10 +2621,11 @@ static CommandCost CheckCanBuildHouse(HouseID house, const Town *t, bool manual)
}
/* Special houses that there can be only one of. */
bool multiple_buildings = (manual && _settings_client.scenario.multiple_buildings);
if (hs->building_flags & BUILDING_IS_CHURCH) {
if (t->church_count >= ((manual && _settings_client.scenario.multiple_buildings) ? 255 : 1)) return_cmd_error(STR_ERROR_ONLY_ONE_BUILDING_ALLOWED_PER_TOWN);
if (t->church_count >= (multiple_buildings ? UINT16_MAX : 1)) return_cmd_error(multiple_buildings ? STR_ERROR_NO_MORE_BUILDINGS_ALLOWED_PER_TOWN : STR_ERROR_ONLY_ONE_BUILDING_ALLOWED_PER_TOWN);
} else if (hs->building_flags & BUILDING_IS_STADIUM) {
if (t->stadium_count >= ((manual && _settings_client.scenario.multiple_buildings) ? 255 : 1)) return_cmd_error(STR_ERROR_ONLY_ONE_BUILDING_ALLOWED_PER_TOWN);
if (t->stadium_count >= (multiple_buildings ? UINT16_MAX : 1)) return_cmd_error(multiple_buildings ? STR_ERROR_NO_MORE_BUILDINGS_ALLOWED_PER_TOWN : STR_ERROR_ONLY_ONE_BUILDING_ALLOWED_PER_TOWN);
}
return CommandCost();

Loading…
Cancel
Save