Codechange: Use std::string for storing GRF error messages.

This commit is contained in:
Michael Lutz
2020-05-17 23:31:54 +02:00
parent c082f570ce
commit 9c2e47d03c
4 changed files with 24 additions and 33 deletions

View File

@@ -179,7 +179,8 @@ uint _missing_extra_graphics = 0;
*/
GRFError::GRFError(StringID severity, StringID message) :
message(message),
severity(severity)
severity(severity),
param_value()
{
}
@@ -188,23 +189,14 @@ GRFError::GRFError(StringID severity, StringID message) :
* @param error The GRFError object to make a copy of.
*/
GRFError::GRFError(const GRFError &error) :
ZeroedMemoryAllocator(),
custom_message(error.custom_message),
data(error.data),
message(error.message),
severity(error.severity)
{
if (error.custom_message != nullptr) this->custom_message = stredup(error.custom_message);
if (error.data != nullptr) this->data = stredup(error.data);
memcpy(this->param_value, error.param_value, sizeof(this->param_value));
}
GRFError::~GRFError()
{
free(this->custom_message);
free(this->data);
}
/**
* Create a new empty GRFParameterInfo object.
* @param nr The newgrf parameter that is changed.