summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2014-05-24 19:13:34 +0000
committeralberth <alberth@openttd.org>2014-05-24 19:13:34 +0000
commit3c9d3f5ecd4c366369e033ba303dd52a2b32cc9c (patch)
tree1e14c1634471dddfc0f037ed98e6dff8074e8306
parentc1e7c32f070ff8f3aadb2373f543f58333740e70 (diff)
downloadopenttd-3c9d3f5ecd4c366369e033ba303dd52a2b32cc9c.tar.xz
(svn r26612) -Add: Method to copy newgrf parameters.
-rw-r--r--src/newgrf_config.cpp13
-rw-r--r--src/newgrf_config.h2
2 files changed, 14 insertions, 1 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 2b268183f..6b7b8c377 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -82,7 +82,7 @@ GRFConfig::GRFConfig(const GRFConfig &config) :
this->name->AddRef();
this->info->AddRef();
this->url->AddRef();
- if (config.error != NULL) this->error = new GRFError(*config.error);
+ if (config.error != NULL) this->error = new GRFError(*config.error);
for (uint i = 0; i < config.param_info.Length(); i++) {
if (config.param_info[i] == NULL) {
*this->param_info.Append() = NULL;
@@ -108,6 +108,17 @@ GRFConfig::~GRFConfig()
}
/**
+ * Copy the parameter information from the \a src config.
+ * @param src Source config.
+ */
+void GRFConfig::CopyParams(const GRFConfig &src)
+{
+ this->num_params = src.num_params;
+ this->num_valid_params = src.num_valid_params;
+ MemCpyT<uint32>(this->param, src.param, lengthof(this->param));
+}
+
+/**
* Get the name of this grf. In case the name isn't known
* the filename is returned.
* @return The name of filename of this grf.
diff --git a/src/newgrf_config.h b/src/newgrf_config.h
index 906f9620d..e19d8d608 100644
--- a/src/newgrf_config.h
+++ b/src/newgrf_config.h
@@ -177,6 +177,8 @@ struct GRFConfig : ZeroedMemoryAllocator {
struct GRFConfig *next; ///< NOSAVE: Next item in the linked list
+ void CopyParams(const GRFConfig &src);
+
bool IsOpenTTDBaseGRF() const;
const char *GetTextfile(TextfileType type) const;