Changeset - r21498:c603a3d7e3d7
[Not reviewed]
master
0 2 0
alberth - 10 years ago 2014-05-24 19:13:34
alberth@openttd.org
(svn r26612) -Add: Method to copy newgrf parameters.
2 files changed with 14 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf_config.cpp
Show inline comments
 
@@ -79,13 +79,13 @@ GRFConfig::GRFConfig(const GRFConfig &co
 
	MemCpyT<uint8>(this->original_md5sum, config.original_md5sum, lengthof(this->original_md5sum));
 
	MemCpyT<uint32>(this->param, config.param, lengthof(this->param));
 
	if (config.filename != NULL) this->filename = stredup(config.filename);
 
	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;
 
		} else {
 
			*this->param_info.Append() = new GRFParameterInfo(*config.param_info[i]);
 
		}
 
@@ -105,12 +105,23 @@ GRFConfig::~GRFConfig()
 
	this->url->Release();
 

	
 
	for (uint i = 0; i < this->param_info.Length(); i++) delete this->param_info[i];
 
}
 

	
 
/**
 
 * 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.
 
 */
 
const char *GRFConfig::GetName() const
 
{
src/newgrf_config.h
Show inline comments
 
@@ -174,12 +174,14 @@ struct GRFConfig : ZeroedMemoryAllocator
 
	uint8 palette;                                 ///< GRFPalette, bitset
 
	SmallVector<GRFParameterInfo *, 4> param_info; ///< NOSAVE: extra information about the parameters
 
	bool has_param_defaults;                       ///< NOSAVE: did this newgrf specify any defaults for it's parameters
 

	
 
	struct GRFConfig *next;                        ///< NOSAVE: Next item in the linked list
 

	
 
	void CopyParams(const GRFConfig &src);
 

	
 
	bool IsOpenTTDBaseGRF() const;
 

	
 
	const char *GetTextfile(TextfileType type) const;
 
	const char *GetName() const;
 
	const char *GetDescription() const;
 
	const char *GetURL() const;
0 comments (0 inline, 0 general)