|
@@ -13,12 +13,13 @@
|
|
|
#include "debug.h"
|
|
|
#include "3rdparty/md5/md5.h"
|
|
|
#include "newgrf.h"
|
|
|
#include "gamelog.h"
|
|
|
#include "network/network_func.h"
|
|
|
#include "gfx_func.h"
|
|
|
#include "newgrf_text.h"
|
|
|
|
|
|
#include "fileio_func.h"
|
|
|
#include "fios.h"
|
|
|
|
|
|
/**
|
|
|
* Create a new GRFConfig.
|
|
@@ -42,47 +43,47 @@ GRFConfig::GRFConfig(const GRFConfig &co
|
|
|
num_params(config.num_params),
|
|
|
windows_paletted(config.windows_paletted)
|
|
|
{
|
|
|
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 = strdup(config.filename);
|
|
|
if (config.name != NULL) this->name = strdup(config.name);
|
|
|
if (config.info != NULL) this->info = strdup(config.info);
|
|
|
this->name = DuplicateGRFText(config.name);
|
|
|
this->info = DuplicateGRFText(config.info);
|
|
|
if (config.error != NULL) this->error = new GRFError(*config.error);
|
|
|
}
|
|
|
|
|
|
/** Cleanup a GRFConfig object. */
|
|
|
GRFConfig::~GRFConfig()
|
|
|
{
|
|
|
/* GCF_COPY as in NOT strdupped/alloced the filename, name and info */
|
|
|
/* GCF_COPY as in NOT strdupped/alloced the filename and info */
|
|
|
if (!HasBit(this->flags, GCF_COPY)) {
|
|
|
free(this->filename);
|
|
|
free(this->name);
|
|
|
free(this->info);
|
|
|
CleanUpGRFText(this->info);
|
|
|
delete this->error;
|
|
|
}
|
|
|
CleanUpGRFText(this->name);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 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
|
|
|
{
|
|
|
if (StrEmpty(this->name)) return this->filename;
|
|
|
return this->name;
|
|
|
const char *name = GetGRFStringFromGRFText(this->name);
|
|
|
return StrEmpty(name) ? this->filename : name;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the grf info.
|
|
|
* @return A string with a description of this grf.
|
|
|
*/
|
|
|
const char *GRFConfig::GetDescription() const
|
|
|
{
|
|
|
return this->info;
|
|
|
return GetGRFStringFromGRFText(this->info);
|
|
|
}
|
|
|
|
|
|
GRFConfig *_all_grfs;
|
|
|
GRFConfig *_grfconfig;
|
|
|
GRFConfig *_grfconfig_newgame;
|
|
|
GRFConfig *_grfconfig_static;
|
|
@@ -346,14 +347,14 @@ compatible_grf:
|
|
|
* When the GCF_COPY flag is set, it is certain that the filename is
|
|
|
* already a local one, so there is no need to replace it. */
|
|
|
if (!HasBit(c->flags, GCF_COPY)) {
|
|
|
free(c->filename);
|
|
|
c->filename = strdup(f->filename);
|
|
|
memcpy(c->ident.md5sum, f->ident.md5sum, sizeof(c->ident.md5sum));
|
|
|
if (c->name == NULL && f->name != NULL) c->name = strdup(f->name);
|
|
|
if (c->info == NULL && f->info != NULL) c->info = strdup(f->info);
|
|
|
if (c->name == NULL) c->name = DuplicateGRFText(f->name);
|
|
|
if (c->info == NULL) c->info = DuplicateGRFText(f->info);
|
|
|
c->error = NULL;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|