diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 2286e34a45..49af8ccf41 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -7191,7 +7191,7 @@ static void GRFLoadError(ByteReader *buf) } /* Only two parameter numbers can be used in the string. */ - for (uint i = 0; i < lengthof(error->param_value) && buf->HasData(); i++) { + for (uint i = 0; i < error->param_value.size() && buf->HasData(); i++) { uint param_number = buf->ReadByte(); error->param_value[i] = _cur.grffile->GetParam(param_number); } diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 235d49a73d..17b0ab6464 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -158,26 +158,10 @@ uint _missing_extra_graphics = 0; * @param severity The severity of this error. * @param message The actual error-string. */ -GRFError::GRFError(StringID severity, StringID message) : - message(message), - severity(severity), - param_value() +GRFError::GRFError(StringID severity, StringID message) : message(message), severity(severity) { } -/** - * Create a new GRFError that is a deep copy of an existing error message. - * @param error The GRFError object to make a copy of. - */ -GRFError::GRFError(const GRFError &error) : - custom_message(error.custom_message), - data(error.data), - message(error.message), - severity(error.severity) -{ - memcpy(this->param_value, error.param_value, sizeof(this->param_value)); -} - /** * Create a new empty GRFParameterInfo object. * @param nr The newgrf parameter that is changed. diff --git a/src/newgrf_config.h b/src/newgrf_config.h index bd8db85961..ef71e7e8d1 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -108,16 +108,12 @@ struct GRFIdentifier { /** Information about why GRF had problems during initialisation */ struct GRFError { GRFError(StringID severity, StringID message = 0); - GRFError(const GRFError &error); - - /* Remove the copy assignment, as the default implementation will not do the right thing. */ - GRFError &operator=(GRFError &rhs) = delete; std::string custom_message; ///< Custom message (if present) std::string data; ///< Additional data for message and custom_message StringID message; ///< Default message StringID severity; ///< Info / Warning / Error / Fatal - uint32 param_value[2]; ///< Values of GRF parameters to show for message and custom_message + std::array param_value; ///< Values of GRF parameters to show for message and custom_message }; /** The possible types of a newgrf parameter. */ diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index da26d62f36..ba6ffa307d 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -55,7 +55,7 @@ void ShowNewGRFError() SetDParamStr(2, c->error->custom_message); SetDParamStr(3, c->filename); SetDParamStr(4, c->error->data); - for (uint i = 0; i < lengthof(c->error->param_value); i++) { + for (uint i = 0; i < c->error->param_value.size(); i++) { SetDParam(5 + i, c->error->param_value[i]); } if (c->error->severity == STR_NEWGRF_ERROR_MSG_FATAL) { @@ -75,7 +75,7 @@ static void ShowNewGRFInfo(const GRFConfig *c, const Rect &r, bool show_params) SetDParamStr(0, c->error->custom_message); // is skipped by built-in messages SetDParamStr(1, c->filename); SetDParamStr(2, c->error->data); - for (uint i = 0; i < lengthof(c->error->param_value); i++) { + for (uint i = 0; i < c->error->param_value.size(); i++) { SetDParam(3 + i, c->error->param_value[i]); } GetString(message, c->error->message != STR_NULL ? c->error->message : STR_JUST_RAW_STRING, lastof(message));