Codechange: Use std::array for industry tile cargo acceptance. (#11498)

This avoids use of memcpy/memset to copy or fill.
This commit is contained in:
Peter Nelson
2023-11-27 23:17:55 +00:00
committed by GitHub
parent f268c90bd3
commit e5aed24395
3 changed files with 14 additions and 16 deletions

View File

@@ -3295,12 +3295,12 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr
case 0x13: { // variable length cargo acceptance
byte num_cargoes = buf->ReadByte();
if (num_cargoes > lengthof(tsp->acceptance)) {
if (num_cargoes > std::size(tsp->acceptance)) {
GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
error->param_value[1] = prop;
return CIR_DISABLED;
}
for (uint i = 0; i < lengthof(tsp->acceptance); i++) {
for (uint i = 0; i < std::size(tsp->acceptance); i++) {
if (i < num_cargoes) {
tsp->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
/* Tile acceptance can be negative to counteract the INDTILE_SPECIAL_ACCEPTS_ALL_CARGO flag */