Codechange: Use std::optional for GRF Parameter list.

This commit is contained in:
Peter Nelson
2023-05-18 12:19:51 +01:00
committed by PeterN
parent c51a7f629e
commit f14479d27d
4 changed files with 62 additions and 65 deletions

View File

@@ -8419,10 +8419,10 @@ static bool HandleParameterInfo(ByteReader *buf)
if (id >= _cur.grfconfig->param_info.size()) {
_cur.grfconfig->param_info.resize(id + 1);
}
if (_cur.grfconfig->param_info[id] == nullptr) {
_cur.grfconfig->param_info[id] = new GRFParameterInfo(id);
if (!_cur.grfconfig->param_info[id].has_value()) {
_cur.grfconfig->param_info[id] = GRFParameterInfo(id);
}
_cur_parameter = _cur.grfconfig->param_info[id];
_cur_parameter = &_cur.grfconfig->param_info[id].value();
/* Read all parameter-data and process each node. */
if (!HandleNodes(buf, _tags_parameters)) return false;
type = buf->ReadByte();