mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
Codechange: Initialise specs with std::fill/std::copy instead of memset/memcpy.
This commit is contained in:
parent
d0c71f2a9e
commit
087654501b
@ -76,21 +76,16 @@ IndustryBuildData _industry_builder; ///< In-game manager of industries.
|
||||
*/
|
||||
void ResetIndustries()
|
||||
{
|
||||
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
||||
/* Reset the spec to default */
|
||||
if (i < lengthof(_origin_industry_specs)) {
|
||||
_industry_specs[i] = _origin_industry_specs[i];
|
||||
} else {
|
||||
_industry_specs[i] = IndustrySpec{};
|
||||
}
|
||||
auto industry_insert = std::copy(std::begin(_origin_industry_specs), std::end(_origin_industry_specs), std::begin(_industry_specs));
|
||||
std::fill(industry_insert, std::end(_industry_specs), IndustrySpec{});
|
||||
|
||||
for (IndustryType i = 0; i < lengthof(_origin_industry_specs); i++) {
|
||||
/* Enable only the current climate industries */
|
||||
_industry_specs[i].enabled = i < NEW_INDUSTRYOFFSET &&
|
||||
HasBit(_origin_industry_specs[i].climate_availability, _settings_game.game_creation.landscape);
|
||||
_industry_specs[i].enabled = HasBit(_industry_specs[i].climate_availability, _settings_game.game_creation.landscape);
|
||||
}
|
||||
|
||||
memset(&_industry_tile_specs, 0, sizeof(_industry_tile_specs));
|
||||
memcpy(&_industry_tile_specs, &_origin_industry_tile_specs, sizeof(_origin_industry_tile_specs));
|
||||
auto industry_tile_insert = std::copy(std::begin(_origin_industry_tile_specs), std::end(_origin_industry_tile_specs), std::begin(_industry_tile_specs));
|
||||
std::fill(industry_tile_insert, std::end(_industry_tile_specs), IndustryTileSpec{});
|
||||
|
||||
/* Reset any overrides that have been set. */
|
||||
_industile_mngr.ResetOverride();
|
||||
|
@ -152,9 +152,10 @@ bool AirportSpec::IsWithinMapBounds(byte table, TileIndex tile) const
|
||||
*/
|
||||
void AirportSpec::ResetAirports()
|
||||
{
|
||||
extern const AirportSpec _origin_airport_specs[];
|
||||
memset(&AirportSpec::specs, 0, sizeof(AirportSpec::specs));
|
||||
memcpy(&AirportSpec::specs, &_origin_airport_specs, sizeof(AirportSpec) * NEW_AIRPORT_OFFSET);
|
||||
extern const AirportSpec _origin_airport_specs[NEW_AIRPORT_OFFSET];
|
||||
|
||||
auto insert = std::copy(std::begin(_origin_airport_specs), std::end(_origin_airport_specs), std::begin(AirportSpec::specs));
|
||||
std::fill(insert, std::end(AirportSpec::specs), AirportSpec{});
|
||||
|
||||
_airport_mngr.ResetOverride();
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ AirportTileOverrideManager _airporttile_mngr(NEW_AIRPORTTILE_OFFSET, NUM_AIRPORT
|
||||
*/
|
||||
void AirportTileSpec::ResetAirportTiles()
|
||||
{
|
||||
memset(&AirportTileSpec::tiles, 0, sizeof(AirportTileSpec::tiles));
|
||||
memcpy(&AirportTileSpec::tiles, &_origin_airporttile_specs, sizeof(_origin_airporttile_specs));
|
||||
auto insert = std::copy(std::begin(_origin_airporttile_specs), std::end(_origin_airporttile_specs), std::begin(AirportTileSpec::tiles));
|
||||
std::fill(insert, std::end(AirportTileSpec::tiles), AirportTileSpec{});
|
||||
|
||||
/* Reset any overrides that have been set. */
|
||||
_airporttile_mngr.ResetOverride();
|
||||
|
@ -3834,8 +3834,8 @@ HouseSpec _house_specs[NUM_HOUSES];
|
||||
|
||||
void ResetHouses()
|
||||
{
|
||||
memset(&_house_specs, 0, sizeof(_house_specs));
|
||||
memcpy(&_house_specs, &_original_house_specs, sizeof(_original_house_specs));
|
||||
auto insert = std::copy(std::begin(_original_house_specs), std::end(_original_house_specs), std::begin(_house_specs));
|
||||
std::fill(insert, std::end(_house_specs), HouseSpec{});
|
||||
|
||||
/* Reset any overrides that have been set. */
|
||||
_house_mngr.ResetOverride();
|
||||
|
Loading…
Reference in New Issue
Block a user