Changeset - r18637:6db0bce1fa51
[Not reviewed]
master
0 4 0
yexo - 12 years ago 2011-12-11 12:55:04
yexo@openttd.org
(svn r23494) -Feature: [NewGRF] action14 node INFO->URL_ to add an url
4 files changed with 27 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/network/network_udp.cpp
Show inline comments
 
@@ -421,6 +421,9 @@ void ClientNetworkUDPSocketHandler::Hand
 
		config->info->Release();
 
		config->info = f->info;
 
		config->info->AddRef();
 
		config->url->Release();
 
		config->url = f->url;
 
		config->url->AddRef();
 
	}
 
	SetBit(config->flags, GCF_COPY);
 
}
src/newgrf.cpp
Show inline comments
 
@@ -7065,6 +7065,13 @@ static bool ChangeGRFDescription(byte la
 
	return true;
 
}
 

	
 
/** Callback function for 'INFO'->'URL_' to set the newgrf url. */
 
static bool ChangeGRFURL(byte langid, const char *str)
 
{
 
	AddGRFTextToList(&_cur.grfconfig->url->text, langid, _cur.grfconfig->ident.grfid, false, str);
 
	return true;
 
}
 

	
 
/** Callback function for 'INFO'->'NPAR' to set the number of valid parameters. */
 
static bool ChangeGRFNumUsedParams(size_t len, ByteReader *buf)
 
{
 
@@ -7412,6 +7419,7 @@ static bool HandleParameterInfo(ByteRead
 
AllowedSubtags _tags_info[] = {
 
	AllowedSubtags('NAME', ChangeGRFName),
 
	AllowedSubtags('DESC', ChangeGRFDescription),
 
	AllowedSubtags('URL_', ChangeGRFURL),
 
	AllowedSubtags('NPAR', ChangeGRFNumUsedParams),
 
	AllowedSubtags('PALS', ChangeGRFPalette),
 
	AllowedSubtags('BLTR', ChangeGRFBlitter),
src/newgrf_config.cpp
Show inline comments
 
@@ -44,11 +44,13 @@ GRFTextWrapper::~GRFTextWrapper()
 
GRFConfig::GRFConfig(const char *filename) :
 
	name(new GRFTextWrapper()),
 
	info(new GRFTextWrapper()),
 
	url(new GRFTextWrapper()),
 
	num_valid_params(lengthof(param))
 
{
 
	if (filename != NULL) this->filename = strdup(filename);
 
	this->name->AddRef();
 
	this->info->AddRef();
 
	this->url->AddRef();
 
}
 

	
 
/**
 
@@ -60,6 +62,7 @@ GRFConfig::GRFConfig(const GRFConfig &co
 
	ident(config.ident),
 
	name(config.name),
 
	info(config.info),
 
	url(config.url),
 
	version(config.version),
 
	min_loadable_version(config.min_loadable_version),
 
	flags(config.flags & ~(1 << GCF_COPY)),
 
@@ -75,6 +78,7 @@ GRFConfig::GRFConfig(const GRFConfig &co
 
	if (config.filename != NULL) this->filename = strdup(config.filename);
 
	this->name->AddRef();
 
	this->info->AddRef();
 
	this->url->AddRef();
 
	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) {
 
@@ -95,6 +99,7 @@ GRFConfig::~GRFConfig()
 
	}
 
	this->name->Release();
 
	this->info->Release();
 
	this->url->Release();
 

	
 
	for (uint i = 0; i < this->param_info.Length(); i++) delete this->param_info[i];
 
}
 
@@ -119,6 +124,15 @@ const char *GRFConfig::GetDescription() 
 
	return GetGRFStringFromGRFText(this->info->text);
 
}
 

	
 
/**
 
 * Get the grf url.
 
 * @return A string with an url of this grf.
 
 */
 
const char *GRFConfig::GetURL() const
 
{
 
	return GetGRFStringFromGRFText(this->url->text);
 
}
 

	
 
/** Set the default value for all parameters as specified by action14. */
 
void GRFConfig::SetParameterDefaults()
 
{
src/newgrf_config.h
Show inline comments
 
@@ -169,6 +169,7 @@ struct GRFConfig : ZeroedMemoryAllocator
 
	char *filename;                                ///< Filename - either with or without full path
 
	GRFTextWrapper *name;                          ///< NOSAVE: GRF name (Action 0x08)
 
	GRFTextWrapper *info;                          ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
 
	GRFTextWrapper *url;                           ///< NOSAVE: URL belonging to this GRF.
 
	GRFError *error;                               ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B)
 

	
 
	uint32 version;                                ///< NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown
 
@@ -190,6 +191,7 @@ struct GRFConfig : ZeroedMemoryAllocator
 
	const char *GetTextfile(TextfileType type) const;
 
	const char *GetName() const;
 
	const char *GetDescription() const;
 
	const char *GetURL() const;
 

	
 
	void SetParameterDefaults();
 
	void SetSuitablePalette();
0 comments (0 inline, 0 general)